toolroll 0.9.140 → 0.9.142

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 (152) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/attest.js +1 -1
  3. package/dist/browser/{chunk-agents-live-view.9f4367c89c6366769a567e729ac9181ccaa898bf3a168d3dc618f3cface887c7.js → chunk-agents-live-view.1b1c797cec2734229d36186796ae378527a7b5f7aa936897671a6c1f3a8cb19a.js} +5 -5
  4. package/dist/browser/chunk-agents-live-view.1b1c797cec2734229d36186796ae378527a7b5f7aa936897671a6c1f3a8cb19a.js.br +0 -0
  5. package/dist/browser/chunk-agents-live-view.1b1c797cec2734229d36186796ae378527a7b5f7aa936897671a6c1f3a8cb19a.js.gz +0 -0
  6. package/dist/browser/chunk-bundle.089b2471028b3dcf578cb4363ea4757738b28eda5459e6194f92707364033cd7.js +2 -0
  7. package/dist/browser/chunk-bundle.089b2471028b3dcf578cb4363ea4757738b28eda5459e6194f92707364033cd7.js.br +0 -0
  8. package/dist/browser/chunk-bundle.089b2471028b3dcf578cb4363ea4757738b28eda5459e6194f92707364033cd7.js.gz +0 -0
  9. package/dist/browser/chunk-chat-parts.51c73684050c98bc25724e417e4180981c14590934bb37fd9a1617942a7d32d3.js +4 -0
  10. package/dist/browser/chunk-chat-parts.51c73684050c98bc25724e417e4180981c14590934bb37fd9a1617942a7d32d3.js.br +0 -0
  11. package/dist/browser/chunk-chat-parts.51c73684050c98bc25724e417e4180981c14590934bb37fd9a1617942a7d32d3.js.gz +0 -0
  12. package/dist/browser/{chunk-core.5490609e81c3a5f78da3e06b9795d71c287016ebc7fd02794b1122b474ebb07f.js → chunk-core.6128decfe528d89de1445dc1ec36e9f13dabd76eba61d13310fc1302db2252eb.js} +11 -11
  13. package/dist/browser/chunk-core.6128decfe528d89de1445dc1ec36e9f13dabd76eba61d13310fc1302db2252eb.js.br +0 -0
  14. package/dist/browser/chunk-core.6128decfe528d89de1445dc1ec36e9f13dabd76eba61d13310fc1302db2252eb.js.gz +0 -0
  15. package/dist/browser/{chunk-flow-view.f5d74c7f072b739a7a0ed86ff35cafa7b8a041233372d1eeaab9eb941ddfc11e.js → chunk-flow-view.f9a4db9db350a9311ce5b11e9358c6e7de4ad9b3cd7a1f058e6c78eedee6dec6.js} +1 -1
  16. package/dist/browser/chunk-flow-view.f9a4db9db350a9311ce5b11e9358c6e7de4ad9b3cd7a1f058e6c78eedee6dec6.js.br +0 -0
  17. package/dist/browser/chunk-flow-view.f9a4db9db350a9311ce5b11e9358c6e7de4ad9b3cd7a1f058e6c78eedee6dec6.js.gz +0 -0
  18. package/dist/browser/{chunk-flows-extra-view.01ebf93780b729363eda11ba21c764fe593bcd3e684aa833c9b86147f780fd41.js → chunk-flows-extra-view.3151cd05656fd35f80588863c323b4799b6b1f0060243ec8bc9b5da94d8d6052.js} +1 -1
  19. package/dist/browser/chunk-flows-extra-view.3151cd05656fd35f80588863c323b4799b6b1f0060243ec8bc9b5da94d8d6052.js.br +0 -0
  20. package/dist/browser/chunk-flows-extra-view.3151cd05656fd35f80588863c323b4799b6b1f0060243ec8bc9b5da94d8d6052.js.gz +0 -0
  21. package/dist/browser/chunk-more-views.70ab484b8f1f1ebc31c3c27061a88c86607d86bb9bc34d277b57f3f4fa0ce291.js +2 -0
  22. package/dist/browser/chunk-more-views.70ab484b8f1f1ebc31c3c27061a88c86607d86bb9bc34d277b57f3f4fa0ce291.js.br +0 -0
  23. package/dist/browser/chunk-more-views.70ab484b8f1f1ebc31c3c27061a88c86607d86bb9bc34d277b57f3f4fa0ce291.js.gz +0 -0
  24. package/dist/browser/{chunk-pages-bundle.e18059f0cb4fbb63e3698971d4c1830ad0945c3645235babc93010cd0b725c1d.js → chunk-pages-bundle.3b596e7529dfb499a536353c9095d0b9a8255e5b7f782211c22aced869905bb0.js} +1 -1
  25. package/dist/browser/chunk-pages-bundle.3b596e7529dfb499a536353c9095d0b9a8255e5b7f782211c22aced869905bb0.js.br +0 -0
  26. package/dist/browser/chunk-pages-bundle.3b596e7529dfb499a536353c9095d0b9a8255e5b7f782211c22aced869905bb0.js.gz +0 -0
  27. package/dist/browser/chunk-result-view.f319cf5973ad4c9e7e495e00e77070ec242da669f87f848d52878e223ba87343.js +2 -0
  28. package/dist/browser/chunk-result-view.f319cf5973ad4c9e7e495e00e77070ec242da669f87f848d52878e223ba87343.js.br +0 -0
  29. package/dist/browser/chunk-result-view.f319cf5973ad4c9e7e495e00e77070ec242da669f87f848d52878e223ba87343.js.gz +0 -0
  30. package/dist/browser/chunk-settings-view.653e09ec0c7cce54c68ae7e968cc015c774fb6fa6e1493fd9f5423281d1e24fe.js +20 -0
  31. package/dist/browser/chunk-settings-view.653e09ec0c7cce54c68ae7e968cc015c774fb6fa6e1493fd9f5423281d1e24fe.js.br +0 -0
  32. package/dist/browser/chunk-settings-view.653e09ec0c7cce54c68ae7e968cc015c774fb6fa6e1493fd9f5423281d1e24fe.js.gz +0 -0
  33. package/dist/browser/chunk-shared.0c0231ce259937612ec120a251373e6b63f68c37fa031567570a9cfd6d6b2eef.js +2 -0
  34. package/dist/browser/chunk-shared.0c0231ce259937612ec120a251373e6b63f68c37fa031567570a9cfd6d6b2eef.js.br +0 -0
  35. package/dist/browser/chunk-shared.0c0231ce259937612ec120a251373e6b63f68c37fa031567570a9cfd6d6b2eef.js.gz +0 -0
  36. package/dist/browser/{chunk-shared.02c0b692de21a9bb80d1761aa887d8532431171945c02e663884c9f45b796753.js → chunk-shared.1bdbb9b057d17e95221becb4ed515b546d671390e4a817a6e72a799480fe14ad.js} +1 -1
  37. package/dist/browser/chunk-shared.1bdbb9b057d17e95221becb4ed515b546d671390e4a817a6e72a799480fe14ad.js.br +0 -0
  38. package/dist/browser/chunk-shared.1bdbb9b057d17e95221becb4ed515b546d671390e4a817a6e72a799480fe14ad.js.gz +0 -0
  39. package/dist/browser/{chunk-shared.c3e5be1c5f441e94905a4bc2005d816d2a0b0e4108bae43e37ec274a911c6847.js → chunk-shared.2d678087d03dcf2430b5bf48656220dbff5fb622188004aae7a76e0e5e5d18f8.js} +1 -1
  40. package/dist/browser/chunk-shared.2d678087d03dcf2430b5bf48656220dbff5fb622188004aae7a76e0e5e5d18f8.js.br +0 -0
  41. package/dist/browser/chunk-shared.2d678087d03dcf2430b5bf48656220dbff5fb622188004aae7a76e0e5e5d18f8.js.gz +0 -0
  42. package/dist/browser/{chunk-shared.6d0b8728b3e309886cfb6eaf596d3f20592939e521bb60bb090824f34da6b086.js → chunk-shared.66f18526381931b1ff69c090bad48c408a035a0d256bcff19b19b51ea988612a.js} +1 -1
  43. package/dist/browser/chunk-shared.66f18526381931b1ff69c090bad48c408a035a0d256bcff19b19b51ea988612a.js.br +0 -0
  44. package/dist/browser/chunk-shared.66f18526381931b1ff69c090bad48c408a035a0d256bcff19b19b51ea988612a.js.gz +0 -0
  45. package/dist/browser/{chunk-shared.0874336833f8101a63b169d8c2e55ca0f281e43e65d4bd6604555c791ea9dd87.js → chunk-shared.782659379fb982a9c2606c051bb711fd0fe38a547b8b4f4620cf2d14a832df25.js} +1 -1
  46. package/dist/browser/chunk-shared.782659379fb982a9c2606c051bb711fd0fe38a547b8b4f4620cf2d14a832df25.js.br +0 -0
  47. package/dist/browser/chunk-shared.782659379fb982a9c2606c051bb711fd0fe38a547b8b4f4620cf2d14a832df25.js.gz +0 -0
  48. package/dist/browser/{chunk-shared.d1f25785c8c168cc75aa99c4be8ca56abfc5eafa3490f8817ff15e61cb901915.js → chunk-shared.8940b7334ec79bcd25cb8e2d41958eecfe71d31340cf8de3c3d99f813cd126af.js} +1 -1
  49. package/dist/browser/chunk-shared.8940b7334ec79bcd25cb8e2d41958eecfe71d31340cf8de3c3d99f813cd126af.js.br +0 -0
  50. package/dist/browser/chunk-shared.8940b7334ec79bcd25cb8e2d41958eecfe71d31340cf8de3c3d99f813cd126af.js.gz +0 -0
  51. package/dist/browser/{chunk-shared.26bb0114998968cccb7bae5f6ffa8979ddecfafd8bc18bb6985760f6bcc030e6.js → chunk-shared.a7e4c6f386cee4623300b0d1b471260a09e05f6e236d56c7814dffc06088fb5c.js} +1 -1
  52. package/dist/browser/chunk-shared.a7e4c6f386cee4623300b0d1b471260a09e05f6e236d56c7814dffc06088fb5c.js.br +0 -0
  53. package/dist/browser/chunk-shared.a7e4c6f386cee4623300b0d1b471260a09e05f6e236d56c7814dffc06088fb5c.js.gz +0 -0
  54. package/dist/browser/{chunk-shared.fd5f2699d3b0017797e5b5e1e1d92eb98818740ebf20a95364bbb7deea0c8242.js → chunk-shared.c9025f6af91453ae8672099cb32126c5967384f769d10c662908e35c31b62478.js} +3 -3
  55. package/dist/browser/chunk-shared.c9025f6af91453ae8672099cb32126c5967384f769d10c662908e35c31b62478.js.br +0 -0
  56. package/dist/browser/chunk-shared.c9025f6af91453ae8672099cb32126c5967384f769d10c662908e35c31b62478.js.gz +0 -0
  57. package/dist/browser/{chunk-sonner.2472e1da55de10b11dc002c80a840966061e817c47793f5e216f1af6c6dbedff.js → chunk-sonner.76904479204cc1375093ccf9b2d60309bf4fb25e41bd0f0523b254404d9a4a11.js} +1 -1
  58. package/dist/browser/chunk-sonner.76904479204cc1375093ccf9b2d60309bf4fb25e41bd0f0523b254404d9a4a11.js.br +0 -0
  59. package/dist/browser/chunk-sonner.76904479204cc1375093ccf9b2d60309bf4fb25e41bd0f0523b254404d9a4a11.js.gz +0 -0
  60. package/dist/browser/chunk-task-view.6fcf84b20eddbbedc54103ca36c5c245ce6e7ccbb161ae0bef4b27027064b771.js +2 -0
  61. package/dist/browser/chunk-task-view.6fcf84b20eddbbedc54103ca36c5c245ce6e7ccbb161ae0bef4b27027064b771.js.br +0 -0
  62. package/dist/browser/chunk-task-view.6fcf84b20eddbbedc54103ca36c5c245ce6e7ccbb161ae0bef4b27027064b771.js.gz +0 -0
  63. package/dist/browser/chunk-team-chat.4cea27fe351f9ce5344da7c4b87240da49394496c12dc95f9e0de0590bb0d720.js +2 -0
  64. package/dist/browser/chunk-team-chat.4cea27fe351f9ce5344da7c4b87240da49394496c12dc95f9e0de0590bb0d720.js.br +0 -0
  65. package/dist/browser/chunk-team-chat.4cea27fe351f9ce5344da7c4b87240da49394496c12dc95f9e0de0590bb0d720.js.gz +0 -0
  66. package/dist/browser/manifest.json +204 -189
  67. package/dist/browser/{workspace.aebb60d4e5ef4509a80cfaccf0af5f7246867ec7531a1734dd8e28c59594950e.js → workspace.1bd4819cccc49c2c8208df3c1d31e13d3df426ecea80e734ac284cea47b49459.js} +2 -2
  68. package/dist/browser/workspace.1bd4819cccc49c2c8208df3c1d31e13d3df426ecea80e734ac284cea47b49459.js.br +0 -0
  69. package/dist/browser/workspace.1bd4819cccc49c2c8208df3c1d31e13d3df426ecea80e734ac284cea47b49459.js.gz +0 -0
  70. package/dist/browser-lazy-parts.js +1 -1
  71. package/dist/build-review.js +3 -2
  72. package/dist/builder.js +4 -3
  73. package/dist/chat-actions.js +2 -2
  74. package/dist/code-map-acts.js +1 -1
  75. package/dist/code-map-admission.js +2 -2
  76. package/dist/code-map-cli.js +2 -2
  77. package/dist/companion/push.js +3 -3
  78. package/dist/contracts/chat-actions.js +1 -1
  79. package/dist/contracts/console-api.js +1 -1
  80. package/dist/dispose.js +1 -1
  81. package/dist/lead-contract.js +1 -1
  82. package/dist/lead-doors.js +2 -2
  83. package/dist/local-owner.js +1 -1
  84. package/dist/operate.js +22 -13
  85. package/dist/owner-mode.js +2 -2
  86. package/dist/planner.js +1 -1
  87. package/dist/project-knowledge.js +1 -1
  88. package/dist/push-line.js +1 -0
  89. package/dist/push.js +1 -1
  90. package/dist/review-switch.js +1 -1
  91. package/dist/runner.js +2 -2
  92. package/dist/server/pages-assets.js +2 -2
  93. package/dist/server/route-table.js +1 -1
  94. package/dist/server/settings.js +2 -2
  95. package/dist/server/task-view-data.js +2 -2
  96. package/dist/server/task-views.js +1 -1
  97. package/dist/sqlite-telemetry.js +1 -1
  98. package/dist/ssr-workspace.js +86 -86
  99. package/dist/store.js +2 -2
  100. package/dist/surface.js +1 -1
  101. package/dist/toolroll-update.js +2 -2
  102. package/dist/work-reads.js +1 -1
  103. package/package.json +1 -1
  104. package/dist/browser/chunk-agents-live-view.9f4367c89c6366769a567e729ac9181ccaa898bf3a168d3dc618f3cface887c7.js.br +0 -0
  105. package/dist/browser/chunk-agents-live-view.9f4367c89c6366769a567e729ac9181ccaa898bf3a168d3dc618f3cface887c7.js.gz +0 -0
  106. package/dist/browser/chunk-bundle.ac5952c82c76e2efcdcf5a097c4fa235d6f1045dcc36d02ee921ff4be976a46a.js +0 -2
  107. package/dist/browser/chunk-bundle.ac5952c82c76e2efcdcf5a097c4fa235d6f1045dcc36d02ee921ff4be976a46a.js.br +0 -0
  108. package/dist/browser/chunk-bundle.ac5952c82c76e2efcdcf5a097c4fa235d6f1045dcc36d02ee921ff4be976a46a.js.gz +0 -0
  109. package/dist/browser/chunk-chat-parts.2a0b0b723508c5c48379f6a3d441f07a18c8b91ed64fd018962931c5ae43331e.js +0 -4
  110. package/dist/browser/chunk-chat-parts.2a0b0b723508c5c48379f6a3d441f07a18c8b91ed64fd018962931c5ae43331e.js.br +0 -0
  111. package/dist/browser/chunk-chat-parts.2a0b0b723508c5c48379f6a3d441f07a18c8b91ed64fd018962931c5ae43331e.js.gz +0 -0
  112. package/dist/browser/chunk-core.5490609e81c3a5f78da3e06b9795d71c287016ebc7fd02794b1122b474ebb07f.js.br +0 -0
  113. package/dist/browser/chunk-core.5490609e81c3a5f78da3e06b9795d71c287016ebc7fd02794b1122b474ebb07f.js.gz +0 -0
  114. package/dist/browser/chunk-flow-view.f5d74c7f072b739a7a0ed86ff35cafa7b8a041233372d1eeaab9eb941ddfc11e.js.br +0 -0
  115. package/dist/browser/chunk-flow-view.f5d74c7f072b739a7a0ed86ff35cafa7b8a041233372d1eeaab9eb941ddfc11e.js.gz +0 -0
  116. package/dist/browser/chunk-flows-extra-view.01ebf93780b729363eda11ba21c764fe593bcd3e684aa833c9b86147f780fd41.js.br +0 -0
  117. package/dist/browser/chunk-flows-extra-view.01ebf93780b729363eda11ba21c764fe593bcd3e684aa833c9b86147f780fd41.js.gz +0 -0
  118. package/dist/browser/chunk-pages-bundle.e18059f0cb4fbb63e3698971d4c1830ad0945c3645235babc93010cd0b725c1d.js.br +0 -0
  119. package/dist/browser/chunk-pages-bundle.e18059f0cb4fbb63e3698971d4c1830ad0945c3645235babc93010cd0b725c1d.js.gz +0 -0
  120. package/dist/browser/chunk-result-view.fc6a6494b316aa786807b7d17035c59defae1bfb0c03bf9c3795679b3a35dd77.js +0 -2
  121. package/dist/browser/chunk-result-view.fc6a6494b316aa786807b7d17035c59defae1bfb0c03bf9c3795679b3a35dd77.js.br +0 -0
  122. package/dist/browser/chunk-result-view.fc6a6494b316aa786807b7d17035c59defae1bfb0c03bf9c3795679b3a35dd77.js.gz +0 -0
  123. package/dist/browser/chunk-settings-view.6dd3a64ded7bd8c047650270918dfb455c9a514a5a40b84c7eb5f443f76fe66f.js +0 -20
  124. package/dist/browser/chunk-settings-view.6dd3a64ded7bd8c047650270918dfb455c9a514a5a40b84c7eb5f443f76fe66f.js.br +0 -0
  125. package/dist/browser/chunk-settings-view.6dd3a64ded7bd8c047650270918dfb455c9a514a5a40b84c7eb5f443f76fe66f.js.gz +0 -0
  126. package/dist/browser/chunk-shared.02c0b692de21a9bb80d1761aa887d8532431171945c02e663884c9f45b796753.js.br +0 -0
  127. package/dist/browser/chunk-shared.02c0b692de21a9bb80d1761aa887d8532431171945c02e663884c9f45b796753.js.gz +0 -0
  128. package/dist/browser/chunk-shared.0874336833f8101a63b169d8c2e55ca0f281e43e65d4bd6604555c791ea9dd87.js.br +0 -0
  129. package/dist/browser/chunk-shared.0874336833f8101a63b169d8c2e55ca0f281e43e65d4bd6604555c791ea9dd87.js.gz +0 -0
  130. package/dist/browser/chunk-shared.2413dd78f32995fbca67f51ac8c21baf4727cd64f185ea739aa2a058e569b0ed.js +0 -2
  131. package/dist/browser/chunk-shared.2413dd78f32995fbca67f51ac8c21baf4727cd64f185ea739aa2a058e569b0ed.js.br +0 -0
  132. package/dist/browser/chunk-shared.2413dd78f32995fbca67f51ac8c21baf4727cd64f185ea739aa2a058e569b0ed.js.gz +0 -0
  133. package/dist/browser/chunk-shared.26bb0114998968cccb7bae5f6ffa8979ddecfafd8bc18bb6985760f6bcc030e6.js.br +0 -0
  134. package/dist/browser/chunk-shared.26bb0114998968cccb7bae5f6ffa8979ddecfafd8bc18bb6985760f6bcc030e6.js.gz +0 -0
  135. package/dist/browser/chunk-shared.6d0b8728b3e309886cfb6eaf596d3f20592939e521bb60bb090824f34da6b086.js.br +0 -0
  136. package/dist/browser/chunk-shared.6d0b8728b3e309886cfb6eaf596d3f20592939e521bb60bb090824f34da6b086.js.gz +0 -0
  137. package/dist/browser/chunk-shared.c3e5be1c5f441e94905a4bc2005d816d2a0b0e4108bae43e37ec274a911c6847.js.br +0 -0
  138. package/dist/browser/chunk-shared.c3e5be1c5f441e94905a4bc2005d816d2a0b0e4108bae43e37ec274a911c6847.js.gz +0 -0
  139. package/dist/browser/chunk-shared.d1f25785c8c168cc75aa99c4be8ca56abfc5eafa3490f8817ff15e61cb901915.js.br +0 -0
  140. package/dist/browser/chunk-shared.d1f25785c8c168cc75aa99c4be8ca56abfc5eafa3490f8817ff15e61cb901915.js.gz +0 -0
  141. package/dist/browser/chunk-shared.fd5f2699d3b0017797e5b5e1e1d92eb98818740ebf20a95364bbb7deea0c8242.js.br +0 -0
  142. package/dist/browser/chunk-shared.fd5f2699d3b0017797e5b5e1e1d92eb98818740ebf20a95364bbb7deea0c8242.js.gz +0 -0
  143. package/dist/browser/chunk-sonner.2472e1da55de10b11dc002c80a840966061e817c47793f5e216f1af6c6dbedff.js.br +0 -0
  144. package/dist/browser/chunk-sonner.2472e1da55de10b11dc002c80a840966061e817c47793f5e216f1af6c6dbedff.js.gz +0 -0
  145. package/dist/browser/chunk-task-view.bbeddc793a5e8a6d1f66b6cc5f0ce1da18414137e85c49ccd07be0e20f61ac12.js +0 -2
  146. package/dist/browser/chunk-task-view.bbeddc793a5e8a6d1f66b6cc5f0ce1da18414137e85c49ccd07be0e20f61ac12.js.br +0 -0
  147. package/dist/browser/chunk-task-view.bbeddc793a5e8a6d1f66b6cc5f0ce1da18414137e85c49ccd07be0e20f61ac12.js.gz +0 -0
  148. package/dist/browser/chunk-team-chat.c3255a5a1d94e39d559c07438c4690543602b1552b2c2bf57b8791d7f989141d.js +0 -2
  149. package/dist/browser/chunk-team-chat.c3255a5a1d94e39d559c07438c4690543602b1552b2c2bf57b8791d7f989141d.js.br +0 -0
  150. package/dist/browser/chunk-team-chat.c3255a5a1d94e39d559c07438c4690543602b1552b2c2bf57b8791d7f989141d.js.gz +0 -0
  151. package/dist/browser/workspace.aebb60d4e5ef4509a80cfaccf0af5f7246867ec7531a1734dd8e28c59594950e.js.br +0 -0
  152. package/dist/browser/workspace.aebb60d4e5ef4509a80cfaccf0af5f7246867ec7531a1734dd8e28c59594950e.js.gz +0 -0
@@ -1,5 +1,5 @@
1
1
  /*! Third-party notices: /assets/THIRD_PARTY_NOTICES.txt */
