@xopcai/xopc 0.0.486 → 0.0.488

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 (426) hide show
  1. package/README.md +9 -3
  2. package/README.zh-CN.md +9 -3
  3. package/dist/browser-ext/_locales/en/messages.json +1 -1
  4. package/dist/browser-ext/_locales/zh_CN/messages.json +1 -1
  5. package/dist/browser-ext/dist/assets/{auth-8EjgHa-n.js → page-context-DCkQH5LX.js} +237 -172
  6. package/dist/browser-ext/dist/background.js +650 -108
  7. package/dist/browser-ext/dist/sidepanel.html +1 -1
  8. package/dist/browser-ext/dist/sidepanel.js +22 -4
  9. package/dist/browser-ext/manifest.json +2 -1
  10. package/dist/extensions/telegram/src/update-offset-store.js +2 -1
  11. package/dist/extensions/telegram/xopc.extension.json +1 -1
  12. package/dist/extensions/weixin/src/messaging/quote-cache.js +3 -1
  13. package/dist/extensions/weixin/src/storage/sync-buf.js +2 -1
  14. package/dist/gateway/server/chunks.bin +1733 -1553
  15. package/dist/gateway/server/chunks.json +1 -1
  16. package/dist/gateway/server/dependency-records.json +42 -0
  17. package/dist/gateway/static/root/assets/{activity-store-hSe5Nbgk.js → activity-store-DyHjQrpP.js} +1 -1
  18. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BY2wRiwY.js → agent-avatar-dicebear-gADhOk89.js} +1 -1
  19. package/dist/gateway/static/root/assets/{agent-avatar-display-D_UDgOr9.js → agent-avatar-display-Dyyk4GdM.js} +2 -2
  20. package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-BrcyLG9M.js → agent-defaults-settings-panel-DD5mU7h6.js} +1 -1
  21. package/dist/gateway/static/root/assets/{agent-plugin-dialog-CSJC1yud.js → agent-plugin-dialog-RZpnW9HG.js} +1 -1
  22. package/dist/gateway/static/root/assets/{agents-DX-t3X7K.js → agents-Ckt9wMj7.js} +3 -3
  23. package/dist/gateway/static/root/assets/{agents-admin-api-DSr-PWuW.js → agents-admin-api-BW3Mzst8.js} +1 -1
  24. package/dist/gateway/static/root/assets/{api-CGrHK9ij.js → api-Cd5TqEwc.js} +1 -1
  25. package/dist/gateway/static/root/assets/{api-B3T06TLl.js → api-DVQaJzrB.js} +1 -1
  26. package/dist/gateway/static/root/assets/{app-management-settings-panel-D6ZoYKaA.js → app-management-settings-panel-Cim6ZmGT.js} +1 -1
  27. package/dist/gateway/static/root/assets/{appearance-settings-BRb6kZT8.js → appearance-settings-BVMDvmUO.js} +1 -1
  28. package/dist/gateway/static/root/assets/{apps-page-6xeWvMpF.js → apps-page-B7T55D7Y.js} +1 -1
  29. package/dist/gateway/static/root/assets/{archive-plugin-CQ5UXgZk.js → archive-plugin-DVoAuR_a.js} +1 -1
  30. package/dist/gateway/static/root/assets/{automation-api-D-gn6x5E.js → automation-api-B6YcuEsE.js} +1 -1
  31. package/dist/gateway/static/root/assets/{automation-result-state-B7hq0XOL.js → automation-result-state-BycWqFXM.js} +1 -1
  32. package/dist/gateway/static/root/assets/{automation-run-list-CM59-qm5.js → automation-run-list-DDDHtKq0.js} +1 -1
  33. package/dist/gateway/static/root/assets/{automation-task-card-C453Q-Wa.js → automation-task-card-BBEA23Zb.js} +1 -1
  34. package/dist/gateway/static/root/assets/{automations-page-BLFBqaPX.js → automations-page-DelDZorh.js} +1 -1
  35. package/dist/gateway/static/root/assets/{automations-workspace-DiO3Iyuj.js → automations-workspace-leY4yCvw.js} +2 -2
  36. package/dist/gateway/static/root/assets/{binary-plugins-D_zw0TgG.js → binary-plugins-o-jwYyMd.js} +1 -1
  37. package/dist/gateway/static/root/assets/block-editor-BFDeQtYs.css +1 -0
  38. package/dist/gateway/static/root/assets/{block-editor-Cesz2DqP.js → block-editor-Bp6TLleA.js} +46 -46
  39. package/dist/gateway/static/root/assets/{browser-settings-page-BHElJSFt.js → browser-settings-page-CtPARtRA.js} +1 -1
  40. package/dist/gateway/static/root/assets/{capabilities-CW-vdkz6.js → capabilities-B5gHYD8r.js} +1 -1
  41. package/dist/gateway/static/root/assets/{capabilities-DZrjA95P.js → capabilities-G2ZaAAs2.js} +1 -1
  42. package/dist/gateway/static/root/assets/{capabilities-page-DQrfkrBA.js → capabilities-page-C6KCaaHR.js} +2 -2
  43. package/dist/gateway/static/root/assets/{capabilities-settings-panel-DIT2dvtc.js → capabilities-settings-panel-CVwdxuL4.js} +1 -1
  44. package/dist/gateway/static/root/assets/{channels-Dcr5dgqw.js → channels-Bh2bHLni.js} +1 -1
  45. package/dist/gateway/static/root/assets/{chat-agents-api-CyvBfBbp.js → chat-agents-api-DRKlkcuv.js} +1 -1
  46. package/dist/gateway/static/root/assets/{chat-chart-block-B83s8HE9.js → chat-chart-block-DxTCx__V.js} +1 -1
  47. package/dist/gateway/static/root/assets/{chat-page-DWZCzxY7.js → chat-page-XqG9aYBd.js} +31 -31
  48. package/dist/gateway/static/root/assets/{chat-terminal-dock-DCUuwiTt.js → chat-terminal-dock-Ch74AWYF.js} +1 -1
  49. package/dist/gateway/static/root/assets/{command-palette-api-UrqPvWR1.js → command-palette-api-CAKoTF_-.js} +1 -1
  50. package/dist/gateway/static/root/assets/{composer-model-config-control-C2Bku39S.js → composer-model-config-control-Bas1wFVW.js} +1 -1
  51. package/dist/gateway/static/root/assets/{composer-notifications-MGKffwC7.js → composer-notifications-CpBgWAE4.js} +1 -1
  52. package/dist/gateway/static/root/assets/{composer-payload-handoff-a0quQ25p.js → composer-payload-handoff-uT_hvvap.js} +1 -1
  53. package/dist/gateway/static/root/assets/{computer-settings-page-DUzQe6Bz.js → computer-settings-page-x8YUBBuX.js} +1 -1
  54. package/dist/gateway/static/root/assets/confirm-dialog-yhRKgG72.js +1 -0
  55. package/dist/gateway/static/root/assets/{connected-providers-grid-BJKEp0SE.js → connected-providers-grid-DS21-u3Q.js} +1 -1
  56. package/dist/gateway/static/root/assets/{connection-usage-guide-B9hoSOnN.js → connection-usage-guide-DNNFESD9.js} +1 -1
  57. package/dist/gateway/static/root/assets/{connector-service-page-e67KylnM.js → connector-service-page-BS7IJ6oc.js} +1 -1
  58. package/dist/gateway/static/root/assets/{connectors-api-CRGq-TSw.js → connectors-api-B27sJ651.js} +1 -1
  59. package/dist/gateway/static/root/assets/{connectors-page-BteRI1XM.js → connectors-page-DM6TppXV.js} +1 -1
  60. package/dist/gateway/static/root/assets/{date-picker-DwITf4I2.js → date-picker-D3N2BGVY.js} +1 -1
  61. package/dist/gateway/static/root/assets/{date-time-picker-ChG1CqR1.js → date-time-picker-BNw099Is.js} +1 -1
  62. package/dist/gateway/static/root/assets/{desktop-pet-BHoFymL4.js → desktop-pet-BtY6aGrh.js} +1 -1
  63. package/dist/gateway/static/root/assets/{desktop-pet-settings-BYeBN4jj.js → desktop-pet-settings-DVXfAMaU.js} +1 -1
  64. package/dist/gateway/static/root/assets/{dev-view-store-DsjH8x76.js → dev-view-store-D4EyUkRI.js} +1 -1
  65. package/dist/gateway/static/root/assets/{device-connections-panel-DE01vyK_.js → device-connections-panel-DYK_DQzO.js} +1 -1
  66. package/dist/gateway/static/root/assets/{device-pairing-action-w1enAo76.js → device-pairing-action-DXo8MWy2.js} +1 -1
  67. package/dist/gateway/static/root/assets/{device-pairing-wizard-Dt737tSq.js → device-pairing-wizard-NddAztJ2.js} +1 -1
  68. package/dist/gateway/static/root/assets/{directory-picker-path-field-B-eUnbng.js → directory-picker-path-field-Bbq7ZyGn.js} +1 -1
  69. package/dist/gateway/static/root/assets/{extension-authoritative-grants-DYp2nNol.js → extension-authoritative-grants-qpYvHriJ.js} +1 -1
  70. package/dist/gateway/static/root/assets/{extension-debug-page-4jJ1uVQJ.js → extension-debug-page-BOb-6rpq.js} +1 -1
  71. package/dist/gateway/static/root/assets/{extension-iframe-host-CJV5JETm.js → extension-iframe-host-DpgIPfJe.js} +1 -1
  72. package/dist/gateway/static/root/assets/{extension-marketplace-api-DGV5FC-v.js → extension-marketplace-api-BhGNQYHl.js} +1 -1
  73. package/dist/gateway/static/root/assets/{extension-message-router-B4I-Y6qs.js → extension-message-router-QjbtEYyu.js} +1 -1
  74. package/dist/gateway/static/root/assets/{extension-page-lc7a84nG.js → extension-page-BOp7wU9Y.js} +1 -1
  75. package/dist/gateway/static/root/assets/{extension-provider-D8_mIBI0.js → extension-provider-CFPicsnW.js} +1 -1
  76. package/dist/gateway/static/root/assets/{extension-settings-page-Uw2lfWRh.js → extension-settings-page-cXjBvPwg.js} +1 -1
  77. package/dist/gateway/static/root/assets/{gateway-config-swr-BD-ams0X.js → gateway-config-swr-DxelrRtx.js} +1 -1
  78. package/dist/gateway/static/root/assets/gateway-realtime-D2B_nv2b.js +1 -0
  79. package/dist/gateway/static/root/assets/gateway-realtime-store-DrVbjYfI.js +1 -0
  80. package/dist/gateway/static/root/assets/{gateway-restart-Dos1Pp84.js → gateway-restart-Ce6rCCAr.js} +1 -1
  81. package/dist/gateway/static/root/assets/{gateway-settings-DUC1iOVK.js → gateway-settings-BTr0Gwdo.js} +1 -1
  82. package/dist/gateway/static/root/assets/{gateway-startup-retry-DgmvR-hb.js → gateway-startup-retry-Dm0dK8BT.js} +1 -1
  83. package/dist/gateway/static/root/assets/{global-defaults-api-B7suATYU.js → global-defaults-api-BZnu44eA.js} +1 -1
  84. package/dist/gateway/static/root/assets/{home-page-mSRCU81k.js → home-page-Bxr3V5lc.js} +3 -3
  85. package/dist/gateway/static/root/assets/{home-task-actions-_ZAc57Y7.js → home-task-actions-GAO06s1_.js} +1 -1
  86. package/dist/gateway/static/root/assets/{image-generation-api-Baz4xdZ4.js → image-generation-api-DrZPmWFt.js} +1 -1
  87. package/dist/gateway/static/root/assets/{imports-page-DR0eLPgB.js → imports-page-D-x5kijk.js} +1 -1
  88. package/dist/gateway/static/root/assets/index-BjU5H5hz.js +11 -0
  89. package/dist/gateway/static/root/assets/index-CREeN6C_.css +1 -0
  90. package/dist/gateway/static/root/assets/{install-connector-dialog-CntHi8Rh.js → install-connector-dialog-st2O1bez.js} +1 -1
  91. package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-DnKkQoqR.js +1 -0
  92. package/dist/gateway/static/root/assets/{local-app-workbench-page-C3Lqi8E1.js → local-app-workbench-page-CKHJa4K8.js} +1 -1
  93. package/dist/gateway/static/root/assets/{local-apps-page-BoCtITdL.js → local-apps-page-D28d-sO0.js} +1 -1
  94. package/dist/gateway/static/root/assets/{local-session-drafts-CGSV1RQg.js → local-session-drafts-KkAOxXk5.js} +2 -2
  95. package/dist/gateway/static/root/assets/{locale-store-CHjsq5NR.js → locale-store-Dy0B0XDJ.js} +1 -1
  96. package/dist/gateway/static/root/assets/{logs-page-0hkRbcUR.js → logs-page-BPuHO-iA.js} +1 -1
  97. package/dist/gateway/static/root/assets/{management-api-FVu7eYXD.js → management-api-BtTRehT0.js} +1 -1
  98. package/dist/gateway/static/root/assets/{management-settings-QQB1r71U.js → management-settings-B2R43Itv.js} +1 -1
  99. package/dist/gateway/static/root/assets/{markdown-view-ihzUc4ud.js → markdown-view-ByuzuGRb.js} +1 -1
  100. package/dist/gateway/static/root/assets/{mcp-conversation-setup-page-DffQKrjd.js → mcp-conversation-setup-page-D_6XeyXG.js} +1 -1
  101. package/dist/gateway/static/root/assets/{media-plugins-C78NkHfB.js → media-plugins-B9Q7WvNF.js} +1 -1
  102. package/dist/gateway/static/root/assets/messages-Bj6DCoic.js +3 -0
  103. package/dist/gateway/static/root/assets/{model-selector-QFZY5XNN.js → model-selector-8FTrQQ2N.js} +1 -1
  104. package/dist/gateway/static/root/assets/{models-hub-cache-BrD6r5Qs.js → models-hub-cache-DMBOw544.js} +1 -1
  105. package/dist/gateway/static/root/assets/{new-session-preferences-gb411vZP.js → new-session-preferences-CxCn2Jxk.js} +1 -1
  106. package/dist/gateway/static/root/assets/note-detail-panel-BTNX68oO.js +7 -0
  107. package/dist/gateway/static/root/assets/note-image-lightbox-D20oZuOM.js +1 -0
  108. package/dist/gateway/static/root/assets/{notes-api-D5SvfybU.js → notes-api-M1FuRZbW.js} +1 -1
  109. package/dist/gateway/static/root/assets/{notes-page-RPfvHnl6.js → notes-page-FocipOyc.js} +2 -2
  110. package/dist/gateway/static/root/assets/{oauth-api-DnMpUoyx.js → oauth-api-Dza1tHcr.js} +1 -1
  111. package/dist/gateway/static/root/assets/{oauth-provider-connect-DGYky6ut.js → oauth-provider-connect-BPNIEiMv.js} +1 -1
  112. package/dist/gateway/static/root/assets/{page-context-capture-button-CVHz9b6c.js → page-context-capture-button-DpGnxSrD.js} +1 -1
  113. package/dist/gateway/static/root/assets/{page-context-draft-Bk7jVvAG.js → page-context-draft-CHAS3BY3.js} +1 -1
  114. package/dist/gateway/static/root/assets/{page-header-store-NP7MCIaP.js → page-header-store-BXED3zhV.js} +1 -1
  115. package/dist/gateway/static/root/assets/{personal-avatar-1TVnHakL.js → personal-avatar-BCk4KoeZ.js} +1 -1
  116. package/dist/gateway/static/root/assets/{personal-page-Dt1d3tQT.js → personal-page-CSc2n5UD.js} +1 -1
  117. package/dist/gateway/static/root/assets/{personal-profile-settings-XiT1MgTK.js → personal-profile-settings-C86FBPOH.js} +1 -1
  118. package/dist/gateway/static/root/assets/{personal-settings-panel-bcw04REt.js → personal-settings-panel-BlPLE0Ip.js} +1 -1
  119. package/dist/gateway/static/root/assets/{phone-dependencies-card-B4QsgIEF.js → phone-dependencies-card-BCob98OY.js} +1 -1
  120. package/dist/gateway/static/root/assets/{phone-model-connection-Dk5kE1Ll.js → phone-model-connection-D-CcYcch.js} +1 -1
  121. package/dist/gateway/static/root/assets/{phone-model-picker-CFoxQiws.js → phone-model-picker-eMe7fmZu.js} +1 -1
  122. package/dist/gateway/static/root/assets/{phone-settings-page-Bv1xm8sh.js → phone-settings-page-D7yXeGmR.js} +1 -1
  123. package/dist/gateway/static/root/assets/{phone-workspace-store-DGaibcsi.js → phone-workspace-store-CcA_vo-t.js} +1 -1
  124. package/dist/gateway/static/root/assets/{plugin-details-dialog-FcOJaeP0.js → plugin-details-dialog-BAmodjSZ.js} +1 -1
  125. package/dist/gateway/static/root/assets/{preference-select-fields-B-yK91If.js → preference-select-fields-BBd5CWkM.js} +1 -1
  126. package/dist/gateway/static/root/assets/{preview-runtime-FtWOW5i4.js → preview-runtime-DUJ7XhMP.js} +3 -3
  127. package/dist/gateway/static/root/assets/product-automation-feedback-BDFpFrSs.js +1 -0
  128. package/dist/gateway/static/root/assets/{product-open-page-C09VEZjY.js → product-open-page-t3hsoYql.js} +1 -1
  129. package/dist/gateway/static/root/assets/{product-preview-content-B3mzl6-f.js → product-preview-content-BM0pjf0F.js} +1 -1
  130. package/dist/gateway/static/root/assets/{product-preview-modal-5kTp_7Qk.js → product-preview-modal-CLQcCVjI.js} +2 -2
  131. package/dist/gateway/static/root/assets/project-detail-page-CK_EN6Jq.js +7 -0
  132. package/dist/gateway/static/root/assets/{project-understanding-4IyHVmus.js → project-understanding-CwtdVbMP.js} +1 -1
  133. package/dist/gateway/static/root/assets/{projects-page-C-9x23LR.js → projects-page-ESAmJ4I_.js} +1 -1
  134. package/dist/gateway/static/root/assets/{providers-api-D9NuB7w3.js → providers-api-CR7FJzt-.js} +1 -1
  135. package/dist/gateway/static/root/assets/recording-upload-DrgujKBt.js +1 -0
  136. package/dist/gateway/static/root/assets/{registry-api-CDpUAb2R.js → registry-api-CaBz9f4g.js} +1 -1
  137. package/dist/gateway/static/root/assets/{remote-access-hub-DVTs8pwO.js → remote-access-hub-CB-Js5gd.js} +1 -1
  138. package/dist/gateway/static/root/assets/{resource-unavailable-CZlqZYk-.js → resource-unavailable-DiPPmZsR.js} +1 -1
  139. package/dist/gateway/static/root/assets/right-workspace-store-CcRApllu.js +1 -0
  140. package/dist/gateway/static/root/assets/{route-preload-CzorjVc9.js → route-preload-Ab7Zw-df.js} +2 -2
  141. package/dist/gateway/static/root/assets/{routine-panel-n4IstC8Y.js → routine-panel-DzdJGicv.js} +2 -2
  142. package/dist/gateway/static/root/assets/{runtime-tools-api-BhS0RWf2.js → runtime-tools-api-utBemmh4.js} +1 -1
  143. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-jTbGPGeA.js → runtime-tools-settings-panel-ChXrIluB.js} +1 -1
  144. package/dist/gateway/static/root/assets/{service-recommendation-list-wfd0Mjtu.js → service-recommendation-list-Dm5GcMRy.js} +1 -1
  145. package/dist/gateway/static/root/assets/{session-api-CR3NLqvs.js → session-api-vEn4BzjV.js} +1 -1
  146. package/dist/gateway/static/root/assets/{session-manager-C2MCS4C5.js → session-manager-7nbjJYyy.js} +2 -2
  147. package/dist/gateway/static/root/assets/{sessions-page-9ibCNP9o.js → sessions-page-B__ftjgG.js} +1 -1
  148. package/dist/gateway/static/root/assets/settings-advanced-gate-DV-_ZdXD.js +1 -0
  149. package/dist/gateway/static/root/assets/{settings-advanced-section-CTLdGPvx.js → settings-advanced-section-DhKzGl03.js} +1 -1
  150. package/dist/gateway/static/root/assets/{settings-mode-store-CCQVvItG.js → settings-mode-store-CQofc337.js} +1 -1
  151. package/dist/gateway/static/root/assets/{settings-page-DsM_f07M.js → settings-page-CzW5GM5r.js} +1 -1
  152. package/dist/gateway/static/root/assets/{settings-page-header-C21Iw2rD.js → settings-page-header-CiS6x6sn.js} +1 -1
  153. package/dist/gateway/static/root/assets/{settings-page-layout-BXcLlp6p.js → settings-page-layout-B-rj_rso.js} +1 -1
  154. package/dist/gateway/static/root/assets/{setup-interaction-page-W2F5ZaR_.js → setup-interaction-page-DTgwtj55.js} +1 -1
  155. package/dist/gateway/static/root/assets/{setup-status-panel-BFNwZuhp.js → setup-status-panel-BhKPMIds.js} +1 -1
  156. package/dist/gateway/static/root/assets/{share-link-dialog-2JjvWs0q.js → share-link-dialog-WR7Op1vL.js} +1 -1
  157. package/dist/gateway/static/root/assets/{share-preview-page-C32Mq-BY.js → share-preview-page-DonmTI11.js} +1 -1
  158. package/dist/gateway/static/root/assets/{shares-api-BhWvN3LS.js → shares-api-CoRLwDnw.js} +1 -1
  159. package/dist/gateway/static/root/assets/{shares-settings-BDGbs8wz.js → shares-settings-UA91fiMV.js} +1 -1
  160. package/dist/gateway/static/root/assets/{skill-api-BG9A1WF0.js → skill-api-BE-iPtTQ.js} +1 -1
  161. package/dist/gateway/static/root/assets/{skill-list-api-B26hHnXq.js → skill-list-api-Dsfjdtuu.js} +1 -1
  162. package/dist/gateway/static/root/assets/{skill-reload-api-B9Eu5Yk_.js → skill-reload-api-BIZJWow-.js} +1 -1
  163. package/dist/gateway/static/root/assets/{skills-page-kL8E5zgi.js → skills-page-1wvItQag.js} +1 -1
  164. package/dist/gateway/static/root/assets/{space-api-_uKFiASp.js → space-api-E8VbAaEl.js} +1 -1
  165. package/dist/gateway/static/root/assets/space-page-BCzDsNJd.js +2 -0
  166. package/dist/gateway/static/root/assets/{space-workbook-BAwHwK6O.js → space-workbook-CwltZeHG.js} +1 -1
  167. package/dist/gateway/static/root/assets/{system-settings-panel-0e2zfQLt.js → system-settings-panel-03a25GEc.js} +1 -1
  168. package/dist/gateway/static/root/assets/{task-detail-page-DdCpNW8K.js → task-detail-page-B_YXsT9W.js} +1 -1
  169. package/dist/gateway/static/root/assets/{task-header-title-CLt_lmjb.js → task-header-title-bZVPIbyR.js} +1 -1
  170. package/dist/gateway/static/root/assets/{task-result-presentation-CgvcqEMD.js → task-result-presentation-_VWkiekf.js} +1 -1
  171. package/dist/gateway/static/root/assets/{task-run-issue-notice-8FX876PP.js → task-run-issue-notice-BXOES2t9.js} +1 -1
  172. package/dist/gateway/static/root/assets/{tasks-CvOAtEHv.js → tasks-D8bnpu0N.js} +1 -1
  173. package/dist/gateway/static/root/assets/{terminal-panel-store-Cy90Ix5U.js → terminal-panel-store-BOHv5O2x.js} +1 -1
  174. package/dist/gateway/static/root/assets/{theme-store-CvG266p8.js → theme-store-XNsFzxSj.js} +1 -1
  175. package/dist/gateway/static/root/assets/{tracing-settings-page-Cx_fOH70.js → tracing-settings-page-Y9z2HoGj.js} +1 -1
  176. package/dist/gateway/static/root/assets/{tunnel-api-Cph-ZBBy.js → tunnel-api-XHGjcUi9.js} +1 -1
  177. package/dist/gateway/static/root/assets/turn-outcome-Bf3N3Bmj.js +1 -0
  178. package/dist/gateway/static/root/assets/{understanding-activity-store-CN4JzOIO.js → understanding-activity-store-BDBAkksk.js} +1 -1
  179. package/dist/gateway/static/root/assets/{understanding-refresh-store-BuZZ1_VH.js → understanding-refresh-store-D7gBfD26.js} +1 -1
  180. package/dist/gateway/static/root/assets/{usage-page-Du42x0ej.js → usage-page-DxESTMwa.js} +1 -1
  181. package/dist/gateway/static/root/assets/{use-autosave-B_WH_LBE.js → use-autosave-D7zZrcsj.js} +1 -1
  182. package/dist/gateway/static/root/assets/{use-composer-attachments-BEuyorVm.js → use-composer-attachments-DWiIdMIi.js} +1 -1
  183. package/dist/gateway/static/root/assets/{use-file-preview-expanded-Cehu0745.js → use-file-preview-expanded-CA9vFUTT.js} +1 -1
  184. package/dist/gateway/static/root/assets/{use-generated-media-CzRbgtcv.js → use-generated-media-DX4_ne7C.js} +1 -1
  185. package/dist/gateway/static/root/assets/{use-personal-profile-D4gLM6Wi.js → use-personal-profile-CaCORKeL.js} +1 -1
  186. package/dist/gateway/static/root/assets/{use-personal-work-B25WRGHj.js → use-personal-work-D0tMU1bP.js} +1 -1
  187. package/dist/gateway/static/root/assets/{use-realtime-voice-CV3GIt_T.js → use-realtime-voice-D9k997EW.js} +1 -1
  188. package/dist/gateway/static/root/assets/{use-share-link-WKZLlEqr.js → use-share-link-CqV3o-VZ.js} +1 -1
  189. package/dist/gateway/static/root/assets/{use-workspace-tree-C0C861cb.js → use-workspace-tree-nnrez9-d.js} +1 -1
  190. package/dist/gateway/static/root/assets/{user-model-page-AK2U8vGc.js → user-model-page-CpVdbSxS.js} +1 -1
  191. package/dist/gateway/static/root/assets/{voice-api-key-field-BqXQj51r.js → voice-api-key-field-CVi3dBKx.js} +1 -1
  192. package/dist/gateway/static/root/assets/{voice-config-api-sXEIG6lz.js → voice-config-api-DZbcg7qD.js} +1 -1
  193. package/dist/gateway/static/root/assets/voice-input-shortcut-events-CwKpIInD.js +1 -0
  194. package/dist/gateway/static/root/assets/{voice-player-store-CTbnOdeM.js → voice-player-store-DT0f9GPa.js} +1 -1
  195. package/dist/gateway/static/root/assets/{voice-settings-JpPo3BvX.js → voice-settings-CJdWnHas.js} +1 -1
  196. package/dist/gateway/static/root/assets/{work-discovery-overlay-BjfTRFX8.js → work-discovery-overlay-qEN1Ikir.js} +1 -1
  197. package/dist/gateway/static/root/assets/{work-discovery-page-CSRkFiXc.js → work-discovery-page-JjCyt1Kw.js} +1 -1
  198. package/dist/gateway/static/root/assets/{working-directory-picker-modal-DgM21YVT.js → working-directory-picker-modal-DX6bRmkQ.js} +1 -1
  199. package/dist/gateway/static/root/assets/{workspace-api-CQOuWbVv.js → workspace-api-CD_6YyPI.js} +2 -2
  200. package/dist/gateway/static/root/assets/workspace-editor-agent-store-BuYdf4CO.js +1 -0
  201. package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-CmMueTmW.js → workspace-file-preview-dialog-DPHnm_7A.js} +1 -1
  202. package/dist/gateway/static/root/assets/{workspace-open-location-menu-BAbIGS01.js → workspace-open-location-menu-BdXn5F2i.js} +1 -1
  203. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-e8HJFnTs.js → xopc-cloud-account-card-CLM7hfkN.js} +1 -1
  204. package/dist/gateway/static/root/index.html +97 -97
  205. package/dist/package.js +1 -1
  206. package/dist/packages/gateway-contract/src/session-input-command.js +2 -1
  207. package/dist/packages/gateway-contract/src/task-display.js +1 -1
  208. package/dist/packages/gateway-contract/src/task-research-result.js +5 -0
  209. package/dist/packages/realtime-client/src/index.js +6 -1
  210. package/dist/packages/realtime-protocol/src/browser-preview.js +111 -0
  211. package/dist/packages/realtime-protocol/src/index.js +5 -1
  212. package/dist/src/agent/agent-manager.d.ts +2 -2
  213. package/dist/src/agent/agent-manager.js +6 -3
  214. package/dist/src/agent/commands/command-registry.js +2 -1
  215. package/dist/src/agent/embedded/execution-tool-policy.d.ts +1 -0
  216. package/dist/src/agent/embedded/execution-tool-policy.js +7 -3
  217. package/dist/src/agent/embedded/run-turn.js +9 -3
  218. package/dist/src/agent/mcp/continuation-guard.js +2 -1
  219. package/dist/src/agent/mcp/conversation-setup.js +2 -1
  220. package/dist/src/agent/mcp/discovery.js +2 -1
  221. package/dist/src/agent/orchestration/child-run-monitor.js +2 -1
  222. package/dist/src/agent/session/interaction-policy-state.js +2 -1
  223. package/dist/src/agent/tools/browser/tool/browser-use-tool.js +24 -16
  224. package/dist/src/agent/tools/browser/tool/schemas.d.ts +1 -0
  225. package/dist/src/agent/tools/browser/tool/schemas.js +6 -1
  226. package/dist/src/agent/tools/clarify-tool.js +1 -1
  227. package/dist/src/agent/tools/factory.js +9 -1
  228. package/dist/src/agent/tools/personal-task-tool.js +79 -16
  229. package/dist/src/agent/tools/session-recall-tool.js +10 -2
  230. package/dist/src/agent/tools/skill-install-tool.js +2 -1
  231. package/dist/src/agent/tools/task-collaboration-tool.js +1 -1
  232. package/dist/src/agent/tools/task-result-tool.js +10 -9
  233. package/dist/src/agent/tools/web.js +5 -3
  234. package/dist/src/agent/tools/xopc-use-tool.js +11 -5
  235. package/dist/src/automations/capabilities/write.js +2 -1
  236. package/dist/src/automations/mcp-source.js +2 -1
  237. package/dist/src/browser/drivers/browser-driver.d.ts +1 -0
  238. package/dist/src/browser/drivers/extension-driver.d.ts +2 -0
  239. package/dist/src/browser/drivers/extension-driver.js +11 -1
  240. package/dist/src/browser/runtime/browser-runtime.d.ts +6 -0
  241. package/dist/src/browser/runtime/browser-runtime.js +13 -1
  242. package/dist/src/capabilities/runtime/dispatcher.d.ts +6 -0
  243. package/dist/src/capabilities/runtime/dispatcher.js +47 -12
  244. package/dist/src/channels/attachments/inbound-persist.js +1 -0
  245. package/dist/src/channels/attachments/outbound-tts-persist.js +1 -0
  246. package/dist/src/channels/message-journal.js +2 -1
  247. package/dist/src/cli/cli-log-level-preset.js +5 -1
  248. package/dist/src/cli/commands/mcp.js +44 -5
  249. package/dist/src/cli/index.js +9 -1
  250. package/dist/src/computer/flows.js +2 -1
  251. package/dist/src/config/schema.d.ts +18 -0
  252. package/dist/src/config/schema.js +6 -0
  253. package/dist/src/connectors/composio-triggers.js +2 -1
  254. package/dist/src/endpoint-tools/delegation.js +2 -1
  255. package/dist/src/endpoint-tools/device-capability-grants.js +2 -1
  256. package/dist/src/endpoint-tools/execution-actor.js +2 -1
  257. package/dist/src/endpoint-tools/folder-connections.js +2 -1
  258. package/dist/src/endpoint-tools/invocation-service.js +2 -1
  259. package/dist/src/endpoint-tools/provider-catalog.js +2 -1
  260. package/dist/src/endpoint-tools/provider-operation-status.js +2 -1
  261. package/dist/src/endpoint-tools/runtime.js +2 -1
  262. package/dist/src/execution-environments/session-environment-service.js +1 -1
  263. package/dist/src/files/workspace-file-spaces.d.ts +4 -0
  264. package/dist/src/files/workspace-file-spaces.js +14 -0
  265. package/dist/src/gateway/file-space-service.d.ts +1 -1
  266. package/dist/src/gateway/file-space-service.js +2 -8
  267. package/dist/src/gateway/hono/app.js +29 -8
  268. package/dist/src/gateway/hono/lib/extension-store.js +2 -1
  269. package/dist/src/gateway/hono/lib/mcp-dispatcher.d.ts +2 -0
  270. package/dist/src/gateway/hono/lib/mcp-dispatcher.js +19 -0
  271. package/dist/src/gateway/hono/routes/browser.js +38 -0
  272. package/dist/src/gateway/hono/routes/capability-operations.d.ts +1 -0
  273. package/dist/src/gateway/hono/routes/capability-operations.js +6 -3
  274. package/dist/src/gateway/hono/routes/device-push.js +7 -2
  275. package/dist/src/gateway/hono/routes/execution-environments.js +4 -0
  276. package/dist/src/gateway/hono/routes/lazy-bundles.js +19 -0
  277. package/dist/src/gateway/hono/routes/mcp-bridge.d.ts +3 -0
  278. package/dist/src/gateway/hono/routes/mcp-bridge.js +87 -0
  279. package/dist/src/gateway/hono/routes/mcp-remote.d.ts +3 -0
  280. package/dist/src/gateway/hono/routes/mcp-remote.js +169 -0
  281. package/dist/src/gateway/hono/routes/notifications.js +11 -7
  282. package/dist/src/gateway/hono/routes/personal-agent.js +2 -1
  283. package/dist/src/gateway/hono/routes/projects.js +2 -3
  284. package/dist/src/gateway/hono/routes/session-command-handler.js +2 -1
  285. package/dist/src/gateway/hono/routes/session-input-handler.d.ts +2 -0
  286. package/dist/src/gateway/security/gateway-scopes.js +2 -0
  287. package/dist/src/gateway/service/agent-runner.js +9 -4
  288. package/dist/src/gateway/service/config-coordinator.d.ts +9 -0
  289. package/dist/src/gateway/service/session-command-service.js +4 -2
  290. package/dist/src/gateway/service/session-input-coordinator.d.ts +1 -0
  291. package/dist/src/gateway/service/session-input-coordinator.js +30 -2
  292. package/dist/src/gateway/service/session-preparation-worker.js +6 -2
  293. package/dist/src/gateway/service.d.ts +6 -0
  294. package/dist/src/gateway/service.js +44 -3
  295. package/dist/src/local-apps/access-audit.js +2 -1
  296. package/dist/src/local-apps/automation-proposals.js +2 -1
  297. package/dist/src/local-apps/capabilities/automation-policy.js +2 -1
  298. package/dist/src/local-apps/capabilities/delegate.js +2 -1
  299. package/dist/src/local-apps/execution-authority.js +2 -1
  300. package/dist/src/local-apps/p1-services.js +2 -1
  301. package/dist/src/local-apps/public-assets.js +2 -1
  302. package/dist/src/local-apps/service.js +2 -1
  303. package/dist/src/local-apps/store.js +2 -1
  304. package/dist/src/mcp/callback-config.d.ts +5 -0
  305. package/dist/src/mcp/callback-config.js +16 -0
  306. package/dist/src/mcp/capability-server.d.ts +1 -2
  307. package/dist/src/mcp/capability-server.js +34 -79
  308. package/dist/src/mcp/connection-grants.d.ts +15 -0
  309. package/dist/src/mcp/connection-grants.js +73 -0
  310. package/dist/src/mcp/delegation.d.ts +329 -0
  311. package/dist/src/mcp/delegation.js +610 -0
  312. package/dist/src/mcp/gateway-http-client.d.ts +2 -2
  313. package/dist/src/mcp/gateway-http-client.js +4 -4
  314. package/dist/src/mcp/product-tools.d.ts +7 -0
  315. package/dist/src/mcp/product-tools.js +292 -0
  316. package/dist/src/mcp/remote-auth.d.ts +8 -0
  317. package/dist/src/mcp/remote-auth.js +51 -0
  318. package/dist/src/mcp/remote-config.d.ts +11 -0
  319. package/dist/src/mcp/remote-config.js +31 -0
  320. package/dist/src/mcp/remote-grants.d.ts +20 -0
  321. package/dist/src/mcp/remote-grants.js +60 -0
  322. package/dist/src/mcp/run-callback-subscriptions.d.ts +13 -0
  323. package/dist/src/mcp/run-callback-subscriptions.js +17 -0
  324. package/dist/src/mcp/run-callbacks.d.ts +6 -0
  325. package/dist/src/mcp/run-callbacks.js +125 -0
  326. package/dist/src/mcp/tool-contract.d.ts +30 -0
  327. package/dist/src/mcp/tool-contract.js +81 -0
  328. package/dist/src/mcp/workspace-search.d.ts +16 -0
  329. package/dist/src/mcp/workspace-search.js +68 -0
  330. package/dist/src/media/index.js +4 -1
  331. package/dist/src/media/media-reference.js +2 -1
  332. package/dist/src/media/session-references.js +4 -2
  333. package/dist/src/media/store.js +2 -1
  334. package/dist/src/media/uri.js +17 -12
  335. package/dist/src/music-generation/artifact.js +2 -1
  336. package/dist/src/music-generation/settings.js +2 -1
  337. package/dist/src/notes/capabilities/write.js +2 -1
  338. package/dist/src/notifications/device-store.js +1 -1
  339. package/dist/src/notifications/platform-push.d.ts +2 -1
  340. package/dist/src/notifications/platform-push.js +4 -3
  341. package/dist/src/notifications/service.js +4 -4
  342. package/dist/src/personal-agent/proactivity/repository.js +2 -1
  343. package/dist/src/personal-agent/proactivity/service.js +2 -1
  344. package/dist/src/personal-agent/reply-result.js +4 -2
  345. package/dist/src/personal-agent/result-reader.d.ts +2 -0
  346. package/dist/src/personal-agent/result-reader.js +12 -1
  347. package/dist/src/personal-agent/specialist-capabilities.js +3 -2
  348. package/dist/src/phone/assistance.js +2 -1
  349. package/dist/src/phone/location-environment.js +2 -1
  350. package/dist/src/phone/repository.js +2 -1
  351. package/dist/src/phone/setup/service.js +2 -1
  352. package/dist/src/projects/index.js +2 -2
  353. package/dist/src/projects/project-kind.d.ts +0 -7
  354. package/dist/src/projects/project-kind.js +1 -6
  355. package/dist/src/projects/project-service.js +1 -9
  356. package/dist/src/realtime/browser-preview-ice.d.ts +2 -0
  357. package/dist/src/realtime/browser-preview-ice.js +42 -0
  358. package/dist/src/realtime/browser-preview.d.ts +45 -0
  359. package/dist/src/realtime/browser-preview.js +191 -0
  360. package/dist/src/realtime/runtime.d.ts +4 -1
  361. package/dist/src/realtime/runtime.js +53 -2
  362. package/dist/src/session/store.js +2 -1
  363. package/dist/src/share/hosted-session-share.js +2 -1
  364. package/dist/src/share/note-share-revocation.js +2 -1
  365. package/dist/src/share/share-store.js +2 -1
  366. package/dist/src/share/site-share-store.js +2 -1
  367. package/dist/src/space/ingest.js +2 -1
  368. package/dist/src/space/workbook-proposals.js +2 -1
  369. package/dist/src/space/workbook-turn.js +2 -1
  370. package/dist/src/space/worker.js +2 -1
  371. package/dist/src/storage/sqlite/durable-state.js +43 -39
  372. package/dist/src/storage/sqlite/session-creation-repository.d.ts +2 -0
  373. package/dist/src/storage/sqlite/session-creation-repository.js +24 -5
  374. package/dist/src/storage/sqlite/session-input-control-repository.js +2 -1
  375. package/dist/src/storage/sqlite/session-input-repository.js +9 -6
  376. package/dist/src/tasks/capabilities/read.js +2 -1
  377. package/dist/src/tasks/capabilities/runs.d.ts +101 -0
  378. package/dist/src/tasks/capabilities/runs.js +41 -34
  379. package/dist/src/tasks/capabilities/write.js +2 -1
  380. package/dist/src/tasks/delegated-run-result.d.ts +16 -0
  381. package/dist/src/tasks/delegated-run-result.js +47 -0
  382. package/dist/src/tasks/index.js +2 -2
  383. package/dist/src/tasks/task-application-service.d.ts +6 -0
  384. package/dist/src/tasks/task-application-service.js +20 -5
  385. package/dist/src/tasks/task-context-assembler.js +10 -6
  386. package/dist/src/tasks/task-contract-planner.js +1 -0
  387. package/dist/src/tasks/task-deliverables.js +19 -14
  388. package/dist/src/tasks/task-handoff.d.ts +20 -3
  389. package/dist/src/tasks/task-handoff.js +207 -146
  390. package/dist/src/tasks/task-json-acceptance.js +3 -2
  391. package/dist/src/tasks/task-main-update-decision-service.js +1 -0
  392. package/dist/src/tasks/task-main-update-delivery.js +4 -2
  393. package/dist/src/tasks/task-origin-repository.d.ts +2 -0
  394. package/dist/src/tasks/task-origin-repository.js +17 -0
  395. package/dist/src/tasks/task-repository.js +3 -0
  396. package/dist/src/tasks/task-research-repair.js +4 -1
  397. package/dist/src/tasks/task-research-result.d.ts +7 -0
  398. package/dist/src/tasks/task-research-result.js +132 -30
  399. package/dist/src/tasks/task-result-delivery-service.js +2 -1
  400. package/dist/src/tasks/task-run-coordinator.js +3 -2
  401. package/dist/src/tasks/task-run-repository.d.ts +2 -1
  402. package/dist/src/tasks/task-run-repository.js +9 -4
  403. package/dist/src/video-generation/artifact.js +2 -1
  404. package/dist/src/video-generation/drafts.js +2 -1
  405. package/dist/src/video-generation/repository.js +2 -1
  406. package/dist/src/video-generation/settings.js +2 -1
  407. package/package.json +3 -1
  408. package/dist/gateway/static/root/assets/block-editor-Cvy3D_4T.css +0 -1
  409. package/dist/gateway/static/root/assets/confirm-dialog-MHCmEEUZ.js +0 -1
  410. package/dist/gateway/static/root/assets/gateway-realtime-CoIFB3im.js +0 -1
  411. package/dist/gateway/static/root/assets/gateway-realtime-store-CTWm23Qi.js +0 -1
  412. package/dist/gateway/static/root/assets/index-B_TGvH_k.css +0 -1
  413. package/dist/gateway/static/root/assets/index-CJAEAcZV.js +0 -11
  414. package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-DlGDLJI2.js +0 -1
  415. package/dist/gateway/static/root/assets/messages-C7QSnTdg.js +0 -3
  416. package/dist/gateway/static/root/assets/note-detail-panel-uc-5k3a2.js +0 -7
  417. package/dist/gateway/static/root/assets/note-image-lightbox-Bvjumefe.js +0 -1
  418. package/dist/gateway/static/root/assets/product-automation-feedback-DdFoCDzG.js +0 -1
  419. package/dist/gateway/static/root/assets/project-detail-page-DGPfKx5M.js +0 -7
  420. package/dist/gateway/static/root/assets/recording-upload-plrQDkLa.js +0 -1
  421. package/dist/gateway/static/root/assets/right-workspace-store-Cehybf-G.js +0 -1
  422. package/dist/gateway/static/root/assets/settings-advanced-gate-Cq4HDQu2.js +0 -1
  423. package/dist/gateway/static/root/assets/space-page-DwyuUvI3.js +0 -2
  424. package/dist/gateway/static/root/assets/turn-outcome-Dtw6OgwL.js +0 -1
  425. package/dist/gateway/static/root/assets/voice-input-shortcut-events-DN-_rY5a.js +0 -1
  426. package/dist/gateway/static/root/assets/workspace-editor-agent-store-CX8zX9eZ.js +0 -1
@@ -1,33 +1,33 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mcp-conversation-setup-page-DffQKrjd.js","assets/rolldown-runtime-aKtaBQYM.js","assets/vendor-react-BOUWij0V.js","assets/chunk-KS7C4IRE-DIIvxCDx.js","assets/preload-helper-Czpn1I53.js","assets/locale-store-CHjsq5NR.js","assets/messages-C7QSnTdg.js","assets/dist-DlirbHVs.js","assets/es2015-CFqg57eW.js","assets/dist-CDSvxjOh.js","assets/check-DUBLcKHA.js","assets/createLucideIcon-DPHK1VkS.js","assets/secret-input-DsjfQmDn.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-C5tRaJxt.js","assets/agent-plugin-dialog-CSJC1yud.js","assets/arrow-left-D880xG-P.js","assets/chevron-down-ccbiQQz_.js","assets/working-directory-picker-modal-DgM21YVT.js","assets/file-archive-DanfQJNe.js","assets/settings-form-draft-Dy10ldo8.js","assets/circle-alert-BEjgurr2.js","assets/circle-BoO4YvTx.js","assets/folder-open-CyzJ19I9.js","assets/package-wATCyihJ.js","assets/shield-check-BU58siTV.js","assets/upload-rrb46c3c.js","assets/capability-links-MZdYfPKx.js","assets/connection-usage-BhdQRWgQ.js","assets/browser-BLJWD7WI.js","assets/capability-icon-CmvCZOJX.js","assets/chat-terminal-dock-DCUuwiTt.js","assets/plus-Q2yW6OE7.js","assets/square-terminal-K87bylpZ.js","assets/session-api-CR3NLqvs.js","assets/schemas-CCWMleym.js","assets/gateway-startup-retry-DgmvR-hb.js","assets/session-manager-C2MCS4C5.js","assets/marked.esm-8VXEA2AD.js","assets/turn-outcome-Dtw6OgwL.js","assets/product-delivery-4gEqUIsK.js","assets/local-session-drafts-CGSV1RQg.js","assets/tool-activity-BtJkgjFf.js","assets/attachment-utils-core-BPYdUI6y.js","assets/agent-run-error-parser-DsXmcKt-.js","assets/gateway-realtime-CoIFB3im.js","assets/gateway-realtime-store-CTWm23Qi.js","assets/playback-coordinator-CWHIf0wr.js","assets/registry-api-CDpUAb2R.js","assets/agents-admin-api-DSr-PWuW.js","assets/gateway-config-swr-BD-ams0X.js","assets/sliding-tab-list-CmcrqRzN.js","assets/sliding-indicator-hwz0sx3h.js","assets/terminal-panel-store-Cy90Ix5U.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,r as i,t as a}from"./marked.esm-8VXEA2AD.js";import{a as o,i as s,n as c,t as l}from"./vendor-react-BOUWij0V.js";import{t as u}from"./preload-helper-Czpn1I53.js";import{_ as d,d as f,f as p,h as m,t as h}from"./chunk-KS7C4IRE-DIIvxCDx.js";import{a as g,i as _,l as v,n as y,o as b,p as x,u as S}from"./locale-store-CHjsq5NR.js";import{t as C}from"./messages-C7QSnTdg.js";import{a as w,c as T,i as E,n as D,o as O,r as k,s as A,t as j}from"./dist-DlirbHVs.js";import{t as M}from"./createLucideIcon-DPHK1VkS.js";import{t as N}from"./app-window-DXFNqt_0.js";import{t as P}from"./archive-Dz0hferG.js";import{t as F}from"./arrow-left-D880xG-P.js";import{a as I,n as L}from"./video-generation-Cec49Jwg.js";import{t as R}from"./arrow-up-D5ZtR1QT.js";import{a as z,c as B,o as V,s as H,t as U}from"./product-automation-feedback-DdFoCDzG.js";import{n as W,t as ee}from"./earth-C9Z4bTTG.js";import{t as te}from"./bot-DjLkhyZL.js";import{t as ne}from"./check-DUBLcKHA.js";import{t as re}from"./chevron-down-ccbiQQz_.js";import{t as ie}from"./chevron-right-BweFrslA.js";import{i as ae,r as oe,t as se}from"./working-directory-picker-modal-DgM21YVT.js";import{a as ce,d as le,n as ue,o as de,r as fe,t as pe}from"./popover-select-hRG1EzAY.js";import{t as G}from"./circle-alert-BEjgurr2.js";import{n as me,t as he}from"./send-1f1Ntw6E.js";import{t as K}from"./circle-x-DFsCKeya.js";import{t as ge}from"./circle-BoO4YvTx.js";import{i as _e,n as q,r as ve,t as ye}from"./file-tree-utils-DJs1faGv.js";import{t as J}from"./copy-Dv6d4Dvw.js";import{t as be}from"./database-CjjeZfRG.js";import{t as xe}from"./download-Dk-ZjtO6.js";import{t as Se}from"./ellipsis-0k4rZLoy.js";import{t as Ce}from"./external-link-DjqjBmc3.js";import{t as we}from"./file-code-corner-byQA1VfD.js";import{t as Te}from"./file-image-CDUPkZvG.js";import{t as Ee}from"./file-text-D12HbeVy.js";import{t as De}from"./file-CStvVK2S.js";import{t as Oe}from"./folder-kanban-CpLlFI1o.js";import{t as ke}from"./folder-open-CyzJ19I9.js";import{t as Ae}from"./folder-CN-pC3XL.js";import{t as je}from"./git-branch-Dh9uxTot.js";import{t as Me}from"./globe-DSSGFWFn.js";import{t as Ne}from"./history-DXH_9jsE.js";import{F as Pe,I as Fe,R as Ie,c as Le,g as Re,o as ze,t as Be,v as Ve}from"./notes-api-D5SvfybU.js";import{t as He}from"./key-round-DWbpyU2U.js";import{t as Ue}from"./laptop-CI3hBVrl.js";import{t as We}from"./link-2-D_ZKYUW7.js";import{t as Ge}from"./list-checks-BbsExAoq.js";import{t as Ke}from"./list-todo-CTVRto8O.js";import{t as qe}from"./loader-circle-CifKLtgG.js";import{A as Je,B as Ye,C as Xe,D as Ze,F as Qe,P as $e,R as et,S as tt,T as nt,_ as rt,b as it,c as at,d as ot,f as st,g as ct,h as lt,l as ut,m as dt,n as ft,p as pt,r as mt,u as ht,v as gt,w as _t,y as vt}from"./markdown-view-ihzUc4ud.js";import{t as yt}from"./messages-square-BckAJrEW.js";import{t as bt}from"./mic-CuUb7zc-.js";import{t as xt}from"./monitor-Af5eAvF7.js";import{c as St,l as Ct,n as wt,r as Tt,t as Et}from"./use-generated-media-CzRbgtcv.js";import{s as Dt,t as Ot}from"./install-connector-dialog-CntHi8Rh.js";import{t as kt}from"./paperclip-f1HujQY1.js";import{t as At}from"./pause-DuPxgSxk.js";import{t as jt}from"./pencil-DmIY3Oa-.js";import{n as Mt,t as Nt}from"./pin-off-BMRv-Kxr.js";import{t as Pt}from"./play-kxZvpBg8.js";import{t as Ft}from"./plus-Q2yW6OE7.js";import{t as It}from"./refresh-cw-BRlGaq2w.js";import{t as Lt}from"./rotate-ccw-JM1TBLpp.js";import{t as Rt}from"./save-DRDABU--.js";import{t as zt}from"./search-DA7gz22f.js";import{t as Bt}from"./settings-2-D-csvaET.js";import{t as Vt}from"./settings-uiTATseT.js";import{t as Ht}from"./share-2-CnIB9PsV.js";import{t as Ut}from"./shield-check-BU58siTV.js";import{t as Wt}from"./smartphone-DSSsQFqA.js";import{t as Gt}from"./sparkles-DHlfQFAF.js";import{t as Kt}from"./square-DMK_fB-3.js";import{a as qt,d as Jt,o as Yt}from"./preview-runtime-FtWOW5i4.js";import{t as Xt}from"./trash-2-DusmjVPV.js";import{t as Zt}from"./triangle-alert-2JXFNNKU.js";import{t as Qt}from"./user-round-C9jxPhMR.js";import{t as $t}from"./volume-2-BSJhAY97.js";import{t as en}from"./wifi-off-C35sMFUl.js";import{r as tn,t as nn}from"./share-link-dialog-2JjvWs0q.js";import{t as rn}from"./wrench-DFb4r8bH.js";import{t as an}from"./x-B_N4OPjy.js";import{t as on}from"./zap-dximCGjy.js";import{t as Y}from"./cn-0WouolD0.js";import{t as sn}from"./skeleton-DzdOeGYz.js";import{a as cn,d as ln,m as un,n as dn,u as fn}from"./schemas-CCWMleym.js";import{a as pn,d as mn,h as hn,m as gn,n as _n,r as vn}from"./product-delivery-4gEqUIsK.js";import{p as yn,t as bn}from"./tasks-CvOAtEHv.js";import{a as xn,c as Sn,d as Cn}from"./api-CGrHK9ij.js";import{a as wn,c as Tn,l as En,p as Dn,s as On}from"./session-api-CR3NLqvs.js";import{n as kn}from"./session-identity-DRFdxntH.js";import{$ as An,A as jn,B as Mn,C as Nn,Ct as Pn,D as Fn,Dt as In,E as Ln,Et as Rn,F as zn,G as Bn,H as Vn,I as Hn,J as Un,K as Wn,L as Gn,M as Kn,N as qn,O as Jn,Ot as Yn,P as Xn,Q as Zn,R as Qn,S as $n,St as er,T as tr,Tt as nr,U as rr,V as ir,W as ar,X as or,Z as sr,_ as cr,_t as lr,at as ur,bt as dr,c as fr,d as pr,dt as mr,et as hr,ft as gr,g as _r,h as vr,ht as yr,it as br,j as xr,k as Sr,kt as Cr,lt as wr,m as Tr,mt as Er,nt as Dr,o as Or,ot as kr,p as Ar,q as jr,r as Mr,rt as Nr,s as Pr,st as Fr,t as Ir,tt as Lr,ut as Rr,v as zr,vt as Br,w as Vr,wt as Hr,x as Ur,xt as Wr,yt as Gr,z as Kr}from"./session-manager-C2MCS4C5.js";import{c as qr,d as Jr,f as Yr,h as Xr,m as Zr,n as Qr,o as $r,s as ei,t as ti}from"./local-session-drafts-CGSV1RQg.js";import{t as ni}from"./tool-activity-BtJkgjFf.js";import{a as ri,c as ii,i as ai,l as oi,n as si,o as ci,r as li,s as ui,t as di}from"./new-session-preferences-gb411vZP.js";import{n as fi,t as pi}from"./composer-model-config-control-C2Bku39S.js";import{n as mi}from"./cloud-credits-B-nbtkqv.js";import{a as hi,d as gi,g as _i,o as vi,r as yi}from"./space-api-_uKFiASp.js";import{i as bi,t as xi}from"./vendor-swr-CdRzEUwF.js";import{C as Si,a as Ci,g as wi,i as Ti,l as Ei,o as Di,r as Oi,s as ki,y as Ai}from"./home-task-actions-_ZAc57Y7.js";import{a as ji}from"./gateway-config-swr-BD-ams0X.js";import{t as Mi}from"./chat-agents-api-CyvBfBbp.js";import{a as Ni,c as Pi,i as Fi,l as Ii,n as Li,o as Ri}from"./attachment-utils-core-BPYdUI6y.js";import{a as zi,n as Bi,r as Vi}from"./agent-run-error-parser-DsXmcKt-.js";import{n as Hi}from"./gateway-realtime-CoIFB3im.js";import{n as Ui}from"./gateway-realtime-store-CTWm23Qi.js";import{s as Wi,t as Gi}from"./playback-coordinator-CWHIf0wr.js";import{n as Ki,t as qi}from"./registry-api-CDpUAb2R.js";import{a as Ji}from"./agents-admin-api-DSr-PWuW.js";import{t as Yi}from"./button-C5tRaJxt.js";import{r as Xi}from"./right-workspace-store-Cehybf-G.js";import{a as Zi,i as Qi,o as $i,r as ea,s as ta}from"./dist-BSVQC3i_.js";import{t as na}from"./middleware-Pd0e8Igk.js";import{i as ra,r as ia}from"./app-link-Ji4uewEG.js";import{t as aa}from"./copy-to-clipboard-HOJ79TWv.js";import{t as oa}from"./task-copy-CtcqCQ78.js";import{C as sa,D as ca,E as la,T as ua,_ as da,b as fa,c as pa,d as ma,f as ha,g as ga,h as _a,m as va,n as ya,o as ba,p as xa,r as Sa,s as Ca,u as wa,v as Ta,w as Ea,x as Da,y as Oa}from"./chunk-D32TOXHM-DQIy-Baq.js";import{i as ka,n as Aa,r as ja,t as Ma}from"./chat-chart-block-B83s8HE9.js";import{t as Na}from"./linkify-it-BkqEorO0.js";import{n as Pa}from"./interaction-BdhHBbYa.js";import{a as Fa,i as Ia,n as La,o as Ra,r as za,s as Ba,t as Va}from"./tool-friendly-title-CJVFJ2Ud.js";import{s as Ha}from"./connectors-api-CRGq-TSw.js";import{t as Ua}from"./use-realtime-voice-CV3GIt_T.js";import{t as Wa}from"./activity-store-hSe5Nbgk.js";import{t as Ga}from"./composer-notifications-MGKffwC7.js";import{n as Ka}from"./voice-call-context-BM2A4bLz.js";import{r as qa}from"./app-chrome-BeB4KgOf.js";import{i as Ja,n as Ya,r as Xa}from"./form-field-width-DJw_jULe.js";import{n as Za}from"./electron-env-DHOGevH3.js";import{t as Qa}from"./page-header-store-NP7MCIaP.js";import{n as $a,t as eo}from"./new-chat-navigation-spnin196.js";import{t as to}from"./use-async-resource-BHFGZCY2.js";import{t as no}from"./loopi-CNtmi9FU.js";import{a as ro}from"./extension-provider-D8_mIBI0.js";import{t as io}from"./agent-avatar-display-D_UDgOr9.js";import{a as ao,n as oo,r as so,t as co}from"./skill-wire-pattern-BPpeIcCi.js";import{a as lo,i as uo,o as fo,t as po}from"./composer-handoff-params-DBpzHuNo.js";import{n as mo,t as ho}from"./agent-display-names-Bje7vfSn.js";import{n as go,t as _o}from"./use-directory-picker-C4p7AgWY.js";import{t as vo}from"./confirm-dialog-MHCmEEUZ.js";import{a as yo,c as bo,f as xo,s as So,u as Co}from"./workspace-api-CQOuWbVv.js";import{n as wo}from"./index.module-Cd9ENXfk.js";import{a as To,i as Eo,o as Do,r as Oo,s as ko}from"./copy-text-row-gqdh0Bg1.js";import{_ as Ao,b as jo,d as Mo,f as No,h as Po,i as Fo,n as Io,p as Lo,s as Ro,u as zo,y as Bo}from"./shares-api-BhWvN3LS.js";import{t as Vo}from"./workspace-editor-agent-store-CX8zX9eZ.js";import{l as Ho,m as Uo,o as Wo,r as Go,t as Ko,u as qo}from"./dist-DaFr5KMw.js";import{n as Jo,r as Yo,t as Xo}from"./use-composer-attachments-BEuyorVm.js";import{_ as Zo,a as Qo,c as $o,d as es,f as ts,g as ns,h as rs,i as is,l as as,m as os,p as ss,s as cs,t as ls,u as us,v as ds}from"./command-palette-api-UrqPvWR1.js";import{a as fs,i as ps,n as ms,o as hs,r as gs,s as _s}from"./composer-payload-handoff-a0quQ25p.js";import{n as vs,o as ys,r as bs,s as xs}from"./voice-input-shortcut-events-DN-_rY5a.js";import{_ as Ss,g as Cs,i as ws,t as Ts,v as Es,y as Ds}from"./automation-task-card-C453Q-Wa.js";import{t as Os}from"./dev-view-store-DsjH8x76.js";import{t as ks}from"./extension-iframe-host-CJV5JETm.js";import{i as As,r as js,t as Ms}from"./runtime-health-zDkHcOZO.js";import{c as Ns,i as Ps,r as Fs}from"./api-B3T06TLl.js";import{r as Is}from"./terminal-panel-store-Cy90Ix5U.js";import{n as Ls}from"./agents-app-path-ciChvpCS.js";import{t as Rs}from"./oauth-provider-connect-DGYky6ut.js";import{t as zs}from"./use-media-query-ady-FgjK.js";import{n as Bs,r as Vs,t as Hs}from"./oauth-authorization-window-o6URRos4.js";import{n as Us,t as Ws}from"./page-context-draft-Bk7jVvAG.js";import{i as Gs,r as Ks}from"./management-api-FVu7eYXD.js";import{t as qs}from"./side-chat-shortcut-BIw-1TTD.js";var Js=M(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),Ys=M(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),Xs=M(`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`}]]),Zs=M(`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`}]]),Qs=M(`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`}]]),$s=M(`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`}]]),ec=M(`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`}]]),tc=M(`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`}]]),nc=M(`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`}]]),rc=M(`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`}]]),ic=M(`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`}]]),ac=M(`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`}]]),oc=M(`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`}]]),sc=M(`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`}]]),cc=M(`message-square-quote`,[[`path`,{d:`M14 14a2 2 0 0 0 2-2V8h-2`,key:`1r06pg`}],[`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:`M8 14a2 2 0 0 0 2-2V8H8`,key:`1jzu5j`}]]),lc=M(`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`}]]),uc=M(`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`}]]),dc=M(`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`}]]),fc=M(`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`}]]),pc=M(`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`}]]),mc=M(`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`}]]),hc=M(`video`,[[`path`,{d:`m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5`,key:`ftymec`}],[`rect`,{x:`2`,y:`6`,width:`14`,height:`12`,rx:`2`,key:`158x01`}]]),gc=M(`volume-x`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`line`,{x1:`22`,x2:`16`,y1:`9`,y2:`15`,key:`1ewh16`}],[`line`,{x1:`16`,x2:`22`,y1:`9`,y2:`15`,key:`5ykzw1`}]]),_c=M(`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 vc(e,t){return e.replace(/\{\{(\w+)}}/g,(e,n)=>t[n]?.trim()??``).replace(/[ \t]{2,}/g,` `).trim()}function yc(e,t,n){return{id:e,title:vc(t.title,n),prompt:vc(t.prompt,n),reason:vc(t.reason,n)}}function bc(e,t){let n={projectName:e.projectName,blockedReason:e.blockedReason,recentFailure:e.recentFailure,nextAction:e.recommendedAction};if(e.blockedReason?.trim())return yc(`project-blocked`,t.recommendations.projectBlocked,n);if(e.recentFailure?.trim())return yc(`project-failure`,t.recommendations.projectFailure,n);if(e.recommendedAction?.trim())return yc(`project-next-action`,t.recommendations.projectNextAction,n)}function xc(e,t){let n={taskTitle:e.taskTitle,attentionSummary:e.attentionSummary,recentFailure:e.recentFailure,nextAction:e.nextAction};if(e.attentionSummary?.trim())return yc(`task-attention`,t.recommendations.taskAttention,n);if(e.recentFailure?.trim())return yc(`task-failure`,t.recommendations.taskFailure,n);if(e.phase===`review`||e.operationalState===`verifying`)return yc(`task-review`,t.recommendations.taskReview,n);if(e.phase===`closed`)return yc(`task-closed`,t.recommendations.taskClosed,n);if(e.nextAction?.trim())return yc(`task-next-action`,t.recommendations.taskNextAction,n)}function Sc(e,t){switch(e.kind){case`project`:return bc(e,t);case`task`:return xc(e,t);default:return}}function Cc(e,t,n={}){let r=n.contextStatus??`ready`;return{headline:e.kind===`project`&&t.projectHeadline?vc(t.projectHeadline,{projectName:e.projectName}):t.headline,contextKind:e.kind,contextStatus:r,recommendation:r===`ready`?Sc(e,t):void 0}}var wc=ln({id:un().uuid(),conversationId:un(),transcriptId:un(),sourceRunId:un(),inputRevision:fn().int().nonnegative(),transcriptCursor:fn().int().nonnegative(),agentId:un(),locale:dn([`zh`,`en`]),prompt:un().min(1).max(160),expiresAt:fn()}),Tc=ln({status:dn([`ready`,`pending`,`none`]),suggestion:wc.optional()});ln({suggestionId:un().uuid(),impressionId:un().uuid(),event:dn([`shown`,`accepted`,`dismissed`,`submitted`]),edited:cn().optional()}).strict();function Ec(e,t=`body`){return`result:${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Dc(e){return`${e.taskRunId}:${e.assignmentEpoch}:${e.outcome.outcomeId}`}var Oc=e(s(),1),X=l(),Z=c(),Q=e(o(),1);function kc(e,t){return e?[`task-detail`,e,t??``]:null}function Ac(e,t){return t.source!==`user`||e===void 0||t.version>e}function jc(e,t){let n=(0,Z.c)(5),r=v(Mc),i;n[0]!==e||n[1]!==r?(i=kc(e,r),n[0]=e,n[1]=r,n[2]=i):i=n[2];let a;return n[3]===e?a=n[4]:(a=()=>Ai(e),n[3]=e,n[4]=a),bi(i,a,t)}function Mc(e){return e.conversationId}function Nc(e){let[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(null),s=(0,Q.useRef)(``),c=(0,Q.useRef)(void 0),l=jc(e,{keepPreviousData:!1,revalidateOnFocus:!0,revalidateOnReconnect:!0,refreshInterval:e=>e&&[`allocating`,`queued`,`running`,`waiting`,`verifying`].includes(e.operationalState)?5e3:0});return c.current=l.data?.task.version,(0,Q.useEffect)(()=>{n(null),i(!1),o(null),s.current=``},[e]),(0,Q.useEffect)(()=>{let t=l.data;if(!t||t.conversation.activeConversationId||t.allocation&&t.allocation.status!==`assigned`)return;let n=`${e}:${t.task.version}`;s.current!==n&&(s.current=n,i(!0),o(null),wi(e).then(()=>s.current===n?l.mutate():void 0).catch(e=>{s.current===n&&o(e)}).finally(()=>{s.current===n&&i(!1)}))},[l.data,l.mutate,e]),(0,Q.useEffect)(()=>{let t,r=()=>{window.clearTimeout(t),t=window.setTimeout(()=>void l.mutate(),120)},i=t=>{let i=bn.safeParse(t.detail);!i.success||i.data.taskId!==e||Ac(c.current,i.data)&&(n(i.data),r())},a=()=>r();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)}},[l.mutate,e]),{...l,lastChange:t,conversationLoading:r,conversationError:a}}var Pc=new Map,Fc=new Set;function Ic(e,t){Pc.set(e,t);for(let e of Fc)e();return()=>{Pc.get(e)===t&&Pc.delete(e)}}async function Lc(e,t,n){await(Pc.get(e)??await new Promise((t,n)=>{let r=()=>{let n=Pc.get(e);n&&(clearTimeout(i),Fc.delete(r),t(n))},i=setTimeout(()=>{Fc.delete(r),n(Error(`Chat input is not ready. Please retry.`))},15e3);Fc.add(r),r()}))(t,n)}var Rc=crypto.randomUUID(),zc=e=>e===`closed`;function Bc(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 Vc=e=>`/api/phone/conversations/${encodeURIComponent(e)}`,Hc=new Map,Uc=()=>{let e=v.getState();return`${e.baseUrl}:${e.conversationId}`};function Wc(e,t,n=Uc()){let r=`${n}:${e}`,i=Hc.get(r);return t&&i&&t.report.sessionId===i.report.sessionId&&(t.report.revision??0)<(i.report.revision??0)?i:(t?(Hc.set(r,t),Hc.size>100&&Hc.delete(Hc.keys().next().value)):Hc.delete(r),t)}async function Gc(e,t=Uc()){let n=await g(_(e)),r=decodeURIComponent(e.split(`/conversations/`)[1]?.split(`?`)[0]??``);if(n.status===404)return Wc(r,null,t);if((n.status===401||n.status===403)&&Wc(r,null,t),!n.ok)throw Object.assign(Error(`Phone view unavailable (HTTP ${n.status})`),{status:n.status});return Wc(r,(await n.json()).payload,t)}function Kc(e,t){let n=(0,Z.c)(5),r=t===void 0||t,i=v(Yc),a;n[0]!==e||n[1]!==r||n[2]!==i?(a=r&&/^(?:device:)?[\da-f]{8}-[\da-f-]{27}$/i.test(e)?[`${Vc(e)}?clientId=${Rc}`,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:qc,errorRetryCount:6,errorRetryInterval:2e3,refreshWhenHidden:!1},n[4]=o):o=n[4],bi(a,Jc,o)}function qc(e){return e.status!==401&&e.status!==403}function Jc(e){let[t,n]=e;return Gc(t,n)}function Yc(e){return`${e.baseUrl}:${e.conversationId}`}async function Xc(e,t,n,r={},i=!1){let a=Uc();return Wc(e,(await b(_(`${Vc(e)}/${t.report.sessionId}/control`),{method:`POST`,keepalive:i,body:JSON.stringify({expectedTranscriptId:t.report.transcriptId,clientId:Rc,assistanceId:t.report.assistanceId,assistanceVersion:t.report.assistanceVersion,operationId:crypto.randomUUID(),epoch:t.report.controlEpoch,op:n,...r})})).payload,a)}async function Zc(e,t,n){let r=await g(_(`${Vc(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 Qc(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 $c(e,t,n,r=!1){return(await b(_(`${Vc(e)}/${t.report.sessionId}/execution-mode`),{method:`POST`,body:JSON.stringify({executionMode:n,applyCurrent:r,epoch:t.report.controlEpoch,clientId:Rc})})).payload}function el(e,t){if(!t.assistanceId||![`needs_user`,`paused`].includes(t.status))return null;let n=v.getState();return JSON.stringify([n.baseUrl,n.conversationId,e,t.transcriptId,t.assistanceId,t.assistanceVersion??1])}var tl=x(na(e=>({seen:[],markSeen:t=>e(e=>e.seen.includes(t)?e:{seen:[...e.seen.slice(-99),t]})}),{name:`xopc-phone-attention-v1`}));function nl(e){let t=(0,Z.c)(18),{detail:n,language:r}=e,i,a,o;t[0]!==n||t[1]!==r?(i=Ei(n),o=r===`zh`,a=i.receipt?oa(r).resultStatuses[yn(i.receipt)]:o?`尚无本版任务的执行结果`:`No run result for this task version`,t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o):(i=t[2],a=t[3],o=t[4]);let s=a,c=o?`执行、验收与交付`:`Execution, acceptance and delivery`,l=n.task.phase===`closed`?``:o?`;任务仍未关闭`:`; task remains open`,u;t[5]!==s||t[6]!==l?(u=(0,X.jsxs)(`p`,{children:[s,l]}),t[5]=s,t[6]=l,t[7]=u):u=t[7];let d=o?`验收:${i.verified}/${i.criteria} 项通过`:`Acceptance: ${i.verified}/${i.criteria} criteria passed`,f=i.criteria===0?o?`,尚未定义验收标准`:`; criteria not defined`:``,p;t[8]!==d||t[9]!==f?(p=(0,X.jsxs)(`p`,{children:[d,f]}),t[8]=d,t[9]=f,t[10]=p):p=t[10];let m=i.deliverables>0?o?`已关联交付物:${i.deliverables} 项`:`Linked deliverables: ${i.deliverables}`:o?`尚无正式交付物`:`No formal deliverables linked`,h;t[11]===m?h=t[12]:(h=(0,X.jsx)(`p`,{children:m}),t[11]=m,t[12]=h);let g;return t[13]!==c||t[14]!==u||t[15]!==p||t[16]!==h?(g=(0,X.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[13]=c,t[14]=u,t[15]=p,t[16]=h,t[17]=g):g=t[17],g}var rl=(0,Q.memo)(function(e){let t=(0,Z.c)(58),{taskId:n}=e,r=f(),i=y(il),a;t[0]===i?a=t[1]:(a=oa(i),t[0]=i,t[1]=a);let o=a,{data:s}=Nc(n);if(!s)return null;let{task:c,operationalState:l}=s,u,d,p,m;if(t[2]!==o.noDecisionNeeded||t[3]!==s||t[4]!==l||t[5]!==c.phase){let e=Ci(s);p=s.attention.length>0;let n;t[10]!==l||t[11]!==c.phase?(n=c.phase!==`closed`&&[`queued`,`running`,`verifying`].includes(l),t[10]=l,t[11]=c.phase,t[12]=n):n=t[12],d=n,u=p?s.attention[0]?.summary??e?.nextAction??e?.summary:c.phase===`closed`?e?.summary:e?.nextAction??e?.summary??o.noDecisionNeeded,m=e?.evidence.filter(al).length??0,t[2]=o.noDecisionNeeded,t[3]=s,t[4]=l,t[5]=c.phase,t[6]=u,t[7]=d,t[8]=p,t[9]=m}else u=t[6],d=t[7],p=t[8],m=t[9];let g=m,_=o.taskProgress.title,v;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,X.jsx)(mc,{className:`size-4`,"aria-hidden":!0}),t[13]=v):v=t[13];let b;t[14]===d?b=t[15]:(b=d?(0,X.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]=d,t[15]=b);let x;t[16]===b?x=t[17]:(x=(0,X.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:[v,b]}),t[16]=b,t[17]=x);let S;t[18]===o.taskProgress.title?S=t[19]:(S=(0,X.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`,ki(Di(s))),t[20]=s,t[21]=C);let w=o.detailStatuses[Di(s)],T;t[22]!==C||t[23]!==w?(T=(0,X.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]!==g?(E=g>0?(0,X.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[g,` `,o.taskProgress.evidence]}):null,t[25]=o.taskProgress.evidence,t[26]=g,t[27]=E):E=t[27];let D;t[28]!==T||t[29]!==E||t[30]!==S?(D=(0,X.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]===c.title?O=t[33]:(O=(0,X.jsx)(`p`,{className:`mt-1 text-sm font-medium leading-5 text-fg`,children:c.title}),t[32]=c.title,t[33]=O);let k;t[34]===u?k=t[35]:(k=u?(0,X.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:u}):null,t[34]=u,t[35]=k);let A;t[36]!==D||t[37]!==O||t[38]!==k?(A=(0,X.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]!==c.id?(M=Qe(j,c.id),t[40]=j,t[41]=c.id,t[42]=M):M=t[42];let N=p?o.taskProgress.decide:o.taskProgress.open,P;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,X.jsx)(Ce,{className:`size-3.5`,"aria-hidden":!0}),t[43]=P):P=t[43];let F;t[44]!==M||t[45]!==N?(F=(0,X.jsxs)(h,{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,X.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,X.jsx)(nl,{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,X.jsxs)(`section`,{className:`mb-6 rounded-xl border border-edge bg-surface-panel px-3 py-3 sm:px-4`,"aria-label":_,"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 il(e){return e.language}function al(e){return e.strength===`verified`}function ol(e){return e===-5||e===-4||e===-3?`
3
- `:e<0?` `:String.fromCharCode(e)}var sl={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 cl(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?tt(a):Xe(a))?(c&&t.exit(`xopcMathValue`),t.exit(l),n(i)):r(i)}function f(n){if(n===null)return d(n);let l=ol(n);if(l===`
4
- `)return e&&i.interrupt||!e||o?d(n):(c&&t.exit(`xopcMathValue`),c=!1,t.attempt(sl,e=>(a+=`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mcp-conversation-setup-page-D_6XeyXG.js","assets/rolldown-runtime-aKtaBQYM.js","assets/vendor-react-BOUWij0V.js","assets/chunk-KS7C4IRE-DIIvxCDx.js","assets/preload-helper-Czpn1I53.js","assets/locale-store-Dy0B0XDJ.js","assets/messages-Bj6DCoic.js","assets/dist-DlirbHVs.js","assets/es2015-CFqg57eW.js","assets/dist-CDSvxjOh.js","assets/check-DUBLcKHA.js","assets/createLucideIcon-DPHK1VkS.js","assets/secret-input-DsjfQmDn.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-C5tRaJxt.js","assets/agent-plugin-dialog-RZpnW9HG.js","assets/arrow-left-D880xG-P.js","assets/chevron-down-ccbiQQz_.js","assets/working-directory-picker-modal-DX6bRmkQ.js","assets/file-archive-DanfQJNe.js","assets/settings-form-draft-Dy10ldo8.js","assets/circle-alert-BEjgurr2.js","assets/circle-BoO4YvTx.js","assets/folder-open-CyzJ19I9.js","assets/package-wATCyihJ.js","assets/shield-check-BU58siTV.js","assets/upload-rrb46c3c.js","assets/capability-links-MZdYfPKx.js","assets/connection-usage-BhdQRWgQ.js","assets/browser-BLJWD7WI.js","assets/capability-icon-CmvCZOJX.js","assets/chat-terminal-dock-Ch74AWYF.js","assets/plus-Q2yW6OE7.js","assets/square-terminal-K87bylpZ.js","assets/session-api-vEn4BzjV.js","assets/schemas-CCWMleym.js","assets/gateway-startup-retry-Dm0dK8BT.js","assets/session-manager-7nbjJYyy.js","assets/marked.esm-8VXEA2AD.js","assets/turn-outcome-Bf3N3Bmj.js","assets/product-delivery-4gEqUIsK.js","assets/local-session-drafts-KkAOxXk5.js","assets/tool-activity-BtJkgjFf.js","assets/attachment-utils-core-BPYdUI6y.js","assets/agent-run-error-parser-DsXmcKt-.js","assets/gateway-realtime-D2B_nv2b.js","assets/gateway-realtime-store-DrVbjYfI.js","assets/playback-coordinator-CWHIf0wr.js","assets/registry-api-CaBz9f4g.js","assets/agents-admin-api-BW3Mzst8.js","assets/gateway-config-swr-DxelrRtx.js","assets/sliding-tab-list-CmcrqRzN.js","assets/sliding-indicator-hwz0sx3h.js","assets/terminal-panel-store-BOHv5O2x.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,r as i,t as a}from"./marked.esm-8VXEA2AD.js";import{a as o,i as s,n as c,t as l}from"./vendor-react-BOUWij0V.js";import{t as u}from"./preload-helper-Czpn1I53.js";import{_ as d,d as f,f as p,h as m,t as h}from"./chunk-KS7C4IRE-DIIvxCDx.js";import{a as g,i as _,l as v,n as y,o as b,p as x,u as S}from"./locale-store-Dy0B0XDJ.js";import{t as C}from"./messages-Bj6DCoic.js";import{a as w,c as T,i as E,n as D,o as O,r as k,s as A,t as j}from"./dist-DlirbHVs.js";import{t as M}from"./createLucideIcon-DPHK1VkS.js";import{t as N}from"./app-window-DXFNqt_0.js";import{t as P}from"./archive-Dz0hferG.js";import{t as F}from"./arrow-left-D880xG-P.js";import{a as I,n as L}from"./video-generation-Cec49Jwg.js";import{t as R}from"./arrow-up-D5ZtR1QT.js";import{a as z,i as B,n as V,r as H,t as U}from"./product-automation-feedback-BDFpFrSs.js";import{n as W,t as ee}from"./earth-C9Z4bTTG.js";import{t as te}from"./bot-DjLkhyZL.js";import{t as ne}from"./check-DUBLcKHA.js";import{t as re}from"./chevron-down-ccbiQQz_.js";import{t as ie}from"./chevron-right-BweFrslA.js";import{i as ae,r as oe,t as se}from"./working-directory-picker-modal-DX6bRmkQ.js";import{a as ce,d as le,n as ue,o as de,r as fe,t as pe}from"./popover-select-hRG1EzAY.js";import{t as G}from"./circle-alert-BEjgurr2.js";import{n as me,t as he}from"./send-1f1Ntw6E.js";import{t as K}from"./circle-x-DFsCKeya.js";import{t as ge}from"./circle-BoO4YvTx.js";import{i as _e,n as q,r as ve,t as ye}from"./file-tree-utils-DJs1faGv.js";import{t as J}from"./copy-Dv6d4Dvw.js";import{t as be}from"./database-CjjeZfRG.js";import{t as xe}from"./download-Dk-ZjtO6.js";import{t as Se}from"./ellipsis-0k4rZLoy.js";import{t as Ce}from"./external-link-DjqjBmc3.js";import{t as we}from"./file-code-corner-byQA1VfD.js";import{t as Te}from"./file-image-CDUPkZvG.js";import{t as Ee}from"./file-text-D12HbeVy.js";import{t as De}from"./file-CStvVK2S.js";import{t as Oe}from"./folder-kanban-CpLlFI1o.js";import{t as ke}from"./folder-open-CyzJ19I9.js";import{t as Ae}from"./folder-CN-pC3XL.js";import{t as je}from"./git-branch-Dh9uxTot.js";import{t as Me}from"./globe-DSSGFWFn.js";import{t as Ne}from"./history-DXH_9jsE.js";import{F as Pe,I as Fe,R as Ie,c as Le,g as Re,o as ze,t as Be,v as Ve}from"./notes-api-M1FuRZbW.js";import{t as He}from"./key-round-DWbpyU2U.js";import{t as Ue}from"./laptop-CI3hBVrl.js";import{t as We}from"./link-2-D_ZKYUW7.js";import{t as Ge}from"./list-checks-BbsExAoq.js";import{t as Ke}from"./list-todo-CTVRto8O.js";import{t as qe}from"./loader-circle-CifKLtgG.js";import{A as Je,B as Ye,C as Xe,D as Ze,F as Qe,P as $e,R as et,S as tt,T as nt,_ as rt,b as it,c as at,d as ot,f as st,g as ct,h as lt,l as ut,m as dt,n as ft,p as pt,r as mt,u as ht,v as gt,w as _t,y as vt}from"./markdown-view-ByuzuGRb.js";import{t as yt}from"./messages-square-BckAJrEW.js";import{t as bt}from"./mic-CuUb7zc-.js";import{t as xt}from"./monitor-Af5eAvF7.js";import{c as St,l as Ct,n as wt,r as Tt,t as Et}from"./use-generated-media-DX4_ne7C.js";import{s as Dt,t as Ot}from"./install-connector-dialog-st2O1bez.js";import{t as kt}from"./paperclip-f1HujQY1.js";import{t as At}from"./pause-DuPxgSxk.js";import{t as jt}from"./pencil-DmIY3Oa-.js";import{n as Mt,t as Nt}from"./pin-off-BMRv-Kxr.js";import{t as Pt}from"./play-kxZvpBg8.js";import{t as Ft}from"./plus-Q2yW6OE7.js";import{t as It}from"./refresh-cw-BRlGaq2w.js";import{t as Lt}from"./rotate-ccw-JM1TBLpp.js";import{t as Rt}from"./save-DRDABU--.js";import{t as zt}from"./search-DA7gz22f.js";import{t as Bt}from"./settings-2-D-csvaET.js";import{t as Vt}from"./settings-uiTATseT.js";import{t as Ht}from"./share-2-CnIB9PsV.js";import{t as Ut}from"./shield-check-BU58siTV.js";import{t as Wt}from"./smartphone-DSSsQFqA.js";import{t as Gt}from"./sparkles-DHlfQFAF.js";import{t as Kt}from"./square-DMK_fB-3.js";import{a as qt,d as Jt,o as Yt}from"./preview-runtime-DUJ7XhMP.js";import{t as Xt}from"./trash-2-DusmjVPV.js";import{t as Zt}from"./triangle-alert-2JXFNNKU.js";import{t as Qt}from"./user-round-C9jxPhMR.js";import{t as $t}from"./volume-2-BSJhAY97.js";import{t as en}from"./wifi-off-C35sMFUl.js";import{r as tn,t as nn}from"./share-link-dialog-WR7Op1vL.js";import{t as rn}from"./wrench-DFb4r8bH.js";import{t as an}from"./x-B_N4OPjy.js";import{t as on}from"./zap-dximCGjy.js";import{t as Y}from"./cn-0WouolD0.js";import{t as sn}from"./skeleton-DzdOeGYz.js";import{a as cn,d as ln,m as un,n as dn,u as fn}from"./schemas-CCWMleym.js";import{a as pn,d as mn,h as hn,m as gn,n as _n,r as vn}from"./product-delivery-4gEqUIsK.js";import{p as yn,t as bn}from"./tasks-D8bnpu0N.js";import{a as xn,c as Sn,d as Cn}from"./api-Cd5TqEwc.js";import{a as wn,c as Tn,l as En,p as Dn,s as On}from"./session-api-vEn4BzjV.js";import{n as kn}from"./session-identity-DRFdxntH.js";import{$ as An,A as jn,B as Mn,C as Nn,Ct as Pn,D as Fn,Dt as In,E as Ln,Et as Rn,F as zn,G as Bn,H as Vn,I as Hn,J as Un,K as Wn,L as Gn,M as Kn,N as qn,O as Jn,Ot as Yn,P as Xn,Q as Zn,R as Qn,S as $n,St as er,T as tr,Tt as nr,U as rr,V as ir,W as ar,X as or,Z as sr,_ as cr,_t as lr,at as ur,bt as dr,c as fr,d as pr,dt as mr,et as hr,ft as gr,g as _r,h as vr,ht as yr,it as br,j as xr,k as Sr,kt as Cr,lt as wr,m as Tr,mt as Er,nt as Dr,o as Or,ot as kr,p as Ar,q as jr,r as Mr,rt as Nr,s as Pr,st as Fr,t as Ir,tt as Lr,ut as Rr,v as zr,vt as Br,w as Vr,wt as Hr,x as Ur,xt as Wr,yt as Gr,z as Kr}from"./session-manager-7nbjJYyy.js";import{c as qr,d as Jr,f as Yr,h as Xr,m as Zr,n as Qr,o as $r,s as ei,t as ti}from"./local-session-drafts-KkAOxXk5.js";import{t as ni}from"./tool-activity-BtJkgjFf.js";import{a as ri,i as ii,n as ai,o as oi,r as si,s as ci,t as li}from"./new-session-preferences-CxCn2Jxk.js";import{n as ui,t as di}from"./composer-model-config-control-Bas1wFVW.js";import{n as fi}from"./cloud-credits-B-nbtkqv.js";import{a as pi,d as mi,g as hi,o as gi,r as _i}from"./space-api-E8VbAaEl.js";import{i as vi,t as yi}from"./vendor-swr-CdRzEUwF.js";import{C as bi,a as xi,g as Si,i as Ci,l as wi,o as Ti,r as Ei,s as Di,y as Oi}from"./home-task-actions-GAO06s1_.js";import{a as ki}from"./gateway-config-swr-DxelrRtx.js";import{t as Ai}from"./chat-agents-api-DRKlkcuv.js";import{a as ji,c as Mi,i as Ni,l as Pi,n as Fi,o as Ii}from"./attachment-utils-core-BPYdUI6y.js";import{a as Li,n as Ri,r as zi}from"./agent-run-error-parser-DsXmcKt-.js";import{r as Bi}from"./gateway-realtime-D2B_nv2b.js";import{n as Vi}from"./gateway-realtime-store-DrVbjYfI.js";import{s as Hi,t as Ui}from"./playback-coordinator-CWHIf0wr.js";import{n as Wi,t as Gi}from"./registry-api-CaBz9f4g.js";import{a as Ki}from"./agents-admin-api-BW3Mzst8.js";import{t as qi}from"./button-C5tRaJxt.js";import{r as Ji}from"./right-workspace-store-CcRApllu.js";import{a as Yi,i as Xi,o as Zi,r as Qi,s as $i}from"./dist-BSVQC3i_.js";import{t as ea}from"./middleware-Pd0e8Igk.js";import{i as ta,r as na}from"./app-link-Ji4uewEG.js";import{t as ra}from"./copy-to-clipboard-HOJ79TWv.js";import{t as ia}from"./task-copy-CtcqCQ78.js";import{C as aa,D as oa,E as sa,T as ca,_ as la,b as ua,c as da,d as fa,f as pa,g as ma,h as ha,m as ga,n as _a,o as va,p as ya,r as ba,s as xa,u as Sa,v as Ca,w as wa,x as Ta,y as Ea}from"./chunk-D32TOXHM-DQIy-Baq.js";import{i as Da,n as Oa,r as ka,t as Aa}from"./chat-chart-block-DxTCx__V.js";import{t as ja}from"./linkify-it-BkqEorO0.js";import{n as Ma}from"./interaction-BdhHBbYa.js";import{a as Na,i as Pa,n as Fa,o as Ia,r as La,s as Ra,t as za}from"./tool-friendly-title-CJVFJ2Ud.js";import{s as Ba}from"./connectors-api-B27sJ651.js";import{t as Va}from"./use-realtime-voice-D9k997EW.js";import{t as Ha}from"./activity-store-DyHjQrpP.js";import{t as Ua}from"./composer-notifications-CpBgWAE4.js";import{n as Wa}from"./voice-call-context-BM2A4bLz.js";import{r as Ga}from"./app-chrome-BeB4KgOf.js";import{i as Ka,n as qa,r as Ja}from"./form-field-width-DJw_jULe.js";import{n as Ya}from"./electron-env-DHOGevH3.js";import{t as Xa}from"./page-header-store-BXED3zhV.js";import{n as Za,t as Qa}from"./new-chat-navigation-spnin196.js";import{t as $a}from"./use-async-resource-BHFGZCY2.js";import{t as eo}from"./loopi-CNtmi9FU.js";import{a as to}from"./extension-provider-CFPicsnW.js";import{t as no}from"./agent-avatar-display-Dyyk4GdM.js";import{a as ro,n as io,r as ao,t as oo}from"./skill-wire-pattern-BPpeIcCi.js";import{a as so,i as co,o as lo,t as uo}from"./composer-handoff-params-DBpzHuNo.js";import{n as fo,t as po}from"./agent-display-names-Bje7vfSn.js";import{n as mo,t as ho}from"./use-directory-picker-C4p7AgWY.js";import{t as go}from"./confirm-dialog-yhRKgG72.js";import{a as _o,c as vo,f as yo,s as bo,u as xo}from"./workspace-api-CD_6YyPI.js";import{n as So}from"./index.module-Cd9ENXfk.js";import{a as Co,i as wo,o as To,r as Eo,s as Do}from"./copy-text-row-gqdh0Bg1.js";import{_ as Oo,b as ko,d as Ao,f as jo,h as Mo,i as No,n as Po,p as Fo,s as Io,u as Lo,y as Ro}from"./shares-api-CoRLwDnw.js";import{t as zo}from"./workspace-editor-agent-store-BuYdf4CO.js";import{l as Bo,m as Vo,o as Ho,r as Uo,t as Wo,u as Go}from"./dist-DaFr5KMw.js";import{n as Ko,r as qo,t as Jo}from"./use-composer-attachments-DWiIdMIi.js";import{_ as Yo,a as Xo,c as Zo,d as Qo,f as $o,g as es,h as ts,i as ns,l as rs,m as is,p as as,s as os,t as ss,u as cs,v as ls}from"./command-palette-api-CAKoTF_-.js";import{a as us,i as ds,n as fs,o as ps,r as ms,s as hs}from"./composer-payload-handoff-uT_hvvap.js";import{n as gs,o as _s,r as vs,s as ys}from"./voice-input-shortcut-events-CwKpIInD.js";import{_ as bs,g as xs,i as Ss,t as Cs,v as ws,y as Ts}from"./automation-task-card-BBEA23Zb.js";import{t as Es}from"./dev-view-store-D4EyUkRI.js";import{t as Ds}from"./extension-iframe-host-DpgIPfJe.js";import{i as Os,r as ks,t as As}from"./runtime-health-zDkHcOZO.js";import{c as js,i as Ms,r as Ns}from"./api-DVQaJzrB.js";import{r as Ps}from"./terminal-panel-store-BOHv5O2x.js";import{n as Fs}from"./agents-app-path-ciChvpCS.js";import{t as Is}from"./oauth-provider-connect-BPNIEiMv.js";import{t as Ls}from"./use-media-query-ady-FgjK.js";import{n as Rs,r as zs,t as Bs}from"./oauth-authorization-window-o6URRos4.js";import{n as Vs,t as Hs}from"./page-context-draft-CHAS3BY3.js";import{i as Us,r as Ws}from"./management-api-BtTRehT0.js";import{t as Gs}from"./side-chat-shortcut-BIw-1TTD.js";var Ks=M(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),qs=M(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),Js=M(`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`}]]),Ys=M(`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`}]]),Xs=M(`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`}]]),Zs=M(`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`}]]),Qs=M(`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`}]]),$s=M(`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`}]]),ec=M(`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`}]]),tc=M(`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`}]]),nc=M(`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`}]]),rc=M(`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`}]]),ic=M(`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`}]]),ac=M(`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`}]]),oc=M(`message-square-quote`,[[`path`,{d:`M14 14a2 2 0 0 0 2-2V8h-2`,key:`1r06pg`}],[`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:`M8 14a2 2 0 0 0 2-2V8H8`,key:`1jzu5j`}]]),sc=M(`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`}]]),cc=M(`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`}]]),lc=M(`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`}]]),uc=M(`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`}]]),dc=M(`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`}]]),fc=M(`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`}]]),pc=M(`video`,[[`path`,{d:`m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5`,key:`ftymec`}],[`rect`,{x:`2`,y:`6`,width:`14`,height:`12`,rx:`2`,key:`158x01`}]]),mc=M(`volume-x`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`line`,{x1:`22`,x2:`16`,y1:`9`,y2:`15`,key:`1ewh16`}],[`line`,{x1:`16`,x2:`22`,y1:`9`,y2:`15`,key:`5ykzw1`}]]),hc=M(`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 gc(e,t){return e.replace(/\{\{(\w+)}}/g,(e,n)=>t[n]?.trim()??``).replace(/[ \t]{2,}/g,` `).trim()}function _c(e,t,n){return{id:e,title:gc(t.title,n),prompt:gc(t.prompt,n),reason:gc(t.reason,n)}}function vc(e,t){let n={projectName:e.projectName,blockedReason:e.blockedReason,recentFailure:e.recentFailure,nextAction:e.recommendedAction};if(e.blockedReason?.trim())return _c(`project-blocked`,t.recommendations.projectBlocked,n);if(e.recentFailure?.trim())return _c(`project-failure`,t.recommendations.projectFailure,n);if(e.recommendedAction?.trim())return _c(`project-next-action`,t.recommendations.projectNextAction,n)}function yc(e,t){let n={taskTitle:e.taskTitle,attentionSummary:e.attentionSummary,recentFailure:e.recentFailure,nextAction:e.nextAction};if(e.attentionSummary?.trim())return _c(`task-attention`,t.recommendations.taskAttention,n);if(e.recentFailure?.trim())return _c(`task-failure`,t.recommendations.taskFailure,n);if(e.phase===`review`||e.operationalState===`verifying`)return _c(`task-review`,t.recommendations.taskReview,n);if(e.phase===`closed`)return _c(`task-closed`,t.recommendations.taskClosed,n);if(e.nextAction?.trim())return _c(`task-next-action`,t.recommendations.taskNextAction,n)}function bc(e,t){switch(e.kind){case`project`:return vc(e,t);case`task`:return yc(e,t);default:return}}function xc(e,t,n={}){let r=n.contextStatus??`ready`;return{headline:e.kind===`project`&&t.projectHeadline?gc(t.projectHeadline,{projectName:e.projectName}):t.headline,contextKind:e.kind,contextStatus:r,recommendation:r===`ready`?bc(e,t):void 0}}var Sc=ln({id:un().uuid(),conversationId:un(),transcriptId:un(),sourceRunId:un(),inputRevision:fn().int().nonnegative(),transcriptCursor:fn().int().nonnegative(),agentId:un(),locale:dn([`zh`,`en`]),prompt:un().min(1).max(160),expiresAt:fn()}),Cc=ln({status:dn([`ready`,`pending`,`none`]),suggestion:Sc.optional()});ln({suggestionId:un().uuid(),impressionId:un().uuid(),event:dn([`shown`,`accepted`,`dismissed`,`submitted`]),edited:cn().optional()}).strict();function wc(e,t=`body`){return`result:${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Tc(e){return`${e.taskRunId}:${e.assignmentEpoch}:${e.outcome.outcomeId}`}var Ec=e(s(),1),X=l(),Z=c(),Q=e(o(),1);function Dc(e,t){return e?[`task-detail`,e,t??``]:null}function Oc(e,t){return t.source!==`user`||e===void 0||t.version>e}function kc(e,t){let n=(0,Z.c)(5),r=v(Ac),i;n[0]!==e||n[1]!==r?(i=Dc(e,r),n[0]=e,n[1]=r,n[2]=i):i=n[2];let a;return n[3]===e?a=n[4]:(a=()=>Oi(e),n[3]=e,n[4]=a),vi(i,a,t)}function Ac(e){return e.conversationId}function jc(e){let[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(null),s=(0,Q.useRef)(``),c=(0,Q.useRef)(void 0),l=kc(e,{keepPreviousData:!1,revalidateOnFocus:!0,revalidateOnReconnect:!0,refreshInterval:e=>e&&[`allocating`,`queued`,`running`,`waiting`,`verifying`].includes(e.operationalState)?5e3:0});return c.current=l.data?.task.version,(0,Q.useEffect)(()=>{n(null),i(!1),o(null),s.current=``},[e]),(0,Q.useEffect)(()=>{let t=l.data;if(!t||t.conversation.activeConversationId||t.allocation&&t.allocation.status!==`assigned`)return;let n=`${e}:${t.task.version}`;s.current!==n&&(s.current=n,i(!0),o(null),Si(e).then(()=>s.current===n?l.mutate():void 0).catch(e=>{s.current===n&&o(e)}).finally(()=>{s.current===n&&i(!1)}))},[l.data,l.mutate,e]),(0,Q.useEffect)(()=>{let t,r=()=>{window.clearTimeout(t),t=window.setTimeout(()=>void l.mutate(),120)},i=t=>{let i=bn.safeParse(t.detail);!i.success||i.data.taskId!==e||Oc(c.current,i.data)&&(n(i.data),r())},a=()=>r();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)}},[l.mutate,e]),{...l,lastChange:t,conversationLoading:r,conversationError:a}}var Mc=new Map,Nc=new Set;function Pc(e,t){Mc.set(e,t);for(let e of Nc)e();return()=>{Mc.get(e)===t&&Mc.delete(e)}}async function Fc(e,t,n){await(Mc.get(e)??await new Promise((t,n)=>{let r=()=>{let n=Mc.get(e);n&&(clearTimeout(i),Nc.delete(r),t(n))},i=setTimeout(()=>{Nc.delete(r),n(Error(`Chat input is not ready. Please retry.`))},15e3);Nc.add(r),r()}))(t,n)}var Ic=crypto.randomUUID(),Lc=e=>e===`closed`;function Rc(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 zc=e=>`/api/phone/conversations/${encodeURIComponent(e)}`,Bc=new Map,Vc=()=>{let e=v.getState();return`${e.baseUrl}:${e.conversationId}`};function Hc(e,t,n=Vc()){let r=`${n}:${e}`,i=Bc.get(r);return t&&i&&t.report.sessionId===i.report.sessionId&&(t.report.revision??0)<(i.report.revision??0)?i:(t?(Bc.set(r,t),Bc.size>100&&Bc.delete(Bc.keys().next().value)):Bc.delete(r),t)}async function Uc(e,t=Vc()){let n=await g(_(e)),r=decodeURIComponent(e.split(`/conversations/`)[1]?.split(`?`)[0]??``);if(n.status===404)return Hc(r,null,t);if((n.status===401||n.status===403)&&Hc(r,null,t),!n.ok)throw Object.assign(Error(`Phone view unavailable (HTTP ${n.status})`),{status:n.status});return Hc(r,(await n.json()).payload,t)}function Wc(e,t){let n=(0,Z.c)(5),r=t===void 0||t,i=v(qc),a;n[0]!==e||n[1]!==r||n[2]!==i?(a=r&&/^(?:device:)?[\da-f]{8}-[\da-f-]{27}$/i.test(e)?[`${zc(e)}?clientId=${Ic}`,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:Gc,errorRetryCount:6,errorRetryInterval:2e3,refreshWhenHidden:!1},n[4]=o):o=n[4],vi(a,Kc,o)}function Gc(e){return e.status!==401&&e.status!==403}function Kc(e){let[t,n]=e;return Uc(t,n)}function qc(e){return`${e.baseUrl}:${e.conversationId}`}async function Jc(e,t,n,r={},i=!1){let a=Vc();return Hc(e,(await b(_(`${zc(e)}/${t.report.sessionId}/control`),{method:`POST`,keepalive:i,body:JSON.stringify({expectedTranscriptId:t.report.transcriptId,clientId:Ic,assistanceId:t.report.assistanceId,assistanceVersion:t.report.assistanceVersion,operationId:crypto.randomUUID(),epoch:t.report.controlEpoch,op:n,...r})})).payload,a)}async function Yc(e,t,n){let r=await g(_(`${zc(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 Xc(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 Zc(e,t,n,r=!1){return(await b(_(`${zc(e)}/${t.report.sessionId}/execution-mode`),{method:`POST`,body:JSON.stringify({executionMode:n,applyCurrent:r,epoch:t.report.controlEpoch,clientId:Ic})})).payload}function Qc(e,t){if(!t.assistanceId||![`needs_user`,`paused`].includes(t.status))return null;let n=v.getState();return JSON.stringify([n.baseUrl,n.conversationId,e,t.transcriptId,t.assistanceId,t.assistanceVersion??1])}var $c=x(ea(e=>({seen:[],markSeen:t=>e(e=>e.seen.includes(t)?e:{seen:[...e.seen.slice(-99),t]})}),{name:`xopc-phone-attention-v1`}));function el(e){let t=(0,Z.c)(18),{detail:n,language:r}=e,i,a,o;t[0]!==n||t[1]!==r?(i=wi(n),o=r===`zh`,a=i.receipt?ia(r).resultStatuses[yn(i.receipt)]:o?`尚无本版任务的执行结果`:`No run result for this task version`,t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o):(i=t[2],a=t[3],o=t[4]);let s=a,c=o?`执行、验收与交付`:`Execution, acceptance and delivery`,l=n.task.phase===`closed`?``:o?`;任务仍未关闭`:`; task remains open`,u;t[5]!==s||t[6]!==l?(u=(0,X.jsxs)(`p`,{children:[s,l]}),t[5]=s,t[6]=l,t[7]=u):u=t[7];let d=o?`验收:${i.verified}/${i.criteria} 项通过`:`Acceptance: ${i.verified}/${i.criteria} criteria passed`,f=i.criteria===0?o?`,尚未定义验收标准`:`; criteria not defined`:``,p;t[8]!==d||t[9]!==f?(p=(0,X.jsxs)(`p`,{children:[d,f]}),t[8]=d,t[9]=f,t[10]=p):p=t[10];let m=i.deliverables>0?o?`已关联交付物:${i.deliverables} 项`:`Linked deliverables: ${i.deliverables}`:o?`尚无正式交付物`:`No formal deliverables linked`,h;t[11]===m?h=t[12]:(h=(0,X.jsx)(`p`,{children:m}),t[11]=m,t[12]=h);let g;return t[13]!==c||t[14]!==u||t[15]!==p||t[16]!==h?(g=(0,X.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[13]=c,t[14]=u,t[15]=p,t[16]=h,t[17]=g):g=t[17],g}var tl=(0,Q.memo)(function(e){let t=(0,Z.c)(58),{taskId:n}=e,r=f(),i=y(nl),a;t[0]===i?a=t[1]:(a=ia(i),t[0]=i,t[1]=a);let o=a,{data:s}=jc(n);if(!s)return null;let{task:c,operationalState:l}=s,u,d,p,m;if(t[2]!==o.noDecisionNeeded||t[3]!==s||t[4]!==l||t[5]!==c.phase){let e=xi(s);p=s.attention.length>0;let n;t[10]!==l||t[11]!==c.phase?(n=c.phase!==`closed`&&[`queued`,`running`,`verifying`].includes(l),t[10]=l,t[11]=c.phase,t[12]=n):n=t[12],d=n,u=p?s.attention[0]?.summary??e?.nextAction??e?.summary:c.phase===`closed`?e?.summary:e?.nextAction??e?.summary??o.noDecisionNeeded,m=e?.evidence.filter(rl).length??0,t[2]=o.noDecisionNeeded,t[3]=s,t[4]=l,t[5]=c.phase,t[6]=u,t[7]=d,t[8]=p,t[9]=m}else u=t[6],d=t[7],p=t[8],m=t[9];let g=m,_=o.taskProgress.title,v;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,X.jsx)(fc,{className:`size-4`,"aria-hidden":!0}),t[13]=v):v=t[13];let b;t[14]===d?b=t[15]:(b=d?(0,X.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]=d,t[15]=b);let x;t[16]===b?x=t[17]:(x=(0,X.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:[v,b]}),t[16]=b,t[17]=x);let S;t[18]===o.taskProgress.title?S=t[19]:(S=(0,X.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`,Di(Ti(s))),t[20]=s,t[21]=C);let w=o.detailStatuses[Ti(s)],T;t[22]!==C||t[23]!==w?(T=(0,X.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]!==g?(E=g>0?(0,X.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[g,` `,o.taskProgress.evidence]}):null,t[25]=o.taskProgress.evidence,t[26]=g,t[27]=E):E=t[27];let D;t[28]!==T||t[29]!==E||t[30]!==S?(D=(0,X.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]===c.title?O=t[33]:(O=(0,X.jsx)(`p`,{className:`mt-1 text-sm font-medium leading-5 text-fg`,children:c.title}),t[32]=c.title,t[33]=O);let k;t[34]===u?k=t[35]:(k=u?(0,X.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:u}):null,t[34]=u,t[35]=k);let A;t[36]!==D||t[37]!==O||t[38]!==k?(A=(0,X.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]!==c.id?(M=Qe(j,c.id),t[40]=j,t[41]=c.id,t[42]=M):M=t[42];let N=p?o.taskProgress.decide:o.taskProgress.open,P;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,X.jsx)(Ce,{className:`size-3.5`,"aria-hidden":!0}),t[43]=P):P=t[43];let F;t[44]!==M||t[45]!==N?(F=(0,X.jsxs)(h,{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,X.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,X.jsx)(el,{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,X.jsxs)(`section`,{className:`mb-6 rounded-xl border border-edge bg-surface-panel px-3 py-3 sm:px-4`,"aria-label":_,"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 nl(e){return e.language}function rl(e){return e.strength===`verified`}function il(e){return e===-5||e===-4||e===-3?`
3
+ `:e<0?` `:String.fromCharCode(e)}var al={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 ol(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?tt(a):Xe(a))?(c&&t.exit(`xopcMathValue`),t.exit(l),n(i)):r(i)}function f(n){if(n===null)return d(n);let l=il(n);if(l===`
4
+ `)return e&&i.interrupt||!e||o?d(n):(c&&t.exit(`xopcMathValue`),c=!1,t.attempt(al,e=>(a+=`
5
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===`%`&&!vt(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)&&!vt(a,a.length-p),f}}}var ll={name:`xopcMathInline`,tokenize:cl(!1)},ul={name:`xopcMathFlow`,tokenize:cl(!0),concrete:!0},dl={text:{92:ll,36:ll},flow:{92:ul,36:ul}};function fl(e){return{hName:`code`,hProperties:{className:[e.display?`math-display`:`math-inline`],"data-xopc-math-source":gt(e)},hChildren:[{type:`text`,value:e.raw}]}}var pl={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=Xe(t);Object.assign(n,{value:t,data:fl(r)}),this.exit(e)},xopcMathFlow(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-1],r=tt(t);Object.assign(n,{value:t,data:fl(r)}),this.exit(e)}}};function ml(){let e=this.data();return(e.micromarkExtensions??=[]).push(dl),(e.fromMarkdownExtensions??=[]).push(pl),(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=fl(_t(r)??it(r,n))}for(let t of e.children??[])n(t)}n(e)}}var hl=new Map,gl=0;function _l(e){if(!/\\[([]|\$|^\s*```math/m.test(e))return[];let t=hl.get(e);if(t)return t;let n=sa(e,{extensions:[dl],mdastExtensions:[pl]}),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(;hl.size>=256||gl+e.length>1048576;){let e=hl.keys().next().value;gl-=e.length,hl.delete(e)}hl.set(e,r),gl+=e.length}return r}function vl(e=e=>_l(e).length){let t=[],n=[];return r=>{let i=0,a=[],o=r.map((n,r)=>{let o=Math.max(0,256-i),s=t[r],c=s?.source===n?s:{source:n,count:e(n)};return a.push(c),i+=c.count,o});return t=a,o.length===n.length&&o.every((e,t)=>e===n[t])?n:(n=o,o)}}var yl=/^(?:查看(?:高清|原|大)?图片|查看大图|查看原图|view(?: (?:full[- ]size|original|hd))? image)$/i;function bl(e){return yl.test(e)}function xl(){let e=new Set,t;function n(e){let t=e.closest(`p`);if(!t||t.querySelector(`a`)!==e)return;let n=!1,r=e.textContent?.trim()??``;if(r===t.textContent?.trim()&&bl(r)){let r=t.nextElementSibling,i=r&&!r.matches(`[data-xopc-watermark]`)?r:t.closest(`.markdown-stream-block`)?.nextElementSibling?.firstElementChild;if(i?.matches(`[data-chat-media]`)){let t=i.querySelectorAll(`[data-chat-media-source]`);n=t.length===1&&t[0].dataset.chatMediaSource===e.getAttribute(`href`)}}t.hidden!==n&&(t.hidden=n)}return r=>{if(!r)return;let i=r.closest(`p`),a=r.closest(`.markdown-render-boundary`);if(!(!i||!a))return e.add(r),n(r),t||(t=new MutationObserver(()=>{for(let t of e)n(t)}),t.observe(a,{subtree:!0,childList:!0,characterData:!0,attributeFilter:[`href`,`data-chat-media`,`data-chat-media-source`]})),()=>{e.delete(r),i.hidden&&=!1,e.size||(t?.disconnect(),t=void 0)}}}var Sl={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`}},Cl=`https://html.spec.whatwg.org/multipage/parsing.html#parse-error-`,wl=/-[a-z]/g,Tl=/%c(?:([-+])(\d+))?/g,El=/%x/g,Dl={2:!0,1:!1,0:null},Ol={};function kl(e,t){let n=t||Ol,r=n.onerror,i=e instanceof da?e:new da(e),a=n.fragment?fa:Oa,o=String(i);return Da(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=Al(t),s=n[a]??!0,c=typeof s==`number`?s:+!!s;if(c){let n=Sl[a],o=new Ta(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=Dl[c],o.note=l(n.description),o.url=n.url===!1?void 0:Cl+t,r(o)}function l(t){return t.replace(Tl,n).replace(El,r);function n(t,n,r){let i=(r?Number.parseInt(r,10):0)*(n===`-`?-1:1);return Ml(o.charAt(e.startOffset+i))}function r(){return Nl(o.charCodeAt(e.startOffset))}}}}function Al(e){return e.replace(wl,jl)}function jl(e){return e.charAt(1).toUpperCase()}function Ml(e){return e==="`"?"` ` `":e}function Nl(e){return`0x`+e.toString(16).toUpperCase()}function Pl(e={streaming:!1}){return t=>{let n=0;ga(t,`element`,(t,r)=>{if(t.tagName!==`code`||typeof t.properties[`data-xopc-math-source`]!=`string`)return;let i=rt(t.properties[`data-xopc-math-source`]);if(!i)return;let a=kl(mt(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),_a})}}var Fl={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},Il={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},Ll={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`},Rl=[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],zl=[12288,12288,65281,65376,65504,65510],Bl=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],Vl=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],Hl=[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],Ul=(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},Wl=19968,[Gl,Kl]=ql(Hl);function ql(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(Wl>=i&&Wl<=a)return[i,a];a-i>n-t&&(t=i,n=a)}return[t,n]}var Jl=e=>e<161||e>1114109?!1:Ul(Rl,e),Yl=e=>e<12288||e>65510?!1:Ul(zl,e),Xl=e=>e<8361||e>65518?!1:Ul(Bl,e),Zl=e=>e<32||e>10630?!1:Ul(Vl,e),Ql=e=>e>=Gl&&e<=Kl?!0:e<4352||e>262141?!1:Ul(Hl,e);function $l(e){return Jl(e)?`ambiguous`:Yl(e)?`fullwidth`:Xl(e)?`halfwidth`:Zl(e)?`narrow`:Ql(e)?`wide`:`neutral`}function eu(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function tu(e){return eu(e),$l(e)}function nu(e){return/^\p{Emoji_Presentation}/u.test(String.fromCodePoint(e))}function ru(e){if(!e||e<4352)return!1;switch(tu(e)){case`fullwidth`:case`halfwidth`:return!0;case`wide`:return!nu(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 iu(e,t){return t!==65025||!e||e<8216?!1:e===8216||e===8217||e===8220||e===8221}function au(e){return e!==null&&e>=65024&&e<=65038}var ou=cu(/\p{P}|\p{S}/u),su=cu(/\s/);function cu(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCodePoint(t))}}function lu(e){return!!(e&Il.characterGroupWhitespace)}function uu(e){return(e&gu.cjkPunctuation)===Il.characterGroupPunctuation}function du(e){return!!(e&gu.cjk)}function fu(e){return e===gu.ivs}function pu(e){return!!(e&gu.cjkOrIvs)}function mu(e){return e===gu.nonEmojiGeneralUseVS}function hu(e){return!!(e&gu.spaceOrPunctuation)}var gu;(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})(gu||={});function _u(e){if(e===Fl.eof||ua(e)||su(e))return Il.characterGroupWhitespace;let t=0;if(e>=4352){if(au(e))return gu.nonEmojiGeneralUseVS;switch(ru(e)){case null:return gu.ivs;case!0:t|=gu.cjk;break}}return ou(e)&&(t|=Il.characterGroupPunctuation),t}function vu(e,t,n){if(!mu(e))return e;let r=t(),i=_u(r);return!r||lu(i)?e:iu(r,n)?gu.cjkPunctuation:yu(i)}function yu(e){return e&~gu.ivs}function bu(e){return!!(e&&e>=55296&&e<=56319)}function xu(e){return!!(e&&e>=56320&&e<=57343)}function Su(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 Cu(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 wu=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=Cu(this.previousCode,this.nowPoint,this.sliceSerialize)),this.cachedValue}};function Tu(e,t,n){let r=n({start:t,end:{...t,_bufferIndex:t._bufferIndex+2}}).codePointAt(0);return r&&r>=65536?r:e}var Eu={name:`attention`,resolveAll:Du,tokenize:Ou};function Du(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};ku(d,-c),ku(f,c),o={type:c>1?Ll.strongSequence:Ll.emphasisSequence,start:d,end:{...e[r][1].end}},s={type:c>1?Ll.strongSequence:Ll.emphasisSequence,start:{...e[n][1].start},end:f},a={type:c>1?Ll.strongText:Ll.emphasisText,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?Ll.strong:Ll.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=la(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=la(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),t.parser.constructs.insideSpan.null,l=la(l,Ea(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=la(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=la(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,ca(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 Ou(e,t){let n=this.parser.constructs.attentionMarkers.null,{now:r,sliceSerialize:i,previous:a}=this,o=xu(a)?Su(a,r(),i):a,s=_u(o),c=new wu(o,r(),i),l=vu(s,c.value.bind(c),o),u;return d;function d(t){return t===Fl.asterisk||Fl.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=_u(bu(a)?Tu(a,r(),i):a),d=uu(l),p=o===Fl.asterisk||o===Fl.underscore,m=d||lu(l)||p,h=uu(c),g=a===Fl.asterisk||a===Fl.underscore,_=h||lu(c)||g,v=pu(l),y=!_||h&&(m||v)||n.includes(a)&&a!==Fl.asterisk&&a!==Fl.underscore,b=!m||d&&(_||du(c))||n.includes(o)&&o!==Fl.asterisk&&o!==Fl.underscore;return s._open=!!(u===Fl.asterisk?y:y&&(hu(l)||!b)),s._close=!!(u===Fl.asterisk?b:b&&(hu(c)||!y)),t(a)}}function ku(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}function Au(){return{text:{[Fl.asterisk]:Eu,[Fl.underscore]:Eu},insideSpan:{null:[Eu]}}}function ju(){let e=this.data();(e.micromarkExtensions||=[]).push(Au())}var Mu=`;`.codePointAt(0)??Fl.eof,Nu=`&`.codePointAt(0)??Fl.eof;function Pu(){return{handlers:{emphasis:Fu,strong:Iu,text:Bu}}}Fu.peek=Lu,Iu.peek=Ru;function Fu(e,t,n,r){return zu(e,t,n,r,Lu(e,t,n),1)}function Iu(e,t,n,r){return zu(e,t,n,r,Ru(e,t,n),2)}function Lu(e,t,n){return n.options.emphasis||`*`}function Ru(e,t,n){return n.options.strong||`*`}function zu(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=Ju(e,t,n,r.before),f=Yu(e,t,n,r.after),p=Vu(d,sd(u),i,`open`);p.inside&&u&&(u=id(u));let m=Vu({current:cd(u),previous:od(u)},f,i,`close`);m.inside&&u&&(u=ad(u));let h=c.move(o);s();let g=m.outside&&ed(t,n);return n.attentionEncodeSurroundingInfo={after:m.outside&&!g,before:p.outside},td(n).cjkFriendlyEncodeAfterSupplementaryText=g,l+u+h}function Bu(e,t,n,r){let i=td(n);if(!i.cjkFriendlyEncodeAfterSupplementaryText)return n.safe(e.value,r);i.cjkFriendlyEncodeAfterSupplementaryText=!1;let[a=``]=[...e.value],o=e.value.slice(a.length);return`${rd(a.codePointAt(0)??Fl.eof)}${n.safe(o,{...r,before:`;`})}`}function Vu(e,t,n,r){let i=qu(e),a=_u(t);if(!pu(i)&&!pu(a))return r===`open`?Hu(i,a,n):Hu(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?ld:e:i.inside?ld:e,o=r===`open`?i.inside?ud:t:i.outside?ud:t;if(r===`open`?Uu(n,a,o):Wu(n,a,o))return i}return l}function Hu(e,t,n){return Ku(e)?Ku(t)?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:lu(t)?{inside:!0,outside:!0}:{inside:!1,outside:!0}:lu(e)?Ku(t)?{inside:!1,outside:!1}:lu(t)?{inside:!0,outside:!0}:{inside:!1,outside:!1}:lu(t)?{inside:!0,outside:!1}:{inside:!1,outside:!1}}function Uu(e,t,n){let r=qu(t),{close:i,open:a}=Gu(r,_u(n));return e===`_`?a&&(hu(r)||!i):a}function Wu(e,t,n){let r=_u(n),{close:i,open:a}=Gu(qu(t),r);return e===`_`?i&&(hu(r)||!a):i}function Gu(e,t){let n=uu(e),r=n||lu(e),i=uu(t),a=i||lu(t);return{open:!a||i&&(r||pu(e)),close:!r||n&&(a||du(t))}}function Ku(e){return!lu(e)&&!uu(e)}function qu(e){let t=_u(e.current);return e.current===null||!mu(t)?t:vu(t,()=>e.previous,e.current)}function Ju(e,t,n,r){let i=cd(r),a=od(r);if(Xu(i)||Qu(i,a)){let r=$u(e,t,n,-1);r&&(i=cd(r),a=od(r))}return{current:i,previous:a}}function Yu(e,t,n,r){let i=sd(r);if(!Zu(i))return i;let a=$u(e,t,n,1);return a?sd(a):i}function Xu(e){return e!==null&&56320<=e&&e<=57343}function Zu(e){return e!==null&&55296<=e&&e<=56319}function Qu(e,t){return mu(_u(e))&&(t===null||t===Fl.eof)}function $u(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 nd(s)||void 0}function ed(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`&&(sd(r.value)??0)>65535}function td(e){return e}function nd(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(nd).join(``):``}function rd(e){return`&#x${(e??0).toString(16).toUpperCase()};`}function id(e){let[t=``]=[...e];return rd(t.codePointAt(0)??Fl.eof)+e.slice(t.length)}function ad(e){let t=[...e],n=t.pop();return`${t.join(``)}${rd(n?.codePointAt(0)??Fl.eof)}`}function od(e){let t=[...e];return t.pop(),t.at(-1)?.codePointAt(0)??Fl.eof}function sd(e){return e.codePointAt(0)??Fl.eof}function cd(e){return[...e].at(-1)?.codePointAt(0)??Fl.eof}var ld={current:Mu,previous:Fl.eof},ud=Nu;function dd(){let e=this.data();(e.toMarkdownExtensions||=[]).push(Pu())}function fd(){ju.call(this),dd.call(this)}var pd=fd;function md(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{[Fl.tilde]:n},insideSpan:{null:[n]},attentionMarkers:{null:[Fl.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&&ca(o,o.length,0,Ea(s,e.slice(r+1,n),t)),ca(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),ca(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=Ll.data);return e}function i(e,n,r){let{now:i,sliceSerialize:a,previous:o}=this,s=xu(o)?Su(o,i(),a):o,c=_u(s),l=new wu(s,i(),a),u=vu(c,l.value.bind(l),s),d=this.events,f=0;return p;function p(t){return Fl.tilde,s===Fl.tilde&&d[d.length-1][1].type!==Ll.characterEscape?r(t):(e.enter(`strikethroughSequenceTemporary`),m(t))}function m(o){let c=_u(s);if(o===Fl.tilde)return f>1?r(o):(e.consume(o),f++,m);if(f<2&&!t)return r(o);let l=e.exit(`strikethroughSequenceTemporary`),d=_u(bu(o)?Tu(o,i(),a):o),p=uu(u)||lu(u),h=uu(d)||lu(d),g=du(u)||fu(c);return l._open=!h||d===Il.attentionSideAfter&&(p||g),l._close=!p||c===Il.attentionSideAfter&&(h||du(d)),n(o)}}}function hd(e){let t=this.data();(t.micromarkExtensions||=[]).push(md(e))}var gd=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`],_d=`;`.codePointAt(0)??Fl.eof,vd=`&`.codePointAt(0)??Fl.eof;function yd(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:gd}],handlers:{delete:bd,text:xd}}}bd.peek=Sd;function bd(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=Ad(e,t,n,r.before),l=jd(e,t,n,r.after),u=Cd(c,Ud(s),`open`);u.inside&&s&&(s=Bd(s));let d=Cd({current:Wd(s),previous:Hd(s)},l,`close`);d.inside&&s&&(s=Vd(s));let f=a.move(`~~`);i();let p=d.outside&&Id(t,n);return n.attentionEncodeSurroundingInfo={after:d.outside&&!p,before:u.outside},Ld(n).cjkFriendlyEncodeAfterSupplementaryText=p,o+s+f}function xd(e,t,n,r){let i=Ld(n);if(!i.cjkFriendlyEncodeAfterSupplementaryText)return n.safe(e.value,r);i.cjkFriendlyEncodeAfterSupplementaryText=!1;let[a=``]=[...e.value],o=e.value.slice(a.length);return`${zd(a.codePointAt(0)??Fl.eof)}${n.safe(o,{...r,before:`;`})}`}function Sd(){return`~`}function Cd(e,t,n){let r=kd(e),i=_u(t);if(!pu(r)&&!pu(i))return n===`open`?wd(r,i):wd(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?Gd:e:r.inside?Gd:e,a=n===`open`?r.inside?Kd:t:r.outside?Kd:t;if(n===`open`?Td(i,a):Ed(i,a))return r}return c}function wd(e,t){return Od(e)?Od(t)?{inside:!1,outside:!1}:lu(t)?{inside:!0,outside:!0}:{inside:!1,outside:!0}:lu(e)?Od(t)?{inside:!1,outside:!1}:lu(t)?{inside:!0,outside:!0}:{inside:!1,outside:!1}:lu(t)?{inside:!0,outside:!1}:{inside:!1,outside:!1}}function Td(e,t){let{open:n}=Dd(kd(e),_u(t));return n}function Ed(e,t){let n=_u(t),{close:r}=Dd(kd(e),n);return r}function Dd(e,t){let n=uu(e),r=n||lu(e),i=uu(t),a=i||lu(t);return{open:!a||i&&(r||pu(e)),close:!r||n&&(a||du(t))}}function Od(e){return!lu(e)&&!uu(e)}function kd(e){let t=_u(e.current);return e.current===null||!mu(t)?t:vu(t,()=>e.previous,e.current)}function Ad(e,t,n,r){let i=Wd(r),a=Hd(r);if(Md(i)||Pd(i,a)){let r=Fd(e,t,n,-1);r&&(i=Wd(r),a=Hd(r))}return{current:i,previous:a}}function jd(e,t,n,r){let i=Ud(r);if(!Nd(i))return i;let a=Fd(e,t,n,1);return a?Ud(a):i}function Md(e){return e!==null&&56320<=e&&e<=57343}function Nd(e){return e!==null&&55296<=e&&e<=56319}function Pd(e,t){return mu(_u(e))&&(t===null||t===Fl.eof)}function Fd(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 Rd(s)||void 0}function Id(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`&&(Ud(r.value)??0)>65535}function Ld(e){return e}function Rd(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(Rd).join(``):``}function zd(e){return`&#x${(e??0).toString(16).toUpperCase()};`}function Bd(e){let[t=``]=[...e];return zd(t.codePointAt(0)??Fl.eof)+e.slice(t.length)}function Vd(e){let t=[...e],n=t.pop();return`${t.join(``)}${zd(n?.codePointAt(0)??Fl.eof)}`}function Hd(e){let t=[...e];return t.pop(),t.at(-1)?.codePointAt(0)??Fl.eof}function Ud(e){return e.codePointAt(0)??Fl.eof}function Wd(e){return[...e].at(-1)?.codePointAt(0)??Fl.eof}var Gd={current:_d,previous:Fl.eof},Kd=vd;function qd(){let e=this.data();(e.toMarkdownExtensions||=[]).push(yd())}function Jd(e){hd.call(this,e),qd.call(this)}var Yd=Jd,Xd=new Set([`。`,`.`,`,`,`、`,`?`,`!`,`:`,`;`,`(`,`)`,`【`,`】`,`「`,`」`,`『`,`』`,`〈`,`〉`,`《`,`》`]),Zd=/^(https?:\/\/|mailto:|www\.)/i,Qd=e=>{if(e.children.length!==1)return!1;let t=e.children[0];return t.type===`text`&&t.value===e.url},$d=e=>{let t=0;for(let n of e){if(Xd.has(n))return t;t+=n.length}return null},ef=(e,t)=>({...t,url:e,children:[{type:`text`,value:e}]}),tf=e=>({type:`text`,value:e}),nf=va().transforms??[],rf=e=>{let t=[],n=e=>{if(!e)return;let n={type:`paragraph`,children:[tf(e)]};if(Zd.exec(e)?.[0]!==e){let e={type:`root`,children:[n]};for(let t of nf)t(e)}t.push(...n.children)},r=0,i=0;for(let t of e)Xd.has(t)&&(n(e.slice(r,i)),n(t),r=i+t.length),i+=t.length;return n(e.slice(r)),t},af=()=>e=>{xa(e,`link`,(e,t,n)=>{if(!n||typeof t!=`number`||!Qd(e)||!Zd.test(e.url))return;let r=$d(e.url);if(r===null||r===0)return;let i=[ef(e.url.slice(0,r),e),...rf(e.url.slice(r))];return n.children.splice(t,1,...i),t+i.length})};function of(){let e=[pd],t=[af,Yd];return{name:`cjk`,type:`cjk`,remarkPluginsBefore:e,remarkPluginsAfter:t,remarkPlugins:[...e,...t]}}var sf=of(),cf=(0,Q.createContext)(new Map);function lf(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 uf(e){let t=(0,Z.c)(50),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=y(ff),u;t[7]===l?u=t[8]:(u=C(l),t[7]=l,t[8]=u);let d=u.chat,{openImage:f}=Fe(),[p,m]=(0,Q.useState)(0),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(null),[S,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),g({source:o,url:t,attempt:p}))}).catch(()=>{e&&v(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?h?.source===o&&h.attempt===p?h.url:void 0:o,k=_===o,A;t[14]===o?A=t[15]:(A=e=>{e.naturalWidth&&(x({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=b?.source===o?b:null,F=P?Math.min(1,320/P.width,280/P.height):1,I=S!==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]!==S||t[25]!==o?(R=S!==o&&!k&&(0,X.jsx)(sn,{as:`span`,className:`pointer-events-none absolute inset-0`}),t[23]=k,t[24]=S,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,X.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:()=>v(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,X.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,X.jsxs)(`span`,{children:[d.attachmentPreviewLoadError,c?` · ${c}`:``]}),(0,X.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(),v(null),w(null),m(df)},children:d.userMessageRetry})]}),t[39]=c,t[40]=k,t[41]=d,t[42]=B):B=t[42];let V;return t[43]!==o||t[44]!==L||t[45]!==R||t[46]!==z||t[47]!==B||t[48]!==I?(V=(0,X.jsxs)(`span`,{className:`chat-image-thumbnail`,"data-chat-media-source":o,"data-image-loading":I,style:L,children:[R,z,B]}),t[43]=o,t[44]=L,t[45]=R,t[46]=z,t[47]=B,t[48]=I,t[49]=V):V=t[49],V}function df(e){return e+1}function ff(e){return e.language}var pf=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,X.jsx)(`div`,{className:`whitespace-pre-wrap break-words`,"data-chat-render-fallback":!0,children:this.props.content}):this.props.children}};function mf(e){if(/^\s{0,3}\[[^\]]+\]:|\[[^\]]+\]\[[^\]]*\]|\[\^/m.test(e))return[e];let t=pa(e),n=_l(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 hf(){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,...mf(n.slice(i))],e=n,t}}function gf(e){let t=(0,Z.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=y(_f),c;t[5]===s?c=t[6]:(c=C(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`]??``),h;t[10]===m?h=t[11]:(h=rt(m),t[10]=m,t[11]=h);let g=h,_=String(r?.properties.dataXopcMath??r?.properties[`data-xopc-math`]??``),v=_===`pending`?l.mathPending:_===`fallback`?l.mathFailed:void 0,b;t[12]===g?b=t[13]:(b=async e=>{g&&await aa(e?g.raw:g.latex)&&d(e?`markdown`:`latex`)},t[12]=g,t[13]=b);let x=b,S=o?`div`:`span`,w;t[14]!==u||t[15]!==x||t[16]!==o||t[17]!==l||t[18]!==g?(w=o&&g&&(0,X.jsxs)(`span`,{className:`markdown-math-actions`,contentEditable:!1,children:[(0,X.jsx)(`button`,{type:`button`,title:u===`latex`?l.messageCopied:l.mathCopyLatex,"aria-label":l.mathCopyLatex,onClick:()=>void x(!1),dangerouslySetInnerHTML:{__html:ft[u===`latex`?`copied`:`latex`]}}),(0,X.jsx)(`button`,{type:`button`,title:u===`markdown`?l.messageCopied:l.mathCopyMarkdown,"aria-label":l.mathCopyMarkdown,onClick:()=>void x(!0),dangerouslySetInnerHTML:{__html:ft[u===`markdown`?`copied`:`markdown`]}})]}),t[14]=u,t[15]=x,t[16]=o,t[17]=l,t[18]=g,t[19]=w):w=t[19];let T;return t[20]!==S||t[21]!==n||t[22]!==i||t[23]!==w||t[24]!==v?(T=(0,X.jsxs)(S,{...i,title:v,children:[n,w]}),t[20]=S,t[21]=n,t[22]=i,t[23]=w,t[24]=v,t[25]=T):T=t[25],T}function _f(e){return e.language}function vf(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)}var yf=new Na().tlds([`app`,`cloud`,`dev`,`online`,`site`,`tech`,`xyz`],!0);function bf(e){return(yf.match(e.replace(/[,。;!?、:()【】《》「」『』]/g,` `))??[]).flatMap(e=>{if(e.schema!==``)return[];try{let t=new URL(`https://${e.raw}`);return ut(t.hostname)?[]:[{start:e.index,end:e.lastIndex,label:e.raw,url:t.href}]}catch{return[]}})}function xf(e,t){let n=new URLSearchParams({path:e});return t&&n.set(`line`,String(t)),`/xopc/workspace/file?${n}`}function Sf(e,t){if(t){let t=ia(e);if(t.kind===`internal-route`)return`#${t.route}`;if(e.startsWith(`#`))return e;let[n]=bf(e);if(n?.start===0&&n.end===e.length)return n.url}let n=ut(e);return n?xf(n.path,n.line):e}function Cf(){return e=>{ga(e,`element`,e=>{e.tagName===`a`&&typeof e.properties.href==`string`?e.properties.href=Sf(e.properties.href,!0):e.tagName===`img`&&typeof e.properties.src==`string`&&(e.properties.src=Sf(e.properties.src,!1))})}}function wf({breaks:e=!1}={}){return t=>{ga(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 _a}if(t.type!==`text`||n.some(e=>e.type===`link`||e.type===`linkReference`))return;let r=[...Array.from(t.value.matchAll(/\[([^\]\n]+)\]\((xopc:\/\/[^\s<>]+?)\)|xopc:\/\/[^\s<>\[\]()"',。;!?、]+/gi),e=>{let t=e[0].replace(/[.,;!?]+$/,``);return{start:e.index,end:e.index+t.length,url:e[2]??t,label:e[1]??t}}),...bf(t.value)].sort((e,t)=>e.start-t.start);if(!r.length&&!(e&&t.value.includes(`
6
+ `&&(s=!1),l===`%`&&!vt(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)&&!vt(a,a.length-p),f}}}var sl={name:`xopcMathInline`,tokenize:ol(!1)},cl={name:`xopcMathFlow`,tokenize:ol(!0),concrete:!0},ll={text:{92:sl,36:sl},flow:{92:cl,36:cl}};function ul(e){return{hName:`code`,hProperties:{className:[e.display?`math-display`:`math-inline`],"data-xopc-math-source":gt(e)},hChildren:[{type:`text`,value:e.raw}]}}var dl={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=Xe(t);Object.assign(n,{value:t,data:ul(r)}),this.exit(e)},xopcMathFlow(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-1],r=tt(t);Object.assign(n,{value:t,data:ul(r)}),this.exit(e)}}};function fl(){let e=this.data();return(e.micromarkExtensions??=[]).push(ll),(e.fromMarkdownExtensions??=[]).push(dl),(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=ul(_t(r)??it(r,n))}for(let t of e.children??[])n(t)}n(e)}}var pl=new Map,ml=0;function hl(e){if(!/\\[([]|\$|^\s*```math/m.test(e))return[];let t=pl.get(e);if(t)return t;let n=aa(e,{extensions:[ll],mdastExtensions:[dl]}),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(;pl.size>=256||ml+e.length>1048576;){let e=pl.keys().next().value;ml-=e.length,pl.delete(e)}pl.set(e,r),ml+=e.length}return r}function gl(e=e=>hl(e).length){let t=[],n=[];return r=>{let i=0,a=[],o=r.map((n,r)=>{let o=Math.max(0,256-i),s=t[r],c=s?.source===n?s:{source:n,count:e(n)};return a.push(c),i+=c.count,o});return t=a,o.length===n.length&&o.every((e,t)=>e===n[t])?n:(n=o,o)}}var _l=/^(?:查看(?:高清|原|大)?图片|查看大图|查看原图|view(?: (?:full[- ]size|original|hd))? image)$/i;function vl(e){return _l.test(e)}function yl(){let e=new Set,t;function n(e){let t=e.closest(`p`);if(!t||t.querySelector(`a`)!==e)return;let n=!1,r=e.textContent?.trim()??``;if(r===t.textContent?.trim()&&vl(r)){let r=t.nextElementSibling,i=r&&!r.matches(`[data-xopc-watermark]`)?r:t.closest(`.markdown-stream-block`)?.nextElementSibling?.firstElementChild;if(i?.matches(`[data-chat-media]`)){let t=i.querySelectorAll(`[data-chat-media-source]`);n=t.length===1&&t[0].dataset.chatMediaSource===e.getAttribute(`href`)}}t.hidden!==n&&(t.hidden=n)}return r=>{if(!r)return;let i=r.closest(`p`),a=r.closest(`.markdown-render-boundary`);if(!(!i||!a))return e.add(r),n(r),t||(t=new MutationObserver(()=>{for(let t of e)n(t)}),t.observe(a,{subtree:!0,childList:!0,characterData:!0,attributeFilter:[`href`,`data-chat-media`,`data-chat-media-source`]})),()=>{e.delete(r),i.hidden&&=!1,e.size||(t?.disconnect(),t=void 0)}}}var bl={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`}},xl=`https://html.spec.whatwg.org/multipage/parsing.html#parse-error-`,Sl=/-[a-z]/g,Cl=/%c(?:([-+])(\d+))?/g,wl=/%x/g,Tl={2:!0,1:!1,0:null},El={};function Dl(e,t){let n=t||El,r=n.onerror,i=e instanceof la?e:new la(e),a=n.fragment?ua:Ea,o=String(i);return Ta(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=Ol(t),s=n[a]??!0,c=typeof s==`number`?s:+!!s;if(c){let n=bl[a],o=new Ca(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=Tl[c],o.note=l(n.description),o.url=n.url===!1?void 0:xl+t,r(o)}function l(t){return t.replace(Cl,n).replace(wl,r);function n(t,n,r){let i=(r?Number.parseInt(r,10):0)*(n===`-`?-1:1);return Al(o.charAt(e.startOffset+i))}function r(){return jl(o.charCodeAt(e.startOffset))}}}}function Ol(e){return e.replace(Sl,kl)}function kl(e){return e.charAt(1).toUpperCase()}function Al(e){return e==="`"?"` ` `":e}function jl(e){return`0x`+e.toString(16).toUpperCase()}function Ml(e={streaming:!1}){return t=>{let n=0;ma(t,`element`,(t,r)=>{if(t.tagName!==`code`||typeof t.properties[`data-xopc-math-source`]!=`string`)return;let i=rt(t.properties[`data-xopc-math-source`]);if(!i)return;let a=Dl(mt(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),ha})}}var Nl={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},Pl={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},Fl={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`},Il=[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],Ll=[12288,12288,65281,65376,65504,65510],Rl=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],zl=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],Bl=[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],Vl=(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},Hl=19968,[Ul,Wl]=Gl(Bl);function Gl(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(Hl>=i&&Hl<=a)return[i,a];a-i>n-t&&(t=i,n=a)}return[t,n]}var Kl=e=>e<161||e>1114109?!1:Vl(Il,e),ql=e=>e<12288||e>65510?!1:Vl(Ll,e),Jl=e=>e<8361||e>65518?!1:Vl(Rl,e),Yl=e=>e<32||e>10630?!1:Vl(zl,e),Xl=e=>e>=Ul&&e<=Wl?!0:e<4352||e>262141?!1:Vl(Bl,e);function Zl(e){return Kl(e)?`ambiguous`:ql(e)?`fullwidth`:Jl(e)?`halfwidth`:Yl(e)?`narrow`:Xl(e)?`wide`:`neutral`}function Ql(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function $l(e){return Ql(e),Zl(e)}function eu(e){return/^\p{Emoji_Presentation}/u.test(String.fromCodePoint(e))}function tu(e){if(!e||e<4352)return!1;switch($l(e)){case`fullwidth`:case`halfwidth`:return!0;case`wide`:return!eu(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 nu(e,t){return t!==65025||!e||e<8216?!1:e===8216||e===8217||e===8220||e===8221}function ru(e){return e!==null&&e>=65024&&e<=65038}var iu=ou(/\p{P}|\p{S}/u),au=ou(/\s/);function ou(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCodePoint(t))}}function su(e){return!!(e&Pl.characterGroupWhitespace)}function cu(e){return(e&mu.cjkPunctuation)===Pl.characterGroupPunctuation}function lu(e){return!!(e&mu.cjk)}function uu(e){return e===mu.ivs}function du(e){return!!(e&mu.cjkOrIvs)}function fu(e){return e===mu.nonEmojiGeneralUseVS}function pu(e){return!!(e&mu.spaceOrPunctuation)}var mu;(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})(mu||={});function hu(e){if(e===Nl.eof||ca(e)||au(e))return Pl.characterGroupWhitespace;let t=0;if(e>=4352){if(ru(e))return mu.nonEmojiGeneralUseVS;switch(tu(e)){case null:return mu.ivs;case!0:t|=mu.cjk;break}}return iu(e)&&(t|=Pl.characterGroupPunctuation),t}function gu(e,t,n){if(!fu(e))return e;let r=t(),i=hu(r);return!r||su(i)?e:nu(r,n)?mu.cjkPunctuation:_u(i)}function _u(e){return e&~mu.ivs}function vu(e){return!!(e&&e>=55296&&e<=56319)}function yu(e){return!!(e&&e>=56320&&e<=57343)}function bu(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 xu(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 Su=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=xu(this.previousCode,this.nowPoint,this.sliceSerialize)),this.cachedValue}};function Cu(e,t,n){let r=n({start:t,end:{...t,_bufferIndex:t._bufferIndex+2}}).codePointAt(0);return r&&r>=65536?r:e}var wu={name:`attention`,resolveAll:Tu,tokenize:Eu};function Tu(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};Du(d,-c),Du(f,c),o={type:c>1?Fl.strongSequence:Fl.emphasisSequence,start:d,end:{...e[r][1].end}},s={type:c>1?Fl.strongSequence:Fl.emphasisSequence,start:{...e[n][1].start},end:f},a={type:c>1?Fl.strongText:Fl.emphasisText,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?Fl.strong:Fl.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=sa(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=sa(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),t.parser.constructs.insideSpan.null,l=sa(l,wa(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=sa(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=sa(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,oa(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 Eu(e,t){let n=this.parser.constructs.attentionMarkers.null,{now:r,sliceSerialize:i,previous:a}=this,o=yu(a)?bu(a,r(),i):a,s=hu(o),c=new Su(o,r(),i),l=gu(s,c.value.bind(c),o),u;return d;function d(t){return t===Nl.asterisk||Nl.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=hu(vu(a)?Cu(a,r(),i):a),d=cu(l),p=o===Nl.asterisk||o===Nl.underscore,m=d||su(l)||p,h=cu(c),g=a===Nl.asterisk||a===Nl.underscore,_=h||su(c)||g,v=du(l),y=!_||h&&(m||v)||n.includes(a)&&a!==Nl.asterisk&&a!==Nl.underscore,b=!m||d&&(_||lu(c))||n.includes(o)&&o!==Nl.asterisk&&o!==Nl.underscore;return s._open=!!(u===Nl.asterisk?y:y&&(pu(l)||!b)),s._close=!!(u===Nl.asterisk?b:b&&(pu(c)||!y)),t(a)}}function Du(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}function Ou(){return{text:{[Nl.asterisk]:wu,[Nl.underscore]:wu},insideSpan:{null:[wu]}}}function ku(){let e=this.data();(e.micromarkExtensions||=[]).push(Ou())}var Au=`;`.codePointAt(0)??Nl.eof,ju=`&`.codePointAt(0)??Nl.eof;function Mu(){return{handlers:{emphasis:Nu,strong:Pu,text:Ru}}}Nu.peek=Fu,Pu.peek=Iu;function Nu(e,t,n,r){return Lu(e,t,n,r,Fu(e,t,n),1)}function Pu(e,t,n,r){return Lu(e,t,n,r,Iu(e,t,n),2)}function Fu(e,t,n){return n.options.emphasis||`*`}function Iu(e,t,n){return n.options.strong||`*`}function Lu(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=Ku(e,t,n,r.before),f=qu(e,t,n,r.after),p=zu(d,ad(u),i,`open`);p.inside&&u&&(u=nd(u));let m=zu({current:od(u),previous:id(u)},f,i,`close`);m.inside&&u&&(u=rd(u));let h=c.move(o);s();let g=m.outside&&Qu(t,n);return n.attentionEncodeSurroundingInfo={after:m.outside&&!g,before:p.outside},$u(n).cjkFriendlyEncodeAfterSupplementaryText=g,l+u+h}function Ru(e,t,n,r){let i=$u(n);if(!i.cjkFriendlyEncodeAfterSupplementaryText)return n.safe(e.value,r);i.cjkFriendlyEncodeAfterSupplementaryText=!1;let[a=``]=[...e.value],o=e.value.slice(a.length);return`${td(a.codePointAt(0)??Nl.eof)}${n.safe(o,{...r,before:`;`})}`}function zu(e,t,n,r){let i=Gu(e),a=hu(t);if(!du(i)&&!du(a))return r===`open`?Bu(i,a,n):Bu(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?sd:e:i.inside?sd:e,o=r===`open`?i.inside?cd:t:i.outside?cd:t;if(r===`open`?Vu(n,a,o):Hu(n,a,o))return i}return l}function Bu(e,t,n){return Wu(e)?Wu(t)?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:su(t)?{inside:!0,outside:!0}:{inside:!1,outside:!0}:su(e)?Wu(t)?{inside:!1,outside:!1}:su(t)?{inside:!0,outside:!0}:{inside:!1,outside:!1}:su(t)?{inside:!0,outside:!1}:{inside:!1,outside:!1}}function Vu(e,t,n){let r=Gu(t),{close:i,open:a}=Uu(r,hu(n));return e===`_`?a&&(pu(r)||!i):a}function Hu(e,t,n){let r=hu(n),{close:i,open:a}=Uu(Gu(t),r);return e===`_`?i&&(pu(r)||!a):i}function Uu(e,t){let n=cu(e),r=n||su(e),i=cu(t),a=i||su(t);return{open:!a||i&&(r||du(e)),close:!r||n&&(a||lu(t))}}function Wu(e){return!su(e)&&!cu(e)}function Gu(e){let t=hu(e.current);return e.current===null||!fu(t)?t:gu(t,()=>e.previous,e.current)}function Ku(e,t,n,r){let i=od(r),a=id(r);if(Ju(i)||Xu(i,a)){let r=Zu(e,t,n,-1);r&&(i=od(r),a=id(r))}return{current:i,previous:a}}function qu(e,t,n,r){let i=ad(r);if(!Yu(i))return i;let a=Zu(e,t,n,1);return a?ad(a):i}function Ju(e){return e!==null&&56320<=e&&e<=57343}function Yu(e){return e!==null&&55296<=e&&e<=56319}function Xu(e,t){return fu(hu(e))&&(t===null||t===Nl.eof)}function Zu(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 ed(s)||void 0}function Qu(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`&&(ad(r.value)??0)>65535}function $u(e){return e}function ed(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(ed).join(``):``}function td(e){return`&#x${(e??0).toString(16).toUpperCase()};`}function nd(e){let[t=``]=[...e];return td(t.codePointAt(0)??Nl.eof)+e.slice(t.length)}function rd(e){let t=[...e],n=t.pop();return`${t.join(``)}${td(n?.codePointAt(0)??Nl.eof)}`}function id(e){let t=[...e];return t.pop(),t.at(-1)?.codePointAt(0)??Nl.eof}function ad(e){return e.codePointAt(0)??Nl.eof}function od(e){return[...e].at(-1)?.codePointAt(0)??Nl.eof}var sd={current:Au,previous:Nl.eof},cd=ju;function ld(){let e=this.data();(e.toMarkdownExtensions||=[]).push(Mu())}function ud(){ku.call(this),ld.call(this)}var dd=ud;function fd(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{[Nl.tilde]:n},insideSpan:{null:[n]},attentionMarkers:{null:[Nl.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&&oa(o,o.length,0,wa(s,e.slice(r+1,n),t)),oa(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),oa(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=Fl.data);return e}function i(e,n,r){let{now:i,sliceSerialize:a,previous:o}=this,s=yu(o)?bu(o,i(),a):o,c=hu(s),l=new Su(s,i(),a),u=gu(c,l.value.bind(l),s),d=this.events,f=0;return p;function p(t){return Nl.tilde,s===Nl.tilde&&d[d.length-1][1].type!==Fl.characterEscape?r(t):(e.enter(`strikethroughSequenceTemporary`),m(t))}function m(o){let c=hu(s);if(o===Nl.tilde)return f>1?r(o):(e.consume(o),f++,m);if(f<2&&!t)return r(o);let l=e.exit(`strikethroughSequenceTemporary`),d=hu(vu(o)?Cu(o,i(),a):o),p=cu(u)||su(u),h=cu(d)||su(d),g=lu(u)||uu(c);return l._open=!h||d===Pl.attentionSideAfter&&(p||g),l._close=!p||c===Pl.attentionSideAfter&&(h||lu(d)),n(o)}}}function pd(e){let t=this.data();(t.micromarkExtensions||=[]).push(fd(e))}var md=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`],hd=`;`.codePointAt(0)??Nl.eof,gd=`&`.codePointAt(0)??Nl.eof;function _d(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:md}],handlers:{delete:vd,text:yd}}}vd.peek=bd;function vd(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=Od(e,t,n,r.before),l=kd(e,t,n,r.after),u=xd(c,Vd(s),`open`);u.inside&&s&&(s=Rd(s));let d=xd({current:Hd(s),previous:Bd(s)},l,`close`);d.inside&&s&&(s=zd(s));let f=a.move(`~~`);i();let p=d.outside&&Pd(t,n);return n.attentionEncodeSurroundingInfo={after:d.outside&&!p,before:u.outside},Fd(n).cjkFriendlyEncodeAfterSupplementaryText=p,o+s+f}function yd(e,t,n,r){let i=Fd(n);if(!i.cjkFriendlyEncodeAfterSupplementaryText)return n.safe(e.value,r);i.cjkFriendlyEncodeAfterSupplementaryText=!1;let[a=``]=[...e.value],o=e.value.slice(a.length);return`${Ld(a.codePointAt(0)??Nl.eof)}${n.safe(o,{...r,before:`;`})}`}function bd(){return`~`}function xd(e,t,n){let r=Dd(e),i=hu(t);if(!du(r)&&!du(i))return n===`open`?Sd(r,i):Sd(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?Ud:e:r.inside?Ud:e,a=n===`open`?r.inside?Wd:t:r.outside?Wd:t;if(n===`open`?Cd(i,a):wd(i,a))return r}return c}function Sd(e,t){return Ed(e)?Ed(t)?{inside:!1,outside:!1}:su(t)?{inside:!0,outside:!0}:{inside:!1,outside:!0}:su(e)?Ed(t)?{inside:!1,outside:!1}:su(t)?{inside:!0,outside:!0}:{inside:!1,outside:!1}:su(t)?{inside:!0,outside:!1}:{inside:!1,outside:!1}}function Cd(e,t){let{open:n}=Td(Dd(e),hu(t));return n}function wd(e,t){let n=hu(t),{close:r}=Td(Dd(e),n);return r}function Td(e,t){let n=cu(e),r=n||su(e),i=cu(t),a=i||su(t);return{open:!a||i&&(r||du(e)),close:!r||n&&(a||lu(t))}}function Ed(e){return!su(e)&&!cu(e)}function Dd(e){let t=hu(e.current);return e.current===null||!fu(t)?t:gu(t,()=>e.previous,e.current)}function Od(e,t,n,r){let i=Hd(r),a=Bd(r);if(Ad(i)||Md(i,a)){let r=Nd(e,t,n,-1);r&&(i=Hd(r),a=Bd(r))}return{current:i,previous:a}}function kd(e,t,n,r){let i=Vd(r);if(!jd(i))return i;let a=Nd(e,t,n,1);return a?Vd(a):i}function Ad(e){return e!==null&&56320<=e&&e<=57343}function jd(e){return e!==null&&55296<=e&&e<=56319}function Md(e,t){return fu(hu(e))&&(t===null||t===Nl.eof)}function Nd(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 Id(s)||void 0}function Pd(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`&&(Vd(r.value)??0)>65535}function Fd(e){return e}function Id(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(Id).join(``):``}function Ld(e){return`&#x${(e??0).toString(16).toUpperCase()};`}function Rd(e){let[t=``]=[...e];return Ld(t.codePointAt(0)??Nl.eof)+e.slice(t.length)}function zd(e){let t=[...e],n=t.pop();return`${t.join(``)}${Ld(n?.codePointAt(0)??Nl.eof)}`}function Bd(e){let t=[...e];return t.pop(),t.at(-1)?.codePointAt(0)??Nl.eof}function Vd(e){return e.codePointAt(0)??Nl.eof}function Hd(e){return[...e].at(-1)?.codePointAt(0)??Nl.eof}var Ud={current:hd,previous:Nl.eof},Wd=gd;function Gd(){let e=this.data();(e.toMarkdownExtensions||=[]).push(_d())}function Kd(e){pd.call(this,e),Gd.call(this)}var qd=Kd,Jd=new Set([`。`,`.`,`,`,`、`,`?`,`!`,`:`,`;`,`(`,`)`,`【`,`】`,`「`,`」`,`『`,`』`,`〈`,`〉`,`《`,`》`]),Yd=/^(https?:\/\/|mailto:|www\.)/i,Xd=e=>{if(e.children.length!==1)return!1;let t=e.children[0];return t.type===`text`&&t.value===e.url},Zd=e=>{let t=0;for(let n of e){if(Jd.has(n))return t;t+=n.length}return null},Qd=(e,t)=>({...t,url:e,children:[{type:`text`,value:e}]}),$d=e=>({type:`text`,value:e}),ef=ga().transforms??[],tf=e=>{let t=[],n=e=>{if(!e)return;let n={type:`paragraph`,children:[$d(e)]};if(Yd.exec(e)?.[0]!==e){let e={type:`root`,children:[n]};for(let t of ef)t(e)}t.push(...n.children)},r=0,i=0;for(let t of e)Jd.has(t)&&(n(e.slice(r,i)),n(t),r=i+t.length),i+=t.length;return n(e.slice(r)),t},nf=()=>e=>{ya(e,`link`,(e,t,n)=>{if(!n||typeof t!=`number`||!Xd(e)||!Yd.test(e.url))return;let r=Zd(e.url);if(r===null||r===0)return;let i=[Qd(e.url.slice(0,r),e),...tf(e.url.slice(r))];return n.children.splice(t,1,...i),t+i.length})};function rf(){let e=[dd],t=[nf,qd];return{name:`cjk`,type:`cjk`,remarkPluginsBefore:e,remarkPluginsAfter:t,remarkPlugins:[...e,...t]}}var af=rf(),of=(0,Q.createContext)(new Map);function sf(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 cf(e){let t=(0,Z.c)(50),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=y(uf),u;t[7]===l?u=t[8]:(u=C(l),t[7]=l,t[8]=u);let d=u.chat,{openImage:f}=Fe(),[p,m]=(0,Q.useState)(0),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(null),[S,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),g({source:o,url:t,attempt:p}))}).catch(()=>{e&&v(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?h?.source===o&&h.attempt===p?h.url:void 0:o,k=_===o,A;t[14]===o?A=t[15]:(A=e=>{e.naturalWidth&&(x({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=b?.source===o?b:null,F=P?Math.min(1,320/P.width,280/P.height):1,I=S!==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]!==S||t[25]!==o?(R=S!==o&&!k&&(0,X.jsx)(sn,{as:`span`,className:`pointer-events-none absolute inset-0`}),t[23]=k,t[24]=S,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,X.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:()=>v(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,X.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,X.jsxs)(`span`,{children:[d.attachmentPreviewLoadError,c?` · ${c}`:``]}),(0,X.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(),v(null),w(null),m(lf)},children:d.userMessageRetry})]}),t[39]=c,t[40]=k,t[41]=d,t[42]=B):B=t[42];let V;return t[43]!==o||t[44]!==L||t[45]!==R||t[46]!==z||t[47]!==B||t[48]!==I?(V=(0,X.jsxs)(`span`,{className:`chat-image-thumbnail`,"data-chat-media-source":o,"data-image-loading":I,style:L,children:[R,z,B]}),t[43]=o,t[44]=L,t[45]=R,t[46]=z,t[47]=B,t[48]=I,t[49]=V):V=t[49],V}function lf(e){return e+1}function uf(e){return e.language}var df=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,X.jsx)(`div`,{className:`whitespace-pre-wrap break-words`,"data-chat-render-fallback":!0,children:this.props.content}):this.props.children}};function ff(e){if(/^\s{0,3}\[[^\]]+\]:|\[[^\]]+\]\[[^\]]*\]|\[\^/m.test(e))return[e];let t=da(e),n=hl(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 pf(){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,...ff(n.slice(i))],e=n,t}}function mf(e){let t=(0,Z.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=y(hf),c;t[5]===s?c=t[6]:(c=C(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`]??``),h;t[10]===m?h=t[11]:(h=rt(m),t[10]=m,t[11]=h);let g=h,_=String(r?.properties.dataXopcMath??r?.properties[`data-xopc-math`]??``),v=_===`pending`?l.mathPending:_===`fallback`?l.mathFailed:void 0,b;t[12]===g?b=t[13]:(b=async e=>{g&&await ra(e?g.raw:g.latex)&&d(e?`markdown`:`latex`)},t[12]=g,t[13]=b);let x=b,S=o?`div`:`span`,w;t[14]!==u||t[15]!==x||t[16]!==o||t[17]!==l||t[18]!==g?(w=o&&g&&(0,X.jsxs)(`span`,{className:`markdown-math-actions`,contentEditable:!1,children:[(0,X.jsx)(`button`,{type:`button`,title:u===`latex`?l.messageCopied:l.mathCopyLatex,"aria-label":l.mathCopyLatex,onClick:()=>void x(!1),dangerouslySetInnerHTML:{__html:ft[u===`latex`?`copied`:`latex`]}}),(0,X.jsx)(`button`,{type:`button`,title:u===`markdown`?l.messageCopied:l.mathCopyMarkdown,"aria-label":l.mathCopyMarkdown,onClick:()=>void x(!0),dangerouslySetInnerHTML:{__html:ft[u===`markdown`?`copied`:`markdown`]}})]}),t[14]=u,t[15]=x,t[16]=o,t[17]=l,t[18]=g,t[19]=w):w=t[19];let T;return t[20]!==S||t[21]!==n||t[22]!==i||t[23]!==w||t[24]!==v?(T=(0,X.jsxs)(S,{...i,title:v,children:[n,w]}),t[20]=S,t[21]=n,t[22]=i,t[23]=w,t[24]=v,t[25]=T):T=t[25],T}function hf(e){return e.language}function gf(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)}var _f=new ja().tlds([`app`,`cloud`,`dev`,`online`,`site`,`tech`,`xyz`],!0);function vf(e){return(_f.match(e.replace(/[,。;!?、:()【】《》「」『』]/g,` `))??[]).flatMap(e=>{if(e.schema!==``)return[];try{let t=new URL(`https://${e.raw}`);return ut(t.hostname)?[]:[{start:e.index,end:e.lastIndex,label:e.raw,url:t.href}]}catch{return[]}})}function yf(e,t){let n=new URLSearchParams({path:e});return t&&n.set(`line`,String(t)),`/xopc/workspace/file?${n}`}function bf(e,t){if(t){let t=na(e);if(t.kind===`internal-route`)return`#${t.route}`;if(e.startsWith(`#`))return e;let[n]=vf(e);if(n?.start===0&&n.end===e.length)return n.url}let n=ut(e);return n?yf(n.path,n.line):e}function xf(){return e=>{ma(e,`element`,e=>{e.tagName===`a`&&typeof e.properties.href==`string`?e.properties.href=bf(e.properties.href,!0):e.tagName===`img`&&typeof e.properties.src==`string`&&(e.properties.src=bf(e.properties.src,!1))})}}function Sf({breaks:e=!1}={}){return t=>{ma(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 ha}if(t.type!==`text`||n.some(e=>e.type===`link`||e.type===`linkReference`))return;let r=[...Array.from(t.value.matchAll(/\[([^\]\n]+)\]\((xopc:\/\/[^\s<>]+?)\)|xopc:\/\/[^\s<>\[\]()"',。;!?、]+/gi),e=>{let t=e[0].replace(/[.,;!?]+$/,``);return{start:e.index,end:e.index+t.length,url:e[2]??t,label:e[1]??t}}),...vf(t.value)].sort((e,t)=>e.start-t.start);if(!r.length&&!(e&&t.value.includes(`
7
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)e.start<o||(a(t.value.slice(o,e.start)),i.push({type:`link`,url:e.url,children:[{type:`text`,value:e.label}]}),o=e.end);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),_a})}}function Tf(){return e=>{ga(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=at(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:xf(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),_a})}}function Ef({prefix:e}){return t=>{let n=new Map;ga(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}),ga(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 Df=typeof Intl.Segmenter==`function`?new Intl.Segmenter(void 0,{granularity:`word`}):null,Of=typeof Intl.Segmenter==`function`?new Intl.Segmenter(void 0,{granularity:`grapheme`}):null;function kf(e){return Df?Array.from(Df.segment(e),({segment:e,index:t})=>({text:e,offset:t})):[{text:e,offset:0}]}function Af(e,t){if(t>=e.length||!Of)return e.length;let n=Of.segment(e).containing(t);return n&&n.index!==t?n.index+n.segment.length:t}var jf=256,Mf=(0,Q.createContext)(null),Nf=(0,Q.createContext)(null);function Pf(e){let t=(0,Z.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)(Mf),i=(0,Q.useContext)(Nf),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>=jf)return;let t=performance.now(),n=r.starts.get(o);if(n===void 0&&!c)return;if(n===void 0){if(r.starts.size>=jf)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,X.jsx)(`span`,{...n,ref:a}),t[11]=n,t[12]=d),d}function Ff(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=jf-(r?.size??0),l=performance.now();ga(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=kf(t.value).flatMap(t=>{let n=e.length-i-t.offset;if(n<=0||n>=t.text.length)return[t];let r=Af(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),[_a,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 If=(0,Q.createContext)(null),Lf=(0,Q.createContext)(``);function Rf(e){let t=(0,Z.c)(56),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)(If),l=(0,Q.useContext)(cf),{openImage:u}=Fe(),d=y(zf),f;t[6]===d?f=t[7]:(f=C(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 h=m,g,_,v,b,x,S,w,T,E,D;if(t[10]!==n||t[11]!==c||t[12]!==h||t[13]!==s||t[14]!==p||t[15]!==i||t[16]!==a||t[17]!==l){w=Symbol.for(`react.early_return_sentinel`);bb0:{if(E=i?Gf(i).trim():typeof n==`string`?n.trim():``,_=ra(ia(s),E),_.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[28]===r?i=t[29]:(i={kind:`internal-route`,route:r},t[28]=r,t[29]=i),_=i}}if(T=!s.startsWith(`#`)&&_.kind!==`internal-route`&&c.openFile?ut(s):null,!h&&!T&&_.kind===`blocked`){let e;t[30]===n?e=t[31]:(e=(0,X.jsx)(X.Fragment,{children:n}),t[30]=n,t[31]=e),w=e;break bb0}let e=_.kind===`internal-route`?_.route:void 0;v=!!e;let r=e?e.slice(1).split(/[/?#]/,1)[0]:``;b=p.destinations[r]??p.open,D=v&&/^(?:xopc:\/\/|#\/|Open(?: in xopc)?$|打开$)/i.test(E)?b:n,g=e?`#${e}`:s,x=a,S=bl(E)?c.trackImageLink:void 0}t[10]=n,t[11]=c,t[12]=h,t[13]=s,t[14]=p,t[15]=i,t[16]=a,t[17]=l,t[18]=g,t[19]=_,t[20]=v,t[21]=b,t[22]=x,t[23]=S,t[24]=w,t[25]=T,t[26]=E,t[27]=D}else g=t[18],_=t[19],v=t[20],b=t[21],x=t[22],S=t[23],w=t[24],T=t[25],E=t[26],D=t[27];if(w!==Symbol.for(`react.early_return_sentinel`))return w;let O=v||T||h?void 0:`_blank`,k;t[32]!==r||t[33]!==T?(k=[r,T?`markdown-file-link`:``].filter(Boolean).join(` `)||void 0,t[32]=r,t[33]=T,t[34]=k):k=t[34];let A=h?`document-fragment`:T?void 0:_.kind,j=T?.path,M=T?.kind,N=T?.line,P=c.linkError===g?p.failed:a.title||(v?b:void 0),F;t[35]!==g||t[36]!==c||t[37]!==h||t[38]!==s||t[39]!==u||t[40]!==T||t[41]!==E?(F=e=>{if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;if(e.preventDefault(),h){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(E)){u(t.src,t.alt);return}if(T){c.openFile?.(T);return}c.openLink(g)},t[35]=g,t[36]=c,t[37]=h,t[38]=s,t[39]=u,t[40]=T,t[41]=E,t[42]=F):F=t[42];let I;return t[43]!==g||t[44]!==j||t[45]!==M||t[46]!==N||t[47]!==P||t[48]!==F||t[49]!==x||t[50]!==S||t[51]!==O||t[52]!==k||t[53]!==A||t[54]!==D?(I=(0,X.jsx)(`a`,{...x,ref:S,href:g,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:D}),t[43]=g,t[44]=j,t[45]=M,t[46]=N,t[47]=P,t[48]=F,t[49]=x,t[50]=S,t[51]=O,t[52]=k,t[53]=A,t[54]=D,t[55]=I):I=t[55],I}function zf(e){return e.language}function Bf({node:e,src:t=``,alt:n,...r}){let i=(0,Q.useContext)(If),a=ut(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,X.jsx)(uf,{...r,source:t,alt:n,load:a?l:void 0})}function Vf(e){let t=(0,Z.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(Wf)&&n.children.every(Hf),t[3]=n,t[4]=i);let a=i||void 0,o;return t[5]!==r||t[6]!==a?(o=(0,X.jsx)(`p`,{...r,"data-chat-media":a}),t[5]=r,t[6]=a,t[7]=o):o=t[7],o}function Hf(e){return e.type===`text`?!e.value.trim():e.type===`element`&&(e.tagName===`img`||e.tagName===`a`&&e.children.every(Uf))}function Uf(e){return e.type===`element`&&e.tagName===`img`}function Wf(e){return e.type===`element`}function Gf(e){return e.children.map(e=>e.type===`text`?e.value:e.type===`element`?Gf(e):``).join(``)}function Kf(e){let t=(0,Z.c)(20),{node:n}=e,r=(0,Q.useContext)(If),i=(0,Q.useContext)(Lf),a=ya(),o,s;if(t[0]!==n?.children){let e=n?.children.find(qf);o=String(e?.properties.className??``).match(/language-([^,\s]+)/)?.[1]??``,s=e?Gf(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||!vf(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,X.jsx)(Ma,{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,X.jsx)(Aa,{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 qf(e){return e.type===`element`&&e.tagName===`code`}function Jf(e){let t=(0,Z.c)(4),n;if(t[0]!==e){let{node:r,...i}=e;n=i,t[0]=e,t[1]=n}else n=t[1];let r;return t[2]===n?r=t[3]:(r=(0,X.jsx)(`div`,{className:`markdown-table-scroll`,tabIndex:0,children:(0,X.jsx)(`table`,{...n})}),t[2]=n,t[3]=r),r}function Yf(e){let t=(0,Z.c)(2),n;return t[0]===e?n=t[1]:(n=e.node?.properties.dataXopcMath??e.node?.properties[`data-xopc-math`]?(0,X.jsx)(gf,{...e}):(0,X.jsx)(Pf,{...e}),t[0]=e,t[1]=n),n}function Xf(e){let t=(0,Z.c)(2),n;return t[0]===e?n=t[1]:(n=e.node?.properties.dataXopcMath??e.node?.properties[`data-xopc-math`]?(0,X.jsx)(gf,{...e,display:!0}):(0,X.jsx)(`div`,{...Object.fromEntries(Object.entries(e).filter(Zf))}),t[0]=e,t[1]=n),n}function Zf(e){let[t]=e;return t!==`node`}var Qf=/^[+−-]?(?:\p{Sc}\s?|v)?\p{Nd}+(?:[.,:/\u00a0\u202f-]\p{Nd}+)*(?:\s?(?:[%%‰]|\p{Sc}|ms|s|KB|MB|GB|TB))?$/iu,$f=e=>function({node:t,...n}){let r=(e===`th`||e===`td`)&&typeof t?.properties.align==`string`?t.properties.align:void 0,i=e===`td`&&t?Gf(t).trim():``,a=i.length<=16&&Qf.test(i);return(0,Q.createElement)(e,{...n,"data-markdown-align":r,"data-markdown-compact-number":a||void 0})},ep={a:Rf,img:Bf,pre:Kf,span:Yf,div:Xf,p:Vf,h1:$f(`h1`),h2:$f(`h2`),h3:$f(`h3`),h4:$f(`h4`),h5:$f(`h5`),h6:$f(`h6`),ul:$f(`ul`),ol:$f(`ol`),li:$f(`li`),strong:$f(`strong`),em:$f(`em`),blockquote:$f(`blockquote`),code:$f(`code`),table:Jf,thead:$f(`thead`),tbody:$f(`tbody`),tr:$f(`tr`),th:$f(`th`),td:$f(`td`),hr:$f(`hr`)},tp=[Cf,[ma,{...ha,attributes:{...ha.attributes,code:[...ha.attributes?.code??[],[`className`,/^language-/,`math-inline`,`math-display`],`data-xopc-math-source`]}}]],np=e=>/^\s{0,3}\[[^\]]+\]:|\[[^\]]+\]\[[^\]]*\]|\[\^/m.test(e),rp=(0,Q.memo)(function(e){let t=(0,Q.useId)(),n=(0,Q.useContext)(If),r=(0,Q.useRef)(null),i=(0,Q.useContext)(Nf),[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)&&!np(e.content)&&!f,m=(0,Q.useMemo)(()=>Ff(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]===Pl?[Pl,{streaming:n.streaming,maxCount:h}]:e),m],[e.rehypePlugins,m,n.streaming,h]),_=performance.now();return(0,Q.useLayoutEffect)(()=>{n.metricsKey&&dt(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,X.jsx)(`div`,{ref:r,className:`markdown-stream-block`,children:(0,X.jsx)(pf,{content:e.content,children:(0,X.jsx)(Lf.Provider,{value:e.content,children:(0,X.jsx)(Mf.Provider,{value:a,children:(0,X.jsx)(ba,{...e,shouldParseIncompleteMarkdown:e.shouldParseIncompleteMarkdown&&_l(e.content).length===0,rehypePlugins:g})})})})})}),ip=(0,Q.memo)(function(e){let t=(0,Z.c)(94),{content:n,compact:i,breaks:a,className:o,codeCopy:s,onWorkspaceFileOpen:c,onWorkspaceImageLoad:l,renderMermaid:u,mermaidActions:d,streamingMetricsKey:f,responseRunId:p,streaming:m}=e,h=i!==void 0&&i,g=a!==void 0&&a,_=s===void 0||s,v=u===void 0||u,b=d!==void 0&&d,x=m!==void 0&&m,S=(0,Q.useId)(),w=(0,Q.useRef)(null),T=nt(),E=y(ap),[D,O]=(0,Q.useState)(null),k=(0,Q.useRef)(0),A=(0,Q.useRef)(null),j;t[0]===T?j=t[1]:(j=e=>{let t=k.current+=1;A.current=e,O(null),T(e).then(n=>{t===k.current&&(n.ok&&(A.current=null),O(n.ok?null:e))}).catch(()=>{t===k.current&&O(e)})},t[0]=T,t[1]=j);let M=j,N,P;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(N=()=>()=>{k.current+=1},P=[],t[2]=N,t[3]=P):(N=t[2],P=t[3]),(0,Q.useEffect)(N,P);let F;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>{let e=A.current;!e||Array.from(w.current?.querySelectorAll(`a[href]`)??[]).some(t=>t.getAttribute(`href`)===e)||(A.current=null,k.current+=1,O(null))},t[4]=F):F=t[4];let I;t[5]===n?I=t[6]:(I=[n],t[5]=n,t[6]=I),(0,Q.useEffect)(F,I);let[L]=(0,Q.useState)(op),R;t[7]!==n||t[8]!==x?(R=()=>x||!n?`streaming`:`static`,t[7]=n,t[8]=x,t[9]=R):R=t[9];let[z]=(0,Q.useState)(R),[B]=(0,Q.useState)(hf),V;t[10]!==n||t[11]!==z?(V=()=>z===`streaming`?mf(n).length:0,t[10]=n,t[11]=z,t[12]=V):V=t[12];let[H]=(0,Q.useState)(V),U;t[13]===x?U=t[14]:(U=[Pl,{streaming:x}],t[13]=x,t[14]=U);let W=U,ee;t[15]===W?ee=t[16]:(ee={cjk:sf,math:{name:`katex`,type:`math`,remarkPlugin:ml,rehypePlugin:W}},t[15]=W,t[16]=ee);let te=ee,[ne]=(0,Q.useState)(vl),[re]=(0,Q.useState)(xl),ie;t[17]!==B||t[18]!==n||t[19]!==ne?(ie=ne(B(n)),t[17]=B,t[18]=n,t[19]=ne,t[20]=ie):ie=t[20];let ae=ie,oe;t[21]!==_||t[22]!==H||t[23]!==D||t[24]!==ae||t[25]!==b||t[26]!==c||t[27]!==l||t[28]!==M||t[29]!==v||t[30]!==x||t[31]!==f||t[32]!==re?(oe={openLink:M,linkError:D,streaming:x,initialBlocks:H,mathRemaining:ae,metricsKey:f,trackImageLink:re,copy:_,renderMermaid:v,mermaidActions:b,openFile:c,loadImage:l},t[21]=_,t[22]=H,t[23]=D,t[24]=ae,t[25]=b,t[26]=c,t[27]=l,t[28]=M,t[29]=v,t[30]=x,t[31]=f,t[32]=re,t[33]=oe):oe=t[33];let se=oe,ce;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(ce=Object.values(wa),t[34]=ce):ce=t[34];let le;t[35]===g?le=t[36]:(le=[...ce,[wf,{breaks:g}]],t[35]=g,t[36]=le);let ue=le,de;t[37]===c?de=t[38]:(de=c?[Tf]:[],t[37]=c,t[38]=de);let fe=`xopc-markdown-${S}`,pe;t[39]===fe?pe=t[40]:(pe=[Ef,{prefix:fe}],t[39]=fe,t[40]=pe);let G;t[41]!==de||t[42]!==pe?(G=[...tp,...de,pe],t[41]=de,t[42]=pe,t[43]=G):G=t[43];let me=G,he;t[44]!==n||t[45]!==p?(he=()=>{if(!r||!p||!n.trim())return;let e=requestAnimationFrame(()=>{if(cr(p)){let e=w.current;if(!e?.getClientRects().length||!e.innerText?.trim())return}_r(p,n)});return()=>cancelAnimationFrame(e)},t[44]=n,t[45]=p,t[46]=he):he=t[46];let K;t[47]!==n||t[48]!==p||t[49]!==x?(K=[n,p,x],t[47]=n,t[48]=p,t[49]=x,t[50]=K):K=t[50],(0,Q.useLayoutEffect)(he,K);let ge;t[51]===f?ge=t[52]:(ge=()=>{if(!r||!f)return;let e=w.current?.querySelectorAll(`.markdown-stream-block`);lt(f,Math.max(0,(e?.length??0)-1),e?.item((e.length??1)-1)?.textContent?.length??0)},t[51]=f,t[52]=ge);let _e;t[53]!==n||t[54]!==f?(_e=[n,f],t[53]=n,t[54]=f,t[55]=_e):_e=t[55],(0,Q.useLayoutEffect)(ge,_e);let q;t[56]===E?q=t[57]:(q=C(E),t[56]=E,t[57]=q);let ve=q.chat.attachmentPreviewClose,ye=h?`markdown-compact`:``,J=g?`markdown-breaks`:``,be=c?`markdown-workspace-links`:``,xe;t[58]!==o||t[59]!==ye||t[60]!==J||t[61]!==be?(xe=[`markdown-body xopc-chat-markdown`,ye,J,be,o].filter(Boolean),t[58]=o,t[59]=ye,t[60]=J,t[61]=be,t[62]=xe):xe=t[62];let Se=xe.join(` `),Ce;t[63]!==B||t[64]!==n||t[65]!==z||t[66]!==te||t[67]!==me||t[68]!==ue||t[69]!==x||t[70]!==Se?(Ce=(0,X.jsx)(Ca,{className:Se,mode:z,isAnimating:x,animated:!1,parseIncompleteMarkdown:x,components:ep,plugins:te,controls:!1,BlockComponent:rp,parseMarkdownIntoBlocksFn:B,remarkPlugins:ue,rehypePlugins:me,urlTransform:Sa,children:n}),t[63]=B,t[64]=n,t[65]=z,t[66]=te,t[67]=me,t[68]=ue,t[69]=x,t[70]=Se,t[71]=Ce):Ce=t[71];let we;t[72]!==n||t[73]!==Ce?(we=(0,X.jsx)(pf,{content:n,children:Ce}),t[72]=n,t[73]=Ce,t[74]=we):we=t[74];let Te;t[75]!==D||t[76]!==E?(Te=D?(0,X.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:C(E).chat.contentLinks.failed}):null,t[75]=D,t[76]=E,t[77]=Te):Te=t[77];let Ee;t[78]!==S||t[79]!==we||t[80]!==Te?(Ee=(0,X.jsxs)(`div`,{ref:w,className:`markdown-render-boundary`,"data-chat-markdown":S,children:[we,Te]}),t[78]=S,t[79]=we,t[80]=Te,t[81]=Ee):Ee=t[81];let De;t[82]!==L||t[83]!==Ee?(De=(0,X.jsx)(Nf.Provider,{value:L,children:Ee}),t[82]=L,t[83]=Ee,t[84]=De):De=t[84];let Oe;t[85]!==n||t[86]!==De?(Oe=(0,X.jsx)(Lf.Provider,{value:n,children:De}),t[85]=n,t[86]=De,t[87]=Oe):Oe=t[87];let ke;t[88]!==se||t[89]!==Oe?(ke=(0,X.jsx)(If.Provider,{value:se,children:Oe}),t[88]=se,t[89]=Oe,t[90]=ke):ke=t[90];let Ae;return t[91]!==q.chat.attachmentPreviewClose||t[92]!==ke?(Ae=(0,X.jsx)(Pe,{interactive:!0,closeLabel:ve,children:ke}),t[91]=q.chat.attachmentPreviewClose,t[92]=ke,t[93]=Ae):Ae=t[93],Ae});function ap(e){return e.language}function op(){return new Set}function sp(e){let t=(0,Z.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,X.jsx)(ne,{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,X.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,X.jsx)(`span`,{className:`font-medium`,children:n}),t[10]=n,t[11]=_);let v;t[12]!==a||t[13]!==o?(v=a?(0,X.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,X.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,X.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,X.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,X.jsx)(I,{"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,X.jsxs)(Yi,{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 cp(e,t,n=`draft`,r){let i=v.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?Qr(o,r):{read:async()=>void 0,write:async e=>{}}}function lp({prompt:e,focusRequestKey:t,submitting:n,submitError:r,labels:i,onSubmit:a,onAgentDecide:o,onCancel:s}){let c=C(y(e=>e.language)).chat,[l,u]=(0,Q.useState)({index:0,answers:{}}),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(!1),b=(0,Q.useRef)(!1),x=(0,Q.useRef)(!1),[S,w]=(0,Q.useState)(),T=(0,Q.useRef)(l),E=(0,Q.useRef)(null),D=(0,Q.useRef)(null),O=e?.questions??[],k=O[Math.min(l.index,O.length-1)],A=k?l.answers[k.id]:void 0,j=(0,Q.useRef)(cp(e.requestId,e.version??1,`draft`,e.conversationId)),M=n||h,N=M||_,P=O.filter(e=>{let t=l.answers[e.id];return t&&(t.choiceId||t.text?.trim())}).length;(0,Q.useEffect)(()=>{let t=!0;cp(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 j.current.read().then(t=>{e||(t&&!b.current&&t.index>=0&&t.index<O.length&&t.answers&&(T.current=t,u(t)),f(!0))}).catch(()=>{e||f(!0)}),()=>{e=!0}},[O.length]),(0,Q.useEffect)(()=>{if(!d||!b.current)return;let e=window.setTimeout(()=>{j.current.write(l).catch(()=>{})},300);return()=>window.clearTimeout(e)},[l,d]),(0,Q.useEffect)(()=>{S&&D.current?.focus()},[S]),(0,Q.useEffect)(()=>{!d||!t||(E.current?.scrollIntoView?.({block:`nearest`}),E.current?.focus({preventScroll:!0}))},[t,d]);function F(e,t=!1){b.current=!0,T.current=e,u(e),m(``),t&&j.current.write(e).catch(()=>{})}function I(e){F({...l,index:e},!0),E.current?.focus()}async function L(t=T.current){if(!(M||x.current||!e)){x.current=!0,g(!0);try{let n={schemaVersion:2,answers:O.map(e=>t.answers[e.id]??{questionId:e.id})};dr(e,n),await j.current.write(t),await a(n)}catch(e){m(e instanceof Error?e.message:String(e))}finally{x.current=!1,g(!1)}}}function R(e){if(N||x.current||!k)return;let t={...T.current,answers:{...T.current.answers,[k.id]:{questionId:k.id,choiceId:e}}};F(t);let n=O.findIndex(e=>{let n=t.answers[e.id];return!n?.choiceId&&!n?.text?.trim()});n===-1?L(t):(F({...t,index:n},!0),E.current?.focus())}if(!d)return(0,X.jsxs)(`div`,{className:`mb-4 space-y-3 rounded-lg border border-edge p-4`,children:[(0,X.jsx)(sn,{className:`h-5 w-1/2`}),(0,X.jsx)(sn,{className:`h-24 w-full`})]});if(!k)return null;let z=!!(A?.choiceId||A?.text?.trim())&&(A?.text?.length??0)<=2e3,B=k.type!==`single_choice`||S===k.id||!!A?.text,V=`clarify-${e.requestId}-${k.id}`;return(0,X.jsxs)(`section`,{ref:E,tabIndex:-1,"aria-label":i.clarifyRegionAria,"aria-busy":M,"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`,Pa.focusRingPanel),children:[(0,X.jsxs)(`header`,{className:`shrink-0 border-b border-edge-subtle px-4 py-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.clarifyRegionAria}),(0,X.jsx)(`span`,{role:`status`,className:`text-xs text-fg-muted`,children:M?i.clarifySubmitting:c.clarifyProgress.replace(`{{answered}}`,String(P)).replace(`{{total}}`,String(O.length))})]}),O.length>1?(0,X.jsx)(`nav`,{"aria-label":c.clarifyQuestions,className:`mt-2 flex flex-wrap gap-1`,children:O.map((e,t)=>(0,X.jsxs)(Yi,{variant:t===l.index?`secondary`:`ghost`,disabled:N,"aria-current":t===l.index?`step`:void 0,onClick:()=>I(t),children:[t+1,`. `,e.header,l.answers[e.id]?.choiceId||l.answers[e.id]?.text?.trim()?` ✓`:``]},e.id))}):null]}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto px-4 py-3`,children:[(0,X.jsx)(ip,{content:k.question,compact:!0,className:`text-fg [&_p]:font-medium`}),k.type===`single_choice`?(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:O.length>1?c.clarifyBatchQuickHint:i.clarifyQuickHint}):null,k.type===`single_choice`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{role:`group`,"aria-label":k.header,className:`space-y-0.5 rounded-lg border border-edge p-1`,children:k.choices.map((e,t)=>(0,X.jsx)(sp,{...e,index:t,recommended:k.recommendedChoiceId===e.id,recommendedLabel:i.clarifyRecommended,selected:A?.choiceId===e.id,disabled:N,onClick:()=>R(e.id)},e.id))}),(0,X.jsxs)(Yi,{variant:`ghost`,disabled:N,"aria-expanded":B,"aria-controls":V,className:`min-h-11 justify-start gap-1 px-1 text-xs`,onClick:()=>w(B?void 0:k.id),children:[(0,X.jsx)(ie,{"aria-hidden":`true`,className:Y(`size-3.5`,B&&`rotate-90`)}),i.clarifyCustomLabel]})]}):null,B?(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{htmlFor:V,className:`sr-only`,children:i.clarifyCustomLabel}),(0,X.jsx)(`textarea`,{ref:D,id:V,rows:3,disabled:N,value:A?.text??``,"aria-invalid":(A?.text?.length??0)>2e3,onChange:e=>F({...l,answers:{...l.answers,[k.id]:{questionId:k.id,text:e.target.value}}}),onKeyDown:e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&!e.nativeEvent.isComposing&&(e.preventDefault(),l.index===O.length-1?L():z&&I(l.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,X.jsxs)(`p`,{className:`flex justify-between gap-2 text-xs text-fg-muted`,children:[(0,X.jsx)(`span`,{children:i.clarifyKeyboardHint}),(0,X.jsxs)(`span`,{children:[A?.text?.length??0,`/2000`]})]})]}):null,r||p?(0,X.jsx)(`p`,{role:`alert`,className:`text-red-600`,children:r||p}):null]}),(0,X.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,X.jsx)(Yi,{variant:`ghost`,disabled:N,onClick:()=>void s(),children:i.clarifyCancel}),o?(0,X.jsx)(Yi,{variant:`ghost`,disabled:N,onClick:()=>void o(),children:i.clarifyAgentDecide}):null,O.length>1?(0,X.jsx)(Yi,{variant:`secondary`,disabled:N||l.index===0,onClick:()=>I(l.index-1),children:c.clarifyPrevious}):null,B||_||r||p||P===O.length?l.index<O.length-1&&!_?(0,X.jsx)(Yi,{variant:`primary`,disabled:N||!z,onClick:()=>I(l.index+1),children:c.clarifyNext}):(0,X.jsx)(Yi,{variant:`primary`,disabled:M||P!==O.length||!z,onClick:()=>void L(),children:M?i.clarifySubmitting:_?c.clarifyRetrySubmission:c.clarifySubmitAll}):null]})]})}function up(e){let t=(0,Z.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,X.jsx)(lp,{...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,X.jsx)(dp,{...e,prompt:e.prompt},e.prompt.requestId):null,t[3]=e,t[4]=n),n}function dp({prompt:e,focusRequestKey:t,submitting:n,submitError:r,labels:i,onSubmit:a,onAgentDecide:o,onCancel:s}){let[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(Date.now),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(``),b=(0,Q.useRef)(!1),x=(0,Q.useRef)(null),S=(0,Q.useRef)(null),C=(0,Q.useRef)(null),[w]=(0,Q.useState)(()=>e.serverTime?e.serverTime-Date.now():0),T=e.expiresAt===void 0?null:Math.max(0,Math.ceil((e.expiresAt-m-w)/1e3)),E=T===0,D=n||g||E,O=e.kind===`approval`,k=f||!e.choiceDetails?.length,A=e.choiceDetails??[],j=c.trim().length>Br,M=`clarify-answer-${e.requestId}`,N=`clarify-error-${e.requestId}`,P=`clarify-hint-${e.requestId}`,F=e.recommendedChoiceId;(0,Q.useEffect)(()=>{t&&x.current?.scrollIntoView?.({block:`nearest`}),x.current?.focus({preventScroll:!!t})},[t]),(0,Q.useEffect)(()=>{(r||v)&&S.current?.focus()},[r,v]),(0,Q.useEffect)(()=>{f&&C.current?.focus()},[f]),(0,Q.useEffect)(()=>{if(!e.expiresAt)return;let t=window.setInterval(()=>h(Date.now()),1e3);return()=>window.clearInterval(t)},[e.expiresAt]),(0,Q.useEffect)(()=>{C.current&&(C.current.style.height=`auto`,C.current.style.height=`${Math.min(160,C.current.scrollHeight)}px`)},[c]);let I=async t=>{if(!(D||b.current)){b.current=!0,_(!0),y(``);try{dr(e,t),await a(t)}catch(e){y(e instanceof Error?e.message:String(e))}finally{b.current=!1,_(!1)}}},L=e=>{D||(d(e),I({response:{choiceId:e}}))},R=()=>{j||!c.trim()||I({response:{text:c.trim()||void 0}})};return(0,X.jsxs)(`section`,{ref:x,tabIndex:-1,"data-clarification-id":e.requestId,"aria-label":O?i.clarifyApprovalTitle:i.clarifyRegionAria,"aria-busy":n||g,className:Y(`mb-4 rounded-lg border border-edge bg-surface-overlay px-4 py-3 text-sm text-fg outline-none`,Pa.focusRingPanel),children:[(0,X.jsx)(`p`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:O?i.clarifyApprovalTitle:i.clarifyRegionAria}),(0,X.jsx)(ip,{content:e.question,compact:!0,className:`mb-3 text-fg [&_p]:font-medium`}),O&&e.approval?(0,X.jsx)(`dl`,{className:`mb-3 space-y-2`,children:[[i.clarifyOperation,e.approval.operation],[i.clarifyTarget,e.approval.target],[i.clarifyImpact,e.approval.impact]].map(([e,t])=>t?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-xs text-fg-muted`,children:e}),(0,X.jsx)(`dd`,{className:`whitespace-pre-wrap break-words`,children:t})]},e):null)}):null,O&&e.approval?.argumentsPreview?(0,X.jsxs)(`details`,{className:`mb-3`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer text-fg-muted`,children:i.clarifyDetails}),(0,X.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,X.jsxs)(`div`,{className:`mb-3 space-y-1 text-xs text-fg-muted`,children:[O?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{children:i.clarifyOnce}),(0,X.jsx)(`p`,{children:i.clarifyApprovalTimeout})]}):null,T===null?null:(0,X.jsx)(`p`,{role:`status`,children:E?i.clarifyExpired:i.clarifyTimeRemaining.replace(`{{time}}`,`${Math.floor(T/60)}:${String(T%60).padStart(2,`0`)}`)})]}),r||v?(0,X.jsx)(`div`,{ref:S,tabIndex:-1,id:N,role:`alert`,className:`mb-3 rounded-md border border-edge p-3 text-red-600`,children:r||v}):null,n||g?(0,X.jsx)(`p`,{role:`status`,className:`mb-2 text-xs text-fg-muted`,children:i.clarifySubmitting}):null,O?(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsx)(Yi,{variant:`secondary`,disabled:D,onClick:()=>void I({decision:`deny`}),children:i.clarifyDeny}),(0,X.jsx)(Yi,{variant:`primary`,disabled:D,onClick:()=>void I({decision:`approve`}),children:i.clarifyApprove})]}):(0,X.jsxs)(X.Fragment,{children:[A.length?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:i.clarifyQuickHint}),(0,X.jsx)(`div`,{role:`group`,"aria-label":i.clarifyChoicesGroupAria,className:`max-h-64 space-y-0.5 overflow-y-auto rounded-lg border border-edge p-1`,children:A.map((e,t)=>(0,X.jsx)(sp,{...e,index:t,recommended:F===e.id,recommendedLabel:i.clarifyRecommended,selected:u===e.id,disabled:D,onClick:()=>L(e.id)},e.id))}),(0,X.jsxs)(Yi,{variant:`ghost`,disabled:D,"aria-expanded":k,"aria-controls":M,className:`mt-1 min-h-11 justify-start gap-1 px-1 text-xs`,onClick:()=>{p(!f)},children:[(0,X.jsx)(ie,{"aria-hidden":`true`,className:Y(`size-3.5`,k&&`rotate-90`)}),i.clarifyCustomLabel]})]}):null,k?(0,X.jsxs)(`form`,{className:`mt-2 space-y-2`,onSubmit:e=>{e.preventDefault(),R()},children:[(0,X.jsx)(`label`,{htmlFor:M,className:`block text-xs font-medium text-fg-muted`,children:i.clarifyCustomLabel}),(0,X.jsx)(`textarea`,{id:M,ref:C,value:c,rows:2,disabled:D,placeholder:i.clarifyPlaceholder,"aria-invalid":j,"aria-describedby":`${P}${r?` ${N}`:``}`,onChange:e=>{l(e.target.value),e.target.value&&p(!0)},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&!e.nativeEvent.isComposing&&(e.preventDefault(),R())},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,X.jsxs)(`div`,{id:P,className:`flex flex-wrap justify-between gap-2 text-xs text-fg-muted`,children:[(0,X.jsx)(`span`,{children:j?i.clarifyAnswerTooLong:i.clarifyKeyboardHint}),(0,X.jsxs)(`span`,{"aria-live":j?`polite`:`off`,children:[c.trim().length,`/`,Br]})]}),(0,X.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,X.jsx)(Yi,{type:`submit`,variant:`primary`,disabled:D||j||!c.trim(),children:i.clarifySend})})]}):null,(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-1 border-t border-edge-subtle pt-2`,children:[o?(0,X.jsx)(Yi,{variant:`ghost`,disabled:D,onClick:()=>void o(),children:i.clarifyAgentDecide}):null,(0,X.jsx)(Yi,{variant:`ghost`,disabled:n||g,onClick:()=>void s(),children:i.clarifyCancel})]})]})]})}function fp(e,t){let n=(0,Z.c)(13),r=v(mp),i=v(pp),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 $r(e)?void 0:(await b(_(`/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=bi(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 pp(e){return e.baseUrl}function mp(e){return e.conversationId}function hp(){return Za()?window.electronAPI?.platform??`web`:`web`}function gp({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 _p=`xopc-web-sidebar-collapsed`,vp=`xopc-web-sidebar-expanded-width-px`;function yp(){try{return globalThis.localStorage?.getItem(_p)===`1`}catch{return!1}}function bp(e){try{globalThis.localStorage?.setItem(_p,e?`1`:`0`)}catch{}}function xp(e){return Math.min(480,Math.max(248,Math.round(e)))}function Sp(){try{let e=globalThis.localStorage?.getItem(vp);if(e==null)return xp(256);let t=Number.parseInt(e,10);return xp(Number.isFinite(t)?t:256)}catch{return xp(256)}}function Cp(e){try{globalThis.localStorage?.setItem(vp,String(e))}catch{}}var wp=x((e,t)=>({collapsed:yp(),setCollapsed:t=>{e({collapsed:t}),queueMicrotask(()=>bp(t))},toggleCollapsed:()=>{t().setCollapsed(!t().collapsed)},expandedWidthPx:Sp(),setExpandedWidthPx:n=>{let r=xp(n);t().expandedWidthPx!==r&&(e({expandedWidthPx:r}),queueMicrotask(()=>Cp(r)))}})),Tp=x(e=>({mobileNavOpen:!1,setMobileNavOpen:t=>e({mobileNavOpen:t}),toggleMobileNav:()=>e(e=>({mobileNavOpen:!e.mobileNavOpen}))}));function Ep(e){return e>99?`99+`:String(e)}function Dp(e,t){let n=(0,Z.c)(15),r=t===void 0||t,i=v(jp),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}=bi(a,Ap,o),[l,u]=(0,Q.useState)(kp),d,f;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)}},f=[c,r,i],n[4]=r,n[5]=i,n[6]=c,n[7]=d,n[8]=f):(d=n[7],f=n[8]),(0,Q.useEffect)(d,f);let p=s?.payload,m,h;return n[9]!==c||n[10]!==p||n[11]!==e||n[12]!==l?(m=()=>{if(!l||!p?.unreadCount||p.conversationId!==e)return;let t=!0;return g(`/api/personal-agent/read`,{method:`POST`,body:JSON.stringify({transcriptId:p.transcriptId,lastSeq:p.lastSeq})}).then(async e=>{if(!e.ok)return;let n=await e.json();t&&await c(n,{revalidate:!1})}).catch(Op),()=>{t=!1}},h=[l,e,p,c],n[9]=c,n[10]=p,n[11]=e,n[12]=l,n[13]=m,n[14]=h):(m=n[13],h=n[14]),(0,Q.useEffect)(m,h),p?.unreadCount??0}function Op(){}function kp(){return document.visibilityState===`visible`&&document.hasFocus()}function Ap(){return b(_(`/api/personal-agent/unread`))}function jp(e){return e.conversationId}var Mp=80;function Np(e){let t=e.trim();(t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`))&&(t=t.slice(1,-1).trim());let n=t.indexOf(`
9
- `);return n!==-1&&(t=t.slice(0,n).trim()),t.length>Mp&&(t=t.slice(0,Mp-1).trimEnd()+`…`),t}function Pp(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 Fp(e){let t=e.trimStart().match(/^\/skill:([^\s]+)(?:\s+([\s\S]*))?$/i);return t&&(t[2]?.trim()||t[1]?.trim())||e}function Ip(e){let t=Fp(Pp(Zn([{type:`text`,text:e}]))).split(/\n/)[0]?.trim();if(!t)return null;let n=Np(t);return n.length>0?n:null}function Lp(e,t){let n=e.trim(),r=t.trim();!n||!r||window.dispatchEvent(new CustomEvent(`session-updated`,{detail:{key:n,name:r},bubbles:!0}))}function Rp({conversationId:e,initialName:t,onClose:n,returnFocusRef:r}){let i=C(y(e=>e.language)),a=(0,Q.useId)(),[o,s]=(0,Q.useState)(t),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1),f=async t=>{t.preventDefault();let r=o.trim();if(!(!r||c)){l(!0),d(!1);try{if(!(await En(e,r)).renamed){d(!0);return}Lp(e,r),n()}catch{d(!0)}finally{l(!1)}}};return(0,X.jsx)(j,{open:!0,onOpenChange:e=>{!e&&!c&&n()},children:(0,X.jsxs)(O,{children:[(0,X.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,X.jsxs)(k,{"aria-describedby":void 0,onCloseAutoFocus:e=>{r?.current&&(e.preventDefault(),r.current.focus())},className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] w-[min(24rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover`,children:[(0,X.jsx)(A,{className:`text-base font-semibold text-fg`,children:i.sidebar.taskRenameTitle}),(0,X.jsxs)(`form`,{onSubmit:e=>void f(e),children:[(0,X.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg-subtle`,htmlFor:a,children:i.sidebar.taskRenamePlaceholder}),(0,X.jsx)(`input`,{id:a,type:`text`,value:o,onChange:e=>s(e.target.value),readOnly:c,className:Y(`mt-1.5 w-full rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 text-sm text-fg`,Xa),placeholder:i.chat.newSession}),u?(0,X.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:i.sessions.renameFailed}):null,(0,X.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,X.jsx)(D,{asChild:!0,children:(0,X.jsx)(Yi,{type:`button`,variant:`secondary`,disabled:c,children:i.sidebar.taskRenameCancel})}),(0,X.jsx)(Yi,{type:`submit`,variant:`primary`,disabled:!o.trim()||c,children:i.sidebar.taskRenameSave})]})]})]})]})})}function zp(e){return e.trim()}var Bp=x(e=>({runs:{},markRunning:t=>{let n=zp(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=zp(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=zp(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=zp(t);n&&e(e=>{let t=e.runs[n];return t?.unread?{runs:{...e.runs,[n]:{...t,unread:!1}}}:e})},clear:t=>{let n=zp(t);n&&e(e=>{if(!(n in e.runs))return e;let{[n]:t,...r}=e.runs;return{runs:r}})}}));function Vp(e){Bp.getState().markRunning(e)}function Hp(e,t){Bp.getState().markCompleted(e,t)}function Up(e,t){Bp.getState().markFailed(e,t)}function Wp(e){Bp.getState().clear(e)}function Gp(e){Bp.setState(t=>({runs:{...t.runs,[e]:{status:`waiting`,startedAt:t.runs[e]?.startedAt??Date.now(),updatedAt:Date.now(),unread:!1}}}))}function Kp(e,t){return[`gateway-chat-session-agent`,e,t]}function qp(e){let t=(0,Z.c)(5),n=v(Yp),r,i;if(t[0]!==e||t[1]!==n){let a=e?.trim();r=bi,i=n&&a?Kp(n,a):null,t[0]=e,t[1]=n,t[2]=r,t[3]=i}else r=t[2],i=t[3];let a;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},t[4]=a):a=t[4],r(i,Jp,a)}function Jp(e){let[,,t]=e;return Xp(t)}function Yp(e){return e.conversationId}async function Xp(e){let t=await $r(e);if(t)return{agentId:t.creation.agentId.trim().toLowerCase(),projectId:t.creation.projectId?.trim()||null,...t.creation.agentSetup?{agentSetup:!0}:{},...!t.creation.agentSetup&&!t.creation.temporary?{expertChat:!0}:{}};let n=await wn(e,{limit:1}),r=typeof n.sourceChannel==`string`?kn(n):void 0,i=r?.source===`workbench`&&r.purpose===`chat`&&n.status!==`archived`&&!n.parentConversationId&&n.customData?.agentSetup!==!0;return{agentId:(n.routing?.agentId??n.agentId).trim().toLowerCase(),projectId:n.projectId?.trim()||null,...n.customData?.agentSetup===!0?{agentSetup:!0}:{},...i?{expertChat:!0}:{}}}function Zp(e){let t=Sr(t=>Fn(t.sessions[e])),[n,r]=(0,Q.useState)(()=>Ln(e)),i=(0,Q.useRef)(e);return i.current!==e&&(i.current=e,r(Ln(e))),(0,Q.useEffect)(()=>{r(Ln(e))},[e,t]),(0,Q.useEffect)(()=>{let t=t=>{t.detail?.chatId===e&&r(Ln(e))};return window.addEventListener($n,t),()=>window.removeEventListener($n,t)},[e]),t||n}var Qp=`application/x-xopc-workspace-file`;function $p(e,t){e.effectAllowed=`copy`,e.setData(Qp,JSON.stringify(t))}function em(e){return!!(e&&Array.from(e.types).includes(`application/x-xopc-workspace-file`))}function tm(e){if(!e)return null;try{let t=JSON.parse(e.getData(Qp)),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 nm=`xopc-web-workspace-panel-open`,rm=`xopc-web-workspace-panel-width-px`;function im(){try{return globalThis.localStorage?.getItem(nm)===`1`}catch{return!1}}function am(e){try{globalThis.localStorage?.setItem(nm,e?`1`:`0`)}catch{}}function om(e){return Math.min(520,Math.max(200,Math.round(e)))}function sm(){try{let e=globalThis.localStorage?.getItem(rm);if(e==null)return 320;let t=Number.parseInt(e,10);return Number.isFinite(t)?om(t):320}catch{return 320}}function cm(e){try{globalThis.localStorage?.setItem(rm,String(e))}catch{}}var lm=x((e,t)=>({open:im(),setOpen:t=>{Xi.getState().setOpen(t),e(t?{open:t}:{open:t,conversationIdOverride:null}),queueMicrotask(()=>am(t))},toggleOpen:()=>{t().setOpen(!t().open)},conversationIdOverride:null,openForSession:t=>{let n=t.trim();Xi.getState().setScope(n||`new`),Xi.getState().setOpen(!0,n||`new`),e({open:!0,conversationIdOverride:n||null}),queueMicrotask(()=>am(!0))},widthPx:sm(),setWidthPx:n=>{let r=om(n);t().widthPx!==r&&(e({widthPx:r}),queueMicrotask(()=>cm(r)))}})),um={commands:!0,skills:!0,agentSwitch:!0},dm={commands:!1,skills:!1,agentSwitch:!1},fm=new WeakMap,pm=`​`,mm=`⁠`,hm=RegExp(`^\\/skill:(${co})`);function gm(e){return!!e.dataset.skill}function _m(e){return!!e.dataset.contextRefId}function vm(e){return e.dataset.slashCommand!=null&&e.dataset.slashCommand!==``}var ym=new WeakMap;function bm(e){let t=Pn(),n,r=-1;for(;(n=t.exec(e))!==null;)r=n.index+n[0].length;return r===e.length}function xm(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=bm(t)||/\/skill:\S+$/.test(t)||ns(t),r=n.startsWith(`@xopc-ref:`)||n.startsWith(`/skill:`)||es(n);(e||r)&&(t+=` `)}}t+=n}return t}function Sm(e){if(e.nodeType!==Node.ELEMENT_NODE)return!1;let t=e.tagName;return t===`DIV`||t===`P`||t===`PRE`||t===`BLOCKQUOTE`}function Cm(e,t){if(e.nodeType===Node.TEXT_NODE)t.push((e.textContent??``).replaceAll(pm,``));else if(e.nodeType===Node.ELEMENT_NODE){let n=e;if(gm(n)){let e=n.dataset.skill??``;e&&t.push(`/skill:${e}`)}else if(_m(n)){let e=n.dataset.contextRefId??``;e&&t.push(er(e))}else if(vm(n)){let e=n.dataset.slashCommand??``;e&&t.push(`/${e}`)}else n.tagName===`BR`?t.push(`
10
- `):wm(n,t)}}function wm(e,t){let n=Array.from(e.childNodes);for(let e=0;e<n.length;e++){let r=n[e],i=n[e+1];Cm(r,t),i!=null&&(Sm(r)||Sm(i))&&t.push(`
11
- `)}}function Tm(e,t){wm(e,t)}function Em(e){let t=[];return Tm(e,t),xm(t).replaceAll(mm,``)}function Dm(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 Om(e){let t=Em(e);return t.length>0||e.childNodes.length===0?t:(Um(e,``),Dm(e),``)}function km(e){let t=new Set,n=ao(),r;for(;(r=n.exec(e))!==null;){let e=r[1];e&&t.add(e)}return t}function Am(e){let t=window.getSelection();if(!t||t.rangeCount===0)return Em(e).length;let n=t.getRangeAt(0);if(!e.contains(n.startContainer))return Em(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()),Em(i).length}var jm=new WeakMap;function Mm(e,t){jm.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 Nm(e,t){ym.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 Pm(e,t){let n=document.createElement(`span`);n.contentEditable=`false`,n.dataset.skill=t,n.className=`chat-skill-pill`,n.textContent=`/${jm.get(e)?.(t)??t}`,n.title=`/${t}`,e.appendChild(n),e.appendChild(document.createTextNode(pm))}function Fm(e,t){let n=ym.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(pm))}function Im(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(pm))}function Lm(e,t=um){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(ao()),r(Pn());for(let r of t.commands?us(e):[])n.push(r);return n.sort((e,t)=>e.start-t.start),n}function Rm(e,t,n=um){for(let{start:r,end:i}of Lm(e,n))if(t>r&&t<=i)return{wire:e.slice(0,r)+e.slice(i),caret:r};return null}function zm(e,t,n=um){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?[so]:[];for(let e of a){let t=i(e);if(t)return t}let o=n.commands?ss(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?[oo]:[];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?ts(r):null;if(a){let n=a.tokenStart;return{wire:e.slice(0,n)+e.slice(t),caret:n}}}return null}function Bm(e){let t=window.getSelection();if(!t||t.rangeCount===0||!t.isCollapsed)return!1;let n=t.getRangeAt(0),r=Em(e),i=Am(e);i===0&&r.length>0&&n.startContainer===e&&n.startOffset===e.childNodes.length&&(i=r.length);let a=fm.get(e)??um,o=Rm(r,i,a);return o||=zm(r,i,a),o?(Um(e,o.wire,o.caret),e.dispatchEvent(new InputEvent(`input`,{bubbles:!0})),!0):!1}function Vm(e,t,n){let r=e.slice(t);return n.skills&&hm.test(r)||Pn().exec(r)?.index===0?!0:n.commands&&rs(e,t)!=null}function Hm(e,t,n){let r=fm.get(e)??um,i=t.slice(n),a=[],o=i.match(hm);r.skills&&o?.[0]&&a.push({len:o[0].length,apply:()=>Pm(e,o[1]??``)});let s=Pn().exec(i);s?.index===0&&s[0]&&a.push({len:s[0].length,apply:()=>Fm(e,s[1]??``)});let c=r.commands?rs(t,n):null;if(c&&a.push({len:c.len,apply:()=>Im(e,c.matchedKey)}),a.length===0){let i=n+1;for(;i<t.length&&!Vm(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 Um(e,t,n,r){r&&fm.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)+mm+t.slice(e)}let a=0;for(;a<i.length;)a=Hm(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]===mm){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 Wm(e,t){for(let n of e)if(n.isActive()&&n.handleKey(t))return!0;return!1}var Gm=8*1024,Km=80,qm=2*1024,Jm=20;function Ym(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 Xm(e){let t=new TextEncoder().encode(e).byteLength,n=e.split(/\r\n|\n|\r/).length,r=Ym(e);return t>=Gm||n>=Km||r!==`text`&&(t>=qm||n>=Jm)?{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 Zm(e){if(!e)return null;let t=_s(e);if(t.length>0)return{kind:`files`,files:t};let n=e.getData(`text/plain`);if(!n)return null;let r=Xm(n);return r?{kind:`text-attachment`,attachment:r}:{kind:`inline-text`,text:n}}async function Qm(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 $m=`fill-chat-composer`;function eh(e,t,n){window.dispatchEvent(new CustomEvent($m,{detail:{text:e,attachments:t,contextRefs:n}}))}function th(e,t,n){let r=(0,Z.c)(20),i=n===void 0||n,a=y(ih),o=v(rh),s=v(nh),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=()=>Qo(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}=bi(c,l,u),p,m;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)},m=[i,o,f],r[10]=i,r[11]=o,r[12]=f,r[13]=p,r[14]=m):(p=r[13],m=r[14]),(0,Q.useEffect)(p,m);let h;r[15]!==d?.skills||r[16]!==a?(h=new Map(d?.skills.map(e=>[e.name,as(e,a).displayName])),r[15]=d?.skills,r[16]=a,r[17]=h):h=r[17];let g=h,_;return r[18]===g?_=r[19]:(_=e=>g.get(e)??e,r[18]=g,r[19]=_),_}function nh(e){return e.baseUrl}function rh(e){return e.conversationId}function ih(e){return e.language}function ah(e,t){e.classList.toggle(`composer-input-empty`,t.length===0)}function oh(e){let{disabled:t,initialValue:n=``,onValueChange:r,autoFocusKey:i,welcomeDraftSeed:a,onExternalTextReplace:o,shouldSyncSelectionRef:s,resolveContextRef:c}=e,l=e.capabilities??um,u=th(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||(Mm(e,u),c&&Nm(e,c),D())},[u,c,h,D]),(0,Q.useLayoutEffect)(()=>{if(T.current)return;let e=_.current;e&&(T.current=!0,c&&Nm(e,c),Um(e,n,n.length,l),ah(e,n),D())},[D,n,c,l]),(0,Q.useLayoutEffect)(()=>{let e=_.current;e&&Um(e,v.current,Am(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}Um(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&&(Um(r,t,n,l),ah(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,a.preserveDraft||o?.(),A({nextText:a.preserveDraft&&v.current.trim()?v.current: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)||document.activeElement?.closest(`[role="dialog"]`))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=Am(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($m,t),()=>window.removeEventListener($m,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 sh=(0,Q.memo)(function(e){let t=(0,Z.c)(42),{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||t[2]!==i?(_=()=>{if(r||i||!n.current)return;let e=requestAnimationFrame(ch);return()=>cancelAnimationFrame(e)},v=[r,i,n],t[0]=r,t[1]=n,t[2]=i,t[3]=_,t[4]=v):(_=t[3],v=t[4]),(0,Q.useEffect)(_,v);let y,b;t[5]!==r||t[6]!==n?(y=()=>{let e=n.current;if(!e||r)return;let t=t=>{t.inputType!==`deleteContentBackward`||!t.cancelable||t.isComposing||g.current||Bm(e)&&t.preventDefault()};return e.addEventListener(`beforeinput`,t),()=>e.removeEventListener(`beforeinput`,t)},b=[r,n],t[5]=r,t[6]=n,t[7]=y,t[8]=b):(y=t[7],b=t[8]),(0,Q.useEffect)(y,b);let x=s??o,S=!r,C=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`,w;t[9]===C?w=t[10]:(w=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`,C,`composer-input-empty`),t[9]=C,t[10]=w);let T;t[11]!==l||t[12]!==c?(T=e=>{let t=e.currentTarget,n=g.current?Em(t):Om(t),r=e.nativeEvent.inputType;!g.current&&r?.startsWith(`delete`)&&n===`
12
- `&&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=``),ah(t,n),c(n,Am(t)),l()},t[11]=l,t[12]=c,t[13]=T):T=t[13];let E;t[14]===f?E=t[15]:(E=()=>{g.current=!0,f(!0)},t[14]=f,t[15]=E);let D;t[16]!==l||t[17]!==n||t[18]!==c||t[19]!==f?(D=()=>{g.current=!1,f(!1),queueMicrotask(()=>{let e=n.current;if(!e||g.current)return;let t=Om(e);ah(e,t),c(t,Am(e)),l()})},t[16]=l,t[17]=n,t[18]=c,t[19]=f,t[20]=D):D=t[20];let O;t[21]!==m||t[22]!==u||t[23]!==d?(O=async e=>{let t=Zm(e.clipboardData);t&&(e.preventDefault(),await Qm(t,{processFiles:u,processPastedText:d,insertText:lh,onUnsupportedFiles:()=>Ga(`warning`,m.clipboardFileTypeUnsupported)}))},t[21]=m,t[22]=u,t[23]=d,t[24]=O):O=t[24];let k;t[25]!==r||t[26]!==n||t[27]!==i||t[28]!==p?(k=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&&Bm(n.current)){e.preventDefault();return}if(Wm(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,`
13
- `);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[25]=r,t[26]=n,t[27]=i,t[28]=p,t[29]=k):k=t[29];let A;return t[30]!==n||t[31]!==i||t[32]!==o||t[33]!==T||t[34]!==E||t[35]!==D||t[36]!==O||t[37]!==k||t[38]!==x||t[39]!==S||t[40]!==w?(A=(0,X.jsx)(`div`,{ref:n,hidden:i,role:`textbox`,"aria-multiline":`true`,"aria-label":x,contentEditable:S,suppressContentEditableWarning:!0,spellCheck:!0,className:w,"data-placeholder":o,onInput:T,onCompositionStart:E,onCompositionEnd:D,onPaste:O,onKeyDown:k}),t[30]=n,t[31]=i,t[32]=o,t[33]=T,t[34]=E,t[35]=D,t[36]=O,t[37]=k,t[38]=x,t[39]=S,t[40]=w,t[41]=A):A=t[41],A});function ch(){return n(`composer_ready_frame`)}function lh(e){return document.execCommand(`insertText`,!1,e)}function uh(e){let t=(0,Z.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,X.jsx)(`div`,{className:s,...i,children:n}),t[8]=n,t[9]=i,t[10]=s,t[11]=c):c=t[11],c}var dh=`touch-target flex min-h-9 cursor-default items-center gap-2 rounded-md px-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover data-[disabled]:opacity-45`,fh={video:hc,music:Ct};function ph(e){let t=(0,Z.c)(16),{trigger:n,fileLabel:r,filesDisabled:i,onPickFiles:a,actions:o}=e,s=(0,Q.useRef)(!1),c;t[0]===n?c=t[1]:(c=(0,X.jsx)(Uo,{asChild:!0,children:n}),t[0]=n,t[1]=c);let l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=e=>{s.current&&e.preventDefault(),s.current=!1},t[2]=l):l=t[2];let u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,X.jsx)(kt,{className:`size-4`,"aria-hidden":!0}),t[3]=u):u=t[3];let d;t[4]!==r||t[5]!==i||t[6]!==a?(d=(0,X.jsxs)(Go,{className:dh,disabled:i,onSelect:a,children:[u,r]}),t[4]=r,t[5]=i,t[6]=a,t[7]=d):d=t[7];let f;t[8]===o.items?f=t[9]:(f=o.items.map(e=>{let{kind:t,label:n,onSelect:r}=e,i=fh[t];return(0,X.jsxs)(Go,{className:dh,onSelect:()=>{s.current=typeof globalThis.matchMedia==`function`&&globalThis.matchMedia(`(hover: hover) and (pointer: fine)`).matches,r()},children:[(0,X.jsx)(i,{className:`size-4`,"aria-hidden":!0}),n]},t)}),t[8]=o.items,t[9]=f);let p;t[10]!==d||t[11]!==f?(p=(0,X.jsx)(Wo,{children:(0,X.jsxs)(Ko,{side:`top`,align:`start`,sideOffset:6,onCloseAutoFocus:l,className:`z-[100] min-w-40 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:[d,f]})}),t[10]=d,t[11]=f,t[12]=p):p=t[12];let m;return t[13]!==c||t[14]!==p?(m=(0,X.jsxs)(Ho,{children:[c,p]}),t[13]=c,t[14]=p,t[15]=m):m=t[15],m}function mh(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function hh(e){let t=(0,Z.c)(19),{disabled:n,runBusy:r,attachmentCount:i,maxAttachments:a,chat:o,onPickFiles:s,addActions:c}=e,l=i>=a,u;t[0]!==i||t[1]!==l||t[2]!==o.attachFile||t[3]!==o.maxAttachmentsReached||t[4]!==a?(u=l?mh(o.maxAttachmentsReached,{max:a}):`${o.attachFile} (${i}/${a})`,t[0]=i,t[1]=l,t[2]=o.attachFile,t[3]=o.maxAttachmentsReached,t[4]=a,t[5]=u):u=t[5];let d=u,f;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(f=Y(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,Pa.transition,Pa.press,Pa.focusRingPanel,`disabled:cursor-not-allowed disabled:opacity-50`),t[6]=f):f=t[6];let p=!c&&l||n||r,m=c?.label??d,h=c?.label??d,g=c?void 0:s,_;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,X.jsx)(Ft,{className:`size-4`}),t[7]=_):_=t[7];let v;t[8]!==p||t[9]!==m||t[10]!==h||t[11]!==g?(v=(0,X.jsx)(`button`,{type:`button`,className:f,disabled:p,title:m,"aria-label":h,onClick:g,children:_}),t[8]=p,t[9]=m,t[10]=h,t[11]=g,t[12]=v):v=t[12];let y=v,b;return t[13]!==c||t[14]!==l||t[15]!==o.attachFile||t[16]!==s||t[17]!==y?(b=c?(0,X.jsx)(ph,{trigger:y,fileLabel:o.attachFile,filesDisabled:l,onPickFiles:s,actions:c}):y,t[13]=c,t[14]=l,t[15]=o.attachFile,t[16]=s,t[17]=y,t[18]=b):b=t[18],b}function gh(e){let t=(0,Z.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,X.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:i?(0,X.jsxs)(X.Fragment,{children:[o&&u?(0,X.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`,Pa.transition,Pa.press,Pa.focusRingPanel),title:s.steeringInterruptSend,"aria-label":s.steeringInterruptSend,onClick:()=>void u(),children:(0,X.jsx)(he,{className:`size-4 stroke-[1.75]`})}):null,(0,X.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`,Pa.transition,Pa.press,Pa.focusRingPanel),title:s.abort,"aria-label":s.abort,onClick:l,children:(0,X.jsx)(Kt,{className:`size-4 stroke-[1.75]`})})]}):(0,X.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`,Pa.press,Pa.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,X.jsx)(he,{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 _h(e){let t=(0,Z.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,X.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var vh=(0,Q.memo)(function(e){let t=(0,Z.c)(43),{disabled:n,sendDisabled:r,runBusy:i,chat:a,hasDraft:o,showSteeringInterrupt:s,attachmentCount:c,maxAttachments:l,onPickFiles:u,addActions:d,thinkingLevel:f,onThinkingChange:p,voiceActive:m,onStartVoiceInput:h,voiceConversationEnabled:g,onStartVoiceConversation:_,onSend:v,onAbort:y,onInterrupt:b,sessionModel:x,showModelSelector:S,onModelChange:C,modelDisabled:w}=e,T=r!==void 0&&r;if(m)return null;let E;t[0]!==d||t[1]!==c||t[2]!==n||t[3]!==a||t[4]!==l||t[5]!==u||t[6]!==i?(E=(0,X.jsx)(hh,{disabled:n,runBusy:i,attachmentCount:c,maxAttachments:l,chat:a,onPickFiles:u,addActions:d}),t[0]=d,t[1]=c,t[2]=n,t[3]=a,t[4]=l,t[5]=u,t[6]=i,t[7]=E):E=t[7];let D;t[8]!==n||t[9]!==a||t[10]!==w||t[11]!==C||t[12]!==p||t[13]!==x||t[14]!==S||t[15]!==f?(D=S?(0,X.jsx)(pi,{chat:a,sessionModel:x,modelDisabled:w,onModelChange:C,thinkingLevel:f,thinkingDisabled:n||w,onThinkingChange:p}):null,t[8]=n,t[9]=a,t[10]=w,t[11]=C,t[12]=p,t[13]=x,t[14]=S,t[15]=f,t[16]=D):D=t[16];let O;t[17]!==n||t[18]!==a||t[19]!==_||t[20]!==h||t[21]!==m||t[22]!==g?(O=m?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(hs,{disabled:n,chat:a,onStart:h}),(0,X.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`,Pa.transition,Pa.press,Pa.focusRingPanel,`disabled:cursor-not-allowed disabled:opacity-50`),disabled:n||!g,title:a.voiceConversation,"aria-label":a.voiceConversation,onClick:()=>void _(),children:(0,X.jsx)(B,{className:`size-4 stroke-[1.75]`})})]}),t[17]=n,t[18]=a,t[19]=_,t[20]=h,t[21]=m,t[22]=g,t[23]=O):O=t[23];let k=n||T,A;t[24]!==o||t[25]!==a||t[26]!==y||t[27]!==b||t[28]!==v||t[29]!==i||t[30]!==s||t[31]!==k||t[32]!==m?(A=(0,X.jsx)(gh,{disabled:k,voiceActive:m,runBusy:i,hasDraft:o,showSteeringInterrupt:s,chat:a,onSend:v,onAbort:y,onInterrupt:b}),t[24]=o,t[25]=a,t[26]=y,t[27]=b,t[28]=v,t[29]=i,t[30]=s,t[31]=k,t[32]=m,t[33]=A):A=t[33];let j;t[34]!==O||t[35]!==A?(j=(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[O,A]}),t[34]=O,t[35]=A,t[36]=j):j=t[36];let M;t[37]!==D||t[38]!==j?(M=(0,X.jsxs)(`div`,{className:`ml-auto flex min-w-0 items-center gap-2`,children:[D,j]}),t[37]=D,t[38]=j,t[39]=M):M=t[39];let N;return t[40]!==E||t[41]!==M?(N=(0,X.jsxs)(_h,{children:[E,M]}),t[40]=E,t[41]=M,t[42]=N):N=t[42],N}),yh=(0,Q.memo)(function(e){let t=(0,Z.c)(18),{spotlight:n,onPickPrompt:r,compact:i}=e,a=i!==void 0&&i,o=y(bh),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,X.jsx)(no,{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,X.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,X.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`,Pa.transition,Pa.press,Pa.focusRingPanel),children:[(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`line-clamp-2 block text-sm font-medium leading-snug text-fg sm:text-[0.9375rem]`,children:s.title}),(0,X.jsx)(`span`,{className:`mt-1 block truncate text-xs text-fg-muted`,children:s.reason})]}),(0,X.jsx)(ie,{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 h;return t[13]!==l||t[14]!==f||t[15]!==p||t[16]!==m?(h=(0,X.jsxs)(`div`,{className:l,children:[f,p,m]}),t[13]=l,t[14]=f,t[15]=p,t[16]=m,t[17]=h):h=t[17],h});function bh(e){return e.language}function xh({sourceVersionId:e,title:t,zh:n,onSaved:r}){let[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),m=(0,Q.useDeferredValue)(o),h=xi((t,n)=>{if(!i||t&&!n?.nextCursor)return null;let r=new URLSearchParams({versionTargetFor:e,q:m});return t&&n?.nextCursor&&r.set(`cursor`,n.nextCursor),`${gi}?${r}`},yi),g=h.data?.flatMap(e=>e.items)??[],_=g.find(e=>e.id===c),v=n?`保存为新版本`:`Save as new version`;function y(e){u||(a(e),e&&(s(``),l(void 0),p(!1)))}async function b(t){if(!u){d(!0),p(!1);try{let n=await vi(t.id,e,t.revision);a(!1),r(n)}catch{p(!0),h.mutate()}finally{d(!1)}}}return(0,X.jsxs)(j,{open:i,onOpenChange:y,children:[(0,X.jsx)(T,{className:`rounded-lg px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":`${v} · ${t}`,children:v}),(0,X.jsxs)(O,{children:[(0,X.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-[90] bg-scrim`}),(0,X.jsxs)(k,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[91] flex h-[min(31rem,calc(100dvh-2rem))] w-[min(30rem,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`,children:[(0,X.jsxs)(`header`,{className:`space-y-3 px-5 pt-5`,children:[(0,X.jsx)(A,{className:`text-base font-semibold text-fg`,children:v}),(0,X.jsx)(E,{className:`truncate text-sm text-fg-muted`,title:t,children:n?`为「${t}」选择原资料`:`Choose the original result for “${t}”`}),(0,X.jsxs)(`label`,{className:`flex min-h-10 items-center gap-2 rounded-lg border border-edge-subtle bg-surface-inset px-3 focus-within:ring-2 focus-within:ring-accent`,children:[(0,X.jsx)(zt,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,X.jsx)(`input`,{value:o,maxLength:160,onChange:e=>{s(e.target.value),l(void 0)},"aria-label":n?`搜索原资料`:`Search original results`,placeholder:n?`搜索原资料`:`Search original results`,className:`min-w-0 flex-1 bg-transparent text-sm text-fg outline-none`})]})]}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-3`,children:[h.isLoading?(0,X.jsx)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[0,1,2].map(e=>(0,X.jsx)(sn,{className:`h-11 rounded-lg`},e))}):null,h.error?(0,X.jsx)(`button`,{type:`button`,className:`rounded-lg px-2 py-2 text-sm text-accent-fg`,onClick:()=>void h.mutate(),children:n?`加载失败,重试`:`Could not load. Retry`}):null,!h.isLoading&&!h.error&&!g.length?(0,X.jsx)(`p`,{className:`py-5 text-center text-sm text-fg-muted`,children:n?`没有可选的资料`:`No matching results`}):null,(0,X.jsx)(`ul`,{className:`space-y-1`,children:g.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,onClick:()=>{l(e.id),p(!1)},disabled:u,"aria-pressed":c===e.id,className:Y(`flex min-h-11 w-full items-center gap-2 rounded-lg px-3 py-1.5 text-start text-sm`,c===e.id?`bg-accent-soft text-accent-fg`:`text-fg hover:bg-surface-hover`),children:[(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block truncate font-medium`,children:e.title}),(0,X.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,children:e.origin?.label??e.currentVersion.fileName})]}),c===e.id?(0,X.jsx)(ne,{className:`size-4 shrink-0`,"aria-hidden":!0}):null]})},e.id))}),h.data?.at(-1)?.nextCursor?(0,X.jsx)(`button`,{type:`button`,onClick:()=>void h.setSize(h.size+1),className:`mt-2 w-full rounded-lg py-2 text-sm text-accent-fg hover:bg-surface-hover`,children:n?`加载更多`:`Load more`}):null]}),(0,X.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-edge-subtle px-5 py-3`,children:[f?(0,X.jsx)(`p`,{role:`alert`,className:`flex-1 text-xs text-danger`,children:n?`保存失败,请重新选择资料。`:`Could not save. Choose the result again.`}):null,(0,X.jsx)(D,{asChild:!0,children:(0,X.jsx)(Yi,{variant:`secondary`,disabled:u,children:n?`取消`:`Cancel`})}),(0,X.jsx)(Yi,{variant:`primary`,disabled:!_||u,onClick:()=>{_&&b(_)},children:u?n?`正在保存`:`Saving`:n?`保存版本`:`Save version`})]})]})]})]})}async function Sh(e){let t=await g(_(e));if(!t.ok)return null;let n=await t.json();return typeof n.id==`string`?{id:n.id,versionId:typeof n.versionId==`string`?n.versionId:void 0,canSaveAsVersion:n.canSaveAsVersion===!0}:null}function Ch(e){let t=(0,Z.c)(19),{path:n,zh:r,title:i,readonly:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={shouldRetryOnError:!1},t[0]=o):o=t[0];let{data:s,mutate:c}=bi(n,Sh,o);if(!s)return null;let l;t[1]!==s.id||t[2]!==s.versionId?(l=new URLSearchParams({item:s.id}),s.versionId&&l.set(`version`,s.versionId),t[1]=s.id,t[2]=s.versionId,t[3]=l):l=t[3];let u=`/space?${l}`,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,X.jsx)(P,{className:`size-3.5`,"aria-hidden":!0}),t[4]=d):d=t[4];let f=r?`在资料库中查看`:`View in Space`,p;t[5]!==u||t[6]!==f||t[7]!==i?(p=(0,X.jsxs)(h,{to:u,title:i,className:`inline-flex items-center gap-1.5 rounded-lg px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,children:[d,f]}),t[5]=u,t[6]=f,t[7]=i,t[8]=p):p=t[8];let m;t[9]!==s.canSaveAsVersion||t[10]!==s.versionId||t[11]!==c||t[12]!==a||t[13]!==i||t[14]!==r?(m=!a&&s.canSaveAsVersion&&s.versionId&&i?(0,X.jsx)(xh,{sourceVersionId:s.versionId,title:i,zh:r,onSaved:e=>{c({...e,canSaveAsVersion:!1},{revalidate:!1});let t=new URLSearchParams({item:e.id,version:e.versionId});Ga(`success`,r?`已保存为新版本`:`Saved as new version`,void 0,{href:`/space?${t}`})}}):null,t[9]=s.canSaveAsVersion,t[10]=s.versionId,t[11]=c,t[12]=a,t[13]=i,t[14]=r,t[15]=m):m=t[15];let g;return t[16]!==p||t[17]!==m?(g=(0,X.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-1`,children:[p,m]}),t[16]=p,t[17]=m,t[18]=g):g=t[18],g}function wh(e){let t=(0,Z.c)(7),{file:n,zh:r,readonly:i}=e,a;t[0]===n.uri?a=t[1]:(a=n.uri?.startsWith(`media://outbound/`)?n.uri.slice(17):null,t[0]=n.uri,t[1]=a);let o=a,s=o?`/api/spaces/artifacts/${o}`:null,c;return t[2]!==n.title||t[3]!==i||t[4]!==s||t[5]!==r?(c=(0,X.jsx)(Ch,{path:s,title:n.title,zh:r,readonly:i}),t[2]=n.title,t[3]=i,t[4]=s,t[5]=r,t[6]=c):c=t[6],c}function Th(e){let t=(0,Z.c)(4),{deliveryId:n,title:r,zh:i}=e,a=`/api/spaces/deliveries/${encodeURIComponent(n)}`,o;return t[0]!==a||t[1]!==r||t[2]!==i?(o=(0,X.jsx)(Ch,{path:a,title:r,zh:i}),t[0]=a,t[1]=r,t[2]=i,t[3]=o):o=t[3],o}function Eh(e){let t=(0,Z.c)(4),{mediaId:n,title:r,zh:i}=e,a=`/api/spaces/artifacts/${encodeURIComponent(n)}`,o;return t[0]!==a||t[1]!==r||t[2]!==i?(o=(0,X.jsx)(Ch,{path:a,title:r,zh:i}),t[0]=a,t[1]=r,t[2]=i,t[3]=o):o=t[3],o}function Dh({provenance:e}){let t=y(e=>e.language),n=t===`zh`,r=C(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,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(0),g=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(``),b(_(`/api/personal-agent/outreach/${e.outreachId}/provenance`)).then(e=>{if(!e.ok)throw Error(e.error??r.load);t&&s(lr.parse(e.payload))}).catch(e=>{t&&l(String(e))}),()=>{t=!1}},[i,e.outreachId,m,r.load]);async function v(t,n={}){d(!0),l(``);try{let i=await b(_(`/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);p(!1),h(e=>e+1)}catch(e){l(String(e))}finally{d(!1)}}async function x(){let e=o?.strategy?.versions[0];if(!(!o||!e||u)){d(!0),l(``);try{let t=await b(_(`/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);p(!1),h(e=>e+1)}catch(e){l(String(e))}finally{d(!1)}}}let S=o&&[`completed`,`expired`].includes(o.thread.status);return(0,X.jsxs)(j,{open:i,onOpenChange:e=>{a(e),p(!1)},children:[(0,X.jsx)(T,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:`${Ss} mt-2`,"aria-label":n?`查看主动联系的缘由`:`Why this message`,children:(0,X.jsx)(Cs,{icon:(0,X.jsx)(Gt,{strokeWidth:1.5}),title:g[e.reasonKind],trailing:(0,X.jsx)(ie,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0})})})}),(0,X.jsxs)(O,{children:[(0,X.jsx)(w,{className:`fixed inset-0 z-50 bg-black/20`}),(0,X.jsxs)(k,{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,X.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge px-5 py-4`,children:[(0,X.jsx)(A,{className:`text-sm font-medium text-fg`,children:n?`为什么联系你`:`Why I reached out`}),(0,X.jsx)(D,{className:`rounded p-1 text-fg-muted hover:text-fg`,"aria-label":n?`关闭`:`Close`,children:(0,X.jsx)(an,{className:`size-4`})})]}),(0,X.jsx)(E,{className:`sr-only`,children:n?`消息的依据、时机与后续跟进`:`Sources, timing, and follow-up for this message`}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4 text-sm`,children:[!o&&!c&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(sn,{className:`h-5 w-3/4`}),(0,X.jsx)(sn,{className:`h-20 w-full`}),(0,X.jsx)(sn,{className:`h-12 w-full`})]}),o&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`mb-1 font-medium text-fg`,children:n?`为什么关注`:`Why this topic`}),(0,X.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,X.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,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`mb-1 font-medium text-fg`,children:n?`为什么现在联系`:`Why now`}),(0,X.jsx)(`p`,{className:`text-fg-muted`,children:o.whyNow})]}),o.sources.map(e=>(0,X.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,X.jsx)(`span`,{className:`line-clamp-2 text-xs`,children:e.excerpt}),(0,X.jsxs)(`span`,{className:`mt-1 block text-xs text-accent`,children:[n?`查看相关对话`:`View conversation`,` ↗`]})]},e.entryId)),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`mb-1 font-medium text-fg`,children:n?`后续`:`Next`}),(0,X.jsx)(`p`,{className:`text-fg-muted`,children:S?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,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,disabled:u,className:`rounded border border-edge px-3 py-2`,onClick:()=>void v(`defer`,{until:Date.now()+7*864e5}),children:n?`下周再跟进`:`Next week`}),(0,X.jsx)(`button`,{type:`button`,disabled:u,className:`rounded border border-edge px-3 py-2`,onClick:()=>void v(`adjust`,{preparation:`thorough`}),children:n?`以后先准备完整`:`Prepare more thoroughly`}),(0,X.jsx)(`button`,{type:`button`,disabled:u,className:`rounded border border-edge px-3 py-2`,onClick:()=>void v(`adjust`,{preparation:`brief`}),children:n?`以后简短一点`:`Keep it brief`})]}),o.strategy&&(0,X.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[(0,X.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,X.jsxs)(`details`,{className:`mt-2`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer`,children:n?`查看调整记录`:`View adjustments`}),(0,X.jsx)(`ul`,{className:`mt-2 space-y-1`,children:o.strategy.versions.map(e=>(0,X.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,X.jsx)(`p`,{role:`alert`,className:`text-danger`,children:c})]}),(0,X.jsxs)(`div`,{className:`flex gap-3 border-t border-edge px-5 py-3 text-xs`,children:[(0,X.jsx)(`button`,{type:`button`,disabled:!o||u||!!S,onClick:()=>p(e=>!e),className:`text-fg-muted hover:text-fg disabled:opacity-50`,children:n?`调整跟进`:`Adjust follow-up`}),(0,X.jsx)(`button`,{type:`button`,disabled:!o||u||!!S,onClick:()=>void v(`stop`),className:`text-fg-muted hover:text-fg disabled:opacity-50`,children:n?`停止关注`:`Stop following`}),o?.strategy?.versions.length?(0,X.jsx)(`button`,{type:`button`,disabled:u||!o.sourcesAvailable,onClick:()=>void x(),className:`ml-auto text-fg-muted hover:text-fg disabled:opacity-50`,children:n?`撤销最近调整`:`Undo latest`}):null]})]})]})]})}function Oh(e,t){let n=t?.split(`;`)[0]?.trim();return!n?.startsWith(`image/`)||e.type===n?e:new Blob([e],{type:n})}function kh(e,t){let n=(0,Z.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?Ni(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=Ii(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 Jt({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(Oh(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 Ah(e){let t=(0,Z.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,h=y(jh),g;t[0]===h?g=t[1]:(g=C(h),t[0]=h,t[1]=g);let _=g,v=(0,Q.useId)(),b;t[2]!==n.mimeType||t[3]!==n.type?(b=n.mimeType?.startsWith(`image/`)||n.type===`image`,t[2]=n.mimeType,t[3]=n.type,t[4]=b):b=t[4];let x=b,S;t[5]!==r||t[6]!==i?(S={authToken:r,conversationId:i},t[5]=r,t[6]=i,t[7]=S):S=t[7];let w=kh(n,S),T;t[8]===n?T=t[9]:(T=!!n.uri&&!Ni(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} · ${Fi(n.size)}`:F,t[16]=n.size,t[17]=F,t[18]=I):I=t[18];let L=I,R=O?`${M} — ${_.chat.attachmentPreviewMissingAuth}`:M,z=_.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 ee;t[22]!==n||t[23]!==M||t[24]!==H||t[25]!==w||t[26]!==B||t[27]!==V||t[28]!==j||t[29]!==x||t[30]!==N||t[31]!==k||t[32]!==_.chat.attachmentPreviewLoadError||t[33]!==_.chat.pastedText||t[34]!==R||t[35]!==v||t[36]!==z||t[37]!==d||t[38]!==u||t[39]!==L||t[40]!==O||t[41]!==P?(ee=x?(0,X.jsxs)(`div`,{className:V,children:[(0,X.jsxs)(`div`,{className:`relative size-full min-h-0`,children:[(0,X.jsxs)(`button`,{type:`button`,className:Y(H,Pa.transition,Pa.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?v:void 0,children:[w.src?(0,X.jsx)(`img`,{src:w.src,alt:M,className:B,decoding:`async`}):w.error||O?(0,X.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:_.chat.attachmentPreviewLoadError,children:[(0,X.jsx)(Ie,{className:`size-5`,strokeWidth:1.5,"aria-hidden":!0}),(0,X.jsx)(`span`,{children:O?z:_.chat.attachmentPreviewLoadError})]}):(0,X.jsx)(`span`,{className:`block size-full animate-pulse bg-surface-active`,"aria-hidden":!0}),u?(0,X.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,X.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,X.jsx)(`p`,{id:v,className:`mt-1 line-clamp-2 text-[10px] leading-snug text-amber-600 dark:text-amber-500`,children:z}):null]}):(0,X.jsx)(`div`,{className:Y(`max-w-[14rem]`,P&&`inline-flex max-w-full`),children:(0,X.jsxs)(`button`,{type:`button`,onClick:()=>d(n),title:R,"aria-label":R,"aria-describedby":O?v: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`,Pa.transition,Pa.press,Pa.focusRingPanel),children:[N?(0,X.jsx)(we,{className:Y(`shrink-0 text-accent-fg`,P?`size-3.5`:`size-8`),"aria-hidden":!0}):j?(0,X.jsx)(q,{className:`size-8 shrink-0 text-fg-subtle`,"aria-hidden":!0}):(0,X.jsx)(Ee,{className:`size-8 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:Y(`truncate text-fg`,P?`inline`:`block`),children:N?_.chat.pastedText:M}),P?(0,X.jsxs)(`span`,{className:`ml-1 whitespace-nowrap text-fg-subtle`,children:[`· `,L]}):null,O?(0,X.jsx)(`span`,{id:v,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]=x,t[30]=N,t[31]=k,t[32]=_.chat.attachmentPreviewLoadError,t[33]=_.chat.pastedText,t[34]=R,t[35]=v,t[36]=z,t[37]=d,t[38]=u,t[39]=L,t[40]=O,t[41]=P,t[42]=ee):ee=t[42];let te;t[43]!==_.chat.attachmentPreviewRemove||t[44]!==o||t[45]!==f?(te=f?(0,X.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`,Pa.transition,Pa.press,Pa.focusRingPanel),onClick:e=>{e.stopPropagation(),o?.()},title:_.chat.attachmentPreviewRemove,"aria-label":_.chat.attachmentPreviewRemove,children:(0,X.jsx)(an,{className:`size-3`})}):null,t[43]=_.chat.attachmentPreviewRemove,t[44]=o,t[45]=f,t[46]=te):te=t[46];let ne;return t[47]!==W||t[48]!==ee||t[49]!==te?(ne=(0,X.jsxs)(`div`,{className:W,children:[ee,te]}),t[47]=W,t[48]=ee,t[49]=te,t[50]=ne):ne=t[50],ne}function jh(e){return e.language}function Mh(e){let t=(0,Z.c)(11),{layout:n,conversationId:r,workspaceConversationId:i,projectId:a}=e,[o,s]=(0,Q.useState)(null),c=Ti(Nh),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 Nh(e){return e.setPath}function Ph(e){let t=Math.max(0,Math.floor(e));return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}function Fh(e){return typeof e==`number`&&Number.isFinite(e)&&e>0}function Ih(e){let t=(0,Z.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,X.jsx)(Lh,{...e},i),t[6]=e,t[7]=i,t[8]=a):a=t[8],a}function Lh({att:e,align:t=`start`,embedded:n=!1,conversationId:r}){let i=y(e=>e.language),a=i===`zh`,o=C(i).chat,s=(0,Q.useId)(),c=(0,Q.useRef)(null),[l,u]=(0,Q.useState)(),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(0),[h,v]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(!1),[S,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(1),[D,O]=(0,Q.useState)(0),k=D||(Fh(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 f(!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 g(_(Pi(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||f(!0)}})(),()=>{t.abort(),n&&URL.revokeObjectURL(n)}},[M,e.mimeType,e.uri,e.taskId,r,p]),(0,Q.useEffect)(()=>{let e=c.current,t=()=>e?.pause();return window.addEventListener(`xopc-voice-recording-start`,t),()=>{t(),e&&Wi(e),window.removeEventListener(`xopc-voice-recording-start`,t)}},[]);let N=()=>{let e=c.current;if(d){m(e=>e+1);return}!e||!l||(h?e.pause():(Gi(e),e.play().catch(t=>{e.paused&&Wi(e),t instanceof DOMException&&t.name===`AbortError`||f(!0)})))},P=()=>{let e=c.current?.duration;Fh(e)&&O(e)},F=a?`播放选项`:`Playback options`;return(0,X.jsx)(`div`,{className:Y(`flex min-w-0`,t===`end`&&`justify-end`,t===`center`&&`justify-center`),children:(0,X.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,X.jsx)(`span`,{className:`sr-only`,role:`status`,children:o.voiceLoading}):null,(0,X.jsxs)(`div`,{className:`flex min-h-14 items-center gap-2`,children:[(0,X.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`:h?o.voicePause:o.voicePlay,children:d?(0,X.jsx)(Lt,{className:`size-5`,"aria-hidden":!0}):h?(0,X.jsx)(At,{className:`size-5`,"aria-hidden":!0}):(0,X.jsx)(Pt,{className:`size-5`,"aria-hidden":!0})}),(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,"aria-hidden":!0,children:!l&&!d?(0,X.jsx)(sn,{className:`h-1 w-full`}):(0,X.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-surface-active`,children:(0,X.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${k>0?Math.min(100,A/k*100):0}%`}})})}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>x(!b),"aria-label":F,"aria-expanded":b,"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?Ph(A>0?A:k):`—`,(0,X.jsx)(re,{className:Y(`size-3`,b&&`rotate-180`),"aria-hidden":!0})]})]}),d?(0,X.jsx)(`p`,{role:`alert`,className:`px-2 pb-2 text-xs text-fg-muted`,children:a?`音频无法播放,请重试`:`Audio unavailable. Try again.`}):null,b?(0,X.jsxs)(`div`,{id:`${s}-options`,className:`space-y-2 px-2 pb-3`,children:[(0,X.jsxs)(`label`,{className:`block text-xs text-fg-muted`,children:[a?`播放进度`:`Playback position`,(0,X.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,X.jsx)(pe,{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,X.jsxs)(`div`,{className:`px-2 pb-1`,children:[(0,X.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(!S),"aria-expanded":S,"aria-controls":`${s}-text`,children:S?a?`收起文字`:`Hide transcript`:a?`查看文字`:`Show transcript`}),S?(0,X.jsx)(`p`,{id:`${s}-text`,className:`whitespace-pre-wrap break-words pb-2 text-sm text-fg-muted`,children:e.extractedText}):null]}):null,(0,X.jsx)(`audio`,{ref:c,src:l,preload:`metadata`,className:`hidden`,onLoadedMetadata:P,onDurationChange:P,onTimeUpdate:e=>j(e.currentTarget.currentTime),onError:()=>{l&&(v(!1),f(!0))},onPlay:e=>{e.currentTarget.paused||(Gi(e.currentTarget),e.currentTarget.playbackRate=T,v(!0))},onPause:()=>v(!1),onEnded:()=>{v(!1),j(0)}})]})})}function Rh(e){return e.type===`voice`||e.type===`audio`||e.mimeType?.startsWith(`audio/`)===!0}var zh=9;function Bh(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<=zh?{container:`grid grid-cols-3 ${n} ${r}`,tileSize:`grid-cell`}:{container:`grid grid-cols-3 ${n} ${r}`,tileSize:`grid-cell`,overflowCount:e-(zh-1)}}function Vh(e){let t=(0,Z.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=Mh(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(Uh);let e=n.filter(Rh),a=n.filter(Hh);m=`flex flex-col gap-2`,h=p.length>0?(()=>{let e=Bh(p.length,l===`user`),t=e.overflowCount==null?p:p.slice(0,zh-1);return(0,X.jsxs)(`div`,{className:Y(`w-full min-w-0`,e.container),children:[t.map((t,n)=>(0,X.jsx)(Ah,{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,X.jsx)(Ah,{attachment:p[zh-1],authToken:r,conversationId:i,imageSize:`grid-cell`,compact:l===`user`,overflowLabel:`+${e.overflowCount}`,onOpen:f.openAttachment},p[zh-1]?.id??`overflow-${zh-1}`)]})})():null,g=e.length>0?(0,X.jsx)(`div`,{className:Y(`flex flex-col gap-2`,l===`user`&&(u?`items-center`:`items-end`)),children:e.map((e,t)=>(0,X.jsx)(Ih,{att:e,conversationId:i,align:l===`user`?u?`center`:`end`:`start`,embedded:l===`user`},e.id??`${e.name}-${t}`))}):null,_=a.length>0?(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:a.map((e,t)=>(0,X.jsx)(Ah,{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,X.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,X.jsx)(Yo,{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,X.jsxs)(X.Fragment,{children:[v,y]}),t[29]=v,t[30]=y,t[31]=b):b=t[31],b}function Hh(e){return e.type!==`image`&&!e.mimeType?.startsWith(`image/`)&&!Rh(e)}function Uh(e){return e.type===`image`||e.mimeType?.startsWith(`image/`)}function Wh(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 Gh(e){return e?.length?e.flatMap((e,t)=>{let n=Wh(e,t);return n?[n]:[]}):[]}function Kh(e){let t=[],n=new Set(ur(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(`
8
+ `):[t]).forEach((e,t)=>{t&&i.push({type:`break`}),e&&i.push({type:`text`,value:e})})},o=0;for(let e of r)e.start<o||(a(t.value.slice(o,e.start)),i.push({type:`link`,url:e.url,children:[{type:`text`,value:e.label}]}),o=e.end);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),ha})}}function Cf(){return e=>{ma(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=at(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:yf(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),ha})}}function wf({prefix:e}){return t=>{let n=new Map;ma(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}),ma(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 Tf=typeof Intl.Segmenter==`function`?new Intl.Segmenter(void 0,{granularity:`word`}):null,Ef=typeof Intl.Segmenter==`function`?new Intl.Segmenter(void 0,{granularity:`grapheme`}):null;function Df(e){return Tf?Array.from(Tf.segment(e),({segment:e,index:t})=>({text:e,offset:t})):[{text:e,offset:0}]}function Of(e,t){if(t>=e.length||!Ef)return e.length;let n=Ef.segment(e).containing(t);return n&&n.index!==t?n.index+n.segment.length:t}var kf=256,Af=(0,Q.createContext)(null),jf=(0,Q.createContext)(null);function Mf(e){let t=(0,Z.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)(Af),i=(0,Q.useContext)(jf),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>=kf)return;let t=performance.now(),n=r.starts.get(o);if(n===void 0&&!c)return;if(n===void 0){if(r.starts.size>=kf)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,X.jsx)(`span`,{...n,ref:a}),t[11]=n,t[12]=d),d}function Nf(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=kf-(r?.size??0),l=performance.now();ma(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=Df(t.value).flatMap(t=>{let n=e.length-i-t.offset;if(n<=0||n>=t.text.length)return[t];let r=Of(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),[ha,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 Pf=(0,Q.createContext)(null),Ff=(0,Q.createContext)(``);function If(e){let t=(0,Z.c)(56),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)(Pf),l=(0,Q.useContext)(of),{openImage:u}=Fe(),d=y(Lf),f;t[6]===d?f=t[7]:(f=C(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 h=m,g,_,v,b,x,S,w,T,E,D;if(t[10]!==n||t[11]!==c||t[12]!==h||t[13]!==s||t[14]!==p||t[15]!==i||t[16]!==a||t[17]!==l){w=Symbol.for(`react.early_return_sentinel`);bb0:{if(E=i?Uf(i).trim():typeof n==`string`?n.trim():``,_=ta(na(s),E),_.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[28]===r?i=t[29]:(i={kind:`internal-route`,route:r},t[28]=r,t[29]=i),_=i}}if(T=!s.startsWith(`#`)&&_.kind!==`internal-route`&&c.openFile?ut(s):null,!h&&!T&&_.kind===`blocked`){let e;t[30]===n?e=t[31]:(e=(0,X.jsx)(X.Fragment,{children:n}),t[30]=n,t[31]=e),w=e;break bb0}let e=_.kind===`internal-route`?_.route:void 0;v=!!e;let r=e?e.slice(1).split(/[/?#]/,1)[0]:``;b=p.destinations[r]??p.open,D=v&&/^(?:xopc:\/\/|#\/|Open(?: in xopc)?$|打开$)/i.test(E)?b:n,g=e?`#${e}`:s,x=a,S=vl(E)?c.trackImageLink:void 0}t[10]=n,t[11]=c,t[12]=h,t[13]=s,t[14]=p,t[15]=i,t[16]=a,t[17]=l,t[18]=g,t[19]=_,t[20]=v,t[21]=b,t[22]=x,t[23]=S,t[24]=w,t[25]=T,t[26]=E,t[27]=D}else g=t[18],_=t[19],v=t[20],b=t[21],x=t[22],S=t[23],w=t[24],T=t[25],E=t[26],D=t[27];if(w!==Symbol.for(`react.early_return_sentinel`))return w;let O=v||T||h?void 0:`_blank`,k;t[32]!==r||t[33]!==T?(k=[r,T?`markdown-file-link`:``].filter(Boolean).join(` `)||void 0,t[32]=r,t[33]=T,t[34]=k):k=t[34];let A=h?`document-fragment`:T?void 0:_.kind,j=T?.path,M=T?.kind,N=T?.line,P=c.linkError===g?p.failed:a.title||(v?b:void 0),F;t[35]!==g||t[36]!==c||t[37]!==h||t[38]!==s||t[39]!==u||t[40]!==T||t[41]!==E?(F=e=>{if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;if(e.preventDefault(),h){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(E)){u(t.src,t.alt);return}if(T){c.openFile?.(T);return}c.openLink(g)},t[35]=g,t[36]=c,t[37]=h,t[38]=s,t[39]=u,t[40]=T,t[41]=E,t[42]=F):F=t[42];let I;return t[43]!==g||t[44]!==j||t[45]!==M||t[46]!==N||t[47]!==P||t[48]!==F||t[49]!==x||t[50]!==S||t[51]!==O||t[52]!==k||t[53]!==A||t[54]!==D?(I=(0,X.jsx)(`a`,{...x,ref:S,href:g,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:D}),t[43]=g,t[44]=j,t[45]=M,t[46]=N,t[47]=P,t[48]=F,t[49]=x,t[50]=S,t[51]=O,t[52]=k,t[53]=A,t[54]=D,t[55]=I):I=t[55],I}function Lf(e){return e.language}function Rf({node:e,src:t=``,alt:n,...r}){let i=(0,Q.useContext)(Pf),a=ut(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,X.jsx)(cf,{...r,source:t,alt:n,load:a?l:void 0})}function zf(e){let t=(0,Z.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(Hf)&&n.children.every(Bf),t[3]=n,t[4]=i);let a=i||void 0,o;return t[5]!==r||t[6]!==a?(o=(0,X.jsx)(`p`,{...r,"data-chat-media":a}),t[5]=r,t[6]=a,t[7]=o):o=t[7],o}function Bf(e){return e.type===`text`?!e.value.trim():e.type===`element`&&(e.tagName===`img`||e.tagName===`a`&&e.children.every(Vf))}function Vf(e){return e.type===`element`&&e.tagName===`img`}function Hf(e){return e.type===`element`}function Uf(e){return e.children.map(e=>e.type===`text`?e.value:e.type===`element`?Uf(e):``).join(``)}function Wf(e){let t=(0,Z.c)(20),{node:n}=e,r=(0,Q.useContext)(Pf),i=(0,Q.useContext)(Ff),a=_a(),o,s;if(t[0]!==n?.children){let e=n?.children.find(Gf);o=String(e?.properties.className??``).match(/language-([^,\s]+)/)?.[1]??``,s=e?Uf(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||!gf(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,X.jsx)(Aa,{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,X.jsx)(Oa,{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 Gf(e){return e.type===`element`&&e.tagName===`code`}function Kf(e){let t=(0,Z.c)(4),n;if(t[0]!==e){let{node:r,...i}=e;n=i,t[0]=e,t[1]=n}else n=t[1];let r;return t[2]===n?r=t[3]:(r=(0,X.jsx)(`div`,{className:`markdown-table-scroll`,tabIndex:0,children:(0,X.jsx)(`table`,{...n})}),t[2]=n,t[3]=r),r}function qf(e){let t=(0,Z.c)(2),n;return t[0]===e?n=t[1]:(n=e.node?.properties.dataXopcMath??e.node?.properties[`data-xopc-math`]?(0,X.jsx)(mf,{...e}):(0,X.jsx)(Mf,{...e}),t[0]=e,t[1]=n),n}function Jf(e){let t=(0,Z.c)(2),n;return t[0]===e?n=t[1]:(n=e.node?.properties.dataXopcMath??e.node?.properties[`data-xopc-math`]?(0,X.jsx)(mf,{...e,display:!0}):(0,X.jsx)(`div`,{...Object.fromEntries(Object.entries(e).filter(Yf))}),t[0]=e,t[1]=n),n}function Yf(e){let[t]=e;return t!==`node`}var Xf=/^[+−-]?(?:\p{Sc}\s?|v)?\p{Nd}+(?:[.,:/\u00a0\u202f-]\p{Nd}+)*(?:\s?(?:[%%‰]|\p{Sc}|ms|s|KB|MB|GB|TB))?$/iu,Zf=e=>function({node:t,...n}){let r=(e===`th`||e===`td`)&&typeof t?.properties.align==`string`?t.properties.align:void 0,i=e===`td`&&t?Uf(t).trim():``,a=i.length<=16&&Xf.test(i);return(0,Q.createElement)(e,{...n,"data-markdown-align":r,"data-markdown-compact-number":a||void 0})},Qf={a:If,img:Rf,pre:Wf,span:qf,div:Jf,p:zf,h1:Zf(`h1`),h2:Zf(`h2`),h3:Zf(`h3`),h4:Zf(`h4`),h5:Zf(`h5`),h6:Zf(`h6`),ul:Zf(`ul`),ol:Zf(`ol`),li:Zf(`li`),strong:Zf(`strong`),em:Zf(`em`),blockquote:Zf(`blockquote`),code:Zf(`code`),table:Kf,thead:Zf(`thead`),tbody:Zf(`tbody`),tr:Zf(`tr`),th:Zf(`th`),td:Zf(`td`),hr:Zf(`hr`)},$f=[xf,[fa,{...pa,attributes:{...pa.attributes,code:[...pa.attributes?.code??[],[`className`,/^language-/,`math-inline`,`math-display`],`data-xopc-math-source`]}}]],ep=e=>/^\s{0,3}\[[^\]]+\]:|\[[^\]]+\]\[[^\]]*\]|\[\^/m.test(e),tp=(0,Q.memo)(function(e){let t=(0,Q.useId)(),n=(0,Q.useContext)(Pf),r=(0,Q.useRef)(null),i=(0,Q.useContext)(jf),[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)&&!ep(e.content)&&!f,m=(0,Q.useMemo)(()=>Nf(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]===Ml?[Ml,{streaming:n.streaming,maxCount:h}]:e),m],[e.rehypePlugins,m,n.streaming,h]),_=performance.now();return(0,Q.useLayoutEffect)(()=>{n.metricsKey&&dt(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,X.jsx)(`div`,{ref:r,className:`markdown-stream-block`,children:(0,X.jsx)(df,{content:e.content,children:(0,X.jsx)(Ff.Provider,{value:e.content,children:(0,X.jsx)(Af.Provider,{value:a,children:(0,X.jsx)(va,{...e,shouldParseIncompleteMarkdown:e.shouldParseIncompleteMarkdown&&hl(e.content).length===0,rehypePlugins:g})})})})})}),np=(0,Q.memo)(function(e){let t=(0,Z.c)(94),{content:n,compact:i,breaks:a,className:o,codeCopy:s,onWorkspaceFileOpen:c,onWorkspaceImageLoad:l,renderMermaid:u,mermaidActions:d,streamingMetricsKey:f,responseRunId:p,streaming:m}=e,h=i!==void 0&&i,g=a!==void 0&&a,_=s===void 0||s,v=u===void 0||u,b=d!==void 0&&d,x=m!==void 0&&m,S=(0,Q.useId)(),w=(0,Q.useRef)(null),T=nt(),E=y(rp),[D,O]=(0,Q.useState)(null),k=(0,Q.useRef)(0),A=(0,Q.useRef)(null),j;t[0]===T?j=t[1]:(j=e=>{let t=k.current+=1;A.current=e,O(null),T(e).then(n=>{t===k.current&&(n.ok&&(A.current=null),O(n.ok?null:e))}).catch(()=>{t===k.current&&O(e)})},t[0]=T,t[1]=j);let M=j,N,P;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(N=()=>()=>{k.current+=1},P=[],t[2]=N,t[3]=P):(N=t[2],P=t[3]),(0,Q.useEffect)(N,P);let F;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>{let e=A.current;!e||Array.from(w.current?.querySelectorAll(`a[href]`)??[]).some(t=>t.getAttribute(`href`)===e)||(A.current=null,k.current+=1,O(null))},t[4]=F):F=t[4];let I;t[5]===n?I=t[6]:(I=[n],t[5]=n,t[6]=I),(0,Q.useEffect)(F,I);let[L]=(0,Q.useState)(ip),R;t[7]!==n||t[8]!==x?(R=()=>x||!n?`streaming`:`static`,t[7]=n,t[8]=x,t[9]=R):R=t[9];let[z]=(0,Q.useState)(R),[B]=(0,Q.useState)(pf),V;t[10]!==n||t[11]!==z?(V=()=>z===`streaming`?ff(n).length:0,t[10]=n,t[11]=z,t[12]=V):V=t[12];let[H]=(0,Q.useState)(V),U;t[13]===x?U=t[14]:(U=[Ml,{streaming:x}],t[13]=x,t[14]=U);let W=U,ee;t[15]===W?ee=t[16]:(ee={cjk:af,math:{name:`katex`,type:`math`,remarkPlugin:fl,rehypePlugin:W}},t[15]=W,t[16]=ee);let te=ee,[ne]=(0,Q.useState)(gl),[re]=(0,Q.useState)(yl),ie;t[17]!==B||t[18]!==n||t[19]!==ne?(ie=ne(B(n)),t[17]=B,t[18]=n,t[19]=ne,t[20]=ie):ie=t[20];let ae=ie,oe;t[21]!==_||t[22]!==H||t[23]!==D||t[24]!==ae||t[25]!==b||t[26]!==c||t[27]!==l||t[28]!==M||t[29]!==v||t[30]!==x||t[31]!==f||t[32]!==re?(oe={openLink:M,linkError:D,streaming:x,initialBlocks:H,mathRemaining:ae,metricsKey:f,trackImageLink:re,copy:_,renderMermaid:v,mermaidActions:b,openFile:c,loadImage:l},t[21]=_,t[22]=H,t[23]=D,t[24]=ae,t[25]=b,t[26]=c,t[27]=l,t[28]=M,t[29]=v,t[30]=x,t[31]=f,t[32]=re,t[33]=oe):oe=t[33];let se=oe,ce;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(ce=Object.values(Sa),t[34]=ce):ce=t[34];let le;t[35]===g?le=t[36]:(le=[...ce,[Sf,{breaks:g}]],t[35]=g,t[36]=le);let ue=le,de;t[37]===c?de=t[38]:(de=c?[Cf]:[],t[37]=c,t[38]=de);let fe=`xopc-markdown-${S}`,pe;t[39]===fe?pe=t[40]:(pe=[wf,{prefix:fe}],t[39]=fe,t[40]=pe);let G;t[41]!==de||t[42]!==pe?(G=[...$f,...de,pe],t[41]=de,t[42]=pe,t[43]=G):G=t[43];let me=G,he;t[44]!==n||t[45]!==p?(he=()=>{if(!r||!p||!n.trim())return;let e=requestAnimationFrame(()=>{if(cr(p)){let e=w.current;if(!e?.getClientRects().length||!e.innerText?.trim())return}_r(p,n)});return()=>cancelAnimationFrame(e)},t[44]=n,t[45]=p,t[46]=he):he=t[46];let K;t[47]!==n||t[48]!==p||t[49]!==x?(K=[n,p,x],t[47]=n,t[48]=p,t[49]=x,t[50]=K):K=t[50],(0,Q.useLayoutEffect)(he,K);let ge;t[51]===f?ge=t[52]:(ge=()=>{if(!r||!f)return;let e=w.current?.querySelectorAll(`.markdown-stream-block`);lt(f,Math.max(0,(e?.length??0)-1),e?.item((e.length??1)-1)?.textContent?.length??0)},t[51]=f,t[52]=ge);let _e;t[53]!==n||t[54]!==f?(_e=[n,f],t[53]=n,t[54]=f,t[55]=_e):_e=t[55],(0,Q.useLayoutEffect)(ge,_e);let q;t[56]===E?q=t[57]:(q=C(E),t[56]=E,t[57]=q);let ve=q.chat.attachmentPreviewClose,ye=h?`markdown-compact`:``,J=g?`markdown-breaks`:``,be=c?`markdown-workspace-links`:``,xe;t[58]!==o||t[59]!==ye||t[60]!==J||t[61]!==be?(xe=[`markdown-body xopc-chat-markdown`,ye,J,be,o].filter(Boolean),t[58]=o,t[59]=ye,t[60]=J,t[61]=be,t[62]=xe):xe=t[62];let Se=xe.join(` `),Ce;t[63]!==B||t[64]!==n||t[65]!==z||t[66]!==te||t[67]!==me||t[68]!==ue||t[69]!==x||t[70]!==Se?(Ce=(0,X.jsx)(xa,{className:Se,mode:z,isAnimating:x,animated:!1,parseIncompleteMarkdown:x,components:Qf,plugins:te,controls:!1,BlockComponent:tp,parseMarkdownIntoBlocksFn:B,remarkPlugins:ue,rehypePlugins:me,urlTransform:ba,children:n}),t[63]=B,t[64]=n,t[65]=z,t[66]=te,t[67]=me,t[68]=ue,t[69]=x,t[70]=Se,t[71]=Ce):Ce=t[71];let we;t[72]!==n||t[73]!==Ce?(we=(0,X.jsx)(df,{content:n,children:Ce}),t[72]=n,t[73]=Ce,t[74]=we):we=t[74];let Te;t[75]!==D||t[76]!==E?(Te=D?(0,X.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:C(E).chat.contentLinks.failed}):null,t[75]=D,t[76]=E,t[77]=Te):Te=t[77];let Ee;t[78]!==S||t[79]!==we||t[80]!==Te?(Ee=(0,X.jsxs)(`div`,{ref:w,className:`markdown-render-boundary`,"data-chat-markdown":S,children:[we,Te]}),t[78]=S,t[79]=we,t[80]=Te,t[81]=Ee):Ee=t[81];let De;t[82]!==L||t[83]!==Ee?(De=(0,X.jsx)(jf.Provider,{value:L,children:Ee}),t[82]=L,t[83]=Ee,t[84]=De):De=t[84];let Oe;t[85]!==n||t[86]!==De?(Oe=(0,X.jsx)(Ff.Provider,{value:n,children:De}),t[85]=n,t[86]=De,t[87]=Oe):Oe=t[87];let ke;t[88]!==se||t[89]!==Oe?(ke=(0,X.jsx)(Pf.Provider,{value:se,children:Oe}),t[88]=se,t[89]=Oe,t[90]=ke):ke=t[90];let Ae;return t[91]!==q.chat.attachmentPreviewClose||t[92]!==ke?(Ae=(0,X.jsx)(Pe,{interactive:!0,closeLabel:ve,children:ke}),t[91]=q.chat.attachmentPreviewClose,t[92]=ke,t[93]=Ae):Ae=t[93],Ae});function rp(e){return e.language}function ip(){return new Set}function ap(e){let t=(0,Z.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,X.jsx)(ne,{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,X.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,X.jsx)(`span`,{className:`font-medium`,children:n}),t[10]=n,t[11]=_);let v;t[12]!==a||t[13]!==o?(v=a?(0,X.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,X.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,X.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,X.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,X.jsx)(I,{"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,X.jsxs)(qi,{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 op(e,t,n=`draft`,r){let i=v.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?Qr(o,r):{read:async()=>void 0,write:async e=>{}}}function sp({prompt:e,focusRequestKey:t,submitting:n,submitError:r,labels:i,onSubmit:a,onAgentDecide:o,onCancel:s}){let c=C(y(e=>e.language)).chat,[l,u]=(0,Q.useState)({index:0,answers:{}}),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(!1),b=(0,Q.useRef)(!1),x=(0,Q.useRef)(!1),[S,w]=(0,Q.useState)(),T=(0,Q.useRef)(l),E=(0,Q.useRef)(null),D=(0,Q.useRef)(null),O=e?.questions??[],k=O[Math.min(l.index,O.length-1)],A=k?l.answers[k.id]:void 0,j=(0,Q.useRef)(op(e.requestId,e.version??1,`draft`,e.conversationId)),M=n||h,N=M||_,P=O.filter(e=>{let t=l.answers[e.id];return t&&(t.choiceId||t.text?.trim())}).length;(0,Q.useEffect)(()=>{let t=!0;op(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 j.current.read().then(t=>{e||(t&&!b.current&&t.index>=0&&t.index<O.length&&t.answers&&(T.current=t,u(t)),f(!0))}).catch(()=>{e||f(!0)}),()=>{e=!0}},[O.length]),(0,Q.useEffect)(()=>{if(!d||!b.current)return;let e=window.setTimeout(()=>{j.current.write(l).catch(()=>{})},300);return()=>window.clearTimeout(e)},[l,d]),(0,Q.useEffect)(()=>{S&&D.current?.focus()},[S]),(0,Q.useEffect)(()=>{!d||!t||(E.current?.scrollIntoView?.({block:`nearest`}),E.current?.focus({preventScroll:!0}))},[t,d]);function F(e,t=!1){b.current=!0,T.current=e,u(e),m(``),t&&j.current.write(e).catch(()=>{})}function I(e){F({...l,index:e},!0),E.current?.focus()}async function L(t=T.current){if(!(M||x.current||!e)){x.current=!0,g(!0);try{let n={schemaVersion:2,answers:O.map(e=>t.answers[e.id]??{questionId:e.id})};dr(e,n),await j.current.write(t),await a(n)}catch(e){m(e instanceof Error?e.message:String(e))}finally{x.current=!1,g(!1)}}}function R(e){if(N||x.current||!k)return;let t={...T.current,answers:{...T.current.answers,[k.id]:{questionId:k.id,choiceId:e}}};F(t);let n=O.findIndex(e=>{let n=t.answers[e.id];return!n?.choiceId&&!n?.text?.trim()});n===-1?L(t):(F({...t,index:n},!0),E.current?.focus())}if(!d)return(0,X.jsxs)(`div`,{className:`mb-4 space-y-3 rounded-lg border border-edge p-4`,children:[(0,X.jsx)(sn,{className:`h-5 w-1/2`}),(0,X.jsx)(sn,{className:`h-24 w-full`})]});if(!k)return null;let z=!!(A?.choiceId||A?.text?.trim())&&(A?.text?.length??0)<=2e3,B=k.type!==`single_choice`||S===k.id||!!A?.text,V=`clarify-${e.requestId}-${k.id}`;return(0,X.jsxs)(`section`,{ref:E,tabIndex:-1,"aria-label":i.clarifyRegionAria,"aria-busy":M,"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`,Ma.focusRingPanel),children:[(0,X.jsxs)(`header`,{className:`shrink-0 border-b border-edge-subtle px-4 py-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.clarifyRegionAria}),(0,X.jsx)(`span`,{role:`status`,className:`text-xs text-fg-muted`,children:M?i.clarifySubmitting:c.clarifyProgress.replace(`{{answered}}`,String(P)).replace(`{{total}}`,String(O.length))})]}),O.length>1?(0,X.jsx)(`nav`,{"aria-label":c.clarifyQuestions,className:`mt-2 flex flex-wrap gap-1`,children:O.map((e,t)=>(0,X.jsxs)(qi,{variant:t===l.index?`secondary`:`ghost`,disabled:N,"aria-current":t===l.index?`step`:void 0,onClick:()=>I(t),children:[t+1,`. `,e.header,l.answers[e.id]?.choiceId||l.answers[e.id]?.text?.trim()?` ✓`:``]},e.id))}):null]}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto px-4 py-3`,children:[(0,X.jsx)(np,{content:k.question,compact:!0,className:`text-fg [&_p]:font-medium`}),k.type===`single_choice`?(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:O.length>1?c.clarifyBatchQuickHint:i.clarifyQuickHint}):null,k.type===`single_choice`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{role:`group`,"aria-label":k.header,className:`space-y-0.5 rounded-lg border border-edge p-1`,children:k.choices.map((e,t)=>(0,X.jsx)(ap,{...e,index:t,recommended:k.recommendedChoiceId===e.id,recommendedLabel:i.clarifyRecommended,selected:A?.choiceId===e.id,disabled:N,onClick:()=>R(e.id)},e.id))}),(0,X.jsxs)(qi,{variant:`ghost`,disabled:N,"aria-expanded":B,"aria-controls":V,className:`min-h-11 justify-start gap-1 px-1 text-xs`,onClick:()=>w(B?void 0:k.id),children:[(0,X.jsx)(ie,{"aria-hidden":`true`,className:Y(`size-3.5`,B&&`rotate-90`)}),i.clarifyCustomLabel]})]}):null,B?(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{htmlFor:V,className:`sr-only`,children:i.clarifyCustomLabel}),(0,X.jsx)(`textarea`,{ref:D,id:V,rows:3,disabled:N,value:A?.text??``,"aria-invalid":(A?.text?.length??0)>2e3,onChange:e=>F({...l,answers:{...l.answers,[k.id]:{questionId:k.id,text:e.target.value}}}),onKeyDown:e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&!e.nativeEvent.isComposing&&(e.preventDefault(),l.index===O.length-1?L():z&&I(l.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,X.jsxs)(`p`,{className:`flex justify-between gap-2 text-xs text-fg-muted`,children:[(0,X.jsx)(`span`,{children:i.clarifyKeyboardHint}),(0,X.jsxs)(`span`,{children:[A?.text?.length??0,`/2000`]})]})]}):null,r||p?(0,X.jsx)(`p`,{role:`alert`,className:`text-red-600`,children:r||p}):null]}),(0,X.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,X.jsx)(qi,{variant:`ghost`,disabled:N,onClick:()=>void s(),children:i.clarifyCancel}),o?(0,X.jsx)(qi,{variant:`ghost`,disabled:N,onClick:()=>void o(),children:i.clarifyAgentDecide}):null,O.length>1?(0,X.jsx)(qi,{variant:`secondary`,disabled:N||l.index===0,onClick:()=>I(l.index-1),children:c.clarifyPrevious}):null,B||_||r||p||P===O.length?l.index<O.length-1&&!_?(0,X.jsx)(qi,{variant:`primary`,disabled:N||!z,onClick:()=>I(l.index+1),children:c.clarifyNext}):(0,X.jsx)(qi,{variant:`primary`,disabled:M||P!==O.length||!z,onClick:()=>void L(),children:M?i.clarifySubmitting:_?c.clarifyRetrySubmission:c.clarifySubmitAll}):null]})]})}function cp(e){let t=(0,Z.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,X.jsx)(sp,{...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,X.jsx)(lp,{...e,prompt:e.prompt},e.prompt.requestId):null,t[3]=e,t[4]=n),n}function lp({prompt:e,focusRequestKey:t,submitting:n,submitError:r,labels:i,onSubmit:a,onAgentDecide:o,onCancel:s}){let[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(Date.now),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(``),b=(0,Q.useRef)(!1),x=(0,Q.useRef)(null),S=(0,Q.useRef)(null),C=(0,Q.useRef)(null),[w]=(0,Q.useState)(()=>e.serverTime?e.serverTime-Date.now():0),T=e.expiresAt===void 0?null:Math.max(0,Math.ceil((e.expiresAt-m-w)/1e3)),E=T===0,D=n||g||E,O=e.kind===`approval`,k=f||!e.choiceDetails?.length,A=e.choiceDetails??[],j=c.trim().length>Br,M=`clarify-answer-${e.requestId}`,N=`clarify-error-${e.requestId}`,P=`clarify-hint-${e.requestId}`,F=e.recommendedChoiceId;(0,Q.useEffect)(()=>{t&&x.current?.scrollIntoView?.({block:`nearest`}),x.current?.focus({preventScroll:!!t})},[t]),(0,Q.useEffect)(()=>{(r||v)&&S.current?.focus()},[r,v]),(0,Q.useEffect)(()=>{f&&C.current?.focus()},[f]),(0,Q.useEffect)(()=>{if(!e.expiresAt)return;let t=window.setInterval(()=>h(Date.now()),1e3);return()=>window.clearInterval(t)},[e.expiresAt]),(0,Q.useEffect)(()=>{C.current&&(C.current.style.height=`auto`,C.current.style.height=`${Math.min(160,C.current.scrollHeight)}px`)},[c]);let I=async t=>{if(!(D||b.current)){b.current=!0,_(!0),y(``);try{dr(e,t),await a(t)}catch(e){y(e instanceof Error?e.message:String(e))}finally{b.current=!1,_(!1)}}},L=e=>{D||(d(e),I({response:{choiceId:e}}))},R=()=>{j||!c.trim()||I({response:{text:c.trim()||void 0}})};return(0,X.jsxs)(`section`,{ref:x,tabIndex:-1,"data-clarification-id":e.requestId,"aria-label":O?i.clarifyApprovalTitle:i.clarifyRegionAria,"aria-busy":n||g,className:Y(`mb-4 rounded-lg border border-edge bg-surface-overlay px-4 py-3 text-sm text-fg outline-none`,Ma.focusRingPanel),children:[(0,X.jsx)(`p`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:O?i.clarifyApprovalTitle:i.clarifyRegionAria}),(0,X.jsx)(np,{content:e.question,compact:!0,className:`mb-3 text-fg [&_p]:font-medium`}),O&&e.approval?(0,X.jsx)(`dl`,{className:`mb-3 space-y-2`,children:[[i.clarifyOperation,e.approval.operation],[i.clarifyTarget,e.approval.target],[i.clarifyImpact,e.approval.impact]].map(([e,t])=>t?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-xs text-fg-muted`,children:e}),(0,X.jsx)(`dd`,{className:`whitespace-pre-wrap break-words`,children:t})]},e):null)}):null,O&&e.approval?.argumentsPreview?(0,X.jsxs)(`details`,{className:`mb-3`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer text-fg-muted`,children:i.clarifyDetails}),(0,X.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,X.jsxs)(`div`,{className:`mb-3 space-y-1 text-xs text-fg-muted`,children:[O?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{children:i.clarifyOnce}),(0,X.jsx)(`p`,{children:i.clarifyApprovalTimeout})]}):null,T===null?null:(0,X.jsx)(`p`,{role:`status`,children:E?i.clarifyExpired:i.clarifyTimeRemaining.replace(`{{time}}`,`${Math.floor(T/60)}:${String(T%60).padStart(2,`0`)}`)})]}),r||v?(0,X.jsx)(`div`,{ref:S,tabIndex:-1,id:N,role:`alert`,className:`mb-3 rounded-md border border-edge p-3 text-red-600`,children:r||v}):null,n||g?(0,X.jsx)(`p`,{role:`status`,className:`mb-2 text-xs text-fg-muted`,children:i.clarifySubmitting}):null,O?(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsx)(qi,{variant:`secondary`,disabled:D,onClick:()=>void I({decision:`deny`}),children:i.clarifyDeny}),(0,X.jsx)(qi,{variant:`primary`,disabled:D,onClick:()=>void I({decision:`approve`}),children:i.clarifyApprove})]}):(0,X.jsxs)(X.Fragment,{children:[A.length?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:i.clarifyQuickHint}),(0,X.jsx)(`div`,{role:`group`,"aria-label":i.clarifyChoicesGroupAria,className:`max-h-64 space-y-0.5 overflow-y-auto rounded-lg border border-edge p-1`,children:A.map((e,t)=>(0,X.jsx)(ap,{...e,index:t,recommended:F===e.id,recommendedLabel:i.clarifyRecommended,selected:u===e.id,disabled:D,onClick:()=>L(e.id)},e.id))}),(0,X.jsxs)(qi,{variant:`ghost`,disabled:D,"aria-expanded":k,"aria-controls":M,className:`mt-1 min-h-11 justify-start gap-1 px-1 text-xs`,onClick:()=>{p(!f)},children:[(0,X.jsx)(ie,{"aria-hidden":`true`,className:Y(`size-3.5`,k&&`rotate-90`)}),i.clarifyCustomLabel]})]}):null,k?(0,X.jsxs)(`form`,{className:`mt-2 space-y-2`,onSubmit:e=>{e.preventDefault(),R()},children:[(0,X.jsx)(`label`,{htmlFor:M,className:`block text-xs font-medium text-fg-muted`,children:i.clarifyCustomLabel}),(0,X.jsx)(`textarea`,{id:M,ref:C,value:c,rows:2,disabled:D,placeholder:i.clarifyPlaceholder,"aria-invalid":j,"aria-describedby":`${P}${r?` ${N}`:``}`,onChange:e=>{l(e.target.value),e.target.value&&p(!0)},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&!e.nativeEvent.isComposing&&(e.preventDefault(),R())},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,X.jsxs)(`div`,{id:P,className:`flex flex-wrap justify-between gap-2 text-xs text-fg-muted`,children:[(0,X.jsx)(`span`,{children:j?i.clarifyAnswerTooLong:i.clarifyKeyboardHint}),(0,X.jsxs)(`span`,{"aria-live":j?`polite`:`off`,children:[c.trim().length,`/`,Br]})]}),(0,X.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,X.jsx)(qi,{type:`submit`,variant:`primary`,disabled:D||j||!c.trim(),children:i.clarifySend})})]}):null,(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-1 border-t border-edge-subtle pt-2`,children:[o?(0,X.jsx)(qi,{variant:`ghost`,disabled:D,onClick:()=>void o(),children:i.clarifyAgentDecide}):null,(0,X.jsx)(qi,{variant:`ghost`,disabled:n||g,onClick:()=>void s(),children:i.clarifyCancel})]})]})]})}function up(e,t){let n=(0,Z.c)(13),r=v(fp),i=v(dp),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 $r(e)?void 0:(await b(_(`/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=vi(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 dp(e){return e.baseUrl}function fp(e){return e.conversationId}function pp(){return Ya()?window.electronAPI?.platform??`web`:`web`}function mp({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 hp=`xopc-web-sidebar-collapsed`,gp=`xopc-web-sidebar-expanded-width-px`;function _p(){try{return globalThis.localStorage?.getItem(hp)===`1`}catch{return!1}}function vp(e){try{globalThis.localStorage?.setItem(hp,e?`1`:`0`)}catch{}}function yp(e){return Math.min(480,Math.max(248,Math.round(e)))}function bp(){try{let e=globalThis.localStorage?.getItem(gp);if(e==null)return yp(256);let t=Number.parseInt(e,10);return yp(Number.isFinite(t)?t:256)}catch{return yp(256)}}function xp(e){try{globalThis.localStorage?.setItem(gp,String(e))}catch{}}var Sp=x((e,t)=>({collapsed:_p(),setCollapsed:t=>{e({collapsed:t}),queueMicrotask(()=>vp(t))},toggleCollapsed:()=>{t().setCollapsed(!t().collapsed)},expandedWidthPx:bp(),setExpandedWidthPx:n=>{let r=yp(n);t().expandedWidthPx!==r&&(e({expandedWidthPx:r}),queueMicrotask(()=>xp(r)))}})),Cp=x(e=>({mobileNavOpen:!1,setMobileNavOpen:t=>e({mobileNavOpen:t}),toggleMobileNav:()=>e(e=>({mobileNavOpen:!e.mobileNavOpen}))}));function wp(e){return e>99?`99+`:String(e)}function Tp(e,t){let n=(0,Z.c)(15),r=t===void 0||t,i=v(kp),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}=vi(a,Op,o),[l,u]=(0,Q.useState)(Dp),d,f;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)}},f=[c,r,i],n[4]=r,n[5]=i,n[6]=c,n[7]=d,n[8]=f):(d=n[7],f=n[8]),(0,Q.useEffect)(d,f);let p=s?.payload,m,h;return n[9]!==c||n[10]!==p||n[11]!==e||n[12]!==l?(m=()=>{if(!l||!p?.unreadCount||p.conversationId!==e)return;let t=!0;return g(`/api/personal-agent/read`,{method:`POST`,body:JSON.stringify({transcriptId:p.transcriptId,lastSeq:p.lastSeq})}).then(async e=>{if(!e.ok)return;let n=await e.json();t&&await c(n,{revalidate:!1})}).catch(Ep),()=>{t=!1}},h=[l,e,p,c],n[9]=c,n[10]=p,n[11]=e,n[12]=l,n[13]=m,n[14]=h):(m=n[13],h=n[14]),(0,Q.useEffect)(m,h),p?.unreadCount??0}function Ep(){}function Dp(){return document.visibilityState===`visible`&&document.hasFocus()}function Op(){return b(_(`/api/personal-agent/unread`))}function kp(e){return e.conversationId}var Ap=80;function jp(e){let t=e.trim();(t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`))&&(t=t.slice(1,-1).trim());let n=t.indexOf(`
9
+ `);return n!==-1&&(t=t.slice(0,n).trim()),t.length>Ap&&(t=t.slice(0,Ap-1).trimEnd()+`…`),t}function Mp(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 Np(e){let t=e.trimStart().match(/^\/skill:([^\s]+)(?:\s+([\s\S]*))?$/i);return t&&(t[2]?.trim()||t[1]?.trim())||e}function Pp(e){let t=Np(Mp(Zn([{type:`text`,text:e}]))).split(/\n/)[0]?.trim();if(!t)return null;let n=jp(t);return n.length>0?n:null}function Fp(e,t){let n=e.trim(),r=t.trim();!n||!r||window.dispatchEvent(new CustomEvent(`session-updated`,{detail:{key:n,name:r},bubbles:!0}))}function Ip({conversationId:e,initialName:t,onClose:n,returnFocusRef:r}){let i=C(y(e=>e.language)),a=(0,Q.useId)(),[o,s]=(0,Q.useState)(t),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1),f=async t=>{t.preventDefault();let r=o.trim();if(!(!r||c)){l(!0),d(!1);try{if(!(await En(e,r)).renamed){d(!0);return}Fp(e,r),n()}catch{d(!0)}finally{l(!1)}}};return(0,X.jsx)(j,{open:!0,onOpenChange:e=>{!e&&!c&&n()},children:(0,X.jsxs)(O,{children:[(0,X.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,X.jsxs)(k,{"aria-describedby":void 0,onCloseAutoFocus:e=>{r?.current&&(e.preventDefault(),r.current.focus())},className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] w-[min(24rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover`,children:[(0,X.jsx)(A,{className:`text-base font-semibold text-fg`,children:i.sidebar.taskRenameTitle}),(0,X.jsxs)(`form`,{onSubmit:e=>void f(e),children:[(0,X.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg-subtle`,htmlFor:a,children:i.sidebar.taskRenamePlaceholder}),(0,X.jsx)(`input`,{id:a,type:`text`,value:o,onChange:e=>s(e.target.value),readOnly:c,className:Y(`mt-1.5 w-full rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 text-sm text-fg`,Ja),placeholder:i.chat.newSession}),u?(0,X.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:i.sessions.renameFailed}):null,(0,X.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,X.jsx)(D,{asChild:!0,children:(0,X.jsx)(qi,{type:`button`,variant:`secondary`,disabled:c,children:i.sidebar.taskRenameCancel})}),(0,X.jsx)(qi,{type:`submit`,variant:`primary`,disabled:!o.trim()||c,children:i.sidebar.taskRenameSave})]})]})]})]})})}function Lp(e){return e.trim()}var Rp=x(e=>({runs:{},markRunning:t=>{let n=Lp(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=Lp(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=Lp(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=Lp(t);n&&e(e=>{let t=e.runs[n];return t?.unread?{runs:{...e.runs,[n]:{...t,unread:!1}}}:e})},clear:t=>{let n=Lp(t);n&&e(e=>{if(!(n in e.runs))return e;let{[n]:t,...r}=e.runs;return{runs:r}})}}));function zp(e){Rp.getState().markRunning(e)}function Bp(e,t){Rp.getState().markCompleted(e,t)}function Vp(e,t){Rp.getState().markFailed(e,t)}function Hp(e){Rp.getState().clear(e)}function Up(e){Rp.setState(t=>({runs:{...t.runs,[e]:{status:`waiting`,startedAt:t.runs[e]?.startedAt??Date.now(),updatedAt:Date.now(),unread:!1}}}))}function Wp(e,t){return[`gateway-chat-session-agent`,e,t]}function Gp(e){let t=(0,Z.c)(5),n=v(qp),r,i;if(t[0]!==e||t[1]!==n){let a=e?.trim();r=vi,i=n&&a?Wp(n,a):null,t[0]=e,t[1]=n,t[2]=r,t[3]=i}else r=t[2],i=t[3];let a;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},t[4]=a):a=t[4],r(i,Kp,a)}function Kp(e){let[,,t]=e;return Jp(t)}function qp(e){return e.conversationId}async function Jp(e){let t=await $r(e);if(t)return{agentId:t.creation.agentId.trim().toLowerCase(),projectId:t.creation.projectId?.trim()||null,...t.creation.agentSetup?{agentSetup:!0}:{},...!t.creation.agentSetup&&!t.creation.temporary?{expertChat:!0}:{}};let n=await wn(e,{limit:1}),r=typeof n.sourceChannel==`string`?kn(n):void 0,i=r?.source===`workbench`&&r.purpose===`chat`&&n.status!==`archived`&&!n.parentConversationId&&n.customData?.agentSetup!==!0;return{agentId:(n.routing?.agentId??n.agentId).trim().toLowerCase(),projectId:n.projectId?.trim()||null,...n.customData?.agentSetup===!0?{agentSetup:!0}:{},...i?{expertChat:!0}:{}}}function Yp(e){let t=Sr(t=>Fn(t.sessions[e])),[n,r]=(0,Q.useState)(()=>Ln(e)),i=(0,Q.useRef)(e);return i.current!==e&&(i.current=e,r(Ln(e))),(0,Q.useEffect)(()=>{r(Ln(e))},[e,t]),(0,Q.useEffect)(()=>{let t=t=>{t.detail?.chatId===e&&r(Ln(e))};return window.addEventListener($n,t),()=>window.removeEventListener($n,t)},[e]),t||n}var Xp=`application/x-xopc-workspace-file`;function Zp(e,t){e.effectAllowed=`copy`,e.setData(Xp,JSON.stringify(t))}function Qp(e){return!!(e&&Array.from(e.types).includes(`application/x-xopc-workspace-file`))}function $p(e){if(!e)return null;try{let t=JSON.parse(e.getData(Xp)),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 em=`xopc-web-workspace-panel-open`,tm=`xopc-web-workspace-panel-width-px`;function nm(){try{return globalThis.localStorage?.getItem(em)===`1`}catch{return!1}}function rm(e){try{globalThis.localStorage?.setItem(em,e?`1`:`0`)}catch{}}function im(e){return Math.min(520,Math.max(200,Math.round(e)))}function am(){try{let e=globalThis.localStorage?.getItem(tm);if(e==null)return 320;let t=Number.parseInt(e,10);return Number.isFinite(t)?im(t):320}catch{return 320}}function om(e){try{globalThis.localStorage?.setItem(tm,String(e))}catch{}}var sm=x((e,t)=>({open:nm(),setOpen:t=>{Ji.getState().setOpen(t),e(t?{open:t}:{open:t,conversationIdOverride:null}),queueMicrotask(()=>rm(t))},toggleOpen:()=>{t().setOpen(!t().open)},conversationIdOverride:null,openForSession:t=>{let n=t.trim();Ji.getState().setScope(n||`new`),Ji.getState().setOpen(!0,n||`new`),e({open:!0,conversationIdOverride:n||null}),queueMicrotask(()=>rm(!0))},widthPx:am(),setWidthPx:n=>{let r=im(n);t().widthPx!==r&&(e({widthPx:r}),queueMicrotask(()=>om(r)))}})),cm={commands:!0,skills:!0,agentSwitch:!0},lm={commands:!1,skills:!1,agentSwitch:!1},um=new WeakMap,dm=`​`,fm=`⁠`,pm=RegExp(`^\\/skill:(${oo})`);function mm(e){return!!e.dataset.skill}function hm(e){return!!e.dataset.contextRefId}function gm(e){return e.dataset.slashCommand!=null&&e.dataset.slashCommand!==``}var _m=new WeakMap;function vm(e){let t=Pn(),n,r=-1;for(;(n=t.exec(e))!==null;)r=n.index+n[0].length;return r===e.length}function ym(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=vm(t)||/\/skill:\S+$/.test(t)||es(t),r=n.startsWith(`@xopc-ref:`)||n.startsWith(`/skill:`)||Qo(n);(e||r)&&(t+=` `)}}t+=n}return t}function bm(e){if(e.nodeType!==Node.ELEMENT_NODE)return!1;let t=e.tagName;return t===`DIV`||t===`P`||t===`PRE`||t===`BLOCKQUOTE`}function xm(e,t){if(e.nodeType===Node.TEXT_NODE)t.push((e.textContent??``).replaceAll(dm,``));else if(e.nodeType===Node.ELEMENT_NODE){let n=e;if(mm(n)){let e=n.dataset.skill??``;e&&t.push(`/skill:${e}`)}else if(hm(n)){let e=n.dataset.contextRefId??``;e&&t.push(er(e))}else if(gm(n)){let e=n.dataset.slashCommand??``;e&&t.push(`/${e}`)}else n.tagName===`BR`?t.push(`
10
+ `):Sm(n,t)}}function Sm(e,t){let n=Array.from(e.childNodes);for(let e=0;e<n.length;e++){let r=n[e],i=n[e+1];xm(r,t),i!=null&&(bm(r)||bm(i))&&t.push(`
11
+ `)}}function Cm(e,t){Sm(e,t)}function wm(e){let t=[];return Cm(e,t),ym(t).replaceAll(fm,``)}function Tm(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 Em(e){let t=wm(e);return t.length>0||e.childNodes.length===0?t:(Vm(e,``),Tm(e),``)}function Dm(e){let t=new Set,n=ro(),r;for(;(r=n.exec(e))!==null;){let e=r[1];e&&t.add(e)}return t}function Om(e){let t=window.getSelection();if(!t||t.rangeCount===0)return wm(e).length;let n=t.getRangeAt(0);if(!e.contains(n.startContainer))return wm(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()),wm(i).length}var km=new WeakMap;function Am(e,t){km.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 jm(e,t){_m.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 Mm(e,t){let n=document.createElement(`span`);n.contentEditable=`false`,n.dataset.skill=t,n.className=`chat-skill-pill`,n.textContent=`/${km.get(e)?.(t)??t}`,n.title=`/${t}`,e.appendChild(n),e.appendChild(document.createTextNode(dm))}function Nm(e,t){let n=_m.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(dm))}function Pm(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(dm))}function Fm(e,t=cm){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(ro()),r(Pn());for(let r of t.commands?cs(e):[])n.push(r);return n.sort((e,t)=>e.start-t.start),n}function Im(e,t,n=cm){for(let{start:r,end:i}of Fm(e,n))if(t>r&&t<=i)return{wire:e.slice(0,r)+e.slice(i),caret:r};return null}function Lm(e,t,n=cm){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?[ao]:[];for(let e of a){let t=i(e);if(t)return t}let o=n.commands?as(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?[io]:[];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?$o(r):null;if(a){let n=a.tokenStart;return{wire:e.slice(0,n)+e.slice(t),caret:n}}}return null}function Rm(e){let t=window.getSelection();if(!t||t.rangeCount===0||!t.isCollapsed)return!1;let n=t.getRangeAt(0),r=wm(e),i=Om(e);i===0&&r.length>0&&n.startContainer===e&&n.startOffset===e.childNodes.length&&(i=r.length);let a=um.get(e)??cm,o=Im(r,i,a);return o||=Lm(r,i,a),o?(Vm(e,o.wire,o.caret),e.dispatchEvent(new InputEvent(`input`,{bubbles:!0})),!0):!1}function zm(e,t,n){let r=e.slice(t);return n.skills&&pm.test(r)||Pn().exec(r)?.index===0?!0:n.commands&&ts(e,t)!=null}function Bm(e,t,n){let r=um.get(e)??cm,i=t.slice(n),a=[],o=i.match(pm);r.skills&&o?.[0]&&a.push({len:o[0].length,apply:()=>Mm(e,o[1]??``)});let s=Pn().exec(i);s?.index===0&&s[0]&&a.push({len:s[0].length,apply:()=>Nm(e,s[1]??``)});let c=r.commands?ts(t,n):null;if(c&&a.push({len:c.len,apply:()=>Pm(e,c.matchedKey)}),a.length===0){let i=n+1;for(;i<t.length&&!zm(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 Vm(e,t,n,r){r&&um.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)+fm+t.slice(e)}let a=0;for(;a<i.length;)a=Bm(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]===fm){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 Hm(e,t){for(let n of e)if(n.isActive()&&n.handleKey(t))return!0;return!1}var Um=8*1024,Wm=80,Gm=2*1024,Km=20;function qm(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 Jm(e){let t=new TextEncoder().encode(e).byteLength,n=e.split(/\r\n|\n|\r/).length,r=qm(e);return t>=Um||n>=Wm||r!==`text`&&(t>=Gm||n>=Km)?{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 Ym(e){if(!e)return null;let t=hs(e);if(t.length>0)return{kind:`files`,files:t};let n=e.getData(`text/plain`);if(!n)return null;let r=Jm(n);return r?{kind:`text-attachment`,attachment:r}:{kind:`inline-text`,text:n}}async function Xm(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 Zm=`fill-chat-composer`;function Qm(e,t,n){window.dispatchEvent(new CustomEvent(Zm,{detail:{text:e,attachments:t,contextRefs:n}}))}function $m(e,t,n){let r=(0,Z.c)(20),i=n===void 0||n,a=y(nh),o=v(th),s=v(eh),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=()=>Xo(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}=vi(c,l,u),p,m;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)},m=[i,o,f],r[10]=i,r[11]=o,r[12]=f,r[13]=p,r[14]=m):(p=r[13],m=r[14]),(0,Q.useEffect)(p,m);let h;r[15]!==d?.skills||r[16]!==a?(h=new Map(d?.skills.map(e=>[e.name,rs(e,a).displayName])),r[15]=d?.skills,r[16]=a,r[17]=h):h=r[17];let g=h,_;return r[18]===g?_=r[19]:(_=e=>g.get(e)??e,r[18]=g,r[19]=_),_}function eh(e){return e.baseUrl}function th(e){return e.conversationId}function nh(e){return e.language}function rh(e,t){e.classList.toggle(`composer-input-empty`,t.length===0)}function ih(e){let{disabled:t,initialValue:n=``,onValueChange:r,autoFocusKey:i,welcomeDraftSeed:a,onExternalTextReplace:o,shouldSyncSelectionRef:s,resolveContextRef:c}=e,l=e.capabilities??cm,u=$m(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||(Am(e,u),c&&jm(e,c),D())},[u,c,h,D]),(0,Q.useLayoutEffect)(()=>{if(T.current)return;let e=_.current;e&&(T.current=!0,c&&jm(e,c),Vm(e,n,n.length,l),rh(e,n),D())},[D,n,c,l]),(0,Q.useLayoutEffect)(()=>{let e=_.current;e&&Vm(e,v.current,Om(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}Vm(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&&(Vm(r,t,n,l),rh(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,a.preserveDraft||o?.(),A({nextText:a.preserveDraft&&v.current.trim()?v.current: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)||document.activeElement?.closest(`[role="dialog"]`))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=Om(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(Zm,t),()=>window.removeEventListener(Zm,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 ah=(0,Q.memo)(function(e){let t=(0,Z.c)(42),{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||t[2]!==i?(_=()=>{if(r||i||!n.current)return;let e=requestAnimationFrame(oh);return()=>cancelAnimationFrame(e)},v=[r,i,n],t[0]=r,t[1]=n,t[2]=i,t[3]=_,t[4]=v):(_=t[3],v=t[4]),(0,Q.useEffect)(_,v);let y,b;t[5]!==r||t[6]!==n?(y=()=>{let e=n.current;if(!e||r)return;let t=t=>{t.inputType!==`deleteContentBackward`||!t.cancelable||t.isComposing||g.current||Rm(e)&&t.preventDefault()};return e.addEventListener(`beforeinput`,t),()=>e.removeEventListener(`beforeinput`,t)},b=[r,n],t[5]=r,t[6]=n,t[7]=y,t[8]=b):(y=t[7],b=t[8]),(0,Q.useEffect)(y,b);let x=s??o,S=!r,C=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`,w;t[9]===C?w=t[10]:(w=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`,C,`composer-input-empty`),t[9]=C,t[10]=w);let T;t[11]!==l||t[12]!==c?(T=e=>{let t=e.currentTarget,n=g.current?wm(t):Em(t),r=e.nativeEvent.inputType;!g.current&&r?.startsWith(`delete`)&&n===`
12
+ `&&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=``),rh(t,n),c(n,Om(t)),l()},t[11]=l,t[12]=c,t[13]=T):T=t[13];let E;t[14]===f?E=t[15]:(E=()=>{g.current=!0,f(!0)},t[14]=f,t[15]=E);let D;t[16]!==l||t[17]!==n||t[18]!==c||t[19]!==f?(D=()=>{g.current=!1,f(!1),queueMicrotask(()=>{let e=n.current;if(!e||g.current)return;let t=Em(e);rh(e,t),c(t,Om(e)),l()})},t[16]=l,t[17]=n,t[18]=c,t[19]=f,t[20]=D):D=t[20];let O;t[21]!==m||t[22]!==u||t[23]!==d?(O=async e=>{let t=Ym(e.clipboardData);t&&(e.preventDefault(),await Xm(t,{processFiles:u,processPastedText:d,insertText:sh,onUnsupportedFiles:()=>Ua(`warning`,m.clipboardFileTypeUnsupported)}))},t[21]=m,t[22]=u,t[23]=d,t[24]=O):O=t[24];let k;t[25]!==r||t[26]!==n||t[27]!==i||t[28]!==p?(k=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){e.preventDefault(),!e.repeat&&t.runBusy&&!t.editingUserTurnId&&!t.editingFollowUpId&&!r&&!i&&(t.valueRef.current.trim()||t.attachmentsLen>0||t.contextRefsLen>0)&&t.submitFollowUp?.();return}if(e.key===`Backspace`&&!t.isComposing&&!g.current&&!e.nativeEvent.isComposing&&n.current&&Rm(n.current)){e.preventDefault();return}if(Hm(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,`
13
+ `);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[25]=r,t[26]=n,t[27]=i,t[28]=p,t[29]=k):k=t[29];let A;return t[30]!==n||t[31]!==i||t[32]!==o||t[33]!==T||t[34]!==E||t[35]!==D||t[36]!==O||t[37]!==k||t[38]!==x||t[39]!==S||t[40]!==w?(A=(0,X.jsx)(`div`,{ref:n,hidden:i,role:`textbox`,"aria-multiline":`true`,"aria-label":x,contentEditable:S,suppressContentEditableWarning:!0,spellCheck:!0,className:w,"data-placeholder":o,onInput:T,onCompositionStart:E,onCompositionEnd:D,onPaste:O,onKeyDown:k}),t[30]=n,t[31]=i,t[32]=o,t[33]=T,t[34]=E,t[35]=D,t[36]=O,t[37]=k,t[38]=x,t[39]=S,t[40]=w,t[41]=A):A=t[41],A});function oh(){return n(`composer_ready_frame`)}function sh(e){return document.execCommand(`insertText`,!1,e)}function ch(e){let t=(0,Z.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,X.jsx)(`div`,{className:s,...i,children:n}),t[8]=n,t[9]=i,t[10]=s,t[11]=c):c=t[11],c}var lh=`touch-target flex min-h-9 cursor-default items-center gap-2 rounded-md px-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover data-[disabled]:opacity-45`,uh={video:pc,music:Ct};function dh(e){let t=(0,Z.c)(16),{trigger:n,fileLabel:r,filesDisabled:i,onPickFiles:a,actions:o}=e,s=(0,Q.useRef)(!1),c;t[0]===n?c=t[1]:(c=(0,X.jsx)(Vo,{asChild:!0,children:n}),t[0]=n,t[1]=c);let l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=e=>{s.current&&e.preventDefault(),s.current=!1},t[2]=l):l=t[2];let u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,X.jsx)(kt,{className:`size-4`,"aria-hidden":!0}),t[3]=u):u=t[3];let d;t[4]!==r||t[5]!==i||t[6]!==a?(d=(0,X.jsxs)(Uo,{className:lh,disabled:i,onSelect:a,children:[u,r]}),t[4]=r,t[5]=i,t[6]=a,t[7]=d):d=t[7];let f;t[8]===o.items?f=t[9]:(f=o.items.map(e=>{let{kind:t,label:n,onSelect:r}=e,i=uh[t];return(0,X.jsxs)(Uo,{className:lh,onSelect:()=>{s.current=typeof globalThis.matchMedia==`function`&&globalThis.matchMedia(`(hover: hover) and (pointer: fine)`).matches,r()},children:[(0,X.jsx)(i,{className:`size-4`,"aria-hidden":!0}),n]},t)}),t[8]=o.items,t[9]=f);let p;t[10]!==d||t[11]!==f?(p=(0,X.jsx)(Ho,{children:(0,X.jsxs)(Wo,{side:`top`,align:`start`,sideOffset:6,onCloseAutoFocus:l,className:`z-[100] min-w-40 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:[d,f]})}),t[10]=d,t[11]=f,t[12]=p):p=t[12];let m;return t[13]!==c||t[14]!==p?(m=(0,X.jsxs)(Bo,{children:[c,p]}),t[13]=c,t[14]=p,t[15]=m):m=t[15],m}function fh(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function ph(e){let t=(0,Z.c)(19),{disabled:n,runBusy:r,attachmentCount:i,maxAttachments:a,chat:o,onPickFiles:s,addActions:c}=e,l=i>=a,u;t[0]!==i||t[1]!==l||t[2]!==o.attachFile||t[3]!==o.maxAttachmentsReached||t[4]!==a?(u=l?fh(o.maxAttachmentsReached,{max:a}):`${o.attachFile} (${i}/${a})`,t[0]=i,t[1]=l,t[2]=o.attachFile,t[3]=o.maxAttachmentsReached,t[4]=a,t[5]=u):u=t[5];let d=u,f;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(f=Y(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,Ma.transition,Ma.press,Ma.focusRingPanel,`disabled:cursor-not-allowed disabled:opacity-50`),t[6]=f):f=t[6];let p=!c&&l||n||r,m=c?.label??d,h=c?.label??d,g=c?void 0:s,_;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,X.jsx)(Ft,{className:`size-4`}),t[7]=_):_=t[7];let v;t[8]!==p||t[9]!==m||t[10]!==h||t[11]!==g?(v=(0,X.jsx)(`button`,{type:`button`,className:f,disabled:p,title:m,"aria-label":h,onClick:g,children:_}),t[8]=p,t[9]=m,t[10]=h,t[11]=g,t[12]=v):v=t[12];let y=v,b;return t[13]!==c||t[14]!==l||t[15]!==o.attachFile||t[16]!==s||t[17]!==y?(b=c?(0,X.jsx)(dh,{trigger:y,fileLabel:o.attachFile,filesDisabled:l,onPickFiles:s,actions:c}):y,t[13]=c,t[14]=l,t[15]=o.attachFile,t[16]=s,t[17]=y,t[18]=b):b=t[18],b}function mh(e){let t=(0,Z.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,X.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:i?(0,X.jsxs)(X.Fragment,{children:[o&&u?(0,X.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`,Ma.transition,Ma.press,Ma.focusRingPanel),title:s.steeringInterruptSend,"aria-label":s.steeringInterruptSend,onClick:()=>void u(),children:(0,X.jsx)(he,{className:`size-4 stroke-[1.75]`})}):null,(0,X.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`,Ma.transition,Ma.press,Ma.focusRingPanel),title:s.abort,"aria-label":s.abort,onClick:l,children:(0,X.jsx)(Kt,{className:`size-4 stroke-[1.75]`})})]}):(0,X.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`,Ma.press,Ma.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,X.jsx)(he,{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 hh(e){let t=(0,Z.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,X.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var gh=(0,Q.memo)(function(e){let t=(0,Z.c)(43),{disabled:n,sendDisabled:r,runBusy:i,chat:a,hasDraft:o,showSteeringInterrupt:s,attachmentCount:c,maxAttachments:l,onPickFiles:u,addActions:d,thinkingLevel:f,onThinkingChange:p,voiceActive:m,onStartVoiceInput:h,voiceConversationEnabled:g,onStartVoiceConversation:_,onSend:v,onAbort:y,onInterrupt:b,sessionModel:x,showModelSelector:S,onModelChange:C,modelDisabled:w}=e,T=r!==void 0&&r;if(m)return null;let E;t[0]!==d||t[1]!==c||t[2]!==n||t[3]!==a||t[4]!==l||t[5]!==u||t[6]!==i?(E=(0,X.jsx)(ph,{disabled:n,runBusy:i,attachmentCount:c,maxAttachments:l,chat:a,onPickFiles:u,addActions:d}),t[0]=d,t[1]=c,t[2]=n,t[3]=a,t[4]=l,t[5]=u,t[6]=i,t[7]=E):E=t[7];let D;t[8]!==n||t[9]!==a||t[10]!==w||t[11]!==C||t[12]!==p||t[13]!==x||t[14]!==S||t[15]!==f?(D=S?(0,X.jsx)(di,{chat:a,sessionModel:x,modelDisabled:w,onModelChange:C,thinkingLevel:f,thinkingDisabled:n||w,onThinkingChange:p}):null,t[8]=n,t[9]=a,t[10]=w,t[11]=C,t[12]=p,t[13]=x,t[14]=S,t[15]=f,t[16]=D):D=t[16];let O;t[17]!==n||t[18]!==a||t[19]!==_||t[20]!==h||t[21]!==m||t[22]!==g?(O=m?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ps,{disabled:n,chat:a,onStart:h}),(0,X.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`,Ma.transition,Ma.press,Ma.focusRingPanel,`disabled:cursor-not-allowed disabled:opacity-50`),disabled:n||!g,title:a.voiceConversation,"aria-label":a.voiceConversation,onClick:()=>void _(),children:(0,X.jsx)(z,{className:`size-4 stroke-[1.75]`})})]}),t[17]=n,t[18]=a,t[19]=_,t[20]=h,t[21]=m,t[22]=g,t[23]=O):O=t[23];let k=n||T,A;t[24]!==o||t[25]!==a||t[26]!==y||t[27]!==b||t[28]!==v||t[29]!==i||t[30]!==s||t[31]!==k||t[32]!==m?(A=(0,X.jsx)(mh,{disabled:k,voiceActive:m,runBusy:i,hasDraft:o,showSteeringInterrupt:s,chat:a,onSend:v,onAbort:y,onInterrupt:b}),t[24]=o,t[25]=a,t[26]=y,t[27]=b,t[28]=v,t[29]=i,t[30]=s,t[31]=k,t[32]=m,t[33]=A):A=t[33];let j;t[34]!==O||t[35]!==A?(j=(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[O,A]}),t[34]=O,t[35]=A,t[36]=j):j=t[36];let M;t[37]!==D||t[38]!==j?(M=(0,X.jsxs)(`div`,{className:`ml-auto flex min-w-0 items-center gap-2`,children:[D,j]}),t[37]=D,t[38]=j,t[39]=M):M=t[39];let N;return t[40]!==E||t[41]!==M?(N=(0,X.jsxs)(hh,{children:[E,M]}),t[40]=E,t[41]=M,t[42]=N):N=t[42],N}),_h=(0,Q.memo)(function(e){let t=(0,Z.c)(18),{spotlight:n,onPickPrompt:r,compact:i}=e,a=i!==void 0&&i,o=y(vh),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,X.jsx)(eo,{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,X.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,X.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`,Ma.transition,Ma.press,Ma.focusRingPanel),children:[(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`line-clamp-2 block text-sm font-medium leading-snug text-fg sm:text-[0.9375rem]`,children:s.title}),(0,X.jsx)(`span`,{className:`mt-1 block truncate text-xs text-fg-muted`,children:s.reason})]}),(0,X.jsx)(ie,{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 h;return t[13]!==l||t[14]!==f||t[15]!==p||t[16]!==m?(h=(0,X.jsxs)(`div`,{className:l,children:[f,p,m]}),t[13]=l,t[14]=f,t[15]=p,t[16]=m,t[17]=h):h=t[17],h});function vh(e){return e.language}function yh({sourceVersionId:e,title:t,zh:n,onSaved:r}){let[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),m=(0,Q.useDeferredValue)(o),h=yi((t,n)=>{if(!i||t&&!n?.nextCursor)return null;let r=new URLSearchParams({versionTargetFor:e,q:m});return t&&n?.nextCursor&&r.set(`cursor`,n.nextCursor),`${mi}?${r}`},_i),g=h.data?.flatMap(e=>e.items)??[],_=g.find(e=>e.id===c),v=n?`保存为新版本`:`Save as new version`;function y(e){u||(a(e),e&&(s(``),l(void 0),p(!1)))}async function b(t){if(!u){d(!0),p(!1);try{let n=await gi(t.id,e,t.revision);a(!1),r(n)}catch{p(!0),h.mutate()}finally{d(!1)}}}return(0,X.jsxs)(j,{open:i,onOpenChange:y,children:[(0,X.jsx)(T,{className:`rounded-lg px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":`${v} · ${t}`,children:v}),(0,X.jsxs)(O,{children:[(0,X.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-[90] bg-scrim`}),(0,X.jsxs)(k,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[91] flex h-[min(31rem,calc(100dvh-2rem))] w-[min(30rem,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`,children:[(0,X.jsxs)(`header`,{className:`space-y-3 px-5 pt-5`,children:[(0,X.jsx)(A,{className:`text-base font-semibold text-fg`,children:v}),(0,X.jsx)(E,{className:`truncate text-sm text-fg-muted`,title:t,children:n?`为「${t}」选择原资料`:`Choose the original result for “${t}”`}),(0,X.jsxs)(`label`,{className:`flex min-h-10 items-center gap-2 rounded-lg border border-edge-subtle bg-surface-inset px-3 focus-within:ring-2 focus-within:ring-accent`,children:[(0,X.jsx)(zt,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,X.jsx)(`input`,{value:o,maxLength:160,onChange:e=>{s(e.target.value),l(void 0)},"aria-label":n?`搜索原资料`:`Search original results`,placeholder:n?`搜索原资料`:`Search original results`,className:`min-w-0 flex-1 bg-transparent text-sm text-fg outline-none`})]})]}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-3`,children:[h.isLoading?(0,X.jsx)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[0,1,2].map(e=>(0,X.jsx)(sn,{className:`h-11 rounded-lg`},e))}):null,h.error?(0,X.jsx)(`button`,{type:`button`,className:`rounded-lg px-2 py-2 text-sm text-accent-fg`,onClick:()=>void h.mutate(),children:n?`加载失败,重试`:`Could not load. Retry`}):null,!h.isLoading&&!h.error&&!g.length?(0,X.jsx)(`p`,{className:`py-5 text-center text-sm text-fg-muted`,children:n?`没有可选的资料`:`No matching results`}):null,(0,X.jsx)(`ul`,{className:`space-y-1`,children:g.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,onClick:()=>{l(e.id),p(!1)},disabled:u,"aria-pressed":c===e.id,className:Y(`flex min-h-11 w-full items-center gap-2 rounded-lg px-3 py-1.5 text-start text-sm`,c===e.id?`bg-accent-soft text-accent-fg`:`text-fg hover:bg-surface-hover`),children:[(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block truncate font-medium`,children:e.title}),(0,X.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,children:e.origin?.label??e.currentVersion.fileName})]}),c===e.id?(0,X.jsx)(ne,{className:`size-4 shrink-0`,"aria-hidden":!0}):null]})},e.id))}),h.data?.at(-1)?.nextCursor?(0,X.jsx)(`button`,{type:`button`,onClick:()=>void h.setSize(h.size+1),className:`mt-2 w-full rounded-lg py-2 text-sm text-accent-fg hover:bg-surface-hover`,children:n?`加载更多`:`Load more`}):null]}),(0,X.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-edge-subtle px-5 py-3`,children:[f?(0,X.jsx)(`p`,{role:`alert`,className:`flex-1 text-xs text-danger`,children:n?`保存失败,请重新选择资料。`:`Could not save. Choose the result again.`}):null,(0,X.jsx)(D,{asChild:!0,children:(0,X.jsx)(qi,{variant:`secondary`,disabled:u,children:n?`取消`:`Cancel`})}),(0,X.jsx)(qi,{variant:`primary`,disabled:!_||u,onClick:()=>{_&&b(_)},children:u?n?`正在保存`:`Saving`:n?`保存版本`:`Save version`})]})]})]})]})}async function bh(e){let t=await g(_(e));if(!t.ok)return null;let n=await t.json();return typeof n.id==`string`?{id:n.id,versionId:typeof n.versionId==`string`?n.versionId:void 0,canSaveAsVersion:n.canSaveAsVersion===!0}:null}function xh(e){let t=(0,Z.c)(19),{path:n,zh:r,title:i,readonly:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={shouldRetryOnError:!1},t[0]=o):o=t[0];let{data:s,mutate:c}=vi(n,bh,o);if(!s)return null;let l;t[1]!==s.id||t[2]!==s.versionId?(l=new URLSearchParams({item:s.id}),s.versionId&&l.set(`version`,s.versionId),t[1]=s.id,t[2]=s.versionId,t[3]=l):l=t[3];let u=`/space?${l}`,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,X.jsx)(P,{className:`size-3.5`,"aria-hidden":!0}),t[4]=d):d=t[4];let f=r?`在资料库中查看`:`View in Space`,p;t[5]!==u||t[6]!==f||t[7]!==i?(p=(0,X.jsxs)(h,{to:u,title:i,className:`inline-flex items-center gap-1.5 rounded-lg px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,children:[d,f]}),t[5]=u,t[6]=f,t[7]=i,t[8]=p):p=t[8];let m;t[9]!==s.canSaveAsVersion||t[10]!==s.versionId||t[11]!==c||t[12]!==a||t[13]!==i||t[14]!==r?(m=!a&&s.canSaveAsVersion&&s.versionId&&i?(0,X.jsx)(yh,{sourceVersionId:s.versionId,title:i,zh:r,onSaved:e=>{c({...e,canSaveAsVersion:!1},{revalidate:!1});let t=new URLSearchParams({item:e.id,version:e.versionId});Ua(`success`,r?`已保存为新版本`:`Saved as new version`,void 0,{href:`/space?${t}`})}}):null,t[9]=s.canSaveAsVersion,t[10]=s.versionId,t[11]=c,t[12]=a,t[13]=i,t[14]=r,t[15]=m):m=t[15];let g;return t[16]!==p||t[17]!==m?(g=(0,X.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-1`,children:[p,m]}),t[16]=p,t[17]=m,t[18]=g):g=t[18],g}function Sh(e){let t=(0,Z.c)(7),{file:n,zh:r,readonly:i}=e,a;t[0]===n.uri?a=t[1]:(a=n.uri?.startsWith(`media://outbound/`)?n.uri.slice(17):null,t[0]=n.uri,t[1]=a);let o=a,s=o?`/api/spaces/artifacts/${o}`:null,c;return t[2]!==n.title||t[3]!==i||t[4]!==s||t[5]!==r?(c=(0,X.jsx)(xh,{path:s,title:n.title,zh:r,readonly:i}),t[2]=n.title,t[3]=i,t[4]=s,t[5]=r,t[6]=c):c=t[6],c}function Ch(e){let t=(0,Z.c)(4),{deliveryId:n,title:r,zh:i}=e,a=`/api/spaces/deliveries/${encodeURIComponent(n)}`,o;return t[0]!==a||t[1]!==r||t[2]!==i?(o=(0,X.jsx)(xh,{path:a,title:r,zh:i}),t[0]=a,t[1]=r,t[2]=i,t[3]=o):o=t[3],o}function wh(e){let t=(0,Z.c)(4),{mediaId:n,title:r,zh:i}=e,a=`/api/spaces/artifacts/${encodeURIComponent(n)}`,o;return t[0]!==a||t[1]!==r||t[2]!==i?(o=(0,X.jsx)(xh,{path:a,title:r,zh:i}),t[0]=a,t[1]=r,t[2]=i,t[3]=o):o=t[3],o}function Th({provenance:e}){let t=y(e=>e.language),n=t===`zh`,r=C(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,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(0),g=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(``),b(_(`/api/personal-agent/outreach/${e.outreachId}/provenance`)).then(e=>{if(!e.ok)throw Error(e.error??r.load);t&&s(lr.parse(e.payload))}).catch(e=>{t&&l(String(e))}),()=>{t=!1}},[i,e.outreachId,m,r.load]);async function v(t,n={}){d(!0),l(``);try{let i=await b(_(`/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);p(!1),h(e=>e+1)}catch(e){l(String(e))}finally{d(!1)}}async function x(){let e=o?.strategy?.versions[0];if(!(!o||!e||u)){d(!0),l(``);try{let t=await b(_(`/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);p(!1),h(e=>e+1)}catch(e){l(String(e))}finally{d(!1)}}}let S=o&&[`completed`,`expired`].includes(o.thread.status);return(0,X.jsxs)(j,{open:i,onOpenChange:e=>{a(e),p(!1)},children:[(0,X.jsx)(T,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:`${bs} mt-2`,"aria-label":n?`查看主动联系的缘由`:`Why this message`,children:(0,X.jsx)(xs,{icon:(0,X.jsx)(Gt,{strokeWidth:1.5}),title:g[e.reasonKind],trailing:(0,X.jsx)(ie,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0})})})}),(0,X.jsxs)(O,{children:[(0,X.jsx)(w,{className:`fixed inset-0 z-50 bg-black/20`}),(0,X.jsxs)(k,{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,X.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge px-5 py-4`,children:[(0,X.jsx)(A,{className:`text-sm font-medium text-fg`,children:n?`为什么联系你`:`Why I reached out`}),(0,X.jsx)(D,{className:`rounded p-1 text-fg-muted hover:text-fg`,"aria-label":n?`关闭`:`Close`,children:(0,X.jsx)(an,{className:`size-4`})})]}),(0,X.jsx)(E,{className:`sr-only`,children:n?`消息的依据、时机与后续跟进`:`Sources, timing, and follow-up for this message`}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4 text-sm`,children:[!o&&!c&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(sn,{className:`h-5 w-3/4`}),(0,X.jsx)(sn,{className:`h-20 w-full`}),(0,X.jsx)(sn,{className:`h-12 w-full`})]}),o&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`mb-1 font-medium text-fg`,children:n?`为什么关注`:`Why this topic`}),(0,X.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,X.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,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`mb-1 font-medium text-fg`,children:n?`为什么现在联系`:`Why now`}),(0,X.jsx)(`p`,{className:`text-fg-muted`,children:o.whyNow})]}),o.sources.map(e=>(0,X.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,X.jsx)(`span`,{className:`line-clamp-2 text-xs`,children:e.excerpt}),(0,X.jsxs)(`span`,{className:`mt-1 block text-xs text-accent`,children:[n?`查看相关对话`:`View conversation`,` ↗`]})]},e.entryId)),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`mb-1 font-medium text-fg`,children:n?`后续`:`Next`}),(0,X.jsx)(`p`,{className:`text-fg-muted`,children:S?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,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,disabled:u,className:`rounded border border-edge px-3 py-2`,onClick:()=>void v(`defer`,{until:Date.now()+7*864e5}),children:n?`下周再跟进`:`Next week`}),(0,X.jsx)(`button`,{type:`button`,disabled:u,className:`rounded border border-edge px-3 py-2`,onClick:()=>void v(`adjust`,{preparation:`thorough`}),children:n?`以后先准备完整`:`Prepare more thoroughly`}),(0,X.jsx)(`button`,{type:`button`,disabled:u,className:`rounded border border-edge px-3 py-2`,onClick:()=>void v(`adjust`,{preparation:`brief`}),children:n?`以后简短一点`:`Keep it brief`})]}),o.strategy&&(0,X.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[(0,X.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,X.jsxs)(`details`,{className:`mt-2`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer`,children:n?`查看调整记录`:`View adjustments`}),(0,X.jsx)(`ul`,{className:`mt-2 space-y-1`,children:o.strategy.versions.map(e=>(0,X.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,X.jsx)(`p`,{role:`alert`,className:`text-danger`,children:c})]}),(0,X.jsxs)(`div`,{className:`flex gap-3 border-t border-edge px-5 py-3 text-xs`,children:[(0,X.jsx)(`button`,{type:`button`,disabled:!o||u||!!S,onClick:()=>p(e=>!e),className:`text-fg-muted hover:text-fg disabled:opacity-50`,children:n?`调整跟进`:`Adjust follow-up`}),(0,X.jsx)(`button`,{type:`button`,disabled:!o||u||!!S,onClick:()=>void v(`stop`),className:`text-fg-muted hover:text-fg disabled:opacity-50`,children:n?`停止关注`:`Stop following`}),o?.strategy?.versions.length?(0,X.jsx)(`button`,{type:`button`,disabled:u||!o.sourcesAvailable,onClick:()=>void x(),className:`ml-auto text-fg-muted hover:text-fg disabled:opacity-50`,children:n?`撤销最近调整`:`Undo latest`}):null]})]})]})]})}function Eh(e,t){let n=t?.split(`;`)[0]?.trim();return!n?.startsWith(`image/`)||e.type===n?e:new Blob([e],{type:n})}function Dh(e,t){let n=(0,Z.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?ji(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=Pi(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 Jt({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(Eh(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 Oh(e){let t=(0,Z.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,h=y(kh),g;t[0]===h?g=t[1]:(g=C(h),t[0]=h,t[1]=g);let _=g,v=(0,Q.useId)(),b;t[2]!==n.mimeType||t[3]!==n.type?(b=n.mimeType?.startsWith(`image/`)||n.type===`image`,t[2]=n.mimeType,t[3]=n.type,t[4]=b):b=t[4];let x=b,S;t[5]!==r||t[6]!==i?(S={authToken:r,conversationId:i},t[5]=r,t[6]=i,t[7]=S):S=t[7];let w=Dh(n,S),T;t[8]===n?T=t[9]:(T=!!n.uri&&!ji(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} · ${Ni(n.size)}`:F,t[16]=n.size,t[17]=F,t[18]=I):I=t[18];let L=I,R=O?`${M} — ${_.chat.attachmentPreviewMissingAuth}`:M,z=_.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 ee;t[22]!==n||t[23]!==M||t[24]!==H||t[25]!==w||t[26]!==B||t[27]!==V||t[28]!==j||t[29]!==x||t[30]!==N||t[31]!==k||t[32]!==_.chat.attachmentPreviewLoadError||t[33]!==_.chat.pastedText||t[34]!==R||t[35]!==v||t[36]!==z||t[37]!==d||t[38]!==u||t[39]!==L||t[40]!==O||t[41]!==P?(ee=x?(0,X.jsxs)(`div`,{className:V,children:[(0,X.jsxs)(`div`,{className:`relative size-full min-h-0`,children:[(0,X.jsxs)(`button`,{type:`button`,className:Y(H,Ma.transition,Ma.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?v:void 0,children:[w.src?(0,X.jsx)(`img`,{src:w.src,alt:M,className:B,decoding:`async`}):w.error||O?(0,X.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:_.chat.attachmentPreviewLoadError,children:[(0,X.jsx)(Ie,{className:`size-5`,strokeWidth:1.5,"aria-hidden":!0}),(0,X.jsx)(`span`,{children:O?z:_.chat.attachmentPreviewLoadError})]}):(0,X.jsx)(`span`,{className:`block size-full animate-pulse bg-surface-active`,"aria-hidden":!0}),u?(0,X.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,X.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,X.jsx)(`p`,{id:v,className:`mt-1 line-clamp-2 text-[10px] leading-snug text-amber-600 dark:text-amber-500`,children:z}):null]}):(0,X.jsx)(`div`,{className:Y(`max-w-[14rem]`,P&&`inline-flex max-w-full`),children:(0,X.jsxs)(`button`,{type:`button`,onClick:()=>d(n),title:R,"aria-label":R,"aria-describedby":O?v: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`,Ma.transition,Ma.press,Ma.focusRingPanel),children:[N?(0,X.jsx)(we,{className:Y(`shrink-0 text-accent-fg`,P?`size-3.5`:`size-8`),"aria-hidden":!0}):j?(0,X.jsx)(q,{className:`size-8 shrink-0 text-fg-subtle`,"aria-hidden":!0}):(0,X.jsx)(Ee,{className:`size-8 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:Y(`truncate text-fg`,P?`inline`:`block`),children:N?_.chat.pastedText:M}),P?(0,X.jsxs)(`span`,{className:`ml-1 whitespace-nowrap text-fg-subtle`,children:[`· `,L]}):null,O?(0,X.jsx)(`span`,{id:v,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]=x,t[30]=N,t[31]=k,t[32]=_.chat.attachmentPreviewLoadError,t[33]=_.chat.pastedText,t[34]=R,t[35]=v,t[36]=z,t[37]=d,t[38]=u,t[39]=L,t[40]=O,t[41]=P,t[42]=ee):ee=t[42];let te;t[43]!==_.chat.attachmentPreviewRemove||t[44]!==o||t[45]!==f?(te=f?(0,X.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`,Ma.transition,Ma.press,Ma.focusRingPanel),onClick:e=>{e.stopPropagation(),o?.()},title:_.chat.attachmentPreviewRemove,"aria-label":_.chat.attachmentPreviewRemove,children:(0,X.jsx)(an,{className:`size-3`})}):null,t[43]=_.chat.attachmentPreviewRemove,t[44]=o,t[45]=f,t[46]=te):te=t[46];let ne;return t[47]!==W||t[48]!==ee||t[49]!==te?(ne=(0,X.jsxs)(`div`,{className:W,children:[ee,te]}),t[47]=W,t[48]=ee,t[49]=te,t[50]=ne):ne=t[50],ne}function kh(e){return e.language}function Ah(e){let t=(0,Z.c)(11),{layout:n,conversationId:r,workspaceConversationId:i,projectId:a}=e,[o,s]=(0,Q.useState)(null),c=Ci(jh),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 jh(e){return e.setPath}function Mh(e){let t=Math.max(0,Math.floor(e));return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}function Nh(e){return typeof e==`number`&&Number.isFinite(e)&&e>0}function Ph(e){let t=(0,Z.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,X.jsx)(Fh,{...e},i),t[6]=e,t[7]=i,t[8]=a):a=t[8],a}function Fh({att:e,align:t=`start`,embedded:n=!1,conversationId:r}){let i=y(e=>e.language),a=i===`zh`,o=C(i).chat,s=(0,Q.useId)(),c=(0,Q.useRef)(null),[l,u]=(0,Q.useState)(),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(0),[h,v]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(!1),[S,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(1),[D,O]=(0,Q.useState)(0),k=D||(Nh(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 f(!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 g(_(Mi(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||f(!0)}})(),()=>{t.abort(),n&&URL.revokeObjectURL(n)}},[M,e.mimeType,e.uri,e.taskId,r,p]),(0,Q.useEffect)(()=>{let e=c.current,t=()=>e?.pause();return window.addEventListener(`xopc-voice-recording-start`,t),()=>{t(),e&&Hi(e),window.removeEventListener(`xopc-voice-recording-start`,t)}},[]);let N=()=>{let e=c.current;if(d){m(e=>e+1);return}!e||!l||(h?e.pause():(Ui(e),e.play().catch(t=>{e.paused&&Hi(e),t instanceof DOMException&&t.name===`AbortError`||f(!0)})))},P=()=>{let e=c.current?.duration;Nh(e)&&O(e)},F=a?`播放选项`:`Playback options`;return(0,X.jsx)(`div`,{className:Y(`flex min-w-0`,t===`end`&&`justify-end`,t===`center`&&`justify-center`),children:(0,X.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,X.jsx)(`span`,{className:`sr-only`,role:`status`,children:o.voiceLoading}):null,(0,X.jsxs)(`div`,{className:`flex min-h-14 items-center gap-2`,children:[(0,X.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`:h?o.voicePause:o.voicePlay,children:d?(0,X.jsx)(Lt,{className:`size-5`,"aria-hidden":!0}):h?(0,X.jsx)(At,{className:`size-5`,"aria-hidden":!0}):(0,X.jsx)(Pt,{className:`size-5`,"aria-hidden":!0})}),(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,"aria-hidden":!0,children:!l&&!d?(0,X.jsx)(sn,{className:`h-1 w-full`}):(0,X.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-surface-active`,children:(0,X.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${k>0?Math.min(100,A/k*100):0}%`}})})}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>x(!b),"aria-label":F,"aria-expanded":b,"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?Mh(A>0?A:k):`—`,(0,X.jsx)(re,{className:Y(`size-3`,b&&`rotate-180`),"aria-hidden":!0})]})]}),d?(0,X.jsx)(`p`,{role:`alert`,className:`px-2 pb-2 text-xs text-fg-muted`,children:a?`音频无法播放,请重试`:`Audio unavailable. Try again.`}):null,b?(0,X.jsxs)(`div`,{id:`${s}-options`,className:`space-y-2 px-2 pb-3`,children:[(0,X.jsxs)(`label`,{className:`block text-xs text-fg-muted`,children:[a?`播放进度`:`Playback position`,(0,X.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,X.jsx)(pe,{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,X.jsxs)(`div`,{className:`px-2 pb-1`,children:[(0,X.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(!S),"aria-expanded":S,"aria-controls":`${s}-text`,children:S?a?`收起文字`:`Hide transcript`:a?`查看文字`:`Show transcript`}),S?(0,X.jsx)(`p`,{id:`${s}-text`,className:`whitespace-pre-wrap break-words pb-2 text-sm text-fg-muted`,children:e.extractedText}):null]}):null,(0,X.jsx)(`audio`,{ref:c,src:l,preload:`metadata`,className:`hidden`,onLoadedMetadata:P,onDurationChange:P,onTimeUpdate:e=>j(e.currentTarget.currentTime),onError:()=>{l&&(v(!1),f(!0))},onPlay:e=>{e.currentTarget.paused||(Ui(e.currentTarget),e.currentTarget.playbackRate=T,v(!0))},onPause:()=>v(!1),onEnded:()=>{v(!1),j(0)}})]})})}function Ih(e){return e.type===`voice`||e.type===`audio`||e.mimeType?.startsWith(`audio/`)===!0}var Lh=9;function Rh(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<=Lh?{container:`grid grid-cols-3 ${n} ${r}`,tileSize:`grid-cell`}:{container:`grid grid-cols-3 ${n} ${r}`,tileSize:`grid-cell`,overflowCount:e-(Lh-1)}}function zh(e){let t=(0,Z.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=Ah(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(Vh);let e=n.filter(Ih),a=n.filter(Bh);m=`flex flex-col gap-2`,h=p.length>0?(()=>{let e=Rh(p.length,l===`user`),t=e.overflowCount==null?p:p.slice(0,Lh-1);return(0,X.jsxs)(`div`,{className:Y(`w-full min-w-0`,e.container),children:[t.map((t,n)=>(0,X.jsx)(Oh,{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,X.jsx)(Oh,{attachment:p[Lh-1],authToken:r,conversationId:i,imageSize:`grid-cell`,compact:l===`user`,overflowLabel:`+${e.overflowCount}`,onOpen:f.openAttachment},p[Lh-1]?.id??`overflow-${Lh-1}`)]})})():null,g=e.length>0?(0,X.jsx)(`div`,{className:Y(`flex flex-col gap-2`,l===`user`&&(u?`items-center`:`items-end`)),children:e.map((e,t)=>(0,X.jsx)(Ph,{att:e,conversationId:i,align:l===`user`?u?`center`:`end`:`start`,embedded:l===`user`},e.id??`${e.name}-${t}`))}):null,_=a.length>0?(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:a.map((e,t)=>(0,X.jsx)(Oh,{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,X.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,X.jsx)(qo,{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,X.jsxs)(X.Fragment,{children:[v,y]}),t[29]=v,t[30]=y,t[31]=b):b=t[31],b}function Bh(e){return e.type!==`image`&&!e.mimeType?.startsWith(`image/`)&&!Ih(e)}function Vh(e){return e.type===`image`||e.mimeType?.startsWith(`image/`)}function Hh(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 Uh(e){return e?.length?e.flatMap((e,t)=>{let n=Hh(e,t);return n?[n]:[]}):[]}function Wh(e){let t=[],n=new Set(ur(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(`
14
14
 
15
- `).trim()}function qh(e){if(!e.trim())return``;let t=a.parse(e,{gfm:!0,breaks:!1});return new DOMParser().parseFromString(`<div>${t}</div>`,`text/html`).body.textContent?.trim()??``}function Jh(e){let t=[],n=new Set(ur(e,{includePending:!0}));for(let r of e)if(r.type===`text`){if(!n.has(r))continue;t.push(qh(r.text))}else r.type===`image`&&t.push(`[image]`);return t.join(`
15
+ `).trim()}function Gh(e){if(!e.trim())return``;let t=a.parse(e,{gfm:!0,breaks:!1});return new DOMParser().parseFromString(`<div>${t}</div>`,`text/html`).body.textContent?.trim()??``}function Kh(e){let t=[],n=new Set(ur(e,{includePending:!0}));for(let r of e)if(r.type===`text`){if(!n.has(r))continue;t.push(Gh(r.text))}else r.type===`image`&&t.push(`[image]`);return t.join(`
16
16
 
17
- `).trim()}var Yh=new WeakMap,Xh=new WeakMap,Zh=new WeakMap,Qh=new WeakMap;function $h(e,t){if(!e)return;let n=e=>{let t=Zh.get(e);return t||(t=new Map(e.content.flatMap(e=>{let t=Fr(e);return t?[[t,e]]:[]})),Zh.set(e,t)),t},r=e.streamingMsg&&n(e.streamingMsg).get(t);if(r)return r;let i=Qh.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);Qh.set(e.messages,i)}return i.get(t)}function eg(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`&&Fr(e)===Fr(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 tg(){let e;return t=>(eg(e??null,t??null)||(e=t),e)}function ng(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=Xh.get(n);if(r?.previous===t)return r.row;let i=gr([t,n]).at(-1);return Xh.set(n,{previous:t,row:i}),i}let r=Yh.get(e.messages);return r||(r=new Map(e.messages.filter(e=>e.renderKey).map(e=>[e.renderKey,e])),Yh.set(e.messages,r)),r.get(t)}function rg(){let e;return t=>{if(!t||!e)return e=t,t;let n=eg(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 ig(e){let t=(0,Z.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=rg(),t[0]=n):n=t[0];let r=n,i;t[1]===e?i=t[2]:(i=()=>r(e?Sr.getState().sessions[e]:void 0),t[1]=e,t[2]=i);let a=i;return(0,Q.useSyncExternalStore)(Sr.subscribe,a,a)}function ag(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=Sr.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 og(e,t){let n=(0,Z.c)(4),r;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=tg(),n[0]=r):r=n[0];let i=r,a;return n[1]!==e||n[2]!==t?(a=()=>i(e&&t?ng(Sr.getState().sessions[e],t):void 0),n[1]=e,n[2]=t,n[3]=a):a=n[3],ag(e,a)}function sg(e,t){let n=(0,Z.c)(3),r;return n[0]!==e||n[1]!==t?(r=()=>e&&t?$h(Sr.getState().sessions[e],t):void 0,n[0]=e,n[1]=t,n[2]=r):r=n[2],ag(e,r)}function cg(e,t){let n=(0,Z.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=Sr.getState().sessions[e],n=o.map(e=>$h(t,e));if(!n.some(ug))return n.map(lg).join(``)},n[4]=e,n[5]=o,n[6]=s):s=n[6],ag(e,s)}function lg(e){return e?.type===`text`?e.text:``}function ug(e){return e?.type!==`text`}function dg(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)})})(ao(),e=>({kind:`skill`,name:e[1]??``}));for(let n of us(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 fg(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 pg(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 mg(e){let t=(0,Z.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,X.jsx)(Ae,{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,X.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,X.jsx)(yt,{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,X.jsx)(N,{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,X.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,X.jsx)(dc,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=r):r=t[5],r}var hg=(0,Q.memo)(function(e){let t=(0,Z.c)(24),{text:n,conversationId:r,document:i,contextRefs:a}=e,o=y(gg),s;t[0]===o?s=t[1]:(s=C(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=dg(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(_g)??[]);e=i.parts.flatMap(e=>e.type===`text`?dg(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=fg(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(vg),t[9]=u,t[10]=p);let m=th(void 0,r,p);if(!u.some(yg)){let e;return t[11]===n?e=t[12]:(e=(0,X.jsx)(`div`,{className:`markdown-content min-w-0`,children:(0,X.jsx)(ip,{content:n,compact:!0,breaks:!0})}),t[11]=n,t[12]=e),e}let h;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,X.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,X.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,X.jsxs)(`span`,{className:Y(`chat-context-ref-pill chat-context-ref-pill-message max-w-full shrink-0`,pg(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,X.jsx)(mg,{contextRef:n.ref}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:n.ref?.title??c})]},r):n.text?(0,X.jsx)(`div`,{className:`chat-user-message-segment markdown-content inline-block min-w-0 max-w-full align-baseline text-fg`,children:(0,X.jsx)(ip,{content:n.text,compact:!0,breaks:!0})},r):null},t[18]=u,t[19]=c,t[20]=m,t[21]=e):e=t[21],h=f.map(e),t[13]=u,t[14]=f,t[15]=c,t[16]=m,t[17]=h}else h=t[17];let g;return t[22]===h?g=t[23]:(g=(0,X.jsx)(`span`,{className:`inline-flex max-w-full flex-wrap items-baseline gap-x-0 gap-y-1 [text-align:inherit]`,children:h}),t[22]=h,t[23]=g),g});function gg(e){return e.language}function _g(e){return e.refId?[[e.refId,e]]:[]}function vg(e){return e.kind===`skill`}function yg(e){return e.kind!==`text`}function bg(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:e.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:e.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 xg(e){let t=(0,Z.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,X.jsx)(He,{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,X.jsx)(_e,{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,X.jsx)(_c,{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,X.jsx)(G,{className:`size-4`,strokeWidth:1.75}),t[3]=e):e=t[3],e}}}function Sg(e){let t=(0,Z.c)(34),{payload:n,onRetry:r}=e,i=p(),a=C(y(wg)).chat,[o,s]=(0,Q.useState)(``),c=bg(n,a),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=[`provider_connection_error`,`timeout`,`rate_limit`,`unknown`,`send_failed`],t[0]=l):l=t[0];let u=l.includes(n.code),d=n.code===`model_quota_exhausted`,f=Cg,m;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(m=Y(`flex flex-col gap-2 rounded-xl border p-3`,`border-edge bg-surface-panel`),t[1]=m):m=t[1];let h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=Y(`flex size-8 shrink-0 items-center justify-center rounded-lg`,`bg-surface-inset text-warning`),t[2]=h):h=t[2];let g;t[3]===n.code?g=t[4]:(g=(0,X.jsx)(`span`,{className:h,"aria-hidden":!0,children:(0,X.jsx)(xg,{code:n.code})}),t[3]=n.code,t[4]=g);let _;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(_=Y(`text-sm font-semibold`,`text-fg`),t[5]=_):_=t[5];let v;t[6]===c.title?v=t[7]:(v=(0,X.jsx)(`h3`,{className:_,children:c.title}),t[6]=c.title,t[7]=v);let b;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(b=Y(`mt-1 text-xs leading-relaxed`,`text-fg-muted`),t[8]=b):b=t[8];let x;t[9]===c.body?x=t[10]:(x=(0,X.jsx)(`p`,{className:b,children:c.body}),t[9]=c.body,t[10]=x);let S;t[11]!==v||t[12]!==x?(S=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[v,x]}),t[11]=v,t[12]=x,t[13]=S):S=t[13];let w;t[14]!==g||t[15]!==S?(w=(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[g,S]}),t[14]=g,t[15]=S,t[16]=w):w=t[16];let T;t[17]!==c.cta||t[18]!==c.deepLink||t[19]!==a||t[20]!==i||t[21]!==r||t[22]!==d||t[23]!==u?(T=u?(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r?(0,X.jsx)(`button`,{type:`button`,className:Y(`min-h-9 rounded-md px-3 text-xs font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`bg-accent text-on-accent hover:bg-accent-hover`),onClick:r,children:a.runRecovery.retry}):null,(0,X.jsx)(`button`,{type:`button`,className:`min-h-9 rounded-md px-3 text-xs text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>i(`/settings/capabilities/models`),children:a.runRecovery.models})]}):d?(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,X.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`,`bg-accent text-on-accent hover:bg-accent-hover`),onClick:()=>f(`/models/credits/purchase`),children:a.xopcQuotaPurchaseCta}),(0,X.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:()=>f(`/models/credits/request`),children:a.xopcQuotaRequestCta}),(0,X.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:()=>i(`/settings/capabilities/models?add=1`),children:a.xopcQuotaOwnProviderCta})]}):c.cta&&c.deepLink?(0,X.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,X.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`,`bg-accent text-on-accent hover:bg-accent-hover`),onClick:()=>i(c.deepLink),children:c.cta})}):null,t[17]=c.cta,t[18]=c.deepLink,t[19]=a,t[20]=i,t[21]=r,t[22]=d,t[23]=u,t[24]=T):T=t[24];let E;t[25]!==o||t[26]!==a||t[27]!==n.message||t[28]!==s?(E=n.message?(0,X.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,X.jsx)(`summary`,{className:Y(`cursor-pointer select-none underline-offset-2`,`text-fg-muted hover:text-fg`),children:a.agentRunErrorDetailToggle}),(0,X.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]`,`bg-surface-inset text-fg-muted`),children:zi(n.message)}),(0,X.jsx)(`button`,{type:`button`,className:`mt-1 min-h-9 rounded-md px-2 text-xs text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:async()=>{try{await navigator.clipboard.writeText(zi(n.message)),s(a.runRecovery.copied)}catch{s(a.runRecovery.copyFailed)}},children:a.runRecovery.copyDetails}),(0,X.jsx)(`span`,{role:`status`,"aria-live":`polite`,className:`ml-2 text-fg-muted`,children:o})]}):null,t[25]=o,t[26]=a,t[27]=n.message,t[28]=s,t[29]=E):E=t[29];let D;return t[30]!==w||t[31]!==T||t[32]!==E?(D=(0,X.jsxs)(`section`,{role:`alert`,"aria-live":`polite`,className:m,children:[w,T,E]}),t[30]=w,t[31]=T,t[32]=E,t[33]=D):D=t[33],D}function Cg(e){return window.open(`https://console.xopc.ai${e}`,`_blank`,`noopener,noreferrer`)}function wg(e){return e.language}function Tg(e){let t=(0,Z.c)(5),{errorText:n,onRetry:r}=e,i;t[0]===n?i=t[1]:(i=Vi(n),t[0]=n,t[1]=i);let a=i;if(!a)return null;let o;return t[2]!==r||t[3]!==a?(o=(0,X.jsx)(`div`,{className:`mb-4`,children:(0,X.jsx)(Sg,{payload:a,onRetry:r})}),t[2]=r,t[3]=a,t[4]=o):o=t[4],o}function Eg(e){let t=(0,Z.c)(4),{payload:n}=e,r;t[0]===n?r=t[1]:(r=JSON.stringify({...n,code:n.kind,message:n.message??``}),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,X.jsx)(Tg,{errorText:r}),t[2]=r,t[3]=i),i}var Dg=/^No API key found for (\S+)/i;function Og(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=Dg.exec(t);return n?{kind:`provider_setup_required`,provider:n[1].replace(/[.,]$/,``),deepLink:`/settings/capabilities/models`,message:t}:null}var kg=new WeakMap;function Ag(e){let t=kg.get(e),n=Fr(e);return t??(n?[n]:[])}function jg(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??``}`},kr(e,t[t.length-1]),kg.set(t[t.length-1],[...Ag(e),...Ag(n)]);continue}t.push(n)}return t}var Mg=/^\s*\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$/m,Ng=/^\s{0,3}(?:[-+*]|\d+[.)])\s+/m,Pg=/^\s{0,3}```/gm;function Fg(e){return(e.match(Pg)?.length??0)%2==1?`code`:Mg.test(e)?`table`:Ng.test(e)?`list`:e.length>=4096?`long_text`:`plain`}var Ig={plain:50,long_text:50,list:50,table:72,code:64};function Lg({tailKind:e,latestParseMs:t}){let n=Ig[e];return!Number.isFinite(t)||t<=16?n:Math.min(120,Math.max(n,Math.ceil(t*2)))}var Rg=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=Af(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 zg(e,t,n,r=!1,i,a=!1){let[o,s]=(0,Q.useState)(()=>e),[c]=(0,Q.useState)(()=>new Rg(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,pt(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){st(n,e.length),o();return}if(c.observe(e.length,performance.now()),p.current=Lg({tailKind:Fg(e.slice(-8192)),latestParseMs:ot(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,st(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 Bg(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 Vg(e){let t=(0,Z.c)(33),{review:n}=e,r=y(Ug),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=C(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,X.jsx)(qe,{className:`size-4 animate-spin text-accent`,"aria-hidden":!0}):null,t[16]=i,t[17]=m),c=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[m,(0,X.jsx)(`div`,{className:`text-sm font-semibold text-fg-primary`,children:i?o.running:o.finished}),i?(0,X.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,X.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,X.jsx)(`div`,{className:`mt-1 text-xs text-fg-tertiary`,children:o.basedOn.replace(`{{target}}`,n.target)}),u=i&&!n.analysisMarkdown?(0,X.jsx)(`div`,{className:`mt-3 text-sm text-fg-secondary`,children:e?o.preparing:o.checking}):null,d=n.analysisMarkdown?(0,X.jsxs)(`div`,{className:`mt-3 rounded-md border border-edge-subtle bg-surface px-2.5 py-2`,children:[(0,X.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg-secondary`,children:o.assistant}),(0,X.jsx)(ip,{content:n.analysisMarkdown,compact:!0,streaming:i})]}):null,f=n.status===`error`&&n.errorMessage?(0,X.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,X.jsxs)(X.Fragment,{children:[n.summary?(0,X.jsx)(`div`,{className:`mt-3 text-sm text-fg-secondary`,children:n.summary}):null,(0,X.jsx)(`div`,{className:`mt-3 space-y-2`,children:n.findings.length===0?(0,X.jsx)(`div`,{className:`text-sm text-fg-secondary`,children:a?o.noModelFindings:o.noFindings}):n.findings.map(Hg)}),n.overallExplanation?(0,X.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,X.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 Hg(e,t){let n=Bg(e);return(0,X.jsxs)(`div`,{className:`rounded-md border border-edge bg-surface p-2`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.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,X.jsx)(`span`,{className:`min-w-0 text-sm font-medium text-fg-primary`,children:e.title})]}),n?(0,X.jsx)(`div`,{className:`mt-1 break-all text-xs text-fg-tertiary`,children:n}):null,e.body?(0,X.jsx)(`div`,{className:`mt-1 text-sm text-fg-secondary`,children:e.body}):null]},`${e.title}-${t}`)}function Ug(e){return e.language}function Wg({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=cg(n,r)??t,p=`assistant-markdown-${(0,Q.useId)()}`,m=zg(f,s,p,c,l,d);(0,Q.useEffect)(()=>{if(s)return ct(p),()=>ht(p)},[p,s]);let h=Ti(e=>e.setPath),g=C(y(e=>e.language)).chat.fileReference,_=(0,Q.useCallback)(async t=>{try{return await yo(t.path,{projectId:o?.trim()||void 0,conversationId:a?.trim()||void 0,taskRunId:e})}catch(n){if(e||o||!a)throw n;return yo(t.path)}},[o,a,e]),v=(0,Q.useCallback)(function t(n){let r=Xi.getState(),i=r.scope,s={status:`loading`,target:n},c={projectId:o?.trim()||void 0,conversationId:a?.trim()||void 0,taskRunId:e},l=r.openFile({path:n.path,projectId:c.projectId,conversationId:c.conversationId,reference:s},i),u={id:l,scope:i,reference:s},d=()=>Xi.getState().panes[i]?.tabs.some(e=>e.id===l&&e.kind===`file`&&e.reference===s),f=()=>t(n);(async()=>{let t=await Co(n.path,c);if(!d())return;let p=t?.absolutePath||t?.workspaceRelativePath;if(p&&t?.capabilities.includes(`preview`)){h(p,n.line,o,a,void 0,{...u,resolvedFile:t.fileId?{id:t.fileId,mtimeMs:t.mtimeMs}:void 0});return}if(n.kind===`workspace-relative`&&!e&&!o&&a){let e=await Co(n.path),t=e?.absolutePath||e?.workspaceRelativePath;if(t&&e?.capabilities.includes(`preview`)){h(t,n.line,void 0,void 0,void 0,{...u,defaultWorkspace:!0,resolvedFile:e.fileId?{id:e.fileId,mtimeMs:e.mtimeMs}:void 0});return}}r.finishFileReference(l,i,s,{reference:t?{status:`ready`,target:n,ref:t,retry:t.exists?void 0:f}:{status:`error`,target:n,message:g.resolveFailedDescription,retry:f}})})().catch(e=>{r.finishFileReference(l,i,s,{reference:{status:`error`,target:n,message:e instanceof Error?e.message:String(e),retry:f}})})},[g.resolveFailedDescription,o,a,e,h]),b=Og(f);return(0,X.jsx)(X.Fragment,{children:b?(0,X.jsx)(Eg,{payload:b}):(0,X.jsx)(ip,{content:m,streaming:s||m!==f,compact:i,onWorkspaceFileOpen:v,onWorkspaceImageLoad:_,renderMermaid:!0,mermaidActions:!0,streamingMetricsKey:p,responseRunId:u})})}function Gg(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){if(e.type===`text`)return n?(0,X.jsx)(`div`,{className:`min-w-0`,children:(0,X.jsx)(hg,{text:Yn(e.text??``),conversationId:s,document:f,contextRefs:p})},t):(0,X.jsx)(`div`,{className:`assistant-markdown-content markdown-content min-w-0`,children:(0,X.jsx)(Wg,{content:e.text,sourcePartIds:Ag(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,X.jsx)(uf,{source:e.source.data,alt:``,title:i,onOpen:a?()=>a(e,n):void 0},t)}return e.type===`review`?(0,X.jsx)(Vg,{review:e},t):null}function Kg(e){let t=(0,Z.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:jg(r),d;t[19]===v?d=t[20]:(d=new Set(v?[...v].map(Fr).filter(Boolean):[]),t[19]=v,t[20]=d);let g=d,y;t[21]!==v||t[22]!==g?(y=e=>v?.has(e)||!!(Fr(e)&&g.has(Fr(e))),t[21]=v,t[22]=g,t[23]=y):y=t[23];let w=y,T=e.findLastIndex(qg),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,X.jsx)(`div`,{"data-assistant-activity":!0,"data-assistant-process-item":v?!0:void 0,hidden:S,children:_(r,A===e.length)},Fr(t)??`activity-${n}`))}else{let e=t.type===`image`?j++:0,r=Gg(t,Fr(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,X.jsx)(`div`,{"data-assistant-process-item":w(t)||void 0,hidden:S&&w(t),children:r},Fr(t)??`block-${A}`):r),A++}}C=(0,X.jsx)(X.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 qg(e){return e.type===`text`&&e.presentation===`pending`}var Jg=[`readFile`,`editFile`,`writeFile`,`runCommand`,`memorySearch`,`codeSearch`,`webSearch`,`search`,`fetchUrl`,`openUrl`,`listDir`,`other`];function Yg(e,t){return Va(e,t)}function Xg(e){let t=new Map;for(let n of e){if(n.type!==`tool_use`)continue;let e=Yg(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 Zg(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 Qg(e,t,n){let r=Xg(e),i=[];for(let e of Jg){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)||Zg(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 $g(e){return e.filter(e=>e.type!==`thinking`||!!e.text?.trim()||!!e.streaming)}function e_(e,t,n){return Qg(e,t,n)}function t_(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function n_(e){if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}}function r_(e){let t=t_(n_(e));if(!t)return[];let n=t_(t.details)?.results??t.results;if(Array.isArray(n))return n.map(t_).filter(e=>e!==null);let r=Array.isArray(t.content)?t.content:[];for(let e of r){let t=t_(e)?.text,n=t_(n_(t));if(Array.isArray(n?.results))return n.results.map(t_).filter(e=>e!==null)}return[]}function i_(e,t){return e.replace(/\{\{count\}\}/g,String(t))}function a_(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=r_(e.result),r=e.activity?.count??n.length;return{title:r===0?t.empty:i_(r===1?t.found_one:t.found_other,r),purpose:t.purpose}}function o_(e,t){if(e.status===`running`)return{title:t?`正在更新记忆`:`Updating memory`,purpose:``};let n=t_(n_(e.result)),r=t_(n?.details)??n;if(!r?.status&&Array.isArray(n?.content))for(let e of n.content){let t=t_(n_(t_(e)?.text));if(t?.status){r=t;break}}let i=typeof r?.receiptId==`string`&&typeof r.committedAt==`number`;if(e.status===`error`||!i||![`saved`,`pending`,`forgotten`].includes(String(r?.status)))return{title:t?`记忆修改未确认保存`:`Memory change not confirmed`,purpose:t?`未收到成功回执,请重试或查看记忆。`:`No successful receipt was received. Retry or check your memory.`};let a=t_(r?.scope)?.type,o=t?{global:`所有协作`,agent:`当前助手`,workspace:`当前工作区`,project:`当前项目`,session:`当前会话`}:{global:`All work`,agent:`This assistant`,workspace:`This workspace`,project:`This project`,session:`This conversation`};if(r?.status===`forgotten`)return{title:t?`已忘记这条记忆`:`Memory forgotten`,purpose:t?`后续不再自动使用;原始对话和文件保留,已运行的上下文不受影响。`:`Future automatic recall is stopped. Original sources and already running contexts are retained.`};if(r?.available===!1)return{title:t?`这条记忆已不再可用`:`This memory is no longer available`,purpose:``};let s=r?.status===`pending`||r?.usable!==!0;return{title:s?t?`已保存,暂不使用`:`Saved, not yet in use`:r?.command===`correct`?t?`已纠正记忆`:`Memory corrected`:r?.command===`scope`?t?`已调整记忆范围`:`Memory scope updated`:t?`已记住`:`Memory saved`,purpose:`${o[String(a)]??``}${s?t?` · 请在记忆中查看确认状态。`:` · Check its review status in Memory.`:t?` · 从下一轮按需使用。`:` · Available when relevant from the next turn.`}`}}function s_(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 c_(e){if(e==null)return null;try{return typeof e==`string`?JSON.parse(e):e}catch{return null}}function l_(e){let t=c_(e),n=t?.path??t?.file_path??t?.filepath??t?.file??t?.qualified_name??t?.function_name;return typeof n==`string`?n:``}function u_(e){let t=c_(e),n=t?.url??t?.href??t?.uri??t?.website;return typeof n==`string`?n:``}function d_(e){let t=c_(e),n=t?.command??t?.cmd??t?.shell??t?.script;return typeof n==`string`?n:``}var f_=120;function p_(e){if(e==null)return``;let t=c_(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>f_?`${t.slice(0,f_)}…`:t}if(typeof e==`number`&&Number.isFinite(e))return String(e)}return``}function m_(e){return e.startsWith(`@@`)?`hunk`:e.startsWith(`+++`)||e.startsWith(`---`)||e.startsWith(`diff `)||e.startsWith(`index `)?`meta`:e.startsWith(`+`)?`add`:e.startsWith(`-`)?`del`:`context`}function h_(e){let t=e.details?.diff;if(typeof t!=`string`||t.length===0)return null;let n=t.split(`
18
- `),r=[],i=0,a=0;for(let e of n){let t=m_(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}}var g_=`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`,__=`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`,v_=`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`,y_=`cursor-pointer select-none text-xs text-fg-subtle underline-offset-2 hover:text-fg-muted group-open:text-fg-muted`;function b_(e){let t=(0,Z.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(g_,a),t[0]=a,t[1]=o);let s;return t[2]!==n||t[3]!==o?(s=(0,X.jsx)(`span`,{className:o,children:n}),t[2]=n,t[3]=o,t[4]=s):s=t[4],s}function x_(e){let t=(0,Z.c)(3),{children:n,title:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,X.jsx)(`code`,{className:__,title:r,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}var S_=(0,Q.memo)(function(e){let t=(0,Z.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 aa(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`,Pa.transition,Pa.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,X.jsx)(ne,{className:`size-3.5`,"aria-hidden":!0}):(0,X.jsx)(J,{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,X.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 C_(e){let t=(0,Z.c)(8),{summary:n,children:r,defaultOpen:i}=e,a=i!==void 0&&i,o;t[0]===n?o=t[1]:(o=(0,X.jsx)(`summary`,{className:y_,children:n}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,X.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,X.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 w_(e){let t=(0,Z.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,X.jsx)(`pre`,{className:v_,children:n}),t[0]=n,t[1]=r),r}function T_(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>{let r=t[n];return r==null?``:String(r)})}function E_(e){return e.details??{}}var D_=/\[(\d+)\/(\d+) lines\]\s*$/;function O_(e){let t=e.match(D_);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 k_(e){return e.replace(D_,``).trimEnd()}var A_=(0,Q.memo)(function(e){let t=(0,Z.c)(32),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=l_(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=Ba(n.result),t[2]=n.result,t[3]=o);let s=o.text,c;t[4]===s?c=t[5]:(c=O_(s),t[4]=s,t[5]=c);let l=c,u;t[6]===s?u=t[7]:(u=k_(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(`
17
+ `).trim()}var qh=new WeakMap,Jh=new WeakMap,Yh=new WeakMap,Xh=new WeakMap;function Zh(e,t){if(!e)return;let n=e=>{let t=Yh.get(e);return t||(t=new Map(e.content.flatMap(e=>{let t=Fr(e);return t?[[t,e]]:[]})),Yh.set(e,t)),t},r=e.streamingMsg&&n(e.streamingMsg).get(t);if(r)return r;let i=Xh.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);Xh.set(e.messages,i)}return i.get(t)}function Qh(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`&&Fr(e)===Fr(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 $h(){let e;return t=>(Qh(e??null,t??null)||(e=t),e)}function eg(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=Jh.get(n);if(r?.previous===t)return r.row;let i=gr([t,n]).at(-1);return Jh.set(n,{previous:t,row:i}),i}let r=qh.get(e.messages);return r||(r=new Map(e.messages.filter(e=>e.renderKey).map(e=>[e.renderKey,e])),qh.set(e.messages,r)),r.get(t)}function tg(){let e;return t=>{if(!t||!e)return e=t,t;let n=Qh(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 ng(e){let t=(0,Z.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=tg(),t[0]=n):n=t[0];let r=n,i;t[1]===e?i=t[2]:(i=()=>r(e?Sr.getState().sessions[e]:void 0),t[1]=e,t[2]=i);let a=i;return(0,Q.useSyncExternalStore)(Sr.subscribe,a,a)}function rg(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=Sr.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 ig(e,t){let n=(0,Z.c)(4),r;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=$h(),n[0]=r):r=n[0];let i=r,a;return n[1]!==e||n[2]!==t?(a=()=>i(e&&t?eg(Sr.getState().sessions[e],t):void 0),n[1]=e,n[2]=t,n[3]=a):a=n[3],rg(e,a)}function ag(e,t){let n=(0,Z.c)(3),r;return n[0]!==e||n[1]!==t?(r=()=>e&&t?Zh(Sr.getState().sessions[e],t):void 0,n[0]=e,n[1]=t,n[2]=r):r=n[2],rg(e,r)}function og(e,t){let n=(0,Z.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=Sr.getState().sessions[e],n=o.map(e=>Zh(t,e));if(!n.some(cg))return n.map(sg).join(``)},n[4]=e,n[5]=o,n[6]=s):s=n[6],rg(e,s)}function sg(e){return e?.type===`text`?e.text:``}function cg(e){return e?.type!==`text`}function lg(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)})})(ro(),e=>({kind:`skill`,name:e[1]??``}));for(let n of cs(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 ug(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 dg(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 fg(e){let t=(0,Z.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,X.jsx)(Ae,{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,X.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,X.jsx)(yt,{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,X.jsx)(N,{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,X.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,X.jsx)(lc,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=r):r=t[5],r}var pg=(0,Q.memo)(function(e){let t=(0,Z.c)(24),{text:n,conversationId:r,document:i,contextRefs:a}=e,o=y(mg),s;t[0]===o?s=t[1]:(s=C(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=lg(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(hg)??[]);e=i.parts.flatMap(e=>e.type===`text`?lg(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=ug(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(gg),t[9]=u,t[10]=p);let m=$m(void 0,r,p);if(!u.some(_g)){let e;return t[11]===n?e=t[12]:(e=(0,X.jsx)(`div`,{className:`markdown-content min-w-0`,children:(0,X.jsx)(np,{content:n,compact:!0,breaks:!0})}),t[11]=n,t[12]=e),e}let h;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,X.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,X.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,X.jsxs)(`span`,{className:Y(`chat-context-ref-pill chat-context-ref-pill-message max-w-full shrink-0`,dg(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,X.jsx)(fg,{contextRef:n.ref}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:n.ref?.title??c})]},r):n.text?(0,X.jsx)(`div`,{className:`chat-user-message-segment markdown-content inline-block min-w-0 max-w-full align-baseline text-fg`,children:(0,X.jsx)(np,{content:n.text,compact:!0,breaks:!0})},r):null},t[18]=u,t[19]=c,t[20]=m,t[21]=e):e=t[21],h=f.map(e),t[13]=u,t[14]=f,t[15]=c,t[16]=m,t[17]=h}else h=t[17];let g;return t[22]===h?g=t[23]:(g=(0,X.jsx)(`span`,{className:`inline-flex max-w-full flex-wrap items-baseline gap-x-0 gap-y-1 [text-align:inherit]`,children:h}),t[22]=h,t[23]=g),g});function mg(e){return e.language}function hg(e){return e.refId?[[e.refId,e]]:[]}function gg(e){return e.kind===`skill`}function _g(e){return e.kind!==`text`}function vg(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:e.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:e.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 yg(e){let t=(0,Z.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,X.jsx)(He,{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,X.jsx)(_e,{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,X.jsx)(hc,{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,X.jsx)(G,{className:`size-4`,strokeWidth:1.75}),t[3]=e):e=t[3],e}}}function bg(e){let t=(0,Z.c)(34),{payload:n,onRetry:r}=e,i=p(),a=C(y(Sg)).chat,[o,s]=(0,Q.useState)(``),c=vg(n,a),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=[`provider_connection_error`,`timeout`,`rate_limit`,`unknown`,`send_failed`],t[0]=l):l=t[0];let u=l.includes(n.code),d=n.code===`model_quota_exhausted`,f=xg,m;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(m=Y(`flex flex-col gap-2 rounded-xl border p-3`,`border-edge bg-surface-panel`),t[1]=m):m=t[1];let h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=Y(`flex size-8 shrink-0 items-center justify-center rounded-lg`,`bg-surface-inset text-warning`),t[2]=h):h=t[2];let g;t[3]===n.code?g=t[4]:(g=(0,X.jsx)(`span`,{className:h,"aria-hidden":!0,children:(0,X.jsx)(yg,{code:n.code})}),t[3]=n.code,t[4]=g);let _;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(_=Y(`text-sm font-semibold`,`text-fg`),t[5]=_):_=t[5];let v;t[6]===c.title?v=t[7]:(v=(0,X.jsx)(`h3`,{className:_,children:c.title}),t[6]=c.title,t[7]=v);let b;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(b=Y(`mt-1 text-xs leading-relaxed`,`text-fg-muted`),t[8]=b):b=t[8];let x;t[9]===c.body?x=t[10]:(x=(0,X.jsx)(`p`,{className:b,children:c.body}),t[9]=c.body,t[10]=x);let S;t[11]!==v||t[12]!==x?(S=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[v,x]}),t[11]=v,t[12]=x,t[13]=S):S=t[13];let w;t[14]!==g||t[15]!==S?(w=(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[g,S]}),t[14]=g,t[15]=S,t[16]=w):w=t[16];let T;t[17]!==c.cta||t[18]!==c.deepLink||t[19]!==a||t[20]!==i||t[21]!==r||t[22]!==d||t[23]!==u?(T=u?(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r?(0,X.jsx)(`button`,{type:`button`,className:Y(`min-h-9 rounded-md px-3 text-xs font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`bg-accent text-on-accent hover:bg-accent-hover`),onClick:r,children:a.runRecovery.retry}):null,(0,X.jsx)(`button`,{type:`button`,className:`min-h-9 rounded-md px-3 text-xs text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>i(`/settings/capabilities/models`),children:a.runRecovery.models})]}):d?(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,X.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`,`bg-accent text-on-accent hover:bg-accent-hover`),onClick:()=>f(`/models/credits/purchase`),children:a.xopcQuotaPurchaseCta}),(0,X.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:()=>f(`/models/credits/request`),children:a.xopcQuotaRequestCta}),(0,X.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:()=>i(`/settings/capabilities/models?add=1`),children:a.xopcQuotaOwnProviderCta})]}):c.cta&&c.deepLink?(0,X.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,X.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`,`bg-accent text-on-accent hover:bg-accent-hover`),onClick:()=>i(c.deepLink),children:c.cta})}):null,t[17]=c.cta,t[18]=c.deepLink,t[19]=a,t[20]=i,t[21]=r,t[22]=d,t[23]=u,t[24]=T):T=t[24];let E;t[25]!==o||t[26]!==a||t[27]!==n.message||t[28]!==s?(E=n.message?(0,X.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,X.jsx)(`summary`,{className:Y(`cursor-pointer select-none underline-offset-2`,`text-fg-muted hover:text-fg`),children:a.agentRunErrorDetailToggle}),(0,X.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]`,`bg-surface-inset text-fg-muted`),children:Li(n.message)}),(0,X.jsx)(`button`,{type:`button`,className:`mt-1 min-h-9 rounded-md px-2 text-xs text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:async()=>{try{await navigator.clipboard.writeText(Li(n.message)),s(a.runRecovery.copied)}catch{s(a.runRecovery.copyFailed)}},children:a.runRecovery.copyDetails}),(0,X.jsx)(`span`,{role:`status`,"aria-live":`polite`,className:`ml-2 text-fg-muted`,children:o})]}):null,t[25]=o,t[26]=a,t[27]=n.message,t[28]=s,t[29]=E):E=t[29];let D;return t[30]!==w||t[31]!==T||t[32]!==E?(D=(0,X.jsxs)(`section`,{role:`alert`,"aria-live":`polite`,className:m,children:[w,T,E]}),t[30]=w,t[31]=T,t[32]=E,t[33]=D):D=t[33],D}function xg(e){return window.open(`https://console.xopc.ai${e}`,`_blank`,`noopener,noreferrer`)}function Sg(e){return e.language}function Cg(e){let t=(0,Z.c)(5),{errorText:n,onRetry:r}=e,i;t[0]===n?i=t[1]:(i=zi(n),t[0]=n,t[1]=i);let a=i;if(!a)return null;let o;return t[2]!==r||t[3]!==a?(o=(0,X.jsx)(`div`,{className:`mb-4`,children:(0,X.jsx)(bg,{payload:a,onRetry:r})}),t[2]=r,t[3]=a,t[4]=o):o=t[4],o}function wg(e){let t=(0,Z.c)(4),{payload:n}=e,r;t[0]===n?r=t[1]:(r=JSON.stringify({...n,code:n.kind,message:n.message??``}),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,X.jsx)(Cg,{errorText:r}),t[2]=r,t[3]=i),i}var Tg=/^No API key found for (\S+)/i;function Eg(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=Tg.exec(t);return n?{kind:`provider_setup_required`,provider:n[1].replace(/[.,]$/,``),deepLink:`/settings/capabilities/models`,message:t}:null}var Dg=new WeakMap;function Og(e){let t=Dg.get(e),n=Fr(e);return t??(n?[n]:[])}function kg(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??``}`},kr(e,t[t.length-1]),Dg.set(t[t.length-1],[...Og(e),...Og(n)]);continue}t.push(n)}return t}var Ag=/^\s*\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$/m,jg=/^\s{0,3}(?:[-+*]|\d+[.)])\s+/m,Mg=/^\s{0,3}```/gm;function Ng(e){return(e.match(Mg)?.length??0)%2==1?`code`:Ag.test(e)?`table`:jg.test(e)?`list`:e.length>=4096?`long_text`:`plain`}var Pg={plain:50,long_text:50,list:50,table:72,code:64};function Fg({tailKind:e,latestParseMs:t}){let n=Pg[e];return!Number.isFinite(t)||t<=16?n:Math.min(120,Math.max(n,Math.ceil(t*2)))}var Ig=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=Of(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 Lg(e,t,n,r=!1,i,a=!1){let[o,s]=(0,Q.useState)(()=>e),[c]=(0,Q.useState)(()=>new Ig(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,pt(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){st(n,e.length),o();return}if(c.observe(e.length,performance.now()),p.current=Fg({tailKind:Ng(e.slice(-8192)),latestParseMs:ot(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,st(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 Rg(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 zg(e){let t=(0,Z.c)(33),{review:n}=e,r=y(Vg),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=C(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,X.jsx)(qe,{className:`size-4 animate-spin text-accent`,"aria-hidden":!0}):null,t[16]=i,t[17]=m),c=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[m,(0,X.jsx)(`div`,{className:`text-sm font-semibold text-fg-primary`,children:i?o.running:o.finished}),i?(0,X.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,X.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,X.jsx)(`div`,{className:`mt-1 text-xs text-fg-tertiary`,children:o.basedOn.replace(`{{target}}`,n.target)}),u=i&&!n.analysisMarkdown?(0,X.jsx)(`div`,{className:`mt-3 text-sm text-fg-secondary`,children:e?o.preparing:o.checking}):null,d=n.analysisMarkdown?(0,X.jsxs)(`div`,{className:`mt-3 rounded-md border border-edge-subtle bg-surface px-2.5 py-2`,children:[(0,X.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg-secondary`,children:o.assistant}),(0,X.jsx)(np,{content:n.analysisMarkdown,compact:!0,streaming:i})]}):null,f=n.status===`error`&&n.errorMessage?(0,X.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,X.jsxs)(X.Fragment,{children:[n.summary?(0,X.jsx)(`div`,{className:`mt-3 text-sm text-fg-secondary`,children:n.summary}):null,(0,X.jsx)(`div`,{className:`mt-3 space-y-2`,children:n.findings.length===0?(0,X.jsx)(`div`,{className:`text-sm text-fg-secondary`,children:a?o.noModelFindings:o.noFindings}):n.findings.map(Bg)}),n.overallExplanation?(0,X.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,X.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 Bg(e,t){let n=Rg(e);return(0,X.jsxs)(`div`,{className:`rounded-md border border-edge bg-surface p-2`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.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,X.jsx)(`span`,{className:`min-w-0 text-sm font-medium text-fg-primary`,children:e.title})]}),n?(0,X.jsx)(`div`,{className:`mt-1 break-all text-xs text-fg-tertiary`,children:n}):null,e.body?(0,X.jsx)(`div`,{className:`mt-1 text-sm text-fg-secondary`,children:e.body}):null]},`${e.title}-${t}`)}function Vg(e){return e.language}function Hg({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=og(n,r)??t,p=`assistant-markdown-${(0,Q.useId)()}`,m=Lg(f,s,p,c,l,d);(0,Q.useEffect)(()=>{if(s)return ct(p),()=>ht(p)},[p,s]);let h=Ci(e=>e.setPath),g=C(y(e=>e.language)).chat.fileReference,_=(0,Q.useCallback)(async t=>{try{return await _o(t.path,{projectId:o?.trim()||void 0,conversationId:a?.trim()||void 0,taskRunId:e})}catch(n){if(e||o||!a)throw n;return _o(t.path)}},[o,a,e]),v=(0,Q.useCallback)(function t(n){let r=Ji.getState(),i=r.scope,s={status:`loading`,target:n},c={projectId:o?.trim()||void 0,conversationId:a?.trim()||void 0,taskRunId:e},l=r.openFile({path:n.path,projectId:c.projectId,conversationId:c.conversationId,reference:s},i),u={id:l,scope:i,reference:s},d=()=>Ji.getState().panes[i]?.tabs.some(e=>e.id===l&&e.kind===`file`&&e.reference===s),f=()=>t(n);(async()=>{let t=await xo(n.path,c);if(!d())return;let p=t?.absolutePath||t?.workspaceRelativePath;if(p&&t?.capabilities.includes(`preview`)){h(p,n.line,o,a,void 0,{...u,resolvedFile:t.fileId?{id:t.fileId,mtimeMs:t.mtimeMs}:void 0});return}if(n.kind===`workspace-relative`&&!e&&!o&&a){let e=await xo(n.path),t=e?.absolutePath||e?.workspaceRelativePath;if(t&&e?.capabilities.includes(`preview`)){h(t,n.line,void 0,void 0,void 0,{...u,defaultWorkspace:!0,resolvedFile:e.fileId?{id:e.fileId,mtimeMs:e.mtimeMs}:void 0});return}}r.finishFileReference(l,i,s,{reference:t?{status:`ready`,target:n,ref:t,retry:t.exists?void 0:f}:{status:`error`,target:n,message:g.resolveFailedDescription,retry:f}})})().catch(e=>{r.finishFileReference(l,i,s,{reference:{status:`error`,target:n,message:e instanceof Error?e.message:String(e),retry:f}})})},[g.resolveFailedDescription,o,a,e,h]),b=Eg(f);return(0,X.jsx)(X.Fragment,{children:b?(0,X.jsx)(wg,{payload:b}):(0,X.jsx)(np,{content:m,streaming:s||m!==f,compact:i,onWorkspaceFileOpen:v,onWorkspaceImageLoad:_,renderMermaid:!0,mermaidActions:!0,streamingMetricsKey:p,responseRunId:u})})}function Ug(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){if(e.type===`text`)return n?(0,X.jsx)(`div`,{className:`min-w-0`,children:(0,X.jsx)(pg,{text:Yn(e.text??``),conversationId:s,document:f,contextRefs:p})},t):(0,X.jsx)(`div`,{className:`assistant-markdown-content markdown-content min-w-0`,children:(0,X.jsx)(Hg,{content:e.text,sourcePartIds:Og(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,X.jsx)(cf,{source:e.source.data,alt:``,title:i,onOpen:a?()=>a(e,n):void 0},t)}return e.type===`review`?(0,X.jsx)(zg,{review:e},t):null}function Wg(e){let t=(0,Z.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:kg(r),d;t[19]===v?d=t[20]:(d=new Set(v?[...v].map(Fr).filter(Boolean):[]),t[19]=v,t[20]=d);let g=d,y;t[21]!==v||t[22]!==g?(y=e=>v?.has(e)||!!(Fr(e)&&g.has(Fr(e))),t[21]=v,t[22]=g,t[23]=y):y=t[23];let w=y,T=e.findLastIndex(Gg),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,X.jsx)(`div`,{"data-assistant-activity":!0,"data-assistant-process-item":v?!0:void 0,hidden:S,children:_(r,A===e.length)},Fr(t)??`activity-${n}`))}else{let e=t.type===`image`?j++:0,r=Ug(t,Fr(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,X.jsx)(`div`,{"data-assistant-process-item":w(t)||void 0,hidden:S&&w(t),children:r},Fr(t)??`block-${A}`):r),A++}}C=(0,X.jsx)(X.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 Gg(e){return e.type===`text`&&e.presentation===`pending`}var Kg=[`readFile`,`editFile`,`writeFile`,`runCommand`,`memorySearch`,`codeSearch`,`webSearch`,`search`,`fetchUrl`,`openUrl`,`listDir`,`other`];function qg(e,t){return za(e,t)}function Jg(e){let t=new Map;for(let n of e){if(n.type!==`tool_use`)continue;let e=qg(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 Yg(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 Xg(e,t,n){let r=Jg(e),i=[];for(let e of Kg){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)||Yg(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 Zg(e){return e.filter(e=>e.type!==`thinking`||!!e.text?.trim()||!!e.streaming)}function Qg(e,t,n){return Xg(e,t,n)}function $g(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function e_(e){if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}}function t_(e){let t=$g(e_(e));if(!t)return[];let n=$g(t.details)?.results??t.results;if(Array.isArray(n))return n.map($g).filter(e=>e!==null);let r=Array.isArray(t.content)?t.content:[];for(let e of r){let t=$g(e)?.text,n=$g(e_(t));if(Array.isArray(n?.results))return n.results.map($g).filter(e=>e!==null)}return[]}function n_(e,t){return e.replace(/\{\{count\}\}/g,String(t))}function r_(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=t_(e.result),r=e.activity?.count??n.length;return{title:r===0?t.empty:n_(r===1?t.found_one:t.found_other,r),purpose:t.purpose}}function i_(e,t){if(e.status===`running`)return{title:t?`正在更新记忆`:`Updating memory`,purpose:``};let n=$g(e_(e.result)),r=$g(n?.details)??n;if(!r?.status&&Array.isArray(n?.content))for(let e of n.content){let t=$g(e_($g(e)?.text));if(t?.status){r=t;break}}let i=typeof r?.receiptId==`string`&&typeof r.committedAt==`number`;if(e.status===`error`||!i||![`saved`,`pending`,`forgotten`].includes(String(r?.status)))return{title:t?`记忆修改未确认保存`:`Memory change not confirmed`,purpose:t?`未收到成功回执,请重试或查看记忆。`:`No successful receipt was received. Retry or check your memory.`};let a=$g(r?.scope)?.type,o=t?{global:`所有协作`,agent:`当前助手`,workspace:`当前工作区`,project:`当前项目`,session:`当前会话`}:{global:`All work`,agent:`This assistant`,workspace:`This workspace`,project:`This project`,session:`This conversation`};if(r?.status===`forgotten`)return{title:t?`已忘记这条记忆`:`Memory forgotten`,purpose:t?`后续不再自动使用;原始对话和文件保留,已运行的上下文不受影响。`:`Future automatic recall is stopped. Original sources and already running contexts are retained.`};if(r?.available===!1)return{title:t?`这条记忆已不再可用`:`This memory is no longer available`,purpose:``};let s=r?.status===`pending`||r?.usable!==!0;return{title:s?t?`已保存,暂不使用`:`Saved, not yet in use`:r?.command===`correct`?t?`已纠正记忆`:`Memory corrected`:r?.command===`scope`?t?`已调整记忆范围`:`Memory scope updated`:t?`已记住`:`Memory saved`,purpose:`${o[String(a)]??``}${s?t?` · 请在记忆中查看确认状态。`:` · Check its review status in Memory.`:t?` · 从下一轮按需使用。`:` · Available when relevant from the next turn.`}`}}function a_(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 o_(e){if(e==null)return null;try{return typeof e==`string`?JSON.parse(e):e}catch{return null}}function s_(e){let t=o_(e),n=t?.path??t?.file_path??t?.filepath??t?.file??t?.qualified_name??t?.function_name;return typeof n==`string`?n:``}function c_(e){let t=o_(e),n=t?.url??t?.href??t?.uri??t?.website;return typeof n==`string`?n:``}function l_(e){let t=o_(e),n=t?.command??t?.cmd??t?.shell??t?.script;return typeof n==`string`?n:``}var u_=120;function d_(e){if(e==null)return``;let t=o_(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>u_?`${t.slice(0,u_)}…`:t}if(typeof e==`number`&&Number.isFinite(e))return String(e)}return``}function f_(e){return e.startsWith(`@@`)?`hunk`:e.startsWith(`+++`)||e.startsWith(`---`)||e.startsWith(`diff `)||e.startsWith(`index `)?`meta`:e.startsWith(`+`)?`add`:e.startsWith(`-`)?`del`:`context`}function p_(e){let t=e.details?.diff;if(typeof t!=`string`||t.length===0)return null;let n=t.split(`
18
+ `),r=[],i=0,a=0;for(let e of n){let t=f_(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}}var m_=`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`,h_=`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`,g_=`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`,__=`cursor-pointer select-none text-xs text-fg-subtle underline-offset-2 hover:text-fg-muted group-open:text-fg-muted`;function v_(e){let t=(0,Z.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(m_,a),t[0]=a,t[1]=o);let s;return t[2]!==n||t[3]!==o?(s=(0,X.jsx)(`span`,{className:o,children:n}),t[2]=n,t[3]=o,t[4]=s):s=t[4],s}function y_(e){let t=(0,Z.c)(3),{children:n,title:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,X.jsx)(`code`,{className:h_,title:r,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}var b_=(0,Q.memo)(function(e){let t=(0,Z.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 ra(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`,Ma.transition,Ma.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,X.jsx)(ne,{className:`size-3.5`,"aria-hidden":!0}):(0,X.jsx)(J,{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,X.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 x_(e){let t=(0,Z.c)(8),{summary:n,children:r,defaultOpen:i}=e,a=i!==void 0&&i,o;t[0]===n?o=t[1]:(o=(0,X.jsx)(`summary`,{className:__,children:n}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,X.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,X.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 S_(e){let t=(0,Z.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,X.jsx)(`pre`,{className:g_,children:n}),t[0]=n,t[1]=r),r}function C_(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>{let r=t[n];return r==null?``:String(r)})}function w_(e){return e.details??{}}var T_=/\[(\d+)\/(\d+) lines\]\s*$/;function E_(e){let t=e.match(T_);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 D_(e){return e.replace(T_,``).trimEnd()}var O_=(0,Q.memo)(function(e){let t=(0,Z.c)(32),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=s_(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=Ra(n.result),t[2]=n.result,t[3]=o);let s=o.text,c;t[4]===s?c=t[5]:(c=E_(s),t[4]=s,t[5]=c);let l=c,u;t[6]===s?u=t[7]:(u=D_(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
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
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,X.jsx)(x_,{title:a,children:a}):null,t[12]=a,t[13]=g);let _;t[14]!==r||t[15]!==l||t[16]!==p?(_=p>0?(0,X.jsx)(b_,{children:l&&l.shown<l.total?T_(r.linesPartial,{shown:l.shown,total:l.total}):T_(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,X.jsx)(S_,{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,X.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,X.jsx)(C_,{summary:r.viewContent,children:(0,X.jsx)(w_,{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,X.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 j_(e){let t=(0,Z.c)(4),{lines:n}=e,r;t[0]===n?r=t[1]:(r=n.map(M_),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,X.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 M_(e,t){return(0,X.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 N_=(0,Q.memo)(function(e){let t=(0,Z.c)(25),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=l_(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=Ba(n.result),t[2]=n.result,t[3]=o);let s=o,c;t[4]===s?c=t[5]:(c=h_(s),t[4]=s,t[5]=c);let l=c,u;t[6]===a?u=t[7]:(u=a?(0,X.jsx)(x_,{title:a,children:a}):null,t[6]=a,t[7]=u);let d;t[8]!==l||t[9]!==r?(d=l?(0,X.jsx)(b_,{tone:`accent`,children:T_(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,X.jsx)(S_,{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,X.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,X.jsx)(C_,{summary:r.viewDiff,defaultOpen:!0,children:(0,X.jsx)(j_,{lines:l.lines})}):s.text?(0,X.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,X.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 P_(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 F_=(0,Q.memo)(function(e){let t=(0,Z.c)(20),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=l_(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=Ba(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=E_(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,X.jsx)(x_,{title:a,children:a}):null,t[10]=a,t[11]=l),u=n==null?null:(0,X.jsx)(b_,{children:T_(r.sizeBadge,{size:P_(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,X.jsx)(S_,{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,X.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}),I_=12;function L_(e){if(!e)return{preview:``,truncated:!1};let t=e.split(`
22
- `);return t.length<=I_?{preview:e,truncated:!1}:{preview:`${t.slice(0,I_).join(`
23
- `)}\n…`,truncated:!0}}var R_=(0,Q.memo)(function(e){let t=(0,Z.c)(29),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=d_(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=Ba(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??E_(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=L_(f),t[7]=f,t[8]=p);let{preview:m}=p,h;t[9]===a?h=t[10]:(h=a?(0,X.jsxs)(x_,{title:a,children:[(0,X.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,X.jsx)(b_,{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,X.jsx)(S_,{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,X.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,X.jsx)(C_,{summary:r.viewOutput,children:(0,X.jsx)(w_,{children:m})}):n.status===`running`?null:(0,X.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,X.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}),z_=(0,Q.memo)(function(e){let t=(0,Z.c)(27),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=u_(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=Ba(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=E_(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(`
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,X.jsx)(y_,{title:a,children:a}):null,t[12]=a,t[13]=g);let _;t[14]!==r||t[15]!==l||t[16]!==p?(_=p>0?(0,X.jsx)(v_,{children:l&&l.shown<l.total?C_(r.linesPartial,{shown:l.shown,total:l.total}):C_(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,X.jsx)(b_,{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,X.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,X.jsx)(x_,{summary:r.viewContent,children:(0,X.jsx)(S_,{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,X.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 k_(e){let t=(0,Z.c)(4),{lines:n}=e,r;t[0]===n?r=t[1]:(r=n.map(A_),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,X.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 A_(e,t){return(0,X.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 j_=(0,Q.memo)(function(e){let t=(0,Z.c)(25),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=s_(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=Ra(n.result),t[2]=n.result,t[3]=o);let s=o,c;t[4]===s?c=t[5]:(c=p_(s),t[4]=s,t[5]=c);let l=c,u;t[6]===a?u=t[7]:(u=a?(0,X.jsx)(y_,{title:a,children:a}):null,t[6]=a,t[7]=u);let d;t[8]!==l||t[9]!==r?(d=l?(0,X.jsx)(v_,{tone:`accent`,children:C_(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,X.jsx)(b_,{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,X.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,X.jsx)(x_,{summary:r.viewDiff,defaultOpen:!0,children:(0,X.jsx)(k_,{lines:l.lines})}):s.text?(0,X.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,X.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 M_(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 N_=(0,Q.memo)(function(e){let t=(0,Z.c)(20),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=s_(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=Ra(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=w_(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,X.jsx)(y_,{title:a,children:a}):null,t[10]=a,t[11]=l),u=n==null?null:(0,X.jsx)(v_,{children:C_(r.sizeBadge,{size:M_(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,X.jsx)(b_,{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,X.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}),P_=12;function F_(e){if(!e)return{preview:``,truncated:!1};let t=e.split(`
22
+ `);return t.length<=P_?{preview:e,truncated:!1}:{preview:`${t.slice(0,P_).join(`
23
+ `)}\n…`,truncated:!0}}var I_=(0,Q.memo)(function(e){let t=(0,Z.c)(29),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=l_(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=Ra(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??w_(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=F_(f),t[7]=f,t[8]=p);let{preview:m}=p,h;t[9]===a?h=t[10]:(h=a?(0,X.jsxs)(y_,{title:a,children:[(0,X.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,X.jsx)(v_,{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,X.jsx)(b_,{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,X.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,X.jsx)(x_,{summary:r.viewOutput,children:(0,X.jsx)(S_,{children:m})}):n.status===`running`?null:(0,X.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,X.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}),L_=(0,Q.memo)(function(e){let t=(0,Z.c)(27),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=c_(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=Ra(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=w_(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
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,X.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,X.jsx)(b_,{children:T_(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,X.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,X.jsx)(C_,{summary:r.viewContent,children:(0,X.jsx)(w_,{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,X.jsxs)(`div`,{className:f,children:[p,m]}),t[23]=f,t[24]=p,t[25]=m,t[26]=h):h=t[26],h}),B_=e=>e&&typeof e==`object`&&!Array.isArray(e)?e:void 0,V_=e=>typeof e==`string`&&/^[a-z0-9][a-z0-9_-]{0,63}$/.test(e)?e:void 0;function H_(e){let t={...Ba(e.result).details,...B_(e.details)},n=B_(t?.searchInfo)??t,r=Array.isArray(n?.attempts)?n.attempts.slice(0,24).flatMap(e=>{let t=B_(e),n=V_(t?.provider);return!n||![`success`,`empty`,`error`,`skipped`].includes(String(t?.outcome))?[]:[{provider:n,upstream:V_(t?.upstream),outcome:String(t?.outcome),reason:V_(t?.reason)}]}):[];return{provider:V_(n?.provider),upstream:V_(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 U_(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 W_(e){let t=(0,Z.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=H_(n),u;t[20]===i.unknown?u=t[21]:(u=e=>U_(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,X.jsx)(`summary`,{className:`cursor-pointer hover:text-fg`,children:r}),t[23]=r,t[24]=m),l=(0,X.jsxs)(`details`,{className:`min-w-0 text-xs text-fg-muted`,onToggle:p,children:[m,s?(0,X.jsxs)(`div`,{className:`mt-2 space-y-2 rounded-md border border-edge px-3 py-2`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,X.jsxs)(`span`,{children:[i.provider,`:`,f]}),(0,X.jsx)(`span`,{className:`text-fg-subtle`,children:e.cached===!0?i.cached:e.cached===!1?i.fresh:i.cacheUnknown})]}),e.cached===!0?(0,X.jsx)(`p`,{className:`text-fg-subtle`,children:i.cacheHint}):null,a?(0,X.jsxs)(`div`,{className:`space-y-1 border-t border-edge pt-2 text-fg-subtle`,children:[e.attemptCount===void 0?null:(0,X.jsxs)(`p`,{children:[i.attempts,`:`,e.attemptCount]}),e.capturedAt===void 0?null:(0,X.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,X.jsx)(`p`,{children:i.incompleteRoute}):null,e.attempts.length?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{children:e.cached===!0?i.cachedRoute:i.route}),(0,X.jsx)(`ol`,{className:`list-inside list-decimal space-y-1`,children:e.attempts.map((e,t)=>(0,X.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 G_(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 K_(e){let t=(0,Z.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,X.jsx)(`div`,{className:`mt-2 w-full min-w-0 overflow-hidden rounded-xl border border-edge bg-surface-base`,children:(0,X.jsx)(ks,{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 q_(e){let t=ro();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 J_(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 Y_(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 X_(e,t,n){let r=new Map,i=0,a=e.toSorted((e,t)=>Number(Fa(e.name))-Number(Fa(t.name)));for(let e of a){if(Ra(e)){i++;continue}let n=t(e);r.set(n,(r.get(n)??0)+1)}let o=[...r],s=o.slice(0,2).map(([e,t])=>t===1?e:n.repeated.replace(`{{action}}`,e).replace(`{{count}}`,String(t))),c=o.slice(2).reduce((e,[,t])=>e+t,0);return c>0&&s.push(n.more.replace(`{{count}}`,String(c))),i>0&&s.push(n.failed.replace(`{{count}}`,String(i))),s.join(n.separator)}function Z_({path:e,conversationId:t,label:n}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(),s=Ti(e=>e.setPath),c=async()=>{i(!0),o(void 0);try{let n=await Co(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,X.jsxs)(`div`,{className:`mt-2`,children:[(0,X.jsx)(Yi,{variant:`ghost`,disabled:r,onClick:()=>{c()},className:`text-accent`,children:n}),a?(0,X.jsx)(`p`,{className:`text-xs text-red-600`,children:a}):null]})}function Q_(e){return/^Full Codemode output: (\.xopc\/codemode-output\/[a-f0-9-]{36}\.txt)(?:\r?\n|$)/.exec(e)?.[1]}function $_(e,t=0){return Fr(e)??(e.type===`tool_use`?e.id:e.type===`text`?e.segmentId??`narration-${t}`:`thinking-${t}`)}var ev=(0,Q.memo)(function(e){let t=(0,Z.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(Ov),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?G_(u,a):i==null?null:G_(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,X.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 tv(e){let t=(0,Z.c)(232),{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,h=l===void 0||l,g=u!==void 0&&u,_=d!==void 0&&d,v=f!==void 0&&f,b=p!==void 0&&p,x=m===void 0||m,S=y(hv),[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]===S?O=t[4]:(O=C(S),t[3]=S,t[4]=O);let k=O.chat,A=Os(mv),j;if(t[5]!==A||t[6]!==v||t[7]!==n.items){let e;t[9]!==A||t[10]!==v?(e=e=>e.type!==`thinking`||A||v,t[9]=A,t[10]=v,t[11]=e):e=t[11],j=n.items.filter(e),t[5]=A,t[6]=v,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(pv),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),[ee,te]=(0,Q.useState)(!1),[ne,ie]=(0,Q.useState)(!1),ae,oe;t[14]!==I||t[15]!==ee?(ae=()=>{if(!I&&!ee)return;let e=()=>{let e=window.getSelection();te(!!(e&&!e.isCollapsed&&W.current?.contains(e.anchorNode)))};return document.addEventListener(`selectionchange`,e),()=>document.removeEventListener(`selectionchange`,e)},oe=[I,ee],t[14]=I,t[15]=ee,t[16]=ae,t[17]=oe):(ae=t[16],oe=t[17]),(0,Q.useEffect)(ae,oe);let se=!n.compact&&M.length>0&&(B??(V||ee)),ce,le;t[18]===se?(ce=t[19],le=t[20]):(ce=()=>{let e=W.current;if(!se||!e)return;let t=e.closest(`.chat-messages`),n=n=>fs(n,e,t);return e.addEventListener(`wheel`,n,{passive:!1}),()=>e.removeEventListener(`wheel`,n)},le=[se],t[18]=se,t[19]=ce,t[20]=le),(0,Q.useEffect)(ce,le);let ue,de;t[21]!==se||t[22]!==ne?(ue=()=>{if(se){ie(!0);return}if(!ne)return;let e=window.setTimeout(()=>ie(!1),200);return()=>window.clearTimeout(e)},de=[se,ne],t[21]=se,t[22]=ne,t[23]=ue,t[24]=de):(ue=t[23],de=t[24]),(0,Q.useEffect)(ue,de);let fe;t[25]===M?fe=t[26]:(fe=M.every(fv),t[25]=M,t[26]=fe);let pe=fe,G,me,he,K,ge,_e,q,ve,ye,J,be;if(t[27]!==P||t[28]!==I||t[29]!==s||t[30]!==k||t[31]!==o||t[32]!==c||t[33]!==se||t[34]!==S||t[35]!==r||t[36]!==g||t[37]!==x||t[38]!==H||t[39]!==A||t[40]!==v||t[41]!==h||t[42]!==pe||t[43]!==a||t[44]!==b||t[45]!==i||t[46]!==M||t[47]!==w||t[48]!==n.durationMs||t[49]!==n.items||t[50]!==n.startedAt){ye=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Y_(M);ge=pe&&I&&!H&&!A?Math.max(0,e.length-3):0,J=e.slice(ge).flatMap(dv),K=n.startedAt??null,me=n.durationMs??null;let l;t[62]!==a.editFile||t[63]!==a.fetchUrl||t[64]!==a.listDirectory||t[65]!==a.openUrl||t[66]!==a.readFile||t[67]!==a.runCommand||t[68]!==a.searched||t[69]!==a.searchedCode||t[70]!==a.searchedMemory||t[71]!==a.searchedWeb||t[72]!==a.unknownTool||t[73]!==a.writeFile?(l={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[62]=a.editFile,t[63]=a.fetchUrl,t[64]=a.listDirectory,t[65]=a.openUrl,t[66]=a.readFile,t[67]=a.runCommand,t[68]=a.searched,t[69]=a.searchedCode,t[70]=a.searchedMemory,t[71]=a.searchedWeb,t[72]=a.unknownTool,t[73]=a.writeFile,t[74]=l):l=t[74];let u=l,d;t[75]!==o.ing||t[76]!==u||t[77]!==a.toolActivity?(d=(e,t)=>za(e,t,a.toolActivity,u,o.ing),t[75]=o.ing,t[76]=u,t[77]=a.toolActivity,t[78]=d):d=t[78],_e=d;let f=P.filter(uv),p=f.length,m;bb1:{if(!I){m=null;break bb1}if(p>1){let e;t[79]!==k.activityParallel||t[80]!==p?(e=k.activityParallel.replace(`{{count}}`,String(p)),t[79]=k.activityParallel,t[80]=p,t[81]=e):e=t[81],m=e;break bb1}let e;t[82]===_e?e=t[83]:(e=e=>_e(e,`running`),t[82]=_e,t[83]=e);let n;t[84]!==P||t[85]!==o.ing||t[86]!==e?(n=e_(P,o.ing,e),t[84]=P,t[85]=o.ing,t[86]=e,t[87]=n):n=t[87],m=n}let _=m,y=r===`sending`?k.sendingLabel:r===`waiting`?w?k.waitingLongLabel:k.waitingLabel:null,C;t[88]!==P||t[89]!==k.thinkingLabel||t[90]!==a.workLogRunning?(C=P.some(lv)?k.thinkingLabel:a.workLogRunning,t[88]=P,t[89]=k.thinkingLabel,t[90]=a.workLogRunning,t[91]=C):C=t[91];let T=C;q=r??(P.some(cv)?`tool`:P.some(sv)?`thinking`:P.length>0?`organizing`:`working`),G=_??y??T;let E;if(t[92]!==P||t[93]!==k.activityFailed||t[94]!==k.activityMore||t[95]!==k.activityRepeated||t[96]!==S||t[97]!==_e||t[98]!==v||t[99]!==a.thoughts){let e=P.filter(ov);E=v&&e.length>0?X_(e,e=>_e(e,`completed`),{repeated:k.activityRepeated,more:k.activityMore,failed:k.activityFailed,separator:S===`zh`?`、`:`, `}):v?a.thoughts:null,t[92]=P,t[93]=k.activityFailed,t[94]=k.activityMore,t[95]=k.activityRepeated,t[96]=S,t[97]=_e,t[98]=v,t[99]=a.thoughts,t[100]=E}else E=t[100];if(he=E,n.items.length===0&&!I){ye=null;break bb0}let D;if(t[101]!==o.ing||t[102]!==a.editFile||t[103]!==a.fetchUrl||t[104]!==a.listDirectory||t[105]!==a.memoryActivity||t[106]!==a.openUrl||t[107]!==a.rawThinking||t[108]!==a.readFile||t[109]!==a.runCommand||t[110]!==a.searched||t[111]!==a.searchedCode||t[112]!==a.searchedMemory||t[113]!==a.searchedWeb||t[114]!==a.stepDetails||t[115]!==a.thoughts||t[116]!==a.thoughtsStreaming||t[117]!==a.toolActivity||t[118]!==a.toolError||t[119]!==a.unknownTool||t[120]!==a.writeFile?(D={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[101]=o.ing,t[102]=a.editFile,t[103]=a.fetchUrl,t[104]=a.listDirectory,t[105]=a.memoryActivity,t[106]=a.openUrl,t[107]=a.rawThinking,t[108]=a.readFile,t[109]=a.runCommand,t[110]=a.searched,t[111]=a.searchedCode,t[112]=a.searchedMemory,t[113]=a.searchedWeb,t[114]=a.stepDetails,t[115]=a.thoughts,t[116]=a.thoughtsStreaming,t[117]=a.toolActivity,t[118]=a.toolError,t[119]=a.unknownTool,t[120]=a.writeFile,t[121]=D):D=t[121],be=D,g||b){let e;t[122]!==I||t[123]!==s||t[124]!==c||t[125]!==x||t[126]!==be||t[127]!==i||t[128]!==n.items?(e=x&&n.items.filter(av).map(e=>(0,X.jsx)(Tv,{block:e,toolLabels:i,stepLabels:be,cardLabels:s,conversationId:c,surfaceOnly:!0,runActive:I},e.id)),t[122]=I,t[123]=s,t[124]=c,t[125]=x,t[126]=be,t[127]=i,t[128]=n.items,t[129]=e):e=t[129];let r;t[130]===e?r=t[131]:(r=(0,X.jsx)(X.Fragment,{children:e}),t[130]=e,t[131]=r),ye=r;break bb0}ve=se&&(!h||A)&&p===1&&J.includes(f[0])}t[27]=P,t[28]=I,t[29]=s,t[30]=k,t[31]=o,t[32]=c,t[33]=se,t[34]=S,t[35]=r,t[36]=g,t[37]=x,t[38]=H,t[39]=A,t[40]=v,t[41]=h,t[42]=pe,t[43]=a,t[44]=b,t[45]=i,t[46]=M,t[47]=w,t[48]=n.durationMs,t[49]=n.items,t[50]=n.startedAt,t[51]=G,t[52]=me,t[53]=he,t[54]=K,t[55]=ge,t[56]=_e,t[57]=q,t[58]=ve,t[59]=ye,t[60]=J,t[61]=be}else G=t[51],me=t[52],he=t[53],K=t[54],ge=t[55],_e=t[56],q=t[57],ve=t[58],ye=t[59],J=t[60],be=t[61];if(ye!==Symbol.for(`react.early_return_sentinel`))return ye;let xe=ve,Se;t[132]!==G||t[133]!==I||t[134]!==me||t[135]!==he||t[136]!==K||t[137]!==S||t[138]!==xe||t[139]!==q||t[140]!==a.workLogComplete||t[141]!==a.workLogFailed||t[142]!==a.workLogPartial||t[143]!==a.workLogTitle||t[144]!==n.status?(Se=I?(0,X.jsxs)(X.Fragment,{children:[xe?(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:a.workLogTitle}):null,(0,X.jsx)(`span`,{className:xe?`sr-only`:`block min-w-0 flex-1 truncate whitespace-nowrap`,"data-status-phase":q,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:(0,X.jsx)(`span`,{className:`assistant-activity-shimmer inline-block max-w-full truncate align-bottom`,children:G})}),(0,X.jsx)(ev,{active:I,startedAt:K,frozenMs:null,language:S,className:`ml-1.5 w-[8ch] shrink-0 whitespace-nowrap text-right tabular-nums text-fg-muted`})]}):(0,X.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:he??(n.status===`failed`?a.workLogFailed:n.status===`partial`?a.workLogPartial:me==null?a.workLogTitle:a.workLogComplete)}),t[132]=G,t[133]=I,t[134]=me,t[135]=he,t[136]=K,t[137]=S,t[138]=xe,t[139]=q,t[140]=a.workLogComplete,t[141]=a.workLogFailed,t[142]=a.workLogPartial,t[143]=a.workLogTitle,t[144]=n.status,t[145]=Se):Se=t[145];let Ce=Se,we;t[146]!==I||t[147]!==me||t[148]!==K||t[149]!==S?(we=I?null:(0,X.jsx)(ev,{active:!1,startedAt:K,frozenMs:me,language:S,className:`mt-0.5 tabular-nums text-xs text-fg-muted`}),t[146]=I,t[147]=me,t[148]=K,t[149]=S,t[150]=we):we=t[150];let Te=we,Ee=!n.compact&&F>0;if(h&&!A){let e;t[151]!==_||t[152]!==I||t[153]!==n.items?(e=!I&&!_&&n.items.some(iv),t[151]=_,t[152]=I,t[153]=n.items,t[154]=e):e=t[154];let r=e,o=n.status===`failed`||n.status===`partial`||r,l,u,d,f,p;if(t[155]!==G||t[156]!==_||t[157]!==I||t[158]!==s||t[159]!==c||t[160]!==o||t[161]!==x||t[162]!==_e||t[163]!==be||t[164]!==i||t[165]!==n.items||t[166]!==n.status){let e=I&&!_||o?J_(n.items,e=>{if(Ra(e)||Fa(e.name)||!Ia(e.name)&&Yg(e.name,e.activity)===`other`)return null;let t=_e(e,I&&(e.status===`running`||e.activity?.status===`running`)?`running`:`completed`);return I&&t===G?null:t}):[];l=!0,u=n.status,d=`my-1 min-w-0 w-full text-left`,t[172]!==I||t[173]!==s||t[174]!==c||t[175]!==x||t[176]!==be||t[177]!==i||t[178]!==n.items?(f=x&&n.items.filter(rv).map(e=>(0,X.jsx)(Tv,{block:e,toolLabels:i,stepLabels:be,cardLabels:s,conversationId:c,surfaceOnly:!0,runActive:I},e.id)),t[172]=I,t[173]=s,t[174]=c,t[175]=x,t[176]=be,t[177]=i,t[178]=n.items,t[179]=f):f=t[179],p=e.length>0?(0,X.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,X.jsx)(Tv,{block:e,toolLabels:i,stepLabels:be,cardLabels:s,conversationId:c,runActive:I},$_(e,t)))}):null,t[155]=G,t[156]=_,t[157]=I,t[158]=s,t[159]=c,t[160]=o,t[161]=x,t[162]=_e,t[163]=be,t[164]=i,t[165]=n.items,t[166]=n.status,t[167]=l,t[168]=u,t[169]=d,t[170]=f,t[171]=p}else l=t[167],u=t[168],d=t[169],f=t[170],p=t[171];let m;t[180]!==I||t[181]!==r||t[182]!==Ce||t[183]!==o||t[184]!==a.workLogFailed||t[185]!==a.workLogPartial||t[186]!==n.status?(m=I?(0,X.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,X.jsx)(Gt,{className:`assistant-activity-busy size-4 shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`div`,{className:`flex h-6 min-w-0 flex-1 items-center`,children:Ce})]}):o?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r||n.status===`failed`?a.workLogFailed:a.workLogPartial}):null,t[180]=I,t[181]=r,t[182]=Ce,t[183]=o,t[184]=a.workLogFailed,t[185]=a.workLogPartial,t[186]=n.status,t[187]=m):m=t[187];let h;return t[188]!==l||t[189]!==u||t[190]!==d||t[191]!==f||t[192]!==p||t[193]!==m?(h=(0,X.jsxs)(`div`,{"data-assistant-work-log":l,"data-work-log-status":u,className:d,children:[f,p,m]}),t[188]=l,t[189]=u,t[190]=d,t[191]=f,t[192]=p,t[193]=m,t[194]=h):h=t[194],h}let De=n.status,Oe=I||se?`w-full`:`w-fit max-w-full`,ke;t[195]===Oe?ke=t[196]:(ke=Y(`my-1 min-w-0`,Oe),t[195]=Oe,t[196]=ke);let Ae;t[197]!==I||t[198]!==se||t[199]!==Te||t[200]!==Ce||t[201]!==Ee||t[202]!==n.compact||t[203]!==n.items.length?(Ae=I||!n.compact&&n.items.length>0?(0,X.jsxs)(`button`,{type:`button`,disabled:!Ee,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:Ee?()=>z({active:I,value:!se}):void 0,"aria-expanded":Ee?se:void 0,children:[(0,X.jsx)(Gt,{className:Y(`size-4 shrink-0`,I&&`assistant-activity-busy`),"aria-hidden":!0}),(0,X.jsx)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:(0,X.jsx)(`span`,{className:Y(`flex w-full min-w-0 items-center`,I?`h-6`:`min-h-6`),children:Ce})}),(0,X.jsx)(`span`,{className:`flex shrink-0 items-start justify-end`,children:Te}),Ee?(0,X.jsx)(re,{className:Y(`size-4 shrink-0 text-fg-muted transition-transform motion-reduce:transition-none`,se&&`rotate-180`),"aria-hidden":!0}):null]}):null,t[197]=I,t[198]=se,t[199]=Te,t[200]=Ce,t[201]=Ee,t[202]=n.compact,t[203]=n.items.length,t[204]=Ae):Ae=t[204];let je;t[205]!==I||t[206]!==s||t[207]!==c||t[208]!==x||t[209]!==be||t[210]!==i||t[211]!==n.items?(je=x&&n.items.filter(nv).map(e=>(0,X.jsx)(Tv,{block:e,toolLabels:i,stepLabels:be,cardLabels:s,conversationId:c,surfaceOnly:!0,runActive:I},e.id)),t[205]=I,t[206]=s,t[207]=c,t[208]=x,t[209]=be,t[210]=i,t[211]=n.items,t[212]=je):je=t[212];let Me;t[213]!==I||t[214]!==s||t[215]!==k.activityEarlier||t[216]!==c||t[217]!==se||t[218]!==ne||t[219]!==ge||t[220]!==H||t[221]!==v||t[222]!==J||t[223]!==be||t[224]!==i?(Me=se||ne?(0,X.jsx)(`div`,{className:`assistant-activity-disclosure`,"data-open":se,"aria-hidden":!se,inert:!se,children:(0,X.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:(0,X.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:[ge>0?(0,X.jsx)(`button`,{type:`button`,className:`mb-3 text-xs text-fg-muted hover:text-fg`,onClick:()=>U(!0),children:k.activityEarlier}):null,(0,X.jsx)(gv,{blocks:J,toolLabels:i,stepLabels:be,cardLabels:s,conversationId:c,animateNew:I&&se&&!H,runActive:I,showThinking:v})]})})}):null,t[213]=I,t[214]=s,t[215]=k.activityEarlier,t[216]=c,t[217]=se,t[218]=ne,t[219]=ge,t[220]=H,t[221]=v,t[222]=J,t[223]=be,t[224]=i,t[225]=Me):Me=t[225];let Ne;return t[226]!==ke||t[227]!==Ae||t[228]!==je||t[229]!==Me||t[230]!==n.status?(Ne=(0,X.jsxs)(`div`,{"data-assistant-work-log":!0,"data-work-log-status":De,className:ke,children:[Ae,je,Me]}),t[226]=ke,t[227]=Ae,t[228]=je,t[229]=Me,t[230]=n.status,t[231]=Ne):Ne=t[231],Ne}function nv(e){return e.type===`tool_use`}function rv(e){return e.type===`tool_use`}function iv(e){return e.type===`tool_use`&&Ra(e)}function av(e){return e.type===`tool_use`}function ov(e){return e.type===`tool_use`}function sv(e){return e.type===`thinking`&&e.streaming}function cv(e){return e.type===`tool_use`&&e.status===`running`}function lv(e){return e.type===`thinking`&&e.streaming}function uv(e){return e.type===`tool_use`&&(e.status===`running`||e.activity?.status===`running`)}function dv(e){return e.type===`tools`?e.tools:[e.item]}function fv(e){return Fr(e)||e.type===`tool_use`||e.type===`text`&&e.segmentId}function pv(e){return e.type!==`text`}function mv(e){return e.showRawToolData}function hv(e){return e.language}function gv({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($_))),u=Os(e=>e.showRawToolData),d=y(e=>e.language),f=u?e.map(e=>({type:`item`,item:e})):Y_(e);return e.length>0?(0,X.jsx)(`div`,{className:Y(`min-w-0 overflow-x-hidden`,i),children:(0,X.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=$_(f,i);return(0,X.jsx)(`div`,{className:Y(o&&!l.current.has(p)&&f.type!==`text`&&`assistant-activity-enter`),children:e.type===`tools`?(0,X.jsx)(_v,{tools:e.tools,runActive:s,labels:n,language:d,renderTool:e=>(0,X.jsx)(Tv,{block:e,toolLabels:t,stepLabels:n,cardLabels:r,conversationId:a,runActive:s},e.id)}):e.item.type===`thinking`&&c&&!u?(0,X.jsx)(`div`,{"data-assistant-thinking":!0,className:`text-sm leading-relaxed text-fg-muted`,children:(0,X.jsx)(ip,{content:e.item.text,compact:!0,streaming:!!(s&&e.item.streaming)})}):(0,X.jsx)(Tv,{block:e.item,toolLabels:t,stepLabels:n,cardLabels:r,conversationId:a,runActive:s})},p)})})}):null}function _v(e){let t=(0,Z.c)(35),{tools:n,runActive:r,labels:i,language:a,renderTool:o}=e,s;t[0]!==r||t[1]!==n?(s=r&&n.some(yv),t[0]=r,t[1]=n,t[2]=s):s=t[2];let c=s,l,u,d,f,p,m,h,g;if(t[3]!==i||t[4]!==a||t[5]!==o||t[6]!==r||t[7]!==c||t[8]!==n){g=Symbol.for(`react.early_return_sentinel`);bb0:{let e=C(a).chat,s=c?[...n].reverse().find(vv):void 0,_=n.filter(e=>e!==s),v;t[17]!==i||t[18]!==r?(v=e=>za(e,r&&(e.status===`running`||e.activity?.status===`running`)?`running`:`completed`,i.toolActivity,i,i.runningActions),t[17]=i,t[18]=r,t[19]=v):v=t[19];let y=X_(_,v,{repeated:e.activityRepeated,more:e.activityMore,failed:e.activityFailed,separator:a===`zh`?`、`:`, `});if(n.length===1){let e;t[20]!==o||t[21]!==n[0]?(e=o(n[0]),t[20]=o,t[21]=n[0],t[22]=e):e=t[22],g=e;break bb0}p=!0,m=`min-w-0 space-y-1.5`,h=s?o(s):null,d=`min-w-0 text-[13px] text-fg-muted`,f=(0,X.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,X.jsx)(`span`,{children:y})}),l=`mt-2 min-w-0 space-y-2.5 border-l border-edge-subtle pl-3`,u=_.map(o)}t[3]=i,t[4]=a,t[5]=o,t[6]=r,t[7]=c,t[8]=n,t[9]=l,t[10]=u,t[11]=d,t[12]=f,t[13]=p,t[14]=m,t[15]=h,t[16]=g}else l=t[9],u=t[10],d=t[11],f=t[12],p=t[13],m=t[14],h=t[15],g=t[16];if(g!==Symbol.for(`react.early_return_sentinel`))return g;let _;t[23]!==l||t[24]!==u?(_=(0,X.jsx)(`div`,{className:l,children:u}),t[23]=l,t[24]=u,t[25]=_):_=t[25];let v;t[26]!==_||t[27]!==d||t[28]!==f?(v=(0,X.jsxs)(`details`,{className:d,children:[f,_]}),t[26]=_,t[27]=d,t[28]=f,t[29]=v):v=t[29];let y;return t[30]!==v||t[31]!==p||t[32]!==m||t[33]!==h?(y=(0,X.jsxs)(`div`,{"data-activity-group":p,className:m,children:[h,v]}),t[30]=v,t[31]=p,t[32]=m,t[33]=h,t[34]=y):y=t[34],y}function vv(e){return e.status===`running`||e.activity?.status===`running`}function yv(e){return e.status===`running`||e.activity?.status===`running`}function bv(e){let t=(0,Z.c)(15),{toolName:n,toolResult:r}=e,i=ro(),a=q_(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,X.jsx)(K_,{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 xv=new Set([`readFile`,`editFile`,`writeFile`,`runCommand`,`fetchUrl`]),Sv=240;function Cv(e){let t=e.split(`
26
- `).map(e=>e.trim()).find(Boolean)??``;return t.length<=Sv?t:`${t.slice(0,Sv)}…`}function wv(e,t,n){let r=Ba(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 Cv(t)}return Cv(r.text)||t}function Tv(e){let t=(0,Z.c)(137),{block:n,toolLabels:r,stepLabels:i,cardLabels:a,conversationId:o,surfaceOnly:s,runActive:c}=e,l=s!==void 0&&s,u=c===void 0||c,d;t[0]===n?d=t[1]:(d=Fr(n),t[0]=n,t[1]=d);let f=sg(o,d),p=f?.type===n.type?f:n,m=Os(Dv),g=y(Ev),_;bb0:{if(p.type!==`tool_use`){_=``;break bb0}if(p.status===`running`){_=``;break bb0}let e=p.result;if(e==null){_=``;break bb0}if(typeof e==`string`){let n;t[2]===e?n=t[3]:(n=e.trim(),t[2]=e,t[3]=n),_=n;break bb0}try{let n;t[4]===e?n=t[5]:(n=JSON.stringify(e,null,2),t[4]=e,t[5]=n),_=n}catch{_=String(e)}}let v=_;if(p.type===`text`){let e;t[6]===p.text?e=t[7]:(e=p.text.trim(),t[6]=p.text,t[7]=e);let n=e;if(!n)return null;let r=p.presentation===`pending`,i;return t[8]!==r||t[9]!==n?(i=(0,X.jsx)(`div`,{className:`min-w-0 text-sm leading-relaxed text-fg-muted`,children:(0,X.jsx)(ip,{content:n,compact:!0,streaming:r})}),t[8]=r,t[9]=n,t[10]=i):i=t[10],i}if(p.type===`thinking`){let e=!!p.streaming,n;t[11]===p.text?n=t[12]:(n=p.text?.trim()??``,t[11]=p.text,t[12]=n);let r=n;if(!m||!r)return null;let a=e?i.thoughtsStreaming:i.thoughts,o;t[13]===a?o=t[14]:(o=(0,X.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]!==m||t[16]!==i.rawThinking||t[17]!==e||t[18]!==r?(s=m&&r?(0,X.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer select-none text-fg-subtle underline-offset-2 hover:text-fg-muted`,children:i.rawThinking}),(0,X.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-xs leading-relaxed text-fg-muted [overflow-wrap:anywhere]`,children:r})]}):e?(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`…`}):null,t[15]=m,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,X.jsx)(`div`,{className:`min-w-0`,children:(0,X.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 b=u&&(p.status===`running`||p.activity?.status===`running`),x;t[23]!==p||t[24]!==l?(x=l?p.status===`error`||p.activity?.status===`failed`:Ra(p),t[23]=p,t[24]=l,t[25]=x):x=t[25];let S=x,w;t[26]!==p||t[27]!==a||t[28]!==S||t[29]!==i.toolError?(w=S?wv(p,i.toolError,a):``,t[26]=p,t[27]=a,t[28]=S,t[29]=i.toolError,t[30]=w):w=t[30];let T=w,E=v,D;t[31]!==p.name||t[32]!==E?(D=p.name===`codemode`?Q_(E??``):void 0,t[31]=p.name,t[32]=E,t[33]=D):D=t[33];let O=D,k=b&&p.details&&typeof p.details==`object`&&!Array.isArray(p.details)&&typeof p.details.text==`string`?p.details.text:``,A=E??``;if(A)try{let e;t[34]===A?e=t[35]:(e=JSON.stringify(JSON.parse(A),null,2),t[34]=A,t[35]=e),A=e}catch{}let j,M,N,P,F;if(t[36]!==p||t[37]!==S||t[38]!==b||t[39]!==g||t[40]!==i.editFile||t[41]!==i.fetchUrl||t[42]!==i.listDirectory||t[43]!==i.memoryActivity||t[44]!==i.openUrl||t[45]!==i.readFile||t[46]!==i.runCommand||t[47]!==i.runningActions||t[48]!==i.searched||t[49]!==i.searchedCode||t[50]!==i.searchedMemory||t[51]!==i.searchedWeb||t[52]!==i.toolActivity||t[53]!==i.toolError||t[54]!==i.unknownTool||t[55]!==i.writeFile){M=Yg(p.name,p.activity),j=xv.has(M),N=p.name===`personal_memory`?o_(p,g===`zh`):M===`memorySearch`?a_(p,i.memoryActivity):null;let e={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},n=za(p,b||S?`running`:`completed`,i.toolActivity,e,i.runningActions);F=S?M===`other`&&!Ia(p.name)?i.toolError:i.toolActivity.stepFailed.replace(`{{operation}}`,n.replace(/^正在|[.…]+$/g,``)):N?.title??n,P=S?Zt:M.includes(`Search`)||M===`search`?zt:M===`readFile`?W:M===`editFile`||M===`writeFile`?$s:M===`fetchUrl`||M===`openUrl`?Me:ge,t[36]=p,t[37]=S,t[38]=b,t[39]=g,t[40]=i.editFile,t[41]=i.fetchUrl,t[42]=i.listDirectory,t[43]=i.memoryActivity,t[44]=i.openUrl,t[45]=i.readFile,t[46]=i.runCommand,t[47]=i.runningActions,t[48]=i.searched,t[49]=i.searchedCode,t[50]=i.searchedMemory,t[51]=i.searchedWeb,t[52]=i.toolActivity,t[53]=i.toolError,t[54]=i.unknownTool,t[55]=i.writeFile,t[56]=j,t[57]=M,t[58]=N,t[59]=P,t[60]=F}else j=t[56],M=t[57],N=t[58],P=t[59],F=t[60];let I=P,L;t[61]!==p.input||t[62]!==N?(L=N?``:p_(p.input),t[61]=p.input,t[62]=N,t[63]=L):L=t[63];let R=L,z;t[64]===p.input?z=t[65]:(z=p.input===void 0?``:s_(p.input),t[64]=p.input,t[65]=z);let B=z,V;t[66]!==p||t[67]!==a||t[68]!==j||t[69]!==M?(V=j?M===`readFile`?(0,X.jsx)(A_,{block:p,labels:a}):M===`editFile`?(0,X.jsx)(N_,{block:p,labels:a}):M===`writeFile`?(0,X.jsx)(F_,{block:p,labels:a}):M===`runCommand`?(0,X.jsx)(R_,{block:p,labels:a}):M===`fetchUrl`?(0,X.jsx)(z_,{block:p,labels:a}):null:null,t[66]=p,t[67]=a,t[68]=j,t[69]=M,t[70]=V):V=t[70];let H=V;if(l){let e;t[71]!==p.name||t[72]!==p.result||t[73]!==S||t[74]!==b?(e=!b&&!S?(0,X.jsx)(bv,{toolName:p.name,toolResult:p.result}):null,t[71]=p.name,t[72]=p.result,t[73]=S,t[74]=b,t[75]=e):e=t[75];let n;return t[76]===e?n=t[77]:(n=(0,X.jsx)(X.Fragment,{children:e}),t[76]=e,t[77]=n),n}let U=!b&&m,ee=p.parentToolCallId?`ml-4 min-w-0 border-l border-edge pl-3`:`min-w-0`,te=S?`failed`:b?`running`:`completed`,ne=b&&`assistant-activity-busy`,re;t[78]===ne?re=t[79]:(re=Y(`mt-0.5 size-4 shrink-0 text-fg-subtle`,ne),t[78]=ne,t[79]=re);let ie;t[80]!==I||t[81]!==re?(ie=(0,X.jsx)(I,{className:re,"aria-hidden":!0}),t[80]=I,t[81]=re,t[82]=ie):ie=t[82];let ae;t[83]===F?ae=t[84]:(ae=(0,X.jsx)(`span`,{className:`inline-flex max-w-full min-w-0 break-words text-[13px] text-fg-muted [overflow-wrap:anywhere]`,children:F}),t[83]=F,t[84]=ae);let oe;t[85]!==te||t[86]!==ie||t[87]!==ae?(oe=(0,X.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,"data-activity-status":te,children:[ie,ae]}),t[85]=te,t[86]=ie,t[87]=ae,t[88]=oe):oe=t[88];let se;t[89]!==H||t[90]!==i.stepDetails?(se=H?(0,X.jsxs)(`details`,{className:`min-w-0 text-xs text-fg-muted`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer hover:text-fg`,children:i.stepDetails}),H]}):null,t[89]=H,t[90]=i.stepDetails,t[91]=se):se=t[91];let ce;t[92]!==p||t[93]!==b||t[94]!==M||t[95]!==g||t[96]!==m||t[97]!==i.stepDetails?(ce=M===`webSearch`&&!b?(0,X.jsx)(W_,{block:p,summary:i.stepDetails,labels:C(g).chat.searchDetails,developer:m,language:g}):null,t[92]=p,t[93]=b,t[94]=M,t[95]=g,t[96]=m,t[97]=i.stepDetails,t[98]=ce):ce=t[98];let le;t[99]!==N||t[100]!==i.memoryActivity?(le=N?(0,X.jsxs)(`div`,{className:`space-y-1 text-xs text-fg-muted`,children:[(0,X.jsx)(`p`,{children:N.purpose}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1`,children:[(0,X.jsx)(h,{className:`font-medium text-accent-fg hover:underline`,to:`/user-model`,children:i.memoryActivity.manage}),(0,X.jsx)(h,{className:`font-medium text-accent-fg hover:underline`,to:`/user-model`,children:i.memoryActivity.privacy})]}),(0,X.jsxs)(`details`,{children:[(0,X.jsx)(`summary`,{className:`cursor-pointer select-none text-fg-subtle hover:text-fg-muted`,children:i.memoryActivity.why}),(0,X.jsx)(`div`,{className:`mt-1.5 rounded-md bg-surface-hover/60 px-2 py-1.5 dark:bg-surface-hover/35`,children:(0,X.jsx)(`p`,{children:i.memoryActivity.explanation})})]})]}):null,t[99]=N,t[100]=i.memoryActivity,t[101]=le):le=t[101];let ue;t[102]!==T||t[103]!==m?(ue=T&&m?(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:T}):null,t[102]=T,t[103]=m,t[104]=ue):ue=t[104];let de;t[105]!==R||t[106]!==j||t[107]!==m?(de=m&&!j&&R?(0,X.jsx)(`p`,{className:`min-w-0 break-words text-xs text-fg-muted [overflow-wrap:anywhere]`,children:R}):null,t[105]=R,t[106]=j,t[107]=m,t[108]=de):de=t[108];let fe;t[109]!==k||t[110]!==m?(fe=m&&k?(0,X.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:k}):null,t[109]=k,t[110]=m,t[111]=fe):fe=t[111];let pe;t[112]!==o||t[113]!==g||t[114]!==O?(pe=O?(0,X.jsx)(Z_,{path:O,conversationId:o,label:g===`zh`?`查看完整输出`:`View full output`}):null,t[112]=o,t[113]=g,t[114]=O,t[115]=pe):pe=t[115];let G;t[116]!==a||t[117]!==j||t[118]!==A||t[119]!==B||t[120]!==U||t[121]!==i.stepDetails||t[122]!==r?(G=U?(0,X.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer select-none text-fg-subtle underline-offset-2 hover:text-fg-muted group-open:text-fg-muted`,children:j?a.rawDetails:i.stepDetails}),(0,X.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:[B?(0,X.jsxs)(`div`,{className:`mb-2 min-w-0`,children:[(0,X.jsx)(`div`,{className:`mb-0.5 text-[10px] uppercase tracking-wide text-fg-disabled`,children:r.input}),(0,X.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-fg-muted [overflow-wrap:anywhere]`,children:B})]}):null,(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`div`,{className:`mb-0.5 text-[10px] uppercase tracking-wide text-fg-disabled`,children:r.output}),(0,X.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-fg-muted [overflow-wrap:anywhere]`,children:A||r.noOutput})]})]})]}):null,t[116]=a,t[117]=j,t[118]=A,t[119]=B,t[120]=U,t[121]=i.stepDetails,t[122]=r,t[123]=G):G=t[123];let me;t[124]!==oe||t[125]!==se||t[126]!==ce||t[127]!==le||t[128]!==ue||t[129]!==de||t[130]!==fe||t[131]!==pe||t[132]!==G?(me=(0,X.jsxs)(`div`,{className:`min-w-0 space-y-1.5`,children:[oe,se,ce,le,ue,de,fe,pe,G]}),t[124]=oe,t[125]=se,t[126]=ce,t[127]=le,t[128]=ue,t[129]=de,t[130]=fe,t[131]=pe,t[132]=G,t[133]=me):me=t[133];let he;return t[134]!==ee||t[135]!==me?(he=(0,X.jsx)(`div`,{className:ee,children:me}),t[134]=ee,t[135]=me,t[136]=he):he=t[136],he}function Ev(e){return e.language}function Dv(e){return e.showRawToolData}function Ov(e){return e+1}function kv(e){let t=(0,Z.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,X.jsx)(To,{delayDuration:300,skipDelayDuration:100,children:n}),t[0]=n,t[1]=r),r}function Av(e){let t=(0,Z.c)(7),{label:n,children:r}=e,i;t[0]===r?i=t[1]:(i=(0,X.jsx)(ko,{asChild:!0,children:r}),t[0]=r,t[1]=i);let a;t[2]===n?a=t[3]:(a=(0,X.jsx)(Eo,{children:(0,X.jsx)(Oo,{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,X.jsxs)(Do,{children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}var jv=`NO_REPLY`;function Mv(e,t){if(e.role!==`assistant`||!e.content?.length)return e;if(t?.hideSilentReply){let n=t.streaming?e.content.findLast(e=>e.type===`text`):void 0,r=e.content.filter(e=>{if(e.type!==`text`)return!0;let t=e.text.trim();return t!==jv&&!(e===n&&e.presentation===`pending`&&t&&jv.startsWith(t))});if(r.length!==e.content.length)return Mv({...e,content:r},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=!1){return t||e.textSurface===`conversation`}function Pv(e,t){return e.renderKey??`${e.timestamp??`n`}-${t}`}var Fv=new WeakMap;function Iv(e,t){let n=Fv.get(e);if(n?.personal===t)return n.text;let r=Or(ur(Mv(e,{hideSilentReply:Nv(e,t),streaming:!1}).content??[]).flatMap(e=>e.type===`text`?[e.text]:[]).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,X.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,X.jsx)(v_,{children:C_(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,X.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,X.jsx)(x_,{summary:r.viewContent,children:(0,X.jsx)(S_,{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,X.jsxs)(`div`,{className:f,children:[p,m]}),t[23]=f,t[24]=p,t[25]=m,t[26]=h):h=t[26],h}),R_=e=>e&&typeof e==`object`&&!Array.isArray(e)?e:void 0,z_=e=>typeof e==`string`&&/^[a-z0-9][a-z0-9_-]{0,63}$/.test(e)?e:void 0;function B_(e){let t={...Ra(e.result).details,...R_(e.details)},n=R_(t?.searchInfo)??t,r=Array.isArray(n?.attempts)?n.attempts.slice(0,24).flatMap(e=>{let t=R_(e),n=z_(t?.provider);return!n||![`success`,`empty`,`error`,`skipped`].includes(String(t?.outcome))?[]:[{provider:n,upstream:z_(t?.upstream),outcome:String(t?.outcome),reason:z_(t?.reason)}]}):[];return{provider:z_(n?.provider),upstream:z_(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 V_(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 H_(e){let t=(0,Z.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=B_(n),u;t[20]===i.unknown?u=t[21]:(u=e=>V_(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,X.jsx)(`summary`,{className:`cursor-pointer hover:text-fg`,children:r}),t[23]=r,t[24]=m),l=(0,X.jsxs)(`details`,{className:`min-w-0 text-xs text-fg-muted`,onToggle:p,children:[m,s?(0,X.jsxs)(`div`,{className:`mt-2 space-y-2 rounded-md border border-edge px-3 py-2`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,X.jsxs)(`span`,{children:[i.provider,`:`,f]}),(0,X.jsx)(`span`,{className:`text-fg-subtle`,children:e.cached===!0?i.cached:e.cached===!1?i.fresh:i.cacheUnknown})]}),e.cached===!0?(0,X.jsx)(`p`,{className:`text-fg-subtle`,children:i.cacheHint}):null,a?(0,X.jsxs)(`div`,{className:`space-y-1 border-t border-edge pt-2 text-fg-subtle`,children:[e.attemptCount===void 0?null:(0,X.jsxs)(`p`,{children:[i.attempts,`:`,e.attemptCount]}),e.capturedAt===void 0?null:(0,X.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,X.jsx)(`p`,{children:i.incompleteRoute}):null,e.attempts.length?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{children:e.cached===!0?i.cachedRoute:i.route}),(0,X.jsx)(`ol`,{className:`list-inside list-decimal space-y-1`,children:e.attempts.map((e,t)=>(0,X.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 U_(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 W_(e){let t=(0,Z.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,X.jsx)(`div`,{className:`mt-2 w-full min-w-0 overflow-hidden rounded-xl border border-edge bg-surface-base`,children:(0,X.jsx)(Ds,{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 G_(e){let t=to();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 K_(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 q_(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 J_(e,t,n){let r=new Map,i=0,a=e.toSorted((e,t)=>Number(Na(e.name))-Number(Na(t.name)));for(let e of a){if(Ia(e)){i++;continue}let n=t(e);r.set(n,(r.get(n)??0)+1)}let o=[...r],s=o.slice(0,2).map(([e,t])=>t===1?e:n.repeated.replace(`{{action}}`,e).replace(`{{count}}`,String(t))),c=o.slice(2).reduce((e,[,t])=>e+t,0);return c>0&&s.push(n.more.replace(`{{count}}`,String(c))),i>0&&s.push(n.failed.replace(`{{count}}`,String(i))),s.join(n.separator)}function Y_({path:e,conversationId:t,label:n}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(),s=Ci(e=>e.setPath),c=async()=>{i(!0),o(void 0);try{let n=await xo(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,X.jsxs)(`div`,{className:`mt-2`,children:[(0,X.jsx)(qi,{variant:`ghost`,disabled:r,onClick:()=>{c()},className:`text-accent`,children:n}),a?(0,X.jsx)(`p`,{className:`text-xs text-red-600`,children:a}):null]})}function X_(e){return/^Full Codemode output: (\.xopc\/codemode-output\/[a-f0-9-]{36}\.txt)(?:\r?\n|$)/.exec(e)?.[1]}function Z_(e,t=0){return Fr(e)??(e.type===`tool_use`?e.id:e.type===`text`?e.segmentId??`narration-${t}`:`thinking-${t}`)}var Q_=(0,Q.memo)(function(e){let t=(0,Z.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(Ev),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?U_(u,a):i==null?null:U_(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,X.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 $_(e){let t=(0,Z.c)(232),{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,h=l===void 0||l,g=u!==void 0&&u,_=d!==void 0&&d,v=f!==void 0&&f,b=p!==void 0&&p,x=m===void 0||m,S=y(pv),[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]===S?O=t[4]:(O=C(S),t[3]=S,t[4]=O);let k=O.chat,A=Es(fv),j;if(t[5]!==A||t[6]!==v||t[7]!==n.items){let e;t[9]!==A||t[10]!==v?(e=e=>e.type!==`thinking`||A||v,t[9]=A,t[10]=v,t[11]=e):e=t[11],j=n.items.filter(e),t[5]=A,t[6]=v,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(dv),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),[ee,te]=(0,Q.useState)(!1),[ne,ie]=(0,Q.useState)(!1),ae,oe;t[14]!==I||t[15]!==ee?(ae=()=>{if(!I&&!ee)return;let e=()=>{let e=window.getSelection();te(!!(e&&!e.isCollapsed&&W.current?.contains(e.anchorNode)))};return document.addEventListener(`selectionchange`,e),()=>document.removeEventListener(`selectionchange`,e)},oe=[I,ee],t[14]=I,t[15]=ee,t[16]=ae,t[17]=oe):(ae=t[16],oe=t[17]),(0,Q.useEffect)(ae,oe);let se=!n.compact&&M.length>0&&(B??(V||ee)),ce,le;t[18]===se?(ce=t[19],le=t[20]):(ce=()=>{let e=W.current;if(!se||!e)return;let t=e.closest(`.chat-messages`),n=n=>us(n,e,t);return e.addEventListener(`wheel`,n,{passive:!1}),()=>e.removeEventListener(`wheel`,n)},le=[se],t[18]=se,t[19]=ce,t[20]=le),(0,Q.useEffect)(ce,le);let ue,de;t[21]!==se||t[22]!==ne?(ue=()=>{if(se){ie(!0);return}if(!ne)return;let e=window.setTimeout(()=>ie(!1),200);return()=>window.clearTimeout(e)},de=[se,ne],t[21]=se,t[22]=ne,t[23]=ue,t[24]=de):(ue=t[23],de=t[24]),(0,Q.useEffect)(ue,de);let fe;t[25]===M?fe=t[26]:(fe=M.every(uv),t[25]=M,t[26]=fe);let pe=fe,G,me,he,K,ge,_e,q,ve,ye,J,be;if(t[27]!==P||t[28]!==I||t[29]!==s||t[30]!==k||t[31]!==o||t[32]!==c||t[33]!==se||t[34]!==S||t[35]!==r||t[36]!==g||t[37]!==x||t[38]!==H||t[39]!==A||t[40]!==v||t[41]!==h||t[42]!==pe||t[43]!==a||t[44]!==b||t[45]!==i||t[46]!==M||t[47]!==w||t[48]!==n.durationMs||t[49]!==n.items||t[50]!==n.startedAt){ye=Symbol.for(`react.early_return_sentinel`);bb0:{let e=q_(M);ge=pe&&I&&!H&&!A?Math.max(0,e.length-3):0,J=e.slice(ge).flatMap(lv),K=n.startedAt??null,me=n.durationMs??null;let l;t[62]!==a.editFile||t[63]!==a.fetchUrl||t[64]!==a.listDirectory||t[65]!==a.openUrl||t[66]!==a.readFile||t[67]!==a.runCommand||t[68]!==a.searched||t[69]!==a.searchedCode||t[70]!==a.searchedMemory||t[71]!==a.searchedWeb||t[72]!==a.unknownTool||t[73]!==a.writeFile?(l={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[62]=a.editFile,t[63]=a.fetchUrl,t[64]=a.listDirectory,t[65]=a.openUrl,t[66]=a.readFile,t[67]=a.runCommand,t[68]=a.searched,t[69]=a.searchedCode,t[70]=a.searchedMemory,t[71]=a.searchedWeb,t[72]=a.unknownTool,t[73]=a.writeFile,t[74]=l):l=t[74];let u=l,d;t[75]!==o.ing||t[76]!==u||t[77]!==a.toolActivity?(d=(e,t)=>La(e,t,a.toolActivity,u,o.ing),t[75]=o.ing,t[76]=u,t[77]=a.toolActivity,t[78]=d):d=t[78],_e=d;let f=P.filter(cv),p=f.length,m;bb1:{if(!I){m=null;break bb1}if(p>1){let e;t[79]!==k.activityParallel||t[80]!==p?(e=k.activityParallel.replace(`{{count}}`,String(p)),t[79]=k.activityParallel,t[80]=p,t[81]=e):e=t[81],m=e;break bb1}let e;t[82]===_e?e=t[83]:(e=e=>_e(e,`running`),t[82]=_e,t[83]=e);let n;t[84]!==P||t[85]!==o.ing||t[86]!==e?(n=Qg(P,o.ing,e),t[84]=P,t[85]=o.ing,t[86]=e,t[87]=n):n=t[87],m=n}let _=m,y=r===`sending`?k.sendingLabel:r===`waiting`?w?k.waitingLongLabel:k.waitingLabel:null,C;t[88]!==P||t[89]!==k.thinkingLabel||t[90]!==a.workLogRunning?(C=P.some(sv)?k.thinkingLabel:a.workLogRunning,t[88]=P,t[89]=k.thinkingLabel,t[90]=a.workLogRunning,t[91]=C):C=t[91];let T=C;q=r??(P.some(ov)?`tool`:P.some(av)?`thinking`:P.length>0?`organizing`:`working`),G=_??y??T;let E;if(t[92]!==P||t[93]!==k.activityFailed||t[94]!==k.activityMore||t[95]!==k.activityRepeated||t[96]!==S||t[97]!==_e||t[98]!==v||t[99]!==a.thoughts){let e=P.filter(iv);E=v&&e.length>0?J_(e,e=>_e(e,`completed`),{repeated:k.activityRepeated,more:k.activityMore,failed:k.activityFailed,separator:S===`zh`?`、`:`, `}):v?a.thoughts:null,t[92]=P,t[93]=k.activityFailed,t[94]=k.activityMore,t[95]=k.activityRepeated,t[96]=S,t[97]=_e,t[98]=v,t[99]=a.thoughts,t[100]=E}else E=t[100];if(he=E,n.items.length===0&&!I){ye=null;break bb0}let D;if(t[101]!==o.ing||t[102]!==a.editFile||t[103]!==a.fetchUrl||t[104]!==a.listDirectory||t[105]!==a.memoryActivity||t[106]!==a.openUrl||t[107]!==a.rawThinking||t[108]!==a.readFile||t[109]!==a.runCommand||t[110]!==a.searched||t[111]!==a.searchedCode||t[112]!==a.searchedMemory||t[113]!==a.searchedWeb||t[114]!==a.stepDetails||t[115]!==a.thoughts||t[116]!==a.thoughtsStreaming||t[117]!==a.toolActivity||t[118]!==a.toolError||t[119]!==a.unknownTool||t[120]!==a.writeFile?(D={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[101]=o.ing,t[102]=a.editFile,t[103]=a.fetchUrl,t[104]=a.listDirectory,t[105]=a.memoryActivity,t[106]=a.openUrl,t[107]=a.rawThinking,t[108]=a.readFile,t[109]=a.runCommand,t[110]=a.searched,t[111]=a.searchedCode,t[112]=a.searchedMemory,t[113]=a.searchedWeb,t[114]=a.stepDetails,t[115]=a.thoughts,t[116]=a.thoughtsStreaming,t[117]=a.toolActivity,t[118]=a.toolError,t[119]=a.unknownTool,t[120]=a.writeFile,t[121]=D):D=t[121],be=D,g||b){let e;t[122]!==I||t[123]!==s||t[124]!==c||t[125]!==x||t[126]!==be||t[127]!==i||t[128]!==n.items?(e=x&&n.items.filter(rv).map(e=>(0,X.jsx)(Cv,{block:e,toolLabels:i,stepLabels:be,cardLabels:s,conversationId:c,surfaceOnly:!0,runActive:I},e.id)),t[122]=I,t[123]=s,t[124]=c,t[125]=x,t[126]=be,t[127]=i,t[128]=n.items,t[129]=e):e=t[129];let r;t[130]===e?r=t[131]:(r=(0,X.jsx)(X.Fragment,{children:e}),t[130]=e,t[131]=r),ye=r;break bb0}ve=se&&(!h||A)&&p===1&&J.includes(f[0])}t[27]=P,t[28]=I,t[29]=s,t[30]=k,t[31]=o,t[32]=c,t[33]=se,t[34]=S,t[35]=r,t[36]=g,t[37]=x,t[38]=H,t[39]=A,t[40]=v,t[41]=h,t[42]=pe,t[43]=a,t[44]=b,t[45]=i,t[46]=M,t[47]=w,t[48]=n.durationMs,t[49]=n.items,t[50]=n.startedAt,t[51]=G,t[52]=me,t[53]=he,t[54]=K,t[55]=ge,t[56]=_e,t[57]=q,t[58]=ve,t[59]=ye,t[60]=J,t[61]=be}else G=t[51],me=t[52],he=t[53],K=t[54],ge=t[55],_e=t[56],q=t[57],ve=t[58],ye=t[59],J=t[60],be=t[61];if(ye!==Symbol.for(`react.early_return_sentinel`))return ye;let xe=ve,Se;t[132]!==G||t[133]!==I||t[134]!==me||t[135]!==he||t[136]!==K||t[137]!==S||t[138]!==xe||t[139]!==q||t[140]!==a.workLogComplete||t[141]!==a.workLogFailed||t[142]!==a.workLogPartial||t[143]!==a.workLogTitle||t[144]!==n.status?(Se=I?(0,X.jsxs)(X.Fragment,{children:[xe?(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:a.workLogTitle}):null,(0,X.jsx)(`span`,{className:xe?`sr-only`:`block min-w-0 flex-1 truncate whitespace-nowrap`,"data-status-phase":q,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:(0,X.jsx)(`span`,{className:`assistant-activity-shimmer inline-block max-w-full truncate align-bottom`,children:G})}),(0,X.jsx)(Q_,{active:I,startedAt:K,frozenMs:null,language:S,className:`ml-1.5 w-[8ch] shrink-0 whitespace-nowrap text-right tabular-nums text-fg-muted`})]}):(0,X.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:he??(n.status===`failed`?a.workLogFailed:n.status===`partial`?a.workLogPartial:me==null?a.workLogTitle:a.workLogComplete)}),t[132]=G,t[133]=I,t[134]=me,t[135]=he,t[136]=K,t[137]=S,t[138]=xe,t[139]=q,t[140]=a.workLogComplete,t[141]=a.workLogFailed,t[142]=a.workLogPartial,t[143]=a.workLogTitle,t[144]=n.status,t[145]=Se):Se=t[145];let Ce=Se,we;t[146]!==I||t[147]!==me||t[148]!==K||t[149]!==S?(we=I?null:(0,X.jsx)(Q_,{active:!1,startedAt:K,frozenMs:me,language:S,className:`mt-0.5 tabular-nums text-xs text-fg-muted`}),t[146]=I,t[147]=me,t[148]=K,t[149]=S,t[150]=we):we=t[150];let Te=we,Ee=!n.compact&&F>0;if(h&&!A){let e;t[151]!==_||t[152]!==I||t[153]!==n.items?(e=!I&&!_&&n.items.some(nv),t[151]=_,t[152]=I,t[153]=n.items,t[154]=e):e=t[154];let r=e,o=n.status===`failed`||n.status===`partial`||r,l,u,d,f,p;if(t[155]!==G||t[156]!==_||t[157]!==I||t[158]!==s||t[159]!==c||t[160]!==o||t[161]!==x||t[162]!==_e||t[163]!==be||t[164]!==i||t[165]!==n.items||t[166]!==n.status){let e=I&&!_||o?K_(n.items,e=>{if(Ia(e)||Na(e.name)||!Pa(e.name)&&qg(e.name,e.activity)===`other`)return null;let t=_e(e,I&&(e.status===`running`||e.activity?.status===`running`)?`running`:`completed`);return I&&t===G?null:t}):[];l=!0,u=n.status,d=`my-1 min-w-0 w-full text-left`,t[172]!==I||t[173]!==s||t[174]!==c||t[175]!==x||t[176]!==be||t[177]!==i||t[178]!==n.items?(f=x&&n.items.filter(tv).map(e=>(0,X.jsx)(Cv,{block:e,toolLabels:i,stepLabels:be,cardLabels:s,conversationId:c,surfaceOnly:!0,runActive:I},e.id)),t[172]=I,t[173]=s,t[174]=c,t[175]=x,t[176]=be,t[177]=i,t[178]=n.items,t[179]=f):f=t[179],p=e.length>0?(0,X.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,X.jsx)(Cv,{block:e,toolLabels:i,stepLabels:be,cardLabels:s,conversationId:c,runActive:I},Z_(e,t)))}):null,t[155]=G,t[156]=_,t[157]=I,t[158]=s,t[159]=c,t[160]=o,t[161]=x,t[162]=_e,t[163]=be,t[164]=i,t[165]=n.items,t[166]=n.status,t[167]=l,t[168]=u,t[169]=d,t[170]=f,t[171]=p}else l=t[167],u=t[168],d=t[169],f=t[170],p=t[171];let m;t[180]!==I||t[181]!==r||t[182]!==Ce||t[183]!==o||t[184]!==a.workLogFailed||t[185]!==a.workLogPartial||t[186]!==n.status?(m=I?(0,X.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,X.jsx)(Gt,{className:`assistant-activity-busy size-4 shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`div`,{className:`flex h-6 min-w-0 flex-1 items-center`,children:Ce})]}):o?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r||n.status===`failed`?a.workLogFailed:a.workLogPartial}):null,t[180]=I,t[181]=r,t[182]=Ce,t[183]=o,t[184]=a.workLogFailed,t[185]=a.workLogPartial,t[186]=n.status,t[187]=m):m=t[187];let h;return t[188]!==l||t[189]!==u||t[190]!==d||t[191]!==f||t[192]!==p||t[193]!==m?(h=(0,X.jsxs)(`div`,{"data-assistant-work-log":l,"data-work-log-status":u,className:d,children:[f,p,m]}),t[188]=l,t[189]=u,t[190]=d,t[191]=f,t[192]=p,t[193]=m,t[194]=h):h=t[194],h}let De=n.status,Oe=I||se?`w-full`:`w-fit max-w-full`,ke;t[195]===Oe?ke=t[196]:(ke=Y(`my-1 min-w-0`,Oe),t[195]=Oe,t[196]=ke);let Ae;t[197]!==I||t[198]!==se||t[199]!==Te||t[200]!==Ce||t[201]!==Ee||t[202]!==n.compact||t[203]!==n.items.length?(Ae=I||!n.compact&&n.items.length>0?(0,X.jsxs)(`button`,{type:`button`,disabled:!Ee,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:Ee?()=>z({active:I,value:!se}):void 0,"aria-expanded":Ee?se:void 0,children:[(0,X.jsx)(Gt,{className:Y(`size-4 shrink-0`,I&&`assistant-activity-busy`),"aria-hidden":!0}),(0,X.jsx)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:(0,X.jsx)(`span`,{className:Y(`flex w-full min-w-0 items-center`,I?`h-6`:`min-h-6`),children:Ce})}),(0,X.jsx)(`span`,{className:`flex shrink-0 items-start justify-end`,children:Te}),Ee?(0,X.jsx)(re,{className:Y(`size-4 shrink-0 text-fg-muted transition-transform motion-reduce:transition-none`,se&&`rotate-180`),"aria-hidden":!0}):null]}):null,t[197]=I,t[198]=se,t[199]=Te,t[200]=Ce,t[201]=Ee,t[202]=n.compact,t[203]=n.items.length,t[204]=Ae):Ae=t[204];let je;t[205]!==I||t[206]!==s||t[207]!==c||t[208]!==x||t[209]!==be||t[210]!==i||t[211]!==n.items?(je=x&&n.items.filter(ev).map(e=>(0,X.jsx)(Cv,{block:e,toolLabels:i,stepLabels:be,cardLabels:s,conversationId:c,surfaceOnly:!0,runActive:I},e.id)),t[205]=I,t[206]=s,t[207]=c,t[208]=x,t[209]=be,t[210]=i,t[211]=n.items,t[212]=je):je=t[212];let Me;t[213]!==I||t[214]!==s||t[215]!==k.activityEarlier||t[216]!==c||t[217]!==se||t[218]!==ne||t[219]!==ge||t[220]!==H||t[221]!==v||t[222]!==J||t[223]!==be||t[224]!==i?(Me=se||ne?(0,X.jsx)(`div`,{className:`assistant-activity-disclosure`,"data-open":se,"aria-hidden":!se,inert:!se,children:(0,X.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:(0,X.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:[ge>0?(0,X.jsx)(`button`,{type:`button`,className:`mb-3 text-xs text-fg-muted hover:text-fg`,onClick:()=>U(!0),children:k.activityEarlier}):null,(0,X.jsx)(mv,{blocks:J,toolLabels:i,stepLabels:be,cardLabels:s,conversationId:c,animateNew:I&&se&&!H,runActive:I,showThinking:v})]})})}):null,t[213]=I,t[214]=s,t[215]=k.activityEarlier,t[216]=c,t[217]=se,t[218]=ne,t[219]=ge,t[220]=H,t[221]=v,t[222]=J,t[223]=be,t[224]=i,t[225]=Me):Me=t[225];let Ne;return t[226]!==ke||t[227]!==Ae||t[228]!==je||t[229]!==Me||t[230]!==n.status?(Ne=(0,X.jsxs)(`div`,{"data-assistant-work-log":!0,"data-work-log-status":De,className:ke,children:[Ae,je,Me]}),t[226]=ke,t[227]=Ae,t[228]=je,t[229]=Me,t[230]=n.status,t[231]=Ne):Ne=t[231],Ne}function ev(e){return e.type===`tool_use`}function tv(e){return e.type===`tool_use`}function nv(e){return e.type===`tool_use`&&Ia(e)}function rv(e){return e.type===`tool_use`}function iv(e){return e.type===`tool_use`}function av(e){return e.type===`thinking`&&e.streaming}function ov(e){return e.type===`tool_use`&&e.status===`running`}function sv(e){return e.type===`thinking`&&e.streaming}function cv(e){return e.type===`tool_use`&&(e.status===`running`||e.activity?.status===`running`)}function lv(e){return e.type===`tools`?e.tools:[e.item]}function uv(e){return Fr(e)||e.type===`tool_use`||e.type===`text`&&e.segmentId}function dv(e){return e.type!==`text`}function fv(e){return e.showRawToolData}function pv(e){return e.language}function mv({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(Z_))),u=Es(e=>e.showRawToolData),d=y(e=>e.language),f=u?e.map(e=>({type:`item`,item:e})):q_(e);return e.length>0?(0,X.jsx)(`div`,{className:Y(`min-w-0 overflow-x-hidden`,i),children:(0,X.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=Z_(f,i);return(0,X.jsx)(`div`,{className:Y(o&&!l.current.has(p)&&f.type!==`text`&&`assistant-activity-enter`),children:e.type===`tools`?(0,X.jsx)(hv,{tools:e.tools,runActive:s,labels:n,language:d,renderTool:e=>(0,X.jsx)(Cv,{block:e,toolLabels:t,stepLabels:n,cardLabels:r,conversationId:a,runActive:s},e.id)}):e.item.type===`thinking`&&c&&!u?(0,X.jsx)(`div`,{"data-assistant-thinking":!0,className:`text-sm leading-relaxed text-fg-muted`,children:(0,X.jsx)(np,{content:e.item.text,compact:!0,streaming:!!(s&&e.item.streaming)})}):(0,X.jsx)(Cv,{block:e.item,toolLabels:t,stepLabels:n,cardLabels:r,conversationId:a,runActive:s})},p)})})}):null}function hv(e){let t=(0,Z.c)(35),{tools:n,runActive:r,labels:i,language:a,renderTool:o}=e,s;t[0]!==r||t[1]!==n?(s=r&&n.some(_v),t[0]=r,t[1]=n,t[2]=s):s=t[2];let c=s,l,u,d,f,p,m,h,g;if(t[3]!==i||t[4]!==a||t[5]!==o||t[6]!==r||t[7]!==c||t[8]!==n){g=Symbol.for(`react.early_return_sentinel`);bb0:{let e=C(a).chat,s=c?[...n].reverse().find(gv):void 0,_=n.filter(e=>e!==s),v;t[17]!==i||t[18]!==r?(v=e=>La(e,r&&(e.status===`running`||e.activity?.status===`running`)?`running`:`completed`,i.toolActivity,i,i.runningActions),t[17]=i,t[18]=r,t[19]=v):v=t[19];let y=J_(_,v,{repeated:e.activityRepeated,more:e.activityMore,failed:e.activityFailed,separator:a===`zh`?`、`:`, `});if(n.length===1){let e;t[20]!==o||t[21]!==n[0]?(e=o(n[0]),t[20]=o,t[21]=n[0],t[22]=e):e=t[22],g=e;break bb0}p=!0,m=`min-w-0 space-y-1.5`,h=s?o(s):null,d=`min-w-0 text-[13px] text-fg-muted`,f=(0,X.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,X.jsx)(`span`,{children:y})}),l=`mt-2 min-w-0 space-y-2.5 border-l border-edge-subtle pl-3`,u=_.map(o)}t[3]=i,t[4]=a,t[5]=o,t[6]=r,t[7]=c,t[8]=n,t[9]=l,t[10]=u,t[11]=d,t[12]=f,t[13]=p,t[14]=m,t[15]=h,t[16]=g}else l=t[9],u=t[10],d=t[11],f=t[12],p=t[13],m=t[14],h=t[15],g=t[16];if(g!==Symbol.for(`react.early_return_sentinel`))return g;let _;t[23]!==l||t[24]!==u?(_=(0,X.jsx)(`div`,{className:l,children:u}),t[23]=l,t[24]=u,t[25]=_):_=t[25];let v;t[26]!==_||t[27]!==d||t[28]!==f?(v=(0,X.jsxs)(`details`,{className:d,children:[f,_]}),t[26]=_,t[27]=d,t[28]=f,t[29]=v):v=t[29];let y;return t[30]!==v||t[31]!==p||t[32]!==m||t[33]!==h?(y=(0,X.jsxs)(`div`,{"data-activity-group":p,className:m,children:[h,v]}),t[30]=v,t[31]=p,t[32]=m,t[33]=h,t[34]=y):y=t[34],y}function gv(e){return e.status===`running`||e.activity?.status===`running`}function _v(e){return e.status===`running`||e.activity?.status===`running`}function vv(e){let t=(0,Z.c)(15),{toolName:n,toolResult:r}=e,i=to(),a=G_(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,X.jsx)(W_,{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 yv=new Set([`readFile`,`editFile`,`writeFile`,`runCommand`,`fetchUrl`]),bv=240;function xv(e){let t=e.split(`
26
+ `).map(e=>e.trim()).find(Boolean)??``;return t.length<=bv?t:`${t.slice(0,bv)}…`}function Sv(e,t,n){let r=Ra(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 xv(t)}return xv(r.text)||t}function Cv(e){let t=(0,Z.c)(137),{block:n,toolLabels:r,stepLabels:i,cardLabels:a,conversationId:o,surfaceOnly:s,runActive:c}=e,l=s!==void 0&&s,u=c===void 0||c,d;t[0]===n?d=t[1]:(d=Fr(n),t[0]=n,t[1]=d);let f=ag(o,d),p=f?.type===n.type?f:n,m=Es(Tv),g=y(wv),_;bb0:{if(p.type!==`tool_use`){_=``;break bb0}if(p.status===`running`){_=``;break bb0}let e=p.result;if(e==null){_=``;break bb0}if(typeof e==`string`){let n;t[2]===e?n=t[3]:(n=e.trim(),t[2]=e,t[3]=n),_=n;break bb0}try{let n;t[4]===e?n=t[5]:(n=JSON.stringify(e,null,2),t[4]=e,t[5]=n),_=n}catch{_=String(e)}}let v=_;if(p.type===`text`){let e;t[6]===p.text?e=t[7]:(e=p.text.trim(),t[6]=p.text,t[7]=e);let n=e;if(!n)return null;let r=p.presentation===`pending`,i;return t[8]!==r||t[9]!==n?(i=(0,X.jsx)(`div`,{className:`min-w-0 text-sm leading-relaxed text-fg-muted`,children:(0,X.jsx)(np,{content:n,compact:!0,streaming:r})}),t[8]=r,t[9]=n,t[10]=i):i=t[10],i}if(p.type===`thinking`){let e=!!p.streaming,n;t[11]===p.text?n=t[12]:(n=p.text?.trim()??``,t[11]=p.text,t[12]=n);let r=n;if(!m||!r)return null;let a=e?i.thoughtsStreaming:i.thoughts,o;t[13]===a?o=t[14]:(o=(0,X.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]!==m||t[16]!==i.rawThinking||t[17]!==e||t[18]!==r?(s=m&&r?(0,X.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer select-none text-fg-subtle underline-offset-2 hover:text-fg-muted`,children:i.rawThinking}),(0,X.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-xs leading-relaxed text-fg-muted [overflow-wrap:anywhere]`,children:r})]}):e?(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`…`}):null,t[15]=m,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,X.jsx)(`div`,{className:`min-w-0`,children:(0,X.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 b=u&&(p.status===`running`||p.activity?.status===`running`),x;t[23]!==p||t[24]!==l?(x=l?p.status===`error`||p.activity?.status===`failed`:Ia(p),t[23]=p,t[24]=l,t[25]=x):x=t[25];let S=x,w;t[26]!==p||t[27]!==a||t[28]!==S||t[29]!==i.toolError?(w=S?Sv(p,i.toolError,a):``,t[26]=p,t[27]=a,t[28]=S,t[29]=i.toolError,t[30]=w):w=t[30];let T=w,E=v,D;t[31]!==p.name||t[32]!==E?(D=p.name===`codemode`?X_(E??``):void 0,t[31]=p.name,t[32]=E,t[33]=D):D=t[33];let O=D,k=b&&p.details&&typeof p.details==`object`&&!Array.isArray(p.details)&&typeof p.details.text==`string`?p.details.text:``,A=E??``;if(A)try{let e;t[34]===A?e=t[35]:(e=JSON.stringify(JSON.parse(A),null,2),t[34]=A,t[35]=e),A=e}catch{}let j,M,N,P,F;if(t[36]!==p||t[37]!==S||t[38]!==b||t[39]!==g||t[40]!==i.editFile||t[41]!==i.fetchUrl||t[42]!==i.listDirectory||t[43]!==i.memoryActivity||t[44]!==i.openUrl||t[45]!==i.readFile||t[46]!==i.runCommand||t[47]!==i.runningActions||t[48]!==i.searched||t[49]!==i.searchedCode||t[50]!==i.searchedMemory||t[51]!==i.searchedWeb||t[52]!==i.toolActivity||t[53]!==i.toolError||t[54]!==i.unknownTool||t[55]!==i.writeFile){M=qg(p.name,p.activity),j=yv.has(M),N=p.name===`personal_memory`?i_(p,g===`zh`):M===`memorySearch`?r_(p,i.memoryActivity):null;let e={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},n=La(p,b||S?`running`:`completed`,i.toolActivity,e,i.runningActions);F=S?M===`other`&&!Pa(p.name)?i.toolError:i.toolActivity.stepFailed.replace(`{{operation}}`,n.replace(/^正在|[.…]+$/g,``)):N?.title??n,P=S?Zt:M.includes(`Search`)||M===`search`?zt:M===`readFile`?W:M===`editFile`||M===`writeFile`?Zs:M===`fetchUrl`||M===`openUrl`?Me:ge,t[36]=p,t[37]=S,t[38]=b,t[39]=g,t[40]=i.editFile,t[41]=i.fetchUrl,t[42]=i.listDirectory,t[43]=i.memoryActivity,t[44]=i.openUrl,t[45]=i.readFile,t[46]=i.runCommand,t[47]=i.runningActions,t[48]=i.searched,t[49]=i.searchedCode,t[50]=i.searchedMemory,t[51]=i.searchedWeb,t[52]=i.toolActivity,t[53]=i.toolError,t[54]=i.unknownTool,t[55]=i.writeFile,t[56]=j,t[57]=M,t[58]=N,t[59]=P,t[60]=F}else j=t[56],M=t[57],N=t[58],P=t[59],F=t[60];let I=P,L;t[61]!==p.input||t[62]!==N?(L=N?``:d_(p.input),t[61]=p.input,t[62]=N,t[63]=L):L=t[63];let R=L,z;t[64]===p.input?z=t[65]:(z=p.input===void 0?``:a_(p.input),t[64]=p.input,t[65]=z);let B=z,V;t[66]!==p||t[67]!==a||t[68]!==j||t[69]!==M?(V=j?M===`readFile`?(0,X.jsx)(O_,{block:p,labels:a}):M===`editFile`?(0,X.jsx)(j_,{block:p,labels:a}):M===`writeFile`?(0,X.jsx)(N_,{block:p,labels:a}):M===`runCommand`?(0,X.jsx)(I_,{block:p,labels:a}):M===`fetchUrl`?(0,X.jsx)(L_,{block:p,labels:a}):null:null,t[66]=p,t[67]=a,t[68]=j,t[69]=M,t[70]=V):V=t[70];let H=V;if(l){let e;t[71]!==p.name||t[72]!==p.result||t[73]!==S||t[74]!==b?(e=!b&&!S?(0,X.jsx)(vv,{toolName:p.name,toolResult:p.result}):null,t[71]=p.name,t[72]=p.result,t[73]=S,t[74]=b,t[75]=e):e=t[75];let n;return t[76]===e?n=t[77]:(n=(0,X.jsx)(X.Fragment,{children:e}),t[76]=e,t[77]=n),n}let U=!b&&m,ee=p.parentToolCallId?`ml-4 min-w-0 border-l border-edge pl-3`:`min-w-0`,te=S?`failed`:b?`running`:`completed`,ne=b&&`assistant-activity-busy`,re;t[78]===ne?re=t[79]:(re=Y(`mt-0.5 size-4 shrink-0 text-fg-subtle`,ne),t[78]=ne,t[79]=re);let ie;t[80]!==I||t[81]!==re?(ie=(0,X.jsx)(I,{className:re,"aria-hidden":!0}),t[80]=I,t[81]=re,t[82]=ie):ie=t[82];let ae;t[83]===F?ae=t[84]:(ae=(0,X.jsx)(`span`,{className:`inline-flex max-w-full min-w-0 break-words text-[13px] text-fg-muted [overflow-wrap:anywhere]`,children:F}),t[83]=F,t[84]=ae);let oe;t[85]!==te||t[86]!==ie||t[87]!==ae?(oe=(0,X.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,"data-activity-status":te,children:[ie,ae]}),t[85]=te,t[86]=ie,t[87]=ae,t[88]=oe):oe=t[88];let se;t[89]!==H||t[90]!==i.stepDetails?(se=H?(0,X.jsxs)(`details`,{className:`min-w-0 text-xs text-fg-muted`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer hover:text-fg`,children:i.stepDetails}),H]}):null,t[89]=H,t[90]=i.stepDetails,t[91]=se):se=t[91];let ce;t[92]!==p||t[93]!==b||t[94]!==M||t[95]!==g||t[96]!==m||t[97]!==i.stepDetails?(ce=M===`webSearch`&&!b?(0,X.jsx)(H_,{block:p,summary:i.stepDetails,labels:C(g).chat.searchDetails,developer:m,language:g}):null,t[92]=p,t[93]=b,t[94]=M,t[95]=g,t[96]=m,t[97]=i.stepDetails,t[98]=ce):ce=t[98];let le;t[99]!==N||t[100]!==i.memoryActivity?(le=N?(0,X.jsxs)(`div`,{className:`space-y-1 text-xs text-fg-muted`,children:[(0,X.jsx)(`p`,{children:N.purpose}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1`,children:[(0,X.jsx)(h,{className:`font-medium text-accent-fg hover:underline`,to:`/user-model`,children:i.memoryActivity.manage}),(0,X.jsx)(h,{className:`font-medium text-accent-fg hover:underline`,to:`/user-model`,children:i.memoryActivity.privacy})]}),(0,X.jsxs)(`details`,{children:[(0,X.jsx)(`summary`,{className:`cursor-pointer select-none text-fg-subtle hover:text-fg-muted`,children:i.memoryActivity.why}),(0,X.jsx)(`div`,{className:`mt-1.5 rounded-md bg-surface-hover/60 px-2 py-1.5 dark:bg-surface-hover/35`,children:(0,X.jsx)(`p`,{children:i.memoryActivity.explanation})})]})]}):null,t[99]=N,t[100]=i.memoryActivity,t[101]=le):le=t[101];let ue;t[102]!==T||t[103]!==m?(ue=T&&m?(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:T}):null,t[102]=T,t[103]=m,t[104]=ue):ue=t[104];let de;t[105]!==R||t[106]!==j||t[107]!==m?(de=m&&!j&&R?(0,X.jsx)(`p`,{className:`min-w-0 break-words text-xs text-fg-muted [overflow-wrap:anywhere]`,children:R}):null,t[105]=R,t[106]=j,t[107]=m,t[108]=de):de=t[108];let fe;t[109]!==k||t[110]!==m?(fe=m&&k?(0,X.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:k}):null,t[109]=k,t[110]=m,t[111]=fe):fe=t[111];let pe;t[112]!==o||t[113]!==g||t[114]!==O?(pe=O?(0,X.jsx)(Y_,{path:O,conversationId:o,label:g===`zh`?`查看完整输出`:`View full output`}):null,t[112]=o,t[113]=g,t[114]=O,t[115]=pe):pe=t[115];let G;t[116]!==a||t[117]!==j||t[118]!==A||t[119]!==B||t[120]!==U||t[121]!==i.stepDetails||t[122]!==r?(G=U?(0,X.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer select-none text-fg-subtle underline-offset-2 hover:text-fg-muted group-open:text-fg-muted`,children:j?a.rawDetails:i.stepDetails}),(0,X.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:[B?(0,X.jsxs)(`div`,{className:`mb-2 min-w-0`,children:[(0,X.jsx)(`div`,{className:`mb-0.5 text-[10px] uppercase tracking-wide text-fg-disabled`,children:r.input}),(0,X.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-fg-muted [overflow-wrap:anywhere]`,children:B})]}):null,(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`div`,{className:`mb-0.5 text-[10px] uppercase tracking-wide text-fg-disabled`,children:r.output}),(0,X.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-fg-muted [overflow-wrap:anywhere]`,children:A||r.noOutput})]})]})]}):null,t[116]=a,t[117]=j,t[118]=A,t[119]=B,t[120]=U,t[121]=i.stepDetails,t[122]=r,t[123]=G):G=t[123];let me;t[124]!==oe||t[125]!==se||t[126]!==ce||t[127]!==le||t[128]!==ue||t[129]!==de||t[130]!==fe||t[131]!==pe||t[132]!==G?(me=(0,X.jsxs)(`div`,{className:`min-w-0 space-y-1.5`,children:[oe,se,ce,le,ue,de,fe,pe,G]}),t[124]=oe,t[125]=se,t[126]=ce,t[127]=le,t[128]=ue,t[129]=de,t[130]=fe,t[131]=pe,t[132]=G,t[133]=me):me=t[133];let he;return t[134]!==ee||t[135]!==me?(he=(0,X.jsx)(`div`,{className:ee,children:me}),t[134]=ee,t[135]=me,t[136]=he):he=t[136],he}function wv(e){return e.language}function Tv(e){return e.showRawToolData}function Ev(e){return e+1}function Dv(e){let t=(0,Z.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,X.jsx)(Co,{delayDuration:300,skipDelayDuration:100,children:n}),t[0]=n,t[1]=r),r}function Ov(e){let t=(0,Z.c)(7),{label:n,children:r}=e,i;t[0]===r?i=t[1]:(i=(0,X.jsx)(Do,{asChild:!0,children:r}),t[0]=r,t[1]=i);let a;t[2]===n?a=t[3]:(a=(0,X.jsx)(wo,{children:(0,X.jsx)(Eo,{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,X.jsxs)(To,{children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}var kv=`NO_REPLY`;function Av(e,t){if(e.role!==`assistant`||!e.content?.length)return e;if(t?.hideSilentReply){let n=t.streaming?e.content.findLast(e=>e.type===`text`):void 0,r=e.content.filter(e=>{if(e.type!==`text`)return!0;let t=e.text.trim();return t!==kv&&!(e===n&&e.presentation===`pending`&&t&&kv.startsWith(t))});if(r.length!==e.content.length)return Av({...e,content:r},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===kv||t.streaming&&i.length>0&&kv.startsWith(i)))return{...e,content:e.content.filter((e,t)=>t!==n)};if(!i.startsWith(kv))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 jv(e,t=!1){return t||e.textSurface===`conversation`}function Mv(e,t){return e.renderKey??`${e.timestamp??`n`}-${t}`}var Nv=new WeakMap;function Pv(e,t){let n=Nv.get(e);if(n?.personal===t)return n.text;let r=Or(ur(Av(e,{hideSilentReply:jv(e,t),streaming:!1}).content??[]).flatMap(e=>e.type===`text`?[e.text]:[]).join(`
27
27
 
28
- `));return Fv.set(e,{personal:t,text:r}),r}function Lv(e,t,n,r,i,a){if(e.role!==`assistant`||e.pendingResponseStatus||e.attachments?.some(e=>e.mimeType?.startsWith(`audio/`)))return;let o=Iv(e,a);if(!o)return;let s=e.turnId&&!e.beforeSteer&&!e.startsNewBubble?`turn:${e.turnId}`:`row:${e.renderKey??e.transcriptEntryId??Pv(e,t)}`;return{source:{type:`chat-message`,id:`${n??`chat`}:${s}`,conversationId:n??void 0,title:o.split(`
29
- `)[0]?.slice(0,48)||i,href:n?`#/chat/${encodeURIComponent(n)}`:void 0,targetId:`chat-message-${t}`},text:o,language:Pr(o,r)}}function Rv(e,t,n,r){let i=(0,Z.c)(13),a=r!==void 0&&r,o=y(Bv),s;i[0]===o?s=i[1]:(s=C(o),i[0]=o,i[1]=s);let c=s.chat.messageReadAloudTitle,l=(0,Q.useRef)(null),u,d;i[2]===e?(u=i[3],d=i[4]):(u=()=>{if(!e)return;let t=Mr(e);return l.current=t,()=>{l.current=null,t.dispose()}},d=[e],i[2]=e,i[3]=u,i[4]=d),(0,Q.useLayoutEffect)(u,d);let f,p;i[5]!==e||i[6]!==c||i[7]!==o||i[8]!==t||i[9]!==a||i[10]!==n?(f=()=>{if(!l.current)return;let r=n?t.findLastIndex(zv):-1;l.current.update(t.flatMap((t,n)=>{if(n===r)return[];let i=Lv(t,n,e,o,c,a);return i?[i]:[]}))},p=[e,c,o,t,a,n],i[5]=e,i[6]=c,i[7]=o,i[8]=t,i[9]=a,i[10]=n,i[11]=f,i[12]=p):(f=i[11],p=i[12]),(0,Q.useLayoutEffect)(f,p)}function zv(e){return!e.pendingSteer}function Bv(e){return e.language}function Vv(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 Hv(e){return e.filter(e=>e.type===`thinking`||e.type===`tool_use`)}function Uv(e){let t=ni(e,`running`);return t.category===`web`&&t.action===`search`}function Wv(e){let t=[];for(let n of e)if(!(!Uv(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 Gv(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Kv(e){let t=Gv(e);return t?qv(_n(t.delivery)??_n(Gv(t.details)?.delivery)??_n(e),t):null}function qv(e,t){let n=e?.primary;if(!e||n?.kind!==`automation`||n.runId||e.operation!==`started`)return e;let r=Gv(t),i=Gv((Gv(r?.result)??r)?.run);return i?.automationId!==n.id||typeof i.id!=`string`||!i.id?e:{...e,primary:{...n,runId:i.id}}}function Jv(e){let t=Kv(e.details);if(t)return t;let n=Ba(e.result),r=Kv(n.details);if(r)return r;let i=vn(n.text);if(i)try{return qv(i,JSON.parse(n.text.split(`
30
- Open in xopc:`)[0]))}catch{return i}if(typeof e.result==`string`)try{return Kv(JSON.parse(e.result))}catch{return null}return Kv(e.result)}function Yv(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 Xv(e){return e.normalize(`NFKC`).trim().replace(/\s+/g,` `).toLowerCase()}function Zv(e){return e.operation!==`opened`||e.presentation?.kind===`diff`||e.presentation?.kind===`inline_app`||e.presentation?.kind===`inline_preview`}function Qv(e){return e.flatMap(({key:e,delivery:t})=>t.presentation?.kind===`diff`?[{key:e,presentation:t.presentation}]:[])}function $v(e){return{truncated:e.flatMap(({delivery:e})=>e.presentation?.kind===`table`?[e.presentation]:[]).some(e=>e.truncated)}}function ey(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 ty(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 ny(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=Xv(e.reference.title);t&&i.set(t,e.reference.id)}return r.filter(e=>{if(e.reference.kind!==`task`)return!0;let t=Xv(e.reference.title);return!t||i.get(t)===e.reference.id})}function ry(e){return Zv(e)?e.presentation||e.related?.length?!0:e.primary?e.primary.kind!==`note`||e.operation===`created`||e.operation===`updated`:!1:!1}function iy({message:e,isStreaming:t,reasoningLevel:n}){let r=e.beforeSteer?e.content.filter(e=>e.type===`text`||e.type===`review`):ur(e.content??[],{includePending:!0}),i=new Set(r),a=$g(Hv(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=Jv(e);t&&ry(t)&&u.set(e.id,t)}let d=[...u].map(([e,t])=>({key:e,delivery:t})),f=Vv(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=[...Gh(_),...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:Wv(c)}}function ay(e){let t=(0,Z.c)(10),{blocks:n,sources:r,className:i}=e,a=n===void 0?[]:n,o=i===void 0?`mt-6`:i,s=C(y(cy)),c=a.filter(sy),l=r??Wv(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,X.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(oy),t[2]=l,t[3]=f);let p;t[4]===f?p=t[5]:(p=(0,X.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,X.jsxs)(`div`,{className:o,children:[d,p]}),t[6]=o,t[7]=d,t[8]=p,t[9]=m):m=t[9],m}function oy(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,X.jsxs)(`li`,{className:`flex min-w-0 gap-2.5`,children:[(0,X.jsxs)(`span`,{className:`mt-0.5 shrink-0 text-xs text-fg-disabled`,children:[t+1,`.`]}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-1.5`,children:[r?(0,X.jsx)(`img`,{src:r,alt:``,className:`mt-0.5 size-3.5 shrink-0 rounded-sm`,"aria-hidden":!0}):null,(0,X.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,X.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 sy(e){return e.type===`tool_use`}function cy(e){return e.language}var ly=(0,Q.createContext)(!1);function uy(e){let t=(0,Z.c)(41),{entries:n,language:r,renderEntry:i}=e,[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null),c=(0,Q.useRef)(null),l=(0,Q.useRef)(0),u=(0,Q.useRef)(!1),d=f(),p;t[0]===d.search?p=t[1]:(p=new URLSearchParams(d.search).has(Je),t[0]=d.search,t[1]=p);let m=p,h,g;t[2]!==n.length||t[3]!==r?(h=C(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,y;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>{u.current=!e,o(e)},t[6]=y):y=t[6];let b;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,X.jsx)(mc,{}),t[7]=b):b=t[7];let x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,X.jsx)(ie,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[8]=x):x=t[8];let S;t[9]===_?S=t[10]:(S=(0,X.jsx)(T,{asChild:!0,children:(0,X.jsx)(`button`,{ref:s,type:`button`,className:Ss,children:(0,X.jsx)(Cs,{icon:b,title:_,trailing:x})})}),t[9]=_,t[10]=S);let M;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,X.jsx)(w,{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(),c.current?.focus({preventScroll:!0})},N=e=>{e.preventDefault(),u.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,X.jsx)(A,{ref:c,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,X.jsx)(an,{className:`size-4`,"aria-hidden":!0}),t[16]=I):I=t[16];let L;t[17]===h.closeTaskList?L=t[18]:(L=(0,X.jsx)(D,{"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,X.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,X.jsx)(E,{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=l.current)},V=e=>{l.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,X.jsx)(`div`,{"data-task-delivery-list":!0,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,ref:B,onScroll:V,children:(0,X.jsx)(`ul`,{className:`${Ds} p-3`,children:H})}),t[31]=H,t[32]=U);let W;t[33]!==R||t[34]!==z||t[35]!==U?(W=(0,X.jsxs)(O,{children:[M,(0,X.jsxs)(k,{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 ee;return t[37]!==W||t[38]!==v||t[39]!==S?(ee=(0,X.jsx)(`li`,{className:`min-w-0 max-w-full`,"data-product-task-group":!0,children:(0,X.jsxs)(j,{open:v,onOpenChange:y,children:[S,W]})}),t[37]=W,t[38]=v,t[39]=S,t[40]=ee):ee=t[40],ee}var dy={agent:Qt,task:mc,project:Oe,note:dc,automation:te,local_app:N,chat_preview:ac,file:Ee,session:uc,settings:Vt};function fy(e,t){let n=e?.trim();return n?C(t).chat.productDelivery.statuses[n.toLowerCase()]??n:null}function py(e,t,n){let r=C(n).chat.productDelivery.operations[e.operation],i=fy(t.status,n);return i&&e.operation===`opened`?i:i&&i.toLowerCase()!==r.toLowerCase()?`${r} · ${i}`:i??r}function my(e,t,n){let r=C(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 hy(e,t){let n=C(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 gy({delivery:e,reference:t,language:n,conversationId:r,projectId:i,fullTitle:a=!1}){let o=p(),s=f(),c=Ti(e=>e.setPath),l=dy[t.kind],u=pn(t),d=t.kind===`file`&&t.capabilities.includes(`preview`)?Yv(t.id):null,m=!!(d&&(r?.trim()||i?.trim())),h=m||!!(u&&t.capabilities.includes(`open`)),g=t.kind!==`note`&&t.kind!==`task`&&t.capabilities.includes(`continue_in_chat`),_=e.operation===`failed`,y=v(e=>e.conversationId),b=t.kind===`agent`?C(n).agentsSettings:null,{data:x}=bi(b&&y?[`gateway-chat-agents`,y]:null,Mi),S=x?.items.find(e=>e.id===t.id),w=b&&S?mo(S,b):t.title,T=bi(t.kind===`task`?[`task-delivery`,t.id,y]:null,()=>Ai(t.id),{revalidateOnFocus:!0}),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{if(t.kind!==`task`)return;let e=e=>{let n=e.detail?.taskId;(!n||n===t.id)&&T.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.kind,t.id,T.mutate]);let A=t.kind===`task`?my(e,{phase:T.data?.task.phase,resolution:T.data?.task.resolution,operationalState:T.data?.operationalState??t.status,attention:T.data?.attention},n):py(e,t,n),j=T.data?.presentation?.primaryAction,M=j?.type===`resolve_wait`?T.data?.waits.find(e=>e.id===j.waitId&&e.condition.type===`connection`)?.taskRunId:void 0,N=j?.type===`retry_run`?j.runId:M,P=async e=>{D(!0),k(``);try{let i=await Si(t.id,e);k(Oi(i,n)),i.status===`waiting_connection`&&i.connectionConversationId&&i.connectionConversationId!==r&&o(`/chat/${encodeURIComponent(i.connectionConversationId)}`),T.mutate()}catch{k(Oi({status:`changed`},n))}finally{D(!1)}};return t.kind===`automation`&&e.operation!==`failed`?(0,X.jsx)(`li`,{className:`min-w-0 max-w-full`,children:(0,X.jsx)(ws,{automationId:t.id,runId:t.runId,language:n,embedded:!0})}):(0,X.jsxs)(`li`,{className:`flex max-w-full min-w-0 flex-wrap items-center gap-2`,"data-product-delivery":t.kind,children:[(0,X.jsx)(`button`,{type:`button`,onClick:h?()=>{if(d&&m){c(d,null,i,r);return}if(t.kind===`task`){o($e(`${s.pathname}${s.search}`,t.id));return}if(t.kind===`note`){o(et(`${s.pathname}${s.search}`,t.id));return}if(u){let e=new URL(u,`https://xopc.local`);t.projectId&&e.searchParams.set(`projectId`,t.projectId),t.kind===`local_app`&&t.revision&&/^[a-f0-9]{64}$/.test(t.revision)&&e.searchParams.set(`sourceHash`,t.revision),o(Ye(Ze(`${s.pathname}${s.search}`,`${e.pathname}${e.search}`),`${s.pathname}${s.search}`))}}:void 0,disabled:!h,title:[w,A,t.summary?.trim()].filter(Boolean).join(` · `),className:Y(Ss,h?`cursor-pointer`:`cursor-default`,_&&`text-danger`),children:(0,X.jsx)(Cs,{icon:b?(0,X.jsx)(io,{agentId:t.id,avatar:S?.avatar,size:18}):(0,X.jsx)(l,{strokeWidth:1.75,className:_?`text-danger`:void 0}),title:w,meta:b?b.backToEditor:A,fullTitle:a,trailing:h?(0,X.jsx)(ie,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}):null})}),N&&(0,X.jsx)(`button`,{type:`button`,className:`touch-manipulation inline-flex min-h-11 w-fit max-w-full min-w-0 items-center gap-2 rounded-[1.125rem] bg-surface-inset px-3 py-2 text-left text-sm text-fg transition-colors duration-150 motion-reduce:transition-none hover:bg-surface-hover active:bg-surface-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,disabled:E,onClick:()=>void P(N),children:M?n===`zh`?`检查连接并继续`:`Check connection and resume`:n===`zh`?`重试任务`:`Retry task`}),O&&(0,X.jsx)(`span`,{role:`status`,className:`text-xs text-fg-muted`,children:O}),b&&h&&!_?(0,X.jsx)(`button`,{type:`button`,className:Ss,onClick:()=>$a(o,`/chat/new?projectScope=none`,{state:{agentId:t.id,forceNewChat:!0,fromAgentEditor:!0}}),children:b.listChatWithAgent}):g?(0,X.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`,Pa.transition,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`),onClick:()=>eh(hy(t,n)),children:C(n).chat.productDelivery.continue}):null]})}function _y(e){let t=(0,Z.c)(23),{entries:n,language:r,conversationId:i,projectId:a}=e,o;t[0]!==n.length||t[1]!==r?(o=C(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(Ss,`cursor-pointer list-none`),t[3]=c):c=t[3];let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,X.jsx)(tc,{strokeWidth:1.75}),t[4]=l):l=t[4];let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,X.jsx)(ie,{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,X.jsx)(`summary`,{className:c,children:(0,X.jsx)(Cs,{icon:l,title:s,trailing:u})}),t[6]=s,t[7]=d);let f;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(f=Y(Ds,Es),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,X.jsx)(gy,{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,X.jsx)(`ul`,{className:f,children:p}),t[18]=p,t[19]=m);let h;return t[20]!==d||t[21]!==m?(h=(0,X.jsx)(`li`,{className:`min-w-0 max-w-full`,"data-product-file-group":!0,children:(0,X.jsxs)(`details`,{className:`group`,children:[d,m]})}),t[20]=d,t[21]=m,t[22]=h):h=t[22],h}function vy(e){let t=(0,Z.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=ny(n,i),t=e.filter(Sy),l=e.findIndex(xy),u=e.filter(by),d=e.findIndex(yy);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,X.jsx)(uy,{entries:u,language:r,renderEntry:(e,t)=>(0,X.jsx)(gy,{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,X.jsx)(gy,{delivery:s,reference:c,language:r,conversationId:a,projectId:o},i):n===l?(0,X.jsx)(_y,{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,X.jsx)(X.Fragment,{children:s}),t[7]=s,t[8]=l),l}function yy(e){let{reference:t}=e;return t.kind===`task`}function by(e){let{reference:t}=e;return t.kind===`task`}function xy(e){let{reference:t}=e;return t.kind===`file`}function Sy(e){let{reference:t}=e;return t.kind===`file`}function Cy(e){let t=(0,Z.c)(22),{presentation:n}=e,r=y(wy),i;t[0]===r?i=t[1]:(i=C(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,X.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,X.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,X.jsxs)(`details`,{className:`rounded border border-edge-subtle p-2`,children:[(0,X.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,X.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,X.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,X.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,X.jsxs)(`section`,{className:`mt-2 rounded-lg bg-surface-inset 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 wy(e){return e.language}function Ty({previewId:e,reference:t,sourceHash:n,preferredHeight:r,language:i}){let a=p(),o=f(),s=(0,Q.useRef)(null),[c,l]=(0,Q.useState)(0),[u,d]=(0,Q.useState)(`booting`),[m,h]=(0,Q.useState)(null),[g,v]=(0,Q.useState)([]),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(null),w=Math.min(720,Math.max(240,r)),T=ka(e),E=bi(T.active?[`inline-local-app-snapshot`,t.id,n]:null,()=>Ps(t.id,n),{revalidateOnFocus:!1,shouldRetryOnError:!1});(0,Q.useEffect)(()=>{let e=s.current;if(!e||!E.data?.previewUrl)return;d(`booting`),h(null),v([]);let t=window.setTimeout(()=>{d(e=>e===`booting`?`timeout`:e)},7e3),n=js(e,e=>{let t=mn(e);if(t){if(t.type===`ready`){d(`healthy`);return}if(t.type===`error`){h(t.detail),d(`failed`),v(e=>[...e,{phase:`runtime`,message:Ms(t.detail),code:t.detail.kind}].slice(-20));return}if(t.type===`acceptance`&&t.detail.status===`failed`){d(`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`&&(d(`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()}},[c,E.data?.previewUrl]);let D=()=>{let e=pn(t);e&&a(Ze(`${o.pathname}${o.search}`,`${e}&sourceHash=${encodeURIComponent(n)}`))};if(!T.active)return(0,X.jsxs)(`section`,{ref:T.containerRef,className:`content-block-action-scope mt-3 overflow-hidden rounded-2xl bg-surface-inset`,"data-inline-local-app":t.id,children:[(0,X.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,title:t.title,children:t.title}),(0,X.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,X.jsx)(Yi,{variant:`ghost`,className:`content-block-action`,onClick:D,title:i===`zh`?`查看预览`:`Preview`,"aria-label":i===`zh`?`查看预览`:`Preview`,children:(0,X.jsx)(Ce,{className:`size-4`,"aria-hidden":!0})})]}),(0,X.jsx)(`div`,{className:`grid place-items-center bg-surface-base`,style:{height:w},children:(0,X.jsx)(Yi,{variant:`secondary`,onClick:T.activate,children:i===`zh`?`加载交互预览`:`Load interactive preview`})})]});if(E.isLoading)return(0,X.jsxs)(`section`,{ref:T.containerRef,className:`mt-3 overflow-hidden rounded-2xl bg-surface-inset`,"aria-label":C(i).chat.productDelivery.loadingAppPreview,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,X.jsx)(sn,{className:`h-5 w-40`}),(0,X.jsx)(sn,{className:`h-9 w-24`})]}),(0,X.jsx)(sn,{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,X.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,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Zt,{className:`size-4`}),t]})})}let k=O.validation.issues.map(e=>({phase:`build`,code:e.code,message:e.message}))??[],A=u===`timeout`?[{phase:`boot`,code:`boot_timeout`,message:C(i).chat.productDelivery.previewTimeout}]:[],j=[...k,...g,...A],M=O.status===`invalid`||O.validation.status===`failed`,N=M||u===`failed`||u===`timeout`,P=M?i===`zh`?`校验失败`:`Validation failed`:u===`healthy`?i===`zh`?`运行正常`:`Running`:u===`booting`?i===`zh`?`正在启动`:`Starting`:u===`timeout`?i===`zh`?`启动超时`:`Start timed out`:i===`zh`?`运行错误`:`Runtime error`,F=()=>{S(null),l(e=>e+1)},I=async()=>{if(j.length){b(!0),S(null);try{let e=await Fs(t.id,{sourceHash:O.sourceHash,locale:i,diagnostics:j});if(e.action===`retry`){F();return}let n=await Ns(t.id);a(As(n,e.prompt))}catch(e){S(e instanceof Error?e.message:String(e))}finally{b(!1)}}};return(0,X.jsxs)(`section`,{ref:T.containerRef,className:`content-block-action-scope mt-3 overflow-hidden rounded-2xl bg-surface-inset`,"data-inline-local-app":t.id,children:[(0,X.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,title:t.title,children:t.title}),(0,X.jsx)(`p`,{className:Y(`mt-0.5 text-xs`,N?`text-danger`:`text-fg-muted`),"aria-live":`polite`,children:P})]}),(0,X.jsx)(Yi,{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,X.jsx)(It,{className:`size-4`,"aria-hidden":!0})}),(0,X.jsx)(Yi,{variant:`ghost`,className:`content-block-action`,onClick:D,title:i===`zh`?`查看预览`:`Preview`,"aria-label":i===`zh`?`查看预览`:`Preview`,children:(0,X.jsx)(Ce,{className:`size-4`,"aria-hidden":!0})})]}),(0,X.jsxs)(`div`,{className:`relative bg-surface-base`,style:{height:w},children:[O.previewUrl?(0,X.jsx)(`iframe`,{ref:s,title:i===`zh`?`${t.title} 交互预览`:`${t.title} interactive preview`,src:_(O.previewUrl),sandbox:`allow-scripts allow-forms`,className:`h-full w-full border-0 bg-white`},c):null,O.previewUrl&&u===`booting`?(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-0 grid place-items-center bg-surface-base/75`,children:(0,X.jsx)(sn,{className:`h-10 w-40`})}):null]}),N?(0,X.jsxs)(`footer`,{className:`border-t border-danger/20 bg-danger-soft/60 px-4 py-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.jsx)(`p`,{className:`min-w-0 flex-1 text-xs text-danger`,children:m?.message??j[0]?.message??(i===`zh`?`预览校验失败`:`Preview validation failed`)}),(0,X.jsxs)(Yi,{variant:`secondary`,className:`min-h-9 px-3 text-xs`,disabled:y||j.length===0,onClick:()=>void I(),children:[(0,X.jsx)(rn,{className:`size-4`}),y?i===`zh`?`生成修复建议…`:`Preparing fix…`:i===`zh`?`让 Coder 修复`:`Ask Coder to fix`]})]}),x?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-danger`,role:`alert`,children:x}):null]}):null]})}async function Ey(e,t){return(await b(_(`/api/chat-previews/${encodeURIComponent(e)}/revisions/${encodeURIComponent(t)}`))).revision}async function Dy(e,t){return(await b(_(`/api/chat-previews/${encodeURIComponent(e)}/fix-guidance`),{method:`POST`,body:JSON.stringify(t)})).guidance}async function Oy(e,t){return(await b(_(`/api/chat-previews/${encodeURIComponent(e)}/promote`),{method:`POST`,body:JSON.stringify({sourceHash:t})})).app}function ky(e,t){return e.replace(RegExp(`</${t}`,`gi`),`<\\/${t}`)}function Ay(e){let t=hn.safeParse(e);return t.success?t.data:null}function jy(e,t){let n=`(() => {
28
+ `));return Nv.set(e,{personal:t,text:r}),r}function Fv(e,t,n,r,i,a){if(e.role!==`assistant`||e.pendingResponseStatus||e.attachments?.some(e=>e.mimeType?.startsWith(`audio/`)))return;let o=Pv(e,a);if(!o)return;let s=e.turnId&&!e.beforeSteer&&!e.startsNewBubble?`turn:${e.turnId}`:`row:${e.renderKey??e.transcriptEntryId??Mv(e,t)}`;return{source:{type:`chat-message`,id:`${n??`chat`}:${s}`,conversationId:n??void 0,title:o.split(`
29
+ `)[0]?.slice(0,48)||i,href:n?`#/chat/${encodeURIComponent(n)}`:void 0,targetId:`chat-message-${t}`},text:o,language:Pr(o,r)}}function Iv(e,t,n,r){let i=(0,Z.c)(13),a=r!==void 0&&r,o=y(Rv),s;i[0]===o?s=i[1]:(s=C(o),i[0]=o,i[1]=s);let c=s.chat.messageReadAloudTitle,l=(0,Q.useRef)(null),u,d;i[2]===e?(u=i[3],d=i[4]):(u=()=>{if(!e)return;let t=Mr(e);return l.current=t,()=>{l.current=null,t.dispose()}},d=[e],i[2]=e,i[3]=u,i[4]=d),(0,Q.useLayoutEffect)(u,d);let f,p;i[5]!==e||i[6]!==c||i[7]!==o||i[8]!==t||i[9]!==a||i[10]!==n?(f=()=>{if(!l.current)return;let r=n?t.findLastIndex(Lv):-1;l.current.update(t.flatMap((t,n)=>{if(n===r)return[];let i=Fv(t,n,e,o,c,a);return i?[i]:[]}))},p=[e,c,o,t,a,n],i[5]=e,i[6]=c,i[7]=o,i[8]=t,i[9]=a,i[10]=n,i[11]=f,i[12]=p):(f=i[11],p=i[12]),(0,Q.useLayoutEffect)(f,p)}function Lv(e){return!e.pendingSteer}function Rv(e){return e.language}function zv(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 Bv(e){return e.filter(e=>e.type===`thinking`||e.type===`tool_use`)}function Vv(e){let t=ni(e,`running`);return t.category===`web`&&t.action===`search`}function Hv(e){let t=[];for(let n of e)if(!(!Vv(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 Uv(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Wv(e){let t=Uv(e);return t?Gv(_n(t.delivery)??_n(Uv(t.details)?.delivery)??_n(e),t):null}function Gv(e,t){let n=e?.primary;if(!e||n?.kind!==`automation`||n.runId||e.operation!==`started`)return e;let r=Uv(t),i=Uv((Uv(r?.result)??r)?.run);return i?.automationId!==n.id||typeof i.id!=`string`||!i.id?e:{...e,primary:{...n,runId:i.id}}}function Kv(e){let t=Wv(e.details);if(t)return t;let n=Ra(e.result),r=Wv(n.details);if(r)return r;let i=vn(n.text);if(i)try{return Gv(i,JSON.parse(n.text.split(`
30
+ Open in xopc:`)[0]))}catch{return i}if(typeof e.result==`string`)try{return Wv(JSON.parse(e.result))}catch{return null}return Wv(e.result)}function qv(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 Jv(e){return e.normalize(`NFKC`).trim().replace(/\s+/g,` `).toLowerCase()}function Yv(e){return e.operation!==`opened`||e.presentation?.kind===`diff`||e.presentation?.kind===`inline_app`||e.presentation?.kind===`inline_preview`}function Xv(e){return e.flatMap(({key:e,delivery:t})=>t.presentation?.kind===`diff`?[{key:e,presentation:t.presentation}]:[])}function Zv(e){return{truncated:e.flatMap(({delivery:e})=>e.presentation?.kind===`table`?[e.presentation]:[]).some(e=>e.truncated)}}function Qv(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 $v(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 ey(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=Jv(e.reference.title);t&&i.set(t,e.reference.id)}return r.filter(e=>{if(e.reference.kind!==`task`)return!0;let t=Jv(e.reference.title);return!t||i.get(t)===e.reference.id})}function ty(e){return Yv(e)?e.presentation||e.related?.length?!0:e.primary?e.primary.kind!==`note`||e.operation===`created`||e.operation===`updated`:!1:!1}function ny({message:e,isStreaming:t,reasoningLevel:n}){let r=e.beforeSteer?e.content.filter(e=>e.type===`text`||e.type===`review`):ur(e.content??[],{includePending:!0}),i=new Set(r),a=Zg(Bv(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=Kv(e);t&&ty(t)&&u.set(e.id,t)}let d=[...u].map(([e,t])=>({key:e,delivery:t})),f=zv(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=[...Uh(_),...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:Hv(c)}}function ry(e){let t=(0,Z.c)(10),{blocks:n,sources:r,className:i}=e,a=n===void 0?[]:n,o=i===void 0?`mt-6`:i,s=C(y(oy)),c=a.filter(ay),l=r??Hv(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,X.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(iy),t[2]=l,t[3]=f);let p;t[4]===f?p=t[5]:(p=(0,X.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,X.jsxs)(`div`,{className:o,children:[d,p]}),t[6]=o,t[7]=d,t[8]=p,t[9]=m):m=t[9],m}function iy(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,X.jsxs)(`li`,{className:`flex min-w-0 gap-2.5`,children:[(0,X.jsxs)(`span`,{className:`mt-0.5 shrink-0 text-xs text-fg-disabled`,children:[t+1,`.`]}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-1.5`,children:[r?(0,X.jsx)(`img`,{src:r,alt:``,className:`mt-0.5 size-3.5 shrink-0 rounded-sm`,"aria-hidden":!0}):null,(0,X.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,X.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 ay(e){return e.type===`tool_use`}function oy(e){return e.language}var sy=(0,Q.createContext)(!1);function cy(e){let t=(0,Z.c)(41),{entries:n,language:r,renderEntry:i}=e,[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null),c=(0,Q.useRef)(null),l=(0,Q.useRef)(0),u=(0,Q.useRef)(!1),d=f(),p;t[0]===d.search?p=t[1]:(p=new URLSearchParams(d.search).has(Je),t[0]=d.search,t[1]=p);let m=p,h,g;t[2]!==n.length||t[3]!==r?(h=C(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,y;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>{u.current=!e,o(e)},t[6]=y):y=t[6];let b;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,X.jsx)(fc,{}),t[7]=b):b=t[7];let x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,X.jsx)(ie,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[8]=x):x=t[8];let S;t[9]===_?S=t[10]:(S=(0,X.jsx)(T,{asChild:!0,children:(0,X.jsx)(`button`,{ref:s,type:`button`,className:bs,children:(0,X.jsx)(xs,{icon:b,title:_,trailing:x})})}),t[9]=_,t[10]=S);let M;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,X.jsx)(w,{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(),c.current?.focus({preventScroll:!0})},N=e=>{e.preventDefault(),u.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,X.jsx)(A,{ref:c,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,X.jsx)(an,{className:`size-4`,"aria-hidden":!0}),t[16]=I):I=t[16];let L;t[17]===h.closeTaskList?L=t[18]:(L=(0,X.jsx)(D,{"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,X.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,X.jsx)(E,{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=l.current)},V=e=>{l.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,X.jsx)(`div`,{"data-task-delivery-list":!0,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,ref:B,onScroll:V,children:(0,X.jsx)(`ul`,{className:`${Ts} p-3`,children:H})}),t[31]=H,t[32]=U);let W;t[33]!==R||t[34]!==z||t[35]!==U?(W=(0,X.jsxs)(O,{children:[M,(0,X.jsxs)(k,{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 ee;return t[37]!==W||t[38]!==v||t[39]!==S?(ee=(0,X.jsx)(`li`,{className:`min-w-0 max-w-full`,"data-product-task-group":!0,children:(0,X.jsxs)(j,{open:v,onOpenChange:y,children:[S,W]})}),t[37]=W,t[38]=v,t[39]=S,t[40]=ee):ee=t[40],ee}var ly={agent:Qt,task:fc,project:Oe,note:lc,automation:te,local_app:N,chat_preview:rc,file:Ee,session:cc,settings:Vt};function uy(e,t){let n=e?.trim();return n?C(t).chat.productDelivery.statuses[n.toLowerCase()]??n:null}function dy(e,t,n){let r=C(n).chat.productDelivery.operations[e.operation],i=uy(t.status,n);return i&&e.operation===`opened`?i:i&&i.toLowerCase()!==r.toLowerCase()?`${r} · ${i}`:i??r}function fy(e,t,n){let r=C(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 py(e,t){let n=C(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 my({delivery:e,reference:t,language:n,conversationId:r,projectId:i,fullTitle:a=!1}){let o=p(),s=f(),c=Ci(e=>e.setPath),l=ly[t.kind],u=pn(t),d=t.kind===`file`&&t.capabilities.includes(`preview`)?qv(t.id):null,m=!!(d&&(r?.trim()||i?.trim())),h=m||!!(u&&t.capabilities.includes(`open`)),g=t.kind!==`note`&&t.kind!==`task`&&t.capabilities.includes(`continue_in_chat`),_=e.operation===`failed`,y=v(e=>e.conversationId),b=t.kind===`agent`?C(n).agentsSettings:null,{data:x}=vi(b&&y?[`gateway-chat-agents`,y]:null,Ai),S=x?.items.find(e=>e.id===t.id),w=b&&S?fo(S,b):t.title,T=vi(t.kind===`task`?[`task-delivery`,t.id,y]:null,()=>Oi(t.id),{revalidateOnFocus:!0}),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{if(t.kind!==`task`)return;let e=e=>{let n=e.detail?.taskId;(!n||n===t.id)&&T.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.kind,t.id,T.mutate]);let A=t.kind===`task`?fy(e,{phase:T.data?.task.phase,resolution:T.data?.task.resolution,operationalState:T.data?.operationalState??t.status,attention:T.data?.attention},n):dy(e,t,n),j=T.data?.presentation?.primaryAction,M=j?.type===`resolve_wait`?T.data?.waits.find(e=>e.id===j.waitId&&e.condition.type===`connection`)?.taskRunId:void 0,N=j?.type===`retry_run`?j.runId:M,P=async e=>{D(!0),k(``);try{let i=await bi(t.id,e);k(Ei(i,n)),i.status===`waiting_connection`&&i.connectionConversationId&&i.connectionConversationId!==r&&o(`/chat/${encodeURIComponent(i.connectionConversationId)}`),T.mutate()}catch{k(Ei({status:`changed`},n))}finally{D(!1)}};return t.kind===`automation`&&e.operation!==`failed`?(0,X.jsx)(`li`,{className:`min-w-0 max-w-full`,children:(0,X.jsx)(Ss,{automationId:t.id,runId:t.runId,language:n,embedded:!0})}):(0,X.jsxs)(`li`,{className:`flex max-w-full min-w-0 flex-wrap items-center gap-2`,"data-product-delivery":t.kind,children:[(0,X.jsx)(`button`,{type:`button`,onClick:h?()=>{if(d&&m){c(d,null,i,r);return}if(t.kind===`task`){o($e(`${s.pathname}${s.search}`,t.id));return}if(t.kind===`note`){o(et(`${s.pathname}${s.search}`,t.id));return}if(u){let e=new URL(u,`https://xopc.local`);t.projectId&&e.searchParams.set(`projectId`,t.projectId),t.kind===`local_app`&&t.revision&&/^[a-f0-9]{64}$/.test(t.revision)&&e.searchParams.set(`sourceHash`,t.revision),o(Ye(Ze(`${s.pathname}${s.search}`,`${e.pathname}${e.search}`),`${s.pathname}${s.search}`))}}:void 0,disabled:!h,title:[w,A,t.summary?.trim()].filter(Boolean).join(` · `),className:Y(bs,h?`cursor-pointer`:`cursor-default`,_&&`text-danger`),children:(0,X.jsx)(xs,{icon:b?(0,X.jsx)(no,{agentId:t.id,avatar:S?.avatar,size:18}):(0,X.jsx)(l,{strokeWidth:1.75,className:_?`text-danger`:void 0}),title:w,meta:b?b.backToEditor:A,fullTitle:a,trailing:h?(0,X.jsx)(ie,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}):null})}),N&&(0,X.jsx)(`button`,{type:`button`,className:`touch-manipulation inline-flex min-h-11 w-fit max-w-full min-w-0 items-center gap-2 rounded-[1.125rem] bg-surface-inset px-3 py-2 text-left text-sm text-fg transition-colors duration-150 motion-reduce:transition-none hover:bg-surface-hover active:bg-surface-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,disabled:E,onClick:()=>void P(N),children:M?n===`zh`?`检查连接并继续`:`Check connection and resume`:n===`zh`?`重试任务`:`Retry task`}),O&&(0,X.jsx)(`span`,{role:`status`,className:`text-xs text-fg-muted`,children:O}),b&&h&&!_?(0,X.jsx)(`button`,{type:`button`,className:bs,onClick:()=>Za(o,`/chat/new?projectScope=none`,{state:{agentId:t.id,forceNewChat:!0,fromAgentEditor:!0}}),children:b.listChatWithAgent}):g?(0,X.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`,Ma.transition,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`),onClick:()=>Qm(py(t,n)),children:C(n).chat.productDelivery.continue}):null]})}function hy(e){let t=(0,Z.c)(23),{entries:n,language:r,conversationId:i,projectId:a}=e,o;t[0]!==n.length||t[1]!==r?(o=C(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(bs,`cursor-pointer list-none`),t[3]=c):c=t[3];let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,X.jsx)($s,{strokeWidth:1.75}),t[4]=l):l=t[4];let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,X.jsx)(ie,{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,X.jsx)(`summary`,{className:c,children:(0,X.jsx)(xs,{icon:l,title:s,trailing:u})}),t[6]=s,t[7]=d);let f;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(f=Y(Ts,ws),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,X.jsx)(my,{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,X.jsx)(`ul`,{className:f,children:p}),t[18]=p,t[19]=m);let h;return t[20]!==d||t[21]!==m?(h=(0,X.jsx)(`li`,{className:`min-w-0 max-w-full`,"data-product-file-group":!0,children:(0,X.jsxs)(`details`,{className:`group`,children:[d,m]})}),t[20]=d,t[21]=m,t[22]=h):h=t[22],h}function gy(e){let t=(0,Z.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=ey(n,i),t=e.filter(by),l=e.findIndex(yy),u=e.filter(vy),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,X.jsx)(cy,{entries:u,language:r,renderEntry:(e,t)=>(0,X.jsx)(my,{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,X.jsx)(my,{delivery:s,reference:c,language:r,conversationId:a,projectId:o},i):n===l?(0,X.jsx)(hy,{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,X.jsx)(X.Fragment,{children:s}),t[7]=s,t[8]=l),l}function _y(e){let{reference:t}=e;return t.kind===`task`}function vy(e){let{reference:t}=e;return t.kind===`task`}function yy(e){let{reference:t}=e;return t.kind===`file`}function by(e){let{reference:t}=e;return t.kind===`file`}function xy(e){let t=(0,Z.c)(22),{presentation:n}=e,r=y(Sy),i;t[0]===r?i=t[1]:(i=C(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,X.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,X.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,X.jsxs)(`details`,{className:`rounded border border-edge-subtle p-2`,children:[(0,X.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,X.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,X.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,X.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,X.jsxs)(`section`,{className:`mt-2 rounded-lg bg-surface-inset 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 Sy(e){return e.language}function Cy({previewId:e,reference:t,sourceHash:n,preferredHeight:r,language:i}){let a=p(),o=f(),s=(0,Q.useRef)(null),[c,l]=(0,Q.useState)(0),[u,d]=(0,Q.useState)(`booting`),[m,h]=(0,Q.useState)(null),[g,v]=(0,Q.useState)([]),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(null),w=Math.min(720,Math.max(240,r)),T=Da(e),E=vi(T.active?[`inline-local-app-snapshot`,t.id,n]:null,()=>Ms(t.id,n),{revalidateOnFocus:!1,shouldRetryOnError:!1});(0,Q.useEffect)(()=>{let e=s.current;if(!e||!E.data?.previewUrl)return;d(`booting`),h(null),v([]);let t=window.setTimeout(()=>{d(e=>e===`booting`?`timeout`:e)},7e3),n=ks(e,e=>{let t=mn(e);if(t){if(t.type===`ready`){d(`healthy`);return}if(t.type===`error`){h(t.detail),d(`failed`),v(e=>[...e,{phase:`runtime`,message:As(t.detail),code:t.detail.kind}].slice(-20));return}if(t.type===`acceptance`&&t.detail.status===`failed`){d(`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`&&(d(`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()}},[c,E.data?.previewUrl]);let D=()=>{let e=pn(t);e&&a(Ze(`${o.pathname}${o.search}`,`${e}&sourceHash=${encodeURIComponent(n)}`))};if(!T.active)return(0,X.jsxs)(`section`,{ref:T.containerRef,className:`content-block-action-scope mt-3 overflow-hidden rounded-2xl bg-surface-inset`,"data-inline-local-app":t.id,children:[(0,X.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,title:t.title,children:t.title}),(0,X.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,X.jsx)(qi,{variant:`ghost`,className:`content-block-action`,onClick:D,title:i===`zh`?`查看预览`:`Preview`,"aria-label":i===`zh`?`查看预览`:`Preview`,children:(0,X.jsx)(Ce,{className:`size-4`,"aria-hidden":!0})})]}),(0,X.jsx)(`div`,{className:`grid place-items-center bg-surface-base`,style:{height:w},children:(0,X.jsx)(qi,{variant:`secondary`,onClick:T.activate,children:i===`zh`?`加载交互预览`:`Load interactive preview`})})]});if(E.isLoading)return(0,X.jsxs)(`section`,{ref:T.containerRef,className:`mt-3 overflow-hidden rounded-2xl bg-surface-inset`,"aria-label":C(i).chat.productDelivery.loadingAppPreview,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,X.jsx)(sn,{className:`h-5 w-40`}),(0,X.jsx)(sn,{className:`h-9 w-24`})]}),(0,X.jsx)(sn,{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,X.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,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Zt,{className:`size-4`}),t]})})}let k=O.validation.issues.map(e=>({phase:`build`,code:e.code,message:e.message}))??[],A=u===`timeout`?[{phase:`boot`,code:`boot_timeout`,message:C(i).chat.productDelivery.previewTimeout}]:[],j=[...k,...g,...A],M=O.status===`invalid`||O.validation.status===`failed`,N=M||u===`failed`||u===`timeout`,P=M?i===`zh`?`校验失败`:`Validation failed`:u===`healthy`?i===`zh`?`运行正常`:`Running`:u===`booting`?i===`zh`?`正在启动`:`Starting`:u===`timeout`?i===`zh`?`启动超时`:`Start timed out`:i===`zh`?`运行错误`:`Runtime error`,F=()=>{S(null),l(e=>e+1)},I=async()=>{if(j.length){b(!0),S(null);try{let e=await Ns(t.id,{sourceHash:O.sourceHash,locale:i,diagnostics:j});if(e.action===`retry`){F();return}let n=await js(t.id);a(Os(n,e.prompt))}catch(e){S(e instanceof Error?e.message:String(e))}finally{b(!1)}}};return(0,X.jsxs)(`section`,{ref:T.containerRef,className:`content-block-action-scope mt-3 overflow-hidden rounded-2xl bg-surface-inset`,"data-inline-local-app":t.id,children:[(0,X.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,title:t.title,children:t.title}),(0,X.jsx)(`p`,{className:Y(`mt-0.5 text-xs`,N?`text-danger`:`text-fg-muted`),"aria-live":`polite`,children:P})]}),(0,X.jsx)(qi,{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,X.jsx)(It,{className:`size-4`,"aria-hidden":!0})}),(0,X.jsx)(qi,{variant:`ghost`,className:`content-block-action`,onClick:D,title:i===`zh`?`查看预览`:`Preview`,"aria-label":i===`zh`?`查看预览`:`Preview`,children:(0,X.jsx)(Ce,{className:`size-4`,"aria-hidden":!0})})]}),(0,X.jsxs)(`div`,{className:`relative bg-surface-base`,style:{height:w},children:[O.previewUrl?(0,X.jsx)(`iframe`,{ref:s,title:i===`zh`?`${t.title} 交互预览`:`${t.title} interactive preview`,src:_(O.previewUrl),sandbox:`allow-scripts allow-forms`,className:`h-full w-full border-0 bg-white`},c):null,O.previewUrl&&u===`booting`?(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-0 grid place-items-center bg-surface-base/75`,children:(0,X.jsx)(sn,{className:`h-10 w-40`})}):null]}),N?(0,X.jsxs)(`footer`,{className:`border-t border-danger/20 bg-danger-soft/60 px-4 py-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.jsx)(`p`,{className:`min-w-0 flex-1 text-xs text-danger`,children:m?.message??j[0]?.message??(i===`zh`?`预览校验失败`:`Preview validation failed`)}),(0,X.jsxs)(qi,{variant:`secondary`,className:`min-h-9 px-3 text-xs`,disabled:y||j.length===0,onClick:()=>void I(),children:[(0,X.jsx)(rn,{className:`size-4`}),y?i===`zh`?`生成修复建议…`:`Preparing fix…`:i===`zh`?`让 Coder 修复`:`Ask Coder to fix`]})]}),x?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-danger`,role:`alert`,children:x}):null]}):null]})}async function wy(e,t){return(await b(_(`/api/chat-previews/${encodeURIComponent(e)}/revisions/${encodeURIComponent(t)}`))).revision}async function Ty(e,t){return(await b(_(`/api/chat-previews/${encodeURIComponent(e)}/fix-guidance`),{method:`POST`,body:JSON.stringify(t)})).guidance}async function Ey(e,t){return(await b(_(`/api/chat-previews/${encodeURIComponent(e)}/promote`),{method:`POST`,body:JSON.stringify({sourceHash:t})})).app}function Dy(e,t){return e.replace(RegExp(`</${t}`,`gi`),`<\\/${t}`)}function Oy(e){let t=hn.safeParse(e);return t.success?t.data:null}function ky(e,t){let n=`(() => {
31
31
  const channel = ${JSON.stringify(t)};
32
32
  const bufferedErrors = [];
33
33
  const send = (type, detail = {}) => parent.postMessage({
@@ -55,20 +55,20 @@ Open in xopc:`)[0]))}catch{return i}if(typeof e.result==`string`)try{return Kv(J
55
55
  })();`;return`<!doctype html>
56
56
  <html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
57
57
  <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'">
58
- <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}${ky(e.styles,`style`)}</style>
58
+ <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}${Dy(e.styles,`style`)}</style>
59
59
  </head><body>${e.markup}
60
- <script>${ky(n,`script`)}<\/script>
61
- <script>${ky(e.script,`script`)}<\/script>
62
- </body></html>`}function My(e,t,n){let r=r=>{if(r.source!==e.contentWindow)return;let i=Ay(r.data);!i||i.channel!==t||n(i)};return window.addEventListener(`message`,r),()=>window.removeEventListener(`message`,r)}function Ny({leaseId:e,reference:t,sourceHash:n,preferredHeight:r,language:i}){let a=p(),o=f(),s=(0,Q.useRef)(null),[c,l]=(0,Q.useState)(0),[u,d]=(0,Q.useState)(`booting`),[m,h]=(0,Q.useState)([]),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(null),b=ka(e),x=Math.min(720,Math.max(240,r)),S=(0,Q.useMemo)(()=>crypto.randomUUID(),[c,n]),C=bi(b.active?[`chat-preview-revision`,t.id,n]:null,()=>Ey(t.id,n),{revalidateOnFocus:!1,shouldRetryOnError:!1}),w=C.data?jy(C.data,S):void 0;(0,Q.useEffect)(()=>{let e=s.current;if(!e||!w)return;d(`booting`),h([]);let t=window.setTimeout(()=>{d(e=>e===`booting`?`timeout`:e)},7e3),n=My(e,S,t=>{t.type===`ready`&&d(`healthy`),t.type===`resize`&&(e.style.height=`${Math.min(720,Math.max(240,t.height))}px`),t.type===`error`&&(d(`failed`),h(e=>[...e,t.diagnostic].slice(-20)))});return()=>{window.clearTimeout(t),n()}},[S,w]);let T=()=>{y(null),l(e=>e+1)},E=async()=>{if(m.length){_(`fix`),y(null);try{eh((await Dy(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 Oy(t.id,n);a(Ze(`${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,X.jsxs)(`section`,{ref:b.containerRef,className:O,"data-inline-chat-preview":t.id,children:[(0,X.jsxs)(`header`,{className:`border-b border-edge-subtle px-4 py-3`,children:[(0,X.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:t.title}),(0,X.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,X.jsx)(`div`,{className:`grid place-items-center bg-surface-base`,style:{height:x},children:(0,X.jsx)(Yi,{variant:`secondary`,className:`min-h-11`,onClick:b.activate,children:i===`zh`?`加载交互预览`:`Load interactive preview`})})]});if(C.isLoading)return(0,X.jsxs)(`section`,{ref:b.containerRef,className:O,"aria-busy":`true`,"aria-label":i===`zh`?`正在加载预览`:`Loading preview`,children:[(0,X.jsx)(`div`,{className:`border-b border-edge-subtle px-4 py-3`,children:(0,X.jsx)(sn,{className:`h-5 w-40`})}),(0,X.jsx)(sn,{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,X.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,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Zt,{className:`size-4`}),e]})})}let k=u===`failed`||u===`timeout`,A=u===`healthy`?i===`zh`?`运行正常`:`Running`:u===`booting`?i===`zh`?`正在启动`:`Starting`:u===`timeout`?i===`zh`?`启动超时`:`Start timed out`:i===`zh`?`运行错误`:`Runtime error`;return(0,X.jsxs)(`section`,{ref:b.containerRef,className:O,"data-inline-chat-preview":t.id,children:[(0,X.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-2 border-b border-edge-subtle px-4 py-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:t.title}),(0,X.jsx)(`p`,{className:Y(`mt-0.5 text-xs`,k?`text-danger`:`text-fg-muted`),"aria-live":`polite`,children:A})]}),(0,X.jsx)(Yi,{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,X.jsx)(It,{className:`size-4`,"aria-hidden":!0})}),(0,X.jsx)(Yi,{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,X.jsx)(Rt,{className:Y(`size-4`,g===`promote`&&`motion-safe:animate-pulse`),"aria-hidden":!0})})]}),(0,X.jsxs)(`div`,{className:`relative bg-surface-base`,style:{minHeight:x},children:[(0,X.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}},c),u===`booting`?(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-0 grid place-items-center bg-surface-base/75`,children:(0,X.jsx)(sn,{className:`h-10 w-40`})}):null]}),k?(0,X.jsx)(`footer`,{className:`border-t border-danger/20 bg-danger-soft/60 px-4 py-3`,children:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.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,X.jsxs)(Yi,{variant:`secondary`,className:`min-h-11 px-3 text-xs`,disabled:!m.length||g!==null,onClick:()=>void E(),children:[(0,X.jsx)(rn,{className:`size-4`}),g===`fix`?i===`zh`?`生成中…`:`Preparing…`:i===`zh`?`让 AI 修复`:`Ask AI to fix`]})]})}):null,v?(0,X.jsx)(`p`,{className:`border-t border-danger/20 px-4 py-2 text-xs text-danger`,role:`alert`,children:v}):null]})}function Py(e){let t=(0,Z.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,X.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,X.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 Fy(e){let t=e.mimeType?.toLowerCase()??``,n=e.type?.toLowerCase()??``;return t.startsWith(`image/`)||n===`image`?Te:t.startsWith(`audio/`)||n===`audio`||n===`voice`?Qs:t.startsWith(`video/`)||n===`video`?ve:t.includes(`spreadsheet`)||[`spreadsheet`,`csv`,`xlsx`,`xls`].includes(n)?q:t.includes(`zip`)||[`archive`,`zip`].includes(n)?P:n===`site`?ee:Ee}function Iy(e,t,n){return!!(e.uri||Ni(e)||e.workspaceRelativePath?.trim()&&(t?.trim()||n?.trim()))}function Ly(e){let t=(0,Z.c)(43),{item:n,authToken:r,conversationId:i,projectId:a,onOpen:o}=e,s=y(Ry),c;t[0]===s?c=t[1]:(c=C(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=kh(n.attachment,u),f;t[5]===n.attachment?f=t[6]:(f=Fy(n.attachment),t[5]=n.attachment,t[6]=f);let p=f,m;t[7]!==i||t[8]!==n.attachment||t[9]!==a?(m=Iy(n.attachment,i,a),t[7]=i,t[8]=n.attachment,t[9]=a,t[10]=m):m=t[10];let h=m,g=h||!!n.href,_;t[11]!==p||t[12]!==d.src||t[13]!==n.failed?(_=d.src?(0,X.jsx)(`img`,{src:d.src,alt:``,className:`size-[18px] rounded object-cover`,decoding:`async`,loading:`lazy`}):(0,X.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]=_):_=t[14];let v=n.attachment.name??l,b;t[15]===g?b=t[16]:(b=g?(0,X.jsx)(ie,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}):null,t[15]=g,t[16]=b);let x;t[17]!==n.meta||t[18]!==_||t[19]!==v||t[20]!==b?(x=(0,X.jsx)(Cs,{icon:_,title:v,meta:n.meta,trailing:b}),t[17]=n.meta,t[18]=_,t[19]=v,t[20]=b,t[21]=x):x=t[21];let S=x,w=g?`cursor-pointer`:`cursor-default`,T;t[22]===w?T=t[23]:(T=Y(Ss,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(!h&&n.href){let e;return t[27]!==E||t[28]!==S||t[29]!==n.href||t[30]!==k?(e=(0,X.jsx)(`li`,{className:`min-w-0 max-w-full`,"data-result-attachment":!0,children:(0,X.jsx)(`a`,{title:k,href:n.href,target:`_blank`,rel:`noreferrer`,className:E,children:S})}),t[27]=E,t[28]=S,t[29]=n.href,t[30]=k,t[31]=e):e=t[31],e}if(!h){let e;return t[32]!==E||t[33]!==S?(e=(0,X.jsx)(`li`,{className:E,"data-result-attachment":!0,children:S}),t[32]=E,t[33]=S,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]!==S||t[40]!==A||t[41]!==k?(j=(0,X.jsx)(`li`,{className:`min-w-0 max-w-full`,"data-result-attachment":!0,children:(0,X.jsx)(`button`,{type:`button`,className:E,title:k,onClick:A,children:S})}),t[38]=E,t[39]=S,t[40]=A,t[41]=k,t[42]=j):j=t[42],j}function Ry(e){return e.language}function zy(e){let t=(0,Z.c)(25),{attachments:n,authToken:r,conversationId:i,projectId:a,onOpen:o,language:s}=e,c;t[0]!==n.length||t[1]!==s?(c=C(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(Ss,`cursor-pointer list-none`),t[3]=u):u=t[3];let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,X.jsx)(tc,{strokeWidth:1.75}),t[4]=d):d=t[4];let f;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,X.jsx)(ie,{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,X.jsx)(`summary`,{className:u,children:(0,X.jsx)(Cs,{icon:d,title:l,trailing:f})}),t[6]=l,t[7]=p);let m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m=Y(Ds,Es),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,X.jsx)(Ly,{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,X.jsx)(`ul`,{className:m,children:h}),t[20]=h,t[21]=g);let _;return t[22]!==p||t[23]!==g?(_=(0,X.jsx)(`li`,{className:`min-w-0 max-w-full`,"data-result-attachment-group":!0,children:(0,X.jsxs)(`details`,{className:`group`,children:[p,g]})}),t[22]=p,t[23]=g,t[24]=_):_=t[24],_}function By(e,t){if(!e)return[];let n=C(t).chat.turnOutcome;return e.deliverables.map(e=>{let t=Li(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:Fi(e.sizeBytes)].filter(Boolean).join(` · `)}})}function Vy(e,t){let n=C(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`?Fi(e.size):null].filter(Boolean).join(` · `)}))}function Hy(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 Uy(e){let t=(0,Z.c)(46),{view:n,authToken:r,conversationId:i,projectId:a}=e,o=y(Jy)===`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=Mh(s),l=n.deliveries.filter(qy),u=Qv(l),d=ey(l),f=ty(l),p=$v(l),m=(0,Q.useContext)(ly),h=new Set(Hy(n.outcome));if(m)for(let{delivery:e,reference:t}of ny(l))t.kind===`automation`&&!t.runId&&e.operation!==`failed`&&h.add(`automation:${t.id}`);let g=ny(l,h).length,_,v,b,x;if(t[3]!==o||t[4]!==c||t[5]!==n.attachments||t[6]!==n.outcome||t[7]!==n.resultRevision){_=[...By(n.outcome,o),...Vy(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],v=e;let r;t[15]!==v||t[16]!==c||t[17]!==n.resultRevision?(r=e=>{c.openAttachment(e,v(e)?n.resultRevision:void 0)},t[15]=v,t[16]=c,t[17]=n.resultRevision,t[18]=r):r=t[18],b=r,x=_.filter(Ky),t[3]=o,t[4]=c,t[5]=n.attachments,t[6]=n.outcome,t[7]=n.resultRevision,t[8]=_,t[9]=v,t[10]=b,t[11]=x}else _=t[8],v=t[9],b=t[10],x=t[11];let S=x,w;t[19]!==_||t[20]!==S?(w=_.filter(e=>!S.includes(e)),t[19]=_,t[20]=S,t[21]=w):w=t[21];let T=w,E=g>0||T.length>0;if(u.length===0&&d.length===0&&f.length===0&&!E&&!S.length)return null;let D;t[22]!==r||t[23]!==i||t[24]!==S?(D=S.length>0?(0,X.jsx)(Vh,{attachments:S.map(Gy),authToken:r,conversationId:i,workspaceConversationId:i,layout:`assistant`}):null,t[22]=r,t[23]=i,t[24]=S,t[25]=D):D=t[25];let O=u.map(Wy),k;t[26]===o?k=t[27]:(k=e=>{let{key:t,presentation:n}=e;return(0,X.jsx)(Ty,{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,X.jsx)(Ny,{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,X.jsxs)(Py,{label:C(o).chat.productDelivery.heading,children:[(0,X.jsxs)(`ul`,{className:Ds,children:[(0,X.jsx)(vy,{deliveries:l,language:o,excludedReferenceKeys:h,conversationId:i,projectId:a}),T.length>1?(0,X.jsx)(zy,{attachments:T,authToken:r,conversationId:i,projectId:a,onOpen:b,language:o}):T.map(e=>(0,X.jsx)(Ly,{item:e,authToken:r,conversationId:i,projectId:a,onOpen:b},e.key))]}),p.truncated?(0,X.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-fg-muted`,children:C(o).chat.productDelivery.partialResults}):null]}):null,P;t[30]!==T.length||t[31]!==r||t[32]!==i||t[33]!==v||t[34]!==c.active||t[35]!==c.closePreview||t[36]!==c.open||t[37]!==n.resultRevision?(P=T.length>0?(0,X.jsx)(Yo,{open:c.open,attachment:c.active,resultRevision:c.active&&v(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]=v,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,X.jsxs)(X.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 Wy(e){let{key:t,presentation:n}=e;return(0,X.jsx)(Cy,{presentation:n},t)}function Gy(e){return e.attachment}function Ky(e){return!e.failed&&e.attachment.mimeType?.startsWith(`image/`)}function qy(e){let{delivery:t}=e;return Zv(t)}function Jy(e){return e.language}var Yy=(0,Q.createContext)({});function Xy(e){let t=(0,Z.c)(16),{outcome:n}=e,r=C(y($y)).chat.turnOutcome,i=(0,Q.useContext)(Yy),a=!!(i.turnId&&i.turnId===n.turnId),o=n.status===`failed`&&!(a&&i.running)?(0,X.jsx)(Tg,{errorText:a&&i.error||n.summary||r.statusFailed,onRetry:a?i.onRetry:void 0}):null,s=!!n.changeSet,c=n.evidence.length>0;if(!s&&!c)return o;let l=n.evidence.filter(Qy).length,u=n.evidence.filter(Zy).length,d=n.status===`succeeded`?r.statusSucceeded:n.status===`failed`?r.statusFailed:r.statusPartial,f=n.status===`succeeded`?ne:n.status===`failed`?K:G,p=[n.changeSet?r.changedFileCount.replace(`{{count}}`,String(n.changeSet.files.length)):null,l>0?r.passedCount.replace(`{{count}}`,String(l)):null,u>0?r.failedCount.replace(`{{count}}`,String(u)):null,c&&l===0&&u===0?r.evidenceCount.replace(`{{count}}`,String(n.evidence.length)):null].filter(Boolean).join(` · `),m=n.status===`succeeded`?`text-success`:n.status===`failed`?`text-danger`:`text-warning`,h;t[0]!==f||t[1]!==m?(h=(0,X.jsx)(f,{className:m,"aria-hidden":!0}),t[0]=f,t[1]=m,t[2]=h):h=t[2];let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,X.jsx)(ie,{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[3]=g):g=t[3];let _=Es,v=n.changeSet?(0,X.jsxs)(`section`,{"aria-label":r.changes,children:[(0,X.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[(0,X.jsx)(`span`,{className:`font-medium text-fg`,children:r.changeSetTitle}),(0,X.jsx)(`span`,{className:`shrink-0 text-fg-subtle`,children:r.changeStats.replace(`{{files}}`,String(n.changeSet.files.length)).replace(`{{added}}`,String(n.changeSet.added)).replace(`{{removed}}`,String(n.changeSet.removed))})]}),(0,X.jsxs)(`div`,{className:`mt-2 border-t border-edge-subtle/70 pt-2`,children:[n.changeSet.files.slice(0,8).map(e=>(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 py-1 text-xs`,children:[(0,X.jsx)(`span`,{className:`w-14 shrink-0 text-fg-subtle`,children:r.fileStatus[e.status??`modified`]}),(0,X.jsx)(`code`,{className:`min-w-0 truncate text-fg-muted`,children:e.path})]},e.path)),n.changeSet.files.length>8?(0,X.jsx)(`div`,{className:`pt-1 text-xs text-fg-subtle`,children:r.moreFiles.replace(`{{count}}`,String(n.changeSet.files.length-8))}):null]}),n.changeSet.diff?(0,X.jsxs)(`details`,{className:`mt-2`,children:[(0,X.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:r.viewDiff}),n.changeSet.diffTruncated?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-warning`,children:r.diffTruncated}):null,(0,X.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,X.jsx)(`code`,{children:n.changeSet.diff})})]}):null]}):null,b;t[4]!==s||t[5]!==c?(b=s&&c?(0,X.jsx)(`div`,{className:`my-2 border-t border-edge-subtle`}):null,t[4]=s,t[5]=c,t[6]=b):b=t[6];let x;t[7]!==c||t[8]!==n.evidence||t[9]!==r?(x=c?(0,X.jsxs)(`section`,{"aria-label":r.evidence,children:[(0,X.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg`,children:r.evidence}),n.evidence.map(e=>(0,X.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,X.jsx)(Ge,{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,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:e.label}),(0,X.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`?r.passed:e.status===`failed`?r.failed:r.warning})]},e.evidenceId))]}):null,t[7]=c,t[8]=n.evidence,t[9]=r,t[10]=x):x=t[10];let S;return t[11]!==_||t[12]!==v||t[13]!==b||t[14]!==x?(S=(0,X.jsxs)(`div`,{className:_,children:[v,b,x]}),t[11]=_,t[12]=v,t[13]=b,t[14]=x,t[15]=S):S=t[15],(0,X.jsxs)(X.Fragment,{children:[o,(0,X.jsxs)(`details`,{className:`group mt-2 min-w-0 max-w-full text-sm`,children:[(0,X.jsx)(`summary`,{className:`${Ss} cursor-pointer list-none`,title:`${d} · ${p}`,children:(0,X.jsx)(Cs,{icon:h,title:d,meta:p,trailing:g})}),S]})]})}function Zy(e){return e.status===`failed`}function Qy(e){return e.status===`passed`}function $y(e){return e.language}function eb(e){let t=(0,Z.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,X.jsx)(Uy,{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,X.jsx)(Xy,{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,X.jsxs)(`details`,{className:`group min-w-0 max-w-full`,"aria-label":o,children:[(0,X.jsx)(`summary`,{className:`${Ss} cursor-pointer list-none`,children:(0,X.jsx)(Cs,{icon:(0,X.jsx)(Me,{}),title:o,trailing:(0,X.jsx)(ie,{className:`size-3.5 shrink-0 text-fg-subtle transition-transform group-open:rotate-90 motion-reduce:transition-none`,"aria-hidden":!0})})}),(0,X.jsx)(`div`,{className:Es,children:(0,X.jsx)(ay,{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,X.jsxs)(X.Fragment,{children:[s,c,l]}),t[10]=s,t[11]=c,t[12]=l,t[13]=u):u=t[13],u}function tb(e,t){return t||e.workLog.items.some(e=>e.type===`tool_use`&&(e.status===`error`||e.activity?.status===`failed`))}function nb(e,t){if(e.role!==`assistant`||t.isStreaming||t.followUpTrigger)return!0;let n=iy({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||tb(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 rb(e,t){let n=ur(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||e.beforeSteer),o=e.runStatus===`error`||e.runStatus===`cancelled`||i?.status===`failed`;return{settled:a,defaultCollapsed:a&&n&&!o,outcome:i}}function ib(e){let t=(0,Z.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=y(ab),p=C(f).chat,m;t[0]!==r||t[1]!==n?(m=rb(n,r),t[0]=r,t[1]=n,t[2]=m):m=t[2];let h=m,g=i&&h.settled&&a.length>0,_,v;t[3]===r?(_=t[4],v=t[5]):(_=()=>{r&&d(null)},v=[r],t[3]=r,t[4]=_,t[5]=v),(0,Q.useEffect)(_,v);let b,x;t[6]!==i||t[7]!==a.length?(b=()=>{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)}},x=[i,a.length],t[6]=i,t[7]=a.length,t[8]=b,t[9]=x):(b=t[8],x=t[9]),(0,Q.useEffect)(b,x);let S=u??(!h.defaultCollapsed||c),w=o==null?null:G_(o,f),T=n.runStatus===`cancelled`?p.processStopped:n.runStatus===`error`||h.outcome?.status===`failed`?p.processFailed:h.outcome?.status===`partial`?p.processPartial:null,E=T?`${T}${w?` · ${w}`:``}`:w?p.processWorkedFor.replace(`{{duration}}`,w):p.processView,D=g&&!S,O;t[10]!==S||t[11]!==E||t[12]!==g?(O=g?(0,X.jsxs)(`button`,{type:`button`,"data-assistant-process-toggle":!0,"aria-expanded":S,onClick:()=>d(!S),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,X.jsx)(`span`,{children:E}),(0,X.jsx)(ie,{"aria-hidden":!0,className:`size-4 shrink-0 transition-transform motion-reduce:transition-none ${S?`rotate-90`:``}`})]}):null,t[10]=S,t[11]=E,t[12]=g,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 ab(e){return e.language}function ob(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 sb(e){let t=(0,Z.c)(23),{trigger:n}=e,r=f(),i=y(cb),a;t[0]===i?a=t[1]:(a=C(i),t[0]=i,t[1]=a);let o=a.chat.taskTrigger,s=n.entryId,c;t[2]===o.about?c=t[3]:(c=(0,X.jsx)(`span`,{className:`shrink-0`,children:o.about}),t[2]=o.about,t[3]=c);let l=`${r.pathname}${r.search}`,u;t[4]!==l||t[5]!==n.taskId?(u=$e(l,n.taskId),t[4]=l,t[5]=n.taskId,t[6]=u):u=t[6];let d=n.taskTitle,p=`${o.openTask}:${n.taskTitle}`,m;t[7]===n.taskTitle?m=t[8]:(m=ob(n.taskTitle),t[7]=n.taskTitle,t[8]=m);let g;t[9]===m?g=t[10]:(g=(0,X.jsxs)(`span`,{className:`truncate`,children:[`「`,m,`」`]}),t[9]=m,t[10]=g);let _;t[11]!==u||t[12]!==p||t[13]!==g||t[14]!==n.taskTitle?(_=(0,X.jsx)(h,{className:`inline-flex min-w-0 max-w-[min(48vw,30rem)] font-medium text-fg hover:text-accent hover:underline`,to:u,title:d,"aria-label":p,children:g}),t[11]=u,t[12]=p,t[13]=g,t[14]=n.taskTitle,t[15]=_):_=t[15];let v=o[n.kind],b;t[16]===v?b=t[17]:(b=(0,X.jsxs)(`span`,{className:`shrink-0 whitespace-nowrap`,children:[`· `,v]}),t[16]=v,t[17]=b);let x;return t[18]!==_||t[19]!==b||t[20]!==c||t[21]!==n.entryId?(x=(0,X.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:[c,_,b]}),t[18]=_,t[19]=b,t[20]=c,t[21]=n.entryId,t[22]=x):x=t[22],x}function cb(e){return e.language}var lb=3;function ub(e){let t=(0,Z.c)(38),{refs:n,groupLabel:r,noteLabel:i,fileLabel:a,folderLabel:o,sessionLabel:s,browserTabLabel:c,mcpResourceLabel:l,workbookLabel:u,truncatedLabel:d,showMoreLabel:f,showLessLabel:p,onOpen:m}=e,h=u===void 0?`Workbook`:u,[g,_]=(0,Q.useState)(!1);if(n.length===0)return null;let v=n.length>lb,y;t[0]!==g||t[1]!==n?(y=g?n:n.slice(0,lb),t[0]=g,t[1]=n,t[2]=y):y=t[2];let b=y,x=n.length-lb,S;if(t[3]!==c||t[4]!==a||t[5]!==o||t[6]!==r||t[7]!==l||t[8]!==i||t[9]!==m||t[10]!==s||t[11]!==d||t[12]!==b||t[13]!==h){let e;t[15]!==c||t[16]!==a||t[17]!==o||t[18]!==r||t[19]!==l||t[20]!==i||t[21]!==m||t[22]!==s||t[23]!==d||t[24]!==h?(e=e=>{let t=e.kind===`note`||e.kind===`workbook`,n=t?`button`:`div`,u=e.kind===`workbook`?h: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,X.jsxs)(n,{...t?{type:`button`,onClick:()=>m(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?d:e.title,children:[(0,X.jsx)(`span`,{className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md bg-accent-soft text-accent-fg`,children:e.kind===`workbook`?(0,X.jsx)(St,{className:`size-3.5`,"aria-hidden":!0}):e.kind===`file`&&e.fileKind===`directory`?(0,X.jsx)(Ae,{className:`size-3.5`,"aria-hidden":!0}):e.kind===`file`||e.kind===`result`?(0,X.jsx)(Ee,{className:`size-3.5`,"aria-hidden":!0}):e.kind===`session`?(0,X.jsx)(yt,{className:`size-3.5`,"aria-hidden":!0}):e.kind===`browser_tab`?(0,X.jsx)(N,{className:`size-3.5`,"aria-hidden":!0}):e.kind===`mcp_resource`?(0,X.jsx)(be,{className:`size-3.5`,"aria-hidden":!0}):(0,X.jsx)(dc,{className:`size-3.5`,"aria-hidden":!0})}),(0,X.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[(0,X.jsx)(`span`,{className:`shrink-0 text-[11px] text-fg-muted`,children:u}),(0,X.jsx)(`span`,{className:`max-w-56 truncate text-xs font-medium text-fg sm:max-w-72`,children:e.title})]}),t?(0,X.jsx)(ie,{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[15]=c,t[16]=a,t[17]=o,t[18]=r,t[19]=l,t[20]=i,t[21]=m,t[22]=s,t[23]=d,t[24]=h,t[25]=e):e=t[25],S=b.map(e),t[3]=c,t[4]=a,t[5]=o,t[6]=r,t[7]=l,t[8]=i,t[9]=m,t[10]=s,t[11]=d,t[12]=b,t[13]=h,t[14]=S}else S=t[14];let C;t[26]===S?C=t[27]:(C=(0,X.jsx)(`div`,{className:`flex min-w-0 flex-wrap gap-1.5`,children:S}),t[26]=S,t[27]=C);let w;t[28]!==v||t[29]!==g||t[30]!==x||t[31]!==p||t[32]!==f?(w=v?(0,X.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":g,onClick:()=>_(db),children:[g?(0,X.jsx)(ae,{className:`size-3.5`,"aria-hidden":!0}):(0,X.jsx)(re,{className:`size-3.5`,"aria-hidden":!0}),g?p:f.replace(`{{count}}`,String(x))]}):null,t[28]=v,t[29]=g,t[30]=x,t[31]=p,t[32]=f,t[33]=w):w=t[33];let T;return t[34]!==r||t[35]!==C||t[36]!==w?(T=(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,role:`group`,"aria-label":r,children:[C,w]}),t[34]=r,t[35]=C,t[36]=w,t[37]=T):T=t[37],T}function db(e){return!e}function fb(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 pb(e){let t=(0,Z.c)(67),{open:n,onOpenChange:r,items:i,labels:a}=e,o;t[0]!==i||t[1]!==a.origins?(o=fb(i,a.origins),t[0]=i,t[1]=a.origins,t[2]=o):o=t[2];let s=o,c=s.reduce(_b,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(gb):[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(hb)))},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,b;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,X.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim/60 backdrop-blur-[1px]`}),t[16]=b):b=t[16];let x;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(x=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]=x):x=t[17];let S;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,X.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,X.jsx)(Xs,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[18]=S):S=t[18];let C;t[19]===a.title?C=t[20]:(C=(0,X.jsx)(A,{className:`text-base font-semibold text-fg`,children:a.title}),t[19]=a.title,t[20]=C);let T;t[21]===a.hint?T=t[22]:(T=(0,X.jsx)(E,{className:`mt-1 text-sm leading-5 text-fg-muted`,children:a.hint}),t[21]=a.hint,t[22]=T);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,X.jsx)(`p`,{className:`mt-2 text-xs font-medium text-fg-subtle`,children:M}),t[26]=M,t[27]=N);let P;t[28]!==C||t[29]!==T||t[30]!==N?(P=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[C,T,N]}),t[28]=C,t[29]=T,t[30]=N,t[31]=P):P=t[31];let F;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,X.jsx)(an,{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,X.jsx)(D,{asChild:!0,children:(0,X.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,X.jsxs)(`header`,{className:`flex shrink-0 items-start gap-3 border-b border-edge-subtle px-4 py-4 sm:px-5`,children:[S,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,X.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,X.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,X.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,X.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel`,children:[(0,X.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,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-fg`,children:e.label}),(0,X.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,X.jsx)(re,{className:Y(`size-4 shrink-0 text-fg-subtle transition-transform duration-200`,t&&`rotate-180`),strokeWidth:1.75,"aria-hidden":!0})]}),t?(0,X.jsx)(`div`,{className:`border-t border-edge-subtle px-3.5`,children:e.items.map(mb)}):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,X.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,X.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,X.jsxs)(O,{children:[b,(0,X.jsxs)(k,{className:x,children:[L,V,U]})]}),t[59]=L,t[60]=V,t[61]=U,t[62]=W):W=t[62];let ee;return t[63]!==r||t[64]!==n||t[65]!==W?(ee=(0,X.jsx)(j,{open:n,onOpenChange:r,children:W}),t[63]=r,t[64]=n,t[65]=W,t[66]=ee):ee=t[66],ee}function mb(e){return(0,X.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 hb(e){return e.id}function gb(e){return e.id}function _b(e,t){return e+t.items.length}var vb=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`,Pa.disabled),yb=`mt-1 min-h-11 shrink-0 sm:min-h-9`,bb=[`misunderstood_intent`,`incorrect`,`did_not_act`,`tone_mismatch`,`too_verbose`,`other`],xb=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`,Pa.disabled),Sb=700,Cb=120,wb=(0,Q.memo)(function({message:e,personal:t=!1,followUpTrigger:n,authToken:r,conversationId:i,workspaceConversationId:a,projectId:o,isStreaming:s,progress:c,reasoningLevel:l=`on`,messageIndex:u,onDeleteRound:d,onRetryUserMessageRound:m,userMessageCanRetry:g=!1,deleteRoundDisabled:v=!1,onSaveAssistantAsNote:x,onSaveAssistantToSourceNote:S,onExtractAssistantTask:w,onForkAssistantTurn:T,readonly:E=!1,density:D=`normal`,suppressAssistantActions:O=!1,onEditUserMessage:k,userMessageCanEdit:A=!0,responseFeedbackEnabled:j=!0,showAssistantWorkLog:M=!0}){let N=(0,Q.useMemo)(()=>Mv(e,{hideSilentReply:Nv(e,t),streaming:s}),[e,t,s]),F=y(e=>e.language),I=C(F),L=p(),R=f(),B=N.role===`user`,U=N.role===`assistant`,W=(0,Q.useRef)(B&&N.deliveryStatus===`sending`).current,ee=B&&N.deliveryStatus===`sending`,te=B&&N.deliveryStatus===`failed`,[ie,oe]=(0,Q.useState)(!1),[se,ce]=(0,Q.useState)(!1),[le,ue]=(0,Q.useState)(()=>typeof navigator<`u`&&navigator.onLine===!1),de=B?I.chat.you:U?I.chat.assistant:I.chat.tool;(0,Q.useEffect)(()=>{if(!ee||typeof window>`u`)return;let e=()=>ue(window.navigator.onLine===!1);return window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}},[ee]),(0,Q.useEffect)(()=>{if(ee){if(ie)return;let e=window.setTimeout(()=>oe(!0),le?0:Sb);return()=>window.clearTimeout(e)}if(!ie)return;let e=0,t=window.requestAnimationFrame(()=>{ce(!0),e=window.setTimeout(()=>{oe(!1),ce(!1)},Cb)});return()=>{window.cancelAnimationFrame(t),window.clearTimeout(e)}},[ee,le,ie]);let fe=te||ie,pe=te?`failed`:`sending`,me=(0,Q.useCallback)(e=>{let t=`${R.pathname}${R.search}`;L(et(t,e))},[R.pathname,R.search,L]),he=(0,Q.useMemo)(()=>({input:I.chat.toolInput,output:I.chat.toolOutput,noOutput:I.chat.noOutput}),[I.chat.toolInput,I.chat.toolOutput,I.chat.noOutput]),K=(0,Q.useMemo)(()=>({thoughts:I.chat.thoughts,thoughtsStreaming:I.chat.thoughtsStreaming,workLogTitle:I.chat.workLogTitle,workLogRunning:I.chat.workLogRunning,workLogComplete:I.chat.workLogComplete,workLogPartial:I.chat.workLogPartial,workLogFailed:I.chat.workLogFailed,searchedWeb:I.chat.stepSearchedWeb,searchedMemory:I.chat.stepSearchedMemory,searchedCode:I.chat.stepSearchedCode,searched:I.chat.stepSearched,readFile:I.chat.stepReadFile,stepDetails:I.chat.stepDetails,runCommand:I.chat.stepRunCommand,listDirectory:I.chat.stepListDirectory,writeFile:I.chat.stepWriteFile,editFile:I.chat.stepEditFile,openUrl:I.chat.stepOpenUrl,fetchUrl:I.chat.stepFetchUrl,unknownTool:I.chat.stepUnknownTool,rawThinking:I.chat.rawThinking,toolError:I.chat.toolError,toolActivity:I.chat.toolActivity,memoryActivity:I.chat.memoryActivity}),[I.chat.thoughts,I.chat.thoughtsStreaming,I.chat.workLogTitle,I.chat.workLogRunning,I.chat.workLogComplete,I.chat.workLogPartial,I.chat.workLogFailed,I.chat.stepSearchedWeb,I.chat.stepSearchedMemory,I.chat.stepSearchedCode,I.chat.stepSearched,I.chat.stepReadFile,I.chat.stepDetails,I.chat.stepRunCommand,I.chat.stepListDirectory,I.chat.stepWriteFile,I.chat.stepEditFile,I.chat.stepOpenUrl,I.chat.stepFetchUrl,I.chat.stepUnknownTool,I.chat.rawThinking,I.chat.toolError,I.chat.toolActivity,I.chat.memoryActivity]),ge=(0,Q.useMemo)(()=>({ing:I.chat.stepsClusterIng}),[I.chat.stepsClusterIng]),_e=(0,Q.useMemo)(()=>I.chat.toolCard,[I.chat.toolCard]),q=l===`off`,ve=(0,Q.useMemo)(()=>U?iy({message:N,isStreaming:s,reasoningLevel:l,personal:t}):null,[U,s,N,l,t]),[ye,be]=(0,Q.useState)(),xe=s&&U&&Nv(N,t),Ce=xe?ve?.answerContent.findLast(e=>e.type===`text`&&!!(e.segmentId&&!e.hydrated&&e.text.trim())):void 0,Te=xe&&!ve?.answer.started&&ye?N.content.findLast(e=>e.type===`text`&&e.segmentId===ye):void 0,De=Ce?.segmentId??(Te?ye:void 0);De!==ye&&be(De);let Oe=(0,Q.useMemo)(()=>{if(!ve)return(N.content??[]).filter(e=>e.type!==`image`);let e=Te?[Te]:ve.answerContent;if(t)return e;if(!q&&M)return(N.content??[]).filter(e=>e.type!==`image`);let n=new Set(e);return(N.content??[]).filter(e=>n.has(e)||e.type===`tool_use`&&(e.status===`error`||e.activity?.status===`failed`))},[ve,N.content,t,q,Te,M]),ke=(0,Q.useMemo)(()=>ve?ve.attachments:N.attachments,[ve,N.attachments]),Ae=U&&!t&&!q&&M,je=ib({message:N,isStreaming:s,enabled:Ae,items:ve?.workLog.items??[],durationMs:N.completedAt==null?void 0:ve?.workLog.durationMs}),Me=(0,Q.useMemo)(()=>Ae?new Set(ve?.workLog.items):void 0,[Ae,ve]),Ne=(0,Q.useMemo)(()=>{let e=new Set(N.userTurnDocument?.parts.flatMap(e=>e.type===`context_ref`?[e.refId]:[])??[]);return N.contextRefs?.filter(t=>!t.refId||!e.has(t.refId))},[N.contextRefs,N.userTurnDocument]),Pe=!!(ve?.workLog.active||ve?.workLog.items.length),Fe=!!ve?.answer.started,Ie=q||U&&(Pe||Fe)?null:c,Le=!q&&!!N.content?.some(e=>e.type===`thinking`&&e.streaming),Re=U?!!ve?.answer.showStreamingCursor:s,ze=t&&U&&s&&!ve?.answer.started&&!Te&&!ke?.length,Be=s&&!Le&&(!U||!Pe&&!Fe),Ve=!!Ie?.message||Be,He=U&&!E&&!s&&!O,Ue=(N.taskResultDelivery?.outcome.deliverables??N.outcome?.deliverables)?.filter(e=>e.availability===`available`&&e.uri?.startsWith(`media://outbound/`)),We=U&&s&&!E&&!O&&Fe,Ge=(0,Q.useMemo)(()=>He?Kh(N.content??[]):``,[He,N]),qe=(0,Q.useMemo)(()=>He&&Ge?Jh(N.content??[]):``,[He,Ge,N]),Je=(0,Q.useMemo)(()=>He?Lv(e,u??0,i,F,I.chat.messageReadAloudTitle,t):void 0,[He,e,u,i,F,I.chat.messageReadAloudTitle,t]),Ye=(0,Q.useMemo)(()=>{if(!B)return``;if(N.userTurnDocument){let e=new Map(N.contextRefs?.flatMap(e=>e.refId?[[e.refId,e.title]]:[])??[]);return nr(N.userTurnDocument,t=>e.get(t))}return Zn(N.content)},[B,N.content,N.contextRefs,N.userTurnDocument]),[Xe,Ze]=(0,Q.useState)(null),[Qe,$e]=(0,Q.useState)(!1),[tt,nt]=(0,Q.useState)(null),[rt,it]=(0,Q.useState)(),at=N.transcriptEntryId?{entryId:N.transcriptEntryId}:N.turnId&&!N.taskResultDelivery?{turnId:N.turnId}:null,ot=at?.entryId??at?.turnId,st=rt?.entryId===ot?rt?.id:void 0,[ct,lt]=(0,Q.useState)(!1),ut=async()=>{if(!(!i||!at||!ot||ct)){lt(!0);try{let{id:e}=await hi(i,at);it({entryId:ot,id:e}),Ga(`success`,F===`zh`?`已保存到资料库`:`Saved to Space`,void 0,{href:`/space?item=${encodeURIComponent(e)}`})}catch{Ga(`error`,F===`zh`?`保存失败,请重试`:`Could not save to Space. Try again.`)}finally{lt(!1)}}},[dt,ft]=(0,Q.useState)(null),[pt,mt]=(0,Q.useState)(!1),[ht,gt]=(0,Q.useState)(null),[_t,vt]=(0,Q.useState)(!1),[yt,bt]=(0,Q.useState)(!1),[xt,St]=(0,Q.useState)(!1),[Ct,wt]=(0,Q.useState)(!1),[Tt,Et]=(0,Q.useState)(null),[Dt,Ot]=(0,Q.useState)([]),[kt,At]=(0,Q.useState)(!1),[Mt,Nt]=(0,Q.useState)(!1),[Pt,Ft]=(0,Q.useState)(null),[Lt,Rt]=(0,Q.useState)(!1),[zt,Bt]=(0,Q.useState)(!1),Vt=(0,Q.useRef)(null),Ht=(0,Q.useCallback)((e,t)=>{let n=Wh(e,t);n&&Ft(n)},[]),Ut=(0,Q.useCallback)(()=>{!i||!N.renderKey||Sr.getState().completeProgressiveRender(i,N.renderKey)},[N.renderKey,i]),Wt=(0,Q.useCallback)(()=>{qe&&aa(qe).then(e=>{e&&(Ze(`plain`),window.setTimeout(()=>Ze(e=>e===`plain`?null:e),2e3))})},[qe]),Gt=(0,Q.useCallback)(()=>{Ge&&aa(Ge).then(e=>{e&&(Ze(`markdown`),window.setTimeout(()=>Ze(e=>e===`markdown`?null:e),2e3))})},[Ge]),Kt=(0,Q.useCallback)(()=>{!Ge||!x||dt||(ft(`create-note`),Promise.resolve(x(Ge)).then(()=>{nt(`create-note`),window.setTimeout(()=>nt(e=>e===`create-note`?null:e),2e3)}).catch(()=>void 0).finally(()=>ft(null)))},[dt,Ge,x]),qt=(0,Q.useCallback)(()=>{!Ge||!S||dt||(ft(`save-source-note`),Promise.resolve(S(Ge)).then(()=>{nt(`save-source-note`),window.setTimeout(()=>nt(e=>e===`save-source-note`?null:e),2e3)}).catch(()=>void 0).finally(()=>ft(null)))},[dt,Ge,S]),Jt=(0,Q.useCallback)(()=>{!qe&&!Ge||!w||dt||(ft(`extract-task`),Promise.resolve(w(qe||Ge)).then(()=>{nt(`extract-task`),window.setTimeout(()=>nt(e=>e===`extract-task`?null:e),2e3)}).catch(()=>void 0).finally(()=>ft(null)))},[dt,Ge,qe,w]),Yt=(0,Q.useCallback)(()=>{Ye&&aa(Ye).then(e=>{e&&(Ze(`user`),window.setTimeout(()=>Ze(e=>e===`user`?null:e),2e3))})},[Ye]),Zt=(0,Q.useCallback)(()=>{!N.turnId||!T||pt||(mt(!0),Promise.resolve(T(N.turnId)).catch(()=>void 0).finally(()=>mt(!1)))},[pt,N.turnId,T]),Qt=(0,Q.useCallback)((e,t)=>{!N.turnId||yt||(bt(!0),vt(!0),St(!1),b(_(`/api/turns/${encodeURIComponent(N.turnId)}/execution-context/feedback`),{method:`POST`,body:JSON.stringify({rating:e===`helpful`?`helpful`:`irrelevant`,reason:t})}).then(()=>{gt(e),Et(t??null),wt(!1)}).catch(()=>St(!0)).finally(()=>bt(!1)))},[N.turnId,yt]),$t=(0,Q.useCallback)(()=>{Tt&&eh(I.chat.messageFeedbackRepairPrompts[Tt])},[I.chat.messageFeedbackRepairPrompts,Tt]),en=(0,Q.useCallback)(()=>{!N.turnId||_t||yt||(bt(!0),b(_(`/api/turns/${encodeURIComponent(N.turnId)}/execution-context`)).then(e=>{Ot(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(()=>{vt(!0),bt(!1)}))},[N.turnId,yt,_t]),tn=(0,Q.useCallback)(()=>{u==null||!d||Nt(!0)},[u,d]),nn=(0,Q.useCallback)(()=>{u==null||!d||(d(u),Nt(!1))},[u,d]),rn=(0,Q.useCallback)(()=>{Nt(!1)},[]);(0,Q.useLayoutEffect)(()=>{if(!B)return;let e=Vt.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;Bt(e.scrollHeight>i*10+1)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[B,Oe,Ye]),(0,Q.useLayoutEffect)(()=>{Rt(!1)},[B,Ye]);let an=v||!g,on=ve&&tb(ve,M)&&(ve.workLog.active||ve.workLog.items.length>0)?(0,X.jsx)(tv,{workLog:ve.workLog,pendingStatus:N.pendingResponseStatus,toolLabels:he,stepLabels:K,clusterLabels:ge,cardLabels:_e,conversationId:i,simplified:!t,personal:t,surfacesOnly:!t,answerStarted:ve.answer.started}):null;return(0,X.jsx)(cf.Provider,{value:lf(ve?.deliveries??[]),children:(0,X.jsxs)(`article`,{className:Y(`group/msg flex w-full min-w-0`,B?`justify-end`:`justify-start`,U&&`@container/assistant-message`,N.clarificationChoice&&`flex-col items-end gap-3`,W&&`xopc-chat-user-message-enter`),children:[N.clarificationChoice?(0,X.jsxs)(`section`,{className:`w-full max-w-[var(--max-width-chat-reading)] self-start rounded-xl border border-edge-subtle bg-surface-base p-3 text-sm`,children:[(0,X.jsx)(`p`,{className:`mb-2 break-words font-medium text-fg`,children:N.clarificationChoice.question}),(0,X.jsx)(`ul`,{className:`space-y-1.5`,children:N.clarificationChoice.choices.map(e=>{let t=e.id===N.clarificationChoice?.choiceId;return(0,X.jsxs)(`li`,{className:Y(`flex items-center justify-between gap-2 rounded-lg border px-3 py-2`,t?`border-accent bg-accent-soft text-fg`:`border-edge-subtle text-fg-muted`),children:[(0,X.jsx)(`span`,{className:`min-w-0 break-words`,children:e.label}),t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`sr-only`,children:F===`zh`?`已选择`:`Selected`}),(0,X.jsx)(ne,{className:`size-4 shrink-0 text-accent-fg`,"aria-hidden":!0})]}):null]},e.id)})})]}):null,(0,X.jsxs)(`div`,{className:Y(`min-w-0`,B?`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)]`,E&&`max-w-full`,(We||Ge)&&`relative @min-[42rem]/assistant-message:min-h-9 @min-[42rem]/assistant-message:pe-32`),children:[(0,X.jsx)(`span`,{className:`sr-only`,children:de}),n?(0,X.jsx)(sb,{trigger:n}):null,B&&Ve?(0,X.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:[Ie?.message&&!Pe?(0,X.jsx)(`span`,{className:`text-fg-subtle`,title:Ie.detail??``,children:Ie.message}):null,Be&&!Ie?.message?(0,X.jsx)(`span`,{className:`text-fg-subtle`,children:I.chat.thinkingLabel}):null]}):null,!B&&Ve&&!ze?(0,X.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-baseline gap-x-2 gap-y-0.5 text-xs text-fg-disabled`,children:[Ie?.message&&!Pe?(0,X.jsx)(`span`,{className:`text-fg-subtle`,title:Ie.detail??``,children:Ie.message}):null,Be&&!Ie?.message?(0,X.jsx)(`span`,{className:`text-fg-subtle`,children:I.chat.thinkingLabel}):null]}):null,(0,X.jsxs)(`div`,{dir:B?`auto`:void 0,className:Y(`min-w-0 text-fg`,B&&`chat-user-message`,D===`compact`?`text-sm leading-relaxed`:B?`text-[0.9375rem] leading-[1.6667]`:`text-base leading-[1.6875]`,B&&`w-fit max-w-full rounded-2xl bg-surface-hover/80 px-4 py-3 text-left dark:bg-surface-hover/50`,B&&t&&`relative mt-2 pt-[18px]`,ze&&`bg-transparent p-0`),children:[B&&t&&!te&&N.agentReaction?(0,X.jsx)(`span`,{role:`img`,"aria-label":`${N.agentReaction.actorName} ${N.agentReaction.emoji}`,className:`pointer-events-none absolute -left-1 -top-[7px] grid h-[25px] w-[33px] select-none place-items-center rounded-full border border-edge bg-surface-panel text-[15px] leading-none`,children:N.agentReaction.emoji}):null,(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[ze?(0,X.jsx)(`div`,{className:`xopc-personal-thinking`,role:`status`,"aria-label":I.chat.thinkingLabel,children:(0,X.jsxs)(`span`,{className:`xopc-personal-thinking-dots`,"aria-hidden":`true`,children:[(0,X.jsx)(`i`,{}),(0,X.jsx)(`i`,{}),(0,X.jsx)(`i`,{})]})}):null,t?on:null,(Oe?.length??0)>0?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{ref:B?Vt:je.contentRef,"data-chat-find-text":!0,className:Y(`relative min-w-0`,`flex flex-col gap-3`,B&&!Lt&&`overflow-hidden`),style:B&&!Lt?{maxHeight:`calc(10lh)`}:void 0,children:[je.summary,(0,X.jsx)(Kg,{taskRunId:N.taskResultDelivery?.taskRunId,content:Oe,isUser:B,isAssistantMessageStreaming:U&&s,imagePreviewLabel:I.chat.attachmentPreviewImage,onImagePreview:Ht,conversationId:i,workspaceConversationId:a,projectId:o,progressiveRender:!!N.progressiveRender,onProgressiveRenderComplete:Ut,userTurnDocument:N.userTurnDocument,contextRefs:N.contextRefs,responseRunId:U?N.turnId:void 0,immediateFirstCommit:!0,processItems:Me,processCollapsed:je.collapsed,renderActivity:!t&&ve?(e,t)=>{let n=s&&(t||e.some(e=>e.type===`tool_use`&&e.status===`running`)),r=Vv(e);return(0,X.jsx)(tv,{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:l===`stream`&&n,startedAt:r.startedAt,durationMs:r.durationMs},toolLabels:he,stepLabels:K,clusterLabels:ge,cardLabels:_e,conversationId:i,simplified:!1,showThinking:!0,renderSurfaces:!1})}:void 0}),Re?(0,X.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]}),B&&zt?(0,X.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:()=>Rt(e=>!e),"aria-expanded":Lt,children:[Lt?(0,X.jsx)(ae,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}):(0,X.jsx)(re,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsx)(`span`,{children:Lt?I.chat.userMessageCollapse:I.chat.userMessageExpand})]}):null]}):null,t?null:on,!t&&ve&&!ve.answer.started&&s&&!Oe.some(e=>e.type===`thinking`||e.type===`tool_use`)?(0,X.jsx)(tv,{workLog:{items:[],active:!0,status:`running`,compact:!0,expandedByDefault:!1},pendingStatus:N.pendingResponseStatus,toolLabels:he,stepLabels:K,clusterLabels:ge,cardLabels:_e,conversationId:i}):null,!B&&(st||N.taskResultDelivery||Ue?.length)?(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[st?(0,X.jsx)(h,{to:`/space?item=${encodeURIComponent(st)}`,className:`rounded-lg px-2 py-1 text-xs text-accent-fg hover:bg-surface-hover`,children:F===`zh`?`在资料库中查看回复`:`View reply in Space`}):null,N.taskResultDelivery&&!Ue?.length?(0,X.jsx)(Th,{deliveryId:N.taskResultDelivery.deliveryId,title:N.taskResultDelivery.taskTitle,zh:F===`zh`}):null,Ue?.slice(0,8).map(e=>(0,X.jsx)(wh,{file:e,zh:F===`zh`,readonly:E||s},e.artifactId))]}):null,!t&&!B&&N.taskResultDelivery&&i?(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,"data-result-follow-up":!0,children:[N.taskResultDelivery.resultRevision?(0,X.jsxs)(`span`,{className:`text-xs text-fg-muted`,"data-result-revision":!0,children:[F===`zh`?`成果版本`:`Result version`,` `,N.taskResultDelivery.resultRevision]}):null,[{sourceId:`body`,title:N.taskResultDelivery.taskTitle},...N.taskResultDelivery.outcome.deliverables.filter(e=>e.availability===`available`).map(e=>({sourceId:e.artifactId,title:e.title}))].map(e=>(0,X.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=N.taskResultDelivery;window.dispatchEvent(new CustomEvent(`chat-result-reference`,{detail:{conversationId:i,reference:{kind:`result`,sourceId:Ec(t.deliveryId.replace(/^reply:/,``),e.sourceId),expectedVersion:Dc(t),title:e.title}}}))},children:[F===`zh`?`询问:`:`Ask about: `,e.title]},e.sourceId))]}):null,ve?(0,X.jsx)(eb,{view:ve,authToken:r,conversationId:a??i,projectId:o,sourcesLabel:I.chat.searchSourcesHeading.replace(`{{count}}`,String(ve.sources.length))}):null,B&&N.sourceDevice?(0,X.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[F===`zh`?`来自 `:`From `,N.sourceDevice.name]}):null,B&&Ne?.length?(0,X.jsx)(ub,{refs:Ne,groupLabel:I.chat.commandPalette.contextLabel,noteLabel:I.chat.commandPalette.notesSection,fileLabel:I.chat.atMention.files,folderLabel:I.chat.atMention.folders,sessionLabel:I.chat.atMention.chats,browserTabLabel:I.chat.atMention.browserTabs,mcpResourceLabel:I.chat.atMention.mcpResources,workbookLabel:F===`zh`?`工作簿`:`Workbook`,truncatedLabel:I.chat.commandPalette.contextTruncated,showMoreLabel:I.chat.contextReferencesMore,showLessLabel:I.chat.contextReferencesLess,onOpen:e=>e.kind===`workbook`?L(_i(e.sourceId,e.version)):me(e.sourceId)}):null,B&&ke?.length?(0,X.jsx)(Vh,{attachments:ke,authToken:r,conversationId:i,workspaceConversationId:a,layout:`user`,centerUserVoiceRow:Ye.length===0}):null]})]}),fe?(0,X.jsxs)(`div`,{"data-delivery-status":pe,role:te?`alert`:`status`,"aria-live":`polite`,"aria-hidden":se&&!te?!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`,te?`text-danger`:`text-fg-subtle`,se&&!te&&`opacity-0`),children:[te?(0,X.jsx)(G,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}):null,(0,X.jsx)(`span`,{children:te?I.chat.userMessageSendFailed:le&&ee?I.chat.userMessageWaitingForNetwork:I.chat.userMessageSending}),te&&m&&u!=null?(0,X.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:()=>m(u),children:I.chat.userMessageRetry}):null]}):null,!B&&N.personalProvenance&&!s&&(0,X.jsx)(Dh,{provenance:N.personalProvenance}),B&&!s&&!E?(0,X.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:[m&&u!=null&&N.deliveryStatus!==`failed`?(0,X.jsxs)(`button`,{type:`button`,className:Y(xb,an&&`opacity-40`),onClick:()=>m(u),disabled:an,title:v?I.chat.userMessageActionsWait:g?I.chat.userMessageRetry:I.chat.userMessageRetryDisabledHint,"aria-label":I.chat.userMessageRetry,children:[(0,X.jsx)(It,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`max-w-[4.5rem] truncate sm:max-w-none`,children:I.chat.userMessageRetry})]}):null,(0,X.jsx)(`button`,{type:`button`,className:Y(xb,`size-8 px-0`),onClick:()=>{if(k&&u!=null){k(N,u);return}eh(Ye,An(N.attachments))},disabled:!Ye&&!N.attachments?.length&&!N.contextRefs?.length||!A,title:A?v?I.chat.userMessageStopAndEdit:I.chat.userMessageEdit:I.chat.userMessageEditDisabledHint,"aria-label":I.chat.userMessageEdit,children:(0,X.jsx)(jt,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})}),(0,X.jsx)(`button`,{type:`button`,className:Y(xb,`size-8 px-0`),onClick:Yt,disabled:!Ye,title:Xe===`user`?I.chat.messageCopied:I.chat.userMessageCopy,"aria-label":Xe===`user`?I.chat.messageCopied:I.chat.userMessageCopy,children:Xe===`user`?(0,X.jsx)(ne,{className:`size-3.5 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}):(0,X.jsx)(J,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})}),d&&u!=null&&!v?(0,X.jsx)(`button`,{type:`button`,className:Y(xb,`size-8 px-0 hover:text-red-500 dark:hover:text-red-400`),onClick:tn,title:I.chat.userMessageDelete,"aria-label":I.chat.userMessageDelete,children:(0,X.jsx)(Xt,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})}):null]}):null,We?(0,X.jsx)(`div`,{"data-assistant-actions-placeholder":!0,className:Y(yb,`@min-[42rem]/assistant-message:hidden`),"aria-hidden":`true`}):null,He&&Ge?(0,X.jsx)(kv,{children:(0,X.jsxs)(`div`,{"data-assistant-message-actions":!0,className:Y(yb,`flex items-center justify-end gap-1 overflow-visible transition-opacity duration-150 ease-out motion-reduce:transition-none`,`@min-[42rem]/assistant-message:absolute @min-[42rem]/assistant-message:end-0 @min-[42rem]/assistant-message:bottom-0 @min-[42rem]/assistant-message:mt-0`,`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`,(Qe||Ct||xt)&&`pointer-events-auto opacity-100`),children:[(0,X.jsx)(Av,{label:Xe===`plain`?I.chat.messageCopied:I.chat.messageCopyPlainText,children:(0,X.jsx)(`button`,{type:`button`,className:vb,onClick:Wt,disabled:!qe,"aria-label":Xe===`plain`?I.chat.messageCopied:I.chat.messageCopyPlainText,children:Xe===`plain`?(0,X.jsx)(ne,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}):(0,X.jsx)(J,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})})}),Je?(0,X.jsx)(Av,{label:I.chat.messageReadAloud,children:(0,X.jsx)(z,{input:Je,labels:{read:I.chat.messageReadAloud,preparing:I.chat.messageReadAloudPreparing,pause:I.chat.messageReadAloudPause,resume:I.chat.messageReadAloudResume,retry:I.chat.messageReadAloudRetry},hideNativeTitle:!0})}):null,(0,X.jsxs)($i,{open:Qe,onOpenChange:e=>{$e(e),e&&en()},children:[(0,X.jsx)(Av,{label:I.chat.messageMoreActions,children:(0,X.jsx)(ta,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:vb,"aria-label":I.chat.messageMoreActions,children:(0,X.jsx)(Se,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})})})}),(0,X.jsx)(Zi,{children:(0,X.jsxs)(Qi,{side:`bottom`,align:`end`,sideOffset:6,className:`z-[70] w-56 rounded-xl border border-edge bg-surface-overlay p-1.5 shadow-popover outline-none`,children:[(0,X.jsx)(ea,{asChild:!0,children:(0,X.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,children:[Xe===`markdown`?(0,X.jsx)(ne,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,X.jsx)(we,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),Xe===`markdown`?I.chat.messageCopied:I.chat.messageCopyMarkdown]})}),T&&N.turnId?(0,X.jsx)(ea,{asChild:!0,children:(0,X.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:Zt,disabled:pt,children:[(0,X.jsx)(rc,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),pt?I.chat.messageForkCreating:I.chat.messageForkFromHere]})}):null,i&&at&&!st?(0,X.jsx)(ea,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,disabled:ct,onClick:()=>void ut(),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`,children:[(0,X.jsx)(P,{className:`size-4`,"aria-hidden":!0}),F===`zh`?`保存到资料库`:`Save to Space`]})}):null,x?(0,X.jsx)(ea,{asChild:!0,children:(0,X.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:Kt,disabled:dt!==null,children:[tt===`create-note`?(0,X.jsx)(ne,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,X.jsx)(ec,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),tt===`create-note`?I.chat.messageSavedToNote:I.chat.messageSaveToNote]})}):null,j&&i&&N.timestamp?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`my-1 border-t border-edge-subtle`,role:`separator`}),(0,X.jsx)(ea,{asChild:!0,children:(0,X.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:()=>Qt(`helpful`),disabled:yt,"aria-pressed":ht===`helpful`,children:[(0,X.jsx)(V,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),I.chat.messageHelpful]})}),(0,X.jsx)(ea,{asChild:!0,children:(0,X.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:()=>wt(e=>!e),disabled:yt,"aria-pressed":ht===`not_helpful`,children:[(0,X.jsx)(H,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),I.chat.messageNotHelpful]})})]}):null,xt?(0,X.jsx)(`p`,{className:`px-2.5 py-1 text-xs text-danger`,role:`status`,children:I.chat.messageFeedbackUnavailable}):null,Dt.length>0?(0,X.jsx)(ea,{asChild:!0,children:(0,X.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(e=>!e),children:[(0,X.jsx)(Xs,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),I.chat.messageWhyThisAnswer]})}):null,S?(0,X.jsx)(ea,{asChild:!0,children:(0,X.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:qt,disabled:!Ge||dt!==null,children:[tt===`save-source-note`?(0,X.jsx)(ne,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,X.jsx)(Ee,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),tt===`save-source-note`?I.chat.messageSavedToSourceNote:I.chat.messageSaveToSourceNote]})}):null,w?(0,X.jsx)(ea,{asChild:!0,children:(0,X.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:Jt,disabled:!qe&&!Ge||dt!==null,children:[tt===`extract-task`?(0,X.jsx)(ne,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,X.jsx)(Ke,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),tt===`extract-task`?I.chat.messageTaskExtracted:I.chat.messageExtractTask]})}):null]})})]})]})}):null,He&&Dt.length>0?(0,X.jsx)(pb,{open:kt,onOpenChange:At,items:Dt,labels:{title:I.chat.messageWhyThisAnswer,hint:I.chat.messageWhyThisAnswerHint,close:I.chat.messageContextClose,itemsSummary:I.chat.messageContextItemsSummary,expandAll:I.chat.messageContextExpandAll,collapseAll:I.chat.messageContextCollapseAll,groupSummary:I.chat.messageContextGroupSummary,origins:I.chat.messageContextOrigins}}):null,He&&Ct?(0,X.jsxs)(`div`,{className:`mt-2 w-full max-w-xl rounded-xl border border-edge-subtle bg-surface-panel p-3`,children:[(0,X.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:I.chat.messageFeedbackReasonTitle}),(0,X.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:I.chat.messageFeedbackReasonHint}),(0,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:bb.map(e=>(0,X.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:yt,onClick:()=>Qt(`not_helpful`,e),children:I.chat.messageFeedbackReasons[e]},e))})]}):null,He&&ht===`not_helpful`&&Tt?(0,X.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:$t,children:[(0,X.jsx)(It,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),I.chat.messageFeedbackRepair]}):null]}),B&&d&&u!=null&&!E?(0,X.jsx)(vo,{open:Mt,title:I.chat.userMessageDeleteConfirmTitle,description:I.chat.userMessageDeleteConfirm,confirmLabel:I.chat.userMessageDeleteOk,cancelLabel:I.chat.userMessageDeleteCancel,destructive:!0,onConfirm:nn,onCancel:rn}):null,(0,X.jsx)(Yo,{open:Pt!==null,attachment:Pt,images:(N.content??[]).flatMap((e,t)=>{if(e.type!==`image`)return[];let n=Wh(e,t);return n?[n]:[]}),onAttachmentChange:Ft,authToken:r,conversationId:i,onClose:()=>Ft(null)})]})})}),Tb=(0,Q.memo)(function(e){let t=(0,Z.c)(3),n=og(e.conversationId,e.message.renderKey)??e.message,r;return t[0]!==n||t[1]!==e?(r=(0,X.jsx)(wb,{...e,message:n}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r}),Eb=new Map;function Db(e,t=`time`){let n=`${e??`default`}:${t}`,r=Eb.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}),Eb.set(n,r)),r}function Ob(e){return e?Db().format(e):``}var kb=1800*1e3;function Ab(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function jb(e,t){return e?!t||!Ab(new Date(e),new Date(t))||e-t>=kb:!1}function Mb(e,t,n){let r=new Date(e),i=new Date(t),a=new Date(i);return a.setDate(i.getDate()-1),`${Ab(r,i)?n===`zh`?`今天`:`Today`:Ab(r,a)?n===`zh`?`昨天`:`Yesterday`:Db(n,r.getFullYear()===i.getFullYear()?`date`:`year`).format(r)} ${Db(n).format(r)}`}var Nb=0,Pb=1,Fb=2,Ib=4;function Lb(e){return()=>e}function Rb(e){e()}function zb(e,t){return n=>e(t(n))}function Bb(e,t){return()=>e(t)}function Vb(e,t){return n=>e(t,n)}function Hb(e){return e!==void 0}function Ub(...e){return()=>{e.map(Rb)}}function Wb(){}function Gb(e,t){return t(e),e}function Kb(e,t){return t(e)}function qb(...e){return e}function Jb(e,t){return e(Pb,t)}function Yb(e,t){e(Nb,t)}function Xb(e){e(Fb)}function Zb(e){return e(Ib)}function Qb(e,t){return Jb(e,Vb(t,Nb))}function $b(e,t){let n=e(Pb,e=>{n(),t(e)});return n}function ex(e){let t,n;return r=>i=>{t=i,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function tx(e,t){return e===t}function nx(e=tx){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function rx(e){return t=>n=>{e(n)&&t(n)}}function ix(e){return t=>zb(t,e)}function ax(e){return t=>()=>{t(e)}}function $(e,...t){let n=ux(...t);return((t,r)=>{switch(t){case Fb:Xb(e);return;case Pb:return Jb(e,n(r))}})}function ox(e,t){return n=>r=>{n(t=e(t,r))}}function sx(e){return t=>n=>{e>0?e--:t(n)}}function cx(e){let t=null,n;return r=>i=>{t=i,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function lx(...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;Jb(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 ux(...e){return t=>e.reduceRight(Kb,t)}function dx(e){let t,n,r=()=>t?.();return function(i,a){switch(i){case Pb:return a?n===a?void 0:(r(),n=a,t=Jb(e,a),t):(r(),Wb);case Fb:r(),n=null;return}}}function fx(e){let t=e,n=mx();return((e,r)=>{switch(e){case Nb:t=r;break;case Pb:r(t);break;case Ib:return t}return n(e,r)})}function px(e,t){return Gb(fx(t),t=>Qb(e,t))}function mx(){let e=[];return((t,n)=>{switch(t){case Nb:e.slice().forEach(e=>{e(n)});return;case Fb:e.splice(0);return;case Pb:return e.push(n),()=>{let t=e.indexOf(n);t>-1&&e.splice(t,1)}}})}function hx(e){return Gb(mx(),t=>Qb(e,t))}var gx={singleton:!0};function _x(e,t=[],n=gx){let{singleton:r}=n;return{constructor:e,dependencies:t,id:vx(),singleton:r}}var vx=()=>Symbol(`id`);function yx(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 bx(...e){let t=mx(),n=Array.from({length:e.length}),r=0,i=2**e.length-1;return e.forEach((e,a)=>{let o=2**a;Jb(e,e=>{n[a]=e,r|=o,r===i&&Yb(t,n)})}),function(e,a){switch(e){case Fb:Xb(t);return;case Pb:return r===i&&a(n),Jb(t,a)}}}function xx(e,t=tx){return $(e,nx(t))}function Sx(...e){return function(t,n){switch(t){case Fb:return;case Pb:return Ub(...e.map(e=>Jb(e,n)))}}}var Cx={DEBUG:0,INFO:1,WARN:2,ERROR:3},wx={[Cx.DEBUG]:`debug`,[Cx.ERROR]:`error`,[Cx.INFO]:`log`,[Cx.WARN]:`warn`},Tx=()=>typeof globalThis>`u`?window:globalThis,Ex=_x(()=>{let e=fx(Cx.ERROR);return{log:fx((t,n,r=Cx.INFO)=>{r>=(Tx().VIRTUOSO_LOG_LEVEL??Zb(e))&&console[wx[r]](`%creact-virtuoso: %c%s %o`,`color: #0253b3; font-weight: bold`,`color: initial`,t,n)}),logLevel:e}},[],{singleton:!0});function Dx(e){return`self`in e?e.document.documentElement:e}function Ox(e){let t=Dx(e);return t.ownerDocument.defaultView.getComputedStyle(t).direction===`rtl`}function kx(e,t){return Ox(e)?-t:t}function Ax(e,t){return Ox(e)?-t:t}function jx(e,t,n){return Mx(e,t,n).callbackRef}function Mx(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 Nx(e,t,n,r,i,a,o,s,c){return Mx(Q.useCallback(n=>{let c=Px(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?kx(o,o.scrollLeft):o.scrollTop:u?s?kx(d,d.scrollX||d.document.documentElement.scrollLeft):d.scrollY||d.document.documentElement.scrollTop:s?kx(l,l.scrollLeft):l.scrollTop;r({scrollHeight:f,scrollTop:Math.max(m,0),viewportHeight:p}),a?.(s?Fx(`column-gap`,getComputedStyle(n).columnGap,i):Fx(`row-gap`,getComputedStyle(n).rowGap,i)),c!==null&&e(c)},[e,t,i,a,o,r,s]),n,c)}function Px(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},Cx.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 Fx(e,t,n){return t!==`normal`&&t?.endsWith(`px`)!==!0&&n(`${e} was not resolved to pixel value correctly`,t,Cx.WARN),t===`normal`?0:parseInt(t??`0`,10)}var Ix=typeof document>`u`?Q.useEffect:Q.useLayoutEffect;function Lx(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}=Mx(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 Rx=_x(()=>{let e=mx(),t=mx(),n=fx(0),r=mx(),i=mx(),a=fx(0),o=mx(),s=mx(),c=fx(0),l=fx(0),u=fx(0),d=fx(0),f=mx(),p=mx(),m=fx(!1),h=fx(!1),g=fx(!1);return Qb($(e,ix(({scrollTop:e})=>e)),t),Qb($(e,ix(({scrollHeight:e})=>e)),s),Qb(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}),zx={lvl:0};function Bx(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 Vx(e){return e===zx}function Hx(e,t){if(!Vx(e))return t===e.k?e.v:t<e.k?Hx(e.l,t):Hx(e.r,t)}function Ux(e,t,n=`k`){if(Vx(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){let r=Ux(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return Ux(e.l,t,n)}function Wx(e,t,n){return Vx(e)?tS(t,n,1):t===e.k?Zx(e,{k:t,v:n}):t<e.k?nS(Zx(e,{l:Wx(e.l,t,n)})):nS(Zx(e,{r:Wx(e.r,t,n)}))}function Gx(){return zx}function Kx(e,t,n){if(Vx(e))return[];let r=Ux(e,t)[0];return aS(Yx(e,r,n))}function qx(e,t){if(Vx(e))return zx;let{k:n,l:r,r:i}=e;if(t===n){if(Vx(r))return i;if(Vx(i))return r;let[t,n]=eS(r);return Xx(Zx(e,{k:t,l:Qx(r),v:n}))}return Xx(t<n?Zx(e,{l:qx(r,t)}):Zx(e,{r:qx(i,t)}))}function Jx(e){return Vx(e)?[]:[...Jx(e.l),{k:e.k,v:e.v},...Jx(e.r)]}function Yx(e,t,n){if(Vx(e))return[];let{k:r,l:i,r:a,v:o}=e,s=[];return r>t&&(s=s.concat(Yx(i,t,n))),r>=t&&r<=n&&s.push({k:r,v:o}),r<=n&&(s=s.concat(Yx(a,t,n))),s}function Xx(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($x(t))return rS(Zx(e,{lvl:n-1}));if(!Vx(t)&&!Vx(t.r))return Zx(t.r,{l:Zx(t,{r:t.r.l}),lvl:n,r:Zx(e,{l:t.r.r,lvl:n-1})});throw Error(`Unexpected empty nodes`)}if($x(e))return iS(Zx(e,{lvl:n-1}));if(!Vx(r)&&!Vx(r.l)){let t=r.l,i=$x(t)?r.lvl-1:r.lvl;return Zx(t,{l:Zx(e,{lvl:n-1,r:t.l}),lvl:t.lvl+1,r:iS(Zx(r,{l:t.r,lvl:i}))})}throw Error(`Unexpected empty nodes`)}function Zx(e,t){return tS(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 Qx(e){return Vx(e.r)?e.l:Xx(Zx(e,{r:Qx(e.r)}))}function $x(e){return Vx(e)||e.lvl>e.r.lvl}function eS(e){return Vx(e.r)?[e.k,e.v]:eS(e.r)}function tS(e,t,n,r=zx,i=zx){return{k:e,l:r,lvl:n,r:i,v:t}}function nS(e){return iS(rS(e))}function rS(e){let{l:t}=e;return!Vx(t)&&t.lvl===e.lvl?Zx(t,{r:Zx(e,{l:t.r})}):e}function iS(e){let{lvl:t,r:n}=e;return!Vx(n)&&!Vx(n.r)&&n.lvl===t&&n.r.lvl===t?Zx(n,{l:Zx(e,{r:n.l}),lvl:t+1}):e}function aS(e){return Bx(e,({k:e,v:t})=>({index:e,value:t}))}function oS(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function sS(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}var cS=_x(()=>({recalcInProgress:fx(!1)}),[],{singleton:!0});function lS(e,t,n){return e[uS(e,t,n)]}function uS(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 dS(e,t,n,r){let i=uS(e,t,r),a=uS(e,n,r,i);return e.slice(i,a+1)}function fS(e,t){return Math.round(e.getBoundingClientRect()[t])}function pS(e){return!Vx(e.groupOffsetTree)}function mS({index:e},t){return t===e?0:t<e?-1:1}function hS(){return{groupIndices:[],groupOffsetTree:Gx(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Gx()}}function gS(e,t){let n=Vx(e)?0:1/0;for(let r of t){let{endIndex:t,size:i,startIndex:a}=r;if(n=Math.min(n,a),Vx(e)){e=Wx(e,0,i);continue}let o=Kx(e,a-1,t+1);if(o.some(OS(r)))continue;let s=!1,c=!1;for(let{end:n,start:r,value:a}of o)s?(t>=r||i===a)&&(e=qx(e,r)):(c=a!==i,s=!0),n>t&&t>=r&&a!==i&&(e=Wx(e,t+1,a));c&&(e=Wx(e,a,i))}return[e,n]}function _S(e){return e.groupIndex!==void 0}function vS({offset:e},t){return t===e?0:t<e?-1:1}function yS(e,t,n){if(t.length===0)return 0;let{index:r,offset:i,size:a}=lS(t,e,mS),o=e-r,s=a*o+(o-1)*n+i;return s>0?s+n:s}function bS(e,t){if(!pS(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function xS(e,t,n){if(_S(e))return t.groupIndices[e.groupIndex]+1;let r=bS(e.index===`LAST`?n:e.index,t);return r=Math.max(0,Math.min(n,r)),r}function SS(e,t,n,r=0){return r>0&&(t=Math.max(t,lS(e,r,mS).offset)),Bx(dS(e,t,n,vS),DS)}function CS(e,[t,n,r,i]){t.length>0&&r(`received item sizes`,t,Cx.DEBUG);let a=e.sizeTree,o=a,s=0;if(n.length>0&&Vx(a)&&t.length===2){let e=t[0].size,r=t[1].size;o=n.reduce((t,n)=>Wx(Wx(t,n,e),n+1,r),o)}else[o,s]=gS(o,t);if(o===a)return e;let{lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d}=ES(e.offsetTree,s,o,i);return{groupIndices:n,groupOffsetTree:n.reduce((e,t)=>Wx(e,t,yS(t,d,i)),Gx()),lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d,sizeTree:o}}function wS(e){return Jx(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 TS(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 ES(e,t,n,r){let i=e,a=0,o=0,s=0,c=0;if(t===0)i=[];else{c=uS(i,t-1,mS),s=i[c].offset;let e=Ux(n,t-1);a=e[0],o=e[1],i.length&&i[c].size===Ux(n,t)[1]&&--c,i=i.slice(0,c+1)}for(let{start:e,value:c}of Kx(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 DS(e){return{index:e.index,value:e}}function OS(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 kS={offsetHeight:`height`,offsetWidth:`width`},AS=_x(([{log:e},{recalcInProgress:t}])=>{let n=mx(),r=mx(),i=px(r,0),a=mx(),o=mx(),s=fx(0),c=fx([]),l=fx(void 0),u=fx(void 0),d=fx(void 0),f=fx(void 0),p=fx((e,t)=>fS(e,kS[t])),m=fx(void 0),h=fx(0),g=hS(),_=px($(n,lx(c,e,h),ox(CS,g),nx()),g),v=px($(c,nx(),ox((e,t)=>({current:t,prev:e.current}),{current:[],prev:[]}),ix(({prev:e})=>e)),[]);Qb($(c,rx(e=>e.length>0),lx(_,h),ix(([e,t,n])=>{let r=e.reduce((e,r,i)=>Wx(e,r,yS(r,t.offsetTree,n)||i),Gx());return{...t,groupIndices:e,groupOffsetTree:r}})),_),Qb($(r,lx(_),rx(([e,{lastIndex:t}])=>e<t),ix(([e,{lastIndex:t,lastSize:n}])=>[{endIndex:t,size:n,startIndex:e}])),n),Qb(l,u);let y=px($(l,ix(e=>e===void 0)),!0);Qb($(u,rx(e=>e!==void 0&&Vx(Zb(_).sizeTree)),ix(e=>{let t=Zb(d),n=Zb(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),Qb($(f,rx(e=>e!==void 0&&e.length>0&&Vx(Zb(_).sizeTree)),ix(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),Qb($(c,lx(d,u),rx(([,e,t])=>e!==void 0&&t!==void 0),ix(([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=hx($(n,lx(_),ox(({sizes:e},[t,n])=>({changed:n!==e,sizes:n}),{changed:!1,sizes:g}),ix(e=>e.changed)));Jb($(s,ox((e,t)=>({diff:e.prev-t,prev:t}),{diff:0,prev:0}),ix(e=>e.diff)),e=>{let{groupIndices:n}=Zb(_);if(e>0)Yb(t,!0),Yb(a,e+TS(e,n));else if(e<0){let t=Zb(v);t.length>0&&(e-=TS(-e,t)),Yb(o,e)}}),Jb($(s,lx(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},Cx.ERROR)});let x=hx(a);Qb($(a,lx(_),ix(([e,t])=>{let n=t.groupIndices.length>0,r=[],i=t.lastSize;if(n){let n=Hx(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=Jx(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 Jx(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=hx($(o,lx(_,h),ix(([e,{offsetTree:t},n])=>yS(-e,t,n))));return Qb($(o,lx(_,h),ix(([e,t,n])=>{if(t.groupIndices.length>0){if(Vx(t.sizeTree))return t;let r=Gx(),i=Zb(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=Jx(t.sizeTree).reduce((t,{k:n,v:r})=>Wx(t,Math.max(0,n+e),r),r),a!==-e){let n=Hx(t.sizeTree,s);r=Wx(r,0,n);let i=Ux(t.sizeTree,-e+1)[1];r=Wx(r,1,i)}return{...t,sizeTree:r,...ES(t.offsetTree,0,r,n)}}let r=Jx(t.sizeTree).reduce((t,{k:n,v:r})=>Wx(t,Math.max(0,n+e),r),Gx());return{...t,sizeTree:r,...ES(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}},qb(Ex,cS),{singleton:!0});function jS(e){return e.reduce((e,t)=>(e.groupIndices.push(e.totalCount),e.totalCount+=t+1,e),{groupIndices:[],totalCount:0})}var MS=_x(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:i}])=>{let a=mx(),o=mx(),s=hx($(a,ix(jS)));return Qb($(s,ix(e=>e.totalCount)),n),Qb($(s,ix(e=>e.groupIndices)),e),Qb($(bx(i,t,r),rx(([e,t])=>pS(t)),ix(([e,t,n])=>Ux(t.groupOffsetTree,Math.max(e-n,0),`v`)[0]),nx(),ix(e=>[e])),o),{groupCounts:a,topItemsIndexes:o}},qb(AS,Rx)),NS=_x(([{log:e}])=>{let t=fx(!1),n=hx($(t,rx(e=>e),nx()));return Jb(t,t=>{t&&Zb(e)(`props updated`,{},Cx.DEBUG)}),{didMount:n,propsReady:t}},qb(Ex),{singleton:!0}),PS=typeof document<`u`&&`scrollBehavior`in document.documentElement.style;function FS(e){let t=typeof e==`number`?{index:e}:{...e};return t.align||=`start`,(!t.behavior||!PS)&&(t.behavior=`auto`),t.offset===void 0&&(t.offset=0),t}var IS=_x(([{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=mx(),m=mx(),h=fx(0),g=null,_=null,v=null;function y(){g!==null&&(g(),g=null),v!==null&&(v(),v=null),_&&=(clearTimeout(_),null),Yb(c,!1)}return Qb($(p,lx(n,d,r,h,s,o,f),lx(e,a,i),ix(([[e,n,r,i,a,o,s,l],d,f,h])=>{let b=FS(e),{align:x,behavior:S,offset:C}=b,w=i-1,T=xS(b,n,w),E=yS(T,n.offsetTree,d)+o;x===`end`?(E+=f+Ux(n.sizeTree,T)[1]-r+h,T===w&&(E+=s)):x===`center`?E+=(f+Ux(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},Cx.DEBUG),Yb(p,e)):(Yb(m,!0),l(`list did not change, scroll successful`,{},Cx.DEBUG))};if(y(),S===`smooth`){let e=!1;v=Jb(t,t=>{e||=t}),g=$b(u,()=>{D(e)})}else g=$b($(t,LS(150)),D);return _=setTimeout(()=>{y()},1200),Yb(c,!0),l(`scrolling from index to`,{behavior:S,index:T,top:E},Cx.DEBUG),{behavior:S,top:E}})),l),{scrollTargetReached:m,scrollToIndex:p,topListHeight:h}},qb(AS,Rx,Ex),{singleton:!0});function LS(e){return t=>{let n=setTimeout(()=>{t(!1)},e);return e=>{e&&(t(!0),clearTimeout(n))}}}function RS(e,t){e===0?t():requestAnimationFrame(()=>{RS(e-1,t)})}function zS(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 BS(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 VS=_x(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:i,scrollToIndex:a},{didMount:o}])=>{let s=fx(!0),c=fx(0),l=fx(!0);return Qb($(o,lx(c),rx(([e,t])=>!BS(t)),ax(!1)),s),Qb($(o,lx(c),rx(([e,t])=>!BS(t)),ax(!1)),l),Jb($(bx(t,o),lx(s,n,e,l),rx(([[,e],t,{sizeTree:n},r,i])=>e&&(!Vx(n)||Hb(r))&&!t&&!i),lx(c)),([,e])=>{if(e===void 0){Yb(s,!0),Yb(l,!0);return}$b(i,()=>{Yb(l,!0)}),RS(4,()=>{$b(r,()=>{Yb(s,!0)}),Yb(a,e)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:c,scrolledToInitialItem:s}},qb(AS,Rx,IS,NS),{singleton:!0});function HS(e,t){return Math.abs(e-t)<1.01}var US=`up`,WS=`down`,GS=`none`,KS={atBottom:!1,notAtBottomBecause:`NOT_SHOWING_LAST_ITEM`,state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},qS=0,JS=_x(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:i,viewportHeight:a}])=>{let o=fx(!1),s=fx(!0),c=mx(),l=mx(),u=fx(4),d=fx(qS),f=px($(Sx($(xx(i),sx(1),ax(!0)),$(xx(i),sx(1),ax(!1),ex(100))),nx()),!1),p=px($(Sx($(n,ax(!0)),$(n,ax(!1),ex(200))),nx()),!1);Qb($(bx(xx(i),xx(d)),ix(([e,t])=>e<=t),nx()),s),Qb($(s,cx(50)),l);let m=hx($(bx(r,xx(a),xx(t),xx(e),xx(u)),ox((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}},KS),nx((e,t)=>e!==void 0&&e.atBottom===t.atBottom))),h=px($(r,ox((e,{scrollHeight:t,scrollTop:n,viewportHeight:r})=>{if(!HS(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}),rx(e=>e.changed),ix(e=>e.jump)),0);Qb($(m,ix(e=>e.atBottom)),o),Qb($(o,cx(50)),c);let g=fx(WS);Qb($(r,ix(({scrollTop:e})=>e),nx(),ox((e,t)=>Zb(p)?{direction:e.direction,prevScrollTop:t}:{direction:t<e.prevScrollTop?US:WS,prevScrollTop:t},{direction:WS,prevScrollTop:0}),ix(e=>e.direction)),g),Qb($(r,cx(50),ax(GS)),g);let _=fx(0);return Qb($(f,rx(e=>!e),ax(0)),_),Qb($(i,cx(100),lx(f),rx(([e,t])=>t),ox(([e,t],[n])=>[t,n],[0,0]),ix(([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:_}},qb(Rx)),YS=`top`,XS=`bottom`,ZS=`none`;function QS(e,t,n){return typeof e==`number`?n===US&&t===YS||n===WS&&t===XS?e:0:n===US?t===YS?e.main:e.reverse:t===XS?e.main:e.reverse}function $S(e,t){return typeof e==`number`?e:e[t]??0}var eC=_x(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:i}])=>{let a=mx(),o=fx(0),s=fx(0),c=fx(0);return{increaseViewportBy:s,listBoundary:a,overscan:c,topListHeight:o,visibleRange:px($(bx(xx(r),xx(i),xx(n),xx(a,sS),xx(c),xx(o),xx(t),xx(e),xx(s)),ix(([e,t,n,[r,i],a,o,s,c,l])=>{let u=e-c,d=o+s,f=Math.max(n-u,0),p=ZS,m=$S(l,YS),h=$S(l,XS);return r-=c,r+=n+s,i+=n+s,i-=c,r>e+d-m&&(p=US),i<e-f+t+h&&(p=WS),p===ZS?null:[Math.max(u-n-QS(a,YS,p)-m,0),u-f-s+t+QS(a,XS,p)+h]}),rx(e=>e!==null),nx(sS)),[0,0])}},qb(Rx),{singleton:!0});function tC(e,t,n){if(pS(t)){let r=bS(e,t);return[{index:Ux(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 nC={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function rC(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:aC(e,i,a),offsetBottom:m,offsetTop:l,top:p,topItems:aC(t,i,a),topListHeight:t.reduce((e,t)=>t.size+e,0),totalCount:n}}function iC(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=zS(t,c?l:s),d=c?Math.max(0,Math.min(s,l-u)):s;return rC(Array.from({length:d}).map((e,t)=>({data:a?.[t+u],index:t+u,offset:0,size:0})),[],d,i,n,r)}function aC(e,t,n){if(e.length===0)return[];if(!pS(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=Kx(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 oC(e,t){return e===void 0?0:typeof e==`number`?e:e[t]??0}var sC=_x(([{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=fx([]),g=fx(0),_=mx(),v=fx(0);Qb(a.topItemsIndexes,h);let y=px($(bx(p,m,xx(c,sS),xx(i),xx(r),xx(l),u,xx(h),xx(t),xx(n),xx(v),e,xx(g)),rx(([e,t,,n,,,,,,,,r])=>{let i=r!==void 0&&r.length!==n;return e&&!t&&!i}),ix(([,,[e,t],n,r,i,a,o,s,c,l,u,d])=>{let f=r,{offsetTree:p,sizeTree:m}=f;if(n===0)return{...nC,totalCount:n};if(e===0&&t===0)return d===0?{...nC,totalCount:n}:iC(d,i,r,s,c,u);if(Vx(m))return d>0?null:rC(tC(zS(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 Kx(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 rC([],h,n,c,f,s);let g=o.length>0?o[o.length-1]+1:0,_=SS(p,e,t,g);if(_.length===0)return null;let v=n-1,y=Gb([],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=oC(l,YS),x=oC(l,XS);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=Kx(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=Kx(m,r,r)[0]?.value??t.size;y.push({data:u?.[r],index:r,offset:n,size:e}),n+=e+c}}}return rC(y,h,n,c,f,s)}),rx(e=>e!==null),nx()),nC);Qb($(e,rx(Hb),ix(e=>e?.length)),i),Qb($(y,ix(e=>e.topListHeight)),d),Qb(d,s),Qb($(y,ix(e=>[e.top,e.bottom])),o),Qb($(y,ix(e=>e.items)),_);let b=hx($(y,rx(({items:e})=>e.length>0),lx(i,e),rx(([{items:e},t])=>e[e.length-1].originalIndex===t-1),ix(([,e,t])=>[e-1,t]),nx(sS),ix(([e])=>e))),x=hx($(y,cx(200),rx(({items:e,topItems:t})=>e.length>0&&e[0].originalIndex===t.length),ix(({items:e})=>e[0].index),nx()));return{endReached:b,initialItemCount:g,itemsRendered:_,listState:y,minOverscanItemCount:v,rangeChanged:hx($(y,rx(({items:e})=>e.length>0),ix(({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}}),nx(oS))),startReached:x,topItemsIndexes:h,...f}},qb(AS,MS,eC,VS,IS,JS,NS,cS),{singleton:!0}),cC=_x(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:i}])=>{let a=mx(),o=px($(bx(n,e,r,t,i),ix(([e,t,n,r,i])=>e+t+n+r+i.offsetBottom+i.bottom)),0);return Qb(xx(o),a),{totalListHeight:o,totalListHeightChanged:a}},qb(Rx,sC),{singleton:!0}),lC=_x(([{viewportHeight:e},{totalListHeight:t}])=>{let n=fx(!1);return{alignToBottom:n,paddingTopAddition:px($(bx(n,e,t),rx(([e])=>e),ix(([,e,t])=>Math.max(0,e-t)),cx(0),nx()),0)}},qb(Rx,cC),{singleton:!0}),uC=_x(()=>({context:fx(null)})),dC=({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,fC=_x(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:i,headerHeight:a,scrollingInProgress:o,scrollTop:s,viewportHeight:c},{scrollToIndex:l}])=>{let u=mx();return Qb($(u,lx(t,c,n,a,i,r,s),lx(e),ix(([[e,t,n,r,i,a,s,c],l])=>{let{calculateViewLocation:u=dC,done:d,...f}=e,p=xS(e,t,r-1),m=yS(p,t.offsetTree,l)+i+a,h=m+Ux(t.sizeTree,p)[1],g=c+a,_=u({itemBottom:h,itemTop:m,locationParams:f,viewportBottom:c+n-s,viewportTop:g});return _===null?d?.():d&&$b($(o,rx(e=>!e),sx(Zb(o)?1:2)),d),_}),rx(e=>e!==null)),l),{scrollIntoView:u}},qb(AS,Rx,IS,sC,Ex),{singleton:!0});function pC(e){return e===!1?!1:e===`smooth`?`smooth`:`auto`}var mC=(e,t)=>typeof e==`function`?pC(e(t)):t&&pC(e),hC=_x(([{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=fx(!1),h=mx(),g=null;function _(e){Yb(o,{align:`end`,behavior:e,index:`LAST`})}Jb($(bx($(xx(t),sx(1)),c),lx(xx(m),a,s,d),ix(([[e,t],n,r,i,a])=>{let o=t&&i,s=`auto`;return o&&(s=mC(n,r||a),o&&=s!==!1),{followOutputBehavior:s,shouldFollow:o,totalCount:e}}),rx(({shouldFollow:e})=>e)),({followOutputBehavior:t,totalCount:r})=>{g!==null&&(g(),g=null),Zb(n)===void 0?g=$b(e,()=>{Zb(u)(`following output to `,{totalCount:r},Cx.DEBUG),_(t),g=null}):requestAnimationFrame(()=>{Zb(u)(`following output to `,{totalCount:r},Cx.DEBUG),_(t)})});function v(e){let t=$b(i,t=>{e&&!t.atBottom&&t.notAtBottomBecause===`SIZE_INCREASED`&&g===null&&(Zb(u)(`scrolling to bottom due to increased size`,{},Cx.DEBUG),_(`auto`))});setTimeout(t,100)}Jb($(bx(xx(m),t,l),rx(([e,,t])=>e!==!1&&t),ox(({value:e},[,t])=>({refreshed:e===t,value:t}),{refreshed:!1,value:0}),rx(({refreshed:e})=>e),lx(m,t)),([,e])=>{Zb(s)&&v(e!==!1)}),Jb(h,()=>{v(Zb(m)!==!1)}),Jb(bx(xx(m),i),([e,t])=>{e!==!1&&!t.atBottom&&t.notAtBottomBecause===`VIEWPORT_HEIGHT_DECREASING`&&_(`auto`)});let y=fx(null),b=mx();return Qb(Sx($(xx(r),ix(e=>e?.length??0)),$(xx(t))),b),Jb($(bx($(b,sx(1)),c),lx(xx(y),s,d,f),ix(([[e,t],n,r,i,a])=>t&&r&&n?.({context:a,totalCount:e,scrollingInProgress:i})),rx(e=>!!e),cx(0)),t=>{g!==null&&(g(),g=null),Zb(n)===void 0?g=$b(e,()=>{Zb(u)(`scrolling into view`,{}),Yb(p,t),g=null}):requestAnimationFrame(()=>{Zb(u)(`scrolling into view`,{}),Yb(p,t)})}),{autoscrollToBottom:h,followOutput:m,scrollIntoViewOnChange:y}},qb(AS,JS,IS,VS,NS,Ex,Rx,uC,fC)),gC=_x(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:i},{initialItemCount:a,listState:o},{didMount:s}])=>(Qb($(s,lx(a),rx(([,e])=>e!==0),lx(i,r,t,n,e),ix(([[,e],t,n,r,i,a])=>iC(e,t,n,r,i,a))),o),{}),qb(AS,VS,sC,NS),{singleton:!0}),_C=_x(([{didMount:e},{scrollTo:t},{listState:n}])=>{let r=fx(0);return Jb($(e,lx(r),rx(([,e])=>e!==0),ix(([,e])=>({top:e}))),e=>{$b($(n,sx(1),rx(e=>e.items.length>1)),()=>{requestAnimationFrame(()=>{Yb(t,e)})})}),{initialScrollTop:r}},qb(NS,Rx,sC),{singleton:!0}),vC=_x(([{scrollVelocity:e}])=>{let t=fx(!1),n=mx(),r=fx(!1);return Qb($(e,lx(r,t,n),rx(([e,t])=>t!==!1&&t!==void 0),ix(([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}),nx()),t),Jb($(bx(t,e,n),lx(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}},qb(JS),{singleton:!0}),yC=_x(([{scrollContainerState:e,scrollTo:t}])=>{let n=mx(),r=mx(),i=mx(),a=fx(!1),o=fx(void 0);return Qb($(bx(n,r),ix(([{scrollTop:e,viewportHeight:t},{offsetTop:n,listHeight:r}])=>({scrollHeight:r,scrollTop:Math.max(0,e-n),viewportHeight:t}))),e),Qb($(t,lx(r),ix(([e,{offsetTop:t}])=>({...e,top:e.top+t}))),i),{customScrollParent:o,useWindowScroll:a,windowScrollContainerState:n,windowScrollTo:i,windowViewportRect:r}},qb(Rx)),bC=_x(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:i},{didMount:a},{useWindowScroll:o,windowScrollContainerState:s,windowViewportRect:c}])=>{let l=mx(),u=fx(void 0),d=fx(null),f=fx(null);return Qb(s,d),Qb(c,f),Jb($(l,lx(t,r,o,d,f,n)),([e,t,n,r,i,a,o])=>{let s=wS(t.sizeTree);r&&i!==null&&a!==null&&(n=i.scrollTop-a.offsetTop),n-=o,e({ranges:s,scrollTop:n})}),Qb($(u,rx(Hb),ix(xC)),i),Qb($(a,lx(u),rx(([,e])=>e!==void 0),nx(),ix(([,e])=>e.ranges)),e),{getState:l,restoreStateFrom:u}},qb(AS,Rx,VS,NS,yC));function xC(e){return{align:`start`,index:0,offset:e.scrollTop}}var SC=_x(([{topItemsIndexes:e}])=>{let t=fx(0);return Qb($(t,rx(e=>e>=0),ix(e=>Array.from({length:e}).map((e,t)=>t))),e),{topItemCount:t}},qb(sC));function CC(e){let t=!1,n;return(()=>(t||(t=!0,n=e()),n))}var wC=CC(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),TC=_x(([{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 Qb(k,T.scrollSeekRangeChanged),Qb($(bx(T.windowViewportRect,_.headerHeight,_.fixedHeaderHeight),ix(([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}},qb(AS,VS,Rx,bC,hC,sC,IS,_x(([{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=hx($(l,lx(s),ox(([,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]),rx(([e])=>e!==0),lx(i,c,r,a,m,h),rx(([,e,t,n,,,r])=>!r&&!n&&e!==0&&t===US),ix(([[e],,,,,t])=>(t(`Upward scrolling compensation`,{amount:e},Cx.DEBUG),e))));function _(t){t>0?(Yb(n,{behavior:`auto`,top:-t}),Yb(e,0)):(Yb(e,0),Yb(n,{behavior:`auto`,top:-t}))}Jb($(g,lx(e,o)),([t,n,r])=>{r&&wC()?Yb(e,n-t):_(-t)}),Jb($(bx(px(o,!1),e,h),rx(([e,t,n])=>!e&&!n&&t!==0),ix(([e,t])=>t),cx(1)),_),Qb($(f,ix(e=>({top:-e}))),n);let v=null;function y(){if(v===null)return;let{offset:t}=v;v=null,Yb(n,{top:t}),requestAnimationFrame(()=>{Yb(e,0),Yb(h,!1)})}return Jb(t,e=>{v===null||!v.acknowledgeable||e===v.offset&&y()}),Jb($(u,lx(p,d),ix(([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=Hx(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:Zb(e)!==t,offset:t},Yb(e,t),requestAnimationFrame(y)}),{deviation:e}},qb(Rx,JS,sC,AS,Ex,cS)),SC,MS,_x(([e,t,n,r,i,a,o,s,c,l,u])=>({...e,...t,...n,...r,...i,...a,...o,...s,...c,...l,...u}),qb(eC,gC,NS,vC,cC,_C,lC,yC,fC,Ex,uC))));function EC(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 DC=typeof document>`u`?Q.useEffect:Q.useLayoutEffect;function OC(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&&Yb(e.propsReady,!1);for(let i of r){let r=e[t.required[i]];Yb(r,n[i])}for(let r of i)if(r in n){let i=e[t.optional[r]];Yb(i,n[r])}e.propsReady!==void 0&&Yb(e.propsReady,!0)}function l(e){return a.reduce((n,r)=>(n[r]=n=>{let i=e[t.methods[r]];Yb(i,n)},n),{})}function u(e){return o.reduce((n,r)=>(n[r]=dx(e[t.events[r]]),n),{})}return{Component:Q.forwardRef(function(t,a){let{children:d,...f}=t,[p]=Q.useState(()=>Gb(yx(e),e=>{c(e,f)})),[m]=Q.useState(Bb(u,p));DC(()=>{for(let e of o)e in f&&Jb(m[e],f[e]);return()=>{Object.values(m).map(Xb)}},[f,m,p]),DC(()=>{c(p,f)}),Q.useImperativeHandle(a,Lb(l(p)));let h=n;return(0,X.jsx)(s.Provider,{value:p,children:n===void 0?d:(0,X.jsx)(h,{...EC([...r,...i,...o],f),children:d})})}),useEmitter:(e,t)=>{let n=Q.useContext(s)[e];DC(()=>Jb(n,t),[t,n])},useEmitterValue:e=>{let t=Q.useContext(s)[e],n=Q.useCallback(e=>Jb(t,e),[t]);return Q.useSyncExternalStore(n,()=>Zb(t),()=>Zb(t))},usePublisher:e=>{let t=Q.useContext(s);return Q.useCallback(n=>{Yb(t[e],n)},[t,e])}}}var kC=Q.createContext(void 0),AC=Q.createContext(void 0),jC=`-webkit-sticky`,MC=`sticky`,NC=CC(()=>{if(typeof document>`u`)return MC;let e=document.createElement(`div`);return e.style.position=jC,e.style.position===jC?jC:MC});function PC(e){return`self`in e}function FC(e){return`body`in e}function IC(e,t,n,r=Wb,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(FC(l)||PC(l)){let e=PC(l)?l:l.defaultView;o=a===!0?kx(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?kx(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():Oc.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;PC(r)?(u=Math.max(fS(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?kx(r,r.scrollX):r.scrollY):(u=r[a===!0?`scrollWidth`:`scrollHeight`],l=fS(r,a===!0?`width`:`height`),d=a===!0?kx(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,HS(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:Ax(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:Ax(o.current,e.top)}}),o.current.scrollBy(e)},[a]),scrollerRef:o,scrollToCallback:u}}function LC(e){return e}var RC=_x(([e,t])=>({...e,...t}),qb(TC,_x(()=>{let e=fx(e=>`Item ${e}`),t=fx(e=>`Group ${e}`),n=fx({}),r=fx(LC),i=fx(`div`),a=fx(Wb),o=(e,t=null)=>px($(n,ix(t=>t[e]),nx()),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`)}}))),zC=({height:e})=>(0,X.jsx)(`div`,{style:{height:e}}),BC={overflowAnchor:`none`,position:NC(),zIndex:1},VC={overflowAnchor:`none`},HC={...VC,display:`inline-block`,height:`100%`},UC=Q.memo(function({showTopList:e=!1}){let t=ow(`listState`),n=sw(`sizeRanges`),r=ow(`useWindowScroll`),i=ow(`customScrollParent`),a=sw(`windowScrollContainerState`),o=sw(`scrollContainerState`),s=i||r?a:o,c=ow(`itemContent`),l=ow(`context`),u=ow(`groupContent`),d=ow(`trackItemSizes`),f=ow(`itemSize`),p=ow(`log`),m=sw(`gap`),h=ow(`horizontalDirection`),{callbackRef:g}=Nx(n,f,d,e?Wb:s,p,m,i,h,ow(`skipAnimationFrameInResizeObserver`)),[_,v]=Q.useState(0);aw(`deviation`,e=>{_!==e&&v(e)});let y=sw(`deviationCommitted`);Ix(()=>{y(_)},[_,y]);let b=ow(`EmptyPlaceholder`),x=ow(`ScrollSeekPlaceholder`)??zC,S=ow(`ListComponent`),C=ow(`ItemComponent`),w=ow(`GroupComponent`),T=ow(`computeItemKey`),E=ow(`isSeeking`),D=ow(`groupIndices`).length>0,O=ow(`alignToBottom`),k=ow(`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,X.jsx)(b,{...YC(b,l)}):(0,X.jsx)(S,{...YC(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,{...YC(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,{...YC(w,l),"data-index":n,"data-item-index":e.index,"data-known-size":e.size,key:r,style:BC},u(e.index,l)):(0,Q.createElement)(C,{...YC(C,l),...XC(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?HC:VC},D?c(e.index,e.groupIndex,e.data,l):c(e.index,e.data,l))})})}),WC={height:`100%`,outline:`none`,overflowY:`auto`,position:`relative`,WebkitOverflowScrolling:`touch`},GC={outline:`none`,overflowX:`auto`,position:`relative`},KC=e=>({height:`100%`,position:`absolute`,top:0,width:`100%`,...e?{display:`flex`,flexDirection:`column`}:void 0}),qC=(e,t,n=0)=>({...KC(e),position:t?`relative`:`absolute`,top:t?-n:0}),JC={position:NC(),top:0,width:`100%`,zIndex:1};function YC(e,t){if(typeof e!=`string`)return{context:t}}function XC(e,t){return{item:typeof e==`string`?void 0:t}}var ZC=Q.memo(function(){let e=ow(`HeaderComponent`),t=sw(`headerHeight`),n=ow(`HeaderFooterTag`),r=jx(Q.useMemo(()=>e=>{t(fS(e,`height`))},[t]),!0,ow(`skipAnimationFrameInResizeObserver`)),i=ow(`context`);return e==null?null:(0,X.jsx)(n,{ref:r,children:(0,X.jsx)(e,{...YC(e,i)})})}),QC=Q.memo(function(){let e=ow(`FooterComponent`),t=sw(`footerHeight`),n=ow(`HeaderFooterTag`),r=jx(Q.useMemo(()=>e=>{t(fS(e,`height`))},[t]),!0,ow(`skipAnimationFrameInResizeObserver`)),i=ow(`context`);return e==null?null:(0,X.jsx)(n,{ref:r,children:(0,X.jsx)(e,{...YC(e,i)})})});function $C({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}=IC(s,l,c,u,void 0,d);return e(`scrollTo`,m),e(`scrollBy`,f),(0,X.jsx)(c,{"data-testid":`virtuoso-scroller`,"data-virtuoso-scroller":!0,ref:p,style:{...d?GC:WC,...i},tabIndex:0,...o,...YC(c,a),children:r})})}function ew({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}=IC(s,l,c,t(`scrollerRef`),f);return Ix(()=>(h.current=f??p.current?.ownerDocument.defaultView,()=>{h.current=null}),[h,f]),e(`windowScrollTo`,g),e(`scrollBy`,m),(0,X.jsx)(c,{ref:p,"data-virtuoso-scroller":!0,style:{position:`relative`,...i,...u===0?void 0:{height:u+d}},...o,...YC(c,a),children:r})})}var tw=({children:e})=>{let t=Q.useContext(kC),n=sw(`viewportHeight`),r=sw(`fixedItemHeight`),i=ow(`alignToBottom`),a=ow(`horizontalDirection`),o=jx(Q.useMemo(()=>zb(n,e=>fS(e,a?`width`:`height`)),[n,a]),!0,ow(`skipAnimationFrameInResizeObserver`));return Q.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),(0,X.jsx)(`div`,{"data-viewport-type":`element`,ref:o,style:KC(i),children:e})},nw=({children:e})=>{let t=Q.useContext(kC),n=sw(`windowViewportRect`),r=sw(`fixedItemHeight`),i=ow(`customScrollParent`),a=ow(`useWindowScroll`),o=ow(`topListHeight`),s=Lx(n,i,ow(`skipAnimationFrameInResizeObserver`)),c=ow(`alignToBottom`);return Q.useEffect(()=>{t&&(r(t.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),(0,X.jsx)(`div`,{"data-viewport-type":`window`,ref:s,style:qC(c,a,o),children:e})},rw=({children:e})=>{let t=ow(`TopItemListComponent`)??`div`,n=ow(`headerHeight`);return(0,X.jsx)(t,{style:{...JC,marginTop:`${n}px`},...YC(t,ow(`context`)),children:e})},{Component:iw,useEmitter:aw,useEmitterValue:ow,usePublisher:sw}=OC(RC,{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=ow(`useWindowScroll`),n=ow(`topItemsIndexes`).length>0,r=ow(`customScrollParent`),i=ow(`context`);return(0,X.jsxs)(r||t?lw:cw,{...e,context:i,children:[n&&(0,X.jsx)(rw,{children:(0,X.jsx)(UC,{showTopList:!0})}),(0,X.jsxs)(r||t?nw:tw,{children:[(0,X.jsx)(ZC,{}),(0,X.jsx)(UC,{}),(0,X.jsx)(QC,{})]})]})})),cw=$C({useEmitter:aw,useEmitterValue:ow,usePublisher:sw}),lw=ew({useEmitter:aw,useEmitterValue:ow,usePublisher:sw}),uw=iw,dw=_x(([e,t])=>({...e,...t}),qb(TC,_x(()=>{let e=fx(e=>(0,X.jsxs)(`td`,{children:[`Item $`,e]})),t=fx(null),n=fx(e=>(0,X.jsxs)(`td`,{colSpan:1e3,children:[`Group `,e]})),r=fx(null),i=fx(null),a=fx({}),o=fx(LC),s=fx(Wb),c=(e,t=null)=>px($(a,ix(t=>t[e]),nx()),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`)}}))),fw=({height:e})=>(0,X.jsx)(`tr`,{children:(0,X.jsx)(`td`,{style:{height:e}})}),pw=({height:e})=>(0,X.jsx)(`tr`,{children:(0,X.jsx)(`td`,{style:{border:0,height:e,padding:0}})}),mw={overflowAnchor:`none`},hw={position:NC(),zIndex:2,overflowAnchor:`none`},gw=Q.memo(function({showTopList:e=!1}){let t=Sw(`listState`),n=Sw(`computeItemKey`),r=Sw(`firstItemIndex`),i=Sw(`context`),a=Sw(`isSeeking`),o=Sw(`fixedHeaderHeight`),s=Sw(`groupIndices`).length>0,c=Sw(`itemContent`),l=Sw(`groupContent`),u=Sw(`ScrollSeekPlaceholder`)??fw,d=Sw(`GroupComponent`),f=Sw(`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,{...YC(u,i),height:t.size,index:t.index,key:h,type:t.type||`item`}):t.type===`group`?(0,Q.createElement)(d,{...YC(d,i),"data-index":m,"data-item-index":t.index,"data-known-size":t.size,key:h,style:{...hw,top:o}},l(t.index,i)):(0,Q.createElement)(f,{...YC(f,i),...XC(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?{...hw,top:o+g}:mw},s?c(t.index,t.groupIndex,t.data,i):c(t.index,t.data,i))})}),_w=Q.memo(function(){let e=Sw(`listState`),t=Sw(`topItemsIndexes`).length>0,n=Cw(`sizeRanges`),r=Sw(`useWindowScroll`),i=Sw(`customScrollParent`),a=Cw(`windowScrollContainerState`),o=Cw(`scrollContainerState`),s=i||r?a:o,c=Sw(`trackItemSizes`),{callbackRef:l,ref:u}=Nx(n,Sw(`itemSize`),c,s,Sw(`log`),void 0,i,!1,Sw(`skipAnimationFrameInResizeObserver`)),[d,f]=Q.useState(0);xw(`deviation`,e=>{d!==e&&(u.current.style.marginTop=`${e}px`,f(e))});let p=Cw(`deviationCommitted`);Ix(()=>{p(d)},[d,p]);let m=Sw(`EmptyPlaceholder`),h=Sw(`FillerRow`)??pw,g=Sw(`TableBodyComponent`),_=Sw(`paddingTopAddition`),v=Sw(`statefulTotalCount`),y=Sw(`context`);if(v===0&&m!=null)return(0,X.jsx)(m,{...YC(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,X.jsx)(h,{context:y,height:x},`padding-top`):null,w=S>0?(0,X.jsx)(h,{context:y,height:S},`padding-bottom`):null;return(0,X.jsxs)(g,{"data-testid":`virtuoso-item-list`,ref:l,...YC(g,y),children:[C,t&&(0,X.jsx)(gw,{showTopList:!0}),(0,X.jsx)(gw,{}),w]})}),vw=({children:e})=>{let t=Q.useContext(kC),n=Cw(`viewportHeight`),r=Cw(`fixedItemHeight`),i=jx(Q.useMemo(()=>zb(n,e=>fS(e,`height`)),[n]),!0,Sw(`skipAnimationFrameInResizeObserver`));return Q.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),(0,X.jsx)(`div`,{"data-viewport-type":`element`,ref:i,style:KC(!1),children:e})},yw=({children:e})=>{let t=Q.useContext(kC),n=Cw(`windowViewportRect`),r=Cw(`fixedItemHeight`),i=Sw(`customScrollParent`),a=Sw(`useWindowScroll`),o=Lx(n,i,Sw(`skipAnimationFrameInResizeObserver`));return Q.useEffect(()=>{t&&(r(t.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),(0,X.jsx)(`div`,{"data-viewport-type":`window`,ref:o,style:qC(!1,a),children:e})},{Component:bw,useEmitter:xw,useEmitterValue:Sw,usePublisher:Cw}=OC(dw,{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=Sw(`useWindowScroll`),n=Sw(`customScrollParent`),r=Cw(`fixedHeaderHeight`),i=Cw(`fixedFooterHeight`),a=Sw(`fixedHeaderContent`),o=Sw(`fixedFooterContent`),s=Sw(`context`),c=jx(Q.useMemo(()=>zb(r,e=>fS(e,`height`)),[r]),!0,Sw(`skipAnimationFrameInResizeObserver`)),l=jx(Q.useMemo(()=>zb(i,e=>fS(e,`height`)),[i]),!0,Sw(`skipAnimationFrameInResizeObserver`)),u=n||t?Tw:ww,d=n||t?yw:vw,f=Sw(`TableComponent`),p=Sw(`TableHeadComponent`),m=Sw(`TableFooterComponent`),h=a?(0,X.jsx)(p,{ref:c,style:{position:`sticky`,top:0,zIndex:2},...YC(p,s),children:a()},`TableHead`):null,g=o?(0,X.jsx)(m,{ref:l,style:{bottom:0,position:`sticky`,zIndex:1},...YC(m,s),children:o()},`TableFoot`):null;return(0,X.jsx)(u,{...e,...YC(u,s),children:(0,X.jsx)(d,{children:(0,X.jsxs)(f,{style:{borderSpacing:0,overflowAnchor:`none`},...YC(f,s),children:[h,(0,X.jsx)(_w,{},`TableBody`),g]})})})})),ww=$C({useEmitter:xw,useEmitterValue:Sw,usePublisher:Cw}),Tw=ew({useEmitter:xw,useEmitterValue:Sw,usePublisher:Cw}),Ew={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Dw={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Ow,floor:kw,max:Aw,min:jw,round:Mw}=Math;function Nw(e,t,n){return Array.from({length:t-e+1}).map((t,r)=>({data:n===null?null:n[r+e],index:r+e}))}function Pw(e){return{...Dw,items:e}}function Fw(e,t){return e!==void 0&&e.width===t.width&&e.height===t.height}function Iw(e,t){return e!==void 0&&e.column===t.column&&e.row===t.row}var Lw=_x(([{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=fx(0),C=fx(0),w=fx(Ew),T=fx({height:0,width:0}),E=fx({height:0,width:0}),D=mx(),O=mx(),k=fx(0),A=fx(null),j=fx({column:0,row:0}),M=mx(),N=mx(),P=fx(!1),F=fx(0),I=fx(!0),L=fx(!1),R=fx(!1);Jb($(m,lx(F),rx(([e,t])=>!BS(t))),()=>{Yb(I,!1)}),Jb($(bx(m,I,E,T,F,L),rx(([e,t,n,r,,i])=>e&&!t&&n.height!==0&&r.height!==0&&!i)),([,,,,e])=>{if(e===void 0){Yb(I,!0);return}Yb(L,!0),RS(1,()=>{Yb(D,e)}),$b($(l),()=>{Yb(t,[0,0]),Yb(I,!0)})}),Qb($(N,rx(e=>e!=null&&e.scrollTop>0),ax(0)),C),Jb($(m,lx(N),rx(([,e])=>e!=null)),([,e])=>{e&&(Yb(T,e.viewport),Yb(E,e.item),Yb(j,e.gap),e.scrollTop>0&&(Yb(P,!0),$b($(l,sx(1)),e=>{Yb(P,!1)}),Yb(c,{top:e.scrollTop})))}),Qb($(T,ix(({height:e})=>e)),d),Qb($(bx(xx(T,Fw),xx(E,Fw),xx(j,(e,t)=>e!==void 0&&e.column===t.column&&e.row===t.row),xx(l)),ix(([e,t,n,r])=>({gap:n,item:t,scrollTop:r,viewport:e}))),M),Qb($(bx(xx(S),r,xx(j,Iw),xx(E,Fw),xx(T,Fw),xx(A),xx(C),xx(P),xx(I),xx(F)),rx(([,,,,,,,e])=>!e),ix(([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 Ew;if(p===0){let t=zS(l,e);return Pw(Nw(t,t+Math.max(s-1,0),o))}let h=Rw(m,p,u),g,_;c?t===0&&n===0&&s>0?(g=0,_=s-1):(g=h*kw((t+d)/(f+d)),_=h*Ow((n+d)/(f+d))-1,_=jw(e-1,Aw(_,h-1)),g=jw(_,Aw(0,g))):(g=0,_=-1);let v=Nw(g,_,o),{bottom:y,top:b}=zw(a,r,i,v),x=Ow(e/h);return{bottom:y,itemHeight:f,items:v,itemWidth:p,offsetBottom:x*f+(x-1)*d-y,offsetTop:b,top:b}})),w),Qb($(A,rx(e=>e!==null),ix(e=>e.length)),S),Qb($(bx(T,E,w,j),rx(([e,t,{items:n}])=>n.length>0&&t.height!==0&&e.height!==0),ix(([e,t,{items:n},r])=>{let{bottom:i,top:a}=zw(e,r,t,n);return[a,i]}),nx(sS)),t);let z=fx(!1);Qb($(l,lx(z),ix(([e,t])=>t||e!==0)),z);let B=hx($(bx(w,S),rx(([{items:e}])=>e.length>0),lx(z),rx(([[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}),ix(([[,e]])=>e-1),nx())),V=hx($(xx(w),rx(({items:e})=>e.length>0&&e[0].index===0),ax(0),nx())),H=hx($(xx(w),lx(P),rx(([{items:e},t])=>e.length>0&&!t),ix(([{items:e}])=>({endIndex:e[e.length-1].index,startIndex:e[0].index})),nx(oS),cx(0)));Qb(H,p.scrollSeekRangeChanged),Qb($(D,lx(T,E,S,j),ix(([e,t,n,r,i])=>{let a=FS(e),{align:o,behavior:s,offset:c}=a,l=a.index;l===`LAST`&&(l=r-1),l=Aw(0,l,jw(r-1,l));let u=Bw(t,i,n,l);return o===`end`?u=Mw(u-t.height+n.height):o===`center`&&(u=Mw(u-t.height/2+n.height/2)),c!==void 0&&c!==0&&(u+=c),{behavior:s,top:u}})),c);let U=px($(w,ix(e=>e.offsetBottom+e.bottom)),0);return Qb($(b,ix(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}},qb(eC,Rx,JS,vC,NS,yC,Ex));function Rw(e,t,n){return Aw(1,kw((e+n)/(kw(t)+n)))}function zw(e,t,n,r){let{height:i}=n;if(i===void 0||r.length===0)return{bottom:0,top:0};let a=Bw(e,t,n,r[0].index);return{bottom:Bw(e,t,n,r[r.length-1].index)+i,top:a}}function Bw(e,t,n,r){let i=kw(r/Rw(e.width,n.width,t.column)),a=i*n.height+Aw(0,i-1)*t.row;return a>0?a+t.row:a}var Vw=_x(([e,t])=>({...e,...t}),qb(Lw,_x(()=>{let e=fx(e=>`Item ${e}`),t=fx({}),n=fx(null),r=fx(`virtuoso-grid-item`),i=fx(`virtuoso-grid-list`),a=fx(LC),o=fx(`div`),s=fx(Wb),c=(e,n=null)=>px($(t,ix(t=>t[e]),nx()),n),l=fx(!1),u=fx(!1);return Qb(xx(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`)}}))),Hw=Q.memo(function(){let e=Yw(`gridState`),t=Yw(`listClassName`),n=Yw(`itemClassName`),r=Yw(`itemContent`),i=Yw(`computeItemKey`),a=Yw(`isSeeking`),o=Xw(`scrollHeight`),s=Yw(`ItemComponent`),c=Yw(`ListComponent`),l=Yw(`ScrollSeekPlaceholder`),u=Yw(`context`),d=Xw(`itemDimensions`),f=Xw(`gap`),p=Yw(`log`),m=Yw(`stateRestoreInProgress`),h=Xw(`reportReadyState`),g=jx(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:$w(`column-gap`,getComputedStyle(e).columnGap,p),row:$w(`row-gap`,getComputedStyle(e).rowGap,p)})},[o,d,f,p]),!0,!1);return Ix(()=>{e.itemHeight>0&&e.itemWidth>0&&h(!0)},[e]),m?null:(0,X.jsx)(c,{className:t,ref:g,...YC(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,X.jsx)(l,{...YC(l,u),height:e.itemHeight,index:t.index,width:e.itemWidth},o):(0,Q.createElement)(s,{...YC(s,u),className:n,"data-index":t.index,key:o},r(t.index,t.data,u))})})}),Uw=Q.memo(function(){let e=Yw(`HeaderComponent`),t=Xw(`headerHeight`),n=Yw(`headerFooterTag`),r=jx(Q.useMemo(()=>e=>{t(fS(e,`height`))},[t]),!0,!1),i=Yw(`context`);return e==null?null:(0,X.jsx)(n,{ref:r,children:(0,X.jsx)(e,{...YC(e,i)})})}),Ww=Q.memo(function(){let e=Yw(`FooterComponent`),t=Xw(`footerHeight`),n=Yw(`headerFooterTag`),r=jx(Q.useMemo(()=>e=>{t(fS(e,`height`))},[t]),!0,!1),i=Yw(`context`);return e==null?null:(0,X.jsx)(n,{ref:r,children:(0,X.jsx)(e,{...YC(e,i)})})}),Gw=({children:e})=>{let t=Q.useContext(AC),n=Xw(`itemDimensions`),r=Xw(`viewportDimensions`),i=jx(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,X.jsx)(`div`,{ref:i,style:KC(!1),children:e})},Kw=({children:e})=>{let t=Q.useContext(AC),n=Xw(`windowViewportRect`),r=Xw(`itemDimensions`),i=Yw(`customScrollParent`),a=Yw(`useWindowScroll`),o=Lx(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,X.jsx)(`div`,{ref:o,style:qC(!1,a),children:e})},{Component:qw,useEmitter:Jw,useEmitterValue:Yw,usePublisher:Xw}=OC(Vw,{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=Yw(`useWindowScroll`),n=Yw(`customScrollParent`),r=n||t?Qw:Zw,i=n||t?Kw:Gw,a=Yw(`context`);return(0,X.jsx)(r,{...e,...YC(r,a),children:(0,X.jsxs)(i,{children:[(0,X.jsx)(Uw,{}),(0,X.jsx)(Hw,{}),(0,X.jsx)(Ww,{})]})})})),Zw=$C({useEmitter:Jw,useEmitterValue:Yw,usePublisher:Xw}),Qw=ew({useEmitter:Jw,useEmitterValue:Yw,usePublisher:Xw});function $w(e,t,n){return t!==`normal`&&t?.endsWith(`px`)!==!0&&n(`${e} was not resolved to pixel value correctly`,t,Cx.WARN),t===`normal`?0:parseInt(t??`0`,10)}function eT(e){return e.scrollHeight-e.scrollTop-e.clientHeight}function tT(e,t=96){return eT(e)<=t}function nT(e){Math.abs(eT(e))>.5&&(e.scrollTop=e.scrollHeight)}function rT(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 iT(){return typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}var aT=new WeakMap;function oT(e,t){return aT.set(e,t),()=>{aT.get(e)===t&&aT.delete(e)}}function sT(e){return aT.get(e)}function cT(e){e.dispatchEvent(new Event(`chat-scroll-reading`))}function lT({context:e}){return e?.footer}var uT={Footer:lT},dT={top:800,bottom:800};function fT({rows:e,scrollRef:t,renderRow:n,footer:r}){let i=(0,Q.useRef)(null),[a,o]=(0,Q.useState)(),[s,c]=(0,Q.useState)(dT),[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 oT(a,{reveal:t=>{let n=e.findIndex(e=>e.index===t||e.aliases.includes(t));return n<0?!1:(cT(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&&iT()===`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=dT.top+(e?a.scrollTop-e.start:0),r=dT.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,X.jsx)(uw,{ref:i,customScrollParent:a,data:e,skipAnimationFrameInResizeObserver:!0,components:uT,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,X.jsx)(`div`,{className:r===e[0]?void 0:r.compactTop?`pt-3`:`pt-8`,children:n(r)})}):null}function pT(e){let t=(0,Z.c)(6),{progress:n}=e,r=y(mT),i;if(t[0]!==r||t[1]!==n.completed||t[2]!==n.stage||t[3]!==n.total){let e=C(r).chat.runRecovery,a;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(It,{className:`size-3.5 shrink-0 motion-safe:animate-spin`,"aria-hidden":!0}),t[5]=a):a=t[5],i=(0,X.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex flex-wrap items-center gap-2 py-2 text-xs text-fg-muted`,"data-run-recovery":!0,children:[a,(0,X.jsx)(`span`,{children:n.stage===`model_fallback`?e.fallback:e.retrying}),n.completed!=null&&n.total!=null?(0,X.jsx)(`span`,{className:`tabular-nums`,children:e.attempt.replace(`{{attempt}}`,String(n.completed)).replace(`{{total}}`,String(n.total))}):null]}),t[0]=r,t[1]=n.completed,t[2]=n.stage,t[3]=n.total,t[4]=i}else i=t[4];return i}function mT(e){return e.language}var hT=e=>{},gT=(0,Q.memo)(function(e){let t=(0,Z.c)(76),{messages:n,timelineEntries:r,personal:i,authToken:a,conversationId:o,workspaceConversationId:s,projectId:c,streaming:l,sending:u,progress:d,runError:f,reasoningLevel:p,registerListContentRef:m,onPickWelcomePrompt:h,welcomeSpotlight:g,welcomeOverlay:_,compactWelcome:v,onDeleteRound:b,onRetryUserMessageRound:x,deleteRoundDisabled:S,onSaveAssistantAsNote:w,onSaveAssistantToSourceNote:T,onExtractAssistantTask:E,onForkAssistantTurn:D,onEditUserMessage:O,editLatestUserOnly:k,editRequiresTurnId:A,responseFeedbackEnabled:j,showAssistantWorkLog:M,hideAssistantActions:N,managesReadAloud:P,trailingContent:F,replySpaceRef:I,scrollRef:L}=e,R=r===void 0?[]:r,z=i!==void 0&&i,B=u!==void 0&&u,V=v!==void 0&&v,H=k!==void 0&&k,U=A!==void 0&&A,W=M===void 0||M,ee=N!==void 0&&N,te=P===void 0||P,ne=y(_T),re;t[0]===ne?re=t[1]:(re=C(ne),t[0]=ne,t[1]=re);let ie=re,[ae]=(0,Q.useState)(!!(L&&n.length>=300)),oe;t[2]===n?oe=t[3]:(oe=n.findLastIndex(vT),t[2]=n,t[3]=oe);let se=oe;if(Rv(te?o:null,n,l||B,z),n.length===0&&R.length===0&&!l&&!B&&!f){if(_){let e;return t[4]===_?e=t[5]:(e=(0,X.jsx)(`div`,{className:`pb-1.5`,children:_}),t[4]=_,t[5]=e),e}let e;t[6]!==ie||t[7]!==g?(e=g??{headline:ie.chat.welcomeSpotlight.headline,contextKind:`empty`,contextStatus:`ready`},t[6]=ie,t[7]=g,t[8]=e):e=t[8];let n=h??hT,r;return t[9]!==V||t[10]!==e||t[11]!==n?(r=(0,X.jsx)(`div`,{className:`pb-1.5`,children:(0,X.jsx)(yh,{spotlight:e,onPickPrompt:n,compact:V})}),t[9]=V,t[10]=e,t[11]=n,t[12]=r):r=t[12],r}let ce=Date.now(),le=n.findLastIndex(yT),ue,de,fe;if(t[13]!==le||t[14]!==n||t[15]!==x||t[16]!==B||t[17]!==l){let e=n.slice(le+1);ue=e.findLast(bT)?.outcome,de=l||B,fe=!de&&x&&le>=0&&!n[le].clarificationChoice&&(Nr(n[le])||n[le].deliveryStatus===`failed`&&n[le].clientSubmissionId)&&!e.some(ST)?()=>x(le):void 0,t[13]=le,t[14]=n,t[15]=x,t[16]=B,t[17]=l,t[18]=ue,t[19]=de,t[20]=fe}else ue=t[18],de=t[19],fe=t[20];let pe=fe,G=ue?.turnId,me;t[21]!==pe||t[22]!==f||t[23]!==de||t[24]!==G?(me={turnId:G,running:de,error:f,onRetry:pe},t[21]=pe,t[22]=f,t[23]=de,t[24]=G,t[25]=me):me=t[25];let he=me,K=de&&(d?.stage===`model_retry`||d?.stage===`model_fallback`),ge;t[26]!==se||t[27]!==B||t[28]!==l?(ge=(e,t)=>!!((l||B||e.pendingResponseStatus)&&t===se&&e.role===`assistant`),t[26]=se,t[27]=B,t[28]=l,t[29]=ge):ge=t[29];let _e=ge,q;t[30]===n?q=t[31]:(q=(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[30]=n,t[31]=q);let ve=q,ye;t[32]!==ve||t[33]!==_e||t[34]!==n||t[35]!==z||t[36]!==p||t[37]!==W?(ye=(e,t)=>!nb(e,{personal:z,isStreaming:_e(e,t),reasoningLevel:p,showAssistantWorkLog:W,followUpTrigger:ve(e,t)})||e.role===`task`&&e.taskTrigger&&e.turnId&&n[t+1]?.role===`assistant`&&n[t+1]?.turnId===e.turnId?[]:[{key:Pv(e,t),index:t,aliases:e.role===`assistant`&&n[t-1]?.role===`task`&&e.turnId===n[t-1]?.turnId?[t-1]:[]}],t[32]=ve,t[33]=_e,t[34]=n,t[35]=z,t[36]=p,t[37]=W,t[38]=ye):ye=t[38];let J=n.flatMap(ye),be;t[39]===n.length?be=t[40]:(be=(e,t)=>({key:e.id,index:n.length+t,aliases:[]}),t[39]=n.length,t[40]=be),J.push(...R.map(be));let xe=0,Se=n.map(e=>(xe=Math.max(e.timestamp??xe,xe),xe)),Ce=e=>R[e-n.length];if(R.length){let e;t[41]===Ce?e=t[42]:(e=e=>Ce(e)?.afterMessageIndex??e,t[41]=Ce,t[42]=e);let n=e,r=e=>Se[n(e)]??Ce(e)?.timestamp??0;J.sort((e,t)=>{let i=r(e.index)-r(t.index)||n(e.index)-n(t.index),a=Ce(e.index),o=Ce(t.index);return i||(a&&o?a.timestamp-o.timestamp:0)||e.index-t.index})}let we=new Map(J.map((e,t)=>{let n=J[t-1],r=Ce(e.index)?.afterMessageIndex;return n&&r!==void 0&&(e.compactTop=n.index===r||Ce(n.index)?.afterMessageIndex===r),[e.index,n?.index]})),Te=new Map,Ee;for(let{index:e}of J)e>=n.length||(Ee!==void 0&&Te.set(e,Ee),Ee=e);let De=e=>{let{index:t,compactTop:r}=e;if(t>=n.length){let e=Ce(t);return(0,X.jsx)(`div`,{className:r&&!ae?`-mt-5`:void 0,"data-chat-timeline-entry":e.id,"data-chat-timeline-index":t,children:e.content},e.id)}let i=n[t],l=_e(i,t),u=t===le,f=n[t-1],m=ve(i,t),h=we.get(t),g=h===void 0?void 0:n[h],_=Te.get(t),v=_===void 0?void 0:n[_],y=v&&_!==void 0?ve(v,_)?n[_-1]?.timestamp??v.timestamp:v.timestamp:void 0,C=Pv(i,t),k=m?f?.timestamp??i.timestamp:i.timestamp,A=jb(k,y);return(0,X.jsxs)(`div`,{id:`chat-message-${t}`,className:Y(`scroll-mt-4`,g&&(g.role===`user`||g.role===`task`)&&!m&&!A&&`-mt-5`),"data-chat-message-index":t,"data-chat-message-row":!0,"data-client-submission-id":i.clientSubmissionId,"data-message-render-key":i.renderKey,children:[m?(0,X.jsx)(`span`,{id:`chat-message-${t-1}`,className:`block h-0 scroll-mt-4`,"aria-hidden":!0}):null,A&&k?(0,X.jsx)(`div`,{className:`mb-8 flex justify-center`,"data-chat-time-separator":!0,children:(0,X.jsx)(`time`,{suppressHydrationWarning:!0,className:`rounded-md px-2 py-1 text-xs tabular-nums text-fg-disabled`,dateTime:new Date(k).toISOString(),children:Mb(k,ce,ne)})}):null,i.role===`task`&&i.taskTrigger?(0,X.jsx)(sb,{trigger:i.taskTrigger}):(0,X.jsx)(Tb,{message:i,personal:z,followUpTrigger:m,authToken:a,conversationId:o,workspaceConversationId:s,projectId:c,isStreaming:l,progress:l&&!K?d:null,reasoningLevel:p,messageIndex:t,onDeleteRound:i.pendingSteer||i.clarificationChoice?void 0:b,onRetryUserMessageRound:x,userMessageCanRetry:!!x&&u&&!i.clarificationChoice,deleteRoundDisabled:!!(S&&u),onSaveAssistantAsNote:w,onSaveAssistantToSourceNote:T,onExtractAssistantTask:E,onForkAssistantTurn:D,suppressAssistantActions:ee,onEditUserMessage:O,userMessageCanEdit:!i.pendingSteer&&!i.clarificationChoice&&(!H||u)&&(!U||!!Nr(i))&&i.deliveryStatus!==`sending`,responseFeedbackEnabled:j,showAssistantWorkLog:W})]},C)},Oe=ae?`pt-8`:`contents`,ke;t[43]===Oe?ke=t[44]:(ke=Y(Oe),t[43]=Oe,t[44]=ke);let Ae;t[45]!==d||t[46]!==K?(Ae=K?(0,X.jsx)(pT,{progress:d}):null,t[45]=d,t[46]=K,t[47]=Ae):Ae=t[47];let je;t[48]!==ue?.status||t[49]!==pe||t[50]!==f||t[51]!==de?(je=!de&&f&&ue?.status!==`failed`?(0,X.jsx)(Tg,{errorText:f,onRetry:pe}):null,t[48]=ue?.status,t[49]=pe,t[50]=f,t[51]=de,t[52]=je):je=t[52];let Me;t[53]!==I||t[54]!==ae?(Me=I&&(0,X.jsx)(`div`,{ref:I,className:Y(!ae&&`-mt-8`,`shrink-0 transition-none`),"aria-hidden":!0,"data-chat-reply-space":!0}),t[53]=I,t[54]=ae,t[55]=Me):Me=t[55];let Ne;t[56]!==ke||t[57]!==Ae||t[58]!==je||t[59]!==Me||t[60]!==F?(Ne=(0,X.jsxs)(`div`,{className:ke,children:[Ae,je,F,Me]}),t[56]=ke,t[57]=Ae,t[58]=je,t[59]=Me,t[60]=F,t[61]=Ne):Ne=t[61];let Pe=Ne,Fe=Yy,Ie=ja,Le=!ae&&`flex flex-col gap-8`,Re;t[62]===Le?Re=t[63]:(Re=Y(`w-full min-w-0 pb-8`,Le),t[62]=Le,t[63]=Re);let ze=ae||void 0,Be=ae&&L?(0,X.jsx)(fT,{rows:J,scrollRef:L,renderRow:De,footer:Pe}):(0,X.jsxs)(X.Fragment,{children:[J.map(De),Pe]}),Ve;t[64]!==m||t[65]!==Re||t[66]!==ze||t[67]!==Be?(Ve=(0,X.jsx)(`div`,{ref:m,className:Re,"data-chat-virtualized":ze,children:Be}),t[64]=m,t[65]=Re,t[66]=ze,t[67]=Be,t[68]=Ve):Ve=t[68];let He;t[69]!==Ie||t[70]!==Ve?(He=(0,X.jsx)(Ie,{children:Ve}),t[69]=Ie,t[70]=Ve,t[71]=He):He=t[71];let Ue;return t[72]!==Fe||t[73]!==he||t[74]!==He?(Ue=(0,X.jsx)(Fe,{value:he,children:He}),t[72]=Fe,t[73]=he,t[74]=He,t[75]=Ue):Ue=t[75],Ue});function _T(e){return e.language}function vT(e){return!e.pendingSteer}function yT(e){return e.role===`user`&&!e.pendingSteer}function bT(e){return e.outcome}function xT(e){return e.type===`tool_use`}function ST(e){return e.content.some(xT)}function CT(e){let t=(0,Z.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,X.jsxs)(`linearGradient`,{id:`xopc-onboarding-ai-glass`,x1:`198`,y1:`180`,x2:`826`,y2:`844`,gradientUnits:`userSpaceOnUse`,children:[(0,X.jsx)(`stop`,{stopColor:`var(--xopc-loop-ai-highlight)`}),(0,X.jsx)(`stop`,{offset:`0.46`,stopColor:`var(--xopc-loop-ai)`}),(0,X.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,X.jsxs)(`svg`,{className:`size-full overflow-visible`,viewBox:`0 0 1024 1024`,fill:`none`,"aria-hidden":`true`,children:[(0,X.jsxs)(`defs`,{children:[c,(0,X.jsxs)(`linearGradient`,{id:`xopc-onboarding-human-glass`,x1:`340`,y1:`224`,x2:`700`,y2:`816`,gradientUnits:`userSpaceOnUse`,children:[(0,X.jsx)(`stop`,{stopColor:`var(--xopc-loop-human-highlight)`}),(0,X.jsx)(`stop`,{offset:`0.52`,stopColor:`var(--xopc-loop-human)`}),(0,X.jsx)(`stop`,{offset:`1`,stopColor:`var(--xopc-loop-human-shadow)`})]})]}),(0,X.jsx)(`circle`,{className:`xopc-loop-logo__ambient`,cx:`512`,cy:`512`,r:`330`}),(0,X.jsx)(`circle`,{className:`xopc-loop-logo__origin`,cx:`512`,cy:`512`,r:`330`}),(0,X.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,X.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,X.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,X.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,X.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 wT=(0,Q.memo)(function(e){let t=(0,Z.c)(19),{visible:n,onClick:r,edge:i,running:a}=e,o=i===void 0?`top`:i,s=a!==void 0&&a,c=y(TT),l;t[0]===c?l=t[1]:(l=C(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 h=n?`scale-100 opacity-100`:`pointer-events-none translate-y-1 scale-95 opacity-0`,g;t[5]===h?g=t[6]:(g=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`,Pa.transition,Pa.press,Pa.focusRingPanel,h,`motion-reduce:translate-y-0 motion-reduce:scale-100`),t[5]=h,t[6]=g);let _=n?void 0:-1,v;t[7]===s?v=t[8]:(v=s?(0,X.jsx)(`span`,{"data-scroll-to-bottom-running-logo":!0,className:`flex size-5 items-center justify-center`,"aria-hidden":!0,children:(0,X.jsx)(CT,{className:`xopc-loop-logo--stream size-5`})}):(0,X.jsx)(Js,{"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]=v);let b;t[9]!==u.chat.scrollToBottom||t[10]!==r||t[11]!==_||t[12]!==v||t[13]!==g?(b=(0,X.jsx)(`button`,{type:`button`,className:g,tabIndex:_,onClick:r,title:u.chat.scrollToBottom,"aria-label":u.chat.scrollToBottom,children:v}),t[9]=u.chat.scrollToBottom,t[10]=r,t[11]=_,t[12]=v,t[13]=g,t[14]=b):b=t[14];let x;return t[15]!==b||t[16]!==d||t[17]!==m?(x=(0,X.jsx)(`div`,{"data-scroll-to-bottom-dock":!0,"aria-hidden":d,className:m,children:b}),t[15]=b,t[16]=d,t[17]=m,t[18]=x):x=t[18],x});function TT(e){return e.language}function ET(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 DT(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 OT(e){return e.webkitDirectionInvertedFromDevice===!0?e.deltaY>0:e.deltaY<0}function kT(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 AT(e){let t=(0,Z.c)(50),{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,k]=(0,Q.useState)(!1),A=(0,Q.useRef)(null),j;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>{D(e),e&&k(!1)},t[0]=j):j=t[0];let M=j,N=(0,Q.useRef)(!0),P=(0,Q.useRef)(0),F=(0,Q.useRef)(o),I;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(I={first:void 0,len:0,scrollHeight:0},t[1]=I):I=t[1];let L=(0,Q.useRef)(I),R;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(R=e=>{p.current=e,e&&(S.current=null)},t[2]=R):R=t[2];let z=R,B;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(B=e=>{let t=u.current;if(!t)return;let n=tT(t);z(n),M(n),_.current=n?e:null,n||(S.current=ET(t))},t[3]=B):B=t[3];let V=B,H;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>{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[4]=H):H=t[4];let U=H,W;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(W=e=>{let t=u.current;if(!t||!e?.force&&!p.current)return;e?.force&&(z(!0),k(!1));let n=sT(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:iT()});return}nT(t),w.current=t.scrollHeight,T.current=t.clientHeight,M(tT(t))},t[5]=W):W=t[5];let ee=W,te;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(te=()=>{let e=u.current;!e||e.scrollHeight<=e.clientHeight||(z(!1),M(tT(e)))},t[6]=te):te=t[6];let ne=te,re;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(re=()=>{let e=u.current;if(!e)return;!p.current&&!sT(e)&&DT(e,S.current);let t=U(),n=e.scrollHeight>w.current,r=e.clientHeight<T.current;w.current=e.scrollHeight,T.current=e.clientHeight,(n||r||t)&&ee(),M(tT(e))},t[7]=re):re=t[7];let ie=re,ae;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(ae=()=>{let e=u.current;e&&p.current&&(sT(e)?nT(e):e.scrollHeight>w.current&&ee()),C.current===null&&(C.current=requestAnimationFrame(()=>{C.current=null,ie()}))},t[8]=ae):ae=t[8];let oe=ae,se;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(se=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(oe);t.observe(e),x.current=t;let n=new MutationObserver(e=>{let t=u.current;!t||!p.current||!sT(t)||(U()||e.some(jT))&&nT(t)});n.observe(e,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:[`style`]}),b.current=n},t[9]=se):se=t[9];let ce=se,le,ue;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(le=()=>()=>{x.current?.disconnect(),b.current?.disconnect(),C.current!==null&&(cancelAnimationFrame(C.current),C.current=null)},ue=[],t[10]=le,t[11]=ue):(le=t[10],ue=t[11]),(0,Q.useEffect)(le,ue);let de;t[12]!==s||t[13]!==l||t[14]!==c?(de=()=>{let e=u.current;if(!e)return;let t=tT(e),n=T.current>0&&(e.scrollHeight!==w.current||e.clientHeight!==T.current);if(A.current!==null){let r=e.scrollTop-A.current;A.current=e.scrollTop,!t&&!n&&r!==0&&k(r>0)}if(!t&&p.current&&n){M(!1),oe();return}z(t),t||(S.current=ET(e)),M(t),t&&U(),e.scrollTop<100&&!t&&s&&!c&&l()},t[12]=s,t[13]=l,t[14]=c,t[15]=de):de=t[15];let fe=de,pe;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(pe=e=>{ee({force:!0,smooth:e===void 0||e})},t[16]=pe):pe=t[16];let G=pe,me,he;t[17]!==n||t[18]!==r?(me=()=>{if(n){if(r){N.current=!0;return}N.current===!0&&(N.current=!1,z(!0),ee({force:!0}))}},he=[r,n,z,ee],t[17]=n,t[18]=r,t[19]=me,t[20]=he):(me=t[19],he=t[20]),(0,Q.useLayoutEffect)(me,he);let K;t[21]!==n||t[22]!==r?(K=()=>{!n||r||(L.current={first:void 0,len:0,scrollHeight:0},P.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`),z(!0),ee({force:!0}))},t[21]=n,t[22]=r,t[23]=K):K=t[23];let ge;t[24]!==i||t[25]!==n||t[26]!==r?(ge=[i,n,r,z,ee],t[24]=i,t[25]=n,t[26]=r,t[27]=ge):ge=t[27],(0,Q.useLayoutEffect)(K,ge);let _e,q;t[28]!==a||t[29]!==r||t[30]!==o?(_e=()=>{if(r)return;let e=F.current&&!o;F.current=o;let t=U(),n=a.length,i=P.current;P.current=n;let s=(u.current?.scrollHeight??0)>w.current;p.current&&(n>i||s||t||e)&&ee()},q=[a,o,r,ee,U],t[28]=a,t[29]=r,t[30]=o,t[31]=_e,t[32]=q):(_e=t[31],q=t[32]),(0,Q.useLayoutEffect)(_e,q);let ve,ye;t[33]!==a||t[34]!==r?(ve=()=>{let e=u.current;if(!e||r)return;let t=L.current,n=a[0],i=a.length,o=e.scrollHeight,s=i-t.len;s>0&&t.len>0&&!kT(n,t.first)&&kT(a[s],t.first)&&!sT(e)&&t.scrollHeight>0&&!DT(e,S.current)&&(e.scrollTop+=o-t.scrollHeight),L.current={first:n,len:i,scrollHeight:o}},ye=[a,r],t[33]=a,t[34]=r,t[35]=ve,t[36]=ye):(ve=t[35],ye=t[36]),(0,Q.useLayoutEffect)(ve,ye);let J,be;t[37]!==n||t[38]!==r?(J=()=>{if(!n||r)return;let e=u.current;if(!e)return;let t=new ResizeObserver(oe);t.observe(e);let i=t=>{t.ctrlKey||t.shiftKey||Math.abs(t.deltaY)<Math.abs(t.deltaX)||Math.abs(t.deltaY)<.25||(OT(t)&&ne(),k(t.deltaY>0&&!tT(e)))},a=null,o=e=>{a=e.touches.length===1?e.touches[0]:null},s=t=>{let n=a;if(o(t),!n||!a)return;let r=a.clientY-n.clientY,i=a.clientX-n.clientX;Math.abs(r)<=2||Math.abs(r)<Math.abs(i)||(r>2&&ne(),k(r<0&&!tT(e)))},c=t=>{if(t.target!==e||t.altKey||t.ctrlKey||t.metaKey)return;let n=[`ArrowUp`,`PageUp`,`Home`].includes(t.key)||t.key===` `&&t.shiftKey,r=[`ArrowDown`,`PageDown`,`End`].includes(t.key)||t.key===` `&&!t.shiftKey;n&&ne(),(n||r)&&k(r&&!tT(e))},l=t=>{if(t.button!==0||t.pointerType===`touch`||t.target!==e)return;let n=e.getBoundingClientRect().left+e.clientLeft+e.clientWidth;t.clientX>=n&&(A.current=e.scrollTop,ne())},d=()=>{A.current=null},f=()=>{let t=window.getSelection();!t||t.isCollapsed||!e.contains(t.anchorNode)||(ne(),S.current=ET(e))},p=t=>{(t.target instanceof Element?t.target:null)?.closest(`button[aria-expanded="false"]:not([aria-haspopup]), summary`)&&(ne(),S.current=ET(e))};return e.addEventListener(`chat-scroll-reading`,ne),e.addEventListener(`wheel`,i,{passive:!0}),e.addEventListener(`keydown`,c),e.addEventListener(`pointerdown`,l),e.addEventListener(`touchstart`,o,{passive:!0}),e.addEventListener(`touchmove`,s,{passive:!0}),e.addEventListener(`click`,p,!0),document.addEventListener(`selectionchange`,f),window.addEventListener(`pointerup`,d,!0),window.addEventListener(`pointercancel`,d,!0),()=>{d(),t.disconnect(),e.removeEventListener(`chat-scroll-reading`,ne),e.removeEventListener(`wheel`,i),e.removeEventListener(`keydown`,c),e.removeEventListener(`pointerdown`,l),e.removeEventListener(`touchstart`,o),e.removeEventListener(`touchmove`,s),e.removeEventListener(`click`,p,!0),document.removeEventListener(`selectionchange`,f),window.removeEventListener(`pointerup`,d,!0),window.removeEventListener(`pointercancel`,d,!0)}},be=[n,r,ne,oe],t[37]=n,t[38]=r,t[39]=J,t[40]=be):(J=t[39],be=t[40]),(0,Q.useLayoutEffect)(J,be);let xe;t[41]===n?xe=t[42]:(xe=()=>{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,oe()};r();let i=new ResizeObserver(r);return i.observe(t),()=>{i.disconnect(),e.style.removeProperty(`padding-bottom`),e.style.removeProperty(`scroll-padding-bottom`)}},t[41]=n,t[42]=xe);let Se;t[43]!==n||t[44]!==r?(Se=[n,r,oe],t[43]=n,t[44]=r,t[45]=Se):Se=t[45],(0,Q.useLayoutEffect)(xe,Se);let Ce=!E&&O,we;return t[46]!==E||t[47]!==fe||t[48]!==Ce?(we={scrollRef:u,composerDockRef:d,atBottom:E,showScrollToBottom:Ce,registerListContentRef:ce,scrollToBottom:G,onScroll:fe,replySpaceRef:m,reserveReplySpace:V},t[46]=E,t[47]=fe,t[48]=Ce,t[49]=we):we=t[49],we}function jT(e){return e.target instanceof HTMLElement&&e.target.hasAttribute(`data-virtuoso-scroller`)}var MT=256*1024,NT=new TextEncoder;function PT(e){return NT.encode(e).byteLength}function FT(e){return PT(e)<=262144?e:new TextDecoder().decode(NT.encode(e).subarray(0,MT),{stream:!0})}function IT(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(`
63
- `);if((i.content.some(e=>e.type!==`text`)||i.attachments?.length)&&(n=!0),!e)continue;if(t<=256){n=!0;continue}let a=NT.encode(e),o=a.byteLength+256>t?new TextDecoder().decode(a.subarray(0,t-256),{stream:!0}):e;o!==e&&(n=!0);let s=PT(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 LT=`xopc:side-chat-panes:v3`,RT={text:``,attachments:[]};function zT(e){return Math.min(760,Math.max(360,Math.round(e)))}function BT(){return{panes:{},tabs:[],widthPx:520}}function VT(){try{let e=JSON.parse(sessionStorage.getItem(LT)||`{}`),t=e.identity;if(t&&t!==v.getState().conversationId)return BT();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:zT(typeof e.widthPx==`number`?e.widthPx:520)}}catch{return BT()}}function HT(e){try{sessionStorage.setItem(LT,JSON.stringify({...e,identity:v.getState().conversationId}))}catch{}}var UT=VT(),WT=x((e,t)=>{let n=n=>{e(n),queueMicrotask(()=>{let e=t();HT({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{...UT,drafts:{},readings:{},setDraftText:(n,r)=>e({drafts:{...t().drafts,[n]:{...t().drafts[n]??RT,text:r}}}),setDraftAttachments:(n,r)=>e({drafts:{...t().drafts,[n]:{...t().drafts[n]??RT,attachments:r}}}),rememberMessages:(n,r)=>{let i={...t().readings};delete i[n],i[n]=IT(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)=>{Xi.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]??RT},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:()=>{Xi.getState().reset(),e({drafts:{},readings:{},pendingCreate:null,creatingRequests:{}}),n({panes:{},tabs:[]})},pendingCreate:null,creatingRequests:{},requestCreate:(n,i=[])=>{Xi.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)=>{Xi.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;Xi.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&&(Xi.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(Xi.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&&Xi.getState().activate(`side:${o.id}`,e),o||i.requestCreate(e)},setWidthPx:e=>n({widthPx:zT(e)})}});v.subscribe((e,t)=>{if(e.conversationId&&!t.conversationId&&e.baseUrl===t.baseUrl){let e=VT();WT.setState(e)}if(e.baseUrl!==t.baseUrl||t.conversationId!==void 0&&e.conversationId!==t.conversationId){WT.getState().reset();try{sessionStorage.removeItem(`xopc:side-chat-client-id`)}catch{}}});function GT(e){return e.acceptsArgs?`/${e.name} `:`/${e.name}`}var KT=3e4,qT=null;function JT(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 YT(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(qT&&qT.key===n&&e-qT.at<KT)return qT.items.map(e=>({...e,...o.has(e.relativePath)?{isRecent:!0}:{isRecent:void 0}}))}let s={conversationId:n,agentId:r},c=JT(a.length===0?await So(``,s):await xo(a,s,i),o);return n&&a.length===0&&(qT={key:n,at:Date.now(),items:c}),c}async function XT(e,t){return So(e,{conversationId:t.conversationId,agentId:t.agentId})}function ZT(e,...t){let n=e.trim().toLocaleLowerCase();return!n||t.some(e=>e?.toLocaleLowerCase().includes(n))}async function QT(e){let t=await g(_(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 $T=[{kind:`file`,search:(e,t)=>YT(e,{conversationId:t.conversationId,agentId:t.currentAgentId,limit:10,recentPaths:t.recentPaths})},{kind:`note`,async search(e,t){return(await Re({...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()||C(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 On({...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 Qo(t.currentAgentId,t.conversationId)).skills.flatMap(n=>{if(!n.availableForCurrentAgent)return[];let r=as(n,t.language);return ZT(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 Mi(),r=C(t.language).agentsSettings;return n.items.flatMap(t=>{let n=mo(t,r),i=ho(t,r);return ZT(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 QT(`/api/browser/tabs?${new URLSearchParams({conversationId:t.conversationId})}`)).tabs.flatMap(n=>!ZT(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}}])}}],eE=(0,Q.createContext)({target:null,register:()=>()=>{}});function tE(e){let t=(0,Z.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,X.jsx)(eE,{value:u,children:n}),t[6]=n,t[7]=u,t[8]=d):d=t[8],d}function nE(){let e=(0,Z.c)(2),{register:t}=(0,Q.useContext)(eE),n;return e[0]===t?n=e[1]:(n=(0,X.jsx)(`div`,{ref:t,className:`min-w-0 shrink-0`}),e[0]=t,e[1]=n),n}function rE(){return(0,Q.useContext)(eE).target}function iE({conversationId:e,turnId:t,requestKey:n,assistantOnly:r,messages:i,ready:a,hasMore:o,loadingMore:s,loadMore:c,reveal:l,onLocated:u}){let d=(0,Q.useRef)({key:``,finished:!1,requestedLength:-1});(0,Q.useEffect)(()=>{let f=JSON.stringify([e,t,n]);if(d.current.key!==f&&(d.current={key:f,finished:!1,requestedLength:-1}),!t||!a||d.current.finished)return;let p=d.current,m=i.findIndex(e=>e.turnId===t&&(!r||e.role===`assistant`));if(m>=0){let e=0,t=!1,n=0,r=()=>{t||d.current===p&&(l(m)?(p.finished=!0,u?.(!0)):++n<3?e=requestAnimationFrame(r):(p.finished=!0,u?.(!1)))};return e=requestAnimationFrame(r),()=>{t=!0,cancelAnimationFrame(e)}}if(!s){if(!o||d.current.requestedLength===i.length){d.current.finished=!0,u?.(!1);return}d.current.requestedLength=i.length,c().catch(()=>{d.current===p&&(p.finished=!0,u?.(!1))})}},[e,t,n,r,i,a,o,s,c,l,u])}function aE({interaction:e,path:t,complete:n}){let r=y(e=>e.language)===`zh`,[i,a]=(0,Q.useState)(`{}`),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1),u=async r=>{s(!0),l(!1);try{let a=r===`accept`?JSON.parse(i):void 0;if(r===`accept`&&(!a||typeof a!=`object`||Array.isArray(a)))throw Error(`Expected an object`);await b(t,{method:`POST`,body:JSON.stringify({requestId:e.requestId,action:r,content:a})}),n()}catch{l(!0)}finally{s(!1)}},d=Object.entries(e.inputSchema.properties??{});return(0,X.jsxs)(`form`,{className:`space-y-2 rounded-xl border border-edge bg-surface p-3 text-sm`,onSubmit:e=>{e.preventDefault(),u(`accept`)},children:[(0,X.jsx)(`p`,{className:`font-medium text-fg`,children:r?`设备需要补充信息`:`Device needs input`}),(0,X.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-fg-muted`,children:e.message}),d.length?(0,X.jsx)(`ul`,{className:`max-h-24 overflow-y-auto text-xs text-fg-muted`,children:d.map(([t,n])=>(0,X.jsxs)(`li`,{children:[t,n.type?` (${n.type})`:``,e.inputSchema.required?.includes(t)?` *`:``,Array.isArray(n.enum)?` · ${JSON.stringify(n.enum).slice(0,180)}`:``]},t))}):null,(0,X.jsx)(`textarea`,{value:i,onChange:e=>a(e.target.value),maxLength:7e3,"aria-label":r?`设备请求参数(JSON)`:`Device response (JSON)`,className:`h-16 w-full resize-none rounded-md border border-edge bg-surface p-2 font-mono text-xs`}),c?(0,X.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:r?`输入不符合要求,或设备请求已结束。`:`The input is invalid or the device request has ended.`}):null,(0,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,X.jsx)(Yi,{type:`button`,variant:`secondary`,disabled:o,onClick:()=>void u(`decline`),children:r?`拒绝`:`Decline`}),(0,X.jsx)(Yi,{type:`submit`,disabled:o,children:r?`提交给设备`:`Send to device`})]})]})}function oE(e){let t=(0,Z.c)(8),{conversationId:n,active:r}=e,i;t[0]===n?i=t[1]:(i=n?_(`/api/endpoint-tools/interactions/${encodeURIComponent(n)}`):null,t[0]=n,t[1]=i);let a=i,o=r?1500:5e3,s;t[2]===o?s=t[3]:(s={refreshInterval:o,shouldRetryOnError:!1},t[2]=o,t[3]=s);let{data:c,mutate:l}=bi(a,sE,s),u=c?.payload?.[0],d;return t[4]!==u||t[5]!==l||t[6]!==a?(d=a&&u?(0,X.jsx)(aE,{interaction:u,path:a,complete:()=>{l()}},u.requestId):null,t[4]=u,t[5]=l,t[6]=a,t[7]=d):d=t[7],d}function sE(e){return b(e)}function cE(e){let t=(0,Z.c)(24),{sk:n,onPick:r,disabled:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(Gt,{className:`size-4`,"aria-hidden":!0}),t[0]=a):a=t[0];let o;t[1]===n.findCapability?o=t[2]:(o=(0,X.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,X.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,X.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,X.jsx)(Yi,{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 u;t[14]===l?u=t[15]:(u=(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:l}),t[14]=l,t[15]=u);let d;t[16]===n.findBack?d=t[17]:(d=(0,X.jsx)(h,{to:`/capabilities/skills`,className:`text-sm text-accent-fg hover:underline`,children:n.findBack}),t[16]=n.findBack,t[17]=d);let f;return t[18]!==o||t[19]!==s||t[20]!==c||t[21]!==u||t[22]!==d?(f=(0,X.jsxs)(`section`,{className:`mx-auto flex max-w-xl flex-col items-start gap-4 py-8 sm:py-12`,children:[o,s,c,u,d]}),t[18]=o,t[19]=s,t[20]=c,t[21]=u,t[22]=d,t[23]=f):f=t[23],f}function lE(e){let t=`/api/sessions/${encodeURIComponent(e)}/connection-wait`,n=Sr(t=>t.sessions[e]?.localDraft),{data:r,mutate:i,isLoading:a}=bi(n?null:[t,n===!1?`persisted`:`unknown`],async()=>await $r(e)?null:(await b(_(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),[p,m]=(0,Q.useState)(),[h,g]=(0,Q.useState)(),v=(0,Q.useCallback)(async(e,n,r,a,d)=>{let p=o.current,h=p?.wait;if(!h||(e===`cancel`?c.current:s.current||c.current))return!1;e===`cancel`?c.current=!0:s.current=!0,l.current+=1,f(!0),m(void 0),e===`cancel`&&g(void 0);let v=h.needs.find(e=>e.key===n),x=e===`connect`&&v?.target.type!==`plugin`?Vs():null,S=JSON.stringify([h.id,h.objectiveRevision,e,n,r,a,d]);u.current?.signature!==S&&(u.current={signature:S,key:crypto.randomUUID()});let C=u.current.key,w=i=>b(_(`${t}/actions`),{method:`POST`,body:JSON.stringify({action:e,needKey:n,accountId:r,candidateRef:a,instanceId:d,waitId:h.id,expectedTranscriptId:i.transcriptId,expectedVersion:i.wait.version,...e===`cancel`?{expectedObjectiveRevision:h.objectiveRevision}:{},idempotencyKey:C})});try{let n;try{n=await w(p)}catch(r){if(e!==`cancel`||r.status!==409)throw r;let a=(await b(_(t))).payload;if(await i(e=>!e||e.transcriptId!==a.transcriptId||a.revision>=e.revision?a:e,!1),a.transcriptId!==p.transcriptId||a.wait?.id!==h.id||a.wait.objectiveRevision!==h.objectiveRevision)throw r;n=await w(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 Bs(n.payload.authorizationUrl,x))throw Error(`Unable to open the authorization window. Allow pop-ups, then retry.`)}else Hs(x);return u.current?.signature===S&&(u.current=null),!0}catch(t){if(Hs(x),t.status===409&&e===`cancel`){let e=y.getState().language===`zh`?`目标状态已变化,未能取消。请检查当前任务状态后再试。`:`The objective state changed and cancellation was not confirmed. Check its current status and try again.`;m(e),g(e)}else if(t.status!==409){let n=t instanceof Error?t.message:String(t);m(n),e===`cancel`&&g(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:p,cancellationError:h,act:v,dismissError:()=>{m(void 0),g(void 0)}}}function uE(e){let t=(0,Z.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,X.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,X.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,X.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,X.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,X.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,X.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,X.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,X.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,X.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,X.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 dE=(0,Q.lazy)(()=>u(()=>import(`./mcp-conversation-setup-page-DffQKrjd.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]))),fE={zh:{connection:`服务连接`,cancel:`取消连接请求`,close:`关闭`,finish:`检查连接`,source:`查看来源`,enter:`填写访问密钥`,login:`登录并继续`,waiting:`等待完成登录`,review:`查看连接`,reconnect:`更新密钥`,configureToken:`配置 MCP Token`,tokenPrepared:`连接已准备好,填写 Token 即可连接`,expired:`连接请求已过期`,rejected:`服务未接受当前密钥`,token:`需要访问密钥`,oauth:`需要登录授权`,unknown:`无法确认认证方式`,failed:`连接检查未通过`,planned:`正在检查连接`,approval:`请确认服务和资料来源`,reload:`配置已保存,重启 Gateway 后生效`,help:`获取访问密钥`,connected:`连接已完成`,continuing:`连接已完成,原任务将自动继续`,cancelFailed:`暂时无法取消连接,请重试。`},en:{connection:`Service connection`,cancel:`Cancel connection request`,close:`Close`,finish:`Check connection`,source:`Review source`,enter:`Enter access key`,login:`Sign in and continue`,waiting:`Waiting for sign-in`,review:`View connection`,reconnect:`Update key`,configureToken:`Set up MCP Token`,tokenPrepared:`Connection prepared. Add your Token to connect.`,expired:`Connection request expired`,rejected:`The service rejected the current key`,token:`Access key required`,oauth:`Sign-in required`,unknown:`Could not verify the authentication method`,failed:`Connection check failed`,planned:`Checking the connection`,approval:`Review the service and its sources`,reload:`Settings saved. Restart the Gateway to apply them.`,help:`Get an access key`,connected:`Connection complete`,continuing:`Connection complete. Your task will resume automatically.`,cancelFailed:`Could not cancel the connection. Try again.`}};function pE({conversationId:e}){let t=y(e=>e.language),[n,r]=d(),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(),[c,l]=(0,Q.useState)(),u=fE[t];(0,Q.useEffect)(()=>{if(!c)return;let e=window.setTimeout(()=>l(void 0),8e3);return()=>window.clearTimeout(e)},[c]);let f=n.get(`mcpSetup`),p=e=>{let t=new URLSearchParams(n);e?t.set(`mcpSetup`,e):t.delete(`mcpSetup`),r(t,{replace:!e})},{data:m,mutate:g}=bi(`/api/mcp/setup/conversations/${encodeURIComponent(e)}`,async e=>{try{return{permitted:!0,...(await b(_(e))).payload}}catch(e){if([403,404].includes(e.status??0))return{permitted:!1,setup:null};throw e}},{refreshInterval:e=>e?.setup?5e3:0,shouldRetryOnError:!1});(0,Q.useEffect)(()=>{if(m?.permitted===!1)return;let t=t=>{let n=t.detail;(n?.conversationId??n?.key)===e&&g()},n=()=>{g()};return window.addEventListener(`session-mcp-setup-changed`,t),window.addEventListener(`session-transcript-updated`,t),window.addEventListener(`gateway-realtime-connected`,n),()=>{window.removeEventListener(`session-mcp-setup-changed`,t),window.removeEventListener(`session-transcript-updated`,t),window.removeEventListener(`gateway-realtime-connected`,n)}},[e,g,m?.permitted]);let v=f?(0,X.jsx)(Q.Suspense,{fallback:null,children:(0,X.jsx)(dE,{setupId:f,onClose:t=>{t?.phase===`ready`&&!t.reloadRequired&&t.conversationId===e&&l({conversationId:e,label:t.displayName||t.serverId,continuing:t.continuationQueued===!0&&t.objective!==`connect_only`}),p(null),g()}})}):null;if(!m?.setup)return(0,X.jsxs)(X.Fragment,{children:[c?.conversationId===e?(0,X.jsxs)(`section`,{className:`mb-2 flex items-center gap-3 rounded-xl border border-edge bg-success-soft px-3 py-2 text-sm text-fg`,children:[(0,X.jsx)(ne,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,X.jsxs)(`p`,{role:`status`,className:`min-w-0 flex-1 break-words`,children:[c.label,` · `,c.continuing?u.continuing:u.connected]}),(0,X.jsx)(Yi,{variant:`ghost`,className:`size-11 shrink-0 p-0`,"aria-label":u.close,onClick:()=>l(void 0),children:(0,X.jsx)(an,{className:`size-4`,"aria-hidden":!0})})]}):null,v]});let x=m.setup,S=async()=>{a(!0),s(void 0);try{await b(_(`/api/mcp/setup/${encodeURIComponent(x.setupId)}`),{method:`POST`,body:JSON.stringify({action:`cancel`,expectedVersion:x.version})}),f===x.setupId&&p(null),await g(e=>e?.setup?.setupId===x.setupId?{...e,setup:null}:e)}catch{s(x.setupId),g()}finally{a(!1)}},C=x.errorCode===`credential_rejected`,w=x.expired?u.expired:x.reloadRequired?u.reload:C?u.rejected:x.approveWithToken?u.tokenPrepared:x.phase===`token_required`?u.token:[`oauth_required`,`authorizing`].includes(x.phase)?u.oauth:x.phase===`auth_unknown`?u.unknown:x.phase===`blocked`?u.failed:x.phase===`approval_required`?u.approval:x.phase===`ready`?u.connected:u.planned,T=x.expired||x.reloadRequired?u.review:C?u.reconnect:x.approveWithToken?u.configureToken:x.phase===`approval_required`?u.source:x.phase===`token_required`||x.canProvideToken?u.enter:x.phase===`oauth_required`?u.login:x.phase===`authorizing`?u.waiting:[`blocked`,`auth_unknown`,`ready`].includes(x.phase)?u.review:u.finish;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`section`,{className:`mb-2 flex flex-wrap items-center gap-2 rounded-xl border border-edge bg-surface-panel px-3 py-2`,"aria-label":u.connection,children:[(0,X.jsx)(We,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 break-words text-sm`,role:`status`,children:[(0,X.jsx)(`p`,{className:`font-medium text-fg`,children:x.displayName||x.serverId}),x.purpose&&!x.approveWithToken?(0,X.jsx)(`p`,{className:`mt-0.5 break-words text-sm text-fg-muted`,children:x.purpose}):null,(0,X.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:w})]}),(0,X.jsx)(Yi,{asChild:!0,variant:`primary`,className:`min-h-11 shrink-0 rounded-lg`,children:(0,X.jsx)(h,{to:`/mcp-setup/${encodeURIComponent(x.setupId)}`,onClick:e=>{e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),p(x.setupId))},children:T})}),(0,X.jsx)(Yi,{variant:`ghost`,className:`size-11 shrink-0 p-0`,"aria-label":u.cancel,title:u.cancel,disabled:i,onClick:()=>void S(),children:(0,X.jsx)(an,{className:`size-4`,"aria-hidden":!0})}),!x.expired&&x.phase===`token_required`&&x.helpUrl?(0,X.jsx)(`div`,{className:`basis-full pl-6`,children:(0,X.jsxs)(`a`,{href:x.helpUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex min-h-11 items-center text-sm text-accent-fg hover:underline`,children:[u.help,` ↗`]})}):null,o===x.setupId?(0,X.jsx)(`span`,{role:`alert`,className:`basis-full text-sm text-fg-muted`,children:u.cancelFailed}):null]}),v]})}var mE=(0,Q.lazy)(()=>u(()=>import(`./agent-plugin-dialog-CSJC1yud.js`).then(e=>e.n).then(e=>({default:e.AgentPluginDialog})),__vite__mapDeps([30,1,2,3,4,5,6,7,8,9,31,11,32,33,34,16,17,18,29,20,21,35,36,13,37,38,39,40,41,27,28,42,43,44,45]))),hE={zh:{waiting:`等待连接`,reconnectRequired:`需要重新授权`,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`,reconnectRequired:`Reauthorization required`,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.`}},gE=`rounded-lg border border-edge px-3 py-1.5 text-sm text-fg hover:bg-surface-hover disabled:opacity-50`,_E=`rounded-lg bg-accent px-3 py-1.5 text-sm text-on-accent disabled:opacity-50`;function vE({conversationId:e}){let{wait:t,busy:n,error:r,cancellationError:i,act:a,dismissError:o}=lE(e),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(),[d,f]=(0,Q.useState)(),[p,m]=(0,Q.useState)(),[h,g]=(0,Q.useState)(),[v,x]=(0,Q.useState)(!1),[S,T]=(0,Q.useState)(),M=y(e=>e.language),N=hE[M];if(!t)return i?(0,X.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,X.jsx)(`p`,{className:`min-w-0 flex-1`,children:i}),(0,X.jsx)(`button`,{type:`button`,onClick:o,className:gE,children:N.close})]}):(0,X.jsx)(pE,{conversationId:e});let P=t.needs[0],F=t.needs.length===1,I=F&&P.phase===`reconnect`,L=t.phase===`queued`,R=t.recoveryStage===`checking_connection`||t.recoveryStage===`checking_tools`,z=t.needs.find(e=>e.phase===`choose_account`),B=t.needs.some(e=>e.capabilityError);if(t.phase===`ready`&&!R&&!t.recoveryError&&!t.needs.some(e=>e.target.type===`plugin`))return(0,X.jsx)(pE,{conversationId:e});let V=t.recoveryStage===`checking_connection`?N.checkingConnection:t.recoveryStage===`checking_tools`?N.checkingTools:L?t.resolution===`skipped`?N.queuedSkipped:N.queued:t.recoveryError===`check_failed`?N.checkFailed:t.recoveryError?N.interrupted:t.phase===`ready`?N.ready:B?N.toolsUnavailable:z?N.account:F&&P.phase===`authorizing`?N.authorizing:I?N.reconnectRequired:N.waiting,H=L||R?N.details:t.recoveryError?N.retry:t.phase===`review_scope`?N.scope:F&&P.phase===`install`?v?N.installing:`${N.install} ${P.label}`:F&&P.phase===`connect`?M===`zh`?`连接 ${P.label}`:`Connect ${P.label}`:F&&P.phase===`reconnect`?N.reconnect:F&&P.phase===`authorizing`&&P.target.type!==`plugin`?N.check:N.details;async function U(e=P){if(e.target.type===`store-connector`){x(!0),T(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(M===`zh`?`Connector 包在审查后发生了变化,请重新发起推荐。`:`The Connector package changed after review. Request a new recommendation.`);f(Dt(t.definition,{packageName:t.packageName,version:t.version,reviewHash:t.reviewHash,permissions:t.permissions})),m(e.key)}catch(e){T(e instanceof Error?e.message:String(e))}finally{x(!1)}}}async function W(e){if(!(e.target.type!==`plugin`||!t)){x(!0),T(void 0);try{let{target:n,pluginId:r}=e,i=r?(await b(_(`/api/extensions/agent-plugins/${encodeURIComponent(r)}`))).payload:void 0,o=`packageName`in n&&!i?`store:${n.packageName}@${n.version}`:void 0;if(!i&&!o||!await a(`connect`,e.key))return;c(!1),g({waitId:t.id,extension:i,source:o})}catch(e){T(e instanceof Error?e.message:String(e))}finally{x(!1)}}}function ee(){L||R?c(!0):t?.recoveryError?a(`check`):t?.phase===`review_scope`?c(!0):F&&P.target.type===`plugin`&&[`install`,`connect`,`reconnect`,`authorizing`].includes(P.phase)?W(P):F&&P.phase===`install`?U():F&&[`connect`,`reconnect`].includes(P.phase)?a(`connect`,P.key):F&&P.phase===`authorizing`?a(`check`):c(!0)}return(0,X.jsxs)(`section`,{className:`mb-2 rounded-xl border border-edge bg-surface-panel px-3 py-2`,"aria-label":V,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(We,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,X.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left text-sm text-fg`,onClick:()=>c(!0),children:[(0,X.jsx)(`span`,{role:`status`,children:F?`${V} · ${P.label}`:`${V} · ${t.needs.length} ${N.apps}`}),(0,X.jsx)(ie,{className:`ml-1 inline size-3`,"aria-hidden":!0})]}),(0,X.jsxs)(`button`,{type:`button`,className:z||L||R?gE:_E,disabled:n&&!R||v,onClick:ee,children:[n&&(0,X.jsx)(qe,{className:`mr-1 inline size-3 animate-spin`,"aria-hidden":!0}),H]}),!L&&!R&&(0,X.jsx)(`button`,{type:`button`,className:`text-xs text-fg-muted hover:text-fg`,disabled:n,onClick:()=>void a(`skip`),children:N.skip}),(0,X.jsx)(`button`,{type:`button`,className:`min-h-11 px-2 text-xs text-fg-muted hover:text-fg`,onClick:()=>void a(`cancel`),children:N.cancel})]}),I&&!R&&!L?(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:N.intro}):null,t.queueBlocked&&(0,X.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.blockedInputId?N.interruptedInputHint:N.queueHint}),t.lastCheckedAt&&(0,X.jsxs)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:[N.lastChecked,`: `,new Date(t.lastCheckedAt).toLocaleTimeString(M===`zh`?`zh-CN`:`en-US`)]}),z&&!L&&(0,X.jsx)(`p`,{className:`mt-2 line-clamp-2 break-words text-sm text-fg-muted`,children:t.summary}),z&&!L&&(0,X.jsx)(uE,{need:z,language:M,disabled:n||R,onSelect:e=>void a(`select_account`,z.key,e),onConnect:()=>void a(`connect`,z.key)},`${t.id}:${t.objectiveRevision}:${z.key}`),(r||S)&&(0,X.jsxs)(`p`,{role:`alert`,className:`mt-2 text-xs text-fg-muted`,children:[r??S,` `,(0,X.jsx)(`button`,{type:`button`,className:`text-accent`,onClick:()=>void a(`check`),children:N.retry})]}),(0,X.jsx)(j,{open:s,onOpenChange:c,children:(0,X.jsxs)(O,{children:[(0,X.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[2px]`}),(0,X.jsxs)(k,{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,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-5 py-4`,children:[(0,X.jsx)(A,{className:`font-medium text-fg`,children:N.preserved}),(0,X.jsx)(D,{"aria-label":N.close,children:(0,X.jsx)(an,{className:`size-4`})})]}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto p-5`,children:[(0,X.jsx)(E,{className:`text-sm text-fg-muted`,children:B?N.toolsHint:t.phase===`review_scope`?N.scopeHint:N.intro}),(0,X.jsx)(`p`,{className:`whitespace-pre-wrap rounded-lg border border-edge p-3 text-sm text-fg`,children:t.summary}),(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:new Date(t.objectiveUpdatedAt).toLocaleString(M===`zh`?`zh-CN`:`en-US`)}),t.timeRange&&(0,X.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[new Date(t.timeRange.from).toLocaleString(M,{timeZone:t.timeRange.timezone}),` – `,new Date(t.timeRange.to).toLocaleString(M,{timeZone:t.timeRange.timezone}),` (`,t.timeRange.timezone,`)`]}),t.needs.map(e=>(0,X.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-edge p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsxs)(`span`,{className:`text-sm font-medium text-fg`,children:[e.label,e.accountSelector?` · ${e.accountSelector}`:``]}),e.capabilityError?(0,X.jsx)(`button`,{type:`button`,disabled:n||L,className:gE,onClick:()=>void a(`check`),children:N.retry}):e.phase===`ready`?(0,X.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[(0,X.jsx)(ne,{className:`mr-1 inline size-3`}),N.ready]}):e.target.type===`plugin`&&e.phase!==`blocked`?(0,X.jsx)(`button`,{type:`button`,disabled:n||L||v,className:_E,onClick:()=>void W(e),children:e.phase===`install`?N.install:e.phase===`reconnect`?N.reconnect:N.connect}):e.phase===`authorizing`?(0,X.jsx)(`button`,{type:`button`,disabled:n,className:gE,onClick:()=>void a(`check`),children:N.check}):e.phase===`install`?(0,X.jsx)(`button`,{type:`button`,disabled:n||L||v,className:_E,onClick:()=>void U(e),children:N.install}):e.phase!==`blocked`&&e.phase!==`choose_account`?(0,X.jsx)(`button`,{type:`button`,disabled:n||L,className:_E,onClick:()=>void a(`connect`,e.key),children:e.phase===`reconnect`?N.reconnect:N.connect}):null]}),e.accountId&&(0,X.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,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(pe,{value:l?.needKey===e.key?l.candidateRef:``,options:e.alternatives.map(e=>({value:e.candidateRef,label:e.label})),placeholder:N.replace,ariaLabel:`${e.label}: ${N.replace}`,disabled:n||L,allowEmpty:!1,onChange:t=>u({needKey:e.key,candidateRef:t,label:e.alternatives.find(e=>e.candidateRef===t).label})}),l?.needKey===e.key&&(0,X.jsxs)(`button`,{type:`button`,className:gE,disabled:n,onClick:()=>{a(`replace_source`,e.key,void 0,l.candidateRef),u(void 0)},children:[N.confirmReplace,` `,l.label]})]}):null,e.reason&&(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.reason}),e.phase===`authorizing`&&e.target.type!==`plugin`&&(0,X.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-fg-muted`,children:[(0,X.jsx)(`span`,{children:N.authorizing}),(0,X.jsx)(`button`,{type:`button`,disabled:n,className:`text-accent`,onClick:()=>void a(`connect`,e.key),children:N.reconnect})]})]},e.key)),(0,X.jsx)(`a`,{href:`#/capabilities/connectors`,className:`text-sm text-accent`,onClick:()=>c(!1),children:N.all})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-t border-edge p-4`,children:[(0,X.jsx)(`button`,{type:`button`,className:`min-h-11 text-sm text-fg-muted`,onClick:()=>void a(`cancel`),children:N.cancel}),t.phase===`review_scope`?(0,X.jsx)(`button`,{type:`button`,disabled:n||L,className:_E,onClick:()=>void a(`confirm_scope`),children:N.scope}):null]})]})]})}),h?.waitId===t.id?(0,X.jsx)(Q.Suspense,{fallback:(0,X.jsx)(sn,{className:`mt-2 h-10 w-full`}),children:(0,X.jsx)(mE,{extension:h.extension,initialSource:h.source,connectionFlow:!0,onClose:()=>g(void 0)})}):null,d?(0,X.jsx)(Ot,{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:C(M).connectorsSettings}):null]})}var yE=new Set([`button`,`checkbox`,`color`,`file`,`hidden`,`image`,`radio`,`range`,`reset`,`submit`]);function bE(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&&!yE.has(t.type)}function xE(){return!!document.querySelector(`dialog[open], [aria-modal="true"], [role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]`)}function SE(e,t){return t.disabled||t.editorHidden||e.defaultPrevented||bE(e.target)||bE(document.activeElement)?!1:!xE()}function CE(e){for(let t=e.parentElement;t;t=t.parentElement)if(/(auto|scroll)/.test(getComputedStyle(t).overflowY))return t;return null}function wE({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=CE(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 TE(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 EE(e){let t=TE(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 DE=(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=C(y(e=>e.language)),m=(0,Q.useRef)(!1),h=e.filter(e=>e.status===`queued`),g=!!(t||d),_=wE({items:e,disabled:g,onReorder:o}),v=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`,Pa.focusRingPanel),b=`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,X.jsxs)(`div`,{ref:_.listRef,className:`space-y-1 px-2 py-2`,onClickCapture:_.onClickCapture,role:`list`,"aria-label":p.chat.followUpQueueAria,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2 pb-1`,children:[(0,X.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:p.chat.followUpQueueHeading}),(0,X.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`,y=h.findIndex(t=>t.id===e.id),x=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=Hr(e.text),D=new Map(e.contextRefs?.flatMap(e=>e.refId?[[e.refId,e.title]]:[])??[]),O=new Set(E?In(E):[]),k=e.contextRefs?.filter(e=>!e.refId||!O.has(e.refId)),A=Cr(E?nr(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,X.jsxs)(`div`,{role:`listitem`,"data-follow-up-id":e.id,"data-follow-up-sortable":!g&&t,onPointerDown:t=>_.onPointerDown(t,e),onDragStart:e=>e.preventDefault(),style:{transform:_.view?.shifts[e.id]?`translateY(${_.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`,!g&&t&&`cursor-grab`,_.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,X.jsx)(`div`,{"data-follow-up-drag-handle":!0,className:Y(`flex shrink-0 touch-none cursor-grab items-center active:cursor-grabbing`,(g||!t)&&`cursor-not-allowed opacity-40`),title:p.chat.followUpQueueDrag,children:(0,X.jsx)(ic,{className:`size-3.5 text-fg-muted`,"aria-hidden":!0})}),(0,X.jsx)(`button`,{type:`button`,"data-follow-up-drag-surface":!0,disabled:g||!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`,Pa.focusRingPanel,`disabled:pointer-events-none disabled:opacity-50`),onClick:()=>r(e.id),children:e.attachments?.length?(0,X.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1`,children:[(0,X.jsx)(De,{className:`size-3 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`truncate`,children:A})]}):(0,X.jsx)(`span`,{className:`line-clamp-2 break-words [overflow-wrap:anywhere]`,children:A})}),k?.length?(0,X.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,X.jsx)(dc,{className:`size-3`,"aria-hidden":!0}),k.length]}):null,T?(0,X.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,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,X.jsxs)(`button`,{type:`button`,className:v,disabled:g||(x?!o:!S),title:x?p.chat.sendThisMessage:p.chat.followUpQueueSteerHint,"aria-label":x?p.chat.sendThisMessage:p.chat.followUpQueueSteerNow,"aria-busy":w,onClick:()=>x?c?.(e.id):s(e.id),children:[(0,X.jsx)(Zs,{className:Y(`size-4`,w&&`motion-safe:animate-pulse`),"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`hidden text-xs sm:inline`,children:x?p.chat.sendThisMessage:p.chat.followUpQueueSteerNow})]}),(0,X.jsx)(`button`,{type:`button`,className:Y(v,`px-1.5 hover:text-danger`),disabled:g||!o,title:p.chat.followUpQueueRemove,"aria-label":p.chat.followUpQueueRemove,onClick:()=>i(e.id),children:(0,X.jsx)(Xt,{className:`size-4`,"aria-hidden":!0})}),(0,X.jsxs)(Ho,{modal:!1,children:[(0,X.jsx)(Uo,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:Y(v,`px-1.5`),disabled:g,title:p.chat.followUpQueueMore,"aria-label":p.chat.followUpQueueMore,children:(0,X.jsx)(Se,{className:`size-4`,"aria-hidden":!0})})}),(0,X.jsx)(Wo,{children:(0,X.jsxs)(Ko,{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,X.jsxs)(Go,{className:b,disabled:!t,onSelect:()=>{m.current=!0,r(e.id)},children:[(0,X.jsx)(jt,{className:`size-4`,"aria-hidden":!0}),p.chat.followUpQueueClickToEdit]}),f?(0,X.jsxs)(Go,{className:b,disabled:!C,onSelect:()=>f(e,A),children:[(0,X.jsx)(sc,{className:`size-4`,"aria-hidden":!0}),p.chat.followUpQueueOpenSideChat]}):null,h.length>1?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(qo,{className:`my-1 h-px bg-edge-subtle`}),(0,X.jsxs)(Go,{className:b,disabled:!t||y===0,onSelect:()=>a(e.id,`up`),children:[(0,X.jsx)(ae,{className:`size-4`,"aria-hidden":!0}),p.chat.followUpQueueMoveUp]}),(0,X.jsxs)(Go,{className:b,disabled:!t||y>=h.length-1,onSelect:()=>a(e.id,`down`),children:[(0,X.jsx)(re,{className:`size-4`,"aria-hidden":!0}),p.chat.followUpQueueMoveDown]})]}):null]})})]})]})]},e.id)})]})});function OE({conversationId:e}){let t=v(e=>e.conversationId),n=y(e=>e.language).startsWith(`zh`),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(``),s=bi(e?[`session-preparation`,t,e]:null,async()=>{let t=await $r(e);if(t&&!t.materialization)return null;let n=await b(_(`/api/sessions/${encodeURIComponent(e)}/input-state`));return n.payload.preparation?Xr.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 g(_(`/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,X.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 text-sm text-fg-muted`,role:`status`,children:[(0,X.jsx)(`span`,{children:l.state===`preparing`?n?`正在准备会话环境…`:`Preparing conversation environment…`:l.lastError??(n?`会话环境准备失败`:`Conversation environment preparation failed`)}),l.state===`preparation_failed`?(0,X.jsx)(`button`,{type:`button`,className:`ml-2 text-accent-fg`,disabled:r,onClick:()=>void u(),children:n?`重试准备`:`Retry preparation`}):null,a?(0,X.jsx)(`span`,{role:`alert`,className:`ml-2`,children:a}):null]})}function kE(e){let t=(0,Z.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,X.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,X.jsx)(Ae,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.kind===`file`||e.kind===`result`?(0,X.jsx)(Ee,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.kind===`session`?(0,X.jsx)(yt,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.kind===`browser_tab`?(0,X.jsx)(N,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,X.jsx)(dc,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`truncate`,children:e.title}),(0,X.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,X.jsx)(an,{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,X.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 AE=`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 jE(e){let t=(0,Z.c)(96),{conversationId:n,project:r,workspacePath:i,canChangeWorkspace:a,disabled:o,environmentPicker:s,onProjectChange:c,onWorkspaceChange:l}=e,u=y(FE),d;t[0]===u?d=t[1]:(d=C(u),t[0]=u,t[1]=d);let f=d,p=f.chat.composerContext,m=v(PE),h=v(NE),[g,_]=(0,Q.useState)(``),[b]=wo(g,200),x;t[2]!==h||t[3]!==b||t[4]!==m?(x=[`composer-projects`,h,m,b],t[2]=h,t[3]=b,t[4]=m,t[5]=x):x=t[5];let S;t[6]===b?S=t[7]:(S=()=>Cn({status:`active`,search:b,sortBy:`updatedAt`,sortOrder:`desc`,limit:50}),t[6]=b,t[7]=S);let w;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(w={keepPreviousData:!1,shouldRetryOnError:!1},t[8]=w):w=t[8];let T=bi(x,S,w),E=fp(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=_o(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,X.jsx)(`button`,{type:`button`,disabled:o,title:f.chat.scopeRemoveProject,"aria-label":f.chat.scopeRemoveProject,className:Y(AE,`size-7 shrink-0 px-0 ml-0.5 text-fg-muted`),onClick:()=>c(null),children:(0,X.jsx)(an,{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 ee;t[30]===W?ee=t[31]:(ee=W.map(ME),t[30]=W,t[31]=ee);let te=p.chooseProject,ne=p.changeProject,re=p.changeProject,ie=p.noProject,ae=p.searchProjects,oe=T.isLoading,ce=T.error?p.projectsFailed:T.data?.items.length===0?p.noProjects:void 0,le=r&&`pl-1`,ue;t[32]===le?ue=t[33]:(ue=Y(AE,`h-8 w-auto max-w-44 gap-1 border-0 bg-transparent pr-2.5 text-sm [&>svg]:hidden [&>span]:text-fg`,le),t[32]=le,t[33]=ue);let de;t[34]!==c||t[35]!==r?.id?(de=e=>{e!==(r?.id??``)&&c(e||null)},t[34]=c,t[35]=r?.id,t[36]=de):de=t[36];let fe;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]!==g||t[44]!==H||t[45]!==U||t[46]!==ee||t[47]!==ce||t[48]!==ue||t[49]!==de?(fe=(0,X.jsx)(pe,{value:H,selectedLabel:U,options:ee,placeholder:te,ariaLabel:ne,title:re,emptyLabel:ie,disabled:o,side:`top`,align:`start`,searchPlaceholder:ae,searchValue:g,onSearchChange:_,loading:oe,statusMessage:ce,triggerClassName:ue,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:de}),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]=g,t[44]=H,t[45]=U,t[46]=ee,t[47]=ce,t[48]=ue,t[49]=de,t[50]=fe):fe=t[50];let G;t[51]!==B||t[52]!==V||t[53]!==fe?(G=(0,X.jsxs)(`div`,{className:B,children:[V,fe]}),t[51]=B,t[52]=V,t[53]=fe,t[54]=G):G=t[54];let me=r?s:null,he;t[55]!==D||t[56]!==s||t[57]!==r?(he=!s&&r&&D&&(D.headSha||D.branch)?(0,X.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,X.jsx)(fc,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}):(0,X.jsx)(Ue,{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]=he):he=t[58];let K;t[59]!==p.retryProjects||t[60]!==T?(K=T.error?(0,X.jsx)(`button`,{type:`button`,className:Y(AE,`size-7 px-0`),"aria-label":p.retryProjects,onClick:()=>void T.mutate(),children:(0,X.jsx)(It,{className:`size-3.5`,"aria-hidden":!0})}):null,t[59]=p.retryProjects,t[60]=T,t[61]=K):K=t[61];let ge;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?(ge=r?null:(0,X.jsxs)(`button`,{type:`button`,className:Y(AE,`max-w-52`),disabled:o||!a||P.picking,title:F,"aria-label":p.chooseFolder,onClick:P.pick,children:[(0,X.jsx)(ke,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),k?(0,X.jsx)(`span`,{className:`truncate`,children:go(k)}):E.isLoading?(0,X.jsx)(sn,{className:`h-4 w-16`}):(0,X.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]=ge):ge=t[71];let _e;t[72]!==L||t[73]!==D?(_e=L?(0,X.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,X.jsx)(je,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`truncate`,children:L})]}):null,t[72]=L,t[73]=D,t[74]=_e):_e=t[74];let q;t[75]===A?q=t[76]:(q=A?(0,X.jsx)(`p`,{role:`alert`,className:`w-full px-2 py-1 text-xs text-danger`,children:A}):null,t[75]=A,t[76]=q);let ve;t[77]!==p.label||t[78]!==G||t[79]!==me||t[80]!==he||t[81]!==K||t[82]!==ge||t[83]!==_e||t[84]!==q?(ve=(0,X.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:[G,me,he,K,ge,_e,q]}),t[77]=p.label,t[78]=G,t[79]=me,t[80]=he,t[81]=K,t[82]=ge,t[83]=_e,t[84]=q,t[85]=ve):ve=t[85];let ye;t[86]!==f.chat.workingDirectory||t[87]!==P.confirmPick||t[88]!==P.hasNativePicker||t[89]!==P.modalOpen||t[90]!==P.setModalOpen||t[91]!==k?(ye=P.hasNativePicker?null:(0,X.jsx)(se,{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]=ye):ye=t[92];let J;return t[93]!==ve||t[94]!==ye?(J=(0,X.jsxs)(X.Fragment,{children:[ve,ye]}),t[93]=ve,t[94]=ye,t[95]=J):J=t[95],J}function ME(e){return{value:e.id,label:e.name}}function NE(e){return e.baseUrl}function PE(e){return e.conversationId}function FE(e){return e.language}var IE=`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 LE(e){let t=(0,Z.c)(17),{disabled:n,attachmentCount:r,maxAttachments:i,chat:a,onPickFiles:o,addActions:s}=e,c=r>=i,l;t[0]!==a.attachFile||t[1]!==a.maxAttachmentsReached||t[2]!==c||t[3]!==i?(l=c?mh(a.maxAttachmentsReached,{max:i}):a.attachFile,t[0]=a.attachFile,t[1]=a.maxAttachmentsReached,t[2]=c,t[3]=i,t[4]=l):l=t[4];let u=l,d=n||!s&&c,f=s?.label??u,p=s?.label??u,m=s?void 0:o,h;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,X.jsx)(Ft,{className:`size-5`,"aria-hidden":!0}),t[5]=h):h=t[5];let g;t[6]!==d||t[7]!==f||t[8]!==p||t[9]!==m?(g=(0,X.jsx)(`button`,{type:`button`,className:IE,disabled:d,"aria-label":f,title:p,onClick:m,children:h}),t[6]=d,t[7]=f,t[8]=p,t[9]=m,t[10]=g):g=t[10];let _=g,v;return t[11]!==s||t[12]!==a.attachFile||t[13]!==c||t[14]!==o||t[15]!==_?(v=s?(0,X.jsx)(ph,{trigger:_,fileLabel:a.attachFile,filesDisabled:c,onPickFiles:o,actions:s}):_,t[11]=s,t[12]=a.attachFile,t[13]=c,t[14]=o,t[15]=_,t[16]=v):v=t[16],v}function RE(e){let t=(0,Z.c)(16),{disabled:n,voiceActive:r,runBusy:i,hasDraft:a,chat:o,onStartVoiceInput:s,onSend:c,onAbort:l}=e;if(r)return null;let u=i&&!a,d=u?o.abort:o.sendMessage,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,X.jsx)(bt,{className:`size-[1.125rem]`,"aria-hidden":!0}),t[0]=f):f=t[0];let p;t[1]!==o.voiceInput||t[2]!==n||t[3]!==s?(p=(0,X.jsx)(`button`,{type:`button`,className:IE,disabled:n,title:o.voiceInput,"aria-label":o.voiceInput,onClick:s,children:f}),t[1]=o.voiceInput,t[2]=n,t[3]=s,t[4]=p):p=t[4];let m;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=Y(IE,`bg-accent text-on-accent hover:bg-accent-hover hover:text-on-accent disabled:bg-surface-hover disabled:text-fg-disabled`),t[5]=m):m=t[5];let h=!u&&(n||!a),g=u?l:c,_;t[6]===u?_=t[7]:(_=u?(0,X.jsx)(Kt,{className:`size-4 fill-current`,"aria-hidden":!0}):(0,X.jsx)(R,{className:`size-5`,"aria-hidden":!0}),t[6]=u,t[7]=_);let v;t[8]!==d||t[9]!==h||t[10]!==g||t[11]!==_?(v=(0,X.jsx)(`button`,{type:`button`,className:m,disabled:h,"aria-label":d,title:d,onClick:g,children:_}),t[8]=d,t[9]=h,t[10]=g,t[11]=_,t[12]=v):v=t[12];let y;return t[13]!==p||t[14]!==v?(y=(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[p,v]}),t[13]=p,t[14]=v,t[15]=y):y=t[15],y}function zE(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 BE=100,VE=400,HE=900;function UE(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 WE(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 GE(e){let t=(0,Z.c)(8),{name:n,query:r}=e,i;t[0]!==n||t[1]!==r?(i=WE(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,X.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,X.jsx)(`span`,{className:`font-medium text-fg`,children:n.slice(r,i)},`pre-${i}`)),e.push((0,X.jsx)(`span`,{className:`font-semibold text-accent-fg`,children:n.slice(i,a)},`hl-${i}-${a}`)),r=a}),r<n.length&&e.push((0,X.jsx)(`span`,{className:`font-medium text-fg`,children:n.slice(r)},`tail`)),o=(0,X.jsx)(X.Fragment,{children:e}),t[5]=n,t[6]=a,t[7]=o}else o=t[7];return o}var KE=(0,Q.memo)(function(e){let t=(0,Z.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)(UE,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&&bo(i,{conversationId:l}).then(e=>{let{content:i}=e,a=i.length>HE?`${i.slice(0,HE)}…`: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,k;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`})},k=[n,a,i.length],t[8]=i.length,t[9]=n,t[10]=a,t[11]=O,t[12]=k):(O=t[11],k=t[12]),(0,Q.useLayoutEffect)(O,k),!n||typeof document>`u`||_===null)return null;let A=i.length,j=Math.min(_.width,VE),M;t[13]!==_.left||t[14]!==_.top||t[15]!==j?(M={position:`fixed`,left:_.left,top:_.top,width:j,transform:`translateY(calc(-100% - 8px))`,zIndex:BE},t[13]=_.left,t[14]=_.top,t[15]=j,t[16]=M):M=t[16];let P=a>=0&&a<A?`at-mention-${a}`:void 0,F;t[17]!==o||t[18]!==A?(F=o&&A===0?(0,X.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2.5 text-sm text-fg-muted`,children:[(0,X.jsx)(qe,{className:`size-4 shrink-0 animate-spin`,"aria-hidden":!0}),(0,X.jsx)(`span`,{children:`…`})]}):null,t[17]=o,t[18]=A,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]!==A?(I=!o&&A===0?(0,X.jsx)(`div`,{className:`px-3 py-2 text-sm text-fg-muted`,children:c}):(0,X.jsxs)(X.Fragment,{children:[i.map((e,t)=>{let n=i[t-1]?.kind,r=d[e.kind],o=e.kind===`file`&&e.isRecent;return(0,X.jsxs)(Q.Fragment,{children:[n===e.kind?null:(0,X.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,X.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,X.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:e.kind===`note`?(0,X.jsx)(dc,{className:`size-3.5 text-accent-fg`,"aria-hidden":!0}):e.kind===`session`?(0,X.jsx)(yt,{className:`size-3.5 text-violet-600 dark:text-violet-400`,"aria-hidden":!0}):e.kind===`skill`?(0,X.jsx)(Gt,{className:`size-3.5 text-cyan-600 dark:text-cyan-400`,"aria-hidden":!0}):e.kind===`agent`?(0,X.jsx)(te,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):e.kind===`browser_tab`?(0,X.jsx)(N,{className:`size-3.5 text-blue-600 dark:text-blue-400`,"aria-hidden":!0}):e.isBrowseUp?(0,X.jsx)(Ae,{className:`size-3.5 text-fg-muted`,"aria-hidden":!0}):e.isDirectory?(0,X.jsx)(Ae,{className:`size-3.5 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}):(0,X.jsx)(Ee,{className:Y(`size-3.5`,ye(e.name)),"aria-hidden":!0})}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 truncate`,children:[(0,X.jsx)(`span`,{className:`truncate`,children:(0,X.jsx)(GE,{name:e.name,query:s})}),o?(0,X.jsx)(`span`,{className:`shrink-0 rounded bg-accent-soft px-1 py-0 text-[0.65rem] text-accent-fg`,children:u}):null]}),(0,X.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:e.description||r})]})]})]},e.id)}),o&&A>0?(0,X.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-edge-subtle px-3 py-2 text-xs text-fg-muted`,children:[(0,X.jsx)(qe,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),(0,X.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]=A,t[30]=I):I=t[30];let L;t[31]!==f||t[32]!==F||t[33]!==I||t[34]!==P?(L=(0,X.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,X.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]!==M?(z=(0,Oc.createPortal)((0,X.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:M,role:`presentation`,children:[L,R]}),document.body),t[38]=L,t[39]=R,t[40]=M,t[41]=z):z=t[41],z});function qE(e,t){let n=e=>{e!==!1&&(e&&typeof e==`object`?t(e.conversationId):t())};e instanceof Promise?e.then(n).catch(e=>{Ga(`error`,e instanceof Error?e.message:String(e))}):n(e)}var JE=new Set([`abort`,`stop`,`cancel`]);function YE(e){if(e.kind!==`command`)return!1;if(JE.has(e.name.toLowerCase()))return!0;for(let t of e.aliases??[])if(JE.has(t.toLowerCase()))return!0;return!1}function XE(e,t,n,r){return e.slice(0,t)+r+e.slice(n)}var ZE=(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=XE(t.editor.valueRef.current,n.start,n.end,r),a=n.start+r.length;t.editor.resetEditor({nextText:i,caretOffset:a,focus:!0})},QE=(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=XE(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(YE(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}qE(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()})},$E=(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 eD(e,t){switch(e.kind){case`skill`:ZE(e,t);return;case`command`:QE(e,t);return;case`agent`:$E(e,t)}}var tD={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},nD=new Set([`abort`,`archive`]);function rD(e){if(e.kind===`command`){let t=e.name.toLowerCase();if(tD[t]!==void 0)return 0;if(nD.has(t))return 2}return 1}function iD(e,t){let n=rD(e),r=rD(t);if(n!==r)return n-r;if(n===0){let n=tD[e.name.toLowerCase()]??999,r=tD[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 aD(e){if(e.kind!==`command`)return!1;if(JE.has(e.name.toLowerCase()))return!0;for(let t of e.aliases??[])if(JE.has(t.toLowerCase()))return!0;return!1}function oD(e,t){return e.kind!==`command`||e.acceptsArgs===!0||aD(e)||!(t.runBusy||t.pendingFollowUpsCount>0)?!1:t.pendingFollowUpsCount>=t.maxPendingFollowUps}function sD(e,t){return e.kind!==`command`||e.acceptsArgs===!0||aD(e)||!(t.runBusy||t.pendingFollowUpsCount>0)?!1:t.pendingFollowUpsCount<t.maxPendingFollowUps}function cD(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 lD(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 uD(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(lD(e,a))return null;let o=i[0],s=o.slice(1);return cD(s)||o.startsWith(`/skill:`)?null:{start:i.index,end:r,query:s}}function dD(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 fD(e,t){return t===0?0:Math.min(e,t-1)}function pD(e,t){let{query:n,value:r,commandsAllowed:i,agentsAllowed:a}=t,o=n.trim()===``,s=km(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=dD(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?iD(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 mD(e,t,n){let r=(0,Z.c)(49),[i,a]=(0,Q.useState)(0),[o,s]=(0,Q.useState)(0),c=y(_D),l=n?.capabilities??um,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:uD(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,h;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(gD)};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},h=[],r[5]=m,r[6]=h):(m=r[5],h=r[6]),(0,Q.useEffect)(m,h);let g;r[7]!==c||r[8]!==n?.conversationId||r[9]!==n?.currentAgentId?(g=async()=>{let[e,t,r]=await Promise.allSettled([is(),Qo(n?.currentAgentId,n?.conversationId),Mi()]),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(hD),o=(t.status===`fulfilled`?t.value.skills:[]).map(e=>{let t=as(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=C(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:mo(e,s),description:ho(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]=g):g=r[10];let _=n?.currentAgentId,v=n?.conversationId,b;r[11]!==c||r[12]!==o||r[13]!==_||r[14]!==v?(b=[c,_,v,o],r[11]=c,r[12]=o,r[13]=_,r[14]=v,r[15]=b):b=r[15];let x;r[16]===Symbol.for(`react.memo_cache_sentinel`)?(x=[],r[16]=x):x=r[16];let S;r[17]===Symbol.for(`react.memo_cache_sentinel`)?(S=[],r[17]=S):S=r[17];let w,T;r[18]===Symbol.for(`react.memo_cache_sentinel`)?(T={items:x,failedKinds:S},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=to(g,b,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=pD(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=fD(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 hD(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 gD(e){return e+1}function _D(e){return e.language}var vD=100,yD=560;function bD(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase().indexOf(n);if(r>=0)return(0,X.jsxs)(X.Fragment,{children:[e.slice(0,r),(0,X.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,X.jsx)(`span`,{className:`text-accent-fg`,children:t},r)),a+=1):i.push((0,X.jsx)(Q.Fragment,{children:t},r)),o+=1}return(0,X.jsx)(X.Fragment,{children:i})}function xD(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase().indexOf(n);return r<0?e:(0,X.jsxs)(X.Fragment,{children:[e.slice(0,r),(0,X.jsx)(`span`,{className:`text-accent-fg`,children:e.slice(r,r+n.length)}),e.slice(r+n.length)]})}var SD=(0,Q.memo)(function(e){let t=(0,Z.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,X.jsx)(io,{agentId:n.agentId,avatar:n.avatar,size:18,className:`size-[18px] shrink-0`}):y?(0,X.jsx)(Gt,{className:`size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,X.jsx)(on,{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,X.jsx)(X.Fragment,{children:bD(n.name,o)}):(0,X.jsx)(`span`,{className:`text-fg`,children:n.name}):a?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`text-fg`,children:`/`}),bD(n.name,o)]}):(0,X.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=sD(n,e),D=oD(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,X.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,X.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,X.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,X.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,X.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?xD(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,X.jsx)(wD,{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}),CD=(0,Q.memo)(function(e){let t=(0,Z.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,yD),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(TD)),n=[`skill`,`command`,`agent`].filter(t=>e.has(t)||s.includes(t)),r=0;W=o&&P===0?(0,X.jsx)(`div`,{className:`space-y-2 p-2.5`,"aria-busy":`true`,children:Array.from({length:6},ED)}):P===0&&s.length===0?(0,X.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,X.jsxs)(`div`,{role:`group`,"aria-labelledby":o,className:Y(n>0&&`border-t border-edge-subtle`),children:[(0,X.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,X.jsx)(`span`,{children:V[t]}),(0,X.jsx)(`span`,{className:`tabular-nums`,"aria-hidden":!0,children:i.length})]}),s.includes(t)?(0,X.jsx)(`div`,{className:`px-2.5 pb-2 text-[11px] leading-relaxed text-fg-muted`,children:u}):i.map((e,t)=>(0,X.jsx)(SD,{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 ee=W,te;t[40]!==O.left||t[41]!==O.top||t[42]!==I?(te={position:`fixed`,left:O.left,top:O.top,width:I,transform:`translateY(calc(-100% - 8px))`,zIndex:vD},t[40]=O.left,t[41]=O.top,t[42]=I,t[43]=te):te=t[43];let ne=`${f}, ${p}, ${m}`,re=F?`${V[F.kind]}: ${F.name}`:``,ie;t[44]===re?ie=t[45]:(ie=(0,X.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:re}),t[44]=re,t[45]=ie);let ae;return t[46]!==ee||t[47]!==o||t[48]!==D||t[49]!==ne||t[50]!==ie||t[51]!==te?(ae=(0,Oc.createPortal)((0,X.jsx)(To,{delayDuration:0,skipDelayDuration:0,disableHoverableContent:!1,children:(0,X.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:te,role:`listbox`,"aria-label":ne,"aria-busy":o,children:[ie,ee]})}),document.body),t[46]=ee,t[47]=o,t[48]=D,t[49]=ne,t[50]=ie,t[51]=te,t[52]=ae):ae=t[52],ae}),wD=(0,Q.memo)(function(e){let t=(0,Z.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,X.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,X.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,X.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,X.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,X.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,X.jsxs)(X.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,X.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,X.jsx)(ko,{asChild:!0,children:F}),t[32]=F,t[33]=e);let n;t[34]===M?n=t[35]:(n=(0,X.jsx)(Eo,{children:(0,X.jsx)(Oo,{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,X.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,X.jsxs)(Do,{delayDuration:0,children:[e,n]}),t[36]=e,t[37]=n,t[38]=r):r=t[38],r}return F});function TD(e){return[e.kind,e]}function ED(e,t){return(0,X.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,X.jsx)(sn,{className:`size-4 shrink-0`}),(0,X.jsx)(sn,{className:`h-3 w-28`}),(0,X.jsx)(sn,{className:`h-3 flex-1`})]},t)}var DD=new Map;function OD(e){let t=DD.get(e);return t||(t={items:[],loadPromise:null,loaded:!1,writeQueue:Promise.resolve(),mutationVersion:0,clearVersion:0},DD.set(e,t)),t}function kD(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 AD(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}kD(e,t)}function jD(e){return OD(e).items.map(e=>e.text)}function MD(e,t=!1){let n=OD(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(()=>b(`/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(()=>MD(e,!0))}),n.loadPromise}function ND(e,t){let n=t.trim();if(!n)return;let r=OD(e),i=r.clearVersion;r.mutationVersion+=1,kD(r,{conversationId:e,id:0,text:n,createdAt:Date.now()}),r.writeQueue=r.writeQueue.then(async()=>{let t=await b(`/api/composer-history`,{method:`POST`,body:JSON.stringify({conversationId:e,text:n})});r.clearVersion===i&&t.item.conversationId===e&&AD(r,t.item)}).catch(()=>{})}function PD(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=OD(t.conversationId);return n.mutationVersion+=1,AD(n,t),t.conversationId}function FD(e){if(!e||typeof e!=`object`||!(`conversationId`in e)||typeof e.conversationId!=`string`)return null;let t=OD(e.conversationId);return t.mutationVersion+=1,t.clearVersion+=1,t.items=[],e.conversationId}function ID(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&&MD(t,!0);let e=e=>{PD(e.detail)===t&&c()},n=e=>{FD(e.detail)===t&&c()},r=()=>{t&&MD(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&&!Hr(e)&&ND(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=jD(t);if(a.length===0)return!1;let o=s.current,c=n.current,l=c?Am(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 LD(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 RD(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 zD(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=performance.now(),r=LD(t.current);if(r===`blocked`)return;if(r===`queue`){D.current();return}let s=RD({voiceActive:i,cancelVoiceInput:a,...w});if(!s)return;if(r===`saveFollowUp`){if(O.current||!o)return;O.current=!0,Promise.resolve().then(()=>g(o,s.text,s.attachments,d(),s.contextRefs)).then(n=>{if(n===!1)return;C?.(s.text);let r=t.current;r.draftScope!==e.draftScope||r.editingFollowUpId!==o||r.getTextValue()!==s.text||JSON.stringify(r.wireAttachmentsPayload())!==JSON.stringify(s.attachments)||JSON.stringify(r.getContextRefs())!==JSON.stringify(s.contextRefs)||(r.onFinishFollowUpEdit?.(),S())}).catch(e=>Ga(`error`,e instanceof Error?e.message:String(e))).finally(()=>{O.current=!1});return}let c=[s.text,s.attachments.length>0?s.attachments:void 0,d(),s.contextRefs.length>0?s.contextRefs:void 0,{submittedAt:n,onDispatched:e=>p?.(e,s)}];qE(f(...c),n=>{C?.(s.text,n);let i=t.current,a=e.draftScope,o=i.draftScope;if(!(!(r===`send`&&a?.conversationId===null&&n!==void 0&&o?.conversationId===n&&o.gatewayIdentity===a.gatewayIdentity)&&o!==a||i.getTextValue()!==s.text||JSON.stringify(i.wireAttachmentsPayload())!==JSON.stringify(s.attachments)||JSON.stringify(i.getContextRefs())!==JSON.stringify(s.contextRefs))){if(r===`replaceTurn`){i.editingUserTurnId===e.editingUserTurnId&&i.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&&void 0,s=e.personal?`steer`:void 0)=>{if(t.current.editingFollowUpId||t.current.editingUserTurnId){k();return}if(!r&&v===0)return;let c=RD({voiceActive:i,cancelVoiceInput:a,...w});if(c&&!t.current.blocked&&m&&!T.current){if(v>=10){Ga(`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){Ga(`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=RD({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=>Ga(`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.personal&&e.pendingFollowUpsCount>0){e.firstPendingFollowUpId&&e.onSteerPendingFollowUp?.(e.firstPendingFollowUpId);return}A(!1,`steer`)}},[A])}}var BD=e=>e?.kind===`editTurn`?`turn:${e.turnId}`:e?.kind===`editFollowUp`?`input:${e.inputId}:${e.version}`:`compose`,VD=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),HD=new Map;function UD(e,t){let n=(HD.get(e)??Promise.resolve()).catch(()=>{}).then(t);HD.set(e,n);let r=()=>{HD.get(e)===n&&HD.delete(e)};return n.then(r,r),n}function WD(e,t,n,r,i,a,o,s){let c=BD(a?.snapshot().mode),l=v(e=>e.conversationId),u=l&&e?JSON.stringify([l,e]):``,d=(0,Q.useRef)({editor:t,attachments:n,refs:r,setRefs:i,editSession:a});d.current={editor:t,attachments:n,refs:r,setRefs:i,editSession:a};let f=(0,Q.useRef)(void 0),p=(0,Q.useRef)(void 0),[m,h]=(0,Q.useState)(0);(0,Q.useLayoutEffect)(()=>{let t=p.current;p.current={identity:l,id:e,unboundDraftKey:o};let n=t?.identity===l&&t?.id===null&&!!e&&e===s?.(),r=t&&(t.identity!==l||t.id!==e||t.unboundDraftKey!==o)&&!n;if(r&&(d.current.editor.resetEditor(),d.current.attachments.clearAttachments(),d.current.setRefs([])),!u||!e){f.current=void 0;return}let i={receipts:[],scope:u,ready:!1,dirty:!1,observe:!1,snapshot:{text:d.current.editor.valueRef.current,attachments:d.current.attachments.attachmentsRef.current,refs:r?[]:d.current.refs,editSession:d.current.editSession?.snapshot()},storage:Qr(e)};f.current=i;let a=!1,c=HD.get(u);return(c?c.catch(()=>{}).then(()=>i.storage.read()):i.storage.read()).then(e=>{if(a=!0,f.current!==i)return;i.receipts=e?.intakeReceipts??[];let t=d.current;e&&!i.dirty&&!t.editor.valueRef.current&&!t.attachments.attachmentsRef.current.length&&!t.refs.length&&(t.editor.resetEditor({nextText:e.text}),t.attachments.setAttachments(e.attachments),t.setRefs(e.refs),e.editSession&&t.editSession?.restore(e.editSession))}).catch(e=>{console.warn(`Composer draft restoration failed`,e)}).finally(()=>{f.current===i&&(i.ready=a,a&&d.current.editSession?.ready?.(),h(e=>e+1))}),()=>{f.current===i&&(f.current=void 0)}},[u,e,l,o,s]),(0,Q.useLayoutEffect)(()=>{let e=f.current;if(!e||e.scope!==u)return;if(!e.observe){e.observe=!0;return}let i={text:t.value,attachments:n.attachments,refs:r,editSession:d.current.editSession?.snapshot()};(i.text!==e.snapshot.text||!VD(i.attachments,e.snapshot.attachments)||!VD(i.refs,e.snapshot.refs)||BD(i.editSession?.mode)!==BD(e.snapshot.editSession?.mode))&&(e.dirty=!0),e.snapshot=i},[u,t.value,n.attachments,r,c]),(0,Q.useEffect)(()=>{let e=f.current;if(!e||e.scope!==u||!e.ready&&!e.dirty)return;let i={text:t.value,attachments:n.attachments,refs:r,editSession:d.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;UD(u,()=>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)})},[u,m,t.value,n.attachments,r,c]),(0,Q.useEffect)(()=>{let e=f.current;if(!(!e?.ready||!u))return Ic(u,async(t,n)=>{if(await HD.get(u)?.catch(()=>{}),f.current!==e)throw Error(`Conversation changed. Please retry.`);if(e.receipts.includes(t))return;let r=d.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()};await UD(u,()=>e.storage.write(t))}catch(n){throw e.receipts=e.receipts.filter(e=>e!==t),n}})},[u,m])}function GD(e){let{conversationId:t,agentId:n,modelKey:r,locale:i,enabled:a,draftText:o,canShow:s}=e,c=v(e=>e.conversationId),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(null),p=(0,Q.useRef)(null),m=(0,Q.useRef)(o),h=(0,Q.useRef)(-1),y=(0,Q.useCallback)((e,t,n)=>{g(_(`/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)(()=>{m.current.length>0&&o.length===0&&(p.current=null),m.current=o},[o]),(0,Q.useEffect)(()=>{p.current=null,h.current=-1,u(null),f(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 $r(t))return;let d=await g(_(`/api/sessions/${encodeURIComponent(t)}/next-turn-suggestion?locale=${i}`),{signal:c.signal});if(!d.ok)return;let f=Tc.safeParse(await d.json());if(e||a!==r||!f.success)return;let p=f.data.suggestion;if(f.data.status===`ready`&&p&&p.conversationId===t&&p.locale===i&&(!n||p.agentId===n)&&p.inputRevision>=h.current&&p.expiresAt>Date.now()&&p.transcriptId===await qr(t)){if(e||a!==r)return;u(e=>e?.suggestion.id===p.id?e:{suggestion:p,impressionId:crypto.randomUUID()}),o=setTimeout(()=>{u(null)},Math.max(0,p.expiresAt-Date.now()))}else u(null),f.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<h.current)return;h.current=n.revision}r++,s=0,o&&clearTimeout(o),u(null),e.type===`session-transcript-updated`?o=setTimeout(()=>{l()},150):l()}},f=()=>{r++,s=0,o&&clearTimeout(o),u(null),l()},p=e=>{e.detail?.topic===`sessions`&&f()};l();let m=[`session-next-turn-suggestion-changed`,`session-input-state`,`session-updated`,`session-transcript-updated`];return m.forEach(e=>window.addEventListener(e,d)),window.addEventListener(`gateway-realtime-connected`,f),window.addEventListener(`config-reload`,f),window.addEventListener(`realtime-gap`,p),()=>{e=!0,r++,c.abort(),o&&clearTimeout(o),m.forEach(e=>window.removeEventListener(e,d)),window.removeEventListener(`gateway-realtime-connected`,f),window.removeEventListener(`config-reload`,f),window.removeEventListener(`realtime-gap`,p)}},[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?(p.current=b,y(b,`accepted`),b.suggestion.prompt):null,[b,y]),C=(0,Q.useCallback)(()=>{b&&(f(b.suggestion.id),y(b,`dismissed`))},[b,y]),w=(0,Q.useCallback)(e=>{let n=p.current;!n||n.suggestion.conversationId!==t||(f(n.suggestion.id),y(n,`submitted`,e.trim()!==n.suggestion.prompt),p.current=null)},[t,y]);return{suggestion:b?.suggestion??null,shown:x,accept:S,dismiss:C,submitted:w}}function KD(e){let t=(0,Z.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 qD=20,JD=`xopc.atMention.recent:`;function YD(e){return`${JD}${e.trim()}`}function XD(e){let t=e?.trim();if(!t||typeof localStorage>`u`)return[];try{let e=localStorage.getItem(YD(t));if(!e)return[];let n=JSON.parse(e);return Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.length>0).slice(0,qD):[]}catch{return[]}}function ZD(e,t){let n=e?.trim(),r=t.trim();if(!(!n||!r||typeof localStorage>`u`))try{let e=[r,...XD(n).filter(e=>e!==r)].slice(0,qD);localStorage.setItem(YD(n),JSON.stringify(e))}catch{}}var QD=150,$D=[`file`,`note`,`session`,`browser_tab`,`skill`,`agent`];function eO(e){let t={items:[],loading:e,error:null};return{file:{...t},note:{...t},session:{...t},skill:{...t},agent:{...t},browser_tab:{...t}}}function tO(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 nO(e){return e.replace(/[\\\s]/gu,e=>`\\${e}`)}function rO(e){let t=e.trim();return t.length>0&&t.endsWith(`/`)&&!/^https?:\/\//i.test(t)}function iO(e){return e.replace(/\/+$/,``).trim()}function aO(e){let t=e.replace(/\/+$/,``);if(!t)return``;let n=t.lastIndexOf(`/`);return n<=0?``:t.slice(0,n)}function oO(e,t){return t===0?0:Math.min(e,t-1)}function sO(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 cO(e,t,n){let r=(0,Z.c)(55),i=n.capabilities??um,[a,o]=(0,Q.useState)(0),[s,c]=(0,Q.useState)(pO),l=(0,Q.useRef)(0),u=y(fO),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=tO(e,t),r[0]=t,r[1]=e,r[2]=i):i=r[2],d=i}let f=d,p=f!==null,[m]=wo(p?f.query:``,QD),h=p?m:``,g;r[3]===n.conversationId?g=r[4]:(g=n.conversationId?.trim()??``,r[3]=n.conversationId,r[4]=g);let _=g,v;r[5]===n.selectedContextKeys?v=r[6]:(v=[...n.selectedContextKeys??new Set].sort().join(`\0`),r[5]=n.selectedContextKeys,r[6]=v);let b=v,x;r[7]!==i.agentSwitch||r[8]!==i.skills||r[9]!==_||r[10]!==h||r[11]!==u||r[12]!==n||r[13]!==p||r[14]!==b?(x=()=>{let e=l.current+=1;if(!p){c(eO(!1));return}if(!_){c(eO(!!n.prepareSession)),n.prepareSession&&n.prepareSession().catch(()=>{l.current===e&&c(eO(!1))});return}let t={conversationId:_,currentAgentId:n.currentAgentId,language:u,selectedContextKeys:new Set(b?b.split(`\0`):[]),recentPaths:new Set(XD(_))};if(rO(h)){let t=eO(!1);t.file={items:[],loading:!0,error:null},c(t);let r=iO(h);XT(r,{conversationId:_,agentId:n.currentAgentId}).then(t=>{if(l.current!==e)return;let n={id:`browse-up:${r}`,kind:`file`,name:`..`,description:aO(r)||`/`,relativePath:``,isDirectory:!0,isBrowseUp:!0};c(e=>({...e,file:{items:[n,...t.map(sO)],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(eO(!0));for(let n of $T.filter(e=>(e.kind!==`skill`||i.skills)&&(e.kind!==`agent`||i.agentSwitch)))n.search(h,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]=_,r[10]=h,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]!==_||r[19]!==h||r[20]!==u||r[21]!==n.currentAgentId||r[22]!==n.prepareSession||r[23]!==p||r[24]!==b?(S=[p,_,h,u,n.currentAgentId,n.prepareSession,b,i.skills,i.agentSwitch],r[16]=i.agentSwitch,r[17]=i.skills,r[18]=_,r[19]=h,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=$D.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(dO):[],E;r[35]!==p||r[36]!==w?(E=p&&w.some(uO),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(lO),r[38]=w,r[39]=O);let k=O,A=!D&&T.length===0?k[0]??null:null,j=`${f?.start??``}:${f?.end??``}:${h}`,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=oO(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 lO(e){return e.error?[e.error]:[]}function uO(e){return e.loading}function dO(e){return e.items}function fO(e){return e.language}function pO(){return eO(!1)}function mO(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 hO(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??um,D=(0,Q.useMemo)(()=>tO(n,r),[n,r]),O=mD(n,r,{suppress:D!=null,capabilities:E,isComposing:i,currentAgentId:m,conversationId:t}),k=cO(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`||eD(e,j())},[j,E]),N=(0,Q.useCallback)(e=>{let n=k.atRange;if(!n)return;let r=mO(e);if(r){let i=_(r);if(!i?.refId)return;let a=`${er(i.refId)} `,o=XE(c.current,n.start,n.end,a);l({nextText:o,caretOffset:n.start+a.length,focus:!0}),t&&e.kind===`file`&&ZD(t,e.relativePath);return}if(e.kind===`skill`){if(!E.skills)return;let t=`/skill:${e.canonicalName} `,r=XE(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=XE(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=`@${nO(e.isBrowseUp?(()=>{let e=aO(iO(n.query));return e?`${e}/`:``})():`${e.relativePath.replace(/\/+$/,``)}/`)}`,a=XE(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]);KD({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=XE(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]),ee=(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||oD(n,U.current)||V.current(n),!0}}if(e.key===`Escape`){e.preventDefault();let n=t.slashRange;if(n){let e=F.current,t=XE(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,ee],[W,ee]),applyPalette:M,applyAtMention:N}}function gO(e){return/^[A-Za-z0-9._/@:-]+$/.test(e)?e:JSON.stringify(e)}function _O(e,t){let n=t?.trim();return n?`${e} --instructions ${gO(n)}`:e}function vO(e){if(e.preset===`base`){if(!e.baseBranch?.trim())throw Error(`Missing base branch.`);return _O(`/review --base ${gO(e.baseBranch.trim())}`,e.instructions)}if(e.preset===`commit`){if(!e.commitSha?.trim())throw Error(`Missing commit SHA.`);return _O(`/review --commit ${gO(e.commitSha.trim())}`,e.instructions)}return e.preset,_O(`/review --uncommitted`,e.instructions)}async function yO(e){let t=await g(_(`/api/review/context?${new URLSearchParams({conversationId:e}).toString()}`)),n=await t.json().catch(()=>({}));if(!t.ok||!n.ok||!n.payload)throw Error(S(t.status,t.statusText,n.error?.message));return n.payload}function bO(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 xO(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 SO(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 CO(e){let t=(0,Z.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`,Pa.transition),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,X.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,X.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,X.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,X.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,X.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 wO(e){let t=(0,Z.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,b]=(0,Q.useState)(``),x;t[0]!==r||t[1]!==c.noSession?(x=()=>{if(!r){u(null),m(c.noSession);return}f(!0),m(null),yO(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]=x):x=t[2];let S=x,C,T;t[3]!==S||t[4]!==n?(C=()=>{n&&(g(`presets`),v(``),b(``),S())},T=[S,n],t[3]=S,t[4]=n,t[5]=C,t[6]=T):(C=t[5],T=t[6]),(0,Q.useEffect)(C,T);let D;t[7]!==l||t[8]!==_?(D=xO(l,_),t[7]=l,t[8]=_,t[9]=D):D=t[9];let M=D,N;t[10]!==l||t[11]!==_?(N=SO(l,_),t[10]=l,t[11]=_,t[12]=N):N=t[12];let P=N,I;t[13]!==l||t[14]!==c?(I=bO(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=vO({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,X.jsx)(w,{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,X.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,X.jsx)(F,{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,X.jsx)(A,{className:`truncate text-sm font-semibold text-fg`,children:B}),t[26]=B,t[27]=W);let ee=l?.cwd??c.description,te;t[28]===ee?te=t[29]:(te=(0,X.jsx)(E,{className:`truncate text-xs text-fg-muted`,children:ee}),t[28]=ee,t[29]=te);let ne;t[30]!==W||t[31]!==te?(ne=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[W,te]}),t[30]=W,t[31]=te,t[32]=ne):ne=t[32];let re;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,X.jsx)(an,{className:`size-4`}),t[33]=re):re=t[33];let ie;t[34]!==c.close||t[35]!==o?(ie=(0,X.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:re}),t[34]=c.close,t[35]=o,t[36]=ie):ie=t[36];let ae;t[37]!==U||t[38]!==ne||t[39]!==ie?(ae=(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-4 py-3`,children:[U,ne,ie]}),t[37]=U,t[38]=ne,t[39]=ie,t[40]=ae):ae=t[40];let oe;t[41]!==M||t[42]!==P||t[43]!==l||t[44]!==i||t[45]!==p||t[46]!==y||t[47]!==S||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?(oe=(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:d?(0,X.jsxs)(`div`,{className:`flex h-full min-h-56 items-center justify-center text-sm text-fg-muted`,children:[(0,X.jsx)(It,{className:`mr-2 size-4 animate-spin`}),c.loading]}):p?(0,X.jsxs)(`div`,{className:`rounded-lg border border-danger/30 bg-danger/5 p-4`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:c.errorTitle}),(0,X.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:p}),(0,X.jsxs)(Yi,{type:`button`,className:`mt-4 h-9 rounded-lg`,variant:`secondary`,onClick:S,children:[(0,X.jsx)(It,{className:`size-4`}),c.retry]})]}):h===`presets`?(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[(0,X.jsx)(CO,{icon:(0,X.jsx)(je,{className:`size-4`}),title:c.presetBase,description:l?.defaultBaseBranch?c.presetBaseDescription.replace(`{{branch}}`,l.defaultBaseBranch):c.presetBaseDescriptionNoDefault,disabled:i,onClick:()=>g(`base`)}),(0,X.jsx)(CO,{icon:(0,X.jsx)(Ge,{className:`size-4`}),title:c.presetUncommitted,description:L,disabled:i,onClick:()=>z(`uncommitted`)}),(0,X.jsx)(CO,{icon:(0,X.jsx)(nc,{className:`size-4`}),title:c.presetCommit,description:c.presetCommitDescription.replace(`{{count}}`,String(l?.commits.length??0)),disabled:i,onClick:()=>g(`commit`)}),(0,X.jsx)(CO,{icon:(0,X.jsx)(Ge,{className:`size-4`}),title:c.presetCustom,description:c.presetCustomDescription,disabled:i,onClick:()=>g(`custom`)})]}):h===`base`?(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(TO,{value:_,placeholder:c.searchBranches,onChange:v}),(0,X.jsx)(`div`,{className:`grid gap-1`,children:M.length===0?(0,X.jsx)(`div`,{className:`rounded-lg border border-edge-subtle px-3 py-6 text-center text-sm text-fg-muted`,children:c.noBranches}):M.map(e=>(0,X.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,X.jsx)(`span`,{className:`min-w-0 truncate text-sm text-fg`,children:e.name}),(0,X.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,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(TO,{value:_,placeholder:c.searchCommits,onChange:v}),(0,X.jsx)(`div`,{className:`grid gap-1`,children:P.length===0?(0,X.jsx)(`div`,{className:`rounded-lg border border-edge-subtle px-3 py-6 text-center text-sm text-fg-muted`,children:c.noCommits}):P.map(e=>(0,X.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,X.jsx)(`span`,{className:`font-mono text-xs text-fg-muted`,children:e.shortSha}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg`,children:e.subject}),e.date?(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:e.date.slice(0,10)}):null]},e.sha))})]}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.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=>b(e.target.value)}),(0,X.jsx)(`div`,{className:`text-xs text-fg-muted`,children:c.customDescription})]})}),t[41]=M,t[42]=P,t[43]=l,t[44]=i,t[45]=p,t[46]=y,t[47]=S,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]=oe):oe=t[73];let se;t[74]!==i||t[75]!==c.cancel||t[76]!==c.runReview||t[77]!==o||t[78]!==z||t[79]!==h?(se=h===`custom`?(0,X.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-4 py-3`,children:[(0,X.jsx)(Yi,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg`,onClick:o,children:c.cancel}),(0,X.jsx)(Yi,{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]=se):se=t[80];let ce;t[81]!==ae||t[82]!==oe||t[83]!==se?(ce=(0,X.jsxs)(O,{children:[H,(0,X.jsxs)(k,{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:[ae,oe,se]})]}),t[81]=ae,t[82]=oe,t[83]=se,t[84]=ce):ce=t[84];let le;return t[85]!==n||t[86]!==ce||t[87]!==V?(le=(0,X.jsx)(j,{open:n,onOpenChange:V,children:ce}),t[85]=n,t[86]=ce,t[87]=V,t[88]=le):le=t[88],le}function TO(e){let t=(0,Z.c)(7),{value:n,placeholder:r,onChange:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(zt,{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,X.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,X.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 EO(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 DO=(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:l,contextRefs:u,maxContextRefs:p=5,setContextRefs:m,onDraftAttachmentsChange:h,thinkingLevel:g,modelSupportsThinking:_,onThinkingChange:b,onSend:x,onPersonalSendDispatched:S,onAbort:w,onAddPendingFollowUp:T,onSteeringInterrupt:E,pendingFollowUps:D,editingFollowUpId:O,onBeginEditFollowUp:k,onCancelEditFollowUp:A,onCommitEditFollowUp:j,onPendingFollowUpRemove:M,onPendingFollowUpMove:N,onPendingFollowUpReorder:P,onPendingFollowUpSteer:F,onPendingFollowUpSend:I,steeringFollowUpId:L,welcomeDraftSeed:R,addActions:z,welcomeSuggestion:B,onAcceptWelcomeSuggestion:V,sessionModel:H,showModelSelector:U,onModelChange:W,modelDisabled:ee,onChatAgentChange:te,currentAgentId:ne,voiceAgentName:re,voiceTaskId:ie,voiceMode:ae,prepareVoiceSession:oe,prepareContextSession:se,unboundDraftKey:ce,getDraftHandoffTarget:le,attachmentHandoffReady:ue,embeddedAttachmentHandoffId:de,editingUserTurnId:fe,composerMode:pe,inputControl:G,onResumeQueue:me,onRestoreEditor:he,onReacquireEdit:K,onComposerHydrated:ge,onCancelUserMessageEdit:_e}){let q=Ka(),ve=(0,Q.useRef)(!1);r||=q.conversationId===s&&q.active;let ye=y(e=>e.language),J=C(ye),[be,xe]=d(),{state:Se}=f();(0,Q.useEffect)(()=>{is()},[]);let Ce=(...e)=>{if(i)return!1;let t=x(...e);return t instanceof Promise?t.then(t=>(t!==!1&&dt.submitted(e[0]),t)):(t!==!1&&dt.submitted(e[0]),t)},we=(0,Q.useRef)(!1),Te=(0,Q.useRef)(null),Ee=(0,Q.useRef)(null),De=(0,Q.useRef)(null),Oe=(0,Q.useRef)(!1),[ke,Ae]=(0,Q.useState)(!1),[je,Me]=(0,Q.useState)(null),[Ne,Pe]=(0,Q.useState)(null),[Fe,Ie]=(0,Q.useState)(!1),Le=(0,Q.useRef)(Ce),Re=(0,Q.useRef)(g);Le.current=Ce,Re.current=g,(0,Q.useEffect)(()=>{if(!s||Ne===s){Me(null);return}let e=!1;return $r(s).then(e=>e?null:cs(s)).then(t=>{e||Me(t&&t.required&&!t.trusted&&t.decision===null?t:null)}).catch(()=>{e||Me(null)}),()=>{e=!0}},[s,Ne]);let ze=(0,Q.useCallback)(()=>{!s||Fe||(Ie(!0),$o(s,!0).then(()=>{Me(null)}).catch(e=>{Ga(`error`,J.chat.commandPalette.workspaceTrustFailed,{error:e instanceof Error?e.message:String(e)})}).finally(()=>Ie(!1)))},[J.chat.commandPalette,s,Fe]),Be=Xo({conversationId:s??`new`,chat:J.chat,onAttachmentsChange:e=>h?.(e.map((e,t)=>({id:e.uri||e.id||`draft:${t}:${e.name}`,title:e.name})))}),Ve=(0,Q.useRef)(u);Ve.current=u;let He=(0,Q.useCallback)(e=>{let t=u.find(t=>t.refId===e);return t?{title:t.title,kind:t.kind,fileKind:t.fileKind}:void 0},[u]),Ue=(0,Q.useCallback)(e=>{let t=e?.contextRefs??[];if(Ve.current=t,m(t),e?.attachments){Be.setAttachments(e.attachments.map(EO));return}Be.clearAttachments()},[Be.clearAttachments,Be.setAttachments,m]),We=(0,Q.useCallback)(e=>{let t=Ve.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 Ve.current=i,m(i),r}if(t.length>=p)return Ga(`warning`,J.chat.commandPalette.contextLimitReached,{max:p}),null;let r=[...t,e];return Ve.current=r,m(r),e},[J.chat.commandPalette.contextLimitReached,p,m]);(0,Q.useEffect)(()=>{let e=e=>{let t=e.detail;t?.conversationId!==s||t.reference.kind!==`result`||We(t.reference)};return window.addEventListener(`chat-result-reference`,e),()=>window.removeEventListener(`chat-result-reference`,e)},[s,We]);let Ge=(0,Q.useCallback)(e=>{let t=e.availability.status===`agent-denied`?J.chat.commandPalette.skillAgentDeniedReason:J.chat.commandPalette.skillDisabledReason,n=mh(J.chat.commandPalette.skillUnavailableMessage,{name:e.name,agent:ne||`main`,reason:t});if(e.availability.status===`agent-denied`&&window.confirm(`${n}\n\n${J.chat.commandPalette.skillAddToAllowlistConfirm}`)){ls(ne,e.canonicalName,s).catch(e=>{window.alert(e instanceof Error?e.message:String(e))});return}window.alert(n)},[ne,J.chat.commandPalette,s]),Ke=oh({capabilities:e?dm:um,disabled:r,agentId:ne,conversationId:s,autoFocusKey:s,welcomeDraftSeed:R,onExternalTextReplace:Ue,shouldSyncSelectionRef:we,resolveContextRef:He}),qe=de??be.get(`attachmentHandoff`);(0,Q.useEffect)(()=>{if(!ue||!qe)return;let e=Yt(qe);s&&!de&&xe(e=>{let t=new URLSearchParams(e);return t.delete(`attachmentHandoff`),t},{replace:!0,state:Se}),e&&Be.processFiles([e]).then(()=>Ke.editorRef.current?.focus({preventScroll:!0}))},[ue,qe,de,Be.processFiles,Ke.editorRef,s,Se,xe]);let{onUserTextCommitted:Je,onWireInputClearWalk:Ye,tryInputHistoryArrow:Xe}=ID({conversationId:s,editorRef:Ke.editorRef,valueRef:Ke.valueRef,resetEditor:Ke.resetEditor,onWireInput:Ke.onWireInput}),Ze=(0,Q.useCallback)((e,t)=>{Ye(e,t);let n=Hr(e),r=new Set(n?In(n):[]),i=Ve.current,a=i.filter(e=>!e.refId||r.has(e.refId));a.length!==i.length&&(Ve.current=a,m(a))},[Ye,m]),Qe=Zp(s??``),$e=a||o||Qe||G?.phase===`running`||G?.phase===`stopping`;Oe.current=$e;let et=(0,Q.useCallback)(()=>{Oe.current||Ae(!0)},[]),tt=(0,Q.useCallback)(e=>{qE(Le.current(e,void 0,Re.current,u),t=>{Je?.(e,t),m([])})},[u,Je,m]),nt=hO({capabilities:e?dm:um,conversationId:s,editorValue:Ke.value,editorCursor:Ke.cursor,isComposing:Ke.isComposing,runBusy:$e,thinkingLevel:g,editorRef:Ke.editorRef,valueRef:Ke.valueRef,resetEditor:Ke.resetEditor,clearAttachments:Be.clearAttachments,onSend:Ce,onUserTextCommitted:Je,onChatAgentChange:te,currentAgentId:ne,prepareSession:se,contextRefs:u,onAddContextRef:We,onUnavailableSkill:Ge,onReviewLauncher:et,onAddPendingFollowUp:T,onAbort:w,pendingFollowUpsCount:D.length,maxPendingFollowUps:10,clearContextRefs:()=>m([]),commandPalettePanelRef:Te});we.current=nt.shouldSyncSelection;let rt=Ua({disabled:r||q.active,chat:J.chat,onTranscript:e=>{let t=Ke.valueRef.current,n=ps(t,e);Ke.resetEditor({nextText:n,caretOffset:n.length,focus:!0})}}),{phase:it,voiceActive:at,startVoiceInput:ot,cancelVoiceInput:st,confirmVoiceInput:ct}=rt;(0,Q.useEffect)(()=>{let e=e=>{if(!SE(e,{disabled:r,editorHidden:at&&it!==`error`}))return;let t=Zm(e.clipboardData);t&&(e.preventDefault(),Ke.focusForExternalPaste(),Qm(t,{processFiles:Be.processFiles,processPastedText:Be.processPastedText,insertText:e=>document.execCommand(`insertText`,!1,e),onUnsupportedFiles:()=>Ga(`warning`,J.chat.clipboardFileTypeUnsupported)}))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[Be.processFiles,Be.processPastedText,r,Ke.focusForExternalPaste,J.chat.clipboardFileTypeUnsupported,at,it]),(0,Q.useEffect)(()=>{let e=e=>{let t=e?.detail?.target;if(!(t&&t!==`chat`)&&(e?.preventDefault(),!r)){if(it===`recording`){ct();return}(it===`idle`||it===`error`)&&(Ke.editorRef.current?.focus({preventScroll:!0}),ot())}},t=e=>{let t=e.detail?.target;t&&t!==`chat`||!at||(e.preventDefault(),st(),Ke.editorRef.current?.focus({preventScroll:!0}))};window.addEventListener(bs,e),window.addEventListener(vs,t);let n=window.setTimeout(()=>{if(xs()){if(r){ys();return}e()}},0);return()=>{window.clearTimeout(n),window.removeEventListener(bs,e),window.removeEventListener(vs,t)}},[st,ct,r,Ke.editorRef,ot,at,it]);let lt=(0,Q.useCallback)(()=>{De.current=null},[]),ut=n&&!r&&!i&&!$e&&!O&&!fe&&!rt.voiceActive&&!Ke.isComposing&&Ke.value.length===0&&Be.attachments.length===0&&u.length===0&&D.length===0,dt=GD({conversationId:s,agentId:ne,modelKey:H,locale:ye,enabled:n,draftText:Ke.value,canShow:ut}),ft=()=>{if(!ut||Ke.valueRef.current.length>0||Ve.current.length>0)return!1;let e=dt.accept();return e?(Ke.resetEditor({nextText:e,focus:!0}),!0):!1};(0,Q.useEffect)(()=>{ut&&dt.suggestion&&!nt.palette.open&&dt.shown()},[ut,dt.suggestion,dt.shown,nt.palette.open]);let pt=v(e=>e.conversationId),mt=(0,Q.useMemo)(()=>({gatewayIdentity:pt,conversationId:s,unboundDraftKey:ce}),[pt,s,ce]),ht=(0,Q.useRef)(new Map),gt=(0,Q.useRef)(`compose`),_t=pe??(O?{kind:`editFollowUp`,inputId:O,version:0}:{kind:`compose`}),vt=_t.kind===`editTurn`?`turn:${_t.turnId}`:_t.kind===`editFollowUp`?`input:${_t.inputId}`:`compose`;(0,Q.useLayoutEffect)(()=>{ht.current.clear(),gt.current=`compose`},[mt]),WD(s,Ke,Be,u,m,{ready:ge,snapshot:()=>({mode:_t,drafts:Object.fromEntries(ht.current)}),restore:e=>{ht.current=new Map(Object.entries(e.drafts)),gt.current=e.mode.kind===`editTurn`?`turn:${e.mode.turnId}`:e.mode.kind===`editFollowUp`?`input:${e.mode.inputId}`:`compose`,he?.(e.mode)}},ce,le);let yt=_t.kind!==`compose`&&!!(G&&!G.paused),bt=zD({personal:e,chat:J.chat,runBusy:$e,draftScope:mt,queuePaused:G?.paused,editingUserTurnId:fe,blocked:r||i||yt||G?.phase===`stopping`,onFinishUserEdit:_e,onFinishFollowUpEdit:A,voiceActive:rt.voiceActive,cancelVoiceInput:rt.cancelVoiceInput,editingFollowUpId:O,getTextValue:()=>Ke.valueRef.current,getAttachmentCount:()=>Be.attachmentsRef.current.length,wireAttachmentsPayload:Be.wireAttachmentsPayload,getContextRefs:()=>u,getThinkingLevel:()=>Re.current,onSend:Ce,onDispatched:e&&S?(e,t)=>{let n=Ke.editorRef.current?.getBoundingClientRect();n&&S(e,n,t)}:void 0,onAddPendingFollowUp:T,onSteeringInterrupt:E,onCommitEditFollowUp:j,onPendingFollowUpRemove:M,pendingFollowUpsCount:D.length,firstPendingFollowUpId:D[0]?.id,onSteerPendingFollowUp:F,steeringPending:!!L,resetEditor:()=>{Ke.resetEditor()},clearAttachments:Be.clearAttachments,clearContextRefs:()=>m([]),clearEditFollowUpRef:lt,onUserTextCommitted:Je}),xt=(0,Q.useCallback)((e=!1)=>bt.flushSteeringDraft(e),[bt.flushSteeringDraft]),St=(0,Q.useCallback)((e,t)=>{!s||s===`new`||WT.getState().requestCreate(s,[{id:e.id,type:`text`,text:t,label:J.chat.followUpQueueHeading}])},[s,J.chat.followUpQueueHeading]);(0,Q.useLayoutEffect)(()=>{if(gt.current===vt)return;ht.current.set(gt.current,{text:Ke.valueRef.current,attachments:Be.wireAttachmentsPayload(),contextRefs:Ve.current,thinkingLevel:Re.current}),gt.current=vt;let e=_t.kind===`editFollowUp`?D.find(e=>e.id===_t.inputId):void 0;e?.thinkingLevel&&_&&b(e.thinkingLevel);let t=(_t.kind===`compose`?_t.draft:void 0)??ht.current.get(vt)??(_t.kind===`editTurn`?_t.draft:e?{text:e.text,attachments:e.attachments??[],contextRefs:e.contextRefs??[]}:void 0);t?.thinkingLevel&&_&&b(t.thinkingLevel),Be.setAttachments(zE(t?.attachments??[])),m(t?.contextRefs??[]),Ke.resetEditor({nextText:t?.text??``,focus:!0})},[vt,_t,D,Be,Ke,m]);let Ct=(0,Q.useCallback)(e=>{k(e)},[k]),wt=(0,Q.useRef)({});wt.current={adapters:nt.adapters,send:bt.send,runBusy:$e,pendingFollowUpsCount:D.length,flushSteeringDraft:xt,steerDraft:()=>bt.flushSteeringDraft(!1,`steer`),steerCurrentReply:bt.steerCurrentReply,interruptDraft:bt.interruptDraft,editingFollowUpId:O,editingUserTurnId:fe,onCancelUserMessageEdit:_e,onCancelEditFollowUp:A,attachmentsLen:Be.attachments.length,contextRefsLen:u.length,isComposing:Ke.isComposing,valueRef:Ke.valueRef,adjustHeight:Ke.adjustHeight,editorRef:Ke.editorRef,tryInputHistoryArrow:Xe,acceptEmptySuggestion:dt.suggestion&&ut?ft:!$e&&!r&&!i&&!fe&&!rt.voiceActive&&B&&V?()=>(V(B),!0):void 0,dismissEmptySuggestion:dt.suggestion?dt.dismiss:void 0};let Tt=$e&&!O&&!fe,Et={...J.chat,sendMessage:O?J.chat.followUpSaveEdit:fe?J.chat.userMessageReplaceSend:G?.paused?J.chat.sendThisMessage:J.chat.sendMessage},Dt=!!Ke.value.trim()||Be.attachments.length>0||u.length>0,Ot=Dt&&!!E,kt=zs(`(hover: hover) and (pointer: fine)`),At=!Tt&&!O&&B?`${B.prompt}${kt?` · ${J.chat.welcomeSpotlight.acceptSuggestionHint}`:``}`:null;return(0,X.jsxs)(`div`,{className:`relative flex min-h-0 w-full flex-col`,children:[s?(0,X.jsx)(vE,{conversationId:s},s):null,c?(0,X.jsx)(jE,{...c,conversationId:s,disabled:(c.disabled??r)||a||o}):null,(0,X.jsxs)(uh,{className:e?`rounded-[1.65rem]`:void 0,dragging:Be.isDragging,onDragOver:e=>{(e.dataTransfer?.types.includes(`Files`)||em(e.dataTransfer))&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,Be.setIsDragging(!0))},onDragLeave:e=>{e.relatedTarget===null&&Be.setIsDragging(!1)},onDrop:async e=>{e.preventDefault(),Be.setIsDragging(!1);let t=e.dataTransfer?.files;if(t?.length){await Be.processFiles(Array.from(t));return}let n=tm(e.dataTransfer);if(n)try{let e=await yo(n.path,{conversationId:n.conversationId,agentId:n.agentId,projectId:n.projectId}),t=Ri(n.name),r=e.type&&e.type!==`application/octet-stream`?e.type:t;await Be.processFiles([new File([e],n.name,{type:r})])}catch{Ga(`error`,J.chat.attachmentLoadFailed,{name:n.name})}},children:[Be.isDragging?(0,X.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,fe?(0,X.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,X.jsx)(`span`,{children:J.chat.userMessageEditing}),(0,X.jsx)(`button`,{type:`button`,className:`font-medium text-accent-fg hover:underline`,onClick:_e,children:J.chat.userMessageEditCancel})]}):null,yt&&(0,X.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,X.jsx)(`span`,{children:J.chat.editQueueResumed}),(0,X.jsx)(`button`,{type:`button`,disabled:r||i,className:`text-accent-fg disabled:opacity-40`,onClick:()=>K?.({text:Ke.valueRef.current,attachments:Be.wireAttachmentsPayload(),contextRefs:Ve.current}),children:J.chat.editPauseAgain})]}),G?.paused&&(D.length>0||G.phase===`stopping`||_t.kind!==`compose`)&&(0,X.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,X.jsx)(`span`,{children:G.phase===`stopping`?J.chat.inputStopping:G.reviewRequired?J.chat.queueReviewRequired:D.length>0?J.chat.queuePausedCount.replace(`{count}`,String(D.length)):J.chat.queuePaused}),(0,X.jsx)(`button`,{type:`button`,disabled:r||i||!!(O||fe)||G.phase!==`idle`,className:`text-accent-fg disabled:opacity-40`,onClick:me,children:J.chat.queueResume})]}),(0,X.jsx)(OE,{conversationId:s}),D.length>0?(0,X.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,X.jsx)(DE,{items:D,disabled:r||i||!!(fe||O),editingFollowUpId:O,onEditInComposer:Ct,onRemove:M,onMove:N,onReorder:P,onSteer:F,onSendSingle:I,queuePaused:G?.paused,queueIdle:G?.phase===`idle`,steeringBusyId:L,onOpenSideChat:s&&s!==`new`?St:void 0})}):null,(O||fe)&&(0,X.jsx)(`div`,{className:`flex items-center justify-end px-4 py-1 text-xs`,children:(0,X.jsx)(`button`,{type:`button`,disabled:i,className:`text-accent-fg disabled:opacity-40`,onClick:()=>he?.({kind:`compose`,draft:{text:Ke.valueRef.current,attachments:Be.wireAttachmentsPayload(),contextRefs:Ve.current}}),children:J.chat.editAsNewMessage})}),_t.kind===`editFollowUp`&&D.some(e=>e.id===_t.inputId&&e.version!==_t.version)&&(0,X.jsxs)(`div`,{className:`border-b border-edge-subtle px-4 py-2 text-xs text-fg-muted`,children:[(0,X.jsx)(`p`,{children:J.chat.followUpEditConflict}),(0,X.jsx)(`p`,{className:`my-1 max-h-20 overflow-auto whitespace-pre-wrap`,children:D.find(e=>e.id===_t.inputId)?.text}),(0,X.jsx)(`button`,{type:`button`,disabled:i,className:`text-accent-fg`,onClick:()=>k(_t.inputId),children:J.chat.followUpKeepMyEdit})]}),O?(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-4 py-2 text-xs text-fg-muted`,children:[(0,X.jsx)(`span`,{children:J.chat.inputPlaceholderSteeringEdit}),(0,X.jsx)(`button`,{type:`button`,onClick:A,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,X.jsx)(Jo,{attachments:Be.attachments,conversationId:s,topPadded:D.length>0,onRemove:Be.removeAttachment}),(0,X.jsx)(kE,{refs:u.filter(e=>!e.refId),label:J.chat.commandPalette.contextLabel,onRemove:e=>m(t=>t.filter(t=>t.sourceId!==e))}),l,(0,X.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,X.jsx)(`input`,{ref:Ee,type:`file`,multiple:!0,className:`hidden`,onChange:async e=>{let t=e.target.files;t&&await Be.processFiles(Array.from(t)),e.target.value=``}}),e&&!rt.voiceActive&&(0,X.jsx)(LE,{disabled:r||i,attachmentCount:Be.attachments.length,maxAttachments:10,chat:J.chat,onPickFiles:()=>Ee.current?.click(),addActions:z}),(0,X.jsxs)(`div`,{className:e?`relative min-w-0 flex-1 px-1`:Y(`relative px-3 pb-0 pt-1 sm:px-4`,Be.attachments.length>0&&`pt-2`),children:[(0,X.jsx)(KE,{open:nt.atPicker.open,anchorRef:Ke.editorRef,items:nt.atPicker.items,selectedIndex:nt.atPicker.selectedIndex,loading:nt.atPicker.loading,query:nt.atPicker.query,noResults:nt.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:nt.applyAtMention}),(0,X.jsx)(CD,{open:nt.palette.open,anchorRef:Ke.editorRef,panelRef:Te,sections:nt.palette.loadError?[]:nt.palette.sections,flatItems:nt.palette.loadError?[]:nt.palette.flatItems,loading:nt.palette.loading,failedKinds:nt.palette.failedKinds,selectedIndex:nt.palette.selectedIndex,noResults:nt.palette.loadError??J.chat.commandPalette.noResults,sectionLoadFailedLabel:J.chat.commandPalette.sectionLoadFailed,query:nt.palette.query,skillsLabel:J.chat.commandPalette.skillsSection,commandsLabel:J.chat.commandPalette.commandsSection,agentsLabel:J.chat.commandPalette.agentsSection,currentAgentId:ne,currentBadgeLabel:J.chat.commandPalette.currentBadge,runBusy:$e,pendingFollowUpsCount:D.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:nt.applyPalette}),rt.voiceActive?(0,X.jsx)(gs,{phase:rt.phase,elapsedLabel:rt.elapsedLabel,recordedDictation:rt.recordedDictation,audioLevel:rt.audioLevel,partialTranscript:rt.partialTranscript,finalTranscript:rt.finalTranscript,error:rt.error,settingsRequired:rt.settingsRequired,disabled:r,chat:J.chat,onCancel:rt.cancelVoiceInput,onConfirm:rt.confirmVoiceInput,onRetry:rt.retryVoiceInput}):null,(0,X.jsx)(sh,{editorRef:Ke.editorRef,disabled:r,hidden:rt.voiceActive&&rt.phase!==`error`,compact:e,ariaLabel:t??J.chat.inputPlaceholder,placeholder:(ut&&dt.suggestion?`${dt.suggestion.prompt}${kt?` · ${J.chat.welcomeSpotlight.acceptSuggestionHint}`:``}`:null)??t??At??(Tt?O?J.chat.inputPlaceholderSteeringEdit:e?J.chat.inputPlaceholderPersonal:J.chat.inputPlaceholderSteering:J.chat.inputPlaceholder),onWireInput:Ze,adjustHeight:Ke.adjustHeight,processFiles:Be.processFiles,processPastedText:Be.processPastedText,setIsComposing:Ke.setIsComposing,kbdRef:wt,chatMessages:J.chat})]}),e?(0,X.jsx)(RE,{disabled:r||i||yt,voiceActive:rt.voiceActive,runBusy:Tt,hasDraft:Dt,chat:Et,onStartVoiceInput:rt.startVoiceInput,onSend:bt.send,onAbort:w}):(0,X.jsx)(vh,{disabled:r,sendDisabled:i||yt,sending:a,streaming:o,runBusy:Tt,chat:Et,hasDraft:Dt,showSteeringInterrupt:Ot,attachmentCount:Be.attachments.length,maxAttachments:10,onPickFiles:()=>Ee.current?.click(),addActions:z,thinkingLevel:g,onThinkingChange:b,voiceActive:rt.voiceActive,onStartVoiceInput:rt.startVoiceInput,voiceConversationEnabled:!!(s||oe),onStartVoiceConversation:()=>{if(!ve.current){if(s){q.open({conversationId:s,name:re||ne||`xopc`,taskId:ie,mode:ae});return}oe&&(ve.current=!0,oe().then(e=>{if(e)return q.open({conversationId:e,name:re||ne||`xopc`,taskId:ie,mode:ae})}).catch(e=>Ga(`error`,e instanceof Error?e.message:J.chat.callFailed)).finally(()=>{ve.current=!1}))}},onSend:bt.send,onAbort:w,onInterrupt:bt.interruptDraft,sessionModel:H,showModelSelector:U,onModelChange:W,modelDisabled:ee})]}),(0,X.jsx)(wO,{open:ke,conversationId:s,disabled:r||Tt,chat:J.chat,onClose:()=>Ae(!1),onSendCommand:tt}),(0,X.jsx)(vo,{open:je!==null,title:J.chat.commandPalette.workspaceTrustTitle,description:mh(J.chat.commandPalette.workspaceTrustDescription,{path:je?.workspacePath??``}),confirmLabel:Fe?J.chat.commandPalette.workspaceTrustSaving:J.chat.commandPalette.workspaceTrustConfirm,cancelLabel:J.chat.commandPalette.workspaceTrustCancel,onConfirm:ze,onCancel:()=>{Me(null),Pe(s)}})]})]})});function OO(e){let t=(0,Z.c)(42),{draft:n,onRemove:r,disabled:i,waiting:a}=e,o=i!==void 0&&i,s=a!==void 0&&a,c=y(AO),l;t[0]===c?l=t[1]:(l=C(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,X.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,X.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(kO).join(`, `),t[7]=n.envelope.resourceRefs,t[8]=m);let h;t[9]===m?h=t[10]:(h=(0,X.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:m}),t[9]=m,t[10]=h);let g;t[11]===n.preview?g=t[12]:(g=(0,X.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]=g);let _;t[13]!==n.truncated||t[14]!==u.truncated?(_=n.truncated?(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:u.truncated}):null,t[13]=n.truncated,t[14]=u.truncated,t[15]=_):_=t[15];let v;t[16]!==n.envelope.selection||t[17]!==u.draft||t[18]!==u.selection?(v=n.envelope.selection?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`mt-2 text-xs font-medium text-fg`,children:n.envelope.selection.draft?u.draft:u.selection}),(0,X.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]=v):v=t[19];let b;t[20]!==_||t[21]!==v||t[22]!==f||t[23]!==p||t[24]!==h||t[25]!==g?(b=(0,X.jsxs)(`details`,{className:`min-w-0 flex-1`,children:[f,p,h,g,_,v]}),t[20]=_,t[21]=v,t[22]=f,t[23]=p,t[24]=h,t[25]=g,t[26]=b):b=t[26];let x=`${u.remove}: ${n.title}`,S;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,X.jsx)(an,{className:`size-4`,"aria-hidden":!0}),t[27]=S):S=t[27];let w;t[28]!==o||t[29]!==r||t[30]!==x?(w=(0,X.jsx)(`button`,{type:`button`,onClick:r,disabled:o,"aria-label":x,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:S}),t[28]=o,t[29]=r,t[30]=x,t[31]=w):w=t[31];let T;t[32]!==b||t[33]!==w?(T=(0,X.jsxs)(`div`,{className:`flex items-start gap-2`,children:[b,w]}),t[32]=b,t[33]=w,t[34]=T):T=t[34];let E;t[35]!==u.pending||t[36]!==s?(E=s?(0,X.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,X.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 kO(e){return`${e.kind} · ${e.id} · v${e.revision}`}function AO(e){return e.language}function jO(e){let t=(0,Z.c)(30),{selection:n}=e,r=y(MO)===`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,X.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,X.jsx)(Ue,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[2]=p):p=t[2];let m=p,h;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,X.jsx)(fc,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[3]=h):h=t[3];let g=h,_=r?`运行位置`:`Work in`,v;t[4]!==l||t[5]!==u||t[6]!==s||t[7]!==_||t[8]!==i||t[9]!==a||t[10]!==r?(v=!a&&!s?(0,X.jsx)(sn,{className:`h-8 w-36 rounded-full`}):(0,X.jsx)(pe,{ariaLabel:r?`新会话运行位置`:`New session environment`,placeholder:_,title:r?`Local 指 xopc Gateway 所在机器;首次发送时创建所选环境。`:`Local means the machine running xopc Gateway. The selected environment is created on first send.`,triggerIcon:l?(0,X.jsx)(qe,{className:`size-4 shrink-0 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}):i===`managed_worktree`?g: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:_,disabled:!a?.localAvailable},{value:`managed_worktree`,label:`New local worktree`,icon:g,group:_,disabled:!a||!!a.worktreeUnavailableReason}],onChange:e=>u(e)}),t[4]=l,t[5]=u,t[6]=s,t[7]=_,t[8]=i,t[9]=a,t[10]=r,t[11]=v):v=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,X.jsx)(Yi,{variant:`ghost`,className:`size-8 rounded-full p-0`,disabled:l||o,onClick:d,"aria-label":r?`重新检查环境`:`Recheck environment`,children:(0,X.jsx)(It,{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,X.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,X.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]!==v||t[26]!==b||t[27]!==x||t[28]!==S?(C=(0,X.jsxs)(X.Fragment,{children:[v,b,x,S]}),t[25]=v,t[26]=b,t[27]=x,t[28]=S,t[29]=C):C=t[29],C}function MO(e){return e.language}function NO({preparation:e,conversationId:t,ready:n,onSend:r}){let i=v(e=>e.conversationId),a=v(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),p=(0,Q.useRef)(!1),m=(0,Q.useRef)(r);m.current=r;let h=(0,Q.useRef)(t);h.current=t;let{data:g,error:y,isValidating:x,mutate:S}=bi(e?[`project-environment-options`,a,i,e.project.id]:null,async()=>(await b(_(`/api/projects/${encodeURIComponent(e.project.id)}/environment-options`))).options,{keepPreviousData:!1,revalidateOnFocus:!1,shouldRetryOnError:!1}),C=g?.localAvailable&&g.worktreeUnavailableReason!==`git_commit_required`&&g.worktreeUnavailableReason!==`workspace_unavailable`?o?.preparation===e?o.mode:e?ci(di(),e.project.id)??`local_checkout`:`local_checkout`:`local_checkout`,w=!!(!y&&g?.localAvailable&&(C===`local_checkout`||!g.worktreeUnavailableReason)),T=(0,Q.useCallback)(e=>{let t=f.current;f.current=null,d(null),t?.resolve(e?t.conversationId:null)},[]),E=(0,Q.useCallback)(()=>{let e=f.current,t=v.getState();return e?.token===t.conversationId&&e?.baseUrl===t.baseUrl?e?.openedConversationId:void 0},[]);(0,Q.useEffect)(()=>{if(u){if(u.baseUrl!==a||u.token!==i){T(!1);return}if(!u.conversationId){e!==u.preparation&&u.openedConversationId!==t&&T(!1);return}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 D=(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,void 0,e=>{f.current===s&&(s.openedConversationId=e)})).then(t=>{if(f.current!==s)return;ai(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:g,checking:x,checkFailed:!!y,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(),getDraftHandoffTarget:E,prepareSession:D,send:async(...n)=>{let r=t;if(e){if(p.current)return!1;p.current=!0;try{let e=await D();if(!e)return!1;r=e,n[2]=void 0}finally{p.current=!1}}return!r||h.current!==r?!1:await m.current(...n)!==!1&&{conversationId:r}}}}function PO(e,t){let n=(0,Z.c)(12),r=v(IO),i=v(FO),a;n[0]===e?a=n[1]:(a=t=>e?t.sessions[e]?.localDraft:void 0,n[0]=e,n[1]=a);let o=Sr(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 $r(e):void 0,r=n?n.creation.projectId:e?(await wn(e)).projectId:t;return r?xn(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}=bi(s,c,l);return d?null:u??null}function FO(e){return e.baseUrl}function IO(e){return e.conversationId}function LO(e,t){let n=mo(e,t),r=ho(e,t);return`${e.id} ${n} ${r}`.toLowerCase()}function RO(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=LO(e,n);return i.every(e=>t.includes(e))})}function zO(e){let t=(0,Z.c)(61),{items:n,value:r,disabled:i,placeholder:a,newChatLabel:o,searchPlaceholder:s,noMatches:c,compact:l,contentSide:u,contentAlign:d,className:f,onChange:p}=e,m=u===void 0?`bottom`:u,h=d===void 0?`end`:d,g=y(VO),_;t[0]===g?_=t[1]:(_=C(g),t[0]=g,t[1]=_);let v=_.agentsSettings,[b,x]=(0,Q.useState)(!1),[S,w]=(0,Q.useState)(``),T;t[2]!==v||t[3]!==n||t[4]!==S?(T=RO(n,S,v),t[2]=v,t[3]=n,t[4]=S,t[5]=T):T=t[5];let E=T,D,O,k;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),O=n.find(e),D=O?mo(O,v):r||a,k=O?[mo(O,v),ho(O,v)].filter(Boolean).join(` — `):void 0,t[6]=v,t[7]=n,t[8]=a,t[9]=r,t[10]=D,t[11]=O,t[12]=k}else D=t[10],O=t[11],k=t[12];let A=k,j=D===a?a:`${o??a} · ${D}`,M=A??a,N=l&&`min-w-0 max-w-[min(calc(15ch+3rem),calc(100vw-8rem))] py-1.5 text-[13px]`,P;t[15]!==f||t[16]!==N?(P=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`,Pa.transition,`hover:border-edge hover:bg-surface-hover/45`,Xa,Ja,`disabled:cursor-not-allowed disabled:opacity-50`,`dark:border-edge-subtle dark:hover:bg-surface-hover/55`,N,f),t[15]=f,t[16]=N,t[17]=P):P=t[17];let F;t[18]!==O?.avatar||t[19]!==r?(F=r?(0,X.jsx)(io,{agentId:r,avatar:O?.avatar,size:28,className:`shrink-0`}):null,t[18]=O?.avatar,t[19]=r,t[20]=F):F=t[20];let I=l?`max-w-[15ch] shrink`:`flex-1`,L;t[21]===I?L=t[22]:(L=Y(`min-w-0 truncate text-left`,I),t[21]=I,t[22]=L);let R;t[23]!==D||t[24]!==L?(R=(0,X.jsx)(`span`,{className:L,children:D}),t[23]=D,t[24]=L,t[25]=R):R=t[25];let z;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,X.jsx)(le,{className:`size-4 shrink-0 text-fg-subtle opacity-70`,"aria-hidden":!0}),t[26]=z):z=t[26];let B;t[27]!==i||t[28]!==F||t[29]!==R||t[30]!==j||t[31]!==M||t[32]!==P?(B=(0,X.jsx)(ta,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,disabled:i,"aria-label":j,title:M,className:P,children:[F,R,z]})}),t[27]=i,t[28]=F,t[29]=R,t[30]=j,t[31]=M,t[32]=P,t[33]=B):B=t[33];let V;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(V=Y(ce,`z-50 w-[var(--radix-popover-trigger-width)] min-w-[12rem] rounded-lg border border-edge bg-surface-overlay shadow-md`,Pa),t[34]=V):V=t[34];let H;t[35]===o?H=t[36]:(H=o?(0,X.jsx)(`p`,{className:`border-b border-edge px-3 py-2 text-xs font-medium text-fg-muted`,children:o}):null,t[35]=o,t[36]=H);let U;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(U=e=>w(e.target.value),t[37]=U):U=t[37];let W;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(W=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`,Xa),t[38]=W):W=t[38];let ee;t[39]!==S||t[40]!==s?(ee=(0,X.jsx)(`div`,{className:`shrink-0 border-b border-edge p-2`,children:(0,X.jsx)(`input`,{type:`search`,value:S,onChange:U,placeholder:s,className:W,"aria-label":s})}),t[39]=S,t[40]=s,t[41]=ee):ee=t[41];let te;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(te=Y(de,`max-h-64 p-1`),t[42]=te):te=t[42];let re;t[43]!==v||t[44]!==E||t[45]!==c||t[46]!==p||t[47]!==r?(re=E.length===0?(0,X.jsx)(`li`,{className:`p-2 text-sm text-fg-muted`,children:c}):E.map(e=>{let t=e.id===r,n=mo(e,v),i=ho(e,v),a=i.length>0?i:void 0;return(0,X.jsx)(`li`,{role:`option`,"aria-selected":t,children:(0,X.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:()=>{p(e.id),x(!1),w(``)},children:[(0,X.jsx)(io,{agentId:e.id,avatar:e.avatar,size:32,className:`shrink-0`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block truncate font-medium leading-tight`,title:n,children:n}),i?(0,X.jsx)(`span`,{className:`mt-0.5 block truncate text-xs leading-tight text-fg-muted`,title:a,children:i}):null]}),(0,X.jsx)(ne,{className:Y(`size-4 shrink-0`,t?`opacity-100`:`opacity-0`),"aria-hidden":!0})]})},e.id)}),t[43]=v,t[44]=E,t[45]=c,t[46]=p,t[47]=r,t[48]=re):re=t[48];let ie;t[49]===re?ie=t[50]:(ie=(0,X.jsx)(`ul`,{"data-select-scroll-region":!0,className:te,role:`listbox`,children:re}),t[49]=re,t[50]=ie);let ae;t[51]!==h||t[52]!==m||t[53]!==H||t[54]!==ee||t[55]!==ie?(ae=(0,X.jsx)(Zi,{children:(0,X.jsxs)(Qi,{side:m,align:h,sideOffset:4,collisionPadding:8,className:V,onOpenAutoFocus:BO,children:[H,ee,ie]})}),t[51]=h,t[52]=m,t[53]=H,t[54]=ee,t[55]=ie,t[56]=ae):ae=t[56];let oe;return t[57]!==b||t[58]!==B||t[59]!==ae?(oe=(0,X.jsxs)($i,{open:b,onOpenChange:x,children:[B,ae]}),t[57]=b,t[58]=B,t[59]=ae,t[60]=oe):oe=t[60],oe}function BO(e){return e.preventDefault()}function VO(e){return e.language}function HO(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 UO(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 WO=`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`,GO=`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 KO({conversationId:e,draftRefs:t=[],draftAttachments:n=[],draftPage:r,project:i,...a}){let[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),g=UO(y(e=>e.language)),_=f(),v=`${_.pathname}${_.search}`,{data:b,error:x,isLoading:S,isValidating:C,mutate:w}=fp(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??[],k=HO(T?.sources??[],t,n,r),A=T?.environment,j=!!(E||D||O.length),M=!!T?.unavailableSections.includes(`work`),P=!!T?.unavailableSections.includes(`sources`),F=!!T?.unavailableSections.includes(`environment`),I=[E?.title,D?.title,k.length?`${g.sources} ${k.length}${T?.sourcesHasMore?`+`:``}`:null,A?.kind===`managed_worktree`?`Worktree`:null].filter(Boolean).join(` · `)||g.title,L=()=>s(!1),R=k.some(e=>e.kind===`note`&&!e.unavailable&&e.origins.some(e=>e.kind===`session`)),z=()=>{A?.rootPath&&aa(A.rootPath).then(e=>{e&&(m(!0),window.setTimeout(()=>m(!1),1200))})},B=()=>(0,X.jsx)(`button`,{type:`button`,className:GO,"aria-label":g.refresh,disabled:C,onClick:()=>void w(),children:(0,X.jsx)(It,{className:`size-3.5 ${C?`animate-spin motion-reduce:animate-none`:``}`,"aria-hidden":!0})});return(0,X.jsxs)($i,{open:o,onOpenChange:s,children:[(0,X.jsx)(ta,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,"aria-label":g.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,X.jsx)(Ke,{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,X.jsx)(Zi,{children:(0,X.jsx)(Qi,{align:`end`,sideOffset:8,collisionPadding:12,"aria-label":g.title,onCloseAutoFocus:e=>{document.activeElement?.closest(`[data-primary-chat-composer]`)&&e.preventDefault()},className:`xopc-session-context-popover z-50 w-[min(23rem,calc(100vw-1.5rem))] rounded-xl border border-edge bg-surface-overlay shadow-popover`,children:(0,X.jsxs)(`div`,{className:`max-h-[min(30rem,var(--radix-popover-content-available-height))] overflow-y-auto rounded-xl p-3`,children:[(0,X.jsx)(`h2`,{className:`mb-2 px-2 text-sm font-medium text-fg`,children:g.title}),S?(0,X.jsx)(`div`,{className:`space-y-2 px-2`,"aria-busy":`true`,children:[0,1,2].map(e=>(0,X.jsx)(sn,{className:`h-8 w-full`},e))}):x?(0,X.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-2 text-sm text-fg-muted`,children:[(0,X.jsx)(`span`,{children:g.unavailable}),B()]}):(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsxs)(`section`,{"aria-label":g.work,children:[E?(0,X.jsxs)(h,{className:WO,to:Ze(v,`/projects/${encodeURIComponent(E.id)}`),onClick:L,children:[(0,X.jsx)(Oe,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:E.title,children:E.title})]}):null,D?(0,X.jsxs)(h,{className:WO,to:Qe(v,D.id),onClick:L,children:[(0,X.jsx)(mc,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:D.title,children:D.title}),(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:D.phase})]}):null,O.length?(0,X.jsxs)(X.Fragment,{children:[O.length>2?(0,X.jsxs)(`button`,{type:`button`,className:`${WO} w-full text-left`,onClick:()=>l(!c),"aria-expanded":c,children:[(0,X.jsx)(mc,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,X.jsxs)(`span`,{className:`flex-1`,children:[g.delegatedTasks,` · `,T?.work.delegatedTaskCount??O.length]}),(0,X.jsx)(`span`,{className:`text-xs text-fg-muted`,children:c?g.collapse:g.expand})]}):(0,X.jsxs)(`p`,{className:`px-2 pt-2 text-xs text-fg-subtle`,children:[g.delegatedTasks,` · `,T?.work.delegatedTaskCount??O.length]}),(c?O:O.slice(0,2)).map(e=>(0,X.jsxs)(h,{className:`${WO} pl-9`,to:Qe(v,e.id),onClick:L,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.title,children:e.title}),(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:e.runStatus??e.phase})]},e.id))]}):null,j?null:(0,X.jsx)(`p`,{className:`px-2 py-2 text-sm text-fg-muted`,children:M?g.unavailable:g.independent}),M?(0,X.jsxs)(`div`,{className:`flex items-center justify-between px-2 text-xs text-fg-muted`,children:[j?g.partialUnavailable:null,B()]}):null,E&&a.onLeaveProject?(0,X.jsx)(`button`,{type:`button`,className:GO,onClick:()=>{L(),a.onLeaveProject?.()},children:a.leaveProjectLabel}):null]}),k.length||P?(0,X.jsxs)(`section`,{className:`border-t border-edge-subtle pt-3`,children:[(0,X.jsxs)(`div`,{className:`mb-1 flex items-center justify-between px-2`,children:[(0,X.jsxs)(`h3`,{className:`text-sm text-fg-subtle`,children:[g.sources,` `,k.length?`${k.length}${T?.sourcesHasMore?`+`:``}`:``]}),P?B():null]}),(u?k:k.slice(0,3)).map(e=>{let t=e.origins.some(e=>e.kind===`session`)?g.session:e.origins.some(e=>e.kind===`task`)?g.task:e.origins.some(e=>e.kind===`recent`)?g.recent:g.draft,n=e.pending&&e.origins.length?`${t} · ${g.draft}`:e.pending?g.draft:t,r=e.kind===`file`&&e.fileKind===`directory`?Ae:e.kind===`file`?Ee:e.kind===`session`?yt:e.kind===`browser_tab`||e.kind===`browser_page`||e.kind===`app_context`?N:e.kind===`mcp_resource`?be:e.kind===`attachment`?kt:Ee,i=e.unavailable?g.unavailable:e.title||(e.kind===`note`?g.untitled:g.untitledSource),a=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(r,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.unavailable?void 0:e.title,children:i}),(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:n})]}),o=e.kind===`note`?et(v,e.id):e.kind===`session`?`/chat/${encodeURIComponent(e.id)}`:null,s=`${e.kind}:${e.id}`;return!e.unavailable&&o?(0,X.jsx)(h,{className:WO,to:o,onClick:L,children:a},s):(0,X.jsx)(`div`,{className:`flex min-w-0 items-center gap-3 px-2 py-2 text-sm text-fg-muted`,children:a},s)}),k.length?null:(0,X.jsx)(`p`,{className:`px-2 py-2 text-xs text-fg-muted`,children:g.unavailable}),k.length>0&&P?(0,X.jsx)(`p`,{className:`px-2 py-1 text-xs text-fg-muted`,children:g.partialUnavailable}):null,k.length>3?(0,X.jsx)(`button`,{type:`button`,className:GO,onClick:()=>d(!u),"aria-expanded":u,children:u?g.collapse:g.expand}):null,T?.sourcesHasMore?(0,X.jsx)(`p`,{className:`px-2 py-1 text-xs text-fg-muted`,children:g.more}):null,R&&a.onDraftSourceNote?(0,X.jsx)(`button`,{type:`button`,className:GO,onClick:()=>{L(),a.onDraftSourceNote?.()},children:a.draftSourceNoteLabel}):null]}):null,e&&(A||F)||a.environmentAction?(0,X.jsxs)(`section`,{className:`border-t border-edge-subtle pt-3`,children:[(0,X.jsxs)(`div`,{className:`mb-1 flex items-center justify-between px-2`,children:[(0,X.jsx)(`h3`,{className:`text-sm text-fg-subtle`,children:g.environment}),F?B():null]}),A?null:a.environmentAction,A?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 px-2 py-2 text-sm text-fg`,children:[(0,X.jsx)(xt,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:A.kind===`managed_worktree`?g.worktree:g.local}),A.branch||A.headSha?(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-40 items-center gap-1 text-xs text-fg-muted`,children:[(0,X.jsx)(je,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`truncate`,children:A.branch||(A.detached?`${g.detached} · ${A.headSha?.slice(0,8)}`:A.headSha?.slice(0,8))})]}):null]}),(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 pl-9 pr-1`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,title:A.rootPath,children:A.rootPath}),(0,X.jsx)(`button`,{type:`button`,className:GO,"aria-label":p?g.copied:g.copyEnvironmentPath,title:p?g.copied:g.copyEnvironmentPath,onClick:z,children:p?(0,X.jsx)(ne,{className:`size-3.5`,"aria-hidden":!0}):(0,X.jsx)(J,{className:`size-3.5`,"aria-hidden":!0})})]}),a.environmentAction,A.available?null:(0,X.jsx)(`p`,{className:`px-2 py-1 text-xs text-fg-muted`,children:g.unavailableEnvironment}),E&&i?.workspaceRoot?(0,X.jsx)(eo,{className:GO,to:uo(E.id),state:{forceNewChat:!0,agentId:a.agentId,temporary:a.temporary},onClick:L,children:g.newEnvironment}):null]}):(0,X.jsx)(`p`,{className:`px-2 py-2 text-xs text-fg-muted`,children:g.unavailable})]}):null]}),a.executionDeviceAction]})})})]})}var qO=`min(36dvh, 320px)`;function JO(e){return e&&Number.isFinite(e.width)&&Number.isFinite(e.height)&&e.width>0&&e.height>0?e.width/e.height:void 0}function YO(e){let t=JO(e);return t?`min(calc(100vw - 2rem), ${36*t}dvh, ${Math.min(480,320*t)}px)`:`min(320px, calc(100vw - 2rem))`}function XO(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 ZO(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 QO({conversationId:e,onFrameSizeChange:t}){let n=ZO(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=y(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`:XO(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,X.jsxs)(`section`,{ref:l,"aria-label":u?`电脑操作预览`:`Computer activity`,className:`relative w-full overflow-hidden rounded-xl bg-transparent`,style:{aspectRatio:JO(n.frameSize)??16/10,maxHeight:qO},children:[!n.hasFrame&&!f&&(0,X.jsx)(sn,{className:`absolute inset-0`}),(0,X.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,X.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`absolute left-2 top-2 z-10 max-w-[calc(100%-1rem)]`,children:(0,X.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,X.jsx)(xt,{size:14,className:`shrink-0`,"aria-hidden":!0}),p&&(0,X.jsx)(`span`,{className:`truncate`,children:p})]})}),f&&(0,X.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-surface-panel/90`,children:(0,X.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 $O(e){let t=(0,Z.c)(26),{conversationId:n}=e,{state:r}=ZO(n,!1),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(),c=y(tk),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,X.jsx)(xt,{className:`size-4 shrink-0`,"aria-hidden":!0}),t[4]=m):m=t[4];let h=c?`电脑`:`Computer`,g;t[5]===h?g=t[6]:(g=(0,X.jsx)(`span`,{className:`hidden whitespace-nowrap text-xs xl:inline`,children:h}),t[5]=h,t[6]=g);let _;t[7]!==f||t[8]!==p||t[9]!==g?(_=(0,X.jsx)(ta,{asChild:!0,children:(0,X.jsxs)(Yi,{variant:`ghost`,className:`size-8 shrink-0 gap-1.5 rounded-lg p-0 xl:w-auto xl:px-2`,title:f,"aria-label":p,children:[m,g]})}),t[7]=f,t[8]=p,t[9]=g,t[10]=_):_=t[10];let v=c?`电脑预览`:`Computer preview`,b;t[11]===o?b=t[12]:(b=YO(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,X.jsx)(QO,{conversationId:n,onFrameSizeChange:s},r.previewId),t[15]=n,t[16]=r.previewId,t[17]=C):C=t[17];let w;t[18]!==v||t[19]!==S||t[20]!==C?(w=(0,X.jsx)(Zi,{children:(0,X.jsx)(Qi,{align:`end`,sideOffset:8,collisionPadding:16,"aria-label":v,onOpenAutoFocus:ek,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]=v,t[19]=S,t[20]=C,t[21]=w):w=t[21];let T;return t[22]!==i||t[23]!==w||t[24]!==_?(T=(0,X.jsxs)($i,{open:i,onOpenChange:a,children:[_,w]}),t[22]=i,t[23]=w,t[24]=_,t[25]=T):T=t[25],T}function ek(e){return e.preventDefault()}function tk(e){return e.language===`zh`}function nk({conversationId:e,deviceName:t,zh:n}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(!1),v=_(`/api/endpoint-tools/artifact-transfers`),{data:y,isLoading:x}=bi(r?`${v}?conversationId=${encodeURIComponent(e)}`:null,e=>b(e),{shouldRetryOnError:!1}),S=y?.payload.files??[],C=y?.payload.tools??[],M=C.find(e=>e.toolName===s);return(0,X.jsxs)(j,{open:r,onOpenChange:e=>{i(e),e&&(o(``),c(``),u(``),m(!1),g(!1))},children:[(0,X.jsx)(T,{asChild:!0,children:(0,X.jsx)(Yi,{variant:`ghost`,className:`h-8 px-2 text-sm`,children:n?`传递文件`:`Transfer file`})}),(0,X.jsxs)(O,{children:[(0,X.jsx)(w,{className:`fixed inset-0 z-[120] bg-black/50`}),(0,X.jsxs)(k,{className:`fixed left-1/2 top-1/2 z-[121] flex h-[min(23rem,90dvh)] w-[min(28rem,92vw)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover`,children:[(0,X.jsx)(A,{className:`text-base font-semibold`,children:n?`向执行设备传递文件`:`Transfer file to execution device`}),(0,X.jsx)(E,{className:`mt-1 text-sm text-fg-muted`,children:t}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto py-3`,children:[x?(0,X.jsx)(sn,{className:`h-20 w-full`}):S.length&&C.length?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(pe,{value:a,onChange:o,placeholder:n?`选择源文件`:`Select source file`,options:S.map(e=>({value:e.fileId,label:`${e.name} · ${e.sourceName} · ${Math.ceil(e.size/1024)} KB`}))}),(0,X.jsx)(pe,{value:s,onChange:c,placeholder:n?`选择接收能力`:`Select receiving capability`,options:C.map(e=>({value:e.toolName,label:e.title}))})]}):(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`当前没有可传递的文件或接收能力。`:`No eligible file or receiving capability is available.`}),l?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`在两分钟内将这段请求发到当前对话。`:`Send this request in this chat within two minutes.`}),(0,X.jsx)(`textarea`,{readOnly:!0,className:`h-20 w-full resize-none rounded-md border border-edge bg-surface-inset p-2 text-xs`,value:l,"aria-label":n?`对话请求`:`Chat request`,onFocus:e=>e.currentTarget.select()})]}):null,h?(0,X.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:n?`文件授权失败,请重新选择设备或文件。`:`Unable to authorize transfer. Reselect the device or file.`}):null]}),(0,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,X.jsx)(D,{asChild:!0,children:(0,X.jsx)(Yi,{variant:`secondary`,children:n?`关闭`:`Close`})}),l?(0,X.jsx)(Yi,{onClick:async()=>{try{await navigator.clipboard.writeText(l),m(!0)}catch{m(!1)}},children:p?n?`已复制`:`Copied`:n?`复制请求`:`Copy request`}):(0,X.jsx)(Yi,{disabled:d||!M||!S.some(e=>e.fileId===a),onClick:async()=>{if(M){f(!0),g(!1);try{let t=await b(v,{method:`POST`,body:JSON.stringify({conversationId:e,fileId:a,toolName:s})}),r=JSON.stringify({[M.input]:t.payload.transferId});u(n?`请在当前执行设备调用 ${s} 处理已授权的文件,使用参数 ${r}。`:`Use ${s} on the selected execution device to process the authorized file with argument ${r}.`)}catch{g(!0)}finally{f(!1)}}},children:d?n?`授权中…`:`Authorizing…`:n?`生成一次性授权`:`Authorize one transfer`})]})]})]})]})}function rk({conversationId:e,disabled:t}){let n=y(e=>e.language)===`zh`,r=e&&/^[0-9a-f-]{36}$/i.test(e)?_(`/api/endpoint-tools/targets/${encodeURIComponent(e)}`):null,i=bi(r,async e=>{let t=await g(e);if(t.status===404||t.status===403)return null;if(!t.ok)throw Error(`Device target unavailable`);return(await t.json()).payload},{refreshInterval:5e3,shouldRetryOnError:!1}),a=bi(r?Gs():null,Ks,{refreshInterval:3e4,shouldRetryOnError:!1}),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1);if(!r)return null;let u=(a.data??[]).filter(e=>!e.principal?.revokedAt&&!e.access?.revokedAt).flatMap(e=>e.endpoints.map(t=>({value:t.endpointId,label:`${e.displayName} · ${e.platform}`}))),d=i.data,f=(a.data??[]).find(e=>e.id===d?.principalId),p=f?.endpoints.some(e=>e.endpointId===d?.endpointId&&e.connectionId===d?.connectionId),m=d&&(!p||d.expiresAt<=Date.now()),h=d?`${f?.displayName??(n?`所选设备`:`Selected device`)}${m?n?` · 需要重新选择`:` · Reselect required`:``}`:void 0;return d&&!u.some(e=>e.value===d.endpointId)&&u.push({value:d.endpointId,label:h,disabled:!0}),(0,X.jsxs)(`section`,{className:`mt-3 space-y-2 border-t border-edge-subtle px-2 pt-3`,children:[(0,X.jsx)(`h3`,{className:`text-sm text-fg-subtle`,children:n?`执行设备`:`Execution device`}),i.isLoading||a.isLoading?(0,X.jsx)(sn,{className:`h-10 w-full rounded-lg`}):(0,X.jsx)(pe,{value:d?.endpointId??``,options:u,allowEmpty:!0,emptyLabel:n?`由对话选择`:`Choose in conversation`,placeholder:n?`由对话选择`:`Choose in conversation`,title:h,selectedLabel:h,ariaLabel:n?`选择执行设备`:`Select execution device`,triggerIcon:(0,X.jsx)(xt,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),triggerClassName:`justify-start [&>span]:flex-1`,side:`bottom`,disabled:t||o||!!(a.error||i.error),onChange:async e=>{if(!o){s(!0),l(!1);try{await b(r,{method:e?`PUT`:`DELETE`,...e?{body:JSON.stringify({endpointId:e})}:{}}),await i.mutate()}catch{l(!0),await i.mutate()}finally{s(!1)}}}}),e&&d&&!m&&!t?(0,X.jsx)(nk,{conversationId:e,deviceName:f?.displayName??d.endpointId,zh:n},d.connectionId):null,c?(0,X.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:n?`无法更改设备,请先结束正在进行的操作并重试。`:`Unable to change device. Finish active operations and retry.`}):null]})}function ik(e){let t=(0,Z.c)(23),{conversationId:n}=e,{data:r}=Kc(n),i=y(ok)===`zh`,a=tl(ak),o,s;if(t[0]!==n||t[1]!==r||t[2]!==a){let e=r?el(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||zc(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=()=>Xi.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,X.jsx)(Wt,{className:`size-4`,"aria-hidden":!0}),t[10]=f):f=t[10];let p;t[11]===c?p=t[12]:(p=c&&(0,X.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,X.jsxs)(`span`,{className:`relative`,children:[f,p]}),t[13]=p,t[14]=m);let h=i?`手机`:`Phone`,g;t[15]===h?g=t[16]:(g=(0,X.jsx)(`span`,{className:`text-xs`,children:h}),t[15]=h,t[16]=g);let _;return t[17]!==g||t[18]!==l||t[19]!==u||t[20]!==d||t[21]!==m?(_=(0,X.jsxs)(Yi,{variant:`ghost`,className:`min-h-10 gap-1.5 px-2`,title:l,"aria-label":u,onClick:d,children:[m,g]}),t[17]=g,t[18]=l,t[19]=u,t[20]=d,t[21]=m,t[22]=_):_=t[22],_}function ak(e){return e.seen}function ok(e){return e.language}function sk(e){let t=(0,Z.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=y(dk),f;t[0]===d?f=t[1]:(f=C(d),t[0]=d,t[1]=f);let p=f,m=lm(uk),h;t[2]===n?h=t[3]:(h=e=>e.panes[n??`new`]?.open===!0,t[2]=n,t[3]=h);let g=Xi(h),[_,v]=(0,Q.useState)(null),b,x;t[4]!==p.chat.workingDirectory.notSet||t[5]!==i?(b=i?.trim()??``,x=b?go(b):p.chat.workingDirectory.notSet,t[4]=p.chat.workingDirectory.notSet,t[5]=i,t[6]=b,t[7]=x):(b=t[6],x=t[7]);let S=x,T;t[8]===c?T=t[9]:(T=async e=>{try{await c(e)}catch(e){let t=e;v(t instanceof Error?t.message:String(t))}},t[8]=c,t[9]=T);let D=T,M;t[10]!==D||t[11]!==b?(M={initialPath:b,onPicked:D},t[10]=D,t[11]=b,t[12]=M):M=t[12];let N=_o(M),P=o||!u||N.picking,F;t[13]!==n||t[14]!==m?(F=()=>{let e=Xi.getState(),t=n??`new`;e.setScope(t);let r=e.panes[t]?.tabs.find(lk);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]!==g?(L=l?null:(0,X.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`,g&&`bg-surface-hover text-fg`),title:d===`zh`?`打开工具`:`Open workspace tools`,"aria-label":d===`zh`?`打开工具`:`Open workspace tools`,"aria-pressed":g,"aria-controls":`app-workspace-panel`,"data-workspace-trigger":!0,onClick:I,children:(0,X.jsx)(pc,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0})}),t[16]=l,t[17]=d,t[18]=I,t[19]=g,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]!==b||t[26]!==P||t[27]!==S?(R=l&&a?(0,X.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}: ${b||S}`,"aria-label":p.chat.workingDirectory.chooseFolder,onClick:N.pick,children:[(0,X.jsx)(oe,{className:`mr-2 size-4`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.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]=b,t[26]=P,t[27]=S,t[28]=R):R=t[28];let z;t[29]!==R||t[30]!==L?(z=(0,X.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]!==b?(B=l&&!N.hasNativePicker?(0,X.jsx)(se,{open:N.modalOpen,onOpenChange:N.setModalOpen,initialAbsolutePath:b||void 0,onConfirm:N.confirmPick,wd:p.chat.workingDirectory}):null,t[32]=l,t[33]=N,t[34]=p.chat.workingDirectory,t[35]=b,t[36]=B):B=t[36];let V=_!==null,H;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(H=e=>{e||v(null)},t[37]=H):H=t[37];let U;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,X.jsx)(w,{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,X.jsx)(A,{className:`text-base font-semibold text-fg`,children:p.chat.workingDirectory.applyErrorTitle}),t[39]=p.chat.workingDirectory.applyErrorTitle,t[40]=W);let ee;t[41]===_?ee=t[42]:(ee=_?(0,X.jsx)(E,{className:`mt-2 whitespace-pre-wrap text-sm leading-relaxed text-fg-muted`,children:_}):null,t[41]=_,t[42]=ee);let te;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(te=()=>v(null),t[43]=te):te=t[43];let ne;t[44]===p.chat.workingDirectory.applyErrorClose?ne=t[45]:(ne=(0,X.jsx)(`div`,{className:`mt-4 flex justify-end border-t border-edge-subtle pt-3`,children:(0,X.jsx)(Yi,{type:`button`,onClick:te,children:p.chat.workingDirectory.applyErrorClose})}),t[44]=p.chat.workingDirectory.applyErrorClose,t[45]=ne);let re;t[46]!==W||t[47]!==ee||t[48]!==ne?(re=(0,X.jsxs)(O,{children:[U,(0,X.jsxs)(k,{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:ck,children:[W,ee,ne]})]}),t[46]=W,t[47]=ee,t[48]=ne,t[49]=re):re=t[49];let ie;t[50]!==V||t[51]!==re?(ie=(0,X.jsx)(j,{open:V,onOpenChange:H,children:re}),t[50]=V,t[51]=re,t[52]=ie):ie=t[52];let ae;return t[53]!==z||t[54]!==B||t[55]!==ie?(ae=(0,X.jsxs)(X.Fragment,{children:[z,B,ie]}),t[53]=z,t[54]=B,t[55]=ie,t[56]=ae):ae=t[56],ae}function ck(e){return e.preventDefault()}function lk(e){return e.kind===`home`}function uk(e){return e.openForSession}function dk(e){return e.language}function fk(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 pk({conversationId:e,dialogOpen:t,onDialogOpenChange:n,hideTrigger:r=!1,returnFocusRef:i}){let a=y(e=>e.language),o=a===`zh`?hk:gk,[s,c]=(0,Q.useState)(!1),l=t??s,u=e=>{c(e),n?.(e)},[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(864e5),[S,C]=(0,Q.useState)(null),[M,N]=(0,Q.useState)(``),[P,F]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)([]),[R,z]=(0,Q.useState)(`hosted`),[B,V]=(0,Q.useState)(!1),[H,U]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(!l||d||p)return;let t=!1;return g(!0),v(null),Promise.all([No(e),Lo(e),Mo()]).then(async([n,r,i])=>{if(t)return;f(n),V(i);let a=i?await Ro().catch(()=>null):null;if(t)return;U(a?.publishing.allowed===!0);let o=i?await zo(e).catch(()=>[]):[];if(t)return;let s=[...o,...r].find(e=>!e.revoked&&!e.expired);s&&m(s)}).catch(e=>{t||v(e instanceof Error?e.message:String(e))}).finally(()=>{t||g(!1)}),()=>{t=!0}},[l,d,p,e]);let W=()=>{f(null),m(null),v(null),g(!1),N(``),F(!1),L([]),U(!1)},ee=async()=>{if(!(!d||h)){g(!0),v(null);try{m(await(R===`hosted`?Io:Fo)(e,{expectedTranscriptId:d.transcriptId,expectedCutoffSeq:d.cutoffSeq,expectedMetadataUpdatedAt:d.metadataUpdatedAt,ttlMs:b,maxViews:S,description:M.trim()||void 0,includeToolActivities:P,attachmentIds:I}))}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(!1)}}},te=async()=>{if(!(!p||h)){g(!0),v(null);try{let t=await No(e);f(t);let n=p.delivery===`hosted`?Po:Ao;m(await n(e,p.id,{expectedTranscriptId:t.transcriptId,expectedCutoffSeq:t.cutoffSeq,expectedMetadataUpdatedAt:t.metadataUpdatedAt}))}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(!1)}}},ne=async()=>{if(!(!p||h)){g(!0),v(null);try{p.delivery===`hosted`?await Bo(e,p.id):await jo(p.id),u(!1),W()}catch(e){v(e instanceof Error?e.message:String(e)),g(!1)}}};return(0,X.jsxs)(j,{open:l,onOpenChange:e=>{u(e),e||W()},children:[r?null:(0,X.jsx)(T,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:`rounded-md p-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,title:o.share,"aria-label":o.share,children:(0,X.jsx)(lc,{className:`size-4`})})}),(0,X.jsxs)(O,{children:[(0,X.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),(0,X.jsxs)(k,{onCloseAutoFocus:e=>{!r||!i?.current||(e.preventDefault(),i.current.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,X.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(A,{className:`text-base font-semibold text-fg`,children:p?o.created:o.title}),(0,X.jsx)(E,{className:`mt-0.5 text-xs text-fg-muted`,children:p?o.createdHint:o.hint})]}),(0,X.jsx)(D,{asChild:!0,children:(0,X.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":o.close,children:(0,X.jsx)(an,{className:`size-4`})})})]}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:[h&&!d&&!p?(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,X.jsx)(qe,{className:`size-4 animate-spin`}),o.loading]}):p?(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:p.fileName}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o.snapshotMessages.replace(`{{count}}`,String(p.messageCount))}),(0,X.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[p.delivery===`hosted`?o.hosted:o.local,` · `,o.revision.replace(`{{revision}}`,String(p.snapshotRevision)),` · `,o.sharedAttachments.replace(`{{count}}`,String(p.attachmentCount))]})]}),(0,X.jsx)(tn,{shareUrl:p.shareUrl,lanUrl:p.lanUrl,reachability:p.reachability}),(0,X.jsx)(nn,{reachability:p.reachability,reachabilityHint:p.reachabilityHint}),(0,X.jsxs)(`a`,{href:p.shareUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-sm font-medium text-accent hover:underline`,children:[o.open,(0,X.jsx)(Ce,{className:`size-3.5`})]})]}):d?(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-inset p-3`,children:[(0,X.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:d.title}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o.snapshotMessages.replace(`{{count}}`,String(d.messageCount))}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:new Date(d.snapshotAt).toLocaleString(a===`zh`?`zh-CN`:`en-US`)})]}),(0,X.jsxs)(`details`,{className:`rounded-lg border border-edge`,children:[(0,X.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:o.reviewContent}),(0,X.jsx)(`div`,{className:`max-h-64 space-y-3 overflow-y-auto border-t border-edge p-3`,children:d.messages.map(e=>(0,X.jsxs)(`div`,{className:`rounded-lg bg-surface-inset px-3 py-2`,children:[(0,X.jsx)(`p`,{className:`mb-1 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:e.role===`user`?o.you:o.assistant}),(0,X.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm leading-6 text-fg`,children:e.markdown})]},e.id))})]}),(0,X.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,X.jsx)(Ut,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:o.scope})]}),(0,X.jsxs)(`label`,{className:`block space-y-1.5 text-xs font-medium text-fg`,children:[(0,X.jsx)(`span`,{children:o.delivery}),(0,X.jsxs)(ue,{value:R,disabled:h,onChange:e=>z(e.target.value),children:[(0,X.jsx)(fe,{value:`hosted`,children:o.hosted}),(0,X.jsx)(fe,{value:`local`,children:o.local})]})]}),R===`hosted`&&!B?(0,X.jsx)(Rs,{providerId:`xopc-share`,displayName:o.hosted,connected:!1,onConnected:()=>{V(!0),Ro().then(e=>U(e.publishing.allowed)).catch(()=>U(!1))}}):null,R===`hosted`&&B&&!H?(0,X.jsx)(`p`,{className:`rounded-lg border border-warning/30 bg-warning-soft px-3 py-2 text-xs text-warning`,children:o.hostedDisabled}):null,d.toolActivities.length?(0,X.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,X.jsx)(`input`,{type:`checkbox`,checked:P,disabled:h,onChange:e=>F(e.target.checked),className:`mt-0.5 size-4 rounded border-edge`}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`block font-medium`,children:o.includeTools.replace(`{{count}}`,String(d.toolActivities.length))}),(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-muted`,children:o.toolDisclosure})]})]}):null,d.attachmentCandidates.length?(0,X.jsxs)(`fieldset`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2.5`,children:[(0,X.jsx)(`legend`,{className:`px-1 text-xs font-medium text-fg`,children:o.attachments}),(0,X.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:o.attachmentDisclosure}),(0,X.jsx)(`div`,{className:`space-y-2`,children:d.attachmentCandidates.map(e=>(0,X.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:I.includes(e.id),disabled:h,onChange:t=>L(n=>t.target.checked?[...n,e.id]:n.filter(t=>t!==e.id)),className:`size-4 rounded border-edge`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.fileName}),(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:mk(e.size)})]},e.id))})]}):null,(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,X.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg`,children:[(0,X.jsx)(`span`,{children:o.ttl}),(0,X.jsxs)(ue,{value:b,disabled:h,onChange:e=>x(Number(e.target.value)),children:[(0,X.jsx)(fe,{value:36e5,children:o.oneHour}),(0,X.jsx)(fe,{value:864e5,children:o.oneDay}),(0,X.jsx)(fe,{value:6048e5,children:o.sevenDays}),(0,X.jsx)(fe,{value:2592e6,children:o.thirtyDays})]})]}),(0,X.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg`,children:[(0,X.jsx)(`span`,{children:o.maxViews}),(0,X.jsxs)(ue,{value:S??`unlimited`,disabled:h,onChange:e=>C(e.target.value===`unlimited`?null:Number(e.target.value)),children:[(0,X.jsx)(fe,{value:`unlimited`,children:o.unlimited}),(0,X.jsx)(fe,{value:1,children:`1`}),(0,X.jsx)(fe,{value:10,children:`10`}),(0,X.jsx)(fe,{value:50,children:`50`})]})]})]}),(0,X.jsxs)(`label`,{className:`block space-y-1.5 text-xs font-medium text-fg`,children:[(0,X.jsx)(`span`,{children:o.description}),(0,X.jsx)(`input`,{value:M,disabled:h,onChange:e=>N(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,X.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-300`,children:o.publicWarning})]}):null,_?(0,X.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:_}):null]}),(0,X.jsx)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-edge bg-surface-overlay px-4 py-3`,children:p?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Yi,{type:`button`,variant:`ghost`,disabled:h,onClick:()=>m(null),children:o.newShare}),(0,X.jsxs)(Yi,{type:`button`,variant:`ghost`,disabled:h,onClick:()=>void ne(),children:[(0,X.jsx)(Xt,{className:`size-4`}),o.revoke]}),(0,X.jsxs)(Yi,{type:`button`,disabled:h||p.delivery===`hosted`&&!H,onClick:()=>void te(),children:[h?(0,X.jsx)(qe,{className:`size-4 animate-spin`}):(0,X.jsx)(It,{className:`size-4`}),o.refresh]})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(D,{asChild:!0,children:(0,X.jsx)(Yi,{type:`button`,variant:`ghost`,children:o.cancel})}),(0,X.jsxs)(Yi,{type:`button`,disabled:!d||h||d.messageCount===0||R===`hosted`&&(!B||!H),onClick:()=>void ee(),children:[h?(0,X.jsx)(qe,{className:`size-4 animate-spin`}):null,o.create]})]})})]})]})]})}function mk(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var hk={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:`助手`},gk={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`},_k=`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`;function vk({title:e,centered:t,conversationId:n,pinned:r,hasMessages:i,onFindOpen:a}){let o=y(e=>e.language),s=C(o),c=(0,Q.useRef)(null),l=(0,Q.useRef)(null),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(!1),g=!!(n&&r!==void 0),_=!!(n&&i),v=r?Nt:Mt,b=async()=>{if(!(!n||m)){h(!0);try{await(r?Dn:Tn)(n)}catch{Ga(`warning`,s.sessions.pinFailed)}finally{h(!1)}}};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`h1`,{className:Y(`flex min-w-0 flex-1 text-[0.9375rem] font-semibold leading-5 tracking-tight text-fg`,t&&`md:justify-center`),children:(0,X.jsxs)(Ho,{modal:!1,children:[(0,X.jsx)(Uo,{asChild:!0,children:(0,X.jsxs)(`button`,{ref:c,type:`button`,title:e,className:Y(`inline-flex h-8 min-w-0 max-w-full items-center gap-1.5 rounded-lg px-2 text-left transition-colors`,`hover:bg-surface-hover data-[state=open]:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,qa),children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e}),(0,X.jsx)(re,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0})]})}),(0,X.jsx)(Wo,{children:(0,X.jsxs)(Ko,{onCloseAutoFocus:e=>{let t=l.current;t&&(e.preventDefault(),l.current=null,c.current?.focus(),t())},align:`start`,sideOffset:4,collisionPadding: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:[g?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Go,{onSelect:()=>{l.current=()=>d(!0)},className:_k,children:[(0,X.jsx)(jt,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),s.sidebar.taskRename]}),(0,X.jsxs)(Go,{disabled:m,onSelect:()=>void b(),className:_k,children:[(0,X.jsx)(v,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),r?s.sessions.unpin:s.sessions.pin]}),(0,X.jsx)(qo,{className:`my-1 h-px bg-edge-subtle`})]}):null,(0,X.jsxs)(Go,{disabled:!i||!a,onSelect:()=>{l.current=a??null},className:_k,children:[(0,X.jsx)(zt,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`flex-1`,children:s.chat.find.input}),(0,X.jsx)(`span`,{className:`text-xs text-fg-muted`,children:window.electronAPI?.platform===`darwin`?`⌘F`:`Ctrl+F`})]}),(0,X.jsxs)(Go,{disabled:!_,onSelect:()=>{l.current=()=>p(!0)},className:_k,children:[(0,X.jsx)(Ht,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),o===`zh`?`分享对话`:`Share conversation`]})]})})]})}),n&&g&&u?(0,X.jsx)(Rp,{conversationId:n,initialName:e,onClose:()=>d(!1),returnFocusRef:c}):null,n&&i?(0,X.jsx)(pk,{conversationId:n,hideTrigger:!0,dialogOpen:f,onDialogOpenChange:p,returnFocusRef:c}):null]})}var yk=`(max-width: 767px)`,bk=(0,Q.memo)(function({inline:e=!1,chatHeadline:t,chatAgents:n,showChatAgentSelector:r,chatAgentId:i,onChatAgentChange:a,chatAgentDisabled:o,conversationId:s,hasMessages:c=!1,pinned:l,workspacePath:u,userContextMode:d=`enabled`,canChangeWorkspace:f=!1,workspaceDisabled:p=!1,onWorkspaceChange:h,prepareTerminalSession:g,terminalDisabled:_=!1,showContextControls:v=!0,onFindOpen:b,projectId:x,context:S}){let w=y(e=>e.language),{conversationId:T}=m(),E=T&&T!==`new`?decodeURIComponent(T):null,D=s?.trim()||E,{data:O,error:k,mutate:A}=fp(D??null,!1),j=!k&&(!O||!!O.environment?.available),M=Xi(e=>e.panes[D??`new`]?.open===!0),N=C(w),P=wp(e=>e.collapsed),F=WT(e=>e.setOpen),I=Is(e=>e.toggle),L=Is(e=>e.open),[R,z]=(0,Q.useState)(!1),B=Tp(e=>e.mobileNavOpen),V=Qa(e=>e.setPageHeader),H=Qa(e=>e.clearPageHeader),U=window.electronAPI?.platform,W=!!(v&&window.electronAPI?.terminal&&(D||g)),ee=(0,Q.useCallback)(()=>{if(!(!W||_||R)){if(D){I(D);return}g&&(z(!0),g().then(e=>{e&&L(e)}).finally(()=>z(!1)))}},[D,L,g,W,_,R,I]),te=(0,Q.useCallback)(()=>{if(!D||!c)return;let e=Xi.getState().panes[D],t=WT.getState().pendingCreate?.parentConversationId===D||!!WT.getState().creatingRequests[D],n=e?.open===!0&&(e.activeId?.startsWith(`side:`)===!0||t);F(D,!n)},[D,c,F]),ne=zs(yk),re=gp({runtime:hp(),sidebarCollapsed:P,mobileNavOpen:B}),ie=ne?!B:re.collapsedNewChatVisible;(0,Q.useLayoutEffect)(()=>{if(!e)return()=>H()},[H,e]),(0,Q.useEffect)(()=>{if(!W)return;let e=e=>{fk(e,U)&&(e.preventDefault(),ee())};return window.addEventListener(`keydown`,e),window.addEventListener(`workspace-open-terminal`,ee),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`workspace-open-terminal`,ee)}},[ee,W,U]),(0,Q.useEffect)(()=>{if(!D||!c)return;let e=e=>{qs(e,U)&&(e.preventDefault(),te())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[D,te,c,U]);let ae=(0,Q.useMemo)(()=>({startExtra:ie?(0,X.jsx)(eo,{to:uo(x),state:{forceNewChat:!0,agentId:i,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`,qa),title:N.sidebar.newTask,children:(0,X.jsx)(Ft,{className:`size-4 shrink-0 text-accent-fg`,strokeWidth:2,"aria-hidden":!0})}):null,main:(0,X.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,X.jsx)(vk,{title:t,centered:ie,conversationId:D,hasMessages:c,pinned:l,onFindOpen:b},D)}),end:(0,X.jsxs)(`div`,{className:Y(`flex min-w-0 max-w-[min(32rem,calc(100vw-8rem))] shrink-0 items-center justify-end gap-2`,qa),children:[r?(0,X.jsx)(zO,{items:n,value:i,disabled:o,placeholder:N.chat.agentPlaceholder,newChatLabel:D?N.chat.agentStartNewChat:void 0,searchPlaceholder:N.chat.agentSearchPlaceholder,noMatches:N.chat.agentNoMatches,compact:!0,contentSide:`bottom`,contentAlign:`end`,onChange:a}):null,v?(0,X.jsx)(KO,{...S,agentId:i,executionDeviceAction:D?(0,X.jsx)(rk,{conversationId:D,disabled:o}):null,environmentAction:f&&h?(0,X.jsx)(sk,{directoryOnly:!0,conversationId:D,workspacePath:D?u:S?.project?.workspaceRoot,available:j,canChangeWorkspace:!0,disabled:p,onWorkspaceChange:async e=>{await h(e),await A()}}):null,temporary:d===`temporary`,conversationId:D??null},`context:${D??S?.project?.id??`new`}`):null,v&&!M?(0,X.jsx)(`span`,{"aria-hidden":!0,className:`mx-0.5 h-6 w-px shrink-0 bg-edge-subtle`}):null,D?(0,X.jsx)($O,{conversationId:D},D):null,D?(0,X.jsx)(ik,{conversationId:D}):null,v&&!M?(0,X.jsx)(sk,{conversationId:D,workspacePath:D?u:S?.project?.workspaceRoot,available:j,canChangeWorkspace:!1,disabled:p,onWorkspaceChange:async e=>{await h?.(e),await A()}},`workspace:${D??x}`):null]})}),[t,n,r,i,a,o,ie,N.chat.agentPlaceholder,N.chat.agentSearchPlaceholder,N.chat.agentNoMatches,N.chat.terminal.open,N.sidebar.newTask,x,S,W,_,v,M,R,D,c,l,b,F,u,j,A,d,f,p,h,ee,te]);return(0,Q.useLayoutEffect)(()=>{e||V(ae)},[ae,e,V]),e?(0,X.jsxs)(`header`,{"aria-label":w===`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,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:ae.main}),ae.end]}):null}),xk=(0,Q.memo)(function(){let e=(0,Z.c)(19),t=y(Sk),n;e[0]===t?n=e[1]:(n=C(t),e[0]=t,e[1]=n);let r=n.chat.runRecovery,i=Ui(Ck),a=Ui(wk),[o,s]=(0,Q.useState)(!1),c=i===`connecting`||i===`reconnecting`,l,u;if(e[2]===c?(l=e[3],u=e[4]):(l=()=>{if(!c)return;let e=window.setTimeout(()=>s(!0),1500);return()=>{window.clearTimeout(e),s(!1)}},u=[c],e[2]=c,e[3]=l,e[4]=u),(0,Q.useEffect)(l,u),i!==`error`&&!(c&&o))return null;let d=i===`error`,f=d?en:It,p=`size-3.5 shrink-0 ${c?`motion-safe:animate-spin`:``}`,m;e[5]!==f||e[6]!==p?(m=(0,X.jsx)(f,{className:p,"aria-hidden":!0}),e[5]=f,e[6]=p,e[7]=m):m=e[7];let h=d?r.connectionFailed:i===`connecting`?r.connecting:r.reconnecting,g;e[8]===h?g=e[9]:(g=(0,X.jsx)(`span`,{className:`min-w-0 flex-1`,children:h}),e[8]=h,e[9]=g);let _;e[10]!==a||e[11]!==d||e[12]!==r.details||e[13]!==r.reconnect?(_=d?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,className:`min-h-9 rounded-md border border-edge px-3 text-xs text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:Tk,children:r.reconnect}),a?(0,X.jsxs)(`details`,{className:`w-full min-w-0`,children:[(0,X.jsx)(`summary`,{className:`w-fit cursor-pointer rounded-md py-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:r.details}),(0,X.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words rounded-md bg-surface-inset p-2`,children:zi(a)})]}):null]}):null,e[10]=a,e[11]=d,e[12]=r.details,e[13]=r.reconnect,e[14]=_):_=e[14];let v;return e[15]!==m||e[16]!==g||e[17]!==_?(v=(0,X.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex flex-wrap items-center gap-2 border-b border-edge-subtle bg-surface-panel px-4 py-2 text-xs text-fg-muted`,children:[m,g,_]}),e[15]=m,e[16]=g,e[17]=_,e[18]=v):v=e[18],v});function Sk(e){return e.language}function Ck(e){return e.connectionState}function wk(e){return e.error}function Tk(){return Hi()}function Ek(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function Dk(e){let t=(0,Z.c)(4),{status:n}=e;if(n===`completed`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.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,X.jsx)(ne,{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,X.jsx)(me,{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,X.jsx)(Ys,{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,X.jsx)(ge,{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 Ok(e,t){return e?`${Ek(e.files.length===1?t.filesChangedOne:t.filesChangedOther,{count:e.files.length})} · +${e.added} -${e.removed}`:null}function kk(e){let t=(0,Z.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(Mk),t[0]=n.items,t[1]=s);let c=s,l=n.items.every(jk),u;t[2]!==a.completedProgress||t[3]!==n.completedCount||t[4]!==n.totalCount?(u=Ek(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=Ek(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=Ok(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`,Pa.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,X.jsx)(ne,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:2,"aria-hidden":!0}):o?(0,X.jsx)(me,{className:`size-4 shrink-0 text-accent`,strokeWidth:2,"aria-hidden":!0}):(0,X.jsx)(Ge,{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,X.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,X.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,X.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,X.jsx)(re,{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,X.jsx)(ta,{asChild:!0,children:(0,X.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,X.jsx)(Ge,{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,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[E,(0,X.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,X.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,X.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,X.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,X.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(Ak),t[47]=n.items,t[48]=N);let P;t[49]!==a.heading||t[50]!==N?(P=(0,X.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,X.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,X.jsx)(Zi,{children:(0,X.jsxs)(Qi,{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,X.jsx)(`div`,{className:`mx-auto flex w-full max-w-80 justify-center pb-2 pt-1`,children:(0,X.jsxs)($i,{children:[T,I]})}),t[58]=T,t[59]=I,t[60]=L):L=t[60],L}function Ak(e){return(0,X.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,X.jsx)(Dk,{status:e.status}),(0,X.jsx)(`span`,{className:`min-w-0 [overflow-wrap:anywhere]`,children:e.title})]},e.id)}function jk(e){return e.status===`completed`||e.status===`cancelled`}function Mk(e){return e.status===`completed`}function Nk(e){let t=zk(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 Pk=new Set([`pending`,`in_progress`,`completed`,`cancelled`]);function Fk(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function Ik(e){return e.trim().toLowerCase().replace(/-/g,`_`).split(`__`).at(-1)??``}function Lk(e){let t=Fk(e.details);return t&&Object.keys(t).length>0?t:Ba(e.result).details}function Rk(e){let t=typeof e==`string`?e.trim():``;return Pk.has(t)?t:null}function zk(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 Bk(e){if(!Array.isArray(e.plan))return null;let t=e.plan.flatMap((e,t)=>{let n=Fk(e),r=typeof n?.id==`string`&&n.id.trim()?n.id.trim():`update-plan-${t}`,i=typeof n?.step==`string`?n.step.trim():``,a=Rk(n?.status);return i&&a?[{id:r,title:i,status:a}]:[]});return zk(`update_plan`,typeof e.explanation==`string`&&e.explanation.trim()?e.explanation.trim():void 0,t)}function Vk(e){return Array.isArray(e.items)?zk(`todo`,void 0,e.items.flatMap((e,t)=>{let n=Fk(e),r=typeof n?.id==`string`&&n.id.trim()?n.id.trim():`todo-${t}`,i=typeof n?.content==`string`?n.content.trim():``,a=Rk(n?.status);return i&&a?[{id:r,title:i,status:a}]:[]})):null}function Hk(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=Ik(n.name),i=Lk(n);if(i){if(r===`update_plan`)return{found:!0,plan:Bk(i)};if(r===`todo`)return{found:!0,plan:Vk(i)}}}return{found:!1,plan:null}}function Uk(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:0}function Wk(e){let t=new Set,n=0,r=0;for(let i of e){if(i.type!==`tool_use`||i.status===`error`||Ik(i.name)!==`apply_patch`)continue;let e=Lk(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=Fk(n),r=typeof e?.moveTo==`string`?e.moveTo:typeof e?.path==`string`?e.path:``;r.trim()&&t.add(r.trim())}n+=Uk(e.added),r+=Uk(e.removed)}}return t.size>0||n>0||r>0?{files:[...t],added:n,removed:r}:null}function Gk(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.role!==`assistant`)continue;let r=Hk(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:Wk(i)}}return null}function Kk(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 Gk(e.slice(n+1))}function qk(e){let{details:t,text:n}=Ba(e.result);if(typeof t?.id==`string`)return t.id;let r=e.details;if(typeof r?.id==`string`)return r.id;if(n.trimStart().startsWith(`{`))try{let e=JSON.parse(n);if(typeof e?.id==`string`)return e.id}catch{}}function Jk(e,t){let n=new Map;return e.forEach((e,r)=>{if(e.role===`assistant`)for(let i of e.content){if(i.type!==`tool_use`||i.name!==t||i.status===`error`)continue;let e=qk(i);e&&(t===`video_draft`||!n.has(e))&&n.set(e,r)}}),n}var Yk={zh:{play:`播放`,pause:`暂停`,retry:`重试播放`,loading:`正在加载音频`,error:`音频暂时无法播放,请重试。`,seek:`播放进度`,lyrics:`歌词`,volume:`音量`,mute:`静音`,unmute:`取消静音`,download:`下载音频`},en:{play:`Play`,pause:`Pause`,retry:`Retry playback`,loading:`Loading audio`,error:`Audio could not play. Try again.`,seek:`Playback position`,lyrics:`Lyrics`,volume:`Volume`,mute:`Mute`,unmute:`Unmute`,download:`Download audio`}};function Xk({src:e,title:t,durationMs:n,lyrics:r,lyricsOpen:i,onToggleLyrics:a,language:o}){let s=Yk[o],c=(0,Q.useId)(),{element:l,hostRef:u}=wt({kind:`audio`,src:e,title:t}),{position:d,duration:f,muted:p,volume:m,starting:h,playing:g,failed:_,toggle:v,seek:y}=Tt(l),b=f||(n&&n>0?Math.round(n/1e3):0),x=Math.min(d,b),S=g||h,C=!!r?.trim(),w=_?Lt:h?qe:S?At:Pt,T=p||m===0?gc:$t;return(0,X.jsxs)(`div`,{role:`group`,"aria-label":t,children:[(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsxs)(`div`,{className:`grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-1.5 text-xs tabular-nums text-fg-muted`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`min-w-[3.5ch]`,children:Et(x)}),(0,X.jsxs)(`div`,{className:`relative flex h-6 items-center`,children:[(0,X.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-1.5 h-1 overflow-hidden rounded-full bg-edge-strong`,children:(0,X.jsx)(`div`,{className:`h-full rounded-full bg-fg`,style:{width:`${b?x/b*100:0}%`}})}),(0,X.jsx)(`input`,{type:`range`,min:0,max:b||1,step:.1,value:x,disabled:!f||_,"aria-label":s.seek,"aria-valuetext":`${Et(x)} / ${b?Et(b):`—`}`,onChange:e=>y(e.currentTarget.valueAsNumber),className:`relative block h-full w-full cursor-pointer appearance-none rounded-md bg-transparent focus-visible:outline-2 focus-visible:outline-accent disabled:cursor-default disabled:opacity-0 [&::-webkit-slider-thumb]:size-3 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-fg [&::-moz-range-thumb]:size-3 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-0 [&::-moz-range-thumb]:bg-fg`})]}),(0,X.jsx)(`span`,{"aria-hidden":!0,className:`min-w-[3.5ch] text-end`,children:b?Et(b):`—`})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(Yi,{variant:`ghost`,className:`size-11 shrink-0 rounded-full bg-fg p-0 text-surface-panel hover:bg-fg/85 hover:text-surface-panel`,onClick:v,"aria-label":_?s.retry:S?s.pause:s.play,children:(0,X.jsx)(w,{size:20,"aria-hidden":!0,className:Y(h&&`motion-safe:animate-spin`,!S&&!_&&`ms-0.5 fill-current`,g&&`fill-current`)})}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:[C&&(0,X.jsxs)(Yi,{variant:`ghost`,className:Y(`min-h-11 gap-1.5 rounded-full px-2.5 text-xs`,i&&`bg-accent-soft text-accent-fg hover:text-accent-fg`),"aria-controls":`${c}-lyrics`,"aria-expanded":i,onClick:a,children:[(0,X.jsx)(cc,{size:17,"aria-hidden":!0}),s.lyrics]}),(0,X.jsx)(Yi,{asChild:!0,variant:`ghost`,className:`size-11 rounded-full p-0`,children:(0,X.jsx)(`a`,{href:`${e}?download=1`,download:`music.mp3`,"aria-label":s.download,title:s.download,children:(0,X.jsx)(xe,{size:18,"aria-hidden":!0})})}),(0,X.jsxs)($i,{children:[(0,X.jsx)(ta,{asChild:!0,children:(0,X.jsx)(Yi,{variant:`ghost`,className:`size-11 rounded-full p-0`,"aria-label":s.volume,title:s.volume,children:(0,X.jsx)(T,{size:18,"aria-hidden":!0})})}),(0,X.jsx)(Zi,{children:(0,X.jsxs)(Qi,{side:`top`,align:`end`,sideOffset:6,"aria-label":s.volume,className:`z-50 flex items-center gap-2 rounded-xl border border-edge bg-surface-overlay p-2 shadow-float`,children:[(0,X.jsx)(Yi,{variant:`ghost`,className:`size-11 rounded-full p-0`,"aria-label":p?s.unmute:s.mute,onClick:()=>{l&&(l.muted=!l.muted)},children:(0,X.jsx)(T,{size:17,"aria-hidden":!0})}),(0,X.jsx)(`input`,{type:`range`,min:0,max:100,step:1,value:p?0:Math.round(m*100),"aria-label":s.volume,className:`h-8 w-28 cursor-pointer accent-accent focus-visible:outline-2 focus-visible:outline-accent`,onChange:e=>{l&&(l.volume=e.currentTarget.valueAsNumber/100,l.muted=!1)}})]})})]})]})]})]}),h&&(0,X.jsx)(`p`,{role:`status`,className:`sr-only`,children:s.loading}),_&&(0,X.jsx)(`p`,{role:`alert`,className:`px-3 pb-3 text-xs text-fg-muted`,children:s.error}),C&&(0,X.jsx)(`div`,{id:`${c}-lyrics`,hidden:!i,role:`region`,"aria-label":s.lyrics,tabIndex:0,className:`mt-2 max-h-[clamp(5rem,calc(100dvh-15rem),17rem)] overflow-y-auto overscroll-y-auto rounded-xl border border-edge bg-surface-inset px-4 py-5 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-accent sm:px-5`,children:i&&(0,X.jsx)(`p`,{className:`whitespace-pre-wrap wrap-anywhere text-[0.9375rem] leading-6 font-normal text-fg`,children:r})}),(0,X.jsx)(`div`,{ref:u,hidden:!0})]})}var Zk={zh:{provider_rate_limited:`音乐服务暂时拒绝了请求。请稍后再试,若持续出现,请检查服务商额度或请求限制。`,provider_rejected:`音乐服务拒绝了请求。请检查「模型与能力」中的音乐配置后再试。`,provider_failed:`音乐服务未能完成生成。你可以在对话中重新发起创作。`,credentials_missing:`请恢复原音乐模型的配置和 API Key,任务会自动继续。`,status_retrying:`暂时无法查询进度,正在重新查询同一个任务。`,audio_retrying:`暂时无法保存音频,正在重新下载同一份成品。`,expired:`任务或音频下载已过期。你可以在对话中重新发起创作。`},en:{provider_rate_limited:`The music service rejected the request. Try again later. If it persists, check the provider’s quota or request limits.`,provider_rejected:`The music service rejected the request. Check the music configuration in Models and capabilities before trying again.`,provider_failed:`The music service could not finish generation. You can start a new request in chat.`,credentials_missing:`Restore the original music model settings and API key to resume this task.`,status_retrying:`Progress is temporarily unavailable. We’re checking the same task again.`,audio_retrying:`The audio could not be saved. We’re downloading the same result again.`,expired:`The task or audio download has expired. You can start a new request in chat.`}},Qk={zh:{song:`歌曲`,instrumental:`纯音乐`,details:`创作详情`,prompt:`提示词`,model:`模型`,status:{queued:`排队中`,submitting:`正在提交`,submitted:`供应商排队中`,running:`生成中`,saving:`正在保存`,completed:`可播放`,failed:`生成失败`,submission_unknown:`提交结果待确认`},unknown:`暂时无法确认音乐服务是否已接收请求。请先核对服务商的任务或账单,再决定是否重新生成。`},en:{song:`Song`,instrumental:`Instrumental`,details:`Creation details`,prompt:`Prompt`,model:`Model`,status:{queued:`Queued`,submitting:`Submitting`,submitted:`Queued at provider`,running:`Generating`,saving:`Saving`,completed:`Ready`,failed:`Generation failed`,submission_unknown:`Submission unconfirmed`},unknown:`The music service may have received the request. Check the provider’s tasks or billing before generating again.`}};function $k(e,t,n,r){let i=(0,Z.c)(23),a;i[0]===e?a=i[1]:(a=e?_(`/api/music-generation/sessions/${encodeURIComponent(e)}/jobs`):null,i[0]=e,i[1]=a);let o=a,{data:s,mutate:c}=bi(o,b),l;i[2]===s?.jobs?l=i[3]:(l=s?.jobs.some(eA)??!1,i[2]=s?.jobs,i[3]=l);let u=l,d,f;i[4]!==n||i[5]!==c||i[6]!==o?(d=()=>{!n&&o&&c()},f=[n,c,o],i[4]=n,i[5]=c,i[6]=o,i[7]=d,i[8]=f):(d=i[7],f=i[8]),(0,Q.useEffect)(d,f);let p,m;i[9]!==u||i[10]!==c?(p=()=>{if(!u)return;let e=window.setInterval(()=>{document.visibilityState===`visible`&&navigator.onLine&&c()},3e3);return()=>window.clearInterval(e)},m=[u,c],i[9]=u,i[10]=c,i[11]=p,i[12]=m):(p=i[11],m=i[12]),(0,Q.useEffect)(p,m);let h,g;i[13]!==e||i[14]!==c?(h=()=>{if(!e)return;let t=t=>{let n=t.detail;(n?.conversationId??n?.key)===e&&c()};return window.addEventListener(`session-updated`,t),window.addEventListener(`session-transcript-updated`,t),()=>{window.removeEventListener(`session-updated`,t),window.removeEventListener(`session-transcript-updated`,t)}},g=[e,c],i[13]=e,i[14]=c,i[15]=h,i[16]=g):(h=i[15],g=i[16]),(0,Q.useEffect)(h,g);let v;bb0:{if(!o||!s?.jobs.length){let e;i[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],i[17]=e):e=i[17],v=e;break bb0}let e;if(i[18]!==s.jobs||i[19]!==t||i[20]!==r||i[21]!==o){let n=Jk(r,`music_generation`);e=s.jobs.map(e=>({id:`music-generation:${e.id}`,timestamp:e.createdAt,afterMessageIndex:n.get(e.id),content:(0,X.jsx)(tA,{job:e,audioUrl:`${o}/${encodeURIComponent(e.id)}/audio`,language:t},e.id)})),i[18]=s.jobs,i[19]=t,i[20]=r,i[21]=o,i[22]=e}else e=i[22];v=e}return v}function eA(e){return![`completed`,`failed`,`submission_unknown`].includes(e.state)}function tA(e){let t=(0,Z.c)(61),{job:n,audioUrl:r,language:i}=e,a=Qk[i],o=(0,Q.useId)(),[s,c]=(0,Q.useState)(null),l=n.state===`completed`,u=n.state===`failed`,d=i===`zh`?`第 ${n.versionNumber} 版`:`Version ${n.versionNumber}`,f=n.errorCode?Zk[i][n.errorCode]:void 0,p=n.state===`submission_unknown`?a.unknown:f??(u?Zk[i].provider_failed:void 0),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=e=>c(t=>t===e?null:e),t[0]=m):m=t[0];let h=m,g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,X.jsxs)(`div`,{className:`relative grid size-11 shrink-0 place-items-center overflow-hidden rounded-lg border border-edge bg-surface-inset text-accent-fg`,"aria-hidden":!0,children:[(0,X.jsx)(`span`,{className:`absolute size-9 rounded-full border border-current opacity-15`}),(0,X.jsx)(`span`,{className:`absolute size-6 rounded-full border border-current opacity-20`}),(0,X.jsx)(Ct,{size:18,className:`relative`})]}),t[1]=g):g=t[1];let _;t[2]===n.title?_=t[3]:(_=(0,X.jsx)(`h3`,{className:`wrap-anywhere text-lg leading-tight font-semibold tracking-tight text-fg`,children:n.title}),t[2]=n.title,t[3]=_);let v=a[n.mode],y;t[4]!==v||t[5]!==d?(y=(0,X.jsxs)(`span`,{children:[v,` · `,d]}),t[4]=v,t[5]=d,t[6]=y):y=t[6];let b;t[7]!==l||t[8]!==n.state||t[9]!==a.status?(b=!l&&(0,X.jsx)(`span`,{role:`status`,className:`font-medium`,children:a.status[n.state]}),t[7]=l,t[8]=n.state,t[9]=a.status,t[10]=b):b=t[10];let x;t[11]!==y||t[12]!==b?(x=(0,X.jsxs)(`p`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2 text-xs text-fg-muted`,children:[y,b]}),t[11]=y,t[12]=b,t[13]=x):x=t[13];let S;t[14]!==_||t[15]!==x?(S=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[_,x]}),t[14]=_,t[15]=x,t[16]=S):S=t[16];let C=`${o}-details`,w=s===`details`,T,E;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>h(`details`),E=(0,X.jsx)(Se,{size:20,"aria-hidden":!0}),t[17]=T,t[18]=E):(T=t[17],E=t[18]);let D;t[19]!==a.details||t[20]!==w||t[21]!==C?(D=(0,X.jsx)(Yi,{variant:`ghost`,className:`size-11 shrink-0 rounded-full p-0 aria-expanded:bg-surface-active aria-expanded:text-fg`,"aria-label":a.details,title:a.details,"aria-controls":C,"aria-expanded":w,onClick:T,children:E}),t[19]=a.details,t[20]=w,t[21]=C,t[22]=D):D=t[22];let O;t[23]!==D||t[24]!==S?(O=(0,X.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[g,S,D]}),t[23]=D,t[24]=S,t[25]=O):O=t[25];let k;t[26]!==u||t[27]!==p?(k=p&&(0,X.jsx)(`p`,{className:u?`text-xs text-danger`:`text-xs text-fg-muted`,children:p}),t[26]=u,t[27]=p,t[28]=k):k=t[28];let A;t[29]!==l||t[30]!==n.id||t[31]!==n.title||t[32]!==i?(A=l&&(0,X.jsx)(Eh,{mediaId:`music-${n.id}.mp3`,title:n.title,zh:i===`zh`}),t[29]=l,t[30]=n.id,t[31]=n.title,t[32]=i,t[33]=A):A=t[33];let j;t[34]!==r||t[35]!==l||t[36]!==n.durationMs||t[37]!==n.lyrics||t[38]!==n.mode||t[39]!==n.title||t[40]!==i||t[41]!==s?(j=l&&(0,X.jsx)(Xk,{src:r,title:n.title,durationMs:n.durationMs,lyrics:n.mode===`song`?n.lyrics:null,lyricsOpen:s===`lyrics`,onToggleLyrics:()=>h(`lyrics`),language:i},r),t[34]=r,t[35]=l,t[36]=n.durationMs,t[37]=n.lyrics,t[38]=n.mode,t[39]=n.title,t[40]=i,t[41]=s,t[42]=j):j=t[42];let M=`${o}-details`,N=s!==`details`,P;t[43]!==n.error||t[44]!==n.errorCode||t[45]!==n.modelRef||t[46]!==n.prompt||t[47]!==a.model||t[48]!==a.prompt||t[49]!==s?(P=s===`details`&&(0,X.jsxs)(`dl`,{className:`space-y-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-xs text-fg-muted`,children:a.prompt}),(0,X.jsx)(`dd`,{className:`mt-1 whitespace-pre-wrap wrap-anywhere text-sm leading-relaxed text-fg`,children:n.prompt})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-xs text-fg-muted`,children:a.model}),(0,X.jsxs)(`dd`,{className:`mt-1 wrap-anywhere text-sm text-fg`,children:[n.modelRef,n.errorCode===`provider_rate_limited`&&n.error?.endsWith(`HTTP 429.`)&&` · HTTP 429`]})]})]}),t[43]=n.error,t[44]=n.errorCode,t[45]=n.modelRef,t[46]=n.prompt,t[47]=a.model,t[48]=a.prompt,t[49]=s,t[50]=P):P=t[50];let F;t[51]!==M||t[52]!==N||t[53]!==P?(F=(0,X.jsx)(`div`,{id:M,hidden:N,className:`border-t border-edge pt-3`,children:P}),t[51]=M,t[52]=N,t[53]=P,t[54]=F):F=t[54];let I;return t[55]!==O||t[56]!==k||t[57]!==A||t[58]!==j||t[59]!==F?(I=(0,X.jsxs)(`article`,{className:`flex w-full min-w-0 max-w-[26rem] flex-col gap-2 rounded-xl border border-edge bg-surface-panel p-3
64
- [background-image:radial-gradient(ellipse_at_top_left,var(--color-accent-soft),transparent_72%)] sm:p-3.5`,children:[O,k,A,j,F]}),t[55]=O,t[56]=k,t[57]=A,t[58]=j,t[59]=F,t[60]=I):I=t[60],I}function nA(e){let t=(0,Z.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,X.jsx)(`article`,{className:`min-w-0 w-full max-w-lg space-y-2.5 rounded-xl bg-surface-inset p-3 sm:p-4`,children:n}),t[0]=n,t[1]=r),r}function rA(e){let t=(0,Z.c)(6),{label:n,children:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,X.jsx)(ie,{size:14,"aria-hidden":!0,className:`group-open:rotate-90`}),t[0]=i):i=t[0];let a;t[1]===n?a=t[2]:(a=(0,X.jsxs)(`summary`,{className:`flex w-fit cursor-pointer list-none items-center gap-1 rounded-sm py-1 hover:text-fg focus-visible:outline-2 focus-visible:outline-accent [&::-webkit-details-marker]:hidden`,children:[i,n]}),t[1]=n,t[2]=a);let o;return t[3]!==r||t[4]!==a?(o=(0,X.jsxs)(`details`,{className:`group text-xs text-fg-muted`,children:[a,r]}),t[3]=r,t[4]=a,t[5]=o):o=t[5],o}function iA(e){let t=(0,Z.c)(5),{src:n,title:r}=e,i;t[0]!==n||t[1]!==r?(i={kind:`video`,src:n,title:r},t[0]=n,t[1]=r,t[2]=i):i=t[2];let{hostRef:a}=wt(i),o;return t[3]===a?o=t[4]:(o=(0,X.jsx)(`div`,{ref:a}),t[3]=a,t[4]=o),o}var aA={zh:{title:`视频`,draft:`视频草稿`,original:`跟随原图`,autoDuration:`自动时长`,download:`下载视频`,previous:`重置前生成的视频`,generate:`确认生成`,adjust:`修改草稿`,submitting:`正在提交…`,noKey:`请在「模型与能力」连接当前视频服务。`,details:`查看完整提示词和模型`,estimate:`预计`,reference:`参考图`,status:{queued:`排队中`,submitting:`正在提交`,submitted:`供应商排队中`,running:`生成中`,saving:`正在保存`,completed:`已完成`,failed:`生成失败`,submission_unknown:`提交结果待确认`}},en:{title:`Video`,draft:`Video draft`,original:`Match the image`,autoDuration:`Auto duration`,download:`Download video`,previous:`Videos from before the reset`,generate:`Confirm generation`,adjust:`Edit draft`,submitting:`Submitting…`,noKey:`Connect the video provider in Models and capabilities.`,details:`View full prompt and model`,estimate:`Est.`,reference:`Reference image`,status:{queued:`Queued`,submitting:`Submitting`,submitted:`Queued at provider`,running:`Generating`,saving:`Saving`,completed:`Ready`,failed:`Generation failed`,submission_unknown:`Submission unconfirmed`}}};function oA(e){return/^(就按这个生成|确认生成视频|确认生成|confirm video generation|generate this video)[。!.!]?$/iu.test(e.trim())}function sA(e){return _(`/api/video-generation/sessions/${encodeURIComponent(e)}/jobs`)}function cA(e){return![`completed`,`failed`,`submission_unknown`].includes(e.state)}function lA(e,t,n,r={}){let{chatBusy:i=!1,readOnly:a=!1,onAdjust:o}=r,s=e?sA(e):null,{data:c,mutate:l}=bi(s,async e=>{try{return await b(e)}catch(e){if(e.status===404)return null;throw e}}),u=c?.jobs.some(cA)??!1,d=(0,Q.useRef)(null),[f,p]=(0,Q.useState)(),[m,h]=(0,Q.useState)(),g=c?.draft,_=g?`${g.id}:${g.revision}`:void 0,v=!!(c?.configured&&g?.modelRef===c.modelRef),y=(0,Q.useCallback)(async()=>{if(!s||!g||!_||d.current||i||a||!v)return!1;d.current=_,p(_),h(void 0);try{let e=await b(`${s}/confirm-draft`,{method:`POST`,body:JSON.stringify({id:g.id,revision:g.revision})});return await l(t=>t&&{...t,draft:t.draft?.id===e.id?void 0:t.draft,jobs:[e,...t.jobs.filter(t=>t.id!==e.id)]},{revalidate:!0}),!0}catch(e){return h({key:_,message:e instanceof Error?e.message:String(e)}),l(),!1}finally{d.current=null,p(void 0)}},[s,g,_,i,a,v,l]),x=(0,Q.useRef)(!1);return(0,Q.useEffect)(()=>{x.current&&!i&&l(),x.current=i},[i,l]),(0,Q.useEffect)(()=>{if(!u)return;let e=window.setInterval(()=>{document.visibilityState===`visible`&&navigator.onLine&&l()},3e3);return()=>window.clearInterval(e)},[u,l]),(0,Q.useEffect)(()=>{if(!e)return;let t=t=>{let n=t.detail;(n?.conversationId??n?.key)===e&&l()};return window.addEventListener(`session-updated`,t),window.addEventListener(`session-transcript-updated`,t),()=>{window.removeEventListener(`session-updated`,t),window.removeEventListener(`session-transcript-updated`,t)}},[e,l]),{draft:g,confirmDraft:y,timelineEntries:(0,Q.useMemo)(()=>{if(!c||!s||!e)return[];let r=e=>(0,X.jsx)(pA,{job:e,url:`${s}/${encodeURIComponent(e.id)}/video`,language:t},e.id),l=c.jobs.filter(e=>e.transcriptId===c.transcriptId),u=c.jobs.filter(e=>e.transcriptId!==c.transcriptId),d=l.length||g?Jk(n,`video_draft`):void 0,p=l.map(e=>({id:`video-generation:${e.id}`,timestamp:e.draftCreatedAt??e.createdAt,afterMessageIndex:d?.get(e.id),content:r(e)}));return g&&p.push({id:`video-generation:${g.id}`,timestamp:g.createdAt,afterMessageIndex:d?.get(g.id),content:(0,X.jsx)(uA,{draft:g,conversationId:e,language:t,configured:v,modelChanged:g.modelRef!==c.modelRef,readOnly:a,disabled:i||!!f,submitting:f===_,error:m?.key===_?m?.message:void 0,onAdjust:o,onConfirm:y})}),u.length&&p.push({id:`video-generation:previous-transcripts`,timestamp:u[0].createdAt,content:(0,X.jsxs)(`details`,{className:`w-full max-w-lg rounded-xl border border-edge-subtle px-4 py-3`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer text-sm text-fg-muted`,children:aA[t].previous}),(0,X.jsx)(`div`,{className:`mt-3 space-y-3`,children:u.map(r)})]})}),p},[c,g,_,v,a,i,f,m,o,y,e,t,n,s])}}function uA(e){let t=(0,Z.c)(60),{draft:n,conversationId:r,language:i,configured:a,modelChanged:o,readOnly:s,disabled:c,submitting:l,error:u,onAdjust:d,onConfirm:f}=e,p=aA[i],m=i===`zh`,h;t[0]===n.modelRef?h=t[1]:(h=n.modelRef.startsWith(`xopc-cloud/`),t[0]=n.modelRef,t[1]=h);let g=h,v;t[2]!==g||t[3]!==n.estimatedCostFen||t[4]!==n.estimatedCreditMicro?(v=g?n.estimatedCreditMicro&&`${mi(String(n.estimatedCreditMicro))} Credits`:`¥${(n.estimatedCostFen/100).toFixed(2)}`,t[2]=g,t[3]=n.estimatedCostFen,t[4]=n.estimatedCreditMicro,t[5]=v):v=t[5];let y=v,b;t[6]!==r||t[7]!==n.imageUri?(b=n.imageUri?_(`/api/media/read?${new URLSearchParams({uri:n.imageUri,conversationId:r})}`):void 0,t[6]=r,t[7]=n.imageUri,t[8]=b):b=t[8];let x=b,S;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,X.jsx)(hc,{size:16,"aria-hidden":!0}),t[9]=S):S=t[9];let C;t[10]===p.draft?C=t[11]:(C=(0,X.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[S,p.draft]}),t[10]=p.draft,t[11]=C);let w;t[12]!==n.imageName||t[13]!==x||t[14]!==p.reference?(w=x&&(0,X.jsx)(`img`,{src:x,alt:n.imageName??p.reference,className:`size-14 shrink-0 rounded-lg object-cover`}),t[12]=n.imageName,t[13]=x,t[14]=p.reference,t[15]=w):w=t[15];let T=n.summary||n.prompt,E;t[16]===T?E=t[17]:(E=(0,X.jsx)(`p`,{className:`line-clamp-3 min-w-0 wrap-anywhere text-sm leading-relaxed text-fg`,children:T}),t[16]=T,t[17]=E);let D;t[18]!==w||t[19]!==E?(D=(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[w,E]}),t[18]=w,t[19]=E,t[20]=D):D=t[20];let O;t[21]!==n||t[22]!==i?(O=dA(n,i),t[21]=n,t[22]=i,t[23]=O):O=t[23];let k;t[24]!==p.estimate||t[25]!==y?(k=y?(0,X.jsxs)(X.Fragment,{children:[` · `,(0,X.jsxs)(`span`,{className:`font-medium tabular-nums text-fg`,children:[p.estimate,` `,y]})]}):null,t[24]=p.estimate,t[25]=y,t[26]=k):k=t[26];let A;t[27]!==O||t[28]!==k?(A=(0,X.jsxs)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:[O,k]}),t[27]=O,t[28]=k,t[29]=A):A=t[29];let j=g?m?`XOPC Cloud 在供应商接受任务后扣除 Credits。`:`XOPC Cloud charges Credits when the provider accepts the task.`:m?`以供应商实际账单为准。`:`Actual charges are set by the provider.`,M=n.duration===-1&&(m?`自动时长按最长时长估算。`:` Auto duration is estimated at the model maximum.`),N;t[30]!==n||t[31]!==i||t[32]!==j||t[33]!==M?(N=(0,X.jsxs)(fA,{video:n,language:i,children:[j,M]}),t[30]=n,t[31]=i,t[32]=j,t[33]=M,t[34]=N):N=t[34];let P;t[35]!==a||t[36]!==p.noKey||t[37]!==o||t[38]!==m?(P=!a&&(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:o?m?`默认视频模型已切换,请先调整草稿。`:`The default video model changed. Adjust the draft first.`:p.noKey}),t[35]=a,t[36]=p.noKey,t[37]=o,t[38]=m,t[39]=P):P=t[39];let F;t[40]===u?F=t[41]:(F=u&&(0,X.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:u}),t[40]=u,t[41]=F);let I;t[42]!==a||t[43]!==c||t[44]!==p.adjust||t[45]!==p.generate||t[46]!==p.submitting||t[47]!==d||t[48]!==f||t[49]!==s||t[50]!==l?(I=!s&&(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(Yi,{variant:`primary`,className:`min-h-9 px-3 py-1`,disabled:c||!a,onClick:()=>void f(),children:l?p.submitting:p.generate}),d&&(0,X.jsx)(Yi,{variant:`ghost`,className:`min-h-9 px-3 py-1`,disabled:c,onClick:d,children:p.adjust})]}),t[42]=a,t[43]=c,t[44]=p.adjust,t[45]=p.generate,t[46]=p.submitting,t[47]=d,t[48]=f,t[49]=s,t[50]=l,t[51]=I):I=t[51];let L;return t[52]!==A||t[53]!==N||t[54]!==P||t[55]!==F||t[56]!==I||t[57]!==C||t[58]!==D?(L=(0,X.jsxs)(nA,{children:[C,D,A,N,P,F,I]}),t[52]=A,t[53]=N,t[54]=P,t[55]=F,t[56]=I,t[57]=C,t[58]=D,t[59]=L):L=t[59],L}function dA(e,t){let n=aA[t];return[e.duration===-1?n.autoDuration:t===`zh`?`${e.duration} 秒`:`${e.duration}s`,e.resolution.toLowerCase(),e.ratio===`adaptive`?n.original:e.ratio].join(` · `)}function fA(e){let t=(0,Z.c)(11),{video:n,language:r,children:i}=e,a=aA[r],o;t[0]===n.prompt?o=t[1]:(o=(0,X.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap wrap-anywhere border-s border-edge px-3 text-sm leading-relaxed text-fg`,children:n.prompt}),t[0]=n.prompt,t[1]=o);let s=L[n.modelRef??`dashscope-cn/wan3.0-video`],c;t[2]===i?c=t[3]:(c=i&&(0,X.jsxs)(X.Fragment,{children:[` · `,i]}),t[2]=i,t[3]=c);let l;t[4]!==s.name||t[5]!==c?(l=(0,X.jsxs)(`p`,{className:`mt-2`,children:[s.name,c]}),t[4]=s.name,t[5]=c,t[6]=l):l=t[6];let u;return t[7]!==a.details||t[8]!==o||t[9]!==l?(u=(0,X.jsxs)(rA,{label:a.details,children:[o,l]}),t[7]=a.details,t[8]=o,t[9]=l,t[10]=u):u=t[10],u}function pA(e){let t=(0,Z.c)(39),{job:n,url:r,language:i}=e,a=aA[i],o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,X.jsx)(hc,{size:16,"aria-hidden":!0}),t[0]=o):o=t[0];let s;t[1]===a.title?s=t[2]:(s=(0,X.jsxs)(`h3`,{className:`flex items-center gap-2 font-medium text-fg`,children:[o,a.title]}),t[1]=a.title,t[2]=s);let c=a.status[n.state],l;t[3]===c?l=t[4]:(l=(0,X.jsx)(`span`,{role:`status`,className:`text-xs text-fg-muted`,children:c}),t[3]=c,t[4]=l);let u;t[5]!==s||t[6]!==l?(u=(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-sm`,children:[s,l]}),t[5]=s,t[6]=l,t[7]=u):u=t[7];let d;t[8]!==n||t[9]!==i?(d=dA(n,i),t[8]=n,t[9]=i,t[10]=d):d=t[10];let f;t[11]===d?f=t[12]:(f=(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:d}),t[11]=d,t[12]=f);let p;t[13]===n.error?p=t[14]:(p=n.error&&(0,X.jsx)(`p`,{className:`text-xs text-danger`,children:n.error}),t[13]=n.error,t[14]=p);let m;t[15]!==n.id||t[16]!==n.state||t[17]!==n.summary||t[18]!==i||t[19]!==a.download||t[20]!==a.title||t[21]!==r?(m=n.state===`completed`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(iA,{src:r,title:n.summary||a.title}),(0,X.jsxs)(`a`,{href:`${r}?download=1`,download:`generated-video.mp4`,className:`inline-flex items-center gap-2 text-sm text-accent-fg hover:underline`,children:[(0,X.jsx)(xe,{size:15,"aria-hidden":!0}),a.download]}),(0,X.jsx)(Eh,{mediaId:`wan-${n.id}.mp4`,title:n.summary||a.title,zh:i===`zh`})]}),t[15]=n.id,t[16]=n.state,t[17]=n.summary,t[18]=i,t[19]=a.download,t[20]=a.title,t[21]=r,t[22]=m):m=t[22];let h;t[23]===n.summary?h=t[24]:(h=n.summary&&(0,X.jsx)(`p`,{className:`line-clamp-3 wrap-anywhere text-sm leading-relaxed text-fg`,children:n.summary}),t[23]=n.summary,t[24]=h);let g;t[25]!==n.imageName||t[26]!==a.reference?(g=n.imageName&&(0,X.jsxs)(`span`,{className:`wrap-anywhere`,children:[a.reference,` · `,n.imageName]}),t[25]=n.imageName,t[26]=a.reference,t[27]=g):g=t[27];let _;t[28]!==n||t[29]!==i||t[30]!==g?(_=(0,X.jsx)(fA,{video:n,language:i,children:g}),t[28]=n,t[29]=i,t[30]=g,t[31]=_):_=t[31];let v;return t[32]!==h||t[33]!==_||t[34]!==u||t[35]!==f||t[36]!==p||t[37]!==m?(v=(0,X.jsxs)(nA,{children:[u,f,p,m,h,_]}),t[32]=h,t[33]=_,t[34]=u,t[35]=f,t[36]=p,t[37]=m,t[38]=v):v=t[38],v}function mA(e,t){return e.bottom>t.top&&e.top<t.bottom&&e.right>t.left&&e.left<t.right}function hA(e,t,n){let r=n.getBoundingClientRect(),i=t.getBoundingClientRect();if(!mA(e,{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight})||!mA(i,r)||typeof t.animate!=`function`)return()=>{};let a=t.closest(`article`);a&&(a.style.animation=`none`);let o=t.getBoundingClientRect(),s=e.left-o.left,c=e.top-o.top,l;try{l=t.animate([{transform:`translate3d(${s}px, ${c}px, 0)`},{transform:`translate3d(0, 0, 0)`}],{duration:360,easing:`cubic-bezier(0.25, 0.1, 0.25, 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.closest(`[data-chat-message-row]`);(!t.isConnected||e&&!mA(e.getBoundingClientRect(),n.getBoundingClientRect()))&&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,510),l.finished.then(f,f),f}function gA(e){let t=(0,Z.c)(13),{enabled:n,conversationId:r,messages:i,viewportRef:a}=e,o=(0,Q.useRef)(null),s=(0,Q.useRef)(null),c=(0,Q.useRef)(r),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{o.current&&window.clearTimeout(o.current.timeout),o.current=null,s.current?.(),s.current=null},t[0]=l):l=t[0];let u=l,d;t[1]===n?d=t[2]:(d=(e,t,r)=>{if(u(),!n||r.attachments.length>0||r.contextRefs.length>0||!r.text.trim()||document.visibilityState===`hidden`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let i={id:e.clientSubmissionId,source:{left:t.left,top:t.top,right:t.right,bottom:t.bottom},timeout:window.setTimeout(()=>{o.current===i&&(o.current=null)},500)};o.current=i},t[1]=n,t[2]=d);let f=d,p,m;t[3]===r?(p=t[4],m=t[5]):(p=()=>{let e=c.current;c.current=r,e!==null&&e!==r&&u()},m=[u,r],t[3]=r,t[4]=p,t[5]=m),(0,Q.useLayoutEffect)(p,m);let h,g;t[6]!==i||t[7]!==a?(h=()=>{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=hA(e.source,n,t))},g=[i,a],t[6]=i,t[7]=a,t[8]=h,t[9]=g):(h=t[8],g=t[9]),(0,Q.useLayoutEffect)(h,g);let _;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>u,t[10]=_):_=t[10];let v;return t[11]===n?v=t[12]:(v=[u,n],t[11]=n,t[12]=v),(0,Q.useEffect)(_,v),f}function _A(e){let t=(0,Z.c)(64),{open:n,query:r,activeIndex:i,resultCount:a,searching:o,truncated:s,limitedToLoaded:c,inputRef:l,className:u,labels:d,onQueryChange:f,onPrevious:p,onNext:m,onClose:h}=e,g=o!==void 0&&o,_=s!==void 0&&s,v=c!==void 0&&c;if(!n)return null;let y;t[0]===r?y=t[1]:(y=r.trim(),t[0]=r,t[1]=y);let b=!!y,x;t[2]!==i||t[3]!==b||t[4]!==d.noResults||t[5]!==d.resultCount||t[6]!==d.searching||t[7]!==a||t[8]!==g||t[9]!==_?(x=g?d.searching:b&&a===0?d.noResults:b?d.resultCount.replace(`{{current}}`,String(i+1)).replace(`{{total}}`,`${a}${_?`+`:``}`):``,t[2]=i,t[3]=b,t[4]=d.noResults,t[5]=d.resultCount,t[6]=d.searching,t[7]=a,t[8]=g,t[9]=_,t[10]=x):x=t[10];let S=x,C;t[11]!==S||t[12]!==b||t[13]!==d.loadedOnly||t[14]!==v?(C=v&&b?[S,d.loadedOnly].filter(Boolean).join(` · `):S,t[11]=S,t[12]=b,t[13]=d.loadedOnly,t[14]=v,t[15]=C):C=t[15];let w=C,T=g||a===0,E=d.input,D;t[16]===u?D=t[17]:(D=Y(`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`,u),t[16]=u,t[17]=D);let O;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,X.jsx)(zt,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[18]=O):O=t[18];let k;t[19]===f?k=t[20]:(k=e=>f(e.target.value),t[19]=f,t[20]=k);let A;t[21]!==m||t[22]!==p?(A=e=>{e.nativeEvent.isComposing||e.key===`Enter`&&(e.preventDefault(),e.shiftKey?p():m())},t[21]=m,t[22]=p,t[23]=A):A=t[23];let j;t[24]!==l||t[25]!==d.input||t[26]!==r||t[27]!==k||t[28]!==A?(j=(0,X.jsx)(`input`,{ref:l,value:r,type:`search`,autoComplete:`off`,spellCheck:!1,"aria-label":d.input,className:`h-12 min-w-0 flex-1 bg-transparent text-base text-fg outline-none placeholder:text-fg-subtle`,placeholder:d.input,onChange:k,onKeyDown:A}),t[24]=l,t[25]=d.input,t[26]=r,t[27]=k,t[28]=A,t[29]=j):j=t[29];let M;t[30]===g?M=t[31]:(M=g?(0,X.jsx)(qe,{className:`size-4 shrink-0 animate-spin text-fg-muted`,"aria-hidden":!0}):null,t[30]=g,t[31]=M);let N;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(N=Y(`inline-flex size-11 shrink-0 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,Pa.focusRingPanel,Pa.press),t[32]=N):N=t[32];let P;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,X.jsx)(an,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[33]=P):P=t[33];let F;t[34]!==d.close||t[35]!==h?(F=(0,X.jsx)(`button`,{type:`button`,onClick:h,className:N,"aria-label":d.close,children:P}),t[34]=d.close,t[35]=h,t[36]=F):F=t[36];let I;t[37]!==j||t[38]!==M||t[39]!==F?(I=(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 px-3`,children:[O,j,M,F]}),t[37]=j,t[38]=M,t[39]=F,t[40]=I):I=t[40];let L;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(L=Y(`inline-flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,Pa.focusRingPanel,Pa.press,Pa.disabled),t[41]=L):L=t[41];let R;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,X.jsx)(ae,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[42]=R):R=t[42];let z;t[43]!==d.previous||t[44]!==T||t[45]!==p?(z=(0,X.jsx)(`button`,{type:`button`,disabled:T,onClick:p,className:L,"aria-label":d.previous,children:R}),t[43]=d.previous,t[44]=T,t[45]=p,t[46]=z):z=t[46];let B;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(B=Y(`inline-flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,Pa.focusRingPanel,Pa.press,Pa.disabled),t[47]=B):B=t[47];let V;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,X.jsx)(re,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[48]=V):V=t[48];let H;t[49]!==d.next||t[50]!==T||t[51]!==m?(H=(0,X.jsx)(`button`,{type:`button`,disabled:T,onClick:m,className:B,"aria-label":d.next,children:V}),t[49]=d.next,t[50]=T,t[51]=m,t[52]=H):H=t[52];let U;t[53]===w?U=t[54]:(U=(0,X.jsx)(`span`,{className:`ml-auto px-2 text-sm tabular-nums text-fg-muted`,"aria-live":`polite`,"aria-atomic":`true`,children:w}),t[53]=w,t[54]=U);let W;t[55]!==z||t[56]!==H||t[57]!==U?(W=(0,X.jsxs)(`div`,{className:`flex h-11 items-center border-t border-edge-subtle px-1.5`,children:[z,H,U]}),t[55]=z,t[56]=H,t[57]=U,t[58]=W):W=t[58];let ee;return t[59]!==d.input||t[60]!==I||t[61]!==W||t[62]!==D?(ee=(0,X.jsxs)(`section`,{"data-chat-find-bar":!0,role:`search`,"aria-label":E,className:D,children:[I,W]}),t[59]=d.input,t[60]=I,t[61]=W,t[62]=D,t[63]=ee):ee=t[63],ee}async function vA(e,t,n={}){let r=await g(_(`${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 yA=`chat-find-match`,bA=`chat-find-active`,xA=`chat-find-highlight-styles`;function SA(){let e=globalThis.CSS,t=globalThis.Highlight;return!e?.highlights||!t?null:{registry:e.highlights,Highlight:t}}function CA(){if(document.getElementById(xA))return;let e=document.createElement(`style`);e.id=xA,e.textContent=`
65
- ::highlight(${yA}) {
60
+ <script>${Dy(n,`script`)}<\/script>
61
+ <script>${Dy(e.script,`script`)}<\/script>
62
+ </body></html>`}function Ay(e,t,n){let r=r=>{if(r.source!==e.contentWindow)return;let i=Oy(r.data);!i||i.channel!==t||n(i)};return window.addEventListener(`message`,r),()=>window.removeEventListener(`message`,r)}function jy({leaseId:e,reference:t,sourceHash:n,preferredHeight:r,language:i}){let a=p(),o=f(),s=(0,Q.useRef)(null),[c,l]=(0,Q.useState)(0),[u,d]=(0,Q.useState)(`booting`),[m,h]=(0,Q.useState)([]),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(null),b=Da(e),x=Math.min(720,Math.max(240,r)),S=(0,Q.useMemo)(()=>crypto.randomUUID(),[c,n]),C=vi(b.active?[`chat-preview-revision`,t.id,n]:null,()=>wy(t.id,n),{revalidateOnFocus:!1,shouldRetryOnError:!1}),w=C.data?ky(C.data,S):void 0;(0,Q.useEffect)(()=>{let e=s.current;if(!e||!w)return;d(`booting`),h([]);let t=window.setTimeout(()=>{d(e=>e===`booting`?`timeout`:e)},7e3),n=Ay(e,S,t=>{t.type===`ready`&&d(`healthy`),t.type===`resize`&&(e.style.height=`${Math.min(720,Math.max(240,t.height))}px`),t.type===`error`&&(d(`failed`),h(e=>[...e,t.diagnostic].slice(-20)))});return()=>{window.clearTimeout(t),n()}},[S,w]);let T=()=>{y(null),l(e=>e+1)},E=async()=>{if(m.length){_(`fix`),y(null);try{Qm((await Ty(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 Ey(t.id,n);a(Ze(`${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,X.jsxs)(`section`,{ref:b.containerRef,className:O,"data-inline-chat-preview":t.id,children:[(0,X.jsxs)(`header`,{className:`border-b border-edge-subtle px-4 py-3`,children:[(0,X.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:t.title}),(0,X.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,X.jsx)(`div`,{className:`grid place-items-center bg-surface-base`,style:{height:x},children:(0,X.jsx)(qi,{variant:`secondary`,className:`min-h-11`,onClick:b.activate,children:i===`zh`?`加载交互预览`:`Load interactive preview`})})]});if(C.isLoading)return(0,X.jsxs)(`section`,{ref:b.containerRef,className:O,"aria-busy":`true`,"aria-label":i===`zh`?`正在加载预览`:`Loading preview`,children:[(0,X.jsx)(`div`,{className:`border-b border-edge-subtle px-4 py-3`,children:(0,X.jsx)(sn,{className:`h-5 w-40`})}),(0,X.jsx)(sn,{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,X.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,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Zt,{className:`size-4`}),e]})})}let k=u===`failed`||u===`timeout`,A=u===`healthy`?i===`zh`?`运行正常`:`Running`:u===`booting`?i===`zh`?`正在启动`:`Starting`:u===`timeout`?i===`zh`?`启动超时`:`Start timed out`:i===`zh`?`运行错误`:`Runtime error`;return(0,X.jsxs)(`section`,{ref:b.containerRef,className:O,"data-inline-chat-preview":t.id,children:[(0,X.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-2 border-b border-edge-subtle px-4 py-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:t.title}),(0,X.jsx)(`p`,{className:Y(`mt-0.5 text-xs`,k?`text-danger`:`text-fg-muted`),"aria-live":`polite`,children:A})]}),(0,X.jsx)(qi,{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,X.jsx)(It,{className:`size-4`,"aria-hidden":!0})}),(0,X.jsx)(qi,{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,X.jsx)(Rt,{className:Y(`size-4`,g===`promote`&&`motion-safe:animate-pulse`),"aria-hidden":!0})})]}),(0,X.jsxs)(`div`,{className:`relative bg-surface-base`,style:{minHeight:x},children:[(0,X.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}},c),u===`booting`?(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-0 grid place-items-center bg-surface-base/75`,children:(0,X.jsx)(sn,{className:`h-10 w-40`})}):null]}),k?(0,X.jsx)(`footer`,{className:`border-t border-danger/20 bg-danger-soft/60 px-4 py-3`,children:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.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,X.jsxs)(qi,{variant:`secondary`,className:`min-h-11 px-3 text-xs`,disabled:!m.length||g!==null,onClick:()=>void E(),children:[(0,X.jsx)(rn,{className:`size-4`}),g===`fix`?i===`zh`?`生成中…`:`Preparing…`:i===`zh`?`让 AI 修复`:`Ask AI to fix`]})]})}):null,v?(0,X.jsx)(`p`,{className:`border-t border-danger/20 px-4 py-2 text-xs text-danger`,role:`alert`,children:v}):null]})}function My(e){let t=(0,Z.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,X.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,X.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 Ny(e){let t=e.mimeType?.toLowerCase()??``,n=e.type?.toLowerCase()??``;return t.startsWith(`image/`)||n===`image`?Te:t.startsWith(`audio/`)||n===`audio`||n===`voice`?Xs:t.startsWith(`video/`)||n===`video`?ve:t.includes(`spreadsheet`)||[`spreadsheet`,`csv`,`xlsx`,`xls`].includes(n)?q:t.includes(`zip`)||[`archive`,`zip`].includes(n)?P:n===`site`?ee:Ee}function Py(e,t,n){return!!(e.uri||ji(e)||e.workspaceRelativePath?.trim()&&(t?.trim()||n?.trim()))}function Fy(e){let t=(0,Z.c)(43),{item:n,authToken:r,conversationId:i,projectId:a,onOpen:o}=e,s=y(Iy),c;t[0]===s?c=t[1]:(c=C(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=Dh(n.attachment,u),f;t[5]===n.attachment?f=t[6]:(f=Ny(n.attachment),t[5]=n.attachment,t[6]=f);let p=f,m;t[7]!==i||t[8]!==n.attachment||t[9]!==a?(m=Py(n.attachment,i,a),t[7]=i,t[8]=n.attachment,t[9]=a,t[10]=m):m=t[10];let h=m,g=h||!!n.href,_;t[11]!==p||t[12]!==d.src||t[13]!==n.failed?(_=d.src?(0,X.jsx)(`img`,{src:d.src,alt:``,className:`size-[18px] rounded object-cover`,decoding:`async`,loading:`lazy`}):(0,X.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]=_):_=t[14];let v=n.attachment.name??l,b;t[15]===g?b=t[16]:(b=g?(0,X.jsx)(ie,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}):null,t[15]=g,t[16]=b);let x;t[17]!==n.meta||t[18]!==_||t[19]!==v||t[20]!==b?(x=(0,X.jsx)(xs,{icon:_,title:v,meta:n.meta,trailing:b}),t[17]=n.meta,t[18]=_,t[19]=v,t[20]=b,t[21]=x):x=t[21];let S=x,w=g?`cursor-pointer`:`cursor-default`,T;t[22]===w?T=t[23]:(T=Y(bs,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(!h&&n.href){let e;return t[27]!==E||t[28]!==S||t[29]!==n.href||t[30]!==k?(e=(0,X.jsx)(`li`,{className:`min-w-0 max-w-full`,"data-result-attachment":!0,children:(0,X.jsx)(`a`,{title:k,href:n.href,target:`_blank`,rel:`noreferrer`,className:E,children:S})}),t[27]=E,t[28]=S,t[29]=n.href,t[30]=k,t[31]=e):e=t[31],e}if(!h){let e;return t[32]!==E||t[33]!==S?(e=(0,X.jsx)(`li`,{className:E,"data-result-attachment":!0,children:S}),t[32]=E,t[33]=S,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]!==S||t[40]!==A||t[41]!==k?(j=(0,X.jsx)(`li`,{className:`min-w-0 max-w-full`,"data-result-attachment":!0,children:(0,X.jsx)(`button`,{type:`button`,className:E,title:k,onClick:A,children:S})}),t[38]=E,t[39]=S,t[40]=A,t[41]=k,t[42]=j):j=t[42],j}function Iy(e){return e.language}function Ly(e){let t=(0,Z.c)(25),{attachments:n,authToken:r,conversationId:i,projectId:a,onOpen:o,language:s}=e,c;t[0]!==n.length||t[1]!==s?(c=C(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(bs,`cursor-pointer list-none`),t[3]=u):u=t[3];let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,X.jsx)($s,{strokeWidth:1.75}),t[4]=d):d=t[4];let f;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,X.jsx)(ie,{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,X.jsx)(`summary`,{className:u,children:(0,X.jsx)(xs,{icon:d,title:l,trailing:f})}),t[6]=l,t[7]=p);let m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m=Y(Ts,ws),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,X.jsx)(Fy,{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,X.jsx)(`ul`,{className:m,children:h}),t[20]=h,t[21]=g);let _;return t[22]!==p||t[23]!==g?(_=(0,X.jsx)(`li`,{className:`min-w-0 max-w-full`,"data-result-attachment-group":!0,children:(0,X.jsxs)(`details`,{className:`group`,children:[p,g]})}),t[22]=p,t[23]=g,t[24]=_):_=t[24],_}function Ry(e,t){if(!e)return[];let n=C(t).chat.turnOutcome;return e.deliverables.map(e=>{let t=Fi(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:Ni(e.sizeBytes)].filter(Boolean).join(` · `)}})}function zy(e,t){let n=C(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`?Ni(e.size):null].filter(Boolean).join(` · `)}))}function By(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 Vy(e){let t=(0,Z.c)(46),{view:n,authToken:r,conversationId:i,projectId:a}=e,o=y(Ky)===`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=Ah(s),l=n.deliveries.filter(Gy),u=Xv(l),d=Qv(l),f=$v(l),p=Zv(l),m=(0,Q.useContext)(sy),h=new Set(By(n.outcome));if(m)for(let{delivery:e,reference:t}of ey(l))t.kind===`automation`&&!t.runId&&e.operation!==`failed`&&h.add(`automation:${t.id}`);let g=ey(l,h).length,_,v,b,x;if(t[3]!==o||t[4]!==c||t[5]!==n.attachments||t[6]!==n.outcome||t[7]!==n.resultRevision){_=[...Ry(n.outcome,o),...zy(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],v=e;let r;t[15]!==v||t[16]!==c||t[17]!==n.resultRevision?(r=e=>{c.openAttachment(e,v(e)?n.resultRevision:void 0)},t[15]=v,t[16]=c,t[17]=n.resultRevision,t[18]=r):r=t[18],b=r,x=_.filter(Wy),t[3]=o,t[4]=c,t[5]=n.attachments,t[6]=n.outcome,t[7]=n.resultRevision,t[8]=_,t[9]=v,t[10]=b,t[11]=x}else _=t[8],v=t[9],b=t[10],x=t[11];let S=x,w;t[19]!==_||t[20]!==S?(w=_.filter(e=>!S.includes(e)),t[19]=_,t[20]=S,t[21]=w):w=t[21];let T=w,E=g>0||T.length>0;if(u.length===0&&d.length===0&&f.length===0&&!E&&!S.length)return null;let D;t[22]!==r||t[23]!==i||t[24]!==S?(D=S.length>0?(0,X.jsx)(zh,{attachments:S.map(Uy),authToken:r,conversationId:i,workspaceConversationId:i,layout:`assistant`}):null,t[22]=r,t[23]=i,t[24]=S,t[25]=D):D=t[25];let O=u.map(Hy),k;t[26]===o?k=t[27]:(k=e=>{let{key:t,presentation:n}=e;return(0,X.jsx)(Cy,{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,X.jsx)(jy,{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,X.jsxs)(My,{label:C(o).chat.productDelivery.heading,children:[(0,X.jsxs)(`ul`,{className:Ts,children:[(0,X.jsx)(gy,{deliveries:l,language:o,excludedReferenceKeys:h,conversationId:i,projectId:a}),T.length>1?(0,X.jsx)(Ly,{attachments:T,authToken:r,conversationId:i,projectId:a,onOpen:b,language:o}):T.map(e=>(0,X.jsx)(Fy,{item:e,authToken:r,conversationId:i,projectId:a,onOpen:b},e.key))]}),p.truncated?(0,X.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-fg-muted`,children:C(o).chat.productDelivery.partialResults}):null]}):null,P;t[30]!==T.length||t[31]!==r||t[32]!==i||t[33]!==v||t[34]!==c.active||t[35]!==c.closePreview||t[36]!==c.open||t[37]!==n.resultRevision?(P=T.length>0?(0,X.jsx)(qo,{open:c.open,attachment:c.active,resultRevision:c.active&&v(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]=v,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,X.jsxs)(X.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 Hy(e){let{key:t,presentation:n}=e;return(0,X.jsx)(xy,{presentation:n},t)}function Uy(e){return e.attachment}function Wy(e){return!e.failed&&e.attachment.mimeType?.startsWith(`image/`)}function Gy(e){let{delivery:t}=e;return Yv(t)}function Ky(e){return e.language}var qy=(0,Q.createContext)({});function Jy(e){let t=(0,Z.c)(16),{outcome:n}=e,r=C(y(Zy)).chat.turnOutcome,i=(0,Q.useContext)(qy),a=!!(i.turnId&&i.turnId===n.turnId),o=n.status===`failed`&&!(a&&i.running)?(0,X.jsx)(Cg,{errorText:a&&i.error||n.summary||r.statusFailed,onRetry:a?i.onRetry:void 0}):null,s=!!n.changeSet,c=n.evidence.length>0;if(!s&&!c)return o;let l=n.evidence.filter(Xy).length,u=n.evidence.filter(Yy).length,d=n.status===`succeeded`?r.statusSucceeded:n.status===`failed`?r.statusFailed:r.statusPartial,f=n.status===`succeeded`?ne:n.status===`failed`?K:G,p=[n.changeSet?r.changedFileCount.replace(`{{count}}`,String(n.changeSet.files.length)):null,l>0?r.passedCount.replace(`{{count}}`,String(l)):null,u>0?r.failedCount.replace(`{{count}}`,String(u)):null,c&&l===0&&u===0?r.evidenceCount.replace(`{{count}}`,String(n.evidence.length)):null].filter(Boolean).join(` · `),m=n.status===`succeeded`?`text-success`:n.status===`failed`?`text-danger`:`text-warning`,h;t[0]!==f||t[1]!==m?(h=(0,X.jsx)(f,{className:m,"aria-hidden":!0}),t[0]=f,t[1]=m,t[2]=h):h=t[2];let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,X.jsx)(ie,{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[3]=g):g=t[3];let _=ws,v=n.changeSet?(0,X.jsxs)(`section`,{"aria-label":r.changes,children:[(0,X.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[(0,X.jsx)(`span`,{className:`font-medium text-fg`,children:r.changeSetTitle}),(0,X.jsx)(`span`,{className:`shrink-0 text-fg-subtle`,children:r.changeStats.replace(`{{files}}`,String(n.changeSet.files.length)).replace(`{{added}}`,String(n.changeSet.added)).replace(`{{removed}}`,String(n.changeSet.removed))})]}),(0,X.jsxs)(`div`,{className:`mt-2 border-t border-edge-subtle/70 pt-2`,children:[n.changeSet.files.slice(0,8).map(e=>(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 py-1 text-xs`,children:[(0,X.jsx)(`span`,{className:`w-14 shrink-0 text-fg-subtle`,children:r.fileStatus[e.status??`modified`]}),(0,X.jsx)(`code`,{className:`min-w-0 truncate text-fg-muted`,children:e.path})]},e.path)),n.changeSet.files.length>8?(0,X.jsx)(`div`,{className:`pt-1 text-xs text-fg-subtle`,children:r.moreFiles.replace(`{{count}}`,String(n.changeSet.files.length-8))}):null]}),n.changeSet.diff?(0,X.jsxs)(`details`,{className:`mt-2`,children:[(0,X.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:r.viewDiff}),n.changeSet.diffTruncated?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-warning`,children:r.diffTruncated}):null,(0,X.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,X.jsx)(`code`,{children:n.changeSet.diff})})]}):null]}):null,b;t[4]!==s||t[5]!==c?(b=s&&c?(0,X.jsx)(`div`,{className:`my-2 border-t border-edge-subtle`}):null,t[4]=s,t[5]=c,t[6]=b):b=t[6];let x;t[7]!==c||t[8]!==n.evidence||t[9]!==r?(x=c?(0,X.jsxs)(`section`,{"aria-label":r.evidence,children:[(0,X.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg`,children:r.evidence}),n.evidence.map(e=>(0,X.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,X.jsx)(Ge,{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,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:e.label}),(0,X.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`?r.passed:e.status===`failed`?r.failed:r.warning})]},e.evidenceId))]}):null,t[7]=c,t[8]=n.evidence,t[9]=r,t[10]=x):x=t[10];let S;return t[11]!==_||t[12]!==v||t[13]!==b||t[14]!==x?(S=(0,X.jsxs)(`div`,{className:_,children:[v,b,x]}),t[11]=_,t[12]=v,t[13]=b,t[14]=x,t[15]=S):S=t[15],(0,X.jsxs)(X.Fragment,{children:[o,(0,X.jsxs)(`details`,{className:`group mt-2 min-w-0 max-w-full text-sm`,children:[(0,X.jsx)(`summary`,{className:`${bs} cursor-pointer list-none`,title:`${d} · ${p}`,children:(0,X.jsx)(xs,{icon:h,title:d,meta:p,trailing:g})}),S]})]})}function Yy(e){return e.status===`failed`}function Xy(e){return e.status===`passed`}function Zy(e){return e.language}function Qy(e){let t=(0,Z.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,X.jsx)(Vy,{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,X.jsx)(Jy,{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,X.jsxs)(`details`,{className:`group min-w-0 max-w-full`,"aria-label":o,children:[(0,X.jsx)(`summary`,{className:`${bs} cursor-pointer list-none`,children:(0,X.jsx)(xs,{icon:(0,X.jsx)(Me,{}),title:o,trailing:(0,X.jsx)(ie,{className:`size-3.5 shrink-0 text-fg-subtle transition-transform group-open:rotate-90 motion-reduce:transition-none`,"aria-hidden":!0})})}),(0,X.jsx)(`div`,{className:ws,children:(0,X.jsx)(ry,{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,X.jsxs)(X.Fragment,{children:[s,c,l]}),t[10]=s,t[11]=c,t[12]=l,t[13]=u):u=t[13],u}function $y(e,t){return t||e.workLog.items.some(e=>e.type===`tool_use`&&(e.status===`error`||e.activity?.status===`failed`))}function eb(e,t){if(e.role!==`assistant`||t.isStreaming||t.followUpTrigger)return!0;let n=ny({message:Av(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||$y(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 tb(e,t){let n=ur(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||e.beforeSteer),o=e.runStatus===`error`||e.runStatus===`cancelled`||i?.status===`failed`;return{settled:a,defaultCollapsed:a&&n&&!o,outcome:i}}function nb(e){let t=(0,Z.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=y(rb),p=C(f).chat,m;t[0]!==r||t[1]!==n?(m=tb(n,r),t[0]=r,t[1]=n,t[2]=m):m=t[2];let h=m,g=i&&h.settled&&a.length>0,_,v;t[3]===r?(_=t[4],v=t[5]):(_=()=>{r&&d(null)},v=[r],t[3]=r,t[4]=_,t[5]=v),(0,Q.useEffect)(_,v);let b,x;t[6]!==i||t[7]!==a.length?(b=()=>{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)}},x=[i,a.length],t[6]=i,t[7]=a.length,t[8]=b,t[9]=x):(b=t[8],x=t[9]),(0,Q.useEffect)(b,x);let S=u??(!h.defaultCollapsed||c),w=o==null?null:U_(o,f),T=n.runStatus===`cancelled`?p.processStopped:n.runStatus===`error`||h.outcome?.status===`failed`?p.processFailed:h.outcome?.status===`partial`?p.processPartial:null,E=T?`${T}${w?` · ${w}`:``}`:w?p.processWorkedFor.replace(`{{duration}}`,w):p.processView,D=g&&!S,O;t[10]!==S||t[11]!==E||t[12]!==g?(O=g?(0,X.jsxs)(`button`,{type:`button`,"data-assistant-process-toggle":!0,"aria-expanded":S,onClick:()=>d(!S),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,X.jsx)(`span`,{children:E}),(0,X.jsx)(ie,{"aria-hidden":!0,className:`size-4 shrink-0 transition-transform motion-reduce:transition-none ${S?`rotate-90`:``}`})]}):null,t[10]=S,t[11]=E,t[12]=g,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 rb(e){return e.language}function ib(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 ab(e){let t=(0,Z.c)(23),{trigger:n}=e,r=f(),i=y(ob),a;t[0]===i?a=t[1]:(a=C(i),t[0]=i,t[1]=a);let o=a.chat.taskTrigger,s=n.entryId,c;t[2]===o.about?c=t[3]:(c=(0,X.jsx)(`span`,{className:`shrink-0`,children:o.about}),t[2]=o.about,t[3]=c);let l=`${r.pathname}${r.search}`,u;t[4]!==l||t[5]!==n.taskId?(u=$e(l,n.taskId),t[4]=l,t[5]=n.taskId,t[6]=u):u=t[6];let d=n.taskTitle,p=`${o.openTask}:${n.taskTitle}`,m;t[7]===n.taskTitle?m=t[8]:(m=ib(n.taskTitle),t[7]=n.taskTitle,t[8]=m);let g;t[9]===m?g=t[10]:(g=(0,X.jsxs)(`span`,{className:`truncate`,children:[`「`,m,`」`]}),t[9]=m,t[10]=g);let _;t[11]!==u||t[12]!==p||t[13]!==g||t[14]!==n.taskTitle?(_=(0,X.jsx)(h,{className:`inline-flex min-w-0 max-w-[min(48vw,30rem)] font-medium text-fg hover:text-accent hover:underline`,to:u,title:d,"aria-label":p,children:g}),t[11]=u,t[12]=p,t[13]=g,t[14]=n.taskTitle,t[15]=_):_=t[15];let v=o[n.kind],b;t[16]===v?b=t[17]:(b=(0,X.jsxs)(`span`,{className:`shrink-0 whitespace-nowrap`,children:[`· `,v]}),t[16]=v,t[17]=b);let x;return t[18]!==_||t[19]!==b||t[20]!==c||t[21]!==n.entryId?(x=(0,X.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:[c,_,b]}),t[18]=_,t[19]=b,t[20]=c,t[21]=n.entryId,t[22]=x):x=t[22],x}function ob(e){return e.language}var sb=3;function cb(e){let t=(0,Z.c)(38),{refs:n,groupLabel:r,noteLabel:i,fileLabel:a,folderLabel:o,sessionLabel:s,browserTabLabel:c,mcpResourceLabel:l,workbookLabel:u,truncatedLabel:d,showMoreLabel:f,showLessLabel:p,onOpen:m}=e,h=u===void 0?`Workbook`:u,[g,_]=(0,Q.useState)(!1);if(n.length===0)return null;let v=n.length>sb,y;t[0]!==g||t[1]!==n?(y=g?n:n.slice(0,sb),t[0]=g,t[1]=n,t[2]=y):y=t[2];let b=y,x=n.length-sb,S;if(t[3]!==c||t[4]!==a||t[5]!==o||t[6]!==r||t[7]!==l||t[8]!==i||t[9]!==m||t[10]!==s||t[11]!==d||t[12]!==b||t[13]!==h){let e;t[15]!==c||t[16]!==a||t[17]!==o||t[18]!==r||t[19]!==l||t[20]!==i||t[21]!==m||t[22]!==s||t[23]!==d||t[24]!==h?(e=e=>{let t=e.kind===`note`||e.kind===`workbook`,n=t?`button`:`div`,u=e.kind===`workbook`?h: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,X.jsxs)(n,{...t?{type:`button`,onClick:()=>m(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?d:e.title,children:[(0,X.jsx)(`span`,{className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md bg-accent-soft text-accent-fg`,children:e.kind===`workbook`?(0,X.jsx)(St,{className:`size-3.5`,"aria-hidden":!0}):e.kind===`file`&&e.fileKind===`directory`?(0,X.jsx)(Ae,{className:`size-3.5`,"aria-hidden":!0}):e.kind===`file`||e.kind===`result`?(0,X.jsx)(Ee,{className:`size-3.5`,"aria-hidden":!0}):e.kind===`session`?(0,X.jsx)(yt,{className:`size-3.5`,"aria-hidden":!0}):e.kind===`browser_tab`?(0,X.jsx)(N,{className:`size-3.5`,"aria-hidden":!0}):e.kind===`mcp_resource`?(0,X.jsx)(be,{className:`size-3.5`,"aria-hidden":!0}):(0,X.jsx)(lc,{className:`size-3.5`,"aria-hidden":!0})}),(0,X.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[(0,X.jsx)(`span`,{className:`shrink-0 text-[11px] text-fg-muted`,children:u}),(0,X.jsx)(`span`,{className:`max-w-56 truncate text-xs font-medium text-fg sm:max-w-72`,children:e.title})]}),t?(0,X.jsx)(ie,{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[15]=c,t[16]=a,t[17]=o,t[18]=r,t[19]=l,t[20]=i,t[21]=m,t[22]=s,t[23]=d,t[24]=h,t[25]=e):e=t[25],S=b.map(e),t[3]=c,t[4]=a,t[5]=o,t[6]=r,t[7]=l,t[8]=i,t[9]=m,t[10]=s,t[11]=d,t[12]=b,t[13]=h,t[14]=S}else S=t[14];let C;t[26]===S?C=t[27]:(C=(0,X.jsx)(`div`,{className:`flex min-w-0 flex-wrap gap-1.5`,children:S}),t[26]=S,t[27]=C);let w;t[28]!==v||t[29]!==g||t[30]!==x||t[31]!==p||t[32]!==f?(w=v?(0,X.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":g,onClick:()=>_(lb),children:[g?(0,X.jsx)(ae,{className:`size-3.5`,"aria-hidden":!0}):(0,X.jsx)(re,{className:`size-3.5`,"aria-hidden":!0}),g?p:f.replace(`{{count}}`,String(x))]}):null,t[28]=v,t[29]=g,t[30]=x,t[31]=p,t[32]=f,t[33]=w):w=t[33];let T;return t[34]!==r||t[35]!==C||t[36]!==w?(T=(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,role:`group`,"aria-label":r,children:[C,w]}),t[34]=r,t[35]=C,t[36]=w,t[37]=T):T=t[37],T}function lb(e){return!e}function ub(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 db(e){let t=(0,Z.c)(67),{open:n,onOpenChange:r,items:i,labels:a}=e,o;t[0]!==i||t[1]!==a.origins?(o=ub(i,a.origins),t[0]=i,t[1]=a.origins,t[2]=o):o=t[2];let s=o,c=s.reduce(hb,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(mb):[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(pb)))},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,b;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,X.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim/60 backdrop-blur-[1px]`}),t[16]=b):b=t[16];let x;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(x=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]=x):x=t[17];let S;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,X.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,X.jsx)(Js,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[18]=S):S=t[18];let C;t[19]===a.title?C=t[20]:(C=(0,X.jsx)(A,{className:`text-base font-semibold text-fg`,children:a.title}),t[19]=a.title,t[20]=C);let T;t[21]===a.hint?T=t[22]:(T=(0,X.jsx)(E,{className:`mt-1 text-sm leading-5 text-fg-muted`,children:a.hint}),t[21]=a.hint,t[22]=T);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,X.jsx)(`p`,{className:`mt-2 text-xs font-medium text-fg-subtle`,children:M}),t[26]=M,t[27]=N);let P;t[28]!==C||t[29]!==T||t[30]!==N?(P=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[C,T,N]}),t[28]=C,t[29]=T,t[30]=N,t[31]=P):P=t[31];let F;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,X.jsx)(an,{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,X.jsx)(D,{asChild:!0,children:(0,X.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,X.jsxs)(`header`,{className:`flex shrink-0 items-start gap-3 border-b border-edge-subtle px-4 py-4 sm:px-5`,children:[S,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,X.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,X.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,X.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,X.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel`,children:[(0,X.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,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-fg`,children:e.label}),(0,X.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,X.jsx)(re,{className:Y(`size-4 shrink-0 text-fg-subtle transition-transform duration-200`,t&&`rotate-180`),strokeWidth:1.75,"aria-hidden":!0})]}),t?(0,X.jsx)(`div`,{className:`border-t border-edge-subtle px-3.5`,children:e.items.map(fb)}):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,X.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,X.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,X.jsxs)(O,{children:[b,(0,X.jsxs)(k,{className:x,children:[L,V,U]})]}),t[59]=L,t[60]=V,t[61]=U,t[62]=W):W=t[62];let ee;return t[63]!==r||t[64]!==n||t[65]!==W?(ee=(0,X.jsx)(j,{open:n,onOpenChange:r,children:W}),t[63]=r,t[64]=n,t[65]=W,t[66]=ee):ee=t[66],ee}function fb(e){return(0,X.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 pb(e){return e.id}function mb(e){return e.id}function hb(e,t){return e+t.items.length}var gb=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`,Ma.disabled),_b=`mt-1 min-h-11 shrink-0 sm:min-h-9`,vb=[`misunderstood_intent`,`incorrect`,`did_not_act`,`tone_mismatch`,`too_verbose`,`other`],yb=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`,Ma.disabled),bb=700,xb=120,Sb=(0,Q.memo)(function({message:e,personal:t=!1,followUpTrigger:n,authToken:r,conversationId:i,workspaceConversationId:a,projectId:o,isStreaming:s,progress:c,reasoningLevel:l=`on`,messageIndex:u,onDeleteRound:d,onRetryUserMessageRound:m,userMessageCanRetry:g=!1,deleteRoundDisabled:v=!1,onSaveAssistantAsNote:x,onSaveAssistantToSourceNote:S,onExtractAssistantTask:w,onForkAssistantTurn:T,readonly:E=!1,density:D=`normal`,suppressAssistantActions:O=!1,onEditUserMessage:k,userMessageCanEdit:A=!0,responseFeedbackEnabled:j=!0,showAssistantWorkLog:M=!0}){let N=(0,Q.useMemo)(()=>Av(e,{hideSilentReply:jv(e,t),streaming:s}),[e,t,s]),F=y(e=>e.language),I=C(F),L=p(),R=f(),z=N.role===`user`,U=N.role===`assistant`,W=(0,Q.useRef)(z&&N.deliveryStatus===`sending`).current,ee=z&&N.deliveryStatus===`sending`,te=z&&N.deliveryStatus===`failed`,[ie,oe]=(0,Q.useState)(!1),[se,ce]=(0,Q.useState)(!1),[le,ue]=(0,Q.useState)(()=>typeof navigator<`u`&&navigator.onLine===!1),de=z?I.chat.you:U?I.chat.assistant:I.chat.tool;(0,Q.useEffect)(()=>{if(!ee||typeof window>`u`)return;let e=()=>ue(window.navigator.onLine===!1);return window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}},[ee]),(0,Q.useEffect)(()=>{if(ee){if(ie)return;let e=window.setTimeout(()=>oe(!0),le?0:bb);return()=>window.clearTimeout(e)}if(!ie)return;let e=0,t=window.requestAnimationFrame(()=>{ce(!0),e=window.setTimeout(()=>{oe(!1),ce(!1)},xb)});return()=>{window.cancelAnimationFrame(t),window.clearTimeout(e)}},[ee,le,ie]);let fe=te||ie,pe=te?`failed`:`sending`,me=(0,Q.useCallback)(e=>{let t=`${R.pathname}${R.search}`;L(et(t,e))},[R.pathname,R.search,L]),he=(0,Q.useMemo)(()=>({input:I.chat.toolInput,output:I.chat.toolOutput,noOutput:I.chat.noOutput}),[I.chat.toolInput,I.chat.toolOutput,I.chat.noOutput]),K=(0,Q.useMemo)(()=>({thoughts:I.chat.thoughts,thoughtsStreaming:I.chat.thoughtsStreaming,workLogTitle:I.chat.workLogTitle,workLogRunning:I.chat.workLogRunning,workLogComplete:I.chat.workLogComplete,workLogPartial:I.chat.workLogPartial,workLogFailed:I.chat.workLogFailed,searchedWeb:I.chat.stepSearchedWeb,searchedMemory:I.chat.stepSearchedMemory,searchedCode:I.chat.stepSearchedCode,searched:I.chat.stepSearched,readFile:I.chat.stepReadFile,stepDetails:I.chat.stepDetails,runCommand:I.chat.stepRunCommand,listDirectory:I.chat.stepListDirectory,writeFile:I.chat.stepWriteFile,editFile:I.chat.stepEditFile,openUrl:I.chat.stepOpenUrl,fetchUrl:I.chat.stepFetchUrl,unknownTool:I.chat.stepUnknownTool,rawThinking:I.chat.rawThinking,toolError:I.chat.toolError,toolActivity:I.chat.toolActivity,memoryActivity:I.chat.memoryActivity}),[I.chat.thoughts,I.chat.thoughtsStreaming,I.chat.workLogTitle,I.chat.workLogRunning,I.chat.workLogComplete,I.chat.workLogPartial,I.chat.workLogFailed,I.chat.stepSearchedWeb,I.chat.stepSearchedMemory,I.chat.stepSearchedCode,I.chat.stepSearched,I.chat.stepReadFile,I.chat.stepDetails,I.chat.stepRunCommand,I.chat.stepListDirectory,I.chat.stepWriteFile,I.chat.stepEditFile,I.chat.stepOpenUrl,I.chat.stepFetchUrl,I.chat.stepUnknownTool,I.chat.rawThinking,I.chat.toolError,I.chat.toolActivity,I.chat.memoryActivity]),ge=(0,Q.useMemo)(()=>({ing:I.chat.stepsClusterIng}),[I.chat.stepsClusterIng]),_e=(0,Q.useMemo)(()=>I.chat.toolCard,[I.chat.toolCard]),q=l===`off`,ve=(0,Q.useMemo)(()=>U?ny({message:N,isStreaming:s,reasoningLevel:l,personal:t}):null,[U,s,N,l,t]),[ye,be]=(0,Q.useState)(),xe=s&&U&&jv(N,t),Ce=xe?ve?.answerContent.findLast(e=>e.type===`text`&&!!(e.segmentId&&!e.hydrated&&e.text.trim())):void 0,Te=xe&&!ve?.answer.started&&ye?N.content.findLast(e=>e.type===`text`&&e.segmentId===ye):void 0,De=Ce?.segmentId??(Te?ye:void 0);De!==ye&&be(De);let Oe=(0,Q.useMemo)(()=>{if(!ve)return(N.content??[]).filter(e=>e.type!==`image`);let e=Te?[Te]:ve.answerContent;if(t)return e;if(!q&&M)return(N.content??[]).filter(e=>e.type!==`image`);let n=new Set(e);return(N.content??[]).filter(e=>n.has(e)||e.type===`tool_use`&&(e.status===`error`||e.activity?.status===`failed`))},[ve,N.content,t,q,Te,M]),ke=(0,Q.useMemo)(()=>ve?ve.attachments:N.attachments,[ve,N.attachments]),Ae=U&&!t&&!q&&M,je=nb({message:N,isStreaming:s,enabled:Ae,items:ve?.workLog.items??[],durationMs:N.completedAt==null?void 0:ve?.workLog.durationMs}),Me=(0,Q.useMemo)(()=>Ae?new Set(ve?.workLog.items):void 0,[Ae,ve]),Ne=(0,Q.useMemo)(()=>{let e=new Set(N.userTurnDocument?.parts.flatMap(e=>e.type===`context_ref`?[e.refId]:[])??[]);return N.contextRefs?.filter(t=>!t.refId||!e.has(t.refId))},[N.contextRefs,N.userTurnDocument]),Pe=!!(ve?.workLog.active||ve?.workLog.items.length),Fe=!!ve?.answer.started,Ie=q||U&&(Pe||Fe)?null:c,Le=!q&&!!N.content?.some(e=>e.type===`thinking`&&e.streaming),Re=U?!!ve?.answer.showStreamingCursor:s,ze=t&&U&&s&&!ve?.answer.started&&!Te&&!ke?.length,Be=s&&!Le&&(!U||!Pe&&!Fe),Ve=!!Ie?.message||Be,He=U&&!E&&!s&&!O,Ue=(N.taskResultDelivery?.outcome.deliverables??N.outcome?.deliverables)?.filter(e=>e.availability===`available`&&e.uri?.startsWith(`media://outbound/`)),We=U&&s&&!E&&!O&&Fe,Ge=(0,Q.useMemo)(()=>He?Wh(N.content??[]):``,[He,N]),qe=(0,Q.useMemo)(()=>He&&Ge?Kh(N.content??[]):``,[He,Ge,N]),Je=(0,Q.useMemo)(()=>He?Fv(e,u??0,i,F,I.chat.messageReadAloudTitle,t):void 0,[He,e,u,i,F,I.chat.messageReadAloudTitle,t]),Ye=(0,Q.useMemo)(()=>{if(!z)return``;if(N.userTurnDocument){let e=new Map(N.contextRefs?.flatMap(e=>e.refId?[[e.refId,e.title]]:[])??[]);return nr(N.userTurnDocument,t=>e.get(t))}return Zn(N.content)},[z,N.content,N.contextRefs,N.userTurnDocument]),[Xe,Ze]=(0,Q.useState)(null),[Qe,$e]=(0,Q.useState)(!1),[tt,nt]=(0,Q.useState)(null),[rt,it]=(0,Q.useState)(),at=N.transcriptEntryId?{entryId:N.transcriptEntryId}:N.turnId&&!N.taskResultDelivery?{turnId:N.turnId}:null,ot=at?.entryId??at?.turnId,st=rt?.entryId===ot?rt?.id:void 0,[ct,lt]=(0,Q.useState)(!1),ut=async()=>{if(!(!i||!at||!ot||ct)){lt(!0);try{let{id:e}=await pi(i,at);it({entryId:ot,id:e}),Ua(`success`,F===`zh`?`已保存到资料库`:`Saved to Space`,void 0,{href:`/space?item=${encodeURIComponent(e)}`})}catch{Ua(`error`,F===`zh`?`保存失败,请重试`:`Could not save to Space. Try again.`)}finally{lt(!1)}}},[dt,ft]=(0,Q.useState)(null),[pt,mt]=(0,Q.useState)(!1),[ht,gt]=(0,Q.useState)(null),[_t,vt]=(0,Q.useState)(!1),[yt,bt]=(0,Q.useState)(!1),[xt,St]=(0,Q.useState)(!1),[Ct,wt]=(0,Q.useState)(!1),[Tt,Et]=(0,Q.useState)(null),[Dt,Ot]=(0,Q.useState)([]),[kt,At]=(0,Q.useState)(!1),[Mt,Nt]=(0,Q.useState)(!1),[Pt,Ft]=(0,Q.useState)(null),[Lt,Rt]=(0,Q.useState)(!1),[zt,Bt]=(0,Q.useState)(!1),Vt=(0,Q.useRef)(null),Ht=(0,Q.useCallback)((e,t)=>{let n=Hh(e,t);n&&Ft(n)},[]),Ut=(0,Q.useCallback)(()=>{!i||!N.renderKey||Sr.getState().completeProgressiveRender(i,N.renderKey)},[N.renderKey,i]),Wt=(0,Q.useCallback)(()=>{qe&&ra(qe).then(e=>{e&&(Ze(`plain`),window.setTimeout(()=>Ze(e=>e===`plain`?null:e),2e3))})},[qe]),Gt=(0,Q.useCallback)(()=>{Ge&&ra(Ge).then(e=>{e&&(Ze(`markdown`),window.setTimeout(()=>Ze(e=>e===`markdown`?null:e),2e3))})},[Ge]),Kt=(0,Q.useCallback)(()=>{!Ge||!x||dt||(ft(`create-note`),Promise.resolve(x(Ge)).then(()=>{nt(`create-note`),window.setTimeout(()=>nt(e=>e===`create-note`?null:e),2e3)}).catch(()=>void 0).finally(()=>ft(null)))},[dt,Ge,x]),qt=(0,Q.useCallback)(()=>{!Ge||!S||dt||(ft(`save-source-note`),Promise.resolve(S(Ge)).then(()=>{nt(`save-source-note`),window.setTimeout(()=>nt(e=>e===`save-source-note`?null:e),2e3)}).catch(()=>void 0).finally(()=>ft(null)))},[dt,Ge,S]),Jt=(0,Q.useCallback)(()=>{!qe&&!Ge||!w||dt||(ft(`extract-task`),Promise.resolve(w(qe||Ge)).then(()=>{nt(`extract-task`),window.setTimeout(()=>nt(e=>e===`extract-task`?null:e),2e3)}).catch(()=>void 0).finally(()=>ft(null)))},[dt,Ge,qe,w]),Yt=(0,Q.useCallback)(()=>{Ye&&ra(Ye).then(e=>{e&&(Ze(`user`),window.setTimeout(()=>Ze(e=>e===`user`?null:e),2e3))})},[Ye]),Zt=(0,Q.useCallback)(()=>{!N.turnId||!T||pt||(mt(!0),Promise.resolve(T(N.turnId)).catch(()=>void 0).finally(()=>mt(!1)))},[pt,N.turnId,T]),Qt=(0,Q.useCallback)((e,t)=>{!N.turnId||yt||(bt(!0),vt(!0),St(!1),b(_(`/api/turns/${encodeURIComponent(N.turnId)}/execution-context/feedback`),{method:`POST`,body:JSON.stringify({rating:e===`helpful`?`helpful`:`irrelevant`,reason:t})}).then(()=>{gt(e),Et(t??null),wt(!1)}).catch(()=>St(!0)).finally(()=>bt(!1)))},[N.turnId,yt]),$t=(0,Q.useCallback)(()=>{Tt&&Qm(I.chat.messageFeedbackRepairPrompts[Tt])},[I.chat.messageFeedbackRepairPrompts,Tt]),en=(0,Q.useCallback)(()=>{!N.turnId||_t||yt||(bt(!0),b(_(`/api/turns/${encodeURIComponent(N.turnId)}/execution-context`)).then(e=>{Ot(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(()=>{vt(!0),bt(!1)}))},[N.turnId,yt,_t]),tn=(0,Q.useCallback)(()=>{u==null||!d||Nt(!0)},[u,d]),nn=(0,Q.useCallback)(()=>{u==null||!d||(d(u),Nt(!1))},[u,d]),rn=(0,Q.useCallback)(()=>{Nt(!1)},[]);(0,Q.useLayoutEffect)(()=>{if(!z)return;let e=Vt.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;Bt(e.scrollHeight>i*10+1)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[z,Oe,Ye]),(0,Q.useLayoutEffect)(()=>{Rt(!1)},[z,Ye]);let an=v||!g,on=ve&&$y(ve,M)&&(ve.workLog.active||ve.workLog.items.length>0)?(0,X.jsx)($_,{workLog:ve.workLog,pendingStatus:N.pendingResponseStatus,toolLabels:he,stepLabels:K,clusterLabels:ge,cardLabels:_e,conversationId:i,simplified:!t,personal:t,surfacesOnly:!t,answerStarted:ve.answer.started}):null;return(0,X.jsx)(of.Provider,{value:sf(ve?.deliveries??[]),children:(0,X.jsxs)(`article`,{className:Y(`group/msg flex w-full min-w-0`,z?`justify-end`:`justify-start`,U&&`@container/assistant-message`,N.clarificationChoice&&`flex-col items-end gap-3`,W&&`xopc-chat-user-message-enter`),children:[N.clarificationChoice?(0,X.jsxs)(`section`,{className:`w-full max-w-[var(--max-width-chat-reading)] self-start rounded-xl border border-edge-subtle bg-surface-base p-3 text-sm`,children:[(0,X.jsx)(`p`,{className:`mb-2 break-words font-medium text-fg`,children:N.clarificationChoice.question}),(0,X.jsx)(`ul`,{className:`space-y-1.5`,children:N.clarificationChoice.choices.map(e=>{let t=e.id===N.clarificationChoice?.choiceId;return(0,X.jsxs)(`li`,{className:Y(`flex items-center justify-between gap-2 rounded-lg border px-3 py-2`,t?`border-accent bg-accent-soft text-fg`:`border-edge-subtle text-fg-muted`),children:[(0,X.jsx)(`span`,{className:`min-w-0 break-words`,children:e.label}),t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`sr-only`,children:F===`zh`?`已选择`:`Selected`}),(0,X.jsx)(ne,{className:`size-4 shrink-0 text-accent-fg`,"aria-hidden":!0})]}):null]},e.id)})})]}):null,(0,X.jsxs)(`div`,{className:Y(`min-w-0`,z?`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)]`,E&&`max-w-full`,(We||Ge)&&`relative @min-[42rem]/assistant-message:min-h-9 @min-[42rem]/assistant-message:pe-32`),children:[(0,X.jsx)(`span`,{className:`sr-only`,children:de}),n?(0,X.jsx)(ab,{trigger:n}):null,z&&Ve?(0,X.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:[Ie?.message&&!Pe?(0,X.jsx)(`span`,{className:`text-fg-subtle`,title:Ie.detail??``,children:Ie.message}):null,Be&&!Ie?.message?(0,X.jsx)(`span`,{className:`text-fg-subtle`,children:I.chat.thinkingLabel}):null]}):null,!z&&Ve&&!ze?(0,X.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-baseline gap-x-2 gap-y-0.5 text-xs text-fg-disabled`,children:[Ie?.message&&!Pe?(0,X.jsx)(`span`,{className:`text-fg-subtle`,title:Ie.detail??``,children:Ie.message}):null,Be&&!Ie?.message?(0,X.jsx)(`span`,{className:`text-fg-subtle`,children:I.chat.thinkingLabel}):null]}):null,(0,X.jsxs)(`div`,{dir:z?`auto`:void 0,className:Y(`min-w-0 text-fg`,z&&`chat-user-message`,D===`compact`?`text-sm leading-relaxed`:z?`text-[0.9375rem] leading-[1.6667]`:`text-base leading-[1.6875]`,z&&`w-fit max-w-full rounded-2xl bg-surface-hover/80 px-4 py-3 text-left dark:bg-surface-hover/50`,z&&t&&`relative mt-2 pt-[18px]`,ze&&`bg-transparent p-0`),children:[z&&t&&!te&&N.agentReaction?(0,X.jsx)(`span`,{role:`img`,"aria-label":`${N.agentReaction.actorName} ${N.agentReaction.emoji}`,className:`pointer-events-none absolute -left-1 -top-[7px] grid h-[25px] w-[33px] select-none place-items-center rounded-full border border-edge bg-surface-panel text-[15px] leading-none`,children:N.agentReaction.emoji}):null,(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[ze?(0,X.jsx)(`div`,{className:`xopc-personal-thinking`,role:`status`,"aria-label":I.chat.thinkingLabel,children:(0,X.jsxs)(`span`,{className:`xopc-personal-thinking-dots`,"aria-hidden":`true`,children:[(0,X.jsx)(`i`,{}),(0,X.jsx)(`i`,{}),(0,X.jsx)(`i`,{})]})}):null,t?on:null,(Oe?.length??0)>0?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{ref:z?Vt:je.contentRef,"data-chat-find-text":!0,className:Y(`relative min-w-0`,`flex flex-col gap-3`,z&&!Lt&&`overflow-hidden`),style:z&&!Lt?{maxHeight:`calc(10lh)`}:void 0,children:[je.summary,(0,X.jsx)(Wg,{taskRunId:N.taskResultDelivery?.taskRunId,content:Oe,isUser:z,isAssistantMessageStreaming:U&&s,imagePreviewLabel:I.chat.attachmentPreviewImage,onImagePreview:Ht,conversationId:i,workspaceConversationId:a,projectId:o,progressiveRender:!!N.progressiveRender,onProgressiveRenderComplete:Ut,userTurnDocument:N.userTurnDocument,contextRefs:N.contextRefs,responseRunId:U?N.turnId:void 0,immediateFirstCommit:!0,processItems:Me,processCollapsed:je.collapsed,renderActivity:!t&&ve?(e,t)=>{let n=s&&(t||e.some(e=>e.type===`tool_use`&&e.status===`running`)),r=zv(e);return(0,X.jsx)($_,{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:l===`stream`&&n,startedAt:r.startedAt,durationMs:r.durationMs},toolLabels:he,stepLabels:K,clusterLabels:ge,cardLabels:_e,conversationId:i,simplified:!1,showThinking:!0,renderSurfaces:!1})}:void 0}),Re?(0,X.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]}),z&&zt?(0,X.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:()=>Rt(e=>!e),"aria-expanded":Lt,children:[Lt?(0,X.jsx)(ae,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}):(0,X.jsx)(re,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsx)(`span`,{children:Lt?I.chat.userMessageCollapse:I.chat.userMessageExpand})]}):null]}):null,t?null:on,!t&&ve&&!ve.answer.started&&s&&!Oe.some(e=>e.type===`thinking`||e.type===`tool_use`)?(0,X.jsx)($_,{workLog:{items:[],active:!0,status:`running`,compact:!0,expandedByDefault:!1},pendingStatus:N.pendingResponseStatus,toolLabels:he,stepLabels:K,clusterLabels:ge,cardLabels:_e,conversationId:i}):null,!z&&(st||N.taskResultDelivery||Ue?.length)?(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[st?(0,X.jsx)(h,{to:`/space?item=${encodeURIComponent(st)}`,className:`rounded-lg px-2 py-1 text-xs text-accent-fg hover:bg-surface-hover`,children:F===`zh`?`在资料库中查看回复`:`View reply in Space`}):null,N.taskResultDelivery&&!Ue?.length?(0,X.jsx)(Ch,{deliveryId:N.taskResultDelivery.deliveryId,title:N.taskResultDelivery.taskTitle,zh:F===`zh`}):null,Ue?.slice(0,8).map(e=>(0,X.jsx)(Sh,{file:e,zh:F===`zh`,readonly:E||s},e.artifactId))]}):null,!t&&!z&&N.taskResultDelivery&&i?(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,"data-result-follow-up":!0,children:[N.taskResultDelivery.resultRevision?(0,X.jsxs)(`span`,{className:`text-xs text-fg-muted`,"data-result-revision":!0,children:[F===`zh`?`成果版本`:`Result version`,` `,N.taskResultDelivery.resultRevision]}):null,[{sourceId:`body`,title:N.taskResultDelivery.taskTitle},...N.taskResultDelivery.outcome.deliverables.filter(e=>e.availability===`available`).map(e=>({sourceId:e.artifactId,title:e.title}))].map(e=>(0,X.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=N.taskResultDelivery;window.dispatchEvent(new CustomEvent(`chat-result-reference`,{detail:{conversationId:i,reference:{kind:`result`,sourceId:wc(t.deliveryId.replace(/^reply:/,``),e.sourceId),expectedVersion:Tc(t),title:e.title}}}))},children:[F===`zh`?`询问:`:`Ask about: `,e.title]},e.sourceId))]}):null,ve?(0,X.jsx)(Qy,{view:ve,authToken:r,conversationId:a??i,projectId:o,sourcesLabel:I.chat.searchSourcesHeading.replace(`{{count}}`,String(ve.sources.length))}):null,z&&N.sourceDevice?(0,X.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[F===`zh`?`来自 `:`From `,N.sourceDevice.name]}):null,z&&Ne?.length?(0,X.jsx)(cb,{refs:Ne,groupLabel:I.chat.commandPalette.contextLabel,noteLabel:I.chat.commandPalette.notesSection,fileLabel:I.chat.atMention.files,folderLabel:I.chat.atMention.folders,sessionLabel:I.chat.atMention.chats,browserTabLabel:I.chat.atMention.browserTabs,mcpResourceLabel:I.chat.atMention.mcpResources,workbookLabel:F===`zh`?`工作簿`:`Workbook`,truncatedLabel:I.chat.commandPalette.contextTruncated,showMoreLabel:I.chat.contextReferencesMore,showLessLabel:I.chat.contextReferencesLess,onOpen:e=>e.kind===`workbook`?L(hi(e.sourceId,e.version)):me(e.sourceId)}):null,z&&ke?.length?(0,X.jsx)(zh,{attachments:ke,authToken:r,conversationId:i,workspaceConversationId:a,layout:`user`,centerUserVoiceRow:Ye.length===0}):null]})]}),fe?(0,X.jsxs)(`div`,{"data-delivery-status":pe,role:te?`alert`:`status`,"aria-live":`polite`,"aria-hidden":se&&!te?!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`,te?`text-danger`:`text-fg-subtle`,se&&!te&&`opacity-0`),children:[te?(0,X.jsx)(G,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}):null,(0,X.jsx)(`span`,{children:te?I.chat.userMessageSendFailed:le&&ee?I.chat.userMessageWaitingForNetwork:I.chat.userMessageSending}),te&&m&&u!=null?(0,X.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:()=>m(u),children:I.chat.userMessageRetry}):null]}):null,!z&&N.personalProvenance&&!s&&(0,X.jsx)(Th,{provenance:N.personalProvenance}),z&&!s&&!E?(0,X.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:[m&&u!=null&&N.deliveryStatus!==`failed`?(0,X.jsxs)(`button`,{type:`button`,className:Y(yb,an&&`opacity-40`),onClick:()=>m(u),disabled:an,title:v?I.chat.userMessageActionsWait:g?I.chat.userMessageRetry:I.chat.userMessageRetryDisabledHint,"aria-label":I.chat.userMessageRetry,children:[(0,X.jsx)(It,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`max-w-[4.5rem] truncate sm:max-w-none`,children:I.chat.userMessageRetry})]}):null,(0,X.jsx)(`button`,{type:`button`,className:Y(yb,`size-8 px-0`),onClick:()=>{if(k&&u!=null){k(N,u);return}Qm(Ye,An(N.attachments))},disabled:!Ye&&!N.attachments?.length&&!N.contextRefs?.length||!A,title:A?v?I.chat.userMessageStopAndEdit:I.chat.userMessageEdit:I.chat.userMessageEditDisabledHint,"aria-label":I.chat.userMessageEdit,children:(0,X.jsx)(jt,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})}),(0,X.jsx)(`button`,{type:`button`,className:Y(yb,`size-8 px-0`),onClick:Yt,disabled:!Ye,title:Xe===`user`?I.chat.messageCopied:I.chat.userMessageCopy,"aria-label":Xe===`user`?I.chat.messageCopied:I.chat.userMessageCopy,children:Xe===`user`?(0,X.jsx)(ne,{className:`size-3.5 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}):(0,X.jsx)(J,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})}),d&&u!=null&&!v?(0,X.jsx)(`button`,{type:`button`,className:Y(yb,`size-8 px-0 hover:text-red-500 dark:hover:text-red-400`),onClick:tn,title:I.chat.userMessageDelete,"aria-label":I.chat.userMessageDelete,children:(0,X.jsx)(Xt,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})}):null]}):null,We?(0,X.jsx)(`div`,{"data-assistant-actions-placeholder":!0,className:Y(_b,`@min-[42rem]/assistant-message:hidden`),"aria-hidden":`true`}):null,He&&Ge?(0,X.jsx)(Dv,{children:(0,X.jsxs)(`div`,{"data-assistant-message-actions":!0,className:Y(_b,`flex items-center justify-end gap-1 overflow-visible transition-opacity duration-150 ease-out motion-reduce:transition-none`,`@min-[42rem]/assistant-message:absolute @min-[42rem]/assistant-message:end-0 @min-[42rem]/assistant-message:bottom-0 @min-[42rem]/assistant-message:mt-0`,`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`,(Qe||Ct||xt)&&`pointer-events-auto opacity-100`),children:[(0,X.jsx)(Ov,{label:Xe===`plain`?I.chat.messageCopied:I.chat.messageCopyPlainText,children:(0,X.jsx)(`button`,{type:`button`,className:gb,onClick:Wt,disabled:!qe,"aria-label":Xe===`plain`?I.chat.messageCopied:I.chat.messageCopyPlainText,children:Xe===`plain`?(0,X.jsx)(ne,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}):(0,X.jsx)(J,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})})}),Je?(0,X.jsx)(Ov,{label:I.chat.messageReadAloud,children:(0,X.jsx)(V,{input:Je,labels:{read:I.chat.messageReadAloud,preparing:I.chat.messageReadAloudPreparing,pause:I.chat.messageReadAloudPause,resume:I.chat.messageReadAloudResume,retry:I.chat.messageReadAloudRetry},hideNativeTitle:!0})}):null,(0,X.jsxs)(Zi,{open:Qe,onOpenChange:e=>{$e(e),e&&en()},children:[(0,X.jsx)(Ov,{label:I.chat.messageMoreActions,children:(0,X.jsx)($i,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:gb,"aria-label":I.chat.messageMoreActions,children:(0,X.jsx)(Se,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})})})}),(0,X.jsx)(Yi,{children:(0,X.jsxs)(Xi,{side:`bottom`,align:`end`,sideOffset:6,className:`z-[70] w-56 rounded-xl border border-edge bg-surface-overlay p-1.5 shadow-popover outline-none`,children:[(0,X.jsx)(Qi,{asChild:!0,children:(0,X.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,children:[Xe===`markdown`?(0,X.jsx)(ne,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,X.jsx)(we,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),Xe===`markdown`?I.chat.messageCopied:I.chat.messageCopyMarkdown]})}),T&&N.turnId?(0,X.jsx)(Qi,{asChild:!0,children:(0,X.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:Zt,disabled:pt,children:[(0,X.jsx)(tc,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),pt?I.chat.messageForkCreating:I.chat.messageForkFromHere]})}):null,i&&at&&!st?(0,X.jsx)(Qi,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,disabled:ct,onClick:()=>void ut(),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`,children:[(0,X.jsx)(P,{className:`size-4`,"aria-hidden":!0}),F===`zh`?`保存到资料库`:`Save to Space`]})}):null,x?(0,X.jsx)(Qi,{asChild:!0,children:(0,X.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:Kt,disabled:dt!==null,children:[tt===`create-note`?(0,X.jsx)(ne,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,X.jsx)(Qs,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),tt===`create-note`?I.chat.messageSavedToNote:I.chat.messageSaveToNote]})}):null,j&&i&&N.timestamp?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`my-1 border-t border-edge-subtle`,role:`separator`}),(0,X.jsx)(Qi,{asChild:!0,children:(0,X.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:()=>Qt(`helpful`),disabled:yt,"aria-pressed":ht===`helpful`,children:[(0,X.jsx)(H,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),I.chat.messageHelpful]})}),(0,X.jsx)(Qi,{asChild:!0,children:(0,X.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:()=>wt(e=>!e),disabled:yt,"aria-pressed":ht===`not_helpful`,children:[(0,X.jsx)(B,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),I.chat.messageNotHelpful]})})]}):null,xt?(0,X.jsx)(`p`,{className:`px-2.5 py-1 text-xs text-danger`,role:`status`,children:I.chat.messageFeedbackUnavailable}):null,Dt.length>0?(0,X.jsx)(Qi,{asChild:!0,children:(0,X.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(e=>!e),children:[(0,X.jsx)(Js,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),I.chat.messageWhyThisAnswer]})}):null,S?(0,X.jsx)(Qi,{asChild:!0,children:(0,X.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:qt,disabled:!Ge||dt!==null,children:[tt===`save-source-note`?(0,X.jsx)(ne,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,X.jsx)(Ee,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),tt===`save-source-note`?I.chat.messageSavedToSourceNote:I.chat.messageSaveToSourceNote]})}):null,w?(0,X.jsx)(Qi,{asChild:!0,children:(0,X.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:Jt,disabled:!qe&&!Ge||dt!==null,children:[tt===`extract-task`?(0,X.jsx)(ne,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,X.jsx)(Ke,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),tt===`extract-task`?I.chat.messageTaskExtracted:I.chat.messageExtractTask]})}):null]})})]})]})}):null,He&&Dt.length>0?(0,X.jsx)(db,{open:kt,onOpenChange:At,items:Dt,labels:{title:I.chat.messageWhyThisAnswer,hint:I.chat.messageWhyThisAnswerHint,close:I.chat.messageContextClose,itemsSummary:I.chat.messageContextItemsSummary,expandAll:I.chat.messageContextExpandAll,collapseAll:I.chat.messageContextCollapseAll,groupSummary:I.chat.messageContextGroupSummary,origins:I.chat.messageContextOrigins}}):null,He&&Ct?(0,X.jsxs)(`div`,{className:`mt-2 w-full max-w-xl rounded-xl border border-edge-subtle bg-surface-panel p-3`,children:[(0,X.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:I.chat.messageFeedbackReasonTitle}),(0,X.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:I.chat.messageFeedbackReasonHint}),(0,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:vb.map(e=>(0,X.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:yt,onClick:()=>Qt(`not_helpful`,e),children:I.chat.messageFeedbackReasons[e]},e))})]}):null,He&&ht===`not_helpful`&&Tt?(0,X.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:$t,children:[(0,X.jsx)(It,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),I.chat.messageFeedbackRepair]}):null]}),z&&d&&u!=null&&!E?(0,X.jsx)(go,{open:Mt,title:I.chat.userMessageDeleteConfirmTitle,description:I.chat.userMessageDeleteConfirm,confirmLabel:I.chat.userMessageDeleteOk,cancelLabel:I.chat.userMessageDeleteCancel,destructive:!0,onConfirm:nn,onCancel:rn}):null,(0,X.jsx)(qo,{open:Pt!==null,attachment:Pt,images:(N.content??[]).flatMap((e,t)=>{if(e.type!==`image`)return[];let n=Hh(e,t);return n?[n]:[]}),onAttachmentChange:Ft,authToken:r,conversationId:i,onClose:()=>Ft(null)})]})})}),Cb=(0,Q.memo)(function(e){let t=(0,Z.c)(3),n=ig(e.conversationId,e.message.renderKey)??e.message,r;return t[0]!==n||t[1]!==e?(r=(0,X.jsx)(Sb,{...e,message:n}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r}),wb=new Map;function Tb(e,t=`time`){let n=`${e??`default`}:${t}`,r=wb.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}),wb.set(n,r)),r}function Eb(e){return e?Tb().format(e):``}var Db=1800*1e3;function Ob(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function kb(e,t){return e?!t||!Ob(new Date(e),new Date(t))||e-t>=Db:!1}function Ab(e,t,n){let r=new Date(e),i=new Date(t),a=new Date(i);return a.setDate(i.getDate()-1),`${Ob(r,i)?n===`zh`?`今天`:`Today`:Ob(r,a)?n===`zh`?`昨天`:`Yesterday`:Tb(n,r.getFullYear()===i.getFullYear()?`date`:`year`).format(r)} ${Tb(n).format(r)}`}var jb=0,Mb=1,Nb=2,Pb=4;function Fb(e){return()=>e}function Ib(e){e()}function Lb(e,t){return n=>e(t(n))}function Rb(e,t){return()=>e(t)}function zb(e,t){return n=>e(t,n)}function Bb(e){return e!==void 0}function Vb(...e){return()=>{e.map(Ib)}}function Hb(){}function Ub(e,t){return t(e),e}function Wb(e,t){return t(e)}function Gb(...e){return e}function Kb(e,t){return e(Mb,t)}function qb(e,t){e(jb,t)}function Jb(e){e(Nb)}function Yb(e){return e(Pb)}function Xb(e,t){return Kb(e,zb(t,jb))}function Zb(e,t){let n=e(Mb,e=>{n(),t(e)});return n}function Qb(e){let t,n;return r=>i=>{t=i,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function $b(e,t){return e===t}function ex(e=$b){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function tx(e){return t=>n=>{e(n)&&t(n)}}function nx(e){return t=>Lb(t,e)}function rx(e){return t=>()=>{t(e)}}function $(e,...t){let n=cx(...t);return((t,r)=>{switch(t){case Nb:Jb(e);return;case Mb:return Kb(e,n(r))}})}function ix(e,t){return n=>r=>{n(t=e(t,r))}}function ax(e){return t=>n=>{e>0?e--:t(n)}}function ox(e){let t=null,n;return r=>i=>{t=i,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function sx(...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;Kb(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 cx(...e){return t=>e.reduceRight(Wb,t)}function lx(e){let t,n,r=()=>t?.();return function(i,a){switch(i){case Mb:return a?n===a?void 0:(r(),n=a,t=Kb(e,a),t):(r(),Hb);case Nb:r(),n=null;return}}}function ux(e){let t=e,n=fx();return((e,r)=>{switch(e){case jb:t=r;break;case Mb:r(t);break;case Pb:return t}return n(e,r)})}function dx(e,t){return Ub(ux(t),t=>Xb(e,t))}function fx(){let e=[];return((t,n)=>{switch(t){case jb:e.slice().forEach(e=>{e(n)});return;case Nb:e.splice(0);return;case Mb:return e.push(n),()=>{let t=e.indexOf(n);t>-1&&e.splice(t,1)}}})}function px(e){return Ub(fx(),t=>Xb(e,t))}var mx={singleton:!0};function hx(e,t=[],n=mx){let{singleton:r}=n;return{constructor:e,dependencies:t,id:gx(),singleton:r}}var gx=()=>Symbol(`id`);function _x(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 vx(...e){let t=fx(),n=Array.from({length:e.length}),r=0,i=2**e.length-1;return e.forEach((e,a)=>{let o=2**a;Kb(e,e=>{n[a]=e,r|=o,r===i&&qb(t,n)})}),function(e,a){switch(e){case Nb:Jb(t);return;case Mb:return r===i&&a(n),Kb(t,a)}}}function yx(e,t=$b){return $(e,ex(t))}function bx(...e){return function(t,n){switch(t){case Nb:return;case Mb:return Vb(...e.map(e=>Kb(e,n)))}}}var xx={DEBUG:0,INFO:1,WARN:2,ERROR:3},Sx={[xx.DEBUG]:`debug`,[xx.ERROR]:`error`,[xx.INFO]:`log`,[xx.WARN]:`warn`},Cx=()=>typeof globalThis>`u`?window:globalThis,wx=hx(()=>{let e=ux(xx.ERROR);return{log:ux((t,n,r=xx.INFO)=>{r>=(Cx().VIRTUOSO_LOG_LEVEL??Yb(e))&&console[Sx[r]](`%creact-virtuoso: %c%s %o`,`color: #0253b3; font-weight: bold`,`color: initial`,t,n)}),logLevel:e}},[],{singleton:!0});function Tx(e){return`self`in e?e.document.documentElement:e}function Ex(e){let t=Tx(e);return t.ownerDocument.defaultView.getComputedStyle(t).direction===`rtl`}function Dx(e,t){return Ex(e)?-t:t}function Ox(e,t){return Ex(e)?-t:t}function kx(e,t,n){return Ax(e,t,n).callbackRef}function Ax(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 jx(e,t,n,r,i,a,o,s,c){return Ax(Q.useCallback(n=>{let c=Mx(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?Dx(o,o.scrollLeft):o.scrollTop:u?s?Dx(d,d.scrollX||d.document.documentElement.scrollLeft):d.scrollY||d.document.documentElement.scrollTop:s?Dx(l,l.scrollLeft):l.scrollTop;r({scrollHeight:f,scrollTop:Math.max(m,0),viewportHeight:p}),a?.(s?Nx(`column-gap`,getComputedStyle(n).columnGap,i):Nx(`row-gap`,getComputedStyle(n).rowGap,i)),c!==null&&e(c)},[e,t,i,a,o,r,s]),n,c)}function Mx(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},xx.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 Nx(e,t,n){return t!==`normal`&&t?.endsWith(`px`)!==!0&&n(`${e} was not resolved to pixel value correctly`,t,xx.WARN),t===`normal`?0:parseInt(t??`0`,10)}var Px=typeof document>`u`?Q.useEffect:Q.useLayoutEffect;function Fx(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}=Ax(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 Ix=hx(()=>{let e=fx(),t=fx(),n=ux(0),r=fx(),i=fx(),a=ux(0),o=fx(),s=fx(),c=ux(0),l=ux(0),u=ux(0),d=ux(0),f=fx(),p=fx(),m=ux(!1),h=ux(!1),g=ux(!1);return Xb($(e,nx(({scrollTop:e})=>e)),t),Xb($(e,nx(({scrollHeight:e})=>e)),s),Xb(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}),Lx={lvl:0};function Rx(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 zx(e){return e===Lx}function Bx(e,t){if(!zx(e))return t===e.k?e.v:t<e.k?Bx(e.l,t):Bx(e.r,t)}function Vx(e,t,n=`k`){if(zx(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){let r=Vx(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return Vx(e.l,t,n)}function Hx(e,t,n){return zx(e)?$x(t,n,1):t===e.k?Yx(e,{k:t,v:n}):t<e.k?eS(Yx(e,{l:Hx(e.l,t,n)})):eS(Yx(e,{r:Hx(e.r,t,n)}))}function Ux(){return Lx}function Wx(e,t,n){if(zx(e))return[];let r=Vx(e,t)[0];return rS(qx(e,r,n))}function Gx(e,t){if(zx(e))return Lx;let{k:n,l:r,r:i}=e;if(t===n){if(zx(r))return i;if(zx(i))return r;let[t,n]=Qx(r);return Jx(Yx(e,{k:t,l:Xx(r),v:n}))}return Jx(t<n?Yx(e,{l:Gx(r,t)}):Yx(e,{r:Gx(i,t)}))}function Kx(e){return zx(e)?[]:[...Kx(e.l),{k:e.k,v:e.v},...Kx(e.r)]}function qx(e,t,n){if(zx(e))return[];let{k:r,l:i,r:a,v:o}=e,s=[];return r>t&&(s=s.concat(qx(i,t,n))),r>=t&&r<=n&&s.push({k:r,v:o}),r<=n&&(s=s.concat(qx(a,t,n))),s}function Jx(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(Zx(t))return tS(Yx(e,{lvl:n-1}));if(!zx(t)&&!zx(t.r))return Yx(t.r,{l:Yx(t,{r:t.r.l}),lvl:n,r:Yx(e,{l:t.r.r,lvl:n-1})});throw Error(`Unexpected empty nodes`)}if(Zx(e))return nS(Yx(e,{lvl:n-1}));if(!zx(r)&&!zx(r.l)){let t=r.l,i=Zx(t)?r.lvl-1:r.lvl;return Yx(t,{l:Yx(e,{lvl:n-1,r:t.l}),lvl:t.lvl+1,r:nS(Yx(r,{l:t.r,lvl:i}))})}throw Error(`Unexpected empty nodes`)}function Yx(e,t){return $x(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 Xx(e){return zx(e.r)?e.l:Jx(Yx(e,{r:Xx(e.r)}))}function Zx(e){return zx(e)||e.lvl>e.r.lvl}function Qx(e){return zx(e.r)?[e.k,e.v]:Qx(e.r)}function $x(e,t,n,r=Lx,i=Lx){return{k:e,l:r,lvl:n,r:i,v:t}}function eS(e){return nS(tS(e))}function tS(e){let{l:t}=e;return!zx(t)&&t.lvl===e.lvl?Yx(t,{r:Yx(e,{l:t.r})}):e}function nS(e){let{lvl:t,r:n}=e;return!zx(n)&&!zx(n.r)&&n.lvl===t&&n.r.lvl===t?Yx(n,{l:Yx(e,{r:n.l}),lvl:t+1}):e}function rS(e){return Rx(e,({k:e,v:t})=>({index:e,value:t}))}function iS(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function aS(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}var oS=hx(()=>({recalcInProgress:ux(!1)}),[],{singleton:!0});function sS(e,t,n){return e[cS(e,t,n)]}function cS(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 lS(e,t,n,r){let i=cS(e,t,r),a=cS(e,n,r,i);return e.slice(i,a+1)}function uS(e,t){return Math.round(e.getBoundingClientRect()[t])}function dS(e){return!zx(e.groupOffsetTree)}function fS({index:e},t){return t===e?0:t<e?-1:1}function pS(){return{groupIndices:[],groupOffsetTree:Ux(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Ux()}}function mS(e,t){let n=zx(e)?0:1/0;for(let r of t){let{endIndex:t,size:i,startIndex:a}=r;if(n=Math.min(n,a),zx(e)){e=Hx(e,0,i);continue}let o=Wx(e,a-1,t+1);if(o.some(ES(r)))continue;let s=!1,c=!1;for(let{end:n,start:r,value:a}of o)s?(t>=r||i===a)&&(e=Gx(e,r)):(c=a!==i,s=!0),n>t&&t>=r&&a!==i&&(e=Hx(e,t+1,a));c&&(e=Hx(e,a,i))}return[e,n]}function hS(e){return e.groupIndex!==void 0}function gS({offset:e},t){return t===e?0:t<e?-1:1}function _S(e,t,n){if(t.length===0)return 0;let{index:r,offset:i,size:a}=sS(t,e,fS),o=e-r,s=a*o+(o-1)*n+i;return s>0?s+n:s}function vS(e,t){if(!dS(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function yS(e,t,n){if(hS(e))return t.groupIndices[e.groupIndex]+1;let r=vS(e.index===`LAST`?n:e.index,t);return r=Math.max(0,Math.min(n,r)),r}function bS(e,t,n,r=0){return r>0&&(t=Math.max(t,sS(e,r,fS).offset)),Rx(lS(e,t,n,gS),TS)}function xS(e,[t,n,r,i]){t.length>0&&r(`received item sizes`,t,xx.DEBUG);let a=e.sizeTree,o=a,s=0;if(n.length>0&&zx(a)&&t.length===2){let e=t[0].size,r=t[1].size;o=n.reduce((t,n)=>Hx(Hx(t,n,e),n+1,r),o)}else[o,s]=mS(o,t);if(o===a)return e;let{lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d}=wS(e.offsetTree,s,o,i);return{groupIndices:n,groupOffsetTree:n.reduce((e,t)=>Hx(e,t,_S(t,d,i)),Ux()),lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d,sizeTree:o}}function SS(e){return Kx(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 CS(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 wS(e,t,n,r){let i=e,a=0,o=0,s=0,c=0;if(t===0)i=[];else{c=cS(i,t-1,fS),s=i[c].offset;let e=Vx(n,t-1);a=e[0],o=e[1],i.length&&i[c].size===Vx(n,t)[1]&&--c,i=i.slice(0,c+1)}for(let{start:e,value:c}of Wx(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 TS(e){return{index:e.index,value:e}}function ES(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 DS={offsetHeight:`height`,offsetWidth:`width`},OS=hx(([{log:e},{recalcInProgress:t}])=>{let n=fx(),r=fx(),i=dx(r,0),a=fx(),o=fx(),s=ux(0),c=ux([]),l=ux(void 0),u=ux(void 0),d=ux(void 0),f=ux(void 0),p=ux((e,t)=>uS(e,DS[t])),m=ux(void 0),h=ux(0),g=pS(),_=dx($(n,sx(c,e,h),ix(xS,g),ex()),g),v=dx($(c,ex(),ix((e,t)=>({current:t,prev:e.current}),{current:[],prev:[]}),nx(({prev:e})=>e)),[]);Xb($(c,tx(e=>e.length>0),sx(_,h),nx(([e,t,n])=>{let r=e.reduce((e,r,i)=>Hx(e,r,_S(r,t.offsetTree,n)||i),Ux());return{...t,groupIndices:e,groupOffsetTree:r}})),_),Xb($(r,sx(_),tx(([e,{lastIndex:t}])=>e<t),nx(([e,{lastIndex:t,lastSize:n}])=>[{endIndex:t,size:n,startIndex:e}])),n),Xb(l,u);let y=dx($(l,nx(e=>e===void 0)),!0);Xb($(u,tx(e=>e!==void 0&&zx(Yb(_).sizeTree)),nx(e=>{let t=Yb(d),n=Yb(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),Xb($(f,tx(e=>e!==void 0&&e.length>0&&zx(Yb(_).sizeTree)),nx(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),Xb($(c,sx(d,u),tx(([,e,t])=>e!==void 0&&t!==void 0),nx(([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=px($(n,sx(_),ix(({sizes:e},[t,n])=>({changed:n!==e,sizes:n}),{changed:!1,sizes:g}),nx(e=>e.changed)));Kb($(s,ix((e,t)=>({diff:e.prev-t,prev:t}),{diff:0,prev:0}),nx(e=>e.diff)),e=>{let{groupIndices:n}=Yb(_);if(e>0)qb(t,!0),qb(a,e+CS(e,n));else if(e<0){let t=Yb(v);t.length>0&&(e-=CS(-e,t)),qb(o,e)}}),Kb($(s,sx(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},xx.ERROR)});let x=px(a);Xb($(a,sx(_),nx(([e,t])=>{let n=t.groupIndices.length>0,r=[],i=t.lastSize;if(n){let n=Bx(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=Kx(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 Kx(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=px($(o,sx(_,h),nx(([e,{offsetTree:t},n])=>_S(-e,t,n))));return Xb($(o,sx(_,h),nx(([e,t,n])=>{if(t.groupIndices.length>0){if(zx(t.sizeTree))return t;let r=Ux(),i=Yb(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=Kx(t.sizeTree).reduce((t,{k:n,v:r})=>Hx(t,Math.max(0,n+e),r),r),a!==-e){let n=Bx(t.sizeTree,s);r=Hx(r,0,n);let i=Vx(t.sizeTree,-e+1)[1];r=Hx(r,1,i)}return{...t,sizeTree:r,...wS(t.offsetTree,0,r,n)}}let r=Kx(t.sizeTree).reduce((t,{k:n,v:r})=>Hx(t,Math.max(0,n+e),r),Ux());return{...t,sizeTree:r,...wS(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}},Gb(wx,oS),{singleton:!0});function kS(e){return e.reduce((e,t)=>(e.groupIndices.push(e.totalCount),e.totalCount+=t+1,e),{groupIndices:[],totalCount:0})}var AS=hx(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:i}])=>{let a=fx(),o=fx(),s=px($(a,nx(kS)));return Xb($(s,nx(e=>e.totalCount)),n),Xb($(s,nx(e=>e.groupIndices)),e),Xb($(vx(i,t,r),tx(([e,t])=>dS(t)),nx(([e,t,n])=>Vx(t.groupOffsetTree,Math.max(e-n,0),`v`)[0]),ex(),nx(e=>[e])),o),{groupCounts:a,topItemsIndexes:o}},Gb(OS,Ix)),jS=hx(([{log:e}])=>{let t=ux(!1),n=px($(t,tx(e=>e),ex()));return Kb(t,t=>{t&&Yb(e)(`props updated`,{},xx.DEBUG)}),{didMount:n,propsReady:t}},Gb(wx),{singleton:!0}),MS=typeof document<`u`&&`scrollBehavior`in document.documentElement.style;function NS(e){let t=typeof e==`number`?{index:e}:{...e};return t.align||=`start`,(!t.behavior||!MS)&&(t.behavior=`auto`),t.offset===void 0&&(t.offset=0),t}var PS=hx(([{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=fx(),m=fx(),h=ux(0),g=null,_=null,v=null;function y(){g!==null&&(g(),g=null),v!==null&&(v(),v=null),_&&=(clearTimeout(_),null),qb(c,!1)}return Xb($(p,sx(n,d,r,h,s,o,f),sx(e,a,i),nx(([[e,n,r,i,a,o,s,l],d,f,h])=>{let b=NS(e),{align:x,behavior:S,offset:C}=b,w=i-1,T=yS(b,n,w),E=_S(T,n.offsetTree,d)+o;x===`end`?(E+=f+Vx(n.sizeTree,T)[1]-r+h,T===w&&(E+=s)):x===`center`?E+=(f+Vx(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},xx.DEBUG),qb(p,e)):(qb(m,!0),l(`list did not change, scroll successful`,{},xx.DEBUG))};if(y(),S===`smooth`){let e=!1;v=Kb(t,t=>{e||=t}),g=Zb(u,()=>{D(e)})}else g=Zb($(t,FS(150)),D);return _=setTimeout(()=>{y()},1200),qb(c,!0),l(`scrolling from index to`,{behavior:S,index:T,top:E},xx.DEBUG),{behavior:S,top:E}})),l),{scrollTargetReached:m,scrollToIndex:p,topListHeight:h}},Gb(OS,Ix,wx),{singleton:!0});function FS(e){return t=>{let n=setTimeout(()=>{t(!1)},e);return e=>{e&&(t(!0),clearTimeout(n))}}}function IS(e,t){e===0?t():requestAnimationFrame(()=>{IS(e-1,t)})}function LS(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 RS(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 zS=hx(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:i,scrollToIndex:a},{didMount:o}])=>{let s=ux(!0),c=ux(0),l=ux(!0);return Xb($(o,sx(c),tx(([e,t])=>!RS(t)),rx(!1)),s),Xb($(o,sx(c),tx(([e,t])=>!RS(t)),rx(!1)),l),Kb($(vx(t,o),sx(s,n,e,l),tx(([[,e],t,{sizeTree:n},r,i])=>e&&(!zx(n)||Bb(r))&&!t&&!i),sx(c)),([,e])=>{if(e===void 0){qb(s,!0),qb(l,!0);return}Zb(i,()=>{qb(l,!0)}),IS(4,()=>{Zb(r,()=>{qb(s,!0)}),qb(a,e)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:c,scrolledToInitialItem:s}},Gb(OS,Ix,PS,jS),{singleton:!0});function BS(e,t){return Math.abs(e-t)<1.01}var VS=`up`,HS=`down`,US=`none`,WS={atBottom:!1,notAtBottomBecause:`NOT_SHOWING_LAST_ITEM`,state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},GS=0,KS=hx(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:i,viewportHeight:a}])=>{let o=ux(!1),s=ux(!0),c=fx(),l=fx(),u=ux(4),d=ux(GS),f=dx($(bx($(yx(i),ax(1),rx(!0)),$(yx(i),ax(1),rx(!1),Qb(100))),ex()),!1),p=dx($(bx($(n,rx(!0)),$(n,rx(!1),Qb(200))),ex()),!1);Xb($(vx(yx(i),yx(d)),nx(([e,t])=>e<=t),ex()),s),Xb($(s,ox(50)),l);let m=px($(vx(r,yx(a),yx(t),yx(e),yx(u)),ix((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}},WS),ex((e,t)=>e!==void 0&&e.atBottom===t.atBottom))),h=dx($(r,ix((e,{scrollHeight:t,scrollTop:n,viewportHeight:r})=>{if(!BS(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}),tx(e=>e.changed),nx(e=>e.jump)),0);Xb($(m,nx(e=>e.atBottom)),o),Xb($(o,ox(50)),c);let g=ux(HS);Xb($(r,nx(({scrollTop:e})=>e),ex(),ix((e,t)=>Yb(p)?{direction:e.direction,prevScrollTop:t}:{direction:t<e.prevScrollTop?VS:HS,prevScrollTop:t},{direction:HS,prevScrollTop:0}),nx(e=>e.direction)),g),Xb($(r,ox(50),rx(US)),g);let _=ux(0);return Xb($(f,tx(e=>!e),rx(0)),_),Xb($(i,ox(100),sx(f),tx(([e,t])=>t),ix(([e,t],[n])=>[t,n],[0,0]),nx(([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:_}},Gb(Ix)),qS=`top`,JS=`bottom`,YS=`none`;function XS(e,t,n){return typeof e==`number`?n===VS&&t===qS||n===HS&&t===JS?e:0:n===VS?t===qS?e.main:e.reverse:t===JS?e.main:e.reverse}function ZS(e,t){return typeof e==`number`?e:e[t]??0}var QS=hx(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:i}])=>{let a=fx(),o=ux(0),s=ux(0),c=ux(0);return{increaseViewportBy:s,listBoundary:a,overscan:c,topListHeight:o,visibleRange:dx($(vx(yx(r),yx(i),yx(n),yx(a,aS),yx(c),yx(o),yx(t),yx(e),yx(s)),nx(([e,t,n,[r,i],a,o,s,c,l])=>{let u=e-c,d=o+s,f=Math.max(n-u,0),p=YS,m=ZS(l,qS),h=ZS(l,JS);return r-=c,r+=n+s,i+=n+s,i-=c,r>e+d-m&&(p=VS),i<e-f+t+h&&(p=HS),p===YS?null:[Math.max(u-n-XS(a,qS,p)-m,0),u-f-s+t+XS(a,JS,p)+h]}),tx(e=>e!==null),ex(aS)),[0,0])}},Gb(Ix),{singleton:!0});function $S(e,t,n){if(dS(t)){let r=vS(e,t);return[{index:Vx(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 eC={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function tC(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:rC(e,i,a),offsetBottom:m,offsetTop:l,top:p,topItems:rC(t,i,a),topListHeight:t.reduce((e,t)=>t.size+e,0),totalCount:n}}function nC(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=LS(t,c?l:s),d=c?Math.max(0,Math.min(s,l-u)):s;return tC(Array.from({length:d}).map((e,t)=>({data:a?.[t+u],index:t+u,offset:0,size:0})),[],d,i,n,r)}function rC(e,t,n){if(e.length===0)return[];if(!dS(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=Wx(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 iC(e,t){return e===void 0?0:typeof e==`number`?e:e[t]??0}var aC=hx(([{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=ux([]),g=ux(0),_=fx(),v=ux(0);Xb(a.topItemsIndexes,h);let y=dx($(vx(p,m,yx(c,aS),yx(i),yx(r),yx(l),u,yx(h),yx(t),yx(n),yx(v),e,yx(g)),tx(([e,t,,n,,,,,,,,r])=>{let i=r!==void 0&&r.length!==n;return e&&!t&&!i}),nx(([,,[e,t],n,r,i,a,o,s,c,l,u,d])=>{let f=r,{offsetTree:p,sizeTree:m}=f;if(n===0)return{...eC,totalCount:n};if(e===0&&t===0)return d===0?{...eC,totalCount:n}:nC(d,i,r,s,c,u);if(zx(m))return d>0?null:tC($S(LS(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 Wx(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 tC([],h,n,c,f,s);let g=o.length>0?o[o.length-1]+1:0,_=bS(p,e,t,g);if(_.length===0)return null;let v=n-1,y=Ub([],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=iC(l,qS),x=iC(l,JS);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=Wx(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=Wx(m,r,r)[0]?.value??t.size;y.push({data:u?.[r],index:r,offset:n,size:e}),n+=e+c}}}return tC(y,h,n,c,f,s)}),tx(e=>e!==null),ex()),eC);Xb($(e,tx(Bb),nx(e=>e?.length)),i),Xb($(y,nx(e=>e.topListHeight)),d),Xb(d,s),Xb($(y,nx(e=>[e.top,e.bottom])),o),Xb($(y,nx(e=>e.items)),_);let b=px($(y,tx(({items:e})=>e.length>0),sx(i,e),tx(([{items:e},t])=>e[e.length-1].originalIndex===t-1),nx(([,e,t])=>[e-1,t]),ex(aS),nx(([e])=>e))),x=px($(y,ox(200),tx(({items:e,topItems:t})=>e.length>0&&e[0].originalIndex===t.length),nx(({items:e})=>e[0].index),ex()));return{endReached:b,initialItemCount:g,itemsRendered:_,listState:y,minOverscanItemCount:v,rangeChanged:px($(y,tx(({items:e})=>e.length>0),nx(({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}}),ex(iS))),startReached:x,topItemsIndexes:h,...f}},Gb(OS,AS,QS,zS,PS,KS,jS,oS),{singleton:!0}),oC=hx(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:i}])=>{let a=fx(),o=dx($(vx(n,e,r,t,i),nx(([e,t,n,r,i])=>e+t+n+r+i.offsetBottom+i.bottom)),0);return Xb(yx(o),a),{totalListHeight:o,totalListHeightChanged:a}},Gb(Ix,aC),{singleton:!0}),sC=hx(([{viewportHeight:e},{totalListHeight:t}])=>{let n=ux(!1);return{alignToBottom:n,paddingTopAddition:dx($(vx(n,e,t),tx(([e])=>e),nx(([,e,t])=>Math.max(0,e-t)),ox(0),ex()),0)}},Gb(Ix,oC),{singleton:!0}),cC=hx(()=>({context:ux(null)})),lC=({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,uC=hx(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:i,headerHeight:a,scrollingInProgress:o,scrollTop:s,viewportHeight:c},{scrollToIndex:l}])=>{let u=fx();return Xb($(u,sx(t,c,n,a,i,r,s),sx(e),nx(([[e,t,n,r,i,a,s,c],l])=>{let{calculateViewLocation:u=lC,done:d,...f}=e,p=yS(e,t,r-1),m=_S(p,t.offsetTree,l)+i+a,h=m+Vx(t.sizeTree,p)[1],g=c+a,_=u({itemBottom:h,itemTop:m,locationParams:f,viewportBottom:c+n-s,viewportTop:g});return _===null?d?.():d&&Zb($(o,tx(e=>!e),ax(Yb(o)?1:2)),d),_}),tx(e=>e!==null)),l),{scrollIntoView:u}},Gb(OS,Ix,PS,aC,wx),{singleton:!0});function dC(e){return e===!1?!1:e===`smooth`?`smooth`:`auto`}var fC=(e,t)=>typeof e==`function`?dC(e(t)):t&&dC(e),pC=hx(([{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=ux(!1),h=fx(),g=null;function _(e){qb(o,{align:`end`,behavior:e,index:`LAST`})}Kb($(vx($(yx(t),ax(1)),c),sx(yx(m),a,s,d),nx(([[e,t],n,r,i,a])=>{let o=t&&i,s=`auto`;return o&&(s=fC(n,r||a),o&&=s!==!1),{followOutputBehavior:s,shouldFollow:o,totalCount:e}}),tx(({shouldFollow:e})=>e)),({followOutputBehavior:t,totalCount:r})=>{g!==null&&(g(),g=null),Yb(n)===void 0?g=Zb(e,()=>{Yb(u)(`following output to `,{totalCount:r},xx.DEBUG),_(t),g=null}):requestAnimationFrame(()=>{Yb(u)(`following output to `,{totalCount:r},xx.DEBUG),_(t)})});function v(e){let t=Zb(i,t=>{e&&!t.atBottom&&t.notAtBottomBecause===`SIZE_INCREASED`&&g===null&&(Yb(u)(`scrolling to bottom due to increased size`,{},xx.DEBUG),_(`auto`))});setTimeout(t,100)}Kb($(vx(yx(m),t,l),tx(([e,,t])=>e!==!1&&t),ix(({value:e},[,t])=>({refreshed:e===t,value:t}),{refreshed:!1,value:0}),tx(({refreshed:e})=>e),sx(m,t)),([,e])=>{Yb(s)&&v(e!==!1)}),Kb(h,()=>{v(Yb(m)!==!1)}),Kb(vx(yx(m),i),([e,t])=>{e!==!1&&!t.atBottom&&t.notAtBottomBecause===`VIEWPORT_HEIGHT_DECREASING`&&_(`auto`)});let y=ux(null),b=fx();return Xb(bx($(yx(r),nx(e=>e?.length??0)),$(yx(t))),b),Kb($(vx($(b,ax(1)),c),sx(yx(y),s,d,f),nx(([[e,t],n,r,i,a])=>t&&r&&n?.({context:a,totalCount:e,scrollingInProgress:i})),tx(e=>!!e),ox(0)),t=>{g!==null&&(g(),g=null),Yb(n)===void 0?g=Zb(e,()=>{Yb(u)(`scrolling into view`,{}),qb(p,t),g=null}):requestAnimationFrame(()=>{Yb(u)(`scrolling into view`,{}),qb(p,t)})}),{autoscrollToBottom:h,followOutput:m,scrollIntoViewOnChange:y}},Gb(OS,KS,PS,zS,jS,wx,Ix,cC,uC)),mC=hx(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:i},{initialItemCount:a,listState:o},{didMount:s}])=>(Xb($(s,sx(a),tx(([,e])=>e!==0),sx(i,r,t,n,e),nx(([[,e],t,n,r,i,a])=>nC(e,t,n,r,i,a))),o),{}),Gb(OS,zS,aC,jS),{singleton:!0}),hC=hx(([{didMount:e},{scrollTo:t},{listState:n}])=>{let r=ux(0);return Kb($(e,sx(r),tx(([,e])=>e!==0),nx(([,e])=>({top:e}))),e=>{Zb($(n,ax(1),tx(e=>e.items.length>1)),()=>{requestAnimationFrame(()=>{qb(t,e)})})}),{initialScrollTop:r}},Gb(jS,Ix,aC),{singleton:!0}),gC=hx(([{scrollVelocity:e}])=>{let t=ux(!1),n=fx(),r=ux(!1);return Xb($(e,sx(r,t,n),tx(([e,t])=>t!==!1&&t!==void 0),nx(([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}),ex()),t),Kb($(vx(t,e,n),sx(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}},Gb(KS),{singleton:!0}),_C=hx(([{scrollContainerState:e,scrollTo:t}])=>{let n=fx(),r=fx(),i=fx(),a=ux(!1),o=ux(void 0);return Xb($(vx(n,r),nx(([{scrollTop:e,viewportHeight:t},{offsetTop:n,listHeight:r}])=>({scrollHeight:r,scrollTop:Math.max(0,e-n),viewportHeight:t}))),e),Xb($(t,sx(r),nx(([e,{offsetTop:t}])=>({...e,top:e.top+t}))),i),{customScrollParent:o,useWindowScroll:a,windowScrollContainerState:n,windowScrollTo:i,windowViewportRect:r}},Gb(Ix)),vC=hx(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:i},{didMount:a},{useWindowScroll:o,windowScrollContainerState:s,windowViewportRect:c}])=>{let l=fx(),u=ux(void 0),d=ux(null),f=ux(null);return Xb(s,d),Xb(c,f),Kb($(l,sx(t,r,o,d,f,n)),([e,t,n,r,i,a,o])=>{let s=SS(t.sizeTree);r&&i!==null&&a!==null&&(n=i.scrollTop-a.offsetTop),n-=o,e({ranges:s,scrollTop:n})}),Xb($(u,tx(Bb),nx(yC)),i),Xb($(a,sx(u),tx(([,e])=>e!==void 0),ex(),nx(([,e])=>e.ranges)),e),{getState:l,restoreStateFrom:u}},Gb(OS,Ix,zS,jS,_C));function yC(e){return{align:`start`,index:0,offset:e.scrollTop}}var bC=hx(([{topItemsIndexes:e}])=>{let t=ux(0);return Xb($(t,tx(e=>e>=0),nx(e=>Array.from({length:e}).map((e,t)=>t))),e),{topItemCount:t}},Gb(aC));function xC(e){let t=!1,n;return(()=>(t||(t=!0,n=e()),n))}var SC=xC(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),CC=hx(([{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 Xb(k,T.scrollSeekRangeChanged),Xb($(vx(T.windowViewportRect,_.headerHeight,_.fixedHeaderHeight),nx(([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}},Gb(OS,zS,Ix,vC,pC,aC,PS,hx(([{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=px($(l,sx(s),ix(([,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]),tx(([e])=>e!==0),sx(i,c,r,a,m,h),tx(([,e,t,n,,,r])=>!r&&!n&&e!==0&&t===VS),nx(([[e],,,,,t])=>(t(`Upward scrolling compensation`,{amount:e},xx.DEBUG),e))));function _(t){t>0?(qb(n,{behavior:`auto`,top:-t}),qb(e,0)):(qb(e,0),qb(n,{behavior:`auto`,top:-t}))}Kb($(g,sx(e,o)),([t,n,r])=>{r&&SC()?qb(e,n-t):_(-t)}),Kb($(vx(dx(o,!1),e,h),tx(([e,t,n])=>!e&&!n&&t!==0),nx(([e,t])=>t),ox(1)),_),Xb($(f,nx(e=>({top:-e}))),n);let v=null;function y(){if(v===null)return;let{offset:t}=v;v=null,qb(n,{top:t}),requestAnimationFrame(()=>{qb(e,0),qb(h,!1)})}return Kb(t,e=>{v===null||!v.acknowledgeable||e===v.offset&&y()}),Kb($(u,sx(p,d),nx(([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=Bx(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:Yb(e)!==t,offset:t},qb(e,t),requestAnimationFrame(y)}),{deviation:e}},Gb(Ix,KS,aC,OS,wx,oS)),bC,AS,hx(([e,t,n,r,i,a,o,s,c,l,u])=>({...e,...t,...n,...r,...i,...a,...o,...s,...c,...l,...u}),Gb(QS,mC,jS,gC,oC,hC,sC,_C,uC,wx,cC))));function wC(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 TC=typeof document>`u`?Q.useEffect:Q.useLayoutEffect;function EC(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&&qb(e.propsReady,!1);for(let i of r){let r=e[t.required[i]];qb(r,n[i])}for(let r of i)if(r in n){let i=e[t.optional[r]];qb(i,n[r])}e.propsReady!==void 0&&qb(e.propsReady,!0)}function l(e){return a.reduce((n,r)=>(n[r]=n=>{let i=e[t.methods[r]];qb(i,n)},n),{})}function u(e){return o.reduce((n,r)=>(n[r]=lx(e[t.events[r]]),n),{})}return{Component:Q.forwardRef(function(t,a){let{children:d,...f}=t,[p]=Q.useState(()=>Ub(_x(e),e=>{c(e,f)})),[m]=Q.useState(Rb(u,p));TC(()=>{for(let e of o)e in f&&Kb(m[e],f[e]);return()=>{Object.values(m).map(Jb)}},[f,m,p]),TC(()=>{c(p,f)}),Q.useImperativeHandle(a,Fb(l(p)));let h=n;return(0,X.jsx)(s.Provider,{value:p,children:n===void 0?d:(0,X.jsx)(h,{...wC([...r,...i,...o],f),children:d})})}),useEmitter:(e,t)=>{let n=Q.useContext(s)[e];TC(()=>Kb(n,t),[t,n])},useEmitterValue:e=>{let t=Q.useContext(s)[e],n=Q.useCallback(e=>Kb(t,e),[t]);return Q.useSyncExternalStore(n,()=>Yb(t),()=>Yb(t))},usePublisher:e=>{let t=Q.useContext(s);return Q.useCallback(n=>{qb(t[e],n)},[t,e])}}}var DC=Q.createContext(void 0),OC=Q.createContext(void 0),kC=`-webkit-sticky`,AC=`sticky`,jC=xC(()=>{if(typeof document>`u`)return AC;let e=document.createElement(`div`);return e.style.position=kC,e.style.position===kC?kC:AC});function MC(e){return`self`in e}function NC(e){return`body`in e}function PC(e,t,n,r=Hb,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(NC(l)||MC(l)){let e=MC(l)?l:l.defaultView;o=a===!0?Dx(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?Dx(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():Ec.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;MC(r)?(u=Math.max(uS(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?Dx(r,r.scrollX):r.scrollY):(u=r[a===!0?`scrollWidth`:`scrollHeight`],l=uS(r,a===!0?`width`:`height`),d=a===!0?Dx(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,BS(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:Ox(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:Ox(o.current,e.top)}}),o.current.scrollBy(e)},[a]),scrollerRef:o,scrollToCallback:u}}function FC(e){return e}var IC=hx(([e,t])=>({...e,...t}),Gb(CC,hx(()=>{let e=ux(e=>`Item ${e}`),t=ux(e=>`Group ${e}`),n=ux({}),r=ux(FC),i=ux(`div`),a=ux(Hb),o=(e,t=null)=>dx($(n,nx(t=>t[e]),ex()),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`)}}))),LC=({height:e})=>(0,X.jsx)(`div`,{style:{height:e}}),RC={overflowAnchor:`none`,position:jC(),zIndex:1},zC={overflowAnchor:`none`},BC={...zC,display:`inline-block`,height:`100%`},VC=Q.memo(function({showTopList:e=!1}){let t=iw(`listState`),n=aw(`sizeRanges`),r=iw(`useWindowScroll`),i=iw(`customScrollParent`),a=aw(`windowScrollContainerState`),o=aw(`scrollContainerState`),s=i||r?a:o,c=iw(`itemContent`),l=iw(`context`),u=iw(`groupContent`),d=iw(`trackItemSizes`),f=iw(`itemSize`),p=iw(`log`),m=aw(`gap`),h=iw(`horizontalDirection`),{callbackRef:g}=jx(n,f,d,e?Hb:s,p,m,i,h,iw(`skipAnimationFrameInResizeObserver`)),[_,v]=Q.useState(0);rw(`deviation`,e=>{_!==e&&v(e)});let y=aw(`deviationCommitted`);Px(()=>{y(_)},[_,y]);let b=iw(`EmptyPlaceholder`),x=iw(`ScrollSeekPlaceholder`)??LC,S=iw(`ListComponent`),C=iw(`ItemComponent`),w=iw(`GroupComponent`),T=iw(`computeItemKey`),E=iw(`isSeeking`),D=iw(`groupIndices`).length>0,O=iw(`alignToBottom`),k=iw(`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,X.jsx)(b,{...qC(b,l)}):(0,X.jsx)(S,{...qC(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,{...qC(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,{...qC(w,l),"data-index":n,"data-item-index":e.index,"data-known-size":e.size,key:r,style:RC},u(e.index,l)):(0,Q.createElement)(C,{...qC(C,l),...JC(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?BC:zC},D?c(e.index,e.groupIndex,e.data,l):c(e.index,e.data,l))})})}),HC={height:`100%`,outline:`none`,overflowY:`auto`,position:`relative`,WebkitOverflowScrolling:`touch`},UC={outline:`none`,overflowX:`auto`,position:`relative`},WC=e=>({height:`100%`,position:`absolute`,top:0,width:`100%`,...e?{display:`flex`,flexDirection:`column`}:void 0}),GC=(e,t,n=0)=>({...WC(e),position:t?`relative`:`absolute`,top:t?-n:0}),KC={position:jC(),top:0,width:`100%`,zIndex:1};function qC(e,t){if(typeof e!=`string`)return{context:t}}function JC(e,t){return{item:typeof e==`string`?void 0:t}}var YC=Q.memo(function(){let e=iw(`HeaderComponent`),t=aw(`headerHeight`),n=iw(`HeaderFooterTag`),r=kx(Q.useMemo(()=>e=>{t(uS(e,`height`))},[t]),!0,iw(`skipAnimationFrameInResizeObserver`)),i=iw(`context`);return e==null?null:(0,X.jsx)(n,{ref:r,children:(0,X.jsx)(e,{...qC(e,i)})})}),XC=Q.memo(function(){let e=iw(`FooterComponent`),t=aw(`footerHeight`),n=iw(`HeaderFooterTag`),r=kx(Q.useMemo(()=>e=>{t(uS(e,`height`))},[t]),!0,iw(`skipAnimationFrameInResizeObserver`)),i=iw(`context`);return e==null?null:(0,X.jsx)(n,{ref:r,children:(0,X.jsx)(e,{...qC(e,i)})})});function ZC({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}=PC(s,l,c,u,void 0,d);return e(`scrollTo`,m),e(`scrollBy`,f),(0,X.jsx)(c,{"data-testid":`virtuoso-scroller`,"data-virtuoso-scroller":!0,ref:p,style:{...d?UC:HC,...i},tabIndex:0,...o,...qC(c,a),children:r})})}function QC({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}=PC(s,l,c,t(`scrollerRef`),f);return Px(()=>(h.current=f??p.current?.ownerDocument.defaultView,()=>{h.current=null}),[h,f]),e(`windowScrollTo`,g),e(`scrollBy`,m),(0,X.jsx)(c,{ref:p,"data-virtuoso-scroller":!0,style:{position:`relative`,...i,...u===0?void 0:{height:u+d}},...o,...qC(c,a),children:r})})}var $C=({children:e})=>{let t=Q.useContext(DC),n=aw(`viewportHeight`),r=aw(`fixedItemHeight`),i=iw(`alignToBottom`),a=iw(`horizontalDirection`),o=kx(Q.useMemo(()=>Lb(n,e=>uS(e,a?`width`:`height`)),[n,a]),!0,iw(`skipAnimationFrameInResizeObserver`));return Q.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),(0,X.jsx)(`div`,{"data-viewport-type":`element`,ref:o,style:WC(i),children:e})},ew=({children:e})=>{let t=Q.useContext(DC),n=aw(`windowViewportRect`),r=aw(`fixedItemHeight`),i=iw(`customScrollParent`),a=iw(`useWindowScroll`),o=iw(`topListHeight`),s=Fx(n,i,iw(`skipAnimationFrameInResizeObserver`)),c=iw(`alignToBottom`);return Q.useEffect(()=>{t&&(r(t.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),(0,X.jsx)(`div`,{"data-viewport-type":`window`,ref:s,style:GC(c,a,o),children:e})},tw=({children:e})=>{let t=iw(`TopItemListComponent`)??`div`,n=iw(`headerHeight`);return(0,X.jsx)(t,{style:{...KC,marginTop:`${n}px`},...qC(t,iw(`context`)),children:e})},{Component:nw,useEmitter:rw,useEmitterValue:iw,usePublisher:aw}=EC(IC,{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=iw(`useWindowScroll`),n=iw(`topItemsIndexes`).length>0,r=iw(`customScrollParent`),i=iw(`context`);return(0,X.jsxs)(r||t?sw:ow,{...e,context:i,children:[n&&(0,X.jsx)(tw,{children:(0,X.jsx)(VC,{showTopList:!0})}),(0,X.jsxs)(r||t?ew:$C,{children:[(0,X.jsx)(YC,{}),(0,X.jsx)(VC,{}),(0,X.jsx)(XC,{})]})]})})),ow=ZC({useEmitter:rw,useEmitterValue:iw,usePublisher:aw}),sw=QC({useEmitter:rw,useEmitterValue:iw,usePublisher:aw}),cw=nw,lw=hx(([e,t])=>({...e,...t}),Gb(CC,hx(()=>{let e=ux(e=>(0,X.jsxs)(`td`,{children:[`Item $`,e]})),t=ux(null),n=ux(e=>(0,X.jsxs)(`td`,{colSpan:1e3,children:[`Group `,e]})),r=ux(null),i=ux(null),a=ux({}),o=ux(FC),s=ux(Hb),c=(e,t=null)=>dx($(a,nx(t=>t[e]),ex()),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`)}}))),uw=({height:e})=>(0,X.jsx)(`tr`,{children:(0,X.jsx)(`td`,{style:{height:e}})}),dw=({height:e})=>(0,X.jsx)(`tr`,{children:(0,X.jsx)(`td`,{style:{border:0,height:e,padding:0}})}),fw={overflowAnchor:`none`},pw={position:jC(),zIndex:2,overflowAnchor:`none`},mw=Q.memo(function({showTopList:e=!1}){let t=bw(`listState`),n=bw(`computeItemKey`),r=bw(`firstItemIndex`),i=bw(`context`),a=bw(`isSeeking`),o=bw(`fixedHeaderHeight`),s=bw(`groupIndices`).length>0,c=bw(`itemContent`),l=bw(`groupContent`),u=bw(`ScrollSeekPlaceholder`)??uw,d=bw(`GroupComponent`),f=bw(`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,{...qC(u,i),height:t.size,index:t.index,key:h,type:t.type||`item`}):t.type===`group`?(0,Q.createElement)(d,{...qC(d,i),"data-index":m,"data-item-index":t.index,"data-known-size":t.size,key:h,style:{...pw,top:o}},l(t.index,i)):(0,Q.createElement)(f,{...qC(f,i),...JC(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?{...pw,top:o+g}:fw},s?c(t.index,t.groupIndex,t.data,i):c(t.index,t.data,i))})}),hw=Q.memo(function(){let e=bw(`listState`),t=bw(`topItemsIndexes`).length>0,n=xw(`sizeRanges`),r=bw(`useWindowScroll`),i=bw(`customScrollParent`),a=xw(`windowScrollContainerState`),o=xw(`scrollContainerState`),s=i||r?a:o,c=bw(`trackItemSizes`),{callbackRef:l,ref:u}=jx(n,bw(`itemSize`),c,s,bw(`log`),void 0,i,!1,bw(`skipAnimationFrameInResizeObserver`)),[d,f]=Q.useState(0);yw(`deviation`,e=>{d!==e&&(u.current.style.marginTop=`${e}px`,f(e))});let p=xw(`deviationCommitted`);Px(()=>{p(d)},[d,p]);let m=bw(`EmptyPlaceholder`),h=bw(`FillerRow`)??dw,g=bw(`TableBodyComponent`),_=bw(`paddingTopAddition`),v=bw(`statefulTotalCount`),y=bw(`context`);if(v===0&&m!=null)return(0,X.jsx)(m,{...qC(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,X.jsx)(h,{context:y,height:x},`padding-top`):null,w=S>0?(0,X.jsx)(h,{context:y,height:S},`padding-bottom`):null;return(0,X.jsxs)(g,{"data-testid":`virtuoso-item-list`,ref:l,...qC(g,y),children:[C,t&&(0,X.jsx)(mw,{showTopList:!0}),(0,X.jsx)(mw,{}),w]})}),gw=({children:e})=>{let t=Q.useContext(DC),n=xw(`viewportHeight`),r=xw(`fixedItemHeight`),i=kx(Q.useMemo(()=>Lb(n,e=>uS(e,`height`)),[n]),!0,bw(`skipAnimationFrameInResizeObserver`));return Q.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),(0,X.jsx)(`div`,{"data-viewport-type":`element`,ref:i,style:WC(!1),children:e})},_w=({children:e})=>{let t=Q.useContext(DC),n=xw(`windowViewportRect`),r=xw(`fixedItemHeight`),i=bw(`customScrollParent`),a=bw(`useWindowScroll`),o=Fx(n,i,bw(`skipAnimationFrameInResizeObserver`));return Q.useEffect(()=>{t&&(r(t.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),(0,X.jsx)(`div`,{"data-viewport-type":`window`,ref:o,style:GC(!1,a),children:e})},{Component:vw,useEmitter:yw,useEmitterValue:bw,usePublisher:xw}=EC(lw,{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=bw(`useWindowScroll`),n=bw(`customScrollParent`),r=xw(`fixedHeaderHeight`),i=xw(`fixedFooterHeight`),a=bw(`fixedHeaderContent`),o=bw(`fixedFooterContent`),s=bw(`context`),c=kx(Q.useMemo(()=>Lb(r,e=>uS(e,`height`)),[r]),!0,bw(`skipAnimationFrameInResizeObserver`)),l=kx(Q.useMemo(()=>Lb(i,e=>uS(e,`height`)),[i]),!0,bw(`skipAnimationFrameInResizeObserver`)),u=n||t?Cw:Sw,d=n||t?_w:gw,f=bw(`TableComponent`),p=bw(`TableHeadComponent`),m=bw(`TableFooterComponent`),h=a?(0,X.jsx)(p,{ref:c,style:{position:`sticky`,top:0,zIndex:2},...qC(p,s),children:a()},`TableHead`):null,g=o?(0,X.jsx)(m,{ref:l,style:{bottom:0,position:`sticky`,zIndex:1},...qC(m,s),children:o()},`TableFoot`):null;return(0,X.jsx)(u,{...e,...qC(u,s),children:(0,X.jsx)(d,{children:(0,X.jsxs)(f,{style:{borderSpacing:0,overflowAnchor:`none`},...qC(f,s),children:[h,(0,X.jsx)(hw,{},`TableBody`),g]})})})})),Sw=ZC({useEmitter:yw,useEmitterValue:bw,usePublisher:xw}),Cw=QC({useEmitter:yw,useEmitterValue:bw,usePublisher:xw}),ww={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Tw={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Ew,floor:Dw,max:Ow,min:kw,round:Aw}=Math;function jw(e,t,n){return Array.from({length:t-e+1}).map((t,r)=>({data:n===null?null:n[r+e],index:r+e}))}function Mw(e){return{...Tw,items:e}}function Nw(e,t){return e!==void 0&&e.width===t.width&&e.height===t.height}function Pw(e,t){return e!==void 0&&e.column===t.column&&e.row===t.row}var Fw=hx(([{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=ux(0),C=ux(0),w=ux(ww),T=ux({height:0,width:0}),E=ux({height:0,width:0}),D=fx(),O=fx(),k=ux(0),A=ux(null),j=ux({column:0,row:0}),M=fx(),N=fx(),P=ux(!1),F=ux(0),I=ux(!0),L=ux(!1),R=ux(!1);Kb($(m,sx(F),tx(([e,t])=>!RS(t))),()=>{qb(I,!1)}),Kb($(vx(m,I,E,T,F,L),tx(([e,t,n,r,,i])=>e&&!t&&n.height!==0&&r.height!==0&&!i)),([,,,,e])=>{if(e===void 0){qb(I,!0);return}qb(L,!0),IS(1,()=>{qb(D,e)}),Zb($(l),()=>{qb(t,[0,0]),qb(I,!0)})}),Xb($(N,tx(e=>e!=null&&e.scrollTop>0),rx(0)),C),Kb($(m,sx(N),tx(([,e])=>e!=null)),([,e])=>{e&&(qb(T,e.viewport),qb(E,e.item),qb(j,e.gap),e.scrollTop>0&&(qb(P,!0),Zb($(l,ax(1)),e=>{qb(P,!1)}),qb(c,{top:e.scrollTop})))}),Xb($(T,nx(({height:e})=>e)),d),Xb($(vx(yx(T,Nw),yx(E,Nw),yx(j,(e,t)=>e!==void 0&&e.column===t.column&&e.row===t.row),yx(l)),nx(([e,t,n,r])=>({gap:n,item:t,scrollTop:r,viewport:e}))),M),Xb($(vx(yx(S),r,yx(j,Pw),yx(E,Nw),yx(T,Nw),yx(A),yx(C),yx(P),yx(I),yx(F)),tx(([,,,,,,,e])=>!e),nx(([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 ww;if(p===0){let t=LS(l,e);return Mw(jw(t,t+Math.max(s-1,0),o))}let h=Iw(m,p,u),g,_;c?t===0&&n===0&&s>0?(g=0,_=s-1):(g=h*Dw((t+d)/(f+d)),_=h*Ew((n+d)/(f+d))-1,_=kw(e-1,Ow(_,h-1)),g=kw(_,Ow(0,g))):(g=0,_=-1);let v=jw(g,_,o),{bottom:y,top:b}=Lw(a,r,i,v),x=Ew(e/h);return{bottom:y,itemHeight:f,items:v,itemWidth:p,offsetBottom:x*f+(x-1)*d-y,offsetTop:b,top:b}})),w),Xb($(A,tx(e=>e!==null),nx(e=>e.length)),S),Xb($(vx(T,E,w,j),tx(([e,t,{items:n}])=>n.length>0&&t.height!==0&&e.height!==0),nx(([e,t,{items:n},r])=>{let{bottom:i,top:a}=Lw(e,r,t,n);return[a,i]}),ex(aS)),t);let z=ux(!1);Xb($(l,sx(z),nx(([e,t])=>t||e!==0)),z);let B=px($(vx(w,S),tx(([{items:e}])=>e.length>0),sx(z),tx(([[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}),nx(([[,e]])=>e-1),ex())),V=px($(yx(w),tx(({items:e})=>e.length>0&&e[0].index===0),rx(0),ex())),H=px($(yx(w),sx(P),tx(([{items:e},t])=>e.length>0&&!t),nx(([{items:e}])=>({endIndex:e[e.length-1].index,startIndex:e[0].index})),ex(iS),ox(0)));Xb(H,p.scrollSeekRangeChanged),Xb($(D,sx(T,E,S,j),nx(([e,t,n,r,i])=>{let a=NS(e),{align:o,behavior:s,offset:c}=a,l=a.index;l===`LAST`&&(l=r-1),l=Ow(0,l,kw(r-1,l));let u=Rw(t,i,n,l);return o===`end`?u=Aw(u-t.height+n.height):o===`center`&&(u=Aw(u-t.height/2+n.height/2)),c!==void 0&&c!==0&&(u+=c),{behavior:s,top:u}})),c);let U=dx($(w,nx(e=>e.offsetBottom+e.bottom)),0);return Xb($(b,nx(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}},Gb(QS,Ix,KS,gC,jS,_C,wx));function Iw(e,t,n){return Ow(1,Dw((e+n)/(Dw(t)+n)))}function Lw(e,t,n,r){let{height:i}=n;if(i===void 0||r.length===0)return{bottom:0,top:0};let a=Rw(e,t,n,r[0].index);return{bottom:Rw(e,t,n,r[r.length-1].index)+i,top:a}}function Rw(e,t,n,r){let i=Dw(r/Iw(e.width,n.width,t.column)),a=i*n.height+Ow(0,i-1)*t.row;return a>0?a+t.row:a}var zw=hx(([e,t])=>({...e,...t}),Gb(Fw,hx(()=>{let e=ux(e=>`Item ${e}`),t=ux({}),n=ux(null),r=ux(`virtuoso-grid-item`),i=ux(`virtuoso-grid-list`),a=ux(FC),o=ux(`div`),s=ux(Hb),c=(e,n=null)=>dx($(t,nx(t=>t[e]),ex()),n),l=ux(!1),u=ux(!1);return Xb(yx(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`)}}))),Bw=Q.memo(function(){let e=qw(`gridState`),t=qw(`listClassName`),n=qw(`itemClassName`),r=qw(`itemContent`),i=qw(`computeItemKey`),a=qw(`isSeeking`),o=Jw(`scrollHeight`),s=qw(`ItemComponent`),c=qw(`ListComponent`),l=qw(`ScrollSeekPlaceholder`),u=qw(`context`),d=Jw(`itemDimensions`),f=Jw(`gap`),p=qw(`log`),m=qw(`stateRestoreInProgress`),h=Jw(`reportReadyState`),g=kx(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:Zw(`column-gap`,getComputedStyle(e).columnGap,p),row:Zw(`row-gap`,getComputedStyle(e).rowGap,p)})},[o,d,f,p]),!0,!1);return Px(()=>{e.itemHeight>0&&e.itemWidth>0&&h(!0)},[e]),m?null:(0,X.jsx)(c,{className:t,ref:g,...qC(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,X.jsx)(l,{...qC(l,u),height:e.itemHeight,index:t.index,width:e.itemWidth},o):(0,Q.createElement)(s,{...qC(s,u),className:n,"data-index":t.index,key:o},r(t.index,t.data,u))})})}),Vw=Q.memo(function(){let e=qw(`HeaderComponent`),t=Jw(`headerHeight`),n=qw(`headerFooterTag`),r=kx(Q.useMemo(()=>e=>{t(uS(e,`height`))},[t]),!0,!1),i=qw(`context`);return e==null?null:(0,X.jsx)(n,{ref:r,children:(0,X.jsx)(e,{...qC(e,i)})})}),Hw=Q.memo(function(){let e=qw(`FooterComponent`),t=Jw(`footerHeight`),n=qw(`headerFooterTag`),r=kx(Q.useMemo(()=>e=>{t(uS(e,`height`))},[t]),!0,!1),i=qw(`context`);return e==null?null:(0,X.jsx)(n,{ref:r,children:(0,X.jsx)(e,{...qC(e,i)})})}),Uw=({children:e})=>{let t=Q.useContext(OC),n=Jw(`itemDimensions`),r=Jw(`viewportDimensions`),i=kx(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,X.jsx)(`div`,{ref:i,style:WC(!1),children:e})},Ww=({children:e})=>{let t=Q.useContext(OC),n=Jw(`windowViewportRect`),r=Jw(`itemDimensions`),i=qw(`customScrollParent`),a=qw(`useWindowScroll`),o=Fx(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,X.jsx)(`div`,{ref:o,style:GC(!1,a),children:e})},{Component:Gw,useEmitter:Kw,useEmitterValue:qw,usePublisher:Jw}=EC(zw,{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=qw(`useWindowScroll`),n=qw(`customScrollParent`),r=n||t?Xw:Yw,i=n||t?Ww:Uw,a=qw(`context`);return(0,X.jsx)(r,{...e,...qC(r,a),children:(0,X.jsxs)(i,{children:[(0,X.jsx)(Vw,{}),(0,X.jsx)(Bw,{}),(0,X.jsx)(Hw,{})]})})})),Yw=ZC({useEmitter:Kw,useEmitterValue:qw,usePublisher:Jw}),Xw=QC({useEmitter:Kw,useEmitterValue:qw,usePublisher:Jw});function Zw(e,t,n){return t!==`normal`&&t?.endsWith(`px`)!==!0&&n(`${e} was not resolved to pixel value correctly`,t,xx.WARN),t===`normal`?0:parseInt(t??`0`,10)}function Qw(e){return e.scrollHeight-e.scrollTop-e.clientHeight}function $w(e,t=96){return Qw(e)<=t}function eT(e){Math.abs(Qw(e))>.5&&(e.scrollTop=e.scrollHeight)}function tT(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 nT(){return typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}var rT=new WeakMap;function iT(e,t){return rT.set(e,t),()=>{rT.get(e)===t&&rT.delete(e)}}function aT(e){return rT.get(e)}function oT(e){e.dispatchEvent(new Event(`chat-scroll-reading`))}function sT({context:e}){return e?.footer}var cT={Footer:sT},lT={top:800,bottom:800};function uT({rows:e,scrollRef:t,renderRow:n,footer:r}){let i=(0,Q.useRef)(null),[a,o]=(0,Q.useState)(),[s,c]=(0,Q.useState)(lT),[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 iT(a,{reveal:t=>{let n=e.findIndex(e=>e.index===t||e.aliases.includes(t));return n<0?!1:(oT(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&&nT()===`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=lT.top+(e?a.scrollTop-e.start:0),r=lT.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,X.jsx)(cw,{ref:i,customScrollParent:a,data:e,skipAnimationFrameInResizeObserver:!0,components:cT,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,X.jsx)(`div`,{className:r===e[0]?void 0:r.compactTop?`pt-3`:`pt-8`,children:n(r)})}):null}function dT(e){let t=(0,Z.c)(6),{progress:n}=e,r=y(fT),i;if(t[0]!==r||t[1]!==n.completed||t[2]!==n.stage||t[3]!==n.total){let e=C(r).chat.runRecovery,a;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(It,{className:`size-3.5 shrink-0 motion-safe:animate-spin`,"aria-hidden":!0}),t[5]=a):a=t[5],i=(0,X.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex flex-wrap items-center gap-2 py-2 text-xs text-fg-muted`,"data-run-recovery":!0,children:[a,(0,X.jsx)(`span`,{children:n.stage===`model_fallback`?e.fallback:e.retrying}),n.completed!=null&&n.total!=null?(0,X.jsx)(`span`,{className:`tabular-nums`,children:e.attempt.replace(`{{attempt}}`,String(n.completed)).replace(`{{total}}`,String(n.total))}):null]}),t[0]=r,t[1]=n.completed,t[2]=n.stage,t[3]=n.total,t[4]=i}else i=t[4];return i}function fT(e){return e.language}var pT=e=>{},mT=(0,Q.memo)(function(e){let t=(0,Z.c)(76),{messages:n,timelineEntries:r,personal:i,authToken:a,conversationId:o,workspaceConversationId:s,projectId:c,streaming:l,sending:u,progress:d,runError:f,reasoningLevel:p,registerListContentRef:m,onPickWelcomePrompt:h,welcomeSpotlight:g,welcomeOverlay:_,compactWelcome:v,onDeleteRound:b,onRetryUserMessageRound:x,deleteRoundDisabled:S,onSaveAssistantAsNote:w,onSaveAssistantToSourceNote:T,onExtractAssistantTask:E,onForkAssistantTurn:D,onEditUserMessage:O,editLatestUserOnly:k,editRequiresTurnId:A,responseFeedbackEnabled:j,showAssistantWorkLog:M,hideAssistantActions:N,managesReadAloud:P,trailingContent:F,replySpaceRef:I,scrollRef:L}=e,R=r===void 0?[]:r,z=i!==void 0&&i,B=u!==void 0&&u,V=v!==void 0&&v,H=k!==void 0&&k,U=A!==void 0&&A,W=M===void 0||M,ee=N!==void 0&&N,te=P===void 0||P,ne=y(hT),re;t[0]===ne?re=t[1]:(re=C(ne),t[0]=ne,t[1]=re);let ie=re,[ae]=(0,Q.useState)(!!(L&&n.length>=300)),oe;t[2]===n?oe=t[3]:(oe=n.findLastIndex(gT),t[2]=n,t[3]=oe);let se=oe;if(Iv(te?o:null,n,l||B,z),n.length===0&&R.length===0&&!l&&!B&&!f){if(_){let e;return t[4]===_?e=t[5]:(e=(0,X.jsx)(`div`,{className:`pb-1.5`,children:_}),t[4]=_,t[5]=e),e}let e;t[6]!==ie||t[7]!==g?(e=g??{headline:ie.chat.welcomeSpotlight.headline,contextKind:`empty`,contextStatus:`ready`},t[6]=ie,t[7]=g,t[8]=e):e=t[8];let n=h??pT,r;return t[9]!==V||t[10]!==e||t[11]!==n?(r=(0,X.jsx)(`div`,{className:`pb-1.5`,children:(0,X.jsx)(_h,{spotlight:e,onPickPrompt:n,compact:V})}),t[9]=V,t[10]=e,t[11]=n,t[12]=r):r=t[12],r}let ce=Date.now(),le=n.findLastIndex(_T),ue,de,fe;if(t[13]!==le||t[14]!==n||t[15]!==x||t[16]!==B||t[17]!==l){let e=n.slice(le+1);ue=e.findLast(vT)?.outcome,de=l||B,fe=!de&&x&&le>=0&&!n[le].clarificationChoice&&(Nr(n[le])||n[le].deliveryStatus===`failed`&&n[le].clientSubmissionId)&&!e.some(bT)?()=>x(le):void 0,t[13]=le,t[14]=n,t[15]=x,t[16]=B,t[17]=l,t[18]=ue,t[19]=de,t[20]=fe}else ue=t[18],de=t[19],fe=t[20];let pe=fe,G=ue?.turnId,me;t[21]!==pe||t[22]!==f||t[23]!==de||t[24]!==G?(me={turnId:G,running:de,error:f,onRetry:pe},t[21]=pe,t[22]=f,t[23]=de,t[24]=G,t[25]=me):me=t[25];let he=me,K=de&&(d?.stage===`model_retry`||d?.stage===`model_fallback`),ge;t[26]!==se||t[27]!==B||t[28]!==l?(ge=(e,t)=>!!((l||B||e.pendingResponseStatus)&&t===se&&e.role===`assistant`),t[26]=se,t[27]=B,t[28]=l,t[29]=ge):ge=t[29];let _e=ge,q;t[30]===n?q=t[31]:(q=(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[30]=n,t[31]=q);let ve=q,ye;t[32]!==ve||t[33]!==_e||t[34]!==n||t[35]!==z||t[36]!==p||t[37]!==W?(ye=(e,t)=>!eb(e,{personal:z,isStreaming:_e(e,t),reasoningLevel:p,showAssistantWorkLog:W,followUpTrigger:ve(e,t)})||e.role===`task`&&e.taskTrigger&&e.turnId&&n[t+1]?.role===`assistant`&&n[t+1]?.turnId===e.turnId?[]:[{key:Mv(e,t),index:t,aliases:e.role===`assistant`&&n[t-1]?.role===`task`&&e.turnId===n[t-1]?.turnId?[t-1]:[]}],t[32]=ve,t[33]=_e,t[34]=n,t[35]=z,t[36]=p,t[37]=W,t[38]=ye):ye=t[38];let J=n.flatMap(ye),be;t[39]===n.length?be=t[40]:(be=(e,t)=>({key:e.id,index:n.length+t,aliases:[]}),t[39]=n.length,t[40]=be),J.push(...R.map(be));let xe=0,Se=n.map(e=>(xe=Math.max(e.timestamp??xe,xe),xe)),Ce=e=>R[e-n.length];if(R.length){let e;t[41]===Ce?e=t[42]:(e=e=>Ce(e)?.afterMessageIndex??e,t[41]=Ce,t[42]=e);let n=e,r=e=>Se[n(e)]??Ce(e)?.timestamp??0;J.sort((e,t)=>{let i=r(e.index)-r(t.index)||n(e.index)-n(t.index),a=Ce(e.index),o=Ce(t.index);return i||(a&&o?a.timestamp-o.timestamp:0)||e.index-t.index})}let we=new Map(J.map((e,t)=>{let n=J[t-1],r=Ce(e.index)?.afterMessageIndex;return n&&r!==void 0&&(e.compactTop=n.index===r||Ce(n.index)?.afterMessageIndex===r),[e.index,n?.index]})),Te=new Map,Ee;for(let{index:e}of J)e>=n.length||(Ee!==void 0&&Te.set(e,Ee),Ee=e);let De=e=>{let{index:t,compactTop:r}=e;if(t>=n.length){let e=Ce(t);return(0,X.jsx)(`div`,{className:r&&!ae?`-mt-5`:void 0,"data-chat-timeline-entry":e.id,"data-chat-timeline-index":t,children:e.content},e.id)}let i=n[t],l=_e(i,t),u=t===le,f=n[t-1],m=ve(i,t),h=we.get(t),g=h===void 0?void 0:n[h],_=Te.get(t),v=_===void 0?void 0:n[_],y=v&&_!==void 0?ve(v,_)?n[_-1]?.timestamp??v.timestamp:v.timestamp:void 0,C=Mv(i,t),k=m?f?.timestamp??i.timestamp:i.timestamp,A=kb(k,y);return(0,X.jsxs)(`div`,{id:`chat-message-${t}`,className:Y(`scroll-mt-4`,g&&(g.role===`user`||g.role===`task`)&&!m&&!A&&`-mt-5`),"data-chat-message-index":t,"data-chat-message-row":!0,"data-client-submission-id":i.clientSubmissionId,"data-message-render-key":i.renderKey,children:[m?(0,X.jsx)(`span`,{id:`chat-message-${t-1}`,className:`block h-0 scroll-mt-4`,"aria-hidden":!0}):null,A&&k?(0,X.jsx)(`div`,{className:`mb-8 flex justify-center`,"data-chat-time-separator":!0,children:(0,X.jsx)(`time`,{suppressHydrationWarning:!0,className:`rounded-md px-2 py-1 text-xs tabular-nums text-fg-disabled`,dateTime:new Date(k).toISOString(),children:Ab(k,ce,ne)})}):null,i.role===`task`&&i.taskTrigger?(0,X.jsx)(ab,{trigger:i.taskTrigger}):(0,X.jsx)(Cb,{message:i,personal:z,followUpTrigger:m,authToken:a,conversationId:o,workspaceConversationId:s,projectId:c,isStreaming:l,progress:l&&!K?d:null,reasoningLevel:p,messageIndex:t,onDeleteRound:i.pendingSteer||i.clarificationChoice?void 0:b,onRetryUserMessageRound:x,userMessageCanRetry:!!x&&u&&!i.clarificationChoice,deleteRoundDisabled:!!(S&&u),onSaveAssistantAsNote:w,onSaveAssistantToSourceNote:T,onExtractAssistantTask:E,onForkAssistantTurn:D,suppressAssistantActions:ee,onEditUserMessage:O,userMessageCanEdit:!i.pendingSteer&&!i.clarificationChoice&&(!H||u)&&(!U||!!Nr(i))&&i.deliveryStatus!==`sending`,responseFeedbackEnabled:j,showAssistantWorkLog:W})]},C)},Oe=ae?`pt-8`:`contents`,ke;t[43]===Oe?ke=t[44]:(ke=Y(Oe),t[43]=Oe,t[44]=ke);let Ae;t[45]!==d||t[46]!==K?(Ae=K?(0,X.jsx)(dT,{progress:d}):null,t[45]=d,t[46]=K,t[47]=Ae):Ae=t[47];let je;t[48]!==ue?.status||t[49]!==pe||t[50]!==f||t[51]!==de?(je=!de&&f&&ue?.status!==`failed`?(0,X.jsx)(Cg,{errorText:f,onRetry:pe}):null,t[48]=ue?.status,t[49]=pe,t[50]=f,t[51]=de,t[52]=je):je=t[52];let Me;t[53]!==I||t[54]!==ae?(Me=I&&(0,X.jsx)(`div`,{ref:I,className:Y(!ae&&`-mt-8`,`shrink-0 transition-none`),"aria-hidden":!0,"data-chat-reply-space":!0}),t[53]=I,t[54]=ae,t[55]=Me):Me=t[55];let Ne;t[56]!==ke||t[57]!==Ae||t[58]!==je||t[59]!==Me||t[60]!==F?(Ne=(0,X.jsxs)(`div`,{className:ke,children:[Ae,je,F,Me]}),t[56]=ke,t[57]=Ae,t[58]=je,t[59]=Me,t[60]=F,t[61]=Ne):Ne=t[61];let Pe=Ne,Fe=qy,Ie=ka,Le=!ae&&`flex flex-col gap-8`,Re;t[62]===Le?Re=t[63]:(Re=Y(`w-full min-w-0 pb-8`,Le),t[62]=Le,t[63]=Re);let ze=ae||void 0,Be=ae&&L?(0,X.jsx)(uT,{rows:J,scrollRef:L,renderRow:De,footer:Pe}):(0,X.jsxs)(X.Fragment,{children:[J.map(De),Pe]}),Ve;t[64]!==m||t[65]!==Re||t[66]!==ze||t[67]!==Be?(Ve=(0,X.jsx)(`div`,{ref:m,className:Re,"data-chat-virtualized":ze,children:Be}),t[64]=m,t[65]=Re,t[66]=ze,t[67]=Be,t[68]=Ve):Ve=t[68];let He;t[69]!==Ie||t[70]!==Ve?(He=(0,X.jsx)(Ie,{children:Ve}),t[69]=Ie,t[70]=Ve,t[71]=He):He=t[71];let Ue;return t[72]!==Fe||t[73]!==he||t[74]!==He?(Ue=(0,X.jsx)(Fe,{value:he,children:He}),t[72]=Fe,t[73]=he,t[74]=He,t[75]=Ue):Ue=t[75],Ue});function hT(e){return e.language}function gT(e){return!e.pendingSteer}function _T(e){return e.role===`user`&&!e.pendingSteer}function vT(e){return e.outcome}function yT(e){return e.type===`tool_use`}function bT(e){return e.content.some(yT)}function xT(e){let t=(0,Z.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,X.jsxs)(`linearGradient`,{id:`xopc-onboarding-ai-glass`,x1:`198`,y1:`180`,x2:`826`,y2:`844`,gradientUnits:`userSpaceOnUse`,children:[(0,X.jsx)(`stop`,{stopColor:`var(--xopc-loop-ai-highlight)`}),(0,X.jsx)(`stop`,{offset:`0.46`,stopColor:`var(--xopc-loop-ai)`}),(0,X.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,X.jsxs)(`svg`,{className:`size-full overflow-visible`,viewBox:`0 0 1024 1024`,fill:`none`,"aria-hidden":`true`,children:[(0,X.jsxs)(`defs`,{children:[c,(0,X.jsxs)(`linearGradient`,{id:`xopc-onboarding-human-glass`,x1:`340`,y1:`224`,x2:`700`,y2:`816`,gradientUnits:`userSpaceOnUse`,children:[(0,X.jsx)(`stop`,{stopColor:`var(--xopc-loop-human-highlight)`}),(0,X.jsx)(`stop`,{offset:`0.52`,stopColor:`var(--xopc-loop-human)`}),(0,X.jsx)(`stop`,{offset:`1`,stopColor:`var(--xopc-loop-human-shadow)`})]})]}),(0,X.jsx)(`circle`,{className:`xopc-loop-logo__ambient`,cx:`512`,cy:`512`,r:`330`}),(0,X.jsx)(`circle`,{className:`xopc-loop-logo__origin`,cx:`512`,cy:`512`,r:`330`}),(0,X.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,X.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,X.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,X.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,X.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 ST=(0,Q.memo)(function(e){let t=(0,Z.c)(19),{visible:n,onClick:r,edge:i,running:a}=e,o=i===void 0?`top`:i,s=a!==void 0&&a,c=y(CT),l;t[0]===c?l=t[1]:(l=C(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 h=n?`scale-100 opacity-100`:`pointer-events-none translate-y-1 scale-95 opacity-0`,g;t[5]===h?g=t[6]:(g=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`,Ma.transition,Ma.press,Ma.focusRingPanel,h,`motion-reduce:translate-y-0 motion-reduce:scale-100`),t[5]=h,t[6]=g);let _=n?void 0:-1,v;t[7]===s?v=t[8]:(v=s?(0,X.jsx)(`span`,{"data-scroll-to-bottom-running-logo":!0,className:`flex size-5 items-center justify-center`,"aria-hidden":!0,children:(0,X.jsx)(xT,{className:`xopc-loop-logo--stream size-5`})}):(0,X.jsx)(Ks,{"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]=v);let b;t[9]!==u.chat.scrollToBottom||t[10]!==r||t[11]!==_||t[12]!==v||t[13]!==g?(b=(0,X.jsx)(`button`,{type:`button`,className:g,tabIndex:_,onClick:r,title:u.chat.scrollToBottom,"aria-label":u.chat.scrollToBottom,children:v}),t[9]=u.chat.scrollToBottom,t[10]=r,t[11]=_,t[12]=v,t[13]=g,t[14]=b):b=t[14];let x;return t[15]!==b||t[16]!==d||t[17]!==m?(x=(0,X.jsx)(`div`,{"data-scroll-to-bottom-dock":!0,"aria-hidden":d,className:m,children:b}),t[15]=b,t[16]=d,t[17]=m,t[18]=x):x=t[18],x});function CT(e){return e.language}function wT(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 TT(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 ET(e){return e.webkitDirectionInvertedFromDevice===!0?e.deltaY>0:e.deltaY<0}function DT(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 OT(e){let t=(0,Z.c)(50),{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,k]=(0,Q.useState)(!1),A=(0,Q.useRef)(null),j;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>{D(e),e&&k(!1)},t[0]=j):j=t[0];let M=j,N=(0,Q.useRef)(!0),P=(0,Q.useRef)(0),F=(0,Q.useRef)(o),I;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(I={first:void 0,len:0,scrollHeight:0},t[1]=I):I=t[1];let L=(0,Q.useRef)(I),R;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(R=e=>{p.current=e,e&&(S.current=null)},t[2]=R):R=t[2];let z=R,B;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(B=e=>{let t=u.current;if(!t)return;let n=$w(t);z(n),M(n),_.current=n?e:null,n||(S.current=wT(t))},t[3]=B):B=t[3];let V=B,H;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>{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[4]=H):H=t[4];let U=H,W;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(W=e=>{let t=u.current;if(!t||!e?.force&&!p.current)return;e?.force&&(z(!0),k(!1));let n=aT(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:nT()});return}eT(t),w.current=t.scrollHeight,T.current=t.clientHeight,M($w(t))},t[5]=W):W=t[5];let ee=W,te;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(te=()=>{let e=u.current;!e||e.scrollHeight<=e.clientHeight||(z(!1),M($w(e)))},t[6]=te):te=t[6];let ne=te,re;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(re=()=>{let e=u.current;if(!e)return;!p.current&&!aT(e)&&TT(e,S.current);let t=U(),n=e.scrollHeight>w.current,r=e.clientHeight<T.current;w.current=e.scrollHeight,T.current=e.clientHeight,(n||r||t)&&ee(),M($w(e))},t[7]=re):re=t[7];let ie=re,ae;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(ae=()=>{let e=u.current;e&&p.current&&(aT(e)?eT(e):e.scrollHeight>w.current&&ee()),C.current===null&&(C.current=requestAnimationFrame(()=>{C.current=null,ie()}))},t[8]=ae):ae=t[8];let oe=ae,se;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(se=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(oe);t.observe(e),x.current=t;let n=new MutationObserver(e=>{let t=u.current;!t||!p.current||!aT(t)||(U()||e.some(kT))&&eT(t)});n.observe(e,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:[`style`]}),b.current=n},t[9]=se):se=t[9];let ce=se,le,ue;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(le=()=>()=>{x.current?.disconnect(),b.current?.disconnect(),C.current!==null&&(cancelAnimationFrame(C.current),C.current=null)},ue=[],t[10]=le,t[11]=ue):(le=t[10],ue=t[11]),(0,Q.useEffect)(le,ue);let de;t[12]!==s||t[13]!==l||t[14]!==c?(de=()=>{let e=u.current;if(!e)return;let t=$w(e),n=T.current>0&&(e.scrollHeight!==w.current||e.clientHeight!==T.current);if(A.current!==null){let r=e.scrollTop-A.current;A.current=e.scrollTop,!t&&!n&&r!==0&&k(r>0)}if(!t&&p.current&&n){M(!1),oe();return}z(t),t||(S.current=wT(e)),M(t),t&&U(),e.scrollTop<100&&!t&&s&&!c&&l()},t[12]=s,t[13]=l,t[14]=c,t[15]=de):de=t[15];let fe=de,pe;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(pe=e=>{ee({force:!0,smooth:e===void 0||e})},t[16]=pe):pe=t[16];let G=pe,me,he;t[17]!==n||t[18]!==r?(me=()=>{if(n){if(r){N.current=!0;return}N.current===!0&&(N.current=!1,z(!0),ee({force:!0}))}},he=[r,n,z,ee],t[17]=n,t[18]=r,t[19]=me,t[20]=he):(me=t[19],he=t[20]),(0,Q.useLayoutEffect)(me,he);let K;t[21]!==n||t[22]!==r?(K=()=>{!n||r||(L.current={first:void 0,len:0,scrollHeight:0},P.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`),z(!0),ee({force:!0}))},t[21]=n,t[22]=r,t[23]=K):K=t[23];let ge;t[24]!==i||t[25]!==n||t[26]!==r?(ge=[i,n,r,z,ee],t[24]=i,t[25]=n,t[26]=r,t[27]=ge):ge=t[27],(0,Q.useLayoutEffect)(K,ge);let _e,q;t[28]!==a||t[29]!==r||t[30]!==o?(_e=()=>{if(r)return;let e=F.current&&!o;F.current=o;let t=U(),n=a.length,i=P.current;P.current=n;let s=(u.current?.scrollHeight??0)>w.current;p.current&&(n>i||s||t||e)&&ee()},q=[a,o,r,ee,U],t[28]=a,t[29]=r,t[30]=o,t[31]=_e,t[32]=q):(_e=t[31],q=t[32]),(0,Q.useLayoutEffect)(_e,q);let ve,ye;t[33]!==a||t[34]!==r?(ve=()=>{let e=u.current;if(!e||r)return;let t=L.current,n=a[0],i=a.length,o=e.scrollHeight,s=i-t.len;s>0&&t.len>0&&!DT(n,t.first)&&DT(a[s],t.first)&&!aT(e)&&t.scrollHeight>0&&!TT(e,S.current)&&(e.scrollTop+=o-t.scrollHeight),L.current={first:n,len:i,scrollHeight:o}},ye=[a,r],t[33]=a,t[34]=r,t[35]=ve,t[36]=ye):(ve=t[35],ye=t[36]),(0,Q.useLayoutEffect)(ve,ye);let J,be;t[37]!==n||t[38]!==r?(J=()=>{if(!n||r)return;let e=u.current;if(!e)return;let t=new ResizeObserver(oe);t.observe(e);let i=t=>{t.ctrlKey||t.shiftKey||Math.abs(t.deltaY)<Math.abs(t.deltaX)||Math.abs(t.deltaY)<.25||(ET(t)&&ne(),k(t.deltaY>0&&!$w(e)))},a=null,o=e=>{a=e.touches.length===1?e.touches[0]:null},s=t=>{let n=a;if(o(t),!n||!a)return;let r=a.clientY-n.clientY,i=a.clientX-n.clientX;Math.abs(r)<=2||Math.abs(r)<Math.abs(i)||(r>2&&ne(),k(r<0&&!$w(e)))},c=t=>{if(t.target!==e||t.altKey||t.ctrlKey||t.metaKey)return;let n=[`ArrowUp`,`PageUp`,`Home`].includes(t.key)||t.key===` `&&t.shiftKey,r=[`ArrowDown`,`PageDown`,`End`].includes(t.key)||t.key===` `&&!t.shiftKey;n&&ne(),(n||r)&&k(r&&!$w(e))},l=t=>{if(t.button!==0||t.pointerType===`touch`||t.target!==e)return;let n=e.getBoundingClientRect().left+e.clientLeft+e.clientWidth;t.clientX>=n&&(A.current=e.scrollTop,ne())},d=()=>{A.current=null},f=()=>{let t=window.getSelection();!t||t.isCollapsed||!e.contains(t.anchorNode)||(ne(),S.current=wT(e))},p=t=>{(t.target instanceof Element?t.target:null)?.closest(`button[aria-expanded="false"]:not([aria-haspopup]), summary`)&&(ne(),S.current=wT(e))};return e.addEventListener(`chat-scroll-reading`,ne),e.addEventListener(`wheel`,i,{passive:!0}),e.addEventListener(`keydown`,c),e.addEventListener(`pointerdown`,l),e.addEventListener(`touchstart`,o,{passive:!0}),e.addEventListener(`touchmove`,s,{passive:!0}),e.addEventListener(`click`,p,!0),document.addEventListener(`selectionchange`,f),window.addEventListener(`pointerup`,d,!0),window.addEventListener(`pointercancel`,d,!0),()=>{d(),t.disconnect(),e.removeEventListener(`chat-scroll-reading`,ne),e.removeEventListener(`wheel`,i),e.removeEventListener(`keydown`,c),e.removeEventListener(`pointerdown`,l),e.removeEventListener(`touchstart`,o),e.removeEventListener(`touchmove`,s),e.removeEventListener(`click`,p,!0),document.removeEventListener(`selectionchange`,f),window.removeEventListener(`pointerup`,d,!0),window.removeEventListener(`pointercancel`,d,!0)}},be=[n,r,ne,oe],t[37]=n,t[38]=r,t[39]=J,t[40]=be):(J=t[39],be=t[40]),(0,Q.useLayoutEffect)(J,be);let xe;t[41]===n?xe=t[42]:(xe=()=>{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,oe()};r();let i=new ResizeObserver(r);return i.observe(t),()=>{i.disconnect(),e.style.removeProperty(`padding-bottom`),e.style.removeProperty(`scroll-padding-bottom`)}},t[41]=n,t[42]=xe);let Se;t[43]!==n||t[44]!==r?(Se=[n,r,oe],t[43]=n,t[44]=r,t[45]=Se):Se=t[45],(0,Q.useLayoutEffect)(xe,Se);let Ce=!E&&O,we;return t[46]!==E||t[47]!==fe||t[48]!==Ce?(we={scrollRef:u,composerDockRef:d,atBottom:E,showScrollToBottom:Ce,registerListContentRef:ce,scrollToBottom:G,onScroll:fe,replySpaceRef:m,reserveReplySpace:V},t[46]=E,t[47]=fe,t[48]=Ce,t[49]=we):we=t[49],we}function kT(e){return e.target instanceof HTMLElement&&e.target.hasAttribute(`data-virtuoso-scroller`)}var AT=256*1024,jT=new TextEncoder;function MT(e){return jT.encode(e).byteLength}function NT(e){return MT(e)<=262144?e:new TextDecoder().decode(jT.encode(e).subarray(0,AT),{stream:!0})}function PT(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(`
63
+ `);if((i.content.some(e=>e.type!==`text`)||i.attachments?.length)&&(n=!0),!e)continue;if(t<=256){n=!0;continue}let a=jT.encode(e),o=a.byteLength+256>t?new TextDecoder().decode(a.subarray(0,t-256),{stream:!0}):e;o!==e&&(n=!0);let s=MT(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 FT=`xopc:side-chat-panes:v3`,IT={text:``,attachments:[]};function LT(e){return Math.min(760,Math.max(360,Math.round(e)))}function RT(){return{panes:{},tabs:[],widthPx:520}}function zT(){try{let e=JSON.parse(sessionStorage.getItem(FT)||`{}`),t=e.identity;if(t&&t!==v.getState().conversationId)return RT();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:LT(typeof e.widthPx==`number`?e.widthPx:520)}}catch{return RT()}}function BT(e){try{sessionStorage.setItem(FT,JSON.stringify({...e,identity:v.getState().conversationId}))}catch{}}var VT=zT(),HT=x((e,t)=>{let n=n=>{e(n),queueMicrotask(()=>{let e=t();BT({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{...VT,drafts:{},readings:{},setDraftText:(n,r)=>e({drafts:{...t().drafts,[n]:{...t().drafts[n]??IT,text:r}}}),setDraftAttachments:(n,r)=>e({drafts:{...t().drafts,[n]:{...t().drafts[n]??IT,attachments:r}}}),rememberMessages:(n,r)=>{let i={...t().readings};delete i[n],i[n]=PT(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)=>{Ji.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]??IT},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:()=>{Ji.getState().reset(),e({drafts:{},readings:{},pendingCreate:null,creatingRequests:{}}),n({panes:{},tabs:[]})},pendingCreate:null,creatingRequests:{},requestCreate:(n,i=[])=>{Ji.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)=>{Ji.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;Ji.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&&(Ji.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(Ji.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&&Ji.getState().activate(`side:${o.id}`,e),o||i.requestCreate(e)},setWidthPx:e=>n({widthPx:LT(e)})}});v.subscribe((e,t)=>{if(e.conversationId&&!t.conversationId&&e.baseUrl===t.baseUrl){let e=zT();HT.setState(e)}if(e.baseUrl!==t.baseUrl||t.conversationId!==void 0&&e.conversationId!==t.conversationId){HT.getState().reset();try{sessionStorage.removeItem(`xopc:side-chat-client-id`)}catch{}}});function UT(e){return e.acceptsArgs?`/${e.name} `:`/${e.name}`}var WT=3e4,GT=null;function KT(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 qT(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(GT&&GT.key===n&&e-GT.at<WT)return GT.items.map(e=>({...e,...o.has(e.relativePath)?{isRecent:!0}:{isRecent:void 0}}))}let s={conversationId:n,agentId:r},c=KT(a.length===0?await bo(``,s):await yo(a,s,i),o);return n&&a.length===0&&(GT={key:n,at:Date.now(),items:c}),c}async function JT(e,t){return bo(e,{conversationId:t.conversationId,agentId:t.agentId})}function YT(e,...t){let n=e.trim().toLocaleLowerCase();return!n||t.some(e=>e?.toLocaleLowerCase().includes(n))}async function XT(e){let t=await g(_(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 ZT=[{kind:`file`,search:(e,t)=>qT(e,{conversationId:t.conversationId,agentId:t.currentAgentId,limit:10,recentPaths:t.recentPaths})},{kind:`note`,async search(e,t){return(await Re({...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()||C(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 On({...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 Xo(t.currentAgentId,t.conversationId)).skills.flatMap(n=>{if(!n.availableForCurrentAgent)return[];let r=rs(n,t.language);return YT(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 Ai(),r=C(t.language).agentsSettings;return n.items.flatMap(t=>{let n=fo(t,r),i=po(t,r);return YT(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 XT(`/api/browser/tabs?${new URLSearchParams({conversationId:t.conversationId})}`)).tabs.flatMap(n=>!YT(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}}])}}],QT=(0,Q.createContext)({target:null,register:()=>()=>{}});function $T(e){let t=(0,Z.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,X.jsx)(QT,{value:u,children:n}),t[6]=n,t[7]=u,t[8]=d):d=t[8],d}function eE(){let e=(0,Z.c)(2),{register:t}=(0,Q.useContext)(QT),n;return e[0]===t?n=e[1]:(n=(0,X.jsx)(`div`,{ref:t,className:`min-w-0 shrink-0`}),e[0]=t,e[1]=n),n}function tE(){return(0,Q.useContext)(QT).target}function nE({conversationId:e,turnId:t,requestKey:n,assistantOnly:r,messages:i,ready:a,hasMore:o,loadingMore:s,loadMore:c,reveal:l,onLocated:u}){let d=(0,Q.useRef)({key:``,finished:!1,requestedLength:-1});(0,Q.useEffect)(()=>{let f=JSON.stringify([e,t,n]);if(d.current.key!==f&&(d.current={key:f,finished:!1,requestedLength:-1}),!t||!a||d.current.finished)return;let p=d.current,m=i.findIndex(e=>e.turnId===t&&(!r||e.role===`assistant`));if(m>=0){let e=0,t=!1,n=0,r=()=>{t||d.current===p&&(l(m)?(p.finished=!0,u?.(!0)):++n<3?e=requestAnimationFrame(r):(p.finished=!0,u?.(!1)))};return e=requestAnimationFrame(r),()=>{t=!0,cancelAnimationFrame(e)}}if(!s){if(!o||d.current.requestedLength===i.length){d.current.finished=!0,u?.(!1);return}d.current.requestedLength=i.length,c().catch(()=>{d.current===p&&(p.finished=!0,u?.(!1))})}},[e,t,n,r,i,a,o,s,c,l,u])}function rE({interaction:e,path:t,complete:n}){let r=y(e=>e.language)===`zh`,[i,a]=(0,Q.useState)(`{}`),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1),u=async r=>{s(!0),l(!1);try{let a=r===`accept`?JSON.parse(i):void 0;if(r===`accept`&&(!a||typeof a!=`object`||Array.isArray(a)))throw Error(`Expected an object`);await b(t,{method:`POST`,body:JSON.stringify({requestId:e.requestId,action:r,content:a})}),n()}catch{l(!0)}finally{s(!1)}},d=Object.entries(e.inputSchema.properties??{});return(0,X.jsxs)(`form`,{className:`space-y-2 rounded-xl border border-edge bg-surface p-3 text-sm`,onSubmit:e=>{e.preventDefault(),u(`accept`)},children:[(0,X.jsx)(`p`,{className:`font-medium text-fg`,children:r?`设备需要补充信息`:`Device needs input`}),(0,X.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-fg-muted`,children:e.message}),d.length?(0,X.jsx)(`ul`,{className:`max-h-24 overflow-y-auto text-xs text-fg-muted`,children:d.map(([t,n])=>(0,X.jsxs)(`li`,{children:[t,n.type?` (${n.type})`:``,e.inputSchema.required?.includes(t)?` *`:``,Array.isArray(n.enum)?` · ${JSON.stringify(n.enum).slice(0,180)}`:``]},t))}):null,(0,X.jsx)(`textarea`,{value:i,onChange:e=>a(e.target.value),maxLength:7e3,"aria-label":r?`设备请求参数(JSON)`:`Device response (JSON)`,className:`h-16 w-full resize-none rounded-md border border-edge bg-surface p-2 font-mono text-xs`}),c?(0,X.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:r?`输入不符合要求,或设备请求已结束。`:`The input is invalid or the device request has ended.`}):null,(0,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,X.jsx)(qi,{type:`button`,variant:`secondary`,disabled:o,onClick:()=>void u(`decline`),children:r?`拒绝`:`Decline`}),(0,X.jsx)(qi,{type:`submit`,disabled:o,children:r?`提交给设备`:`Send to device`})]})]})}function iE(e){let t=(0,Z.c)(8),{conversationId:n,active:r}=e,i;t[0]===n?i=t[1]:(i=n?_(`/api/endpoint-tools/interactions/${encodeURIComponent(n)}`):null,t[0]=n,t[1]=i);let a=i,o=r?1500:5e3,s;t[2]===o?s=t[3]:(s={refreshInterval:o,shouldRetryOnError:!1},t[2]=o,t[3]=s);let{data:c,mutate:l}=vi(a,aE,s),u=c?.payload?.[0],d;return t[4]!==u||t[5]!==l||t[6]!==a?(d=a&&u?(0,X.jsx)(rE,{interaction:u,path:a,complete:()=>{l()}},u.requestId):null,t[4]=u,t[5]=l,t[6]=a,t[7]=d):d=t[7],d}function aE(e){return b(e)}function oE(e){let t=(0,Z.c)(24),{sk:n,onPick:r,disabled:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(Gt,{className:`size-4`,"aria-hidden":!0}),t[0]=a):a=t[0];let o;t[1]===n.findCapability?o=t[2]:(o=(0,X.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,X.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,X.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,X.jsx)(qi,{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 u;t[14]===l?u=t[15]:(u=(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:l}),t[14]=l,t[15]=u);let d;t[16]===n.findBack?d=t[17]:(d=(0,X.jsx)(h,{to:`/capabilities/skills`,className:`text-sm text-accent-fg hover:underline`,children:n.findBack}),t[16]=n.findBack,t[17]=d);let f;return t[18]!==o||t[19]!==s||t[20]!==c||t[21]!==u||t[22]!==d?(f=(0,X.jsxs)(`section`,{className:`mx-auto flex max-w-xl flex-col items-start gap-4 py-8 sm:py-12`,children:[o,s,c,u,d]}),t[18]=o,t[19]=s,t[20]=c,t[21]=u,t[22]=d,t[23]=f):f=t[23],f}function sE(e){let t=`/api/sessions/${encodeURIComponent(e)}/connection-wait`,n=Sr(t=>t.sessions[e]?.localDraft),{data:r,mutate:i,isLoading:a}=vi(n?null:[t,n===!1?`persisted`:`unknown`],async()=>await $r(e)?null:(await b(_(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),[p,m]=(0,Q.useState)(),[h,g]=(0,Q.useState)(),v=(0,Q.useCallback)(async(e,n,r,a,d)=>{let p=o.current,h=p?.wait;if(!h||(e===`cancel`?c.current:s.current||c.current))return!1;e===`cancel`?c.current=!0:s.current=!0,l.current+=1,f(!0),m(void 0),e===`cancel`&&g(void 0);let v=h.needs.find(e=>e.key===n),x=e===`connect`&&v?.target.type!==`plugin`?zs():null,S=JSON.stringify([h.id,h.objectiveRevision,e,n,r,a,d]);u.current?.signature!==S&&(u.current={signature:S,key:crypto.randomUUID()});let C=u.current.key,w=i=>b(_(`${t}/actions`),{method:`POST`,body:JSON.stringify({action:e,needKey:n,accountId:r,candidateRef:a,instanceId:d,waitId:h.id,expectedTranscriptId:i.transcriptId,expectedVersion:i.wait.version,...e===`cancel`?{expectedObjectiveRevision:h.objectiveRevision}:{},idempotencyKey:C})});try{let n;try{n=await w(p)}catch(r){if(e!==`cancel`||r.status!==409)throw r;let a=(await b(_(t))).payload;if(await i(e=>!e||e.transcriptId!==a.transcriptId||a.revision>=e.revision?a:e,!1),a.transcriptId!==p.transcriptId||a.wait?.id!==h.id||a.wait.objectiveRevision!==h.objectiveRevision)throw r;n=await w(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 Rs(n.payload.authorizationUrl,x))throw Error(`Unable to open the authorization window. Allow pop-ups, then retry.`)}else Bs(x);return u.current?.signature===S&&(u.current=null),!0}catch(t){if(Bs(x),t.status===409&&e===`cancel`){let e=y.getState().language===`zh`?`目标状态已变化,未能取消。请检查当前任务状态后再试。`:`The objective state changed and cancellation was not confirmed. Check its current status and try again.`;m(e),g(e)}else if(t.status!==409){let n=t instanceof Error?t.message:String(t);m(n),e===`cancel`&&g(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:p,cancellationError:h,act:v,dismissError:()=>{m(void 0),g(void 0)}}}function cE(e){let t=(0,Z.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,X.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,X.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,X.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,X.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,X.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,X.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,X.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,X.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,X.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,X.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 lE=(0,Q.lazy)(()=>u(()=>import(`./mcp-conversation-setup-page-D_6XeyXG.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]))),uE={zh:{connection:`服务连接`,cancel:`取消连接请求`,close:`关闭`,finish:`检查连接`,source:`查看来源`,enter:`填写访问密钥`,login:`登录并继续`,waiting:`等待完成登录`,review:`查看连接`,reconnect:`更新密钥`,configureToken:`配置 MCP Token`,tokenPrepared:`连接已准备好,填写 Token 即可连接`,expired:`连接请求已过期`,rejected:`服务未接受当前密钥`,token:`需要访问密钥`,oauth:`需要登录授权`,unknown:`无法确认认证方式`,failed:`连接检查未通过`,planned:`正在检查连接`,approval:`请确认服务和资料来源`,reload:`配置已保存,重启 Gateway 后生效`,help:`获取访问密钥`,connected:`连接已完成`,continuing:`连接已完成,原任务将自动继续`,cancelFailed:`暂时无法取消连接,请重试。`},en:{connection:`Service connection`,cancel:`Cancel connection request`,close:`Close`,finish:`Check connection`,source:`Review source`,enter:`Enter access key`,login:`Sign in and continue`,waiting:`Waiting for sign-in`,review:`View connection`,reconnect:`Update key`,configureToken:`Set up MCP Token`,tokenPrepared:`Connection prepared. Add your Token to connect.`,expired:`Connection request expired`,rejected:`The service rejected the current key`,token:`Access key required`,oauth:`Sign-in required`,unknown:`Could not verify the authentication method`,failed:`Connection check failed`,planned:`Checking the connection`,approval:`Review the service and its sources`,reload:`Settings saved. Restart the Gateway to apply them.`,help:`Get an access key`,connected:`Connection complete`,continuing:`Connection complete. Your task will resume automatically.`,cancelFailed:`Could not cancel the connection. Try again.`}};function dE({conversationId:e}){let t=y(e=>e.language),[n,r]=d(),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(),[c,l]=(0,Q.useState)(),u=uE[t];(0,Q.useEffect)(()=>{if(!c)return;let e=window.setTimeout(()=>l(void 0),8e3);return()=>window.clearTimeout(e)},[c]);let f=n.get(`mcpSetup`),p=e=>{let t=new URLSearchParams(n);e?t.set(`mcpSetup`,e):t.delete(`mcpSetup`),r(t,{replace:!e})},{data:m,mutate:g}=vi(`/api/mcp/setup/conversations/${encodeURIComponent(e)}`,async e=>{try{return{permitted:!0,...(await b(_(e))).payload}}catch(e){if([403,404].includes(e.status??0))return{permitted:!1,setup:null};throw e}},{refreshInterval:e=>e?.setup?5e3:0,shouldRetryOnError:!1});(0,Q.useEffect)(()=>{if(m?.permitted===!1)return;let t=t=>{let n=t.detail;(n?.conversationId??n?.key)===e&&g()},n=()=>{g()};return window.addEventListener(`session-mcp-setup-changed`,t),window.addEventListener(`session-transcript-updated`,t),window.addEventListener(`gateway-realtime-connected`,n),()=>{window.removeEventListener(`session-mcp-setup-changed`,t),window.removeEventListener(`session-transcript-updated`,t),window.removeEventListener(`gateway-realtime-connected`,n)}},[e,g,m?.permitted]);let v=f?(0,X.jsx)(Q.Suspense,{fallback:null,children:(0,X.jsx)(lE,{setupId:f,onClose:t=>{t?.phase===`ready`&&!t.reloadRequired&&t.conversationId===e&&l({conversationId:e,label:t.displayName||t.serverId,continuing:t.continuationQueued===!0&&t.objective!==`connect_only`}),p(null),g()}})}):null;if(!m?.setup)return(0,X.jsxs)(X.Fragment,{children:[c?.conversationId===e?(0,X.jsxs)(`section`,{className:`mb-2 flex items-center gap-3 rounded-xl border border-edge bg-success-soft px-3 py-2 text-sm text-fg`,children:[(0,X.jsx)(ne,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,X.jsxs)(`p`,{role:`status`,className:`min-w-0 flex-1 break-words`,children:[c.label,` · `,c.continuing?u.continuing:u.connected]}),(0,X.jsx)(qi,{variant:`ghost`,className:`size-11 shrink-0 p-0`,"aria-label":u.close,onClick:()=>l(void 0),children:(0,X.jsx)(an,{className:`size-4`,"aria-hidden":!0})})]}):null,v]});let x=m.setup,S=async()=>{a(!0),s(void 0);try{await b(_(`/api/mcp/setup/${encodeURIComponent(x.setupId)}`),{method:`POST`,body:JSON.stringify({action:`cancel`,expectedVersion:x.version})}),f===x.setupId&&p(null),await g(e=>e?.setup?.setupId===x.setupId?{...e,setup:null}:e)}catch{s(x.setupId),g()}finally{a(!1)}},C=x.errorCode===`credential_rejected`,w=x.expired?u.expired:x.reloadRequired?u.reload:C?u.rejected:x.approveWithToken?u.tokenPrepared:x.phase===`token_required`?u.token:[`oauth_required`,`authorizing`].includes(x.phase)?u.oauth:x.phase===`auth_unknown`?u.unknown:x.phase===`blocked`?u.failed:x.phase===`approval_required`?u.approval:x.phase===`ready`?u.connected:u.planned,T=x.expired||x.reloadRequired?u.review:C?u.reconnect:x.approveWithToken?u.configureToken:x.phase===`approval_required`?u.source:x.phase===`token_required`||x.canProvideToken?u.enter:x.phase===`oauth_required`?u.login:x.phase===`authorizing`?u.waiting:[`blocked`,`auth_unknown`,`ready`].includes(x.phase)?u.review:u.finish;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`section`,{className:`mb-2 flex flex-wrap items-center gap-2 rounded-xl border border-edge bg-surface-panel px-3 py-2`,"aria-label":u.connection,children:[(0,X.jsx)(We,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 break-words text-sm`,role:`status`,children:[(0,X.jsx)(`p`,{className:`font-medium text-fg`,children:x.displayName||x.serverId}),x.purpose&&!x.approveWithToken?(0,X.jsx)(`p`,{className:`mt-0.5 break-words text-sm text-fg-muted`,children:x.purpose}):null,(0,X.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:w})]}),(0,X.jsx)(qi,{asChild:!0,variant:`primary`,className:`min-h-11 shrink-0 rounded-lg`,children:(0,X.jsx)(h,{to:`/mcp-setup/${encodeURIComponent(x.setupId)}`,onClick:e=>{e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),p(x.setupId))},children:T})}),(0,X.jsx)(qi,{variant:`ghost`,className:`size-11 shrink-0 p-0`,"aria-label":u.cancel,title:u.cancel,disabled:i,onClick:()=>void S(),children:(0,X.jsx)(an,{className:`size-4`,"aria-hidden":!0})}),!x.expired&&x.phase===`token_required`&&x.helpUrl?(0,X.jsx)(`div`,{className:`basis-full pl-6`,children:(0,X.jsxs)(`a`,{href:x.helpUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex min-h-11 items-center text-sm text-accent-fg hover:underline`,children:[u.help,` ↗`]})}):null,o===x.setupId?(0,X.jsx)(`span`,{role:`alert`,className:`basis-full text-sm text-fg-muted`,children:u.cancelFailed}):null]}),v]})}var fE=(0,Q.lazy)(()=>u(()=>import(`./agent-plugin-dialog-RZpnW9HG.js`).then(e=>e.n).then(e=>({default:e.AgentPluginDialog})),__vite__mapDeps([30,1,2,3,4,5,6,7,8,9,31,11,32,33,34,16,17,18,29,20,21,35,36,13,37,38,39,40,41,27,28,42,43,44,45]))),pE={zh:{waiting:`等待连接`,reconnectRequired:`需要重新授权`,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`,reconnectRequired:`Reauthorization required`,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.`}},mE=`rounded-lg border border-edge px-3 py-1.5 text-sm text-fg hover:bg-surface-hover disabled:opacity-50`,hE=`rounded-lg bg-accent px-3 py-1.5 text-sm text-on-accent disabled:opacity-50`;function gE({conversationId:e}){let{wait:t,busy:n,error:r,cancellationError:i,act:a,dismissError:o}=sE(e),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(),[d,f]=(0,Q.useState)(),[p,m]=(0,Q.useState)(),[h,g]=(0,Q.useState)(),[v,x]=(0,Q.useState)(!1),[S,T]=(0,Q.useState)(),M=y(e=>e.language),N=pE[M];if(!t)return i?(0,X.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,X.jsx)(`p`,{className:`min-w-0 flex-1`,children:i}),(0,X.jsx)(`button`,{type:`button`,onClick:o,className:mE,children:N.close})]}):(0,X.jsx)(dE,{conversationId:e});let P=t.needs[0],F=t.needs.length===1,I=F&&P.phase===`reconnect`,L=t.phase===`queued`,R=t.recoveryStage===`checking_connection`||t.recoveryStage===`checking_tools`,z=t.needs.find(e=>e.phase===`choose_account`),B=t.needs.some(e=>e.capabilityError);if(t.phase===`ready`&&!R&&!t.recoveryError&&!t.needs.some(e=>e.target.type===`plugin`))return(0,X.jsx)(dE,{conversationId:e});let V=t.recoveryStage===`checking_connection`?N.checkingConnection:t.recoveryStage===`checking_tools`?N.checkingTools:L?t.resolution===`skipped`?N.queuedSkipped:N.queued:t.recoveryError===`check_failed`?N.checkFailed:t.recoveryError?N.interrupted:t.phase===`ready`?N.ready:B?N.toolsUnavailable:z?N.account:F&&P.phase===`authorizing`?N.authorizing:I?N.reconnectRequired:N.waiting,H=L||R?N.details:t.recoveryError?N.retry:t.phase===`review_scope`?N.scope:F&&P.phase===`install`?v?N.installing:`${N.install} ${P.label}`:F&&P.phase===`connect`?M===`zh`?`连接 ${P.label}`:`Connect ${P.label}`:F&&P.phase===`reconnect`?N.reconnect:F&&P.phase===`authorizing`&&P.target.type!==`plugin`?N.check:N.details;async function U(e=P){if(e.target.type===`store-connector`){x(!0),T(void 0);try{let t=await Ba(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(M===`zh`?`Connector 包在审查后发生了变化,请重新发起推荐。`:`The Connector package changed after review. Request a new recommendation.`);f(Dt(t.definition,{packageName:t.packageName,version:t.version,reviewHash:t.reviewHash,permissions:t.permissions})),m(e.key)}catch(e){T(e instanceof Error?e.message:String(e))}finally{x(!1)}}}async function W(e){if(!(e.target.type!==`plugin`||!t)){x(!0),T(void 0);try{let{target:n,pluginId:r}=e,i=r?(await b(_(`/api/extensions/agent-plugins/${encodeURIComponent(r)}`))).payload:void 0,o=`packageName`in n&&!i?`store:${n.packageName}@${n.version}`:void 0;if(!i&&!o||!await a(`connect`,e.key))return;c(!1),g({waitId:t.id,extension:i,source:o})}catch(e){T(e instanceof Error?e.message:String(e))}finally{x(!1)}}}function ee(){L||R?c(!0):t?.recoveryError?a(`check`):t?.phase===`review_scope`?c(!0):F&&P.target.type===`plugin`&&[`install`,`connect`,`reconnect`,`authorizing`].includes(P.phase)?W(P):F&&P.phase===`install`?U():F&&[`connect`,`reconnect`].includes(P.phase)?a(`connect`,P.key):F&&P.phase===`authorizing`?a(`check`):c(!0)}return(0,X.jsxs)(`section`,{className:`mb-2 rounded-xl border border-edge bg-surface-panel px-3 py-2`,"aria-label":V,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(We,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,X.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left text-sm text-fg`,onClick:()=>c(!0),children:[(0,X.jsx)(`span`,{role:`status`,children:F?`${V} · ${P.label}`:`${V} · ${t.needs.length} ${N.apps}`}),(0,X.jsx)(ie,{className:`ml-1 inline size-3`,"aria-hidden":!0})]}),(0,X.jsxs)(`button`,{type:`button`,className:z||L||R?mE:hE,disabled:n&&!R||v,onClick:ee,children:[n&&(0,X.jsx)(qe,{className:`mr-1 inline size-3 animate-spin`,"aria-hidden":!0}),H]}),!L&&!R&&(0,X.jsx)(`button`,{type:`button`,className:`text-xs text-fg-muted hover:text-fg`,disabled:n,onClick:()=>void a(`skip`),children:N.skip}),(0,X.jsx)(`button`,{type:`button`,className:`min-h-11 px-2 text-xs text-fg-muted hover:text-fg`,onClick:()=>void a(`cancel`),children:N.cancel})]}),I&&!R&&!L?(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:N.intro}):null,t.queueBlocked&&(0,X.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.blockedInputId?N.interruptedInputHint:N.queueHint}),t.lastCheckedAt&&(0,X.jsxs)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:[N.lastChecked,`: `,new Date(t.lastCheckedAt).toLocaleTimeString(M===`zh`?`zh-CN`:`en-US`)]}),z&&!L&&(0,X.jsx)(`p`,{className:`mt-2 line-clamp-2 break-words text-sm text-fg-muted`,children:t.summary}),z&&!L&&(0,X.jsx)(cE,{need:z,language:M,disabled:n||R,onSelect:e=>void a(`select_account`,z.key,e),onConnect:()=>void a(`connect`,z.key)},`${t.id}:${t.objectiveRevision}:${z.key}`),(r||S)&&(0,X.jsxs)(`p`,{role:`alert`,className:`mt-2 text-xs text-fg-muted`,children:[r??S,` `,(0,X.jsx)(`button`,{type:`button`,className:`text-accent`,onClick:()=>void a(`check`),children:N.retry})]}),(0,X.jsx)(j,{open:s,onOpenChange:c,children:(0,X.jsxs)(O,{children:[(0,X.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[2px]`}),(0,X.jsxs)(k,{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,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-5 py-4`,children:[(0,X.jsx)(A,{className:`font-medium text-fg`,children:N.preserved}),(0,X.jsx)(D,{"aria-label":N.close,children:(0,X.jsx)(an,{className:`size-4`})})]}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto p-5`,children:[(0,X.jsx)(E,{className:`text-sm text-fg-muted`,children:B?N.toolsHint:t.phase===`review_scope`?N.scopeHint:N.intro}),(0,X.jsx)(`p`,{className:`whitespace-pre-wrap rounded-lg border border-edge p-3 text-sm text-fg`,children:t.summary}),(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:new Date(t.objectiveUpdatedAt).toLocaleString(M===`zh`?`zh-CN`:`en-US`)}),t.timeRange&&(0,X.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[new Date(t.timeRange.from).toLocaleString(M,{timeZone:t.timeRange.timezone}),` – `,new Date(t.timeRange.to).toLocaleString(M,{timeZone:t.timeRange.timezone}),` (`,t.timeRange.timezone,`)`]}),t.needs.map(e=>(0,X.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-edge p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsxs)(`span`,{className:`text-sm font-medium text-fg`,children:[e.label,e.accountSelector?` · ${e.accountSelector}`:``]}),e.capabilityError?(0,X.jsx)(`button`,{type:`button`,disabled:n||L,className:mE,onClick:()=>void a(`check`),children:N.retry}):e.phase===`ready`?(0,X.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[(0,X.jsx)(ne,{className:`mr-1 inline size-3`}),N.ready]}):e.target.type===`plugin`&&e.phase!==`blocked`?(0,X.jsx)(`button`,{type:`button`,disabled:n||L||v,className:hE,onClick:()=>void W(e),children:e.phase===`install`?N.install:e.phase===`reconnect`?N.reconnect:N.connect}):e.phase===`authorizing`?(0,X.jsx)(`button`,{type:`button`,disabled:n,className:mE,onClick:()=>void a(`check`),children:N.check}):e.phase===`install`?(0,X.jsx)(`button`,{type:`button`,disabled:n||L||v,className:hE,onClick:()=>void U(e),children:N.install}):e.phase!==`blocked`&&e.phase!==`choose_account`?(0,X.jsx)(`button`,{type:`button`,disabled:n||L,className:hE,onClick:()=>void a(`connect`,e.key),children:e.phase===`reconnect`?N.reconnect:N.connect}):null]}),e.accountId&&(0,X.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,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(pe,{value:l?.needKey===e.key?l.candidateRef:``,options:e.alternatives.map(e=>({value:e.candidateRef,label:e.label})),placeholder:N.replace,ariaLabel:`${e.label}: ${N.replace}`,disabled:n||L,allowEmpty:!1,onChange:t=>u({needKey:e.key,candidateRef:t,label:e.alternatives.find(e=>e.candidateRef===t).label})}),l?.needKey===e.key&&(0,X.jsxs)(`button`,{type:`button`,className:mE,disabled:n,onClick:()=>{a(`replace_source`,e.key,void 0,l.candidateRef),u(void 0)},children:[N.confirmReplace,` `,l.label]})]}):null,e.reason&&(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.reason}),e.phase===`authorizing`&&e.target.type!==`plugin`&&(0,X.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-fg-muted`,children:[(0,X.jsx)(`span`,{children:N.authorizing}),(0,X.jsx)(`button`,{type:`button`,disabled:n,className:`text-accent`,onClick:()=>void a(`connect`,e.key),children:N.reconnect})]})]},e.key)),(0,X.jsx)(`a`,{href:`#/capabilities/connectors`,className:`text-sm text-accent`,onClick:()=>c(!1),children:N.all})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-t border-edge p-4`,children:[(0,X.jsx)(`button`,{type:`button`,className:`min-h-11 text-sm text-fg-muted`,onClick:()=>void a(`cancel`),children:N.cancel}),t.phase===`review_scope`?(0,X.jsx)(`button`,{type:`button`,disabled:n||L,className:hE,onClick:()=>void a(`confirm_scope`),children:N.scope}):null]})]})]})}),h?.waitId===t.id?(0,X.jsx)(Q.Suspense,{fallback:(0,X.jsx)(sn,{className:`mt-2 h-10 w-full`}),children:(0,X.jsx)(fE,{extension:h.extension,initialSource:h.source,connectionFlow:!0,onClose:()=>g(void 0)})}):null,d?(0,X.jsx)(Ot,{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:C(M).connectorsSettings}):null]})}var _E=new Set([`button`,`checkbox`,`color`,`file`,`hidden`,`image`,`radio`,`range`,`reset`,`submit`]);function vE(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&&!_E.has(t.type)}function yE(){return!!document.querySelector(`dialog[open], [aria-modal="true"], [role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]`)}function bE(e,t){return t.disabled||t.editorHidden||e.defaultPrevented||vE(e.target)||vE(document.activeElement)?!1:!yE()}function xE(e){for(let t=e.parentElement;t;t=t.parentElement)if(/(auto|scroll)/.test(getComputedStyle(t).overflowY))return t;return null}function SE({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=xE(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 CE(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 wE(e){let t=CE(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 TE=(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=C(y(e=>e.language)),m=(0,Q.useRef)(!1),h=e.filter(e=>e.status===`queued`),g=!!(t||d),_=SE({items:e,disabled:g,onReorder:o}),v=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`,Ma.focusRingPanel),b=`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,X.jsxs)(`div`,{ref:_.listRef,className:`space-y-1 px-2 py-2`,onClickCapture:_.onClickCapture,role:`list`,"aria-label":p.chat.followUpQueueAria,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2 pb-1`,children:[(0,X.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:p.chat.followUpQueueHeading}),(0,X.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`,y=h.findIndex(t=>t.id===e.id),x=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=Hr(e.text),D=new Map(e.contextRefs?.flatMap(e=>e.refId?[[e.refId,e.title]]:[])??[]),O=new Set(E?In(E):[]),k=e.contextRefs?.filter(e=>!e.refId||!O.has(e.refId)),A=Cr(E?nr(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,X.jsxs)(`div`,{role:`listitem`,"data-follow-up-id":e.id,"data-follow-up-sortable":!g&&t,onPointerDown:t=>_.onPointerDown(t,e),onDragStart:e=>e.preventDefault(),style:{transform:_.view?.shifts[e.id]?`translateY(${_.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`,!g&&t&&`cursor-grab`,_.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,X.jsx)(`div`,{"data-follow-up-drag-handle":!0,className:Y(`flex shrink-0 touch-none cursor-grab items-center active:cursor-grabbing`,(g||!t)&&`cursor-not-allowed opacity-40`),title:p.chat.followUpQueueDrag,children:(0,X.jsx)(nc,{className:`size-3.5 text-fg-muted`,"aria-hidden":!0})}),(0,X.jsx)(`button`,{type:`button`,"data-follow-up-drag-surface":!0,disabled:g||!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`,Ma.focusRingPanel,`disabled:pointer-events-none disabled:opacity-50`),onClick:()=>r(e.id),children:e.attachments?.length?(0,X.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1`,children:[(0,X.jsx)(De,{className:`size-3 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`truncate`,children:A})]}):(0,X.jsx)(`span`,{className:`line-clamp-2 break-words [overflow-wrap:anywhere]`,children:A})}),k?.length?(0,X.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,X.jsx)(lc,{className:`size-3`,"aria-hidden":!0}),k.length]}):null,T?(0,X.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,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,X.jsxs)(`button`,{type:`button`,className:v,disabled:g||(x?!o:!S),title:x?p.chat.sendThisMessage:p.chat.followUpQueueSteerHint,"aria-label":x?p.chat.sendThisMessage:p.chat.followUpQueueSteerNow,"aria-busy":w,onClick:()=>x?c?.(e.id):s(e.id),children:[(0,X.jsx)(Ys,{className:Y(`size-4`,w&&`motion-safe:animate-pulse`),"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`hidden text-xs sm:inline`,children:x?p.chat.sendThisMessage:p.chat.followUpQueueSteerNow})]}),(0,X.jsx)(`button`,{type:`button`,className:Y(v,`px-1.5 hover:text-danger`),disabled:g||!o,title:p.chat.followUpQueueRemove,"aria-label":p.chat.followUpQueueRemove,onClick:()=>i(e.id),children:(0,X.jsx)(Xt,{className:`size-4`,"aria-hidden":!0})}),(0,X.jsxs)(Bo,{modal:!1,children:[(0,X.jsx)(Vo,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:Y(v,`px-1.5`),disabled:g,title:p.chat.followUpQueueMore,"aria-label":p.chat.followUpQueueMore,children:(0,X.jsx)(Se,{className:`size-4`,"aria-hidden":!0})})}),(0,X.jsx)(Ho,{children:(0,X.jsxs)(Wo,{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,X.jsxs)(Uo,{className:b,disabled:!t,onSelect:()=>{m.current=!0,r(e.id)},children:[(0,X.jsx)(jt,{className:`size-4`,"aria-hidden":!0}),p.chat.followUpQueueClickToEdit]}),f?(0,X.jsxs)(Uo,{className:b,disabled:!C,onSelect:()=>f(e,A),children:[(0,X.jsx)(ac,{className:`size-4`,"aria-hidden":!0}),p.chat.followUpQueueOpenSideChat]}):null,h.length>1?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Go,{className:`my-1 h-px bg-edge-subtle`}),(0,X.jsxs)(Uo,{className:b,disabled:!t||y===0,onSelect:()=>a(e.id,`up`),children:[(0,X.jsx)(ae,{className:`size-4`,"aria-hidden":!0}),p.chat.followUpQueueMoveUp]}),(0,X.jsxs)(Uo,{className:b,disabled:!t||y>=h.length-1,onSelect:()=>a(e.id,`down`),children:[(0,X.jsx)(re,{className:`size-4`,"aria-hidden":!0}),p.chat.followUpQueueMoveDown]})]}):null]})})]})]})]},e.id)})]})});function EE({conversationId:e}){let t=v(e=>e.conversationId),n=y(e=>e.language).startsWith(`zh`),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(``),s=vi(e?[`session-preparation`,t,e]:null,async()=>{let t=await $r(e);if(t&&!t.materialization)return null;let n=await b(_(`/api/sessions/${encodeURIComponent(e)}/input-state`));return n.payload.preparation?Xr.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 g(_(`/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,X.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 text-sm text-fg-muted`,role:`status`,children:[(0,X.jsx)(`span`,{children:l.state===`preparing`?n?`正在准备会话环境…`:`Preparing conversation environment…`:l.lastError??(n?`会话环境准备失败`:`Conversation environment preparation failed`)}),l.state===`preparation_failed`?(0,X.jsx)(`button`,{type:`button`,className:`ml-2 text-accent-fg`,disabled:r,onClick:()=>void u(),children:n?`重试准备`:`Retry preparation`}):null,a?(0,X.jsx)(`span`,{role:`alert`,className:`ml-2`,children:a}):null]})}function DE(e){let t=(0,Z.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,X.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,X.jsx)(Ae,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.kind===`file`||e.kind===`result`?(0,X.jsx)(Ee,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.kind===`session`?(0,X.jsx)(yt,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.kind===`browser_tab`?(0,X.jsx)(N,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,X.jsx)(lc,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`truncate`,children:e.title}),(0,X.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,X.jsx)(an,{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,X.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 OE=`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 kE(e){let t=(0,Z.c)(96),{conversationId:n,project:r,workspacePath:i,canChangeWorkspace:a,disabled:o,directoryStatus:s,onProjectChange:c,onWorkspaceChange:l}=e,u=y(NE),d;t[0]===u?d=t[1]:(d=C(u),t[0]=u,t[1]=d);let f=d,p=f.chat.composerContext,m=v(ME),h=v(jE),[g,_]=(0,Q.useState)(``),[b]=So(g,200),x;t[2]!==h||t[3]!==b||t[4]!==m?(x=[`composer-projects`,h,m,b],t[2]=h,t[3]=b,t[4]=m,t[5]=x):x=t[5];let S;t[6]===b?S=t[7]:(S=()=>Cn({status:`active`,search:b,sortBy:`updatedAt`,sortOrder:`desc`,limit:50}),t[6]=b,t[7]=S);let w;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(w={keepPreviousData:!1,shouldRetryOnError:!1},t[8]=w):w=t[8];let T=vi(x,S,w),E=up(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=ho(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,X.jsx)(`button`,{type:`button`,disabled:o,title:f.chat.scopeRemoveProject,"aria-label":f.chat.scopeRemoveProject,className:Y(OE,`size-7 shrink-0 px-0 ml-0.5 text-fg-muted`),onClick:()=>c(null),children:(0,X.jsx)(an,{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 ee;t[30]===W?ee=t[31]:(ee=W.map(AE),t[30]=W,t[31]=ee);let te=p.chooseProject,ne=p.changeProject,re=p.changeProject,ie=p.noProject,ae=p.searchProjects,oe=T.isLoading,ce=T.error?p.projectsFailed:T.data?.items.length===0?p.noProjects:void 0,le=r&&`pl-1`,ue;t[32]===le?ue=t[33]:(ue=Y(OE,`h-8 w-auto max-w-44 gap-1 border-0 bg-transparent pr-2.5 text-sm [&>svg]:hidden [&>span]:text-fg`,le),t[32]=le,t[33]=ue);let de;t[34]!==c||t[35]!==r?.id?(de=e=>{e!==(r?.id??``)&&c(e||null)},t[34]=c,t[35]=r?.id,t[36]=de):de=t[36];let fe;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]!==g||t[44]!==H||t[45]!==U||t[46]!==ee||t[47]!==ce||t[48]!==ue||t[49]!==de?(fe=(0,X.jsx)(pe,{value:H,selectedLabel:U,options:ee,placeholder:te,ariaLabel:ne,title:re,emptyLabel:ie,disabled:o,side:`top`,align:`start`,searchPlaceholder:ae,searchValue:g,onSearchChange:_,loading:oe,statusMessage:ce,triggerClassName:ue,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:de}),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]=g,t[44]=H,t[45]=U,t[46]=ee,t[47]=ce,t[48]=ue,t[49]=de,t[50]=fe):fe=t[50];let G;t[51]!==B||t[52]!==V||t[53]!==fe?(G=(0,X.jsxs)(`div`,{className:B,children:[V,fe]}),t[51]=B,t[52]=V,t[53]=fe,t[54]=G):G=t[54];let me=r?s:null,he;t[55]!==n||t[56]!==D||t[57]!==r?(he=r&&n&&D&&(D.headSha||D.branch)?(0,X.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,X.jsx)(uc,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}):(0,X.jsx)(Ue,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),D.kind===`managed_worktree`?`Worktree`:`Local`]}):null,t[55]=n,t[56]=D,t[57]=r,t[58]=he):he=t[58];let K;t[59]!==p.retryProjects||t[60]!==T?(K=T.error?(0,X.jsx)(`button`,{type:`button`,className:Y(OE,`size-7 px-0`),"aria-label":p.retryProjects,onClick:()=>void T.mutate(),children:(0,X.jsx)(It,{className:`size-3.5`,"aria-hidden":!0})}):null,t[59]=p.retryProjects,t[60]=T,t[61]=K):K=t[61];let ge;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?(ge=r?null:(0,X.jsxs)(`button`,{type:`button`,className:Y(OE,`max-w-52`),disabled:o||!a||P.picking,title:F,"aria-label":p.chooseFolder,onClick:P.pick,children:[(0,X.jsx)(ke,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),k?(0,X.jsx)(`span`,{className:`truncate`,children:mo(k)}):E.isLoading?(0,X.jsx)(sn,{className:`h-4 w-16`}):(0,X.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]=ge):ge=t[71];let _e;t[72]!==L||t[73]!==D?(_e=L?(0,X.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,X.jsx)(je,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`truncate`,children:L})]}):null,t[72]=L,t[73]=D,t[74]=_e):_e=t[74];let q;t[75]===A?q=t[76]:(q=A?(0,X.jsx)(`p`,{role:`alert`,className:`w-full px-2 py-1 text-xs text-danger`,children:A}):null,t[75]=A,t[76]=q);let ve;t[77]!==p.label||t[78]!==G||t[79]!==me||t[80]!==he||t[81]!==K||t[82]!==ge||t[83]!==_e||t[84]!==q?(ve=(0,X.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:[G,me,he,K,ge,_e,q]}),t[77]=p.label,t[78]=G,t[79]=me,t[80]=he,t[81]=K,t[82]=ge,t[83]=_e,t[84]=q,t[85]=ve):ve=t[85];let ye;t[86]!==f.chat.workingDirectory||t[87]!==P.confirmPick||t[88]!==P.hasNativePicker||t[89]!==P.modalOpen||t[90]!==P.setModalOpen||t[91]!==k?(ye=P.hasNativePicker?null:(0,X.jsx)(se,{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]=ye):ye=t[92];let J;return t[93]!==ve||t[94]!==ye?(J=(0,X.jsxs)(X.Fragment,{children:[ve,ye]}),t[93]=ve,t[94]=ye,t[95]=J):J=t[95],J}function AE(e){return{value:e.id,label:e.name}}function jE(e){return e.baseUrl}function ME(e){return e.conversationId}function NE(e){return e.language}var PE=`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 FE(e){let t=(0,Z.c)(17),{disabled:n,attachmentCount:r,maxAttachments:i,chat:a,onPickFiles:o,addActions:s}=e,c=r>=i,l;t[0]!==a.attachFile||t[1]!==a.maxAttachmentsReached||t[2]!==c||t[3]!==i?(l=c?fh(a.maxAttachmentsReached,{max:i}):a.attachFile,t[0]=a.attachFile,t[1]=a.maxAttachmentsReached,t[2]=c,t[3]=i,t[4]=l):l=t[4];let u=l,d=n||!s&&c,f=s?.label??u,p=s?.label??u,m=s?void 0:o,h;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,X.jsx)(Ft,{className:`size-5`,"aria-hidden":!0}),t[5]=h):h=t[5];let g;t[6]!==d||t[7]!==f||t[8]!==p||t[9]!==m?(g=(0,X.jsx)(`button`,{type:`button`,className:PE,disabled:d,"aria-label":f,title:p,onClick:m,children:h}),t[6]=d,t[7]=f,t[8]=p,t[9]=m,t[10]=g):g=t[10];let _=g,v;return t[11]!==s||t[12]!==a.attachFile||t[13]!==c||t[14]!==o||t[15]!==_?(v=s?(0,X.jsx)(dh,{trigger:_,fileLabel:a.attachFile,filesDisabled:c,onPickFiles:o,actions:s}):_,t[11]=s,t[12]=a.attachFile,t[13]=c,t[14]=o,t[15]=_,t[16]=v):v=t[16],v}function IE(e){let t=(0,Z.c)(16),{disabled:n,voiceActive:r,runBusy:i,hasDraft:a,chat:o,onStartVoiceInput:s,onSend:c,onAbort:l}=e;if(r)return null;let u=i&&!a,d=u?o.abort:o.sendMessage,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,X.jsx)(bt,{className:`size-[1.125rem]`,"aria-hidden":!0}),t[0]=f):f=t[0];let p;t[1]!==o.voiceInput||t[2]!==n||t[3]!==s?(p=(0,X.jsx)(`button`,{type:`button`,className:PE,disabled:n,title:o.voiceInput,"aria-label":o.voiceInput,onClick:s,children:f}),t[1]=o.voiceInput,t[2]=n,t[3]=s,t[4]=p):p=t[4];let m;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=Y(PE,`bg-accent text-on-accent hover:bg-accent-hover hover:text-on-accent disabled:bg-surface-hover disabled:text-fg-disabled`),t[5]=m):m=t[5];let h=!u&&(n||!a),g=u?l:c,_;t[6]===u?_=t[7]:(_=u?(0,X.jsx)(Kt,{className:`size-4 fill-current`,"aria-hidden":!0}):(0,X.jsx)(R,{className:`size-5`,"aria-hidden":!0}),t[6]=u,t[7]=_);let v;t[8]!==d||t[9]!==h||t[10]!==g||t[11]!==_?(v=(0,X.jsx)(`button`,{type:`button`,className:m,disabled:h,"aria-label":d,title:d,onClick:g,children:_}),t[8]=d,t[9]=h,t[10]=g,t[11]=_,t[12]=v):v=t[12];let y;return t[13]!==p||t[14]!==v?(y=(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[p,v]}),t[13]=p,t[14]=v,t[15]=y):y=t[15],y}function LE(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 RE=100,zE=400,BE=900;function VE(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 HE(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 UE(e){let t=(0,Z.c)(8),{name:n,query:r}=e,i;t[0]!==n||t[1]!==r?(i=HE(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,X.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,X.jsx)(`span`,{className:`font-medium text-fg`,children:n.slice(r,i)},`pre-${i}`)),e.push((0,X.jsx)(`span`,{className:`font-semibold text-accent-fg`,children:n.slice(i,a)},`hl-${i}-${a}`)),r=a}),r<n.length&&e.push((0,X.jsx)(`span`,{className:`font-medium text-fg`,children:n.slice(r)},`tail`)),o=(0,X.jsx)(X.Fragment,{children:e}),t[5]=n,t[6]=a,t[7]=o}else o=t[7];return o}var WE=(0,Q.memo)(function(e){let t=(0,Z.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)(VE,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&&vo(i,{conversationId:l}).then(e=>{let{content:i}=e,a=i.length>BE?`${i.slice(0,BE)}…`: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,k;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`})},k=[n,a,i.length],t[8]=i.length,t[9]=n,t[10]=a,t[11]=O,t[12]=k):(O=t[11],k=t[12]),(0,Q.useLayoutEffect)(O,k),!n||typeof document>`u`||_===null)return null;let A=i.length,j=Math.min(_.width,zE),M;t[13]!==_.left||t[14]!==_.top||t[15]!==j?(M={position:`fixed`,left:_.left,top:_.top,width:j,transform:`translateY(calc(-100% - 8px))`,zIndex:RE},t[13]=_.left,t[14]=_.top,t[15]=j,t[16]=M):M=t[16];let P=a>=0&&a<A?`at-mention-${a}`:void 0,F;t[17]!==o||t[18]!==A?(F=o&&A===0?(0,X.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2.5 text-sm text-fg-muted`,children:[(0,X.jsx)(qe,{className:`size-4 shrink-0 animate-spin`,"aria-hidden":!0}),(0,X.jsx)(`span`,{children:`…`})]}):null,t[17]=o,t[18]=A,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]!==A?(I=!o&&A===0?(0,X.jsx)(`div`,{className:`px-3 py-2 text-sm text-fg-muted`,children:c}):(0,X.jsxs)(X.Fragment,{children:[i.map((e,t)=>{let n=i[t-1]?.kind,r=d[e.kind],o=e.kind===`file`&&e.isRecent;return(0,X.jsxs)(Q.Fragment,{children:[n===e.kind?null:(0,X.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,X.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,X.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:e.kind===`note`?(0,X.jsx)(lc,{className:`size-3.5 text-accent-fg`,"aria-hidden":!0}):e.kind===`session`?(0,X.jsx)(yt,{className:`size-3.5 text-violet-600 dark:text-violet-400`,"aria-hidden":!0}):e.kind===`skill`?(0,X.jsx)(Gt,{className:`size-3.5 text-cyan-600 dark:text-cyan-400`,"aria-hidden":!0}):e.kind===`agent`?(0,X.jsx)(te,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):e.kind===`browser_tab`?(0,X.jsx)(N,{className:`size-3.5 text-blue-600 dark:text-blue-400`,"aria-hidden":!0}):e.isBrowseUp?(0,X.jsx)(Ae,{className:`size-3.5 text-fg-muted`,"aria-hidden":!0}):e.isDirectory?(0,X.jsx)(Ae,{className:`size-3.5 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}):(0,X.jsx)(Ee,{className:Y(`size-3.5`,ye(e.name)),"aria-hidden":!0})}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 truncate`,children:[(0,X.jsx)(`span`,{className:`truncate`,children:(0,X.jsx)(UE,{name:e.name,query:s})}),o?(0,X.jsx)(`span`,{className:`shrink-0 rounded bg-accent-soft px-1 py-0 text-[0.65rem] text-accent-fg`,children:u}):null]}),(0,X.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:e.description||r})]})]})]},e.id)}),o&&A>0?(0,X.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-edge-subtle px-3 py-2 text-xs text-fg-muted`,children:[(0,X.jsx)(qe,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),(0,X.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]=A,t[30]=I):I=t[30];let L;t[31]!==f||t[32]!==F||t[33]!==I||t[34]!==P?(L=(0,X.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,X.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]!==M?(z=(0,Ec.createPortal)((0,X.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:M,role:`presentation`,children:[L,R]}),document.body),t[38]=L,t[39]=R,t[40]=M,t[41]=z):z=t[41],z});function GE(e,t){let n=e=>{e!==!1&&(e&&typeof e==`object`?t(e.conversationId):t())};e instanceof Promise?e.then(n).catch(e=>{Ua(`error`,e instanceof Error?e.message:String(e))}):n(e)}var KE=new Set([`abort`,`stop`,`cancel`]);function qE(e){if(e.kind!==`command`)return!1;if(KE.has(e.name.toLowerCase()))return!0;for(let t of e.aliases??[])if(KE.has(t.toLowerCase()))return!0;return!1}function JE(e,t,n,r){return e.slice(0,t)+r+e.slice(n)}var YE=(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=JE(t.editor.valueRef.current,n.start,n.end,r),a=n.start+r.length;t.editor.resetEditor({nextText:i,caretOffset:a,focus:!0})},XE=(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=JE(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(qE(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}GE(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()})},ZE=(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 QE(e,t){switch(e.kind){case`skill`:YE(e,t);return;case`command`:XE(e,t);return;case`agent`:ZE(e,t)}}var $E={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},eD=new Set([`abort`,`archive`]);function tD(e){if(e.kind===`command`){let t=e.name.toLowerCase();if($E[t]!==void 0)return 0;if(eD.has(t))return 2}return 1}function nD(e,t){let n=tD(e),r=tD(t);if(n!==r)return n-r;if(n===0){let n=$E[e.name.toLowerCase()]??999,r=$E[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 rD(e){if(e.kind!==`command`)return!1;if(KE.has(e.name.toLowerCase()))return!0;for(let t of e.aliases??[])if(KE.has(t.toLowerCase()))return!0;return!1}function iD(e,t){return e.kind!==`command`||e.acceptsArgs===!0||rD(e)||!(t.runBusy||t.pendingFollowUpsCount>0)?!1:t.pendingFollowUpsCount>=t.maxPendingFollowUps}function aD(e,t){return e.kind!==`command`||e.acceptsArgs===!0||rD(e)||!(t.runBusy||t.pendingFollowUpsCount>0)?!1:t.pendingFollowUpsCount<t.maxPendingFollowUps}function oD(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 sD(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 cD(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(sD(e,a))return null;let o=i[0],s=o.slice(1);return oD(s)||o.startsWith(`/skill:`)?null:{start:i.index,end:r,query:s}}function lD(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 uD(e,t){return t===0?0:Math.min(e,t-1)}function dD(e,t){let{query:n,value:r,commandsAllowed:i,agentsAllowed:a}=t,o=n.trim()===``,s=Dm(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=lD(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?nD(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 fD(e,t,n){let r=(0,Z.c)(49),[i,a]=(0,Q.useState)(0),[o,s]=(0,Q.useState)(0),c=y(hD),l=n?.capabilities??cm,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:cD(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,h;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(mD)};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},h=[],r[5]=m,r[6]=h):(m=r[5],h=r[6]),(0,Q.useEffect)(m,h);let g;r[7]!==c||r[8]!==n?.conversationId||r[9]!==n?.currentAgentId?(g=async()=>{let[e,t,r]=await Promise.allSettled([ns(),Xo(n?.currentAgentId,n?.conversationId),Ai()]),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(pD),o=(t.status===`fulfilled`?t.value.skills:[]).map(e=>{let t=rs(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=C(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:fo(e,s),description:po(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]=g):g=r[10];let _=n?.currentAgentId,v=n?.conversationId,b;r[11]!==c||r[12]!==o||r[13]!==_||r[14]!==v?(b=[c,_,v,o],r[11]=c,r[12]=o,r[13]=_,r[14]=v,r[15]=b):b=r[15];let x;r[16]===Symbol.for(`react.memo_cache_sentinel`)?(x=[],r[16]=x):x=r[16];let S;r[17]===Symbol.for(`react.memo_cache_sentinel`)?(S=[],r[17]=S):S=r[17];let w,T;r[18]===Symbol.for(`react.memo_cache_sentinel`)?(T={items:x,failedKinds:S},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=$a(g,b,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=dD(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=uD(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 pD(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 mD(e){return e+1}function hD(e){return e.language}var gD=100,_D=560;function vD(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase().indexOf(n);if(r>=0)return(0,X.jsxs)(X.Fragment,{children:[e.slice(0,r),(0,X.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,X.jsx)(`span`,{className:`text-accent-fg`,children:t},r)),a+=1):i.push((0,X.jsx)(Q.Fragment,{children:t},r)),o+=1}return(0,X.jsx)(X.Fragment,{children:i})}function yD(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase().indexOf(n);return r<0?e:(0,X.jsxs)(X.Fragment,{children:[e.slice(0,r),(0,X.jsx)(`span`,{className:`text-accent-fg`,children:e.slice(r,r+n.length)}),e.slice(r+n.length)]})}var bD=(0,Q.memo)(function(e){let t=(0,Z.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,X.jsx)(no,{agentId:n.agentId,avatar:n.avatar,size:18,className:`size-[18px] shrink-0`}):y?(0,X.jsx)(Gt,{className:`size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,X.jsx)(on,{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,X.jsx)(X.Fragment,{children:vD(n.name,o)}):(0,X.jsx)(`span`,{className:`text-fg`,children:n.name}):a?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`text-fg`,children:`/`}),vD(n.name,o)]}):(0,X.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=aD(n,e),D=iD(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,X.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,X.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,X.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,X.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,X.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?yD(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,X.jsx)(SD,{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}),xD=(0,Q.memo)(function(e){let t=(0,Z.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,_D),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(CD)),n=[`skill`,`command`,`agent`].filter(t=>e.has(t)||s.includes(t)),r=0;W=o&&P===0?(0,X.jsx)(`div`,{className:`space-y-2 p-2.5`,"aria-busy":`true`,children:Array.from({length:6},wD)}):P===0&&s.length===0?(0,X.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,X.jsxs)(`div`,{role:`group`,"aria-labelledby":o,className:Y(n>0&&`border-t border-edge-subtle`),children:[(0,X.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,X.jsx)(`span`,{children:V[t]}),(0,X.jsx)(`span`,{className:`tabular-nums`,"aria-hidden":!0,children:i.length})]}),s.includes(t)?(0,X.jsx)(`div`,{className:`px-2.5 pb-2 text-[11px] leading-relaxed text-fg-muted`,children:u}):i.map((e,t)=>(0,X.jsx)(bD,{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 ee=W,te;t[40]!==O.left||t[41]!==O.top||t[42]!==I?(te={position:`fixed`,left:O.left,top:O.top,width:I,transform:`translateY(calc(-100% - 8px))`,zIndex:gD},t[40]=O.left,t[41]=O.top,t[42]=I,t[43]=te):te=t[43];let ne=`${f}, ${p}, ${m}`,re=F?`${V[F.kind]}: ${F.name}`:``,ie;t[44]===re?ie=t[45]:(ie=(0,X.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:re}),t[44]=re,t[45]=ie);let ae;return t[46]!==ee||t[47]!==o||t[48]!==D||t[49]!==ne||t[50]!==ie||t[51]!==te?(ae=(0,Ec.createPortal)((0,X.jsx)(Co,{delayDuration:0,skipDelayDuration:0,disableHoverableContent:!1,children:(0,X.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:te,role:`listbox`,"aria-label":ne,"aria-busy":o,children:[ie,ee]})}),document.body),t[46]=ee,t[47]=o,t[48]=D,t[49]=ne,t[50]=ie,t[51]=te,t[52]=ae):ae=t[52],ae}),SD=(0,Q.memo)(function(e){let t=(0,Z.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,X.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,X.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,X.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,X.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,X.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,X.jsxs)(X.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,X.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,X.jsx)(Do,{asChild:!0,children:F}),t[32]=F,t[33]=e);let n;t[34]===M?n=t[35]:(n=(0,X.jsx)(wo,{children:(0,X.jsx)(Eo,{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,X.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,X.jsxs)(To,{delayDuration:0,children:[e,n]}),t[36]=e,t[37]=n,t[38]=r):r=t[38],r}return F});function CD(e){return[e.kind,e]}function wD(e,t){return(0,X.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,X.jsx)(sn,{className:`size-4 shrink-0`}),(0,X.jsx)(sn,{className:`h-3 w-28`}),(0,X.jsx)(sn,{className:`h-3 flex-1`})]},t)}var TD=new Map;function ED(e){let t=TD.get(e);return t||(t={items:[],loadPromise:null,loaded:!1,writeQueue:Promise.resolve(),mutationVersion:0,clearVersion:0},TD.set(e,t)),t}function DD(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 OD(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}DD(e,t)}function kD(e){return ED(e).items.map(e=>e.text)}function AD(e,t=!1){let n=ED(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(()=>b(`/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(()=>AD(e,!0))}),n.loadPromise}function jD(e,t){let n=t.trim();if(!n)return;let r=ED(e),i=r.clearVersion;r.mutationVersion+=1,DD(r,{conversationId:e,id:0,text:n,createdAt:Date.now()}),r.writeQueue=r.writeQueue.then(async()=>{let t=await b(`/api/composer-history`,{method:`POST`,body:JSON.stringify({conversationId:e,text:n})});r.clearVersion===i&&t.item.conversationId===e&&OD(r,t.item)}).catch(()=>{})}function MD(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=ED(t.conversationId);return n.mutationVersion+=1,OD(n,t),t.conversationId}function ND(e){if(!e||typeof e!=`object`||!(`conversationId`in e)||typeof e.conversationId!=`string`)return null;let t=ED(e.conversationId);return t.mutationVersion+=1,t.clearVersion+=1,t.items=[],e.conversationId}function PD(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&&AD(t,!0);let e=e=>{MD(e.detail)===t&&c()},n=e=>{ND(e.detail)===t&&c()},r=()=>{t&&AD(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&&!Hr(e)&&jD(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=kD(t);if(a.length===0)return!1;let o=s.current,c=n.current,l=c?Om(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 FD(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 ID(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 LD(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=performance.now(),r=FD(t.current);if(r===`blocked`)return;if(r===`queue`){D.current();return}let s=ID({voiceActive:i,cancelVoiceInput:a,...w});if(!s)return;if(r===`saveFollowUp`){if(O.current||!o)return;O.current=!0,Promise.resolve().then(()=>g(o,s.text,s.attachments,d(),s.contextRefs)).then(n=>{if(n===!1)return;C?.(s.text);let r=t.current;r.draftScope!==e.draftScope||r.editingFollowUpId!==o||r.getTextValue()!==s.text||JSON.stringify(r.wireAttachmentsPayload())!==JSON.stringify(s.attachments)||JSON.stringify(r.getContextRefs())!==JSON.stringify(s.contextRefs)||(r.onFinishFollowUpEdit?.(),S())}).catch(e=>Ua(`error`,e instanceof Error?e.message:String(e))).finally(()=>{O.current=!1});return}let c=[s.text,s.attachments.length>0?s.attachments:void 0,d(),s.contextRefs.length>0?s.contextRefs:void 0,{submittedAt:n,onDispatched:e=>p?.(e,s)}];GE(f(...c),n=>{C?.(s.text,n);let i=t.current,a=e.draftScope,o=i.draftScope;if(!(!(r===`send`&&a?.conversationId===null&&n!==void 0&&o?.conversationId===n&&o.gatewayIdentity===a.gatewayIdentity)&&o!==a||i.getTextValue()!==s.text||JSON.stringify(i.wireAttachmentsPayload())!==JSON.stringify(s.attachments)||JSON.stringify(i.getContextRefs())!==JSON.stringify(s.contextRefs))){if(r===`replaceTurn`){i.editingUserTurnId===e.editingUserTurnId&&i.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=!1,s=`steer`)=>{if(t.current.editingFollowUpId||t.current.editingUserTurnId){k();return}if(!r&&v===0)return;let c=ID({voiceActive:i,cancelVoiceInput:a,...w});if(c&&!t.current.blocked&&m&&!T.current){if(v>=10){Ua(`warning`,n.followUpQueueMaxReached,{max:10});return}T.current=!0;try{await m(c.text,c.attachments.length?c.attachments:void 0,c.contextRefs.length?c.contextRefs:void 0,o,s),C?.(c.text);let n=t.current;if(n.draftScope!==e.draftScope||n.editingFollowUpId||n.editingUserTurnId||n.getTextValue()!==c.text||JSON.stringify(n.wireAttachmentsPayload())!==JSON.stringify(c.attachments)||JSON.stringify(n.getContextRefs())!==JSON.stringify(c.contextRefs))return;y(),b(),x()}catch(e){Ua(`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.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=ID({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=>Ua(`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])}}var RD=e=>e?.kind===`editTurn`?`turn:${e.turnId}`:e?.kind===`editFollowUp`?`input:${e.inputId}:${e.version}`:`compose`,zD=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),BD=new Map;function VD(e,t){let n=(BD.get(e)??Promise.resolve()).catch(()=>{}).then(t);BD.set(e,n);let r=()=>{BD.get(e)===n&&BD.delete(e)};return n.then(r,r),n}function HD(e,t,n,r,i,a,o,s){let c=RD(a?.snapshot().mode),l=v(e=>e.conversationId),u=l&&e?JSON.stringify([l,e]):``,d=(0,Q.useRef)({editor:t,attachments:n,refs:r,setRefs:i,editSession:a});d.current={editor:t,attachments:n,refs:r,setRefs:i,editSession:a};let f=(0,Q.useRef)(void 0),p=(0,Q.useRef)(void 0),[m,h]=(0,Q.useState)(0);(0,Q.useLayoutEffect)(()=>{let t=p.current;p.current={identity:l,id:e,unboundDraftKey:o};let n=t?.identity===l&&t?.id===null&&!!e&&e===s?.(),r=t&&(t.identity!==l||t.id!==e||t.unboundDraftKey!==o)&&!n;if(r&&(d.current.editor.resetEditor(),d.current.attachments.clearAttachments(),d.current.setRefs([])),!u||!e){f.current=void 0;return}let i={receipts:[],scope:u,ready:!1,dirty:!1,observe:!1,snapshot:{text:d.current.editor.valueRef.current,attachments:d.current.attachments.attachmentsRef.current,refs:r?[]:d.current.refs,editSession:d.current.editSession?.snapshot()},storage:Qr(e)};f.current=i;let a=!1,c=BD.get(u);return(c?c.catch(()=>{}).then(()=>i.storage.read()):i.storage.read()).then(e=>{if(a=!0,f.current!==i)return;i.receipts=e?.intakeReceipts??[];let t=d.current;e&&!i.dirty&&!t.editor.valueRef.current&&!t.attachments.attachmentsRef.current.length&&!t.refs.length&&(t.editor.resetEditor({nextText:e.text}),t.attachments.setAttachments(e.attachments),t.setRefs(e.refs),e.editSession&&t.editSession?.restore(e.editSession))}).catch(e=>{console.warn(`Composer draft restoration failed`,e)}).finally(()=>{f.current===i&&(i.ready=a,a&&d.current.editSession?.ready?.(),h(e=>e+1))}),()=>{f.current===i&&(f.current=void 0)}},[u,e,l,o,s]),(0,Q.useLayoutEffect)(()=>{let e=f.current;if(!e||e.scope!==u)return;if(!e.observe){e.observe=!0;return}let i={text:t.value,attachments:n.attachments,refs:r,editSession:d.current.editSession?.snapshot()};(i.text!==e.snapshot.text||!zD(i.attachments,e.snapshot.attachments)||!zD(i.refs,e.snapshot.refs)||RD(i.editSession?.mode)!==RD(e.snapshot.editSession?.mode))&&(e.dirty=!0),e.snapshot=i},[u,t.value,n.attachments,r,c]),(0,Q.useEffect)(()=>{let e=f.current;if(!e||e.scope!==u||!e.ready&&!e.dirty)return;let i={text:t.value,attachments:n.attachments,refs:r,editSession:d.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;VD(u,()=>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)})},[u,m,t.value,n.attachments,r,c]),(0,Q.useEffect)(()=>{let e=f.current;if(!(!e?.ready||!u))return Pc(u,async(t,n)=>{if(await BD.get(u)?.catch(()=>{}),f.current!==e)throw Error(`Conversation changed. Please retry.`);if(e.receipts.includes(t))return;let r=d.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()};await VD(u,()=>e.storage.write(t))}catch(n){throw e.receipts=e.receipts.filter(e=>e!==t),n}})},[u,m])}function UD(e){let{conversationId:t,agentId:n,modelKey:r,locale:i,enabled:a,draftText:o,canShow:s}=e,c=v(e=>e.conversationId),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(null),p=(0,Q.useRef)(null),m=(0,Q.useRef)(o),h=(0,Q.useRef)(-1),y=(0,Q.useCallback)((e,t,n)=>{g(_(`/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)(()=>{m.current.length>0&&o.length===0&&(p.current=null),m.current=o},[o]),(0,Q.useEffect)(()=>{p.current=null,h.current=-1,u(null),f(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 $r(t))return;let d=await g(_(`/api/sessions/${encodeURIComponent(t)}/next-turn-suggestion?locale=${i}`),{signal:c.signal});if(!d.ok)return;let f=Cc.safeParse(await d.json());if(e||a!==r||!f.success)return;let p=f.data.suggestion;if(f.data.status===`ready`&&p&&p.conversationId===t&&p.locale===i&&(!n||p.agentId===n)&&p.inputRevision>=h.current&&p.expiresAt>Date.now()&&p.transcriptId===await qr(t)){if(e||a!==r)return;u(e=>e?.suggestion.id===p.id?e:{suggestion:p,impressionId:crypto.randomUUID()}),o=setTimeout(()=>{u(null)},Math.max(0,p.expiresAt-Date.now()))}else u(null),f.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<h.current)return;h.current=n.revision}r++,s=0,o&&clearTimeout(o),u(null),e.type===`session-transcript-updated`?o=setTimeout(()=>{l()},150):l()}},f=()=>{r++,s=0,o&&clearTimeout(o),u(null),l()},p=e=>{e.detail?.topic===`sessions`&&f()};l();let m=[`session-next-turn-suggestion-changed`,`session-input-state`,`session-updated`,`session-transcript-updated`];return m.forEach(e=>window.addEventListener(e,d)),window.addEventListener(`gateway-realtime-connected`,f),window.addEventListener(`config-reload`,f),window.addEventListener(`realtime-gap`,p),()=>{e=!0,r++,c.abort(),o&&clearTimeout(o),m.forEach(e=>window.removeEventListener(e,d)),window.removeEventListener(`gateway-realtime-connected`,f),window.removeEventListener(`config-reload`,f),window.removeEventListener(`realtime-gap`,p)}},[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?(p.current=b,y(b,`accepted`),b.suggestion.prompt):null,[b,y]),C=(0,Q.useCallback)(()=>{b&&(f(b.suggestion.id),y(b,`dismissed`))},[b,y]),w=(0,Q.useCallback)(e=>{let n=p.current;!n||n.suggestion.conversationId!==t||(f(n.suggestion.id),y(n,`submitted`,e.trim()!==n.suggestion.prompt),p.current=null)},[t,y]);return{suggestion:b?.suggestion??null,shown:x,accept:S,dismiss:C,submitted:w}}function WD(e){let t=(0,Z.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 GD=20,KD=`xopc.atMention.recent:`;function qD(e){return`${KD}${e.trim()}`}function JD(e){let t=e?.trim();if(!t||typeof localStorage>`u`)return[];try{let e=localStorage.getItem(qD(t));if(!e)return[];let n=JSON.parse(e);return Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.length>0).slice(0,GD):[]}catch{return[]}}function YD(e,t){let n=e?.trim(),r=t.trim();if(!(!n||!r||typeof localStorage>`u`))try{let e=[r,...JD(n).filter(e=>e!==r)].slice(0,GD);localStorage.setItem(qD(n),JSON.stringify(e))}catch{}}var XD=150,ZD=[`file`,`note`,`session`,`browser_tab`,`skill`,`agent`];function QD(e){let t={items:[],loading:e,error:null};return{file:{...t},note:{...t},session:{...t},skill:{...t},agent:{...t},browser_tab:{...t}}}function $D(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 eO(e){return e.replace(/[\\\s]/gu,e=>`\\${e}`)}function tO(e){let t=e.trim();return t.length>0&&t.endsWith(`/`)&&!/^https?:\/\//i.test(t)}function nO(e){return e.replace(/\/+$/,``).trim()}function rO(e){let t=e.replace(/\/+$/,``);if(!t)return``;let n=t.lastIndexOf(`/`);return n<=0?``:t.slice(0,n)}function iO(e,t){return t===0?0:Math.min(e,t-1)}function aO(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 oO(e,t,n){let r=(0,Z.c)(55),i=n.capabilities??cm,[a,o]=(0,Q.useState)(0),[s,c]=(0,Q.useState)(dO),l=(0,Q.useRef)(0),u=y(uO),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=$D(e,t),r[0]=t,r[1]=e,r[2]=i):i=r[2],d=i}let f=d,p=f!==null,[m]=So(p?f.query:``,XD),h=p?m:``,g;r[3]===n.conversationId?g=r[4]:(g=n.conversationId?.trim()??``,r[3]=n.conversationId,r[4]=g);let _=g,v;r[5]===n.selectedContextKeys?v=r[6]:(v=[...n.selectedContextKeys??new Set].sort().join(`\0`),r[5]=n.selectedContextKeys,r[6]=v);let b=v,x;r[7]!==i.agentSwitch||r[8]!==i.skills||r[9]!==_||r[10]!==h||r[11]!==u||r[12]!==n||r[13]!==p||r[14]!==b?(x=()=>{let e=l.current+=1;if(!p){c(QD(!1));return}if(!_){c(QD(!!n.prepareSession)),n.prepareSession&&n.prepareSession().catch(()=>{l.current===e&&c(QD(!1))});return}let t={conversationId:_,currentAgentId:n.currentAgentId,language:u,selectedContextKeys:new Set(b?b.split(`\0`):[]),recentPaths:new Set(JD(_))};if(tO(h)){let t=QD(!1);t.file={items:[],loading:!0,error:null},c(t);let r=nO(h);JT(r,{conversationId:_,agentId:n.currentAgentId}).then(t=>{if(l.current!==e)return;let n={id:`browse-up:${r}`,kind:`file`,name:`..`,description:rO(r)||`/`,relativePath:``,isDirectory:!0,isBrowseUp:!0};c(e=>({...e,file:{items:[n,...t.map(aO)],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(QD(!0));for(let n of ZT.filter(e=>(e.kind!==`skill`||i.skills)&&(e.kind!==`agent`||i.agentSwitch)))n.search(h,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]=_,r[10]=h,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]!==_||r[19]!==h||r[20]!==u||r[21]!==n.currentAgentId||r[22]!==n.prepareSession||r[23]!==p||r[24]!==b?(S=[p,_,h,u,n.currentAgentId,n.prepareSession,b,i.skills,i.agentSwitch],r[16]=i.agentSwitch,r[17]=i.skills,r[18]=_,r[19]=h,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=ZD.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(lO):[],E;r[35]!==p||r[36]!==w?(E=p&&w.some(cO),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(sO),r[38]=w,r[39]=O);let k=O,A=!D&&T.length===0?k[0]??null:null,j=`${f?.start??``}:${f?.end??``}:${h}`,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=iO(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 sO(e){return e.error?[e.error]:[]}function cO(e){return e.loading}function lO(e){return e.items}function uO(e){return e.language}function dO(){return QD(!1)}function fO(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 pO(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??cm,D=(0,Q.useMemo)(()=>$D(n,r),[n,r]),O=fD(n,r,{suppress:D!=null,capabilities:E,isComposing:i,currentAgentId:m,conversationId:t}),k=oO(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`||QE(e,j())},[j,E]),N=(0,Q.useCallback)(e=>{let n=k.atRange;if(!n)return;let r=fO(e);if(r){let i=_(r);if(!i?.refId)return;let a=`${er(i.refId)} `,o=JE(c.current,n.start,n.end,a);l({nextText:o,caretOffset:n.start+a.length,focus:!0}),t&&e.kind===`file`&&YD(t,e.relativePath);return}if(e.kind===`skill`){if(!E.skills)return;let t=`/skill:${e.canonicalName} `,r=JE(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=JE(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=`@${eO(e.isBrowseUp?(()=>{let e=rO(nO(n.query));return e?`${e}/`:``})():`${e.relativePath.replace(/\/+$/,``)}/`)}`,a=JE(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]);WD({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=JE(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]),ee=(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||iD(n,U.current)||V.current(n),!0}}if(e.key===`Escape`){e.preventDefault();let n=t.slashRange;if(n){let e=F.current,t=JE(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,ee],[W,ee]),applyPalette:M,applyAtMention:N}}function mO(e){return/^[A-Za-z0-9._/@:-]+$/.test(e)?e:JSON.stringify(e)}function hO(e,t){let n=t?.trim();return n?`${e} --instructions ${mO(n)}`:e}function gO(e){if(e.preset===`base`){if(!e.baseBranch?.trim())throw Error(`Missing base branch.`);return hO(`/review --base ${mO(e.baseBranch.trim())}`,e.instructions)}if(e.preset===`commit`){if(!e.commitSha?.trim())throw Error(`Missing commit SHA.`);return hO(`/review --commit ${mO(e.commitSha.trim())}`,e.instructions)}return e.preset,hO(`/review --uncommitted`,e.instructions)}async function _O(e){let t=await g(_(`/api/review/context?${new URLSearchParams({conversationId:e}).toString()}`)),n=await t.json().catch(()=>({}));if(!t.ok||!n.ok||!n.payload)throw Error(S(t.status,t.statusText,n.error?.message));return n.payload}function vO(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 yO(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 bO(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 xO(e){let t=(0,Z.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`,Ma.transition),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,X.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,X.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,X.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,X.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,X.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 SO(e){let t=(0,Z.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,b]=(0,Q.useState)(``),x;t[0]!==r||t[1]!==c.noSession?(x=()=>{if(!r){u(null),m(c.noSession);return}f(!0),m(null),_O(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]=x):x=t[2];let S=x,C,T;t[3]!==S||t[4]!==n?(C=()=>{n&&(g(`presets`),v(``),b(``),S())},T=[S,n],t[3]=S,t[4]=n,t[5]=C,t[6]=T):(C=t[5],T=t[6]),(0,Q.useEffect)(C,T);let D;t[7]!==l||t[8]!==_?(D=yO(l,_),t[7]=l,t[8]=_,t[9]=D):D=t[9];let M=D,N;t[10]!==l||t[11]!==_?(N=bO(l,_),t[10]=l,t[11]=_,t[12]=N):N=t[12];let P=N,I;t[13]!==l||t[14]!==c?(I=vO(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=gO({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,X.jsx)(w,{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,X.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,X.jsx)(F,{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,X.jsx)(A,{className:`truncate text-sm font-semibold text-fg`,children:B}),t[26]=B,t[27]=W);let ee=l?.cwd??c.description,te;t[28]===ee?te=t[29]:(te=(0,X.jsx)(E,{className:`truncate text-xs text-fg-muted`,children:ee}),t[28]=ee,t[29]=te);let ne;t[30]!==W||t[31]!==te?(ne=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[W,te]}),t[30]=W,t[31]=te,t[32]=ne):ne=t[32];let re;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,X.jsx)(an,{className:`size-4`}),t[33]=re):re=t[33];let ie;t[34]!==c.close||t[35]!==o?(ie=(0,X.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:re}),t[34]=c.close,t[35]=o,t[36]=ie):ie=t[36];let ae;t[37]!==U||t[38]!==ne||t[39]!==ie?(ae=(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-4 py-3`,children:[U,ne,ie]}),t[37]=U,t[38]=ne,t[39]=ie,t[40]=ae):ae=t[40];let oe;t[41]!==M||t[42]!==P||t[43]!==l||t[44]!==i||t[45]!==p||t[46]!==y||t[47]!==S||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?(oe=(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:d?(0,X.jsxs)(`div`,{className:`flex h-full min-h-56 items-center justify-center text-sm text-fg-muted`,children:[(0,X.jsx)(It,{className:`mr-2 size-4 animate-spin`}),c.loading]}):p?(0,X.jsxs)(`div`,{className:`rounded-lg border border-danger/30 bg-danger/5 p-4`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:c.errorTitle}),(0,X.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:p}),(0,X.jsxs)(qi,{type:`button`,className:`mt-4 h-9 rounded-lg`,variant:`secondary`,onClick:S,children:[(0,X.jsx)(It,{className:`size-4`}),c.retry]})]}):h===`presets`?(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[(0,X.jsx)(xO,{icon:(0,X.jsx)(je,{className:`size-4`}),title:c.presetBase,description:l?.defaultBaseBranch?c.presetBaseDescription.replace(`{{branch}}`,l.defaultBaseBranch):c.presetBaseDescriptionNoDefault,disabled:i,onClick:()=>g(`base`)}),(0,X.jsx)(xO,{icon:(0,X.jsx)(Ge,{className:`size-4`}),title:c.presetUncommitted,description:L,disabled:i,onClick:()=>z(`uncommitted`)}),(0,X.jsx)(xO,{icon:(0,X.jsx)(ec,{className:`size-4`}),title:c.presetCommit,description:c.presetCommitDescription.replace(`{{count}}`,String(l?.commits.length??0)),disabled:i,onClick:()=>g(`commit`)}),(0,X.jsx)(xO,{icon:(0,X.jsx)(Ge,{className:`size-4`}),title:c.presetCustom,description:c.presetCustomDescription,disabled:i,onClick:()=>g(`custom`)})]}):h===`base`?(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(CO,{value:_,placeholder:c.searchBranches,onChange:v}),(0,X.jsx)(`div`,{className:`grid gap-1`,children:M.length===0?(0,X.jsx)(`div`,{className:`rounded-lg border border-edge-subtle px-3 py-6 text-center text-sm text-fg-muted`,children:c.noBranches}):M.map(e=>(0,X.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,X.jsx)(`span`,{className:`min-w-0 truncate text-sm text-fg`,children:e.name}),(0,X.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,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(CO,{value:_,placeholder:c.searchCommits,onChange:v}),(0,X.jsx)(`div`,{className:`grid gap-1`,children:P.length===0?(0,X.jsx)(`div`,{className:`rounded-lg border border-edge-subtle px-3 py-6 text-center text-sm text-fg-muted`,children:c.noCommits}):P.map(e=>(0,X.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,X.jsx)(`span`,{className:`font-mono text-xs text-fg-muted`,children:e.shortSha}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg`,children:e.subject}),e.date?(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:e.date.slice(0,10)}):null]},e.sha))})]}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.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=>b(e.target.value)}),(0,X.jsx)(`div`,{className:`text-xs text-fg-muted`,children:c.customDescription})]})}),t[41]=M,t[42]=P,t[43]=l,t[44]=i,t[45]=p,t[46]=y,t[47]=S,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]=oe):oe=t[73];let se;t[74]!==i||t[75]!==c.cancel||t[76]!==c.runReview||t[77]!==o||t[78]!==z||t[79]!==h?(se=h===`custom`?(0,X.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-4 py-3`,children:[(0,X.jsx)(qi,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg`,onClick:o,children:c.cancel}),(0,X.jsx)(qi,{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]=se):se=t[80];let ce;t[81]!==ae||t[82]!==oe||t[83]!==se?(ce=(0,X.jsxs)(O,{children:[H,(0,X.jsxs)(k,{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:[ae,oe,se]})]}),t[81]=ae,t[82]=oe,t[83]=se,t[84]=ce):ce=t[84];let le;return t[85]!==n||t[86]!==ce||t[87]!==V?(le=(0,X.jsx)(j,{open:n,onOpenChange:V,children:ce}),t[85]=n,t[86]=ce,t[87]=V,t[88]=le):le=t[88],le}function CO(e){let t=(0,Z.c)(7),{value:n,placeholder:r,onChange:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(zt,{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,X.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,X.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 wO(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 TO=(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:l,contextRefs:u,maxContextRefs:p=5,setContextRefs:m,onDraftAttachmentsChange:h,thinkingLevel:g,modelSupportsThinking:_,onThinkingChange:b,onSend:x,onPersonalSendDispatched:S,onAbort:w,onAddPendingFollowUp:T,onSteeringInterrupt:E,pendingFollowUps:D,editingFollowUpId:O,onBeginEditFollowUp:k,onCancelEditFollowUp:A,onCommitEditFollowUp:j,onPendingFollowUpRemove:M,onPendingFollowUpMove:N,onPendingFollowUpReorder:P,onPendingFollowUpSteer:F,onPendingFollowUpSend:I,steeringFollowUpId:L,welcomeDraftSeed:R,addActions:z,welcomeSuggestion:B,onAcceptWelcomeSuggestion:V,sessionModel:H,showModelSelector:U,onModelChange:W,modelDisabled:ee,onChatAgentChange:te,currentAgentId:ne,voiceAgentName:re,voiceTaskId:ie,voiceMode:ae,prepareVoiceSession:oe,prepareContextSession:se,unboundDraftKey:ce,getDraftHandoffTarget:le,attachmentHandoffReady:ue,embeddedAttachmentHandoffId:de,editingUserTurnId:fe,composerMode:pe,inputControl:G,onResumeQueue:me,onRestoreEditor:he,onReacquireEdit:K,onComposerHydrated:ge,onCancelUserMessageEdit:_e}){let q=Wa(),ve=(0,Q.useRef)(!1);r||=q.conversationId===s&&q.active;let ye=y(e=>e.language),J=C(ye),[be,xe]=d(),{state:Se}=f();(0,Q.useEffect)(()=>{ns()},[]);let Ce=(...e)=>{if(i)return!1;let t=x(...e);return t instanceof Promise?t.then(t=>(t!==!1&&dt.submitted(e[0]),t)):(t!==!1&&dt.submitted(e[0]),t)},we=(0,Q.useRef)(!1),Te=(0,Q.useRef)(null),Ee=(0,Q.useRef)(null),De=(0,Q.useRef)(null),Oe=(0,Q.useRef)(!1),[ke,Ae]=(0,Q.useState)(!1),[je,Me]=(0,Q.useState)(null),[Ne,Pe]=(0,Q.useState)(null),[Fe,Ie]=(0,Q.useState)(!1),Le=(0,Q.useRef)(Ce),Re=(0,Q.useRef)(g);Le.current=Ce,Re.current=g,(0,Q.useEffect)(()=>{if(!s||Ne===s){Me(null);return}let e=!1;return $r(s).then(e=>e?null:os(s)).then(t=>{e||Me(t&&t.required&&!t.trusted&&t.decision===null?t:null)}).catch(()=>{e||Me(null)}),()=>{e=!0}},[s,Ne]);let ze=(0,Q.useCallback)(()=>{!s||Fe||(Ie(!0),Zo(s,!0).then(()=>{Me(null)}).catch(e=>{Ua(`error`,J.chat.commandPalette.workspaceTrustFailed,{error:e instanceof Error?e.message:String(e)})}).finally(()=>Ie(!1)))},[J.chat.commandPalette,s,Fe]),Be=Jo({conversationId:s??`new`,chat:J.chat,onAttachmentsChange:e=>h?.(e.map((e,t)=>({id:e.uri||e.id||`draft:${t}:${e.name}`,title:e.name})))}),Ve=(0,Q.useRef)(u);Ve.current=u;let He=(0,Q.useCallback)(e=>{let t=u.find(t=>t.refId===e);return t?{title:t.title,kind:t.kind,fileKind:t.fileKind}:void 0},[u]),Ue=(0,Q.useCallback)(e=>{let t=e?.contextRefs??[];if(Ve.current=t,m(t),e?.attachments){Be.setAttachments(e.attachments.map(wO));return}Be.clearAttachments()},[Be.clearAttachments,Be.setAttachments,m]),We=(0,Q.useCallback)(e=>{let t=Ve.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 Ve.current=i,m(i),r}if(t.length>=p)return Ua(`warning`,J.chat.commandPalette.contextLimitReached,{max:p}),null;let r=[...t,e];return Ve.current=r,m(r),e},[J.chat.commandPalette.contextLimitReached,p,m]);(0,Q.useEffect)(()=>{let e=e=>{let t=e.detail;t?.conversationId!==s||t.reference.kind!==`result`||We(t.reference)};return window.addEventListener(`chat-result-reference`,e),()=>window.removeEventListener(`chat-result-reference`,e)},[s,We]);let Ge=(0,Q.useCallback)(e=>{let t=e.availability.status===`agent-denied`?J.chat.commandPalette.skillAgentDeniedReason:J.chat.commandPalette.skillDisabledReason,n=fh(J.chat.commandPalette.skillUnavailableMessage,{name:e.name,agent:ne||`main`,reason:t});if(e.availability.status===`agent-denied`&&window.confirm(`${n}\n\n${J.chat.commandPalette.skillAddToAllowlistConfirm}`)){ss(ne,e.canonicalName,s).catch(e=>{window.alert(e instanceof Error?e.message:String(e))});return}window.alert(n)},[ne,J.chat.commandPalette,s]),Ke=ih({capabilities:e?lm:cm,disabled:r,agentId:ne,conversationId:s,autoFocusKey:s,welcomeDraftSeed:R,onExternalTextReplace:Ue,shouldSyncSelectionRef:we,resolveContextRef:He}),qe=de??be.get(`attachmentHandoff`);(0,Q.useEffect)(()=>{if(!ue||!qe)return;let e=Yt(qe);s&&!de&&xe(e=>{let t=new URLSearchParams(e);return t.delete(`attachmentHandoff`),t},{replace:!0,state:Se}),e&&Be.processFiles([e]).then(()=>Ke.editorRef.current?.focus({preventScroll:!0}))},[ue,qe,de,Be.processFiles,Ke.editorRef,s,Se,xe]);let{onUserTextCommitted:Je,onWireInputClearWalk:Ye,tryInputHistoryArrow:Xe}=PD({conversationId:s,editorRef:Ke.editorRef,valueRef:Ke.valueRef,resetEditor:Ke.resetEditor,onWireInput:Ke.onWireInput}),Ze=(0,Q.useCallback)((e,t)=>{Ye(e,t);let n=Hr(e),r=new Set(n?In(n):[]),i=Ve.current,a=i.filter(e=>!e.refId||r.has(e.refId));a.length!==i.length&&(Ve.current=a,m(a))},[Ye,m]),Qe=Yp(s??``),$e=a||o||Qe||G?.phase===`running`||G?.phase===`stopping`;Oe.current=$e;let et=(0,Q.useCallback)(()=>{Oe.current||Ae(!0)},[]),tt=(0,Q.useCallback)(e=>{GE(Le.current(e,void 0,Re.current,u),t=>{Je?.(e,t),m([])})},[u,Je,m]),nt=pO({capabilities:e?lm:cm,conversationId:s,editorValue:Ke.value,editorCursor:Ke.cursor,isComposing:Ke.isComposing,runBusy:$e,thinkingLevel:g,editorRef:Ke.editorRef,valueRef:Ke.valueRef,resetEditor:Ke.resetEditor,clearAttachments:Be.clearAttachments,onSend:Ce,onUserTextCommitted:Je,onChatAgentChange:te,currentAgentId:ne,prepareSession:se,contextRefs:u,onAddContextRef:We,onUnavailableSkill:Ge,onReviewLauncher:et,onAddPendingFollowUp:T,onAbort:w,pendingFollowUpsCount:D.length,maxPendingFollowUps:10,clearContextRefs:()=>m([]),commandPalettePanelRef:Te});we.current=nt.shouldSyncSelection;let rt=Va({disabled:r||q.active,chat:J.chat,onTranscript:e=>{let t=Ke.valueRef.current,n=ds(t,e);Ke.resetEditor({nextText:n,caretOffset:n.length,focus:!0})}}),{phase:it,voiceActive:at,startVoiceInput:ot,cancelVoiceInput:st,confirmVoiceInput:ct}=rt;(0,Q.useEffect)(()=>{let e=e=>{if(!bE(e,{disabled:r,editorHidden:at&&it!==`error`}))return;let t=Ym(e.clipboardData);t&&(e.preventDefault(),Ke.focusForExternalPaste(),Xm(t,{processFiles:Be.processFiles,processPastedText:Be.processPastedText,insertText:e=>document.execCommand(`insertText`,!1,e),onUnsupportedFiles:()=>Ua(`warning`,J.chat.clipboardFileTypeUnsupported)}))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[Be.processFiles,Be.processPastedText,r,Ke.focusForExternalPaste,J.chat.clipboardFileTypeUnsupported,at,it]),(0,Q.useEffect)(()=>{let e=e=>{let t=e?.detail?.target;if(!(t&&t!==`chat`)&&(e?.preventDefault(),!r)){if(it===`recording`){ct();return}(it===`idle`||it===`error`)&&(Ke.editorRef.current?.focus({preventScroll:!0}),ot())}},t=e=>{let t=e.detail?.target;t&&t!==`chat`||!at||(e.preventDefault(),st(),Ke.editorRef.current?.focus({preventScroll:!0}))};window.addEventListener(vs,e),window.addEventListener(gs,t);let n=window.setTimeout(()=>{if(ys()){if(r){_s();return}e()}},0);return()=>{window.clearTimeout(n),window.removeEventListener(vs,e),window.removeEventListener(gs,t)}},[st,ct,r,Ke.editorRef,ot,at,it]);let lt=(0,Q.useCallback)(()=>{De.current=null},[]),ut=n&&!r&&!i&&!$e&&!O&&!fe&&!rt.voiceActive&&!Ke.isComposing&&Ke.value.length===0&&Be.attachments.length===0&&u.length===0&&D.length===0,dt=UD({conversationId:s,agentId:ne,modelKey:H,locale:ye,enabled:n,draftText:Ke.value,canShow:ut}),ft=()=>{if(!ut||Ke.valueRef.current.length>0||Ve.current.length>0)return!1;let e=dt.accept();return e?(Ke.resetEditor({nextText:e,focus:!0}),!0):!1};(0,Q.useEffect)(()=>{ut&&dt.suggestion&&!nt.palette.open&&dt.shown()},[ut,dt.suggestion,dt.shown,nt.palette.open]);let pt=v(e=>e.conversationId),mt=(0,Q.useMemo)(()=>({gatewayIdentity:pt,conversationId:s,unboundDraftKey:ce}),[pt,s,ce]),ht=(0,Q.useRef)(new Map),gt=(0,Q.useRef)(`compose`),_t=pe??(O?{kind:`editFollowUp`,inputId:O,version:0}:{kind:`compose`}),vt=_t.kind===`editTurn`?`turn:${_t.turnId}`:_t.kind===`editFollowUp`?`input:${_t.inputId}`:`compose`;(0,Q.useLayoutEffect)(()=>{ht.current.clear(),gt.current=`compose`},[mt]),HD(s,Ke,Be,u,m,{ready:ge,snapshot:()=>({mode:_t,drafts:Object.fromEntries(ht.current)}),restore:e=>{ht.current=new Map(Object.entries(e.drafts)),gt.current=e.mode.kind===`editTurn`?`turn:${e.mode.turnId}`:e.mode.kind===`editFollowUp`?`input:${e.mode.inputId}`:`compose`,he?.(e.mode)}},ce,le);let yt=_t.kind!==`compose`&&!!(G&&!G.paused),bt=LD({chat:J.chat,runBusy:$e,draftScope:mt,queuePaused:G?.paused,editingUserTurnId:fe,blocked:r||i||yt||G?.phase===`stopping`,onFinishUserEdit:_e,onFinishFollowUpEdit:A,voiceActive:rt.voiceActive,cancelVoiceInput:rt.cancelVoiceInput,editingFollowUpId:O,getTextValue:()=>Ke.valueRef.current,getAttachmentCount:()=>Be.attachmentsRef.current.length,wireAttachmentsPayload:Be.wireAttachmentsPayload,getContextRefs:()=>u,getThinkingLevel:()=>Re.current,onSend:Ce,onDispatched:e&&S?(e,t)=>{let n=Ke.editorRef.current?.getBoundingClientRect();n&&S(e,n,t)}:void 0,onAddPendingFollowUp:T,onSteeringInterrupt:E,onCommitEditFollowUp:j,onPendingFollowUpRemove:M,pendingFollowUpsCount:D.length,resetEditor:()=>{Ke.resetEditor()},clearAttachments:Be.clearAttachments,clearContextRefs:()=>m([]),clearEditFollowUpRef:lt,onUserTextCommitted:Je}),xt=(0,Q.useCallback)((e,t)=>{!s||s===`new`||HT.getState().requestCreate(s,[{id:e.id,type:`text`,text:t,label:J.chat.followUpQueueHeading}])},[s,J.chat.followUpQueueHeading]);(0,Q.useLayoutEffect)(()=>{if(gt.current===vt)return;ht.current.set(gt.current,{text:Ke.valueRef.current,attachments:Be.wireAttachmentsPayload(),contextRefs:Ve.current,thinkingLevel:Re.current}),gt.current=vt;let e=_t.kind===`editFollowUp`?D.find(e=>e.id===_t.inputId):void 0;e?.thinkingLevel&&_&&b(e.thinkingLevel);let t=(_t.kind===`compose`?_t.draft:void 0)??ht.current.get(vt)??(_t.kind===`editTurn`?_t.draft:e?{text:e.text,attachments:e.attachments??[],contextRefs:e.contextRefs??[]}:void 0);t?.thinkingLevel&&_&&b(t.thinkingLevel),Be.setAttachments(LE(t?.attachments??[])),m(t?.contextRefs??[]),Ke.resetEditor({nextText:t?.text??``,focus:!0})},[vt,_t,D,Be,Ke,m]);let St=(0,Q.useCallback)(e=>{k(e)},[k]),Ct=(0,Q.useRef)({});Ct.current={adapters:nt.adapters,send:bt.send,runBusy:$e,pendingFollowUpsCount:D.length,submitFollowUp:()=>bt.flushSteeringDraft(!1,`next`),steerDraft:()=>bt.flushSteeringDraft(!1,`steer`),interruptDraft:bt.interruptDraft,editingFollowUpId:O,editingUserTurnId:fe,onCancelUserMessageEdit:_e,onCancelEditFollowUp:A,attachmentsLen:Be.attachments.length,contextRefsLen:u.length,isComposing:Ke.isComposing,valueRef:Ke.valueRef,adjustHeight:Ke.adjustHeight,editorRef:Ke.editorRef,tryInputHistoryArrow:Xe,acceptEmptySuggestion:dt.suggestion&&ut?ft:!$e&&!r&&!i&&!fe&&!rt.voiceActive&&B&&V?()=>(V(B),!0):void 0,dismissEmptySuggestion:dt.suggestion?dt.dismiss:void 0};let wt=$e&&!O&&!fe,Tt={...J.chat,sendMessage:O?J.chat.followUpSaveEdit:fe?J.chat.userMessageReplaceSend:G?.paused?J.chat.sendThisMessage:J.chat.sendMessage},Et=!!Ke.value.trim()||Be.attachments.length>0||u.length>0,Dt=Et&&!!E,Ot=Ls(`(hover: hover) and (pointer: fine)`),kt=!wt&&!O&&B?`${B.prompt}${Ot?` · ${J.chat.welcomeSpotlight.acceptSuggestionHint}`:``}`:null;return(0,X.jsxs)(`div`,{className:`relative flex min-h-0 w-full flex-col`,children:[s?(0,X.jsx)(gE,{conversationId:s},s):null,c?(0,X.jsx)(kE,{...c,conversationId:s,disabled:(c.disabled??r)||a||o}):null,(0,X.jsxs)(ch,{className:e?`rounded-[1.65rem]`:void 0,dragging:Be.isDragging,onDragOver:e=>{(e.dataTransfer?.types.includes(`Files`)||Qp(e.dataTransfer))&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,Be.setIsDragging(!0))},onDragLeave:e=>{e.relatedTarget===null&&Be.setIsDragging(!1)},onDrop:async e=>{e.preventDefault(),Be.setIsDragging(!1);let t=e.dataTransfer?.files;if(t?.length){await Be.processFiles(Array.from(t));return}let n=$p(e.dataTransfer);if(n)try{let e=await _o(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 Be.processFiles([new File([e],n.name,{type:r})])}catch{Ua(`error`,J.chat.attachmentLoadFailed,{name:n.name})}},children:[Be.isDragging?(0,X.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,fe?(0,X.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,X.jsx)(`span`,{children:J.chat.userMessageEditing}),(0,X.jsx)(`button`,{type:`button`,className:`font-medium text-accent-fg hover:underline`,onClick:_e,children:J.chat.userMessageEditCancel})]}):null,yt&&(0,X.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,X.jsx)(`span`,{children:J.chat.editQueueResumed}),(0,X.jsx)(`button`,{type:`button`,disabled:r||i,className:`text-accent-fg disabled:opacity-40`,onClick:()=>K?.({text:Ke.valueRef.current,attachments:Be.wireAttachmentsPayload(),contextRefs:Ve.current}),children:J.chat.editPauseAgain})]}),G?.paused&&(D.length>0||G.phase===`stopping`||_t.kind!==`compose`)&&(0,X.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,X.jsx)(`span`,{children:G.phase===`stopping`?J.chat.inputStopping:G.reviewRequired?J.chat.queueReviewRequired:D.length>0?J.chat.queuePausedCount.replace(`{count}`,String(D.length)):J.chat.queuePaused}),(0,X.jsx)(`button`,{type:`button`,disabled:r||i||!!(O||fe)||G.phase!==`idle`,className:`text-accent-fg disabled:opacity-40`,onClick:me,children:J.chat.queueResume})]}),(0,X.jsx)(EE,{conversationId:s}),D.length>0?(0,X.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,X.jsx)(TE,{items:D,disabled:r||i||!!(fe||O),editingFollowUpId:O,onEditInComposer:St,onRemove:M,onMove:N,onReorder:P,onSteer:F,onSendSingle:I,queuePaused:G?.paused,queueIdle:G?.phase===`idle`,steeringBusyId:L,onOpenSideChat:s&&s!==`new`?xt:void 0})}):null,(O||fe)&&(0,X.jsx)(`div`,{className:`flex items-center justify-end px-4 py-1 text-xs`,children:(0,X.jsx)(`button`,{type:`button`,disabled:i,className:`text-accent-fg disabled:opacity-40`,onClick:()=>he?.({kind:`compose`,draft:{text:Ke.valueRef.current,attachments:Be.wireAttachmentsPayload(),contextRefs:Ve.current}}),children:J.chat.editAsNewMessage})}),_t.kind===`editFollowUp`&&D.some(e=>e.id===_t.inputId&&e.version!==_t.version)&&(0,X.jsxs)(`div`,{className:`border-b border-edge-subtle px-4 py-2 text-xs text-fg-muted`,children:[(0,X.jsx)(`p`,{children:J.chat.followUpEditConflict}),(0,X.jsx)(`p`,{className:`my-1 max-h-20 overflow-auto whitespace-pre-wrap`,children:D.find(e=>e.id===_t.inputId)?.text}),(0,X.jsx)(`button`,{type:`button`,disabled:i,className:`text-accent-fg`,onClick:()=>k(_t.inputId),children:J.chat.followUpKeepMyEdit})]}),O?(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-4 py-2 text-xs text-fg-muted`,children:[(0,X.jsx)(`span`,{children:J.chat.inputPlaceholderSteeringEdit}),(0,X.jsx)(`button`,{type:`button`,onClick:A,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,X.jsx)(Ko,{attachments:Be.attachments,conversationId:s,topPadded:D.length>0,onRemove:Be.removeAttachment}),(0,X.jsx)(DE,{refs:u.filter(e=>!e.refId),label:J.chat.commandPalette.contextLabel,onRemove:e=>m(t=>t.filter(t=>t.sourceId!==e))}),l,(0,X.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,X.jsx)(`input`,{ref:Ee,type:`file`,multiple:!0,className:`hidden`,onChange:async e=>{let t=e.target.files;t&&await Be.processFiles(Array.from(t)),e.target.value=``}}),e&&!rt.voiceActive&&(0,X.jsx)(FE,{disabled:r||i,attachmentCount:Be.attachments.length,maxAttachments:10,chat:J.chat,onPickFiles:()=>Ee.current?.click(),addActions:z}),(0,X.jsxs)(`div`,{className:e?`relative min-w-0 flex-1 px-1`:Y(`relative px-3 pb-0 pt-1 sm:px-4`,Be.attachments.length>0&&`pt-2`),children:[(0,X.jsx)(WE,{open:nt.atPicker.open,anchorRef:Ke.editorRef,items:nt.atPicker.items,selectedIndex:nt.atPicker.selectedIndex,loading:nt.atPicker.loading,query:nt.atPicker.query,noResults:nt.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:nt.applyAtMention}),(0,X.jsx)(xD,{open:nt.palette.open,anchorRef:Ke.editorRef,panelRef:Te,sections:nt.palette.loadError?[]:nt.palette.sections,flatItems:nt.palette.loadError?[]:nt.palette.flatItems,loading:nt.palette.loading,failedKinds:nt.palette.failedKinds,selectedIndex:nt.palette.selectedIndex,noResults:nt.palette.loadError??J.chat.commandPalette.noResults,sectionLoadFailedLabel:J.chat.commandPalette.sectionLoadFailed,query:nt.palette.query,skillsLabel:J.chat.commandPalette.skillsSection,commandsLabel:J.chat.commandPalette.commandsSection,agentsLabel:J.chat.commandPalette.agentsSection,currentAgentId:ne,currentBadgeLabel:J.chat.commandPalette.currentBadge,runBusy:$e,pendingFollowUpsCount:D.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:nt.applyPalette}),rt.voiceActive?(0,X.jsx)(ms,{phase:rt.phase,elapsedLabel:rt.elapsedLabel,recordedDictation:rt.recordedDictation,audioLevel:rt.audioLevel,partialTranscript:rt.partialTranscript,finalTranscript:rt.finalTranscript,error:rt.error,settingsRequired:rt.settingsRequired,disabled:r,chat:J.chat,onCancel:rt.cancelVoiceInput,onConfirm:rt.confirmVoiceInput,onRetry:rt.retryVoiceInput}):null,(0,X.jsx)(ah,{editorRef:Ke.editorRef,disabled:r,hidden:rt.voiceActive&&rt.phase!==`error`,compact:e,ariaLabel:t??J.chat.inputPlaceholder,placeholder:(ut&&dt.suggestion?`${dt.suggestion.prompt}${Ot?` · ${J.chat.welcomeSpotlight.acceptSuggestionHint}`:``}`:null)??t??kt??(wt?O?J.chat.inputPlaceholderSteeringEdit:J.chat.inputPlaceholderSteering:J.chat.inputPlaceholder),onWireInput:Ze,adjustHeight:Ke.adjustHeight,processFiles:Be.processFiles,processPastedText:Be.processPastedText,setIsComposing:Ke.setIsComposing,kbdRef:Ct,chatMessages:J.chat})]}),e?(0,X.jsx)(IE,{disabled:r||i||yt,voiceActive:rt.voiceActive,runBusy:wt,hasDraft:Et,chat:Tt,onStartVoiceInput:rt.startVoiceInput,onSend:bt.send,onAbort:w}):(0,X.jsx)(gh,{disabled:r,sendDisabled:i||yt,sending:a,streaming:o,runBusy:wt,chat:Tt,hasDraft:Et,showSteeringInterrupt:Dt,attachmentCount:Be.attachments.length,maxAttachments:10,onPickFiles:()=>Ee.current?.click(),addActions:z,thinkingLevel:g,onThinkingChange:b,voiceActive:rt.voiceActive,onStartVoiceInput:rt.startVoiceInput,voiceConversationEnabled:!!(s||oe),onStartVoiceConversation:()=>{if(!ve.current){if(s){q.open({conversationId:s,name:re||ne||`xopc`,taskId:ie,mode:ae});return}oe&&(ve.current=!0,oe().then(e=>{if(e)return q.open({conversationId:e,name:re||ne||`xopc`,taskId:ie,mode:ae})}).catch(e=>Ua(`error`,e instanceof Error?e.message:J.chat.callFailed)).finally(()=>{ve.current=!1}))}},onSend:bt.send,onAbort:w,onInterrupt:bt.interruptDraft,sessionModel:H,showModelSelector:U,onModelChange:W,modelDisabled:ee})]}),(0,X.jsx)(SO,{open:ke,conversationId:s,disabled:r||wt,chat:J.chat,onClose:()=>Ae(!1),onSendCommand:tt}),(0,X.jsx)(go,{open:je!==null,title:J.chat.commandPalette.workspaceTrustTitle,description:fh(J.chat.commandPalette.workspaceTrustDescription,{path:je?.workspacePath??``}),confirmLabel:Fe?J.chat.commandPalette.workspaceTrustSaving:J.chat.commandPalette.workspaceTrustConfirm,cancelLabel:J.chat.commandPalette.workspaceTrustCancel,onConfirm:ze,onCancel:()=>{Me(null),Pe(s)}})]})]})});function EO(e){let t=(0,Z.c)(42),{draft:n,onRemove:r,disabled:i,waiting:a}=e,o=i!==void 0&&i,s=a!==void 0&&a,c=y(OO),l;t[0]===c?l=t[1]:(l=C(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,X.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,X.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(DO).join(`, `),t[7]=n.envelope.resourceRefs,t[8]=m);let h;t[9]===m?h=t[10]:(h=(0,X.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:m}),t[9]=m,t[10]=h);let g;t[11]===n.preview?g=t[12]:(g=(0,X.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]=g);let _;t[13]!==n.truncated||t[14]!==u.truncated?(_=n.truncated?(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:u.truncated}):null,t[13]=n.truncated,t[14]=u.truncated,t[15]=_):_=t[15];let v;t[16]!==n.envelope.selection||t[17]!==u.draft||t[18]!==u.selection?(v=n.envelope.selection?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`mt-2 text-xs font-medium text-fg`,children:n.envelope.selection.draft?u.draft:u.selection}),(0,X.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]=v):v=t[19];let b;t[20]!==_||t[21]!==v||t[22]!==f||t[23]!==p||t[24]!==h||t[25]!==g?(b=(0,X.jsxs)(`details`,{className:`min-w-0 flex-1`,children:[f,p,h,g,_,v]}),t[20]=_,t[21]=v,t[22]=f,t[23]=p,t[24]=h,t[25]=g,t[26]=b):b=t[26];let x=`${u.remove}: ${n.title}`,S;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,X.jsx)(an,{className:`size-4`,"aria-hidden":!0}),t[27]=S):S=t[27];let w;t[28]!==o||t[29]!==r||t[30]!==x?(w=(0,X.jsx)(`button`,{type:`button`,onClick:r,disabled:o,"aria-label":x,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:S}),t[28]=o,t[29]=r,t[30]=x,t[31]=w):w=t[31];let T;t[32]!==b||t[33]!==w?(T=(0,X.jsxs)(`div`,{className:`flex items-start gap-2`,children:[b,w]}),t[32]=b,t[33]=w,t[34]=T):T=t[34];let E;t[35]!==u.pending||t[36]!==s?(E=s?(0,X.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,X.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 DO(e){return`${e.kind} · ${e.id} · v${e.revision}`}function OO(e){return e.language}function kO(e){let t=(0,Z.c)(14),{composer:n}=e,r=y(AO)===`zh`,{options:i,checking:a,checkFailed:o,failure:s,busy:c,retry:l}=n,u=o?r?`无法检查项目目录。`:`Could not check the project directory.`:i?.localAvailable===!1?r?`项目目录不可用,请在项目设置中检查路径。`:`Project directory unavailable. Check its path in project settings.`:null;if(a&&!i&&!o){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(sn,{className:`h-8 w-24 rounded-full`}),t[0]=e):e=t[0],e}if(!u&&!s)return null;let d=c||a,f=r?`重新检查项目目录`:`Recheck project directory`,p;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,X.jsx)(It,{className:`size-3.5`,"aria-hidden":!0}),t[1]=p):p=t[1];let m;t[2]!==l||t[3]!==d||t[4]!==f?(m=(0,X.jsx)(qi,{variant:`ghost`,className:`size-8 rounded-full p-0`,disabled:d,onClick:l,"aria-label":f,children:p}),t[2]=l,t[3]=d,t[4]=f,t[5]=m):m=t[5];let h;t[6]===u?h=t[7]:(h=u?(0,X.jsx)(`p`,{role:`status`,className:`w-full px-2 py-1 text-xs leading-5 text-fg-muted`,children:u}):null,t[6]=u,t[7]=h);let g;t[8]===s?g=t[9]:(g=s?(0,X.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:s}):null,t[8]=s,t[9]=g);let _;return t[10]!==m||t[11]!==h||t[12]!==g?(_=(0,X.jsxs)(X.Fragment,{children:[m,h,g]}),t[10]=m,t[11]=h,t[12]=g,t[13]=_):_=t[13],_}function AO(e){return e.language}function jO({preparation:e,conversationId:t,ready:n,onSend:r}){let i=v(e=>e.conversationId),a=v(e=>e.baseUrl),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(null),u=(0,Q.useRef)(null),d=(0,Q.useRef)(!1),f=(0,Q.useRef)(r);f.current=r;let p=(0,Q.useRef)(t);p.current=t;let{data:m,error:h,isValidating:g,mutate:y}=vi(e?[`project-environment-options`,a,i,e.project.id]:null,async()=>(await b(_(`/api/projects/${encodeURIComponent(e.project.id)}/environment-options?mode=local_checkout`))).options,{keepPreviousData:!1,revalidateOnFocus:!1,shouldRetryOnError:!1}),x=!!(!h&&m?.localAvailable),S=(0,Q.useCallback)(e=>{let t=u.current;u.current=null,l(null),t?.resolve(e?t.conversationId:null)},[]),C=(0,Q.useCallback)(()=>{let e=u.current,t=v.getState();return e?.token===t.conversationId&&e?.baseUrl===t.baseUrl?e?.openedConversationId:void 0},[]);(0,Q.useEffect)(()=>{if(c){if(c.baseUrl!==a||c.token!==i){S(!1);return}if(!c.conversationId){e!==c.preparation&&c.openedConversationId!==t&&S(!1);return}t===c.conversationId?n&&S(!0):e!==c.preparation&&S(!1)}},[c,t,n,e,S,a,i]),(0,Q.useEffect)(()=>()=>{u.current?.resolve(null),u.current=null},[]);let w=(0,Q.useCallback)(async()=>{if(!e)return t;let n=u.current;if(n)return n.preparation===e?n.completion:null;if(!x||g)return null;s(null);let r,o=new Promise(e=>{r=e}),c={preparation:e,baseUrl:a,token:i,conversationId:null,completion:o,resolve:r};return u.current=c,l(c),Promise.resolve().then(()=>e.create(`local_checkout`,void 0,e=>{u.current===c&&(c.openedConversationId=e)})).then(e=>{if(u.current!==c)return;let t={...c,conversationId:e};u.current=t,l(t)}).catch(t=>{u.current===c&&(s({preparation:e,message:t instanceof Error?t.message:String(t)}),y(),S(!1))}),o},[x,a,S,g,y,e,t,i]);return{options:m,checking:g,checkFailed:!!h,allowed:x,busy:!!(c&&(c.preparation===e||c.conversationId&&c.conversationId===t)),failure:o?.preparation===e?o.message:null,retry:()=>void y(),getDraftHandoffTarget:C,prepareSession:w,send:async(...n)=>{let r=t;if(e){if(d.current)return!1;d.current=!0;try{let e=await w();if(!e)return!1;r=e,n[2]=void 0}finally{d.current=!1}}return!r||p.current!==r?!1:await f.current(...n)!==!1&&{conversationId:r}}}}function MO(e,t){let n=(0,Z.c)(12),r=v(PO),i=v(NO),a;n[0]===e?a=n[1]:(a=t=>e?t.sessions[e]?.localDraft:void 0,n[0]=e,n[1]=a);let o=Sr(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 $r(e):void 0,r=n?n.creation.projectId:e?(await wn(e)).projectId:t;return r?xn(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}=vi(s,c,l);return d?null:u??null}function NO(e){return e.baseUrl}function PO(e){return e.conversationId}function FO(e,t){let n=fo(e,t),r=po(e,t);return`${e.id} ${n} ${r}`.toLowerCase()}function IO(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=FO(e,n);return i.every(e=>t.includes(e))})}function LO(e){let t=(0,Z.c)(61),{items:n,value:r,disabled:i,placeholder:a,newChatLabel:o,searchPlaceholder:s,noMatches:c,compact:l,contentSide:u,contentAlign:d,className:f,onChange:p}=e,m=u===void 0?`bottom`:u,h=d===void 0?`end`:d,g=y(zO),_;t[0]===g?_=t[1]:(_=C(g),t[0]=g,t[1]=_);let v=_.agentsSettings,[b,x]=(0,Q.useState)(!1),[S,w]=(0,Q.useState)(``),T;t[2]!==v||t[3]!==n||t[4]!==S?(T=IO(n,S,v),t[2]=v,t[3]=n,t[4]=S,t[5]=T):T=t[5];let E=T,D,O,k;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),O=n.find(e),D=O?fo(O,v):r||a,k=O?[fo(O,v),po(O,v)].filter(Boolean).join(` — `):void 0,t[6]=v,t[7]=n,t[8]=a,t[9]=r,t[10]=D,t[11]=O,t[12]=k}else D=t[10],O=t[11],k=t[12];let A=k,j=D===a?a:`${o??a} · ${D}`,M=A??a,N=l&&`min-w-0 max-w-[min(calc(15ch+3rem),calc(100vw-8rem))] py-1.5 text-[13px]`,P;t[15]!==f||t[16]!==N?(P=Y(qa,`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`,Ma.transition,`hover:border-edge hover:bg-surface-hover/45`,Ja,Ka,`disabled:cursor-not-allowed disabled:opacity-50`,`dark:border-edge-subtle dark:hover:bg-surface-hover/55`,N,f),t[15]=f,t[16]=N,t[17]=P):P=t[17];let F;t[18]!==O?.avatar||t[19]!==r?(F=r?(0,X.jsx)(no,{agentId:r,avatar:O?.avatar,size:28,className:`shrink-0`}):null,t[18]=O?.avatar,t[19]=r,t[20]=F):F=t[20];let I=l?`max-w-[15ch] shrink`:`flex-1`,L;t[21]===I?L=t[22]:(L=Y(`min-w-0 truncate text-left`,I),t[21]=I,t[22]=L);let R;t[23]!==D||t[24]!==L?(R=(0,X.jsx)(`span`,{className:L,children:D}),t[23]=D,t[24]=L,t[25]=R):R=t[25];let z;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,X.jsx)(le,{className:`size-4 shrink-0 text-fg-subtle opacity-70`,"aria-hidden":!0}),t[26]=z):z=t[26];let B;t[27]!==i||t[28]!==F||t[29]!==R||t[30]!==j||t[31]!==M||t[32]!==P?(B=(0,X.jsx)($i,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,disabled:i,"aria-label":j,title:M,className:P,children:[F,R,z]})}),t[27]=i,t[28]=F,t[29]=R,t[30]=j,t[31]=M,t[32]=P,t[33]=B):B=t[33];let V;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(V=Y(ce,`z-50 w-[var(--radix-popover-trigger-width)] min-w-[12rem] rounded-lg border border-edge bg-surface-overlay shadow-md`,Ma),t[34]=V):V=t[34];let H;t[35]===o?H=t[36]:(H=o?(0,X.jsx)(`p`,{className:`border-b border-edge px-3 py-2 text-xs font-medium text-fg-muted`,children:o}):null,t[35]=o,t[36]=H);let U;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(U=e=>w(e.target.value),t[37]=U):U=t[37];let W;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(W=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`,Ja),t[38]=W):W=t[38];let ee;t[39]!==S||t[40]!==s?(ee=(0,X.jsx)(`div`,{className:`shrink-0 border-b border-edge p-2`,children:(0,X.jsx)(`input`,{type:`search`,value:S,onChange:U,placeholder:s,className:W,"aria-label":s})}),t[39]=S,t[40]=s,t[41]=ee):ee=t[41];let te;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(te=Y(de,`max-h-64 p-1`),t[42]=te):te=t[42];let re;t[43]!==v||t[44]!==E||t[45]!==c||t[46]!==p||t[47]!==r?(re=E.length===0?(0,X.jsx)(`li`,{className:`p-2 text-sm text-fg-muted`,children:c}):E.map(e=>{let t=e.id===r,n=fo(e,v),i=po(e,v),a=i.length>0?i:void 0;return(0,X.jsx)(`li`,{role:`option`,"aria-selected":t,children:(0,X.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:()=>{p(e.id),x(!1),w(``)},children:[(0,X.jsx)(no,{agentId:e.id,avatar:e.avatar,size:32,className:`shrink-0`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block truncate font-medium leading-tight`,title:n,children:n}),i?(0,X.jsx)(`span`,{className:`mt-0.5 block truncate text-xs leading-tight text-fg-muted`,title:a,children:i}):null]}),(0,X.jsx)(ne,{className:Y(`size-4 shrink-0`,t?`opacity-100`:`opacity-0`),"aria-hidden":!0})]})},e.id)}),t[43]=v,t[44]=E,t[45]=c,t[46]=p,t[47]=r,t[48]=re):re=t[48];let ie;t[49]===re?ie=t[50]:(ie=(0,X.jsx)(`ul`,{"data-select-scroll-region":!0,className:te,role:`listbox`,children:re}),t[49]=re,t[50]=ie);let ae;t[51]!==h||t[52]!==m||t[53]!==H||t[54]!==ee||t[55]!==ie?(ae=(0,X.jsx)(Yi,{children:(0,X.jsxs)(Xi,{side:m,align:h,sideOffset:4,collisionPadding:8,className:V,onOpenAutoFocus:RO,children:[H,ee,ie]})}),t[51]=h,t[52]=m,t[53]=H,t[54]=ee,t[55]=ie,t[56]=ae):ae=t[56];let oe;return t[57]!==b||t[58]!==B||t[59]!==ae?(oe=(0,X.jsxs)(Zi,{open:b,onOpenChange:x,children:[B,ae]}),t[57]=b,t[58]=B,t[59]=ae,t[60]=oe):oe=t[60],oe}function RO(e){return e.preventDefault()}function zO(e){return e.language}function BO(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 VO(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 HO=`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`,UO=`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 WO({conversationId:e,draftRefs:t=[],draftAttachments:n=[],draftPage:r,project:i,...a}){let[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),g=VO(y(e=>e.language)),_=f(),v=`${_.pathname}${_.search}`,{data:b,error:x,isLoading:S,isValidating:C,mutate:w}=up(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??[],k=BO(T?.sources??[],t,n,r),A=T?.environment,j=!!(E||D||O.length),M=!!T?.unavailableSections.includes(`work`),P=!!T?.unavailableSections.includes(`sources`),F=!!T?.unavailableSections.includes(`environment`),I=[E?.title,D?.title,k.length?`${g.sources} ${k.length}${T?.sourcesHasMore?`+`:``}`:null,A?.kind===`managed_worktree`?`Worktree`:null].filter(Boolean).join(` · `)||g.title,L=()=>s(!1),R=k.some(e=>e.kind===`note`&&!e.unavailable&&e.origins.some(e=>e.kind===`session`)),z=()=>{A?.rootPath&&ra(A.rootPath).then(e=>{e&&(m(!0),window.setTimeout(()=>m(!1),1200))})},B=()=>(0,X.jsx)(`button`,{type:`button`,className:UO,"aria-label":g.refresh,disabled:C,onClick:()=>void w(),children:(0,X.jsx)(It,{className:`size-3.5 ${C?`animate-spin motion-reduce:animate-none`:``}`,"aria-hidden":!0})});return(0,X.jsxs)(Zi,{open:o,onOpenChange:s,children:[(0,X.jsx)($i,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,"aria-label":g.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,X.jsx)(Ke,{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,X.jsx)(Yi,{children:(0,X.jsx)(Xi,{align:`end`,sideOffset:8,collisionPadding:12,"aria-label":g.title,onCloseAutoFocus:e=>{document.activeElement?.closest(`[data-primary-chat-composer]`)&&e.preventDefault()},className:`xopc-session-context-popover z-50 w-[min(23rem,calc(100vw-1.5rem))] rounded-xl border border-edge bg-surface-overlay shadow-popover`,children:(0,X.jsxs)(`div`,{className:`max-h-[min(30rem,var(--radix-popover-content-available-height))] overflow-y-auto rounded-xl p-3`,children:[(0,X.jsx)(`h2`,{className:`mb-2 px-2 text-sm font-medium text-fg`,children:g.title}),S?(0,X.jsx)(`div`,{className:`space-y-2 px-2`,"aria-busy":`true`,children:[0,1,2].map(e=>(0,X.jsx)(sn,{className:`h-8 w-full`},e))}):x?(0,X.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-2 text-sm text-fg-muted`,children:[(0,X.jsx)(`span`,{children:g.unavailable}),B()]}):(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsxs)(`section`,{"aria-label":g.work,children:[E?(0,X.jsxs)(h,{className:HO,to:Ze(v,`/projects/${encodeURIComponent(E.id)}`),onClick:L,children:[(0,X.jsx)(Oe,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:E.title,children:E.title})]}):null,D?(0,X.jsxs)(h,{className:HO,to:Qe(v,D.id),onClick:L,children:[(0,X.jsx)(fc,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:D.title,children:D.title}),(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:D.phase})]}):null,O.length?(0,X.jsxs)(X.Fragment,{children:[O.length>2?(0,X.jsxs)(`button`,{type:`button`,className:`${HO} w-full text-left`,onClick:()=>l(!c),"aria-expanded":c,children:[(0,X.jsx)(fc,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,X.jsxs)(`span`,{className:`flex-1`,children:[g.delegatedTasks,` · `,T?.work.delegatedTaskCount??O.length]}),(0,X.jsx)(`span`,{className:`text-xs text-fg-muted`,children:c?g.collapse:g.expand})]}):(0,X.jsxs)(`p`,{className:`px-2 pt-2 text-xs text-fg-subtle`,children:[g.delegatedTasks,` · `,T?.work.delegatedTaskCount??O.length]}),(c?O:O.slice(0,2)).map(e=>(0,X.jsxs)(h,{className:`${HO} pl-9`,to:Qe(v,e.id),onClick:L,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.title,children:e.title}),(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:e.runStatus??e.phase})]},e.id))]}):null,j?null:(0,X.jsx)(`p`,{className:`px-2 py-2 text-sm text-fg-muted`,children:M?g.unavailable:g.independent}),M?(0,X.jsxs)(`div`,{className:`flex items-center justify-between px-2 text-xs text-fg-muted`,children:[j?g.partialUnavailable:null,B()]}):null,E&&a.onLeaveProject?(0,X.jsx)(`button`,{type:`button`,className:UO,onClick:()=>{L(),a.onLeaveProject?.()},children:a.leaveProjectLabel}):null]}),k.length||P?(0,X.jsxs)(`section`,{className:`border-t border-edge-subtle pt-3`,children:[(0,X.jsxs)(`div`,{className:`mb-1 flex items-center justify-between px-2`,children:[(0,X.jsxs)(`h3`,{className:`text-sm text-fg-subtle`,children:[g.sources,` `,k.length?`${k.length}${T?.sourcesHasMore?`+`:``}`:``]}),P?B():null]}),(u?k:k.slice(0,3)).map(e=>{let t=e.origins.some(e=>e.kind===`session`)?g.session:e.origins.some(e=>e.kind===`task`)?g.task:e.origins.some(e=>e.kind===`recent`)?g.recent:g.draft,n=e.pending&&e.origins.length?`${t} · ${g.draft}`:e.pending?g.draft:t,r=e.kind===`file`&&e.fileKind===`directory`?Ae:e.kind===`file`?Ee:e.kind===`session`?yt:e.kind===`browser_tab`||e.kind===`browser_page`||e.kind===`app_context`?N:e.kind===`mcp_resource`?be:e.kind===`attachment`?kt:Ee,i=e.unavailable?g.unavailable:e.title||(e.kind===`note`?g.untitled:g.untitledSource),a=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(r,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.unavailable?void 0:e.title,children:i}),(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:n})]}),o=e.kind===`note`?et(v,e.id):e.kind===`session`?`/chat/${encodeURIComponent(e.id)}`:null,s=`${e.kind}:${e.id}`;return!e.unavailable&&o?(0,X.jsx)(h,{className:HO,to:o,onClick:L,children:a},s):(0,X.jsx)(`div`,{className:`flex min-w-0 items-center gap-3 px-2 py-2 text-sm text-fg-muted`,children:a},s)}),k.length?null:(0,X.jsx)(`p`,{className:`px-2 py-2 text-xs text-fg-muted`,children:g.unavailable}),k.length>0&&P?(0,X.jsx)(`p`,{className:`px-2 py-1 text-xs text-fg-muted`,children:g.partialUnavailable}):null,k.length>3?(0,X.jsx)(`button`,{type:`button`,className:UO,onClick:()=>d(!u),"aria-expanded":u,children:u?g.collapse:g.expand}):null,T?.sourcesHasMore?(0,X.jsx)(`p`,{className:`px-2 py-1 text-xs text-fg-muted`,children:g.more}):null,R&&a.onDraftSourceNote?(0,X.jsx)(`button`,{type:`button`,className:UO,onClick:()=>{L(),a.onDraftSourceNote?.()},children:a.draftSourceNoteLabel}):null]}):null,e&&(A||F)||a.environmentAction?(0,X.jsxs)(`section`,{className:`border-t border-edge-subtle pt-3`,children:[(0,X.jsxs)(`div`,{className:`mb-1 flex items-center justify-between px-2`,children:[(0,X.jsx)(`h3`,{className:`text-sm text-fg-subtle`,children:g.environment}),F?B():null]}),A?null:a.environmentAction,A?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 px-2 py-2 text-sm text-fg`,children:[(0,X.jsx)(xt,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:A.kind===`managed_worktree`?g.worktree:g.local}),A.branch||A.headSha?(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-40 items-center gap-1 text-xs text-fg-muted`,children:[(0,X.jsx)(je,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`truncate`,children:A.branch||(A.detached?`${g.detached} · ${A.headSha?.slice(0,8)}`:A.headSha?.slice(0,8))})]}):null]}),(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 pl-9 pr-1`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,title:A.rootPath,children:A.rootPath}),(0,X.jsx)(`button`,{type:`button`,className:UO,"aria-label":p?g.copied:g.copyEnvironmentPath,title:p?g.copied:g.copyEnvironmentPath,onClick:z,children:p?(0,X.jsx)(ne,{className:`size-3.5`,"aria-hidden":!0}):(0,X.jsx)(J,{className:`size-3.5`,"aria-hidden":!0})})]}),a.environmentAction,A.available?null:(0,X.jsx)(`p`,{className:`px-2 py-1 text-xs text-fg-muted`,children:g.unavailableEnvironment}),E&&i?.workspaceRoot?(0,X.jsx)(Qa,{className:UO,to:co(E.id),state:{forceNewChat:!0,agentId:a.agentId,temporary:a.temporary},onClick:L,children:g.newEnvironment}):null]}):(0,X.jsx)(`p`,{className:`px-2 py-2 text-xs text-fg-muted`,children:g.unavailable})]}):null]}),a.executionDeviceAction]})})})]})}function GO(e){let t=(0,Z.c)(16),{conversationId:n}=e,r=y(JO),i=v(qO),a;t[0]===n?a=t[1]:(a=e=>Fn(e.sessions[n]),t[0]=n,t[1]=a);let o=Sr(a),s;t[2]!==n||t[3]!==i||t[4]!==o?(s=o?[`/api/browser/preview/${encodeURIComponent(n)}`,i]:null,t[2]=n,t[3]=i,t[4]=o,t[5]=s):s=t[5];let c;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(c={refreshInterval:1800,shouldRetryOnError:!1},t[6]=c):c=t[6];let{data:l}=vi(s,KO,c);if(!o||!l?.available||typeof RTCPeerConnection>`u`)return null;let u=r?`查看浏览器`:`View browser`,d;t[7]===n?d=t[8]:(d=()=>Ji.getState().openBrowserPreview(n),t[7]=n,t[8]=d);let f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,X.jsx)(Me,{className:`size-4 shrink-0`,"aria-hidden":!0}),t[9]=f):f=t[9];let p;t[10]===u?p=t[11]:(p=(0,X.jsx)(`span`,{className:`hidden whitespace-nowrap text-xs xl:inline`,children:u}),t[10]=u,t[11]=p);let m;return t[12]!==u||t[13]!==d||t[14]!==p?(m=(0,X.jsxs)(qi,{variant:`ghost`,className:`size-8 shrink-0 gap-1.5 rounded-lg p-0 xl:w-auto xl:px-2`,"aria-label":u,title:u,onClick:d,children:[f,p]}),t[12]=u,t[13]=d,t[14]=p,t[15]=m):m=t[15],m}function KO(e){let[t]=e;return b(_(t))}function qO(e){return e.conversationId}function JO(e){return e.language===`zh`}var YO=`min(36dvh, 320px)`;function XO(e){return e&&Number.isFinite(e.width)&&Number.isFinite(e.height)&&e.width>0&&e.height>0?e.width/e.height:void 0}function ZO(e){let t=XO(e);return t?`min(calc(100vw - 2rem), ${36*t}dvh, ${Math.min(480,320*t)}px)`:`min(320px, calc(100vw - 2rem))`}function QO(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 $O(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 ek({conversationId:e,onFrameSizeChange:t}){let n=$O(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=y(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`:QO(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,X.jsxs)(`section`,{ref:l,"aria-label":u?`电脑操作预览`:`Computer activity`,className:`relative w-full overflow-hidden rounded-xl bg-transparent`,style:{aspectRatio:XO(n.frameSize)??16/10,maxHeight:YO},children:[!n.hasFrame&&!f&&(0,X.jsx)(sn,{className:`absolute inset-0`}),(0,X.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,X.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`absolute left-2 top-2 z-10 max-w-[calc(100%-1rem)]`,children:(0,X.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,X.jsx)(xt,{size:14,className:`shrink-0`,"aria-hidden":!0}),p&&(0,X.jsx)(`span`,{className:`truncate`,children:p})]})}),f&&(0,X.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-surface-panel/90`,children:(0,X.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 tk(e){let t=(0,Z.c)(26),{conversationId:n}=e,{state:r}=$O(n,!1),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(),c=y(rk),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,X.jsx)(xt,{className:`size-4 shrink-0`,"aria-hidden":!0}),t[4]=m):m=t[4];let h=c?`电脑`:`Computer`,g;t[5]===h?g=t[6]:(g=(0,X.jsx)(`span`,{className:`hidden whitespace-nowrap text-xs xl:inline`,children:h}),t[5]=h,t[6]=g);let _;t[7]!==f||t[8]!==p||t[9]!==g?(_=(0,X.jsx)($i,{asChild:!0,children:(0,X.jsxs)(qi,{variant:`ghost`,className:`size-8 shrink-0 gap-1.5 rounded-lg p-0 xl:w-auto xl:px-2`,title:f,"aria-label":p,children:[m,g]})}),t[7]=f,t[8]=p,t[9]=g,t[10]=_):_=t[10];let v=c?`电脑预览`:`Computer preview`,b;t[11]===o?b=t[12]:(b=ZO(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,X.jsx)(ek,{conversationId:n,onFrameSizeChange:s},r.previewId),t[15]=n,t[16]=r.previewId,t[17]=C):C=t[17];let w;t[18]!==v||t[19]!==S||t[20]!==C?(w=(0,X.jsx)(Yi,{children:(0,X.jsx)(Xi,{align:`end`,sideOffset:8,collisionPadding:16,"aria-label":v,onOpenAutoFocus:nk,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]=v,t[19]=S,t[20]=C,t[21]=w):w=t[21];let T;return t[22]!==i||t[23]!==w||t[24]!==_?(T=(0,X.jsxs)(Zi,{open:i,onOpenChange:a,children:[_,w]}),t[22]=i,t[23]=w,t[24]=_,t[25]=T):T=t[25],T}function nk(e){return e.preventDefault()}function rk(e){return e.language===`zh`}function ik({conversationId:e,deviceName:t,zh:n}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(!1),v=_(`/api/endpoint-tools/artifact-transfers`),{data:y,isLoading:x}=vi(r?`${v}?conversationId=${encodeURIComponent(e)}`:null,e=>b(e),{shouldRetryOnError:!1}),S=y?.payload.files??[],C=y?.payload.tools??[],M=C.find(e=>e.toolName===s);return(0,X.jsxs)(j,{open:r,onOpenChange:e=>{i(e),e&&(o(``),c(``),u(``),m(!1),g(!1))},children:[(0,X.jsx)(T,{asChild:!0,children:(0,X.jsx)(qi,{variant:`ghost`,className:`h-8 px-2 text-sm`,children:n?`传递文件`:`Transfer file`})}),(0,X.jsxs)(O,{children:[(0,X.jsx)(w,{className:`fixed inset-0 z-[120] bg-black/50`}),(0,X.jsxs)(k,{className:`fixed left-1/2 top-1/2 z-[121] flex h-[min(23rem,90dvh)] w-[min(28rem,92vw)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover`,children:[(0,X.jsx)(A,{className:`text-base font-semibold`,children:n?`向执行设备传递文件`:`Transfer file to execution device`}),(0,X.jsx)(E,{className:`mt-1 text-sm text-fg-muted`,children:t}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto py-3`,children:[x?(0,X.jsx)(sn,{className:`h-20 w-full`}):S.length&&C.length?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(pe,{value:a,onChange:o,placeholder:n?`选择源文件`:`Select source file`,options:S.map(e=>({value:e.fileId,label:`${e.name} · ${e.sourceName} · ${Math.ceil(e.size/1024)} KB`}))}),(0,X.jsx)(pe,{value:s,onChange:c,placeholder:n?`选择接收能力`:`Select receiving capability`,options:C.map(e=>({value:e.toolName,label:e.title}))})]}):(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`当前没有可传递的文件或接收能力。`:`No eligible file or receiving capability is available.`}),l?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`在两分钟内将这段请求发到当前对话。`:`Send this request in this chat within two minutes.`}),(0,X.jsx)(`textarea`,{readOnly:!0,className:`h-20 w-full resize-none rounded-md border border-edge bg-surface-inset p-2 text-xs`,value:l,"aria-label":n?`对话请求`:`Chat request`,onFocus:e=>e.currentTarget.select()})]}):null,h?(0,X.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:n?`文件授权失败,请重新选择设备或文件。`:`Unable to authorize transfer. Reselect the device or file.`}):null]}),(0,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,X.jsx)(D,{asChild:!0,children:(0,X.jsx)(qi,{variant:`secondary`,children:n?`关闭`:`Close`})}),l?(0,X.jsx)(qi,{onClick:async()=>{try{await navigator.clipboard.writeText(l),m(!0)}catch{m(!1)}},children:p?n?`已复制`:`Copied`:n?`复制请求`:`Copy request`}):(0,X.jsx)(qi,{disabled:d||!M||!S.some(e=>e.fileId===a),onClick:async()=>{if(M){f(!0),g(!1);try{let t=await b(v,{method:`POST`,body:JSON.stringify({conversationId:e,fileId:a,toolName:s})}),r=JSON.stringify({[M.input]:t.payload.transferId});u(n?`请在当前执行设备调用 ${s} 处理已授权的文件,使用参数 ${r}。`:`Use ${s} on the selected execution device to process the authorized file with argument ${r}.`)}catch{g(!0)}finally{f(!1)}}},children:d?n?`授权中…`:`Authorizing…`:n?`生成一次性授权`:`Authorize one transfer`})]})]})]})]})}function ak({conversationId:e,disabled:t}){let n=y(e=>e.language)===`zh`,r=e&&/^[0-9a-f-]{36}$/i.test(e)?_(`/api/endpoint-tools/targets/${encodeURIComponent(e)}`):null,i=vi(r,async e=>{let t=await g(e);if(t.status===404||t.status===403)return null;if(!t.ok)throw Error(`Device target unavailable`);return(await t.json()).payload},{refreshInterval:5e3,shouldRetryOnError:!1}),a=vi(r?Us():null,Ws,{refreshInterval:3e4,shouldRetryOnError:!1}),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1);if(!r)return null;let u=(a.data??[]).filter(e=>!e.principal?.revokedAt&&!e.access?.revokedAt).flatMap(e=>e.endpoints.map(t=>({value:t.endpointId,label:`${e.displayName} · ${e.platform}`}))),d=i.data,f=(a.data??[]).find(e=>e.id===d?.principalId),p=f?.endpoints.some(e=>e.endpointId===d?.endpointId&&e.connectionId===d?.connectionId),m=d&&(!p||d.expiresAt<=Date.now()),h=d?`${f?.displayName??(n?`所选设备`:`Selected device`)}${m?n?` · 需要重新选择`:` · Reselect required`:``}`:void 0;return d&&!u.some(e=>e.value===d.endpointId)&&u.push({value:d.endpointId,label:h,disabled:!0}),(0,X.jsxs)(`section`,{className:`mt-3 space-y-2 border-t border-edge-subtle px-2 pt-3`,children:[(0,X.jsx)(`h3`,{className:`text-sm text-fg-subtle`,children:n?`执行设备`:`Execution device`}),i.isLoading||a.isLoading?(0,X.jsx)(sn,{className:`h-10 w-full rounded-lg`}):(0,X.jsx)(pe,{value:d?.endpointId??``,options:u,allowEmpty:!0,emptyLabel:n?`由对话选择`:`Choose in conversation`,placeholder:n?`由对话选择`:`Choose in conversation`,title:h,selectedLabel:h,ariaLabel:n?`选择执行设备`:`Select execution device`,triggerIcon:(0,X.jsx)(xt,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),triggerClassName:`justify-start [&>span]:flex-1`,side:`bottom`,disabled:t||o||!!(a.error||i.error),onChange:async e=>{if(!o){s(!0),l(!1);try{await b(r,{method:e?`PUT`:`DELETE`,...e?{body:JSON.stringify({endpointId:e})}:{}}),await i.mutate()}catch{l(!0),await i.mutate()}finally{s(!1)}}}}),e&&d&&!m&&!t?(0,X.jsx)(ik,{conversationId:e,deviceName:f?.displayName??d.endpointId,zh:n},d.connectionId):null,c?(0,X.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:n?`无法更改设备,请先结束正在进行的操作并重试。`:`Unable to change device. Finish active operations and retry.`}):null]})}function ok(e){let t=(0,Z.c)(23),{conversationId:n}=e,{data:r}=Wc(n),i=y(ck)===`zh`,a=$c(sk),o,s;if(t[0]!==n||t[1]!==r||t[2]!==a){let e=r?Qc(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||Lc(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=()=>Ji.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,X.jsx)(Wt,{className:`size-4`,"aria-hidden":!0}),t[10]=f):f=t[10];let p;t[11]===c?p=t[12]:(p=c&&(0,X.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,X.jsxs)(`span`,{className:`relative`,children:[f,p]}),t[13]=p,t[14]=m);let h=i?`手机`:`Phone`,g;t[15]===h?g=t[16]:(g=(0,X.jsx)(`span`,{className:`text-xs`,children:h}),t[15]=h,t[16]=g);let _;return t[17]!==g||t[18]!==l||t[19]!==u||t[20]!==d||t[21]!==m?(_=(0,X.jsxs)(qi,{variant:`ghost`,className:`min-h-10 gap-1.5 px-2`,title:l,"aria-label":u,onClick:d,children:[m,g]}),t[17]=g,t[18]=l,t[19]=u,t[20]=d,t[21]=m,t[22]=_):_=t[22],_}function sk(e){return e.seen}function ck(e){return e.language}function lk(e){let t=(0,Z.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=y(pk),f;t[0]===d?f=t[1]:(f=C(d),t[0]=d,t[1]=f);let p=f,m=sm(fk),h;t[2]===n?h=t[3]:(h=e=>e.panes[n??`new`]?.open===!0,t[2]=n,t[3]=h);let g=Ji(h),[_,v]=(0,Q.useState)(null),b,x;t[4]!==p.chat.workingDirectory.notSet||t[5]!==i?(b=i?.trim()??``,x=b?mo(b):p.chat.workingDirectory.notSet,t[4]=p.chat.workingDirectory.notSet,t[5]=i,t[6]=b,t[7]=x):(b=t[6],x=t[7]);let S=x,T;t[8]===c?T=t[9]:(T=async e=>{try{await c(e)}catch(e){let t=e;v(t instanceof Error?t.message:String(t))}},t[8]=c,t[9]=T);let D=T,M;t[10]!==D||t[11]!==b?(M={initialPath:b,onPicked:D},t[10]=D,t[11]=b,t[12]=M):M=t[12];let N=ho(M),P=o||!u||N.picking,F;t[13]!==n||t[14]!==m?(F=()=>{let e=Ji.getState(),t=n??`new`;e.setScope(t);let r=e.panes[t]?.tabs.find(dk);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]!==g?(L=l?null:(0,X.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`,g&&`bg-surface-hover text-fg`),title:d===`zh`?`打开工具`:`Open workspace tools`,"aria-label":d===`zh`?`打开工具`:`Open workspace tools`,"aria-pressed":g,"aria-controls":`app-workspace-panel`,"data-workspace-trigger":!0,onClick:I,children:(0,X.jsx)(dc,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0})}),t[16]=l,t[17]=d,t[18]=I,t[19]=g,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]!==b||t[26]!==P||t[27]!==S?(R=l&&a?(0,X.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}: ${b||S}`,"aria-label":p.chat.workingDirectory.chooseFolder,onClick:N.pick,children:[(0,X.jsx)(oe,{className:`mr-2 size-4`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.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]=b,t[26]=P,t[27]=S,t[28]=R):R=t[28];let z;t[29]!==R||t[30]!==L?(z=(0,X.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]!==b?(B=l&&!N.hasNativePicker?(0,X.jsx)(se,{open:N.modalOpen,onOpenChange:N.setModalOpen,initialAbsolutePath:b||void 0,onConfirm:N.confirmPick,wd:p.chat.workingDirectory}):null,t[32]=l,t[33]=N,t[34]=p.chat.workingDirectory,t[35]=b,t[36]=B):B=t[36];let V=_!==null,H;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(H=e=>{e||v(null)},t[37]=H):H=t[37];let U;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,X.jsx)(w,{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,X.jsx)(A,{className:`text-base font-semibold text-fg`,children:p.chat.workingDirectory.applyErrorTitle}),t[39]=p.chat.workingDirectory.applyErrorTitle,t[40]=W);let ee;t[41]===_?ee=t[42]:(ee=_?(0,X.jsx)(E,{className:`mt-2 whitespace-pre-wrap text-sm leading-relaxed text-fg-muted`,children:_}):null,t[41]=_,t[42]=ee);let te;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(te=()=>v(null),t[43]=te):te=t[43];let ne;t[44]===p.chat.workingDirectory.applyErrorClose?ne=t[45]:(ne=(0,X.jsx)(`div`,{className:`mt-4 flex justify-end border-t border-edge-subtle pt-3`,children:(0,X.jsx)(qi,{type:`button`,onClick:te,children:p.chat.workingDirectory.applyErrorClose})}),t[44]=p.chat.workingDirectory.applyErrorClose,t[45]=ne);let re;t[46]!==W||t[47]!==ee||t[48]!==ne?(re=(0,X.jsxs)(O,{children:[U,(0,X.jsxs)(k,{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:uk,children:[W,ee,ne]})]}),t[46]=W,t[47]=ee,t[48]=ne,t[49]=re):re=t[49];let ie;t[50]!==V||t[51]!==re?(ie=(0,X.jsx)(j,{open:V,onOpenChange:H,children:re}),t[50]=V,t[51]=re,t[52]=ie):ie=t[52];let ae;return t[53]!==z||t[54]!==B||t[55]!==ie?(ae=(0,X.jsxs)(X.Fragment,{children:[z,B,ie]}),t[53]=z,t[54]=B,t[55]=ie,t[56]=ae):ae=t[56],ae}function uk(e){return e.preventDefault()}function dk(e){return e.kind===`home`}function fk(e){return e.openForSession}function pk(e){return e.language}function mk(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 hk({conversationId:e,dialogOpen:t,onDialogOpenChange:n,hideTrigger:r=!1,returnFocusRef:i}){let a=y(e=>e.language),o=a===`zh`?_k:vk,[s,c]=(0,Q.useState)(!1),l=t??s,u=e=>{c(e),n?.(e)},[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(864e5),[S,C]=(0,Q.useState)(null),[M,N]=(0,Q.useState)(``),[P,F]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)([]),[R,z]=(0,Q.useState)(`hosted`),[B,V]=(0,Q.useState)(!1),[H,U]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(!l||d||p)return;let t=!1;return g(!0),v(null),Promise.all([jo(e),Fo(e),Ao()]).then(async([n,r,i])=>{if(t)return;f(n),V(i);let a=i?await Io().catch(()=>null):null;if(t)return;U(a?.publishing.allowed===!0);let o=i?await Lo(e).catch(()=>[]):[];if(t)return;let s=[...o,...r].find(e=>!e.revoked&&!e.expired);s&&m(s)}).catch(e=>{t||v(e instanceof Error?e.message:String(e))}).finally(()=>{t||g(!1)}),()=>{t=!0}},[l,d,p,e]);let W=()=>{f(null),m(null),v(null),g(!1),N(``),F(!1),L([]),U(!1)},ee=async()=>{if(!(!d||h)){g(!0),v(null);try{m(await(R===`hosted`?Po:No)(e,{expectedTranscriptId:d.transcriptId,expectedCutoffSeq:d.cutoffSeq,expectedMetadataUpdatedAt:d.metadataUpdatedAt,ttlMs:b,maxViews:S,description:M.trim()||void 0,includeToolActivities:P,attachmentIds:I}))}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(!1)}}},te=async()=>{if(!(!p||h)){g(!0),v(null);try{let t=await jo(e);f(t);let n=p.delivery===`hosted`?Mo:Oo;m(await n(e,p.id,{expectedTranscriptId:t.transcriptId,expectedCutoffSeq:t.cutoffSeq,expectedMetadataUpdatedAt:t.metadataUpdatedAt}))}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(!1)}}},ne=async()=>{if(!(!p||h)){g(!0),v(null);try{p.delivery===`hosted`?await Ro(e,p.id):await ko(p.id),u(!1),W()}catch(e){v(e instanceof Error?e.message:String(e)),g(!1)}}};return(0,X.jsxs)(j,{open:l,onOpenChange:e=>{u(e),e||W()},children:[r?null:(0,X.jsx)(T,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:`rounded-md p-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,title:o.share,"aria-label":o.share,children:(0,X.jsx)(sc,{className:`size-4`})})}),(0,X.jsxs)(O,{children:[(0,X.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),(0,X.jsxs)(k,{onCloseAutoFocus:e=>{!r||!i?.current||(e.preventDefault(),i.current.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,X.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(A,{className:`text-base font-semibold text-fg`,children:p?o.created:o.title}),(0,X.jsx)(E,{className:`mt-0.5 text-xs text-fg-muted`,children:p?o.createdHint:o.hint})]}),(0,X.jsx)(D,{asChild:!0,children:(0,X.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":o.close,children:(0,X.jsx)(an,{className:`size-4`})})})]}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:[h&&!d&&!p?(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,X.jsx)(qe,{className:`size-4 animate-spin`}),o.loading]}):p?(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:p.fileName}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o.snapshotMessages.replace(`{{count}}`,String(p.messageCount))}),(0,X.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[p.delivery===`hosted`?o.hosted:o.local,` · `,o.revision.replace(`{{revision}}`,String(p.snapshotRevision)),` · `,o.sharedAttachments.replace(`{{count}}`,String(p.attachmentCount))]})]}),(0,X.jsx)(tn,{shareUrl:p.shareUrl,lanUrl:p.lanUrl,reachability:p.reachability}),(0,X.jsx)(nn,{reachability:p.reachability,reachabilityHint:p.reachabilityHint}),(0,X.jsxs)(`a`,{href:p.shareUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-sm font-medium text-accent hover:underline`,children:[o.open,(0,X.jsx)(Ce,{className:`size-3.5`})]})]}):d?(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-inset p-3`,children:[(0,X.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:d.title}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o.snapshotMessages.replace(`{{count}}`,String(d.messageCount))}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:new Date(d.snapshotAt).toLocaleString(a===`zh`?`zh-CN`:`en-US`)})]}),(0,X.jsxs)(`details`,{className:`rounded-lg border border-edge`,children:[(0,X.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:o.reviewContent}),(0,X.jsx)(`div`,{className:`max-h-64 space-y-3 overflow-y-auto border-t border-edge p-3`,children:d.messages.map(e=>(0,X.jsxs)(`div`,{className:`rounded-lg bg-surface-inset px-3 py-2`,children:[(0,X.jsx)(`p`,{className:`mb-1 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:e.role===`user`?o.you:o.assistant}),(0,X.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm leading-6 text-fg`,children:e.markdown})]},e.id))})]}),(0,X.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,X.jsx)(Ut,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:o.scope})]}),(0,X.jsxs)(`label`,{className:`block space-y-1.5 text-xs font-medium text-fg`,children:[(0,X.jsx)(`span`,{children:o.delivery}),(0,X.jsxs)(ue,{value:R,disabled:h,onChange:e=>z(e.target.value),children:[(0,X.jsx)(fe,{value:`hosted`,children:o.hosted}),(0,X.jsx)(fe,{value:`local`,children:o.local})]})]}),R===`hosted`&&!B?(0,X.jsx)(Is,{providerId:`xopc-share`,displayName:o.hosted,connected:!1,onConnected:()=>{V(!0),Io().then(e=>U(e.publishing.allowed)).catch(()=>U(!1))}}):null,R===`hosted`&&B&&!H?(0,X.jsx)(`p`,{className:`rounded-lg border border-warning/30 bg-warning-soft px-3 py-2 text-xs text-warning`,children:o.hostedDisabled}):null,d.toolActivities.length?(0,X.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,X.jsx)(`input`,{type:`checkbox`,checked:P,disabled:h,onChange:e=>F(e.target.checked),className:`mt-0.5 size-4 rounded border-edge`}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`block font-medium`,children:o.includeTools.replace(`{{count}}`,String(d.toolActivities.length))}),(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-muted`,children:o.toolDisclosure})]})]}):null,d.attachmentCandidates.length?(0,X.jsxs)(`fieldset`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2.5`,children:[(0,X.jsx)(`legend`,{className:`px-1 text-xs font-medium text-fg`,children:o.attachments}),(0,X.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:o.attachmentDisclosure}),(0,X.jsx)(`div`,{className:`space-y-2`,children:d.attachmentCandidates.map(e=>(0,X.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:I.includes(e.id),disabled:h,onChange:t=>L(n=>t.target.checked?[...n,e.id]:n.filter(t=>t!==e.id)),className:`size-4 rounded border-edge`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.fileName}),(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:gk(e.size)})]},e.id))})]}):null,(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,X.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg`,children:[(0,X.jsx)(`span`,{children:o.ttl}),(0,X.jsxs)(ue,{value:b,disabled:h,onChange:e=>x(Number(e.target.value)),children:[(0,X.jsx)(fe,{value:36e5,children:o.oneHour}),(0,X.jsx)(fe,{value:864e5,children:o.oneDay}),(0,X.jsx)(fe,{value:6048e5,children:o.sevenDays}),(0,X.jsx)(fe,{value:2592e6,children:o.thirtyDays})]})]}),(0,X.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg`,children:[(0,X.jsx)(`span`,{children:o.maxViews}),(0,X.jsxs)(ue,{value:S??`unlimited`,disabled:h,onChange:e=>C(e.target.value===`unlimited`?null:Number(e.target.value)),children:[(0,X.jsx)(fe,{value:`unlimited`,children:o.unlimited}),(0,X.jsx)(fe,{value:1,children:`1`}),(0,X.jsx)(fe,{value:10,children:`10`}),(0,X.jsx)(fe,{value:50,children:`50`})]})]})]}),(0,X.jsxs)(`label`,{className:`block space-y-1.5 text-xs font-medium text-fg`,children:[(0,X.jsx)(`span`,{children:o.description}),(0,X.jsx)(`input`,{value:M,disabled:h,onChange:e=>N(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,X.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-300`,children:o.publicWarning})]}):null,_?(0,X.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:_}):null]}),(0,X.jsx)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-edge bg-surface-overlay px-4 py-3`,children:p?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(qi,{type:`button`,variant:`ghost`,disabled:h,onClick:()=>m(null),children:o.newShare}),(0,X.jsxs)(qi,{type:`button`,variant:`ghost`,disabled:h,onClick:()=>void ne(),children:[(0,X.jsx)(Xt,{className:`size-4`}),o.revoke]}),(0,X.jsxs)(qi,{type:`button`,disabled:h||p.delivery===`hosted`&&!H,onClick:()=>void te(),children:[h?(0,X.jsx)(qe,{className:`size-4 animate-spin`}):(0,X.jsx)(It,{className:`size-4`}),o.refresh]})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(D,{asChild:!0,children:(0,X.jsx)(qi,{type:`button`,variant:`ghost`,children:o.cancel})}),(0,X.jsxs)(qi,{type:`button`,disabled:!d||h||d.messageCount===0||R===`hosted`&&(!B||!H),onClick:()=>void ee(),children:[h?(0,X.jsx)(qe,{className:`size-4 animate-spin`}):null,o.create]})]})})]})]})]})}function gk(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var _k={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:`助手`},vk={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`},yk=`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`;function bk({title:e,centered:t,conversationId:n,pinned:r,hasMessages:i,onFindOpen:a}){let o=y(e=>e.language),s=C(o),c=(0,Q.useRef)(null),l=(0,Q.useRef)(null),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(!1),g=!!(n&&r!==void 0),_=!!(n&&i),v=r?Nt:Mt,b=async()=>{if(!(!n||m)){h(!0);try{await(r?Dn:Tn)(n)}catch{Ua(`warning`,s.sessions.pinFailed)}finally{h(!1)}}};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`h1`,{className:Y(`flex min-w-0 flex-1 text-[0.9375rem] font-semibold leading-5 tracking-tight text-fg`,t&&`md:justify-center`),children:(0,X.jsxs)(Bo,{modal:!1,children:[(0,X.jsx)(Vo,{asChild:!0,children:(0,X.jsxs)(`button`,{ref:c,type:`button`,title:e,className:Y(`inline-flex h-8 min-w-0 max-w-full items-center gap-1.5 rounded-lg px-2 text-left transition-colors`,`hover:bg-surface-hover data-[state=open]:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,Ga),children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e}),(0,X.jsx)(re,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0})]})}),(0,X.jsx)(Ho,{children:(0,X.jsxs)(Wo,{onCloseAutoFocus:e=>{let t=l.current;t&&(e.preventDefault(),l.current=null,c.current?.focus(),t())},align:`start`,sideOffset:4,collisionPadding: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:[g?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Uo,{onSelect:()=>{l.current=()=>d(!0)},className:yk,children:[(0,X.jsx)(jt,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),s.sidebar.taskRename]}),(0,X.jsxs)(Uo,{disabled:m,onSelect:()=>void b(),className:yk,children:[(0,X.jsx)(v,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),r?s.sessions.unpin:s.sessions.pin]}),(0,X.jsx)(Go,{className:`my-1 h-px bg-edge-subtle`})]}):null,(0,X.jsxs)(Uo,{disabled:!i||!a,onSelect:()=>{l.current=a??null},className:yk,children:[(0,X.jsx)(zt,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`flex-1`,children:s.chat.find.input}),(0,X.jsx)(`span`,{className:`text-xs text-fg-muted`,children:window.electronAPI?.platform===`darwin`?`⌘F`:`Ctrl+F`})]}),(0,X.jsxs)(Uo,{disabled:!_,onSelect:()=>{l.current=()=>p(!0)},className:yk,children:[(0,X.jsx)(Ht,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),o===`zh`?`分享对话`:`Share conversation`]})]})})]})}),n&&g&&u?(0,X.jsx)(Ip,{conversationId:n,initialName:e,onClose:()=>d(!1),returnFocusRef:c}):null,n&&i?(0,X.jsx)(hk,{conversationId:n,hideTrigger:!0,dialogOpen:f,onDialogOpenChange:p,returnFocusRef:c}):null]})}var xk=`(max-width: 767px)`,Sk=(0,Q.memo)(function({inline:e=!1,chatHeadline:t,chatAgents:n,showChatAgentSelector:r,chatAgentId:i,onChatAgentChange:a,chatAgentDisabled:o,conversationId:s,hasMessages:c=!1,pinned:l,workspacePath:u,userContextMode:d=`enabled`,canChangeWorkspace:f=!1,workspaceDisabled:p=!1,onWorkspaceChange:h,prepareTerminalSession:g,terminalDisabled:_=!1,showContextControls:v=!0,onFindOpen:b,projectId:x,context:S}){let w=y(e=>e.language),{conversationId:T}=m(),E=T&&T!==`new`?decodeURIComponent(T):null,D=s?.trim()||E,{data:O,error:k,mutate:A}=up(D??null,!1),j=!k&&(!O||!!O.environment?.available),M=Ji(e=>e.panes[D??`new`]?.open===!0),N=C(w),P=Sp(e=>e.collapsed),F=HT(e=>e.setOpen),I=Ps(e=>e.toggle),L=Ps(e=>e.open),[R,z]=(0,Q.useState)(!1),B=Cp(e=>e.mobileNavOpen),V=Xa(e=>e.setPageHeader),H=Xa(e=>e.clearPageHeader),U=window.electronAPI?.platform,W=!!(v&&window.electronAPI?.terminal&&(D||g)),ee=(0,Q.useCallback)(()=>{if(!(!W||_||R)){if(D){I(D);return}g&&(z(!0),g().then(e=>{e&&L(e)}).finally(()=>z(!1)))}},[D,L,g,W,_,R,I]),te=(0,Q.useCallback)(()=>{if(!D||!c)return;let e=Ji.getState().panes[D],t=HT.getState().pendingCreate?.parentConversationId===D||!!HT.getState().creatingRequests[D],n=e?.open===!0&&(e.activeId?.startsWith(`side:`)===!0||t);F(D,!n)},[D,c,F]),ne=Ls(xk),re=mp({runtime:pp(),sidebarCollapsed:P,mobileNavOpen:B}),ie=ne?!B:re.collapsedNewChatVisible;(0,Q.useLayoutEffect)(()=>{if(!e)return()=>H()},[H,e]),(0,Q.useEffect)(()=>{if(!W)return;let e=e=>{mk(e,U)&&(e.preventDefault(),ee())};return window.addEventListener(`keydown`,e),window.addEventListener(`workspace-open-terminal`,ee),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`workspace-open-terminal`,ee)}},[ee,W,U]),(0,Q.useEffect)(()=>{if(!D||!c)return;let e=e=>{Gs(e,U)&&(e.preventDefault(),te())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[D,te,c,U]);let ae=(0,Q.useMemo)(()=>({startExtra:ie?(0,X.jsx)(Qa,{to:co(x),state:{forceNewChat:!0,agentId:i,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`,Ga),title:N.sidebar.newTask,children:(0,X.jsx)(Ft,{className:`size-4 shrink-0 text-accent-fg`,strokeWidth:2,"aria-hidden":!0})}):null,main:(0,X.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,X.jsx)(bk,{title:t,centered:ie,conversationId:D,hasMessages:c,pinned:l,onFindOpen:b},D)}),end:(0,X.jsxs)(`div`,{className:Y(`flex min-w-0 max-w-[min(32rem,calc(100vw-8rem))] shrink-0 items-center justify-end gap-2`,Ga),children:[r?(0,X.jsx)(LO,{items:n,value:i,disabled:o,placeholder:N.chat.agentPlaceholder,newChatLabel:D?N.chat.agentStartNewChat:void 0,searchPlaceholder:N.chat.agentSearchPlaceholder,noMatches:N.chat.agentNoMatches,compact:!0,contentSide:`bottom`,contentAlign:`end`,onChange:a}):null,v?(0,X.jsx)(WO,{...S,agentId:i,executionDeviceAction:D?(0,X.jsx)(ak,{conversationId:D,disabled:o}):null,environmentAction:f&&h?(0,X.jsx)(lk,{directoryOnly:!0,conversationId:D,workspacePath:D?u:S?.project?.workspaceRoot,available:j,canChangeWorkspace:!0,disabled:p,onWorkspaceChange:async e=>{await h(e),await A()}}):null,temporary:d===`temporary`,conversationId:D??null},`context:${D??S?.project?.id??`new`}`):null,v&&!M?(0,X.jsx)(`span`,{"aria-hidden":!0,className:`mx-0.5 h-6 w-px shrink-0 bg-edge-subtle`}):null,D?(0,X.jsx)(GO,{conversationId:D}):null,D?(0,X.jsx)(tk,{conversationId:D},D):null,D?(0,X.jsx)(ok,{conversationId:D}):null,v&&!M?(0,X.jsx)(lk,{conversationId:D,workspacePath:D?u:S?.project?.workspaceRoot,available:j,canChangeWorkspace:!1,disabled:p,onWorkspaceChange:async e=>{await h?.(e),await A()}},`workspace:${D??x}`):null]})}),[t,n,r,i,a,o,ie,N.chat.agentPlaceholder,N.chat.agentSearchPlaceholder,N.chat.agentNoMatches,N.chat.terminal.open,N.sidebar.newTask,x,S,W,_,v,M,R,D,c,l,b,F,u,j,A,d,f,p,h,ee,te]);return(0,Q.useLayoutEffect)(()=>{e||V(ae)},[ae,e,V]),e?(0,X.jsxs)(`header`,{"aria-label":w===`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,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:ae.main}),ae.end]}):null}),Ck=(0,Q.memo)(function(){let e=(0,Z.c)(19),t=y(wk),n;e[0]===t?n=e[1]:(n=C(t),e[0]=t,e[1]=n);let r=n.chat.runRecovery,i=Vi(Tk),a=Vi(Ek),[o,s]=(0,Q.useState)(!1),c=i===`connecting`||i===`reconnecting`,l,u;if(e[2]===c?(l=e[3],u=e[4]):(l=()=>{if(!c)return;let e=window.setTimeout(()=>s(!0),1500);return()=>{window.clearTimeout(e),s(!1)}},u=[c],e[2]=c,e[3]=l,e[4]=u),(0,Q.useEffect)(l,u),i!==`error`&&!(c&&o))return null;let d=i===`error`,f=d?en:It,p=`size-3.5 shrink-0 ${c?`motion-safe:animate-spin`:``}`,m;e[5]!==f||e[6]!==p?(m=(0,X.jsx)(f,{className:p,"aria-hidden":!0}),e[5]=f,e[6]=p,e[7]=m):m=e[7];let h=d?r.connectionFailed:i===`connecting`?r.connecting:r.reconnecting,g;e[8]===h?g=e[9]:(g=(0,X.jsx)(`span`,{className:`min-w-0 flex-1`,children:h}),e[8]=h,e[9]=g);let _;e[10]!==a||e[11]!==d||e[12]!==r.details||e[13]!==r.reconnect?(_=d?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,className:`min-h-9 rounded-md border border-edge px-3 text-xs text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:Dk,children:r.reconnect}),a?(0,X.jsxs)(`details`,{className:`w-full min-w-0`,children:[(0,X.jsx)(`summary`,{className:`w-fit cursor-pointer rounded-md py-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:r.details}),(0,X.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words rounded-md bg-surface-inset p-2`,children:Li(a)})]}):null]}):null,e[10]=a,e[11]=d,e[12]=r.details,e[13]=r.reconnect,e[14]=_):_=e[14];let v;return e[15]!==m||e[16]!==g||e[17]!==_?(v=(0,X.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex flex-wrap items-center gap-2 border-b border-edge-subtle bg-surface-panel px-4 py-2 text-xs text-fg-muted`,children:[m,g,_]}),e[15]=m,e[16]=g,e[17]=_,e[18]=v):v=e[18],v});function wk(e){return e.language}function Tk(e){return e.connectionState}function Ek(e){return e.error}function Dk(){return Bi()}function Ok(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function kk(e){let t=(0,Z.c)(4),{status:n}=e;if(n===`completed`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.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,X.jsx)(ne,{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,X.jsx)(me,{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,X.jsx)(qs,{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,X.jsx)(ge,{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 Ak(e,t){return e?`${Ok(e.files.length===1?t.filesChangedOne:t.filesChangedOther,{count:e.files.length})} · +${e.added} -${e.removed}`:null}function jk(e){let t=(0,Z.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(Pk),t[0]=n.items,t[1]=s);let c=s,l=n.items.every(Nk),u;t[2]!==a.completedProgress||t[3]!==n.completedCount||t[4]!==n.totalCount?(u=Ok(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=Ok(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=Ak(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`,Ma.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,X.jsx)(ne,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:2,"aria-hidden":!0}):o?(0,X.jsx)(me,{className:`size-4 shrink-0 text-accent`,strokeWidth:2,"aria-hidden":!0}):(0,X.jsx)(Ge,{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,X.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,X.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,X.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,X.jsx)(re,{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,X.jsx)($i,{asChild:!0,children:(0,X.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,X.jsx)(Ge,{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,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[E,(0,X.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,X.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,X.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,X.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,X.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(Mk),t[47]=n.items,t[48]=N);let P;t[49]!==a.heading||t[50]!==N?(P=(0,X.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,X.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,X.jsx)(Yi,{children:(0,X.jsxs)(Xi,{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,X.jsx)(`div`,{className:`mx-auto flex w-full max-w-80 justify-center pb-2 pt-1`,children:(0,X.jsxs)(Zi,{children:[T,I]})}),t[58]=T,t[59]=I,t[60]=L):L=t[60],L}function Mk(e){return(0,X.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,X.jsx)(kk,{status:e.status}),(0,X.jsx)(`span`,{className:`min-w-0 [overflow-wrap:anywhere]`,children:e.title})]},e.id)}function Nk(e){return e.status===`completed`||e.status===`cancelled`}function Pk(e){return e.status===`completed`}function Fk(e){let t=Vk(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 Ik=new Set([`pending`,`in_progress`,`completed`,`cancelled`]);function Lk(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function Rk(e){return e.trim().toLowerCase().replace(/-/g,`_`).split(`__`).at(-1)??``}function zk(e){let t=Lk(e.details);return t&&Object.keys(t).length>0?t:Ra(e.result).details}function Bk(e){let t=typeof e==`string`?e.trim():``;return Ik.has(t)?t:null}function Vk(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 Hk(e){if(!Array.isArray(e.plan))return null;let t=e.plan.flatMap((e,t)=>{let n=Lk(e),r=typeof n?.id==`string`&&n.id.trim()?n.id.trim():`update-plan-${t}`,i=typeof n?.step==`string`?n.step.trim():``,a=Bk(n?.status);return i&&a?[{id:r,title:i,status:a}]:[]});return Vk(`update_plan`,typeof e.explanation==`string`&&e.explanation.trim()?e.explanation.trim():void 0,t)}function Uk(e){return Array.isArray(e.items)?Vk(`todo`,void 0,e.items.flatMap((e,t)=>{let n=Lk(e),r=typeof n?.id==`string`&&n.id.trim()?n.id.trim():`todo-${t}`,i=typeof n?.content==`string`?n.content.trim():``,a=Bk(n?.status);return i&&a?[{id:r,title:i,status:a}]:[]})):null}function Wk(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=Rk(n.name),i=zk(n);if(i){if(r===`update_plan`)return{found:!0,plan:Hk(i)};if(r===`todo`)return{found:!0,plan:Uk(i)}}}return{found:!1,plan:null}}function Gk(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:0}function Kk(e){let t=new Set,n=0,r=0;for(let i of e){if(i.type!==`tool_use`||i.status===`error`||Rk(i.name)!==`apply_patch`)continue;let e=zk(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=Lk(n),r=typeof e?.moveTo==`string`?e.moveTo:typeof e?.path==`string`?e.path:``;r.trim()&&t.add(r.trim())}n+=Gk(e.added),r+=Gk(e.removed)}}return t.size>0||n>0||r>0?{files:[...t],added:n,removed:r}:null}function qk(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.role!==`assistant`)continue;let r=Wk(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:Kk(i)}}return null}function Jk(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 qk(e.slice(n+1))}function Yk(e){let{details:t,text:n}=Ra(e.result);if(typeof t?.id==`string`)return t.id;let r=e.details;if(typeof r?.id==`string`)return r.id;if(n.trimStart().startsWith(`{`))try{let e=JSON.parse(n);if(typeof e?.id==`string`)return e.id}catch{}}function Xk(e,t){let n=new Map;return e.forEach((e,r)=>{if(e.role===`assistant`)for(let i of e.content){if(i.type!==`tool_use`||i.name!==t||i.status===`error`)continue;let e=Yk(i);e&&(t===`video_draft`||!n.has(e))&&n.set(e,r)}}),n}var Zk={zh:{play:`播放`,pause:`暂停`,retry:`重试播放`,loading:`正在加载音频`,error:`音频暂时无法播放,请重试。`,seek:`播放进度`,lyrics:`歌词`,volume:`音量`,mute:`静音`,unmute:`取消静音`,download:`下载音频`},en:{play:`Play`,pause:`Pause`,retry:`Retry playback`,loading:`Loading audio`,error:`Audio could not play. Try again.`,seek:`Playback position`,lyrics:`Lyrics`,volume:`Volume`,mute:`Mute`,unmute:`Unmute`,download:`Download audio`}};function Qk({src:e,title:t,durationMs:n,lyrics:r,lyricsOpen:i,onToggleLyrics:a,language:o}){let s=Zk[o],c=(0,Q.useId)(),{element:l,hostRef:u}=wt({kind:`audio`,src:e,title:t}),{position:d,duration:f,muted:p,volume:m,starting:h,playing:g,failed:_,toggle:v,seek:y}=Tt(l),b=f||(n&&n>0?Math.round(n/1e3):0),x=Math.min(d,b),S=g||h,C=!!r?.trim(),w=_?Lt:h?qe:S?At:Pt,T=p||m===0?mc:$t;return(0,X.jsxs)(`div`,{role:`group`,"aria-label":t,children:[(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsxs)(`div`,{className:`grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-1.5 text-xs tabular-nums text-fg-muted`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`min-w-[3.5ch]`,children:Et(x)}),(0,X.jsxs)(`div`,{className:`relative flex h-6 items-center`,children:[(0,X.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-1.5 h-1 overflow-hidden rounded-full bg-edge-strong`,children:(0,X.jsx)(`div`,{className:`h-full rounded-full bg-fg`,style:{width:`${b?x/b*100:0}%`}})}),(0,X.jsx)(`input`,{type:`range`,min:0,max:b||1,step:.1,value:x,disabled:!f||_,"aria-label":s.seek,"aria-valuetext":`${Et(x)} / ${b?Et(b):`—`}`,onChange:e=>y(e.currentTarget.valueAsNumber),className:`relative block h-full w-full cursor-pointer appearance-none rounded-md bg-transparent focus-visible:outline-2 focus-visible:outline-accent disabled:cursor-default disabled:opacity-0 [&::-webkit-slider-thumb]:size-3 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-fg [&::-moz-range-thumb]:size-3 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-0 [&::-moz-range-thumb]:bg-fg`})]}),(0,X.jsx)(`span`,{"aria-hidden":!0,className:`min-w-[3.5ch] text-end`,children:b?Et(b):`—`})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(qi,{variant:`ghost`,className:`size-11 shrink-0 rounded-full bg-fg p-0 text-surface-panel hover:bg-fg/85 hover:text-surface-panel`,onClick:v,"aria-label":_?s.retry:S?s.pause:s.play,children:(0,X.jsx)(w,{size:20,"aria-hidden":!0,className:Y(h&&`motion-safe:animate-spin`,!S&&!_&&`ms-0.5 fill-current`,g&&`fill-current`)})}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:[C&&(0,X.jsxs)(qi,{variant:`ghost`,className:Y(`min-h-11 gap-1.5 rounded-full px-2.5 text-xs`,i&&`bg-accent-soft text-accent-fg hover:text-accent-fg`),"aria-controls":`${c}-lyrics`,"aria-expanded":i,onClick:a,children:[(0,X.jsx)(oc,{size:17,"aria-hidden":!0}),s.lyrics]}),(0,X.jsx)(qi,{asChild:!0,variant:`ghost`,className:`size-11 rounded-full p-0`,children:(0,X.jsx)(`a`,{href:`${e}?download=1`,download:`music.mp3`,"aria-label":s.download,title:s.download,children:(0,X.jsx)(xe,{size:18,"aria-hidden":!0})})}),(0,X.jsxs)(Zi,{children:[(0,X.jsx)($i,{asChild:!0,children:(0,X.jsx)(qi,{variant:`ghost`,className:`size-11 rounded-full p-0`,"aria-label":s.volume,title:s.volume,children:(0,X.jsx)(T,{size:18,"aria-hidden":!0})})}),(0,X.jsx)(Yi,{children:(0,X.jsxs)(Xi,{side:`top`,align:`end`,sideOffset:6,"aria-label":s.volume,className:`z-50 flex items-center gap-2 rounded-xl border border-edge bg-surface-overlay p-2 shadow-float`,children:[(0,X.jsx)(qi,{variant:`ghost`,className:`size-11 rounded-full p-0`,"aria-label":p?s.unmute:s.mute,onClick:()=>{l&&(l.muted=!l.muted)},children:(0,X.jsx)(T,{size:17,"aria-hidden":!0})}),(0,X.jsx)(`input`,{type:`range`,min:0,max:100,step:1,value:p?0:Math.round(m*100),"aria-label":s.volume,className:`h-8 w-28 cursor-pointer accent-accent focus-visible:outline-2 focus-visible:outline-accent`,onChange:e=>{l&&(l.volume=e.currentTarget.valueAsNumber/100,l.muted=!1)}})]})})]})]})]})]}),h&&(0,X.jsx)(`p`,{role:`status`,className:`sr-only`,children:s.loading}),_&&(0,X.jsx)(`p`,{role:`alert`,className:`px-3 pb-3 text-xs text-fg-muted`,children:s.error}),C&&(0,X.jsx)(`div`,{id:`${c}-lyrics`,hidden:!i,role:`region`,"aria-label":s.lyrics,tabIndex:0,className:`mt-2 max-h-[clamp(5rem,calc(100dvh-15rem),17rem)] overflow-y-auto overscroll-y-auto rounded-xl border border-edge bg-surface-inset px-4 py-5 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-accent sm:px-5`,children:i&&(0,X.jsx)(`p`,{className:`whitespace-pre-wrap wrap-anywhere text-[0.9375rem] leading-6 font-normal text-fg`,children:r})}),(0,X.jsx)(`div`,{ref:u,hidden:!0})]})}var $k={zh:{provider_rate_limited:`音乐服务暂时拒绝了请求。请稍后再试,若持续出现,请检查服务商额度或请求限制。`,provider_rejected:`音乐服务拒绝了请求。请检查「模型与能力」中的音乐配置后再试。`,provider_failed:`音乐服务未能完成生成。你可以在对话中重新发起创作。`,credentials_missing:`请恢复原音乐模型的配置和 API Key,任务会自动继续。`,status_retrying:`暂时无法查询进度,正在重新查询同一个任务。`,audio_retrying:`暂时无法保存音频,正在重新下载同一份成品。`,expired:`任务或音频下载已过期。你可以在对话中重新发起创作。`},en:{provider_rate_limited:`The music service rejected the request. Try again later. If it persists, check the provider’s quota or request limits.`,provider_rejected:`The music service rejected the request. Check the music configuration in Models and capabilities before trying again.`,provider_failed:`The music service could not finish generation. You can start a new request in chat.`,credentials_missing:`Restore the original music model settings and API key to resume this task.`,status_retrying:`Progress is temporarily unavailable. We’re checking the same task again.`,audio_retrying:`The audio could not be saved. We’re downloading the same result again.`,expired:`The task or audio download has expired. You can start a new request in chat.`}},eA={zh:{song:`歌曲`,instrumental:`纯音乐`,details:`创作详情`,prompt:`提示词`,model:`模型`,status:{queued:`排队中`,submitting:`正在提交`,submitted:`供应商排队中`,running:`生成中`,saving:`正在保存`,completed:`可播放`,failed:`生成失败`,submission_unknown:`提交结果待确认`},unknown:`暂时无法确认音乐服务是否已接收请求。请先核对服务商的任务或账单,再决定是否重新生成。`},en:{song:`Song`,instrumental:`Instrumental`,details:`Creation details`,prompt:`Prompt`,model:`Model`,status:{queued:`Queued`,submitting:`Submitting`,submitted:`Queued at provider`,running:`Generating`,saving:`Saving`,completed:`Ready`,failed:`Generation failed`,submission_unknown:`Submission unconfirmed`},unknown:`The music service may have received the request. Check the provider’s tasks or billing before generating again.`}};function tA(e,t,n,r){let i=(0,Z.c)(23),a;i[0]===e?a=i[1]:(a=e?_(`/api/music-generation/sessions/${encodeURIComponent(e)}/jobs`):null,i[0]=e,i[1]=a);let o=a,{data:s,mutate:c}=vi(o,b),l;i[2]===s?.jobs?l=i[3]:(l=s?.jobs.some(nA)??!1,i[2]=s?.jobs,i[3]=l);let u=l,d,f;i[4]!==n||i[5]!==c||i[6]!==o?(d=()=>{!n&&o&&c()},f=[n,c,o],i[4]=n,i[5]=c,i[6]=o,i[7]=d,i[8]=f):(d=i[7],f=i[8]),(0,Q.useEffect)(d,f);let p,m;i[9]!==u||i[10]!==c?(p=()=>{if(!u)return;let e=window.setInterval(()=>{document.visibilityState===`visible`&&navigator.onLine&&c()},3e3);return()=>window.clearInterval(e)},m=[u,c],i[9]=u,i[10]=c,i[11]=p,i[12]=m):(p=i[11],m=i[12]),(0,Q.useEffect)(p,m);let h,g;i[13]!==e||i[14]!==c?(h=()=>{if(!e)return;let t=t=>{let n=t.detail;(n?.conversationId??n?.key)===e&&c()};return window.addEventListener(`session-updated`,t),window.addEventListener(`session-transcript-updated`,t),()=>{window.removeEventListener(`session-updated`,t),window.removeEventListener(`session-transcript-updated`,t)}},g=[e,c],i[13]=e,i[14]=c,i[15]=h,i[16]=g):(h=i[15],g=i[16]),(0,Q.useEffect)(h,g);let v;bb0:{if(!o||!s?.jobs.length){let e;i[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],i[17]=e):e=i[17],v=e;break bb0}let e;if(i[18]!==s.jobs||i[19]!==t||i[20]!==r||i[21]!==o){let n=Xk(r,`music_generation`);e=s.jobs.map(e=>({id:`music-generation:${e.id}`,timestamp:e.createdAt,afterMessageIndex:n.get(e.id),content:(0,X.jsx)(rA,{job:e,audioUrl:`${o}/${encodeURIComponent(e.id)}/audio`,language:t},e.id)})),i[18]=s.jobs,i[19]=t,i[20]=r,i[21]=o,i[22]=e}else e=i[22];v=e}return v}function nA(e){return![`completed`,`failed`,`submission_unknown`].includes(e.state)}function rA(e){let t=(0,Z.c)(61),{job:n,audioUrl:r,language:i}=e,a=eA[i],o=(0,Q.useId)(),[s,c]=(0,Q.useState)(null),l=n.state===`completed`,u=n.state===`failed`,d=i===`zh`?`第 ${n.versionNumber} 版`:`Version ${n.versionNumber}`,f=n.errorCode?$k[i][n.errorCode]:void 0,p=n.state===`submission_unknown`?a.unknown:f??(u?$k[i].provider_failed:void 0),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=e=>c(t=>t===e?null:e),t[0]=m):m=t[0];let h=m,g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,X.jsxs)(`div`,{className:`relative grid size-11 shrink-0 place-items-center overflow-hidden rounded-lg border border-edge bg-surface-inset text-accent-fg`,"aria-hidden":!0,children:[(0,X.jsx)(`span`,{className:`absolute size-9 rounded-full border border-current opacity-15`}),(0,X.jsx)(`span`,{className:`absolute size-6 rounded-full border border-current opacity-20`}),(0,X.jsx)(Ct,{size:18,className:`relative`})]}),t[1]=g):g=t[1];let _;t[2]===n.title?_=t[3]:(_=(0,X.jsx)(`h3`,{className:`wrap-anywhere text-lg leading-tight font-semibold tracking-tight text-fg`,children:n.title}),t[2]=n.title,t[3]=_);let v=a[n.mode],y;t[4]!==v||t[5]!==d?(y=(0,X.jsxs)(`span`,{children:[v,` · `,d]}),t[4]=v,t[5]=d,t[6]=y):y=t[6];let b;t[7]!==l||t[8]!==n.state||t[9]!==a.status?(b=!l&&(0,X.jsx)(`span`,{role:`status`,className:`font-medium`,children:a.status[n.state]}),t[7]=l,t[8]=n.state,t[9]=a.status,t[10]=b):b=t[10];let x;t[11]!==y||t[12]!==b?(x=(0,X.jsxs)(`p`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2 text-xs text-fg-muted`,children:[y,b]}),t[11]=y,t[12]=b,t[13]=x):x=t[13];let S;t[14]!==_||t[15]!==x?(S=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[_,x]}),t[14]=_,t[15]=x,t[16]=S):S=t[16];let C=`${o}-details`,w=s===`details`,T,E;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>h(`details`),E=(0,X.jsx)(Se,{size:20,"aria-hidden":!0}),t[17]=T,t[18]=E):(T=t[17],E=t[18]);let D;t[19]!==a.details||t[20]!==w||t[21]!==C?(D=(0,X.jsx)(qi,{variant:`ghost`,className:`size-11 shrink-0 rounded-full p-0 aria-expanded:bg-surface-active aria-expanded:text-fg`,"aria-label":a.details,title:a.details,"aria-controls":C,"aria-expanded":w,onClick:T,children:E}),t[19]=a.details,t[20]=w,t[21]=C,t[22]=D):D=t[22];let O;t[23]!==D||t[24]!==S?(O=(0,X.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[g,S,D]}),t[23]=D,t[24]=S,t[25]=O):O=t[25];let k;t[26]!==u||t[27]!==p?(k=p&&(0,X.jsx)(`p`,{className:u?`text-xs text-danger`:`text-xs text-fg-muted`,children:p}),t[26]=u,t[27]=p,t[28]=k):k=t[28];let A;t[29]!==l||t[30]!==n.id||t[31]!==n.title||t[32]!==i?(A=l&&(0,X.jsx)(wh,{mediaId:`music-${n.id}.mp3`,title:n.title,zh:i===`zh`}),t[29]=l,t[30]=n.id,t[31]=n.title,t[32]=i,t[33]=A):A=t[33];let j;t[34]!==r||t[35]!==l||t[36]!==n.durationMs||t[37]!==n.lyrics||t[38]!==n.mode||t[39]!==n.title||t[40]!==i||t[41]!==s?(j=l&&(0,X.jsx)(Qk,{src:r,title:n.title,durationMs:n.durationMs,lyrics:n.mode===`song`?n.lyrics:null,lyricsOpen:s===`lyrics`,onToggleLyrics:()=>h(`lyrics`),language:i},r),t[34]=r,t[35]=l,t[36]=n.durationMs,t[37]=n.lyrics,t[38]=n.mode,t[39]=n.title,t[40]=i,t[41]=s,t[42]=j):j=t[42];let M=`${o}-details`,N=s!==`details`,P;t[43]!==n.error||t[44]!==n.errorCode||t[45]!==n.modelRef||t[46]!==n.prompt||t[47]!==a.model||t[48]!==a.prompt||t[49]!==s?(P=s===`details`&&(0,X.jsxs)(`dl`,{className:`space-y-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-xs text-fg-muted`,children:a.prompt}),(0,X.jsx)(`dd`,{className:`mt-1 whitespace-pre-wrap wrap-anywhere text-sm leading-relaxed text-fg`,children:n.prompt})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-xs text-fg-muted`,children:a.model}),(0,X.jsxs)(`dd`,{className:`mt-1 wrap-anywhere text-sm text-fg`,children:[n.modelRef,n.errorCode===`provider_rate_limited`&&n.error?.endsWith(`HTTP 429.`)&&` · HTTP 429`]})]})]}),t[43]=n.error,t[44]=n.errorCode,t[45]=n.modelRef,t[46]=n.prompt,t[47]=a.model,t[48]=a.prompt,t[49]=s,t[50]=P):P=t[50];let F;t[51]!==M||t[52]!==N||t[53]!==P?(F=(0,X.jsx)(`div`,{id:M,hidden:N,className:`border-t border-edge pt-3`,children:P}),t[51]=M,t[52]=N,t[53]=P,t[54]=F):F=t[54];let I;return t[55]!==O||t[56]!==k||t[57]!==A||t[58]!==j||t[59]!==F?(I=(0,X.jsxs)(`article`,{className:`flex w-full min-w-0 max-w-[26rem] flex-col gap-2 rounded-xl border border-edge bg-surface-panel p-3
64
+ [background-image:radial-gradient(ellipse_at_top_left,var(--color-accent-soft),transparent_72%)] sm:p-3.5`,children:[O,k,A,j,F]}),t[55]=O,t[56]=k,t[57]=A,t[58]=j,t[59]=F,t[60]=I):I=t[60],I}function iA(e){let t=(0,Z.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,X.jsx)(`article`,{className:`min-w-0 w-full max-w-lg space-y-2.5 rounded-xl bg-surface-inset p-3 sm:p-4`,children:n}),t[0]=n,t[1]=r),r}function aA(e){let t=(0,Z.c)(6),{label:n,children:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,X.jsx)(ie,{size:14,"aria-hidden":!0,className:`group-open:rotate-90`}),t[0]=i):i=t[0];let a;t[1]===n?a=t[2]:(a=(0,X.jsxs)(`summary`,{className:`flex w-fit cursor-pointer list-none items-center gap-1 rounded-sm py-1 hover:text-fg focus-visible:outline-2 focus-visible:outline-accent [&::-webkit-details-marker]:hidden`,children:[i,n]}),t[1]=n,t[2]=a);let o;return t[3]!==r||t[4]!==a?(o=(0,X.jsxs)(`details`,{className:`group text-xs text-fg-muted`,children:[a,r]}),t[3]=r,t[4]=a,t[5]=o):o=t[5],o}function oA(e){let t=(0,Z.c)(5),{src:n,title:r}=e,i;t[0]!==n||t[1]!==r?(i={kind:`video`,src:n,title:r},t[0]=n,t[1]=r,t[2]=i):i=t[2];let{hostRef:a}=wt(i),o;return t[3]===a?o=t[4]:(o=(0,X.jsx)(`div`,{ref:a}),t[3]=a,t[4]=o),o}var sA={zh:{title:`视频`,draft:`视频草稿`,original:`跟随原图`,autoDuration:`自动时长`,download:`下载视频`,previous:`重置前生成的视频`,generate:`确认生成`,adjust:`修改草稿`,submitting:`正在提交…`,noKey:`请在「模型与能力」连接当前视频服务。`,details:`查看完整提示词和模型`,estimate:`预计`,reference:`参考图`,status:{queued:`排队中`,submitting:`正在提交`,submitted:`供应商排队中`,running:`生成中`,saving:`正在保存`,completed:`已完成`,failed:`生成失败`,submission_unknown:`提交结果待确认`}},en:{title:`Video`,draft:`Video draft`,original:`Match the image`,autoDuration:`Auto duration`,download:`Download video`,previous:`Videos from before the reset`,generate:`Confirm generation`,adjust:`Edit draft`,submitting:`Submitting…`,noKey:`Connect the video provider in Models and capabilities.`,details:`View full prompt and model`,estimate:`Est.`,reference:`Reference image`,status:{queued:`Queued`,submitting:`Submitting`,submitted:`Queued at provider`,running:`Generating`,saving:`Saving`,completed:`Ready`,failed:`Generation failed`,submission_unknown:`Submission unconfirmed`}}};function cA(e){return/^(就按这个生成|确认生成视频|确认生成|confirm video generation|generate this video)[。!.!]?$/iu.test(e.trim())}function lA(e){return _(`/api/video-generation/sessions/${encodeURIComponent(e)}/jobs`)}function uA(e){return![`completed`,`failed`,`submission_unknown`].includes(e.state)}function dA(e,t,n,r={}){let{chatBusy:i=!1,readOnly:a=!1,onAdjust:o}=r,s=e?lA(e):null,{data:c,mutate:l}=vi(s,async e=>{try{return await b(e)}catch(e){if(e.status===404)return null;throw e}}),u=c?.jobs.some(uA)??!1,d=(0,Q.useRef)(null),[f,p]=(0,Q.useState)(),[m,h]=(0,Q.useState)(),g=c?.draft,_=g?`${g.id}:${g.revision}`:void 0,v=!!(c?.configured&&g?.modelRef===c.modelRef),y=(0,Q.useCallback)(async()=>{if(!s||!g||!_||d.current||i||a||!v)return!1;d.current=_,p(_),h(void 0);try{let e=await b(`${s}/confirm-draft`,{method:`POST`,body:JSON.stringify({id:g.id,revision:g.revision})});return await l(t=>t&&{...t,draft:t.draft?.id===e.id?void 0:t.draft,jobs:[e,...t.jobs.filter(t=>t.id!==e.id)]},{revalidate:!0}),!0}catch(e){return h({key:_,message:e instanceof Error?e.message:String(e)}),l(),!1}finally{d.current=null,p(void 0)}},[s,g,_,i,a,v,l]),x=(0,Q.useRef)(!1);return(0,Q.useEffect)(()=>{x.current&&!i&&l(),x.current=i},[i,l]),(0,Q.useEffect)(()=>{if(!u)return;let e=window.setInterval(()=>{document.visibilityState===`visible`&&navigator.onLine&&l()},3e3);return()=>window.clearInterval(e)},[u,l]),(0,Q.useEffect)(()=>{if(!e)return;let t=t=>{let n=t.detail;(n?.conversationId??n?.key)===e&&l()};return window.addEventListener(`session-updated`,t),window.addEventListener(`session-transcript-updated`,t),()=>{window.removeEventListener(`session-updated`,t),window.removeEventListener(`session-transcript-updated`,t)}},[e,l]),{draft:g,confirmDraft:y,timelineEntries:(0,Q.useMemo)(()=>{if(!c||!s||!e)return[];let r=e=>(0,X.jsx)(hA,{job:e,url:`${s}/${encodeURIComponent(e.id)}/video`,language:t},e.id),l=c.jobs.filter(e=>e.transcriptId===c.transcriptId),u=c.jobs.filter(e=>e.transcriptId!==c.transcriptId),d=l.length||g?Xk(n,`video_draft`):void 0,p=l.map(e=>({id:`video-generation:${e.id}`,timestamp:e.draftCreatedAt??e.createdAt,afterMessageIndex:d?.get(e.id),content:r(e)}));return g&&p.push({id:`video-generation:${g.id}`,timestamp:g.createdAt,afterMessageIndex:d?.get(g.id),content:(0,X.jsx)(fA,{draft:g,conversationId:e,language:t,configured:v,modelChanged:g.modelRef!==c.modelRef,readOnly:a,disabled:i||!!f,submitting:f===_,error:m?.key===_?m?.message:void 0,onAdjust:o,onConfirm:y})}),u.length&&p.push({id:`video-generation:previous-transcripts`,timestamp:u[0].createdAt,content:(0,X.jsxs)(`details`,{className:`w-full max-w-lg rounded-xl border border-edge-subtle px-4 py-3`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer text-sm text-fg-muted`,children:sA[t].previous}),(0,X.jsx)(`div`,{className:`mt-3 space-y-3`,children:u.map(r)})]})}),p},[c,g,_,v,a,i,f,m,o,y,e,t,n,s])}}function fA(e){let t=(0,Z.c)(60),{draft:n,conversationId:r,language:i,configured:a,modelChanged:o,readOnly:s,disabled:c,submitting:l,error:u,onAdjust:d,onConfirm:f}=e,p=sA[i],m=i===`zh`,h;t[0]===n.modelRef?h=t[1]:(h=n.modelRef.startsWith(`xopc-cloud/`),t[0]=n.modelRef,t[1]=h);let g=h,v;t[2]!==g||t[3]!==n.estimatedCostFen||t[4]!==n.estimatedCreditMicro?(v=g?n.estimatedCreditMicro&&`${fi(String(n.estimatedCreditMicro))} Credits`:`¥${(n.estimatedCostFen/100).toFixed(2)}`,t[2]=g,t[3]=n.estimatedCostFen,t[4]=n.estimatedCreditMicro,t[5]=v):v=t[5];let y=v,b;t[6]!==r||t[7]!==n.imageUri?(b=n.imageUri?_(`/api/media/read?${new URLSearchParams({uri:n.imageUri,conversationId:r})}`):void 0,t[6]=r,t[7]=n.imageUri,t[8]=b):b=t[8];let x=b,S;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,X.jsx)(pc,{size:16,"aria-hidden":!0}),t[9]=S):S=t[9];let C;t[10]===p.draft?C=t[11]:(C=(0,X.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[S,p.draft]}),t[10]=p.draft,t[11]=C);let w;t[12]!==n.imageName||t[13]!==x||t[14]!==p.reference?(w=x&&(0,X.jsx)(`img`,{src:x,alt:n.imageName??p.reference,className:`size-14 shrink-0 rounded-lg object-cover`}),t[12]=n.imageName,t[13]=x,t[14]=p.reference,t[15]=w):w=t[15];let T=n.summary||n.prompt,E;t[16]===T?E=t[17]:(E=(0,X.jsx)(`p`,{className:`line-clamp-3 min-w-0 wrap-anywhere text-sm leading-relaxed text-fg`,children:T}),t[16]=T,t[17]=E);let D;t[18]!==w||t[19]!==E?(D=(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[w,E]}),t[18]=w,t[19]=E,t[20]=D):D=t[20];let O;t[21]!==n||t[22]!==i?(O=pA(n,i),t[21]=n,t[22]=i,t[23]=O):O=t[23];let k;t[24]!==p.estimate||t[25]!==y?(k=y?(0,X.jsxs)(X.Fragment,{children:[` · `,(0,X.jsxs)(`span`,{className:`font-medium tabular-nums text-fg`,children:[p.estimate,` `,y]})]}):null,t[24]=p.estimate,t[25]=y,t[26]=k):k=t[26];let A;t[27]!==O||t[28]!==k?(A=(0,X.jsxs)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:[O,k]}),t[27]=O,t[28]=k,t[29]=A):A=t[29];let j=g?m?`XOPC Cloud 在供应商接受任务后扣除 Credits。`:`XOPC Cloud charges Credits when the provider accepts the task.`:m?`以供应商实际账单为准。`:`Actual charges are set by the provider.`,M=n.duration===-1&&(m?`自动时长按最长时长估算。`:` Auto duration is estimated at the model maximum.`),N;t[30]!==n||t[31]!==i||t[32]!==j||t[33]!==M?(N=(0,X.jsxs)(mA,{video:n,language:i,children:[j,M]}),t[30]=n,t[31]=i,t[32]=j,t[33]=M,t[34]=N):N=t[34];let P;t[35]!==a||t[36]!==p.noKey||t[37]!==o||t[38]!==m?(P=!a&&(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:o?m?`默认视频模型已切换,请先调整草稿。`:`The default video model changed. Adjust the draft first.`:p.noKey}),t[35]=a,t[36]=p.noKey,t[37]=o,t[38]=m,t[39]=P):P=t[39];let F;t[40]===u?F=t[41]:(F=u&&(0,X.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:u}),t[40]=u,t[41]=F);let I;t[42]!==a||t[43]!==c||t[44]!==p.adjust||t[45]!==p.generate||t[46]!==p.submitting||t[47]!==d||t[48]!==f||t[49]!==s||t[50]!==l?(I=!s&&(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(qi,{variant:`primary`,className:`min-h-9 px-3 py-1`,disabled:c||!a,onClick:()=>void f(),children:l?p.submitting:p.generate}),d&&(0,X.jsx)(qi,{variant:`ghost`,className:`min-h-9 px-3 py-1`,disabled:c,onClick:d,children:p.adjust})]}),t[42]=a,t[43]=c,t[44]=p.adjust,t[45]=p.generate,t[46]=p.submitting,t[47]=d,t[48]=f,t[49]=s,t[50]=l,t[51]=I):I=t[51];let L;return t[52]!==A||t[53]!==N||t[54]!==P||t[55]!==F||t[56]!==I||t[57]!==C||t[58]!==D?(L=(0,X.jsxs)(iA,{children:[C,D,A,N,P,F,I]}),t[52]=A,t[53]=N,t[54]=P,t[55]=F,t[56]=I,t[57]=C,t[58]=D,t[59]=L):L=t[59],L}function pA(e,t){let n=sA[t];return[e.duration===-1?n.autoDuration:t===`zh`?`${e.duration} 秒`:`${e.duration}s`,e.resolution.toLowerCase(),e.ratio===`adaptive`?n.original:e.ratio].join(` · `)}function mA(e){let t=(0,Z.c)(11),{video:n,language:r,children:i}=e,a=sA[r],o;t[0]===n.prompt?o=t[1]:(o=(0,X.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap wrap-anywhere border-s border-edge px-3 text-sm leading-relaxed text-fg`,children:n.prompt}),t[0]=n.prompt,t[1]=o);let s=L[n.modelRef??`dashscope-cn/wan3.0-video`],c;t[2]===i?c=t[3]:(c=i&&(0,X.jsxs)(X.Fragment,{children:[` · `,i]}),t[2]=i,t[3]=c);let l;t[4]!==s.name||t[5]!==c?(l=(0,X.jsxs)(`p`,{className:`mt-2`,children:[s.name,c]}),t[4]=s.name,t[5]=c,t[6]=l):l=t[6];let u;return t[7]!==a.details||t[8]!==o||t[9]!==l?(u=(0,X.jsxs)(aA,{label:a.details,children:[o,l]}),t[7]=a.details,t[8]=o,t[9]=l,t[10]=u):u=t[10],u}function hA(e){let t=(0,Z.c)(39),{job:n,url:r,language:i}=e,a=sA[i],o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,X.jsx)(pc,{size:16,"aria-hidden":!0}),t[0]=o):o=t[0];let s;t[1]===a.title?s=t[2]:(s=(0,X.jsxs)(`h3`,{className:`flex items-center gap-2 font-medium text-fg`,children:[o,a.title]}),t[1]=a.title,t[2]=s);let c=a.status[n.state],l;t[3]===c?l=t[4]:(l=(0,X.jsx)(`span`,{role:`status`,className:`text-xs text-fg-muted`,children:c}),t[3]=c,t[4]=l);let u;t[5]!==s||t[6]!==l?(u=(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-sm`,children:[s,l]}),t[5]=s,t[6]=l,t[7]=u):u=t[7];let d;t[8]!==n||t[9]!==i?(d=pA(n,i),t[8]=n,t[9]=i,t[10]=d):d=t[10];let f;t[11]===d?f=t[12]:(f=(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:d}),t[11]=d,t[12]=f);let p;t[13]===n.error?p=t[14]:(p=n.error&&(0,X.jsx)(`p`,{className:`text-xs text-danger`,children:n.error}),t[13]=n.error,t[14]=p);let m;t[15]!==n.id||t[16]!==n.state||t[17]!==n.summary||t[18]!==i||t[19]!==a.download||t[20]!==a.title||t[21]!==r?(m=n.state===`completed`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(oA,{src:r,title:n.summary||a.title}),(0,X.jsxs)(`a`,{href:`${r}?download=1`,download:`generated-video.mp4`,className:`inline-flex items-center gap-2 text-sm text-accent-fg hover:underline`,children:[(0,X.jsx)(xe,{size:15,"aria-hidden":!0}),a.download]}),(0,X.jsx)(wh,{mediaId:`wan-${n.id}.mp4`,title:n.summary||a.title,zh:i===`zh`})]}),t[15]=n.id,t[16]=n.state,t[17]=n.summary,t[18]=i,t[19]=a.download,t[20]=a.title,t[21]=r,t[22]=m):m=t[22];let h;t[23]===n.summary?h=t[24]:(h=n.summary&&(0,X.jsx)(`p`,{className:`line-clamp-3 wrap-anywhere text-sm leading-relaxed text-fg`,children:n.summary}),t[23]=n.summary,t[24]=h);let g;t[25]!==n.imageName||t[26]!==a.reference?(g=n.imageName&&(0,X.jsxs)(`span`,{className:`wrap-anywhere`,children:[a.reference,` · `,n.imageName]}),t[25]=n.imageName,t[26]=a.reference,t[27]=g):g=t[27];let _;t[28]!==n||t[29]!==i||t[30]!==g?(_=(0,X.jsx)(mA,{video:n,language:i,children:g}),t[28]=n,t[29]=i,t[30]=g,t[31]=_):_=t[31];let v;return t[32]!==h||t[33]!==_||t[34]!==u||t[35]!==f||t[36]!==p||t[37]!==m?(v=(0,X.jsxs)(iA,{children:[u,f,p,m,h,_]}),t[32]=h,t[33]=_,t[34]=u,t[35]=f,t[36]=p,t[37]=m,t[38]=v):v=t[38],v}function gA(e,t){return e.bottom>t.top&&e.top<t.bottom&&e.right>t.left&&e.left<t.right}function _A(e,t,n){let r=n.getBoundingClientRect(),i=t.getBoundingClientRect();if(!gA(e,{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight})||!gA(i,r)||typeof t.animate!=`function`)return()=>{};let a=t.closest(`article`);a&&(a.style.animation=`none`);let o=t.getBoundingClientRect(),s=e.left-o.left,c=e.top-o.top,l;try{l=t.animate([{transform:`translate3d(${s}px, ${c}px, 0)`},{transform:`translate3d(0, 0, 0)`}],{duration:360,easing:`cubic-bezier(0.25, 0.1, 0.25, 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.closest(`[data-chat-message-row]`);(!t.isConnected||e&&!gA(e.getBoundingClientRect(),n.getBoundingClientRect()))&&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,510),l.finished.then(f,f),f}function vA(e){let t=(0,Z.c)(13),{enabled:n,conversationId:r,messages:i,viewportRef:a}=e,o=(0,Q.useRef)(null),s=(0,Q.useRef)(null),c=(0,Q.useRef)(r),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{o.current&&window.clearTimeout(o.current.timeout),o.current=null,s.current?.(),s.current=null},t[0]=l):l=t[0];let u=l,d;t[1]===n?d=t[2]:(d=(e,t,r)=>{if(u(),!n||r.attachments.length>0||r.contextRefs.length>0||!r.text.trim()||document.visibilityState===`hidden`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let i={id:e.clientSubmissionId,source:{left:t.left,top:t.top,right:t.right,bottom:t.bottom},timeout:window.setTimeout(()=>{o.current===i&&(o.current=null)},500)};o.current=i},t[1]=n,t[2]=d);let f=d,p,m;t[3]===r?(p=t[4],m=t[5]):(p=()=>{let e=c.current;c.current=r,e!==null&&e!==r&&u()},m=[u,r],t[3]=r,t[4]=p,t[5]=m),(0,Q.useLayoutEffect)(p,m);let h,g;t[6]!==i||t[7]!==a?(h=()=>{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=_A(e.source,n,t))},g=[i,a],t[6]=i,t[7]=a,t[8]=h,t[9]=g):(h=t[8],g=t[9]),(0,Q.useLayoutEffect)(h,g);let _;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>u,t[10]=_):_=t[10];let v;return t[11]===n?v=t[12]:(v=[u,n],t[11]=n,t[12]=v),(0,Q.useEffect)(_,v),f}function yA(e){let t=(0,Z.c)(64),{open:n,query:r,activeIndex:i,resultCount:a,searching:o,truncated:s,limitedToLoaded:c,inputRef:l,className:u,labels:d,onQueryChange:f,onPrevious:p,onNext:m,onClose:h}=e,g=o!==void 0&&o,_=s!==void 0&&s,v=c!==void 0&&c;if(!n)return null;let y;t[0]===r?y=t[1]:(y=r.trim(),t[0]=r,t[1]=y);let b=!!y,x;t[2]!==i||t[3]!==b||t[4]!==d.noResults||t[5]!==d.resultCount||t[6]!==d.searching||t[7]!==a||t[8]!==g||t[9]!==_?(x=g?d.searching:b&&a===0?d.noResults:b?d.resultCount.replace(`{{current}}`,String(i+1)).replace(`{{total}}`,`${a}${_?`+`:``}`):``,t[2]=i,t[3]=b,t[4]=d.noResults,t[5]=d.resultCount,t[6]=d.searching,t[7]=a,t[8]=g,t[9]=_,t[10]=x):x=t[10];let S=x,C;t[11]!==S||t[12]!==b||t[13]!==d.loadedOnly||t[14]!==v?(C=v&&b?[S,d.loadedOnly].filter(Boolean).join(` · `):S,t[11]=S,t[12]=b,t[13]=d.loadedOnly,t[14]=v,t[15]=C):C=t[15];let w=C,T=g||a===0,E=d.input,D;t[16]===u?D=t[17]:(D=Y(`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`,u),t[16]=u,t[17]=D);let O;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,X.jsx)(zt,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[18]=O):O=t[18];let k;t[19]===f?k=t[20]:(k=e=>f(e.target.value),t[19]=f,t[20]=k);let A;t[21]!==m||t[22]!==p?(A=e=>{e.nativeEvent.isComposing||e.key===`Enter`&&(e.preventDefault(),e.shiftKey?p():m())},t[21]=m,t[22]=p,t[23]=A):A=t[23];let j;t[24]!==l||t[25]!==d.input||t[26]!==r||t[27]!==k||t[28]!==A?(j=(0,X.jsx)(`input`,{ref:l,value:r,type:`search`,autoComplete:`off`,spellCheck:!1,"aria-label":d.input,className:`h-12 min-w-0 flex-1 bg-transparent text-base text-fg outline-none placeholder:text-fg-subtle`,placeholder:d.input,onChange:k,onKeyDown:A}),t[24]=l,t[25]=d.input,t[26]=r,t[27]=k,t[28]=A,t[29]=j):j=t[29];let M;t[30]===g?M=t[31]:(M=g?(0,X.jsx)(qe,{className:`size-4 shrink-0 animate-spin text-fg-muted`,"aria-hidden":!0}):null,t[30]=g,t[31]=M);let N;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(N=Y(`inline-flex size-11 shrink-0 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,Ma.focusRingPanel,Ma.press),t[32]=N):N=t[32];let P;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,X.jsx)(an,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[33]=P):P=t[33];let F;t[34]!==d.close||t[35]!==h?(F=(0,X.jsx)(`button`,{type:`button`,onClick:h,className:N,"aria-label":d.close,children:P}),t[34]=d.close,t[35]=h,t[36]=F):F=t[36];let I;t[37]!==j||t[38]!==M||t[39]!==F?(I=(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 px-3`,children:[O,j,M,F]}),t[37]=j,t[38]=M,t[39]=F,t[40]=I):I=t[40];let L;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(L=Y(`inline-flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,Ma.focusRingPanel,Ma.press,Ma.disabled),t[41]=L):L=t[41];let R;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,X.jsx)(ae,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[42]=R):R=t[42];let z;t[43]!==d.previous||t[44]!==T||t[45]!==p?(z=(0,X.jsx)(`button`,{type:`button`,disabled:T,onClick:p,className:L,"aria-label":d.previous,children:R}),t[43]=d.previous,t[44]=T,t[45]=p,t[46]=z):z=t[46];let B;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(B=Y(`inline-flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,Ma.focusRingPanel,Ma.press,Ma.disabled),t[47]=B):B=t[47];let V;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,X.jsx)(re,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[48]=V):V=t[48];let H;t[49]!==d.next||t[50]!==T||t[51]!==m?(H=(0,X.jsx)(`button`,{type:`button`,disabled:T,onClick:m,className:B,"aria-label":d.next,children:V}),t[49]=d.next,t[50]=T,t[51]=m,t[52]=H):H=t[52];let U;t[53]===w?U=t[54]:(U=(0,X.jsx)(`span`,{className:`ml-auto px-2 text-sm tabular-nums text-fg-muted`,"aria-live":`polite`,"aria-atomic":`true`,children:w}),t[53]=w,t[54]=U);let W;t[55]!==z||t[56]!==H||t[57]!==U?(W=(0,X.jsxs)(`div`,{className:`flex h-11 items-center border-t border-edge-subtle px-1.5`,children:[z,H,U]}),t[55]=z,t[56]=H,t[57]=U,t[58]=W):W=t[58];let ee;return t[59]!==d.input||t[60]!==I||t[61]!==W||t[62]!==D?(ee=(0,X.jsxs)(`section`,{"data-chat-find-bar":!0,role:`search`,"aria-label":E,className:D,children:[I,W]}),t[59]=d.input,t[60]=I,t[61]=W,t[62]=D,t[63]=ee):ee=t[63],ee}async function bA(e,t,n={}){let r=await g(_(`${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 xA=`chat-find-match`,SA=`chat-find-active`,CA=`chat-find-highlight-styles`;function wA(){let e=globalThis.CSS,t=globalThis.Highlight;return!e?.highlights||!t?null:{registry:e.highlights,Highlight:t}}function TA(){if(document.getElementById(CA))return;let e=document.createElement(`style`);e.id=CA,e.textContent=`
65
+ ::highlight(${xA}) {
66
66
  color: inherit;
67
67
  background-color: color-mix(in srgb, var(--color-warning) 38%, transparent);
68
68
  }
69
- ::highlight(${bA}) {
69
+ ::highlight(${SA}) {
70
70
  color: inherit;
71
71
  background-color: color-mix(in srgb, var(--color-warning) 78%, transparent);
72
72
  text-decoration: underline 2px var(--color-fg);
73
73
  }
74
- `,document.head.appendChild(e)}function wA(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 TA(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 EA(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 DA(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=wA(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 EA(s,n)){let t=TA(o,e.start,e.end);t&&(r.push({messageIndex:i,occurrence:a,range:t}),a+=1)}}}return r}function OA(e,t){let n=SA();if(!n||(CA(),n.registry.delete(yA),n.registry.delete(bA),e.length===0))return;n.registry.set(yA,new n.Highlight(...e.map(e=>e.range)));let r=e[t];r&&n.registry.set(bA,new n.Highlight(r.range))}function kA(){let e=SA();e?.registry.delete(yA),e?.registry.delete(bA)}function AA(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||(cT(e),e.scrollTo({top:Math.max(0,e.scrollTop+r.top-a),behavior:window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}))}function jA(e,t){return t===0?0:(e+t)%t}function MA(e){return`${e.displayIndex}:${e.occurrence}`}function NA(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 PA(e){let t=(0,Z.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(zA));for(let t of p){let n={displayIndex:a+t.messageIndex,occurrence:t.occurrence};e.set(MA(n),n)}A=[...e.values()].sort(RA),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),kA(),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=>jA(t+e,j.length))},t[14]=j.length,t[15]=H);let U=H,W,ee;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)},ee=[z,U,c,F],t[16]=U,t[17]=c,t[18]=F,t[19]=W,t[20]=ee):(W=t[19],ee=t[20]),(0,Q.useEffect)(W,ee);let te;t[21]!==k||t[22]!==c||t[23]!==o?(te=()=>{let e=o.current;if(!c||!e||!k.trim()){m(LA),kA();return}let t=()=>{let t=DA(e,k);m(e=>NA(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]=te):te=t[24];let ne;t[25]!==k||t[26]!==i||t[27]!==c||t[28]!==o?(ne=[k,i,c,o],t[25]=k,t[26]=i,t[27]=c,t[28]=o,t[29]=ne):ne=t[29],(0,Q.useLayoutEffect)(te,ne);let re,ie;t[30]!==n||t[31]!==k||t[32]!==c||t[33]!==r?(re=()=>{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(()=>{vA(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()}},ie=[n,k,c,r],t[30]=n,t[31]=k,t[32]=c,t[33]=r,t[34]=re,t[35]=ie):(re=t[34],ie=t[35]),(0,Q.useEffect)(re,ie);let ae,oe;t[36]===j.length?(ae=t[37],oe=t[38]):(ae=()=>{T(e=>Math.min(e,Math.max(0,j.length-1)))},oe=[j.length],t[36]=j.length,t[37]=ae,t[38]=oe),(0,Q.useEffect)(ae,oe);let se,ce;t[39]!==w||t[40]!==j||t[41]!==a||t[42]!==p||t[43]!==s||t[44]!==o?(se=()=>{let e=j[w],t=o.current;if(!t||!e){OA(p,-1);return}let n=e.displayIndex-a,r=p.findIndex(t=>t.messageIndex===n&&t.occurrence===e.occurrence);OA(p,r),r>=0?AA(t,p[r]):s(e.displayIndex)},ce=[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]=se,t[46]=ce):(se=t[45],ce=t[46]),(0,Q.useLayoutEffect)(se,ce);let le;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(le=[],t[47]=le):le=t[47],(0,Q.useEffect)(FA,le);let ue,de;t[48]!==n||t[49]!==c?(ue=()=>{O.current!==n&&(O.current=n,c&&z())},de=[z,n,c],t[48]=n,t[49]=c,t[50]=ue,t[51]=de):(ue=t[50],de=t[51]),(0,Q.useEffect)(ue,de);let fe,pe;t[52]===U?(fe=t[53],pe=t[54]):(fe=()=>U(-1),pe=()=>U(1),t[52]=U,t[53]=fe,t[54]=pe);let G;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]!==fe||t[64]!==pe?(G={open:c,query:u,inputRef:E,activeIndex:w,resultCount:j.length,truncated:v,limitedToLoaded:b,searching:S,setQuery:V,show:F,close:z,previous:fe,next:pe},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]=fe,t[64]=pe,t[65]=G):G=t[65],G}function FA(){return IA}function IA(){return kA()}function LA(e){return e.length===0?e:[]}function RA(e,t){return e.displayIndex-t.displayIndex||e.occurrence-t.occurrence}function zA(e){return[MA(e),e]}function BA(e){let t=String(e??``).trim();return!t||t===`new`?null:t}function VA(e){let t=String(e.streamConversationId??``).trim(),n=BA(e.routeConversationId);return!t||!n?!1:t===n}function HA(e){let t=BA(e.routeConversationId);return t?e.cacheConversationId===t:!1}function UA(e){let t=String(e.chatId??``).trim();if(!t)return!1;let n=BA(e.routeConversationId);return n?n===t:!1}function WA(e,t){return e?`new`:t??null}function GA(e,t){if(!(e||!t))return decodeURIComponent(t)}function KA(e){if(!e.viewConversationId||e.conversationId!==e.viewConversationId)return[];if(!e.streamingMsg)return e.messages;let t=e.messages.findLastIndex(e=>!e.pendingSteer)+1,n=e.messages.slice(t),r=e.messages[t-1];if(n.length&&!e.streamingMsg.content.length&&!e.streamingMsg.attachments?.length)return[...e.messages,e.streamingMsg];if(r?.role===`assistant`&&e.streamingMsg.role===`assistant`){let i=gr([r,e.streamingMsg]);return[...e.messages.slice(0,t-1),...i,...n]}return[...e.messages.slice(0,t),e.streamingMsg,...n]}function qA(e,t){let n=e.findLastIndex(e=>!e.pendingSteer),r=e[n];return r?.role!==`assistant`||r.turnId!==t?null:{messagesWithoutTail:[...e.slice(0,n),...e.slice(n+1)],tail:r}}function JA(e){e()}function YA(e,t){return!!(e&&(e.localDraft||e.configVersion!==void 0)&&t?.some(t=>t.id===e.model))}function XA(e){e.sendingRef.current=!1,e.streamingRef.current=!1}function ZA(e){return e.isNewRoute?`creating-session`:e.sessionRoutePending||e.showSessionLoading||e.sessionContentLoading?`loading-history`:e.messageCount===0?`ready-empty`:`ready-conversation`}var QA=new Map;async function $A(e,t,n,r,i){let a=v.getState(),o=Yr([a.baseUrl,a.conversationId,e,t]),s=Yr({action:n,submission:r}),c=QA.get(o);if(c){if(c.signature!==s)throw Error(`An answer is already being submitted`);return(await c.promise).clone()}let l=ej(e,t,n,r,i).then(e=>{for(e.ok||QA.delete(o);QA.size>64;)QA.delete(QA.keys().next().value);return e},e=>{throw QA.delete(o),e});return QA.set(o,{signature:s,promise:l}),(await l).clone()}async function ej(e,t,n,r,i){let a=v.getState().conversationId,o=cp(e,t,`submission`,i),s={schemaVersion:2,action:n,...r,expectedVersion:t},c=Yr(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}})),v.getState().conversationId!==a)throw Error(`Active Gateway changed`);let d=await g(_(`/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 cp(e,t,`draft`,i).write(void 0)),d}async function tj(e,t,n){let r=()=>{if(!n())throw new DOMException(`Conversation changed`,`AbortError`)},i=await ei(e);if(r(),i&&(i.kind!==`append`||i.execution||i.delivery!==t.delivery||Yr(i.input)!==Yr(t.input)||!!i.interrupt!=!!t.interrupt))throw Error(`The previous input is awaiting confirmation`);let a=Zr.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},s=async t=>{let n=await g(_(`/api/sessions/${encodeURIComponent(e)}/input-receipts/${encodeURIComponent(a.clientMessageId)}`),{signal:t}),i=await n.json();if(r(),n.ok)return o(i.payload);if(n.status!==404||i.error?.code!==`NOT_RECEIVED`)throw Error(i.error?.message??`Input receipt lookup failed`)},c=async t=>(r(),await ti(e,a.clientMessageId),r(),t);if(i){let e=await s();if(e!==void 0)return c(e)}let{origin:l,...u}=a;await Jr(e,u),r();let d,f;try{d=await g(_(`/api/sessions/${encodeURIComponent(e)}/inputs`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(a)});let t=await d.json();if(r(),!d.ok)throw Error(typeof t.error==`string`?t.error:t.error?.message??`Message was not accepted`);f=o(t.payload)}catch(t){if(r(),d&&d.status>=400&&d.status<500&&d.status!==408)throw await ti(e,a.clientMessageId),t;if(f=await s(AbortSignal.timeout(3e3)).catch(()=>void 0),r(),f===void 0)throw t}return c(f)}function nj(e){return e.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e,n=t.origin;if(t.status!==`injecting`||t.effectiveDelivery!==`steer`||n?.type!==`endpoint`||typeof t.clientMessageId!=`string`||typeof t.content!=`string`)return[];let r=Hr(t.content),i=Array.isArray(t.contextRefs)?t.contextRefs:[],a=new Map(i.flatMap(e=>typeof e?.refId==`string`&&typeof e.title==`string`?[[e.refId,e.title]]:[]));return Er([{role:`user`,content:r?nr(r,e=>a.get(e)):t.content,attachments:t.attachments,metadata:{clientMessageId:t.clientMessageId,steered:!0,sourceContexts:i,userTurnDocument:r},timestamp:t.createdAtMs,turnId:t.targetRunId}]).map(e=>({...e,pendingSteer:!0}))})}function rj(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:{...Wr(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 ij(e){let{conversationId:t,personal:n,decodedKey:r,conversationIdRef:i,sendingRef:a,streamingRef:o,modelSupportsThinking:s,thinkingLevel:c,shouldApplyStreamUpdate:l}=e,u=v(e=>e.conversationId),d=(0,Q.useRef)({gateway:u,conversationId:t});(d.current.gateway!==u||d.current.conversationId!==t)&&(d.current={gateway:u,conversationId:t});let f=(0,Q.useCallback)(()=>{let e=d.current;return()=>d.current===e&&i.current===e.conversationId&&v.getState().conversationId===e.gateway},[i]),[p,m]=(0,Q.useState)(null),[h,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(null),S=(0,Q.useRef)(null),C=(0,Q.useRef)(0),w=(0,Q.useRef)(null),[T,E]=(0,Q.useState)([]),D=(0,Q.useRef)([]),[O,k]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(()=>({scope:d.current,mode:{kind:`compose`}})),M=A.scope===d.current?A.mode:{kind:`compose`},N=(0,Q.useCallback)(e=>j({scope:d.current,mode:e}),[]),P=(0,Q.useRef)(M);P.current=M;let F=M.kind===`editFollowUp`?M.inputId:null,I=e=>N(e?{kind:`editFollowUp`,inputId:e,version:D.current.find(t=>t.id===e)?.version??0}:{kind:`compose`}),[L,R]=(0,Q.useState)(()=>wr(t??``)),[z,B]=(0,Q.useState)(!1),V=(0,Q.useRef)(!1),H=(0,Q.useRef)(null),U=(0,Q.useRef)(-1),[W,ee]=(0,Q.useState)(!1),te=(0,Q.useRef)(null),[ne,re]=(0,Q.useState)(null),ie=(0,Q.useCallback)(()=>re(d.current),[]);S.current=p,D.current=T,H.current=F;let ae=(0,Q.useCallback)(e=>{if(!e||typeof e!=`object`)return;let t=e;if(t.conversationId!==i.current||typeof t.revision!=`number`||!Array.isArray(t.inputs)||t.revision<U.current)return;if(t.control){if(!Rr(t.conversationId,t.control,t.revision))return;R(t.control)}let n=EE({control:t.control,inputs:t.inputs,activeRunId:t.activeRunId,preparation:t.preparation}),r=nj(t.inputs),a=Sr.getState();if(r.length||a.sessions[t.conversationId]?.messages.some(e=>e.pendingSteer)){let e=new Set(n.map(e=>e.clientMessageId));a.updateSessionMessages(t.conversationId,t=>{let n=t.filter(t=>!t.pendingSteer||!t.clientMessageId||!e.has(t.clientMessageId)),i=new Set(n.map(e=>e.clientMessageId));return[...n,...r.filter(e=>!i.has(e.clientMessageId))]})}U.current=t.revision,ee(!t.activeRunId&&t.inputs.length===0),D.current=n,E(n)},[i]),oe=(0,Q.useCallback)(async e=>{if(e!==i.current)return;let t=f();if(await $r(e)||!t())return;let n=await g(_(`/api/sessions/${encodeURIComponent(e)}/input-state`)).catch(()=>null);if(!n?.ok||i.current!==e)return;let r=await n.json().catch(()=>null);t()&&ae(r?.payload)},[ae,f,i]),se=(0,Q.useCallback)(async e=>{if(e!==i.current)return;let t=f(),n=++C.current;if(await $r(e)||!t())return;let r=await g(_(`/api/sessions/${encodeURIComponent(e)}/clarification`)).catch(()=>null);if(!r?.ok||i.current!==e)return;let a=await r.json().catch(()=>null);!t()||n!==C.current||i.current!==e||(x(null),m(rj(a?.payload,e)),w.current=null)},[f,i]);(0,Q.useLayoutEffect)(()=>{U.current=-1,ee(!1),te.current=null,V.current=!1,B(!1),k(null),C.current++,R(wr(t??``)),N({kind:`compose`}),D.current=[],E([]),I(null),m(null)},[t,u]),(0,Q.useEffect)(()=>{!t||t!==r||(oe(t),se(t))},[r,se,oe,t,u]),(0,Q.useEffect)(()=>{let e=e=>{let t=e.detail;ae(t);let n=i.current;n&&t&&typeof t==`object`&&t.conversationId===n&&se(n)},t=e=>{let t=i.current;if(!t)return;let n=e.detail;if(n&&typeof n==`object`){let e=n.conversationId;if(typeof e==`string`&&e!==t)return}x(null),C.current++,m(rj(n,t)),w.current=null},n=()=>{let e=i.current;e&&(oe(e),se(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)}},[ae,se,oe,i]),(0,Q.useEffect)(()=>{if(!p?.expiresAt)return;let e=Math.max(0,p.expiresAt-Date.now())+250,t=window.setTimeout(()=>{let e=i.current;e&&se(e)},e);return()=>window.clearTimeout(t)},[p?.expiresAt,se,i]);let ce=(0,Q.useCallback)(()=>{x(null),m(null)},[]),le=(0,Q.useCallback)(e=>{let t=String(e??``).trim();t&&i.current===t&&(x(null),m(null))},[i]),ue=(0,Q.useCallback)(()=>{x(null),m(null)},[]),de=(0,Q.useCallback)(()=>{I(null)},[]),fe=(0,Q.useCallback)(()=>{x(null),m(null),I(null)},[]),pe=(0,Q.useCallback)(e=>t=>{l(e)&&(a.current=!1,o.current=!1,Sr.getState().setSessionFlags(e,{sending:!1,streaming:!1}),Sr.getState().setSessionProgress(e,null),x(null),C.current++,m({...t,conversationId:e}),w.current=null)},[l,a,o]),G=(0,Q.useCallback)(async(e,t,n,r,a,o)=>{let s=e.trim();if(!s&&!t?.length&&!n?.length)return;let c=i.current;if(!c)throw Error(`No active session`);let l=f(),u=wr(c),d=await qr(c);if(!l())throw new DOMException(`Conversation changed`,`AbortError`);let p=await Ur();if(!l())throw new DOMException(`Conversation changed`,`AbortError`);if(!d)throw Error(`Reload the conversation before sending`);let m=Sr.getState().sessions[c]?.configVersion;if(m===void 0)throw Error(`Reload the conversation before sending`);let h=await tj(c,{kind:`append`,expectedTranscriptId:d,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:r},origin:p},l);l()&&ae(h)},[ae,f,i]),me=(0,Q.useCallback)(async(e,t)=>{let n=i.current;if(!n||V.current)throw Error(`Wait for the current operation`);let r=f(),a=()=>{if(!r())throw new DOMException(`Conversation changed`,`AbortError`)};V.current=!0,B(!0);try{let r=await qr(n);a();let i=Date.now()+15e3;for(;!r&&e===`stop`&&Date.now()<i;)await new Promise(e=>setTimeout(e,100)),r=await qr(n),a();if(!r)throw Error(`Input acceptance is awaiting confirmation`);if(t?.onlyIfEmpty&&P.current.kind!==`compose`)return;let o={action:e,operationId:crypto.randomUUID(),expectedTranscriptId:r,expectedVersion:wr(n).version,...t},s=await mr(n,o);if(a(),ae(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(;wr(n).phase===`stopping`;){if(a(),Date.now()>=e)throw Error(`Stop is awaiting confirmation`);await new Promise(e=>setTimeout(e,100)),await oe(n)}}if(a(),e===`stop`||e===`pause`){let t=wr(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!r()||(await oe(n),!r())||t?.onlyIfEmpty||Ga(`error`,e instanceof Error?e.message:String(e)),e}finally{r()&&(V.current=!1,B(!1))}},[ae,f,i,oe]);(0,Q.useEffect)(()=>{if(!t||!W||!L.paused||L.phase!==`idle`||z||M.kind!==`compose`||ne!==d.current)return;let e=`${u}:${t}:${L.version}:${U.current}`;if(te.current===e)return;let n=window.setTimeout(()=>{V.current||P.current.kind!==`compose`||(te.current=e,me(`resume`,{onlyIfEmpty:!0}).catch(()=>{}))},0);return()=>window.clearTimeout(n)},[me,M.kind,L.paused,L.phase,L.version,z,t,u,ne,W]);let he=(0,Q.useCallback)(()=>me(`stop`),[me]),K=(0,Q.useCallback)(()=>me(`resume`),[me]),ge=(0,Q.useCallback)(async(e,t)=>{let n=f();try{return await me(`stop`,{turnId:e}),n()?(N({kind:`editTurn`,turnId:e,draft:t}),!0):!1}catch{return!1}},[f,me]),_e=(0,Q.useCallback)(async e=>{let t=D.current.find(t=>t.id===e);if(!t)return!1;let n=f();try{return await me(`pause`,{inputId:e,inputVersion:t.version}),n()?(N({kind:`editFollowUp`,inputId:e,version:t.version}),!0):!1}catch{return!1}},[f,me]),q=(0,Q.useCallback)(()=>N({kind:`compose`}),[]),ve=(0,Q.useCallback)(async(e,t,n,r,a)=>{let o=i.current;if(!o||M.kind!==`editFollowUp`||M.inputId!==e||!t.trim()&&!n?.length&&!a?.length)return!1;let l=f(),u=await g(_(`/api/sessions/${encodeURIComponent(o)}/inputs/${encodeURIComponent(e)}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({version:M.version,content:t,attachments:n??[],thinking:s?r??c:`off`,contextRefs:(a??[]).map(({refId:e,kind:t,sourceId:n,expectedVersion:r})=>({refId:e,kind:t,sourceId:n,expectedVersion:r}))})}),d=await u.json();if(!l())return!1;if(ae(d.payload),!u.ok)throw Error(d.error?.message??`This input changed; your draft has been preserved`);if(P.current===M){let t=d.payload?.inputs?.find(t=>t.id===e);t&&N({...M,version:t.version})}return!0},[ae,f,M,i,s,c]),ye=(0,Q.useCallback)(e=>{H.current===e&&I(null);let t=i.current,n=D.current.find(t=>t.id===e);if(!t||!n)return;let r=f();g(_(`/api/sessions/${encodeURIComponent(t)}/inputs/${encodeURIComponent(e)}?version=${n.version}`),{method:`DELETE`}).then(async e=>{let t=await e.json().catch(()=>null);r()&&ae(t?.payload)}).catch(()=>{oe(t)})},[ae,f,oe,i]),J=(0,Q.useCallback)((e,t)=>{let n=D.current.filter(e=>e.status===`queued`),r=n.findIndex(t=>t.id===e);if(r<0)return;let a=t===`up`?r-1:r+1,o=i.current,s=n[r];if(!o||!s||a<0||a>=n.length)return;let c=f();g(_(`/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()&&ae(t?.payload)}).catch(()=>{oe(o)})},[ae,f,oe,i]),be=(0,Q.useCallback)((e,t)=>{let n=i.current,r=D.current[e],a=D.current[t],o=D.current.filter(e=>e.status===`queued`),s=a?o.findIndex(e=>e.id===a.id):-1;if(!n||r?.status!==`queued`||a?.status!==`queued`||s<0)return;let c=f();g(_(`/api/sessions/${encodeURIComponent(n)}/inputs/${encodeURIComponent(r.id)}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({version:r.version,position:s})}).then(async e=>{let t=await e.json().catch(()=>null);c()&&ae(t?.payload)}).catch(()=>{oe(n)})},[ae,f,oe,i]),xe=(0,Q.useCallback)(async(e,t)=>{let n=D.current.find(t=>t.id===e);if(!n)return;let r=f();k(e);try{await me(t,{inputId:e,inputVersion:n.version})}finally{r()&&k(null)}},[f,me]),Se=(0,Q.useCallback)(e=>xe(e,`steer`),[xe]),Ce=(0,Q.useCallback)(e=>xe(e,`send`),[xe]),we=(0,Q.useCallback)(async(e,t)=>{let r=S.current,a=i.current;if(!r||!a)return;let o=f(),s=JSON.stringify([r.requestId,r.version,e,t]);w.current?.signature!==s&&(w.current={signature:s,idempotencyKey:crypto.randomUUID()});let c=w.current.idempotencyKey;y(!0),x(null);try{let s=r.schemaVersion===2?await $A(r.requestId,r.version,e,t,i.current??void 0):await g(_(`/api/clarifications/${encodeURIComponent(r.requestId)}/responses`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:e,...t,expectedVersion:r.version,idempotencyKey:c})});if(!o())return;let l=n&&e===`answer`&&s.ok?Gr(r,t):void 0,u=l?.choices.find(e=>e.id===l.choiceId)?.label;if(l&&u){let e=`clarification-choice:${r.requestId}`;Sr.getState().updateSessionMessages(a,t=>t.some(t=>t.turnId===e)?t:[...t,{role:`user`,content:[{type:`text`,text:u}],timestamp:Date.now(),turnId:e,clarificationChoice:l}])}if(S.current?.requestId!==r.requestId)return;if(!s.ok){let e=await s.json().catch(()=>({}));x(e.error?.message??s.statusText??`Clarify failed`);let t=i.current;t&&(s.status===409||s.status===410)&&se(t);return}w.current=null,m(null),x(null)}catch(e){S.current?.requestId===r.requestId&&x(e instanceof Error?e.message:String(e))}finally{y(!1)}},[f,i,n,se]);return{clarifyPrompt:p,clarifySubmitting:h,clarifySubmitError:b,clarifyPromptRef:S,pendingFollowUps:T,pendingFollowUpsRef:D,steeringFollowUpId:O,composerMode:M,control:L,controlPending:z,stopSession:he,resumeQueue:K,sendQueuedInput:Ce,beginEditTurn:ge,cancelEditor:q,restoreEditor:N,markComposerHydrated:ie,editingFollowUpId:F,addPendingFollowUp:G,beginEditFollowUp:_e,cancelEditFollowUp:q,commitEditFollowUp:ve,removePendingFollowUp:ye,movePendingFollowUp:J,reorderPendingFollowUp:be,steerPendingFollowUp:Se,submitClarifyAnswer:(0,Q.useCallback)(e=>we(`answer`,e),[we]),letAgentDecideClarification:(0,Q.useCallback)(()=>we(`agent_decide`),[we]),cancelClarification:(0,Q.useCallback)(()=>we(`cancel`),[we]),clearVisibleClarify:ce,dismissClarify:ue,dismissClarifyForSession:le,clearPendingFollowUps:de,dismissClarifyAndClearPending:fe,makeOnClarifyRequest:pe}}function aj(e){let t=(0,Z.c)(51),{navigate:n,conversationIdRef:r,conversationId:i,isNewRoute:a,locationState:o,locationSearch:s,personal:c}=e,l=c!==void 0&&c,u=v(lj),d;t[0]===u?d=t[1]:(d=u?[`gateway-chat-agents`,u]:null,t[0]=u,t[1]=d);let f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f={revalidateOnFocus:!1},t[2]=f):f=t[2];let{data:p,mutate:m}=bi(d,Mi,f),{data:h}=qp(i),g=h?.agentId??``,_,y;t[3]===m?(_=t[4],y=t[5]):(_=()=>{let e=e=>{ji(e.detail)||m()};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},y=[m],t[3]=m,t[4]=_,t[5]=y),(0,Q.useEffect)(_,y);let[b,x]=(0,Q.useState)(cj),S=(0,Q.useRef)(p??null),C;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(C=di().selectedAgentId??null,t[6]=C):C=t[6];let w=(0,Q.useRef)(C),T,E;t[7]===p?(T=t[8],E=t[9]):(T=()=>{S.current=p??null},E=[p],t[7]=p,t[8]=T,t[9]=E),(0,Q.useEffect)(T,E);let D,O;t[10]===b?(D=t[11],O=t[12]):(D=()=>{w.current=b},O=[b],t[10]=b,t[11]=D,t[12]=O),(0,Q.useEffect)(D,O);let k,A;t[13]===p?(k=t[14],A=t[15]):(k=()=>{if(!p)return;let e=new Set(p.items.map(sj));x(t=>t==null||t===``||!e.has(t)?p.defaultId:t)},A=[p],t[13]=p,t[14]=k,t[15]=A),(0,Q.useEffect)(k,A);let j;t[16]!==r||t[17]!==g?(j=()=>{if(r.current&&g)return g;let e=S.current,t=(w.current??``).trim().toLowerCase();if(!e)return t||void 0;let n=new Set(e.items.map(oj));return t&&n.has(t)?t:e.defaultId},t[16]=r,t[17]=g,t[18]=j):j=t[18];let M=j,N;t[19]!==r||t[20]!==g||t[21]!==h?.projectId||t[22]!==a||t[23]!==s||t[24]!==o||t[25]!==n?(N=e=>{let t=e.trim().toLowerCase(),i=r.current?g||w.current:null;w.current=t,x(t),ri(t),i!==t&&n(a?`/chat/new${s}`:uo(h?.projectId),{replace:!1,state:{...a&&o&&typeof o==`object`?o:{},agentId:t,forceNewChat:!0}})},t[19]=r,t[20]=g,t[21]=h?.projectId,t[22]=a,t[23]=s,t[24]=o,t[25]=n,t[26]=N):N=t[26],h?.projectId;let P=N,F,I;t[27]===P?(F=t[28],I=t[29]):(F=()=>{let e=e=>{let t=e.detail?.agentId;typeof t!=`string`||!t.trim()||P(t)};return window.addEventListener(`xopc-set-chat-agent`,e),()=>window.removeEventListener(`xopc-set-chat-agent`,e)},I=[P],t[27]=P,t[28]=F,t[29]=I),(0,Q.useEffect)(F,I);let L,R;t[30]!==i||t[31]!==g||t[32]!==l?(L=()=>{if(!i||l)return;let e=g;!e||w.current===e||(w.current=e,x(e),ri(e))},R=[g,i,l],t[30]=i,t[31]=g,t[32]=l,t[33]=L,t[34]=R):(L=t[33],R=t[34]),(0,Q.useLayoutEffect)(L,R);let z,B;t[35]!==i||t[36]!==h?(z=()=>{!i||!h||li(h.projectId)},B=[h,i],t[35]=i,t[36]=h,t[37]=z,t[38]=B):(z=t[37],B=t[38]),(0,Q.useLayoutEffect)(z,B);let V,H;t[39]!==a||t[40]!==o?(V=()=>{if(!a)return;let e=o,t=typeof e?.agentId==`string`?e.agentId.trim().toLowerCase():``;t&&(w.current=t,x(t),ri(t))},H=[a,o],t[39]=a,t[40]=o,t[41]=V,t[42]=H):(V=t[41],H=t[42]),(0,Q.useLayoutEffect)(V,H);let U=g||b||p?.defaultId||`main`,W=(p?.items.length??0)>1,ee=h?.projectId??null,te;return t[43]!==p||t[44]!==U||t[45]!==P||t[46]!==M||t[47]!==W||t[48]!==ee||t[49]!==u?(te={token:u,chatAgentsData:p,resolveAgentIdForPost:M,onChatAgentChange:P,displayAgentId:U,showChatAgentSelector:W,currentSessionProjectId:ee},t[43]=p,t[44]=U,t[45]=P,t[46]=M,t[47]=W,t[48]=ee,t[49]=u,t[50]=te):te=t[50],te}function oj(e){return e.id}function sj(e){return e.id}function cj(){return di().selectedAgentId??null}function lj(e){return e.conversationId}async function uj(e){let t=await e.sessionMgr.createSession(e);return{kind:`create`,conversationId:t.key,session:t}}var dj=new Map,fj=0;function pj(e){let t=v.getState(),n=ii(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=dj.get(r);if(i)return i.target.opts=e,i.target.generation=++fj,i.promise;let a={opts:e,generation:++fj},o=e=>{if(a.generation!==fj)return;let t=a.opts;!t.routeConversationId&&Xi.getState().scope===`new`&&Xi.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 uj({sessionMgr:e.sessionMgr,agentId:t?.trim()||`main`,projectId:e.projectId,currentConversationId:e.currentConversationId,forceNew:e.forceNew,temporary:e.temporary,...new URLSearchParams(e.search).get(`agentSetup`)===`1`?{agentSetup:!0,agentSetupLanguage:y.getState().language===`zh`?`zh-CN`:`en`}:{},initialAgentConfig:e.initialAgentConfig,executionMode:e.executionMode});return o(n),n})().finally(()=>{dj.delete(r)});return dj.set(r,{promise:s,target:a}),s}var mj={current:null},hj={current:null};function gj(e){return!!(e&&typeof e==`object`&&e.forceNewChat===!0)}function _j(e){let t=f(),{conversationId:n}=m(),r=!e&&t.pathname.endsWith(`/new`),i=r&&gj(t.state),a=e??GA(r,n),o=WA(r,a),s=BA(o),c=r?null:a??null,l=(0,Q.useRef)(o);return l.current=o,mj.current=c,!r&&a&&(hj.current=a),(0,Q.useLayoutEffect)(()=>{Sr.getState().focusedConversationId!==c&&Sr.getState().setFocusedConversationId(c)},[c]),{isNewRoute:r,forceNewChat:i,decodedKey:a,routedConversationId:o,viewConversationId:s,routedFocusedConversationId:c,routeConversationIdRef:l,locationKey:t.key,locationSearch:t.search,locationState:t.state}}var vj={get current(){return hj.current}},yj={get current(){return mj.current},set current(e){mj.current=e,Sr.getState().setFocusedConversationId(e)}};function bj(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:m,adoptEmptySession:h,applyAgentConfig:g,patchInitUi:_}=e,y=(0,Q.useRef)(0),b=v(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:m,adoptEmptySession:h,applyAgentConfig:g,patchInitUi:_});return E.current={sessionMgrRef:l,resolveAgentIdForPost:u,navigateToSession:d,loadSessionById:f,tryResumeAgentRun:p,restoreLiveCacheIfNeeded:m,adoptEmptySession:h,applyAgentConfig:g,patchInitUi:_},(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=di(),i=n.resolveAgentIdForPost(),s=oi({origin:`web-route`,project:lo(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 xn(s.projectId):null;if(!a())return;!e.requestedAgentId&&c?.defaultAgentId&&(s.agentId=c.defaultAgentId);let l=ui(r,s.agentId),u=(t,r,i)=>pj({sessionMgr:n.sessionMgrRef.current,agentId:s.agentId,currentConversationId:vj.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:fo(e.newRouteLocationSearch),onOpened:e=>{a()&&(i?.(e),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,n)=>a()?u(e,t,n):Promise.reject(Error(`New chat request changed`))});return}await u()},c=(e,t)=>{if(!a())return Promise.resolve();n.restoreLiveCacheIfNeeded(e);let r=Vr(e)?.messages??t??tr(e);return n.tryResumeAgentRun(e,r)},l=e=>a()?Vr(e)?.historyStatus===`ready`?(o(e),c(e,tr(e))):n.loadSessionById(e,0).then(t=>{if(a())return c(e,t??tr(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=Vr(t.key)?.messages??e??tr(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 pj({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 xj(e){let t=v(e=>e.conversationId),n=v(e=>e.baseUrl),[r,i]=(0,Q.useState)(null),{data:a,error:o}=bi(e?[`prepared-session-model`,n,t,e.create]:null,async()=>{let t=ui(di(),e.agentId),[n,r]=await Promise.all([Ki(),t?.modelRef??Ji(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?fi(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,n,r)=>{let i=d.current;if(i.preparation!==e||!i.ready||!i.selection)throw Error(`Model configuration is not ready`);let a=i.selection,o=await e.create(t,a,r);return i.explicitlySelected&&si(e.agentId,{modelRef:a.model,thinkingLevel:a.thinkingLevel}),o}},[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=ui(di(),e.agentId)?.thinkingByModel?.[t],c=r.thinking?fi(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)}}var Sj=class{tails=new Map;run(e,t){let n=this.tails.get(e),r=n?n.then(t,t):Promise.resolve().then(t),i=r.finally(()=>{this.tails.get(e)===i&&this.tails.delete(e)});return this.tails.set(e,i),i.catch(()=>{}),r}};async function Cj(e){let t=e.trim();if(!t)return!1;try{return!!(await Ki()).find(e=>e.id===t)?.reasoning}catch{return!1}}function wj(e){let{sessionMgrRef:t,routeConversationIdRef:n,sendingRef:r,streamingRef:a,loadingSessionRef:o,messagesLenRef:s,thinkingSupportGenRef:c,navigateToSession:l,resolveAgentIdForPost:u,detachForNewConversation:d,conversationId:f,sessionAgentId:p,currentProjectId:m,taskId:h,hasMore:g}=e,_=()=>Sr.getState(),v=(0,Q.useRef)(new Sj),y=(0,Q.useRef)(0),b=(0,Q.useRef)(null),x=(0,Q.useRef)(0),S=(0,Q.useCallback)(e=>{let t=_().focusedConversationId;if(!e.trim())return++c.current===c.current&&t&&_().patchSessionMeta(t,{modelSupportsThinking:!1}),Promise.resolve();let n=++c.current;return Cj(e).then(t=>{if(n!==c.current)return;let r=_().focusedConversationId;r&&_().sessions[r]?.model===e&&_().patchSessionMeta(r,{modelSupportsThinking:t})})},[c]),C=(0,Q.useCallback)(async e=>{try{let n=await t.current.loadSessionAgentConfig(e);zr(e,n),S(n.model)}catch{}},[t,S]),w=(0,Q.useCallback)(()=>{let e=_().focusedConversationId;if(!e||(_().sessions[e]?.name)?.trim())return;let n=++x.current,r=[700,900,900,1e3,1e3],i=a=>{a>=5||n===x.current&&_().focusedConversationId===e&&(_().sessions[e]?.name?.trim()||window.setTimeout(()=>{n===x.current&&_().focusedConversationId===e&&(_().sessions[e]?.name?.trim()||t.current.fetchSessionName(e).then(t=>{if(n===x.current){if(t){_().patchSessionMeta(e,{name:t});return}i(a+1)}}).catch(()=>{i(a+1)}))},r[a]??900))};i(0)},[t]),T=(0,Q.useCallback)(e=>UA({chatId:e,routeConversationId:n.current}),[n]),E=(0,Q.useCallback)((e,t,n)=>{let r=_().sessions[e];if(n&&r?.messages!==n.messages&&!Fn(r))return!1;let i=t.hasMore&&Nn(r?.messages??[],t.messages)>0;return _().mergeCommittedFromServer(e,t.messages,t.hasMore,n?.completedRunId,n?.recoveringRunId),t.name!==void 0&&_().patchSessionMeta(e,{name:t.name||null}),T(e)&&(i||(b.current=t.nextBeforeCursor??null)),!0},[T]),D=(0,Q.useCallback)(async(e,r=0,a)=>{let s=i(`session_load`),c=async(e,r,i)=>{let a=r===0&&!i;y.current++,o.current=!0,s(`request_started`);let d=a&&Jn(_().sessions[e]?.historyStatus);d&&_().setSessionHistoryStatus(e,`loading`);let f=a?Promise.resolve().then(()=>t.current.loadSessionAgentConfig(e)).then(e=>(s(`config_received`),{config:e}),e=>({error:e})):void 0;try{let n={messages:_().sessions[e]?.messages},{messages:o,hasMore:c,name:l,nextBeforeCursor:u}=await t.current.loadSession(e,r,i,h,n.messages);if(s(`history_received`),a){if(!E(e,{messages:o,hasMore:c,name:l,nextBeforeCursor:u},n))return _().sessions[e]?.messages;if(!T(e))return o;s(`history_committed`);let t=await f;if(`error`in t)throw t.error;let r=t.config;return T(e)?(zr(e,r),S(r.model),o):o}if(!T(e))return;b.current=u??null,_().prependHistoryMessages(e,o,c);return}catch(a){if(s(`failed`),n.current&&!T(e))return;if(r===0&&!i){b.current=null;let r=a instanceof Error?a.message:`Failed to load session`;_().setShellError(/^HTTP 404\b/.test(r)?JSON.stringify(Bi(r)):`Failed to load session`);let i=BA(n.current);if(i&&i===e)return;let o=await t.current.loadSessions().catch(()=>[]),s=o.filter(e=>(e.messageCount??0)>0)[0]??o[0];if(s)return l(s.key,!0),await c(s.key,0,null);{b.current=null;let e=u();pj({sessionMgr:t.current,agentId:e,currentConversationId:null,routeConversationId:null,navigateToSession:l,replaceNavigate:!0,onOpened:e=>{_().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:null}),C(e)}})}}return}finally{y.current--,o.current=y.current>0,s(`settled`),d&&_().sessions[e]?.historyStatus===`loading`&&_().setSessionHistoryStatus(e,`ready`)}};return v.current.run(e,()=>c(e,r,a))},[n,T,r,a,o,l,S,u,t,h,E]),O=(0,Q.useCallback)(async()=>{let e=_().focusedConversationId;if(!(!e||_().loadingMore||!g)){_().setLoadingMore(!0);try{await D(e,s.current,b.current)}finally{_().setLoadingMore(!1)}}},[g,D,s]),k=(0,Q.useCallback)(async(e,n)=>{if(!f)throw Error(`No active session`);let r=_().sessions[f];if(r?.modelConfigSaving)throw Error(`Model configuration is being saved`);if(!(r?.model===e&&n!==void 0&&r.thinkingLevel===n)){_().patchSessionMeta(f,{modelConfigSaving:!0});try{if(_().setShellError(null),n===void 0){let t=(await Ki()).find(t=>t.id===e);if(t?.thinking){let i=ui(di(),p)?.thinkingByModel?.[e];n=fi(t.thinking,r?.thinkingLevel,i)}}let i=h?await t.current.patchTaskConversationModel(h,e,n,r?.configVersion):await t.current.patchSessionAgentConfig(f,{model:e,thinkingLevel:n,configVersion:r?.configVersion});zr(f,i),si(p,{modelRef:i.model,thinkingLevel:i.thinkingLevel}),i.model!==r?.model&&S(i.model)}catch(e){let n=e instanceof Error?e.message:`Failed to update model configuration`;_().setShellError(n);let r=await t.current.loadSessionAgentConfig(f).catch(()=>null);throw r&&zr(f,r),e}finally{_().patchSessionMeta(f,{modelConfigSaving:!1})}}},[f,p,h,t,S]);return{refreshModelThinkingSupport:S,pollSessionNameAfterTurn:w,applyLoadedSessionSnapshot:E,loadSessionById:D,loadMoreMessages:O,onSessionModelChange:k,onSessionThinkingLevelChange:(0,Q.useCallback)(async e=>{let t=f?_().sessions[f]?.model:void 0;t&&await k(t,e)},[f,k]),onSessionWorkingDirectoryChange:(0,Q.useCallback)(async e=>{let n=e.trim();if(!(!f||!n))try{_().setShellError(null),await t.current.patchSessionAgentConfig(f,{workingDirectory:n}),await C(f)}catch(e){throw _().setShellError(e instanceof Error?e.message:`Failed to update working directory`),e}},[C,f,t]),createNewSession:(0,Q.useCallback)(async e=>{_().setShellError(null);let n=u(),r=ui(di(),n??`main`);await pj({sessionMgr:t.current,agentId:n,currentConversationId:f,routeConversationId:f,forceNew:e?.forceNew,temporary:e?.temporary,executionMode:e?.executionMode,projectId:e?.projectId===void 0?m:e.projectId,initialAgentConfig:r?{model:r.modelRef,...r.thinkingLevel?{thinkingLevel:r.thinkingLevel}:{}}:void 0,navigateToSession:l,onOpened:e=>{d(),b.current=null,_().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:null}),C(e)}})},[d,l,u,m,f,t,C]),resetCurrentSession:(0,Q.useCallback)(async()=>{if(f){_().setShellError(null);try{await t.current.resetSession(f),d(),b.current=null,_().setCommittedSnapshot(f,{messages:[],hasMore:!1,name:null}),C(f)}catch(e){_().setShellError(e instanceof Error?e.message:`Failed to reset session`)}}},[C,f,d,t])}}function Tj(e){return new Promise(t=>{Promise.resolve().then(()=>e(()=>t(!0))).then(()=>t(!1),()=>t(!1))})}function Ej(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 Dj(e){return e!==`suspended`}function Oj(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=()=>Sr.getState(),h=()=>{m().sessions[t]?.progress?.stage.startsWith(`model_`)&&m().setSessionProgress(t,null)},g=e=>{let n=e?.runId,r={messages:m().sessions[t]?.messages,completedRunId:e?.terminal?n:void 0,recoveringRunId:e?.terminal?void 0:n};return l.current.loadSession(t,0,void 0,void 0,r.messages).then(i=>{!p()||e?.signal.aborted||u(t,i,r)===!1||n&&m().sessions[t]?.messages.some(e=>e.role===`assistant`&&e.turnId===n&&e.content.some(e=>e.type===`text`&&e.text.trim()&&e.text.trim()!==`NO_REPLY`))&&vr(n,`history`)}).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)xr(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&&Un.setResumeRunId(t,null),m().setSessionFlags(t,{sending:!1,streaming:!1}),m().setSessionProgress(t,null),Dj(e)&&f.dismissClarifyForSession(t),g()},w={onTextSurface:e=>{r(),m().mutateSessionStreaming(t,t=>{t.textSurface=e})},onReplayGap:g,onUserMessage:e=>{if(e.clientMessageId)b();else if(!n(t))return;m().appendUserMessageIfMissing(t,e)},onStreamStart:(e,n,i)=>{Vp(t),r(),i&&m().updateSessionMessages(t,t=>yr([...t,{role:`task`,content:[],taskTrigger:i,turnId:e,timestamp:Date.now()}])),m().updateSessionMessages(t,t=>sr(t,e)),m().mutateSessionStreaming(t,t=>{t.turnId=e,n&&(t.startsNewBubble=!0)}),m().setSessionFlags(t,{streaming:!0})},onToken:(e,a,o)=>{h(),r(),m().mutateSessionStreaming(t,t=>{Kn(t.content,e,a,{offset:o,reconcileHydratedSegment:i})}),n(t)&&m().setSessionFlags(t,{streaming:!0})},onAssistantMessageEnd:(e,n,i)=>{r(),m().mutateSessionStreaming(t,t=>{rr(t.content,e,n),i&&(t.usage=i)})},onThinking:(e,n,i)=>{h(),r(),m().mutateSessionStreaming(t,t=>{!n&&e===``?Wn(t.content):qn(t.content,e,n,i)})},onThinkingEnd:e=>{r(),m().mutateSessionStreaming(t,t=>{ir(t.content,e)})},onToolStart:(e,n,i,a,o,s)=>{h(),r(),m().mutateSessionStreaming(t,t=>{Xn(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=>{Hn(t.content,e,n,i,a,o,s,c)})},onToolUpdate:(e,n,i)=>{r(),m().mutateSessionStreaming(t,t=>{jr(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=>{jn(t.content,e)}),n(t)&&m().setSessionFlags(t,{streaming:!0})},onReviewStart:e=>{r(),m().mutateSessionStreaming(t,t=>{Bn(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=>{Vn(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=C(y.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=>zr(t,e)).catch(()=>{}).finally(()=>m().patchSessionMeta(t,{modelConfigSaving:!1}))},onResult:({status:e})=>{b();let r=n(t);if(Un.takeUserAborted(t)||e===`cancelled`){Wp(t),r?d(t,e):S(e);return}if(e===`error`){if(Up(t,!r),!r){S(e);return}d(t,e),g();return}if(e===`suspended`?Gp(t):Hp(t,!r),!r){S(e);return}d(t,e)},onError:e=>{b();let r=n(t);if(Up(t,!r),!r){S(`error`);return}d(t,`error`),s&&Un.setResumeRunId(t,null),m().setSessionFlags(t,{sending:!1,streaming:!1}),m().setSessionProgress(t,null),c(e),f.dismissClarifyForSession(t)}};return Object.fromEntries(Object.entries(w).map(([e,t])=>[e,(...e)=>{if(p())return Reflect.apply(t,void 0,e)}]))}function kj(e){return Vr(e)?.streamingMsg??null}function Aj(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:m,pollSessionNameAfterTurn:h}=e,g=()=>Sr.getState(),_=e=>g().setShellError(e),y=()=>g().setShellError(null),b=(0,Q.useCallback)((e,t)=>{if(!u(e))return;let n=kj(e),r=null;if(n){let e=Gn(n,Date.now());e.runStatus=t,Qn(e.content,t===`success`),ir(e.content),t!==`suspended`&&Mn(e.content,t===`success`),Kr(e.content),e.completedAt=t&&t!==`suspended`?Date.now():void 0,r=zn(e)}r&&ar(r)?g().finalizeStreamingTurn(e,r):g().clearStreamingState(e),o.current=!1,s.current=!1,Un.resetRunTracking(e),(!t||Dj(t))&&d.dismissClarify(),h(),window.setTimeout(()=>{!u(e)||o.current||s.current||p(e,0)},400)},[o,s,d.dismissClarify,d.pendingFollowUpsRef,h,p,u]),x=(0,Q.useCallback)(async(e,t)=>{if(!u(e)||Un.isSubmittingFor(e))return;let r=v.getState().conversationId,i=()=>v.getState().conversationId===r,a=Un.getGeneration(e),l=g().sessions[e]?.streamingMsg,m=g().sessions[e]?.messages.findLast(e=>e.role===`user`)?.clientSubmissionId,h=await fr(e);if(!i()||Un.getGeneration(e)!==a||Un.isSubmittingFor(e))return;if(!h){let t=g().sessions[e]?.streamingMsg;if(t?.pendingResponseStatus||t&&t!==l||Un.isStreamingFor(e))return;let n=Un.getResumeRunId(e);n&&Un.reconcileInactive(e,n),g().clearStreamingState(e,{preservePendingResponse:!0}),Wp(e);return}let y=()=>{let t=g().sessions[e]?.streamingMsg,n=g().sessions[e]?.messages.findLast(e=>e.role===`user`)?.clientSubmissionId;return!i()||Un.getGeneration(e)!==a||Un.isSubmittingFor(e)||!!(n&&n!==m)||!!(Ar(e)&&Ar(e)!==h)||!!(t?.turnId&&t.turnId!==h&&t.turnId!==l?.turnId)||!!(t?.pendingResponseStatus&&t!==l)};if(y()||Un.isTrackingRun(e,h))return;let x=()=>{let t=g().sessions[e]?.streamingMsg;!t?.turnId||t.turnId===h||t.turnId!==l?.turnId||(ar(t)?g().finalizeStreamingTurn(e,zn(t)):g().clearStreamingState(e))},S=t??tr(e),C=Vr(e)?.hasMore??!1;try{let t=await c.current.loadSession(e,0,void 0,n,g().sessions[e]?.messages);if(y()||Un.isTrackingRun(e,h))return;x(),g().mergeCommittedFromServer(e,t.messages,t.hasMore),S=t.messages,C=t.hasMore}catch{}if(y()||Un.isTrackingRun(e,h))return;x(),a=Un.advanceGeneration(e),Un.setUserAborted(e,!1),Un.setResumeRunId(e,h),o.current=!0,s.current=!0,g().seedSessionIfEmpty(e,S,!0,!0,C),g().setSessionFlags(e,{sending:!0,streaming:!0}),g().setSessionProgress(e,null),Vp(e);let w=!1,T=l?.turnId!==h||!ar(l),E=T?S.findLast(e=>e.turnId===h&&e.clientMessageId&&!e.pendingSteer)?.clientMessageId:void 0;if(E){let t=qA(S,h);g().applyHydratedTail(e,t?.messagesWithoutTail??S,t?.tail??null),t||g().mutateSessionStreaming(e,e=>{e.turnId=h}),w=!0}let D=()=>{if(w||!u(e))return;w=!0;let t=qA(tr(e),h);t&&g().applyHydratedTail(e,t.messagesWithoutTail,zn(t.tail))},O=()=>{g().clearStreamingState(e),Un.getResumeRunId(e)===h&&Un.setResumeRunId(e,null),u(e)&&(o.current=!1,s.current=!1)};try{let t=Oj({chatId:e,shouldApplyStreamUpdate:u,isCurrentRun:()=>i()&&Un.getGeneration(e)===a,beforeAssistantDelta:D,reconcileHydratedAssistantText:!0,setStreamingOnStreamStart:!1,clearResumeRunIdOnBackgroundTerminal:!0,clearResumeRunIdOnVisibleError:!0,setError:_,sessionMgrRef:c,applyLoadedSessionSnapshot:f,finalizeMessage:b,fq:d}),n=await Un.senderFor(e).resume(h,e,t,{replayFromStart:T,...E?{afterSteerId:E}:{}});if(!i()||Un.getGeneration(e)!==a)return;n||(Wp(e),O(),await p(e,0).catch(()=>void 0))}catch(t){if(!i()||Un.getGeneration(e)!==a)return;t.name!==`AbortError`&&console.error(`[chat] resume failed:`,t),Wp(e),O()}finally{Un.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&&!Un.isStreamingFor(c))return!1;let l=e.trim();if(n&&ds(l))return _(`A task has one continuous conversation.`),!1;if(Zo(l)&&!t?.length){await m();return}return await d.addPendingFollowUp(e,t,i,void 0,!0),!0},[o,s,a,d.addPendingFollowUp,m,n]),C=(0,Q.useCallback)(async(e,a,l,h,x,S,C,w,T)=>{if(!t||!u(t)||!e.trim()&&!a?.length&&!h?.length||o.current||s.current||Un.isStreamingFor(t))return!1;let E=e.trim();if(n&&ds(E))return _(`A task has one continuous conversation.`),!1;if(Zo(E)&&!a?.length){await m();return}let D=i?l??r:`off`,O=t,k=Un.advanceGeneration(O),A=v.getState().conversationId,j=()=>v.getState().conversationId===A&&Un.getGeneration(O)===k,M=crypto.randomUUID(),N=`assistant-stream:${O}:${M}`,P=tr(O),F=w?P.filter(e=>e.clientSubmissionId!==w):P,I=x?F.findIndex(e=>Nr(e)===x):-1;if(x&&I<0)return!1;Un.setUserAborted(O,!1),o.current=!0,s.current=!1,y(),d.dismissClarify();let L=I>=0?F.slice(0,I):F,R=Hr(e)??void 0,z=new Map(h?.flatMap(e=>e.refId?[[e.refId,e.title]]:[])??[]),B=R?nr(R,e=>z.get(e)):e,V=[...L,{role:`user`,content:B?[{type:`text`,text:B}]:[],userTurnDocument:R,deliveryStatus:`sending`,clientSubmissionId:M,pendingAppContext:S===void 0?void 0:structuredClone(S),attachments:a,contextRefs:h?.map(e=>({refId:e.refId,kind:e.kind,sourceId:e.sourceId,version:e.expectedVersion,title:e.title,fileKind:e.fileKind})),timestamp:Date.now()}];C?.(M);let H=Vr(O);if(g().initSessionSnapshot(O,{...H??{...or(),historyStatus:`ready`,hasMore:!1,streamingMsg:null,progress:null,taskPlan:null,sending:!1,streaming:!1},messages:V,hasMore:H?.hasMore??!1,streamingMsg:{role:`assistant`,content:[],timestamp:Date.now(),renderKey:N,pendingResponseStatus:`sending`},progress:null,sending:!0,streaming:!1}),Vp(O),!H?.name?.trim()&&B.trim()){let e=Ip(B.trim());e&&(g().patchSessionMeta(O,{name:e}),Lp(O,e))}let U=e=>{g().updateSessionMessages(O,t=>Ej(t,M,e))};return Tj(async t=>{let r=!1;try{let i=Oj({chatId:O,shouldApplyStreamUpdate:u,isCurrentRun:j,beforeAssistantDelta:()=>{},reconcileHydratedAssistantText:!1,setStreamingOnStreamStart:!0,clearResumeRunIdOnBackgroundTerminal:!1,clearResumeRunIdOnVisibleError:!1,setError:_,sessionMgrRef:c,applyLoadedSessionSnapshot:f,finalizeMessage:b,fq:d});i.onInputAccepted=()=>{r=!0,U(`accepted`),j()&&g().setPendingResponseStatus(O,`waiting`),t()},await Un.senderFor(O).send(e,O,a,D,i,n,x,h,S,T)}catch(e){if(!j())return;if(e.name!==`AbortError`)g().clearStreamingState(O),Wp(O),u(O)&&_(e instanceof Error?e.message:String(e)),x&&p(O,0);else{Wp(O);let e=Vr(O)?.streamingMsg;e?.renderKey===N&&e.pendingResponseStatus&&g().clearStreamingState(O)}}finally{j()&&(r||U(`failed`),u(O)&&(o.current=!1,s.current=!1),g().setSessionFlags(O,{sending:!1}),Un.releaseIdleSender(O))}})},[t,r,i,o,s,u,c,f,b,d.dismissClarify,m,n,p]),w=(0,Q.useCallback)((e,t,n,r,i,a)=>C(t,n,r,i,e,void 0,void 0,void 0,a),[C]),T=(0,Q.useCallback)((e,t)=>{let n=a.current;if(!n||wr(n).phase!==`idle`||Un.getGeneration(n)!==e)return;let r=Un.getResumeRunId(n),i=g().sessions[n]?.streamingMsg?.turnId;r&&r!==t||i&&i!==t||(d.dismissClarify(),Un.abort(n,!1),Wp(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=Un.getGeneration(e),n=Un.getResumeRunId(e)??g().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=tr(t),r=n[e];if(!r||!Lr(r.role)||r.pendingSteer)return;if(r.deliveryStatus===`failed`){let r=[...n];r.splice(e,1),g().updateSessionMessages(t,()=>r);return}let i=br(n,e);if(i===null)return;let l=Dr(n,e),u=[...n];u.splice(e,l),g().updateSessionMessages(t,()=>u);let d=r.clientMessageId?{steerId:r.clientMessageId}:{userRoundIndex:i};c.current.deleteMessages(t,d).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=tr(t),r=n[e];if(!r||!Lr(r.role)||r.pendingSteer)return;for(let t=e+1;t<n.length;t++){let e=n[t];if(e&&Lr(e.role))return}let i=r.userTurnDocument?Rn(r.userTurnDocument):Zn(r.content),c=An(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,f=Nr(r);!d&&!f||l.current(i,c,void 0,u,f,r.pendingAppContext,void 0,d).catch(()=>{p(t,0)})},[a,o,s,p,l])}}function jj(e){let t=(0,Z.c)(15),{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)(Fj,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]!==n||t[7]!==a?(d=()=>{let e=e=>{let t=e.detail;!n||t?.conversationId!==n||(t.enabled===!1&&Sr.getState().updateSessionMessages(n,Nj),a(n,0))};window.addEventListener(`session-agent-reaction`,e),window.addEventListener(`session-agent-reaction-preference`,e);let t=()=>{n&&a(n,0)};return window.addEventListener(`gateway-realtime-connected`,t),()=>{window.removeEventListener(`session-agent-reaction`,e),window.removeEventListener(`session-agent-reaction-preference`,e),window.removeEventListener(`gateway-realtime-connected`,t)}},f=[n,a],t[6]=n,t[7]=a,t[8]=d,t[9]=f):(d=t[8],f=t[9]),(0,Q.useEffect)(d,f);let p,m;t[10]!==s||t[11]!==r||t[12]!==i?(p=()=>{let e=e=>{if(ji(e.detail))return;let t=r.current;t&&i.current.loadSessionAgentConfig(t).then(e=>{s(t,e)}).catch(Mj)};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},m=[r,i,s],t[10]=s,t[11]=r,t[12]=i,t[13]=p,t[14]=m):(p=t[13],m=t[14]),(0,Q.useEffect)(p,m)}function Mj(){}function Nj(e){return e.map(Pj)}function Pj(e){return e.agentReaction?{...e,agentReaction:void 0}:e}function Fj(){let e=Ij;return window.addEventListener(`session-updated`,e),()=>window.removeEventListener(`session-updated`,e)}function Ij(e){let t=e.detail;!t?.key||t.name===void 0||Sr.getState().patchSessionMeta(t.key,{name:t.name||null})}function Lj(e){let t=p(),{isNewRoute:n,forceNewChat:r,decodedKey:i,viewConversationId:a,routedFocusedConversationId:o,routeConversationIdRef:s,locationKey:c,locationSearch:l,locationState:u}=_j(e?.fixedConversationId),d=(0,Q.useRef)(new Ir),f=(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=Sr(e=>e.initLoading),w=Sr(e=>e.loadingMore),T=Sr(e=>e.shellError),E=a,D=ig(E),O=E?Fn(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=YA(D,bi(qi,Ki,{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||d.current.loadSessionAgentConfig(E).then(e=>zr(E,e)).catch(()=>void 0)},[E,A,k]),(0,Q.useEffect)(()=>{let e=e=>{let t=e.detail.conversationId;d.current.loadSessionAgentConfig(t).then(e=>zr(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:ee,resolveAgentIdForPost:te,onChatAgentChange:ne,displayAgentId:re,showChatAgentSelector:ie,currentSessionProjectId:ae}=aj({navigate:t,personal:e?.personal,conversationIdRef:yj,conversationId:S,isNewRoute:n,locationState:u,locationSearch:l}),oe=i!==void 0&&S!==i,se=!!(W&&i&&!T&&D?.historyStatus!==`ready`&&!oe),ce=(0,Q.useMemo)(()=>C&&(S==null||i===void 0),[C,S,i]),le=ZA({isNewRoute:n,sessionRoutePending:oe,showSessionLoading:ce,sessionContentLoading:se,messageCount:D?.messages.length??0}),ue=n&&u?.fromAgentEditor===!0,de=(0,Q.useCallback)((e,n=!1,r)=>{let i=r??``;t({pathname:`/chat/${encodeURIComponent(e)}`,search:i},{replace:n,...ue?{state:{fromAgentEditor:!0}}:{}})},[ue,t]),fe=(0,Q.useCallback)(e=>VA({streamConversationId:e,routeConversationId:s.current}),[s]),pe=(0,Q.useCallback)(()=>{XA({sendingRef:m,streamingRef:h})},[]),G=ij({conversationId:S,personal:e?.personal,decodedKey:i,conversationIdRef:yj,sendingRef:m,streamingRef:h,modelSupportsThinking:B,thinkingLevel:R,shouldApplyStreamUpdate:fe}),me=(0,Q.useCallback)(()=>{G.clearVisibleClarify();let e=yj.current;e&&Un.resetRunTracking(e),JA(pe)},[G.clearVisibleClarify,yj,pe]),{refreshModelThinkingSupport:he,pollSessionNameAfterTurn:K,applyLoadedSessionSnapshot:ge,loadSessionById:_e,loadMoreMessages:q,onSessionModelChange:ve,onSessionThinkingLevelChange:ye,onSessionWorkingDirectoryChange:J,createNewSession:be,resetCurrentSession:xe}=wj({sessionMgrRef:d,routeConversationIdRef:s,sendingRef:m,streamingRef:h,loadingSessionRef:f,messagesLenRef:x,thinkingSupportGenRef:g,navigateToSession:de,resolveAgentIdForPost:te,detachForNewConversation:me,conversationId:S,sessionAgentId:re,currentProjectId:ae,hasMore:N,taskId:e?.taskId}),Se=(0,Q.useCallback)(e=>{if(!HA({cacheConversationId:e,routeConversationId:s.current}))return!1;let t=Vr(e);return!t||!Fn(t)&&!pr(e)&&!Un.isStreamingFor(e)?!1:(m.current=t.sending,h.current=t.streaming,!0)},[s]),{tryResumeAgentRun:Ce,sendMessage:we,replaceLatestUserTurn:Te,interruptAndSend:Ee,abort:De,settleStoppedRun:Oe,deleteMessageRound:ke,retryUserMessageRound:Ae}=Aj({conversationId:S,taskId:e?.taskId,thinkingLevel:R,modelSupportsThinking:B,conversationIdRef:yj,sendingRef:m,streamingRef:h,sessionMgrRef:d,sendMessageRef:b,shouldApplyStreamUpdate:fe,fq:G,applyLoadedSessionSnapshot:ge,loadSessionById:_e,resetCurrentSession:xe,pollSessionNameAfterTurn:K});(0,Q.useEffect)(()=>{n&&me()},[n,me]);let je=(0,Q.useMemo)(()=>KA({viewConversationId:a,conversationId:E,messages:D?.messages??[],streamingMsg:O?D?.streamingMsg??null:null}),[a,E,D?.messages,D?.streamingMsg,O]),Me=(0,Q.useCallback)((e,t)=>{Sr.getState().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:t}),pe()},[pe]),Ne=(0,Q.useCallback)((e,t)=>{zr(e,t),he(t.model)},[he]),Pe=(0,Q.useCallback)(e=>{let t=Sr.getState();e.loading!==void 0&&t.setInitLoading(e.loading),e.error!==void 0&&t.setShellError(e.error)},[]),Fe=(0,Q.useCallback)(async t=>{try{let n=await d.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}Fe(S)},[S,n,Fe]),jj({conversationId:S,conversationIdRef:yj,sendingRef:m,streamingRef:h,sessionMgrRef:d,loadSessionById:_e,loadTimelineById:Fe,applyAgentConfig:Ne});let Ie=bj({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:d,resolveAgentIdForPost:te,navigateToSession:de,loadSessionById:_e,tryResumeAgentRun:Ce,restoreLiveCacheIfNeeded:Se,adoptEmptySession:Me,applyAgentConfig:Ne,patchInitUi:Pe}),Le=xj(Ie);return(0,Q.useEffect)(()=>{Ie&&Le.error&&Sr.getState().setShellError(Le.error instanceof Error?Le.error.message:`Failed to load model configuration`)},[Ie,Le.error]),(0,Q.useEffect)(()=>{let e=e=>{let t=e.detail,n=t?.conversationId,r=t?.runId;!n||!r?.trim()||(Tr(n,r),Un.setResumeRunId(n,r),fe(n)&&(Un.isTrackingRun(n,r)||queueMicrotask(()=>{fe(n)&&(Un.isTrackingRun(n,r)||Ce(n,tr(n)))})))};return window.addEventListener(`run-started`,e),()=>window.removeEventListener(`run-started`,e)},[Ce,fe]),(0,Q.useEffect)(()=>{let e=k||A,t=_.current;if(_.current=e,!t||e)return;let n=yj.current;n&&queueMicrotask(()=>{!n||!fe(n)||Un.isStreamingFor(n)||pr(n)&&Ce(n,tr(n))})},[k,A,Ce,fe]),b.current=we,{auth:{hasToken:!!W},session:{projectPreparation:Le.preparation,conversationId:S,sessionName:P,decodedKey:i,sessionRoutePending:oe,sessionContentLoading:se,showSessionLoading:ce,conversationPhase:le,loading:C,sessionModel:Ie?Le.model:F,modelConfigReady:Ie?Le.ready:I,modelConfigSaving:L,thinkingLevel:Ie?Le.thinkingLevel:R,onSessionThinkingLevelChange:Ie?Le.onThinkingChange:ye,onSessionWorkingDirectoryChange:J,reasoningLevel:z,modelSupportsThinking:Ie?Le.modelSupportsThinking:B,effectiveWorkspacePath:V,workspaceSource:H,userContextMode:Ie?.temporary?`temporary`:U,hasMore:N,loadingMore:w,loadMoreMessages:q,onSessionModelChange:Ie?Le.onModelChange:ve,createNewSession:be,sessionManager:d.current},messages:{items:je},timeline:{items:v,refresh:Fe},stream:{error:T,streaming:k,sending:A,progress:j,taskPlan:M,sendMessage:we,replaceLatestUserTurn:Te,abort:De,settleStoppedRun:Oe,interruptAndSend:Ee,deleteMessageRound:ke,retryUserMessageRound:Ae},followUp:{composerMode:G.composerMode,control:G.control,controlPending:G.controlPending,beginEditTurn:G.beginEditTurn,cancelEditor:G.cancelEditor,restoreEditor:G.restoreEditor,markComposerHydrated:G.markComposerHydrated,resumeQueue:G.resumeQueue,sendQueuedInput:G.sendQueuedInput,addPendingFollowUp:G.addPendingFollowUp,pendingFollowUps:G.pendingFollowUps,editingFollowUpId:G.editingFollowUpId,beginEditFollowUp:G.beginEditFollowUp,cancelEditFollowUp:G.cancelEditFollowUp,commitEditFollowUp:G.commitEditFollowUp,removePendingFollowUp:G.removePendingFollowUp,movePendingFollowUp:G.movePendingFollowUp,reorderPendingFollowUp:G.reorderPendingFollowUp,steerPendingFollowUp:G.steerPendingFollowUp,steeringFollowUpId:G.steeringFollowUpId},clarify:{clarifyPrompt:G.clarifyPrompt,clarifySubmitting:G.clarifySubmitting,clarifySubmitError:G.clarifySubmitError,submitClarifyAnswer:G.submitClarifyAnswer,letAgentDecideClarification:G.letAgentDecideClarification,cancelClarification:G.cancelClarification},agents:{chatAgents:ee,displayAgentId:Ie?.agentId??re,showChatAgentSelector:ie,onChatAgentChange:ne}}}function Rj(e){let t=(0,Z.c)(15),n=v(Bj),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=Sr(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 $r(i))return;let e=await wn(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{pinned:e.status===`pinned`,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;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(l={revalidateOnFocus:!1},t[10]=l):l=t[10];let u=bi(s,c,l),{mutate:d}=u,f,p;return t[11]!==d||t[12]!==i?(f=()=>{if(!i)return;let e=e=>{let t=e.detail;if(t?.key!==i||typeof t.pinned!=`boolean`)return;let{pinned:n}=t;d(e=>e&&{...e,pinned:n},{revalidate:zj})};return window.addEventListener(`session-updated`,e),()=>window.removeEventListener(`session-updated`,e)},p=[i,d],t[11]=d,t[12]=i,t[13]=f,t[14]=p):(f=t[13],p=t[14]),(0,Q.useEffect)(f,p),u}function zj(e){return!e}function Bj(e){return e.conversationId}function Vj(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 Hj(e,t){return Vj(hr(e??``),t)}function Uj(e,t){return La(e,t)}function Wj(e){return e===`context`||e===`branch`||e===`compaction`?e:null}function Gj(e){return Vj(e.preview||e.title,72)||e.kind}function Kj(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:Hj(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:Uj(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=Wj(a.kind);if(!e)continue;let o=`${a.id}:${a.kind}`;r.events.some(e=>e.key===o)||r.events.push({key:o,label:Gj(a),tone:e})}return n}function qj(e,t){return(e===1?t.toolCount_one:t.toolCount_other).replace(`{{count}}`,String(e))}function Jj(e,t){let n=e[0]?.id;for(let r of e)r.messageIndex<=t&&(n=r.id);return n}function Yj(e){let t=(0,Z.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,X.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,X.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,X.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,X.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,X.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,X.jsx)(`time`,{suppressHydrationWarning:!0,dateTime:new Date(n.timestamp).toISOString(),children:Ob(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,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,X.jsx)(rn,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),qj(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,X.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,X.jsxs)(`span`,{className:`mt-2 flex min-w-0 flex-wrap gap-1.5`,children:[e.map(Zj),h.map(Xj),g>0?(0,X.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,X.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,X.jsx)(`li`,{children:(0,X.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 Xj(e){return(0,X.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,X.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current opacity-70`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`truncate`,children:e.label})]},e.key)}function Zj(e){return(0,X.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,X.jsx)(rn,{className:`size-3 shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`truncate`,children:e.label})]},e.key)}function Qj(e){let t=(0,Z.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=Kj(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=Jj(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,X.jsx)(Ne,{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,X.jsx)(T,{asChild:!0,children:(0,X.jsx)(Yi,{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,X.jsx)(w,{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,X.jsx)(A,{className:`min-w-0 truncate text-base font-semibold text-fg`,children:i.title}),t[11]=i.title,t[12]=y);let b;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,X.jsx)(an,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=b):b=t[13];let x;t[14]===o?x=t[15]:(x=(0,X.jsx)(D,{asChild:!0,children:(0,X.jsx)(Yi,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":o,children:b})}),t[14]=o,t[15]=x);let S;t[16]!==y||t[17]!==x?(S=(0,X.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,x]}),t[16]=y,t[17]=x,t[18]=S):S=t[18];let C;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,X.jsx)(Yj,{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],C=u.map(e),t[19]=m,t[20]=s,t[21]=i,t[22]=c,t[23]=u,t[24]=C}else C=t[24];let E;t[30]===C?E=t[31]:(E=(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,X.jsx)(`ol`,{className:`min-w-0`,children:C})}),t[30]=C,t[31]=E);let M;t[32]!==S||t[33]!==E?(M=(0,X.jsxs)(O,{children:[_,(0,X.jsxs)(k,{className:v,"aria-describedby":void 0,children:[S,E]})]}),t[32]=S,t[33]=E,t[34]=M):M=t[34];let N;return t[35]!==d||t[36]!==M||t[37]!==g?(N=(0,X.jsxs)(j,{open:d,onOpenChange:f,children:[g,M]}),t[35]=d,t[36]=M,t[37]=g,t[38]=N):N=t[38],N}function $j(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 eM(e){let t=(0,Z.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(iM),...m.map(rM),...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,X.jsx)(`div`,{className:`mb-1 flex min-w-0 justify-end text-xs`,children:(0,X.jsx)(`time`,{suppressHydrationWarning:!0,className:`shrink-0 tabular-nums text-fg-disabled`,dateTime:new Date(n.timestamp).toISOString(),children:Ob(n.timestamp)})}):null,t[16]=n.timestamp,t[17]=u),t[18]===n.preview?d=t[19]:(d=(0,X.jsx)(`div`,{className:`min-w-0 text-sm font-semibold leading-5 text-fg`,children:(0,X.jsx)(`span`,{className:`line-clamp-1`,children:n.preview})}),t[18]=n.preview,t[19]=d),t[20]===h?f=t[21]:(f=(0,X.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,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(rn,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`span`,{children:qj(n.tools.length,r)})]}):(0,X.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(nM),c=m.map(tM),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,X.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,X.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,X.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 tM(e){return(0,X.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,X.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current opacity-70`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`truncate`,children:e.label})]},e.key)}function nM(e){return(0,X.jsxs)(`span`,{className:Y(`inline-flex min-w-0 max-w-[9rem] items-center gap-1.5`,e.running&&`text-accent`),children:[(0,X.jsx)(rn,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`truncate`,children:e.label})]},e.key)}function rM(e){return e.label}function iM(e){return e.label}function aM(e){let t=(0,Z.c)(44),{items:n,activeMessageIndex:r,labels:i,onSelectMessage:a}=e,o;t[0]!==n||t[1]!==i?(o=Kj(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,X.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,X.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,X.jsx)(`span`,{className:Y(`block h-0.5 rounded-full transition-[width,background-color] duration-150 ease-out`,$j({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,X.jsx)(`div`,{className:`chat-timeline-scroll flex min-h-0 w-full flex-col`,children:(0,X.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,X.jsx)(eM,{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,X.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,X.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 oM(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 sM(e){let t=oM(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 cM(e){let{enabled:t,conversationId:n,sourceContextPending:r,sourceContextFailed:i,suppressProjectContext:a,project:o,task:s}=e,c=oM(e),[l,u]=(0,Q.useState)(()=>sM(e));(0,Q.useEffect)(()=>{let e=!1,l=sM({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 $r(n);r=e?e.creation.projectId?.trim()||null:(await wn(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):xn(r),Sn(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:sM(e);return{context:d.context,status:d.status}}var lM=[Gt,Bt,oc];function uM(e){let t=(0,Z.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,X.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-2xl bg-accent-soft text-accent`,children:(0,X.jsx)(Gt,{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,X.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,X.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,X.jsx)(`div`,{className:`mt-7 grid w-full gap-3 md:grid-cols-3`,children:s.map((e,t)=>{let n=lM[t]??Gt;return(0,X.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`,Pa.transition,Pa.pressCard,Pa.focusRingPanel,Pa.disabled),children:[(0,X.jsx)(n,{className:`size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.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,X.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 dM=t({ChatPage:()=>pM}),fM=(0,Q.lazy)(async()=>({default:(await u(()=>import(`./chat-terminal-dock-DCUuwiTt.js`),__vite__mapDeps([46,1,2,5,6,47,11,48,26,27,17,18,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,4,64,65,28,29,9,66,67,68,69]))).ChatTerminalDock}));function pM({beforeSend:e,prepareSendContext:t,onRunSettled:n,composerPlaceholder:r,embeddedAttachmentHandoffId:i,draftSeed:a,sourceNoteInView:o=!1,embedded:s=!1,conversationId:c,taskId:l,personal:u=!1,personalWelcome:m,automationWorkspace:g=!1,automationTimelineEntries:_,readOnly:b=!1,onHistoryReady:x,automationExecution:S=!1,initialTurnId:T,onInitialTurnLocated:D}={}){let M=y(e=>e.language),N=C(M),P=v(e=>e.conversationId),F=p(),I=f(),{pathname:L}=I,R=u||!s&&/^\/chat(?:\/|$)/.test(L),[z,B]=d(),V=(0,Q.useRef)(null),H=(0,Q.useRef)(0),W=(0,Q.useRef)(null),[ee,te]=(0,Q.useState)(null),[ne,re]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{re(a??null)},[a]);let[ie,ae]=(0,Q.useState)(()=>!!(c&&window.localStorage.getItem(`personal-calibration:${c}`))),[oe,se]=(0,Q.useState)(null),[ce,le]=(0,Q.useState)(null),[ue,de]=(0,Q.useState)(!1),[fe,pe]=(0,Q.useState)(null),G=l?.trim()||null,{data:me}=Nc(G??``),{auth:he,session:K,messages:ge,timeline:_e,stream:q,followUp:ve,clarify:ye,agents:J}=Lj({fixedConversationId:c,taskId:G??void 0,personal:u}),be=I.state,xe=be?.focusClarification,Se=u?be?.personalSourceTurnId:void 0,Ce=ve.composerMode.kind===`editTurn`?ve.composerMode:null,we=Sr(e=>!!(K.conversationId&&!e.shellError&&e.sessions[K.conversationId]?.historyStatus===`ready`));(0,Q.useEffect)(()=>{we&&ge.items.length>0&&x?.()},[we,ge.items.length,x]),(0,Q.useLayoutEffect)(()=>{if(!g&&!S||!K.conversationId)return;let e=K.conversationId;return lm.setState({conversationIdOverride:e}),()=>{lm.getState().conversationIdOverride===e&&lm.setState({conversationIdOverride:null})}},[g,S,K.conversationId]);let Te=!u&&!s&&!G&&z.get(`scene`)===`find-skills`,De=g||z.get(`setup`)===`automation`,Oe=!s&&!G&&z.get(`agentSetup`)===`1`,ke=u?``:z.get(`skill`)?.trim()??``,Ae=u?``:z.get(`slash`)?.trim()??``;(0,Q.useEffect)(()=>{if(!u||!z.has(`skill`)&&!z.has(`slash`))return;let e=new URLSearchParams(z);e.delete(`skill`),e.delete(`slash`),B(e,{replace:!0})},[u,z,B]);let je=z.get(g?`chatDraft`:`draft`)??``,Me=z.get(`autoSend`)===`1`,Ne=z.get(`attachmentHandoff`),Pe=z.get(`attachmentsHandoff`),Fe=K.decodedKey??K.conversationId,[Ie,Re]=(0,Q.useState)(null),He=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(Ne){let e=qt(Ne);e&&Re(e),He.current=Fe;return}He.current!==Fe&&(He.current=Fe,Re(null))},[Ne,Fe]);let Ue=Bp(e=>e.markViewed),We=Bp(e=>Fe?e.runs[Fe]?.unread:!1);(0,Q.useEffect)(()=>{Fe&&We&&Ue(Fe)},[Fe,We,Ue]);let{data:Ge}=Rj(Fe),Ke=De||!!Ge?.identity?.customData?.automationSetup,qe=(!s||u)&&!G&&!Oe&&!Ke,Je=qe?Fe:null,Ye=(0,Q.useCallback)(()=>{H.current+=1,te({id:H.current,preserveDraft:!0,text:M===`zh`?`把视频草稿改成`:`Adjust the video draft to `})},[M]),Xe=lA(Je,M,ge.items,{chatBusy:q.streaming||q.sending,readOnly:b,onAdjust:Ye}),Ze=$k(Je,M,q.streaming||q.sending,ge.items),Qe=(0,Q.useMemo)(()=>[..._??[],...Xe.timelineEntries,...Ze],[_,Xe.timelineEntries,Ze]),$e=Se?.startsWith(`music-generation:`)||Se?.startsWith(`video-generation:`),tt=$e?Qe.findIndex(e=>e.id===Se):-1,{draft:nt,confirmDraft:rt}=Xe,it=!!Ge?.identity?.customData?.automationSetup?.automationId,at=(0,Q.useCallback)(async e=>{if(Fe)try{let t=await K.sessionManager.forkSessionAtTurn(Fe,e);window.dispatchEvent(new CustomEvent(`session-created`,{detail:{key:t.conversationId,conversationId:t.conversationId}})),Ga(`success`,N.chat.messageForkCreated),F(`/chat/${encodeURIComponent(t.conversationId)}`)}catch(e){throw Ga(`error`,e instanceof Error?e.message:N.chat.messageForkFailed),e}},[Fe,N.chat.messageForkCreated,N.chat.messageForkFailed,F,K.sessionManager]),ot=ge.items.at(-1),st=u&&!ie&&!q.streaming&&!q.sending&&ot?.role===`assistant`&&ge.items.filter(e=>e.role===`user`).length===1&&ge.items.filter(e=>e.role===`assistant`).length===1&&!ge.items.some(e=>e.role===`task`),ct=e=>{ae(!0),c&&window.localStorage.setItem(`personal-calibration:${c}`,`1`),e&&(H.current+=1,te({id:H.current,text:e}))};(0,Q.useEffect)(()=>{V.current=null},[K.conversationId]),(0,Q.useEffect)(()=>{if(!he.hasToken||!ke&&!Ae&&!je&&!(K.projectPreparation&&Pe)||Me&&!K.projectPreparation||K.showSessionLoading||K.sessionRoutePending||!K.conversationId&&!K.projectPreparation)return;let e=K.projectPreparation&&Pe?ms(Pe)??void 0:void 0,t=()=>{let e=new URLSearchParams(z);e.delete(`skill`),e.delete(`slash`),e.delete(g?`chatDraft`:`draft`),K.projectPreparation&&(e.delete(`autoSend`),e.delete(`attachmentsHandoff`));let t=e.toString();F({pathname:L,search:t?`?${t}`:``},{replace:!0})},n=(n,r)=>{V.current!==r&&(V.current=r,queueMicrotask(()=>{e?.length?eh(n,e):(H.current+=1,te({id:H.current,text:n})),t()}))},r=po(ke,je);if(r||e?.length){let e=`${K.conversationId}:draft:${r}`;n(r??``,e);return}if(ke){t();return}if(!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(Ae)){t();return}let i=`${K.conversationId}:slash:${Ae}`;V.current!==i&&queueMicrotask(()=>{(async()=>{try{let e=await is(),t=Ae.toLowerCase(),n=e.find(e=>e.name.toLowerCase()===t||Array.isArray(e.aliases)&&e.aliases.some(e=>e.toLowerCase()===t));if(n){if(V.current===i)return;V.current=i,H.current+=1,te({id:H.current,text:GT(n)})}}finally{t()}})()})},[he.hasToken,g,ke,Ae,je,Me,Pe,K.projectPreparation,z,K.showSessionLoading,K.sessionRoutePending,K.conversationId,F,L]);let{scrollRef:lt,composerDockRef:ut,atBottom:dt,registerListContentRef:ft,scrollToBottom:pt,showScrollToBottom:mt,replySpaceRef:ht,reserveReplySpace:gt,onScroll:_t}=AT({hasToken:he.hasToken,showSessionLoading:K.showSessionLoading,conversationId:K.conversationId,chatMessages:ge.items,streaming:q.streaming,hasMore:K.hasMore,loadingMore:K.loadingMore,loadMoreMessages:K.loadMoreMessages});(0,Q.useEffect)(()=>{if(!g||!dt||!_?.length)return;let e=requestAnimationFrame(()=>pt(!1));return()=>cancelAnimationFrame(e)},[g,_,dt,pt]);let vt=gA({enabled:u,conversationId:K.conversationId,messages:ge.items,viewportRef:lt}),[yt,bt]=(0,Q.useState)(0),xt=(0,Q.useRef)(null),St=(0,Q.useRef)(null),Ct=(0,Q.useMemo)(()=>{let e=-1;for(let t of _e.items)typeof t.displayIndex==`number`&&Number.isFinite(t.displayIndex)&&(e=Math.max(e,t.displayIndex));return e<0?0:Math.max(0,e+1-ge.items.length)},[ge.items.length,_e.items]),wt=(0,Q.useCallback)(e=>{let t=lt.current;if(!t)return!1;let n=t.querySelector(`[data-chat-message-index="${e}"], [data-chat-timeline-index="${e}"]`);if(!n){let n=sT(t)?.reveal(e)??!1;return n&&e<ge.items.length&&bt(e),n}cT(t),e<ge.items.length&&bt(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:iT()}),!0},[ge.items.length,lt]),Tt=(0,Q.useCallback)(()=>{let e=lt.current;if(!e)return;let t=rT(e);bt(e=>e===t?e:t)},[lt]),Et=(0,Q.useCallback)(()=>{xt.current??=requestAnimationFrame(()=>{xt.current=null,Tt()})},[Tt]),Dt=(0,Q.useCallback)(()=>{_t(),Et()},[_t,Et]),Ot=(0,Q.useCallback)(e=>{let t=e-Ct;if(t<0||t>=ge.items.length){t<0&&K.hasMore&&!K.loadingMore&&(St.current=e,K.loadMoreMessages());return}St.current=null,wt(t)},[ge.items.length,wt,K.hasMore,K.loadMoreMessages,K.loadingMore,Ct]);iE({conversationId:K.conversationId,turnId:$e?void 0:Se??T,requestKey:Se?I.key:void 0,assistantOnly:!!Se,messages:ge.items,ready:we,hasMore:K.hasMore,loadingMore:K.loadingMore,loadMore:K.loadMoreMessages,reveal:wt,onLocated:D});let kt=(0,Q.useRef)(void 0),At=I.key;(0,Q.useEffect)(()=>{if(!we||tt<0||kt.current===At)return;let e=requestAnimationFrame(()=>{wt(ge.items.length+tt)&&(kt.current=At)});return()=>cancelAnimationFrame(e)},[At,tt,ge.items.length,we,wt]);let jt=PA({conversationId:K.conversationId,taskId:G,messages:ge.items,displayOffset:Ct,viewportRef:lt,onRevealDisplayIndex:Ot});(0,Q.useEffect)(()=>{let e=St.current;if(e==null)return;let t=e-Ct;if(t>=0&&t<ge.items.length){St.current=null,requestAnimationFrame(()=>wt(t));return}if(t<0&&K.hasMore&&!K.loadingMore){K.loadMoreMessages();return}(t>=ge.items.length||!K.hasMore)&&(St.current=null)},[ge.items.length,wt,K.hasMore,K.loadMoreMessages,K.loadingMore,Ct]),(0,Q.useEffect)(()=>{Et()},[ge.items.length,Et,K.conversationId,Ct]),(0,Q.useEffect)(()=>()=>{xt.current!=null&&cancelAnimationFrame(xt.current)},[]),(0,Q.useEffect)(()=>{te(null)},[K.conversationId]);let Mt=(0,Q.useCallback)(e=>{H.current+=1,te({id:H.current,text:e.prompt})},[]),Nt=!!(K.conversationId&&!K.showSessionLoading&&!K.sessionRoutePending&&K.workspaceSource!==`project`&&K.workspaceSource!==`execution_environment`&&ge.items.length===0),Pt=Vo(e=>e.setAgentId);(0,Q.useEffect)(()=>{if(he.hasToken)return Pt(J.displayAgentId),()=>Pt(``)},[he.hasToken,J.displayAgentId,Pt]);let Ft=K.conversationPhase===`creating-session`,It=K.conversationPhase===`loading-history`;Dp(u&&!It?Fe:null,u);let Lt=Ft||It,Rt=It,zt=!Rt&&ge.items.length===0&&!_?.length&&!Xe.timelineEntries.length&&!Ze.length&&!q.streaming,Bt=(0,Q.useMemo)(()=>{if(q.taskPlan){let e=Nk(q.taskPlan);return e?{plan:e,changeSummary:Kk(ge.items,q.streaming)?.changeSummary??null}:null}return Kk(ge.items,q.streaming)},[ge.items,q.streaming,q.taskPlan]),Vt=(0,Q.useMemo)(()=>(K.sessionRoutePending&&K.decodedKey?K.decodedKey:K.conversationId)?K.sessionName?.trim()||N.chat.newSession:N.nav.chat,[K.conversationId,K.sessionName,K.sessionRoutePending,K.decodedKey,N.nav.chat,N.chat.newSession]),Ht=Ge?.sourceNoteId??null,Ut=PO(Fe,z.get(`projectId`)),Wt=K.projectPreparation?.project??Ut,[Gt,Kt]=(0,Q.useState)([]),[Jt,Yt]=(0,Q.useState)([]),Xt=v(e=>e.baseUrl),Zt=Fe?Ws(Xt,P,Fe):null,Qt=Us.store(e=>Zt?e.drafts[Zt]:void 0),$t=(0,Q.useRef)(void 0),[en,tn]=(0,Q.useState)(!1);(0,Q.useLayoutEffect)(()=>{Fe&&Fe!==$t.current&&($t.current=void 0)},[Fe]),(0,Q.useEffect)(()=>{let e=!1;if(se(null),Ht)return Le(Ht).then(t=>{e||se(t?.title?.trim()||null)}).catch(()=>{e||se(null)}),()=>{e=!0}},[Ht]);let nn=oe||Ge?.sourceNoteTitle||N.chat.sourceNoteFallbackTitle,rn=cM({enabled:he.hasToken&&!!(Fe||Wt)&&!Oe&&ge.items.length===0&&!K.showSessionLoading&&!K.sessionRoutePending,conversationId:Fe,suppressProjectContext:!!(Ht||Ie||K.workspaceSource===`execution_environment`||K.workspaceSource===`session_override`||K.workspaceSource===`agent_workspace`),project:Wt,task:me}),an=(0,Q.useMemo)(()=>J.chatAgents?.items.find(e=>e.id===J.displayAgentId)??{id:J.displayAgentId},[J.chatAgents?.items,J.displayAgentId]),on=(0,Q.useMemo)(()=>Cc(rn.context,N.chat.welcomeSpotlight,{contextStatus:rn.status}),[N.chat.welcomeSpotlight,rn.context,rn.status]),cn=(0,Q.useMemo)(()=>on.recommendation?{suggestionId:on.recommendation.id,contextKind:on.contextKind,prompt:on.recommendation.prompt}:null,[on]),ln=(0,Q.useRef)(0);(0,Q.useEffect)(()=>(ln.current++,()=>{ln.current++}),[c,P]);let un=(0,Q.useRef)(!1),dn=q.sending||q.streaming;(0,Q.useEffect)(()=>{let e=un.current&&!dn;un.current=dn,e&&n?.()},[n,dn]);let fn=(0,Q.useCallback)(async n=>{let r=ln.current;if(e&&!await e()||r!==ln.current)return null;if(!t)return{refs:n};let i=await t();if(r!==ln.current)return null;if(!i)return Ga(`error`,M===`zh`?`工作簿暂不可用,请检查左侧的编辑或保存状态后重试。`:`Check the workbook’s edit or save status and try again.`),null;let a=n?.find(e=>e.kind===i.kind&&e.sourceId===i.sourceId);return a?{refs:n?.map(e=>e===a?{...i,refId:a.refId}:e)}:(n?.length??0)>=5?(Ga(`warning`,N.chat.commandPalette.contextLimitReached,{max:4}),null):{refs:[...n??[],i]}},[e,M,N.chat.commandPalette.contextLimitReached,t]),pn=(0,Q.useCallback)((...[n,r,i,a,o])=>{let s=e=>{if(Qt&&(Ce||os(n)))return Sr.getState().setShellError(N.chat.pageContext.pending),!1;if(Ce)return q.replaceLatestUserTurn(Ce.turnId,n,r,i,e,o?.submittedAt);if(nt&&!r?.length&&!e?.length&&!Qt&&oA(n))return rt();let t=!1,a=q.sendMessage(n,r,i,e,void 0,Qt?.envelope,(e,n)=>{t=!0,gt(n??e),o?.onDispatched?.({clientSubmissionId:e,messageRenderKey:n})},void 0,o?.submittedAt);return t?(Zt&&Qt&&Us.remove(Zt,Qt),!0):a};return!e&&!t?s(a):fn(a).then(e=>e?s(e.refs):!1)},[e,t,fn,Ce,q.replaceLatestUserTurn,q.sendMessage,Qt,Zt,N.chat.pageContext.pending,gt,nt,rt]),mn=NO({preparation:K.projectPreparation,conversationId:Fe,ready:K.modelConfigReady&&!Lt,onSend:pn}),hn=(0,Q.useCallback)(e=>{let t=Nr(e);if(!t||!K.conversationId)return;let n=Un.getGeneration(K.conversationId),r=Un.getResumeRunId(K.conversationId);ve.beginEditTurn(t,{text:e.userTurnDocument?Rn(e.userTurnDocument):Zn(e.content),attachments:An(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(n,r)})},[ve.beginEditTurn,q.settleStoppedRun,K.conversationId]),gn=(0,Q.useCallback)(e=>{if(ve.composerMode.kind===`editFollowUp`)ve.beginEditFollowUp(ve.composerMode.inputId);else if(ve.composerMode.kind===`editTurn`&&K.conversationId){let t=Un.getGeneration(K.conversationId),n=Un.getResumeRunId(K.conversationId);ve.beginEditTurn(ve.composerMode.turnId,e).then(e=>{e&&q.settleStoppedRun(t,n)})}},[ve.composerMode,ve.beginEditFollowUp,ve.beginEditTurn,K.conversationId,q.settleStoppedRun]),_n=ve.cancelEditor;(0,Q.useEffect)(()=>{if(!Me||!je.trim()&&!Pe||!he.hasToken||K.showSessionLoading||K.sessionRoutePending||!K.conversationId||q.sending||q.streaming)return;let e=po(ke,je),t=Pe?ms(Pe):void 0;if(!e&&!t?.length)return;let n=`${K.conversationId}:auto-send:${e??``}:${Pe??``}`;if(V.current===n)return;V.current=n;let r=new URLSearchParams(z);r.delete(`skill`),r.delete(`slash`),r.delete(`draft`),r.delete(`autoSend`),r.delete(`attachmentsHandoff`);let i=r.toString();F({pathname:L,search:i?`?${i}`:``},{replace:!0}),pn(e??``,t??void 0)},[he.hasToken,Me,Pe,je,pn,F,L,z,K.conversationId,K.sessionRoutePending,K.showSessionLoading,ke,q.sending,q.streaming]);let vn=(0,Q.useCallback)(()=>{W.current?.reject(),W.current=null,le(null),de(!1)},[]);(0,Q.useEffect)(()=>{vn()},[vn,Ht]);let yn=(0,Q.useMemo)(()=>({title:N.chat.timelineTitle,turn:N.chat.timelineTurn,messageFallback:N.chat.timelineMessageFallback,toolCount_one:N.chat.timelineToolCount_one,toolCount_other:N.chat.timelineToolCount_other,searchedWeb:N.chat.stepSearchedWeb,searchedMemory:N.chat.stepSearchedMemory,searchedCode:N.chat.stepSearchedCode,searched:N.chat.stepSearched,readFile:N.chat.stepReadFile,runCommand:N.chat.stepRunCommand,listDirectory:N.chat.stepListDirectory,writeFile:N.chat.stepWriteFile,editFile:N.chat.stepEditFile,openUrl:N.chat.stepOpenUrl,fetchUrl:N.chat.stepFetchUrl,unknownTool:N.chat.stepUnknownTool}),[N.chat.timelineTitle,N.chat.timelineTurn,N.chat.timelineMessageFallback,N.chat.timelineToolCount_one,N.chat.timelineToolCount_other,N.chat.stepSearchedWeb,N.chat.stepSearchedMemory,N.chat.stepSearchedCode,N.chat.stepSearched,N.chat.stepReadFile,N.chat.stepRunCommand,N.chat.stepListDirectory,N.chat.stepWriteFile,N.chat.stepEditFile,N.chat.stepOpenUrl,N.chat.stepFetchUrl,N.chat.stepUnknownTool]),bn=(0,Q.useCallback)(async e=>{if(!Ht)return;W.current?.reject(),de(!1);let t=N.chat.sourceNoteAppendSourceLine.replace(`{{time}}`,new Date().toLocaleString(M));return le({heading:N.chat.sourceNoteAppendHeading,content:`${t}\n\n${e.trim()}`}),new Promise((e,t)=>{W.current={sourceNoteId:Ht,resolve:e,reject:t}})},[M,N.chat.sourceNoteAppendHeading,N.chat.sourceNoteAppendSourceLine,Ht]),xn=`${I.pathname}${I.search}`,Sn=(0,Q.useCallback)(async e=>{try{let t=await Ve(e.trim(),`web`);Ga(`success`,N.chat.messageSavedToNote,void 0,{href:et(xn,t.id)})}catch(e){throw Ga(`error`,e instanceof Error?e.message:N.notes.quickCaptureFailed),e}},[xn,N.chat.messageSavedToNote,N.notes.quickCaptureFailed]),Cn=(0,Q.useCallback)(async()=>{let e=W.current;if(!e||!ce)return;let t=ce.heading.trim()||N.chat.sourceNoteAppendHeading,n=ce.content.trim();if(n){de(!0),pe(null);try{await Be(e.sourceNoteId,n,t),window.dispatchEvent(new CustomEvent(`note-updated`,{detail:{noteId:e.sourceNoteId,source:`chat`,conversationId:Fe}})),e.resolve(),W.current=null,le(null)}catch(e){pe(e instanceof Error?e.message:N.chat.sourceNoteSaveFailed)}finally{de(!1)}}},[Fe,N.chat.sourceNoteAppendHeading,N.chat.sourceNoteSaveFailed,N.chat.sourceNoteSaveSuccess,ce]),wn=(0,Q.useCallback)(async e=>{if(!Ht)return;let t=e.trim().split(/\n+/)[0]?.replace(/^[-#*>\s]+/,``).trim()||N.chat.sourceNoteTaskFallbackTitle;try{await ze(t.slice(0,120),{sourceNoteId:Ht,sourceConversationId:Fe})}catch(e){throw Ga(`error`,e instanceof Error?e.message:N.chat.sourceNoteTaskFailed),e}},[Fe,N.chat.sourceNoteTaskFailed,N.chat.sourceNoteTaskFallbackTitle,N.chat.sourceNoteTaskSuccess,Ht]),Tn=(0,Q.useCallback)(async()=>{if(!Ht)return;let t=ln.current;if(e&&(!await e()||t!==ln.current))return;let n=N.chat.sourceNoteDigestPrompt.replace(`{{title}}`,nn);if(q.streaming||q.sending){ve.addPendingFollowUp(n),Wa({tone:`info`,status:`done`,title:N.chat.sourceNoteDigestQueued,source:M===`zh`?`笔记整理`:`Note digest`,dedupeKey:Ht?`note-digest:${Ht}`:void 0});return}q.sendMessage(n)},[e,ve,M,N.chat.sourceNoteDigestPrompt,N.chat.sourceNoteDigestQueued,Ht,nn,q]),En=(0,Q.useCallback)(async e=>{if(!(en||mn.busy)){if(K.projectPreparation){F(uo(e),{state:{forceNewChat:!0,agentId:J.displayAgentId,temporary:K.userContextMode===`temporary`}});return}if(!($t.current!==void 0||q.sending||q.streaming||Lt)){$t.current=Fe,tn(!0);try{e?F(uo(e),{state:{forceNewChat:!0,agentId:J.displayAgentId,temporary:K.userContextMode===`temporary`}}):await K.createNewSession({forceNew:!0,projectId:e,temporary:K.userContextMode===`temporary`})}catch(e){$t.current=void 0,Ga(`error`,N.chat.composerContext.changeFailed,{error:e instanceof Error?e.message:String(e)})}finally{tn(!1)}}}},[Fe,Lt,N.chat.composerContext.changeFailed,en,mn.busy,K.createNewSession,K.projectPreparation,K.userContextMode,q.sending,q.streaming,F,J.displayAgentId]),Dn=(0,Q.useCallback)(()=>En(null),[En]),On=(0,Q.useCallback)(async e=>{if(!(en||Lt||q.sending||q.streaming||!Nt)){tn(!0);try{await K.onSessionWorkingDirectoryChange(e)}finally{tn(!1)}}},[en,Lt,q.sending,q.streaming,Nt,K.onSessionWorkingDirectoryChange]),kn=(0,Q.useMemo)(()=>({project:Wt,draftRefs:Gt,draftAttachments:Jt,draftPage:Qt?{id:`${Qt.envelope.tabId}:${Qt.envelope.sequence}`,title:Qt.title||(M===`zh`?`当前页面`:`Current page`)}:void 0,onLeaveProject:en||mn.busy?void 0:Dn,leaveProjectLabel:N.chat.scopeRemoveProject,onDraftSourceNote:Ht?Tn:void 0,draftSourceNoteLabel:N.chat.sourceNoteDigestAction}),[en,mn.busy,Wt,Gt,Jt,Qt,M,Dn,N.chat.scopeRemoveProject,Ht,Tn,N.chat.sourceNoteDigestAction]);return he.hasToken?(q.error?Vi(q.error):null)?.code===`session_not_found`?(0,X.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col overflow-hidden bg-surface-panel pt-[var(--app-chat-header-height,0px)]`,children:[(0,X.jsx)(xk,{}),(0,X.jsx)(bk,{chatHeadline:N.chat.sessionNotFoundTitle,chatAgents:J.chatAgents?.items??[],showChatAgentSelector:!1,chatAgentId:J.displayAgentId,onChatAgentChange:J.onChatAgentChange,chatAgentDisabled:!0}),(0,X.jsx)(`main`,{className:`mx-auto flex w-full max-w-xl flex-1 items-center px-4 py-12 sm:px-6`,children:(0,X.jsx)(`div`,{className:`w-full`,children:(0,X.jsx)(Tg,{errorText:q.error})})})]}):(0,X.jsx)(ly,{value:Ke,children:(0,X.jsxs)(`div`,{className:Y(`flex h-full min-h-0 flex-1 flex-col bg-surface-panel`,g?`overflow-clip`:`overflow-hidden`),children:[R?null:(0,X.jsx)(xk,{}),!s||g?(0,X.jsx)(bk,{inline:g,chatHeadline:Oe?N.agentsSettings.setupTitle:Te&&ge.items.length===0?N.skills.findTitle:Vt,chatAgents:J.chatAgents?.items??[],showChatAgentSelector:!g&&!Oe&&J.showChatAgentSelector,chatAgentId:J.displayAgentId,onChatAgentChange:J.onChatAgentChange,chatAgentDisabled:mn.busy||en||Lt&&!K.projectPreparation,conversationId:K.conversationId,hasMessages:!Lt&&ge.items.length>0,pinned:!b&&K.conversationId===Fe?Ge?.pinned:void 0,workspacePath:K.effectiveWorkspacePath,userContextMode:K.userContextMode,projectId:Wt?.id,context:kn,canChangeWorkspace:!1,workspaceDisabled:Lt||q.sending||q.streaming,onWorkspaceChange:K.onSessionWorkingDirectoryChange,prepareTerminalSession:K.projectPreparation?mn.prepareSession:void 0,terminalDisabled:!!(K.projectPreparation&&(mn.busy||!mn.allowed||mn.checking)),showContextControls:!Oe,onFindOpen:jt.show}):null,(0,X.jsxs)(`div`,{className:`relative flex min-h-0 w-full flex-1 flex-col`,children:[s&&Ht&&!o?(0,X.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,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:N.chat.sourceNoteBanner.replace(`{{title}}`,nn)}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,X.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:Tn,children:[(0,X.jsx)(Ee,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsx)(`span`,{children:N.chat.sourceNoteDigestAction})]}),(0,X.jsx)(h,{to:et(`${I.pathname}${I.search}`,Ht),className:`font-medium text-accent transition-colors hover:text-accent-fg`,children:N.chat.sourceNoteOpen})]})]})}):null,(0,X.jsxs)(`div`,{className:Y(`relative flex min-h-0 min-w-0 flex-1 flex-col`,u?`[--chat-composer-bottom-radius:1.65rem]`:`[--chat-composer-bottom-radius:1rem]`,zt?`[--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,X.jsx)(_A,{className:R?`top-[calc(var(--app-chat-header-height,0px)+0.75rem)]`:void 0,open:jt.open,query:jt.query,activeIndex:jt.activeIndex,resultCount:jt.resultCount,searching:jt.searching,truncated:jt.truncated,limitedToLoaded:jt.limitedToLoaded,inputRef:jt.inputRef,labels:N.chat.find,onQueryChange:jt.setQuery,onPrevious:jt.previous,onNext:jt.next,onClose:jt.close}),!s||g?(0,X.jsx)(`div`,{className:Y(`pointer-events-none absolute bottom-0 left-1/2 z-20 hidden w-full max-w-[calc(var(--max-width-chat-frame)+8rem)] -translate-x-1/2 xl:block`,R?`top-[var(--app-chat-header-height,0px)]`:`top-0`),children:(0,X.jsx)(`div`,{className:`pointer-events-auto absolute inset-y-0 right-0`,children:(0,X.jsx)(aM,{items:_e.items,activeMessageIndex:yt+Ct,labels:yn,onSelectMessage:Ot})})}):null,(0,X.jsxs)(`div`,{ref:lt,"data-chat-scroll-viewport":!0,"data-app-chat-scroll":R?``:void 0,className:Y(`chat-messages chat-messages--wide-viewport chat-messages--composer-fade relative min-h-0 flex-1 overflow-y-auto overflow-x-hidden [overflow-anchor:none] [scrollbar-gutter:stable_both-edges]`,zt?`chat-messages--compact-welcome pt-5 pb-2`:`py-4`),onScroll:Dt,tabIndex:0,"data-chat-find-open":jt.open?``:void 0,children:[R?(0,X.jsx)(xk,{}):null,!s&&Ge?.parentConversationId?(0,X.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,X.jsx)(h,{to:`/chat/${encodeURIComponent(Ge.parentConversationId)}`,className:`font-medium text-accent transition-colors hover:text-accent-fg`,children:N.chat.forkedFromConversation.replace(`{{name}}`,Ge.forkedFromSessionName||N.chat.forkedFromConversationFallback)}),(0,X.jsx)(`span`,{className:`ms-2`,children:N.chat.forkSharedWorkspaceNotice})]}):null,I.state?.fromAgentEditor&&J.displayAgentId?(0,X.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,X.jsxs)(h,{to:Ls(J.displayAgentId),className:`inline-flex items-center gap-1 text-xs font-medium text-accent transition-colors hover:text-accent-fg`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,children:`←`}),N.agentsSettings.backToEditor]})}):null,(0,X.jsx)(`div`,{className:s&&!u?`px-3`:`px-3 sm:px-5 xl:px-6`,children:(0,X.jsx)(`div`,{"data-chat-message-frame":!0,className:Y(`mx-auto w-full min-w-0`,(!s||u||g)&&`max-w-[var(--max-width-chat-frame)]`),children:It?(0,X.jsxs)(`div`,{className:`flex min-h-[min(40vh,20rem)] w-full flex-col gap-10 py-8`,"aria-busy":`true`,children:[(0,X.jsx)(`div`,{className:`flex justify-end`,children:(0,X.jsx)(sn,{className:`h-11 w-[min(70%,22rem)] rounded-2xl`})}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(sn,{className:`h-4 w-24`}),(0,X.jsx)(sn,{className:`h-4 w-[min(82%,36rem)]`}),(0,X.jsx)(sn,{className:`h-4 w-[min(74%,32rem)]`}),(0,X.jsx)(sn,{className:`h-4 w-[min(48%,22rem)]`})]}),(0,X.jsx)(`div`,{className:`flex justify-end`,children:(0,X.jsx)(sn,{className:`h-11 w-[min(62%,18rem)] rounded-2xl`})})]}):(0,X.jsxs)(X.Fragment,{children:[K.loadingMore?(0,X.jsx)(`div`,{className:`mb-3 text-center text-xs text-fg-muted`,children:N.chat.loadOlder}):null,Ke&&!g&&Fe?(0,X.jsx)(Ts,{conversationId:Fe,language:M,running:q.streaming||q.sending}):null,Ke&&!g&&ge.items.length>0?(0,X.jsx)(h,{className:`mb-4 inline-block rounded-md px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover`,to:`/automations`,children:M===`zh`?`← 定时任务`:`← Scheduled tasks`}):null,!s&&G?(0,X.jsx)(`div`,{className:`hidden md:block`,children:(0,X.jsx)(rl,{taskId:G})}):null,null,null,!s&&Fe?(0,X.jsx)(U,{eventType:`session.transcript.updated`,source:`sessions`,payloadKey:`conversationId`,payloadValue:Fe,className:`mb-6`}):null,(0,X.jsx)(gT,{scrollRef:lt,messages:ge.items,timelineEntries:Qe,personal:u,authToken:P??void 0,conversationId:K.decodedKey??K.conversationId,projectId:Wt?.id,streaming:q.streaming,sending:q.sending,progress:q.progress,runError:q.error,reasoningLevel:K.reasoningLevel,showAssistantWorkLog:!0,registerListContentRef:ft,replySpaceRef:ht,onPickWelcomePrompt:Mt,welcomeSpotlight:on,welcomeOverlay:u&&m?(0,X.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,X.jsx)(`h2`,{className:`text-2xl font-semibold`,children:M===`zh`?`你好${m.addressAs?`,${m.addressAs}`:``}。我们从哪里开始?`:`Hello${m.addressAs?`, ${m.addressAs}`:``}. Where should we start?`}),(0,X.jsx)(`p`,{className:`max-w-xl text-sm leading-relaxed text-fg-muted`,children:m.opening??(M===`zh`?`想讨论问题、整理思路或推进工作,都可以直接说。`:`Bring a question, an idea, or work to move forward.`)}),(0,X.jsx)(`button`,{type:`button`,disabled:K.sessionRoutePending||K.showSessionLoading,className:`min-h-11 rounded-lg border border-edge px-3 py-2 text-left text-sm text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,onClick:()=>{H.current+=1,te({id:H.current,text:N.chat.personalStarterPrompt})},children:N.chat.personalStarterPrompt})]}):Ke?(0,X.jsxs)(`div`,{className:`mx-auto max-w-xl px-4 py-10 text-center`,children:[(0,X.jsx)(`h2`,{className:`text-xl font-semibold text-fg`,children:it?M===`zh`?`想怎么调整这个任务?`:`What would you like to change?`:M===`zh`?`你想安排什么任务?`:`What would you like to schedule?`}),(0,X.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:it?M===`zh`?`直接说要改的内容、时间,或告诉我暂停、恢复。`:`Change what it does or when it runs, or ask to pause or resume.`:M===`zh`?`说说要做的事,时间和细节我们一起确定。`:`Tell us what to do. We’ll work out the timing and details together.`}),g?null:(0,X.jsx)(h,{className:`mt-4 inline-block text-xs text-fg-muted hover:text-fg`,to:`/automations`,children:M===`zh`?`← 返回定时任务`:`← Back to scheduled tasks`})]}):Oe?(0,X.jsx)(uM,{agentName:an.name?.trim()||J.displayAgentId,messages:N.agentsSettings,disabled:K.sessionRoutePending||K.showSessionLoading,onPick:e=>{H.current+=1,te({id:H.current,text:e})}}):Te?(0,X.jsx)(cE,{sk:N.skills,disabled:K.sessionRoutePending||K.showSessionLoading,onPick:e=>{H.current+=1,te({id:H.current,text:po(`find-skills`,e)})}}):void 0,compactWelcome:s,onDeleteRound:G?void 0:q.deleteMessageRound,onRetryUserMessageRound:G?void 0:q.retryUserMessageRound,deleteRoundDisabled:q.streaming||q.sending,onEditUserMessage:G?void 0:hn,editLatestUserOnly:!0,editRequiresTurnId:!0,onSaveAssistantAsNote:Sn,onSaveAssistantToSourceNote:Ht?bn:void 0,onExtractAssistantTask:Ht?wn:void 0,onForkAssistantTurn:!G&&Ge?.sessionType===`chat`?at:void 0,trailingContent:st?(0,X.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,X.jsx)(`p`,{className:`text-fg-muted`,children:M===`zh`?`这个回答合适吗?点选后可以在输入框修改,再发给我。`:`Did that response work for you? Pick an adjustment, edit it, then send.`}),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[[[M===`zh`?`再短一点`:`Make it shorter`,M===`zh`?`这次回答再短一点。`:`Please make this answer shorter.`],[M===`zh`?`更温和一点`:`A little gentler`,M===`zh`?`这次回答的语气更温和一点。`:`Please make this answer a little gentler.`]].map(([e,t])=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>ct(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,X.jsx)(`button`,{type:`button`,onClick:()=>ct(),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:M===`zh`?`这样就好`:`Looks good`})]})]}):null},Fe)]})})})]}),(0,X.jsx)(`div`,{ref:ut,className:`pointer-events-none absolute inset-x-0 bottom-0 z-10`,children:(0,X.jsx)(`div`,{className:s&&!u?`px-3`:`px-3 sm:px-5 xl:px-6`,children:(0,X.jsxs)(`div`,{"data-chat-composer-frame":!0,"data-primary-chat-composer":!s||void 0,className:Y(`pointer-events-auto relative mx-auto w-full min-w-0 pb-[var(--chat-composer-bottom-space)]`,(!s||u||g)&&`max-w-[calc(var(--max-width-chat-frame)+14px)]`,zt?`pt-2.5`:`pt-2 sm:pt-4`),children:[(0,X.jsx)(wT,{visible:!K.showSessionLoading&&mt,onClick:()=>pt(!0),running:q.streaming||q.sending}),(0,X.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:!s||g?(0,X.jsx)(Qj,{items:_e.items,activeMessageIndex:yt+Ct,labels:yn,openLabel:N.chat.timelineOpen,closeLabel:N.chat.timelineClose,currentLabel:N.chat.timelineCurrent,onSelectMessage:Ot}):null}),(0,X.jsx)(up,{prompt:ye.clarifyPrompt,focusRequestKey:xe&&xe===ye.clarifyPrompt?.requestId?I.key:void 0,submitting:ye.clarifySubmitting,submitError:ye.clarifySubmitError,labels:N.chat,onSubmit:ye.submitClarifyAnswer,onAgentDecide:ye.letAgentDecideClarification,onCancel:ye.cancelClarification}),Bt?(0,X.jsx)(kk,{plan:Bt.plan,changeSummary:Bt.changeSummary,isStreaming:q.streaming,labels:{heading:N.chat.planHeading,stepProgress:N.chat.planStepProgress,completedProgress:N.chat.planCompletedProgress,finished:N.chat.planFinished,ended:N.chat.planEnded,planned:N.chat.planPlanned,filesChangedOne:N.chat.planFilesChanged_one,filesChangedOther:N.chat.planFilesChanged_other}}):null,Te&&ge.items.length>0?(0,X.jsx)(`div`,{className:`mb-2 text-right`,children:(0,X.jsx)(h,{to:`/capabilities/skills`,className:`text-xs text-accent-fg hover:underline`,children:N.skills.findBack})}):null,(0,X.jsx)(nE,{}),(0,X.jsx)(oE,{conversationId:K.conversationId,active:q.streaming||q.sending}),(0,X.jsx)(DO,{personal:u,addActions:qe&&!b?{label:M===`zh`?`添加附件或操作`:`Add attachments or actions`,items:[{kind:`video`,label:M===`zh`?`生成视频`:`Generate video`,onSelect:()=>{H.current+=1,te({id:H.current,preserveDraft:!0,text:M===`zh`?`帮我生成一段视频:`:`Generate a video: `})}},{kind:`music`,label:M===`zh`?`创作音乐`:`Create music`,onSelect:()=>{H.current+=1,te({id:H.current,preserveDraft:!0,text:M===`zh`?`帮我做一段轻快的纯音乐,适合旅行视频。`:`Make an upbeat instrumental track for a travel video.`})}}]}:void 0,nextTurnSuggestionsEnabled:!q.streaming,onPersonalSendDispatched:u?vt:void 0,placeholder:r??(u?q.streaming||q.sending?M===`zh`?`继续聊,或补充要求…`:`Keep talking or add a detail…`:M===`zh`?`发消息给「${m?.name||`Personal AI`}」…`:`Message ${m?.name||`Personal AI`}…`:Oe?N.agentsSettings.setupComposerPlaceholder:Te?N.skills.findPlaceholder:void 0),composerContext:!Oe&&!s&&!G&&!Ce&&!Rt&&ge.items.length===0?{project:Wt,disabled:en||mn.busy||Lt&&!K.projectPreparation,environmentPicker:K.projectPreparation?(0,X.jsx)(jO,{selection:mn}):void 0,workspacePath:K.effectiveWorkspacePath,canChangeWorkspace:Nt,onProjectChange:En,onWorkspaceChange:On}:void 0,contextRefs:Gt,pageContextPreview:Qt&&Zt?(0,X.jsx)(OO,{draft:Qt,disabled:q.sending,waiting:q.streaming,onRemove:()=>Us.remove(Zt,Qt)}):void 0,setContextRefs:Kt,maxContextRefs:t?4:void 0,onDraftAttachmentsChange:Yt,disabled:b||It||mn.busy||en,sendDisabled:ve.controlPending||ve.control.phase===`stopping`||b||!K.modelConfigReady||!K.projectPreparation&&Lt||!!(K.projectPreparation&&!mn.allowed)||K.modelConfigSaving||mn.busy||en,sending:q.sending,streaming:q.streaming,conversationId:K.conversationId,embeddedAttachmentHandoffId:i,attachmentHandoffReady:(!s||u||!!i)&&!G&&!b&&(!!K.projectPreparation||!!(K.conversationId&&!Lt)),unboundDraftKey:K.conversationId?void 0:JSON.stringify([L,z.get(`projectId`)]),getDraftHandoffTarget:mn.getDraftHandoffTarget,prepareContextSession:K.projectPreparation?mn.prepareSession:void 0,welcomeDraftSeed:ne??ee,welcomeSuggestion:!Te&&zt?cn:null,onAcceptWelcomeSuggestion:Mt,thinkingLevel:K.thinkingLevel,modelSupportsThinking:K.modelSupportsThinking,onThinkingChange:K.onSessionThinkingLevelChange,onSend:mn.send,composerMode:ve.composerMode,onRestoreEditor:ve.restoreEditor,onComposerHydrated:ve.markComposerHydrated,onReacquireEdit:gn,inputControl:ve.control,onResumeQueue:()=>void ve.resumeQueue().catch(()=>{}),editingUserTurnId:Ce?.turnId,onCancelUserMessageEdit:_n,onAbort:()=>void q.abort().catch(()=>{}),onAddPendingFollowUp:async(n,r,i,a,o)=>{let s=e||t?await fn(i):{refs:i};if(!s)throw Error(t?M===`zh`?`工作簿还未就绪,请重试。`:`The workbook is not ready. Try again.`:M===`zh`?`请先保存笔记,再发送消息。`:`Save the note before sending.`);await ve.addPendingFollowUp(n,r,s.refs,Qt?.envelope,a,o),Zt&&Qt&&Us.remove(Zt,Qt)},onSteeringInterrupt:Qt?void 0:async(n,r,i)=>{let a=e||t?await fn(i):{refs:i};return a?q.interruptAndSend(n,r,void 0,a.refs):!1},pendingFollowUps:ve.pendingFollowUps,editingFollowUpId:ve.editingFollowUpId,onBeginEditFollowUp:ve.beginEditFollowUp,onCancelEditFollowUp:ve.cancelEditFollowUp,onCommitEditFollowUp:async(e,n,r,i,a)=>{let o=t?await fn(a):{refs:a};return o?ve.commitEditFollowUp(e,n,r,i,o.refs):!1},onPendingFollowUpRemove:ve.removePendingFollowUp,onPendingFollowUpMove:ve.movePendingFollowUp,onPendingFollowUpReorder:ve.reorderPendingFollowUp,onPendingFollowUpSteer:e=>void ve.steerPendingFollowUp(e).catch(()=>{}),onPendingFollowUpSend:e=>void ve.sendQueuedInput(e).catch(()=>{}),steeringFollowUpId:ve.steeringFollowUpId,sessionModel:K.sessionModel,showModelSelector:!u,onModelChange:K.onSessionModelChange,modelDisabled:Lt&&!K.projectPreparation||mn.busy||K.modelConfigSaving,onChatAgentChange:!u&&!Oe&&!G&&J.showChatAgentSelector?J.onChatAgentChange:void 0,currentAgentId:J.displayAgentId,voiceAgentName:u&&m?m.name:an.name,voiceTaskId:G??void 0,prepareVoiceSession:K.projectPreparation?mn.prepareSession:void 0})]})})})]})]}),(!s||g)&&Fe&&window.electronAPI?.terminal?(0,X.jsx)(Q.Suspense,{fallback:null,children:(0,X.jsx)(fM,{conversationId:Fe},Fe)}):null,(0,X.jsx)(j,{open:ce!==null,onOpenChange:e=>{!e&&!ue&&vn()},children:(0,X.jsxs)(O,{children:[(0,X.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[1px]`}),(0,X.jsxs)(k,{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,X.jsxs)(`div`,{className:`shrink-0 border-b border-edge-subtle px-5 py-4`,children:[(0,X.jsx)(A,{className:`text-base font-semibold text-fg`,children:N.chat.sourceNoteSaveDialogTitle}),(0,X.jsx)(E,{className:`mt-1 text-sm text-fg-muted`,children:N.chat.sourceNoteSaveDialogDescription.replace(`{{title}}`,nn)})]}),(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-5 py-4`,children:[fe?(0,X.jsxs)(`p`,{className:`rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-sm text-danger`,role:`alert`,children:[N.chat.sourceNoteSaveFailed,`: `,fe]}):null,(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium text-fg`,children:[(0,X.jsx)(`span`,{children:N.chat.sourceNoteSaveDialogHeadingLabel}),(0,X.jsx)(`input`,{value:ce?.heading??``,onChange:e=>le(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:ue})]}),(0,X.jsxs)(`label`,{className:`flex min-h-0 flex-1 flex-col gap-1.5 text-sm font-medium text-fg`,children:[(0,X.jsx)(`span`,{children:N.chat.sourceNoteSaveDialogContentLabel}),(0,X.jsx)(`textarea`,{value:ce?.content??``,onChange:e=>le(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:ue})]})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:[(0,X.jsx)(Yi,{type:`button`,variant:`secondary`,onClick:vn,disabled:ue,children:N.chat.sourceNoteSaveDialogCancel}),(0,X.jsx)(Yi,{type:`button`,variant:`primary`,onClick:()=>void Cn(),disabled:ue||!ce?.content.trim(),children:ue?N.chat.sourceNoteSaveDialogSaving:N.chat.sourceNoteSaveDialogConfirm})]})]})]})})]})}):(0,X.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:N.chat.needToken})}export{Rc as $,qp as A,Zs as At,Tp as B,oh as C,ic as Ct,$p as D,ec as Dt,lm as E,tc as Et,Gp as F,fp as G,wp as H,Bp as I,rl as J,up as K,Rp as L,Hp as M,Ys as Mt,Up as N,Js as Nt,Zp as O,$s as Ot,Vp as P,Xc as Q,Ep as R,sh as S,ac as St,om as T,nc as Tt,hp as U,xp as V,gp as W,el as X,nl as Y,tl as Z,wh as _,uc as _t,YT as a,Kc as at,_h as b,sc as bt,MT as c,Nc as ct,PT as d,gc as dt,zc as et,AT as f,hc as ft,Rv as g,dc as gt,Ny as h,fc as ht,rE as i,$c as it,Wp as j,Xs as jt,Kp as k,Qs as kt,IT as l,jc as lt,gT as m,pc as mt,dM as n,Zc as nt,GT as o,Lc as ot,wT as p,mc as pt,ip as q,tE as r,Qc as rt,WT as s,kc as st,pM as t,Bc as tt,FT as u,_c as ut,hh as v,lc as vt,eh as w,rc as wt,uh as x,oc as xt,gh as y,cc as yt,Dp as z};
74
+ `,document.head.appendChild(e)}function EA(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 DA(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 OA(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 kA(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=EA(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 OA(s,n)){let t=DA(o,e.start,e.end);t&&(r.push({messageIndex:i,occurrence:a,range:t}),a+=1)}}}return r}function AA(e,t){let n=wA();if(!n||(TA(),n.registry.delete(xA),n.registry.delete(SA),e.length===0))return;n.registry.set(xA,new n.Highlight(...e.map(e=>e.range)));let r=e[t];r&&n.registry.set(SA,new n.Highlight(r.range))}function jA(){let e=wA();e?.registry.delete(xA),e?.registry.delete(SA)}function MA(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||(oT(e),e.scrollTo({top:Math.max(0,e.scrollTop+r.top-a),behavior:window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}))}function NA(e,t){return t===0?0:(e+t)%t}function PA(e){return`${e.displayIndex}:${e.occurrence}`}function FA(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 IA(e){let t=(0,Z.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(VA));for(let t of p){let n={displayIndex:a+t.messageIndex,occurrence:t.occurrence};e.set(PA(n),n)}A=[...e.values()].sort(BA),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),jA(),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=>NA(t+e,j.length))},t[14]=j.length,t[15]=H);let U=H,W,ee;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)},ee=[z,U,c,F],t[16]=U,t[17]=c,t[18]=F,t[19]=W,t[20]=ee):(W=t[19],ee=t[20]),(0,Q.useEffect)(W,ee);let te;t[21]!==k||t[22]!==c||t[23]!==o?(te=()=>{let e=o.current;if(!c||!e||!k.trim()){m(zA),jA();return}let t=()=>{let t=kA(e,k);m(e=>FA(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]=te):te=t[24];let ne;t[25]!==k||t[26]!==i||t[27]!==c||t[28]!==o?(ne=[k,i,c,o],t[25]=k,t[26]=i,t[27]=c,t[28]=o,t[29]=ne):ne=t[29],(0,Q.useLayoutEffect)(te,ne);let re,ie;t[30]!==n||t[31]!==k||t[32]!==c||t[33]!==r?(re=()=>{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(()=>{bA(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()}},ie=[n,k,c,r],t[30]=n,t[31]=k,t[32]=c,t[33]=r,t[34]=re,t[35]=ie):(re=t[34],ie=t[35]),(0,Q.useEffect)(re,ie);let ae,oe;t[36]===j.length?(ae=t[37],oe=t[38]):(ae=()=>{T(e=>Math.min(e,Math.max(0,j.length-1)))},oe=[j.length],t[36]=j.length,t[37]=ae,t[38]=oe),(0,Q.useEffect)(ae,oe);let se,ce;t[39]!==w||t[40]!==j||t[41]!==a||t[42]!==p||t[43]!==s||t[44]!==o?(se=()=>{let e=j[w],t=o.current;if(!t||!e){AA(p,-1);return}let n=e.displayIndex-a,r=p.findIndex(t=>t.messageIndex===n&&t.occurrence===e.occurrence);AA(p,r),r>=0?MA(t,p[r]):s(e.displayIndex)},ce=[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]=se,t[46]=ce):(se=t[45],ce=t[46]),(0,Q.useLayoutEffect)(se,ce);let le;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(le=[],t[47]=le):le=t[47],(0,Q.useEffect)(LA,le);let ue,de;t[48]!==n||t[49]!==c?(ue=()=>{O.current!==n&&(O.current=n,c&&z())},de=[z,n,c],t[48]=n,t[49]=c,t[50]=ue,t[51]=de):(ue=t[50],de=t[51]),(0,Q.useEffect)(ue,de);let fe,pe;t[52]===U?(fe=t[53],pe=t[54]):(fe=()=>U(-1),pe=()=>U(1),t[52]=U,t[53]=fe,t[54]=pe);let G;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]!==fe||t[64]!==pe?(G={open:c,query:u,inputRef:E,activeIndex:w,resultCount:j.length,truncated:v,limitedToLoaded:b,searching:S,setQuery:V,show:F,close:z,previous:fe,next:pe},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]=fe,t[64]=pe,t[65]=G):G=t[65],G}function LA(){return RA}function RA(){return jA()}function zA(e){return e.length===0?e:[]}function BA(e,t){return e.displayIndex-t.displayIndex||e.occurrence-t.occurrence}function VA(e){return[PA(e),e]}function HA(e){let t=String(e??``).trim();return!t||t===`new`?null:t}function UA(e){let t=String(e.streamConversationId??``).trim(),n=HA(e.routeConversationId);return!t||!n?!1:t===n}function WA(e){let t=HA(e.routeConversationId);return t?e.cacheConversationId===t:!1}function GA(e){let t=String(e.chatId??``).trim();if(!t)return!1;let n=HA(e.routeConversationId);return n?n===t:!1}function KA(e,t){return e?`new`:t??null}function qA(e,t){if(!(e||!t))return decodeURIComponent(t)}function JA(e){if(!e.viewConversationId||e.conversationId!==e.viewConversationId)return[];if(!e.streamingMsg)return e.messages;let t=e.messages.findLastIndex(e=>!e.pendingSteer)+1,n=e.messages.slice(t),r=e.messages[t-1];if(n.length&&!e.streamingMsg.content.length&&!e.streamingMsg.attachments?.length)return[...e.messages,e.streamingMsg];if(r?.role===`assistant`&&e.streamingMsg.role===`assistant`){let i=gr([r,e.streamingMsg]);return[...e.messages.slice(0,t-1),...i,...n]}return[...e.messages.slice(0,t),e.streamingMsg,...n]}function YA(e,t){let n=e.findLastIndex(e=>!e.pendingSteer),r=e[n];return r?.role!==`assistant`||r.turnId!==t?null:{messagesWithoutTail:[...e.slice(0,n),...e.slice(n+1)],tail:r}}function XA(e){e()}function ZA(e,t){return!!(e&&(e.localDraft||e.configVersion!==void 0)&&t?.some(t=>t.id===e.model))}function QA(e){e.sendingRef.current=!1,e.streamingRef.current=!1}function $A(e){return e.isNewRoute?`creating-session`:e.sessionRoutePending||e.showSessionLoading||e.sessionContentLoading?`loading-history`:e.messageCount===0?`ready-empty`:`ready-conversation`}var ej=new Map;async function tj(e,t,n,r,i){let a=v.getState(),o=Yr([a.baseUrl,a.conversationId,e,t]),s=Yr({action:n,submission:r}),c=ej.get(o);if(c){if(c.signature!==s)throw Error(`An answer is already being submitted`);return(await c.promise).clone()}let l=nj(e,t,n,r,i).then(e=>{for(e.ok||ej.delete(o);ej.size>64;)ej.delete(ej.keys().next().value);return e},e=>{throw ej.delete(o),e});return ej.set(o,{signature:s,promise:l}),(await l).clone()}async function nj(e,t,n,r,i){let a=v.getState().conversationId,o=op(e,t,`submission`,i),s={schemaVersion:2,action:n,...r,expectedVersion:t},c=Yr(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}})),v.getState().conversationId!==a)throw Error(`Active Gateway changed`);let d=await g(_(`/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 op(e,t,`draft`,i).write(void 0)),d}async function rj(e,t,n){let r=()=>{if(!n())throw new DOMException(`Conversation changed`,`AbortError`)},i=await ei(e);if(r(),i&&(i.kind!==`append`||i.execution||i.delivery!==t.delivery||Yr(i.input)!==Yr(t.input)||!!i.interrupt!=!!t.interrupt))throw Error(`The previous input is awaiting confirmation`);let a=Zr.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},s=async t=>{let n=await g(_(`/api/sessions/${encodeURIComponent(e)}/input-receipts/${encodeURIComponent(a.clientMessageId)}`),{signal:t}),i=await n.json();if(r(),n.ok)return o(i.payload);if(n.status!==404||i.error?.code!==`NOT_RECEIVED`)throw Error(i.error?.message??`Input receipt lookup failed`)},c=async t=>(r(),await ti(e,a.clientMessageId),r(),t);if(i){let e=await s();if(e!==void 0)return c(e)}let{origin:l,...u}=a;await Jr(e,u),r();let d,f;try{d=await g(_(`/api/sessions/${encodeURIComponent(e)}/inputs`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(a)});let t=await d.json();if(r(),!d.ok)throw Error(typeof t.error==`string`?t.error:t.error?.message??`Message was not accepted`);f=o(t.payload)}catch(t){if(r(),d&&d.status>=400&&d.status<500&&d.status!==408)throw await ti(e,a.clientMessageId),t;if(f=await s(AbortSignal.timeout(3e3)).catch(()=>void 0),r(),f===void 0)throw t}return c(f)}function ij(e){return e.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e,n=t.origin;if(t.status!==`injecting`||t.effectiveDelivery!==`steer`||n?.type!==`endpoint`||typeof t.clientMessageId!=`string`||typeof t.content!=`string`)return[];let r=Hr(t.content),i=Array.isArray(t.contextRefs)?t.contextRefs:[],a=new Map(i.flatMap(e=>typeof e?.refId==`string`&&typeof e.title==`string`?[[e.refId,e.title]]:[]));return Er([{role:`user`,content:r?nr(r,e=>a.get(e)):t.content,attachments:t.attachments,metadata:{clientMessageId:t.clientMessageId,steered:!0,sourceContexts:i,userTurnDocument:r},timestamp:t.createdAtMs,turnId:t.targetRunId}]).map(e=>({...e,pendingSteer:!0}))})}function aj(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:{...Wr(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 oj(e){let{conversationId:t,personal:n,decodedKey:r,conversationIdRef:i,sendingRef:a,streamingRef:o,modelSupportsThinking:s,thinkingLevel:c,shouldApplyStreamUpdate:l}=e,u=v(e=>e.conversationId),d=(0,Q.useRef)({gateway:u,conversationId:t});(d.current.gateway!==u||d.current.conversationId!==t)&&(d.current={gateway:u,conversationId:t});let f=(0,Q.useCallback)(()=>{let e=d.current;return()=>d.current===e&&i.current===e.conversationId&&v.getState().conversationId===e.gateway},[i]),[p,m]=(0,Q.useState)(null),[h,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(null),S=(0,Q.useRef)(null),C=(0,Q.useRef)(0),w=(0,Q.useRef)(null),[T,E]=(0,Q.useState)([]),D=(0,Q.useRef)([]),[O,k]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(()=>({scope:d.current,mode:{kind:`compose`}})),M=A.scope===d.current?A.mode:{kind:`compose`},N=(0,Q.useCallback)(e=>j({scope:d.current,mode:e}),[]),P=(0,Q.useRef)(M);P.current=M;let F=M.kind===`editFollowUp`?M.inputId:null,I=e=>N(e?{kind:`editFollowUp`,inputId:e,version:D.current.find(t=>t.id===e)?.version??0}:{kind:`compose`}),[L,R]=(0,Q.useState)(()=>wr(t??``)),[z,B]=(0,Q.useState)(!1),V=(0,Q.useRef)(!1),H=(0,Q.useRef)(null),U=(0,Q.useRef)(-1),[W,ee]=(0,Q.useState)(!1),te=(0,Q.useRef)(null),[ne,re]=(0,Q.useState)(null),ie=(0,Q.useCallback)(()=>re(d.current),[]);S.current=p,D.current=T,H.current=F;let ae=(0,Q.useCallback)(e=>{if(!e||typeof e!=`object`)return;let t=e;if(t.conversationId!==i.current||typeof t.revision!=`number`||!Array.isArray(t.inputs)||t.revision<U.current)return;if(t.control){if(!Rr(t.conversationId,t.control,t.revision))return;R(t.control)}let n=wE({control:t.control,inputs:t.inputs,activeRunId:t.activeRunId,preparation:t.preparation}),r=ij(t.inputs),a=Sr.getState();if(r.length||a.sessions[t.conversationId]?.messages.some(e=>e.pendingSteer)){let e=new Set(n.map(e=>e.clientMessageId));a.updateSessionMessages(t.conversationId,t=>{let n=t.filter(t=>!t.pendingSteer||!t.clientMessageId||!e.has(t.clientMessageId)),i=new Set(n.map(e=>e.clientMessageId));return[...n,...r.filter(e=>!i.has(e.clientMessageId))]})}U.current=t.revision,ee(!t.activeRunId&&t.inputs.length===0),D.current=n,E(n)},[i]),oe=(0,Q.useCallback)(async e=>{if(e!==i.current)return;let t=f();if(await $r(e)||!t())return;let n=await g(_(`/api/sessions/${encodeURIComponent(e)}/input-state`)).catch(()=>null);if(!n?.ok||i.current!==e)return;let r=await n.json().catch(()=>null);t()&&ae(r?.payload)},[ae,f,i]),se=(0,Q.useCallback)(async e=>{if(e!==i.current)return;let t=f(),n=++C.current;if(await $r(e)||!t())return;let r=await g(_(`/api/sessions/${encodeURIComponent(e)}/clarification`)).catch(()=>null);if(!r?.ok||i.current!==e)return;let a=await r.json().catch(()=>null);!t()||n!==C.current||i.current!==e||(x(null),m(aj(a?.payload,e)),w.current=null)},[f,i]);(0,Q.useLayoutEffect)(()=>{U.current=-1,ee(!1),te.current=null,V.current=!1,B(!1),k(null),C.current++,R(wr(t??``)),N({kind:`compose`}),D.current=[],E([]),I(null),m(null)},[t,u]),(0,Q.useEffect)(()=>{!t||t!==r||(oe(t),se(t))},[r,se,oe,t,u]),(0,Q.useEffect)(()=>{let e=e=>{let t=e.detail;ae(t);let n=i.current;n&&t&&typeof t==`object`&&t.conversationId===n&&se(n)},t=e=>{let t=i.current;if(!t)return;let n=e.detail;if(n&&typeof n==`object`){let e=n.conversationId;if(typeof e==`string`&&e!==t)return}x(null),C.current++,m(aj(n,t)),w.current=null},n=()=>{let e=i.current;e&&(oe(e),se(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)}},[ae,se,oe,i]),(0,Q.useEffect)(()=>{if(!p?.expiresAt)return;let e=Math.max(0,p.expiresAt-Date.now())+250,t=window.setTimeout(()=>{let e=i.current;e&&se(e)},e);return()=>window.clearTimeout(t)},[p?.expiresAt,se,i]);let ce=(0,Q.useCallback)(()=>{x(null),m(null)},[]),le=(0,Q.useCallback)(e=>{let t=String(e??``).trim();t&&i.current===t&&(x(null),m(null))},[i]),ue=(0,Q.useCallback)(()=>{x(null),m(null)},[]),de=(0,Q.useCallback)(()=>{I(null)},[]),fe=(0,Q.useCallback)(()=>{x(null),m(null),I(null)},[]),pe=(0,Q.useCallback)(e=>t=>{l(e)&&(a.current=!1,o.current=!1,Sr.getState().setSessionFlags(e,{sending:!1,streaming:!1}),Sr.getState().setSessionProgress(e,null),x(null),C.current++,m({...t,conversationId:e}),w.current=null)},[l,a,o]),G=(0,Q.useCallback)(async(e,t,n,r,a,o)=>{let s=e.trim();if(!s&&!t?.length&&!n?.length)return;let c=i.current;if(!c)throw Error(`No active session`);let l=f(),u=wr(c),d=await qr(c);if(!l())throw new DOMException(`Conversation changed`,`AbortError`);let p=await Ur();if(!l())throw new DOMException(`Conversation changed`,`AbortError`);if(!d)throw Error(`Reload the conversation before sending`);let m=Sr.getState().sessions[c]?.configVersion;if(m===void 0)throw Error(`Reload the conversation before sending`);let h=await rj(c,{kind:`append`,expectedTranscriptId:d,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:r},origin:p},l);l()&&ae(h)},[ae,f,i]),me=(0,Q.useCallback)(async(e,t)=>{let n=i.current;if(!n||V.current)throw Error(`Wait for the current operation`);let r=f(),a=()=>{if(!r())throw new DOMException(`Conversation changed`,`AbortError`)};V.current=!0,B(!0);try{let r=await qr(n);a();let i=Date.now()+15e3;for(;!r&&e===`stop`&&Date.now()<i;)await new Promise(e=>setTimeout(e,100)),r=await qr(n),a();if(!r)throw Error(`Input acceptance is awaiting confirmation`);if(t?.onlyIfEmpty&&P.current.kind!==`compose`)return;let o={action:e,operationId:crypto.randomUUID(),expectedTranscriptId:r,expectedVersion:wr(n).version,...t},s=await mr(n,o);if(a(),ae(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(;wr(n).phase===`stopping`;){if(a(),Date.now()>=e)throw Error(`Stop is awaiting confirmation`);await new Promise(e=>setTimeout(e,100)),await oe(n)}}if(a(),e===`stop`||e===`pause`){let t=wr(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!r()||(await oe(n),!r())||t?.onlyIfEmpty||Ua(`error`,e instanceof Error?e.message:String(e)),e}finally{r()&&(V.current=!1,B(!1))}},[ae,f,i,oe]);(0,Q.useEffect)(()=>{if(!t||!W||!L.paused||L.phase!==`idle`||z||M.kind!==`compose`||ne!==d.current)return;let e=`${u}:${t}:${L.version}:${U.current}`;if(te.current===e)return;let n=window.setTimeout(()=>{V.current||P.current.kind!==`compose`||(te.current=e,me(`resume`,{onlyIfEmpty:!0}).catch(()=>{}))},0);return()=>window.clearTimeout(n)},[me,M.kind,L.paused,L.phase,L.version,z,t,u,ne,W]);let he=(0,Q.useCallback)(()=>me(`stop`),[me]),K=(0,Q.useCallback)(()=>me(`resume`),[me]),ge=(0,Q.useCallback)(async(e,t)=>{let n=f();try{return await me(`stop`,{turnId:e}),n()?(N({kind:`editTurn`,turnId:e,draft:t}),!0):!1}catch{return!1}},[f,me]),_e=(0,Q.useCallback)(async e=>{let t=D.current.find(t=>t.id===e);if(!t)return!1;let n=f();try{return await me(`pause`,{inputId:e,inputVersion:t.version}),n()?(N({kind:`editFollowUp`,inputId:e,version:t.version}),!0):!1}catch{return!1}},[f,me]),q=(0,Q.useCallback)(()=>N({kind:`compose`}),[]),ve=(0,Q.useCallback)(async(e,t,n,r,a)=>{let o=i.current;if(!o||M.kind!==`editFollowUp`||M.inputId!==e||!t.trim()&&!n?.length&&!a?.length)return!1;let l=f(),u=await g(_(`/api/sessions/${encodeURIComponent(o)}/inputs/${encodeURIComponent(e)}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({version:M.version,content:t,attachments:n??[],thinking:s?r??c:`off`,contextRefs:(a??[]).map(({refId:e,kind:t,sourceId:n,expectedVersion:r})=>({refId:e,kind:t,sourceId:n,expectedVersion:r}))})}),d=await u.json();if(!l())return!1;if(ae(d.payload),!u.ok)throw Error(d.error?.message??`This input changed; your draft has been preserved`);if(P.current===M){let t=d.payload?.inputs?.find(t=>t.id===e);t&&N({...M,version:t.version})}return!0},[ae,f,M,i,s,c]),ye=(0,Q.useCallback)(e=>{H.current===e&&I(null);let t=i.current,n=D.current.find(t=>t.id===e);if(!t||!n)return;let r=f();g(_(`/api/sessions/${encodeURIComponent(t)}/inputs/${encodeURIComponent(e)}?version=${n.version}`),{method:`DELETE`}).then(async e=>{let t=await e.json().catch(()=>null);r()&&ae(t?.payload)}).catch(()=>{oe(t)})},[ae,f,oe,i]),J=(0,Q.useCallback)((e,t)=>{let n=D.current.filter(e=>e.status===`queued`),r=n.findIndex(t=>t.id===e);if(r<0)return;let a=t===`up`?r-1:r+1,o=i.current,s=n[r];if(!o||!s||a<0||a>=n.length)return;let c=f();g(_(`/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()&&ae(t?.payload)}).catch(()=>{oe(o)})},[ae,f,oe,i]),be=(0,Q.useCallback)((e,t)=>{let n=i.current,r=D.current[e],a=D.current[t],o=D.current.filter(e=>e.status===`queued`),s=a?o.findIndex(e=>e.id===a.id):-1;if(!n||r?.status!==`queued`||a?.status!==`queued`||s<0)return;let c=f();g(_(`/api/sessions/${encodeURIComponent(n)}/inputs/${encodeURIComponent(r.id)}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({version:r.version,position:s})}).then(async e=>{let t=await e.json().catch(()=>null);c()&&ae(t?.payload)}).catch(()=>{oe(n)})},[ae,f,oe,i]),xe=(0,Q.useCallback)(async(e,t)=>{let n=D.current.find(t=>t.id===e);if(!n)return;let r=f();k(e);try{await me(t,{inputId:e,inputVersion:n.version})}finally{r()&&k(null)}},[f,me]),Se=(0,Q.useCallback)(e=>xe(e,`steer`),[xe]),Ce=(0,Q.useCallback)(e=>xe(e,`send`),[xe]),we=(0,Q.useCallback)(async(e,t)=>{let r=S.current,a=i.current;if(!r||!a)return;let o=f(),s=JSON.stringify([r.requestId,r.version,e,t]);w.current?.signature!==s&&(w.current={signature:s,idempotencyKey:crypto.randomUUID()});let c=w.current.idempotencyKey;y(!0),x(null);try{let s=r.schemaVersion===2?await tj(r.requestId,r.version,e,t,i.current??void 0):await g(_(`/api/clarifications/${encodeURIComponent(r.requestId)}/responses`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:e,...t,expectedVersion:r.version,idempotencyKey:c})});if(!o())return;let l=n&&e===`answer`&&s.ok?Gr(r,t):void 0,u=l?.choices.find(e=>e.id===l.choiceId)?.label;if(l&&u){let e=`clarification-choice:${r.requestId}`;Sr.getState().updateSessionMessages(a,t=>t.some(t=>t.turnId===e)?t:[...t,{role:`user`,content:[{type:`text`,text:u}],timestamp:Date.now(),turnId:e,clarificationChoice:l}])}if(S.current?.requestId!==r.requestId)return;if(!s.ok){let e=await s.json().catch(()=>({}));x(e.error?.message??s.statusText??`Clarify failed`);let t=i.current;t&&(s.status===409||s.status===410)&&se(t);return}w.current=null,m(null),x(null)}catch(e){S.current?.requestId===r.requestId&&x(e instanceof Error?e.message:String(e))}finally{y(!1)}},[f,i,n,se]);return{clarifyPrompt:p,clarifySubmitting:h,clarifySubmitError:b,clarifyPromptRef:S,pendingFollowUps:T,pendingFollowUpsRef:D,steeringFollowUpId:O,composerMode:M,control:L,controlPending:z,stopSession:he,resumeQueue:K,sendQueuedInput:Ce,beginEditTurn:ge,cancelEditor:q,restoreEditor:N,markComposerHydrated:ie,editingFollowUpId:F,addPendingFollowUp:G,beginEditFollowUp:_e,cancelEditFollowUp:q,commitEditFollowUp:ve,removePendingFollowUp:ye,movePendingFollowUp:J,reorderPendingFollowUp:be,steerPendingFollowUp:Se,submitClarifyAnswer:(0,Q.useCallback)(e=>we(`answer`,e),[we]),letAgentDecideClarification:(0,Q.useCallback)(()=>we(`agent_decide`),[we]),cancelClarification:(0,Q.useCallback)(()=>we(`cancel`),[we]),clearVisibleClarify:ce,dismissClarify:ue,dismissClarifyForSession:le,clearPendingFollowUps:de,dismissClarifyAndClearPending:fe,makeOnClarifyRequest:pe}}function sj(e){let t=(0,Z.c)(51),{navigate:n,conversationIdRef:r,conversationId:i,isNewRoute:a,locationState:o,locationSearch:s,personal:c}=e,l=c!==void 0&&c,u=v(dj),d;t[0]===u?d=t[1]:(d=u?[`gateway-chat-agents`,u]:null,t[0]=u,t[1]=d);let f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f={revalidateOnFocus:!1},t[2]=f):f=t[2];let{data:p,mutate:m}=vi(d,Ai,f),{data:h}=Gp(i),g=h?.agentId??``,_,y;t[3]===m?(_=t[4],y=t[5]):(_=()=>{let e=e=>{ki(e.detail)||m()};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},y=[m],t[3]=m,t[4]=_,t[5]=y),(0,Q.useEffect)(_,y);let[b,x]=(0,Q.useState)(uj),S=(0,Q.useRef)(p??null),C;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(C=li().selectedAgentId??null,t[6]=C):C=t[6];let w=(0,Q.useRef)(C),T,E;t[7]===p?(T=t[8],E=t[9]):(T=()=>{S.current=p??null},E=[p],t[7]=p,t[8]=T,t[9]=E),(0,Q.useEffect)(T,E);let D,O;t[10]===b?(D=t[11],O=t[12]):(D=()=>{w.current=b},O=[b],t[10]=b,t[11]=D,t[12]=O),(0,Q.useEffect)(D,O);let k,A;t[13]===p?(k=t[14],A=t[15]):(k=()=>{if(!p)return;let e=new Set(p.items.map(lj));x(t=>t==null||t===``||!e.has(t)?p.defaultId:t)},A=[p],t[13]=p,t[14]=k,t[15]=A),(0,Q.useEffect)(k,A);let j;t[16]!==r||t[17]!==g?(j=()=>{if(r.current&&g)return g;let e=S.current,t=(w.current??``).trim().toLowerCase();if(!e)return t||void 0;let n=new Set(e.items.map(cj));return t&&n.has(t)?t:e.defaultId},t[16]=r,t[17]=g,t[18]=j):j=t[18];let M=j,N;t[19]!==r||t[20]!==g||t[21]!==h?.projectId||t[22]!==a||t[23]!==s||t[24]!==o||t[25]!==n?(N=e=>{let t=e.trim().toLowerCase(),i=r.current?g||w.current:null;w.current=t,x(t),ii(t),i!==t&&n(a?`/chat/new${s}`:co(h?.projectId),{replace:!1,state:{...a&&o&&typeof o==`object`?o:{},agentId:t,forceNewChat:!0}})},t[19]=r,t[20]=g,t[21]=h?.projectId,t[22]=a,t[23]=s,t[24]=o,t[25]=n,t[26]=N):N=t[26],h?.projectId;let P=N,F,I;t[27]===P?(F=t[28],I=t[29]):(F=()=>{let e=e=>{let t=e.detail?.agentId;typeof t!=`string`||!t.trim()||P(t)};return window.addEventListener(`xopc-set-chat-agent`,e),()=>window.removeEventListener(`xopc-set-chat-agent`,e)},I=[P],t[27]=P,t[28]=F,t[29]=I),(0,Q.useEffect)(F,I);let L,R;t[30]!==i||t[31]!==g||t[32]!==l?(L=()=>{if(!i||l)return;let e=g;!e||w.current===e||(w.current=e,x(e),ii(e))},R=[g,i,l],t[30]=i,t[31]=g,t[32]=l,t[33]=L,t[34]=R):(L=t[33],R=t[34]),(0,Q.useLayoutEffect)(L,R);let z,B;t[35]!==i||t[36]!==h?(z=()=>{!i||!h||si(h.projectId)},B=[h,i],t[35]=i,t[36]=h,t[37]=z,t[38]=B):(z=t[37],B=t[38]),(0,Q.useLayoutEffect)(z,B);let V,H;t[39]!==a||t[40]!==o?(V=()=>{if(!a)return;let e=o,t=typeof e?.agentId==`string`?e.agentId.trim().toLowerCase():``;t&&(w.current=t,x(t),ii(t))},H=[a,o],t[39]=a,t[40]=o,t[41]=V,t[42]=H):(V=t[41],H=t[42]),(0,Q.useLayoutEffect)(V,H);let U=g||b||p?.defaultId||`main`,W=(p?.items.length??0)>1,ee=h?.projectId??null,te;return t[43]!==p||t[44]!==U||t[45]!==P||t[46]!==M||t[47]!==W||t[48]!==ee||t[49]!==u?(te={token:u,chatAgentsData:p,resolveAgentIdForPost:M,onChatAgentChange:P,displayAgentId:U,showChatAgentSelector:W,currentSessionProjectId:ee},t[43]=p,t[44]=U,t[45]=P,t[46]=M,t[47]=W,t[48]=ee,t[49]=u,t[50]=te):te=t[50],te}function cj(e){return e.id}function lj(e){return e.id}function uj(){return li().selectedAgentId??null}function dj(e){return e.conversationId}async function fj(e){let t=await e.sessionMgr.createSession(e);return{kind:`create`,conversationId:t.key,session:t}}var pj=new Map,mj=0;function hj(e){let t=v.getState(),n=oi(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=pj.get(r);if(i)return i.target.opts=e,i.target.generation=++mj,i.promise;let a={opts:e,generation:++mj},o=e=>{if(a.generation!==mj)return;let t=a.opts;!t.routeConversationId&&Ji.getState().scope===`new`&&Ji.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 fj({sessionMgr:e.sessionMgr,agentId:t?.trim()||`main`,projectId:e.projectId,currentConversationId:e.currentConversationId,forceNew:e.forceNew,temporary:e.temporary,...new URLSearchParams(e.search).get(`agentSetup`)===`1`?{agentSetup:!0,agentSetupLanguage:y.getState().language===`zh`?`zh-CN`:`en`}:{},initialAgentConfig:e.initialAgentConfig,executionMode:e.executionMode});return o(n),n})().finally(()=>{pj.delete(r)});return pj.set(r,{promise:s,target:a}),s}var gj={current:null},_j={current:null};function vj(e){return!!(e&&typeof e==`object`&&e.forceNewChat===!0)}function yj(e){let t=f(),{conversationId:n}=m(),r=!e&&t.pathname.endsWith(`/new`),i=r&&vj(t.state),a=e??qA(r,n),o=KA(r,a),s=HA(o),c=r?null:a??null,l=(0,Q.useRef)(o);return l.current=o,gj.current=c,!r&&a&&(_j.current=a),(0,Q.useLayoutEffect)(()=>{Sr.getState().focusedConversationId!==c&&Sr.getState().setFocusedConversationId(c)},[c]),{isNewRoute:r,forceNewChat:i,decodedKey:a,routedConversationId:o,viewConversationId:s,routedFocusedConversationId:c,routeConversationIdRef:l,locationKey:t.key,locationSearch:t.search,locationState:t.state}}var bj={get current(){return _j.current}},xj={get current(){return gj.current},set current(e){gj.current=e,Sr.getState().setFocusedConversationId(e)}};function Sj(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:m,adoptEmptySession:h,applyAgentConfig:g,patchInitUi:_}=e,y=(0,Q.useRef)(0),b=v(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:m,adoptEmptySession:h,applyAgentConfig:g,patchInitUi:_});return E.current={sessionMgrRef:l,resolveAgentIdForPost:u,navigateToSession:d,loadSessionById:f,tryResumeAgentRun:p,restoreLiveCacheIfNeeded:m,adoptEmptySession:h,applyAgentConfig:g,patchInitUi:_},(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=li(),i=n.resolveAgentIdForPost(),s=ci({origin:`web-route`,project:so(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 xn(s.projectId):null;if(!a())return;!e.requestedAgentId&&c?.defaultAgentId&&(s.agentId=c.defaultAgentId);let l=ri(r,s.agentId),u=(t,r,i)=>hj({sessionMgr:n.sessionMgrRef.current,agentId:s.agentId,currentConversationId:bj.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:lo(e.newRouteLocationSearch),onOpened:e=>{a()&&(i?.(e),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,n)=>a()?u(e,t,n):Promise.reject(Error(`New chat request changed`))});return}await u()},c=(e,t)=>{if(!a())return Promise.resolve();n.restoreLiveCacheIfNeeded(e);let r=Vr(e)?.messages??t??tr(e);return n.tryResumeAgentRun(e,r)},l=e=>a()?Vr(e)?.historyStatus===`ready`?(o(e),c(e,tr(e))):n.loadSessionById(e,0).then(t=>{if(a())return c(e,t??tr(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=Vr(t.key)?.messages??e??tr(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 hj({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 Cj(e){let t=v(e=>e.conversationId),n=v(e=>e.baseUrl),[r,i]=(0,Q.useState)(null),{data:a,error:o}=vi(e?[`prepared-session-model`,n,t,e.create]:null,async()=>{let t=ri(li(),e.agentId),[n,r]=await Promise.all([Wi(),t?.modelRef??Ki(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?ui(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,n,r)=>{let i=d.current;if(i.preparation!==e||!i.ready||!i.selection)throw Error(`Model configuration is not ready`);let a=i.selection,o=await e.create(t,a,r);return i.explicitlySelected&&ai(e.agentId,{modelRef:a.model,thinkingLevel:a.thinkingLevel}),o}},[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=ri(li(),e.agentId)?.thinkingByModel?.[t],c=r.thinking?ui(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)}}var wj=class{tails=new Map;run(e,t){let n=this.tails.get(e),r=n?n.then(t,t):Promise.resolve().then(t),i=r.finally(()=>{this.tails.get(e)===i&&this.tails.delete(e)});return this.tails.set(e,i),i.catch(()=>{}),r}};async function Tj(e){let t=e.trim();if(!t)return!1;try{return!!(await Wi()).find(e=>e.id===t)?.reasoning}catch{return!1}}function Ej(e){let{sessionMgrRef:t,routeConversationIdRef:n,sendingRef:r,streamingRef:a,loadingSessionRef:o,messagesLenRef:s,thinkingSupportGenRef:c,navigateToSession:l,resolveAgentIdForPost:u,detachForNewConversation:d,conversationId:f,sessionAgentId:p,currentProjectId:m,taskId:h,hasMore:g}=e,_=()=>Sr.getState(),v=(0,Q.useRef)(new wj),y=(0,Q.useRef)(0),b=(0,Q.useRef)(null),x=(0,Q.useRef)(0),S=(0,Q.useCallback)(e=>{let t=_().focusedConversationId;if(!e.trim())return++c.current===c.current&&t&&_().patchSessionMeta(t,{modelSupportsThinking:!1}),Promise.resolve();let n=++c.current;return Tj(e).then(t=>{if(n!==c.current)return;let r=_().focusedConversationId;r&&_().sessions[r]?.model===e&&_().patchSessionMeta(r,{modelSupportsThinking:t})})},[c]),C=(0,Q.useCallback)(async e=>{try{let n=await t.current.loadSessionAgentConfig(e);zr(e,n),S(n.model)}catch{}},[t,S]),w=(0,Q.useCallback)(()=>{let e=_().focusedConversationId;if(!e||(_().sessions[e]?.name)?.trim())return;let n=++x.current,r=[700,900,900,1e3,1e3],i=a=>{a>=5||n===x.current&&_().focusedConversationId===e&&(_().sessions[e]?.name?.trim()||window.setTimeout(()=>{n===x.current&&_().focusedConversationId===e&&(_().sessions[e]?.name?.trim()||t.current.fetchSessionName(e).then(t=>{if(n===x.current){if(t){_().patchSessionMeta(e,{name:t});return}i(a+1)}}).catch(()=>{i(a+1)}))},r[a]??900))};i(0)},[t]),T=(0,Q.useCallback)(e=>GA({chatId:e,routeConversationId:n.current}),[n]),E=(0,Q.useCallback)((e,t,n)=>{let r=_().sessions[e];if(n&&r?.messages!==n.messages&&!Fn(r))return!1;let i=t.hasMore&&Nn(r?.messages??[],t.messages)>0;return _().mergeCommittedFromServer(e,t.messages,t.hasMore,n?.completedRunId,n?.recoveringRunId),t.name!==void 0&&_().patchSessionMeta(e,{name:t.name||null}),T(e)&&(i||(b.current=t.nextBeforeCursor??null)),!0},[T]),D=(0,Q.useCallback)(async(e,r=0,a)=>{let s=i(`session_load`),c=async(e,r,i)=>{let a=r===0&&!i;y.current++,o.current=!0,s(`request_started`);let d=a&&Jn(_().sessions[e]?.historyStatus);d&&_().setSessionHistoryStatus(e,`loading`);let f=a?Promise.resolve().then(()=>t.current.loadSessionAgentConfig(e)).then(e=>(s(`config_received`),{config:e}),e=>({error:e})):void 0;try{let n={messages:_().sessions[e]?.messages},{messages:o,hasMore:c,name:l,nextBeforeCursor:u}=await t.current.loadSession(e,r,i,h,n.messages);if(s(`history_received`),a){if(!E(e,{messages:o,hasMore:c,name:l,nextBeforeCursor:u},n))return _().sessions[e]?.messages;if(!T(e))return o;s(`history_committed`);let t=await f;if(`error`in t)throw t.error;let r=t.config;return T(e)?(zr(e,r),S(r.model),o):o}if(!T(e))return;b.current=u??null,_().prependHistoryMessages(e,o,c);return}catch(a){if(s(`failed`),n.current&&!T(e))return;if(r===0&&!i){b.current=null;let r=a instanceof Error?a.message:`Failed to load session`;_().setShellError(/^HTTP 404\b/.test(r)?JSON.stringify(Ri(r)):`Failed to load session`);let i=HA(n.current);if(i&&i===e)return;let o=await t.current.loadSessions().catch(()=>[]),s=o.filter(e=>(e.messageCount??0)>0)[0]??o[0];if(s)return l(s.key,!0),await c(s.key,0,null);{b.current=null;let e=u();hj({sessionMgr:t.current,agentId:e,currentConversationId:null,routeConversationId:null,navigateToSession:l,replaceNavigate:!0,onOpened:e=>{_().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:null}),C(e)}})}}return}finally{y.current--,o.current=y.current>0,s(`settled`),d&&_().sessions[e]?.historyStatus===`loading`&&_().setSessionHistoryStatus(e,`ready`)}};return v.current.run(e,()=>c(e,r,a))},[n,T,r,a,o,l,S,u,t,h,E]),O=(0,Q.useCallback)(async()=>{let e=_().focusedConversationId;if(!(!e||_().loadingMore||!g)){_().setLoadingMore(!0);try{await D(e,s.current,b.current)}finally{_().setLoadingMore(!1)}}},[g,D,s]),k=(0,Q.useCallback)(async(e,n)=>{if(!f)throw Error(`No active session`);let r=_().sessions[f];if(r?.modelConfigSaving)throw Error(`Model configuration is being saved`);if(!(r?.model===e&&n!==void 0&&r.thinkingLevel===n)){_().patchSessionMeta(f,{modelConfigSaving:!0});try{if(_().setShellError(null),n===void 0){let t=(await Wi()).find(t=>t.id===e);if(t?.thinking){let i=ri(li(),p)?.thinkingByModel?.[e];n=ui(t.thinking,r?.thinkingLevel,i)}}let i=h?await t.current.patchTaskConversationModel(h,e,n,r?.configVersion):await t.current.patchSessionAgentConfig(f,{model:e,thinkingLevel:n,configVersion:r?.configVersion});zr(f,i),ai(p,{modelRef:i.model,thinkingLevel:i.thinkingLevel}),i.model!==r?.model&&S(i.model)}catch(e){let n=e instanceof Error?e.message:`Failed to update model configuration`;_().setShellError(n);let r=await t.current.loadSessionAgentConfig(f).catch(()=>null);throw r&&zr(f,r),e}finally{_().patchSessionMeta(f,{modelConfigSaving:!1})}}},[f,p,h,t,S]);return{refreshModelThinkingSupport:S,pollSessionNameAfterTurn:w,applyLoadedSessionSnapshot:E,loadSessionById:D,loadMoreMessages:O,onSessionModelChange:k,onSessionThinkingLevelChange:(0,Q.useCallback)(async e=>{let t=f?_().sessions[f]?.model:void 0;t&&await k(t,e)},[f,k]),onSessionWorkingDirectoryChange:(0,Q.useCallback)(async e=>{let n=e.trim();if(!(!f||!n))try{_().setShellError(null),await t.current.patchSessionAgentConfig(f,{workingDirectory:n}),await C(f)}catch(e){throw _().setShellError(e instanceof Error?e.message:`Failed to update working directory`),e}},[C,f,t]),createNewSession:(0,Q.useCallback)(async e=>{_().setShellError(null);let n=u(),r=ri(li(),n??`main`);await hj({sessionMgr:t.current,agentId:n,currentConversationId:f,routeConversationId:f,forceNew:e?.forceNew,temporary:e?.temporary,executionMode:e?.executionMode,projectId:e?.projectId===void 0?m:e.projectId,initialAgentConfig:r?{model:r.modelRef,...r.thinkingLevel?{thinkingLevel:r.thinkingLevel}:{}}:void 0,navigateToSession:l,onOpened:e=>{d(),b.current=null,_().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:null}),C(e)}})},[d,l,u,m,f,t,C]),resetCurrentSession:(0,Q.useCallback)(async()=>{if(f){_().setShellError(null);try{await t.current.resetSession(f),d(),b.current=null,_().setCommittedSnapshot(f,{messages:[],hasMore:!1,name:null}),C(f)}catch(e){_().setShellError(e instanceof Error?e.message:`Failed to reset session`)}}},[C,f,d,t])}}function Dj(e){return new Promise(t=>{Promise.resolve().then(()=>e(()=>t(!0))).then(()=>t(!1),()=>t(!1))})}function Oj(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 kj(e){return e!==`suspended`}function Aj(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=()=>Sr.getState(),h=()=>{m().sessions[t]?.progress?.stage.startsWith(`model_`)&&m().setSessionProgress(t,null)},g=e=>{let n=e?.runId,r={messages:m().sessions[t]?.messages,completedRunId:e?.terminal?n:void 0,recoveringRunId:e?.terminal?void 0:n};return l.current.loadSession(t,0,void 0,void 0,r.messages).then(i=>{!p()||e?.signal.aborted||u(t,i,r)===!1||n&&m().sessions[t]?.messages.some(e=>e.role===`assistant`&&e.turnId===n&&e.content.some(e=>e.type===`text`&&e.text.trim()&&e.text.trim()!==`NO_REPLY`))&&vr(n,`history`)}).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)xr(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&&Un.setResumeRunId(t,null),m().setSessionFlags(t,{sending:!1,streaming:!1}),m().setSessionProgress(t,null),kj(e)&&f.dismissClarifyForSession(t),g()},w={onTextSurface:e=>{r(),m().mutateSessionStreaming(t,t=>{t.textSurface=e})},onReplayGap:g,onUserMessage:e=>{if(e.clientMessageId)b();else if(!n(t))return;m().appendUserMessageIfMissing(t,e)},onStreamStart:(e,n,i)=>{zp(t),r(),i&&m().updateSessionMessages(t,t=>yr([...t,{role:`task`,content:[],taskTrigger:i,turnId:e,timestamp:Date.now()}])),m().updateSessionMessages(t,t=>sr(t,e)),m().mutateSessionStreaming(t,t=>{t.turnId=e,n&&(t.startsNewBubble=!0)}),m().setSessionFlags(t,{streaming:!0})},onToken:(e,a,o)=>{h(),r(),m().mutateSessionStreaming(t,t=>{Kn(t.content,e,a,{offset:o,reconcileHydratedSegment:i})}),n(t)&&m().setSessionFlags(t,{streaming:!0})},onAssistantMessageEnd:(e,n,i)=>{r(),m().mutateSessionStreaming(t,t=>{rr(t.content,e,n),i&&(t.usage=i)})},onThinking:(e,n,i)=>{h(),r(),m().mutateSessionStreaming(t,t=>{!n&&e===``?Wn(t.content):qn(t.content,e,n,i)})},onThinkingEnd:e=>{r(),m().mutateSessionStreaming(t,t=>{ir(t.content,e)})},onToolStart:(e,n,i,a,o,s)=>{h(),r(),m().mutateSessionStreaming(t,t=>{Xn(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=>{Hn(t.content,e,n,i,a,o,s,c)})},onToolUpdate:(e,n,i)=>{r(),m().mutateSessionStreaming(t,t=>{jr(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=>{jn(t.content,e)}),n(t)&&m().setSessionFlags(t,{streaming:!0})},onReviewStart:e=>{r(),m().mutateSessionStreaming(t,t=>{Bn(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=>{Vn(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=C(y.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=>zr(t,e)).catch(()=>{}).finally(()=>m().patchSessionMeta(t,{modelConfigSaving:!1}))},onResult:({status:e})=>{b();let r=n(t);if(Un.takeUserAborted(t)||e===`cancelled`){Hp(t),r?d(t,e):S(e);return}if(e===`error`){if(Vp(t,!r),!r){S(e);return}d(t,e),g();return}if(e===`suspended`?Up(t):Bp(t,!r),!r){S(e);return}d(t,e)},onError:e=>{b();let r=n(t);if(Vp(t,!r),!r){S(`error`);return}d(t,`error`),s&&Un.setResumeRunId(t,null),m().setSessionFlags(t,{sending:!1,streaming:!1}),m().setSessionProgress(t,null),c(e),f.dismissClarifyForSession(t)}};return Object.fromEntries(Object.entries(w).map(([e,t])=>[e,(...e)=>{if(p())return Reflect.apply(t,void 0,e)}]))}function jj(e){return Vr(e)?.streamingMsg??null}function Mj(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:m,pollSessionNameAfterTurn:h}=e,g=()=>Sr.getState(),_=e=>g().setShellError(e),y=()=>g().setShellError(null),b=(0,Q.useCallback)((e,t)=>{if(!u(e))return;let n=jj(e),r=null;if(n){let e=Gn(n,Date.now());e.runStatus=t,Qn(e.content,t===`success`),ir(e.content),t!==`suspended`&&Mn(e.content,t===`success`),Kr(e.content),e.completedAt=t&&t!==`suspended`?Date.now():void 0,r=zn(e)}r&&ar(r)?g().finalizeStreamingTurn(e,r):g().clearStreamingState(e),o.current=!1,s.current=!1,Un.resetRunTracking(e),(!t||kj(t))&&d.dismissClarify(),h(),window.setTimeout(()=>{!u(e)||o.current||s.current||p(e,0)},400)},[o,s,d.dismissClarify,d.pendingFollowUpsRef,h,p,u]),x=(0,Q.useCallback)(async(e,t)=>{if(!u(e)||Un.isSubmittingFor(e))return;let r=v.getState().conversationId,i=()=>v.getState().conversationId===r,a=Un.getGeneration(e),l=g().sessions[e]?.streamingMsg,m=g().sessions[e]?.messages.findLast(e=>e.role===`user`)?.clientSubmissionId,h=await fr(e);if(!i()||Un.getGeneration(e)!==a||Un.isSubmittingFor(e))return;if(!h){let t=g().sessions[e]?.streamingMsg;if(t?.pendingResponseStatus||t&&t!==l||Un.isStreamingFor(e))return;let n=Un.getResumeRunId(e);n&&Un.reconcileInactive(e,n),g().clearStreamingState(e,{preservePendingResponse:!0}),Hp(e);return}let y=()=>{let t=g().sessions[e]?.streamingMsg,n=g().sessions[e]?.messages.findLast(e=>e.role===`user`)?.clientSubmissionId;return!i()||Un.getGeneration(e)!==a||Un.isSubmittingFor(e)||!!(n&&n!==m)||!!(Ar(e)&&Ar(e)!==h)||!!(t?.turnId&&t.turnId!==h&&t.turnId!==l?.turnId)||!!(t?.pendingResponseStatus&&t!==l)};if(y()||Un.isTrackingRun(e,h))return;let x=()=>{let t=g().sessions[e]?.streamingMsg;!t?.turnId||t.turnId===h||t.turnId!==l?.turnId||(ar(t)?g().finalizeStreamingTurn(e,zn(t)):g().clearStreamingState(e))},S=t??tr(e),C=Vr(e)?.hasMore??!1;try{let t=await c.current.loadSession(e,0,void 0,n,g().sessions[e]?.messages);if(y()||Un.isTrackingRun(e,h))return;x(),g().mergeCommittedFromServer(e,t.messages,t.hasMore),S=t.messages,C=t.hasMore}catch{}if(y()||Un.isTrackingRun(e,h))return;x(),a=Un.advanceGeneration(e),Un.setUserAborted(e,!1),Un.setResumeRunId(e,h),o.current=!0,s.current=!0,g().seedSessionIfEmpty(e,S,!0,!0,C),g().setSessionFlags(e,{sending:!0,streaming:!0}),g().setSessionProgress(e,null),zp(e);let w=!1,T=l?.turnId!==h||!ar(l),E=T?S.findLast(e=>e.turnId===h&&e.clientMessageId&&!e.pendingSteer)?.clientMessageId:void 0;if(E){let t=YA(S,h);g().applyHydratedTail(e,t?.messagesWithoutTail??S,t?.tail??null),t||g().mutateSessionStreaming(e,e=>{e.turnId=h}),w=!0}let D=()=>{if(w||!u(e))return;w=!0;let t=YA(tr(e),h);t&&g().applyHydratedTail(e,t.messagesWithoutTail,zn(t.tail))},O=()=>{g().clearStreamingState(e),Un.getResumeRunId(e)===h&&Un.setResumeRunId(e,null),u(e)&&(o.current=!1,s.current=!1)};try{let t=Aj({chatId:e,shouldApplyStreamUpdate:u,isCurrentRun:()=>i()&&Un.getGeneration(e)===a,beforeAssistantDelta:D,reconcileHydratedAssistantText:!0,setStreamingOnStreamStart:!1,clearResumeRunIdOnBackgroundTerminal:!0,clearResumeRunIdOnVisibleError:!0,setError:_,sessionMgrRef:c,applyLoadedSessionSnapshot:f,finalizeMessage:b,fq:d}),n=await Un.senderFor(e).resume(h,e,t,{replayFromStart:T,...E?{afterSteerId:E}:{}});if(!i()||Un.getGeneration(e)!==a)return;n||(Hp(e),O(),await p(e,0).catch(()=>void 0))}catch(t){if(!i()||Un.getGeneration(e)!==a)return;t.name!==`AbortError`&&console.error(`[chat] resume failed:`,t),Hp(e),O()}finally{Un.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&&!Un.isStreamingFor(c))return!1;let l=e.trim();if(n&&ls(l))return _(`A task has one continuous conversation.`),!1;if(Yo(l)&&!t?.length){await m();return}return await d.addPendingFollowUp(e,t,i,void 0,!0),!0},[o,s,a,d.addPendingFollowUp,m,n]),C=(0,Q.useCallback)(async(e,a,l,h,x,S,C,w,T)=>{if(!t||!u(t)||!e.trim()&&!a?.length&&!h?.length||o.current||s.current||Un.isStreamingFor(t))return!1;let E=e.trim();if(n&&ls(E))return _(`A task has one continuous conversation.`),!1;if(Yo(E)&&!a?.length){await m();return}let D=i?l??r:`off`,O=t,k=Un.advanceGeneration(O),A=v.getState().conversationId,j=()=>v.getState().conversationId===A&&Un.getGeneration(O)===k,M=crypto.randomUUID(),N=`assistant-stream:${O}:${M}`,P=tr(O),F=w?P.filter(e=>e.clientSubmissionId!==w):P,I=x?F.findIndex(e=>Nr(e)===x):-1;if(x&&I<0)return!1;Un.setUserAborted(O,!1),o.current=!0,s.current=!1,y(),d.dismissClarify();let L=I>=0?F.slice(0,I):F,R=Hr(e)??void 0,z=new Map(h?.flatMap(e=>e.refId?[[e.refId,e.title]]:[])??[]),B=R?nr(R,e=>z.get(e)):e,V=[...L,{role:`user`,content:B?[{type:`text`,text:B}]:[],userTurnDocument:R,deliveryStatus:`sending`,clientSubmissionId:M,pendingAppContext:S===void 0?void 0:structuredClone(S),attachments:a,contextRefs:h?.map(e=>({refId:e.refId,kind:e.kind,sourceId:e.sourceId,version:e.expectedVersion,title:e.title,fileKind:e.fileKind})),timestamp:Date.now()}];C?.(M);let H=Vr(O);if(g().initSessionSnapshot(O,{...H??{...or(),historyStatus:`ready`,hasMore:!1,streamingMsg:null,progress:null,taskPlan:null,sending:!1,streaming:!1},messages:V,hasMore:H?.hasMore??!1,streamingMsg:{role:`assistant`,content:[],timestamp:Date.now(),renderKey:N,pendingResponseStatus:`sending`},progress:null,sending:!0,streaming:!1}),zp(O),!H?.name?.trim()&&B.trim()){let e=Pp(B.trim());e&&(g().patchSessionMeta(O,{name:e}),Fp(O,e))}let U=e=>{g().updateSessionMessages(O,t=>Oj(t,M,e))};return Dj(async t=>{let r=!1;try{let i=Aj({chatId:O,shouldApplyStreamUpdate:u,isCurrentRun:j,beforeAssistantDelta:()=>{},reconcileHydratedAssistantText:!1,setStreamingOnStreamStart:!0,clearResumeRunIdOnBackgroundTerminal:!1,clearResumeRunIdOnVisibleError:!1,setError:_,sessionMgrRef:c,applyLoadedSessionSnapshot:f,finalizeMessage:b,fq:d});i.onInputAccepted=()=>{r=!0,U(`accepted`),j()&&g().setPendingResponseStatus(O,`waiting`),t()},await Un.senderFor(O).send(e,O,a,D,i,n,x,h,S,T)}catch(e){if(!j())return;if(e.name!==`AbortError`)g().clearStreamingState(O),Hp(O),u(O)&&_(e instanceof Error?e.message:String(e)),x&&p(O,0);else{Hp(O);let e=Vr(O)?.streamingMsg;e?.renderKey===N&&e.pendingResponseStatus&&g().clearStreamingState(O)}}finally{j()&&(r||U(`failed`),u(O)&&(o.current=!1,s.current=!1),g().setSessionFlags(O,{sending:!1}),Un.releaseIdleSender(O))}})},[t,r,i,o,s,u,c,f,b,d.dismissClarify,m,n,p]),w=(0,Q.useCallback)((e,t,n,r,i,a)=>C(t,n,r,i,e,void 0,void 0,void 0,a),[C]),T=(0,Q.useCallback)((e,t)=>{let n=a.current;if(!n||wr(n).phase!==`idle`||Un.getGeneration(n)!==e)return;let r=Un.getResumeRunId(n),i=g().sessions[n]?.streamingMsg?.turnId;r&&r!==t||i&&i!==t||(d.dismissClarify(),Un.abort(n,!1),Hp(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=Un.getGeneration(e),n=Un.getResumeRunId(e)??g().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=tr(t),r=n[e];if(!r||!Lr(r.role)||r.pendingSteer)return;if(r.deliveryStatus===`failed`){let r=[...n];r.splice(e,1),g().updateSessionMessages(t,()=>r);return}let i=br(n,e);if(i===null)return;let l=Dr(n,e),u=[...n];u.splice(e,l),g().updateSessionMessages(t,()=>u);let d=r.clientMessageId?{steerId:r.clientMessageId}:{userRoundIndex:i};c.current.deleteMessages(t,d).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=tr(t),r=n[e];if(!r||!Lr(r.role)||r.pendingSteer)return;for(let t=e+1;t<n.length;t++){let e=n[t];if(e&&Lr(e.role))return}let i=r.userTurnDocument?Rn(r.userTurnDocument):Zn(r.content),c=An(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,f=Nr(r);!d&&!f||l.current(i,c,void 0,u,f,r.pendingAppContext,void 0,d).catch(()=>{p(t,0)})},[a,o,s,p,l])}}function Nj(e){let t=(0,Z.c)(15),{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)(Lj,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]!==n||t[7]!==a?(d=()=>{let e=e=>{let t=e.detail;!n||t?.conversationId!==n||(t.enabled===!1&&Sr.getState().updateSessionMessages(n,Fj),a(n,0))};window.addEventListener(`session-agent-reaction`,e),window.addEventListener(`session-agent-reaction-preference`,e);let t=()=>{n&&a(n,0)};return window.addEventListener(`gateway-realtime-connected`,t),()=>{window.removeEventListener(`session-agent-reaction`,e),window.removeEventListener(`session-agent-reaction-preference`,e),window.removeEventListener(`gateway-realtime-connected`,t)}},f=[n,a],t[6]=n,t[7]=a,t[8]=d,t[9]=f):(d=t[8],f=t[9]),(0,Q.useEffect)(d,f);let p,m;t[10]!==s||t[11]!==r||t[12]!==i?(p=()=>{let e=e=>{if(ki(e.detail))return;let t=r.current;t&&i.current.loadSessionAgentConfig(t).then(e=>{s(t,e)}).catch(Pj)};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},m=[r,i,s],t[10]=s,t[11]=r,t[12]=i,t[13]=p,t[14]=m):(p=t[13],m=t[14]),(0,Q.useEffect)(p,m)}function Pj(){}function Fj(e){return e.map(Ij)}function Ij(e){return e.agentReaction?{...e,agentReaction:void 0}:e}function Lj(){let e=Rj;return window.addEventListener(`session-updated`,e),()=>window.removeEventListener(`session-updated`,e)}function Rj(e){let t=e.detail;!t?.key||t.name===void 0||Sr.getState().patchSessionMeta(t.key,{name:t.name||null})}function zj(e){let t=p(),{isNewRoute:n,forceNewChat:r,decodedKey:i,viewConversationId:a,routedFocusedConversationId:o,routeConversationIdRef:s,locationKey:c,locationSearch:l,locationState:u}=yj(e?.fixedConversationId),d=(0,Q.useRef)(new Ir),f=(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=Sr(e=>e.initLoading),w=Sr(e=>e.loadingMore),T=Sr(e=>e.shellError),E=a,D=ng(E),O=E?Fn(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=ZA(D,vi(Gi,Wi,{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||d.current.loadSessionAgentConfig(E).then(e=>zr(E,e)).catch(()=>void 0)},[E,A,k]),(0,Q.useEffect)(()=>{let e=e=>{let t=e.detail.conversationId;d.current.loadSessionAgentConfig(t).then(e=>zr(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:ee,resolveAgentIdForPost:te,onChatAgentChange:ne,displayAgentId:re,showChatAgentSelector:ie,currentSessionProjectId:ae}=sj({navigate:t,personal:e?.personal,conversationIdRef:xj,conversationId:S,isNewRoute:n,locationState:u,locationSearch:l}),oe=i!==void 0&&S!==i,se=!!(W&&i&&!T&&D?.historyStatus!==`ready`&&!oe),ce=(0,Q.useMemo)(()=>C&&(S==null||i===void 0),[C,S,i]),le=$A({isNewRoute:n,sessionRoutePending:oe,showSessionLoading:ce,sessionContentLoading:se,messageCount:D?.messages.length??0}),ue=n&&u?.fromAgentEditor===!0,de=(0,Q.useCallback)((e,n=!1,r)=>{let i=r??``;t({pathname:`/chat/${encodeURIComponent(e)}`,search:i},{replace:n,...ue?{state:{fromAgentEditor:!0}}:{}})},[ue,t]),fe=(0,Q.useCallback)(e=>UA({streamConversationId:e,routeConversationId:s.current}),[s]),pe=(0,Q.useCallback)(()=>{QA({sendingRef:m,streamingRef:h})},[]),G=oj({conversationId:S,personal:e?.personal,decodedKey:i,conversationIdRef:xj,sendingRef:m,streamingRef:h,modelSupportsThinking:B,thinkingLevel:R,shouldApplyStreamUpdate:fe}),me=(0,Q.useCallback)(()=>{G.clearVisibleClarify();let e=xj.current;e&&Un.resetRunTracking(e),XA(pe)},[G.clearVisibleClarify,xj,pe]),{refreshModelThinkingSupport:he,pollSessionNameAfterTurn:K,applyLoadedSessionSnapshot:ge,loadSessionById:_e,loadMoreMessages:q,onSessionModelChange:ve,onSessionThinkingLevelChange:ye,onSessionWorkingDirectoryChange:J,createNewSession:be,resetCurrentSession:xe}=Ej({sessionMgrRef:d,routeConversationIdRef:s,sendingRef:m,streamingRef:h,loadingSessionRef:f,messagesLenRef:x,thinkingSupportGenRef:g,navigateToSession:de,resolveAgentIdForPost:te,detachForNewConversation:me,conversationId:S,sessionAgentId:re,currentProjectId:ae,hasMore:N,taskId:e?.taskId}),Se=(0,Q.useCallback)(e=>{if(!WA({cacheConversationId:e,routeConversationId:s.current}))return!1;let t=Vr(e);return!t||!Fn(t)&&!pr(e)&&!Un.isStreamingFor(e)?!1:(m.current=t.sending,h.current=t.streaming,!0)},[s]),{tryResumeAgentRun:Ce,sendMessage:we,replaceLatestUserTurn:Te,interruptAndSend:Ee,abort:De,settleStoppedRun:Oe,deleteMessageRound:ke,retryUserMessageRound:Ae}=Mj({conversationId:S,taskId:e?.taskId,thinkingLevel:R,modelSupportsThinking:B,conversationIdRef:xj,sendingRef:m,streamingRef:h,sessionMgrRef:d,sendMessageRef:b,shouldApplyStreamUpdate:fe,fq:G,applyLoadedSessionSnapshot:ge,loadSessionById:_e,resetCurrentSession:xe,pollSessionNameAfterTurn:K});(0,Q.useEffect)(()=>{n&&me()},[n,me]);let je=(0,Q.useMemo)(()=>JA({viewConversationId:a,conversationId:E,messages:D?.messages??[],streamingMsg:O?D?.streamingMsg??null:null}),[a,E,D?.messages,D?.streamingMsg,O]),Me=(0,Q.useCallback)((e,t)=>{Sr.getState().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:t}),pe()},[pe]),Ne=(0,Q.useCallback)((e,t)=>{zr(e,t),he(t.model)},[he]),Pe=(0,Q.useCallback)(e=>{let t=Sr.getState();e.loading!==void 0&&t.setInitLoading(e.loading),e.error!==void 0&&t.setShellError(e.error)},[]),Fe=(0,Q.useCallback)(async t=>{try{let n=await d.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}Fe(S)},[S,n,Fe]),Nj({conversationId:S,conversationIdRef:xj,sendingRef:m,streamingRef:h,sessionMgrRef:d,loadSessionById:_e,loadTimelineById:Fe,applyAgentConfig:Ne});let Ie=Sj({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:d,resolveAgentIdForPost:te,navigateToSession:de,loadSessionById:_e,tryResumeAgentRun:Ce,restoreLiveCacheIfNeeded:Se,adoptEmptySession:Me,applyAgentConfig:Ne,patchInitUi:Pe}),Le=Cj(Ie);return(0,Q.useEffect)(()=>{Ie&&Le.error&&Sr.getState().setShellError(Le.error instanceof Error?Le.error.message:`Failed to load model configuration`)},[Ie,Le.error]),(0,Q.useEffect)(()=>{let e=e=>{let t=e.detail,n=t?.conversationId,r=t?.runId;!n||!r?.trim()||(Tr(n,r),Un.setResumeRunId(n,r),fe(n)&&(Un.isTrackingRun(n,r)||queueMicrotask(()=>{fe(n)&&(Un.isTrackingRun(n,r)||Ce(n,tr(n)))})))};return window.addEventListener(`run-started`,e),()=>window.removeEventListener(`run-started`,e)},[Ce,fe]),(0,Q.useEffect)(()=>{let e=k||A,t=_.current;if(_.current=e,!t||e)return;let n=xj.current;n&&queueMicrotask(()=>{!n||!fe(n)||Un.isStreamingFor(n)||pr(n)&&Ce(n,tr(n))})},[k,A,Ce,fe]),b.current=we,{auth:{hasToken:!!W},session:{projectPreparation:Le.preparation,conversationId:S,sessionName:P,decodedKey:i,sessionRoutePending:oe,sessionContentLoading:se,showSessionLoading:ce,conversationPhase:le,loading:C,sessionModel:Ie?Le.model:F,modelConfigReady:Ie?Le.ready:I,modelConfigSaving:L,thinkingLevel:Ie?Le.thinkingLevel:R,onSessionThinkingLevelChange:Ie?Le.onThinkingChange:ye,onSessionWorkingDirectoryChange:J,reasoningLevel:z,modelSupportsThinking:Ie?Le.modelSupportsThinking:B,effectiveWorkspacePath:V,workspaceSource:H,userContextMode:Ie?.temporary?`temporary`:U,hasMore:N,loadingMore:w,loadMoreMessages:q,onSessionModelChange:Ie?Le.onModelChange:ve,createNewSession:be,sessionManager:d.current},messages:{items:je},timeline:{items:v,refresh:Fe},stream:{error:T,streaming:k,sending:A,progress:j,taskPlan:M,sendMessage:we,replaceLatestUserTurn:Te,abort:De,settleStoppedRun:Oe,interruptAndSend:Ee,deleteMessageRound:ke,retryUserMessageRound:Ae},followUp:{composerMode:G.composerMode,control:G.control,controlPending:G.controlPending,beginEditTurn:G.beginEditTurn,cancelEditor:G.cancelEditor,restoreEditor:G.restoreEditor,markComposerHydrated:G.markComposerHydrated,resumeQueue:G.resumeQueue,sendQueuedInput:G.sendQueuedInput,addPendingFollowUp:G.addPendingFollowUp,pendingFollowUps:G.pendingFollowUps,editingFollowUpId:G.editingFollowUpId,beginEditFollowUp:G.beginEditFollowUp,cancelEditFollowUp:G.cancelEditFollowUp,commitEditFollowUp:G.commitEditFollowUp,removePendingFollowUp:G.removePendingFollowUp,movePendingFollowUp:G.movePendingFollowUp,reorderPendingFollowUp:G.reorderPendingFollowUp,steerPendingFollowUp:G.steerPendingFollowUp,steeringFollowUpId:G.steeringFollowUpId},clarify:{clarifyPrompt:G.clarifyPrompt,clarifySubmitting:G.clarifySubmitting,clarifySubmitError:G.clarifySubmitError,submitClarifyAnswer:G.submitClarifyAnswer,letAgentDecideClarification:G.letAgentDecideClarification,cancelClarification:G.cancelClarification},agents:{chatAgents:ee,displayAgentId:Ie?.agentId??re,showChatAgentSelector:ie,onChatAgentChange:ne}}}function Bj(e){let t=(0,Z.c)(15),n=v(Hj),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=Sr(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 $r(i))return;let e=await wn(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{pinned:e.status===`pinned`,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;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(l={revalidateOnFocus:!1},t[10]=l):l=t[10];let u=vi(s,c,l),{mutate:d}=u,f,p;return t[11]!==d||t[12]!==i?(f=()=>{if(!i)return;let e=e=>{let t=e.detail;if(t?.key!==i||typeof t.pinned!=`boolean`)return;let{pinned:n}=t;d(e=>e&&{...e,pinned:n},{revalidate:Vj})};return window.addEventListener(`session-updated`,e),()=>window.removeEventListener(`session-updated`,e)},p=[i,d],t[11]=d,t[12]=i,t[13]=f,t[14]=p):(f=t[13],p=t[14]),(0,Q.useEffect)(f,p),u}function Vj(e){return!e}function Hj(e){return e.conversationId}function Uj(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 Wj(e,t){return Uj(hr(e??``),t)}function Gj(e,t){return Fa(e,t)}function Kj(e){return e===`context`||e===`branch`||e===`compaction`?e:null}function qj(e){return Uj(e.preview||e.title,72)||e.kind}function Jj(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:Wj(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:Gj(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=Kj(a.kind);if(!e)continue;let o=`${a.id}:${a.kind}`;r.events.some(e=>e.key===o)||r.events.push({key:o,label:qj(a),tone:e})}return n}function Yj(e,t){return(e===1?t.toolCount_one:t.toolCount_other).replace(`{{count}}`,String(e))}function Xj(e,t){let n=e[0]?.id;for(let r of e)r.messageIndex<=t&&(n=r.id);return n}function Zj(e){let t=(0,Z.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,X.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,X.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,X.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,X.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,X.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,X.jsx)(`time`,{suppressHydrationWarning:!0,dateTime:new Date(n.timestamp).toISOString(),children:Eb(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,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,X.jsx)(rn,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),Yj(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,X.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,X.jsxs)(`span`,{className:`mt-2 flex min-w-0 flex-wrap gap-1.5`,children:[e.map($j),h.map(Qj),g>0?(0,X.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,X.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,X.jsx)(`li`,{children:(0,X.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 Qj(e){return(0,X.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,X.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current opacity-70`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`truncate`,children:e.label})]},e.key)}function $j(e){return(0,X.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,X.jsx)(rn,{className:`size-3 shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`truncate`,children:e.label})]},e.key)}function eM(e){let t=(0,Z.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=Jj(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=Xj(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,X.jsx)(Ne,{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,X.jsx)(T,{asChild:!0,children:(0,X.jsx)(qi,{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,X.jsx)(w,{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,X.jsx)(A,{className:`min-w-0 truncate text-base font-semibold text-fg`,children:i.title}),t[11]=i.title,t[12]=y);let b;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,X.jsx)(an,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=b):b=t[13];let x;t[14]===o?x=t[15]:(x=(0,X.jsx)(D,{asChild:!0,children:(0,X.jsx)(qi,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":o,children:b})}),t[14]=o,t[15]=x);let S;t[16]!==y||t[17]!==x?(S=(0,X.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,x]}),t[16]=y,t[17]=x,t[18]=S):S=t[18];let C;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,X.jsx)(Zj,{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],C=u.map(e),t[19]=m,t[20]=s,t[21]=i,t[22]=c,t[23]=u,t[24]=C}else C=t[24];let E;t[30]===C?E=t[31]:(E=(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,X.jsx)(`ol`,{className:`min-w-0`,children:C})}),t[30]=C,t[31]=E);let M;t[32]!==S||t[33]!==E?(M=(0,X.jsxs)(O,{children:[_,(0,X.jsxs)(k,{className:v,"aria-describedby":void 0,children:[S,E]})]}),t[32]=S,t[33]=E,t[34]=M):M=t[34];let N;return t[35]!==d||t[36]!==M||t[37]!==g?(N=(0,X.jsxs)(j,{open:d,onOpenChange:f,children:[g,M]}),t[35]=d,t[36]=M,t[37]=g,t[38]=N):N=t[38],N}function tM(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 nM(e){let t=(0,Z.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(oM),...m.map(aM),...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,X.jsx)(`div`,{className:`mb-1 flex min-w-0 justify-end text-xs`,children:(0,X.jsx)(`time`,{suppressHydrationWarning:!0,className:`shrink-0 tabular-nums text-fg-disabled`,dateTime:new Date(n.timestamp).toISOString(),children:Eb(n.timestamp)})}):null,t[16]=n.timestamp,t[17]=u),t[18]===n.preview?d=t[19]:(d=(0,X.jsx)(`div`,{className:`min-w-0 text-sm font-semibold leading-5 text-fg`,children:(0,X.jsx)(`span`,{className:`line-clamp-1`,children:n.preview})}),t[18]=n.preview,t[19]=d),t[20]===h?f=t[21]:(f=(0,X.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,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(rn,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`span`,{children:Yj(n.tools.length,r)})]}):(0,X.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(iM),c=m.map(rM),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,X.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,X.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,X.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 rM(e){return(0,X.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,X.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current opacity-70`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`truncate`,children:e.label})]},e.key)}function iM(e){return(0,X.jsxs)(`span`,{className:Y(`inline-flex min-w-0 max-w-[9rem] items-center gap-1.5`,e.running&&`text-accent`),children:[(0,X.jsx)(rn,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`truncate`,children:e.label})]},e.key)}function aM(e){return e.label}function oM(e){return e.label}function sM(e){let t=(0,Z.c)(44),{items:n,activeMessageIndex:r,labels:i,onSelectMessage:a}=e,o;t[0]!==n||t[1]!==i?(o=Jj(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,X.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,X.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,X.jsx)(`span`,{className:Y(`block h-0.5 rounded-full transition-[width,background-color] duration-150 ease-out`,tM({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,X.jsx)(`div`,{className:`chat-timeline-scroll flex min-h-0 w-full flex-col`,children:(0,X.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,X.jsx)(nM,{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,X.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,X.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 cM(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 lM(e){let t=cM(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 uM(e){let{enabled:t,conversationId:n,sourceContextPending:r,sourceContextFailed:i,suppressProjectContext:a,project:o,task:s}=e,c=cM(e),[l,u]=(0,Q.useState)(()=>lM(e));(0,Q.useEffect)(()=>{let e=!1,l=lM({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 $r(n);r=e?e.creation.projectId?.trim()||null:(await wn(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):xn(r),Sn(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:lM(e);return{context:d.context,status:d.status}}var dM=[Gt,Bt,ic];function fM(e){let t=(0,Z.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,X.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-2xl bg-accent-soft text-accent`,children:(0,X.jsx)(Gt,{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,X.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,X.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,X.jsx)(`div`,{className:`mt-7 grid w-full gap-3 md:grid-cols-3`,children:s.map((e,t)=>{let n=dM[t]??Gt;return(0,X.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`,Ma.transition,Ma.pressCard,Ma.focusRingPanel,Ma.disabled),children:[(0,X.jsx)(n,{className:`size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.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,X.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 pM=t({ChatPage:()=>hM}),mM=(0,Q.lazy)(async()=>({default:(await u(()=>import(`./chat-terminal-dock-Ch74AWYF.js`),__vite__mapDeps([46,1,2,5,6,47,11,48,26,27,17,18,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,4,64,65,28,29,9,66,67,68,69]))).ChatTerminalDock}));function hM({beforeSend:e,prepareSendContext:t,onRunSettled:n,composerPlaceholder:r,embeddedAttachmentHandoffId:i,draftSeed:a,sourceNoteInView:o=!1,embedded:s=!1,conversationId:c,taskId:l,personal:u=!1,personalWelcome:m,automationWorkspace:g=!1,automationTimelineEntries:_,readOnly:b=!1,onHistoryReady:x,automationExecution:S=!1,initialTurnId:T,onInitialTurnLocated:D}={}){let M=y(e=>e.language),N=C(M),P=v(e=>e.conversationId),F=p(),I=f(),{pathname:L}=I,R=u||!s&&/^\/chat(?:\/|$)/.test(L),[z,B]=d(),V=(0,Q.useRef)(null),H=(0,Q.useRef)(0),W=(0,Q.useRef)(null),[ee,te]=(0,Q.useState)(null),[ne,re]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{re(a??null)},[a]);let[ie,ae]=(0,Q.useState)(()=>!!(c&&window.localStorage.getItem(`personal-calibration:${c}`))),[oe,se]=(0,Q.useState)(null),[ce,le]=(0,Q.useState)(null),[ue,de]=(0,Q.useState)(!1),[fe,pe]=(0,Q.useState)(null),G=l?.trim()||null,{data:me}=jc(G??``),{auth:he,session:K,messages:ge,timeline:_e,stream:q,followUp:ve,clarify:ye,agents:J}=zj({fixedConversationId:c,taskId:G??void 0,personal:u}),be=I.state,xe=be?.focusClarification,Se=u?be?.personalSourceTurnId:void 0,Ce=ve.composerMode.kind===`editTurn`?ve.composerMode:null,we=Sr(e=>!!(K.conversationId&&!e.shellError&&e.sessions[K.conversationId]?.historyStatus===`ready`));(0,Q.useEffect)(()=>{we&&ge.items.length>0&&x?.()},[we,ge.items.length,x]),(0,Q.useLayoutEffect)(()=>{if(!g&&!S||!K.conversationId)return;let e=K.conversationId;return sm.setState({conversationIdOverride:e}),()=>{sm.getState().conversationIdOverride===e&&sm.setState({conversationIdOverride:null})}},[g,S,K.conversationId]);let Te=!u&&!s&&!G&&z.get(`scene`)===`find-skills`,De=g||z.get(`setup`)===`automation`,Oe=!s&&!G&&z.get(`agentSetup`)===`1`,ke=u?``:z.get(`skill`)?.trim()??``,Ae=u?``:z.get(`slash`)?.trim()??``;(0,Q.useEffect)(()=>{if(!u||!z.has(`skill`)&&!z.has(`slash`))return;let e=new URLSearchParams(z);e.delete(`skill`),e.delete(`slash`),B(e,{replace:!0})},[u,z,B]);let je=z.get(g?`chatDraft`:`draft`)??``,Me=z.get(`autoSend`)===`1`,Ne=z.get(`attachmentHandoff`),Pe=z.get(`attachmentsHandoff`),Fe=K.decodedKey??K.conversationId,[Ie,Re]=(0,Q.useState)(null),He=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(Ne){let e=qt(Ne);e&&Re(e),He.current=Fe;return}He.current!==Fe&&(He.current=Fe,Re(null))},[Ne,Fe]);let Ue=Rp(e=>e.markViewed),We=Rp(e=>Fe?e.runs[Fe]?.unread:!1);(0,Q.useEffect)(()=>{Fe&&We&&Ue(Fe)},[Fe,We,Ue]);let{data:Ge}=Bj(Fe),Ke=De||!!Ge?.identity?.customData?.automationSetup,qe=(!s||u)&&!G&&!Oe&&!Ke,Je=qe?Fe:null,Ye=(0,Q.useCallback)(()=>{H.current+=1,te({id:H.current,preserveDraft:!0,text:M===`zh`?`把视频草稿改成`:`Adjust the video draft to `})},[M]),Xe=dA(Je,M,ge.items,{chatBusy:q.streaming||q.sending,readOnly:b,onAdjust:Ye}),Ze=tA(Je,M,q.streaming||q.sending,ge.items),Qe=(0,Q.useMemo)(()=>[..._??[],...Xe.timelineEntries,...Ze],[_,Xe.timelineEntries,Ze]),$e=Se?.startsWith(`music-generation:`)||Se?.startsWith(`video-generation:`),tt=$e?Qe.findIndex(e=>e.id===Se):-1,{draft:nt,confirmDraft:rt}=Xe,it=!!Ge?.identity?.customData?.automationSetup?.automationId,at=(0,Q.useCallback)(async e=>{if(Fe)try{let t=await K.sessionManager.forkSessionAtTurn(Fe,e);window.dispatchEvent(new CustomEvent(`session-created`,{detail:{key:t.conversationId,conversationId:t.conversationId}})),Ua(`success`,N.chat.messageForkCreated),F(`/chat/${encodeURIComponent(t.conversationId)}`)}catch(e){throw Ua(`error`,e instanceof Error?e.message:N.chat.messageForkFailed),e}},[Fe,N.chat.messageForkCreated,N.chat.messageForkFailed,F,K.sessionManager]),ot=ge.items.at(-1),st=u&&!ie&&!q.streaming&&!q.sending&&ot?.role===`assistant`&&ge.items.filter(e=>e.role===`user`).length===1&&ge.items.filter(e=>e.role===`assistant`).length===1&&!ge.items.some(e=>e.role===`task`),ct=e=>{ae(!0),c&&window.localStorage.setItem(`personal-calibration:${c}`,`1`),e&&(H.current+=1,te({id:H.current,text:e}))};(0,Q.useEffect)(()=>{V.current=null},[K.conversationId]),(0,Q.useEffect)(()=>{if(!he.hasToken||!ke&&!Ae&&!je&&!(K.projectPreparation&&Pe)||Me&&!K.projectPreparation||K.showSessionLoading||K.sessionRoutePending||!K.conversationId&&!K.projectPreparation)return;let e=K.projectPreparation&&Pe?fs(Pe)??void 0:void 0,t=()=>{let e=new URLSearchParams(z);e.delete(`skill`),e.delete(`slash`),e.delete(g?`chatDraft`:`draft`),K.projectPreparation&&(e.delete(`autoSend`),e.delete(`attachmentsHandoff`));let t=e.toString();F({pathname:L,search:t?`?${t}`:``},{replace:!0})},n=(n,r)=>{V.current!==r&&(V.current=r,queueMicrotask(()=>{e?.length?Qm(n,e):(H.current+=1,te({id:H.current,text:n})),t()}))},r=uo(ke,je);if(r||e?.length){let e=`${K.conversationId}:draft:${r}`;n(r??``,e);return}if(ke){t();return}if(!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(Ae)){t();return}let i=`${K.conversationId}:slash:${Ae}`;V.current!==i&&queueMicrotask(()=>{(async()=>{try{let e=await ns(),t=Ae.toLowerCase(),n=e.find(e=>e.name.toLowerCase()===t||Array.isArray(e.aliases)&&e.aliases.some(e=>e.toLowerCase()===t));if(n){if(V.current===i)return;V.current=i,H.current+=1,te({id:H.current,text:UT(n)})}}finally{t()}})()})},[he.hasToken,g,ke,Ae,je,Me,Pe,K.projectPreparation,z,K.showSessionLoading,K.sessionRoutePending,K.conversationId,F,L]);let{scrollRef:lt,composerDockRef:ut,atBottom:dt,registerListContentRef:ft,scrollToBottom:pt,showScrollToBottom:mt,replySpaceRef:ht,reserveReplySpace:gt,onScroll:_t}=OT({hasToken:he.hasToken,showSessionLoading:K.showSessionLoading,conversationId:K.conversationId,chatMessages:ge.items,streaming:q.streaming,hasMore:K.hasMore,loadingMore:K.loadingMore,loadMoreMessages:K.loadMoreMessages});(0,Q.useEffect)(()=>{if(!g||!dt||!_?.length)return;let e=requestAnimationFrame(()=>pt(!1));return()=>cancelAnimationFrame(e)},[g,_,dt,pt]);let vt=vA({enabled:u,conversationId:K.conversationId,messages:ge.items,viewportRef:lt}),[yt,bt]=(0,Q.useState)(0),xt=(0,Q.useRef)(null),St=(0,Q.useRef)(null),Ct=(0,Q.useMemo)(()=>{let e=-1;for(let t of _e.items)typeof t.displayIndex==`number`&&Number.isFinite(t.displayIndex)&&(e=Math.max(e,t.displayIndex));return e<0?0:Math.max(0,e+1-ge.items.length)},[ge.items.length,_e.items]),wt=(0,Q.useCallback)(e=>{let t=lt.current;if(!t)return!1;let n=t.querySelector(`[data-chat-message-index="${e}"], [data-chat-timeline-index="${e}"]`);if(!n){let n=aT(t)?.reveal(e)??!1;return n&&e<ge.items.length&&bt(e),n}oT(t),e<ge.items.length&&bt(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:nT()}),!0},[ge.items.length,lt]),Tt=(0,Q.useCallback)(()=>{let e=lt.current;if(!e)return;let t=tT(e);bt(e=>e===t?e:t)},[lt]),Et=(0,Q.useCallback)(()=>{xt.current??=requestAnimationFrame(()=>{xt.current=null,Tt()})},[Tt]),Dt=(0,Q.useCallback)(()=>{_t(),Et()},[_t,Et]),Ot=(0,Q.useCallback)(e=>{let t=e-Ct;if(t<0||t>=ge.items.length){t<0&&K.hasMore&&!K.loadingMore&&(St.current=e,K.loadMoreMessages());return}St.current=null,wt(t)},[ge.items.length,wt,K.hasMore,K.loadMoreMessages,K.loadingMore,Ct]);nE({conversationId:K.conversationId,turnId:$e?void 0:Se??T,requestKey:Se?I.key:void 0,assistantOnly:!!Se,messages:ge.items,ready:we,hasMore:K.hasMore,loadingMore:K.loadingMore,loadMore:K.loadMoreMessages,reveal:wt,onLocated:D});let kt=(0,Q.useRef)(void 0),At=I.key;(0,Q.useEffect)(()=>{if(!we||tt<0||kt.current===At)return;let e=requestAnimationFrame(()=>{wt(ge.items.length+tt)&&(kt.current=At)});return()=>cancelAnimationFrame(e)},[At,tt,ge.items.length,we,wt]);let jt=IA({conversationId:K.conversationId,taskId:G,messages:ge.items,displayOffset:Ct,viewportRef:lt,onRevealDisplayIndex:Ot});(0,Q.useEffect)(()=>{let e=St.current;if(e==null)return;let t=e-Ct;if(t>=0&&t<ge.items.length){St.current=null,requestAnimationFrame(()=>wt(t));return}if(t<0&&K.hasMore&&!K.loadingMore){K.loadMoreMessages();return}(t>=ge.items.length||!K.hasMore)&&(St.current=null)},[ge.items.length,wt,K.hasMore,K.loadMoreMessages,K.loadingMore,Ct]),(0,Q.useEffect)(()=>{Et()},[ge.items.length,Et,K.conversationId,Ct]),(0,Q.useEffect)(()=>()=>{xt.current!=null&&cancelAnimationFrame(xt.current)},[]),(0,Q.useEffect)(()=>{te(null)},[K.conversationId]);let Mt=(0,Q.useCallback)(e=>{H.current+=1,te({id:H.current,text:e.prompt})},[]),Nt=!!(K.conversationId&&!K.showSessionLoading&&!K.sessionRoutePending&&K.workspaceSource!==`project`&&K.workspaceSource!==`execution_environment`&&ge.items.length===0),Pt=zo(e=>e.setAgentId);(0,Q.useEffect)(()=>{if(he.hasToken)return Pt(J.displayAgentId),()=>Pt(``)},[he.hasToken,J.displayAgentId,Pt]);let Ft=K.conversationPhase===`creating-session`,It=K.conversationPhase===`loading-history`;Tp(u&&!It?Fe:null,u);let Lt=Ft||It,Rt=It,zt=!Rt&&ge.items.length===0&&!_?.length&&!Xe.timelineEntries.length&&!Ze.length&&!q.streaming,Bt=(0,Q.useMemo)(()=>{if(q.taskPlan){let e=Fk(q.taskPlan);return e?{plan:e,changeSummary:Jk(ge.items,q.streaming)?.changeSummary??null}:null}return Jk(ge.items,q.streaming)},[ge.items,q.streaming,q.taskPlan]),Vt=(0,Q.useMemo)(()=>(K.sessionRoutePending&&K.decodedKey?K.decodedKey:K.conversationId)?K.sessionName?.trim()||N.chat.newSession:N.nav.chat,[K.conversationId,K.sessionName,K.sessionRoutePending,K.decodedKey,N.nav.chat,N.chat.newSession]),Ht=Ge?.sourceNoteId??null,Ut=MO(Fe,z.get(`projectId`)),Wt=K.projectPreparation?.project??Ut,[Gt,Kt]=(0,Q.useState)([]),[Jt,Yt]=(0,Q.useState)([]),Xt=v(e=>e.baseUrl),Zt=Fe?Hs(Xt,P,Fe):null,Qt=Vs.store(e=>Zt?e.drafts[Zt]:void 0),$t=(0,Q.useRef)(void 0),[en,tn]=(0,Q.useState)(!1);(0,Q.useLayoutEffect)(()=>{Fe&&Fe!==$t.current&&($t.current=void 0)},[Fe]),(0,Q.useEffect)(()=>{let e=!1;if(se(null),Ht)return Le(Ht).then(t=>{e||se(t?.title?.trim()||null)}).catch(()=>{e||se(null)}),()=>{e=!0}},[Ht]);let nn=oe||Ge?.sourceNoteTitle||N.chat.sourceNoteFallbackTitle,rn=uM({enabled:he.hasToken&&!!(Fe||Wt)&&!Oe&&ge.items.length===0&&!K.showSessionLoading&&!K.sessionRoutePending,conversationId:Fe,suppressProjectContext:!!(Ht||Ie||K.workspaceSource===`execution_environment`||K.workspaceSource===`session_override`||K.workspaceSource===`agent_workspace`),project:Wt,task:me}),an=(0,Q.useMemo)(()=>J.chatAgents?.items.find(e=>e.id===J.displayAgentId)??{id:J.displayAgentId},[J.chatAgents?.items,J.displayAgentId]),on=(0,Q.useMemo)(()=>xc(rn.context,N.chat.welcomeSpotlight,{contextStatus:rn.status}),[N.chat.welcomeSpotlight,rn.context,rn.status]),cn=(0,Q.useMemo)(()=>on.recommendation?{suggestionId:on.recommendation.id,contextKind:on.contextKind,prompt:on.recommendation.prompt}:null,[on]),ln=(0,Q.useRef)(0);(0,Q.useEffect)(()=>(ln.current++,()=>{ln.current++}),[c,P]);let un=(0,Q.useRef)(!1),dn=q.sending||q.streaming;(0,Q.useEffect)(()=>{let e=un.current&&!dn;un.current=dn,e&&n?.()},[n,dn]);let fn=(0,Q.useCallback)(async n=>{let r=ln.current;if(e&&!await e()||r!==ln.current)return null;if(!t)return{refs:n};let i=await t();if(r!==ln.current)return null;if(!i)return Ua(`error`,M===`zh`?`工作簿暂不可用,请检查左侧的编辑或保存状态后重试。`:`Check the workbook’s edit or save status and try again.`),null;let a=n?.find(e=>e.kind===i.kind&&e.sourceId===i.sourceId);return a?{refs:n?.map(e=>e===a?{...i,refId:a.refId}:e)}:(n?.length??0)>=5?(Ua(`warning`,N.chat.commandPalette.contextLimitReached,{max:4}),null):{refs:[...n??[],i]}},[e,M,N.chat.commandPalette.contextLimitReached,t]),pn=(0,Q.useCallback)((...[n,r,i,a,o])=>{let s=e=>{if(Qt&&(Ce||is(n)))return Sr.getState().setShellError(N.chat.pageContext.pending),!1;if(Ce)return q.replaceLatestUserTurn(Ce.turnId,n,r,i,e,o?.submittedAt);if(nt&&!r?.length&&!e?.length&&!Qt&&cA(n))return rt();let t=!1,a=q.sendMessage(n,r,i,e,void 0,Qt?.envelope,(e,n)=>{t=!0,gt(n??e),o?.onDispatched?.({clientSubmissionId:e,messageRenderKey:n})},void 0,o?.submittedAt);return t?(Zt&&Qt&&Vs.remove(Zt,Qt),!0):a};return!e&&!t?s(a):fn(a).then(e=>e?s(e.refs):!1)},[e,t,fn,Ce,q.replaceLatestUserTurn,q.sendMessage,Qt,Zt,N.chat.pageContext.pending,gt,nt,rt]),mn=jO({preparation:K.projectPreparation,conversationId:Fe,ready:K.modelConfigReady&&!Lt,onSend:pn}),hn=(0,Q.useCallback)(e=>{let t=Nr(e);if(!t||!K.conversationId)return;let n=Un.getGeneration(K.conversationId),r=Un.getResumeRunId(K.conversationId);ve.beginEditTurn(t,{text:e.userTurnDocument?Rn(e.userTurnDocument):Zn(e.content),attachments:An(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(n,r)})},[ve.beginEditTurn,q.settleStoppedRun,K.conversationId]),gn=(0,Q.useCallback)(e=>{if(ve.composerMode.kind===`editFollowUp`)ve.beginEditFollowUp(ve.composerMode.inputId);else if(ve.composerMode.kind===`editTurn`&&K.conversationId){let t=Un.getGeneration(K.conversationId),n=Un.getResumeRunId(K.conversationId);ve.beginEditTurn(ve.composerMode.turnId,e).then(e=>{e&&q.settleStoppedRun(t,n)})}},[ve.composerMode,ve.beginEditFollowUp,ve.beginEditTurn,K.conversationId,q.settleStoppedRun]),_n=ve.cancelEditor;(0,Q.useEffect)(()=>{if(!Me||!je.trim()&&!Pe||!he.hasToken||K.showSessionLoading||K.sessionRoutePending||!K.conversationId||q.sending||q.streaming)return;let e=uo(ke,je),t=Pe?fs(Pe):void 0;if(!e&&!t?.length)return;let n=`${K.conversationId}:auto-send:${e??``}:${Pe??``}`;if(V.current===n)return;V.current=n;let r=new URLSearchParams(z);r.delete(`skill`),r.delete(`slash`),r.delete(`draft`),r.delete(`autoSend`),r.delete(`attachmentsHandoff`);let i=r.toString();F({pathname:L,search:i?`?${i}`:``},{replace:!0}),pn(e??``,t??void 0)},[he.hasToken,Me,Pe,je,pn,F,L,z,K.conversationId,K.sessionRoutePending,K.showSessionLoading,ke,q.sending,q.streaming]);let vn=(0,Q.useCallback)(()=>{W.current?.reject(),W.current=null,le(null),de(!1)},[]);(0,Q.useEffect)(()=>{vn()},[vn,Ht]);let yn=(0,Q.useMemo)(()=>({title:N.chat.timelineTitle,turn:N.chat.timelineTurn,messageFallback:N.chat.timelineMessageFallback,toolCount_one:N.chat.timelineToolCount_one,toolCount_other:N.chat.timelineToolCount_other,searchedWeb:N.chat.stepSearchedWeb,searchedMemory:N.chat.stepSearchedMemory,searchedCode:N.chat.stepSearchedCode,searched:N.chat.stepSearched,readFile:N.chat.stepReadFile,runCommand:N.chat.stepRunCommand,listDirectory:N.chat.stepListDirectory,writeFile:N.chat.stepWriteFile,editFile:N.chat.stepEditFile,openUrl:N.chat.stepOpenUrl,fetchUrl:N.chat.stepFetchUrl,unknownTool:N.chat.stepUnknownTool}),[N.chat.timelineTitle,N.chat.timelineTurn,N.chat.timelineMessageFallback,N.chat.timelineToolCount_one,N.chat.timelineToolCount_other,N.chat.stepSearchedWeb,N.chat.stepSearchedMemory,N.chat.stepSearchedCode,N.chat.stepSearched,N.chat.stepReadFile,N.chat.stepRunCommand,N.chat.stepListDirectory,N.chat.stepWriteFile,N.chat.stepEditFile,N.chat.stepOpenUrl,N.chat.stepFetchUrl,N.chat.stepUnknownTool]),bn=(0,Q.useCallback)(async e=>{if(!Ht)return;W.current?.reject(),de(!1);let t=N.chat.sourceNoteAppendSourceLine.replace(`{{time}}`,new Date().toLocaleString(M));return le({heading:N.chat.sourceNoteAppendHeading,content:`${t}\n\n${e.trim()}`}),new Promise((e,t)=>{W.current={sourceNoteId:Ht,resolve:e,reject:t}})},[M,N.chat.sourceNoteAppendHeading,N.chat.sourceNoteAppendSourceLine,Ht]),xn=`${I.pathname}${I.search}`,Sn=(0,Q.useCallback)(async e=>{try{let t=await Ve(e.trim(),`web`);Ua(`success`,N.chat.messageSavedToNote,void 0,{href:et(xn,t.id)})}catch(e){throw Ua(`error`,e instanceof Error?e.message:N.notes.quickCaptureFailed),e}},[xn,N.chat.messageSavedToNote,N.notes.quickCaptureFailed]),Cn=(0,Q.useCallback)(async()=>{let e=W.current;if(!e||!ce)return;let t=ce.heading.trim()||N.chat.sourceNoteAppendHeading,n=ce.content.trim();if(n){de(!0),pe(null);try{await Be(e.sourceNoteId,n,t),window.dispatchEvent(new CustomEvent(`note-updated`,{detail:{noteId:e.sourceNoteId,source:`chat`,conversationId:Fe}})),e.resolve(),W.current=null,le(null)}catch(e){pe(e instanceof Error?e.message:N.chat.sourceNoteSaveFailed)}finally{de(!1)}}},[Fe,N.chat.sourceNoteAppendHeading,N.chat.sourceNoteSaveFailed,N.chat.sourceNoteSaveSuccess,ce]),wn=(0,Q.useCallback)(async e=>{if(!Ht)return;let t=e.trim().split(/\n+/)[0]?.replace(/^[-#*>\s]+/,``).trim()||N.chat.sourceNoteTaskFallbackTitle;try{await ze(t.slice(0,120),{sourceNoteId:Ht,sourceConversationId:Fe})}catch(e){throw Ua(`error`,e instanceof Error?e.message:N.chat.sourceNoteTaskFailed),e}},[Fe,N.chat.sourceNoteTaskFailed,N.chat.sourceNoteTaskFallbackTitle,N.chat.sourceNoteTaskSuccess,Ht]),Tn=(0,Q.useCallback)(async()=>{if(!Ht)return;let t=ln.current;if(e&&(!await e()||t!==ln.current))return;let n=N.chat.sourceNoteDigestPrompt.replace(`{{title}}`,nn);if(q.streaming||q.sending){ve.addPendingFollowUp(n),Ha({tone:`info`,status:`done`,title:N.chat.sourceNoteDigestQueued,source:M===`zh`?`笔记整理`:`Note digest`,dedupeKey:Ht?`note-digest:${Ht}`:void 0});return}q.sendMessage(n)},[e,ve,M,N.chat.sourceNoteDigestPrompt,N.chat.sourceNoteDigestQueued,Ht,nn,q]),En=(0,Q.useCallback)(async e=>{if(!(en||mn.busy)){if(K.projectPreparation){F(co(e),{state:{forceNewChat:!0,agentId:J.displayAgentId,temporary:K.userContextMode===`temporary`}});return}if(!($t.current!==void 0||q.sending||q.streaming||Lt)){$t.current=Fe,tn(!0);try{e?F(co(e),{state:{forceNewChat:!0,agentId:J.displayAgentId,temporary:K.userContextMode===`temporary`}}):await K.createNewSession({forceNew:!0,projectId:e,temporary:K.userContextMode===`temporary`})}catch(e){$t.current=void 0,Ua(`error`,N.chat.composerContext.changeFailed,{error:e instanceof Error?e.message:String(e)})}finally{tn(!1)}}}},[Fe,Lt,N.chat.composerContext.changeFailed,en,mn.busy,K.createNewSession,K.projectPreparation,K.userContextMode,q.sending,q.streaming,F,J.displayAgentId]),Dn=(0,Q.useCallback)(()=>En(null),[En]),On=(0,Q.useCallback)(async e=>{if(!(en||Lt||q.sending||q.streaming||!Nt)){tn(!0);try{await K.onSessionWorkingDirectoryChange(e)}finally{tn(!1)}}},[en,Lt,q.sending,q.streaming,Nt,K.onSessionWorkingDirectoryChange]),kn=(0,Q.useMemo)(()=>({project:Wt,draftRefs:Gt,draftAttachments:Jt,draftPage:Qt?{id:`${Qt.envelope.tabId}:${Qt.envelope.sequence}`,title:Qt.title||(M===`zh`?`当前页面`:`Current page`)}:void 0,onLeaveProject:en||mn.busy?void 0:Dn,leaveProjectLabel:N.chat.scopeRemoveProject,onDraftSourceNote:Ht?Tn:void 0,draftSourceNoteLabel:N.chat.sourceNoteDigestAction}),[en,mn.busy,Wt,Gt,Jt,Qt,M,Dn,N.chat.scopeRemoveProject,Ht,Tn,N.chat.sourceNoteDigestAction]);return he.hasToken?(q.error?zi(q.error):null)?.code===`session_not_found`?(0,X.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col overflow-hidden bg-surface-panel pt-[var(--app-chat-header-height,0px)]`,children:[(0,X.jsx)(Ck,{}),(0,X.jsx)(Sk,{chatHeadline:N.chat.sessionNotFoundTitle,chatAgents:J.chatAgents?.items??[],showChatAgentSelector:!1,chatAgentId:J.displayAgentId,onChatAgentChange:J.onChatAgentChange,chatAgentDisabled:!0}),(0,X.jsx)(`main`,{className:`mx-auto flex w-full max-w-xl flex-1 items-center px-4 py-12 sm:px-6`,children:(0,X.jsx)(`div`,{className:`w-full`,children:(0,X.jsx)(Cg,{errorText:q.error})})})]}):(0,X.jsx)(sy,{value:Ke,children:(0,X.jsxs)(`div`,{className:Y(`flex h-full min-h-0 flex-1 flex-col bg-surface-panel`,g?`overflow-clip`:`overflow-hidden`),children:[R?null:(0,X.jsx)(Ck,{}),!s||g?(0,X.jsx)(Sk,{inline:g,chatHeadline:Oe?N.agentsSettings.setupTitle:Te&&ge.items.length===0?N.skills.findTitle:Vt,chatAgents:J.chatAgents?.items??[],showChatAgentSelector:!g&&!Oe&&J.showChatAgentSelector,chatAgentId:J.displayAgentId,onChatAgentChange:J.onChatAgentChange,chatAgentDisabled:mn.busy||en||Lt&&!K.projectPreparation,conversationId:K.conversationId,hasMessages:!Lt&&ge.items.length>0,pinned:!b&&K.conversationId===Fe?Ge?.pinned:void 0,workspacePath:K.effectiveWorkspacePath,userContextMode:K.userContextMode,projectId:Wt?.id,context:kn,canChangeWorkspace:!1,workspaceDisabled:Lt||q.sending||q.streaming,onWorkspaceChange:K.onSessionWorkingDirectoryChange,prepareTerminalSession:K.projectPreparation?mn.prepareSession:void 0,terminalDisabled:!!(K.projectPreparation&&(mn.busy||!mn.allowed||mn.checking)),showContextControls:!Oe,onFindOpen:jt.show}):null,(0,X.jsxs)(`div`,{className:`relative flex min-h-0 w-full flex-1 flex-col`,children:[s&&Ht&&!o?(0,X.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,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:N.chat.sourceNoteBanner.replace(`{{title}}`,nn)}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,X.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:Tn,children:[(0,X.jsx)(Ee,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsx)(`span`,{children:N.chat.sourceNoteDigestAction})]}),(0,X.jsx)(h,{to:et(`${I.pathname}${I.search}`,Ht),className:`font-medium text-accent transition-colors hover:text-accent-fg`,children:N.chat.sourceNoteOpen})]})]})}):null,(0,X.jsxs)(`div`,{className:Y(`relative flex min-h-0 min-w-0 flex-1 flex-col`,u?`[--chat-composer-bottom-radius:1.65rem]`:`[--chat-composer-bottom-radius:1rem]`,zt?`[--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,X.jsx)(yA,{className:R?`top-[calc(var(--app-chat-header-height,0px)+0.75rem)]`:void 0,open:jt.open,query:jt.query,activeIndex:jt.activeIndex,resultCount:jt.resultCount,searching:jt.searching,truncated:jt.truncated,limitedToLoaded:jt.limitedToLoaded,inputRef:jt.inputRef,labels:N.chat.find,onQueryChange:jt.setQuery,onPrevious:jt.previous,onNext:jt.next,onClose:jt.close}),!s||g?(0,X.jsx)(`div`,{className:Y(`pointer-events-none absolute bottom-0 left-1/2 z-20 hidden w-full max-w-[calc(var(--max-width-chat-frame)+8rem)] -translate-x-1/2 xl:block`,R?`top-[var(--app-chat-header-height,0px)]`:`top-0`),children:(0,X.jsx)(`div`,{className:`pointer-events-auto absolute inset-y-0 right-0`,children:(0,X.jsx)(sM,{items:_e.items,activeMessageIndex:yt+Ct,labels:yn,onSelectMessage:Ot})})}):null,(0,X.jsxs)(`div`,{ref:lt,"data-chat-scroll-viewport":!0,"data-app-chat-scroll":R?``:void 0,className:Y(`chat-messages chat-messages--wide-viewport chat-messages--composer-fade relative min-h-0 flex-1 overflow-y-auto overflow-x-hidden [overflow-anchor:none] [scrollbar-gutter:stable_both-edges]`,zt?`chat-messages--compact-welcome pt-5 pb-2`:`py-4`),onScroll:Dt,tabIndex:0,"data-chat-find-open":jt.open?``:void 0,children:[R?(0,X.jsx)(Ck,{}):null,!s&&Ge?.parentConversationId?(0,X.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,X.jsx)(h,{to:`/chat/${encodeURIComponent(Ge.parentConversationId)}`,className:`font-medium text-accent transition-colors hover:text-accent-fg`,children:N.chat.forkedFromConversation.replace(`{{name}}`,Ge.forkedFromSessionName||N.chat.forkedFromConversationFallback)}),(0,X.jsx)(`span`,{className:`ms-2`,children:N.chat.forkSharedWorkspaceNotice})]}):null,I.state?.fromAgentEditor&&J.displayAgentId?(0,X.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,X.jsxs)(h,{to:Fs(J.displayAgentId),className:`inline-flex items-center gap-1 text-xs font-medium text-accent transition-colors hover:text-accent-fg`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,children:`←`}),N.agentsSettings.backToEditor]})}):null,(0,X.jsx)(`div`,{className:s&&!u?`px-3`:`px-3 sm:px-5 xl:px-6`,children:(0,X.jsx)(`div`,{"data-chat-message-frame":!0,className:Y(`mx-auto w-full min-w-0`,(!s||u||g)&&`max-w-[var(--max-width-chat-frame)]`),children:It?(0,X.jsxs)(`div`,{className:`flex min-h-[min(40vh,20rem)] w-full flex-col gap-10 py-8`,"aria-busy":`true`,children:[(0,X.jsx)(`div`,{className:`flex justify-end`,children:(0,X.jsx)(sn,{className:`h-11 w-[min(70%,22rem)] rounded-2xl`})}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(sn,{className:`h-4 w-24`}),(0,X.jsx)(sn,{className:`h-4 w-[min(82%,36rem)]`}),(0,X.jsx)(sn,{className:`h-4 w-[min(74%,32rem)]`}),(0,X.jsx)(sn,{className:`h-4 w-[min(48%,22rem)]`})]}),(0,X.jsx)(`div`,{className:`flex justify-end`,children:(0,X.jsx)(sn,{className:`h-11 w-[min(62%,18rem)] rounded-2xl`})})]}):(0,X.jsxs)(X.Fragment,{children:[K.loadingMore?(0,X.jsx)(`div`,{className:`mb-3 text-center text-xs text-fg-muted`,children:N.chat.loadOlder}):null,Ke&&!g&&Fe?(0,X.jsx)(Cs,{conversationId:Fe,language:M,running:q.streaming||q.sending}):null,Ke&&!g&&ge.items.length>0?(0,X.jsx)(h,{className:`mb-4 inline-block rounded-md px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover`,to:`/automations`,children:M===`zh`?`← 定时任务`:`← Scheduled tasks`}):null,!s&&G?(0,X.jsx)(`div`,{className:`hidden md:block`,children:(0,X.jsx)(tl,{taskId:G})}):null,null,null,!s&&Fe?(0,X.jsx)(U,{eventType:`session.transcript.updated`,source:`sessions`,payloadKey:`conversationId`,payloadValue:Fe,className:`mb-6`}):null,(0,X.jsx)(mT,{scrollRef:lt,messages:ge.items,timelineEntries:Qe,personal:u,authToken:P??void 0,conversationId:K.decodedKey??K.conversationId,projectId:Wt?.id,streaming:q.streaming,sending:q.sending,progress:q.progress,runError:q.error,reasoningLevel:K.reasoningLevel,showAssistantWorkLog:!0,registerListContentRef:ft,replySpaceRef:ht,onPickWelcomePrompt:Mt,welcomeSpotlight:on,welcomeOverlay:u&&m?(0,X.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,X.jsx)(`h2`,{className:`text-2xl font-semibold`,children:M===`zh`?`你好${m.addressAs?`,${m.addressAs}`:``}。我们从哪里开始?`:`Hello${m.addressAs?`, ${m.addressAs}`:``}. Where should we start?`}),(0,X.jsx)(`p`,{className:`max-w-xl text-sm leading-relaxed text-fg-muted`,children:m.opening??(M===`zh`?`想讨论问题、整理思路或推进工作,都可以直接说。`:`Bring a question, an idea, or work to move forward.`)}),(0,X.jsx)(`button`,{type:`button`,disabled:K.sessionRoutePending||K.showSessionLoading,className:`min-h-11 rounded-lg border border-edge px-3 py-2 text-left text-sm text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,onClick:()=>{H.current+=1,te({id:H.current,text:N.chat.personalStarterPrompt})},children:N.chat.personalStarterPrompt})]}):Ke?(0,X.jsxs)(`div`,{className:`mx-auto max-w-xl px-4 py-10 text-center`,children:[(0,X.jsx)(`h2`,{className:`text-xl font-semibold text-fg`,children:it?M===`zh`?`想怎么调整这个任务?`:`What would you like to change?`:M===`zh`?`你想安排什么任务?`:`What would you like to schedule?`}),(0,X.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:it?M===`zh`?`直接说要改的内容、时间,或告诉我暂停、恢复。`:`Change what it does or when it runs, or ask to pause or resume.`:M===`zh`?`说说要做的事,时间和细节我们一起确定。`:`Tell us what to do. We’ll work out the timing and details together.`}),g?null:(0,X.jsx)(h,{className:`mt-4 inline-block text-xs text-fg-muted hover:text-fg`,to:`/automations`,children:M===`zh`?`← 返回定时任务`:`← Back to scheduled tasks`})]}):Oe?(0,X.jsx)(fM,{agentName:an.name?.trim()||J.displayAgentId,messages:N.agentsSettings,disabled:K.sessionRoutePending||K.showSessionLoading,onPick:e=>{H.current+=1,te({id:H.current,text:e})}}):Te?(0,X.jsx)(oE,{sk:N.skills,disabled:K.sessionRoutePending||K.showSessionLoading,onPick:e=>{H.current+=1,te({id:H.current,text:uo(`find-skills`,e)})}}):void 0,compactWelcome:s,onDeleteRound:G?void 0:q.deleteMessageRound,onRetryUserMessageRound:G?void 0:q.retryUserMessageRound,deleteRoundDisabled:q.streaming||q.sending,onEditUserMessage:G?void 0:hn,editLatestUserOnly:!0,editRequiresTurnId:!0,onSaveAssistantAsNote:Sn,onSaveAssistantToSourceNote:Ht?bn:void 0,onExtractAssistantTask:Ht?wn:void 0,onForkAssistantTurn:!G&&Ge?.sessionType===`chat`?at:void 0,trailingContent:st?(0,X.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,X.jsx)(`p`,{className:`text-fg-muted`,children:M===`zh`?`这个回答合适吗?点选后可以在输入框修改,再发给我。`:`Did that response work for you? Pick an adjustment, edit it, then send.`}),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[[[M===`zh`?`再短一点`:`Make it shorter`,M===`zh`?`这次回答再短一点。`:`Please make this answer shorter.`],[M===`zh`?`更温和一点`:`A little gentler`,M===`zh`?`这次回答的语气更温和一点。`:`Please make this answer a little gentler.`]].map(([e,t])=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>ct(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,X.jsx)(`button`,{type:`button`,onClick:()=>ct(),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:M===`zh`?`这样就好`:`Looks good`})]})]}):null},Fe)]})})})]}),(0,X.jsx)(`div`,{ref:ut,className:`pointer-events-none absolute inset-x-0 bottom-0 z-10`,children:(0,X.jsx)(`div`,{className:s&&!u?`px-3`:`px-3 sm:px-5 xl:px-6`,children:(0,X.jsxs)(`div`,{"data-chat-composer-frame":!0,"data-primary-chat-composer":!s||void 0,className:Y(`pointer-events-auto relative mx-auto w-full min-w-0 pb-[var(--chat-composer-bottom-space)]`,(!s||u||g)&&`max-w-[calc(var(--max-width-chat-frame)+14px)]`,zt?`pt-2.5`:`pt-2 sm:pt-4`),children:[(0,X.jsx)(ST,{visible:!K.showSessionLoading&&mt,onClick:()=>pt(!0),running:q.streaming||q.sending}),(0,X.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:!s||g?(0,X.jsx)(eM,{items:_e.items,activeMessageIndex:yt+Ct,labels:yn,openLabel:N.chat.timelineOpen,closeLabel:N.chat.timelineClose,currentLabel:N.chat.timelineCurrent,onSelectMessage:Ot}):null}),(0,X.jsx)(cp,{prompt:ye.clarifyPrompt,focusRequestKey:xe&&xe===ye.clarifyPrompt?.requestId?I.key:void 0,submitting:ye.clarifySubmitting,submitError:ye.clarifySubmitError,labels:N.chat,onSubmit:ye.submitClarifyAnswer,onAgentDecide:ye.letAgentDecideClarification,onCancel:ye.cancelClarification}),Bt?(0,X.jsx)(jk,{plan:Bt.plan,changeSummary:Bt.changeSummary,isStreaming:q.streaming,labels:{heading:N.chat.planHeading,stepProgress:N.chat.planStepProgress,completedProgress:N.chat.planCompletedProgress,finished:N.chat.planFinished,ended:N.chat.planEnded,planned:N.chat.planPlanned,filesChangedOne:N.chat.planFilesChanged_one,filesChangedOther:N.chat.planFilesChanged_other}}):null,Te&&ge.items.length>0?(0,X.jsx)(`div`,{className:`mb-2 text-right`,children:(0,X.jsx)(h,{to:`/capabilities/skills`,className:`text-xs text-accent-fg hover:underline`,children:N.skills.findBack})}):null,(0,X.jsx)(eE,{}),(0,X.jsx)(iE,{conversationId:K.conversationId,active:q.streaming||q.sending}),(0,X.jsx)(TO,{personal:u,addActions:qe&&!b?{label:M===`zh`?`添加附件或操作`:`Add attachments or actions`,items:[{kind:`video`,label:M===`zh`?`生成视频`:`Generate video`,onSelect:()=>{H.current+=1,te({id:H.current,preserveDraft:!0,text:M===`zh`?`帮我生成一段视频:`:`Generate a video: `})}},{kind:`music`,label:M===`zh`?`创作音乐`:`Create music`,onSelect:()=>{H.current+=1,te({id:H.current,preserveDraft:!0,text:M===`zh`?`帮我做一段轻快的纯音乐,适合旅行视频。`:`Make an upbeat instrumental track for a travel video.`})}}]}:void 0,nextTurnSuggestionsEnabled:!q.streaming,onPersonalSendDispatched:u?vt:void 0,placeholder:r??(u?q.streaming||q.sending?N.chat.inputPlaceholderSteering:M===`zh`?`发消息给「${m?.name||`Personal AI`}」…`:`Message ${m?.name||`Personal AI`}…`:Oe?N.agentsSettings.setupComposerPlaceholder:Te?N.skills.findPlaceholder:void 0),composerContext:!Oe&&!s&&!G&&!Ce&&!Rt&&ge.items.length===0?{project:Wt,disabled:en||mn.busy||Lt&&!K.projectPreparation,directoryStatus:K.projectPreparation?(0,X.jsx)(kO,{composer:mn}):void 0,workspacePath:K.effectiveWorkspacePath,canChangeWorkspace:Nt,onProjectChange:En,onWorkspaceChange:On}:void 0,contextRefs:Gt,pageContextPreview:Qt&&Zt?(0,X.jsx)(EO,{draft:Qt,disabled:q.sending,waiting:q.streaming,onRemove:()=>Vs.remove(Zt,Qt)}):void 0,setContextRefs:Kt,maxContextRefs:t?4:void 0,onDraftAttachmentsChange:Yt,disabled:b||It||mn.busy||en,sendDisabled:ve.controlPending||ve.control.phase===`stopping`||b||!K.modelConfigReady||!K.projectPreparation&&Lt||!!(K.projectPreparation&&!mn.allowed)||K.modelConfigSaving||mn.busy||en,sending:q.sending,streaming:q.streaming,conversationId:K.conversationId,embeddedAttachmentHandoffId:i,attachmentHandoffReady:(!s||u||!!i)&&!G&&!b&&(!!K.projectPreparation||!!(K.conversationId&&!Lt)),unboundDraftKey:K.conversationId?void 0:JSON.stringify([L,z.get(`projectId`)]),getDraftHandoffTarget:mn.getDraftHandoffTarget,prepareContextSession:K.projectPreparation?mn.prepareSession:void 0,welcomeDraftSeed:ne??ee,welcomeSuggestion:!Te&&zt?cn:null,onAcceptWelcomeSuggestion:Mt,thinkingLevel:K.thinkingLevel,modelSupportsThinking:K.modelSupportsThinking,onThinkingChange:K.onSessionThinkingLevelChange,onSend:mn.send,composerMode:ve.composerMode,onRestoreEditor:ve.restoreEditor,onComposerHydrated:ve.markComposerHydrated,onReacquireEdit:gn,inputControl:ve.control,onResumeQueue:()=>void ve.resumeQueue().catch(()=>{}),editingUserTurnId:Ce?.turnId,onCancelUserMessageEdit:_n,onAbort:()=>void q.abort().catch(()=>{}),onAddPendingFollowUp:async(n,r,i,a,o)=>{let s=e||t?await fn(i):{refs:i};if(!s)throw Error(t?M===`zh`?`工作簿还未就绪,请重试。`:`The workbook is not ready. Try again.`:M===`zh`?`请先保存笔记,再发送消息。`:`Save the note before sending.`);await ve.addPendingFollowUp(n,r,s.refs,Qt?.envelope,a,o),Zt&&Qt&&Vs.remove(Zt,Qt)},onSteeringInterrupt:Qt?void 0:async(n,r,i)=>{let a=e||t?await fn(i):{refs:i};return a?q.interruptAndSend(n,r,void 0,a.refs):!1},pendingFollowUps:ve.pendingFollowUps,editingFollowUpId:ve.editingFollowUpId,onBeginEditFollowUp:ve.beginEditFollowUp,onCancelEditFollowUp:ve.cancelEditFollowUp,onCommitEditFollowUp:async(e,n,r,i,a)=>{let o=t?await fn(a):{refs:a};return o?ve.commitEditFollowUp(e,n,r,i,o.refs):!1},onPendingFollowUpRemove:ve.removePendingFollowUp,onPendingFollowUpMove:ve.movePendingFollowUp,onPendingFollowUpReorder:ve.reorderPendingFollowUp,onPendingFollowUpSteer:e=>void ve.steerPendingFollowUp(e).catch(()=>{}),onPendingFollowUpSend:e=>void ve.sendQueuedInput(e).catch(()=>{}),steeringFollowUpId:ve.steeringFollowUpId,sessionModel:K.sessionModel,showModelSelector:!u,onModelChange:K.onSessionModelChange,modelDisabled:Lt&&!K.projectPreparation||mn.busy||K.modelConfigSaving,onChatAgentChange:!u&&!Oe&&!G&&J.showChatAgentSelector?J.onChatAgentChange:void 0,currentAgentId:J.displayAgentId,voiceAgentName:u&&m?m.name:an.name,voiceTaskId:G??void 0,prepareVoiceSession:K.projectPreparation?mn.prepareSession:void 0})]})})})]})]}),(!s||g)&&Fe&&window.electronAPI?.terminal?(0,X.jsx)(Q.Suspense,{fallback:null,children:(0,X.jsx)(mM,{conversationId:Fe},Fe)}):null,(0,X.jsx)(j,{open:ce!==null,onOpenChange:e=>{!e&&!ue&&vn()},children:(0,X.jsxs)(O,{children:[(0,X.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[1px]`}),(0,X.jsxs)(k,{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,X.jsxs)(`div`,{className:`shrink-0 border-b border-edge-subtle px-5 py-4`,children:[(0,X.jsx)(A,{className:`text-base font-semibold text-fg`,children:N.chat.sourceNoteSaveDialogTitle}),(0,X.jsx)(E,{className:`mt-1 text-sm text-fg-muted`,children:N.chat.sourceNoteSaveDialogDescription.replace(`{{title}}`,nn)})]}),(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-5 py-4`,children:[fe?(0,X.jsxs)(`p`,{className:`rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-sm text-danger`,role:`alert`,children:[N.chat.sourceNoteSaveFailed,`: `,fe]}):null,(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium text-fg`,children:[(0,X.jsx)(`span`,{children:N.chat.sourceNoteSaveDialogHeadingLabel}),(0,X.jsx)(`input`,{value:ce?.heading??``,onChange:e=>le(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:ue})]}),(0,X.jsxs)(`label`,{className:`flex min-h-0 flex-1 flex-col gap-1.5 text-sm font-medium text-fg`,children:[(0,X.jsx)(`span`,{children:N.chat.sourceNoteSaveDialogContentLabel}),(0,X.jsx)(`textarea`,{value:ce?.content??``,onChange:e=>le(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:ue})]})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:[(0,X.jsx)(qi,{type:`button`,variant:`secondary`,onClick:vn,disabled:ue,children:N.chat.sourceNoteSaveDialogCancel}),(0,X.jsx)(qi,{type:`button`,variant:`primary`,onClick:()=>void Cn(),disabled:ue||!ce?.content.trim(),children:ue?N.chat.sourceNoteSaveDialogSaving:N.chat.sourceNoteSaveDialogConfirm})]})]})]})})]})}):(0,X.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:N.chat.needToken})}export{Ic as $,Gp as A,Ys as At,Cp as B,ih as C,nc as Ct,Zp as D,Qs as Dt,sm as E,$s as Et,Up as F,up as G,Sp as H,Rp as I,tl as J,cp as K,Ip as L,Bp as M,qs as Mt,Vp as N,Ks as Nt,Yp as O,Zs as Ot,zp as P,Jc as Q,wp as R,ah as S,rc as St,im as T,ec as Tt,pp as U,yp as V,mp as W,Qc as X,el as Y,$c as Z,Sh as _,cc as _t,qT as a,Wc as at,hh as b,ac as bt,AT as c,jc as ct,MT as d,mc as dt,Lc as et,OT as f,pc as ft,Iv as g,lc as gt,jy as h,uc as ht,tE as i,Zc as it,Hp as j,Js as jt,Wp as k,Xs as kt,PT as l,kc as lt,mT as m,dc as mt,pM as n,Yc as nt,UT as o,Fc as ot,ST as p,fc as pt,np as q,$T as r,Xc as rt,HT as s,Dc as st,hM as t,Rc as tt,NT as u,hc as ut,ph as v,sc as vt,Qm as w,tc as wt,ch as x,ic as xt,mh as y,oc as yt,Tp as z};