@xopcai/xopc 0.0.441 → 0.0.443

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 (367) hide show
  1. package/README.md +2 -3
  2. package/README.zh-CN.md +1 -2
  3. package/dist/browser-ext/_locales/en/messages.json +0 -28
  4. package/dist/browser-ext/_locales/zh_CN/messages.json +0 -28
  5. package/dist/browser-ext/dist/assets/{sidepanel-CQeQB5vW.css → sidepanel-lpBGVKwZ.css} +0 -42
  6. package/dist/browser-ext/dist/background.js +247 -647
  7. package/dist/browser-ext/dist/sidepanel.html +2 -2
  8. package/dist/browser-ext/dist/sidepanel.js +105 -346
  9. package/dist/browser-ext/manifest.json +1 -1
  10. package/dist/extensions/telegram/src/plugin.js +1 -1
  11. package/dist/extensions/telegram/xopc.extension.json +1 -1
  12. package/dist/gateway/static/root/assets/{activity-store-t5c6XavH.js → activity-store-CuPXAoLe.js} +1 -1
  13. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CSTtf3RI.js → agent-avatar-dicebear-D92uHOFV.js} +1 -1
  14. package/dist/gateway/static/root/assets/{agent-avatar-display-Cm0afn_O.js → agent-avatar-display-DINzeGs0.js} +2 -2
  15. package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-BMbsLf16.js → agent-defaults-settings-panel-rH1QpgiR.js} +1 -1
  16. package/dist/gateway/static/root/assets/{agent-plugin-dialog-DofyWKnP.js → agent-plugin-dialog-B2vXlrDW.js} +1 -1
  17. package/dist/gateway/static/root/assets/{agents-admin-api-CewiIx4v.js → agents-admin-api-DPLtjJtX.js} +1 -1
  18. package/dist/gateway/static/root/assets/{agents-CAqwtADW.js → agents-lvQfOQPN.js} +3 -3
  19. package/dist/gateway/static/root/assets/{api-CE6gdBWx.js → api-CEzBruRJ.js} +1 -1
  20. package/dist/gateway/static/root/assets/{api-DRyQFk9q.js → api-snfMD8_Y.js} +1 -1
  21. package/dist/gateway/static/root/assets/app-link-CdD448kS.js +1 -0
  22. package/dist/gateway/static/root/assets/{app-management-settings-panel-BZfs2ydm.js → app-management-settings-panel-CONwDpqL.js} +1 -1
  23. package/dist/gateway/static/root/assets/{appearance-settings-BA7spRv6.js → appearance-settings-Bu7K-_ri.js} +1 -1
  24. package/dist/gateway/static/root/assets/{apps-page-B0qorxfq.js → apps-page-C3iDd3ZQ.js} +1 -1
  25. package/dist/gateway/static/root/assets/{archive-plugin-CPCI6nqQ.js → archive-plugin-CfLz9o-2.js} +1 -1
  26. package/dist/gateway/static/root/assets/{automation-api-paBg5ie6.js → automation-api-Dl9fi8t0.js} +1 -1
  27. package/dist/gateway/static/root/assets/{automation-result-state-Ds-59DdX.js → automation-result-state-BjjZCxee.js} +1 -1
  28. package/dist/gateway/static/root/assets/{automation-run-list-Crw5qn_I.js → automation-run-list-9IPHu_UC.js} +1 -1
  29. package/dist/gateway/static/root/assets/automation-task-card-CKbHMLSy.js +3 -0
  30. package/dist/gateway/static/root/assets/{automations-page-D3Cb5vfR.js → automations-page-BDHgk3CW.js} +1 -1
  31. package/dist/gateway/static/root/assets/automations-workspace-B7D9U89Z.js +9 -0
  32. package/dist/gateway/static/root/assets/{binary-plugins-CFJCUpWH.js → binary-plugins-Bv4ixxo4.js} +1 -1
  33. package/dist/gateway/static/root/assets/{block-editor-DbG2QKd0.js → block-editor-CtaJSB9U.js} +1 -1
  34. package/dist/gateway/static/root/assets/browser-settings-page-CmBsnx24.js +8 -0
  35. package/dist/gateway/static/root/assets/{capabilities-DG0ckPuF.js → capabilities-DDJJhQ40.js} +1 -1
  36. package/dist/gateway/static/root/assets/capabilities-DJYgOjeq.js +1 -0
  37. package/dist/gateway/static/root/assets/capabilities-page-CBqvHAyp.js +2 -0
  38. package/dist/gateway/static/root/assets/capabilities-settings-panel-wjezs0OE.js +8 -0
  39. package/dist/gateway/static/root/assets/capability-icon-CmvCZOJX.js +1 -0
  40. package/dist/gateway/static/root/assets/{capability-links-DeO34GIF.js → capability-links-MZdYfPKx.js} +1 -1
  41. package/dist/gateway/static/root/assets/{channels-OiT-5N_6.js → channels-D4q8hiD0.js} +1 -1
  42. package/dist/gateway/static/root/assets/{chat-agents-api-CTL8cwNk.js → chat-agents-api-BOB3dILf.js} +1 -1
  43. package/dist/gateway/static/root/assets/{chat-chart-block-Z41MRuzh.js → chat-chart-block-DsaCatBN.js} +1 -1
  44. package/dist/gateway/static/root/assets/chat-page-CAt7FyMT.js +72 -0
  45. package/dist/gateway/static/root/assets/{chat-terminal-dock-CEaFlZEs.js → chat-terminal-dock-D9o0nUEV.js} +1 -1
  46. package/dist/gateway/static/root/assets/{command-palette-api-C3G6veE2.js → command-palette-api-Cj0_7g9o.js} +1 -1
  47. package/dist/gateway/static/root/assets/{composer-payload-handoff-Ccq_KF1W.js → composer-payload-handoff-CoDWKzBm.js} +1 -1
  48. package/dist/gateway/static/root/assets/{computer-settings-page-CTkICYyM.js → computer-settings-page-DJ9BIOHC.js} +1 -1
  49. package/dist/gateway/static/root/assets/connected-providers-grid-C5-3MDIj.js +1 -0
  50. package/dist/gateway/static/root/assets/connection-usage-BhdQRWgQ.js +1 -0
  51. package/dist/gateway/static/root/assets/connection-usage-guide-bD1sKiAp.js +1 -0
  52. package/dist/gateway/static/root/assets/{connector-service-page-C6yeCQWW.js → connector-service-page-BEq3i3Vi.js} +1 -1
  53. package/dist/gateway/static/root/assets/{connectors-api-HFW1Iey5.js → connectors-api-DEExP6a7.js} +1 -1
  54. package/dist/gateway/static/root/assets/connectors-page-QVWuoxuK.js +1 -0
  55. package/dist/gateway/static/root/assets/constants-CsVXarqA.js +1 -0
  56. package/dist/gateway/static/root/assets/{date-picker-C_tweuM0.js → date-picker-D2whl8Ci.js} +1 -1
  57. package/dist/gateway/static/root/assets/{desktop-pet-narrative-ChwjpnsG.js → desktop-pet-narrative-C8zQtMcw.js} +1 -1
  58. package/dist/gateway/static/root/assets/{desktop-pet-BAX0ZLyq.js → desktop-pet-qnIdmNnH.js} +1 -1
  59. package/dist/gateway/static/root/assets/{desktop-pet-settings-BIIsWpW9.js → desktop-pet-settings-C54b1FY4.js} +1 -1
  60. package/dist/gateway/static/root/assets/{dev-view-store-D4C_zjRq.js → dev-view-store-bryv5YRw.js} +1 -1
  61. package/dist/gateway/static/root/assets/{device-pairing-wizard-ZUE6wZ1X.js → device-pairing-wizard-Du-yOxZv.js} +1 -1
  62. package/dist/gateway/static/root/assets/{directory-picker-path-field-CFb2VFW-.js → directory-picker-path-field-GsMkjw59.js} +1 -1
  63. package/dist/gateway/static/root/assets/{discussion-annotation-sync-Bd4r2auZ.js → discussion-annotation-sync-CrpDiC7J.js} +1 -1
  64. package/dist/gateway/static/root/assets/earth-C9Z4bTTG.js +1 -0
  65. package/dist/gateway/static/root/assets/{extension-debug-page-DXGpnxwM.js → extension-debug-page-CDZfdMAR.js} +1 -1
  66. package/dist/gateway/static/root/assets/{extension-iframe-host-DTwDBQQ9.js → extension-iframe-host-CG70QWPS.js} +1 -1
  67. package/dist/gateway/static/root/assets/{extension-marketplace-api-Q6E4x8gu.js → extension-marketplace-api-D7Av-sOf.js} +1 -1
  68. package/dist/gateway/static/root/assets/{extension-page-BVBxNzys.js → extension-page-DpJTL6-v.js} +1 -1
  69. package/dist/gateway/static/root/assets/{extension-provider-D-Fa5PU-.js → extension-provider-BZTbdvCF.js} +1 -1
  70. package/dist/gateway/static/root/assets/{extension-settings-page-ycMuOpv3.js → extension-settings-page-CC4rmiFC.js} +1 -1
  71. package/dist/gateway/static/root/assets/{file-preview-surface-D62ph0m0.js → file-preview-surface-Dtla5oAW.js} +1 -1
  72. package/dist/gateway/static/root/assets/{gateway-config-swr-BW6eBLIt.js → gateway-config-swr-B5THNdYK.js} +1 -1
  73. package/dist/gateway/static/root/assets/{gateway-realtime-Bg4Mf7HA.js → gateway-realtime-hnEaDFaA.js} +1 -1
  74. package/dist/gateway/static/root/assets/gateway-realtime-store-ugwtyD4q.js +1 -0
  75. package/dist/gateway/static/root/assets/{gateway-restart-BzrJNB4Q.js → gateway-restart-kwv0njYq.js} +1 -1
  76. package/dist/gateway/static/root/assets/{gateway-settings-BOW90CER.js → gateway-settings-CxYPJTy8.js} +1 -1
  77. package/dist/gateway/static/root/assets/{gateway-startup-retry-DCjREMIO.js → gateway-startup-retry-CqtCJzWJ.js} +1 -1
  78. package/dist/gateway/static/root/assets/{global-defaults-api-myAmGZ2_.js → global-defaults-api-BQMdHLlp.js} +1 -1
  79. package/dist/gateway/static/root/assets/{home-page-eXW3llb0.js → home-page-CpbsTucI.js} +2 -2
  80. package/dist/gateway/static/root/assets/{image-generation-api-CLkuZdsz.js → image-generation-api-G3tQFhif.js} +1 -1
  81. package/dist/gateway/static/root/assets/{imports-page-BFsLQu7n.js → imports-page-BmEqiunH.js} +1 -1
  82. package/dist/gateway/static/root/assets/index-CbhkKfcy.js +11 -0
  83. package/dist/gateway/static/root/assets/index-DE2bG5EI.css +1 -0
  84. package/dist/gateway/static/root/assets/{install-connector-dialog-CVjCFdly.js → install-connector-dialog-BU4l6KJv.js} +1 -1
  85. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DdZfxLQb.js → keyboard-shortcuts-settings-CtNI6i7K.js} +1 -1
  86. package/dist/gateway/static/root/assets/{local-app-workbench-page-xV9a7McI.js → local-app-workbench-page-CE46mHc0.js} +1 -1
  87. package/dist/gateway/static/root/assets/{local-apps-page-buwr_S_-.js → local-apps-page-DqZT5hLH.js} +1 -1
  88. package/dist/gateway/static/root/assets/{local-session-drafts-v7v7Hb6T.js → local-session-drafts-Bt_e3A8f.js} +1 -1
  89. package/dist/gateway/static/root/assets/{locale-store-DGtk-KSF.js → locale-store-Bld7_m-Q.js} +1 -1
  90. package/dist/gateway/static/root/assets/{logs-page-D_VBpYkM.js → logs-page-CzajqK40.js} +1 -1
  91. package/dist/gateway/static/root/assets/{management-settings-BlRCdUF3.js → management-settings-BgdAP0kf.js} +1 -1
  92. package/dist/gateway/static/root/assets/{markdown-view-JXJ3e1CB.js → markdown-view-B3cFKCfO.js} +1 -1
  93. package/dist/gateway/static/root/assets/markdown-view-DG8DDkEA.css +1 -0
  94. package/dist/gateway/static/root/assets/{mcp-conversation-setup-page-Vr2dpowU.js → mcp-conversation-setup-page-ZcY1nqMO.js} +1 -1
  95. package/dist/gateway/static/root/assets/{media-plugins-DcN8Y0hJ.js → media-plugins-DSOplRhW.js} +1 -1
  96. package/dist/gateway/static/root/assets/messages-CGO1P4mz.js +3 -0
  97. package/dist/gateway/static/root/assets/{model-selector-zD2x0Sn6.js → model-selector-yAKlOR3O.js} +1 -1
  98. package/dist/gateway/static/root/assets/{models-hub-cache-DtZG5bA_.js → models-hub-cache-8V-ZpAIa.js} +1 -1
  99. package/dist/gateway/static/root/assets/{note-detail-panel-CVrfF6XL.js → note-detail-panel-DWIWloib.js} +3 -3
  100. package/dist/gateway/static/root/assets/note-image-lightbox-BbNYW2Rw.js +1 -0
  101. package/dist/gateway/static/root/assets/notes-api-CVQqqmGI.js +1 -0
  102. package/dist/gateway/static/root/assets/{notes-page-BOCURwg6.js → notes-page-DIugUbkV.js} +3 -3
  103. package/dist/gateway/static/root/assets/{oauth-api-DYNQAQBx.js → oauth-api-DGa6PTuq.js} +1 -1
  104. package/dist/gateway/static/root/assets/{oauth-provider-connect-BvV6SP0k.js → oauth-provider-connect-Bc-KLH1e.js} +1 -1
  105. package/dist/gateway/static/root/assets/{page-context-capture-button-Dor5Y5Bf.js → page-context-capture-button-B9L7V_n2.js} +1 -1
  106. package/dist/gateway/static/root/assets/{page-context-draft-B8DQ5lNT.js → page-context-draft-GveHK8e2.js} +1 -1
  107. package/dist/gateway/static/root/assets/page-header-store-YZfSLNTg.js +1 -0
  108. package/dist/gateway/static/root/assets/palette-CDI0VweW.js +1 -0
  109. package/dist/gateway/static/root/assets/{personal-avatar-CF6T0aTT.js → personal-avatar-Cu8lGBXZ.js} +1 -1
  110. package/dist/gateway/static/root/assets/personal-page-Dah3dgRQ.js +1 -0
  111. package/dist/gateway/static/root/assets/{personal-settings-panel-BrQ94X_A.js → personal-settings-panel-awr10jTV.js} +1 -1
  112. package/dist/gateway/static/root/assets/{phone-dependencies-card-Zvbw-N0D.js → phone-dependencies-card-CAxn3usD.js} +1 -1
  113. package/dist/gateway/static/root/assets/{phone-model-connection-CQ4PhhE5.js → phone-model-connection-BBG3LxRP.js} +1 -1
  114. package/dist/gateway/static/root/assets/{phone-model-picker-BDBtemUm.js → phone-model-picker-CfPjKpnd.js} +1 -1
  115. package/dist/gateway/static/root/assets/{phone-settings-page-D2KXWcg1.js → phone-settings-page-C4dJdwRW.js} +1 -1
  116. package/dist/gateway/static/root/assets/{phone-workspace-store-BhJAeHdQ.js → phone-workspace-store-BKltFHtG.js} +1 -1
  117. package/dist/gateway/static/root/assets/{plugin-details-dialog-DpPtI0sI.js → plugin-details-dialog-BqcFfZFH.js} +1 -1
  118. package/dist/gateway/static/root/assets/{popover-select-CEMWIrtY.js → popover-select-CLsphyzA.js} +1 -1
  119. package/dist/gateway/static/root/assets/{preference-select-fields-Bx26yGRF.js → preference-select-fields-QlyIA8ve.js} +1 -1
  120. package/dist/gateway/static/root/assets/product-automation-feedback-CRsfuAXl.js +7 -0
  121. package/dist/gateway/static/root/assets/product-navigation-Dp-adLY_.js +1 -0
  122. package/dist/gateway/static/root/assets/{product-open-page-DSWELoz0.js → product-open-page-CQ4dk-_l.js} +1 -1
  123. package/dist/gateway/static/root/assets/{product-preview-content-DJb-OtMo.js → product-preview-content-CGbqoID0.js} +1 -1
  124. package/dist/gateway/static/root/assets/{product-preview-modal-DaQhXcev.js → product-preview-modal-0wvIDcVr.js} +2 -2
  125. package/dist/gateway/static/root/assets/{project-detail-page-BHLOHrat.js → project-detail-page-VPcXR1YD.js} +2 -2
  126. package/dist/gateway/static/root/assets/{project-understanding-CjhVk8l-.js → project-understanding-CU2af95r.js} +1 -1
  127. package/dist/gateway/static/root/assets/{projects-page-sVWDuzmC.js → projects-page-BsgZb6n9.js} +1 -1
  128. package/dist/gateway/static/root/assets/{providers-api-gWGsgOOf.js → providers-api-CspehmSU.js} +1 -1
  129. package/dist/gateway/static/root/assets/recording-upload-BOZAOdCI.js +1 -0
  130. package/dist/gateway/static/root/assets/{registry-api-CRxE9kFY.js → registry-api-Bdp3UUyz.js} +1 -1
  131. package/dist/gateway/static/root/assets/{remote-access-hub-Bw__qp-v.js → remote-access-hub-Bos3uwAT.js} +1 -1
  132. package/dist/gateway/static/root/assets/{resource-unavailable-BaczkGfK.js → resource-unavailable-DJR3SCy6.js} +1 -1
  133. package/dist/gateway/static/root/assets/route-preload-Blmi-1Iq.js +2 -0
  134. package/dist/gateway/static/root/assets/{runtime-tools-api-ygfM5FCT.js → runtime-tools-api-DsbahxzE.js} +1 -1
  135. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-BWEK7BZS.js → runtime-tools-settings-panel-DW9_OFi2.js} +1 -1
  136. package/dist/gateway/static/root/assets/{schema-form-C-jw6Hid.js → schema-form-CtRM41Re.js} +1 -1
  137. package/dist/gateway/static/root/assets/{service-recommendation-list-DrgwXSEt.js → service-recommendation-list-Bd1JDO5T.js} +1 -1
  138. package/dist/gateway/static/root/assets/{session-api-CpZ24vrQ.js → session-api-DjnHJ-0n.js} +1 -1
  139. package/dist/gateway/static/root/assets/{session-manager-CZyY5Y87.js → session-manager-ChHnJOWW.js} +1 -1
  140. package/dist/gateway/static/root/assets/{sessions-page-DgXRw0_8.js → sessions-page-BM-oqd22.js} +1 -1
  141. package/dist/gateway/static/root/assets/settings-advanced-gate-DyGT3o1e.js +1 -0
  142. package/dist/gateway/static/root/assets/{settings-advanced-section-DmCp3OWb.js → settings-advanced-section-CM44UlF8.js} +1 -1
  143. package/dist/gateway/static/root/assets/{settings-loading-skeleton-BTqvr_Fw.js → settings-loading-skeleton-CAoOV17i.js} +1 -1
  144. package/dist/gateway/static/root/assets/{settings-mode-store-fZ6mzf4A.js → settings-mode-store-Blc4C8aw.js} +1 -1
  145. package/dist/gateway/static/root/assets/{settings-page-SQwLKlTr.js → settings-page-CMSYmtOu.js} +1 -1
  146. package/dist/gateway/static/root/assets/{settings-page-header-4d1u-o-F.js → settings-page-header-BYFaTD8a.js} +1 -1
  147. package/dist/gateway/static/root/assets/{settings-page-layout-Cy9_VBag.js → settings-page-layout-CnUQSxT3.js} +1 -1
  148. package/dist/gateway/static/root/assets/{setup-interaction-page-OFU6DKgp.js → setup-interaction-page-DqaiLQ0I.js} +1 -1
  149. package/dist/gateway/static/root/assets/{setup-status-panel-KKAneNTe.js → setup-status-panel-iOYgfkoK.js} +1 -1
  150. package/dist/gateway/static/root/assets/{share-link-dialog-Apq3cegw.js → share-link-dialog-C_uYNUlp.js} +1 -1
  151. package/dist/gateway/static/root/assets/{share-preview-page-B6yMj5nG.js → share-preview-page-CFebGqyB.js} +1 -1
  152. package/dist/gateway/static/root/assets/{shares-api-Q5x_ty6F.js → shares-api-C2GDyqxP.js} +1 -1
  153. package/dist/gateway/static/root/assets/{shares-settings-vxTYg6Hp.js → shares-settings-B-7la3QN.js} +1 -1
  154. package/dist/gateway/static/root/assets/skeleton-DzdOeGYz.js +1 -0
  155. package/dist/gateway/static/root/assets/{skill-api-CBFXDh9m.js → skill-api-BnpTSZGc.js} +1 -1
  156. package/dist/gateway/static/root/assets/{skill-list-api-C8tm-XxH.js → skill-list-api-7MY9ewiu.js} +1 -1
  157. package/dist/gateway/static/root/assets/{skill-reload-api-B-4Yj46U.js → skill-reload-api-DkDpu3Wd.js} +1 -1
  158. package/dist/gateway/static/root/assets/skills-page-sL2kGqHZ.js +2 -0
  159. package/dist/gateway/static/root/assets/sliding-tab-list-CmcrqRzN.js +1 -0
  160. package/dist/gateway/static/root/assets/{system-settings-panel-a4mBz4J2.js → system-settings-panel-BltKPJdb.js} +1 -1
  161. package/dist/gateway/static/root/assets/task-detail-page-BuP1vEuu.js +3 -0
  162. package/dist/gateway/static/root/assets/{task-result-evidence-DFiu5SlL.js → task-result-evidence-B1MHhqVR.js} +1 -1
  163. package/dist/gateway/static/root/assets/{tasks-DRmd6sWt.js → tasks-D_xuHn6V.js} +1 -1
  164. package/dist/gateway/static/root/assets/{terminal-panel-store-BdOlpRkY.js → terminal-panel-store-DUEJoa1M.js} +1 -1
  165. package/dist/gateway/static/root/assets/{theme-store-D58tk8pq.js → theme-store-DsvYj7Vy.js} +1 -1
  166. package/dist/gateway/static/root/assets/tool-friendly-title-DEGpbye4.js +1 -0
  167. package/dist/gateway/static/root/assets/{tracing-settings-page-CO0-AiCl.js → tracing-settings-page-B_Xdc2VF.js} +1 -1
  168. package/dist/gateway/static/root/assets/{tunnel-api-DVRX9yW6.js → tunnel-api-B6BhWTh3.js} +1 -1
  169. package/dist/gateway/static/root/assets/{understanding-activity-store-B_-648uj.js → understanding-activity-store-B7rFXhDk.js} +1 -1
  170. package/dist/gateway/static/root/assets/{understanding-refresh-store-BXJ-kwzq.js → understanding-refresh-store-DCFASve5.js} +1 -1
  171. package/dist/gateway/static/root/assets/{usage-page-C76JnWR8.js → usage-page-DqzosTxy.js} +1 -1
  172. package/dist/gateway/static/root/assets/{use-autosave-xytwr7Lc.js → use-autosave-DsqcLHV9.js} +1 -1
  173. package/dist/gateway/static/root/assets/use-composer-attachments-Brdrrzrp.js +2 -0
  174. package/dist/gateway/static/root/assets/use-file-preview-expanded-9DED7ohY.js +2 -0
  175. package/dist/gateway/static/root/assets/{use-personal-profile-BXHU0P8I.js → use-personal-profile-T2e6P5Ed.js} +1 -1
  176. package/dist/gateway/static/root/assets/{use-workspace-tree-CiLbOQHQ.js → use-workspace-tree-Dq0qgK3N.js} +1 -1
  177. package/dist/gateway/static/root/assets/user-model-page-Ziz55hVM.js +2 -0
  178. package/dist/gateway/static/root/assets/{voice-api-key-field-Dn092u0X.js → voice-api-key-field-D7NPAc1E.js} +1 -1
  179. package/dist/gateway/static/root/assets/voice-call-context-CJ1ZiJWR.js +1 -0
  180. package/dist/gateway/static/root/assets/{voice-config-api-fqUzP-ZY.js → voice-config-api-UQDTh6hh.js} +1 -1
  181. package/dist/gateway/static/root/assets/{voice-input-shortcut-events-D7QdPeuj.js → voice-input-shortcut-events-SD2gZVg8.js} +1 -1
  182. package/dist/gateway/static/root/assets/{voice-transcribe-api-NpNY_gsE.js → voice-transcribe-api-Bf9FaI-p.js} +1 -1
  183. package/dist/gateway/static/root/assets/{work-discovery-overlay-BARpCMZl.js → work-discovery-overlay-B41GOFXh.js} +1 -1
  184. package/dist/gateway/static/root/assets/{work-discovery-page-p0aVb8xr.js → work-discovery-page-NNhExALx.js} +1 -1
  185. package/dist/gateway/static/root/assets/{working-directory-picker-modal-7G-6icvh.js → working-directory-picker-modal-DeNWVFFK.js} +1 -1
  186. package/dist/gateway/static/root/assets/{workspace-api-BKbezgv-.js → workspace-api-DrVss2Fd.js} +2 -2
  187. package/dist/gateway/static/root/assets/workspace-editor-agent-store-CmSYxTmk.js +1 -0
  188. package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-CS8-ZbVG.js → workspace-file-preview-dialog-C2egBzza.js} +1 -1
  189. package/dist/gateway/static/root/assets/{workspace-open-location-menu-BQrTy-8o.js → workspace-open-location-menu-XFUtwfLY.js} +1 -1
  190. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-Bc5rXL-E.js → xopc-cloud-account-card-BlhFT1q9.js} +1 -1
  191. package/dist/gateway/static/root/index.html +98 -101
  192. package/dist/package.js +1 -1
  193. package/dist/packages/browser-control-contract/src/dom.js +79 -0
  194. package/dist/packages/browser-control-contract/src/index.js +2 -25
  195. package/dist/packages/gateway-contract/src/automations.js +0 -6
  196. package/dist/packages/gateway-contract/src/task-research-result.js +1 -0
  197. package/dist/packages/gateway-contract/src/tasks.js +1 -1
  198. package/dist/src/agent/agent-manager.d.ts +0 -1
  199. package/dist/src/agent/agent-manager.js +0 -1
  200. package/dist/src/agent/embedded/execution-tool-policy.d.ts +1 -1
  201. package/dist/src/agent/embedded/execution-tool-policy.js +2 -1
  202. package/dist/src/agent/external-tools/index.d.ts +1 -1
  203. package/dist/src/agent/service.js +0 -1
  204. package/dist/src/agent/service.types.d.ts +0 -1
  205. package/dist/src/agent/tool-manuals/browser.d.ts +1 -1
  206. package/dist/src/agent/tool-manuals/browser.js +0 -3
  207. package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
  208. package/dist/src/agent/tool-manuals/xopc-use.js +3 -0
  209. package/dist/src/agent/tools/factory.d.ts +0 -2
  210. package/dist/src/agent/tools/factory.js +1 -2
  211. package/dist/src/agent/tools/find.d.ts +1 -1
  212. package/dist/src/agent/tools/grep.d.ts +1 -1
  213. package/dist/src/agent/tools/index.d.ts +0 -1
  214. package/dist/src/agent/tools/index.js +1 -2
  215. package/dist/src/agent/tools/metadata.d.ts +1 -1
  216. package/dist/src/agent/tools/personal-request-result-tool.js +2 -2
  217. package/dist/src/agent/tools/personal-request-tool.js +4 -1
  218. package/dist/src/agent/tools/personal-task-tool.d.ts +1 -0
  219. package/dist/src/agent/tools/personal-task-tool.js +4 -0
  220. package/dist/src/agent/tools/xopc-use-tool.js +10 -1
  221. package/dist/src/auth/oauth/anthropic.d.ts +1 -7
  222. package/dist/src/auth/oauth/anthropic.js +6 -83
  223. package/dist/src/auth/oauth/index.d.ts +0 -2
  224. package/dist/src/auth/oauth/index.js +2 -6
  225. package/dist/src/auth/oauth/kimi-coding.d.ts +1 -6
  226. package/dist/src/auth/oauth/kimi-coding.js +5 -79
  227. package/dist/src/auth/oauth/openai.js +1 -1
  228. package/dist/src/auth/oauth/pi-oauth-adapter.d.ts +4 -0
  229. package/dist/src/auth/oauth/pi-oauth-adapter.js +53 -0
  230. package/dist/src/auth/oauth/registry.js +0 -9
  231. package/dist/src/automations/capabilities/write.d.ts +6 -18
  232. package/dist/src/automations/domain/defaults.d.ts +0 -1
  233. package/dist/src/automations/domain/defaults.js +2 -3
  234. package/dist/src/automations/domain/index.js +2 -2
  235. package/dist/src/automations/domain/types.d.ts +0 -26
  236. package/dist/src/automations/domain/validation.d.ts +12 -36
  237. package/dist/src/automations/domain/validation.js +0 -7
  238. package/dist/src/automations/draft/automation-draft-validator.d.ts +1 -7
  239. package/dist/src/automations/draft/automation-draft-validator.js +0 -1
  240. package/dist/src/automations/index.js +2 -2
  241. package/dist/src/automations/service/action-executor.d.ts +0 -1
  242. package/dist/src/automations/service/action-executor.js +0 -31
  243. package/dist/src/automations/service/automation-service.d.ts +0 -1
  244. package/dist/src/automations/service/automation-service.js +1 -13
  245. package/dist/src/browser/drivers/playwright-driver.js +1 -2
  246. package/dist/src/channels/index.js +1 -1
  247. package/dist/src/channels/manager.js +1 -1
  248. package/dist/src/cli/commands/connectors.js +1 -1
  249. package/dist/src/cli/commands/extension-marketplace.js +1 -1
  250. package/dist/src/cli/commands/models.js +1 -1
  251. package/dist/src/cli/commands/onboard.js +1 -1
  252. package/dist/src/config/models-json.d.ts +24 -24
  253. package/dist/src/endpoint-tools/policy.js +3 -4
  254. package/dist/src/extensions/sdk/index.js +1 -1
  255. package/dist/src/gateway/hono/routes/lazy-bundles.js +0 -16
  256. package/dist/src/gateway/hono/routes/projects.js +1 -1
  257. package/dist/src/gateway/next-turn-suggestions/snapshot.js +11 -3
  258. package/dist/src/gateway/security/gateway-scopes.js +0 -2
  259. package/dist/src/gateway/service.d.ts +0 -3
  260. package/dist/src/gateway/service.js +2 -17
  261. package/dist/src/home-intelligence/application-service.js +1 -1
  262. package/dist/src/personal-agent/communication.d.ts +1 -1
  263. package/dist/src/personal-agent/communication.js +2 -2
  264. package/dist/src/personal-agent/prompts.js +1 -1
  265. package/dist/src/personal-agent/reply-style.d.ts +2 -2
  266. package/dist/src/personal-agent/reply-style.js +12 -0
  267. package/dist/src/personal-agent/request-delivery.js +1 -5
  268. package/dist/src/personal-agent/request-repository.d.ts +1 -0
  269. package/dist/src/personal-agent/request-service.d.ts +1 -0
  270. package/dist/src/personal-agent/request-service.js +12 -3
  271. package/dist/src/personal-agent/request-verification.d.ts +6 -0
  272. package/dist/src/personal-agent/request-verification.js +22 -0
  273. package/dist/src/providers/domestic-presets.d.ts +2 -310
  274. package/dist/src/providers/domestic-presets.js +2 -396
  275. package/dist/src/providers/env-keys.js +2 -6
  276. package/dist/src/providers/index.js +6 -13
  277. package/dist/src/providers/presentation.js +4 -6
  278. package/dist/src/providers/setup/profiles.js +1 -2
  279. package/dist/src/storage/sqlite/schema.sql +0 -81
  280. package/dist/src/tasks/home-query-service.js +0 -1
  281. package/dist/src/tasks/task-allocation-service.js +4 -2
  282. package/dist/src/tasks/task-application-service.js +4 -1
  283. package/dist/src/tasks/task-context-assembler.js +3 -1
  284. package/dist/src/tasks/task-contract-definition.d.ts +1 -0
  285. package/dist/src/tasks/task-contract-planner.js +3 -0
  286. package/dist/src/tasks/task-main-update-decision-service.js +7 -7
  287. package/dist/src/tasks/task-main-update-delivery.js +15 -2
  288. package/dist/src/tasks/task-repository.js +1 -1
  289. package/dist/src/tasks/task-research-repair.d.ts +1 -0
  290. package/dist/src/tasks/task-research-repair.js +3 -1
  291. package/dist/src/tasks/task-research-result.js +19 -1
  292. package/dist/src/tasks/task-run-coordinator.js +12 -9
  293. package/package.json +8 -8
  294. package/dist/gateway/static/root/assets/app-link-DRy3-k7j.js +0 -1
  295. package/dist/gateway/static/root/assets/arrow-up-right-T72JbQ1Q.js +0 -1
  296. package/dist/gateway/static/root/assets/automation-task-card-BecBULES.js +0 -3
  297. package/dist/gateway/static/root/assets/automations-workspace-BBSTBucV.js +0 -9
  298. package/dist/gateway/static/root/assets/book-open-CCGtrT3R.js +0 -1
  299. package/dist/gateway/static/root/assets/browser-automation-inputs-DADzEaqe.js +0 -1
  300. package/dist/gateway/static/root/assets/browser-automations-page-V7_ZTcyU.js +0 -3
  301. package/dist/gateway/static/root/assets/browser-control-api-Bdr2nGCE.js +0 -6
  302. package/dist/gateway/static/root/assets/browser-settings-page-irOt8KDh.js +0 -3
  303. package/dist/gateway/static/root/assets/capabilities-CrAs-oqU.js +0 -1
  304. package/dist/gateway/static/root/assets/capabilities-page-CJLVUcD4.js +0 -2
  305. package/dist/gateway/static/root/assets/capabilities-settings-panel-D8t5F998.js +0 -8
  306. package/dist/gateway/static/root/assets/capability-icon-DVoZxEgW.js +0 -1
  307. package/dist/gateway/static/root/assets/chat-page-DBAezT9u.js +0 -72
  308. package/dist/gateway/static/root/assets/connected-providers-grid-CpO98SqR.js +0 -1
  309. package/dist/gateway/static/root/assets/connection-usage-Cm_McddI.js +0 -1
  310. package/dist/gateway/static/root/assets/connection-usage-guide-DOf2VWzv.js +0 -1
  311. package/dist/gateway/static/root/assets/connectors-page-Cbn4LSpC.js +0 -1
  312. package/dist/gateway/static/root/assets/constants-DBtMsXdW.js +0 -1
  313. package/dist/gateway/static/root/assets/earth-BMhZtzcj.js +0 -1
  314. package/dist/gateway/static/root/assets/gateway-realtime-store-xYMxjztG.js +0 -1
  315. package/dist/gateway/static/root/assets/index-CKIirf4W.css +0 -1
  316. package/dist/gateway/static/root/assets/index-CQ570IAI.js +0 -11
  317. package/dist/gateway/static/root/assets/markdown-view-C-DHb3Io.css +0 -1
  318. package/dist/gateway/static/root/assets/messages-DYDySzn1.js +0 -3
  319. package/dist/gateway/static/root/assets/note-image-lightbox-V4rmgfLB.js +0 -1
  320. package/dist/gateway/static/root/assets/notes-api-UXC3eyeM.js +0 -1
  321. package/dist/gateway/static/root/assets/page-header-store-f8XcAs9b.js +0 -1
  322. package/dist/gateway/static/root/assets/personal-page-DUykELZZ.js +0 -1
  323. package/dist/gateway/static/root/assets/product-automation-feedback-_K6grEOt.js +0 -7
  324. package/dist/gateway/static/root/assets/product-navigation-Co8pLbDP.js +0 -1
  325. package/dist/gateway/static/root/assets/recording-upload-CBefH7C5.js +0 -1
  326. package/dist/gateway/static/root/assets/route-preload-Coy9Gjyy.js +0 -2
  327. package/dist/gateway/static/root/assets/settings-advanced-gate-Ch9MNvvk.js +0 -1
  328. package/dist/gateway/static/root/assets/skeleton-BI5TyibZ.js +0 -1
  329. package/dist/gateway/static/root/assets/skills-page-Xbnh0-6I.js +0 -2
  330. package/dist/gateway/static/root/assets/sliding-tab-list-DuQyViqe.js +0 -1
  331. package/dist/gateway/static/root/assets/star-BUWJqJ5c.js +0 -1
  332. package/dist/gateway/static/root/assets/task-detail-page-B9akf3i8.js +0 -3
  333. package/dist/gateway/static/root/assets/tool-friendly-title-DcCc6g7o.js +0 -1
  334. package/dist/gateway/static/root/assets/use-composer-attachments-fK2PUQbB.js +0 -2
  335. package/dist/gateway/static/root/assets/use-file-preview-expanded-ivMxmMu1.js +0 -2
  336. package/dist/gateway/static/root/assets/user-model-page-BzpV1hq_.js +0 -2
  337. package/dist/gateway/static/root/assets/video-B6V0GFss.js +0 -1
  338. package/dist/gateway/static/root/assets/voice-call-context-BM2A4bLz.js +0 -1
  339. package/dist/gateway/static/root/assets/workspace-editor-agent-store-CODAQqJn.js +0 -1
  340. package/dist/packages/browser-control-contract/src/automation.js +0 -213
  341. package/dist/src/agent/tools/browser-automation-tool.d.ts +0 -194
  342. package/dist/src/agent/tools/browser-automation-tool.js +0 -243
  343. package/dist/src/auth/oauth/minimax-cn.d.ts +0 -11
  344. package/dist/src/auth/oauth/minimax-cn.js +0 -95
  345. package/dist/src/auth/oauth/minimax.d.ts +0 -8
  346. package/dist/src/auth/oauth/minimax.js +0 -95
  347. package/dist/src/browser/automations/index.d.ts +0 -4
  348. package/dist/src/browser/automations/index.js +0 -4
  349. package/dist/src/browser/automations/repository.d.ts +0 -17
  350. package/dist/src/browser/automations/repository.js +0 -81
  351. package/dist/src/browser/automations/runner.d.ts +0 -17
  352. package/dist/src/browser/automations/runner.js +0 -265
  353. package/dist/src/browser/automations/runtime-service.d.ts +0 -8
  354. package/dist/src/browser/automations/runtime-service.js +0 -38
  355. package/dist/src/browser/automations/schema.d.ts +0 -227
  356. package/dist/src/browser/automations/schema.js +0 -201
  357. package/dist/src/browser/automations/service.d.ts +0 -232
  358. package/dist/src/browser/automations/service.js +0 -214
  359. package/dist/src/browser/automations/types.d.ts +0 -105
  360. package/dist/src/browser/automations/types.js +0 -1
  361. package/dist/src/browser/recordings/service.d.ts +0 -22
  362. package/dist/src/browser/recordings/service.js +0 -159
  363. package/dist/src/gateway/hono/routes/browser-automations.d.ts +0 -3
  364. package/dist/src/gateway/hono/routes/browser-automations.js +0 -93
  365. package/dist/src/gateway/hono/routes/browser-recordings.d.ts +0 -3
  366. package/dist/src/gateway/hono/routes/browser-recordings.js +0 -78
  367. package/dist/browser-ext/dist/assets/{page-context-DngcqfGf.js → auth-DAIwDtVp.js} +1368 -1368
@@ -0,0 +1,72 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mcp-conversation-setup-page-ZcY1nqMO.js","assets/rolldown-runtime-aKtaBQYM.js","assets/vendor-react-BOUWij0V.js","assets/chunk-KS7C4IRE-CiwuuyV8.js","assets/preload-helper-Czpn1I53.js","assets/locale-store-Bld7_m-Q.js","assets/messages-CGO1P4mz.js","assets/dist-BGTk37IG.js","assets/es2015-DBLcMg5B.js","assets/dist-CxGUk8J-.js","assets/check-DUBLcKHA.js","assets/createLucideIcon-DPHK1VkS.js","assets/secret-input-Dryrns2s.js","assets/circle-check-C23XjkUj.js","assets/copy-Dv6d4Dvw.js","assets/eye-CABVeTq0.js","assets/loader-circle-CifKLtgG.js","assets/cn-0WouolD0.js","assets/bundle-mjs-rHxsej31.js","assets/copy-to-clipboard-HOJ79TWv.js","assets/interaction-BdhHBbYa.js","assets/form-field-width-DJw_jULe.js","assets/is-masked-secret-DOkL5b_X.js","assets/key-round-DWbpyU2U.js","assets/link-2-D_ZKYUW7.js","assets/lock-keyhole-DEK5kH0u.js","assets/x-B_N4OPjy.js","assets/skeleton-DzdOeGYz.js","assets/vendor-swr-CdRzEUwF.js","assets/button-Cc4hUNTt.js","assets/chat-terminal-dock-D9o0nUEV.js","assets/plus-Q2yW6OE7.js","assets/square-terminal-K87bylpZ.js","assets/session-api-DjnHJ-0n.js","assets/schemas-CCWMleym.js","assets/gateway-startup-retry-CqtCJzWJ.js","assets/session-manager-ChHnJOWW.js","assets/constants-CsVXarqA.js","assets/local-session-drafts-Bt_e3A8f.js","assets/tool-activity-BtJkgjFf.js","assets/personal-proactivity-DaRnbB1f.js","assets/attachment-utils-core-BIOUBrpT.js","assets/gateway-realtime-hnEaDFaA.js","assets/gateway-realtime-store-ugwtyD4q.js","assets/registry-api-Bdp3UUyz.js","assets/agents-admin-api-DPLtjJtX.js","assets/gateway-config-swr-B5THNdYK.js","assets/sliding-tab-list-CmcrqRzN.js","assets/sliding-indicator-hwz0sx3h.js","assets/terminal-panel-store-DUEJoa1M.js","assets/chat-terminal-dock-uQUnjRtf.css"])))=>i.map(i=>d[i]);
2
+ import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,i as r,n as i,t as a}from"./vendor-react-BOUWij0V.js";import{t as o}from"./preload-helper-Czpn1I53.js";import{f as s,l as c,m as l,t as u,u as d}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{a as f,i as p,l as m,n as h,o as g,p as _,u as v}from"./locale-store-Bld7_m-Q.js";import{t as y}from"./messages-CGO1P4mz.js";import{a as b,c as x,i as S,n as C,o as w,r as T,s as E,t as D}from"./dist-BGTk37IG.js";import{t as O}from"./createLucideIcon-DPHK1VkS.js";import{t as k}from"./app-window-DXFNqt_0.js";import{t as A}from"./archive-Dz0hferG.js";import{t as j}from"./arrow-left-D880xG-P.js";import{n as M,r as N}from"./voice-call-context-CJ1ZiJWR.js";import{t as P}from"./arrow-up-D5ZtR1QT.js";import{a as F,c as I,d as L,f as R,l as z,s as B,t as V,u as H}from"./product-automation-feedback-CRsfuAXl.js";import{n as U,t as W}from"./earth-C9Z4bTTG.js";import{t as G}from"./bot-DjLkhyZL.js";import{t as ee}from"./check-DUBLcKHA.js";import{t as te}from"./chevron-down-ccbiQQz_.js";import{t as ne}from"./chevron-right-BweFrslA.js";import{i as re,r as ie,t as ae}from"./working-directory-picker-modal-DeNWVFFK.js";import{a as K,d as oe,n as se,o as q,r as ce,t as le}from"./popover-select-CLsphyzA.js";import{t as ue}from"./circle-alert-BEjgurr2.js";import{i as de,r as fe,t as J}from"./new-chat-navigation-B6NPQ4h4.js";import{t as pe}from"./circle-x-DFsCKeya.js";import{t as me}from"./circle-BoO4YvTx.js";import{i as he,n as ge,r as _e,t as ve}from"./file-tree-utils-DJs1faGv.js";import{t as ye}from"./copy-Dv6d4Dvw.js";import{t as be}from"./database-CjjeZfRG.js";import{t as xe}from"./ellipsis-0k4rZLoy.js";import{t as Se}from"./external-link-DjqjBmc3.js";import{n as Ce,t as we}from"./file-BqMS_3DT.js";import{t as Te}from"./file-image-CDUPkZvG.js";import{t as Ee}from"./file-text-D12HbeVy.js";import{t as De}from"./folder-kanban-CpLlFI1o.js";import{t as Oe}from"./folder-open-CyzJ19I9.js";import{t as ke}from"./folder-CN-pC3XL.js";import{i as Ae,r as je,u as Me,x as Ne}from"./use-file-preview-expanded-9DED7ohY.js";import{t as Pe}from"./git-branch-Dh9uxTot.js";import{t as Fe}from"./globe-DSSGFWFn.js";import{t as Ie}from"./history-DXH_9jsE.js";import{F as Le,L as Re,P as ze,c as Be,g as Ve,o as He,t as Ue,v as We}from"./notes-api-CVQqqmGI.js";import{t as Ge}from"./key-round-DWbpyU2U.js";import{t as Ke}from"./laptop-CI3hBVrl.js";import{t as qe}from"./link-2-D_ZKYUW7.js";import{t as Je}from"./list-checks-BbsExAoq.js";import{t as Ye}from"./list-todo-CTVRto8O.js";import{t as Xe}from"./loader-circle-CifKLtgG.js";import{A as Ze,B as Qe,C as $e,D as et,F as tt,P as nt,R as rt,S as it,T as at,_ as ot,b as st,c as ct,d as lt,f as ut,g as dt,h as ft,l as pt,m as mt,n as ht,p as gt,r as _t,u as vt,v as yt,w as bt,y as xt}from"./markdown-view-B3cFKCfO.js";import{t as St}from"./messages-square-BckAJrEW.js";import{t as Ct}from"./mic-CuUb7zc-.js";import{t as wt}from"./monitor-Af5eAvF7.js";import{s as Tt,t as Et}from"./install-connector-dialog-BU4l6KJv.js";import{t as Dt}from"./paperclip-f1HujQY1.js";import{t as Ot}from"./pause-DuPxgSxk.js";import{t as kt}from"./pencil-DmIY3Oa-.js";import{t as At}from"./play-kxZvpBg8.js";import{t as jt}from"./plus-Q2yW6OE7.js";import{t as Mt}from"./refresh-cw-BRlGaq2w.js";import{t as Nt}from"./rotate-ccw-JM1TBLpp.js";import{t as Pt}from"./save-DRDABU--.js";import{t as Ft}from"./search-DA7gz22f.js";import{t as It}from"./settings-2-D-csvaET.js";import{t as Lt}from"./settings-uiTATseT.js";import{t as Rt}from"./shield-check-BU58siTV.js";import{t as zt}from"./smartphone-DSSsQFqA.js";import{t as Bt}from"./sparkles-DHlfQFAF.js";import{t as Vt}from"./square-DMK_fB-3.js";import{t as Ht}from"./trash-2-DusmjVPV.js";import{t as Ut}from"./triangle-alert-2JXFNNKU.js";import{r as Wt,t as Gt}from"./share-link-dialog-C_uYNUlp.js";import{t as Kt}from"./wrench-DFb4r8bH.js";import{t as qt}from"./x-B_N4OPjy.js";import{t as Jt}from"./zap-dximCGjy.js";import{t as Y}from"./cn-0WouolD0.js";import{t as Yt}from"./skeleton-DzdOeGYz.js";import{a as Xt,d as Zt,m as Qt,n as $t,u as en}from"./schemas-CCWMleym.js";import{t as tn}from"./tasks-D_xuHn6V.js";import{i as nn,n as rn,o as an,s as on,t as sn}from"./product-delivery-DRyD9_Xq.js";import{a as cn}from"./local-apps-Ck6kACsY.js";import{a as ln,c as un,d as dn}from"./api-snfMD8_Y.js";import{a as fn,s as pn}from"./session-api-DjnHJ-0n.js";import{$ as mn,A as hn,B as gn,C as _n,D as vn,E as yn,F as bn,G as xn,H as Sn,I as Cn,J as wn,L as Tn,M as En,N as Dn,O as On,P as kn,Q as An,R as jn,S as Mn,T as Nn,U as Pn,V as Fn,W as In,X as Ln,Y as Rn,Z as zn,_ as Bn,_t as Vn,at as Hn,b as Un,bt as Wn,c as Gn,d as Kn,et as qn,ft as Jn,g as Yn,gt as Xn,h as Zn,ht as Qn,it as $n,j as er,k as tr,l as nr,lt as rr,m as ir,mt as ar,nt as or,o as sr,ot as cr,pt as lr,q as ur,r as dr,st as fr,t as pr,tt as mr,u as hr,ut as gr,v as _r,vt as vr,w as yr,x as br,xt as xr,y as Sr,yt as Cr,z as wr}from"./session-manager-ChHnJOWW.js";import{a as Tr,d as Er,m as Dr,n as Or,o as kr,p as Ar,s as jr,t as Mr,u as Nr}from"./local-session-drafts-Bt_e3A8f.js";import{t as Pr}from"./tool-activity-BtJkgjFf.js";import{a as Fr,c as Ir,i as Lr,l as Rr,n as zr,o as Br,r as Vr,s as Hr,t as Ur}from"./new-session-preferences-gb411vZP.js";import{a as Wr}from"./extension-provider-BZTbdvCF.js";import{n as Gr}from"./personal-proactivity-DaRnbB1f.js";import{i as Kr}from"./vendor-swr-CdRzEUwF.js";import{c as qr,h as Jr,i as Yr,n as Xr,o as Zr,r as Qr,s as $r,t as ei,v as ti}from"./use-composer-attachments-Brdrrzrp.js";import{a as ni}from"./gateway-config-swr-B5THNdYK.js";import{t as ri}from"./chat-agents-api-BOB3dILf.js";import{a as ii,c as ai,i as oi,r as si,s as ci}from"./attachment-utils-core-BIOUBrpT.js";import{n as li}from"./gateway-realtime-hnEaDFaA.js";import{n as ui}from"./gateway-realtime-store-ugwtyD4q.js";import{n as di,t as fi}from"./registry-api-Bdp3UUyz.js";import{a as pi}from"./agents-admin-api-DPLtjJtX.js";import{t as mi}from"./button-Cc4hUNTt.js";import{s as hi}from"./file-preview-surface-Dtla5oAW.js";import{a as gi,i as _i,o as vi,r as yi,s as bi}from"./dist-GJ8-1PAx.js";import{t as xi}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as Si}from"./middleware-Pd0e8Igk.js";import{i as Ci,r as wi}from"./app-link-CdD448kS.js";import{t as Ti}from"./copy-to-clipboard-HOJ79TWv.js";import{a as Ei,c as Di,d as Oi,f as ki,g as Ai,i as ji,m as Mi,n as Ni,o as Pi,p as Fi,r as Ii,s as Li}from"./composer-payload-handoff-CoDWKzBm.js";import{C as Ri,D as zi,E as Bi,T as Vi,_ as Hi,b as Ui,c as Wi,d as Gi,f as Ki,g as qi,h as Ji,m as Yi,n as Xi,o as Zi,p as Qi,r as $i,s as ea,u as ta,v as na,w as ra,x as ia,y as aa}from"./chunk-D32TOXHM-DQIy-Baq.js";import{i as oa,n as sa,r as ca,t as la}from"./chat-chart-block-DsaCatBN.js";import{n as ua}from"./interaction-BdhHBbYa.js";import{i as da,n as fa,r as pa,t as ma}from"./tool-friendly-title-DEGpbye4.js";import{s as ha}from"./connectors-api-DEExP6a7.js";import{t as ga}from"./activity-store-CuPXAoLe.js";import{r as _a}from"./app-chrome-BeB4KgOf.js";import{i as va,n as ya,r as ba}from"./form-field-width-DJw_jULe.js";import{n as xa}from"./electron-env-DHOGevH3.js";import{t as Sa}from"./page-header-store-YZfSLNTg.js";import{t as Ca}from"./use-async-resource-BHFGZCY2.js";import{t as wa}from"./loopi-CNtmi9FU.js";import{t as Ta}from"./agent-avatar-display-DINzeGs0.js";import{n as Ea}from"./index.module-Cd9ENXfk.js";import{a as Da,n as Oa,r as ka,t as Aa}from"./skill-wire-pattern-BPpeIcCi.js";import{n as ja,t as Ma}from"./use-directory-picker-C4p7AgWY.js";import{t as Na}from"./confirm-dialog-D7dQJytv.js";import{a as Pa,c as Fa,f as Ia,l as La,s as Ra,u as za}from"./workspace-api-DrVss2Fd.js";import{a as Ba,i as Va,o as Ha,r as Ua,s as Wa}from"./copy-text-row-CpiRzq4G.js";import{_ as Ga,b as Ka,d as qa,f as Ja,h as Ya,i as Xa,n as Za,p as Qa,s as $a,u as eo,y as to}from"./shares-api-C2GDyqxP.js";import{t as no}from"./workspace-editor-agent-store-CmSYxTmk.js";import{l as ro,m as io,o as ao,r as oo,t as so,u as co}from"./dist-ZrL34Ps4.js";import{a as lo,c as uo,d as fo,f as po,h as mo,i as ho,l as go,m as _o,p as vo,s as yo,t as bo,u as xo}from"./command-palette-api-Cj0_7g9o.js";import{r as So,t as Co}from"./model-selector-yAKlOR3O.js";import{n as wo,o as To,r as Eo,s as Do}from"./voice-input-shortcut-events-SD2gZVg8.js";import{D as Oo,E as ko,O as Ao,i as jo,k as Mo,t as No}from"./automation-task-card-CKbHMLSy.js";import{t as Po}from"./dev-view-store-bryv5YRw.js";import{t as Fo}from"./extension-iframe-host-CG70QWPS.js";import{i as Io,r as Lo}from"./api-CEzBruRJ.js";import{r as Ro,t as zo}from"./runtime-health-D2TDFLLq.js";import{r as Bo}from"./terminal-panel-store-DUEJoa1M.js";import{n as Vo}from"./agents-app-path-ciChvpCS.js";import{n as Ho,t as Uo}from"./agent-display-names-Bje7vfSn.js";import{t as Wo}from"./oauth-provider-connect-Bc-KLH1e.js";import{t as Go}from"./use-media-query-ady-FgjK.js";import{n as Ko,r as qo,t as Jo}from"./oauth-authorization-window-o6URRos4.js";import{n as Yo,t as Xo}from"./page-context-draft-GveHK8e2.js";import{t as Zo}from"./side-chat-shortcut-BIw-1TTD.js";var Qo=O(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),$o=O(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),es=O(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),ts=O(`corner-down-right`,[[`path`,{d:`m15 10 5 5-5 5`,key:`qqa56n`}],[`path`,{d:`M4 4v7a4 4 0 0 0 4 4h12`,key:`z08zvw`}]]),ns=O(`file-headphone`,[[`path`,{d:`M4 6.835V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-.343`,key:`1vfytu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M2 19a2 2 0 0 1 4 0v1a2 2 0 0 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 0 1-4 0v-1a2 2 0 0 1 4 0`,key:`1etmh7`}]]),rs=O(`file-pen-line`,[[`path`,{d:`M14.364 13.634a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506l4.013-4.009a1 1 0 0 0-3.004-3.004z`,key:`ukzhwg`}],[`path`,{d:`M14.487 7.858A1 1 0 0 1 14 7V2`,key:`1klhew`}],[`path`,{d:`M20 19.645V20a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l2.516 2.516`,key:`rxaxab`}],[`path`,{d:`M8 18h1`,key:`13wk12`}]]),is=O(`file-plus-corner`,[[`path`,{d:`M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35`,key:`17jvcc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M14 19h6`,key:`bvotb8`}],[`path`,{d:`M17 16v6`,key:`18yu1i`}]]),as=O(`files`,[[`path`,{d:`M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8`,key:`14sh0y`}],[`path`,{d:`M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z`,key:`1970lx`}],[`path`,{d:`M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1`,key:`l4dndm`}]]),os=O(`git-commit-horizontal`,[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]]),ss=O(`git-fork`,[[`circle`,{cx:`12`,cy:`18`,r:`3`,key:`1mpf1b`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`path`,{d:`M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9`,key:`1uq4wg`}],[`path`,{d:`M12 12v3`,key:`158kv8`}]]),cs=O(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),ls=O(`layout-template`,[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`9`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`jqznyg`}],[`rect`,{width:`5`,height:`7`,x:`16`,y:`14`,rx:`1`,key:`q5h2i8`}]]),us=O(`message-circle-more`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}]]),ds=O(`message-circle-plus`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]]),fs=O(`message-square-share`,[[`path`,{d:`M12 3H4a2 2 0 0 0-2 2v16.286a.71.71 0 0 0 1.212.502l2.202-2.202A2 2 0 0 1 6.828 19H20a2 2 0 0 0 2-2v-4`,key:`11da1y`}],[`path`,{d:`M16 3h6v6`,key:`1bx56c`}],[`path`,{d:`m16 9 6-6`,key:`m4dnic`}]]),ps=O(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),ms=O(`notebook-pen`,[[`path`,{d:`M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4`,key:`re6nr2`}],[`path`,{d:`M2 6h4`,key:`aawbzj`}],[`path`,{d:`M2 10h4`,key:`l0bgd4`}],[`path`,{d:`M2 14h4`,key:`1gsvsf`}],[`path`,{d:`M2 18h4`,key:`1bu2t1`}],[`path`,{d:`M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`pqwjuv`}]]),hs=O(`shuffle`,[[`path`,{d:`m18 14 4 4-4 4`,key:`10pe0f`}],[`path`,{d:`m18 2 4 4-4 4`,key:`pucp1d`}],[`path`,{d:`M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22`,key:`1ailkh`}],[`path`,{d:`M2 6h1.972a4 4 0 0 1 3.6 2.2`,key:`km57vx`}],[`path`,{d:`M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45`,key:`os18l9`}]]),gs=O(`square-plus`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]]),_s=O(`target`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),vs=O(`wallet`,[[`path`,{d:`M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1`,key:`18etb6`}],[`path`,{d:`M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4`,key:`xoc0q4`}]]);function ys(e,t){return e.replace(/\{\{(\w+)}}/g,(e,n)=>t[n]?.trim()??``).replace(/[ \t]{2,}/g,` `).trim()}function bs(e,t,n){return{id:e,title:ys(t.title,n),prompt:ys(t.prompt,n),reason:ys(t.reason,n)}}function xs(e,t){let n={projectName:e.projectName,blockedReason:e.blockedReason,recentFailure:e.recentFailure,nextAction:e.recommendedAction};if(e.blockedReason?.trim())return bs(`project-blocked`,t.recommendations.projectBlocked,n);if(e.recentFailure?.trim())return bs(`project-failure`,t.recommendations.projectFailure,n);if(e.recommendedAction?.trim())return bs(`project-next-action`,t.recommendations.projectNextAction,n)}function Ss(e,t){let n={taskTitle:e.taskTitle,attentionSummary:e.attentionSummary,recentFailure:e.recentFailure,nextAction:e.nextAction};if(e.attentionSummary?.trim())return bs(`task-attention`,t.recommendations.taskAttention,n);if(e.recentFailure?.trim())return bs(`task-failure`,t.recommendations.taskFailure,n);if(e.phase===`review`||e.operationalState===`verifying`)return bs(`task-review`,t.recommendations.taskReview,n);if(e.phase===`closed`)return bs(`task-closed`,t.recommendations.taskClosed,n);if(e.nextAction?.trim())return bs(`task-next-action`,t.recommendations.taskNextAction,n)}function Cs(e,t){switch(e.kind){case`project`:return xs(e,t);case`task`:return Ss(e,t);default:return}}function ws(e,t,n={}){let r=n.contextStatus??`ready`;return{headline:e.kind===`project`&&t.projectHeadline?ys(t.projectHeadline,{projectName:e.projectName}):t.headline,contextKind:e.kind,contextStatus:r,recommendation:r===`ready`?Cs(e,t):void 0}}var Ts=Zt({id:Qt().uuid(),conversationId:Qt(),transcriptId:Qt(),sourceRunId:Qt(),inputRevision:en().int().nonnegative(),transcriptCursor:en().int().nonnegative(),agentId:Qt(),locale:$t([`zh`,`en`]),prompt:Qt().min(1).max(160),expiresAt:en()}),Es=Zt({status:$t([`ready`,`pending`,`none`]),suggestion:Ts.optional()});Zt({suggestionId:Qt().uuid(),impressionId:Qt().uuid(),event:$t([`shown`,`accepted`,`dismissed`,`submitted`]),edited:Xt().optional()}).strict();function Ds(e,t,n){for(let r of[n,t])if(e.options.includes(r))return r;return e.initialValue}function Os(e,t=`body`){return`result:${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function ks(e){return`${e.taskRunId}:${e.assignmentEpoch}:${e.outcome.outcomeId}`}var As=e(r(),1),X=i(),Z=a(),Q=e(n(),1);function js(e,t){return e?[`task-detail`,e,t??``]:null}function Ms(e,t){return t.source!==`user`||e===void 0||t.version>e}function Ns(e){let t=m(e=>e.conversationId),[n,r]=(0,Q.useState)(null),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(null),c=(0,Q.useRef)(``),l=(0,Q.useRef)(void 0),u=Kr(js(e,t),()=>ti(e),{keepPreviousData:!1,revalidateOnFocus:!0,revalidateOnReconnect:!0,refreshInterval:e=>e&&[`allocating`,`queued`,`running`,`waiting`,`verifying`].includes(e.operationalState)?5e3:0});return l.current=u.data?.task.version,(0,Q.useEffect)(()=>{r(null),a(!1),s(null),c.current=``},[e]),(0,Q.useEffect)(()=>{let t=u.data;if(!t||t.conversation.activeConversationId||t.allocation&&t.allocation.status!==`assigned`)return;let n=`${e}:${t.task.version}`;c.current!==n&&(c.current=n,a(!0),s(null),Jr(e).then(()=>c.current===n?u.mutate():void 0).catch(e=>{c.current===n&&s(e)}).finally(()=>{c.current===n&&a(!1)}))},[u.data,u.mutate,e]),(0,Q.useEffect)(()=>{let t,n=()=>{window.clearTimeout(t),t=window.setTimeout(()=>void u.mutate(),120)},i=t=>{let i=tn.safeParse(t.detail);!i.success||i.data.taskId!==e||Ms(l.current,i.data)&&(r(i.data),n())},a=()=>n();return window.addEventListener(`task-changed-v2`,i),window.addEventListener(`gateway-realtime-connected`,a),window.addEventListener(`realtime-gap`,a),()=>{window.clearTimeout(t),window.removeEventListener(`task-changed-v2`,i),window.removeEventListener(`gateway-realtime-connected`,a),window.removeEventListener(`realtime-gap`,a)}},[u.mutate,e]),{...u,lastChange:n,conversationLoading:i,conversationError:o}}var Ps=new Map,Fs=new Set;function Is(e,t){Ps.set(e,t);for(let e of Fs)e();return()=>{Ps.get(e)===t&&Ps.delete(e)}}async function Ls(e,t,n){await(Ps.get(e)??await new Promise((t,n)=>{let r=()=>{let n=Ps.get(e);n&&(clearTimeout(i),Fs.delete(r),t(n))},i=setTimeout(()=>{Fs.delete(r),n(Error(`Chat input is not ready. Please retry.`))},15e3);Fs.add(r),r()}))(t,n)}var Rs=crypto.randomUUID(),zs=e=>e===`closed`;function Bs(e,t){let n=e,r=n?.code??n?.body?.error?.code,i={PHONE_HDC_VIDEO_DEPENDENCY:`鸿蒙投屏库或 JDK 不兼容,请在添加手机的投屏工具路径中检查 HOScrcpy JAR 和 JDK。`,PHONE_HDC_VIDEO_TIMEOUT:`鸿蒙投屏启动超时,已回退截图。请检查 USB 连接和投屏工具。`,PHONE_HDC_VIDEO_FAILED:`鸿蒙投屏暂不可用,已回退截图。请检查 USB 连接和投屏库兼容性。`,PHONE_VIDEO_BUSY:`手机已有原生调试或投屏连接,请关闭该连接后重试视频。`,PHONE_CONTROL_BUSY:`另一设备正在操作手机,请等待其结束控制。`,PHONE_DEVICE_BUSY:`手机正被其他聊天或人工操作占用,本次操作尚未开始。请查看当前任务,等待或明确停止后再试。`,PHONE_OBSERVE_ONLY:`此入口仅支持查看手机画面,请在来源聊天中操作或接管手机。`,PHONE_CONTROL_CHANGED:`手机控制权已变化,本次操作未继续。请查看最新状态后重新接管。`,PHONE_CONTROL_REQUIRED:`当前窗口没有手机操作权,请先接管手机。`,PHONE_CONTROL_STALE:`手机控制状态已更新,请等待状态刷新后再操作。`,PHONE_DISPATCH_UNKNOWN:`上一条手机输入的结果尚未确认,请先检查手机,避免重复执行。`,PHONE_FRAME_STALE:`手机画面已变化,请等待新画面后再操作。`,PHONE_APP_DENIED:`当前页面不在授权应用范围内,请返回授权应用。`,PHONE_SESSION_NOT_FOUND:`手机连接或来源聊天已变化,请刷新手机面板。`,PHONE_PAUSED:`手机任务已暂停,请检查手机状态并明确交回控制权后继续。`,PHONE_DEVICE_OFFLINE:`手机暂未连接,任务进度已保留。请连接手机后重试。`,PHONE_BINDING_CHANGED:`手机或 Agent 设置已变化,任务进度已保留。请检查设备和模型设置后重试。`,PHONE_ASSISTANCE_CHANGED:`待接管任务已更新,请刷新状态后操作。`};return t&&r&&i[r]?i[r]:n?.message??(t?`无法完成手机操作,请检查连接状态。`:`Phone operation failed. Check the connection.`)}var Vs=e=>`/api/phone/conversations/${encodeURIComponent(e)}`,Hs=new Map,Us=()=>{let e=m.getState();return`${e.baseUrl}:${e.conversationId}`};function Ws(e,t,n=Us()){let r=`${n}:${e}`,i=Hs.get(r);return t&&i&&t.report.sessionId===i.report.sessionId&&(t.report.revision??0)<(i.report.revision??0)?i:(t?(Hs.set(r,t),Hs.size>100&&Hs.delete(Hs.keys().next().value)):Hs.delete(r),t)}async function Gs(e,t=Us()){let n=await f(p(e)),r=decodeURIComponent(e.split(`/conversations/`)[1]?.split(`?`)[0]??``);if(n.status===404)return Ws(r,null,t);if((n.status===401||n.status===403)&&Ws(r,null,t),!n.ok)throw Object.assign(Error(`Phone view unavailable (HTTP ${n.status})`),{status:n.status});return Ws(r,(await n.json()).payload,t)}function Ks(e,t){let n=(0,X.c)(5),r=t===void 0||t,i=m(Ys),a;n[0]!==e||n[1]!==r||n[2]!==i?(a=r&&/^(?:device:)?[\da-f]{8}-[\da-f-]{27}$/i.test(e)?[`${Vs(e)}?clientId=${Rs}`,i]:null,n[0]=e,n[1]=r,n[2]=i,n[3]=a):a=n[3];let o;return n[4]===Symbol.for(`react.memo_cache_sentinel`)?(o={refreshInterval:1200,revalidateOnFocus:!0,shouldRetryOnError:qs,errorRetryCount:6,errorRetryInterval:2e3,refreshWhenHidden:!1},n[4]=o):o=n[4],Kr(a,Js,o)}function qs(e){return e.status!==401&&e.status!==403}function Js(e){let[t,n]=e;return Gs(t,n)}function Ys(e){return`${e.baseUrl}:${e.conversationId}`}async function Xs(e,t,n,r={},i=!1){let a=Us();return Ws(e,(await g(p(`${Vs(e)}/${t.report.sessionId}/control`),{method:`POST`,keepalive:i,body:JSON.stringify({expectedTranscriptId:t.report.transcriptId,clientId:Rs,assistanceId:t.report.assistanceId,assistanceVersion:t.report.assistanceVersion,operationId:crypto.randomUUID(),epoch:t.report.controlEpoch,op:n,...r})})).payload,a)}async function Zs(e,t,n){let r=await f(p(`${Vs(e)}/${t}/frame`),{signal:n});if(!r.ok){let e=await r.json().catch(()=>({}));throw Object.assign(Error(e.error?.message??`HTTP ${r.status}`),{status:r.status,code:e.error?.code})}return{blob:await r.blob(),seq:Number(r.headers.get(`X-Phone-Frame-Seq`)),capturedAt:Number(r.headers.get(`X-Phone-Captured-At`)),width:Number(r.headers.get(`X-Phone-Width`)),height:Number(r.headers.get(`X-Phone-Height`))}}function Qs(e,t,n,r,i){let a=Math.min(e.width/t,e.height/n),o=t*a,s=n*a,c=r-e.left-(e.width-o)/2,l=i-e.top-(e.height-s)/2;return!a||c<0||l<0||c>o||l>s?null:[Math.round(c/o*1e3),Math.round(l/s*1e3)]}async function $s(e,t,n,r=!1){return(await g(p(`${Vs(e)}/${t.report.sessionId}/execution-mode`),{method:`POST`,body:JSON.stringify({executionMode:n,applyCurrent:r,epoch:t.report.controlEpoch,clientId:Rs})})).payload}function ec(e,t){if(!t.assistanceId||![`needs_user`,`paused`].includes(t.status))return null;let n=m.getState();return JSON.stringify([n.baseUrl,n.conversationId,e,t.transcriptId,t.assistanceId,t.assistanceVersion??1])}var tc=_(Si(e=>({seen:[],markSeen:t=>e(e=>e.seen.includes(t)?e:{seen:[...e.seen.slice(-99),t]})}),{name:`xopc-phone-attention-v1`}));function nc(e){let t=(0,X.c)(15),{detail:n,language:r}=e,i;t[0]===n?i=t[1]:(i=Ai(n),t[0]=n,t[1]=i);let a=i,o=r===`zh`,s=a.receipt?.status===`failed`?o?`最近一轮执行失败`:`Latest run failed`:a.receipt?.status===`cancelled`?o?`最近一轮执行已取消`:`Latest run canceled`:a.receipt?o?`最近一轮执行已结束`:`Latest run ended`:o?`尚无本版任务的执行结果`:`No run result for this task version`,c=o?`执行、验收与交付`:`Execution, acceptance and delivery`,l=n.task.phase===`closed`?``:o?`;任务仍未关闭`:`; task remains open`,u;t[2]!==s||t[3]!==l?(u=(0,Z.jsxs)(`p`,{children:[s,l]}),t[2]=s,t[3]=l,t[4]=u):u=t[4];let d=o?`验收:${a.verified}/${a.criteria} 项通过`:`Acceptance: ${a.verified}/${a.criteria} criteria passed`,f=a.criteria===0?o?`,尚未定义验收标准`:`; criteria not defined`:``,p;t[5]!==d||t[6]!==f?(p=(0,Z.jsxs)(`p`,{children:[d,f]}),t[5]=d,t[6]=f,t[7]=p):p=t[7];let m=a.deliverables>0?o?`已关联交付物:${a.deliverables} 项`:`Linked deliverables: ${a.deliverables}`:o?`尚无正式交付物`:`No formal deliverables linked`,h;t[8]===m?h=t[9]:(h=(0,Z.jsx)(`p`,{children:m}),t[8]=m,t[9]=h);let g;return t[10]!==c||t[11]!==u||t[12]!==p||t[13]!==h?(g=(0,Z.jsxs)(`div`,{className:`mt-3 space-y-1 border-t border-edge-subtle pt-3 text-xs leading-5 text-fg-muted`,"aria-label":c,children:[u,p,h]}),t[10]=c,t[11]=u,t[12]=p,t[13]=h,t[14]=g):g=t[14],g}var rc=(0,Q.memo)(function(e){let t=(0,X.c)(58),{taskId:n}=e,r=c(),i=h(ic),a;t[0]===i?a=t[1]:(a=Oi(i),t[0]=i,t[1]=a);let o=a,{data:s}=Ns(n);if(!s)return null;let{task:l,operationalState:d}=s,f,p,m,g;if(t[2]!==o.noDecisionNeeded||t[3]!==s||t[4]!==d||t[5]!==l.phase){let e=ki(s);m=s.attention.length>0;let n;t[10]!==d||t[11]!==l.phase?(n=l.phase!==`closed`&&[`queued`,`running`,`verifying`].includes(d),t[10]=d,t[11]=l.phase,t[12]=n):n=t[12],p=n,f=m?s.attention[0]?.summary??e?.nextAction??e?.summary:l.phase===`closed`?e?.summary:e?.nextAction??e?.summary??o.noDecisionNeeded,g=e?.evidence.filter(ac).length??0,t[2]=o.noDecisionNeeded,t[3]=s,t[4]=d,t[5]=l.phase,t[6]=f,t[7]=p,t[8]=m,t[9]=g}else f=t[6],p=t[7],m=t[8],g=t[9];let _=g,v=o.taskProgress.title,y;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(_s,{className:`size-4`,"aria-hidden":!0}),t[13]=y):y=t[13];let b;t[14]===p?b=t[15]:(b=p?(0,Z.jsx)(`span`,{className:`absolute -right-0.5 -top-0.5 size-2.5 rounded-full border-2 border-surface-panel bg-accent motion-safe:animate-pulse`}):null,t[14]=p,t[15]=b);let x;t[16]===b?x=t[17]:(x=(0,Z.jsxs)(`span`,{className:`relative mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-full bg-accent-soft text-accent-fg`,children:[y,b]}),t[16]=b,t[17]=x);let S;t[18]===o.taskProgress.title?S=t[19]:(S=(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:o.taskProgress.title}),t[18]=o.taskProgress.title,t[19]=S);let C;t[20]===s?C=t[21]:(C=Y(`rounded-full border px-1.5 py-0.5 text-[10px] font-medium`,Mi(Fi(s))),t[20]=s,t[21]=C);let w=o.detailStatuses[Fi(s)],T;t[22]!==C||t[23]!==w?(T=(0,Z.jsx)(`span`,{className:C,children:w}),t[22]=C,t[23]=w,t[24]=T):T=t[24];let E;t[25]!==o.taskProgress.evidence||t[26]!==_?(E=_>0?(0,Z.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[_,` `,o.taskProgress.evidence]}):null,t[25]=o.taskProgress.evidence,t[26]=_,t[27]=E):E=t[27];let D;t[28]!==T||t[29]!==E||t[30]!==S?(D=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[S,T,E]}),t[28]=T,t[29]=E,t[30]=S,t[31]=D):D=t[31];let O;t[32]===l.title?O=t[33]:(O=(0,Z.jsx)(`p`,{className:`mt-1 text-sm font-medium leading-5 text-fg`,children:l.title}),t[32]=l.title,t[33]=O);let k;t[34]===f?k=t[35]:(k=f?(0,Z.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:f}):null,t[34]=f,t[35]=k);let A;t[36]!==D||t[37]!==O||t[38]!==k?(A=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[D,O,k]}),t[36]=D,t[37]=O,t[38]=k,t[39]=A):A=t[39];let j=`${r.pathname}${r.search}`,M;t[40]!==j||t[41]!==l.id?(M=tt(j,l.id),t[40]=j,t[41]=l.id,t[42]=M):M=t[42];let N=m?o.taskProgress.decide:o.taskProgress.open,P;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Z.jsx)(Se,{className:`size-3.5`,"aria-hidden":!0}),t[43]=P):P=t[43];let F;t[44]!==M||t[45]!==N?(F=(0,Z.jsxs)(u,{to:M,className:`inline-flex shrink-0 items-center gap-1 rounded-md px-2 py-1.5 text-xs font-medium text-accent hover:bg-accent-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[N,P]}),t[44]=M,t[45]=N,t[46]=F):F=t[46];let I;t[47]!==A||t[48]!==F||t[49]!==x?(I=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[x,A,F]}),t[47]=A,t[48]=F,t[49]=x,t[50]=I):I=t[50];let L;t[51]!==s||t[52]!==i?(L=(0,Z.jsx)(nc,{detail:s,language:i}),t[51]=s,t[52]=i,t[53]=L):L=t[53];let R;return t[54]!==o.taskProgress.title||t[55]!==I||t[56]!==L?(R=(0,Z.jsxs)(`section`,{className:`mb-6 rounded-xl border border-edge bg-surface-panel px-3 py-3 sm:px-4`,"aria-label":v,"aria-live":`polite`,children:[I,L]}),t[54]=o.taskProgress.title,t[55]=I,t[56]=L,t[57]=R):R=t[57],R});function ic(e){return e.language}function ac(e){return e.strength===`verified`}function oc(e){return e===-5||e===-4||e===-3?`
3
+ `:e<0?` `:String.fromCharCode(e)}var sc={partial:!0,tokenize(e,t,n){let r=this;return i=>i===null?t(i):(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),e=>r.parser.lazy[r.now().line]?n(e):t(e))}};function cc(e){return function(t,n,r){let i=this,a=``,o=!1,s=!1,c=!1,l=e?`xopcMathFlow`:`xopcMathInline`;return u;function u(e){return t.enter(l),f(e)}function d(i){return(e?it(a):$e(a))?(c&&t.exit(`xopcMathValue`),t.exit(l),n(i)):r(i)}function f(n){if(n===null)return d(n);let l=oc(n);if(l===`
4
+ `)return e&&i.interrupt||!e||o?d(n):(c&&t.exit(`xopcMathValue`),c=!1,t.attempt(sc,e=>(a+=`
5
+ `,s=!1,f(e)),e=>d(e))(n));if(o){if(!e)return/\d/.test(l)&&a.startsWith(`$`)?r(n):d(n);if(l!==` `&&l!==` `)return r(n)}if(c||=(t.enter(`xopcMathValue`),!0),t.consume(n),a+=l,l===`
6
+ `&&(s=!1),l===`%`&&!xt(a,a.length-1)&&(s=!0),a.length===1&&l===`\\`)return f;if(a.length===2&&a.startsWith(`\\`)&&a!==(e?`\\[`:`\\(`)||!e&&a.startsWith(`$$`)||e&&a.startsWith(`$`)&&a.length===2&&a!==`$$`)return r;let u=a.startsWith(`\\`)?e?`\\]`:`\\)`:e?`$$`:`$`,p=u.length;return o=!s&&a.length>=p*2&&a.endsWith(u)&&!xt(a,a.length-p),f}}}var lc={name:`xopcMathInline`,tokenize:cc(!1)},uc={name:`xopcMathFlow`,tokenize:cc(!0),concrete:!0},dc={text:{92:lc,36:lc},flow:{92:uc,36:uc}};function fc(e){return{hName:`code`,hProperties:{className:[e.display?`math-display`:`math-inline`],"data-xopc-math-source":yt(e)},hChildren:[{type:`text`,value:e.raw}]}}var pc={enter:{xopcMathInline(e){this.enter({type:`inlineCode`,value:``},e)},xopcMathFlow(e){this.enter({type:`code`,value:``},e)}},exit:{xopcMathInline(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-1],r=$e(t);Object.assign(n,{value:t,data:fc(r)}),this.exit(e)},xopcMathFlow(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-1],r=it(t);Object.assign(n,{value:t,data:fc(r)}),this.exit(e)}}};function mc(){let e=this.data();return(e.micromarkExtensions??=[]).push(dc),(e.fromMarkdownExtensions??=[]).push(pc),(e,t)=>{function n(e){if(e.type===`code`&&e.lang===`math`){let n=e.value??``,r=String(t.value).slice(e.position?.start.offset,e.position?.end.offset);e.data=fc(bt(r)??st(r,n))}for(let t of e.children??[])n(t)}n(e)}}var hc=new Map,gc=0;function _c(e){if(!/\\[([]|\$|^\s*```math/m.test(e))return[];let t=hc.get(e);if(t)return t;let n=Ri(e,{extensions:[dc],mdastExtensions:[pc]}),r=[];function i(e){if(!(e.type===`image`||e.type===`html`)){if(e.data?.hProperties||e.type===`code`&&e.lang===`math`){let t=e.position?.start.offset,n=e.position?.end.offset;t!==void 0&&n!==void 0&&r.push({start:t,end:n})}for(let t of e.children??[])i(t)}}if(i(n),e.length<=262144){for(;hc.size>=256||gc+e.length>1048576;){let e=hc.keys().next().value;gc-=e.length,hc.delete(e)}hc.set(e,r),gc+=e.length}return r}var vc={abandonedHeadElementChild:{reason:`Unexpected metadata element after head`,description:"Unexpected element after head. Expected the element before `</head>`",url:!1},abruptClosingOfEmptyComment:{reason:`Unexpected abruptly closed empty comment`,description:"Unexpected `>` or `->`. Expected `-->` to close comments"},abruptDoctypePublicIdentifier:{reason:`Unexpected abruptly closed public identifier`,description:"Unexpected `>`. Expected a closing `\"` or `'` after the public identifier"},abruptDoctypeSystemIdentifier:{reason:`Unexpected abruptly closed system identifier`,description:"Unexpected `>`. Expected a closing `\"` or `'` after the identifier identifier"},absenceOfDigitsInNumericCharacterReference:{reason:`Unexpected non-digit at start of numeric character reference`,description:"Unexpected `%c`. Expected `[0-9]` for decimal references or `[0-9a-fA-F]` for hexadecimal references"},cdataInHtmlContent:{reason:`Unexpected CDATA section in HTML`,description:"Unexpected `<![CDATA[` in HTML. Remove it, use a comment, or encode special characters instead"},characterReferenceOutsideUnicodeRange:{reason:`Unexpected too big numeric character reference`,description:`Unexpectedly high character reference. Expected character references to be at most hexadecimal 10ffff (or decimal 1114111)`},closingOfElementWithOpenChildElements:{reason:`Unexpected closing tag with open child elements`,description:`Unexpectedly closing tag. Expected other tags to be closed first`,url:!1},controlCharacterInInputStream:{reason:`Unexpected control character`,description:"Unexpected control character `%x`. Expected a non-control code point, 0x00, or ASCII whitespace"},controlCharacterReference:{reason:`Unexpected control character reference`,description:`Unexpectedly control character in reference. Expected a non-control code point, 0x00, or ASCII whitespace`},disallowedContentInNoscriptInHead:{reason:"Disallowed content inside `<noscript>` in `<head>`",description:"Unexpected text character `%c`. Only use text in `<noscript>`s in `<body>`",url:!1},duplicateAttribute:{reason:`Unexpected duplicate attribute`,description:`Unexpectedly double attribute. Expected attributes to occur only once`},endTagWithAttributes:{reason:`Unexpected attribute on closing tag`,description:"Unexpected attribute. Expected `>` instead"},endTagWithTrailingSolidus:{reason:`Unexpected slash at end of closing tag`,description:"Unexpected `%c-1`. Expected `>` instead"},endTagWithoutMatchingOpenElement:{reason:`Unexpected unopened end tag`,description:`Unexpected end tag. Expected no end tag or another end tag`,url:!1},eofBeforeTagName:{reason:`Unexpected end of file`,description:`Unexpected end of file. Expected tag name instead`},eofInCdata:{reason:`Unexpected end of file in CDATA`,description:"Unexpected end of file. Expected `]]>` to close the CDATA"},eofInComment:{reason:`Unexpected end of file in comment`,description:"Unexpected end of file. Expected `-->` to close the comment"},eofInDoctype:{reason:`Unexpected end of file in doctype`,description:"Unexpected end of file. Expected a valid doctype (such as `<!doctype html>`)"},eofInElementThatCanContainOnlyText:{reason:`Unexpected end of file in element that can only contain text`,description:`Unexpected end of file. Expected text or a closing tag`,url:!1},eofInScriptHtmlCommentLikeText:{reason:`Unexpected end of file in comment inside script`,description:"Unexpected end of file. Expected `-->` to close the comment"},eofInTag:{reason:`Unexpected end of file in tag`,description:"Unexpected end of file. Expected `>` to close the tag"},incorrectlyClosedComment:{reason:`Incorrectly closed comment`,description:"Unexpected `%c-1`. Expected `-->` to close the comment"},incorrectlyOpenedComment:{reason:`Incorrectly opened comment`,description:"Unexpected `%c`. Expected `<!--` to open the comment"},invalidCharacterSequenceAfterDoctypeName:{reason:`Invalid sequence after doctype name`,description:"Unexpected sequence at `%c`. Expected `public` or `system`"},invalidFirstCharacterOfTagName:{reason:`Invalid first character in tag name`,description:"Unexpected `%c`. Expected an ASCII letter instead"},misplacedDoctype:{reason:`Misplaced doctype`,description:`Unexpected doctype. Expected doctype before head`,url:!1},misplacedStartTagForHeadElement:{reason:"Misplaced `<head>` start tag",description:"Unexpected start tag `<head>`. Expected `<head>` directly after doctype",url:!1},missingAttributeValue:{reason:`Missing attribute value`,description:"Unexpected `%c-1`. Expected an attribute value or no `%c-1` instead"},missingDoctype:{reason:`Missing doctype before other content`,description:"Expected a `<!doctype html>` before anything else",url:!1},missingDoctypeName:{reason:`Missing doctype name`,description:"Unexpected doctype end at `%c`. Expected `html` instead"},missingDoctypePublicIdentifier:{reason:`Missing public identifier in doctype`,description:"Unexpected `%c`. Expected identifier for `public` instead"},missingDoctypeSystemIdentifier:{reason:`Missing system identifier in doctype`,description:'Unexpected `%c`. Expected identifier for `system` instead (suggested: `"about:legacy-compat"`)'},missingEndTagName:{reason:`Missing name in end tag`,description:"Unexpected `%c`. Expected an ASCII letter instead"},missingQuoteBeforeDoctypePublicIdentifier:{reason:`Missing quote before public identifier in doctype`,description:"Unexpected `%c`. Expected `\"` or `'` instead"},missingQuoteBeforeDoctypeSystemIdentifier:{reason:`Missing quote before system identifier in doctype`,description:"Unexpected `%c`. Expected `\"` or `'` instead"},missingSemicolonAfterCharacterReference:{reason:`Missing semicolon after character reference`,description:"Unexpected `%c`. Expected `;` instead"},missingWhitespaceAfterDoctypePublicKeyword:{reason:`Missing whitespace after public identifier in doctype`,description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceAfterDoctypeSystemKeyword:{reason:`Missing whitespace after system identifier in doctype`,description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceBeforeDoctypeName:{reason:`Missing whitespace before doctype name`,description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceBetweenAttributes:{reason:`Missing whitespace between attributes`,description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers:{reason:`Missing whitespace between public and system identifiers in doctype`,description:"Unexpected `%c`. Expected ASCII whitespace instead"},nestedComment:{reason:`Unexpected nested comment`,description:"Unexpected `<!--`. Expected `-->`"},nestedNoscriptInHead:{reason:"Unexpected nested `<noscript>` in `<head>`",description:"Unexpected `<noscript>`. Expected a closing tag or a meta element",url:!1},nonConformingDoctype:{reason:`Unexpected non-conforming doctype declaration`,description:'Expected `<!doctype html>` or `<!doctype html system "about:legacy-compat">`',url:!1},nonVoidHtmlElementStartTagWithTrailingSolidus:{reason:`Unexpected trailing slash on start tag of non-void element`,description:"Unexpected `/`. Expected `>` instead"},noncharacterCharacterReference:{reason:`Unexpected noncharacter code point referenced by character reference`,description:`Unexpected code point. Do not use noncharacters in HTML`},noncharacterInInputStream:{reason:`Unexpected noncharacter character`,description:"Unexpected code point `%x`. Do not use noncharacters in HTML"},nullCharacterReference:{reason:`Unexpected NULL character referenced by character reference`,description:`Unexpected code point. Do not use NULL characters in HTML`},openElementsLeftAfterEof:{reason:`Unexpected end of file`,description:`Unexpected end of file. Expected closing tag instead`,url:!1},surrogateCharacterReference:{reason:`Unexpected surrogate character referenced by character reference`,description:`Unexpected code point. Do not use lone surrogate characters in HTML`},surrogateInInputStream:{reason:`Unexpected surrogate character`,description:"Unexpected code point `%x`. Do not use lone surrogate characters in HTML"},unexpectedCharacterAfterDoctypeSystemIdentifier:{reason:`Invalid character after system identifier in doctype`,description:"Unexpected character at `%c`. Expected `>`"},unexpectedCharacterInAttributeName:{reason:`Unexpected character in attribute name`,description:"Unexpected `%c`. Expected whitespace, `/`, `>`, `=`, or probably an ASCII letter"},unexpectedCharacterInUnquotedAttributeValue:{reason:`Unexpected character in unquoted attribute value`,description:"Unexpected `%c`. Quote the attribute value to include it"},unexpectedEqualsSignBeforeAttributeName:{reason:`Unexpected equals sign before attribute name`,description:"Unexpected `%c`. Add an attribute name before it"},unexpectedNullCharacter:{reason:`Unexpected NULL character`,description:"Unexpected code point `%x`. Do not use NULL characters in HTML"},unexpectedQuestionMarkInsteadOfTagName:{reason:`Unexpected question mark instead of tag name`,description:"Unexpected `%c`. Expected an ASCII letter instead"},unexpectedSolidusInTag:{reason:`Unexpected slash in tag`,description:"Unexpected `%c-1`. Expected it followed by `>` or in a quoted attribute value"},unknownNamedCharacterReference:{reason:`Unexpected unknown named character reference`,description:`Unexpected character reference. Expected known named character references`}},yc=`https://html.spec.whatwg.org/multipage/parsing.html#parse-error-`,bc=/-[a-z]/g,xc=/%c(?:([-+])(\d+))?/g,Sc=/%x/g,Cc={2:!0,1:!1,0:null},wc={};function Tc(e,t){let n=t||wc,r=n.onerror,i=e instanceof Hi?e:new Hi(e),a=n.fragment?Ui:aa,o=String(i);return ia(a(o,{sourceCodeLocationInfo:!0,onParseError:n.onerror?s:null,scriptingEnabled:!1}),{file:i,space:n.space,verbose:n.verbose});function s(e){let t=e.code,a=Ec(t),s=n[a]??!0,c=typeof s==`number`?s:+!!s;if(c){let n=vc[a],o=new na(l(n.reason),{place:{start:{line:e.startLine,column:e.startCol,offset:e.startOffset},end:{line:e.endLine,column:e.endCol,offset:e.endOffset}},ruleId:t,source:`hast-util-from-html`});i.path&&(o.file=i.path,o.name=i.path+`:`+o.name),o.fatal=Cc[c],o.note=l(n.description),o.url=n.url===!1?void 0:yc+t,r(o)}function l(t){return t.replace(xc,n).replace(Sc,r);function n(t,n,r){let i=(r?Number.parseInt(r,10):0)*(n===`-`?-1:1);return Oc(o.charAt(e.startOffset+i))}function r(){return kc(o.charCodeAt(e.startOffset))}}}}function Ec(e){return e.replace(bc,Dc)}function Dc(e){return e.charAt(1).toUpperCase()}function Oc(e){return e==="`"?"` ` `":e}function kc(e){return`0x`+e.toString(16).toUpperCase()}function Ac(e={streaming:!1}){return t=>{let n=0;qi(t,`element`,(t,r)=>{if(t.tagName!==`code`||typeof t.properties[`data-xopc-math-source`]!=`string`)return;let i=ot(t.properties[`data-xopc-math-source`]);if(!i)return;let a=Tc(_t(i,e,++n>(e.maxCount??256)),{fragment:!0}).children[0],o=r.at(-1),s=r.at(-2);if(!(!o||!a))return o.type===`element`&&o.tagName===`pre`&&s?s.children.splice(s.children.indexOf(o),1,a):o.children.splice(o.children.indexOf(t),1,a),Ji})}}var jc={carriageReturn:-5,lineFeed:-4,carriageReturnLineFeed:-3,horizontalTab:-2,virtualSpace:-1,eof:null,nul:0,soh:1,stx:2,etx:3,eot:4,enq:5,ack:6,bel:7,bs:8,ht:9,lf:10,vt:11,ff:12,cr:13,so:14,si:15,dle:16,dc1:17,dc2:18,dc3:19,dc4:20,nak:21,syn:22,etb:23,can:24,em:25,sub:26,esc:27,fs:28,gs:29,rs:30,us:31,space:32,exclamationMark:33,quotationMark:34,numberSign:35,dollarSign:36,percentSign:37,ampersand:38,apostrophe:39,leftParenthesis:40,rightParenthesis:41,asterisk:42,plusSign:43,comma:44,dash:45,dot:46,slash:47,digit0:48,digit1:49,digit2:50,digit3:51,digit4:52,digit5:53,digit6:54,digit7:55,digit8:56,digit9:57,colon:58,semicolon:59,lessThan:60,equalsTo:61,greaterThan:62,questionMark:63,atSign:64,uppercaseA:65,uppercaseB:66,uppercaseC:67,uppercaseD:68,uppercaseE:69,uppercaseF:70,uppercaseG:71,uppercaseH:72,uppercaseI:73,uppercaseJ:74,uppercaseK:75,uppercaseL:76,uppercaseM:77,uppercaseN:78,uppercaseO:79,uppercaseP:80,uppercaseQ:81,uppercaseR:82,uppercaseS:83,uppercaseT:84,uppercaseU:85,uppercaseV:86,uppercaseW:87,uppercaseX:88,uppercaseY:89,uppercaseZ:90,leftSquareBracket:91,backslash:92,rightSquareBracket:93,caret:94,underscore:95,graveAccent:96,lowercaseA:97,lowercaseB:98,lowercaseC:99,lowercaseD:100,lowercaseE:101,lowercaseF:102,lowercaseG:103,lowercaseH:104,lowercaseI:105,lowercaseJ:106,lowercaseK:107,lowercaseL:108,lowercaseM:109,lowercaseN:110,lowercaseO:111,lowercaseP:112,lowercaseQ:113,lowercaseR:114,lowercaseS:115,lowercaseT:116,lowercaseU:117,lowercaseV:118,lowercaseW:119,lowercaseX:120,lowercaseY:121,lowercaseZ:122,leftCurlyBrace:123,verticalBar:124,rightCurlyBrace:125,tilde:126,del:127,byteOrderMarker:65279,replacementCharacter:65533},Mc={attentionSideAfter:2,attentionSideBefore:1,atxHeadingOpeningFenceSizeMax:6,autolinkDomainSizeMax:63,autolinkSchemeSizeMax:32,cdataOpeningString:`CDATA[`,characterGroupPunctuation:2,characterGroupWhitespace:1,characterReferenceDecimalSizeMax:7,characterReferenceHexadecimalSizeMax:6,characterReferenceNamedSizeMax:31,codeFencedSequenceSizeMin:3,contentTypeContent:`content`,contentTypeDocument:`document`,contentTypeFlow:`flow`,contentTypeString:`string`,contentTypeText:`text`,hardBreakPrefixSizeMin:2,htmlBasic:6,htmlCdata:5,htmlComment:2,htmlComplete:7,htmlDeclaration:4,htmlInstruction:3,htmlRawSizeMax:8,htmlRaw:1,linkResourceDestinationBalanceMax:32,linkReferenceSizeMax:999,listItemValueSizeMax:10,numericBaseDecimal:10,numericBaseHexadecimal:16,tabSize:4,thematicBreakMarkerCountMin:3,v8MaxSafeChunkSize:1e4},Nc={data:`data`,whitespace:`whitespace`,lineEnding:`lineEnding`,lineEndingBlank:`lineEndingBlank`,linePrefix:`linePrefix`,lineSuffix:`lineSuffix`,atxHeading:`atxHeading`,atxHeadingSequence:`atxHeadingSequence`,atxHeadingText:`atxHeadingText`,autolink:`autolink`,autolinkEmail:`autolinkEmail`,autolinkMarker:`autolinkMarker`,autolinkProtocol:`autolinkProtocol`,characterEscape:`characterEscape`,characterEscapeValue:`characterEscapeValue`,characterReference:`characterReference`,characterReferenceMarker:`characterReferenceMarker`,characterReferenceMarkerNumeric:`characterReferenceMarkerNumeric`,characterReferenceMarkerHexadecimal:`characterReferenceMarkerHexadecimal`,characterReferenceValue:`characterReferenceValue`,codeFenced:`codeFenced`,codeFencedFence:`codeFencedFence`,codeFencedFenceSequence:`codeFencedFenceSequence`,codeFencedFenceInfo:`codeFencedFenceInfo`,codeFencedFenceMeta:`codeFencedFenceMeta`,codeFlowValue:`codeFlowValue`,codeIndented:`codeIndented`,codeText:`codeText`,codeTextData:`codeTextData`,codeTextPadding:`codeTextPadding`,codeTextSequence:`codeTextSequence`,content:`content`,definition:`definition`,definitionDestination:`definitionDestination`,definitionDestinationLiteral:`definitionDestinationLiteral`,definitionDestinationLiteralMarker:`definitionDestinationLiteralMarker`,definitionDestinationRaw:`definitionDestinationRaw`,definitionDestinationString:`definitionDestinationString`,definitionLabel:`definitionLabel`,definitionLabelMarker:`definitionLabelMarker`,definitionLabelString:`definitionLabelString`,definitionMarker:`definitionMarker`,definitionTitle:`definitionTitle`,definitionTitleMarker:`definitionTitleMarker`,definitionTitleString:`definitionTitleString`,emphasis:`emphasis`,emphasisSequence:`emphasisSequence`,emphasisText:`emphasisText`,escapeMarker:`escapeMarker`,hardBreakEscape:`hardBreakEscape`,hardBreakTrailing:`hardBreakTrailing`,htmlFlow:`htmlFlow`,htmlFlowData:`htmlFlowData`,htmlText:`htmlText`,htmlTextData:`htmlTextData`,image:`image`,label:`label`,labelText:`labelText`,labelLink:`labelLink`,labelImage:`labelImage`,labelMarker:`labelMarker`,labelImageMarker:`labelImageMarker`,labelEnd:`labelEnd`,link:`link`,paragraph:`paragraph`,reference:`reference`,referenceMarker:`referenceMarker`,referenceString:`referenceString`,resource:`resource`,resourceDestination:`resourceDestination`,resourceDestinationLiteral:`resourceDestinationLiteral`,resourceDestinationLiteralMarker:`resourceDestinationLiteralMarker`,resourceDestinationRaw:`resourceDestinationRaw`,resourceDestinationString:`resourceDestinationString`,resourceMarker:`resourceMarker`,resourceTitle:`resourceTitle`,resourceTitleMarker:`resourceTitleMarker`,resourceTitleString:`resourceTitleString`,setextHeading:`setextHeading`,setextHeadingText:`setextHeadingText`,setextHeadingLine:`setextHeadingLine`,setextHeadingLineSequence:`setextHeadingLineSequence`,strong:`strong`,strongSequence:`strongSequence`,strongText:`strongText`,thematicBreak:`thematicBreak`,thematicBreakSequence:`thematicBreakSequence`,blockQuote:`blockQuote`,blockQuotePrefix:`blockQuotePrefix`,blockQuoteMarker:`blockQuoteMarker`,blockQuotePrefixWhitespace:`blockQuotePrefixWhitespace`,listOrdered:`listOrdered`,listUnordered:`listUnordered`,listItemIndent:`listItemIndent`,listItemMarker:`listItemMarker`,listItemPrefix:`listItemPrefix`,listItemPrefixWhitespace:`listItemPrefixWhitespace`,listItemValue:`listItemValue`,chunkDocument:`chunkDocument`,chunkContent:`chunkContent`,chunkFlow:`chunkFlow`,chunkText:`chunkText`,chunkString:`chunkString`},Pc=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],Fc=[12288,12288,65281,65376,65504,65510],Ic=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],Lc=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],Rc=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],zc=(e,t)=>{let n=0,r=Math.floor(e.length/2)-1;for(;n<=r;){let i=Math.floor((n+r)/2),a=i*2;if(t<e[a])r=i-1;else if(t>e[a+1])n=i+1;else return!0}return!1},Bc=19968,[Vc,Hc]=Uc(Rc);function Uc(e){let t=e[0],n=e[1];for(let r=0;r<e.length;r+=2){let i=e[r],a=e[r+1];if(Bc>=i&&Bc<=a)return[i,a];a-i>n-t&&(t=i,n=a)}return[t,n]}var Wc=e=>e<161||e>1114109?!1:zc(Pc,e),Gc=e=>e<12288||e>65510?!1:zc(Fc,e),Kc=e=>e<8361||e>65518?!1:zc(Ic,e),qc=e=>e<32||e>10630?!1:zc(Lc,e),Jc=e=>e>=Vc&&e<=Hc?!0:e<4352||e>262141?!1:zc(Rc,e);function Yc(e){return Wc(e)?`ambiguous`:Gc(e)?`fullwidth`:Kc(e)?`halfwidth`:qc(e)?`narrow`:Jc(e)?`wide`:`neutral`}function Xc(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function Zc(e){return Xc(e),Yc(e)}function Qc(e){return/^\p{Emoji_Presentation}/u.test(String.fromCodePoint(e))}function $c(e){if(!e||e<4352)return!1;switch(Zc(e)){case`fullwidth`:case`halfwidth`:return!0;case`wide`:return!Qc(e);case`narrow`:return!1;case`ambiguous`:return 917760<=e&&e<=917999&&null;case`neutral`:return/^\p{sc=Hangul}/u.test(String.fromCodePoint(e))}}function el(e,t){return t!==65025||!e||e<8216?!1:e===8216||e===8217||e===8220||e===8221}function tl(e){return e!==null&&e>=65024&&e<=65038}var nl=il(/\p{P}|\p{S}/u),rl=il(/\s/);function il(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCodePoint(t))}}function al(e){return!!(e&Mc.characterGroupWhitespace)}function ol(e){return(e&fl.cjkPunctuation)===Mc.characterGroupPunctuation}function sl(e){return!!(e&fl.cjk)}function cl(e){return e===fl.ivs}function ll(e){return!!(e&fl.cjkOrIvs)}function ul(e){return e===fl.nonEmojiGeneralUseVS}function dl(e){return!!(e&fl.spaceOrPunctuation)}var fl;(function(e){e.spaceOrPunctuation=3,e.cjk=4096,e.cjkPunctuation=4098,e.ivs=8192,e.cjkOrIvs=12288,e.nonEmojiGeneralUseVS=16384,e.variationSelector=24576,e.ivsToCjkRightShift=1})(fl||={});function pl(e){if(e===jc.eof||Vi(e)||rl(e))return Mc.characterGroupWhitespace;let t=0;if(e>=4352){if(tl(e))return fl.nonEmojiGeneralUseVS;switch($c(e)){case null:return fl.ivs;case!0:t|=fl.cjk;break}}return nl(e)&&(t|=Mc.characterGroupPunctuation),t}function ml(e,t,n){if(!ul(e))return e;let r=t(),i=pl(r);return!r||al(i)?e:el(r,n)?fl.cjkPunctuation:hl(i)}function hl(e){return e&~fl.ivs}function gl(e){return!!(e&&e>=55296&&e<=56319)}function _l(e){return!!(e&&e>=56320&&e<=57343)}function vl(e,t,n){if(t._bufferIndex<2)return e;let r=n({start:{...t,_bufferIndex:t._bufferIndex-2},end:t}).codePointAt(0);return r&&r>=65536?r:e}function yl(e,t,n){let r=e>=65536?2:1;if(t._bufferIndex<1+r)return null;let i=t._bufferIndex-r-2,a=n({start:{...t,_bufferIndex:i>=0?i:0},end:{...t,_bufferIndex:t._bufferIndex-r}}),o=a.charCodeAt(a.length-1);if(Number.isNaN(o))return null;if(a.length<2||o<56320||57343<o)return o;let s=a.codePointAt(0);return s&&s>=65536?s:o}var bl=class{cachedValue=void 0;constructor(e,t,n){this.previousCode=e,this.nowPoint=t,this.sliceSerialize=n}value(){return this.cachedValue===void 0&&(this.cachedValue=yl(this.previousCode,this.nowPoint,this.sliceSerialize)),this.cachedValue}};function xl(e,t,n){let r=n({start:t,end:{...t,_bufferIndex:t._bufferIndex+2}}).codePointAt(0);return r&&r>=65536?r:e}var Sl={name:`attention`,resolveAll:Cl,tokenize:wl};function Cl(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};Tl(d,-c),Tl(f,c),o={type:c>1?Nc.strongSequence:Nc.emphasisSequence,start:d,end:{...e[r][1].end}},s={type:c>1?Nc.strongSequence:Nc.emphasisSequence,start:{...e[n][1].start},end:f},a={type:c>1?Nc.strongText:Nc.emphasisText,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?Nc.strong:Nc.emphasis,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=Bi(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=Bi(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),t.parser.constructs.insideSpan.null,l=Bi(l,ra(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=Bi(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=Bi(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,zi(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function wl(e,t){let n=this.parser.constructs.attentionMarkers.null,{now:r,sliceSerialize:i,previous:a}=this,o=_l(a)?vl(a,r(),i):a,s=pl(o),c=new bl(o,r(),i),l=ml(s,c.value.bind(c),o),u;return d;function d(t){return t===jc.asterisk||jc.underscore,u=t,e.enter(`attentionSequence`),f(t)}function f(a){if(a===u)return e.consume(a),f;let s=e.exit(`attentionSequence`),c=pl(gl(a)?xl(a,r(),i):a),d=ol(l),p=o===jc.asterisk||o===jc.underscore,m=d||al(l)||p,h=ol(c),g=a===jc.asterisk||a===jc.underscore,_=h||al(c)||g,v=ll(l),y=!_||h&&(m||v)||n.includes(a)&&a!==jc.asterisk&&a!==jc.underscore,b=!m||d&&(_||sl(c))||n.includes(o)&&o!==jc.asterisk&&o!==jc.underscore;return s._open=!!(u===jc.asterisk?y:y&&(dl(l)||!b)),s._close=!!(u===jc.asterisk?b:b&&(dl(c)||!y)),t(a)}}function Tl(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}function El(){return{text:{[jc.asterisk]:Sl,[jc.underscore]:Sl},insideSpan:{null:[Sl]}}}function Dl(){let e=this.data();(e.micromarkExtensions||=[]).push(El())}var Ol=`;`.codePointAt(0)??jc.eof,kl=`&`.codePointAt(0)??jc.eof;function Al(){return{handlers:{emphasis:jl,strong:Ml,text:Il}}}jl.peek=Nl,Ml.peek=Pl;function jl(e,t,n,r){return Fl(e,t,n,r,Nl(e,t,n),1)}function Ml(e,t,n,r){return Fl(e,t,n,r,Pl(e,t,n),2)}function Nl(e,t,n){return n.options.emphasis||`*`}function Pl(e,t,n){return n.options.strong||`*`}function Fl(e,t,n,r,i,a){let o=i.repeat(a),s=n.enter(a===1?`emphasis`:`strong`),c=n.createTracker(r),l=c.move(o),u=c.move(n.containerPhrasing(e,{after:i,before:l,...c.current()})),d=Wl(e,t,n,r.before),f=Gl(e,t,n,r.after),p=Ll(d,ru(u),i,`open`);p.inside&&u&&(u=eu(u));let m=Ll({current:iu(u),previous:nu(u)},f,i,`close`);m.inside&&u&&(u=tu(u));let h=c.move(o);s();let g=m.outside&&Xl(t,n);return n.attentionEncodeSurroundingInfo={after:m.outside&&!g,before:p.outside},Zl(n).cjkFriendlyEncodeAfterSupplementaryText=g,l+u+h}function Il(e,t,n,r){let i=Zl(n);if(!i.cjkFriendlyEncodeAfterSupplementaryText)return n.safe(e.value,r);i.cjkFriendlyEncodeAfterSupplementaryText=!1;let[a=``]=[...e.value],o=e.value.slice(a.length);return`${$l(a.codePointAt(0)??jc.eof)}${n.safe(o,{...r,before:`;`})}`}function Ll(e,t,n,r){let i=Ul(e),a=pl(t);if(!ll(i)&&!ll(a))return r===`open`?Rl(i,a,n):Rl(a,i,n);let o={inside:!1,outside:!1},s={inside:!0,outside:!1},c={inside:!1,outside:!0},l={inside:!0,outside:!0};for(let i of[o,s,c,l]){let a=r===`open`?i.outside?au:e:i.inside?au:e,o=r===`open`?i.inside?ou:t:i.outside?ou:t;if(r===`open`?zl(n,a,o):Bl(n,a,o))return i}return l}function Rl(e,t,n){return Hl(e)?Hl(t)?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:al(t)?{inside:!0,outside:!0}:{inside:!1,outside:!0}:al(e)?Hl(t)?{inside:!1,outside:!1}:al(t)?{inside:!0,outside:!0}:{inside:!1,outside:!1}:al(t)?{inside:!0,outside:!1}:{inside:!1,outside:!1}}function zl(e,t,n){let r=Ul(t),{close:i,open:a}=Vl(r,pl(n));return e===`_`?a&&(dl(r)||!i):a}function Bl(e,t,n){let r=pl(n),{close:i,open:a}=Vl(Ul(t),r);return e===`_`?i&&(dl(r)||!a):i}function Vl(e,t){let n=ol(e),r=n||al(e),i=ol(t),a=i||al(t);return{open:!a||i&&(r||ll(e)),close:!r||n&&(a||sl(t))}}function Hl(e){return!al(e)&&!ol(e)}function Ul(e){let t=pl(e.current);return e.current===null||!ul(t)?t:ml(t,()=>e.previous,e.current)}function Wl(e,t,n,r){let i=iu(r),a=nu(r);if(Kl(i)||Jl(i,a)){let r=Yl(e,t,n,-1);r&&(i=iu(r),a=nu(r))}return{current:i,previous:a}}function Gl(e,t,n,r){let i=ru(r);if(!ql(i))return i;let a=Yl(e,t,n,1);return a?ru(a):i}function Kl(e){return e!==null&&56320<=e&&e<=57343}function ql(e){return e!==null&&55296<=e&&e<=56319}function Jl(e,t){return ul(pl(e))&&(t===null||t===jc.eof)}function Yl(e,t,n,r){if(!t)return;let i=n.indexStack.at(-1),a=t.children,o=typeof i==`number`?i:a.indexOf(e);if(o<0)return;let s=a[o+r];return Ql(s)||void 0}function Xl(e,t){if(!e)return!1;let n=t.indexStack.at(-1);if(typeof n!=`number`)return!1;let r=e.children[n+1];return r?.type===`text`&&(ru(r.value)??0)>65535}function Zl(e){return e}function Ql(e){return!e||typeof e!=`object`?``:`value`in e&&typeof e.value==`string`?e.value:`alt`in e&&typeof e.alt==`string`?e.alt:`children`in e&&Array.isArray(e.children)?e.children.map(Ql).join(``):``}function $l(e){return`&#x${(e??0).toString(16).toUpperCase()};`}function eu(e){let[t=``]=[...e];return $l(t.codePointAt(0)??jc.eof)+e.slice(t.length)}function tu(e){let t=[...e],n=t.pop();return`${t.join(``)}${$l(n?.codePointAt(0)??jc.eof)}`}function nu(e){let t=[...e];return t.pop(),t.at(-1)?.codePointAt(0)??jc.eof}function ru(e){return e.codePointAt(0)??jc.eof}function iu(e){return[...e].at(-1)?.codePointAt(0)??jc.eof}var au={current:Ol,previous:jc.eof},ou=kl;function su(){let e=this.data();(e.toMarkdownExtensions||=[]).push(Al())}function cu(){Dl.call(this),su.call(this)}var lu=cu;function uu(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{[jc.tilde]:n},insideSpan:{null:[n]},attentionMarkers:{null:[jc.tilde]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&zi(o,o.length,0,ra(s,e.slice(r+1,n),t)),zi(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),zi(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=Nc.data);return e}function i(e,n,r){let{now:i,sliceSerialize:a,previous:o}=this,s=_l(o)?vl(o,i(),a):o,c=pl(s),l=new bl(s,i(),a),u=ml(c,l.value.bind(l),s),d=this.events,f=0;return p;function p(t){return jc.tilde,s===jc.tilde&&d[d.length-1][1].type!==Nc.characterEscape?r(t):(e.enter(`strikethroughSequenceTemporary`),m(t))}function m(o){let c=pl(s);if(o===jc.tilde)return f>1?r(o):(e.consume(o),f++,m);if(f<2&&!t)return r(o);let l=e.exit(`strikethroughSequenceTemporary`),d=pl(gl(o)?xl(o,i(),a):o),p=ol(u)||al(u),h=ol(d)||al(d),g=sl(u)||cl(c);return l._open=!h||d===Mc.attentionSideAfter&&(p||g),l._close=!p||c===Mc.attentionSideAfter&&(h||sl(d)),n(o)}}}function du(e){let t=this.data();(t.micromarkExtensions||=[]).push(uu(e))}var fu=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`],pu=`;`.codePointAt(0)??jc.eof,mu=`&`.codePointAt(0)??jc.eof;function hu(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:fu}],handlers:{delete:gu,text:_u}}}gu.peek=vu;function gu(e,t,n,r){let i=n.enter(`strikethrough`),a=n.createTracker(r),o=a.move(`~~`),s=a.move(n.containerPhrasing(e,{after:`~`,before:o,...a.current()})),c=Eu(e,t,n,r.before),l=Du(e,t,n,r.after),u=yu(c,zu(s),`open`);u.inside&&s&&(s=Iu(s));let d=yu({current:Bu(s),previous:Ru(s)},l,`close`);d.inside&&s&&(s=Lu(s));let f=a.move(`~~`);i();let p=d.outside&&Mu(t,n);return n.attentionEncodeSurroundingInfo={after:d.outside&&!p,before:u.outside},Nu(n).cjkFriendlyEncodeAfterSupplementaryText=p,o+s+f}function _u(e,t,n,r){let i=Nu(n);if(!i.cjkFriendlyEncodeAfterSupplementaryText)return n.safe(e.value,r);i.cjkFriendlyEncodeAfterSupplementaryText=!1;let[a=``]=[...e.value],o=e.value.slice(a.length);return`${Fu(a.codePointAt(0)??jc.eof)}${n.safe(o,{...r,before:`;`})}`}function vu(){return`~`}function yu(e,t,n){let r=Tu(e),i=pl(t);if(!ll(r)&&!ll(i))return n===`open`?bu(r,i):bu(i,r);let a={inside:!1,outside:!1},o={inside:!0,outside:!1},s={inside:!1,outside:!0},c={inside:!0,outside:!0};for(let r of[a,o,s,c]){let i=n===`open`?r.outside?Vu:e:r.inside?Vu:e,a=n===`open`?r.inside?Hu:t:r.outside?Hu:t;if(n===`open`?xu(i,a):Su(i,a))return r}return c}function bu(e,t){return wu(e)?wu(t)?{inside:!1,outside:!1}:al(t)?{inside:!0,outside:!0}:{inside:!1,outside:!0}:al(e)?wu(t)?{inside:!1,outside:!1}:al(t)?{inside:!0,outside:!0}:{inside:!1,outside:!1}:al(t)?{inside:!0,outside:!1}:{inside:!1,outside:!1}}function xu(e,t){let{open:n}=Cu(Tu(e),pl(t));return n}function Su(e,t){let n=pl(t),{close:r}=Cu(Tu(e),n);return r}function Cu(e,t){let n=ol(e),r=n||al(e),i=ol(t),a=i||al(t);return{open:!a||i&&(r||ll(e)),close:!r||n&&(a||sl(t))}}function wu(e){return!al(e)&&!ol(e)}function Tu(e){let t=pl(e.current);return e.current===null||!ul(t)?t:ml(t,()=>e.previous,e.current)}function Eu(e,t,n,r){let i=Bu(r),a=Ru(r);if(Ou(i)||Au(i,a)){let r=ju(e,t,n,-1);r&&(i=Bu(r),a=Ru(r))}return{current:i,previous:a}}function Du(e,t,n,r){let i=zu(r);if(!ku(i))return i;let a=ju(e,t,n,1);return a?zu(a):i}function Ou(e){return e!==null&&56320<=e&&e<=57343}function ku(e){return e!==null&&55296<=e&&e<=56319}function Au(e,t){return ul(pl(e))&&(t===null||t===jc.eof)}function ju(e,t,n,r){if(!t)return;let i=n.indexStack.at(-1),a=t.children,o=typeof i==`number`?i:a.indexOf(e);if(o<0)return;let s=a[o+r];return Pu(s)||void 0}function Mu(e,t){if(!e)return!1;let n=t.indexStack.at(-1);if(typeof n!=`number`)return!1;let r=e.children[n+1];return r?.type===`text`&&(zu(r.value)??0)>65535}function Nu(e){return e}function Pu(e){return!e||typeof e!=`object`?``:`value`in e&&typeof e.value==`string`?e.value:`alt`in e&&typeof e.alt==`string`?e.alt:`children`in e&&Array.isArray(e.children)?e.children.map(Pu).join(``):``}function Fu(e){return`&#x${(e??0).toString(16).toUpperCase()};`}function Iu(e){let[t=``]=[...e];return Fu(t.codePointAt(0)??jc.eof)+e.slice(t.length)}function Lu(e){let t=[...e],n=t.pop();return`${t.join(``)}${Fu(n?.codePointAt(0)??jc.eof)}`}function Ru(e){let t=[...e];return t.pop(),t.at(-1)?.codePointAt(0)??jc.eof}function zu(e){return e.codePointAt(0)??jc.eof}function Bu(e){return[...e].at(-1)?.codePointAt(0)??jc.eof}var Vu={current:pu,previous:jc.eof},Hu=mu;function Uu(){let e=this.data();(e.toMarkdownExtensions||=[]).push(hu())}function Wu(e){du.call(this,e),Uu.call(this)}var Gu=Wu,Ku=new Set([`。`,`.`,`,`,`、`,`?`,`!`,`:`,`;`,`(`,`)`,`【`,`】`,`「`,`」`,`『`,`』`,`〈`,`〉`,`《`,`》`]),qu=/^(https?:\/\/|mailto:|www\.)/i,Ju=e=>{if(e.children.length!==1)return!1;let t=e.children[0];return t.type===`text`&&t.value===e.url},Yu=e=>{let t=0;for(let n of e){if(Ku.has(n))return t;t+=n.length}return null},Xu=(e,t)=>({...t,url:e,children:[{type:`text`,value:e}]}),Zu=e=>({type:`text`,value:e}),Qu=Yi().transforms??[],$u=e=>{let t=[],n=e=>{if(!e)return;let n={type:`paragraph`,children:[Zu(e)]};if(qu.exec(e)?.[0]!==e){let e={type:`root`,children:[n]};for(let t of Qu)t(e)}t.push(...n.children)},r=0,i=0;for(let t of e)Ku.has(t)&&(n(e.slice(r,i)),n(t),r=i+t.length),i+=t.length;return n(e.slice(r)),t},ed=()=>e=>{Qi(e,`link`,(e,t,n)=>{if(!n||typeof t!=`number`||!Ju(e)||!qu.test(e.url))return;let r=Yu(e.url);if(r===null||r===0)return;let i=[Xu(e.url.slice(0,r),e),...$u(e.url.slice(r))];return n.children.splice(t,1,...i),t+i.length})};function td(){let e=[lu],t=[ed,Gu];return{name:`cjk`,type:`cjk`,remarkPluginsBefore:e,remarkPluginsAfter:t,remarkPlugins:[...e,...t]}}var nd=td(),rd=(0,Q.createContext)(new Map);function id(e){let t=new Map;for(let{delivery:n}of e){let e=n.primary;if(e?.kind!==`automation`||!e.runId)continue;let r=t.get(e.id)??new Set;r.add(e.runId),t.set(e.id,r)}return new Map([...t].flatMap(([e,t])=>t.size===1?[[e,[...t][0]]]:[]))}function ad(e){let t=(0,X.c)(49),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({source:o,load:r,onOpen:i,alt:s,className:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=s===void 0?``:s,l=h(sd),u;t[7]===l?u=t[8]:(u=y(l),t[7]=l,t[8]=u);let d=u.chat,{openImage:f}=Le(),[p,m]=(0,Q.useState)(0),[g,_]=(0,Q.useState)(null),[v,b]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(null),T=(0,Q.useRef)(null),E,D;t[9]!==p||t[10]!==r||t[11]!==o?(E=()=>{if(!r)return;let e=!0,t;return r().then(n=>{e&&(t=URL.createObjectURL(n),_({source:o,url:t,attempt:p}))}).catch(()=>{e&&b(o)}),()=>{e=!1,t&&URL.revokeObjectURL(t)}},D=[o,r,p],t[9]=p,t[10]=r,t[11]=o,t[12]=E,t[13]=D):(E=t[12],D=t[13]),(0,Q.useEffect)(E,D);let O=r?g?.source===o&&g.attempt===p?g.url:void 0:o,k=v===o,A;t[14]===o?A=t[15]:(A=e=>{e.naturalWidth&&(S({source:o,width:e.naturalWidth,height:e.naturalHeight}),w(o))},t[14]=o,t[15]=A);let j=A,M;t[16]===j?M=t[17]:(M=()=>{T.current?.complete&&j(T.current)},t[16]=j,t[17]=M);let N;t[18]===O?N=t[19]:(N=[O],t[18]=O,t[19]=N),(0,Q.useEffect)(M,N);let P=x?.source===o?x:null,F=P?Math.min(1,320/P.width,280/P.height):1,I=C!==o&&!k||void 0,L;t[20]!==F||t[21]!==P?(L=P?{width:P.width*F,aspectRatio:`${P.width} / ${P.height}`}:void 0,t[20]=F,t[21]=P,t[22]=L):L=t[22];let R;t[23]!==k||t[24]!==C||t[25]!==o?(R=C!==o&&!k&&(0,Z.jsx)(Yt,{as:`span`,className:`pointer-events-none absolute inset-0`}),t[23]=k,t[24]=C,t[25]=o,t[26]=R):R=t[26];let z;t[27]!==c||t[28]!==p||t[29]!==n||t[30]!==k||t[31]!==d||t[32]!==j||t[33]!==i||t[34]!==f||t[35]!==a||t[36]!==o||t[37]!==O?(z=!k&&(0,Z.jsx)(`img`,{...a,ref:T,src:O,alt:c,loading:`lazy`,decoding:`async`,"data-chat-image-source":o,title:a.title??d.attachmentPreviewImage,className:[`chat-reading-image`,n].filter(Boolean).join(` `),role:O?`button`:void 0,tabIndex:O?0:void 0,"aria-label":O?`${d.attachmentPreviewImage}${c?`: ${c}`:``}`:void 0,onLoad:e=>j(e.currentTarget),onError:()=>b(o),onClick:e=>{O&&(e.preventDefault(),e.stopPropagation(),i?i():f(O,c))},onKeyDown:e=>{!O||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),e.stopPropagation(),i?i():f(O,c))}},`${o}:${p}`),t[27]=c,t[28]=p,t[29]=n,t[30]=k,t[31]=d,t[32]=j,t[33]=i,t[34]=f,t[35]=a,t[36]=o,t[37]=O,t[38]=z):z=t[38];let B;t[39]!==c||t[40]!==k||t[41]!==d?(B=k&&(0,Z.jsxs)(`span`,{className:`flex min-h-24 flex-col items-start justify-center gap-2 p-3 text-sm text-fg-muted`,role:`status`,children:[(0,Z.jsxs)(`span`,{children:[d.attachmentPreviewLoadError,c?` · ${c}`:``]}),(0,Z.jsx)(`button`,{type:`button`,className:`min-h-11 rounded-md px-2 text-accent-fg focus-visible:outline-2 focus-visible:outline-accent`,onClick:e=>{e.preventDefault(),e.stopPropagation(),b(null),w(null),m(od)},children:d.userMessageRetry})]}),t[39]=c,t[40]=k,t[41]=d,t[42]=B):B=t[42];let V;return t[43]!==L||t[44]!==R||t[45]!==z||t[46]!==B||t[47]!==I?(V=(0,Z.jsxs)(`span`,{className:`chat-image-thumbnail`,"data-image-loading":I,style:L,children:[R,z,B]}),t[43]=L,t[44]=R,t[45]=z,t[46]=B,t[47]=I,t[48]=V):V=t[48],V}function od(e){return e+1}function sd(e){return e.language}var cd=class extends Q.Component{state={error:!1,content:this.props.content};static getDerivedStateFromError(){return{error:!0}}static getDerivedStateFromProps(e,t){return e.content===t.content?null:{error:!1,content:e.content}}render(){return this.state.error?(0,Z.jsx)(`div`,{className:`whitespace-pre-wrap break-words`,"data-chat-render-fallback":!0,children:this.props.content}):this.props.children}};function ld(e){if(/^\s{0,3}\[[^\]]+\]:|\[[^\]]+\]\[[^\]]*\]|\[\^/m.test(e))return[e];let t=Wi(e),n=_c(e);if(!n.length)return t;if(t.join(``)!==e)return[e];let r=[],i=0,a=``;for(let e of t)a+=e,i+=e.length,n.some(e=>e.start<i&&e.end>i)||(r.push(a),a=``);return a&&r.push(a),r}function ud(){let e=``,t=[];return n=>{if(n===e)return t;let r=n.startsWith(e)&&!/\[\^|\]\[/m.test(n)?t.slice(0,-2):[],i=r.reduce((e,t)=>e+t.length,0);return t=[...r,...ld(n.slice(i))],e=n,t}}function dd(e){let t=(0,X.c)(26),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({node:r,display:a,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a!==void 0&&a,s=h(fd),c;t[5]===s?c=t[6]:(c=y(s),t[5]=s,t[6]=c);let l=c.chat,[u,d]=(0,Q.useState)(null),f,p;t[7]===u?(f=t[8],p=t[9]):(f=()=>{if(!u)return;let e=window.setTimeout(()=>d(null),2e3);return()=>window.clearTimeout(e)},p=[u],t[7]=u,t[8]=f,t[9]=p),(0,Q.useEffect)(f,p);let m=String(r?.properties.dataXopcMathSource??r?.properties[`data-xopc-math-source`]??``),g;t[10]===m?g=t[11]:(g=ot(m),t[10]=m,t[11]=g);let _=g,v=String(r?.properties.dataXopcMath??r?.properties[`data-xopc-math`]??``),b=v===`pending`?l.mathPending:v===`fallback`?l.mathFailed:void 0,x;t[12]===_?x=t[13]:(x=async e=>{_&&await Ti(e?_.raw:_.latex)&&d(e?`markdown`:`latex`)},t[12]=_,t[13]=x);let S=x,C=o?`div`:`span`,w;t[14]!==u||t[15]!==S||t[16]!==o||t[17]!==l||t[18]!==_?(w=o&&_&&(0,Z.jsxs)(`span`,{className:`markdown-math-actions`,contentEditable:!1,children:[(0,Z.jsx)(`button`,{type:`button`,title:u===`latex`?l.messageCopied:l.mathCopyLatex,"aria-label":l.mathCopyLatex,onClick:()=>void S(!1),dangerouslySetInnerHTML:{__html:ht[u===`latex`?`copied`:`latex`]}}),(0,Z.jsx)(`button`,{type:`button`,title:u===`markdown`?l.messageCopied:l.mathCopyMarkdown,"aria-label":l.mathCopyMarkdown,onClick:()=>void S(!0),dangerouslySetInnerHTML:{__html:ht[u===`markdown`?`copied`:`markdown`]}})]}),t[14]=u,t[15]=S,t[16]=o,t[17]=l,t[18]=_,t[19]=w):w=t[19];let T;return t[20]!==C||t[21]!==n||t[22]!==i||t[23]!==w||t[24]!==b?(T=(0,Z.jsxs)(C,{...i,title:b,children:[n,w]}),t[20]=C,t[21]=n,t[22]=i,t[23]=w,t[24]=b,t[25]=T):T=t[25],T}function fd(e){return e.language}function pd(e,t,n){if(!t||!n||n<=t)return!1;let r=e.split(/\r?\n/),i=r[t-1]?.match(/(?:^|[\s>])(`{3,}|~{3,})chart(?:\s|$)/)?.[1];if(!i)return!1;let a=r[n-1]?.match(/(?:^|[\s>])(`{3,}|~{3,})[ \t]*$/)?.[1];return!!(a&&a[0]===i[0]&&a.length>=i.length)}function md(e,t){let n=new URLSearchParams({path:e});return t&&n.set(`line`,String(t)),`/xopc/workspace/file?${n}`}function hd(e,t){if(t){let t=wi(e);if(t.kind===`internal-route`)return`#${t.route}`;if(e.startsWith(`#`))return e}let n=pt(e);return n?md(n.path,n.line):e}function gd(){return e=>{qi(e,`element`,e=>{e.tagName===`a`&&typeof e.properties.href==`string`?e.properties.href=hd(e.properties.href,!0):e.tagName===`img`&&typeof e.properties.src==`string`&&(e.properties.src=hd(e.properties.src,!1))})}}function _d({breaks:e=!1}={}){return t=>{qi(t,(t,n)=>{if(t.type===`html`){let e=n.at(-1);if(e&&`children`in e){let n=e.children.indexOf(t);e.children.splice(n,1,{type:`text`,value:t.value})}return Ji}if(t.type!==`text`||n.some(e=>e.type===`link`))return;let r=Array.from(t.value.matchAll(/\[([^\]\n]+)\]\((xopc:\/\/[^\s<>]+?)\)|xopc:\/\/[^\s<>\[\]()"',。;!?、]+/gi));if(!r.length&&!(e&&t.value.includes(`
7
+ `)))return;let i=[],a=t=>{(e?t.split(`
8
+ `):[t]).forEach((e,t)=>{t&&i.push({type:`break`}),e&&i.push({type:`text`,value:e})})},o=0;for(let e of r){let n=e[0].replace(/[.,;!?]+$/,``);a(t.value.slice(o,e.index)),i.push({type:`link`,url:e[2]??n,children:[{type:`text`,value:e[1]??n}]}),o=e.index+n.length}a(t.value.slice(o));let s=n.at(-1);if(s&&`children`in s)return s.children.splice(s.children.indexOf(t),1,...i),Ji})}}function vd(){return e=>{qi(e,`text`,(e,t)=>{if(t.some(e=>e.type===`element`&&([`a`,`pre`,`code`,`kbd`,`samp`,`math`,`annotation`].includes(e.tagName)||e.properties.dataXopcMath!==void 0||e.properties[`data-xopc-math`]!==void 0)))return;let n=ct(e.value);if(!n.length)return;let r=t.at(-1);if(!r||!(`children`in r))return;let i=[],a=0;for(let t of n)t.start>a&&i.push({type:`text`,value:e.value.slice(a,t.start)}),i.push({type:`element`,tagName:`a`,properties:{href:md(t.target.path,t.target.line),className:[`markdown-file-link`]},children:[{type:`text`,value:t.raw}]}),a=t.end;return a<e.value.length&&i.push({type:`text`,value:e.value.slice(a)}),r.children.splice(r.children.indexOf(e),1,...i),Ji})}}function yd({prefix:e}){return t=>{let n=new Map;qi(t,`element`,t=>{if(typeof t.properties.id!=`string`)return;let r=t.properties.id,i=`${e}-${r}`;n.set(r,i),r.startsWith(`user-content-`)&&n.set(r.slice(13),i),t.properties.id=i}),qi(t,`element`,e=>{if(typeof e.properties.href==`string`&&e.properties.href.startsWith(`#`)&&!e.properties.href.startsWith(`#/`)){let t=n.get(e.properties.href.slice(1));t&&(e.properties.href=`#${t}`)}for(let t of[`ariaDescribedBy`,`ariaLabelledBy`]){let r=e.properties[t];Array.isArray(r)&&(e.properties[t]=r.map(e=>n.get(String(e))??e))}})}}var bd=typeof Intl.Segmenter==`function`?new Intl.Segmenter(void 0,{granularity:`word`}):null,xd=typeof Intl.Segmenter==`function`?new Intl.Segmenter(void 0,{granularity:`grapheme`}):null;function Sd(e){return bd?Array.from(bd.segment(e),({segment:e,index:t})=>({text:e,offset:t})):[{text:e,offset:0}]}function Cd(e,t){if(t>=e.length||!xd)return e.length;let n=xd.segment(e).containing(t);return n&&n.index!==t?n.index+n.segment.length:t}var wd=256,Td=(0,Q.createContext)(null),Ed=(0,Q.createContext)(null);function Dd(e){let t=(0,X.c)(13),n;if(t[0]!==e){let{node:r,...i}=e;n=i,t[0]=e,t[1]=n}else n=t[1];let r=(0,Q.useContext)(Td),i=(0,Q.useContext)(Ed),a=(0,Q.useRef)(null),o=Number(n[`data-xopc-segment`]),s=n[`data-xopc-new`],c=s===!0||s===`true`,l;t[2]!==i||t[3]!==o||t[4]!==c||t[5]!==r?(l=()=>{let e=a.current;if(!r||!e?.animate||document.visibilityState===`hidden`||window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches||i&&i.size>=wd)return;let t=performance.now(),n=r.starts.get(o);if(n===void 0&&!c)return;if(n===void 0){if(r.starts.size>=wd)return;r.starts.set(o,t)}let s=t-(n??t);if(s>=700)return;let l=e.animate([{opacity:0},{opacity:1}],{duration:700,easing:`cubic-bezier(.37,.55,.86,.88)`,fill:`both`});l.currentTime=s,i?.add(l);let u=()=>{l.cancel(),i?.delete(l)};return l.onfinish=u,u},t[2]=i,t[3]=o,t[4]=c,t[5]=r,t[6]=l):l=t[6];let u;t[7]!==i||t[8]!==o||t[9]!==r?(u=[o,r,i],t[7]=i,t[8]=o,t[9]=r,t[10]=u):u=t[10],(0,Q.useLayoutEffect)(l,u);let d;return t[11]===n?d=t[12]:(d=(0,Z.jsx)(`span`,{...n,ref:a}),t[11]=n,t[12]=d),d}function Od(e,t,n,r,i){let a=()=>i=>{let a=t&&document.visibilityState!==`hidden`&&!window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches,o=0,s=0,c=wd-(r?.size??0),l=performance.now();qi(i,`text`,(t,r)=>{if(r.some(e=>e.type===`element`&&([`pre`,`svg`,`math`,`annotation`].includes(e.tagName)||e.properties.dataXopcMath!==void 0||e.properties[`data-xopc-math`]!==void 0||e.properties[`data-xopc-segment`]!==void 0)))return;let i=o;if(o+=t.value.length,!a)return;let u=r.at(-1);if(!u||!(`children`in u))return;let d=[],f=Sd(t.value).flatMap(t=>{let n=e.length-i-t.offset;if(n<=0||n>=t.text.length)return[t];let r=Cd(t.text,n);return r>=t.text.length?[t]:[{text:t.text.slice(0,r),offset:t.offset},{text:t.text.slice(r),offset:t.offset+r}]});for(let t of f){let r=i+t.offset,a=!n&&r>=e.length,o=e.starts.get(r),u=o!==void 0&&l-o<700;if(!a&&!u||!t.text.trim()||a&&!u&&s++>=c){let e=d.at(-1);e?.type===`text`?e.value+=t.text:d.push({type:`text`,value:t.text})}else d.push({type:`element`,tagName:`span`,properties:{"data-xopc-segment":r,"data-xopc-new":a},children:[{type:`text`,value:t.text}]})}let p=u.children.indexOf(t);return u.children.splice(p,1,...d),[Ji,p+d.length]}),i.children.push({type:`element`,tagName:`span`,properties:{hidden:!0,"data-xopc-watermark":o},children:[]})};return Object.defineProperty(a,"name",{value:`xopcReveal-${i}-${t}-${n}`}),a}var kd=(0,Q.createContext)(null),Ad=(0,Q.createContext)(``);function jd(e){let t=(0,X.c)(52),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({node:i,href:o,children:n,className:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=o===void 0?``:o,c=(0,Q.useContext)(kd),l=(0,Q.useContext)(rd),{openImage:u}=Le(),d=h(Md),f;t[6]===d?f=t[7]:(f=y(d),t[6]=d,t[7]=f);let p=f.chat.contentLinks,m;t[8]===s?m=t[9]:(m=s.startsWith(`#`)&&!s.startsWith(`#/`),t[8]=s,t[9]=m);let g=m,_,v,b,x,S,C,w,T;if(t[10]!==n||t[11]!==c||t[12]!==g||t[13]!==s||t[14]!==p||t[15]!==i||t[16]!==l){C=Symbol.for(`react.early_return_sentinel`);bb0:{if(T=i?Rd(i).trim():typeof n==`string`?n.trim():``,_=Ci(wi(s),T),_.kind===`internal-route`&&_.route.startsWith(`/automations?`)){let e=new URL(_.route,`https://xopc.local`),n=l.get(e.searchParams.get(`automation`)??``);if(e.searchParams.get(`view`)===`run`&&!e.searchParams.has(`run`)&&n){e.searchParams.set(`run`,n);let r=`${e.pathname}${e.search}`,i;t[25]===r?i=t[26]:(i={kind:`internal-route`,route:r},t[25]=r,t[26]=i),_=i}}if(w=!s.startsWith(`#`)&&_.kind!==`internal-route`&&c.openFile?pt(s):null,!g&&!w&&_.kind===`blocked`){let e;t[27]===n?e=t[28]:(e=(0,Z.jsx)(Z.Fragment,{children:n}),t[27]=n,t[28]=e),C=e;break bb0}b=_.kind===`internal-route`?_.route:void 0,v=!!b;let e=b?b.slice(1).split(/[/?#]/,1)[0]:``;x=p.destinations[e]??p.open,S=v&&/^(?:xopc:\/\/|#\/|Open(?: in xopc)?$|打开$)/i.test(T)?x:n}t[10]=n,t[11]=c,t[12]=g,t[13]=s,t[14]=p,t[15]=i,t[16]=l,t[17]=_,t[18]=v,t[19]=b,t[20]=x,t[21]=S,t[22]=C,t[23]=w,t[24]=T}else _=t[17],v=t[18],b=t[19],x=t[20],S=t[21],C=t[22],w=t[23],T=t[24];if(C!==Symbol.for(`react.early_return_sentinel`))return C;let E=S,D=b?`#${b}`:s,O=v||w||g?void 0:`_blank`,k;t[29]!==r||t[30]!==w?(k=[r,w?`markdown-file-link`:``].filter(Boolean).join(` `)||void 0,t[29]=r,t[30]=w,t[31]=k):k=t[31];let A=g?`document-fragment`:w?void 0:_.kind,j=w?.path,M=w?.kind,N=w?.line,P=c.linkError===D?p.failed:a.title||(v?x:void 0),F;t[32]!==D||t[33]!==c||t[34]!==g||t[35]!==s||t[36]!==u||t[37]!==w||t[38]!==T?(F=e=>{if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;if(e.preventDefault(),g){let t=e.currentTarget.closest(`.markdown-render-boundary`),n=s.slice(1),r=n;try{r=decodeURIComponent(n)}catch{}let i=Array.from(t?.querySelectorAll(`[id]`)??[]),a=i.find(e=>e.id===n)??i.find(e=>e.id===r);if(!a)return;a.closest(`[data-chat-scroll-viewport]`)?.dispatchEvent(new Event(`chat-scroll-reading`)),a.scrollIntoView({block:`nearest`,behavior:`auto`}),a.hasAttribute(`tabindex`)||a.setAttribute(`tabindex`,`-1`),a.focus({preventScroll:!0});return}let t=Array.from(e.currentTarget.closest(`.markdown-render-boundary`)?.querySelectorAll(`img[data-chat-image-source]`)??[]).find(e=>e.dataset.chatImageSource===s&&e.getAttribute(`src`));if(t?.src&&!/下载|download/i.test(T)){u(t.src,t.alt);return}if(w){c.openFile?.(w);return}c.openLink(D)},t[32]=D,t[33]=c,t[34]=g,t[35]=s,t[36]=u,t[37]=w,t[38]=T,t[39]=F):F=t[39];let I;return t[40]!==D||t[41]!==a||t[42]!==M||t[43]!==N||t[44]!==P||t[45]!==F||t[46]!==O||t[47]!==k||t[48]!==A||t[49]!==j||t[50]!==E?(I=(0,Z.jsx)(`a`,{...a,href:D,target:O,rel:`noopener noreferrer`,className:k,"data-xopc-link-kind":A,"data-xopc-file-path":j,"data-xopc-file-kind":M,"data-xopc-line":N,title:P,onClick:F,children:E}),t[40]=D,t[41]=a,t[42]=M,t[43]=N,t[44]=P,t[45]=F,t[46]=O,t[47]=k,t[48]=A,t[49]=j,t[50]=E,t[51]=I):I=t[51],I}function Md(e){return e.language}function Nd({node:e,src:t=``,alt:n,...r}){let i=(0,Q.useContext)(kd),a=pt(t),o=a?.path,s=a?.line,c=a?.kind,l=(0,Q.useCallback)(()=>!o||!c||!i.loadImage?Promise.reject(Error(`Image unavailable`)):i.loadImage({path:o,line:s,kind:c}),[i.loadImage,o,s,c]);return(0,Z.jsx)(ad,{...r,source:t,alt:n,load:a?l:void 0})}function Pd(e){let t=(0,X.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({node:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=n?.children.some(Ld)&&n.children.every(Fd),t[3]=n,t[4]=i);let a=i||void 0,o;return t[5]!==r||t[6]!==a?(o=(0,Z.jsx)(`p`,{...r,"data-chat-media":a}),t[5]=r,t[6]=a,t[7]=o):o=t[7],o}function Fd(e){return e.type===`text`?!e.value.trim():e.type===`element`&&(e.tagName===`img`||e.tagName===`a`&&e.children.every(Id))}function Id(e){return e.type===`element`&&e.tagName===`img`}function Ld(e){return e.type===`element`}function Rd(e){return e.children.map(e=>e.type===`text`?e.value:e.type===`element`?Rd(e):``).join(``)}function zd(e){let t=(0,X.c)(20),{node:n}=e,r=(0,Q.useContext)(kd),i=(0,Q.useContext)(Ad),a=Xi(),o,s;if(t[0]!==n?.children){let e=n?.children.find(Bd);o=String(e?.properties.className??``).match(/language-([^,\s]+)/)?.[1]??``,s=e?Rd(e).replace(/\n$/,``):``,t[0]=n?.children,t[1]=o,t[2]=s}else o=t[1],s=t[2];let c=s;if(o===`chart`){let e;t[3]!==i||t[4]!==a||t[5]!==n?.position?.end||t[6]!==n?.position?.start?(e=a||!pd(i,n?.position?.start.line,n?.position?.end.line),t[3]=i,t[4]=a,t[5]=n?.position?.end,t[6]=n?.position?.start,t[7]=e):e=t[7];let o;return t[8]!==c||t[9]!==r.copy||t[10]!==r.streaming||t[11]!==e?(o=(0,Z.jsx)(la,{source:c,incomplete:e,streaming:r.streaming,copy:r.copy}),t[8]=c,t[9]=r.copy,t[10]=r.streaming,t[11]=e,t[12]=o):o=t[12],o}let l;return t[13]!==c||t[14]!==r.copy||t[15]!==r.mermaidActions||t[16]!==r.renderMermaid||t[17]!==a||t[18]!==o?(l=(0,Z.jsx)(sa,{code:c,language:o,incomplete:a,renderMermaid:r.renderMermaid,actions:r.mermaidActions,copy:r.copy}),t[13]=c,t[14]=r.copy,t[15]=r.mermaidActions,t[16]=r.renderMermaid,t[17]=a,t[18]=o,t[19]=l):l=t[19],l}function Bd(e){return e.type===`element`&&e.tagName===`code`}function Vd(e){let t=(0,X.c)(14),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({node:r,children:n,style:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]===r?o=t[6]:(o=((r?.children.find(Wd)??r)?.children.find(Ud))?.children.filter(Hd).length??1,t[5]=r,t[6]=o);let s=`${o*6}rem`,c;t[7]!==a||t[8]!==s?(c={...a,minWidth:s},t[7]=a,t[8]=s,t[9]=c):c=t[9];let l;return t[10]!==n||t[11]!==i||t[12]!==c?(l=(0,Z.jsx)(`div`,{className:`markdown-table-scroll`,tabIndex:0,children:(0,Z.jsx)(`table`,{...i,style:c,children:n})}),t[10]=n,t[11]=i,t[12]=c,t[13]=l):l=t[13],l}function Hd(e){return e.type===`element`&&[`th`,`td`].includes(e.tagName)}function Ud(e){return e.type===`element`&&e.tagName===`tr`}function Wd(e){return e.type===`element`&&e.tagName===`thead`}function Gd(e){let t=(0,X.c)(2),n;return t[0]===e?n=t[1]:(n=e.node?.properties.dataXopcMath??e.node?.properties[`data-xopc-math`]?(0,Z.jsx)(dd,{...e}):(0,Z.jsx)(Dd,{...e}),t[0]=e,t[1]=n),n}function Kd(e){let t=(0,X.c)(2),n;return t[0]===e?n=t[1]:(n=e.node?.properties.dataXopcMath??e.node?.properties[`data-xopc-math`]?(0,Z.jsx)(dd,{...e,display:!0}):(0,Z.jsx)(`div`,{...Object.fromEntries(Object.entries(e).filter(qd))}),t[0]=e,t[1]=n),n}function qd(e){let[t]=e;return t!==`node`}var Jd=e=>function({node:t,...n}){let r=(e===`th`||e===`td`)&&typeof t?.properties.align==`string`?t.properties.align:void 0;return(0,Q.createElement)(e,{...n,"data-markdown-align":r})},Yd={a:jd,img:Nd,pre:zd,span:Gd,div:Kd,p:Pd,h1:Jd(`h1`),h2:Jd(`h2`),h3:Jd(`h3`),h4:Jd(`h4`),h5:Jd(`h5`),h6:Jd(`h6`),ul:Jd(`ul`),ol:Jd(`ol`),li:Jd(`li`),strong:Jd(`strong`),em:Jd(`em`),blockquote:Jd(`blockquote`),code:Jd(`code`),table:Vd,thead:Jd(`thead`),tbody:Jd(`tbody`),tr:Jd(`tr`),th:Jd(`th`),td:Jd(`td`),hr:Jd(`hr`)},Xd=[gd,[Gi,{...Ki,attributes:{...Ki.attributes,code:[...Ki.attributes?.code??[],[`className`,/^language-/,`math-inline`,`math-display`],`data-xopc-math-source`]}}]],Zd=e=>/^\s{0,3}\[[^\]]+\]:|\[[^\]]+\]\[[^\]]*\]|\[\^/m.test(e),Qd=(0,Q.memo)(function(e){let t=(0,Q.useId)(),n=(0,Q.useContext)(kd),r=(0,Q.useRef)(null),i=(0,Q.useContext)(Ed),[a]=(0,Q.useState)(()=>({length:0,starts:new Map})),o=(0,Q.useRef)(``),s=(0,Q.useRef)(!1),[c,l]=(0,Q.useState)(0),u=!s.current&&e.index<n.initialBlocks,d=o.current.trimEnd().replace(/[*_~`]+$/,``),f=s.current&&!e.content.startsWith(d),p=(n.streaming||a.starts.size>0)&&!Zd(e.content)&&!f,m=(0,Q.useMemo)(()=>Od(a,p,u,i,t),[a,p,u,c,i,t]),h=n.mathRemaining[e.index]??256,g=(0,Q.useMemo)(()=>[...(e.rehypePlugins??[]).map(e=>Array.isArray(e)&&e[0]===Ac?[Ac,{streaming:n.streaming,maxCount:h}]:e),m],[e.rehypePlugins,m,n.streaming,h]),_=performance.now();return(0,Q.useLayoutEffect)(()=>{n.metricsKey&&mt(n.metricsKey,performance.now()-_),a.length=Number(r.current?.querySelector(`[data-xopc-watermark]`)?.getAttribute(`data-xopc-watermark`)??0),f&&a.starts.clear(),o.current=e.content,s.current=!0;for(let[e,t]of a.starts)performance.now()-t>=700&&a.starts.delete(e)},[e.content,n.metricsKey,a,f]),(0,Q.useEffect)(()=>{let e=()=>{let e=window.getSelection();e&&!e.isCollapsed&&r.current?.contains(e.anchorNode)||r.current?.querySelector(`[data-xopc-segment]`)&&(a.starts.clear(),l(e=>e+1))},t=window.setTimeout(e,750);return document.addEventListener(`selectionchange`,e),()=>{window.clearTimeout(t),document.removeEventListener(`selectionchange`,e)}},[e.content,a]),(0,Z.jsx)(`div`,{ref:r,className:`markdown-stream-block`,children:(0,Z.jsx)(cd,{content:e.content,children:(0,Z.jsx)(Ad.Provider,{value:e.content,children:(0,Z.jsx)(Td.Provider,{value:a,children:(0,Z.jsx)(Zi,{...e,shouldParseIncompleteMarkdown:e.shouldParseIncompleteMarkdown&&_c(e.content).length===0,rehypePlugins:g})})})})})}),$d=(0,Q.memo)(function({content:e,compact:t=!1,breaks:n=!1,className:r,codeCopy:i=!0,onWorkspaceFileOpen:a,onWorkspaceImageLoad:o,renderMermaid:s=!0,mermaidActions:c=!1,streamingMetricsKey:l,streaming:u=!1}){let d=(0,Q.useId)(),f=(0,Q.useRef)(null),p=at(),m=h(e=>e.language),[g,_]=(0,Q.useState)(null),v=(0,Q.useRef)(0),b=(0,Q.useRef)(null),x=(0,Q.useCallback)(e=>{let t=++v.current;b.current=e,_(null),p(e).then(n=>{t===v.current&&(n.ok&&(b.current=null),_(n.ok?null:e))}).catch(()=>{t===v.current&&_(e)})},[p]);(0,Q.useEffect)(()=>()=>{v.current++},[]),(0,Q.useEffect)(()=>{let e=b.current;!e||Array.from(f.current?.querySelectorAll(`a[href]`)??[]).some(t=>t.getAttribute(`href`)===e)||(b.current=null,v.current++,_(null))},[e]);let[S]=(0,Q.useState)(()=>new Set),[C]=(0,Q.useState)(()=>u||!e?`streaming`:`static`),[w]=(0,Q.useState)(ud),[T]=(0,Q.useState)(()=>C===`streaming`?ld(e).length:0),E=(0,Q.useMemo)(()=>({cjk:nd,math:{name:`katex`,type:`math`,remarkPlugin:mc,rehypePlugin:[Ac,{streaming:u}]}}),[u]),D=(0,Q.useMemo)(()=>{let t=0;return w(e).map(e=>{let n=Math.max(0,256-t);return t+=_c(e).length,n})},[e,w]),O=(0,Q.useMemo)(()=>({openLink:x,linkError:g,streaming:u,initialBlocks:T,mathRemaining:D,metricsKey:l,copy:i,renderMermaid:s,mermaidActions:c,openFile:a,loadImage:o}),[x,g,u,T,D,l,i,s,c,a,o]),k=(0,Q.useMemo)(()=>[...Object.values(ta),[_d,{breaks:n}]],[n]),A=(0,Q.useMemo)(()=>[...Xd,...a?[vd]:[],[yd,{prefix:`xopc-markdown-${d}`}]],[d,a]);return(0,Q.useLayoutEffect)(()=>{},[e,l]),(0,Q.useLayoutEffect)(()=>{let e=f.current?.querySelectorAll(`p`)??[];for(let t of e){t.hidden=!1;let e=t.querySelector(`a`);if(!e||t.textContent?.trim()!==e.textContent?.trim()||!/^(?:查看(?:高清|原|大)?图片|查看大图|查看原图|view(?: (?:full[- ]size|original|hd))? image)$/i.test(e.textContent?.trim()??``))continue;let n=t.nextElementSibling??t.closest(`.markdown-stream-block`)?.nextElementSibling?.firstElementChild,r=n?.querySelectorAll(`img[data-chat-image-source]`);n?.matches(`[data-chat-media]`)&&r?.length===1&&r[0].dataset.chatImageSource===e.getAttribute(`href`)&&(t.hidden=!0)}},[e]),(0,Z.jsx)(ze,{interactive:!0,closeLabel:y(m).chat.attachmentPreviewClose,children:(0,Z.jsx)(kd.Provider,{value:O,children:(0,Z.jsx)(Ad.Provider,{value:e,children:(0,Z.jsx)(Ed.Provider,{value:S,children:(0,Z.jsxs)(`div`,{ref:f,className:`markdown-render-boundary`,"data-chat-markdown":d,children:[(0,Z.jsx)(cd,{content:e,children:(0,Z.jsx)(ea,{className:[`markdown-body xopc-chat-markdown`,t?`markdown-compact`:``,n?`markdown-breaks`:``,a?`markdown-workspace-links`:``,r].filter(Boolean).join(` `),mode:C,isAnimating:u,animated:!1,parseIncompleteMarkdown:u,components:Yd,plugins:E,controls:!1,BlockComponent:Qd,parseMarkdownIntoBlocksFn:w,remarkPlugins:k,rehypePlugins:A,urlTransform:$i,children:e})}),g?(0,Z.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:y(m).chat.contentLinks.failed}):null]})})})})})});function ef(e){let t=(0,X.c)(31),{label:n,description:r,index:i,recommended:a,recommendedLabel:o,selected:s,disabled:c,onClick:l}=e,u=!!s,d=s&&`bg-accent-soft`,f;t[0]===d?f=t[1]:(f=Y(`group min-h-11 w-full justify-start gap-3 rounded-md px-3 py-2.5 text-left font-normal text-fg shadow-none`,d),t[0]=d,t[1]=f);let p=s&&`border-accent text-accent-fg`,m;t[2]===p?m=t[3]:(m=Y(`flex size-6 shrink-0 items-center justify-center rounded-md border border-edge text-xs tabular-nums text-fg-muted`,p),t[2]=p,t[3]=m);let h;t[4]!==i||t[5]!==s?(h=s?(0,Z.jsx)(ee,{className:`size-3.5`}):i+1,t[4]=i,t[5]=s,t[6]=h):h=t[6];let g;t[7]!==m||t[8]!==h?(g=(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:m,children:h}),t[7]=m,t[8]=h,t[9]=g):g=t[9];let _;t[10]===n?_=t[11]:(_=(0,Z.jsx)(`span`,{className:`font-medium`,children:n}),t[10]=n,t[11]=_);let v;t[12]!==a||t[13]!==o?(v=a?(0,Z.jsx)(`span`,{className:`text-xs font-normal text-fg-muted`,children:o}):null,t[12]=a,t[13]=o,t[14]=v):v=t[14];let y;t[15]!==_||t[16]!==v?(y=(0,Z.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-0.5`,children:[_,v]}),t[15]=_,t[16]=v,t[17]=y):y=t[17];let b;t[18]===r?b=t[19]:(b=r?(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs leading-relaxed text-fg-muted`,children:r}):null,t[18]=r,t[19]=b);let x;t[20]!==y||t[21]!==b?(x=(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 whitespace-normal break-words`,children:[y,b]}),t[20]=y,t[21]=b,t[22]=x):x=t[22];let S;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(N,{"aria-hidden":`true`,className:`size-4 shrink-0 text-fg-muted opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100 motion-reduce:transition-none`}),t[23]=S):S=t[23];let C;return t[24]!==c||t[25]!==l||t[26]!==u||t[27]!==x||t[28]!==f||t[29]!==g?(C=(0,Z.jsxs)(mi,{variant:`ghost`,disabled:c,onClick:l,"aria-pressed":u,className:f,children:[g,x,S]}),t[24]=c,t[25]=l,t[26]=u,t[27]=x,t[28]=f,t[29]=g,t[30]=C):C=t[30],C}function tf(e,t,n=`draft`,r){let i=m.getState(),a=sessionStorage.getItem(`xopc.clarification.endpoint`);a||(a=crypto.randomUUID(),sessionStorage.setItem(`xopc.clarification.endpoint`,a));let o=`clarification:${i.baseUrl}:${a}:${e}:${t}:${n}`;return i.conversationId?Or(o,r):{read:async()=>void 0,write:async e=>{}}}function nf({prompt:e,submitting:t,submitError:n,labels:r,onSubmit:i,onAgentDecide:a,onCancel:o}){let s=y(h(e=>e.language)).chat,[c,l]=(0,Q.useState)({index:0,answers:{}}),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(``),[m,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(!1),b=(0,Q.useRef)(!1),x=(0,Q.useRef)(!1),[S,C]=(0,Q.useState)(),w=(0,Q.useRef)(c),T=(0,Q.useRef)(null),E=(0,Q.useRef)(null),D=e?.questions??[],O=D[Math.min(c.index,D.length-1)],k=O?c.answers[O.id]:void 0,A=(0,Q.useRef)(tf(e.requestId,e.version??1,`draft`,e.conversationId)),j=t||m,M=j||_,N=D.filter(e=>{let t=c.answers[e.id];return t&&(t.choiceId||t.text?.trim())}).length;(0,Q.useEffect)(()=>{let t=!0;tf(e.requestId,e.version??1,`submission`,e.conversationId).read().then(e=>{t&&v(!!e)}).catch(()=>{});let n=t=>{let n=t.detail;n.requestId===e.requestId&&v(n.pending)};return window.addEventListener(`clarification-submission-state`,n),()=>{t=!1,window.removeEventListener(`clarification-submission-state`,n)}},[e]),(0,Q.useEffect)(()=>{let e=!1;return A.current.read().then(t=>{e||(t&&!b.current&&t.index>=0&&t.index<D.length&&t.answers&&(w.current=t,l(t)),d(!0))}).catch(()=>{e||d(!0)}),()=>{e=!0}},[D.length]),(0,Q.useEffect)(()=>{if(!u||!b.current)return;let e=window.setTimeout(()=>{A.current.write(c).catch(()=>{})},300);return()=>window.clearTimeout(e)},[c,u]),(0,Q.useEffect)(()=>{S&&E.current?.focus()},[S]);function P(e,t=!1){b.current=!0,w.current=e,l(e),p(``),t&&A.current.write(e).catch(()=>{})}function F(e){P({...c,index:e},!0),T.current?.focus()}async function I(t=w.current){if(!(j||x.current||!e)){x.current=!0,g(!0);try{let n={schemaVersion:2,answers:D.map(e=>t.answers[e.id]??{questionId:e.id})};ar(e,n),await A.current.write(t),await i(n)}catch(e){p(e instanceof Error?e.message:String(e))}finally{x.current=!1,g(!1)}}}function L(e){if(M||x.current||!O)return;let t={...w.current,answers:{...w.current.answers,[O.id]:{questionId:O.id,choiceId:e}}};P(t);let n=D.findIndex(e=>{let n=t.answers[e.id];return!n?.choiceId&&!n?.text?.trim()});n===-1?I(t):(P({...t,index:n},!0),T.current?.focus())}if(!u)return(0,Z.jsxs)(`div`,{className:`mb-4 space-y-3 rounded-lg border border-edge p-4`,children:[(0,Z.jsx)(Yt,{className:`h-5 w-1/2`}),(0,Z.jsx)(Yt,{className:`h-24 w-full`})]});if(!O)return null;let R=!!(k?.choiceId||k?.text?.trim())&&(k?.text?.length??0)<=2e3,z=O.type!==`single_choice`||S===O.id||!!k?.text,B=`clarify-${e.requestId}-${O.id}`;return(0,Z.jsxs)(`section`,{ref:T,tabIndex:-1,"aria-label":r.clarifyRegionAria,"aria-busy":j,"data-clarification-id":e.requestId,className:Y(`mb-4 flex max-h-[min(36rem,75dvh)] min-h-0 flex-col overflow-hidden rounded-lg border border-edge bg-surface-overlay text-sm text-fg outline-none`,ua.focusRingPanel),children:[(0,Z.jsxs)(`header`,{className:`shrink-0 border-b border-edge-subtle px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r.clarifyRegionAria}),(0,Z.jsx)(`span`,{role:`status`,className:`text-xs text-fg-muted`,children:j?r.clarifySubmitting:s.clarifyProgress.replace(`{{answered}}`,String(N)).replace(`{{total}}`,String(D.length))})]}),D.length>1?(0,Z.jsx)(`nav`,{"aria-label":s.clarifyQuestions,className:`mt-2 flex flex-wrap gap-1`,children:D.map((e,t)=>(0,Z.jsxs)(mi,{variant:t===c.index?`secondary`:`ghost`,disabled:M,"aria-current":t===c.index?`step`:void 0,onClick:()=>F(t),children:[t+1,`. `,e.header,c.answers[e.id]?.choiceId||c.answers[e.id]?.text?.trim()?` ✓`:``]},e.id))}):null]}),(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto px-4 py-3`,children:[(0,Z.jsx)($d,{content:O.question,compact:!0,className:`text-fg [&_p]:font-medium`}),O.type===`single_choice`?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:D.length>1?s.clarifyBatchQuickHint:r.clarifyQuickHint}):null,O.type===`single_choice`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{role:`group`,"aria-label":O.header,className:`space-y-0.5 rounded-lg border border-edge p-1`,children:O.choices.map((e,t)=>(0,Z.jsx)(ef,{...e,index:t,recommended:O.recommendedChoiceId===e.id,recommendedLabel:r.clarifyRecommended,selected:k?.choiceId===e.id,disabled:M,onClick:()=>L(e.id)},e.id))}),(0,Z.jsxs)(mi,{variant:`ghost`,disabled:M,"aria-expanded":z,"aria-controls":B,className:`min-h-11 justify-start gap-1 px-1 text-xs`,onClick:()=>C(z?void 0:O.id),children:[(0,Z.jsx)(ne,{"aria-hidden":`true`,className:Y(`size-3.5`,z&&`rotate-90`)}),r.clarifyCustomLabel]})]}):null,z?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`label`,{htmlFor:B,className:`sr-only`,children:r.clarifyCustomLabel}),(0,Z.jsx)(`textarea`,{ref:E,id:B,rows:3,disabled:M,value:k?.text??``,"aria-invalid":(k?.text?.length??0)>2e3,onChange:e=>P({...c,answers:{...c.answers,[O.id]:{questionId:O.id,text:e.target.value}}}),onKeyDown:e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&!e.nativeEvent.isComposing&&(e.preventDefault(),c.index===D.length-1?I():R&&F(c.index+1))},className:`min-h-20 w-full resize-y rounded-md border border-edge bg-surface-panel px-3 py-2 focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent`}),(0,Z.jsxs)(`p`,{className:`flex justify-between gap-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:r.clarifyKeyboardHint}),(0,Z.jsxs)(`span`,{children:[k?.text?.length??0,`/2000`]})]})]}):null,n||f?(0,Z.jsx)(`p`,{role:`alert`,className:`text-red-600`,children:n||f}):null]}),(0,Z.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-edge-subtle px-4 py-3`,children:[(0,Z.jsx)(mi,{variant:`ghost`,disabled:M,onClick:()=>void o(),children:r.clarifyCancel}),a?(0,Z.jsx)(mi,{variant:`ghost`,disabled:M,onClick:()=>void a(),children:r.clarifyAgentDecide}):null,D.length>1?(0,Z.jsx)(mi,{variant:`secondary`,disabled:M||c.index===0,onClick:()=>F(c.index-1),children:s.clarifyPrevious}):null,z||_||n||f||N===D.length?c.index<D.length-1&&!_?(0,Z.jsx)(mi,{variant:`primary`,disabled:M||!R,onClick:()=>F(c.index+1),children:s.clarifyNext}):(0,Z.jsx)(mi,{variant:`primary`,disabled:j||N!==D.length||!R,onClick:()=>void I(),children:j?r.clarifySubmitting:_?s.clarifyRetrySubmission:s.clarifySubmitAll}):null]})]})}function rf(e){let t=(0,X.c)(5);if(e.prompt?.schemaVersion===2&&e.prompt.kind!==`approval`){let n=`${e.prompt.requestId}:${e.prompt.version}`,r;return t[0]!==e||t[1]!==n?(r=(0,Z.jsx)(nf,{...e},n),t[0]=e,t[1]=n,t[2]=r):r=t[2],r}let n;return t[3]===e?n=t[4]:(n=e.prompt?(0,Z.jsx)(af,{...e,prompt:e.prompt},e.prompt.requestId):null,t[3]=e,t[4]=n),n}function af({prompt:e,submitting:t,submitError:n,labels:r,onSubmit:i,onAgentDecide:a,onCancel:o}){let[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(Date.now),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(``),y=(0,Q.useRef)(!1),b=(0,Q.useRef)(null),x=(0,Q.useRef)(null),S=(0,Q.useRef)(null),[C]=(0,Q.useState)(()=>e.serverTime?e.serverTime-Date.now():0),w=e.expiresAt===void 0?null:Math.max(0,Math.ceil((e.expiresAt-p-C)/1e3)),T=w===0,E=t||h||T,D=e.kind===`approval`,O=d||!e.choiceDetails?.length,k=e.choiceDetails??[],A=s.trim().length>lr,j=`clarify-answer-${e.requestId}`,M=`clarify-error-${e.requestId}`,N=`clarify-hint-${e.requestId}`,P=e.recommendedChoiceId;(0,Q.useEffect)(()=>{b.current?.focus()},[]),(0,Q.useEffect)(()=>{(n||_)&&x.current?.focus()},[n,_]),(0,Q.useEffect)(()=>{d&&S.current?.focus()},[d]),(0,Q.useEffect)(()=>{if(!e.expiresAt)return;let t=window.setInterval(()=>m(Date.now()),1e3);return()=>window.clearInterval(t)},[e.expiresAt]),(0,Q.useEffect)(()=>{S.current&&(S.current.style.height=`auto`,S.current.style.height=`${Math.min(160,S.current.scrollHeight)}px`)},[s]);let F=async t=>{if(!(E||y.current)){y.current=!0,g(!0),v(``);try{ar(e,t),await i(t)}catch(e){v(e instanceof Error?e.message:String(e))}finally{y.current=!1,g(!1)}}},I=e=>{E||(u(e),F({response:{choiceId:e}}))},L=()=>{A||!s.trim()||F({response:{text:s.trim()||void 0}})};return(0,Z.jsxs)(`section`,{ref:b,tabIndex:-1,"data-clarification-id":e.requestId,"aria-label":D?r.clarifyApprovalTitle:r.clarifyRegionAria,"aria-busy":t||h,className:Y(`mb-4 rounded-lg border border-edge bg-surface-overlay px-4 py-3 text-sm text-fg outline-none`,ua.focusRingPanel),children:[(0,Z.jsx)(`p`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:D?r.clarifyApprovalTitle:r.clarifyRegionAria}),(0,Z.jsx)($d,{content:e.question,compact:!0,className:`mb-3 text-fg [&_p]:font-medium`}),D&&e.approval?(0,Z.jsx)(`dl`,{className:`mb-3 space-y-2`,children:[[r.clarifyOperation,e.approval.operation],[r.clarifyTarget,e.approval.target],[r.clarifyImpact,e.approval.impact]].map(([e,t])=>t?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-xs text-fg-muted`,children:e}),(0,Z.jsx)(`dd`,{className:`whitespace-pre-wrap break-words`,children:t})]},e):null)}):null,D&&e.approval?.argumentsPreview?(0,Z.jsxs)(`details`,{className:`mb-3`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer text-fg-muted`,children:r.clarifyDetails}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-all text-xs`,children:JSON.stringify(e.approval.argumentsPreview,null,2)})]}):null,(0,Z.jsxs)(`div`,{className:`mb-3 space-y-1 text-xs text-fg-muted`,children:[D?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{children:r.clarifyOnce}),(0,Z.jsx)(`p`,{children:r.clarifyApprovalTimeout})]}):null,w===null?null:(0,Z.jsx)(`p`,{role:`status`,children:T?r.clarifyExpired:r.clarifyTimeRemaining.replace(`{{time}}`,`${Math.floor(w/60)}:${String(w%60).padStart(2,`0`)}`)})]}),n||_?(0,Z.jsx)(`div`,{ref:x,tabIndex:-1,id:M,role:`alert`,className:`mb-3 rounded-md border border-edge p-3 text-red-600`,children:n||_}):null,t||h?(0,Z.jsx)(`p`,{role:`status`,className:`mb-2 text-xs text-fg-muted`,children:r.clarifySubmitting}):null,D?(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(mi,{variant:`secondary`,disabled:E,onClick:()=>void F({decision:`deny`}),children:r.clarifyDeny}),(0,Z.jsx)(mi,{variant:`primary`,disabled:E,onClick:()=>void F({decision:`approve`}),children:r.clarifyApprove})]}):(0,Z.jsxs)(Z.Fragment,{children:[k.length?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:r.clarifyQuickHint}),(0,Z.jsx)(`div`,{role:`group`,"aria-label":r.clarifyChoicesGroupAria,className:`max-h-64 space-y-0.5 overflow-y-auto rounded-lg border border-edge p-1`,children:k.map((e,t)=>(0,Z.jsx)(ef,{...e,index:t,recommended:P===e.id,recommendedLabel:r.clarifyRecommended,selected:l===e.id,disabled:E,onClick:()=>I(e.id)},e.id))}),(0,Z.jsxs)(mi,{variant:`ghost`,disabled:E,"aria-expanded":O,"aria-controls":j,className:`mt-1 min-h-11 justify-start gap-1 px-1 text-xs`,onClick:()=>{f(!d)},children:[(0,Z.jsx)(ne,{"aria-hidden":`true`,className:Y(`size-3.5`,O&&`rotate-90`)}),r.clarifyCustomLabel]})]}):null,O?(0,Z.jsxs)(`form`,{className:`mt-2 space-y-2`,onSubmit:e=>{e.preventDefault(),L()},children:[(0,Z.jsx)(`label`,{htmlFor:j,className:`block text-xs font-medium text-fg-muted`,children:r.clarifyCustomLabel}),(0,Z.jsx)(`textarea`,{id:j,ref:S,value:s,rows:2,disabled:E,placeholder:r.clarifyPlaceholder,"aria-invalid":A,"aria-describedby":`${N}${n?` ${M}`:``}`,onChange:e=>{c(e.target.value),e.target.value&&f(!0)},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&!e.nativeEvent.isComposing&&(e.preventDefault(),L())},className:`max-h-40 min-h-16 w-full resize-none overflow-y-auto rounded-md border border-edge bg-surface-panel px-3 py-2 text-fg placeholder:text-fg-muted focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent disabled:opacity-50`}),(0,Z.jsxs)(`div`,{id:N,className:`flex flex-wrap justify-between gap-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:A?r.clarifyAnswerTooLong:r.clarifyKeyboardHint}),(0,Z.jsxs)(`span`,{"aria-live":A?`polite`:`off`,children:[s.trim().length,`/`,lr]})]}),(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,Z.jsx)(mi,{type:`submit`,variant:`primary`,disabled:E||A||!s.trim(),children:r.clarifySend})})]}):null,(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-1 border-t border-edge-subtle pt-2`,children:[a?(0,Z.jsx)(mi,{variant:`ghost`,disabled:E,onClick:()=>void a(),children:r.clarifyAgentDecide}):null,(0,Z.jsx)(mi,{variant:`ghost`,disabled:t||h,onClick:()=>void o(),children:r.clarifyCancel})]})]})]})}function of(e,t){let n=(0,X.c)(13),r=m(cf),i=m(sf),a;n[0]!==i||n[1]!==e||n[2]!==r?(a=e?[`session-context`,i,r,e]:null,n[0]=i,n[1]=e,n[2]=r,n[3]=a):a=n[3];let o;n[4]===e?o=n[5]:(o=async()=>await Tr(e)?void 0:(await g(p(`/api/sessions/${encodeURIComponent(e)}/context-summary`))).summary,n[4]=e,n[5]=o);let s;n[6]===t?s=n[7]:(s={keepPreviousData:!1,revalidateOnFocus:t,revalidateOnReconnect:t,shouldRetryOnError:!1},n[6]=t,n[7]=s);let c=Kr(a,o,s),{mutate:l}=c,u,d;return n[8]!==e||n[9]!==l||n[10]!==t?(u=()=>{if(!t||!e)return;l();let n,r=()=>{window.clearTimeout(n),n=window.setTimeout(()=>{l()},150)},i=[`session-updated`,`run-completed`,`agent-run-ended`,`note-updated`,`task-changed-v2`,`task-collaboration-entry-added`,`gateway-realtime-connected`];for(let e of i)window.addEventListener(e,r);return()=>{window.clearTimeout(n);for(let e of i)window.removeEventListener(e,r)}},d=[t,e,l],n[8]=e,n[9]=l,n[10]=t,n[11]=u,n[12]=d):(u=n[11],d=n[12]),(0,Q.useEffect)(u,d),c}function sf(e){return e.baseUrl}function cf(e){return e.conversationId}function lf(){return xa()?window.electronAPI?.platform??`web`:`web`}function uf({runtime:e,sidebarCollapsed:t,mobileNavOpen:n}){let r=e===`darwin`,i=e===`linux`,a=e===`web`,o=a||i||r&&!t&&!n;return{sidebarChromeVisible:o||n,sidebarQuickActionsVisible:o,sidebarChromeDraggable:r,sidebarLeadingInsetClass:r?`pl-[88px]`:``,mainHeaderDraggable:r,mainHeaderQuickActionsVisible:(a||i)&&t||r&&t&&!n,mainHeaderLeadingInsetClass:r&&t?`pl-[88px]`:``,collapsedNewChatVisible:a&&t}}var df=`xopc-web-sidebar-collapsed`,ff=`xopc-web-sidebar-expanded-width-px`;function pf(){try{return globalThis.localStorage?.getItem(df)===`1`}catch{return!1}}function mf(e){try{globalThis.localStorage?.setItem(df,e?`1`:`0`)}catch{}}function hf(e){return Math.min(480,Math.max(248,Math.round(e)))}function gf(){try{let e=globalThis.localStorage?.getItem(ff);if(e==null)return hf(256);let t=Number.parseInt(e,10);return hf(Number.isFinite(t)?t:256)}catch{return hf(256)}}function _f(e){try{globalThis.localStorage?.setItem(ff,String(e))}catch{}}var vf=_((e,t)=>({collapsed:pf(),setCollapsed:t=>{e({collapsed:t}),queueMicrotask(()=>mf(t))},toggleCollapsed:()=>{t().setCollapsed(!t().collapsed)},expandedWidthPx:gf(),setExpandedWidthPx:n=>{let r=hf(n);t().expandedWidthPx!==r&&(e({expandedWidthPx:r}),queueMicrotask(()=>_f(r)))}})),yf=_(e=>({mobileNavOpen:!1,setMobileNavOpen:t=>e({mobileNavOpen:t}),toggleMobileNav:()=>e(e=>({mobileNavOpen:!e.mobileNavOpen}))}));function bf(e){return e>99?`99+`:String(e)}function xf(e,t){let n=(0,X.c)(15),r=t===void 0||t,i=m(Tf),a;n[0]!==r||n[1]!==i?(a=i&&r?[`personal-agent-unread`,i]:null,n[0]=r,n[1]=i,n[2]=a):a=n[2];let o;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(o={refreshInterval:3e4},n[3]=o):o=n[3];let{data:s,mutate:c}=Kr(a,wf,o),[l,u]=(0,Q.useState)(Cf),d,p;n[4]!==r||n[5]!==i||n[6]!==c?(d=()=>{if(!r||!i)return;let e=()=>{c()},t=()=>{let t=document.visibilityState===`visible`&&document.hasFocus();u(t),t&&e()},n=[`session-transcript-updated`,`session-task-result`,`agent-run-ended`,`personal-unread-updated`,`gateway-realtime-connected`,`realtime-gap`];return n.forEach(t=>window.addEventListener(t,e)),window.addEventListener(`focus`,t),window.addEventListener(`blur`,t),document.addEventListener(`visibilitychange`,t),()=>{n.forEach(t=>window.removeEventListener(t,e)),window.removeEventListener(`focus`,t),window.removeEventListener(`blur`,t),document.removeEventListener(`visibilitychange`,t)}},p=[c,r,i],n[4]=r,n[5]=i,n[6]=c,n[7]=d,n[8]=p):(d=n[7],p=n[8]),(0,Q.useEffect)(d,p);let h=s?.payload,g,_;return n[9]!==c||n[10]!==h||n[11]!==e||n[12]!==l?(g=()=>{if(!l||!h?.unreadCount||h.conversationId!==e)return;let t=!0;return f(`/api/personal-agent/read`,{method:`POST`,body:JSON.stringify({transcriptId:h.transcriptId,lastSeq:h.lastSeq})}).then(async e=>{if(!e.ok)return;let n=await e.json();t&&await c(n,{revalidate:!1})}).catch(Sf),()=>{t=!1}},_=[l,e,h,c],n[9]=c,n[10]=h,n[11]=e,n[12]=l,n[13]=g,n[14]=_):(g=n[13],_=n[14]),(0,Q.useEffect)(g,_),h?.unreadCount??0}function Sf(){}function Cf(){return document.visibilityState===`visible`&&document.hasFocus()}function wf(){return g(p(`/api/personal-agent/unread`))}function Tf(e){return e.conversationId}function Ef(e){let t=Nn(t=>_n(t.sessions[e])),[n,r]=(0,Q.useState)(()=>Mn(e)),i=(0,Q.useRef)(e);return i.current!==e&&(i.current=e,r(Mn(e))),(0,Q.useEffect)(()=>{r(Mn(e))},[e,t]),(0,Q.useEffect)(()=>{let t=t=>{t.detail?.chatId===e&&r(Mn(e))};return window.addEventListener(Zn,t),()=>window.removeEventListener(Zn,t)},[e]),t||n}function Df(e){return e.trim()}var Of=_(e=>({runs:{},markRunning:t=>{let n=Df(t);if(!n)return;let r=Date.now();e(e=>{let t=e.runs[n];return{runs:{...e.runs,[n]:{status:`running`,startedAt:t?.status===`running`?t.startedAt:r,updatedAt:r,unread:!1}}}})},markCompleted:(t,n)=>{let r=Df(t);if(!r)return;let i=Date.now();e(e=>{let t=e.runs[r];return{runs:{...e.runs,[r]:{status:`completed`,startedAt:t?.startedAt??i,updatedAt:i,unread:n}}}})},markFailed:(t,n)=>{let r=Df(t);if(!r)return;let i=Date.now();e(e=>{let t=e.runs[r];return{runs:{...e.runs,[r]:{status:`failed`,startedAt:t?.startedAt??i,updatedAt:i,unread:n}}}})},markViewed:t=>{let n=Df(t);n&&e(e=>{let t=e.runs[n];return t?.unread?{runs:{...e.runs,[n]:{...t,unread:!1}}}:e})},clear:t=>{let n=Df(t);n&&e(e=>{if(!(n in e.runs))return e;let{[n]:t,...r}=e.runs;return{runs:r}})}}));function kf(e){Of.getState().markRunning(e)}function Af(e,t){Of.getState().markCompleted(e,t)}function jf(e,t){Of.getState().markFailed(e,t)}function Mf(e){Of.getState().clear(e)}function Nf(e){Of.setState(t=>({runs:{...t.runs,[e]:{status:`waiting`,startedAt:t.runs[e]?.startedAt??Date.now(),updatedAt:Date.now(),unread:!1}}}))}var Pf=`application/x-xopc-workspace-file`;function Ff(e,t){e.effectAllowed=`copy`,e.setData(Pf,JSON.stringify(t))}function If(e){return!!(e&&Array.from(e.types).includes(`application/x-xopc-workspace-file`))}function Lf(e){if(!e)return null;try{let t=JSON.parse(e.getData(Pf)),n=typeof t.path==`string`?t.path.trim():``,r=typeof t.name==`string`?t.name.trim():``;return!n||!r?null:{path:n,name:r,...typeof t.conversationId==`string`&&t.conversationId.trim()?{conversationId:t.conversationId.trim()}:{},...typeof t.agentId==`string`&&t.agentId.trim()?{agentId:t.agentId.trim()}:{},...typeof t.projectId==`string`&&t.projectId.trim()?{projectId:t.projectId.trim()}:{}}}catch{return null}}var Rf=`xopc-web-workspace-panel-open`,zf=`xopc-web-workspace-panel-width-px`;function Bf(){try{return globalThis.localStorage?.getItem(Rf)===`1`}catch{return!1}}function Vf(e){try{globalThis.localStorage?.setItem(Rf,e?`1`:`0`)}catch{}}function Hf(e){return Math.min(520,Math.max(200,Math.round(e)))}function Uf(){try{let e=globalThis.localStorage?.getItem(zf);if(e==null)return 320;let t=Number.parseInt(e,10);return Number.isFinite(t)?Hf(t):320}catch{return 320}}function Wf(e){try{globalThis.localStorage?.setItem(zf,String(e))}catch{}}var Gf=_((e,t)=>({open:Bf(),setOpen:t=>{hi.getState().setOpen(t),e(t?{open:t}:{open:t,conversationIdOverride:null}),queueMicrotask(()=>Vf(t))},toggleOpen:()=>{t().setOpen(!t().open)},conversationIdOverride:null,openForSession:t=>{let n=t.trim();hi.getState().setScope(n||`new`),hi.getState().setOpen(!0,n||`new`),e({open:!0,conversationIdOverride:n||null}),queueMicrotask(()=>Vf(!0))},widthPx:Uf(),setWidthPx:n=>{let r=Hf(n);t().widthPx!==r&&(e({widthPx:r}),queueMicrotask(()=>Wf(r)))}})),Kf={commands:!0,skills:!0,agentSwitch:!0},qf={commands:!1,skills:!1,agentSwitch:!1},Jf=new WeakMap,Yf=`​`,Xf=`⁠`,Zf=RegExp(`^\\/skill:(${Aa})`);function Qf(e){return!!e.dataset.skill}function $f(e){return!!e.dataset.contextRefId}function ep(e){return e.dataset.slashCommand!=null&&e.dataset.slashCommand!==``}var tp=new WeakMap;function np(e){let t=Vn(),n,r=-1;for(;(n=t.exec(e))!==null;)r=n.index+n[0].length;return r===e.length}function rp(e){let t=``;for(let n of e)if(n){if(t.length>0){let e=t[t.length-1],r=n[0];if(!/\s/.test(e)&&!/\s/.test(r)){let e=np(t)||/\/skill:\S+$/.test(t)||mo(t),r=n.startsWith(`@xopc-ref:`)||n.startsWith(`/skill:`)||fo(n);(e||r)&&(t+=` `)}}t+=n}return t}function ip(e){if(e.nodeType!==Node.ELEMENT_NODE)return!1;let t=e.tagName;return t===`DIV`||t===`P`||t===`PRE`||t===`BLOCKQUOTE`}function ap(e,t){if(e.nodeType===Node.TEXT_NODE)t.push((e.textContent??``).replaceAll(Yf,``));else if(e.nodeType===Node.ELEMENT_NODE){let n=e;if(Qf(n)){let e=n.dataset.skill??``;e&&t.push(`/skill:${e}`)}else if($f(n)){let e=n.dataset.contextRefId??``;e&&t.push(Xn(e))}else if(ep(n)){let e=n.dataset.slashCommand??``;e&&t.push(`/${e}`)}else n.tagName===`BR`?t.push(`
9
+ `):op(n,t)}}function op(e,t){let n=Array.from(e.childNodes);for(let e=0;e<n.length;e++){let r=n[e],i=n[e+1];ap(r,t),i!=null&&(ip(r)||ip(i))&&t.push(`
10
+ `)}}function sp(e,t){op(e,t)}function cp(e){let t=[];return sp(e,t),rp(t).replaceAll(Xf,``)}function lp(e){let t=window.getSelection();if(!t)return;let n=document.createRange(),r=e.firstChild;r&&r.nodeType===Node.TEXT_NODE?(n.setStart(r,0),n.collapse(!0)):(n.setStart(e,0),n.collapse(!0)),t.removeAllRanges(),t.addRange(n)}function up(e){let t=cp(e);return t.length>0||e.childNodes.length===0?t:(Tp(e,``),lp(e),``)}function dp(e){let t=new Set,n=Da(),r;for(;(r=n.exec(e))!==null;){let e=r[1];e&&t.add(e)}return t}function fp(e){let t=window.getSelection();if(!t||t.rangeCount===0)return cp(e).length;let n=t.getRangeAt(0);if(!e.contains(n.startContainer))return cp(e).length;let r=document.createRange();r.selectNodeContents(e),r.setEnd(n.startContainer,n.startOffset);let i=document.createElement(`div`);return i.appendChild(r.cloneContents()),cp(i).length}var pp=new WeakMap;function mp(e,t){pp.set(e,t);for(let n of e.querySelectorAll(`[data-skill]`)){let e=`/${t(n.dataset.skill??``)}`;n.textContent!==e&&(n.textContent=e),n.title=`/${n.dataset.skill}`}}function hp(e,t){tp.set(e,t);for(let n of e.querySelectorAll(`[data-context-ref-id]`)){let e=t(n.dataset.contextRefId??``);n.textContent=e?`@${e.title}`:`@reference`,n.title=e?.title??``,n.dataset.refKind=e?.kind??``,n.dataset.fileKind=e?.fileKind??``}}function gp(e,t){let n=document.createElement(`span`);n.contentEditable=`false`,n.dataset.skill=t,n.className=`chat-skill-pill`,n.textContent=`/${pp.get(e)?.(t)??t}`,n.title=`/${t}`,e.appendChild(n),e.appendChild(document.createTextNode(Yf))}function _p(e,t){let n=tp.get(e)?.(t),r=document.createElement(`span`);r.contentEditable=`false`,r.dataset.contextRefId=t,r.dataset.refKind=n?.kind??``,r.dataset.fileKind=n?.fileKind??``,r.className=`chat-context-ref-pill`,r.textContent=n?`@${n.title}`:`@reference`,r.title=n?.title??``,e.appendChild(r),e.appendChild(document.createTextNode(Yf))}function vp(e,t){let n=document.createElement(`span`);n.contentEditable=`false`,n.dataset.slashCommand=t,n.className=`chat-command-pill`,n.textContent=`/${t}`,e.appendChild(n),e.appendChild(document.createTextNode(Yf))}function yp(e,t=Kf){let n=[],r=t=>{let r,i=new RegExp(t.source,t.flags);for(;(r=i.exec(e))!==null;)n.push({start:r.index,end:r.index+r[0].length})};t.skills&&r(Da()),r(Vn());for(let r of t.commands?xo(e):[])n.push(r);return n.sort((e,t)=>e.start-t.start),n}function bp(e,t,n=Kf){for(let{start:r,end:i}of yp(e,n))if(t>r&&t<=i)return{wire:e.slice(0,r)+e.slice(i),caret:r};return null}function xp(e,t,n=Kf){if(t<=0)return null;let r=e.slice(0,t),i=n=>{let i=r.match(n);if(i?.[1]){let n=i[1],a=r.length-n.length;return{wire:e.slice(0,a)+e.slice(t),caret:a}}return null},a=n.skills?[ka]:[];for(let e of a){let t=i(e);if(t)return t}let o=n.commands?vo(r):null;if(o){let n=o.tokenStart;return{wire:e.slice(0,n)+e.slice(t),caret:n}}if(t===e.length){let i=n.skills?[Oa]:[];for(let n of i){let i=r.match(n);if(i?.[1]){let n=i[0],a=r.length-n.length;return{wire:e.slice(0,a)+e.slice(t),caret:a}}}let a=n.commands?po(r):null;if(a){let n=a.tokenStart;return{wire:e.slice(0,n)+e.slice(t),caret:n}}}return null}function Sp(e){let t=window.getSelection();if(!t||t.rangeCount===0||!t.isCollapsed)return!1;let n=t.getRangeAt(0),r=cp(e),i=fp(e);i===0&&r.length>0&&n.startContainer===e&&n.startOffset===e.childNodes.length&&(i=r.length);let a=Jf.get(e)??Kf,o=bp(r,i,a);return o||=xp(r,i,a),o?(Tp(e,o.wire,o.caret),e.dispatchEvent(new InputEvent(`input`,{bubbles:!0})),!0):!1}function Cp(e,t,n){let r=e.slice(t);return n.skills&&Zf.test(r)||Vn().exec(r)?.index===0?!0:n.commands&&_o(e,t)!=null}function wp(e,t,n){let r=Jf.get(e)??Kf,i=t.slice(n),a=[],o=i.match(Zf);r.skills&&o?.[0]&&a.push({len:o[0].length,apply:()=>gp(e,o[1]??``)});let s=Vn().exec(i);s?.index===0&&s[0]&&a.push({len:s[0].length,apply:()=>_p(e,s[1]??``)});let c=r.commands?_o(t,n):null;if(c&&a.push({len:c.len,apply:()=>vp(e,c.matchedKey)}),a.length===0){let i=n+1;for(;i<t.length&&!Cp(t,i,r);)i+=1;let a=t.slice(n,i);return a&&e.appendChild(document.createTextNode(a)),i}return a.sort((e,t)=>t.len-e.len),a[0].apply(),n+a[0].len}function Tp(e,t,n,r){r&&Jf.set(e,r),e.replaceChildren();let i=t;if(n!==void 0){let e=Math.max(0,Math.min(n,t.length));i=t.slice(0,e)+Xf+t.slice(e)}let a=0;for(;a<i.length;)a=wp(e,i,a);if(n===void 0)return;let o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),s;for(;s=o.nextNode();){let e=s.textContent??``,t=-1;for(let n=0;n<e.length;n++)if(e[n]===Xf){t=n;break}if(t>=0){let n=s;n.textContent=e.slice(0,t)+e.slice(t+1);let r=window.getSelection(),i=document.createRange();i.setStart(n,t),i.collapse(!0),r?.removeAllRanges(),r?.addRange(i);return}}}function Ep(e,t){for(let n of e)if(n.isActive()&&n.handleKey(t))return!0;return!1}var Dp=8*1024,Op=80,kp=2*1024,Ap=20;function jp(e){let t=e.trimStart().slice(0,8*1024);if(/^(?:<!doctype\s+html\b|<(?:html|head|body)\b)/i.test(t)||/^<(?:div|span|section|main|article|script|style)\b/i.test(t))return`html`;let n=e.trim();return(n.startsWith(`{`)&&n.endsWith(`}`)||n.startsWith(`[`)&&n.endsWith(`]`))&&/[\":,]/.test(t)?`json`:/(?:^|\n)\s*(?:(?:import|export|const|let|var|function|class|interface|type|def|SELECT|CREATE)\b|#!\/)/m.test(t)||/(?:=>|\{\s*$|;\s*$)/m.test(t)?`code`:`text`}function Mp(e){let t=new TextEncoder().encode(e).byteLength,n=e.split(/\r\n|\n|\r/).length,r=jp(e);return t>=Dp||n>=Op||r!==`text`&&(t>=kp||n>=Ap)?{text:e,...r===`html`?{name:`pasted-text.html`,mimeType:`text/html`}:r===`json`?{name:`pasted-text.json`,mimeType:`application/json`}:r===`code`?{name:`pasted-code.txt`,mimeType:`text/plain`}:{name:`pasted-text.txt`,mimeType:`text/plain`},byteLength:t,lineCount:n}:null}function Np(e){if(!e)return null;let t=Pi(e);if(t.length>0)return{kind:`files`,files:t};let n=e.getData(`text/plain`);if(!n)return null;let r=Mp(n);return r?{kind:`text-attachment`,attachment:r}:{kind:`inline-text`,text:n}}async function Pp(e,t){switch(e.kind){case`files`:await t.processFiles(e.files);return;case`unsupported-files`:t.onUnsupportedFiles();return;case`text-attachment`:await t.processPastedText(e.attachment);return;case`inline-text`:t.insertText(e.text)}}var Fp=`fill-chat-composer`;function Ip(e,t,n){window.dispatchEvent(new CustomEvent(Fp,{detail:{text:e,attachments:t,contextRefs:n}}))}function Lp(e,t,n){let r=(0,X.c)(20),i=n===void 0||n,a=h(Bp),o=m(zp),s=m(Rp),c;r[0]!==e||r[1]!==s||r[2]!==t||r[3]!==i||r[4]!==o?(c=i&&o?[`chat-skill-labels`,s,o,e??`main`,t??``]:null,r[0]=e,r[1]=s,r[2]=t,r[3]=i,r[4]=o,r[5]=c):c=r[5];let l;r[6]!==e||r[7]!==t?(l=()=>lo(e,t),r[6]=e,r[7]=t,r[8]=l):l=r[8];let u;r[9]===Symbol.for(`react.memo_cache_sentinel`)?(u={revalidateOnFocus:!1,shouldRetryOnError:!1},r[9]=u):u=r[9];let{data:d,mutate:f}=Kr(c,l,u),p,g;r[10]!==i||r[11]!==o||r[12]!==f?(p=()=>{if(!i||!o)return;let e=e=>{let t=e.detail?.section;(t===`skills`||t===`agents`)&&f()};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},g=[i,o,f],r[10]=i,r[11]=o,r[12]=f,r[13]=p,r[14]=g):(p=r[13],g=r[14]),(0,Q.useEffect)(p,g);let _;r[15]!==d?.skills||r[16]!==a?(_=new Map(d?.skills.map(e=>[e.name,go(e,a).displayName])),r[15]=d?.skills,r[16]=a,r[17]=_):_=r[17];let v=_,y;return r[18]===v?y=r[19]:(y=e=>v.get(e)??e,r[18]=v,r[19]=y),y}function Rp(e){return e.baseUrl}function zp(e){return e.conversationId}function Bp(e){return e.language}function Vp(e,t){e.classList.toggle(`composer-input-empty`,t.length===0)}function Hp(e){let{disabled:t,initialValue:n=``,onValueChange:r,autoFocusKey:i,welcomeDraftSeed:a,onExternalTextReplace:o,shouldSyncSelectionRef:s,resolveContextRef:c}=e,l=e.capabilities??Kf,u=Lp(e.agentId,e.conversationId,l.skills),[d,f]=(0,Q.useState)(n),[p,m]=(0,Q.useState)(n.length),[h,g]=(0,Q.useState)(!1),_=(0,Q.useRef)(null),v=(0,Q.useRef)(d),y=(0,Q.useRef)(p),b=(0,Q.useRef)(null),x=(0,Q.useRef)(0),S=(0,Q.useRef)(r),C=(0,Q.useRef)(!0),w=(0,Q.useRef)(null),T=(0,Q.useRef)(!1);v.current=d,y.current=p,S.current=r;let E=(0,Q.useRef)(null),D=(0,Q.useCallback)(()=>{let e=_.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,128)}px`)},[]),O=(0,Q.useCallback)(()=>{E.current===null&&(E.current=requestAnimationFrame(()=>{E.current=null,D()}))},[D]);(0,Q.useEffect)(()=>()=>{E.current!==null&&cancelAnimationFrame(E.current),E.current=null},[]),(0,Q.useLayoutEffect)(()=>{let e=_.current;if(!e||typeof ResizeObserver>`u`)return;let t=e.clientWidth,n=new ResizeObserver(()=>{t!==e.clientWidth&&(t=e.clientWidth,O())});return n.observe(e),()=>n.disconnect()},[O]),(0,Q.useLayoutEffect)(()=>{let e=_.current;!e||h||(mp(e,u),c&&hp(e,c),D())},[u,c,h,D]),(0,Q.useLayoutEffect)(()=>{if(T.current)return;let e=_.current;e&&(T.current=!0,c&&hp(e,c),Tp(e,n,n.length,l),Vp(e,n),D())},[D,n,c,l]),(0,Q.useLayoutEffect)(()=>{let e=_.current;e&&Tp(e,v.current,fp(e),l)},[l]);let k=(0,Q.useCallback)(()=>{let e=_.current;if(!e)return;e.focus({preventScroll:!0});let t=window.getSelection(),n=b.current;if(t&&n?.startContainer.isConnected&&n.endContainer.isConnected&&e.contains(n.startContainer)&&e.contains(n.endContainer)){t.removeAllRanges(),t.addRange(n);return}Tp(e,v.current,y.current,l)},[l]),A=(0,Q.useCallback)(e=>{let t=e?.nextText??``,n=e?.caretOffset??t.length;f(t),S.current?.(t),v.current=t,m(n),y.current=n,b.current=null;let r=_.current;r&&(Tp(r,t,n,l),Vp(r,t),e?.focus&&r.focus({preventScroll:!0})),O()},[O,l]);(0,Q.useEffect)(()=>{O()},[d,O]);let j=(0,Q.useRef)(a?.id??0);return(0,Q.useLayoutEffect)(()=>{!a||a.id===j.current||(j.current=a.id,x.current=a.id,o?.(),A({nextText:a.text,focus:typeof globalThis.matchMedia==`function`&&globalThis.matchMedia(`(hover: hover) and (pointer: fine)`).matches}))},[a,o,A]),(0,Q.useLayoutEffect)(()=>{if(t){C.current=!0;return}let e=i??null,n=C.current,r=e!==w.current;if(!n&&!r)return;C.current=!0;let a=requestAnimationFrame(()=>{if(!(typeof globalThis.matchMedia==`function`&&globalThis.matchMedia(`(hover: hover) and (pointer: fine)`).matches))return;let t=_.current;t&&(t.focus({preventScroll:!0}),document.activeElement===t&&(C.current=!1,w.current=e))});return()=>cancelAnimationFrame(a)},[t,i]),(0,Q.useEffect)(()=>{let e=_.current;if(!e)return;let t=!1,n=null,r=!1,i=-1,a=()=>{let t=window.getSelection();if(!t?.rangeCount||!e.contains(t.anchorNode)||!e.contains(t.focusNode))return null;let n=fp(e);return y.current=n,b.current=t.getRangeAt(0).cloneRange(),n},o=()=>{if(n=null,r=!1,document.activeElement!==e)return;let t=a();t!==null&&t!==i&&(i=t,s.current&&m(t))},c=()=>{t&&(r||(r=!0,n=requestAnimationFrame(o)))},l=()=>{t||(t=!0,document.addEventListener(`selectionchange`,c),c())},u=()=>{t&&(t=!1,document.removeEventListener(`selectionchange`,c),n!=null&&cancelAnimationFrame(n),n=null,r=!1)},d=()=>l(),f=()=>{a(),u()};return e.addEventListener(`focus`,d),e.addEventListener(`blur`,f),document.activeElement===e&&l(),()=>{e.removeEventListener(`focus`,d),e.removeEventListener(`blur`,f),u()}},[s]),(0,Q.useEffect)(()=>{let t=t=>{if(e.receiveExternalFill===!1)return;let n=t.detail;typeof n?.text==`string`&&(o?.(n),A({nextText:n.text,focus:!0}))};return window.addEventListener(Fp,t),()=>window.removeEventListener(Fp,t)},[o,e.receiveExternalFill,A]),{value:d,cursor:p,isComposing:h,setIsComposing:g,editorRef:_,valueRef:v,adjustHeight:O,focusForExternalPaste:k,resetEditor:A,onWireInput:(0,Q.useCallback)((e,t)=>{v.current=e,y.current=t,f(e),S.current?.(e),m(t)},[])}}var Up=(0,Q.memo)(function(e){let t=(0,X.c)(37),{editorRef:n,disabled:r,hidden:i,compact:a,placeholder:o,ariaLabel:s,onWireInput:c,adjustHeight:l,processFiles:u,processPastedText:d,setIsComposing:f,kbdRef:p,chatMessages:m}=e,h=a!==void 0&&a,g=(0,Q.useRef)(!1),_,v;t[0]!==r||t[1]!==n?(_=()=>{let e=n.current;if(!e||r)return;let t=t=>{t.inputType!==`deleteContentBackward`||!t.cancelable||t.isComposing||g.current||Sp(e)&&t.preventDefault()};return e.addEventListener(`beforeinput`,t),()=>e.removeEventListener(`beforeinput`,t)},v=[r,n],t[0]=r,t[1]=n,t[2]=_,t[3]=v):(_=t[2],v=t[3]),(0,Q.useEffect)(_,v);let y=s??o,b=!r,x=h?`max-h-32 min-h-10 py-2`:`max-h-24 min-h-12 py-1.5 sm:max-h-32 sm:min-h-16 sm:py-2`,S;t[4]===x?S=t[5]:(S=Y(`composer-input box-border m-0 w-full overflow-y-auto border-0 bg-transparent px-0 text-[0.9375rem] leading-6 text-fg focus:outline-none focus:ring-0 disabled:opacity-50`,x,`composer-input-empty`),t[4]=x,t[5]=S);let C;t[6]!==l||t[7]!==c?(C=e=>{let t=e.currentTarget,n=g.current?cp(t):up(t),r=e.nativeEvent.inputType;!g.current&&r?.startsWith(`delete`)&&n===`
11
+ `&&t.children.length===1&&t.firstElementChild?.tagName===`BR`&&Array.from(t.childNodes).every(e=>e===t.firstElementChild||e.nodeType===Node.TEXT_NODE&&!e.textContent)&&(t.replaceChildren(),n=``),Vp(t,n),c(n,fp(t)),l()},t[6]=l,t[7]=c,t[8]=C):C=t[8];let w;t[9]===f?w=t[10]:(w=()=>{g.current=!0,f(!0)},t[9]=f,t[10]=w);let T;t[11]!==l||t[12]!==n||t[13]!==c||t[14]!==f?(T=()=>{g.current=!1,f(!1),queueMicrotask(()=>{let e=n.current;if(!e||g.current)return;let t=up(e);Vp(e,t),c(t,fp(e)),l()})},t[11]=l,t[12]=n,t[13]=c,t[14]=f,t[15]=T):T=t[15];let E;t[16]!==m||t[17]!==u||t[18]!==d?(E=async e=>{let t=Np(e.clipboardData);t&&(e.preventDefault(),await Pp(t,{processFiles:u,processPastedText:d,insertText:Wp,onUnsupportedFiles:()=>Ne(`warning`,m.clipboardFileTypeUnsupported)}))},t[16]=m,t[17]=u,t[18]=d,t[19]=E):E=t[19];let D;t[20]!==r||t[21]!==n||t[22]!==i||t[23]!==p?(D=e=>{let t=p.current;if(t.isComposing||g.current||e.nativeEvent.isComposing||e.nativeEvent.keyCode===229)return;if(e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&t.runBusy&&!t.editingUserTurnId&&!t.editingFollowUpId&&!r&&!i){if(e.preventDefault(),e.repeat)return;(t.pendingFollowUpsCount>0||t.valueRef.current.trim()||t.attachmentsLen>0||t.contextRefsLen>0)&&t.steerCurrentReply?.();return}if(e.key===`Backspace`&&!t.isComposing&&!g.current&&!e.nativeEvent.isComposing&&n.current&&Sp(n.current)){e.preventDefault();return}if(Ep(t.adapters,e))return;if((e.key===`Tab`||e.key===`Enter`)&&!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!t.isComposing&&!g.current&&!e.nativeEvent.isComposing&&!r&&!i&&!t.runBusy&&!t.pendingFollowUpsCount&&!t.editingFollowUpId&&!t.attachmentsLen&&!t.contextRefsLen&&t.valueRef.current.length===0&&t.acceptEmptySuggestion?.()){e.preventDefault();return}if(!t.isComposing&&(e.key===`ArrowUp`||e.key===`ArrowDown`)){let n=e.key===`ArrowUp`?`up`:`down`;if(t.tryInputHistoryArrow?.(n)){e.preventDefault(),t.adjustHeight();return}}if(e.key===`Escape`&&!t.isComposing&&t.editingUserTurnId){e.preventDefault(),t.onCancelUserMessageEdit?.();return}if(e.key===`Escape`&&!t.isComposing&&t.editingFollowUpId){e.preventDefault(),t.onCancelEditFollowUp?.();return}if(e.key===`Escape`&&!t.isComposing&&!g.current&&t.valueRef.current.length===0&&t.dismissEmptySuggestion?.(),e.key===`Enter`&&e.shiftKey&&!t.isComposing){e.preventDefault(),document.execCommand(`insertText`,!1,`
12
+ `);return}let a=typeof KeyboardEvent<`u`&&e.nativeEvent instanceof KeyboardEvent&&e.nativeEvent.isComposing;if(e.key===`Enter`&&!e.shiftKey&&!t.isComposing&&!g.current&&!a&&!r&&!i){e.preventDefault();let n=!!(t.valueRef.current.trim()||t.attachmentsLen>0||t.contextRefsLen>0);if(e.altKey&&!e.metaKey&&!e.ctrlKey&&n&&t.runBusy&&!t.editingUserTurnId&&!t.editingFollowUpId){t.steerDraft?.();return}if(e.metaKey||e.ctrlKey||e.altKey)return;n&&t.send()}},t[20]=r,t[21]=n,t[22]=i,t[23]=p,t[24]=D):D=t[24];let O;return t[25]!==n||t[26]!==i||t[27]!==o||t[28]!==T||t[29]!==E||t[30]!==D||t[31]!==y||t[32]!==b||t[33]!==S||t[34]!==C||t[35]!==w?(O=(0,Z.jsx)(`div`,{ref:n,hidden:i,role:`textbox`,"aria-multiline":`true`,"aria-label":y,contentEditable:b,suppressContentEditableWarning:!0,spellCheck:!0,className:S,"data-placeholder":o,onInput:C,onCompositionStart:w,onCompositionEnd:T,onPaste:E,onKeyDown:D}),t[25]=n,t[26]=i,t[27]=o,t[28]=T,t[29]=E,t[30]=D,t[31]=y,t[32]=b,t[33]=S,t[34]=C,t[35]=w,t[36]=O):O=t[36],O});function Wp(e){return document.execCommand(`insertText`,!1,e)}function Gp(e){let t=(0,X.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({children:n,dragging:a,className:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a!==void 0&&a&&`ring-2 ring-accent ring-inset`,s;t[5]!==r||t[6]!==o?(s=Y(`chat-composer-surface relative flex min-h-0 w-full flex-col overflow-hidden rounded-2xl shadow-elevated ring-1 ring-inset ring-edge-subtle focus-within:ring-edge dark:shadow-surface`,o,r),t[5]=r,t[6]=o,t[7]=s):s=t[7];let c;return t[8]!==n||t[9]!==i||t[10]!==s?(c=(0,Z.jsx)(`div`,{className:s,...i,children:n}),t[8]=n,t[9]=i,t[10]=s,t[11]=c):c=t[11],c}function Kp({options:e,value:t,label:n,levelLabel:r,disabled:i,onCommit:a,modelControl:o,resetLabel:s,defaultValue:c}){let[l,u]=(0,Q.useState)(),d=(0,Q.useRef)(!1),f=Math.max(0,e.indexOf(t)),p=l??f,m=e.length-1,h=async n=>{if(!(d.current||i)){if(!e[n]||e[n]===t){u(void 0);return}d.current=!0,u(n);try{await a(e[n])}finally{d.current=!1,u(void 0)}}};return(0,Z.jsxs)(`div`,{className:`px-1 pt-1`,children:[(0,Z.jsxs)(`div`,{className:`relative text-center`,children:[(0,Z.jsx)(`p`,{className:`text-base font-medium text-accent-fg`,"aria-hidden":!0,children:r(e[p])}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":s,title:s,disabled:i||t===c,onClick:()=>void h(e.indexOf(c)),className:Y(`absolute -right-2 -top-2 flex size-9 items-center justify-center rounded-lg text-fg-subtle hover:bg-surface-hover hover:text-fg disabled:opacity-40`,ua.focusRingPanel),children:(0,Z.jsx)(Nt,{className:`size-4`,"aria-hidden":!0})}),o]}),(0,Z.jsxs)(`div`,{className:`relative mt-1 h-11`,children:[(0,Z.jsxs)(`div`,{className:`pointer-events-none absolute inset-x-0 top-1/2 h-6 -translate-y-1/2 overflow-hidden rounded-full bg-surface-active`,"aria-hidden":!0,children:[(0,Z.jsx)(`div`,{className:`absolute inset-y-0 left-0 rounded-full bg-accent`,style:{width:`calc(16px + (100% - 32px) * ${m>0?p/m:0})`}}),(0,Z.jsx)(`div`,{className:`absolute inset-x-4 inset-y-0`,children:e.map((e,t)=>(0,Z.jsx)(`span`,{className:Y(`absolute top-1/2 size-1 -translate-x-1/2 -translate-y-1/2 rounded-full`,t<=p?`bg-surface-panel/60`:`bg-fg-subtle/50`),style:{left:`${m>0?t/m*100:0}%`}},e))})]}),(0,Z.jsx)(`input`,{type:`range`,min:0,max:Math.max(0,m),step:1,value:p,"aria-label":n,"aria-valuetext":r(e[p]),disabled:i||m<1,className:Y(`xopc-thinking-effort-slider relative m-0 block h-11 w-full cursor-pointer rounded-lg disabled:cursor-not-allowed`,ua.focusRingPanel),onChange:e=>u(Number(e.currentTarget.value)),onPointerUp:e=>void h(Number(e.currentTarget.value)),onPointerCancel:()=>{d.current||u(void 0)},onKeyUp:e=>{[`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Home`,`End`,`PageUp`,`PageDown`].includes(e.key)&&h(Number(e.currentTarget.value))},onBlur:e=>{l!==void 0&&h(Number(e.currentTarget.value))}})]})]})}function qp({chat:e,sessionModel:t,modelDisabled:n,onModelChange:r,thinkingLevel:i,thinkingDisabled:a,onThinkingChange:o}){let s=h(e=>e.language),c=Kr(fi,di,{revalidateOnFocus:!1}),[l,d]=(0,Q.useState)(`config`),f=(0,Q.useRef)(null),p=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{(l===`models`?p:f).current?.focus()},[l]);let[m,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(``),y=c.data??[],b=y.find(e=>e.id===t),x=!!(t&&c.data&&!b),S=b?So(b,s):t.slice(t.indexOf(`/`)+1)||e.modelConfigure,C=S.split(`/`).at(-1)||S,w=b?.provider||(t.includes(`/`)?t.slice(0,t.indexOf(`/`)):``),T=w?`${C} · ${w}`:C,E=b?.thinking,D=E?.mode===`levels`||E?.mode===`toggle`,O=E?Ds(E,i):i,k=t=>E?.mode===`toggle`&&t!==`off`?e.modelThinkingOn:e.thinkingLevels[t]??t,A=D?k(O):E?.mode===`fixed`?e.modelThinkingFixed:``,M=m||n;async function N(e,t=!1){g(!0),v(``);try{await e(),t&&d(`config`)}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(!1)}}let P=(0,Z.jsxs)(`button`,{ref:f,type:`button`,disabled:M||!y.length,onClick:()=>d(`models`),title:t,className:Y(`mx-auto flex min-h-8 max-w-full items-center justify-center gap-1 rounded-lg px-2 text-sm text-fg-muted hover:bg-surface-hover hover:text-fg`,ua.focusRingPanel),children:[(0,Z.jsxs)(`span`,{className:`min-w-0 truncate`,children:[C,w&&(0,Z.jsxs)(`span`,{className:`text-fg-subtle`,children:[` · `,w]})]}),(0,Z.jsx)(ne,{className:`size-3.5 shrink-0`,"aria-hidden":!0})]});return(0,Z.jsxs)(vi,{onOpenChange:e=>{e||(d(`config`),v(``))},children:[(0,Z.jsx)(bi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"aria-label":`${e.modelConfigLabel}: ${T}${A?` · ${A}`:``}`,title:T,className:Y(`inline-flex h-8 min-w-0 max-w-[min(18rem,calc(100vw-10rem))] items-center gap-1.5 rounded-lg bg-surface-hover/70 px-2.5 text-[13px] text-fg hover:bg-surface-hover`,ua.focusRingPanel,ua.transition),children:[c.isLoading||!t&&y.length>0?(0,Z.jsx)(Yt,{className:`h-4 w-28`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:C}),x?(0,Z.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:e.modelUnavailable}):A&&(0,Z.jsxs)(`span`,{className:`shrink-0 text-fg-muted`,children:[`· `,A]})]}),(0,Z.jsx)(te,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0})]})}),(0,Z.jsx)(gi,{children:(0,Z.jsxs)(_i,{side:`top`,align:`end`,sideOffset:8,collisionPadding:12,"aria-label":e.modelConfigLabel,className:Y(xi,`xopc-composer-config-popover flex max-h-[min(21rem,calc(100dvh-3rem))] w-[min(20rem,calc(100vw-2rem))] flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay p-3 shadow-popover`),children:[l===`models`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`button`,{ref:p,type:`button`,onClick:()=>d(`config`),className:Y(`mb-2 flex min-h-11 shrink-0 items-center gap-2 rounded-lg px-2 text-sm text-fg hover:bg-surface-hover`,ua.focusRingPanel),children:[(0,Z.jsx)(j,{className:`size-4`,"aria-hidden":!0}),e.modelBack]}),(0,Z.jsx)(Co,{models:y,value:t,disabled:M,groupByProvider:!0,searchPlaceholder:e.modelSearchPlaceholder,noMatches:e.modelNoMatches,onChange:e=>{let t=y.find(t=>t.id===e),n=t?.thinking?Ds(t.thinking,O):O;N(()=>r(e,n),!0)}})]}):(0,Z.jsx)(`div`,{className:`min-w-0 shrink-0`,children:c.isLoading?(0,Z.jsxs)(`div`,{className:`space-y-4 p-3`,children:[(0,Z.jsx)(Yt,{className:`h-6 w-40`}),(0,Z.jsx)(Yt,{className:`h-4 w-24`}),(0,Z.jsx)(Yt,{className:`h-11 w-full`})]}):(0,Z.jsxs)(Z.Fragment,{children:[!D&&P,x&&(0,Z.jsx)(`p`,{className:`px-3 py-2 text-sm text-fg-muted`,children:e.modelUnavailable}),b&&(0,Z.jsx)(`div`,{children:D?(0,Z.jsx)(Kp,{options:E.options,value:O,label:e.modelThinkingLabel,levelLabel:k,disabled:M||a,modelControl:P,resetLabel:e.modelThinkingReset,defaultValue:E.initialValue,onCommit:e=>N(()=>o(e))}):(0,Z.jsx)(`p`,{className:`px-1 pb-2 text-center text-xs text-fg-muted`,children:E?.mode===`none`?e.thinkingUnsupported:E?.mode===`fixed`?e.modelThinkingFixed:e.modelThinkingUnknown})})]})}),m&&(0,Z.jsx)(`span`,{className:`sr-only`,role:`status`,children:e.modelConfigSaving}),(_||c.error)&&(0,Z.jsx)(`div`,{className:`shrink-0 break-words px-1 py-2 text-xs`,"aria-live":`polite`,children:_?(0,Z.jsx)(`span`,{role:`alert`,className:`text-danger`,children:_}):(0,Z.jsx)(`button`,{type:`button`,onClick:()=>void c.mutate(),className:Y(`text-accent-fg`,ua.focusRingPanel),children:e.modelRetry})}),l===`models`&&(0,Z.jsx)(u,{to:`/settings/capabilities/models`,className:Y(`shrink-0 rounded-lg border-t border-edge-subtle px-3 py-3 text-sm text-fg-muted hover:bg-surface-hover`,ua.focusRingPanel),children:y.length?e.modelManage:e.modelConfigure})]})})]})}function Jp(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function Yp(e){let t=(0,X.c)(12),{disabled:n,runBusy:r,attachmentCount:i,maxAttachments:a,chat:o,onPickFiles:s}=e,c=i>=a,l;t[0]!==i||t[1]!==c||t[2]!==o.attachFile||t[3]!==o.maxAttachmentsReached||t[4]!==a?(l=c?Jp(o.maxAttachmentsReached,{max:a}):`${o.attachFile} (${i}/${a})`,t[0]=i,t[1]=c,t[2]=o.attachFile,t[3]=o.maxAttachmentsReached,t[4]=a,t[5]=l):l=t[5];let u=l,d;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=Y(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,ua.transition,ua.press,ua.focusRingPanel,`disabled:cursor-not-allowed disabled:opacity-50`),t[6]=d):d=t[6];let f=c||n||r,p;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(jt,{className:`size-4`}),t[7]=p):p=t[7];let m;return t[8]!==s||t[9]!==f||t[10]!==u?(m=(0,Z.jsx)(`button`,{type:`button`,className:d,disabled:f,title:u,"aria-label":u,onClick:s,children:p}),t[8]=s,t[9]=f,t[10]=u,t[11]=m):m=t[11],m}function Xp(e){let t=(0,X.c)(12),{disabled:n,voiceActive:r,runBusy:i,hasDraft:a,showSteeringInterrupt:o,chat:s,onSend:c,onAbort:l,onInterrupt:u}=e,d;return t[0]!==n||t[1]!==a||t[2]!==s.abort||t[3]!==s.sendMessage||t[4]!==s.steeringInterruptSend||t[5]!==l||t[6]!==u||t[7]!==c||t[8]!==i||t[9]!==o||t[10]!==r?(d=(0,Z.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:i?(0,Z.jsxs)(Z.Fragment,{children:[o&&u?(0,Z.jsx)(`button`,{type:`button`,className:Y(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg border border-transparent text-accent-fg hover:bg-accent-soft dark:hover:bg-accent-soft`,ua.transition,ua.press,ua.focusRingPanel),title:s.steeringInterruptSend,"aria-label":s.steeringInterruptSend,onClick:()=>void u(),children:(0,Z.jsx)(fe,{className:`size-4 stroke-[1.75]`})}):null,(0,Z.jsx)(`button`,{type:`button`,className:Y(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover/70 text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/50`,ua.transition,ua.press,ua.focusRingPanel),title:s.abort,"aria-label":s.abort,onClick:l,children:(0,Z.jsx)(Vt,{className:`size-4 stroke-[1.75]`})})]}):(0,Z.jsx)(`button`,{type:`button`,className:Y(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg border transition-colors duration-150 ease-out`,ua.press,ua.focusRingPanel,a?`border-transparent text-accent-fg hover:bg-accent-soft dark:text-accent-fg dark:hover:bg-accent-soft`:`border-transparent text-fg-disabled`),disabled:n||r||!a,title:s.sendMessage,"aria-label":s.sendMessage,onClick:c,children:(0,Z.jsx)(fe,{className:`size-4 stroke-[1.75]`})})}),t[0]=n,t[1]=a,t[2]=s.abort,t[3]=s.sendMessage,t[4]=s.steeringInterruptSend,t[5]=l,t[6]=u,t[7]=c,t[8]=i,t[9]=o,t[10]=r,t[11]=d):d=t[11],d}function Zp(e){let t=(0,X.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Y(`flex flex-wrap items-center gap-2 px-3 py-1.5 sm:px-4 sm:py-2.5`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var Qp=(0,Q.memo)(function(e){let t=(0,X.c)(42),{disabled:n,sendDisabled:r,runBusy:i,chat:a,hasDraft:o,showSteeringInterrupt:s,attachmentCount:c,maxAttachments:l,onPickFiles:u,thinkingLevel:d,onThinkingChange:f,voiceActive:p,onStartVoiceInput:m,voiceConversationEnabled:h,onStartVoiceConversation:g,onSend:_,onAbort:v,onInterrupt:y,sessionModel:b,showModelSelector:x,onModelChange:S,modelDisabled:C}=e,w=r!==void 0&&r;if(p)return null;let T;t[0]!==c||t[1]!==n||t[2]!==a||t[3]!==l||t[4]!==u||t[5]!==i?(T=(0,Z.jsx)(Yp,{disabled:n,runBusy:i,attachmentCount:c,maxAttachments:l,chat:a,onPickFiles:u}),t[0]=c,t[1]=n,t[2]=a,t[3]=l,t[4]=u,t[5]=i,t[6]=T):T=t[6];let E;t[7]!==n||t[8]!==a||t[9]!==C||t[10]!==S||t[11]!==f||t[12]!==b||t[13]!==x||t[14]!==d?(E=x?(0,Z.jsx)(qp,{chat:a,sessionModel:b,modelDisabled:C,onModelChange:S,thinkingLevel:d,thinkingDisabled:n||C,onThinkingChange:f}):null,t[7]=n,t[8]=a,t[9]=C,t[10]=S,t[11]=f,t[12]=b,t[13]=x,t[14]=d,t[15]=E):E=t[15];let D;t[16]!==n||t[17]!==a||t[18]!==g||t[19]!==m||t[20]!==p||t[21]!==h?(D=p?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ei,{disabled:n,chat:a,onStart:m}),(0,Z.jsx)(`button`,{type:`button`,className:Y(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg border border-transparent text-fg-subtle hover:bg-surface-hover hover:text-fg`,ua.transition,ua.press,ua.focusRingPanel,`disabled:cursor-not-allowed disabled:opacity-50`),disabled:n||!h,title:a.voiceConversation,"aria-label":a.voiceConversation,onClick:()=>void g(),children:(0,Z.jsx)(R,{className:`size-4 stroke-[1.75]`})})]}),t[16]=n,t[17]=a,t[18]=g,t[19]=m,t[20]=p,t[21]=h,t[22]=D):D=t[22];let O=n||w,k;t[23]!==o||t[24]!==a||t[25]!==v||t[26]!==y||t[27]!==_||t[28]!==i||t[29]!==s||t[30]!==O||t[31]!==p?(k=(0,Z.jsx)(Xp,{disabled:O,voiceActive:p,runBusy:i,hasDraft:o,showSteeringInterrupt:s,chat:a,onSend:_,onAbort:v,onInterrupt:y}),t[23]=o,t[24]=a,t[25]=v,t[26]=y,t[27]=_,t[28]=i,t[29]=s,t[30]=O,t[31]=p,t[32]=k):k=t[32];let A;t[33]!==D||t[34]!==k?(A=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[D,k]}),t[33]=D,t[34]=k,t[35]=A):A=t[35];let j;t[36]!==E||t[37]!==A?(j=(0,Z.jsxs)(`div`,{className:`ml-auto flex min-w-0 items-center gap-2`,children:[E,A]}),t[36]=E,t[37]=A,t[38]=j):j=t[38];let M;return t[39]!==T||t[40]!==j?(M=(0,Z.jsxs)(Zp,{children:[T,j]}),t[39]=T,t[40]=j,t[41]=M):M=t[41],M}),$p=(0,Q.memo)(function(e){let t=(0,X.c)(18),{spotlight:n,onPickPrompt:r,compact:i}=e,a=i!==void 0&&i,o=h(em),s=n.recommendation,c=a?`gap-4 pb-3 pt-5`:`gap-5 pb-6 pt-32 sm:pt-36 [@media(max-height:800px)]:pt-12`,l;t[0]===c?l=t[1]:(l=Y(`flex flex-col items-center px-3 text-center`,c),t[0]=c,t[1]=l);let u=a?`size-24`:`size-28 sm:size-32 [@media(max-height:800px)]:size-24`,d;t[2]===u?d=t[3]:(d=Y(`shrink-0`,u),t[2]=u,t[3]=d);let f;t[4]!==o||t[5]!==d?(f=(0,Z.jsx)(wa,{className:d,interactive:!0,language:o,mood:`listen`}),t[4]=o,t[5]=d,t[6]=f):f=t[6];let p;t[7]===n.headline?p=t[8]:(p=(0,Z.jsx)(`h1`,{className:`max-w-xl text-balance text-xl font-semibold tracking-tight text-fg`,children:n.headline}),t[7]=n.headline,t[8]=p);let m;t[9]!==r||t[10]!==s||t[11]!==n.contextKind?(m=s?(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>r({suggestionId:s.id,contextKind:n.contextKind,prompt:s.prompt}),className:Y(`mt-4 flex min-h-16 w-full max-w-xl items-center gap-3 rounded-xl border border-edge bg-surface-panel px-4 py-3 text-left hover:border-edge-strong hover:bg-surface-hover`,ua.transition,ua.press,ua.focusRingPanel),children:[(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`line-clamp-2 block text-sm font-medium leading-snug text-fg sm:text-[0.9375rem]`,children:s.title}),(0,Z.jsx)(`span`,{className:`mt-1 block truncate text-xs text-fg-muted`,children:s.reason})]}),(0,Z.jsx)(ne,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0})]}):null,t[9]=r,t[10]=s,t[11]=n.contextKind,t[12]=m):m=t[12];let g;return t[13]!==l||t[14]!==f||t[15]!==p||t[16]!==m?(g=(0,Z.jsxs)(`div`,{className:l,children:[f,p,m]}),t[13]=l,t[14]=f,t[15]=p,t[16]=m,t[17]=g):g=t[17],g});function em(e){return e.language}function tm({provenance:e}){let t=h(e=>e.language),n=t===`zh`,r=y(t).chat.provenanceErrors,[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(!1),[f,m]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(0),O=n?{follow_up:`跟进你交代的事情`,discussion:`延续之前的讨论`,change:`关注的事情有新进展`,prepared:`之前的准备有了结果`}:{follow_up:`Following up as requested`,discussion:`Continuing our discussion`,change:`An update on what matters`,prepared:`Your preparation is ready`};(0,Q.useEffect)(()=>{if(!i)return;let t=!0;return s(void 0),l(``),g(p(`/api/personal-agent/outreach/${e.outreachId}/provenance`)).then(e=>{if(!e.ok)throw Error(e.error??r.load);t&&s(Gr.parse(e.payload))}).catch(e=>{t&&l(String(e))}),()=>{t=!1}},[i,e.outreachId,_,r.load]);async function k(t,n={}){d(!0),l(``);try{let i=await g(p(`/api/personal-agent/outreach/${e.outreachId}/feedback`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({idempotencyKey:crypto.randomUUID(),kind:t,scope:`thread`,...n})});if(!i.ok)throw Error(i.error??r.save);m(!1),v(e=>e+1)}catch(e){l(String(e))}finally{d(!1)}}async function A(){let e=o?.strategy?.versions[0];if(!(!o||!e||u)){d(!0),l(``);try{let t=await g(p(`/api/personal-agent/attention/${o.thread.id}/strategy/rollback`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({versionId:e.id,revision:o.thread.revision,idempotencyKey:crypto.randomUUID()})});if(!t.ok)throw Error(t.error??r.undo);m(!1),v(e=>e+1)}catch(e){l(String(e))}finally{d(!1)}}}let j=o&&[`completed`,`expired`].includes(o.thread.status);return(0,Z.jsxs)(D,{open:i,onOpenChange:e=>{a(e),m(!1)},children:[(0,Z.jsx)(x,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`${Oo} mt-2`,"aria-label":n?`查看主动联系的缘由`:`Why this message`,children:(0,Z.jsx)(ko,{icon:(0,Z.jsx)(Bt,{strokeWidth:1.5}),title:O[e.reasonKind],trailing:(0,Z.jsx)(ne,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0})})})}),(0,Z.jsxs)(w,{children:[(0,Z.jsx)(b,{className:`fixed inset-0 z-50 bg-black/20`}),(0,Z.jsxs)(T,{className:`fixed inset-x-0 bottom-0 z-50 flex h-[min(28rem,75dvh)] flex-col overflow-hidden rounded-t-2xl border border-edge bg-surface-overlay sm:inset-x-auto sm:bottom-auto sm:left-1/2 sm:top-1/2 sm:w-[min(25rem,calc(100vw-2rem))] sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-xl`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge px-5 py-4`,children:[(0,Z.jsx)(E,{className:`text-sm font-medium text-fg`,children:n?`为什么联系你`:`Why I reached out`}),(0,Z.jsx)(C,{className:`rounded p-1 text-fg-muted hover:text-fg`,"aria-label":n?`关闭`:`Close`,children:(0,Z.jsx)(qt,{className:`size-4`})})]}),(0,Z.jsx)(S,{className:`sr-only`,children:n?`消息的依据、时机与后续跟进`:`Sources, timing, and follow-up for this message`}),(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4 text-sm`,children:[!o&&!c&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Yt,{className:`h-5 w-3/4`}),(0,Z.jsx)(Yt,{className:`h-20 w-full`}),(0,Z.jsx)(Yt,{className:`h-12 w-full`})]}),o&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`mb-1 font-medium text-fg`,children:n?`为什么关注`:`Why this topic`}),(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:o.sourcesAvailable?o.thread.subject:n?`原始依据已不可用`:`The original sources are no longer available`}),o.sourcesAvailable&&e.authority===`inferred`&&(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n?`根据之前的讨论判断你可能仍在关注,并非明确委托。`:`Inferred from our discussion; this is not an explicit request.`})]}),o.sourcesAvailable&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`mb-1 font-medium text-fg`,children:n?`为什么现在联系`:`Why now`}),(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:o.whyNow})]}),o.sources.map(e=>(0,Z.jsxs)(`a`,{className:`block rounded border border-edge p-2 text-fg-muted hover:text-accent`,onClick:()=>a(!1),href:`#/chat/${encodeURIComponent(e.conversationId)}?entryId=${encodeURIComponent(e.entryId)}`,children:[(0,Z.jsx)(`span`,{className:`line-clamp-2 text-xs`,children:e.excerpt}),(0,Z.jsxs)(`span`,{className:`mt-1 block text-xs text-accent`,children:[n?`查看相关对话`:`View conversation`,` ↗`]})]},e.entryId)),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`mb-1 font-medium text-fg`,children:n?`后续`:`Next`}),(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:j?n?`已停止关注`:`No longer following`:o.thread.status===`paused`?n?`已延后跟进`:`Follow-up postponed`:n?`有新的有效进展时,再判断是否值得交流。`:`I will reassess when there is something useful to share.`})]}),f&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,disabled:u,className:`rounded border border-edge px-3 py-2`,onClick:()=>void k(`defer`,{until:Date.now()+7*864e5}),children:n?`下周再跟进`:`Next week`}),(0,Z.jsx)(`button`,{type:`button`,disabled:u,className:`rounded border border-edge px-3 py-2`,onClick:()=>void k(`adjust`,{preparation:`thorough`}),children:n?`以后先准备完整`:`Prepare more thoroughly`}),(0,Z.jsx)(`button`,{type:`button`,disabled:u,className:`rounded border border-edge px-3 py-2`,onClick:()=>void k(`adjust`,{preparation:`brief`}),children:n?`以后简短一点`:`Keep it brief`})]}),o.strategy&&(0,Z.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[(0,Z.jsxs)(`p`,{children:[n?`准备方式:`:`Preparation: `,o.strategy.preparation===`thorough`?n?`先准备完整`:`Thorough`:o.strategy.preparation===`brief`?n?`简短交流`:`Brief`:n?`按当前内容判断`:`Based on the topic`]}),o.strategy.versions.length>0&&(0,Z.jsxs)(`details`,{className:`mt-2`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer`,children:n?`查看调整记录`:`View adjustments`}),(0,Z.jsx)(`ul`,{className:`mt-2 space-y-1`,children:o.strategy.versions.map(e=>(0,Z.jsxs)(`li`,{children:[n?{stop:`停止关注`,defer:`延后跟进`,adjust:`调整准备方式`,rollback:`撤销调整`}[e.kind]:{stop:`Stopped`,defer:`Postponed`,adjust:`Preparation changed`,rollback:`Undone`}[e.kind],` · `,new Date(e.createdAt).toLocaleString(n?`zh-CN`:`en`)]},e.id))})]})]})]}),c&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-danger`,children:c})]}),(0,Z.jsxs)(`div`,{className:`flex gap-3 border-t border-edge px-5 py-3 text-xs`,children:[(0,Z.jsx)(`button`,{type:`button`,disabled:!o||u||!!j,onClick:()=>m(e=>!e),className:`text-fg-muted hover:text-fg disabled:opacity-50`,children:n?`调整跟进`:`Adjust follow-up`}),(0,Z.jsx)(`button`,{type:`button`,disabled:!o||u||!!j,onClick:()=>void k(`stop`),className:`text-fg-muted hover:text-fg disabled:opacity-50`,children:n?`停止关注`:`Stop following`}),o?.strategy?.versions.length?(0,Z.jsx)(`button`,{type:`button`,disabled:u||!o.sourcesAvailable,onClick:()=>void A(),className:`ml-auto text-fg-muted hover:text-fg disabled:opacity-50`,children:n?`撤销最近调整`:`Undo latest`}):null]})]})]})]})}function nm(e,t){let n=t?.split(`;`)[0]?.trim();return!n?.startsWith(`image/`)||e.type===n?e:new Blob([e],{type:n})}function rm(e,t){let n=(0,X.c)(29),r;n[0]!==e.mimeType||n[1]!==e.type?(r=e.type===`image`||e.mimeType?.startsWith(`image/`)===!0,n[0]=e.mimeType,n[1]=e.type,n[2]=r):r=n[2];let i=r,a;n[3]!==e||n[4]!==i?(a=i?oi(e):void 0,n[3]=e,n[4]=i,n[5]=a):a=n[5];let o=a,s;bb0:{if(!o){s=void 0;break bb0}let t=e.mimeType?.startsWith(`image/`)?e.mimeType:`image/png`,r;n[6]!==o||n[7]!==t?(r=ai(t,o),n[6]=o,n[7]=t,n[8]=r):r=n[8],s=r}let c=s,l=`${e.uri??``}\n${t.conversationId??``}\n${e.taskId??``}`,[u,d]=(0,Q.useState)(),f;n[9]!==e.mimeType||n[10]!==e.taskId||n[11]!==e.uri||n[12]!==c||n[13]!==i||n[14]!==t.authToken||n[15]!==t.conversationId||n[16]!==l?(f=()=>{if(c||!e.uri||!i){d(void 0);return}if(!String(t.authToken??``).trim()){d(void 0);return}let n,r=!1;return d({key:l,status:`loading`}),(async()=>{let i=await Me({uri:e.uri,conversationId:t.conversationId,taskId:e.taskId});if(r)return;if(!i.ok){d({key:l,status:`error`});return}let a=URL.createObjectURL(nm(i.blob,e.mimeType));n=a,d({key:l,blobUrl:a,status:`loaded`})})(),()=>{r=!0,n&&URL.revokeObjectURL(n)}},n[9]=e.mimeType,n[10]=e.taskId,n[11]=e.uri,n[12]=c,n[13]=i,n[14]=t.authToken,n[15]=t.conversationId,n[16]=l,n[17]=f):f=n[17];let p;n[18]!==e.taskId||n[19]!==e.uri||n[20]!==c||n[21]!==i||n[22]!==t.authToken||n[23]!==t.conversationId||n[24]!==l?(p=[c,e.taskId,e.uri,i,t.authToken,t.conversationId,l],n[18]=e.taskId,n[19]=e.uri,n[20]=c,n[21]=i,n[22]=t.authToken,n[23]=t.conversationId,n[24]=l,n[25]=p):p=n[25],(0,Q.useEffect)(f,p);let m=u?.key===l?u:void 0,h=c??m?.blobUrl??``,g=!c&&m?.status===`error`,_;return n[26]!==h||n[27]!==g?(_={src:h,error:g},n[26]=h,n[27]=g,n[28]=_):_=n[28],_}function im(e){let t=(0,X.c)(51),{attachment:n,authToken:r,conversationId:i,showDelete:a,onDelete:o,imageSize:s,compact:c,className:l,overflowLabel:u,onOpen:d}=e,f=a!==void 0&&a,p=s===void 0?`thumbnail`:s,m=c!==void 0&&c,g=h(am),_;t[0]===g?_=t[1]:(_=y(g),t[0]=g,t[1]=_);let v=_,b=(0,Q.useId)(),x;t[2]!==n.mimeType||t[3]!==n.type?(x=n.mimeType?.startsWith(`image/`)||n.type===`image`,t[2]=n.mimeType,t[3]=n.type,t[4]=x):x=t[4];let S=x,C;t[5]!==r||t[6]!==i?(C={authToken:r,conversationId:i},t[5]=r,t[6]=i,t[7]=C):C=t[7];let w=rm(n,C),T;t[8]===n?T=t[9]:(T=!!n.uri&&!oi(n),t[8]=n,t[9]=T);let E=T,D;t[10]!==r||t[11]!==E?(D=E&&!String(r??``).trim(),t[10]=r,t[11]=E,t[12]=D):D=t[12];let O=D,k=n.mimeType===`application/pdf`,A;t[13]!==n.mimeType||t[14]!==n.name?(A=n.mimeType?.includes(`spreadsheetml`)||n.name?.toLowerCase().endsWith(`.xlsx`)||n.name?.toLowerCase().endsWith(`.xls`),t[13]=n.mimeType,t[14]=n.name,t[15]=A):A=t[15];let j=A,M=n.name??`file`,N=n.type===`pasted_text`,P=N&&!O,F=n.mimeType?.split(`;`,1)[0]?.trim().toLowerCase()===`text/html`?`HTML`:n.mimeType?.split(`;`,1)[0]?.trim().toLowerCase()===`application/json`?`JSON`:`TXT`,I;t[16]!==n.size||t[17]!==F?(I=typeof n.size==`number`?`${F} · ${si(n.size)}`:F,t[16]=n.size,t[17]=F,t[18]=I):I=t[18];let L=I,R=O?`${M} — ${v.chat.attachmentPreviewMissingAuth}`:M,z=v.chat.attachmentPreviewMissingAuth,B=p===`single`?`size-full object-contain`:p===`grid-cell`?`size-full object-cover`:`max-h-16 w-full object-cover`,V=p===`single`?m?`w-36 max-w-full`:`w-44 max-w-full`:p===`grid-cell`?`min-h-0 w-full`:`max-w-[10rem]`,H=p===`grid-cell`?`relative block aspect-square w-full min-w-0 overflow-hidden rounded-md border border-edge dark:border-edge`:p===`single`?`relative block aspect-[4/3] w-full overflow-hidden rounded-md border border-edge bg-surface-hover dark:border-edge`:`block w-full overflow-hidden rounded-md border border-edge dark:border-edge`,U=p===`grid-cell`?`w-full min-h-0`:`inline-block`,W;t[19]!==l||t[20]!==U?(W=Y(`group relative min-w-0`,U,l),t[19]=l,t[20]=U,t[21]=W):W=t[21];let G;t[22]!==n||t[23]!==M||t[24]!==H||t[25]!==w||t[26]!==B||t[27]!==V||t[28]!==j||t[29]!==S||t[30]!==N||t[31]!==k||t[32]!==v.chat.attachmentPreviewLoadError||t[33]!==v.chat.pastedText||t[34]!==R||t[35]!==b||t[36]!==z||t[37]!==d||t[38]!==u||t[39]!==L||t[40]!==O||t[41]!==P?(G=S?(0,Z.jsxs)(`div`,{className:V,children:[(0,Z.jsxs)(`div`,{className:`relative size-full min-h-0`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:Y(H,ua.transition,ua.press,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),onClick:()=>d(n),title:R,"aria-label":R,"aria-describedby":O?b:void 0,children:[w.src?(0,Z.jsx)(`img`,{src:w.src,alt:M,className:B,decoding:`async`}):w.error||O?(0,Z.jsxs)(`span`,{className:`flex size-full flex-col items-center justify-center gap-1 bg-surface-hover px-2 text-center text-[10px] text-fg-muted`,title:O?z:v.chat.attachmentPreviewLoadError,children:[(0,Z.jsx)(Re,{className:`size-5`,strokeWidth:1.5,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:O?z:v.chat.attachmentPreviewLoadError})]}):(0,Z.jsx)(`span`,{className:`block size-full animate-pulse bg-surface-active`,"aria-hidden":!0}),u?(0,Z.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center bg-black/55 text-lg font-semibold text-white`,children:u}):null]}),k?(0,Z.jsx)(`div`,{className:`pointer-events-none absolute bottom-1 right-1 rounded bg-black/60 px-1.5 py-0.5 text-[10px] font-semibold text-white`,"aria-hidden":!0,children:`PDF`}):null]}),O?(0,Z.jsx)(`p`,{id:b,className:`mt-1 line-clamp-2 text-[10px] leading-snug text-amber-600 dark:text-amber-500`,children:z}):null]}):(0,Z.jsx)(`div`,{className:Y(`max-w-[14rem]`,P&&`inline-flex max-w-full`),children:(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>d(n),title:R,"aria-label":R,"aria-describedby":O?b:void 0,className:Y(`flex min-w-0 border border-edge bg-surface-hover text-left text-xs text-fg-muted hover:bg-surface-active dark:border-edge`,P?`w-auto max-w-full items-center gap-1.5 rounded-full px-2.5 py-1`:`w-full gap-2 rounded-md px-2 py-1.5`,O?`items-start`:`items-center`,ua.transition,ua.press,ua.focusRingPanel),children:[N?(0,Z.jsx)(Ce,{className:Y(`shrink-0 text-accent-fg`,P?`size-3.5`:`size-8`),"aria-hidden":!0}):j?(0,Z.jsx)(ge,{className:`size-8 shrink-0 text-fg-subtle`,"aria-hidden":!0}):(0,Z.jsx)(Ee,{className:`size-8 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:Y(`truncate text-fg`,P?`inline`:`block`),children:N?v.chat.pastedText:M}),P?(0,Z.jsxs)(`span`,{className:`ml-1 whitespace-nowrap text-fg-subtle`,children:[`· `,L]}):null,O?(0,Z.jsx)(`span`,{id:b,className:`mt-0.5 line-clamp-2 block text-[10px] font-normal leading-snug text-amber-600 dark:text-amber-500`,children:z}):null]})]})}),t[22]=n,t[23]=M,t[24]=H,t[25]=w,t[26]=B,t[27]=V,t[28]=j,t[29]=S,t[30]=N,t[31]=k,t[32]=v.chat.attachmentPreviewLoadError,t[33]=v.chat.pastedText,t[34]=R,t[35]=b,t[36]=z,t[37]=d,t[38]=u,t[39]=L,t[40]=O,t[41]=P,t[42]=G):G=t[42];let ee;t[43]!==v.chat.attachmentPreviewRemove||t[44]!==o||t[45]!==f?(ee=f?(0,Z.jsx)(`button`,{type:`button`,className:Y(`absolute -right-1 -top-1 flex size-5 items-center justify-center rounded-full border border-edge bg-surface-panel text-fg-muted shadow-surface hover:text-fg dark:border-edge`,ua.transition,ua.press,ua.focusRingPanel),onClick:e=>{e.stopPropagation(),o?.()},title:v.chat.attachmentPreviewRemove,"aria-label":v.chat.attachmentPreviewRemove,children:(0,Z.jsx)(qt,{className:`size-3`})}):null,t[43]=v.chat.attachmentPreviewRemove,t[44]=o,t[45]=f,t[46]=ee):ee=t[46];let te;return t[47]!==W||t[48]!==G||t[49]!==ee?(te=(0,Z.jsxs)(`div`,{className:W,children:[G,ee]}),t[47]=W,t[48]=G,t[49]=ee,t[50]=te):te=t[50],te}function am(e){return e.language}function om(e){let t=(0,X.c)(11),{layout:n,conversationId:r,workspaceConversationId:i,projectId:a}=e,[o,s]=(0,Q.useState)(null),c=Li(sm),l;t[0]!==r||t[1]!==n||t[2]!==a||t[3]!==c||t[4]!==i?(l=(e,t)=>{let o=i??r;if(n===`assistant`&&e.type!==`image`&&!e.mimeType?.startsWith(`image/`)&&e.workspaceRelativePath?.trim()&&(a?.trim()||o?.trim())){c(e.workspaceRelativePath.trim(),null,a,o,t);return}s(e)},t[0]=r,t[1]=n,t[2]=a,t[3]=c,t[4]=i,t[5]=l):l=t[5];let u=l,d;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>s(null),t[6]=d):d=t[6];let f=d,p=o!==null,m;return t[7]!==o||t[8]!==u||t[9]!==p?(m={active:o,open:p,openAttachment:u,closePreview:f,selectAttachment:s},t[7]=o,t[8]=u,t[9]=p,t[10]=m):m=t[10],m}function sm(e){return e.setPath}function cm(e){let t=Math.max(0,Math.floor(e));return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}function lm(e){return typeof e==`number`&&Number.isFinite(e)&&e>0}function um(e){let t=(0,X.c)(9),{att:n,conversationId:r}=e,i;t[0]!==n.content||t[1]!==n.data||t[2]!==n.taskId||t[3]!==n.uri||t[4]!==r?(i=JSON.stringify([n.uri,n.content,n.data,n.taskId,r]),t[0]=n.content,t[1]=n.data,t[2]=n.taskId,t[3]=n.uri,t[4]=r,t[5]=i):i=t[5];let a;return t[6]!==e||t[7]!==i?(a=(0,Z.jsx)(dm,{...e},i),t[6]=e,t[7]=i,t[8]=a):a=t[8],a}function dm({att:e,align:t=`start`,embedded:n=!1,conversationId:r}){let i=h(e=>e.language),a=i===`zh`,o=y(i).chat,s=(0,Q.useId)(),c=(0,Q.useRef)(null),[l,u]=(0,Q.useState)(),[d,m]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(0),[v,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(1),[D,O]=(0,Q.useState)(0),k=D||(lm(e.durationSeconds)?e.durationSeconds:0),[A,j]=(0,Q.useState)(0),M=e.content??e.data;(0,Q.useEffect)(()=>{let t=new AbortController,n;return m(!1),u(void 0),(async()=>{try{if(M){u(`data:${e.mimeType||`audio/mpeg`};base64,${M.replace(/\s/g,``)}`);return}if(!e.uri)throw Error(`Missing audio source`);let i=await f(p(ci(e.uri,r,e.taskId)),{signal:t.signal});if(!i.ok)throw Error(`Audio unavailable`);let a=await i.blob();if(t.signal.aborted)return;n=URL.createObjectURL(a),u(n)}catch{t.signal.aborted||m(!0)}})(),()=>{t.abort(),n&&URL.revokeObjectURL(n)}},[M,e.mimeType,e.uri,e.taskId,r,g]),(0,Q.useEffect)(()=>{let e=c.current,t=()=>e?.pause(),n=e=>{let n=e.detail?.id;n&&n!==s&&t()};return window.addEventListener(`xopc-voice-recording-start`,t),window.addEventListener(`xopc-voice-playback-start`,n),()=>{t(),window.removeEventListener(`xopc-voice-recording-start`,t),window.removeEventListener(`xopc-voice-playback-start`,n)}},[s]);let N=()=>{let e=c.current;if(d){_(e=>e+1);return}!e||!l||(v?e.pause():e.play().catch(e=>{e instanceof DOMException&&e.name===`AbortError`||m(!0)}))},P=()=>{let e=c.current?.duration;lm(e)&&O(e)},F=a?`播放选项`:`Playback options`;return(0,Z.jsx)(`div`,{className:Y(`flex min-w-0`,t===`end`&&`justify-end`,t===`center`&&`justify-center`),children:(0,Z.jsxs)(`div`,{className:Y(`w-60 max-w-full rounded-xl`,!n&&`bg-surface-base px-1`),role:`group`,"aria-label":o.voiceAriaRegion,children:[!l&&!d?(0,Z.jsx)(`span`,{className:`sr-only`,role:`status`,children:o.voiceLoading}):null,(0,Z.jsxs)(`div`,{className:`flex min-h-14 items-center gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:N,disabled:!l&&!d,className:`inline-flex size-11 shrink-0 items-center justify-center rounded-full text-fg hover:bg-surface-hover disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":d?a?`重试播放`:`Retry playback`:v?o.voicePause:o.voicePlay,children:d?(0,Z.jsx)(Nt,{className:`size-5`,"aria-hidden":!0}):v?(0,Z.jsx)(Ot,{className:`size-5`,"aria-hidden":!0}):(0,Z.jsx)(At,{className:`size-5`,"aria-hidden":!0})}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,"aria-hidden":!0,children:!l&&!d?(0,Z.jsx)(Yt,{className:`h-1 w-full`}):(0,Z.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${k>0?Math.min(100,A/k*100):0}%`}})})}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>S(!x),"aria-label":F,"aria-expanded":x,"aria-controls":`${s}-options`,className:`flex min-h-11 shrink-0 items-center gap-1 rounded-lg px-2 text-[13px] tabular-nums text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[A>0||k>0?cm(A>0?A:k):`—`,(0,Z.jsx)(te,{className:Y(`size-3`,x&&`rotate-180`),"aria-hidden":!0})]})]}),d?(0,Z.jsx)(`p`,{role:`alert`,className:`px-2 pb-2 text-xs text-fg-muted`,children:a?`音频无法播放,请重试`:`Audio unavailable. Try again.`}):null,x?(0,Z.jsxs)(`div`,{id:`${s}-options`,className:`space-y-2 px-2 pb-3`,children:[(0,Z.jsxs)(`label`,{className:`block text-xs text-fg-muted`,children:[a?`播放进度`:`Playback position`,(0,Z.jsx)(`input`,{type:`range`,min:0,max:k||1,step:.1,value:Math.min(A,k),disabled:!l||!k||d,onChange:e=>{c.current&&(c.current.currentTime=Number(e.target.value),j(Number(e.target.value)))},className:`block h-11 w-full accent-accent`})]}),(0,Z.jsx)(le,{contentClassName:`[&_button]:min-h-11`,value:String(T),allowEmpty:!1,placeholder:`1×`,ariaLabel:o.voicePlaybackSpeed,triggerClassName:`min-h-11`,options:[.75,1,1.25,1.5,2].map(e=>({value:String(e),label:`${e}×`})),onChange:e=>{let t=Number(e);E(t),c.current&&(c.current.playbackRate=t)}})]}):null,e.extractedText?.trim()?(0,Z.jsxs)(`div`,{className:`px-2 pb-1`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`min-h-11 rounded-lg text-xs text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>w(!C),"aria-expanded":C,"aria-controls":`${s}-text`,children:C?a?`收起文字`:`Hide transcript`:a?`查看文字`:`Show transcript`}),C?(0,Z.jsx)(`p`,{id:`${s}-text`,className:`whitespace-pre-wrap break-words pb-2 text-sm text-fg-muted`,children:e.extractedText}):null]}):null,(0,Z.jsx)(`audio`,{ref:c,src:l,preload:`metadata`,className:`hidden`,onLoadedMetadata:P,onDurationChange:P,onTimeUpdate:e=>j(e.currentTarget.currentTime),onError:()=>{l&&(b(!1),m(!0))},onPlay:e=>{e.currentTarget.playbackRate=T,b(!0),window.dispatchEvent(new CustomEvent(`xopc-voice-playback-start`,{detail:{id:s}}))},onPause:()=>b(!1),onEnded:()=>{b(!1),j(0)}})]})})}function fm(e){return e.type===`voice`||e.type===`audio`||e.mimeType?.startsWith(`audio/`)===!0}var pm=9;function mm(e,t){let n=t?`max-w-[11rem]`:`max-w-52`,r=`gap-1`;return e===1?{container:`grid grid-cols-1 ${n} ${r}`,tileSize:`single`}:e===2?{container:`grid grid-cols-2 ${n} ${r}`,tileSize:`grid-cell`}:e===3?{container:`grid grid-cols-3 ${n} ${r}`,tileSize:`grid-cell`}:e===4?{container:`grid grid-cols-2 ${n} ${r}`,tileSize:`grid-cell`}:e<=pm?{container:`grid grid-cols-3 ${n} ${r}`,tileSize:`grid-cell`}:{container:`grid grid-cols-3 ${n} ${r}`,tileSize:`grid-cell`,overflowCount:e-(pm-1)}}function hm(e){let t=(0,X.c)(32),{attachments:n,authToken:r,conversationId:i,workspaceConversationId:a,projectId:o,layout:s,centerUserVoiceRow:c}=e,l=s===void 0?`assistant`:s,u=c!==void 0&&c,d;t[0]!==i||t[1]!==l||t[2]!==o||t[3]!==a?(d={layout:l,conversationId:i,workspaceConversationId:a,projectId:o},t[0]=i,t[1]=l,t[2]=o,t[3]=a,t[4]=d):d=t[4];let f=om(d);if(!n?.length)return null;let p,m,h,g,_;if(t[5]!==n||t[6]!==r||t[7]!==u||t[8]!==i||t[9]!==l||t[10]!==f.openAttachment){p=n.filter(_m);let e=n.filter(fm),a=n.filter(gm);m=`flex flex-col gap-2`,h=p.length>0?(()=>{let e=mm(p.length,l===`user`),t=e.overflowCount==null?p:p.slice(0,pm-1);return(0,Z.jsxs)(`div`,{className:Y(`w-full min-w-0`,e.container),children:[t.map((t,n)=>(0,Z.jsx)(im,{attachment:t,authToken:r,conversationId:i,imageSize:e.tileSize,compact:l===`user`,onOpen:f.openAttachment},t.id??`${t.name}-${n}`)),e.overflowCount==null?null:(0,Z.jsx)(im,{attachment:p[pm-1],authToken:r,conversationId:i,imageSize:`grid-cell`,compact:l===`user`,overflowLabel:`+${e.overflowCount}`,onOpen:f.openAttachment},p[pm-1]?.id??`overflow-${pm-1}`)]})})():null,g=e.length>0?(0,Z.jsx)(`div`,{className:Y(`flex flex-col gap-2`,l===`user`&&(u?`items-center`:`items-end`)),children:e.map((e,t)=>(0,Z.jsx)(um,{att:e,conversationId:i,align:l===`user`?u?`center`:`end`:`start`,embedded:l===`user`},e.id??`${e.name}-${t}`))}):null,_=a.length>0?(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:a.map((e,t)=>(0,Z.jsx)(im,{attachment:e,authToken:r,conversationId:i,onOpen:f.openAttachment},e.id??`${e.name}-${t}`))}):null,t[5]=n,t[6]=r,t[7]=u,t[8]=i,t[9]=l,t[10]=f.openAttachment,t[11]=p,t[12]=m,t[13]=h,t[14]=g,t[15]=_}else p=t[11],m=t[12],h=t[13],g=t[14],_=t[15];let v;t[16]!==m||t[17]!==h||t[18]!==g||t[19]!==_?(v=(0,Z.jsxs)(`div`,{className:m,children:[h,g,_]}),t[16]=m,t[17]=h,t[18]=g,t[19]=_,t[20]=v):v=t[20];let y;t[21]!==r||t[22]!==i||t[23]!==p||t[24]!==f.active||t[25]!==f.closePreview||t[26]!==f.open||t[27]!==f.selectAttachment?(y=(0,Z.jsx)(Qr,{open:f.open,attachment:f.active,images:p,onAttachmentChange:f.selectAttachment,authToken:r,conversationId:i,onClose:f.closePreview}),t[21]=r,t[22]=i,t[23]=p,t[24]=f.active,t[25]=f.closePreview,t[26]=f.open,t[27]=f.selectAttachment,t[28]=y):y=t[28];let b;return t[29]!==v||t[30]!==y?(b=(0,Z.jsxs)(Z.Fragment,{children:[v,y]}),t[29]=v,t[30]=y,t[31]=b):b=t[31],b}function gm(e){return e.type!==`image`&&!e.mimeType?.startsWith(`image/`)&&!fm(e)}function _m(e){return e.type===`image`||e.mimeType?.startsWith(`image/`)}function vm(e,t){let n=e.source?.data?.trim();if(!n)return null;let r=n.match(/^data:([^;]+);base64,([\s\S]+)$/i);if(r?.[1]&&r[2]){let e=r[2].replace(/\s/g,``);return{name:`image-${t+1}`,mimeType:r[1],type:`image`,content:e,data:e}}if(n.startsWith(`data:`))return{name:`image-${t+1}`,mimeType:`image/png`,type:`image`,content:n,data:n};let i=n.replace(/\s/g,``);return{name:`image-${t+1}`,mimeType:`image/png`,type:`image`,content:i,data:i}}function ym(e){return e?.length?e.flatMap((e,t)=>{let n=vm(e,t);return n?[n]:[]}):[]}function bm(e){let t=[],n=new Set(In(e,{includePending:!0}));for(let r of e)if(r.type===`text`){if(!n.has(r))continue;t.push(r.text)}else r.type===`image`&&t.push(`[image]`);return t.join(`
13
+
14
+ `).trim()}function xm(e){if(!e.trim())return``;let t=dt.parse(e,{gfm:!0,breaks:!1});return new DOMParser().parseFromString(`<div>${t}</div>`,`text/html`).body.textContent?.trim()??``}function Sm(e){let t=[],n=new Set(In(e,{includePending:!0}));for(let r of e)if(r.type===`text`){if(!n.has(r))continue;t.push(xm(r.text))}else r.type===`image`&&t.push(`[image]`);return t.join(`
15
+
16
+ `).trim()}var Cm=new WeakMap,wm=new WeakMap,Tm=new WeakMap,Em=new WeakMap;function Dm(e,t){if(!e)return;let n=e=>{let t=Tm.get(e);return t||(t=new Map(e.content.flatMap(e=>{let t=or(e);return t?[[t,e]]:[]})),Tm.set(e,t)),t},r=e.streamingMsg&&n(e.streamingMsg).get(t);if(r)return r;let i=Em.get(e.messages);if(!i){i=new Map;for(let t of e.messages)for(let[e,r]of n(t))i.set(e,r);Em.set(e.messages,i)}return i.get(t)}function Om(e,t){return e===t?!0:!e||!t||e.content.length!==t.content.length||!e.content.every((e,n)=>{let r=t.content[n];return e===r||e.type===`text`&&r.type===`text`&&or(e)===or(r)&&e.segmentId===r.segmentId&&e.presentation===r.presentation&&!!e.text.trim()==!!r.text.trim()&&(e.text===r.text||![e.text,r.text].some(e=>{let t=e.trimStart();return t.startsWith(`NO_REPLY`)||t.length>0&&`NO_REPLY`.startsWith(t)}))})?!1:[...new Set([...Object.keys(e),...Object.keys(t)])].every(n=>n===`content`||e[n]===t[n])}function km(){let e;return t=>(Om(e??null,t??null)||(e=t),e)}function Am(e,t){if(!e)return;let n=e.streamingMsg;if(n?.renderKey===t){let t=e.messages.at(-1);if(t?.role!==`assistant`)return n;let r=wm.get(n);if(r?.previous===t)return r.row;let i=fr([t,n]).at(-1);return wm.set(n,{previous:t,row:i}),i}let r=Cm.get(e.messages);return r||(r=new Map(e.messages.filter(e=>e.renderKey).map(e=>[e.renderKey,e])),Cm.set(e.messages,r)),r.get(t)}function jm(){let e;return t=>{if(!t||!e)return e=t,t;let n=Om(e.streamingMsg,t.streamingMsg);return n&&Object.keys(t).every(n=>n===`streamingMsg`||e[n]===t[n])||(e=n?{...t,streamingMsg:e.streamingMsg}:t),e}}function Mm(e){let t=(0,X.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=jm(),t[0]=n):n=t[0];let r=n,i;t[1]===e?i=t[2]:(i=()=>r(e?Nn.getState().sessions[e]:void 0),t[1]=e,t[2]=i);let a=i;return(0,Q.useSyncExternalStore)(Nn.subscribe,a,a)}function Nm(e,t){let n=(0,Q.useMemo)(()=>{let n=t();return{read:()=>n,subscribe:r=>{let i=null,a=null,o=()=>{i!==null&&cancelAnimationFrame(i),a!==null&&clearTimeout(a),i=null,a=null},s=()=>{o();let e=t();n!==e&&(n=e,r())},c=Nn.subscribe((r,o)=>{if(t()===n)return;let c=e?r.sessions[e]:void 0,l=e?o.sessions[e]:void 0;if(c?.streaming!==l?.streaming||c?.messages!==l?.messages){s();return}i===null&&(i=requestAnimationFrame(s),a=setTimeout(s,50))});return s(),()=>{o(),c()}}}},[e,t]);return(0,Q.useSyncExternalStore)(n.subscribe,n.read,n.read)}function Pm(e,t){let n=(0,X.c)(4),r;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=km(),n[0]=r):r=n[0];let i=r,a;return n[1]!==e||n[2]!==t?(a=()=>i(e&&t?Am(Nn.getState().sessions[e],t):void 0),n[1]=e,n[2]=t,n[3]=a):a=n[3],Nm(e,a)}function Fm(e,t){let n=(0,X.c)(3),r;return n[0]!==e||n[1]!==t?(r=()=>e&&t?Dm(Nn.getState().sessions[e],t):void 0,n[0]=e,n[1]=t,n[2]=r):r=n[2],Nm(e,r)}function Im(e,t){let n=(0,X.c)(7),r;n[0]===t?r=n[1]:(r=t.join(`,`),n[0]=t,n[1]=r);let i=r,a;n[2]===i?a=n[3]:(a=i?i.split(`,`):[],n[2]=i,n[3]=a);let o=a,s;return n[4]!==e||n[5]!==o?(s=()=>{if(!e||!o.length)return;let t=Nn.getState().sessions[e],n=o.map(e=>Dm(t,e));if(!n.some(Rm))return n.map(Lm).join(``)},n[4]=e,n[5]=o,n[6]=s):s=n[6],Nm(e,s)}function Lm(e){return e?.type===`text`?e.text:``}function Rm(e){return e?.type!==`text`}function zm(e){let t=[];((n,r)=>{let i=new RegExp(n.source,n.flags),a;for(;(a=i.exec(e))!==null;)t.push({start:a.index,end:a.index+a[0].length,seg:r(a)})})(Da(),e=>({kind:`skill`,name:e[1]??``}));for(let n of xo(e))t.push({start:n.start,end:n.end,seg:{kind:`command`,name:e.slice(n.start+1,n.end)}});t.sort((e,t)=>e.start===t.start?t.end-e.end:e.start-t.start);let n=[],r=0;for(let i of t)i.start<r||(i.start>r&&n.push({kind:`text`,text:e.slice(r,i.start)}),n.push(i.seg),r=i.end);return r<e.length&&n.push({kind:`text`,text:e.slice(r)}),n.length===0&&n.push({kind:`text`,text:e}),n}function Bm(e){return e.kind===`text`?`t:${e.text}`:e.kind===`skill`?`s:${e.name}`:e.kind===`context_ref`?`r:${e.refId}`:`c:${e.name}`}function Vm(e,t){let n=e[t-1],r=e[t-2],i=e[t+1],a=n?.kind===`text`&&n.text.trim()===``&&r!==void 0&&r.kind!==`text`;return Y(n?.kind===`text`&&/\s$/u.test(n.text)&&!a&&`ms-1`,i?.kind===`text`&&/^\s/u.test(i.text)&&`me-1`)}function Hm(e){let t=(0,X.c)(6),{contextRef:n}=e;if(n?.kind===`file`&&n.fileKind===`directory`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(ke,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[0]=e):e=t[0],e}if(n?.kind===`file`){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Ee,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[1]=e):e=t[1],e}if(n?.kind===`session`){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(St,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[2]=e):e=t[2],e}if(n?.kind===`browser_tab`){let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(k,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[3]=e):e=t[3],e}if(n?.kind===`mcp_resource`){let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(be,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[4]=e):e=t[4],e}let r;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(ms,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=r):r=t[5],r}var Um=(0,Q.memo)(function(e){let t=(0,X.c)(24),{text:n,conversationId:r,document:i,contextRefs:a}=e,o=h(Wm),s;t[0]===o?s=t[1]:(s=y(o),t[0]=o,t[1]=s);let c=s.chat.referenceFallback,l;bb0:{if(!i){let e;t[2]===n?e=t[3]:(e=zm(n),t[2]=n,t[3]=e),l=e;break bb0}let e;if(t[4]!==a||t[5]!==i.parts){let n=new Map(a?.flatMap(Gm)??[]);e=i.parts.flatMap(e=>e.type===`text`?zm(e.text):[{kind:`context_ref`,refId:e.refId,ref:n.get(e.refId)}]),t[4]=a,t[5]=i.parts,t[6]=e}else e=t[6];l=e}let u=l,d;if(t[7]!==u){let e=new Map;d=u.map(t=>{let n=Bm(t),r=e.get(n)??0;return e.set(n,r+1),{part:t,key:`${n}#${String(r)}`}}),t[7]=u,t[8]=d}else d=t[8];let f=d,p;t[9]===u?p=t[10]:(p=u.some(Km),t[9]=u,t[10]=p);let m=Lp(void 0,r,p);if(!u.some(qm)){let e;return t[11]===n?e=t[12]:(e=(0,Z.jsx)(`div`,{className:`markdown-content min-w-0`,children:(0,Z.jsx)($d,{content:n,compact:!0,breaks:!0})}),t[11]=n,t[12]=e),e}let g;if(t[13]!==u||t[14]!==f||t[15]!==c||t[16]!==m){let e;t[18]!==u||t[19]!==c||t[20]!==m?(e=(e,t)=>{let{part:n,key:r}=e;return n.kind===`skill`?(0,Z.jsxs)(`span`,{className:`chat-skill-pill max-w-full shrink-0`,"data-skill":n.name,title:`/${n.name}`,children:[`/`,m(n.name)]},r):n.kind===`command`?(0,Z.jsxs)(`span`,{className:`chat-command-pill max-w-full shrink-0`,"data-slash-command":n.name,children:[`/`,n.name]},r):n.kind===`context_ref`?(0,Z.jsxs)(`span`,{className:Y(`chat-context-ref-pill chat-context-ref-pill-message max-w-full shrink-0`,Vm(u,t)),"data-context-ref-id":n.refId,"data-ref-kind":n.ref?.kind??``,"data-file-kind":n.ref?.fileKind??``,title:n.ref?.title,"aria-label":n.ref?.title??c,children:[(0,Z.jsx)(Hm,{contextRef:n.ref}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:n.ref?.title??c})]},r):n.text?(0,Z.jsx)(`div`,{className:`chat-user-message-segment markdown-content inline-block min-w-0 max-w-full align-baseline text-fg`,children:(0,Z.jsx)($d,{content:n.text,compact:!0,breaks:!0})},r):null},t[18]=u,t[19]=c,t[20]=m,t[21]=e):e=t[21],g=f.map(e),t[13]=u,t[14]=f,t[15]=c,t[16]=m,t[17]=g}else g=t[17];let _;return t[22]===g?_=t[23]:(_=(0,Z.jsx)(`span`,{className:`inline-flex max-w-full flex-wrap items-baseline gap-x-0 gap-y-1 [text-align:inherit]`,children:g}),t[22]=g,t[23]=_),_});function Wm(e){return e.language}function Gm(e){return e.refId?[[e.refId,e]]:[]}function Km(e){return e.kind===`skill`}function qm(e){return e.kind!==`text`}function Jm(e,t){switch(e.code){case`provider_setup_required`:return{title:t.providerSetupRequiredTitle,body:t.providerSetupRequiredBody.replace(`{{provider}}`,e.provider??t.agentRunErrorUnknownProvider),cta:t.providerSetupRequiredCta,deepLink:`/settings/capabilities/models`};case`provider_auth_invalid`:return{title:t.agentRunErrorAuthInvalidTitle,body:t.agentRunErrorAuthInvalidBody.replace(`{{provider}}`,e.provider??t.agentRunErrorUnknownProvider),cta:t.agentRunErrorCtaProviders,deepLink:`/settings/capabilities/models`};case`rate_limit`:return{title:t.agentRunErrorRateLimitTitle,body:t.agentRunErrorRateLimitBody};case`timeout`:return{title:t.agentRunErrorTimeoutTitle,body:t.agentRunErrorTimeoutBody};case`provider_connection_error`:return{title:t.agentRunErrorConnectionTitle,body:t.agentRunErrorConnectionBody};case`billing`:return{title:t.agentRunErrorBillingTitle,body:t.agentRunErrorBillingBody};case`credit_budget_exhausted`:return{title:t.creditBudgetExhaustedTitle,body:t.creditBudgetExhaustedBody,cta:t.creditBudgetSettingsCta,deepLink:`/settings/agent-defaults?panel=runtime`};case`model_quota_exhausted`:return{title:t.xopcQuotaExhaustedTitle,body:t.xopcQuotaExhaustedBody};case`platform_token_limit_exceeded`:return{title:t.xopcPlatformLimitTitle,body:t.xopcPlatformLimitBody,cta:t.xopcPlatformLimitCta,deepLink:`/settings/capabilities/models?add=1`};case`send_failed`:return{title:t.agentRunErrorSendFailedTitle,body:t.agentRunErrorSendFailedBody};case`session_not_found`:return{title:t.sessionNotFoundTitle,body:t.sessionNotFoundBody,cta:t.sessionNotFoundCta,deepLink:`/chat/new`};default:return{title:t.agentRunErrorUnknownTitle,body:t.agentRunErrorUnknownBody}}}function Ym(e){let t=(0,X.c)(4),{code:n}=e;switch(n){case`provider_setup_required`:case`provider_auth_invalid`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Ge,{className:`size-4`,strokeWidth:1.75}),t[0]=e):e=t[0],e}case`rate_limit`:case`timeout`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(he,{className:`size-4`,strokeWidth:1.75}),t[1]=e):e=t[1],e}case`billing`:case`credit_budget_exhausted`:case`model_quota_exhausted`:case`platform_token_limit_exceeded`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(vs,{className:`size-4`,strokeWidth:1.75}),t[2]=e):e=t[2],e}default:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(ue,{className:`size-4`,strokeWidth:1.75}),t[3]=e):e=t[3],e}}}function Xm(e){return e===`provider_setup_required`||e===`provider_auth_invalid`||e===`rate_limit`||e===`timeout`||e===`billing`||e===`model_quota_exhausted`||e===`platform_token_limit_exceeded`||e===`session_not_found`?`amber`:`red`}function Zm(e){let t=(0,X.c)(46),{payload:n}=e,r=d(),i=h($m),a,o;t[0]!==i||t[1]!==n?(a=y(i).chat,o=Jm(n,a),t[0]=i,t[1]=n,t[2]=a,t[3]=o):(a=t[2],o=t[3]);let s=o,c=Xm(n.code),l=c===`amber`?`border-amber-300/60 bg-amber-50 dark:border-amber-500/30 dark:bg-amber-950`:`border-red-300/60 bg-red-50 dark:border-red-500/30 dark:bg-red-950`,u=c===`amber`?`bg-amber-100 text-amber-700 dark:bg-amber-500/20 dark:text-amber-300`:`bg-red-100 text-red-700 dark:bg-red-500/20 dark:text-red-300`,f=c===`amber`?`text-amber-900 dark:text-amber-100`:`text-red-900 dark:text-red-100`,p=c===`amber`?`text-amber-900/85 dark:text-amber-100/80`:`text-red-900/85 dark:text-red-100/80`,m=c===`amber`?`text-amber-800/80 hover:text-amber-900 dark:text-amber-200/80 dark:hover:text-amber-100`:`text-red-800/80 hover:text-red-900 dark:text-red-200/80 dark:hover:text-red-100`,g=c===`amber`?`bg-amber-100/60 text-amber-900 dark:bg-amber-500/15 dark:text-amber-100`:`bg-red-100/60 text-red-900 dark:bg-red-500/15 dark:text-red-100`,_=c===`amber`?`bg-amber-600 text-white hover:bg-amber-700 dark:bg-amber-500 dark:text-amber-950 dark:hover:bg-amber-400`:`bg-red-600 text-white hover:bg-red-700 dark:bg-red-500 dark:text-red-950 dark:hover:bg-red-400`,v=n.code===`model_quota_exhausted`,b=Qm,x;t[4]===l?x=t[5]:(x=Y(`flex flex-col gap-2 rounded-xl border p-3`,l),t[4]=l,t[5]=x);let S;t[6]===u?S=t[7]:(S=Y(`flex size-8 shrink-0 items-center justify-center rounded-lg`,u),t[6]=u,t[7]=S);let C;t[8]===n.code?C=t[9]:(C=(0,Z.jsx)(Ym,{code:n.code}),t[8]=n.code,t[9]=C);let w;t[10]!==S||t[11]!==C?(w=(0,Z.jsx)(`span`,{className:S,"aria-hidden":!0,children:C}),t[10]=S,t[11]=C,t[12]=w):w=t[12];let T;t[13]===f?T=t[14]:(T=Y(`text-sm font-semibold`,f),t[13]=f,t[14]=T);let E;t[15]!==s.title||t[16]!==T?(E=(0,Z.jsx)(`h3`,{className:T,children:s.title}),t[15]=s.title,t[16]=T,t[17]=E):E=t[17];let D;t[18]===p?D=t[19]:(D=Y(`mt-1 text-xs leading-relaxed`,p),t[18]=p,t[19]=D);let O;t[20]!==s.body||t[21]!==D?(O=(0,Z.jsx)(`p`,{className:D,children:s.body}),t[20]=s.body,t[21]=D,t[22]=O):O=t[22];let k;t[23]!==E||t[24]!==O?(k=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[E,O]}),t[23]=E,t[24]=O,t[25]=k):k=t[25];let A;t[26]!==k||t[27]!==w?(A=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[w,k]}),t[26]=k,t[27]=w,t[28]=A):A=t[28];let j;t[29]!==s.cta||t[30]!==s.deepLink||t[31]!==_||t[32]!==a||t[33]!==r||t[34]!==v?(j=v?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,className:Y(`inline-flex h-8 items-center rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,_),onClick:()=>b(`/models/credits/purchase`),children:a.xopcQuotaPurchaseCta}),(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex h-8 items-center rounded-lg border border-current px-3 py-1.5 text-xs font-medium transition-colors hover:bg-amber-500/10`,onClick:()=>b(`/models/credits/request`),children:a.xopcQuotaRequestCta}),(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex h-8 items-center rounded-lg border border-current px-3 py-1.5 text-xs font-medium transition-colors hover:bg-amber-500/10`,onClick:()=>r(`/settings/capabilities/models?add=1`),children:a.xopcQuotaOwnProviderCta})]}):s.cta&&s.deepLink?(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,Z.jsx)(`button`,{type:`button`,className:Y(`inline-flex h-8 items-center rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/50`,_),onClick:()=>r(s.deepLink),children:s.cta})}):null,t[29]=s.cta,t[30]=s.deepLink,t[31]=_,t[32]=a,t[33]=r,t[34]=v,t[35]=j):j=t[35];let M;t[36]!==m||t[37]!==g||t[38]!==a||t[39]!==n.message?(M=n.message?(0,Z.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,Z.jsx)(`summary`,{className:Y(`cursor-pointer select-none underline-offset-2`,m),children:a.agentRunErrorDetailToggle}),(0,Z.jsx)(`pre`,{className:Y(`mt-2 max-h-40 w-full min-w-0 overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-md p-2 font-mono text-[11px] [overflow-wrap:anywhere]`,g),children:n.message})]}):null,t[36]=m,t[37]=g,t[38]=a,t[39]=n.message,t[40]=M):M=t[40];let N;return t[41]!==A||t[42]!==j||t[43]!==M||t[44]!==x?(N=(0,Z.jsxs)(`section`,{role:`alert`,"aria-live":`polite`,className:x,children:[A,j,M]}),t[41]=A,t[42]=j,t[43]=M,t[44]=x,t[45]=N):N=t[45],N}function Qm(e){return window.open(`https://console.xopc.ai${e}`,`_blank`,`noopener,noreferrer`)}function $m(e){return e.language}function eh(e){let t=(0,X.c)(8),{errorText:n}=e,r;t[0]===n?r=t[1]:(r=Bn(n),t[0]=n,t[1]=r);let i=r;if(!i)return null;let a;t[2]===i?a=t[3]:(a=_r(i),t[2]=i,t[3]=a);let o=a;if(o){let e;return t[4]===o?e=t[5]:(e=(0,Z.jsx)(`div`,{className:`mb-4`,children:(0,Z.jsx)(th,{payload:o})}),t[4]=o,t[5]=e),e}let s;return t[6]===i?s=t[7]:(s=(0,Z.jsx)(`div`,{className:`mb-4`,children:(0,Z.jsx)(Zm,{payload:i})}),t[6]=i,t[7]=s),s}function th(e){let t=(0,X.c)(32),{payload:n}=e,r=d(),i=h(nh),a,o,s,c;t[0]!==i||t[1]!==n.kind||t[2]!==n.provider?(o=y(i).chat,a=n.kind===`provider_auth_invalid`,c=a?o.agentRunErrorAuthInvalidTitle:o.providerSetupRequiredTitle,s=(a?o.agentRunErrorAuthInvalidBody:o.providerSetupRequiredBody).replace(`{{provider}}`,n.provider),t[0]=i,t[1]=n.kind,t[2]=n.provider,t[3]=a,t[4]=o,t[5]=s,t[6]=c):(a=t[3],o=t[4],s=t[5],c=t[6]);let l=s,u=a?o.agentRunErrorCtaProviders:o.providerSetupRequiredCta,f=a?o.agentRunErrorDetailToggle:o.providerSetupRequiredDetailToggle,p=a?`alert`:`status`,m;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=Y(`flex flex-col gap-2 rounded-xl border border-amber-300/60 bg-amber-50 p-3`,`dark:border-amber-500/30 dark:bg-amber-950`),t[7]=m):m=t[7];let g;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(g=Y(`flex size-8 shrink-0 items-center justify-center rounded-lg`,`bg-amber-100 text-amber-700 dark:bg-amber-500/20 dark:text-amber-300`),t[8]=g):g=t[8];let _;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Z.jsx)(`span`,{className:g,"aria-hidden":!0,children:(0,Z.jsx)(Ge,{className:`size-4`,strokeWidth:1.75})}),t[9]=_):_=t[9];let v;t[10]===c?v=t[11]:(v=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-amber-900 dark:text-amber-100`,children:c}),t[10]=c,t[11]=v);let b;t[12]===l?b=t[13]:(b=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-amber-900/85 dark:text-amber-100/80`,children:l}),t[12]=l,t[13]=b);let x;t[14]!==v||t[15]!==b?(x=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[_,(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[v,b]})]}),t[14]=v,t[15]=b,t[16]=x):x=t[16];let S;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(S=Y(`inline-flex h-8 items-center rounded-lg px-3 py-1.5 text-xs font-medium`,`bg-amber-600 text-white hover:bg-amber-700`,`dark:bg-amber-500 dark:text-amber-950 dark:hover:bg-amber-400`,`transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/50`),t[17]=S):S=t[17];let C;t[18]!==r||t[19]!==n.deepLink?(C=()=>r(n.deepLink),t[18]=r,t[19]=n.deepLink,t[20]=C):C=t[20];let w;t[21]!==u||t[22]!==C?(w=(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,Z.jsx)(`button`,{type:`button`,className:S,onClick:C,children:u})}),t[21]=u,t[22]=C,t[23]=w):w=t[23];let T;t[24]!==f||t[25]!==n.message?(T=n.message?(0,Z.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer select-none text-amber-800/80 underline-offset-2 hover:text-amber-900 dark:text-amber-200/80 dark:hover:text-amber-100`,children:f}),(0,Z.jsx)(`pre`,{className:`mt-2 max-h-40 w-full min-w-0 overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-md bg-amber-100/60 p-2 font-mono text-[11px] text-amber-900 dark:bg-amber-500/15 dark:text-amber-100 [overflow-wrap:anywhere]`,children:n.message})]}):null,t[24]=f,t[25]=n.message,t[26]=T):T=t[26];let E;return t[27]!==w||t[28]!==T||t[29]!==p||t[30]!==x?(E=(0,Z.jsxs)(`section`,{role:p,"aria-live":`polite`,className:m,children:[x,w,T]}),t[27]=w,t[28]=T,t[29]=p,t[30]=x,t[31]=E):E=t[31],E}function nh(e){return e.language}var rh=/^No API key found for (\S+)/i;function ih(e){let t=e.trim();if(t.startsWith(`{`))try{let e=JSON.parse(t);return e.kind!==`provider_setup_required`||typeof e.provider!=`string`||!e.provider||typeof e.deepLink!=`string`||!e.deepLink.startsWith(`/settings/`)?null:{kind:`provider_setup_required`,provider:e.provider,deepLink:e.deepLink,message:typeof e.message==`string`?e.message:void 0}}catch{return null}let n=rh.exec(t);return n?{kind:`provider_setup_required`,provider:n[1].replace(/[.,]$/,``),deepLink:`/settings/capabilities/models`,message:t}:null}var ah=new WeakMap;function oh(e){let t=ah.get(e),n=or(e);return t??(n?[n]:[])}function sh(e){let t=[];for(let n of e){let e=t[t.length-1];if(n.type===`text`&&e?.type===`text`&&n.segmentId===e.segmentId&&n.presentation===e.presentation){t[t.length-1]={...e,text:`${e.text??``}${n.text??``}`},mr(e,t[t.length-1]),ah.set(t[t.length-1],[...oh(e),...oh(n)]);continue}t.push(n)}return t}var ch=/^\s*\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$/m,lh=/^\s{0,3}(?:[-+*]|\d+[.)])\s+/m,uh=/^\s{0,3}```/gm;function dh(e){return(e.match(uh)?.length??0)%2==1?`code`:ch.test(e)?`table`:lh.test(e)?`list`:e.length>=4096?`long_text`:`plain`}var fh={plain:50,long_text:50,list:50,table:72,code:64};function ph({tailKind:e,latestParseMs:t}){let n=fh[e];return!Number.isFinite(t)||t<=16?n:Math.min(120,Math.max(n,Math.ceil(t*2)))}var mh=class{targetLength;lastArrivalAt=null;lastDrainAt=null;arrivalRate=40;outputRate=40;carry=0;constructor(e){this.targetLength=e}reset(e){this.targetLength=e,this.lastArrivalAt=null,this.lastDrainAt=null,this.arrivalRate=40,this.outputRate=40,this.carry=0}observe(e,t){let n=e-this.targetLength;if(n<=0)return;let r=this.lastArrivalAt===null?n:n*1e3/Math.max(10,t-this.lastArrivalAt);this.arrivalRate=Math.max(1,this.arrivalRate*.9+r*.1),this.targetLength=e,this.lastArrivalAt=t,this.lastDrainAt??=t}nextLength(e,t,n){let r=t.length-e;if(r<=0)return t.length;let i=Math.max(0,Math.min(120,n-(this.lastDrainAt??n)));this.lastDrainAt=n;let a=Math.max(20,this.arrivalRate,r/.6);this.outputRate+=(a-this.outputRate)*(1-Math.exp(-i/120));let o=this.carry+this.outputRate*i/1e3,s=Cd(t,Math.min(t.length,e+Math.floor(o)));return this.carry=Math.max(0,o-(s-e)),s===t.length&&(this.lastDrainAt=null,this.carry=0),s}};function hh(e,t,n,r=!1,i,a=!1){let[o,s]=(0,Q.useState)(()=>e),[c]=(0,Q.useState)(()=>new mh(e.length)),l=(0,Q.useRef)(e),u=(0,Q.useRef)(o),d=(0,Q.useRef)(null),f=(0,Q.useRef)(null),p=(0,Q.useRef)(50),m=(0,Q.useRef)(t||r),h=(0,Q.useRef)(!1),g=(0,Q.useRef)(i);return g.current=i,(0,Q.useEffect)(()=>{let r=!e.startsWith(l.current);l.current=e;let i=()=>{d.current!==null&&window.clearTimeout(d.current),f.current!==null&&window.cancelAnimationFrame(f.current),d.current=null,f.current=null},o=()=>{i(),c.reset(e.length),u.current=e,s(e)},_=()=>{m.current&&!h.current&&(h.current=!0,m.current=!1,g.current?.())};if(t&&(m.current=!0,h.current=!1,gt(n,e.length)),r||!e.startsWith(u.current)||document.visibilityState===`hidden`||window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches||!t){o(),t||_();return}if(t&&a&&u.current.length===0){ut(n,e.length),o();return}if(c.observe(e.length,performance.now()),p.current=ph({tailKind:dh(e.slice(-8192)),latestParseMs:lt(n)}),e===u.current||d.current!==null||f.current!==null)return;let v=()=>{d.current=window.setTimeout(()=>{d.current=null;let e=()=>{f.current=null;let e=l.current,t=document.visibilityState===`hidden`?e.length:c.nextLength(u.current.length,e,performance.now()),r=e.slice(0,t);r!==u.current&&(u.current=r,ut(n,r.length),s(r)),r!==e&&v()};document.visibilityState===`hidden`?e():f.current=window.requestAnimationFrame(e)},p.current)};v()},[e,n,t,a,c]),(0,Q.useEffect)(()=>()=>{d.current!==null&&window.clearTimeout(d.current),f.current!==null&&window.cancelAnimationFrame(f.current),d.current=null,f.current=null},[]),!t||!e.startsWith(o)||t&&a&&!o?e:o}function gh(e){if(!e.filePath)return``;if(!e.lineStart)return e.filePath;let t=e.lineEnd&&e.lineEnd!==e.lineStart?`-${e.lineEnd}`:``;return`${e.filePath}:${e.lineStart}${t}`}function _h(e){let t=(0,X.c)(33),{review:n}=e,r=h(yh),i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n.analysisMarkdown||t[2]!==n.errorMessage||t[3]!==n.overallCorrectness||t[4]!==n.source||t[5]!==n.status||t[6]!==n.target){o=y(r).chat.reviewCard,i=n.status===`preparing`||n.status===`reviewing`;let e=n.status===`preparing`;a=n.source===`local`&&n.overallCorrectness===`unknown`;let p=n.overallCorrectness===`patch is incorrect`?`border-red-500/30 bg-red-500/5 text-red-700 dark:text-red-300`:n.overallCorrectness===`patch is correct`?`border-emerald-500/30 bg-emerald-500/5 text-emerald-700 dark:text-emerald-300`:`border-edge bg-surface-inset text-fg-secondary`;s=`min-w-0 rounded-lg border border-edge bg-surface-inset p-3`;let m;t[16]===i?m=t[17]:(m=i?(0,Z.jsx)(Xe,{className:`size-4 animate-spin text-accent`,"aria-hidden":!0}):null,t[16]=i,t[17]=m),c=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[m,(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg-primary`,children:i?o.running:o.finished}),i?(0,Z.jsx)(`div`,{className:`rounded-md border border-edge bg-surface-inset px-1.5 py-0.5 text-[11px] font-medium text-fg-secondary`,children:e?o.collecting:o.assistant}):(0,Z.jsx)(`div`,{className:Y(`rounded-md border px-1.5 py-0.5 text-[11px] font-medium`,p),children:o.correctness[n.overallCorrectness]})]}),l=(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-fg-tertiary`,children:o.basedOn.replace(`{{target}}`,n.target)}),u=i&&!n.analysisMarkdown?(0,Z.jsx)(`div`,{className:`mt-3 text-sm text-fg-secondary`,children:e?o.preparing:o.checking}):null,d=n.analysisMarkdown?(0,Z.jsxs)(`div`,{className:`mt-3 rounded-md border border-edge-subtle bg-surface px-2.5 py-2`,children:[(0,Z.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg-secondary`,children:o.assistant}),(0,Z.jsx)($d,{content:n.analysisMarkdown,compact:!0,streaming:i})]}):null,f=n.status===`error`&&n.errorMessage?(0,Z.jsx)(`div`,{className:`mt-3 rounded-md border border-warning/30 bg-warning/5 px-2.5 py-2 text-sm text-warning`,children:o.error.replace(`{{error}}`,n.errorMessage)}):null,t[0]=r,t[1]=n.analysisMarkdown,t[2]=n.errorMessage,t[3]=n.overallCorrectness,t[4]=n.source,t[5]=n.status,t[6]=n.target,t[7]=i,t[8]=a,t[9]=o,t[10]=s,t[11]=c,t[12]=l,t[13]=u,t[14]=d,t[15]=f}else i=t[7],a=t[8],o=t[9],s=t[10],c=t[11],l=t[12],u=t[13],d=t[14],f=t[15];let p;t[18]!==i||t[19]!==a||t[20]!==n.findings||t[21]!==n.overallExplanation||t[22]!==n.summary||t[23]!==o?(p=i?null:(0,Z.jsxs)(Z.Fragment,{children:[n.summary?(0,Z.jsx)(`div`,{className:`mt-3 text-sm text-fg-secondary`,children:n.summary}):null,(0,Z.jsx)(`div`,{className:`mt-3 space-y-2`,children:n.findings.length===0?(0,Z.jsx)(`div`,{className:`text-sm text-fg-secondary`,children:a?o.noModelFindings:o.noFindings}):n.findings.map(vh)}),n.overallExplanation?(0,Z.jsx)(`div`,{className:`mt-3 whitespace-pre-wrap text-sm text-fg-secondary`,children:n.overallExplanation}):null]}),t[18]=i,t[19]=a,t[20]=n.findings,t[21]=n.overallExplanation,t[22]=n.summary,t[23]=o,t[24]=p):p=t[24];let m;return t[25]!==s||t[26]!==c||t[27]!==l||t[28]!==u||t[29]!==d||t[30]!==f||t[31]!==p?(m=(0,Z.jsxs)(`div`,{className:s,children:[c,l,u,d,f,p]}),t[25]=s,t[26]=c,t[27]=l,t[28]=u,t[29]=d,t[30]=f,t[31]=p,t[32]=m):m=t[32],m}function vh(e,t){let n=gh(e);return(0,Z.jsxs)(`div`,{className:`rounded-md border border-edge bg-surface p-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`span`,{className:`rounded border border-edge bg-surface-inset px-1.5 py-0.5 text-[11px] font-semibold text-fg-secondary`,children:[`P`,e.priority]}),(0,Z.jsx)(`span`,{className:`min-w-0 text-sm font-medium text-fg-primary`,children:e.title})]}),n?(0,Z.jsx)(`div`,{className:`mt-1 break-all text-xs text-fg-tertiary`,children:n}):null,e.body?(0,Z.jsx)(`div`,{className:`mt-1 text-sm text-fg-secondary`,children:e.body}):null]},`${e.title}-${t}`)}function yh(e){return e.language}function bh({resolution:e,conversationId:t,onClose:n}){let r=h(e=>e.language),i=y(r).chat.fileReference,[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(!1),d=xa()&&!!window.electronAPI?.shell,f=e.target.path,p=e.status===`ready`?e.ref:null,m=p?.displayName??f.split(/[\\/]/).pop()??f,g=p?.absolutePath??p?.workspaceRelativePath??f,_=(0,Q.useCallback)(()=>{Ti(g).then(e=>{e&&(o(!0),window.setTimeout(()=>o(!1),2e3))})},[g]),v=async e=>{let n=window.electronAPI?.shell;if(!(!p?.fileRefId||!d||!n||l)){c(``),u(!0);try{let r=await La(p.fileRefId,e,{conversationId:t?.trim()||void 0});if(e===`openExternal`){let e=await n.openPath(r.absolutePath);e.ok||c(e.error)}else(await n.showItemInFolder(r.absolutePath)).success||c(i.resolveFailedDescription)}catch(e){c(e instanceof Error?e.message:String(e))}finally{u(!1)}}};return(0,Z.jsxs)(`div`,{className:Y(`mt-2 flex max-w-xl min-w-0 flex-col gap-1.5 rounded-lg border px-2.5 py-2 text-xs`,e.status===`ready`&&e.ref.exists&&e.ref.scope!==`missing`?`border-edge-subtle bg-surface-panel`:`border-warning/30 bg-warning/5`),children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.status===`loading`?(0,Z.jsx)(Xe,{className:`size-3.5 shrink-0 animate-spin text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}):e.status===`error`||p?.scope===`missing`||p?.scope===`invalid`?(0,Z.jsx)(ue,{className:`size-3.5 shrink-0 text-warning`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(we,{className:`size-3.5 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:m}),(0,Z.jsx)(`button`,{type:`button`,onClick:n,className:Y(`ml-auto inline-flex size-5 shrink-0 items-center justify-center rounded text-fg-muted hover:bg-surface-hover hover:text-fg`,ua.focusRingPanel),"aria-label":i.closeActions,children:(0,Z.jsx)(qt,{className:`size-3`,strokeWidth:1.75,"aria-hidden":!0})})]}),(0,Z.jsx)(`p`,{className:`line-clamp-2 break-all text-[11px] leading-snug text-fg-muted`,children:e.status===`loading`?i.resolvingDescription:e.status===`error`?e.message:p?.scope===`missing`?i.missingDescription:p?.scope===`invalid`?i.invalidDescription:d?i.externalDescription:i.browserExternalDescription}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 pt-0.5`,children:[d&&p?.capabilities.includes(`openExternal`)?(0,Z.jsxs)(`button`,{type:`button`,className:xh,disabled:l,onClick:()=>void v(`openExternal`),children:[(0,Z.jsx)(Se,{className:`size-3`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:i.openExternal})]}):null,d&&p?.capabilities.includes(`revealInFolder`)?(0,Z.jsxs)(`button`,{type:`button`,className:xh,disabled:l,onClick:()=>void v(`revealInFolder`),children:[(0,Z.jsx)(Oe,{className:`size-3`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:i.revealInFolder})]}):null,p?.manageRoute?(0,Z.jsxs)(`a`,{className:xh,href:`#${p.manageRoute}`,children:[(0,Z.jsx)(Lt,{className:`size-3`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:y(r).nav.settings})]}):null,(0,Z.jsxs)(`button`,{type:`button`,className:xh,onClick:_,children:[(0,Z.jsx)(ye,{className:`size-3`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:a?y(r).chat.messageCopied:i.copyPath})]})]}),s?(0,Z.jsx)(`p`,{role:`alert`,className:`text-warning`,children:s}):null]})}var xh=Y(`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,ua.focusRingPanel,ua.press);function Sh({taskRunId:e,content:t,sourceConversationId:n,sourcePartIds:r=[],compact:i,conversationId:a,projectId:o,streaming:s=!1,animateInitialContent:c=!1,onProgressiveRenderComplete:l,responseRunId:u,immediateFirstCommit:d=!1}){let f=Im(n,r)??t,p=`assistant-markdown-${(0,Q.useId)()}`,m=hh(f,s,p,c,l,d);(0,Q.useLayoutEffect)(()=>{if(!u||!m.trim())return;let e=window.requestAnimationFrame(()=>hr(u,m));return()=>window.cancelAnimationFrame(e)},[u,m,s]),(0,Q.useEffect)(()=>{if(s)return ft(p),()=>vt(p)},[p,s]);let g=Li(e=>e.setPath),_=y(h(e=>e.language)).chat.fileReference,[v,b]=(0,Q.useState)(null),x=(0,Q.useRef)(0);(0,Q.useEffect)(()=>()=>{x.current++},[a,o,e]);let S=(0,Q.useCallback)(async t=>{try{return await Pa(t.path,{projectId:o?.trim()||void 0,conversationId:a?.trim()||void 0,taskRunId:e})}catch(n){if(e||o||!a)throw n;return Pa(t.path)}},[o,a,e]),C=(0,Q.useCallback)(t=>{let n=++x.current;if(t.kind===`workspace-relative`){b({status:`loading`,target:t}),(async()=>{let r=await za(t.path,{projectId:o?.trim()||void 0,conversationId:a?.trim()||void 0,taskRunId:e});if(n!==x.current)return;if(r?.capabilities.includes(`preview`)&&(r.absolutePath||r.workspaceRelativePath)){g(r.absolutePath||r.workspaceRelativePath,t.line,o,a),b(null);return}let i=!e&&!o&&a?await za(t.path):null;if(n===x.current){if(i?.capabilities.includes(`preview`)&&(i.absolutePath||i.workspaceRelativePath)){g(i.absolutePath||i.workspaceRelativePath,t.line),b(null);return}b(r?{status:`ready`,target:t,ref:r}:{status:`error`,target:t,message:_.resolveFailedDescription})}})().catch(e=>{n===x.current&&b({status:`error`,target:t,message:e instanceof Error?e.message:String(e)})});return}b({status:`loading`,target:t}),za(t.path,{projectId:o?.trim()||void 0,conversationId:a?.trim()||void 0,taskRunId:e}).then(e=>{if(n===x.current){if(!e){b({status:`error`,target:t,message:_.resolveFailedDescription});return}if(e.capabilities.includes(`preview`)&&(e.absolutePath||e.workspaceRelativePath)){g(e.absolutePath||e.workspaceRelativePath,t.line,o,a),b(null);return}b({status:`ready`,target:t,ref:e})}}).catch(e=>{n===x.current&&b({status:`error`,target:t,message:e instanceof Error?e.message:String(e)})})},[_.resolveFailedDescription,o,a,e,g]),w=ih(f);return(0,Z.jsxs)(Z.Fragment,{children:[w?(0,Z.jsx)(th,{payload:w}):(0,Z.jsx)($d,{content:m,streaming:s||m!==f,compact:i,onWorkspaceFileOpen:C,onWorkspaceImageLoad:S,renderMermaid:!0,mermaidActions:!0,streamingMetricsKey:p}),v?(0,Z.jsx)(bh,{resolution:v,conversationId:a,onClose:()=>{x.current++,b(null)}}):null]})}function Ch(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){if(e.type===`text`)return n?(0,Z.jsx)(`div`,{className:`min-w-0`,children:(0,Z.jsx)(Um,{text:gr(e.text??``),conversationId:s,document:f,contextRefs:p})},t):(0,Z.jsx)(`div`,{className:`assistant-markdown-content markdown-content min-w-0`,children:(0,Z.jsx)(Sh,{content:e.text,sourcePartIds:oh(e),sourceConversationId:s,taskRunId:m,compact:!0,conversationId:c??s,projectId:l,streaming:r,animateInitialContent:u,onProgressiveRenderComplete:d,responseRunId:h,immediateFirstCommit:g})},t);if(e.type===`image`&&e.source?.data){let n=o??0;return(0,Z.jsx)(ad,{source:e.source.data,alt:``,title:i,onOpen:a?()=>a(e,n):void 0},t)}return e.type===`review`?(0,Z.jsx)(_h,{review:e},t):null}function wh(e){let t=(0,X.c)(24),{taskRunId:n,content:r,isUser:i,isAssistantMessageStreaming:a,imagePreviewLabel:o,onImagePreview:s,conversationId:c,workspaceConversationId:l,projectId:u,progressiveRender:d,onProgressiveRenderComplete:f,userTurnDocument:p,contextRefs:m,responseRunId:h,immediateFirstCommit:g,renderActivity:_,processItems:v,processCollapsed:y}=e,b=d!==void 0&&d,x=g!==void 0&&g,S=y!==void 0&&y,C;if(t[0]!==r||t[1]!==m||t[2]!==c||t[3]!==o||t[4]!==x||t[5]!==a||t[6]!==i||t[7]!==s||t[8]!==f||t[9]!==S||t[10]!==v||t[11]!==b||t[12]!==u||t[13]!==_||t[14]!==h||t[15]!==n||t[16]!==p||t[17]!==l){let e=i?r:sh(r),d;t[19]===v?d=t[20]:(d=new Set(v?[...v].map(or).filter(Boolean):[]),t[19]=v,t[20]=d);let g=d,y;t[21]!==v||t[22]!==g?(y=e=>v?.has(e)||!!(or(e)&&g.has(or(e))),t[21]=v,t[22]=g,t[23]=y):y=t[23];let w=y,T=e.findLastIndex(Th),E=e.at(-1),D=T<0&&E?.type===`text`&&E.presentation===void 0?e.length-1:-1,O=a?Math.max(T,D):-1,k=[],A=0,j=0;for(;A<e.length;){let t=e[A];if(t.type===`thinking`||t.type===`tool_use`){let n=A,r=[];for(;A<e.length;){let t=e[A];if(t.type!==`thinking`&&t.type!==`tool_use`)break;r.push(t),A++}_&&k.push((0,Z.jsx)(`div`,{"data-assistant-activity":!0,"data-assistant-process-item":v?!0:void 0,hidden:S,children:_(r,A===e.length)},or(t)??`activity-${n}`))}else{let e=t.type===`image`?j++:0,r=Ch(t,or(t)??`block-${A}`,i,A===O,o,s,t.type===`image`?e:A,c,l,u,b,f,i&&A===0?p:void 0,i&&A===0?m:void 0,n,h,x);r&&k.push(v?(0,Z.jsx)(`div`,{"data-assistant-process-item":w(t)||void 0,hidden:S&&w(t),children:r},or(t)??`block-${A}`):r),A++}}C=(0,Z.jsx)(Z.Fragment,{children:k}),t[0]=r,t[1]=m,t[2]=c,t[3]=o,t[4]=x,t[5]=a,t[6]=i,t[7]=s,t[8]=f,t[9]=S,t[10]=v,t[11]=b,t[12]=u,t[13]=_,t[14]=h,t[15]=n,t[16]=p,t[17]=l,t[18]=C}else C=t[18];return C}function Th(e){return e.type===`text`&&e.presentation===`pending`}var Eh=[`readFile`,`editFile`,`writeFile`,`runCommand`,`memorySearch`,`codeSearch`,`webSearch`,`search`,`fetchUrl`,`openUrl`,`listDir`,`other`];function Dh(e,t){return ma(e,t)}function Oh(e){let t=new Map;for(let n of e){if(n.type!==`tool_use`)continue;let e=Dh(n.name,n.activity),r=t.get(e)??{total:0,running:0};r.total+=1,(n.status===`running`||n.activity?.status===`running`)&&(r.running+=1),t.set(e,r)}return t}function kh(e,t){switch(e){case`webSearch`:return t.webSearch;case`memorySearch`:return t.memorySearch;case`codeSearch`:return t.codeSearch;case`search`:return t.search;case`readFile`:return t.readFile;case`editFile`:return t.editFile;case`writeFile`:return t.writeFile;case`runCommand`:return t.runCommand;case`listDir`:return t.listDir;case`openUrl`:return t.openUrl;case`fetchUrl`:return t.fetchUrl;case`other`:return t.other}}function Ah(e,t,n){let r=Oh(e),i=[];for(let e of Eh){let t=r.get(e);t&&t.running>0&&i.push(e)}if(i.length===1){let r=[...e].reverse().find(e=>e.type===`tool_use`&&(e.status===`running`||e.activity?.status===`running`));return(r?n?.(r):null)||kh(i[0],t)}return i.length>1?t.mixed:e.some(e=>e.type===`thinking`&&e.streaming)?t.thinking:r.size>0?t.mixed:null}function jh(e){return e.filter(e=>e.type!==`thinking`||!!e.text?.trim()||!!e.streaming)}function Mh(e,t,n){return Ah(e,t,n)}function Nh(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Ph(e){if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}}function Fh(e){let t=Nh(Ph(e));if(!t)return[];let n=Nh(t.details)?.results??t.results;if(Array.isArray(n))return n.map(Nh).filter(e=>e!==null);let r=Array.isArray(t.content)?t.content:[];for(let e of r){let t=Nh(e)?.text,n=Nh(Ph(t));if(Array.isArray(n?.results))return n.results.map(Nh).filter(e=>e!==null)}return[]}function Ih(e,t){return e.replace(/\{\{count\}\}/g,String(t))}function Lh(e,t){if(e.status===`running`||e.activity?.status===`running`)return{title:t.running,purpose:t.purpose};if(e.status===`error`||e.activity?.status===`failed`)return{title:t.failed,purpose:t.purpose};let n=Fh(e.result),r=e.activity?.count??n.length;return{title:r===0?t.empty:Ih(r===1?t.found_one:t.found_other,r),purpose:t.purpose}}function Rh(e){if(e.scrollHeight<=e.clientHeight)return!1;let t=window.getComputedStyle(e).overflowY;return t===`auto`||t===`scroll`}function zh(e,t,n){let r=[],i=e instanceof HTMLElement?e:t;for(;i&&i!==t;)Rh(i)&&r.push(i),i=i.parentElement;return t.scrollHeight>t.clientHeight&&r.push(t),n!==t&&r.push(n),r}function Bh(e,t){let n=e;for(let e of t){let t=Math.max(0,e.scrollHeight-e.clientHeight),r=Math.min(t,Math.max(0,e.scrollTop+n)),i=r-e.scrollTop;if(i!==0&&(e.scrollTop=r),n-=i,Math.abs(n)<.01)break}}function Vh(e,t){if(e.defaultPrevented||e.ctrlKey||e.deltaY===0||Math.abs(e.deltaY)<=Math.abs(e.deltaX))return;let n=t.closest(`.chat-messages`);if(!n)return;let r=t.clientHeight||n.clientHeight,i=e.deltaMode===WheelEvent.DOM_DELTA_LINE?16:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?r:1,a=zh(e.target,t,n);e.preventDefault(),Bh(e.deltaY*i,a)}function Hh(e){if(e===void 0)return``;try{return JSON.stringify(JSON.parse(e),null,2)}catch{try{return JSON.stringify(e,null,2)}catch{return String(e)}}}function Uh(e){if(e==null)return null;try{return typeof e==`string`?JSON.parse(e):e}catch{return null}}function Wh(e){let t=Uh(e),n=t?.path??t?.file_path??t?.filepath??t?.file??t?.qualified_name??t?.function_name;return typeof n==`string`?n:``}function Gh(e){let t=Uh(e),n=t?.url??t?.href??t?.uri??t?.website;return typeof n==`string`?n:``}function Kh(e){let t=Uh(e),n=t?.command??t?.cmd??t?.shell??t?.script;return typeof n==`string`?n:``}var qh=120;function Jh(e){if(e==null)return``;let t=Uh(e);if(!t)return typeof e==`string`?e.trim():``;let n=[t.command,t.cmd,t.shell,t.script,t.path,t.file_path,t.filepath,t.file,t.url,t.href,t.uri,t.website,t.query,t.q,t.query_string,t.search_term,t.searchQuery,t.qualified_name,t.function_name,t.name_pattern,t.qn_pattern,t.file_pattern];for(let e of n){if(typeof e==`string`&&e.trim()){let t=e.trim();return t.length>qh?`${t.slice(0,qh)}…`:t}if(typeof e==`number`&&Number.isFinite(e))return String(e)}return``}function Yh(e){return e.startsWith(`@@`)?`hunk`:e.startsWith(`+++`)||e.startsWith(`---`)||e.startsWith(`diff `)||e.startsWith(`index `)?`meta`:e.startsWith(`+`)?`add`:e.startsWith(`-`)?`del`:`context`}function Xh(e){let t=e.details?.diff;if(typeof t!=`string`||t.length===0)return null;let n=t.split(`
17
+ `),r=[],i=0,a=0;for(let e of n){let t=Yh(e);t===`add`&&!e.startsWith(`+++`)&&i++,t===`del`&&!e.startsWith(`---`)&&a++,r.push({kind:t,text:e})}return{raw:t,lines:r,added:i,removed:a}}function Zh(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function Qh(e){if(typeof e==`string`)return e;if(!Array.isArray(e))return``;let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;e.type===`text`&&typeof e.text==`string`&&t.push(e.text)}return t.join(`
18
+ `)}function $h(e){if(e==null)return{details:null,text:``,isStructured:!1};if(typeof e==`object`&&!Array.isArray(e)){let t=e;return`content`in t||`details`in t?{details:Zh(t.details),text:Qh(t.content),isStructured:!0}:{details:null,text:``,isStructured:!1}}if(typeof e==`string`){let t=e.trim();if(t.startsWith(`{`))try{let e=Zh(JSON.parse(t));if(e&&(`content`in e||`details`in e))return{details:Zh(e.details),text:Qh(e.content),isStructured:!0}}catch{}return{details:null,text:e,isStructured:!1}}return{details:null,text:String(e),isStructured:!1}}var eg=`inline-flex max-w-full min-w-0 items-center gap-1 rounded-md bg-accent-soft/40 px-1.5 py-0.5 text-[11px] font-medium text-fg-muted [overflow-wrap:anywhere] dark:bg-accent-soft/25`,tg=`inline-flex max-w-full min-w-0 items-center break-words rounded-md bg-surface-hover/60 px-1.5 py-0.5 font-mono text-xs text-fg [overflow-wrap:anywhere] dark:bg-surface-hover/35`,ng=`max-h-72 w-full min-w-0 max-w-full overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-md bg-surface-hover/60 p-2 font-mono text-xs text-fg-muted [overflow-wrap:anywhere] dark:bg-surface-hover/35`,rg=`cursor-pointer select-none text-xs text-fg-subtle underline-offset-2 hover:text-fg-muted group-open:text-fg-muted`;function ig(e){let t=(0,X.c)(5),{children:n,tone:r}=e,i=r===void 0?`neutral`:r,a=i===`positive`?`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`:i===`negative`?`bg-red-500/15 text-red-700 dark:text-red-300`:i===`warning`?`bg-amber-500/15 text-amber-700 dark:text-amber-300`:i===`accent`?`bg-accent-soft/70 text-accent-fg dark:bg-accent-soft/50`:``,o;t[0]===a?o=t[1]:(o=Y(eg,a),t[0]=a,t[1]=o);let s;return t[2]!==n||t[3]!==o?(s=(0,Z.jsx)(`span`,{className:o,children:n}),t[2]=n,t[3]=o,t[4]=s):s=t[4],s}function ag(e){let t=(0,X.c)(3),{children:n,title:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,Z.jsx)(`code`,{className:tg,title:r,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}var og=(0,Q.memo)(function(e){let t=(0,X.c)(10),{text:n,label:r,copiedLabel:i}=e,[a,o]=(0,Q.useState)(!1),s;t[0]===n?s=t[1]:(s=async e=>{e.preventDefault(),e.stopPropagation(),await Ti(n)&&(o(!0),window.setTimeout(()=>o(!1),1200))},t[0]=n,t[1]=s);let c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=Y(`content-block-action text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,ua.transition,ua.focusRingPanel),t[2]=c):c=t[2];let l=a?i:r,u=a?i:r,d;t[3]===a?d=t[4]:(d=a?(0,Z.jsx)(ee,{className:`size-3.5`,"aria-hidden":!0}):(0,Z.jsx)(ye,{className:`size-3.5`,"aria-hidden":!0}),t[3]=a,t[4]=d);let f;return t[5]!==s||t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,Z.jsx)(`button`,{type:`button`,onClick:s,className:c,"aria-label":l,title:u,children:d}),t[5]=s,t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9],f});function sg(e){let t=(0,X.c)(8),{summary:n,children:r,defaultOpen:i}=e,a=i!==void 0&&i,o;t[0]===n?o=t[1]:(o=(0,Z.jsx)(`summary`,{className:rg,children:n}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,Z.jsx)(`div`,{className:`mt-1.5 min-w-0`,children:r}),t[2]=r,t[3]=s);let c;return t[4]!==a||t[5]!==o||t[6]!==s?(c=(0,Z.jsxs)(`details`,{className:`group min-w-0 text-xs`,open:a,children:[o,s]}),t[4]=a,t[5]=o,t[6]=s,t[7]=c):c=t[7],c}function cg(e){let t=(0,X.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`pre`,{className:ng,children:n}),t[0]=n,t[1]=r),r}function lg(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>{let r=t[n];return r==null?``:String(r)})}function ug(e){return e.details??{}}var dg=/\[(\d+)\/(\d+) lines\]\s*$/;function fg(e){let t=e.match(dg);if(!t)return null;let n=Number(t[1]),r=Number(t[2]);return!Number.isFinite(n)||!Number.isFinite(r)?null:{shown:n,total:r}}function pg(e){return e.replace(dg,``).trimEnd()}var mg=(0,Q.memo)(function(e){let t=(0,X.c)(32),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=Wh(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=$h(n.result),t[2]=n.result,t[3]=o);let s=o.text,c;t[4]===s?c=t[5]:(c=fg(s),t[4]=s,t[5]=c);let l=c,u;t[6]===s?u=t[7]:(u=pg(s),t[6]=s,t[7]=u);let d=u,f;bb0:{if(l){f=l.total;break bb0}if(!d){f=0;break bb0}let e;t[8]===d?e=t[9]:(e=d.split(`
19
+ `),t[8]=d,t[9]=e),f=e.length}let p=f,m;if(t[10]!==d){bb1:{if(!d){m=``;break bb1}let e=d.split(`
20
+ `);if(e.length<=12){m=d;break bb1}m=`${e.slice(0,12).join(`
21
+ `)}\n…`}t[10]=d,t[11]=m}else m=t[11];let h=m,g;t[12]===a?g=t[13]:(g=a?(0,Z.jsx)(ag,{title:a,children:a}):null,t[12]=a,t[13]=g);let _;t[14]!==r||t[15]!==l||t[16]!==p?(_=p>0?(0,Z.jsx)(ig,{children:l&&l.shown<l.total?lg(r.linesPartial,{shown:l.shown,total:l.total}):lg(r.linesBadge,{count:p})}):null,t[14]=r,t[15]=l,t[16]=p,t[17]=_):_=t[17];let v;t[18]!==r||t[19]!==a?(v=a?(0,Z.jsx)(og,{text:a,label:r.copyPath,copiedLabel:r.copied}):null,t[18]=r,t[19]=a,t[20]=v):v=t[20];let y;t[21]!==g||t[22]!==_||t[23]!==v?(y=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,children:[g,_,v]}),t[21]=g,t[22]=_,t[23]=v,t[24]=y):y=t[24];let b;t[25]!==d||t[26]!==r||t[27]!==h?(b=d?(0,Z.jsx)(sg,{summary:r.viewContent,children:(0,Z.jsx)(cg,{children:h})}):null,t[25]=d,t[26]=r,t[27]=h,t[28]=b):b=t[28];let x;return t[29]!==y||t[30]!==b?(x=(0,Z.jsxs)(`div`,{className:`content-block-action-scope space-y-1.5`,children:[y,b]}),t[29]=y,t[30]=b,t[31]=x):x=t[31],x});function hg(e){let t=(0,X.c)(4),{lines:n}=e,r;t[0]===n?r=t[1]:(r=n.map(gg),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,Z.jsx)(`pre`,{className:`max-h-80 w-full min-w-0 max-w-full overflow-auto rounded-md bg-surface-hover/60 p-2 font-mono text-xs leading-snug text-fg-muted dark:bg-surface-hover/35`,children:r}),t[2]=r,t[3]=i),i}function gg(e,t){return(0,Z.jsx)(`div`,{className:Y(`whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,e.kind===`add`&&`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`,e.kind===`del`&&`bg-red-500/15 text-red-700 dark:text-red-300`,e.kind===`hunk`&&`text-fg-subtle`,e.kind===`meta`&&`text-fg-disabled`),children:e.text||`\xA0`},t)}var _g=(0,Q.memo)(function(e){let t=(0,X.c)(25),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=Wh(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=$h(n.result),t[2]=n.result,t[3]=o);let s=o,c;t[4]===s?c=t[5]:(c=Xh(s),t[4]=s,t[5]=c);let l=c,u;t[6]===a?u=t[7]:(u=a?(0,Z.jsx)(ag,{title:a,children:a}):null,t[6]=a,t[7]=u);let d;t[8]!==l||t[9]!==r?(d=l?(0,Z.jsx)(ig,{tone:`accent`,children:lg(r.diffStats,{added:l.added,removed:l.removed})}):null,t[8]=l,t[9]=r,t[10]=d):d=t[10];let f;t[11]!==r||t[12]!==a?(f=a?(0,Z.jsx)(og,{text:a,label:r.copyPath,copiedLabel:r.copied}):null,t[11]=r,t[12]=a,t[13]=f):f=t[13];let p;t[14]!==u||t[15]!==d||t[16]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,children:[u,d,f]}),t[14]=u,t[15]=d,t[16]=f,t[17]=p):p=t[17];let m;t[18]!==l||t[19]!==r||t[20]!==s?(m=l?(0,Z.jsx)(sg,{summary:r.viewDiff,defaultOpen:!0,children:(0,Z.jsx)(hg,{lines:l.lines})}):s.text?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted [overflow-wrap:anywhere]`,children:s.text}):null,t[18]=l,t[19]=r,t[20]=s,t[21]=m):m=t[21];let h;return t[22]!==p||t[23]!==m?(h=(0,Z.jsxs)(`div`,{className:`content-block-action-scope space-y-1.5`,children:[p,m]}),t[22]=p,t[23]=m,t[24]=h):h=t[24],h});function vg(e){return!Number.isFinite(e)||e<0?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var yg=(0,Q.memo)(function(e){let t=(0,X.c)(20),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=Wh(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=$h(n.result),t[2]=n.result,t[3]=o);let s=o,c,l,u;if(t[4]!==r||t[5]!==s||t[6]!==a){let e=ug(s),n=typeof e.size==`number`?e.size:null;c=`content-block-action-scope flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,t[10]===a?l=t[11]:(l=a?(0,Z.jsx)(ag,{title:a,children:a}):null,t[10]=a,t[11]=l),u=n==null?null:(0,Z.jsx)(ig,{children:lg(r.sizeBadge,{size:vg(n)})}),t[4]=r,t[5]=s,t[6]=a,t[7]=c,t[8]=l,t[9]=u}else c=t[7],l=t[8],u=t[9];let d;t[12]!==r||t[13]!==a?(d=a?(0,Z.jsx)(og,{text:a,label:r.copyPath,copiedLabel:r.copied}):null,t[12]=r,t[13]=a,t[14]=d):d=t[14];let f;return t[15]!==c||t[16]!==l||t[17]!==u||t[18]!==d?(f=(0,Z.jsxs)(`div`,{className:c,children:[l,u,d]}),t[15]=c,t[16]=l,t[17]=u,t[18]=d,t[19]=f):f=t[19],f}),bg=12;function xg(e){if(!e)return{preview:``,truncated:!1};let t=e.split(`
22
+ `);return t.length<=bg?{preview:e,truncated:!1}:{preview:`${t.slice(0,bg).join(`
23
+ `)}\n…`,truncated:!0}}var Sg=(0,Q.memo)(function(e){let t=(0,X.c)(29),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=Kh(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=$h(n.result),t[2]=n.result,t[3]=o);let s=o,c=n.details&&typeof n.details==`object`&&!Array.isArray(n.details)?n.details:null,l;t[4]!==c||t[5]!==s?(l=c??ug(s),t[4]=c,t[5]=s,t[6]=l):l=t[6];let u=l,d=!!u.truncated,f=typeof u.aggregatedOutput==`string`&&u.aggregatedOutput.length>0?u.aggregatedOutput:s.text,p;t[7]===f?p=t[8]:(p=xg(f),t[7]=f,t[8]=p);let{preview:m}=p,h;t[9]===a?h=t[10]:(h=a?(0,Z.jsxs)(ag,{title:a,children:[(0,Z.jsx)(`span`,{className:`mr-1 text-fg-disabled`,children:`$`}),a]}):null,t[9]=a,t[10]=h);let g;t[11]!==r||t[12]!==d?(g=d?(0,Z.jsx)(ig,{children:r.truncatedBadge}):null,t[11]=r,t[12]=d,t[13]=g):g=t[13];let _;t[14]!==a||t[15]!==r?(_=a?(0,Z.jsx)(og,{text:a,label:r.copyCommand,copiedLabel:r.copied}):null,t[14]=a,t[15]=r,t[16]=_):_=t[16];let v;t[17]!==h||t[18]!==g||t[19]!==_?(v=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,children:[h,g,_]}),t[17]=h,t[18]=g,t[19]=_,t[20]=v):v=t[20];let y;t[21]!==n.status||t[22]!==r||t[23]!==f||t[24]!==m?(y=f?(0,Z.jsx)(sg,{summary:r.viewOutput,children:(0,Z.jsx)(cg,{children:m})}):n.status===`running`?null:(0,Z.jsx)(`p`,{className:`text-xs text-fg-disabled`,children:r.noOutput}),t[21]=n.status,t[22]=r,t[23]=f,t[24]=m,t[25]=y):y=t[25];let b;return t[26]!==v||t[27]!==y?(b=(0,Z.jsxs)(`div`,{className:`content-block-action-scope space-y-1.5`,children:[v,y]}),t[26]=v,t[27]=y,t[28]=b):b=t[28],b}),Cg=(0,Q.memo)(function(e){let t=(0,X.c)(27),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=Gh(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=$h(n.result),t[2]=n.result,t[3]=o);let s=o,c,l,u,d,f;if(t[4]!==r||t[5]!==s||t[6]!==a){let e=ug(s),n=typeof e.extractedLength==`number`?e.extractedLength:null,i;if(t[12]!==s.text){bb0:{if(!s.text){i=``;break bb0}let e=s.text.split(`
24
+ `);if(e.length<=12){i=s.text;break bb0}i=`${e.slice(0,12).join(`
25
+ `)}\n…`}t[12]=s.text,t[13]=i}else i=t[13];c=i,f=`space-y-1.5`,l=`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,t[14]===a?u=t[15]:(u=a?(0,Z.jsx)(`a`,{href:a,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex max-w-full min-w-0 items-center break-words rounded-md bg-surface-hover/60 px-1.5 py-0.5 font-mono text-xs text-accent-fg underline-offset-2 hover:underline [overflow-wrap:anywhere] dark:bg-surface-hover/35`,title:a,children:a}):null,t[14]=a,t[15]=u),d=n!=null&&n>0?(0,Z.jsx)(ig,{children:lg(r.linesBadge,{count:n})}):null,t[4]=r,t[5]=s,t[6]=a,t[7]=c,t[8]=l,t[9]=u,t[10]=d,t[11]=f}else c=t[7],l=t[8],u=t[9],d=t[10],f=t[11];let p;t[16]!==l||t[17]!==u||t[18]!==d?(p=(0,Z.jsxs)(`div`,{className:l,children:[u,d]}),t[16]=l,t[17]=u,t[18]=d,t[19]=p):p=t[19];let m;t[20]!==r||t[21]!==c?(m=c?(0,Z.jsx)(sg,{summary:r.viewContent,children:(0,Z.jsx)(cg,{children:c})}):null,t[20]=r,t[21]=c,t[22]=m):m=t[22];let h;return t[23]!==f||t[24]!==p||t[25]!==m?(h=(0,Z.jsxs)(`div`,{className:f,children:[p,m]}),t[23]=f,t[24]=p,t[25]=m,t[26]=h):h=t[26],h}),wg=e=>e&&typeof e==`object`&&!Array.isArray(e)?e:void 0,Tg=e=>typeof e==`string`&&/^[a-z0-9][a-z0-9_-]{0,63}$/.test(e)?e:void 0;function Eg(e){let t={...$h(e.result).details,...wg(e.details)},n=wg(t?.searchInfo)??t,r=Array.isArray(n?.attempts)?n.attempts.slice(0,24).flatMap(e=>{let t=wg(e),n=Tg(t?.provider);return!n||![`success`,`empty`,`error`,`skipped`].includes(String(t?.outcome))?[]:[{provider:n,upstream:Tg(t?.upstream),outcome:String(t?.outcome),reason:Tg(t?.reason)}]}):[];return{provider:Tg(n?.provider),upstream:Tg(n?.upstream),cached:typeof n?.cached==`boolean`?n.cached:void 0,capturedAt:typeof n?.capturedAt==`number`&&Number.isSafeInteger(n.capturedAt)&&n.capturedAt>0?n.capturedAt:void 0,attemptCount:typeof n?.attemptCount==`number`&&Number.isSafeInteger(n.attemptCount)&&n.attemptCount>0&&n.attemptCount<=1e4?n.attemptCount:void 0,attempts:r}}function Dg(e,t){return{deepseek:`DeepSeek`,"xopc-cloud":`XOPC Cloud`,tavily:`Tavily`,brave:`Brave`,bing:`Bing`,searxng:`SearXNG`,"bing-html":`Bing HTML`,"duckduckgo-html":`DuckDuckGo HTML`,html:`HTML`}[e??``]??t}function Og(e){let t=(0,X.c)(25),{block:n,summary:r,labels:i,developer:a,language:o}=e,[s,c]=(0,Q.useState)(!1),l;if(t[0]!==n||t[1]!==a||t[2]!==i.attempts||t[3]!==i.cacheHint||t[4]!==i.cacheUnknown||t[5]!==i.cached||t[6]!==i.cachedRoute||t[7]!==i.capturedAt||t[8]!==i.fresh||t[9]!==i.incompleteRoute||t[10]!==i.outcomes||t[11]!==i.provider||t[12]!==i.reasons||t[13]!==i.route||t[14]!==i.unknown||t[15]!==i.upstreamUnknown||t[16]!==o||t[17]!==s||t[18]!==r){let e=Eg(n),u;t[20]===i.unknown?u=t[21]:(u=e=>Dg(e,i.unknown),t[20]=i.unknown,t[21]=u);let d=u,f=e.provider===`xopc-cloud`?`${d(e.provider)} · ${e.upstream?d(e.upstream):i.upstreamUnknown}`:d(e.provider),p;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(p=e=>c(e.currentTarget.open),t[22]=p):p=t[22];let m;t[23]===r?m=t[24]:(m=(0,Z.jsx)(`summary`,{className:`cursor-pointer hover:text-fg`,children:r}),t[23]=r,t[24]=m),l=(0,Z.jsxs)(`details`,{className:`min-w-0 text-xs text-fg-muted`,onToggle:p,children:[m,s?(0,Z.jsxs)(`div`,{className:`mt-2 space-y-2 rounded-md border border-edge px-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Z.jsxs)(`span`,{children:[i.provider,`:`,f]}),(0,Z.jsx)(`span`,{className:`text-fg-subtle`,children:e.cached===!0?i.cached:e.cached===!1?i.fresh:i.cacheUnknown})]}),e.cached===!0?(0,Z.jsx)(`p`,{className:`text-fg-subtle`,children:i.cacheHint}):null,a?(0,Z.jsxs)(`div`,{className:`space-y-1 border-t border-edge pt-2 text-fg-subtle`,children:[e.attemptCount===void 0?null:(0,Z.jsxs)(`p`,{children:[i.attempts,`:`,e.attemptCount]}),e.capturedAt===void 0?null:(0,Z.jsxs)(`p`,{children:[i.capturedAt,`:`,new Date(e.capturedAt).toLocaleString(o===`zh`?`zh-CN`:`en-US`)]}),e.attemptCount!==void 0&&e.attemptCount>e.attempts.length?(0,Z.jsx)(`p`,{children:i.incompleteRoute}):null,e.attempts.length?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{children:e.cached===!0?i.cachedRoute:i.route}),(0,Z.jsx)(`ol`,{className:`list-inside list-decimal space-y-1`,children:e.attempts.map((e,t)=>(0,Z.jsxs)(`li`,{children:[d(e.provider),e.upstream?` · ${d(e.upstream)}`:``,` · `,i.outcomes[e.outcome]??i.unknown,e.reason?` · ${i.reasons[e.reason]??i.unknown}`:``]},t))})]}):null]}):null]}):null]}),t[0]=n,t[1]=a,t[2]=i.attempts,t[3]=i.cacheHint,t[4]=i.cacheUnknown,t[5]=i.cached,t[6]=i.cachedRoute,t[7]=i.capturedAt,t[8]=i.fresh,t[9]=i.incompleteRoute,t[10]=i.outcomes,t[11]=i.provider,t[12]=i.reasons,t[13]=i.route,t[14]=i.unknown,t[15]=i.upstreamUnknown,t[16]=o,t[17]=s,t[18]=r,t[19]=l}else l=t[19];return l}function kg(e,t){if(!Number.isFinite(e)||e<=0)return t===`zh`?`不到1秒`:`<1s`;let n=Math.floor(e/1e3);if(n===0)return t===`zh`?`不到1秒`:`<1s`;let r=Math.floor(n/60),i=n%60;return t===`zh`?r===0?`${i}秒`:i===0?`${r}分`:`${r}分${i}秒`:r===0?`${i}s`:i===0?`${r}m`:`${r}m ${i}s`}function Ag(e){let t=(0,X.c)(8),{extensionId:n,extensionName:r,entrypoint:i,title:a,toolResult:o,maxHeight:s,interactive:c,permissions:l}=e,u=s===void 0?400:s,d;return t[0]!==i||t[1]!==n||t[2]!==r||t[3]!==u||t[4]!==l||t[5]!==a||t[6]!==o?(d=(0,Z.jsx)(`div`,{className:`mt-2 w-full min-w-0 overflow-hidden rounded-xl border border-edge bg-surface-base`,children:(0,Z.jsx)(Fo,{extensionId:n,extensionName:r,entrypoint:i,permissions:l,title:a,className:`w-full`,minHeight:80,maxHeight:u,initialData:o})}),t[0]=i,t[1]=n,t[2]=r,t[3]=u,t[4]=l,t[5]=a,t[6]=o,t[7]=d):d=t[7],d}function jg(e){let t=Wr();return(0,Q.useMemo)(()=>{for(let n of t){let t=n.ui?.contributions?.chatWidgets;if(t){for(let r of t)if(r.match.toolName&&r.match.toolName===e)return{...r,extensionId:n.id}}}return null},[t,e])}function Mg(e,t){let n=new Set,r=[];for(let i of e){let e=i.type===`tool_use`?t?.(i):null,a=i.type===`text`&&i.presentation===`narration`?i:e?{type:`text`,text:e,presentation:`narration`,segmentId:`tool-progress:${i.type===`tool_use`?i.id:``}`}:null;if(!a)continue;let o=a.text.replace(/\s+/g,` `).trim();!o||/^(?:正在处理|正在执行操作|其他操作|处理中|working|processing|other operations?|running)[.。…\s]*$/i.test(o)||n.has(o)||(n.add(o),r.push(a))}return r}function Ng(e){let t=[];for(let n of e){let e=t.at(-1);n.type===`tool_use`?e?.type===`tools`?e.tools.push(n):t.push({type:`tools`,tools:[n]}):t.push({type:`item`,item:n})}return t}function Pg(e,t,n){let r=new Map,i=0;for(let n of e){if(n.status===`error`||n.activity?.status===`failed`){i++;continue}let e=t(n);r.set(e,(r.get(e)??0)+1)}let a=[...r],o=a.slice(0,2).map(([e,t])=>t===1?e:n.repeated.replace(`{{action}}`,e).replace(`{{count}}`,String(t))),s=a.slice(2).reduce((e,[,t])=>e+t,0);return s>0&&o.push(n.more.replace(`{{count}}`,String(s))),i>0&&o.push(n.failed.replace(`{{count}}`,String(i))),o.join(n.separator)}function Fg({path:e,conversationId:t,label:n}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(),s=Li(e=>e.setPath),c=async()=>{i(!0),o(void 0);try{let n=await za(e,{conversationId:t??void 0});if(!n?.capabilities.includes(`preview`))throw Error(`Output file is unavailable`);s(n.absolutePath??n.workspaceRelativePath??e,void 0,void 0,t)}catch(e){o(e instanceof Error?e.message:String(e))}finally{i(!1)}};return(0,Z.jsxs)(`div`,{className:`mt-2`,children:[(0,Z.jsx)(mi,{variant:`ghost`,disabled:r,onClick:()=>{c()},className:`text-accent`,children:n}),a?(0,Z.jsx)(`p`,{className:`text-xs text-red-600`,children:a}):null]})}function Ig(e){return/^Full Codemode output: (\.xopc\/codemode-output\/[a-f0-9-]{36}\.txt)(?:\r?\n|$)/.exec(e)?.[1]}function Lg(e,t=0){return or(e)??(e.type===`tool_use`?e.id:e.type===`text`?e.segmentId??`narration-${t}`:`thinking-${t}`)}var Rg=(0,Q.memo)(function(e){let t=(0,X.c)(15),{active:n,startedAt:r,frozenMs:i,language:a,className:o}=e,[,s]=(0,Q.useState)(0),c;t[0]!==n||t[1]!==s?(c=()=>{if(!n)return;let e=window.setInterval(()=>s(f_),500);return()=>window.clearInterval(e)},t[0]=n,t[1]=s,t[2]=c):c=t[2];let l;t[3]===n?l=t[4]:(l=[n],t[3]=n,t[4]=l),(0,Q.useEffect)(c,l);let u=n&&r!=null?Math.max(0,Date.now()-r):0,d;t[5]!==n||t[6]!==u||t[7]!==i||t[8]!==a||t[9]!==r?(d=n&&r!=null?kg(u,a):i==null?null:kg(i,a),t[5]=n,t[6]=u,t[7]=i,t[8]=a,t[9]=r,t[10]=d):d=t[10];let f=d;if(!f)return null;let p=n||void 0,m;return t[11]!==o||t[12]!==p||t[13]!==f?(m=(0,Z.jsx)(`span`,{className:o,"aria-hidden":p,children:f}),t[11]=o,t[12]=p,t[13]=f,t[14]=m):m=t[14],m});function zg(e){let t=(0,X.c)(204),{workLog:n,pendingStatus:r,toolLabels:i,stepLabels:a,clusterLabels:o,cardLabels:s,conversationId:c,simplified:l,personal:u,answerStarted:d,showThinking:f,surfacesOnly:p,renderSurfaces:m}=e,g=l===void 0||l,_=u!==void 0&&u,v=d!==void 0&&d,b=f!==void 0&&f,x=p!==void 0&&p,S=m===void 0||m,C=h($g),[w,T]=(0,Q.useState)(!1),E,D;t[0]===r?(E=t[1],D=t[2]):(E=()=>{if(T(!1),r!==`waiting`)return;let e=window.setTimeout(()=>T(!0),3e3);return()=>window.clearTimeout(e)},D=[r],t[0]=r,t[1]=E,t[2]=D),(0,Q.useEffect)(E,D);let O;t[3]===C?O=t[4]:(O=y(C),t[3]=C,t[4]=O);let k=O.chat,A=Po(Qg),j;if(t[5]!==A||t[6]!==b||t[7]!==n.items){let e;t[9]!==A||t[10]!==b?(e=e=>e.type!==`thinking`||A||b,t[9]=A,t[10]=b,t[11]=e):e=t[11],j=n.items.filter(e),t[5]=A,t[6]=b,t[7]=n.items,t[8]=j}else j=t[8];let M=j,N;t[12]===n.items?N=t[13]:(N=n.items.filter(Zg),t[12]=n.items,t[13]=N);let P=N,F=M.length,I=n.active,L=n.expandedByDefault&&I,[R,z]=(0,Q.useState)(null),B=R?.active===I?R.value:null,V=L,[H,U]=(0,Q.useState)(!1),W=(0,Q.useRef)(null),[G,ee]=(0,Q.useState)(!1),[ne,re]=(0,Q.useState)(!1),ie,ae;t[14]!==I||t[15]!==G?(ie=()=>{if(!I&&!G)return;let e=()=>{let e=window.getSelection();ee(!!(e&&!e.isCollapsed&&W.current?.contains(e.anchorNode)))};return document.addEventListener(`selectionchange`,e),()=>document.removeEventListener(`selectionchange`,e)},ae=[I,G],t[14]=I,t[15]=G,t[16]=ie,t[17]=ae):(ie=t[16],ae=t[17]),(0,Q.useEffect)(ie,ae);let K=!n.compact&&M.length>0&&(B??(V||G)),oe,se;t[18]===K?(oe=t[19],se=t[20]):(oe=()=>{let e=W.current;if(!K||!e)return;let t=t=>Vh(t,e);return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},se=[K],t[18]=K,t[19]=oe,t[20]=se),(0,Q.useEffect)(oe,se);let q,ce;t[21]!==K||t[22]!==ne?(q=()=>{if(K){re(!0);return}if(!ne)return;let e=window.setTimeout(()=>re(!1),200);return()=>window.clearTimeout(e)},ce=[K,ne],t[21]=K,t[22]=ne,t[23]=q,t[24]=ce):(q=t[23],ce=t[24]),(0,Q.useEffect)(q,ce);let le;t[25]===M?le=t[26]:(le=M.every(Xg),t[25]=M,t[26]=le);let ue=le,de,fe;if(t[27]!==I||t[28]!==H||t[29]!==A||t[30]!==ue||t[31]!==M){let e=Ng(M);de=ue&&I&&!H&&!A?Math.max(0,e.length-3):0,fe=e.slice(de).flatMap(Yg),t[27]=I,t[28]=H,t[29]=A,t[30]=ue,t[31]=M,t[32]=de,t[33]=fe}else de=t[32],fe=t[33];let J=fe,pe=n.startedAt??null,me=n.durationMs??null,he;t[34]!==a.editFile||t[35]!==a.fetchUrl||t[36]!==a.listDirectory||t[37]!==a.openUrl||t[38]!==a.readFile||t[39]!==a.runCommand||t[40]!==a.searched||t[41]!==a.searchedCode||t[42]!==a.searchedMemory||t[43]!==a.searchedWeb||t[44]!==a.unknownTool||t[45]!==a.writeFile?(he={searchedWeb:a.searchedWeb,searchedMemory:a.searchedMemory,searchedCode:a.searchedCode,searched:a.searched,readFile:a.readFile,runCommand:a.runCommand,listDirectory:a.listDirectory,writeFile:a.writeFile,editFile:a.editFile,openUrl:a.openUrl,fetchUrl:a.fetchUrl,unknownTool:a.unknownTool},t[34]=a.editFile,t[35]=a.fetchUrl,t[36]=a.listDirectory,t[37]=a.openUrl,t[38]=a.readFile,t[39]=a.runCommand,t[40]=a.searched,t[41]=a.searchedCode,t[42]=a.searchedMemory,t[43]=a.searchedWeb,t[44]=a.unknownTool,t[45]=a.writeFile,t[46]=he):he=t[46];let ge=he,_e;t[47]!==o.ing||t[48]!==ge||t[49]!==a.toolActivity?(_e=(e,t)=>pa(e,t,a.toolActivity,ge,o.ing),t[47]=o.ing,t[48]=ge,t[49]=a.toolActivity,t[50]=_e):_e=t[50];let ve=_e,ye;bb0:{if(!I){ye=null;break bb0}let e;t[51]===P?e=t[52]:(e=P.filter(Jg),t[51]=P,t[52]=e);let n=e.length;if(n>1){let e;t[53]!==k.activityParallel||t[54]!==n?(e=k.activityParallel.replace(`{{count}}`,String(n)),t[53]=k.activityParallel,t[54]=n,t[55]=e):e=t[55],ye=e;break bb0}let r;t[56]===ve?r=t[57]:(r=e=>ve(e,`running`),t[56]=ve,t[57]=r);let i;t[58]!==P||t[59]!==o.ing||t[60]!==r?(i=Mh(P,o.ing,r),t[58]=P,t[59]=o.ing,t[60]=r,t[61]=i):i=t[61],ye=i}let be=ye,xe=r===`sending`?k.sendingLabel:r===`waiting`?w?k.waitingLongLabel:k.waitingLabel:null,Se;t[62]!==P||t[63]!==k.thinkingLabel||t[64]!==a.workLogRunning?(Se=P.some(qg)?k.thinkingLabel:a.workLogRunning,t[62]=P,t[63]=k.thinkingLabel,t[64]=a.workLogRunning,t[65]=Se):Se=t[65];let Ce=Se,we=r??(P.some(Kg)?`tool`:P.some(Gg)?`thinking`:P.length>0?`organizing`:`working`),Te=be??xe??Ce,Ee;if(t[66]!==P||t[67]!==k.activityFailed||t[68]!==k.activityMore||t[69]!==k.activityRepeated||t[70]!==C||t[71]!==ve||t[72]!==b||t[73]!==a.thoughts){let e=P.filter(Wg);Ee=b&&e.length>0?Pg(e,e=>ve(e,`completed`),{repeated:k.activityRepeated,more:k.activityMore,failed:k.activityFailed,separator:C===`zh`?`、`:`, `}):b?a.thoughts:null,t[66]=P,t[67]=k.activityFailed,t[68]=k.activityMore,t[69]=k.activityRepeated,t[70]=C,t[71]=ve,t[72]=b,t[73]=a.thoughts,t[74]=Ee}else Ee=t[74];let De=Ee;if(n.items.length===0&&!I)return null;let Oe;t[75]!==o.ing||t[76]!==a.editFile||t[77]!==a.fetchUrl||t[78]!==a.listDirectory||t[79]!==a.memoryActivity||t[80]!==a.openUrl||t[81]!==a.rawThinking||t[82]!==a.readFile||t[83]!==a.runCommand||t[84]!==a.searched||t[85]!==a.searchedCode||t[86]!==a.searchedMemory||t[87]!==a.searchedWeb||t[88]!==a.stepDetails||t[89]!==a.thoughts||t[90]!==a.thoughtsStreaming||t[91]!==a.toolActivity||t[92]!==a.toolError||t[93]!==a.unknownTool||t[94]!==a.writeFile?(Oe={thoughts:a.thoughts,thoughtsStreaming:a.thoughtsStreaming,searchedWeb:a.searchedWeb,searchedMemory:a.searchedMemory,searchedCode:a.searchedCode,searched:a.searched,readFile:a.readFile,stepDetails:a.stepDetails,runCommand:a.runCommand,listDirectory:a.listDirectory,writeFile:a.writeFile,editFile:a.editFile,openUrl:a.openUrl,fetchUrl:a.fetchUrl,unknownTool:a.unknownTool,rawThinking:a.rawThinking,toolError:a.toolError,toolActivity:a.toolActivity,runningActions:o.ing,memoryActivity:a.memoryActivity},t[75]=o.ing,t[76]=a.editFile,t[77]=a.fetchUrl,t[78]=a.listDirectory,t[79]=a.memoryActivity,t[80]=a.openUrl,t[81]=a.rawThinking,t[82]=a.readFile,t[83]=a.runCommand,t[84]=a.searched,t[85]=a.searchedCode,t[86]=a.searchedMemory,t[87]=a.searchedWeb,t[88]=a.stepDetails,t[89]=a.thoughts,t[90]=a.thoughtsStreaming,t[91]=a.toolActivity,t[92]=a.toolError,t[93]=a.unknownTool,t[94]=a.writeFile,t[95]=Oe):Oe=t[95];let ke=Oe;if(_||x){let e;t[96]!==I||t[97]!==s||t[98]!==c||t[99]!==S||t[100]!==ke||t[101]!==i||t[102]!==n.items?(e=S&&n.items.filter(Ug).map(e=>(0,Z.jsx)(l_,{block:e,toolLabels:i,stepLabels:ke,cardLabels:s,conversationId:c,surfaceOnly:!0,runActive:I},e.id)),t[96]=I,t[97]=s,t[98]=c,t[99]=S,t[100]=ke,t[101]=i,t[102]=n.items,t[103]=e):e=t[103];let r;return t[104]===e?r=t[105]:(r=(0,Z.jsx)(Z.Fragment,{children:e}),t[104]=e,t[105]=r),r}let Ae;t[106]!==Te||t[107]!==I||t[108]!==me||t[109]!==De||t[110]!==pe||t[111]!==C||t[112]!==we||t[113]!==a.workLogComplete||t[114]!==a.workLogFailed||t[115]!==a.workLogPartial||t[116]!==a.workLogTitle||t[117]!==n.status?(Ae=I?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`block min-w-0 flex-1 truncate whitespace-nowrap`,"data-status-phase":we,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:(0,Z.jsx)(`span`,{className:`assistant-activity-shimmer inline-block max-w-full truncate align-bottom`,children:Te})}),(0,Z.jsx)(Rg,{active:I,startedAt:pe,frozenMs:null,language:C,className:`ml-1.5 w-[8ch] shrink-0 whitespace-nowrap text-right tabular-nums text-fg-muted`})]}):(0,Z.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:De??(n.status===`failed`?a.workLogFailed:n.status===`partial`?a.workLogPartial:me==null?a.workLogTitle:a.workLogComplete)}),t[106]=Te,t[107]=I,t[108]=me,t[109]=De,t[110]=pe,t[111]=C,t[112]=we,t[113]=a.workLogComplete,t[114]=a.workLogFailed,t[115]=a.workLogPartial,t[116]=a.workLogTitle,t[117]=n.status,t[118]=Ae):Ae=t[118];let je=Ae,Me;t[119]!==I||t[120]!==me||t[121]!==pe||t[122]!==C?(Me=I?null:(0,Z.jsx)(Rg,{active:!1,startedAt:pe,frozenMs:me,language:C,className:`mt-0.5 tabular-nums text-xs text-fg-muted`}),t[119]=I,t[120]=me,t[121]=pe,t[122]=C,t[123]=Me):Me=t[123];let Ne=Me,Pe=!n.compact&&F>0;if(g&&!A){let e;t[124]!==v||t[125]!==I||t[126]!==n.items?(e=!I&&!v&&n.items.some(Hg),t[124]=v,t[125]=I,t[126]=n.items,t[127]=e):e=t[127];let r=e,o=n.status===`failed`||n.status===`partial`||r,l,u,d,f,p;if(t[128]!==v||t[129]!==I||t[130]!==s||t[131]!==c||t[132]!==o||t[133]!==S||t[134]!==ve||t[135]!==ke||t[136]!==i||t[137]!==n.items||t[138]!==n.status){let e=I&&!v||o?Mg(n.items,e=>e.status===`error`||e.activity?.status===`failed`||!da(e.name)&&Dh(e.name,e.activity)===`other`?null:ve(e,I&&(e.status===`running`||e.activity?.status===`running`)?`running`:`completed`)):[];l=!0,u=n.status,d=`my-1 min-w-0 w-full text-left`,t[144]!==I||t[145]!==s||t[146]!==c||t[147]!==S||t[148]!==ke||t[149]!==i||t[150]!==n.items?(f=S&&n.items.filter(Vg).map(e=>(0,Z.jsx)(l_,{block:e,toolLabels:i,stepLabels:ke,cardLabels:s,conversationId:c,surfaceOnly:!0,runActive:I},e.id)),t[144]=I,t[145]=s,t[146]=c,t[147]=S,t[148]=ke,t[149]=i,t[150]=n.items,t[151]=f):f=t[151],p=e.length>0?(0,Z.jsx)(`div`,{"data-assistant-activity-flow":!0,className:`space-y-2.5 text-sm leading-relaxed text-fg-muted`,children:e.map((e,t)=>(0,Z.jsx)(l_,{block:e,toolLabels:i,stepLabels:ke,cardLabels:s,conversationId:c,runActive:I},Lg(e,t)))}):null,t[128]=v,t[129]=I,t[130]=s,t[131]=c,t[132]=o,t[133]=S,t[134]=ve,t[135]=ke,t[136]=i,t[137]=n.items,t[138]=n.status,t[139]=l,t[140]=u,t[141]=d,t[142]=f,t[143]=p}else l=t[139],u=t[140],d=t[141],f=t[142],p=t[143];let m;t[152]!==I||t[153]!==r||t[154]!==je||t[155]!==o||t[156]!==a.workLogFailed||t[157]!==a.workLogPartial||t[158]!==n.status?(m=I?(0,Z.jsxs)(`div`,{className:`mt-2 flex h-11 w-full min-w-0 items-center gap-2 px-1 text-sm text-fg-muted`,"data-assistant-running":!0,children:[(0,Z.jsx)(Bt,{className:`assistant-activity-busy size-4 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`div`,{className:`flex h-6 min-w-0 flex-1 items-center`,children:je})]}):o?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r||n.status===`failed`?a.workLogFailed:a.workLogPartial}):null,t[152]=I,t[153]=r,t[154]=je,t[155]=o,t[156]=a.workLogFailed,t[157]=a.workLogPartial,t[158]=n.status,t[159]=m):m=t[159];let h;return t[160]!==l||t[161]!==u||t[162]!==d||t[163]!==f||t[164]!==p||t[165]!==m?(h=(0,Z.jsxs)(`div`,{"data-assistant-work-log":l,"data-work-log-status":u,className:d,children:[f,p,m]}),t[160]=l,t[161]=u,t[162]=d,t[163]=f,t[164]=p,t[165]=m,t[166]=h):h=t[166],h}let Fe=n.status,Ie=I||K?`w-full`:`w-fit max-w-full`,Le;t[167]===Ie?Le=t[168]:(Le=Y(`my-1 min-w-0`,Ie),t[167]=Ie,t[168]=Le);let Re;t[169]!==I||t[170]!==K||t[171]!==Ne||t[172]!==je||t[173]!==Pe||t[174]!==n.compact||t[175]!==n.items.length?(Re=I||!n.compact&&n.items.length>0?(0,Z.jsxs)(`button`,{type:`button`,disabled:!Pe,className:Y(`flex max-w-full min-w-0 items-center gap-2 rounded-lg px-1 py-1.5 text-left text-sm text-fg-muted`,I?`h-11`:`min-h-11`,I?`w-full`:`w-fit`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),onClick:Pe?()=>z({active:I,value:!K}):void 0,"aria-expanded":Pe?K:void 0,children:[(0,Z.jsx)(Bt,{className:Y(`size-4 shrink-0`,I&&`assistant-activity-busy`),"aria-hidden":!0}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:(0,Z.jsx)(`span`,{className:`flex h-6 w-full min-w-0 items-center`,children:je})}),(0,Z.jsx)(`span`,{className:`flex shrink-0 items-start justify-end`,children:Ne}),Pe?(0,Z.jsx)(te,{className:Y(`size-4 shrink-0 text-fg-muted transition-transform motion-reduce:transition-none`,K&&`rotate-180`),"aria-hidden":!0}):null]}):null,t[169]=I,t[170]=K,t[171]=Ne,t[172]=je,t[173]=Pe,t[174]=n.compact,t[175]=n.items.length,t[176]=Re):Re=t[176];let ze;t[177]!==I||t[178]!==s||t[179]!==c||t[180]!==S||t[181]!==ke||t[182]!==i||t[183]!==n.items?(ze=S&&n.items.filter(Bg).map(e=>(0,Z.jsx)(l_,{block:e,toolLabels:i,stepLabels:ke,cardLabels:s,conversationId:c,surfaceOnly:!0,runActive:I},e.id)),t[177]=I,t[178]=s,t[179]=c,t[180]=S,t[181]=ke,t[182]=i,t[183]=n.items,t[184]=ze):ze=t[184];let Be;t[185]!==I||t[186]!==s||t[187]!==k.activityEarlier||t[188]!==c||t[189]!==K||t[190]!==ne||t[191]!==de||t[192]!==H||t[193]!==b||t[194]!==J||t[195]!==ke||t[196]!==i?(Be=K||ne?(0,Z.jsx)(`div`,{className:`assistant-activity-disclosure`,"data-open":K,"aria-hidden":!K,inert:!K,children:(0,Z.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:(0,Z.jsxs)(`div`,{ref:W,className:`assistant-activity-flow mt-1 max-h-[min(32rem,50dvh)] w-full min-w-0 overflow-x-hidden overflow-y-auto pb-1 pl-1 pr-2 [scrollbar-gutter:stable]`,"data-assistant-activity-flow":!0,onFocusCapture:()=>z({active:I,value:!0}),children:[de>0?(0,Z.jsx)(`button`,{type:`button`,className:`mb-3 text-xs text-fg-muted hover:text-fg`,onClick:()=>U(!0),children:k.activityEarlier}):null,(0,Z.jsx)(e_,{blocks:J,toolLabels:i,stepLabels:ke,cardLabels:s,conversationId:c,animateNew:I&&K&&!H,runActive:I,showThinking:b})]})})}):null,t[185]=I,t[186]=s,t[187]=k.activityEarlier,t[188]=c,t[189]=K,t[190]=ne,t[191]=de,t[192]=H,t[193]=b,t[194]=J,t[195]=ke,t[196]=i,t[197]=Be):Be=t[197];let Ve;return t[198]!==Le||t[199]!==Re||t[200]!==ze||t[201]!==Be||t[202]!==n.status?(Ve=(0,Z.jsxs)(`div`,{"data-assistant-work-log":!0,"data-work-log-status":Fe,className:Le,children:[Re,ze,Be]}),t[198]=Le,t[199]=Re,t[200]=ze,t[201]=Be,t[202]=n.status,t[203]=Ve):Ve=t[203],Ve}function Bg(e){return e.type===`tool_use`}function Vg(e){return e.type===`tool_use`}function Hg(e){return e.type===`tool_use`&&(e.status===`error`||e.activity?.status===`failed`)}function Ug(e){return e.type===`tool_use`}function Wg(e){return e.type===`tool_use`}function Gg(e){return e.type===`thinking`&&e.streaming}function Kg(e){return e.type===`tool_use`&&e.status===`running`}function qg(e){return e.type===`thinking`&&e.streaming}function Jg(e){return e.type===`tool_use`&&(e.status===`running`||e.activity?.status===`running`)}function Yg(e){return e.type===`tools`?e.tools:[e.item]}function Xg(e){return or(e)||e.type===`tool_use`||e.type===`text`&&e.segmentId}function Zg(e){return e.type!==`text`}function Qg(e){return e.showRawToolData}function $g(e){return e.language}function e_({blocks:e,toolLabels:t,stepLabels:n,cardLabels:r,className:i,conversationId:a,animateNew:o=!1,runActive:s,showThinking:c=!1}){let l=(0,Q.useRef)(new Set(e.map(Lg))),u=Po(e=>e.showRawToolData),d=h(e=>e.language),f=u?e.map(e=>({type:`item`,item:e})):Ng(e);return e.length>0?(0,Z.jsx)(`div`,{className:Y(`min-w-0 overflow-x-hidden`,i),children:(0,Z.jsx)(`div`,{className:`min-w-0 space-y-2.5 pl-1`,children:f.map((e,i)=>{let f=e.type===`tools`?e.tools[0]:e.item,p=Lg(f,i);return(0,Z.jsx)(`div`,{className:Y(o&&!l.current.has(p)&&f.type!==`text`&&`assistant-activity-enter`),children:e.type===`tools`?(0,Z.jsx)(t_,{tools:e.tools,runActive:s,labels:n,language:d,renderTool:e=>(0,Z.jsx)(l_,{block:e,toolLabels:t,stepLabels:n,cardLabels:r,conversationId:a,runActive:s},e.id)}):e.item.type===`thinking`&&c&&!u?(0,Z.jsx)(`div`,{"data-assistant-thinking":!0,className:`text-sm leading-relaxed text-fg-muted`,children:(0,Z.jsx)($d,{content:e.item.text,compact:!0,streaming:!!(s&&e.item.streaming)})}):(0,Z.jsx)(l_,{block:e.item,toolLabels:t,stepLabels:n,cardLabels:r,conversationId:a,runActive:s})},p)})})}):null}function t_(e){let t=(0,X.c)(40),{tools:n,runActive:r,labels:i,language:a,renderTool:o}=e,s;t[0]!==r||t[1]!==n?(s=r&&n.some(r_),t[0]=r,t[1]=n,t[2]=s):s=t[2];let c=s,l;if(t[3]!==i||t[4]!==a||t[5]!==r||t[6]!==n){let e=y(a).chat,o;t[8]!==i||t[9]!==r?(o=e=>pa(e,r&&(e.status===`running`||e.activity?.status===`running`)?`running`:`completed`,i.toolActivity,i,i.runningActions),t[8]=i,t[9]=r,t[10]=o):o=t[10],l=Pg(n,o,{repeated:e.activityRepeated,more:e.activityMore,failed:e.activityFailed,separator:a===`zh`?`、`:`, `}),t[3]=i,t[4]=a,t[5]=r,t[6]=n,t[7]=l}else l=t[7];let u=l,d,f,p,m,h;if(t[11]!==o||t[12]!==c||t[13]!==n){h=Symbol.for(`react.early_return_sentinel`);bb0:{if(d=c?[...n].reverse().find(n_):void 0,n.length===1){let e;t[19]!==o||t[20]!==n[0]?(e=o(n[0]),t[19]=o,t[20]=n[0],t[21]=e):e=t[21],h=e;break bb0}f=!0,p=`min-w-0 space-y-1.5`,m=d?o(d):null}t[11]=o,t[12]=c,t[13]=n,t[14]=d,t[15]=f,t[16]=p,t[17]=m,t[18]=h}else d=t[14],f=t[15],p=t[16],m=t[17],h=t[18];if(h!==Symbol.for(`react.early_return_sentinel`))return h;let g;t[22]===u?g=t[23]:(g=(0,Z.jsx)(`summary`,{className:`cursor-pointer rounded-md py-1 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,Z.jsx)(`span`,{children:u})}),t[22]=u,t[23]=g);let _;if(t[24]!==d||t[25]!==o||t[26]!==n){let e;t[28]===d?e=t[29]:(e=e=>e!==d,t[28]=d,t[29]=e),_=n.filter(e).map(o),t[24]=d,t[25]=o,t[26]=n,t[27]=_}else _=t[27];let v;t[30]===_?v=t[31]:(v=(0,Z.jsx)(`div`,{className:`mt-2 min-w-0 space-y-2.5 border-l border-edge-subtle pl-3`,children:_}),t[30]=_,t[31]=v);let b;t[32]!==g||t[33]!==v?(b=(0,Z.jsxs)(`details`,{className:`min-w-0 text-[13px] text-fg-muted`,children:[g,v]}),t[32]=g,t[33]=v,t[34]=b):b=t[34];let x;return t[35]!==b||t[36]!==f||t[37]!==p||t[38]!==m?(x=(0,Z.jsxs)(`div`,{"data-activity-group":f,className:p,children:[m,b]}),t[35]=b,t[36]=f,t[37]=p,t[38]=m,t[39]=x):x=t[39],x}function n_(e){return e.status===`running`||e.activity?.status===`running`}function r_(e){return e.status===`running`||e.activity?.status===`running`}function i_(e){let t=(0,X.c)(15),{toolName:n,toolResult:r}=e,i=Wr(),a=jg(n);if(!a||i.length===0)return null;let o;if(t[0]!==i||t[1]!==a.extensionId){let e;t[3]===a.extensionId?e=t[4]:(e=e=>e.id===a.extensionId,t[3]=a.extensionId,t[4]=e),o=i.find(e),t[0]=i,t[1]=a.extensionId,t[2]=o}else o=t[2];let s=o,c=s?.name??a.extensionId,l=a.maxHeight??400,u=a.interactive??!1,d=s?.ui?.permissions,f;return t[5]!==c||t[6]!==l||t[7]!==u||t[8]!==d||t[9]!==r||t[10]!==a.entrypoint||t[11]!==a.extensionId||t[12]!==a.id||t[13]!==a.title?(f=(0,Z.jsx)(Ag,{extensionId:a.extensionId,extensionName:c,widgetId:a.id,entrypoint:a.entrypoint,title:a.title,toolResult:r,maxHeight:l,interactive:u,permissions:d}),t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=r,t[10]=a.entrypoint,t[11]=a.extensionId,t[12]=a.id,t[13]=a.title,t[14]=f):f=t[14],f}var a_=new Set([`readFile`,`editFile`,`writeFile`,`runCommand`,`fetchUrl`]),o_=240;function s_(e){let t=e.split(`
26
+ `).map(e=>e.trim()).find(Boolean)??``;return t.length<=o_?t:`${t.slice(0,o_)}…`}function c_(e,t,n){let r=$h(e.result),i=(e.details&&typeof e.details==`object`&&!Array.isArray(e.details)?e.details:null)??r.details;if(i?.timedOut===!0)return n.timedOut;if(typeof i?.exitCode==`number`&&i.exitCode!==0)return n.exitCodeNonZero.replace(/\{\{code\}\}/g,String(i.exitCode));for(let e of[`errorMessage`,`error`,`message`,`reason`]){let t=i?.[e];if(typeof t==`string`&&t.trim())return s_(t)}return s_(r.text)||t}function l_(e){let t=(0,X.c)(153),{block:n,toolLabels:r,stepLabels:i,cardLabels:a,conversationId:o,surfaceOnly:s,runActive:c}=e,l=s!==void 0&&s,d=c===void 0||c,f;t[0]===n?f=t[1]:(f=or(n),t[0]=n,t[1]=f);let p=Fm(o,f),m=p?.type===n.type?p:n,g=Po(d_),_=h(u_),v;bb0:{if(m.type!==`tool_use`){v=``;break bb0}if(m.status===`running`){v=``;break bb0}let e=m.result;if(e==null){v=``;break bb0}if(typeof e==`string`){let n;t[2]===e?n=t[3]:(n=e.trim(),t[2]=e,t[3]=n),v=n;break bb0}try{let n;t[4]===e?n=t[5]:(n=JSON.stringify(e,null,2),t[4]=e,t[5]=n),v=n}catch{v=String(e)}}let b=v;if(m.type===`text`){let e;t[6]===m.text?e=t[7]:(e=m.text.trim(),t[6]=m.text,t[7]=e);let n=e;if(!n)return null;let r=m.presentation===`pending`,i;return t[8]!==r||t[9]!==n?(i=(0,Z.jsx)(`div`,{className:`min-w-0 text-sm leading-relaxed text-fg-muted`,children:(0,Z.jsx)($d,{content:n,compact:!0,streaming:r})}),t[8]=r,t[9]=n,t[10]=i):i=t[10],i}if(m.type===`thinking`){let e=!!m.streaming,n;t[11]===m.text?n=t[12]:(n=m.text?.trim()??``,t[11]=m.text,t[12]=n);let r=n;if(!g||!r)return null;let a=e?i.thoughtsStreaming:i.thoughts,o;t[13]===a?o=t[14]:(o=(0,Z.jsx)(`span`,{className:`inline-flex max-w-full min-w-0 break-words text-[13px] text-fg-muted [overflow-wrap:anywhere]`,children:a}),t[13]=a,t[14]=o);let s;t[15]!==g||t[16]!==i.rawThinking||t[17]!==e||t[18]!==r?(s=g&&r?(0,Z.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer select-none text-fg-subtle underline-offset-2 hover:text-fg-muted`,children:i.rawThinking}),(0,Z.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-xs leading-relaxed text-fg-muted [overflow-wrap:anywhere]`,children:r})]}):e?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`…`}):null,t[15]=g,t[16]=i.rawThinking,t[17]=e,t[18]=r,t[19]=s):s=t[19];let c;return t[20]!==o||t[21]!==s?(c=(0,Z.jsx)(`div`,{className:`min-w-0`,children:(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[o,s]})}),t[20]=o,t[21]=s,t[22]=c):c=t[22],c}let x=d&&(m.status===`running`||m.activity?.status===`running`),S=m.status===`error`||m.activity?.status===`failed`,C;t[23]!==m||t[24]!==a||t[25]!==S||t[26]!==i.toolError?(C=S?c_(m,i.toolError,a):``,t[23]=m,t[24]=a,t[25]=S,t[26]=i.toolError,t[27]=C):C=t[27];let w=C,T=b,E;t[28]!==m.name||t[29]!==T?(E=m.name===`codemode`?Ig(T??``):void 0,t[28]=m.name,t[29]=T,t[30]=E):E=t[30];let D=E,O=x&&m.details&&typeof m.details==`object`&&!Array.isArray(m.details)&&typeof m.details.text==`string`?m.details.text:``,k=T??``;if(k)try{let e;t[31]===k?e=t[32]:(e=JSON.stringify(JSON.parse(k),null,2),t[31]=k,t[32]=e),k=e}catch{}let A,j,M,N,P;if(t[33]!==m||t[34]!==S||t[35]!==x||t[36]!==i.editFile||t[37]!==i.fetchUrl||t[38]!==i.listDirectory||t[39]!==i.memoryActivity||t[40]!==i.openUrl||t[41]!==i.readFile||t[42]!==i.runCommand||t[43]!==i.runningActions||t[44]!==i.searched||t[45]!==i.searchedCode||t[46]!==i.searchedMemory||t[47]!==i.searchedWeb||t[48]!==i.toolActivity||t[49]!==i.toolError||t[50]!==i.unknownTool||t[51]!==i.writeFile){j=Dh(m.name,m.activity),A=a_.has(j),M=j===`memorySearch`?Lh(m,i.memoryActivity):null;let e;if(t[57]!==m||t[58]!==S||t[59]!==x||t[60]!==M?.title||t[61]!==i.editFile||t[62]!==i.fetchUrl||t[63]!==i.listDirectory||t[64]!==i.openUrl||t[65]!==i.readFile||t[66]!==i.runCommand||t[67]!==i.runningActions||t[68]!==i.searched||t[69]!==i.searchedCode||t[70]!==i.searchedMemory||t[71]!==i.searchedWeb||t[72]!==i.toolActivity||t[73]!==i.toolError||t[74]!==i.unknownTool||t[75]!==i.writeFile){let n={searchedWeb:i.searchedWeb,searchedMemory:i.searchedMemory,searchedCode:i.searchedCode,searched:i.searched,readFile:i.readFile,runCommand:i.runCommand,listDirectory:i.listDirectory,writeFile:i.writeFile,editFile:i.editFile,openUrl:i.openUrl,fetchUrl:i.fetchUrl,unknownTool:i.unknownTool};e=S?i.toolError:M?.title??pa(m,x?`running`:`completed`,i.toolActivity,n,i.runningActions),t[57]=m,t[58]=S,t[59]=x,t[60]=M?.title,t[61]=i.editFile,t[62]=i.fetchUrl,t[63]=i.listDirectory,t[64]=i.openUrl,t[65]=i.readFile,t[66]=i.runCommand,t[67]=i.runningActions,t[68]=i.searched,t[69]=i.searchedCode,t[70]=i.searchedMemory,t[71]=i.searchedWeb,t[72]=i.toolActivity,t[73]=i.toolError,t[74]=i.unknownTool,t[75]=i.writeFile,t[76]=e}else e=t[76];P=e,N=S?Ut:j.includes(`Search`)||j===`search`?Ft:j===`readFile`?U:j===`editFile`||j===`writeFile`?rs:j===`fetchUrl`||j===`openUrl`?Fe:me,t[33]=m,t[34]=S,t[35]=x,t[36]=i.editFile,t[37]=i.fetchUrl,t[38]=i.listDirectory,t[39]=i.memoryActivity,t[40]=i.openUrl,t[41]=i.readFile,t[42]=i.runCommand,t[43]=i.runningActions,t[44]=i.searched,t[45]=i.searchedCode,t[46]=i.searchedMemory,t[47]=i.searchedWeb,t[48]=i.toolActivity,t[49]=i.toolError,t[50]=i.unknownTool,t[51]=i.writeFile,t[52]=A,t[53]=j,t[54]=M,t[55]=N,t[56]=P}else A=t[52],j=t[53],M=t[54],N=t[55],P=t[56];let F=N,I;t[77]!==m.input||t[78]!==M?(I=M?``:Jh(m.input),t[77]=m.input,t[78]=M,t[79]=I):I=t[79];let L=I,R;t[80]===m.input?R=t[81]:(R=m.input===void 0?``:Hh(m.input),t[80]=m.input,t[81]=R);let z=R,B;t[82]!==m||t[83]!==a||t[84]!==A||t[85]!==j?(B=A?j===`readFile`?(0,Z.jsx)(mg,{block:m,labels:a}):j===`editFile`?(0,Z.jsx)(_g,{block:m,labels:a}):j===`writeFile`?(0,Z.jsx)(yg,{block:m,labels:a}):j===`runCommand`?(0,Z.jsx)(Sg,{block:m,labels:a}):j===`fetchUrl`?(0,Z.jsx)(Cg,{block:m,labels:a}):null:null,t[82]=m,t[83]=a,t[84]=A,t[85]=j,t[86]=B):B=t[86];let V=B;if(l){let e;t[87]!==m.name||t[88]!==m.result||t[89]!==S||t[90]!==x?(e=!x&&!S?(0,Z.jsx)(i_,{toolName:m.name,toolResult:m.result}):null,t[87]=m.name,t[88]=m.result,t[89]=S,t[90]=x,t[91]=e):e=t[91];let n;return t[92]===e?n=t[93]:(n=(0,Z.jsx)(Z.Fragment,{children:e}),t[92]=e,t[93]=n),n}let H=!x&&g,W=m.parentToolCallId?`ml-4 min-w-0 border-l border-edge pl-3`:`min-w-0`,G=S?`failed`:x?`running`:`completed`,ee=x&&`assistant-activity-busy`,te;t[94]===ee?te=t[95]:(te=Y(`mt-0.5 size-4 shrink-0 text-fg-subtle`,ee),t[94]=ee,t[95]=te);let ne;t[96]!==F||t[97]!==te?(ne=(0,Z.jsx)(F,{className:te,"aria-hidden":!0}),t[96]=F,t[97]=te,t[98]=ne):ne=t[98];let re;t[99]===P?re=t[100]:(re=(0,Z.jsx)(`span`,{className:`inline-flex max-w-full min-w-0 break-words text-[13px] text-fg-muted [overflow-wrap:anywhere]`,children:P}),t[99]=P,t[100]=re);let ie;t[101]!==G||t[102]!==ne||t[103]!==re?(ie=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,"data-activity-status":G,children:[ne,re]}),t[101]=G,t[102]=ne,t[103]=re,t[104]=ie):ie=t[104];let ae;t[105]!==V||t[106]!==i.stepDetails?(ae=V?(0,Z.jsxs)(`details`,{className:`min-w-0 text-xs text-fg-muted`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer hover:text-fg`,children:i.stepDetails}),V]}):null,t[105]=V,t[106]=i.stepDetails,t[107]=ae):ae=t[107];let K;t[108]!==m||t[109]!==x||t[110]!==j||t[111]!==_||t[112]!==g||t[113]!==i.stepDetails?(K=j===`webSearch`&&!x?(0,Z.jsx)(Og,{block:m,summary:i.stepDetails,labels:y(_).chat.searchDetails,developer:g,language:_}):null,t[108]=m,t[109]=x,t[110]=j,t[111]=_,t[112]=g,t[113]=i.stepDetails,t[114]=K):K=t[114];let oe;t[115]!==M||t[116]!==i.memoryActivity?(oe=M?(0,Z.jsxs)(`div`,{className:`space-y-1 text-xs text-fg-muted`,children:[(0,Z.jsx)(`p`,{children:M.purpose}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1`,children:[(0,Z.jsx)(u,{className:`font-medium text-accent-fg hover:underline`,to:`/user-model`,children:i.memoryActivity.manage}),(0,Z.jsx)(u,{className:`font-medium text-accent-fg hover:underline`,to:`/user-model`,children:i.memoryActivity.privacy})]}),(0,Z.jsxs)(`details`,{children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer select-none text-fg-subtle hover:text-fg-muted`,children:i.memoryActivity.why}),(0,Z.jsx)(`div`,{className:`mt-1.5 rounded-md bg-surface-hover/60 px-2 py-1.5 dark:bg-surface-hover/35`,children:(0,Z.jsx)(`p`,{children:i.memoryActivity.explanation})})]})]}):null,t[115]=M,t[116]=i.memoryActivity,t[117]=oe):oe=t[117];let se;t[118]!==w||t[119]!==g?(se=w&&g?(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:w}):null,t[118]=w,t[119]=g,t[120]=se):se=t[120];let q;t[121]!==L||t[122]!==A||t[123]!==g?(q=g&&!A&&L?(0,Z.jsx)(`p`,{className:`min-w-0 break-words text-xs text-fg-muted [overflow-wrap:anywhere]`,children:L}):null,t[121]=L,t[122]=A,t[123]=g,t[124]=q):q=t[124];let ce;t[125]!==O||t[126]!==g?(ce=g&&O?(0,Z.jsx)(`pre`,{className:`max-h-48 min-w-0 overflow-y-auto overflow-x-hidden rounded-md bg-surface-hover/60 p-2 whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-fg-muted [overflow-wrap:anywhere] dark:bg-surface-hover/35`,children:O}):null,t[125]=O,t[126]=g,t[127]=ce):ce=t[127];let le;t[128]!==o||t[129]!==_||t[130]!==D?(le=D?(0,Z.jsx)(Fg,{path:D,conversationId:o,label:_===`zh`?`查看完整输出`:`View full output`}):null,t[128]=o,t[129]=_,t[130]=D,t[131]=le):le=t[131];let ue;t[132]!==a||t[133]!==A||t[134]!==k||t[135]!==z||t[136]!==H||t[137]!==i.stepDetails||t[138]!==r?(ue=H?(0,Z.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer select-none text-fg-subtle underline-offset-2 hover:text-fg-muted group-open:text-fg-muted`,children:A?a.rawDetails:i.stepDetails}),(0,Z.jsxs)(`div`,{className:`mt-2 max-h-48 w-full min-w-0 max-w-full overflow-y-auto overflow-x-hidden rounded-md bg-surface-hover/60 p-2 font-mono dark:bg-surface-hover/35`,children:[z?(0,Z.jsxs)(`div`,{className:`mb-2 min-w-0`,children:[(0,Z.jsx)(`div`,{className:`mb-0.5 text-[10px] uppercase tracking-wide text-fg-disabled`,children:r.input}),(0,Z.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-fg-muted [overflow-wrap:anywhere]`,children:z})]}):null,(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`mb-0.5 text-[10px] uppercase tracking-wide text-fg-disabled`,children:r.output}),(0,Z.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-fg-muted [overflow-wrap:anywhere]`,children:k||r.noOutput})]})]})]}):null,t[132]=a,t[133]=A,t[134]=k,t[135]=z,t[136]=H,t[137]=i.stepDetails,t[138]=r,t[139]=ue):ue=t[139];let de;t[140]!==ie||t[141]!==ae||t[142]!==K||t[143]!==oe||t[144]!==se||t[145]!==q||t[146]!==ce||t[147]!==le||t[148]!==ue?(de=(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-1.5`,children:[ie,ae,K,oe,se,q,ce,le,ue]}),t[140]=ie,t[141]=ae,t[142]=K,t[143]=oe,t[144]=se,t[145]=q,t[146]=ce,t[147]=le,t[148]=ue,t[149]=de):de=t[149];let fe;return t[150]!==W||t[151]!==de?(fe=(0,Z.jsx)(`div`,{className:W,children:de}),t[150]=W,t[151]=de,t[152]=fe):fe=t[152],fe}function u_(e){return e.language}function d_(e){return e.showRawToolData}function f_(e){return e+1}function p_(e){let t=(0,X.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(Ba,{delayDuration:300,skipDelayDuration:100,children:n}),t[0]=n,t[1]=r),r}function m_(e){let t=(0,X.c)(7),{label:n,children:r}=e,i;t[0]===r?i=t[1]:(i=(0,Z.jsx)(Wa,{asChild:!0,children:r}),t[0]=r,t[1]=i);let a;t[2]===n?a=t[3]:(a=(0,Z.jsx)(Va,{children:(0,Z.jsx)(Ua,{side:`top`,sideOffset:7,collisionPadding:12,className:`z-[100] max-w-[min(18rem,90vw)] rounded-md border border-edge bg-surface-overlay px-2.5 py-1.5 text-xs text-fg shadow-popover`,children:n})}),t[2]=n,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Z.jsxs)(Ha,{children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function h_(e,t){let n=e.filter(e=>e.type===`tool_use`),r=n.map(e=>e.startedAt).filter(e=>Number.isFinite(e)),i=n.map(e=>e.completedAt).filter(e=>Number.isFinite(e)),a=r.length>0?Math.min(...r):void 0,o=[...i,...Number.isFinite(t)?[t]:[]],s=o.length>0?Math.max(...o):void 0;return{startedAt:a,completedAt:s,durationMs:a!=null&&s!=null?Math.max(0,s-a):void 0}}function g_(e){return e.filter(e=>e.type===`thinking`||e.type===`tool_use`)}function __(e){let t=Pr(e,`running`);return t.category===`web`&&t.action===`search`}function v_(e){let t=[];for(let n of e)if(!(!__(n.name)||n.result==null))try{let e=typeof n.result==`string`?JSON.parse(n.result):n.result,r=Array.isArray(e)?e:e?.results??[];for(let e of r)e.url&&t.push({url:e.url,title:e.title??e.url,snippet:e.snippet})}catch{}return t}function y_(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function b_(e){let t=y_(e);return t?x_(sn(t.delivery)??sn(y_(t.details)?.delivery)??sn(e),t):null}function x_(e,t){let n=e?.primary;if(!e||n?.kind!==`automation`||n.runId||e.operation!==`started`)return e;let r=y_(t),i=y_((y_(r?.result)??r)?.run);return i?.automationId!==n.id||typeof i.id!=`string`||!i.id?e:{...e,primary:{...n,runId:i.id}}}function S_(e){let t=b_(e.details);if(t)return t;let n=$h(e.result),r=b_(n.details);if(r)return r;let i=rn(n.text);if(i)try{return x_(i,JSON.parse(n.text.split(`
27
+ Open in xopc:`)[0]))}catch{return i}if(typeof e.result==`string`)try{return b_(JSON.parse(e.result))}catch{return null}return b_(e.result)}function C_(e){let t=e.indexOf(`.`);if(t<=0)return null;let n=e.slice(t+1);if(!/^[A-Za-z0-9_-]+$/.test(n))return null;try{let e=Uint8Array.from(atob(n.replace(/-/g,`+`).replace(/_/g,`/`)),e=>e.charCodeAt(0)),t=new TextDecoder(`utf-8`,{fatal:!0}).decode(e);return t&&!t.startsWith(`/`)&&!t.includes(`\\`)&&t.split(`/`).every(e=>e!==`.`&&e!==`..`&&e!==``)?t:null}catch{return null}}function w_(e){return e.normalize(`NFKC`).trim().replace(/\s+/g,` `).toLowerCase()}function T_(e){return e.operation!==`opened`||e.presentation?.kind===`diff`||e.presentation?.kind===`inline_app`||e.presentation?.kind===`inline_preview`}function E_(e){return e.flatMap(({key:e,delivery:t})=>t.presentation?.kind===`diff`?[{key:e,presentation:t.presentation}]:[])}function D_(e){return{truncated:e.flatMap(({delivery:e})=>e.presentation?.kind===`table`?[e.presentation]:[]).some(e=>e.truncated)}}function O_(e){let t=e.flatMap(({key:e,delivery:t})=>t.presentation?.kind===`inline_app`?[{key:e,delivery:t,presentation:t.presentation}]:[]);return[...new Map(t.map(e=>[`${e.presentation.reference.id}:${e.presentation.snapshot.sourceHash}`,e])).values()]}function k_(e){let t=e.flatMap(({key:e,delivery:t})=>t.presentation?.kind===`inline_preview`?[{key:e,delivery:t,presentation:t.presentation}]:[]);return[...new Map(t.map(e=>[`${e.presentation.reference.id}:${e.presentation.sourceHash}`,e])).values()]}function A_(e,t){let n=e.flatMap(({key:e,delivery:n})=>(n.presentation?.kind===`table`?n.presentation.items:n.presentation?[]:[n.primary,...n.related??[]]).flatMap((r,i)=>{if(!r)return[];let a=`${r.kind}:${r.id}${r.runId?`:${r.runId}`:``}`;return t?.has(a)?[]:[{key:`${e}:${i}:${a}`,delivery:n,reference:r}]})),r=[...new Map(n.map(e=>[`${e.reference.kind}:${e.reference.id}:${e.reference.runId??``}`,e])).values()],i=new Map;for(let e of r){if(e.reference.kind!==`task`)continue;let t=w_(e.reference.title);t&&i.set(t,e.reference.id)}return r.filter(e=>{if(e.reference.kind!==`task`)return!0;let t=w_(e.reference.title);return!t||i.get(t)===e.reference.id})}function j_(e){return T_(e)?e.presentation||e.related?.length?!0:e.primary?e.primary.kind!==`note`||e.operation===`created`||e.operation===`updated`:!1:!1}function M_({message:e,isStreaming:t,reasoningLevel:n}){let r=In(e.content??[],{includePending:!0}),i=new Set(r),a=jh(g_(e.content??[])),o=(e.content??[]).filter(e=>e.type===`tool_use`?!0:e.type===`thinking`?n!==`off`&&(!!e.text?.trim()||!!e.streaming):e.type===`text`&&!i.has(e)&&!!e.text?.trim()),s=r.some(e=>e.type===`review`||e.type===`text`&&!!e.text?.trim()),c=a.filter(e=>e.type===`tool_use`),l=[...c].reverse().find(e=>e.status===`running`||e.activity?.status===`running`),u=new Map;for(let e of c){let t=S_(e);t&&j_(t)&&u.set(e.id,t)}let d=[...u].map(([e,t])=>({key:e,delivery:t})),f=h_(a,t?void 0:e.completedAt??e.timestamp),p=[e.startedAt??e.timestamp,f.startedAt].filter(e=>Number.isFinite(e)),m=p.length>0?Math.min(...p):void 0,h=m!=null&&f.completedAt!=null?Math.max(0,f.completedAt-m):void 0,g=t?`running`:e.outcome?.status===`failed`?`failed`:e.outcome?.status===`partial`?`partial`:`completed`,_=(e.content??[]).filter(e=>e.type===`image`&&!!e.source?.data),v=e.outcome??e.taskResultDelivery?.outcome,y=new Set(v?.deliverables.map(e=>e.artifactId)),b=new Set(v?.deliverables.flatMap(e=>e.uri?[e.uri]:[])),x=[...ym(_),...e.attachments??[]].filter(e=>!(e.id&&y.has(e.id)||e.uri&&b.has(e.uri))),S;return S=t?l?`using_tool`:a.some(e=>e.type===`thinking`&&!!e.streaming)?`reasoning`:s?`answering`:`starting`:e.outcome?.status===`partial`||e.outcome?.status===`failed`?`partial`:`completed`,{answerContent:r,workLog:{items:o,active:t&&(o.length>0||!s),status:g,compact:n===`off`,expandedByDefault:n!==`off`&&t&&!s,startedAt:m,durationMs:h},answer:{started:s,showStreamingCursor:t&&s&&(o.length===0||S===`answering`)},lifecycle:{state:S,activeTool:S===`using_tool`?l:void 0},outcome:v,resultRevision:e.taskResultDelivery?.resultRevision,deliveries:d,attachments:x,sources:v_(c)}}function N_(e){let t=(0,X.c)(10),{blocks:n,sources:r,className:i}=e,a=n===void 0?[]:n,o=i===void 0?`mt-6`:i,s=y(h(I_)),c=a.filter(F_),l=r??v_(c);if(l.length===0)return null;let u=s.chat.searchSourcesHeading.replace(`{{count}}`,String(l.length)),d;t[0]===u?d=t[1]:(d=(0,Z.jsx)(`p`,{className:`mb-3 text-xs font-medium text-fg-muted`,children:u}),t[0]=u,t[1]=d);let f;t[2]===l?f=t[3]:(f=l.map(P_),t[2]=l,t[3]=f);let p;t[4]===f?p=t[5]:(p=(0,Z.jsx)(`ol`,{className:`space-y-3`,children:f}),t[4]=f,t[5]=p);let m;return t[6]!==o||t[7]!==d||t[8]!==p?(m=(0,Z.jsxs)(`div`,{className:o,children:[d,p]}),t[6]=o,t[7]=d,t[8]=p,t[9]=m):m=t[9],m}function P_(e,t){let n=(()=>{try{return new URL(e.url).hostname}catch{return``}})(),r=n?`https://www.google.com/s2/favicons?domain=${n}&sz=16`:void 0;return(0,Z.jsxs)(`li`,{className:`flex min-w-0 gap-2.5`,children:[(0,Z.jsxs)(`span`,{className:`mt-0.5 shrink-0 text-xs text-fg-disabled`,children:[t+1,`.`]}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-1.5`,children:[r?(0,Z.jsx)(`img`,{src:r,alt:``,className:`mt-0.5 size-3.5 shrink-0 rounded-sm`,"aria-hidden":!0}):null,(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`min-w-0 flex-1 break-words text-xs font-medium text-accent-fg [overflow-wrap:anywhere] hover:underline`,children:e.title})]}),e.snippet?(0,Z.jsx)(`p`,{className:`mt-0.5 line-clamp-4 text-xs break-words text-fg-muted [overflow-wrap:anywhere]`,children:e.snippet}):null]})]},e.url)}function F_(e){return e.type===`tool_use`}function I_(e){return e.language}var L_=(0,Q.createContext)(!1);function R_(e){let t=(0,X.c)(41),{entries:n,language:r,renderEntry:i}=e,[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null),l=(0,Q.useRef)(null),u=(0,Q.useRef)(0),d=(0,Q.useRef)(!1),f=c(),p;t[0]===f.search?p=t[1]:(p=new URLSearchParams(f.search).has(Ze),t[0]=f.search,t[1]=p);let m=p,h,g;t[2]!==n.length||t[3]!==r?(h=y(r).chat.productDelivery,g=h.relatedTaskCount.replace(`{{count}}`,String(n.length)),t[2]=n.length,t[3]=r,t[4]=h,t[5]=g):(h=t[4],g=t[5]);let _=g,v=a&&!m,O;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(O=e=>{d.current=!e,o(e)},t[6]=O):O=t[6];let k;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,Z.jsx)(_s,{}),t[7]=k):k=t[7];let A;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(ne,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[8]=A):A=t[8];let j;t[9]===_?j=t[10]:(j=(0,Z.jsx)(x,{asChild:!0,children:(0,Z.jsx)(`button`,{ref:s,type:`button`,className:Oo,children:(0,Z.jsx)(ko,{icon:k,title:_,trailing:A})})}),t[9]=_,t[10]=j);let M;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Z.jsx)(b,{className:`fixed inset-0 z-[80] bg-scrim`}),t[11]=M):M=t[11];let N,P;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(P=e=>{e.preventDefault(),l.current?.focus({preventScroll:!0})},N=e=>{e.preventDefault(),d.current&&s.current?.focus({preventScroll:!0})},t[12]=N,t[13]=P):(N=t[12],P=t[13]);let F;t[14]===_?F=t[15]:(F=(0,Z.jsx)(E,{ref:l,tabIndex:-1,className:`min-w-0 flex-1 font-medium text-fg focus:outline-none`,children:_}),t[14]=_,t[15]=F);let I;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(qt,{className:`size-4`,"aria-hidden":!0}),t[16]=I):I=t[16];let L;t[17]===h.closeTaskList?L=t[18]:(L=(0,Z.jsx)(C,{"aria-label":h.closeTaskList,className:`flex size-11 shrink-0 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:I}),t[17]=h.closeTaskList,t[18]=L);let R;t[19]!==F||t[20]!==L?(R=(0,Z.jsxs)(`header`,{className:`flex shrink-0 items-center gap-3 border-b border-edge px-4 py-3`,children:[F,L]}),t[19]=F,t[20]=L,t[21]=R):R=t[21];let z;t[22]===h.relatedTasksDescription?z=t[23]:(z=(0,Z.jsx)(S,{className:`sr-only`,children:h.relatedTasksDescription}),t[22]=h.relatedTasksDescription,t[23]=z);let B,V;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(B=e=>{e&&(e.scrollTop=u.current)},V=e=>{u.current=e.currentTarget.scrollTop},t[24]=B,t[25]=V):(B=t[24],V=t[25]);let H;if(t[26]!==n||t[27]!==i){let e;t[29]===i?e=t[30]:(e=e=>i(e,!0),t[29]=i,t[30]=e),H=n.map(e),t[26]=n,t[27]=i,t[28]=H}else H=t[28];let U;t[31]===H?U=t[32]:(U=(0,Z.jsx)(`div`,{"data-task-delivery-list":!0,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,ref:B,onScroll:V,children:(0,Z.jsx)(`ul`,{className:`${Mo} p-3`,children:H})}),t[31]=H,t[32]=U);let W;t[33]!==R||t[34]!==z||t[35]!==U?(W=(0,Z.jsxs)(w,{children:[M,(0,Z.jsxs)(T,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(40rem,calc(100dvh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay focus:outline-none`,onOpenAutoFocus:P,onCloseAutoFocus:N,children:[R,z,U]})]}),t[33]=R,t[34]=z,t[35]=U,t[36]=W):W=t[36];let G;return t[37]!==W||t[38]!==v||t[39]!==j?(G=(0,Z.jsx)(`li`,{className:`min-w-0 max-w-full`,"data-product-task-group":!0,children:(0,Z.jsxs)(D,{open:v,onOpenChange:O,children:[j,W]})}),t[37]=W,t[38]=v,t[39]=j,t[40]=G):G=t[40],G}var z_={task:_s,project:De,note:ms,automation:G,local_app:k,chat_preview:ls,file:Ee,session:ps,settings:Lt};function B_(e,t){let n=e?.trim();return n?y(t).chat.productDelivery.statuses[n.toLowerCase()]??n:null}function V_(e,t,n){let r=y(n).chat.productDelivery.operations[e.operation],i=B_(t.status,n);return i&&e.operation===`opened`?i:i&&i.toLowerCase()!==r.toLowerCase()?`${r} · ${i}`:i??r}function H_(e,t,n){let r=y(n).chat.productDelivery.taskStates;if(t.phase===`closed`)return t.resolution===`done`?r.completed:r.closed;if(t.attention?.length)return r.blocked;let i={allocating:r.allocating,queued:r.queued,running:r.running,verifying:r.verifying,waiting:r.waiting,blocked:r.blocked,completed:r.completed};return t.operationalState&&i[t.operationalState]||(e.operation===`completed`?r.completed:e.operation===`failed`?r.failed:e.operation===`started`?r.assigned:r.ready)}function U_(e,t){let n=y(t).chat.productDelivery;return n.continuePrompt.replace(/\{\{(kind|title|id)\}\}/g,(r,i)=>({kind:t===`en`?n.kinds[e.kind].toLowerCase():n.kinds[e.kind],title:e.title,id:e.id})[i])}function W_(e){let t=(0,X.c)(90),{delivery:n,reference:r,language:i,conversationId:a,projectId:o,fullTitle:s}=e,l=s!==void 0&&s,u=d(),f=c(),p=Li(K_),h=z_[r.kind],g;t[0]===r?g=t[1]:(g=nn(r),t[0]=r,t[1]=g);let _=g,v;t[2]!==r.capabilities||t[3]!==r.id||t[4]!==r.kind?(v=r.kind===`file`&&r.capabilities.includes(`preview`)?C_(r.id):null,t[2]=r.capabilities,t[3]=r.id,t[4]=r.kind,t[5]=v):v=t[5];let b=v,x;t[6]!==a||t[7]!==b||t[8]!==o?(x=b&&(a?.trim()||o?.trim()),t[6]=a,t[7]=b,t[8]=o,t[9]=x):x=t[9];let S=!!x,C;t[10]!==S||t[11]!==r.capabilities||t[12]!==_?(C=S||!!(_&&r.capabilities.includes(`open`)),t[10]=S,t[11]=r.capabilities,t[12]=_,t[13]=C):C=t[13];let w=C,T;t[14]!==r.capabilities||t[15]!==r.kind?(T=r.kind!==`note`&&r.kind!==`task`&&r.capabilities.includes(`continue_in_chat`),t[14]=r.capabilities,t[15]=r.kind,t[16]=T):T=t[16];let E=T,D=n.operation===`failed`,O=m(G_),k;t[17]!==r.id||t[18]!==r.kind||t[19]!==O?(k=r.kind===`task`?[`task-delivery`,r.id,O]:null,t[17]=r.id,t[18]=r.kind,t[19]=O,t[20]=k):k=t[20];let A;t[21]===r.id?A=t[22]:(A=()=>ti(r.id),t[21]=r.id,t[22]=A);let j;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(j={revalidateOnFocus:!0},t[23]=j):j=t[23];let M=Kr(k,A,j),N;t[24]!==r.id||t[25]!==r.kind||t[26]!==M?(N=()=>{if(r.kind!==`task`)return;let e=e=>{let t=e.detail?.taskId;(!t||t===r.id)&&M.mutate()};return window.addEventListener(`task-changed-v2`,e),window.addEventListener(`gateway-realtime-connected`,e),()=>{window.removeEventListener(`task-changed-v2`,e),window.removeEventListener(`gateway-realtime-connected`,e)}},t[24]=r.id,t[25]=r.kind,t[26]=M,t[27]=N):N=t[27];let P;t[28]!==r.id||t[29]!==r.kind||t[30]!==M.mutate?(P=[r.kind,r.id,M.mutate],t[28]=r.id,t[29]=r.kind,t[30]=M.mutate,t[31]=P):P=t[31],(0,Q.useEffect)(N,P);let F;t[32]!==n||t[33]!==i||t[34]!==r||t[35]!==M.data?.attention||t[36]!==M.data?.operationalState||t[37]!==M.data?.task?(F=r.kind===`task`?H_(n,{phase:M.data?.task.phase,resolution:M.data?.task.resolution,operationalState:M.data?.operationalState??r.status,attention:M.data?.attention},i):V_(n,r,i),t[32]=n,t[33]=i,t[34]=r,t[35]=M.data?.attention,t[36]=M.data?.operationalState,t[37]=M.data?.task,t[38]=F):F=t[38];let I=F;if(r.kind===`automation`&&n.operation!==`failed`){let e;return t[39]!==i||t[40]!==r.id||t[41]!==r.runId?(e=(0,Z.jsx)(`li`,{className:`min-w-0 max-w-full`,children:(0,Z.jsx)(jo,{automationId:r.id,runId:r.runId,language:i,embedded:!0})}),t[39]=i,t[40]=r.id,t[41]=r.runId,t[42]=e):e=t[42],e}let L;t[43]!==S||t[44]!==a||t[45]!==b||t[46]!==f||t[47]!==u||t[48]!==o||t[49]!==r.id||t[50]!==r.kind||t[51]!==r.projectId||t[52]!==r.revision||t[53]!==_||t[54]!==p?(L=()=>{if(b&&S){p(b,null,o,a);return}if(r.kind===`task`){u(nt(`${f.pathname}${f.search}`,r.id));return}if(r.kind===`note`){u(rt(`${f.pathname}${f.search}`,r.id));return}if(_){let e=new URL(_,`https://xopc.local`);r.projectId&&e.searchParams.set(`projectId`,r.projectId),r.kind===`local_app`&&r.revision&&/^[a-f0-9]{64}$/.test(r.revision)&&e.searchParams.set(`sourceHash`,r.revision),u(Qe(et(`${f.pathname}${f.search}`,`${e.pathname}${e.search}`),`${f.pathname}${f.search}`))}},t[43]=S,t[44]=a,t[45]=b,t[46]=f,t[47]=u,t[48]=o,t[49]=r.id,t[50]=r.kind,t[51]=r.projectId,t[52]=r.revision,t[53]=_,t[54]=p,t[55]=L):L=t[55];let R=L,z=r.kind,B=w?R:void 0,V=!w,H;t[56]===r.summary?H=t[57]:(H=r.summary?.trim(),t[56]=r.summary,t[57]=H);let U;t[58]!==I||t[59]!==r.title||t[60]!==H?(U=[r.title,I,H].filter(Boolean),t[58]=I,t[59]=r.title,t[60]=H,t[61]=U):U=t[61];let W=U.join(` · `),G=w?`cursor-pointer`:`cursor-default`,ee=D&&`text-danger`,te;t[62]!==G||t[63]!==ee?(te=Y(Oo,G,ee),t[62]=G,t[63]=ee,t[64]=te):te=t[64];let re=D?`text-danger`:void 0,ie;t[65]!==h||t[66]!==re?(ie=(0,Z.jsx)(h,{strokeWidth:1.75,className:re}),t[65]=h,t[66]=re,t[67]=ie):ie=t[67];let ae;t[68]===w?ae=t[69]:(ae=w?(0,Z.jsx)(ne,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}):null,t[68]=w,t[69]=ae);let K;t[70]!==I||t[71]!==l||t[72]!==r.title||t[73]!==ie||t[74]!==ae?(K=(0,Z.jsx)(ko,{icon:ie,title:r.title,meta:I,fullTitle:l,trailing:ae}),t[70]=I,t[71]=l,t[72]=r.title,t[73]=ie,t[74]=ae,t[75]=K):K=t[75];let oe;t[76]!==B||t[77]!==V||t[78]!==W||t[79]!==te||t[80]!==K?(oe=(0,Z.jsx)(`button`,{type:`button`,onClick:B,disabled:V,title:W,className:te,children:K}),t[76]=B,t[77]=V,t[78]=W,t[79]=te,t[80]=K,t[81]=oe):oe=t[81];let se;t[82]!==E||t[83]!==i||t[84]!==r?(se=E?(0,Z.jsx)(`button`,{type:`button`,className:Y(`inline-flex min-h-11 max-w-full cursor-pointer items-center rounded-[1.125rem] px-3 text-xs text-accent-fg`,`hover:bg-accent-soft active:bg-accent-soft/70`,ua.transition,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`),onClick:()=>Ip(U_(r,i)),children:y(i).chat.productDelivery.continue}):null,t[82]=E,t[83]=i,t[84]=r,t[85]=se):se=t[85];let q;return t[86]!==r.kind||t[87]!==oe||t[88]!==se?(q=(0,Z.jsxs)(`li`,{className:`flex max-w-full min-w-0 flex-wrap items-center gap-2`,"data-product-delivery":z,children:[oe,se]}),t[86]=r.kind,t[87]=oe,t[88]=se,t[89]=q):q=t[89],q}function G_(e){return e.conversationId}function K_(e){return e.setPath}function q_(e){let t=(0,X.c)(23),{entries:n,language:r,conversationId:i,projectId:a}=e,o;t[0]!==n.length||t[1]!==r?(o=y(r).chat.turnOutcome.fileCount.replace(`{{count}}`,String(n.length)),t[0]=n.length,t[1]=r,t[2]=o):o=t[2];let s=o,c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=Y(Oo,`cursor-pointer list-none`),t[3]=c):c=t[3];let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(as,{strokeWidth:1.75}),t[4]=l):l=t[4];let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(ne,{className:`size-3.5 shrink-0 text-fg-subtle transition-transform duration-150 group-open:rotate-90 motion-reduce:transition-none`,"aria-hidden":!0}),t[5]=u):u=t[5];let d;t[6]===s?d=t[7]:(d=(0,Z.jsx)(`summary`,{className:c,children:(0,Z.jsx)(ko,{icon:l,title:s,trailing:u})}),t[6]=s,t[7]=d);let f;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(f=Y(Mo,Ao),t[8]=f):f=t[8];let p;if(t[9]!==i||t[10]!==n||t[11]!==r||t[12]!==a){let e;t[14]!==i||t[15]!==r||t[16]!==a?(e=e=>{let{key:t,delivery:n,reference:o}=e;return(0,Z.jsx)(W_,{delivery:n,reference:o,language:r,conversationId:i,projectId:a},t)},t[14]=i,t[15]=r,t[16]=a,t[17]=e):e=t[17],p=n.map(e),t[9]=i,t[10]=n,t[11]=r,t[12]=a,t[13]=p}else p=t[13];let m;t[18]===p?m=t[19]:(m=(0,Z.jsx)(`ul`,{className:f,children:p}),t[18]=p,t[19]=m);let h;return t[20]!==d||t[21]!==m?(h=(0,Z.jsx)(`li`,{className:`min-w-0 max-w-full`,"data-product-file-group":!0,children:(0,Z.jsxs)(`details`,{className:`group`,children:[d,m]})}),t[20]=d,t[21]=m,t[22]=h):h=t[22],h}function J_(e){let t=(0,X.c)(9),{deliveries:n,language:r,excludedReferenceKeys:i,conversationId:a,projectId:o}=e,s,c;if(t[0]!==a||t[1]!==n||t[2]!==i||t[3]!==r||t[4]!==o){c=Symbol.for(`react.early_return_sentinel`);bb0:{let e=A_(n,i),t=e.filter(Q_),l=e.findIndex(Z_),u=e.filter(X_),d=e.findIndex(Y_);if(e.length===0){c=null;break bb0}s=e.map((e,n)=>{let{key:i,delivery:s,reference:c}=e;return c.kind===`task`&&u.length>3?n===d?(0,Z.jsx)(R_,{entries:u,language:r,renderEntry:(e,t)=>(0,Z.jsx)(W_,{delivery:e.delivery,reference:e.reference,language:r,conversationId:a,projectId:o,fullTitle:t},e.key)},`task-delivery-group`):null:c.kind!==`file`||t.length===1?(0,Z.jsx)(W_,{delivery:s,reference:c,language:r,conversationId:a,projectId:o},i):n===l?(0,Z.jsx)(q_,{entries:t,language:r,conversationId:a,projectId:o},`file-delivery-group`):null})}t[0]=a,t[1]=n,t[2]=i,t[3]=r,t[4]=o,t[5]=s,t[6]=c}else s=t[5],c=t[6];if(c!==Symbol.for(`react.early_return_sentinel`))return c;let l;return t[7]===s?l=t[8]:(l=(0,Z.jsx)(Z.Fragment,{children:s}),t[7]=s,t[8]=l),l}function Y_(e){let{reference:t}=e;return t.kind===`task`}function X_(e){let{reference:t}=e;return t.kind===`task`}function Z_(e){let{reference:t}=e;return t.kind===`file`}function Q_(e){let{reference:t}=e;return t.kind===`file`}function $_(e){let t=(0,X.c)(22),{presentation:n}=e,r=h(ev),i;t[0]===r?i=t[1]:(i=y(r),t[0]=r,t[1]=i);let a=i.chat.productDelivery,o=a.diffPreview,s;t[2]===a.proposedChanges?s=t[3]:(s=(0,Z.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:a.proposedChanges}),t[2]=a.proposedChanges,t[3]=s);let c;t[4]===n.title?c=t[5]:(c=(0,Z.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:n.title}),t[4]=n.title,t[5]=c);let l;if(t[6]!==n.edits||t[7]!==a.replaceRange){let e;t[9]===a.replaceRange?e=t[10]:(e=(e,t)=>(0,Z.jsxs)(`details`,{className:`rounded border border-edge-subtle p-2`,children:[(0,Z.jsxs)(`summary`,{className:`cursor-pointer rounded text-xs text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[a.replaceRange,` `,e.from,`–`,e.to]}),(0,Z.jsx)(`pre`,{className:`mt-2 whitespace-pre-wrap [overflow-wrap:anywhere] font-mono text-xs text-fg`,children:e.text})]},t),t[9]=a.replaceRange,t[10]=e),l=n.edits.map(e),t[6]=n.edits,t[7]=a.replaceRange,t[8]=l}else l=t[8];let u;t[11]===l?u=t[12]:(u=(0,Z.jsx)(`div`,{className:`mt-2 max-h-80 space-y-2 overflow-y-auto`,children:l}),t[11]=l,t[12]=u);let d;t[13]!==n.truncated||t[14]!==a.partialDiff?(d=n.truncated?(0,Z.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-fg-muted`,children:a.partialDiff}):null,t[13]=n.truncated,t[14]=a.partialDiff,t[15]=d):d=t[15];let f;return t[16]!==a.diffPreview||t[17]!==s||t[18]!==c||t[19]!==u||t[20]!==d?(f=(0,Z.jsxs)(`section`,{className:`mt-2 rounded-lg border border-edge bg-surface-panel p-3`,"aria-label":o,children:[s,c,u,d]}),t[16]=a.diffPreview,t[17]=s,t[18]=c,t[19]=u,t[20]=d,t[21]=f):f=t[21],f}function ev(e){return e.language}function tv({previewId:e,reference:t,sourceHash:n,preferredHeight:r,language:i}){let a=d(),o=c(),s=(0,Q.useRef)(null),[l,u]=(0,Q.useState)(0),[f,m]=(0,Q.useState)(`booting`),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)([]),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(null),w=Math.min(720,Math.max(240,r)),T=oa(e),E=Kr(T.active?[`inline-local-app-snapshot`,t.id,n]:null,()=>Io(t.id,n),{revalidateOnFocus:!1,shouldRetryOnError:!1});(0,Q.useEffect)(()=>{let e=s.current;if(!e||!E.data?.previewUrl)return;m(`booting`),g(null),v([]);let t=window.setTimeout(()=>{m(e=>e===`booting`?`timeout`:e)},7e3),n=Ro(e,e=>{let t=cn(e);if(t){if(t.type===`ready`){m(`healthy`);return}if(t.type===`error`){g(t.detail),m(`failed`),v(e=>[...e,{phase:`runtime`,message:zo(t.detail),code:t.detail.kind}].slice(-20));return}if(t.type===`acceptance`&&t.detail.status===`failed`){m(`failed`),v(e=>[...e,...t.detail.checks.filter(e=>e.status===`failed`).map(e=>({phase:`acceptance`,code:e.id,message:e.message}))].slice(-20));return}t.type===`criteria`&&t.detail.status===`failed`&&(m(`failed`),v(e=>[...e,...t.detail.scenarios.filter(e=>e.status===`failed`).map(e=>({phase:e.failureKind===`runner`?`runner`:`acceptance`,code:e.id,message:`${e.name}: ${e.message}`}))].slice(-20)))}});return()=>{window.clearTimeout(t),n()}},[l,E.data?.previewUrl]);let D=()=>{let e=nn(t);e&&a(et(`${o.pathname}${o.search}`,`${e}&sourceHash=${encodeURIComponent(n)}`))};if(!T.active)return(0,Z.jsxs)(`section`,{ref:T.containerRef,className:`content-block-action-scope mt-3 overflow-hidden rounded-2xl border border-edge bg-surface-panel`,"data-inline-local-app":t.id,children:[(0,Z.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,title:t.title,children:t.title}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:T.state===`queued`?i===`zh`?`正在等待预览资源`:`Waiting for a preview slot`:i===`zh`?`预览尚未加载`:`Preview not loaded`})]}),(0,Z.jsx)(mi,{variant:`ghost`,className:`content-block-action`,onClick:D,title:i===`zh`?`查看预览`:`Preview`,"aria-label":i===`zh`?`查看预览`:`Preview`,children:(0,Z.jsx)(Se,{className:`size-4`,"aria-hidden":!0})})]}),(0,Z.jsx)(`div`,{className:`grid place-items-center bg-surface-base`,style:{height:w},children:(0,Z.jsx)(mi,{variant:`secondary`,onClick:T.activate,children:i===`zh`?`加载交互预览`:`Load interactive preview`})})]});if(E.isLoading)return(0,Z.jsxs)(`section`,{ref:T.containerRef,className:`mt-3 overflow-hidden rounded-2xl border border-edge bg-surface-panel`,"aria-label":y(i).chat.productDelivery.loadingAppPreview,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,Z.jsx)(Yt,{className:`h-5 w-40`}),(0,Z.jsx)(Yt,{className:`h-9 w-24`})]}),(0,Z.jsx)(Yt,{className:`m-3 w-[calc(100%-1.5rem)]`,style:{height:w}})]});let O=E.data;if(!O){let e=E.error,t=e instanceof Error?e.message:i===`zh`?`无法加载应用预览`:`Unable to load app preview`;return(0,Z.jsx)(`section`,{ref:T.containerRef,className:`mt-3 rounded-2xl border border-danger/30 bg-danger-soft p-4 text-sm text-danger`,role:`alert`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Ut,{className:`size-4`}),t]})})}let k=O.validation.issues.map(e=>({phase:`build`,code:e.code,message:e.message}))??[],A=f===`timeout`?[{phase:`boot`,code:`boot_timeout`,message:y(i).chat.productDelivery.previewTimeout}]:[],j=[...k,..._,...A],M=O.status===`invalid`||O.validation.status===`failed`,N=M||f===`failed`||f===`timeout`,P=M?i===`zh`?`校验失败`:`Validation failed`:f===`healthy`?i===`zh`?`运行正常`:`Running`:f===`booting`?i===`zh`?`正在启动`:`Starting`:f===`timeout`?i===`zh`?`启动超时`:`Start timed out`:i===`zh`?`运行错误`:`Runtime error`,F=()=>{C(null),u(e=>e+1)},I=async()=>{if(j.length){x(!0),C(null);try{Ip((await Lo(t.id,{sourceHash:O.sourceHash,locale:i,diagnostics:j})).prompt)}catch(e){C(e instanceof Error?e.message:String(e))}finally{x(!1)}}};return(0,Z.jsxs)(`section`,{ref:T.containerRef,className:`content-block-action-scope mt-3 overflow-hidden rounded-2xl border border-edge bg-surface-panel`,"data-inline-local-app":t.id,children:[(0,Z.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,title:t.title,children:t.title}),(0,Z.jsx)(`p`,{className:Y(`mt-0.5 text-xs`,N?`text-danger`:`text-fg-muted`),"aria-live":`polite`,children:P})]}),(0,Z.jsx)(mi,{variant:`ghost`,className:`content-block-action`,onClick:F,"data-action-visible":N,title:i===`zh`?`重新加载预览`:`Reload preview`,"aria-label":i===`zh`?`重新加载预览`:`Reload preview`,children:(0,Z.jsx)(Mt,{className:`size-4`,"aria-hidden":!0})}),(0,Z.jsx)(mi,{variant:`ghost`,className:`content-block-action`,onClick:D,title:i===`zh`?`查看预览`:`Preview`,"aria-label":i===`zh`?`查看预览`:`Preview`,children:(0,Z.jsx)(Se,{className:`size-4`,"aria-hidden":!0})})]}),(0,Z.jsxs)(`div`,{className:`relative bg-surface-base`,style:{height:w},children:[O.previewUrl?(0,Z.jsx)(`iframe`,{ref:s,title:i===`zh`?`${t.title} 交互预览`:`${t.title} interactive preview`,src:p(O.previewUrl),sandbox:`allow-scripts allow-forms`,className:`h-full w-full border-0 bg-white`},l):null,O.previewUrl&&f===`booting`?(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-0 grid place-items-center bg-surface-base/75`,children:(0,Z.jsx)(Yt,{className:`h-10 w-40`})}):null]}),N?(0,Z.jsxs)(`footer`,{className:`border-t border-danger/20 bg-danger-soft/60 px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Z.jsx)(`p`,{className:`min-w-0 flex-1 text-xs text-danger`,children:h?.message??j[0]?.message??(i===`zh`?`预览校验失败`:`Preview validation failed`)}),(0,Z.jsxs)(mi,{variant:`secondary`,className:`min-h-9 px-3 text-xs`,disabled:b||j.length===0,onClick:()=>void I(),children:[(0,Z.jsx)(Kt,{className:`size-4`}),b?i===`zh`?`生成修复建议…`:`Preparing fix…`:i===`zh`?`让 Coder 修复`:`Ask Coder to fix`]})]}),S?(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-danger`,role:`alert`,children:S}):null]}):null]})}async function nv(e,t){return(await g(p(`/api/chat-previews/${encodeURIComponent(e)}/revisions/${encodeURIComponent(t)}`))).revision}async function rv(e,t){return(await g(p(`/api/chat-previews/${encodeURIComponent(e)}/fix-guidance`),{method:`POST`,body:JSON.stringify(t)})).guidance}async function iv(e,t){return(await g(p(`/api/chat-previews/${encodeURIComponent(e)}/promote`),{method:`POST`,body:JSON.stringify({sourceHash:t})})).app}function av(e,t){return e.replace(RegExp(`</${t}`,`gi`),`<\\/${t}`)}function ov(e){let t=on.safeParse(e);return t.success?t.data:null}function sv(e,t){let n=`(() => {
28
+ const channel = ${JSON.stringify(t)};
29
+ const bufferedErrors = [];
30
+ const send = (type, detail = {}) => parent.postMessage({
31
+ source: ${JSON.stringify(an)},
32
+ version: 1, channel, type, ...detail
33
+ }, '*');
34
+ const resize = () => send('resize', { height: Math.max(120, Math.min(2000,
35
+ Math.ceil(document.documentElement.getBoundingClientRect().height))) });
36
+ const report = (diagnostic) => { bufferedErrors.push(diagnostic); send('error', { diagnostic }); };
37
+ addEventListener('error', (event) => report({
38
+ kind: 'script_error', message: String(event.message || 'Script error'),
39
+ filename: event.filename || undefined, line: event.lineno || undefined,
40
+ column: event.colno || undefined
41
+ }));
42
+ addEventListener('unhandledrejection', (event) => report({
43
+ kind: 'unhandled_rejection', message: String(event.reason?.message || event.reason || 'Unhandled rejection')
44
+ }));
45
+ addEventListener('DOMContentLoaded', () => {
46
+ resize(); new ResizeObserver(resize).observe(document.documentElement);
47
+ setTimeout(() => {
48
+ send('ready');
49
+ bufferedErrors.forEach((diagnostic) => send('error', { diagnostic }));
50
+ }, 100);
51
+ });
52
+ })();`;return`<!doctype html>
53
+ <html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
54
+ <meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: blob:; font-src data:; connect-src 'none'; frame-src 'none'; object-src 'none'; base-uri 'none'; form-action 'none'">
55
+ <style>html,body{margin:0;min-height:100%;background:#fff;color:#111827;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif}*{box-sizing:border-box}${av(e.styles,`style`)}</style>
56
+ </head><body>${e.markup}
57
+ <script>${av(n,`script`)}<\/script>
58
+ <script>${av(e.script,`script`)}<\/script>
59
+ </body></html>`}function cv(e,t,n){let r=r=>{if(r.source!==e.contentWindow)return;let i=ov(r.data);!i||i.channel!==t||n(i)};return window.addEventListener(`message`,r),()=>window.removeEventListener(`message`,r)}function lv({leaseId:e,reference:t,sourceHash:n,preferredHeight:r,language:i}){let a=d(),o=c(),s=(0,Q.useRef)(null),[l,u]=(0,Q.useState)(0),[f,p]=(0,Q.useState)(`booting`),[m,h]=(0,Q.useState)([]),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(null),b=oa(e),x=Math.min(720,Math.max(240,r)),S=(0,Q.useMemo)(()=>crypto.randomUUID(),[l,n]),C=Kr(b.active?[`chat-preview-revision`,t.id,n]:null,()=>nv(t.id,n),{revalidateOnFocus:!1,shouldRetryOnError:!1}),w=C.data?sv(C.data,S):void 0;(0,Q.useEffect)(()=>{let e=s.current;if(!e||!w)return;p(`booting`),h([]);let t=window.setTimeout(()=>{p(e=>e===`booting`?`timeout`:e)},7e3),n=cv(e,S,t=>{t.type===`ready`&&p(`healthy`),t.type===`resize`&&(e.style.height=`${Math.min(720,Math.max(240,t.height))}px`),t.type===`error`&&(p(`failed`),h(e=>[...e,t.diagnostic].slice(-20)))});return()=>{window.clearTimeout(t),n()}},[S,w]);let T=()=>{y(null),u(e=>e+1)},E=async()=>{if(m.length){_(`fix`),y(null);try{Ip((await rv(t.id,{sourceHash:n,diagnostics:m,locale:i})).prompt)}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(null)}}},D=async()=>{_(`promote`),y(null);try{let e=await iv(t.id,n);a(et(`${o.pathname}${o.search}`,`/local-apps/${encodeURIComponent(e.id)}`))}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(null)}},O=`content-block-action-scope mt-3 overflow-hidden rounded-2xl border border-edge bg-surface-panel`;if(!b.active)return(0,Z.jsxs)(`section`,{ref:b.containerRef,className:O,"data-inline-chat-preview":t.id,children:[(0,Z.jsxs)(`header`,{className:`border-b border-edge-subtle px-4 py-3`,children:[(0,Z.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:t.title}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:b.state===`queued`?i===`zh`?`正在等待预览资源`:`Waiting for a preview slot`:i===`zh`?`预览尚未加载`:`Preview not loaded`})]}),(0,Z.jsx)(`div`,{className:`grid place-items-center bg-surface-base`,style:{height:x},children:(0,Z.jsx)(mi,{variant:`secondary`,className:`min-h-11`,onClick:b.activate,children:i===`zh`?`加载交互预览`:`Load interactive preview`})})]});if(C.isLoading)return(0,Z.jsxs)(`section`,{ref:b.containerRef,className:O,"aria-busy":`true`,"aria-label":i===`zh`?`正在加载预览`:`Loading preview`,children:[(0,Z.jsx)(`div`,{className:`border-b border-edge-subtle px-4 py-3`,children:(0,Z.jsx)(Yt,{className:`h-5 w-40`})}),(0,Z.jsx)(Yt,{className:`m-3 w-[calc(100%-1.5rem)]`,style:{height:x}})]});if(!C.data||!w){let e=C.error instanceof Error?C.error.message:i===`zh`?`无法加载预览`:`Unable to load preview`;return(0,Z.jsx)(`section`,{ref:b.containerRef,className:`mt-3 rounded-2xl border border-danger/30 bg-danger-soft p-4 text-sm text-danger`,role:`alert`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Ut,{className:`size-4`}),e]})})}let k=f===`failed`||f===`timeout`,A=f===`healthy`?i===`zh`?`运行正常`:`Running`:f===`booting`?i===`zh`?`正在启动`:`Starting`:f===`timeout`?i===`zh`?`启动超时`:`Start timed out`:i===`zh`?`运行错误`:`Runtime error`;return(0,Z.jsxs)(`section`,{ref:b.containerRef,className:O,"data-inline-chat-preview":t.id,children:[(0,Z.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-2 border-b border-edge-subtle px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:t.title}),(0,Z.jsx)(`p`,{className:Y(`mt-0.5 text-xs`,k?`text-danger`:`text-fg-muted`),"aria-live":`polite`,children:A})]}),(0,Z.jsx)(mi,{variant:`ghost`,className:`content-block-action`,onClick:T,"data-action-visible":k,title:i===`zh`?`重新加载预览`:`Reload preview`,"aria-label":i===`zh`?`重新加载预览`:`Reload preview`,children:(0,Z.jsx)(Mt,{className:`size-4`,"aria-hidden":!0})}),(0,Z.jsx)(mi,{variant:`ghost`,className:`content-block-action`,disabled:g!==null,onClick:()=>void D(),"aria-busy":g===`promote`,title:g===`promote`?i===`zh`?`保存中…`:`Saving…`:i===`zh`?`保存为应用`:`Save as app`,"aria-label":g===`promote`?i===`zh`?`保存中…`:`Saving…`:i===`zh`?`保存为应用`:`Save as app`,children:(0,Z.jsx)(Pt,{className:Y(`size-4`,g===`promote`&&`motion-safe:animate-pulse`),"aria-hidden":!0})})]}),(0,Z.jsxs)(`div`,{className:`relative bg-surface-base`,style:{minHeight:x},children:[(0,Z.jsx)(`iframe`,{ref:s,title:i===`zh`?`${t.title} 交互预览`:`${t.title} interactive preview`,srcDoc:w,sandbox:`allow-scripts allow-forms`,className:`block w-full border-0 bg-white`,style:{height:x}},l),f===`booting`?(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-0 grid place-items-center bg-surface-base/75`,children:(0,Z.jsx)(Yt,{className:`h-10 w-40`})}):null]}),k?(0,Z.jsx)(`footer`,{className:`border-t border-danger/20 bg-danger-soft/60 px-4 py-3`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Z.jsx)(`p`,{className:`min-w-0 flex-1 text-xs text-danger`,role:`alert`,children:m.at(-1)?.message??(i===`zh`?`预览未能正常启动`:`The preview did not start correctly`)}),(0,Z.jsxs)(mi,{variant:`secondary`,className:`min-h-11 px-3 text-xs`,disabled:!m.length||g!==null,onClick:()=>void E(),children:[(0,Z.jsx)(Kt,{className:`size-4`}),g===`fix`?i===`zh`?`生成中…`:`Preparing…`:i===`zh`?`让 AI 修复`:`Ask AI to fix`]})]})}):null,v?(0,Z.jsx)(`p`,{className:`border-t border-danger/20 px-4 py-2 text-xs text-danger`,role:`alert`,children:v}):null]})}function uv(e){let t=(0,X.c)(8),{children:n,label:r,className:i}=e,a;t[0]===i?a=t[1]:(a=Y(`mt-2 w-full min-w-0 max-w-full self-start`,i),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,Z.jsx)(`div`,{className:`min-w-0`,children:n}),t[2]=n,t[3]=o);let s;return t[4]!==r||t[5]!==a||t[6]!==o?(s=(0,Z.jsx)(`section`,{className:a,"aria-label":r,"data-turn-tail":!0,children:o}),t[4]=r,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function dv(e){return{id:e.artifactId,name:e.title,type:e.kind,mimeType:e.mimeType,size:e.sizeBytes,uri:e.uri,workspaceRelativePath:e.workspaceRelativePath}}function fv(e){let t=e.mimeType?.toLowerCase()??``,n=e.type?.toLowerCase()??``;return t.startsWith(`image/`)||n===`image`?Te:t.startsWith(`audio/`)||n===`audio`||n===`voice`?ns:t.startsWith(`video/`)||n===`video`?_e:t.includes(`spreadsheet`)||[`spreadsheet`,`csv`,`xlsx`,`xls`].includes(n)?ge:t.includes(`zip`)||[`archive`,`zip`].includes(n)?A:n===`site`?W:Ee}function pv(e,t,n){return!!(e.uri||oi(e)||e.workspaceRelativePath?.trim()&&(t?.trim()||n?.trim()))}function mv(e){let t=(0,X.c)(43),{item:n,authToken:r,conversationId:i,projectId:a,onOpen:o}=e,s=h(hv),c;t[0]===s?c=t[1]:(c=y(s),t[0]=s,t[1]=c);let l=c.chat.productDelivery.kinds.file,u;t[2]!==r||t[3]!==i?(u={authToken:r,conversationId:i},t[2]=r,t[3]=i,t[4]=u):u=t[4];let d=rm(n.attachment,u),f;t[5]===n.attachment?f=t[6]:(f=fv(n.attachment),t[5]=n.attachment,t[6]=f);let p=f,m;t[7]!==i||t[8]!==n.attachment||t[9]!==a?(m=pv(n.attachment,i,a),t[7]=i,t[8]=n.attachment,t[9]=a,t[10]=m):m=t[10];let g=m,_=g||!!n.href,v;t[11]!==p||t[12]!==d.src||t[13]!==n.failed?(v=d.src?(0,Z.jsx)(`img`,{src:d.src,alt:``,className:`size-[18px] rounded object-cover`,decoding:`async`,loading:`lazy`}):(0,Z.jsx)(p,{strokeWidth:1.75,className:n.failed?`text-danger`:void 0}),t[11]=p,t[12]=d.src,t[13]=n.failed,t[14]=v):v=t[14];let b=n.attachment.name??l,x;t[15]===_?x=t[16]:(x=_?(0,Z.jsx)(ne,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}):null,t[15]=_,t[16]=x);let S;t[17]!==n.meta||t[18]!==v||t[19]!==b||t[20]!==x?(S=(0,Z.jsx)(ko,{icon:v,title:b,meta:n.meta,trailing:x}),t[17]=n.meta,t[18]=v,t[19]=b,t[20]=x,t[21]=S):S=t[21];let C=S,w=_?`cursor-pointer`:`cursor-default`,T;t[22]===w?T=t[23]:(T=Y(Oo,w),t[22]=w,t[23]=T);let E=T,D=n.attachment.name??l,O;t[24]!==n.meta||t[25]!==D?(O=[D,n.meta],t[24]=n.meta,t[25]=D,t[26]=O):O=t[26];let k=O.join(` · `);if(!g&&n.href){let e;return t[27]!==E||t[28]!==C||t[29]!==n.href||t[30]!==k?(e=(0,Z.jsx)(`li`,{className:`min-w-0 max-w-full`,"data-result-attachment":!0,children:(0,Z.jsx)(`a`,{title:k,href:n.href,target:`_blank`,rel:`noreferrer`,className:E,children:C})}),t[27]=E,t[28]=C,t[29]=n.href,t[30]=k,t[31]=e):e=t[31],e}if(!g){let e;return t[32]!==E||t[33]!==C?(e=(0,Z.jsx)(`li`,{className:E,"data-result-attachment":!0,children:C}),t[32]=E,t[33]=C,t[34]=e):e=t[34],e}let A;t[35]!==n.attachment||t[36]!==o?(A=()=>o(n.attachment),t[35]=n.attachment,t[36]=o,t[37]=A):A=t[37];let j;return t[38]!==E||t[39]!==C||t[40]!==A||t[41]!==k?(j=(0,Z.jsx)(`li`,{className:`min-w-0 max-w-full`,"data-result-attachment":!0,children:(0,Z.jsx)(`button`,{type:`button`,className:E,title:k,onClick:A,children:C})}),t[38]=E,t[39]=C,t[40]=A,t[41]=k,t[42]=j):j=t[42],j}function hv(e){return e.language}function gv(e){let t=(0,X.c)(25),{attachments:n,authToken:r,conversationId:i,projectId:a,onOpen:o,language:s}=e,c;t[0]!==n.length||t[1]!==s?(c=y(s).chat.turnOutcome.fileCount.replace(`{{count}}`,String(n.length)),t[0]=n.length,t[1]=s,t[2]=c):c=t[2];let l=c,u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=Y(Oo,`cursor-pointer list-none`),t[3]=u):u=t[3];let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(as,{strokeWidth:1.75}),t[4]=d):d=t[4];let f;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(ne,{className:`size-3.5 shrink-0 text-fg-subtle transition-transform duration-150 group-open:rotate-90 motion-reduce:transition-none`,"aria-hidden":!0}),t[5]=f):f=t[5];let p;t[6]===l?p=t[7]:(p=(0,Z.jsx)(`summary`,{className:u,children:(0,Z.jsx)(ko,{icon:d,title:l,trailing:f})}),t[6]=l,t[7]=p);let m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m=Y(Mo,Ao),t[8]=m):m=t[8];let h;if(t[9]!==n||t[10]!==r||t[11]!==i||t[12]!==o||t[13]!==a){let e;t[15]!==r||t[16]!==i||t[17]!==o||t[18]!==a?(e=e=>(0,Z.jsx)(mv,{item:e,authToken:r,conversationId:i,projectId:a,onOpen:o},e.key),t[15]=r,t[16]=i,t[17]=o,t[18]=a,t[19]=e):e=t[19],h=n.map(e),t[9]=n,t[10]=r,t[11]=i,t[12]=o,t[13]=a,t[14]=h}else h=t[14];let g;t[20]===h?g=t[21]:(g=(0,Z.jsx)(`ul`,{className:m,children:h}),t[20]=h,t[21]=g);let _;return t[22]!==p||t[23]!==g?(_=(0,Z.jsx)(`li`,{className:`min-w-0 max-w-full`,"data-result-attachment-group":!0,children:(0,Z.jsxs)(`details`,{className:`group`,children:[p,g]})}),t[22]=p,t[23]=g,t[24]=_):_=t[24],_}function _v(e,t){if(!e)return[];let n=y(t).chat.turnOutcome;return e.deliverables.map(e=>{let t=dv(e);return{key:`outcome:${e.artifactId}`,attachment:t,href:e.shareUrl,failed:e.availability===`failed`||e.availability===`missing`,meta:[n.availability[e.availability],e.sizeBytes===void 0?null:si(e.sizeBytes)].filter(Boolean).join(` · `)}})}function vv(e,t){let n=y(t).chat.turnOutcome;return(e??[]).map((e,t)=>({key:`attachment:${e.id??e.uri??e.name??t}`,attachment:e,meta:[n.generatedFile,typeof e.size==`number`?si(e.size):null].filter(Boolean).join(` · `)}))}function yv(e){let t=new Set;for(let n of e?.deliverables??[])for(let e of[n.artifactId,n.sourceFileId,n.workspaceRelativePath]){let n=e?.trim();n&&t.add(`file:${n}`)}return t}function bv(e){let t=(0,X.c)(46),{view:n,authToken:r,conversationId:i,projectId:a}=e,o=h(Tv)===`zh`?`zh`:`en`,s;t[0]!==i||t[1]!==a?(s={layout:`assistant`,conversationId:i,projectId:a},t[0]=i,t[1]=a,t[2]=s):s=t[2];let c=om(s),l=n.deliveries.filter(wv),u=E_(l),d=O_(l),f=k_(l),p=D_(l),m=(0,Q.useContext)(L_),g=new Set(yv(n.outcome));if(m)for(let{delivery:e,reference:t}of A_(l))t.kind===`automation`&&!t.runId&&e.operation!==`failed`&&g.add(`automation:${t.id}`);let _=A_(l,g).length,v,b,x,S;if(t[3]!==o||t[4]!==c||t[5]!==n.attachments||t[6]!==n.outcome||t[7]!==n.resultRevision){v=[..._v(n.outcome,o),...vv(n.attachments,o)];let e;t[12]!==n.outcome?.deliverables||t[13]!==n.resultRevision?(e=e=>!!(n.resultRevision&&n.outcome?.deliverables.some(t=>t.artifactId===e.id)),t[12]=n.outcome?.deliverables,t[13]=n.resultRevision,t[14]=e):e=t[14],b=e;let r;t[15]!==b||t[16]!==c||t[17]!==n.resultRevision?(r=e=>{c.openAttachment(e,b(e)?n.resultRevision:void 0)},t[15]=b,t[16]=c,t[17]=n.resultRevision,t[18]=r):r=t[18],x=r,S=v.filter(Cv),t[3]=o,t[4]=c,t[5]=n.attachments,t[6]=n.outcome,t[7]=n.resultRevision,t[8]=v,t[9]=b,t[10]=x,t[11]=S}else v=t[8],b=t[9],x=t[10],S=t[11];let C=S,w;t[19]!==v||t[20]!==C?(w=v.filter(e=>!C.includes(e)),t[19]=v,t[20]=C,t[21]=w):w=t[21];let T=w,E=_>0||T.length>0;if(u.length===0&&d.length===0&&f.length===0&&!E&&!C.length)return null;let D;t[22]!==r||t[23]!==i||t[24]!==C?(D=C.length>0?(0,Z.jsx)(hm,{attachments:C.map(Sv),authToken:r,conversationId:i,workspaceConversationId:i,layout:`assistant`}):null,t[22]=r,t[23]=i,t[24]=C,t[25]=D):D=t[25];let O=u.map(xv),k;t[26]===o?k=t[27]:(k=e=>{let{key:t,presentation:n}=e;return(0,Z.jsx)(tv,{previewId:`${t}:${n.reference.id}:${n.snapshot.sourceHash}`,reference:n.reference,sourceHash:n.snapshot.sourceHash,preferredHeight:n.preferredHeight,language:o},t)},t[26]=o,t[27]=k);let A=d.map(k),j;t[28]===o?j=t[29]:(j=e=>{let{key:t,presentation:n}=e;return(0,Z.jsx)(lv,{leaseId:`${t}:${n.reference.id}:${n.sourceHash}`,reference:n.reference,sourceHash:n.sourceHash,preferredHeight:n.preferredHeight,language:o},t)},t[28]=o,t[29]=j);let M=f.map(j),N=E?(0,Z.jsxs)(uv,{label:y(o).chat.productDelivery.heading,children:[(0,Z.jsxs)(`ul`,{className:Mo,children:[(0,Z.jsx)(J_,{deliveries:l,language:o,excludedReferenceKeys:g,conversationId:i,projectId:a}),T.length>1?(0,Z.jsx)(gv,{attachments:T,authToken:r,conversationId:i,projectId:a,onOpen:x,language:o}):T.map(e=>(0,Z.jsx)(mv,{item:e,authToken:r,conversationId:i,projectId:a,onOpen:x},e.key))]}),p.truncated?(0,Z.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-fg-muted`,children:y(o).chat.productDelivery.partialResults}):null]}):null,P;t[30]!==T.length||t[31]!==r||t[32]!==i||t[33]!==b||t[34]!==c.active||t[35]!==c.closePreview||t[36]!==c.open||t[37]!==n.resultRevision?(P=T.length>0?(0,Z.jsx)(Qr,{open:c.open,attachment:c.active,resultRevision:c.active&&b(c.active)?n.resultRevision:void 0,authToken:r,conversationId:i,onClose:c.closePreview}):null,t[30]=T.length,t[31]=r,t[32]=i,t[33]=b,t[34]=c.active,t[35]=c.closePreview,t[36]=c.open,t[37]=n.resultRevision,t[38]=P):P=t[38];let F;return t[39]!==N||t[40]!==P||t[41]!==D||t[42]!==O||t[43]!==A||t[44]!==M?(F=(0,Z.jsxs)(Z.Fragment,{children:[D,O,A,M,N,P]}),t[39]=N,t[40]=P,t[41]=D,t[42]=O,t[43]=A,t[44]=M,t[45]=F):F=t[45],F}function xv(e){let{key:t,presentation:n}=e;return(0,Z.jsx)($_,{presentation:n},t)}function Sv(e){return e.attachment}function Cv(e){return!e.failed&&e.attachment.mimeType?.startsWith(`image/`)}function wv(e){let{delivery:t}=e;return T_(t)}function Tv(e){return e.language}function Ev(e){let t=(0,X.c)(33),{outcome:n}=e,r=h(kv),i,a,o,s,c,l,u,d;if(t[0]!==r||t[1]!==n.changeSet||t[2]!==n.evidence||t[3]!==n.status||t[4]!==n.summary){d=Symbol.for(`react.early_return_sentinel`);bb0:{if(o=y(r).chat.turnOutcome,i=!!n.changeSet,a=n.evidence.length>0,!i&&!a){d=n.status===`failed`?(0,Z.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:n.summary||o.statusFailed}):null;break bb0}let e=n.evidence.filter(Ov).length,f=n.evidence.filter(Dv).length,p=n.status===`succeeded`?o.statusSucceeded:n.status===`failed`?o.statusFailed:o.statusPartial,m=n.status===`succeeded`?ee:n.status===`failed`?pe:ue,h=[n.changeSet?o.changedFileCount.replace(`{{count}}`,String(n.changeSet.files.length)):null,e>0?o.passedCount.replace(`{{count}}`,String(e)):null,f>0?o.failedCount.replace(`{{count}}`,String(f)):null,a&&e===0&&f===0?o.evidenceCount.replace(`{{count}}`,String(n.evidence.length)):null].filter(Boolean).join(` · `);l=`group mt-2 min-w-0 max-w-full text-sm`;let g=n.status===`succeeded`?`text-success`:n.status===`failed`?`text-danger`:`text-warning`,_;t[13]!==m||t[14]!==g?(_=(0,Z.jsx)(m,{className:g,"aria-hidden":!0}),t[13]=m,t[14]=g,t[15]=_):_=t[15];let v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(ne,{className:`size-3.5 shrink-0 text-fg-subtle transition-transform group-open:rotate-90 motion-reduce:transition-none`,strokeWidth:1.75,"aria-hidden":!0}),t[16]=v):v=t[16],u=(0,Z.jsx)(`summary`,{className:`${Oo} cursor-pointer list-none`,title:`${p} · ${h}`,children:(0,Z.jsx)(ko,{icon:_,title:p,meta:h,trailing:v})}),s=Ao,c=n.changeSet?(0,Z.jsxs)(`section`,{"aria-label":o.changes,children:[(0,Z.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:o.changeSetTitle}),(0,Z.jsx)(`span`,{className:`shrink-0 text-fg-subtle`,children:o.changeStats.replace(`{{files}}`,String(n.changeSet.files.length)).replace(`{{added}}`,String(n.changeSet.added)).replace(`{{removed}}`,String(n.changeSet.removed))})]}),(0,Z.jsxs)(`div`,{className:`mt-2 border-t border-edge-subtle/70 pt-2`,children:[n.changeSet.files.slice(0,8).map(e=>(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 py-1 text-xs`,children:[(0,Z.jsx)(`span`,{className:`w-14 shrink-0 text-fg-subtle`,children:o.fileStatus[e.status??`modified`]}),(0,Z.jsx)(`code`,{className:`min-w-0 truncate text-fg-muted`,children:e.path})]},e.path)),n.changeSet.files.length>8?(0,Z.jsx)(`div`,{className:`pt-1 text-xs text-fg-subtle`,children:o.moreFiles.replace(`{{count}}`,String(n.changeSet.files.length-8))}):null]}),n.changeSet.diff?(0,Z.jsxs)(`details`,{className:`mt-2`,children:[(0,Z.jsx)(`summary`,{className:`w-fit cursor-pointer rounded-md px-1.5 py-1 text-xs font-medium text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:o.viewDiff}),n.changeSet.diffTruncated?(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-warning`,children:o.diffTruncated}):null,(0,Z.jsx)(`pre`,{className:`mt-2 max-h-72 overflow-auto rounded-lg bg-surface-inset p-3 text-xs leading-5 text-fg-muted`,children:(0,Z.jsx)(`code`,{children:n.changeSet.diff})})]}):null]}):null}t[0]=r,t[1]=n.changeSet,t[2]=n.evidence,t[3]=n.status,t[4]=n.summary,t[5]=i,t[6]=a,t[7]=o,t[8]=s,t[9]=c,t[10]=l,t[11]=u,t[12]=d}else i=t[5],a=t[6],o=t[7],s=t[8],c=t[9],l=t[10],u=t[11],d=t[12];if(d!==Symbol.for(`react.early_return_sentinel`))return d;let f;t[17]!==i||t[18]!==a?(f=i&&a?(0,Z.jsx)(`div`,{className:`my-2 border-t border-edge-subtle`}):null,t[17]=i,t[18]=a,t[19]=f):f=t[19];let p;t[20]!==a||t[21]!==n.evidence||t[22]!==o?(p=a?(0,Z.jsxs)(`section`,{"aria-label":o.evidence,children:[(0,Z.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg`,children:o.evidence}),n.evidence.map(e=>(0,Z.jsxs)(`div`,{className:`flex min-h-10 items-center gap-2.5 border-b border-edge-subtle/60 py-1.5 last:border-b-0`,children:[(0,Z.jsx)(Je,{className:e.status===`passed`?`size-4 shrink-0 text-success`:e.status===`failed`?`size-4 shrink-0 text-danger`:`size-4 shrink-0 text-warning`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:e.label}),(0,Z.jsx)(`span`,{className:e.status===`passed`?`text-xs font-medium text-success`:e.status===`failed`?`text-xs font-medium text-danger`:`text-xs font-medium text-warning`,children:e.status===`passed`?o.passed:e.status===`failed`?o.failed:o.warning})]},e.evidenceId))]}):null,t[20]=a,t[21]=n.evidence,t[22]=o,t[23]=p):p=t[23];let m;t[24]!==s||t[25]!==c||t[26]!==f||t[27]!==p?(m=(0,Z.jsxs)(`div`,{className:s,children:[c,f,p]}),t[24]=s,t[25]=c,t[26]=f,t[27]=p,t[28]=m):m=t[28];let g;return t[29]!==l||t[30]!==u||t[31]!==m?(g=(0,Z.jsxs)(`details`,{className:l,children:[u,m]}),t[29]=l,t[30]=u,t[31]=m,t[32]=g):g=t[32],g}function Dv(e){return e.status===`failed`}function Ov(e){return e.status===`passed`}function kv(e){return e.language}function Av(e){let t=(0,X.c)(14),{view:n,authToken:r,conversationId:i,projectId:a,sourcesLabel:o}=e,s;t[0]!==r||t[1]!==i||t[2]!==a||t[3]!==n?(s=(0,Z.jsx)(bv,{view:n,authToken:r,conversationId:i,projectId:a}),t[0]=r,t[1]=i,t[2]=a,t[3]=n,t[4]=s):s=t[4];let c;t[5]===n.outcome?c=t[6]:(c=n.outcome?(0,Z.jsx)(Ev,{outcome:n.outcome}):null,t[5]=n.outcome,t[6]=c);let l;t[7]!==o||t[8]!==n.sources?(l=n.sources.length>0?(0,Z.jsxs)(`details`,{className:`group min-w-0 max-w-full`,"aria-label":o,children:[(0,Z.jsx)(`summary`,{className:`${Oo} cursor-pointer list-none`,children:(0,Z.jsx)(ko,{icon:(0,Z.jsx)(Fe,{}),title:o,trailing:(0,Z.jsx)(ne,{className:`size-3.5 shrink-0 text-fg-subtle transition-transform group-open:rotate-90 motion-reduce:transition-none`,"aria-hidden":!0})})}),(0,Z.jsx)(`div`,{className:Ao,children:(0,Z.jsx)(N_,{sources:n.sources,className:``})})]}):null,t[7]=o,t[8]=n.sources,t[9]=l):l=t[9];let u;return t[10]!==s||t[11]!==c||t[12]!==l?(u=(0,Z.jsxs)(Z.Fragment,{children:[s,c,l]}),t[10]=s,t[11]=c,t[12]=l,t[13]=u):u=t[13],u}var jv=`NO_REPLY`;function Mv(e,t){if(e.role!==`assistant`||!e.content?.length)return e;if(t?.hideSilentReply){let n=e.content.filter(e=>e.type!==`text`||e.text.trim()!==jv);if(n.length!==e.content.length)return Mv({...e,content:n},t)}let n=e.content.findIndex(e=>e.type===`text`);if(n<0)return e;let r=e.content[n];if(r.type!==`text`)return e;let i=r.text.trimStart();if(t?.hideSilentReply&&(i===jv||t.streaming&&i.length>0&&jv.startsWith(i)))return{...e,content:e.content.filter((e,t)=>t!==n)};if(!i.startsWith(jv))return e;if(i.length===8)return e.content.slice(n+1).some(e=>e.type===`text`&&e.text.trim().length>0)?{...e,content:e.content.filter((e,t)=>t!==n)}:e;let a=i.slice(8).trimStart();if(!a)return e;let o=[...e.content];return o[n]={...r,text:a},{...e,content:o}}function Nv(e,t){return t||e.workLog.items.some(e=>e.type===`tool_use`&&(e.status===`error`||e.activity?.status===`failed`))}function Pv(e,t){if(e.role!==`assistant`||t.isStreaming||t.followUpTrigger)return!0;let n=M_({message:Mv(e,{hideSilentReply:!0}),...t});return!!(n.answerContent.some(e=>e.type===`review`||e.type===`text`&&e.text.trim())||n.attachments?.length||n.deliveries.length||n.sources.length||n.outcome&&(n.outcome.status===`failed`||n.outcome.changeSet||n.outcome.evidence.length||n.outcome.deliverables.length)||e.taskResultDelivery||e.personalProvenance||Nv(n,t.showAssistantWorkLog)&&n.workLog.items.some(e=>t.personal||!n.workLog.compact&&t.showAssistantWorkLog||e.type===`tool_use`&&(e.status===`error`||e.activity?.status===`failed`)))}function Fv(e,t){let n=In(e.content).some(e=>e.type===`review`&&(!e.status||e.status===`complete`)||e.type===`text`&&!!e.text.trim()),r=e.fromHistory&&n,i=e.outcome??e.taskResultDelivery?.outcome,a=!t&&e.runStatus!==`suspended`&&!!(e.runStatus||i||r),o=e.runStatus===`error`||e.runStatus===`cancelled`||i?.status===`failed`;return{settled:a,defaultCollapsed:a&&n&&!o,outcome:i}}function Iv(e){let t=(0,X.c)(17),{message:n,isStreaming:r,enabled:i,items:a,durationMs:o}=e,s=(0,Q.useRef)(null),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(null),f=h(Lv),p=y(f).chat,m;t[0]!==r||t[1]!==n?(m=Fv(n,r),t[0]=r,t[1]=n,t[2]=m):m=t[2];let g=m,_=i&&g.settled&&a.length>0,v,b;t[3]===r?(v=t[4],b=t[5]):(v=()=>{r&&d(null)},b=[r],t[3]=r,t[4]=v,t[5]=b),(0,Q.useEffect)(v,b);let x,S;t[6]!==i||t[7]!==a.length?(x=()=>{if(!i||a.length===0)return;let e=()=>{let e=window.getSelection();l(!!(s.current&&[...s.current.querySelectorAll(`[data-assistant-process-item]`)].some(t=>e&&!e.isCollapsed&&e.containsNode(t,!0)||t.contains(document.activeElement))))};return e(),document.addEventListener(`selectionchange`,e),document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,e),()=>{document.removeEventListener(`selectionchange`,e),document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,e)}},S=[i,a.length],t[6]=i,t[7]=a.length,t[8]=x,t[9]=S):(x=t[8],S=t[9]),(0,Q.useEffect)(x,S);let C=u??(!g.defaultCollapsed||c),w=o==null?null:kg(o,f),T=n.runStatus===`cancelled`?p.processStopped:n.runStatus===`error`||g.outcome?.status===`failed`?p.processFailed:g.outcome?.status===`partial`?p.processPartial:null,E=T?`${T}${w?` · ${w}`:``}`:w?p.processWorkedFor.replace(`{{duration}}`,w):p.processView,D=_&&!C,O;t[10]!==C||t[11]!==E||t[12]!==_?(O=_?(0,Z.jsxs)(`button`,{type:`button`,"data-assistant-process-toggle":!0,"aria-expanded":C,onClick:()=>d(!C),className:`flex min-h-11 w-full items-center gap-1.5 border-b border-edge-subtle py-2 text-left text-sm text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,children:[(0,Z.jsx)(`span`,{children:E}),(0,Z.jsx)(ne,{"aria-hidden":!0,className:`size-4 shrink-0 transition-transform motion-reduce:transition-none ${C?`rotate-90`:``}`})]}):null,t[10]=C,t[11]=E,t[12]=_,t[13]=O):O=t[13];let k;return t[14]!==D||t[15]!==O?(k={contentRef:s,collapsed:D,summary:O},t[14]=D,t[15]=O,t[16]=k):k=t[16],k}function Lv(e){return e.language}function Rv(e,t=!1){return t||e.textSurface===`conversation`}function zv(e){let t=e.trim().split(/[,,;;。\n]/,1)[0]?.trim()||e.trim(),n=Array.from(t);return n.length>32?`${n.slice(0,32).join(``)}…`:t}function Bv(e){let t=(0,X.c)(23),{trigger:n}=e,r=c(),i=h(Vv),a;t[0]===i?a=t[1]:(a=y(i),t[0]=i,t[1]=a);let o=a.chat.taskTrigger,s=n.entryId,l;t[2]===o.about?l=t[3]:(l=(0,Z.jsx)(`span`,{className:`shrink-0`,children:o.about}),t[2]=o.about,t[3]=l);let d=`${r.pathname}${r.search}`,f;t[4]!==d||t[5]!==n.taskId?(f=nt(d,n.taskId),t[4]=d,t[5]=n.taskId,t[6]=f):f=t[6];let p=n.taskTitle,m=`${o.openTask}:${n.taskTitle}`,g;t[7]===n.taskTitle?g=t[8]:(g=zv(n.taskTitle),t[7]=n.taskTitle,t[8]=g);let _;t[9]===g?_=t[10]:(_=(0,Z.jsxs)(`span`,{className:`truncate`,children:[`「`,g,`」`]}),t[9]=g,t[10]=_);let v;t[11]!==f||t[12]!==m||t[13]!==_||t[14]!==n.taskTitle?(v=(0,Z.jsx)(u,{className:`inline-flex min-w-0 max-w-[min(48vw,30rem)] font-medium text-fg hover:text-accent hover:underline`,to:f,title:p,"aria-label":m,children:_}),t[11]=f,t[12]=m,t[13]=_,t[14]=n.taskTitle,t[15]=v):v=t[15];let b=o[n.kind],x;t[16]===b?x=t[17]:(x=(0,Z.jsxs)(`span`,{className:`shrink-0 whitespace-nowrap`,children:[`· `,b]}),t[16]=b,t[17]=x);let S;return t[18]!==v||t[19]!==x||t[20]!==l||t[21]!==n.entryId?(S=(0,Z.jsxs)(`div`,{className:`mb-4 flex min-w-0 max-w-full items-center gap-1.5 border-t border-edge-subtle pt-5 text-sm text-fg-muted`,"data-task-trigger":s,children:[l,v,x]}),t[18]=v,t[19]=x,t[20]=l,t[21]=n.entryId,t[22]=S):S=t[22],S}function Vv(e){return e.language}var Hv=3;function Uv(e){let t=(0,X.c)(36),{refs:n,groupLabel:r,noteLabel:i,fileLabel:a,folderLabel:o,sessionLabel:s,browserTabLabel:c,mcpResourceLabel:l,truncatedLabel:u,showMoreLabel:d,showLessLabel:f,onOpen:p}=e,[m,h]=(0,Q.useState)(!1);if(n.length===0)return null;let g=n.length>Hv,_;t[0]!==m||t[1]!==n?(_=m?n:n.slice(0,Hv),t[0]=m,t[1]=n,t[2]=_):_=t[2];let v=_,y=n.length-Hv,b;if(t[3]!==c||t[4]!==a||t[5]!==o||t[6]!==r||t[7]!==l||t[8]!==i||t[9]!==p||t[10]!==s||t[11]!==u||t[12]!==v){let e;t[14]!==c||t[15]!==a||t[16]!==o||t[17]!==r||t[18]!==l||t[19]!==i||t[20]!==p||t[21]!==s||t[22]!==u?(e=e=>{let t=e.kind===`note`,n=t?`button`:`div`,d=e.kind===`result`?a:e.kind===`file`?e.fileKind===`directory`?o:a:e.kind===`session`?s:e.kind===`browser_tab`?c:e.kind===`mcp_resource`?l:i;return(0,Z.jsxs)(n,{...t?{type:`button`,onClick:()=>p(e)}:{},className:Y(`group inline-flex min-h-9 min-w-0 max-w-full items-center gap-2 rounded-lg border border-edge-subtle bg-surface-panel/80 px-2 py-1.5 text-left`,t&&`transition-colors hover:border-accent/40 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),...t?{"aria-label":`${r}: ${e.title}`}:{},title:e.truncated?u:e.title,children:[(0,Z.jsx)(`span`,{className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md bg-accent-soft text-accent-fg`,children:e.kind===`file`&&e.fileKind===`directory`?(0,Z.jsx)(ke,{className:`size-3.5`,"aria-hidden":!0}):e.kind===`file`||e.kind===`result`?(0,Z.jsx)(Ee,{className:`size-3.5`,"aria-hidden":!0}):e.kind===`session`?(0,Z.jsx)(St,{className:`size-3.5`,"aria-hidden":!0}):e.kind===`browser_tab`?(0,Z.jsx)(k,{className:`size-3.5`,"aria-hidden":!0}):e.kind===`mcp_resource`?(0,Z.jsx)(be,{className:`size-3.5`,"aria-hidden":!0}):(0,Z.jsx)(ms,{className:`size-3.5`,"aria-hidden":!0})}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`shrink-0 text-[11px] text-fg-muted`,children:d}),(0,Z.jsx)(`span`,{className:`max-w-56 truncate text-xs font-medium text-fg sm:max-w-72`,children:e.title})]}),t?(0,Z.jsx)(ne,{className:`size-3.5 shrink-0 text-fg-disabled transition-transform group-hover:translate-x-0.5 group-hover:text-fg-muted`,"aria-hidden":!0}):null]},`${e.kind}:${e.sourceId}`)},t[14]=c,t[15]=a,t[16]=o,t[17]=r,t[18]=l,t[19]=i,t[20]=p,t[21]=s,t[22]=u,t[23]=e):e=t[23],b=v.map(e),t[3]=c,t[4]=a,t[5]=o,t[6]=r,t[7]=l,t[8]=i,t[9]=p,t[10]=s,t[11]=u,t[12]=v,t[13]=b}else b=t[13];let x;t[24]===b?x=t[25]:(x=(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-wrap gap-1.5`,children:b}),t[24]=b,t[25]=x);let S;t[26]!==g||t[27]!==m||t[28]!==y||t[29]!==f||t[30]!==d?(S=g?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-8 w-fit items-center gap-1 rounded-md px-2 text-xs text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-expanded":m,onClick:()=>h(Wv),children:[m?(0,Z.jsx)(re,{className:`size-3.5`,"aria-hidden":!0}):(0,Z.jsx)(te,{className:`size-3.5`,"aria-hidden":!0}),m?f:d.replace(`{{count}}`,String(y))]}):null,t[26]=g,t[27]=m,t[28]=y,t[29]=f,t[30]=d,t[31]=S):S=t[31];let C;return t[32]!==r||t[33]!==x||t[34]!==S?(C=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,role:`group`,"aria-label":r,children:[x,S]}),t[32]=r,t[33]=x,t[34]=S,t[35]=C):C=t[35],C}function Wv(e){return!e}function Gv(e,t){let n=new Map;for(let r of e){let e=r.sourceName.trim(),i=r.statement.trim().replace(/\s+/g,` `),a=r.origin===`connected_source`?`${r.origin}:${e}`:r.origin,o=r.origin===`connected_source`?t.connected_source.replace(`{{source}}`,e):t[r.origin],s=n.get(a);s?s.items.some(e=>e.statement.trim().replace(/\s+/g,` `)===i)||s.items.push(r):n.set(a,{id:a,label:o,items:[r]})}return Array.from(n.values())}function Kv(e){let t=(0,X.c)(67),{open:n,onOpenChange:r,items:i,labels:a}=e,o;t[0]!==i||t[1]!==a.origins?(o=Gv(i,a.origins),t[0]=i,t[1]=a.origins,t[2]=o):o=t[2];let s=o,c=s.reduce(Xv,0),l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=new Set,t[3]=l):l=t[3];let[u,d]=(0,Q.useState)(l),f,p;t[4]!==c||t[5]!==s||t[6]!==n?(f=()=>{!n||s.length===0||d(new Set(c<=6?s.map(Yv):[s[0].id]))},p=[c,s,n],t[4]=c,t[5]=s,t[6]=n,t[7]=f,t[8]=p):(f=t[7],p=t[8]),(0,Q.useEffect)(f,p);let m;t[9]!==u||t[10]!==s?(m=s.length>0&&s.every(e=>u.has(e.id)),t[9]=u,t[10]=s,t[11]=m):m=t[11];let h=m,g;t[12]!==h||t[13]!==s?(g=()=>{d(h?new Set:new Set(s.map(Jv)))},t[12]=h,t[13]=s,t[14]=g):g=t[14];let _=g,v;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(v=e=>{d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},t[15]=v):v=t[15];let y=v,x;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim/60 backdrop-blur-[1px]`}),t[16]=x):x=t[16];let O;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(O=Y(`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(36rem,calc(100dvh-2rem))]`,`w-[min(42rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-popover outline-none`),t[17]=O):O=t[17];let k;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,Z.jsx)(`span`,{className:`mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-lg bg-accent-soft text-accent-fg`,children:(0,Z.jsx)(es,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[18]=k):k=t[18];let A;t[19]===a.title?A=t[20]:(A=(0,Z.jsx)(E,{className:`text-base font-semibold text-fg`,children:a.title}),t[19]=a.title,t[20]=A);let j;t[21]===a.hint?j=t[22]:(j=(0,Z.jsx)(S,{className:`mt-1 text-sm leading-5 text-fg-muted`,children:a.hint}),t[21]=a.hint,t[22]=j);let M;t[23]!==c||t[24]!==a.itemsSummary?(M=a.itemsSummary.replace(`{{count}}`,String(c)),t[23]=c,t[24]=a.itemsSummary,t[25]=M):M=t[25];let N;t[26]===M?N=t[27]:(N=(0,Z.jsx)(`p`,{className:`mt-2 text-xs font-medium text-fg-subtle`,children:M}),t[26]=M,t[27]=N);let P;t[28]!==A||t[29]!==j||t[30]!==N?(P=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[A,j,N]}),t[28]=A,t[29]=j,t[30]=N,t[31]=P):P=t[31];let F;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Z.jsx)(qt,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[32]=F):F=t[32];let I;t[33]===a.close?I=t[34]:(I=(0,Z.jsx)(C,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors duration-150 hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":a.close,title:a.close,children:F})}),t[33]=a.close,t[34]=I);let L;t[35]!==P||t[36]!==I?(L=(0,Z.jsxs)(`header`,{className:`flex shrink-0 items-start gap-3 border-b border-edge-subtle px-4 py-4 sm:px-5`,children:[k,P,I]}),t[35]=P,t[36]=I,t[37]=L):L=t[37];let R;t[38]!==s.length||t[39]!==a.groupSummary?(R=a.groupSummary.replace(`{{count}}`,String(s.length)),t[38]=s.length,t[39]=a.groupSummary,t[40]=R):R=t[40];let z;t[41]===R?z=t[42]:(z=(0,Z.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:R}),t[41]=R,t[42]=z);let B;t[43]!==h||t[44]!==s.length||t[45]!==a.collapseAll||t[46]!==a.expandAll||t[47]!==_?(B=s.length>1?(0,Z.jsx)(`button`,{type:`button`,className:`rounded-md px-2 py-1 text-xs font-medium text-accent-fg transition-colors duration-150 hover:bg-accent-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:_,children:h?a.collapseAll:a.expandAll}):null,t[43]=h,t[44]=s.length,t[45]=a.collapseAll,t[46]=a.expandAll,t[47]=_,t[48]=B):B=t[48];let V;t[49]!==z||t[50]!==B?(V=(0,Z.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center justify-between gap-3 border-b border-edge-subtle px-4 sm:px-5`,children:[z,B]}),t[49]=z,t[50]=B,t[51]=V):V=t[51];let H;if(t[52]!==u||t[53]!==s){let e;t[55]===u?e=t[56]:(e=e=>{let t=u.has(e.id);return(0,Z.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`flex min-h-12 w-full items-center gap-3 px-3.5 py-2.5 text-left transition-colors duration-150 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,"aria-expanded":t,onClick:()=>y(e.id),children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-fg`,children:e.label}),(0,Z.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] tabular-nums text-fg-muted`,children:e.items.length}),(0,Z.jsx)(te,{className:Y(`size-4 shrink-0 text-fg-subtle transition-transform duration-200`,t&&`rotate-180`),strokeWidth:1.75,"aria-hidden":!0})]}),t?(0,Z.jsx)(`div`,{className:`border-t border-edge-subtle px-3.5`,children:e.items.map(qv)}):null]},e.id)},t[55]=u,t[56]=e),H=s.map(e),t[52]=u,t[53]=s,t[54]=H}else H=t[54];let U;t[57]===H?U=t[58]:(U=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-3 py-3 sm:px-4`,"data-testid":`response-context-scroll-region`,children:(0,Z.jsx)(`div`,{className:`space-y-2`,children:H})}),t[57]=H,t[58]=U);let W;t[59]!==L||t[60]!==V||t[61]!==U?(W=(0,Z.jsxs)(w,{children:[x,(0,Z.jsxs)(T,{className:O,children:[L,V,U]})]}),t[59]=L,t[60]=V,t[61]=U,t[62]=W):W=t[62];let G;return t[63]!==r||t[64]!==n||t[65]!==W?(G=(0,Z.jsx)(D,{open:n,onOpenChange:r,children:W}),t[63]=r,t[64]=n,t[65]=W,t[66]=G):G=t[66],G}function qv(e){return(0,Z.jsx)(`p`,{className:`border-b border-edge-subtle py-3 text-sm leading-6 text-fg last:border-b-0`,children:e.statement},e.id)}function Jv(e){return e.id}function Yv(e){return e.id}function Xv(e,t){return e+t.items.length}var Zv=Y(`inline-flex size-11 shrink-0 items-center justify-center rounded-lg sm:size-9`,`text-fg-muted transition-colors transition-transform duration-150 ease-out`,`hover:bg-surface-hover hover:text-fg active:scale-95`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,ua.disabled),Qv=[`misunderstood_intent`,`incorrect`,`did_not_act`,`tone_mismatch`,`too_verbose`,`other`],$v=Y(`inline-flex h-8 shrink-0 items-center justify-center gap-1 rounded-md px-2 text-xs text-fg-muted transition-colors`,`hover:bg-surface-hover hover:text-fg active:scale-[0.98]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,ua.disabled),ey=700,ty=120,ny=(0,Q.memo)(function({message:e,personal:t=!1,followUpTrigger:n,authToken:r,conversationId:i,workspaceConversationId:a,projectId:o,isStreaming:s,progress:l,reasoningLevel:u=`on`,messageIndex:f,onDeleteRound:m,onRetryUserMessageRound:_,userMessageCanRetry:v=!1,deleteRoundDisabled:b=!1,onSaveAssistantAsNote:x,onSaveAssistantToSourceNote:S,onExtractAssistantTask:C,onForkAssistantTurn:w,readonly:T=!1,density:E=`normal`,suppressAssistantActions:D=!1,onEditUserMessage:O,userMessageCanEdit:k=!0,responseFeedbackEnabled:A=!0,showAssistantWorkLog:j=!0}){let M=(0,Q.useMemo)(()=>Mv(e,{hideSilentReply:Rv(e,t),streaming:s}),[e,t,s]),N=h(e=>e.language),P=y(N),L=d(),R=c(),V=M.role===`user`,U=M.role===`assistant`,W=(0,Q.useRef)(V&&M.deliveryStatus===`sending`).current,G=V&&M.deliveryStatus===`sending`,ne=V&&M.deliveryStatus===`failed`,[ie,ae]=(0,Q.useState)(!1),[K,oe]=(0,Q.useState)(!1),[se,q]=(0,Q.useState)(()=>typeof navigator<`u`&&navigator.onLine===!1),ce=V?P.chat.you:U?P.chat.assistant:P.chat.tool;(0,Q.useEffect)(()=>{if(!G||typeof window>`u`)return;let e=()=>q(window.navigator.onLine===!1);return window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}},[G]),(0,Q.useEffect)(()=>{if(G){if(ie)return;let e=window.setTimeout(()=>ae(!0),se?0:ey);return()=>window.clearTimeout(e)}if(!ie)return;let e=0,t=window.requestAnimationFrame(()=>{oe(!0),e=window.setTimeout(()=>{ae(!1),oe(!1)},ty)});return()=>{window.cancelAnimationFrame(t),window.clearTimeout(e)}},[G,se,ie]);let le=ne||ie,de=ne?`failed`:`sending`,fe=(0,Q.useCallback)(e=>{let t=`${R.pathname}${R.search}`;L(rt(t,e))},[R.pathname,R.search,L]),J=(0,Q.useMemo)(()=>({input:P.chat.toolInput,output:P.chat.toolOutput,noOutput:P.chat.noOutput}),[P.chat.toolInput,P.chat.toolOutput,P.chat.noOutput]),pe=(0,Q.useMemo)(()=>({thoughts:P.chat.thoughts,thoughtsStreaming:P.chat.thoughtsStreaming,workLogTitle:P.chat.workLogTitle,workLogRunning:P.chat.workLogRunning,workLogComplete:P.chat.workLogComplete,workLogPartial:P.chat.workLogPartial,workLogFailed:P.chat.workLogFailed,searchedWeb:P.chat.stepSearchedWeb,searchedMemory:P.chat.stepSearchedMemory,searchedCode:P.chat.stepSearchedCode,searched:P.chat.stepSearched,readFile:P.chat.stepReadFile,stepDetails:P.chat.stepDetails,runCommand:P.chat.stepRunCommand,listDirectory:P.chat.stepListDirectory,writeFile:P.chat.stepWriteFile,editFile:P.chat.stepEditFile,openUrl:P.chat.stepOpenUrl,fetchUrl:P.chat.stepFetchUrl,unknownTool:P.chat.stepUnknownTool,rawThinking:P.chat.rawThinking,toolError:P.chat.toolError,toolActivity:P.chat.toolActivity,memoryActivity:P.chat.memoryActivity}),[P.chat.thoughts,P.chat.thoughtsStreaming,P.chat.workLogTitle,P.chat.workLogRunning,P.chat.workLogComplete,P.chat.workLogPartial,P.chat.workLogFailed,P.chat.stepSearchedWeb,P.chat.stepSearchedMemory,P.chat.stepSearchedCode,P.chat.stepSearched,P.chat.stepReadFile,P.chat.stepDetails,P.chat.stepRunCommand,P.chat.stepListDirectory,P.chat.stepWriteFile,P.chat.stepEditFile,P.chat.stepOpenUrl,P.chat.stepFetchUrl,P.chat.stepUnknownTool,P.chat.rawThinking,P.chat.toolError,P.chat.toolActivity,P.chat.memoryActivity]),me=(0,Q.useMemo)(()=>({ing:P.chat.stepsClusterIng}),[P.chat.stepsClusterIng]),he=(0,Q.useMemo)(()=>P.chat.toolCard,[P.chat.toolCard]),ge=u===`off`,_e=(0,Q.useMemo)(()=>U?M_({message:M,isStreaming:s,reasoningLevel:u,personal:t}):null,[U,s,M,u,t]),ve=(0,Q.useMemo)(()=>{if(!_e)return(M.content??[]).filter(e=>e.type!==`image`);if(t)return _e.answerContent;if(!ge&&j)return(M.content??[]).filter(e=>e.type!==`image`);let e=new Set(_e.answerContent);return(M.content??[]).filter(t=>e.has(t)||t.type===`tool_use`&&(t.status===`error`||t.activity?.status===`failed`))},[_e,M.content,t,ge,j]),be=(0,Q.useMemo)(()=>_e?_e.attachments:M.attachments,[_e,M.attachments]),Se=U&&!t&&!ge&&j,we=Iv({message:M,isStreaming:s,enabled:Se,items:_e?.workLog.items??[],durationMs:M.completedAt==null?void 0:_e?.workLog.durationMs}),Te=(0,Q.useMemo)(()=>Se?new Set(_e?.workLog.items):void 0,[Se,_e]),De=(0,Q.useMemo)(()=>{let e=new Set(M.userTurnDocument?.parts.flatMap(e=>e.type===`context_ref`?[e.refId]:[])??[]);return M.contextRefs?.filter(t=>!t.refId||!e.has(t.refId))},[M.contextRefs,M.userTurnDocument]),Oe=!!(_e?.workLog.active||_e?.workLog.items.length),ke=!!_e?.answer.started,Ae=ge||U&&(Oe||ke)?null:l,je=!ge&&!!M.content?.some(e=>e.type===`thinking`&&e.streaming),Me=U?!!_e?.answer.showStreamingCursor:s,Ne=t&&U&&s&&!_e?.answer.started&&!be?.length,Pe=s&&!je&&(!U||!Oe&&!ke),Fe=!!Ae?.message||Pe,Ie=U&&!T&&!s&&!D,Le=U&&s&&!T&&!D&&ke,Re=(0,Q.useMemo)(()=>Ie?bm(M.content??[]):``,[Ie,M]),ze=(0,Q.useMemo)(()=>Ie&&Re?Sm(M.content??[]):``,[Ie,Re,M]),Be=(0,Q.useMemo)(()=>Ie&&Re?B(Re):``,[Ie,Re]),Ve=(0,Q.useMemo)(()=>({source:{type:`chat-message`,id:`${i??`chat`}:${M.timestamp??f??Re.length}`,title:Be.split(`
60
+ `)[0]?.slice(0,48)||P.chat.messageReadAloudTitle,href:i?`#/chat/${encodeURIComponent(i)}`:void 0,targetId:f==null?void 0:`chat-message-${f}`},text:Be,language:I(Be,N)}),[Re.length,N,P.chat.messageReadAloudTitle,M.timestamp,f,i,Be]),He=(0,Q.useMemo)(()=>{if(!V)return``;if(M.userTurnDocument){let e=new Map(M.contextRefs?.flatMap(e=>e.refId?[[e.refId,e.title]]:[])??[]);return Cr(M.userTurnDocument,t=>e.get(t))}return Rn(M.content)},[V,M.content,M.contextRefs,M.userTurnDocument]),[Ue,We]=(0,Q.useState)(null),[Ge,Ke]=(0,Q.useState)(!1),[qe,Je]=(0,Q.useState)(null),[Xe,Ze]=(0,Q.useState)(null),[Qe,$e]=(0,Q.useState)(!1),[et,tt]=(0,Q.useState)(null),[nt,it]=(0,Q.useState)(!1),[at,ot]=(0,Q.useState)(!1),[st,ct]=(0,Q.useState)(!1),[lt,ut]=(0,Q.useState)(!1),[dt,ft]=(0,Q.useState)(null),[pt,mt]=(0,Q.useState)([]),[ht,gt]=(0,Q.useState)(!1),[_t,vt]=(0,Q.useState)(!1),[yt,bt]=(0,Q.useState)(null),[xt,St]=(0,Q.useState)(!1),[Ct,wt]=(0,Q.useState)(!1),Tt=(0,Q.useRef)(null),Et=(0,Q.useCallback)((e,t)=>{let n=vm(e,t);n&&bt(n)},[]),Dt=(0,Q.useCallback)(()=>{!i||!M.renderKey||Nn.getState().completeProgressiveRender(i,M.renderKey)},[M.renderKey,i]),Ot=(0,Q.useCallback)(()=>{ze&&Ti(ze).then(e=>{e&&(We(`plain`),window.setTimeout(()=>We(e=>e===`plain`?null:e),2e3))})},[ze]),At=(0,Q.useCallback)(()=>{Re&&Ti(Re).then(e=>{e&&(We(`markdown`),window.setTimeout(()=>We(e=>e===`markdown`?null:e),2e3))})},[Re]),jt=(0,Q.useCallback)(()=>{!Re||!x||Xe||(Ze(`create-note`),Promise.resolve(x(Re)).then(()=>{Je(`create-note`),window.setTimeout(()=>Je(e=>e===`create-note`?null:e),2e3)}).catch(()=>void 0).finally(()=>Ze(null)))},[Xe,Re,x]),Nt=(0,Q.useCallback)(()=>{!Re||!S||Xe||(Ze(`save-source-note`),Promise.resolve(S(Re)).then(()=>{Je(`save-source-note`),window.setTimeout(()=>Je(e=>e===`save-source-note`?null:e),2e3)}).catch(()=>void 0).finally(()=>Ze(null)))},[Xe,Re,S]),Pt=(0,Q.useCallback)(()=>{!ze&&!Re||!C||Xe||(Ze(`extract-task`),Promise.resolve(C(ze||Re)).then(()=>{Je(`extract-task`),window.setTimeout(()=>Je(e=>e===`extract-task`?null:e),2e3)}).catch(()=>void 0).finally(()=>Ze(null)))},[Xe,Re,ze,C]),Ft=(0,Q.useCallback)(()=>{He&&Ti(He).then(e=>{e&&(We(`user`),window.setTimeout(()=>We(e=>e===`user`?null:e),2e3))})},[He]),It=(0,Q.useCallback)(()=>{!M.turnId||!w||Qe||($e(!0),Promise.resolve(w(M.turnId)).catch(()=>void 0).finally(()=>$e(!1)))},[Qe,M.turnId,w]),Lt=(0,Q.useCallback)((e,t)=>{!M.turnId||at||(ot(!0),it(!0),ct(!1),g(p(`/api/turns/${encodeURIComponent(M.turnId)}/execution-context/feedback`),{method:`POST`,body:JSON.stringify({rating:e===`helpful`?`helpful`:`irrelevant`,reason:t})}).then(()=>{tt(e),ft(t??null),ut(!1)}).catch(()=>ct(!0)).finally(()=>ot(!1)))},[M.turnId,at]),Rt=(0,Q.useCallback)(()=>{dt&&Ip(P.chat.messageFeedbackRepairPrompts[dt])},[P.chat.messageFeedbackRepairPrompts,dt]),zt=(0,Q.useCallback)(()=>{!M.turnId||nt||at||(ot(!0),g(p(`/api/turns/${encodeURIComponent(M.turnId)}/execution-context`)).then(e=>{mt(e.resolvedItems.filter(e=>e.included).map(e=>({id:`${e.objectType}:${e.objectId}`,statement:e.content,origin:e.origin,sourceName:e.sourceLabel})))}).catch(()=>void 0).finally(()=>{it(!0),ot(!1)}))},[M.turnId,at,nt]),Bt=(0,Q.useCallback)(()=>{f==null||!m||vt(!0)},[f,m]),Vt=(0,Q.useCallback)(()=>{f==null||!m||(m(f),vt(!1))},[f,m]),Ut=(0,Q.useCallback)(()=>{vt(!1)},[]);(0,Q.useLayoutEffect)(()=>{if(!V)return;let e=Tt.current;if(!e)return;let t=()=>{let t=window.getComputedStyle(e),n=Number.parseFloat(t.lineHeight),r=Number.parseFloat(t.fontSize)||14,i=Number.isFinite(n)?n:r*1.625;wt(e.scrollHeight>i*10+1)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[V,ve,He]),(0,Q.useLayoutEffect)(()=>{St(!1)},[V,He]);let Wt=b||!v,Gt=_e&&Nv(_e,j)&&(_e.workLog.active||_e.workLog.items.length>0)?(0,Z.jsx)(zg,{workLog:_e.workLog,pendingStatus:M.pendingResponseStatus,toolLabels:J,stepLabels:pe,clusterLabels:me,cardLabels:he,conversationId:i,simplified:!t,personal:t,surfacesOnly:!t,answerStarted:_e.answer.started}):null;return(0,Z.jsx)(rd.Provider,{value:id(_e?.deliveries??[]),children:(0,Z.jsxs)(`article`,{className:Y(`group/msg flex w-full min-w-0`,V?`justify-end`:`justify-start`,W&&`xopc-chat-user-message-enter`),children:[(0,Z.jsxs)(`div`,{className:Y(`min-w-0`,V?`flex w-full max-w-[min(78%,var(--max-width-chat-user))] flex-col items-end`:`w-full max-w-[var(--max-width-chat-reading)]`,T&&`max-w-full`),children:[(0,Z.jsx)(`span`,{className:`sr-only`,children:ce}),n?(0,Z.jsx)(Bv,{trigger:n}):null,V&&Fe?(0,Z.jsxs)(`div`,{className:`mb-2 flex w-full min-w-0 flex-wrap items-center justify-end gap-x-2 gap-y-0.5 text-xs`,children:[Ae?.message&&!Oe?(0,Z.jsx)(`span`,{className:`text-fg-subtle`,title:Ae.detail??``,children:Ae.message}):null,Pe&&!Ae?.message?(0,Z.jsx)(`span`,{className:`text-fg-subtle`,children:P.chat.thinkingLabel}):null]}):null,!V&&Fe&&!Ne?(0,Z.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-baseline gap-x-2 gap-y-0.5 text-xs text-fg-disabled`,children:[Ae?.message&&!Oe?(0,Z.jsx)(`span`,{className:`text-fg-subtle`,title:Ae.detail??``,children:Ae.message}):null,Pe&&!Ae?.message?(0,Z.jsx)(`span`,{className:`text-fg-subtle`,children:P.chat.thinkingLabel}):null]}):null,(0,Z.jsx)(`div`,{dir:V?`auto`:void 0,className:Y(`min-w-0 text-fg`,V&&`chat-user-message`,E===`compact`?`text-sm leading-relaxed`:V?`text-[0.9375rem] leading-[1.6667]`:`text-base leading-[1.6875]`,V&&`w-fit max-w-full rounded-2xl bg-surface-hover/80 px-4 py-3 text-left dark:bg-surface-hover/50`,Ne&&`bg-transparent p-0`),children:(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[Ne?(0,Z.jsx)(`div`,{className:`xopc-personal-thinking`,role:`status`,"aria-label":P.chat.thinkingLabel,children:(0,Z.jsxs)(`span`,{className:`xopc-personal-thinking-dots`,"aria-hidden":`true`,children:[(0,Z.jsx)(`i`,{}),(0,Z.jsx)(`i`,{}),(0,Z.jsx)(`i`,{})]})}):null,t?Gt:null,(ve?.length??0)>0?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{ref:V?Tt:we.contentRef,"data-chat-find-text":!0,className:Y(`relative min-w-0`,`flex flex-col gap-3`,V&&!xt&&`overflow-hidden`),style:V&&!xt?{maxHeight:`calc(10lh)`}:void 0,children:[we.summary,(0,Z.jsx)(wh,{taskRunId:M.taskResultDelivery?.taskRunId,content:ve,isUser:V,isAssistantMessageStreaming:U&&s,imagePreviewLabel:P.chat.attachmentPreviewImage,onImagePreview:Et,conversationId:i,workspaceConversationId:a,projectId:o,progressiveRender:!!M.progressiveRender,onProgressiveRenderComplete:Dt,userTurnDocument:M.userTurnDocument,contextRefs:M.contextRefs,responseRunId:U?M.turnId:void 0,immediateFirstCommit:Rv(M,t),processItems:Te,processCollapsed:we.collapsed,renderActivity:!t&&_e?(e,t)=>{let n=s&&(t||e.some(e=>e.type===`tool_use`&&e.status===`running`)),r=h_(e);return(0,Z.jsx)(zg,{workLog:{items:e,active:n,status:n?`running`:e.some(e=>e.type===`tool_use`&&(e.status===`error`||e.activity?.status===`failed`))?`failed`:`completed`,compact:!1,expandedByDefault:u===`stream`&&n,startedAt:r.startedAt,durationMs:r.durationMs},toolLabels:J,stepLabels:pe,clusterLabels:me,cardLabels:he,conversationId:i,simplified:!1,showThinking:!0,renderSurfaces:!1})}:void 0}),Me?(0,Z.jsx)(`span`,{"aria-hidden":!0,"data-chat-streaming-cursor":!0,className:`pointer-events-none absolute start-0 top-full mt-1 h-3 w-0.5 bg-accent opacity-60`}):null]}),V&&Ct?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex w-fit items-center gap-1 rounded-md px-1.5 py-1 text-xs font-medium text-accent transition-colors hover:bg-accent/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,onClick:()=>St(e=>!e),"aria-expanded":xt,children:[xt?(0,Z.jsx)(re,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(te,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:xt?P.chat.userMessageCollapse:P.chat.userMessageExpand})]}):null]}):null,t?null:Gt,!t&&_e&&!_e.answer.started&&s&&!ve.some(e=>e.type===`thinking`||e.type===`tool_use`)?(0,Z.jsx)(zg,{workLog:{items:[],active:!0,status:`running`,compact:!0,expandedByDefault:!1},pendingStatus:M.pendingResponseStatus,toolLabels:J,stepLabels:pe,clusterLabels:me,cardLabels:he,conversationId:i}):null,!t&&!V&&M.taskResultDelivery&&i?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,"data-result-follow-up":!0,children:[M.taskResultDelivery.resultRevision?(0,Z.jsxs)(`span`,{className:`text-xs text-fg-muted`,"data-result-revision":!0,children:[N===`zh`?`成果版本`:`Result version`,` `,M.taskResultDelivery.resultRevision]}):null,[{sourceId:`body`,title:M.taskResultDelivery.taskTitle},...M.taskResultDelivery.outcome.deliverables.filter(e=>e.availability===`available`).map(e=>({sourceId:e.artifactId,title:e.title}))].map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`max-w-64 truncate rounded-md border border-edge-subtle px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>{let t=M.taskResultDelivery;window.dispatchEvent(new CustomEvent(`chat-result-reference`,{detail:{conversationId:i,reference:{kind:`result`,sourceId:Os(t.deliveryId.replace(/^reply:/,``),e.sourceId),expectedVersion:ks(t),title:e.title}}}))},children:[N===`zh`?`询问:`:`Ask about: `,e.title]},e.sourceId))]}):null,_e?(0,Z.jsx)(Av,{view:_e,authToken:r,conversationId:a??i,projectId:o,sourcesLabel:P.chat.searchSourcesHeading.replace(`{{count}}`,String(_e.sources.length))}):null,V&&M.sourceDevice?(0,Z.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[N===`zh`?`来自 `:`From `,M.sourceDevice.name]}):null,V&&De?.length?(0,Z.jsx)(Uv,{refs:De,groupLabel:P.chat.commandPalette.contextLabel,noteLabel:P.chat.commandPalette.notesSection,fileLabel:P.chat.atMention.files,folderLabel:P.chat.atMention.folders,sessionLabel:P.chat.atMention.chats,browserTabLabel:P.chat.atMention.browserTabs,mcpResourceLabel:P.chat.atMention.mcpResources,truncatedLabel:P.chat.commandPalette.contextTruncated,showMoreLabel:P.chat.contextReferencesMore,showLessLabel:P.chat.contextReferencesLess,onOpen:e=>fe(e.sourceId)}):null,V&&be?.length?(0,Z.jsx)(hm,{attachments:be,authToken:r,conversationId:i,workspaceConversationId:a,layout:`user`,centerUserVoiceRow:He.length===0}):null]})}),le?(0,Z.jsxs)(`div`,{"data-delivery-status":de,role:ne?`alert`:`status`,"aria-live":`polite`,"aria-hidden":K&&!ne?!0:void 0,className:Y(`mt-1 flex min-h-5 items-center justify-end gap-1.5 pe-1 text-xs transition-opacity duration-[120ms] ease-out motion-reduce:transition-none`,ne?`text-danger`:`text-fg-subtle`,K&&!ne&&`opacity-0`),children:[ne?(0,Z.jsx)(ue,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}):null,(0,Z.jsx)(`span`,{children:ne?P.chat.userMessageSendFailed:se&&G?P.chat.userMessageWaitingForNetwork:P.chat.userMessageSending}),ne&&_&&f!=null?(0,Z.jsx)(`button`,{type:`button`,className:`rounded-md px-1.5 py-0.5 font-medium text-danger underline-offset-2 hover:bg-danger/10 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-danger/40`,onClick:()=>_(f),children:P.chat.userMessageRetry}):null]}):null,!V&&M.personalProvenance&&!s&&(0,Z.jsx)(tm,{provenance:M.personalProvenance}),V&&!s&&!T?(0,Z.jsxs)(`div`,{"data-user-message-actions":!0,className:Y(`mt-1 flex h-8 w-full min-w-0 shrink-0 items-center justify-end gap-0.5 sm:gap-2`,`pointer-events-none opacity-0 transition-opacity duration-150 ease-out`,`group-hover/msg:pointer-events-auto group-hover/msg:opacity-100`,`group-focus-within/msg:pointer-events-auto group-focus-within/msg:opacity-100`,`[@media(hover:none)_and_(pointer:coarse)]:pointer-events-auto [@media(hover:none)_and_(pointer:coarse)]:opacity-100`),children:[_&&f!=null&&M.deliveryStatus!==`failed`?(0,Z.jsxs)(`button`,{type:`button`,className:Y($v,Wt&&`opacity-40`),onClick:()=>_(f),disabled:Wt,title:b?P.chat.userMessageActionsWait:v?P.chat.userMessageRetry:P.chat.userMessageRetryDisabledHint,"aria-label":P.chat.userMessageRetry,children:[(0,Z.jsx)(Mt,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`max-w-[4.5rem] truncate sm:max-w-none`,children:P.chat.userMessageRetry})]}):null,(0,Z.jsx)(`button`,{type:`button`,className:Y($v,`size-8 px-0`),onClick:()=>{if(O&&f!=null){O(M,f);return}Ip(He,Ln(M.attachments))},disabled:!He&&!M.attachments?.length&&!M.contextRefs?.length||!k,title:k?b?P.chat.userMessageStopAndEdit:P.chat.userMessageEdit:P.chat.userMessageEditDisabledHint,"aria-label":P.chat.userMessageEdit,children:(0,Z.jsx)(kt,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})}),(0,Z.jsx)(`button`,{type:`button`,className:Y($v,`size-8 px-0`),onClick:Ft,disabled:!He,title:Ue===`user`?P.chat.messageCopied:P.chat.userMessageCopy,"aria-label":Ue===`user`?P.chat.messageCopied:P.chat.userMessageCopy,children:Ue===`user`?(0,Z.jsx)(ee,{className:`size-3.5 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(ye,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})}),m&&f!=null&&!b?(0,Z.jsx)(`button`,{type:`button`,className:Y($v,`size-8 px-0 hover:text-red-500 dark:hover:text-red-400`),onClick:Bt,title:P.chat.userMessageDelete,"aria-label":P.chat.userMessageDelete,children:(0,Z.jsx)(Ht,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})}):null]}):null,Le?(0,Z.jsx)(`div`,{"data-assistant-actions-placeholder":!0,className:`mt-1 min-h-9 shrink-0`,"aria-hidden":`true`}):null,Ie&&Re?(0,Z.jsx)(p_,{children:(0,Z.jsxs)(`div`,{"data-assistant-message-actions":!0,className:Y(`mt-1 flex min-h-9 shrink-0 items-center gap-1 overflow-visible transition-opacity duration-150 ease-out motion-reduce:transition-none`,`pointer-events-none opacity-0 group-hover/msg:pointer-events-auto group-hover/msg:opacity-100`,`group-focus-within/msg:pointer-events-auto group-focus-within/msg:opacity-100`,`[@media(hover:none)_and_(pointer:coarse)]:pointer-events-auto [@media(hover:none)_and_(pointer:coarse)]:opacity-100`,(Ge||lt||st)&&`pointer-events-auto opacity-100`),children:[(0,Z.jsx)(m_,{label:Ue===`plain`?P.chat.messageCopied:P.chat.messageCopyPlainText,children:(0,Z.jsx)(`button`,{type:`button`,className:Zv,onClick:Ot,disabled:!ze,"aria-label":Ue===`plain`?P.chat.messageCopied:P.chat.messageCopyPlainText,children:Ue===`plain`?(0,Z.jsx)(ee,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(ye,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})})}),(0,Z.jsx)(m_,{label:P.chat.messageReadAloud,children:(0,Z.jsx)(F,{input:Ve,labels:{read:P.chat.messageReadAloud,preparing:P.chat.messageReadAloudPreparing,pause:P.chat.messageReadAloudPause,resume:P.chat.messageReadAloudResume,retry:P.chat.messageReadAloudRetry},hideNativeTitle:!0})}),(0,Z.jsxs)(vi,{open:Ge,onOpenChange:e=>{Ke(e),e&&zt()},children:[(0,Z.jsx)(m_,{label:P.chat.messageMoreActions,children:(0,Z.jsx)(bi,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:Zv,"aria-label":P.chat.messageMoreActions,children:(0,Z.jsx)(xe,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})})})}),(0,Z.jsx)(gi,{children:(0,Z.jsxs)(_i,{side:`bottom`,align:`start`,sideOffset:6,className:`z-[70] w-56 rounded-xl border border-edge bg-surface-overlay p-1.5 shadow-popover outline-none`,children:[(0,Z.jsx)(yi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:At,children:[Ue===`markdown`?(0,Z.jsx)(ee,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(Ce,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),Ue===`markdown`?P.chat.messageCopied:P.chat.messageCopyMarkdown]})}),w&&M.turnId?(0,Z.jsx)(yi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:It,disabled:Qe,children:[(0,Z.jsx)(ss,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),Qe?P.chat.messageForkCreating:P.chat.messageForkFromHere]})}):null,x?(0,Z.jsx)(yi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:jt,disabled:Xe!==null,children:[qe===`create-note`?(0,Z.jsx)(ee,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(is,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),qe===`create-note`?P.chat.messageSavedToNote:P.chat.messageSaveToNote]})}):null,A&&i&&M.timestamp?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`my-1 border-t border-edge-subtle`,role:`separator`}),(0,Z.jsx)(yi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>Lt(`helpful`),disabled:at,"aria-pressed":et===`helpful`,children:[(0,Z.jsx)(z,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),P.chat.messageHelpful]})}),(0,Z.jsx)(yi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>ut(e=>!e),disabled:at,"aria-pressed":et===`not_helpful`,children:[(0,Z.jsx)(H,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),P.chat.messageNotHelpful]})})]}):null,st?(0,Z.jsx)(`p`,{className:`px-2.5 py-1 text-xs text-danger`,role:`status`,children:P.chat.messageFeedbackUnavailable}):null,pt.length>0?(0,Z.jsx)(yi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>gt(e=>!e),children:[(0,Z.jsx)(es,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),P.chat.messageWhyThisAnswer]})}):null,S?(0,Z.jsx)(yi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-40`,onClick:Nt,disabled:!Re||Xe!==null,children:[qe===`save-source-note`?(0,Z.jsx)(ee,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(Ee,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),qe===`save-source-note`?P.chat.messageSavedToSourceNote:P.chat.messageSaveToSourceNote]})}):null,C?(0,Z.jsx)(yi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-40`,onClick:Pt,disabled:!ze&&!Re||Xe!==null,children:[qe===`extract-task`?(0,Z.jsx)(ee,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(Ye,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),qe===`extract-task`?P.chat.messageTaskExtracted:P.chat.messageExtractTask]})}):null]})})]})]})}):null,Ie&&pt.length>0?(0,Z.jsx)(Kv,{open:ht,onOpenChange:gt,items:pt,labels:{title:P.chat.messageWhyThisAnswer,hint:P.chat.messageWhyThisAnswerHint,close:P.chat.messageContextClose,itemsSummary:P.chat.messageContextItemsSummary,expandAll:P.chat.messageContextExpandAll,collapseAll:P.chat.messageContextCollapseAll,groupSummary:P.chat.messageContextGroupSummary,origins:P.chat.messageContextOrigins}}):null,Ie&&lt?(0,Z.jsxs)(`div`,{className:`mt-2 w-full max-w-xl rounded-xl border border-edge-subtle bg-surface-panel p-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:P.chat.messageFeedbackReasonTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:P.chat.messageFeedbackReasonHint}),(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:Qv.map(e=>(0,Z.jsx)(`button`,{type:`button`,className:`rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,disabled:at,onClick:()=>Lt(`not_helpful`,e),children:P.chat.messageFeedbackReasons[e]},e))})]}):null,Ie&&et===`not_helpful`&&dt?(0,Z.jsxs)(`button`,{type:`button`,className:`mt-2 inline-flex w-fit items-center gap-1.5 rounded-lg bg-accent-soft px-3 py-1.5 text-xs font-medium text-accent-fg hover:bg-accent-soft/80`,onClick:Rt,children:[(0,Z.jsx)(Mt,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),P.chat.messageFeedbackRepair]}):null]}),V&&m&&f!=null&&!T?(0,Z.jsx)(Na,{open:_t,title:P.chat.userMessageDeleteConfirmTitle,description:P.chat.userMessageDeleteConfirm,confirmLabel:P.chat.userMessageDeleteOk,cancelLabel:P.chat.userMessageDeleteCancel,destructive:!0,onConfirm:Vt,onCancel:Ut}):null,(0,Z.jsx)(Qr,{open:yt!==null,attachment:yt,images:(M.content??[]).flatMap((e,t)=>{if(e.type!==`image`)return[];let n=vm(e,t);return n?[n]:[]}),onAttachmentChange:bt,authToken:r,conversationId:i,onClose:()=>bt(null)})]})})}),ry=(0,Q.memo)(function(e){let t=(0,X.c)(3),n=Pm(e.conversationId,e.message.renderKey)??e.message,r;return t[0]!==n||t[1]!==e?(r=(0,Z.jsx)(ny,{...e,message:n}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r});function iy(e,t){return e.renderKey??`${e.timestamp??`n`}-${t}`}var ay=new Map;function oy(e,t=`time`){let n=`${e??`default`}:${t}`,r=ay.get(n);return r||(r=new Intl.DateTimeFormat(e===`zh`?`zh-CN`:e,t===`time`?{hour:`2-digit`,minute:`2-digit`}:{month:`short`,day:`numeric`,year:t===`year`?`numeric`:void 0}),ay.set(n,r)),r}function sy(e){return e?oy().format(e):``}var cy=1800*1e3;function ly(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function uy(e,t){return e?!t||!ly(new Date(e),new Date(t))||e-t>=cy:!1}function dy(e,t,n){let r=new Date(e),i=new Date(t),a=new Date(i);return a.setDate(i.getDate()-1),`${ly(r,i)?n===`zh`?`今天`:`Today`:ly(r,a)?n===`zh`?`昨天`:`Yesterday`:oy(n,r.getFullYear()===i.getFullYear()?`date`:`year`).format(r)} ${oy(n).format(r)}`}var fy=0,py=1,my=2,hy=4;function gy(e){return()=>e}function _y(e){e()}function vy(e,t){return n=>e(t(n))}function yy(e,t){return()=>e(t)}function by(e,t){return n=>e(t,n)}function xy(e){return e!==void 0}function Sy(...e){return()=>{e.map(_y)}}function Cy(){}function wy(e,t){return t(e),e}function Ty(e,t){return t(e)}function Ey(...e){return e}function Dy(e,t){return e(py,t)}function Oy(e,t){e(fy,t)}function ky(e){e(my)}function Ay(e){return e(hy)}function jy(e,t){return Dy(e,by(t,fy))}function My(e,t){let n=e(py,e=>{n(),t(e)});return n}function Ny(e){let t,n;return r=>i=>{t=i,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Py(e,t){return e===t}function Fy(e=Py){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Iy(e){return t=>n=>{e(n)&&t(n)}}function Ly(e){return t=>vy(t,e)}function Ry(e){return t=>()=>{t(e)}}function $(e,...t){let n=Uy(...t);return((t,r)=>{switch(t){case my:ky(e);return;case py:return Dy(e,n(r))}})}function zy(e,t){return n=>r=>{n(t=e(t,r))}}function By(e){return t=>n=>{e>0?e--:t(n)}}function Vy(e){let t=null,n;return r=>i=>{t=i,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Hy(...e){let t=Array.from({length:e.length}),n=0,r=null,i=2**e.length-1;return e.forEach((e,a)=>{let o=2**a;Dy(e,e=>{let s=n;n|=o,t[a]=e,s!==i&&n===i&&r&&(r(),r=null)})}),e=>a=>{let o=()=>{e([a].concat(t))};n===i?o():r=o}}function Uy(...e){return t=>e.reduceRight(Ty,t)}function Wy(e){let t,n,r=()=>t?.();return function(i,a){switch(i){case py:return a?n===a?void 0:(r(),n=a,t=Dy(e,a),t):(r(),Cy);case my:r(),n=null;return}}}function Gy(e){let t=e,n=qy();return((e,r)=>{switch(e){case fy:t=r;break;case py:r(t);break;case hy:return t}return n(e,r)})}function Ky(e,t){return wy(Gy(t),t=>jy(e,t))}function qy(){let e=[];return((t,n)=>{switch(t){case fy:e.slice().forEach(e=>{e(n)});return;case my:e.splice(0);return;case py:return e.push(n),()=>{let t=e.indexOf(n);t>-1&&e.splice(t,1)}}})}function Jy(e){return wy(qy(),t=>jy(e,t))}var Yy={singleton:!0};function Xy(e,t=[],n=Yy){let{singleton:r}=n;return{constructor:e,dependencies:t,id:Zy(),singleton:r}}var Zy=()=>Symbol(`id`);function Qy(e){let t=new Map,n=({constructor:e,dependencies:r,id:i,singleton:a})=>{if(a&&t.has(i))return t.get(i);let o=e(r.map(e=>n(e)));return a&&t.set(i,o),o};return n(e)}function $y(...e){let t=qy(),n=Array.from({length:e.length}),r=0,i=2**e.length-1;return e.forEach((e,a)=>{let o=2**a;Dy(e,e=>{n[a]=e,r|=o,r===i&&Oy(t,n)})}),function(e,a){switch(e){case my:ky(t);return;case py:return r===i&&a(n),Dy(t,a)}}}function eb(e,t=Py){return $(e,Fy(t))}function tb(...e){return function(t,n){switch(t){case my:return;case py:return Sy(...e.map(e=>Dy(e,n)))}}}var nb={DEBUG:0,INFO:1,WARN:2,ERROR:3},rb={[nb.DEBUG]:`debug`,[nb.ERROR]:`error`,[nb.INFO]:`log`,[nb.WARN]:`warn`},ib=()=>typeof globalThis>`u`?window:globalThis,ab=Xy(()=>{let e=Gy(nb.ERROR);return{log:Gy((t,n,r=nb.INFO)=>{r>=(ib().VIRTUOSO_LOG_LEVEL??Ay(e))&&console[rb[r]](`%creact-virtuoso: %c%s %o`,`color: #0253b3; font-weight: bold`,`color: initial`,t,n)}),logLevel:e}},[],{singleton:!0});function ob(e){return`self`in e?e.document.documentElement:e}function sb(e){let t=ob(e);return t.ownerDocument.defaultView.getComputedStyle(t).direction===`rtl`}function cb(e,t){return sb(e)?-t:t}function lb(e,t){return sb(e)?-t:t}function ub(e,t,n){return db(e,t,n).callbackRef}function db(e,t,n){let r=Q.useRef(null),i=e=>{},a=Q.useMemo(()=>typeof ResizeObserver<`u`?new ResizeObserver(t=>{let r=()=>{let n=t[0].target;n.offsetParent!==null&&e(n)};n?r():requestAnimationFrame(r)}):null,[e,n]);return i=e=>{e&&t?(a?.observe(e),r.current=e):(r.current&&a?.unobserve(r.current),r.current=null)},{callbackRef:i,ref:r}}function fb(e,t,n,r,i,a,o,s,c){return db(Q.useCallback(n=>{let c=pb(n.children,t,s?`offsetWidth`:`offsetHeight`,i),l=n.parentElement;for(;l.dataset.virtuosoScroller===void 0;)l=l.parentElement;let u=l.lastElementChild?.dataset.viewportType===`window`,d;u&&(d=l.ownerDocument.defaultView);let f=o?s?o.scrollWidth:o.scrollHeight:u?s?d.document.documentElement.scrollWidth:d.document.documentElement.scrollHeight:s?l.scrollWidth:l.scrollHeight,p=o?s?o.offsetWidth:o.offsetHeight:u?s?d.innerWidth:d.innerHeight:s?l.offsetWidth:l.offsetHeight,m=o?s?cb(o,o.scrollLeft):o.scrollTop:u?s?cb(d,d.scrollX||d.document.documentElement.scrollLeft):d.scrollY||d.document.documentElement.scrollTop:s?cb(l,l.scrollLeft):l.scrollTop;r({scrollHeight:f,scrollTop:Math.max(m,0),viewportHeight:p}),a?.(s?mb(`column-gap`,getComputedStyle(n).columnGap,i):mb(`row-gap`,getComputedStyle(n).rowGap,i)),c!==null&&e(c)},[e,t,i,a,o,r,s]),n,c)}function pb(e,t,n,r){let i=e.length;if(i===0)return null;let a=[];for(let o=0;o<i;o++){let i=e.item(o);if(i.dataset.index===void 0)continue;let s=parseInt(i.dataset.index,10),c=parseFloat(i.dataset.knownSize),l=t(i,n);if(l===0&&r(`Zero-sized element, this should not happen`,{child:i},nb.ERROR),l===c)continue;let u=a[a.length-1];a.length===0||u.size!==l||u.endIndex!==s-1?a.push({endIndex:s,size:l,startIndex:s}):a[a.length-1].endIndex++}return a}function mb(e,t,n){return t!==`normal`&&t?.endsWith(`px`)!==!0&&n(`${e} was not resolved to pixel value correctly`,t,nb.WARN),t===`normal`?0:parseInt(t??`0`,10)}var hb=typeof document>`u`?Q.useEffect:Q.useLayoutEffect;function gb(e,t,n){let r=Q.useRef(null),i=Q.useCallback(n=>{if(!n?.offsetParent)return;let i=n.getBoundingClientRect(),a=i.width,s,c;if(t){let e=t.getBoundingClientRect(),n=i.top-e.top;c=e.height-Math.max(0,n),s=n+t.scrollTop}else{let e=o.current.ownerDocument.defaultView;c=e.innerHeight-Math.max(0,i.top),s=i.top+e.scrollY}r.current={listHeight:i.height,offsetTop:s,visibleHeight:c,visibleWidth:a},e(r.current)},[e,t]),{callbackRef:a,ref:o}=db(i,!0,n),s=Q.useCallback(()=>{i(o.current)},[i,o]);return Q.useEffect(()=>{if(t){t.addEventListener(`scroll`,s);let e=new ResizeObserver(()=>{requestAnimationFrame(s)});return e.observe(t),()=>{t.removeEventListener(`scroll`,s),e.unobserve(t)}}let e=o.current?.ownerDocument.defaultView;return e?.addEventListener(`scroll`,s),e?.addEventListener(`resize`,s),()=>{e?.removeEventListener(`scroll`,s),e?.removeEventListener(`resize`,s)}},[s,t,o]),a}var _b=Xy(()=>{let e=qy(),t=qy(),n=Gy(0),r=qy(),i=qy(),a=Gy(0),o=qy(),s=qy(),c=Gy(0),l=Gy(0),u=Gy(0),d=Gy(0),f=qy(),p=qy(),m=Gy(!1),h=Gy(!1),g=Gy(!1);return jy($(e,Ly(({scrollTop:e})=>e)),t),jy($(e,Ly(({scrollHeight:e})=>e)),s),jy(t,a),{deviation:n,deviationCommitted:r,fixedFooterHeight:u,fixedHeaderHeight:l,footerHeight:d,headerHeight:c,horizontalDirection:h,scrollBy:p,scrollContainerState:e,scrollHeight:s,scrollingInProgress:m,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:i,statefulScrollTop:a,viewportHeight:o}},[],{singleton:!0}),vb={lvl:0};function yb(e,t){let n=e.length;if(n===0)return[];let{index:r,value:i}=t(e[0]),a=[];for(let o=1;o<n;o++){let{index:n,value:s}=t(e[o]);a.push({end:n-1,start:r,value:i}),r=n,i=s}return a.push({end:1/0,start:r,value:i}),a}function bb(e){return e===vb}function xb(e,t){if(!bb(e))return t===e.k?e.v:t<e.k?xb(e.l,t):xb(e.r,t)}function Sb(e,t,n=`k`){if(bb(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){let r=Sb(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return Sb(e.l,t,n)}function Cb(e,t,n){return bb(e)?Pb(t,n,1):t===e.k?Ab(e,{k:t,v:n}):t<e.k?Fb(Ab(e,{l:Cb(e.l,t,n)})):Fb(Ab(e,{r:Cb(e.r,t,n)}))}function wb(){return vb}function Tb(e,t,n){if(bb(e))return[];let r=Sb(e,t)[0];return Rb(Ob(e,r,n))}function Eb(e,t){if(bb(e))return vb;let{k:n,l:r,r:i}=e;if(t===n){if(bb(r))return i;if(bb(i))return r;let[t,n]=Nb(r);return kb(Ab(e,{k:t,l:jb(r),v:n}))}return kb(t<n?Ab(e,{l:Eb(r,t)}):Ab(e,{r:Eb(i,t)}))}function Db(e){return bb(e)?[]:[...Db(e.l),{k:e.k,v:e.v},...Db(e.r)]}function Ob(e,t,n){if(bb(e))return[];let{k:r,l:i,r:a,v:o}=e,s=[];return r>t&&(s=s.concat(Ob(i,t,n))),r>=t&&r<=n&&s.push({k:r,v:o}),r<=n&&(s=s.concat(Ob(a,t,n))),s}function kb(e){let{l:t,lvl:n,r}=e;if(r.lvl>=n-1&&t.lvl>=n-1)return e;if(n>r.lvl+1){if(Mb(t))return Ib(Ab(e,{lvl:n-1}));if(!bb(t)&&!bb(t.r))return Ab(t.r,{l:Ab(t,{r:t.r.l}),lvl:n,r:Ab(e,{l:t.r.r,lvl:n-1})});throw Error(`Unexpected empty nodes`)}if(Mb(e))return Lb(Ab(e,{lvl:n-1}));if(!bb(r)&&!bb(r.l)){let t=r.l,i=Mb(t)?r.lvl-1:r.lvl;return Ab(t,{l:Ab(e,{lvl:n-1,r:t.l}),lvl:t.lvl+1,r:Lb(Ab(r,{l:t.r,lvl:i}))})}throw Error(`Unexpected empty nodes`)}function Ab(e,t){return Pb(t.k===void 0?e.k:t.k,t.v===void 0?e.v:t.v,t.lvl===void 0?e.lvl:t.lvl,t.l===void 0?e.l:t.l,t.r===void 0?e.r:t.r)}function jb(e){return bb(e.r)?e.l:kb(Ab(e,{r:jb(e.r)}))}function Mb(e){return bb(e)||e.lvl>e.r.lvl}function Nb(e){return bb(e.r)?[e.k,e.v]:Nb(e.r)}function Pb(e,t,n,r=vb,i=vb){return{k:e,l:r,lvl:n,r:i,v:t}}function Fb(e){return Lb(Ib(e))}function Ib(e){let{l:t}=e;return!bb(t)&&t.lvl===e.lvl?Ab(t,{r:Ab(e,{l:t.r})}):e}function Lb(e){let{lvl:t,r:n}=e;return!bb(n)&&!bb(n.r)&&n.lvl===t&&n.r.lvl===t?Ab(n,{l:Ab(e,{r:n.l}),lvl:t+1}):e}function Rb(e){return yb(e,({k:e,v:t})=>({index:e,value:t}))}function zb(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Bb(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}var Vb=Xy(()=>({recalcInProgress:Gy(!1)}),[],{singleton:!0});function Hb(e,t,n){return e[Ub(e,t,n)]}function Ub(e,t,n,r=0){let i=e.length-1;for(;r<=i;){let a=Math.floor((r+i)/2),o=e[a],s=n(o,t);if(s===0)return a;if(s===-1){if(i-r<2)return a-1;i=a-1}else{if(i===r)return a;r=a+1}}throw Error(`Failed binary finding record in array - ${e.join(`,`)}, searched for ${t}`)}function Wb(e,t,n,r){let i=Ub(e,t,r),a=Ub(e,n,r,i);return e.slice(i,a+1)}function Gb(e,t){return Math.round(e.getBoundingClientRect()[t])}function Kb(e){return!bb(e.groupOffsetTree)}function qb({index:e},t){return t===e?0:t<e?-1:1}function Jb(){return{groupIndices:[],groupOffsetTree:wb(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:wb()}}function Yb(e,t){let n=bb(e)?0:1/0;for(let r of t){let{endIndex:t,size:i,startIndex:a}=r;if(n=Math.min(n,a),bb(e)){e=Cb(e,0,i);continue}let o=Tb(e,a-1,t+1);if(o.some(sx(r)))continue;let s=!1,c=!1;for(let{end:n,start:r,value:a}of o)s?(t>=r||i===a)&&(e=Eb(e,r)):(c=a!==i,s=!0),n>t&&t>=r&&a!==i&&(e=Cb(e,t+1,a));c&&(e=Cb(e,a,i))}return[e,n]}function Xb(e){return e.groupIndex!==void 0}function Zb({offset:e},t){return t===e?0:t<e?-1:1}function Qb(e,t,n){if(t.length===0)return 0;let{index:r,offset:i,size:a}=Hb(t,e,qb),o=e-r,s=a*o+(o-1)*n+i;return s>0?s+n:s}function $b(e,t){if(!Kb(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function ex(e,t,n){if(Xb(e))return t.groupIndices[e.groupIndex]+1;let r=$b(e.index===`LAST`?n:e.index,t);return r=Math.max(0,Math.min(n,r)),r}function tx(e,t,n,r=0){return r>0&&(t=Math.max(t,Hb(e,r,qb).offset)),yb(Wb(e,t,n,Zb),ox)}function nx(e,[t,n,r,i]){t.length>0&&r(`received item sizes`,t,nb.DEBUG);let a=e.sizeTree,o=a,s=0;if(n.length>0&&bb(a)&&t.length===2){let e=t[0].size,r=t[1].size;o=n.reduce((t,n)=>Cb(Cb(t,n,e),n+1,r),o)}else[o,s]=Yb(o,t);if(o===a)return e;let{lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d}=ax(e.offsetTree,s,o,i);return{groupIndices:n,groupOffsetTree:n.reduce((e,t)=>Cb(e,t,Qb(t,d,i)),wb()),lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d,sizeTree:o}}function rx(e){return Db(e).map(({k:e,v:t},n,r)=>{let i=r[n+1];return{endIndex:i===void 0?1/0:i.k-1,size:t,startIndex:e}})}function ix(e,t){let n=0,r=0;for(;n<e;)n+=t[r+1]-t[r]-1,r++;return r-(n===e?0:1)}function ax(e,t,n,r){let i=e,a=0,o=0,s=0,c=0;if(t===0)i=[];else{c=Ub(i,t-1,qb),s=i[c].offset;let e=Sb(n,t-1);a=e[0],o=e[1],i.length&&i[c].size===Sb(n,t)[1]&&--c,i=i.slice(0,c+1)}for(let{start:e,value:c}of Tb(n,t,1/0)){let t=e-a,n=t*o+s+t*r;i.push({index:e,offset:n,size:c}),a=e,s=n,o=c}return{lastIndex:a,lastOffset:s,lastSize:o,offsetTree:i}}function ox(e){return{index:e.index,value:e}}function sx(e){let{endIndex:t,size:n,startIndex:r}=e;return e=>e.start===r&&(e.end===t||e.end===1/0)&&e.value===n}var cx={offsetHeight:`height`,offsetWidth:`width`},lx=Xy(([{log:e},{recalcInProgress:t}])=>{let n=qy(),r=qy(),i=Ky(r,0),a=qy(),o=qy(),s=Gy(0),c=Gy([]),l=Gy(void 0),u=Gy(void 0),d=Gy(void 0),f=Gy(void 0),p=Gy((e,t)=>Gb(e,cx[t])),m=Gy(void 0),h=Gy(0),g=Jb(),_=Ky($(n,Hy(c,e,h),zy(nx,g),Fy()),g),v=Ky($(c,Fy(),zy((e,t)=>({current:t,prev:e.current}),{current:[],prev:[]}),Ly(({prev:e})=>e)),[]);jy($(c,Iy(e=>e.length>0),Hy(_,h),Ly(([e,t,n])=>{let r=e.reduce((e,r,i)=>Cb(e,r,Qb(r,t.offsetTree,n)||i),wb());return{...t,groupIndices:e,groupOffsetTree:r}})),_),jy($(r,Hy(_),Iy(([e,{lastIndex:t}])=>e<t),Ly(([e,{lastIndex:t,lastSize:n}])=>[{endIndex:t,size:n,startIndex:e}])),n),jy(l,u);let y=Ky($(l,Ly(e=>e===void 0)),!0);jy($(u,Iy(e=>e!==void 0&&bb(Ay(_).sizeTree)),Ly(e=>{let t=Ay(d),n=Ay(c).length>0;return t!==void 0&&t!==0?n?[{endIndex:0,size:t,startIndex:0},{endIndex:1,size:e,startIndex:1}]:[]:[{endIndex:0,size:e,startIndex:0}]})),n),jy($(f,Iy(e=>e!==void 0&&e.length>0&&bb(Ay(_).sizeTree)),Ly(e=>{let t=[],n=e[0],r=0;for(let i=1;i<e.length;i++){let a=e[i];a!==n&&(t.push({endIndex:i-1,size:n,startIndex:r}),n=a,r=i)}return t.push({endIndex:e.length-1,size:n,startIndex:r}),t})),n),jy($(c,Hy(d,u),Iy(([,e,t])=>e!==void 0&&t!==void 0),Ly(([e,t,n])=>{let r=[];for(let i=0;i<e.length;i++){let a=e[i],o=e[i+1];r.push({startIndex:a,endIndex:a,size:t}),o!==void 0&&r.push({startIndex:a+1,endIndex:o-1,size:n})}return r})),n);let b=Jy($(n,Hy(_),zy(({sizes:e},[t,n])=>({changed:n!==e,sizes:n}),{changed:!1,sizes:g}),Ly(e=>e.changed)));Dy($(s,zy((e,t)=>({diff:e.prev-t,prev:t}),{diff:0,prev:0}),Ly(e=>e.diff)),e=>{let{groupIndices:n}=Ay(_);if(e>0)Oy(t,!0),Oy(a,e+ix(e,n));else if(e<0){let t=Ay(v);t.length>0&&(e-=ix(-e,t)),Oy(o,e)}}),Dy($(s,Hy(e)),([e,t])=>{e<0&&t("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:s},nb.ERROR)});let x=Jy(a);jy($(a,Hy(_),Ly(([e,t])=>{let n=t.groupIndices.length>0,r=[],i=t.lastSize;if(n){let n=xb(t.sizeTree,0),a=0,o=0;for(;a<e;){let e=t.groupIndices[o],s=t.groupIndices.length===o+1?1/0:t.groupIndices[o+1]-e-1;r.push({endIndex:e,size:n,startIndex:e}),r.push({endIndex:e+1+s-1,size:i,startIndex:e+1}),o++,a+=s+1}let s=Db(t.sizeTree);return a!==e&&s.shift(),s.reduce((t,{k:n,v:r})=>{let i=t.ranges;return t.prevSize!==0&&(i=[...t.ranges,{endIndex:n+e-1,size:t.prevSize,startIndex:t.prevIndex}]),{prevIndex:n+e,prevSize:r,ranges:i}},{prevIndex:e,prevSize:0,ranges:r}).ranges}return Db(t.sizeTree).reduce((t,{k:n,v:r})=>({prevIndex:n+e,prevSize:r,ranges:[...t.ranges,{endIndex:n+e-1,size:t.prevSize,startIndex:t.prevIndex}]}),{prevIndex:0,prevSize:i,ranges:[]}).ranges})),n);let S=Jy($(o,Hy(_,h),Ly(([e,{offsetTree:t},n])=>Qb(-e,t,n))));return jy($(o,Hy(_,h),Ly(([e,t,n])=>{if(t.groupIndices.length>0){if(bb(t.sizeTree))return t;let r=wb(),i=Ay(v),a=0,o=0,s=0;for(;a<-e;){s=i[o];let e=i[o+1]-s-1;o++,a+=e+1}if(r=Db(t.sizeTree).reduce((t,{k:n,v:r})=>Cb(t,Math.max(0,n+e),r),r),a!==-e){let n=xb(t.sizeTree,s);r=Cb(r,0,n);let i=Sb(t.sizeTree,-e+1)[1];r=Cb(r,1,i)}return{...t,sizeTree:r,...ax(t.offsetTree,0,r,n)}}let r=Db(t.sizeTree).reduce((t,{k:n,v:r})=>Cb(t,Math.max(0,n+e),r),wb());return{...t,sizeTree:r,...ax(t.offsetTree,0,r,n)}})),_),{beforeUnshiftWith:x,data:m,defaultItemSize:u,firstItemIndex:s,fixedItemSize:l,fixedGroupSize:d,gap:h,groupIndices:c,heightEstimates:f,itemSize:p,listRefresh:b,shiftWith:o,shiftWithOffset:S,sizeRanges:n,sizes:_,statefulTotalCount:i,totalCount:r,trackItemSizes:y,unshiftWith:a}},Ey(ab,Vb),{singleton:!0});function ux(e){return e.reduce((e,t)=>(e.groupIndices.push(e.totalCount),e.totalCount+=t+1,e),{groupIndices:[],totalCount:0})}var dx=Xy(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:i}])=>{let a=qy(),o=qy(),s=Jy($(a,Ly(ux)));return jy($(s,Ly(e=>e.totalCount)),n),jy($(s,Ly(e=>e.groupIndices)),e),jy($($y(i,t,r),Iy(([e,t])=>Kb(t)),Ly(([e,t,n])=>Sb(t.groupOffsetTree,Math.max(e-n,0),`v`)[0]),Fy(),Ly(e=>[e])),o),{groupCounts:a,topItemsIndexes:o}},Ey(lx,_b)),fx=Xy(([{log:e}])=>{let t=Gy(!1),n=Jy($(t,Iy(e=>e),Fy()));return Dy(t,t=>{t&&Ay(e)(`props updated`,{},nb.DEBUG)}),{didMount:n,propsReady:t}},Ey(ab),{singleton:!0}),px=typeof document<`u`&&`scrollBehavior`in document.documentElement.style;function mx(e){let t=typeof e==`number`?{index:e}:{...e};return t.align||=`start`,(!t.behavior||!px)&&(t.behavior=`auto`),t.offset===void 0&&(t.offset=0),t}var hx=Xy(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:i,fixedHeaderHeight:a,footerHeight:o,headerHeight:s,scrollingInProgress:c,scrollTo:l,smoothScrollTargetReached:u,viewportHeight:d},{log:f}])=>{let p=qy(),m=qy(),h=Gy(0),g=null,_=null,v=null;function y(){g!==null&&(g(),g=null),v!==null&&(v(),v=null),_&&=(clearTimeout(_),null),Oy(c,!1)}return jy($(p,Hy(n,d,r,h,s,o,f),Hy(e,a,i),Ly(([[e,n,r,i,a,o,s,l],d,f,h])=>{let b=mx(e),{align:x,behavior:S,offset:C}=b,w=i-1,T=ex(b,n,w),E=Qb(T,n.offsetTree,d)+o;x===`end`?(E+=f+Sb(n.sizeTree,T)[1]-r+h,T===w&&(E+=s)):x===`center`?E+=(f+Sb(n.sizeTree,T)[1]-r+h)/2:E-=a,C!==void 0&&C!==0&&(E+=C);let D=t=>{y(),t?(l(`retrying to scroll to`,{location:e},nb.DEBUG),Oy(p,e)):(Oy(m,!0),l(`list did not change, scroll successful`,{},nb.DEBUG))};if(y(),S===`smooth`){let e=!1;v=Dy(t,t=>{e||=t}),g=My(u,()=>{D(e)})}else g=My($(t,gx(150)),D);return _=setTimeout(()=>{y()},1200),Oy(c,!0),l(`scrolling from index to`,{behavior:S,index:T,top:E},nb.DEBUG),{behavior:S,top:E}})),l),{scrollTargetReached:m,scrollToIndex:p,topListHeight:h}},Ey(lx,_b,ab),{singleton:!0});function gx(e){return t=>{let n=setTimeout(()=>{t(!1)},e);return e=>{e&&(t(!0),clearTimeout(n))}}}function _x(e,t){e===0?t():requestAnimationFrame(()=>{_x(e-1,t)})}function vx(e,t){if(e===void 0)return 0;let n=t-1,r=typeof e==`number`?e:e.index===`LAST`?n:e.index;return Math.max(0,Math.min(r,n))}function yx(e){return e===void 0?!0:typeof e==`number`?e===0:e.index===0&&(e.align===void 0||e.align===`start`)&&(e.offset===void 0||e.offset===0)}var bx=Xy(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:i,scrollToIndex:a},{didMount:o}])=>{let s=Gy(!0),c=Gy(0),l=Gy(!0);return jy($(o,Hy(c),Iy(([e,t])=>!yx(t)),Ry(!1)),s),jy($(o,Hy(c),Iy(([e,t])=>!yx(t)),Ry(!1)),l),Dy($($y(t,o),Hy(s,n,e,l),Iy(([[,e],t,{sizeTree:n},r,i])=>e&&(!bb(n)||xy(r))&&!t&&!i),Hy(c)),([,e])=>{if(e===void 0){Oy(s,!0),Oy(l,!0);return}My(i,()=>{Oy(l,!0)}),_x(4,()=>{My(r,()=>{Oy(s,!0)}),Oy(a,e)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:c,scrolledToInitialItem:s}},Ey(lx,_b,hx,fx),{singleton:!0});function xx(e,t){return Math.abs(e-t)<1.01}var Sx=`up`,Cx=`down`,wx=`none`,Tx={atBottom:!1,notAtBottomBecause:`NOT_SHOWING_LAST_ITEM`,state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Ex=0,Dx=Xy(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:i,viewportHeight:a}])=>{let o=Gy(!1),s=Gy(!0),c=qy(),l=qy(),u=Gy(4),d=Gy(Ex),f=Ky($(tb($(eb(i),By(1),Ry(!0)),$(eb(i),By(1),Ry(!1),Ny(100))),Fy()),!1),p=Ky($(tb($(n,Ry(!0)),$(n,Ry(!1),Ny(200))),Fy()),!1);jy($($y(eb(i),eb(d)),Ly(([e,t])=>e<=t),Fy()),s),jy($(s,Vy(50)),l);let m=Jy($($y(r,eb(a),eb(t),eb(e),eb(u)),zy((e,[{scrollHeight:t,scrollTop:n},r,i,a,o])=>{let s=n+r-t>-o,c={scrollHeight:t,scrollTop:n,viewportHeight:r};if(s){let t,r;return n>e.state.scrollTop?(t=`SCROLLED_DOWN`,r=e.state.scrollTop-n):(t=`SIZE_DECREASED`,r=e.state.scrollTop-n||e.scrollTopDelta),{atBottom:!0,atBottomBecause:t,scrollTopDelta:r,state:c}}let l;return l=c.scrollHeight>e.state.scrollHeight?`SIZE_INCREASED`:r<e.state.viewportHeight?`VIEWPORT_HEIGHT_DECREASING`:n<e.state.scrollTop?`SCROLLING_UPWARDS`:`NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM`,{atBottom:!1,notAtBottomBecause:l,state:c}},Tx),Fy((e,t)=>e!==void 0&&e.atBottom===t.atBottom))),h=Ky($(r,zy((e,{scrollHeight:t,scrollTop:n,viewportHeight:r})=>{if(!xx(e.scrollHeight,t)){let i=t-(n+r)<1;return e.scrollTop!==n&&i?{changed:!0,jump:e.scrollTop-n,scrollHeight:t,scrollTop:n}:{changed:!0,jump:0,scrollHeight:t,scrollTop:n}}return{changed:!1,jump:0,scrollHeight:t,scrollTop:n}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Iy(e=>e.changed),Ly(e=>e.jump)),0);jy($(m,Ly(e=>e.atBottom)),o),jy($(o,Vy(50)),c);let g=Gy(Cx);jy($(r,Ly(({scrollTop:e})=>e),Fy(),zy((e,t)=>Ay(p)?{direction:e.direction,prevScrollTop:t}:{direction:t<e.prevScrollTop?Sx:Cx,prevScrollTop:t},{direction:Cx,prevScrollTop:0}),Ly(e=>e.direction)),g),jy($(r,Vy(50),Ry(wx)),g);let _=Gy(0);return jy($(f,Iy(e=>!e),Ry(0)),_),jy($(i,Vy(100),Hy(f),Iy(([e,t])=>t),zy(([e,t],[n])=>[t,n],[0,0]),Ly(([e,t])=>t-e)),_),{atBottomState:m,atBottomStateChange:c,atBottomThreshold:u,atTopStateChange:l,atTopThreshold:d,isAtBottom:o,isAtTop:s,isScrolling:f,lastJumpDueToItemResize:h,scrollDirection:g,scrollVelocity:_}},Ey(_b)),Ox=`top`,kx=`bottom`,Ax=`none`;function jx(e,t,n){return typeof e==`number`?n===Sx&&t===Ox||n===Cx&&t===kx?e:0:n===Sx?t===Ox?e.main:e.reverse:t===kx?e.main:e.reverse}function Mx(e,t){return typeof e==`number`?e:e[t]??0}var Nx=Xy(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:i}])=>{let a=qy(),o=Gy(0),s=Gy(0),c=Gy(0);return{increaseViewportBy:s,listBoundary:a,overscan:c,topListHeight:o,visibleRange:Ky($($y(eb(r),eb(i),eb(n),eb(a,Bb),eb(c),eb(o),eb(t),eb(e),eb(s)),Ly(([e,t,n,[r,i],a,o,s,c,l])=>{let u=e-c,d=o+s,f=Math.max(n-u,0),p=Ax,m=Mx(l,Ox),h=Mx(l,kx);return r-=c,r+=n+s,i+=n+s,i-=c,r>e+d-m&&(p=Sx),i<e-f+t+h&&(p=Cx),p===Ax?null:[Math.max(u-n-jx(a,Ox,p)-m,0),u-f-s+t+jx(a,kx,p)+h]}),Iy(e=>e!==null),Fy(Bb)),[0,0])}},Ey(_b),{singleton:!0});function Px(e,t,n){if(Kb(t)){let r=$b(e,t);return[{index:Sb(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n?.[0],index:r,offset:0,size:0}]}return[{data:n?.[0],index:e,offset:0,size:0}]}var Fx={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ix(e,t,n,r,i,a){let{lastIndex:o,lastOffset:s,lastSize:c}=i,l=0,u=0;if(e.length>0){l=e[0].offset;let t=e[e.length-1];u=t.offset+t.size}let d=n-o,f=s+d*c+(d-1)*r,p=l,m=f-u;return{bottom:u,firstItemIndex:a,items:Rx(e,i,a),offsetBottom:m,offsetTop:l,top:p,topItems:Rx(t,i,a),topListHeight:t.reduce((e,t)=>t.size+e,0),totalCount:n}}function Lx(e,t,n,r,i,a){let o=0;if(n.groupIndices.length>0)for(let t of n.groupIndices){if(t-o>=e)break;o++}let s=e+o,c=a!==void 0,l=a?.length??0,u=vx(t,c?l:s),d=c?Math.max(0,Math.min(s,l-u)):s;return Ix(Array.from({length:d}).map((e,t)=>({data:a?.[t+u],index:t+u,offset:0,size:0})),[],d,i,n,r)}function Rx(e,t,n){if(e.length===0)return[];if(!Kb(t))return e.map(e=>({...e,index:e.index+n,originalIndex:e.index}));let r=e[0].index,i=e[e.length-1].index,a=[],o=Tb(t.groupOffsetTree,r,i),s,c=0;for(let r of e){(!s||s.end<r.index)&&(s=o.shift(),c=t.groupIndices.indexOf(s.start));let e;e=r.index===s.start?{index:c,type:`group`}:{groupIndex:c,index:r.index-(c+1)+n},a.push({...e,data:r.data,offset:r.offset,originalIndex:r.index,size:r.size})}return a}function zx(e,t){return e===void 0?0:typeof e==`number`?e:e[t]??0}var Bx=Xy(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:i},a,{listBoundary:o,topListHeight:s,visibleRange:c},{initialTopMostItemIndex:l,scrolledToInitialItem:u},{topListHeight:d},f,{didMount:p},{recalcInProgress:m}])=>{let h=Gy([]),g=Gy(0),_=qy(),v=Gy(0);jy(a.topItemsIndexes,h);let y=Ky($($y(p,m,eb(c,Bb),eb(i),eb(r),eb(l),u,eb(h),eb(t),eb(n),eb(v),e,eb(g)),Iy(([e,t,,n,,,,,,,,r])=>{let i=r!==void 0&&r.length!==n;return e&&!t&&!i}),Ly(([,,[e,t],n,r,i,a,o,s,c,l,u,d])=>{let f=r,{offsetTree:p,sizeTree:m}=f;if(n===0)return{...Fx,totalCount:n};if(e===0&&t===0)return d===0?{...Fx,totalCount:n}:Lx(d,i,r,s,c,u);if(bb(m))return d>0?null:Ix(Px(vx(i,n),f,u),[],n,c,f,s);let h=[];if(o.length>0){let e=o[0],t=o[o.length-1],n=0;for(let r of Tb(m,e,t)){let i=r.value,a=Math.max(r.start,e),o=Math.min(r.end,t);for(let e=a;e<=o;e++)h.push({data:u?.[e],index:e,offset:n,size:i}),n+=i}}if(!a)return Ix([],h,n,c,f,s);let g=o.length>0?o[o.length-1]+1:0,_=tx(p,e,t,g);if(_.length===0)return null;let v=n-1,y=wy([],n=>{for(let r of _){let i=r.value,a=i.offset,o=r.start,s=i.size;if(i.offset<e){o+=Math.floor((e-i.offset+c)/(s+c));let t=o-r.start;a+=t*s+t*c}o<g&&(a+=(g-o)*s,o=g);let l=Math.min(r.end,v);for(let e=o;e<=l&&!(a>=t);e++)n.push({data:u?.[e],index:e,offset:a,size:s}),a+=s+c}}),b=zx(l,Ox),x=zx(l,kx);if(y.length>0&&(b>0||x>0)){let e=y[0],t=y[y.length-1];if(b>0&&e.index>g){let t=Math.min(b,e.index-g),n=[],r=e.offset;for(let i=e.index-1;i>=e.index-t;i--){let t=Tb(m,i,i)[0]?.value??e.size;r-=t+c,n.unshift({data:u?.[i],index:i,offset:r,size:t})}y.unshift(...n)}if(x>0&&t.index<v){let e=Math.min(x,v-t.index),n=t.offset+t.size+c;for(let r=t.index+1;r<=t.index+e;r++){let e=Tb(m,r,r)[0]?.value??t.size;y.push({data:u?.[r],index:r,offset:n,size:e}),n+=e+c}}}return Ix(y,h,n,c,f,s)}),Iy(e=>e!==null),Fy()),Fx);jy($(e,Iy(xy),Ly(e=>e?.length)),i),jy($(y,Ly(e=>e.topListHeight)),d),jy(d,s),jy($(y,Ly(e=>[e.top,e.bottom])),o),jy($(y,Ly(e=>e.items)),_);let b=Jy($(y,Iy(({items:e})=>e.length>0),Hy(i,e),Iy(([{items:e},t])=>e[e.length-1].originalIndex===t-1),Ly(([,e,t])=>[e-1,t]),Fy(Bb),Ly(([e])=>e))),x=Jy($(y,Vy(200),Iy(({items:e,topItems:t})=>e.length>0&&e[0].originalIndex===t.length),Ly(({items:e})=>e[0].index),Fy()));return{endReached:b,initialItemCount:g,itemsRendered:_,listState:y,minOverscanItemCount:v,rangeChanged:Jy($(y,Iy(({items:e})=>e.length>0),Ly(({items:e})=>{let t=0,n=e.length-1;for(;e[t].type===`group`&&t<n;)t++;for(;e[n].type===`group`&&n>t;)n--;return{endIndex:e[n].index,startIndex:e[t].index}}),Fy(zb))),startReached:x,topItemsIndexes:h,...f}},Ey(lx,dx,Nx,bx,hx,Dx,fx,Vb),{singleton:!0}),Vx=Xy(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:i}])=>{let a=qy(),o=Ky($($y(n,e,r,t,i),Ly(([e,t,n,r,i])=>e+t+n+r+i.offsetBottom+i.bottom)),0);return jy(eb(o),a),{totalListHeight:o,totalListHeightChanged:a}},Ey(_b,Bx),{singleton:!0}),Hx=Xy(([{viewportHeight:e},{totalListHeight:t}])=>{let n=Gy(!1);return{alignToBottom:n,paddingTopAddition:Ky($($y(n,e,t),Iy(([e])=>e),Ly(([,e,t])=>Math.max(0,e-t)),Vy(0),Fy()),0)}},Ey(_b,Vx),{singleton:!0}),Ux=Xy(()=>({context:Gy(null)})),Wx=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:r,...i},viewportBottom:a,viewportTop:o})=>t<o?{...i,align:n??`start`,...r===void 0?{}:{behavior:r}}:e>a?{...i,align:n??`end`,...r===void 0?{}:{behavior:r}}:null,Gx=Xy(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:i,headerHeight:a,scrollingInProgress:o,scrollTop:s,viewportHeight:c},{scrollToIndex:l}])=>{let u=qy();return jy($(u,Hy(t,c,n,a,i,r,s),Hy(e),Ly(([[e,t,n,r,i,a,s,c],l])=>{let{calculateViewLocation:u=Wx,done:d,...f}=e,p=ex(e,t,r-1),m=Qb(p,t.offsetTree,l)+i+a,h=m+Sb(t.sizeTree,p)[1],g=c+a,_=u({itemBottom:h,itemTop:m,locationParams:f,viewportBottom:c+n-s,viewportTop:g});return _===null?d?.():d&&My($(o,Iy(e=>!e),By(Ay(o)?1:2)),d),_}),Iy(e=>e!==null)),l),{scrollIntoView:u}},Ey(lx,_b,hx,Bx,ab),{singleton:!0});function Kx(e){return e===!1?!1:e===`smooth`?`smooth`:`auto`}var qx=(e,t)=>typeof e==`function`?Kx(e(t)):t&&Kx(e),Jx=Xy(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:i,isAtBottom:a},{scrollToIndex:o},{scrolledToInitialItem:s},{didMount:c,propsReady:l},{log:u},{scrollingInProgress:d},{context:f},{scrollIntoView:p}])=>{let m=Gy(!1),h=qy(),g=null;function _(e){Oy(o,{align:`end`,behavior:e,index:`LAST`})}Dy($($y($(eb(t),By(1)),c),Hy(eb(m),a,s,d),Ly(([[e,t],n,r,i,a])=>{let o=t&&i,s=`auto`;return o&&(s=qx(n,r||a),o&&=s!==!1),{followOutputBehavior:s,shouldFollow:o,totalCount:e}}),Iy(({shouldFollow:e})=>e)),({followOutputBehavior:t,totalCount:r})=>{g!==null&&(g(),g=null),Ay(n)===void 0?g=My(e,()=>{Ay(u)(`following output to `,{totalCount:r},nb.DEBUG),_(t),g=null}):requestAnimationFrame(()=>{Ay(u)(`following output to `,{totalCount:r},nb.DEBUG),_(t)})});function v(e){let t=My(i,t=>{e&&!t.atBottom&&t.notAtBottomBecause===`SIZE_INCREASED`&&g===null&&(Ay(u)(`scrolling to bottom due to increased size`,{},nb.DEBUG),_(`auto`))});setTimeout(t,100)}Dy($($y(eb(m),t,l),Iy(([e,,t])=>e!==!1&&t),zy(({value:e},[,t])=>({refreshed:e===t,value:t}),{refreshed:!1,value:0}),Iy(({refreshed:e})=>e),Hy(m,t)),([,e])=>{Ay(s)&&v(e!==!1)}),Dy(h,()=>{v(Ay(m)!==!1)}),Dy($y(eb(m),i),([e,t])=>{e!==!1&&!t.atBottom&&t.notAtBottomBecause===`VIEWPORT_HEIGHT_DECREASING`&&_(`auto`)});let y=Gy(null),b=qy();return jy(tb($(eb(r),Ly(e=>e?.length??0)),$(eb(t))),b),Dy($($y($(b,By(1)),c),Hy(eb(y),s,d,f),Ly(([[e,t],n,r,i,a])=>t&&r&&n?.({context:a,totalCount:e,scrollingInProgress:i})),Iy(e=>!!e),Vy(0)),t=>{g!==null&&(g(),g=null),Ay(n)===void 0?g=My(e,()=>{Ay(u)(`scrolling into view`,{}),Oy(p,t),g=null}):requestAnimationFrame(()=>{Ay(u)(`scrolling into view`,{}),Oy(p,t)})}),{autoscrollToBottom:h,followOutput:m,scrollIntoViewOnChange:y}},Ey(lx,Dx,hx,bx,fx,ab,_b,Ux,Gx)),Yx=Xy(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:i},{initialItemCount:a,listState:o},{didMount:s}])=>(jy($(s,Hy(a),Iy(([,e])=>e!==0),Hy(i,r,t,n,e),Ly(([[,e],t,n,r,i,a])=>Lx(e,t,n,r,i,a))),o),{}),Ey(lx,bx,Bx,fx),{singleton:!0}),Xx=Xy(([{didMount:e},{scrollTo:t},{listState:n}])=>{let r=Gy(0);return Dy($(e,Hy(r),Iy(([,e])=>e!==0),Ly(([,e])=>({top:e}))),e=>{My($(n,By(1),Iy(e=>e.items.length>1)),()=>{requestAnimationFrame(()=>{Oy(t,e)})})}),{initialScrollTop:r}},Ey(fx,_b,Bx),{singleton:!0}),Zx=Xy(([{scrollVelocity:e}])=>{let t=Gy(!1),n=qy(),r=Gy(!1);return jy($(e,Hy(r,t,n),Iy(([e,t])=>t!==!1&&t!==void 0),Ly(([e,t,n,r])=>{let{enter:i,exit:a}=t;if(n){if(a(e,r))return!1}else if(i(e,r))return!0;return n}),Fy()),t),Dy($($y(t,e,n),Hy(r)),([[e,t,n],r])=>{e&&r!==!1&&r!==void 0&&r.change&&r.change(t,n)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},Ey(Dx),{singleton:!0}),Qx=Xy(([{scrollContainerState:e,scrollTo:t}])=>{let n=qy(),r=qy(),i=qy(),a=Gy(!1),o=Gy(void 0);return jy($($y(n,r),Ly(([{scrollTop:e,viewportHeight:t},{offsetTop:n,listHeight:r}])=>({scrollHeight:r,scrollTop:Math.max(0,e-n),viewportHeight:t}))),e),jy($(t,Hy(r),Ly(([e,{offsetTop:t}])=>({...e,top:e.top+t}))),i),{customScrollParent:o,useWindowScroll:a,windowScrollContainerState:n,windowScrollTo:i,windowViewportRect:r}},Ey(_b)),$x=Xy(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:i},{didMount:a},{useWindowScroll:o,windowScrollContainerState:s,windowViewportRect:c}])=>{let l=qy(),u=Gy(void 0),d=Gy(null),f=Gy(null);return jy(s,d),jy(c,f),Dy($(l,Hy(t,r,o,d,f,n)),([e,t,n,r,i,a,o])=>{let s=rx(t.sizeTree);r&&i!==null&&a!==null&&(n=i.scrollTop-a.offsetTop),n-=o,e({ranges:s,scrollTop:n})}),jy($(u,Iy(xy),Ly(eS)),i),jy($(a,Hy(u),Iy(([,e])=>e!==void 0),Fy(),Ly(([,e])=>e.ranges)),e),{getState:l,restoreStateFrom:u}},Ey(lx,_b,bx,fx,Qx));function eS(e){return{align:`start`,index:0,offset:e.scrollTop}}var tS=Xy(([{topItemsIndexes:e}])=>{let t=Gy(0);return jy($(t,Iy(e=>e>=0),Ly(e=>Array.from({length:e}).map((e,t)=>t))),e),{topItemCount:t}},Ey(Bx));function nS(e){let t=!1,n;return(()=>(t||(t=!0,n=e()),n))}var rS=nS(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),iS=Xy(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,fixedGroupSize:i,gap:a,groupIndices:o,heightEstimates:s,itemSize:c,sizeRanges:l,sizes:u,statefulTotalCount:d,totalCount:f,trackItemSizes:p},{initialItemFinalLocationReached:m,initialTopMostItemIndex:h,scrolledToInitialItem:g},_,v,y,b,{scrollToIndex:x},S,{topItemCount:C},{groupCounts:w},T])=>{let{listState:E,minOverscanItemCount:D,topItemsIndexes:O,rangeChanged:k,...A}=b;return jy(k,T.scrollSeekRangeChanged),jy($($y(T.windowViewportRect,_.headerHeight,_.fixedHeaderHeight),Ly(([e,t,n])=>Math.max(t+n+1,e.visibleHeight))),_.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,fixedGroupHeight:i,gap:a,groupCounts:w,heightEstimates:s,initialItemFinalLocationReached:m,initialTopMostItemIndex:h,scrolledToInitialItem:g,sizeRanges:l,topItemCount:C,topItemsIndexes:O,totalCount:f,...y,groupIndices:o,itemSize:c,listState:E,minOverscanItemCount:D,scrollToIndex:x,statefulTotalCount:d,trackItemSizes:p,rangeChanged:k,...A,...T,..._,sizes:u,...v}},Ey(lx,bx,_b,$x,Jx,Bx,hx,Xy(([{deviation:e,deviationCommitted:t,scrollBy:n,scrollingInProgress:r,scrollTop:i},{isAtBottom:a,isScrolling:o,lastJumpDueToItemResize:s,scrollDirection:c},{listState:l},{beforeUnshiftWith:u,gap:d,shiftWithOffset:f,sizes:p},{log:m},{recalcInProgress:h}])=>{let g=Jy($(l,Hy(s),zy(([,e,t,n],[{bottom:r,items:i,offsetBottom:a,totalCount:o},s])=>{let c=r+a,l=0;return t===o&&e.length>0&&i.length>0&&(i[0].originalIndex===0&&e[0].originalIndex===0||(l=c-n,l!==0&&(l+=s))),[l,i,o,c]},[0,[],0,0]),Iy(([e])=>e!==0),Hy(i,c,r,a,m,h),Iy(([,e,t,n,,,r])=>!r&&!n&&e!==0&&t===Sx),Ly(([[e],,,,,t])=>(t(`Upward scrolling compensation`,{amount:e},nb.DEBUG),e))));function _(t){t>0?(Oy(n,{behavior:`auto`,top:-t}),Oy(e,0)):(Oy(e,0),Oy(n,{behavior:`auto`,top:-t}))}Dy($(g,Hy(e,o)),([t,n,r])=>{r&&rS()?Oy(e,n-t):_(-t)}),Dy($($y(Ky(o,!1),e,h),Iy(([e,t,n])=>!e&&!n&&t!==0),Ly(([e,t])=>t),Vy(1)),_),jy($(f,Ly(e=>({top:-e}))),n);let v=null;function y(){if(v===null)return;let{offset:t}=v;v=null,Oy(n,{top:t}),requestAnimationFrame(()=>{Oy(e,0),Oy(h,!1)})}return Dy(t,e=>{v===null||!v.acknowledgeable||e===v.offset&&y()}),Dy($(u,Hy(p,d),Ly(([e,{groupIndices:t,lastSize:n,sizeTree:r},i])=>{function a(e){return e*(n+i)}if(t.length===0)return a(e);let o=0,s=xb(r,0),c=0,l=0;for(;c<e;){c++,o+=s;let n=t.length===l+1?1/0:t[l+1]-t[l]-1;c+n>e&&(o-=s,n=e-c+1),c+=n,o+=a(n),l++}return o})),t=>{v={acknowledgeable:Ay(e)!==t,offset:t},Oy(e,t),requestAnimationFrame(y)}),{deviation:e}},Ey(_b,Dx,Bx,lx,ab,Vb)),tS,dx,Xy(([e,t,n,r,i,a,o,s,c,l,u])=>({...e,...t,...n,...r,...i,...a,...o,...s,...c,...l,...u}),Ey(Nx,Yx,fx,Zx,Vx,Xx,Hx,Qx,Gx,ab,Ux))));function aS(e,t){let n={},r={},i=0,a=e.length;for(;i<a;)r[e[i]]=1,i+=1;for(let e in t)Object.hasOwn(r,e)||(n[e]=t[e]);return n}var oS=typeof document>`u`?Q.useEffect:Q.useLayoutEffect;function sS(e,t,n){let r=Object.keys(t.required||{}),i=Object.keys(t.optional||{}),a=Object.keys(t.methods||{}),o=Object.keys(t.events||{}),s=Q.createContext({});function c(e,n){e.propsReady!==void 0&&Oy(e.propsReady,!1);for(let i of r){let r=e[t.required[i]];Oy(r,n[i])}for(let r of i)if(r in n){let i=e[t.optional[r]];Oy(i,n[r])}e.propsReady!==void 0&&Oy(e.propsReady,!0)}function l(e){return a.reduce((n,r)=>(n[r]=n=>{let i=e[t.methods[r]];Oy(i,n)},n),{})}function u(e){return o.reduce((n,r)=>(n[r]=Wy(e[t.events[r]]),n),{})}return{Component:Q.forwardRef(function(t,a){let{children:d,...f}=t,[p]=Q.useState(()=>wy(Qy(e),e=>{c(e,f)})),[m]=Q.useState(yy(u,p));oS(()=>{for(let e of o)e in f&&Dy(m[e],f[e]);return()=>{Object.values(m).map(ky)}},[f,m,p]),oS(()=>{c(p,f)}),Q.useImperativeHandle(a,gy(l(p)));let h=n;return(0,Z.jsx)(s.Provider,{value:p,children:n===void 0?d:(0,Z.jsx)(h,{...aS([...r,...i,...o],f),children:d})})}),useEmitter:(e,t)=>{let n=Q.useContext(s)[e];oS(()=>Dy(n,t),[t,n])},useEmitterValue:e=>{let t=Q.useContext(s)[e],n=Q.useCallback(e=>Dy(t,e),[t]);return Q.useSyncExternalStore(n,()=>Ay(t),()=>Ay(t))},usePublisher:e=>{let t=Q.useContext(s);return Q.useCallback(n=>{Oy(t[e],n)},[t,e])}}}var cS=Q.createContext(void 0),lS=Q.createContext(void 0),uS=`-webkit-sticky`,dS=`sticky`,fS=nS(()=>{if(typeof document>`u`)return dS;let e=document.createElement(`div`);return e.style.position=uS,e.style.position===uS?uS:dS});function pS(e){return`self`in e}function mS(e){return`body`in e}function hS(e,t,n,r=Cy,i,a){let o=Q.useRef(null),s=Q.useRef(null),c=Q.useRef(null),l=Q.useCallback(n=>{let r,i,o,l=n.target;if(mS(l)||pS(l)){let e=pS(l)?l:l.defaultView;o=a===!0?cb(e,e.scrollX):e.scrollY,r=a===!0?e.document.documentElement.scrollWidth:e.document.documentElement.scrollHeight,i=a===!0?e.innerWidth:e.innerHeight}else o=a===!0?cb(l,l.scrollLeft):l.scrollTop,r=a===!0?l.scrollWidth:l.scrollHeight,i=a===!0?l.offsetWidth:l.offsetHeight;let u=()=>{e({scrollHeight:r,scrollTop:Math.max(o,0),viewportHeight:i})};n.suppressFlushSync===!0?u():As.flushSync(u),s.current!==null&&(o===s.current||o<=0||o===r-i)&&(s.current=null,t(!0),c.current&&=(clearTimeout(c.current),null))},[e,t,a]);Q.useEffect(()=>{let e=i??o.current;return r(i??o.current),l({suppressFlushSync:!0,target:e}),e.addEventListener(`scroll`,l,{passive:!0}),()=>{r(null),e.removeEventListener(`scroll`,l)}},[o,l,n,r,i]);function u(n){let r=o.current;if(!r||(a===!0?`offsetWidth`in r&&r.offsetWidth===0:`offsetHeight`in r&&r.offsetHeight===0))return;let i=n.behavior===`smooth`,l,u,d;pS(r)?(u=Math.max(Gb(r.document.documentElement,a===!0?`width`:`height`),a===!0?r.document.documentElement.scrollWidth:r.document.documentElement.scrollHeight),l=a===!0?r.innerWidth:r.innerHeight,d=a===!0?cb(r,r.scrollX):r.scrollY):(u=r[a===!0?`scrollWidth`:`scrollHeight`],l=Gb(r,a===!0?`width`:`height`),d=a===!0?cb(r,r.scrollLeft):r.scrollTop);let f=u-l;if(n.top===void 0){r.scrollTo(n);return}let p=Math.ceil(Math.max(Math.min(f,n.top),0));if(n.top=p,xx(l,u)||p===d){e({scrollHeight:u,scrollTop:d,viewportHeight:l}),i&&t(!0);return}i?(s.current=p,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,s.current=null,t(!0)},1e3)):s.current=null,a===!0&&(n={...n.behavior===void 0?{}:{behavior:n.behavior},left:lb(r,p)}),r.scrollTo(n)}return{scrollByCallback:Q.useCallback(e=>{a===!0&&(e={...e.behavior===void 0?{}:{behavior:e.behavior},...e.top===void 0?{}:{left:lb(o.current,e.top)}}),o.current.scrollBy(e)},[a]),scrollerRef:o,scrollToCallback:u}}function gS(e){return e}var _S=Xy(([e,t])=>({...e,...t}),Ey(iS,Xy(()=>{let e=Gy(e=>`Item ${e}`),t=Gy(e=>`Group ${e}`),n=Gy({}),r=Gy(gS),i=Gy(`div`),a=Gy(Cy),o=(e,t=null)=>Ky($(n,Ly(t=>t[e]),Fy()),t);return{components:n,computeItemKey:r,EmptyPlaceholder:o(`EmptyPlaceholder`),FooterComponent:o(`Footer`),GroupComponent:o(`Group`,`div`),groupContent:t,HeaderComponent:o(`Header`),HeaderFooterTag:i,ItemComponent:o(`Item`,`div`),itemContent:e,ListComponent:o(`List`,`div`),ScrollerComponent:o(`Scroller`,`div`),scrollerRef:a,ScrollSeekPlaceholder:o(`ScrollSeekPlaceholder`),TopItemListComponent:o(`TopItemList`)}}))),vS=({height:e})=>(0,Z.jsx)(`div`,{style:{height:e}}),yS={overflowAnchor:`none`,position:fS(),zIndex:1},bS={overflowAnchor:`none`},xS={...bS,display:`inline-block`,height:`100%`},SS=Q.memo(function({showTopList:e=!1}){let t=zS(`listState`),n=BS(`sizeRanges`),r=zS(`useWindowScroll`),i=zS(`customScrollParent`),a=BS(`windowScrollContainerState`),o=BS(`scrollContainerState`),s=i||r?a:o,c=zS(`itemContent`),l=zS(`context`),u=zS(`groupContent`),d=zS(`trackItemSizes`),f=zS(`itemSize`),p=zS(`log`),m=BS(`gap`),h=zS(`horizontalDirection`),{callbackRef:g}=fb(n,f,d,e?Cy:s,p,m,i,h,zS(`skipAnimationFrameInResizeObserver`)),[_,v]=Q.useState(0);RS(`deviation`,e=>{_!==e&&v(e)});let y=BS(`deviationCommitted`);hb(()=>{y(_)},[_,y]);let b=zS(`EmptyPlaceholder`),x=zS(`ScrollSeekPlaceholder`)??vS,S=zS(`ListComponent`),C=zS(`ItemComponent`),w=zS(`GroupComponent`),T=zS(`computeItemKey`),E=zS(`isSeeking`),D=zS(`groupIndices`).length>0,O=zS(`alignToBottom`),k=zS(`initialItemFinalLocationReached`),A=e?{}:{boxSizing:`border-box`,...h?{display:`inline-block`,height:`100%`,marginInlineStart:_===0?O?`auto`:0:_,paddingInlineEnd:t.offsetBottom,paddingInlineStart:t.offsetTop,whiteSpace:`nowrap`}:{marginTop:_===0?O?`auto`:0:_,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...k?{}:{visibility:`hidden`}};return!e&&t.totalCount===0&&b!=null?(0,Z.jsx)(b,{...OS(b,l)}):(0,Z.jsx)(S,{...OS(S,l),"data-testid":e?`virtuoso-top-item-list`:`virtuoso-item-list`,ref:g,style:A,children:(e?t.topItems:t.items).map(e=>{let n=e.originalIndex,r=T(n+t.firstItemIndex,e.data,l);return E?(0,Q.createElement)(x,{...OS(x,l),height:e.size,index:e.index,key:r,type:e.type||`item`,...e.type===`group`?{}:{groupIndex:e.groupIndex}}):e.type===`group`?(0,Q.createElement)(w,{...OS(w,l),"data-index":n,"data-item-index":e.index,"data-known-size":e.size,key:r,style:yS},u(e.index,l)):(0,Q.createElement)(C,{...OS(C,l),...kS(C,e.data),"data-index":n,"data-item-group-index":e.groupIndex,"data-item-index":e.index,"data-known-size":e.size,key:r,style:h?xS:bS},D?c(e.index,e.groupIndex,e.data,l):c(e.index,e.data,l))})})}),CS={height:`100%`,outline:`none`,overflowY:`auto`,position:`relative`,WebkitOverflowScrolling:`touch`},wS={outline:`none`,overflowX:`auto`,position:`relative`},TS=e=>({height:`100%`,position:`absolute`,top:0,width:`100%`,...e?{display:`flex`,flexDirection:`column`}:void 0}),ES=(e,t,n=0)=>({...TS(e),position:t?`relative`:`absolute`,top:t?-n:0}),DS={position:fS(),top:0,width:`100%`,zIndex:1};function OS(e,t){if(typeof e!=`string`)return{context:t}}function kS(e,t){return{item:typeof e==`string`?void 0:t}}var AS=Q.memo(function(){let e=zS(`HeaderComponent`),t=BS(`headerHeight`),n=zS(`HeaderFooterTag`),r=ub(Q.useMemo(()=>e=>{t(Gb(e,`height`))},[t]),!0,zS(`skipAnimationFrameInResizeObserver`)),i=zS(`context`);return e==null?null:(0,Z.jsx)(n,{ref:r,children:(0,Z.jsx)(e,{...OS(e,i)})})}),jS=Q.memo(function(){let e=zS(`FooterComponent`),t=BS(`footerHeight`),n=zS(`HeaderFooterTag`),r=ub(Q.useMemo(()=>e=>{t(Gb(e,`height`))},[t]),!0,zS(`skipAnimationFrameInResizeObserver`)),i=zS(`context`);return e==null?null:(0,Z.jsx)(n,{ref:r,children:(0,Z.jsx)(e,{...OS(e,i)})})});function MS({useEmitter:e,useEmitterValue:t,usePublisher:n}){return Q.memo(function({children:r,style:i,context:a,...o}){let s=n(`scrollContainerState`),c=t(`ScrollerComponent`),l=n(`smoothScrollTargetReached`),u=t(`scrollerRef`),d=t(`horizontalDirection`)||!1,{scrollByCallback:f,scrollerRef:p,scrollToCallback:m}=hS(s,l,c,u,void 0,d);return e(`scrollTo`,m),e(`scrollBy`,f),(0,Z.jsx)(c,{"data-testid":`virtuoso-scroller`,"data-virtuoso-scroller":!0,ref:p,style:{...d?wS:CS,...i},tabIndex:0,...o,...OS(c,a),children:r})})}function NS({useEmitter:e,useEmitterValue:t,usePublisher:n}){return Q.memo(function({children:r,style:i,context:a,...o}){let s=n(`windowScrollContainerState`),c=t(`ScrollerComponent`),l=n(`smoothScrollTargetReached`),u=t(`totalListHeight`),d=t(`deviation`),f=t(`customScrollParent`),p=Q.useRef(null),{scrollByCallback:m,scrollerRef:h,scrollToCallback:g}=hS(s,l,c,t(`scrollerRef`),f);return hb(()=>(h.current=f??p.current?.ownerDocument.defaultView,()=>{h.current=null}),[h,f]),e(`windowScrollTo`,g),e(`scrollBy`,m),(0,Z.jsx)(c,{ref:p,"data-virtuoso-scroller":!0,style:{position:`relative`,...i,...u===0?void 0:{height:u+d}},...o,...OS(c,a),children:r})})}var PS=({children:e})=>{let t=Q.useContext(cS),n=BS(`viewportHeight`),r=BS(`fixedItemHeight`),i=zS(`alignToBottom`),a=zS(`horizontalDirection`),o=ub(Q.useMemo(()=>vy(n,e=>Gb(e,a?`width`:`height`)),[n,a]),!0,zS(`skipAnimationFrameInResizeObserver`));return Q.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),(0,Z.jsx)(`div`,{"data-viewport-type":`element`,ref:o,style:TS(i),children:e})},FS=({children:e})=>{let t=Q.useContext(cS),n=BS(`windowViewportRect`),r=BS(`fixedItemHeight`),i=zS(`customScrollParent`),a=zS(`useWindowScroll`),o=zS(`topListHeight`),s=gb(n,i,zS(`skipAnimationFrameInResizeObserver`)),c=zS(`alignToBottom`);return Q.useEffect(()=>{t&&(r(t.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),(0,Z.jsx)(`div`,{"data-viewport-type":`window`,ref:s,style:ES(c,a,o),children:e})},IS=({children:e})=>{let t=zS(`TopItemListComponent`)??`div`,n=zS(`headerHeight`);return(0,Z.jsx)(t,{style:{...DS,marginTop:`${n}px`},...OS(t,zS(`context`)),children:e})},{Component:LS,useEmitter:RS,useEmitterValue:zS,usePublisher:BS}=sS(_S,{optional:{restoreStateFrom:`restoreStateFrom`,context:`context`,followOutput:`followOutput`,scrollIntoViewOnChange:`scrollIntoViewOnChange`,itemContent:`itemContent`,groupContent:`groupContent`,overscan:`overscan`,increaseViewportBy:`increaseViewportBy`,minOverscanItemCount:`minOverscanItemCount`,totalCount:`totalCount`,groupCounts:`groupCounts`,topItemCount:`topItemCount`,firstItemIndex:`firstItemIndex`,initialTopMostItemIndex:`initialTopMostItemIndex`,components:`components`,atBottomThreshold:`atBottomThreshold`,atTopThreshold:`atTopThreshold`,computeItemKey:`computeItemKey`,defaultItemHeight:`defaultItemHeight`,fixedGroupHeight:`fixedGroupHeight`,fixedItemHeight:`fixedItemHeight`,heightEstimates:`heightEstimates`,itemSize:`itemSize`,scrollSeekConfiguration:`scrollSeekConfiguration`,headerFooterTag:`HeaderFooterTag`,data:`data`,initialItemCount:`initialItemCount`,initialScrollTop:`initialScrollTop`,alignToBottom:`alignToBottom`,useWindowScroll:`useWindowScroll`,customScrollParent:`customScrollParent`,scrollerRef:`scrollerRef`,logLevel:`logLevel`,horizontalDirection:`horizontalDirection`,skipAnimationFrameInResizeObserver:`skipAnimationFrameInResizeObserver`},methods:{scrollToIndex:`scrollToIndex`,scrollIntoView:`scrollIntoView`,scrollTo:`scrollTo`,scrollBy:`scrollBy`,autoscrollToBottom:`autoscrollToBottom`,getState:`getState`},events:{isScrolling:`isScrolling`,endReached:`endReached`,startReached:`startReached`,rangeChanged:`rangeChanged`,atBottomStateChange:`atBottomStateChange`,atTopStateChange:`atTopStateChange`,totalListHeightChanged:`totalListHeightChanged`,itemsRendered:`itemsRendered`,groupIndices:`groupIndices`}},Q.memo(function(e){let t=zS(`useWindowScroll`),n=zS(`topItemsIndexes`).length>0,r=zS(`customScrollParent`),i=zS(`context`);return(0,Z.jsxs)(r||t?HS:VS,{...e,context:i,children:[n&&(0,Z.jsx)(IS,{children:(0,Z.jsx)(SS,{showTopList:!0})}),(0,Z.jsxs)(r||t?FS:PS,{children:[(0,Z.jsx)(AS,{}),(0,Z.jsx)(SS,{}),(0,Z.jsx)(jS,{})]})]})})),VS=MS({useEmitter:RS,useEmitterValue:zS,usePublisher:BS}),HS=NS({useEmitter:RS,useEmitterValue:zS,usePublisher:BS}),US=LS,WS=Xy(([e,t])=>({...e,...t}),Ey(iS,Xy(()=>{let e=Gy(e=>(0,Z.jsxs)(`td`,{children:[`Item $`,e]})),t=Gy(null),n=Gy(e=>(0,Z.jsxs)(`td`,{colSpan:1e3,children:[`Group `,e]})),r=Gy(null),i=Gy(null),a=Gy({}),o=Gy(gS),s=Gy(Cy),c=(e,t=null)=>Ky($(a,Ly(t=>t[e]),Fy()),t);return{components:a,computeItemKey:o,context:t,EmptyPlaceholder:c(`EmptyPlaceholder`),FillerRow:c(`FillerRow`),fixedFooterContent:i,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:c(`Scroller`,`div`),scrollerRef:s,ScrollSeekPlaceholder:c(`ScrollSeekPlaceholder`),TableBodyComponent:c(`TableBody`,`tbody`),TableComponent:c(`Table`,`table`),TableFooterComponent:c(`TableFoot`,`tfoot`),TableHeadComponent:c(`TableHead`,`thead`),TableRowComponent:c(`TableRow`,`tr`),GroupComponent:c(`Group`,`tr`)}}))),GS=({height:e})=>(0,Z.jsx)(`tr`,{children:(0,Z.jsx)(`td`,{style:{height:e}})}),KS=({height:e})=>(0,Z.jsx)(`tr`,{children:(0,Z.jsx)(`td`,{style:{border:0,height:e,padding:0}})}),qS={overflowAnchor:`none`},JS={position:fS(),zIndex:2,overflowAnchor:`none`},YS=Q.memo(function({showTopList:e=!1}){let t=tC(`listState`),n=tC(`computeItemKey`),r=tC(`firstItemIndex`),i=tC(`context`),a=tC(`isSeeking`),o=tC(`fixedHeaderHeight`),s=tC(`groupIndices`).length>0,c=tC(`itemContent`),l=tC(`groupContent`),u=tC(`ScrollSeekPlaceholder`)??GS,d=tC(`GroupComponent`),f=tC(`TableRowComponent`),p=(e?t.topItems:[]).reduce((e,t,n)=>(n===0?e.push(t.size):e.push(e[n-1]+t.size),e),[]);return(e?t.topItems:t.items).map(t=>{let m=t.originalIndex,h=n(m+r,t.data,i),g=e?m===0?0:p[m-1]:0;return a?(0,Q.createElement)(u,{...OS(u,i),height:t.size,index:t.index,key:h,type:t.type||`item`}):t.type===`group`?(0,Q.createElement)(d,{...OS(d,i),"data-index":m,"data-item-index":t.index,"data-known-size":t.size,key:h,style:{...JS,top:o}},l(t.index,i)):(0,Q.createElement)(f,{...OS(f,i),...kS(f,t.data),"data-index":m,"data-item-index":t.index,"data-known-size":t.size,"data-item-group-index":t.groupIndex,key:h,style:e?{...JS,top:o+g}:qS},s?c(t.index,t.groupIndex,t.data,i):c(t.index,t.data,i))})}),XS=Q.memo(function(){let e=tC(`listState`),t=tC(`topItemsIndexes`).length>0,n=nC(`sizeRanges`),r=tC(`useWindowScroll`),i=tC(`customScrollParent`),a=nC(`windowScrollContainerState`),o=nC(`scrollContainerState`),s=i||r?a:o,c=tC(`trackItemSizes`),{callbackRef:l,ref:u}=fb(n,tC(`itemSize`),c,s,tC(`log`),void 0,i,!1,tC(`skipAnimationFrameInResizeObserver`)),[d,f]=Q.useState(0);eC(`deviation`,e=>{d!==e&&(u.current.style.marginTop=`${e}px`,f(e))});let p=nC(`deviationCommitted`);hb(()=>{p(d)},[d,p]);let m=tC(`EmptyPlaceholder`),h=tC(`FillerRow`)??KS,g=tC(`TableBodyComponent`),_=tC(`paddingTopAddition`),v=tC(`statefulTotalCount`),y=tC(`context`);if(v===0&&m!=null)return(0,Z.jsx)(m,{...OS(m,y)});let b=(t?e.topItems:[]).reduce((e,t)=>e+t.size,0),x=e.offsetTop+_+d-b,S=e.offsetBottom,C=x>0?(0,Z.jsx)(h,{context:y,height:x},`padding-top`):null,w=S>0?(0,Z.jsx)(h,{context:y,height:S},`padding-bottom`):null;return(0,Z.jsxs)(g,{"data-testid":`virtuoso-item-list`,ref:l,...OS(g,y),children:[C,t&&(0,Z.jsx)(YS,{showTopList:!0}),(0,Z.jsx)(YS,{}),w]})}),ZS=({children:e})=>{let t=Q.useContext(cS),n=nC(`viewportHeight`),r=nC(`fixedItemHeight`),i=ub(Q.useMemo(()=>vy(n,e=>Gb(e,`height`)),[n]),!0,tC(`skipAnimationFrameInResizeObserver`));return Q.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),(0,Z.jsx)(`div`,{"data-viewport-type":`element`,ref:i,style:TS(!1),children:e})},QS=({children:e})=>{let t=Q.useContext(cS),n=nC(`windowViewportRect`),r=nC(`fixedItemHeight`),i=tC(`customScrollParent`),a=tC(`useWindowScroll`),o=gb(n,i,tC(`skipAnimationFrameInResizeObserver`));return Q.useEffect(()=>{t&&(r(t.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),(0,Z.jsx)(`div`,{"data-viewport-type":`window`,ref:o,style:ES(!1,a),children:e})},{Component:$S,useEmitter:eC,useEmitterValue:tC,usePublisher:nC}=sS(WS,{optional:{restoreStateFrom:`restoreStateFrom`,context:`context`,followOutput:`followOutput`,firstItemIndex:`firstItemIndex`,itemContent:`itemContent`,groupContent:`groupContent`,fixedHeaderContent:`fixedHeaderContent`,fixedFooterContent:`fixedFooterContent`,overscan:`overscan`,increaseViewportBy:`increaseViewportBy`,minOverscanItemCount:`minOverscanItemCount`,totalCount:`totalCount`,topItemCount:`topItemCount`,initialTopMostItemIndex:`initialTopMostItemIndex`,components:`components`,groupCounts:`groupCounts`,atBottomThreshold:`atBottomThreshold`,atTopThreshold:`atTopThreshold`,computeItemKey:`computeItemKey`,defaultItemHeight:`defaultItemHeight`,fixedGroupHeight:`fixedGroupHeight`,fixedItemHeight:`fixedItemHeight`,itemSize:`itemSize`,scrollSeekConfiguration:`scrollSeekConfiguration`,data:`data`,initialItemCount:`initialItemCount`,initialScrollTop:`initialScrollTop`,alignToBottom:`alignToBottom`,useWindowScroll:`useWindowScroll`,customScrollParent:`customScrollParent`,scrollerRef:`scrollerRef`,logLevel:`logLevel`,skipAnimationFrameInResizeObserver:`skipAnimationFrameInResizeObserver`},methods:{scrollToIndex:`scrollToIndex`,scrollIntoView:`scrollIntoView`,scrollTo:`scrollTo`,scrollBy:`scrollBy`,getState:`getState`},events:{isScrolling:`isScrolling`,endReached:`endReached`,startReached:`startReached`,rangeChanged:`rangeChanged`,atBottomStateChange:`atBottomStateChange`,atTopStateChange:`atTopStateChange`,totalListHeightChanged:`totalListHeightChanged`,itemsRendered:`itemsRendered`,groupIndices:`groupIndices`}},Q.memo(function(e){let t=tC(`useWindowScroll`),n=tC(`customScrollParent`),r=nC(`fixedHeaderHeight`),i=nC(`fixedFooterHeight`),a=tC(`fixedHeaderContent`),o=tC(`fixedFooterContent`),s=tC(`context`),c=ub(Q.useMemo(()=>vy(r,e=>Gb(e,`height`)),[r]),!0,tC(`skipAnimationFrameInResizeObserver`)),l=ub(Q.useMemo(()=>vy(i,e=>Gb(e,`height`)),[i]),!0,tC(`skipAnimationFrameInResizeObserver`)),u=n||t?iC:rC,d=n||t?QS:ZS,f=tC(`TableComponent`),p=tC(`TableHeadComponent`),m=tC(`TableFooterComponent`),h=a?(0,Z.jsx)(p,{ref:c,style:{position:`sticky`,top:0,zIndex:2},...OS(p,s),children:a()},`TableHead`):null,g=o?(0,Z.jsx)(m,{ref:l,style:{bottom:0,position:`sticky`,zIndex:1},...OS(m,s),children:o()},`TableFoot`):null;return(0,Z.jsx)(u,{...e,...OS(u,s),children:(0,Z.jsx)(d,{children:(0,Z.jsxs)(f,{style:{borderSpacing:0,overflowAnchor:`none`},...OS(f,s),children:[h,(0,Z.jsx)(XS,{},`TableBody`),g]})})})})),rC=MS({useEmitter:eC,useEmitterValue:tC,usePublisher:nC}),iC=NS({useEmitter:eC,useEmitterValue:tC,usePublisher:nC}),aC={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},oC={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:sC,floor:cC,max:lC,min:uC,round:dC}=Math;function fC(e,t,n){return Array.from({length:t-e+1}).map((t,r)=>({data:n===null?null:n[r+e],index:r+e}))}function pC(e){return{...oC,items:e}}function mC(e,t){return e!==void 0&&e.width===t.width&&e.height===t.height}function hC(e,t){return e!==void 0&&e.column===t.column&&e.row===t.row}var gC=Xy(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:i,headerHeight:a,scrollBy:o,scrollContainerState:s,scrollTo:c,scrollTop:l,smoothScrollTargetReached:u,viewportHeight:d},f,p,{didMount:m,propsReady:h},{customScrollParent:g,useWindowScroll:_,windowScrollContainerState:v,windowScrollTo:y,windowViewportRect:b},x])=>{let S=Gy(0),C=Gy(0),w=Gy(aC),T=Gy({height:0,width:0}),E=Gy({height:0,width:0}),D=qy(),O=qy(),k=Gy(0),A=Gy(null),j=Gy({column:0,row:0}),M=qy(),N=qy(),P=Gy(!1),F=Gy(0),I=Gy(!0),L=Gy(!1),R=Gy(!1);Dy($(m,Hy(F),Iy(([e,t])=>!yx(t))),()=>{Oy(I,!1)}),Dy($($y(m,I,E,T,F,L),Iy(([e,t,n,r,,i])=>e&&!t&&n.height!==0&&r.height!==0&&!i)),([,,,,e])=>{if(e===void 0){Oy(I,!0);return}Oy(L,!0),_x(1,()=>{Oy(D,e)}),My($(l),()=>{Oy(t,[0,0]),Oy(I,!0)})}),jy($(N,Iy(e=>e!=null&&e.scrollTop>0),Ry(0)),C),Dy($(m,Hy(N),Iy(([,e])=>e!=null)),([,e])=>{e&&(Oy(T,e.viewport),Oy(E,e.item),Oy(j,e.gap),e.scrollTop>0&&(Oy(P,!0),My($(l,By(1)),e=>{Oy(P,!1)}),Oy(c,{top:e.scrollTop})))}),jy($(T,Ly(({height:e})=>e)),d),jy($($y(eb(T,mC),eb(E,mC),eb(j,(e,t)=>e!==void 0&&e.column===t.column&&e.row===t.row),eb(l)),Ly(([e,t,n,r])=>({gap:n,item:t,scrollTop:r,viewport:e}))),M),jy($($y(eb(S),r,eb(j,hC),eb(E,mC),eb(T,mC),eb(A),eb(C),eb(P),eb(I),eb(F)),Iy(([,,,,,,,e])=>!e),Ly(([e,[t,n],r,i,a,o,s,,c,l])=>{let{column:u,row:d}=r,{height:f,width:p}=i,{width:m}=a;if(s===0&&(e===0||m===0))return aC;if(p===0){let t=vx(l,e);return pC(fC(t,t+Math.max(s-1,0),o))}let h=_C(m,p,u),g,_;c?t===0&&n===0&&s>0?(g=0,_=s-1):(g=h*cC((t+d)/(f+d)),_=h*sC((n+d)/(f+d))-1,_=uC(e-1,lC(_,h-1)),g=uC(_,lC(0,g))):(g=0,_=-1);let v=fC(g,_,o),{bottom:y,top:b}=vC(a,r,i,v),x=sC(e/h);return{bottom:y,itemHeight:f,items:v,itemWidth:p,offsetBottom:x*f+(x-1)*d-y,offsetTop:b,top:b}})),w),jy($(A,Iy(e=>e!==null),Ly(e=>e.length)),S),jy($($y(T,E,w,j),Iy(([e,t,{items:n}])=>n.length>0&&t.height!==0&&e.height!==0),Ly(([e,t,{items:n},r])=>{let{bottom:i,top:a}=vC(e,r,t,n);return[a,i]}),Fy(Bb)),t);let z=Gy(!1);jy($(l,Hy(z),Ly(([e,t])=>t||e!==0)),z);let B=Jy($($y(w,S),Iy(([{items:e}])=>e.length>0),Hy(z),Iy(([[e,t],n])=>{let r=e.items[e.items.length-1].index===t-1;return(n||e.bottom>0&&e.itemHeight>0&&e.offsetBottom===0&&e.items.length===t)&&r}),Ly(([[,e]])=>e-1),Fy())),V=Jy($(eb(w),Iy(({items:e})=>e.length>0&&e[0].index===0),Ry(0),Fy())),H=Jy($(eb(w),Hy(P),Iy(([{items:e},t])=>e.length>0&&!t),Ly(([{items:e}])=>({endIndex:e[e.length-1].index,startIndex:e[0].index})),Fy(zb),Vy(0)));jy(H,p.scrollSeekRangeChanged),jy($(D,Hy(T,E,S,j),Ly(([e,t,n,r,i])=>{let a=mx(e),{align:o,behavior:s,offset:c}=a,l=a.index;l===`LAST`&&(l=r-1),l=lC(0,l,uC(r-1,l));let u=yC(t,i,n,l);return o===`end`?u=dC(u-t.height+n.height):o===`center`&&(u=dC(u-t.height/2+n.height/2)),c!==void 0&&c!==0&&(u+=c),{behavior:s,top:u}})),c);let U=Ky($(w,Ly(e=>e.offsetBottom+e.bottom)),0);return jy($(b,Ly(e=>({height:e.visibleHeight,width:e.visibleWidth}))),T),{customScrollParent:g,data:A,deviation:k,footerHeight:i,gap:j,headerHeight:a,increaseViewportBy:e,initialItemCount:C,itemDimensions:E,overscan:n,restoreStateFrom:N,scrollBy:o,scrollContainerState:s,scrollHeight:O,scrollTo:c,scrollToIndex:D,scrollTop:l,smoothScrollTargetReached:u,totalCount:S,useWindowScroll:_,viewportDimensions:T,windowScrollContainerState:v,windowScrollTo:y,windowViewportRect:b,...p,gridState:w,horizontalDirection:R,initialTopMostItemIndex:F,totalListHeight:U,...f,endReached:B,propsReady:h,rangeChanged:H,startReached:V,stateChanged:M,stateRestoreInProgress:P,...x}},Ey(Nx,_b,Dx,Zx,fx,Qx,ab));function _C(e,t,n){return lC(1,cC((e+n)/(cC(t)+n)))}function vC(e,t,n,r){let{height:i}=n;if(i===void 0||r.length===0)return{bottom:0,top:0};let a=yC(e,t,n,r[0].index);return{bottom:yC(e,t,n,r[r.length-1].index)+i,top:a}}function yC(e,t,n,r){let i=cC(r/_C(e.width,n.width,t.column)),a=i*n.height+lC(0,i-1)*t.row;return a>0?a+t.row:a}var bC=Xy(([e,t])=>({...e,...t}),Ey(gC,Xy(()=>{let e=Gy(e=>`Item ${e}`),t=Gy({}),n=Gy(null),r=Gy(`virtuoso-grid-item`),i=Gy(`virtuoso-grid-list`),a=Gy(gS),o=Gy(`div`),s=Gy(Cy),c=(e,n=null)=>Ky($(t,Ly(t=>t[e]),Fy()),n),l=Gy(!1),u=Gy(!1);return jy(eb(u),l),{components:t,computeItemKey:a,context:n,FooterComponent:c(`Footer`),HeaderComponent:c(`Header`),headerFooterTag:o,itemClassName:r,ItemComponent:c(`Item`,`div`),itemContent:e,listClassName:i,ListComponent:c(`List`,`div`),readyStateChanged:l,reportReadyState:u,ScrollerComponent:c(`Scroller`,`div`),scrollerRef:s,ScrollSeekPlaceholder:c(`ScrollSeekPlaceholder`,`div`)}}))),xC=Q.memo(function(){let e=OC(`gridState`),t=OC(`listClassName`),n=OC(`itemClassName`),r=OC(`itemContent`),i=OC(`computeItemKey`),a=OC(`isSeeking`),o=kC(`scrollHeight`),s=OC(`ItemComponent`),c=OC(`ListComponent`),l=OC(`ScrollSeekPlaceholder`),u=OC(`context`),d=kC(`itemDimensions`),f=kC(`gap`),p=OC(`log`),m=OC(`stateRestoreInProgress`),h=kC(`reportReadyState`),g=ub(Q.useMemo(()=>e=>{let t=e.parentElement.parentElement.scrollHeight;o(t);let n=e.firstChild;if(n!==null){let{height:e,width:t}=n.getBoundingClientRect();d({height:e,width:t})}f({column:MC(`column-gap`,getComputedStyle(e).columnGap,p),row:MC(`row-gap`,getComputedStyle(e).rowGap,p)})},[o,d,f,p]),!0,!1);return hb(()=>{e.itemHeight>0&&e.itemWidth>0&&h(!0)},[e]),m?null:(0,Z.jsx)(c,{className:t,ref:g,...OS(c,u),"data-testid":`virtuoso-item-list`,style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(t=>{let o=i(t.index,t.data,u);return a?(0,Z.jsx)(l,{...OS(l,u),height:e.itemHeight,index:t.index,width:e.itemWidth},o):(0,Q.createElement)(s,{...OS(s,u),className:n,"data-index":t.index,key:o},r(t.index,t.data,u))})})}),SC=Q.memo(function(){let e=OC(`HeaderComponent`),t=kC(`headerHeight`),n=OC(`headerFooterTag`),r=ub(Q.useMemo(()=>e=>{t(Gb(e,`height`))},[t]),!0,!1),i=OC(`context`);return e==null?null:(0,Z.jsx)(n,{ref:r,children:(0,Z.jsx)(e,{...OS(e,i)})})}),CC=Q.memo(function(){let e=OC(`FooterComponent`),t=kC(`footerHeight`),n=OC(`headerFooterTag`),r=ub(Q.useMemo(()=>e=>{t(Gb(e,`height`))},[t]),!0,!1),i=OC(`context`);return e==null?null:(0,Z.jsx)(n,{ref:r,children:(0,Z.jsx)(e,{...OS(e,i)})})}),wC=({children:e})=>{let t=Q.useContext(lS),n=kC(`itemDimensions`),r=kC(`viewportDimensions`),i=ub(Q.useMemo(()=>e=>{r(e.getBoundingClientRect())},[r]),!0,!1);return Q.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),(0,Z.jsx)(`div`,{ref:i,style:TS(!1),children:e})},TC=({children:e})=>{let t=Q.useContext(lS),n=kC(`windowViewportRect`),r=kC(`itemDimensions`),i=OC(`customScrollParent`),a=OC(`useWindowScroll`),o=gb(n,i,!1);return Q.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),(0,Z.jsx)(`div`,{ref:o,style:ES(!1,a),children:e})},{Component:EC,useEmitter:DC,useEmitterValue:OC,usePublisher:kC}=sS(bC,{optional:{context:`context`,totalCount:`totalCount`,overscan:`overscan`,itemContent:`itemContent`,components:`components`,computeItemKey:`computeItemKey`,data:`data`,initialItemCount:`initialItemCount`,scrollSeekConfiguration:`scrollSeekConfiguration`,headerFooterTag:`headerFooterTag`,listClassName:`listClassName`,itemClassName:`itemClassName`,useWindowScroll:`useWindowScroll`,customScrollParent:`customScrollParent`,scrollerRef:`scrollerRef`,logLevel:`logLevel`,restoreStateFrom:`restoreStateFrom`,initialTopMostItemIndex:`initialTopMostItemIndex`,increaseViewportBy:`increaseViewportBy`},methods:{scrollTo:`scrollTo`,scrollBy:`scrollBy`,scrollToIndex:`scrollToIndex`},events:{isScrolling:`isScrolling`,endReached:`endReached`,startReached:`startReached`,rangeChanged:`rangeChanged`,atBottomStateChange:`atBottomStateChange`,atTopStateChange:`atTopStateChange`,stateChanged:`stateChanged`,readyStateChanged:`readyStateChanged`}},Q.memo(function({...e}){let t=OC(`useWindowScroll`),n=OC(`customScrollParent`),r=n||t?jC:AC,i=n||t?TC:wC,a=OC(`context`);return(0,Z.jsx)(r,{...e,...OS(r,a),children:(0,Z.jsxs)(i,{children:[(0,Z.jsx)(SC,{}),(0,Z.jsx)(xC,{}),(0,Z.jsx)(CC,{})]})})})),AC=MS({useEmitter:DC,useEmitterValue:OC,usePublisher:kC}),jC=NS({useEmitter:DC,useEmitterValue:OC,usePublisher:kC});function MC(e,t,n){return t!==`normal`&&t?.endsWith(`px`)!==!0&&n(`${e} was not resolved to pixel value correctly`,t,nb.WARN),t===`normal`?0:parseInt(t??`0`,10)}function NC(e){return e.scrollHeight-e.scrollTop-e.clientHeight}function PC(e,t=96){return NC(e)<=t}function FC(e){Math.abs(NC(e))>.5&&(e.scrollTop=e.scrollHeight)}function IC(e){let t=e.querySelectorAll(`[data-chat-message-index]`);if(!t.length)return 0;let n=e.getBoundingClientRect(),r=n.top+Math.min(180,n.height*.35),i=0,a=t.length-1;for(;i<a;){let e=Math.ceil((i+a)/2);t[e].getBoundingClientRect().top<=r?i=e:a=e-1}let o=Number.parseInt(t[i].dataset.chatMessageIndex??``,10);return Number.isFinite(o)?o:0}function LC(){return typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}var RC=new WeakMap;function zC(e,t){return RC.set(e,t),()=>{RC.get(e)===t&&RC.delete(e)}}function BC(e){return RC.get(e)}function VC(e){e.dispatchEvent(new Event(`chat-scroll-reading`))}function HC({context:e}){return e?.footer}var UC={Footer:HC},WC={top:800,bottom:800};function GC({rows:e,scrollRef:t,renderRow:n,footer:r}){let i=(0,Q.useRef)(null),[a,o]=(0,Q.useState)(),[s,c]=(0,Q.useState)(WC),[l,u]=(0,Q.useState)({rows:e,first:1e9});if(l.rows!==e){let t=l.rows[0]?.key,n=t?e.findIndex(e=>e.key===t):0;u({rows:e,first:l.first-Math.max(0,n)})}return(0,Q.useEffect)(()=>{o(t.current??void 0)},[t]),(0,Q.useLayoutEffect)(()=>{if(a)return zC(a,{reveal:t=>{let n=e.findIndex(e=>e.index===t||e.aliases.includes(t));return n<0?!1:(VC(a),i.current?.scrollToIndex({index:n,align:`start`,offset:-16,behavior:`auto`}),!0)},end:e=>i.current?.scrollToIndex({index:`LAST`,align:`end`,offset:(parseFloat(getComputedStyle(a).paddingBottom)||0)+(parseFloat(getComputedStyle(a.querySelector(`[data-chat-virtualized]`)??a).paddingBottom)||0),behavior:e&&LC()===`smooth`?`smooth`:`auto`})})},[a,e,l.first]),(0,Q.useLayoutEffect)(()=>{if(!a)return;let e=null,t=()=>{let t=window.getSelection();t&&!t.isCollapsed&&a.contains(t.anchorNode)?(e??={start:a.scrollTop,end:a.scrollTop},e.start=Math.min(e.start,a.scrollTop),e.end=Math.max(e.end,a.scrollTop)):e=null;let n=WC.top+(e?a.scrollTop-e.start:0),r=WC.bottom+(e?e.end-a.scrollTop:0);c(e=>e.top===n&&e.bottom===r?e:{top:n,bottom:r})},n=()=>{e!==null&&t()};return document.addEventListener(`selectionchange`,t),a.addEventListener(`scroll`,n,{passive:!0}),()=>{document.removeEventListener(`selectionchange`,t),a.removeEventListener(`scroll`,n)}},[a]),a?(0,Z.jsx)(US,{ref:i,customScrollParent:a,data:e,skipAnimationFrameInResizeObserver:!0,components:UC,context:{footer:r},firstItemIndex:l.first,initialTopMostItemIndex:{index:e.length-1,align:`end`},defaultItemHeight:160,increaseViewportBy:s,computeItemKey:(e,t)=>t.key,itemContent:(t,r)=>(0,Z.jsx)(`div`,{className:r===e[0]?void 0:`pt-8`,children:n(r.index)})}):null}var KC=e=>{},qC=(0,Q.memo)(function(e){let t=(0,X.c)(47),{messages:n,timelineEntries:r,personal:i,authToken:a,conversationId:o,workspaceConversationId:s,projectId:c,streaming:l,sending:u,progress:d,reasoningLevel:f,registerListContentRef:p,onPickWelcomePrompt:m,welcomeSpotlight:g,welcomeOverlay:_,compactWelcome:v,onDeleteRound:b,onRetryUserMessageRound:x,deleteRoundDisabled:S,onSaveAssistantAsNote:C,onSaveAssistantToSourceNote:w,onExtractAssistantTask:T,onForkAssistantTurn:E,onEditUserMessage:D,editLatestUserOnly:O,editRequiresTurnId:k,responseFeedbackEnabled:A,showAssistantWorkLog:j,hideAssistantActions:M,trailingContent:N,replySpaceRef:P,scrollRef:F}=e,I=r===void 0?[]:r,L=i!==void 0&&i,R=u!==void 0&&u,z=v!==void 0&&v,B=O!==void 0&&O,V=k!==void 0&&k,H=j===void 0||j,U=M!==void 0&&M,W=h(JC),G;t[0]===W?G=t[1]:(G=y(W),t[0]=W,t[1]=G);let ee=G,[te]=(0,Q.useState)(!!(F&&n.length>=300));if(n.length===0&&I.length===0&&!l&&!R){if(_){let e;return t[2]===_?e=t[3]:(e=(0,Z.jsx)(`div`,{className:`pb-1.5`,children:_}),t[2]=_,t[3]=e),e}let e;t[4]!==ee||t[5]!==g?(e=g??{headline:ee.chat.welcomeSpotlight.headline,contextKind:`empty`,contextStatus:`ready`},t[4]=ee,t[5]=g,t[6]=e):e=t[6];let n=m??KC,r;return t[7]!==z||t[8]!==e||t[9]!==n?(r=(0,Z.jsx)(`div`,{className:`pb-1.5`,children:(0,Z.jsx)($p,{spotlight:e,onPickPrompt:n,compact:z})}),t[7]=z,t[8]=e,t[9]=n,t[10]=r):r=t[10],r}let ne=Date.now(),re;t[11]===n?re=t[12]:(re=n.findLastIndex(YC),t[11]=n,t[12]=re);let ie=re,ae;t[13]!==n.length||t[14]!==R||t[15]!==l?(ae=(e,t)=>!!((l||R||e.pendingResponseStatus)&&t===n.length-1&&e.role===`assistant`),t[13]=n.length,t[14]=R,t[15]=l,t[16]=ae):ae=t[16];let K=ae,oe;t[17]===n?oe=t[18]:(oe=(e,t)=>e.role===`assistant`&&e.turnId&&n[t-1]?.role===`task`&&n[t-1]?.turnId===e.turnId?n[t-1].taskTrigger:void 0,t[17]=n,t[18]=oe);let se=oe,q;t[19]!==se||t[20]!==K||t[21]!==n||t[22]!==L||t[23]!==f||t[24]!==H?(q=(e,t)=>!Pv(e,{personal:L,isStreaming:K(e,t),reasoningLevel:f,showAssistantWorkLog:H,followUpTrigger:se(e,t)})||e.role===`task`&&e.taskTrigger&&e.turnId&&n[t+1]?.role===`assistant`&&n[t+1]?.turnId===e.turnId?[]:[{key:iy(e,t),index:t,aliases:e.role===`assistant`&&n[t-1]?.role===`task`&&e.turnId===n[t-1]?.turnId?[t-1]:[]}],t[19]=se,t[20]=K,t[21]=n,t[22]=L,t[23]=f,t[24]=H,t[25]=q):q=t[25];let ce=n.flatMap(q),le;t[26]===n.length?le=t[27]:(le=(e,t)=>({key:e.id,index:n.length+t,aliases:[]}),t[26]=n.length,t[27]=le),ce.push(...I.map(le));let ue=0,de=n.map(e=>(ue=Math.max(e.timestamp??ue,ue),ue));I.length&&ce.sort((e,t)=>{let r=e=>e<n.length?de[e]:I[e-n.length].timestamp;return r(e.index)-r(t.index)||e.index-t.index});let fe=new Map(ce.map((e,t)=>[e.index,ce[t-1]?.index])),J=e=>{if(e>=n.length){let t=I[e-n.length];return(0,Z.jsx)(`div`,{"data-chat-timeline-entry":t.id,children:t.content},t.id)}let t=n[e],r=K(t,e),i=e===ie,l=n[e-1],u=se(t,e),p=fe.get(e),m=p===void 0?void 0:n[p],h=m&&p!==void 0?se(m,p)?n[p-1]?.timestamp??m.timestamp:m.timestamp:void 0,g=iy(t,e),_=u?l?.timestamp??t.timestamp:t.timestamp,v=uy(_,h);return(0,Z.jsxs)(`div`,{id:`chat-message-${e}`,className:Y(`scroll-mt-4`,m&&(m.role===`user`||m.role===`task`)&&!u&&!v&&`-mt-5`),"data-chat-message-index":e,"data-chat-message-row":!0,"data-client-submission-id":t.clientSubmissionId,"data-message-render-key":t.renderKey,children:[u?(0,Z.jsx)(`span`,{id:`chat-message-${e-1}`,className:`block h-0 scroll-mt-4`,"aria-hidden":!0}):null,v&&_?(0,Z.jsx)(`div`,{className:`mb-8 flex justify-center`,"data-chat-time-separator":!0,children:(0,Z.jsx)(`time`,{suppressHydrationWarning:!0,className:`rounded-md px-2 py-1 text-xs tabular-nums text-fg-disabled`,dateTime:new Date(_).toISOString(),children:dy(_,ne,W)})}):null,t.role===`task`&&t.taskTrigger?(0,Z.jsx)(Bv,{trigger:t.taskTrigger}):(0,Z.jsx)(ry,{message:t,personal:L,followUpTrigger:u,authToken:a,conversationId:o,workspaceConversationId:s,projectId:c,isStreaming:r,progress:r?d:null,reasoningLevel:f,messageIndex:e,onDeleteRound:b,onRetryUserMessageRound:x,userMessageCanRetry:!!x&&i,deleteRoundDisabled:!!(S&&i),onSaveAssistantAsNote:C,onSaveAssistantToSourceNote:w,onExtractAssistantTask:T,onForkAssistantTurn:E,suppressAssistantActions:U,onEditUserMessage:D,userMessageCanEdit:(!B||i)&&(!V||!!t.turnId)&&t.deliveryStatus!==`sending`,responseFeedbackEnabled:A,showAssistantWorkLog:H})]},g)},pe=te?`pt-8`:`contents`,me;t[28]===pe?me=t[29]:(me=Y(pe),t[28]=pe,t[29]=me);let he;t[30]!==P||t[31]!==te?(he=P&&(0,Z.jsx)(`div`,{ref:P,className:Y(!te&&`-mt-8`,`shrink-0 transition-none`),"aria-hidden":!0,"data-chat-reply-space":!0}),t[30]=P,t[31]=te,t[32]=he):he=t[32];let ge;t[33]!==me||t[34]!==he||t[35]!==N?(ge=(0,Z.jsxs)(`div`,{className:me,children:[N,he]}),t[33]=me,t[34]=he,t[35]=N,t[36]=ge):ge=t[36];let _e=ge,ve=ca,ye=!te&&`flex flex-col gap-8`,be;t[37]===ye?be=t[38]:(be=Y(`w-full min-w-0 pb-8`,ye),t[37]=ye,t[38]=be);let xe=te||void 0,Se=te&&F?(0,Z.jsx)(GC,{rows:ce,scrollRef:F,renderRow:J,footer:_e}):(0,Z.jsxs)(Z.Fragment,{children:[ce.map(e=>J(e.index)),_e]}),Ce;t[39]!==p||t[40]!==be||t[41]!==xe||t[42]!==Se?(Ce=(0,Z.jsx)(`div`,{ref:p,className:be,"data-chat-virtualized":xe,children:Se}),t[39]=p,t[40]=be,t[41]=xe,t[42]=Se,t[43]=Ce):Ce=t[43];let we;return t[44]!==ve||t[45]!==Ce?(we=(0,Z.jsx)(ve,{children:Ce}),t[44]=ve,t[45]=Ce,t[46]=we):we=t[46],we});function JC(e){return e.language}function YC(e){return e.role===`user`}function XC(e){let t=(0,X.c)(8),{alt:n,className:r,"aria-hidden":i}=e,a=n?.trim()?n:void 0,o=i??(!a||void 0),s;t[0]===r?s=t[1]:(s=Y(`xopc-loop-logo relative inline-block shrink-0`,r),t[0]=r,t[1]=s);let c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsxs)(`linearGradient`,{id:`xopc-onboarding-ai-glass`,x1:`198`,y1:`180`,x2:`826`,y2:`844`,gradientUnits:`userSpaceOnUse`,children:[(0,Z.jsx)(`stop`,{stopColor:`var(--xopc-loop-ai-highlight)`}),(0,Z.jsx)(`stop`,{offset:`0.46`,stopColor:`var(--xopc-loop-ai)`}),(0,Z.jsx)(`stop`,{offset:`1`,stopColor:`var(--xopc-loop-ai-shadow)`})]}),t[2]=c):c=t[2];let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsxs)(`svg`,{className:`size-full overflow-visible`,viewBox:`0 0 1024 1024`,fill:`none`,"aria-hidden":`true`,children:[(0,Z.jsxs)(`defs`,{children:[c,(0,Z.jsxs)(`linearGradient`,{id:`xopc-onboarding-human-glass`,x1:`340`,y1:`224`,x2:`700`,y2:`816`,gradientUnits:`userSpaceOnUse`,children:[(0,Z.jsx)(`stop`,{stopColor:`var(--xopc-loop-human-highlight)`}),(0,Z.jsx)(`stop`,{offset:`0.52`,stopColor:`var(--xopc-loop-human)`}),(0,Z.jsx)(`stop`,{offset:`1`,stopColor:`var(--xopc-loop-human-shadow)`})]})]}),(0,Z.jsx)(`circle`,{className:`xopc-loop-logo__ambient`,cx:`512`,cy:`512`,r:`330`}),(0,Z.jsx)(`circle`,{className:`xopc-loop-logo__origin`,cx:`512`,cy:`512`,r:`330`}),(0,Z.jsx)(`circle`,{className:`xopc-loop-logo__ai-glow`,cx:`512`,cy:`512`,r:`330`,strokeDasharray:`1419.162121 654.289030`,transform:`rotate(11.8 512 512)`}),(0,Z.jsx)(`circle`,{className:`xopc-loop-logo__ai`,cx:`512`,cy:`512`,r:`330`,stroke:`url(#xopc-onboarding-ai-glass)`,strokeDasharray:`1419.162121 654.289030`,transform:`rotate(11.8 512 512)`}),(0,Z.jsx)(`circle`,{className:`xopc-loop-logo__human`,cx:`512`,cy:`512`,r:`330`,stroke:`url(#xopc-onboarding-human-glass)`,strokeDasharray:`354.790530 1718.660621`,transform:`rotate(284.2 512 512)`}),(0,Z.jsx)(`circle`,{className:`xopc-loop-logo__liquid-front`,cx:`512`,cy:`512`,r:`330`,strokeDasharray:`58 2015.451151`,transform:`rotate(11.8 512 512)`})]}),t[3]=l):l=t[3];let u;return t[4]!==o||t[5]!==a||t[6]!==s?(u=(0,Z.jsx)(`span`,{className:s,role:`img`,"aria-hidden":o,"aria-label":a,children:l}),t[4]=o,t[5]=a,t[6]=s,t[7]=u):u=t[7],u}var ZC=(0,Q.memo)(function(e){let t=(0,X.c)(19),{visible:n,onClick:r,edge:i,running:a}=e,o=i===void 0?`top`:i,s=a!==void 0&&a,c=h(QC),l;t[0]===c?l=t[1]:(l=y(c),t[0]=c,t[1]=l);let u=l,d=!n,f=o===`top`?`-top-2 -translate-y-full`:`bottom-2`,p=n?`opacity-100`:`opacity-0`,m;t[2]!==f||t[3]!==p?(m=Y(`pointer-events-none absolute inset-x-0 z-20 flex items-center justify-center transition-opacity duration-150 ease-out motion-reduce:transition-none`,f,p),t[2]=f,t[3]=p,t[4]=m):m=t[4];let g=n?`scale-100 opacity-100`:`pointer-events-none translate-y-1 scale-95 opacity-0`,_;t[5]===g?_=t[6]:(_=Y(`group relative pointer-events-auto flex size-11 sm:size-8 shrink-0 items-center justify-center rounded-full border border-edge-subtle bg-surface-overlay text-fg-muted shadow-surface`,`hover:border-edge-strong hover:text-fg`,ua.transition,ua.press,ua.focusRingPanel,g,`motion-reduce:translate-y-0 motion-reduce:scale-100`),t[5]=g,t[6]=_);let v=n?void 0:-1,b;t[7]===s?b=t[8]:(b=s?(0,Z.jsx)(`span`,{"data-scroll-to-bottom-running-logo":!0,className:`flex size-5 items-center justify-center`,"aria-hidden":!0,children:(0,Z.jsx)(XC,{className:`xopc-loop-logo--stream size-5`})}):(0,Z.jsx)(Qo,{"data-scroll-to-bottom-arrow":!0,className:`size-4 transition-transform duration-150 ease-out group-hover:translate-y-0.5 motion-reduce:transition-none`,strokeWidth:1.8,"aria-hidden":!0}),t[7]=s,t[8]=b);let x;t[9]!==u.chat.scrollToBottom||t[10]!==r||t[11]!==v||t[12]!==b||t[13]!==_?(x=(0,Z.jsx)(`button`,{type:`button`,className:_,tabIndex:v,onClick:r,title:u.chat.scrollToBottom,"aria-label":u.chat.scrollToBottom,children:b}),t[9]=u.chat.scrollToBottom,t[10]=r,t[11]=v,t[12]=b,t[13]=_,t[14]=x):x=t[14];let S;return t[15]!==x||t[16]!==d||t[17]!==m?(S=(0,Z.jsx)(`div`,{"data-scroll-to-bottom-dock":!0,"aria-hidden":d,className:m,children:x}),t[15]=x,t[16]=d,t[17]=m,t[18]=S):S=t[18],S});function QC(e){return e.language}function $C(e){let t=e.getBoundingClientRect();for(let n of e.querySelectorAll(`[data-chat-message-row]`)){let e=n.getBoundingClientRect(),r=n.dataset.messageRenderKey??n.dataset.clientSubmissionId;if(r&&e.bottom>t.top&&e.top<t.bottom)return{rowId:r,offset:e.top-t.top}}return null}function ew(e,t){if(!t)return!1;let n=Array.from(e.querySelectorAll(`[data-chat-message-row]`)).find(e=>e.dataset.messageRenderKey===t.rowId||e.dataset.clientSubmissionId===t.rowId);if(!n)return!1;let r=n.getBoundingClientRect().top-e.getBoundingClientRect().top-t.offset;return Math.abs(r)>.5&&(e.scrollTop+=r),!0}function tw(e){return e.webkitDirectionInvertedFromDevice===!0?e.deltaY>0:e.deltaY<0}function nw(e,t){return!e||!t||e.role!==t.role?!1:e===t?!0:e.renderKey&&t.renderKey?e.renderKey===t.renderKey:e.clientSubmissionId&&t.clientSubmissionId?e.clientSubmissionId===t.clientSubmissionId:e.timestamp!=null&&e.timestamp===t.timestamp&&e.turnId===t.turnId}function rw(e){let t=(0,X.c)(48),{hasToken:n,showSessionLoading:r,conversationId:i,chatMessages:a,streaming:o,hasMore:s,loadingMore:c,loadMoreMessages:l}=e,u=(0,Q.useRef)(null),d=(0,Q.useRef)(null),f=(0,Q.useRef)(null),p=(0,Q.useRef)(!0),m=(0,Q.useRef)(null),h=(0,Q.useRef)(null),g=(0,Q.useRef)(null),_=(0,Q.useRef)(null),v=(0,Q.useRef)(0),y=(0,Q.useRef)(0),b=(0,Q.useRef)(null),x=(0,Q.useRef)(null),S=(0,Q.useRef)(null),C=(0,Q.useRef)(null),w=(0,Q.useRef)(0),T=(0,Q.useRef)(0),[E,D]=(0,Q.useState)(!0),O=(0,Q.useRef)(!0),k=(0,Q.useRef)(0),A=(0,Q.useRef)(o),j;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(j={first:void 0,len:0,scrollHeight:0},t[0]=j):j=t[0];let M=(0,Q.useRef)(j),N;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>{p.current=e,e&&(S.current=null)},t[1]=N):N=t[1];let P=N,F;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(F=e=>{let t=u.current;if(!t)return;let n=PC(t);P(n),D(n),_.current=n?e:null,n||(S.current=$C(t))},t[2]=F):F=t[2];let I=F,L;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(L=()=>{let e=u.current,t=m.current;if(!e||!t||!p.current||!_.current&&!h.current)return!1;let n=_.current??h.current;if(!n)return!1;let r=!_.current&&g.current?.isConnected?g.current:Array.from(e.querySelectorAll(`[data-chat-message-row]`)).find(e=>e.dataset.messageRenderKey===n||e.dataset.clientSubmissionId===n);if(!r)return!1;_.current&&(h.current=n,g.current=r,_.current=null,v.current=Math.min(64,Math.max(0,e.clientHeight)*.1),y.current=v.current);let i=parseFloat(getComputedStyle(t.parentElement).paddingTop)||0,a=Math.max(i,t.getBoundingClientRect().top-r.getBoundingClientRect().bottom),o=Math.max(y.current,a),s=Math.min(v.current,Math.min(64,Math.max(0,e.clientHeight)*.1)),c=Math.max(0,Math.min(s,o-a));return y.current=a+c,t.style.height===`${c}px`?!1:(t.style.height=`${c}px`,!0)},t[3]=L):L=t[3];let R=L,z;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>{let t=u.current;if(!t||!e?.force&&!p.current)return;e?.force&&P(!0);let n=BC(t);if(n){n.end(!!e?.smooth),w.current=t.scrollHeight,T.current=t.clientHeight;return}if(e?.smooth){t.scrollTo({top:t.scrollHeight,behavior:LC()});return}FC(t),w.current=t.scrollHeight,T.current=t.clientHeight,D(PC(t))},t[4]=z):z=t[4];let B=z,V;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(V=()=>{let e=u.current;!e||e.scrollHeight<=e.clientHeight||(P(!1),D(PC(e)))},t[5]=V):V=t[5];let H=V,U;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(U=()=>{let e=u.current;if(!e)return;!p.current&&!BC(e)&&ew(e,S.current);let t=R(),n=e.scrollHeight>w.current,r=e.clientHeight<T.current;w.current=e.scrollHeight,T.current=e.clientHeight,(n||r||t)&&B(),D(PC(e))},t[6]=U):U=t[6];let W=U,G;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(G=()=>{let e=u.current;e&&p.current&&(BC(e)?FC(e):e.scrollHeight>w.current&&B()),C.current===null&&(C.current=requestAnimationFrame(()=>{C.current=null,W()}))},t[7]=G):G=t[7];let ee=G,te;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(te=e=>{if(f.current===e||(x.current?.disconnect(),b.current?.disconnect(),b.current=null,x.current=null,f.current=e,!e))return;let t=new ResizeObserver(ee);t.observe(e),x.current=t;let n=new MutationObserver(e=>{let t=u.current;!t||!p.current||!BC(t)||(R()||e.some(iw))&&FC(t)});n.observe(e,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:[`style`]}),b.current=n},t[8]=te):te=t[8];let ne=te,re,ie;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(re=()=>()=>{x.current?.disconnect(),b.current?.disconnect(),C.current!==null&&(cancelAnimationFrame(C.current),C.current=null)},ie=[],t[9]=re,t[10]=ie):(re=t[9],ie=t[10]),(0,Q.useEffect)(re,ie);let ae;t[11]!==s||t[12]!==l||t[13]!==c?(ae=()=>{let e=u.current;if(!e)return;let t=PC(e),n=T.current>0&&(e.scrollHeight!==w.current||e.clientHeight!==T.current);if(!t&&p.current&&n){D(!1),ee();return}P(t),t||(S.current=$C(e)),D(t),t&&R(),e.scrollTop<100&&!t&&s&&!c&&l()},t[11]=s,t[12]=l,t[13]=c,t[14]=ae):ae=t[14];let K=ae,oe;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(oe=e=>{B({force:!0,smooth:e===void 0||e})},t[15]=oe):oe=t[15];let se=oe,q,ce;t[16]!==n||t[17]!==r?(q=()=>{if(n){if(r){O.current=!0;return}O.current===!0&&(O.current=!1,P(!0),B({force:!0}))}},ce=[r,n,P,B],t[16]=n,t[17]=r,t[18]=q,t[19]=ce):(q=t[18],ce=t[19]),(0,Q.useLayoutEffect)(q,ce);let le;t[20]!==n||t[21]!==r?(le=()=>{!n||r||(M.current={first:void 0,len:0,scrollHeight:0},k.current=0,w.current=0,T.current=0,h.current=null,g.current=null,y.current=0,Array.from(u.current?.querySelectorAll(`[data-chat-message-row]`)??[]).some(e=>e.dataset.messageRenderKey===_.current||e.dataset.clientSubmissionId===_.current)||(_.current=null),m.current&&(m.current.style.height=`0px`),P(!0),B({force:!0}))},t[20]=n,t[21]=r,t[22]=le):le=t[22];let ue;t[23]!==i||t[24]!==n||t[25]!==r?(ue=[i,n,r,P,B],t[23]=i,t[24]=n,t[25]=r,t[26]=ue):ue=t[26],(0,Q.useLayoutEffect)(le,ue);let de,fe;t[27]!==a||t[28]!==r||t[29]!==o?(de=()=>{if(r)return;let e=A.current&&!o;A.current=o;let t=R(),n=a.length,i=k.current;k.current=n;let s=(u.current?.scrollHeight??0)>w.current;p.current&&(n>i||s||t||e)&&B()},fe=[a,o,r,B,R],t[27]=a,t[28]=r,t[29]=o,t[30]=de,t[31]=fe):(de=t[30],fe=t[31]),(0,Q.useLayoutEffect)(de,fe);let J,pe;t[32]!==a||t[33]!==r?(J=()=>{let e=u.current;if(!e||r)return;let t=M.current,n=a[0],i=a.length,o=e.scrollHeight,s=i-t.len;s>0&&t.len>0&&!nw(n,t.first)&&nw(a[s],t.first)&&!BC(e)&&t.scrollHeight>0&&!ew(e,S.current)&&(e.scrollTop+=o-t.scrollHeight),M.current={first:n,len:i,scrollHeight:o}},pe=[a,r],t[32]=a,t[33]=r,t[34]=J,t[35]=pe):(J=t[34],pe=t[35]),(0,Q.useLayoutEffect)(J,pe);let me,he;t[36]!==n||t[37]!==r?(me=()=>{if(!n||r)return;let e=u.current;if(!e)return;let t=new ResizeObserver(ee);t.observe(e);let i=e=>{Math.abs(e.deltaY)<Math.abs(e.deltaX)||Math.abs(e.deltaY)<.25||tw(e)&&H()},a=0,o=e=>{e.touches.length===1&&(a=e.touches[0].clientY)},s=e=>{if(e.touches.length!==1)return;let t=e.touches[0].clientY,n=t-a;a=t,n>2&&H()},c=t=>{if(t.button!==0)return;let n=e.offsetWidth-e.clientWidth;if(n<=0)return;let r=e.getBoundingClientRect();t.clientX>=r.right-n&&H()},l=()=>{let t=window.getSelection();!t||t.isCollapsed||!e.contains(t.anchorNode)||(H(),S.current=$C(e))},d=t=>{(t.target instanceof Element?t.target:null)?.closest(`button[aria-expanded="false"]:not([aria-haspopup]), summary`)&&(H(),S.current=$C(e))};return e.addEventListener(`chat-scroll-reading`,H),e.addEventListener(`wheel`,i,{passive:!0}),e.addEventListener(`pointerdown`,c),e.addEventListener(`touchstart`,o,{passive:!0}),e.addEventListener(`touchmove`,s,{passive:!0}),e.addEventListener(`click`,d,!0),document.addEventListener(`selectionchange`,l),()=>{t.disconnect(),e.removeEventListener(`chat-scroll-reading`,H),e.removeEventListener(`wheel`,i),e.removeEventListener(`pointerdown`,c),e.removeEventListener(`touchstart`,o),e.removeEventListener(`touchmove`,s),e.removeEventListener(`click`,d,!0),document.removeEventListener(`selectionchange`,l)}},he=[n,r,H,ee],t[36]=n,t[37]=r,t[38]=me,t[39]=he):(me=t[38],he=t[39]),(0,Q.useLayoutEffect)(me,he);let ge;t[40]===n?ge=t[41]:(ge=()=>{if(!n)return;let e=u.current,t=d.current;if(!e||!t)return;let r=()=>{let n=`${t.getBoundingClientRect().height+16}px`;e.style.paddingBottom=n,e.style.scrollPaddingBottom=n,ee()};r();let i=new ResizeObserver(r);return i.observe(t),()=>{i.disconnect(),e.style.removeProperty(`padding-bottom`),e.style.removeProperty(`scroll-padding-bottom`)}},t[40]=n,t[41]=ge);let _e;t[42]!==n||t[43]!==r?(_e=[n,r,ee],t[42]=n,t[43]=r,t[44]=_e):_e=t[44],(0,Q.useLayoutEffect)(ge,_e);let ve;return t[45]!==E||t[46]!==K?(ve={scrollRef:u,composerDockRef:d,atBottom:E,registerListContentRef:ne,scrollToBottom:se,onScroll:K,replySpaceRef:m,reserveReplySpace:I},t[45]=E,t[46]=K,t[47]=ve):ve=t[47],ve}function iw(e){return e.target instanceof HTMLElement&&e.target.hasAttribute(`data-virtuoso-scroller`)}var aw=256*1024,ow=new TextEncoder;function sw(e){return ow.encode(e).byteLength}function cw(e){return sw(e)<=262144?e:new TextDecoder().decode(ow.encode(e).subarray(0,aw),{stream:!0})}function lw(e){let t=512*1024,n=e.length>20,r=[];for(let i of e.slice(-20).reverse()){let e=i.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
61
+ `);if((i.content.some(e=>e.type!==`text`)||i.attachments?.length)&&(n=!0),!e)continue;if(t<=256){n=!0;continue}let a=ow.encode(e),o=a.byteLength+256>t?new TextDecoder().decode(a.subarray(0,t-256),{stream:!0}):e;o!==e&&(n=!0);let s=sw(o)+256;t-=s,r.unshift({role:i.role,content:[{type:`text`,text:o}],timestamp:i.timestamp,renderKey:i.renderKey?.slice(0,128)})}return{messages:r,truncated:n,bytes:512*1024-t}}var uw=`xopc:side-chat-panes:v3`,dw={text:``,attachments:[]};function fw(e){return Math.min(760,Math.max(360,Math.round(e)))}function pw(){return{panes:{},tabs:[],widthPx:520}}function mw(){try{let e=JSON.parse(sessionStorage.getItem(uw)||`{}`),t=e.identity;if(t&&t!==m.getState().conversationId)return pw();let n=Array.isArray(e.tabs)?e.tabs.filter(e=>!!(e?.id&&e.parentConversationId)):[],r=e.panes&&typeof e.panes==`object`?e.panes:{},i=Object.fromEntries(Object.entries(r).map(([e,t])=>{let r=n.filter(t=>t.parentConversationId===e),i=typeof t?.activeId==`string`&&r.some(e=>e.id===t.activeId)?t.activeId:r.at(-1)?.id??null;return[e,{open:t?.open===!0&&r.length>0,activeId:i}]}));for(let e of n)i[e.parentConversationId]??={open:!1,activeId:e.id};return{panes:i,tabs:n,widthPx:fw(typeof e.widthPx==`number`?e.widthPx:520)}}catch{return pw()}}function hw(e){try{sessionStorage.setItem(uw,JSON.stringify({...e,identity:m.getState().conversationId}))}catch{}}var gw=mw(),_w=_((e,t)=>{let n=n=>{e(n),queueMicrotask(()=>{let e=t();hw({panes:e.panes,tabs:e.tabs,widthPx:e.widthPx})})},r=(e,r)=>{let i=t().panes[e]??{open:!1,activeId:null};n({panes:{...t().panes,[e]:{...i,...r}}})};return{...gw,drafts:{},readings:{},setDraftText:(n,r)=>e({drafts:{...t().drafts,[n]:{...t().drafts[n]??dw,text:r}}}),setDraftAttachments:(n,r)=>e({drafts:{...t().drafts,[n]:{...t().drafts[n]??dw,attachments:r}}}),rememberMessages:(n,r)=>{let i={...t().readings};delete i[n],i[n]=lw(r),i[n].truncated||=t().readings[n]?.truncated??!1;let a=Object.values(i).reduce((e,t)=>e+t.bytes,0);for(;Object.keys(i).length>5||a>2097152;){let e=Object.keys(i)[0];a-=i[e].bytes,delete i[e]}e({readings:i})},markEnded:(e,r)=>n({tabs:t().tabs.map(t=>t.id===e?{...t,ended:r,runId:void 0}:t)}),markPromoted:(e,r)=>n({tabs:t().tabs.map(t=>t.id===e?{...t,ended:`promoted`,promotedConversationId:r,runId:void 0}:t)}),replaceTab:(r,i)=>{hi.getState().replaceSideChat(r,i.id,i.parentConversationId);let a=t();if(!a.tabs.some(e=>e.id===r))return;let o={...a.drafts,[i.id]:a.drafts[r]??dw},s={...a.readings};delete o[r],delete s[r],e({drafts:o,readings:s}),n({tabs:a.tabs.map(e=>e.id===r?{...i,fresh:!0}:e),panes:{...a.panes,[i.parentConversationId]:{open:a.panes[i.parentConversationId]?.open??!1,activeId:a.panes[i.parentConversationId]?.activeId===r?i.id:a.panes[i.parentConversationId]?.activeId??i.id}}})},reset:()=>{hi.getState().reset(),e({drafts:{},readings:{},pendingCreate:null,creatingRequests:{}}),n({panes:{},tabs:[]})},pendingCreate:null,creatingRequests:{},requestCreate:(n,i=[])=>{hi.getState().setOpen(!0,n),!(t().creatingRequests[n]||t().pendingCreate?.parentConversationId===n)&&(e({pendingCreate:{requestId:crypto.randomUUID(),parentConversationId:n,selections:i}}),r(n,{open:!0}))},claimPendingCreate:(n,r)=>{let i=t().pendingCreate;return!i||i.parentConversationId!==n||i.requestId!==r?null:(e({pendingCreate:null,creatingRequests:{...t().creatingRequests,[n]:r}}),i)},finishCreate:(n,r)=>{if(t().creatingRequests[n]!==r)return;let i={...t().creatingRequests};delete i[n],e({creatingRequests:i})},addTab:(e,r=!0)=>{hi.getState().addSideChat(e.id,e.title,e.parentConversationId,r);let i=[...t().tabs.filter(t=>t.id!==e.id),{...e,lastSelectedAt:Date.now()}],a=t().panes[e.parentConversationId]??{open:!1,activeId:null};n({tabs:i,panes:{...t().panes,[e.parentConversationId]:{...a,activeId:e.id,open:!0}}})},removeTab:r=>{let i=t().tabs.find(e=>e.id===r);if(!i)return;hi.getState().remove(`side:${r}`,i.parentConversationId);let a={...t().drafts},o={...t().readings};delete a[r],delete o[r],e({drafts:a,readings:o});let s=t().tabs.filter(e=>e.id!==r),c=s.filter(e=>e.parentConversationId===i.parentConversationId),l=t().panes[i.parentConversationId]??{open:!1,activeId:null},u=l.activeId===r?c.at(-1)?.id??null:l.activeId;n({tabs:s,panes:{...t().panes,[i.parentConversationId]:{open:c.length>0&&l.open,activeId:u}}})},setActive:e=>{let i=t().tabs.find(t=>t.id===e);i&&(hi.getState().activate(`side:${e}`,i.parentConversationId),n({tabs:t().tabs.map(t=>t.id===e?{...t,lastSelectedAt:Date.now()}:t)}),r(i.parentConversationId,{activeId:e,open:!0}))},setTabStatus:(n,r)=>{let i=t().tabs.find(e=>e.id===n);i&&(i.waiting!==r.waiting||i.disconnected!==r.disconnected||i.unread!==r.unread)&&e({tabs:t().tabs.map(e=>e.id===n?{...e,...r}:e)})},setTabRunId:(e,r)=>n({tabs:t().tabs.map(t=>t.id===e?{...t,runId:r}:t)}),setOpen:(e,n)=>{if(hi.getState().setOpen(n,e),!n){r(e,{open:n});return}let i=t(),a=i.tabs.filter(t=>t.parentConversationId===e&&!t.ended&&!t.promotedConversationId),o=a.find(t=>t.id===i.panes[e]?.activeId)??a.reduce((e,t)=>!e||(t.lastSelectedAt??0)>=(e.lastSelectedAt??0)?t:e,void 0);r(e,{open:n,activeId:o?.id??null}),o&&hi.getState().activate(`side:${o.id}`,e),o||i.requestCreate(e)},setWidthPx:e=>n({widthPx:fw(e)})}});m.subscribe((e,t)=>{if(e.conversationId&&!t.conversationId&&e.baseUrl===t.baseUrl){let e=mw();_w.setState(e)}if(e.baseUrl!==t.baseUrl||t.conversationId!==void 0&&e.conversationId!==t.conversationId){_w.getState().reset();try{sessionStorage.removeItem(`xopc:side-chat-client-id`)}catch{}}});function vw(e){return e.acceptsArgs?`/${e.name} `:`/${e.name}`}var yw=3e4,bw=null;function xw(e,t){return e.map(e=>({id:`file:${e.id}`,kind:`file`,name:e.name,description:e.path,relativePath:e.path,isDirectory:e.isDirectory,...t.has(e.path)?{isRecent:!0}:{},fileRef:{sourceId:e.id,expectedVersion:e.revision}}))}async function Sw(e,t){let n=t.conversationId?.trim(),r=t.agentId?.trim(),i=t.limit??15,a=e.trim(),o=t.recentPaths??new Set;if(n&&a.length===0){let e=Date.now();if(bw&&bw.key===n&&e-bw.at<yw)return bw.items.map(e=>({...e,...o.has(e.relativePath)?{isRecent:!0}:{isRecent:void 0}}))}let s={conversationId:n,agentId:r},c=xw(a.length===0?await Ra(``,s):await Ia(a,s,i),o);return n&&a.length===0&&(bw={key:n,at:Date.now(),items:c}),c}async function Cw(e,t){return Ra(e,{conversationId:t.conversationId,agentId:t.agentId})}function ww(e,...t){let n=e.trim().toLocaleLowerCase();return!n||t.some(e=>e?.toLocaleLowerCase().includes(n))}async function Tw(e){let t=await f(p(e)),n=await t.json().catch(()=>({}));if(!t.ok||!n.payload)throw Error(typeof n.error==`string`?n.error:`HTTP ${t.status}`);return n.payload}var Ew=[{kind:`file`,search:(e,t)=>Sw(e,{conversationId:t.conversationId,agentId:t.currentAgentId,limit:10,recentPaths:t.recentPaths})},{kind:`note`,async search(e,t){return(await Ve({...e.trim()?{search:e.trim()}:{},limit:5,sortBy:`updatedAt`,sortOrder:`desc`})).items.filter(e=>e.status!==`trashed`&&!t.selectedContextKeys.has(`note:${e.id}`)).map(e=>({id:`note:${e.id}`,kind:`note`,name:e.title?.trim()||e.snippet?.trim()||y(t.language).chat.commandPalette.untitledNote,description:e.snippet?.trim()||``,noteRef:{sourceId:e.id,expectedVersion:String(e.updatedAt)}}))}},{kind:`session`,async search(e,t){return(await pn({...e.trim()?{search:e.trim()}:{},limit:5,sortBy:`updatedAt`,sortOrder:`desc`})).items.filter(e=>e.key!==t.conversationId&&!t.selectedContextKeys.has(`session:${e.key}`)).map(e=>({id:`session:${e.key}`,kind:`session`,name:e.name?.trim()||e.key,description:`${e.messageCount} messages`,sessionRef:{sourceId:e.key,expectedVersion:e.updatedAt}}))}},{kind:`skill`,async search(e,t){return(await lo(t.currentAgentId,t.conversationId)).skills.flatMap(n=>{if(!n.availableForCurrentAgent)return[];let r=go(n,t.language);return ww(e,n.name,r.displayName,r.description,...r.searchTerms)?[{id:`skill:${n.name}`,kind:`skill`,name:r.displayName,description:r.description,canonicalName:n.name}]:[]}).slice(0,5)}},{kind:`agent`,async search(e,t){let n=await ri(),r=y(t.language).agentsSettings;return n.items.flatMap(t=>{let n=Ho(t,r),i=Uo(t,r);return ww(e,t.id,n,i)?[{id:`agent:${t.id}`,kind:`agent`,name:n,description:i,agentId:t.id,...t.avatar?{avatar:t.avatar}:{}}]:[]}).slice(0,5)}},{kind:`browser_tab`,async search(e,t){return(await Tw(`/api/browser/tabs?${new URLSearchParams({conversationId:t.conversationId})}`)).tabs.flatMap(n=>!ww(e,n.title,n.url)||t.selectedContextKeys.has(`browser_tab:${n.id}`)?[]:[{id:`browser-tab:${n.id}`,kind:`browser_tab`,name:n.title||n.url,description:n.url,url:n.url,tabRef:{sourceId:n.id,expectedVersion:n.documentId}}])}}],Dw=(0,Q.createContext)({target:null,register:()=>()=>{}});function Ow(e){let t=(0,X.c)(9),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],t[0]=r):r=t[0];let[i,a]=(0,Q.useState)(r),o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=e=>(a(t=>[...t,e]),()=>a(t=>t.filter(t=>t!==e))),t[1]=o):o=t[1];let s=o,c;t[2]===i?c=t[3]:(c=i.at(-1)??null,t[2]=i,t[3]=c);let l;t[4]===c?l=t[5]:(l={target:c,register:s},t[4]=c,t[5]=l);let u=l,d;return t[6]!==n||t[7]!==u?(d=(0,Z.jsx)(Dw,{value:u,children:n}),t[6]=n,t[7]=u,t[8]=d):d=t[8],d}function kw(){let e=(0,X.c)(2),{register:t}=(0,Q.useContext)(Dw),n;return e[0]===t?n=e[1]:(n=(0,Z.jsx)(`div`,{ref:t,className:`min-w-0 shrink-0`}),e[0]=t,e[1]=n),n}function Aw(){return(0,Q.useContext)(Dw).target}function jw({conversationId:e,turnId:t,messages:n,ready:r,hasMore:i,loadingMore:a,loadMore:o,reveal:s,onLocated:c}){let l=(0,Q.useRef)({key:``,finished:!1,requestedLength:-1});(0,Q.useEffect)(()=>{let u=`${e??``}:${t??``}`;if(l.current.key!==u&&(l.current={key:u,finished:!1,requestedLength:-1}),!t||!r||l.current.finished)return;let d=l.current,f=n.findIndex(e=>e.turnId===t);if(f>=0){let e=0,t=!1,n=0,r=()=>{t||l.current===d&&(s(f)?(d.finished=!0,c?.(!0)):++n<3?e=requestAnimationFrame(r):(d.finished=!0,c?.(!1)))};return e=requestAnimationFrame(r),()=>{t=!0,cancelAnimationFrame(e)}}if(!a){if(!i||l.current.requestedLength===n.length){l.current.finished=!0,c?.(!1);return}l.current.requestedLength=n.length,o().catch(()=>{l.current===d&&(d.finished=!0,c?.(!1))})}},[e,t,n,r,i,a,o,s,c])}function Mw(e){let t=(0,X.c)(24),{sk:n,onPick:r,disabled:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Bt,{className:`size-4`,"aria-hidden":!0}),t[0]=a):a=t[0];let o;t[1]===n.findCapability?o=t[2]:(o=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-sm text-accent-fg`,children:[a,n.findCapability]}),t[1]=n.findCapability,t[2]=o);let s;t[3]===n.findWelcome?s=t[4]:(s=(0,Z.jsx)(`h1`,{className:`text-xl font-semibold text-fg`,children:n.findWelcome}),t[3]=n.findWelcome,t[4]=s);let c;t[5]===n.findDescription?c=t[6]:(c=(0,Z.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:n.findDescription}),t[5]=n.findDescription,t[6]=c);let l;if(t[7]!==i||t[8]!==r||t[9]!==n.findExamples){let e;t[11]!==i||t[12]!==r?(e=e=>(0,Z.jsx)(mi,{disabled:i,onClick:()=>r(e),children:e},e),t[11]=i,t[12]=r,t[13]=e):e=t[13],l=n.findExamples.map(e),t[7]=i,t[8]=r,t[9]=n.findExamples,t[10]=l}else l=t[10];let d;t[14]===l?d=t[15]:(d=(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:l}),t[14]=l,t[15]=d);let f;t[16]===n.findBack?f=t[17]:(f=(0,Z.jsx)(u,{to:`/capabilities/skills`,className:`text-sm text-accent-fg hover:underline`,children:n.findBack}),t[16]=n.findBack,t[17]=f);let p;return t[18]!==o||t[19]!==s||t[20]!==c||t[21]!==d||t[22]!==f?(p=(0,Z.jsxs)(`section`,{className:`mx-auto flex max-w-xl flex-col items-start gap-4 py-8 sm:py-12`,children:[o,s,c,d,f]}),t[18]=o,t[19]=s,t[20]=c,t[21]=d,t[22]=f,t[23]=p):p=t[23],p}function Nw(e){let t=`/api/sessions/${encodeURIComponent(e)}/connection-wait`,n=Nn(t=>t.sessions[e]?.localDraft),{data:r,mutate:i,isLoading:a}=Kr(n?null:[t,n===!1?`persisted`:`unknown`],async()=>await Tr(e)?null:(await g(p(t))).payload,{refreshInterval:e=>e?.wait?5e3:0,revalidateOnFocus:!0}),o=(0,Q.useRef)(r);o.current=r;let s=(0,Q.useRef)(!1),c=(0,Q.useRef)(!1),l=(0,Q.useRef)(0),u=(0,Q.useRef)(null),[d,f]=(0,Q.useState)(!1),[m,_]=(0,Q.useState)(),[v,y]=(0,Q.useState)(),b=(0,Q.useCallback)(async(e,n,r,a,d)=>{let m=o.current,v=m?.wait;if(!v||(e===`cancel`?c.current:s.current||c.current))return!1;e===`cancel`?c.current=!0:s.current=!0,l.current+=1,f(!0),_(void 0),e===`cancel`&&y(void 0);let b=e===`connect`?qo():null,x=JSON.stringify([v.id,v.objectiveRevision,e,n,r,a,d]);u.current?.signature!==x&&(u.current={signature:x,key:crypto.randomUUID()});let S=u.current.key,C=i=>g(p(`${t}/actions`),{method:`POST`,body:JSON.stringify({action:e,needKey:n,accountId:r,candidateRef:a,instanceId:d,waitId:v.id,expectedTranscriptId:i.transcriptId,expectedVersion:i.wait.version,...e===`cancel`?{expectedObjectiveRevision:v.objectiveRevision}:{},idempotencyKey:S})});try{let n;try{n=await C(m)}catch(r){if(e!==`cancel`||r.status!==409)throw r;let a=(await g(p(t))).payload;if(await i(e=>!e||e.transcriptId!==a.transcriptId||a.revision>=e.revision?a:e,!1),a.transcriptId!==m.transcriptId||a.wait?.id!==v.id||a.wait.objectiveRevision!==v.objectiveRevision)throw r;n=await C(a)}let r=n.payload.snapshot;if(await i(e=>!e||e.transcriptId!==r.transcriptId||r.revision>=e.revision?r:e,!1),n.payload.authorizationUrl){if(!await Ko(n.payload.authorizationUrl,b))throw Error(`Unable to open the authorization window. Allow pop-ups, then retry.`)}else Jo(b);return u.current?.signature===x&&(u.current=null),!0}catch(t){if(Jo(b),t.status===409&&e===`cancel`){let e=h.getState().language===`zh`?`目标状态已变化,未能取消。请检查当前任务状态后再试。`:`The objective state changed and cancellation was not confirmed. Check its current status and try again.`;_(e),y(e)}else if(t.status!==409){let n=t instanceof Error?t.message:String(t);_(n),e===`cancel`&&y(n)}return await i(),!1}finally{e===`cancel`?c.current=!1:s.current=!1,--l.current,f(l.current>0)}},[t,i]);return(0,Q.useEffect)(()=>{let t=t=>{let n=t.detail;n?.conversationId===e&&(n.revision??1/0)>(o.current?.revision??0)&&i()};window.addEventListener(`session-connection-wait-changed`,t);let n=()=>{i()};return window.addEventListener(`gateway-realtime-connected`,n),()=>{window.removeEventListener(`session-connection-wait-changed`,t),window.removeEventListener(`gateway-realtime-connected`,n)}},[e,i]),{wait:r?.wait,isLoading:a,busy:d,error:m,cancellationError:v,act:b,dismissError:()=>{_(void 0),y(void 0)}}}function Pw(e){let t=(0,X.c)(39),{need:n,language:r,disabled:i,onSelect:a,onConnect:o}=e,s=(0,Q.useId)(),[c,l]=(0,Q.useState)(),u=r===`zh`,d;if(t[0]!==n.accounts||t[1]!==c){let e;t[3]===c?e=t[4]:(e=e=>e.id===c,t[3]=c,t[4]=e),d=n.accounts.some(e),t[0]=n.accounts,t[1]=c,t[2]=d}else d=t[2];let f=d,p=u?`这次使用哪个 ${n.label} 账号或工作区?`:`Which ${n.label} account or workspace should this request use?`,m;t[5]===p?m=t[6]:(m=(0,Z.jsx)(`legend`,{className:`float-left mb-3 w-full text-sm font-medium text-fg`,children:p}),t[5]=p,t[6]=m);let h;if(t[7]!==s||t[8]!==n.accounts||t[9]!==c){let e;t[11]!==s||t[12]!==c?(e=e=>(0,Z.jsxs)(`label`,{className:`flex min-h-11 cursor-pointer items-center gap-3 rounded-lg border px-3 py-2 text-sm text-fg hover:bg-surface-hover ${c===e.id?`border-accent bg-surface-hover`:`border-edge`}`,children:[(0,Z.jsx)(`input`,{type:`radio`,name:s,value:e.id,checked:c===e.id,onChange:()=>l(e.id),className:`shrink-0 accent-accent focus-visible:outline-2 focus-visible:outline-accent`}),(0,Z.jsx)(`span`,{className:`min-w-0 break-words`,children:e.label})]},e.id),t[11]=s,t[12]=c,t[13]=e):e=t[13],h=n.accounts.map(e),t[7]=s,t[8]=n.accounts,t[9]=c,t[10]=h}else h=t[10];let g;t[14]===h?g=t[15]:(g=(0,Z.jsx)(`div`,{className:`clear-both grid max-h-48 gap-2 overflow-y-auto sm:grid-cols-2`,children:h}),t[14]=h,t[15]=g);let _=u?`选择仅用于本次目标,选定后会自动继续。`:`This choice applies to this objective only. It will continue after selection.`,v;t[16]===_?v=t[17]:(v=(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:_}),t[16]=_,t[17]=v);let y=i||!f,b;t[18]!==a||t[19]!==c||t[20]!==f?(b=()=>{f&&c&&a(c)},t[18]=a,t[19]=c,t[20]=f,t[21]=b):b=t[21];let x=u?`使用所选账号并继续`:`Use selected account and continue`,S;t[22]!==x||t[23]!==y||t[24]!==b?(S=(0,Z.jsx)(`button`,{type:`button`,disabled:y,onClick:b,className:`min-h-11 rounded-lg bg-accent px-3 py-2 text-sm text-on-accent disabled:opacity-50`,children:x}),t[22]=x,t[23]=y,t[24]=b,t[25]=S):S=t[25];let C=u?`连接其他账号`:`Connect another account`,w;t[26]!==i||t[27]!==o||t[28]!==C?(w=(0,Z.jsx)(`button`,{type:`button`,disabled:i,onClick:o,className:`min-h-11 rounded-lg px-3 py-2 text-sm text-accent hover:bg-surface-hover disabled:opacity-50`,children:C}),t[26]=i,t[27]=o,t[28]=C,t[29]=w):w=t[29];let T;t[30]!==S||t[31]!==w?(T=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[S,w]}),t[30]=S,t[31]=w,t[32]=T):T=t[32];let E;return t[33]!==i||t[34]!==T||t[35]!==m||t[36]!==g||t[37]!==v?(E=(0,Z.jsxs)(`fieldset`,{disabled:i,className:`mt-3 min-w-0 space-y-3 border-t border-edge-subtle pt-3`,children:[m,g,v,T]}),t[33]=i,t[34]=T,t[35]=m,t[36]=g,t[37]=v,t[38]=E):E=t[38],E}var Fw=(0,Q.lazy)(()=>o(()=>import(`./mcp-conversation-setup-page-ZcY1nqMO.js`).then(e=>({default:e.McpConversationSetupDialog})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29])));function Iw(e){let t=(0,X.c)(35),{conversationId:n}=e,r=h(zw),[i,a]=l(),o;t[0]===i?o=t[1]:(o=i.get(`mcpSetup`),t[0]=i,t[1]=o);let s=o,c;t[2]!==i||t[3]!==a?(c=e=>{let t=new URLSearchParams(i);e?t.set(`mcpSetup`,e):t.delete(`mcpSetup`),a(t,{replace:!e})},t[2]=i,t[3]=a,t[4]=c):c=t[4];let d=c,f;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(f={refreshInterval:Lw,shouldRetryOnError:!1},t[5]=f):f=t[5];let{data:p,mutate:m}=Kr(`/api/mcp/setup/conversations/${encodeURIComponent(n)}`,Rw,f),g;t[6]!==n||t[7]!==p?.permitted||t[8]!==m?(g=()=>{if(p?.permitted===!1)return;let e=e=>{let t=e.detail;(t?.conversationId??t?.key)===n&&m()},t=()=>{m()};return window.addEventListener(`session-mcp-setup-changed`,e),window.addEventListener(`session-transcript-updated`,e),window.addEventListener(`gateway-realtime-connected`,t),()=>{window.removeEventListener(`session-mcp-setup-changed`,e),window.removeEventListener(`session-transcript-updated`,e),window.removeEventListener(`gateway-realtime-connected`,t)}},t[6]=n,t[7]=p?.permitted,t[8]=m,t[9]=g):g=t[9];let _=p?.permitted,v;t[10]!==n||t[11]!==m||t[12]!==_?(v=[n,m,_],t[10]=n,t[11]=m,t[12]=_,t[13]=v):v=t[13],(0,Q.useEffect)(g,v);let y;t[14]!==m||t[15]!==s||t[16]!==d?(y=s?(0,Z.jsx)(Q.Suspense,{fallback:null,children:(0,Z.jsx)(Fw,{setupId:s,onClose:()=>{d(null),m()}})}):null,t[14]=m,t[15]=s,t[16]=d,t[17]=y):y=t[17];let b=y;if(!p?.setup)return b;let x=p.setup,S=r===`zh`?`服务连接`:`Service connection`,C=x.expired?r===`zh`?`连接请求已过期`:`Connection request expired`:r===`zh`?`连接`:`Connect`,w=x.displayName||x.serverId,T;t[18]!==w||t[19]!==C?(T=(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 break-all text-sm text-fg`,role:`status`,children:[C,` `,w]}),t[18]=w,t[19]=C,t[20]=T):T=t[20];let E=`/mcp-setup/${encodeURIComponent(x.setupId)}`,D;t[21]!==d||t[22]!==x.setupId?(D=e=>{e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),d(x.setupId))},t[21]=d,t[22]=x.setupId,t[23]=D):D=t[23];let O=r===`zh`?`完成连接`:`Complete connection`,k;t[24]!==E||t[25]!==D||t[26]!==O?(k=(0,Z.jsx)(u,{className:`inline-flex min-h-11 items-center rounded-lg px-3 text-sm text-accent-fg hover:bg-surface-hover`,to:E,onClick:D,children:O}),t[24]=E,t[25]=D,t[26]=O,t[27]=k):k=t[27];let A;t[28]!==T||t[29]!==k||t[30]!==S?(A=(0,Z.jsxs)(`section`,{className:`mb-2 flex flex-wrap items-center gap-3 rounded-xl border border-edge bg-surface-panel px-3 py-2`,"aria-label":S,children:[T,k]}),t[28]=T,t[29]=k,t[30]=S,t[31]=A):A=t[31];let j;return t[32]!==b||t[33]!==A?(j=(0,Z.jsxs)(Z.Fragment,{children:[A,b]}),t[32]=b,t[33]=A,t[34]=j):j=t[34],j}function Lw(e){return e?.setup?5e3:0}async function Rw(e){try{return{permitted:!0,...(await g(p(e))).payload}}catch(e){let t=e;if([403,404].includes(t.status??0))return{permitted:!1,setup:null};throw t}}function zw(e){return e.language}var Bw={zh:{waiting:`等待连接`,install:`安装`,installing:`正在准备安装`,connect:`连接`,reconnect:`重新连接`,details:`查看详情`,skip:`跳过连接`,cancel:`取消这个目标`,ready:`已连接`,check:`我已完成授权`,authorizing:`等待完成授权`,queued:`已连接,等待继续`,queuedSkipped:`等待使用现有信息继续`,checkingConnection:`正在检查连接`,checkingTools:`已连接,正在验证工具`,queueHint:`目标已保存,正在等待当前执行结束。`,interruptedInputHint:`有条补充消息在重启时中断。请重新发送要求,或移除上方中断的消息后继续。`,checkFailed:`连接检查暂时失败,目标已保存`,interrupted:`恢复检查曾中断,目标已保存`,lastChecked:`最近检查`,scope:`确认后继续`,scopeHint:`这个目标已等待了一段时间。请确认仍要按下方原始要求继续;如需修改时间范围,请先在聊天中说明。未读等条件将以实际执行时为准。`,account:`选择账号`,all:`查看全部连接`,close:`关闭`,intro:`完成连接后,将自动恢复当前目标。你也可以继续发送消息。`,callbackHint:`远程 Gateway 无法接收本地回调时,粘贴浏览器地址栏中的完整回调 URL。`,callbackPlaceholder:`完整回调 URL`,callbackSubmit:`完成连接`,replace:`更换应用`,confirmReplace:`确认改用`,apps:`个应用需要连接`,preserved:`目标已保留`,retry:`重试检查`,toolsUnavailable:`应用工具暂不可用`,toolsHint:`账号已连接,当前无法使用任务所需工具。可以重试检查,无需重新授权。`},en:{waiting:`Waiting for connection`,install:`Install`,installing:`Preparing installation`,connect:`Connect`,reconnect:`Reconnect`,details:`Details`,skip:`Skip connection`,cancel:`Cancel this objective`,ready:`Connected`,check:`Check authorization`,authorizing:`Waiting for authorization`,queued:`Connected, waiting to continue`,queuedSkipped:`Waiting to continue with available information`,checkingConnection:`Checking connection`,checkingTools:`Connected, checking tools`,queueHint:`Your objective is saved. Waiting for the current execution to finish.`,interruptedInputHint:`A message was interrupted during restart. Resend the requirement or remove the interrupted message above before continuing.`,checkFailed:`Connection check failed; objective saved`,interrupted:`Recovery check interrupted; objective saved`,lastChecked:`Last checked`,scope:`Confirm and continue`,scopeHint:`This objective has been waiting for a while. Confirm the original request below, or send a message to change the time range first. Conditions such as unread status are evaluated at execution time.`,account:`Choose an account`,all:`View all connections`,close:`Close`,intro:`The current objective resumes automatically after connecting. You can keep sending messages.`,callbackHint:`If a remote Gateway cannot receive the local callback, paste the complete callback URL from the browser address bar.`,callbackPlaceholder:`Complete callback URL`,callbackSubmit:`Complete connection`,replace:`Change app`,confirmReplace:`Confirm switch to`,apps:`apps need connecting`,preserved:`Objective preserved`,retry:`Retry check`,toolsUnavailable:`App tools unavailable`,toolsHint:`The account is connected, but the tools needed for this task are unavailable. Retry the check without reconnecting.`}},Vw=`rounded-lg border border-edge px-3 py-1.5 text-sm text-fg hover:bg-surface-hover disabled:opacity-50`,Hw=`rounded-lg bg-accent px-3 py-1.5 text-sm text-on-accent disabled:opacity-50`;function Uw({conversationId:e}){let{wait:t,busy:n,error:r,cancellationError:i,act:a,dismissError:o}=Nw(e),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(),[d,f]=(0,Q.useState)(),[p,m]=(0,Q.useState)(),[g,_]=(0,Q.useState)(!1),[v,x]=(0,Q.useState)(),O=h(e=>e.language),k=Bw[O];if(!t)return i?(0,Z.jsxs)(`div`,{role:`alert`,className:`mb-2 flex items-center gap-2 rounded-xl border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,children:[(0,Z.jsx)(`p`,{className:`min-w-0 flex-1`,children:i}),(0,Z.jsx)(`button`,{type:`button`,onClick:o,className:Vw,children:k.close})]}):(0,Z.jsx)(Iw,{conversationId:e});let A=t.needs[0],j=t.needs.length===1,M=t.phase===`queued`,N=t.recoveryStage===`checking_connection`||t.recoveryStage===`checking_tools`,P=t.needs.find(e=>e.phase===`choose_account`),F=t.needs.some(e=>e.capabilityError);if(t.phase===`ready`&&!N&&!t.recoveryError)return(0,Z.jsx)(Iw,{conversationId:e});let I=t.recoveryStage===`checking_connection`?k.checkingConnection:t.recoveryStage===`checking_tools`?k.checkingTools:M?t.resolution===`skipped`?k.queuedSkipped:k.queued:t.recoveryError===`check_failed`?k.checkFailed:t.recoveryError?k.interrupted:F?k.toolsUnavailable:P?k.account:j&&A.phase===`authorizing`?k.authorizing:k.waiting,L=M||N?k.details:t.recoveryError?k.retry:t.phase===`review_scope`?k.scope:j&&A.phase===`install`?g?k.installing:`${k.install} ${A.label}`:j&&A.phase===`connect`?O===`zh`?`连接 ${A.label}`:`Connect ${A.label}`:j&&A.phase===`reconnect`?k.reconnect:j&&A.phase===`authorizing`?k.check:k.details;async function R(e=A){if(e.target.type===`store-connector`){_(!0),x(void 0);try{let t=await ha(e.target.packageName,e.target.version);if(t.reviewHash!==e.target.reviewHash||t.definition.id!==e.target.connectorId||t.definition.provenance?.sha256!==e.target.sha256)throw Error(O===`zh`?`Connector 包在审查后发生了变化,请重新发起推荐。`:`The Connector package changed after review. Request a new recommendation.`);f(Tt(t.definition,{packageName:t.packageName,version:t.version,reviewHash:t.reviewHash,permissions:t.permissions})),m(e.key)}catch(e){x(e instanceof Error?e.message:String(e))}finally{_(!1)}}}function z(){M||N?c(!0):t?.recoveryError?a(`check`):t?.phase===`review_scope`?c(!0):j&&A.phase===`install`?R():j&&[`connect`,`reconnect`].includes(A.phase)?a(`connect`,A.key):j&&A.phase===`authorizing`?a(`check`):c(!0)}return(0,Z.jsxs)(`section`,{className:`mb-2 rounded-xl border border-edge bg-surface-panel px-3 py-2`,"aria-label":I,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(qe,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,Z.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left text-sm text-fg`,onClick:()=>c(!0),children:[(0,Z.jsx)(`span`,{role:`status`,children:j?`${I} · ${A.label}`:`${I} · ${t.needs.length} ${k.apps}`}),(0,Z.jsx)(ne,{className:`ml-1 inline size-3`,"aria-hidden":!0})]}),(0,Z.jsxs)(`button`,{type:`button`,className:P||M||N?Vw:Hw,disabled:n&&!N||g,onClick:z,children:[n&&(0,Z.jsx)(Xe,{className:`mr-1 inline size-3 animate-spin`,"aria-hidden":!0}),L]}),!M&&!N&&(0,Z.jsx)(`button`,{type:`button`,className:`text-xs text-fg-muted hover:text-fg`,disabled:n,onClick:()=>void a(`skip`),children:k.skip}),(0,Z.jsx)(`button`,{type:`button`,className:`min-h-11 px-2 text-xs text-fg-muted hover:text-fg`,onClick:()=>void a(`cancel`),children:k.cancel})]}),t.queueBlocked&&(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.blockedInputId?k.interruptedInputHint:k.queueHint}),t.lastCheckedAt&&(0,Z.jsxs)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:[k.lastChecked,`: `,new Date(t.lastCheckedAt).toLocaleTimeString(O===`zh`?`zh-CN`:`en-US`)]}),P&&!M&&(0,Z.jsx)(`p`,{className:`mt-2 line-clamp-2 break-words text-sm text-fg-muted`,children:t.summary}),P&&!M&&(0,Z.jsx)(Pw,{need:P,language:O,disabled:n||N,onSelect:e=>void a(`select_account`,P.key,e),onConnect:()=>void a(`connect`,P.key)},`${t.id}:${t.objectiveRevision}:${P.key}`),(r||v)&&(0,Z.jsxs)(`p`,{role:`alert`,className:`mt-2 text-xs text-fg-muted`,children:[r??v,` `,(0,Z.jsx)(`button`,{type:`button`,className:`text-accent`,onClick:()=>void a(`check`),children:k.retry})]}),(0,Z.jsx)(D,{open:s,onOpenChange:c,children:(0,Z.jsxs)(w,{children:[(0,Z.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[2px]`}),(0,Z.jsxs)(T,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(90dvh,34rem)] w-[min(94vw,34rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-5 py-4`,children:[(0,Z.jsx)(E,{className:`font-medium text-fg`,children:k.preserved}),(0,Z.jsx)(C,{"aria-label":k.close,children:(0,Z.jsx)(qt,{className:`size-4`})})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto p-5`,children:[(0,Z.jsx)(S,{className:`text-sm text-fg-muted`,children:F?k.toolsHint:t.phase===`review_scope`?k.scopeHint:k.intro}),(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap rounded-lg border border-edge p-3 text-sm text-fg`,children:t.summary}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:new Date(t.objectiveUpdatedAt).toLocaleString(O===`zh`?`zh-CN`:`en-US`)}),t.timeRange&&(0,Z.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[new Date(t.timeRange.from).toLocaleString(O,{timeZone:t.timeRange.timezone}),` – `,new Date(t.timeRange.to).toLocaleString(O,{timeZone:t.timeRange.timezone}),` (`,t.timeRange.timezone,`)`]}),t.needs.map(e=>(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-edge p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`span`,{className:`text-sm font-medium text-fg`,children:[e.label,e.accountSelector?` · ${e.accountSelector}`:``]}),e.capabilityError?(0,Z.jsx)(`button`,{type:`button`,disabled:n||M,className:Vw,onClick:()=>void a(`check`),children:k.retry}):e.phase===`ready`?(0,Z.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[(0,Z.jsx)(ee,{className:`mr-1 inline size-3`}),k.ready]}):e.phase===`authorizing`?(0,Z.jsx)(`button`,{type:`button`,disabled:n,className:Vw,onClick:()=>void a(`check`),children:k.check}):e.phase===`install`?(0,Z.jsx)(`button`,{type:`button`,disabled:n||M||g,className:Hw,onClick:()=>void R(e),children:k.install}):e.phase!==`blocked`&&e.phase!==`choose_account`?(0,Z.jsx)(`button`,{type:`button`,disabled:n||M,className:Hw,onClick:()=>void a(`connect`,e.key),children:e.phase===`reconnect`?k.reconnect:k.connect}):null]}),e.accountId&&(0,Z.jsx)(`p`,{className:`break-words text-xs text-fg-muted`,children:e.accounts.find(t=>t.id===e.accountId)?.label??e.accountId}),e.alternatives?.length?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(le,{value:l?.needKey===e.key?l.candidateRef:``,options:e.alternatives.map(e=>({value:e.candidateRef,label:e.label})),placeholder:k.replace,ariaLabel:`${e.label}: ${k.replace}`,disabled:n||M,allowEmpty:!1,onChange:t=>u({needKey:e.key,candidateRef:t,label:e.alternatives.find(e=>e.candidateRef===t).label})}),l?.needKey===e.key&&(0,Z.jsxs)(`button`,{type:`button`,className:Vw,disabled:n,onClick:()=>{a(`replace_source`,e.key,void 0,l.candidateRef),u(void 0)},children:[k.confirmReplace,` `,l.label]})]}):null,e.reason&&(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.reason}),e.phase===`authorizing`&&(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:k.authorizing}),(0,Z.jsx)(`button`,{type:`button`,disabled:n,className:`text-accent`,onClick:()=>void a(`connect`,e.key),children:k.reconnect})]})]},e.key)),(0,Z.jsx)(`a`,{href:`#/capabilities/connectors`,className:`text-sm text-accent`,onClick:()=>c(!1),children:k.all})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-t border-edge p-4`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`min-h-11 text-sm text-fg-muted`,onClick:()=>void a(`cancel`),children:k.cancel}),t.phase===`review_scope`?(0,Z.jsx)(`button`,{type:`button`,disabled:n||M,className:Hw,onClick:()=>void a(`confirm_scope`),children:k.scope}):null]})]})]})}),d?(0,Z.jsx)(Et,{draft:d,onChange:f,onClose:()=>{f(void 0),m(void 0)},onInstalled:async e=>{p&&await a(`install_complete`,p,void 0,void 0,e.instanceId)&&(f(void 0),m(void 0))},t:y(O).connectorsSettings}):null]})}var Ww=new Set([`button`,`checkbox`,`color`,`file`,`hidden`,`image`,`radio`,`range`,`reset`,`submit`]);function Gw(e){if(!(e instanceof Element))return!1;if(e.closest(`textarea, select, [role="textbox"]`)||e instanceof HTMLElement&&e.isContentEditable)return!0;let t=e.closest(`input`);return t instanceof HTMLInputElement&&!Ww.has(t.type)}function Kw(){return!!document.querySelector(`dialog[open], [aria-modal="true"], [role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]`)}function qw(e,t){return t.disabled||t.editorHidden||e.defaultPrevented||Gw(e.target)||Gw(document.activeElement)?!1:!Kw()}function Jw(e){for(let t=e.parentElement;t;t=t.parentElement)if(/(auto|scroll)/.test(getComputedStyle(t).overflowY))return t;return null}function Yw({items:e,disabled:t,onReorder:n}){let r=(0,Q.useRef)(null),i=(0,Q.useRef)(null),a=(0,Q.useRef)(0),o=(0,Q.useRef)(null),s=(0,Q.useRef)({items:e,onReorder:n});s.current={items:e,onReorder:n};let[c,l]=(0,Q.useState)(null),u=e.map(e=>`${e.id}:${e.version}:${e.status}`).join(`|`);function d(){let e=i.current;e&&(cancelAnimationFrame(e.frame),e.overlay?.remove(),e.row.hasPointerCapture?.(e.pointerId)&&e.row.releasePointerCapture(e.pointerId),e.overlay&&(a.current=Date.now()+250,document.body.style.cursor=e.cursor,document.body.style.userSelect=e.userSelect),i.current=null,o.current&&clearTimeout(o.current),o.current=null)}(0,Q.useEffect)(()=>(l(null),d),[u,t]);function f(e){let t=(e.scroller?.scrollTop??0)-e.initialScroll,n=e.y-e.offsetY+e.slots[e.from].height/2,r=e.slots.filter((r,i)=>i!==e.from&&n>r.top-t+r.height/2).length;e.to=r;let i=[...e.slots];i.splice(r,0,i.splice(e.from,1)[0]);let a={},o=0,s=e.allSlots[0].top;e.allSlots.forEach((t,n)=>{let r=t.sortable?i[o++]:t;a[r.id]=s-r.top,r.id===e.id&&(e.landingTop=s);let c=e.allSlots[n+1];s+=r.height+(c?c.top-t.top-t.height:0)}),l(t=>t?.id===e.id&&t.targetId===e.slots[r].id?t:{id:e.id,targetId:e.slots[r].id,shifts:a})}function p(e){if(i.current!==e||!e.overlay)return;let t=e.scroller;if(t){let n=t.getBoundingClientRect(),r=Math.min(32,n.height/4),i=e.y<n.top+r?-Math.min(8,(n.top+r-e.y)/4):e.y>n.bottom-r?Math.min(8,(e.y-n.bottom+r)/4):0;i&&(t.scrollTop+=i,f(e))}e.frame=requestAnimationFrame(()=>p(e))}function m(e,n){if(t||n.status!==`queued`||e.button!==0||i.current)return;let a=e.target;if(a.closest(`button, a, input`)&&!a.closest(`[data-follow-up-drag-surface]`)||e.pointerType===`touch`&&!a.closest(`[data-follow-up-drag-handle]`))return;let o=e.currentTarget,s=o.getBoundingClientRect(),c=Array.from(r.current?.querySelectorAll(`[data-follow-up-id]`)??[]).map(e=>{let t=e.getBoundingClientRect();return{id:e.dataset.followUpId,top:t.top,height:t.height,sortable:e.dataset.followUpSortable===`true`}}),l=c.filter(e=>e.sortable);if(l.length<2)return;let u=l.findIndex(e=>e.id===n.id);if(u<0)return;let d=Jw(o);i.current={pointerId:e.pointerId,id:n.id,row:o,startX:e.clientX,startY:e.clientY,x:e.clientX,y:e.clientY,left:s.left,top:s.top,offsetY:e.clientY-s.top,slots:l,allSlots:c,landingTop:s.top,from:u,to:u,scroller:d,initialScroll:d?.scrollTop??0,overlay:null,frame:0,cursor:document.body.style.cursor,userSelect:document.body.style.userSelect}}function h(e){let t=i.current;if(!(!t||t.pointerId!==e.pointerId||o.current)&&(t.x=e.clientX,t.y=e.clientY,!(!t.overlay&&Math.hypot(t.x-t.startX,t.y-t.startY)<5))){if(e.preventDefault(),!t.overlay){t.row.setPointerCapture?.(t.pointerId);let e=t.row.cloneNode(!0);e.removeAttribute(`data-follow-up-id`),e.removeAttribute(`data-follow-up-sortable`),e.setAttribute(`data-follow-up-drag-overlay`,``),e.setAttribute(`aria-hidden`,`true`),e.setAttribute(`inert`,``),e.querySelectorAll(`[id]`).forEach(e=>e.removeAttribute(`id`)),Object.assign(e.style,{position:`fixed`,left:`${t.left}px`,top:`${t.top}px`,width:`${t.row.getBoundingClientRect().width}px`,height:`${t.slots[t.from].height}px`,zIndex:`60`,pointerEvents:`none`,margin:`0`,opacity:`1`,background:`var(--color-surface-overlay)`,border:`1px solid var(--color-edge-strong)`,boxShadow:`var(--shadow-popover)`,willChange:`transform`,transition:`none`}),document.body.append(e),t.overlay=e,document.body.style.cursor=`grabbing`,document.body.style.userSelect=`none`,t.frame=requestAnimationFrame(()=>p(t))}t.overlay.style.transform=`translate3d(${t.x-t.startX}px, ${t.y-t.startY}px, 0) scale(1.015)`,f(t)}}function g(e){let t=i.current;if(!t||o.current)return;if(!t.overlay){d();return}a.current=Date.now()+250,cancelAnimationFrame(t.frame);let n=e?t.landingTop:t.top,r=(t.scroller?.scrollTop??0)-t.initialScroll,c=window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches;if(t.overlay.style.transition=c?`none`:`transform 160ms ease-out, opacity 160ms ease-out`,t.overlay.style.transform=`translate3d(0, ${n-r-t.top}px, 0) scale(1)`,o.current=setTimeout(()=>{d(),l(null)},c?0:170),e&&t.to!==t.from){let e=s.current.items.findIndex(e=>e.id===t.id),n=s.current.items.findIndex(e=>e.id===t.slots[t.to].id);e>=0&&n>=0&&s.current.onReorder(e,n)}}return(0,Q.useEffect)(()=>{let e=e=>{e.key===`Escape`&&i.current&&(e.preventDefault(),d(),l(null))},t=()=>{d(),l(null)},n=e=>h(e),r=e=>{e.pointerId===i.current?.pointerId&&g(!0)},a=e=>{e.pointerId===i.current?.pointerId&&g(!1)};return window.addEventListener(`pointermove`,n,{passive:!1}),window.addEventListener(`pointerup`,r),window.addEventListener(`pointercancel`,a),window.addEventListener(`keydown`,e),window.addEventListener(`blur`,t),window.addEventListener(`resize`,t),()=>{window.removeEventListener(`pointermove`,n),window.removeEventListener(`pointerup`,r),window.removeEventListener(`pointercancel`,a),window.removeEventListener(`keydown`,e),window.removeEventListener(`blur`,t),window.removeEventListener(`resize`,t)}},[]),{listRef:r,view:c,onPointerDown:m,onClickCapture:e=>{Date.now()<a.current&&(e.preventDefault(),e.stopPropagation())}}}function Xw(e){return e.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;if(typeof t.id!=`string`||typeof t.clientMessageId!=`string`||typeof t.content!=`string`||typeof t.version!=`number`||t.effectiveDelivery!==`next`&&t.effectiveDelivery!==`steer`||t.status!==`queued`&&t.status!==`interrupted`)return[];let n=Array.isArray(t.contextRefs)?t.contextRefs.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;return t.kind!==`note`&&t.kind!==`file`&&t.kind!==`session`&&t.kind!==`browser_tab`||typeof t.sourceId!=`string`||typeof t.version!=`string`||typeof t.title!=`string`?[]:[{...typeof t.refId==`string`?{refId:t.refId}:{},kind:t.kind,sourceId:t.sourceId,expectedVersion:t.version,title:t.title,...t.kind===`file`&&(t.fileKind===`file`||t.fileKind===`directory`)?{fileKind:t.fileKind}:{}}]}):void 0;return[{id:t.id,clientMessageId:t.clientMessageId,text:t.content,attachments:Array.isArray(t.attachments)?t.attachments:void 0,thinkingLevel:typeof t.thinking==`string`?t.thinking:void 0,contextRefs:n?.length?n:void 0,version:t.version,delivery:t.effectiveDelivery,status:t.status}]})}function Zw(e){let t=Xw(e.inputs);if(!e.control?.paused&&!e.activeRunId&&e.preparation?.state!==`preparation_failed`){let e=t.findIndex(e=>e.status===`queued`);e>=0&&t.splice(e,1)}return t}var Qw=(0,Q.memo)(function({items:e,disabled:t,editingFollowUpId:n,onEditInComposer:r,onRemove:i,onMove:a,onReorder:o,onSteer:s,onSendSingle:c,queuePaused:l=!1,queueIdle:u=!1,steeringBusyId:d,onOpenSideChat:f}){let p=y(h(e=>e.language)),m=(0,Q.useRef)(!1),g=e.filter(e=>e.status===`queued`),_=!!(t||d),v=Yw({items:e,disabled:_,onReorder:o}),b=Y(`inline-flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-lg px-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:pointer-events-none disabled:opacity-35`,ua.focusRingPanel),x=`flex cursor-pointer items-center gap-2 rounded-md px-3 py-2 text-sm text-fg outline-none focus:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-35`;return e.length===0?null:(0,Z.jsxs)(`div`,{ref:v.listRef,className:`space-y-1 px-2 py-2`,onClickCapture:v.onClickCapture,role:`list`,"aria-label":p.chat.followUpQueueAria,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2 pb-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:p.chat.followUpQueueHeading}),(0,Z.jsxs)(`span`,{className:`tabular-nums text-[0.65rem] text-fg-muted`,children:[e.length,`/`,10]})]}),e.map(e=>{let t=e.status===`queued`,o=t||e.status===`interrupted`,h=g.findIndex(t=>t.id===e.id),y=u&&(l||e.status===`interrupted`),S=o&&!!(e.text.trim()||e.attachments?.length||e.contextRefs?.length),C=o&&!e.attachments?.length&&!e.contextRefs?.length&&e.text.trim().length>0,w=d===e.id,T=e.status===`interrupted`?p.chat.followUpStatusInterrupted:null,E=vr(e.text),D=new Map(e.contextRefs?.flatMap(e=>e.refId?[[e.refId,e.title]]:[])??[]),O=new Set(E?xr(E):[]),k=e.contextRefs?.filter(e=>!e.refId||!O.has(e.refId)),A=Jn(E?Cr(E,e=>D.get(e)):e.text).trim();return!A&&e.attachments?.length&&(A=e.attachments[0]?.name?.trim()||p.chat.followUpQueueAttachmentOnly),A||=p.chat.followUpQueueEmptyPreview,(0,Z.jsxs)(`div`,{role:`listitem`,"data-follow-up-id":e.id,"data-follow-up-sortable":!_&&t,onPointerDown:t=>v.onPointerDown(t,e),onDragStart:e=>e.preventDefault(),style:{transform:v.view?.shifts[e.id]?`translateY(${v.view.shifts[e.id]}px)`:void 0},className:Y(`relative flex min-h-10 items-center gap-1 rounded-lg px-1.5 py-1 motion-safe:transition-transform motion-safe:duration-150`,!_&&t&&`cursor-grab`,v.view?.id===e.id&&`bg-surface-inset ring-1 ring-inset ring-edge-strong [&>*]:invisible`,n===e.id?`bg-accent-soft ring-1 ring-inset ring-accent/30`:`hover:bg-surface-hover/50`),children:[(0,Z.jsx)(`div`,{"data-follow-up-drag-handle":!0,className:Y(`flex shrink-0 touch-none cursor-grab items-center active:cursor-grabbing`,(_||!t)&&`cursor-not-allowed opacity-40`),title:p.chat.followUpQueueDrag,children:(0,Z.jsx)(cs,{className:`size-3.5 text-fg-muted`,"aria-hidden":!0})}),(0,Z.jsx)(`button`,{type:`button`,"data-follow-up-drag-surface":!0,disabled:_||!t,title:p.chat.followUpQueueClickToEdit,"aria-label":p.chat.followUpQueueClickToEdit,className:Y(`min-h-8 min-w-0 flex-1 cursor-grab rounded-md px-1.5 text-left text-sm text-fg`,ua.focusRingPanel,`disabled:pointer-events-none disabled:opacity-50`),onClick:()=>r(e.id),children:e.attachments?.length?(0,Z.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1`,children:[(0,Z.jsx)(we,{className:`size-3 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate`,children:A})]}):(0,Z.jsx)(`span`,{className:`line-clamp-2 break-words [overflow-wrap:anywhere]`,children:A})}),k?.length?(0,Z.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-0.5 rounded bg-accent-soft px-1.5 py-0.5 text-[0.625rem] text-accent-fg`,title:k.map(e=>e.title).join(`, `),children:[(0,Z.jsx)(ms,{className:`size-3`,"aria-hidden":!0}),k.length]}):null,T?(0,Z.jsx)(`span`,{className:`shrink-0 rounded bg-surface-panel px-1.5 py-0.5 text-[0.625rem] text-fg-muted`,children:T}):null,(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:b,disabled:_||(y?!o:!S),title:y?p.chat.sendThisMessage:p.chat.followUpQueueSteerHint,"aria-label":y?p.chat.sendThisMessage:p.chat.followUpQueueSteerNow,"aria-busy":w,onClick:()=>y?c?.(e.id):s(e.id),children:[(0,Z.jsx)(ts,{className:Y(`size-4`,w&&`motion-safe:animate-pulse`),"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`hidden text-xs sm:inline`,children:y?p.chat.sendThisMessage:p.chat.followUpQueueSteerNow})]}),(0,Z.jsx)(`button`,{type:`button`,className:Y(b,`px-1.5 hover:text-danger`),disabled:_||!o,title:p.chat.followUpQueueRemove,"aria-label":p.chat.followUpQueueRemove,onClick:()=>i(e.id),children:(0,Z.jsx)(Ht,{className:`size-4`,"aria-hidden":!0})}),(0,Z.jsxs)(ro,{modal:!1,children:[(0,Z.jsx)(io,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:Y(b,`px-1.5`),disabled:_,title:p.chat.followUpQueueMore,"aria-label":p.chat.followUpQueueMore,children:(0,Z.jsx)(xe,{className:`size-4`,"aria-hidden":!0})})}),(0,Z.jsx)(ao,{children:(0,Z.jsxs)(so,{side:`top`,align:`end`,sideOffset:6,onCloseAutoFocus:e=>{m.current&&e.preventDefault(),m.current=!1},className:`z-50 min-w-52 max-w-[calc(100vw-2rem)] rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:[(0,Z.jsxs)(oo,{className:x,disabled:!t,onSelect:()=>{m.current=!0,r(e.id)},children:[(0,Z.jsx)(kt,{className:`size-4`,"aria-hidden":!0}),p.chat.followUpQueueClickToEdit]}),f?(0,Z.jsxs)(oo,{className:x,disabled:!C,onSelect:()=>f(e,A),children:[(0,Z.jsx)(ds,{className:`size-4`,"aria-hidden":!0}),p.chat.followUpQueueOpenSideChat]}):null,g.length>1?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(co,{className:`my-1 h-px bg-edge-subtle`}),(0,Z.jsxs)(oo,{className:x,disabled:!t||h===0,onSelect:()=>a(e.id,`up`),children:[(0,Z.jsx)(re,{className:`size-4`,"aria-hidden":!0}),p.chat.followUpQueueMoveUp]}),(0,Z.jsxs)(oo,{className:x,disabled:!t||h>=g.length-1,onSelect:()=>a(e.id,`down`),children:[(0,Z.jsx)(te,{className:`size-4`,"aria-hidden":!0}),p.chat.followUpQueueMoveDown]})]}):null]})})]})]})]},e.id)})]})});function $w({conversationId:e}){let t=m(e=>e.conversationId),n=h(e=>e.language).startsWith(`zh`),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(``),s=Kr(e?[`session-preparation`,t,e]:null,async()=>{let t=await Tr(e);if(t&&!t.materialization)return null;let n=await g(p(`/api/sessions/${encodeURIComponent(e)}/input-state`));return n.payload.preparation?Dr.parse(n.payload.preparation):null},{refreshInterval:e=>e?.state===`preparing`?5e3:0,shouldRetryOnError:!1}),{mutate:c}=s;(0,Q.useEffect)(()=>{let t=t=>{t.detail?.conversationId===e&&c()};return window.addEventListener(`session-input-state`,t),()=>window.removeEventListener(`session-input-state`,t)},[e,c]);let l=s.data;if(!l||l.state===`ready`)return null;let u=async()=>{i(!0),o(``);try{let t=await f(p(`/api/sessions/${encodeURIComponent(e)}/preparation/retry`),{method:`POST`,body:JSON.stringify({operationId:l.operationId,expectedRevision:l.revision,idempotencyKey:`${l.operationId}:${l.revision}`})});if(!t.ok)throw Error(`HTTP ${t.status}`);await c()}catch(e){o(e instanceof Error?e.message:String(e))}finally{i(!1)}};return(0,Z.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 text-sm text-fg-muted`,role:`status`,children:[(0,Z.jsx)(`span`,{children:l.state===`preparing`?n?`正在准备会话环境…`:`Preparing conversation environment…`:l.lastError??(n?`会话环境准备失败`:`Conversation environment preparation failed`)}),l.state===`preparation_failed`?(0,Z.jsx)(`button`,{type:`button`,className:`ml-2 text-accent-fg`,disabled:r,onClick:()=>void u(),children:n?`重试准备`:`Retry preparation`}):null,a?(0,Z.jsx)(`span`,{role:`alert`,className:`ml-2`,children:a}):null]})}function eT(e){let t=(0,X.c)(10),{refs:n,label:r,onRemove:i}=e;if(n.length===0)return null;let a;if(t[0]!==r||t[1]!==i||t[2]!==n){let e;t[4]!==r||t[5]!==i?(e=e=>(0,Z.jsxs)(`span`,{className:`inline-flex h-7 min-w-0 max-w-56 items-center gap-1.5 rounded-md border border-edge-subtle bg-accent-soft/50 px-2 text-xs text-fg`,children:[e.kind===`file`&&e.fileKind===`directory`?(0,Z.jsx)(ke,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.kind===`file`||e.kind===`result`?(0,Z.jsx)(Ee,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.kind===`session`?(0,Z.jsx)(St,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.kind===`browser_tab`?(0,Z.jsx)(k,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,Z.jsx)(ms,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.title}),(0,Z.jsx)(`button`,{type:`button`,className:`-mr-1 inline-flex size-5 shrink-0 items-center justify-center rounded text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":`${r}: ${e.title}`,onClick:()=>i(e.sourceId),children:(0,Z.jsx)(qt,{className:`size-3`,"aria-hidden":!0})})]},e.sourceId),t[4]=r,t[5]=i,t[6]=e):e=t[6],a=n.map(e),t[0]=r,t[1]=i,t[2]=n,t[3]=a}else a=t[3];let o;return t[7]!==r||t[8]!==a?(o=(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5 px-4 pt-2`,"aria-label":r,children:a}),t[7]=r,t[8]=a,t[9]=o):o=t[9],o}var tT=`inline-flex h-8 min-w-0 shrink-0 items-center justify-center gap-1.5 rounded-full px-2.5 text-sm text-fg transition-[background-color,transform] hover:bg-surface-hover active:scale-95 disabled:pointer-events-none disabled:opacity-45 motion-reduce:transition-none motion-reduce:transform-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`;function nT(e){let t=(0,X.c)(96),{conversationId:n,project:r,workspacePath:i,canChangeWorkspace:a,disabled:o,environmentPicker:s,onProjectChange:c,onWorkspaceChange:l}=e,u=h(oT),d;t[0]===u?d=t[1]:(d=y(u),t[0]=u,t[1]=d);let f=d,p=f.chat.composerContext,g=m(aT),_=m(iT),[v,b]=(0,Q.useState)(``),[x]=Ea(v,200),S;t[2]!==_||t[3]!==x||t[4]!==g?(S=[`composer-projects`,_,g,x],t[2]=_,t[3]=x,t[4]=g,t[5]=S):S=t[5];let C;t[6]===x?C=t[7]:(C=()=>dn({status:`active`,search:x,sortBy:`updatedAt`,sortOrder:`desc`,limit:50}),t[6]=x,t[7]=C);let w;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(w={keepPreviousData:!1,shouldRetryOnError:!1},t[8]=w):w=t[8];let T=Kr(S,C,w),E=of(n,!1),D=E.error?void 0:E.data?.environment,O;t[9]!==D?.rootPath||t[10]!==i?(O=i?.trim()||D?.rootPath||``,t[9]=D?.rootPath,t[10]=i,t[11]=O):O=t[11];let k=O,[A,j]=(0,Q.useState)(null),M;t[12]!==E||t[13]!==l?(M=async e=>{j(null);try{await l(e),await E.mutate()}catch(e){let t=e;j(t instanceof Error?t.message:String(t))}},t[12]=E,t[13]=l,t[14]=M):M=t[14];let N;t[15]!==k||t[16]!==M?(N={initialPath:k,onPicked:M},t[15]=k,t[16]=M,t[17]=N):N=t[17];let P=Ma(N),F=a?`${p.chooseFolder}${k?`: ${k}`:``}`:r?p.projectFolder:p.lockedFolder,I;t[18]===D?I=t[19]:(I=D?.branch||(D?.detached?D.headSha?.slice(0,8):void 0),t[18]=D,t[19]=I);let L=I,R=p.label,z=r&&`bg-surface-hover`,B;t[20]===z?B=t[21]:(B=Y(`flex min-w-0 max-w-full items-center rounded-full`,z),t[20]=z,t[21]=B);let V;t[22]!==o||t[23]!==f.chat.scopeRemoveProject||t[24]!==c||t[25]!==r?(V=r?(0,Z.jsx)(`button`,{type:`button`,disabled:o,title:f.chat.scopeRemoveProject,"aria-label":f.chat.scopeRemoveProject,className:Y(tT,`size-7 shrink-0 px-0 ml-0.5 text-fg-muted`),onClick:()=>c(null),children:(0,Z.jsx)(qt,{className:`size-3.5`,"aria-hidden":!0})}):null,t[22]=o,t[23]=f.chat.scopeRemoveProject,t[24]=c,t[25]=r,t[26]=V):V=t[26];let H=r?.id??``,U=r?.name,W;t[27]!==T.data?.items||t[28]!==T.error?(W=T.error?[]:T.data?.items??[],t[27]=T.data?.items,t[28]=T.error,t[29]=W):W=t[29];let G;t[30]===W?G=t[31]:(G=W.map(rT),t[30]=W,t[31]=G);let ee=p.chooseProject,te=p.changeProject,ne=p.changeProject,re=p.noProject,ie=p.searchProjects,K=T.isLoading,oe=T.error?p.projectsFailed:T.data?.items.length===0?p.noProjects:void 0,se=r&&`pl-1`,q;t[32]===se?q=t[33]:(q=Y(tT,`h-8 w-auto max-w-44 gap-1 border-0 bg-transparent pr-2.5 text-sm [&>svg]:hidden [&>span]:text-fg`,se),t[32]=se,t[33]=q);let ce;t[34]!==c||t[35]!==r?.id?(ce=e=>{e!==(r?.id??``)&&c(e||null)},t[34]=c,t[35]=r?.id,t[36]=ce):ce=t[36];let ue;t[37]!==p.changeProject||t[38]!==p.chooseProject||t[39]!==p.noProject||t[40]!==p.searchProjects||t[41]!==o||t[42]!==T.isLoading||t[43]!==v||t[44]!==H||t[45]!==U||t[46]!==G||t[47]!==oe||t[48]!==q||t[49]!==ce?(ue=(0,Z.jsx)(le,{value:H,selectedLabel:U,options:G,placeholder:ee,ariaLabel:te,title:ne,emptyLabel:re,disabled:o,side:`top`,align:`start`,searchPlaceholder:ie,searchValue:v,onSearchChange:b,loading:K,statusMessage:oe,triggerClassName:q,contentClassName:`xopc-composer-config-popover w-max min-w-[min(12rem,calc(100vw-1.5rem))] max-w-[min(20rem,calc(100vw-1.5rem))] [&>input]:w-0 [&>input]:min-w-full`,onChange:ce}),t[37]=p.changeProject,t[38]=p.chooseProject,t[39]=p.noProject,t[40]=p.searchProjects,t[41]=o,t[42]=T.isLoading,t[43]=v,t[44]=H,t[45]=U,t[46]=G,t[47]=oe,t[48]=q,t[49]=ce,t[50]=ue):ue=t[50];let de;t[51]!==B||t[52]!==V||t[53]!==ue?(de=(0,Z.jsxs)(`div`,{className:B,children:[V,ue]}),t[51]=B,t[52]=V,t[53]=ue,t[54]=de):de=t[54];let fe=r?s:null,J;t[55]!==D||t[56]!==s||t[57]!==r?(J=!s&&r&&D&&(D.headSha||D.branch)?(0,Z.jsxs)(`span`,{className:`inline-flex h-8 min-w-0 items-center gap-1.5 rounded-full bg-surface-hover px-2.5 text-sm text-fg`,title:D.rootPath,children:[D.kind===`managed_worktree`?(0,Z.jsx)(hs,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(Ke,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),D.kind===`managed_worktree`?`Worktree`:`Local`]}):null,t[55]=D,t[56]=s,t[57]=r,t[58]=J):J=t[58];let pe;t[59]!==p.retryProjects||t[60]!==T?(pe=T.error?(0,Z.jsx)(`button`,{type:`button`,className:Y(tT,`size-7 px-0`),"aria-label":p.retryProjects,onClick:()=>void T.mutate(),children:(0,Z.jsx)(Mt,{className:`size-3.5`,"aria-hidden":!0})}):null,t[59]=p.retryProjects,t[60]=T,t[61]=pe):pe=t[61];let me;t[62]!==a||t[63]!==E.isLoading||t[64]!==p.chooseFolder||t[65]!==o||t[66]!==P.pick||t[67]!==P.picking||t[68]!==r||t[69]!==k||t[70]!==F?(me=r?null:(0,Z.jsxs)(`button`,{type:`button`,className:Y(tT,`max-w-52`),disabled:o||!a||P.picking,title:F,"aria-label":p.chooseFolder,onClick:P.pick,children:[(0,Z.jsx)(Oe,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),k?(0,Z.jsx)(`span`,{className:`truncate`,children:ja(k)}):E.isLoading?(0,Z.jsx)(Yt,{className:`h-4 w-16`}):(0,Z.jsx)(`span`,{children:p.chooseFolder})]}),t[62]=a,t[63]=E.isLoading,t[64]=p.chooseFolder,t[65]=o,t[66]=P.pick,t[67]=P.picking,t[68]=r,t[69]=k,t[70]=F,t[71]=me):me=t[71];let he;t[72]!==L||t[73]!==D?(he=L?(0,Z.jsxs)(`span`,{className:`inline-flex h-8 min-w-0 max-w-44 items-center gap-1.5 px-2 text-sm text-fg`,title:`${L}${D?.headSha?` · ${D.headSha.slice(0,8)}`:``}`,children:[(0,Z.jsx)(Pe,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate`,children:L})]}):null,t[72]=L,t[73]=D,t[74]=he):he=t[74];let ge;t[75]===A?ge=t[76]:(ge=A?(0,Z.jsx)(`p`,{role:`alert`,className:`w-full px-2 py-1 text-xs text-danger`,children:A}):null,t[75]=A,t[76]=ge);let _e;t[77]!==p.label||t[78]!==de||t[79]!==fe||t[80]!==J||t[81]!==pe||t[82]!==me||t[83]!==he||t[84]!==ge?(_e=(0,Z.jsxs)(`div`,{className:`mx-3 -mb-3 flex min-w-0 shrink-0 flex-wrap items-center gap-x-1 gap-y-1 rounded-t-2xl bg-surface-base px-2 pb-4 pt-1.5 sm:mx-4`,"aria-label":R,children:[de,fe,J,pe,me,he,ge]}),t[77]=p.label,t[78]=de,t[79]=fe,t[80]=J,t[81]=pe,t[82]=me,t[83]=he,t[84]=ge,t[85]=_e):_e=t[85];let ve;t[86]!==f.chat.workingDirectory||t[87]!==P.confirmPick||t[88]!==P.hasNativePicker||t[89]!==P.modalOpen||t[90]!==P.setModalOpen||t[91]!==k?(ve=P.hasNativePicker?null:(0,Z.jsx)(ae,{open:P.modalOpen,onOpenChange:P.setModalOpen,initialAbsolutePath:k||void 0,onConfirm:P.confirmPick,wd:f.chat.workingDirectory}),t[86]=f.chat.workingDirectory,t[87]=P.confirmPick,t[88]=P.hasNativePicker,t[89]=P.modalOpen,t[90]=P.setModalOpen,t[91]=k,t[92]=ve):ve=t[92];let ye;return t[93]!==_e||t[94]!==ve?(ye=(0,Z.jsxs)(Z.Fragment,{children:[_e,ve]}),t[93]=_e,t[94]=ve,t[95]=ye):ye=t[95],ye}function rT(e){return{value:e.id,label:e.name}}function iT(e){return e.baseUrl}function aT(e){return e.conversationId}function oT(e){return e.language}var sT=`flex size-11 shrink-0 items-center justify-center rounded-full text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent sm:size-10`;function cT(e){let t=(0,X.c)(10),{disabled:n,attachmentCount:r,maxAttachments:i,chat:a,onPickFiles:o}=e,s=r>=i,c;t[0]!==a.attachFile||t[1]!==a.maxAttachmentsReached||t[2]!==s||t[3]!==i?(c=s?Jp(a.maxAttachmentsReached,{max:i}):a.attachFile,t[0]=a.attachFile,t[1]=a.maxAttachmentsReached,t[2]=s,t[3]=i,t[4]=c):c=t[4];let l=c,u=n||s,d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(jt,{className:`size-5`,"aria-hidden":!0}),t[5]=d):d=t[5];let f;return t[6]!==l||t[7]!==o||t[8]!==u?(f=(0,Z.jsx)(`button`,{type:`button`,className:sT,disabled:u,"aria-label":l,title:l,onClick:o,children:d}),t[6]=l,t[7]=o,t[8]=u,t[9]=f):f=t[9],f}function lT(e){let t=(0,X.c)(38),{disabled:n,voiceActive:r,runBusy:i,hasDraft:a,chat:o,onStartVoiceInput:s,onSend:c,onQueue:l,onDefer:u,onAbort:d,onInterrupt:f,onSteer:p,steerDisabled:m}=e,h=m!==void 0&&m;if(r)return null;let g=i&&a&&!!l,_=i&&!a,v=_?o.abort:g?o.steeringInterruptSend:o.sendMessage,y;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(Ct,{className:`size-[1.125rem]`,"aria-hidden":!0}),t[0]=y):y=t[0];let b;t[1]!==o.voiceInput||t[2]!==n||t[3]!==s?(b=(0,Z.jsx)(`button`,{type:`button`,className:sT,disabled:n,title:o.voiceInput,"aria-label":o.voiceInput,onClick:s,children:y}),t[1]=o.voiceInput,t[2]=n,t[3]=s,t[4]=b):b=t[4];let x;t[5]!==o.abort||t[6]!==o.followUpQueueAdd||t[7]!==o.followUpQueueMore||t[8]!==o.steerCurrentReply||t[9]!==o.steerCurrentReplyHint||t[10]!==o.steeringInterruptSend||t[11]!==n||t[12]!==a||t[13]!==d||t[14]!==u||t[15]!==f||t[16]!==p||t[17]!==i||t[18]!==h?(x=i&&(0,Z.jsxs)(ro,{modal:!1,children:[(0,Z.jsx)(io,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:sT,disabled:n,"aria-label":o.followUpQueueMore,title:o.followUpQueueMore,children:(0,Z.jsx)(xe,{className:`size-5`,"aria-hidden":!0})})}),(0,Z.jsx)(ao,{children:(0,Z.jsxs)(so,{side:`top`,align:`end`,sideOffset:8,className:`z-50 min-w-44 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:[p&&(0,Z.jsx)(oo,{disabled:n||h,onSelect:p,title:o.steerCurrentReplyHint,className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none focus:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,children:o.steerCurrentReply}),u&&(0,Z.jsx)(oo,{disabled:!a,onSelect:()=>void u(),className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none focus:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,children:o.followUpQueueAdd}),f&&(0,Z.jsx)(oo,{disabled:!a,onSelect:f,className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none focus:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,children:o.steeringInterruptSend}),(0,Z.jsx)(oo,{onSelect:d,className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none focus:bg-surface-hover`,children:o.abort})]})})]}),t[5]=o.abort,t[6]=o.followUpQueueAdd,t[7]=o.followUpQueueMore,t[8]=o.steerCurrentReply,t[9]=o.steerCurrentReplyHint,t[10]=o.steeringInterruptSend,t[11]=n,t[12]=a,t[13]=d,t[14]=u,t[15]=f,t[16]=p,t[17]=i,t[18]=h,t[19]=x):x=t[19];let S;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(S=Y(sT,`bg-accent text-on-accent hover:bg-accent-hover hover:text-on-accent disabled:bg-surface-hover disabled:text-fg-disabled`),t[20]=S):S=t[20];let C=!_&&(n||!a||i&&!l),w;t[21]!==g||t[22]!==d||t[23]!==l||t[24]!==c||t[25]!==_?(w=_?d:g?()=>void l?.():c,t[21]=g,t[22]=d,t[23]=l,t[24]=c,t[25]=_,t[26]=w):w=t[26];let T;t[27]===_?T=t[28]:(T=_?(0,Z.jsx)(Vt,{className:`size-4 fill-current`,"aria-hidden":!0}):(0,Z.jsx)(P,{className:`size-5`,"aria-hidden":!0}),t[27]=_,t[28]=T);let E;t[29]!==v||t[30]!==C||t[31]!==w||t[32]!==T?(E=(0,Z.jsx)(`button`,{type:`button`,className:S,disabled:C,"aria-label":v,title:v,onClick:w,children:T}),t[29]=v,t[30]=C,t[31]=w,t[32]=T,t[33]=E):E=t[33];let D;return t[34]!==b||t[35]!==x||t[36]!==E?(D=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[b,x,E]}),t[34]=b,t[35]=x,t[36]=E,t[37]=D):D=t[37],D}function uT(e){return e.map(e=>({type:e.type===`voice`?`voice`:(e.mimeType??``).startsWith(`image/`)?`image`:`document`,mimeType:e.mimeType??`application/octet-stream`,content:e.data??``,name:e.name??`file`,size:e.size??0,uri:e.uri,...typeof e.durationSeconds==`number`&&Number.isFinite(e.durationSeconds)&&e.durationSeconds>0?{durationSeconds:e.durationSeconds}:{}}))}var dT=100,fT=400,pT=900;function mT(e,t){switch(t.type){case`reset`:return{box:null,hoverPreview:null};case`set-box`:return{...e,box:t.box};case`set-hover`:return{...e,hoverPreview:t.hoverPreview}}}function hT(e,t){let n=t.trim().toLowerCase();if(!n)return[];let r=e.toLowerCase(),i=[],a=0;for(let e=0;e<r.length&&a<n.length;e++)r[e]===n[a]&&(i.push([e,e+1]),a++);return i}function gT(e){let t=(0,X.c)(8),{name:n,query:r}=e,i;t[0]!==n||t[1]!==r?(i=hT(n,r),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a=i;if(a.length===0){let e;return t[3]===n?e=t[4]:(e=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:n}),t[3]=n,t[4]=e),e}let o;if(t[5]!==n||t[6]!==a){let e=[],r=0;a.forEach(t=>{let[i,a]=t;i>r&&e.push((0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:n.slice(r,i)},`pre-${i}`)),e.push((0,Z.jsx)(`span`,{className:`font-semibold text-accent-fg`,children:n.slice(i,a)},`hl-${i}-${a}`)),r=a}),r<n.length&&e.push((0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:n.slice(r)},`tail`)),o=(0,Z.jsx)(Z.Fragment,{children:e}),t[5]=n,t[6]=a,t[7]=o}else o=t[7];return o}var _T=(0,Q.memo)(function(e){let t=(0,X.c)(42),{open:n,anchorRef:r,items:i,selectedIndex:a,loading:o,query:s,noResults:c,conversationId:l,recentLabel:u,sectionLabels:d,ariaLabel:f,onSelectItem:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m={box:null,hoverPreview:null},t[0]=m):m=t[0];let[h,g]=(0,Q.useReducer)(mT,m),_=h.box,v=h.hoverPreview,y=(0,Q.useRef)(null),b=(0,Q.useRef)(0),x=(0,Q.useRef)(null),S;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>{y.current&&=(clearTimeout(y.current),null)},t[1]=S):S=t[1];let C=S,w;t[2]===l?w=t[3]:(w=(e,t,n)=>{C(),b.current+=1;let r=b.current;if(e.kind!==`file`){g({type:`set-hover`,hoverPreview:null});return}let i=e.relativePath;if(!l?.trim()||e.isDirectory||e.isBrowseUp||!i){g({type:`set-hover`,hoverPreview:null});return}y.current=setTimeout(()=>{y.current=null,r===b.current&&Fa(i,{conversationId:l}).then(e=>{let{content:i}=e,a=i.length>pT?`${i.slice(0,pT)}…`:i;r===b.current&&g({type:`set-hover`,hoverPreview:{text:a,x:t,y:n}})}).catch(()=>{r===b.current&&g({type:`set-hover`,hoverPreview:null})})},420)},t[2]=l,t[3]=w);let T=w,E,D;t[4]!==r||t[5]!==n?(E=()=>{if(!n){g({type:`reset`}),C(),b.current+=1;return}let e=()=>{let e=r.current;if(!e)return;let t=e.getBoundingClientRect();g({type:`set-box`,box:{left:t.left,top:t.top,width:t.width}})};e();let t=r.current,i=t&&typeof ResizeObserver<`u`?new ResizeObserver(()=>{e()}):null;return t&&i&&i.observe(t),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{t&&i&&i.disconnect(),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},D=[n,r],t[4]=r,t[5]=n,t[6]=E,t[7]=D):(E=t[6],D=t[7]),(0,Q.useLayoutEffect)(E,D);let O,A;if(t[8]!==i.length||t[9]!==n||t[10]!==a?(O=()=>{!n||a<0||a>=i.length||(x.current?.querySelector(`#at-mention-${a}`))?.scrollIntoView({block:`nearest`})},A=[n,a,i.length],t[8]=i.length,t[9]=n,t[10]=a,t[11]=O,t[12]=A):(O=t[11],A=t[12]),(0,Q.useLayoutEffect)(O,A),!n||typeof document>`u`||_===null)return null;let j=i.length,M=Math.min(_.width,fT),N;t[13]!==_.left||t[14]!==_.top||t[15]!==M?(N={position:`fixed`,left:_.left,top:_.top,width:M,transform:`translateY(calc(-100% - 8px))`,zIndex:dT},t[13]=_.left,t[14]=_.top,t[15]=M,t[16]=N):N=t[16];let P=a>=0&&a<j?`at-mention-${a}`:void 0,F;t[17]!==o||t[18]!==j?(F=o&&j===0?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2.5 text-sm text-fg-muted`,children:[(0,Z.jsx)(Xe,{className:`size-4 shrink-0 animate-spin`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:`…`})]}):null,t[17]=o,t[18]=j,t[19]=F):F=t[19];let I;t[20]!==i||t[21]!==o||t[22]!==c||t[23]!==p||t[24]!==s||t[25]!==u||t[26]!==T||t[27]!==d||t[28]!==a||t[29]!==j?(I=!o&&j===0?(0,Z.jsx)(`div`,{className:`px-3 py-2 text-sm text-fg-muted`,children:c}):(0,Z.jsxs)(Z.Fragment,{children:[i.map((e,t)=>{let n=i[t-1]?.kind,r=d[e.kind],o=e.kind===`file`&&e.isRecent;return(0,Z.jsxs)(Q.Fragment,{children:[n===e.kind?null:(0,Z.jsx)(`div`,{className:`border-t border-edge-subtle px-3 pb-1 pt-2 text-[0.65rem] font-medium uppercase tracking-wide text-fg-muted first:border-t-0`,children:r}),(0,Z.jsxs)(`div`,{id:`at-mention-${t}`,role:`option`,"aria-selected":a===t,tabIndex:-1,className:Y(`flex cursor-pointer items-start gap-2 px-3 py-2 text-left text-sm`,a===t?`bg-surface-hover text-fg`:`text-fg-subtle hover:bg-surface-hover/80`,o&&`border-l-2 border-l-accent/60`),onPointerDown:t=>{t.pointerType===`mouse`&&t.button!==0||(t.preventDefault(),p(e))},onPointerEnter:t=>T(e,t.clientX,t.clientY),onPointerLeave:()=>{C(),b.current+=1,g({type:`set-hover`,hoverPreview:null})},children:[(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:e.kind===`note`?(0,Z.jsx)(ms,{className:`size-3.5 text-accent-fg`,"aria-hidden":!0}):e.kind===`session`?(0,Z.jsx)(St,{className:`size-3.5 text-violet-600 dark:text-violet-400`,"aria-hidden":!0}):e.kind===`skill`?(0,Z.jsx)(Bt,{className:`size-3.5 text-cyan-600 dark:text-cyan-400`,"aria-hidden":!0}):e.kind===`agent`?(0,Z.jsx)(G,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):e.kind===`browser_tab`?(0,Z.jsx)(k,{className:`size-3.5 text-blue-600 dark:text-blue-400`,"aria-hidden":!0}):e.isBrowseUp?(0,Z.jsx)(ke,{className:`size-3.5 text-fg-muted`,"aria-hidden":!0}):e.isDirectory?(0,Z.jsx)(ke,{className:`size-3.5 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}):(0,Z.jsx)(Ee,{className:Y(`size-3.5`,ve(e.name)),"aria-hidden":!0})}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 truncate`,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:(0,Z.jsx)(gT,{name:e.name,query:s})}),o?(0,Z.jsx)(`span`,{className:`shrink-0 rounded bg-accent-soft px-1 py-0 text-[0.65rem] text-accent-fg`,children:u}):null]}),(0,Z.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:e.description||r})]})]})]},e.id)}),o&&j>0?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-edge-subtle px-3 py-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(Xe,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:`…`})]}):null]}),t[20]=i,t[21]=o,t[22]=c,t[23]=p,t[24]=s,t[25]=u,t[26]=T,t[27]=d,t[28]=a,t[29]=j,t[30]=I):I=t[30];let L;t[31]!==f||t[32]!==F||t[33]!==I||t[34]!==P?(L=(0,Z.jsxs)(`div`,{ref:x,className:`max-h-[min(26rem,54vh)] overflow-y-auto`,role:`listbox`,"aria-label":f,"aria-activedescendant":P,children:[F,I]}),t[31]=f,t[32]=F,t[33]=I,t[34]=P,t[35]=L):L=t[35];let R;t[36]===v?R=t[37]:(R=v?(0,Z.jsx)(`div`,{className:`pointer-events-none fixed z-[200] max-h-48 max-w-sm overflow-auto rounded-md border border-edge bg-surface-overlay p-2 font-mono text-[0.7rem] text-fg shadow-lg`,style:{left:Math.min(v.x+12,window.innerWidth-320),top:Math.min(v.y+12,window.innerHeight-200)},children:v.text}):null,t[36]=v,t[37]=R);let z;return t[38]!==L||t[39]!==R||t[40]!==N?(z=(0,As.createPortal)((0,Z.jsxs)(`div`,{"data-composer-picker-panel":!0,className:`pointer-events-auto max-h-[min(28rem,60vh)] min-h-[2.5rem] overflow-hidden rounded-lg border border-edge bg-surface-overlay shadow-lg`,style:N,role:`presentation`,children:[L,R]}),document.body),t[38]=L,t[39]=R,t[40]=N,t[41]=z):z=t[41],z});function vT(e,t){let n=e=>{e!==!1&&(e&&typeof e==`object`?t(e.conversationId):t())};e instanceof Promise?e.then(n).catch(e=>{Ne(`error`,e instanceof Error?e.message:String(e))}):n(e)}var yT=new Set([`abort`,`stop`,`cancel`]);function bT(e){if(e.kind!==`command`)return!1;if(yT.has(e.name.toLowerCase()))return!0;for(let t of e.aliases??[])if(yT.has(t.toLowerCase()))return!0;return!1}function xT(e,t,n,r){return e.slice(0,t)+r+e.slice(n)}var ST=(e,t)=>{let n=t.slashRange;if(!n)return;if(e.availability.status!==`available`){t.callbacks.onUnavailableSkill?.(e);return}let r=`/skill:${e.canonicalName} `,i=xT(t.editor.valueRef.current,n.start,n.end,r),a=n.start+r.length;t.editor.resetEditor({nextText:i,caretOffset:a,focus:!0})},CT=(e,t)=>{let n=t.slashRange;if(!n||n.start!==0)return;if(e.name.toLowerCase()===`review`&&t.callbacks.onReviewLauncher&&!t.runBusy&&t.pendingFollowUpsCount===0){let e=t.editor.valueRef.current,r=e.slice(0,n.start)+e.slice(n.end);t.editor.resetEditor({nextText:r,caretOffset:n.start,focus:!0}),t.callbacks.onReviewLauncher();return}if(e.acceptsArgs===!0){let r=`/${e.name} `,i=xT(t.editor.valueRef.current,n.start,n.end,r),a=n.start+r.length;t.editor.resetEditor({nextText:i,caretOffset:a,focus:!0});return}let r=`/${e.name}`;if(t.runBusy||t.pendingFollowUpsCount>0){if(bT(e)){if(!t.callbacks.onAbort)return;t.callbacks.onAbort();let e=t.editor.valueRef.current,r=e.slice(0,n.start)+e.slice(n.end);t.editor.resetEditor({nextText:r,caretOffset:n.start});return}if(!t.callbacks.onAddPendingFollowUp||t.pendingFollowUpsCount>=t.maxPendingFollowUps)return;t.contextRefs.current.length?t.callbacks.onAddPendingFollowUp(r,void 0,t.contextRefs.current):t.callbacks.onAddPendingFollowUp(r,void 0),t.callbacks.onUserTextCommitted?.(r),t.attachments.clearAttachments(),t.contextRefs.clear(),t.editor.resetEditor();return}vT(t.contextRefs.current.length?t.callbacks.onSend(r,void 0,t.thinkingLevel,t.contextRefs.current):t.callbacks.onSend(r,void 0,t.thinkingLevel),e=>{e===void 0?t.callbacks.onUserTextCommitted?.(r):t.callbacks.onUserTextCommitted?.(r,e),t.attachments.clearAttachments(),t.contextRefs.clear(),t.editor.resetEditor()})},wT=(e,t)=>{let n=t.slashRange;if(!n||n.start!==0||!t.callbacks.onChatAgentChange)return;let r=t.editor.valueRef.current,i=r.slice(n.end),a=r.slice(0,n.start)+(i.startsWith(` `)?i.slice(1):i);t.editor.resetEditor({nextText:a,caretOffset:n.start}),t.callbacks.onChatAgentChange(e.agentId)};function TT(e,t){switch(e.kind){case`skill`:ST(e,t);return;case`command`:CT(e,t);return;case`agent`:wT(e,t)}}var ET={new:10,help:11,list:12,clear:13,switch:14,models:15,usage:16,skills:17,settings:18,start:19,think:20,reasoning:21,verbose:22,status:23,tts:24},DT=new Set([`abort`,`archive`]);function OT(e){if(e.kind===`command`){let t=e.name.toLowerCase();if(ET[t]!==void 0)return 0;if(DT.has(t))return 2}return 1}function kT(e,t){let n=OT(e),r=OT(t);if(n!==r)return n-r;if(n===0){let n=ET[e.name.toLowerCase()]??999,r=ET[t.name.toLowerCase()]??999;if(n!==r)return n-r}let i=e.name.localeCompare(t.name);return i===0?e.id.localeCompare(t.id):i}function AT(e){if(e.kind!==`command`)return!1;if(yT.has(e.name.toLowerCase()))return!0;for(let t of e.aliases??[])if(yT.has(t.toLowerCase()))return!0;return!1}function jT(e,t){return e.kind!==`command`||e.acceptsArgs===!0||AT(e)||!(t.runBusy||t.pendingFollowUpsCount>0)?!1:t.pendingFollowUpsCount>=t.maxPendingFollowUps}function MT(e,t){return e.kind!==`command`||e.acceptsArgs===!0||AT(e)||!(t.runBusy||t.pendingFollowUpsCount>0)?!1:t.pendingFollowUpsCount<t.maxPendingFollowUps}function NT(e){return e.includes(`/`)||/^[A-Za-z]:/u.test(e)?!0:/^(Users|home|var|tmp|etc|opt|private|Volumes|System|Applications|Library|usr|dev|bin|sbin|proc|sys)(\/|$)/iu.test(e)}function PT(e,t){if(t===0)return!1;let n=e[t-1];if(n===void 0||n===`.`||n===`:`||n===`/`)return!0;let r=e.slice(0,t);return/[a-zA-Z0-9-]+\.[a-zA-Z0-9.-]+$/u.test(r)}function FT(e,t){let n=e.length,r=Math.min(Math.max(t,0),n);if(r<1&&e===`/`&&(r=1),r<1)return null;let i=e.slice(0,r).match(/\/[^\s]*$/);if(!i||i.index===void 0)return null;let a=i.index;if(PT(e,a))return null;let o=i[0],s=o.slice(1);return NT(s)||o.startsWith(`/skill:`)?null:{start:i.index,end:r,query:s}}function IT(e,t){let n=t.trim().toLowerCase();if(!n)return 0;let r=e.name.toLowerCase();if(r===n)return 0;for(let t of e.aliases??[])if(t.toLowerCase()===n)return 1;if(r.startsWith(n))return 2;for(let t of e.aliases??[])if(t.toLowerCase().startsWith(n))return 3;if(r.includes(n))return 4;for(let t of e.aliases??[])if(t.toLowerCase().includes(n))return 5;if(e.description.toLowerCase().includes(n))return 100;if(e.category.toLowerCase().includes(n))return 101;if(e.kind===`skill`&&(e.source??``).toLowerCase().includes(n))return 102;if(e.kind===`skill`){for(let t of e.searchTerms??[])if(t.toLowerCase().includes(n))return 103}return null}function LT(e,t){return t===0?0:Math.min(e,t-1)}function RT(e,t){let{query:n,value:r,commandsAllowed:i,agentsAllowed:a}=t,o=n.trim()===``,s=dp(r),c=[];for(let r of e){if(r.kind===`command`&&!i||r.kind===`agent`&&!a||r.kind===`skill`&&t.skillsAllowed===!1||r.kind===`skill`&&s.has(r.canonicalName)||r.kind===`skill`&&o&&r.availability.status!==`available`)continue;let e=IT(r,n);e!==null&&c.push({item:r,rank:e})}c.sort((e,t)=>{let n=e.item.kind===`skill`&&e.item.availability.status!==`available`;return n===(t.item.kind===`skill`&&t.item.availability.status!==`available`)?e.rank===t.rank?kT(e.item,t.item):e.rank-t.rank:n?1:-1});let l=c.map(e=>e.item),u=[],d=l.filter(e=>e.kind===`skill`),f=l.filter(e=>e.kind===`command`),p=l.filter(e=>e.kind===`agent`);d.length>0&&u.push({kind:`skill`,items:d}),f.length>0&&u.push({kind:`command`,items:f}),p.length>0&&u.push({kind:`agent`,items:p});let m=[];for(let e of u)m.push(...e.items);return{sections:u,flatItems:m}}function zT(e,t,n){let r=(0,X.c)(49),[i,a]=(0,Q.useState)(0),[o,s]=(0,Q.useState)(0),c=h(HT),l=n?.capabilities??Kf,u=l.commands||l.skills||l.agentSwitch;n?.isComposing;let d;r[0]!==t||r[1]!==u||r[2]!==n?.isComposing||r[3]!==e?(d=!u||n?.isComposing?null:FT(e,t),r[0]=t,r[1]=u,r[2]=n?.isComposing,r[3]=e,r[4]=d):d=r[4];let f=d,p=!!(f&&!n?.suppress),m,g;r[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{let e=e=>{let t=e.detail;t&&typeof t==`object`&&`section`in t&&(t.section===`skills`||t.section===`agents`)&&s(VT)};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},g=[],r[5]=m,r[6]=g):(m=r[5],g=r[6]),(0,Q.useEffect)(m,g);let _;r[7]!==c||r[8]!==n?.conversationId||r[9]!==n?.currentAgentId?(_=async()=>{let[e,t,r]=await Promise.allSettled([ho(),lo(n?.currentAgentId,n?.conversationId),ri()]),i=[];t.status===`rejected`&&i.push(`skill`),e.status===`rejected`&&i.push(`command`),r.status===`rejected`&&i.push(`agent`);let a=(e.status===`fulfilled`?e.value:[]).map(BT),o=(t.status===`fulfilled`?t.value.skills:[]).map(e=>{let t=go(e,c);return{kind:`skill`,id:`skill:${e.name}`,name:t.displayName,canonicalName:e.name,description:t.description,aliases:t.aliases,searchTerms:t.searchTerms,category:`skill`,source:e.source,availability:{status:e.availableForCurrentAgent?`available`:e.unavailableReason??`agent-denied`,reason:e.unavailableReason??void 0}}}),s=y(c).agentsSettings,l=r.status===`fulfilled`?r.value:null,u=l&&l.items.length>1?l.items.map(e=>({kind:`agent`,id:`agent:${e.id}`,agentId:e.id,name:Ho(e,s),description:Uo(e,s),category:`agent`,...e.avatar?{avatar:e.avatar}:{},aliases:[e.id,...e.name?[e.name]:[]]})):[];return{items:[...o,...a,...u],failedKinds:i}},r[7]=c,r[8]=n?.conversationId,r[9]=n?.currentAgentId,r[10]=_):_=r[10];let v=n?.currentAgentId,b=n?.conversationId,x;r[11]!==c||r[12]!==o||r[13]!==v||r[14]!==b?(x=[c,v,b,o],r[11]=c,r[12]=o,r[13]=v,r[14]=b,r[15]=x):x=r[15];let S;r[16]===Symbol.for(`react.memo_cache_sentinel`)?(S=[],r[16]=S):S=r[16];let C;r[17]===Symbol.for(`react.memo_cache_sentinel`)?(C=[],r[17]=C):C=r[17];let w,T;r[18]===Symbol.for(`react.memo_cache_sentinel`)?(T={items:S,failedKinds:C},w=[],r[18]=w,r[19]=T):(w=r[18],T=r[19]);let E;r[20]===Symbol.for(`react.memo_cache_sentinel`)?(E=[],r[20]=E):E=r[20];let D;r[21]===Symbol.for(`react.memo_cache_sentinel`)?(D={items:w,failedKinds:E},r[21]=D):D=r[21];let O;r[22]===p?O=r[23]:(O={enabled:p,initial:T,errorData:D},r[22]=p,r[23]=O);let k=Ca(_,x,O),A=k.data.items,j=k.error==null?null:k.error instanceof Error?k.error.message:String(k.error),M=f?.query??``,N=l.commands&&f!==null&&f.start===0,P=l.agentSwitch&&f!==null&&f.start===0,F;r[24]!==P||r[25]!==A||r[26]!==l.skills||r[27]!==N||r[28]!==M||r[29]!==e?(F=RT(A,{query:M,value:e,commandsAllowed:N,agentsAllowed:P,skillsAllowed:l.skills}),r[24]=P,r[25]=A,r[26]=l.skills,r[27]=N,r[28]=M,r[29]=e,r[30]=F):F=r[30];let{sections:I,flatItems:L}=F,R=f?M:``,z=(0,Q.useRef)(R);z.current!==R&&(z.current=R,i!==0&&a(0));let B;r[31]!==L.length||r[32]!==i?(B=LT(i,L.length),r[31]=L.length,r[32]=i,r[33]=B):B=r[33];let V=B,H;r[34]===L.length?H=r[35]:(H=e=>{L.length!==0&&a(t=>e===`down`?(t+1)%L.length:(t-1+L.length)%L.length)},r[34]=L.length,r[35]=H);let U=H,W;return r[36]!==P||r[37]!==N||r[38]!==L||r[39]!==k.data.failedKinds||r[40]!==k.loading||r[41]!==j||r[42]!==U||r[43]!==p||r[44]!==M||r[45]!==V||r[46]!==I||r[47]!==f?(W={open:p,slashRange:f,commandsAllowed:N,agentsAllowed:P,sections:I,flatItems:L,selectedIndex:V,query:M,loading:k.loading,failedKinds:k.data.failedKinds,loadError:j,onNavigate:U,setSelectedIndex:a},r[36]=P,r[37]=N,r[38]=L,r[39]=k.data.failedKinds,r[40]=k.loading,r[41]=j,r[42]=U,r[43]=p,r[44]=M,r[45]=V,r[46]=I,r[47]=f,r[48]=W):W=r[48],W}function BT(e){return{kind:`command`,id:`cmd:${e.id}`,name:e.name,description:e.description,category:e.category,aliases:e.aliases,acceptsArgs:e.acceptsArgs,acceptsContext:e.acceptsContext,examples:e.examples}}function VT(e){return e+1}function HT(e){return e.language}var UT=100,WT=560;function GT(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase().indexOf(n);if(r>=0)return(0,Z.jsxs)(Z.Fragment,{children:[e.slice(0,r),(0,Z.jsx)(`span`,{className:`text-accent-fg`,children:e.slice(r,r+n.length)}),e.slice(r+n.length)]});let i=[],a=0,o=0;for(let t of e){let e=n[a],r=`${String(o)}-${t}`;e!==void 0&&t.toLowerCase()===e?(i.push((0,Z.jsx)(`span`,{className:`text-accent-fg`,children:t},r)),a+=1):i.push((0,Z.jsx)(Q.Fragment,{children:t},r)),o+=1}return(0,Z.jsx)(Z.Fragment,{children:i})}function KT(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase().indexOf(n);return r<0?e:(0,Z.jsxs)(Z.Fragment,{children:[e.slice(0,r),(0,Z.jsx)(`span`,{className:`text-accent-fg`,children:e.slice(r,r+n.length)}),e.slice(r+n.length)]})}var qT=(0,Q.memo)(function(e){let t=(0,X.c)(46),{item:n,index:r,selectedIndex:i,showHighlight:a,filterQuery:o,currentAgentId:s,currentBadgeLabel:c,runBusy:l,pendingFollowUpsCount:u,maxPendingFollowUps:d,queueBadgeLabel:f,queueFullBadgeLabel:p,queueFullTooltip:m,skillUnavailableLabel:h,skillAgentDeniedLabel:g,skillSourceLabels:_,onSelectItem:v}=e,y=n.kind===`skill`,b=n.kind===`agent`,x;t[0]!==b||t[1]!==y||t[2]!==n.agentId||t[3]!==n.avatar?(x=b?(0,Z.jsx)(Ta,{agentId:n.agentId,avatar:n.avatar,size:18,className:`size-[18px] shrink-0`}):y?(0,Z.jsx)(Bt,{className:`size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,Z.jsx)(Jt,{className:`size-4 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}),t[0]=b,t[1]=y,t[2]=n.agentId,t[3]=n.avatar,t[4]=x):x=t[4];let S=x,C;t[5]!==o||t[6]!==b||t[7]!==n.name||t[8]!==a?(C=b?a?(0,Z.jsx)(Z.Fragment,{children:GT(n.name,o)}):(0,Z.jsx)(`span`,{className:`text-fg`,children:n.name}):a?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`text-fg`,children:`/`}),GT(n.name,o)]}):(0,Z.jsxs)(`span`,{className:`text-fg`,children:[`/`,n.name]}),t[5]=o,t[6]=b,t[7]=n.name,t[8]=a,t[9]=C):C=t[9];let w=C,T=b&&s!=null&&s.length>0&&n.agentId===s,E=y&&n.availability.status!==`available`,D,O;if(t[10]!==n||t[11]!==d||t[12]!==u||t[13]!==l){let e={runBusy:l,pendingFollowUpsCount:u,maxPendingFollowUps:d};O=MT(n,e),D=jT(n,e),t[10]=n,t[11]=d,t[12]=u,t[13]=l,t[14]=D,t[15]=O}else D=t[14],O=t[15];let k=D,A=null;if(T){let e;t[16]===c?e=t[17]:(e=(0,Z.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-accent-soft px-1 py-px text-[0.6rem] font-medium leading-none text-accent-fg`,"aria-label":c,children:c}),t[16]=c,t[17]=e),A=e}else if(E){let e=n.availability.reason??`unavailable`,r=n.availability.status===`agent-denied`?g:h,i;t[18]!==e||t[19]!==r?(i=(0,Z.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-surface-hover px-1 py-px text-[0.6rem] font-medium leading-none text-fg-muted`,"aria-label":e,children:r}),t[18]=e,t[19]=r,t[20]=i):i=t[20],A=i}else if(y&&n.source){let e=_[n.source]??n.source,r;t[21]===e?r=t[22]:(r=(0,Z.jsx)(`span`,{className:`ml-2 shrink-0 text-[11px] font-normal text-fg-muted`,children:e}),t[21]=e,t[22]=r),A=r}else if(k){let e;t[23]===p?e=t[24]:(e=(0,Z.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-red-100 px-1 py-px text-[0.6rem] font-medium leading-none text-red-700 dark:bg-red-900/40 dark:text-red-300`,"aria-label":p,children:p}),t[23]=p,t[24]=e),A=e}else if(O){let e;t[25]===f?e=t[26]:(e=(0,Z.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-surface-hover px-1 py-px text-[0.6rem] font-medium leading-none text-fg-muted`,"aria-label":f,children:f}),t[25]=f,t[26]=e),A=e}let j=i===r,M=`palette-${r}`,N;t[27]!==o||t[28]!==n.description||t[29]!==a?(N=n.description?a?KT(n.description,o):n.description:null,t[27]=o,t[28]=n.description,t[29]=a,t[30]=N):N=t[30];let P=k?m:void 0,F;t[31]!==n||t[32]!==v?(F=()=>v(n),t[31]=n,t[32]=v,t[33]=F):F=t[33];let I;return t[34]!==S||t[35]!==k||t[36]!==n||t[37]!==w||t[38]!==a||t[39]!==j||t[40]!==M||t[41]!==N||t[42]!==P||t[43]!==F||t[44]!==A?(I=(0,Z.jsx)(YT,{item:n,icon:S,selected:j,id:M,nameLine:w,descriptionLine:N,dimCategoryBadge:a,trailingBadge:A,disabled:k,disabledTooltip:P,onSelect:F}),t[34]=S,t[35]=k,t[36]=n,t[37]=w,t[38]=a,t[39]=j,t[40]=M,t[41]=N,t[42]=P,t[43]=F,t[44]=A,t[45]=I):I=t[45],I}),JT=(0,Q.memo)(function(e){let t=(0,X.c)(53),{open:n,anchorRef:r,sections:i,flatItems:a,loading:o,failedKinds:s,selectedIndex:c,noResults:l,sectionLoadFailedLabel:u,query:d,skillsLabel:f,commandsLabel:p,agentsLabel:m,currentAgentId:h,currentBadgeLabel:g,runBusy:_,pendingFollowUpsCount:v,maxPendingFollowUps:y,queueBadgeLabel:b,queueFullBadgeLabel:x,queueFullTooltip:S,skillUnavailableLabel:C,skillAgentDeniedLabel:w,skillSourceLabels:T,onSelectItem:E,panelRef:D}=e,[O,k]=(0,Q.useState)(null),A,j;t[0]!==r||t[1]!==n?(A=()=>{if(!n){k(null);return}let e=()=>{let e=r.current;if(!e)return;let t=e.getBoundingClientRect();k({left:t.left,top:t.top,width:t.width})};e();let t=r.current,i=t&&typeof ResizeObserver<`u`?new ResizeObserver(()=>{e()}):null;return t&&i&&i.observe(t),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{t&&i&&i.disconnect(),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},j=[n,r],t[0]=r,t[1]=n,t[2]=A,t[3]=j):(A=t[2],j=t[3]),(0,Q.useLayoutEffect)(A,j);let M,N;if(t[4]!==a.length||t[5]!==n||t[6]!==c?(M=()=>{!n||a.length===0||document.getElementById(`palette-${c}`)?.scrollIntoView?.({block:`nearest`})},N=[a.length,n,c],t[4]=a.length,t[5]=n,t[6]=c,t[7]=M,t[8]=N):(M=t[7],N=t[8]),(0,Q.useEffect)(M,N),!n||typeof document>`u`||O===null)return null;let P=a.length,F=a[c],I=Math.min(O.width,WT),L;t[9]===d?L=t[10]:(L=d.trim(),t[9]=d,t[10]=L);let R=L,z=R.length>0,B;t[11]!==m||t[12]!==p||t[13]!==f?(B={skill:f,command:p,agent:m},t[11]=m,t[12]=p,t[13]=f,t[14]=B):B=t[14];let V=B,H;t[15]!==h||t[16]!==g||t[17]!==R||t[18]!==y||t[19]!==E||t[20]!==v||t[21]!==b||t[22]!==x||t[23]!==S||t[24]!==_||t[25]!==c||t[26]!==z||t[27]!==w||t[28]!==T||t[29]!==C?(H={selectedIndex:c,showHighlight:z,filterQuery:R,currentAgentId:h,currentBadgeLabel:g,runBusy:_,pendingFollowUpsCount:v,maxPendingFollowUps:y,queueBadgeLabel:b,queueFullBadgeLabel:x,queueFullTooltip:S,skillUnavailableLabel:C,skillAgentDeniedLabel:w,skillSourceLabels:T,onSelectItem:E},t[15]=h,t[16]=g,t[17]=R,t[18]=y,t[19]=E,t[20]=v,t[21]=b,t[22]=x,t[23]=S,t[24]=_,t[25]=c,t[26]=z,t[27]=w,t[28]=T,t[29]=C,t[30]=H):H=t[30];let U=H,W;if(t[31]!==s||t[32]!==o||t[33]!==l||t[34]!==U||t[35]!==V||t[36]!==u||t[37]!==i||t[38]!==P){let e=new Map(i.map(XT)),n=[`skill`,`command`,`agent`].filter(t=>e.has(t)||s.includes(t)),r=0;W=o&&P===0?(0,Z.jsx)(`div`,{className:`space-y-2 p-2.5`,"aria-busy":`true`,children:Array.from({length:6},ZT)}):P===0&&s.length===0?(0,Z.jsx)(`div`,{className:`p-2.5 text-xs leading-normal text-fg-muted`,children:l}):n.map((t,n)=>{let i=e.get(t)?.items??[],a=r;r+=i.length;let o=`palette-section-${t}`;return(0,Z.jsxs)(`div`,{role:`group`,"aria-labelledby":o,className:Y(n>0&&`border-t border-edge-subtle`),children:[(0,Z.jsxs)(`div`,{id:o,className:`sticky top-0 z-10 flex items-center justify-between bg-surface-overlay px-2.5 py-2 text-[0.65rem] font-medium uppercase leading-none tracking-wide text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:V[t]}),(0,Z.jsx)(`span`,{className:`tabular-nums`,"aria-hidden":!0,children:i.length})]}),s.includes(t)?(0,Z.jsx)(`div`,{className:`px-2.5 pb-2 text-[11px] leading-relaxed text-fg-muted`,children:u}):i.map((e,t)=>(0,Z.jsx)(qT,{item:e,index:a+t,...U},e.id))]},t)}),t[31]=s,t[32]=o,t[33]=l,t[34]=U,t[35]=V,t[36]=u,t[37]=i,t[38]=P,t[39]=W}else W=t[39];let G=W,ee;t[40]!==O.left||t[41]!==O.top||t[42]!==I?(ee={position:`fixed`,left:O.left,top:O.top,width:I,transform:`translateY(calc(-100% - 8px))`,zIndex:UT},t[40]=O.left,t[41]=O.top,t[42]=I,t[43]=ee):ee=t[43];let te=`${f}, ${p}, ${m}`,ne=F?`${V[F.kind]}: ${F.name}`:``,re;t[44]===ne?re=t[45]:(re=(0,Z.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:ne}),t[44]=ne,t[45]=re);let ie;return t[46]!==G||t[47]!==o||t[48]!==D||t[49]!==te||t[50]!==re||t[51]!==ee?(ie=(0,As.createPortal)((0,Z.jsx)(Ba,{delayDuration:0,skipDelayDuration:0,disableHoverableContent:!1,children:(0,Z.jsxs)(`div`,{ref:D,className:`pointer-events-auto max-h-[min(32rem,60vh)] min-h-8 overflow-y-auto rounded-md border border-edge bg-surface-overlay text-xs leading-4 shadow-lg`,style:ee,role:`listbox`,"aria-label":te,"aria-busy":o,children:[re,G]})}),document.body),t[46]=G,t[47]=o,t[48]=D,t[49]=te,t[50]=re,t[51]=ee,t[52]=ie):ie=t[52],ie}),YT=(0,Q.memo)(function(e){let t=(0,X.c)(39),{item:n,icon:r,selected:i,id:a,nameLine:o,descriptionLine:s,dimCategoryBadge:c,trailingBadge:l,disabled:u,disabledTooltip:d,onSelect:f}=e,p;t[0]===n.description?p=t[1]:(p=n.description.trim(),t[0]=n.description,t[1]=p);let m=p,h=m.length>0&&s!=null,g=m.length>0,_=n.description,v=n.category&&n.kind!==`skill`&&!c&&!(n.kind===`agent`&&l),y;t[2]===o?y=t[3]:(y=(0,Z.jsx)(`span`,{className:`min-w-0 max-w-[min(12rem,46%)] shrink-0 truncate font-semibold text-fg`,children:o}),t[2]=o,t[3]=y);let b;t[4]!==n.category||t[5]!==v?(b=v?(0,Z.jsx)(`span`,{className:`shrink-0 rounded bg-surface-hover px-1 py-px text-[0.6rem] font-normal leading-none text-fg-muted`,children:n.category}):null,t[4]=n.category,t[5]=v,t[6]=b):b=t[6];let x;t[7]!==s||t[8]!==h?(x=h?(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] font-normal leading-tight text-fg-muted`,children:s}):null,t[7]=s,t[8]=h,t[9]=x):x=t[9];let S;t[10]!==y||t[11]!==b||t[12]!==x?(S=(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-1`,children:[y,b,x]}),t[10]=y,t[11]=b,t[12]=x,t[13]=S):S=t[13];let C=S,w=u?`cursor-not-allowed opacity-50 text-fg-muted`:i?`cursor-pointer bg-surface-hover text-fg`:`cursor-pointer text-fg-subtle hover:bg-surface-hover/80`,T;t[14]===w?T=t[15]:(T=Y(`flex min-h-11 w-full min-w-0 items-center gap-2 px-2.5 py-1.5 text-left text-sm leading-5 sm:min-h-9`,w),t[14]=w,t[15]=T);let E=T,D;t[16]!==u||t[17]!==f?(D=e=>{u||e.pointerType===`mouse`&&e.button!==0||(e.preventDefault(),f())},t[16]=u,t[17]=f,t[18]=D):D=t[18];let O=D,k;t[19]===r?k=t[20]:(k=(0,Z.jsx)(`span`,{className:`shrink-0 [&_svg]:align-middle`,children:r}),t[19]=r,t[20]=k);let A;t[21]!==k||t[22]!==C||t[23]!==l?(A=(0,Z.jsxs)(Z.Fragment,{children:[k,C,l]}),t[21]=k,t[22]=C,t[23]=l,t[24]=A):A=t[24];let j=A,M=u&&d?d:g?_:null,N=u||void 0,P;t[25]!==a||t[26]!==O||t[27]!==E||t[28]!==j||t[29]!==i||t[30]!==N?(P=(0,Z.jsx)(`div`,{id:a,role:`option`,"aria-selected":i,"aria-disabled":N,tabIndex:-1,className:E,onPointerDown:O,children:j}),t[25]=a,t[26]=O,t[27]=E,t[28]=j,t[29]=i,t[30]=N,t[31]=P):P=t[31];let F=P;if(M!==null){let e;t[32]===F?e=t[33]:(e=(0,Z.jsx)(Wa,{asChild:!0,children:F}),t[32]=F,t[33]=e);let n;t[34]===M?n=t[35]:(n=(0,Z.jsx)(Va,{children:(0,Z.jsx)(Ua,{side:`right`,align:`start`,sideOffset:8,collisionPadding:12,className:`!z-[10000] max-h-[min(12rem,40vh)] max-w-sm overflow-y-auto rounded-md border border-edge bg-surface-overlay px-2 py-1.5 text-left text-[11px] leading-snug text-fg shadow-lg select-text [max-width:min(20rem,90vw)]`,"data-slash-palette-tooltip":``,children:(0,Z.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:M})})}),t[34]=M,t[35]=n);let r;return t[36]!==e||t[37]!==n?(r=(0,Z.jsxs)(Ha,{delayDuration:0,children:[e,n]}),t[36]=e,t[37]=n,t[38]=r):r=t[38],r}return F});function XT(e){return[e.kind,e]}function ZT(e,t){return(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,Z.jsx)(Yt,{className:`size-4 shrink-0`}),(0,Z.jsx)(Yt,{className:`h-3 w-28`}),(0,Z.jsx)(Yt,{className:`h-3 flex-1`})]},t)}var QT=new Map;function $T(e){let t=QT.get(e);return t||(t={items:[],loadPromise:null,loaded:!1,writeQueue:Promise.resolve(),mutationVersion:0,clearVersion:0},QT.set(e,t)),t}function eE(e,t){if(e.items[0]?.text===t.text){t.id>0&&(e.items[0]=t);return}e.items=[t,...e.items].slice(0,100)}function tE(e,t){if(e.items.some(e=>e.id===t.id))return;let n=e.items.findIndex(e=>e.id===0&&e.text===t.text);if(n>=0){e.items[n]=t;return}eE(e,t)}function nE(e){return $T(e).items.map(e=>e.text)}function rE(e,t=!1){let n=$T(e);if(n.loaded&&!t)return Promise.resolve();if(n.loadPromise)return n.loadPromise;let r=n.mutationVersion,i=!1;return n.loadPromise=n.writeQueue.then(()=>g(`/api/composer-history?conversationId=${encodeURIComponent(e)}`)).then(t=>{n.mutationVersion===r?(n.items=t.items.filter(t=>t.conversationId===e).slice(0,100),n.loaded=!0):i=!0}).catch(()=>{}).finally(()=>{n.loadPromise=null,i&&n.writeQueue.then(()=>rE(e,!0))}),n.loadPromise}function iE(e,t){let n=t.trim();if(!n)return;let r=$T(e),i=r.clearVersion;r.mutationVersion+=1,eE(r,{conversationId:e,id:0,text:n,createdAt:Date.now()}),r.writeQueue=r.writeQueue.then(async()=>{let t=await g(`/api/composer-history`,{method:`POST`,body:JSON.stringify({conversationId:e,text:n})});r.clearVersion===i&&t.item.conversationId===e&&tE(r,t.item)}).catch(()=>{})}function aE(e){if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.conversationId!=`string`||!t.conversationId||typeof t.id!=`number`||typeof t.text!=`string`||typeof t.createdAt!=`number`)return null;let n=$T(t.conversationId);return n.mutationVersion+=1,tE(n,t),t.conversationId}function oE(e){if(!e||typeof e!=`object`||!(`conversationId`in e)||typeof e.conversationId!=`string`)return null;let t=$T(e.conversationId);return t.mutationVersion+=1,t.clearVersion+=1,t.items=[],e.conversationId}function sE(e){let{conversationId:t,editorRef:n,valueRef:r,resetEditor:i,onWireInput:a}=e,o=(0,Q.useRef)(t);o.current=t;let s=(0,Q.useRef)(null),c=(0,Q.useCallback)(()=>{s.current=null},[]);return(0,Q.useEffect)(()=>{c()},[t,c]),(0,Q.useEffect)(()=>{t&&rE(t,!0);let e=e=>{aE(e.detail)===t&&c()},n=e=>{oE(e.detail)===t&&c()},r=()=>{t&&rE(t,!0)};return window.addEventListener(`composer-history-appended`,e),window.addEventListener(`composer-history-cleared`,n),window.addEventListener(`gateway-realtime-connected`,r),()=>{window.removeEventListener(`composer-history-appended`,e),window.removeEventListener(`composer-history-cleared`,n),window.removeEventListener(`gateway-realtime-connected`,r)}},[t,c]),{onUserTextCommitted:(0,Q.useCallback)((e,n=t)=>{n&&!vr(e)&&iE(n,e),n===o.current&&c()},[t,c]),onWireInputClearWalk:(0,Q.useCallback)((e,t)=>{s.current=null,a(e,t)},[a]),tryInputHistoryArrow:(0,Q.useCallback)(e=>{if(!t)return!1;let a=nE(t);if(a.length===0)return!1;let o=s.current,c=n.current,l=c?fp(c):0,u=r.current;if(e===`up`){if(o==null){if(l!==0)return!1;s.current={index:0,stash:u};let e=a[0];return e?(i({nextText:e,caretOffset:e.length,focus:!0}),!0):!1}if(o.index>=a.length-1)return!0;o.index+=1;let e=a[o.index];return e?(i({nextText:e,caretOffset:e.length,focus:!0}),!0):!1}if(o==null)return!1;if(--o.index,o.index<0){let e=o.stash;return s.current=null,i({nextText:e,caretOffset:e.length,focus:!0}),!0}let d=a[o.index];return d?(i({nextText:d,caretOffset:d.length,focus:!0}),!0):!1},[t,n,r,i])}}function cE(e){return e.blocked||(e.editingUserTurnId||e.editingFollowUpId)&&e.queuePaused===!1?`blocked`:e.editingFollowUpId?`saveFollowUp`:e.editingUserTurnId?e.runBusy?`blocked`:`replaceTurn`:e.runBusy?`queue`:`send`}function lE(e){if(e.voiceActive)return e.cancelVoiceInput(),null;let t=e.getTextValue(),n=e.getContextRefs();if(!t.trim()&&e.getAttachmentCount()===0&&n.length===0)return null;let r=e.wireAttachmentsPayload();return structuredClone({text:t,attachments:r,contextRefs:n})}function uE(e){let t=(0,Q.useRef)(e);t.current=e;let{chat:n,runBusy:r,voiceActive:i,cancelVoiceInput:a,editingFollowUpId:o,getTextValue:s,getAttachmentCount:c,wireAttachmentsPayload:l,getContextRefs:u,getThinkingLevel:d,onSend:f,onDispatched:p,onAddPendingFollowUp:m,onSteeringInterrupt:h,onCommitEditFollowUp:g,onPendingFollowUpRemove:_,pendingFollowUpsCount:v,resetEditor:y,clearAttachments:b,clearContextRefs:x,clearEditFollowUpRef:S,onUserTextCommitted:C}=e,w={getTextValue:s,getAttachmentCount:c,wireAttachmentsPayload:l,getContextRefs:u},T=(0,Q.useRef)(!1),E=(0,Q.useRef)(!1),D=(0,Q.useRef)(()=>{}),O=(0,Q.useRef)(!1),k=(0,Q.useCallback)(()=>{let n=cE(t.current);if(n===`blocked`)return;if(n===`queue`){D.current();return}let r=lE({voiceActive:i,cancelVoiceInput:a,...w});if(!r)return;if(n===`saveFollowUp`){if(O.current||!o)return;O.current=!0,Promise.resolve().then(()=>g(o,r.text,r.attachments,d(),r.contextRefs)).then(n=>{if(n===!1)return;C?.(r.text);let i=t.current;i.draftScope!==e.draftScope||i.editingFollowUpId!==o||i.getTextValue()!==r.text||JSON.stringify(i.wireAttachmentsPayload())!==JSON.stringify(r.attachments)||JSON.stringify(i.getContextRefs())!==JSON.stringify(r.contextRefs)||(i.onFinishFollowUpEdit?.(),S())}).catch(e=>Ne(`error`,e instanceof Error?e.message:String(e))).finally(()=>{O.current=!1});return}let s=[r.text,r.attachments.length>0?r.attachments:void 0,d(),r.contextRefs.length>0?r.contextRefs:void 0,{onDispatched:e=>p?.(e,r)}];vT(f(...s),i=>{C?.(r.text,i);let a=t.current;if(!(a.draftScope!==e.draftScope||a.getTextValue()!==r.text||JSON.stringify(a.wireAttachmentsPayload())!==JSON.stringify(r.attachments)||JSON.stringify(a.getContextRefs())!==JSON.stringify(r.contextRefs))){if(n===`replaceTurn`){a.editingUserTurnId===e.editingUserTurnId&&a.onFinishUserEdit?.();return}y(),b(),x()}})},[r,o,g,S,i,a,f,p,e.editingUserTurnId,e.draftScope,d,C,y,b,x,s,c,l,u]),A=(0,Q.useCallback)(async(o=e.personal?!0:void 0,s)=>{if(t.current.editingFollowUpId||t.current.editingUserTurnId){k();return}if(!r&&v===0)return;let c=lE({voiceActive:i,cancelVoiceInput:a,...w});if(c&&!t.current.blocked&&m&&!T.current){if(v>=10){Ne(`warning`,n.followUpQueueMaxReached,{max:10});return}T.current=!0;try{let n=[c.text,c.attachments.length>0?c.attachments:void 0,c.contextRefs.length>0?c.contextRefs:void 0];(o!==void 0||s!==void 0)&&n.push(o),s!==void 0&&n.push(s),await m(...n),C?.(c.text);let r=t.current;if(r.draftScope!==e.draftScope||r.editingFollowUpId||r.editingUserTurnId||r.getTextValue()!==c.text||JSON.stringify(r.wireAttachmentsPayload())!==JSON.stringify(c.attachments)||JSON.stringify(r.getContextRefs())!==JSON.stringify(c.contextRefs))return;y(),b(),x()}catch(e){Ne(`error`,n.followUpQueueSubmitFailed,{message:e instanceof Error?e.message:String(e)})}finally{T.current=!1}}},[k,r,i,a,o,v,m,g,d,e.personal,e.draftScope,n.followUpQueueMaxReached,n.followUpQueueSubmitFailed,S,C,y,b,x,s,c,l,u]);return D.current=()=>{A()},{send:k,flushSteeringDraft:A,interruptDraft:(0,Q.useCallback)(()=>{if(t.current.blocked||t.current.editingFollowUpId||t.current.editingUserTurnId||!r||!h||E.current)return;let n=lE({voiceActive:i,cancelVoiceInput:a,...w});n&&(E.current=!0,(async()=>{if(await h(n.text,n.attachments.length>0?n.attachments:void 0,n.contextRefs.length>0?n.contextRefs:void 0)===!1)return;C?.(n.text);let r=t.current;r.draftScope!==e.draftScope||r.editingFollowUpId||r.editingUserTurnId||r.getTextValue()!==n.text||JSON.stringify(r.wireAttachmentsPayload())!==JSON.stringify(n.attachments)||JSON.stringify(r.getContextRefs())!==JSON.stringify(n.contextRefs)||(y(),b(),x())})().catch(e=>Ne(`error`,e instanceof Error?e.message:String(e))).finally(()=>{E.current=!1}))},[r,i,a,o,_,h,e.draftScope,C,S,y,b,x,s,c,l,u]),steerCurrentReply:(0,Q.useCallback)(()=>{let e=t.current;if(!(!e.runBusy||e.blocked||e.voiceActive||e.steeringPending||e.editingFollowUpId||e.editingUserTurnId)){if(e.pendingFollowUpsCount>0){e.firstPendingFollowUpId&&e.onSteerPendingFollowUp?.(e.firstPendingFollowUpId);return}A(!1,`steer`)}},[A])}}var dE=e=>e?.kind===`editTurn`?`turn:${e.turnId}`:e?.kind===`editFollowUp`?`input:${e.inputId}:${e.version}`:`compose`,fE=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]);function pE(e,t,n,r,i,a){let o=dE(a?.snapshot().mode),s=m(e=>e.conversationId),c=s&&e?JSON.stringify([s,e]):``,l=(0,Q.useRef)({editor:t,attachments:n,refs:r,setRefs:i,editSession:a});l.current={editor:t,attachments:n,refs:r,setRefs:i,editSession:a};let u=(0,Q.useRef)(void 0),d=(0,Q.useRef)(``),[f,p]=(0,Q.useState)(0),h=(0,Q.useRef)(Promise.resolve());(0,Q.useLayoutEffect)(()=>{if(!c||!e){u.current=void 0;return}let t={receipts:[],scope:c,ready:!1,dirty:!1,observe:!1,snapshot:{text:l.current.editor.valueRef.current,attachments:l.current.attachments.attachmentsRef.current,refs:l.current.refs,editSession:l.current.editSession?.snapshot()},storage:Or(e)};u.current=t,d.current&&d.current!==c&&(l.current.editor.resetEditor(),l.current.attachments.clearAttachments(),l.current.setRefs([]),t.snapshot={text:``,attachments:[],refs:[],editSession:l.current.editSession?.snapshot()}),d.current=c;let n=!1;return t.storage.read().then(e=>{if(n=!0,u.current!==t)return;t.receipts=e?.intakeReceipts??[];let r=l.current;e&&!t.dirty&&!r.editor.valueRef.current&&!r.attachments.attachmentsRef.current.length&&!r.refs.length&&(r.editor.resetEditor({nextText:e.text}),r.attachments.setAttachments(e.attachments),r.setRefs(e.refs),e.editSession&&r.editSession?.restore(e.editSession))}).catch(e=>{console.warn(`Composer draft restoration failed`,e)}).finally(()=>{u.current===t&&(t.ready=n,p(e=>e+1))}),()=>{u.current===t&&(u.current=void 0)}},[c,e]),(0,Q.useLayoutEffect)(()=>{let e=u.current;if(!e||e.scope!==c)return;if(!e.observe){e.observe=!0;return}let i={text:t.value,attachments:n.attachments,refs:r,editSession:l.current.editSession?.snapshot()};(i.text!==e.snapshot.text||!fE(i.attachments,e.snapshot.attachments)||!fE(i.refs,e.snapshot.refs)||dE(i.editSession?.mode)!==dE(e.snapshot.editSession?.mode))&&(e.dirty=!0),e.snapshot=i},[c,t.value,n.attachments,r,o]),(0,Q.useEffect)(()=>{let e=u.current;if(!e||e.scope!==c||!e.ready&&!e.dirty)return;let i={text:t.value,attachments:n.attachments,refs:r,editSession:l.current.editSession?.snapshot()},a=i.text||i.attachments.length||r.length||i.editSession?.mode.kind!==void 0&&i.editSession.mode.kind!==`compose`?i:void 0;h.current=h.current.catch(()=>{}).then(()=>e.storage.write(a?{...a,intakeReceipts:e.receipts}:e.receipts.length?{text:``,attachments:[],refs:[],intakeReceipts:e.receipts}:void 0)).catch(e=>{console.warn(`Composer draft persistence failed`,e)})},[c,f,t.value,n.attachments,r,o]),(0,Q.useEffect)(()=>{let e=u.current;if(!(!e?.ready||!c))return Is(c,async(t,n)=>{if(await h.current,u.current!==e)throw Error(`Conversation changed. Please retry.`);if(e.receipts.includes(t))return;let r=l.current,i=r.attachments.attachmentsRef.current,a=n.filter(e=>!i.some(t=>t.id===e.id));if(i.length+a.length>10)throw Error(`A message supports at most 10 attachments. Remove attachments or choose another conversation.`);r.attachments.setAttachments([...i,...a]),e.receipts.push(t);try{let t={text:r.editor.valueRef.current,attachments:r.attachments.attachmentsRef.current,refs:r.refs,intakeReceipts:e.receipts.slice(),editSession:r.editSession?.snapshot()},n=h.current.catch(()=>{}).then(()=>e.storage.write(t));h.current=n,await n}catch(n){throw e.receipts=e.receipts.filter(e=>e!==t),n}})},[c,f])}function mE(e){let{conversationId:t,agentId:n,modelKey:r,locale:i,enabled:a,draftText:o,canShow:s}=e,c=m(e=>e.conversationId),[l,u]=(0,Q.useState)(null),[d,h]=(0,Q.useState)(null),g=(0,Q.useRef)(null),_=(0,Q.useRef)(o),v=(0,Q.useRef)(-1),y=(0,Q.useCallback)((e,t,n)=>{f(p(`/api/sessions/${encodeURIComponent(e.suggestion.conversationId)}/next-turn-suggestion-feedback`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({suggestionId:e.suggestion.id,impressionId:e.impressionId,event:t,...n===void 0?{}:{edited:n}})}).catch(()=>{})},[]);(0,Q.useEffect)(()=>{_.current.length>0&&o.length===0&&(g.current=null),_.current=o},[o]),(0,Q.useEffect)(()=>{g.current=null,v.current=-1,u(null),h(null)},[t,n,r,i,c]),(0,Q.useEffect)(()=>{if(u(null),!a||!t)return;let e=!1,r=0,o,s=0,c=new AbortController,l=async()=>{let a=++r;try{if(await Tr(t))return;let d=await f(p(`/api/sessions/${encodeURIComponent(t)}/next-turn-suggestion?locale=${i}`),{signal:c.signal});if(!d.ok)return;let m=Es.safeParse(await d.json());if(e||a!==r||!m.success)return;let h=m.data.suggestion;if(m.data.status===`ready`&&h&&h.conversationId===t&&h.locale===i&&(!n||h.agentId===n)&&h.inputRevision>=v.current&&h.expiresAt>Date.now()&&h.transcriptId===await jr(t)){if(e||a!==r)return;u(e=>e?.suggestion.id===h.id?e:{suggestion:h,impressionId:crypto.randomUUID()}),o=setTimeout(()=>{u(null)},Math.max(0,h.expiresAt-Date.now()))}else u(null),m.data.status===`pending`&&s++<7&&(o=setTimeout(()=>{l()},600))}catch{}},d=e=>{let n=e.detail;if(!(n?.conversationId!==t&&n?.key!==t)){if(typeof n.revision==`number`){if(n.revision<v.current)return;v.current=n.revision}r++,s=0,o&&clearTimeout(o),u(null),e.type===`session-transcript-updated`?o=setTimeout(()=>{l()},150):l()}},m=()=>{r++,s=0,o&&clearTimeout(o),u(null),l()},h=e=>{e.detail?.topic===`sessions`&&m()};l();let g=[`session-next-turn-suggestion-changed`,`session-input-state`,`session-updated`,`session-transcript-updated`];return g.forEach(e=>window.addEventListener(e,d)),window.addEventListener(`gateway-realtime-connected`,m),window.addEventListener(`config-reload`,m),window.addEventListener(`realtime-gap`,h),()=>{e=!0,r++,c.abort(),o&&clearTimeout(o),g.forEach(e=>window.removeEventListener(e,d)),window.removeEventListener(`gateway-realtime-connected`,m),window.removeEventListener(`config-reload`,m),window.removeEventListener(`realtime-gap`,h)}},[t,n,r,i,c,a]);let b=a&&s&&o.length===0&&l?.suggestion.id!==d&&l?.suggestion.conversationId===t&&l.suggestion.expiresAt>Date.now()?l:null,x=(0,Q.useCallback)(()=>{b&&y(b,`shown`)},[b,y]),S=(0,Q.useCallback)(()=>b?(g.current=b,y(b,`accepted`),b.suggestion.prompt):null,[b,y]),C=(0,Q.useCallback)(()=>{b&&(h(b.suggestion.id),y(b,`dismissed`))},[b,y]),w=(0,Q.useCallback)(e=>{let n=g.current;!n||n.suggestion.conversationId!==t||(h(n.suggestion.id),y(n,`submitted`,e.trim()!==n.suggestion.prompt),g.current=null)},[t,y]);return{suggestion:b?.suggestion??null,shown:x,accept:S,dismiss:C,submitted:w}}function hE(e){let t=(0,X.c)(6),{active:n,anchors:r,ignoreSelector:i,onDismiss:a}=e,o,s;t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a?(o=()=>{if(!n)return;let e=e=>{let t=e.target;if(t instanceof Node){for(let e of r){let n=e.current;if(n&&n.contains(t))return}i&&t instanceof Element&&t.closest(i)||a()}};return window.addEventListener(`pointerdown`,e,!0),()=>window.removeEventListener(`pointerdown`,e,!0)},s=[n,r,i,a],t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s):(o=t[4],s=t[5]),(0,Q.useEffect)(o,s)}var gE=20,_E=`xopc.atMention.recent:`;function vE(e){return`${_E}${e.trim()}`}function yE(e){let t=e?.trim();if(!t||typeof localStorage>`u`)return[];try{let e=localStorage.getItem(vE(t));if(!e)return[];let n=JSON.parse(e);return Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.length>0).slice(0,gE):[]}catch{return[]}}function bE(e,t){let n=e?.trim(),r=t.trim();if(!(!n||!r||typeof localStorage>`u`))try{let e=[r,...yE(n).filter(e=>e!==r)].slice(0,gE);localStorage.setItem(vE(n),JSON.stringify(e))}catch{}}var xE=150,SE=[`file`,`note`,`session`,`browser_tab`,`skill`,`agent`];function CE(e){let t={items:[],loading:e,error:null};return{file:{...t},note:{...t},session:{...t},skill:{...t},agent:{...t},browser_tab:{...t}}}function wE(e,t){let n=Math.min(Math.max(t,0),e.length);if(n<1)return null;let r=e.slice(0,n).match(/@((?:\\.|[^\s])*)$/);if(!r||r.index===void 0)return null;let i=r.index;return i>0&&/[a-zA-Z0-9_]/.test(e[i-1])?null:{start:i,end:n,query:(r[1]??``).replace(/\\([\\\s])/gu,`$1`)}}function TE(e){return e.replace(/[\\\s]/gu,e=>`\\${e}`)}function EE(e){let t=e.trim();return t.length>0&&t.endsWith(`/`)&&!/^https?:\/\//i.test(t)}function DE(e){return e.replace(/\/+$/,``).trim()}function OE(e){let t=e.replace(/\/+$/,``);if(!t)return``;let n=t.lastIndexOf(`/`);return n<=0?``:t.slice(0,n)}function kE(e,t){return t===0?0:Math.min(e,t-1)}function AE(e){return{id:`file:${e.id}`,kind:`file`,name:e.name,description:e.path,relativePath:e.path,isDirectory:e.isDirectory,fileRef:{sourceId:e.id,expectedVersion:e.revision}}}function jE(e,t,n){let r=(0,X.c)(55),i=n.capabilities??Kf,[a,o]=(0,Q.useState)(0),[s,c]=(0,Q.useState)(IE),l=(0,Q.useRef)(0),u=h(FE),d;bb0:{if(n.isComposing||n.slashPaletteOpen){d=null;break bb0}if(n.precomputedAtRange!==void 0){d=n.precomputedAtRange;break bb0}let i;r[0]!==t||r[1]!==e?(i=wE(e,t),r[0]=t,r[1]=e,r[2]=i):i=r[2],d=i}let f=d,p=f!==null,[m]=Ea(p?f.query:``,xE),g=p?m:``,_;r[3]===n.conversationId?_=r[4]:(_=n.conversationId?.trim()??``,r[3]=n.conversationId,r[4]=_);let v=_,y;r[5]===n.selectedContextKeys?y=r[6]:(y=[...n.selectedContextKeys??new Set].sort().join(`\0`),r[5]=n.selectedContextKeys,r[6]=y);let b=y,x;r[7]!==i.agentSwitch||r[8]!==i.skills||r[9]!==v||r[10]!==g||r[11]!==u||r[12]!==n||r[13]!==p||r[14]!==b?(x=()=>{let e=l.current+=1;if(!p){c(CE(!1));return}if(!v){c(CE(!!n.prepareSession)),n.prepareSession&&n.prepareSession().catch(()=>{l.current===e&&c(CE(!1))});return}let t={conversationId:v,currentAgentId:n.currentAgentId,language:u,selectedContextKeys:new Set(b?b.split(`\0`):[]),recentPaths:new Set(yE(v))};if(EE(g)){let t=CE(!1);t.file={items:[],loading:!0,error:null},c(t);let r=DE(g);Cw(r,{conversationId:v,agentId:n.currentAgentId}).then(t=>{if(l.current!==e)return;let n={id:`browse-up:${r}`,kind:`file`,name:`..`,description:OE(r)||`/`,relativePath:``,isDirectory:!0,isBrowseUp:!0};c(e=>({...e,file:{items:[n,...t.map(AE)],loading:!1,error:null}}))}).catch(t=>{l.current===e&&c(e=>({...e,file:{items:[],loading:!1,error:t instanceof Error?t.message:String(t)}}))});return}c(CE(!0));for(let n of Ew.filter(e=>(e.kind!==`skill`||i.skills)&&(e.kind!==`agent`||i.agentSwitch)))n.search(g,t).then(t=>{l.current===e&&c(e=>({...e,[n.kind]:{items:t,loading:!1,error:null}}))}).catch(t=>{l.current===e&&c(e=>({...e,[n.kind]:{items:[],loading:!1,error:t instanceof Error?t.message:String(t)}}))})},r[7]=i.agentSwitch,r[8]=i.skills,r[9]=v,r[10]=g,r[11]=u,r[12]=n,r[13]=p,r[14]=b,r[15]=x):x=r[15];let S;r[16]!==i.agentSwitch||r[17]!==i.skills||r[18]!==v||r[19]!==g||r[20]!==u||r[21]!==n.currentAgentId||r[22]!==n.prepareSession||r[23]!==p||r[24]!==b?(S=[p,v,g,u,n.currentAgentId,n.prepareSession,b,i.skills,i.agentSwitch],r[16]=i.agentSwitch,r[17]=i.skills,r[18]=v,r[19]=g,r[20]=u,r[21]=n.currentAgentId,r[22]=n.prepareSession,r[23]=p,r[24]=b,r[25]=S):S=r[25],(0,Q.useEffect)(x,S);let C;if(r[26]!==i.agentSwitch||r[27]!==i.skills||r[28]!==s){let e;r[30]!==i.agentSwitch||r[31]!==i.skills?(e=e=>(e!==`skill`||i.skills)&&(e!==`agent`||i.agentSwitch),r[30]=i.agentSwitch,r[31]=i.skills,r[32]=e):e=r[32];let t;r[33]===s?t=r[34]:(t=e=>({kind:e,...s[e]}),r[33]=s,r[34]=t),C=SE.filter(e).map(t),r[26]=i.agentSwitch,r[27]=i.skills,r[28]=s,r[29]=C}else C=r[29];let w=C,T=p?w.flatMap(PE):[],E;r[35]!==p||r[36]!==w?(E=p&&w.some(NE),r[35]=p,r[36]=w,r[37]=E):E=r[37];let D=E,O;r[38]===w?O=r[39]:(O=w.flatMap(ME),r[38]=w,r[39]=O);let k=O,A=!D&&T.length===0?k[0]??null:null,j=`${f?.start??``}:${f?.end??``}:${g}`,M;r[40]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>o(0),r[40]=M):M=r[40];let N;r[41]===j?N=r[42]:(N=[j],r[41]=j,r[42]=N),(0,Q.useEffect)(M,N);let P=kE(a,T.length),F;r[43]===T.length?F=r[44]:(F=e=>{T.length!==0&&o(t=>e===`down`?(t+1)%T.length:(t-1+T.length)%T.length)},r[43]=T.length,r[44]=F);let I=F,L=f?.query??``,R;return r[45]!==f||r[46]!==A||r[47]!==T||r[48]!==D||r[49]!==I||r[50]!==p||r[51]!==P||r[52]!==w||r[53]!==L?(R={open:p,atRange:f,sections:w,items:T,selectedIndex:P,query:L,loading:D,error:A,onNavigate:I,setSelectedIndex:o},r[45]=f,r[46]=A,r[47]=T,r[48]=D,r[49]=I,r[50]=p,r[51]=P,r[52]=w,r[53]=L,r[54]=R):R=r[54],R}function ME(e){return e.error?[e.error]:[]}function NE(e){return e.loading}function PE(e){return e.items}function FE(e){return e.language}function IE(){return CE(!1)}function LE(e){return e.kind===`note`?{refId:crypto.randomUUID(),kind:`note`,sourceId:e.noteRef.sourceId,expectedVersion:e.noteRef.expectedVersion,title:e.name}:e.kind===`file`&&!e.isBrowseUp&&e.fileRef?{refId:crypto.randomUUID(),kind:`file`,sourceId:e.fileRef.sourceId,expectedVersion:e.fileRef.expectedVersion,title:e.name,fileKind:e.isDirectory?`directory`:`file`}:e.kind===`session`?{refId:crypto.randomUUID(),kind:`session`,sourceId:e.sessionRef.sourceId,expectedVersion:e.sessionRef.expectedVersion,title:e.name}:e.kind===`browser_tab`?{refId:crypto.randomUUID(),kind:`browser_tab`,sourceId:e.tabRef.sourceId,expectedVersion:e.tabRef.expectedVersion,title:e.name}:null}function RE(e){let{conversationId:t,editorValue:n,editorCursor:r,isComposing:i,runBusy:a,thinkingLevel:o,editorRef:s,valueRef:c,resetEditor:l,clearAttachments:u,onSend:d,onUserTextCommitted:f,onChatAgentChange:p,currentAgentId:m,prepareSession:h,contextRefs:g,onAddContextRef:_,onUnavailableSkill:v,onReviewLauncher:y,onAddPendingFollowUp:b,onAbort:x,pendingFollowUpsCount:S,maxPendingFollowUps:C,clearContextRefs:w,commandPalettePanelRef:T}=e,E=e.capabilities??Kf,D=(0,Q.useMemo)(()=>wE(n,r),[n,r]),O=zT(n,r,{suppress:D!=null,capabilities:E,isComposing:i,currentAgentId:m,conversationId:t}),k=jE(n,r,{conversationId:t,currentAgentId:m,slashPaletteOpen:O.open,capabilities:E,isComposing:i,precomputedAtRange:D,selectedContextKeys:new Set(g.map(e=>`${e.kind}:${e.sourceId}`)),prepareSession:h}),A=O.open||k.open||D!=null,j=(0,Q.useCallback)(()=>({slashRange:O.slashRange,runBusy:a,pendingFollowUpsCount:S,maxPendingFollowUps:C,thinkingLevel:o,editor:{valueRef:c,resetEditor:l},attachments:{clearAttachments:u},contextRefs:{current:g,clear:w},callbacks:{onSend:d,onUserTextCommitted:f,onChatAgentChange:p,onAddPendingFollowUp:b,onAbort:x,onUnavailableSkill:v,onReviewLauncher:y}}),[O.slashRange,a,S,C,o,c,l,u,g,w,d,f,p,b,x,v,y]),M=(0,Q.useCallback)(e=>{!E.commands&&e.kind===`command`||!E.skills&&e.kind===`skill`||!E.agentSwitch&&e.kind===`agent`||TT(e,j())},[j,E]),N=(0,Q.useCallback)(e=>{let n=k.atRange;if(!n)return;let r=LE(e);if(r){let i=_(r);if(!i?.refId)return;let a=`${Xn(i.refId)} `,o=xT(c.current,n.start,n.end,a);l({nextText:o,caretOffset:n.start+a.length,focus:!0}),t&&e.kind===`file`&&bE(t,e.relativePath);return}if(e.kind===`skill`){if(!E.skills)return;let t=`/skill:${e.canonicalName} `,r=xT(c.current,n.start,n.end,t);l({nextText:r,caretOffset:n.start+t.length,focus:!0});return}if(e.kind===`agent`){if(!E.agentSwitch)return;let t=xT(c.current,n.start,n.end,``);l({nextText:t,caretOffset:n.start,focus:!0}),p?.(e.agentId);return}if(e.kind!==`file`||!e.isDirectory)return;let i=`@${TE(e.isBrowseUp?(()=>{let e=OE(DE(n.query));return e?`${e}/`:``})():`${e.relativePath.replace(/\/+$/,``)}/`)}`,a=xT(c.current,n.start,n.end,i),o=n.start+i.length;l({nextText:a,caretOffset:o,focus:!0})},[k.atRange,E,_,t,p,c,l]),P=(0,Q.useRef)(null);P.current=k.open?k.atRange:O.open?O.slashRange:null;let F=c,I=(0,Q.useCallback)(()=>{let e=P.current;if(!e)return;let t=F.current,n=t.slice(0,e.start)+t.slice(e.end);l({nextText:n,caretOffset:e.start})},[l,F]),L=(0,Q.useMemo)(()=>[s,T],[s,T]);hE({active:O.open||k.open,anchors:L,ignoreSelector:`[data-composer-picker-panel], [data-slash-palette-tooltip]`,onDismiss:I});let R=(0,Q.useRef)(k);R.current=k;let z=(0,Q.useRef)(O);z.current=O;let B=(0,Q.useRef)(i);B.current=i;let V=(0,Q.useRef)(M);V.current=M;let H=(0,Q.useRef)(N);H.current=N;let U=(0,Q.useRef)({runBusy:a,pendingFollowUpsCount:S,maxPendingFollowUps:C});U.current={runBusy:a,pendingFollowUpsCount:S,maxPendingFollowUps:C};let W=(0,Q.useMemo)(()=>({name:`at-mention`,isActive:()=>{let e=R.current;return e.open&&e.atRange!=null&&!B.current},handleKey:e=>{let t=R.current;if(!t.atRange)return!1;if(e.key===`Escape`){e.preventDefault();let n=t.atRange,r=F.current,i=xT(r,n.start,n.end,``);return l({nextText:i,caretOffset:n.start,focus:!0}),!0}if(t.items.length===0)return!1;if(e.key===`ArrowDown`)return e.preventDefault(),t.onNavigate(`down`),!0;if(e.key===`ArrowUp`)return e.preventDefault(),t.onNavigate(`up`),!0;if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let n=t.items[t.selectedIndex];return n&&H.current(n),!0}return!1}}),[l,F]),G=(0,Q.useMemo)(()=>({name:`slash-palette`,isActive:()=>z.current.open&&!B.current,handleKey:e=>{let t=z.current;if(t.flatItems.length>0){if(e.key===`ArrowDown`)return e.preventDefault(),t.onNavigate(`down`),!0;if(e.key===`ArrowUp`)return e.preventDefault(),t.onNavigate(`up`),!0;if((e.key===`Enter`||e.key===`Tab`)&&!e.shiftKey){e.preventDefault();let n=t.flatItems[t.selectedIndex];return!n||jT(n,U.current)||V.current(n),!0}}if(e.key===`Escape`){e.preventDefault();let n=t.slashRange;if(n){let e=F.current,t=xT(e,n.start,n.end,``);l({nextText:t,caretOffset:n.start,focus:!0})}return!0}return!1}}),[l,F]);return{palette:O,atPicker:k,shouldSyncSelection:A,adapters:(0,Q.useMemo)(()=>[W,G],[W,G]),applyPalette:M,applyAtMention:N}}function zE(e){return/^[A-Za-z0-9._/@:-]+$/.test(e)?e:JSON.stringify(e)}function BE(e,t){let n=t?.trim();return n?`${e} --instructions ${zE(n)}`:e}function VE(e){if(e.preset===`base`){if(!e.baseBranch?.trim())throw Error(`Missing base branch.`);return BE(`/review --base ${zE(e.baseBranch.trim())}`,e.instructions)}if(e.preset===`commit`){if(!e.commitSha?.trim())throw Error(`Missing commit SHA.`);return BE(`/review --commit ${zE(e.commitSha.trim())}`,e.instructions)}return e.preset,BE(`/review --uncommitted`,e.instructions)}async function HE(e){let t=await f(p(`/api/review/context?${new URLSearchParams({conversationId:e}).toString()}`)),n=await t.json().catch(()=>({}));if(!t.ok||!n.ok||!n.payload)throw Error(v(t.status,t.statusText,n.error?.message));return n.payload}function UE(e,t){let n=e?.status;if(!n)return``;if(n.isClean)return t.statusClean;let r=[];return n.changedFiles>0&&r.push(t.statusChanged.replace(`{{count}}`,String(n.changedFiles))),n.untrackedFiles>0&&r.push(t.statusUntracked.replace(`{{count}}`,String(n.untrackedFiles))),r.join(`, `)}function WE(e,t){let n=t.trim().toLowerCase(),r=[...(e?.branches??[]).filter(e=>!e.current)].sort((t,n)=>t.name===e?.defaultBaseBranch&&n.name!==e.defaultBaseBranch?-1:n.name===e?.defaultBaseBranch&&t.name!==e.defaultBaseBranch?1:t.name.localeCompare(n.name));return n?r.filter(e=>e.name.toLowerCase().includes(n)):r}function GE(e,t){let n=t.trim().toLowerCase(),r=e?.commits??[];return n?r.filter(e=>`${e.sha} ${e.shortSha} ${e.subject}`.toLowerCase().includes(n)):r}function KE(e){let t=(0,X.c)(15),{icon:n,title:r,description:i,disabled:a,onClick:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=Y(`flex min-h-16 w-full items-center gap-3 rounded-lg border border-edge bg-surface-panel px-3 py-2.5 text-left`,`hover:border-accent/45 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:cursor-not-allowed disabled:opacity-50`,ua.transition),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,Z.jsx)(`span`,{className:`inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:n}),t[1]=n,t[2]=c);let l;t[3]===r?l=t[4]:(l=(0,Z.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:r}),t[3]=r,t[4]=l);let u;t[5]===i?u=t[6]:(u=(0,Z.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:i}),t[5]=i,t[6]=u);let d;t[7]!==l||t[8]!==u?(d=(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[l,u]}),t[7]=l,t[8]=u,t[9]=d):d=t[9];let f;return t[10]!==a||t[11]!==o||t[12]!==c||t[13]!==d?(f=(0,Z.jsxs)(`button`,{type:`button`,disabled:a,className:s,onClick:o,children:[c,d]}),t[10]=a,t[11]=o,t[12]=c,t[13]=d,t[14]=f):f=t[14],f}function qE(e){let t=(0,X.c)(89),{open:n,conversationId:r,disabled:i,chat:a,onClose:o,onSendCommand:s}=e,c=a.reviewLauncher,[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(`presets`),[_,v]=(0,Q.useState)(``),[y,x]=(0,Q.useState)(``),C;t[0]!==r||t[1]!==c.noSession?(C=()=>{if(!r){u(null),m(c.noSession);return}f(!0),m(null),HE(r).then(e=>u(e)).catch(e=>{u(null),m(e instanceof Error?e.message:String(e))}).finally(()=>f(!1))},t[0]=r,t[1]=c.noSession,t[2]=C):C=t[2];let O=C,k,A;t[3]!==O||t[4]!==n?(k=()=>{n&&(g(`presets`),v(``),x(``),O())},A=[O,n],t[3]=O,t[4]=n,t[5]=k,t[6]=A):(k=t[5],A=t[6]),(0,Q.useEffect)(k,A);let M;t[7]!==l||t[8]!==_?(M=WE(l,_),t[7]=l,t[8]=_,t[9]=M):M=t[9];let N=M,P;t[10]!==l||t[11]!==_?(P=GE(l,_),t[10]=l,t[11]=_,t[12]=P):P=t[12];let F=P,I;t[13]!==l||t[14]!==c?(I=UE(l,c),t[13]=l,t[14]=c,t[15]=I):I=t[15];let L=I,R;t[16]!==y||t[17]!==o||t[18]!==s?(R=(e,t)=>{let n=VE({preset:e,baseBranch:t?.branch,commitSha:t?.commit,instructions:y});s(n),o()},t[16]=y,t[17]=o,t[18]=s,t[19]=R):R=t[19];let z=R,B=h===`base`?c.baseTitle:h===`commit`?c.commitTitle:h===`custom`?c.customTitle:c.title,V;t[20]===o?V=t[21]:(V=e=>!e&&o(),t[20]=o,t[21]=V);let H;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,Z.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[120] bg-scrim backdrop-blur-[1px]`}),t[22]=H):H=t[22];let U;t[23]!==c.back||t[24]!==h?(U=h===`presets`?null:(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":c.back,onClick:()=>{g(`presets`),v(``)},children:(0,Z.jsx)(j,{className:`size-4`})}),t[23]=c.back,t[24]=h,t[25]=U):U=t[25];let W;t[26]===B?W=t[27]:(W=(0,Z.jsx)(E,{className:`truncate text-sm font-semibold text-fg`,children:B}),t[26]=B,t[27]=W);let G=l?.cwd??c.description,ee;t[28]===G?ee=t[29]:(ee=(0,Z.jsx)(S,{className:`truncate text-xs text-fg-muted`,children:G}),t[28]=G,t[29]=ee);let te;t[30]!==W||t[31]!==ee?(te=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[W,ee]}),t[30]=W,t[31]=ee,t[32]=te):te=t[32];let ne;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,Z.jsx)(qt,{className:`size-4`}),t[33]=ne):ne=t[33];let re;t[34]!==c.close||t[35]!==o?(re=(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":c.close,onClick:o,children:ne}),t[34]=c.close,t[35]=o,t[36]=re):re=t[36];let ie;t[37]!==U||t[38]!==te||t[39]!==re?(ie=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-4 py-3`,children:[U,te,re]}),t[37]=U,t[38]=te,t[39]=re,t[40]=ie):ie=t[40];let ae;t[41]!==N||t[42]!==F||t[43]!==l||t[44]!==i||t[45]!==p||t[46]!==y||t[47]!==O||t[48]!==d||t[49]!==c.customDescription||t[50]!==c.customPlaceholder||t[51]!==c.defaultBadge||t[52]!==c.errorTitle||t[53]!==c.loading||t[54]!==c.localBadge||t[55]!==c.noBranches||t[56]!==c.noCommits||t[57]!==c.presetBase||t[58]!==c.presetBaseDescription||t[59]!==c.presetBaseDescriptionNoDefault||t[60]!==c.presetCommit||t[61]!==c.presetCommitDescription||t[62]!==c.presetCustom||t[63]!==c.presetCustomDescription||t[64]!==c.presetUncommitted||t[65]!==c.remoteBadge||t[66]!==c.retry||t[67]!==c.searchBranches||t[68]!==c.searchCommits||t[69]!==_||t[70]!==z||t[71]!==L||t[72]!==h?(ae=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:d?(0,Z.jsxs)(`div`,{className:`flex h-full min-h-56 items-center justify-center text-sm text-fg-muted`,children:[(0,Z.jsx)(Mt,{className:`mr-2 size-4 animate-spin`}),c.loading]}):p?(0,Z.jsxs)(`div`,{className:`rounded-lg border border-danger/30 bg-danger/5 p-4`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:c.errorTitle}),(0,Z.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:p}),(0,Z.jsxs)(mi,{type:`button`,className:`mt-4 h-9 rounded-lg`,variant:`secondary`,onClick:O,children:[(0,Z.jsx)(Mt,{className:`size-4`}),c.retry]})]}):h===`presets`?(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Z.jsx)(KE,{icon:(0,Z.jsx)(Pe,{className:`size-4`}),title:c.presetBase,description:l?.defaultBaseBranch?c.presetBaseDescription.replace(`{{branch}}`,l.defaultBaseBranch):c.presetBaseDescriptionNoDefault,disabled:i,onClick:()=>g(`base`)}),(0,Z.jsx)(KE,{icon:(0,Z.jsx)(Je,{className:`size-4`}),title:c.presetUncommitted,description:L,disabled:i,onClick:()=>z(`uncommitted`)}),(0,Z.jsx)(KE,{icon:(0,Z.jsx)(os,{className:`size-4`}),title:c.presetCommit,description:c.presetCommitDescription.replace(`{{count}}`,String(l?.commits.length??0)),disabled:i,onClick:()=>g(`commit`)}),(0,Z.jsx)(KE,{icon:(0,Z.jsx)(Je,{className:`size-4`}),title:c.presetCustom,description:c.presetCustomDescription,disabled:i,onClick:()=>g(`custom`)})]}):h===`base`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(JE,{value:_,placeholder:c.searchBranches,onChange:v}),(0,Z.jsx)(`div`,{className:`grid gap-1`,children:N.length===0?(0,Z.jsx)(`div`,{className:`rounded-lg border border-edge-subtle px-3 py-6 text-center text-sm text-fg-muted`,children:c.noBranches}):N.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`flex items-center justify-between gap-3 rounded-lg px-3 py-2 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,disabled:i,onClick:()=>z(`base`,{branch:e.name}),children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-sm text-fg`,children:e.name}),(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:e.name===l?.defaultBaseBranch?c.defaultBadge:e.remote?c.remoteBadge:c.localBadge})]},e.name))})]}):h===`commit`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(JE,{value:_,placeholder:c.searchCommits,onChange:v}),(0,Z.jsx)(`div`,{className:`grid gap-1`,children:F.length===0?(0,Z.jsx)(`div`,{className:`rounded-lg border border-edge-subtle px-3 py-6 text-center text-sm text-fg-muted`,children:c.noCommits}):F.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`flex items-center gap-3 rounded-lg px-3 py-2 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,disabled:i,onClick:()=>z(`commit`,{commit:e.sha}),children:[(0,Z.jsx)(`span`,{className:`font-mono text-xs text-fg-muted`,children:e.shortSha}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg`,children:e.subject}),e.date?(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:e.date.slice(0,10)}):null]},e.sha))})]}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(`textarea`,{className:`h-40 resize-none rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-disabled focus:border-accent focus:ring-2 focus:ring-accent/25`,value:y,placeholder:c.customPlaceholder,onChange:e=>x(e.target.value)}),(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:c.customDescription})]})}),t[41]=N,t[42]=F,t[43]=l,t[44]=i,t[45]=p,t[46]=y,t[47]=O,t[48]=d,t[49]=c.customDescription,t[50]=c.customPlaceholder,t[51]=c.defaultBadge,t[52]=c.errorTitle,t[53]=c.loading,t[54]=c.localBadge,t[55]=c.noBranches,t[56]=c.noCommits,t[57]=c.presetBase,t[58]=c.presetBaseDescription,t[59]=c.presetBaseDescriptionNoDefault,t[60]=c.presetCommit,t[61]=c.presetCommitDescription,t[62]=c.presetCustom,t[63]=c.presetCustomDescription,t[64]=c.presetUncommitted,t[65]=c.remoteBadge,t[66]=c.retry,t[67]=c.searchBranches,t[68]=c.searchCommits,t[69]=_,t[70]=z,t[71]=L,t[72]=h,t[73]=ae):ae=t[73];let K;t[74]!==i||t[75]!==c.cancel||t[76]!==c.runReview||t[77]!==o||t[78]!==z||t[79]!==h?(K=h===`custom`?(0,Z.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-4 py-3`,children:[(0,Z.jsx)(mi,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg`,onClick:o,children:c.cancel}),(0,Z.jsx)(mi,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,disabled:i,onClick:()=>z(`custom`),children:c.runReview})]}):null,t[74]=i,t[75]=c.cancel,t[76]=c.runReview,t[77]=o,t[78]=z,t[79]=h,t[80]=K):K=t[80];let oe;t[81]!==ie||t[82]!==ae||t[83]!==K?(oe=(0,Z.jsxs)(w,{children:[H,(0,Z.jsxs)(T,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[121] flex h-[min(86vh,34rem)] w-[min(100vw-2rem,40rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:[ie,ae,K]})]}),t[81]=ie,t[82]=ae,t[83]=K,t[84]=oe):oe=t[84];let se;return t[85]!==n||t[86]!==oe||t[87]!==V?(se=(0,Z.jsx)(D,{open:n,onOpenChange:V,children:oe}),t[85]=n,t[86]=oe,t[87]=V,t[88]=se):se=t[88],se}function JE(e){let t=(0,X.c)(7),{value:n,placeholder:r,onChange:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Ft,{className:`size-4 shrink-0 text-fg-muted`}),t[0]=a):a=t[0];let o;t[1]===i?o=t[2]:(o=e=>i(e.target.value),t[1]=i,t[2]=o);let s;return t[3]!==r||t[4]!==o||t[5]!==n?(s=(0,Z.jsxs)(`label`,{className:`flex h-9 items-center gap-2 rounded-lg border border-edge bg-surface-base px-3 text-sm text-fg focus-within:border-accent focus-within:ring-2 focus-within:ring-accent/25`,children:[a,(0,Z.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent outline-none placeholder:text-fg-disabled`,value:n,placeholder:r,onChange:o})]}),t[3]=r,t[4]=o,t[5]=n,t[6]=s):s=t[6],s}function YE(e){let t=e.mimeType||`application/octet-stream`,n=e.type===`voice`||t.startsWith(`audio/`)?`voice`:e.type===`pasted_text`?`pasted_text`:t.startsWith(`image/`)?`image`:`document`;return{id:e.id,type:n,name:e.name||`file`,mimeType:t,size:e.size??0,content:e.data??``,data:e.data,uri:e.uri,durationSeconds:e.durationSeconds}}var XE=(0,Q.memo)(function({personal:e=!1,placeholder:t,nextTurnSuggestionsEnabled:n=!1,disabled:r,sendDisabled:i=!1,sending:a,streaming:o,conversationId:s,composerContext:c,pageContextPreview:u,contextRefs:d,setContextRefs:f,onDraftAttachmentsChange:p,thinkingLevel:g,modelSupportsThinking:_,onThinkingChange:v,onSend:b,onPersonalSendDispatched:x,onAbort:S,onAddPendingFollowUp:C,onSteeringInterrupt:w,pendingFollowUps:T,editingFollowUpId:E,onBeginEditFollowUp:D,onCancelEditFollowUp:O,onCommitEditFollowUp:k,onPendingFollowUpRemove:A,onPendingFollowUpMove:j,onPendingFollowUpReorder:N,onPendingFollowUpSteer:P,onPendingFollowUpSend:F,steeringFollowUpId:I,welcomeDraftSeed:L,welcomeSuggestion:R,onAcceptWelcomeSuggestion:z,sessionModel:B,showModelSelector:V,onModelChange:H,modelDisabled:U,onChatAgentChange:W,currentAgentId:G,voiceAgentName:ee,voiceTaskId:te,voiceMode:ne,prepareVoiceSession:re,prepareContextSession:ie,editingUserTurnId:ae,composerMode:K,inputControl:oe,onResumeQueue:se,onRestoreEditor:q,onReacquireEdit:ce,onCancelUserMessageEdit:le}){let ue=M(),de=(0,Q.useRef)(!1);r||=ue.conversationId===s&&ue.active;let fe=h(e=>e.language),J=y(fe),[pe,me]=l();(0,Q.useEffect)(()=>{ho()},[]);let he=(...e)=>{if(i)return!1;let t=b(...e);return t instanceof Promise?t.then(t=>(t!==!1&&at.submitted(e[0]),t)):(t!==!1&&at.submitted(e[0]),t)},ge=(0,Q.useRef)(!1),_e=(0,Q.useRef)(null),ve=(0,Q.useRef)(null),ye=(0,Q.useRef)(null),be=(0,Q.useRef)(!1),[xe,Se]=(0,Q.useState)(!1),[Ce,we]=(0,Q.useState)(null),[Te,Ee]=(0,Q.useState)(null),[De,Oe]=(0,Q.useState)(!1),ke=(0,Q.useRef)(he),je=(0,Q.useRef)(g);ke.current=he,je.current=g,(0,Q.useEffect)(()=>{if(!s||Te===s){we(null);return}let e=!1;return Tr(s).then(e=>e?null:yo(s)).then(t=>{e||we(t&&t.required&&!t.trusted&&t.decision===null?t:null)}).catch(()=>{e||we(null)}),()=>{e=!0}},[s,Te]);let Me=(0,Q.useCallback)(()=>{!s||De||(Oe(!0),uo(s,!0).then(()=>{we(null)}).catch(e=>{Ne(`error`,J.chat.commandPalette.workspaceTrustFailed,{error:e instanceof Error?e.message:String(e)})}).finally(()=>Oe(!1)))},[J.chat.commandPalette,s,De]),Pe=ei({conversationId:s??`new`,chat:J.chat,onAttachmentsChange:e=>p?.(e.map((e,t)=>({id:e.uri||e.id||`draft:${t}:${e.name}`,title:e.name})))}),Fe=(0,Q.useRef)(d);Fe.current=d;let Ie=(0,Q.useCallback)(e=>{let t=d.find(t=>t.refId===e);return t?{title:t.title,kind:t.kind,fileKind:t.fileKind}:void 0},[d]),Le=(0,Q.useCallback)(e=>{let t=e?.contextRefs??[];if(Fe.current=t,f(t),e?.attachments){Pe.setAttachments(e.attachments.map(YE));return}Pe.clearAttachments()},[Pe.clearAttachments,Pe.setAttachments,f]),Re=(0,Q.useCallback)(e=>{let t=Fe.current,n=t.find(t=>t.kind===e.kind&&t.sourceId===e.sourceId);if(n){if(n.refId)return n;let r={...n,refId:e.refId},i=t.map(e=>e===n?r:e);return Fe.current=i,f(i),r}if(t.length>=5)return Ne(`warning`,J.chat.commandPalette.contextLimitReached,{max:5}),null;let r=[...t,e];return Fe.current=r,f(r),e},[J.chat.commandPalette.contextLimitReached,f]);(0,Q.useEffect)(()=>{let e=e=>{let t=e.detail;t?.conversationId!==s||t.reference.kind!==`result`||Re(t.reference)};return window.addEventListener(`chat-result-reference`,e),()=>window.removeEventListener(`chat-result-reference`,e)},[s,Re]);let ze=(0,Q.useCallback)(e=>{let t=e.availability.status===`agent-denied`?J.chat.commandPalette.skillAgentDeniedReason:J.chat.commandPalette.skillDisabledReason,n=Jp(J.chat.commandPalette.skillUnavailableMessage,{name:e.name,agent:G||`main`,reason:t});if(e.availability.status===`agent-denied`&&window.confirm(`${n}\n\n${J.chat.commandPalette.skillAddToAllowlistConfirm}`)){bo(G,e.canonicalName,s).catch(e=>{window.alert(e instanceof Error?e.message:String(e))});return}window.alert(n)},[G,J.chat.commandPalette,s]),Be=Hp({capabilities:e?qf:Kf,disabled:r,agentId:G,conversationId:s,autoFocusKey:s,welcomeDraftSeed:L,onExternalTextReplace:Le,shouldSyncSelectionRef:ge,resolveContextRef:Ie}),Ve=pe.get(`attachmentHandoff`);(0,Q.useEffect)(()=>{if(!Ve)return;let e=Ae(Ve);me(e=>{let t=new URLSearchParams(e);return t.delete(`attachmentHandoff`),t},{replace:!0}),e&&Pe.processFiles([e]).then(()=>Be.editorRef.current?.focus({preventScroll:!0}))},[Ve,Pe.processFiles,Be.editorRef,s,me]);let{onUserTextCommitted:He,onWireInputClearWalk:Ue,tryInputHistoryArrow:We}=sE({conversationId:s,editorRef:Be.editorRef,valueRef:Be.valueRef,resetEditor:Be.resetEditor,onWireInput:Be.onWireInput}),Ge=(0,Q.useCallback)((e,t)=>{Ue(e,t);let n=vr(e),r=new Set(n?xr(n):[]),i=Fe.current,a=i.filter(e=>!e.refId||r.has(e.refId));a.length!==i.length&&(Fe.current=a,f(a))},[Ue,f]),Ke=Ef(s??``),qe=a||o||Ke||oe?.phase===`running`||oe?.phase===`stopping`;be.current=qe;let Je=(0,Q.useCallback)(()=>{be.current||Se(!0)},[]),Ye=(0,Q.useCallback)(e=>{vT(ke.current(e,void 0,je.current,d),t=>{He?.(e,t),f([])})},[d,He,f]),Xe=RE({capabilities:e?qf:Kf,conversationId:s,editorValue:Be.value,editorCursor:Be.cursor,isComposing:Be.isComposing,runBusy:qe,thinkingLevel:g,editorRef:Be.editorRef,valueRef:Be.valueRef,resetEditor:Be.resetEditor,clearAttachments:Pe.clearAttachments,onSend:he,onUserTextCommitted:He,onChatAgentChange:W,currentAgentId:G,prepareSession:ie,contextRefs:d,onAddContextRef:Re,onUnavailableSkill:ze,onReviewLauncher:Je,onAddPendingFollowUp:C,onAbort:S,pendingFollowUpsCount:T.length,maxPendingFollowUps:10,clearContextRefs:()=>f([]),commandPalettePanelRef:_e});ge.current=Xe.shouldSyncSelection;let Ze=Di({disabled:r||ue.active,chat:J.chat,onTranscript:e=>{let t=Be.valueRef.current,n=ji(t,e);Be.resetEditor({nextText:n,caretOffset:n.length,focus:!0})}}),{phase:Qe,voiceActive:$e,startVoiceInput:et,cancelVoiceInput:tt,confirmVoiceInput:nt}=Ze;(0,Q.useEffect)(()=>{let e=e=>{if(!qw(e,{disabled:r,editorHidden:$e&&Qe!==`error`}))return;let t=Np(e.clipboardData);t&&(e.preventDefault(),Be.focusForExternalPaste(),Pp(t,{processFiles:Pe.processFiles,processPastedText:Pe.processPastedText,insertText:e=>document.execCommand(`insertText`,!1,e),onUnsupportedFiles:()=>Ne(`warning`,J.chat.clipboardFileTypeUnsupported)}))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[Pe.processFiles,Pe.processPastedText,r,Be.focusForExternalPaste,J.chat.clipboardFileTypeUnsupported,$e,Qe]),(0,Q.useEffect)(()=>{let e=e=>{let t=e?.detail?.target;if(!(t&&t!==`chat`)&&(e?.preventDefault(),!r)){if(Qe===`recording`){nt();return}(Qe===`idle`||Qe===`error`)&&(Be.editorRef.current?.focus({preventScroll:!0}),et())}},t=e=>{let t=e.detail?.target;t&&t!==`chat`||!$e||(e.preventDefault(),tt(),Be.editorRef.current?.focus({preventScroll:!0}))};window.addEventListener(Eo,e),window.addEventListener(wo,t);let n=window.setTimeout(()=>{if(Do()){if(r){To();return}e()}},0);return()=>{window.clearTimeout(n),window.removeEventListener(Eo,e),window.removeEventListener(wo,t)}},[tt,nt,r,Be.editorRef,et,$e,Qe]);let rt=(0,Q.useCallback)(()=>{ye.current=null},[]),it=n&&!r&&!i&&!qe&&!E&&!ae&&!Ze.voiceActive&&!Be.isComposing&&Be.value.length===0&&Pe.attachments.length===0&&d.length===0&&T.length===0,at=mE({conversationId:s,agentId:G,modelKey:B,locale:fe,enabled:n,draftText:Be.value,canShow:it}),ot=()=>{if(!it||Be.valueRef.current.length>0||Fe.current.length>0)return!1;let e=at.accept();return e?(Be.resetEditor({nextText:e,focus:!0}),!0):!1};(0,Q.useEffect)(()=>{it&&at.suggestion&&!Xe.palette.open&&at.shown()},[it,at.suggestion,at.shown,Xe.palette.open]);let st=m(e=>e.conversationId),ct=JSON.stringify([st,s]),lt=(0,Q.useRef)(new Map),ut=(0,Q.useRef)(`compose`),dt=K??(E?{kind:`editFollowUp`,inputId:E,version:0}:{kind:`compose`}),ft=dt.kind===`editTurn`?`turn:${dt.turnId}`:dt.kind===`editFollowUp`?`input:${dt.inputId}`:`compose`;(0,Q.useLayoutEffect)(()=>{lt.current.clear(),ut.current=`compose`},[ct]),pE(s,Be,Pe,d,f,{snapshot:()=>({mode:dt,drafts:Object.fromEntries(lt.current)}),restore:e=>{lt.current=new Map(Object.entries(e.drafts)),ut.current=e.mode.kind===`editTurn`?`turn:${e.mode.turnId}`:e.mode.kind===`editFollowUp`?`input:${e.mode.inputId}`:`compose`,q?.(e.mode)}});let pt=dt.kind!==`compose`&&!!(oe&&!oe.paused),mt=uE({personal:e,chat:J.chat,runBusy:qe,draftScope:ct,queuePaused:oe?.paused,editingUserTurnId:ae,blocked:r||i||pt||oe?.phase===`stopping`,onFinishUserEdit:le,onFinishFollowUpEdit:O,voiceActive:Ze.voiceActive,cancelVoiceInput:Ze.cancelVoiceInput,editingFollowUpId:E,getTextValue:()=>Be.valueRef.current,getAttachmentCount:()=>Pe.attachmentsRef.current.length,wireAttachmentsPayload:Pe.wireAttachmentsPayload,getContextRefs:()=>d,getThinkingLevel:()=>je.current,onSend:he,onDispatched:e&&x?(e,t)=>{let n=Be.editorRef.current?.getBoundingClientRect();n&&x(e,n,t)}:void 0,onAddPendingFollowUp:C,onSteeringInterrupt:w,onCommitEditFollowUp:k,onPendingFollowUpRemove:A,pendingFollowUpsCount:T.length,firstPendingFollowUpId:T[0]?.id,onSteerPendingFollowUp:P,steeringPending:!!I,resetEditor:()=>{Be.resetEditor()},clearAttachments:Pe.clearAttachments,clearContextRefs:()=>f([]),clearEditFollowUpRef:rt,onUserTextCommitted:He}),ht=(0,Q.useCallback)((e=!1)=>mt.flushSteeringDraft(e),[mt.flushSteeringDraft]),gt=(0,Q.useCallback)((e,t)=>{!s||s===`new`||_w.getState().requestCreate(s,[{id:e.id,type:`text`,text:t,label:J.chat.followUpQueueHeading}])},[s,J.chat.followUpQueueHeading]);(0,Q.useLayoutEffect)(()=>{if(ut.current===ft)return;lt.current.set(ut.current,{text:Be.valueRef.current,attachments:Pe.wireAttachmentsPayload(),contextRefs:Fe.current,thinkingLevel:je.current}),ut.current=ft;let e=dt.kind===`editFollowUp`?T.find(e=>e.id===dt.inputId):void 0;e?.thinkingLevel&&_&&v(e.thinkingLevel);let t=(dt.kind===`compose`?dt.draft:void 0)??lt.current.get(ft)??(dt.kind===`editTurn`?dt.draft:e?{text:e.text,attachments:e.attachments??[],contextRefs:e.contextRefs??[]}:void 0);t?.thinkingLevel&&_&&v(t.thinkingLevel),Pe.setAttachments(uT(t?.attachments??[])),f(t?.contextRefs??[]),Be.resetEditor({nextText:t?.text??``,focus:!0})},[ft,dt,T,Pe,Be,f]);let _t=(0,Q.useCallback)(e=>{D(e)},[D]),vt=(0,Q.useRef)({});vt.current={adapters:Xe.adapters,send:mt.send,runBusy:qe,pendingFollowUpsCount:T.length,flushSteeringDraft:ht,steerDraft:()=>mt.flushSteeringDraft(!1,`steer`),steerCurrentReply:mt.steerCurrentReply,interruptDraft:mt.interruptDraft,editingFollowUpId:E,editingUserTurnId:ae,onCancelUserMessageEdit:le,onCancelEditFollowUp:O,attachmentsLen:Pe.attachments.length,contextRefsLen:d.length,isComposing:Be.isComposing,valueRef:Be.valueRef,adjustHeight:Be.adjustHeight,editorRef:Be.editorRef,tryInputHistoryArrow:We,acceptEmptySuggestion:at.suggestion&&it?ot:!qe&&!r&&!i&&!ae&&!Ze.voiceActive&&R&&z?()=>(z(R),!0):void 0,dismissEmptySuggestion:at.suggestion?at.dismiss:void 0};let yt=qe&&!E&&!ae,bt={...J.chat,sendMessage:E?J.chat.followUpSaveEdit:ae?J.chat.userMessageReplaceSend:oe?.paused?J.chat.sendThisMessage:J.chat.sendMessage},xt=!!Be.value.trim()||Pe.attachments.length>0||d.length>0,St=!yt||!!I||oe?.phase===`stopping`||!xt&&T.length===0,Ct=xt&&!!w,wt=Go(`(hover: hover) and (pointer: fine)`),Tt=!yt&&!E&&R?`${R.prompt}${wt?` · ${J.chat.welcomeSpotlight.acceptSuggestionHint}`:``}`:null;return(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 w-full flex-col`,children:[s?(0,Z.jsx)(Uw,{conversationId:s},s):null,c?(0,Z.jsx)(nT,{...c,conversationId:s,disabled:(c.disabled??r)||a||o}):null,(0,Z.jsxs)(Gp,{className:e?`rounded-[1.65rem]`:void 0,dragging:Pe.isDragging,onDragOver:e=>{(e.dataTransfer?.types.includes(`Files`)||If(e.dataTransfer))&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,Pe.setIsDragging(!0))},onDragLeave:e=>{e.relatedTarget===null&&Pe.setIsDragging(!1)},onDrop:async e=>{e.preventDefault(),Pe.setIsDragging(!1);let t=e.dataTransfer?.files;if(t?.length){await Pe.processFiles(Array.from(t));return}let n=Lf(e.dataTransfer);if(n)try{let e=await Pa(n.path,{conversationId:n.conversationId,agentId:n.agentId,projectId:n.projectId}),t=ii(n.name),r=e.type&&e.type!==`application/octet-stream`?e.type:t;await Pe.processFiles([new File([e],n.name,{type:r})])}catch{Ne(`error`,J.chat.attachmentLoadFailed,{name:n.name})}},children:[Pe.isDragging?(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-10 flex items-center justify-center rounded-xl bg-accent-soft/80 text-sm font-medium text-accent-fg backdrop-blur-[1px]`,children:J.chat.dropFiles}):null,ae?(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-edge-subtle bg-accent-soft/40 px-4 py-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:J.chat.userMessageEditing}),(0,Z.jsx)(`button`,{type:`button`,className:`font-medium text-accent-fg hover:underline`,onClick:le,children:J.chat.userMessageEditCancel})]}):null,pt&&(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge-subtle px-4 py-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:J.chat.editQueueResumed}),(0,Z.jsx)(`button`,{type:`button`,disabled:r||i,className:`text-accent-fg disabled:opacity-40`,onClick:()=>ce?.({text:Be.valueRef.current,attachments:Pe.wireAttachmentsPayload(),contextRefs:Fe.current}),children:J.chat.editPauseAgain})]}),oe?.paused&&(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge-subtle px-4 py-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:oe.phase===`stopping`?J.chat.inputStopping:oe.reviewRequired?J.chat.queueReviewRequired:J.chat.queuePaused}),(0,Z.jsx)(`button`,{type:`button`,disabled:r||i||!!(E||ae)||oe.phase!==`idle`,className:`text-accent-fg disabled:opacity-40`,onClick:se,children:J.chat.queueResume})]}),(0,Z.jsx)($w,{conversationId:s}),T.length>0?(0,Z.jsx)(`div`,{className:`max-h-[min(30vh,11rem)] shrink-0 overflow-y-auto overflow-x-hidden border-b border-edge-subtle/80 [scrollbar-gutter:stable] dark:border-edge-subtle/70`,children:(0,Z.jsx)(Qw,{items:T,disabled:r||i||!!(ae||E),editingFollowUpId:E,onEditInComposer:_t,onRemove:A,onMove:j,onReorder:N,onSteer:P,onSendSingle:F,queuePaused:oe?.paused,queueIdle:oe?.phase===`idle`,steeringBusyId:I,onOpenSideChat:s&&s!==`new`?gt:void 0})}):null,(E||ae)&&(0,Z.jsx)(`div`,{className:`flex items-center justify-end px-4 py-1 text-xs`,children:(0,Z.jsx)(`button`,{type:`button`,disabled:i,className:`text-accent-fg disabled:opacity-40`,onClick:()=>q?.({kind:`compose`,draft:{text:Be.valueRef.current,attachments:Pe.wireAttachmentsPayload(),contextRefs:Fe.current}}),children:J.chat.editAsNewMessage})}),dt.kind===`editFollowUp`&&T.some(e=>e.id===dt.inputId&&e.version!==dt.version)&&(0,Z.jsxs)(`div`,{className:`border-b border-edge-subtle px-4 py-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`p`,{children:J.chat.followUpEditConflict}),(0,Z.jsx)(`p`,{className:`my-1 max-h-20 overflow-auto whitespace-pre-wrap`,children:T.find(e=>e.id===dt.inputId)?.text}),(0,Z.jsx)(`button`,{type:`button`,disabled:i,className:`text-accent-fg`,onClick:()=>D(dt.inputId),children:J.chat.followUpKeepMyEdit})]}),E?(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-4 py-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:J.chat.inputPlaceholderSteeringEdit}),(0,Z.jsx)(`button`,{type:`button`,onClick:O,className:`shrink-0 rounded px-1 text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:J.chat.userMessageEditCancel})]}):null,(0,Z.jsx)(Xr,{attachments:Pe.attachments,conversationId:s,topPadded:T.length>0,onRemove:Pe.removeAttachment}),(0,Z.jsx)(eT,{refs:d.filter(e=>!e.refId),label:J.chat.commandPalette.contextLabel,onRemove:e=>f(t=>t.filter(t=>t.sourceId!==e))}),u,(0,Z.jsxs)(`div`,{className:e?`flex min-h-0 shrink-0 items-end gap-1 px-1.5 py-1.5 sm:px-2`:`flex min-h-0 shrink-0 flex-col`,children:[(0,Z.jsx)(`input`,{ref:ve,type:`file`,multiple:!0,className:`hidden`,onChange:async e=>{let t=e.target.files;t&&await Pe.processFiles(Array.from(t)),e.target.value=``}}),e&&!Ze.voiceActive&&(0,Z.jsx)(cT,{disabled:r||i,attachmentCount:Pe.attachments.length,maxAttachments:10,chat:J.chat,onPickFiles:()=>ve.current?.click()}),(0,Z.jsxs)(`div`,{className:e?`relative min-w-0 flex-1 px-1`:Y(`relative px-3 pb-0 pt-1 sm:px-4`,Pe.attachments.length>0&&`pt-2`),children:[(0,Z.jsx)(_T,{open:Xe.atPicker.open,anchorRef:Be.editorRef,items:Xe.atPicker.items,selectedIndex:Xe.atPicker.selectedIndex,loading:Xe.atPicker.loading,query:Xe.atPicker.query,noResults:Xe.atPicker.error??J.chat.atMention.noResults,conversationId:s,recentLabel:J.chat.atMention.recentBadge,sectionLabels:{file:J.chat.atMention.files,note:J.chat.atMention.notes,session:J.chat.atMention.chats,skill:J.chat.atMention.skills,agent:J.chat.atMention.agents,browser_tab:J.chat.atMention.browserTabs},ariaLabel:J.chat.atMention.placeholder,onSelectItem:Xe.applyAtMention}),(0,Z.jsx)(JT,{open:Xe.palette.open,anchorRef:Be.editorRef,panelRef:_e,sections:Xe.palette.loadError?[]:Xe.palette.sections,flatItems:Xe.palette.loadError?[]:Xe.palette.flatItems,loading:Xe.palette.loading,failedKinds:Xe.palette.failedKinds,selectedIndex:Xe.palette.selectedIndex,noResults:Xe.palette.loadError??J.chat.commandPalette.noResults,sectionLoadFailedLabel:J.chat.commandPalette.sectionLoadFailed,query:Xe.palette.query,skillsLabel:J.chat.commandPalette.skillsSection,commandsLabel:J.chat.commandPalette.commandsSection,agentsLabel:J.chat.commandPalette.agentsSection,currentAgentId:G,currentBadgeLabel:J.chat.commandPalette.currentBadge,runBusy:qe,pendingFollowUpsCount:T.length,maxPendingFollowUps:10,queueBadgeLabel:J.chat.commandPalette.queueBadge,queueFullBadgeLabel:J.chat.commandPalette.queueFullBadge,queueFullTooltip:J.chat.commandPalette.queueFullTooltip,skillUnavailableLabel:J.chat.commandPalette.skillUnavailableBadge,skillAgentDeniedLabel:J.chat.commandPalette.skillAgentDeniedBadge,skillSourceLabels:{builtin:J.chat.commandPalette.sourceBuiltin,workspace:J.chat.commandPalette.sourceWorkspace,global:J.chat.commandPalette.sourceGlobal,extra:J.chat.commandPalette.sourceExtra},onSelectItem:Xe.applyPalette}),Ze.voiceActive?(0,Z.jsx)(Ii,{phase:Ze.phase,elapsedLabel:Ze.elapsedLabel,recordedDictation:Ze.recordedDictation,audioLevel:Ze.audioLevel,partialTranscript:Ze.partialTranscript,finalTranscript:Ze.finalTranscript,error:Ze.error,settingsRequired:Ze.settingsRequired,disabled:r,chat:J.chat,onCancel:Ze.cancelVoiceInput,onConfirm:Ze.confirmVoiceInput,onRetry:Ze.retryVoiceInput}):null,(0,Z.jsx)(Up,{editorRef:Be.editorRef,disabled:r,hidden:Ze.voiceActive&&Ze.phase!==`error`,compact:e,ariaLabel:t??J.chat.inputPlaceholder,placeholder:(it&&at.suggestion?`${at.suggestion.prompt}${wt?` · ${J.chat.welcomeSpotlight.acceptSuggestionHint}`:``}`:null)??t??Tt??(yt?E?J.chat.inputPlaceholderSteeringEdit:e?J.chat.inputPlaceholderImmediate:J.chat.inputPlaceholderSteering:J.chat.inputPlaceholder),onWireInput:Ge,adjustHeight:Be.adjustHeight,processFiles:Pe.processFiles,processPastedText:Pe.processPastedText,setIsComposing:Be.setIsComposing,kbdRef:vt,chatMessages:J.chat})]}),e?(0,Z.jsx)(lT,{disabled:r||i||pt,voiceActive:Ze.voiceActive,runBusy:yt,hasDraft:xt,chat:bt,onStartVoiceInput:Ze.startVoiceInput,onSend:mt.send,onQueue:C?mt.send:void 0,onDefer:C?()=>mt.flushSteeringDraft(!1):void 0,onAbort:S,onInterrupt:mt.interruptDraft,onSteer:mt.steerCurrentReply,steerDisabled:St}):(0,Z.jsx)(Qp,{disabled:r,sendDisabled:i||pt,sending:a,streaming:o,runBusy:yt,chat:bt,hasDraft:xt,showSteeringInterrupt:Ct,attachmentCount:Pe.attachments.length,maxAttachments:10,onPickFiles:()=>ve.current?.click(),thinkingLevel:g,onThinkingChange:v,voiceActive:Ze.voiceActive,onStartVoiceInput:Ze.startVoiceInput,voiceConversationEnabled:!!(s||re)&&!yt,onStartVoiceConversation:()=>{if(!de.current){if(s){ue.open({conversationId:s,name:ee||G||`xopc`,taskId:te,mode:ne});return}re&&(de.current=!0,re().then(e=>ue.open({conversationId:e,name:ee||G||`xopc`,taskId:te,mode:ne})).catch(e=>Ne(`error`,e instanceof Error?e.message:J.chat.callFailed)).finally(()=>{de.current=!1}))}},onSend:mt.send,onAbort:S,onInterrupt:mt.interruptDraft,sessionModel:B,showModelSelector:V,onModelChange:H,modelDisabled:U})]}),(0,Z.jsx)(qE,{open:xe,conversationId:s,disabled:r||yt,chat:J.chat,onClose:()=>Se(!1),onSendCommand:Ye}),(0,Z.jsx)(Na,{open:Ce!==null,title:J.chat.commandPalette.workspaceTrustTitle,description:Jp(J.chat.commandPalette.workspaceTrustDescription,{path:Ce?.workspacePath??``}),confirmLabel:De?J.chat.commandPalette.workspaceTrustSaving:J.chat.commandPalette.workspaceTrustConfirm,cancelLabel:J.chat.commandPalette.workspaceTrustCancel,onConfirm:Me,onCancel:()=>{we(null),Ee(s)}})]})]})});function ZE(e){let t=(0,X.c)(42),{draft:n,onRemove:r,disabled:i,waiting:a}=e,o=i!==void 0&&i,s=a!==void 0&&a,c=h($E),l;t[0]===c?l=t[1]:(l=y(c),t[0]=c,t[1]=l);let u=l.chat.pageContext,d=u.label,f;t[2]!==n.title||t[3]!==u.preview?(f=(0,Z.jsxs)(`summary`,{className:`cursor-pointer break-words rounded text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[u.preview,`: `,n.title]}),t[2]=n.title,t[3]=u.preview,t[4]=f):f=t[4];let p;t[5]===u.frozen?p=t[6]:(p=(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:u.frozen}),t[5]=u.frozen,t[6]=p);let m;t[7]===n.envelope.resourceRefs?m=t[8]:(m=n.envelope.resourceRefs.map(QE).join(`, `),t[7]=n.envelope.resourceRefs,t[8]=m);let g;t[9]===m?g=t[10]:(g=(0,Z.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:m}),t[9]=m,t[10]=g);let _;t[11]===n.preview?_=t[12]:(_=(0,Z.jsx)(`pre`,{className:`mt-2 max-h-48 overflow-y-auto whitespace-pre-wrap break-words font-sans text-sm text-fg`,children:n.preview}),t[11]=n.preview,t[12]=_);let v;t[13]!==n.truncated||t[14]!==u.truncated?(v=n.truncated?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:u.truncated}):null,t[13]=n.truncated,t[14]=u.truncated,t[15]=v):v=t[15];let b;t[16]!==n.envelope.selection||t[17]!==u.draft||t[18]!==u.selection?(b=n.envelope.selection?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`mt-2 text-xs font-medium text-fg`,children:n.envelope.selection.draft?u.draft:u.selection}),(0,Z.jsx)(`pre`,{className:`mt-1 max-h-36 overflow-y-auto whitespace-pre-wrap break-words font-sans text-sm text-fg`,children:n.envelope.selection.text})]}):null,t[16]=n.envelope.selection,t[17]=u.draft,t[18]=u.selection,t[19]=b):b=t[19];let x;t[20]!==v||t[21]!==b||t[22]!==f||t[23]!==p||t[24]!==g||t[25]!==_?(x=(0,Z.jsxs)(`details`,{className:`min-w-0 flex-1`,children:[f,p,g,_,v,b]}),t[20]=v,t[21]=b,t[22]=f,t[23]=p,t[24]=g,t[25]=_,t[26]=x):x=t[26];let S=`${u.remove}: ${n.title}`,C;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Z.jsx)(qt,{className:`size-4`,"aria-hidden":!0}),t[27]=C):C=t[27];let w;t[28]!==o||t[29]!==r||t[30]!==S?(w=(0,Z.jsx)(`button`,{type:`button`,onClick:r,disabled:o,"aria-label":S,className:`inline-flex size-8 shrink-0 items-center justify-center rounded text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:C}),t[28]=o,t[29]=r,t[30]=S,t[31]=w):w=t[31];let T;t[32]!==x||t[33]!==w?(T=(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[x,w]}),t[32]=x,t[33]=w,t[34]=T):T=t[34];let E;t[35]!==u.pending||t[36]!==s?(E=s?(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,role:`status`,children:u.pending}):null,t[35]=u.pending,t[36]=s,t[37]=E):E=t[37];let D;return t[38]!==u.label||t[39]!==T||t[40]!==E?(D=(0,Z.jsxs)(`section`,{className:`mx-4 mt-2 min-w-0 rounded-lg border border-edge bg-surface-hover p-3`,"aria-label":d,children:[T,E]}),t[38]=u.label,t[39]=T,t[40]=E,t[41]=D):D=t[41],D}function QE(e){return`${e.kind} · ${e.id} · v${e.revision}`}function $E(e){return e.language}function eD(e){let t=(0,X.c)(30),{selection:n}=e,r=h(tD)===`zh`,{mode:i,options:a,checking:o,checkFailed:s,failure:c,busy:l,changeMode:u,retry:d}=n,f=s?r?`无法检查运行环境,请重试。`:`Could not check the environment. Retry.`:a?.worktreeUnavailableReason===`workspace_unavailable`?r?`项目目录不可用,请在项目设置中检查路径。`:`Project directory unavailable. Check its path in project settings.`:null;if(!s&&a?.worktreeUnavailableReason===`git_commit_required`){let e;return t[0]===c?e=t[1]:(e=c?(0,Z.jsx)(`p`,{role:`alert`,className:`w-full px-2 py-1 text-xs text-danger`,children:c}):null,t[0]=c,t[1]=e),e}let p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(Ke,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[2]=p):p=t[2];let m=p,g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsx)(hs,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[3]=g):g=t[3];let _=g,v=r?`运行位置`:`Work in`,y;t[4]!==l||t[5]!==u||t[6]!==s||t[7]!==v||t[8]!==i||t[9]!==a||t[10]!==r?(y=!a&&!s?(0,Z.jsx)(Yt,{className:`h-8 w-36 rounded-full`}):(0,Z.jsx)(le,{ariaLabel:r?`新会话运行位置`:`New session environment`,placeholder:v,title:r?`Local 指 xopc Gateway 所在机器;首次发送时创建所选环境。`:`Local means the machine running xopc Gateway. The selected environment is created on first send.`,triggerIcon:l?(0,Z.jsx)(Xe,{className:`size-4 shrink-0 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}):i===`managed_worktree`?_:m,triggerClassName:`h-8 w-auto max-w-full justify-start gap-1.5 rounded-full border-0 bg-surface-hover px-2.5 hover:bg-surface-active [&>svg:last-child]:hidden`,contentClassName:`xopc-composer-config-popover w-max min-w-0 max-w-[calc(100vw-1.5rem)]`,side:`top`,allowEmpty:!1,value:i,disabled:l||s,options:[{value:`local_checkout`,label:`Local`,icon:m,group:v,disabled:!a?.localAvailable},{value:`managed_worktree`,label:`New local worktree`,icon:_,group:v,disabled:!a||!!a.worktreeUnavailableReason}],onChange:e=>u(e)}),t[4]=l,t[5]=u,t[6]=s,t[7]=v,t[8]=i,t[9]=a,t[10]=r,t[11]=y):y=t[11];let b;t[12]!==l||t[13]!==o||t[14]!==c||t[15]!==i||t[16]!==a?.worktreeUnavailableReason||t[17]!==f||t[18]!==d||t[19]!==r?(b=f||c||i===`managed_worktree`&&a?.worktreeUnavailableReason?(0,Z.jsx)(mi,{variant:`ghost`,className:`size-8 rounded-full p-0`,disabled:l||o,onClick:d,"aria-label":r?`重新检查环境`:`Recheck environment`,children:(0,Z.jsx)(Mt,{className:`size-3.5 `+(o?`animate-spin motion-reduce:animate-none`:``),"aria-hidden":!0})}):null,t[12]=l,t[13]=o,t[14]=c,t[15]=i,t[16]=a?.worktreeUnavailableReason,t[17]=f,t[18]=d,t[19]=r,t[20]=b):b=t[20];let x;t[21]===f?x=t[22]:(x=f?(0,Z.jsx)(`p`,{role:`status`,className:`w-full px-2 py-1 text-xs leading-5 text-fg-muted`,children:f}):null,t[21]=f,t[22]=x);let S;t[23]===c?S=t[24]:(S=c?(0,Z.jsx)(`p`,{role:`alert`,className:`max-h-20 w-full overflow-y-auto break-words px-2 py-1 text-xs leading-5 text-danger`,children:c}):null,t[23]=c,t[24]=S);let C;return t[25]!==y||t[26]!==b||t[27]!==x||t[28]!==S?(C=(0,Z.jsxs)(Z.Fragment,{children:[y,b,x,S]}),t[25]=y,t[26]=b,t[27]=x,t[28]=S,t[29]=C):C=t[29],C}function tD(e){return e.language}function nD({preparation:e,conversationId:t,ready:n,onSend:r}){let i=m(e=>e.conversationId),a=m(e=>e.baseUrl),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(null),f=(0,Q.useRef)(null),h=(0,Q.useRef)(!1),_=(0,Q.useRef)(r);_.current=r;let v=(0,Q.useRef)(t);v.current=t;let{data:y,error:b,isValidating:x,mutate:S}=Kr(e?[`project-environment-options`,a,i,e.project.id]:null,async()=>(await g(p(`/api/projects/${encodeURIComponent(e.project.id)}/environment-options`))).options,{keepPreviousData:!1,revalidateOnFocus:!1,shouldRetryOnError:!1}),C=y?.localAvailable&&y.worktreeUnavailableReason!==`git_commit_required`&&y.worktreeUnavailableReason!==`workspace_unavailable`?o?.preparation===e?o.mode:e?Br(Ur(),e.project.id)??`local_checkout`:`local_checkout`:`local_checkout`,w=!!(!b&&y?.localAvailable&&(C===`local_checkout`||!y.worktreeUnavailableReason)),T=(0,Q.useCallback)(e=>{let t=f.current;f.current=null,d(null),t?.resolve(e?t.conversationId:null)},[]);(0,Q.useEffect)(()=>{if(u){if(u.baseUrl!==a||u.token!==i){T(!1);return}u.conversationId&&(t===u.conversationId?n&&T(!0):e!==u.preparation&&T(!1))}},[u,t,n,e,T,a,i]),(0,Q.useEffect)(()=>()=>{f.current?.resolve(null),f.current=null},[]);let E=(0,Q.useCallback)(async()=>{if(!e)return t;let n=f.current;if(n)return n.preparation===e?n.completion:null;if(!w||x)return null;l(null);let r,o=new Promise(e=>{r=e}),s={preparation:e,baseUrl:a,token:i,conversationId:null,completion:o,resolve:r};return f.current=s,d(s),Promise.resolve().then(()=>e.create(C)).then(t=>{if(f.current!==s)return;Lr(e.project.id,C);let n={...s,conversationId:t};f.current=n,d(n)}).catch(t=>{f.current===s&&(l({preparation:e,message:t instanceof Error?t.message:String(t)}),S(),T(!1))}),o},[w,a,T,x,C,S,e,t,i]);return{mode:C,options:y,checking:x,checkFailed:!!b,allowed:w,busy:!!(u&&(u.preparation===e||u.conversationId&&u.conversationId===t)),failure:c?.preparation===e?c.message:null,changeMode:t=>{!e||f.current||(s({preparation:e,mode:t}),l(null))},retry:()=>void S(),prepareSession:E,send:async(...n)=>{let r=t;if(e){if(h.current)return!1;h.current=!0;try{let e=await E();if(!e)return!1;r=e,n[2]=void 0}finally{h.current=!1}}return!r||v.current!==r?!1:await _.current(...n)!==!1&&{conversationId:r}}}}function rD(e,t){let n=(0,X.c)(12),r=m(aD),i=m(iD),a;n[0]===e?a=n[1]:(a=t=>e?t.sessions[e]?.localDraft:void 0,n[0]=e,n[1]=a);let o=Nn(a),s;n[2]!==i||n[3]!==e||n[4]!==t||n[5]!==o||n[6]!==r?(s=e||t?[`chat-project-scope`,i,r,e,t,o===!0?`draft`:o===!1?`persisted`:`unknown`]:null,n[2]=i,n[3]=e,n[4]=t,n[5]=o,n[6]=r,n[7]=s):s=n[7];let c;n[8]!==e||n[9]!==t?(c=async()=>{let n=e?await Tr(e):void 0,r=n?n.creation.projectId:e?(await fn(e)).projectId:t;return r?ln(r):null},n[8]=e,n[9]=t,n[10]=c):c=n[10];let l;n[11]===Symbol.for(`react.memo_cache_sentinel`)?(l={keepPreviousData:!1,shouldRetryOnError:!1},n[11]=l):l=n[11];let{data:u,error:d}=Kr(s,c,l);return d?null:u??null}function iD(e){return e.baseUrl}function aD(e){return e.conversationId}function oD(e,t){let n=Ho(e,t),r=Uo(e,t);return`${e.id} ${n} ${r}`.toLowerCase()}function sD(e,t,n){let r=t.trim().toLowerCase();if(!r)return e;let i=r.split(/\s+/).filter(Boolean);return e.filter(e=>{let t=oD(e,n);return i.every(e=>t.includes(e))})}function cD(e){let t=(0,X.c)(57),{items:n,value:r,disabled:i,placeholder:a,searchPlaceholder:o,noMatches:s,compact:c,contentSide:l,contentAlign:u,className:d,onChange:f}=e,p=l===void 0?`bottom`:l,m=u===void 0?`end`:u,g=h(uD),_;t[0]===g?_=t[1]:(_=y(g),t[0]=g,t[1]=_);let v=_.agentsSettings,[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(``),w;t[2]!==v||t[3]!==n||t[4]!==S?(w=sD(n,S,v),t[2]=v,t[3]=n,t[4]=S,t[5]=w):w=t[5];let T=w,E,D,O;if(t[6]!==v||t[7]!==n||t[8]!==a||t[9]!==r){let e;t[13]===r?e=t[14]:(e=e=>e.id===r,t[13]=r,t[14]=e),D=n.find(e),E=D?Ho(D,v):r||a,O=D?[Ho(D,v),Uo(D,v)].filter(Boolean).join(` — `):void 0,t[6]=v,t[7]=n,t[8]=a,t[9]=r,t[10]=E,t[11]=D,t[12]=O}else E=t[10],D=t[11],O=t[12];let k=O??a,A=c&&`min-w-0 max-w-[min(calc(15ch+3rem),calc(100vw-8rem))] py-1.5 text-[13px]`,j;t[15]!==d||t[16]!==A?(j=Y(ya,`items-center gap-2 rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-2 text-left text-sm font-normal text-fg`,ua.transition,`hover:border-edge hover:bg-surface-hover/45`,ba,va,`disabled:cursor-not-allowed disabled:opacity-50`,`dark:border-edge-subtle dark:hover:bg-surface-hover/55`,A,d),t[15]=d,t[16]=A,t[17]=j):j=t[17];let M;t[18]!==D?.avatar||t[19]!==r?(M=r?(0,Z.jsx)(Ta,{agentId:r,avatar:D?.avatar,size:28,className:`shrink-0`}):null,t[18]=D?.avatar,t[19]=r,t[20]=M):M=t[20];let N=c?`max-w-[15ch] shrink`:`flex-1`,P;t[21]===N?P=t[22]:(P=Y(`min-w-0 truncate text-left`,N),t[21]=N,t[22]=P);let F;t[23]!==E||t[24]!==P?(F=(0,Z.jsx)(`span`,{className:P,children:E}),t[23]=E,t[24]=P,t[25]=F):F=t[25];let I;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(oe,{className:`size-4 shrink-0 text-fg-subtle opacity-70`,"aria-hidden":!0}),t[26]=I):I=t[26];let L;t[27]!==i||t[28]!==F||t[29]!==k||t[30]!==j||t[31]!==M?(L=(0,Z.jsx)(bi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,disabled:i,title:k,className:j,children:[M,F,I]})}),t[27]=i,t[28]=F,t[29]=k,t[30]=j,t[31]=M,t[32]=L):L=t[32];let R;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(R=Y(K,`z-50 w-[var(--radix-popover-trigger-width)] min-w-[12rem] rounded-lg border border-edge bg-surface-overlay shadow-md`,ua),t[33]=R):R=t[33];let z;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>C(e.target.value),t[34]=z):z=t[34];let B;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(B=Y(`w-full rounded-md border border-edge bg-surface-panel px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-muted`,ba),t[35]=B):B=t[35];let V;t[36]!==S||t[37]!==o?(V=(0,Z.jsx)(`div`,{className:`shrink-0 border-b border-edge p-2`,children:(0,Z.jsx)(`input`,{type:`search`,value:S,onChange:z,placeholder:o,className:B,"aria-label":o})}),t[36]=S,t[37]=o,t[38]=V):V=t[38];let H;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(H=Y(q,`max-h-64 p-1`),t[39]=H):H=t[39];let U;t[40]!==v||t[41]!==T||t[42]!==s||t[43]!==f||t[44]!==r?(U=T.length===0?(0,Z.jsx)(`li`,{className:`p-2 text-sm text-fg-muted`,children:s}):T.map(e=>{let t=e.id===r,n=Ho(e,v),i=Uo(e,v),a=i.length>0?i:void 0;return(0,Z.jsx)(`li`,{role:`option`,"aria-selected":t,children:(0,Z.jsxs)(`button`,{type:`button`,className:Y(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-fg`,t?`bg-surface-hover`:`hover:bg-surface-hover`),onClick:()=>{f(e.id),x(!1),C(``)},children:[(0,Z.jsx)(Ta,{agentId:e.id,avatar:e.avatar,size:32,className:`shrink-0`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`block truncate font-medium leading-tight`,title:n,children:n}),i?(0,Z.jsx)(`span`,{className:`mt-0.5 block truncate text-xs leading-tight text-fg-muted`,title:a,children:i}):null]}),(0,Z.jsx)(ee,{className:Y(`size-4 shrink-0`,t?`opacity-100`:`opacity-0`),"aria-hidden":!0})]})},e.id)}),t[40]=v,t[41]=T,t[42]=s,t[43]=f,t[44]=r,t[45]=U):U=t[45];let W;t[46]===U?W=t[47]:(W=(0,Z.jsx)(`ul`,{"data-select-scroll-region":!0,className:H,role:`listbox`,children:U}),t[46]=U,t[47]=W);let G;t[48]!==m||t[49]!==p||t[50]!==V||t[51]!==W?(G=(0,Z.jsx)(gi,{children:(0,Z.jsxs)(_i,{side:p,align:m,sideOffset:4,collisionPadding:8,className:R,onOpenAutoFocus:lD,children:[V,W]})}),t[48]=m,t[49]=p,t[50]=V,t[51]=W,t[52]=G):G=t[52];let te;return t[53]!==b||t[54]!==L||t[55]!==G?(te=(0,Z.jsxs)(vi,{open:b,onOpenChange:x,children:[L,G]}),t[53]=b,t[54]=L,t[55]=G,t[56]=te):te=t[56],te}function lD(e){return e.preventDefault()}function uD(e){return e.language}function dD(e,t,n=[],r){let i=new Map;for(let t of e)i.set(`${t.kind}:${t.id}`,{...t,pending:!1});let a=(e,t,n,r)=>{let a=`${e}:${t}`,o=i.get(a);if(o){o.pending=!0;return}i.set(a,{kind:e,id:t,title:n,...r?{fileKind:r}:{},origins:[],pending:!0})};for(let e of t)a(e.kind,e.sourceId,e.title,e.fileKind);for(let e of n)a(`attachment`,e.id,e.title);return r&&a(`app_context`,r.id,r.title),[...i.values()]}function fD(e){return e===`zh`?{title:`会话信息`,work:`当前工作`,sources:`关联来源`,environment:`运行位置`,independent:`独立会话`,delegatedTasks:`派出任务`,expand:`显示更多`,collapse:`收起`,session:`会话关联`,task:`任务关联`,recent:`最近引用`,draft:`待发送`,untitled:`未命名 Note`,untitledSource:`未命名来源`,unavailable:`暂无法查看`,partialUnavailable:`部分信息暂无法查看`,refresh:`重试`,more:`仅显示前 20 项`,local:`本地目录`,worktree:`Worktree`,detached:`游离 HEAD`,unavailableEnvironment:`运行目录不可用`,newEnvironment:`在另一环境新建会话`,copyEnvironmentPath:`复制环境路径`,copied:`已复制`}:{title:`Session info`,work:`Current work`,sources:`Related sources`,environment:`Run location`,independent:`Independent chat`,delegatedTasks:`Delegated tasks`,expand:`Show more`,collapse:`Show less`,session:`Linked to chat`,task:`Linked to task`,recent:`Recently used`,draft:`Pending send`,untitled:`Untitled Note`,untitledSource:`Untitled source`,unavailable:`Temporarily unavailable`,partialUnavailable:`Some details are unavailable`,refresh:`Retry`,more:`Showing the first 20 items`,local:`Local directory`,worktree:`Worktree`,detached:`Detached HEAD`,unavailableEnvironment:`Run directory unavailable`,newEnvironment:`New chat in another environment`,copyEnvironmentPath:`Copy environment path`,copied:`Copied`}}var pD=`flex min-w-0 items-center gap-3 rounded-lg px-2 py-2 text-sm text-fg transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,mD=`rounded-md px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`;function hD({conversationId:e,draftRefs:t=[],draftAttachments:n=[],draftPage:r,project:i,...a}){let[o,s]=(0,Q.useState)(!1),[l,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),[m,g]=(0,Q.useState)(!1),_=fD(h(e=>e.language)),v=c(),y=`${v.pathname}${v.search}`,{data:b,error:x,isLoading:S,isValidating:C,mutate:w}=of(e,o),T=x?void 0:b,E=T?.work.project??(!e&&i?{id:i.id,title:i.name}:void 0),D=T?.work.task,O=T?.work.delegatedTasks??[],A=dD(T?.sources??[],t,n,r),j=T?.environment,M=!!(E||D||O.length),N=!!T?.unavailableSections.includes(`work`),P=!!T?.unavailableSections.includes(`sources`),F=!!T?.unavailableSections.includes(`environment`),I=[E?.title,D?.title,A.length?`${_.sources} ${A.length}${T?.sourcesHasMore?`+`:``}`:null,j?.kind===`managed_worktree`?`Worktree`:null].filter(Boolean).join(` · `)||_.title,L=()=>s(!1),R=A.some(e=>e.kind===`note`&&!e.unavailable&&e.origins.some(e=>e.kind===`session`)),z=()=>{j?.rootPath&&Ti(j.rootPath).then(e=>{e&&(g(!0),window.setTimeout(()=>g(!1),1200))})},B=()=>(0,Z.jsx)(`button`,{type:`button`,className:mD,"aria-label":_.refresh,disabled:C,onClick:()=>void w(),children:(0,Z.jsx)(Mt,{className:`size-3.5 ${C?`animate-spin motion-reduce:animate-none`:``}`,"aria-hidden":!0})});return(0,Z.jsxs)(vi,{open:o,onOpenChange:s,children:[(0,Z.jsx)(bi,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,"aria-label":_.title,title:I,className:`group inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-[background-color,color,transform] duration-150 hover:bg-surface-hover hover:text-fg active:scale-95 data-[state=open]:bg-surface-hover data-[state=open]:text-fg motion-reduce:transition-none motion-reduce:transform-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,Z.jsx)(Ye,{className:`size-4 transition-transform duration-200 group-data-[state=open]:scale-110 motion-reduce:transform-none motion-reduce:transition-none`,strokeWidth:1.75,"aria-hidden":!0})})}),(0,Z.jsx)(gi,{children:(0,Z.jsxs)(_i,{align:`end`,sideOffset:8,collisionPadding:12,"aria-label":_.title,onCloseAutoFocus:e=>{document.activeElement?.closest(`[data-primary-chat-composer]`)&&e.preventDefault()},className:`xopc-session-context-popover z-50 max-h-[min(30rem,var(--radix-popover-content-available-height))] w-[min(23rem,calc(100vw-1.5rem))] overflow-y-auto rounded-xl border border-edge bg-surface-overlay p-3 shadow-popover`,children:[(0,Z.jsx)(`h2`,{className:`mb-2 px-2 text-sm font-medium text-fg`,children:_.title}),S?(0,Z.jsx)(`div`,{className:`space-y-2 px-2`,"aria-busy":`true`,children:[0,1,2].map(e=>(0,Z.jsx)(Yt,{className:`h-8 w-full`},e))}):x?(0,Z.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-2 text-sm text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:_.unavailable}),B()]}):(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`section`,{"aria-label":_.work,children:[E?(0,Z.jsxs)(u,{className:pD,to:et(y,`/projects/${encodeURIComponent(E.id)}`),onClick:L,children:[(0,Z.jsx)(De,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:E.title,children:E.title})]}):null,D?(0,Z.jsxs)(u,{className:pD,to:tt(y,D.id),onClick:L,children:[(0,Z.jsx)(_s,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:D.title,children:D.title}),(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:D.phase})]}):null,O.length?(0,Z.jsxs)(Z.Fragment,{children:[O.length>2?(0,Z.jsxs)(`button`,{type:`button`,className:`${pD} w-full text-left`,onClick:()=>d(!l),"aria-expanded":l,children:[(0,Z.jsx)(_s,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,Z.jsxs)(`span`,{className:`flex-1`,children:[_.delegatedTasks,` · `,T?.work.delegatedTaskCount??O.length]}),(0,Z.jsx)(`span`,{className:`text-xs text-fg-muted`,children:l?_.collapse:_.expand})]}):(0,Z.jsxs)(`p`,{className:`px-2 pt-2 text-xs text-fg-subtle`,children:[_.delegatedTasks,` · `,T?.work.delegatedTaskCount??O.length]}),(l?O:O.slice(0,2)).map(e=>(0,Z.jsxs)(u,{className:`${pD} pl-9`,to:tt(y,e.id),onClick:L,children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.title,children:e.title}),(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:e.runStatus??e.phase})]},e.id))]}):null,M?null:(0,Z.jsx)(`p`,{className:`px-2 py-2 text-sm text-fg-muted`,children:N?_.unavailable:_.independent}),N?(0,Z.jsxs)(`div`,{className:`flex items-center justify-between px-2 text-xs text-fg-muted`,children:[M?_.partialUnavailable:null,B()]}):null,E&&a.onLeaveProject?(0,Z.jsx)(`button`,{type:`button`,className:mD,onClick:()=>{L(),a.onLeaveProject?.()},children:a.leaveProjectLabel}):null]}),A.length||P?(0,Z.jsxs)(`section`,{className:`border-t border-edge-subtle pt-3`,children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex items-center justify-between px-2`,children:[(0,Z.jsxs)(`h3`,{className:`text-sm text-fg-subtle`,children:[_.sources,` `,A.length?`${A.length}${T?.sourcesHasMore?`+`:``}`:``]}),P?B():null]}),(f?A:A.slice(0,3)).map(e=>{let t=e.origins.some(e=>e.kind===`session`)?_.session:e.origins.some(e=>e.kind===`task`)?_.task:e.origins.some(e=>e.kind===`recent`)?_.recent:_.draft,n=e.pending&&e.origins.length?`${t} · ${_.draft}`:e.pending?_.draft:t,r=e.kind===`file`&&e.fileKind===`directory`?ke:e.kind===`file`?Ee:e.kind===`session`?St:e.kind===`browser_tab`||e.kind===`browser_page`||e.kind===`app_context`?k:e.kind===`mcp_resource`?be:e.kind===`attachment`?Dt:Ee,i=e.unavailable?_.unavailable:e.title||(e.kind===`note`?_.untitled:_.untitledSource),a=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(r,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.unavailable?void 0:e.title,children:i}),(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:n})]}),o=e.kind===`note`?rt(y,e.id):e.kind===`session`?`/chat/${encodeURIComponent(e.id)}`:null,s=`${e.kind}:${e.id}`;return!e.unavailable&&o?(0,Z.jsx)(u,{className:pD,to:o,onClick:L,children:a},s):(0,Z.jsx)(`div`,{className:`flex min-w-0 items-center gap-3 px-2 py-2 text-sm text-fg-muted`,children:a},s)}),A.length?null:(0,Z.jsx)(`p`,{className:`px-2 py-2 text-xs text-fg-muted`,children:_.unavailable}),A.length>0&&P?(0,Z.jsx)(`p`,{className:`px-2 py-1 text-xs text-fg-muted`,children:_.partialUnavailable}):null,A.length>3?(0,Z.jsx)(`button`,{type:`button`,className:mD,onClick:()=>p(!f),"aria-expanded":f,children:f?_.collapse:_.expand}):null,T?.sourcesHasMore?(0,Z.jsx)(`p`,{className:`px-2 py-1 text-xs text-fg-muted`,children:_.more}):null,R&&a.onDraftSourceNote?(0,Z.jsx)(`button`,{type:`button`,className:mD,onClick:()=>{L(),a.onDraftSourceNote?.()},children:a.draftSourceNoteLabel}):null]}):null,e&&(j||F)||a.environmentAction?(0,Z.jsxs)(`section`,{className:`border-t border-edge-subtle pt-3`,children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex items-center justify-between px-2`,children:[(0,Z.jsx)(`h3`,{className:`text-sm text-fg-subtle`,children:_.environment}),F?B():null]}),j?null:a.environmentAction,j?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 px-2 py-2 text-sm text-fg`,children:[(0,Z.jsx)(wt,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:j.kind===`managed_worktree`?_.worktree:_.local}),j.branch||j.headSha?(0,Z.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-40 items-center gap-1 text-xs text-fg-muted`,children:[(0,Z.jsx)(Pe,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate`,children:j.branch||(j.detached?`${_.detached} · ${j.headSha?.slice(0,8)}`:j.headSha?.slice(0,8))})]}):null]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 pl-9 pr-1`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,title:j.rootPath,children:j.rootPath}),(0,Z.jsx)(`button`,{type:`button`,className:mD,"aria-label":m?_.copied:_.copyEnvironmentPath,title:m?_.copied:_.copyEnvironmentPath,onClick:z,children:m?(0,Z.jsx)(ee,{className:`size-3.5`,"aria-hidden":!0}):(0,Z.jsx)(ye,{className:`size-3.5`,"aria-hidden":!0})})]}),a.environmentAction,j.available?null:(0,Z.jsx)(`p`,{className:`px-2 py-1 text-xs text-fg-muted`,children:_.unavailableEnvironment}),E&&i?.workspaceRoot?(0,Z.jsx)(J,{className:mD,to:Zr(E.id),state:{forceNewChat:!0,agentId:a.agentId,temporary:a.temporary},onClick:L,children:_.newEnvironment}):null]}):(0,Z.jsx)(`p`,{className:`px-2 py-2 text-xs text-fg-muted`,children:_.unavailable})]}):null]})]})})]})}var gD=`min(36dvh, 320px)`;function _D(e){return e&&Number.isFinite(e.width)&&Number.isFinite(e.height)&&e.width>0&&e.height>0?e.width/e.height:void 0}function vD(e){let t=_D(e);return t?`min(calc(100vw - 2rem), ${36*t}dvh, ${Math.min(480,320*t)}px)`:`min(320px, calc(100vw - 2rem))`}function yD(e,t){if(e)return e.phase===`observing`?e.action?t?`正在查看操作结果`:`Checking the result`:t?`正在查看画面`:`Observing the window`:e.action?{activate:[`正在点击`,`Clicking`,`已点击`,`Clicked`],activateSequence:[`正在连续点击`,`Clicking controls`,`已连续点击`,`Controls clicked`],batch:[`正在执行操作`,`Performing actions`,`操作已执行`,`Actions completed`],showMenu:[`正在打开菜单`,`Opening a menu`,`菜单已打开`,`Menu opened`],click:[`正在点击`,`Clicking`,`已点击`,`Clicked`],drag:[`正在拖动`,`Dragging`,`已拖动`,`Dragged`],setValue:[`正在填写`,`Filling a field`,`已填写`,`Field filled`],typeText:[`正在输入`,`Typing`,`已输入`,`Typed`],pressKeys:[`正在按键`,`Pressing keys`,`已按键`,`Keys pressed`],scroll:[`正在滚动`,`Scrolling`,`已滚动`,`Scrolled`],wait:[`正在等待`,`Waiting`,`等待结束`,`Wait completed`]}[e.action]?.[(e.phase===`acting`?0:2)+ +!t]:t?`正在查看画面`:`Observing the window`}function bD(e,t=!0){let[n,r]=(0,Q.useState)(),[i,a]=(0,Q.useState)(),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(),[u,d]=(0,Q.useState)(),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(0),[g,_]=(0,Q.useState)(!0),v=(0,Q.useRef)(new Set),y=(0,Q.useRef)(0),b=window.electronAPI?.computer?.preview,x=(0,Q.useCallback)(e=>{for(let e of v.current)e.isConnected||v.current.delete(e);e&&v.current.add(e)},[]);(0,Q.useEffect)(()=>{if(r(void 0),s(!1),a(void 0),!e||!b)return;let t=!1,n=!1,i=b.onState(i=>{!t&&i.conversationId===e&&(n=!0,r(i))});return b.current(e).then(i=>{!t&&!n&&r(i?.conversationId===e?i:void 0)}).catch(()=>{}),()=>{t=!0,i()}},[b,e]);let S=n?.previewId,C=n?.targetEpoch,w=n?.runId,T=n?.status===`preparing`&&!i,E=n?.status===`ended`;return(0,Q.useEffect)(()=>{if(s(!1),l(void 0),p(!1),y.current=0,!t||!b||!e||!S||C===void 0||E||T&&m===0)return;let n=!1,i,o=0,c=0;return b.subscribe({conversationId:e,runId:w,preset:`compact`},async e=>{if(n||e.previewId!==S||e.targetEpoch!==C)return;if(!(`sequence`in e)){r(e);return}if(e.streamEpoch<o||e.streamEpoch===o&&e.sequence<=c)return;o=e.streamEpoch,c=e.sequence;let t=new Uint8Array(e.bytes),i;try{if(i=await createImageBitmap(new Blob([t],{type:`image/jpeg`})),n||o!==e.streamEpoch||c!==e.sequence)return;for(let e of v.current){if(!e.isConnected){v.current.delete(e);continue}e.width=i.width,e.height=i.height,e.getContext(`2d`)?.drawImage(i,0,0)}let r=i.width,a=i.height;l(e=>e?.width===r&&e.height===a?e:{width:r,height:a}),y.current=performance.now(),d(S),s(!0),p(!1)}finally{i?.close()}}).then(e=>{i=e.subscriptionId,n?b.unsubscribe(i).catch(()=>{}):a(i)}).catch(()=>{n||r(e=>e?.previewId===S?{...e,status:`unavailable`,errorCode:`COMPUTER_PREVIEW_UNAVAILABLE`}:e)}),()=>{n=!0,a(void 0),i&&b.unsubscribe(i).catch(()=>{})}},[b,e,S,C,w,m,E,t]),(0,Q.useEffect)(()=>{let e=()=>_(document.visibilityState!==`hidden`);e(),document.addEventListener(`visibilitychange`,e);let t=setInterval(()=>{y.current&&p(performance.now()-y.current>1500)},500);return()=>{clearInterval(t),document.removeEventListener(`visibilitychange`,e)}},[]),{state:n,subscriptionId:i,frameSize:c,hasFrame:o&&u===n?.previewId,stale:f,visible:g,registerCanvas:x,retry:()=>h(e=>e+1),api:b}}function xD({conversationId:e,onFrameSizeChange:t}){let n=bD(e),[r,i]=(0,Q.useState)(!0),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),l=(0,Q.useRef)(null),u=h(e=>e.language===`zh`),d=n.state?.previewId;if((0,Q.useEffect)(()=>{n.frameSize&&t?.(n.frameSize)},[n.frameSize,t]),(0,Q.useEffect)(()=>{c(!1)},[d]),(0,Q.useEffect)(()=>{if(!l.current||typeof IntersectionObserver>`u`)return;let e=new IntersectionObserver(e=>i(e.some(e=>e.isIntersecting)),{rootMargin:`160px`});return e.observe(l.current),()=>e.disconnect()},[d]),(0,Q.useEffect)(()=>{!n.subscriptionId||!n.api||n.api.setPreset(n.subscriptionId,n.visible&&r?`compact`:`paused`).catch(()=>{})},[n.api,n.subscriptionId,n.visible,r]),!n.state||n.state.conversationId!==e||n.state.status===`ended`)return null;let f=n.state.status===`unavailable`,p=s?u?`重试切换`:`Retry switch`:n.stale?u?`等待新画面`:`Waiting for a new frame`:yD(n.state.activity,u),m=async()=>{let t=window.electronAPI?.computer;if(!(!t?.focusTarget||!e||!d||a)){o(!0),c(!1);try{await t.focusTarget(e,d)}catch{c(!0)}finally{o(!1)}}};return(0,Z.jsxs)(`section`,{ref:l,"aria-label":u?`电脑操作预览`:`Computer activity`,className:`relative w-full overflow-hidden rounded-xl bg-transparent`,style:{aspectRatio:_D(n.frameSize)??16/10,maxHeight:gD},children:[!n.hasFrame&&!f&&(0,Z.jsx)(Yt,{className:`absolute inset-0`}),(0,Z.jsx)(`canvas`,{ref:n.registerCanvas,role:`img`,"aria-label":u?`${n.state.appName}窗口预览`:`${n.state.appName} window preview`,className:`absolute inset-0 h-full w-full object-contain ${n.hasFrame&&!f?``:`invisible`}`}),!f&&(0,Z.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`absolute left-2 top-2 z-10 max-w-[calc(100%-1rem)]`,children:(0,Z.jsxs)(`button`,{type:`button`,disabled:a||!window.electronAPI?.computer?.focusTarget,"aria-label":u?`切换到正在操作的应用`:`Switch to the active app`,title:s?u?`暂时无法切换应用,请重试`:`Could not switch to the app. Try again.`:u?`切换到应用`:`Switch to app`,className:`inline-flex min-h-11 min-w-11 max-w-full sm:min-h-9 sm:min-w-9 items-center justify-center gap-1.5 rounded-md bg-surface-overlay/80 px-2 text-xs text-fg backdrop-blur-sm hover:bg-surface-overlay focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>{m()},children:[(0,Z.jsx)(wt,{size:14,className:`shrink-0`,"aria-hidden":!0}),p&&(0,Z.jsx)(`span`,{className:`truncate`,children:p})]})}),f&&(0,Z.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-surface-panel/90`,children:(0,Z.jsx)(`button`,{className:`min-h-11 rounded-md px-3 text-sm text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:n.retry,children:u?`预览暂时不可用,点击重试`:`Preview unavailable. Retry preview`})})]})}function SD(e){let t=(0,X.c)(26),{conversationId:n}=e,{state:r}=bD(n,!1),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(),c=h(wD),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{a(!1),s(void 0)},t[0]=l):l=t[0];let u=r?.previewId,d;if(t[1]!==n||t[2]!==u?(d=[n,u],t[1]=n,t[2]=u,t[3]=d):d=t[3],(0,Q.useEffect)(l,d),!r||r.conversationId!==n||r.status===`ended`)return null;let f=c?`查看电脑预览`:`View computer preview`,p=c?`查看电脑预览`:`View computer preview`,m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(wt,{className:`size-4`,"aria-hidden":!0}),t[4]=m):m=t[4];let g=c?`电脑`:`Computer`,_;t[5]===g?_=t[6]:(_=(0,Z.jsx)(`span`,{className:`text-xs`,children:g}),t[5]=g,t[6]=_);let v;t[7]!==f||t[8]!==p||t[9]!==_?(v=(0,Z.jsx)(bi,{asChild:!0,children:(0,Z.jsxs)(mi,{variant:`ghost`,className:`min-h-10 gap-1.5 px-2`,title:f,"aria-label":p,children:[m,_]})}),t[7]=f,t[8]=p,t[9]=_,t[10]=v):v=t[10];let y=c?`电脑预览`:`Computer preview`,b;t[11]===o?b=t[12]:(b=vD(o),t[11]=o,t[12]=b);let x;t[13]===b?x=t[14]:(x={"--computer-preview-width":b},t[13]=b,t[14]=x);let S=x,C;t[15]!==n||t[16]!==r.previewId?(C=(0,Z.jsx)(xD,{conversationId:n,onFrameSizeChange:s},r.previewId),t[15]=n,t[16]=r.previewId,t[17]=C):C=t[17];let w;t[18]!==y||t[19]!==S||t[20]!==C?(w=(0,Z.jsx)(gi,{children:(0,Z.jsx)(_i,{align:`end`,sideOffset:8,collisionPadding:16,"aria-label":y,onOpenAutoFocus:CD,style:S,className:`z-40 w-[var(--computer-preview-width)] max-h-[calc(100dvh-5rem)] overflow-hidden rounded-xl bg-transparent p-0 outline-none`,children:C})}),t[18]=y,t[19]=S,t[20]=C,t[21]=w):w=t[21];let T;return t[22]!==i||t[23]!==w||t[24]!==v?(T=(0,Z.jsxs)(vi,{open:i,onOpenChange:a,children:[v,w]}),t[22]=i,t[23]=w,t[24]=v,t[25]=T):T=t[25],T}function CD(e){return e.preventDefault()}function wD(e){return e.language===`zh`}function TD(e){let t=(0,X.c)(23),{conversationId:n}=e,{data:r}=Ks(n),i=h(DD)===`zh`,a=tc(ED),o,s;if(t[0]!==n||t[1]!==r||t[2]!==a){let e=r?ec(n,r.report):null;o=Boolean,s=e&&!a.includes(e),t[0]=n,t[1]=r,t[2]=a,t[3]=o,t[4]=s}else o=t[3],s=t[4];let c=o(s);if(!r||zs(r.report.status))return null;let l=c?i?`手机需要你操作`:`Your help is needed on the phone`:i?`查看手机`:`View phone`,u=c?i?`手机需要你操作`:`Your help is needed on the phone`:i?`查看手机`:`View phone`,d;t[5]!==n||t[6]!==r.report.deviceId||t[7]!==r.report.deviceName||t[8]!==r.report.sessionId?(d=()=>hi.getState().openPhone(r.report.deviceId??r.report.sessionId,r.report.deviceName,n,!0),t[5]=n,t[6]=r.report.deviceId,t[7]=r.report.deviceName,t[8]=r.report.sessionId,t[9]=d):d=t[9];let f;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(zt,{className:`size-4`,"aria-hidden":!0}),t[10]=f):f=t[10];let p;t[11]===c?p=t[12]:(p=c&&(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`absolute -right-1 -top-1 size-1.5 rounded-full bg-accent`}),t[11]=c,t[12]=p);let m;t[13]===p?m=t[14]:(m=(0,Z.jsxs)(`span`,{className:`relative`,children:[f,p]}),t[13]=p,t[14]=m);let g=i?`手机`:`Phone`,_;t[15]===g?_=t[16]:(_=(0,Z.jsx)(`span`,{className:`text-xs`,children:g}),t[15]=g,t[16]=_);let v;return t[17]!==_||t[18]!==l||t[19]!==u||t[20]!==d||t[21]!==m?(v=(0,Z.jsxs)(mi,{variant:`ghost`,className:`min-h-10 gap-1.5 px-2`,title:l,"aria-label":u,onClick:d,children:[m,_]}),t[17]=_,t[18]=l,t[19]=u,t[20]=d,t[21]=m,t[22]=v):v=t[22],v}function ED(e){return e.seen}function DD(e){return e.language}function OD(e){let t=(0,X.c)(57),{conversationId:n,directoryOnly:r,workspacePath:i,canChangeWorkspace:a,disabled:o,available:s,onWorkspaceChange:c}=e,l=r!==void 0&&r,u=s===void 0||s,d=h(MD),f;t[0]===d?f=t[1]:(f=y(d),t[0]=d,t[1]=f);let p=f,m=Gf(jD),g;t[2]===n?g=t[3]:(g=e=>e.panes[n??`new`]?.open===!0,t[2]=n,t[3]=g);let _=hi(g),[v,x]=(0,Q.useState)(null),C,O;t[4]!==p.chat.workingDirectory.notSet||t[5]!==i?(C=i?.trim()??``,O=C?ja(C):p.chat.workingDirectory.notSet,t[4]=p.chat.workingDirectory.notSet,t[5]=i,t[6]=C,t[7]=O):(C=t[6],O=t[7]);let k=O,A;t[8]===c?A=t[9]:(A=async e=>{try{await c(e)}catch(e){let t=e;x(t instanceof Error?t.message:String(t))}},t[8]=c,t[9]=A);let j=A,M;t[10]!==j||t[11]!==C?(M={initialPath:C,onPicked:j},t[10]=j,t[11]=C,t[12]=M):M=t[12];let N=Ma(M),P=o||!u||N.picking,F;t[13]!==n||t[14]!==m?(F=()=>{let e=hi.getState(),t=n??`new`;e.setScope(t);let r=e.panes[t]?.tabs.find(AD);r?e.activate(r.id,t):e.openTools(t),m(n??``)},t[13]=n,t[14]=m,t[15]=F):F=t[15];let I=F,L;t[16]!==l||t[17]!==d||t[18]!==I||t[19]!==_?(L=l?null:(0,Z.jsx)(`button`,{type:`button`,className:Y(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors`,`hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,_&&`bg-surface-hover text-fg`),title:d===`zh`?`打开工具`:`Open workspace tools`,"aria-label":d===`zh`?`打开工具`:`Open workspace tools`,"aria-pressed":_,"aria-controls":`app-workspace-panel`,"data-workspace-trigger":!0,onClick:I,children:(0,Z.jsx)(gs,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0})}),t[16]=l,t[17]=d,t[18]=I,t[19]=_,t[20]=L):L=t[20];let R;t[21]!==a||t[22]!==l||t[23]!==N||t[24]!==p.chat.workingDirectory.chooseFolder||t[25]!==C||t[26]!==P||t[27]!==k?(R=l&&a?(0,Z.jsxs)(`button`,{type:`button`,disabled:P,className:Y(`inline-flex h-8 max-w-full shrink-0 px-2 items-center justify-center rounded-lg text-fg-muted transition-colors`,`hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,P&&`cursor-not-allowed opacity-50`),title:`${p.chat.workingDirectory.chooseFolder}: ${C||k}`,"aria-label":p.chat.workingDirectory.chooseFolder,onClick:N.pick,children:[(0,Z.jsx)(ie,{className:`mr-2 size-4`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate text-xs`,children:p.chat.workingDirectory.chooseFolder})]}):null,t[21]=a,t[22]=l,t[23]=N,t[24]=p.chat.workingDirectory.chooseFolder,t[25]=C,t[26]=P,t[27]=k,t[28]=R):R=t[28];let z;t[29]!==R||t[30]!==L?(z=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-0.5`,children:[L,R]}),t[29]=R,t[30]=L,t[31]=z):z=t[31];let B;t[32]!==l||t[33]!==N||t[34]!==p.chat.workingDirectory||t[35]!==C?(B=l&&!N.hasNativePicker?(0,Z.jsx)(ae,{open:N.modalOpen,onOpenChange:N.setModalOpen,initialAbsolutePath:C||void 0,onConfirm:N.confirmPick,wd:p.chat.workingDirectory}):null,t[32]=l,t[33]=N,t[34]=p.chat.workingDirectory,t[35]=C,t[36]=B):B=t[36];let V=v!==null,H;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(H=e=>{e||x(null)},t[37]=H):H=t[37];let U;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Z.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),t[38]=U):U=t[38];let W;t[39]===p.chat.workingDirectory.applyErrorTitle?W=t[40]:(W=(0,Z.jsx)(E,{className:`text-base font-semibold text-fg`,children:p.chat.workingDirectory.applyErrorTitle}),t[39]=p.chat.workingDirectory.applyErrorTitle,t[40]=W);let G;t[41]===v?G=t[42]:(G=v?(0,Z.jsx)(S,{className:`mt-2 whitespace-pre-wrap text-sm leading-relaxed text-fg-muted`,children:v}):null,t[41]=v,t[42]=G);let ee;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(ee=()=>x(null),t[43]=ee):ee=t[43];let te;t[44]===p.chat.workingDirectory.applyErrorClose?te=t[45]:(te=(0,Z.jsx)(`div`,{className:`mt-4 flex justify-end border-t border-edge-subtle pt-3`,children:(0,Z.jsx)(mi,{type:`button`,onClick:ee,children:p.chat.workingDirectory.applyErrorClose})}),t[44]=p.chat.workingDirectory.applyErrorClose,t[45]=te);let ne;t[46]!==W||t[47]!==G||t[48]!==te?(ne=(0,Z.jsxs)(w,{children:[U,(0,Z.jsxs)(T,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[81] w-[min(100%-2rem,26rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover`,onOpenAutoFocus:kD,children:[W,G,te]})]}),t[46]=W,t[47]=G,t[48]=te,t[49]=ne):ne=t[49];let re;t[50]!==V||t[51]!==ne?(re=(0,Z.jsx)(D,{open:V,onOpenChange:H,children:ne}),t[50]=V,t[51]=ne,t[52]=re):re=t[52];let K;return t[53]!==z||t[54]!==B||t[55]!==re?(K=(0,Z.jsxs)(Z.Fragment,{children:[z,B,re]}),t[53]=z,t[54]=B,t[55]=re,t[56]=K):K=t[56],K}function kD(e){return e.preventDefault()}function AD(e){return e.kind===`home`}function jD(e){return e.openForSession}function MD(e){return e.language}function ND(e,t){return e.repeat||e.altKey||e.shiftKey||e.key.toLowerCase()!==`j`?!1:t===`darwin`?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function PD({conversationId:e,dialogOpen:t,onDialogOpenChange:n,hideTrigger:r=!1}){let i=h(e=>e.language),a=i===`zh`?ID:LD,[o,s]=(0,Q.useState)(!1),c=t??o,l=e=>{s(e),n?.(e)},[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(null),[m,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(null),[y,O]=(0,Q.useState)(864e5),[k,A]=(0,Q.useState)(null),[j,M]=(0,Q.useState)(``),[N,P]=(0,Q.useState)(!1),[F,I]=(0,Q.useState)([]),[L,R]=(0,Q.useState)(`hosted`),[z,B]=(0,Q.useState)(!1),[V,H]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(!c||u||f)return;let t=!1;return g(!0),v(null),Promise.all([Ja(e),Qa(e),qa()]).then(async([n,r,i])=>{if(t)return;d(n),B(i);let a=i?await $a().catch(()=>null):null;if(t)return;H(a?.publishing.allowed===!0);let o=i?await eo(e).catch(()=>[]):[];if(t)return;let s=[...o,...r].find(e=>!e.revoked&&!e.expired);s&&p(s)}).catch(e=>{t||v(e instanceof Error?e.message:String(e))}).finally(()=>{t||g(!1)}),()=>{t=!0}},[c,u,f,e]);let U=()=>{d(null),p(null),v(null),g(!1),M(``),P(!1),I([]),H(!1)},W=async()=>{if(!(!u||m)){g(!0),v(null);try{p(await(L===`hosted`?Za:Xa)(e,{expectedTranscriptId:u.transcriptId,expectedCutoffSeq:u.cutoffSeq,expectedMetadataUpdatedAt:u.metadataUpdatedAt,ttlMs:y,maxViews:k,description:j.trim()||void 0,includeToolActivities:N,attachmentIds:F}))}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(!1)}}},G=async()=>{if(!(!f||m)){g(!0),v(null);try{let t=await Ja(e);d(t);let n=f.delivery===`hosted`?Ya:Ga;p(await n(e,f.id,{expectedTranscriptId:t.transcriptId,expectedCutoffSeq:t.cutoffSeq,expectedMetadataUpdatedAt:t.metadataUpdatedAt}))}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(!1)}}},ee=async()=>{if(!(!f||m)){g(!0),v(null);try{f.delivery===`hosted`?await to(e,f.id):await Ka(f.id),l(!1),U()}catch(e){v(e instanceof Error?e.message:String(e)),g(!1)}}};return(0,Z.jsxs)(D,{open:c,onOpenChange:e=>{l(e),e||U()},children:[r?null:(0,Z.jsx)(x,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`rounded-md p-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,title:a.share,"aria-label":a.share,children:(0,Z.jsx)(fs,{className:`size-4`})})}),(0,Z.jsxs)(w,{children:[(0,Z.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),(0,Z.jsxs)(T,{onCloseAutoFocus:e=>{r&&(e.preventDefault(),document.querySelector(`[data-chat-menu-trigger]`)?.focus())},className:Y(`xopc-dialog-content fixed left-1/2 top-1/2 z-[71] flex h-[min(35rem,calc(100dvh-2rem))] w-[min(34rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col`,`overflow-hidden rounded-xl border border-edge bg-surface-overlay outline-none`),children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(E,{className:`text-base font-semibold text-fg`,children:f?a.created:a.title}),(0,Z.jsx)(S,{className:`mt-0.5 text-xs text-fg-muted`,children:f?a.createdHint:a.hint})]}),(0,Z.jsx)(C,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`touch-target flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":a.close,children:(0,Z.jsx)(qt,{className:`size-4`})})})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:[m&&!u&&!f?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,Z.jsx)(Xe,{className:`size-4 animate-spin`}),a.loading]}):f?(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f.fileName}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.snapshotMessages.replace(`{{count}}`,String(f.messageCount))}),(0,Z.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[f.delivery===`hosted`?a.hosted:a.local,` · `,a.revision.replace(`{{revision}}`,String(f.snapshotRevision)),` · `,a.sharedAttachments.replace(`{{count}}`,String(f.attachmentCount))]})]}),(0,Z.jsx)(Wt,{shareUrl:f.shareUrl,lanUrl:f.lanUrl,reachability:f.reachability}),(0,Z.jsx)(Gt,{reachability:f.reachability,reachabilityHint:f.reachabilityHint}),(0,Z.jsxs)(`a`,{href:f.shareUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-sm font-medium text-accent hover:underline`,children:[a.open,(0,Z.jsx)(Se,{className:`size-3.5`})]})]}):u?(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-inset p-3`,children:[(0,Z.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:u.title}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.snapshotMessages.replace(`{{count}}`,String(u.messageCount))}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:new Date(u.snapshotAt).toLocaleString(i===`zh`?`zh-CN`:`en-US`)})]}),(0,Z.jsxs)(`details`,{className:`rounded-lg border border-edge`,children:[(0,Z.jsx)(`summary`,{className:`touch-target cursor-pointer px-3 py-2.5 text-xs font-medium text-fg transition-colors hover:bg-surface-hover`,children:a.reviewContent}),(0,Z.jsx)(`div`,{className:`max-h-64 space-y-3 overflow-y-auto border-t border-edge p-3`,children:u.messages.map(e=>(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-inset px-3 py-2`,children:[(0,Z.jsx)(`p`,{className:`mb-1 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:e.role===`user`?a.you:a.assistant}),(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm leading-6 text-fg`,children:e.markdown})]},e.id))})]}),(0,Z.jsxs)(`div`,{className:`flex gap-2 rounded-lg border border-accent/20 bg-accent-soft px-3 py-2.5 text-xs leading-5 text-fg-muted`,children:[(0,Z.jsx)(Rt,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{children:a.scope})]}),(0,Z.jsxs)(`label`,{className:`block space-y-1.5 text-xs font-medium text-fg`,children:[(0,Z.jsx)(`span`,{children:a.delivery}),(0,Z.jsxs)(se,{value:L,disabled:m,onChange:e=>R(e.target.value),children:[(0,Z.jsx)(ce,{value:`hosted`,children:a.hosted}),(0,Z.jsx)(ce,{value:`local`,children:a.local})]})]}),L===`hosted`&&!z?(0,Z.jsx)(Wo,{providerId:`xopc-share`,displayName:a.hosted,connected:!1,onConnected:()=>{B(!0),$a().then(e=>H(e.publishing.allowed)).catch(()=>H(!1))}}):null,L===`hosted`&&z&&!V?(0,Z.jsx)(`p`,{className:`rounded-lg border border-warning/30 bg-warning-soft px-3 py-2 text-xs text-warning`,children:a.hostedDisabled}):null,u.toolActivities.length?(0,Z.jsxs)(`label`,{className:`flex items-start gap-2 rounded-lg border border-edge bg-surface-inset px-3 py-2.5 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:N,disabled:m,onChange:e=>P(e.target.checked),className:`mt-0.5 size-4 rounded border-edge`}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`block font-medium`,children:a.includeTools.replace(`{{count}}`,String(u.toolActivities.length))}),(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-muted`,children:a.toolDisclosure})]})]}):null,u.attachmentCandidates.length?(0,Z.jsxs)(`fieldset`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2.5`,children:[(0,Z.jsx)(`legend`,{className:`px-1 text-xs font-medium text-fg`,children:a.attachments}),(0,Z.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:a.attachmentDisclosure}),(0,Z.jsx)(`div`,{className:`space-y-2`,children:u.attachmentCandidates.map(e=>(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:F.includes(e.id),disabled:m,onChange:t=>I(n=>t.target.checked?[...n,e.id]:n.filter(t=>t!==e.id)),className:`size-4 rounded border-edge`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.fileName}),(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:FD(e.size)})]},e.id))})]}):null,(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg`,children:[(0,Z.jsx)(`span`,{children:a.ttl}),(0,Z.jsxs)(se,{value:y,disabled:m,onChange:e=>O(Number(e.target.value)),children:[(0,Z.jsx)(ce,{value:36e5,children:a.oneHour}),(0,Z.jsx)(ce,{value:864e5,children:a.oneDay}),(0,Z.jsx)(ce,{value:6048e5,children:a.sevenDays}),(0,Z.jsx)(ce,{value:2592e6,children:a.thirtyDays})]})]}),(0,Z.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg`,children:[(0,Z.jsx)(`span`,{children:a.maxViews}),(0,Z.jsxs)(se,{value:k??`unlimited`,disabled:m,onChange:e=>A(e.target.value===`unlimited`?null:Number(e.target.value)),children:[(0,Z.jsx)(ce,{value:`unlimited`,children:a.unlimited}),(0,Z.jsx)(ce,{value:1,children:`1`}),(0,Z.jsx)(ce,{value:10,children:`10`}),(0,Z.jsx)(ce,{value:50,children:`50`})]})]})]}),(0,Z.jsxs)(`label`,{className:`block space-y-1.5 text-xs font-medium text-fg`,children:[(0,Z.jsx)(`span`,{children:a.description}),(0,Z.jsx)(`input`,{value:j,disabled:m,onChange:e=>M(e.target.value),className:`h-10 w-full rounded-lg border border-edge bg-surface-inset px-3 text-sm font-normal text-fg outline-none focus-visible:border-accent/50 focus-visible:ring-2 focus-visible:ring-accent/20`})]}),(0,Z.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-300`,children:a.publicWarning})]}):null,_?(0,Z.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:_}):null]}),(0,Z.jsx)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-edge bg-surface-overlay px-4 py-3`,children:f?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(mi,{type:`button`,variant:`ghost`,disabled:m,onClick:()=>p(null),children:a.newShare}),(0,Z.jsxs)(mi,{type:`button`,variant:`ghost`,disabled:m,onClick:()=>void ee(),children:[(0,Z.jsx)(Ht,{className:`size-4`}),a.revoke]}),(0,Z.jsxs)(mi,{type:`button`,disabled:m||f.delivery===`hosted`&&!V,onClick:()=>void G(),children:[m?(0,Z.jsx)(Xe,{className:`size-4 animate-spin`}):(0,Z.jsx)(Mt,{className:`size-4`}),a.refresh]})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(C,{asChild:!0,children:(0,Z.jsx)(mi,{type:`button`,variant:`ghost`,children:a.cancel})}),(0,Z.jsxs)(mi,{type:`button`,disabled:!u||m||u.messageCount===0||L===`hosted`&&(!z||!V),onClick:()=>void W(),children:[m?(0,Z.jsx)(Xe,{className:`size-4 animate-spin`}):null,a.create]})]})})]})]})]})}function FD(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var ID={share:`分享会话`,title:`分享会话`,hint:`创建当前会话的只读快照`,created:`分享已创建`,createdHint:`复制链接后即可发送给其他人`,close:`关闭`,loading:`正在准备预览…`,snapshotMessages:`当前快照包含 {{count}} 条公开消息`,scope:`默认仅包含用户与助手的可见文本;系统提示、推理、工具参数、命令文本、输出和路径始终不会公开。`,ttl:`有效期`,maxViews:`最大访问次数`,includeTools:`包含 {{count}} 条工具活动`,toolDisclosure:`只公开工具名称和成功/失败状态,不公开参数与结果。`,attachments:`附件`,attachmentDisclosure:`附件默认不公开,请逐个选择。`,oneHour:`1 小时`,oneDay:`24 小时`,sevenDays:`7 天`,thirtyDays:`30 天`,unlimited:`不限`,description:`说明(可选)`,publicWarning:`任何获得链接的人都可以查看这份快照。后续会话消息不会自动加入。`,cancel:`取消`,create:`创建分享`,revoke:`撤销分享`,refresh:`更新到当前会话`,open:`打开分享页面`,revision:`快照版本 {{revision}}`,sharedAttachments:`{{count}} 个附件`,newShare:`新建分享`,delivery:`分享方式`,hosted:`XOPC 托管分享`,local:`本机 Gateway 分享`,hostedDisabled:`管理员已暂停你的公网分享能力。已有托管链接当前不可访问,但仍可撤销。`,reviewContent:`检查将要公开的内容`,you:`你`,assistant:`助手`},LD={share:`Share conversation`,title:`Share conversation`,hint:`Create a read-only snapshot of this conversation`,created:`Share created`,createdHint:`Copy the link and send it to anyone`,close:`Close`,loading:`Preparing preview…`,snapshotMessages:`This snapshot contains {{count}} public messages`,scope:`Only visible user and assistant text is included by default. System prompts, reasoning, tool arguments, command text, output, and paths always stay private.`,ttl:`Expires after`,maxViews:`Maximum views`,includeTools:`Include {{count}} tool activities`,toolDisclosure:`Only tool names and success/failure states are shared; arguments and results stay private.`,attachments:`Attachments`,attachmentDisclosure:`Attachments stay private unless selected individually.`,oneHour:`1 hour`,oneDay:`24 hours`,sevenDays:`7 days`,thirtyDays:`30 days`,unlimited:`Unlimited`,description:`Description (optional)`,publicWarning:`Anyone with the link can view this snapshot. Later conversation messages are not added automatically.`,cancel:`Cancel`,create:`Create share`,revoke:`Revoke share`,refresh:`Update to current conversation`,open:`Open shared page`,revision:`Snapshot revision {{revision}}`,sharedAttachments:`{{count}} attachments`,newShare:`New share`,delivery:`Delivery`,hosted:`XOPC Hosted Share`,local:`Local Gateway Share`,hostedDisabled:`An administrator has paused public sharing for your account. Existing hosted links are unavailable, but can still be revoked.`,reviewContent:`Review the content to publish`,you:`You`,assistant:`Assistant`},RD=`(max-width: 767px)`,zD=(0,Q.memo)(function(e){let t=(0,X.c)(140),{inline:n,chatHeadline:r,chatAgents:i,showChatAgentSelector:a,chatAgentId:o,onChatAgentChange:c,chatAgentDisabled:l,conversationId:u,hasMessages:d,workspacePath:f,userContextMode:p,canChangeWorkspace:m,workspaceDisabled:g,onWorkspaceChange:_,prepareTerminalSession:v,terminalDisabled:b,showContextControls:x,onFindOpen:S,projectId:C,context:w}=e,T=n!==void 0&&n,E=d!==void 0&&d,D=p===void 0?`enabled`:p,O=m!==void 0&&m,k=g!==void 0&&g,A=b!==void 0&&b,j=x===void 0||x,M=h(BD),{conversationId:N}=s(),P=N&&N!==`new`?decodeURIComponent(N):null,F;t[0]!==u||t[1]!==P?(F=u?.trim()||P,t[0]=u,t[1]=P,t[2]=F):F=t[2];let I=F,{data:R,error:z,mutate:B}=of(I??null,!1),V=!z&&(!R||!!R.environment?.available),H;t[3]===I?H=t[4]:(H=e=>e.panes[I??`new`]?.open===!0,t[3]=I,t[4]=H);let U=hi(H),W;t[5]===M?W=t[6]:(W=y(M),t[5]=M,t[6]=W);let G=W,ee=vf(VD),te=_w(HD),ne=Bo(UD),re=Bo(WD),[ie,ae]=(0,Q.useState)(!1),K=(0,Q.useRef)(!1),[oe,se]=(0,Q.useState)(!1),q=yf(GD),ce=Sa(KD),le=Sa(qD),ue=window.electronAPI?.platform,de=!!(j&&window.electronAPI?.terminal&&(I||v)),fe;t[7]!==I||t[8]!==re||t[9]!==v||t[10]!==de||t[11]!==A||t[12]!==oe||t[13]!==ne?(fe=()=>{if(!(!de||A||oe)){if(I){ne(I);return}v&&(se(!0),v().then(e=>{e&&re(e)}).finally(()=>se(!1)))}},t[7]=I,t[8]=re,t[9]=v,t[10]=de,t[11]=A,t[12]=oe,t[13]=ne,t[14]=fe):fe=t[14];let pe=fe,me;t[15]!==I||t[16]!==E||t[17]!==te?(me=()=>{if(!I||!E)return;let e=hi.getState().panes[I],t=_w.getState().pendingCreate?.parentConversationId===I||!!_w.getState().creatingRequests[I],n=e?.open===!0&&(e.activeId?.startsWith(`side:`)===!0||t);te(I,!n)},t[15]=I,t[16]=E,t[17]=te,t[18]=me):me=t[18];let he=me,ge=Go(RD),_e;t[19]!==q||t[20]!==ee?(_e=uf({runtime:lf(),sidebarCollapsed:ee,mobileNavOpen:q}),t[19]=q,t[20]=ee,t[21]=_e):_e=t[21];let ve=ge?!q:_e.collapsedNewChatVisible,ye,be;t[22]!==le||t[23]!==T?(ye=()=>{if(!T)return()=>le()},be=[le,T],t[22]=le,t[23]=T,t[24]=ye,t[25]=be):(ye=t[24],be=t[25]),(0,Q.useLayoutEffect)(ye,be);let Se,Ce;t[26]!==pe||t[27]!==de?(Se=()=>{if(!de)return;let e=e=>{ND(e,ue)&&(e.preventDefault(),pe())};return window.addEventListener(`keydown`,e),window.addEventListener(`workspace-open-terminal`,pe),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`workspace-open-terminal`,pe)}},Ce=[pe,de,ue],t[26]=pe,t[27]=de,t[28]=Se,t[29]=Ce):(Se=t[28],Ce=t[29]),(0,Q.useEffect)(Se,Ce);let we,Te;t[30]!==I||t[31]!==he||t[32]!==E?(we=()=>{if(!I||!E)return;let e=e=>{Zo(e,ue)&&(e.preventDefault(),he())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},Te=[I,he,E,ue],t[30]=I,t[31]=he,t[32]=E,t[33]=we,t[34]=Te):(we=t[33],Te=t[34]),(0,Q.useEffect)(we,Te);let Ee;t[35]!==o||t[36]!==G.sidebar.newTask||t[37]!==C||t[38]!==ve||t[39]!==D?(Ee=ve?(0,Z.jsx)(J,{to:Zr(C),state:{forceNewChat:!0,agentId:o,temporary:D===`temporary`},className:Y(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-panel text-sm font-medium leading-none text-fg transition-colors hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,_a),title:G.sidebar.newTask,children:(0,Z.jsx)(jt,{className:`size-4 shrink-0 text-accent-fg`,strokeWidth:2,"aria-hidden":!0})}):null,t[35]=o,t[36]=G.sidebar.newTask,t[37]=C,t[38]=ve,t[39]=D,t[40]=Ee):Ee=t[40];let De=ve?`text-left md:text-center`:`text-left`,Oe;t[41]===De?Oe=t[42]:(Oe=Y(`min-w-0 flex-1 truncate text-[0.9375rem] font-semibold leading-5 tracking-tight text-fg`,De),t[41]=De,t[42]=Oe);let ke;t[43]!==r||t[44]!==Oe?(ke=(0,Z.jsx)(`div`,{className:`flex w-full min-w-0 max-w-(--max-width-chat-frame) items-center gap-3 px-3 sm:px-5 xl:px-6`,children:(0,Z.jsx)(`h1`,{className:Oe,title:r,children:r})}),t[43]=r,t[44]=Oe,t[45]=ke):ke=t[45];let Ae;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=Y(`flex min-w-0 max-w-[min(32rem,calc(100vw-8rem))] shrink-0 items-center justify-end gap-2`,_a),t[46]=Ae):Ae=t[46];let je;t[47]!==l||t[48]!==o||t[49]!==i||t[50]!==G.chat.agentNoMatches||t[51]!==G.chat.agentPlaceholder||t[52]!==G.chat.agentSearchPlaceholder||t[53]!==c||t[54]!==a?(je=a?(0,Z.jsx)(cD,{items:i,value:o,disabled:l,placeholder:G.chat.agentPlaceholder,searchPlaceholder:G.chat.agentSearchPlaceholder,noMatches:G.chat.agentNoMatches,compact:!0,contentSide:`bottom`,contentAlign:`end`,onChange:c}):null,t[47]=l,t[48]=o,t[49]=i,t[50]=G.chat.agentNoMatches,t[51]=G.chat.agentPlaceholder,t[52]=G.chat.agentSearchPlaceholder,t[53]=c,t[54]=a,t[55]=je):je=t[55];let Me=M===`zh`?`聊天菜单`:`Chat menu`,Ne=M===`zh`?`聊天菜单`:`Chat menu`,Pe;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=(0,Z.jsx)(xe,{className:`size-4`,"aria-hidden":!0}),t[56]=Pe):Pe=t[56];let Fe;t[57]!==Me||t[58]!==Ne?(Fe=(0,Z.jsx)(io,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,"data-chat-menu-trigger":!0,"aria-label":Me,title:Ne,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover data-[state=open]:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:Pe})}),t[57]=Me,t[58]=Ne,t[59]=Fe):Fe=t[59];let Ie;t[60]===S?Ie=t[61]:(Ie=e=>{K.current&&(e.preventDefault(),K.current=!1,document.querySelector(`[data-chat-menu-trigger]`)?.focus(),S?.())},t[60]=S,t[61]=Ie);let Le=!E||!S,Re;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(Re=()=>{K.current=!0},t[62]=Re):Re=t[62];let ze;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(ze=(0,Z.jsx)(Ft,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t[63]=ze):ze=t[63];let Be;t[64]===G.chat.find.input?Be=t[65]:(Be=(0,Z.jsx)(`span`,{className:`flex-1`,children:G.chat.find.input}),t[64]=G.chat.find.input,t[65]=Be);let Ve;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(Ve=(0,Z.jsx)(`span`,{className:`text-xs text-fg-muted`,children:ue===`darwin`?`⌘F`:`Ctrl+F`}),t[66]=Ve):Ve=t[66];let He;t[67]!==Le||t[68]!==Be?(He=(0,Z.jsxs)(oo,{disabled:Le,onSelect:Re,className:`flex cursor-default items-center gap-3 rounded-lg px-3 py-2 text-fg outline-none data-[highlighted]:bg-surface-hover data-[disabled]:opacity-40`,children:[ze,Be,Ve]}),t[67]=Le,t[68]=Be,t[69]=He):He=t[69];let Ue=!I||!E,We;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(We=()=>ae(!0),t[70]=We):We=t[70];let Ge;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(Ge=(0,Z.jsx)(L,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t[71]=Ge):Ge=t[71];let Ke=M===`zh`?`分享对话`:`Share conversation`,qe;t[72]===Ke?qe=t[73]:(qe=(0,Z.jsx)(`span`,{children:Ke}),t[72]=Ke,t[73]=qe);let Je;t[74]!==Ue||t[75]!==qe?(Je=(0,Z.jsxs)(oo,{disabled:Ue,onSelect:We,className:`flex cursor-default items-center gap-3 rounded-lg px-3 py-2 text-fg outline-none data-[highlighted]:bg-surface-hover data-[disabled]:opacity-40`,children:[Ge,qe]}),t[74]=Ue,t[75]=qe,t[76]=Je):Je=t[76];let Ye;t[77]!==Ie||t[78]!==He||t[79]!==Je?(Ye=(0,Z.jsx)(ao,{children:(0,Z.jsxs)(so,{onCloseAutoFocus:Ie,align:`end`,sideOffset:8,className:`workspace-menu z-[125] min-w-60 rounded-xl border border-edge bg-surface-overlay p-1.5 text-sm shadow-popover outline-none`,children:[He,Je]})}),t[77]=Ie,t[78]=He,t[79]=Je,t[80]=Ye):Ye=t[80];let Xe;t[81]!==Fe||t[82]!==Ye?(Xe=(0,Z.jsxs)(ro,{modal:!1,children:[Fe,Ye]}),t[81]=Fe,t[82]=Ye,t[83]=Xe):Xe=t[83];let Ze;t[84]!==I||t[85]!==E||t[86]!==ie?(Ze=I&&E?(0,Z.jsx)(PD,{conversationId:I,hideTrigger:!0,dialogOpen:ie,onDialogOpenChange:ae},`share:${I}`):null,t[84]=I,t[85]=E,t[86]=ie,t[87]=Ze):Ze=t[87];let Qe;t[88]!==I||t[89]!==O||t[90]!==o||t[91]!==w||t[92]!==_||t[93]!==B||t[94]!==j||t[95]!==D||t[96]!==V||t[97]!==k||t[98]!==f?(Qe=j?(0,Z.jsx)(hD,{...w,agentId:o,environmentAction:O&&_?(0,Z.jsx)(OD,{directoryOnly:!0,conversationId:I,workspacePath:I?f:w?.project?.workspaceRoot,available:V,canChangeWorkspace:!0,disabled:k,onWorkspaceChange:async e=>{await _(e),await B()}}):null,temporary:D===`temporary`,conversationId:I??null},`context:${I??w?.project?.id??`new`}`):null,t[88]=I,t[89]=O,t[90]=o,t[91]=w,t[92]=_,t[93]=B,t[94]=j,t[95]=D,t[96]=V,t[97]=k,t[98]=f,t[99]=Qe):Qe=t[99];let $e;t[100]!==j||t[101]!==U?($e=j&&!U?(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`mx-0.5 h-6 w-px shrink-0 bg-edge-subtle`}):null,t[100]=j,t[101]=U,t[102]=$e):$e=t[102];let et;t[103]===I?et=t[104]:(et=I?(0,Z.jsx)(SD,{conversationId:I},I):null,t[103]=I,t[104]=et);let tt;t[105]===I?tt=t[106]:(tt=I?(0,Z.jsx)(TD,{conversationId:I}):null,t[105]=I,t[106]=tt);let nt;t[107]!==I||t[108]!==w?.project?.workspaceRoot||t[109]!==_||t[110]!==C||t[111]!==B||t[112]!==j||t[113]!==V||t[114]!==k||t[115]!==U||t[116]!==f?(nt=j&&!U?(0,Z.jsx)(OD,{conversationId:I,workspacePath:I?f:w?.project?.workspaceRoot,available:V,canChangeWorkspace:!1,disabled:k,onWorkspaceChange:async e=>{await _?.(e),await B()}},`workspace:${I??C}`):null,t[107]=I,t[108]=w?.project?.workspaceRoot,t[109]=_,t[110]=C,t[111]=B,t[112]=j,t[113]=V,t[114]=k,t[115]=U,t[116]=f,t[117]=nt):nt=t[117];let rt;t[118]!==je||t[119]!==Xe||t[120]!==Ze||t[121]!==Qe||t[122]!==$e||t[123]!==et||t[124]!==tt||t[125]!==nt?(rt=(0,Z.jsxs)(`div`,{className:Ae,children:[je,Xe,Ze,Qe,$e,et,tt,nt]}),t[118]=je,t[119]=Xe,t[120]=Ze,t[121]=Qe,t[122]=$e,t[123]=et,t[124]=tt,t[125]=nt,t[126]=rt):rt=t[126];let it;t[127]!==Ee||t[128]!==ke||t[129]!==rt?(it={className:`bg-surface-panel`,startExtra:Ee,main:ke,end:rt},t[127]=Ee,t[128]=ke,t[129]=rt,t[130]=it):it=t[130];let at=it,ot,st;t[131]!==at||t[132]!==T||t[133]!==ce?(ot=()=>{T||ce(at)},st=[at,T,ce],t[131]=at,t[132]=T,t[133]=ce,t[134]=ot,t[135]=st):(ot=t[134],st=t[135]),(0,Q.useLayoutEffect)(ot,st);let ct;return t[136]!==at||t[137]!==T||t[138]!==M?(ct=T?(0,Z.jsxs)(`header`,{"aria-label":M===`zh`?`聊天工具栏`:`Chat toolbar`,className:`flex min-h-14 shrink-0 items-center justify-between gap-2 border-b border-edge-subtle px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:at.main}),at.end]}):null,t[136]=at,t[137]=T,t[138]=M,t[139]=ct):ct=t[139],ct});function BD(e){return e.language}function VD(e){return e.collapsed}function HD(e){return e.setOpen}function UD(e){return e.toggle}function WD(e){return e.open}function GD(e){return e.mobileNavOpen}function KD(e){return e.setPageHeader}function qD(e){return e.clearPageHeader}var JD=(0,Q.memo)(function(){let e=(0,X.c)(13),t=h(YD),n;e[0]===t?n=e[1]:(n=y(t),e[0]=t,e[1]=n);let r=n,i=ui(XD),a=ui(ZD);if(i===`idle`)return null;if(i===`error`&&a){let t;e[2]===a?t=e[3]:(t=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:a}),e[2]=a,e[3]=t);let n;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(n=Y(`shrink-0 rounded-xl border border-red-200 bg-white px-2.5 py-1 text-xs font-medium text-red-700`,`hover:bg-red-50 dark:border-red-800 dark:bg-red-950/40 dark:text-red-300 dark:hover:bg-red-950/70`,ua.transition,ua.press,ua.focusRingPanel),e[4]=n):n=e[4];let i;e[5]===r.connection.reconnect?i=e[6]:(i=(0,Z.jsx)(`button`,{type:`button`,className:n,onClick:QD,children:r.connection.reconnect}),e[5]=r.connection.reconnect,e[6]=i);let o;return e[7]!==t||e[8]!==i?(o=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-red-100 bg-red-50 px-4 py-2 text-sm text-red-600 dark:border-red-900/40 dark:bg-red-950/50 dark:text-red-400`,children:[t,i]}),e[7]=t,e[8]=i,e[9]=o):o=e[9],o}if(i===`connecting`||i===`reconnecting`){let t;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`span`,{className:`inline-block size-3 animate-spin rounded-full border-2 border-amber-500 border-t-transparent`,"aria-hidden":!0}),e[10]=t):t=e[10];let n=i===`reconnecting`?r.connection.reconnecting:r.connection.connecting,a;return e[11]===n?a=e[12]:(a=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-amber-100 bg-amber-50 px-4 py-2 text-sm text-amber-800 dark:border-amber-900/40 dark:bg-amber-950/50 dark:text-amber-200`,children:[t,(0,Z.jsx)(`span`,{children:n})]}),e[11]=n,e[12]=a),a}return null});function YD(e){return e.language}function XD(e){return e.connectionState}function ZD(e){return e.error}function QD(){return li()}function $D(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function eO(e){let t=(0,X.c)(4),{status:n}=e;if(n===`completed`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(`span`,{className:`mt-0.5 inline-flex size-4 shrink-0 items-center justify-center rounded-full bg-fg-muted text-surface-panel`,children:(0,Z.jsx)(ee,{className:`size-3`,strokeWidth:2.5,"aria-hidden":!0})}),t[0]=e):e=t[0],e}if(n===`in_progress`){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(de,{className:`mt-0.5 size-4 shrink-0 text-accent`,strokeWidth:2,"aria-hidden":!0}),t[1]=e):e=t[1],e}if(n===`cancelled`){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)($o,{className:`mt-0.5 size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),t[2]=e):e=t[2],e}let r;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(me,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[3]=r):r=t[3],r}function tO(e,t){return e?`${$D(e.files.length===1?t.filesChangedOne:t.filesChangedOther,{count:e.files.length})} · +${e.added} -${e.removed}`:null}function nO(e){let t=(0,X.c)(61),{plan:n,changeSummary:r,isStreaming:i,labels:a}=e,o=n.currentIndex==null?void 0:n.items[n.currentIndex-1],s;t[0]===n.items?s=t[1]:(s=n.items.every(aO),t[0]=n.items,t[1]=s);let c=s,l=n.items.every(iO),u;t[2]!==a.completedProgress||t[3]!==n.completedCount||t[4]!==n.totalCount?(u=$D(a.completedProgress,{completed:n.completedCount,total:n.totalCount}),t[2]=a.completedProgress,t[3]=n.completedCount,t[4]=n.totalCount,t[5]=u):u=t[5];let d=u,f=a.ended;if(c)f=a.finished;else if(o){let e=n.currentIndex??1,r;t[6]!==a.stepProgress||t[7]!==n.totalCount||t[8]!==e?(r=$D(a.stepProgress,{current:e,total:n.totalCount}),t[6]=a.stepProgress,t[7]=n.totalCount,t[8]=e,t[9]=r):r=t[9],f=r}else!l&&i&&(f=a.planned);let p;t[10]!==r||t[11]!==a?(p=tO(r,a),t[10]=r,t[11]=a,t[12]=p):p=t[12];let m=p,h=o?.title,g;t[13]!==m||t[14]!==f||t[15]!==h?(g=[f,h,m].filter(Boolean),t[13]=m,t[14]=f,t[15]=h,t[16]=g):g=t[16];let _=g.join(` · `),v;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(v=Y(`inline-flex min-h-9 min-w-0 max-w-full items-center gap-2 rounded-pill border border-edge-subtle bg-surface-overlay px-3 py-1.5 text-sm text-fg shadow-surface`,ua.transition,`hover:border-edge hover:text-accent-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),t[17]=v):v=t[17];let y=`${a.heading}: ${_}`,b;t[18]!==o||t[19]!==c?(b=c?(0,Z.jsx)(ee,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:2,"aria-hidden":!0}):o?(0,Z.jsx)(de,{className:`size-4 shrink-0 text-accent`,strokeWidth:2,"aria-hidden":!0}):(0,Z.jsx)(Je,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[18]=o,t[19]=c,t[20]=b):b=t[20];let x;t[21]===f?x=t[22]:(x=(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:f}),t[21]=f,t[22]=x);let S;t[23]===o?S=t[24]:(S=o?(0,Z.jsxs)(`span`,{className:`min-w-0 truncate text-fg-muted`,children:[`· `,o.title]}):null,t[23]=o,t[24]=S);let C;t[25]===m?C=t[26]:(C=m?(0,Z.jsxs)(`span`,{className:`hidden shrink-0 tabular-nums text-fg-subtle sm:inline`,children:[`· `,m]}):null,t[25]=m,t[26]=C);let w;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(te,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[27]=w):w=t[27];let T;t[28]!==S||t[29]!==C||t[30]!==y||t[31]!==b||t[32]!==x?(T=(0,Z.jsx)(bi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:v,"aria-label":y,children:[b,x,S,C,w]})}),t[28]=S,t[29]=C,t[30]=y,t[31]=b,t[32]=x,t[33]=T):T=t[33];let E;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsx)(Je,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[34]=E):E=t[34];let D;t[35]===a.heading?D=t[36]:(D=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[E,(0,Z.jsx)(`span`,{children:a.heading})]}),t[35]=a.heading,t[36]=D);let O;t[37]===n.explanation?O=t[38]:(O=n.explanation?(0,Z.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:n.explanation}):null,t[37]=n.explanation,t[38]=O);let k;t[39]!==D||t[40]!==O?(k=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[D,O]}),t[39]=D,t[40]=O,t[41]=k):k=t[41];let A;t[42]===d?A=t[43]:(A=(0,Z.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-fg-subtle`,children:d}),t[42]=d,t[43]=A);let j;t[44]!==k||t[45]!==A?(j=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge-subtle px-4 py-3`,children:[k,A]}),t[44]=k,t[45]=A,t[46]=j):j=t[46];let M=a.heading,N;t[47]===n.items?N=t[48]:(N=n.items.map(rO),t[47]=n.items,t[48]=N);let P;t[49]!==a.heading||t[50]!==N?(P=(0,Z.jsx)(`ol`,{className:`max-h-[min(22rem,55vh)] overflow-y-auto px-4 py-3`,"aria-label":M,children:N}),t[49]=a.heading,t[50]=N,t[51]=P):P=t[51];let F;t[52]===m?F=t[53]:(F=m?(0,Z.jsx)(`div`,{className:`border-t border-edge-subtle px-4 py-2 text-right text-xs tabular-nums text-fg-subtle`,children:m}):null,t[52]=m,t[53]=F);let I;t[54]!==j||t[55]!==P||t[56]!==F?(I=(0,Z.jsx)(gi,{children:(0,Z.jsxs)(_i,{side:`top`,align:`center`,sideOffset:8,collisionPadding:16,className:`z-[120] w-[min(28rem,calc(100vw-2rem))] overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:[j,P,F]})}),t[54]=j,t[55]=P,t[56]=F,t[57]=I):I=t[57];let L;return t[58]!==T||t[59]!==I?(L=(0,Z.jsx)(`div`,{className:`mx-auto flex w-full max-w-80 justify-center pb-2 pt-1`,children:(0,Z.jsxs)(vi,{children:[T,I]})}),t[58]=T,t[59]=I,t[60]=L):L=t[60],L}function rO(e){return(0,Z.jsxs)(`li`,{className:Y(`flex gap-3 py-2 text-sm leading-relaxed text-fg-muted`,e.status===`in_progress`&&`font-medium text-fg`,e.status===`cancelled`&&`text-fg-disabled`),children:[(0,Z.jsx)(eO,{status:e.status}),(0,Z.jsx)(`span`,{className:`min-w-0 [overflow-wrap:anywhere]`,children:e.title})]},e.id)}function iO(e){return e.status===`completed`||e.status===`cancelled`}function aO(e){return e.status===`completed`}function oO(e){let t=fO(e.source,e.explanation,e.items.map(e=>({...e})));return t&&t.items.some(e=>e.status===`pending`||e.status===`in_progress`)?t:null}var sO=new Set([`pending`,`in_progress`,`completed`,`cancelled`]);function cO(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function lO(e){return e.trim().toLowerCase().replace(/-/g,`_`).split(`__`).at(-1)??``}function uO(e){let t=cO(e.details);return t&&Object.keys(t).length>0?t:$h(e.result).details}function dO(e){let t=typeof e==`string`?e.trim():``;return sO.has(t)?t:null}function fO(e,t,n){if(n.length===0)return null;let r=n.findIndex(e=>e.status===`in_progress`);return{source:e,explanation:t,items:n,currentIndex:r>=0?r+1:void 0,completedCount:n.filter(e=>e.status===`completed`).length,totalCount:n.length}}function pO(e){if(!Array.isArray(e.plan))return null;let t=e.plan.flatMap((e,t)=>{let n=cO(e),r=typeof n?.id==`string`&&n.id.trim()?n.id.trim():`update-plan-${t}`,i=typeof n?.step==`string`?n.step.trim():``,a=dO(n?.status);return i&&a?[{id:r,title:i,status:a}]:[]});return fO(`update_plan`,typeof e.explanation==`string`&&e.explanation.trim()?e.explanation.trim():void 0,t)}function mO(e){return Array.isArray(e.items)?fO(`todo`,void 0,e.items.flatMap((e,t)=>{let n=cO(e),r=typeof n?.id==`string`&&n.id.trim()?n.id.trim():`todo-${t}`,i=typeof n?.content==`string`?n.content.trim():``,a=dO(n?.status);return i&&a?[{id:r,title:i,status:a}]:[]})):null}function hO(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.type!==`tool_use`||n.status===`error`)continue;let r=lO(n.name),i=uO(n);if(i){if(r===`update_plan`)return{found:!0,plan:pO(i)};if(r===`todo`)return{found:!0,plan:mO(i)}}}return{found:!1,plan:null}}function gO(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:0}function _O(e){let t=new Set,n=0,r=0;for(let i of e){if(i.type!==`tool_use`||i.status===`error`||lO(i.name)!==`apply_patch`)continue;let e=uO(i);if(e){if(Array.isArray(e.files))for(let n of e.files)typeof n==`string`&&n.trim()&&t.add(n.trim());if(t.size===0&&Array.isArray(e.changes))for(let n of e.changes){let e=cO(n),r=typeof e?.moveTo==`string`?e.moveTo:typeof e?.path==`string`?e.path:``;r.trim()&&t.add(r.trim())}n+=gO(e.added),r+=gO(e.removed)}}return t.size>0||n>0||r>0?{files:[...t],added:n,removed:r}:null}function vO(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.role!==`assistant`)continue;let r=hO(n.content??[]);if(!r.found)continue;if(!r.plan||!r.plan.items.some(e=>e.status===`pending`||e.status===`in_progress`))return null;let i=e.slice(t).flatMap(e=>e.role===`assistant`?e.content??[]:[]);return{plan:r.plan,changeSummary:_O(i)}}return null}function yO(e,t){if(!t)return null;let n=-1;for(let t=e.length-1;t>=0;--t)if(e[t]?.role===`user`){n=t;break}return vO(e.slice(n+1))}function bO(e,t){return e.bottom>t.top&&e.top<t.bottom&&e.right>t.left&&e.left<t.right}function xO(e,t,n){let r=n.getBoundingClientRect(),i=t.getBoundingClientRect();if(!bO(e,{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight})||!bO(i,r)||typeof t.animate!=`function`)return()=>{};let a=t.closest(`article`);a&&(a.style.animation=`none`);let o=t.getBoundingClientRect(),s=Math.max(-8,Math.min(8,e.left-o.left)),c=Math.max(-8,Math.min(8,e.top-o.top)),l;try{l=t.animate([{transform:`translate3d(${s}px, ${c}px, 0)`},{transform:`translate3d(0, 0, 0)`}],{duration:180,easing:`cubic-bezier(0.22, 1, 0.36, 1)`})}catch{return()=>{}}let u=!1,d,f=()=>{u||(u=!0,d!==void 0&&window.clearTimeout(d),n.removeEventListener(`scroll`,p),n.removeEventListener(`wheel`,f),n.removeEventListener(`touchstart`,f),window.removeEventListener(`resize`,f),l.cancel())},p=()=>{let e=t.getBoundingClientRect();(Math.abs(e.top-o.top)>1||Math.abs(e.left-o.left)>1)&&f()};return n.addEventListener(`scroll`,p,{passive:!0}),n.addEventListener(`wheel`,f,{passive:!0}),n.addEventListener(`touchstart`,f,{passive:!0}),window.addEventListener(`resize`,f),d=window.setTimeout(f,350),l.finished.then(f,f),f}function SO(e){let t=(0,X.c)(12),{enabled:n,conversationId:r,messages:i,viewportRef:a}=e,o=(0,Q.useRef)(null),s=(0,Q.useRef)(null),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{o.current&&window.clearTimeout(o.current.timeout),o.current=null,s.current?.(),s.current=null},t[0]=c):c=t[0];let l=c,u;t[1]!==r||t[2]!==n?(u=(e,t,i)=>{if(l(),!n||!r||i.attachments.length>0||i.contextRefs.length>0||!i.text.trim()||document.visibilityState===`hidden`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let a={id:e.clientSubmissionId,source:{left:t.left,top:t.top,right:t.right,bottom:t.bottom},timeout:window.setTimeout(()=>{o.current===a&&(o.current=null)},500)};o.current=a},t[1]=r,t[2]=n,t[3]=u):u=t[3];let d=u,f,p;t[4]!==i||t[5]!==a?(f=()=>{let e=o.current,t=a.current;if(!e||!t||!i.some(t=>t.clientSubmissionId===e.id))return;window.clearTimeout(e.timeout),o.current=null;let n=t.querySelector(`[data-client-submission-id="${e.id}"]`)?.querySelector(`.chat-user-message`);n&&(s.current=xO(e.source,n,t))},p=[i,a],t[4]=i,t[5]=a,t[6]=f,t[7]=p):(f=t[6],p=t[7]),(0,Q.useLayoutEffect)(f,p);let m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>l,t[8]=m):m=t[8];let h;return t[9]!==r||t[10]!==n?(h=[l,r,n],t[9]=r,t[10]=n,t[11]=h):h=t[11],(0,Q.useEffect)(m,h),d}function CO(e){let t=(0,X.c)(61),{open:n,query:r,activeIndex:i,resultCount:a,searching:o,truncated:s,limitedToLoaded:c,inputRef:l,labels:u,onQueryChange:d,onPrevious:f,onNext:p,onClose:m}=e,h=o!==void 0&&o,g=s!==void 0&&s,_=c!==void 0&&c;if(!n)return null;let v;t[0]===r?v=t[1]:(v=r.trim(),t[0]=r,t[1]=v);let y=!!v,b;t[2]!==i||t[3]!==y||t[4]!==u.noResults||t[5]!==u.resultCount||t[6]!==u.searching||t[7]!==a||t[8]!==h||t[9]!==g?(b=h?u.searching:y&&a===0?u.noResults:y?u.resultCount.replace(`{{current}}`,String(i+1)).replace(`{{total}}`,`${a}${g?`+`:``}`):``,t[2]=i,t[3]=y,t[4]=u.noResults,t[5]=u.resultCount,t[6]=u.searching,t[7]=a,t[8]=h,t[9]=g,t[10]=b):b=t[10];let x=b,S;t[11]!==x||t[12]!==y||t[13]!==u.loadedOnly||t[14]!==_?(S=_&&y?[x,u.loadedOnly].filter(Boolean).join(` · `):x,t[11]=x,t[12]=y,t[13]=u.loadedOnly,t[14]=_,t[15]=S):S=t[15];let C=S,w=h||a===0,T=u.input,E;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsx)(Ft,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[16]=E):E=t[16];let D;t[17]===d?D=t[18]:(D=e=>d(e.target.value),t[17]=d,t[18]=D);let O;t[19]!==p||t[20]!==f?(O=e=>{e.nativeEvent.isComposing||e.key===`Enter`&&(e.preventDefault(),e.shiftKey?f():p())},t[19]=p,t[20]=f,t[21]=O):O=t[21];let k;t[22]!==l||t[23]!==u.input||t[24]!==r||t[25]!==O||t[26]!==D?(k=(0,Z.jsx)(`input`,{ref:l,value:r,type:`search`,autoComplete:`off`,spellCheck:!1,"aria-label":u.input,className:`h-12 min-w-0 flex-1 bg-transparent text-base text-fg outline-none placeholder:text-fg-subtle`,placeholder:u.input,onChange:D,onKeyDown:O}),t[22]=l,t[23]=u.input,t[24]=r,t[25]=O,t[26]=D,t[27]=k):k=t[27];let A;t[28]===h?A=t[29]:(A=h?(0,Z.jsx)(Xe,{className:`size-4 shrink-0 animate-spin text-fg-muted`,"aria-hidden":!0}):null,t[28]=h,t[29]=A);let j;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(j=Y(`inline-flex size-11 shrink-0 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,ua.focusRingPanel,ua.press),t[30]=j):j=t[30];let M;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Z.jsx)(qt,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[31]=M):M=t[31];let N;t[32]!==u.close||t[33]!==m?(N=(0,Z.jsx)(`button`,{type:`button`,onClick:m,className:j,"aria-label":u.close,children:M}),t[32]=u.close,t[33]=m,t[34]=N):N=t[34];let P;t[35]!==k||t[36]!==A||t[37]!==N?(P=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 px-3`,children:[E,k,A,N]}),t[35]=k,t[36]=A,t[37]=N,t[38]=P):P=t[38];let F;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(F=Y(`inline-flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,ua.focusRingPanel,ua.press,ua.disabled),t[39]=F):F=t[39];let I;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(re,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[40]=I):I=t[40];let L;t[41]!==u.previous||t[42]!==w||t[43]!==f?(L=(0,Z.jsx)(`button`,{type:`button`,disabled:w,onClick:f,className:F,"aria-label":u.previous,children:I}),t[41]=u.previous,t[42]=w,t[43]=f,t[44]=L):L=t[44];let R;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(R=Y(`inline-flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,ua.focusRingPanel,ua.press,ua.disabled),t[45]=R):R=t[45];let z;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Z.jsx)(te,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[46]=z):z=t[46];let B;t[47]!==u.next||t[48]!==w||t[49]!==p?(B=(0,Z.jsx)(`button`,{type:`button`,disabled:w,onClick:p,className:R,"aria-label":u.next,children:z}),t[47]=u.next,t[48]=w,t[49]=p,t[50]=B):B=t[50];let V;t[51]===C?V=t[52]:(V=(0,Z.jsx)(`span`,{className:`ml-auto px-2 text-sm tabular-nums text-fg-muted`,"aria-live":`polite`,"aria-atomic":`true`,children:C}),t[51]=C,t[52]=V);let H;t[53]!==L||t[54]!==B||t[55]!==V?(H=(0,Z.jsxs)(`div`,{className:`flex h-11 items-center border-t border-edge-subtle px-1.5`,children:[L,B,V]}),t[53]=L,t[54]=B,t[55]=V,t[56]=H):H=t[56];let U;return t[57]!==u.input||t[58]!==P||t[59]!==H?(U=(0,Z.jsxs)(`section`,{"data-chat-find-bar":!0,role:`search`,"aria-label":T,className:`absolute right-3 top-3 z-30 w-[min(25rem,calc(100%-1.5rem))] overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover`,children:[P,H]}),t[57]=u.input,t[58]=P,t[59]=H,t[60]=U):U=t[60],U}async function wO(e,t,n={}){let r=await f(p(`${n.taskId?`/api/tasks/${encodeURIComponent(n.taskId)}/conversation/find`:`/api/sessions/${encodeURIComponent(e)}/find`}?${new URLSearchParams({q:t,limit:`1000`})}`),{signal:n.signal});if(!r.ok)throw Error(`HTTP ${r.status}: ${r.statusText}`);let i=await r.json();if(i.ok!==!0||!Array.isArray(i.matches)||typeof i.total!=`number`)throw Error(`Invalid chat find response`);return{query:typeof i.query==`string`?i.query:t,total:i.total,truncated:i.truncated===!0,matches:i.matches.filter(e=>Number.isInteger(e?.displayIndex)&&e.displayIndex>=0&&Number.isInteger(e?.occurrence)&&e.occurrence>=0)}}var TO=`chat-find-match`,EO=`chat-find-active`,DO=`chat-find-highlight-styles`;function OO(){let e=globalThis.CSS,t=globalThis.Highlight;return!e?.highlights||!t?null:{registry:e.highlights,Highlight:t}}function kO(){if(document.getElementById(DO))return;let e=document.createElement(`style`);e.id=DO,e.textContent=`
62
+ ::highlight(${TO}) {
63
+ color: inherit;
64
+ background-color: color-mix(in srgb, var(--color-warning) 38%, transparent);
65
+ }
66
+ ::highlight(${EO}) {
67
+ color: inherit;
68
+ background-color: color-mix(in srgb, var(--color-warning) 78%, transparent);
69
+ text-decoration: underline 2px var(--color-fg);
70
+ }
71
+ `,document.head.appendChild(e)}function AO(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(e){let t=e.parentElement;return!e.textContent||!t||t.closest(`button, [hidden], [aria-hidden="true"], .sr-only, script, style`)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),r=n.nextNode();for(;r;)t.push(r),r=n.nextNode();return t}function jO(e,t,n){let r=e.find(e=>e.end>t),i=[...e].reverse().find(e=>e.start<n);if(!r||!i)return null;let a=document.createRange();return a.setStart(r.node,t-r.start),a.setEnd(i.node,n-i.start),a}function MO(e,t){let n=t.toLowerCase(),r=e.toLowerCase();if(!n)return[];let i=[],a=0;for(;a<=r.length-n.length;){let e=r.indexOf(n,a);if(e<0)break;i.push({start:e,end:e+n.length}),a=e+Math.max(n.length,1)}return i}function NO(e,t){let n=t.trim();if(!n)return[];let r=[],i=e.querySelectorAll(`[data-chat-message-index]`);for(let e of i){let t=e.dataset.chatMessageIndex,i=t?Number.parseInt(t,10):NaN;if(!Number.isFinite(i))continue;let a=0;for(let t of e.querySelectorAll(`[data-chat-find-text]`)){let e=AO(t),o=[],s=``;for(let t of e){let e=t.textContent??``,n=s.length;s+=e,o.push({node:t,start:n,end:s.length})}for(let e of MO(s,n)){let t=jO(o,e.start,e.end);t&&(r.push({messageIndex:i,occurrence:a,range:t}),a+=1)}}}return r}function PO(e,t){let n=OO();if(!n||(kO(),n.registry.delete(TO),n.registry.delete(EO),e.length===0))return;n.registry.set(TO,new n.Highlight(...e.map(e=>e.range)));let r=e[t];r&&n.registry.set(EO,new n.Highlight(r.range))}function FO(){let e=OO();e?.registry.delete(TO),e?.registry.delete(EO)}function IO(e,t,n=96){let r=t.range.getBoundingClientRect(),i=e.getBoundingClientRect(),a=i.top+n,o=i.bottom-24;r.top>=a&&r.bottom<=o||(VC(e),e.scrollTo({top:Math.max(0,e.scrollTop+r.top-a),behavior:window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}))}function LO(e,t){return t===0?0:(e+t)%t}function RO(e){return`${e.displayIndex}:${e.occurrence}`}function zO(e,t){return e.length===t.length&&e.every((e,n)=>{let r=t[n];return r?.messageIndex===e.messageIndex&&r.occurrence===e.occurrence&&r.range.startContainer===e.range.startContainer&&r.range.startOffset===e.range.startOffset&&r.range.endContainer===e.range.endContainer&&r.range.endOffset===e.range.endOffset})}function BO(e){let t=(0,X.c)(66),{conversationId:n,taskId:r,messages:i,displayOffset:a,viewportRef:o,onRevealDisplayIndex:s}=e,[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(``),f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=[],t[0]=f):f=t[0];let[p,m]=(0,Q.useState)(f),h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h=[],t[1]=h):h=t[1];let[g,_]=(0,Q.useState)(h),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(0),E=(0,Q.useRef)(null),D=(0,Q.useRef)(null),O=(0,Q.useRef)(n),k=(0,Q.useDeferredValue)(u),A;if(t[2]!==a||t[3]!==p||t[4]!==g){let e=new Map(g.map(GO));for(let t of p){let n={displayIndex:a+t.messageIndex,occurrence:t.occurrence};e.set(RO(n),n)}A=[...e.values()].sort(WO),t[2]=a,t[3]=p,t[4]=g,t[5]=A}else A=t[5];let j=A,M;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>{requestAnimationFrame(()=>{E.current?.focus(),E.current?.select()})},t[6]=M):M=t[6];let N=M,P;t[7]===c?P=t[8]:(P=()=>{if(!c){D.current=document.activeElement instanceof HTMLElement?document.activeElement:null,l(!0);return}N()},t[7]=c,t[8]=P);let F=P,I,L;t[9]===c?(I=t[10],L=t[11]):(I=()=>{c&&N()},L=[N,c],t[9]=c,t[10]=I,t[11]=L),(0,Q.useLayoutEffect)(I,L);let R;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(R=()=>{l(!1),d(``),m([]),_([]),y(!1),x(!1),C(!1),T(0),FO(),D.current?.focus(),D.current=null},t[12]=R):R=t[12];let z=R,B;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(B=e=>{d(e),T(0)},t[13]=B):B=t[13];let V=B,H;t[14]===j.length?H=t[15]:(H=e=>{T(t=>LO(t+e,j.length))},t[14]=j.length,t[15]=H);let U=H,W,G;t[16]!==U||t[17]!==c||t[18]!==F?(W=()=>{let e=e=>{let t=e.metaKey||e.ctrlKey;if(t&&!e.altKey&&!e.shiftKey&&e.key.toLowerCase()===`f`){if(document.querySelector(`[role="dialog"][data-state="open"]`))return;e.preventDefault(),F();return}if(c){if(t&&!e.altKey&&e.key.toLowerCase()===`g`){e.preventDefault(),U(e.shiftKey?-1:1);return}e.key===`Escape`&&(e.preventDefault(),z())}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},G=[z,U,c,F],t[16]=U,t[17]=c,t[18]=F,t[19]=W,t[20]=G):(W=t[19],G=t[20]),(0,Q.useEffect)(W,G);let ee;t[21]!==k||t[22]!==c||t[23]!==o?(ee=()=>{let e=o.current;if(!c||!e||!k.trim()){m(UO),FO();return}let t=()=>{let t=NO(e,k);m(e=>zO(e,t)?e:t)};t();let n=null,r=new MutationObserver(()=>{n===null&&(n=requestAnimationFrame(()=>{n=null,t()}))});return r.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>{r.disconnect(),n!==null&&cancelAnimationFrame(n)}},t[21]=k,t[22]=c,t[23]=o,t[24]=ee):ee=t[24];let te;t[25]!==k||t[26]!==i||t[27]!==c||t[28]!==o?(te=[k,i,c,o],t[25]=k,t[26]=i,t[27]=c,t[28]=o,t[29]=te):te=t[29],(0,Q.useLayoutEffect)(ee,te);let ne,re;t[30]!==n||t[31]!==k||t[32]!==c||t[33]!==r?(ne=()=>{let e=k.trim();if(!c||!n||!e){_([]),y(!1),x(!1),C(!1);return}let t=new AbortController;_([]),y(!1),x(!1),C(!0);let i=window.setTimeout(()=>{wO(n,e,{taskId:r,signal:t.signal}).then(e=>{_(e.matches),y(e.truncated)}).catch(e=>{e?.name!==`AbortError`&&(_([]),y(!1),x(!0))}).finally(()=>{t.signal.aborted||C(!1)})},150);return()=>{window.clearTimeout(i),t.abort()}},re=[n,k,c,r],t[30]=n,t[31]=k,t[32]=c,t[33]=r,t[34]=ne,t[35]=re):(ne=t[34],re=t[35]),(0,Q.useEffect)(ne,re);let ie,ae;t[36]===j.length?(ie=t[37],ae=t[38]):(ie=()=>{T(e=>Math.min(e,Math.max(0,j.length-1)))},ae=[j.length],t[36]=j.length,t[37]=ie,t[38]=ae),(0,Q.useEffect)(ie,ae);let K,oe;t[39]!==w||t[40]!==j||t[41]!==a||t[42]!==p||t[43]!==s||t[44]!==o?(K=()=>{let e=j[w],t=o.current;if(!t||!e){PO(p,-1);return}let n=e.displayIndex-a,r=p.findIndex(t=>t.messageIndex===n&&t.occurrence===e.occurrence);PO(p,r),r>=0?IO(t,p[r]):s(e.displayIndex)},oe=[w,j,a,p,s,o],t[39]=w,t[40]=j,t[41]=a,t[42]=p,t[43]=s,t[44]=o,t[45]=K,t[46]=oe):(K=t[45],oe=t[46]),(0,Q.useLayoutEffect)(K,oe);let se;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(se=[],t[47]=se):se=t[47],(0,Q.useEffect)(VO,se);let q,ce;t[48]!==n||t[49]!==c?(q=()=>{O.current!==n&&(O.current=n,c&&z())},ce=[z,n,c],t[48]=n,t[49]=c,t[50]=q,t[51]=ce):(q=t[50],ce=t[51]),(0,Q.useEffect)(q,ce);let le,ue;t[52]===U?(le=t[53],ue=t[54]):(le=()=>U(-1),ue=()=>U(1),t[52]=U,t[53]=le,t[54]=ue);let de;return t[55]!==w||t[56]!==j.length||t[57]!==b||t[58]!==c||t[59]!==u||t[60]!==v||t[61]!==S||t[62]!==F||t[63]!==le||t[64]!==ue?(de={open:c,query:u,inputRef:E,activeIndex:w,resultCount:j.length,truncated:v,limitedToLoaded:b,searching:S,setQuery:V,show:F,close:z,previous:le,next:ue},t[55]=w,t[56]=j.length,t[57]=b,t[58]=c,t[59]=u,t[60]=v,t[61]=S,t[62]=F,t[63]=le,t[64]=ue,t[65]=de):de=t[65],de}function VO(){return HO}function HO(){return FO()}function UO(e){return e.length===0?e:[]}function WO(e,t){return e.displayIndex-t.displayIndex||e.occurrence-t.occurrence}function GO(e){return[RO(e),e]}function KO(e){let t=String(e??``).trim();return!t||t===`new`?null:t}function qO(e){let t=String(e.streamConversationId??``).trim(),n=KO(e.routeConversationId);return!t||!n?!1:t===n}function JO(e){let t=KO(e.routeConversationId);return t?e.cacheConversationId===t:!1}function YO(e){let t=String(e.chatId??``).trim();if(!t)return!1;let n=KO(e.routeConversationId);return n?n===t:!1}function XO(e,t){return e?`new`:t??null}function ZO(e,t){if(!(e||!t))return decodeURIComponent(t)}function QO(e){if(!e.viewConversationId||e.conversationId!==e.viewConversationId)return[];if(!e.streamingMsg)return e.messages;let t=e.messages[e.messages.length-1];if(t?.role===`assistant`&&e.streamingMsg.role===`assistant`){let n=fr([t,e.streamingMsg]);return[...e.messages.slice(0,-1),...n]}return[...e.messages,e.streamingMsg]}function $O(e,t){let n=e[e.length-1];return n?.role!==`assistant`||n.turnId!==t?null:{messagesWithoutTail:e.slice(0,-1),tail:n}}function ek(e){e()}function tk(e,t){return!!(e&&(e.localDraft||e.configVersion!==void 0)&&t?.some(t=>t.id===e.model))}function nk(e){e.sendingRef.current=!1,e.streamingRef.current=!1}function rk(e){return e.isNewRoute?`creating-session`:e.sessionRoutePending||e.showSessionLoading||e.sessionContentLoading?`loading-history`:e.messageCount===0?`ready-empty`:`ready-conversation`}var ik=new Map;async function ak(e,t,n,r,i){let a=m.getState(),o=Er([a.baseUrl,a.conversationId,e,t]),s=Er({action:n,submission:r}),c=ik.get(o);if(c){if(c.signature!==s)throw Error(`An answer is already being submitted`);return(await c.promise).clone()}let l=ok(e,t,n,r,i).then(e=>{for(e.ok||ik.delete(o);ik.size>64;)ik.delete(ik.keys().next().value);return e},e=>{throw ik.delete(o),e});return ik.set(o,{signature:s,promise:l}),(await l).clone()}async function ok(e,t,n,r,i){let a=m.getState().conversationId,o=tf(e,t,`submission`,i),s={schemaVersion:2,action:n,...r,expectedVersion:t},c=Er(s),l=await o.read();if(l&&l.signature!==c)throw Error(`The previous answer is awaiting confirmation. Retry the original answer before changing it.`);let u=l??{signature:c,body:{...s,idempotencyKey:crypto.randomUUID()}};if(await o.write(u),window.dispatchEvent(new CustomEvent(`clarification-submission-state`,{detail:{requestId:e,pending:!0}})),m.getState().conversationId!==a)throw Error(`Active Gateway changed`);let d=await f(p(`/api/clarifications/${encodeURIComponent(e)}/responses`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(u.body)});return(d.ok||d.status>=400&&d.status<500)&&(await o.write(void 0),window.dispatchEvent(new CustomEvent(`clarification-submission-state`,{detail:{requestId:e,pending:!1}})),d.ok&&await tf(e,t,`draft`,i).write(void 0)),d}async function sk(e,t,n){let r=()=>{if(!n())throw new DOMException(`Conversation changed`,`AbortError`)},i=await kr(e);if(r(),i&&(i.kind!==`append`||i.execution||i.delivery!==t.delivery||Er(i.input)!==Er(t.input)||!!i.interrupt!=!!t.interrupt))throw Error(`The previous input is awaiting confirmation`);let a=Ar.parse({...i??t,origin:t.origin}),o=t=>{let n=t?.receipt;if(!n||n.conversationId!==e||n.clientMessageId!==a.clientMessageId||n.transcriptId!==a.expectedTranscriptId||t?.session?.transcriptId!==n.transcriptId)throw Error(`Invalid input receipt or conversation was reset; reload before sending`);if(!t?.inputState)throw Error(`Gateway returned an invalid input state`);return t.inputState};if(i){let t=await f(p(`/api/sessions/${encodeURIComponent(e)}/input-receipts/${encodeURIComponent(a.clientMessageId)}`)),n=await t.json();if(r(),t.ok){let t=o(n.payload);return await Mr(e,a.clientMessageId),r(),t}if(t.status!==404||n.error?.code!==`NOT_RECEIVED`)throw Error(n.error?.message??`Input receipt lookup failed`)}let{origin:s,...c}=a;await Nr(e,c),r();let l=await f(p(`/api/sessions/${encodeURIComponent(e)}/inputs`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(a)}),u=await l.json();if(r(),!l.ok)throw l.status>=400&&l.status<500&&await Mr(e,a.clientMessageId),Error(typeof u.error==`string`?u.error:u.error?.message??`Message was not accepted`);let d=o(u.payload);return await Mr(e,a.clientMessageId),r(),d}function ck(e,t){if(!e||typeof e!=`object`)return null;let n=e,r=n.clarification&&typeof n.clarification==`object`?n.clarification:n;if(r.status!==void 0&&r.status!==`open`||t&&typeof r.conversationId==`string`&&r.conversationId!==t)return null;let i=typeof r.id==`string`?r.id:r.requestId,a=r.question,o=r.kind===`approval`?`approval`:`input`;return typeof i!=`string`||!i.trim()||typeof a!=`string`||!a.trim()?null:{...Qn(r),requestId:i.trim(),conversationId:t,kind:o,question:a.trim(),version:typeof r.version==`number`?r.version:1,createdAt:typeof r.createdAt==`number`?r.createdAt:Date.now(),expiresAt:typeof r.expiresAt==`number`?r.expiresAt:void 0,serverTime:typeof n.serverTime==`number`?n.serverTime:void 0}}function lk(e){let{conversationId:t,decodedKey:n,conversationIdRef:r,sendingRef:i,streamingRef:a,modelSupportsThinking:o,thinkingLevel:s,shouldApplyStreamUpdate:c}=e,l=m(e=>e.conversationId),u=(0,Q.useRef)({gateway:l,conversationId:t});(u.current.gateway!==l||u.current.conversationId!==t)&&(u.current={gateway:l,conversationId:t});let d=(0,Q.useCallback)(()=>{let e=u.current;return()=>u.current===e&&r.current===e.conversationId&&m.getState().conversationId===e.gateway},[r]),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(null),x=(0,Q.useRef)(null),S=(0,Q.useRef)(0),C=(0,Q.useRef)(null),[w,T]=(0,Q.useState)([]),E=(0,Q.useRef)([]),[D,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(()=>({scope:u.current,mode:{kind:`compose`}})),j=k.scope===u.current?k.mode:{kind:`compose`},M=(0,Q.useCallback)(e=>A({scope:u.current,mode:e}),[]),N=(0,Q.useRef)(j);N.current=j;let P=j.kind===`editFollowUp`?j.inputId:null,F=e=>M(e?{kind:`editFollowUp`,inputId:e,version:E.current.find(t=>t.id===e)?.version??0}:{kind:`compose`}),[I,L]=(0,Q.useState)(()=>$n(t??``)),[R,z]=(0,Q.useState)(!1),B=(0,Q.useRef)(!1),V=(0,Q.useRef)(null),H=(0,Q.useRef)(-1);x.current=h,E.current=w,V.current=P;let U=(0,Q.useCallback)(e=>{if(!e||typeof e!=`object`)return;let t=e;if(t.conversationId!==r.current||typeof t.revision!=`number`||!Array.isArray(t.inputs)||t.revision<H.current)return;if(t.control){if(!Hn(t.conversationId,t.control,t.revision))return;L(t.control)}let n=Zw({control:t.control,inputs:t.inputs,activeRunId:t.activeRunId,preparation:t.preparation});H.current=t.revision,E.current=n,T(n)},[r]),W=(0,Q.useCallback)(async e=>{if(e!==r.current)return;let t=d();if(await Tr(e)||!t())return;let n=await f(p(`/api/sessions/${encodeURIComponent(e)}/input-state`)).catch(()=>null);if(!n?.ok||r.current!==e)return;let i=await n.json().catch(()=>null);t()&&U(i?.payload)},[U,d,r]),G=(0,Q.useCallback)(async e=>{if(e!==r.current)return;let t=d(),n=++S.current;if(await Tr(e)||!t())return;let i=await f(p(`/api/sessions/${encodeURIComponent(e)}/clarification`)).catch(()=>null);if(!i?.ok||r.current!==e)return;let a=await i.json().catch(()=>null);!t()||n!==S.current||r.current!==e||(b(null),g(ck(a?.payload,e)),C.current=null)},[d,r]);(0,Q.useLayoutEffect)(()=>{H.current=-1,B.current=!1,z(!1),O(null),S.current++,L($n(t??``)),M({kind:`compose`}),E.current=[],T([]),F(null),g(null)},[t,l]),(0,Q.useEffect)(()=>{!t||t!==n||(W(t),G(t))},[n,G,W,t,l]),(0,Q.useEffect)(()=>{let e=e=>{let t=e.detail;U(t);let n=r.current;n&&t&&typeof t==`object`&&t.conversationId===n&&G(n)},t=e=>{let t=r.current;if(!t)return;let n=e.detail;if(n&&typeof n==`object`){let e=n.conversationId;if(typeof e==`string`&&e!==t)return}b(null),S.current++,g(ck(n,t)),C.current=null},n=()=>{let e=r.current;e&&(W(e),G(e))};return window.addEventListener(`session-input-state`,e),window.addEventListener(`clarification-updated`,t),window.addEventListener(`gateway-realtime-connected`,n),()=>{window.removeEventListener(`session-input-state`,e),window.removeEventListener(`clarification-updated`,t),window.removeEventListener(`gateway-realtime-connected`,n)}},[U,G,W,r]),(0,Q.useEffect)(()=>{if(!h?.expiresAt)return;let e=Math.max(0,h.expiresAt-Date.now())+250,t=window.setTimeout(()=>{let e=r.current;e&&G(e)},e);return()=>window.clearTimeout(t)},[h?.expiresAt,G,r]);let ee=(0,Q.useCallback)(()=>{b(null),g(null)},[]),te=(0,Q.useCallback)(e=>{let t=String(e??``).trim();t&&r.current===t&&(b(null),g(null))},[r]),ne=(0,Q.useCallback)(()=>{b(null),g(null)},[]),re=(0,Q.useCallback)(()=>{F(null)},[]),ie=(0,Q.useCallback)(()=>{b(null),g(null),F(null)},[]),ae=(0,Q.useCallback)(e=>t=>{c(e)&&(i.current=!1,a.current=!1,Nn.getState().setSessionFlags(e,{sending:!1,streaming:!1}),Nn.getState().setSessionProgress(e,null),b(null),S.current++,g({...t,conversationId:e}),C.current=null)},[c,i,a]),K=(0,Q.useCallback)(async(e,t,n,i,a,o)=>{let s=e.trim();if(!s&&!t?.length&&!n?.length)return;let c=r.current;if(!c)throw Error(`No active session`);let l=d(),u=$n(c),f=await jr(c);if(!l())throw new DOMException(`Conversation changed`,`AbortError`);let p=await ir();if(!l())throw new DOMException(`Conversation changed`,`AbortError`);if(!f)throw Error(`Reload the conversation before sending`);let m=Nn.getState().sessions[c]?.configVersion;if(m===void 0)throw Error(`Reload the conversation before sending`);let h=await sk(c,{kind:`append`,expectedTranscriptId:f,configVersion:m,clientMessageId:crypto.randomUUID(),delivery:o??`next`,interrupt:a,controlVersion:u.version,input:{content:s||e,attachments:t?.length?t:void 0,contextRefs:n?.map(({refId:e,kind:t,sourceId:n,expectedVersion:r})=>({refId:e,kind:t,sourceId:n,expectedVersion:r})),appContext:i},origin:p},l);l()&&U(h)},[U,d,r]),oe=(0,Q.useCallback)(async(e,t)=>{let n=r.current;if(!n||B.current)throw Error(`Wait for the current operation`);let i=d(),a=()=>{if(!i())throw new DOMException(`Conversation changed`,`AbortError`)};B.current=!0,z(!0);try{let r=await jr(n);a();let i=Date.now()+15e3;for(;!r&&e===`stop`&&Date.now()<i;)await new Promise(e=>setTimeout(e,100)),r=await jr(n),a();if(!r)throw Error(`Input acceptance is awaiting confirmation`);let o={action:e,operationId:crypto.randomUUID(),expectedTranscriptId:r,expectedVersion:$n(n).version,...t},s=await cr(n,o);if(a(),U(s),e===`steer`){let e=s.inputs?.find(e=>e.id===t?.inputId);if(e?.status===`interrupted`)throw Error(e.error??`Current reply ended before steering`)}if(e===`stop`){let e=Date.now()+15e3;for(;$n(n).phase===`stopping`;){if(a(),Date.now()>=e)throw Error(`Stop is awaiting confirmation`);await new Promise(e=>setTimeout(e,100)),await W(n)}}if(a(),e===`stop`||e===`pause`){let t=$n(n);if(!t.paused||t.version!==o.expectedVersion+1)throw Error(`Queue control changed on another device`);if(e===`stop`&&t.phase!==`idle`)throw Error(`Another input has started`)}}catch(e){throw!i()||(await W(n),!i())||Ne(`error`,e instanceof Error?e.message:String(e)),e}finally{i()&&(B.current=!1,z(!1))}},[U,d,r,W]),se=(0,Q.useCallback)(()=>oe(`stop`),[oe]),q=(0,Q.useCallback)(()=>oe(`resume`),[oe]),ce=(0,Q.useCallback)(async(e,t)=>{let n=d();try{return await oe(`stop`,{turnId:e}),n()?(M({kind:`editTurn`,turnId:e,draft:t}),!0):!1}catch{return!1}},[d,oe]),le=(0,Q.useCallback)(async e=>{let t=E.current.find(t=>t.id===e);if(!t)return!1;let n=d();try{return await oe(`pause`,{inputId:e,inputVersion:t.version}),n()?(M({kind:`editFollowUp`,inputId:e,version:t.version}),!0):!1}catch{return!1}},[d,oe]),ue=(0,Q.useCallback)(()=>M({kind:`compose`}),[]),de=(0,Q.useCallback)(async(e,t,n,i,a)=>{let c=r.current;if(!c||j.kind!==`editFollowUp`||j.inputId!==e||!t.trim()&&!n?.length&&!a?.length)return!1;let l=d(),u=await f(p(`/api/sessions/${encodeURIComponent(c)}/inputs/${encodeURIComponent(e)}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({version:j.version,content:t,attachments:n??[],thinking:o?i??s:`off`,contextRefs:(a??[]).map(({refId:e,kind:t,sourceId:n,expectedVersion:r})=>({refId:e,kind:t,sourceId:n,expectedVersion:r}))})}),m=await u.json();if(!l())return!1;if(U(m.payload),!u.ok)throw Error(m.error?.message??`This input changed; your draft has been preserved`);if(N.current===j){let t=m.payload?.inputs?.find(t=>t.id===e);t&&M({...j,version:t.version})}return!0},[U,d,j,r,o,s]),fe=(0,Q.useCallback)(e=>{V.current===e&&F(null);let t=r.current,n=E.current.find(t=>t.id===e);if(!t||!n)return;let i=d();f(p(`/api/sessions/${encodeURIComponent(t)}/inputs/${encodeURIComponent(e)}?version=${n.version}`),{method:`DELETE`}).then(async e=>{let t=await e.json().catch(()=>null);i()&&U(t?.payload)}).catch(()=>{W(t)})},[U,d,W,r]),J=(0,Q.useCallback)((e,t)=>{let n=E.current.filter(e=>e.status===`queued`),i=n.findIndex(t=>t.id===e);if(i<0)return;let a=t===`up`?i-1:i+1,o=r.current,s=n[i];if(!o||!s||a<0||a>=n.length)return;let c=d();f(p(`/api/sessions/${encodeURIComponent(o)}/inputs/${encodeURIComponent(s.id)}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({version:s.version,position:a})}).then(async e=>{let t=await e.json().catch(()=>null);c()&&U(t?.payload)}).catch(()=>{W(o)})},[U,d,W,r]),pe=(0,Q.useCallback)((e,t)=>{let n=r.current,i=E.current[e],a=E.current[t],o=E.current.filter(e=>e.status===`queued`),s=a?o.findIndex(e=>e.id===a.id):-1;if(!n||i?.status!==`queued`||a?.status!==`queued`||s<0)return;let c=d();f(p(`/api/sessions/${encodeURIComponent(n)}/inputs/${encodeURIComponent(i.id)}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({version:i.version,position:s})}).then(async e=>{let t=await e.json().catch(()=>null);c()&&U(t?.payload)}).catch(()=>{W(n)})},[U,d,W,r]),me=(0,Q.useCallback)(async(e,t)=>{let n=E.current.find(t=>t.id===e);if(!n)return;let r=d();O(e);try{await oe(t,{inputId:e,inputVersion:n.version})}finally{r()&&O(null)}},[d,oe]),he=(0,Q.useCallback)(e=>me(e,`steer`),[me]),ge=(0,Q.useCallback)(e=>me(e,`send`),[me]),_e=(0,Q.useCallback)(async(e,t)=>{let n=x.current;if(!n)return;let i=JSON.stringify([n.requestId,n.version,e,t]);C.current?.signature!==i&&(C.current={signature:i,idempotencyKey:crypto.randomUUID()});let a=C.current.idempotencyKey;v(!0),b(null);try{let i=n.schemaVersion===2?await ak(n.requestId,n.version,e,t,r.current??void 0):await f(p(`/api/clarifications/${encodeURIComponent(n.requestId)}/responses`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:e,...t,expectedVersion:n.version,idempotencyKey:a})});if(x.current?.requestId!==n.requestId)return;if(!i.ok){let e=await i.json().catch(()=>({}));b(e.error?.message??i.statusText??`Clarify failed`);let t=r.current;t&&(i.status===409||i.status===410)&&G(t);return}C.current=null,g(null),b(null)}catch(e){x.current?.requestId===n.requestId&&b(e instanceof Error?e.message:String(e))}finally{v(!1)}},[G,r]);return{clarifyPrompt:h,clarifySubmitting:_,clarifySubmitError:y,clarifyPromptRef:x,pendingFollowUps:w,pendingFollowUpsRef:E,steeringFollowUpId:D,composerMode:j,control:I,controlPending:R,stopSession:se,resumeQueue:q,sendQueuedInput:ge,beginEditTurn:ce,cancelEditor:ue,restoreEditor:M,editingFollowUpId:P,addPendingFollowUp:K,beginEditFollowUp:le,cancelEditFollowUp:ue,commitEditFollowUp:de,removePendingFollowUp:fe,movePendingFollowUp:J,reorderPendingFollowUp:pe,steerPendingFollowUp:he,submitClarifyAnswer:(0,Q.useCallback)(e=>_e(`answer`,e),[_e]),letAgentDecideClarification:(0,Q.useCallback)(()=>_e(`agent_decide`),[_e]),cancelClarification:(0,Q.useCallback)(()=>_e(`cancel`),[_e]),clearVisibleClarify:ee,dismissClarify:ne,dismissClarifyForSession:te,clearPendingFollowUps:re,dismissClarifyAndClearPending:ie,makeOnClarifyRequest:ae}}async function uk(e){let t=await Tr(e);if(t)return{agentId:t.creation.agentId.trim().toLowerCase(),projectId:t.creation.projectId?.trim()||null};let n=await fn(e);return{agentId:(n.routing?.agentId??n.agentId).trim().toLowerCase(),projectId:n.projectId?.trim()||null}}function dk(e){let t=(0,X.c)(59),{navigate:n,conversationIdRef:r,conversationId:i,isNewRoute:a,locationState:o,locationSearch:s,personal:c}=e,l=c!==void 0&&c,u=m(hk),d;t[0]===i?d=t[1]:(d=i?.trim()??``,t[0]=i,t[1]=d);let f=d,p;t[2]===u?p=t[3]:(p=u?[`gateway-chat-agents`,u]:null,t[2]=u,t[3]=p);let h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h={revalidateOnFocus:!1},t[4]=h):h=t[4];let{data:g,mutate:_}=Kr(p,ri,h),v;t[5]!==f||t[6]!==u?(v=u&&f?[`gateway-chat-session-agent`,u,f]:null,t[5]=f,t[6]=u,t[7]=v):v=t[7];let y;t[8]===f?y=t[9]:(y=()=>uk(f),t[8]=f,t[9]=y);let b;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(b={revalidateOnFocus:!1},t[10]=b):b=t[10];let{data:x}=Kr(v,y,b),S=x?.agentId??``,C,w;t[11]===_?(C=t[12],w=t[13]):(C=()=>{let e=e=>{ni(e.detail)||_()};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},w=[_],t[11]=_,t[12]=C,t[13]=w),(0,Q.useEffect)(C,w);let[T,E]=(0,Q.useState)(mk),D=(0,Q.useRef)(g??null),O;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(O=Ur().selectedAgentId??null,t[14]=O):O=t[14];let k=(0,Q.useRef)(O),A,j;t[15]===g?(A=t[16],j=t[17]):(A=()=>{D.current=g??null},j=[g],t[15]=g,t[16]=A,t[17]=j),(0,Q.useEffect)(A,j);let M,N;t[18]===T?(M=t[19],N=t[20]):(M=()=>{k.current=T},N=[T],t[18]=T,t[19]=M,t[20]=N),(0,Q.useEffect)(M,N);let P,F;t[21]===g?(P=t[22],F=t[23]):(P=()=>{if(!g)return;let e=new Set(g.items.map(pk));E(t=>t==null||t===``||!e.has(t)?g.defaultId:t)},F=[g],t[21]=g,t[22]=P,t[23]=F),(0,Q.useEffect)(P,F);let I;t[24]!==r||t[25]!==S?(I=()=>{if(r.current&&S)return S;let e=D.current,t=(k.current??``).trim().toLowerCase();if(!e)return t||void 0;let n=new Set(e.items.map(fk));return t&&n.has(t)?t:e.defaultId},t[24]=r,t[25]=S,t[26]=I):I=t[26];let L=I,R;t[27]!==r||t[28]!==S||t[29]!==x?.projectId||t[30]!==a||t[31]!==s||t[32]!==o||t[33]!==n?(R=e=>{let t=e.trim().toLowerCase(),i=r.current?S||k.current:null;k.current=t,E(t),Fr(t),i!==t&&n(a?`/chat/new${s}`:Zr(x?.projectId),{replace:!1,state:{...a&&o&&typeof o==`object`?o:{},agentId:t,forceNewChat:!0}})},t[27]=r,t[28]=S,t[29]=x?.projectId,t[30]=a,t[31]=s,t[32]=o,t[33]=n,t[34]=R):R=t[34],x?.projectId;let z=R,B,V;t[35]===z?(B=t[36],V=t[37]):(B=()=>{let e=e=>{let t=e.detail?.agentId;typeof t!=`string`||!t.trim()||z(t)};return window.addEventListener(`xopc-set-chat-agent`,e),()=>window.removeEventListener(`xopc-set-chat-agent`,e)},V=[z],t[35]=z,t[36]=B,t[37]=V),(0,Q.useEffect)(B,V);let H,U;t[38]!==i||t[39]!==S||t[40]!==l?(H=()=>{if(!i||l)return;let e=S;!e||k.current===e||(k.current=e,E(e),Fr(e))},U=[S,i,l],t[38]=i,t[39]=S,t[40]=l,t[41]=H,t[42]=U):(H=t[41],U=t[42]),(0,Q.useLayoutEffect)(H,U);let W,G;t[43]!==i||t[44]!==x?(W=()=>{!i||!x||Vr(x.projectId)},G=[x,i],t[43]=i,t[44]=x,t[45]=W,t[46]=G):(W=t[45],G=t[46]),(0,Q.useLayoutEffect)(W,G);let ee,te;t[47]!==a||t[48]!==o?(ee=()=>{if(!a)return;let e=o,t=typeof e?.agentId==`string`?e.agentId.trim().toLowerCase():``;t&&(k.current=t,E(t),Fr(t))},te=[a,o],t[47]=a,t[48]=o,t[49]=ee,t[50]=te):(ee=t[49],te=t[50]),(0,Q.useLayoutEffect)(ee,te);let ne=S||T||g?.defaultId||`main`,re=(g?.items.length??0)>1,ie=x?.projectId??null,ae;return t[51]!==g||t[52]!==ne||t[53]!==z||t[54]!==L||t[55]!==re||t[56]!==ie||t[57]!==u?(ae={token:u,chatAgentsData:g,resolveAgentIdForPost:L,onChatAgentChange:z,displayAgentId:ne,showChatAgentSelector:re,currentSessionProjectId:ie},t[51]=g,t[52]=ne,t[53]=z,t[54]=L,t[55]=re,t[56]=ie,t[57]=u,t[58]=ae):ae=t[58],ae}function fk(e){return e.id}function pk(e){return e.id}function mk(){return Ur().selectedAgentId??null}function hk(e){return e.conversationId}async function gk(e){let t=await e.sessionMgr.createSession(e);return{kind:`create`,conversationId:t.key,session:t}}var _k=new Map,vk=0;function yk(e){let t=m.getState(),n=Ir(t.baseUrl,{agentId:e.agentId?.trim()||`main`,projectId:e.projectId??null}),r=JSON.stringify([n,t.conversationId,e.forceNew===!0,e.temporary===!0,e.executionMode,e.search]),i=_k.get(r);if(i)return i.target.opts=e,i.target.generation=++vk,i.promise;let a={opts:e,generation:++vk},o=e=>{if(a.generation!==vk)return;let t=a.opts;!t.routeConversationId&&hi.getState().scope===`new`&&hi.getState().migrateScope(`new`,e),t.onOpened(e),(t.routeConversationId?.trim()||null)!==e&&t.navigateToSession(e,t.replaceNavigate??!1,t.search)},s=(async()=>{let t=e.agentId??void 0,{conversationId:n}=await gk({sessionMgr:e.sessionMgr,agentId:t?.trim()||`main`,projectId:e.projectId,currentConversationId:e.currentConversationId,forceNew:e.forceNew,temporary:e.temporary,initialAgentConfig:e.initialAgentConfig,executionMode:e.executionMode});return o(n),n})().finally(()=>{_k.delete(r)});return _k.set(r,{promise:s,target:a}),s}var bk={current:null},xk={current:null};function Sk(e){return!!(e&&typeof e==`object`&&e.forceNewChat===!0)}function Ck(e){let t=c(),{conversationId:n}=s(),r=!e&&t.pathname.endsWith(`/new`),i=r&&Sk(t.state),a=e??ZO(r,n),o=XO(r,a),l=KO(o),u=r?null:a??null,d=(0,Q.useRef)(o);return d.current=o,bk.current=u,!r&&a&&(xk.current=a),(0,Q.useLayoutEffect)(()=>{Nn.getState().focusedConversationId!==u&&Nn.getState().setFocusedConversationId(u)},[u]),{isNewRoute:r,forceNewChat:i,decodedKey:a,routedConversationId:o,viewConversationId:l,routedFocusedConversationId:u,routeConversationIdRef:d,locationKey:t.key,locationSearch:t.search,locationState:t.state}}var wk={get current(){return xk.current}},Tk={get current(){return bk.current},set current(e){bk.current=e,Nn.getState().setFocusedConversationId(e)}};function Ek(e){let{token:t,isNewRoute:n,forceNewChat:r,temporary:i=!1,requestedAgentId:a,decodedKey:o,locationKey:s,locationSearch:c,sessionMgrRef:l,resolveAgentIdForPost:u,navigateToSession:d,loadSessionById:f,tryResumeAgentRun:p,restoreLiveCacheIfNeeded:h,adoptEmptySession:g,applyAgentConfig:_,patchInitUi:v}=e,y=(0,Q.useRef)(0),b=m(e=>e.baseUrl),[x,S]=(0,Q.useState)(null),C=n?c:``,w=n?`new:${s}`:o?`session:${o}`:`fallback:${s}`,T=(0,Q.useRef)({isNewRoute:n,forceNewChat:r,temporary:i,requestedAgentId:a,decodedKey:o,newRouteLocationSearch:C});T.current={isNewRoute:n,forceNewChat:r,temporary:i,requestedAgentId:a,decodedKey:o,newRouteLocationSearch:C};let E=(0,Q.useRef)({sessionMgrRef:l,resolveAgentIdForPost:u,navigateToSession:d,loadSessionById:f,tryResumeAgentRun:p,restoreLiveCacheIfNeeded:h,adoptEmptySession:g,applyAgentConfig:_,patchInitUi:v});return E.current={sessionMgrRef:l,resolveAgentIdForPost:u,navigateToSession:d,loadSessionById:f,tryResumeAgentRun:p,restoreLiveCacheIfNeeded:h,adoptEmptySession:g,applyAgentConfig:_,patchInitUi:v},(0,Q.useEffect)(()=>{let e=T.current,n=E.current;if(!t){n.patchInitUi({loading:!1});return}let r=++y.current,i=!1,a=()=>!i&&r===y.current,o=e=>{a()&&n.sessionMgrRef.current.loadSessionAgentConfig(e).then(t=>{a()&&n.applyAgentConfig(e,t)}).catch(()=>{})},s=async()=>{if(!a())return Promise.resolve();let r=Ur(),i=n.resolveAgentIdForPost(),s=Rr({origin:`web-route`,project:$r(e.newRouteLocationSearch),agentId:e.requestedAgentId??i,forceNew:e.forceNewChat,temporary:e.temporary},{defaultAgentId:i??`main`,selectedAgentId:r.selectedAgentId,lastChatScope:r.lastChatScope}),c=s.projectId?await ln(s.projectId):null;if(!a())return;!e.requestedAgentId&&c?.defaultAgentId&&(s.agentId=c.defaultAgentId);let l=Hr(r,s.agentId),u=(t,r)=>yk({sessionMgr:n.sessionMgrRef.current,agentId:s.agentId,currentConversationId:wk.current,routeConversationId:null,forceNew:s.forceNew,temporary:s.temporary,projectId:s.projectId,executionMode:t,initialAgentConfig:r??(l?{model:l.modelRef,...l.thinkingLevel?{thinkingLevel:l.thinkingLevel}:{}}:void 0),navigateToSession:(...e)=>{a()&&n.navigateToSession(...e)},replaceNavigate:!0,search:qr(e.newRouteLocationSearch),onOpened:e=>{a()&&(n.adoptEmptySession(e,null),o(e))}});if(c?.workspaceRoot?.trim()){S({requestKey:w,token:t,baseUrl:b,project:c,agentId:s.agentId,temporary:s.temporary,create:(e,t)=>a()?u(e,t):Promise.reject(Error(`New chat request changed`))});return}await u()},c=(e,t)=>{if(!a())return Promise.resolve();n.restoreLiveCacheIfNeeded(e);let r=Un(e)?.messages??t??br(e);return n.tryResumeAgentRun(e,r)},l=e=>a()?Un(e)?.historyStatus===`ready`?(o(e),c(e,br(e))):n.loadSessionById(e,0).then(t=>{if(a())return c(e,t??br(e))}):Promise.resolve(),u=()=>a()?n.sessionMgrRef.current.loadSessions().then(e=>{if(!a())return;let t=e.filter(e=>(e.messageCount??0)>0)[0]??e[0];if(t)return a()?n.loadSessionById(t.key,0).then(e=>{if(!a())return;n.restoreLiveCacheIfNeeded(t.key);let r=Un(t.key)?.messages??e??br(t.key);return n.sessionMgrRef.current.parseSessionFromHash()||n.navigateToSession(t.key,!0),n.tryResumeAgentRun(t.key,r)}):void 0;if(!a())return;let r=n.resolveAgentIdForPost();return yk({sessionMgr:n.sessionMgrRef.current,agentId:r,currentConversationId:null,routeConversationId:null,navigateToSession:n.navigateToSession,onOpened:e=>{n.adoptEmptySession(e,null),o(e)}}).then(()=>void 0)}):Promise.resolve();return(()=>{let t=e.decodedKey===void 0&&!e.isNewRoute;n.patchInitUi({loading:t,error:null}),(e.isNewRoute?s():e.decodedKey?l(e.decodedKey):u()).then(()=>{a()&&n.patchInitUi({loading:!1})}).catch(e=>{i?a()&&n.patchInitUi({loading:!1}):n.patchInitUi({error:e instanceof Error?e.message:`Chat init failed`,loading:!1})})})(),()=>{i=!0}},[t,b,w]),n&&x?.requestKey===w&&x.token===t&&x.baseUrl===b?x:null}function Dk(e){let t=m(e=>e.conversationId),n=m(e=>e.baseUrl),[r,i]=(0,Q.useState)(null),{data:a,error:o}=Kr(e?[`prepared-session-model`,n,t,e.create]:null,async()=>{let t=Hr(Ur(),e.agentId),[n,r]=await Promise.all([di(),t?.modelRef??pi(e.agentId).then(e=>e.config.models.chat.primary)]),i=n.filter(e=>e.id===r||e.id.endsWith(`/${r}`)),a=n.find(e=>e.id===r)??(i.length===1?i[0]:void 0);return{models:n,selection:{model:a?.id??r,thinkingLevel:a?.thinking?Ds(a.thinking,t?.thinkingLevel,t?.thinkingByModel?.[a.id]):t?.thinkingLevel??`medium`}}},{revalidateOnFocus:!1}),s=r?.preparation===e?r?.selection:a?.selection,c=a?.models.find(e=>e.id===s?.model),l=!!(s?.model&&c),u=r?.preparation===e,d=(0,Q.useRef)({preparation:e,selection:s,ready:l,explicitlySelected:u});d.current={preparation:e,selection:s,ready:l,explicitlySelected:u};let f=(0,Q.useMemo)(()=>e&&{...e,create:async t=>{let n=d.current;if(n.preparation!==e||!n.ready||!n.selection)throw Error(`Model configuration is not ready`);let r=n.selection,i=await e.create(t,r);return n.explicitlySelected&&zr(e.agentId,{modelRef:r.model,thinkingLevel:r.thinkingLevel}),i}},[e]),p=async(t,n)=>{if(!e||!a)throw Error(`Model configuration is not ready`);let r=a.models.find(e=>e.id===t);if(!r)throw Error(`Model is unavailable`);let o=Hr(Ur(),e.agentId)?.thinkingByModel?.[t],c=r.thinking?Ds(r.thinking,n??s?.thinkingLevel,n===void 0?o:void 0):n??s?.thinkingLevel??`medium`;i({preparation:e,selection:{model:t,thinkingLevel:c}})};return{preparation:f,model:s?.model??``,thinkingLevel:s?.thinkingLevel??`medium`,modelSupportsThinking:!!c?.reasoning,ready:l,error:o,onModelChange:e=>p(e),onThinkingChange:e=>p(s?.model??``,e)}}async function Ok(e){let t=e.trim();if(!t)return!1;try{return!!(await di()).find(e=>e.id===t)?.reasoning}catch{return!1}}function kk(e){let{sessionMgrRef:t,routeConversationIdRef:n,sendingRef:r,streamingRef:i,loadingSessionRef:a,messagesLenRef:o,thinkingSupportGenRef:s,navigateToSession:c,resolveAgentIdForPost:l,detachForNewConversation:u,conversationId:d,sessionAgentId:f,currentProjectId:p,taskId:m,hasMore:h}=e,g=()=>Nn.getState(),_=(0,Q.useRef)(Promise.resolve(void 0)),v=(0,Q.useRef)(null),y=(0,Q.useRef)(0),b=(0,Q.useCallback)(e=>{let t=g().focusedConversationId;if(!e.trim())return++s.current===s.current&&t&&g().patchSessionMeta(t,{modelSupportsThinking:!1}),Promise.resolve();let n=++s.current;return Ok(e).then(t=>{if(n!==s.current)return;let r=g().focusedConversationId;r&&g().sessions[r]?.model===e&&g().patchSessionMeta(r,{modelSupportsThinking:t})})},[s]),x=(0,Q.useCallback)(async e=>{try{let n=await t.current.loadSessionAgentConfig(e);Kn(e,n),b(n.model)}catch{}},[t,b]),S=(0,Q.useCallback)(()=>{let e=g().focusedConversationId;if(!e||(g().sessions[e]?.name)?.trim())return;let n=++y.current,r=[700,900,900,1e3,1e3],i=a=>{a>=5||n===y.current&&g().focusedConversationId===e&&(g().sessions[e]?.name?.trim()||window.setTimeout(()=>{n===y.current&&g().focusedConversationId===e&&(g().sessions[e]?.name?.trim()||t.current.fetchSessionName(e).then(t=>{if(n===y.current){if(t){g().patchSessionMeta(e,{name:t});return}i(a+1)}}).catch(()=>{i(a+1)}))},r[a]??900))};i(0)},[t]),C=(0,Q.useCallback)(e=>YO({chatId:e,routeConversationId:n.current}),[n]),w=(0,Q.useCallback)((e,t,n)=>{let r=g().sessions[e];if(n&&r?.messages!==n.messages&&!_n(r))return!1;let i=t.hasMore&&Sr(r?.messages??[],t.messages)>0;return g().mergeCommittedFromServer(e,t.messages,t.hasMore),t.name!==void 0&&g().patchSessionMeta(e,{name:t.name||null}),C(e)&&(i||(v.current=t.nextBeforeCursor??null)),!0},[C]),T=(0,Q.useCallback)(async(e,r=0,i)=>{let o=async(e,r,i)=>{let s=r===0&&!i;a.current=!0;let u=s&&yr(g().sessions[e]?.historyStatus);u&&g().setSessionHistoryStatus(e,`loading`);try{let n={messages:g().sessions[e]?.messages},{messages:a,hasMore:o,name:c,nextBeforeCursor:l}=await t.current.loadSession(e,r,i,m,n.messages);if(s){if(!w(e,{messages:a,hasMore:o,name:c,nextBeforeCursor:l},n))return g().sessions[e]?.messages;if(!C(e))return a;let r=await t.current.loadSessionAgentConfig(e);return C(e)?(Kn(e,r),b(r.model),a):a}if(v.current=l??null,!C(e))return;g().prependHistoryMessages(e,a,o);return}catch(a){if(r===0&&!i){v.current=null;let r=a instanceof Error?a.message:`Failed to load session`;g().setShellError(/^HTTP 404\b/.test(r)?JSON.stringify(Yn(r)):`Failed to load session`);let i=KO(n.current);if(i&&i===e)return;let s=await t.current.loadSessions().catch(()=>[]),u=s.filter(e=>(e.messageCount??0)>0)[0]??s[0];if(u)return c(u.key,!0),await o(u.key,0,null);{v.current=null;let e=l();yk({sessionMgr:t.current,agentId:e,currentConversationId:null,routeConversationId:null,navigateToSession:c,replaceNavigate:!0,onOpened:e=>{g().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:null}),x(e)}})}}return}finally{a.current=!1,u&&g().sessions[e]?.historyStatus===`loading`&&g().setSessionHistoryStatus(e,`ready`)}},s=_.current,u,d=new Promise(e=>{u=e});_.current=s.then(()=>d),await s;try{return await o(e,r,i)}finally{u()}},[n,C,r,i,a,c,b,l,t,m,w]),E=(0,Q.useCallback)(async()=>{let e=g().focusedConversationId;if(!(!e||g().loadingMore||!h)){g().setLoadingMore(!0);try{await T(e,o.current,v.current)}finally{g().setLoadingMore(!1)}}},[h,T,o]),D=(0,Q.useCallback)(async(e,n)=>{if(!d)throw Error(`No active session`);let r=g().sessions[d];if(r?.modelConfigSaving)throw Error(`Model configuration is being saved`);if(!(r?.model===e&&n!==void 0&&r.thinkingLevel===n)){g().patchSessionMeta(d,{modelConfigSaving:!0});try{if(g().setShellError(null),n===void 0){let t=(await di()).find(t=>t.id===e);if(t?.thinking){let i=Hr(Ur(),f)?.thinkingByModel?.[e];n=Ds(t.thinking,r?.thinkingLevel,i)}}let i=m?await t.current.patchTaskConversationModel(m,e,n,r?.configVersion):await t.current.patchSessionAgentConfig(d,{model:e,thinkingLevel:n,configVersion:r?.configVersion});Kn(d,i),zr(f,{modelRef:i.model,thinkingLevel:i.thinkingLevel}),i.model!==r?.model&&b(i.model)}catch(e){let n=e instanceof Error?e.message:`Failed to update model configuration`;g().setShellError(n);let r=await t.current.loadSessionAgentConfig(d).catch(()=>null);throw r&&Kn(d,r),e}finally{g().patchSessionMeta(d,{modelConfigSaving:!1})}}},[d,f,m,t,b]);return{refreshModelThinkingSupport:b,pollSessionNameAfterTurn:S,applyLoadedSessionSnapshot:w,loadSessionById:T,loadMoreMessages:E,onSessionModelChange:D,onSessionThinkingLevelChange:(0,Q.useCallback)(async e=>{let t=d?g().sessions[d]?.model:void 0;t&&await D(t,e)},[d,D]),onSessionWorkingDirectoryChange:(0,Q.useCallback)(async e=>{let n=e.trim();if(!(!d||!n))try{g().setShellError(null),await t.current.patchSessionAgentConfig(d,{workingDirectory:n}),await x(d)}catch(e){throw g().setShellError(e instanceof Error?e.message:`Failed to update working directory`),e}},[x,d,t]),createNewSession:(0,Q.useCallback)(async e=>{g().setShellError(null);let n=l(),r=Hr(Ur(),n??`main`);await yk({sessionMgr:t.current,agentId:n,currentConversationId:d,routeConversationId:d,forceNew:e?.forceNew,temporary:e?.temporary,executionMode:e?.executionMode,projectId:e?.projectId===void 0?p:e.projectId,initialAgentConfig:r?{model:r.modelRef,...r.thinkingLevel?{thinkingLevel:r.thinkingLevel}:{}}:void 0,navigateToSession:c,onOpened:e=>{u(),v.current=null,g().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:null}),x(e)}})},[u,c,l,p,d,t,x]),resetCurrentSession:(0,Q.useCallback)(async()=>{if(d){g().setShellError(null);try{await t.current.resetSession(d),u(),v.current=null,g().setCommittedSnapshot(d,{messages:[],hasMore:!1,name:null}),x(d)}catch(e){g().setShellError(e instanceof Error?e.message:`Failed to reset session`)}}},[x,d,u,t])}}function Ak(e){return new Promise(t=>{Promise.resolve().then(()=>e(()=>t(!0))).then(()=>t(!1),()=>t(!1))})}function jk(e,t,n){return e.map(e=>{if(e.clientSubmissionId!==t||!e.deliveryStatus)return e;if(n===`failed`)return{...e,deliveryStatus:`failed`};let r={...e,deliveryStatus:`accepted`};return delete r.pendingAppContext,r})}function Mk(e){return e!==`suspended`}function Nk(e){let{chatId:t,shouldApplyStreamUpdate:n,beforeAssistantDelta:r,reconcileHydratedAssistantText:i,setStreamingOnStreamStart:a,clearResumeRunIdOnBackgroundTerminal:o,clearResumeRunIdOnVisibleError:s,setError:c,sessionMgrRef:l,applyLoadedSessionSnapshot:u,finalizeMessage:d,fq:f}=e,p=e.isCurrentRun??(()=>!0),m=()=>Nn.getState(),g=()=>{let e={messages:m().sessions[t]?.messages};return l.current.loadSession(t,0,void 0,void 0,e.messages).then(n=>{p()&&u(t,n,e)}).catch(()=>{})},_=new Map,v,b=()=>{if(v!==void 0&&(window.clearTimeout(v),v=void 0),!p()){_.clear();return}if(_.size===0)return;let e=Array.from(_.entries());_.clear(),r(),m().mutateSessionStreaming(t,t=>{for(let[n,r]of e)vn(t.content,n,r)})},x=(e,t)=>{_.set(e,`${_.get(e)??``}${t}`),v===void 0&&(v=window.setTimeout(b,120))},S=e=>{m().clearStreamingState(t),o&&xn.setResumeRunId(t,null),m().setSessionFlags(t,{sending:!1,streaming:!1}),m().setSessionProgress(t,null),Mk(e)&&f.dismissClarifyForSession(t),g()},C={onTextSurface:e=>{r(),m().mutateSessionStreaming(t,t=>{t.textSurface=e})},onReplayGap:g,onUserMessage:e=>{n(t)&&m().appendUserMessageIfMissing(t,e)},onStreamStart:(e,n,i)=>{kf(t),r(),i&&m().updateSessionMessages(t,t=>rr([...t,{role:`task`,content:[],taskTrigger:i,turnId:e,timestamp:Date.now()}])),m().updateSessionMessages(t,t=>wn(t,e)),m().mutateSessionStreaming(t,t=>{t.turnId=e,n&&(t.startsNewBubble=!0)}),m().setSessionFlags(t,{streaming:!0})},onToken:(e,a,o)=>{r(),m().mutateSessionStreaming(t,t=>{On(t.content,e,a,{offset:o,reconcileHydratedSegment:i})}),n(t)&&m().setSessionFlags(t,{streaming:!0})},onAssistantMessageEnd:(e,n,i)=>{r(),m().mutateSessionStreaming(t,t=>{wr(t.content,e,n),i&&(t.usage=i)})},onThinking:(e,n,i)=>{r(),m().mutateSessionStreaming(t,t=>{!n&&e===``?Sn(t.content):tr(t.content,e,n,i)})},onThinkingEnd:e=>{r(),m().mutateSessionStreaming(t,t=>{Tn(t.content,e)})},onToolStart:(e,n,i,a,o,s)=>{r(),m().mutateSessionStreaming(t,t=>{hn(t.content,e,n,i,a,o,s)}),m().setSessionFlags(t,{streaming:!0})},onToolEnd:(e,n,i,a,o,s,c)=>{r(),m().mutateSessionStreaming(t,t=>{En(t.content,e,n,i,a,o,s,c)})},onToolUpdate:(e,n,i)=>{r(),m().mutateSessionStreaming(t,t=>{Pn(t.content,e,n,i)})},onTaskPlanUpdated:e=>{m().setSessionTaskPlan(t,e)},onTurnOutcome:e=>{r(),m().mutateSessionStreaming(t,t=>{t.outcome=e})},onReview:({review:e})=>{r(),m().mutateSessionStreaming(t,t=>{yn(t.content,e)}),n(t)&&m().setSessionFlags(t,{streaming:!0})},onReviewStart:e=>{r(),m().mutateSessionStreaming(t,t=>{Fn(t.content,e)}),n(t)&&m().setSessionFlags(t,{streaming:!0})},onReviewDelta:({reviewId:e,delta:t})=>{x(e,t)},onReviewEnd:({reviewId:e,status:n,message:i})=>{b(),r(),m().mutateSessionStreaming(t,t=>{jn(t.content,e,n,i)})},onProgress:e=>{m().setSessionProgress(t,e)},onTtsAudio:e=>{n(t)&&m().appendAttachmentToCurrentAssistant(t,{name:e.name,mimeType:e.mimeType,type:`voice`,uri:e.uri,size:0},{attachTo:e.attachTo,messageId:e.messageId})},onCompaction:e=>{if(!n(t))return;let r=y(h.getState().language).chat;if(e.status===`started`)m().setSessionProgress(t,{stage:`compaction`,message:r.compactingContext,timestamp:Date.now()});else if(e.status===`completed`){let n=e.tokensBefore&&e.tokensAfter?` (${r.contextTokensFreed.replace(`{{count}}`,String(Math.round((e.tokensBefore-e.tokensAfter)/1e3)))})`:``;m().setSessionProgress(t,{stage:`compaction`,message:`${r.contextCompacted}${n}`,timestamp:Date.now()})}else m().setSessionProgress(t,null)},onClarifyRequest:f.makeOnClarifyRequest(t),onSessionConfigUpdated:()=>{m().patchSessionMeta(t,{modelConfigSaving:!0}),l.current.loadSessionAgentConfig(t).then(e=>Kn(t,e)).catch(()=>{}).finally(()=>m().patchSessionMeta(t,{modelConfigSaving:!1}))},onResult:({status:e})=>{b();let r=n(t);if(xn.takeUserAborted(t)||e===`cancelled`){Mf(t),r?d(t,e):S(e);return}if(e===`error`){if(jf(t,!r),!r){S(e);return}d(t,e),g();return}if(e===`suspended`?Nf(t):Af(t,!r),!r){S(e);return}d(t,e)},onError:e=>{b();let r=n(t);if(jf(t,!r),!r){S(`error`);return}m().clearStreamingState(t),s&&xn.setResumeRunId(t,null),m().setSessionFlags(t,{sending:!1,streaming:!1}),m().setSessionProgress(t,null),c(e),f.dismissClarifyForSession(t)}};return Object.fromEntries(Object.entries(C).map(([e,t])=>[e,(...e)=>{if(p())return Reflect.apply(t,void 0,e)}]))}function Pk(e){return Un(e)?.streamingMsg??null}var Fk=80;function Ik(e){let t=e.trim();(t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`))&&(t=t.slice(1,-1).trim());let n=t.indexOf(`
72
+ `);return n!==-1&&(t=t.slice(0,n).trim()),t.length>Fk&&(t=t.slice(0,Fk-1).trimEnd()+`…`),t}function Lk(e){let t=e.trimStart();if(!/^##\s+Skill:\s*\S+/i.test(t))return e;let n=/(?:^|\r?\n)\*\*Arguments\*\*:\s*/gi,r=-1;for(;n.exec(t)!==null;)r=n.lastIndex;if(r!==-1){let e=t.slice(r).trim();if(e)return e}return(t.split(/\r?\n/)[0]?.trim()??``).replace(/^##\s+Skill:\s*/i,``).trim()}function Rk(e){let t=e.trimStart().match(/^\/skill:([^\s]+)(?:\s+([\s\S]*))?$/i);return t&&(t[2]?.trim()||t[1]?.trim())||e}function zk(e){let t=Rk(Lk(Rn([{type:`text`,text:e}]))).split(/\n/)[0]?.trim();if(!t)return null;let n=Ik(t);return n.length>0?n:null}function Bk(e,t){let n=e.trim(),r=t.trim();!n||!r||window.dispatchEvent(new CustomEvent(`session-updated`,{detail:{key:n,name:r},bubbles:!0}))}var Vk=new Set([`new`,`reset`,`restart`]),Hk=new Set([...Vk,`clear`,`archive`]);function Uk(e){let t=e.trim(),n=/^\/([^\s@]+)(?:@[^\s]+)?(?:\s+([\s\S]*))?$/.exec(t);return n?{name:n[1].toLowerCase(),args:n[2]?.trim()??``}:null}function Wk(e){let t=Uk(e);return!!(t&&Vk.has(t.name)&&!t.args)}function Gk(e){let t=Uk(e);return!!(t&&Hk.has(t.name))}function Kk(e){let{conversationId:t,taskId:n,thinkingLevel:r,modelSupportsThinking:i,conversationIdRef:a,sendingRef:o,streamingRef:s,sessionMgrRef:c,sendMessageRef:l,shouldApplyStreamUpdate:u,fq:d,applyLoadedSessionSnapshot:f,loadSessionById:p,resetCurrentSession:h,pollSessionNameAfterTurn:g}=e,_=()=>Nn.getState(),v=e=>_().setShellError(e),y=()=>_().setShellError(null),b=(0,Q.useCallback)((e,t)=>{let n=e??a.current;if(n&&!u(n))return;let r=n?Pk(n):null,i=null;if(r){let e=Dn(r,Date.now());e.runStatus=t,kn(e.content,t===`success`),Tn(e.content),t!==`suspended`&&Cn(e.content,t===`success`),bn(e.content),e.completedAt=t&&t!==`suspended`?Date.now():void 0,i=er(e)}i&&gn(i)&&n?_().finalizeStreamingTurn(n,i):n&&_().clearStreamingState(n),o.current=!1,s.current=!1,n&&xn.resetRunTracking(n),(!t||Mk(t))&&d.dismissClarify(),g();let c=a.current;c&&window.setTimeout(()=>{a.current===c&&(o.current||s.current||p(c,0))},400)},[o,s,a,d.dismissClarify,d.pendingFollowUpsRef,g,p,u]),x=(0,Q.useCallback)(async(e,t)=>{if(!u(e))return;let r=m.getState().conversationId,i=()=>m.getState().conversationId===r,a=xn.getGeneration(e),l=_().sessions[e]?.streamingMsg,h=_().sessions[e]?.messages.findLast(e=>e.role===`user`)?.clientSubmissionId,g=await dr(e);if(!i()||xn.getGeneration(e)!==a)return;if(!g){let t=_().sessions[e]?.streamingMsg;if(t?.pendingResponseStatus||t&&t!==l||xn.isStreamingFor(e))return;let n=xn.getResumeRunId(e);n&&xn.reconcileInactive(e,n),_().clearStreamingState(e,{preservePendingResponse:!0}),Mf(e);return}let y=()=>{let t=_().sessions[e]?.streamingMsg,n=_().sessions[e]?.messages.findLast(e=>e.role===`user`)?.clientSubmissionId;return!i()||xn.getGeneration(e)!==a||!!(n&&n!==h)||!!(Gn(e)&&Gn(e)!==g)||!!(t?.turnId&&t.turnId!==g&&t.turnId!==l?.turnId)||!!(t?.pendingResponseStatus&&t!==l)};if(y()||xn.isTrackingRun(e,g))return;let x=()=>{let t=_().sessions[e]?.streamingMsg;!t?.turnId||t.turnId===g||t.turnId!==l?.turnId||(gn(t)?_().finalizeStreamingTurn(e,er(t)):_().clearStreamingState(e))},S=t??br(e),C=Un(e)?.hasMore??!1;try{let t=await c.current.loadSession(e,0,void 0,n,_().sessions[e]?.messages);if(y()||xn.isTrackingRun(e,g))return;x(),_().mergeCommittedFromServer(e,t.messages,t.hasMore),S=t.messages,C=t.hasMore}catch{}if(y()||xn.isTrackingRun(e,g))return;x(),a=xn.advanceGeneration(e),xn.setUserAborted(e,!1),xn.setResumeRunId(e,g),o.current=!0,s.current=!0,_().seedSessionIfEmpty(e,S,!0,!0,C),_().setSessionFlags(e,{sending:!0,streaming:!0}),_().setSessionProgress(e,null),kf(e);let w=!1,T=()=>{if(w||!u(e))return;w=!0;let t=$O(br(e),g);t&&_().applyHydratedTail(e,t.messagesWithoutTail,er(t.tail))},E=()=>{_().clearStreamingState(e),xn.getResumeRunId(e)===g&&xn.setResumeRunId(e,null),u(e)&&(o.current=!1,s.current=!1)};try{let t=Nk({chatId:e,shouldApplyStreamUpdate:u,isCurrentRun:()=>i()&&xn.getGeneration(e)===a,beforeAssistantDelta:T,reconcileHydratedAssistantText:!0,setStreamingOnStreamStart:!1,clearResumeRunIdOnBackgroundTerminal:!0,clearResumeRunIdOnVisibleError:!0,setError:v,sessionMgrRef:c,applyLoadedSessionSnapshot:f,finalizeMessage:b,fq:d}),n=await xn.senderFor(e).resume(g,e,t,{replayFromStart:l?.turnId!==g||!gn(l)});if(!i()||xn.getGeneration(e)!==a)return;n||(Mf(e),E(),await p(e,0).catch(()=>void 0))}catch(t){if(!i()||xn.getGeneration(e)!==a)return;t.name!==`AbortError`&&console.error(`[chat] resume failed:`,t),Mf(e),E()}finally{xn.releaseIdleSender(e)}},[o,s,u,c,f,b,p,n]),S=(0,Q.useCallback)(async(e,t,r,i)=>{if(!e.trim()&&!t?.length&&!i?.length)return!1;let c=a.current;if(!c||!o.current&&!s.current&&!xn.isStreamingFor(c))return!1;let l=e.trim();if(n&&Gk(l))return v(`A task has one continuous conversation.`),!1;if(Wk(l)&&!t?.length){await h();return}return await d.addPendingFollowUp(e,t,i,void 0,!0),!0},[o,s,a,d.addPendingFollowUp,h,n]),C=(0,Q.useCallback)(async(e,a,l,g,x,S,C,w)=>{if(!t||!u(t)||!e.trim()&&!a?.length&&!g?.length||o.current||s.current||xn.isStreamingFor(t))return!1;let T=e.trim();if(n&&Gk(T))return v(`A task has one continuous conversation.`),!1;if(Wk(T)&&!a?.length){await h();return}let E=i?l??r:`off`,D=t,O=xn.advanceGeneration(D),k=m.getState().conversationId,A=()=>m.getState().conversationId===k&&xn.getGeneration(D)===O,j=crypto.randomUUID(),M=`assistant-stream:${D}:${j}`,N=br(D),P=w?N.filter(e=>e.clientSubmissionId!==w):N,F=x?P.findIndex(e=>e.role===`user`&&e.turnId===x):-1;if(x&&F<0)return!1;xn.setUserAborted(D,!1),o.current=!0,s.current=!1,y(),d.dismissClarify();let I=F>=0?P.slice(0,F):P,L=vr(e)??void 0,R=new Map(g?.flatMap(e=>e.refId?[[e.refId,e.title]]:[])??[]),z=L?Cr(L,e=>R.get(e)):e,B=[...I,{role:`user`,content:z?[{type:`text`,text:z}]:[],userTurnDocument:L,deliveryStatus:`sending`,clientSubmissionId:j,pendingAppContext:S===void 0?void 0:structuredClone(S),attachments:a,contextRefs:g?.map(e=>({refId:e.refId,kind:e.kind,sourceId:e.sourceId,version:e.expectedVersion,title:e.title,fileKind:e.fileKind})),timestamp:Date.now()}];C?.(j);let V=Un(D);if(_().initSessionSnapshot(D,{...V??{...ur(),historyStatus:`ready`,hasMore:!1,streamingMsg:null,progress:null,taskPlan:null,sending:!1,streaming:!1},messages:B,hasMore:V?.hasMore??!1,streamingMsg:{role:`assistant`,content:[],timestamp:Date.now(),renderKey:M,pendingResponseStatus:`sending`},progress:null,sending:!0,streaming:!1}),kf(D),!V?.name?.trim()&&z.trim()){let e=zk(z.trim());e&&(_().patchSessionMeta(D,{name:e}),Bk(D,e))}let H=e=>{_().updateSessionMessages(D,t=>jk(t,j,e))};return Ak(async t=>{let r=!1;try{let i=Nk({chatId:D,shouldApplyStreamUpdate:u,isCurrentRun:A,beforeAssistantDelta:()=>{},reconcileHydratedAssistantText:!1,setStreamingOnStreamStart:!0,clearResumeRunIdOnBackgroundTerminal:!1,clearResumeRunIdOnVisibleError:!1,setError:v,sessionMgrRef:c,applyLoadedSessionSnapshot:f,finalizeMessage:b,fq:d});i.onInputAccepted=()=>{r=!0,H(`accepted`),A()&&_().setPendingResponseStatus(D,`waiting`),t()},await xn.senderFor(D).send(e,D,a,E,i,n,x,g,S)}catch(e){if(!A())return;if(e.name!==`AbortError`)_().clearStreamingState(D),Mf(D),u(D)&&v(e instanceof Error?e.message:String(e)),x&&p(D,0);else{Mf(D);let e=Un(D)?.streamingMsg;e?.renderKey===M&&e.pendingResponseStatus&&_().clearStreamingState(D)}}finally{A()&&(r||H(`failed`),u(D)&&(o.current=!1,s.current=!1),_().setSessionFlags(D,{sending:!1}),xn.releaseIdleSender(D))}})},[t,r,i,o,s,u,c,f,b,d.dismissClarify,h,n,p]),w=(0,Q.useCallback)((e,t,n,r,i)=>C(t,n,r,i,e),[C]),T=(0,Q.useCallback)((e,t)=>{let n=a.current;if(!n||$n(n).phase!==`idle`||xn.getGeneration(n)!==e)return;let r=xn.getResumeRunId(n),i=_().sessions[n]?.streamingMsg?.turnId;r&&r!==t||i&&i!==t||(d.dismissClarify(),xn.abort(n,!1),Mf(n),o.current=!1,s.current=!1,b(n,`cancelled`),p(n,0))},[d.dismissClarify,o,s,b,a,p]);return{finalizeMessage:b,tryResumeAgentRun:x,sendMessage:C,replaceLatestUserTurn:w,interruptAndSend:S,abort:(0,Q.useCallback)(async()=>{let e=a.current;if(!e)return;let t=xn.getGeneration(e),n=xn.getResumeRunId(e)??_().sessions[e]?.streamingMsg?.turnId??null;await d.stopSession(),a.current===e&&T(t,n)},[d.stopSession,a,T]),settleStoppedRun:T,deleteMessageRound:(0,Q.useCallback)(e=>{let t=a.current;if(!t||o.current||s.current)return;let n=br(t),r=n[e];if(!r||!An(r.role))return;if(r.deliveryStatus===`failed`){let r=[...n];r.splice(e,1),_().updateSessionMessages(t,()=>r);return}let i=qn(n,e);if(i===null)return;let l=mn(n,e),u=[...n];u.splice(e,l),_().updateSessionMessages(t,()=>u),c.current.deleteMessages(t,{userRoundIndex:i}).catch(()=>{p(t,0)})},[a,o,s,c,p]),retryUserMessageRound:(0,Q.useCallback)(e=>{let t=a.current;if(!t||o.current||s.current)return;let n=br(t),r=n[e];if(!r||!An(r.role))return;for(let t=e+1;t<n.length;t++){let e=n[t];if(e&&An(e.role))return}let i=r.userTurnDocument?Wn(r.userTurnDocument):Rn(r.content),c=Ln(r.attachments);if(!i.trim()&&!c?.length&&!r.contextRefs?.length)return;let u=r.contextRefs?.flatMap(e=>e.kind===`mcp_resource`?[]:[{refId:e.refId,kind:e.kind,sourceId:e.sourceId,expectedVersion:e.version,title:e.title,fileKind:e.fileKind}]),d=r.deliveryStatus===`failed`?r.clientSubmissionId:void 0;!d&&!r.turnId||l.current(i,c,void 0,u,r.turnId,r.pendingAppContext,void 0,d).catch(()=>{p(t,0)})},[a,o,s,p,l])}}function qk(e){let t=(0,X.c)(11),{conversationId:n,conversationIdRef:r,sessionMgrRef:i,loadSessionById:a,loadTimelineById:o,applyAgentConfig:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=[],t[0]=c):c=t[0],(0,Q.useEffect)(Yk,c);let l,u;t[1]!==n||t[2]!==a||t[3]!==o?(l=()=>{let e=e=>{let t=e.detail;!t?.key||t.key!==n||(a(n,0),o(n))};return window.addEventListener(`session-transcript-updated`,e),()=>window.removeEventListener(`session-transcript-updated`,e)},u=[n,a,o],t[1]=n,t[2]=a,t[3]=o,t[4]=l,t[5]=u):(l=t[4],u=t[5]),(0,Q.useEffect)(l,u);let d,f;t[6]!==s||t[7]!==r||t[8]!==i?(d=()=>{let e=e=>{if(ni(e.detail))return;let t=r.current;t&&i.current.loadSessionAgentConfig(t).then(e=>{s(t,e)}).catch(Jk)};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},f=[r,i,s],t[6]=s,t[7]=r,t[8]=i,t[9]=d,t[10]=f):(d=t[9],f=t[10]),(0,Q.useEffect)(d,f)}function Jk(){}function Yk(){let e=Xk;return window.addEventListener(`session-updated`,e),()=>window.removeEventListener(`session-updated`,e)}function Xk(e){let t=e.detail;!t?.key||t.name===void 0||Nn.getState().patchSessionMeta(t.key,{name:t.name||null})}function Zk(e){let t=d(),{isNewRoute:n,forceNewChat:r,decodedKey:i,viewConversationId:a,routedFocusedConversationId:o,routeConversationIdRef:s,locationKey:c,locationSearch:l,locationState:u}=Ck(e?.fixedConversationId),f=(0,Q.useRef)(new pr),p=(0,Q.useRef)(!1),m=(0,Q.useRef)(!1),h=(0,Q.useRef)(!1),g=(0,Q.useRef)(0),_=(0,Q.useRef)(!1),[v,y]=(0,Q.useState)([]),b=(0,Q.useRef)(async()=>{}),x=(0,Q.useRef)(0),S=o,C=Nn(e=>e.initLoading),w=Nn(e=>e.loadingMore),T=Nn(e=>e.shellError),E=a,D=Mm(E),O=E?_n(D):!1,k=O?D?.streaming??!1:!1,A=O?D?.sending??!1:!1,j=O?D?.progress??null:null,M=O?D?.taskPlan??null:null,N=D?.hasMore??!1,P=D?.name??null,F=D?.model??``,I=tk(D,Kr(fi,di,{revalidateOnFocus:!1}).data),L=D?.modelConfigSaving??!1,R=D?.thinkingLevel??`medium`,z=D?.reasoningLevel??`on`,B=D?.modelSupportsThinking??!1,V=D?.effectiveWorkspacePath??``,H=D?.workspaceSource??`agent_default_root`,U=D?.userContextMode??`enabled`;(0,Q.useEffect)(()=>{!E||A||k||f.current.loadSessionAgentConfig(E).then(e=>Kn(E,e)).catch(()=>void 0)},[E,A,k]),(0,Q.useEffect)(()=>{let e=e=>{let t=e.detail.conversationId;f.current.loadSessionAgentConfig(t).then(e=>Kn(t,e)).catch(()=>void 0)};return window.addEventListener(`session-model-config-stale`,e),()=>window.removeEventListener(`session-model-config-stale`,e)},[]),(0,Q.useEffect)(()=>{x.current=D?.messages.length??0},[D?.messages.length]),(0,Q.useEffect)(()=>{m.current=A,h.current=k},[A,k]);let{token:W,chatAgentsData:G,resolveAgentIdForPost:ee,onChatAgentChange:te,displayAgentId:ne,showChatAgentSelector:re,currentSessionProjectId:ie}=dk({navigate:t,personal:e?.personal,conversationIdRef:Tk,conversationId:S,isNewRoute:n,locationState:u,locationSearch:l}),ae=i!==void 0&&S!==i,K=!!(i&&D?.historyStatus===`loading`&&!ae),oe=(0,Q.useMemo)(()=>C&&(S==null||i===void 0),[C,S,i]),se=rk({isNewRoute:n,sessionRoutePending:ae,showSessionLoading:oe,sessionContentLoading:K,messageCount:D?.messages.length??0}),q=(0,Q.useCallback)((e,n=!1,r)=>{let i=r??``;t({pathname:`/chat/${encodeURIComponent(e)}`,search:i},{replace:n})},[t]),ce=(0,Q.useCallback)(e=>qO({streamConversationId:e,routeConversationId:s.current}),[s]),le=(0,Q.useCallback)(()=>{nk({sendingRef:m,streamingRef:h})},[]),ue=lk({conversationId:S,decodedKey:i,conversationIdRef:Tk,sendingRef:m,streamingRef:h,modelSupportsThinking:B,thinkingLevel:R,shouldApplyStreamUpdate:ce}),de=(0,Q.useCallback)(()=>{ue.clearVisibleClarify();let e=Tk.current;e&&xn.resetRunTracking(e),ek(le)},[ue.clearVisibleClarify,Tk,le]),{refreshModelThinkingSupport:fe,pollSessionNameAfterTurn:J,applyLoadedSessionSnapshot:pe,loadSessionById:me,loadMoreMessages:he,onSessionModelChange:ge,onSessionThinkingLevelChange:_e,onSessionWorkingDirectoryChange:ve,createNewSession:ye,resetCurrentSession:be}=kk({sessionMgrRef:f,routeConversationIdRef:s,sendingRef:m,streamingRef:h,loadingSessionRef:p,messagesLenRef:x,thinkingSupportGenRef:g,navigateToSession:q,resolveAgentIdForPost:ee,detachForNewConversation:de,conversationId:S,sessionAgentId:ne,currentProjectId:ie,hasMore:N,taskId:e?.taskId}),xe=(0,Q.useCallback)(e=>{if(!JO({cacheConversationId:e,routeConversationId:s.current}))return!1;let t=Un(e);return!t||!_n(t)&&!sr(e)&&!xn.isStreamingFor(e)?!1:(m.current=t.sending,h.current=t.streaming,!0)},[s]),{tryResumeAgentRun:Se,sendMessage:Ce,replaceLatestUserTurn:we,interruptAndSend:Te,abort:Ee,settleStoppedRun:De,deleteMessageRound:Oe,retryUserMessageRound:ke}=Kk({conversationId:S,taskId:e?.taskId,thinkingLevel:R,modelSupportsThinking:B,conversationIdRef:Tk,sendingRef:m,streamingRef:h,sessionMgrRef:f,sendMessageRef:b,shouldApplyStreamUpdate:ce,fq:ue,applyLoadedSessionSnapshot:pe,loadSessionById:me,resetCurrentSession:be,pollSessionNameAfterTurn:J});(0,Q.useEffect)(()=>{n&&de()},[n,de]);let Ae=(0,Q.useMemo)(()=>QO({viewConversationId:a,conversationId:E,messages:D?.messages??[],streamingMsg:O?D?.streamingMsg??null:null}),[a,E,D?.messages,D?.streamingMsg,O]),je=(0,Q.useCallback)((e,t)=>{Nn.getState().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:t}),le()},[le]),Me=(0,Q.useCallback)((e,t)=>{Kn(e,t),fe(t.model)},[fe]),Ne=(0,Q.useCallback)(e=>{let t=Nn.getState();e.loading!==void 0&&t.setInitLoading(e.loading),e.error!==void 0&&t.setShellError(e.error)},[]),Pe=(0,Q.useCallback)(async t=>{try{let n=await f.current.loadTimeline(t,e?.taskId);if(s.current!==t)return;y(n)}catch{s.current===t&&y([])}},[s,e?.taskId]);(0,Q.useEffect)(()=>{if(n||!S){y([]);return}Pe(S)},[S,n,Pe]),qk({conversationId:S,conversationIdRef:Tk,sendingRef:m,streamingRef:h,sessionMgrRef:f,loadSessionById:me,loadTimelineById:Pe,applyAgentConfig:Me});let Fe=Ek({token:W,isNewRoute:n,forceNewChat:r,temporary:u?.temporary===!0,requestedAgentId:typeof u?.agentId==`string`?u.agentId:void 0,decodedKey:i,locationKey:c,locationSearch:l,sessionMgrRef:f,resolveAgentIdForPost:ee,navigateToSession:q,loadSessionById:me,tryResumeAgentRun:Se,restoreLiveCacheIfNeeded:xe,adoptEmptySession:je,applyAgentConfig:Me,patchInitUi:Ne}),Ie=Dk(Fe);return(0,Q.useEffect)(()=>{Fe&&Ie.error&&Nn.getState().setShellError(Ie.error instanceof Error?Ie.error.message:`Failed to load model configuration`)},[Fe,Ie.error]),(0,Q.useEffect)(()=>{let e=e=>{let t=e.detail,n=t?.conversationId,r=t?.runId;!n||!r?.trim()||(nr(n,r),xn.setResumeRunId(n,r),ce(n)&&(xn.isTrackingRun(n,r)||queueMicrotask(()=>{ce(n)&&(xn.isTrackingRun(n,r)||Se(n,br(n)))})))};return window.addEventListener(`run-started`,e),()=>window.removeEventListener(`run-started`,e)},[Se,ce]),(0,Q.useEffect)(()=>{let e=k||A,t=_.current;if(_.current=e,!t||e)return;let n=Tk.current;n&&queueMicrotask(()=>{!n||!ce(n)||xn.isStreamingFor(n)||sr(n)&&Se(n,br(n))})},[k,A,Se,ce]),b.current=Ce,{auth:{hasToken:!!W},session:{projectPreparation:Ie.preparation,conversationId:S,sessionName:P,decodedKey:i,sessionRoutePending:ae,sessionContentLoading:K,showSessionLoading:oe,conversationPhase:se,loading:C,sessionModel:Fe?Ie.model:F,modelConfigReady:Fe?Ie.ready:I,modelConfigSaving:L,thinkingLevel:Fe?Ie.thinkingLevel:R,onSessionThinkingLevelChange:Fe?Ie.onThinkingChange:_e,onSessionWorkingDirectoryChange:ve,reasoningLevel:z,modelSupportsThinking:Fe?Ie.modelSupportsThinking:B,effectiveWorkspacePath:V,workspaceSource:H,userContextMode:Fe?.temporary?`temporary`:U,hasMore:N,loadingMore:w,loadMoreMessages:he,onSessionModelChange:Fe?Ie.onModelChange:ge,createNewSession:ye,sessionManager:f.current},messages:{items:Ae},timeline:{items:v,refresh:Pe},stream:{error:T,streaming:k,sending:A,progress:j,taskPlan:M,sendMessage:Ce,replaceLatestUserTurn:we,abort:Ee,settleStoppedRun:De,interruptAndSend:Te,deleteMessageRound:Oe,retryUserMessageRound:ke},followUp:{composerMode:ue.composerMode,control:ue.control,controlPending:ue.controlPending,beginEditTurn:ue.beginEditTurn,cancelEditor:ue.cancelEditor,restoreEditor:ue.restoreEditor,resumeQueue:ue.resumeQueue,sendQueuedInput:ue.sendQueuedInput,addPendingFollowUp:ue.addPendingFollowUp,pendingFollowUps:ue.pendingFollowUps,editingFollowUpId:ue.editingFollowUpId,beginEditFollowUp:ue.beginEditFollowUp,cancelEditFollowUp:ue.cancelEditFollowUp,commitEditFollowUp:ue.commitEditFollowUp,removePendingFollowUp:ue.removePendingFollowUp,movePendingFollowUp:ue.movePendingFollowUp,reorderPendingFollowUp:ue.reorderPendingFollowUp,steerPendingFollowUp:ue.steerPendingFollowUp,steeringFollowUpId:ue.steeringFollowUpId},clarify:{clarifyPrompt:ue.clarifyPrompt,clarifySubmitting:ue.clarifySubmitting,clarifySubmitError:ue.clarifySubmitError,submitClarifyAnswer:ue.submitClarifyAnswer,letAgentDecideClarification:ue.letAgentDecideClarification,cancelClarification:ue.cancelClarification},agents:{chatAgents:G,displayAgentId:Fe?.agentId??ne,showChatAgentSelector:re,onChatAgentChange:te}}}function Qk(e){let t=(0,X.c)(11),n=m($k),r;t[0]===e?r=t[1]:(r=e?.trim()||null,t[0]=e,t[1]=r);let i=r,a;t[2]===i?a=t[3]:(a=e=>i?e.sessions[i]?.localDraft:void 0,t[2]=i,t[3]=a);let o=Nn(a),s;t[4]!==o||t[5]!==n||t[6]!==i?(s=n&&i&&!o?[`chat-session-meta`,i,n,o===!1?`persisted`:`unknown`]:null,t[4]=o,t[5]=n,t[6]=i,t[7]=s):s=t[7];let c;t[8]===i?c=t[9]:(c=async()=>{if(await Tr(i))return;let e=await fn(i),t=typeof e.sessionType==`string`&&e.sessionType.trim()?e.sessionType.trim():null,n=typeof e.routing?.agentId==`string`&&e.routing.agentId.trim()?e.routing.agentId.trim():null,r=e.customData?.sourceBinding,a=r&&typeof r==`object`?r:null,o=a?.kind===`note`&&typeof a.sourceId==`string`&&a.sourceId.trim()?a.sourceId.trim():null,s=typeof e.parentConversationId==`string`&&e.parentConversationId.trim()?e.parentConversationId.trim():null,c=e.customData?.forkedFromSessionName;return{identity:{sourceChannel:e.sourceChannel,sessionType:e.sessionType,customData:e.customData},ownerAgentId:n,sessionType:t,sourceNoteId:o,sourceNoteTitle:null,parentConversationId:s,forkedFromSessionName:typeof c==`string`&&c.trim()?c.trim():null}},t[8]=i,t[9]=c);let l;return t[10]===Symbol.for(`react.memo_cache_sentinel`)?(l={revalidateOnFocus:!1},t[10]=l):l=t[10],Kr(s,c,l)}function $k(e){return e.conversationId}function eA(e,t){if(!e)return``;let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,Math.max(0,t-3)).trimEnd()}...`}function tA(e,t){return eA(zn(e??``),t)}function nA(e,t){return fa(e,t)}function rA(e){return e===`context`||e===`branch`||e===`compaction`?e:null}function iA(e){return eA(e.preview||e.title,72)||e.kind}function aA(e,t){let n=[],r=null,i=0;for(let a of e){if(a.displayIndex!==void 0&&(i=a.displayIndex),a.kind===`turn`&&a.role===`user`){let e=a.turn||n.length+1;r={id:a.id,messageIndex:a.displayIndex??i,ordinal:e,title:t.turn.replace(`{{count}}`,String(e)),preview:tA(a.preview||a.title,88)||t.messageFallback,...a.timestamp===void 0?{}:{timestamp:a.timestamp},tools:[],events:[]},n.push(r);continue}if(!r)continue;if(a.kind===`tool`||a.kind===`file`||a.kind===`command`){let e=a.meta?.toolName||a.title||a.kind,n=a.kind===`file`||a.kind===`command`?a.title:nA(e,t),i=`${a.id}:${e}`;r.tools.some(e=>e.key===i)||r.tools.push({key:i,label:n,running:a.status===`running`});continue}let e=rA(a.kind);if(!e)continue;let o=`${a.id}:${a.kind}`;r.events.some(e=>e.key===o)||r.events.push({key:o,label:iA(a),tone:e})}return n}function oA(e,t){return(e===1?t.toolCount_one:t.toolCount_other).replace(`{{count}}`,String(e))}function sA(e,t){let n=e[0]?.id;for(let r of e)r.messageIndex<=t&&(n=r.id);return n}function cA(e){let t=(0,X.c)(53),{turn:n,active:r,labels:i,currentLabel:a,onSelect:o}=e,s,c,l,u,d,f,p,m;if(t[0]!==r||t[1]!==a||t[2]!==i||t[3]!==o||t[4]!==n.events||t[5]!==n.preview||t[6]!==n.timestamp||t[7]!==n.title||t[8]!==n.tools){let e=n.tools.slice(0,2),h=n.events.slice(0,Math.max(0,3-e.length)),g=Math.max(0,n.tools.length-e.length)+Math.max(0,n.events.length-h.length);d=`button`;let _=r&&`bg-accent-soft/70`;t[17]===_?f=t[18]:(f=Y(`flex w-full min-w-0 items-start gap-3 border-b border-edge-subtle px-4 py-3 text-left transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,_),t[17]=_,t[18]=f),p=o;let v=r&&`border-accent bg-accent`,y;t[19]===v?y=t[20]:(y=Y(`mt-1 size-2.5 shrink-0 rounded-full border border-edge-strong bg-surface-panel`,v),t[19]=v,t[20]=y),t[21]===y?m=t[22]:(m=(0,Z.jsx)(`span`,{className:y,"aria-hidden":!0}),t[21]=y,t[22]=m),s=`min-w-0 flex-1`;let b;t[23]===n.preview?b=t[24]:(b=(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:n.preview}),t[23]=n.preview,t[24]=b);let x;t[25]!==r||t[26]!==a?(x=r?(0,Z.jsx)(`span`,{className:`shrink-0 rounded-full bg-accent px-1.5 py-0.5 text-[10px] font-medium text-on-accent`,children:a}):null,t[25]=r,t[26]=a,t[27]=x):x=t[27],t[28]!==b||t[29]!==x?(c=(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[b,x]}),t[28]=b,t[29]=x,t[30]=c):c=t[30];let S;t[31]===n.title?S=t[32]:(S=(0,Z.jsx)(`span`,{children:n.title}),t[31]=n.title,t[32]=S);let C;t[33]===n.timestamp?C=t[34]:(C=n.timestamp?(0,Z.jsx)(`time`,{suppressHydrationWarning:!0,dateTime:new Date(n.timestamp).toISOString(),children:sy(n.timestamp)}):null,t[33]=n.timestamp,t[34]=C);let w;t[35]!==i||t[36]!==n.tools.length?(w=n.tools.length>0?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Z.jsx)(Kt,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),oA(n.tools.length,i)]}):null,t[35]=i,t[36]=n.tools.length,t[37]=w):w=t[37],t[38]!==S||t[39]!==C||t[40]!==w?(l=(0,Z.jsxs)(`span`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[S,C,w]}),t[38]=S,t[39]=C,t[40]=w,t[41]=l):l=t[41],u=e.length>0||n.events.length>0?(0,Z.jsxs)(`span`,{className:`mt-2 flex min-w-0 flex-wrap gap-1.5`,children:[e.map(uA),h.map(lA),g>0?(0,Z.jsxs)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:[`+`,g]}):null]}):null,t[0]=r,t[1]=a,t[2]=i,t[3]=o,t[4]=n.events,t[5]=n.preview,t[6]=n.timestamp,t[7]=n.title,t[8]=n.tools,t[9]=s,t[10]=c,t[11]=l,t[12]=u,t[13]=d,t[14]=f,t[15]=p,t[16]=m}else s=t[9],c=t[10],l=t[11],u=t[12],d=t[13],f=t[14],p=t[15],m=t[16];let h;t[42]!==s||t[43]!==c||t[44]!==l||t[45]!==u?(h=(0,Z.jsxs)(`span`,{className:s,children:[c,l,u]}),t[42]=s,t[43]=c,t[44]=l,t[45]=u,t[46]=h):h=t[46];let g;return t[47]!==d||t[48]!==f||t[49]!==p||t[50]!==m||t[51]!==h?(g=(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`button`,{type:d,className:f,onClick:p,children:[m,h]})}),t[47]=d,t[48]=f,t[49]=p,t[50]=m,t[51]=h,t[52]=g):g=t[52],g}function lA(e){return(0,Z.jsxs)(`span`,{className:`inline-flex max-w-[10rem] items-center gap-1 rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:[(0,Z.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current opacity-70`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.label})]},e.key)}function uA(e){return(0,Z.jsxs)(`span`,{className:Y(`inline-flex max-w-[9rem] items-center gap-1 rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,e.running&&`text-accent-fg`),children:[(0,Z.jsx)(Kt,{className:`size-3 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.label})]},e.key)}function dA(e){let t=(0,X.c)(39),{items:n,activeMessageIndex:r,labels:i,openLabel:a,closeLabel:o,currentLabel:s,onSelectMessage:c}=e,l;t[0]!==n||t[1]!==i?(l=aA(n,i),t[0]=n,t[1]=i,t[2]=l):l=t[2];let u=l,[d,f]=(0,Q.useState)(!1);if(u.length<4)return null;let p;t[3]!==r||t[4]!==u?(p=sA(u,r),t[3]=r,t[4]=u,t[5]=p):p=t[5];let m=p,h;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(Ie,{className:`size-[1.125rem]`,strokeWidth:1.8,"aria-hidden":!0}),t[6]=h):h=t[6];let g;t[7]===a?g=t[8]:(g=(0,Z.jsx)(x,{asChild:!0,children:(0,Z.jsx)(mi,{type:`button`,variant:`ghost`,className:`size-10 shrink-0 rounded-full p-0 sm:size-9 xl:hidden`,"aria-label":a,title:a,children:h})}),t[7]=a,t[8]=g);let _;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Z.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim/60 backdrop-blur-[1px] xl:hidden`}),t[9]=_):_=t[9];let v;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(v=Y(`xopc-dialog-content-pane fixed inset-x-2 bottom-[max(.5rem,env(safe-area-inset-bottom))] z-[90] flex h-[min(72dvh,34rem)] flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-popover outline-none`,`sm:left-auto sm:right-3 sm:w-[min(24rem,calc(100vw-1.5rem))]`,`md:bottom-[max(1rem,env(safe-area-inset-bottom))] md:right-4 md:h-[min(calc(100dvh-6rem),40rem)]`,`xl:hidden`),t[10]=v):v=t[10];let y;t[11]===i.title?y=t[12]:(y=(0,Z.jsx)(E,{className:`min-w-0 truncate text-base font-semibold text-fg`,children:i.title}),t[11]=i.title,t[12]=y);let S;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(qt,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=S):S=t[13];let O;t[14]===o?O=t[15]:(O=(0,Z.jsx)(C,{asChild:!0,children:(0,Z.jsx)(mi,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":o,children:S})}),t[14]=o,t[15]=O);let k;t[16]!==y||t[17]!==O?(k=(0,Z.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-between gap-3 border-b border-edge-subtle px-3.5 py-3`,children:[y,O]}),t[16]=y,t[17]=O,t[18]=k):k=t[18];let A;if(t[19]!==m||t[20]!==s||t[21]!==i||t[22]!==c||t[23]!==u){let e;t[25]!==m||t[26]!==s||t[27]!==i||t[28]!==c?(e=e=>(0,Z.jsx)(cA,{turn:e,active:e.id===m,labels:i,currentLabel:s,onSelect:()=>{c(e.messageIndex),f(!1)}},e.id),t[25]=m,t[26]=s,t[27]=i,t[28]=c,t[29]=e):e=t[29],A=u.map(e),t[19]=m,t[20]=s,t[21]=i,t[22]=c,t[23]=u,t[24]=A}else A=t[24];let j;t[30]===A?j=t[31]:(j=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,Z.jsx)(`ol`,{className:`min-w-0`,children:A})}),t[30]=A,t[31]=j);let M;t[32]!==k||t[33]!==j?(M=(0,Z.jsxs)(w,{children:[_,(0,Z.jsxs)(T,{className:v,"aria-describedby":void 0,children:[k,j]})]}),t[32]=k,t[33]=j,t[34]=M):M=t[34];let N;return t[35]!==d||t[36]!==M||t[37]!==g?(N=(0,Z.jsxs)(D,{open:d,onOpenChange:f,children:[g,M]}),t[35]=d,t[36]=M,t[37]=g,t[38]=N):N=t[38],N}function fA(e){let{active:t,scrubbing:n,distance:r}=e;return n?r===0?`w-7 bg-fg`:r===1?`w-5 bg-fg-muted`:r===2?`w-4 bg-edge-strong/70`:t?`w-3.5 bg-accent`:`w-2.5 bg-edge-strong/45`:t?`w-3.5 bg-accent`:`w-2.5 bg-edge-strong/45`}function pA(e){let t=(0,X.c)(40),{turn:n,labels:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n.events||t[2]!==n.preview||t[3]!==n.timestamp||t[4]!==n.title||t[5]!==n.tools){let e=n.tools.slice(0,3),p=Math.max(0,n.tools.length-e.length),m=n.events.slice(0,Math.max(0,3-e.length));i=p+Math.max(0,n.events.length-m.length);let h=n.tools.length>0||n.events.length>0?[...e.map(_A),...m.map(gA),...i>0?[`+${i}`]:[]].join(` · `):n.title;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(l=Y(`pointer-events-auto absolute right-12 top-1/2 z-[100] w-[min(25rem,calc(100vw-8rem))] -translate-y-1/2`,`rounded-2xl border border-edge bg-surface-overlay p-3 text-left shadow-popover backdrop-blur`),t[15]=l):l=t[15],t[16]===n.timestamp?u=t[17]:(u=n.timestamp?(0,Z.jsx)(`div`,{className:`mb-1 flex min-w-0 justify-end text-xs`,children:(0,Z.jsx)(`time`,{suppressHydrationWarning:!0,className:`shrink-0 tabular-nums text-fg-disabled`,dateTime:new Date(n.timestamp).toISOString(),children:sy(n.timestamp)})}):null,t[16]=n.timestamp,t[17]=u),t[18]===n.preview?d=t[19]:(d=(0,Z.jsx)(`div`,{className:`min-w-0 text-sm font-semibold leading-5 text-fg`,children:(0,Z.jsx)(`span`,{className:`line-clamp-1`,children:n.preview})}),t[18]=n.preview,t[19]=d),t[20]===h?f=t[21]:(f=(0,Z.jsx)(`div`,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:h}),t[20]=h,t[21]=f),a=`mt-3 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 text-sm text-fg-subtle`,t[22]!==r||t[23]!==n.title||t[24]!==n.tools.length?(o=n.tools.length>0?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Z.jsx)(Kt,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:oA(n.tools.length,r)})]}):(0,Z.jsx)(`span`,{children:n.title}),t[22]=r,t[23]=n.title,t[24]=n.tools.length,t[25]=o):o=t[25],s=e.map(hA),c=m.map(mA),t[0]=r,t[1]=n.events,t[2]=n.preview,t[3]=n.timestamp,t[4]=n.title,t[5]=n.tools,t[6]=i,t[7]=a,t[8]=o,t[9]=s,t[10]=c,t[11]=l,t[12]=u,t[13]=d,t[14]=f}else i=t[6],a=t[7],o=t[8],s=t[9],c=t[10],l=t[11],u=t[12],d=t[13],f=t[14];let p;t[26]===i?p=t[27]:(p=i>0?(0,Z.jsxs)(`span`,{children:[`+`,i]}):null,t[26]=i,t[27]=p);let m;t[28]!==a||t[29]!==o||t[30]!==s||t[31]!==c||t[32]!==p?(m=(0,Z.jsxs)(`div`,{className:a,children:[o,s,c,p]}),t[28]=a,t[29]=o,t[30]=s,t[31]=c,t[32]=p,t[33]=m):m=t[33];let h;return t[34]!==m||t[35]!==l||t[36]!==u||t[37]!==d||t[38]!==f?(h=(0,Z.jsxs)(`div`,{className:l,children:[u,d,f,m]}),t[34]=m,t[35]=l,t[36]=u,t[37]=d,t[38]=f,t[39]=h):h=t[39],h}function mA(e){return(0,Z.jsxs)(`span`,{className:Y(`inline-flex min-w-0 max-w-[10rem] items-center gap-1.5`,e.tone===`branch`&&`text-accent`,e.tone===`compaction`&&`text-fg-muted`),children:[(0,Z.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current opacity-70`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.label})]},e.key)}function hA(e){return(0,Z.jsxs)(`span`,{className:Y(`inline-flex min-w-0 max-w-[9rem] items-center gap-1.5`,e.running&&`text-accent`),children:[(0,Z.jsx)(Kt,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.label})]},e.key)}function gA(e){return e.label}function _A(e){return e.label}function vA(e){let t=(0,X.c)(44),{items:n,activeMessageIndex:r,labels:i,onSelectMessage:a}=e,o;t[0]!==n||t[1]!==i?(o=aA(n,i),t[0]=n,t[1]=i,t[2]=o):o=t[2];let s=o,[c,l]=(0,Q.useState)(null),u=(0,Q.useRef)(null),d,f;if(t[3]===c?(d=t[4],f=t[5]):(d=()=>{if(!c)return;let e=()=>{l(null)},t=t=>{let n=t.target;n instanceof Node&&(u.current?.contains(n)||e())},n=t=>{t.key===`Escape`&&e()};return document.addEventListener(`pointerdown`,t,!0),document.addEventListener(`keydown`,n),()=>{document.removeEventListener(`pointerdown`,t,!0),document.removeEventListener(`keydown`,n)}},f=[c],t[3]=c,t[4]=d,t[5]=f),(0,Q.useEffect)(d,f),s.length<4)return null;let p;if(t[6]!==r||t[7]!==s){p=s[0]?.id;for(let e of s)e.messageIndex<=r&&(p=e.id);t[6]=r,t[7]=s,t[8]=p}else p=t[8];let m=c??p,h;t[9]!==c||t[10]!==s?(h=c?s.find(e=>e.id===c):null,t[9]=c,t[10]=s,t[11]=h):h=t[11];let g=h,_=c!==null,v;if(t[12]!==m||t[13]!==s){let e;t[15]===m?e=t[16]:(e=e=>e.id===m,t[15]=m,t[16]=e),v=s.findIndex(e),t[12]=m,t[13]=s,t[14]=v}else v=t[14];let y=Math.max(0,v),b=i.title,x,S;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{l(null)},S=e=>{let t=e.relatedTarget;(!(t instanceof Node)||!e.currentTarget.contains(t))&&l(null)},t[17]=x,t[18]=S):(x=t[17],S=t[18]);let C;t[19]===p?C=t[20]:(C=()=>l(e=>e??p??null),t[19]=p,t[20]=C);let w;if(t[21]!==a||t[22]!==_||t[23]!==m||t[24]!==y||t[25]!==s){let e;t[27]!==a||t[28]!==_||t[29]!==m||t[30]!==y?(e=(e,t)=>{let n=e.id===m,r=Math.abs(t-y);return(0,Z.jsx)(`li`,{className:`group relative flex h-3.5 w-full shrink-0 items-center justify-end`,onMouseEnter:()=>l(e.id),onFocus:()=>l(e.id),children:(0,Z.jsx)(`button`,{type:`button`,className:Y(`flex h-3.5 w-full items-center justify-end rounded-sm pr-1.5`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),onClick:()=>a(e.messageIndex),"aria-label":`${e.title}: ${e.preview}`,children:(0,Z.jsx)(`span`,{className:Y(`block h-0.5 rounded-full transition-[width,background-color] duration-150 ease-out`,fA({active:n,scrubbing:_,distance:r}),`group-hover:bg-fg`),"aria-hidden":!0})})},e.id)},t[27]=a,t[28]=_,t[29]=m,t[30]=y,t[31]=e):e=t[31],w=s.map(e),t[21]=a,t[22]=_,t[23]=m,t[24]=y,t[25]=s,t[26]=w}else w=t[26];let T;t[32]!==w||t[33]!==C?(T=(0,Z.jsx)(`div`,{className:`chat-timeline-scroll flex min-h-0 w-full flex-col`,children:(0,Z.jsx)(`ol`,{className:`my-auto flex w-full shrink-0 flex-col items-end py-1`,onMouseEnter:C,children:w})}),t[32]=w,t[33]=C,t[34]=T):T=t[34];let E;t[35]!==i||t[36]!==g?(E=g?(0,Z.jsx)(pA,{turn:g,labels:i}):null,t[35]=i,t[36]=g,t[37]=E):E=t[37];let D;t[38]!==T||t[39]!==E?(D=(0,Z.jsxs)(`div`,{className:`relative z-[90] flex h-full min-h-0 w-full flex-col justify-center overflow-visible`,children:[T,E]}),t[38]=T,t[39]=E,t[40]=D):D=t[40];let O;return t[41]!==i.title||t[42]!==D?(O=(0,Z.jsx)(`aside`,{ref:u,className:`hidden h-full min-h-0 max-h-full w-12 shrink-0 items-center overflow-visible py-4 xl:flex`,"aria-label":b,onMouseLeave:x,onBlur:S,children:D}),t[41]=i.title,t[42]=D,t[43]=O):O=t[43],O}function yA(e){return e.enabled?e.sourceContextPending?`pending:${e.conversationId??``}`:e.task?`task:${e.task.task.id}:${e.task.task.version}`:e.suppressProjectContext?`suppressed:${e.conversationId??``}`:e.project?`project:${e.project.id}:${e.project.name}`:e.conversationId?`session:${e.conversationId}:failed:${e.sourceContextFailed?`1`:`0`}`:`empty`:`disabled`}function bA(e){let t=yA(e);if(!e.enabled)return{key:t,context:{kind:`empty`},status:`ready`};if(e.sourceContextPending)return{key:t,context:{kind:`empty`},status:`loading`};if(e.task){let n=e.task.receipts[0];return{key:t,context:{kind:`task`,taskId:e.task.task.id,taskTitle:e.task.task.title,phase:e.task.task.phase,operationalState:e.task.operationalState,attentionSummary:e.task.attention[0]?.summary,nextAction:n?.nextAction,recentFailure:n?.failure?.recoveryAction},status:`ready`}}return e.suppressProjectContext?{key:t,context:{kind:`empty`},status:e.sourceContextFailed?`degraded`:`ready`}:e.project?{key:t,context:{kind:`project`,projectId:e.project.id,projectName:e.project.name},status:`ready`}:{key:t,context:{kind:`empty`},status:e.conversationId?`loading`:`ready`}}function xA(e){let{enabled:t,conversationId:n,sourceContextPending:r,sourceContextFailed:i,suppressProjectContext:a,project:o,task:s}=e,c=yA(e),[l,u]=(0,Q.useState)(()=>bA(e));(0,Q.useEffect)(()=>{let e=!1,l=bA({enabled:t,conversationId:n,sourceContextPending:r,sourceContextFailed:i,suppressProjectContext:a,project:o,task:s});if(u(l),!(!t||!n||r||s||a))return(async()=>{let t=!!i,r=o?.id??null;if(!r)try{let e=await Tr(n);r=e?e.creation.projectId?.trim()||null:(await fn(n)).projectId?.trim()||null}catch{t=!0}if(!r){e||u({key:c,context:{kind:`empty`},status:t?`degraded`:`ready`});return}try{let[n,i]=await Promise.allSettled([o?Promise.resolve(o):ln(r),un(r)]);if(n.status===`rejected`)throw n.reason;let a=i.status===`fulfilled`?i.value:null;a||(t=!0);let s=a?.blockers[0],l=a?.digest.health===`attention`?a.recentResults.find(({receipt:e})=>e.status===`failed`||e.verification.status===`failed`):void 0;e||u({key:c,context:{kind:`project`,projectId:r,projectName:n.value.name,recommendedAction:a?.digest.recommendedAction,blockedReason:s?.detail??s?.title,recentFailure:l?.receipt.failure?.recoveryAction??l?.receipt.summary},status:t?`degraded`:`ready`})}catch{e||u({key:c,context:{kind:`empty`},status:`degraded`})}})(),()=>{e=!0}},[n,c,t,i,r,a,o,s]);let d=l.key===c?l:bA(e);return{context:d.context,status:d.status}}var SA=[Bt,It,us];function CA(e){let t=(0,X.c)(20),{agentName:n,messages:r,disabled:i,onPick:a}=e,o;t[0]!==r.setupPromptComplete||t[1]!==r.setupPromptIdentity||t[2]!==r.setupPromptProject?(o=[r.setupPromptIdentity,r.setupPromptProject,r.setupPromptComplete],t[0]=r.setupPromptComplete,t[1]=r.setupPromptIdentity,t[2]=r.setupPromptProject,t[3]=o):o=t[3];let s=o,c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-2xl bg-accent-soft text-accent`,children:(0,Z.jsx)(Bt,{className:`size-6`,strokeWidth:1.75,"aria-hidden":!0})}),t[4]=c):c=t[4];let l;t[5]===r.setupTitle?l=t[6]:(l=(0,Z.jsx)(`h1`,{id:`agent-setup-title`,className:`mt-4 text-balance text-xl font-semibold tracking-tight text-fg`,children:r.setupTitle}),t[5]=r.setupTitle,t[6]=l);let u;t[7]!==n||t[8]!==r.setupDescription?(u=r.setupDescription.replace(`{{name}}`,n),t[7]=n,t[8]=r.setupDescription,t[9]=u):u=t[9];let d;t[10]===u?d=t[11]:(d=(0,Z.jsx)(`p`,{className:`mt-2 max-w-xl text-pretty text-sm leading-relaxed text-fg-muted`,children:u}),t[10]=u,t[11]=d);let f;t[12]!==i||t[13]!==a||t[14]!==s?(f=(0,Z.jsx)(`div`,{className:`mt-7 grid w-full gap-3 md:grid-cols-3`,children:s.map((e,t)=>{let n=SA[t]??Bt;return(0,Z.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>a(e),className:Y(`flex min-h-24 items-center gap-3 rounded-xl border border-edge bg-surface-panel px-4 py-4 text-left text-sm font-medium leading-relaxed text-fg`,`hover:border-accent/30 hover:bg-surface-hover`,ua.transition,ua.pressCard,ua.focusRingPanel,ua.disabled),children:[(0,Z.jsx)(n,{className:`size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:e})]},e)})}),t[12]=i,t[13]=a,t[14]=s,t[15]=f):f=t[15];let p;return t[16]!==l||t[17]!==d||t[18]!==f?(p=(0,Z.jsxs)(`section`,{className:`mx-auto flex w-full max-w-4xl flex-col items-center px-2 pb-4 pt-12 text-center sm:pt-16`,"aria-labelledby":`agent-setup-title`,children:[c,l,d,f]}),t[16]=l,t[17]=d,t[18]=f,t[19]=p):p=t[19],p}var wA=t({ChatPage:()=>EA}),TA=(0,Q.lazy)(async()=>({default:(await o(()=>import(`./chat-terminal-dock-D9o0nUEV.js`),__vite__mapDeps([30,1,2,5,6,31,11,32,26,27,17,18,33,34,35,36,37,38,39,40,41,42,43,44,4,45,46,28,29,9,47,48,49,50]))).ChatTerminalDock}));function EA({embedded:e=!1,conversationId:t,taskId:n,personal:r=!1,personalWelcome:i,automationWorkspace:a=!1,automationTimelineEntries:o,readOnly:s=!1,onHistoryReady:f,automationExecution:p=!1,initialTurnId:g,onInitialTurnLocated:_}={}){let v=h(e=>e.language),x=y(v),C=m(e=>e.conversationId),O=d(),k=c(),{pathname:A}=k,[j,M]=l(),N=(0,Q.useRef)(null),P=(0,Q.useRef)(0),F=(0,Q.useRef)(null),[I,L]=(0,Q.useState)(null),[R,z]=(0,Q.useState)(()=>!!(t&&window.localStorage.getItem(`personal-calibration:${t}`))),[B,H]=(0,Q.useState)(null),[U,W]=(0,Q.useState)(null),[G,ee]=(0,Q.useState)(!1),[te,ne]=(0,Q.useState)(null),re=n?.trim()||null,{data:ie}=Ns(re??``),{auth:ae,session:K,messages:oe,timeline:se,stream:q,followUp:ce,clarify:le,agents:ue}=Zk({fixedConversationId:t,taskId:re??void 0,personal:r}),de=ce.composerMode.kind===`editTurn`?ce.composerMode:null,fe=Nn(e=>!!(K.conversationId&&!e.shellError&&e.sessions[K.conversationId]?.historyStatus===`ready`));(0,Q.useEffect)(()=>{fe&&oe.items.length>0&&f?.()},[fe,oe.items.length,f]),(0,Q.useLayoutEffect)(()=>{if(!a&&!p||!K.conversationId)return;let e=K.conversationId;return Gf.setState({conversationIdOverride:e}),()=>{Gf.getState().conversationIdOverride===e&&Gf.setState({conversationIdOverride:null})}},[a,p,K.conversationId]);let J=!r&&!e&&!re&&j.get(`scene`)===`find-skills`,pe=a||j.get(`setup`)===`automation`,me=!e&&!re&&j.get(`agentSetup`)===`1`,he=r?``:j.get(`skill`)?.trim()??``,ge=r?``:j.get(`slash`)?.trim()??``;(0,Q.useEffect)(()=>{if(!r||!j.has(`skill`)&&!j.has(`slash`))return;let e=new URLSearchParams(j);e.delete(`skill`),e.delete(`slash`),M(e,{replace:!0})},[r,j,M]);let _e=j.get(a?`chatDraft`:`draft`)??``,ve=j.get(`autoSend`)===`1`,ye=j.get(`attachmentHandoff`),be=j.get(`attachmentsHandoff`),xe=K.decodedKey??K.conversationId,[Se,Ce]=(0,Q.useState)(null),we=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(ye){let e=je(ye);e&&Ce(e),we.current=xe;return}we.current!==xe&&(we.current=xe,Ce(null))},[ye,xe]);let Te=Of(e=>e.markViewed),De=Of(e=>xe?e.runs[xe]?.unread:!1);(0,Q.useEffect)(()=>{xe&&De&&Te(xe)},[xe,De,Te]);let{data:Oe}=Qk(xe),ke=pe||!!Oe?.identity?.customData?.automationSetup,Ae=!!Oe?.identity?.customData?.automationSetup?.automationId,Me=(0,Q.useCallback)(async e=>{if(xe)try{let t=await K.sessionManager.forkSessionAtTurn(xe,e);window.dispatchEvent(new CustomEvent(`session-created`,{detail:{key:t.conversationId,conversationId:t.conversationId}})),Ne(`success`,x.chat.messageForkCreated),O(`/chat/${encodeURIComponent(t.conversationId)}`)}catch(e){throw Ne(`error`,e instanceof Error?e.message:x.chat.messageForkFailed),e}},[xe,x.chat.messageForkCreated,x.chat.messageForkFailed,O,K.sessionManager]),Pe=oe.items.at(-1),Fe=r&&!R&&!q.streaming&&!q.sending&&Pe?.role===`assistant`&&oe.items.filter(e=>e.role===`user`).length===1&&oe.items.filter(e=>e.role===`assistant`).length===1&&!oe.items.some(e=>e.role===`task`),Ie=e=>{z(!0),t&&window.localStorage.setItem(`personal-calibration:${t}`,`1`),e&&(P.current+=1,L({id:P.current,text:e}))};(0,Q.useEffect)(()=>{N.current=null},[K.conversationId]),(0,Q.useEffect)(()=>{if(!ae.hasToken||!he&&!ge&&!_e&&!(K.projectPreparation&&be)||ve&&!K.projectPreparation||K.showSessionLoading||K.sessionRoutePending||!K.conversationId&&!K.projectPreparation)return;let e=K.projectPreparation&&be?Ni(be)??void 0:void 0,t=()=>{let e=new URLSearchParams(j);e.delete(`skill`),e.delete(`slash`),e.delete(a?`chatDraft`:`draft`),K.projectPreparation&&(e.delete(`autoSend`),e.delete(`attachmentsHandoff`));let t=e.toString();O({pathname:A,search:t?`?${t}`:``},{replace:!0})},n=(n,r)=>{N.current!==r&&(N.current=r,queueMicrotask(()=>{e?.length?Ip(n,e):(P.current+=1,L({id:P.current,text:n})),t()}))},r=Yr(he,_e);if(r||e?.length){let e=`${K.conversationId}:draft:${r}`;n(r??``,e);return}if(he){t();return}if(!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(ge)){t();return}let i=`${K.conversationId}:slash:${ge}`;N.current!==i&&queueMicrotask(()=>{(async()=>{try{let e=await ho(),t=ge.toLowerCase(),n=e.find(e=>e.name.toLowerCase()===t||Array.isArray(e.aliases)&&e.aliases.some(e=>e.toLowerCase()===t));if(n){if(N.current===i)return;N.current=i,P.current+=1,L({id:P.current,text:vw(n)})}}finally{t()}})()})},[ae.hasToken,a,he,ge,_e,ve,be,K.projectPreparation,j,K.showSessionLoading,K.sessionRoutePending,K.conversationId,O,A]);let{scrollRef:Le,composerDockRef:Re,atBottom:ze,registerListContentRef:Ve,scrollToBottom:Ge,replySpaceRef:Ke,reserveReplySpace:qe,onScroll:Je}=rw({hasToken:ae.hasToken,showSessionLoading:K.showSessionLoading,conversationId:K.conversationId,chatMessages:oe.items,streaming:q.streaming,hasMore:K.hasMore,loadingMore:K.loadingMore,loadMoreMessages:K.loadMoreMessages});(0,Q.useEffect)(()=>{if(!a||!ze||!o?.length)return;let e=requestAnimationFrame(()=>Ge(!1));return()=>cancelAnimationFrame(e)},[a,o,ze,Ge]);let Ye=SO({enabled:r,conversationId:K.conversationId,messages:oe.items,viewportRef:Le}),[Xe,Ze]=(0,Q.useState)(0),Qe=(0,Q.useRef)(null),$e=(0,Q.useRef)(null),et=(0,Q.useMemo)(()=>{let e=-1;for(let t of se.items)typeof t.displayIndex==`number`&&Number.isFinite(t.displayIndex)&&(e=Math.max(e,t.displayIndex));return e<0?0:Math.max(0,e+1-oe.items.length)},[oe.items.length,se.items]),tt=(0,Q.useCallback)(e=>{let t=Le.current;if(!t)return!1;let n=t.querySelector(`[data-chat-message-index="${e}"]`);if(!n){let n=BC(t)?.reveal(e)??!1;return n&&Ze(e),n}VC(t),Ze(e);let r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=t.scrollTop+i.top-r.top-16;return t.scrollTo({top:Math.max(0,a),behavior:LC()}),!0},[Le]),nt=(0,Q.useCallback)(()=>{let e=Le.current;if(!e)return;let t=IC(e);Ze(e=>e===t?e:t)},[Le]),it=(0,Q.useCallback)(()=>{Qe.current??=requestAnimationFrame(()=>{Qe.current=null,nt()})},[nt]),at=(0,Q.useCallback)(()=>{Je(),it()},[Je,it]),ot=(0,Q.useCallback)(e=>{let t=e-et;if(t<0||t>=oe.items.length){t<0&&K.hasMore&&!K.loadingMore&&($e.current=e,K.loadMoreMessages());return}$e.current=null,tt(t)},[oe.items.length,tt,K.hasMore,K.loadMoreMessages,K.loadingMore,et]);jw({conversationId:K.conversationId,turnId:g,messages:oe.items,ready:fe,hasMore:K.hasMore,loadingMore:K.loadingMore,loadMore:K.loadMoreMessages,reveal:tt,onLocated:_});let st=BO({conversationId:K.conversationId,taskId:re,messages:oe.items,displayOffset:et,viewportRef:Le,onRevealDisplayIndex:ot});(0,Q.useEffect)(()=>{let e=$e.current;if(e==null)return;let t=e-et;if(t>=0&&t<oe.items.length){$e.current=null,requestAnimationFrame(()=>tt(t));return}if(t<0&&K.hasMore&&!K.loadingMore){K.loadMoreMessages();return}(t>=oe.items.length||!K.hasMore)&&($e.current=null)},[oe.items.length,tt,K.hasMore,K.loadMoreMessages,K.loadingMore,et]),(0,Q.useEffect)(()=>{it()},[oe.items.length,it,K.conversationId,et]),(0,Q.useEffect)(()=>()=>{Qe.current!=null&&cancelAnimationFrame(Qe.current)},[]),(0,Q.useEffect)(()=>{L(null)},[K.conversationId]);let ct=(0,Q.useCallback)(e=>{P.current+=1,L({id:P.current,text:e.prompt})},[]),lt=!!(K.conversationId&&!K.showSessionLoading&&!K.sessionRoutePending&&K.workspaceSource!==`project`&&K.workspaceSource!==`execution_environment`&&oe.items.length===0),ut=no(e=>e.setAgentId);(0,Q.useEffect)(()=>{if(ae.hasToken)return ut(ue.displayAgentId),()=>ut(``)},[ae.hasToken,ue.displayAgentId,ut]);let dt=K.conversationPhase===`creating-session`,ft=K.conversationPhase===`loading-history`;xf(r&&!ft?xe:null,r);let pt=dt||ft,mt=ft,ht=!mt&&oe.items.length===0&&!o?.length&&!q.streaming,gt=(0,Q.useMemo)(()=>{if(q.taskPlan){let e=oO(q.taskPlan);return e?{plan:e,changeSummary:yO(oe.items,q.streaming)?.changeSummary??null}:null}return yO(oe.items,q.streaming)},[oe.items,q.streaming,q.taskPlan]),_t=(0,Q.useMemo)(()=>(K.sessionRoutePending&&K.decodedKey?K.decodedKey:K.conversationId)?K.sessionName?.trim()||x.chat.newSession:x.nav.chat,[K.conversationId,K.sessionName,K.sessionRoutePending,K.decodedKey,x.nav.chat,x.chat.newSession]),vt=Oe?.sourceNoteId??null,yt=rD(xe,j.get(`projectId`)),bt=K.projectPreparation?.project??yt,[xt,St]=(0,Q.useState)([]),[Ct,wt]=(0,Q.useState)([]),Tt=m(e=>e.baseUrl),Et=xe?Xo(Tt,C,xe):null,Dt=Yo.store(e=>Et?e.drafts[Et]:void 0),Ot=(0,Q.useRef)(void 0),[kt,At]=(0,Q.useState)(!1);(0,Q.useLayoutEffect)(()=>{if(Ot.current!==void 0){xe&&xe!==Ot.current&&(Ot.current=void 0);return}St([]),wt([])},[xe]),(0,Q.useEffect)(()=>{let e=!1;if(H(null),vt)return Be(vt).then(t=>{e||H(t?.title?.trim()||null)}).catch(()=>{e||H(null)}),()=>{e=!0}},[vt]);let jt=B||Oe?.sourceNoteTitle||x.chat.sourceNoteFallbackTitle,Mt=xA({enabled:ae.hasToken&&!!(xe||bt)&&!me&&oe.items.length===0&&!K.showSessionLoading&&!K.sessionRoutePending,conversationId:xe,suppressProjectContext:!!(vt||Se||K.workspaceSource===`execution_environment`||K.workspaceSource===`session_override`||K.workspaceSource===`agent_workspace`),project:bt,task:ie}),Nt=(0,Q.useMemo)(()=>ue.chatAgents?.items.find(e=>e.id===ue.displayAgentId)??{id:ue.displayAgentId},[ue.chatAgents?.items,ue.displayAgentId]),Pt=(0,Q.useMemo)(()=>ws(Mt.context,x.chat.welcomeSpotlight,{contextStatus:Mt.status}),[x.chat.welcomeSpotlight,Mt.context,Mt.status]),Ft=(0,Q.useMemo)(()=>Pt.recommendation?{suggestionId:Pt.recommendation.id,contextKind:Pt.contextKind,prompt:Pt.recommendation.prompt}:null,[Pt]),It=(0,Q.useCallback)((...e)=>{let[t,n,r,i,a]=e;if(Dt&&(de||t.trim().startsWith(`/`)))return Nn.getState().setShellError(x.chat.pageContext.pending),!1;if(de)return q.replaceLatestUserTurn(de.turnId,t,n,r,i);let o=!1,s=q.sendMessage(t,n,r,i,void 0,Dt?.envelope,(e,t)=>{o=!0,qe(t??e),a?.onDispatched?.({clientSubmissionId:e,messageRenderKey:t})});return o?(Et&&Dt&&Yo.remove(Et,Dt),!0):s},[de,q.replaceLatestUserTurn,q.sendMessage,Dt,Et,x.chat.pageContext.pending,qe]),Lt=nD({preparation:K.projectPreparation,conversationId:xe,ready:K.modelConfigReady&&!pt,onSend:It}),Rt=(0,Q.useCallback)(e=>{if(!e.turnId||!K.conversationId)return;let t=xn.getGeneration(K.conversationId),n=xn.getResumeRunId(K.conversationId);ce.beginEditTurn(e.turnId,{text:e.userTurnDocument?Wn(e.userTurnDocument):Rn(e.content),attachments:Ln(e.attachments)??[],contextRefs:e.contextRefs?.flatMap(e=>e.kind===`mcp_resource`?[]:[{refId:e.refId,kind:e.kind,sourceId:e.sourceId,expectedVersion:e.version,title:e.title,fileKind:e.fileKind}])??[]}).then(e=>{e&&q.settleStoppedRun(t,n)})},[ce.beginEditTurn,q.settleStoppedRun,K.conversationId]),zt=(0,Q.useCallback)(e=>{if(ce.composerMode.kind===`editFollowUp`)ce.beginEditFollowUp(ce.composerMode.inputId);else if(ce.composerMode.kind===`editTurn`&&K.conversationId){let t=xn.getGeneration(K.conversationId),n=xn.getResumeRunId(K.conversationId);ce.beginEditTurn(ce.composerMode.turnId,e).then(e=>{e&&q.settleStoppedRun(t,n)})}},[ce.composerMode,ce.beginEditFollowUp,ce.beginEditTurn,K.conversationId,q.settleStoppedRun]),Bt=ce.cancelEditor;(0,Q.useEffect)(()=>{if(!ve||!_e.trim()&&!be||!ae.hasToken||K.showSessionLoading||K.sessionRoutePending||!K.conversationId||q.sending||q.streaming)return;let e=Yr(he,_e),t=be?Ni(be):void 0;if(!e&&!t?.length)return;let n=`${K.conversationId}:auto-send:${e??``}:${be??``}`;if(N.current===n)return;N.current=n;let r=new URLSearchParams(j);r.delete(`skill`),r.delete(`slash`),r.delete(`draft`),r.delete(`autoSend`),r.delete(`attachmentsHandoff`);let i=r.toString();O({pathname:A,search:i?`?${i}`:``},{replace:!0}),It(e??``,t??void 0)},[ae.hasToken,ve,be,_e,It,O,A,j,K.conversationId,K.sessionRoutePending,K.showSessionLoading,he,q.sending,q.streaming]);let Vt=(0,Q.useCallback)(()=>{F.current?.reject(),F.current=null,W(null),ee(!1)},[]);(0,Q.useEffect)(()=>{Vt()},[Vt,vt]);let Ht=(0,Q.useMemo)(()=>({title:x.chat.timelineTitle,turn:x.chat.timelineTurn,messageFallback:x.chat.timelineMessageFallback,toolCount_one:x.chat.timelineToolCount_one,toolCount_other:x.chat.timelineToolCount_other,searchedWeb:x.chat.stepSearchedWeb,searchedMemory:x.chat.stepSearchedMemory,searchedCode:x.chat.stepSearchedCode,searched:x.chat.stepSearched,readFile:x.chat.stepReadFile,runCommand:x.chat.stepRunCommand,listDirectory:x.chat.stepListDirectory,writeFile:x.chat.stepWriteFile,editFile:x.chat.stepEditFile,openUrl:x.chat.stepOpenUrl,fetchUrl:x.chat.stepFetchUrl,unknownTool:x.chat.stepUnknownTool}),[x.chat.timelineTitle,x.chat.timelineTurn,x.chat.timelineMessageFallback,x.chat.timelineToolCount_one,x.chat.timelineToolCount_other,x.chat.stepSearchedWeb,x.chat.stepSearchedMemory,x.chat.stepSearchedCode,x.chat.stepSearched,x.chat.stepReadFile,x.chat.stepRunCommand,x.chat.stepListDirectory,x.chat.stepWriteFile,x.chat.stepEditFile,x.chat.stepOpenUrl,x.chat.stepFetchUrl,x.chat.stepUnknownTool]),Ut=(0,Q.useCallback)(async e=>{if(!vt)return;F.current?.reject(),ee(!1);let t=x.chat.sourceNoteAppendSourceLine.replace(`{{time}}`,new Date().toLocaleString(v));return W({heading:x.chat.sourceNoteAppendHeading,content:`${t}\n\n${e.trim()}`}),new Promise((e,t)=>{F.current={sourceNoteId:vt,resolve:e,reject:t}})},[v,x.chat.sourceNoteAppendHeading,x.chat.sourceNoteAppendSourceLine,vt]),Wt=`${k.pathname}${k.search}`,Gt=(0,Q.useCallback)(async e=>{try{let t=await We(e.trim(),`web`);Ne(`success`,x.chat.messageSavedToNote,void 0,{href:rt(Wt,t.id)})}catch(e){throw Ne(`error`,e instanceof Error?e.message:x.notes.quickCaptureFailed),e}},[Wt,x.chat.messageSavedToNote,x.notes.quickCaptureFailed]),Kt=(0,Q.useCallback)(async()=>{let e=F.current;if(!e||!U)return;let t=U.heading.trim()||x.chat.sourceNoteAppendHeading,n=U.content.trim();if(n){ee(!0),ne(null);try{await Ue(e.sourceNoteId,n,t),window.dispatchEvent(new CustomEvent(`note-updated`,{detail:{noteId:e.sourceNoteId,source:`chat`,conversationId:xe}})),e.resolve(),F.current=null,W(null)}catch(e){ne(e instanceof Error?e.message:x.chat.sourceNoteSaveFailed)}finally{ee(!1)}}},[xe,x.chat.sourceNoteAppendHeading,x.chat.sourceNoteSaveFailed,x.chat.sourceNoteSaveSuccess,U]),qt=(0,Q.useCallback)(async e=>{if(!vt)return;let t=e.trim().split(/\n+/)[0]?.replace(/^[-#*>\s]+/,``).trim()||x.chat.sourceNoteTaskFallbackTitle;try{await He(t.slice(0,120),{sourceNoteId:vt,sourceConversationId:xe})}catch(e){throw Ne(`error`,e instanceof Error?e.message:x.chat.sourceNoteTaskFailed),e}},[xe,x.chat.sourceNoteTaskFailed,x.chat.sourceNoteTaskFallbackTitle,x.chat.sourceNoteTaskSuccess,vt]),Jt=(0,Q.useCallback)(()=>{if(!vt)return;let e=x.chat.sourceNoteDigestPrompt.replace(`{{title}}`,jt);if(q.streaming||q.sending){ce.addPendingFollowUp(e),ga({tone:`info`,status:`done`,title:x.chat.sourceNoteDigestQueued,source:v===`zh`?`笔记整理`:`Note digest`,dedupeKey:vt?`note-digest:${vt}`:void 0});return}q.sendMessage(e)},[ce,v,x.chat.sourceNoteDigestPrompt,x.chat.sourceNoteDigestQueued,vt,jt,q]),Xt=(0,Q.useCallback)(async e=>{if(!(kt||Lt.busy)){if(K.projectPreparation){Ot.current=null,O(Zr(e),{state:{forceNewChat:!0,agentId:ue.displayAgentId,temporary:K.userContextMode===`temporary`}});return}if(!(Ot.current!==void 0||q.sending||q.streaming||pt)){Ot.current=xe,At(!0);try{e?O(Zr(e),{state:{forceNewChat:!0,agentId:ue.displayAgentId,temporary:K.userContextMode===`temporary`}}):await K.createNewSession({forceNew:!0,projectId:e,temporary:K.userContextMode===`temporary`})}catch(e){Ot.current=void 0,Ne(`error`,x.chat.composerContext.changeFailed,{error:e instanceof Error?e.message:String(e)})}finally{At(!1)}}}},[xe,pt,x.chat.composerContext.changeFailed,kt,Lt.busy,K.createNewSession,K.projectPreparation,K.userContextMode,q.sending,q.streaming,O,ue.displayAgentId]),Zt=(0,Q.useCallback)(()=>Xt(null),[Xt]),Qt=(0,Q.useCallback)(async e=>{if(!(kt||pt||q.sending||q.streaming||!lt)){At(!0);try{await K.onSessionWorkingDirectoryChange(e)}finally{At(!1)}}},[kt,pt,q.sending,q.streaming,lt,K.onSessionWorkingDirectoryChange]),$t=(0,Q.useMemo)(()=>({project:bt,draftRefs:xt,draftAttachments:Ct,draftPage:Dt?{id:`${Dt.envelope.tabId}:${Dt.envelope.sequence}`,title:Dt.title||(v===`zh`?`当前页面`:`Current page`)}:void 0,onLeaveProject:kt||Lt.busy?void 0:Zt,leaveProjectLabel:x.chat.scopeRemoveProject,onDraftSourceNote:vt?Jt:void 0,draftSourceNoteLabel:x.chat.sourceNoteDigestAction}),[kt,Lt.busy,bt,xt,Ct,Dt,v,Zt,x.chat.scopeRemoveProject,vt,Jt,x.chat.sourceNoteDigestAction]);return ae.hasToken?(q.error?Bn(q.error):null)?.code===`session_not_found`?(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col overflow-hidden bg-surface-panel`,children:[(0,Z.jsx)(JD,{}),(0,Z.jsx)(zD,{chatHeadline:x.chat.sessionNotFoundTitle,chatAgents:ue.chatAgents?.items??[],showChatAgentSelector:!1,chatAgentId:ue.displayAgentId,onChatAgentChange:ue.onChatAgentChange,chatAgentDisabled:!0}),(0,Z.jsx)(`main`,{className:`mx-auto flex w-full max-w-xl flex-1 items-center px-4 py-12 sm:px-6`,children:(0,Z.jsx)(`div`,{className:`w-full`,children:(0,Z.jsx)(eh,{errorText:q.error})})})]}):(0,Z.jsx)(L_,{value:ke,children:(0,Z.jsxs)(`div`,{className:Y(`flex h-full min-h-0 flex-1 flex-col bg-surface-panel`,a?`overflow-clip`:`overflow-hidden`),children:[(0,Z.jsx)(JD,{}),!e||a?(0,Z.jsx)(zD,{inline:a,chatHeadline:J&&oe.items.length===0?x.skills.findTitle:_t,chatAgents:ue.chatAgents?.items??[],showChatAgentSelector:!a&&!me&&ue.showChatAgentSelector,chatAgentId:ue.displayAgentId,onChatAgentChange:ue.onChatAgentChange,chatAgentDisabled:Lt.busy||kt||pt&&!K.projectPreparation,conversationId:K.conversationId,hasMessages:!pt&&oe.items.length>0,workspacePath:K.effectiveWorkspacePath,userContextMode:K.userContextMode,projectId:bt?.id,context:$t,canChangeWorkspace:!1,workspaceDisabled:pt||q.sending||q.streaming,onWorkspaceChange:K.onSessionWorkingDirectoryChange,prepareTerminalSession:K.projectPreparation?Lt.prepareSession:void 0,terminalDisabled:!!(K.projectPreparation&&(Lt.busy||!Lt.allowed||Lt.checking)),showContextControls:!me,onFindOpen:st.show}):null,(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 w-full flex-1 flex-col`,children:[!e&&Oe?.parentConversationId?(0,Z.jsxs)(`div`,{className:`shrink-0 border-b border-edge-subtle bg-surface-panel/80 px-3 py-2 text-xs text-fg-muted sm:px-5 xl:px-6`,children:[(0,Z.jsx)(u,{to:`/chat/${encodeURIComponent(Oe.parentConversationId)}`,className:`font-medium text-accent transition-colors hover:text-accent-fg`,children:x.chat.forkedFromConversation.replace(`{{name}}`,Oe.forkedFromSessionName||x.chat.forkedFromConversationFallback)}),(0,Z.jsx)(`span`,{className:`ms-2`,children:x.chat.forkSharedWorkspaceNotice})]}):null,k.state?.fromAgentEditor&&ue.displayAgentId?(0,Z.jsx)(`div`,{className:`shrink-0 border-b border-edge-subtle bg-surface-panel/80 px-3 py-1.5 sm:px-5 xl:px-6`,children:(0,Z.jsxs)(u,{to:Vo(ue.displayAgentId),className:`inline-flex items-center gap-1 text-xs font-medium text-accent transition-colors hover:text-accent-fg`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`←`}),x.agentsSettings.backToEditor]})}):null,e&&vt?(0,Z.jsx)(`div`,{className:`shrink-0 border-b border-edge-subtle bg-surface-panel/80 px-3 py-1.5 sm:px-5 xl:px-6`,children:(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:x.chat.sourceNoteBanner.replace(`{{title}}`,jt)}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex h-7 items-center gap-1.5 rounded-md border border-edge-subtle px-2 font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,onClick:Jt,children:[(0,Z.jsx)(Ee,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:x.chat.sourceNoteDigestAction})]}),(0,Z.jsx)(u,{to:rt(`${k.pathname}${k.search}`,vt),className:`font-medium text-accent transition-colors hover:text-accent-fg`,children:x.chat.sourceNoteOpen})]})]})}):null,(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(CO,{open:st.open,query:st.query,activeIndex:st.activeIndex,resultCount:st.resultCount,searching:st.searching,truncated:st.truncated,limitedToLoaded:st.limitedToLoaded,inputRef:st.inputRef,labels:x.chat.find,onQueryChange:st.setQuery,onPrevious:st.previous,onNext:st.next,onClose:st.close}),!e||a?(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 left-1/2 z-20 hidden w-full max-w-[calc(var(--max-width-chat-frame)+8rem)] -translate-x-1/2 xl:block`,children:(0,Z.jsx)(`div`,{className:`pointer-events-auto absolute inset-y-0 right-0`,children:(0,Z.jsx)(vA,{items:se.items,activeMessageIndex:Xe+et,labels:Ht,onSelectMessage:ot})})}):null,(0,Z.jsx)(`div`,{ref:Le,"data-chat-scroll-viewport":!0,className:Y(`chat-messages chat-messages--wide-viewport relative min-h-0 flex-1 overflow-y-auto overflow-x-hidden [overflow-anchor:none] [scrollbar-gutter:stable_both-edges]`,ht?`chat-messages--compact-welcome pt-5 pb-2`:`py-4`),onScroll:at,"data-chat-find-open":st.open?``:void 0,children:(0,Z.jsx)(`div`,{className:e&&!r?`px-3`:`px-3 sm:px-5 xl:px-6`,children:(0,Z.jsx)(`div`,{"data-chat-message-frame":!0,className:Y(`mx-auto w-full min-w-0`,(!e||r||a)&&`max-w-[var(--max-width-chat-frame)]`),children:ft?(0,Z.jsxs)(`div`,{className:`flex min-h-[min(40vh,20rem)] w-full flex-col gap-10 py-8`,"aria-busy":`true`,children:[(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(Yt,{className:`h-11 w-[min(70%,22rem)] rounded-2xl`})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(Yt,{className:`h-4 w-24`}),(0,Z.jsx)(Yt,{className:`h-4 w-[min(82%,36rem)]`}),(0,Z.jsx)(Yt,{className:`h-4 w-[min(74%,32rem)]`}),(0,Z.jsx)(Yt,{className:`h-4 w-[min(48%,22rem)]`})]}),(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(Yt,{className:`h-11 w-[min(62%,18rem)] rounded-2xl`})})]}):(0,Z.jsxs)(Z.Fragment,{children:[K.loadingMore?(0,Z.jsx)(`div`,{className:`mb-3 text-center text-xs text-fg-muted`,children:x.chat.loadOlder}):null,q.error?(0,Z.jsx)(`div`,{className:Y(`sticky z-20 shrink-0 bg-transparent pe-2`,ht?`-top-5`:`-top-4`),children:(0,Z.jsx)(eh,{errorText:q.error})}):null,ke&&!a&&xe?(0,Z.jsx)(No,{conversationId:xe,language:v,running:q.streaming||q.sending}):null,ke&&!a&&oe.items.length>0?(0,Z.jsx)(u,{className:`mb-4 inline-block rounded-md px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover`,to:`/automations`,children:v===`zh`?`← 定时任务`:`← Scheduled tasks`}):null,!e&&re?(0,Z.jsx)(`div`,{className:`hidden md:block`,children:(0,Z.jsx)(rc,{taskId:re})}):null,null,null,!e&&xe?(0,Z.jsx)(V,{eventType:`session.transcript.updated`,source:`sessions`,payloadKey:`conversationId`,payloadValue:xe,className:`mb-6`}):null,(0,Z.jsx)(qC,{scrollRef:Le,messages:oe.items,timelineEntries:o,personal:r,authToken:C??void 0,conversationId:K.decodedKey??K.conversationId,projectId:bt?.id,streaming:q.streaming,sending:q.sending,progress:q.progress,reasoningLevel:K.reasoningLevel,showAssistantWorkLog:!0,registerListContentRef:Ve,replySpaceRef:Ke,onPickWelcomePrompt:ct,welcomeSpotlight:Pt,welcomeOverlay:r&&i?(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col items-start gap-3 px-4 py-8 text-fg`,children:[(0,Z.jsx)(`div`,{className:`flex size-16 items-center justify-center rounded-3xl bg-accent/10 text-3xl text-accent`,"aria-hidden":!0,children:i.avatar??`✦`}),(0,Z.jsx)(`h2`,{className:`text-2xl font-semibold`,children:v===`zh`?`你好${i.addressAs?`,${i.addressAs}`:``}。我们从哪里开始?`:`Hello${i.addressAs?`, ${i.addressAs}`:``}. Where should we start?`}),(0,Z.jsx)(`p`,{className:`max-w-xl text-sm leading-relaxed text-fg-muted`,children:i.opening??(v===`zh`?`想讨论问题、整理思路或推进工作,都可以直接说。`:`Bring a question, an idea, or work to move forward.`)})]}):ke?(0,Z.jsxs)(`div`,{className:`mx-auto max-w-xl px-4 py-10 text-center`,children:[(0,Z.jsx)(`h2`,{className:`text-xl font-semibold text-fg`,children:Ae?v===`zh`?`想怎么调整这个任务?`:`What would you like to change?`:v===`zh`?`你想安排什么任务?`:`What would you like to schedule?`}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:Ae?v===`zh`?`直接说要改的内容、时间,或告诉我暂停、恢复。`:`Change what it does or when it runs, or ask to pause or resume.`:v===`zh`?`说说要做的事,时间和细节我们一起确定。`:`Tell us what to do. We’ll work out the timing and details together.`}),a?null:(0,Z.jsx)(u,{className:`mt-4 inline-block text-xs text-fg-muted hover:text-fg`,to:`/automations`,children:v===`zh`?`← 返回定时任务`:`← Back to scheduled tasks`})]}):me?(0,Z.jsx)(CA,{agentName:Nt.name?.trim()||ue.displayAgentId,messages:x.agentsSettings,disabled:K.sessionRoutePending||K.showSessionLoading,onPick:e=>{P.current+=1,L({id:P.current,text:e})}}):J?(0,Z.jsx)(Mw,{sk:x.skills,disabled:K.sessionRoutePending||K.showSessionLoading,onPick:e=>{P.current+=1,L({id:P.current,text:Yr(`find-skills`,e)})}}):void 0,compactWelcome:e,onDeleteRound:re?void 0:q.deleteMessageRound,onRetryUserMessageRound:re?void 0:q.retryUserMessageRound,deleteRoundDisabled:q.streaming||q.sending,onEditUserMessage:re?void 0:Rt,editLatestUserOnly:!0,editRequiresTurnId:!0,onSaveAssistantAsNote:Gt,onSaveAssistantToSourceNote:vt?Ut:void 0,onExtractAssistantTask:vt?qt:void 0,onForkAssistantTurn:!re&&Oe?.sessionType===`chat`?Me:void 0,trailingContent:Fe?(0,Z.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl rounded-2xl border border-edge-subtle bg-surface-panel px-4 py-3 text-sm`,children:[(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:v===`zh`?`这个回答合适吗?点选后可以在输入框修改,再发给我。`:`Did that response work for you? Pick an adjustment, edit it, then send.`}),(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[[[v===`zh`?`再短一点`:`Make it shorter`,v===`zh`?`这次回答再短一点。`:`Please make this answer shorter.`],[v===`zh`?`更温和一点`:`A little gentler`,v===`zh`?`这次回答的语气更温和一点。`:`Please make this answer a little gentler.`]].map(([e,t])=>(0,Z.jsx)(`button`,{type:`button`,onClick:()=>Ie(t),className:`rounded-full border border-edge px-3 py-1.5 text-xs text-fg transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:e},e)),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>Ie(),className:`rounded-full px-3 py-1.5 text-xs text-fg-muted transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:v===`zh`?`这样就好`:`Looks good`})]})]}):null},xe)]})})})}),(0,Z.jsx)(`div`,{ref:Re,className:Y(`chat-composer-dock pointer-events-none absolute inset-x-0 bottom-0 z-10`,r?`[--chat-composer-bottom-radius:1.65rem]`:`[--chat-composer-bottom-radius:1rem]`,ht?`[--chat-composer-bottom-space:max(0.625rem,env(safe-area-inset-bottom))]`:`[--chat-composer-bottom-space:max(0.5rem,env(safe-area-inset-bottom))] sm:[--chat-composer-bottom-space:max(1rem,env(safe-area-inset-bottom))]`),children:(0,Z.jsx)(`div`,{className:e&&!r?`px-3`:`px-3 sm:px-5 xl:px-6`,children:(0,Z.jsxs)(`div`,{"data-chat-composer-frame":!0,"data-primary-chat-composer":!e||void 0,className:Y(`pointer-events-auto relative mx-auto w-full min-w-0 pb-[var(--chat-composer-bottom-space)]`,(!e||r||a)&&`max-w-[calc(var(--max-width-chat-frame)+14px)]`,ht?`pt-2.5`:`pt-2 sm:pt-4`),children:[(0,Z.jsx)(ZC,{visible:!K.showSessionLoading&&!ze,onClick:()=>Ge(!0),running:q.streaming||q.sending}),(0,Z.jsx)(`div`,{className:`absolute bottom-full right-0 z-20 mb-2 flex items-center rounded-full border border-edge-subtle bg-surface-overlay p-1 shadow-elevated backdrop-blur-sm empty:hidden xl:hidden`,children:!e||a?(0,Z.jsx)(dA,{items:se.items,activeMessageIndex:Xe+et,labels:Ht,openLabel:x.chat.timelineOpen,closeLabel:x.chat.timelineClose,currentLabel:x.chat.timelineCurrent,onSelectMessage:ot}):null}),(0,Z.jsx)(rf,{prompt:le.clarifyPrompt,submitting:le.clarifySubmitting,submitError:le.clarifySubmitError,labels:x.chat,onSubmit:le.submitClarifyAnswer,onAgentDecide:le.letAgentDecideClarification,onCancel:le.cancelClarification}),gt?(0,Z.jsx)(nO,{plan:gt.plan,changeSummary:gt.changeSummary,isStreaming:q.streaming,labels:{heading:x.chat.planHeading,stepProgress:x.chat.planStepProgress,completedProgress:x.chat.planCompletedProgress,finished:x.chat.planFinished,ended:x.chat.planEnded,planned:x.chat.planPlanned,filesChangedOne:x.chat.planFilesChanged_one,filesChangedOther:x.chat.planFilesChanged_other}}):null,J&&oe.items.length>0?(0,Z.jsx)(`div`,{className:`mb-2 text-right`,children:(0,Z.jsx)(u,{to:`/capabilities/skills`,className:`text-xs text-accent-fg hover:underline`,children:x.skills.findBack})}):null,(0,Z.jsx)(kw,{}),(0,Z.jsx)(XE,{personal:r,nextTurnSuggestionsEnabled:!q.streaming,onPersonalSendDispatched:r?Ye:void 0,placeholder:r?q.streaming||q.sending?v===`zh`?`继续聊,或补充要求…`:`Keep talking or add a detail…`:v===`zh`?`发消息给「${i?.name||`Personal AI`}」…`:`Message ${i?.name||`Personal AI`}…`:me?x.agentsSettings.setupComposerPlaceholder:J?x.skills.findPlaceholder:void 0,composerContext:!me&&!e&&!re&&!de&&!mt&&oe.items.length===0?{project:bt,disabled:kt||Lt.busy||pt&&!K.projectPreparation,environmentPicker:K.projectPreparation?(0,Z.jsx)(eD,{selection:Lt}):void 0,workspacePath:K.effectiveWorkspacePath,canChangeWorkspace:lt,onProjectChange:Xt,onWorkspaceChange:Qt}:void 0,contextRefs:xt,pageContextPreview:Dt&&Et?(0,Z.jsx)(ZE,{draft:Dt,disabled:q.sending,waiting:q.streaming,onRemove:()=>Yo.remove(Et,Dt)}):void 0,setContextRefs:St,onDraftAttachmentsChange:wt,disabled:s||ft||Lt.busy||kt,sendDisabled:ce.controlPending||ce.control.phase===`stopping`||s||!K.modelConfigReady||!K.projectPreparation&&pt||!!(K.projectPreparation&&!Lt.allowed)||K.modelConfigSaving||Lt.busy||kt,sending:q.sending,streaming:q.streaming,conversationId:K.conversationId,prepareContextSession:K.projectPreparation?Lt.prepareSession:void 0,welcomeDraftSeed:I,welcomeSuggestion:!J&&ht?Ft:null,onAcceptWelcomeSuggestion:ct,thinkingLevel:K.thinkingLevel,modelSupportsThinking:K.modelSupportsThinking,onThinkingChange:K.onSessionThinkingLevelChange,onSend:Lt.send,composerMode:ce.composerMode,onRestoreEditor:ce.restoreEditor,onReacquireEdit:zt,inputControl:ce.control,onResumeQueue:()=>void ce.resumeQueue().catch(()=>{}),editingUserTurnId:de?.turnId,onCancelUserMessageEdit:Bt,onAbort:()=>void q.abort().catch(()=>{}),onAddPendingFollowUp:async(e,t,n,r,i)=>{await ce.addPendingFollowUp(e,t,n,Dt?.envelope,r,i),Et&&Dt&&Yo.remove(Et,Dt)},onSteeringInterrupt:Dt?void 0:(e,t,n)=>q.interruptAndSend(e,t,void 0,n),pendingFollowUps:ce.pendingFollowUps,editingFollowUpId:ce.editingFollowUpId,onBeginEditFollowUp:ce.beginEditFollowUp,onCancelEditFollowUp:ce.cancelEditFollowUp,onCommitEditFollowUp:(e,t,n,r,i)=>ce.commitEditFollowUp(e,t,n,r,i),onPendingFollowUpRemove:ce.removePendingFollowUp,onPendingFollowUpMove:ce.movePendingFollowUp,onPendingFollowUpReorder:ce.reorderPendingFollowUp,onPendingFollowUpSteer:e=>void ce.steerPendingFollowUp(e).catch(()=>{}),onPendingFollowUpSend:e=>void ce.sendQueuedInput(e).catch(()=>{}),steeringFollowUpId:ce.steeringFollowUpId,sessionModel:K.sessionModel,showModelSelector:!r,onModelChange:K.onSessionModelChange,modelDisabled:pt&&!K.projectPreparation||Lt.busy||K.modelConfigSaving,onChatAgentChange:!r&&!me&&!re&&ue.showChatAgentSelector?ue.onChatAgentChange:void 0,currentAgentId:ue.displayAgentId,voiceAgentName:r&&i?i.name:Nt.name,voiceTaskId:re??void 0,voiceMode:r?`assistant`:void 0,prepareVoiceSession:K.projectPreparation?()=>K.projectPreparation.create(Lt.mode):void 0})]})})})]})]}),(!e||a)&&xe&&window.electronAPI?.terminal?(0,Z.jsx)(Q.Suspense,{fallback:null,children:(0,Z.jsx)(TA,{conversationId:xe},xe)}):null,(0,Z.jsx)(D,{open:U!==null,onOpenChange:e=>{!e&&!G&&Vt()},children:(0,Z.jsxs)(w,{children:[(0,Z.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[1px]`}),(0,Z.jsxs)(T,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(82vh,42rem)] w-[min(100%-2rem,44rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:[(0,Z.jsxs)(`div`,{className:`shrink-0 border-b border-edge-subtle px-5 py-4`,children:[(0,Z.jsx)(E,{className:`text-base font-semibold text-fg`,children:x.chat.sourceNoteSaveDialogTitle}),(0,Z.jsx)(S,{className:`mt-1 text-sm text-fg-muted`,children:x.chat.sourceNoteSaveDialogDescription.replace(`{{title}}`,jt)})]}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-5 py-4`,children:[te?(0,Z.jsxs)(`p`,{className:`rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-sm text-danger`,role:`alert`,children:[x.chat.sourceNoteSaveFailed,`: `,te]}):null,(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium text-fg`,children:[(0,Z.jsx)(`span`,{children:x.chat.sourceNoteSaveDialogHeadingLabel}),(0,Z.jsx)(`input`,{value:U?.heading??``,onChange:e=>W(t=>t&&{...t,heading:e.target.value}),className:`h-10 rounded-lg border border-edge bg-surface-base px-3 text-sm font-normal text-fg outline-none transition-colors focus:border-accent focus:ring-2 focus:ring-accent/20`,disabled:G})]}),(0,Z.jsxs)(`label`,{className:`flex min-h-0 flex-1 flex-col gap-1.5 text-sm font-medium text-fg`,children:[(0,Z.jsx)(`span`,{children:x.chat.sourceNoteSaveDialogContentLabel}),(0,Z.jsx)(`textarea`,{value:U?.content??``,onChange:e=>W(t=>t&&{...t,content:e.target.value}),className:`min-h-[18rem] flex-1 resize-none rounded-lg border border-edge bg-surface-base px-3 py-2 font-mono text-xs leading-relaxed text-fg outline-none transition-colors focus:border-accent focus:ring-2 focus:ring-accent/20`,disabled:G})]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:[(0,Z.jsx)(mi,{type:`button`,variant:`secondary`,onClick:Vt,disabled:G,children:x.chat.sourceNoteSaveDialogCancel}),(0,Z.jsx)(mi,{type:`button`,variant:`primary`,onClick:()=>void Kt(),disabled:G||!U?.content.trim(),children:G?x.chat.sourceNoteSaveDialogSaving:x.chat.sourceNoteSaveDialogConfirm})]})]})]})})]})}):(0,Z.jsx)(`div`,{className:`mx-auto w-full max-w-[var(--max-width-chat-frame)] px-3 py-16 text-center text-sm leading-relaxed text-fg-muted sm:px-5`,children:x.chat.needToken})}export{Ks as $,Nf as A,of as B,Hf as C,Qo as Ct,Af as D,Mf as E,yf as F,tc as G,rc as H,hf as I,zs as J,Xs as K,vf as L,Ef as M,bf as N,jf as O,xf as P,$s as Q,lf as R,Ip as S,$o as St,Ff as T,nc as U,rf as V,ec as W,Zs as X,Bs as Y,Qs as Z,Zp as _,is as _t,Sw as a,gs as at,Up as b,ts as bt,aw as c,ps as ct,sw as d,us as dt,Ls as et,rw as f,ls as ft,Xp as g,as as gt,Yp as h,os as ht,Aw as i,_s as it,Of as j,kf as k,lw as l,fs as lt,qC as m,ss as mt,wA as n,Ns as nt,vw as o,hs as ot,ZC as p,cs as pt,Rs as q,Ow as r,vs as rt,_w as s,ms as st,EA as t,js as tt,cw as u,ds as ut,qp as v,rs as vt,Gf as w,Hp as x,es as xt,Gp as y,ns as yt,uf as z};