2
- import{a as Me}from"./chunk-shared.b664b4e2524d0f293cecbb854f7479a13c2494fbabcef45232900bf7235f4ae0.js";import{c as Da}from"./chunk-shared.26bb0114998968cccb7bae5f6ffa8979ddecfafd8bc18bb6985760f6bcc030e6.js";import{p6$a as Ks,p6$b as zs}from"./chunk-core.5490609e81c3a5f78da3e06b9795d71c287016ebc7fd02794b1122b474ebb07f.js";import"./chunk-shared.c3e5be1c5f441e94905a4bc2005d816d2a0b0e4108bae43e37ec274a911c6847.js";import"./chunk-shared.fd5f2699d3b0017797e5b5e1e1d92eb98818740ebf20a95364bbb7deea0c8242.js";import{p9$a as Xs,p9$b as Vs,p9$c as Zs,p9$d as Js,p9$e as Qs,p9$f as eo,p9$g as to,p9$h as no,p9$i as ao}from"./chunk-core.5490609e81c3a5f78da3e06b9795d71c287016ebc7fd02794b1122b474ebb07f.js";import"./chunk-shared.6d0b8728b3e309886cfb6eaf596d3f20592939e521bb60bb090824f34da6b086.js";import{p7$a as oo,p7$b as lo,p7$c as io,p7$d as uo,p7$e as co,p7$f as po,p7$g as fo,p7$h as mo,p7$i as ho,p7$j as go}from"./chunk-core.5490609e81c3a5f78da3e06b9795d71c287016ebc7fd02794b1122b474ebb07f.js";import{p8$a as bo,p8$b as wo,p8$c as yo,p8$d as jo,p8$e as ko,p8$f as $o,p8$g as No,p8$h as So,p8$i as Eo,p8$j as Co,p8$k as Ro,p8$l as Do,p8$m as Io,p8$n as Ao,p8$o as Oo,p8$p as Po,p8$q as To,p8$r as Mo,p8$s as Lo,p8$t as Fo}from"./chunk-core.5490609e81c3a5f78da3e06b9795d71c287016ebc7fd02794b1122b474ebb07f.js";import"./chunk-shared.0874336833f8101a63b169d8c2e55ca0f281e43e65d4bd6604555c791ea9dd87.js";import"./chunk-shared.d1f25785c8c168cc75aa99c4be8ca56abfc5eafa3490f8817ff15e61cb901915.js";import{p10$A as Bo,p10$B as Wo,p10$C as Ho,p10$D as qo,p10$E as Ko,p10$F as zo,p10$G as Yo,p10$H as Go,p10$I as Xo,p10$J as Vo,p10$a as Zo,p10$b as Jo,p10$c as Qo,p10$d as el,p10$e as tl,p10$f as nl,p10$g as al,p10$h as rl,p10$i as sl,p10$j as ol,p10$k as ll,p10$l as il,p10$m as dl,p10$n as ul,p10$o as cl,p10$p as pl,p10$q as fl,p10$r as ml,p10$s as hl,p10$t as gl,p10$u as xl,p10$v as vl,p10$w as bl,p10$x as wl,p10$y as yl,p10$z as jl}from"./chunk-core.5490609e81c3a5f78da3e06b9795d71c287016ebc7fd02794b1122b474ebb07f.js";import{p11$a as Nl,p11$b as Sl}from"./chunk-core.5490609e81c3a5f78da3e06b9795d71c287016ebc7fd02794b1122b474ebb07f.js";import{p1$$ as Rl,p1$$a as Dl,p1$$b as Il,p1$A as Al,p1$Aa as ht,p1$Ab as Ol,p1$B as Pl,p1$Ba as Tl,p1$Bb as Ml,p1$C as Ll,p1$Ca as Fl,p1$Cb as _l,p1$D as Ul,p1$Da as Bl,p1$Db as Wl,p1$E as Hl,p1$Ea as ql,p1$Eb as Kl,p1$F as zl,p1$Fa as Yl,p1$Fb as Gl,p1$G as Xl,p1$Ga as Vl,p1$Gb as Zl,p1$H as Ve,p1$Ha as Jl,p1$Hb as Ql,p1$I as ei,p1$Ia as ti,p1$Ib as ni,p1$J as ai,p1$Ja as ri,p1$Jb as si,p1$K as oi,p1$Ka as li,p1$Kb as ii,p1$L as di,p1$La as ui,p1$Lb as ci,p1$M as pi,p1$Ma as fi,p1$Mb as mi,p1$N as hi,p1$Na as gi,p1$Nb as xi,p1$O as vi,p1$Oa as bi,p1$Ob as wi,p1$P as yi,p1$Pa as en,p1$Pb as ji,p1$Q as ki,p1$Qa as $i,p1$Qb as Ni,p1$R as Si,p1$Ra as Ei,p1$Rb as Ci,p1$S as Ri,p1$Sa as Di,p1$Sb as Ii,p1$T as Ai,p1$Ta as tn,p1$Tb as Oi,p1$U as Pi,p1$Ua as Ti,p1$Ub as Mi,p1$V as Li,p1$Va as Fi,p1$Vb as _i,p1$W as Ui,p1$Wa as Bi,p1$Wb as Wi,p1$X as Hi,p1$Xa as qi,p1$Xb as Be,p1$Y as Ki,p1$Ya as zi,p1$Yb as Yi,p1$Z as Gi,p1$Za as Xi,p1$Zb as Vi,p1$_ as Zi,p1$_a as Ji,p1$_b as Qi,p1$a as K,p1$aa as ed,p1$ab as td,p1$ac as nd,p1$b as ad,p1$ba as rd,p1$bb as sd,p1$bc as od,p1$c as We,p1$ca as ld,p1$cb as Ze,p1$cc as id,p1$d as nn,p1$da as dd,p1$db as ud,p1$dc as cd,p1$e as pd,p1$ea as fd,p1$eb as md,p1$ec as hd,p1$f as an,p1$fa as gd,p1$fb as xd,p1$fc as vd,p1$g as we,p1$ga as bd,p1$gb as wd,p1$gc as rn,p1$h as sn,p1$ha as yd,p1$hb as jd,p1$hc as on,p1$i as kd,p1$ia as $d,p1$ib as ln,p1$ic as Nd,p1$j as Sd,p1$ja as Ed,p1$jb as Cd,p1$jc as Rd,p1$k as Dd,p1$ka as Id,p1$kb as Ad,p1$kc as dn,p1$l as Od,p1$la as Pd,p1$lb as Td,p1$lc as Md,p1$m as Ld,p1$ma as Fd,p1$mb as _d,p1$mc as Ud,p1$n as Bd,p1$na as Wd,p1$nb as Hd,p1$nc as qd,p1$o as Kd,p1$oa as zd,p1$ob as Yd,p1$p as Gd,p1$pa as Xd,p1$pb as Vd,p1$q as Zd,p1$qa as Jd,p1$qb as Qd,p1$r as eu,p1$ra as tu,p1$rb as nu,p1$s as au,p1$sa as ru,p1$sb as su,p1$t as ou,p1$ta as lu,p1$tb as iu,p1$u as du,p1$ua as uu,p1$ub as cu,p1$v as pu,p1$va as fu,p1$vb as mu,p1$w as hu,p1$wa as gu,p1$wb as xu,p1$x as vu,p1$xa as bu,p1$xb as wu,p1$y as yu,p1$ya as ju,p1$yb as ku,p1$z as $u,p1$za as Nu,p1$zb as Su}from"./chunk-core.5490609e81c3a5f78da3e06b9795d71c287016ebc7fd02794b1122b474ebb07f.js";import{p2$a as Ru,p2$b as O,p2$c as L,p2$d as un,p2$e as xe}from"./chunk-core.5490609e81c3a5f78da3e06b9795d71c287016ebc7fd02794b1122b474ebb07f.js";var Y=O(L(),1),Ia=Object.defineProperty,Le=(e,t)=>Ia(e,"name",{value:t,configurable:!0}),On=!!(typeof window<"u"&&window.document&&window.document.createElement);function be(e,t,{checkForDefaultPrevented:n=!0}={}){return Le(function(a){if(e?.(a),n===!1||!a||!a.defaultPrevented)return t?.(a)},"handleEvent")}Le(be,"composeEventHandlers");function Aa(e){if(!On)throw new Error("Cannot access window outside of the DOM");return e?.ownerDocument?.defaultView??window}Le(Aa,"getOwnerWindow");function $t(e){if(!On)throw new Error("Cannot access document outside of the DOM");return e?.ownerDocument??document}Le($t,"getOwnerDocument");function Pn(e,t=!1){let{activeElement:n}=$t(e);if(!n?.nodeName)return null;if(Tn(n)&&n.contentDocument)return Pn(n.contentDocument.body,t);if(t){let a=n.getAttribute("aria-activedescendant");if(a){let o=$t(n).getElementById(a);if(o)return o}}return n}Le(Pn,"getActiveElement");function Tn(e){return e.tagName==="IFRAME"}Le(Tn,"isFrame");var pe=O(L(),1),Mn=O(xe(),1),Oa=Object.defineProperty,ee=(e,t)=>Oa(e,"name",{value:t,configurable:!0});function Pa(e,t){let n=pe.createContext(t);n.displayName=e+"Context";let a=ee(s=>{let{children:i,...l}=s,d=pe.useMemo(()=>l,Object.values(l));return(0,Mn.jsx)(n.Provider,{value:d,children:i})},"Provider");a.displayName=e+"Provider";function o(s,i={}){let{optional:l=!1}=i,d=pe.useContext(n);if(d)return d;if(t!==void 0)return t;if(!l)throw new Error(`\`${s}\` must be used within \`${e}\``)}return ee(o,"useContext"),[a,o]}ee(Pa,"createContext");function Ln(e,t=[]){let n=[];function a(s,i){let l=pe.createContext(i);l.displayName=s+"Context";let d=n.length;n=[...n,i];let h=ee(m=>{let{scope:g,children:p,...v}=m,f=g?.[e]?.[d]||l,x=pe.useMemo(()=>v,Object.values(v));return(0,Mn.jsx)(f.Provider,{value:x,children:p})},"Provider");h.displayName=s+"Provider";function c(m,g,p={}){let{optional:v=!1}=p,f=g?.[e]?.[d]||l,x=pe.useContext(f);if(x)return x;if(i!==void 0)return i;if(!v)throw new Error(`\`${m}\` must be used within \`${s}\``)}return ee(c,"useContext"),[h,c]}ee(a,"createContext");let o=ee(()=>{let s=n.map(i=>pe.createContext(i));return ee(function(i){let l=i?.[e]||s;return pe.useMemo(()=>({[`__scope${e}`]:{...i,[e]:l}}),[i,l])},"useScope")},"createScope");return o.scopeName=e,[a,Fn(o,...t)]}ee(Ln,"createContextScope");function Fn(...e){let t=e[0];if(e.length===1)return t;let n=ee(()=>{let a=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return ee(function(o){let s=a.reduce((i,{useScope:l,scopeName:d})=>{let h=l(o)[`__scope${d}`];return{...i,...h}},{});return pe.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}ee(Fn,"composeContextScopes");var _n=O(L(),1),Ta=O(L(),1),ke=globalThis?.document?Ta.useLayoutEffect:()=>{},Ma=Object.defineProperty,La=(e,t)=>Ma(e,"name",{value:t,configurable:!0}),Fa=_n[" useId ".trim().toString()]||(()=>{}),_a=0;function nt(e){let[t,n]=_n.useState(Fa());return ke(()=>{e||n(a=>a??String(_a++))},[e]),e||(t?`radix-${t}`:"")}La(nt,"useId");var ve=O(L(),1),Un=!1,ye=O(L(),1),ot=O(L(),1),Ua=Object.defineProperty,Ba=(e,t)=>Ua(e,"name",{value:t,configurable:!0}),cn=ot[" useEffectEvent ".trim().toString()],pn=ot[" useInsertionEffect ".trim().toString()];function Bn(e){if(typeof cn=="function")return cn(e);let t=ot.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof pn=="function"?pn(()=>{t.current=e}):ke(()=>{t.current=e}),ot.useMemo(()=>((...n)=>t.current?.(...n)),[])}Ba(Bn,"useEffectEvent");var Wa=Object.defineProperty,Ye=(e,t)=>Wa(e,"name",{value:t,configurable:!0}),Ha=ve[" useInsertionEffect ".trim().toString()]||ke;function Wn({prop:e,defaultProp:t,onChange:n=Ye(()=>{},"onChange"),caller:a}){let[o,s,i]=Hn({defaultProp:t,onChange:n}),l=e!==void 0,d=l?e:o;if(Un){let c=ve.useRef(e!==void 0);ve.useEffect(()=>{let m=c.current;m!==l&&console.warn(`${a} is changing from ${m?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),c.current=l},[l,a])}let h=ve.useCallback(c=>{if(l){let m=qn(c)?c(e):c;m!==e&&i.current?.(m)}else s(c)},[l,e,s,i]);return[d,h]}Ye(Wn,"useControllableState");function Hn({defaultProp:e,onChange:t}){let[n,a]=ve.useState(e),o=ve.useRef(n),s=ve.useRef(t);return Ha(()=>{s.current=t},[t]),ve.useEffect(()=>{o.current!==n&&(s.current?.(n),o.current=n)},[n,o]),[n,a,s]}Ye(Hn,"useUncontrolledState");function qn(e){return typeof e=="function"}Ye(qn,"isFunction");var fn=Symbol("RADIX:SYNC_STATE");function qa(e,t,n,a){let{prop:o,defaultProp:s,onChange:i,caller:l}=t,d=o!==void 0,h=Bn(i);if(Un){let x=ye.useRef(o!==void 0);ye.useEffect(()=>{let N=x.current;N!==d&&console.warn(`${l} is changing from ${N?"controlled":"uncontrolled"} to ${d?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),x.current=d},[d,l])}let c=[{...n,state:s}];a&&c.push(a);let[m,g]=ye.useReducer((x,N)=>{if(N.type===fn)return{...x,state:N.state};let w=e(x,N);return d&&!Object.is(w.state,x.state)&&h(w.state),w},...c),p=m.state,v=ye.useRef(p);ye.useEffect(()=>{v.current!==p&&(v.current=p,d||h(p))},[p,v,d]);let f=ye.useMemo(()=>o!==void 0?{...m,state:o}:m,[m,o]);return ye.useEffect(()=>{d&&!Object.is(o,m.state)&&g({type:fn,state:o})},[o,m.state,d]),[f,g]}Ye(qa,"useControllableStateReducer");var F=O(L(),1),gt=O(L(),1),Ka=Object.defineProperty,za=(e,t)=>Ka(e,"name",{value:t,configurable:!0});function Pe(e){let t=gt.useRef(e);return gt.useEffect(()=>{t.current=e}),gt.useMemo(()=>((...n)=>t.current?.(...n)),[])}za(Pe,"useCallbackRef");var Ya=O(xe(),1),Ga=Object.defineProperty,z=(e,t)=>Ga(e,"name",{value:t,configurable:!0}),Nt="dismissableLayer.update",Xa="dismissableLayer.pointerDownOutside",Va="dismissableLayer.focusOutside",mn,Kn=F.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Za=F.forwardRef(z(function(e,t){let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:a=!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:i,onInteractOutside:l,onDismiss:d,...h}=e,c=F.useContext(Kn),[m,g]=F.useState(null),p=m?.ownerDocument??globalThis?.document,[,v]=F.useState({}),f=We(t,g),x=Array.from(c.layers),[N]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),w=N?x.indexOf(N):-1,j=m?x.indexOf(m):-1,C=c.layersWithOutsidePointerEventsDisabled.size>0,D=j>=w,E=F.useRef(!1),P=Yn(I=>{s?.(I),l?.(I),I.defaultPrevented||d?.()},{ownerDocument:p,deferPointerDownOutside:a,isDeferredPointerDownOutsideRef:E,dismissableSurfaces:c.dismissableSurfaces,shouldHandlePointerDownOutside:F.useCallback(I=>{if(!(I instanceof Node))return!1;let Z=[...c.branches].some(he=>he.contains(I));return D&&!Z},[c.branches,D])}),H=Gn(I=>{if(a&&E.current)return;let Z=I.target;[...c.branches].some(he=>he.contains(Z))||(i?.(I),l?.(I),I.defaultPrevented||d?.())},p),Q=m?j===x.length-1:!1,M=Pe(I=>{I.key==="Escape"&&(o?.(I),!I.defaultPrevented&&d&&(I.preventDefault(),d()))});return F.useEffect(()=>{if(Q)return p.addEventListener("keydown",M,{capture:!0}),()=>p.removeEventListener("keydown",M,{capture:!0})},[p,Q,M]),F.useEffect(()=>{if(m)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(mn=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(m)),c.layers.add(m),St(),()=>{n&&(c.layersWithOutsidePointerEventsDisabled.delete(m),c.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=mn))}},[m,p,n,c]),F.useEffect(()=>()=>{m&&(c.layers.delete(m),c.layersWithOutsidePointerEventsDisabled.delete(m),St())},[m,c]),F.useEffect(()=>{let I=z(()=>v({}),"handleUpdate");return document.addEventListener(Nt,I),()=>document.removeEventListener(Nt,I)},[]),(0,Ya.jsx)(we.div,{...h,ref:f,style:{pointerEvents:C?D?"auto":"none":void 0,...e.style},onFocusCapture:be(e.onFocusCapture,H.onFocusCapture),onBlurCapture:be(e.onBlurCapture,H.onBlurCapture),onPointerDownCapture:be(e.onPointerDownCapture,P.onPointerDownCapture)})},"DismissableLayer"));function zn(){let e=F.useContext(Kn),[t,n]=F.useState(null);return F.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}z(zn,"useDismissableLayerSurface");var Ja=z(()=>!0,"IS_TRUE");function Yn(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:a=!1,isDeferredPointerDownOutsideRef:o,dismissableSurfaces:s,shouldHandlePointerDownOutside:i=Ja}=t,l=Pe(e),d=F.useRef(!1),h=F.useRef(!1),c=F.useRef(new Map),m=F.useRef(()=>{});return F.useEffect(()=>{function g(){h.current=!1,o.current=!1,c.current.clear()}z(g,"resetOutsideInteraction");function p(){return Array.from(c.current.values()).some(Boolean)}z(p,"isOutsideInteractionIntercepted");function v(j){if(!h.current)return;let C=j.target;C instanceof Node&&[...s].some(D=>D.contains(C))||c.current.set(j.type,!0),j.type==="click"&&window.setTimeout(()=>{h.current&&m.current()},0)}z(v,"handleInteractionCapture");function f(j){h.current&&c.current.set(j.type,!1)}z(f,"handleInteractionBubble");let x=z(j=>{if(j.target&&!d.current){let D=function(){n.removeEventListener("click",m.current);let P=p();g(),P||Mt(Xa,l,E,{discrete:!0})};var C=D;if(z(D,"handleAndDispatchPointerDownOutsideEvent"),!i(j.target)){n.removeEventListener("click",m.current),g(),d.current=!1;return}let E={originalEvent:j};h.current=!0,o.current=a&&j.button===0,c.current.clear(),!a||j.button!==0?D():(n.removeEventListener("click",m.current),m.current=D,n.addEventListener("click",m.current,{once:!0}))}else n.removeEventListener("click",m.current),g();d.current=!1},"handlePointerDown"),N=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(let j of N)n.addEventListener(j,v,!0),n.addEventListener(j,f);let w=window.setTimeout(()=>{n.addEventListener("pointerdown",x)},0);return()=>{window.clearTimeout(w),n.removeEventListener("pointerdown",x),n.removeEventListener("click",m.current);for(let j of N)n.removeEventListener(j,v,!0),n.removeEventListener(j,f)}},[n,l,a,o,s,i]),{onPointerDownCapture:z(()=>d.current=!0,"onPointerDownCapture")}}z(Yn,"usePointerDownOutside");function Gn(e,t=globalThis?.document){let n=Pe(e),a=F.useRef(!1);return F.useEffect(()=>{let o=z(s=>{s.target&&!a.current&&Mt(Va,n,{originalEvent:s},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:z(()=>a.current=!0,"onFocusCapture"),onBlurCapture:z(()=>a.current=!1,"onBlurCapture")}}z(Gn,"useFocusOutside");function St(){let e=new CustomEvent(Nt);document.dispatchEvent(e)}z(St,"dispatchUpdate");function Mt(e,t,n,{discrete:a}){let o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),a?sn(o,s):o.dispatchEvent(s)}z(Mt,"handleAndDispatchCustomEvent");var je=O(L(),1),Qa=O(xe(),1),er=Object.defineProperty,J=(e,t)=>er(e,"name",{value:t,configurable:!0}),xt="focusScope.autoFocusOnMount",vt="focusScope.autoFocusOnUnmount",hn={bubbles:!1,cancelable:!0},tr=je.forwardRef(J(function(e,t){let{loop:n=!1,trapped:a=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[l,d]=je.useState(null),h=Pe(o),c=Pe(s),m=je.useRef(null),g=We(t,d),p=je.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;je.useEffect(()=>{if(a){let w=function(E){if(p.paused||!l)return;let P=E.target;l.contains(P)?m.current=P:ce(m.current,{select:!0})},j=function(E){if(p.paused||!l)return;let P=E.relatedTarget;P!==null&&(l.contains(P)||ce(m.current,{select:!0}))},C=function(E){if(document.activeElement===document.body)for(let P of E)P.removedNodes.length>0&&ce(l)};var f=w,x=j,N=C;J(w,"handleFocusIn"),J(j,"handleFocusOut"),J(C,"handleMutations"),document.addEventListener("focusin",w),document.addEventListener("focusout",j);let D=new MutationObserver(C);return l&&D.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",j),D.disconnect()}}},[a,l,p.paused]),je.useEffect(()=>{if(l){gn.add(p);let f=document.activeElement;if(!l.contains(f)){let x=new CustomEvent(xt,hn);l.addEventListener(xt,h),l.dispatchEvent(x),x.defaultPrevented||(Xn(ea(Lt(l)),{select:!0}),document.activeElement===f&&ce(l))}return()=>{l.removeEventListener(xt,h),setTimeout(()=>{let x=new CustomEvent(vt,hn);l.addEventListener(vt,c),l.dispatchEvent(x),x.defaultPrevented||ce(f??document.body,{select:!0}),l.removeEventListener(vt,c),gn.remove(p)},0)}}},[l,h,c,p]);let v=je.useCallback(f=>{if(!n&&!a||p.paused)return;let x=f.key==="Tab"&&!f.altKey&&!f.ctrlKey&&!f.metaKey,N=document.activeElement;if(x&&N){let w=f.currentTarget,[j,C]=Vn(w);j&&C?!f.shiftKey&&N===C?(f.preventDefault(),n&&ce(j,{select:!0})):f.shiftKey&&N===j&&(f.preventDefault(),n&&ce(C,{select:!0})):N===w&&f.preventDefault()}},[n,a,p.paused]);return(0,Qa.jsx)(we.div,{tabIndex:-1,...i,ref:g,onKeyDown:v})},"FocusScope"));function Xn(e,{select:t=!1}={}){let n=document.activeElement;for(let a of e)if(ce(a,{select:t}),document.activeElement!==n)return}J(Xn,"focusFirst");function Vn(e){let t=Lt(e),n=Et(t,e),a=Et(t.reverse(),e);return[n,a]}J(Vn,"getTabbableEdges");function Lt(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:J(a=>{let o=a.tagName==="INPUT"&&a.type==="hidden";return a.disabled||a.hidden||o?NodeFilter.FILTER_SKIP:a.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}J(Lt,"getTabbableCandidates");function Et(e,t){let n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(let a of e)if(!(n?!a.checkVisibility({checkVisibilityCSS:!0}):Zn(a,{upTo:t})))return a}J(Et,"findVisible");function Zn(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}J(Zn,"isHidden");function Jn(e){return e instanceof HTMLInputElement&&"select"in e}J(Jn,"isSelectableInput");function ce(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Jn(e)&&t&&e.select()}}J(ce,"focus");var gn=Qn();function Qn(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=Ct(e,t),e.unshift(t)},remove(t){e=Ct(e,t),e[0]?.resume()}}}J(Qn,"createFocusScopesStack");function Ct(e,t){let n=[...e],a=n.indexOf(t);return a!==-1&&n.splice(a,1),n}J(Ct,"arrayRemove");function ea(e){return e.filter(t=>t.tagName!=="A")}J(ea,"removeLinks");var xn=O(L(),1),nr=O(un(),1),ar=O(xe(),1),rr=Object.defineProperty,sr=(e,t)=>rr(e,"name",{value:t,configurable:!0}),or=xn.forwardRef(sr(function(e,t){let{container:n,...a}=e,[o,s]=xn.useState(!1);ke(()=>s(!0),[]);let i=n||o&&globalThis?.document?.body;return i?nr.createPortal((0,ar.jsx)(we.div,{...a,ref:t}),i):null},"Portal")),ae=O(L(),1),lr=O(L(),1),ir=Object.defineProperty,fe=(e,t)=>ir(e,"name",{value:t,configurable:!0});function ta(e,t){return lr.useReducer((n,a)=>t[n][a]??n,e)}fe(ta,"useStateMachine");var Ft=fe(e=>{let{present:t,children:n}=e,a=na(t),o=typeof n=="function"?n({present:a.isPresent}):ae.Children.only(n),s=aa(a.ref,ra(o));return typeof n=="function"||a.isPresent?ae.cloneElement(o,{ref:s}):null},"Presence");function na(e){let[t,n]=ae.useState(),a=ae.useRef(null),o=ae.useRef(e),s=ae.useRef("none"),i=ae.useRef(void 0),l=e?"mounted":"unmounted",[d,h]=ta(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return ae.useEffect(()=>{d==="mounted"?(s.current=i.current??Ie(a.current),i.current=void 0):s.current="none"},[d]),ke(()=>{let c=a.current,m=o.current;if(m!==e){let g=s.current,p=Ie(c);e?(i.current=p,h("MOUNT")):p==="none"||c?.display==="none"?h("UNMOUNT"):h(m&&g!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,h]),ke(()=>{if(t){let c,m=t.ownerDocument.defaultView??window,g=fe(v=>{let f=Ie(a.current).includes(CSS.escape(v.animationName));if(v.target===t&&f&&(h("ANIMATION_END"),!o.current)){let x=t.style.animationFillMode;t.style.animationFillMode="forwards",c=m.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},"handleAnimationEnd"),p=fe(v=>{v.target===t&&(s.current=Ie(a.current))},"handleAnimationStart");return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",g),t.addEventListener("animationend",g),()=>{m.clearTimeout(c),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",g),t.removeEventListener("animationend",g)}}else h("ANIMATION_END")},[t,h]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:ae.useCallback(c=>{if(c){let m=getComputedStyle(c);a.current=m,i.current=Ie(m)}else a.current=null;n(c)},[])}}fe(na,"usePresence");function Rt(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}fe(Rt,"setRef");function aa(...e){let t=ae.useRef(e);return t.current=e,ae.useCallback(n=>{let a=t.current,o=!1,s=a.map(i=>{let l=Rt(i,n);return!o&&typeof l=="function"&&(o=!0),l});if(o)return()=>{for(let i=0;i<s.length;i++){let l=s[i];typeof l=="function"?l():Rt(a[i],null)}}},[])}fe(aa,"useStableComposedRefs");function Ie(e){return e?.animationName||"none"}fe(Ie,"getAnimationName");function ra(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}fe(ra,"getElementRef");var dr=O(L(),1),ur=Object.defineProperty,_t=(e,t)=>ur(e,"name",{value:t,configurable:!0}),Je=0,Ee=null;function cr(e){return Ut(),e.children}_t(cr,"FocusGuards");function Ut(){dr.useEffect(()=>{Ee||(Ee={start:Dt(),end:Dt()});let{start:e,end:t}=Ee;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),Je++,()=>{Je===1&&(Ee?.start.remove(),Ee?.end.remove(),Ee=null),Je=Math.max(0,Je-1)}},[])}_t(Ut,"useFocusGuards");function Dt(){let e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}_t(Dt,"createFocusGuard");var oe=function(){return oe=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++){t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},oe.apply(this,arguments)};function sa(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]]);return n}function pr(e,t,n){if(n||arguments.length===2)for(var a=0,o=t.length,s;a<o;a++)(s||!(a in t))&&(s||(s=Array.prototype.slice.call(t,0,a)),s[a]=t[a]);return e.concat(s||Array.prototype.slice.call(t))}var vn=O(L()),ue=O(L()),at="right-scroll-bar-position",rt="width-before-scroll-bar",fr="with-scroll-bars-hidden",mr="--removed-body-scroll-bar-size";function bt(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}var hr=O(L());function gr(e,t){var n=(0,hr.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(a){var o=n.value;o!==a&&(n.value=a,n.callback(a,o))}}}})[0];return n.callback=t,n.facade}var bn=O(L()),xr=typeof window<"u"?bn.useLayoutEffect:bn.useEffect,wn=new WeakMap;function vr(e,t){var n=gr(t||null,function(a){return e.forEach(function(o){return bt(o,a)})});return xr(function(){var a=wn.get(n);if(a){var o=new Set(a),s=new Set(e),i=n.current;o.forEach(function(l){s.has(l)||bt(l,null)}),s.forEach(function(l){o.has(l)||bt(l,i)})}wn.set(n,e)},[e]),n}function br(e){return e}function wr(e,t){t===void 0&&(t=br);var n=[],a=!1,o={read:function(){if(a)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,a);return n.push(i),function(){n=n.filter(function(l){return l!==i})}},assignSyncMedium:function(s){for(a=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(l){return s(l)},filter:function(){return n}}},assignMedium:function(s){a=!0;var i=[];if(n.length){var l=n;n=[],l.forEach(s),i=n}var d=function(){var c=i;i=[],c.forEach(s)},h=function(){return Promise.resolve().then(d)};h(),n={push:function(c){i.push(c),h()},filter:function(c){return i=i.filter(c),n}}}};return o}function yr(e){e===void 0&&(e={});var t=wr(null);return t.options=oe({async:!0,ssr:!1},e),t}var jr=O(L()),oa=function(e){var t=e.sideCar,n=sa(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var a=t.read();if(!a)throw new Error("Sidecar medium not found");return jr.createElement(a,oe({},n))};oa.isSideCarExport=!0;function kr(e,t){return e.useMedium(t),oa}var la=yr(),wt=function(){},lt=ue.forwardRef(function(e,t){var n=ue.useRef(null),a=ue.useState({onScrollCapture:wt,onWheelCapture:wt,onTouchMoveCapture:wt}),o=a[0],s=a[1],i=e.forwardProps,l=e.children,d=e.className,h=e.removeScrollBar,c=e.enabled,m=e.shards,g=e.sideCar,p=e.noRelative,v=e.noIsolation,f=e.inert,x=e.allowPinchZoom,N=e.as,w=N===void 0?"div":N,j=e.gapMode,C=sa(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),D=g,E=vr([n,t]),P=oe(oe({},C),o);return ue.createElement(ue.Fragment,null,c&&ue.createElement(D,{sideCar:la,removeScrollBar:h,shards:m,noRelative:p,noIsolation:v,inert:f,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:j}),i?ue.cloneElement(ue.Children.only(l),oe(oe({},P),{ref:E})):ue.createElement(w,oe({},P,{className:d,ref:E}),l))});lt.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};lt.classNames={fullWidth:rt,zeroRight:at};var U=O(L()),It=O(L()),$r=O(L()),yn,Nr=function(){if(yn)return yn;if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Sr(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Nr();return t&&e.setAttribute("nonce",t),e}function Er(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Cr(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Rr=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Sr())&&(Er(t,n),Cr(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Dr=function(){var e=Rr();return function(t,n){$r.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},ia=function(){var e=Dr(),t=function(n){var a=n.styles,o=n.dynamic;return e(a,o),null};return t},Ir={left:0,top:0,right:0,gap:0},yt=function(e){return parseInt(e||"",10)||0},Ar=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],a=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[yt(n),yt(a),yt(o)]},Or=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Ir;var t=Ar(e),n=document.documentElement.clientWidth,a=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,a-n+t[2]-t[0])}},Pr=ia(),Ae="data-scroll-locked",Tr=function(e,t,n,a){var o=e.left,s=e.top,i=e.right,l=e.gap;return n===void 0&&(n="margin"),`
2
+ import{c as Da}from"./chunk-shared.a7e4c6f386cee4623300b0d1b471260a09e05f6e236d56c7814dffc06088fb5c.js";import{p0$a as Ks,p0$b as zs}from"./chunk-core.6128decfe528d89de1445dc1ec36e9f13dabd76eba61d13310fc1302db2252eb.js";import"./chunk-shared.2d678087d03dcf2430b5bf48656220dbff5fb622188004aae7a76e0e5e5d18f8.js";import{a as Me}from"./chunk-shared.b664b4e2524d0f293cecbb854f7479a13c2494fbabcef45232900bf7235f4ae0.js";import"./chunk-shared.c9025f6af91453ae8672099cb32126c5967384f769d10c662908e35c31b62478.js";import{p8$a as Xs,p8$b as Vs,p8$c as Zs,p8$d as Js,p8$e as Qs,p8$f as eo,p8$g as to,p8$h as no,p8$i as ao}from"./chunk-core.6128decfe528d89de1445dc1ec36e9f13dabd76eba61d13310fc1302db2252eb.js";import"./chunk-shared.66f18526381931b1ff69c090bad48c408a035a0d256bcff19b19b51ea988612a.js";import{p10$a as oo,p10$b as lo,p10$c as io,p10$d as uo}from"./chunk-core.6128decfe528d89de1445dc1ec36e9f13dabd76eba61d13310fc1302db2252eb.js";import{p1$a as fo,p1$b as mo,p1$c as ho,p1$d as xo,p1$e as go,p1$f as vo}from"./chunk-core.6128decfe528d89de1445dc1ec36e9f13dabd76eba61d13310fc1302db2252eb.js";import{p2$a as yo,p2$b as jo,p2$c as ko,p2$d as $o,p2$e as No,p2$f as So,p2$g as Eo,p2$h as Co,p2$i as Ro,p2$j as Do,p2$k as Io,p2$l as Ao,p2$m as Oo,p2$n as Po,p2$o as To,p2$p as Mo,p2$q as Lo,p2$r as Fo,p2$s as _o,p2$t as Uo}from"./chunk-core.6128decfe528d89de1445dc1ec36e9f13dabd76eba61d13310fc1302db2252eb.js";import"./chunk-shared.782659379fb982a9c2606c051bb711fd0fe38a547b8b4f4620cf2d14a832df25.js";import"./chunk-shared.8940b7334ec79bcd25cb8e2d41958eecfe71d31340cf8de3c3d99f813cd126af.js";import{p9$A as Ho,p9$B as qo,p9$C as Ko,p9$D as zo,p9$E as Yo,p9$F as Go,p9$G as Xo,p9$H as Vo,p9$I as Zo,p9$J as Jo,p9$a as Qo,p9$b as el,p9$c as tl,p9$d as nl,p9$e as al,p9$f as rl,p9$g as sl,p9$h as ol,p9$i as ll,p9$j as il,p9$k as dl,p9$l as ul,p9$m as cl,p9$n as pl,p9$o as fl,p9$p as ml,p9$q as hl,p9$r as xl,p9$s as gl,p9$t as vl,p9$u as bl,p9$v as wl,p9$w as yl,p9$x as jl,p9$y as kl,p9$z as $l}from"./chunk-core.6128decfe528d89de1445dc1ec36e9f13dabd76eba61d13310fc1302db2252eb.js";import{p13$a as El,p13$b as Cl}from"./chunk-core.6128decfe528d89de1445dc1ec36e9f13dabd76eba61d13310fc1302db2252eb.js";import{p3$$ as Il,p3$$a as Al,p3$$b as Ol,p3$A as Pl,p3$Aa as ht,p3$Ab as Tl,p3$B as Ml,p3$Ba as Ll,p3$Bb as Fl,p3$C as _l,p3$Ca as Ul,p3$Cb as Bl,p3$D as Wl,p3$Da as Hl,p3$Db as ql,p3$E as Kl,p3$Ea as zl,p3$Eb as Yl,p3$F as Gl,p3$Fa as Xl,p3$Fb as Vl,p3$G as Zl,p3$Ga as Jl,p3$Gb as Ql,p3$H as Ve,p3$Ha as ei,p3$Hb as ti,p3$I as ni,p3$Ia as ai,p3$Ib as ri,p3$J as si,p3$Ja as oi,p3$Jb as li,p3$K as ii,p3$Ka as di,p3$Kb as ui,p3$L as ci,p3$La as pi,p3$Lb as fi,p3$M as mi,p3$Ma as hi,p3$Mb as xi,p3$N as gi,p3$Na as vi,p3$Nb as bi,p3$O as wi,p3$Oa as yi,p3$Ob as ji,p3$P as ki,p3$Pa as en,p3$Pb as $i,p3$Q as Ni,p3$Qa as Si,p3$Qb as Ei,p3$R as Ci,p3$Ra as Ri,p3$Rb as Di,p3$S as Ii,p3$Sa as Ai,p3$Sb as Oi,p3$T as Pi,p3$Ta as tn,p3$Tb as Ti,p3$U as Mi,p3$Ua as Li,p3$Ub as Fi,p3$V as _i,p3$Va as Ui,p3$Vb as Bi,p3$W as Wi,p3$Wa as Hi,p3$Wb as qi,p3$X as Ki,p3$Xa as zi,p3$Xb as Be,p3$Y as Yi,p3$Ya as Gi,p3$Yb as Xi,p3$Z as Vi,p3$Za as Zi,p3$Zb as Ji,p3$_ as Qi,p3$_a as ed,p3$_b as td,p3$a as K,p3$aa as nd,p3$ab as ad,p3$ac as rd,p3$b as sd,p3$ba as od,p3$bb as ld,p3$bc as id,p3$c as We,p3$ca as dd,p3$cb as Ze,p3$cc as ud,p3$d as nn,p3$da as cd,p3$db as pd,p3$dc as fd,p3$e as md,p3$ea as hd,p3$eb as xd,p3$ec as gd,p3$f as an,p3$fa as vd,p3$fb as bd,p3$fc as wd,p3$g as we,p3$ga as yd,p3$gb as jd,p3$gc as rn,p3$h as sn,p3$ha as kd,p3$hb as $d,p3$hc as on,p3$i as Nd,p3$ia as Sd,p3$ib as ln,p3$ic as Ed,p3$j as Cd,p3$ja as Rd,p3$jb as Dd,p3$jc as Id,p3$k as Ad,p3$ka as Od,p3$kb as Pd,p3$kc as dn,p3$l as Td,p3$la as Md,p3$lb as Ld,p3$lc as Fd,p3$m as _d,p3$ma as Ud,p3$mb as Bd,p3$mc as Wd,p3$n as Hd,p3$na as qd,p3$nb as Kd,p3$nc as zd,p3$o as Yd,p3$oa as Gd,p3$ob as Xd,p3$p as Vd,p3$pa as Zd,p3$pb as Jd,p3$q as Qd,p3$qa as eu,p3$qb as tu,p3$r as nu,p3$ra as au,p3$rb as ru,p3$s as su,p3$sa as ou,p3$sb as lu,p3$t as iu,p3$ta as du,p3$tb as uu,p3$u as cu,p3$ua as pu,p3$ub as fu,p3$v as mu,p3$va as hu,p3$vb as xu,p3$w as gu,p3$wa as vu,p3$wb as bu,p3$x as wu,p3$xa as yu,p3$xb as ju,p3$y as ku,p3$ya as $u,p3$yb as Nu,p3$z as Su,p3$za as Eu,p3$zb as Cu}from"./chunk-core.6128decfe528d89de1445dc1ec36e9f13dabd76eba61d13310fc1302db2252eb.js";import{p4$a as Iu,p4$b as O,p4$c as L,p4$d as un,p4$e as ge}from"./chunk-core.6128decfe528d89de1445dc1ec36e9f13dabd76eba61d13310fc1302db2252eb.js";var Y=O(L(),1),Ia=Object.defineProperty,Le=(e,t)=>Ia(e,"name",{value:t,configurable:!0}),On=!!(typeof window<"u"&&window.document&&window.document.createElement);function be(e,t,{checkForDefaultPrevented:n=!0}={}){return Le(function(a){if(e?.(a),n===!1||!a||!a.defaultPrevented)return t?.(a)},"handleEvent")}Le(be,"composeEventHandlers");function Aa(e){if(!On)throw new Error("Cannot access window outside of the DOM");return e?.ownerDocument?.defaultView??window}Le(Aa,"getOwnerWindow");function $t(e){if(!On)throw new Error("Cannot access document outside of the DOM");return e?.ownerDocument??document}Le($t,"getOwnerDocument");function Pn(e,t=!1){let{activeElement:n}=$t(e);if(!n?.nodeName)return null;if(Tn(n)&&n.contentDocument)return Pn(n.contentDocument.body,t);if(t){let a=n.getAttribute("aria-activedescendant");if(a){let o=$t(n).getElementById(a);if(o)return o}}return n}Le(Pn,"getActiveElement");function Tn(e){return e.tagName==="IFRAME"}Le(Tn,"isFrame");var pe=O(L(),1),Mn=O(ge(),1),Oa=Object.defineProperty,ee=(e,t)=>Oa(e,"name",{value:t,configurable:!0});function Pa(e,t){let n=pe.createContext(t);n.displayName=e+"Context";let a=ee(s=>{let{children:i,...l}=s,d=pe.useMemo(()=>l,Object.values(l));return(0,Mn.jsx)(n.Provider,{value:d,children:i})},"Provider");a.displayName=e+"Provider";function o(s,i={}){let{optional:l=!1}=i,d=pe.useContext(n);if(d)return d;if(t!==void 0)return t;if(!l)throw new Error(`\`${s}\` must be used within \`${e}\``)}return ee(o,"useContext"),[a,o]}ee(Pa,"createContext");function Ln(e,t=[]){let n=[];function a(s,i){let l=pe.createContext(i);l.displayName=s+"Context";let d=n.length;n=[...n,i];let h=ee(m=>{let{scope:x,children:p,...v}=m,f=x?.[e]?.[d]||l,g=pe.useMemo(()=>v,Object.values(v));return(0,Mn.jsx)(f.Provider,{value:g,children:p})},"Provider");h.displayName=s+"Provider";function c(m,x,p={}){let{optional:v=!1}=p,f=x?.[e]?.[d]||l,g=pe.useContext(f);if(g)return g;if(i!==void 0)return i;if(!v)throw new Error(`\`${m}\` must be used within \`${s}\``)}return ee(c,"useContext"),[h,c]}ee(a,"createContext");let o=ee(()=>{let s=n.map(i=>pe.createContext(i));return ee(function(i){let l=i?.[e]||s;return pe.useMemo(()=>({[`__scope${e}`]:{...i,[e]:l}}),[i,l])},"useScope")},"createScope");return o.scopeName=e,[a,Fn(o,...t)]}ee(Ln,"createContextScope");function Fn(...e){let t=e[0];if(e.length===1)return t;let n=ee(()=>{let a=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return ee(function(o){let s=a.reduce((i,{useScope:l,scopeName:d})=>{let h=l(o)[`__scope${d}`];return{...i,...h}},{});return pe.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}ee(Fn,"composeContextScopes");var _n=O(L(),1),Ta=O(L(),1),ke=globalThis?.document?Ta.useLayoutEffect:()=>{},Ma=Object.defineProperty,La=(e,t)=>Ma(e,"name",{value:t,configurable:!0}),Fa=_n[" useId ".trim().toString()]||(()=>{}),_a=0;function nt(e){let[t,n]=_n.useState(Fa());return ke(()=>{e||n(a=>a??String(_a++))},[e]),e||(t?`radix-${t}`:"")}La(nt,"useId");var ve=O(L(),1),Un=!1,ye=O(L(),1),ot=O(L(),1),Ua=Object.defineProperty,Ba=(e,t)=>Ua(e,"name",{value:t,configurable:!0}),cn=ot[" useEffectEvent ".trim().toString()],pn=ot[" useInsertionEffect ".trim().toString()];function Bn(e){if(typeof cn=="function")return cn(e);let t=ot.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof pn=="function"?pn(()=>{t.current=e}):ke(()=>{t.current=e}),ot.useMemo(()=>((...n)=>t.current?.(...n)),[])}Ba(Bn,"useEffectEvent");var Wa=Object.defineProperty,Ye=(e,t)=>Wa(e,"name",{value:t,configurable:!0}),Ha=ve[" useInsertionEffect ".trim().toString()]||ke;function Wn({prop:e,defaultProp:t,onChange:n=Ye(()=>{},"onChange"),caller:a}){let[o,s,i]=Hn({defaultProp:t,onChange:n}),l=e!==void 0,d=l?e:o;if(Un){let c=ve.useRef(e!==void 0);ve.useEffect(()=>{let m=c.current;m!==l&&console.warn(`${a} is changing from ${m?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),c.current=l},[l,a])}let h=ve.useCallback(c=>{if(l){let m=qn(c)?c(e):c;m!==e&&i.current?.(m)}else s(c)},[l,e,s,i]);return[d,h]}Ye(Wn,"useControllableState");function Hn({defaultProp:e,onChange:t}){let[n,a]=ve.useState(e),o=ve.useRef(n),s=ve.useRef(t);return Ha(()=>{s.current=t},[t]),ve.useEffect(()=>{o.current!==n&&(s.current?.(n),o.current=n)},[n,o]),[n,a,s]}Ye(Hn,"useUncontrolledState");function qn(e){return typeof e=="function"}Ye(qn,"isFunction");var fn=Symbol("RADIX:SYNC_STATE");function qa(e,t,n,a){let{prop:o,defaultProp:s,onChange:i,caller:l}=t,d=o!==void 0,h=Bn(i);if(Un){let g=ye.useRef(o!==void 0);ye.useEffect(()=>{let N=g.current;N!==d&&console.warn(`${l} is changing from ${N?"controlled":"uncontrolled"} to ${d?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),g.current=d},[d,l])}let c=[{...n,state:s}];a&&c.push(a);let[m,x]=ye.useReducer((g,N)=>{if(N.type===fn)return{...g,state:N.state};let w=e(g,N);return d&&!Object.is(w.state,g.state)&&h(w.state),w},...c),p=m.state,v=ye.useRef(p);ye.useEffect(()=>{v.current!==p&&(v.current=p,d||h(p))},[p,v,d]);let f=ye.useMemo(()=>o!==void 0?{...m,state:o}:m,[m,o]);return ye.useEffect(()=>{d&&!Object.is(o,m.state)&&x({type:fn,state:o})},[o,m.state,d]),[f,x]}Ye(qa,"useControllableStateReducer");var F=O(L(),1),xt=O(L(),1),Ka=Object.defineProperty,za=(e,t)=>Ka(e,"name",{value:t,configurable:!0});function Pe(e){let t=xt.useRef(e);return xt.useEffect(()=>{t.current=e}),xt.useMemo(()=>((...n)=>t.current?.(...n)),[])}za(Pe,"useCallbackRef");var Ya=O(ge(),1),Ga=Object.defineProperty,z=(e,t)=>Ga(e,"name",{value:t,configurable:!0}),Nt="dismissableLayer.update",Xa="dismissableLayer.pointerDownOutside",Va="dismissableLayer.focusOutside",mn,Kn=F.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Za=F.forwardRef(z(function(e,t){let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:a=!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:i,onInteractOutside:l,onDismiss:d,...h}=e,c=F.useContext(Kn),[m,x]=F.useState(null),p=m?.ownerDocument??globalThis?.document,[,v]=F.useState({}),f=We(t,x),g=Array.from(c.layers),[N]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),w=N?g.indexOf(N):-1,j=m?g.indexOf(m):-1,C=c.layersWithOutsidePointerEventsDisabled.size>0,D=j>=w,E=F.useRef(!1),P=Yn(I=>{s?.(I),l?.(I),I.defaultPrevented||d?.()},{ownerDocument:p,deferPointerDownOutside:a,isDeferredPointerDownOutsideRef:E,dismissableSurfaces:c.dismissableSurfaces,shouldHandlePointerDownOutside:F.useCallback(I=>{if(!(I instanceof Node))return!1;let Z=[...c.branches].some(he=>he.contains(I));return D&&!Z},[c.branches,D])}),H=Gn(I=>{if(a&&E.current)return;let Z=I.target;[...c.branches].some(he=>he.contains(Z))||(i?.(I),l?.(I),I.defaultPrevented||d?.())},p),Q=m?j===g.length-1:!1,M=Pe(I=>{I.key==="Escape"&&(o?.(I),!I.defaultPrevented&&d&&(I.preventDefault(),d()))});return F.useEffect(()=>{if(Q)return p.addEventListener("keydown",M,{capture:!0}),()=>p.removeEventListener("keydown",M,{capture:!0})},[p,Q,M]),F.useEffect(()=>{if(m)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(mn=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(m)),c.layers.add(m),St(),()=>{n&&(c.layersWithOutsidePointerEventsDisabled.delete(m),c.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=mn))}},[m,p,n,c]),F.useEffect(()=>()=>{m&&(c.layers.delete(m),c.layersWithOutsidePointerEventsDisabled.delete(m),St())},[m,c]),F.useEffect(()=>{let I=z(()=>v({}),"handleUpdate");return document.addEventListener(Nt,I),()=>document.removeEventListener(Nt,I)},[]),(0,Ya.jsx)(we.div,{...h,ref:f,style:{pointerEvents:C?D?"auto":"none":void 0,...e.style},onFocusCapture:be(e.onFocusCapture,H.onFocusCapture),onBlurCapture:be(e.onBlurCapture,H.onBlurCapture),onPointerDownCapture:be(e.onPointerDownCapture,P.onPointerDownCapture)})},"DismissableLayer"));function zn(){let e=F.useContext(Kn),[t,n]=F.useState(null);return F.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}z(zn,"useDismissableLayerSurface");var Ja=z(()=>!0,"IS_TRUE");function Yn(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:a=!1,isDeferredPointerDownOutsideRef:o,dismissableSurfaces:s,shouldHandlePointerDownOutside:i=Ja}=t,l=Pe(e),d=F.useRef(!1),h=F.useRef(!1),c=F.useRef(new Map),m=F.useRef(()=>{});return F.useEffect(()=>{function x(){h.current=!1,o.current=!1,c.current.clear()}z(x,"resetOutsideInteraction");function p(){return Array.from(c.current.values()).some(Boolean)}z(p,"isOutsideInteractionIntercepted");function v(j){if(!h.current)return;let C=j.target;C instanceof Node&&[...s].some(D=>D.contains(C))||c.current.set(j.type,!0),j.type==="click"&&window.setTimeout(()=>{h.current&&m.current()},0)}z(v,"handleInteractionCapture");function f(j){h.current&&c.current.set(j.type,!1)}z(f,"handleInteractionBubble");let g=z(j=>{if(j.target&&!d.current){let D=function(){n.removeEventListener("click",m.current);let P=p();x(),P||Mt(Xa,l,E,{discrete:!0})};var C=D;if(z(D,"handleAndDispatchPointerDownOutsideEvent"),!i(j.target)){n.removeEventListener("click",m.current),x(),d.current=!1;return}let E={originalEvent:j};h.current=!0,o.current=a&&j.button===0,c.current.clear(),!a||j.button!==0?D():(n.removeEventListener("click",m.current),m.current=D,n.addEventListener("click",m.current,{once:!0}))}else n.removeEventListener("click",m.current),x();d.current=!1},"handlePointerDown"),N=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(let j of N)n.addEventListener(j,v,!0),n.addEventListener(j,f);let w=window.setTimeout(()=>{n.addEventListener("pointerdown",g)},0);return()=>{window.clearTimeout(w),n.removeEventListener("pointerdown",g),n.removeEventListener("click",m.current);for(let j of N)n.removeEventListener(j,v,!0),n.removeEventListener(j,f)}},[n,l,a,o,s,i]),{onPointerDownCapture:z(()=>d.current=!0,"onPointerDownCapture")}}z(Yn,"usePointerDownOutside");function Gn(e,t=globalThis?.document){let n=Pe(e),a=F.useRef(!1);return F.useEffect(()=>{let o=z(s=>{s.target&&!a.current&&Mt(Va,n,{originalEvent:s},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:z(()=>a.current=!0,"onFocusCapture"),onBlurCapture:z(()=>a.current=!1,"onBlurCapture")}}z(Gn,"useFocusOutside");function St(){let e=new CustomEvent(Nt);document.dispatchEvent(e)}z(St,"dispatchUpdate");function Mt(e,t,n,{discrete:a}){let o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),a?sn(o,s):o.dispatchEvent(s)}z(Mt,"handleAndDispatchCustomEvent");var je=O(L(),1),Qa=O(ge(),1),er=Object.defineProperty,J=(e,t)=>er(e,"name",{value:t,configurable:!0}),gt="focusScope.autoFocusOnMount",vt="focusScope.autoFocusOnUnmount",hn={bubbles:!1,cancelable:!0},tr=je.forwardRef(J(function(e,t){let{loop:n=!1,trapped:a=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[l,d]=je.useState(null),h=Pe(o),c=Pe(s),m=je.useRef(null),x=We(t,d),p=je.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;je.useEffect(()=>{if(a){let w=function(E){if(p.paused||!l)return;let P=E.target;l.contains(P)?m.current=P:ce(m.current,{select:!0})},j=function(E){if(p.paused||!l)return;let P=E.relatedTarget;P!==null&&(l.contains(P)||ce(m.current,{select:!0}))},C=function(E){if(document.activeElement===document.body)for(let P of E)P.removedNodes.length>0&&ce(l)};var f=w,g=j,N=C;J(w,"handleFocusIn"),J(j,"handleFocusOut"),J(C,"handleMutations"),document.addEventListener("focusin",w),document.addEventListener("focusout",j);let D=new MutationObserver(C);return l&&D.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",j),D.disconnect()}}},[a,l,p.paused]),je.useEffect(()=>{if(l){xn.add(p);let f=document.activeElement;if(!l.contains(f)){let g=new CustomEvent(gt,hn);l.addEventListener(gt,h),l.dispatchEvent(g),g.defaultPrevented||(Xn(ea(Lt(l)),{select:!0}),document.activeElement===f&&ce(l))}return()=>{l.removeEventListener(gt,h),setTimeout(()=>{let g=new CustomEvent(vt,hn);l.addEventListener(vt,c),l.dispatchEvent(g),g.defaultPrevented||ce(f??document.body,{select:!0}),l.removeEventListener(vt,c),xn.remove(p)},0)}}},[l,h,c,p]);let v=je.useCallback(f=>{if(!n&&!a||p.paused)return;let g=f.key==="Tab"&&!f.altKey&&!f.ctrlKey&&!f.metaKey,N=document.activeElement;if(g&&N){let w=f.currentTarget,[j,C]=Vn(w);j&&C?!f.shiftKey&&N===C?(f.preventDefault(),n&&ce(j,{select:!0})):f.shiftKey&&N===j&&(f.preventDefault(),n&&ce(C,{select:!0})):N===w&&f.preventDefault()}},[n,a,p.paused]);return(0,Qa.jsx)(we.div,{tabIndex:-1,...i,ref:x,onKeyDown:v})},"FocusScope"));function Xn(e,{select:t=!1}={}){let n=document.activeElement;for(let a of e)if(ce(a,{select:t}),document.activeElement!==n)return}J(Xn,"focusFirst");function Vn(e){let t=Lt(e),n=Et(t,e),a=Et(t.reverse(),e);return[n,a]}J(Vn,"getTabbableEdges");function Lt(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:J(a=>{let o=a.tagName==="INPUT"&&a.type==="hidden";return a.disabled||a.hidden||o?NodeFilter.FILTER_SKIP:a.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}J(Lt,"getTabbableCandidates");function Et(e,t){let n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(let a of e)if(!(n?!a.checkVisibility({checkVisibilityCSS:!0}):Zn(a,{upTo:t})))return a}J(Et,"findVisible");function Zn(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}J(Zn,"isHidden");function Jn(e){return e instanceof HTMLInputElement&&"select"in e}J(Jn,"isSelectableInput");function ce(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Jn(e)&&t&&e.select()}}J(ce,"focus");var xn=Qn();function Qn(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=Ct(e,t),e.unshift(t)},remove(t){e=Ct(e,t),e[0]?.resume()}}}J(Qn,"createFocusScopesStack");function Ct(e,t){let n=[...e],a=n.indexOf(t);return a!==-1&&n.splice(a,1),n}J(Ct,"arrayRemove");function ea(e){return e.filter(t=>t.tagName!=="A")}J(ea,"removeLinks");var gn=O(L(),1),nr=O(un(),1),ar=O(ge(),1),rr=Object.defineProperty,sr=(e,t)=>rr(e,"name",{value:t,configurable:!0}),or=gn.forwardRef(sr(function(e,t){let{container:n,...a}=e,[o,s]=gn.useState(!1);ke(()=>s(!0),[]);let i=n||o&&globalThis?.document?.body;return i?nr.createPortal((0,ar.jsx)(we.div,{...a,ref:t}),i):null},"Portal")),ae=O(L(),1),lr=O(L(),1),ir=Object.defineProperty,fe=(e,t)=>ir(e,"name",{value:t,configurable:!0});function ta(e,t){return lr.useReducer((n,a)=>t[n][a]??n,e)}fe(ta,"useStateMachine");var Ft=fe(e=>{let{present:t,children:n}=e,a=na(t),o=typeof n=="function"?n({present:a.isPresent}):ae.Children.only(n),s=aa(a.ref,ra(o));return typeof n=="function"||a.isPresent?ae.cloneElement(o,{ref:s}):null},"Presence");function na(e){let[t,n]=ae.useState(),a=ae.useRef(null),o=ae.useRef(e),s=ae.useRef("none"),i=ae.useRef(void 0),l=e?"mounted":"unmounted",[d,h]=ta(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return ae.useEffect(()=>{d==="mounted"?(s.current=i.current??Ie(a.current),i.current=void 0):s.current="none"},[d]),ke(()=>{let c=a.current,m=o.current;if(m!==e){let x=s.current,p=Ie(c);e?(i.current=p,h("MOUNT")):p==="none"||c?.display==="none"?h("UNMOUNT"):h(m&&x!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,h]),ke(()=>{if(t){let c,m=t.ownerDocument.defaultView??window,x=fe(v=>{let f=Ie(a.current).includes(CSS.escape(v.animationName));if(v.target===t&&f&&(h("ANIMATION_END"),!o.current)){let g=t.style.animationFillMode;t.style.animationFillMode="forwards",c=m.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},"handleAnimationEnd"),p=fe(v=>{v.target===t&&(s.current=Ie(a.current))},"handleAnimationStart");return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",x),t.addEventListener("animationend",x),()=>{m.clearTimeout(c),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",x),t.removeEventListener("animationend",x)}}else h("ANIMATION_END")},[t,h]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:ae.useCallback(c=>{if(c){let m=getComputedStyle(c);a.current=m,i.current=Ie(m)}else a.current=null;n(c)},[])}}fe(na,"usePresence");function Rt(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}fe(Rt,"setRef");function aa(...e){let t=ae.useRef(e);return t.current=e,ae.useCallback(n=>{let a=t.current,o=!1,s=a.map(i=>{let l=Rt(i,n);return!o&&typeof l=="function"&&(o=!0),l});if(o)return()=>{for(let i=0;i<s.length;i++){let l=s[i];typeof l=="function"?l():Rt(a[i],null)}}},[])}fe(aa,"useStableComposedRefs");function Ie(e){return e?.animationName||"none"}fe(Ie,"getAnimationName");function ra(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}fe(ra,"getElementRef");var dr=O(L(),1),ur=Object.defineProperty,_t=(e,t)=>ur(e,"name",{value:t,configurable:!0}),Je=0,Ee=null;function cr(e){return Ut(),e.children}_t(cr,"FocusGuards");function Ut(){dr.useEffect(()=>{Ee||(Ee={start:Dt(),end:Dt()});let{start:e,end:t}=Ee;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),Je++,()=>{Je===1&&(Ee?.start.remove(),Ee?.end.remove(),Ee=null),Je=Math.max(0,Je-1)}},[])}_t(Ut,"useFocusGuards");function Dt(){let e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}_t(Dt,"createFocusGuard");var oe=function(){return oe=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++){t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},oe.apply(this,arguments)};function sa(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]]);return n}function pr(e,t,n){if(n||arguments.length===2)for(var a=0,o=t.length,s;a<o;a++)(s||!(a in t))&&(s||(s=Array.prototype.slice.call(t,0,a)),s[a]=t[a]);return e.concat(s||Array.prototype.slice.call(t))}var vn=O(L()),ue=O(L()),at="right-scroll-bar-position",rt="width-before-scroll-bar",fr="with-scroll-bars-hidden",mr="--removed-body-scroll-bar-size";function bt(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}var hr=O(L());function xr(e,t){var n=(0,hr.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(a){var o=n.value;o!==a&&(n.value=a,n.callback(a,o))}}}})[0];return n.callback=t,n.facade}var bn=O(L()),gr=typeof window<"u"?bn.useLayoutEffect:bn.useEffect,wn=new WeakMap;function vr(e,t){var n=xr(t||null,function(a){return e.forEach(function(o){return bt(o,a)})});return gr(function(){var a=wn.get(n);if(a){var o=new Set(a),s=new Set(e),i=n.current;o.forEach(function(l){s.has(l)||bt(l,null)}),s.forEach(function(l){o.has(l)||bt(l,i)})}wn.set(n,e)},[e]),n}function br(e){return e}function wr(e,t){t===void 0&&(t=br);var n=[],a=!1,o={read:function(){if(a)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,a);return n.push(i),function(){n=n.filter(function(l){return l!==i})}},assignSyncMedium:function(s){for(a=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(l){return s(l)},filter:function(){return n}}},assignMedium:function(s){a=!0;var i=[];if(n.length){var l=n;n=[],l.forEach(s),i=n}var d=function(){var c=i;i=[],c.forEach(s)},h=function(){return Promise.resolve().then(d)};h(),n={push:function(c){i.push(c),h()},filter:function(c){return i=i.filter(c),n}}}};return o}function yr(e){e===void 0&&(e={});var t=wr(null);return t.options=oe({async:!0,ssr:!1},e),t}var jr=O(L()),oa=function(e){var t=e.sideCar,n=sa(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var a=t.read();if(!a)throw new Error("Sidecar medium not found");return jr.createElement(a,oe({},n))};oa.isSideCarExport=!0;function kr(e,t){return e.useMedium(t),oa}var la=yr(),wt=function(){},lt=ue.forwardRef(function(e,t){var n=ue.useRef(null),a=ue.useState({onScrollCapture:wt,onWheelCapture:wt,onTouchMoveCapture:wt}),o=a[0],s=a[1],i=e.forwardProps,l=e.children,d=e.className,h=e.removeScrollBar,c=e.enabled,m=e.shards,x=e.sideCar,p=e.noRelative,v=e.noIsolation,f=e.inert,g=e.allowPinchZoom,N=e.as,w=N===void 0?"div":N,j=e.gapMode,C=sa(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),D=x,E=vr([n,t]),P=oe(oe({},C),o);return ue.createElement(ue.Fragment,null,c&&ue.createElement(D,{sideCar:la,removeScrollBar:h,shards:m,noRelative:p,noIsolation:v,inert:f,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:j}),i?ue.cloneElement(ue.Children.only(l),oe(oe({},P),{ref:E})):ue.createElement(w,oe({},P,{className:d,ref:E}),l))});lt.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};lt.classNames={fullWidth:rt,zeroRight:at};var U=O(L()),It=O(L()),$r=O(L()),yn,Nr=function(){if(yn)return yn;if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Sr(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Nr();return t&&e.setAttribute("nonce",t),e}function Er(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Cr(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Rr=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Sr())&&(Er(t,n),Cr(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Dr=function(){var e=Rr();return function(t,n){$r.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},ia=function(){var e=Dr(),t=function(n){var a=n.styles,o=n.dynamic;return e(a,o),null};return t},Ir={left:0,top:0,right:0,gap:0},yt=function(e){return parseInt(e||"",10)||0},Ar=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],a=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[yt(n),yt(a),yt(o)]},Or=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Ir;var t=Ar(e),n=document.documentElement.clientWidth,a=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,a-n+t[2]-t[0])}},Pr=ia(),Ae="data-scroll-locked",Tr=function(e,t,n,a){var o=e.left,s=e.top,i=e.right,l=e.gap;return n===void 0&&(n="margin"),`
3
3
  .`.concat(fr,` {
4
4
  overflow: hidden `).concat(a,`;
5
5
  padding-right: `).concat(l,"px ").concat(a,`;
@@ -36,9 +36,9 @@ import{a as Me}from"./chunk-shared.b664b4e2524d0f293cecbb854f7479a13c2494fbabcef
36
36
  body[`).concat(Ae,`] {
37
37
  `).concat(mr,": ").concat(l,`px;
38
38
  }
39
- `)},jn=function(){var e=parseInt(document.body.getAttribute(Ae)||"0",10);return isFinite(e)?e:0},Mr=function(){It.useEffect(function(){return document.body.setAttribute(Ae,(jn()+1).toString()),function(){var e=jn()-1;e<=0?document.body.removeAttribute(Ae):document.body.setAttribute(Ae,e.toString())}},[])},Lr=function(e){var t=e.noRelative,n=e.noImportant,a=e.gapMode,o=a===void 0?"margin":a;Mr();var s=It.useMemo(function(){return Or(o)},[o]);return It.createElement(Pr,{styles:Tr(s,!t,o,n?"":"!important")})},At=!1;if(typeof window<"u")try{He=Object.defineProperty({},"passive",{get:function(){return At=!0,!0}}),window.addEventListener("test",He,He),window.removeEventListener("test",He,He)}catch{At=!1}var He,Ce=At?{passive:!1}:!1,Fr=function(e){return e.tagName==="TEXTAREA"},da=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Fr(e)&&n[t]==="visible")},_r=function(e){return da(e,"overflowY")},Ur=function(e){return da(e,"overflowX")},kn=function(e,t){var n=t.ownerDocument,a=t;do{typeof ShadowRoot<"u"&&a instanceof ShadowRoot&&(a=a.host);var o=ua(e,a);if(o){var s=ca(e,a),i=s[1],l=s[2];if(i>l)return!0}a=a.parentNode}while(a&&a!==n.body);return!1},Br=function(e){var t=e.scrollTop,n=e.scrollHeight,a=e.clientHeight;return[t,n,a]},Wr=function(e){var t=e.scrollLeft,n=e.scrollWidth,a=e.clientWidth;return[t,n,a]},ua=function(e,t){return e==="v"?_r(t):Ur(t)},ca=function(e,t){return e==="v"?Br(t):Wr(t)},Hr=function(e,t){return e==="h"&&t==="rtl"?-1:1},qr=function(e,t,n,a,o){var s=Hr(e,window.getComputedStyle(t).direction),i=s*a,l=n.target,d=t.contains(l),h=!1,c=i>0,m=0,g=0;do{if(!l)break;var p=ca(e,l),v=p[0],f=p[1],x=p[2],N=f-x-s*v;(v||N)&&ua(e,l)&&(m+=N,g+=v);var w=l.parentNode;l=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}while(!d&&l!==document.body||d&&(t.contains(l)||t===l));return(c&&(o&&Math.abs(m)<1||!o&&i>m)||!c&&(o&&Math.abs(g)<1||!o&&-i>g))&&(h=!0),h},Qe=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},$n=function(e){return[e.deltaX,e.deltaY]},Nn=function(e){return e&&"current"in e?e.current:e},Kr=function(e,t){return e[0]===t[0]&&e[1]===t[1]},zr=function(e){return`
39
+ `)},jn=function(){var e=parseInt(document.body.getAttribute(Ae)||"0",10);return isFinite(e)?e:0},Mr=function(){It.useEffect(function(){return document.body.setAttribute(Ae,(jn()+1).toString()),function(){var e=jn()-1;e<=0?document.body.removeAttribute(Ae):document.body.setAttribute(Ae,e.toString())}},[])},Lr=function(e){var t=e.noRelative,n=e.noImportant,a=e.gapMode,o=a===void 0?"margin":a;Mr();var s=It.useMemo(function(){return Or(o)},[o]);return It.createElement(Pr,{styles:Tr(s,!t,o,n?"":"!important")})},At=!1;if(typeof window<"u")try{He=Object.defineProperty({},"passive",{get:function(){return At=!0,!0}}),window.addEventListener("test",He,He),window.removeEventListener("test",He,He)}catch{At=!1}var He,Ce=At?{passive:!1}:!1,Fr=function(e){return e.tagName==="TEXTAREA"},da=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Fr(e)&&n[t]==="visible")},_r=function(e){return da(e,"overflowY")},Ur=function(e){return da(e,"overflowX")},kn=function(e,t){var n=t.ownerDocument,a=t;do{typeof ShadowRoot<"u"&&a instanceof ShadowRoot&&(a=a.host);var o=ua(e,a);if(o){var s=ca(e,a),i=s[1],l=s[2];if(i>l)return!0}a=a.parentNode}while(a&&a!==n.body);return!1},Br=function(e){var t=e.scrollTop,n=e.scrollHeight,a=e.clientHeight;return[t,n,a]},Wr=function(e){var t=e.scrollLeft,n=e.scrollWidth,a=e.clientWidth;return[t,n,a]},ua=function(e,t){return e==="v"?_r(t):Ur(t)},ca=function(e,t){return e==="v"?Br(t):Wr(t)},Hr=function(e,t){return e==="h"&&t==="rtl"?-1:1},qr=function(e,t,n,a,o){var s=Hr(e,window.getComputedStyle(t).direction),i=s*a,l=n.target,d=t.contains(l),h=!1,c=i>0,m=0,x=0;do{if(!l)break;var p=ca(e,l),v=p[0],f=p[1],g=p[2],N=f-g-s*v;(v||N)&&ua(e,l)&&(m+=N,x+=v);var w=l.parentNode;l=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}while(!d&&l!==document.body||d&&(t.contains(l)||t===l));return(c&&(o&&Math.abs(m)<1||!o&&i>m)||!c&&(o&&Math.abs(x)<1||!o&&-i>x))&&(h=!0),h},Qe=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},$n=function(e){return[e.deltaX,e.deltaY]},Nn=function(e){return e&&"current"in e?e.current:e},Kr=function(e,t){return e[0]===t[0]&&e[1]===t[1]},zr=function(e){return`
40
40
  .block-interactivity-`.concat(e,` {pointer-events: none;}
41
41
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
42
- `)},Yr=0,Re=[];function Gr(e){var t=U.useRef([]),n=U.useRef([0,0]),a=U.useRef(),o=U.useState(Yr++)[0],s=U.useState(ia)[0],i=U.useRef(e);U.useEffect(function(){i.current=e},[e]),U.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var f=pr([e.lockRef.current],(e.shards||[]).map(Nn),!0).filter(Boolean);return f.forEach(function(x){return x.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),f.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var l=U.useCallback(function(f,x){if("touches"in f&&f.touches.length===2||f.type==="wheel"&&f.ctrlKey)return!i.current.allowPinchZoom;var N=Qe(f),w=n.current,j="deltaX"in f?f.deltaX:w[0]-N[0],C="deltaY"in f?f.deltaY:w[1]-N[1],D,E=f.target,P=Math.abs(j)>Math.abs(C)?"h":"v";if("touches"in f&&P==="h"&&E.type==="range")return!1;var H=window.getSelection(),Q=H&&H.anchorNode,M=Q?Q===E||Q.contains(E):!1;if(M)return!1;var I=kn(P,E);if(!I)return!0;if(I?D=P:(D=P==="v"?"h":"v",I=kn(P,E)),!I)return!1;if(!a.current&&"changedTouches"in f&&(j||C)&&(a.current=D),!D)return!0;var Z=a.current||D;return qr(Z,x,f,Z==="h"?j:C,!0)},[]),d=U.useCallback(function(f){var x=f;if(!(!Re.length||Re[Re.length-1]!==s)){var N="deltaY"in x?$n(x):Qe(x),w=t.current.filter(function(D){return D.name===x.type&&(D.target===x.target||x.target===D.shadowParent)&&Kr(D.delta,N)})[0];if(w&&w.should){x.cancelable&&x.preventDefault();return}if(!w){var j=(i.current.shards||[]).map(Nn).filter(Boolean).filter(function(D){return D.contains(x.target)}),C=j.length>0?l(x,j[0]):!i.current.noIsolation;C&&x.cancelable&&x.preventDefault()}}},[]),h=U.useCallback(function(f,x,N,w){var j={name:f,delta:x,target:N,should:w,shadowParent:Xr(N)};t.current.push(j),setTimeout(function(){t.current=t.current.filter(function(C){return C!==j})},1)},[]),c=U.useCallback(function(f){n.current=Qe(f),a.current=void 0},[]),m=U.useCallback(function(f){h(f.type,$n(f),f.target,l(f,e.lockRef.current))},[]),g=U.useCallback(function(f){h(f.type,Qe(f),f.target,l(f,e.lockRef.current))},[]);U.useEffect(function(){return Re.push(s),e.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:g}),document.addEventListener("wheel",d,Ce),document.addEventListener("touchmove",d,Ce),document.addEventListener("touchstart",c,Ce),function(){Re=Re.filter(function(f){return f!==s}),document.removeEventListener("wheel",d,Ce),document.removeEventListener("touchmove",d,Ce),document.removeEventListener("touchstart",c,Ce)}},[]);var p=e.removeScrollBar,v=e.inert;return U.createElement(U.Fragment,null,v?U.createElement(s,{styles:zr(o)}):null,p?U.createElement(Lr,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Xr(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var Vr=kr(la,Gr),pa=vn.forwardRef(function(e,t){return vn.createElement(lt,oe({},e,{ref:t,sideCar:Vr}))});pa.classNames=lt.classNames;var Zr=pa,Jr=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},De=new WeakMap,et=new WeakMap,tt={},jt=0,fa=function(e){return e&&(e.host||fa(e.parentNode))},Qr=function(e,t){return t.map(function(n){if(e.contains(n))return n;var a=fa(n);return a&&e.contains(a)?a:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},es=function(e,t,n,a){var o=Qr(t,Array.isArray(e)?e:[e]);tt[n]||(tt[n]=new WeakMap);var s=tt[n],i=[],l=new Set,d=new Set(o),h=function(m){!m||l.has(m)||(l.add(m),h(m.parentNode))};o.forEach(h);var c=function(m){!m||d.has(m)||Array.prototype.forEach.call(m.children,function(g){if(l.has(g))c(g);else try{var p=g.getAttribute(a),v=p!==null&&p!=="false",f=(De.get(g)||0)+1,x=(s.get(g)||0)+1;De.set(g,f),s.set(g,x),i.push(g),f===1&&v&&et.set(g,!0),x===1&&g.setAttribute(n,"true"),v||g.setAttribute(a,"true")}catch(N){console.error("aria-hidden: cannot operate on ",g,N)}})};return c(t),l.clear(),jt++,function(){i.forEach(function(m){var g=De.get(m)-1,p=s.get(m)-1;De.set(m,g),s.set(m,p),g||(et.has(m)||m.removeAttribute(a),et.delete(m)),p||m.removeAttribute(n)}),jt--,jt||(De=new WeakMap,De=new WeakMap,et=new WeakMap,tt={})}},ts=function(e,t,n){n===void 0&&(n="data-aria-hidden");var a=Array.from(Array.isArray(e)?e:[e]),o=t||Jr(e);return o?(a.push.apply(a,Array.from(o.querySelectorAll("[aria-live], script"))),es(a,o,n,"aria-hidden")):function(){return null}},W=O(xe(),1),ns=Object.defineProperty,re=(e,t)=>ns(e,"name",{value:t,configurable:!0}),Bt="Dialog",[ma,Ku]=Ln(Bt),[as,me]=ma(Bt),Wt=re(e=>{let{__scopeDialog:t,children:n,open:a,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,l=Y.useRef(null),d=Y.useRef(null),[h,c]=Wn({prop:a,defaultProp:o??!1,onChange:s,caller:Bt}),[m,g]=Y.useState(0),[p,v]=Y.useState(0);return(0,W.jsx)(as,{scope:t,triggerRef:l,contentRef:d,contentId:nt(),titleId:nt(),descriptionId:nt(),titlePresent:m>0,descriptionPresent:p>0,setTitleCount:g,setDescriptionCount:v,open:h,onOpenChange:c,onOpenToggle:Y.useCallback(()=>c(f=>!f),[c]),modal:i,children:n})},"Dialog"),ha="DialogPortal",[rs,ga]=ma(ha,{forceMount:void 0}),Ht=re(e=>{let{__scopeDialog:t,forceMount:n,children:a,container:o}=e,s=me(ha,t);return(0,W.jsx)(rs,{scope:t,forceMount:n,children:Y.Children.map(a,i=>(0,W.jsx)(Ft,{present:n||s.open,children:(0,W.jsx)(or,{asChild:!0,container:o,children:i})}))})},"DialogPortal"),Ot="DialogOverlay",qt=Y.forwardRef(re(function(e,t){let n=ga(Ot,e.__scopeDialog),{forceMount:a=n.forceMount,...o}=e,s=me(Ot,e.__scopeDialog);return s.modal?(0,W.jsx)(Ft,{present:a||s.open,children:(0,W.jsx)(os,{...o,ref:t})}):null},"DialogOverlay")),ss=nn("DialogOverlay.RemoveScroll"),os=Y.forwardRef(re(function(e,t){let{__scopeDialog:n,...a}=e,o=me(Ot,n),s=zn(),i=We(t,s);return(0,W.jsx)(Zr,{as:ss,allowPinchZoom:!0,shards:[o.contentRef],children:(0,W.jsx)(we.div,{"data-state":Yt(o.open),...a,ref:i,style:{pointerEvents:"auto",...a.style}})})},"DialogOverlayImpl")),Ke="DialogContent",Kt=Y.forwardRef(re(function(e,t){let n=ga(Ke,e.__scopeDialog),{forceMount:a=n.forceMount,...o}=e,s=me(Ke,e.__scopeDialog);return(0,W.jsx)(Ft,{present:a||s.open,children:s.modal?(0,W.jsx)(ls,{...o,ref:t}):(0,W.jsx)(is,{...o,ref:t})})},"DialogContent")),ls=Y.forwardRef(re(function(e,t){let n=me(Ke,e.__scopeDialog),a=Y.useRef(null),o=We(t,n.contentRef,a);return Y.useEffect(()=>{let s=a.current;if(s)return ts(s)},[]),(0,W.jsx)(xa,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:be(e.onCloseAutoFocus,s=>{s.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:be(e.onPointerDownOutside,s=>{let i=s.detail.originalEvent,l=i.button===0&&i.ctrlKey===!0;(i.button===2||l)&&s.preventDefault()}),onFocusOutside:be(e.onFocusOutside,s=>s.preventDefault())})},"DialogContentModal")),is=Y.forwardRef(re(function(e,t){let n=me(Ke,e.__scopeDialog),a=Y.useRef(!1),o=Y.useRef(!1);return(0,W.jsx)(xa,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{e.onCloseAutoFocus?.(s),s.defaultPrevented||(a.current||n.triggerRef.current?.focus(),s.preventDefault()),a.current=!1,o.current=!1},onInteractOutside:s=>{e.onInteractOutside?.(s),s.defaultPrevented||(a.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));let i=s.target;n.triggerRef.current?.contains(i)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})},"DialogContentNonModal")),xa=Y.forwardRef(re(function(e,t){let{__scopeDialog:n,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,l=me(Ke,n);return Ut(),(0,W.jsx)(W.Fragment,{children:(0,W.jsx)(tr,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:o,onUnmountAutoFocus:s,children:(0,W.jsx)(Za,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionPresent?l.descriptionId:void 0,"aria-labelledby":l.titlePresent?l.titleId:void 0,"data-state":Yt(l.open),...i,ref:t,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1)})})})},"DialogContentImpl")),ds="DialogTitle",zt=Y.forwardRef(re(function(e,t){let{__scopeDialog:n,...a}=e,o=me(ds,n),{setTitleCount:s}=o;return ke(()=>(s(i=>i+1),()=>s(i=>i-1)),[s]),(0,W.jsx)(we.h2,{id:o.titleId,...a,ref:t})},"DialogTitle")),us="DialogClose",va=Y.forwardRef(re(function(e,t){let{__scopeDialog:n,...a}=e,o=me(us,n);return(0,W.jsx)(we.button,{type:"button",...a,ref:t,onClick:be(e.onClick,()=>o.onOpenChange(!1))})},"DialogClose"));function Yt(e){return e?"open":"closed"}re(Yt,"getState");var k=O(L(),1),B=O(L(),1),y=O(xe(),1),ne="inline-flex h-8 items-center justify-center gap-1.5 rounded-md !border !border-[var(--so-input-line)] !bg-[var(--so-raised)] px-3 text-[12px] font-medium text-foreground transition-colors hover:!border-[var(--so-field-line)] hover:!bg-[var(--so-soft)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--so-signal)] disabled:opacity-50",kt="inline-flex h-8 items-center justify-center gap-1.5 rounded-md !border !border-[var(--so-signal)] !bg-[var(--so-signal)] px-3 text-[12px] font-medium !text-[var(--so-on-signal)] transition-opacity hover:opacity-90 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--so-signal)] disabled:opacity-50",cs="inline-flex h-8 items-center justify-center gap-1.5 rounded-md !border !border-[var(--so-danger)]/40 !bg-[var(--so-danger-soft)] px-3 text-[12px] font-medium !text-[var(--so-danger)] transition-colors hover:!border-[var(--so-danger)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--so-danger)] disabled:opacity-50",Sn="h-8 min-w-0 flex-1 rounded-md !border !border-[var(--so-input-line)] !bg-[var(--so-paper)] px-2.5 text-[12.5px] text-foreground placeholder:text-muted-foreground focus:outline-none focus:!border-[var(--so-signal)]",ps=2500;function fs({onClose:e,initialState:t}){let n=(0,B.useContext)(Ve),[a,o]=(0,B.useState)(t??null),[s,i]=(0,B.useState)(t===void 0),[l,d]=(0,B.useState)(null),[h,c]=(0,B.useState)(t?.activeSession?.profile??"default"),[m,g]=(0,B.useState)(t?.activeSession?.url??""),[p,v]=(0,B.useState)(""),[f,x]=(0,B.useState)(!1),[N,w]=(0,B.useState)(1),[j,C]=(0,B.useState)(null),[D,E]=(0,B.useState)(null),[P,H]=(0,B.useState)(!1),[Q,M]=(0,B.useState)(!1),[I,Z]=(0,B.useState)(null),he=(0,B.useRef)(null),S=a?.activeSession??null,le=(0,B.useCallback)(async(b,R)=>{let T=await fetch(b,{method:"POST",credentials:"same-origin",headers:Be({"content-type":"application/json",accept:"application/json",...n?{"x-csrf-token":n}:{}}),body:JSON.stringify({...R,...n?{csrf:n}:{}})}),_=await T.json().catch(()=>({}));return{ok:T.ok,status:T.status,data:_}},[n]),se=(0,B.useCallback)(async(b=!1)=>{b||i(!0);try{let R=await fetch("/api/browser/state",{method:"GET",credentials:"same-origin",cache:"no-store",headers:{accept:"application/json"}});if(!R.ok){b||E("Could not read shared browser state.");return}let T=await R.json();o(T),T.activeSession&&(c(T.activeSession.profile),g(_=>_===""?T.activeSession.url:_),w(_=>_+1)),b||E(null)}catch{b||E("Could not reach shared browser.")}finally{b||i(!1)}},[]);(0,B.useEffect)(()=>{t===void 0&&se(!1)},[t,se]),(0,B.useEffect)(()=>{if(!S)return;let b=window.setInterval(()=>{se(!0)},ps);return()=>window.clearInterval(b)},[S,se]);let dt=async b=>{b.preventDefault();let R=m.trim();if(R){d("open"),E(null),C(null);try{let T=await le("/api/browser/open",{profile:h,url:R,takeover:!0});if(!T.ok||!T.data.session){E(T.data.error??"Could not open URL.");return}g(T.data.session.url),C("Opened page in shared browser."),await se(!0)}catch{E("Could not open URL.")}finally{d(null)}}},Fe=async()=>{if(!S)return;let b=!S.takeover;d("takeover"),E(null),C(null);try{let R=await le("/api/browser/takeover",{session:S.id,active:b,...b?{reason:"Human took over from Web"}:{}});if(!R.ok||!R.data.session){E(R.data.error??"Could not update takeover state.");return}C(b?"You have control. Agents are paused on this browser.":"Handed back to agent."),b||H(!1),await se(!0)}catch{E("Could not update takeover state.")}finally{d(null)}},G=async(b,R)=>{if(S){if(!S.takeover){E("Take over the browser first before interacting.");return}d(R??"input"),E(null);try{let T=await le("/api/browser/takeover",{session:S.id,...b});if(!T.ok){E(T.data.error??"Input failed.");return}T.data.session&&g(T.data.session.url),w(_=>_+1),await se(!0)}catch{E("Input failed.")}finally{d(null)}}},_e=b=>{if(!S||!S.takeover)return;let R=b.currentTarget.getBoundingClientRect();if(R.width<=0||R.height<=0)return;let T=Math.min(1,Math.max(0,(b.clientX-R.left)/R.width)),_=Math.min(1,Math.max(0,(b.clientY-R.top)/R.height));G({kind:"click",x:T,y:_},"click")},Ge=b=>{if(!S||!S.takeover)return;let R=b.currentTarget.getBoundingClientRect(),T=R.width>0?Math.min(1,Math.max(0,(b.clientX-R.left)/R.width)):.5,_=R.height>0?Math.min(1,Math.max(0,(b.clientY-R.top)/R.height)):.5;G({kind:"scroll",x:T,y:_,deltaY:Math.round(b.deltaY)},"scroll")},ut=async b=>{if(b.preventDefault(),!p)return;let R=p;v(""),await G({kind:"type",text:R,secure:f},"type")},Xe=async()=>{if(S){if(P){H(!1);return}H(!0),M(!0),E(null);try{let b=await fetch(`/api/browser/credentials?session=${encodeURIComponent(S.id)}`,{method:"GET",credentials:"same-origin",cache:"no-store",headers:{accept:"application/json"}});if(!b.ok){E("Could not read matching 1Password items.");return}let R=await b.json();Z(R)}catch{E("Could not read matching 1Password items.")}finally{M(!1)}}},Ne=async(b,R,T)=>{if(S){d(`fill:${b}:${T}`),E(null),C(null);try{let _=await le("/api/browser/fill",{session:S.id,itemId:b,field:T});if(!_.ok||!_.data.ok){E(_.data.error??"1Password fill refused.");return}C(`Filled ${T} from “${R}” directly in host browser (zero secret bytes exposed).`),H(!1),w(ge=>ge+1)}catch{E("1Password fill failed.")}finally{d(null)}}},ie=async()=>{if(S){d("close"),E(null),C(null);try{let b=await le("/api/browser/close",{session:S.id});if(!b.ok){E(b.data.error??"Could not close session.");return}H(!1),C("Closed shared browser session."),await se(!0)}catch{E("Could not close session.")}finally{d(null)}}},Se=S!==null?`/api/browser/frame?session=${encodeURIComponent(S.id)}&t=${N}`:null;return(0,y.jsxs)("div",{className:"flex h-full flex-col gap-3 text-foreground","data-shared-browser-panel":"",children:[(0,y.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 border-b border-[var(--so-line)] pb-3",children:[(0,y.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,y.jsx)("h2",{className:"text-[15px] font-semibold tracking-tight text-foreground",children:"Shared Browser"}),S?(0,y.jsxs)("span",{"data-shared-browser-owner":S.takeover?"human":"agent",className:K("inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-[11px] font-medium",S.takeover?"bg-[var(--so-signal-soft)] text-[var(--so-signal)]":"bg-[var(--so-raised)] text-muted-foreground"),children:[(0,y.jsx)("span",{className:K("h-1.5 w-1.5 rounded-full",S.takeover?"bg-[var(--so-signal)]":"bg-[var(--so-done)]")}),S.takeover?"Human control":"Agent control"]}):(0,y.jsx)("span",{className:"inline-flex items-center rounded-full bg-[var(--so-raised)] px-2.5 py-0.5 text-[11px] font-medium text-muted-foreground",children:"Idle"})]}),(0,y.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[S&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("button",{type:"button","data-shared-browser-takeover":"",disabled:l!==null,onClick:()=>{Fe()},className:S.takeover?kt:ne,children:S.takeover?"Hand back to agent":"Take over"}),(0,y.jsxs)("div",{className:"relative",children:[(0,y.jsx)("button",{type:"button","data-shared-browser-1p-trigger":"",disabled:l!==null||!S.takeover,title:S.takeover?"List domain-matched 1Password logins (zero-leak host fill)":"Take over the browser first to use 1Password fill",onClick:()=>{Xe()},className:ne,children:"1Password fill"}),P&&(0,y.jsxs)("div",{role:"dialog","aria-label":"1Password fill","data-shared-browser-1p-popover":"",className:"absolute right-0 top-10 z-30 w-80 rounded-lg !border !border-[var(--so-line)] !bg-[var(--so-paper)] p-3 shadow-xl",children:[(0,y.jsxs)("div",{className:"mb-2 flex items-center justify-between gap-2",children:[(0,y.jsx)("span",{className:"text-[12px] font-semibold text-foreground",children:"1Password · Zero-leak fill"}),(0,y.jsx)("button",{type:"button",onClick:()=>H(!1),className:"rounded px-1.5 py-0.5 text-[11px] text-muted-foreground hover:text-foreground",children:"Close"})]}),Q?(0,y.jsx)("p",{className:"text-[12px] text-muted-foreground",children:"Checking domain-matched items…"}):!I||!I.available?(0,y.jsxs)("p",{className:"text-[12px] text-muted-foreground",children:["1Password CLI (",(0,y.jsx)("code",{children:"op"}),") is not available on this host."]}):I.items.length===0?(0,y.jsxs)("p",{className:"text-[12px] text-muted-foreground",children:["No 1Password logins match ",(0,y.jsx)("code",{className:"text-foreground",children:I.origin||"this page"}),"."]}):(0,y.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,y.jsxs)("p",{className:"text-[11px] text-muted-foreground",children:["Matched origin: ",(0,y.jsx)("code",{className:"text-foreground",children:I.origin}),". Focus the page field first, then click fill."]}),(0,y.jsx)("ul",{className:"flex max-h-60 flex-col gap-2 overflow-y-auto","data-shared-browser-1p-list":"",children:I.items.map(b=>(0,y.jsxs)("li",{"data-1p-item-id":b.id,className:"rounded-md !border !border-[var(--so-line)] !bg-[var(--so-raised)] p-2",children:[(0,y.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,y.jsx)("span",{className:"truncate text-[12.5px] font-medium text-foreground",children:b.title}),(0,y.jsx)("span",{className:"shrink-0 text-[10.5px] text-muted-foreground",children:b.vault})]}),(0,y.jsxs)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[(0,y.jsx)("button",{type:"button","data-1p-fill":`${b.id}:username`,disabled:l!==null,onClick:()=>{Ne(b.id,b.title,"username")},className:ne,children:"Username"}),(0,y.jsx)("button",{type:"button","data-1p-fill":`${b.id}:password`,disabled:l!==null,onClick:()=>{Ne(b.id,b.title,"password")},className:kt,children:"Password"}),b.hasOtp&&(0,y.jsx)("button",{type:"button","data-1p-fill":`${b.id}:otp`,disabled:l!==null,onClick:()=>{Ne(b.id,b.title,"otp")},className:ne,children:"OTP"})]})]},b.id))})]})]})]}),(0,y.jsx)("button",{type:"button","data-shared-browser-close-session":"",disabled:l!==null,onClick:()=>{ie()},className:cs,children:"End session"})]}),e&&(0,y.jsx)("button",{type:"button",onClick:e,className:ne,"data-shared-browser-dismiss":"",children:"Close"})]})]}),(0,y.jsxs)("form",{onSubmit:b=>{dt(b)},className:"flex flex-wrap items-center gap-2","data-shared-browser-nav":"",children:[(0,y.jsx)("select",{"aria-label":"Browser profile",value:h,onChange:b=>c(b.target.value),disabled:l!==null,className:"h-8 rounded-md !border !border-[var(--so-input-line)] !bg-[var(--so-raised)] px-2 text-[12px] text-foreground",children:(a?.profiles??[{id:"default",label:"Default"},{id:"work",label:"Work"},{id:"personal",label:"Personal"}]).map(b=>(0,y.jsx)("option",{value:b.id,children:b.label},b.id))}),S&&(0,y.jsxs)("div",{className:"flex items-center gap-1",children:[(0,y.jsx)("button",{type:"button",disabled:l!==null||!S.takeover,onClick:()=>{G({kind:"back"},"back")},className:ne,"aria-label":"Back",children:"←"}),(0,y.jsx)("button",{type:"button",disabled:l!==null||!S.takeover,onClick:()=>{G({kind:"forward"},"forward")},className:ne,"aria-label":"Forward",children:"→"}),(0,y.jsx)("button",{type:"button",disabled:l!==null||!S.takeover,onClick:()=>{G({kind:"reload"},"reload")},className:ne,"aria-label":"Reload",children:"↻"})]}),(0,y.jsx)("input",{type:"text","aria-label":"URL","data-shared-browser-url":"",placeholder:"https://example.com",value:m,onChange:b=>g(b.target.value),disabled:l!==null,className:Sn}),(0,y.jsx)("button",{type:"submit","data-shared-browser-go":"",disabled:l!==null||m.trim()==="",className:kt,children:S?"Go":"Open"})]}),S?.takeoverReason&&S.takeover&&(0,y.jsxs)("div",{className:"rounded-md !border !border-[var(--so-signal)]/30 !bg-[var(--so-signal-soft)] px-3 py-2 text-[12px] text-foreground",role:"status",children:["Takeover active: ",S.takeoverReason]}),j&&(0,y.jsx)("div",{className:"rounded-md !border !border-[var(--so-line)] !bg-[var(--so-raised)] px-3 py-1.5 text-[12px] text-foreground",role:"status",children:j}),D&&(0,y.jsx)("div",{className:"rounded-md !border !border-[var(--so-danger)]/40 !bg-[var(--so-danger-soft)] px-3 py-1.5 text-[12px] text-[var(--so-danger)]",role:"alert",children:D}),(0,y.jsx)("div",{ref:he,"data-shared-browser-viewport":"",onClick:_e,onWheel:Ge,className:K("relative flex min-h-[320px] flex-1 items-center justify-center overflow-hidden rounded-lg !border !border-[var(--so-line)] !bg-[#0b0b0c]",S?.takeover?"cursor-crosshair":"cursor-default"),children:s?(0,y.jsx)("p",{className:"text-[13px] text-muted-foreground",children:"Loading shared browser…"}):S&&Se?(0,y.jsx)("img",{src:Se,alt:S.title||S.url,"data-shared-browser-frame":"",draggable:!1,className:"h-full w-full select-none object-contain"}):(0,y.jsxs)("div",{className:"flex max-w-sm flex-col items-center gap-2 px-6 text-center",children:[(0,y.jsx)("p",{className:"text-[13.5px] font-medium text-foreground",children:"No active browser session"}),(0,y.jsx)("p",{className:"text-[12px] text-muted-foreground",children:"Enter a URL above to launch an isolated Chrome profile, or wait for an agent to open one."})]})}),S?.takeover&&(0,y.jsxs)("form",{onSubmit:b=>{ut(b)},className:"flex flex-wrap items-center gap-2 border-t border-[var(--so-line)] pt-2",children:[(0,y.jsx)("input",{type:f?"password":"text","aria-label":"Type into focused field","data-shared-browser-type-input":"",placeholder:f?"Type securely (masked from agents)…":"Type into focused browser field…",value:p,onChange:b=>v(b.target.value),disabled:l!==null,className:Sn}),(0,y.jsxs)("label",{className:"inline-flex items-center gap-1.5 text-[11.5px] text-muted-foreground",children:[(0,y.jsx)("input",{type:"checkbox",checked:f,onChange:b=>x(b.target.checked)}),"Mask from agent"]}),(0,y.jsx)("button",{type:"submit",disabled:l!==null||p==="",className:ne,children:"Send text"}),(0,y.jsx)("button",{type:"button",disabled:l!==null,onClick:()=>{G({kind:"key",key:"Enter"},"key")},className:ne,children:"Enter"}),(0,y.jsx)("button",{type:"button",disabled:l!==null,onClick:()=>{G({kind:"key",key:"Tab"},"key")},className:ne,children:"Tab"})]})]})}function ms({open:e,onOpenChange:t}){return e?(0,y.jsx)(Wt,{open:e,onOpenChange:t,children:(0,y.jsxs)(Ht,{container:typeof document>"u"?void 0:document.querySelector("[data-view]")??void 0,children:[(0,y.jsx)(qt,{className:"ui-dialog-overlay"}),(0,y.jsxs)(Kt,{"data-shared-browser-drawer":"","aria-describedby":void 0,className:"fixed inset-y-0 right-0 z-50 flex w-full max-w-4xl flex-col !border-l !border-[var(--so-line)] !bg-[var(--so-paper)] p-5 shadow-2xl focus:outline-none",children:[(0,y.jsx)(zt,{className:"sr-only",children:"Shared Browser"}),(0,y.jsx)(fs,{onClose:()=>t(!1)})]})]})}):null}var r=O(xe(),1),hs=2e3,st=200,En=24,gs=4,xs=1e4,vs=3e4,bs=3e4,ws=5e3,ze={working:"Working","needs-you":"Needs you",done:"Done",failed:"Failed",stopped:"Stopped",parked:"Parked"},Cn={edit:"Editing",command:"Running",read:"Reading",search:"Searching for",lookup:"Looking up",plan:"Planning",delegate:"Handing off",tool:"Using a tool",session:"Starting",message:""},ys={command:"Running a command",edit:"Editing files",read:"Reading the code",search:"Searching the code",lookup:"Looking something up"},js=e=>e.target?`${Cn[e.kind??"tool"]??"Working"} ${e.target}`:ys[e.kind??""]??Cn[e.kind??"tool"]??"Working",ba=()=>({lines:[],open:[],editedFiles:[]});function Rn(e,t,n){let a=[...e.lines],o=e.open,s=e.editedFiles;if(t.k==="say")a.push(...t.t??[]);else if(t.k==="step"){let i=js(t);a.push(`→ ${i}`),t.once!==!0&&t.id!==void 0&&(o=[...o.filter(([l])=>l!==t.id),[t.id,i]]),t.kind==="edit"&&t.target&&!s.includes(t.target)&&(s=[...s,t.target])}else t.k==="done"?(o=o.filter(([i])=>i!==t.id),a.push(...(t.out??[]).map(i=>` ${i}`)),t.ok===!1&&a.push("✗ failed")):t.k==="start"?a.push("The agent session started."):t.k==="cut"?a.push("A line was too long to show."):t.k==="cap"&&a.push("Output stopped at its size limit.");return{lines:a.slice(-n),open:o,editedFiles:s}}var wa=e=>e.open.at(-1)?.[1]??null,qe={main:ba(),children:new Map,mainState:"loading",subState:"loading",earlier:!1,restarted:!1,subRestarted:!1,over:!1},Dn=e=>e!==void 0&&Number.isFinite(Date.parse(e))?Date.parse(e):Date.now();function ks(e,t,n,a=st){if(n.error!==void 0){if(n.error==="missing")return t==="main"?{...e,mainState:"ready"}:{...e,subState:"ready"};let d=n.error==="off"?"off":n.error==="gone"||n.error==="unavailable"?"unavailable":"error";return t==="main"?{...e,mainState:d}:{...e,subState:d}}let o=n.restarted===!0,s=t==="main"&&o?{lines:["Output restarted."],open:[],editedFiles:[]}:e.main,i=t==="sub"&&o?new Map:new Map(e.children),l=e.over&&!(t==="sub"&&o);for(let d of n.records??[]){if(t==="main"){d.s===void 0&&(s=Rn(s,d,a));continue}if(d.k==="over"){l=!0;continue}if(d.s===void 0)continue;if(d.k==="child"){i.set(d.s,{...ba(),s:d.s,...d.via===void 0?{}:{via:d.via},desc:d.desc??"Subagent",startedAt:Dn(d.at),endedAt:null,ok:null,expired:!1});continue}let h=i.get(d.s);h!==void 0&&(d.k==="end"?i.set(d.s,{...h,open:[],endedAt:d.at===void 0?0:Math.max(Dn(d.at),h.startedAt),ok:d.ok??null}):i.set(d.s,{...h,...Rn(h,d,a)}))}return{...e,main:s,children:i,over:l,earlier:e.earlier||n.earlier===!0,restarted:e.restarted||o,subRestarted:t==="sub"?e.subRestarted||o:e.subRestarted,...t==="main"?{mainState:"ready"}:{subState:"ready"}}}function $s(e,t=(...n)=>fetch(...n)){let n=new Map,a=new Set,o=new Map,s=new Map,i=new Map,l=!1,d=null,h=()=>{if(l||d!==null||a.size===0)return;let p=Math.min(...[...a].map(v=>s.get(v)??Date.now()));d=setTimeout(()=>{d=null,g()},Math.max(50,p-Date.now()))},c=(p,v)=>{let f=Math.min(bs,(i.get(p)??500)*2);i.set(p,f),s.set(p,Date.now()+Math.max(f,v??0)),a.add(p),e(p,{error:"retry"})},m=p=>{if(p===null)return;let v=Number(p);if(Number.isFinite(v)&&v>0)return v*1e3;let f=Date.parse(p);return Number.isFinite(f)?Math.max(0,f-Date.now()):void 0},g=()=>{if(!l){for(let p of[...a]){if(o.size>=gs)break;if(o.has(p)||(s.get(p)??0)>Date.now())continue;a.delete(p);let v=new AbortController;o.set(p,v);let[f,x]=p.split(":"),N=n.get(p),w=setTimeout(()=>v.abort(),xs);t(`/agents/live/${f}?file=${x}${N===void 0?"":`&cursor=${encodeURIComponent(N)}`}`,{signal:v.signal,credentials:"same-origin"}).then(async j=>{if(l)return;if(j.status===404){e(p,{error:"gone"});return}if(!j.ok){c(p,m(j.headers.get("retry-after")));return}let C=await j.json();l||(C.cursor!==void 0&&n.set(p,C.cursor),i.delete(p),s.delete(p),C.more===!0&&a.add(p),e(p,C))}).catch(()=>{l||c(p)}).finally(()=>{clearTimeout(w),o.delete(p),l||g()})}h()}};return{want(p){if(!l){for(let v of p)a.add(v);g()}},keep(p){for(let v of[...a,...o.keys(),...n.keys(),...s.keys()])p.has(v)||(o.get(v)?.abort(),o.delete(v),a.delete(v),n.delete(v),s.delete(v),i.delete(v))},dispose(){l=!0,d!==null&&clearTimeout(d);for(let p of o.values())p.abort();o.clear(),a.clear()}}}var Te={working:"info",done:"success",failed:"danger",stopped:"neutral",parked:"neutral"},Ns="border-wait";function $e({tone:e,children:t}){return(0,r.jsx)(an,{size:"chip",dot:!0,tone:e,"data-live-chip":!0,children:t})}function it({lines:e,short:t,tall:n=!1}){let a=(0,k.useRef)(null),[o,s]=(0,k.useState)(!0),[i,l]=(0,k.useState)(!1);return(0,k.useLayoutEffect)(()=>{let d=a.current;d!==null&&(o&&(d.scrollTop=d.scrollHeight),l(d.scrollTop>1))}),e.length===0?(0,r.jsx)("p",{className:"text-[12px] text-muted-foreground",children:"No output yet."}):(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("div",{ref:a,tabIndex:0,role:"log","aria-label":"Output",onScroll:d=>{let h=d.currentTarget;s(h.scrollHeight-h.scrollTop-h.clientHeight<4),l(h.scrollTop>1)},className:K("overflow-y-auto overscroll-contain rounded-md border border-border bg-code-bg px-2.5 py-2",n?"max-h-[60vh]":t?"max-h-[calc(4*1.5*12px+1rem)]":"max-h-[calc(12*1.5*12px+1rem)] phone:max-h-[calc(4*1.5*12px+1rem)]"),children:(0,r.jsx)("pre",{className:"whitespace-pre-wrap break-words font-mono text-[12px] leading-[1.5] text-foreground","data-live-lines":!0,children:e.join(`
43
- `)})}),i&&(0,r.jsx)("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-px top-px h-6 rounded-t-md bg-[linear-gradient(to_bottom,var(--so-code-bg)_30%,transparent)]"}),!o&&(0,r.jsx)("button",{type:"button",onClick:()=>s(!0),className:"absolute bottom-2 right-2 rounded-sm border border-border bg-card px-2 py-0.5 text-[11.5px] text-foreground shadow-pill phone:min-h-11",children:"Jump to latest"})]})}var ya=e=>K("relative pl-5",!e&&"pb-2","before:absolute before:left-0 before:top-0 before:h-[22px] before:w-3.5 before:rounded-bl-sm before:border-b before:border-l before:border-border before:content-['']",!e&&"after:absolute after:bottom-0 after:left-0 after:top-[22px] after:border-l after:border-border after:content-['']");function Gt({child:e,all:t,now:n,last:a}){let o=e.endedAt===null?"Working":e.ok===!1?"Ended with an error":e.ok===!0?"Done":"Ended",s=e.endedAt===null?"working":e.ok===!1?"failed":e.ok===!0?"done":"stopped",i=t.filter(l=>l.via===e.s);return(0,r.jsxs)("li",{className:ya(a),"data-live-child":e.s,children:[(0,r.jsxs)("article",{className:"flex flex-col gap-2 rounded-card border border-border bg-card p-3",children:[(0,r.jsxs)("header",{className:"flex items-start gap-2",children:[(0,r.jsx)("h3",{className:"line-clamp-2 min-w-0 flex-1 text-[13px] font-semibold leading-[1.35]",title:e.desc,children:e.desc}),(0,r.jsx)($e,{tone:Te[s]??"info",children:o})]}),(0,r.jsxs)("p",{className:"flex gap-2 text-[12px] text-muted-foreground",children:[(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.endedAt===null?wa(e)??"":""}),(0,r.jsx)("span",{className:"shrink-0 tabular-nums",children:Me(new Date(e.startedAt).toISOString(),e.endedAt??n)})]}),(0,r.jsx)(it,{lines:e.lines,short:!0})]}),i.length>0&&(0,r.jsx)("ul",{"aria-label":`Subagents of ${e.desc}`,className:"ml-4 mt-2 flex flex-col",children:i.map((l,d)=>(0,r.jsx)(Gt,{child:l,all:t,now:n,last:d===i.length-1},l.s))})]})}function ja({tile:e,stream:t,streamed:n,showLive:a,tall:o=!1,lost:s=!1}){let i="text-[12px] text-muted-foreground",l="text-[11.5px] text-muted-foreground",d=!e.local||t.mainState==="off"?(0,r.jsx)("p",{className:i,children:"Output is on another computer."}):n?t.mainState==="unavailable"?(0,r.jsx)("p",{className:i,children:"Output unavailable."}):(0,r.jsxs)(r.Fragment,{children:[t.earlier&&(0,r.jsx)("p",{className:l,children:"Earlier output isn't shown."}),t.mainState==="error"&&(0,r.jsx)("p",{className:l,children:"Couldn't read the latest output. Retrying."}),t.mainState==="loading"?(0,r.jsx)("p",{className:i,children:"Loading output…"}):(0,r.jsx)(it,{lines:t.main.lines,short:!1,tall:o})]}):(0,r.jsxs)("p",{className:K(i,"flex items-center gap-2"),children:["Not shown live.",(0,r.jsx)("button",{type:"button",onClick:a,className:"rounded-sm border border-border bg-card px-2 py-0.5 text-[11.5px] text-foreground phone:min-h-11",children:"Show live"})]});return(0,r.jsxs)(r.Fragment,{children:[s&&(0,r.jsx)("p",{className:l,children:"Reconnecting… these lines may not be the latest."}),d,t.subState==="unavailable"&&(0,r.jsx)("p",{className:l,children:"Subagents' output unavailable."}),t.subState==="error"&&(0,r.jsx)("p",{className:l,children:"Couldn't read the subagents' output. Retrying."}),t.subRestarted&&(0,r.jsx)("p",{className:l,children:"Subagents' output restarted."}),t.over&&(0,r.jsx)("p",{className:l,children:"More subagents started than are shown."})]})}function Pt(e){let t=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID().replace(/-/g,"").slice(0,16):`${Date.now().toString(36)}${Math.random().toString(36).slice(2,10)}`;return`${e}-${t}`}function ka(e,t,n){return e.why==="quiet"&&e.quietSince!==null?`Quiet for ${Me(e.quietSince,n)}`:e.why==="question"?"Asked a question":e.endedAt!==null?"":wa(t.main)??e.now??""}var Oe="inline-flex h-7 items-center justify-center rounded-md border border-[var(--so-input-line)] bg-[var(--so-raised)] px-2.5 text-[12px] font-medium text-foreground transition-colors hover:border-[var(--so-field-line)] hover:bg-[var(--so-soft)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--so-signal)] disabled:opacity-50 phone:min-h-9 phone:px-3",Ss="inline-flex h-7 items-center justify-center rounded-md border border-[var(--so-danger)]/35 bg-[var(--so-danger-soft)] px-2.5 text-[12px] font-medium text-[var(--so-danger)] transition-colors hover:border-[var(--so-danger)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--so-danger)] disabled:opacity-50 phone:min-h-9 phone:px-3",Es="inline-flex h-7 items-center justify-center rounded-md border border-[var(--so-signal)] bg-[var(--so-signal)] px-2.5 text-[12px] font-medium text-[var(--so-on-signal)] transition-opacity hover:opacity-90 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--so-signal)] disabled:opacity-50 phone:min-h-9 phone:px-3";function $a({tile:e,stream:t,childrenCount:n}){let a=Math.max(e.subagentCount??0,n),o=e.changedFiles??t.main.editedFiles.length;return a<=0&&o<=0?null:(0,r.jsxs)("div",{className:"agents-live-pills",children:[a>0&&(0,r.jsxs)("span",{className:"agents-live-pill agents-live-pill--signal inline-flex items-center rounded-full border border-[var(--so-signal)]/40 bg-[var(--so-signal-soft)] px-2 py-0.5 text-[11px] font-medium tabular-nums text-[var(--so-signal)]","data-live-helpers":a,children:[a," ",a===1?"helper":"helpers"]}),o>0&&(0,r.jsxs)("span",{className:"agents-live-pill inline-flex items-center rounded-full border border-[var(--so-line)] bg-[var(--so-raised)] px-2 py-0.5 text-[11px] font-medium tabular-nums text-foreground","data-live-files":o,children:["+",o," ",o===1?"file":"files"]})]})}function Na({tile:e,actionState:t,onAction:n,onInspect:a}){if(e.endedAt!==null||e.taskId==="")return a===void 0?null:(0,r.jsx)("div",{className:"agents-live-tile-acts flex flex-wrap items-center gap-2 border-t border-border pt-2.5","data-live-actions":e.runId,children:(0,r.jsx)("button",{type:"button",className:Oe,"data-live-inspect":e.runId,onClick:a,children:"Inspect"})});let o=t?.paused??(e.paused===!0||e.pauseState==="paused"),s=t?.busy??null;return(0,r.jsxs)("div",{className:"agents-live-tile-acts flex flex-wrap items-center gap-2 border-t border-border pt-2.5","data-live-actions":e.runId,children:[a!==void 0&&(0,r.jsx)("button",{type:"button",className:Es,"data-live-inspect":e.runId,onClick:a,children:"Inspect"}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 ml-auto",children:[o?(0,r.jsx)("button",{type:"button",className:K("agents-live-act-btn",Oe),"data-live-action":"resume",disabled:s!==null,onClick:()=>n(e,"resume"),children:s==="resume"?"Resuming…":"Resume"}):(0,r.jsx)("button",{type:"button",className:K("agents-live-act-btn",Oe),"data-live-action":"pause",disabled:s!==null,onClick:()=>n(e,"pause"),children:s==="pause"?"Pausing…":"Pause"}),(0,r.jsx)("button",{type:"button",className:K("agents-live-act-btn agents-live-act-btn--danger",Ss),"data-live-action":"stop",disabled:s!==null,onClick:()=>n(e,"stop"),children:s==="stop"?"Stopping…":"Stop"})]}),t?.message&&(0,r.jsx)("p",{className:"agents-live-act-msg w-full text-[11.5px] text-muted-foreground",role:"status","data-live-action-status":!0,children:t.message})]})}function Tt({tile:e,stream:t,streamed:n,now:a,repairs:o,streams:s,streamedIds:i,showLive:l,openRun:d,actionStates:h,onAction:c,nested:m}){let g=e.state==="needs-you",p=ka(e,t,a),v=[...t.children.values()].filter(w=>!w.expired).sort((w,j)=>w.s-j.s),f=v.filter(w=>w.via===void 0||!v.some(j=>j.s===w.via)),x=[e.project?.split("/").pop(),e.role,e.agent,e.model].filter(Boolean).join(" · "),N=g?"needs":e.state;return(0,r.jsxs)("li",{className:K("flex min-w-0 flex-col gap-2",m!==void 0&&ya(m.last)),"data-live-tile":e.runId,"data-live-state":e.state,children:[(0,r.jsxs)("article",{className:K("flex min-w-0 flex-col gap-2.5 rounded-card border bg-card p-3.5",g?Ns:"border-border"),children:[(0,r.jsxs)("header",{className:"flex flex-col gap-1",children:[(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)("h2",{className:"line-clamp-2 min-w-0 flex-1 text-[15px] font-semibold leading-[1.3]",title:e.title,children:(0,r.jsx)("button",{type:"button","data-live-open":e.runId,onClick:()=>d(e.runId),className:"text-left hover:underline hover:underline-offset-4 phone:min-h-11",children:e.title})}),(0,r.jsx)($e,{tone:N==="needs"?"needs":Te[N]??"info",children:ze[e.state]})]}),(0,r.jsx)("p",{className:"truncate font-mono text-[11px] text-muted-foreground",title:x,children:x})]}),(0,r.jsxs)("p",{className:"flex gap-2 text-[13px]",children:[(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate","data-live-now":!0,children:p}),(0,r.jsx)("span",{className:"shrink-0 text-[12px] tabular-nums text-muted-foreground",children:Me(e.startedAt,e.endedAt===null?a:Date.parse(e.endedAt))})]}),(0,r.jsx)($a,{tile:e,stream:t,childrenCount:v.length}),(0,r.jsx)(ja,{tile:e,stream:t,streamed:n,showLive:()=>l(e.runId)}),(0,r.jsx)(Na,{tile:e,actionState:h.get(e.runId),onAction:c,onInspect:()=>d(e.runId)})]}),o.length>0&&(0,r.jsx)("ul",{"aria-label":`Repairs of ${e.title}`,className:"ml-4 flex flex-col gap-2",children:o.map(w=>(0,r.jsx)(Tt,{tile:w,stream:s.get(w.runId)??qe,streamed:i.has(w.runId),now:a,repairs:[],streams:s,streamedIds:i,showLive:l,openRun:d,actionStates:h,onAction:c},w.runId))}),f.length>0&&(0,r.jsx)("ul",{"aria-label":`Subagents of ${e.title}`,className:"ml-4 flex flex-col",children:f.map((w,j)=>(0,r.jsx)(Gt,{child:w,all:v,now:a,last:j===f.length-1},w.s))})]})}function Cs({runId:e,fileIndex:t,initialHunks:n}){let[a,o]=(0,k.useState)(n);return(0,k.useEffect)(()=>{if(n!==null){o(n);return}let s=!0;return fetch(`/agents/live/run/${e}/diff?file=${t}`,{credentials:"same-origin"}).then(i=>i.ok?i.json():null).then(i=>{s&&o(Array.isArray(i?.file?.hunks)?i.file.hunks:"error")}).catch(()=>{s&&o("error")}),()=>{s=!1}},[e,t,n]),a===null?(0,r.jsx)("p",{className:"px-3 py-2 text-[12px] text-muted-foreground",children:"Reading hunks…"}):a==="error"?(0,r.jsx)("p",{className:"px-3 py-2 text-[12px] text-muted-foreground",children:"This file's diff couldn't be read."}):a.length===0?(0,r.jsx)("p",{className:"px-3 py-2 text-[12px] text-muted-foreground",children:"No hunks for this file."}):(0,r.jsx)("div",{"data-live-diff-hunks":t,children:a.map((s,i)=>(0,r.jsxs)("div",{className:"agents-diff-hunk",children:[(0,r.jsx)("div",{className:"agents-diff-hunk-head",children:s.header}),(0,r.jsx)("ol",{className:"agents-diff-lines",children:s.lines.map((l,d)=>{let h=l.kind==="addition"||l.kind==="add"||l.kind==="+",c=l.kind==="deletion"||l.kind==="del"||l.kind==="-";return(0,r.jsxs)("li",{className:K("agents-diff-line",h&&"agents-diff-line--addition",c&&"agents-diff-line--deletion"),"data-diff-line-kind":l.kind,children:[(0,r.jsx)("span",{className:"agents-diff-ln",children:l.oldLine??""}),(0,r.jsx)("span",{className:"agents-diff-ln",children:l.newLine??""}),(0,r.jsx)("span",{"aria-hidden":"true",className:"agents-diff-sigil",children:h?"+":c?"−":" "}),(0,r.jsx)("span",{className:"agents-diff-code",children:l.text})]},d)})})]},i))})}function Rs({runId:e,running:t,active:n}){let[a,o]=(0,k.useState)({status:"loading"}),[s,i]=(0,k.useState)(null);if((0,k.useEffect)(()=>{if(!n)return;let g=!1,p=0,v=async()=>{try{let f=await fetch(`/agents/live/run/${e}/diff`,{cache:"no-store",credentials:"same-origin"});if(g)return;if(f.status===404||!f.ok)o(x=>x.status==="ready"?x:{status:"empty"});else{let x=await f.json();if(g)return;let N=Array.isArray(x?.files)?x.files:[];N.length===0?o({status:"empty"}):o({status:"ready",data:{version:x?.version??1,files:N,...x?.live===void 0?{}:{live:x.live},...x?.totals===void 0?{}:{totals:x.totals},...x?.file===void 0?{}:{file:x.file}}})}}catch{g||o(f=>f.status==="ready"?f:{status:"empty"})}!g&&t&&(p=window.setTimeout(()=>{v()},ws))};return v(),()=>{g=!0,window.clearTimeout(p)}},[e,t,n]),a.status==="loading")return(0,r.jsx)("p",{className:"text-[12.5px] text-muted-foreground","data-live-diff-loading":!0,children:"Reading worktree diff…"});if(a.status==="empty")return(0,r.jsxs)("div",{className:"flex flex-col gap-2","data-live-diff-empty":!0,children:[t&&(0,r.jsx)("div",{className:"agents-diff-head",children:(0,r.jsx)("span",{className:"agents-diff-badge agents-diff-badge--live","data-live-diff-badge":!0,children:"Live worktree"})}),(0,r.jsx)("p",{className:"text-[12.5px] text-muted-foreground",children:"No changes yet"})]});let{data:l}=a,d=l.live!==!1&&t,h=l.totals?.files??l.files.length,c=l.totals?.added??l.files.reduce((g,p)=>g+p.added,0),m=l.totals?.removed??l.files.reduce((g,p)=>g+p.removed,0);return(0,r.jsxs)("div",{className:"flex flex-col gap-3","data-live-diff":!0,children:[(0,r.jsxs)("div",{className:"agents-diff-head",children:[(0,r.jsx)("span",{className:K("agents-diff-badge inline-flex items-center rounded-full border px-2.5 py-0.5 text-[11.5px] font-medium",d?"agents-diff-badge--live border-[var(--so-signal)]/40 bg-[var(--so-signal-soft)] text-[var(--so-signal)]":"border-[var(--so-line)] bg-[var(--so-raised)] text-foreground"),"data-live-diff-badge":!0,children:d?"Live worktree":"Diff snapshot"}),(0,r.jsxs)("span",{className:"agents-diff-totals",children:[h," ",h===1?"file":"files"," · ",(0,r.jsxs)("span",{className:"agents-add",children:["+",c]})," ",(0,r.jsxs)("span",{className:"agents-del",children:["−",m]})]})]}),(0,r.jsx)("ul",{className:"agents-diff-list","data-live-diff-files":!0,children:l.files.map((g,p)=>{let v=g.index??p,f=s===v,x=l.file?.path===g.path&&Array.isArray(l.file.hunks)?l.file.hunks:null;return(0,r.jsxs)("li",{className:"agents-diff-file","data-live-diff-file":g.path,children:[(0,r.jsxs)("div",{className:"agents-diff-file-row",children:[(0,r.jsx)("span",{className:"agents-diff-file-path",title:g.path,children:g.path}),(0,r.jsx)("span",{className:"agents-diff-file-stat",children:g.binary?(0,r.jsx)("span",{className:"text-muted-foreground",children:"binary"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("span",{className:"agents-add",children:["+",g.added]}),(0,r.jsxs)("span",{className:"agents-del",children:["−",g.removed]})]})}),!g.binary&&(0,r.jsx)("button",{type:"button",className:K("agents-live-act-btn",Oe),"aria-expanded":f,"data-live-diff-toggle":v,onClick:()=>i(f?null:v),children:f?"Hide":"Show"})]}),f&&(0,r.jsx)(Cs,{runId:e,fileIndex:v,initialHunks:x})]},`${v}:${g.path}`)})})]})}function Ds({tile:e,csrf:t,onSent:n}){let[a,o]=(0,k.useState)(""),[s,i]=(0,k.useState)(!1),[l,d]=(0,k.useState)(null);if(e.endedAt!==null||e.taskId==="")return null;let h=async()=>{let c=a.trim();if(!(s||c==="")){i(!0),d(null);try{let m=await fetch(`/t/${encodeURIComponent(e.taskId)}/steer`,{method:"POST",credentials:"same-origin",redirect:"manual",headers:Be({accept:"application/json"}),body:new URLSearchParams({csrf:t,run:String(e.runId),key:Pt("live"),note:c,return:"agents"})});m.type==="opaqueredirect"||m.ok?(o(""),d({ok:!0,text:"Sent to agent."}),n()):d({ok:!1,text:"Couldn't send note. Try again."})}catch{d({ok:!1,text:"Couldn't reach Toolroll. Your note is kept."})}finally{i(!1)}}};return(0,r.jsxs)("div",{className:"agents-inspector-steer","data-inspector-steer":!0,children:[(0,r.jsxs)("div",{className:"agents-inspector-steer-row",children:[(0,r.jsx)("textarea",{className:"agents-inspector-steer-input min-h-[38px] max-h-[120px] min-w-0 flex-1 resize-y rounded-md border border-[var(--so-input-line)] bg-[var(--so-raised)] px-2.5 py-2 text-[13px] leading-[1.45] text-foreground placeholder:text-muted-foreground focus-visible:border-[var(--so-signal)] focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-[var(--so-signal)]","aria-label":"Steer this agent",placeholder:"Steer this agent…",rows:2,maxLength:4e3,value:a,disabled:s,onChange:c=>{o(c.target.value),l!==null&&d(null)},onKeyDown:c=>{c.key==="Enter"&&!c.shiftKey&&!c.nativeEvent.isComposing&&(c.preventDefault(),h())}}),(0,r.jsx)("button",{type:"button",className:"agents-inspector-steer-send inline-flex h-[38px] shrink-0 items-center justify-center rounded-md border border-[var(--so-signal)] bg-[var(--so-signal)] px-3.5 text-[12.5px] font-medium text-[var(--so-on-signal)] transition-opacity hover:opacity-90 disabled:opacity-45","data-inspector-steer-send":!0,disabled:s||a.trim()==="",onClick:()=>{h()},children:s?"Sending…":"Steer"})]}),l!==null&&(0,r.jsx)("p",{className:K("text-[12px]",l.ok?"text-muted-foreground":"text-destructive"),role:"status","data-inspector-steer-status":!0,children:l.text})]})}function Is({runId:e,tile:t,stream:n,streamed:a,now:o,lost:s,csrf:i,actionState:l,onAction:d,onSent:h,onClose:c,showLive:m}){let g=(0,k.useRef)(null),[p,v]=(0,k.useState)("live"),f=[...n.children.values()].sort((w,j)=>w.s-j.s),x=f.filter(w=>w.via===void 0||!f.some(j=>j.s===w.via)),N=t!==null&&t.taskId!==""?`/term?task=${encodeURIComponent(t.taskId)}&run=${t.runId}`:`/term?run=${e}`;return(0,r.jsx)(Wt,{open:!0,onOpenChange:w=>{w||c()},children:(0,r.jsxs)(Ht,{container:typeof document>"u"?void 0:document.querySelector("[data-view]")??void 0,children:[(0,r.jsx)(qt,{className:"ui-dialog-overlay"}),(0,r.jsxs)(Kt,{"data-live-full":!0,"data-live-inspector":e,"aria-describedby":void 0,onOpenAutoFocus:w=>{w.preventDefault(),g.current?.focus()},onCloseAutoFocus:w=>{w.preventDefault(),(document.querySelector(`[data-live-open="${e}"]`)??document.querySelector("[data-live-grid]"))?.focus()},className:"ui-dialog-content agents-inspector-drawer",children:[(0,r.jsxs)("header",{className:"flex items-start gap-3",children:[(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)(zt,{className:"text-[18px] font-semibold leading-[1.3]","data-live-full-title":!0,children:t?.title??"This agent isn't on the grid anymore"}),t!==null&&(0,r.jsx)("p",{className:"truncate font-mono text-[11px] text-muted-foreground",children:[t.project?.split("/").pop(),t.role,t.agent,t.model].filter(Boolean).join(" · ")})]}),t!==null&&(0,r.jsx)($e,{tone:t.state==="needs-you"?"needs":Te[t.state]??"info",children:ze[t.state]}),(0,r.jsx)(va,{ref:g,className:K("shrink-0",Oe),children:"Close"})]}),(0,r.jsx)(ln,{label:"Inspector",current:p,onChange:w=>v(w==="diff"||w==="terminal"?w:"live"),items:[{key:"live",label:"Live"},{key:"diff",label:"Diff"},{key:"terminal",label:"Terminal"}]}),(0,r.jsxs)("div",{className:"agents-inspector-body",children:[p==="live"&&(0,r.jsx)("div",{role:"tabpanel","aria-label":"Live","data-inspector-panel":"live",className:"flex flex-col gap-3",children:t!==null&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("p",{className:"flex items-center gap-3 text-[13px]",children:[(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate",children:ka(t,n,o)}),(0,r.jsx)("span",{className:"shrink-0 text-[12px] tabular-nums text-muted-foreground",children:Me(t.startedAt,t.endedAt===null?o:Date.parse(t.endedAt))}),t.taskHref!==null&&(0,r.jsx)("a",{href:t.taskHref,className:"shrink-0 text-[12.5px] underline decoration-border underline-offset-4 hover:decoration-current phone:inline-flex phone:min-h-11 phone:items-center",children:"Open task"})]}),(0,r.jsx)($a,{tile:t,stream:n,childrenCount:f.length}),(0,r.jsx)(Na,{tile:t,actionState:l,onAction:d}),(0,r.jsx)(ja,{tile:t,stream:n,streamed:a,showLive:m,tall:!0,lost:s}),x.length>0&&(0,r.jsxs)("section",{"aria-label":"Subagents",className:"flex flex-col gap-2",children:[(0,r.jsxs)("h3",{className:"text-[13px] font-semibold",children:["Subagents ",(0,r.jsx)("span",{className:"font-normal tabular-nums text-muted-foreground",children:f.length})]}),(0,r.jsx)("ul",{className:"flex flex-col",children:x.map((w,j)=>(0,r.jsx)(Gt,{child:w,all:f,now:o,last:j===x.length-1},w.s))})]}),(0,r.jsx)(Ds,{tile:t,csrf:i,onSent:h})]})}),p==="diff"&&(0,r.jsx)("div",{role:"tabpanel","aria-label":"Diff","data-inspector-panel":"diff",className:"flex flex-col gap-3",children:(0,r.jsx)(Rs,{runId:e,running:t!==null&&t.endedAt===null,active:p==="diff"})}),p==="terminal"&&(0,r.jsx)("div",{role:"tabpanel","aria-label":"Terminal","data-inspector-panel":"terminal",className:"flex flex-col gap-3",children:(0,r.jsxs)("div",{className:"agents-term-card",children:[(0,r.jsx)("p",{className:"text-[13px] text-foreground",children:"Attach to this run's live PTY session in the interactive terminal."}),t!==null&&(0,r.jsxs)("p",{className:"font-mono text-[11.5px] text-muted-foreground",children:["Run #",t.runId," · ",t.taskId]}),(0,r.jsx)("a",{href:N,className:"agents-term-link","data-inspector-terminal-link":!0,children:"Open interactive terminal ↗"})]})})]})]})]})})}var Sa=e=>["lead chat",e.project?.split("/").pop(),e.stepAt.length>1?`step ${e.stepAt.length}`:null].filter(Boolean).join(" · "),As={lead:"lead chat",project:"project chat",task:"task chat"};function Os({thread:e,runs:t,label:n,render:a}){return t.length===0?null:(0,r.jsx)("ul",{"aria-label":n,className:"ml-4 flex flex-col","data-live-filed":e,children:t.map((o,s)=>a(o,s===t.length-1))})}function Ps({lead:e,now:t,openLead:n}){return(0,r.jsxs)("article",{className:"flex min-w-0 flex-col gap-2.5 rounded-card border border-border bg-card p-3.5",children:[(0,r.jsxs)("header",{className:"flex flex-col gap-1",children:[(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)("h2",{className:"line-clamp-2 min-w-0 flex-1 text-[15px] font-semibold leading-[1.3]",title:e.title,children:(0,r.jsx)("button",{type:"button","data-live-open-lead":e.thread,onClick:()=>n(e.thread),className:"text-left hover:underline hover:underline-offset-4 phone:min-h-11",children:e.title})}),(0,r.jsx)($e,{tone:Te[e.state]??"info",children:ze[e.state]})]}),(0,r.jsx)("p",{className:"truncate font-mono text-[11px] text-muted-foreground",children:Sa(e)})]}),(0,r.jsxs)("p",{className:"flex gap-2 text-[13px]",children:[(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.doing??""}),(0,r.jsx)("span",{className:"shrink-0 text-[12px] tabular-nums text-muted-foreground",children:Me(e.startedAt,e.endedAt===null?t:Date.parse(e.endedAt))})]}),e.earlier&&(0,r.jsx)("p",{className:"text-[11.5px] text-muted-foreground",children:"Earlier lines aren't shown."}),(0,r.jsx)(it,{lines:e.lines,short:!1})]})}function In({thread:e,lead:t,runs:n,now:a,openLead:o,render:s}){let i=[...new Set(n.map(d=>d.project?.split("/").pop()).filter(Boolean))].join(", "),l=n.length===0?"":`Filed by ${As[n[0].filedBy.chat]}${i===""?"":` · ${i}`}`;return(0,r.jsxs)("li",{className:"flex min-w-0 flex-col gap-2",...t!==null?{"data-live-lead":e,"data-live-state":t.state}:{"data-live-filed-group":e},children:[t!==null?(0,r.jsx)(Ps,{lead:t,now:a,openLead:o}):(0,r.jsx)("p",{className:"truncate text-[12px] text-muted-foreground",title:l,children:l}),(0,r.jsx)(Os,{thread:e,runs:n,label:t!==null?`Filed by ${t.title}`:l,render:s})]})}function Ts({thread:e,lead:t,now:n,lost:a,onClose:o,filed:s}){let i=(0,k.useRef)(null),l="shrink-0 text-[12.5px] underline decoration-border underline-offset-4 hover:decoration-current phone:inline-flex phone:min-h-11 phone:items-center";return(0,r.jsx)(Wt,{open:!0,onOpenChange:d=>{d||o()},children:(0,r.jsxs)(Ht,{container:typeof document>"u"?void 0:document.querySelector("[data-view]")??void 0,children:[(0,r.jsx)(qt,{className:"ui-dialog-overlay"}),(0,r.jsxs)(Kt,{"data-live-full":!0,"aria-describedby":void 0,onOpenAutoFocus:d=>{d.preventDefault(),i.current?.focus()},onCloseAutoFocus:d=>{d.preventDefault(),(document.querySelector(`[data-live-open-lead="${e}"]`)??document.querySelector("[data-live-grid]"))?.focus()},className:"ui-dialog-content flex !w-[min(1100px,calc(100vw-48px))] flex-col gap-3 !p-5 phone:!bottom-0 phone:!left-0 phone:!top-auto phone:!max-h-[calc(100dvh-2rem)] phone:!w-full phone:!rounded-b-none phone:!p-4 phone:!pb-[max(1rem,env(safe-area-inset-bottom))] phone:![transform:none]",children:[(0,r.jsxs)("header",{className:"flex items-start gap-3",children:[(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)(zt,{className:"text-[18px] font-semibold leading-[1.3]","data-live-full-title":!0,children:t?.title??"This reply isn't on the grid anymore"}),t!==null&&(0,r.jsx)("p",{className:"truncate font-mono text-[11px] text-muted-foreground",children:Sa(t)})]}),t!==null&&(0,r.jsx)($e,{tone:Te[t.state]??"info",children:ze[t.state]}),(0,r.jsx)(va,{ref:i,className:K("shrink-0",Oe),children:"Close"})]}),t!==null&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("p",{className:"flex items-center gap-3 text-[13px]",children:[(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t.doing??""}),(0,r.jsx)("span",{className:"shrink-0 text-[12px] tabular-nums text-muted-foreground",children:Me(t.startedAt,t.endedAt===null?n:Date.parse(t.endedAt))}),(0,r.jsx)("a",{href:t.chatHref,className:l,children:"Open chat"}),t.taskHref!==null&&(0,r.jsx)("a",{href:t.taskHref,className:l,children:"Open task"})]}),t.earlier&&(0,r.jsx)("p",{className:"text-[11.5px] text-muted-foreground",children:"Earlier lines aren't shown."}),(0,r.jsx)(it,{lines:t.lines,short:!1,tall:!0})]}),a&&(t!==null||s.length>0)&&(0,r.jsx)("p",{className:"text-[11.5px] text-muted-foreground",children:"Reconnecting… these lines may not be the latest."}),s.length>0&&(0,r.jsxs)("section",{"aria-label":"Tasks it filed",className:"flex flex-col gap-2","data-live-full-filed":!0,children:[(0,r.jsxs)("h3",{className:"text-[13px] font-semibold",children:["Tasks it filed ",(0,r.jsx)("span",{className:"font-normal tabular-nums text-muted-foreground",children:s.length})]}),(0,r.jsx)("ul",{className:"flex flex-col gap-1.5",children:s.map(d=>(0,r.jsxs)("li",{className:"flex items-center gap-2 text-[13px]",children:[(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate",title:d.title,children:d.title}),(0,r.jsx)($e,{tone:d.state==="needs-you"?"needs":Te[d.state]??"info",children:ze[d.state]}),d.taskHref!==null&&(0,r.jsx)("a",{href:d.taskHref,className:l,children:"Open task"})]},d.runId))})]})]})]})})}function Ms({working:e,needsYou:t,shownLive:n,local:a}){let o=s=>(0,r.jsx)("span",{className:"font-semibold tabular-nums text-foreground",children:s});return(0,r.jsxs)("p",{className:"text-[13px] text-muted-foreground","data-live-headline":!0,children:[o(e)," ",e===1?"agent":"agents"," working",t>0&&(0,r.jsxs)(r.Fragment,{children:[" · ",o(t)," ",t===1?"needs":"need"," you"]}),a>n&&(0,r.jsxs)(r.Fragment,{children:[" · ",o(n)," of ",o(a)," shown live"]})]})}function Ls(e){return e.waiting>0?{word:"Question",tone:"needs"}:e.ended?{word:"Ended",tone:"neutral"}:e.turn==="admitted"||e.turn==="running"?{word:"Working",tone:"info"}:e.ship!==null&&["approved","imported","armed","completed","merging"].includes(e.ship)?{word:"Shipping",tone:"info"}:e.turn==="unknown"?{word:"Outcome unknown",tone:"neutral"}:e.turn==="interrupted"?{word:"Stopped",tone:"neutral"}:e.ship==="cancelled"?{word:"Ship stopped",tone:"neutral"}:e.ship==="refused"||e.ship==="failed"?{word:"Ship refused",tone:"danger"}:{word:"Ready",tone:"neutral"}}function An(e){return e==="merged"?"Ship: Merged":e==="sent-back"?"Ship: sent back":null}function Fs(e,t){let n=e.filter(s=>s.s===void 0&&s.k!=="you"),a=on(rn("thread"),{records:n,final:!t}),o=e.flatMap((s,i)=>s.k!=="you"||!Array.isArray(s.t)?[]:[{id:i+1,author:"You",mine:!0,text:s.t.join(`
44
- `),standing:"Sent",readAt:null,at:Number.isFinite(Date.parse(s.at??""))?new Date(Date.parse(s.at)-1).toISOString():""}]);return{...a,notes:o}}function _s({thread:e,file:t}){let[n,a]=(0,k.useState)(null);return(0,k.useEffect)(()=>{let o=!0;return fetch(`/agents/live/thread/${e}/diff?file=${t.file}`,{credentials:"same-origin"}).then(s=>s.ok?s.json():null).then(s=>{o&&a(Array.isArray(s?.file?.hunks)?s.file.hunks.flatMap(i=>Array.isArray(i.lines)?i.lines:[]):"error")}).catch(()=>{o&&a("error")}),()=>{o=!1}},[e,t.file]),n===null?(0,r.jsx)("p",{className:"text-caption text-muted-foreground",children:"Reading…"}):n==="error"?(0,r.jsx)("p",{className:"text-caption text-muted-foreground",children:"This file's changes couldn't be read."}):(0,r.jsx)(Da,{excerpt:{path:t.path,cited:!0,more:0,lines:n.map(o=>({kind:o.kind==="meta"?"context":o.kind,line:o.newLine??o.oldLine,text:o.text}))},changesHref:null})}function Us({id:e}){let t=(0,k.useContext)(Ve),[n,a]=(0,k.useState)(null),[o,s]=(0,k.useState)(!1);return(0,r.jsxs)("div",{className:"flex flex-col gap-1","data-live-thread-save":!0,children:[(0,r.jsx)("span",{children:(0,r.jsx)(Ze,{variant:"outline",sm:!0,label:o?"Saving…":"Save as branch",disabled:o,onClick:()=>{o||t===""||(s(!0),fetch(`/agents/live/thread/${e}/save`,{method:"POST",credentials:"same-origin",headers:Be({accept:"application/json"}),body:new URLSearchParams({csrf:t})}).then(async i=>{let l=await i.json().catch(()=>null);a({ok:l?.outcome==="done",words:typeof l?.words=="string"?l.words:"That didn't go through."})}).catch(()=>a({ok:!1,words:"That didn't go through. Check your connection and try again."})).finally(()=>s(!1)))}})}),n!==null&&(0,r.jsx)("p",{className:`text-caption ${n.ok?"text-foreground":"text-destructive"}`,role:"status",children:n.words})]})}function Bs({id:e}){let[t,n]=(0,k.useState)(null),[a,o]=(0,k.useState)(!1),[s,i]=(0,k.useState)(null),[l,d]=(0,k.useState)(null);return(0,k.useEffect)(()=>{let h=!0;return fetch(`/agents/live/thread/${e}?file=main`,{credentials:"same-origin"}).then(c=>c.ok?c.json():null).then(c=>{h&&(o(c?.live===!0),n(c?.window?.ok===!0&&Array.isArray(c.window.records)?c.window.records:[]))}).catch(()=>{h&&n([])}),fetch(`/agents/live/thread/${e}/diff`,{credentials:"same-origin"}).then(c=>c.ok?c.json():null).then(c=>{h&&i({files:Array.isArray(c?.files)?c.files:[],problem:c===null?"The changes couldn't be read.":c.problem??null,patchTruncated:c?.patchTruncated===!0})}).catch(()=>{h&&i({files:[],problem:"The changes couldn't be read.",patchTruncated:!1})}),()=>{h=!1}},[e]),(0,r.jsxs)("div",{className:"flex flex-col gap-3 pb-2 pl-1","data-live-thread-detail":e,children:[t===null?(0,r.jsx)("p",{className:"text-caption text-muted-foreground",children:"Reading…"}):t.length===0?(0,r.jsx)("p",{className:"text-caption text-muted-foreground",children:"Nothing to show here yet."}):(0,r.jsx)(dn,{conversation:Fs(t,a),live:a}),(0,r.jsxs)("section",{"aria-label":"Changes",className:"flex flex-col gap-2","data-live-thread-diff":!0,children:[(0,r.jsx)("h3",{className:"text-label font-semibold text-foreground",children:"Changes since the thread started"}),s===null?(0,r.jsx)("p",{className:"text-caption text-muted-foreground",children:"Reading…"}):s.problem!==null?(0,r.jsx)("p",{className:"text-caption text-muted-foreground",children:s.problem}):(0,r.jsx)("ul",{className:"flex flex-col gap-1",children:s.files.map(h=>(0,r.jsxs)("li",{className:"flex flex-col gap-1",children:[(0,r.jsxs)("span",{className:"flex min-w-0 items-center gap-2 text-body",children:[(0,r.jsx)("span",{className:"min-w-0 truncate font-mono text-foreground",children:h.path}),(0,r.jsx)("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:h.binary?"binary":`+${h.additions} −${h.deletions}`}),(0,r.jsx)("span",{className:"ml-auto shrink-0",children:(0,r.jsx)(Ze,{variant:"ghost",sm:!0,label:l===h.file?"Hide":"Show","aria-expanded":l===h.file,onClick:()=>d(l===h.file?null:h.file)})})]}),l===h.file&&(0,r.jsx)(_s,{thread:e,file:h})]},h.file))}),s?.patchTruncated===!0&&(0,r.jsx)("p",{className:"text-caption text-muted-foreground",children:"Some files are left out: the change is too large to show here."})]}),s!==null&&s.problem===null&&s.files.length>0&&(0,r.jsx)(Us,{id:e})]})}function Ws({refreshKey:e}){let[t,n]=(0,k.useState)([]),[a,o]=(0,k.useState)(null);return(0,k.useEffect)(()=>{let s=!0;return fetch("/agents/live/threads",{credentials:"same-origin"}).then(i=>i.ok?i.json():null).then(i=>{s&&n(Array.isArray(i?.threads)?i.threads:[])}).catch(()=>{}),()=>{s=!1}},[e]),t.length===0?null:(0,r.jsxs)("section",{"aria-label":"Your threads",className:"flex flex-col gap-2 border-t border-border pt-3","data-live-threads":!0,children:[(0,r.jsx)("h2",{className:"text-label font-semibold text-foreground",children:"Your threads"}),(0,r.jsx)("ul",{className:"flex flex-col gap-1",children:t.map(s=>{let{word:i,tone:l}=Ls(s);return(0,r.jsxs)("li",{className:"flex min-w-0 flex-col gap-1","data-live-thread":!0,children:[(0,r.jsxs)("span",{className:"flex min-w-0 items-center gap-2 text-body",children:[(0,r.jsx)("span",{className:"min-w-0 truncate text-foreground",children:s.title}),s.project!==null&&(0,r.jsx)("span",{className:"shrink-0 text-muted-foreground",children:s.project}),An(s.ship)!==null&&(0,r.jsx)("span",{className:"shrink-0 text-muted-foreground",children:An(s.ship)}),(0,r.jsx)("span",{className:"ml-auto shrink-0",children:(0,r.jsx)($e,{tone:l,children:i})}),(0,r.jsx)(Ze,{variant:"ghost",sm:!0,label:a===s.id?"Close":"Open","aria-expanded":a===s.id,"data-live-thread-open":s.id,onClick:()=>o(a===s.id?null:s.id)})]}),a===s.id&&(0,r.jsx)(Bs,{id:s.id})]},s.id)})}),(0,r.jsxs)("p",{className:"text-caption text-muted-foreground",children:["Reply, ship or end a thread in the terminal: run ",(0,r.jsx)("code",{children:"toolroll"}),", then pick it."]})]})}function zu(){let e=(0,k.useContext)(Ve),[t,n]=(0,k.useState)([]),[a,o]=(0,k.useState)([]),[s,i]=(0,k.useState)([]),[l,d]=(0,k.useState)(new Map),[h,c]=(0,k.useState)(()=>new Map),[m,g]=(0,k.useState)("loading"),[p,v]=(0,k.useState)(!1),[f,x]=(0,k.useState)(0),[N,w]=(0,k.useState)(!1),j=(0,k.useRef)(!1),C=(0,k.useRef)(!1),[D,E]=(0,k.useState)(!1),P=tn(1e3),H=(0,k.useRef)(null),Q=()=>{let u=Number(new URLSearchParams(location.search).get("run"));return Number.isSafeInteger(u)&&u>0?u:null},[M,I]=ht(()=>null,Q),Z=(0,k.useRef)(M);Z.current=M;let he=(0,k.useRef)(new Set),S=(0,k.useRef)(null),le=(0,k.useRef)(0);(0,k.useEffect)(()=>{let u=$s(($,A)=>{let[q,V]=$.split(":");d(X=>new Map(X).set(Number(q),ks(X.get(Number(q))??qe,V,A,Number(q)===Z.current?hs:st)))});return H.current=u,()=>{u.dispose(),H.current=null}},[]);let[se,dt]=(0,k.useState)([]),Fe=[...t,...s.filter(u=>!t.some($=>$.runId===u.runId))].filter(u=>u.local),G=new Set([...new Set([...M!==null&&Fe.some(u=>u.runId===M)?[M]:[],...se.filter(u=>Fe.some($=>$.runId===u)),...Fe.map(u=>u.runId)])].slice(0,En)),_e=[...G].sort((u,$)=>u-$).join(",");(0,k.useEffect)(()=>{let u=_e===""?[]:_e.split(",").flatMap($=>[`${$}:main`,`${$}:sub`]);H.current?.keep(new Set(u)),H.current?.want(u)},[_e]),he.current=G,(0,k.useEffect)(()=>{let u=()=>I(Q());return window.addEventListener("popstate",u),()=>window.removeEventListener("popstate",u)},[]);let Ge=u=>{Z.current!==u&&(Z.current=u,history.pushState({liveRun:u},"",`/agents?view=live&run=${u}`),I(u))},ut=()=>{let u=Z.current;u!==null&&(Z.current=null,history.state?.liveRun===u?history.back():history.replaceState(null,"","/agents?view=live"),I(null))},Xe=(0,k.useRef)(M);(0,k.useEffect)(()=>{let u=Xe.current;Xe.current=M,!(u===null||u===M)&&d($=>{let A=$.get(u);if(A===void 0)return $;let q=new Map([...A.children].map(([V,X])=>[V,{...X,lines:X.lines.slice(-st)}]));return new Map($).set(u,{...A,main:{...A.main,lines:A.main.lines.slice(-st)},children:q})})},[M]);let Ne=()=>{if(Q()!==null)return null;let u=Number(new URLSearchParams(location.search).get("lead"));return Number.isSafeInteger(u)&&u>0?u:null},[ie,Se]=ht(()=>null,Ne),b=(0,k.useRef)(ie);b.current=ie,(0,k.useEffect)(()=>{let u=()=>Se(Ne());return window.addEventListener("popstate",u),()=>window.removeEventListener("popstate",u)},[]);let R=u=>{b.current!==u&&(b.current=u,history.pushState({liveLead:u},"",`/agents?view=live&lead=${u}`),Se(u))},T=()=>{let u=b.current;u!==null&&(b.current=null,history.state?.liveLead===u?history.back():history.replaceState(null,"","/agents?view=live"),Se(null))},_=u=>dt($=>[u,...$.filter(A=>A!==u)].slice(0,En)),ge=(0,k.useCallback)(()=>{let u=++le.current;fetch("/agents/live",{credentials:"same-origin"}).then($=>$.ok?$.json():null).then($=>{if(u===le.current){if($===null){g(A=>A==="ready"?"ready":"error");return}n($.tiles),o($.leads??[]),g("ready"),H.current?.want([...he.current].flatMap(A=>[`${A}:main`,`${A}:sub`]))}}).catch(()=>{u===le.current&&g($=>$==="ready"?"ready":"error")})},[]);(0,k.useEffect)(()=>{ge()},[ge]),en("agents-live",u=>{if(u==="lost"||u==="retrying"){v(!0);return}(u==="change"||u==="reload")&&(v(!1),ge())}),(0,k.useEffect)(()=>{fetch("/term/state",{credentials:"same-origin"}).then(u=>u.ok?u.json():null).then(u=>x((u?.sessions??[]).filter($=>$.endedAt===null).length)).catch(()=>{})},[]);let ct=(0,k.useCallback)(u=>i($=>[...$.flatMap(A=>{let q=t.find(V=>V.runId===A.runId);return q!==void 0?[q]:u?[A]:[]}),...t.filter(A=>!$.some(q=>q.runId===A.runId)).sort((A,q)=>Date.parse(A.startedAt)-Date.parse(q.startedAt))]),[t]);(0,k.useEffect)(()=>{ct(j.current||C.current)},[ct]),(0,k.useEffect)(()=>{C.current&&S.current!==null&&!S.current.contains(document.activeElement)&&Ue(null,!1)}),(0,k.useEffect)(()=>{D||d(u=>{let $=!1,A=new Map(u);for(let[q,V]of u){let X=[...V.children.values()].filter(de=>!de.expired&&de.endedAt!==null&&P-de.endedAt>=vs);if(X.length===0)continue;let te=new Map(V.children);for(let de of X)te.set(de.s,{...de,expired:!0});A.set(q,{...V,children:te}),$=!0}return $?A:u})},[P,D,l]);let Ue=(u,$)=>{u!==null&&(j.current=u),$!==null&&(C.current=$);let A=j.current||C.current;E(A),A||ct(!1)},pt=(0,k.useCallback)((u,$)=>{if(u.taskId==="")return;c(X=>{let te=new Map(X);return te.set(u.runId,{...X.get(u.runId),busy:$,message:null}),te});let A=`/t/${encodeURIComponent(u.taskId)}`,q=$==="stop"?`${A}/stop`:`${A}/pause`,V=new URLSearchParams({csrf:e,run:String(u.runId),return:"agents"});$==="pause"?V.set("request",Pt("live")):$==="resume"&&(V.set("request",Pt("live")),V.set("mode","resume")),fetch(q,{method:"POST",credentials:"same-origin",redirect:"manual",headers:Be({accept:"application/json"}),body:V}).then(X=>{let te=X.type==="opaqueredirect"||X.ok;c(de=>{let mt=new Map(de),Qt=de.get(u.runId);return te?mt.set(u.runId,{...Qt,busy:null,...$==="pause"?{paused:!0,message:"Paused."}:$==="resume"?{paused:!1,message:"Resuming…"}:{message:"Stopping…"}}):mt.set(u.runId,{...Qt,busy:null,message:`Couldn't ${$}. Try again.`}),mt}),te&&ge()}).catch(()=>{c(X=>{let te=new Map(X);return te.set(u.runId,{...X.get(u.runId),busy:null,message:`Couldn't ${$}. Check your connection.`}),te})})},[e,ge]),Xt=new Set(s.map(u=>u.runId)),Vt=u=>s.filter($=>$.role==="repair"&&$.parentRun===u),ft=s.filter(u=>!(u.role==="repair"&&u.parentRun!==null&&Xt.has(u.parentRun))),Zt=u=>ft.filter($=>$.filedBy?.thread===u),Jt=(u,$)=>(0,r.jsx)(Tt,{tile:u,stream:l.get(u.runId)??qe,streamed:G.has(u.runId),now:P,repairs:Vt(u.runId),streams:l,streamedIds:G,showLive:_,openRun:Ge,actionStates:h,onAction:pt,nested:{last:$}},u.runId),Ea=s.filter(u=>u.endedAt===null).length+a.filter(u=>u.endedAt===null).length,Ca=s.filter(u=>u.state==="needs-you").length,Ra=t.length!==s.length||t.some(u=>!Xt.has(u.runId));return(0,r.jsxs)("section",{className:"flex w-full flex-col gap-4 outline-none","data-live-grid":!0,"aria-label":"Live",tabIndex:-1,children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1 phone:sticky phone:top-0 phone:z-10 phone:bg-card phone:py-2",children:[(0,r.jsx)(Ms,{working:Ea,needsYou:Ca,shownLive:G.size,local:t.filter(u=>u.local).length}),Ra&&D&&(0,r.jsx)("p",{className:"text-[12px] text-muted-foreground",children:"Changes wait while you look."}),p&&(0,r.jsx)("p",{className:"text-[12px] text-muted-foreground",role:"status",children:"Reconnecting…"}),(0,r.jsx)("div",{className:"ml-auto flex items-center gap-2",children:(0,r.jsx)("button",{type:"button","data-open-shared-browser":"",onClick:()=>w(!0),className:"inline-flex h-7 items-center gap-1.5 rounded-md !border !border-[var(--so-input-line)] !bg-[var(--so-raised)] px-2.5 text-[12px] font-medium text-foreground transition-colors hover:!border-[var(--so-field-line)] hover:!bg-[var(--so-soft)]",children:"Shared browser"})})]}),m==="error"?(0,r.jsx)("p",{className:"text-[13px] text-muted-foreground",role:"status",children:"Couldn't load the agents. Retrying."}):m==="ready"&&ft.length===0&&a.length===0?(0,r.jsx)("p",{className:"text-[13px] text-muted-foreground",children:"No agents running."}):(0,r.jsxs)("ul",{ref:S,className:"grid items-start gap-4 [grid-template-columns:repeat(auto-fill,minmax(min(100%,340px),1fr))]",onPointerEnter:()=>Ue(!0,null),onPointerLeave:()=>Ue(!1,null),onFocus:()=>Ue(null,!0),onBlur:u=>{u.currentTarget.contains(u.relatedTarget)||Ue(null,!1)},children:[a.filter(u=>Zt(u.thread).length===0).map(u=>(0,r.jsx)(In,{thread:u.thread,lead:u,runs:[],now:P,openLead:R,render:Jt},`lead-${u.thread}`)),ft.map(u=>{let $=u.filedBy?.thread;if($===void 0)return(0,r.jsx)(Tt,{tile:u,stream:l.get(u.runId)??qe,streamed:G.has(u.runId),now:P,repairs:Vt(u.runId),streams:l,streamedIds:G,showLive:_,openRun:Ge,actionStates:h,onAction:pt},u.runId);let A=Zt($),q=a.find(V=>V.thread===$);return A[0]!==u?null:(0,r.jsx)(In,{thread:$,lead:q??null,runs:A,now:P,openLead:R,render:Jt},`group-${$}`)})]}),M!==null&&(0,r.jsx)(Is,{runId:M,tile:[...t,...s].find(u=>u.runId===M)??null,stream:l.get(M)??qe,streamed:G.has(M),now:P,lost:p,csrf:e,actionState:h.get(M),onAction:pt,onSent:ge,onClose:ut,showLive:()=>_(M)},M),ie!==null&&(0,r.jsx)(Ts,{thread:ie,lead:a.find(u=>u.thread===ie)??null,now:P,lost:p,onClose:T,filed:s.filter(u=>u.filedBy?.thread===ie)},`lead-${ie}`),(0,r.jsx)(ms,{open:N,onOpenChange:w}),(0,r.jsx)(Ws,{refreshKey:t.length+a.length}),f>0&&(0,r.jsx)("p",{className:"border-t border-border pt-3 text-[12px] text-muted-foreground",children:(0,r.jsxs)("a",{href:"/term",className:"inline-block underline decoration-border underline-offset-4 hover:text-foreground hover:decoration-current phone:min-h-11 phone:py-3",children:[(0,r.jsx)("span",{className:"tabular-nums",children:f})," ",f===1?"terminal":"terminals"," you're driving"]})})]})}export{vs as CHILD_DONE_MS,qe as EMPTY,hs as FULL_LINES,st as KEEP_LINES,zu as LiveGrid,bs as MAX_BACKOFF_MS,gs as MAX_READS,xs as READ_DEADLINE_MS,En as STREAMED,ks as applyWindow,$s as createScheduler,An as shipOutcome,Fs as threadConversation,Ls as threadWord};
42
+ `)},Yr=0,Re=[];function Gr(e){var t=U.useRef([]),n=U.useRef([0,0]),a=U.useRef(),o=U.useState(Yr++)[0],s=U.useState(ia)[0],i=U.useRef(e);U.useEffect(function(){i.current=e},[e]),U.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var f=pr([e.lockRef.current],(e.shards||[]).map(Nn),!0).filter(Boolean);return f.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),f.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var l=U.useCallback(function(f,g){if("touches"in f&&f.touches.length===2||f.type==="wheel"&&f.ctrlKey)return!i.current.allowPinchZoom;var N=Qe(f),w=n.current,j="deltaX"in f?f.deltaX:w[0]-N[0],C="deltaY"in f?f.deltaY:w[1]-N[1],D,E=f.target,P=Math.abs(j)>Math.abs(C)?"h":"v";if("touches"in f&&P==="h"&&E.type==="range")return!1;var H=window.getSelection(),Q=H&&H.anchorNode,M=Q?Q===E||Q.contains(E):!1;if(M)return!1;var I=kn(P,E);if(!I)return!0;if(I?D=P:(D=P==="v"?"h":"v",I=kn(P,E)),!I)return!1;if(!a.current&&"changedTouches"in f&&(j||C)&&(a.current=D),!D)return!0;var Z=a.current||D;return qr(Z,g,f,Z==="h"?j:C,!0)},[]),d=U.useCallback(function(f){var g=f;if(!(!Re.length||Re[Re.length-1]!==s)){var N="deltaY"in g?$n(g):Qe(g),w=t.current.filter(function(D){return D.name===g.type&&(D.target===g.target||g.target===D.shadowParent)&&Kr(D.delta,N)})[0];if(w&&w.should){g.cancelable&&g.preventDefault();return}if(!w){var j=(i.current.shards||[]).map(Nn).filter(Boolean).filter(function(D){return D.contains(g.target)}),C=j.length>0?l(g,j[0]):!i.current.noIsolation;C&&g.cancelable&&g.preventDefault()}}},[]),h=U.useCallback(function(f,g,N,w){var j={name:f,delta:g,target:N,should:w,shadowParent:Xr(N)};t.current.push(j),setTimeout(function(){t.current=t.current.filter(function(C){return C!==j})},1)},[]),c=U.useCallback(function(f){n.current=Qe(f),a.current=void 0},[]),m=U.useCallback(function(f){h(f.type,$n(f),f.target,l(f,e.lockRef.current))},[]),x=U.useCallback(function(f){h(f.type,Qe(f),f.target,l(f,e.lockRef.current))},[]);U.useEffect(function(){return Re.push(s),e.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:x}),document.addEventListener("wheel",d,Ce),document.addEventListener("touchmove",d,Ce),document.addEventListener("touchstart",c,Ce),function(){Re=Re.filter(function(f){return f!==s}),document.removeEventListener("wheel",d,Ce),document.removeEventListener("touchmove",d,Ce),document.removeEventListener("touchstart",c,Ce)}},[]);var p=e.removeScrollBar,v=e.inert;return U.createElement(U.Fragment,null,v?U.createElement(s,{styles:zr(o)}):null,p?U.createElement(Lr,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Xr(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var Vr=kr(la,Gr),pa=vn.forwardRef(function(e,t){return vn.createElement(lt,oe({},e,{ref:t,sideCar:Vr}))});pa.classNames=lt.classNames;var Zr=pa,Jr=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},De=new WeakMap,et=new WeakMap,tt={},jt=0,fa=function(e){return e&&(e.host||fa(e.parentNode))},Qr=function(e,t){return t.map(function(n){if(e.contains(n))return n;var a=fa(n);return a&&e.contains(a)?a:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},es=function(e,t,n,a){var o=Qr(t,Array.isArray(e)?e:[e]);tt[n]||(tt[n]=new WeakMap);var s=tt[n],i=[],l=new Set,d=new Set(o),h=function(m){!m||l.has(m)||(l.add(m),h(m.parentNode))};o.forEach(h);var c=function(m){!m||d.has(m)||Array.prototype.forEach.call(m.children,function(x){if(l.has(x))c(x);else try{var p=x.getAttribute(a),v=p!==null&&p!=="false",f=(De.get(x)||0)+1,g=(s.get(x)||0)+1;De.set(x,f),s.set(x,g),i.push(x),f===1&&v&&et.set(x,!0),g===1&&x.setAttribute(n,"true"),v||x.setAttribute(a,"true")}catch(N){console.error("aria-hidden: cannot operate on ",x,N)}})};return c(t),l.clear(),jt++,function(){i.forEach(function(m){var x=De.get(m)-1,p=s.get(m)-1;De.set(m,x),s.set(m,p),x||(et.has(m)||m.removeAttribute(a),et.delete(m)),p||m.removeAttribute(n)}),jt--,jt||(De=new WeakMap,De=new WeakMap,et=new WeakMap,tt={})}},ts=function(e,t,n){n===void 0&&(n="data-aria-hidden");var a=Array.from(Array.isArray(e)?e:[e]),o=t||Jr(e);return o?(a.push.apply(a,Array.from(o.querySelectorAll("[aria-live], script"))),es(a,o,n,"aria-hidden")):function(){return null}},W=O(ge(),1),ns=Object.defineProperty,re=(e,t)=>ns(e,"name",{value:t,configurable:!0}),Bt="Dialog",[ma,Gu]=Ln(Bt),[as,me]=ma(Bt),Wt=re(e=>{let{__scopeDialog:t,children:n,open:a,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,l=Y.useRef(null),d=Y.useRef(null),[h,c]=Wn({prop:a,defaultProp:o??!1,onChange:s,caller:Bt}),[m,x]=Y.useState(0),[p,v]=Y.useState(0);return(0,W.jsx)(as,{scope:t,triggerRef:l,contentRef:d,contentId:nt(),titleId:nt(),descriptionId:nt(),titlePresent:m>0,descriptionPresent:p>0,setTitleCount:x,setDescriptionCount:v,open:h,onOpenChange:c,onOpenToggle:Y.useCallback(()=>c(f=>!f),[c]),modal:i,children:n})},"Dialog"),ha="DialogPortal",[rs,xa]=ma(ha,{forceMount:void 0}),Ht=re(e=>{let{__scopeDialog:t,forceMount:n,children:a,container:o}=e,s=me(ha,t);return(0,W.jsx)(rs,{scope:t,forceMount:n,children:Y.Children.map(a,i=>(0,W.jsx)(Ft,{present:n||s.open,children:(0,W.jsx)(or,{asChild:!0,container:o,children:i})}))})},"DialogPortal"),Ot="DialogOverlay",qt=Y.forwardRef(re(function(e,t){let n=xa(Ot,e.__scopeDialog),{forceMount:a=n.forceMount,...o}=e,s=me(Ot,e.__scopeDialog);return s.modal?(0,W.jsx)(Ft,{present:a||s.open,children:(0,W.jsx)(os,{...o,ref:t})}):null},"DialogOverlay")),ss=nn("DialogOverlay.RemoveScroll"),os=Y.forwardRef(re(function(e,t){let{__scopeDialog:n,...a}=e,o=me(Ot,n),s=zn(),i=We(t,s);return(0,W.jsx)(Zr,{as:ss,allowPinchZoom:!0,shards:[o.contentRef],children:(0,W.jsx)(we.div,{"data-state":Yt(o.open),...a,ref:i,style:{pointerEvents:"auto",...a.style}})})},"DialogOverlayImpl")),Ke="DialogContent",Kt=Y.forwardRef(re(function(e,t){let n=xa(Ke,e.__scopeDialog),{forceMount:a=n.forceMount,...o}=e,s=me(Ke,e.__scopeDialog);return(0,W.jsx)(Ft,{present:a||s.open,children:s.modal?(0,W.jsx)(ls,{...o,ref:t}):(0,W.jsx)(is,{...o,ref:t})})},"DialogContent")),ls=Y.forwardRef(re(function(e,t){let n=me(Ke,e.__scopeDialog),a=Y.useRef(null),o=We(t,n.contentRef,a);return Y.useEffect(()=>{let s=a.current;if(s)return ts(s)},[]),(0,W.jsx)(ga,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:be(e.onCloseAutoFocus,s=>{s.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:be(e.onPointerDownOutside,s=>{let i=s.detail.originalEvent,l=i.button===0&&i.ctrlKey===!0;(i.button===2||l)&&s.preventDefault()}),onFocusOutside:be(e.onFocusOutside,s=>s.preventDefault())})},"DialogContentModal")),is=Y.forwardRef(re(function(e,t){let n=me(Ke,e.__scopeDialog),a=Y.useRef(!1),o=Y.useRef(!1);return(0,W.jsx)(ga,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{e.onCloseAutoFocus?.(s),s.defaultPrevented||(a.current||n.triggerRef.current?.focus(),s.preventDefault()),a.current=!1,o.current=!1},onInteractOutside:s=>{e.onInteractOutside?.(s),s.defaultPrevented||(a.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));let i=s.target;n.triggerRef.current?.contains(i)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})},"DialogContentNonModal")),ga=Y.forwardRef(re(function(e,t){let{__scopeDialog:n,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,l=me(Ke,n);return Ut(),(0,W.jsx)(W.Fragment,{children:(0,W.jsx)(tr,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:o,onUnmountAutoFocus:s,children:(0,W.jsx)(Za,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionPresent?l.descriptionId:void 0,"aria-labelledby":l.titlePresent?l.titleId:void 0,"data-state":Yt(l.open),...i,ref:t,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1)})})})},"DialogContentImpl")),ds="DialogTitle",zt=Y.forwardRef(re(function(e,t){let{__scopeDialog:n,...a}=e,o=me(ds,n),{setTitleCount:s}=o;return ke(()=>(s(i=>i+1),()=>s(i=>i-1)),[s]),(0,W.jsx)(we.h2,{id:o.titleId,...a,ref:t})},"DialogTitle")),us="DialogClose",va=Y.forwardRef(re(function(e,t){let{__scopeDialog:n,...a}=e,o=me(us,n);return(0,W.jsx)(we.button,{type:"button",...a,ref:t,onClick:be(e.onClick,()=>o.onOpenChange(!1))})},"DialogClose"));function Yt(e){return e?"open":"closed"}re(Yt,"getState");var k=O(L(),1),B=O(L(),1),y=O(ge(),1),ne="inline-flex h-8 items-center justify-center gap-1.5 rounded-md !border !border-[var(--so-input-line)] !bg-[var(--so-raised)] px-3 text-[12px] font-medium text-foreground transition-colors hover:!border-[var(--so-field-line)] hover:!bg-[var(--so-soft)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--so-signal)] disabled:opacity-50",kt="inline-flex h-8 items-center justify-center gap-1.5 rounded-md !border !border-[var(--so-signal)] !bg-[var(--so-signal)] px-3 text-[12px] font-medium !text-[var(--so-on-signal)] transition-opacity hover:opacity-90 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--so-signal)] disabled:opacity-50",cs="inline-flex h-8 items-center justify-center gap-1.5 rounded-md !border !border-[var(--so-danger)]/40 !bg-[var(--so-danger-soft)] px-3 text-[12px] font-medium !text-[var(--so-danger)] transition-colors hover:!border-[var(--so-danger)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--so-danger)] disabled:opacity-50",Sn="h-8 min-w-0 flex-1 rounded-md !border !border-[var(--so-input-line)] !bg-[var(--so-paper)] px-2.5 text-[12.5px] text-foreground placeholder:text-muted-foreground focus:outline-none focus:!border-[var(--so-signal)]",ps=2500;function fs({onClose:e,initialState:t}){let n=(0,B.useContext)(Ve),[a,o]=(0,B.useState)(t??null),[s,i]=(0,B.useState)(t===void 0),[l,d]=(0,B.useState)(null),[h,c]=(0,B.useState)(t?.activeSession?.profile??"default"),[m,x]=(0,B.useState)(t?.activeSession?.url??""),[p,v]=(0,B.useState)(""),[f,g]=(0,B.useState)(!1),[N,w]=(0,B.useState)(1),[j,C]=(0,B.useState)(null),[D,E]=(0,B.useState)(null),[P,H]=(0,B.useState)(!1),[Q,M]=(0,B.useState)(!1),[I,Z]=(0,B.useState)(null),he=(0,B.useRef)(null),S=a?.activeSession??null,le=(0,B.useCallback)(async(b,R)=>{let T=await fetch(b,{method:"POST",credentials:"same-origin",headers:Be({"content-type":"application/json",accept:"application/json",...n?{"x-csrf-token":n}:{}}),body:JSON.stringify({...R,...n?{csrf:n}:{}})}),_=await T.json().catch(()=>({}));return{ok:T.ok,status:T.status,data:_}},[n]),se=(0,B.useCallback)(async(b=!1)=>{b||i(!0);try{let R=await fetch("/api/browser/state",{method:"GET",credentials:"same-origin",cache:"no-store",headers:{accept:"application/json"}});if(!R.ok){b||E("Could not read shared browser state.");return}let T=await R.json();o(T),T.activeSession&&(c(T.activeSession.profile),x(_=>_===""?T.activeSession.url:_),w(_=>_+1)),b||E(null)}catch{b||E("Could not reach shared browser.")}finally{b||i(!1)}},[]);(0,B.useEffect)(()=>{t===void 0&&se(!1)},[t,se]),(0,B.useEffect)(()=>{if(!S)return;let b=window.setInterval(()=>{se(!0)},ps);return()=>window.clearInterval(b)},[S,se]);let dt=async b=>{b.preventDefault();let R=m.trim();if(R){d("open"),E(null),C(null);try{let T=await le("/api/browser/open",{profile:h,url:R,takeover:!0});if(!T.ok||!T.data.session){E(T.data.error??"Could not open URL.");return}x(T.data.session.url),C("Opened page in shared browser."),await se(!0)}catch{E("Could not open URL.")}finally{d(null)}}},Fe=async()=>{if(!S)return;let b=!S.takeover;d("takeover"),E(null),C(null);try{let R=await le("/api/browser/takeover",{session:S.id,active:b,...b?{reason:"Human took over from Web"}:{}});if(!R.ok||!R.data.session){E(R.data.error??"Could not update takeover state.");return}C(b?"You have control. Agents are paused on this browser.":"Handed back to agent."),b||H(!1),await se(!0)}catch{E("Could not update takeover state.")}finally{d(null)}},G=async(b,R)=>{if(S){if(!S.takeover){E("Take over the browser first before interacting.");return}d(R??"input"),E(null);try{let T=await le("/api/browser/takeover",{session:S.id,...b});if(!T.ok){E(T.data.error??"Input failed.");return}T.data.session&&x(T.data.session.url),w(_=>_+1),await se(!0)}catch{E("Input failed.")}finally{d(null)}}},_e=b=>{if(!S||!S.takeover)return;let R=b.currentTarget.getBoundingClientRect();if(R.width<=0||R.height<=0)return;let T=Math.min(1,Math.max(0,(b.clientX-R.left)/R.width)),_=Math.min(1,Math.max(0,(b.clientY-R.top)/R.height));G({kind:"click",x:T,y:_},"click")},Ge=b=>{if(!S||!S.takeover)return;let R=b.currentTarget.getBoundingClientRect(),T=R.width>0?Math.min(1,Math.max(0,(b.clientX-R.left)/R.width)):.5,_=R.height>0?Math.min(1,Math.max(0,(b.clientY-R.top)/R.height)):.5;G({kind:"scroll",x:T,y:_,deltaY:Math.round(b.deltaY)},"scroll")},ut=async b=>{if(b.preventDefault(),!p)return;let R=p;v(""),await G({kind:"type",text:R,secure:f},"type")},Xe=async()=>{if(S){if(P){H(!1);return}H(!0),M(!0),E(null);try{let b=await fetch(`/api/browser/credentials?session=${encodeURIComponent(S.id)}`,{method:"GET",credentials:"same-origin",cache:"no-store",headers:{accept:"application/json"}});if(!b.ok){E("Could not read matching 1Password items.");return}let R=await b.json();Z(R)}catch{E("Could not read matching 1Password items.")}finally{M(!1)}}},Ne=async(b,R,T)=>{if(S){d(`fill:${b}:${T}`),E(null),C(null);try{let _=await le("/api/browser/fill",{session:S.id,itemId:b,field:T});if(!_.ok||!_.data.ok){E(_.data.error??"1Password fill refused.");return}C(`Filled ${T} from “${R}” directly in host browser (zero secret bytes exposed).`),H(!1),w(xe=>xe+1)}catch{E("1Password fill failed.")}finally{d(null)}}},ie=async()=>{if(S){d("close"),E(null),C(null);try{let b=await le("/api/browser/close",{session:S.id});if(!b.ok){E(b.data.error??"Could not close session.");return}H(!1),C("Closed shared browser session."),await se(!0)}catch{E("Could not close session.")}finally{d(null)}}},Se=S!==null?`/api/browser/frame?session=${encodeURIComponent(S.id)}&t=${N}`:null;return(0,y.jsxs)("div",{className:"flex h-full flex-col gap-3 text-foreground","data-shared-browser-panel":"",children:[(0,y.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 border-b border-[var(--so-line)] pb-3",children:[(0,y.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,y.jsx)("h2",{className:"text-[15px] font-semibold tracking-tight text-foreground",children:"Shared Browser"}),S?(0,y.jsxs)("span",{"data-shared-browser-owner":S.takeover?"human":"agent",className:K("inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-[11px] font-medium",S.takeover?"bg-[var(--so-signal-soft)] text-[var(--so-signal)]":"bg-[var(--so-raised)] text-muted-foreground"),children:[(0,y.jsx)("span",{className:K("h-1.5 w-1.5 rounded-full",S.takeover?"bg-[var(--so-signal)]":"bg-[var(--so-done)]")}),S.takeover?"Human control":"Agent control"]}):(0,y.jsx)("span",{className:"inline-flex items-center rounded-full bg-[var(--so-raised)] px-2.5 py-0.5 text-[11px] font-medium text-muted-foreground",children:"Idle"})]}),(0,y.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[S&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("button",{type:"button","data-shared-browser-takeover":"",disabled:l!==null,onClick:()=>{Fe()},className:S.takeover?kt:ne,children:S.takeover?"Hand back to agent":"Take over"}),(0,y.jsxs)("div",{className:"relative",children:[(0,y.jsx)("button",{type:"button","data-shared-browser-1p-trigger":"",disabled:l!==null||!S.takeover,title:S.takeover?"List domain-matched 1Password logins (zero-leak host fill)":"Take over the browser first to use 1Password fill",onClick:()=>{Xe()},className:ne,children:"1Password fill"}),P&&(0,y.jsxs)("div",{role:"dialog","aria-label":"1Password fill","data-shared-browser-1p-popover":"",className:"absolute right-0 top-10 z-30 w-80 rounded-lg !border !border-[var(--so-line)] !bg-[var(--so-paper)] p-3 shadow-xl",children:[(0,y.jsxs)("div",{className:"mb-2 flex items-center justify-between gap-2",children:[(0,y.jsx)("span",{className:"text-[12px] font-semibold text-foreground",children:"1Password · Zero-leak fill"}),(0,y.jsx)("button",{type:"button",onClick:()=>H(!1),className:"rounded px-1.5 py-0.5 text-[11px] text-muted-foreground hover:text-foreground",children:"Close"})]}),Q?(0,y.jsx)("p",{className:"text-[12px] text-muted-foreground",children:"Checking domain-matched items…"}):!I||!I.available?(0,y.jsxs)("p",{className:"text-[12px] text-muted-foreground",children:["1Password CLI (",(0,y.jsx)("code",{children:"op"}),") is not available on this host."]}):I.items.length===0?(0,y.jsxs)("p",{className:"text-[12px] text-muted-foreground",children:["No 1Password logins match ",(0,y.jsx)("code",{className:"text-foreground",children:I.origin||"this page"}),"."]}):(0,y.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,y.jsxs)("p",{className:"text-[11px] text-muted-foreground",children:["Matched origin: ",(0,y.jsx)("code",{className:"text-foreground",children:I.origin}),". Focus the page field first, then click fill."]}),(0,y.jsx)("ul",{className:"flex max-h-60 flex-col gap-2 overflow-y-auto","data-shared-browser-1p-list":"",children:I.items.map(b=>(0,y.jsxs)("li",{"data-1p-item-id":b.id,className:"rounded-md !border !border-[var(--so-line)] !bg-[var(--so-raised)] p-2",children:[(0,y.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,y.jsx)("span",{className:"truncate text-[12.5px] font-medium text-foreground",children:b.title}),(0,y.jsx)("span",{className:"shrink-0 text-[10.5px] text-muted-foreground",children:b.vault})]}),(0,y.jsxs)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[(0,y.jsx)("button",{type:"button","data-1p-fill":`${b.id}:username`,disabled:l!==null,onClick:()=>{Ne(b.id,b.title,"username")},className:ne,children:"Username"}),(0,y.jsx)("button",{type:"button","data-1p-fill":`${b.id}:password`,disabled:l!==null,onClick:()=>{Ne(b.id,b.title,"password")},className:kt,children:"Password"}),b.hasOtp&&(0,y.jsx)("button",{type:"button","data-1p-fill":`${b.id}:otp`,disabled:l!==null,onClick:()=>{Ne(b.id,b.title,"otp")},className:ne,children:"OTP"})]})]},b.id))})]})]})]}),(0,y.jsx)("button",{type:"button","data-shared-browser-close-session":"",disabled:l!==null,onClick:()=>{ie()},className:cs,children:"End session"})]}),e&&(0,y.jsx)("button",{type:"button",onClick:e,className:ne,"data-shared-browser-dismiss":"",children:"Close"})]})]}),(0,y.jsxs)("form",{onSubmit:b=>{dt(b)},className:"flex flex-wrap items-center gap-2","data-shared-browser-nav":"",children:[(0,y.jsx)("select",{"aria-label":"Browser profile",value:h,onChange:b=>c(b.target.value),disabled:l!==null,className:"h-8 rounded-md !border !border-[var(--so-input-line)] !bg-[var(--so-raised)] px-2 text-[12px] text-foreground",children:(a?.profiles??[{id:"default",label:"Default"},{id:"work",label:"Work"},{id:"personal",label:"Personal"}]).map(b=>(0,y.jsx)("option",{value:b.id,children:b.label},b.id))}),S&&(0,y.jsxs)("div",{className:"flex items-center gap-1",children:[(0,y.jsx)("button",{type:"button",disabled:l!==null||!S.takeover,onClick:()=>{G({kind:"back"},"back")},className:ne,"aria-label":"Back",children:"←"}),(0,y.jsx)("button",{type:"button",disabled:l!==null||!S.takeover,onClick:()=>{G({kind:"forward"},"forward")},className:ne,"aria-label":"Forward",children:"→"}),(0,y.jsx)("button",{type:"button",disabled:l!==null||!S.takeover,onClick:()=>{G({kind:"reload"},"reload")},className:ne,"aria-label":"Reload",children:"↻"})]}),(0,y.jsx)("input",{type:"text","aria-label":"URL","data-shared-browser-url":"",placeholder:"https://example.com",value:m,onChange:b=>x(b.target.value),disabled:l!==null,className:Sn}),(0,y.jsx)("button",{type:"submit","data-shared-browser-go":"",disabled:l!==null||m.trim()==="",className:kt,children:S?"Go":"Open"})]}),S?.takeoverReason&&S.takeover&&(0,y.jsxs)("div",{className:"rounded-md !border !border-[var(--so-signal)]/30 !bg-[var(--so-signal-soft)] px-3 py-2 text-[12px] text-foreground",role:"status",children:["Takeover active: ",S.takeoverReason]}),j&&(0,y.jsx)("div",{className:"rounded-md !border !border-[var(--so-line)] !bg-[var(--so-raised)] px-3 py-1.5 text-[12px] text-foreground",role:"status",children:j}),D&&(0,y.jsx)("div",{className:"rounded-md !border !border-[var(--so-danger)]/40 !bg-[var(--so-danger-soft)] px-3 py-1.5 text-[12px] text-[var(--so-danger)]",role:"alert",children:D}),(0,y.jsx)("div",{ref:he,"data-shared-browser-viewport":"",onClick:_e,onWheel:Ge,className:K("relative flex min-h-[320px] flex-1 items-center justify-center overflow-hidden rounded-lg !border !border-[var(--so-line)] !bg-[#0b0b0c]",S?.takeover?"cursor-crosshair":"cursor-default"),children:s?(0,y.jsx)("p",{className:"text-[13px] text-muted-foreground",children:"Loading shared browser…"}):S&&Se?(0,y.jsx)("img",{src:Se,alt:S.title||S.url,"data-shared-browser-frame":"",draggable:!1,className:"h-full w-full select-none object-contain"}):(0,y.jsxs)("div",{className:"flex max-w-sm flex-col items-center gap-2 px-6 text-center",children:[(0,y.jsx)("p",{className:"text-[13.5px] font-medium text-foreground",children:"No active browser session"}),(0,y.jsx)("p",{className:"text-[12px] text-muted-foreground",children:"Enter a URL above to launch an isolated Chrome profile, or wait for an agent to open one."})]})}),S?.takeover&&(0,y.jsxs)("form",{onSubmit:b=>{ut(b)},className:"flex flex-wrap items-center gap-2 border-t border-[var(--so-line)] pt-2",children:[(0,y.jsx)("input",{type:f?"password":"text","aria-label":"Type into focused field","data-shared-browser-type-input":"",placeholder:f?"Type securely (masked from agents)…":"Type into focused browser field…",value:p,onChange:b=>v(b.target.value),disabled:l!==null,className:Sn}),(0,y.jsxs)("label",{className:"inline-flex items-center gap-1.5 text-[11.5px] text-muted-foreground",children:[(0,y.jsx)("input",{type:"checkbox",checked:f,onChange:b=>g(b.target.checked)}),"Mask from agent"]}),(0,y.jsx)("button",{type:"submit",disabled:l!==null||p==="",className:ne,children:"Send text"}),(0,y.jsx)("button",{type:"button",disabled:l!==null,onClick:()=>{G({kind:"key",key:"Enter"},"key")},className:ne,children:"Enter"}),(0,y.jsx)("button",{type:"button",disabled:l!==null,onClick:()=>{G({kind:"key",key:"Tab"},"key")},className:ne,children:"Tab"})]})]})}function ms({open:e,onOpenChange:t}){return e?(0,y.jsx)(Wt,{open:e,onOpenChange:t,children:(0,y.jsxs)(Ht,{container:typeof document>"u"?void 0:document.querySelector("[data-view]")??void 0,children:[(0,y.jsx)(qt,{className:"ui-dialog-overlay"}),(0,y.jsxs)(Kt,{"data-shared-browser-drawer":"","aria-describedby":void 0,className:"fixed inset-y-0 right-0 z-50 flex w-full max-w-4xl flex-col !border-l !border-[var(--so-line)] !bg-[var(--so-paper)] p-5 shadow-2xl focus:outline-none",children:[(0,y.jsx)(zt,{className:"sr-only",children:"Shared Browser"}),(0,y.jsx)(fs,{onClose:()=>t(!1)})]})]})}):null}var r=O(ge(),1),hs=2e3,st=200,En=24,xs=4,gs=1e4,vs=3e4,bs=3e4,ws=5e3,ze={working:"Working","needs-you":"Needs you",done:"Done",failed:"Failed",stopped:"Stopped",parked:"Parked"},Cn={edit:"Editing",command:"Running",read:"Reading",search:"Searching for",lookup:"Looking up",plan:"Planning",delegate:"Handing off",tool:"Using a tool",session:"Starting",message:""},ys={command:"Running a command",edit:"Editing files",read:"Reading the code",search:"Searching the code",lookup:"Looking something up"},js=e=>e.target?`${Cn[e.kind??"tool"]??"Working"} ${e.target}`:ys[e.kind??""]??Cn[e.kind??"tool"]??"Working",ba=()=>({lines:[],open:[],editedFiles:[]});function Rn(e,t,n){let a=[...e.lines],o=e.open,s=e.editedFiles;if(t.k==="say")a.push(...t.t??[]);else if(t.k==="step"){let i=js(t);a.push(`→ ${i}`),t.once!==!0&&t.id!==void 0&&(o=[...o.filter(([l])=>l!==t.id),[t.id,i]]),t.kind==="edit"&&t.target&&!s.includes(t.target)&&(s=[...s,t.target])}else t.k==="done"?(o=o.filter(([i])=>i!==t.id),a.push(...(t.out??[]).map(i=>` ${i}`)),t.ok===!1&&a.push("✗ failed")):t.k==="start"?a.push("The agent session started."):t.k==="cut"?a.push("A line was too long to show."):t.k==="cap"&&a.push("Output stopped at its size limit.");return{lines:a.slice(-n),open:o,editedFiles:s}}var wa=e=>e.open.at(-1)?.[1]??null,qe={main:ba(),children:new Map,mainState:"loading",subState:"loading",earlier:!1,restarted:!1,subRestarted:!1,over:!1},Dn=e=>e!==void 0&&Number.isFinite(Date.parse(e))?Date.parse(e):Date.now();function ks(e,t,n,a=st){if(n.error!==void 0){if(n.error==="missing")return t==="main"?{...e,mainState:"ready"}:{...e,subState:"ready"};let d=n.error==="off"?"off":n.error==="gone"||n.error==="unavailable"?"unavailable":"error";return t==="main"?{...e,mainState:d}:{...e,subState:d}}let o=n.restarted===!0,s=t==="main"&&o?{lines:["Output restarted."],open:[],editedFiles:[]}:e.main,i=t==="sub"&&o?new Map:new Map(e.children),l=e.over&&!(t==="sub"&&o);for(let d of n.records??[]){if(t==="main"){d.s===void 0&&(s=Rn(s,d,a));continue}if(d.k==="over"){l=!0;continue}if(d.s===void 0)continue;if(d.k==="child"){i.set(d.s,{...ba(),s:d.s,...d.via===void 0?{}:{via:d.via},desc:d.desc??"Subagent",startedAt:Dn(d.at),endedAt:null,ok:null,expired:!1});continue}let h=i.get(d.s);h!==void 0&&(d.k==="end"?i.set(d.s,{...h,open:[],endedAt:d.at===void 0?0:Math.max(Dn(d.at),h.startedAt),ok:d.ok??null}):i.set(d.s,{...h,...Rn(h,d,a)}))}return{...e,main:s,children:i,over:l,earlier:e.earlier||n.earlier===!0,restarted:e.restarted||o,subRestarted:t==="sub"?e.subRestarted||o:e.subRestarted,...t==="main"?{mainState:"ready"}:{subState:"ready"}}}function $s(e,t=(...n)=>fetch(...n)){let n=new Map,a=new Set,o=new Map,s=new Map,i=new Map,l=!1,d=null,h=()=>{if(l||d!==null||a.size===0)return;let p=Math.min(...[...a].map(v=>s.get(v)??Date.now()));d=setTimeout(()=>{d=null,x()},Math.max(50,p-Date.now()))},c=(p,v)=>{let f=Math.min(bs,(i.get(p)??500)*2);i.set(p,f),s.set(p,Date.now()+Math.max(f,v??0)),a.add(p),e(p,{error:"retry"})},m=p=>{if(p===null)return;let v=Number(p);if(Number.isFinite(v)&&v>0)return v*1e3;let f=Date.parse(p);return Number.isFinite(f)?Math.max(0,f-Date.now()):void 0},x=()=>{if(!l){for(let p of[...a]){if(o.size>=xs)break;if(o.has(p)||(s.get(p)??0)>Date.now())continue;a.delete(p);let v=new AbortController;o.set(p,v);let[f,g]=p.split(":"),N=n.get(p),w=setTimeout(()=>v.abort(),gs);t(`/agents/live/${f}?file=${g}${N===void 0?"":`&cursor=${encodeURIComponent(N)}`}`,{signal:v.signal,credentials:"same-origin"}).then(async j=>{if(l)return;if(j.status===404){e(p,{error:"gone"});return}if(!j.ok){c(p,m(j.headers.get("retry-after")));return}let C=await j.json();l||(C.cursor!==void 0&&n.set(p,C.cursor),i.delete(p),s.delete(p),C.more===!0&&a.add(p),e(p,C))}).catch(()=>{l||c(p)}).finally(()=>{clearTimeout(w),o.delete(p),l||x()})}h()}};return{want(p){if(!l){for(let v of p)a.add(v);x()}},keep(p){for(let v of[...a,...o.keys(),...n.keys(),...s.keys()])p.has(v)||(o.get(v)?.abort(),o.delete(v),a.delete(v),n.delete(v),s.delete(v),i.delete(v))},dispose(){l=!0,d!==null&&clearTimeout(d);for(let p of o.values())p.abort();o.clear(),a.clear()}}}var Te={working:"info",done:"success",failed:"danger",stopped:"neutral",parked:"neutral"},Ns="border-wait";function $e({tone:e,children:t}){return(0,r.jsx)(an,{size:"chip",dot:!0,tone:e,"data-live-chip":!0,children:t})}function it({lines:e,short:t,tall:n=!1}){let a=(0,k.useRef)(null),[o,s]=(0,k.useState)(!0),[i,l]=(0,k.useState)(!1);return(0,k.useLayoutEffect)(()=>{let d=a.current;d!==null&&(o&&(d.scrollTop=d.scrollHeight),l(d.scrollTop>1))}),e.length===0?(0,r.jsx)("p",{className:"text-[12px] text-muted-foreground",children:"No output yet."}):(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("div",{ref:a,tabIndex:0,role:"log","aria-label":"Output",onScroll:d=>{let h=d.currentTarget;s(h.scrollHeight-h.scrollTop-h.clientHeight<4),l(h.scrollTop>1)},className:K("overflow-y-auto overscroll-contain rounded-md border border-border bg-code-bg px-2.5 py-2",n?"max-h-[60vh]":t?"max-h-[calc(4*1.5*12px+1rem)]":"max-h-[calc(12*1.5*12px+1rem)] phone:max-h-[calc(4*1.5*12px+1rem)]"),children:(0,r.jsx)("pre",{className:"whitespace-pre-wrap break-words font-mono text-[12px] leading-[1.5] text-foreground","data-live-lines":!0,children:e.join(`
43
+ `)})}),i&&(0,r.jsx)("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-px top-px h-6 rounded-t-md bg-[linear-gradient(to_bottom,var(--so-code-bg)_30%,transparent)]"}),!o&&(0,r.jsx)("button",{type:"button",onClick:()=>s(!0),className:"absolute bottom-2 right-2 rounded-sm border border-border bg-card px-2 py-0.5 text-[11.5px] text-foreground shadow-pill phone:min-h-11",children:"Jump to latest"})]})}var ya=e=>K("relative pl-5",!e&&"pb-2","before:absolute before:left-0 before:top-0 before:h-[22px] before:w-3.5 before:rounded-bl-sm before:border-b before:border-l before:border-border before:content-['']",!e&&"after:absolute after:bottom-0 after:left-0 after:top-[22px] after:border-l after:border-border after:content-['']");function Gt({child:e,all:t,now:n,last:a}){let o=e.endedAt===null?"Working":e.ok===!1?"Ended with an error":e.ok===!0?"Done":"Ended",s=e.endedAt===null?"working":e.ok===!1?"failed":e.ok===!0?"done":"stopped",i=t.filter(l=>l.via===e.s);return(0,r.jsxs)("li",{className:ya(a),"data-live-child":e.s,children:[(0,r.jsxs)("article",{className:"flex flex-col gap-2 rounded-card border border-border bg-card p-3",children:[(0,r.jsxs)("header",{className:"flex items-start gap-2",children:[(0,r.jsx)("h3",{className:"line-clamp-2 min-w-0 flex-1 text-[13px] font-semibold leading-[1.35]",title:e.desc,children:e.desc}),(0,r.jsx)($e,{tone:Te[s]??"info",children:o})]}),(0,r.jsxs)("p",{className:"flex gap-2 text-[12px] text-muted-foreground",children:[(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.endedAt===null?wa(e)??"":""}),(0,r.jsx)("span",{className:"shrink-0 tabular-nums",children:Me(new Date(e.startedAt).toISOString(),e.endedAt??n)})]}),(0,r.jsx)(it,{lines:e.lines,short:!0})]}),i.length>0&&(0,r.jsx)("ul",{"aria-label":`Subagents of ${e.desc}`,className:"ml-4 mt-2 flex flex-col",children:i.map((l,d)=>(0,r.jsx)(Gt,{child:l,all:t,now:n,last:d===i.length-1},l.s))})]})}function ja({tile:e,stream:t,streamed:n,showLive:a,tall:o=!1,lost:s=!1}){let i="text-[12px] text-muted-foreground",l="text-[11.5px] text-muted-foreground",d=!e.local||t.mainState==="off"?(0,r.jsx)("p",{className:i,children:"Output is on another computer."}):n?t.mainState==="unavailable"?(0,r.jsx)("p",{className:i,children:"Output unavailable."}):(0,r.jsxs)(r.Fragment,{children:[t.earlier&&(0,r.jsx)("p",{className:l,children:"Earlier output isn't shown."}),t.mainState==="error"&&(0,r.jsx)("p",{className:l,children:"Couldn't read the latest output. Retrying."}),t.mainState==="loading"?(0,r.jsx)("p",{className:i,children:"Loading output…"}):(0,r.jsx)(it,{lines:t.main.lines,short:!1,tall:o})]}):(0,r.jsxs)("p",{className:K(i,"flex items-center gap-2"),children:["Not shown live.",(0,r.jsx)("button",{type:"button",onClick:a,className:"rounded-sm border border-border bg-card px-2 py-0.5 text-[11.5px] text-foreground phone:min-h-11",children:"Show live"})]});return(0,r.jsxs)(r.Fragment,{children:[s&&(0,r.jsx)("p",{className:l,children:"Reconnecting… these lines may not be the latest."}),d,t.subState==="unavailable"&&(0,r.jsx)("p",{className:l,children:"Subagents' output unavailable."}),t.subState==="error"&&(0,r.jsx)("p",{className:l,children:"Couldn't read the subagents' output. Retrying."}),t.subRestarted&&(0,r.jsx)("p",{className:l,children:"Subagents' output restarted."}),t.over&&(0,r.jsx)("p",{className:l,children:"More subagents started than are shown."})]})}function Pt(e){let t=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID().replace(/-/g,"").slice(0,16):`${Date.now().toString(36)}${Math.random().toString(36).slice(2,10)}`;return`${e}-${t}`}function ka(e,t,n){return e.why==="quiet"&&e.quietSince!==null?`Quiet for ${Me(e.quietSince,n)}`:e.why==="question"?"Asked a question":e.endedAt!==null?"":wa(t.main)??e.now??""}var Oe="inline-flex h-7 items-center justify-center rounded-md border border-[var(--so-input-line)] bg-[var(--so-raised)] px-2.5 text-[12px] font-medium text-foreground transition-colors hover:border-[var(--so-field-line)] hover:bg-[var(--so-soft)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--so-signal)] disabled:opacity-50 phone:min-h-9 phone:px-3",Ss="inline-flex h-7 items-center justify-center rounded-md border border-[var(--so-danger)]/35 bg-[var(--so-danger-soft)] px-2.5 text-[12px] font-medium text-[var(--so-danger)] transition-colors hover:border-[var(--so-danger)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--so-danger)] disabled:opacity-50 phone:min-h-9 phone:px-3",Es="inline-flex h-7 items-center justify-center rounded-md border border-[var(--so-signal)] bg-[var(--so-signal)] px-2.5 text-[12px] font-medium text-[var(--so-on-signal)] transition-opacity hover:opacity-90 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--so-signal)] disabled:opacity-50 phone:min-h-9 phone:px-3";function $a({tile:e,stream:t,childrenCount:n}){let a=Math.max(e.subagentCount??0,n),o=e.changedFiles??t.main.editedFiles.length;return a<=0&&o<=0?null:(0,r.jsxs)("div",{className:"agents-live-pills",children:[a>0&&(0,r.jsxs)("span",{className:"agents-live-pill agents-live-pill--signal inline-flex items-center rounded-full border border-[var(--so-signal)]/40 bg-[var(--so-signal-soft)] px-2 py-0.5 text-[11px] font-medium tabular-nums text-[var(--so-signal)]","data-live-helpers":a,children:[a," ",a===1?"helper":"helpers"]}),o>0&&(0,r.jsxs)("span",{className:"agents-live-pill inline-flex items-center rounded-full border border-[var(--so-line)] bg-[var(--so-raised)] px-2 py-0.5 text-[11px] font-medium tabular-nums text-foreground","data-live-files":o,children:["+",o," ",o===1?"file":"files"]})]})}function Na({tile:e,actionState:t,onAction:n,onInspect:a}){if(e.endedAt!==null||e.taskId==="")return a===void 0?null:(0,r.jsx)("div",{className:"agents-live-tile-acts flex flex-wrap items-center gap-2 border-t border-border pt-2.5","data-live-actions":e.runId,children:(0,r.jsx)("button",{type:"button",className:Oe,"data-live-inspect":e.runId,onClick:a,children:"Inspect"})});let o=t?.paused??(e.paused===!0||e.pauseState==="paused"),s=t?.busy??null;return(0,r.jsxs)("div",{className:"agents-live-tile-acts flex flex-wrap items-center gap-2 border-t border-border pt-2.5","data-live-actions":e.runId,children:[a!==void 0&&(0,r.jsx)("button",{type:"button",className:Es,"data-live-inspect":e.runId,onClick:a,children:"Inspect"}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 ml-auto",children:[o?(0,r.jsx)("button",{type:"button",className:K("agents-live-act-btn",Oe),"data-live-action":"resume",disabled:s!==null,onClick:()=>n(e,"resume"),children:s==="resume"?"Resuming…":"Resume"}):(0,r.jsx)("button",{type:"button",className:K("agents-live-act-btn",Oe),"data-live-action":"pause",disabled:s!==null,onClick:()=>n(e,"pause"),children:s==="pause"?"Pausing…":"Pause"}),(0,r.jsx)("button",{type:"button",className:K("agents-live-act-btn agents-live-act-btn--danger",Ss),"data-live-action":"stop",disabled:s!==null,onClick:()=>n(e,"stop"),children:s==="stop"?"Stopping…":"Stop"})]}),t?.message&&(0,r.jsx)("p",{className:"agents-live-act-msg w-full text-[11.5px] text-muted-foreground",role:"status","data-live-action-status":!0,children:t.message})]})}function Tt({tile:e,stream:t,streamed:n,now:a,repairs:o,streams:s,streamedIds:i,showLive:l,openRun:d,actionStates:h,onAction:c,nested:m}){let x=e.state==="needs-you",p=ka(e,t,a),v=[...t.children.values()].filter(w=>!w.expired).sort((w,j)=>w.s-j.s),f=v.filter(w=>w.via===void 0||!v.some(j=>j.s===w.via)),g=[e.project?.split("/").pop(),e.role,e.agent,e.model].filter(Boolean).join(" · "),N=x?"needs":e.state;return(0,r.jsxs)("li",{className:K("flex min-w-0 flex-col gap-2",m!==void 0&&ya(m.last)),"data-live-tile":e.runId,"data-live-state":e.state,children:[(0,r.jsxs)("article",{className:K("flex min-w-0 flex-col gap-2.5 rounded-card border bg-card p-3.5",x?Ns:"border-border"),children:[(0,r.jsxs)("header",{className:"flex flex-col gap-1",children:[(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)("h2",{className:"line-clamp-2 min-w-0 flex-1 text-[15px] font-semibold leading-[1.3]",title:e.title,children:(0,r.jsx)("button",{type:"button","data-live-open":e.runId,onClick:()=>d(e.runId),className:"text-left hover:underline hover:underline-offset-4 phone:min-h-11",children:e.title})}),(0,r.jsx)($e,{tone:N==="needs"?"needs":Te[N]??"info",children:ze[e.state]})]}),(0,r.jsx)("p",{className:"truncate font-mono text-[11px] text-muted-foreground",title:g,children:g})]}),(0,r.jsxs)("p",{className:"flex gap-2 text-[13px]",children:[(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate","data-live-now":!0,children:p}),(0,r.jsx)("span",{className:"shrink-0 text-[12px] tabular-nums text-muted-foreground",children:Me(e.startedAt,e.endedAt===null?a:Date.parse(e.endedAt))})]}),(0,r.jsx)($a,{tile:e,stream:t,childrenCount:v.length}),(0,r.jsx)(ja,{tile:e,stream:t,streamed:n,showLive:()=>l(e.runId)}),(0,r.jsx)(Na,{tile:e,actionState:h.get(e.runId),onAction:c,onInspect:()=>d(e.runId)})]}),o.length>0&&(0,r.jsx)("ul",{"aria-label":`Repairs of ${e.title}`,className:"ml-4 flex flex-col gap-2",children:o.map(w=>(0,r.jsx)(Tt,{tile:w,stream:s.get(w.runId)??qe,streamed:i.has(w.runId),now:a,repairs:[],streams:s,streamedIds:i,showLive:l,openRun:d,actionStates:h,onAction:c},w.runId))}),f.length>0&&(0,r.jsx)("ul",{"aria-label":`Subagents of ${e.title}`,className:"ml-4 flex flex-col",children:f.map((w,j)=>(0,r.jsx)(Gt,{child:w,all:v,now:a,last:j===f.length-1},w.s))})]})}function Cs({runId:e,fileIndex:t,initialHunks:n}){let[a,o]=(0,k.useState)(n);return(0,k.useEffect)(()=>{if(n!==null){o(n);return}let s=!0;return fetch(`/agents/live/run/${e}/diff?file=${t}`,{credentials:"same-origin"}).then(i=>i.ok?i.json():null).then(i=>{s&&o(Array.isArray(i?.file?.hunks)?i.file.hunks:"error")}).catch(()=>{s&&o("error")}),()=>{s=!1}},[e,t,n]),a===null?(0,r.jsx)("p",{className:"px-3 py-2 text-[12px] text-muted-foreground",children:"Reading hunks…"}):a==="error"?(0,r.jsx)("p",{className:"px-3 py-2 text-[12px] text-muted-foreground",children:"This file's diff couldn't be read."}):a.length===0?(0,r.jsx)("p",{className:"px-3 py-2 text-[12px] text-muted-foreground",children:"No hunks for this file."}):(0,r.jsx)("div",{"data-live-diff-hunks":t,children:a.map((s,i)=>(0,r.jsxs)("div",{className:"agents-diff-hunk",children:[(0,r.jsx)("div",{className:"agents-diff-hunk-head",children:s.header}),(0,r.jsx)("ol",{className:"agents-diff-lines",children:s.lines.map((l,d)=>{let h=l.kind==="addition"||l.kind==="add"||l.kind==="+",c=l.kind==="deletion"||l.kind==="del"||l.kind==="-";return(0,r.jsxs)("li",{className:K("agents-diff-line",h&&"agents-diff-line--addition",c&&"agents-diff-line--deletion"),"data-diff-line-kind":l.kind,children:[(0,r.jsx)("span",{className:"agents-diff-ln",children:l.oldLine??""}),(0,r.jsx)("span",{className:"agents-diff-ln",children:l.newLine??""}),(0,r.jsx)("span",{"aria-hidden":"true",className:"agents-diff-sigil",children:h?"+":c?"−":" "}),(0,r.jsx)("span",{className:"agents-diff-code",children:l.text})]},d)})})]},i))})}function Rs({runId:e,running:t,active:n}){let[a,o]=(0,k.useState)({status:"loading"}),[s,i]=(0,k.useState)(null);if((0,k.useEffect)(()=>{if(!n)return;let x=!1,p=0,v=async()=>{try{let f=await fetch(`/agents/live/run/${e}/diff`,{cache:"no-store",credentials:"same-origin"});if(x)return;if(f.status===404||!f.ok)o(g=>g.status==="ready"?g:{status:"empty"});else{let g=await f.json();if(x)return;let N=Array.isArray(g?.files)?g.files:[];N.length===0?o({status:"empty"}):o({status:"ready",data:{version:g?.version??1,files:N,...g?.live===void 0?{}:{live:g.live},...g?.totals===void 0?{}:{totals:g.totals},...g?.file===void 0?{}:{file:g.file}}})}}catch{x||o(f=>f.status==="ready"?f:{status:"empty"})}!x&&t&&(p=window.setTimeout(()=>{v()},ws))};return v(),()=>{x=!0,window.clearTimeout(p)}},[e,t,n]),a.status==="loading")return(0,r.jsx)("p",{className:"text-[12.5px] text-muted-foreground","data-live-diff-loading":!0,children:"Reading worktree diff…"});if(a.status==="empty")return(0,r.jsxs)("div",{className:"flex flex-col gap-2","data-live-diff-empty":!0,children:[t&&(0,r.jsx)("div",{className:"agents-diff-head",children:(0,r.jsx)("span",{className:"agents-diff-badge agents-diff-badge--live","data-live-diff-badge":!0,children:"Live worktree"})}),(0,r.jsx)("p",{className:"text-[12.5px] text-muted-foreground",children:"No changes yet"})]});let{data:l}=a,d=l.live!==!1&&t,h=l.totals?.files??l.files.length,c=l.totals?.added??l.files.reduce((x,p)=>x+p.added,0),m=l.totals?.removed??l.files.reduce((x,p)=>x+p.removed,0);return(0,r.jsxs)("div",{className:"flex flex-col gap-3","data-live-diff":!0,children:[(0,r.jsxs)("div",{className:"agents-diff-head",children:[(0,r.jsx)("span",{className:K("agents-diff-badge inline-flex items-center rounded-full border px-2.5 py-0.5 text-[11.5px] font-medium",d?"agents-diff-badge--live border-[var(--so-signal)]/40 bg-[var(--so-signal-soft)] text-[var(--so-signal)]":"border-[var(--so-line)] bg-[var(--so-raised)] text-foreground"),"data-live-diff-badge":!0,children:d?"Live worktree":"Diff snapshot"}),(0,r.jsxs)("span",{className:"agents-diff-totals",children:[h," ",h===1?"file":"files"," · ",(0,r.jsxs)("span",{className:"agents-add",children:["+",c]})," ",(0,r.jsxs)("span",{className:"agents-del",children:["−",m]})]})]}),(0,r.jsx)("ul",{className:"agents-diff-list","data-live-diff-files":!0,children:l.files.map((x,p)=>{let v=x.index??p,f=s===v,g=l.file?.path===x.path&&Array.isArray(l.file.hunks)?l.file.hunks:null;return(0,r.jsxs)("li",{className:"agents-diff-file","data-live-diff-file":x.path,children:[(0,r.jsxs)("div",{className:"agents-diff-file-row",children:[(0,r.jsx)("span",{className:"agents-diff-file-path",title:x.path,children:x.path}),(0,r.jsx)("span",{className:"agents-diff-file-stat",children:x.binary?(0,r.jsx)("span",{className:"text-muted-foreground",children:"binary"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("span",{className:"agents-add",children:["+",x.added]}),(0,r.jsxs)("span",{className:"agents-del",children:["−",x.removed]})]})}),!x.binary&&(0,r.jsx)("button",{type:"button",className:K("agents-live-act-btn",Oe),"aria-expanded":f,"data-live-diff-toggle":v,onClick:()=>i(f?null:v),children:f?"Hide":"Show"})]}),f&&(0,r.jsx)(Cs,{runId:e,fileIndex:v,initialHunks:g})]},`${v}:${x.path}`)})})]})}function Ds({tile:e,csrf:t,onSent:n}){let[a,o]=(0,k.useState)(""),[s,i]=(0,k.useState)(!1),[l,d]=(0,k.useState)(null);if(e.endedAt!==null||e.taskId==="")return null;let h=async()=>{let c=a.trim();if(!(s||c==="")){i(!0),d(null);try{let m=await fetch(`/t/${encodeURIComponent(e.taskId)}/steer`,{method:"POST",credentials:"same-origin",redirect:"manual",headers:Be({accept:"application/json"}),body:new URLSearchParams({csrf:t,run:String(e.runId),key:Pt("live"),note:c,return:"agents"})});m.type==="opaqueredirect"||m.ok?(o(""),d({ok:!0,text:"Sent to agent."}),n()):d({ok:!1,text:"Couldn't send note. Try again."})}catch{d({ok:!1,text:"Couldn't reach Toolroll. Your note is kept."})}finally{i(!1)}}};return(0,r.jsxs)("div",{className:"agents-inspector-steer","data-inspector-steer":!0,children:[(0,r.jsxs)("div",{className:"agents-inspector-steer-row",children:[(0,r.jsx)("textarea",{className:"agents-inspector-steer-input min-h-[38px] max-h-[120px] min-w-0 flex-1 resize-y rounded-md border border-[var(--so-input-line)] bg-[var(--so-raised)] px-2.5 py-2 text-[13px] leading-[1.45] text-foreground placeholder:text-muted-foreground focus-visible:border-[var(--so-signal)] focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-[var(--so-signal)]","aria-label":"Steer this agent",placeholder:"Steer this agent…",rows:2,maxLength:4e3,value:a,disabled:s,onChange:c=>{o(c.target.value),l!==null&&d(null)},onKeyDown:c=>{c.key==="Enter"&&!c.shiftKey&&!c.nativeEvent.isComposing&&(c.preventDefault(),h())}}),(0,r.jsx)("button",{type:"button",className:"agents-inspector-steer-send inline-flex h-[38px] shrink-0 items-center justify-center rounded-md border border-[var(--so-signal)] bg-[var(--so-signal)] px-3.5 text-[12.5px] font-medium text-[var(--so-on-signal)] transition-opacity hover:opacity-90 disabled:opacity-45","data-inspector-steer-send":!0,disabled:s||a.trim()==="",onClick:()=>{h()},children:s?"Sending…":"Steer"})]}),l!==null&&(0,r.jsx)("p",{className:K("text-[12px]",l.ok?"text-muted-foreground":"text-destructive"),role:"status","data-inspector-steer-status":!0,children:l.text})]})}function Is({runId:e,tile:t,stream:n,streamed:a,now:o,lost:s,csrf:i,actionState:l,onAction:d,onSent:h,onClose:c,showLive:m}){let x=(0,k.useRef)(null),[p,v]=(0,k.useState)("live"),f=[...n.children.values()].sort((w,j)=>w.s-j.s),g=f.filter(w=>w.via===void 0||!f.some(j=>j.s===w.via)),N=t!==null&&t.taskId!==""?`/term?task=${encodeURIComponent(t.taskId)}&run=${t.runId}`:`/term?run=${e}`;return(0,r.jsx)(Wt,{open:!0,onOpenChange:w=>{w||c()},children:(0,r.jsxs)(Ht,{container:typeof document>"u"?void 0:document.querySelector("[data-view]")??void 0,children:[(0,r.jsx)(qt,{className:"ui-dialog-overlay"}),(0,r.jsxs)(Kt,{"data-live-full":!0,"data-live-inspector":e,"aria-describedby":void 0,onOpenAutoFocus:w=>{w.preventDefault(),x.current?.focus()},onCloseAutoFocus:w=>{w.preventDefault(),(document.querySelector(`[data-live-open="${e}"]`)??document.querySelector("[data-live-grid]"))?.focus()},className:"ui-dialog-content agents-inspector-drawer",children:[(0,r.jsxs)("header",{className:"flex items-start gap-3",children:[(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)(zt,{className:"text-[18px] font-semibold leading-[1.3]","data-live-full-title":!0,children:t?.title??"This agent isn't on the grid anymore"}),t!==null&&(0,r.jsx)("p",{className:"truncate font-mono text-[11px] text-muted-foreground",children:[t.project?.split("/").pop(),t.role,t.agent,t.model].filter(Boolean).join(" · ")})]}),t!==null&&(0,r.jsx)($e,{tone:t.state==="needs-you"?"needs":Te[t.state]??"info",children:ze[t.state]}),(0,r.jsx)(va,{ref:x,className:K("shrink-0",Oe),children:"Close"})]}),(0,r.jsx)(ln,{label:"Inspector",current:p,onChange:w=>v(w==="diff"||w==="terminal"?w:"live"),items:[{key:"live",label:"Live"},{key:"diff",label:"Diff"},{key:"terminal",label:"Terminal"}]}),(0,r.jsxs)("div",{className:"agents-inspector-body",children:[p==="live"&&(0,r.jsx)("div",{role:"tabpanel","aria-label":"Live","data-inspector-panel":"live",className:"flex flex-col gap-3",children:t!==null&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("p",{className:"flex items-center gap-3 text-[13px]",children:[(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate",children:ka(t,n,o)}),(0,r.jsx)("span",{className:"shrink-0 text-[12px] tabular-nums text-muted-foreground",children:Me(t.startedAt,t.endedAt===null?o:Date.parse(t.endedAt))}),t.taskHref!==null&&(0,r.jsx)("a",{href:t.taskHref,className:"shrink-0 text-[12.5px] underline decoration-border underline-offset-4 hover:decoration-current phone:inline-flex phone:min-h-11 phone:items-center",children:"Open task"})]}),(0,r.jsx)($a,{tile:t,stream:n,childrenCount:f.length}),(0,r.jsx)(Na,{tile:t,actionState:l,onAction:d}),(0,r.jsx)(ja,{tile:t,stream:n,streamed:a,showLive:m,tall:!0,lost:s}),g.length>0&&(0,r.jsxs)("section",{"aria-label":"Subagents",className:"flex flex-col gap-2",children:[(0,r.jsxs)("h3",{className:"text-[13px] font-semibold",children:["Subagents ",(0,r.jsx)("span",{className:"font-normal tabular-nums text-muted-foreground",children:f.length})]}),(0,r.jsx)("ul",{className:"flex flex-col",children:g.map((w,j)=>(0,r.jsx)(Gt,{child:w,all:f,now:o,last:j===g.length-1},w.s))})]}),(0,r.jsx)(Ds,{tile:t,csrf:i,onSent:h})]})}),p==="diff"&&(0,r.jsx)("div",{role:"tabpanel","aria-label":"Diff","data-inspector-panel":"diff",className:"flex flex-col gap-3",children:(0,r.jsx)(Rs,{runId:e,running:t!==null&&t.endedAt===null,active:p==="diff"})}),p==="terminal"&&(0,r.jsx)("div",{role:"tabpanel","aria-label":"Terminal","data-inspector-panel":"terminal",className:"flex flex-col gap-3",children:(0,r.jsxs)("div",{className:"agents-term-card",children:[(0,r.jsx)("p",{className:"text-[13px] text-foreground",children:"Attach to this run's live PTY session in the interactive terminal."}),t!==null&&(0,r.jsxs)("p",{className:"font-mono text-[11.5px] text-muted-foreground",children:["Run #",t.runId," · ",t.taskId]}),(0,r.jsx)("a",{href:N,className:"agents-term-link","data-inspector-terminal-link":!0,children:"Open interactive terminal ↗"})]})})]})]})]})})}var Sa=e=>["lead chat",e.project?.split("/").pop(),e.stepAt.length>1?`step ${e.stepAt.length}`:null].filter(Boolean).join(" · "),As={lead:"lead chat",project:"project chat",task:"task chat"};function Os({thread:e,runs:t,label:n,render:a}){return t.length===0?null:(0,r.jsx)("ul",{"aria-label":n,className:"ml-4 flex flex-col","data-live-filed":e,children:t.map((o,s)=>a(o,s===t.length-1))})}function Ps({lead:e,now:t,openLead:n}){return(0,r.jsxs)("article",{className:"flex min-w-0 flex-col gap-2.5 rounded-card border border-border bg-card p-3.5",children:[(0,r.jsxs)("header",{className:"flex flex-col gap-1",children:[(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)("h2",{className:"line-clamp-2 min-w-0 flex-1 text-[15px] font-semibold leading-[1.3]",title:e.title,children:(0,r.jsx)("button",{type:"button","data-live-open-lead":e.thread,onClick:()=>n(e.thread),className:"text-left hover:underline hover:underline-offset-4 phone:min-h-11",children:e.title})}),(0,r.jsx)($e,{tone:Te[e.state]??"info",children:ze[e.state]})]}),(0,r.jsx)("p",{className:"truncate font-mono text-[11px] text-muted-foreground",children:Sa(e)})]}),(0,r.jsxs)("p",{className:"flex gap-2 text-[13px]",children:[(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.doing??""}),(0,r.jsx)("span",{className:"shrink-0 text-[12px] tabular-nums text-muted-foreground",children:Me(e.startedAt,e.endedAt===null?t:Date.parse(e.endedAt))})]}),e.earlier&&(0,r.jsx)("p",{className:"text-[11.5px] text-muted-foreground",children:"Earlier lines aren't shown."}),(0,r.jsx)(it,{lines:e.lines,short:!1})]})}function In({thread:e,lead:t,runs:n,now:a,openLead:o,render:s}){let i=[...new Set(n.map(d=>d.project?.split("/").pop()).filter(Boolean))].join(", "),l=n.length===0?"":`Filed by ${As[n[0].filedBy.chat]}${i===""?"":` · ${i}`}`;return(0,r.jsxs)("li",{className:"flex min-w-0 flex-col gap-2",...t!==null?{"data-live-lead":e,"data-live-state":t.state}:{"data-live-filed-group":e},children:[t!==null?(0,r.jsx)(Ps,{lead:t,now:a,openLead:o}):(0,r.jsx)("p",{className:"truncate text-[12px] text-muted-foreground",title:l,children:l}),(0,r.jsx)(Os,{thread:e,runs:n,label:t!==null?`Filed by ${t.title}`:l,render:s})]})}function Ts({thread:e,lead:t,now:n,lost:a,onClose:o,filed:s}){let i=(0,k.useRef)(null),l="shrink-0 text-[12.5px] underline decoration-border underline-offset-4 hover:decoration-current phone:inline-flex phone:min-h-11 phone:items-center";return(0,r.jsx)(Wt,{open:!0,onOpenChange:d=>{d||o()},children:(0,r.jsxs)(Ht,{container:typeof document>"u"?void 0:document.querySelector("[data-view]")??void 0,children:[(0,r.jsx)(qt,{className:"ui-dialog-overlay"}),(0,r.jsxs)(Kt,{"data-live-full":!0,"aria-describedby":void 0,onOpenAutoFocus:d=>{d.preventDefault(),i.current?.focus()},onCloseAutoFocus:d=>{d.preventDefault(),(document.querySelector(`[data-live-open-lead="${e}"]`)??document.querySelector("[data-live-grid]"))?.focus()},className:"ui-dialog-content flex !w-[min(1100px,calc(100vw-48px))] flex-col gap-3 !p-5 phone:!bottom-0 phone:!left-0 phone:!top-auto phone:!max-h-[calc(100dvh-2rem)] phone:!w-full phone:!rounded-b-none phone:!p-4 phone:!pb-[max(1rem,env(safe-area-inset-bottom))] phone:![transform:none]",children:[(0,r.jsxs)("header",{className:"flex items-start gap-3",children:[(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)(zt,{className:"text-[18px] font-semibold leading-[1.3]","data-live-full-title":!0,children:t?.title??"This reply isn't on the grid anymore"}),t!==null&&(0,r.jsx)("p",{className:"truncate font-mono text-[11px] text-muted-foreground",children:Sa(t)})]}),t!==null&&(0,r.jsx)($e,{tone:Te[t.state]??"info",children:ze[t.state]}),(0,r.jsx)(va,{ref:i,className:K("shrink-0",Oe),children:"Close"})]}),t!==null&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("p",{className:"flex items-center gap-3 text-[13px]",children:[(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t.doing??""}),(0,r.jsx)("span",{className:"shrink-0 text-[12px] tabular-nums text-muted-foreground",children:Me(t.startedAt,t.endedAt===null?n:Date.parse(t.endedAt))}),(0,r.jsx)("a",{href:t.chatHref,className:l,children:"Open chat"}),t.taskHref!==null&&(0,r.jsx)("a",{href:t.taskHref,className:l,children:"Open task"})]}),t.earlier&&(0,r.jsx)("p",{className:"text-[11.5px] text-muted-foreground",children:"Earlier lines aren't shown."}),(0,r.jsx)(it,{lines:t.lines,short:!1,tall:!0})]}),a&&(t!==null||s.length>0)&&(0,r.jsx)("p",{className:"text-[11.5px] text-muted-foreground",children:"Reconnecting… these lines may not be the latest."}),s.length>0&&(0,r.jsxs)("section",{"aria-label":"Tasks it filed",className:"flex flex-col gap-2","data-live-full-filed":!0,children:[(0,r.jsxs)("h3",{className:"text-[13px] font-semibold",children:["Tasks it filed ",(0,r.jsx)("span",{className:"font-normal tabular-nums text-muted-foreground",children:s.length})]}),(0,r.jsx)("ul",{className:"flex flex-col gap-1.5",children:s.map(d=>(0,r.jsxs)("li",{className:"flex items-center gap-2 text-[13px]",children:[(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate",title:d.title,children:d.title}),(0,r.jsx)($e,{tone:d.state==="needs-you"?"needs":Te[d.state]??"info",children:ze[d.state]}),d.taskHref!==null&&(0,r.jsx)("a",{href:d.taskHref,className:l,children:"Open task"})]},d.runId))})]})]})]})})}function Ms({working:e,needsYou:t,shownLive:n,local:a}){let o=s=>(0,r.jsx)("span",{className:"font-semibold tabular-nums text-foreground",children:s});return(0,r.jsxs)("p",{className:"text-[13px] text-muted-foreground","data-live-headline":!0,children:[o(e)," ",e===1?"agent":"agents"," working",t>0&&(0,r.jsxs)(r.Fragment,{children:[" · ",o(t)," ",t===1?"needs":"need"," you"]}),a>n&&(0,r.jsxs)(r.Fragment,{children:[" · ",o(n)," of ",o(a)," shown live"]})]})}function Ls(e){return e.waiting>0?{word:"Question",tone:"needs"}:e.ended?{word:"Ended",tone:"neutral"}:e.turn==="admitted"||e.turn==="running"?{word:"Working",tone:"info"}:e.ship!==null&&["approved","imported","armed","completed","merging"].includes(e.ship)?{word:"Shipping",tone:"info"}:e.turn==="unknown"?{word:"Outcome unknown",tone:"neutral"}:e.turn==="interrupted"?{word:"Stopped",tone:"neutral"}:e.ship==="cancelled"?{word:"Ship stopped",tone:"neutral"}:e.ship==="refused"||e.ship==="failed"?{word:"Ship refused",tone:"danger"}:{word:"Ready",tone:"neutral"}}function An(e){return e==="merged"?"Ship: Merged":e==="sent-back"?"Ship: sent back":null}function Fs(e,t){let n=e.filter(s=>s.s===void 0&&s.k!=="you"),a=on(rn("thread"),{records:n,final:!t}),o=e.flatMap((s,i)=>s.k!=="you"||!Array.isArray(s.t)?[]:[{id:i+1,author:"You",mine:!0,text:s.t.join(`
44
+ `),standing:"Sent",readAt:null,at:Number.isFinite(Date.parse(s.at??""))?new Date(Date.parse(s.at)-1).toISOString():""}]);return{...a,notes:o}}function _s({thread:e,file:t}){let[n,a]=(0,k.useState)(null);return(0,k.useEffect)(()=>{let o=!0;return fetch(`/agents/live/thread/${e}/diff?file=${t.file}`,{credentials:"same-origin"}).then(s=>s.ok?s.json():null).then(s=>{o&&a(Array.isArray(s?.file?.hunks)?s.file.hunks.flatMap(i=>Array.isArray(i.lines)?i.lines:[]):"error")}).catch(()=>{o&&a("error")}),()=>{o=!1}},[e,t.file]),n===null?(0,r.jsx)("p",{className:"text-caption text-muted-foreground",children:"Reading…"}):n==="error"?(0,r.jsx)("p",{className:"text-caption text-muted-foreground",children:"This file's changes couldn't be read."}):(0,r.jsx)(Da,{excerpt:{path:t.path,cited:!0,more:0,lines:n.map(o=>({kind:o.kind==="meta"?"context":o.kind,line:o.newLine??o.oldLine,text:o.text}))},changesHref:null})}function Us({id:e}){let t=(0,k.useContext)(Ve),[n,a]=(0,k.useState)(null),[o,s]=(0,k.useState)(!1);return(0,r.jsxs)("div",{className:"flex flex-col gap-1","data-live-thread-save":!0,children:[(0,r.jsx)("span",{children:(0,r.jsx)(Ze,{variant:"outline",sm:!0,label:o?"Saving…":"Save as branch",disabled:o,onClick:()=>{o||t===""||(s(!0),fetch(`/agents/live/thread/${e}/save`,{method:"POST",credentials:"same-origin",headers:Be({accept:"application/json"}),body:new URLSearchParams({csrf:t})}).then(async i=>{let l=await i.json().catch(()=>null);a({ok:l?.outcome==="done",words:typeof l?.words=="string"?l.words:"That didn't go through."})}).catch(()=>a({ok:!1,words:"That didn't go through. Check your connection and try again."})).finally(()=>s(!1)))}})}),n!==null&&(0,r.jsx)("p",{className:`text-caption ${n.ok?"text-foreground":"text-destructive"}`,role:"status",children:n.words})]})}function Bs({id:e}){let[t,n]=(0,k.useState)(null),[a,o]=(0,k.useState)(!1),[s,i]=(0,k.useState)(null),[l,d]=(0,k.useState)(null);return(0,k.useEffect)(()=>{let h=!0;return fetch(`/agents/live/thread/${e}?file=main`,{credentials:"same-origin"}).then(c=>c.ok?c.json():null).then(c=>{h&&(o(c?.live===!0),n(c?.window?.ok===!0&&Array.isArray(c.window.records)?c.window.records:[]))}).catch(()=>{h&&n([])}),fetch(`/agents/live/thread/${e}/diff`,{credentials:"same-origin"}).then(c=>c.ok?c.json():null).then(c=>{h&&i({files:Array.isArray(c?.files)?c.files:[],problem:c===null?"The changes couldn't be read.":c.problem??null,patchTruncated:c?.patchTruncated===!0})}).catch(()=>{h&&i({files:[],problem:"The changes couldn't be read.",patchTruncated:!1})}),()=>{h=!1}},[e]),(0,r.jsxs)("div",{className:"flex flex-col gap-3 pb-2 pl-1","data-live-thread-detail":e,children:[t===null?(0,r.jsx)("p",{className:"text-caption text-muted-foreground",children:"Reading…"}):t.length===0?(0,r.jsx)("p",{className:"text-caption text-muted-foreground",children:"Nothing to show here yet."}):(0,r.jsx)(dn,{conversation:Fs(t,a),live:a}),(0,r.jsxs)("section",{"aria-label":"Changes",className:"flex flex-col gap-2","data-live-thread-diff":!0,children:[(0,r.jsx)("h3",{className:"text-label font-semibold text-foreground",children:"Changes since the thread started"}),s===null?(0,r.jsx)("p",{className:"text-caption text-muted-foreground",children:"Reading…"}):s.problem!==null?(0,r.jsx)("p",{className:"text-caption text-muted-foreground",children:s.problem}):(0,r.jsx)("ul",{className:"flex flex-col gap-1",children:s.files.map(h=>(0,r.jsxs)("li",{className:"flex flex-col gap-1",children:[(0,r.jsxs)("span",{className:"flex min-w-0 items-center gap-2 text-body",children:[(0,r.jsx)("span",{className:"min-w-0 truncate font-mono text-foreground",children:h.path}),(0,r.jsx)("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:h.binary?"binary":`+${h.additions} −${h.deletions}`}),(0,r.jsx)("span",{className:"ml-auto shrink-0",children:(0,r.jsx)(Ze,{variant:"ghost",sm:!0,label:l===h.file?"Hide":"Show","aria-expanded":l===h.file,onClick:()=>d(l===h.file?null:h.file)})})]}),l===h.file&&(0,r.jsx)(_s,{thread:e,file:h})]},h.file))}),s?.patchTruncated===!0&&(0,r.jsx)("p",{className:"text-caption text-muted-foreground",children:"Some files are left out: the change is too large to show here."})]}),s!==null&&s.problem===null&&s.files.length>0&&(0,r.jsx)(Us,{id:e})]})}function Ws({refreshKey:e}){let[t,n]=(0,k.useState)([]),[a,o]=(0,k.useState)(null);return(0,k.useEffect)(()=>{let s=!0;return fetch("/agents/live/threads",{credentials:"same-origin"}).then(i=>i.ok?i.json():null).then(i=>{s&&n(Array.isArray(i?.threads)?i.threads:[])}).catch(()=>{}),()=>{s=!1}},[e]),t.length===0?null:(0,r.jsxs)("section",{"aria-label":"Your threads",className:"flex flex-col gap-2 border-t border-border pt-3","data-live-threads":!0,children:[(0,r.jsx)("h2",{className:"text-label font-semibold text-foreground",children:"Your threads"}),(0,r.jsx)("ul",{className:"flex flex-col gap-1",children:t.map(s=>{let{word:i,tone:l}=Ls(s);return(0,r.jsxs)("li",{className:"flex min-w-0 flex-col gap-1","data-live-thread":!0,children:[(0,r.jsxs)("span",{className:"flex min-w-0 items-center gap-2 text-body",children:[(0,r.jsx)("span",{className:"min-w-0 truncate text-foreground",children:s.title}),s.project!==null&&(0,r.jsx)("span",{className:"shrink-0 text-muted-foreground",children:s.project}),An(s.ship)!==null&&(0,r.jsx)("span",{className:"shrink-0 text-muted-foreground",children:An(s.ship)}),(0,r.jsx)("span",{className:"ml-auto shrink-0",children:(0,r.jsx)($e,{tone:l,children:i})}),(0,r.jsx)(Ze,{variant:"ghost",sm:!0,label:a===s.id?"Close":"Open","aria-expanded":a===s.id,"data-live-thread-open":s.id,onClick:()=>o(a===s.id?null:s.id)})]}),a===s.id&&(0,r.jsx)(Bs,{id:s.id})]},s.id)})}),(0,r.jsxs)("p",{className:"text-caption text-muted-foreground",children:["Reply, ship or end a thread in the terminal: run ",(0,r.jsx)("code",{children:"toolroll"}),", then pick it."]})]})}function Xu(){let e=(0,k.useContext)(Ve),[t,n]=(0,k.useState)([]),[a,o]=(0,k.useState)([]),[s,i]=(0,k.useState)([]),[l,d]=(0,k.useState)(new Map),[h,c]=(0,k.useState)(()=>new Map),[m,x]=(0,k.useState)("loading"),[p,v]=(0,k.useState)(!1),[f,g]=(0,k.useState)(0),[N,w]=(0,k.useState)(!1),j=(0,k.useRef)(!1),C=(0,k.useRef)(!1),[D,E]=(0,k.useState)(!1),P=tn(1e3),H=(0,k.useRef)(null),Q=()=>{let u=Number(new URLSearchParams(location.search).get("run"));return Number.isSafeInteger(u)&&u>0?u:null},[M,I]=ht(()=>null,Q),Z=(0,k.useRef)(M);Z.current=M;let he=(0,k.useRef)(new Set),S=(0,k.useRef)(null),le=(0,k.useRef)(0);(0,k.useEffect)(()=>{let u=$s(($,A)=>{let[q,V]=$.split(":");d(X=>new Map(X).set(Number(q),ks(X.get(Number(q))??qe,V,A,Number(q)===Z.current?hs:st)))});return H.current=u,()=>{u.dispose(),H.current=null}},[]);let[se,dt]=(0,k.useState)([]),Fe=[...t,...s.filter(u=>!t.some($=>$.runId===u.runId))].filter(u=>u.local),G=new Set([...new Set([...M!==null&&Fe.some(u=>u.runId===M)?[M]:[],...se.filter(u=>Fe.some($=>$.runId===u)),...Fe.map(u=>u.runId)])].slice(0,En)),_e=[...G].sort((u,$)=>u-$).join(",");(0,k.useEffect)(()=>{let u=_e===""?[]:_e.split(",").flatMap($=>[`${$}:main`,`${$}:sub`]);H.current?.keep(new Set(u)),H.current?.want(u)},[_e]),he.current=G,(0,k.useEffect)(()=>{let u=()=>I(Q());return window.addEventListener("popstate",u),()=>window.removeEventListener("popstate",u)},[]);let Ge=u=>{Z.current!==u&&(Z.current=u,history.pushState({liveRun:u},"",`/agents?view=live&run=${u}`),I(u))},ut=()=>{let u=Z.current;u!==null&&(Z.current=null,history.state?.liveRun===u?history.back():history.replaceState(null,"","/agents?view=live"),I(null))},Xe=(0,k.useRef)(M);(0,k.useEffect)(()=>{let u=Xe.current;Xe.current=M,!(u===null||u===M)&&d($=>{let A=$.get(u);if(A===void 0)return $;let q=new Map([...A.children].map(([V,X])=>[V,{...X,lines:X.lines.slice(-st)}]));return new Map($).set(u,{...A,main:{...A.main,lines:A.main.lines.slice(-st)},children:q})})},[M]);let Ne=()=>{if(Q()!==null)return null;let u=Number(new URLSearchParams(location.search).get("lead"));return Number.isSafeInteger(u)&&u>0?u:null},[ie,Se]=ht(()=>null,Ne),b=(0,k.useRef)(ie);b.current=ie,(0,k.useEffect)(()=>{let u=()=>Se(Ne());return window.addEventListener("popstate",u),()=>window.removeEventListener("popstate",u)},[]);let R=u=>{b.current!==u&&(b.current=u,history.pushState({liveLead:u},"",`/agents?view=live&lead=${u}`),Se(u))},T=()=>{let u=b.current;u!==null&&(b.current=null,history.state?.liveLead===u?history.back():history.replaceState(null,"","/agents?view=live"),Se(null))},_=u=>dt($=>[u,...$.filter(A=>A!==u)].slice(0,En)),xe=(0,k.useCallback)(()=>{let u=++le.current;fetch("/agents/live",{credentials:"same-origin"}).then($=>$.ok?$.json():null).then($=>{if(u===le.current){if($===null){x(A=>A==="ready"?"ready":"error");return}n($.tiles),o($.leads??[]),x("ready"),H.current?.want([...he.current].flatMap(A=>[`${A}:main`,`${A}:sub`]))}}).catch(()=>{u===le.current&&x($=>$==="ready"?"ready":"error")})},[]);(0,k.useEffect)(()=>{xe()},[xe]),en("agents-live",u=>{if(u==="lost"||u==="retrying"){v(!0);return}(u==="change"||u==="reload")&&(v(!1),xe())}),(0,k.useEffect)(()=>{fetch("/term/state",{credentials:"same-origin"}).then(u=>u.ok?u.json():null).then(u=>g((u?.sessions??[]).filter($=>$.endedAt===null).length)).catch(()=>{})},[]);let ct=(0,k.useCallback)(u=>i($=>[...$.flatMap(A=>{let q=t.find(V=>V.runId===A.runId);return q!==void 0?[q]:u?[A]:[]}),...t.filter(A=>!$.some(q=>q.runId===A.runId)).sort((A,q)=>Date.parse(A.startedAt)-Date.parse(q.startedAt))]),[t]);(0,k.useEffect)(()=>{ct(j.current||C.current)},[ct]),(0,k.useEffect)(()=>{C.current&&S.current!==null&&!S.current.contains(document.activeElement)&&Ue(null,!1)}),(0,k.useEffect)(()=>{D||d(u=>{let $=!1,A=new Map(u);for(let[q,V]of u){let X=[...V.children.values()].filter(de=>!de.expired&&de.endedAt!==null&&P-de.endedAt>=vs);if(X.length===0)continue;let te=new Map(V.children);for(let de of X)te.set(de.s,{...de,expired:!0});A.set(q,{...V,children:te}),$=!0}return $?A:u})},[P,D,l]);let Ue=(u,$)=>{u!==null&&(j.current=u),$!==null&&(C.current=$);let A=j.current||C.current;E(A),A||ct(!1)},pt=(0,k.useCallback)((u,$)=>{if(u.taskId==="")return;c(X=>{let te=new Map(X);return te.set(u.runId,{...X.get(u.runId),busy:$,message:null}),te});let A=`/t/${encodeURIComponent(u.taskId)}`,q=$==="stop"?`${A}/stop`:`${A}/pause`,V=new URLSearchParams({csrf:e,run:String(u.runId),return:"agents"});$==="pause"?V.set("request",Pt("live")):$==="resume"&&(V.set("request",Pt("live")),V.set("mode","resume")),fetch(q,{method:"POST",credentials:"same-origin",redirect:"manual",headers:Be({accept:"application/json"}),body:V}).then(X=>{let te=X.type==="opaqueredirect"||X.ok;c(de=>{let mt=new Map(de),Qt=de.get(u.runId);return te?mt.set(u.runId,{...Qt,busy:null,...$==="pause"?{paused:!0,message:"Paused."}:$==="resume"?{paused:!1,message:"Resuming…"}:{message:"Stopping…"}}):mt.set(u.runId,{...Qt,busy:null,message:`Couldn't ${$}. Try again.`}),mt}),te&&xe()}).catch(()=>{c(X=>{let te=new Map(X);return te.set(u.runId,{...X.get(u.runId),busy:null,message:`Couldn't ${$}. Check your connection.`}),te})})},[e,xe]),Xt=new Set(s.map(u=>u.runId)),Vt=u=>s.filter($=>$.role==="repair"&&$.parentRun===u),ft=s.filter(u=>!(u.role==="repair"&&u.parentRun!==null&&Xt.has(u.parentRun))),Zt=u=>ft.filter($=>$.filedBy?.thread===u),Jt=(u,$)=>(0,r.jsx)(Tt,{tile:u,stream:l.get(u.runId)??qe,streamed:G.has(u.runId),now:P,repairs:Vt(u.runId),streams:l,streamedIds:G,showLive:_,openRun:Ge,actionStates:h,onAction:pt,nested:{last:$}},u.runId),Ea=s.filter(u=>u.endedAt===null).length+a.filter(u=>u.endedAt===null).length,Ca=s.filter(u=>u.state==="needs-you").length,Ra=t.length!==s.length||t.some(u=>!Xt.has(u.runId));return(0,r.jsxs)("section",{className:"flex w-full flex-col gap-4 outline-none","data-live-grid":!0,"aria-label":"Live",tabIndex:-1,children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1 phone:sticky phone:top-0 phone:z-10 phone:bg-card phone:py-2",children:[(0,r.jsx)(Ms,{working:Ea,needsYou:Ca,shownLive:G.size,local:t.filter(u=>u.local).length}),Ra&&D&&(0,r.jsx)("p",{className:"text-[12px] text-muted-foreground",children:"Changes wait while you look."}),p&&(0,r.jsx)("p",{className:"text-[12px] text-muted-foreground",role:"status",children:"Reconnecting…"}),(0,r.jsx)("div",{className:"ml-auto flex items-center gap-2",children:(0,r.jsx)("button",{type:"button","data-open-shared-browser":"",onClick:()=>w(!0),className:"inline-flex h-7 items-center gap-1.5 rounded-md !border !border-[var(--so-input-line)] !bg-[var(--so-raised)] px-2.5 text-[12px] font-medium text-foreground transition-colors hover:!border-[var(--so-field-line)] hover:!bg-[var(--so-soft)]",children:"Shared browser"})})]}),m==="error"?(0,r.jsx)("p",{className:"text-[13px] text-muted-foreground",role:"status",children:"Couldn't load the agents. Retrying."}):m==="ready"&&ft.length===0&&a.length===0?(0,r.jsx)("p",{className:"text-[13px] text-muted-foreground",children:"No agents running."}):(0,r.jsxs)("ul",{ref:S,className:"grid items-start gap-4 [grid-template-columns:repeat(auto-fill,minmax(min(100%,340px),1fr))]",onPointerEnter:()=>Ue(!0,null),onPointerLeave:()=>Ue(!1,null),onFocus:()=>Ue(null,!0),onBlur:u=>{u.currentTarget.contains(u.relatedTarget)||Ue(null,!1)},children:[a.filter(u=>Zt(u.thread).length===0).map(u=>(0,r.jsx)(In,{thread:u.thread,lead:u,runs:[],now:P,openLead:R,render:Jt},`lead-${u.thread}`)),ft.map(u=>{let $=u.filedBy?.thread;if($===void 0)return(0,r.jsx)(Tt,{tile:u,stream:l.get(u.runId)??qe,streamed:G.has(u.runId),now:P,repairs:Vt(u.runId),streams:l,streamedIds:G,showLive:_,openRun:Ge,actionStates:h,onAction:pt},u.runId);let A=Zt($),q=a.find(V=>V.thread===$);return A[0]!==u?null:(0,r.jsx)(In,{thread:$,lead:q??null,runs:A,now:P,openLead:R,render:Jt},`group-${$}`)})]}),M!==null&&(0,r.jsx)(Is,{runId:M,tile:[...t,...s].find(u=>u.runId===M)??null,stream:l.get(M)??qe,streamed:G.has(M),now:P,lost:p,csrf:e,actionState:h.get(M),onAction:pt,onSent:xe,onClose:ut,showLive:()=>_(M)},M),ie!==null&&(0,r.jsx)(Ts,{thread:ie,lead:a.find(u=>u.thread===ie)??null,now:P,lost:p,onClose:T,filed:s.filter(u=>u.filedBy?.thread===ie)},`lead-${ie}`),(0,r.jsx)(ms,{open:N,onOpenChange:w}),(0,r.jsx)(Ws,{refreshKey:t.length+a.length}),f>0&&(0,r.jsx)("p",{className:"border-t border-border pt-3 text-[12px] text-muted-foreground",children:(0,r.jsxs)("a",{href:"/term",className:"inline-block underline decoration-border underline-offset-4 hover:text-foreground hover:decoration-current phone:min-h-11 phone:py-3",children:[(0,r.jsx)("span",{className:"tabular-nums",children:f})," ",f===1?"terminal":"terminals"," you're driving"]})})]})}export{vs as CHILD_DONE_MS,qe as EMPTY,hs as FULL_LINES,st as KEEP_LINES,Xu as LiveGrid,bs as MAX_BACKOFF_MS,xs as MAX_READS,gs as READ_DEADLINE_MS,En as STREAMED,ks as applyWindow,$s as createScheduler,An as shipOutcome,Fs as threadConversation,Ls as threadWord};