@xopcai/xopc 0.0.454 → 0.0.456

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 (463) hide show
  1. package/dist/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/eventEmitter2.js +40 -0
  2. package/dist/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/index.js +56 -0
  3. package/dist/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/shared/conout.js +16 -0
  4. package/dist/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/terminal.js +190 -0
  5. package/dist/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/unixTerminal.js +287 -0
  6. package/dist/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/utils.js +49 -0
  7. package/dist/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/windowsConoutConnection.js +190 -0
  8. package/dist/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/windowsPtyAgent.js +265 -0
  9. package/dist/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/windowsTerminal.js +178 -0
  10. package/dist/_virtual/_rolldown/runtime.js +10 -2
  11. package/dist/browser-ext/manifest.json +1 -1
  12. package/dist/extensions/telegram/xopc.extension.json +1 -1
  13. package/dist/gateway/static/root/assets/{activity-store-BKH-qNPt.js → activity-store-DYwR1u3f.js} +1 -1
  14. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DY6IWy0_.js → agent-avatar-dicebear-CsRBprL-.js} +1 -1
  15. package/dist/gateway/static/root/assets/{agent-avatar-display-tnAtQOAZ.js → agent-avatar-display-DqFYHXCS.js} +2 -2
  16. package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-BLQ2N_dY.js → agent-defaults-settings-panel-DOAJrMLe.js} +1 -1
  17. package/dist/gateway/static/root/assets/{agent-plugin-dialog-Bfsm4GOs.js → agent-plugin-dialog-vqlN3ORH.js} +1 -1
  18. package/dist/gateway/static/root/assets/{agents-CDNiLv0W.js → agents-BgHlOVRV.js} +3 -3
  19. package/dist/gateway/static/root/assets/{agents-admin-api-DGZsm8U4.js → agents-admin-api-CKscfdvA.js} +1 -1
  20. package/dist/gateway/static/root/assets/{api-BhipC15e.js → api-CHM2c_Ah.js} +1 -1
  21. package/dist/gateway/static/root/assets/{api-Bbj5k-7e.js → api-DPNeNCmR.js} +1 -1
  22. package/dist/gateway/static/root/assets/{app-link-CCZ-LmVT.js → app-link-DImAfVs5.js} +1 -1
  23. package/dist/gateway/static/root/assets/{app-management-settings-panel-fwhXHKxt.js → app-management-settings-panel-Bhz6bj1C.js} +1 -1
  24. package/dist/gateway/static/root/assets/{appearance-settings-BHkl-vFO.js → appearance-settings-BX32aogA.js} +1 -1
  25. package/dist/gateway/static/root/assets/{apps-page-DtCWwdsK.js → apps-page-0Yo3jBsQ.js} +1 -1
  26. package/dist/gateway/static/root/assets/{archive-plugin-B9xaxa7V.js → archive-plugin-Bha8obMe.js} +1 -1
  27. package/dist/gateway/static/root/assets/{automation-api-BHMjSwcy.js → automation-api-mn8ihWJ_.js} +1 -1
  28. package/dist/gateway/static/root/assets/{automation-result-state-BgAjEoNV.js → automation-result-state-COzakzak.js} +1 -1
  29. package/dist/gateway/static/root/assets/{automation-run-list-D3Eon5C0.js → automation-run-list-BhtaMpTb.js} +1 -1
  30. package/dist/gateway/static/root/assets/{automation-task-card-DJRg72t-.js → automation-task-card-BY_k6iWp.js} +1 -1
  31. package/dist/gateway/static/root/assets/{automations-page-DdAzXb7s.js → automations-page-CgQDpSpK.js} +1 -1
  32. package/dist/gateway/static/root/assets/{automations-workspace-D0nNat6N.js → automations-workspace-CWEDraTP.js} +2 -2
  33. package/dist/gateway/static/root/assets/{binary-plugins-CgsjdprR.js → binary-plugins-DUbrJFLU.js} +1 -1
  34. package/dist/gateway/static/root/assets/{block-editor-r6vj6dZO.js → block-editor-DW--pXAc.js} +1 -1
  35. package/dist/gateway/static/root/assets/{browser-settings-page-APCGT8Yr.js → browser-settings-page-CDh6nxs9.js} +1 -1
  36. package/dist/gateway/static/root/assets/{capabilities-0gYkjdax.js → capabilities-DKbXv8Ck.js} +1 -1
  37. package/dist/gateway/static/root/assets/{capabilities-BgBwcqvY.js → capabilities-kG175Q-7.js} +1 -1
  38. package/dist/gateway/static/root/assets/{capabilities-page-B1x3TwdV.js → capabilities-page-D1wQ2sPI.js} +2 -2
  39. package/dist/gateway/static/root/assets/capabilities-settings-panel-BW5jQz5R.js +8 -0
  40. package/dist/gateway/static/root/assets/{channels-8Y08v4Q2.js → channels-BzZp42yO.js} +1 -1
  41. package/dist/gateway/static/root/assets/{chat-agents-api-BRQDNNI5.js → chat-agents-api-UOdNWZ0_.js} +1 -1
  42. package/dist/gateway/static/root/assets/{chat-chart-block-qMGhfeQZ.js → chat-chart-block-NSy-B0NS.js} +1 -1
  43. package/dist/gateway/static/root/assets/{chat-page-CSTyfO9c.js → chat-page-BjYumhaI.js} +20 -20
  44. package/dist/gateway/static/root/assets/{chat-terminal-dock-0PJ9dURQ.js → chat-terminal-dock-CAaHWS7F.js} +1 -1
  45. package/dist/gateway/static/root/assets/{command-palette-api-C4U_-rDo.js → command-palette-api-Dkn9bbYd.js} +1 -1
  46. package/dist/gateway/static/root/assets/{composer-model-config-control-B9Q40ptH.js → composer-model-config-control-BrK8-SNz.js} +1 -1
  47. package/dist/gateway/static/root/assets/{composer-notifications-ByuA8h5Z.js → composer-notifications-B-kL3qAA.js} +1 -1
  48. package/dist/gateway/static/root/assets/{composer-payload-handoff-zr1JDn3p.js → composer-payload-handoff-DBE1mvOS.js} +1 -1
  49. package/dist/gateway/static/root/assets/{computer-settings-page-D2F1quZR.js → computer-settings-page-C9KdEecx.js} +1 -1
  50. package/dist/gateway/static/root/assets/connected-providers-grid-D_8v6Qex.js +1 -0
  51. package/dist/gateway/static/root/assets/{connection-usage-guide-DkDsHm_l.js → connection-usage-guide-CiVpcbds.js} +1 -1
  52. package/dist/gateway/static/root/assets/{connector-service-page-1AcvESmp.js → connector-service-page-B919cKSm.js} +1 -1
  53. package/dist/gateway/static/root/assets/{connectors-api-C1OML7OO.js → connectors-api-CgsSm-Av.js} +1 -1
  54. package/dist/gateway/static/root/assets/{connectors-page-CMIY0Zj_.js → connectors-page-CEpfDCLA.js} +1 -1
  55. package/dist/gateway/static/root/assets/{date-picker-D1eFhoMI.js → date-picker-dx284jQI.js} +1 -1
  56. package/dist/gateway/static/root/assets/{date-time-picker-CqplKVk6.js → date-time-picker-Dj-bhLNP.js} +1 -1
  57. package/dist/gateway/static/root/assets/{desktop-pet-UmrjWSq-.js → desktop-pet-Cn1TfGz4.js} +1 -1
  58. package/dist/gateway/static/root/assets/{desktop-pet-narrative-B7I1II0Z.js → desktop-pet-narrative-JqMsz4rn.js} +1 -1
  59. package/dist/gateway/static/root/assets/{desktop-pet-settings-DRRDJMu6.js → desktop-pet-settings-CsmrvoxU.js} +1 -1
  60. package/dist/gateway/static/root/assets/{dev-view-store-CtKJMK52.js → dev-view-store-BOxbj1ie.js} +1 -1
  61. package/dist/gateway/static/root/assets/{device-pairing-wizard-C4aSCbqo.js → device-pairing-wizard-CAqFIFRC.js} +1 -1
  62. package/dist/gateway/static/root/assets/{directory-picker-path-field-D9U9yfnb.js → directory-picker-path-field-BxEw5OrT.js} +1 -1
  63. package/dist/gateway/static/root/assets/{discussion-annotation-sync-D-eGt1_L.js → discussion-annotation-sync-CyntTwIa.js} +1 -1
  64. package/dist/gateway/static/root/assets/extension-authoritative-grants-C0ReZguU.js +1 -0
  65. package/dist/gateway/static/root/assets/{extension-debug-page-BTLcC8-r.js → extension-debug-page-Cd3HMUbi.js} +1 -1
  66. package/dist/gateway/static/root/assets/extension-iframe-host-DiIqM2JO.js +1 -0
  67. package/dist/gateway/static/root/assets/{extension-marketplace-api-DLRCNlej.js → extension-marketplace-api-CK5CMKTs.js} +1 -1
  68. package/dist/gateway/static/root/assets/extension-message-router-Dn8JzOdR.js +8 -0
  69. package/dist/gateway/static/root/assets/{extension-page-CdpI-Plq.js → extension-page-CLZtAtqm.js} +1 -1
  70. package/dist/gateway/static/root/assets/{extension-provider-DUDaMvQg.js → extension-provider-CbVokTvd.js} +1 -1
  71. package/dist/gateway/static/root/assets/{extension-settings-page-biWCnMGr.js → extension-settings-page-BM79cwUy.js} +1 -1
  72. package/dist/gateway/static/root/assets/{file-preview-surface-CnBRiQo8.js → file-preview-surface-z7_HV0WN.js} +1 -1
  73. package/dist/gateway/static/root/assets/{gateway-config-swr-BV5fpBSK.js → gateway-config-swr-OGhON-s6.js} +1 -1
  74. package/dist/gateway/static/root/assets/{gateway-realtime-CIqLQXlm.js → gateway-realtime-B9u4uSXW.js} +1 -1
  75. package/dist/gateway/static/root/assets/gateway-realtime-store-xB7Bq4Zs.js +1 -0
  76. package/dist/gateway/static/root/assets/{gateway-restart-DBkfCzT5.js → gateway-restart-DKAweWmg.js} +1 -1
  77. package/dist/gateway/static/root/assets/{gateway-settings-DTzXUm9f.js → gateway-settings-Dc7qUbG-.js} +1 -1
  78. package/dist/gateway/static/root/assets/{gateway-startup-retry-B49N_Ngm.js → gateway-startup-retry-BaaoKBoB.js} +1 -1
  79. package/dist/gateway/static/root/assets/{global-defaults-api-DVpxe45P.js → global-defaults-api-BIr3ApRj.js} +1 -1
  80. package/dist/gateway/static/root/assets/{home-page-DvaxBrjG.js → home-page-i_PIrDCU.js} +2 -2
  81. package/dist/gateway/static/root/assets/{image-generation-api-CAKYslID.js → image-generation-api-C7D2IetZ.js} +1 -1
  82. package/dist/gateway/static/root/assets/{imports-page-C2KmQJ2H.js → imports-page-BjEdZJxZ.js} +1 -1
  83. package/dist/gateway/static/root/assets/{index-BpzvsoS1.js → index-DBlVVXOA.js} +5 -5
  84. package/dist/gateway/static/root/assets/index-DpkEeFEQ.css +1 -0
  85. package/dist/gateway/static/root/assets/{install-connector-dialog-CmNvZt8M.js → install-connector-dialog-BsiyYQhx.js} +1 -1
  86. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-syG2KRr2.js → keyboard-shortcuts-settings-CIthQ1lp.js} +1 -1
  87. package/dist/gateway/static/root/assets/{local-app-workbench-page-DGA4EHGm.js → local-app-workbench-page-CSCIHvZV.js} +1 -1
  88. package/dist/gateway/static/root/assets/local-apps-DeqzkJiF.js +1 -0
  89. package/dist/gateway/static/root/assets/{local-apps-page-I0O2ybpp.js → local-apps-page-EntiM0tz.js} +1 -1
  90. package/dist/gateway/static/root/assets/{local-session-drafts-DsPDloiq.js → local-session-drafts-XurtjR58.js} +1 -1
  91. package/dist/gateway/static/root/assets/{locale-store-D3c8DIm-.js → locale-store-cg9cm2EL.js} +1 -1
  92. package/dist/gateway/static/root/assets/{logs-page-u9FTZaTh.js → logs-page-rmS9VSem.js} +1 -1
  93. package/dist/gateway/static/root/assets/{management-api-uxRxRX-6.js → management-api-B6jVuJ6W.js} +1 -1
  94. package/dist/gateway/static/root/assets/{management-settings-BCbDfM7f.js → management-settings-DdI9gs51.js} +1 -1
  95. package/dist/gateway/static/root/assets/{markdown-view-ohhExTMC.js → markdown-view-D1zBWkfB.js} +1 -1
  96. package/dist/gateway/static/root/assets/{mcp-conversation-setup-page-382BGqQC.js → mcp-conversation-setup-page-Bn49Ph1n.js} +1 -1
  97. package/dist/gateway/static/root/assets/{media-plugins-B5wtLz3Z.js → media-plugins-Cd6hAGDp.js} +1 -1
  98. package/dist/gateway/static/root/assets/messages-eQ2CYlpG.js +3 -0
  99. package/dist/gateway/static/root/assets/{model-selector-CoKcq0AZ.js → model-selector-CL6WT-jw.js} +1 -1
  100. package/dist/gateway/static/root/assets/{models-hub-cache-CtooMAQW.js → models-hub-cache-s0FMNhq9.js} +1 -1
  101. package/dist/gateway/static/root/assets/{note-detail-panel-DiGQtSD0.js → note-detail-panel-C6s0WlNL.js} +3 -3
  102. package/dist/gateway/static/root/assets/note-image-lightbox-DfK2KSgu.js +1 -0
  103. package/dist/gateway/static/root/assets/{notes-api-Cvet94d8.js → notes-api-CR75RHd0.js} +1 -1
  104. package/dist/gateway/static/root/assets/{notes-page-DwlmKweX.js → notes-page-CR7dNVDi.js} +1 -1
  105. package/dist/gateway/static/root/assets/{oauth-api-BHp5dVNh.js → oauth-api-CvPnQTlH.js} +1 -1
  106. package/dist/gateway/static/root/assets/oauth-provider-connect-Dk1NeeqD.js +1 -0
  107. package/dist/gateway/static/root/assets/{page-context-capture-button-BwsK2uDe.js → page-context-capture-button-BPtX67hZ.js} +1 -1
  108. package/dist/gateway/static/root/assets/{page-context-draft-ieK9IN3R.js → page-context-draft-Ckb8baxj.js} +1 -1
  109. package/dist/gateway/static/root/assets/page-header-store-DU4NnGap.js +1 -0
  110. package/dist/gateway/static/root/assets/{personal-avatar-BZSC0BLP.js → personal-avatar-CZSnrSfc.js} +1 -1
  111. package/dist/gateway/static/root/assets/{personal-page-CbiD8Wn7.js → personal-page-C89kLOIL.js} +1 -1
  112. package/dist/gateway/static/root/assets/personal-profile-settings-DJRDcK2c.js +1 -0
  113. package/dist/gateway/static/root/assets/{personal-settings-panel-_cxSzWsN.js → personal-settings-panel-C6p25Noq.js} +1 -1
  114. package/dist/gateway/static/root/assets/{phone-dependencies-card-C2OWtG2B.js → phone-dependencies-card-DKkFFpqi.js} +1 -1
  115. package/dist/gateway/static/root/assets/{phone-model-connection-CqmafRhr.js → phone-model-connection-CRRHq4PQ.js} +1 -1
  116. package/dist/gateway/static/root/assets/{phone-model-picker-BwYQtl_5.js → phone-model-picker-CN_I0-46.js} +1 -1
  117. package/dist/gateway/static/root/assets/{phone-settings-page-CPteZZWu.js → phone-settings-page-CkdSOA7D.js} +1 -1
  118. package/dist/gateway/static/root/assets/{phone-workspace-store-ReUEjG9m.js → phone-workspace-store-CC61pIuJ.js} +1 -1
  119. package/dist/gateway/static/root/assets/{plugin-details-dialog-BlNVtbEU.js → plugin-details-dialog-Bqz4jT53.js} +1 -1
  120. package/dist/gateway/static/root/assets/{preference-select-fields-BbA-g7Zq.js → preference-select-fields-DHeNbAvn.js} +1 -1
  121. package/dist/gateway/static/root/assets/{product-automation-feedback-DcPY76PG.js → product-automation-feedback-BN2HTA9T.js} +1 -1
  122. package/dist/gateway/static/root/assets/{product-delivery-2Ks17_OH.js → product-delivery-BFfqdKLe.js} +1 -1
  123. package/dist/gateway/static/root/assets/{product-open-page-BBJ7glAm.js → product-open-page-B-j4gpLD.js} +1 -1
  124. package/dist/gateway/static/root/assets/{product-preview-content-UTOSc_ii.js → product-preview-content-EqrTk7kU.js} +1 -1
  125. package/dist/gateway/static/root/assets/{product-preview-modal-Q1RZqeMo.js → product-preview-modal-aurFBFq4.js} +2 -2
  126. package/dist/gateway/static/root/assets/{project-detail-page-BlrtsEZK.js → project-detail-page-sHcdluTm.js} +1 -1
  127. package/dist/gateway/static/root/assets/{project-understanding-B35f5MkG.js → project-understanding-HNK9lFVy.js} +1 -1
  128. package/dist/gateway/static/root/assets/{projects-page-CBH-sHOU.js → projects-page-CugSyKl5.js} +1 -1
  129. package/dist/gateway/static/root/assets/providers-api-DUntOOqr.js +1 -0
  130. package/dist/gateway/static/root/assets/{recording-upload-P1WcsdEY.js → recording-upload-DIwP541B.js} +1 -1
  131. package/dist/gateway/static/root/assets/{registry-api-DnVlwJ6M.js → registry-api-BTd_OgbD.js} +1 -1
  132. package/dist/gateway/static/root/assets/{remote-access-hub-CVEj3p0J.js → remote-access-hub-f5mIfsBF.js} +1 -1
  133. package/dist/gateway/static/root/assets/{resource-unavailable-B_S1dFze.js → resource-unavailable-DtQ2rfu_.js} +1 -1
  134. package/dist/gateway/static/root/assets/{route-preload-DGmrxJSb.js → route-preload-DrfQJkmW.js} +2 -2
  135. package/dist/gateway/static/root/assets/{runtime-tools-api-970sp5zI.js → runtime-tools-api-C1iI8EPo.js} +1 -1
  136. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-au6vZ0sL.js → runtime-tools-settings-panel-0tdI1z0g.js} +1 -1
  137. package/dist/gateway/static/root/assets/{service-recommendation-list-XeRFtJ-Z.js → service-recommendation-list-DSIe-NRe.js} +1 -1
  138. package/dist/gateway/static/root/assets/{session-api-CuT7EPI0.js → session-api-CQlEq0MB.js} +1 -1
  139. package/dist/gateway/static/root/assets/{session-manager-CyZHiuWY.js → session-manager-C7RfUfqI.js} +1 -1
  140. package/dist/gateway/static/root/assets/{sessions-page-BIxDwAIX.js → sessions-page-DdS8U0RV.js} +1 -1
  141. package/dist/gateway/static/root/assets/settings-advanced-gate-DnfH22f_.js +1 -0
  142. package/dist/gateway/static/root/assets/{settings-advanced-section-nbkGHQ_4.js → settings-advanced-section-C6dPu5i1.js} +1 -1
  143. package/dist/gateway/static/root/assets/{settings-mode-store-EQHfksdV.js → settings-mode-store-BSiiowQa.js} +1 -1
  144. package/dist/gateway/static/root/assets/{settings-page-D6RNHRHq.js → settings-page-C4CYw21O.js} +1 -1
  145. package/dist/gateway/static/root/assets/{settings-page-header-19GJ_a45.js → settings-page-header-BSMu5Zq3.js} +1 -1
  146. package/dist/gateway/static/root/assets/{settings-page-layout-B2WCzSel.js → settings-page-layout-B_vMffB1.js} +1 -1
  147. package/dist/gateway/static/root/assets/{setup-interaction-page-C5i7y_pM.js → setup-interaction-page-DKXfFdNt.js} +1 -1
  148. package/dist/gateway/static/root/assets/{setup-status-panel-Cwp8YKdT.js → setup-status-panel-BbAZ9w77.js} +1 -1
  149. package/dist/gateway/static/root/assets/{share-link-dialog-DDsVTMZ-.js → share-link-dialog-ztX1WPXG.js} +1 -1
  150. package/dist/gateway/static/root/assets/{share-preview-page-C1S_gWGf.js → share-preview-page-Ds2Ydfg6.js} +1 -1
  151. package/dist/gateway/static/root/assets/{shares-api-CepTFl1f.js → shares-api-CSZqeNL4.js} +1 -1
  152. package/dist/gateway/static/root/assets/{shares-settings-Cv-tdcAN.js → shares-settings-CX3TNAmI.js} +1 -1
  153. package/dist/gateway/static/root/assets/{skill-api-CsT-iHnl.js → skill-api-CGzAQ-MX.js} +1 -1
  154. package/dist/gateway/static/root/assets/{skill-list-api-CMJTjvSo.js → skill-list-api-DfUsku-x.js} +1 -1
  155. package/dist/gateway/static/root/assets/{skill-reload-api-S6B7P9ur.js → skill-reload-api-Y9qSMnBd.js} +1 -1
  156. package/dist/gateway/static/root/assets/{skills-page-BKcsJtYx.js → skills-page-DnMN50Ot.js} +1 -1
  157. package/dist/gateway/static/root/assets/{system-settings-panel-DhHPM5qU.js → system-settings-panel-DWNkQmme.js} +1 -1
  158. package/dist/gateway/static/root/assets/{task-detail-page-BHH2_Z9_.js → task-detail-page-DBnkT1Nj.js} +1 -1
  159. package/dist/gateway/static/root/assets/{task-input-card-D_2rNF31.js → task-input-card-lCMSy6YY.js} +1 -1
  160. package/dist/gateway/static/root/assets/{terminal-panel-store-CcUWpqvC.js → terminal-panel-store-D8eZPvql.js} +1 -1
  161. package/dist/gateway/static/root/assets/{theme-store-D9pquJiM.js → theme-store-GZQ3pTgy.js} +1 -1
  162. package/dist/gateway/static/root/assets/tool-friendly-title-CP35P4VA.js +2 -0
  163. package/dist/gateway/static/root/assets/{tracing-settings-page-CjNrKILr.js → tracing-settings-page-DM3-7Hlw.js} +1 -1
  164. package/dist/gateway/static/root/assets/{tunnel-api-GtLO40pc.js → tunnel-api-DOGAIXRR.js} +1 -1
  165. package/dist/gateway/static/root/assets/{understanding-activity-store-BhB5wAbq.js → understanding-activity-store-CuPfe0eQ.js} +1 -1
  166. package/dist/gateway/static/root/assets/understanding-refresh-store-CIpGYSl0.js +1 -0
  167. package/dist/gateway/static/root/assets/{usage-page-CZa_a6_7.js → usage-page-BA9Yrvqu.js} +1 -1
  168. package/dist/gateway/static/root/assets/{use-autosave-BtOp6W9H.js → use-autosave-CO0IPCVg.js} +1 -1
  169. package/dist/gateway/static/root/assets/{use-composer-attachments-BTQZx8Nj.js → use-composer-attachments-CLIrD0mm.js} +1 -1
  170. package/dist/gateway/static/root/assets/{use-file-preview-expanded-B7nscYS4.js → use-file-preview-expanded-dhNMHf5b.js} +3 -3
  171. package/dist/gateway/static/root/assets/{use-personal-profile-Cj7WGOfv.js → use-personal-profile-CVqDWBDS.js} +1 -1
  172. package/dist/gateway/static/root/assets/{use-realtime-voice-BS1rygyV.js → use-realtime-voice-DDVVlX1R.js} +1 -1
  173. package/dist/gateway/static/root/assets/{use-workspace-tree-DYosm4Gz.js → use-workspace-tree-CZej8mhf.js} +1 -1
  174. package/dist/gateway/static/root/assets/user-model-page-Bbi2MpIS.js +2 -0
  175. package/dist/gateway/static/root/assets/{voice-api-key-field-8voN8dQG.js → voice-api-key-field-DpwUDAvu.js} +1 -1
  176. package/dist/gateway/static/root/assets/{voice-config-api-CrZd2aqw.js → voice-config-api-GIuXoHXw.js} +1 -1
  177. package/dist/gateway/static/root/assets/{voice-input-shortcut-events-DcFp_fy4.js → voice-input-shortcut-events-Cc30ZcFy.js} +1 -1
  178. package/dist/gateway/static/root/assets/{voice-settings-AckvhNnP.js → voice-settings-DA3m5MT0.js} +1 -1
  179. package/dist/gateway/static/root/assets/{work-discovery-overlay-DAIk5csp.js → work-discovery-overlay-yGUkk1NV.js} +1 -1
  180. package/dist/gateway/static/root/assets/{work-discovery-page-CJeixeWQ.js → work-discovery-page-RN6iuY-0.js} +1 -1
  181. package/dist/gateway/static/root/assets/{working-directory-picker-modal-BW76VaD5.js → working-directory-picker-modal-CeXl9w6z.js} +1 -1
  182. package/dist/gateway/static/root/assets/{workspace-api-Cu2gzmVn.js → workspace-api-B1Uirhxf.js} +2 -2
  183. package/dist/gateway/static/root/assets/workspace-editor-agent-store-Nos5ebMv.js +1 -0
  184. package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-DyqI793w.js → workspace-file-preview-dialog-D0h2yJ3v.js} +1 -1
  185. package/dist/gateway/static/root/assets/{workspace-open-location-menu-DTYkApy8.js → workspace-open-location-menu-DWGNOIE2.js} +1 -1
  186. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-Rytp_NWV.js → xopc-cloud-account-card-x-XT4bKF.js} +1 -1
  187. package/dist/gateway/static/root/index.html +91 -91
  188. package/dist/package.js +1 -1
  189. package/dist/packages/gateway-contract/src/extension-capabilities.js +69 -4
  190. package/dist/packages/gateway-contract/src/local-app-delegation.js +4 -1
  191. package/dist/src/agent/agent-manager.js +8 -3
  192. package/dist/src/agent/background-review/prompts.d.ts +1 -1
  193. package/dist/src/agent/background-review/prompts.js +8 -1
  194. package/dist/src/agent/background-review/run-background-review.js +48 -4
  195. package/dist/src/agent/child-agent-factory.js +24 -1
  196. package/dist/src/agent/commands/command-registry.d.ts +10 -0
  197. package/dist/src/agent/commands/command-registry.js +37 -16
  198. package/dist/src/agent/commands/command-transport.d.ts +19 -0
  199. package/dist/src/agent/commands/command-transport.js +92 -0
  200. package/dist/src/agent/context/audit.js +18 -0
  201. package/dist/src/agent/context/coordinator.d.ts +4 -0
  202. package/dist/src/agent/context/coordinator.js +33 -7
  203. package/dist/src/agent/context/deep-recall.d.ts +33 -0
  204. package/dist/src/agent/context/deep-recall.js +190 -0
  205. package/dist/src/agent/context/execution-context.js +29 -5
  206. package/dist/src/agent/context/execution-context.types.d.ts +2 -0
  207. package/dist/src/agent/context/memory-claim-grounding.d.ts +2 -0
  208. package/dist/src/agent/context/memory-claim-grounding.js +20 -0
  209. package/dist/src/agent/context/project-context.js +1 -1
  210. package/dist/src/agent/context/recall-grounding.d.ts +3 -0
  211. package/dist/src/agent/context/recall-grounding.js +31 -0
  212. package/dist/src/agent/embedded/execution-tool-policy.d.ts +1 -0
  213. package/dist/src/agent/embedded/execution-tool-policy.js +16 -5
  214. package/dist/src/agent/embedded/index.js +1 -1
  215. package/dist/src/agent/embedded/run-turn.js +120 -14
  216. package/dist/src/agent/embedded/runs.d.ts +2 -0
  217. package/dist/src/agent/embedded/runs.js +8 -1
  218. package/dist/src/agent/embedded/session-runner.js +2 -2
  219. package/dist/src/agent/external-tools/cliProvider.js +2 -2
  220. package/dist/src/agent/external-tools/composio-provider.js +2 -2
  221. package/dist/src/agent/external-tools/endpoint-provider.js +4 -4
  222. package/dist/src/agent/inbound/attachment-pipeline.js +1 -1
  223. package/dist/src/agent/memory/context-recovery.d.ts +1 -1
  224. package/dist/src/agent/memory/index.js +1 -1
  225. package/dist/src/agent/orchestration/agent-orchestrator.js +1 -1
  226. package/dist/src/agent/orchestration/child-run-monitor.d.ts +35 -0
  227. package/dist/src/agent/orchestration/child-run-monitor.js +104 -0
  228. package/dist/src/agent/orchestration/child-run-resume.d.ts +3 -0
  229. package/dist/src/agent/orchestration/child-run-resume.js +67 -0
  230. package/dist/src/agent/sandbox/native-command.d.ts +15 -0
  231. package/dist/src/agent/sandbox/native-command.js +65 -0
  232. package/dist/src/agent/service/btw-query.d.ts +1 -0
  233. package/dist/src/agent/service/btw-query.js +1 -1
  234. package/dist/src/agent/service/direct-turn-helpers.js +2 -2
  235. package/dist/src/agent/service/process-direct-streaming.js +3 -3
  236. package/dist/src/agent/service.d.ts +1 -0
  237. package/dist/src/agent/service.js +8 -5
  238. package/dist/src/agent/session/interaction-policy.d.ts +21 -0
  239. package/dist/src/agent/session/interaction-policy.js +58 -0
  240. package/dist/src/agent/session/session-inspector.js +3 -2
  241. package/dist/src/agent/skills/index.js +1 -1
  242. package/dist/src/agent/skills/managed-store.js +1 -1
  243. package/dist/src/agent/skills/skill-manage-ops.js +1 -1
  244. package/dist/src/agent/tools/create-share-tool.js +1 -1
  245. package/dist/src/agent/tools/exec-command.js +5 -0
  246. package/dist/src/agent/tools/factory.js +23 -1
  247. package/dist/src/agent/tools/index.js +1 -1
  248. package/dist/src/agent/tools/knowledge-memory-tool.js +7 -1
  249. package/dist/src/agent/tools/list-dir.js +1 -1
  250. package/dist/src/agent/tools/managed-job-tool.js +16 -1
  251. package/dist/src/agent/tools/personal-memory-tool.d.ts +11 -0
  252. package/dist/src/agent/tools/personal-memory-tool.js +387 -0
  253. package/dist/src/agent/tools/personal-read-tool.js +2 -2
  254. package/dist/src/agent/tools/publish-artifacts.js +1 -1
  255. package/dist/src/agent/tools/read.js +1 -1
  256. package/dist/src/agent/tools/send-media.js +1 -1
  257. package/dist/src/agent/tools/session-search-tool.d.ts +2 -0
  258. package/dist/src/agent/tools/session-search-tool.js +21 -7
  259. package/dist/src/agent/tools/user-context-tool.js +11 -1
  260. package/dist/src/agent/tools/write.js +1 -1
  261. package/dist/src/agent/tools/xopc-use-tool.js +6 -6
  262. package/dist/src/agent-catalog/capabilities.js +2 -2
  263. package/dist/src/agent-catalog/repository.js +1 -1
  264. package/dist/src/automations/api/routes.js +2 -2
  265. package/dist/src/automations/capabilities/drafts.js +6 -2
  266. package/dist/src/automations/capabilities/read.js +58 -8
  267. package/dist/src/automations/capabilities/write.js +54 -1
  268. package/dist/src/automations/configuration-conversation.js +1 -1
  269. package/dist/src/automations/delivery/delivery-router.js +3 -1
  270. package/dist/src/automations/run-changes.d.ts +2 -0
  271. package/dist/src/automations/run-changes.js +18 -0
  272. package/dist/src/automations/service/automation-service.d.ts +2 -9
  273. package/dist/src/automations/service/automation-service.js +3 -2
  274. package/dist/src/automations/storage/automation-run-repository.d.ts +5 -0
  275. package/dist/src/automations/storage/automation-run-repository.js +15 -1
  276. package/dist/src/browser/providers/browser-ext-install.js +1 -1
  277. package/dist/src/capabilities/runtime/dispatcher.d.ts +1 -0
  278. package/dist/src/capabilities/runtime/dispatcher.js +1 -1
  279. package/dist/src/capabilities/runtime/product.d.ts +2 -0
  280. package/dist/src/capabilities/runtime/product.js +27 -7
  281. package/dist/src/channels/attachments/voice-stt-webchat.js +1 -1
  282. package/dist/src/chat-commands/types.d.ts +2 -0
  283. package/dist/src/cli/commands/agents.js +1 -1
  284. package/dist/src/cli/commands/models.js +1 -1
  285. package/dist/src/cli/commands/onboard/model.js +1 -1
  286. package/dist/src/cli/commands/tui-runner.d.ts +1 -1
  287. package/dist/src/cli/commands/tui-runner.js +1 -0
  288. package/dist/src/cli/commands/tui.js +1 -1
  289. package/dist/src/cli/utils/init-workspace-core.js +1 -1
  290. package/dist/src/computer/endpoint-transport.js +1 -1
  291. package/dist/src/config/agent-profile.js +1 -1
  292. package/dist/src/config/schema.d.ts +7 -1
  293. package/dist/src/config/schema.js +6 -0
  294. package/dist/src/execution-environments/local-worktree-manager.js +1 -1
  295. package/dist/src/extensions/agent-plugins/skill-catalog.js +1 -1
  296. package/dist/src/extensions/agent-plugins/validation.js +1 -1
  297. package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
  298. package/dist/src/gateway/agents-admin.js +1 -1
  299. package/dist/src/gateway/file-path-classifier.js +1 -1
  300. package/dist/src/gateway/global-defaults-admin.js +1 -1
  301. package/dist/src/gateway/hono/lib/config-payload.d.ts +6 -0
  302. package/dist/src/gateway/hono/routes/agents.js +1 -1
  303. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +108 -11
  304. package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
  305. package/dist/src/gateway/hono/routes/imports.js +1 -1
  306. package/dist/src/gateway/hono/routes/lazy-bundles.js +2 -2
  307. package/dist/src/gateway/hono/routes/local-app-capabilities.js +12 -2
  308. package/dist/src/gateway/hono/routes/local-app-run-streams.d.ts +4 -0
  309. package/dist/src/gateway/hono/routes/local-app-run-streams.js +105 -0
  310. package/dist/src/gateway/hono/routes/notes.js +2 -2
  311. package/dist/src/gateway/hono/routes/phone-setup.js +1 -1
  312. package/dist/src/gateway/hono/routes/projects.js +2 -2
  313. package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
  314. package/dist/src/gateway/hono/routes/sessions.js +2 -2
  315. package/dist/src/gateway/hono/routes/shares.js +1 -1
  316. package/dist/src/gateway/hono/routes/tasks.js +4 -4
  317. package/dist/src/gateway/hono/routes/tui.js +308 -0
  318. package/dist/src/gateway/hono/routes/user-model.js +47 -7
  319. package/dist/src/gateway/image-generation-setup.js +1 -1
  320. package/dist/src/gateway/media-access.js +1 -1
  321. package/dist/src/gateway/security/gateway-scopes.js +1 -1
  322. package/dist/src/gateway/service/agent-runner.js +1 -1
  323. package/dist/src/gateway/service/config-coordinator.d.ts +7 -1
  324. package/dist/src/gateway/service/sessions-api.d.ts +1 -1
  325. package/dist/src/gateway/service/sessions-api.js +3 -3
  326. package/dist/src/gateway/service.js +4 -4
  327. package/dist/src/gateway/session-reset-service.js +1 -1
  328. package/dist/src/gateway/xopc-cloud-capability-setup.js +2 -2
  329. package/dist/src/imports/importService.js +1 -1
  330. package/dist/src/infra/execution-authority.d.ts +12 -0
  331. package/dist/src/infra/execution-authority.js +27 -0
  332. package/dist/src/knowledge-memory/index.js +2 -2
  333. package/dist/src/knowledge-memory/repository.d.ts +6 -0
  334. package/dist/src/knowledge-memory/repository.js +49 -1
  335. package/dist/src/knowledge-memory/usage-policy.js +7 -7
  336. package/dist/src/local-apps/automation-proposals.d.ts +754 -0
  337. package/dist/src/local-apps/automation-proposals.js +185 -0
  338. package/dist/src/local-apps/capabilities/automation-policy.d.ts +7 -0
  339. package/dist/src/local-apps/capabilities/automation-policy.js +46 -0
  340. package/dist/src/local-apps/capabilities/contracts.js +23 -0
  341. package/dist/src/local-apps/capabilities/delegate.js +24 -7
  342. package/dist/src/local-apps/capabilities/projections.d.ts +588 -0
  343. package/dist/src/local-apps/capabilities/projections.js +135 -2
  344. package/dist/src/local-apps/capabilities/resource-policy.js +76 -0
  345. package/dist/src/local-apps/capabilities/runtime.js +2 -1
  346. package/dist/src/local-apps/execution-authority.d.ts +13 -0
  347. package/dist/src/local-apps/execution-authority.js +104 -0
  348. package/dist/src/local-apps/p1-services.d.ts +189 -0
  349. package/dist/src/local-apps/p1-services.js +620 -0
  350. package/dist/src/local-apps/preview-sessions.d.ts +1 -1
  351. package/dist/src/local-apps/preview-sessions.js +2 -2
  352. package/dist/src/local-apps/preview-worker.js +11 -2
  353. package/dist/src/local-apps/service.d.ts +81 -1
  354. package/dist/src/local-apps/service.js +19 -2
  355. package/dist/src/local-apps/store.js +1 -1
  356. package/dist/src/memory-learning/work-capture.js +3 -1
  357. package/dist/src/notes/agent-context.js +1 -1
  358. package/dist/src/personal-agent/policy.d.ts +1 -1
  359. package/dist/src/personal-agent/policy.js +2 -1
  360. package/dist/src/personal-agent/prompts.js +7 -1
  361. package/dist/src/personal-agent/request-service.js +1 -1
  362. package/dist/src/personal-agent/service.js +1 -1
  363. package/dist/src/personal-agent/task-cancel.js +1 -1
  364. package/dist/src/platform/contracts.d.ts +3 -3
  365. package/dist/src/projects/capabilities/read.js +43 -2
  366. package/dist/src/projects/capabilities/write.js +25 -0
  367. package/dist/src/projects/project-store.js +12 -1
  368. package/dist/src/projects/types.d.ts +1 -0
  369. package/dist/src/providers/model-catalog-persistence.js +1 -1
  370. package/dist/src/review/review-git.js +14 -1
  371. package/dist/src/runtime-tools/archive.js +1 -1
  372. package/dist/src/session/history-recall-policy.d.ts +6 -0
  373. package/dist/src/session/history-recall-policy.js +48 -0
  374. package/dist/src/share/share-store.js +1 -1
  375. package/dist/src/share/site-share-store.js +1 -1
  376. package/dist/src/storage/sqlite/resource-scope.js +2 -2
  377. package/dist/src/tasks/capabilities/management.js +3 -0
  378. package/dist/src/tasks/capabilities/read.js +2 -2
  379. package/dist/src/tasks/capabilities/write.js +12 -3
  380. package/dist/src/tasks/index.js +1 -1
  381. package/dist/src/tui/backend-services.d.ts +14 -0
  382. package/dist/src/tui/backend-services.js +67 -0
  383. package/dist/src/tui/backends/embedded-backend.d.ts +48 -4
  384. package/dist/src/tui/backends/embedded-backend.js +249 -43
  385. package/dist/src/tui/backends/gateway-realtime-backend.d.ts +46 -2
  386. package/dist/src/tui/backends/gateway-realtime-backend.js +205 -62
  387. package/dist/src/tui/components/chat-log.d.ts +1 -0
  388. package/dist/src/tui/components/chat-log.js +11 -5
  389. package/dist/src/tui/components/scoped-models-selector.js +1 -1
  390. package/dist/src/tui/components/session-selector.js +1 -1
  391. package/dist/src/tui/components/text-viewer.d.ts +32 -0
  392. package/dist/src/tui/components/text-viewer.js +132 -0
  393. package/dist/src/tui/components/tui-bottom-bar.js +3 -0
  394. package/dist/src/tui/extension-host/autocomplete.js +9 -1
  395. package/dist/src/tui/extension-host/runtime.d.ts +1 -0
  396. package/dist/src/tui/extension-host/runtime.js +1 -0
  397. package/dist/src/tui/tui-backend.d.ts +36 -3
  398. package/dist/src/tui/tui-capabilities.d.ts +15 -0
  399. package/dist/src/tui/tui-capabilities.js +46 -0
  400. package/dist/src/tui/tui-capability-controls.d.ts +9 -0
  401. package/dist/src/tui/tui-capability-controls.js +250 -0
  402. package/dist/src/tui/tui-clarification.d.ts +15 -0
  403. package/dist/src/tui/tui-clarification.js +91 -0
  404. package/dist/src/tui/tui-command-formatters.d.ts +0 -4
  405. package/dist/src/tui/tui-command-formatters.js +3 -43
  406. package/dist/src/tui/tui-commands.d.ts +4 -4
  407. package/dist/src/tui/tui-commands.js +219 -127
  408. package/dist/src/tui/tui-control-commands.d.ts +12 -0
  409. package/dist/src/tui/tui-control-commands.js +127 -0
  410. package/dist/src/tui/tui-image-files.d.ts +2 -0
  411. package/dist/src/tui/tui-image-files.js +47 -0
  412. package/dist/src/tui/tui-local-shell.d.ts +6 -0
  413. package/dist/src/tui/tui-local-shell.js +36 -2
  414. package/dist/src/tui/tui-management.d.ts +114 -0
  415. package/dist/src/tui/tui-management.js +233 -0
  416. package/dist/src/tui/tui-picker-overlay.d.ts +1 -6
  417. package/dist/src/tui/tui-picker-overlay.js +1 -62
  418. package/dist/src/tui/tui-session-actions.d.ts +1 -0
  419. package/dist/src/tui/tui-session-actions.js +97 -29
  420. package/dist/src/tui/tui-settings.js +1 -1
  421. package/dist/src/tui/tui-side-chat.d.ts +10 -0
  422. package/dist/src/tui/tui-side-chat.js +56 -0
  423. package/dist/src/tui/tui-terminal.d.ts +3 -0
  424. package/dist/src/tui/tui-terminal.js +52 -0
  425. package/dist/src/tui/tui-types.d.ts +4 -1
  426. package/dist/src/tui/tui.js +422 -211
  427. package/dist/src/tui/xopc-tui-keybindings.d.ts +29 -9
  428. package/dist/src/tui/xopc-tui-keybindings.js +27 -7
  429. package/dist/src/usage/recorder.js +2 -0
  430. package/dist/src/user-context/config.d.ts +12 -0
  431. package/dist/src/user-context/config.js +14 -1
  432. package/dist/src/user-context/memory-version.d.ts +2 -0
  433. package/dist/src/user-context/memory-version.js +12 -0
  434. package/dist/src/user-model/capture/evidence-policy.d.ts +45 -0
  435. package/dist/src/user-model/capture/evidence-policy.js +143 -0
  436. package/dist/src/user-model/capture/executor.d.ts +1 -0
  437. package/dist/src/user-model/capture/executor.js +68 -8
  438. package/dist/src/user-model/capture/semantic.d.ts +16 -0
  439. package/dist/src/user-model/capture/semantic.js +66 -12
  440. package/dist/src/user-model/repository.js +11 -0
  441. package/dist/src/user-model/usage-policy.js +5 -5
  442. package/dist/src/voice/realtime/persona-context.js +1 -1
  443. package/dist/src/work-discovery/service.js +1 -1
  444. package/package.json +2 -1
  445. package/dist/gateway/static/root/assets/capabilities-settings-panel-CZ78ckHR.js +0 -8
  446. package/dist/gateway/static/root/assets/connected-providers-grid-CgULhOBZ.js +0 -1
  447. package/dist/gateway/static/root/assets/extension-authoritative-grants-8ONVOjPW.js +0 -1
  448. package/dist/gateway/static/root/assets/extension-iframe-host-D0-OvFV2.js +0 -1
  449. package/dist/gateway/static/root/assets/extension-message-router-DboLTCVp.js +0 -1
  450. package/dist/gateway/static/root/assets/gateway-realtime-store-B6T1Xzag.js +0 -1
  451. package/dist/gateway/static/root/assets/index-B49yIcMR.css +0 -1
  452. package/dist/gateway/static/root/assets/local-apps-CB-MZAaL.js +0 -1
  453. package/dist/gateway/static/root/assets/messages-DPLud9GK.js +0 -3
  454. package/dist/gateway/static/root/assets/note-image-lightbox-Ds4M9fJJ.js +0 -1
  455. package/dist/gateway/static/root/assets/oauth-provider-connect-cvxtmf3C.js +0 -1
  456. package/dist/gateway/static/root/assets/page-header-store-Xe8CP_4a.js +0 -1
  457. package/dist/gateway/static/root/assets/personal-profile-settings-KvdNnaNv.js +0 -1
  458. package/dist/gateway/static/root/assets/providers-api-BSmKlQ8K.js +0 -1
  459. package/dist/gateway/static/root/assets/settings-advanced-gate-Cy7xeKmH.js +0 -1
  460. package/dist/gateway/static/root/assets/tool-friendly-title-YQmN1S2k.js +0 -2
  461. package/dist/gateway/static/root/assets/understanding-refresh-store-BxtpXRfV.js +0 -1
  462. package/dist/gateway/static/root/assets/user-model-page-DmmJODQ4.js +0 -2
  463. package/dist/gateway/static/root/assets/workspace-editor-agent-store-pVOYuH7u.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mcp-conversation-setup-page-382BGqQC.js","assets/rolldown-runtime-aKtaBQYM.js","assets/vendor-react-BOUWij0V.js","assets/chunk-KS7C4IRE-CiwuuyV8.js","assets/preload-helper-Czpn1I53.js","assets/locale-store-D3c8DIm-.js","assets/messages-DPLud9GK.js","assets/dist-CY7CS_D3.js","assets/es2015-DBLcMg5B.js","assets/dist-CxGUk8J-.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-Cc4hUNTt.js","assets/chat-terminal-dock-0PJ9dURQ.js","assets/plus-Q2yW6OE7.js","assets/square-terminal-K87bylpZ.js","assets/session-api-CuT7EPI0.js","assets/schemas-CCWMleym.js","assets/gateway-startup-retry-B49N_Ngm.js","assets/session-manager-CyZHiuWY.js","assets/constants-DpkUgykJ.js","assets/local-session-drafts-DsPDloiq.js","assets/tool-activity-BtJkgjFf.js","assets/attachment-utils-core-BIOUBrpT.js","assets/gateway-realtime-CIqLQXlm.js","assets/gateway-realtime-store-B6T1Xzag.js","assets/registry-api-DnVlwJ6M.js","assets/agents-admin-api-DGZsm8U4.js","assets/gateway-config-swr-BV5fpBSK.js","assets/sliding-tab-list-CmcrqRzN.js","assets/sliding-indicator-hwz0sx3h.js","assets/terminal-panel-store-CcUWpqvC.js","assets/chat-terminal-dock-uQUnjRtf.css"])))=>i.map(i=>d[i]);
2
- import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,i as r,n as i,t as a}from"./vendor-react-BOUWij0V.js";import{t as o}from"./preload-helper-Czpn1I53.js";import{f as s,l as c,m as l,t as u,u as d}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{a as f,i as p,l as m,n as h,o as g,p as _,u as v}from"./locale-store-D3c8DIm-.js";import{t as y}from"./messages-DPLud9GK.js";import{a as b,c as x,i as S,n as C,o as w,r as T,s as E,t as D}from"./dist-CY7CS_D3.js";import{t as O}from"./createLucideIcon-DPHK1VkS.js";import{t as k}from"./app-window-DXFNqt_0.js";import{t as A}from"./archive-Dz0hferG.js";import{t as j}from"./arrow-left-D880xG-P.js";import{t as M}from"./arrow-up-right-T72JbQ1Q.js";import{t as N}from"./arrow-up-D5ZtR1QT.js";import{a as P,c as F,d as I,f as L,l as R,s as z,t as B,u as V}from"./product-automation-feedback-DcPY76PG.js";import{n as H,t as U}from"./earth-C9Z4bTTG.js";import{t as W}from"./bot-DjLkhyZL.js";import{t as G}from"./check-DUBLcKHA.js";import{t as ee}from"./chevron-down-ccbiQQz_.js";import{t as te}from"./chevron-right-BweFrslA.js";import{i as ne,r as re,t as ie}from"./working-directory-picker-modal-BW76VaD5.js";import{a as ae,d as oe,n as se,o as ce,r as le,t as ue}from"./popover-select-CLsphyzA.js";import{t as K}from"./circle-alert-BEjgurr2.js";import{i as q,r as de,t as fe}from"./new-chat-navigation-B6NPQ4h4.js";import{t as pe}from"./circle-x-DFsCKeya.js";import{t as J}from"./circle-BoO4YvTx.js";import{i as me,n as he,r as ge,t as _e}from"./file-tree-utils-DJs1faGv.js";import{t as ve}from"./copy-Dv6d4Dvw.js";import{t as ye}from"./database-CjjeZfRG.js";import{t as be}from"./ellipsis-0k4rZLoy.js";import{t as xe}from"./external-link-DjqjBmc3.js";import{n as Se,t as Ce}from"./file-BqMS_3DT.js";import{t as we}from"./file-image-CDUPkZvG.js";import{t as Te}from"./file-text-D12HbeVy.js";import{t as Ee}from"./folder-kanban-CpLlFI1o.js";import{t as De}from"./folder-open-CyzJ19I9.js";import{t as Oe}from"./folder-CN-pC3XL.js";import{i as ke,r as Ae,u as je}from"./use-file-preview-expanded-B7nscYS4.js";import{t as Me}from"./git-branch-Dh9uxTot.js";import{t as Ne}from"./globe-DSSGFWFn.js";import{t as Pe}from"./history-DXH_9jsE.js";import{F as Fe,L as Ie,P as Le,c as Re,g as ze,o as Be,t as Ve,v as He}from"./notes-api-Cvet94d8.js";import{t as Ue}from"./key-round-DWbpyU2U.js";import{t as We}from"./laptop-CI3hBVrl.js";import{t as Ge}from"./link-2-D_ZKYUW7.js";import{t as Ke}from"./list-checks-BbsExAoq.js";import{t as qe}from"./list-todo-CTVRto8O.js";import{t as Je}from"./loader-circle-CifKLtgG.js";import{A as Ye,B as Xe,C as Ze,D as Qe,F as $e,P as et,R as tt,S as nt,T as rt,_ as it,b as at,c as ot,d as st,f as ct,g as lt,h as ut,l as dt,m as ft,n as pt,p as mt,r as ht,u as gt,v as _t,w as vt,y as yt}from"./markdown-view-ohhExTMC.js";import{t as bt}from"./messages-square-BckAJrEW.js";import{t as xt}from"./mic-CuUb7zc-.js";import{t as St}from"./monitor-Af5eAvF7.js";import{s as Ct,t as wt}from"./install-connector-dialog-CmNvZt8M.js";import{t as Tt}from"./paperclip-f1HujQY1.js";import{t as Et}from"./pause-DuPxgSxk.js";import{t as Dt}from"./pencil-DmIY3Oa-.js";import{t as Ot}from"./play-kxZvpBg8.js";import{t as kt}from"./plus-Q2yW6OE7.js";import{t as At}from"./refresh-cw-BRlGaq2w.js";import{t as jt}from"./rotate-ccw-JM1TBLpp.js";import{t as Mt}from"./save-DRDABU--.js";import{t as Nt}from"./search-DA7gz22f.js";import{t as Pt}from"./settings-2-D-csvaET.js";import{t as Ft}from"./settings-uiTATseT.js";import{t as It}from"./shield-check-BU58siTV.js";import{t as Lt}from"./smartphone-DSSsQFqA.js";import{t as Rt}from"./sparkles-DHlfQFAF.js";import{t as zt}from"./square-DMK_fB-3.js";import{t as Bt}from"./trash-2-DusmjVPV.js";import{t as Vt}from"./triangle-alert-2JXFNNKU.js";import{r as Ht,t as Ut}from"./share-link-dialog-DDsVTMZ-.js";import{t as Wt}from"./wrench-DFb4r8bH.js";import{t as Gt}from"./x-B_N4OPjy.js";import{t as Kt}from"./zap-dximCGjy.js";import{t as Y}from"./cn-0WouolD0.js";import{t as qt}from"./skeleton-DzdOeGYz.js";import{a as Jt,d as Yt,m as Xt,n as Zt,u as Qt}from"./schemas-CCWMleym.js";import{t as $t}from"./tasks-BTLabOMp.js";import{i as en,n as tn,o as nn,s as rn,t as an}from"./product-delivery-2Ks17_OH.js";import{o as on}from"./local-apps-CB-MZAaL.js";import{a as sn,c as cn,d as ln}from"./api-Bbj5k-7e.js";import{a as un,s as dn}from"./session-api-CuT7EPI0.js";import{$ as fn,A as pn,B as mn,C as hn,Ct as gn,D as _n,E as vn,F as yn,G as bn,H as xn,I as Sn,J as Cn,L as wn,M as Tn,N as En,O as Dn,P as On,Q as kn,R as An,S as jn,St as Mn,T as Nn,U as Pn,V as Fn,W as In,X as Ln,Y as Rn,Z as zn,_ as Bn,_t as Vn,at as Hn,b as Un,bt as Wn,c as Gn,d as Kn,et as qn,ft as Jn,g as Yn,gt as Xn,h as Zn,ht as Qn,it as $n,j as er,k as tr,l as nr,lt as rr,m as ir,mt as ar,nt as or,o as sr,ot as cr,q as lr,r as ur,st as dr,t as fr,tt as pr,u as mr,ut as hr,v as gr,vt as _r,w as vr,x as yr,xt as br,y as xr,yt as Sr,z as Cr}from"./session-manager-CyZHiuWY.js";import{a as wr,d as Tr,m as Er,n as Dr,o as Or,p as kr,s as Ar,t as jr,u as Mr}from"./local-session-drafts-DsPDloiq.js";import{t as Nr}from"./tool-activity-BtJkgjFf.js";import{a as Pr,c as Fr,i as Ir,l as Lr,n as Rr,o as zr,r as Br,s as Vr,t as Hr}from"./new-session-preferences-gb411vZP.js";import{n as Ur,t as Wr}from"./composer-model-config-control-B9Q40ptH.js";import{i as Gr}from"./vendor-swr-CdRzEUwF.js";import{c as Kr,h as qr,i as Jr,n as Yr,o as Xr,r as Zr,s as Qr,t as $r,v as ei}from"./use-composer-attachments-BTQZx8Nj.js";import{a as ti}from"./gateway-config-swr-BV5fpBSK.js";import{t as ni}from"./chat-agents-api-BRQDNNI5.js";import{a as ri,c as ii,i as ai,r as oi,s as si}from"./attachment-utils-core-BIOUBrpT.js";import{n as ci}from"./gateway-realtime-CIqLQXlm.js";import{n as li}from"./gateway-realtime-store-B6T1Xzag.js";import{n as ui,t as di}from"./registry-api-DnVlwJ6M.js";import{a as fi}from"./agents-admin-api-DGZsm8U4.js";import{t as pi}from"./button-Cc4hUNTt.js";import{s as mi}from"./file-preview-surface-CnBRiQo8.js";import{a as hi,i as gi,o as _i,r as vi,s as yi}from"./dist-GJ8-1PAx.js";import{t as bi}from"./middleware-Pd0e8Igk.js";import{i as xi,r as Si}from"./app-link-CCZ-LmVT.js";import{t as Ci}from"./copy-to-clipboard-HOJ79TWv.js";import{a as wi,c as Ti,d as Ei,i as Di,l as Oi,n as ki,o as Ai,p as ji,r as Mi,s as Ni,u as Pi}from"./composer-payload-handoff-zr1JDn3p.js";import{C as Fi,D as Ii,E as Li,T as Ri,_ as zi,b as Bi,c as Vi,d as Hi,f as Ui,g as Wi,h as Gi,m as Ki,n as qi,o as Ji,p as Yi,r as Xi,s as Zi,u as Qi,v as $i,w as ea,x as ta,y as na}from"./chunk-D32TOXHM-DQIy-Baq.js";import{i as ra,n as ia,r as aa,t as oa}from"./chat-chart-block-qMGhfeQZ.js";import{t as sa}from"./linkify-it-BkqEorO0.js";import{n as ca}from"./interaction-BdhHBbYa.js";import{a as la,i as ua,n as da,o as fa,r as pa,s as ma,t as ha}from"./tool-friendly-title-YQmN1S2k.js";import{s as ga}from"./connectors-api-C1OML7OO.js";import{t as _a}from"./use-realtime-voice-BS1rygyV.js";import{t as va}from"./activity-store-BKH-qNPt.js";import{t as ya}from"./composer-notifications-ByuA8h5Z.js";import{n as ba}from"./voice-call-context-BM2A4bLz.js";import{r as xa}from"./app-chrome-BeB4KgOf.js";import{i as Sa,n as Ca,r as wa}from"./form-field-width-DJw_jULe.js";import{n as Ta}from"./electron-env-DHOGevH3.js";import{t as Ea}from"./page-header-store-Xe8CP_4a.js";import{t as Da}from"./use-async-resource-BHFGZCY2.js";import{t as Oa}from"./loopi-CNtmi9FU.js";import{a as ka}from"./extension-provider-DUDaMvQg.js";import{t as Aa}from"./agent-avatar-display-tnAtQOAZ.js";import{a as ja,n as Ma,r as Na,t as Pa}from"./skill-wire-pattern-BPpeIcCi.js";import{n as Fa,t as Ia}from"./use-directory-picker-C4p7AgWY.js";import{t as La}from"./confirm-dialog-DrA5mTQp.js";import{a as Ra,c as za,f as Ba,l as Va,s as Ha,u as Ua}from"./workspace-api-Cu2gzmVn.js";import{n as Wa}from"./index.module-Cd9ENXfk.js";import{a as Ga,i as Ka,o as qa,r as Ja,s as Ya}from"./copy-text-row-CpiRzq4G.js";import{_ as Xa,b as Za,d as Qa,f as $a,h as eo,i as to,n as no,p as ro,s as io,u as ao,y as oo}from"./shares-api-CepTFl1f.js";import{t as so}from"./workspace-editor-agent-store-pVOYuH7u.js";import{l as co,m as lo,o as uo,r as fo,t as po,u as mo}from"./dist-ZrL34Ps4.js";import{a as ho,c as go,d as _o,f as vo,h as yo,i as bo,l as xo,m as So,p as Co,s as wo,t as To,u as Eo}from"./command-palette-api-C4U_-rDo.js";import{n as Do,o as Oo,r as ko,s as Ao}from"./voice-input-shortcut-events-DcFp_fy4.js";import{D as jo,E as Mo,O as No,T as Po,i as Fo,t as Io}from"./automation-task-card-DJRg72t-.js";import{t as Lo}from"./dev-view-store-CtKJMK52.js";import{t as Ro}from"./extension-iframe-host-D0-OvFV2.js";import{i as zo,r as Bo,t as Vo}from"./runtime-health-zDkHcOZO.js";import{c as Ho,i as Uo,r as Wo}from"./api-BhipC15e.js";import{r as Go}from"./terminal-panel-store-CcUWpqvC.js";import{n as Ko}from"./agents-app-path-ciChvpCS.js";import{n as qo,t as Jo}from"./agent-display-names-Bje7vfSn.js";import{t as Yo}from"./oauth-provider-connect-cvxtmf3C.js";import{t as Xo}from"./use-media-query-ady-FgjK.js";import{n as Zo,r as Qo,t as $o}from"./oauth-authorization-window-o6URRos4.js";import{n as es,t as ts}from"./page-context-draft-ieK9IN3R.js";import{i as ns,r as rs}from"./management-api-uxRxRX-6.js";import{t as is}from"./side-chat-shortcut-BIw-1TTD.js";var as=O(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),os=O(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),ss=O(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),cs=O(`corner-down-right`,[[`path`,{d:`m15 10 5 5-5 5`,key:`qqa56n`}],[`path`,{d:`M4 4v7a4 4 0 0 0 4 4h12`,key:`z08zvw`}]]),ls=O(`file-headphone`,[[`path`,{d:`M4 6.835V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-.343`,key:`1vfytu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M2 19a2 2 0 0 1 4 0v1a2 2 0 0 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 0 1-4 0v-1a2 2 0 0 1 4 0`,key:`1etmh7`}]]),us=O(`file-pen-line`,[[`path`,{d:`M14.364 13.634a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506l4.013-4.009a1 1 0 0 0-3.004-3.004z`,key:`ukzhwg`}],[`path`,{d:`M14.487 7.858A1 1 0 0 1 14 7V2`,key:`1klhew`}],[`path`,{d:`M20 19.645V20a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l2.516 2.516`,key:`rxaxab`}],[`path`,{d:`M8 18h1`,key:`13wk12`}]]),ds=O(`file-plus-corner`,[[`path`,{d:`M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35`,key:`17jvcc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M14 19h6`,key:`bvotb8`}],[`path`,{d:`M17 16v6`,key:`18yu1i`}]]),fs=O(`files`,[[`path`,{d:`M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8`,key:`14sh0y`}],[`path`,{d:`M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z`,key:`1970lx`}],[`path`,{d:`M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1`,key:`l4dndm`}]]),ps=O(`git-commit-horizontal`,[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]]),ms=O(`git-fork`,[[`circle`,{cx:`12`,cy:`18`,r:`3`,key:`1mpf1b`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`path`,{d:`M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9`,key:`1uq4wg`}],[`path`,{d:`M12 12v3`,key:`158kv8`}]]),hs=O(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),gs=O(`layout-template`,[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`9`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`jqznyg`}],[`rect`,{width:`5`,height:`7`,x:`16`,y:`14`,rx:`1`,key:`q5h2i8`}]]),_s=O(`message-circle-more`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}]]),vs=O(`message-circle-plus`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]]),ys=O(`message-square-share`,[[`path`,{d:`M12 3H4a2 2 0 0 0-2 2v16.286a.71.71 0 0 0 1.212.502l2.202-2.202A2 2 0 0 1 6.828 19H20a2 2 0 0 0 2-2v-4`,key:`11da1y`}],[`path`,{d:`M16 3h6v6`,key:`1bx56c`}],[`path`,{d:`m16 9 6-6`,key:`m4dnic`}]]),bs=O(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),xs=O(`notebook-pen`,[[`path`,{d:`M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4`,key:`re6nr2`}],[`path`,{d:`M2 6h4`,key:`aawbzj`}],[`path`,{d:`M2 10h4`,key:`l0bgd4`}],[`path`,{d:`M2 14h4`,key:`1gsvsf`}],[`path`,{d:`M2 18h4`,key:`1bu2t1`}],[`path`,{d:`M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`pqwjuv`}]]),Ss=O(`shuffle`,[[`path`,{d:`m18 14 4 4-4 4`,key:`10pe0f`}],[`path`,{d:`m18 2 4 4-4 4`,key:`pucp1d`}],[`path`,{d:`M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22`,key:`1ailkh`}],[`path`,{d:`M2 6h1.972a4 4 0 0 1 3.6 2.2`,key:`km57vx`}],[`path`,{d:`M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45`,key:`os18l9`}]]),Cs=O(`square-plus`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]]),ws=O(`target`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),Ts=O(`wallet`,[[`path`,{d:`M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1`,key:`18etb6`}],[`path`,{d:`M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4`,key:`xoc0q4`}]]);function Es(e,t){return e.replace(/\{\{(\w+)}}/g,(e,n)=>t[n]?.trim()??``).replace(/[ \t]{2,}/g,` `).trim()}function Ds(e,t,n){return{id:e,title:Es(t.title,n),prompt:Es(t.prompt,n),reason:Es(t.reason,n)}}function Os(e,t){let n={projectName:e.projectName,blockedReason:e.blockedReason,recentFailure:e.recentFailure,nextAction:e.recommendedAction};if(e.blockedReason?.trim())return Ds(`project-blocked`,t.recommendations.projectBlocked,n);if(e.recentFailure?.trim())return Ds(`project-failure`,t.recommendations.projectFailure,n);if(e.recommendedAction?.trim())return Ds(`project-next-action`,t.recommendations.projectNextAction,n)}function ks(e,t){let n={taskTitle:e.taskTitle,attentionSummary:e.attentionSummary,recentFailure:e.recentFailure,nextAction:e.nextAction};if(e.attentionSummary?.trim())return Ds(`task-attention`,t.recommendations.taskAttention,n);if(e.recentFailure?.trim())return Ds(`task-failure`,t.recommendations.taskFailure,n);if(e.phase===`review`||e.operationalState===`verifying`)return Ds(`task-review`,t.recommendations.taskReview,n);if(e.phase===`closed`)return Ds(`task-closed`,t.recommendations.taskClosed,n);if(e.nextAction?.trim())return Ds(`task-next-action`,t.recommendations.taskNextAction,n)}function As(e,t){switch(e.kind){case`project`:return Os(e,t);case`task`:return ks(e,t);default:return}}function js(e,t,n={}){let r=n.contextStatus??`ready`;return{headline:e.kind===`project`&&t.projectHeadline?Es(t.projectHeadline,{projectName:e.projectName}):t.headline,contextKind:e.kind,contextStatus:r,recommendation:r===`ready`?As(e,t):void 0}}var Ms=Yt({id:Xt().uuid(),conversationId:Xt(),transcriptId:Xt(),sourceRunId:Xt(),inputRevision:Qt().int().nonnegative(),transcriptCursor:Qt().int().nonnegative(),agentId:Xt(),locale:Zt([`zh`,`en`]),prompt:Xt().min(1).max(160),expiresAt:Qt()}),Ns=Yt({status:Zt([`ready`,`pending`,`none`]),suggestion:Ms.optional()});Yt({suggestionId:Xt().uuid(),impressionId:Xt().uuid(),event:Zt([`shown`,`accepted`,`dismissed`,`submitted`]),edited:Jt().optional()}).strict();function Ps(e,t=`body`){return`result:${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Fs(e){return`${e.taskRunId}:${e.assignmentEpoch}:${e.outcome.outcomeId}`}var Is=e(r(),1),X=i(),Z=a(),Q=e(n(),1);function Ls(e,t){return e?[`task-detail`,e,t??``]:null}function Rs(e,t){return t.source!==`user`||e===void 0||t.version>e}function zs(e){let t=m(e=>e.conversationId),[n,r]=(0,Q.useState)(null),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(null),c=(0,Q.useRef)(``),l=(0,Q.useRef)(void 0),u=Gr(Ls(e,t),()=>ei(e),{keepPreviousData:!1,revalidateOnFocus:!0,revalidateOnReconnect:!0,refreshInterval:e=>e&&[`allocating`,`queued`,`running`,`waiting`,`verifying`].includes(e.operationalState)?5e3:0});return l.current=u.data?.task.version,(0,Q.useEffect)(()=>{r(null),a(!1),s(null),c.current=``},[e]),(0,Q.useEffect)(()=>{let t=u.data;if(!t||t.conversation.activeConversationId||t.allocation&&t.allocation.status!==`assigned`)return;let n=`${e}:${t.task.version}`;c.current!==n&&(c.current=n,a(!0),s(null),qr(e).then(()=>c.current===n?u.mutate():void 0).catch(e=>{c.current===n&&s(e)}).finally(()=>{c.current===n&&a(!1)}))},[u.data,u.mutate,e]),(0,Q.useEffect)(()=>{let t,n=()=>{window.clearTimeout(t),t=window.setTimeout(()=>void u.mutate(),120)},i=t=>{let i=$t.safeParse(t.detail);!i.success||i.data.taskId!==e||Rs(l.current,i.data)&&(r(i.data),n())},a=()=>n();return window.addEventListener(`task-changed-v2`,i),window.addEventListener(`gateway-realtime-connected`,a),window.addEventListener(`realtime-gap`,a),()=>{window.clearTimeout(t),window.removeEventListener(`task-changed-v2`,i),window.removeEventListener(`gateway-realtime-connected`,a),window.removeEventListener(`realtime-gap`,a)}},[u.mutate,e]),{...u,lastChange:n,conversationLoading:i,conversationError:o}}var Bs=new Map,Vs=new Set;function Hs(e,t){Bs.set(e,t);for(let e of Vs)e();return()=>{Bs.get(e)===t&&Bs.delete(e)}}async function Us(e,t,n){await(Bs.get(e)??await new Promise((t,n)=>{let r=()=>{let n=Bs.get(e);n&&(clearTimeout(i),Vs.delete(r),t(n))},i=setTimeout(()=>{Vs.delete(r),n(Error(`Chat input is not ready. Please retry.`))},15e3);Vs.add(r),r()}))(t,n)}var Ws=crypto.randomUUID(),Gs=e=>e===`closed`;function Ks(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 qs=e=>`/api/phone/conversations/${encodeURIComponent(e)}`,Js=new Map,Ys=()=>{let e=m.getState();return`${e.baseUrl}:${e.conversationId}`};function Xs(e,t,n=Ys()){let r=`${n}:${e}`,i=Js.get(r);return t&&i&&t.report.sessionId===i.report.sessionId&&(t.report.revision??0)<(i.report.revision??0)?i:(t?(Js.set(r,t),Js.size>100&&Js.delete(Js.keys().next().value)):Js.delete(r),t)}async function Zs(e,t=Ys()){let n=await f(p(e)),r=decodeURIComponent(e.split(`/conversations/`)[1]?.split(`?`)[0]??``);if(n.status===404)return Xs(r,null,t);if((n.status===401||n.status===403)&&Xs(r,null,t),!n.ok)throw Object.assign(Error(`Phone view unavailable (HTTP ${n.status})`),{status:n.status});return Xs(r,(await n.json()).payload,t)}function Qs(e,t){let n=(0,X.c)(5),r=t===void 0||t,i=m(tc),a;n[0]!==e||n[1]!==r||n[2]!==i?(a=r&&/^(?:device:)?[\da-f]{8}-[\da-f-]{27}$/i.test(e)?[`${qs(e)}?clientId=${Ws}`,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:$s,errorRetryCount:6,errorRetryInterval:2e3,refreshWhenHidden:!1},n[4]=o):o=n[4],Gr(a,ec,o)}function $s(e){return e.status!==401&&e.status!==403}function ec(e){let[t,n]=e;return Zs(t,n)}function tc(e){return`${e.baseUrl}:${e.conversationId}`}async function nc(e,t,n,r={},i=!1){let a=Ys();return Xs(e,(await g(p(`${qs(e)}/${t.report.sessionId}/control`),{method:`POST`,keepalive:i,body:JSON.stringify({expectedTranscriptId:t.report.transcriptId,clientId:Ws,assistanceId:t.report.assistanceId,assistanceVersion:t.report.assistanceVersion,operationId:crypto.randomUUID(),epoch:t.report.controlEpoch,op:n,...r})})).payload,a)}async function rc(e,t,n){let r=await f(p(`${qs(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 ic(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 ac(e,t,n,r=!1){return(await g(p(`${qs(e)}/${t.report.sessionId}/execution-mode`),{method:`POST`,body:JSON.stringify({executionMode:n,applyCurrent:r,epoch:t.report.controlEpoch,clientId:Ws})})).payload}function oc(e,t){if(!t.assistanceId||![`needs_user`,`paused`].includes(t.status))return null;let n=m.getState();return JSON.stringify([n.baseUrl,n.conversationId,e,t.transcriptId,t.assistanceId,t.assistanceVersion??1])}var sc=_(bi(e=>({seen:[],markSeen:t=>e(e=>e.seen.includes(t)?e:{seen:[...e.seen.slice(-99),t]})}),{name:`xopc-phone-attention-v1`}));function cc(e){let t=(0,X.c)(15),{detail:n,language:r}=e,i;t[0]===n?i=t[1]:(i=ji(n),t[0]=n,t[1]=i);let a=i,o=r===`zh`,s=a.receipt?.status===`failed`?o?`最近一轮执行失败`:`Latest run failed`:a.receipt?.status===`cancelled`?o?`最近一轮执行已取消`:`Latest run canceled`:a.receipt?o?`最近一轮执行已结束`:`Latest run ended`:o?`尚无本版任务的执行结果`:`No run result for this task version`,c=o?`执行、验收与交付`:`Execution, acceptance and delivery`,l=n.task.phase===`closed`?``:o?`;任务仍未关闭`:`; task remains open`,u;t[2]!==s||t[3]!==l?(u=(0,Z.jsxs)(`p`,{children:[s,l]}),t[2]=s,t[3]=l,t[4]=u):u=t[4];let d=o?`验收:${a.verified}/${a.criteria} 项通过`:`Acceptance: ${a.verified}/${a.criteria} criteria passed`,f=a.criteria===0?o?`,尚未定义验收标准`:`; criteria not defined`:``,p;t[5]!==d||t[6]!==f?(p=(0,Z.jsxs)(`p`,{children:[d,f]}),t[5]=d,t[6]=f,t[7]=p):p=t[7];let m=a.deliverables>0?o?`已关联交付物:${a.deliverables} 项`:`Linked deliverables: ${a.deliverables}`:o?`尚无正式交付物`:`No formal deliverables linked`,h;t[8]===m?h=t[9]:(h=(0,Z.jsx)(`p`,{children:m}),t[8]=m,t[9]=h);let g;return t[10]!==c||t[11]!==u||t[12]!==p||t[13]!==h?(g=(0,Z.jsxs)(`div`,{className:`mt-3 space-y-1 border-t border-edge-subtle pt-3 text-xs leading-5 text-fg-muted`,"aria-label":c,children:[u,p,h]}),t[10]=c,t[11]=u,t[12]=p,t[13]=h,t[14]=g):g=t[14],g}var lc=(0,Q.memo)(function(e){let t=(0,X.c)(58),{taskId:n}=e,r=c(),i=h(uc),a;t[0]===i?a=t[1]:(a=Ti(i),t[0]=i,t[1]=a);let o=a,{data:s}=zs(n);if(!s)return null;let{task:l,operationalState:d}=s,f,p,m,g;if(t[2]!==o.noDecisionNeeded||t[3]!==s||t[4]!==d||t[5]!==l.phase){let e=Oi(s);m=s.attention.length>0;let n;t[10]!==d||t[11]!==l.phase?(n=l.phase!==`closed`&&[`queued`,`running`,`verifying`].includes(d),t[10]=d,t[11]=l.phase,t[12]=n):n=t[12],p=n,f=m?s.attention[0]?.summary??e?.nextAction??e?.summary:l.phase===`closed`?e?.summary:e?.nextAction??e?.summary??o.noDecisionNeeded,g=e?.evidence.filter(dc).length??0,t[2]=o.noDecisionNeeded,t[3]=s,t[4]=d,t[5]=l.phase,t[6]=f,t[7]=p,t[8]=m,t[9]=g}else f=t[6],p=t[7],m=t[8],g=t[9];let _=g,v=o.taskProgress.title,y;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(ws,{className:`size-4`,"aria-hidden":!0}),t[13]=y):y=t[13];let b;t[14]===p?b=t[15]:(b=p?(0,Z.jsx)(`span`,{className:`absolute -right-0.5 -top-0.5 size-2.5 rounded-full border-2 border-surface-panel bg-accent motion-safe:animate-pulse`}):null,t[14]=p,t[15]=b);let x;t[16]===b?x=t[17]:(x=(0,Z.jsxs)(`span`,{className:`relative mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-full bg-accent-soft text-accent-fg`,children:[y,b]}),t[16]=b,t[17]=x);let S;t[18]===o.taskProgress.title?S=t[19]:(S=(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:o.taskProgress.title}),t[18]=o.taskProgress.title,t[19]=S);let C;t[20]===s?C=t[21]:(C=Y(`rounded-full border px-1.5 py-0.5 text-[10px] font-medium`,Ei(Pi(s))),t[20]=s,t[21]=C);let w=o.detailStatuses[Pi(s)],T;t[22]!==C||t[23]!==w?(T=(0,Z.jsx)(`span`,{className:C,children:w}),t[22]=C,t[23]=w,t[24]=T):T=t[24];let E;t[25]!==o.taskProgress.evidence||t[26]!==_?(E=_>0?(0,Z.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[_,` `,o.taskProgress.evidence]}):null,t[25]=o.taskProgress.evidence,t[26]=_,t[27]=E):E=t[27];let D;t[28]!==T||t[29]!==E||t[30]!==S?(D=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[S,T,E]}),t[28]=T,t[29]=E,t[30]=S,t[31]=D):D=t[31];let O;t[32]===l.title?O=t[33]:(O=(0,Z.jsx)(`p`,{className:`mt-1 text-sm font-medium leading-5 text-fg`,children:l.title}),t[32]=l.title,t[33]=O);let k;t[34]===f?k=t[35]:(k=f?(0,Z.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:f}):null,t[34]=f,t[35]=k);let A;t[36]!==D||t[37]!==O||t[38]!==k?(A=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[D,O,k]}),t[36]=D,t[37]=O,t[38]=k,t[39]=A):A=t[39];let j=`${r.pathname}${r.search}`,M;t[40]!==j||t[41]!==l.id?(M=$e(j,l.id),t[40]=j,t[41]=l.id,t[42]=M):M=t[42];let N=m?o.taskProgress.decide:o.taskProgress.open,P;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Z.jsx)(xe,{className:`size-3.5`,"aria-hidden":!0}),t[43]=P):P=t[43];let F;t[44]!==M||t[45]!==N?(F=(0,Z.jsxs)(u,{to:M,className:`inline-flex shrink-0 items-center gap-1 rounded-md px-2 py-1.5 text-xs font-medium text-accent hover:bg-accent-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[N,P]}),t[44]=M,t[45]=N,t[46]=F):F=t[46];let I;t[47]!==A||t[48]!==F||t[49]!==x?(I=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[x,A,F]}),t[47]=A,t[48]=F,t[49]=x,t[50]=I):I=t[50];let L;t[51]!==s||t[52]!==i?(L=(0,Z.jsx)(cc,{detail:s,language:i}),t[51]=s,t[52]=i,t[53]=L):L=t[53];let R;return t[54]!==o.taskProgress.title||t[55]!==I||t[56]!==L?(R=(0,Z.jsxs)(`section`,{className:`mb-6 rounded-xl border border-edge bg-surface-panel px-3 py-3 sm:px-4`,"aria-label":v,"aria-live":`polite`,children:[I,L]}),t[54]=o.taskProgress.title,t[55]=I,t[56]=L,t[57]=R):R=t[57],R});function uc(e){return e.language}function dc(e){return e.strength===`verified`}function fc(e){return e===-5||e===-4||e===-3?`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mcp-conversation-setup-page-Bn49Ph1n.js","assets/rolldown-runtime-aKtaBQYM.js","assets/vendor-react-BOUWij0V.js","assets/chunk-KS7C4IRE-CiwuuyV8.js","assets/preload-helper-Czpn1I53.js","assets/locale-store-cg9cm2EL.js","assets/messages-eQ2CYlpG.js","assets/dist-CY7CS_D3.js","assets/es2015-DBLcMg5B.js","assets/dist-CxGUk8J-.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-Cc4hUNTt.js","assets/chat-terminal-dock-CAaHWS7F.js","assets/plus-Q2yW6OE7.js","assets/square-terminal-K87bylpZ.js","assets/session-api-CQlEq0MB.js","assets/schemas-CCWMleym.js","assets/gateway-startup-retry-BaaoKBoB.js","assets/session-manager-C7RfUfqI.js","assets/constants-DpkUgykJ.js","assets/local-session-drafts-XurtjR58.js","assets/tool-activity-BtJkgjFf.js","assets/attachment-utils-core-BIOUBrpT.js","assets/gateway-realtime-B9u4uSXW.js","assets/gateway-realtime-store-xB7Bq4Zs.js","assets/registry-api-BTd_OgbD.js","assets/agents-admin-api-CKscfdvA.js","assets/gateway-config-swr-OGhON-s6.js","assets/sliding-tab-list-CmcrqRzN.js","assets/sliding-indicator-hwz0sx3h.js","assets/terminal-panel-store-D8eZPvql.js","assets/chat-terminal-dock-uQUnjRtf.css"])))=>i.map(i=>d[i]);
2
+ import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,i as r,n as i,t as a}from"./vendor-react-BOUWij0V.js";import{t as o}from"./preload-helper-Czpn1I53.js";import{f as s,l as c,m as l,t as u,u as d}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{a as f,i as p,l as m,n as h,o as g,p as _,u as v}from"./locale-store-cg9cm2EL.js";import{t as y}from"./messages-eQ2CYlpG.js";import{a as b,c as x,i as S,n as C,o as w,r as T,s as E,t as D}from"./dist-CY7CS_D3.js";import{t as O}from"./createLucideIcon-DPHK1VkS.js";import{t as k}from"./app-window-DXFNqt_0.js";import{t as A}from"./archive-Dz0hferG.js";import{t as j}from"./arrow-left-D880xG-P.js";import{t as M}from"./arrow-up-right-T72JbQ1Q.js";import{t as N}from"./arrow-up-D5ZtR1QT.js";import{a as P,c as F,d as I,f as L,l as R,s as z,t as B,u as V}from"./product-automation-feedback-BN2HTA9T.js";import{n as H,t as U}from"./earth-C9Z4bTTG.js";import{t as W}from"./bot-DjLkhyZL.js";import{t as G}from"./check-DUBLcKHA.js";import{t as ee}from"./chevron-down-ccbiQQz_.js";import{t as te}from"./chevron-right-BweFrslA.js";import{i as ne,r as re,t as ie}from"./working-directory-picker-modal-CeXl9w6z.js";import{a as ae,d as oe,n as se,o as ce,r as le,t as ue}from"./popover-select-CLsphyzA.js";import{t as K}from"./circle-alert-BEjgurr2.js";import{i as q,r as de,t as fe}from"./new-chat-navigation-B6NPQ4h4.js";import{t as pe}from"./circle-x-DFsCKeya.js";import{t as J}from"./circle-BoO4YvTx.js";import{i as me,n as he,r as ge,t as _e}from"./file-tree-utils-DJs1faGv.js";import{t as ve}from"./copy-Dv6d4Dvw.js";import{t as ye}from"./database-CjjeZfRG.js";import{t as be}from"./ellipsis-0k4rZLoy.js";import{t as xe}from"./external-link-DjqjBmc3.js";import{n as Se,t as Ce}from"./file-BqMS_3DT.js";import{t as we}from"./file-image-CDUPkZvG.js";import{t as Te}from"./file-text-D12HbeVy.js";import{t as Ee}from"./folder-kanban-CpLlFI1o.js";import{t as De}from"./folder-open-CyzJ19I9.js";import{t as Oe}from"./folder-CN-pC3XL.js";import{i as ke,r as Ae,u as je}from"./use-file-preview-expanded-dhNMHf5b.js";import{t as Me}from"./git-branch-Dh9uxTot.js";import{t as Ne}from"./globe-DSSGFWFn.js";import{t as Pe}from"./history-DXH_9jsE.js";import{F as Fe,L as Ie,P as Le,c as Re,g as ze,o as Be,t as Ve,v as He}from"./notes-api-CR75RHd0.js";import{t as Ue}from"./key-round-DWbpyU2U.js";import{t as We}from"./laptop-CI3hBVrl.js";import{t as Ge}from"./link-2-D_ZKYUW7.js";import{t as Ke}from"./list-checks-BbsExAoq.js";import{t as qe}from"./list-todo-CTVRto8O.js";import{t as Je}from"./loader-circle-CifKLtgG.js";import{A as Ye,B as Xe,C as Ze,D as Qe,F as $e,P as et,R as tt,S as nt,T as rt,_ as it,b as at,c as ot,d as st,f as ct,g as lt,h as ut,l as dt,m as ft,n as pt,p as mt,r as ht,u as gt,v as _t,w as vt,y as yt}from"./markdown-view-D1zBWkfB.js";import{t as bt}from"./messages-square-BckAJrEW.js";import{t as xt}from"./mic-CuUb7zc-.js";import{t as St}from"./monitor-Af5eAvF7.js";import{s as Ct,t as wt}from"./install-connector-dialog-BsiyYQhx.js";import{t as Tt}from"./paperclip-f1HujQY1.js";import{t as Et}from"./pause-DuPxgSxk.js";import{t as Dt}from"./pencil-DmIY3Oa-.js";import{t as Ot}from"./play-kxZvpBg8.js";import{t as kt}from"./plus-Q2yW6OE7.js";import{t as At}from"./refresh-cw-BRlGaq2w.js";import{t as jt}from"./rotate-ccw-JM1TBLpp.js";import{t as Mt}from"./save-DRDABU--.js";import{t as Nt}from"./search-DA7gz22f.js";import{t as Pt}from"./settings-2-D-csvaET.js";import{t as Ft}from"./settings-uiTATseT.js";import{t as It}from"./shield-check-BU58siTV.js";import{t as Lt}from"./smartphone-DSSsQFqA.js";import{t as Rt}from"./sparkles-DHlfQFAF.js";import{t as zt}from"./square-DMK_fB-3.js";import{t as Bt}from"./trash-2-DusmjVPV.js";import{t as Vt}from"./triangle-alert-2JXFNNKU.js";import{r as Ht,t as Ut}from"./share-link-dialog-ztX1WPXG.js";import{t as Wt}from"./wrench-DFb4r8bH.js";import{t as Gt}from"./x-B_N4OPjy.js";import{t as Kt}from"./zap-dximCGjy.js";import{t as Y}from"./cn-0WouolD0.js";import{t as qt}from"./skeleton-DzdOeGYz.js";import{a as Jt,d as Yt,m as Xt,n as Zt,u as Qt}from"./schemas-CCWMleym.js";import{t as $t}from"./tasks-BTLabOMp.js";import{i as en,n as tn,o as nn,s as rn,t as an}from"./product-delivery-BFfqdKLe.js";import{o as on}from"./local-apps-DeqzkJiF.js";import{a as sn,c as cn,d as ln}from"./api-DPNeNCmR.js";import{a as un,s as dn}from"./session-api-CQlEq0MB.js";import{$ as fn,A as pn,B as mn,C as hn,Ct as gn,D as _n,E as vn,F as yn,G as bn,H as xn,I as Sn,J as Cn,L as wn,M as Tn,N as En,O as Dn,P as On,Q as kn,R as An,S as jn,St as Mn,T as Nn,U as Pn,V as Fn,W as In,X as Ln,Y as Rn,Z as zn,_ as Bn,_t as Vn,at as Hn,b as Un,bt as Wn,c as Gn,d as Kn,et as qn,ft as Jn,g as Yn,gt as Xn,h as Zn,ht as Qn,it as $n,j as er,k as tr,l as nr,lt as rr,m as ir,mt as ar,nt as or,o as sr,ot as cr,q as lr,r as ur,st as dr,t as fr,tt as pr,u as mr,ut as hr,v as gr,vt as _r,w as vr,x as yr,xt as br,y as xr,yt as Sr,z as Cr}from"./session-manager-C7RfUfqI.js";import{a as wr,d as Tr,m as Er,n as Dr,o as Or,p as kr,s as Ar,t as jr,u as Mr}from"./local-session-drafts-XurtjR58.js";import{t as Nr}from"./tool-activity-BtJkgjFf.js";import{a as Pr,c as Fr,i as Ir,l as Lr,n as Rr,o as zr,r as Br,s as Vr,t as Hr}from"./new-session-preferences-gb411vZP.js";import{n as Ur,t as Wr}from"./composer-model-config-control-BrK8-SNz.js";import{i as Gr}from"./vendor-swr-CdRzEUwF.js";import{c as Kr,h as qr,i as Jr,n as Yr,o as Xr,r as Zr,s as Qr,t as $r,v as ei}from"./use-composer-attachments-CLIrD0mm.js";import{a as ti}from"./gateway-config-swr-OGhON-s6.js";import{t as ni}from"./chat-agents-api-UOdNWZ0_.js";import{a as ri,c as ii,i as ai,r as oi,s as si}from"./attachment-utils-core-BIOUBrpT.js";import{n as ci}from"./gateway-realtime-B9u4uSXW.js";import{n as li}from"./gateway-realtime-store-xB7Bq4Zs.js";import{n as ui,t as di}from"./registry-api-BTd_OgbD.js";import{a as fi}from"./agents-admin-api-CKscfdvA.js";import{t as pi}from"./button-Cc4hUNTt.js";import{s as mi}from"./file-preview-surface-z7_HV0WN.js";import{a as hi,i as gi,o as _i,r as vi,s as yi}from"./dist-GJ8-1PAx.js";import{t as bi}from"./middleware-Pd0e8Igk.js";import{i as xi,r as Si}from"./app-link-DImAfVs5.js";import{t as Ci}from"./copy-to-clipboard-HOJ79TWv.js";import{a as wi,c as Ti,d as Ei,i as Di,l as Oi,n as ki,o as Ai,p as ji,r as Mi,s as Ni,u as Pi}from"./composer-payload-handoff-DBE1mvOS.js";import{C as Fi,D as Ii,E as Li,T as Ri,_ as zi,b as Bi,c as Vi,d as Hi,f as Ui,g as Wi,h as Gi,m as Ki,n as qi,o as Ji,p as Yi,r as Xi,s as Zi,u as Qi,v as $i,w as ea,x as ta,y as na}from"./chunk-D32TOXHM-DQIy-Baq.js";import{i as ra,n as ia,r as aa,t as oa}from"./chat-chart-block-NSy-B0NS.js";import{t as sa}from"./linkify-it-BkqEorO0.js";import{n as ca}from"./interaction-BdhHBbYa.js";import{a as la,i as ua,n as da,o as fa,r as pa,s as ma,t as ha}from"./tool-friendly-title-CP35P4VA.js";import{s as ga}from"./connectors-api-CgsSm-Av.js";import{t as _a}from"./use-realtime-voice-DDVVlX1R.js";import{t as va}from"./activity-store-DYwR1u3f.js";import{t as ya}from"./composer-notifications-B-kL3qAA.js";import{n as ba}from"./voice-call-context-BM2A4bLz.js";import{r as xa}from"./app-chrome-BeB4KgOf.js";import{i as Sa,n as Ca,r as wa}from"./form-field-width-DJw_jULe.js";import{n as Ta}from"./electron-env-DHOGevH3.js";import{t as Ea}from"./page-header-store-DU4NnGap.js";import{t as Da}from"./use-async-resource-BHFGZCY2.js";import{t as Oa}from"./loopi-CNtmi9FU.js";import{a as ka}from"./extension-provider-CbVokTvd.js";import{t as Aa}from"./agent-avatar-display-DqFYHXCS.js";import{a as ja,n as Ma,r as Na,t as Pa}from"./skill-wire-pattern-BPpeIcCi.js";import{n as Fa,t as Ia}from"./use-directory-picker-C4p7AgWY.js";import{t as La}from"./confirm-dialog-DrA5mTQp.js";import{a as Ra,c as za,f as Ba,l as Va,s as Ha,u as Ua}from"./workspace-api-B1Uirhxf.js";import{n as Wa}from"./index.module-Cd9ENXfk.js";import{a as Ga,i as Ka,o as qa,r as Ja,s as Ya}from"./copy-text-row-CpiRzq4G.js";import{_ as Xa,b as Za,d as Qa,f as $a,h as eo,i as to,n as no,p as ro,s as io,u as ao,y as oo}from"./shares-api-CSZqeNL4.js";import{t as so}from"./workspace-editor-agent-store-Nos5ebMv.js";import{l as co,m as lo,o as uo,r as fo,t as po,u as mo}from"./dist-ZrL34Ps4.js";import{a as ho,c as go,d as _o,f as vo,h as yo,i as bo,l as xo,m as So,p as Co,s as wo,t as To,u as Eo}from"./command-palette-api-Dkn9bbYd.js";import{n as Do,o as Oo,r as ko,s as Ao}from"./voice-input-shortcut-events-Cc30ZcFy.js";import{D as jo,E as Mo,O as No,T as Po,i as Fo,t as Io}from"./automation-task-card-BY_k6iWp.js";import{t as Lo}from"./dev-view-store-BOxbj1ie.js";import{t as Ro}from"./extension-iframe-host-DiIqM2JO.js";import{i as zo,r as Bo,t as Vo}from"./runtime-health-zDkHcOZO.js";import{c as Ho,i as Uo,r as Wo}from"./api-CHM2c_Ah.js";import{r as Go}from"./terminal-panel-store-D8eZPvql.js";import{n as Ko}from"./agents-app-path-ciChvpCS.js";import{n as qo,t as Jo}from"./agent-display-names-Bje7vfSn.js";import{t as Yo}from"./oauth-provider-connect-Dk1NeeqD.js";import{t as Xo}from"./use-media-query-ady-FgjK.js";import{n as Zo,r as Qo,t as $o}from"./oauth-authorization-window-o6URRos4.js";import{n as es,t as ts}from"./page-context-draft-Ckb8baxj.js";import{i as ns,r as rs}from"./management-api-B6jVuJ6W.js";import{t as is}from"./side-chat-shortcut-BIw-1TTD.js";var as=O(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),os=O(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),ss=O(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),cs=O(`corner-down-right`,[[`path`,{d:`m15 10 5 5-5 5`,key:`qqa56n`}],[`path`,{d:`M4 4v7a4 4 0 0 0 4 4h12`,key:`z08zvw`}]]),ls=O(`file-headphone`,[[`path`,{d:`M4 6.835V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-.343`,key:`1vfytu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M2 19a2 2 0 0 1 4 0v1a2 2 0 0 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 0 1-4 0v-1a2 2 0 0 1 4 0`,key:`1etmh7`}]]),us=O(`file-pen-line`,[[`path`,{d:`M14.364 13.634a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506l4.013-4.009a1 1 0 0 0-3.004-3.004z`,key:`ukzhwg`}],[`path`,{d:`M14.487 7.858A1 1 0 0 1 14 7V2`,key:`1klhew`}],[`path`,{d:`M20 19.645V20a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l2.516 2.516`,key:`rxaxab`}],[`path`,{d:`M8 18h1`,key:`13wk12`}]]),ds=O(`file-plus-corner`,[[`path`,{d:`M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35`,key:`17jvcc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M14 19h6`,key:`bvotb8`}],[`path`,{d:`M17 16v6`,key:`18yu1i`}]]),fs=O(`files`,[[`path`,{d:`M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8`,key:`14sh0y`}],[`path`,{d:`M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z`,key:`1970lx`}],[`path`,{d:`M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1`,key:`l4dndm`}]]),ps=O(`git-commit-horizontal`,[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]]),ms=O(`git-fork`,[[`circle`,{cx:`12`,cy:`18`,r:`3`,key:`1mpf1b`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`path`,{d:`M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9`,key:`1uq4wg`}],[`path`,{d:`M12 12v3`,key:`158kv8`}]]),hs=O(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),gs=O(`layout-template`,[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`9`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`jqznyg`}],[`rect`,{width:`5`,height:`7`,x:`16`,y:`14`,rx:`1`,key:`q5h2i8`}]]),_s=O(`message-circle-more`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}]]),vs=O(`message-circle-plus`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]]),ys=O(`message-square-share`,[[`path`,{d:`M12 3H4a2 2 0 0 0-2 2v16.286a.71.71 0 0 0 1.212.502l2.202-2.202A2 2 0 0 1 6.828 19H20a2 2 0 0 0 2-2v-4`,key:`11da1y`}],[`path`,{d:`M16 3h6v6`,key:`1bx56c`}],[`path`,{d:`m16 9 6-6`,key:`m4dnic`}]]),bs=O(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),xs=O(`notebook-pen`,[[`path`,{d:`M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4`,key:`re6nr2`}],[`path`,{d:`M2 6h4`,key:`aawbzj`}],[`path`,{d:`M2 10h4`,key:`l0bgd4`}],[`path`,{d:`M2 14h4`,key:`1gsvsf`}],[`path`,{d:`M2 18h4`,key:`1bu2t1`}],[`path`,{d:`M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`pqwjuv`}]]),Ss=O(`shuffle`,[[`path`,{d:`m18 14 4 4-4 4`,key:`10pe0f`}],[`path`,{d:`m18 2 4 4-4 4`,key:`pucp1d`}],[`path`,{d:`M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22`,key:`1ailkh`}],[`path`,{d:`M2 6h1.972a4 4 0 0 1 3.6 2.2`,key:`km57vx`}],[`path`,{d:`M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45`,key:`os18l9`}]]),Cs=O(`square-plus`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]]),ws=O(`target`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),Ts=O(`wallet`,[[`path`,{d:`M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1`,key:`18etb6`}],[`path`,{d:`M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4`,key:`xoc0q4`}]]);function Es(e,t){return e.replace(/\{\{(\w+)}}/g,(e,n)=>t[n]?.trim()??``).replace(/[ \t]{2,}/g,` `).trim()}function Ds(e,t,n){return{id:e,title:Es(t.title,n),prompt:Es(t.prompt,n),reason:Es(t.reason,n)}}function Os(e,t){let n={projectName:e.projectName,blockedReason:e.blockedReason,recentFailure:e.recentFailure,nextAction:e.recommendedAction};if(e.blockedReason?.trim())return Ds(`project-blocked`,t.recommendations.projectBlocked,n);if(e.recentFailure?.trim())return Ds(`project-failure`,t.recommendations.projectFailure,n);if(e.recommendedAction?.trim())return Ds(`project-next-action`,t.recommendations.projectNextAction,n)}function ks(e,t){let n={taskTitle:e.taskTitle,attentionSummary:e.attentionSummary,recentFailure:e.recentFailure,nextAction:e.nextAction};if(e.attentionSummary?.trim())return Ds(`task-attention`,t.recommendations.taskAttention,n);if(e.recentFailure?.trim())return Ds(`task-failure`,t.recommendations.taskFailure,n);if(e.phase===`review`||e.operationalState===`verifying`)return Ds(`task-review`,t.recommendations.taskReview,n);if(e.phase===`closed`)return Ds(`task-closed`,t.recommendations.taskClosed,n);if(e.nextAction?.trim())return Ds(`task-next-action`,t.recommendations.taskNextAction,n)}function As(e,t){switch(e.kind){case`project`:return Os(e,t);case`task`:return ks(e,t);default:return}}function js(e,t,n={}){let r=n.contextStatus??`ready`;return{headline:e.kind===`project`&&t.projectHeadline?Es(t.projectHeadline,{projectName:e.projectName}):t.headline,contextKind:e.kind,contextStatus:r,recommendation:r===`ready`?As(e,t):void 0}}var Ms=Yt({id:Xt().uuid(),conversationId:Xt(),transcriptId:Xt(),sourceRunId:Xt(),inputRevision:Qt().int().nonnegative(),transcriptCursor:Qt().int().nonnegative(),agentId:Xt(),locale:Zt([`zh`,`en`]),prompt:Xt().min(1).max(160),expiresAt:Qt()}),Ns=Yt({status:Zt([`ready`,`pending`,`none`]),suggestion:Ms.optional()});Yt({suggestionId:Xt().uuid(),impressionId:Xt().uuid(),event:Zt([`shown`,`accepted`,`dismissed`,`submitted`]),edited:Jt().optional()}).strict();function Ps(e,t=`body`){return`result:${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Fs(e){return`${e.taskRunId}:${e.assignmentEpoch}:${e.outcome.outcomeId}`}var Is=e(r(),1),X=i(),Z=a(),Q=e(n(),1);function Ls(e,t){return e?[`task-detail`,e,t??``]:null}function Rs(e,t){return t.source!==`user`||e===void 0||t.version>e}function zs(e){let t=m(e=>e.conversationId),[n,r]=(0,Q.useState)(null),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(null),c=(0,Q.useRef)(``),l=(0,Q.useRef)(void 0),u=Gr(Ls(e,t),()=>ei(e),{keepPreviousData:!1,revalidateOnFocus:!0,revalidateOnReconnect:!0,refreshInterval:e=>e&&[`allocating`,`queued`,`running`,`waiting`,`verifying`].includes(e.operationalState)?5e3:0});return l.current=u.data?.task.version,(0,Q.useEffect)(()=>{r(null),a(!1),s(null),c.current=``},[e]),(0,Q.useEffect)(()=>{let t=u.data;if(!t||t.conversation.activeConversationId||t.allocation&&t.allocation.status!==`assigned`)return;let n=`${e}:${t.task.version}`;c.current!==n&&(c.current=n,a(!0),s(null),qr(e).then(()=>c.current===n?u.mutate():void 0).catch(e=>{c.current===n&&s(e)}).finally(()=>{c.current===n&&a(!1)}))},[u.data,u.mutate,e]),(0,Q.useEffect)(()=>{let t,n=()=>{window.clearTimeout(t),t=window.setTimeout(()=>void u.mutate(),120)},i=t=>{let i=$t.safeParse(t.detail);!i.success||i.data.taskId!==e||Rs(l.current,i.data)&&(r(i.data),n())},a=()=>n();return window.addEventListener(`task-changed-v2`,i),window.addEventListener(`gateway-realtime-connected`,a),window.addEventListener(`realtime-gap`,a),()=>{window.clearTimeout(t),window.removeEventListener(`task-changed-v2`,i),window.removeEventListener(`gateway-realtime-connected`,a),window.removeEventListener(`realtime-gap`,a)}},[u.mutate,e]),{...u,lastChange:n,conversationLoading:i,conversationError:o}}var Bs=new Map,Vs=new Set;function Hs(e,t){Bs.set(e,t);for(let e of Vs)e();return()=>{Bs.get(e)===t&&Bs.delete(e)}}async function Us(e,t,n){await(Bs.get(e)??await new Promise((t,n)=>{let r=()=>{let n=Bs.get(e);n&&(clearTimeout(i),Vs.delete(r),t(n))},i=setTimeout(()=>{Vs.delete(r),n(Error(`Chat input is not ready. Please retry.`))},15e3);Vs.add(r),r()}))(t,n)}var Ws=crypto.randomUUID(),Gs=e=>e===`closed`;function Ks(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 qs=e=>`/api/phone/conversations/${encodeURIComponent(e)}`,Js=new Map,Ys=()=>{let e=m.getState();return`${e.baseUrl}:${e.conversationId}`};function Xs(e,t,n=Ys()){let r=`${n}:${e}`,i=Js.get(r);return t&&i&&t.report.sessionId===i.report.sessionId&&(t.report.revision??0)<(i.report.revision??0)?i:(t?(Js.set(r,t),Js.size>100&&Js.delete(Js.keys().next().value)):Js.delete(r),t)}async function Zs(e,t=Ys()){let n=await f(p(e)),r=decodeURIComponent(e.split(`/conversations/`)[1]?.split(`?`)[0]??``);if(n.status===404)return Xs(r,null,t);if((n.status===401||n.status===403)&&Xs(r,null,t),!n.ok)throw Object.assign(Error(`Phone view unavailable (HTTP ${n.status})`),{status:n.status});return Xs(r,(await n.json()).payload,t)}function Qs(e,t){let n=(0,X.c)(5),r=t===void 0||t,i=m(tc),a;n[0]!==e||n[1]!==r||n[2]!==i?(a=r&&/^(?:device:)?[\da-f]{8}-[\da-f-]{27}$/i.test(e)?[`${qs(e)}?clientId=${Ws}`,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:$s,errorRetryCount:6,errorRetryInterval:2e3,refreshWhenHidden:!1},n[4]=o):o=n[4],Gr(a,ec,o)}function $s(e){return e.status!==401&&e.status!==403}function ec(e){let[t,n]=e;return Zs(t,n)}function tc(e){return`${e.baseUrl}:${e.conversationId}`}async function nc(e,t,n,r={},i=!1){let a=Ys();return Xs(e,(await g(p(`${qs(e)}/${t.report.sessionId}/control`),{method:`POST`,keepalive:i,body:JSON.stringify({expectedTranscriptId:t.report.transcriptId,clientId:Ws,assistanceId:t.report.assistanceId,assistanceVersion:t.report.assistanceVersion,operationId:crypto.randomUUID(),epoch:t.report.controlEpoch,op:n,...r})})).payload,a)}async function rc(e,t,n){let r=await f(p(`${qs(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 ic(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 ac(e,t,n,r=!1){return(await g(p(`${qs(e)}/${t.report.sessionId}/execution-mode`),{method:`POST`,body:JSON.stringify({executionMode:n,applyCurrent:r,epoch:t.report.controlEpoch,clientId:Ws})})).payload}function oc(e,t){if(!t.assistanceId||![`needs_user`,`paused`].includes(t.status))return null;let n=m.getState();return JSON.stringify([n.baseUrl,n.conversationId,e,t.transcriptId,t.assistanceId,t.assistanceVersion??1])}var sc=_(bi(e=>({seen:[],markSeen:t=>e(e=>e.seen.includes(t)?e:{seen:[...e.seen.slice(-99),t]})}),{name:`xopc-phone-attention-v1`}));function cc(e){let t=(0,X.c)(15),{detail:n,language:r}=e,i;t[0]===n?i=t[1]:(i=ji(n),t[0]=n,t[1]=i);let a=i,o=r===`zh`,s=a.receipt?.status===`failed`?o?`最近一轮执行失败`:`Latest run failed`:a.receipt?.status===`cancelled`?o?`最近一轮执行已取消`:`Latest run canceled`:a.receipt?o?`最近一轮执行已结束`:`Latest run ended`:o?`尚无本版任务的执行结果`:`No run result for this task version`,c=o?`执行、验收与交付`:`Execution, acceptance and delivery`,l=n.task.phase===`closed`?``:o?`;任务仍未关闭`:`; task remains open`,u;t[2]!==s||t[3]!==l?(u=(0,Z.jsxs)(`p`,{children:[s,l]}),t[2]=s,t[3]=l,t[4]=u):u=t[4];let d=o?`验收:${a.verified}/${a.criteria} 项通过`:`Acceptance: ${a.verified}/${a.criteria} criteria passed`,f=a.criteria===0?o?`,尚未定义验收标准`:`; criteria not defined`:``,p;t[5]!==d||t[6]!==f?(p=(0,Z.jsxs)(`p`,{children:[d,f]}),t[5]=d,t[6]=f,t[7]=p):p=t[7];let m=a.deliverables>0?o?`已关联交付物:${a.deliverables} 项`:`Linked deliverables: ${a.deliverables}`:o?`尚无正式交付物`:`No formal deliverables linked`,h;t[8]===m?h=t[9]:(h=(0,Z.jsx)(`p`,{children:m}),t[8]=m,t[9]=h);let g;return t[10]!==c||t[11]!==u||t[12]!==p||t[13]!==h?(g=(0,Z.jsxs)(`div`,{className:`mt-3 space-y-1 border-t border-edge-subtle pt-3 text-xs leading-5 text-fg-muted`,"aria-label":c,children:[u,p,h]}),t[10]=c,t[11]=u,t[12]=p,t[13]=h,t[14]=g):g=t[14],g}var lc=(0,Q.memo)(function(e){let t=(0,X.c)(58),{taskId:n}=e,r=c(),i=h(uc),a;t[0]===i?a=t[1]:(a=Ti(i),t[0]=i,t[1]=a);let o=a,{data:s}=zs(n);if(!s)return null;let{task:l,operationalState:d}=s,f,p,m,g;if(t[2]!==o.noDecisionNeeded||t[3]!==s||t[4]!==d||t[5]!==l.phase){let e=Oi(s);m=s.attention.length>0;let n;t[10]!==d||t[11]!==l.phase?(n=l.phase!==`closed`&&[`queued`,`running`,`verifying`].includes(d),t[10]=d,t[11]=l.phase,t[12]=n):n=t[12],p=n,f=m?s.attention[0]?.summary??e?.nextAction??e?.summary:l.phase===`closed`?e?.summary:e?.nextAction??e?.summary??o.noDecisionNeeded,g=e?.evidence.filter(dc).length??0,t[2]=o.noDecisionNeeded,t[3]=s,t[4]=d,t[5]=l.phase,t[6]=f,t[7]=p,t[8]=m,t[9]=g}else f=t[6],p=t[7],m=t[8],g=t[9];let _=g,v=o.taskProgress.title,y;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(ws,{className:`size-4`,"aria-hidden":!0}),t[13]=y):y=t[13];let b;t[14]===p?b=t[15]:(b=p?(0,Z.jsx)(`span`,{className:`absolute -right-0.5 -top-0.5 size-2.5 rounded-full border-2 border-surface-panel bg-accent motion-safe:animate-pulse`}):null,t[14]=p,t[15]=b);let x;t[16]===b?x=t[17]:(x=(0,Z.jsxs)(`span`,{className:`relative mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-full bg-accent-soft text-accent-fg`,children:[y,b]}),t[16]=b,t[17]=x);let S;t[18]===o.taskProgress.title?S=t[19]:(S=(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:o.taskProgress.title}),t[18]=o.taskProgress.title,t[19]=S);let C;t[20]===s?C=t[21]:(C=Y(`rounded-full border px-1.5 py-0.5 text-[10px] font-medium`,Ei(Pi(s))),t[20]=s,t[21]=C);let w=o.detailStatuses[Pi(s)],T;t[22]!==C||t[23]!==w?(T=(0,Z.jsx)(`span`,{className:C,children:w}),t[22]=C,t[23]=w,t[24]=T):T=t[24];let E;t[25]!==o.taskProgress.evidence||t[26]!==_?(E=_>0?(0,Z.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[_,` `,o.taskProgress.evidence]}):null,t[25]=o.taskProgress.evidence,t[26]=_,t[27]=E):E=t[27];let D;t[28]!==T||t[29]!==E||t[30]!==S?(D=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[S,T,E]}),t[28]=T,t[29]=E,t[30]=S,t[31]=D):D=t[31];let O;t[32]===l.title?O=t[33]:(O=(0,Z.jsx)(`p`,{className:`mt-1 text-sm font-medium leading-5 text-fg`,children:l.title}),t[32]=l.title,t[33]=O);let k;t[34]===f?k=t[35]:(k=f?(0,Z.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:f}):null,t[34]=f,t[35]=k);let A;t[36]!==D||t[37]!==O||t[38]!==k?(A=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[D,O,k]}),t[36]=D,t[37]=O,t[38]=k,t[39]=A):A=t[39];let j=`${r.pathname}${r.search}`,M;t[40]!==j||t[41]!==l.id?(M=$e(j,l.id),t[40]=j,t[41]=l.id,t[42]=M):M=t[42];let N=m?o.taskProgress.decide:o.taskProgress.open,P;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Z.jsx)(xe,{className:`size-3.5`,"aria-hidden":!0}),t[43]=P):P=t[43];let F;t[44]!==M||t[45]!==N?(F=(0,Z.jsxs)(u,{to:M,className:`inline-flex shrink-0 items-center gap-1 rounded-md px-2 py-1.5 text-xs font-medium text-accent hover:bg-accent-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[N,P]}),t[44]=M,t[45]=N,t[46]=F):F=t[46];let I;t[47]!==A||t[48]!==F||t[49]!==x?(I=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[x,A,F]}),t[47]=A,t[48]=F,t[49]=x,t[50]=I):I=t[50];let L;t[51]!==s||t[52]!==i?(L=(0,Z.jsx)(cc,{detail:s,language:i}),t[51]=s,t[52]=i,t[53]=L):L=t[53];let R;return t[54]!==o.taskProgress.title||t[55]!==I||t[56]!==L?(R=(0,Z.jsxs)(`section`,{className:`mb-6 rounded-xl border border-edge bg-surface-panel px-3 py-3 sm:px-4`,"aria-label":v,"aria-live":`polite`,children:[I,L]}),t[54]=o.taskProgress.title,t[55]=I,t[56]=L,t[57]=R):R=t[57],R});function uc(e){return e.language}function dc(e){return e.strength===`verified`}function fc(e){return e===-5||e===-4||e===-3?`
3
3
  `:e<0?` `:String.fromCharCode(e)}var pc={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 mc(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?nt(a):Ze(a))?(c&&t.exit(`xopcMathValue`),t.exit(l),n(i)):r(i)}function f(n){if(n===null)return d(n);let l=fc(n);if(l===`
4
4
  `)return e&&i.interrupt||!e||o?d(n):(c&&t.exit(`xopcMathValue`),c=!1,t.attempt(pc,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===`
@@ -13,17 +13,17 @@ import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,i as r,n
13
13
 
14
14
  `).trim()}function Dm(e){if(!e.trim())return``;let t=lt.parse(e,{gfm:!0,breaks:!1});return new DOMParser().parseFromString(`<div>${t}</div>`,`text/html`).body.textContent?.trim()??``}function Om(e){let t=[],n=new Set(In(e,{includePending:!0}));for(let r of e)if(r.type===`text`){if(!n.has(r))continue;t.push(Dm(r.text))}else r.type===`image`&&t.push(`[image]`);return t.join(`
15
15
 
16
- `).trim()}var km=new WeakMap,Am=new WeakMap,jm=new WeakMap,Mm=new WeakMap;function Nm(e,t){if(!e)return;let n=e=>{let t=jm.get(e);return t||(t=new Map(e.content.flatMap(e=>{let t=or(e);return t?[[t,e]]:[]})),jm.set(e,t)),t},r=e.streamingMsg&&n(e.streamingMsg).get(t);if(r)return r;let i=Mm.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);Mm.set(e.messages,i)}return i.get(t)}function Pm(e,t){return e===t?!0:!e||!t||e.content.length!==t.content.length||!e.content.every((e,n)=>{let r=t.content[n];return e===r||e.type===`text`&&r.type===`text`&&or(e)===or(r)&&e.segmentId===r.segmentId&&e.presentation===r.presentation&&!!e.text.trim()==!!r.text.trim()&&(e.text===r.text||![e.text,r.text].some(e=>{let t=e.trimStart();return t.startsWith(`NO_REPLY`)||t.length>0&&`NO_REPLY`.startsWith(t)}))})?!1:[...new Set([...Object.keys(e),...Object.keys(t)])].every(n=>n===`content`||e[n]===t[n])}function Fm(){let e;return t=>(Pm(e??null,t??null)||(e=t),e)}function Im(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=Am.get(n);if(r?.previous===t)return r.row;let i=dr([t,n]).at(-1);return Am.set(n,{previous:t,row:i}),i}let r=km.get(e.messages);return r||(r=new Map(e.messages.filter(e=>e.renderKey).map(e=>[e.renderKey,e])),km.set(e.messages,r)),r.get(t)}function Lm(){let e;return t=>{if(!t||!e)return e=t,t;let n=Pm(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 Rm(e){let t=(0,X.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=Lm(),t[0]=n):n=t[0];let r=n,i;t[1]===e?i=t[2]:(i=()=>r(e?Nn.getState().sessions[e]:void 0),t[1]=e,t[2]=i);let a=i;return(0,Q.useSyncExternalStore)(Nn.subscribe,a,a)}function zm(e,t){let n=(0,Q.useMemo)(()=>{let n=t();return{read:()=>n,subscribe:r=>{let i=null,a=null,o=()=>{i!==null&&cancelAnimationFrame(i),a!==null&&clearTimeout(a),i=null,a=null},s=()=>{o();let e=t();n!==e&&(n=e,r())},c=Nn.subscribe((r,o)=>{if(t()===n)return;let c=e?r.sessions[e]:void 0,l=e?o.sessions[e]:void 0;if(c?.streaming!==l?.streaming||c?.messages!==l?.messages){s();return}i===null&&(i=requestAnimationFrame(s),a=setTimeout(s,50))});return s(),()=>{o(),c()}}}},[e,t]);return(0,Q.useSyncExternalStore)(n.subscribe,n.read,n.read)}function Bm(e,t){let n=(0,X.c)(4),r;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=Fm(),n[0]=r):r=n[0];let i=r,a;return n[1]!==e||n[2]!==t?(a=()=>i(e&&t?Im(Nn.getState().sessions[e],t):void 0),n[1]=e,n[2]=t,n[3]=a):a=n[3],zm(e,a)}function Vm(e,t){let n=(0,X.c)(3),r;return n[0]!==e||n[1]!==t?(r=()=>e&&t?Nm(Nn.getState().sessions[e],t):void 0,n[0]=e,n[1]=t,n[2]=r):r=n[2],zm(e,r)}function Hm(e,t){let n=(0,X.c)(7),r;n[0]===t?r=n[1]:(r=t.join(`,`),n[0]=t,n[1]=r);let i=r,a;n[2]===i?a=n[3]:(a=i?i.split(`,`):[],n[2]=i,n[3]=a);let o=a,s;return n[4]!==e||n[5]!==o?(s=()=>{if(!e||!o.length)return;let t=Nn.getState().sessions[e],n=o.map(e=>Nm(t,e));if(!n.some(Wm))return n.map(Um).join(``)},n[4]=e,n[5]=o,n[6]=s):s=n[6],zm(e,s)}function Um(e){return e?.type===`text`?e.text:``}function Wm(e){return e?.type!==`text`}function Gm(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)})})(ja(),e=>({kind:`skill`,name:e[1]??``}));for(let n of Eo(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 Km(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 qm(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 Jm(e){let t=(0,X.c)(6),{contextRef:n}=e;if(n?.kind===`file`&&n.fileKind===`directory`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Oe,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[0]=e):e=t[0],e}if(n?.kind===`file`){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Te,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[1]=e):e=t[1],e}if(n?.kind===`session`){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(bt,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[2]=e):e=t[2],e}if(n?.kind===`browser_tab`){let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(k,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[3]=e):e=t[3],e}if(n?.kind===`mcp_resource`){let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(ye,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[4]=e):e=t[4],e}let r;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(xs,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=r):r=t[5],r}var Ym=(0,Q.memo)(function(e){let t=(0,X.c)(24),{text:n,conversationId:r,document:i,contextRefs:a}=e,o=h(Xm),s;t[0]===o?s=t[1]:(s=y(o),t[0]=o,t[1]=s);let c=s.chat.referenceFallback,l;bb0:{if(!i){let e;t[2]===n?e=t[3]:(e=Gm(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(Zm)??[]);e=i.parts.flatMap(e=>e.type===`text`?Gm(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=Km(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(Qm),t[9]=u,t[10]=p);let m=Gp(void 0,r,p);if(!u.some($m)){let e;return t[11]===n?e=t[12]:(e=(0,Z.jsx)(`div`,{className:`markdown-content min-w-0`,children:(0,Z.jsx)(cf,{content:n,compact:!0,breaks:!0})}),t[11]=n,t[12]=e),e}let g;if(t[13]!==u||t[14]!==f||t[15]!==c||t[16]!==m){let e;t[18]!==u||t[19]!==c||t[20]!==m?(e=(e,t)=>{let{part:n,key:r}=e;return n.kind===`skill`?(0,Z.jsxs)(`span`,{className:`chat-skill-pill max-w-full shrink-0`,"data-skill":n.name,title:`/${n.name}`,children:[`/`,m(n.name)]},r):n.kind===`command`?(0,Z.jsxs)(`span`,{className:`chat-command-pill max-w-full shrink-0`,"data-slash-command":n.name,children:[`/`,n.name]},r):n.kind===`context_ref`?(0,Z.jsxs)(`span`,{className:Y(`chat-context-ref-pill chat-context-ref-pill-message max-w-full shrink-0`,qm(u,t)),"data-context-ref-id":n.refId,"data-ref-kind":n.ref?.kind??``,"data-file-kind":n.ref?.fileKind??``,title:n.ref?.title,"aria-label":n.ref?.title??c,children:[(0,Z.jsx)(Jm,{contextRef:n.ref}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:n.ref?.title??c})]},r):n.text?(0,Z.jsx)(`div`,{className:`chat-user-message-segment markdown-content inline-block min-w-0 max-w-full align-baseline text-fg`,children:(0,Z.jsx)(cf,{content:n.text,compact:!0,breaks:!0})},r):null},t[18]=u,t[19]=c,t[20]=m,t[21]=e):e=t[21],g=f.map(e),t[13]=u,t[14]=f,t[15]=c,t[16]=m,t[17]=g}else g=t[17];let _;return t[22]===g?_=t[23]:(_=(0,Z.jsx)(`span`,{className:`inline-flex max-w-full flex-wrap items-baseline gap-x-0 gap-y-1 [text-align:inherit]`,children:g}),t[22]=g,t[23]=_),_});function Xm(e){return e.language}function Zm(e){return e.refId?[[e.refId,e]]:[]}function Qm(e){return e.kind===`skill`}function $m(e){return e.kind!==`text`}function eh(e,t){switch(e.code){case`provider_setup_required`:return{title:t.providerSetupRequiredTitle,body:t.providerSetupRequiredBody.replace(`{{provider}}`,e.provider??t.agentRunErrorUnknownProvider),cta:t.providerSetupRequiredCta,deepLink:`/settings/capabilities/models`};case`provider_auth_invalid`:return{title:t.agentRunErrorAuthInvalidTitle,body:t.agentRunErrorAuthInvalidBody.replace(`{{provider}}`,e.provider??t.agentRunErrorUnknownProvider),cta:t.agentRunErrorCtaProviders,deepLink:`/settings/capabilities/models`};case`rate_limit`:return{title:t.agentRunErrorRateLimitTitle,body:t.agentRunErrorRateLimitBody};case`timeout`:return{title:t.agentRunErrorTimeoutTitle,body:t.agentRunErrorTimeoutBody};case`provider_connection_error`:return{title:t.agentRunErrorConnectionTitle,body:t.agentRunErrorConnectionBody};case`billing`:return{title:t.agentRunErrorBillingTitle,body:t.agentRunErrorBillingBody};case`credit_budget_exhausted`:return{title:t.creditBudgetExhaustedTitle,body:t.creditBudgetExhaustedBody,cta:t.creditBudgetSettingsCta,deepLink:`/settings/agent-defaults?panel=runtime`};case`model_quota_exhausted`:return{title:t.xopcQuotaExhaustedTitle,body:t.xopcQuotaExhaustedBody};case`platform_token_limit_exceeded`:return{title:t.xopcPlatformLimitTitle,body:t.xopcPlatformLimitBody,cta:t.xopcPlatformLimitCta,deepLink:`/settings/capabilities/models?add=1`};case`send_failed`:return{title:t.agentRunErrorSendFailedTitle,body:t.agentRunErrorSendFailedBody};case`session_not_found`:return{title:t.sessionNotFoundTitle,body:t.sessionNotFoundBody,cta:t.sessionNotFoundCta,deepLink:`/chat/new`};default:return{title:t.agentRunErrorUnknownTitle,body:t.agentRunErrorUnknownBody}}}function th(e){let t=(0,X.c)(4),{code:n}=e;switch(n){case`provider_setup_required`:case`provider_auth_invalid`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Ue,{className:`size-4`,strokeWidth:1.75}),t[0]=e):e=t[0],e}case`rate_limit`:case`timeout`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(me,{className:`size-4`,strokeWidth:1.75}),t[1]=e):e=t[1],e}case`billing`:case`credit_budget_exhausted`:case`model_quota_exhausted`:case`platform_token_limit_exceeded`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Ts,{className:`size-4`,strokeWidth:1.75}),t[2]=e):e=t[2],e}default:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(K,{className:`size-4`,strokeWidth:1.75}),t[3]=e):e=t[3],e}}}function nh(e){return e===`provider_setup_required`||e===`provider_auth_invalid`||e===`rate_limit`||e===`timeout`||e===`billing`||e===`model_quota_exhausted`||e===`platform_token_limit_exceeded`||e===`session_not_found`?`amber`:`red`}function rh(e){let t=(0,X.c)(46),{payload:n}=e,r=d(),i=h(ah),a,o;t[0]!==i||t[1]!==n?(a=y(i).chat,o=eh(n,a),t[0]=i,t[1]=n,t[2]=a,t[3]=o):(a=t[2],o=t[3]);let s=o,c=nh(n.code),l=c===`amber`?`border-amber-300/60 bg-amber-50 dark:border-amber-500/30 dark:bg-amber-950`:`border-red-300/60 bg-red-50 dark:border-red-500/30 dark:bg-red-950`,u=c===`amber`?`bg-amber-100 text-amber-700 dark:bg-amber-500/20 dark:text-amber-300`:`bg-red-100 text-red-700 dark:bg-red-500/20 dark:text-red-300`,f=c===`amber`?`text-amber-900 dark:text-amber-100`:`text-red-900 dark:text-red-100`,p=c===`amber`?`text-amber-900/85 dark:text-amber-100/80`:`text-red-900/85 dark:text-red-100/80`,m=c===`amber`?`text-amber-800/80 hover:text-amber-900 dark:text-amber-200/80 dark:hover:text-amber-100`:`text-red-800/80 hover:text-red-900 dark:text-red-200/80 dark:hover:text-red-100`,g=c===`amber`?`bg-amber-100/60 text-amber-900 dark:bg-amber-500/15 dark:text-amber-100`:`bg-red-100/60 text-red-900 dark:bg-red-500/15 dark:text-red-100`,_=c===`amber`?`bg-amber-600 text-white hover:bg-amber-700 dark:bg-amber-500 dark:text-amber-950 dark:hover:bg-amber-400`:`bg-red-600 text-white hover:bg-red-700 dark:bg-red-500 dark:text-red-950 dark:hover:bg-red-400`,v=n.code===`model_quota_exhausted`,b=ih,x;t[4]===l?x=t[5]:(x=Y(`flex flex-col gap-2 rounded-xl border p-3`,l),t[4]=l,t[5]=x);let S;t[6]===u?S=t[7]:(S=Y(`flex size-8 shrink-0 items-center justify-center rounded-lg`,u),t[6]=u,t[7]=S);let C;t[8]===n.code?C=t[9]:(C=(0,Z.jsx)(th,{code:n.code}),t[8]=n.code,t[9]=C);let w;t[10]!==S||t[11]!==C?(w=(0,Z.jsx)(`span`,{className:S,"aria-hidden":!0,children:C}),t[10]=S,t[11]=C,t[12]=w):w=t[12];let T;t[13]===f?T=t[14]:(T=Y(`text-sm font-semibold`,f),t[13]=f,t[14]=T);let E;t[15]!==s.title||t[16]!==T?(E=(0,Z.jsx)(`h3`,{className:T,children:s.title}),t[15]=s.title,t[16]=T,t[17]=E):E=t[17];let D;t[18]===p?D=t[19]:(D=Y(`mt-1 text-xs leading-relaxed`,p),t[18]=p,t[19]=D);let O;t[20]!==s.body||t[21]!==D?(O=(0,Z.jsx)(`p`,{className:D,children:s.body}),t[20]=s.body,t[21]=D,t[22]=O):O=t[22];let k;t[23]!==E||t[24]!==O?(k=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[E,O]}),t[23]=E,t[24]=O,t[25]=k):k=t[25];let A;t[26]!==k||t[27]!==w?(A=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[w,k]}),t[26]=k,t[27]=w,t[28]=A):A=t[28];let j;t[29]!==s.cta||t[30]!==s.deepLink||t[31]!==_||t[32]!==a||t[33]!==r||t[34]!==v?(j=v?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,className:Y(`inline-flex h-8 items-center rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,_),onClick:()=>b(`/models/credits/purchase`),children:a.xopcQuotaPurchaseCta}),(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex h-8 items-center rounded-lg border border-current px-3 py-1.5 text-xs font-medium transition-colors hover:bg-amber-500/10`,onClick:()=>b(`/models/credits/request`),children:a.xopcQuotaRequestCta}),(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex h-8 items-center rounded-lg border border-current px-3 py-1.5 text-xs font-medium transition-colors hover:bg-amber-500/10`,onClick:()=>r(`/settings/capabilities/models?add=1`),children:a.xopcQuotaOwnProviderCta})]}):s.cta&&s.deepLink?(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,Z.jsx)(`button`,{type:`button`,className:Y(`inline-flex h-8 items-center rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/50`,_),onClick:()=>r(s.deepLink),children:s.cta})}):null,t[29]=s.cta,t[30]=s.deepLink,t[31]=_,t[32]=a,t[33]=r,t[34]=v,t[35]=j):j=t[35];let M;t[36]!==m||t[37]!==g||t[38]!==a||t[39]!==n.message?(M=n.message?(0,Z.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,Z.jsx)(`summary`,{className:Y(`cursor-pointer select-none underline-offset-2`,m),children:a.agentRunErrorDetailToggle}),(0,Z.jsx)(`pre`,{className:Y(`mt-2 max-h-40 w-full min-w-0 overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-md p-2 font-mono text-[11px] [overflow-wrap:anywhere]`,g),children:n.message})]}):null,t[36]=m,t[37]=g,t[38]=a,t[39]=n.message,t[40]=M):M=t[40];let N;return t[41]!==A||t[42]!==j||t[43]!==M||t[44]!==x?(N=(0,Z.jsxs)(`section`,{role:`alert`,"aria-live":`polite`,className:x,children:[A,j,M]}),t[41]=A,t[42]=j,t[43]=M,t[44]=x,t[45]=N):N=t[45],N}function ih(e){return window.open(`https://console.xopc.ai${e}`,`_blank`,`noopener,noreferrer`)}function ah(e){return e.language}function oh(e){let t=(0,X.c)(8),{errorText:n}=e,r;t[0]===n?r=t[1]:(r=Bn(n),t[0]=n,t[1]=r);let i=r;if(!i)return null;let a;t[2]===i?a=t[3]:(a=gr(i),t[2]=i,t[3]=a);let o=a;if(o){let e;return t[4]===o?e=t[5]:(e=(0,Z.jsx)(`div`,{className:`mb-4`,children:(0,Z.jsx)(sh,{payload:o})}),t[4]=o,t[5]=e),e}let s;return t[6]===i?s=t[7]:(s=(0,Z.jsx)(`div`,{className:`mb-4`,children:(0,Z.jsx)(rh,{payload:i})}),t[6]=i,t[7]=s),s}function sh(e){let t=(0,X.c)(32),{payload:n}=e,r=d(),i=h(ch),a,o,s,c;t[0]!==i||t[1]!==n.kind||t[2]!==n.provider?(o=y(i).chat,a=n.kind===`provider_auth_invalid`,c=a?o.agentRunErrorAuthInvalidTitle:o.providerSetupRequiredTitle,s=(a?o.agentRunErrorAuthInvalidBody:o.providerSetupRequiredBody).replace(`{{provider}}`,n.provider),t[0]=i,t[1]=n.kind,t[2]=n.provider,t[3]=a,t[4]=o,t[5]=s,t[6]=c):(a=t[3],o=t[4],s=t[5],c=t[6]);let l=s,u=a?o.agentRunErrorCtaProviders:o.providerSetupRequiredCta,f=a?o.agentRunErrorDetailToggle:o.providerSetupRequiredDetailToggle,p=a?`alert`:`status`,m;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=Y(`flex flex-col gap-2 rounded-xl border border-amber-300/60 bg-amber-50 p-3`,`dark:border-amber-500/30 dark:bg-amber-950`),t[7]=m):m=t[7];let g;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(g=Y(`flex size-8 shrink-0 items-center justify-center rounded-lg`,`bg-amber-100 text-amber-700 dark:bg-amber-500/20 dark:text-amber-300`),t[8]=g):g=t[8];let _;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Z.jsx)(`span`,{className:g,"aria-hidden":!0,children:(0,Z.jsx)(Ue,{className:`size-4`,strokeWidth:1.75})}),t[9]=_):_=t[9];let v;t[10]===c?v=t[11]:(v=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-amber-900 dark:text-amber-100`,children:c}),t[10]=c,t[11]=v);let b;t[12]===l?b=t[13]:(b=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-amber-900/85 dark:text-amber-100/80`,children:l}),t[12]=l,t[13]=b);let x;t[14]!==v||t[15]!==b?(x=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[_,(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[v,b]})]}),t[14]=v,t[15]=b,t[16]=x):x=t[16];let S;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(S=Y(`inline-flex h-8 items-center rounded-lg px-3 py-1.5 text-xs font-medium`,`bg-amber-600 text-white hover:bg-amber-700`,`dark:bg-amber-500 dark:text-amber-950 dark:hover:bg-amber-400`,`transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/50`),t[17]=S):S=t[17];let C;t[18]!==r||t[19]!==n.deepLink?(C=()=>r(n.deepLink),t[18]=r,t[19]=n.deepLink,t[20]=C):C=t[20];let w;t[21]!==u||t[22]!==C?(w=(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,Z.jsx)(`button`,{type:`button`,className:S,onClick:C,children:u})}),t[21]=u,t[22]=C,t[23]=w):w=t[23];let T;t[24]!==f||t[25]!==n.message?(T=n.message?(0,Z.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer select-none text-amber-800/80 underline-offset-2 hover:text-amber-900 dark:text-amber-200/80 dark:hover:text-amber-100`,children:f}),(0,Z.jsx)(`pre`,{className:`mt-2 max-h-40 w-full min-w-0 overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-md bg-amber-100/60 p-2 font-mono text-[11px] text-amber-900 dark:bg-amber-500/15 dark:text-amber-100 [overflow-wrap:anywhere]`,children:n.message})]}):null,t[24]=f,t[25]=n.message,t[26]=T):T=t[26];let E;return t[27]!==w||t[28]!==T||t[29]!==p||t[30]!==x?(E=(0,Z.jsxs)(`section`,{role:p,"aria-live":`polite`,className:m,children:[x,w,T]}),t[27]=w,t[28]=T,t[29]=p,t[30]=x,t[31]=E):E=t[31],E}function ch(e){return e.language}var lh=/^No API key found for (\S+)/i;function uh(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=lh.exec(t);return n?{kind:`provider_setup_required`,provider:n[1].replace(/[.,]$/,``),deepLink:`/settings/capabilities/models`,message:t}:null}var dh=new WeakMap;function fh(e){let t=dh.get(e),n=or(e);return t??(n?[n]:[])}function ph(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??``}`},pr(e,t[t.length-1]),dh.set(t[t.length-1],[...fh(e),...fh(n)]);continue}t.push(n)}return t}var mh=/^\s*\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$/m,hh=/^\s{0,3}(?:[-+*]|\d+[.)])\s+/m,gh=/^\s{0,3}```/gm;function _h(e){return(e.match(gh)?.length??0)%2==1?`code`:mh.test(e)?`table`:hh.test(e)?`list`:e.length>=4096?`long_text`:`plain`}var vh={plain:50,long_text:50,list:50,table:72,code:64};function yh({tailKind:e,latestParseMs:t}){let n=vh[e];return!Number.isFinite(t)||t<=16?n:Math.min(120,Math.max(n,Math.ceil(t*2)))}var bh=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=jd(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 xh(e,t,n,r=!1,i,a=!1){let[o,s]=(0,Q.useState)(()=>e),[c]=(0,Q.useState)(()=>new bh(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,mt(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){ct(n,e.length),o();return}if(c.observe(e.length,performance.now()),p.current=yh({tailKind:_h(e.slice(-8192)),latestParseMs:st(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,ct(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 Sh(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 Ch(e){let t=(0,X.c)(33),{review:n}=e,r=h(Th),i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n.analysisMarkdown||t[2]!==n.errorMessage||t[3]!==n.overallCorrectness||t[4]!==n.source||t[5]!==n.status||t[6]!==n.target){o=y(r).chat.reviewCard,i=n.status===`preparing`||n.status===`reviewing`;let e=n.status===`preparing`;a=n.source===`local`&&n.overallCorrectness===`unknown`;let p=n.overallCorrectness===`patch is incorrect`?`border-red-500/30 bg-red-500/5 text-red-700 dark:text-red-300`:n.overallCorrectness===`patch is correct`?`border-emerald-500/30 bg-emerald-500/5 text-emerald-700 dark:text-emerald-300`:`border-edge bg-surface-inset text-fg-secondary`;s=`min-w-0 rounded-lg border border-edge bg-surface-inset p-3`;let m;t[16]===i?m=t[17]:(m=i?(0,Z.jsx)(Je,{className:`size-4 animate-spin text-accent`,"aria-hidden":!0}):null,t[16]=i,t[17]=m),c=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[m,(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg-primary`,children:i?o.running:o.finished}),i?(0,Z.jsx)(`div`,{className:`rounded-md border border-edge bg-surface-inset px-1.5 py-0.5 text-[11px] font-medium text-fg-secondary`,children:e?o.collecting:o.assistant}):(0,Z.jsx)(`div`,{className:Y(`rounded-md border px-1.5 py-0.5 text-[11px] font-medium`,p),children:o.correctness[n.overallCorrectness]})]}),l=(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-fg-tertiary`,children:o.basedOn.replace(`{{target}}`,n.target)}),u=i&&!n.analysisMarkdown?(0,Z.jsx)(`div`,{className:`mt-3 text-sm text-fg-secondary`,children:e?o.preparing:o.checking}):null,d=n.analysisMarkdown?(0,Z.jsxs)(`div`,{className:`mt-3 rounded-md border border-edge-subtle bg-surface px-2.5 py-2`,children:[(0,Z.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg-secondary`,children:o.assistant}),(0,Z.jsx)(cf,{content:n.analysisMarkdown,compact:!0,streaming:i})]}):null,f=n.status===`error`&&n.errorMessage?(0,Z.jsx)(`div`,{className:`mt-3 rounded-md border border-warning/30 bg-warning/5 px-2.5 py-2 text-sm text-warning`,children:o.error.replace(`{{error}}`,n.errorMessage)}):null,t[0]=r,t[1]=n.analysisMarkdown,t[2]=n.errorMessage,t[3]=n.overallCorrectness,t[4]=n.source,t[5]=n.status,t[6]=n.target,t[7]=i,t[8]=a,t[9]=o,t[10]=s,t[11]=c,t[12]=l,t[13]=u,t[14]=d,t[15]=f}else i=t[7],a=t[8],o=t[9],s=t[10],c=t[11],l=t[12],u=t[13],d=t[14],f=t[15];let p;t[18]!==i||t[19]!==a||t[20]!==n.findings||t[21]!==n.overallExplanation||t[22]!==n.summary||t[23]!==o?(p=i?null:(0,Z.jsxs)(Z.Fragment,{children:[n.summary?(0,Z.jsx)(`div`,{className:`mt-3 text-sm text-fg-secondary`,children:n.summary}):null,(0,Z.jsx)(`div`,{className:`mt-3 space-y-2`,children:n.findings.length===0?(0,Z.jsx)(`div`,{className:`text-sm text-fg-secondary`,children:a?o.noModelFindings:o.noFindings}):n.findings.map(wh)}),n.overallExplanation?(0,Z.jsx)(`div`,{className:`mt-3 whitespace-pre-wrap text-sm text-fg-secondary`,children:n.overallExplanation}):null]}),t[18]=i,t[19]=a,t[20]=n.findings,t[21]=n.overallExplanation,t[22]=n.summary,t[23]=o,t[24]=p):p=t[24];let m;return t[25]!==s||t[26]!==c||t[27]!==l||t[28]!==u||t[29]!==d||t[30]!==f||t[31]!==p?(m=(0,Z.jsxs)(`div`,{className:s,children:[c,l,u,d,f,p]}),t[25]=s,t[26]=c,t[27]=l,t[28]=u,t[29]=d,t[30]=f,t[31]=p,t[32]=m):m=t[32],m}function wh(e,t){let n=Sh(e);return(0,Z.jsxs)(`div`,{className:`rounded-md border border-edge bg-surface p-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`span`,{className:`rounded border border-edge bg-surface-inset px-1.5 py-0.5 text-[11px] font-semibold text-fg-secondary`,children:[`P`,e.priority]}),(0,Z.jsx)(`span`,{className:`min-w-0 text-sm font-medium text-fg-primary`,children:e.title})]}),n?(0,Z.jsx)(`div`,{className:`mt-1 break-all text-xs text-fg-tertiary`,children:n}):null,e.body?(0,Z.jsx)(`div`,{className:`mt-1 text-sm text-fg-secondary`,children:e.body}):null]},`${e.title}-${t}`)}function Th(e){return e.language}function Eh({resolution:e,conversationId:t,onClose:n}){let r=h(e=>e.language),i=y(r).chat.fileReference,[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(!1),d=Ta()&&!!window.electronAPI?.shell,f=e.target.path,p=e.status===`ready`?e.ref:null,m=p?.displayName??f.split(/[\\/]/).pop()??f,g=p?.absolutePath??p?.workspaceRelativePath??f,_=(0,Q.useCallback)(()=>{Ci(g).then(e=>{e&&(o(!0),window.setTimeout(()=>o(!1),2e3))})},[g]),v=async e=>{let n=window.electronAPI?.shell;if(!(!p?.fileRefId||!d||!n||l)){c(``),u(!0);try{let r=await Va(p.fileRefId,e,{conversationId:t?.trim()||void 0});if(e===`openExternal`){let e=await n.openPath(r.absolutePath);e.ok||c(e.error)}else(await n.showItemInFolder(r.absolutePath)).success||c(i.resolveFailedDescription)}catch(e){c(e instanceof Error?e.message:String(e))}finally{u(!1)}}};return(0,Z.jsxs)(`div`,{className:Y(`mt-2 flex max-w-xl min-w-0 flex-col gap-1.5 rounded-lg border px-2.5 py-2 text-xs`,e.status===`ready`&&e.ref.exists&&e.ref.scope!==`missing`?`border-edge-subtle bg-surface-panel`:`border-warning/30 bg-warning/5`),children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.status===`loading`?(0,Z.jsx)(Je,{className:`size-3.5 shrink-0 animate-spin text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}):e.status===`error`||p?.scope===`missing`||p?.scope===`invalid`?(0,Z.jsx)(K,{className:`size-3.5 shrink-0 text-warning`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(Ce,{className:`size-3.5 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:m}),(0,Z.jsx)(`button`,{type:`button`,onClick:n,className:Y(`ml-auto inline-flex size-5 shrink-0 items-center justify-center rounded text-fg-muted hover:bg-surface-hover hover:text-fg`,ca.focusRingPanel),"aria-label":i.closeActions,children:(0,Z.jsx)(Gt,{className:`size-3`,strokeWidth:1.75,"aria-hidden":!0})})]}),(0,Z.jsx)(`p`,{className:`line-clamp-2 break-all text-[11px] leading-snug text-fg-muted`,children:e.status===`loading`?i.resolvingDescription:e.status===`error`?e.message:p?.scope===`missing`?i.missingDescription:p?.scope===`invalid`?i.invalidDescription:d?i.externalDescription:i.browserExternalDescription}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 pt-0.5`,children:[d&&p?.capabilities.includes(`openExternal`)?(0,Z.jsxs)(`button`,{type:`button`,className:Dh,disabled:l,onClick:()=>void v(`openExternal`),children:[(0,Z.jsx)(xe,{className:`size-3`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:i.openExternal})]}):null,d&&p?.capabilities.includes(`revealInFolder`)?(0,Z.jsxs)(`button`,{type:`button`,className:Dh,disabled:l,onClick:()=>void v(`revealInFolder`),children:[(0,Z.jsx)(De,{className:`size-3`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:i.revealInFolder})]}):null,p?.manageRoute?(0,Z.jsxs)(`a`,{className:Dh,href:`#${p.manageRoute}`,children:[(0,Z.jsx)(Ft,{className:`size-3`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:y(r).nav.settings})]}):null,(0,Z.jsxs)(`button`,{type:`button`,className:Dh,onClick:_,children:[(0,Z.jsx)(ve,{className:`size-3`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:a?y(r).chat.messageCopied:i.copyPath})]})]}),s?(0,Z.jsx)(`p`,{role:`alert`,className:`text-warning`,children:s}):null]})}var Dh=Y(`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,ca.focusRingPanel,ca.press);function Oh({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=Hm(n,r)??t,p=`assistant-markdown-${(0,Q.useId)()}`,m=xh(f,s,p,c,l,d);(0,Q.useLayoutEffect)(()=>{if(!u||!m.trim())return;let e=window.requestAnimationFrame(()=>mr(u,m));return()=>window.cancelAnimationFrame(e)},[u,m,s]),(0,Q.useEffect)(()=>{if(s)return ut(p),()=>gt(p)},[p,s]);let g=Ni(e=>e.setPath),_=y(h(e=>e.language)).chat.fileReference,[v,b]=(0,Q.useState)(null),x=(0,Q.useRef)(0);(0,Q.useEffect)(()=>()=>{x.current++},[a,o,e]);let S=(0,Q.useCallback)(async t=>{try{return await Ra(t.path,{projectId:o?.trim()||void 0,conversationId:a?.trim()||void 0,taskRunId:e})}catch(n){if(e||o||!a)throw n;return Ra(t.path)}},[o,a,e]),C=(0,Q.useCallback)(t=>{let n=++x.current;if(t.kind===`workspace-relative`){b({status:`loading`,target:t}),(async()=>{let r=await Ua(t.path,{projectId:o?.trim()||void 0,conversationId:a?.trim()||void 0,taskRunId:e});if(n!==x.current)return;if(r?.capabilities.includes(`preview`)&&(r.absolutePath||r.workspaceRelativePath)){g(r.absolutePath||r.workspaceRelativePath,t.line,o,a),b(null);return}let i=!e&&!o&&a?await Ua(t.path):null;if(n===x.current){if(i?.capabilities.includes(`preview`)&&(i.absolutePath||i.workspaceRelativePath)){g(i.absolutePath||i.workspaceRelativePath,t.line),b(null);return}b(r?{status:`ready`,target:t,ref:r}:{status:`error`,target:t,message:_.resolveFailedDescription})}})().catch(e=>{n===x.current&&b({status:`error`,target:t,message:e instanceof Error?e.message:String(e)})});return}b({status:`loading`,target:t}),Ua(t.path,{projectId:o?.trim()||void 0,conversationId:a?.trim()||void 0,taskRunId:e}).then(e=>{if(n===x.current){if(!e){b({status:`error`,target:t,message:_.resolveFailedDescription});return}if(e.capabilities.includes(`preview`)&&(e.absolutePath||e.workspaceRelativePath)){g(e.absolutePath||e.workspaceRelativePath,t.line,o,a),b(null);return}b({status:`ready`,target:t,ref:e})}}).catch(e=>{n===x.current&&b({status:`error`,target:t,message:e instanceof Error?e.message:String(e)})})},[_.resolveFailedDescription,o,a,e,g]),w=uh(f);return(0,Z.jsxs)(Z.Fragment,{children:[w?(0,Z.jsx)(sh,{payload:w}):(0,Z.jsx)(cf,{content:m,streaming:s||m!==f,compact:i,onWorkspaceFileOpen:C,onWorkspaceImageLoad:S,renderMermaid:!0,mermaidActions:!0,streamingMetricsKey:p}),v?(0,Z.jsx)(Eh,{resolution:v,conversationId:a,onClose:()=>{x.current++,b(null)}}):null]})}function kh(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){if(e.type===`text`)return n?(0,Z.jsx)(`div`,{className:`min-w-0`,children:(0,Z.jsx)(Ym,{text:hr(e.text??``),conversationId:s,document:f,contextRefs:p})},t):(0,Z.jsx)(`div`,{className:`assistant-markdown-content markdown-content min-w-0`,children:(0,Z.jsx)(Oh,{content:e.text,sourcePartIds:fh(e),sourceConversationId:s,taskRunId:m,compact:!0,conversationId:c??s,projectId:l,streaming:r,animateInitialContent:u,onProgressiveRenderComplete:d,responseRunId:h,immediateFirstCommit:g})},t);if(e.type===`image`&&e.source?.data){let n=o??0;return(0,Z.jsx)(dd,{source:e.source.data,alt:``,title:i,onOpen:a?()=>a(e,n):void 0},t)}return e.type===`review`?(0,Z.jsx)(Ch,{review:e},t):null}function Ah(e){let t=(0,X.c)(24),{taskRunId:n,content:r,isUser:i,isAssistantMessageStreaming:a,imagePreviewLabel:o,onImagePreview:s,conversationId:c,workspaceConversationId:l,projectId:u,progressiveRender:d,onProgressiveRenderComplete:f,userTurnDocument:p,contextRefs:m,responseRunId:h,immediateFirstCommit:g,renderActivity:_,processItems:v,processCollapsed:y}=e,b=d!==void 0&&d,x=g!==void 0&&g,S=y!==void 0&&y,C;if(t[0]!==r||t[1]!==m||t[2]!==c||t[3]!==o||t[4]!==x||t[5]!==a||t[6]!==i||t[7]!==s||t[8]!==f||t[9]!==S||t[10]!==v||t[11]!==b||t[12]!==u||t[13]!==_||t[14]!==h||t[15]!==n||t[16]!==p||t[17]!==l){let e=i?r:ph(r),d;t[19]===v?d=t[20]:(d=new Set(v?[...v].map(or).filter(Boolean):[]),t[19]=v,t[20]=d);let g=d,y;t[21]!==v||t[22]!==g?(y=e=>v?.has(e)||!!(or(e)&&g.has(or(e))),t[21]=v,t[22]=g,t[23]=y):y=t[23];let w=y,T=e.findLastIndex(jh),E=e.at(-1),D=T<0&&E?.type===`text`&&E.presentation===void 0?e.length-1:-1,O=a?Math.max(T,D):-1,k=[],A=0,j=0;for(;A<e.length;){let t=e[A];if(t.type===`thinking`||t.type===`tool_use`){let n=A,r=[];for(;A<e.length;){let t=e[A];if(t.type!==`thinking`&&t.type!==`tool_use`)break;r.push(t),A++}_&&k.push((0,Z.jsx)(`div`,{"data-assistant-activity":!0,"data-assistant-process-item":v?!0:void 0,hidden:S,children:_(r,A===e.length)},or(t)??`activity-${n}`))}else{let e=t.type===`image`?j++:0,r=kh(t,or(t)??`block-${A}`,i,A===O,o,s,t.type===`image`?e:A,c,l,u,b,f,i&&A===0?p:void 0,i&&A===0?m:void 0,n,h,x);r&&k.push(v?(0,Z.jsx)(`div`,{"data-assistant-process-item":w(t)||void 0,hidden:S&&w(t),children:r},or(t)??`block-${A}`):r),A++}}C=(0,Z.jsx)(Z.Fragment,{children:k}),t[0]=r,t[1]=m,t[2]=c,t[3]=o,t[4]=x,t[5]=a,t[6]=i,t[7]=s,t[8]=f,t[9]=S,t[10]=v,t[11]=b,t[12]=u,t[13]=_,t[14]=h,t[15]=n,t[16]=p,t[17]=l,t[18]=C}else C=t[18];return C}function jh(e){return e.type===`text`&&e.presentation===`pending`}var Mh=[`readFile`,`editFile`,`writeFile`,`runCommand`,`memorySearch`,`codeSearch`,`webSearch`,`search`,`fetchUrl`,`openUrl`,`listDir`,`other`];function Nh(e,t){return ha(e,t)}function Ph(e){let t=new Map;for(let n of e){if(n.type!==`tool_use`)continue;let e=Nh(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 Fh(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 Ih(e,t,n){let r=Ph(e),i=[];for(let e of Mh){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)||Fh(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 Lh(e){return e.filter(e=>e.type!==`thinking`||!!e.text?.trim()||!!e.streaming)}function Rh(e,t,n){return Ih(e,t,n)}function zh(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Bh(e){if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}}function Vh(e){let t=zh(Bh(e));if(!t)return[];let n=zh(t.details)?.results??t.results;if(Array.isArray(n))return n.map(zh).filter(e=>e!==null);let r=Array.isArray(t.content)?t.content:[];for(let e of r){let t=zh(e)?.text,n=zh(Bh(t));if(Array.isArray(n?.results))return n.results.map(zh).filter(e=>e!==null)}return[]}function Hh(e,t){return e.replace(/\{\{count\}\}/g,String(t))}function Uh(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=Vh(e.result),r=e.activity?.count??n.length;return{title:r===0?t.empty:Hh(r===1?t.found_one:t.found_other,r),purpose:t.purpose}}function Wh(e){if(e.scrollHeight<=e.clientHeight)return!1;let t=window.getComputedStyle(e).overflowY;return t===`auto`||t===`scroll`}function Gh(e,t,n){let r=[],i=e instanceof HTMLElement?e:t;for(;i&&i!==t;)Wh(i)&&r.push(i),i=i.parentElement;return t.scrollHeight>t.clientHeight&&r.push(t),n!==t&&r.push(n),r}function Kh(e,t){let n=e;for(let e of t){let t=Math.max(0,e.scrollHeight-e.clientHeight),r=Math.min(t,Math.max(0,e.scrollTop+n)),i=r-e.scrollTop;if(i!==0&&(e.scrollTop=r),n-=i,Math.abs(n)<.01)break}}function qh(e,t){if(e.defaultPrevented||e.ctrlKey||e.deltaY===0||Math.abs(e.deltaY)<=Math.abs(e.deltaX))return;let n=t.closest(`.chat-messages`);if(!n)return;let r=t.clientHeight||n.clientHeight,i=e.deltaMode===WheelEvent.DOM_DELTA_LINE?16:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?r:1,a=Gh(e.target,t,n);e.preventDefault(),Kh(e.deltaY*i,a)}function Jh(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 Yh(e){if(e==null)return null;try{return typeof e==`string`?JSON.parse(e):e}catch{return null}}function Xh(e){let t=Yh(e),n=t?.path??t?.file_path??t?.filepath??t?.file??t?.qualified_name??t?.function_name;return typeof n==`string`?n:``}function Zh(e){let t=Yh(e),n=t?.url??t?.href??t?.uri??t?.website;return typeof n==`string`?n:``}function Qh(e){let t=Yh(e),n=t?.command??t?.cmd??t?.shell??t?.script;return typeof n==`string`?n:``}var $h=120;function eg(e){if(e==null)return``;let t=Yh(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>$h?`${t.slice(0,$h)}…`:t}if(typeof e==`number`&&Number.isFinite(e))return String(e)}return``}function tg(e){return e.startsWith(`@@`)?`hunk`:e.startsWith(`+++`)||e.startsWith(`---`)||e.startsWith(`diff `)||e.startsWith(`index `)?`meta`:e.startsWith(`+`)?`add`:e.startsWith(`-`)?`del`:`context`}function ng(e){let t=e.details?.diff;if(typeof t!=`string`||t.length===0)return null;let n=t.split(`
17
- `),r=[],i=0,a=0;for(let e of n){let t=tg(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 rg=`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`,ig=`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`,ag=`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`,og=`cursor-pointer select-none text-xs text-fg-subtle underline-offset-2 hover:text-fg-muted group-open:text-fg-muted`;function sg(e){let t=(0,X.c)(5),{children:n,tone:r}=e,i=r===void 0?`neutral`:r,a=i===`positive`?`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`:i===`negative`?`bg-red-500/15 text-red-700 dark:text-red-300`:i===`warning`?`bg-amber-500/15 text-amber-700 dark:text-amber-300`:i===`accent`?`bg-accent-soft/70 text-accent-fg dark:bg-accent-soft/50`:``,o;t[0]===a?o=t[1]:(o=Y(rg,a),t[0]=a,t[1]=o);let s;return t[2]!==n||t[3]!==o?(s=(0,Z.jsx)(`span`,{className:o,children:n}),t[2]=n,t[3]=o,t[4]=s):s=t[4],s}function cg(e){let t=(0,X.c)(3),{children:n,title:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,Z.jsx)(`code`,{className:ig,title:r,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}var lg=(0,Q.memo)(function(e){let t=(0,X.c)(10),{text:n,label:r,copiedLabel:i}=e,[a,o]=(0,Q.useState)(!1),s;t[0]===n?s=t[1]:(s=async e=>{e.preventDefault(),e.stopPropagation(),await Ci(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`,ca.transition,ca.focusRingPanel),t[2]=c):c=t[2];let l=a?i:r,u=a?i:r,d;t[3]===a?d=t[4]:(d=a?(0,Z.jsx)(G,{className:`size-3.5`,"aria-hidden":!0}):(0,Z.jsx)(ve,{className:`size-3.5`,"aria-hidden":!0}),t[3]=a,t[4]=d);let f;return t[5]!==s||t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,Z.jsx)(`button`,{type:`button`,onClick:s,className:c,"aria-label":l,title:u,children:d}),t[5]=s,t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9],f});function ug(e){let t=(0,X.c)(8),{summary:n,children:r,defaultOpen:i}=e,a=i!==void 0&&i,o;t[0]===n?o=t[1]:(o=(0,Z.jsx)(`summary`,{className:og,children:n}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,Z.jsx)(`div`,{className:`mt-1.5 min-w-0`,children:r}),t[2]=r,t[3]=s);let c;return t[4]!==a||t[5]!==o||t[6]!==s?(c=(0,Z.jsxs)(`details`,{className:`group min-w-0 text-xs`,open:a,children:[o,s]}),t[4]=a,t[5]=o,t[6]=s,t[7]=c):c=t[7],c}function dg(e){let t=(0,X.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`pre`,{className:ag,children:n}),t[0]=n,t[1]=r),r}function fg(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>{let r=t[n];return r==null?``:String(r)})}function pg(e){return e.details??{}}var mg=/\[(\d+)\/(\d+) lines\]\s*$/;function hg(e){let t=e.match(mg);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 gg(e){return e.replace(mg,``).trimEnd()}var _g=(0,Q.memo)(function(e){let t=(0,X.c)(32),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=Xh(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=ma(n.result),t[2]=n.result,t[3]=o);let s=o.text,c;t[4]===s?c=t[5]:(c=hg(s),t[4]=s,t[5]=c);let l=c,u;t[6]===s?u=t[7]:(u=gg(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(`
16
+ `).trim()}var km=new WeakMap,Am=new WeakMap,jm=new WeakMap,Mm=new WeakMap;function Nm(e,t){if(!e)return;let n=e=>{let t=jm.get(e);return t||(t=new Map(e.content.flatMap(e=>{let t=or(e);return t?[[t,e]]:[]})),jm.set(e,t)),t},r=e.streamingMsg&&n(e.streamingMsg).get(t);if(r)return r;let i=Mm.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);Mm.set(e.messages,i)}return i.get(t)}function Pm(e,t){return e===t?!0:!e||!t||e.content.length!==t.content.length||!e.content.every((e,n)=>{let r=t.content[n];return e===r||e.type===`text`&&r.type===`text`&&or(e)===or(r)&&e.segmentId===r.segmentId&&e.presentation===r.presentation&&!!e.text.trim()==!!r.text.trim()&&(e.text===r.text||![e.text,r.text].some(e=>{let t=e.trimStart();return t.startsWith(`NO_REPLY`)||t.length>0&&`NO_REPLY`.startsWith(t)}))})?!1:[...new Set([...Object.keys(e),...Object.keys(t)])].every(n=>n===`content`||e[n]===t[n])}function Fm(){let e;return t=>(Pm(e??null,t??null)||(e=t),e)}function Im(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=Am.get(n);if(r?.previous===t)return r.row;let i=dr([t,n]).at(-1);return Am.set(n,{previous:t,row:i}),i}let r=km.get(e.messages);return r||(r=new Map(e.messages.filter(e=>e.renderKey).map(e=>[e.renderKey,e])),km.set(e.messages,r)),r.get(t)}function Lm(){let e;return t=>{if(!t||!e)return e=t,t;let n=Pm(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 Rm(e){let t=(0,X.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=Lm(),t[0]=n):n=t[0];let r=n,i;t[1]===e?i=t[2]:(i=()=>r(e?Nn.getState().sessions[e]:void 0),t[1]=e,t[2]=i);let a=i;return(0,Q.useSyncExternalStore)(Nn.subscribe,a,a)}function zm(e,t){let n=(0,Q.useMemo)(()=>{let n=t();return{read:()=>n,subscribe:r=>{let i=null,a=null,o=()=>{i!==null&&cancelAnimationFrame(i),a!==null&&clearTimeout(a),i=null,a=null},s=()=>{o();let e=t();n!==e&&(n=e,r())},c=Nn.subscribe((r,o)=>{if(t()===n)return;let c=e?r.sessions[e]:void 0,l=e?o.sessions[e]:void 0;if(c?.streaming!==l?.streaming||c?.messages!==l?.messages){s();return}i===null&&(i=requestAnimationFrame(s),a=setTimeout(s,50))});return s(),()=>{o(),c()}}}},[e,t]);return(0,Q.useSyncExternalStore)(n.subscribe,n.read,n.read)}function Bm(e,t){let n=(0,X.c)(4),r;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=Fm(),n[0]=r):r=n[0];let i=r,a;return n[1]!==e||n[2]!==t?(a=()=>i(e&&t?Im(Nn.getState().sessions[e],t):void 0),n[1]=e,n[2]=t,n[3]=a):a=n[3],zm(e,a)}function Vm(e,t){let n=(0,X.c)(3),r;return n[0]!==e||n[1]!==t?(r=()=>e&&t?Nm(Nn.getState().sessions[e],t):void 0,n[0]=e,n[1]=t,n[2]=r):r=n[2],zm(e,r)}function Hm(e,t){let n=(0,X.c)(7),r;n[0]===t?r=n[1]:(r=t.join(`,`),n[0]=t,n[1]=r);let i=r,a;n[2]===i?a=n[3]:(a=i?i.split(`,`):[],n[2]=i,n[3]=a);let o=a,s;return n[4]!==e||n[5]!==o?(s=()=>{if(!e||!o.length)return;let t=Nn.getState().sessions[e],n=o.map(e=>Nm(t,e));if(!n.some(Wm))return n.map(Um).join(``)},n[4]=e,n[5]=o,n[6]=s):s=n[6],zm(e,s)}function Um(e){return e?.type===`text`?e.text:``}function Wm(e){return e?.type!==`text`}function Gm(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)})})(ja(),e=>({kind:`skill`,name:e[1]??``}));for(let n of Eo(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 Km(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 qm(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 Jm(e){let t=(0,X.c)(6),{contextRef:n}=e;if(n?.kind===`file`&&n.fileKind===`directory`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Oe,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[0]=e):e=t[0],e}if(n?.kind===`file`){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Te,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[1]=e):e=t[1],e}if(n?.kind===`session`){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(bt,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[2]=e):e=t[2],e}if(n?.kind===`browser_tab`){let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(k,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[3]=e):e=t[3],e}if(n?.kind===`mcp_resource`){let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(ye,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[4]=e):e=t[4],e}let r;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(xs,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=r):r=t[5],r}var Ym=(0,Q.memo)(function(e){let t=(0,X.c)(24),{text:n,conversationId:r,document:i,contextRefs:a}=e,o=h(Xm),s;t[0]===o?s=t[1]:(s=y(o),t[0]=o,t[1]=s);let c=s.chat.referenceFallback,l;bb0:{if(!i){let e;t[2]===n?e=t[3]:(e=Gm(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(Zm)??[]);e=i.parts.flatMap(e=>e.type===`text`?Gm(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=Km(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(Qm),t[9]=u,t[10]=p);let m=Gp(void 0,r,p);if(!u.some($m)){let e;return t[11]===n?e=t[12]:(e=(0,Z.jsx)(`div`,{className:`markdown-content min-w-0`,children:(0,Z.jsx)(cf,{content:n,compact:!0,breaks:!0})}),t[11]=n,t[12]=e),e}let g;if(t[13]!==u||t[14]!==f||t[15]!==c||t[16]!==m){let e;t[18]!==u||t[19]!==c||t[20]!==m?(e=(e,t)=>{let{part:n,key:r}=e;return n.kind===`skill`?(0,Z.jsxs)(`span`,{className:`chat-skill-pill max-w-full shrink-0`,"data-skill":n.name,title:`/${n.name}`,children:[`/`,m(n.name)]},r):n.kind===`command`?(0,Z.jsxs)(`span`,{className:`chat-command-pill max-w-full shrink-0`,"data-slash-command":n.name,children:[`/`,n.name]},r):n.kind===`context_ref`?(0,Z.jsxs)(`span`,{className:Y(`chat-context-ref-pill chat-context-ref-pill-message max-w-full shrink-0`,qm(u,t)),"data-context-ref-id":n.refId,"data-ref-kind":n.ref?.kind??``,"data-file-kind":n.ref?.fileKind??``,title:n.ref?.title,"aria-label":n.ref?.title??c,children:[(0,Z.jsx)(Jm,{contextRef:n.ref}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:n.ref?.title??c})]},r):n.text?(0,Z.jsx)(`div`,{className:`chat-user-message-segment markdown-content inline-block min-w-0 max-w-full align-baseline text-fg`,children:(0,Z.jsx)(cf,{content:n.text,compact:!0,breaks:!0})},r):null},t[18]=u,t[19]=c,t[20]=m,t[21]=e):e=t[21],g=f.map(e),t[13]=u,t[14]=f,t[15]=c,t[16]=m,t[17]=g}else g=t[17];let _;return t[22]===g?_=t[23]:(_=(0,Z.jsx)(`span`,{className:`inline-flex max-w-full flex-wrap items-baseline gap-x-0 gap-y-1 [text-align:inherit]`,children:g}),t[22]=g,t[23]=_),_});function Xm(e){return e.language}function Zm(e){return e.refId?[[e.refId,e]]:[]}function Qm(e){return e.kind===`skill`}function $m(e){return e.kind!==`text`}function eh(e,t){switch(e.code){case`provider_setup_required`:return{title:t.providerSetupRequiredTitle,body:t.providerSetupRequiredBody.replace(`{{provider}}`,e.provider??t.agentRunErrorUnknownProvider),cta:t.providerSetupRequiredCta,deepLink:`/settings/capabilities/models`};case`provider_auth_invalid`:return{title:t.agentRunErrorAuthInvalidTitle,body:t.agentRunErrorAuthInvalidBody.replace(`{{provider}}`,e.provider??t.agentRunErrorUnknownProvider),cta:t.agentRunErrorCtaProviders,deepLink:`/settings/capabilities/models`};case`rate_limit`:return{title:t.agentRunErrorRateLimitTitle,body:t.agentRunErrorRateLimitBody};case`timeout`:return{title:t.agentRunErrorTimeoutTitle,body:t.agentRunErrorTimeoutBody};case`provider_connection_error`:return{title:t.agentRunErrorConnectionTitle,body:t.agentRunErrorConnectionBody};case`billing`:return{title:t.agentRunErrorBillingTitle,body:t.agentRunErrorBillingBody};case`credit_budget_exhausted`:return{title:t.creditBudgetExhaustedTitle,body:t.creditBudgetExhaustedBody,cta:t.creditBudgetSettingsCta,deepLink:`/settings/agent-defaults?panel=runtime`};case`model_quota_exhausted`:return{title:t.xopcQuotaExhaustedTitle,body:t.xopcQuotaExhaustedBody};case`platform_token_limit_exceeded`:return{title:t.xopcPlatformLimitTitle,body:t.xopcPlatformLimitBody,cta:t.xopcPlatformLimitCta,deepLink:`/settings/capabilities/models?add=1`};case`send_failed`:return{title:t.agentRunErrorSendFailedTitle,body:t.agentRunErrorSendFailedBody};case`session_not_found`:return{title:t.sessionNotFoundTitle,body:t.sessionNotFoundBody,cta:t.sessionNotFoundCta,deepLink:`/chat/new`};default:return{title:t.agentRunErrorUnknownTitle,body:t.agentRunErrorUnknownBody}}}function th(e){let t=(0,X.c)(4),{code:n}=e;switch(n){case`provider_setup_required`:case`provider_auth_invalid`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Ue,{className:`size-4`,strokeWidth:1.75}),t[0]=e):e=t[0],e}case`rate_limit`:case`timeout`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(me,{className:`size-4`,strokeWidth:1.75}),t[1]=e):e=t[1],e}case`billing`:case`credit_budget_exhausted`:case`model_quota_exhausted`:case`platform_token_limit_exceeded`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Ts,{className:`size-4`,strokeWidth:1.75}),t[2]=e):e=t[2],e}default:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(K,{className:`size-4`,strokeWidth:1.75}),t[3]=e):e=t[3],e}}}function nh(e){return e===`provider_setup_required`||e===`provider_auth_invalid`||e===`rate_limit`||e===`timeout`||e===`billing`||e===`model_quota_exhausted`||e===`platform_token_limit_exceeded`||e===`session_not_found`?`amber`:`red`}function rh(e){let t=(0,X.c)(46),{payload:n}=e,r=d(),i=h(ah),a,o;t[0]!==i||t[1]!==n?(a=y(i).chat,o=eh(n,a),t[0]=i,t[1]=n,t[2]=a,t[3]=o):(a=t[2],o=t[3]);let s=o,c=nh(n.code),l=c===`amber`?`border-amber-300/60 bg-amber-50 dark:border-amber-500/30 dark:bg-amber-950`:`border-red-300/60 bg-red-50 dark:border-red-500/30 dark:bg-red-950`,u=c===`amber`?`bg-amber-100 text-amber-700 dark:bg-amber-500/20 dark:text-amber-300`:`bg-red-100 text-red-700 dark:bg-red-500/20 dark:text-red-300`,f=c===`amber`?`text-amber-900 dark:text-amber-100`:`text-red-900 dark:text-red-100`,p=c===`amber`?`text-amber-900/85 dark:text-amber-100/80`:`text-red-900/85 dark:text-red-100/80`,m=c===`amber`?`text-amber-800/80 hover:text-amber-900 dark:text-amber-200/80 dark:hover:text-amber-100`:`text-red-800/80 hover:text-red-900 dark:text-red-200/80 dark:hover:text-red-100`,g=c===`amber`?`bg-amber-100/60 text-amber-900 dark:bg-amber-500/15 dark:text-amber-100`:`bg-red-100/60 text-red-900 dark:bg-red-500/15 dark:text-red-100`,_=c===`amber`?`bg-amber-600 text-white hover:bg-amber-700 dark:bg-amber-500 dark:text-amber-950 dark:hover:bg-amber-400`:`bg-red-600 text-white hover:bg-red-700 dark:bg-red-500 dark:text-red-950 dark:hover:bg-red-400`,v=n.code===`model_quota_exhausted`,b=ih,x;t[4]===l?x=t[5]:(x=Y(`flex flex-col gap-2 rounded-xl border p-3`,l),t[4]=l,t[5]=x);let S;t[6]===u?S=t[7]:(S=Y(`flex size-8 shrink-0 items-center justify-center rounded-lg`,u),t[6]=u,t[7]=S);let C;t[8]===n.code?C=t[9]:(C=(0,Z.jsx)(th,{code:n.code}),t[8]=n.code,t[9]=C);let w;t[10]!==S||t[11]!==C?(w=(0,Z.jsx)(`span`,{className:S,"aria-hidden":!0,children:C}),t[10]=S,t[11]=C,t[12]=w):w=t[12];let T;t[13]===f?T=t[14]:(T=Y(`text-sm font-semibold`,f),t[13]=f,t[14]=T);let E;t[15]!==s.title||t[16]!==T?(E=(0,Z.jsx)(`h3`,{className:T,children:s.title}),t[15]=s.title,t[16]=T,t[17]=E):E=t[17];let D;t[18]===p?D=t[19]:(D=Y(`mt-1 text-xs leading-relaxed`,p),t[18]=p,t[19]=D);let O;t[20]!==s.body||t[21]!==D?(O=(0,Z.jsx)(`p`,{className:D,children:s.body}),t[20]=s.body,t[21]=D,t[22]=O):O=t[22];let k;t[23]!==E||t[24]!==O?(k=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[E,O]}),t[23]=E,t[24]=O,t[25]=k):k=t[25];let A;t[26]!==k||t[27]!==w?(A=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[w,k]}),t[26]=k,t[27]=w,t[28]=A):A=t[28];let j;t[29]!==s.cta||t[30]!==s.deepLink||t[31]!==_||t[32]!==a||t[33]!==r||t[34]!==v?(j=v?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,className:Y(`inline-flex h-8 items-center rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,_),onClick:()=>b(`/models/credits/purchase`),children:a.xopcQuotaPurchaseCta}),(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex h-8 items-center rounded-lg border border-current px-3 py-1.5 text-xs font-medium transition-colors hover:bg-amber-500/10`,onClick:()=>b(`/models/credits/request`),children:a.xopcQuotaRequestCta}),(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex h-8 items-center rounded-lg border border-current px-3 py-1.5 text-xs font-medium transition-colors hover:bg-amber-500/10`,onClick:()=>r(`/settings/capabilities/models?add=1`),children:a.xopcQuotaOwnProviderCta})]}):s.cta&&s.deepLink?(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,Z.jsx)(`button`,{type:`button`,className:Y(`inline-flex h-8 items-center rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/50`,_),onClick:()=>r(s.deepLink),children:s.cta})}):null,t[29]=s.cta,t[30]=s.deepLink,t[31]=_,t[32]=a,t[33]=r,t[34]=v,t[35]=j):j=t[35];let M;t[36]!==m||t[37]!==g||t[38]!==a||t[39]!==n.message?(M=n.message?(0,Z.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,Z.jsx)(`summary`,{className:Y(`cursor-pointer select-none underline-offset-2`,m),children:a.agentRunErrorDetailToggle}),(0,Z.jsx)(`pre`,{className:Y(`mt-2 max-h-40 w-full min-w-0 overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-md p-2 font-mono text-[11px] [overflow-wrap:anywhere]`,g),children:n.message})]}):null,t[36]=m,t[37]=g,t[38]=a,t[39]=n.message,t[40]=M):M=t[40];let N;return t[41]!==A||t[42]!==j||t[43]!==M||t[44]!==x?(N=(0,Z.jsxs)(`section`,{role:`alert`,"aria-live":`polite`,className:x,children:[A,j,M]}),t[41]=A,t[42]=j,t[43]=M,t[44]=x,t[45]=N):N=t[45],N}function ih(e){return window.open(`https://console.xopc.ai${e}`,`_blank`,`noopener,noreferrer`)}function ah(e){return e.language}function oh(e){let t=(0,X.c)(8),{errorText:n}=e,r;t[0]===n?r=t[1]:(r=Bn(n),t[0]=n,t[1]=r);let i=r;if(!i)return null;let a;t[2]===i?a=t[3]:(a=gr(i),t[2]=i,t[3]=a);let o=a;if(o){let e;return t[4]===o?e=t[5]:(e=(0,Z.jsx)(`div`,{className:`mb-4`,children:(0,Z.jsx)(sh,{payload:o})}),t[4]=o,t[5]=e),e}let s;return t[6]===i?s=t[7]:(s=(0,Z.jsx)(`div`,{className:`mb-4`,children:(0,Z.jsx)(rh,{payload:i})}),t[6]=i,t[7]=s),s}function sh(e){let t=(0,X.c)(32),{payload:n}=e,r=d(),i=h(ch),a,o,s,c;t[0]!==i||t[1]!==n.kind||t[2]!==n.provider?(o=y(i).chat,a=n.kind===`provider_auth_invalid`,c=a?o.agentRunErrorAuthInvalidTitle:o.providerSetupRequiredTitle,s=(a?o.agentRunErrorAuthInvalidBody:o.providerSetupRequiredBody).replace(`{{provider}}`,n.provider),t[0]=i,t[1]=n.kind,t[2]=n.provider,t[3]=a,t[4]=o,t[5]=s,t[6]=c):(a=t[3],o=t[4],s=t[5],c=t[6]);let l=s,u=a?o.agentRunErrorCtaProviders:o.providerSetupRequiredCta,f=a?o.agentRunErrorDetailToggle:o.providerSetupRequiredDetailToggle,p=a?`alert`:`status`,m;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=Y(`flex flex-col gap-2 rounded-xl border border-amber-300/60 bg-amber-50 p-3`,`dark:border-amber-500/30 dark:bg-amber-950`),t[7]=m):m=t[7];let g;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(g=Y(`flex size-8 shrink-0 items-center justify-center rounded-lg`,`bg-amber-100 text-amber-700 dark:bg-amber-500/20 dark:text-amber-300`),t[8]=g):g=t[8];let _;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Z.jsx)(`span`,{className:g,"aria-hidden":!0,children:(0,Z.jsx)(Ue,{className:`size-4`,strokeWidth:1.75})}),t[9]=_):_=t[9];let v;t[10]===c?v=t[11]:(v=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-amber-900 dark:text-amber-100`,children:c}),t[10]=c,t[11]=v);let b;t[12]===l?b=t[13]:(b=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-amber-900/85 dark:text-amber-100/80`,children:l}),t[12]=l,t[13]=b);let x;t[14]!==v||t[15]!==b?(x=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[_,(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[v,b]})]}),t[14]=v,t[15]=b,t[16]=x):x=t[16];let S;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(S=Y(`inline-flex h-8 items-center rounded-lg px-3 py-1.5 text-xs font-medium`,`bg-amber-600 text-white hover:bg-amber-700`,`dark:bg-amber-500 dark:text-amber-950 dark:hover:bg-amber-400`,`transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/50`),t[17]=S):S=t[17];let C;t[18]!==r||t[19]!==n.deepLink?(C=()=>r(n.deepLink),t[18]=r,t[19]=n.deepLink,t[20]=C):C=t[20];let w;t[21]!==u||t[22]!==C?(w=(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,Z.jsx)(`button`,{type:`button`,className:S,onClick:C,children:u})}),t[21]=u,t[22]=C,t[23]=w):w=t[23];let T;t[24]!==f||t[25]!==n.message?(T=n.message?(0,Z.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer select-none text-amber-800/80 underline-offset-2 hover:text-amber-900 dark:text-amber-200/80 dark:hover:text-amber-100`,children:f}),(0,Z.jsx)(`pre`,{className:`mt-2 max-h-40 w-full min-w-0 overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-md bg-amber-100/60 p-2 font-mono text-[11px] text-amber-900 dark:bg-amber-500/15 dark:text-amber-100 [overflow-wrap:anywhere]`,children:n.message})]}):null,t[24]=f,t[25]=n.message,t[26]=T):T=t[26];let E;return t[27]!==w||t[28]!==T||t[29]!==p||t[30]!==x?(E=(0,Z.jsxs)(`section`,{role:p,"aria-live":`polite`,className:m,children:[x,w,T]}),t[27]=w,t[28]=T,t[29]=p,t[30]=x,t[31]=E):E=t[31],E}function ch(e){return e.language}var lh=/^No API key found for (\S+)/i;function uh(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=lh.exec(t);return n?{kind:`provider_setup_required`,provider:n[1].replace(/[.,]$/,``),deepLink:`/settings/capabilities/models`,message:t}:null}var dh=new WeakMap;function fh(e){let t=dh.get(e),n=or(e);return t??(n?[n]:[])}function ph(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??``}`},pr(e,t[t.length-1]),dh.set(t[t.length-1],[...fh(e),...fh(n)]);continue}t.push(n)}return t}var mh=/^\s*\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$/m,hh=/^\s{0,3}(?:[-+*]|\d+[.)])\s+/m,gh=/^\s{0,3}```/gm;function _h(e){return(e.match(gh)?.length??0)%2==1?`code`:mh.test(e)?`table`:hh.test(e)?`list`:e.length>=4096?`long_text`:`plain`}var vh={plain:50,long_text:50,list:50,table:72,code:64};function yh({tailKind:e,latestParseMs:t}){let n=vh[e];return!Number.isFinite(t)||t<=16?n:Math.min(120,Math.max(n,Math.ceil(t*2)))}var bh=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=jd(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 xh(e,t,n,r=!1,i,a=!1){let[o,s]=(0,Q.useState)(()=>e),[c]=(0,Q.useState)(()=>new bh(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,mt(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){ct(n,e.length),o();return}if(c.observe(e.length,performance.now()),p.current=yh({tailKind:_h(e.slice(-8192)),latestParseMs:st(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,ct(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 Sh(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 Ch(e){let t=(0,X.c)(33),{review:n}=e,r=h(Th),i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n.analysisMarkdown||t[2]!==n.errorMessage||t[3]!==n.overallCorrectness||t[4]!==n.source||t[5]!==n.status||t[6]!==n.target){o=y(r).chat.reviewCard,i=n.status===`preparing`||n.status===`reviewing`;let e=n.status===`preparing`;a=n.source===`local`&&n.overallCorrectness===`unknown`;let p=n.overallCorrectness===`patch is incorrect`?`border-red-500/30 bg-red-500/5 text-red-700 dark:text-red-300`:n.overallCorrectness===`patch is correct`?`border-emerald-500/30 bg-emerald-500/5 text-emerald-700 dark:text-emerald-300`:`border-edge bg-surface-inset text-fg-secondary`;s=`min-w-0 rounded-lg border border-edge bg-surface-inset p-3`;let m;t[16]===i?m=t[17]:(m=i?(0,Z.jsx)(Je,{className:`size-4 animate-spin text-accent`,"aria-hidden":!0}):null,t[16]=i,t[17]=m),c=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[m,(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg-primary`,children:i?o.running:o.finished}),i?(0,Z.jsx)(`div`,{className:`rounded-md border border-edge bg-surface-inset px-1.5 py-0.5 text-[11px] font-medium text-fg-secondary`,children:e?o.collecting:o.assistant}):(0,Z.jsx)(`div`,{className:Y(`rounded-md border px-1.5 py-0.5 text-[11px] font-medium`,p),children:o.correctness[n.overallCorrectness]})]}),l=(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-fg-tertiary`,children:o.basedOn.replace(`{{target}}`,n.target)}),u=i&&!n.analysisMarkdown?(0,Z.jsx)(`div`,{className:`mt-3 text-sm text-fg-secondary`,children:e?o.preparing:o.checking}):null,d=n.analysisMarkdown?(0,Z.jsxs)(`div`,{className:`mt-3 rounded-md border border-edge-subtle bg-surface px-2.5 py-2`,children:[(0,Z.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg-secondary`,children:o.assistant}),(0,Z.jsx)(cf,{content:n.analysisMarkdown,compact:!0,streaming:i})]}):null,f=n.status===`error`&&n.errorMessage?(0,Z.jsx)(`div`,{className:`mt-3 rounded-md border border-warning/30 bg-warning/5 px-2.5 py-2 text-sm text-warning`,children:o.error.replace(`{{error}}`,n.errorMessage)}):null,t[0]=r,t[1]=n.analysisMarkdown,t[2]=n.errorMessage,t[3]=n.overallCorrectness,t[4]=n.source,t[5]=n.status,t[6]=n.target,t[7]=i,t[8]=a,t[9]=o,t[10]=s,t[11]=c,t[12]=l,t[13]=u,t[14]=d,t[15]=f}else i=t[7],a=t[8],o=t[9],s=t[10],c=t[11],l=t[12],u=t[13],d=t[14],f=t[15];let p;t[18]!==i||t[19]!==a||t[20]!==n.findings||t[21]!==n.overallExplanation||t[22]!==n.summary||t[23]!==o?(p=i?null:(0,Z.jsxs)(Z.Fragment,{children:[n.summary?(0,Z.jsx)(`div`,{className:`mt-3 text-sm text-fg-secondary`,children:n.summary}):null,(0,Z.jsx)(`div`,{className:`mt-3 space-y-2`,children:n.findings.length===0?(0,Z.jsx)(`div`,{className:`text-sm text-fg-secondary`,children:a?o.noModelFindings:o.noFindings}):n.findings.map(wh)}),n.overallExplanation?(0,Z.jsx)(`div`,{className:`mt-3 whitespace-pre-wrap text-sm text-fg-secondary`,children:n.overallExplanation}):null]}),t[18]=i,t[19]=a,t[20]=n.findings,t[21]=n.overallExplanation,t[22]=n.summary,t[23]=o,t[24]=p):p=t[24];let m;return t[25]!==s||t[26]!==c||t[27]!==l||t[28]!==u||t[29]!==d||t[30]!==f||t[31]!==p?(m=(0,Z.jsxs)(`div`,{className:s,children:[c,l,u,d,f,p]}),t[25]=s,t[26]=c,t[27]=l,t[28]=u,t[29]=d,t[30]=f,t[31]=p,t[32]=m):m=t[32],m}function wh(e,t){let n=Sh(e);return(0,Z.jsxs)(`div`,{className:`rounded-md border border-edge bg-surface p-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`span`,{className:`rounded border border-edge bg-surface-inset px-1.5 py-0.5 text-[11px] font-semibold text-fg-secondary`,children:[`P`,e.priority]}),(0,Z.jsx)(`span`,{className:`min-w-0 text-sm font-medium text-fg-primary`,children:e.title})]}),n?(0,Z.jsx)(`div`,{className:`mt-1 break-all text-xs text-fg-tertiary`,children:n}):null,e.body?(0,Z.jsx)(`div`,{className:`mt-1 text-sm text-fg-secondary`,children:e.body}):null]},`${e.title}-${t}`)}function Th(e){return e.language}function Eh({resolution:e,conversationId:t,onClose:n}){let r=h(e=>e.language),i=y(r).chat.fileReference,[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(!1),d=Ta()&&!!window.electronAPI?.shell,f=e.target.path,p=e.status===`ready`?e.ref:null,m=p?.displayName??f.split(/[\\/]/).pop()??f,g=p?.absolutePath??p?.workspaceRelativePath??f,_=(0,Q.useCallback)(()=>{Ci(g).then(e=>{e&&(o(!0),window.setTimeout(()=>o(!1),2e3))})},[g]),v=async e=>{let n=window.electronAPI?.shell;if(!(!p?.fileRefId||!d||!n||l)){c(``),u(!0);try{let r=await Va(p.fileRefId,e,{conversationId:t?.trim()||void 0});if(e===`openExternal`){let e=await n.openPath(r.absolutePath);e.ok||c(e.error)}else(await n.showItemInFolder(r.absolutePath)).success||c(i.resolveFailedDescription)}catch(e){c(e instanceof Error?e.message:String(e))}finally{u(!1)}}};return(0,Z.jsxs)(`div`,{className:Y(`mt-2 flex max-w-xl min-w-0 flex-col gap-1.5 rounded-lg border px-2.5 py-2 text-xs`,e.status===`ready`&&e.ref.exists&&e.ref.scope!==`missing`?`border-edge-subtle bg-surface-panel`:`border-warning/30 bg-warning/5`),children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.status===`loading`?(0,Z.jsx)(Je,{className:`size-3.5 shrink-0 animate-spin text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}):e.status===`error`||p?.scope===`missing`||p?.scope===`invalid`?(0,Z.jsx)(K,{className:`size-3.5 shrink-0 text-warning`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(Ce,{className:`size-3.5 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:m}),(0,Z.jsx)(`button`,{type:`button`,onClick:n,className:Y(`ml-auto inline-flex size-5 shrink-0 items-center justify-center rounded text-fg-muted hover:bg-surface-hover hover:text-fg`,ca.focusRingPanel),"aria-label":i.closeActions,children:(0,Z.jsx)(Gt,{className:`size-3`,strokeWidth:1.75,"aria-hidden":!0})})]}),(0,Z.jsx)(`p`,{className:`line-clamp-2 break-all text-[11px] leading-snug text-fg-muted`,children:e.status===`loading`?i.resolvingDescription:e.status===`error`?e.message:p?.scope===`missing`?i.missingDescription:p?.scope===`invalid`?i.invalidDescription:d?i.externalDescription:i.browserExternalDescription}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 pt-0.5`,children:[d&&p?.capabilities.includes(`openExternal`)?(0,Z.jsxs)(`button`,{type:`button`,className:Dh,disabled:l,onClick:()=>void v(`openExternal`),children:[(0,Z.jsx)(xe,{className:`size-3`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:i.openExternal})]}):null,d&&p?.capabilities.includes(`revealInFolder`)?(0,Z.jsxs)(`button`,{type:`button`,className:Dh,disabled:l,onClick:()=>void v(`revealInFolder`),children:[(0,Z.jsx)(De,{className:`size-3`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:i.revealInFolder})]}):null,p?.manageRoute?(0,Z.jsxs)(`a`,{className:Dh,href:`#${p.manageRoute}`,children:[(0,Z.jsx)(Ft,{className:`size-3`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:y(r).nav.settings})]}):null,(0,Z.jsxs)(`button`,{type:`button`,className:Dh,onClick:_,children:[(0,Z.jsx)(ve,{className:`size-3`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:a?y(r).chat.messageCopied:i.copyPath})]})]}),s?(0,Z.jsx)(`p`,{role:`alert`,className:`text-warning`,children:s}):null]})}var Dh=Y(`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,ca.focusRingPanel,ca.press);function Oh({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=Hm(n,r)??t,p=`assistant-markdown-${(0,Q.useId)()}`,m=xh(f,s,p,c,l,d);(0,Q.useLayoutEffect)(()=>{if(!u||!m.trim())return;let e=window.requestAnimationFrame(()=>mr(u,m));return()=>window.cancelAnimationFrame(e)},[u,m,s]),(0,Q.useEffect)(()=>{if(s)return ut(p),()=>gt(p)},[p,s]);let g=Ni(e=>e.setPath),_=y(h(e=>e.language)).chat.fileReference,[v,b]=(0,Q.useState)(null),x=(0,Q.useRef)(0);(0,Q.useEffect)(()=>()=>{x.current++},[a,o,e]);let S=(0,Q.useCallback)(async t=>{try{return await Ra(t.path,{projectId:o?.trim()||void 0,conversationId:a?.trim()||void 0,taskRunId:e})}catch(n){if(e||o||!a)throw n;return Ra(t.path)}},[o,a,e]),C=(0,Q.useCallback)(t=>{let n=++x.current;if(t.kind===`workspace-relative`){b({status:`loading`,target:t}),(async()=>{let r=await Ua(t.path,{projectId:o?.trim()||void 0,conversationId:a?.trim()||void 0,taskRunId:e});if(n!==x.current)return;if(r?.capabilities.includes(`preview`)&&(r.absolutePath||r.workspaceRelativePath)){g(r.absolutePath||r.workspaceRelativePath,t.line,o,a),b(null);return}let i=!e&&!o&&a?await Ua(t.path):null;if(n===x.current){if(i?.capabilities.includes(`preview`)&&(i.absolutePath||i.workspaceRelativePath)){g(i.absolutePath||i.workspaceRelativePath,t.line),b(null);return}b(r?{status:`ready`,target:t,ref:r}:{status:`error`,target:t,message:_.resolveFailedDescription})}})().catch(e=>{n===x.current&&b({status:`error`,target:t,message:e instanceof Error?e.message:String(e)})});return}b({status:`loading`,target:t}),Ua(t.path,{projectId:o?.trim()||void 0,conversationId:a?.trim()||void 0,taskRunId:e}).then(e=>{if(n===x.current){if(!e){b({status:`error`,target:t,message:_.resolveFailedDescription});return}if(e.capabilities.includes(`preview`)&&(e.absolutePath||e.workspaceRelativePath)){g(e.absolutePath||e.workspaceRelativePath,t.line,o,a),b(null);return}b({status:`ready`,target:t,ref:e})}}).catch(e=>{n===x.current&&b({status:`error`,target:t,message:e instanceof Error?e.message:String(e)})})},[_.resolveFailedDescription,o,a,e,g]),w=uh(f);return(0,Z.jsxs)(Z.Fragment,{children:[w?(0,Z.jsx)(sh,{payload:w}):(0,Z.jsx)(cf,{content:m,streaming:s||m!==f,compact:i,onWorkspaceFileOpen:C,onWorkspaceImageLoad:S,renderMermaid:!0,mermaidActions:!0,streamingMetricsKey:p}),v?(0,Z.jsx)(Eh,{resolution:v,conversationId:a,onClose:()=>{x.current++,b(null)}}):null]})}function kh(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){if(e.type===`text`)return n?(0,Z.jsx)(`div`,{className:`min-w-0`,children:(0,Z.jsx)(Ym,{text:hr(e.text??``),conversationId:s,document:f,contextRefs:p})},t):(0,Z.jsx)(`div`,{className:`assistant-markdown-content markdown-content min-w-0`,children:(0,Z.jsx)(Oh,{content:e.text,sourcePartIds:fh(e),sourceConversationId:s,taskRunId:m,compact:!0,conversationId:c??s,projectId:l,streaming:r,animateInitialContent:u,onProgressiveRenderComplete:d,responseRunId:h,immediateFirstCommit:g})},t);if(e.type===`image`&&e.source?.data){let n=o??0;return(0,Z.jsx)(dd,{source:e.source.data,alt:``,title:i,onOpen:a?()=>a(e,n):void 0},t)}return e.type===`review`?(0,Z.jsx)(Ch,{review:e},t):null}function Ah(e){let t=(0,X.c)(24),{taskRunId:n,content:r,isUser:i,isAssistantMessageStreaming:a,imagePreviewLabel:o,onImagePreview:s,conversationId:c,workspaceConversationId:l,projectId:u,progressiveRender:d,onProgressiveRenderComplete:f,userTurnDocument:p,contextRefs:m,responseRunId:h,immediateFirstCommit:g,renderActivity:_,processItems:v,processCollapsed:y}=e,b=d!==void 0&&d,x=g!==void 0&&g,S=y!==void 0&&y,C;if(t[0]!==r||t[1]!==m||t[2]!==c||t[3]!==o||t[4]!==x||t[5]!==a||t[6]!==i||t[7]!==s||t[8]!==f||t[9]!==S||t[10]!==v||t[11]!==b||t[12]!==u||t[13]!==_||t[14]!==h||t[15]!==n||t[16]!==p||t[17]!==l){let e=i?r:ph(r),d;t[19]===v?d=t[20]:(d=new Set(v?[...v].map(or).filter(Boolean):[]),t[19]=v,t[20]=d);let g=d,y;t[21]!==v||t[22]!==g?(y=e=>v?.has(e)||!!(or(e)&&g.has(or(e))),t[21]=v,t[22]=g,t[23]=y):y=t[23];let w=y,T=e.findLastIndex(jh),E=e.at(-1),D=T<0&&E?.type===`text`&&E.presentation===void 0?e.length-1:-1,O=a?Math.max(T,D):-1,k=[],A=0,j=0;for(;A<e.length;){let t=e[A];if(t.type===`thinking`||t.type===`tool_use`){let n=A,r=[];for(;A<e.length;){let t=e[A];if(t.type!==`thinking`&&t.type!==`tool_use`)break;r.push(t),A++}_&&k.push((0,Z.jsx)(`div`,{"data-assistant-activity":!0,"data-assistant-process-item":v?!0:void 0,hidden:S,children:_(r,A===e.length)},or(t)??`activity-${n}`))}else{let e=t.type===`image`?j++:0,r=kh(t,or(t)??`block-${A}`,i,A===O,o,s,t.type===`image`?e:A,c,l,u,b,f,i&&A===0?p:void 0,i&&A===0?m:void 0,n,h,x);r&&k.push(v?(0,Z.jsx)(`div`,{"data-assistant-process-item":w(t)||void 0,hidden:S&&w(t),children:r},or(t)??`block-${A}`):r),A++}}C=(0,Z.jsx)(Z.Fragment,{children:k}),t[0]=r,t[1]=m,t[2]=c,t[3]=o,t[4]=x,t[5]=a,t[6]=i,t[7]=s,t[8]=f,t[9]=S,t[10]=v,t[11]=b,t[12]=u,t[13]=_,t[14]=h,t[15]=n,t[16]=p,t[17]=l,t[18]=C}else C=t[18];return C}function jh(e){return e.type===`text`&&e.presentation===`pending`}var Mh=[`readFile`,`editFile`,`writeFile`,`runCommand`,`memorySearch`,`codeSearch`,`webSearch`,`search`,`fetchUrl`,`openUrl`,`listDir`,`other`];function Nh(e,t){return ha(e,t)}function Ph(e){let t=new Map;for(let n of e){if(n.type!==`tool_use`)continue;let e=Nh(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 Fh(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 Ih(e,t,n){let r=Ph(e),i=[];for(let e of Mh){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)||Fh(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 Lh(e){return e.filter(e=>e.type!==`thinking`||!!e.text?.trim()||!!e.streaming)}function Rh(e,t,n){return Ih(e,t,n)}function zh(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Bh(e){if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}}function Vh(e){let t=zh(Bh(e));if(!t)return[];let n=zh(t.details)?.results??t.results;if(Array.isArray(n))return n.map(zh).filter(e=>e!==null);let r=Array.isArray(t.content)?t.content:[];for(let e of r){let t=zh(e)?.text,n=zh(Bh(t));if(Array.isArray(n?.results))return n.results.map(zh).filter(e=>e!==null)}return[]}function Hh(e,t){return e.replace(/\{\{count\}\}/g,String(t))}function Uh(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=Vh(e.result),r=e.activity?.count??n.length;return{title:r===0?t.empty:Hh(r===1?t.found_one:t.found_other,r),purpose:t.purpose}}function Wh(e,t){if(e.status===`running`)return{title:t?`正在更新记忆`:`Updating memory`,purpose:``};let n=zh(Bh(e.result)),r=zh(n?.details)??n;if(!r?.status&&Array.isArray(n?.content))for(let e of n.content){let t=zh(Bh(zh(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=zh(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 Gh(e){if(e.scrollHeight<=e.clientHeight)return!1;let t=window.getComputedStyle(e).overflowY;return t===`auto`||t===`scroll`}function Kh(e,t,n){let r=[],i=e instanceof HTMLElement?e:t;for(;i&&i!==t;)Gh(i)&&r.push(i),i=i.parentElement;return t.scrollHeight>t.clientHeight&&r.push(t),n!==t&&r.push(n),r}function qh(e,t){let n=e;for(let e of t){let t=Math.max(0,e.scrollHeight-e.clientHeight),r=Math.min(t,Math.max(0,e.scrollTop+n)),i=r-e.scrollTop;if(i!==0&&(e.scrollTop=r),n-=i,Math.abs(n)<.01)break}}function Jh(e,t){if(e.defaultPrevented||e.ctrlKey||e.deltaY===0||Math.abs(e.deltaY)<=Math.abs(e.deltaX))return;let n=t.closest(`.chat-messages`);if(!n)return;let r=t.clientHeight||n.clientHeight,i=e.deltaMode===WheelEvent.DOM_DELTA_LINE?16:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?r:1,a=Kh(e.target,t,n);e.preventDefault(),qh(e.deltaY*i,a)}function Yh(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 Xh(e){if(e==null)return null;try{return typeof e==`string`?JSON.parse(e):e}catch{return null}}function Zh(e){let t=Xh(e),n=t?.path??t?.file_path??t?.filepath??t?.file??t?.qualified_name??t?.function_name;return typeof n==`string`?n:``}function Qh(e){let t=Xh(e),n=t?.url??t?.href??t?.uri??t?.website;return typeof n==`string`?n:``}function $h(e){let t=Xh(e),n=t?.command??t?.cmd??t?.shell??t?.script;return typeof n==`string`?n:``}var eg=120;function tg(e){if(e==null)return``;let t=Xh(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>eg?`${t.slice(0,eg)}…`:t}if(typeof e==`number`&&Number.isFinite(e))return String(e)}return``}function ng(e){return e.startsWith(`@@`)?`hunk`:e.startsWith(`+++`)||e.startsWith(`---`)||e.startsWith(`diff `)||e.startsWith(`index `)?`meta`:e.startsWith(`+`)?`add`:e.startsWith(`-`)?`del`:`context`}function rg(e){let t=e.details?.diff;if(typeof t!=`string`||t.length===0)return null;let n=t.split(`
17
+ `),r=[],i=0,a=0;for(let e of n){let t=ng(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 ig=`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`,ag=`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`,og=`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`,sg=`cursor-pointer select-none text-xs text-fg-subtle underline-offset-2 hover:text-fg-muted group-open:text-fg-muted`;function cg(e){let t=(0,X.c)(5),{children:n,tone:r}=e,i=r===void 0?`neutral`:r,a=i===`positive`?`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`:i===`negative`?`bg-red-500/15 text-red-700 dark:text-red-300`:i===`warning`?`bg-amber-500/15 text-amber-700 dark:text-amber-300`:i===`accent`?`bg-accent-soft/70 text-accent-fg dark:bg-accent-soft/50`:``,o;t[0]===a?o=t[1]:(o=Y(ig,a),t[0]=a,t[1]=o);let s;return t[2]!==n||t[3]!==o?(s=(0,Z.jsx)(`span`,{className:o,children:n}),t[2]=n,t[3]=o,t[4]=s):s=t[4],s}function lg(e){let t=(0,X.c)(3),{children:n,title:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,Z.jsx)(`code`,{className:ag,title:r,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}var ug=(0,Q.memo)(function(e){let t=(0,X.c)(10),{text:n,label:r,copiedLabel:i}=e,[a,o]=(0,Q.useState)(!1),s;t[0]===n?s=t[1]:(s=async e=>{e.preventDefault(),e.stopPropagation(),await Ci(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`,ca.transition,ca.focusRingPanel),t[2]=c):c=t[2];let l=a?i:r,u=a?i:r,d;t[3]===a?d=t[4]:(d=a?(0,Z.jsx)(G,{className:`size-3.5`,"aria-hidden":!0}):(0,Z.jsx)(ve,{className:`size-3.5`,"aria-hidden":!0}),t[3]=a,t[4]=d);let f;return t[5]!==s||t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,Z.jsx)(`button`,{type:`button`,onClick:s,className:c,"aria-label":l,title:u,children:d}),t[5]=s,t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9],f});function dg(e){let t=(0,X.c)(8),{summary:n,children:r,defaultOpen:i}=e,a=i!==void 0&&i,o;t[0]===n?o=t[1]:(o=(0,Z.jsx)(`summary`,{className:sg,children:n}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,Z.jsx)(`div`,{className:`mt-1.5 min-w-0`,children:r}),t[2]=r,t[3]=s);let c;return t[4]!==a||t[5]!==o||t[6]!==s?(c=(0,Z.jsxs)(`details`,{className:`group min-w-0 text-xs`,open:a,children:[o,s]}),t[4]=a,t[5]=o,t[6]=s,t[7]=c):c=t[7],c}function fg(e){let t=(0,X.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`pre`,{className:og,children:n}),t[0]=n,t[1]=r),r}function pg(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>{let r=t[n];return r==null?``:String(r)})}function mg(e){return e.details??{}}var hg=/\[(\d+)\/(\d+) lines\]\s*$/;function gg(e){let t=e.match(hg);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 _g(e){return e.replace(hg,``).trimEnd()}var vg=(0,Q.memo)(function(e){let t=(0,X.c)(32),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=Zh(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=ma(n.result),t[2]=n.result,t[3]=o);let s=o.text,c;t[4]===s?c=t[5]:(c=gg(s),t[4]=s,t[5]=c);let l=c,u;t[6]===s?u=t[7]:(u=_g(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(`
18
18
  `),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(`
19
19
  `);if(e.length<=12){m=d;break bb1}m=`${e.slice(0,12).join(`
20
- `)}\n…`}t[10]=d,t[11]=m}else m=t[11];let h=m,g;t[12]===a?g=t[13]:(g=a?(0,Z.jsx)(cg,{title:a,children:a}):null,t[12]=a,t[13]=g);let _;t[14]!==r||t[15]!==l||t[16]!==p?(_=p>0?(0,Z.jsx)(sg,{children:l&&l.shown<l.total?fg(r.linesPartial,{shown:l.shown,total:l.total}):fg(r.linesBadge,{count:p})}):null,t[14]=r,t[15]=l,t[16]=p,t[17]=_):_=t[17];let v;t[18]!==r||t[19]!==a?(v=a?(0,Z.jsx)(lg,{text:a,label:r.copyPath,copiedLabel:r.copied}):null,t[18]=r,t[19]=a,t[20]=v):v=t[20];let y;t[21]!==g||t[22]!==_||t[23]!==v?(y=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,children:[g,_,v]}),t[21]=g,t[22]=_,t[23]=v,t[24]=y):y=t[24];let b;t[25]!==d||t[26]!==r||t[27]!==h?(b=d?(0,Z.jsx)(ug,{summary:r.viewContent,children:(0,Z.jsx)(dg,{children:h})}):null,t[25]=d,t[26]=r,t[27]=h,t[28]=b):b=t[28];let x;return t[29]!==y||t[30]!==b?(x=(0,Z.jsxs)(`div`,{className:`content-block-action-scope space-y-1.5`,children:[y,b]}),t[29]=y,t[30]=b,t[31]=x):x=t[31],x});function vg(e){let t=(0,X.c)(4),{lines:n}=e,r;t[0]===n?r=t[1]:(r=n.map(yg),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,Z.jsx)(`pre`,{className:`max-h-80 w-full min-w-0 max-w-full overflow-auto rounded-md bg-surface-hover/60 p-2 font-mono text-xs leading-snug text-fg-muted dark:bg-surface-hover/35`,children:r}),t[2]=r,t[3]=i),i}function yg(e,t){return(0,Z.jsx)(`div`,{className:Y(`whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,e.kind===`add`&&`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`,e.kind===`del`&&`bg-red-500/15 text-red-700 dark:text-red-300`,e.kind===`hunk`&&`text-fg-subtle`,e.kind===`meta`&&`text-fg-disabled`),children:e.text||`\xA0`},t)}var bg=(0,Q.memo)(function(e){let t=(0,X.c)(25),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=Xh(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=ma(n.result),t[2]=n.result,t[3]=o);let s=o,c;t[4]===s?c=t[5]:(c=ng(s),t[4]=s,t[5]=c);let l=c,u;t[6]===a?u=t[7]:(u=a?(0,Z.jsx)(cg,{title:a,children:a}):null,t[6]=a,t[7]=u);let d;t[8]!==l||t[9]!==r?(d=l?(0,Z.jsx)(sg,{tone:`accent`,children:fg(r.diffStats,{added:l.added,removed:l.removed})}):null,t[8]=l,t[9]=r,t[10]=d):d=t[10];let f;t[11]!==r||t[12]!==a?(f=a?(0,Z.jsx)(lg,{text:a,label:r.copyPath,copiedLabel:r.copied}):null,t[11]=r,t[12]=a,t[13]=f):f=t[13];let p;t[14]!==u||t[15]!==d||t[16]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,children:[u,d,f]}),t[14]=u,t[15]=d,t[16]=f,t[17]=p):p=t[17];let m;t[18]!==l||t[19]!==r||t[20]!==s?(m=l?(0,Z.jsx)(ug,{summary:r.viewDiff,defaultOpen:!0,children:(0,Z.jsx)(vg,{lines:l.lines})}):s.text?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted [overflow-wrap:anywhere]`,children:s.text}):null,t[18]=l,t[19]=r,t[20]=s,t[21]=m):m=t[21];let h;return t[22]!==p||t[23]!==m?(h=(0,Z.jsxs)(`div`,{className:`content-block-action-scope space-y-1.5`,children:[p,m]}),t[22]=p,t[23]=m,t[24]=h):h=t[24],h});function xg(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 Sg=(0,Q.memo)(function(e){let t=(0,X.c)(20),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=Xh(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=ma(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=pg(s),n=typeof e.size==`number`?e.size:null;c=`content-block-action-scope flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,t[10]===a?l=t[11]:(l=a?(0,Z.jsx)(cg,{title:a,children:a}):null,t[10]=a,t[11]=l),u=n==null?null:(0,Z.jsx)(sg,{children:fg(r.sizeBadge,{size:xg(n)})}),t[4]=r,t[5]=s,t[6]=a,t[7]=c,t[8]=l,t[9]=u}else c=t[7],l=t[8],u=t[9];let d;t[12]!==r||t[13]!==a?(d=a?(0,Z.jsx)(lg,{text:a,label:r.copyPath,copiedLabel:r.copied}):null,t[12]=r,t[13]=a,t[14]=d):d=t[14];let f;return t[15]!==c||t[16]!==l||t[17]!==u||t[18]!==d?(f=(0,Z.jsxs)(`div`,{className:c,children:[l,u,d]}),t[15]=c,t[16]=l,t[17]=u,t[18]=d,t[19]=f):f=t[19],f}),Cg=12;function wg(e){if(!e)return{preview:``,truncated:!1};let t=e.split(`
21
- `);return t.length<=Cg?{preview:e,truncated:!1}:{preview:`${t.slice(0,Cg).join(`
22
- `)}\n…`,truncated:!0}}var Tg=(0,Q.memo)(function(e){let t=(0,X.c)(29),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=Qh(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=ma(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??pg(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=wg(f),t[7]=f,t[8]=p);let{preview:m}=p,h;t[9]===a?h=t[10]:(h=a?(0,Z.jsxs)(cg,{title:a,children:[(0,Z.jsx)(`span`,{className:`mr-1 text-fg-disabled`,children:`$`}),a]}):null,t[9]=a,t[10]=h);let g;t[11]!==r||t[12]!==d?(g=d?(0,Z.jsx)(sg,{children:r.truncatedBadge}):null,t[11]=r,t[12]=d,t[13]=g):g=t[13];let _;t[14]!==a||t[15]!==r?(_=a?(0,Z.jsx)(lg,{text:a,label:r.copyCommand,copiedLabel:r.copied}):null,t[14]=a,t[15]=r,t[16]=_):_=t[16];let v;t[17]!==h||t[18]!==g||t[19]!==_?(v=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,children:[h,g,_]}),t[17]=h,t[18]=g,t[19]=_,t[20]=v):v=t[20];let y;t[21]!==n.status||t[22]!==r||t[23]!==f||t[24]!==m?(y=f?(0,Z.jsx)(ug,{summary:r.viewOutput,children:(0,Z.jsx)(dg,{children:m})}):n.status===`running`?null:(0,Z.jsx)(`p`,{className:`text-xs text-fg-disabled`,children:r.noOutput}),t[21]=n.status,t[22]=r,t[23]=f,t[24]=m,t[25]=y):y=t[25];let b;return t[26]!==v||t[27]!==y?(b=(0,Z.jsxs)(`div`,{className:`content-block-action-scope space-y-1.5`,children:[v,y]}),t[26]=v,t[27]=y,t[28]=b):b=t[28],b}),Eg=(0,Q.memo)(function(e){let t=(0,X.c)(27),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=Zh(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=ma(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=pg(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(`
20
+ `)}\n…`}t[10]=d,t[11]=m}else m=t[11];let h=m,g;t[12]===a?g=t[13]:(g=a?(0,Z.jsx)(lg,{title:a,children:a}):null,t[12]=a,t[13]=g);let _;t[14]!==r||t[15]!==l||t[16]!==p?(_=p>0?(0,Z.jsx)(cg,{children:l&&l.shown<l.total?pg(r.linesPartial,{shown:l.shown,total:l.total}):pg(r.linesBadge,{count:p})}):null,t[14]=r,t[15]=l,t[16]=p,t[17]=_):_=t[17];let v;t[18]!==r||t[19]!==a?(v=a?(0,Z.jsx)(ug,{text:a,label:r.copyPath,copiedLabel:r.copied}):null,t[18]=r,t[19]=a,t[20]=v):v=t[20];let y;t[21]!==g||t[22]!==_||t[23]!==v?(y=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,children:[g,_,v]}),t[21]=g,t[22]=_,t[23]=v,t[24]=y):y=t[24];let b;t[25]!==d||t[26]!==r||t[27]!==h?(b=d?(0,Z.jsx)(dg,{summary:r.viewContent,children:(0,Z.jsx)(fg,{children:h})}):null,t[25]=d,t[26]=r,t[27]=h,t[28]=b):b=t[28];let x;return t[29]!==y||t[30]!==b?(x=(0,Z.jsxs)(`div`,{className:`content-block-action-scope space-y-1.5`,children:[y,b]}),t[29]=y,t[30]=b,t[31]=x):x=t[31],x});function yg(e){let t=(0,X.c)(4),{lines:n}=e,r;t[0]===n?r=t[1]:(r=n.map(bg),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,Z.jsx)(`pre`,{className:`max-h-80 w-full min-w-0 max-w-full overflow-auto rounded-md bg-surface-hover/60 p-2 font-mono text-xs leading-snug text-fg-muted dark:bg-surface-hover/35`,children:r}),t[2]=r,t[3]=i),i}function bg(e,t){return(0,Z.jsx)(`div`,{className:Y(`whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,e.kind===`add`&&`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`,e.kind===`del`&&`bg-red-500/15 text-red-700 dark:text-red-300`,e.kind===`hunk`&&`text-fg-subtle`,e.kind===`meta`&&`text-fg-disabled`),children:e.text||`\xA0`},t)}var xg=(0,Q.memo)(function(e){let t=(0,X.c)(25),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=Zh(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=ma(n.result),t[2]=n.result,t[3]=o);let s=o,c;t[4]===s?c=t[5]:(c=rg(s),t[4]=s,t[5]=c);let l=c,u;t[6]===a?u=t[7]:(u=a?(0,Z.jsx)(lg,{title:a,children:a}):null,t[6]=a,t[7]=u);let d;t[8]!==l||t[9]!==r?(d=l?(0,Z.jsx)(cg,{tone:`accent`,children:pg(r.diffStats,{added:l.added,removed:l.removed})}):null,t[8]=l,t[9]=r,t[10]=d):d=t[10];let f;t[11]!==r||t[12]!==a?(f=a?(0,Z.jsx)(ug,{text:a,label:r.copyPath,copiedLabel:r.copied}):null,t[11]=r,t[12]=a,t[13]=f):f=t[13];let p;t[14]!==u||t[15]!==d||t[16]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,children:[u,d,f]}),t[14]=u,t[15]=d,t[16]=f,t[17]=p):p=t[17];let m;t[18]!==l||t[19]!==r||t[20]!==s?(m=l?(0,Z.jsx)(dg,{summary:r.viewDiff,defaultOpen:!0,children:(0,Z.jsx)(yg,{lines:l.lines})}):s.text?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted [overflow-wrap:anywhere]`,children:s.text}):null,t[18]=l,t[19]=r,t[20]=s,t[21]=m):m=t[21];let h;return t[22]!==p||t[23]!==m?(h=(0,Z.jsxs)(`div`,{className:`content-block-action-scope space-y-1.5`,children:[p,m]}),t[22]=p,t[23]=m,t[24]=h):h=t[24],h});function Sg(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 Cg=(0,Q.memo)(function(e){let t=(0,X.c)(20),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=Zh(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=ma(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=mg(s),n=typeof e.size==`number`?e.size:null;c=`content-block-action-scope flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,t[10]===a?l=t[11]:(l=a?(0,Z.jsx)(lg,{title:a,children:a}):null,t[10]=a,t[11]=l),u=n==null?null:(0,Z.jsx)(cg,{children:pg(r.sizeBadge,{size:Sg(n)})}),t[4]=r,t[5]=s,t[6]=a,t[7]=c,t[8]=l,t[9]=u}else c=t[7],l=t[8],u=t[9];let d;t[12]!==r||t[13]!==a?(d=a?(0,Z.jsx)(ug,{text:a,label:r.copyPath,copiedLabel:r.copied}):null,t[12]=r,t[13]=a,t[14]=d):d=t[14];let f;return t[15]!==c||t[16]!==l||t[17]!==u||t[18]!==d?(f=(0,Z.jsxs)(`div`,{className:c,children:[l,u,d]}),t[15]=c,t[16]=l,t[17]=u,t[18]=d,t[19]=f):f=t[19],f}),wg=12;function Tg(e){if(!e)return{preview:``,truncated:!1};let t=e.split(`
21
+ `);return t.length<=wg?{preview:e,truncated:!1}:{preview:`${t.slice(0,wg).join(`
22
+ `)}\n…`,truncated:!0}}var Eg=(0,Q.memo)(function(e){let t=(0,X.c)(29),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=$h(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=ma(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??mg(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=Tg(f),t[7]=f,t[8]=p);let{preview:m}=p,h;t[9]===a?h=t[10]:(h=a?(0,Z.jsxs)(lg,{title:a,children:[(0,Z.jsx)(`span`,{className:`mr-1 text-fg-disabled`,children:`$`}),a]}):null,t[9]=a,t[10]=h);let g;t[11]!==r||t[12]!==d?(g=d?(0,Z.jsx)(cg,{children:r.truncatedBadge}):null,t[11]=r,t[12]=d,t[13]=g):g=t[13];let _;t[14]!==a||t[15]!==r?(_=a?(0,Z.jsx)(ug,{text:a,label:r.copyCommand,copiedLabel:r.copied}):null,t[14]=a,t[15]=r,t[16]=_):_=t[16];let v;t[17]!==h||t[18]!==g||t[19]!==_?(v=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,children:[h,g,_]}),t[17]=h,t[18]=g,t[19]=_,t[20]=v):v=t[20];let y;t[21]!==n.status||t[22]!==r||t[23]!==f||t[24]!==m?(y=f?(0,Z.jsx)(dg,{summary:r.viewOutput,children:(0,Z.jsx)(fg,{children:m})}):n.status===`running`?null:(0,Z.jsx)(`p`,{className:`text-xs text-fg-disabled`,children:r.noOutput}),t[21]=n.status,t[22]=r,t[23]=f,t[24]=m,t[25]=y):y=t[25];let b;return t[26]!==v||t[27]!==y?(b=(0,Z.jsxs)(`div`,{className:`content-block-action-scope space-y-1.5`,children:[v,y]}),t[26]=v,t[27]=y,t[28]=b):b=t[28],b}),Dg=(0,Q.memo)(function(e){let t=(0,X.c)(27),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=Qh(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=ma(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=mg(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(`
23
23
  `);if(e.length<=12){i=s.text;break bb0}i=`${e.slice(0,12).join(`
24
- `)}\n…`}t[12]=s.text,t[13]=i}else i=t[13];c=i,f=`space-y-1.5`,l=`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,t[14]===a?u=t[15]:(u=a?(0,Z.jsx)(`a`,{href:a,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex max-w-full min-w-0 items-center break-words rounded-md bg-surface-hover/60 px-1.5 py-0.5 font-mono text-xs text-accent-fg underline-offset-2 hover:underline [overflow-wrap:anywhere] dark:bg-surface-hover/35`,title:a,children:a}):null,t[14]=a,t[15]=u),d=n!=null&&n>0?(0,Z.jsx)(sg,{children:fg(r.linesBadge,{count:n})}):null,t[4]=r,t[5]=s,t[6]=a,t[7]=c,t[8]=l,t[9]=u,t[10]=d,t[11]=f}else c=t[7],l=t[8],u=t[9],d=t[10],f=t[11];let p;t[16]!==l||t[17]!==u||t[18]!==d?(p=(0,Z.jsxs)(`div`,{className:l,children:[u,d]}),t[16]=l,t[17]=u,t[18]=d,t[19]=p):p=t[19];let m;t[20]!==r||t[21]!==c?(m=c?(0,Z.jsx)(ug,{summary:r.viewContent,children:(0,Z.jsx)(dg,{children:c})}):null,t[20]=r,t[21]=c,t[22]=m):m=t[22];let h;return t[23]!==f||t[24]!==p||t[25]!==m?(h=(0,Z.jsxs)(`div`,{className:f,children:[p,m]}),t[23]=f,t[24]=p,t[25]=m,t[26]=h):h=t[26],h}),Dg=e=>e&&typeof e==`object`&&!Array.isArray(e)?e:void 0,Og=e=>typeof e==`string`&&/^[a-z0-9][a-z0-9_-]{0,63}$/.test(e)?e:void 0;function kg(e){let t={...ma(e.result).details,...Dg(e.details)},n=Dg(t?.searchInfo)??t,r=Array.isArray(n?.attempts)?n.attempts.slice(0,24).flatMap(e=>{let t=Dg(e),n=Og(t?.provider);return!n||![`success`,`empty`,`error`,`skipped`].includes(String(t?.outcome))?[]:[{provider:n,upstream:Og(t?.upstream),outcome:String(t?.outcome),reason:Og(t?.reason)}]}):[];return{provider:Og(n?.provider),upstream:Og(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 Ag(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 jg(e){let t=(0,X.c)(25),{block:n,summary:r,labels:i,developer:a,language:o}=e,[s,c]=(0,Q.useState)(!1),l;if(t[0]!==n||t[1]!==a||t[2]!==i.attempts||t[3]!==i.cacheHint||t[4]!==i.cacheUnknown||t[5]!==i.cached||t[6]!==i.cachedRoute||t[7]!==i.capturedAt||t[8]!==i.fresh||t[9]!==i.incompleteRoute||t[10]!==i.outcomes||t[11]!==i.provider||t[12]!==i.reasons||t[13]!==i.route||t[14]!==i.unknown||t[15]!==i.upstreamUnknown||t[16]!==o||t[17]!==s||t[18]!==r){let e=kg(n),u;t[20]===i.unknown?u=t[21]:(u=e=>Ag(e,i.unknown),t[20]=i.unknown,t[21]=u);let d=u,f=e.provider===`xopc-cloud`?`${d(e.provider)} · ${e.upstream?d(e.upstream):i.upstreamUnknown}`:d(e.provider),p;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(p=e=>c(e.currentTarget.open),t[22]=p):p=t[22];let m;t[23]===r?m=t[24]:(m=(0,Z.jsx)(`summary`,{className:`cursor-pointer hover:text-fg`,children:r}),t[23]=r,t[24]=m),l=(0,Z.jsxs)(`details`,{className:`min-w-0 text-xs text-fg-muted`,onToggle:p,children:[m,s?(0,Z.jsxs)(`div`,{className:`mt-2 space-y-2 rounded-md border border-edge px-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Z.jsxs)(`span`,{children:[i.provider,`:`,f]}),(0,Z.jsx)(`span`,{className:`text-fg-subtle`,children:e.cached===!0?i.cached:e.cached===!1?i.fresh:i.cacheUnknown})]}),e.cached===!0?(0,Z.jsx)(`p`,{className:`text-fg-subtle`,children:i.cacheHint}):null,a?(0,Z.jsxs)(`div`,{className:`space-y-1 border-t border-edge pt-2 text-fg-subtle`,children:[e.attemptCount===void 0?null:(0,Z.jsxs)(`p`,{children:[i.attempts,`:`,e.attemptCount]}),e.capturedAt===void 0?null:(0,Z.jsxs)(`p`,{children:[i.capturedAt,`:`,new Date(e.capturedAt).toLocaleString(o===`zh`?`zh-CN`:`en-US`)]}),e.attemptCount!==void 0&&e.attemptCount>e.attempts.length?(0,Z.jsx)(`p`,{children:i.incompleteRoute}):null,e.attempts.length?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{children:e.cached===!0?i.cachedRoute:i.route}),(0,Z.jsx)(`ol`,{className:`list-inside list-decimal space-y-1`,children:e.attempts.map((e,t)=>(0,Z.jsxs)(`li`,{children:[d(e.provider),e.upstream?` · ${d(e.upstream)}`:``,` · `,i.outcomes[e.outcome]??i.unknown,e.reason?` · ${i.reasons[e.reason]??i.unknown}`:``]},t))})]}):null]}):null]}):null]}),t[0]=n,t[1]=a,t[2]=i.attempts,t[3]=i.cacheHint,t[4]=i.cacheUnknown,t[5]=i.cached,t[6]=i.cachedRoute,t[7]=i.capturedAt,t[8]=i.fresh,t[9]=i.incompleteRoute,t[10]=i.outcomes,t[11]=i.provider,t[12]=i.reasons,t[13]=i.route,t[14]=i.unknown,t[15]=i.upstreamUnknown,t[16]=o,t[17]=s,t[18]=r,t[19]=l}else l=t[19];return l}function Mg(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 Ng(e){let t=(0,X.c)(8),{extensionId:n,extensionName:r,entrypoint:i,title:a,toolResult:o,maxHeight:s,interactive:c,permissions:l}=e,u=s===void 0?400:s,d;return t[0]!==i||t[1]!==n||t[2]!==r||t[3]!==u||t[4]!==l||t[5]!==a||t[6]!==o?(d=(0,Z.jsx)(`div`,{className:`mt-2 w-full min-w-0 overflow-hidden rounded-xl border border-edge bg-surface-base`,children:(0,Z.jsx)(Ro,{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 Pg(e){let t=ka();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 Fg(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 Ig(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 Lg(e,t,n){let r=new Map,i=0,a=e.toSorted((e,t)=>Number(la(e.name))-Number(la(t.name)));for(let e of a){if(fa(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 Rg({path:e,conversationId:t,label:n}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(),s=Ni(e=>e.setPath),c=async()=>{i(!0),o(void 0);try{let n=await Ua(e,{conversationId:t??void 0});if(!n?.capabilities.includes(`preview`))throw Error(`Output file is unavailable`);s(n.absolutePath??n.workspaceRelativePath??e,void 0,void 0,t)}catch(e){o(e instanceof Error?e.message:String(e))}finally{i(!1)}};return(0,Z.jsxs)(`div`,{className:`mt-2`,children:[(0,Z.jsx)(pi,{variant:`ghost`,disabled:r,onClick:()=>{c()},className:`text-accent`,children:n}),a?(0,Z.jsx)(`p`,{className:`text-xs text-red-600`,children:a}):null]})}function zg(e){return/^Full Codemode output: (\.xopc\/codemode-output\/[a-f0-9-]{36}\.txt)(?:\r?\n|$)/.exec(e)?.[1]}function Bg(e,t=0){return or(e)??(e.type===`tool_use`?e.id:e.type===`text`?e.segmentId??`narration-${t}`:`thinking-${t}`)}var Vg=(0,Q.memo)(function(e){let t=(0,X.c)(15),{active:n,startedAt:r,frozenMs:i,language:a,className:o}=e,[,s]=(0,Q.useState)(0),c;t[0]!==n||t[1]!==s?(c=()=>{if(!n)return;let e=window.setInterval(()=>s(h_),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?Mg(u,a):i==null?null:Mg(i,a),t[5]=n,t[6]=u,t[7]=i,t[8]=a,t[9]=r,t[10]=d):d=t[10];let f=d;if(!f)return null;let p=n||void 0,m;return t[11]!==o||t[12]!==p||t[13]!==f?(m=(0,Z.jsx)(`span`,{className:o,"aria-hidden":p,children:f}),t[11]=o,t[12]=p,t[13]=f,t[14]=m):m=t[14],m});function Hg(e){let t=(0,X.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,g=l===void 0||l,_=u!==void 0&&u,v=d!==void 0&&d,b=f!==void 0&&f,x=p!==void 0&&p,S=m===void 0||m,C=h(n_),[w,T]=(0,Q.useState)(!1),E,D;t[0]===r?(E=t[1],D=t[2]):(E=()=>{if(T(!1),r!==`waiting`)return;let e=window.setTimeout(()=>T(!0),3e3);return()=>window.clearTimeout(e)},D=[r],t[0]=r,t[1]=E,t[2]=D),(0,Q.useEffect)(E,D);let O;t[3]===C?O=t[4]:(O=y(C),t[3]=C,t[4]=O);let k=O.chat,A=Lo(t_),j;if(t[5]!==A||t[6]!==b||t[7]!==n.items){let e;t[9]!==A||t[10]!==b?(e=e=>e.type!==`thinking`||A||b,t[9]=A,t[10]=b,t[11]=e):e=t[11],j=n.items.filter(e),t[5]=A,t[6]=b,t[7]=n.items,t[8]=j}else j=t[8];let M=j,N;t[12]===n.items?N=t[13]:(N=n.items.filter(e_),t[12]=n.items,t[13]=N);let P=N,F=M.length,I=n.active,L=n.expandedByDefault&&I,[R,z]=(0,Q.useState)(null),B=R?.active===I?R.value:null,V=L,[H,U]=(0,Q.useState)(!1),W=(0,Q.useRef)(null),[G,te]=(0,Q.useState)(!1),[ne,re]=(0,Q.useState)(!1),ie,ae;t[14]!==I||t[15]!==G?(ie=()=>{if(!I&&!G)return;let e=()=>{let e=window.getSelection();te(!!(e&&!e.isCollapsed&&W.current?.contains(e.anchorNode)))};return document.addEventListener(`selectionchange`,e),()=>document.removeEventListener(`selectionchange`,e)},ae=[I,G],t[14]=I,t[15]=G,t[16]=ie,t[17]=ae):(ie=t[16],ae=t[17]),(0,Q.useEffect)(ie,ae);let oe=!n.compact&&M.length>0&&(B??(V||G)),se,ce;t[18]===oe?(se=t[19],ce=t[20]):(se=()=>{let e=W.current;if(!oe||!e)return;let t=t=>qh(t,e);return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},ce=[oe],t[18]=oe,t[19]=se,t[20]=ce),(0,Q.useEffect)(se,ce);let le,ue;t[21]!==oe||t[22]!==ne?(le=()=>{if(oe){re(!0);return}if(!ne)return;let e=window.setTimeout(()=>re(!1),200);return()=>window.clearTimeout(e)},ue=[oe,ne],t[21]=oe,t[22]=ne,t[23]=le,t[24]=ue):(le=t[23],ue=t[24]),(0,Q.useEffect)(le,ue);let K;t[25]===M?K=t[26]:(K=M.every($g),t[25]=M,t[26]=K);let q=K,de,fe,pe,J,me,he,ge,_e,ve,ye,be;if(t[27]!==P||t[28]!==I||t[29]!==s||t[30]!==k||t[31]!==o||t[32]!==c||t[33]!==oe||t[34]!==C||t[35]!==r||t[36]!==_||t[37]!==S||t[38]!==H||t[39]!==A||t[40]!==b||t[41]!==g||t[42]!==q||t[43]!==a||t[44]!==x||t[45]!==i||t[46]!==M||t[47]!==w||t[48]!==n.durationMs||t[49]!==n.items||t[50]!==n.startedAt){ve=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Ig(M);me=q&&I&&!H&&!A?Math.max(0,e.length-3):0,ye=e.slice(me).flatMap(Qg),J=n.startedAt??null,fe=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)=>pa(e,t,a.toolActivity,u,o.ing),t[75]=o.ing,t[76]=u,t[77]=a.toolActivity,t[78]=d):d=t[78],he=d;let f=P.filter(Zg),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]===he?e=t[83]:(e=e=>he(e,`running`),t[82]=he,t[83]=e);let n;t[84]!==P||t[85]!==o.ing||t[86]!==e?(n=Rh(P,o.ing,e),t[84]=P,t[85]=o.ing,t[86]=e,t[87]=n):n=t[87],m=n}let h=m,v=r===`sending`?k.sendingLabel:r===`waiting`?w?k.waitingLongLabel:k.waitingLabel:null,y;t[88]!==P||t[89]!==k.thinkingLabel||t[90]!==a.workLogRunning?(y=P.some(Xg)?k.thinkingLabel:a.workLogRunning,t[88]=P,t[89]=k.thinkingLabel,t[90]=a.workLogRunning,t[91]=y):y=t[91];let T=y;ge=r??(P.some(Yg)?`tool`:P.some(Jg)?`thinking`:P.length>0?`organizing`:`working`),de=h??v??T;let E;if(t[92]!==P||t[93]!==k.activityFailed||t[94]!==k.activityMore||t[95]!==k.activityRepeated||t[96]!==C||t[97]!==he||t[98]!==b||t[99]!==a.thoughts){let e=P.filter(qg);E=b&&e.length>0?Lg(e,e=>he(e,`completed`),{repeated:k.activityRepeated,more:k.activityMore,failed:k.activityFailed,separator:C===`zh`?`、`:`, `}):b?a.thoughts:null,t[92]=P,t[93]=k.activityFailed,t[94]=k.activityMore,t[95]=k.activityRepeated,t[96]=C,t[97]=he,t[98]=b,t[99]=a.thoughts,t[100]=E}else E=t[100];if(pe=E,n.items.length===0&&!I){ve=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,_||x){let e;t[122]!==I||t[123]!==s||t[124]!==c||t[125]!==S||t[126]!==be||t[127]!==i||t[128]!==n.items?(e=S&&n.items.filter(Kg).map(e=>(0,Z.jsx)(f_,{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]=S,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,Z.jsx)(Z.Fragment,{children:e}),t[130]=e,t[131]=r),ve=r;break bb0}_e=oe&&(!g||A)&&p===1&&ye.includes(f[0])}t[27]=P,t[28]=I,t[29]=s,t[30]=k,t[31]=o,t[32]=c,t[33]=oe,t[34]=C,t[35]=r,t[36]=_,t[37]=S,t[38]=H,t[39]=A,t[40]=b,t[41]=g,t[42]=q,t[43]=a,t[44]=x,t[45]=i,t[46]=M,t[47]=w,t[48]=n.durationMs,t[49]=n.items,t[50]=n.startedAt,t[51]=de,t[52]=fe,t[53]=pe,t[54]=J,t[55]=me,t[56]=he,t[57]=ge,t[58]=_e,t[59]=ve,t[60]=ye,t[61]=be}else de=t[51],fe=t[52],pe=t[53],J=t[54],me=t[55],he=t[56],ge=t[57],_e=t[58],ve=t[59],ye=t[60],be=t[61];if(ve!==Symbol.for(`react.early_return_sentinel`))return ve;let xe=_e,Se;t[132]!==de||t[133]!==I||t[134]!==fe||t[135]!==pe||t[136]!==J||t[137]!==C||t[138]!==xe||t[139]!==ge||t[140]!==a.workLogComplete||t[141]!==a.workLogFailed||t[142]!==a.workLogPartial||t[143]!==a.workLogTitle||t[144]!==n.status?(Se=I?(0,Z.jsxs)(Z.Fragment,{children:[xe?(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:a.workLogTitle}):null,(0,Z.jsx)(`span`,{className:xe?`sr-only`:`block min-w-0 flex-1 truncate whitespace-nowrap`,"data-status-phase":ge,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:(0,Z.jsx)(`span`,{className:`assistant-activity-shimmer inline-block max-w-full truncate align-bottom`,children:de})}),(0,Z.jsx)(Vg,{active:I,startedAt:J,frozenMs:null,language:C,className:`ml-1.5 w-[8ch] shrink-0 whitespace-nowrap text-right tabular-nums text-fg-muted`})]}):(0,Z.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:pe??(n.status===`failed`?a.workLogFailed:n.status===`partial`?a.workLogPartial:fe==null?a.workLogTitle:a.workLogComplete)}),t[132]=de,t[133]=I,t[134]=fe,t[135]=pe,t[136]=J,t[137]=C,t[138]=xe,t[139]=ge,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]!==fe||t[148]!==J||t[149]!==C?(we=I?null:(0,Z.jsx)(Vg,{active:!1,startedAt:J,frozenMs:fe,language:C,className:`mt-0.5 tabular-nums text-xs text-fg-muted`}),t[146]=I,t[147]=fe,t[148]=J,t[149]=C,t[150]=we):we=t[150];let Te=we,Ee=!n.compact&&F>0;if(g&&!A){let e;t[151]!==v||t[152]!==I||t[153]!==n.items?(e=!I&&!v&&n.items.some(Gg),t[151]=v,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]!==de||t[156]!==v||t[157]!==I||t[158]!==s||t[159]!==c||t[160]!==o||t[161]!==S||t[162]!==he||t[163]!==be||t[164]!==i||t[165]!==n.items||t[166]!==n.status){let e=I&&!v||o?Fg(n.items,e=>{if(fa(e)||la(e.name)||!ua(e.name)&&Nh(e.name,e.activity)===`other`)return null;let t=he(e,I&&(e.status===`running`||e.activity?.status===`running`)?`running`:`completed`);return I&&t===de?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]!==S||t[176]!==be||t[177]!==i||t[178]!==n.items?(f=S&&n.items.filter(Wg).map(e=>(0,Z.jsx)(f_,{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]=S,t[176]=be,t[177]=i,t[178]=n.items,t[179]=f):f=t[179],p=e.length>0?(0,Z.jsx)(`div`,{"data-assistant-activity-flow":!0,className:`space-y-2.5 text-sm leading-relaxed text-fg-muted`,children:e.map((e,t)=>(0,Z.jsx)(f_,{block:e,toolLabels:i,stepLabels:be,cardLabels:s,conversationId:c,runActive:I},Bg(e,t)))}):null,t[155]=de,t[156]=v,t[157]=I,t[158]=s,t[159]=c,t[160]=o,t[161]=S,t[162]=he,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,Z.jsxs)(`div`,{className:`mt-2 flex h-11 w-full min-w-0 items-center gap-2 px-1 text-sm text-fg-muted`,"data-assistant-running":!0,children:[(0,Z.jsx)(Rt,{className:`assistant-activity-busy size-4 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`div`,{className:`flex h-6 min-w-0 flex-1 items-center`,children:Ce})]}):o?(0,Z.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,Z.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||oe?`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]!==oe||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,Z.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:!oe}):void 0,"aria-expanded":Ee?oe:void 0,children:[(0,Z.jsx)(Rt,{className:Y(`size-4 shrink-0`,I&&`assistant-activity-busy`),"aria-hidden":!0}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:(0,Z.jsx)(`span`,{className:Y(`flex w-full min-w-0 items-center`,I?`h-6`:`min-h-6`),children:Ce})}),(0,Z.jsx)(`span`,{className:`flex shrink-0 items-start justify-end`,children:Te}),Ee?(0,Z.jsx)(ee,{className:Y(`size-4 shrink-0 text-fg-muted transition-transform motion-reduce:transition-none`,oe&&`rotate-180`),"aria-hidden":!0}):null]}):null,t[197]=I,t[198]=oe,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]!==S||t[209]!==be||t[210]!==i||t[211]!==n.items?(je=S&&n.items.filter(Ug).map(e=>(0,Z.jsx)(f_,{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]=S,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]!==oe||t[218]!==ne||t[219]!==me||t[220]!==H||t[221]!==b||t[222]!==ye||t[223]!==be||t[224]!==i?(Me=oe||ne?(0,Z.jsx)(`div`,{className:`assistant-activity-disclosure`,"data-open":oe,"aria-hidden":!oe,inert:!oe,children:(0,Z.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:(0,Z.jsxs)(`div`,{ref:W,className:`assistant-activity-flow mt-1 max-h-[min(32rem,50dvh)] w-full min-w-0 overflow-x-hidden overflow-y-auto pb-1 pl-1 pr-2 [scrollbar-gutter:stable]`,"data-assistant-activity-flow":!0,onFocusCapture:()=>z({active:I,value:!0}),children:[me>0?(0,Z.jsx)(`button`,{type:`button`,className:`mb-3 text-xs text-fg-muted hover:text-fg`,onClick:()=>U(!0),children:k.activityEarlier}):null,(0,Z.jsx)(r_,{blocks:ye,toolLabels:i,stepLabels:be,cardLabels:s,conversationId:c,animateNew:I&&oe&&!H,runActive:I,showThinking:b})]})})}):null,t[213]=I,t[214]=s,t[215]=k.activityEarlier,t[216]=c,t[217]=oe,t[218]=ne,t[219]=me,t[220]=H,t[221]=b,t[222]=ye,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,Z.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 Ug(e){return e.type===`tool_use`}function Wg(e){return e.type===`tool_use`}function Gg(e){return e.type===`tool_use`&&fa(e)}function Kg(e){return e.type===`tool_use`}function qg(e){return e.type===`tool_use`}function Jg(e){return e.type===`thinking`&&e.streaming}function Yg(e){return e.type===`tool_use`&&e.status===`running`}function Xg(e){return e.type===`thinking`&&e.streaming}function Zg(e){return e.type===`tool_use`&&(e.status===`running`||e.activity?.status===`running`)}function Qg(e){return e.type===`tools`?e.tools:[e.item]}function $g(e){return or(e)||e.type===`tool_use`||e.type===`text`&&e.segmentId}function e_(e){return e.type!==`text`}function t_(e){return e.showRawToolData}function n_(e){return e.language}function r_({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(Bg))),u=Lo(e=>e.showRawToolData),d=h(e=>e.language),f=u?e.map(e=>({type:`item`,item:e})):Ig(e);return e.length>0?(0,Z.jsx)(`div`,{className:Y(`min-w-0 overflow-x-hidden`,i),children:(0,Z.jsx)(`div`,{className:`min-w-0 space-y-2.5 pl-1`,children:f.map((e,i)=>{let f=e.type===`tools`?e.tools[0]:e.item,p=Bg(f,i);return(0,Z.jsx)(`div`,{className:Y(o&&!l.current.has(p)&&f.type!==`text`&&`assistant-activity-enter`),children:e.type===`tools`?(0,Z.jsx)(i_,{tools:e.tools,runActive:s,labels:n,language:d,renderTool:e=>(0,Z.jsx)(f_,{block:e,toolLabels:t,stepLabels:n,cardLabels:r,conversationId:a,runActive:s},e.id)}):e.item.type===`thinking`&&c&&!u?(0,Z.jsx)(`div`,{"data-assistant-thinking":!0,className:`text-sm leading-relaxed text-fg-muted`,children:(0,Z.jsx)(cf,{content:e.item.text,compact:!0,streaming:!!(s&&e.item.streaming)})}):(0,Z.jsx)(f_,{block:e.item,toolLabels:t,stepLabels:n,cardLabels:r,conversationId:a,runActive:s})},p)})})}):null}function i_(e){let t=(0,X.c)(35),{tools:n,runActive:r,labels:i,language:a,renderTool:o}=e,s;t[0]!==r||t[1]!==n?(s=r&&n.some(o_),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=y(a).chat,s=c?[...n].reverse().find(a_):void 0,_=n.filter(e=>e!==s),v;t[17]!==i||t[18]!==r?(v=e=>pa(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 b=Lg(_,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,Z.jsx)(`summary`,{className:`cursor-pointer rounded-md py-1 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,Z.jsx)(`span`,{children:b})}),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,Z.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,Z.jsxs)(`details`,{className:d,children:[f,_]}),t[26]=_,t[27]=d,t[28]=f,t[29]=v):v=t[29];let b;return t[30]!==v||t[31]!==p||t[32]!==m||t[33]!==h?(b=(0,Z.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]=b):b=t[34],b}function a_(e){return e.status===`running`||e.activity?.status===`running`}function o_(e){return e.status===`running`||e.activity?.status===`running`}function s_(e){let t=(0,X.c)(15),{toolName:n,toolResult:r}=e,i=ka(),a=Pg(n);if(!a||i.length===0)return null;let o;if(t[0]!==i||t[1]!==a.extensionId){let e;t[3]===a.extensionId?e=t[4]:(e=e=>e.id===a.extensionId,t[3]=a.extensionId,t[4]=e),o=i.find(e),t[0]=i,t[1]=a.extensionId,t[2]=o}else o=t[2];let s=o,c=s?.name??a.extensionId,l=a.maxHeight??400,u=a.interactive??!1,d=s?.ui?.permissions,f;return t[5]!==c||t[6]!==l||t[7]!==u||t[8]!==d||t[9]!==r||t[10]!==a.entrypoint||t[11]!==a.extensionId||t[12]!==a.id||t[13]!==a.title?(f=(0,Z.jsx)(Ng,{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 c_=new Set([`readFile`,`editFile`,`writeFile`,`runCommand`,`fetchUrl`]),l_=240;function u_(e){let t=e.split(`
25
- `).map(e=>e.trim()).find(Boolean)??``;return t.length<=l_?t:`${t.slice(0,l_)}…`}function d_(e,t,n){let r=ma(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 u_(t)}return u_(r.text)||t}function f_(e){let t=(0,X.c)(136),{block:n,toolLabels:r,stepLabels:i,cardLabels:a,conversationId:o,surfaceOnly:s,runActive:c}=e,l=s!==void 0&&s,d=c===void 0||c,f;t[0]===n?f=t[1]:(f=or(n),t[0]=n,t[1]=f);let p=Vm(o,f),m=p?.type===n.type?p:n,g=Lo(m_),_=h(p_),v;bb0:{if(m.type!==`tool_use`){v=``;break bb0}if(m.status===`running`){v=``;break bb0}let e=m.result;if(e==null){v=``;break bb0}if(typeof e==`string`){let n;t[2]===e?n=t[3]:(n=e.trim(),t[2]=e,t[3]=n),v=n;break bb0}try{let n;t[4]===e?n=t[5]:(n=JSON.stringify(e,null,2),t[4]=e,t[5]=n),v=n}catch{v=String(e)}}let b=v;if(m.type===`text`){let e;t[6]===m.text?e=t[7]:(e=m.text.trim(),t[6]=m.text,t[7]=e);let n=e;if(!n)return null;let r=m.presentation===`pending`,i;return t[8]!==r||t[9]!==n?(i=(0,Z.jsx)(`div`,{className:`min-w-0 text-sm leading-relaxed text-fg-muted`,children:(0,Z.jsx)(cf,{content:n,compact:!0,streaming:r})}),t[8]=r,t[9]=n,t[10]=i):i=t[10],i}if(m.type===`thinking`){let e=!!m.streaming,n;t[11]===m.text?n=t[12]:(n=m.text?.trim()??``,t[11]=m.text,t[12]=n);let r=n;if(!g||!r)return null;let a=e?i.thoughtsStreaming:i.thoughts,o;t[13]===a?o=t[14]:(o=(0,Z.jsx)(`span`,{className:`inline-flex max-w-full min-w-0 break-words text-[13px] text-fg-muted [overflow-wrap:anywhere]`,children:a}),t[13]=a,t[14]=o);let s;t[15]!==g||t[16]!==i.rawThinking||t[17]!==e||t[18]!==r?(s=g&&r?(0,Z.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer select-none text-fg-subtle underline-offset-2 hover:text-fg-muted`,children:i.rawThinking}),(0,Z.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-xs leading-relaxed text-fg-muted [overflow-wrap:anywhere]`,children:r})]}):e?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`…`}):null,t[15]=g,t[16]=i.rawThinking,t[17]=e,t[18]=r,t[19]=s):s=t[19];let c;return t[20]!==o||t[21]!==s?(c=(0,Z.jsx)(`div`,{className:`min-w-0`,children:(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[o,s]})}),t[20]=o,t[21]=s,t[22]=c):c=t[22],c}let x=d&&(m.status===`running`||m.activity?.status===`running`),S;t[23]!==m||t[24]!==l?(S=l?m.status===`error`||m.activity?.status===`failed`:fa(m),t[23]=m,t[24]=l,t[25]=S):S=t[25];let C=S,w;t[26]!==m||t[27]!==a||t[28]!==C||t[29]!==i.toolError?(w=C?d_(m,i.toolError,a):``,t[26]=m,t[27]=a,t[28]=C,t[29]=i.toolError,t[30]=w):w=t[30];let T=w,E=b,D;t[31]!==m.name||t[32]!==E?(D=m.name===`codemode`?zg(E??``):void 0,t[31]=m.name,t[32]=E,t[33]=D):D=t[33];let O=D,k=x&&m.details&&typeof m.details==`object`&&!Array.isArray(m.details)&&typeof m.details.text==`string`?m.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]!==m||t[37]!==C||t[38]!==x||t[39]!==i.editFile||t[40]!==i.fetchUrl||t[41]!==i.listDirectory||t[42]!==i.memoryActivity||t[43]!==i.openUrl||t[44]!==i.readFile||t[45]!==i.runCommand||t[46]!==i.runningActions||t[47]!==i.searched||t[48]!==i.searchedCode||t[49]!==i.searchedMemory||t[50]!==i.searchedWeb||t[51]!==i.toolActivity||t[52]!==i.toolError||t[53]!==i.unknownTool||t[54]!==i.writeFile){M=Nh(m.name,m.activity),j=c_.has(M),N=M===`memorySearch`?Uh(m,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=pa(m,x||C?`running`:`completed`,i.toolActivity,e,i.runningActions);F=C?M===`other`&&!ua(m.name)?i.toolError:i.toolActivity.stepFailed.replace(`{{operation}}`,n.replace(/^正在|[.…]+$/g,``)):N?.title??n,P=C?Vt:M.includes(`Search`)||M===`search`?Nt:M===`readFile`?H:M===`editFile`||M===`writeFile`?us:M===`fetchUrl`||M===`openUrl`?Ne:J,t[36]=m,t[37]=C,t[38]=x,t[39]=i.editFile,t[40]=i.fetchUrl,t[41]=i.listDirectory,t[42]=i.memoryActivity,t[43]=i.openUrl,t[44]=i.readFile,t[45]=i.runCommand,t[46]=i.runningActions,t[47]=i.searched,t[48]=i.searchedCode,t[49]=i.searchedMemory,t[50]=i.searchedWeb,t[51]=i.toolActivity,t[52]=i.toolError,t[53]=i.unknownTool,t[54]=i.writeFile,t[55]=j,t[56]=M,t[57]=N,t[58]=P,t[59]=F}else j=t[55],M=t[56],N=t[57],P=t[58],F=t[59];let I=P,L;t[60]!==m.input||t[61]!==N?(L=N?``:eg(m.input),t[60]=m.input,t[61]=N,t[62]=L):L=t[62];let R=L,z;t[63]===m.input?z=t[64]:(z=m.input===void 0?``:Jh(m.input),t[63]=m.input,t[64]=z);let B=z,V;t[65]!==m||t[66]!==a||t[67]!==j||t[68]!==M?(V=j?M===`readFile`?(0,Z.jsx)(_g,{block:m,labels:a}):M===`editFile`?(0,Z.jsx)(bg,{block:m,labels:a}):M===`writeFile`?(0,Z.jsx)(Sg,{block:m,labels:a}):M===`runCommand`?(0,Z.jsx)(Tg,{block:m,labels:a}):M===`fetchUrl`?(0,Z.jsx)(Eg,{block:m,labels:a}):null:null,t[65]=m,t[66]=a,t[67]=j,t[68]=M,t[69]=V):V=t[69];let U=V;if(l){let e;t[70]!==m.name||t[71]!==m.result||t[72]!==C||t[73]!==x?(e=!x&&!C?(0,Z.jsx)(s_,{toolName:m.name,toolResult:m.result}):null,t[70]=m.name,t[71]=m.result,t[72]=C,t[73]=x,t[74]=e):e=t[74];let n;return t[75]===e?n=t[76]:(n=(0,Z.jsx)(Z.Fragment,{children:e}),t[75]=e,t[76]=n),n}let W=!x&&g,G=m.parentToolCallId?`ml-4 min-w-0 border-l border-edge pl-3`:`min-w-0`,ee=C?`failed`:x?`running`:`completed`,te=x&&`assistant-activity-busy`,ne;t[77]===te?ne=t[78]:(ne=Y(`mt-0.5 size-4 shrink-0 text-fg-subtle`,te),t[77]=te,t[78]=ne);let re;t[79]!==I||t[80]!==ne?(re=(0,Z.jsx)(I,{className:ne,"aria-hidden":!0}),t[79]=I,t[80]=ne,t[81]=re):re=t[81];let ie;t[82]===F?ie=t[83]:(ie=(0,Z.jsx)(`span`,{className:`inline-flex max-w-full min-w-0 break-words text-[13px] text-fg-muted [overflow-wrap:anywhere]`,children:F}),t[82]=F,t[83]=ie);let ae;t[84]!==ee||t[85]!==re||t[86]!==ie?(ae=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,"data-activity-status":ee,children:[re,ie]}),t[84]=ee,t[85]=re,t[86]=ie,t[87]=ae):ae=t[87];let oe;t[88]!==U||t[89]!==i.stepDetails?(oe=U?(0,Z.jsxs)(`details`,{className:`min-w-0 text-xs text-fg-muted`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer hover:text-fg`,children:i.stepDetails}),U]}):null,t[88]=U,t[89]=i.stepDetails,t[90]=oe):oe=t[90];let se;t[91]!==m||t[92]!==x||t[93]!==M||t[94]!==_||t[95]!==g||t[96]!==i.stepDetails?(se=M===`webSearch`&&!x?(0,Z.jsx)(jg,{block:m,summary:i.stepDetails,labels:y(_).chat.searchDetails,developer:g,language:_}):null,t[91]=m,t[92]=x,t[93]=M,t[94]=_,t[95]=g,t[96]=i.stepDetails,t[97]=se):se=t[97];let ce;t[98]!==N||t[99]!==i.memoryActivity?(ce=N?(0,Z.jsxs)(`div`,{className:`space-y-1 text-xs text-fg-muted`,children:[(0,Z.jsx)(`p`,{children:N.purpose}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1`,children:[(0,Z.jsx)(u,{className:`font-medium text-accent-fg hover:underline`,to:`/user-model`,children:i.memoryActivity.manage}),(0,Z.jsx)(u,{className:`font-medium text-accent-fg hover:underline`,to:`/user-model`,children:i.memoryActivity.privacy})]}),(0,Z.jsxs)(`details`,{children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer select-none text-fg-subtle hover:text-fg-muted`,children:i.memoryActivity.why}),(0,Z.jsx)(`div`,{className:`mt-1.5 rounded-md bg-surface-hover/60 px-2 py-1.5 dark:bg-surface-hover/35`,children:(0,Z.jsx)(`p`,{children:i.memoryActivity.explanation})})]})]}):null,t[98]=N,t[99]=i.memoryActivity,t[100]=ce):ce=t[100];let le;t[101]!==T||t[102]!==g?(le=T&&g?(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:T}):null,t[101]=T,t[102]=g,t[103]=le):le=t[103];let ue;t[104]!==R||t[105]!==j||t[106]!==g?(ue=g&&!j&&R?(0,Z.jsx)(`p`,{className:`min-w-0 break-words text-xs text-fg-muted [overflow-wrap:anywhere]`,children:R}):null,t[104]=R,t[105]=j,t[106]=g,t[107]=ue):ue=t[107];let K;t[108]!==k||t[109]!==g?(K=g&&k?(0,Z.jsx)(`pre`,{className:`max-h-48 min-w-0 overflow-y-auto overflow-x-hidden rounded-md bg-surface-hover/60 p-2 whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-fg-muted [overflow-wrap:anywhere] dark:bg-surface-hover/35`,children:k}):null,t[108]=k,t[109]=g,t[110]=K):K=t[110];let q;t[111]!==o||t[112]!==_||t[113]!==O?(q=O?(0,Z.jsx)(Rg,{path:O,conversationId:o,label:_===`zh`?`查看完整输出`:`View full output`}):null,t[111]=o,t[112]=_,t[113]=O,t[114]=q):q=t[114];let de;t[115]!==a||t[116]!==j||t[117]!==A||t[118]!==B||t[119]!==W||t[120]!==i.stepDetails||t[121]!==r?(de=W?(0,Z.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer select-none text-fg-subtle underline-offset-2 hover:text-fg-muted group-open:text-fg-muted`,children:j?a.rawDetails:i.stepDetails}),(0,Z.jsxs)(`div`,{className:`mt-2 max-h-48 w-full min-w-0 max-w-full overflow-y-auto overflow-x-hidden rounded-md bg-surface-hover/60 p-2 font-mono dark:bg-surface-hover/35`,children:[B?(0,Z.jsxs)(`div`,{className:`mb-2 min-w-0`,children:[(0,Z.jsx)(`div`,{className:`mb-0.5 text-[10px] uppercase tracking-wide text-fg-disabled`,children:r.input}),(0,Z.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-fg-muted [overflow-wrap:anywhere]`,children:B})]}):null,(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`mb-0.5 text-[10px] uppercase tracking-wide text-fg-disabled`,children:r.output}),(0,Z.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-fg-muted [overflow-wrap:anywhere]`,children:A||r.noOutput})]})]})]}):null,t[115]=a,t[116]=j,t[117]=A,t[118]=B,t[119]=W,t[120]=i.stepDetails,t[121]=r,t[122]=de):de=t[122];let fe;t[123]!==ae||t[124]!==oe||t[125]!==se||t[126]!==ce||t[127]!==le||t[128]!==ue||t[129]!==K||t[130]!==q||t[131]!==de?(fe=(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-1.5`,children:[ae,oe,se,ce,le,ue,K,q,de]}),t[123]=ae,t[124]=oe,t[125]=se,t[126]=ce,t[127]=le,t[128]=ue,t[129]=K,t[130]=q,t[131]=de,t[132]=fe):fe=t[132];let pe;return t[133]!==G||t[134]!==fe?(pe=(0,Z.jsx)(`div`,{className:G,children:fe}),t[133]=G,t[134]=fe,t[135]=pe):pe=t[135],pe}function p_(e){return e.language}function m_(e){return e.showRawToolData}function h_(e){return e+1}function g_(e){let t=(0,X.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(Ga,{delayDuration:300,skipDelayDuration:100,children:n}),t[0]=n,t[1]=r),r}function __(e){let t=(0,X.c)(7),{label:n,children:r}=e,i;t[0]===r?i=t[1]:(i=(0,Z.jsx)(Ya,{asChild:!0,children:r}),t[0]=r,t[1]=i);let a;t[2]===n?a=t[3]:(a=(0,Z.jsx)(Ka,{children:(0,Z.jsx)(Ja,{side:`top`,sideOffset:7,collisionPadding:12,className:`z-[100] max-w-[min(18rem,90vw)] rounded-md border border-edge bg-surface-overlay px-2.5 py-1.5 text-xs text-fg shadow-popover`,children:n})}),t[2]=n,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Z.jsxs)(qa,{children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function v_(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 y_(e){return e.filter(e=>e.type===`thinking`||e.type===`tool_use`)}function b_(e){let t=Nr(e,`running`);return t.category===`web`&&t.action===`search`}function x_(e){let t=[];for(let n of e)if(!(!b_(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 S_(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function C_(e){let t=S_(e);return t?w_(an(t.delivery)??an(S_(t.details)?.delivery)??an(e),t):null}function w_(e,t){let n=e?.primary;if(!e||n?.kind!==`automation`||n.runId||e.operation!==`started`)return e;let r=S_(t),i=S_((S_(r?.result)??r)?.run);return i?.automationId!==n.id||typeof i.id!=`string`||!i.id?e:{...e,primary:{...n,runId:i.id}}}function T_(e){let t=C_(e.details);if(t)return t;let n=ma(e.result),r=C_(n.details);if(r)return r;let i=tn(n.text);if(i)try{return w_(i,JSON.parse(n.text.split(`
26
- Open in xopc:`)[0]))}catch{return i}if(typeof e.result==`string`)try{return C_(JSON.parse(e.result))}catch{return null}return C_(e.result)}function E_(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 D_(e){return e.normalize(`NFKC`).trim().replace(/\s+/g,` `).toLowerCase()}function O_(e){return e.operation!==`opened`||e.presentation?.kind===`diff`||e.presentation?.kind===`inline_app`||e.presentation?.kind===`inline_preview`}function k_(e){return e.flatMap(({key:e,delivery:t})=>t.presentation?.kind===`diff`?[{key:e,presentation:t.presentation}]:[])}function A_(e){return{truncated:e.flatMap(({delivery:e})=>e.presentation?.kind===`table`?[e.presentation]:[]).some(e=>e.truncated)}}function j_(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 M_(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 N_(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=D_(e.reference.title);t&&i.set(t,e.reference.id)}return r.filter(e=>{if(e.reference.kind!==`task`)return!0;let t=D_(e.reference.title);return!t||i.get(t)===e.reference.id})}function P_(e){return O_(e)?e.presentation||e.related?.length?!0:e.primary?e.primary.kind!==`note`||e.operation===`created`||e.operation===`updated`:!1:!1}function F_({message:e,isStreaming:t,reasoningLevel:n}){let r=In(e.content??[],{includePending:!0}),i=new Set(r),a=Lh(y_(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=T_(e);t&&P_(t)&&u.set(e.id,t)}let d=[...u].map(([e,t])=>({key:e,delivery:t})),f=v_(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=[...Tm(_),...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:x_(c)}}function I_(e){let t=(0,X.c)(10),{blocks:n,sources:r,className:i}=e,a=n===void 0?[]:n,o=i===void 0?`mt-6`:i,s=y(h(z_)),c=a.filter(R_),l=r??x_(c);if(l.length===0)return null;let u=s.chat.searchSourcesHeading.replace(`{{count}}`,String(l.length)),d;t[0]===u?d=t[1]:(d=(0,Z.jsx)(`p`,{className:`mb-3 text-xs font-medium text-fg-muted`,children:u}),t[0]=u,t[1]=d);let f;t[2]===l?f=t[3]:(f=l.map(L_),t[2]=l,t[3]=f);let p;t[4]===f?p=t[5]:(p=(0,Z.jsx)(`ol`,{className:`space-y-3`,children:f}),t[4]=f,t[5]=p);let m;return t[6]!==o||t[7]!==d||t[8]!==p?(m=(0,Z.jsxs)(`div`,{className:o,children:[d,p]}),t[6]=o,t[7]=d,t[8]=p,t[9]=m):m=t[9],m}function L_(e,t){let n=(()=>{try{return new URL(e.url).hostname}catch{return``}})(),r=n?`https://www.google.com/s2/favicons?domain=${n}&sz=16`:void 0;return(0,Z.jsxs)(`li`,{className:`flex min-w-0 gap-2.5`,children:[(0,Z.jsxs)(`span`,{className:`mt-0.5 shrink-0 text-xs text-fg-disabled`,children:[t+1,`.`]}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-1.5`,children:[r?(0,Z.jsx)(`img`,{src:r,alt:``,className:`mt-0.5 size-3.5 shrink-0 rounded-sm`,"aria-hidden":!0}):null,(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`min-w-0 flex-1 break-words text-xs font-medium text-accent-fg [overflow-wrap:anywhere] hover:underline`,children:e.title})]}),e.snippet?(0,Z.jsx)(`p`,{className:`mt-0.5 line-clamp-4 text-xs break-words text-fg-muted [overflow-wrap:anywhere]`,children:e.snippet}):null]})]},e.url)}function R_(e){return e.type===`tool_use`}function z_(e){return e.language}var B_=(0,Q.createContext)(!1);function V_(e){let t=(0,X.c)(41),{entries:n,language:r,renderEntry:i}=e,[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null),l=(0,Q.useRef)(null),u=(0,Q.useRef)(0),d=(0,Q.useRef)(!1),f=c(),p;t[0]===f.search?p=t[1]:(p=new URLSearchParams(f.search).has(Ye),t[0]=f.search,t[1]=p);let m=p,h,g;t[2]!==n.length||t[3]!==r?(h=y(r).chat.productDelivery,g=h.relatedTaskCount.replace(`{{count}}`,String(n.length)),t[2]=n.length,t[3]=r,t[4]=h,t[5]=g):(h=t[4],g=t[5]);let _=g,v=a&&!m,O;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(O=e=>{d.current=!e,o(e)},t[6]=O):O=t[6];let k;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,Z.jsx)(ws,{}),t[7]=k):k=t[7];let A;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(te,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[8]=A):A=t[8];let j;t[9]===_?j=t[10]:(j=(0,Z.jsx)(x,{asChild:!0,children:(0,Z.jsx)(`button`,{ref:s,type:`button`,className:Mo,children:(0,Z.jsx)(Po,{icon:k,title:_,trailing:A})})}),t[9]=_,t[10]=j);let M;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Z.jsx)(b,{className:`fixed inset-0 z-[80] bg-scrim`}),t[11]=M):M=t[11];let N,P;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(P=e=>{e.preventDefault(),l.current?.focus({preventScroll:!0})},N=e=>{e.preventDefault(),d.current&&s.current?.focus({preventScroll:!0})},t[12]=N,t[13]=P):(N=t[12],P=t[13]);let F;t[14]===_?F=t[15]:(F=(0,Z.jsx)(E,{ref:l,tabIndex:-1,className:`min-w-0 flex-1 font-medium text-fg focus:outline-none`,children:_}),t[14]=_,t[15]=F);let I;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(Gt,{className:`size-4`,"aria-hidden":!0}),t[16]=I):I=t[16];let L;t[17]===h.closeTaskList?L=t[18]:(L=(0,Z.jsx)(C,{"aria-label":h.closeTaskList,className:`flex size-11 shrink-0 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:I}),t[17]=h.closeTaskList,t[18]=L);let R;t[19]!==F||t[20]!==L?(R=(0,Z.jsxs)(`header`,{className:`flex shrink-0 items-center gap-3 border-b border-edge px-4 py-3`,children:[F,L]}),t[19]=F,t[20]=L,t[21]=R):R=t[21];let z;t[22]===h.relatedTasksDescription?z=t[23]:(z=(0,Z.jsx)(S,{className:`sr-only`,children:h.relatedTasksDescription}),t[22]=h.relatedTasksDescription,t[23]=z);let B,V;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(B=e=>{e&&(e.scrollTop=u.current)},V=e=>{u.current=e.currentTarget.scrollTop},t[24]=B,t[25]=V):(B=t[24],V=t[25]);let H;if(t[26]!==n||t[27]!==i){let e;t[29]===i?e=t[30]:(e=e=>i(e,!0),t[29]=i,t[30]=e),H=n.map(e),t[26]=n,t[27]=i,t[28]=H}else H=t[28];let U;t[31]===H?U=t[32]:(U=(0,Z.jsx)(`div`,{"data-task-delivery-list":!0,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,ref:B,onScroll:V,children:(0,Z.jsx)(`ul`,{className:`${No} p-3`,children:H})}),t[31]=H,t[32]=U);let W;t[33]!==R||t[34]!==z||t[35]!==U?(W=(0,Z.jsxs)(w,{children:[M,(0,Z.jsxs)(T,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(40rem,calc(100dvh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay focus:outline-none`,onOpenAutoFocus:P,onCloseAutoFocus:N,children:[R,z,U]})]}),t[33]=R,t[34]=z,t[35]=U,t[36]=W):W=t[36];let G;return t[37]!==W||t[38]!==v||t[39]!==j?(G=(0,Z.jsx)(`li`,{className:`min-w-0 max-w-full`,"data-product-task-group":!0,children:(0,Z.jsxs)(D,{open:v,onOpenChange:O,children:[j,W]})}),t[37]=W,t[38]=v,t[39]=j,t[40]=G):G=t[40],G}var H_={task:ws,project:Ee,note:xs,automation:W,local_app:k,chat_preview:gs,file:Te,session:bs,settings:Ft};function U_(e,t){let n=e?.trim();return n?y(t).chat.productDelivery.statuses[n.toLowerCase()]??n:null}function W_(e,t,n){let r=y(n).chat.productDelivery.operations[e.operation],i=U_(t.status,n);return i&&e.operation===`opened`?i:i&&i.toLowerCase()!==r.toLowerCase()?`${r} · ${i}`:i??r}function G_(e,t,n){let r=y(n).chat.productDelivery.taskStates;if(t.phase===`closed`)return t.resolution===`done`?r.completed:r.closed;if(t.attention?.length)return r.blocked;let i={allocating:r.allocating,queued:r.queued,running:r.running,verifying:r.verifying,waiting:r.waiting,blocked:r.blocked,completed:r.completed};return t.operationalState&&i[t.operationalState]||(e.operation===`completed`?r.completed:e.operation===`failed`?r.failed:e.operation===`started`?r.assigned:r.ready)}function K_(e,t){let n=y(t).chat.productDelivery;return n.continuePrompt.replace(/\{\{(kind|title|id)\}\}/g,(r,i)=>({kind:t===`en`?n.kinds[e.kind].toLowerCase():n.kinds[e.kind],title:e.title,id:e.id})[i])}function q_(e){let t=(0,X.c)(90),{delivery:n,reference:r,language:i,conversationId:a,projectId:o,fullTitle:s}=e,l=s!==void 0&&s,u=d(),f=c(),p=Ni(Y_),h=H_[r.kind],g;t[0]===r?g=t[1]:(g=en(r),t[0]=r,t[1]=g);let _=g,v;t[2]!==r.capabilities||t[3]!==r.id||t[4]!==r.kind?(v=r.kind===`file`&&r.capabilities.includes(`preview`)?E_(r.id):null,t[2]=r.capabilities,t[3]=r.id,t[4]=r.kind,t[5]=v):v=t[5];let b=v,x;t[6]!==a||t[7]!==b||t[8]!==o?(x=b&&(a?.trim()||o?.trim()),t[6]=a,t[7]=b,t[8]=o,t[9]=x):x=t[9];let S=!!x,C;t[10]!==S||t[11]!==r.capabilities||t[12]!==_?(C=S||!!(_&&r.capabilities.includes(`open`)),t[10]=S,t[11]=r.capabilities,t[12]=_,t[13]=C):C=t[13];let w=C,T;t[14]!==r.capabilities||t[15]!==r.kind?(T=r.kind!==`note`&&r.kind!==`task`&&r.capabilities.includes(`continue_in_chat`),t[14]=r.capabilities,t[15]=r.kind,t[16]=T):T=t[16];let E=T,D=n.operation===`failed`,O=m(J_),k;t[17]!==r.id||t[18]!==r.kind||t[19]!==O?(k=r.kind===`task`?[`task-delivery`,r.id,O]:null,t[17]=r.id,t[18]=r.kind,t[19]=O,t[20]=k):k=t[20];let A;t[21]===r.id?A=t[22]:(A=()=>ei(r.id),t[21]=r.id,t[22]=A);let j;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(j={revalidateOnFocus:!0},t[23]=j):j=t[23];let M=Gr(k,A,j),N;t[24]!==r.id||t[25]!==r.kind||t[26]!==M?(N=()=>{if(r.kind!==`task`)return;let e=e=>{let t=e.detail?.taskId;(!t||t===r.id)&&M.mutate()};return window.addEventListener(`task-changed-v2`,e),window.addEventListener(`gateway-realtime-connected`,e),()=>{window.removeEventListener(`task-changed-v2`,e),window.removeEventListener(`gateway-realtime-connected`,e)}},t[24]=r.id,t[25]=r.kind,t[26]=M,t[27]=N):N=t[27];let P;t[28]!==r.id||t[29]!==r.kind||t[30]!==M.mutate?(P=[r.kind,r.id,M.mutate],t[28]=r.id,t[29]=r.kind,t[30]=M.mutate,t[31]=P):P=t[31],(0,Q.useEffect)(N,P);let F;t[32]!==n||t[33]!==i||t[34]!==r||t[35]!==M.data?.attention||t[36]!==M.data?.operationalState||t[37]!==M.data?.task?(F=r.kind===`task`?G_(n,{phase:M.data?.task.phase,resolution:M.data?.task.resolution,operationalState:M.data?.operationalState??r.status,attention:M.data?.attention},i):W_(n,r,i),t[32]=n,t[33]=i,t[34]=r,t[35]=M.data?.attention,t[36]=M.data?.operationalState,t[37]=M.data?.task,t[38]=F):F=t[38];let I=F;if(r.kind===`automation`&&n.operation!==`failed`){let e;return t[39]!==i||t[40]!==r.id||t[41]!==r.runId?(e=(0,Z.jsx)(`li`,{className:`min-w-0 max-w-full`,children:(0,Z.jsx)(Fo,{automationId:r.id,runId:r.runId,language:i,embedded:!0})}),t[39]=i,t[40]=r.id,t[41]=r.runId,t[42]=e):e=t[42],e}let L;t[43]!==S||t[44]!==a||t[45]!==b||t[46]!==f||t[47]!==u||t[48]!==o||t[49]!==r.id||t[50]!==r.kind||t[51]!==r.projectId||t[52]!==r.revision||t[53]!==_||t[54]!==p?(L=()=>{if(b&&S){p(b,null,o,a);return}if(r.kind===`task`){u(et(`${f.pathname}${f.search}`,r.id));return}if(r.kind===`note`){u(tt(`${f.pathname}${f.search}`,r.id));return}if(_){let e=new URL(_,`https://xopc.local`);r.projectId&&e.searchParams.set(`projectId`,r.projectId),r.kind===`local_app`&&r.revision&&/^[a-f0-9]{64}$/.test(r.revision)&&e.searchParams.set(`sourceHash`,r.revision),u(Xe(Qe(`${f.pathname}${f.search}`,`${e.pathname}${e.search}`),`${f.pathname}${f.search}`))}},t[43]=S,t[44]=a,t[45]=b,t[46]=f,t[47]=u,t[48]=o,t[49]=r.id,t[50]=r.kind,t[51]=r.projectId,t[52]=r.revision,t[53]=_,t[54]=p,t[55]=L):L=t[55];let R=L,z=r.kind,B=w?R:void 0,V=!w,H;t[56]===r.summary?H=t[57]:(H=r.summary?.trim(),t[56]=r.summary,t[57]=H);let U;t[58]!==I||t[59]!==r.title||t[60]!==H?(U=[r.title,I,H].filter(Boolean),t[58]=I,t[59]=r.title,t[60]=H,t[61]=U):U=t[61];let W=U.join(` · `),G=w?`cursor-pointer`:`cursor-default`,ee=D&&`text-danger`,ne;t[62]!==G||t[63]!==ee?(ne=Y(Mo,G,ee),t[62]=G,t[63]=ee,t[64]=ne):ne=t[64];let re=D?`text-danger`:void 0,ie;t[65]!==h||t[66]!==re?(ie=(0,Z.jsx)(h,{strokeWidth:1.75,className:re}),t[65]=h,t[66]=re,t[67]=ie):ie=t[67];let ae;t[68]===w?ae=t[69]:(ae=w?(0,Z.jsx)(te,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}):null,t[68]=w,t[69]=ae);let oe;t[70]!==I||t[71]!==l||t[72]!==r.title||t[73]!==ie||t[74]!==ae?(oe=(0,Z.jsx)(Po,{icon:ie,title:r.title,meta:I,fullTitle:l,trailing:ae}),t[70]=I,t[71]=l,t[72]=r.title,t[73]=ie,t[74]=ae,t[75]=oe):oe=t[75];let se;t[76]!==B||t[77]!==V||t[78]!==W||t[79]!==ne||t[80]!==oe?(se=(0,Z.jsx)(`button`,{type:`button`,onClick:B,disabled:V,title:W,className:ne,children:oe}),t[76]=B,t[77]=V,t[78]=W,t[79]=ne,t[80]=oe,t[81]=se):se=t[81];let ce;t[82]!==E||t[83]!==i||t[84]!==r?(ce=E?(0,Z.jsx)(`button`,{type:`button`,className:Y(`inline-flex min-h-11 max-w-full cursor-pointer items-center rounded-[1.125rem] px-3 text-xs text-accent-fg`,`hover:bg-accent-soft active:bg-accent-soft/70`,ca.transition,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`),onClick:()=>Wp(K_(r,i)),children:y(i).chat.productDelivery.continue}):null,t[82]=E,t[83]=i,t[84]=r,t[85]=ce):ce=t[85];let le;return t[86]!==r.kind||t[87]!==se||t[88]!==ce?(le=(0,Z.jsxs)(`li`,{className:`flex max-w-full min-w-0 flex-wrap items-center gap-2`,"data-product-delivery":z,children:[se,ce]}),t[86]=r.kind,t[87]=se,t[88]=ce,t[89]=le):le=t[89],le}function J_(e){return e.conversationId}function Y_(e){return e.setPath}function X_(e){let t=(0,X.c)(23),{entries:n,language:r,conversationId:i,projectId:a}=e,o;t[0]!==n.length||t[1]!==r?(o=y(r).chat.turnOutcome.fileCount.replace(`{{count}}`,String(n.length)),t[0]=n.length,t[1]=r,t[2]=o):o=t[2];let s=o,c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=Y(Mo,`cursor-pointer list-none`),t[3]=c):c=t[3];let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(fs,{strokeWidth:1.75}),t[4]=l):l=t[4];let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(te,{className:`size-3.5 shrink-0 text-fg-subtle transition-transform duration-150 group-open:rotate-90 motion-reduce:transition-none`,"aria-hidden":!0}),t[5]=u):u=t[5];let d;t[6]===s?d=t[7]:(d=(0,Z.jsx)(`summary`,{className:c,children:(0,Z.jsx)(Po,{icon:l,title:s,trailing:u})}),t[6]=s,t[7]=d);let f;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(f=Y(No,jo),t[8]=f):f=t[8];let p;if(t[9]!==i||t[10]!==n||t[11]!==r||t[12]!==a){let e;t[14]!==i||t[15]!==r||t[16]!==a?(e=e=>{let{key:t,delivery:n,reference:o}=e;return(0,Z.jsx)(q_,{delivery:n,reference:o,language:r,conversationId:i,projectId:a},t)},t[14]=i,t[15]=r,t[16]=a,t[17]=e):e=t[17],p=n.map(e),t[9]=i,t[10]=n,t[11]=r,t[12]=a,t[13]=p}else p=t[13];let m;t[18]===p?m=t[19]:(m=(0,Z.jsx)(`ul`,{className:f,children:p}),t[18]=p,t[19]=m);let h;return t[20]!==d||t[21]!==m?(h=(0,Z.jsx)(`li`,{className:`min-w-0 max-w-full`,"data-product-file-group":!0,children:(0,Z.jsxs)(`details`,{className:`group`,children:[d,m]})}),t[20]=d,t[21]=m,t[22]=h):h=t[22],h}function Z_(e){let t=(0,X.c)(9),{deliveries:n,language:r,excludedReferenceKeys:i,conversationId:a,projectId:o}=e,s,c;if(t[0]!==a||t[1]!==n||t[2]!==i||t[3]!==r||t[4]!==o){c=Symbol.for(`react.early_return_sentinel`);bb0:{let e=N_(n,i),t=e.filter(tv),l=e.findIndex(ev),u=e.filter($_),d=e.findIndex(Q_);if(e.length===0){c=null;break bb0}s=e.map((e,n)=>{let{key:i,delivery:s,reference:c}=e;return c.kind===`task`&&u.length>3?n===d?(0,Z.jsx)(V_,{entries:u,language:r,renderEntry:(e,t)=>(0,Z.jsx)(q_,{delivery:e.delivery,reference:e.reference,language:r,conversationId:a,projectId:o,fullTitle:t},e.key)},`task-delivery-group`):null:c.kind!==`file`||t.length===1?(0,Z.jsx)(q_,{delivery:s,reference:c,language:r,conversationId:a,projectId:o},i):n===l?(0,Z.jsx)(X_,{entries:t,language:r,conversationId:a,projectId:o},`file-delivery-group`):null})}t[0]=a,t[1]=n,t[2]=i,t[3]=r,t[4]=o,t[5]=s,t[6]=c}else s=t[5],c=t[6];if(c!==Symbol.for(`react.early_return_sentinel`))return c;let l;return t[7]===s?l=t[8]:(l=(0,Z.jsx)(Z.Fragment,{children:s}),t[7]=s,t[8]=l),l}function Q_(e){let{reference:t}=e;return t.kind===`task`}function $_(e){let{reference:t}=e;return t.kind===`task`}function ev(e){let{reference:t}=e;return t.kind===`file`}function tv(e){let{reference:t}=e;return t.kind===`file`}function nv(e){let t=(0,X.c)(22),{presentation:n}=e,r=h(rv),i;t[0]===r?i=t[1]:(i=y(r),t[0]=r,t[1]=i);let a=i.chat.productDelivery,o=a.diffPreview,s;t[2]===a.proposedChanges?s=t[3]:(s=(0,Z.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:a.proposedChanges}),t[2]=a.proposedChanges,t[3]=s);let c;t[4]===n.title?c=t[5]:(c=(0,Z.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:n.title}),t[4]=n.title,t[5]=c);let l;if(t[6]!==n.edits||t[7]!==a.replaceRange){let e;t[9]===a.replaceRange?e=t[10]:(e=(e,t)=>(0,Z.jsxs)(`details`,{className:`rounded border border-edge-subtle p-2`,children:[(0,Z.jsxs)(`summary`,{className:`cursor-pointer rounded text-xs text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[a.replaceRange,` `,e.from,`–`,e.to]}),(0,Z.jsx)(`pre`,{className:`mt-2 whitespace-pre-wrap [overflow-wrap:anywhere] font-mono text-xs text-fg`,children:e.text})]},t),t[9]=a.replaceRange,t[10]=e),l=n.edits.map(e),t[6]=n.edits,t[7]=a.replaceRange,t[8]=l}else l=t[8];let u;t[11]===l?u=t[12]:(u=(0,Z.jsx)(`div`,{className:`mt-2 max-h-80 space-y-2 overflow-y-auto`,children:l}),t[11]=l,t[12]=u);let d;t[13]!==n.truncated||t[14]!==a.partialDiff?(d=n.truncated?(0,Z.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-fg-muted`,children:a.partialDiff}):null,t[13]=n.truncated,t[14]=a.partialDiff,t[15]=d):d=t[15];let f;return t[16]!==a.diffPreview||t[17]!==s||t[18]!==c||t[19]!==u||t[20]!==d?(f=(0,Z.jsxs)(`section`,{className:`mt-2 rounded-lg border border-edge bg-surface-panel p-3`,"aria-label":o,children:[s,c,u,d]}),t[16]=a.diffPreview,t[17]=s,t[18]=c,t[19]=u,t[20]=d,t[21]=f):f=t[21],f}function rv(e){return e.language}function iv({previewId:e,reference:t,sourceHash:n,preferredHeight:r,language:i}){let a=d(),o=c(),s=(0,Q.useRef)(null),[l,u]=(0,Q.useState)(0),[f,m]=(0,Q.useState)(`booting`),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)([]),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(null),w=Math.min(720,Math.max(240,r)),T=ra(e),E=Gr(T.active?[`inline-local-app-snapshot`,t.id,n]:null,()=>Uo(t.id,n),{revalidateOnFocus:!1,shouldRetryOnError:!1});(0,Q.useEffect)(()=>{let e=s.current;if(!e||!E.data?.previewUrl)return;m(`booting`),g(null),v([]);let t=window.setTimeout(()=>{m(e=>e===`booting`?`timeout`:e)},7e3),n=Bo(e,e=>{let t=on(e);if(t){if(t.type===`ready`){m(`healthy`);return}if(t.type===`error`){g(t.detail),m(`failed`),v(e=>[...e,{phase:`runtime`,message:Vo(t.detail),code:t.detail.kind}].slice(-20));return}if(t.type===`acceptance`&&t.detail.status===`failed`){m(`failed`),v(e=>[...e,...t.detail.checks.filter(e=>e.status===`failed`).map(e=>({phase:`acceptance`,code:e.id,message:e.message}))].slice(-20));return}t.type===`criteria`&&t.detail.status===`failed`&&(m(`failed`),v(e=>[...e,...t.detail.scenarios.filter(e=>e.status===`failed`).map(e=>({phase:e.failureKind===`runner`?`runner`:`acceptance`,code:e.id,message:`${e.name}: ${e.message}`}))].slice(-20)))}});return()=>{window.clearTimeout(t),n()}},[l,E.data?.previewUrl]);let D=()=>{let e=en(t);e&&a(Qe(`${o.pathname}${o.search}`,`${e}&sourceHash=${encodeURIComponent(n)}`))};if(!T.active)return(0,Z.jsxs)(`section`,{ref:T.containerRef,className:`content-block-action-scope mt-3 overflow-hidden rounded-2xl border border-edge bg-surface-panel`,"data-inline-local-app":t.id,children:[(0,Z.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,title:t.title,children:t.title}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:T.state===`queued`?i===`zh`?`正在等待预览资源`:`Waiting for a preview slot`:i===`zh`?`预览尚未加载`:`Preview not loaded`})]}),(0,Z.jsx)(pi,{variant:`ghost`,className:`content-block-action`,onClick:D,title:i===`zh`?`查看预览`:`Preview`,"aria-label":i===`zh`?`查看预览`:`Preview`,children:(0,Z.jsx)(xe,{className:`size-4`,"aria-hidden":!0})})]}),(0,Z.jsx)(`div`,{className:`grid place-items-center bg-surface-base`,style:{height:w},children:(0,Z.jsx)(pi,{variant:`secondary`,onClick:T.activate,children:i===`zh`?`加载交互预览`:`Load interactive preview`})})]});if(E.isLoading)return(0,Z.jsxs)(`section`,{ref:T.containerRef,className:`mt-3 overflow-hidden rounded-2xl border border-edge bg-surface-panel`,"aria-label":y(i).chat.productDelivery.loadingAppPreview,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,Z.jsx)(qt,{className:`h-5 w-40`}),(0,Z.jsx)(qt,{className:`h-9 w-24`})]}),(0,Z.jsx)(qt,{className:`m-3 w-[calc(100%-1.5rem)]`,style:{height:w}})]});let O=E.data;if(!O){let e=E.error,t=e instanceof Error?e.message:i===`zh`?`无法加载应用预览`:`Unable to load app preview`;return(0,Z.jsx)(`section`,{ref:T.containerRef,className:`mt-3 rounded-2xl border border-danger/30 bg-danger-soft p-4 text-sm text-danger`,role:`alert`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Vt,{className:`size-4`}),t]})})}let k=O.validation.issues.map(e=>({phase:`build`,code:e.code,message:e.message}))??[],A=f===`timeout`?[{phase:`boot`,code:`boot_timeout`,message:y(i).chat.productDelivery.previewTimeout}]:[],j=[...k,..._,...A],M=O.status===`invalid`||O.validation.status===`failed`,N=M||f===`failed`||f===`timeout`,P=M?i===`zh`?`校验失败`:`Validation failed`:f===`healthy`?i===`zh`?`运行正常`:`Running`:f===`booting`?i===`zh`?`正在启动`:`Starting`:f===`timeout`?i===`zh`?`启动超时`:`Start timed out`:i===`zh`?`运行错误`:`Runtime error`,F=()=>{C(null),u(e=>e+1)},I=async()=>{if(j.length){x(!0),C(null);try{let e=await Wo(t.id,{sourceHash:O.sourceHash,locale:i,diagnostics:j});if(e.action===`retry`){F();return}let n=await Ho(t.id);a(zo(n,e.prompt))}catch(e){C(e instanceof Error?e.message:String(e))}finally{x(!1)}}};return(0,Z.jsxs)(`section`,{ref:T.containerRef,className:`content-block-action-scope mt-3 overflow-hidden rounded-2xl border border-edge bg-surface-panel`,"data-inline-local-app":t.id,children:[(0,Z.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,title:t.title,children:t.title}),(0,Z.jsx)(`p`,{className:Y(`mt-0.5 text-xs`,N?`text-danger`:`text-fg-muted`),"aria-live":`polite`,children:P})]}),(0,Z.jsx)(pi,{variant:`ghost`,className:`content-block-action`,onClick:F,"data-action-visible":N,title:i===`zh`?`重新加载预览`:`Reload preview`,"aria-label":i===`zh`?`重新加载预览`:`Reload preview`,children:(0,Z.jsx)(At,{className:`size-4`,"aria-hidden":!0})}),(0,Z.jsx)(pi,{variant:`ghost`,className:`content-block-action`,onClick:D,title:i===`zh`?`查看预览`:`Preview`,"aria-label":i===`zh`?`查看预览`:`Preview`,children:(0,Z.jsx)(xe,{className:`size-4`,"aria-hidden":!0})})]}),(0,Z.jsxs)(`div`,{className:`relative bg-surface-base`,style:{height:w},children:[O.previewUrl?(0,Z.jsx)(`iframe`,{ref:s,title:i===`zh`?`${t.title} 交互预览`:`${t.title} interactive preview`,src:p(O.previewUrl),sandbox:`allow-scripts allow-forms`,className:`h-full w-full border-0 bg-white`},l):null,O.previewUrl&&f===`booting`?(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-0 grid place-items-center bg-surface-base/75`,children:(0,Z.jsx)(qt,{className:`h-10 w-40`})}):null]}),N?(0,Z.jsxs)(`footer`,{className:`border-t border-danger/20 bg-danger-soft/60 px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Z.jsx)(`p`,{className:`min-w-0 flex-1 text-xs text-danger`,children:h?.message??j[0]?.message??(i===`zh`?`预览校验失败`:`Preview validation failed`)}),(0,Z.jsxs)(pi,{variant:`secondary`,className:`min-h-9 px-3 text-xs`,disabled:b||j.length===0,onClick:()=>void I(),children:[(0,Z.jsx)(Wt,{className:`size-4`}),b?i===`zh`?`生成修复建议…`:`Preparing fix…`:i===`zh`?`让 Coder 修复`:`Ask Coder to fix`]})]}),S?(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-danger`,role:`alert`,children:S}):null]}):null]})}async function av(e,t){return(await g(p(`/api/chat-previews/${encodeURIComponent(e)}/revisions/${encodeURIComponent(t)}`))).revision}async function ov(e,t){return(await g(p(`/api/chat-previews/${encodeURIComponent(e)}/fix-guidance`),{method:`POST`,body:JSON.stringify(t)})).guidance}async function sv(e,t){return(await g(p(`/api/chat-previews/${encodeURIComponent(e)}/promote`),{method:`POST`,body:JSON.stringify({sourceHash:t})})).app}function cv(e,t){return e.replace(RegExp(`</${t}`,`gi`),`<\\/${t}`)}function lv(e){let t=rn.safeParse(e);return t.success?t.data:null}function uv(e,t){let n=`(() => {
24
+ `)}\n…`}t[12]=s.text,t[13]=i}else i=t[13];c=i,f=`space-y-1.5`,l=`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,t[14]===a?u=t[15]:(u=a?(0,Z.jsx)(`a`,{href:a,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex max-w-full min-w-0 items-center break-words rounded-md bg-surface-hover/60 px-1.5 py-0.5 font-mono text-xs text-accent-fg underline-offset-2 hover:underline [overflow-wrap:anywhere] dark:bg-surface-hover/35`,title:a,children:a}):null,t[14]=a,t[15]=u),d=n!=null&&n>0?(0,Z.jsx)(cg,{children:pg(r.linesBadge,{count:n})}):null,t[4]=r,t[5]=s,t[6]=a,t[7]=c,t[8]=l,t[9]=u,t[10]=d,t[11]=f}else c=t[7],l=t[8],u=t[9],d=t[10],f=t[11];let p;t[16]!==l||t[17]!==u||t[18]!==d?(p=(0,Z.jsxs)(`div`,{className:l,children:[u,d]}),t[16]=l,t[17]=u,t[18]=d,t[19]=p):p=t[19];let m;t[20]!==r||t[21]!==c?(m=c?(0,Z.jsx)(dg,{summary:r.viewContent,children:(0,Z.jsx)(fg,{children:c})}):null,t[20]=r,t[21]=c,t[22]=m):m=t[22];let h;return t[23]!==f||t[24]!==p||t[25]!==m?(h=(0,Z.jsxs)(`div`,{className:f,children:[p,m]}),t[23]=f,t[24]=p,t[25]=m,t[26]=h):h=t[26],h}),Og=e=>e&&typeof e==`object`&&!Array.isArray(e)?e:void 0,kg=e=>typeof e==`string`&&/^[a-z0-9][a-z0-9_-]{0,63}$/.test(e)?e:void 0;function Ag(e){let t={...ma(e.result).details,...Og(e.details)},n=Og(t?.searchInfo)??t,r=Array.isArray(n?.attempts)?n.attempts.slice(0,24).flatMap(e=>{let t=Og(e),n=kg(t?.provider);return!n||![`success`,`empty`,`error`,`skipped`].includes(String(t?.outcome))?[]:[{provider:n,upstream:kg(t?.upstream),outcome:String(t?.outcome),reason:kg(t?.reason)}]}):[];return{provider:kg(n?.provider),upstream:kg(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 jg(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 Mg(e){let t=(0,X.c)(25),{block:n,summary:r,labels:i,developer:a,language:o}=e,[s,c]=(0,Q.useState)(!1),l;if(t[0]!==n||t[1]!==a||t[2]!==i.attempts||t[3]!==i.cacheHint||t[4]!==i.cacheUnknown||t[5]!==i.cached||t[6]!==i.cachedRoute||t[7]!==i.capturedAt||t[8]!==i.fresh||t[9]!==i.incompleteRoute||t[10]!==i.outcomes||t[11]!==i.provider||t[12]!==i.reasons||t[13]!==i.route||t[14]!==i.unknown||t[15]!==i.upstreamUnknown||t[16]!==o||t[17]!==s||t[18]!==r){let e=Ag(n),u;t[20]===i.unknown?u=t[21]:(u=e=>jg(e,i.unknown),t[20]=i.unknown,t[21]=u);let d=u,f=e.provider===`xopc-cloud`?`${d(e.provider)} · ${e.upstream?d(e.upstream):i.upstreamUnknown}`:d(e.provider),p;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(p=e=>c(e.currentTarget.open),t[22]=p):p=t[22];let m;t[23]===r?m=t[24]:(m=(0,Z.jsx)(`summary`,{className:`cursor-pointer hover:text-fg`,children:r}),t[23]=r,t[24]=m),l=(0,Z.jsxs)(`details`,{className:`min-w-0 text-xs text-fg-muted`,onToggle:p,children:[m,s?(0,Z.jsxs)(`div`,{className:`mt-2 space-y-2 rounded-md border border-edge px-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Z.jsxs)(`span`,{children:[i.provider,`:`,f]}),(0,Z.jsx)(`span`,{className:`text-fg-subtle`,children:e.cached===!0?i.cached:e.cached===!1?i.fresh:i.cacheUnknown})]}),e.cached===!0?(0,Z.jsx)(`p`,{className:`text-fg-subtle`,children:i.cacheHint}):null,a?(0,Z.jsxs)(`div`,{className:`space-y-1 border-t border-edge pt-2 text-fg-subtle`,children:[e.attemptCount===void 0?null:(0,Z.jsxs)(`p`,{children:[i.attempts,`:`,e.attemptCount]}),e.capturedAt===void 0?null:(0,Z.jsxs)(`p`,{children:[i.capturedAt,`:`,new Date(e.capturedAt).toLocaleString(o===`zh`?`zh-CN`:`en-US`)]}),e.attemptCount!==void 0&&e.attemptCount>e.attempts.length?(0,Z.jsx)(`p`,{children:i.incompleteRoute}):null,e.attempts.length?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{children:e.cached===!0?i.cachedRoute:i.route}),(0,Z.jsx)(`ol`,{className:`list-inside list-decimal space-y-1`,children:e.attempts.map((e,t)=>(0,Z.jsxs)(`li`,{children:[d(e.provider),e.upstream?` · ${d(e.upstream)}`:``,` · `,i.outcomes[e.outcome]??i.unknown,e.reason?` · ${i.reasons[e.reason]??i.unknown}`:``]},t))})]}):null]}):null]}):null]}),t[0]=n,t[1]=a,t[2]=i.attempts,t[3]=i.cacheHint,t[4]=i.cacheUnknown,t[5]=i.cached,t[6]=i.cachedRoute,t[7]=i.capturedAt,t[8]=i.fresh,t[9]=i.incompleteRoute,t[10]=i.outcomes,t[11]=i.provider,t[12]=i.reasons,t[13]=i.route,t[14]=i.unknown,t[15]=i.upstreamUnknown,t[16]=o,t[17]=s,t[18]=r,t[19]=l}else l=t[19];return l}function Ng(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 Pg(e){let t=(0,X.c)(8),{extensionId:n,extensionName:r,entrypoint:i,title:a,toolResult:o,maxHeight:s,interactive:c,permissions:l}=e,u=s===void 0?400:s,d;return t[0]!==i||t[1]!==n||t[2]!==r||t[3]!==u||t[4]!==l||t[5]!==a||t[6]!==o?(d=(0,Z.jsx)(`div`,{className:`mt-2 w-full min-w-0 overflow-hidden rounded-xl border border-edge bg-surface-base`,children:(0,Z.jsx)(Ro,{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 Fg(e){let t=ka();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 Ig(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 Lg(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 Rg(e,t,n){let r=new Map,i=0,a=e.toSorted((e,t)=>Number(la(e.name))-Number(la(t.name)));for(let e of a){if(fa(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 zg({path:e,conversationId:t,label:n}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(),s=Ni(e=>e.setPath),c=async()=>{i(!0),o(void 0);try{let n=await Ua(e,{conversationId:t??void 0});if(!n?.capabilities.includes(`preview`))throw Error(`Output file is unavailable`);s(n.absolutePath??n.workspaceRelativePath??e,void 0,void 0,t)}catch(e){o(e instanceof Error?e.message:String(e))}finally{i(!1)}};return(0,Z.jsxs)(`div`,{className:`mt-2`,children:[(0,Z.jsx)(pi,{variant:`ghost`,disabled:r,onClick:()=>{c()},className:`text-accent`,children:n}),a?(0,Z.jsx)(`p`,{className:`text-xs text-red-600`,children:a}):null]})}function Bg(e){return/^Full Codemode output: (\.xopc\/codemode-output\/[a-f0-9-]{36}\.txt)(?:\r?\n|$)/.exec(e)?.[1]}function Vg(e,t=0){return or(e)??(e.type===`tool_use`?e.id:e.type===`text`?e.segmentId??`narration-${t}`:`thinking-${t}`)}var Hg=(0,Q.memo)(function(e){let t=(0,X.c)(15),{active:n,startedAt:r,frozenMs:i,language:a,className:o}=e,[,s]=(0,Q.useState)(0),c;t[0]!==n||t[1]!==s?(c=()=>{if(!n)return;let e=window.setInterval(()=>s(g_),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?Ng(u,a):i==null?null:Ng(i,a),t[5]=n,t[6]=u,t[7]=i,t[8]=a,t[9]=r,t[10]=d):d=t[10];let f=d;if(!f)return null;let p=n||void 0,m;return t[11]!==o||t[12]!==p||t[13]!==f?(m=(0,Z.jsx)(`span`,{className:o,"aria-hidden":p,children:f}),t[11]=o,t[12]=p,t[13]=f,t[14]=m):m=t[14],m});function Ug(e){let t=(0,X.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,g=l===void 0||l,_=u!==void 0&&u,v=d!==void 0&&d,b=f!==void 0&&f,x=p!==void 0&&p,S=m===void 0||m,C=h(r_),[w,T]=(0,Q.useState)(!1),E,D;t[0]===r?(E=t[1],D=t[2]):(E=()=>{if(T(!1),r!==`waiting`)return;let e=window.setTimeout(()=>T(!0),3e3);return()=>window.clearTimeout(e)},D=[r],t[0]=r,t[1]=E,t[2]=D),(0,Q.useEffect)(E,D);let O;t[3]===C?O=t[4]:(O=y(C),t[3]=C,t[4]=O);let k=O.chat,A=Lo(n_),j;if(t[5]!==A||t[6]!==b||t[7]!==n.items){let e;t[9]!==A||t[10]!==b?(e=e=>e.type!==`thinking`||A||b,t[9]=A,t[10]=b,t[11]=e):e=t[11],j=n.items.filter(e),t[5]=A,t[6]=b,t[7]=n.items,t[8]=j}else j=t[8];let M=j,N;t[12]===n.items?N=t[13]:(N=n.items.filter(t_),t[12]=n.items,t[13]=N);let P=N,F=M.length,I=n.active,L=n.expandedByDefault&&I,[R,z]=(0,Q.useState)(null),B=R?.active===I?R.value:null,V=L,[H,U]=(0,Q.useState)(!1),W=(0,Q.useRef)(null),[G,te]=(0,Q.useState)(!1),[ne,re]=(0,Q.useState)(!1),ie,ae;t[14]!==I||t[15]!==G?(ie=()=>{if(!I&&!G)return;let e=()=>{let e=window.getSelection();te(!!(e&&!e.isCollapsed&&W.current?.contains(e.anchorNode)))};return document.addEventListener(`selectionchange`,e),()=>document.removeEventListener(`selectionchange`,e)},ae=[I,G],t[14]=I,t[15]=G,t[16]=ie,t[17]=ae):(ie=t[16],ae=t[17]),(0,Q.useEffect)(ie,ae);let oe=!n.compact&&M.length>0&&(B??(V||G)),se,ce;t[18]===oe?(se=t[19],ce=t[20]):(se=()=>{let e=W.current;if(!oe||!e)return;let t=t=>Jh(t,e);return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},ce=[oe],t[18]=oe,t[19]=se,t[20]=ce),(0,Q.useEffect)(se,ce);let le,ue;t[21]!==oe||t[22]!==ne?(le=()=>{if(oe){re(!0);return}if(!ne)return;let e=window.setTimeout(()=>re(!1),200);return()=>window.clearTimeout(e)},ue=[oe,ne],t[21]=oe,t[22]=ne,t[23]=le,t[24]=ue):(le=t[23],ue=t[24]),(0,Q.useEffect)(le,ue);let K;t[25]===M?K=t[26]:(K=M.every(e_),t[25]=M,t[26]=K);let q=K,de,fe,pe,J,me,he,ge,_e,ve,ye,be;if(t[27]!==P||t[28]!==I||t[29]!==s||t[30]!==k||t[31]!==o||t[32]!==c||t[33]!==oe||t[34]!==C||t[35]!==r||t[36]!==_||t[37]!==S||t[38]!==H||t[39]!==A||t[40]!==b||t[41]!==g||t[42]!==q||t[43]!==a||t[44]!==x||t[45]!==i||t[46]!==M||t[47]!==w||t[48]!==n.durationMs||t[49]!==n.items||t[50]!==n.startedAt){ve=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Lg(M);me=q&&I&&!H&&!A?Math.max(0,e.length-3):0,ye=e.slice(me).flatMap($g),J=n.startedAt??null,fe=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)=>pa(e,t,a.toolActivity,u,o.ing),t[75]=o.ing,t[76]=u,t[77]=a.toolActivity,t[78]=d):d=t[78],he=d;let f=P.filter(Qg),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]===he?e=t[83]:(e=e=>he(e,`running`),t[82]=he,t[83]=e);let n;t[84]!==P||t[85]!==o.ing||t[86]!==e?(n=Rh(P,o.ing,e),t[84]=P,t[85]=o.ing,t[86]=e,t[87]=n):n=t[87],m=n}let h=m,v=r===`sending`?k.sendingLabel:r===`waiting`?w?k.waitingLongLabel:k.waitingLabel:null,y;t[88]!==P||t[89]!==k.thinkingLabel||t[90]!==a.workLogRunning?(y=P.some(Zg)?k.thinkingLabel:a.workLogRunning,t[88]=P,t[89]=k.thinkingLabel,t[90]=a.workLogRunning,t[91]=y):y=t[91];let T=y;ge=r??(P.some(Xg)?`tool`:P.some(Yg)?`thinking`:P.length>0?`organizing`:`working`),de=h??v??T;let E;if(t[92]!==P||t[93]!==k.activityFailed||t[94]!==k.activityMore||t[95]!==k.activityRepeated||t[96]!==C||t[97]!==he||t[98]!==b||t[99]!==a.thoughts){let e=P.filter(Jg);E=b&&e.length>0?Rg(e,e=>he(e,`completed`),{repeated:k.activityRepeated,more:k.activityMore,failed:k.activityFailed,separator:C===`zh`?`、`:`, `}):b?a.thoughts:null,t[92]=P,t[93]=k.activityFailed,t[94]=k.activityMore,t[95]=k.activityRepeated,t[96]=C,t[97]=he,t[98]=b,t[99]=a.thoughts,t[100]=E}else E=t[100];if(pe=E,n.items.length===0&&!I){ve=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,_||x){let e;t[122]!==I||t[123]!==s||t[124]!==c||t[125]!==S||t[126]!==be||t[127]!==i||t[128]!==n.items?(e=S&&n.items.filter(qg).map(e=>(0,Z.jsx)(p_,{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]=S,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,Z.jsx)(Z.Fragment,{children:e}),t[130]=e,t[131]=r),ve=r;break bb0}_e=oe&&(!g||A)&&p===1&&ye.includes(f[0])}t[27]=P,t[28]=I,t[29]=s,t[30]=k,t[31]=o,t[32]=c,t[33]=oe,t[34]=C,t[35]=r,t[36]=_,t[37]=S,t[38]=H,t[39]=A,t[40]=b,t[41]=g,t[42]=q,t[43]=a,t[44]=x,t[45]=i,t[46]=M,t[47]=w,t[48]=n.durationMs,t[49]=n.items,t[50]=n.startedAt,t[51]=de,t[52]=fe,t[53]=pe,t[54]=J,t[55]=me,t[56]=he,t[57]=ge,t[58]=_e,t[59]=ve,t[60]=ye,t[61]=be}else de=t[51],fe=t[52],pe=t[53],J=t[54],me=t[55],he=t[56],ge=t[57],_e=t[58],ve=t[59],ye=t[60],be=t[61];if(ve!==Symbol.for(`react.early_return_sentinel`))return ve;let xe=_e,Se;t[132]!==de||t[133]!==I||t[134]!==fe||t[135]!==pe||t[136]!==J||t[137]!==C||t[138]!==xe||t[139]!==ge||t[140]!==a.workLogComplete||t[141]!==a.workLogFailed||t[142]!==a.workLogPartial||t[143]!==a.workLogTitle||t[144]!==n.status?(Se=I?(0,Z.jsxs)(Z.Fragment,{children:[xe?(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:a.workLogTitle}):null,(0,Z.jsx)(`span`,{className:xe?`sr-only`:`block min-w-0 flex-1 truncate whitespace-nowrap`,"data-status-phase":ge,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:(0,Z.jsx)(`span`,{className:`assistant-activity-shimmer inline-block max-w-full truncate align-bottom`,children:de})}),(0,Z.jsx)(Hg,{active:I,startedAt:J,frozenMs:null,language:C,className:`ml-1.5 w-[8ch] shrink-0 whitespace-nowrap text-right tabular-nums text-fg-muted`})]}):(0,Z.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:pe??(n.status===`failed`?a.workLogFailed:n.status===`partial`?a.workLogPartial:fe==null?a.workLogTitle:a.workLogComplete)}),t[132]=de,t[133]=I,t[134]=fe,t[135]=pe,t[136]=J,t[137]=C,t[138]=xe,t[139]=ge,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]!==fe||t[148]!==J||t[149]!==C?(we=I?null:(0,Z.jsx)(Hg,{active:!1,startedAt:J,frozenMs:fe,language:C,className:`mt-0.5 tabular-nums text-xs text-fg-muted`}),t[146]=I,t[147]=fe,t[148]=J,t[149]=C,t[150]=we):we=t[150];let Te=we,Ee=!n.compact&&F>0;if(g&&!A){let e;t[151]!==v||t[152]!==I||t[153]!==n.items?(e=!I&&!v&&n.items.some(Kg),t[151]=v,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]!==de||t[156]!==v||t[157]!==I||t[158]!==s||t[159]!==c||t[160]!==o||t[161]!==S||t[162]!==he||t[163]!==be||t[164]!==i||t[165]!==n.items||t[166]!==n.status){let e=I&&!v||o?Ig(n.items,e=>{if(fa(e)||la(e.name)||!ua(e.name)&&Nh(e.name,e.activity)===`other`)return null;let t=he(e,I&&(e.status===`running`||e.activity?.status===`running`)?`running`:`completed`);return I&&t===de?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]!==S||t[176]!==be||t[177]!==i||t[178]!==n.items?(f=S&&n.items.filter(Gg).map(e=>(0,Z.jsx)(p_,{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]=S,t[176]=be,t[177]=i,t[178]=n.items,t[179]=f):f=t[179],p=e.length>0?(0,Z.jsx)(`div`,{"data-assistant-activity-flow":!0,className:`space-y-2.5 text-sm leading-relaxed text-fg-muted`,children:e.map((e,t)=>(0,Z.jsx)(p_,{block:e,toolLabels:i,stepLabels:be,cardLabels:s,conversationId:c,runActive:I},Vg(e,t)))}):null,t[155]=de,t[156]=v,t[157]=I,t[158]=s,t[159]=c,t[160]=o,t[161]=S,t[162]=he,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,Z.jsxs)(`div`,{className:`mt-2 flex h-11 w-full min-w-0 items-center gap-2 px-1 text-sm text-fg-muted`,"data-assistant-running":!0,children:[(0,Z.jsx)(Rt,{className:`assistant-activity-busy size-4 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`div`,{className:`flex h-6 min-w-0 flex-1 items-center`,children:Ce})]}):o?(0,Z.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,Z.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||oe?`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]!==oe||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,Z.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:!oe}):void 0,"aria-expanded":Ee?oe:void 0,children:[(0,Z.jsx)(Rt,{className:Y(`size-4 shrink-0`,I&&`assistant-activity-busy`),"aria-hidden":!0}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:(0,Z.jsx)(`span`,{className:Y(`flex w-full min-w-0 items-center`,I?`h-6`:`min-h-6`),children:Ce})}),(0,Z.jsx)(`span`,{className:`flex shrink-0 items-start justify-end`,children:Te}),Ee?(0,Z.jsx)(ee,{className:Y(`size-4 shrink-0 text-fg-muted transition-transform motion-reduce:transition-none`,oe&&`rotate-180`),"aria-hidden":!0}):null]}):null,t[197]=I,t[198]=oe,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]!==S||t[209]!==be||t[210]!==i||t[211]!==n.items?(je=S&&n.items.filter(Wg).map(e=>(0,Z.jsx)(p_,{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]=S,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]!==oe||t[218]!==ne||t[219]!==me||t[220]!==H||t[221]!==b||t[222]!==ye||t[223]!==be||t[224]!==i?(Me=oe||ne?(0,Z.jsx)(`div`,{className:`assistant-activity-disclosure`,"data-open":oe,"aria-hidden":!oe,inert:!oe,children:(0,Z.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:(0,Z.jsxs)(`div`,{ref:W,className:`assistant-activity-flow mt-1 max-h-[min(32rem,50dvh)] w-full min-w-0 overflow-x-hidden overflow-y-auto pb-1 pl-1 pr-2 [scrollbar-gutter:stable]`,"data-assistant-activity-flow":!0,onFocusCapture:()=>z({active:I,value:!0}),children:[me>0?(0,Z.jsx)(`button`,{type:`button`,className:`mb-3 text-xs text-fg-muted hover:text-fg`,onClick:()=>U(!0),children:k.activityEarlier}):null,(0,Z.jsx)(i_,{blocks:ye,toolLabels:i,stepLabels:be,cardLabels:s,conversationId:c,animateNew:I&&oe&&!H,runActive:I,showThinking:b})]})})}):null,t[213]=I,t[214]=s,t[215]=k.activityEarlier,t[216]=c,t[217]=oe,t[218]=ne,t[219]=me,t[220]=H,t[221]=b,t[222]=ye,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,Z.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 Wg(e){return e.type===`tool_use`}function Gg(e){return e.type===`tool_use`}function Kg(e){return e.type===`tool_use`&&fa(e)}function qg(e){return e.type===`tool_use`}function Jg(e){return e.type===`tool_use`}function Yg(e){return e.type===`thinking`&&e.streaming}function Xg(e){return e.type===`tool_use`&&e.status===`running`}function Zg(e){return e.type===`thinking`&&e.streaming}function Qg(e){return e.type===`tool_use`&&(e.status===`running`||e.activity?.status===`running`)}function $g(e){return e.type===`tools`?e.tools:[e.item]}function e_(e){return or(e)||e.type===`tool_use`||e.type===`text`&&e.segmentId}function t_(e){return e.type!==`text`}function n_(e){return e.showRawToolData}function r_(e){return e.language}function i_({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(Vg))),u=Lo(e=>e.showRawToolData),d=h(e=>e.language),f=u?e.map(e=>({type:`item`,item:e})):Lg(e);return e.length>0?(0,Z.jsx)(`div`,{className:Y(`min-w-0 overflow-x-hidden`,i),children:(0,Z.jsx)(`div`,{className:`min-w-0 space-y-2.5 pl-1`,children:f.map((e,i)=>{let f=e.type===`tools`?e.tools[0]:e.item,p=Vg(f,i);return(0,Z.jsx)(`div`,{className:Y(o&&!l.current.has(p)&&f.type!==`text`&&`assistant-activity-enter`),children:e.type===`tools`?(0,Z.jsx)(a_,{tools:e.tools,runActive:s,labels:n,language:d,renderTool:e=>(0,Z.jsx)(p_,{block:e,toolLabels:t,stepLabels:n,cardLabels:r,conversationId:a,runActive:s},e.id)}):e.item.type===`thinking`&&c&&!u?(0,Z.jsx)(`div`,{"data-assistant-thinking":!0,className:`text-sm leading-relaxed text-fg-muted`,children:(0,Z.jsx)(cf,{content:e.item.text,compact:!0,streaming:!!(s&&e.item.streaming)})}):(0,Z.jsx)(p_,{block:e.item,toolLabels:t,stepLabels:n,cardLabels:r,conversationId:a,runActive:s})},p)})})}):null}function a_(e){let t=(0,X.c)(35),{tools:n,runActive:r,labels:i,language:a,renderTool:o}=e,s;t[0]!==r||t[1]!==n?(s=r&&n.some(s_),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=y(a).chat,s=c?[...n].reverse().find(o_):void 0,_=n.filter(e=>e!==s),v;t[17]!==i||t[18]!==r?(v=e=>pa(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 b=Rg(_,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,Z.jsx)(`summary`,{className:`cursor-pointer rounded-md py-1 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,Z.jsx)(`span`,{children:b})}),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,Z.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,Z.jsxs)(`details`,{className:d,children:[f,_]}),t[26]=_,t[27]=d,t[28]=f,t[29]=v):v=t[29];let b;return t[30]!==v||t[31]!==p||t[32]!==m||t[33]!==h?(b=(0,Z.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]=b):b=t[34],b}function o_(e){return e.status===`running`||e.activity?.status===`running`}function s_(e){return e.status===`running`||e.activity?.status===`running`}function c_(e){let t=(0,X.c)(15),{toolName:n,toolResult:r}=e,i=ka(),a=Fg(n);if(!a||i.length===0)return null;let o;if(t[0]!==i||t[1]!==a.extensionId){let e;t[3]===a.extensionId?e=t[4]:(e=e=>e.id===a.extensionId,t[3]=a.extensionId,t[4]=e),o=i.find(e),t[0]=i,t[1]=a.extensionId,t[2]=o}else o=t[2];let s=o,c=s?.name??a.extensionId,l=a.maxHeight??400,u=a.interactive??!1,d=s?.ui?.permissions,f;return t[5]!==c||t[6]!==l||t[7]!==u||t[8]!==d||t[9]!==r||t[10]!==a.entrypoint||t[11]!==a.extensionId||t[12]!==a.id||t[13]!==a.title?(f=(0,Z.jsx)(Pg,{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 l_=new Set([`readFile`,`editFile`,`writeFile`,`runCommand`,`fetchUrl`]),u_=240;function d_(e){let t=e.split(`
25
+ `).map(e=>e.trim()).find(Boolean)??``;return t.length<=u_?t:`${t.slice(0,u_)}…`}function f_(e,t,n){let r=ma(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 d_(t)}return d_(r.text)||t}function p_(e){let t=(0,X.c)(137),{block:n,toolLabels:r,stepLabels:i,cardLabels:a,conversationId:o,surfaceOnly:s,runActive:c}=e,l=s!==void 0&&s,d=c===void 0||c,f;t[0]===n?f=t[1]:(f=or(n),t[0]=n,t[1]=f);let p=Vm(o,f),m=p?.type===n.type?p:n,g=Lo(h_),_=h(m_),v;bb0:{if(m.type!==`tool_use`){v=``;break bb0}if(m.status===`running`){v=``;break bb0}let e=m.result;if(e==null){v=``;break bb0}if(typeof e==`string`){let n;t[2]===e?n=t[3]:(n=e.trim(),t[2]=e,t[3]=n),v=n;break bb0}try{let n;t[4]===e?n=t[5]:(n=JSON.stringify(e,null,2),t[4]=e,t[5]=n),v=n}catch{v=String(e)}}let b=v;if(m.type===`text`){let e;t[6]===m.text?e=t[7]:(e=m.text.trim(),t[6]=m.text,t[7]=e);let n=e;if(!n)return null;let r=m.presentation===`pending`,i;return t[8]!==r||t[9]!==n?(i=(0,Z.jsx)(`div`,{className:`min-w-0 text-sm leading-relaxed text-fg-muted`,children:(0,Z.jsx)(cf,{content:n,compact:!0,streaming:r})}),t[8]=r,t[9]=n,t[10]=i):i=t[10],i}if(m.type===`thinking`){let e=!!m.streaming,n;t[11]===m.text?n=t[12]:(n=m.text?.trim()??``,t[11]=m.text,t[12]=n);let r=n;if(!g||!r)return null;let a=e?i.thoughtsStreaming:i.thoughts,o;t[13]===a?o=t[14]:(o=(0,Z.jsx)(`span`,{className:`inline-flex max-w-full min-w-0 break-words text-[13px] text-fg-muted [overflow-wrap:anywhere]`,children:a}),t[13]=a,t[14]=o);let s;t[15]!==g||t[16]!==i.rawThinking||t[17]!==e||t[18]!==r?(s=g&&r?(0,Z.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer select-none text-fg-subtle underline-offset-2 hover:text-fg-muted`,children:i.rawThinking}),(0,Z.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-xs leading-relaxed text-fg-muted [overflow-wrap:anywhere]`,children:r})]}):e?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`…`}):null,t[15]=g,t[16]=i.rawThinking,t[17]=e,t[18]=r,t[19]=s):s=t[19];let c;return t[20]!==o||t[21]!==s?(c=(0,Z.jsx)(`div`,{className:`min-w-0`,children:(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[o,s]})}),t[20]=o,t[21]=s,t[22]=c):c=t[22],c}let x=d&&(m.status===`running`||m.activity?.status===`running`),S;t[23]!==m||t[24]!==l?(S=l?m.status===`error`||m.activity?.status===`failed`:fa(m),t[23]=m,t[24]=l,t[25]=S):S=t[25];let C=S,w;t[26]!==m||t[27]!==a||t[28]!==C||t[29]!==i.toolError?(w=C?f_(m,i.toolError,a):``,t[26]=m,t[27]=a,t[28]=C,t[29]=i.toolError,t[30]=w):w=t[30];let T=w,E=b,D;t[31]!==m.name||t[32]!==E?(D=m.name===`codemode`?Bg(E??``):void 0,t[31]=m.name,t[32]=E,t[33]=D):D=t[33];let O=D,k=x&&m.details&&typeof m.details==`object`&&!Array.isArray(m.details)&&typeof m.details.text==`string`?m.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]!==m||t[37]!==C||t[38]!==x||t[39]!==_||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=Nh(m.name,m.activity),j=l_.has(M),N=m.name===`personal_memory`?Wh(m,_===`zh`):M===`memorySearch`?Uh(m,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=pa(m,x||C?`running`:`completed`,i.toolActivity,e,i.runningActions);F=C?M===`other`&&!ua(m.name)?i.toolError:i.toolActivity.stepFailed.replace(`{{operation}}`,n.replace(/^正在|[.…]+$/g,``)):N?.title??n,P=C?Vt:M.includes(`Search`)||M===`search`?Nt:M===`readFile`?H:M===`editFile`||M===`writeFile`?us:M===`fetchUrl`||M===`openUrl`?Ne:J,t[36]=m,t[37]=C,t[38]=x,t[39]=_,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]!==m.input||t[62]!==N?(L=N?``:tg(m.input),t[61]=m.input,t[62]=N,t[63]=L):L=t[63];let R=L,z;t[64]===m.input?z=t[65]:(z=m.input===void 0?``:Yh(m.input),t[64]=m.input,t[65]=z);let B=z,V;t[66]!==m||t[67]!==a||t[68]!==j||t[69]!==M?(V=j?M===`readFile`?(0,Z.jsx)(vg,{block:m,labels:a}):M===`editFile`?(0,Z.jsx)(xg,{block:m,labels:a}):M===`writeFile`?(0,Z.jsx)(Cg,{block:m,labels:a}):M===`runCommand`?(0,Z.jsx)(Eg,{block:m,labels:a}):M===`fetchUrl`?(0,Z.jsx)(Dg,{block:m,labels:a}):null:null,t[66]=m,t[67]=a,t[68]=j,t[69]=M,t[70]=V):V=t[70];let U=V;if(l){let e;t[71]!==m.name||t[72]!==m.result||t[73]!==C||t[74]!==x?(e=!x&&!C?(0,Z.jsx)(c_,{toolName:m.name,toolResult:m.result}):null,t[71]=m.name,t[72]=m.result,t[73]=C,t[74]=x,t[75]=e):e=t[75];let n;return t[76]===e?n=t[77]:(n=(0,Z.jsx)(Z.Fragment,{children:e}),t[76]=e,t[77]=n),n}let W=!x&&g,G=m.parentToolCallId?`ml-4 min-w-0 border-l border-edge pl-3`:`min-w-0`,ee=C?`failed`:x?`running`:`completed`,te=x&&`assistant-activity-busy`,ne;t[78]===te?ne=t[79]:(ne=Y(`mt-0.5 size-4 shrink-0 text-fg-subtle`,te),t[78]=te,t[79]=ne);let re;t[80]!==I||t[81]!==ne?(re=(0,Z.jsx)(I,{className:ne,"aria-hidden":!0}),t[80]=I,t[81]=ne,t[82]=re):re=t[82];let ie;t[83]===F?ie=t[84]:(ie=(0,Z.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]=ie);let ae;t[85]!==ee||t[86]!==re||t[87]!==ie?(ae=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,"data-activity-status":ee,children:[re,ie]}),t[85]=ee,t[86]=re,t[87]=ie,t[88]=ae):ae=t[88];let oe;t[89]!==U||t[90]!==i.stepDetails?(oe=U?(0,Z.jsxs)(`details`,{className:`min-w-0 text-xs text-fg-muted`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer hover:text-fg`,children:i.stepDetails}),U]}):null,t[89]=U,t[90]=i.stepDetails,t[91]=oe):oe=t[91];let se;t[92]!==m||t[93]!==x||t[94]!==M||t[95]!==_||t[96]!==g||t[97]!==i.stepDetails?(se=M===`webSearch`&&!x?(0,Z.jsx)(Mg,{block:m,summary:i.stepDetails,labels:y(_).chat.searchDetails,developer:g,language:_}):null,t[92]=m,t[93]=x,t[94]=M,t[95]=_,t[96]=g,t[97]=i.stepDetails,t[98]=se):se=t[98];let ce;t[99]!==N||t[100]!==i.memoryActivity?(ce=N?(0,Z.jsxs)(`div`,{className:`space-y-1 text-xs text-fg-muted`,children:[(0,Z.jsx)(`p`,{children:N.purpose}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1`,children:[(0,Z.jsx)(u,{className:`font-medium text-accent-fg hover:underline`,to:`/user-model`,children:i.memoryActivity.manage}),(0,Z.jsx)(u,{className:`font-medium text-accent-fg hover:underline`,to:`/user-model`,children:i.memoryActivity.privacy})]}),(0,Z.jsxs)(`details`,{children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer select-none text-fg-subtle hover:text-fg-muted`,children:i.memoryActivity.why}),(0,Z.jsx)(`div`,{className:`mt-1.5 rounded-md bg-surface-hover/60 px-2 py-1.5 dark:bg-surface-hover/35`,children:(0,Z.jsx)(`p`,{children:i.memoryActivity.explanation})})]})]}):null,t[99]=N,t[100]=i.memoryActivity,t[101]=ce):ce=t[101];let le;t[102]!==T||t[103]!==g?(le=T&&g?(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:T}):null,t[102]=T,t[103]=g,t[104]=le):le=t[104];let ue;t[105]!==R||t[106]!==j||t[107]!==g?(ue=g&&!j&&R?(0,Z.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]=g,t[108]=ue):ue=t[108];let K;t[109]!==k||t[110]!==g?(K=g&&k?(0,Z.jsx)(`pre`,{className:`max-h-48 min-w-0 overflow-y-auto overflow-x-hidden rounded-md bg-surface-hover/60 p-2 whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-fg-muted [overflow-wrap:anywhere] dark:bg-surface-hover/35`,children:k}):null,t[109]=k,t[110]=g,t[111]=K):K=t[111];let q;t[112]!==o||t[113]!==_||t[114]!==O?(q=O?(0,Z.jsx)(zg,{path:O,conversationId:o,label:_===`zh`?`查看完整输出`:`View full output`}):null,t[112]=o,t[113]=_,t[114]=O,t[115]=q):q=t[115];let de;t[116]!==a||t[117]!==j||t[118]!==A||t[119]!==B||t[120]!==W||t[121]!==i.stepDetails||t[122]!==r?(de=W?(0,Z.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer select-none text-fg-subtle underline-offset-2 hover:text-fg-muted group-open:text-fg-muted`,children:j?a.rawDetails:i.stepDetails}),(0,Z.jsxs)(`div`,{className:`mt-2 max-h-48 w-full min-w-0 max-w-full overflow-y-auto overflow-x-hidden rounded-md bg-surface-hover/60 p-2 font-mono dark:bg-surface-hover/35`,children:[B?(0,Z.jsxs)(`div`,{className:`mb-2 min-w-0`,children:[(0,Z.jsx)(`div`,{className:`mb-0.5 text-[10px] uppercase tracking-wide text-fg-disabled`,children:r.input}),(0,Z.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-fg-muted [overflow-wrap:anywhere]`,children:B})]}):null,(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`mb-0.5 text-[10px] uppercase tracking-wide text-fg-disabled`,children:r.output}),(0,Z.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-fg-muted [overflow-wrap:anywhere]`,children:A||r.noOutput})]})]})]}):null,t[116]=a,t[117]=j,t[118]=A,t[119]=B,t[120]=W,t[121]=i.stepDetails,t[122]=r,t[123]=de):de=t[123];let fe;t[124]!==ae||t[125]!==oe||t[126]!==se||t[127]!==ce||t[128]!==le||t[129]!==ue||t[130]!==K||t[131]!==q||t[132]!==de?(fe=(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-1.5`,children:[ae,oe,se,ce,le,ue,K,q,de]}),t[124]=ae,t[125]=oe,t[126]=se,t[127]=ce,t[128]=le,t[129]=ue,t[130]=K,t[131]=q,t[132]=de,t[133]=fe):fe=t[133];let pe;return t[134]!==G||t[135]!==fe?(pe=(0,Z.jsx)(`div`,{className:G,children:fe}),t[134]=G,t[135]=fe,t[136]=pe):pe=t[136],pe}function m_(e){return e.language}function h_(e){return e.showRawToolData}function g_(e){return e+1}function __(e){let t=(0,X.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(Ga,{delayDuration:300,skipDelayDuration:100,children:n}),t[0]=n,t[1]=r),r}function v_(e){let t=(0,X.c)(7),{label:n,children:r}=e,i;t[0]===r?i=t[1]:(i=(0,Z.jsx)(Ya,{asChild:!0,children:r}),t[0]=r,t[1]=i);let a;t[2]===n?a=t[3]:(a=(0,Z.jsx)(Ka,{children:(0,Z.jsx)(Ja,{side:`top`,sideOffset:7,collisionPadding:12,className:`z-[100] max-w-[min(18rem,90vw)] rounded-md border border-edge bg-surface-overlay px-2.5 py-1.5 text-xs text-fg shadow-popover`,children:n})}),t[2]=n,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Z.jsxs)(qa,{children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function y_(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 b_(e){return e.filter(e=>e.type===`thinking`||e.type===`tool_use`)}function x_(e){let t=Nr(e,`running`);return t.category===`web`&&t.action===`search`}function S_(e){let t=[];for(let n of e)if(!(!x_(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 C_(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function w_(e){let t=C_(e);return t?T_(an(t.delivery)??an(C_(t.details)?.delivery)??an(e),t):null}function T_(e,t){let n=e?.primary;if(!e||n?.kind!==`automation`||n.runId||e.operation!==`started`)return e;let r=C_(t),i=C_((C_(r?.result)??r)?.run);return i?.automationId!==n.id||typeof i.id!=`string`||!i.id?e:{...e,primary:{...n,runId:i.id}}}function E_(e){let t=w_(e.details);if(t)return t;let n=ma(e.result),r=w_(n.details);if(r)return r;let i=tn(n.text);if(i)try{return T_(i,JSON.parse(n.text.split(`
26
+ Open in xopc:`)[0]))}catch{return i}if(typeof e.result==`string`)try{return w_(JSON.parse(e.result))}catch{return null}return w_(e.result)}function D_(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 O_(e){return e.normalize(`NFKC`).trim().replace(/\s+/g,` `).toLowerCase()}function k_(e){return e.operation!==`opened`||e.presentation?.kind===`diff`||e.presentation?.kind===`inline_app`||e.presentation?.kind===`inline_preview`}function A_(e){return e.flatMap(({key:e,delivery:t})=>t.presentation?.kind===`diff`?[{key:e,presentation:t.presentation}]:[])}function j_(e){return{truncated:e.flatMap(({delivery:e})=>e.presentation?.kind===`table`?[e.presentation]:[]).some(e=>e.truncated)}}function M_(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 N_(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 P_(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=O_(e.reference.title);t&&i.set(t,e.reference.id)}return r.filter(e=>{if(e.reference.kind!==`task`)return!0;let t=O_(e.reference.title);return!t||i.get(t)===e.reference.id})}function F_(e){return k_(e)?e.presentation||e.related?.length?!0:e.primary?e.primary.kind!==`note`||e.operation===`created`||e.operation===`updated`:!1:!1}function I_({message:e,isStreaming:t,reasoningLevel:n}){let r=In(e.content??[],{includePending:!0}),i=new Set(r),a=Lh(b_(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=E_(e);t&&F_(t)&&u.set(e.id,t)}let d=[...u].map(([e,t])=>({key:e,delivery:t})),f=y_(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=[...Tm(_),...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:S_(c)}}function L_(e){let t=(0,X.c)(10),{blocks:n,sources:r,className:i}=e,a=n===void 0?[]:n,o=i===void 0?`mt-6`:i,s=y(h(B_)),c=a.filter(z_),l=r??S_(c);if(l.length===0)return null;let u=s.chat.searchSourcesHeading.replace(`{{count}}`,String(l.length)),d;t[0]===u?d=t[1]:(d=(0,Z.jsx)(`p`,{className:`mb-3 text-xs font-medium text-fg-muted`,children:u}),t[0]=u,t[1]=d);let f;t[2]===l?f=t[3]:(f=l.map(R_),t[2]=l,t[3]=f);let p;t[4]===f?p=t[5]:(p=(0,Z.jsx)(`ol`,{className:`space-y-3`,children:f}),t[4]=f,t[5]=p);let m;return t[6]!==o||t[7]!==d||t[8]!==p?(m=(0,Z.jsxs)(`div`,{className:o,children:[d,p]}),t[6]=o,t[7]=d,t[8]=p,t[9]=m):m=t[9],m}function R_(e,t){let n=(()=>{try{return new URL(e.url).hostname}catch{return``}})(),r=n?`https://www.google.com/s2/favicons?domain=${n}&sz=16`:void 0;return(0,Z.jsxs)(`li`,{className:`flex min-w-0 gap-2.5`,children:[(0,Z.jsxs)(`span`,{className:`mt-0.5 shrink-0 text-xs text-fg-disabled`,children:[t+1,`.`]}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-1.5`,children:[r?(0,Z.jsx)(`img`,{src:r,alt:``,className:`mt-0.5 size-3.5 shrink-0 rounded-sm`,"aria-hidden":!0}):null,(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`min-w-0 flex-1 break-words text-xs font-medium text-accent-fg [overflow-wrap:anywhere] hover:underline`,children:e.title})]}),e.snippet?(0,Z.jsx)(`p`,{className:`mt-0.5 line-clamp-4 text-xs break-words text-fg-muted [overflow-wrap:anywhere]`,children:e.snippet}):null]})]},e.url)}function z_(e){return e.type===`tool_use`}function B_(e){return e.language}var V_=(0,Q.createContext)(!1);function H_(e){let t=(0,X.c)(41),{entries:n,language:r,renderEntry:i}=e,[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null),l=(0,Q.useRef)(null),u=(0,Q.useRef)(0),d=(0,Q.useRef)(!1),f=c(),p;t[0]===f.search?p=t[1]:(p=new URLSearchParams(f.search).has(Ye),t[0]=f.search,t[1]=p);let m=p,h,g;t[2]!==n.length||t[3]!==r?(h=y(r).chat.productDelivery,g=h.relatedTaskCount.replace(`{{count}}`,String(n.length)),t[2]=n.length,t[3]=r,t[4]=h,t[5]=g):(h=t[4],g=t[5]);let _=g,v=a&&!m,O;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(O=e=>{d.current=!e,o(e)},t[6]=O):O=t[6];let k;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,Z.jsx)(ws,{}),t[7]=k):k=t[7];let A;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(te,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[8]=A):A=t[8];let j;t[9]===_?j=t[10]:(j=(0,Z.jsx)(x,{asChild:!0,children:(0,Z.jsx)(`button`,{ref:s,type:`button`,className:Mo,children:(0,Z.jsx)(Po,{icon:k,title:_,trailing:A})})}),t[9]=_,t[10]=j);let M;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Z.jsx)(b,{className:`fixed inset-0 z-[80] bg-scrim`}),t[11]=M):M=t[11];let N,P;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(P=e=>{e.preventDefault(),l.current?.focus({preventScroll:!0})},N=e=>{e.preventDefault(),d.current&&s.current?.focus({preventScroll:!0})},t[12]=N,t[13]=P):(N=t[12],P=t[13]);let F;t[14]===_?F=t[15]:(F=(0,Z.jsx)(E,{ref:l,tabIndex:-1,className:`min-w-0 flex-1 font-medium text-fg focus:outline-none`,children:_}),t[14]=_,t[15]=F);let I;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(Gt,{className:`size-4`,"aria-hidden":!0}),t[16]=I):I=t[16];let L;t[17]===h.closeTaskList?L=t[18]:(L=(0,Z.jsx)(C,{"aria-label":h.closeTaskList,className:`flex size-11 shrink-0 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:I}),t[17]=h.closeTaskList,t[18]=L);let R;t[19]!==F||t[20]!==L?(R=(0,Z.jsxs)(`header`,{className:`flex shrink-0 items-center gap-3 border-b border-edge px-4 py-3`,children:[F,L]}),t[19]=F,t[20]=L,t[21]=R):R=t[21];let z;t[22]===h.relatedTasksDescription?z=t[23]:(z=(0,Z.jsx)(S,{className:`sr-only`,children:h.relatedTasksDescription}),t[22]=h.relatedTasksDescription,t[23]=z);let B,V;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(B=e=>{e&&(e.scrollTop=u.current)},V=e=>{u.current=e.currentTarget.scrollTop},t[24]=B,t[25]=V):(B=t[24],V=t[25]);let H;if(t[26]!==n||t[27]!==i){let e;t[29]===i?e=t[30]:(e=e=>i(e,!0),t[29]=i,t[30]=e),H=n.map(e),t[26]=n,t[27]=i,t[28]=H}else H=t[28];let U;t[31]===H?U=t[32]:(U=(0,Z.jsx)(`div`,{"data-task-delivery-list":!0,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,ref:B,onScroll:V,children:(0,Z.jsx)(`ul`,{className:`${No} p-3`,children:H})}),t[31]=H,t[32]=U);let W;t[33]!==R||t[34]!==z||t[35]!==U?(W=(0,Z.jsxs)(w,{children:[M,(0,Z.jsxs)(T,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(40rem,calc(100dvh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay focus:outline-none`,onOpenAutoFocus:P,onCloseAutoFocus:N,children:[R,z,U]})]}),t[33]=R,t[34]=z,t[35]=U,t[36]=W):W=t[36];let G;return t[37]!==W||t[38]!==v||t[39]!==j?(G=(0,Z.jsx)(`li`,{className:`min-w-0 max-w-full`,"data-product-task-group":!0,children:(0,Z.jsxs)(D,{open:v,onOpenChange:O,children:[j,W]})}),t[37]=W,t[38]=v,t[39]=j,t[40]=G):G=t[40],G}var U_={task:ws,project:Ee,note:xs,automation:W,local_app:k,chat_preview:gs,file:Te,session:bs,settings:Ft};function W_(e,t){let n=e?.trim();return n?y(t).chat.productDelivery.statuses[n.toLowerCase()]??n:null}function G_(e,t,n){let r=y(n).chat.productDelivery.operations[e.operation],i=W_(t.status,n);return i&&e.operation===`opened`?i:i&&i.toLowerCase()!==r.toLowerCase()?`${r} · ${i}`:i??r}function K_(e,t,n){let r=y(n).chat.productDelivery.taskStates;if(t.phase===`closed`)return t.resolution===`done`?r.completed:r.closed;if(t.attention?.length)return r.blocked;let i={allocating:r.allocating,queued:r.queued,running:r.running,verifying:r.verifying,waiting:r.waiting,blocked:r.blocked,completed:r.completed};return t.operationalState&&i[t.operationalState]||(e.operation===`completed`?r.completed:e.operation===`failed`?r.failed:e.operation===`started`?r.assigned:r.ready)}function q_(e,t){let n=y(t).chat.productDelivery;return n.continuePrompt.replace(/\{\{(kind|title|id)\}\}/g,(r,i)=>({kind:t===`en`?n.kinds[e.kind].toLowerCase():n.kinds[e.kind],title:e.title,id:e.id})[i])}function J_(e){let t=(0,X.c)(90),{delivery:n,reference:r,language:i,conversationId:a,projectId:o,fullTitle:s}=e,l=s!==void 0&&s,u=d(),f=c(),p=Ni(X_),h=U_[r.kind],g;t[0]===r?g=t[1]:(g=en(r),t[0]=r,t[1]=g);let _=g,v;t[2]!==r.capabilities||t[3]!==r.id||t[4]!==r.kind?(v=r.kind===`file`&&r.capabilities.includes(`preview`)?D_(r.id):null,t[2]=r.capabilities,t[3]=r.id,t[4]=r.kind,t[5]=v):v=t[5];let b=v,x;t[6]!==a||t[7]!==b||t[8]!==o?(x=b&&(a?.trim()||o?.trim()),t[6]=a,t[7]=b,t[8]=o,t[9]=x):x=t[9];let S=!!x,C;t[10]!==S||t[11]!==r.capabilities||t[12]!==_?(C=S||!!(_&&r.capabilities.includes(`open`)),t[10]=S,t[11]=r.capabilities,t[12]=_,t[13]=C):C=t[13];let w=C,T;t[14]!==r.capabilities||t[15]!==r.kind?(T=r.kind!==`note`&&r.kind!==`task`&&r.capabilities.includes(`continue_in_chat`),t[14]=r.capabilities,t[15]=r.kind,t[16]=T):T=t[16];let E=T,D=n.operation===`failed`,O=m(Y_),k;t[17]!==r.id||t[18]!==r.kind||t[19]!==O?(k=r.kind===`task`?[`task-delivery`,r.id,O]:null,t[17]=r.id,t[18]=r.kind,t[19]=O,t[20]=k):k=t[20];let A;t[21]===r.id?A=t[22]:(A=()=>ei(r.id),t[21]=r.id,t[22]=A);let j;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(j={revalidateOnFocus:!0},t[23]=j):j=t[23];let M=Gr(k,A,j),N;t[24]!==r.id||t[25]!==r.kind||t[26]!==M?(N=()=>{if(r.kind!==`task`)return;let e=e=>{let t=e.detail?.taskId;(!t||t===r.id)&&M.mutate()};return window.addEventListener(`task-changed-v2`,e),window.addEventListener(`gateway-realtime-connected`,e),()=>{window.removeEventListener(`task-changed-v2`,e),window.removeEventListener(`gateway-realtime-connected`,e)}},t[24]=r.id,t[25]=r.kind,t[26]=M,t[27]=N):N=t[27];let P;t[28]!==r.id||t[29]!==r.kind||t[30]!==M.mutate?(P=[r.kind,r.id,M.mutate],t[28]=r.id,t[29]=r.kind,t[30]=M.mutate,t[31]=P):P=t[31],(0,Q.useEffect)(N,P);let F;t[32]!==n||t[33]!==i||t[34]!==r||t[35]!==M.data?.attention||t[36]!==M.data?.operationalState||t[37]!==M.data?.task?(F=r.kind===`task`?K_(n,{phase:M.data?.task.phase,resolution:M.data?.task.resolution,operationalState:M.data?.operationalState??r.status,attention:M.data?.attention},i):G_(n,r,i),t[32]=n,t[33]=i,t[34]=r,t[35]=M.data?.attention,t[36]=M.data?.operationalState,t[37]=M.data?.task,t[38]=F):F=t[38];let I=F;if(r.kind===`automation`&&n.operation!==`failed`){let e;return t[39]!==i||t[40]!==r.id||t[41]!==r.runId?(e=(0,Z.jsx)(`li`,{className:`min-w-0 max-w-full`,children:(0,Z.jsx)(Fo,{automationId:r.id,runId:r.runId,language:i,embedded:!0})}),t[39]=i,t[40]=r.id,t[41]=r.runId,t[42]=e):e=t[42],e}let L;t[43]!==S||t[44]!==a||t[45]!==b||t[46]!==f||t[47]!==u||t[48]!==o||t[49]!==r.id||t[50]!==r.kind||t[51]!==r.projectId||t[52]!==r.revision||t[53]!==_||t[54]!==p?(L=()=>{if(b&&S){p(b,null,o,a);return}if(r.kind===`task`){u(et(`${f.pathname}${f.search}`,r.id));return}if(r.kind===`note`){u(tt(`${f.pathname}${f.search}`,r.id));return}if(_){let e=new URL(_,`https://xopc.local`);r.projectId&&e.searchParams.set(`projectId`,r.projectId),r.kind===`local_app`&&r.revision&&/^[a-f0-9]{64}$/.test(r.revision)&&e.searchParams.set(`sourceHash`,r.revision),u(Xe(Qe(`${f.pathname}${f.search}`,`${e.pathname}${e.search}`),`${f.pathname}${f.search}`))}},t[43]=S,t[44]=a,t[45]=b,t[46]=f,t[47]=u,t[48]=o,t[49]=r.id,t[50]=r.kind,t[51]=r.projectId,t[52]=r.revision,t[53]=_,t[54]=p,t[55]=L):L=t[55];let R=L,z=r.kind,B=w?R:void 0,V=!w,H;t[56]===r.summary?H=t[57]:(H=r.summary?.trim(),t[56]=r.summary,t[57]=H);let U;t[58]!==I||t[59]!==r.title||t[60]!==H?(U=[r.title,I,H].filter(Boolean),t[58]=I,t[59]=r.title,t[60]=H,t[61]=U):U=t[61];let W=U.join(` · `),G=w?`cursor-pointer`:`cursor-default`,ee=D&&`text-danger`,ne;t[62]!==G||t[63]!==ee?(ne=Y(Mo,G,ee),t[62]=G,t[63]=ee,t[64]=ne):ne=t[64];let re=D?`text-danger`:void 0,ie;t[65]!==h||t[66]!==re?(ie=(0,Z.jsx)(h,{strokeWidth:1.75,className:re}),t[65]=h,t[66]=re,t[67]=ie):ie=t[67];let ae;t[68]===w?ae=t[69]:(ae=w?(0,Z.jsx)(te,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}):null,t[68]=w,t[69]=ae);let oe;t[70]!==I||t[71]!==l||t[72]!==r.title||t[73]!==ie||t[74]!==ae?(oe=(0,Z.jsx)(Po,{icon:ie,title:r.title,meta:I,fullTitle:l,trailing:ae}),t[70]=I,t[71]=l,t[72]=r.title,t[73]=ie,t[74]=ae,t[75]=oe):oe=t[75];let se;t[76]!==B||t[77]!==V||t[78]!==W||t[79]!==ne||t[80]!==oe?(se=(0,Z.jsx)(`button`,{type:`button`,onClick:B,disabled:V,title:W,className:ne,children:oe}),t[76]=B,t[77]=V,t[78]=W,t[79]=ne,t[80]=oe,t[81]=se):se=t[81];let ce;t[82]!==E||t[83]!==i||t[84]!==r?(ce=E?(0,Z.jsx)(`button`,{type:`button`,className:Y(`inline-flex min-h-11 max-w-full cursor-pointer items-center rounded-[1.125rem] px-3 text-xs text-accent-fg`,`hover:bg-accent-soft active:bg-accent-soft/70`,ca.transition,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`),onClick:()=>Wp(q_(r,i)),children:y(i).chat.productDelivery.continue}):null,t[82]=E,t[83]=i,t[84]=r,t[85]=ce):ce=t[85];let le;return t[86]!==r.kind||t[87]!==se||t[88]!==ce?(le=(0,Z.jsxs)(`li`,{className:`flex max-w-full min-w-0 flex-wrap items-center gap-2`,"data-product-delivery":z,children:[se,ce]}),t[86]=r.kind,t[87]=se,t[88]=ce,t[89]=le):le=t[89],le}function Y_(e){return e.conversationId}function X_(e){return e.setPath}function Z_(e){let t=(0,X.c)(23),{entries:n,language:r,conversationId:i,projectId:a}=e,o;t[0]!==n.length||t[1]!==r?(o=y(r).chat.turnOutcome.fileCount.replace(`{{count}}`,String(n.length)),t[0]=n.length,t[1]=r,t[2]=o):o=t[2];let s=o,c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=Y(Mo,`cursor-pointer list-none`),t[3]=c):c=t[3];let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(fs,{strokeWidth:1.75}),t[4]=l):l=t[4];let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(te,{className:`size-3.5 shrink-0 text-fg-subtle transition-transform duration-150 group-open:rotate-90 motion-reduce:transition-none`,"aria-hidden":!0}),t[5]=u):u=t[5];let d;t[6]===s?d=t[7]:(d=(0,Z.jsx)(`summary`,{className:c,children:(0,Z.jsx)(Po,{icon:l,title:s,trailing:u})}),t[6]=s,t[7]=d);let f;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(f=Y(No,jo),t[8]=f):f=t[8];let p;if(t[9]!==i||t[10]!==n||t[11]!==r||t[12]!==a){let e;t[14]!==i||t[15]!==r||t[16]!==a?(e=e=>{let{key:t,delivery:n,reference:o}=e;return(0,Z.jsx)(J_,{delivery:n,reference:o,language:r,conversationId:i,projectId:a},t)},t[14]=i,t[15]=r,t[16]=a,t[17]=e):e=t[17],p=n.map(e),t[9]=i,t[10]=n,t[11]=r,t[12]=a,t[13]=p}else p=t[13];let m;t[18]===p?m=t[19]:(m=(0,Z.jsx)(`ul`,{className:f,children:p}),t[18]=p,t[19]=m);let h;return t[20]!==d||t[21]!==m?(h=(0,Z.jsx)(`li`,{className:`min-w-0 max-w-full`,"data-product-file-group":!0,children:(0,Z.jsxs)(`details`,{className:`group`,children:[d,m]})}),t[20]=d,t[21]=m,t[22]=h):h=t[22],h}function Q_(e){let t=(0,X.c)(9),{deliveries:n,language:r,excludedReferenceKeys:i,conversationId:a,projectId:o}=e,s,c;if(t[0]!==a||t[1]!==n||t[2]!==i||t[3]!==r||t[4]!==o){c=Symbol.for(`react.early_return_sentinel`);bb0:{let e=P_(n,i),t=e.filter(nv),l=e.findIndex(tv),u=e.filter(ev),d=e.findIndex($_);if(e.length===0){c=null;break bb0}s=e.map((e,n)=>{let{key:i,delivery:s,reference:c}=e;return c.kind===`task`&&u.length>3?n===d?(0,Z.jsx)(H_,{entries:u,language:r,renderEntry:(e,t)=>(0,Z.jsx)(J_,{delivery:e.delivery,reference:e.reference,language:r,conversationId:a,projectId:o,fullTitle:t},e.key)},`task-delivery-group`):null:c.kind!==`file`||t.length===1?(0,Z.jsx)(J_,{delivery:s,reference:c,language:r,conversationId:a,projectId:o},i):n===l?(0,Z.jsx)(Z_,{entries:t,language:r,conversationId:a,projectId:o},`file-delivery-group`):null})}t[0]=a,t[1]=n,t[2]=i,t[3]=r,t[4]=o,t[5]=s,t[6]=c}else s=t[5],c=t[6];if(c!==Symbol.for(`react.early_return_sentinel`))return c;let l;return t[7]===s?l=t[8]:(l=(0,Z.jsx)(Z.Fragment,{children:s}),t[7]=s,t[8]=l),l}function $_(e){let{reference:t}=e;return t.kind===`task`}function ev(e){let{reference:t}=e;return t.kind===`task`}function tv(e){let{reference:t}=e;return t.kind===`file`}function nv(e){let{reference:t}=e;return t.kind===`file`}function rv(e){let t=(0,X.c)(22),{presentation:n}=e,r=h(iv),i;t[0]===r?i=t[1]:(i=y(r),t[0]=r,t[1]=i);let a=i.chat.productDelivery,o=a.diffPreview,s;t[2]===a.proposedChanges?s=t[3]:(s=(0,Z.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:a.proposedChanges}),t[2]=a.proposedChanges,t[3]=s);let c;t[4]===n.title?c=t[5]:(c=(0,Z.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:n.title}),t[4]=n.title,t[5]=c);let l;if(t[6]!==n.edits||t[7]!==a.replaceRange){let e;t[9]===a.replaceRange?e=t[10]:(e=(e,t)=>(0,Z.jsxs)(`details`,{className:`rounded border border-edge-subtle p-2`,children:[(0,Z.jsxs)(`summary`,{className:`cursor-pointer rounded text-xs text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[a.replaceRange,` `,e.from,`–`,e.to]}),(0,Z.jsx)(`pre`,{className:`mt-2 whitespace-pre-wrap [overflow-wrap:anywhere] font-mono text-xs text-fg`,children:e.text})]},t),t[9]=a.replaceRange,t[10]=e),l=n.edits.map(e),t[6]=n.edits,t[7]=a.replaceRange,t[8]=l}else l=t[8];let u;t[11]===l?u=t[12]:(u=(0,Z.jsx)(`div`,{className:`mt-2 max-h-80 space-y-2 overflow-y-auto`,children:l}),t[11]=l,t[12]=u);let d;t[13]!==n.truncated||t[14]!==a.partialDiff?(d=n.truncated?(0,Z.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-fg-muted`,children:a.partialDiff}):null,t[13]=n.truncated,t[14]=a.partialDiff,t[15]=d):d=t[15];let f;return t[16]!==a.diffPreview||t[17]!==s||t[18]!==c||t[19]!==u||t[20]!==d?(f=(0,Z.jsxs)(`section`,{className:`mt-2 rounded-lg border border-edge bg-surface-panel p-3`,"aria-label":o,children:[s,c,u,d]}),t[16]=a.diffPreview,t[17]=s,t[18]=c,t[19]=u,t[20]=d,t[21]=f):f=t[21],f}function iv(e){return e.language}function av({previewId:e,reference:t,sourceHash:n,preferredHeight:r,language:i}){let a=d(),o=c(),s=(0,Q.useRef)(null),[l,u]=(0,Q.useState)(0),[f,m]=(0,Q.useState)(`booting`),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)([]),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(null),w=Math.min(720,Math.max(240,r)),T=ra(e),E=Gr(T.active?[`inline-local-app-snapshot`,t.id,n]:null,()=>Uo(t.id,n),{revalidateOnFocus:!1,shouldRetryOnError:!1});(0,Q.useEffect)(()=>{let e=s.current;if(!e||!E.data?.previewUrl)return;m(`booting`),g(null),v([]);let t=window.setTimeout(()=>{m(e=>e===`booting`?`timeout`:e)},7e3),n=Bo(e,e=>{let t=on(e);if(t){if(t.type===`ready`){m(`healthy`);return}if(t.type===`error`){g(t.detail),m(`failed`),v(e=>[...e,{phase:`runtime`,message:Vo(t.detail),code:t.detail.kind}].slice(-20));return}if(t.type===`acceptance`&&t.detail.status===`failed`){m(`failed`),v(e=>[...e,...t.detail.checks.filter(e=>e.status===`failed`).map(e=>({phase:`acceptance`,code:e.id,message:e.message}))].slice(-20));return}t.type===`criteria`&&t.detail.status===`failed`&&(m(`failed`),v(e=>[...e,...t.detail.scenarios.filter(e=>e.status===`failed`).map(e=>({phase:e.failureKind===`runner`?`runner`:`acceptance`,code:e.id,message:`${e.name}: ${e.message}`}))].slice(-20)))}});return()=>{window.clearTimeout(t),n()}},[l,E.data?.previewUrl]);let D=()=>{let e=en(t);e&&a(Qe(`${o.pathname}${o.search}`,`${e}&sourceHash=${encodeURIComponent(n)}`))};if(!T.active)return(0,Z.jsxs)(`section`,{ref:T.containerRef,className:`content-block-action-scope mt-3 overflow-hidden rounded-2xl border border-edge bg-surface-panel`,"data-inline-local-app":t.id,children:[(0,Z.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,title:t.title,children:t.title}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:T.state===`queued`?i===`zh`?`正在等待预览资源`:`Waiting for a preview slot`:i===`zh`?`预览尚未加载`:`Preview not loaded`})]}),(0,Z.jsx)(pi,{variant:`ghost`,className:`content-block-action`,onClick:D,title:i===`zh`?`查看预览`:`Preview`,"aria-label":i===`zh`?`查看预览`:`Preview`,children:(0,Z.jsx)(xe,{className:`size-4`,"aria-hidden":!0})})]}),(0,Z.jsx)(`div`,{className:`grid place-items-center bg-surface-base`,style:{height:w},children:(0,Z.jsx)(pi,{variant:`secondary`,onClick:T.activate,children:i===`zh`?`加载交互预览`:`Load interactive preview`})})]});if(E.isLoading)return(0,Z.jsxs)(`section`,{ref:T.containerRef,className:`mt-3 overflow-hidden rounded-2xl border border-edge bg-surface-panel`,"aria-label":y(i).chat.productDelivery.loadingAppPreview,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,Z.jsx)(qt,{className:`h-5 w-40`}),(0,Z.jsx)(qt,{className:`h-9 w-24`})]}),(0,Z.jsx)(qt,{className:`m-3 w-[calc(100%-1.5rem)]`,style:{height:w}})]});let O=E.data;if(!O){let e=E.error,t=e instanceof Error?e.message:i===`zh`?`无法加载应用预览`:`Unable to load app preview`;return(0,Z.jsx)(`section`,{ref:T.containerRef,className:`mt-3 rounded-2xl border border-danger/30 bg-danger-soft p-4 text-sm text-danger`,role:`alert`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Vt,{className:`size-4`}),t]})})}let k=O.validation.issues.map(e=>({phase:`build`,code:e.code,message:e.message}))??[],A=f===`timeout`?[{phase:`boot`,code:`boot_timeout`,message:y(i).chat.productDelivery.previewTimeout}]:[],j=[...k,..._,...A],M=O.status===`invalid`||O.validation.status===`failed`,N=M||f===`failed`||f===`timeout`,P=M?i===`zh`?`校验失败`:`Validation failed`:f===`healthy`?i===`zh`?`运行正常`:`Running`:f===`booting`?i===`zh`?`正在启动`:`Starting`:f===`timeout`?i===`zh`?`启动超时`:`Start timed out`:i===`zh`?`运行错误`:`Runtime error`,F=()=>{C(null),u(e=>e+1)},I=async()=>{if(j.length){x(!0),C(null);try{let e=await Wo(t.id,{sourceHash:O.sourceHash,locale:i,diagnostics:j});if(e.action===`retry`){F();return}let n=await Ho(t.id);a(zo(n,e.prompt))}catch(e){C(e instanceof Error?e.message:String(e))}finally{x(!1)}}};return(0,Z.jsxs)(`section`,{ref:T.containerRef,className:`content-block-action-scope mt-3 overflow-hidden rounded-2xl border border-edge bg-surface-panel`,"data-inline-local-app":t.id,children:[(0,Z.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,title:t.title,children:t.title}),(0,Z.jsx)(`p`,{className:Y(`mt-0.5 text-xs`,N?`text-danger`:`text-fg-muted`),"aria-live":`polite`,children:P})]}),(0,Z.jsx)(pi,{variant:`ghost`,className:`content-block-action`,onClick:F,"data-action-visible":N,title:i===`zh`?`重新加载预览`:`Reload preview`,"aria-label":i===`zh`?`重新加载预览`:`Reload preview`,children:(0,Z.jsx)(At,{className:`size-4`,"aria-hidden":!0})}),(0,Z.jsx)(pi,{variant:`ghost`,className:`content-block-action`,onClick:D,title:i===`zh`?`查看预览`:`Preview`,"aria-label":i===`zh`?`查看预览`:`Preview`,children:(0,Z.jsx)(xe,{className:`size-4`,"aria-hidden":!0})})]}),(0,Z.jsxs)(`div`,{className:`relative bg-surface-base`,style:{height:w},children:[O.previewUrl?(0,Z.jsx)(`iframe`,{ref:s,title:i===`zh`?`${t.title} 交互预览`:`${t.title} interactive preview`,src:p(O.previewUrl),sandbox:`allow-scripts allow-forms`,className:`h-full w-full border-0 bg-white`},l):null,O.previewUrl&&f===`booting`?(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-0 grid place-items-center bg-surface-base/75`,children:(0,Z.jsx)(qt,{className:`h-10 w-40`})}):null]}),N?(0,Z.jsxs)(`footer`,{className:`border-t border-danger/20 bg-danger-soft/60 px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Z.jsx)(`p`,{className:`min-w-0 flex-1 text-xs text-danger`,children:h?.message??j[0]?.message??(i===`zh`?`预览校验失败`:`Preview validation failed`)}),(0,Z.jsxs)(pi,{variant:`secondary`,className:`min-h-9 px-3 text-xs`,disabled:b||j.length===0,onClick:()=>void I(),children:[(0,Z.jsx)(Wt,{className:`size-4`}),b?i===`zh`?`生成修复建议…`:`Preparing fix…`:i===`zh`?`让 Coder 修复`:`Ask Coder to fix`]})]}),S?(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-danger`,role:`alert`,children:S}):null]}):null]})}async function ov(e,t){return(await g(p(`/api/chat-previews/${encodeURIComponent(e)}/revisions/${encodeURIComponent(t)}`))).revision}async function sv(e,t){return(await g(p(`/api/chat-previews/${encodeURIComponent(e)}/fix-guidance`),{method:`POST`,body:JSON.stringify(t)})).guidance}async function cv(e,t){return(await g(p(`/api/chat-previews/${encodeURIComponent(e)}/promote`),{method:`POST`,body:JSON.stringify({sourceHash:t})})).app}function lv(e,t){return e.replace(RegExp(`</${t}`,`gi`),`<\\/${t}`)}function uv(e){let t=rn.safeParse(e);return t.success?t.data:null}function dv(e,t){let n=`(() => {
27
27
  const channel = ${JSON.stringify(t)};
28
28
  const bufferedErrors = [];
29
29
  const send = (type, detail = {}) => parent.postMessage({
@@ -51,21 +51,21 @@ Open in xopc:`)[0]))}catch{return i}if(typeof e.result==`string`)try{return C_(J
51
51
  })();`;return`<!doctype html>
52
52
  <html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
53
53
  <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'">
54
- <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}${cv(e.styles,`style`)}</style>
54
+ <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}${lv(e.styles,`style`)}</style>
55
55
  </head><body>${e.markup}
56
- <script>${cv(n,`script`)}<\/script>
57
- <script>${cv(e.script,`script`)}<\/script>
58
- </body></html>`}function dv(e,t,n){let r=r=>{if(r.source!==e.contentWindow)return;let i=lv(r.data);!i||i.channel!==t||n(i)};return window.addEventListener(`message`,r),()=>window.removeEventListener(`message`,r)}function fv({leaseId:e,reference:t,sourceHash:n,preferredHeight:r,language:i}){let a=d(),o=c(),s=(0,Q.useRef)(null),[l,u]=(0,Q.useState)(0),[f,p]=(0,Q.useState)(`booting`),[m,h]=(0,Q.useState)([]),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(null),b=ra(e),x=Math.min(720,Math.max(240,r)),S=(0,Q.useMemo)(()=>crypto.randomUUID(),[l,n]),C=Gr(b.active?[`chat-preview-revision`,t.id,n]:null,()=>av(t.id,n),{revalidateOnFocus:!1,shouldRetryOnError:!1}),w=C.data?uv(C.data,S):void 0;(0,Q.useEffect)(()=>{let e=s.current;if(!e||!w)return;p(`booting`),h([]);let t=window.setTimeout(()=>{p(e=>e===`booting`?`timeout`:e)},7e3),n=dv(e,S,t=>{t.type===`ready`&&p(`healthy`),t.type===`resize`&&(e.style.height=`${Math.min(720,Math.max(240,t.height))}px`),t.type===`error`&&(p(`failed`),h(e=>[...e,t.diagnostic].slice(-20)))});return()=>{window.clearTimeout(t),n()}},[S,w]);let T=()=>{y(null),u(e=>e+1)},E=async()=>{if(m.length){_(`fix`),y(null);try{Wp((await ov(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 sv(t.id,n);a(Qe(`${o.pathname}${o.search}`,`/local-apps/${encodeURIComponent(e.id)}`))}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(null)}},O=`content-block-action-scope mt-3 overflow-hidden rounded-2xl border border-edge bg-surface-panel`;if(!b.active)return(0,Z.jsxs)(`section`,{ref:b.containerRef,className:O,"data-inline-chat-preview":t.id,children:[(0,Z.jsxs)(`header`,{className:`border-b border-edge-subtle px-4 py-3`,children:[(0,Z.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:t.title}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:b.state===`queued`?i===`zh`?`正在等待预览资源`:`Waiting for a preview slot`:i===`zh`?`预览尚未加载`:`Preview not loaded`})]}),(0,Z.jsx)(`div`,{className:`grid place-items-center bg-surface-base`,style:{height:x},children:(0,Z.jsx)(pi,{variant:`secondary`,className:`min-h-11`,onClick:b.activate,children:i===`zh`?`加载交互预览`:`Load interactive preview`})})]});if(C.isLoading)return(0,Z.jsxs)(`section`,{ref:b.containerRef,className:O,"aria-busy":`true`,"aria-label":i===`zh`?`正在加载预览`:`Loading preview`,children:[(0,Z.jsx)(`div`,{className:`border-b border-edge-subtle px-4 py-3`,children:(0,Z.jsx)(qt,{className:`h-5 w-40`})}),(0,Z.jsx)(qt,{className:`m-3 w-[calc(100%-1.5rem)]`,style:{height:x}})]});if(!C.data||!w){let e=C.error instanceof Error?C.error.message:i===`zh`?`无法加载预览`:`Unable to load preview`;return(0,Z.jsx)(`section`,{ref:b.containerRef,className:`mt-3 rounded-2xl border border-danger/30 bg-danger-soft p-4 text-sm text-danger`,role:`alert`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Vt,{className:`size-4`}),e]})})}let k=f===`failed`||f===`timeout`,A=f===`healthy`?i===`zh`?`运行正常`:`Running`:f===`booting`?i===`zh`?`正在启动`:`Starting`:f===`timeout`?i===`zh`?`启动超时`:`Start timed out`:i===`zh`?`运行错误`:`Runtime error`;return(0,Z.jsxs)(`section`,{ref:b.containerRef,className:O,"data-inline-chat-preview":t.id,children:[(0,Z.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-2 border-b border-edge-subtle px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:t.title}),(0,Z.jsx)(`p`,{className:Y(`mt-0.5 text-xs`,k?`text-danger`:`text-fg-muted`),"aria-live":`polite`,children:A})]}),(0,Z.jsx)(pi,{variant:`ghost`,className:`content-block-action`,onClick:T,"data-action-visible":k,title:i===`zh`?`重新加载预览`:`Reload preview`,"aria-label":i===`zh`?`重新加载预览`:`Reload preview`,children:(0,Z.jsx)(At,{className:`size-4`,"aria-hidden":!0})}),(0,Z.jsx)(pi,{variant:`ghost`,className:`content-block-action`,disabled:g!==null,onClick:()=>void D(),"aria-busy":g===`promote`,title:g===`promote`?i===`zh`?`保存中…`:`Saving…`:i===`zh`?`保存为应用`:`Save as app`,"aria-label":g===`promote`?i===`zh`?`保存中…`:`Saving…`:i===`zh`?`保存为应用`:`Save as app`,children:(0,Z.jsx)(Mt,{className:Y(`size-4`,g===`promote`&&`motion-safe:animate-pulse`),"aria-hidden":!0})})]}),(0,Z.jsxs)(`div`,{className:`relative bg-surface-base`,style:{minHeight:x},children:[(0,Z.jsx)(`iframe`,{ref:s,title:i===`zh`?`${t.title} 交互预览`:`${t.title} interactive preview`,srcDoc:w,sandbox:`allow-scripts allow-forms`,className:`block w-full border-0 bg-white`,style:{height:x}},l),f===`booting`?(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-0 grid place-items-center bg-surface-base/75`,children:(0,Z.jsx)(qt,{className:`h-10 w-40`})}):null]}),k?(0,Z.jsx)(`footer`,{className:`border-t border-danger/20 bg-danger-soft/60 px-4 py-3`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Z.jsx)(`p`,{className:`min-w-0 flex-1 text-xs text-danger`,role:`alert`,children:m.at(-1)?.message??(i===`zh`?`预览未能正常启动`:`The preview did not start correctly`)}),(0,Z.jsxs)(pi,{variant:`secondary`,className:`min-h-11 px-3 text-xs`,disabled:!m.length||g!==null,onClick:()=>void E(),children:[(0,Z.jsx)(Wt,{className:`size-4`}),g===`fix`?i===`zh`?`生成中…`:`Preparing…`:i===`zh`?`让 AI 修复`:`Ask AI to fix`]})]})}):null,v?(0,Z.jsx)(`p`,{className:`border-t border-danger/20 px-4 py-2 text-xs text-danger`,role:`alert`,children:v}):null]})}function pv(e){let t=(0,X.c)(8),{children:n,label:r,className:i}=e,a;t[0]===i?a=t[1]:(a=Y(`mt-2 w-full min-w-0 max-w-full self-start`,i),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,Z.jsx)(`div`,{className:`min-w-0`,children:n}),t[2]=n,t[3]=o);let s;return t[4]!==r||t[5]!==a||t[6]!==o?(s=(0,Z.jsx)(`section`,{className:a,"aria-label":r,"data-turn-tail":!0,children:o}),t[4]=r,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function mv(e){return{id:e.artifactId,name:e.title,type:e.kind,mimeType:e.mimeType,size:e.sizeBytes,uri:e.uri,workspaceRelativePath:e.workspaceRelativePath}}function hv(e){let t=e.mimeType?.toLowerCase()??``,n=e.type?.toLowerCase()??``;return t.startsWith(`image/`)||n===`image`?we:t.startsWith(`audio/`)||n===`audio`||n===`voice`?ls:t.startsWith(`video/`)||n===`video`?ge:t.includes(`spreadsheet`)||[`spreadsheet`,`csv`,`xlsx`,`xls`].includes(n)?he:t.includes(`zip`)||[`archive`,`zip`].includes(n)?A:n===`site`?U:Te}function gv(e,t,n){return!!(e.uri||ai(e)||e.workspaceRelativePath?.trim()&&(t?.trim()||n?.trim()))}function _v(e){let t=(0,X.c)(43),{item:n,authToken:r,conversationId:i,projectId:a,onOpen:o}=e,s=h(vv),c;t[0]===s?c=t[1]:(c=y(s),t[0]=s,t[1]=c);let l=c.chat.productDelivery.kinds.file,u;t[2]!==r||t[3]!==i?(u={authToken:r,conversationId:i},t[2]=r,t[3]=i,t[4]=u):u=t[4];let d=lm(n.attachment,u),f;t[5]===n.attachment?f=t[6]:(f=hv(n.attachment),t[5]=n.attachment,t[6]=f);let p=f,m;t[7]!==i||t[8]!==n.attachment||t[9]!==a?(m=gv(n.attachment,i,a),t[7]=i,t[8]=n.attachment,t[9]=a,t[10]=m):m=t[10];let g=m,_=g||!!n.href,v;t[11]!==p||t[12]!==d.src||t[13]!==n.failed?(v=d.src?(0,Z.jsx)(`img`,{src:d.src,alt:``,className:`size-[18px] rounded object-cover`,decoding:`async`,loading:`lazy`}):(0,Z.jsx)(p,{strokeWidth:1.75,className:n.failed?`text-danger`:void 0}),t[11]=p,t[12]=d.src,t[13]=n.failed,t[14]=v):v=t[14];let b=n.attachment.name??l,x;t[15]===_?x=t[16]:(x=_?(0,Z.jsx)(te,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}):null,t[15]=_,t[16]=x);let S;t[17]!==n.meta||t[18]!==v||t[19]!==b||t[20]!==x?(S=(0,Z.jsx)(Po,{icon:v,title:b,meta:n.meta,trailing:x}),t[17]=n.meta,t[18]=v,t[19]=b,t[20]=x,t[21]=S):S=t[21];let C=S,w=_?`cursor-pointer`:`cursor-default`,T;t[22]===w?T=t[23]:(T=Y(Mo,w),t[22]=w,t[23]=T);let E=T,D=n.attachment.name??l,O;t[24]!==n.meta||t[25]!==D?(O=[D,n.meta],t[24]=n.meta,t[25]=D,t[26]=O):O=t[26];let k=O.join(` · `);if(!g&&n.href){let e;return t[27]!==E||t[28]!==C||t[29]!==n.href||t[30]!==k?(e=(0,Z.jsx)(`li`,{className:`min-w-0 max-w-full`,"data-result-attachment":!0,children:(0,Z.jsx)(`a`,{title:k,href:n.href,target:`_blank`,rel:`noreferrer`,className:E,children:C})}),t[27]=E,t[28]=C,t[29]=n.href,t[30]=k,t[31]=e):e=t[31],e}if(!g){let e;return t[32]!==E||t[33]!==C?(e=(0,Z.jsx)(`li`,{className:E,"data-result-attachment":!0,children:C}),t[32]=E,t[33]=C,t[34]=e):e=t[34],e}let A;t[35]!==n.attachment||t[36]!==o?(A=()=>o(n.attachment),t[35]=n.attachment,t[36]=o,t[37]=A):A=t[37];let j;return t[38]!==E||t[39]!==C||t[40]!==A||t[41]!==k?(j=(0,Z.jsx)(`li`,{className:`min-w-0 max-w-full`,"data-result-attachment":!0,children:(0,Z.jsx)(`button`,{type:`button`,className:E,title:k,onClick:A,children:C})}),t[38]=E,t[39]=C,t[40]=A,t[41]=k,t[42]=j):j=t[42],j}function vv(e){return e.language}function yv(e){let t=(0,X.c)(25),{attachments:n,authToken:r,conversationId:i,projectId:a,onOpen:o,language:s}=e,c;t[0]!==n.length||t[1]!==s?(c=y(s).chat.turnOutcome.fileCount.replace(`{{count}}`,String(n.length)),t[0]=n.length,t[1]=s,t[2]=c):c=t[2];let l=c,u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=Y(Mo,`cursor-pointer list-none`),t[3]=u):u=t[3];let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(fs,{strokeWidth:1.75}),t[4]=d):d=t[4];let f;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(te,{className:`size-3.5 shrink-0 text-fg-subtle transition-transform duration-150 group-open:rotate-90 motion-reduce:transition-none`,"aria-hidden":!0}),t[5]=f):f=t[5];let p;t[6]===l?p=t[7]:(p=(0,Z.jsx)(`summary`,{className:u,children:(0,Z.jsx)(Po,{icon:d,title:l,trailing:f})}),t[6]=l,t[7]=p);let m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m=Y(No,jo),t[8]=m):m=t[8];let h;if(t[9]!==n||t[10]!==r||t[11]!==i||t[12]!==o||t[13]!==a){let e;t[15]!==r||t[16]!==i||t[17]!==o||t[18]!==a?(e=e=>(0,Z.jsx)(_v,{item:e,authToken:r,conversationId:i,projectId:a,onOpen:o},e.key),t[15]=r,t[16]=i,t[17]=o,t[18]=a,t[19]=e):e=t[19],h=n.map(e),t[9]=n,t[10]=r,t[11]=i,t[12]=o,t[13]=a,t[14]=h}else h=t[14];let g;t[20]===h?g=t[21]:(g=(0,Z.jsx)(`ul`,{className:m,children:h}),t[20]=h,t[21]=g);let _;return t[22]!==p||t[23]!==g?(_=(0,Z.jsx)(`li`,{className:`min-w-0 max-w-full`,"data-result-attachment-group":!0,children:(0,Z.jsxs)(`details`,{className:`group`,children:[p,g]})}),t[22]=p,t[23]=g,t[24]=_):_=t[24],_}function bv(e,t){if(!e)return[];let n=y(t).chat.turnOutcome;return e.deliverables.map(e=>{let t=mv(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:oi(e.sizeBytes)].filter(Boolean).join(` · `)}})}function xv(e,t){let n=y(t).chat.turnOutcome;return(e??[]).map((e,t)=>({key:`attachment:${e.id??e.uri??e.name??t}`,attachment:e,meta:[n.generatedFile,typeof e.size==`number`?oi(e.size):null].filter(Boolean).join(` · `)}))}function Sv(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 Cv(e){let t=(0,X.c)(46),{view:n,authToken:r,conversationId:i,projectId:a}=e,o=h(Ov)===`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=fm(s),l=n.deliveries.filter(Dv),u=k_(l),d=j_(l),f=M_(l),p=A_(l),m=(0,Q.useContext)(B_),g=new Set(Sv(n.outcome));if(m)for(let{delivery:e,reference:t}of N_(l))t.kind===`automation`&&!t.runId&&e.operation!==`failed`&&g.add(`automation:${t.id}`);let _=N_(l,g).length,v,b,x,S;if(t[3]!==o||t[4]!==c||t[5]!==n.attachments||t[6]!==n.outcome||t[7]!==n.resultRevision){v=[...bv(n.outcome,o),...xv(n.attachments,o)];let e;t[12]!==n.outcome?.deliverables||t[13]!==n.resultRevision?(e=e=>!!(n.resultRevision&&n.outcome?.deliverables.some(t=>t.artifactId===e.id)),t[12]=n.outcome?.deliverables,t[13]=n.resultRevision,t[14]=e):e=t[14],b=e;let r;t[15]!==b||t[16]!==c||t[17]!==n.resultRevision?(r=e=>{c.openAttachment(e,b(e)?n.resultRevision:void 0)},t[15]=b,t[16]=c,t[17]=n.resultRevision,t[18]=r):r=t[18],x=r,S=v.filter(Ev),t[3]=o,t[4]=c,t[5]=n.attachments,t[6]=n.outcome,t[7]=n.resultRevision,t[8]=v,t[9]=b,t[10]=x,t[11]=S}else v=t[8],b=t[9],x=t[10],S=t[11];let C=S,w;t[19]!==v||t[20]!==C?(w=v.filter(e=>!C.includes(e)),t[19]=v,t[20]=C,t[21]=w):w=t[21];let T=w,E=_>0||T.length>0;if(u.length===0&&d.length===0&&f.length===0&&!E&&!C.length)return null;let D;t[22]!==r||t[23]!==i||t[24]!==C?(D=C.length>0?(0,Z.jsx)(xm,{attachments:C.map(Tv),authToken:r,conversationId:i,workspaceConversationId:i,layout:`assistant`}):null,t[22]=r,t[23]=i,t[24]=C,t[25]=D):D=t[25];let O=u.map(wv),k;t[26]===o?k=t[27]:(k=e=>{let{key:t,presentation:n}=e;return(0,Z.jsx)(iv,{previewId:`${t}:${n.reference.id}:${n.snapshot.sourceHash}`,reference:n.reference,sourceHash:n.snapshot.sourceHash,preferredHeight:n.preferredHeight,language:o},t)},t[26]=o,t[27]=k);let A=d.map(k),j;t[28]===o?j=t[29]:(j=e=>{let{key:t,presentation:n}=e;return(0,Z.jsx)(fv,{leaseId:`${t}:${n.reference.id}:${n.sourceHash}`,reference:n.reference,sourceHash:n.sourceHash,preferredHeight:n.preferredHeight,language:o},t)},t[28]=o,t[29]=j);let M=f.map(j),N=E?(0,Z.jsxs)(pv,{label:y(o).chat.productDelivery.heading,children:[(0,Z.jsxs)(`ul`,{className:No,children:[(0,Z.jsx)(Z_,{deliveries:l,language:o,excludedReferenceKeys:g,conversationId:i,projectId:a}),T.length>1?(0,Z.jsx)(yv,{attachments:T,authToken:r,conversationId:i,projectId:a,onOpen:x,language:o}):T.map(e=>(0,Z.jsx)(_v,{item:e,authToken:r,conversationId:i,projectId:a,onOpen:x},e.key))]}),p.truncated?(0,Z.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-fg-muted`,children:y(o).chat.productDelivery.partialResults}):null]}):null,P;t[30]!==T.length||t[31]!==r||t[32]!==i||t[33]!==b||t[34]!==c.active||t[35]!==c.closePreview||t[36]!==c.open||t[37]!==n.resultRevision?(P=T.length>0?(0,Z.jsx)(Zr,{open:c.open,attachment:c.active,resultRevision:c.active&&b(c.active)?n.resultRevision:void 0,authToken:r,conversationId:i,onClose:c.closePreview}):null,t[30]=T.length,t[31]=r,t[32]=i,t[33]=b,t[34]=c.active,t[35]=c.closePreview,t[36]=c.open,t[37]=n.resultRevision,t[38]=P):P=t[38];let F;return t[39]!==N||t[40]!==P||t[41]!==D||t[42]!==O||t[43]!==A||t[44]!==M?(F=(0,Z.jsxs)(Z.Fragment,{children:[D,O,A,M,N,P]}),t[39]=N,t[40]=P,t[41]=D,t[42]=O,t[43]=A,t[44]=M,t[45]=F):F=t[45],F}function wv(e){let{key:t,presentation:n}=e;return(0,Z.jsx)(nv,{presentation:n},t)}function Tv(e){return e.attachment}function Ev(e){return!e.failed&&e.attachment.mimeType?.startsWith(`image/`)}function Dv(e){let{delivery:t}=e;return O_(t)}function Ov(e){return e.language}function kv(e){let t=(0,X.c)(33),{outcome:n}=e,r=h(Mv),i,a,o,s,c,l,u,d;if(t[0]!==r||t[1]!==n.changeSet||t[2]!==n.evidence||t[3]!==n.status||t[4]!==n.summary){d=Symbol.for(`react.early_return_sentinel`);bb0:{if(o=y(r).chat.turnOutcome,i=!!n.changeSet,a=n.evidence.length>0,!i&&!a){d=n.status===`failed`?(0,Z.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:n.summary||o.statusFailed}):null;break bb0}let e=n.evidence.filter(jv).length,f=n.evidence.filter(Av).length,p=n.status===`succeeded`?o.statusSucceeded:n.status===`failed`?o.statusFailed:o.statusPartial,m=n.status===`succeeded`?G:n.status===`failed`?pe:K,h=[n.changeSet?o.changedFileCount.replace(`{{count}}`,String(n.changeSet.files.length)):null,e>0?o.passedCount.replace(`{{count}}`,String(e)):null,f>0?o.failedCount.replace(`{{count}}`,String(f)):null,a&&e===0&&f===0?o.evidenceCount.replace(`{{count}}`,String(n.evidence.length)):null].filter(Boolean).join(` · `);l=`group mt-2 min-w-0 max-w-full text-sm`;let g=n.status===`succeeded`?`text-success`:n.status===`failed`?`text-danger`:`text-warning`,_;t[13]!==m||t[14]!==g?(_=(0,Z.jsx)(m,{className:g,"aria-hidden":!0}),t[13]=m,t[14]=g,t[15]=_):_=t[15];let v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(te,{className:`size-3.5 shrink-0 text-fg-subtle transition-transform group-open:rotate-90 motion-reduce:transition-none`,strokeWidth:1.75,"aria-hidden":!0}),t[16]=v):v=t[16],u=(0,Z.jsx)(`summary`,{className:`${Mo} cursor-pointer list-none`,title:`${p} · ${h}`,children:(0,Z.jsx)(Po,{icon:_,title:p,meta:h,trailing:v})}),s=jo,c=n.changeSet?(0,Z.jsxs)(`section`,{"aria-label":o.changes,children:[(0,Z.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:o.changeSetTitle}),(0,Z.jsx)(`span`,{className:`shrink-0 text-fg-subtle`,children:o.changeStats.replace(`{{files}}`,String(n.changeSet.files.length)).replace(`{{added}}`,String(n.changeSet.added)).replace(`{{removed}}`,String(n.changeSet.removed))})]}),(0,Z.jsxs)(`div`,{className:`mt-2 border-t border-edge-subtle/70 pt-2`,children:[n.changeSet.files.slice(0,8).map(e=>(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 py-1 text-xs`,children:[(0,Z.jsx)(`span`,{className:`w-14 shrink-0 text-fg-subtle`,children:o.fileStatus[e.status??`modified`]}),(0,Z.jsx)(`code`,{className:`min-w-0 truncate text-fg-muted`,children:e.path})]},e.path)),n.changeSet.files.length>8?(0,Z.jsx)(`div`,{className:`pt-1 text-xs text-fg-subtle`,children:o.moreFiles.replace(`{{count}}`,String(n.changeSet.files.length-8))}):null]}),n.changeSet.diff?(0,Z.jsxs)(`details`,{className:`mt-2`,children:[(0,Z.jsx)(`summary`,{className:`w-fit cursor-pointer rounded-md px-1.5 py-1 text-xs font-medium text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:o.viewDiff}),n.changeSet.diffTruncated?(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-warning`,children:o.diffTruncated}):null,(0,Z.jsx)(`pre`,{className:`mt-2 max-h-72 overflow-auto rounded-lg bg-surface-inset p-3 text-xs leading-5 text-fg-muted`,children:(0,Z.jsx)(`code`,{children:n.changeSet.diff})})]}):null]}):null}t[0]=r,t[1]=n.changeSet,t[2]=n.evidence,t[3]=n.status,t[4]=n.summary,t[5]=i,t[6]=a,t[7]=o,t[8]=s,t[9]=c,t[10]=l,t[11]=u,t[12]=d}else i=t[5],a=t[6],o=t[7],s=t[8],c=t[9],l=t[10],u=t[11],d=t[12];if(d!==Symbol.for(`react.early_return_sentinel`))return d;let f;t[17]!==i||t[18]!==a?(f=i&&a?(0,Z.jsx)(`div`,{className:`my-2 border-t border-edge-subtle`}):null,t[17]=i,t[18]=a,t[19]=f):f=t[19];let p;t[20]!==a||t[21]!==n.evidence||t[22]!==o?(p=a?(0,Z.jsxs)(`section`,{"aria-label":o.evidence,children:[(0,Z.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg`,children:o.evidence}),n.evidence.map(e=>(0,Z.jsxs)(`div`,{className:`flex min-h-10 items-center gap-2.5 border-b border-edge-subtle/60 py-1.5 last:border-b-0`,children:[(0,Z.jsx)(Ke,{className:e.status===`passed`?`size-4 shrink-0 text-success`:e.status===`failed`?`size-4 shrink-0 text-danger`:`size-4 shrink-0 text-warning`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:e.label}),(0,Z.jsx)(`span`,{className:e.status===`passed`?`text-xs font-medium text-success`:e.status===`failed`?`text-xs font-medium text-danger`:`text-xs font-medium text-warning`,children:e.status===`passed`?o.passed:e.status===`failed`?o.failed:o.warning})]},e.evidenceId))]}):null,t[20]=a,t[21]=n.evidence,t[22]=o,t[23]=p):p=t[23];let m;t[24]!==s||t[25]!==c||t[26]!==f||t[27]!==p?(m=(0,Z.jsxs)(`div`,{className:s,children:[c,f,p]}),t[24]=s,t[25]=c,t[26]=f,t[27]=p,t[28]=m):m=t[28];let g;return t[29]!==l||t[30]!==u||t[31]!==m?(g=(0,Z.jsxs)(`details`,{className:l,children:[u,m]}),t[29]=l,t[30]=u,t[31]=m,t[32]=g):g=t[32],g}function Av(e){return e.status===`failed`}function jv(e){return e.status===`passed`}function Mv(e){return e.language}function Nv(e){let t=(0,X.c)(14),{view:n,authToken:r,conversationId:i,projectId:a,sourcesLabel:o}=e,s;t[0]!==r||t[1]!==i||t[2]!==a||t[3]!==n?(s=(0,Z.jsx)(Cv,{view:n,authToken:r,conversationId:i,projectId:a}),t[0]=r,t[1]=i,t[2]=a,t[3]=n,t[4]=s):s=t[4];let c;t[5]===n.outcome?c=t[6]:(c=n.outcome?(0,Z.jsx)(kv,{outcome:n.outcome}):null,t[5]=n.outcome,t[6]=c);let l;t[7]!==o||t[8]!==n.sources?(l=n.sources.length>0?(0,Z.jsxs)(`details`,{className:`group min-w-0 max-w-full`,"aria-label":o,children:[(0,Z.jsx)(`summary`,{className:`${Mo} cursor-pointer list-none`,children:(0,Z.jsx)(Po,{icon:(0,Z.jsx)(Ne,{}),title:o,trailing:(0,Z.jsx)(te,{className:`size-3.5 shrink-0 text-fg-subtle transition-transform group-open:rotate-90 motion-reduce:transition-none`,"aria-hidden":!0})})}),(0,Z.jsx)(`div`,{className:jo,children:(0,Z.jsx)(I_,{sources:n.sources,className:``})})]}):null,t[7]=o,t[8]=n.sources,t[9]=l):l=t[9];let u;return t[10]!==s||t[11]!==c||t[12]!==l?(u=(0,Z.jsxs)(Z.Fragment,{children:[s,c,l]}),t[10]=s,t[11]=c,t[12]=l,t[13]=u):u=t[13],u}var Pv=`NO_REPLY`;function Fv(e,t){if(e.role!==`assistant`||!e.content?.length)return e;if(t?.hideSilentReply){let n=e.content.filter(e=>e.type!==`text`||e.text.trim()!==Pv);if(n.length!==e.content.length)return Fv({...e,content:n},t)}let n=e.content.findIndex(e=>e.type===`text`);if(n<0)return e;let r=e.content[n];if(r.type!==`text`)return e;let i=r.text.trimStart();if(t?.hideSilentReply&&(i===Pv||t.streaming&&i.length>0&&Pv.startsWith(i)))return{...e,content:e.content.filter((e,t)=>t!==n)};if(!i.startsWith(Pv))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 Iv(e,t){return t||e.workLog.items.some(e=>e.type===`tool_use`&&(e.status===`error`||e.activity?.status===`failed`))}function Lv(e,t){if(e.role!==`assistant`||t.isStreaming||t.followUpTrigger)return!0;let n=F_({message:Fv(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||Iv(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 Rv(e,t){let n=In(e.content).some(e=>e.type===`review`&&(!e.status||e.status===`complete`)||e.type===`text`&&!!e.text.trim()),r=e.fromHistory&&n,i=e.outcome??e.taskResultDelivery?.outcome,a=!t&&e.runStatus!==`suspended`&&!!(e.runStatus||i||r),o=e.runStatus===`error`||e.runStatus===`cancelled`||i?.status===`failed`;return{settled:a,defaultCollapsed:a&&n&&!o,outcome:i}}function zv(e){let t=(0,X.c)(17),{message:n,isStreaming:r,enabled:i,items:a,durationMs:o}=e,s=(0,Q.useRef)(null),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(null),f=h(Bv),p=y(f).chat,m;t[0]!==r||t[1]!==n?(m=Rv(n,r),t[0]=r,t[1]=n,t[2]=m):m=t[2];let g=m,_=i&&g.settled&&a.length>0,v,b;t[3]===r?(v=t[4],b=t[5]):(v=()=>{r&&d(null)},b=[r],t[3]=r,t[4]=v,t[5]=b),(0,Q.useEffect)(v,b);let x,S;t[6]!==i||t[7]!==a.length?(x=()=>{if(!i||a.length===0)return;let e=()=>{let e=window.getSelection();l(!!(s.current&&[...s.current.querySelectorAll(`[data-assistant-process-item]`)].some(t=>e&&!e.isCollapsed&&e.containsNode(t,!0)||t.contains(document.activeElement))))};return e(),document.addEventListener(`selectionchange`,e),document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,e),()=>{document.removeEventListener(`selectionchange`,e),document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,e)}},S=[i,a.length],t[6]=i,t[7]=a.length,t[8]=x,t[9]=S):(x=t[8],S=t[9]),(0,Q.useEffect)(x,S);let C=u??(!g.defaultCollapsed||c),w=o==null?null:Mg(o,f),T=n.runStatus===`cancelled`?p.processStopped:n.runStatus===`error`||g.outcome?.status===`failed`?p.processFailed:g.outcome?.status===`partial`?p.processPartial:null,E=T?`${T}${w?` · ${w}`:``}`:w?p.processWorkedFor.replace(`{{duration}}`,w):p.processView,D=_&&!C,O;t[10]!==C||t[11]!==E||t[12]!==_?(O=_?(0,Z.jsxs)(`button`,{type:`button`,"data-assistant-process-toggle":!0,"aria-expanded":C,onClick:()=>d(!C),className:`flex min-h-11 w-full items-center gap-1.5 border-b border-edge-subtle py-2 text-left text-sm text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,children:[(0,Z.jsx)(`span`,{children:E}),(0,Z.jsx)(te,{"aria-hidden":!0,className:`size-4 shrink-0 transition-transform motion-reduce:transition-none ${C?`rotate-90`:``}`})]}):null,t[10]=C,t[11]=E,t[12]=_,t[13]=O):O=t[13];let k;return t[14]!==D||t[15]!==O?(k={contentRef:s,collapsed:D,summary:O},t[14]=D,t[15]=O,t[16]=k):k=t[16],k}function Bv(e){return e.language}function Vv(e,t=!1){return t||e.textSurface===`conversation`}function Hv(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 Uv(e){let t=(0,X.c)(23),{trigger:n}=e,r=c(),i=h(Wv),a;t[0]===i?a=t[1]:(a=y(i),t[0]=i,t[1]=a);let o=a.chat.taskTrigger,s=n.entryId,l;t[2]===o.about?l=t[3]:(l=(0,Z.jsx)(`span`,{className:`shrink-0`,children:o.about}),t[2]=o.about,t[3]=l);let d=`${r.pathname}${r.search}`,f;t[4]!==d||t[5]!==n.taskId?(f=et(d,n.taskId),t[4]=d,t[5]=n.taskId,t[6]=f):f=t[6];let p=n.taskTitle,m=`${o.openTask}:${n.taskTitle}`,g;t[7]===n.taskTitle?g=t[8]:(g=Hv(n.taskTitle),t[7]=n.taskTitle,t[8]=g);let _;t[9]===g?_=t[10]:(_=(0,Z.jsxs)(`span`,{className:`truncate`,children:[`「`,g,`」`]}),t[9]=g,t[10]=_);let v;t[11]!==f||t[12]!==m||t[13]!==_||t[14]!==n.taskTitle?(v=(0,Z.jsx)(u,{className:`inline-flex min-w-0 max-w-[min(48vw,30rem)] font-medium text-fg hover:text-accent hover:underline`,to:f,title:p,"aria-label":m,children:_}),t[11]=f,t[12]=m,t[13]=_,t[14]=n.taskTitle,t[15]=v):v=t[15];let b=o[n.kind],x;t[16]===b?x=t[17]:(x=(0,Z.jsxs)(`span`,{className:`shrink-0 whitespace-nowrap`,children:[`· `,b]}),t[16]=b,t[17]=x);let S;return t[18]!==v||t[19]!==x||t[20]!==l||t[21]!==n.entryId?(S=(0,Z.jsxs)(`div`,{className:`mb-4 flex min-w-0 max-w-full items-center gap-1.5 border-t border-edge-subtle pt-5 text-sm text-fg-muted`,"data-task-trigger":s,children:[l,v,x]}),t[18]=v,t[19]=x,t[20]=l,t[21]=n.entryId,t[22]=S):S=t[22],S}function Wv(e){return e.language}var Gv=3;function Kv(e){let t=(0,X.c)(36),{refs:n,groupLabel:r,noteLabel:i,fileLabel:a,folderLabel:o,sessionLabel:s,browserTabLabel:c,mcpResourceLabel:l,truncatedLabel:u,showMoreLabel:d,showLessLabel:f,onOpen:p}=e,[m,h]=(0,Q.useState)(!1);if(n.length===0)return null;let g=n.length>Gv,_;t[0]!==m||t[1]!==n?(_=m?n:n.slice(0,Gv),t[0]=m,t[1]=n,t[2]=_):_=t[2];let v=_,y=n.length-Gv,b;if(t[3]!==c||t[4]!==a||t[5]!==o||t[6]!==r||t[7]!==l||t[8]!==i||t[9]!==p||t[10]!==s||t[11]!==u||t[12]!==v){let e;t[14]!==c||t[15]!==a||t[16]!==o||t[17]!==r||t[18]!==l||t[19]!==i||t[20]!==p||t[21]!==s||t[22]!==u?(e=e=>{let t=e.kind===`note`,n=t?`button`:`div`,d=e.kind===`result`?a:e.kind===`file`?e.fileKind===`directory`?o:a:e.kind===`session`?s:e.kind===`browser_tab`?c:e.kind===`mcp_resource`?l:i;return(0,Z.jsxs)(n,{...t?{type:`button`,onClick:()=>p(e)}:{},className:Y(`group inline-flex min-h-9 min-w-0 max-w-full items-center gap-2 rounded-lg border border-edge-subtle bg-surface-panel/80 px-2 py-1.5 text-left`,t&&`transition-colors hover:border-accent/40 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),...t?{"aria-label":`${r}: ${e.title}`}:{},title:e.truncated?u:e.title,children:[(0,Z.jsx)(`span`,{className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md bg-accent-soft text-accent-fg`,children:e.kind===`file`&&e.fileKind===`directory`?(0,Z.jsx)(Oe,{className:`size-3.5`,"aria-hidden":!0}):e.kind===`file`||e.kind===`result`?(0,Z.jsx)(Te,{className:`size-3.5`,"aria-hidden":!0}):e.kind===`session`?(0,Z.jsx)(bt,{className:`size-3.5`,"aria-hidden":!0}):e.kind===`browser_tab`?(0,Z.jsx)(k,{className:`size-3.5`,"aria-hidden":!0}):e.kind===`mcp_resource`?(0,Z.jsx)(ye,{className:`size-3.5`,"aria-hidden":!0}):(0,Z.jsx)(xs,{className:`size-3.5`,"aria-hidden":!0})}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`shrink-0 text-[11px] text-fg-muted`,children:d}),(0,Z.jsx)(`span`,{className:`max-w-56 truncate text-xs font-medium text-fg sm:max-w-72`,children:e.title})]}),t?(0,Z.jsx)(te,{className:`size-3.5 shrink-0 text-fg-disabled transition-transform group-hover:translate-x-0.5 group-hover:text-fg-muted`,"aria-hidden":!0}):null]},`${e.kind}:${e.sourceId}`)},t[14]=c,t[15]=a,t[16]=o,t[17]=r,t[18]=l,t[19]=i,t[20]=p,t[21]=s,t[22]=u,t[23]=e):e=t[23],b=v.map(e),t[3]=c,t[4]=a,t[5]=o,t[6]=r,t[7]=l,t[8]=i,t[9]=p,t[10]=s,t[11]=u,t[12]=v,t[13]=b}else b=t[13];let x;t[24]===b?x=t[25]:(x=(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-wrap gap-1.5`,children:b}),t[24]=b,t[25]=x);let S;t[26]!==g||t[27]!==m||t[28]!==y||t[29]!==f||t[30]!==d?(S=g?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-8 w-fit items-center gap-1 rounded-md px-2 text-xs text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-expanded":m,onClick:()=>h(qv),children:[m?(0,Z.jsx)(ne,{className:`size-3.5`,"aria-hidden":!0}):(0,Z.jsx)(ee,{className:`size-3.5`,"aria-hidden":!0}),m?f:d.replace(`{{count}}`,String(y))]}):null,t[26]=g,t[27]=m,t[28]=y,t[29]=f,t[30]=d,t[31]=S):S=t[31];let C;return t[32]!==r||t[33]!==x||t[34]!==S?(C=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,role:`group`,"aria-label":r,children:[x,S]}),t[32]=r,t[33]=x,t[34]=S,t[35]=C):C=t[35],C}function qv(e){return!e}function Jv(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 Yv(e){let t=(0,X.c)(67),{open:n,onOpenChange:r,items:i,labels:a}=e,o;t[0]!==i||t[1]!==a.origins?(o=Jv(i,a.origins),t[0]=i,t[1]=a.origins,t[2]=o):o=t[2];let s=o,c=s.reduce($v,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(Qv):[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(Zv)))},t[12]=h,t[13]=s,t[14]=g):g=t[14];let _=g,v;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(v=e=>{d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},t[15]=v):v=t[15];let y=v,x;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim/60 backdrop-blur-[1px]`}),t[16]=x):x=t[16];let O;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(O=Y(`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(36rem,calc(100dvh-2rem))]`,`w-[min(42rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-popover outline-none`),t[17]=O):O=t[17];let k;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,Z.jsx)(`span`,{className:`mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-lg bg-accent-soft text-accent-fg`,children:(0,Z.jsx)(ss,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[18]=k):k=t[18];let A;t[19]===a.title?A=t[20]:(A=(0,Z.jsx)(E,{className:`text-base font-semibold text-fg`,children:a.title}),t[19]=a.title,t[20]=A);let j;t[21]===a.hint?j=t[22]:(j=(0,Z.jsx)(S,{className:`mt-1 text-sm leading-5 text-fg-muted`,children:a.hint}),t[21]=a.hint,t[22]=j);let M;t[23]!==c||t[24]!==a.itemsSummary?(M=a.itemsSummary.replace(`{{count}}`,String(c)),t[23]=c,t[24]=a.itemsSummary,t[25]=M):M=t[25];let N;t[26]===M?N=t[27]:(N=(0,Z.jsx)(`p`,{className:`mt-2 text-xs font-medium text-fg-subtle`,children:M}),t[26]=M,t[27]=N);let P;t[28]!==A||t[29]!==j||t[30]!==N?(P=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[A,j,N]}),t[28]=A,t[29]=j,t[30]=N,t[31]=P):P=t[31];let F;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Z.jsx)(Gt,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[32]=F):F=t[32];let I;t[33]===a.close?I=t[34]:(I=(0,Z.jsx)(C,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors duration-150 hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":a.close,title:a.close,children:F})}),t[33]=a.close,t[34]=I);let L;t[35]!==P||t[36]!==I?(L=(0,Z.jsxs)(`header`,{className:`flex shrink-0 items-start gap-3 border-b border-edge-subtle px-4 py-4 sm:px-5`,children:[k,P,I]}),t[35]=P,t[36]=I,t[37]=L):L=t[37];let R;t[38]!==s.length||t[39]!==a.groupSummary?(R=a.groupSummary.replace(`{{count}}`,String(s.length)),t[38]=s.length,t[39]=a.groupSummary,t[40]=R):R=t[40];let z;t[41]===R?z=t[42]:(z=(0,Z.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:R}),t[41]=R,t[42]=z);let B;t[43]!==h||t[44]!==s.length||t[45]!==a.collapseAll||t[46]!==a.expandAll||t[47]!==_?(B=s.length>1?(0,Z.jsx)(`button`,{type:`button`,className:`rounded-md px-2 py-1 text-xs font-medium text-accent-fg transition-colors duration-150 hover:bg-accent-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:_,children:h?a.collapseAll:a.expandAll}):null,t[43]=h,t[44]=s.length,t[45]=a.collapseAll,t[46]=a.expandAll,t[47]=_,t[48]=B):B=t[48];let V;t[49]!==z||t[50]!==B?(V=(0,Z.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center justify-between gap-3 border-b border-edge-subtle px-4 sm:px-5`,children:[z,B]}),t[49]=z,t[50]=B,t[51]=V):V=t[51];let H;if(t[52]!==u||t[53]!==s){let e;t[55]===u?e=t[56]:(e=e=>{let t=u.has(e.id);return(0,Z.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`flex min-h-12 w-full items-center gap-3 px-3.5 py-2.5 text-left transition-colors duration-150 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,"aria-expanded":t,onClick:()=>y(e.id),children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-fg`,children:e.label}),(0,Z.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] tabular-nums text-fg-muted`,children:e.items.length}),(0,Z.jsx)(ee,{className:Y(`size-4 shrink-0 text-fg-subtle transition-transform duration-200`,t&&`rotate-180`),strokeWidth:1.75,"aria-hidden":!0})]}),t?(0,Z.jsx)(`div`,{className:`border-t border-edge-subtle px-3.5`,children:e.items.map(Xv)}):null]},e.id)},t[55]=u,t[56]=e),H=s.map(e),t[52]=u,t[53]=s,t[54]=H}else H=t[54];let U;t[57]===H?U=t[58]:(U=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-3 py-3 sm:px-4`,"data-testid":`response-context-scroll-region`,children:(0,Z.jsx)(`div`,{className:`space-y-2`,children:H})}),t[57]=H,t[58]=U);let W;t[59]!==L||t[60]!==V||t[61]!==U?(W=(0,Z.jsxs)(w,{children:[x,(0,Z.jsxs)(T,{className:O,children:[L,V,U]})]}),t[59]=L,t[60]=V,t[61]=U,t[62]=W):W=t[62];let G;return t[63]!==r||t[64]!==n||t[65]!==W?(G=(0,Z.jsx)(D,{open:n,onOpenChange:r,children:W}),t[63]=r,t[64]=n,t[65]=W,t[66]=G):G=t[66],G}function Xv(e){return(0,Z.jsx)(`p`,{className:`border-b border-edge-subtle py-3 text-sm leading-6 text-fg last:border-b-0`,children:e.statement},e.id)}function Zv(e){return e.id}function Qv(e){return e.id}function $v(e,t){return e+t.items.length}var ey=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`,ca.disabled),ty=[`misunderstood_intent`,`incorrect`,`did_not_act`,`tone_mismatch`,`too_verbose`,`other`],ny=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`,ca.disabled),ry=700,iy=120,ay=(0,Q.memo)(function({message:e,personal:t=!1,followUpTrigger:n,authToken:r,conversationId:i,workspaceConversationId:a,projectId:o,isStreaming:s,progress:l,reasoningLevel:u=`on`,messageIndex:f,onDeleteRound:m,onRetryUserMessageRound:_,userMessageCanRetry:v=!1,deleteRoundDisabled:b=!1,onSaveAssistantAsNote:x,onSaveAssistantToSourceNote:S,onExtractAssistantTask:C,onForkAssistantTurn:w,readonly:T=!1,density:E=`normal`,suppressAssistantActions:D=!1,onEditUserMessage:O,userMessageCanEdit:k=!0,responseFeedbackEnabled:A=!0,showAssistantWorkLog:j=!0}){let M=(0,Q.useMemo)(()=>Fv(e,{hideSilentReply:Vv(e,t),streaming:s}),[e,t,s]),N=h(e=>e.language),I=y(N),L=d(),B=c(),H=M.role===`user`,U=M.role===`assistant`,W=(0,Q.useRef)(H&&M.deliveryStatus===`sending`).current,te=H&&M.deliveryStatus===`sending`,re=H&&M.deliveryStatus===`failed`,[ie,ae]=(0,Q.useState)(!1),[oe,se]=(0,Q.useState)(!1),[ce,le]=(0,Q.useState)(()=>typeof navigator<`u`&&navigator.onLine===!1),ue=H?I.chat.you:U?I.chat.assistant:I.chat.tool;(0,Q.useEffect)(()=>{if(!te||typeof window>`u`)return;let e=()=>le(window.navigator.onLine===!1);return window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}},[te]),(0,Q.useEffect)(()=>{if(te){if(ie)return;let e=window.setTimeout(()=>ae(!0),ce?0:ry);return()=>window.clearTimeout(e)}if(!ie)return;let e=0,t=window.requestAnimationFrame(()=>{se(!0),e=window.setTimeout(()=>{ae(!1),se(!1)},iy)});return()=>{window.cancelAnimationFrame(t),window.clearTimeout(e)}},[te,ce,ie]);let q=re||ie,de=re?`failed`:`sending`,fe=(0,Q.useCallback)(e=>{let t=`${B.pathname}${B.search}`;L(tt(t,e))},[B.pathname,B.search,L]),pe=(0,Q.useMemo)(()=>({input:I.chat.toolInput,output:I.chat.toolOutput,noOutput:I.chat.noOutput}),[I.chat.toolInput,I.chat.toolOutput,I.chat.noOutput]),J=(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]),me=(0,Q.useMemo)(()=>({ing:I.chat.stepsClusterIng}),[I.chat.stepsClusterIng]),he=(0,Q.useMemo)(()=>I.chat.toolCard,[I.chat.toolCard]),ge=u===`off`,_e=(0,Q.useMemo)(()=>U?F_({message:M,isStreaming:s,reasoningLevel:u,personal:t}):null,[U,s,M,u,t]),ye=(0,Q.useMemo)(()=>{if(!_e)return(M.content??[]).filter(e=>e.type!==`image`);if(t)return _e.answerContent;if(!ge&&j)return(M.content??[]).filter(e=>e.type!==`image`);let e=new Set(_e.answerContent);return(M.content??[]).filter(t=>e.has(t)||t.type===`tool_use`&&(t.status===`error`||t.activity?.status===`failed`))},[_e,M.content,t,ge,j]),xe=(0,Q.useMemo)(()=>_e?_e.attachments:M.attachments,[_e,M.attachments]),Ce=U&&!t&&!ge&&j,we=zv({message:M,isStreaming:s,enabled:Ce,items:_e?.workLog.items??[],durationMs:M.completedAt==null?void 0:_e?.workLog.durationMs}),Ee=(0,Q.useMemo)(()=>Ce?new Set(_e?.workLog.items):void 0,[Ce,_e]),De=(0,Q.useMemo)(()=>{let e=new Set(M.userTurnDocument?.parts.flatMap(e=>e.type===`context_ref`?[e.refId]:[])??[]);return M.contextRefs?.filter(t=>!t.refId||!e.has(t.refId))},[M.contextRefs,M.userTurnDocument]),Oe=!!(_e?.workLog.active||_e?.workLog.items.length),ke=!!_e?.answer.started,Ae=ge||U&&(Oe||ke)?null:l,je=!ge&&!!M.content?.some(e=>e.type===`thinking`&&e.streaming),Me=U?!!_e?.answer.showStreamingCursor:s,Ne=t&&U&&s&&!_e?.answer.started&&!xe?.length,Pe=s&&!je&&(!U||!Oe&&!ke),Fe=!!Ae?.message||Pe,Ie=U&&!T&&!s&&!D,Le=U&&s&&!T&&!D&&ke,Re=(0,Q.useMemo)(()=>Ie?Em(M.content??[]):``,[Ie,M]),ze=(0,Q.useMemo)(()=>Ie&&Re?Om(M.content??[]):``,[Ie,Re,M]),Be=(0,Q.useMemo)(()=>Ie&&Re?z(Re):``,[Ie,Re]),Ve=(0,Q.useMemo)(()=>({source:{type:`chat-message`,id:`${i??`chat`}:${M.timestamp??f??Re.length}`,title:Be.split(`
59
- `)[0]?.slice(0,48)||I.chat.messageReadAloudTitle,href:i?`#/chat/${encodeURIComponent(i)}`:void 0,targetId:f==null?void 0:`chat-message-${f}`},text:Be,language:F(Be,N)}),[Re.length,N,I.chat.messageReadAloudTitle,M.timestamp,f,i,Be]),He=(0,Q.useMemo)(()=>{if(!H)return``;if(M.userTurnDocument){let e=new Map(M.contextRefs?.flatMap(e=>e.refId?[[e.refId,e.title]]:[])??[]);return br(M.userTurnDocument,t=>e.get(t))}return Rn(M.content)},[H,M.content,M.contextRefs,M.userTurnDocument]),[Ue,We]=(0,Q.useState)(null),[Ge,Ke]=(0,Q.useState)(!1),[Je,Ye]=(0,Q.useState)(null),[Xe,Ze]=(0,Q.useState)(null),[Qe,$e]=(0,Q.useState)(!1),[et,nt]=(0,Q.useState)(null),[rt,it]=(0,Q.useState)(!1),[at,ot]=(0,Q.useState)(!1),[st,ct]=(0,Q.useState)(!1),[lt,ut]=(0,Q.useState)(!1),[dt,ft]=(0,Q.useState)(null),[pt,mt]=(0,Q.useState)([]),[ht,gt]=(0,Q.useState)(!1),[_t,vt]=(0,Q.useState)(!1),[yt,bt]=(0,Q.useState)(null),[xt,St]=(0,Q.useState)(!1),[Ct,wt]=(0,Q.useState)(!1),Tt=(0,Q.useRef)(null),Et=(0,Q.useCallback)((e,t)=>{let n=wm(e,t);n&&bt(n)},[]),Ot=(0,Q.useCallback)(()=>{!i||!M.renderKey||Nn.getState().completeProgressiveRender(i,M.renderKey)},[M.renderKey,i]),kt=(0,Q.useCallback)(()=>{ze&&Ci(ze).then(e=>{e&&(We(`plain`),window.setTimeout(()=>We(e=>e===`plain`?null:e),2e3))})},[ze]),jt=(0,Q.useCallback)(()=>{Re&&Ci(Re).then(e=>{e&&(We(`markdown`),window.setTimeout(()=>We(e=>e===`markdown`?null:e),2e3))})},[Re]),Mt=(0,Q.useCallback)(()=>{!Re||!x||Xe||(Ze(`create-note`),Promise.resolve(x(Re)).then(()=>{Ye(`create-note`),window.setTimeout(()=>Ye(e=>e===`create-note`?null:e),2e3)}).catch(()=>void 0).finally(()=>Ze(null)))},[Xe,Re,x]),Nt=(0,Q.useCallback)(()=>{!Re||!S||Xe||(Ze(`save-source-note`),Promise.resolve(S(Re)).then(()=>{Ye(`save-source-note`),window.setTimeout(()=>Ye(e=>e===`save-source-note`?null:e),2e3)}).catch(()=>void 0).finally(()=>Ze(null)))},[Xe,Re,S]),Pt=(0,Q.useCallback)(()=>{!ze&&!Re||!C||Xe||(Ze(`extract-task`),Promise.resolve(C(ze||Re)).then(()=>{Ye(`extract-task`),window.setTimeout(()=>Ye(e=>e===`extract-task`?null:e),2e3)}).catch(()=>void 0).finally(()=>Ze(null)))},[Xe,Re,ze,C]),Ft=(0,Q.useCallback)(()=>{He&&Ci(He).then(e=>{e&&(We(`user`),window.setTimeout(()=>We(e=>e===`user`?null:e),2e3))})},[He]),It=(0,Q.useCallback)(()=>{!M.turnId||!w||Qe||($e(!0),Promise.resolve(w(M.turnId)).catch(()=>void 0).finally(()=>$e(!1)))},[Qe,M.turnId,w]),Lt=(0,Q.useCallback)((e,t)=>{!M.turnId||at||(ot(!0),it(!0),ct(!1),g(p(`/api/turns/${encodeURIComponent(M.turnId)}/execution-context/feedback`),{method:`POST`,body:JSON.stringify({rating:e===`helpful`?`helpful`:`irrelevant`,reason:t})}).then(()=>{nt(e),ft(t??null),ut(!1)}).catch(()=>ct(!0)).finally(()=>ot(!1)))},[M.turnId,at]),Rt=(0,Q.useCallback)(()=>{dt&&Wp(I.chat.messageFeedbackRepairPrompts[dt])},[I.chat.messageFeedbackRepairPrompts,dt]),zt=(0,Q.useCallback)(()=>{!M.turnId||rt||at||(ot(!0),g(p(`/api/turns/${encodeURIComponent(M.turnId)}/execution-context`)).then(e=>{mt(e.resolvedItems.filter(e=>e.included).map(e=>({id:`${e.objectType}:${e.objectId}`,statement:e.content,origin:e.origin,sourceName:e.sourceLabel})))}).catch(()=>void 0).finally(()=>{it(!0),ot(!1)}))},[M.turnId,at,rt]),Vt=(0,Q.useCallback)(()=>{f==null||!m||vt(!0)},[f,m]),Ht=(0,Q.useCallback)(()=>{f==null||!m||(m(f),vt(!1))},[f,m]),Ut=(0,Q.useCallback)(()=>{vt(!1)},[]);(0,Q.useLayoutEffect)(()=>{if(!H)return;let e=Tt.current;if(!e)return;let t=()=>{let t=window.getComputedStyle(e),n=Number.parseFloat(t.lineHeight),r=Number.parseFloat(t.fontSize)||14,i=Number.isFinite(n)?n:r*1.625;wt(e.scrollHeight>i*10+1)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[H,ye,He]),(0,Q.useLayoutEffect)(()=>{St(!1)},[H,He]);let Wt=b||!v,Gt=_e&&Iv(_e,j)&&(_e.workLog.active||_e.workLog.items.length>0)?(0,Z.jsx)(Hg,{workLog:_e.workLog,pendingStatus:M.pendingResponseStatus,toolLabels:pe,stepLabels:J,clusterLabels:me,cardLabels:he,conversationId:i,simplified:!t,personal:t,surfacesOnly:!t,answerStarted:_e.answer.started}):null;return(0,Z.jsx)(ld.Provider,{value:ud(_e?.deliveries??[]),children:(0,Z.jsxs)(`article`,{className:Y(`group/msg flex w-full min-w-0`,H?`justify-end`:`justify-start`,W&&`xopc-chat-user-message-enter`),children:[(0,Z.jsxs)(`div`,{className:Y(`min-w-0`,H?`flex w-full max-w-[min(78%,var(--max-width-chat-user))] flex-col items-end`:`w-full max-w-[var(--max-width-chat-reading)]`,T&&`max-w-full`),children:[(0,Z.jsx)(`span`,{className:`sr-only`,children:ue}),n?(0,Z.jsx)(Uv,{trigger:n}):null,H&&Fe?(0,Z.jsxs)(`div`,{className:`mb-2 flex w-full min-w-0 flex-wrap items-center justify-end gap-x-2 gap-y-0.5 text-xs`,children:[Ae?.message&&!Oe?(0,Z.jsx)(`span`,{className:`text-fg-subtle`,title:Ae.detail??``,children:Ae.message}):null,Pe&&!Ae?.message?(0,Z.jsx)(`span`,{className:`text-fg-subtle`,children:I.chat.thinkingLabel}):null]}):null,!H&&Fe&&!Ne?(0,Z.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-baseline gap-x-2 gap-y-0.5 text-xs text-fg-disabled`,children:[Ae?.message&&!Oe?(0,Z.jsx)(`span`,{className:`text-fg-subtle`,title:Ae.detail??``,children:Ae.message}):null,Pe&&!Ae?.message?(0,Z.jsx)(`span`,{className:`text-fg-subtle`,children:I.chat.thinkingLabel}):null]}):null,(0,Z.jsx)(`div`,{dir:H?`auto`:void 0,className:Y(`min-w-0 text-fg`,H&&`chat-user-message`,E===`compact`?`text-sm leading-relaxed`:H?`text-[0.9375rem] leading-[1.6667]`:`text-base leading-[1.6875]`,H&&`w-fit max-w-full rounded-2xl bg-surface-hover/80 px-4 py-3 text-left dark:bg-surface-hover/50`,Ne&&`bg-transparent p-0`),children:(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[Ne?(0,Z.jsx)(`div`,{className:`xopc-personal-thinking`,role:`status`,"aria-label":I.chat.thinkingLabel,children:(0,Z.jsxs)(`span`,{className:`xopc-personal-thinking-dots`,"aria-hidden":`true`,children:[(0,Z.jsx)(`i`,{}),(0,Z.jsx)(`i`,{}),(0,Z.jsx)(`i`,{})]})}):null,t?Gt:null,(ye?.length??0)>0?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{ref:H?Tt:we.contentRef,"data-chat-find-text":!0,className:Y(`relative min-w-0`,`flex flex-col gap-3`,H&&!xt&&`overflow-hidden`),style:H&&!xt?{maxHeight:`calc(10lh)`}:void 0,children:[we.summary,(0,Z.jsx)(Ah,{taskRunId:M.taskResultDelivery?.taskRunId,content:ye,isUser:H,isAssistantMessageStreaming:U&&s,imagePreviewLabel:I.chat.attachmentPreviewImage,onImagePreview:Et,conversationId:i,workspaceConversationId:a,projectId:o,progressiveRender:!!M.progressiveRender,onProgressiveRenderComplete:Ot,userTurnDocument:M.userTurnDocument,contextRefs:M.contextRefs,responseRunId:U?M.turnId:void 0,immediateFirstCommit:Vv(M,t),processItems:Ee,processCollapsed:we.collapsed,renderActivity:!t&&_e?(e,t)=>{let n=s&&(t||e.some(e=>e.type===`tool_use`&&e.status===`running`)),r=v_(e);return(0,Z.jsx)(Hg,{workLog:{items:e,active:n,status:n?`running`:e.some(e=>e.type===`tool_use`&&(e.status===`error`||e.activity?.status===`failed`))?`failed`:`completed`,compact:!1,expandedByDefault:u===`stream`&&n,startedAt:r.startedAt,durationMs:r.durationMs},toolLabels:pe,stepLabels:J,clusterLabels:me,cardLabels:he,conversationId:i,simplified:!1,showThinking:!0,renderSurfaces:!1})}:void 0}),Me?(0,Z.jsx)(`span`,{"aria-hidden":!0,"data-chat-streaming-cursor":!0,className:`pointer-events-none absolute start-0 top-full mt-1 h-3 w-0.5 bg-accent opacity-60`}):null]}),H&&Ct?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex w-fit items-center gap-1 rounded-md px-1.5 py-1 text-xs font-medium text-accent transition-colors hover:bg-accent/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,onClick:()=>St(e=>!e),"aria-expanded":xt,children:[xt?(0,Z.jsx)(ne,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(ee,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:xt?I.chat.userMessageCollapse:I.chat.userMessageExpand})]}):null]}):null,t?null:Gt,!t&&_e&&!_e.answer.started&&s&&!ye.some(e=>e.type===`thinking`||e.type===`tool_use`)?(0,Z.jsx)(Hg,{workLog:{items:[],active:!0,status:`running`,compact:!0,expandedByDefault:!1},pendingStatus:M.pendingResponseStatus,toolLabels:pe,stepLabels:J,clusterLabels:me,cardLabels:he,conversationId:i}):null,!t&&!H&&M.taskResultDelivery&&i?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,"data-result-follow-up":!0,children:[M.taskResultDelivery.resultRevision?(0,Z.jsxs)(`span`,{className:`text-xs text-fg-muted`,"data-result-revision":!0,children:[N===`zh`?`成果版本`:`Result version`,` `,M.taskResultDelivery.resultRevision]}):null,[{sourceId:`body`,title:M.taskResultDelivery.taskTitle},...M.taskResultDelivery.outcome.deliverables.filter(e=>e.availability===`available`).map(e=>({sourceId:e.artifactId,title:e.title}))].map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`max-w-64 truncate rounded-md border border-edge-subtle px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>{let t=M.taskResultDelivery;window.dispatchEvent(new CustomEvent(`chat-result-reference`,{detail:{conversationId:i,reference:{kind:`result`,sourceId:Ps(t.deliveryId.replace(/^reply:/,``),e.sourceId),expectedVersion:Fs(t),title:e.title}}}))},children:[N===`zh`?`询问:`:`Ask about: `,e.title]},e.sourceId))]}):null,_e?(0,Z.jsx)(Nv,{view:_e,authToken:r,conversationId:a??i,projectId:o,sourcesLabel:I.chat.searchSourcesHeading.replace(`{{count}}`,String(_e.sources.length))}):null,H&&M.sourceDevice?(0,Z.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[N===`zh`?`来自 `:`From `,M.sourceDevice.name]}):null,H&&De?.length?(0,Z.jsx)(Kv,{refs:De,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,truncatedLabel:I.chat.commandPalette.contextTruncated,showMoreLabel:I.chat.contextReferencesMore,showLessLabel:I.chat.contextReferencesLess,onOpen:e=>fe(e.sourceId)}):null,H&&xe?.length?(0,Z.jsx)(xm,{attachments:xe,authToken:r,conversationId:i,workspaceConversationId:a,layout:`user`,centerUserVoiceRow:He.length===0}):null]})}),q?(0,Z.jsxs)(`div`,{"data-delivery-status":de,role:re?`alert`:`status`,"aria-live":`polite`,"aria-hidden":oe&&!re?!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`,re?`text-danger`:`text-fg-subtle`,oe&&!re&&`opacity-0`),children:[re?(0,Z.jsx)(K,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}):null,(0,Z.jsx)(`span`,{children:re?I.chat.userMessageSendFailed:ce&&te?I.chat.userMessageWaitingForNetwork:I.chat.userMessageSending}),re&&_&&f!=null?(0,Z.jsx)(`button`,{type:`button`,className:`rounded-md px-1.5 py-0.5 font-medium text-danger underline-offset-2 hover:bg-danger/10 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-danger/40`,onClick:()=>_(f),children:I.chat.userMessageRetry}):null]}):null,!H&&M.personalProvenance&&!s&&(0,Z.jsx)(sm,{provenance:M.personalProvenance}),H&&!s&&!T?(0,Z.jsxs)(`div`,{"data-user-message-actions":!0,className:Y(`mt-1 flex h-8 w-full min-w-0 shrink-0 items-center justify-end gap-0.5 sm:gap-2`,`pointer-events-none opacity-0 transition-opacity duration-150 ease-out`,`group-hover/msg:pointer-events-auto group-hover/msg:opacity-100`,`group-focus-within/msg:pointer-events-auto group-focus-within/msg:opacity-100`,`[@media(hover:none)_and_(pointer:coarse)]:pointer-events-auto [@media(hover:none)_and_(pointer:coarse)]:opacity-100`),children:[_&&f!=null&&M.deliveryStatus!==`failed`?(0,Z.jsxs)(`button`,{type:`button`,className:Y(ny,Wt&&`opacity-40`),onClick:()=>_(f),disabled:Wt,title:b?I.chat.userMessageActionsWait:v?I.chat.userMessageRetry:I.chat.userMessageRetryDisabledHint,"aria-label":I.chat.userMessageRetry,children:[(0,Z.jsx)(At,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`max-w-[4.5rem] truncate sm:max-w-none`,children:I.chat.userMessageRetry})]}):null,(0,Z.jsx)(`button`,{type:`button`,className:Y(ny,`size-8 px-0`),onClick:()=>{if(O&&f!=null){O(M,f);return}Wp(He,Ln(M.attachments))},disabled:!He&&!M.attachments?.length&&!M.contextRefs?.length||!k,title:k?b?I.chat.userMessageStopAndEdit:I.chat.userMessageEdit:I.chat.userMessageEditDisabledHint,"aria-label":I.chat.userMessageEdit,children:(0,Z.jsx)(Dt,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})}),(0,Z.jsx)(`button`,{type:`button`,className:Y(ny,`size-8 px-0`),onClick:Ft,disabled:!He,title:Ue===`user`?I.chat.messageCopied:I.chat.userMessageCopy,"aria-label":Ue===`user`?I.chat.messageCopied:I.chat.userMessageCopy,children:Ue===`user`?(0,Z.jsx)(G,{className:`size-3.5 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(ve,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})}),m&&f!=null&&!b?(0,Z.jsx)(`button`,{type:`button`,className:Y(ny,`size-8 px-0 hover:text-red-500 dark:hover:text-red-400`),onClick:Vt,title:I.chat.userMessageDelete,"aria-label":I.chat.userMessageDelete,children:(0,Z.jsx)(Bt,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})}):null]}):null,Le?(0,Z.jsx)(`div`,{"data-assistant-actions-placeholder":!0,className:`mt-1 min-h-9 shrink-0`,"aria-hidden":`true`}):null,Ie&&Re?(0,Z.jsx)(g_,{children:(0,Z.jsxs)(`div`,{"data-assistant-message-actions":!0,className:Y(`mt-1 flex min-h-9 shrink-0 items-center gap-1 overflow-visible transition-opacity duration-150 ease-out motion-reduce:transition-none`,`pointer-events-none opacity-0 group-hover/msg:pointer-events-auto group-hover/msg:opacity-100`,`group-focus-within/msg:pointer-events-auto group-focus-within/msg:opacity-100`,`[@media(hover:none)_and_(pointer:coarse)]:pointer-events-auto [@media(hover:none)_and_(pointer:coarse)]:opacity-100`,(Ge||lt||st)&&`pointer-events-auto opacity-100`),children:[(0,Z.jsx)(__,{label:Ue===`plain`?I.chat.messageCopied:I.chat.messageCopyPlainText,children:(0,Z.jsx)(`button`,{type:`button`,className:ey,onClick:kt,disabled:!ze,"aria-label":Ue===`plain`?I.chat.messageCopied:I.chat.messageCopyPlainText,children:Ue===`plain`?(0,Z.jsx)(G,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(ve,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})})}),(0,Z.jsx)(__,{label:I.chat.messageReadAloud,children:(0,Z.jsx)(P,{input:Ve,labels:{read:I.chat.messageReadAloud,preparing:I.chat.messageReadAloudPreparing,pause:I.chat.messageReadAloudPause,resume:I.chat.messageReadAloudResume,retry:I.chat.messageReadAloudRetry},hideNativeTitle:!0})}),(0,Z.jsxs)(_i,{open:Ge,onOpenChange:e=>{Ke(e),e&&zt()},children:[(0,Z.jsx)(__,{label:I.chat.messageMoreActions,children:(0,Z.jsx)(yi,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:ey,"aria-label":I.chat.messageMoreActions,children:(0,Z.jsx)(be,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})})})}),(0,Z.jsx)(hi,{children:(0,Z.jsxs)(gi,{side:`bottom`,align:`start`,sideOffset:6,className:`z-[70] w-56 rounded-xl border border-edge bg-surface-overlay p-1.5 shadow-popover outline-none`,children:[(0,Z.jsx)(vi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:jt,children:[Ue===`markdown`?(0,Z.jsx)(G,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(Se,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),Ue===`markdown`?I.chat.messageCopied:I.chat.messageCopyMarkdown]})}),w&&M.turnId?(0,Z.jsx)(vi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:It,disabled:Qe,children:[(0,Z.jsx)(ms,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),Qe?I.chat.messageForkCreating:I.chat.messageForkFromHere]})}):null,x?(0,Z.jsx)(vi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:Mt,disabled:Xe!==null,children:[Je===`create-note`?(0,Z.jsx)(G,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(ds,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),Je===`create-note`?I.chat.messageSavedToNote:I.chat.messageSaveToNote]})}):null,A&&i&&M.timestamp?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`my-1 border-t border-edge-subtle`,role:`separator`}),(0,Z.jsx)(vi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>Lt(`helpful`),disabled:at,"aria-pressed":et===`helpful`,children:[(0,Z.jsx)(R,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),I.chat.messageHelpful]})}),(0,Z.jsx)(vi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>ut(e=>!e),disabled:at,"aria-pressed":et===`not_helpful`,children:[(0,Z.jsx)(V,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),I.chat.messageNotHelpful]})})]}):null,st?(0,Z.jsx)(`p`,{className:`px-2.5 py-1 text-xs text-danger`,role:`status`,children:I.chat.messageFeedbackUnavailable}):null,pt.length>0?(0,Z.jsx)(vi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>gt(e=>!e),children:[(0,Z.jsx)(ss,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),I.chat.messageWhyThisAnswer]})}):null,S?(0,Z.jsx)(vi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-40`,onClick:Nt,disabled:!Re||Xe!==null,children:[Je===`save-source-note`?(0,Z.jsx)(G,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(Te,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),Je===`save-source-note`?I.chat.messageSavedToSourceNote:I.chat.messageSaveToSourceNote]})}):null,C?(0,Z.jsx)(vi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-40`,onClick:Pt,disabled:!ze&&!Re||Xe!==null,children:[Je===`extract-task`?(0,Z.jsx)(G,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(qe,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),Je===`extract-task`?I.chat.messageTaskExtracted:I.chat.messageExtractTask]})}):null]})})]})]})}):null,Ie&&pt.length>0?(0,Z.jsx)(Yv,{open:ht,onOpenChange:gt,items:pt,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,Ie&&lt?(0,Z.jsxs)(`div`,{className:`mt-2 w-full max-w-xl rounded-xl border border-edge-subtle bg-surface-panel p-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:I.chat.messageFeedbackReasonTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:I.chat.messageFeedbackReasonHint}),(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:ty.map(e=>(0,Z.jsx)(`button`,{type:`button`,className:`rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,disabled:at,onClick:()=>Lt(`not_helpful`,e),children:I.chat.messageFeedbackReasons[e]},e))})]}):null,Ie&&et===`not_helpful`&&dt?(0,Z.jsxs)(`button`,{type:`button`,className:`mt-2 inline-flex w-fit items-center gap-1.5 rounded-lg bg-accent-soft px-3 py-1.5 text-xs font-medium text-accent-fg hover:bg-accent-soft/80`,onClick:Rt,children:[(0,Z.jsx)(At,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),I.chat.messageFeedbackRepair]}):null]}),H&&m&&f!=null&&!T?(0,Z.jsx)(La,{open:_t,title:I.chat.userMessageDeleteConfirmTitle,description:I.chat.userMessageDeleteConfirm,confirmLabel:I.chat.userMessageDeleteOk,cancelLabel:I.chat.userMessageDeleteCancel,destructive:!0,onConfirm:Ht,onCancel:Ut}):null,(0,Z.jsx)(Zr,{open:yt!==null,attachment:yt,images:(M.content??[]).flatMap((e,t)=>{if(e.type!==`image`)return[];let n=wm(e,t);return n?[n]:[]}),onAttachmentChange:bt,authToken:r,conversationId:i,onClose:()=>bt(null)})]})})}),oy=(0,Q.memo)(function(e){let t=(0,X.c)(3),n=Bm(e.conversationId,e.message.renderKey)??e.message,r;return t[0]!==n||t[1]!==e?(r=(0,Z.jsx)(ay,{...e,message:n}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r});function sy(e,t){return e.renderKey??`${e.timestamp??`n`}-${t}`}var cy=new Map;function ly(e,t=`time`){let n=`${e??`default`}:${t}`,r=cy.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}),cy.set(n,r)),r}function uy(e){return e?ly().format(e):``}var dy=1800*1e3;function fy(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function py(e,t){return e?!t||!fy(new Date(e),new Date(t))||e-t>=dy:!1}function my(e,t,n){let r=new Date(e),i=new Date(t),a=new Date(i);return a.setDate(i.getDate()-1),`${fy(r,i)?n===`zh`?`今天`:`Today`:fy(r,a)?n===`zh`?`昨天`:`Yesterday`:ly(n,r.getFullYear()===i.getFullYear()?`date`:`year`).format(r)} ${ly(n).format(r)}`}var hy=0,gy=1,_y=2,vy=4;function yy(e){return()=>e}function by(e){e()}function xy(e,t){return n=>e(t(n))}function Sy(e,t){return()=>e(t)}function Cy(e,t){return n=>e(t,n)}function wy(e){return e!==void 0}function Ty(...e){return()=>{e.map(by)}}function Ey(){}function Dy(e,t){return t(e),e}function Oy(e,t){return t(e)}function ky(...e){return e}function Ay(e,t){return e(gy,t)}function jy(e,t){e(hy,t)}function My(e){e(_y)}function Ny(e){return e(vy)}function Py(e,t){return Ay(e,Cy(t,hy))}function Fy(e,t){let n=e(gy,e=>{n(),t(e)});return n}function Iy(e){let t,n;return r=>i=>{t=i,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Ly(e,t){return e===t}function Ry(e=Ly){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function zy(e){return t=>n=>{e(n)&&t(n)}}function By(e){return t=>xy(t,e)}function Vy(e){return t=>()=>{t(e)}}function $(e,...t){let n=Ky(...t);return((t,r)=>{switch(t){case _y:My(e);return;case gy:return Ay(e,n(r))}})}function Hy(e,t){return n=>r=>{n(t=e(t,r))}}function Uy(e){return t=>n=>{e>0?e--:t(n)}}function Wy(e){let t=null,n;return r=>i=>{t=i,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Gy(...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;Ay(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 Ky(...e){return t=>e.reduceRight(Oy,t)}function qy(e){let t,n,r=()=>t?.();return function(i,a){switch(i){case gy:return a?n===a?void 0:(r(),n=a,t=Ay(e,a),t):(r(),Ey);case _y:r(),n=null;return}}}function Jy(e){let t=e,n=Xy();return((e,r)=>{switch(e){case hy:t=r;break;case gy:r(t);break;case vy:return t}return n(e,r)})}function Yy(e,t){return Dy(Jy(t),t=>Py(e,t))}function Xy(){let e=[];return((t,n)=>{switch(t){case hy:e.slice().forEach(e=>{e(n)});return;case _y:e.splice(0);return;case gy:return e.push(n),()=>{let t=e.indexOf(n);t>-1&&e.splice(t,1)}}})}function Zy(e){return Dy(Xy(),t=>Py(e,t))}var Qy={singleton:!0};function $y(e,t=[],n=Qy){let{singleton:r}=n;return{constructor:e,dependencies:t,id:eb(),singleton:r}}var eb=()=>Symbol(`id`);function tb(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 nb(...e){let t=Xy(),n=Array.from({length:e.length}),r=0,i=2**e.length-1;return e.forEach((e,a)=>{let o=2**a;Ay(e,e=>{n[a]=e,r|=o,r===i&&jy(t,n)})}),function(e,a){switch(e){case _y:My(t);return;case gy:return r===i&&a(n),Ay(t,a)}}}function rb(e,t=Ly){return $(e,Ry(t))}function ib(...e){return function(t,n){switch(t){case _y:return;case gy:return Ty(...e.map(e=>Ay(e,n)))}}}var ab={DEBUG:0,INFO:1,WARN:2,ERROR:3},ob={[ab.DEBUG]:`debug`,[ab.ERROR]:`error`,[ab.INFO]:`log`,[ab.WARN]:`warn`},sb=()=>typeof globalThis>`u`?window:globalThis,cb=$y(()=>{let e=Jy(ab.ERROR);return{log:Jy((t,n,r=ab.INFO)=>{r>=(sb().VIRTUOSO_LOG_LEVEL??Ny(e))&&console[ob[r]](`%creact-virtuoso: %c%s %o`,`color: #0253b3; font-weight: bold`,`color: initial`,t,n)}),logLevel:e}},[],{singleton:!0});function lb(e){return`self`in e?e.document.documentElement:e}function ub(e){let t=lb(e);return t.ownerDocument.defaultView.getComputedStyle(t).direction===`rtl`}function db(e,t){return ub(e)?-t:t}function fb(e,t){return ub(e)?-t:t}function pb(e,t,n){return mb(e,t,n).callbackRef}function mb(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 hb(e,t,n,r,i,a,o,s,c){return mb(Q.useCallback(n=>{let c=gb(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?db(o,o.scrollLeft):o.scrollTop:u?s?db(d,d.scrollX||d.document.documentElement.scrollLeft):d.scrollY||d.document.documentElement.scrollTop:s?db(l,l.scrollLeft):l.scrollTop;r({scrollHeight:f,scrollTop:Math.max(m,0),viewportHeight:p}),a?.(s?_b(`column-gap`,getComputedStyle(n).columnGap,i):_b(`row-gap`,getComputedStyle(n).rowGap,i)),c!==null&&e(c)},[e,t,i,a,o,r,s]),n,c)}function gb(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},ab.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 _b(e,t,n){return t!==`normal`&&t?.endsWith(`px`)!==!0&&n(`${e} was not resolved to pixel value correctly`,t,ab.WARN),t===`normal`?0:parseInt(t??`0`,10)}var vb=typeof document>`u`?Q.useEffect:Q.useLayoutEffect;function yb(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}=mb(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 bb=$y(()=>{let e=Xy(),t=Xy(),n=Jy(0),r=Xy(),i=Xy(),a=Jy(0),o=Xy(),s=Xy(),c=Jy(0),l=Jy(0),u=Jy(0),d=Jy(0),f=Xy(),p=Xy(),m=Jy(!1),h=Jy(!1),g=Jy(!1);return Py($(e,By(({scrollTop:e})=>e)),t),Py($(e,By(({scrollHeight:e})=>e)),s),Py(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}),xb={lvl:0};function Sb(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 Cb(e){return e===xb}function wb(e,t){if(!Cb(e))return t===e.k?e.v:t<e.k?wb(e.l,t):wb(e.r,t)}function Tb(e,t,n=`k`){if(Cb(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){let r=Tb(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return Tb(e.l,t,n)}function Eb(e,t,n){return Cb(e)?Lb(t,n,1):t===e.k?Nb(e,{k:t,v:n}):t<e.k?Rb(Nb(e,{l:Eb(e.l,t,n)})):Rb(Nb(e,{r:Eb(e.r,t,n)}))}function Db(){return xb}function Ob(e,t,n){if(Cb(e))return[];let r=Tb(e,t)[0];return Vb(jb(e,r,n))}function kb(e,t){if(Cb(e))return xb;let{k:n,l:r,r:i}=e;if(t===n){if(Cb(r))return i;if(Cb(i))return r;let[t,n]=Ib(r);return Mb(Nb(e,{k:t,l:Pb(r),v:n}))}return Mb(t<n?Nb(e,{l:kb(r,t)}):Nb(e,{r:kb(i,t)}))}function Ab(e){return Cb(e)?[]:[...Ab(e.l),{k:e.k,v:e.v},...Ab(e.r)]}function jb(e,t,n){if(Cb(e))return[];let{k:r,l:i,r:a,v:o}=e,s=[];return r>t&&(s=s.concat(jb(i,t,n))),r>=t&&r<=n&&s.push({k:r,v:o}),r<=n&&(s=s.concat(jb(a,t,n))),s}function Mb(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(Fb(t))return zb(Nb(e,{lvl:n-1}));if(!Cb(t)&&!Cb(t.r))return Nb(t.r,{l:Nb(t,{r:t.r.l}),lvl:n,r:Nb(e,{l:t.r.r,lvl:n-1})});throw Error(`Unexpected empty nodes`)}if(Fb(e))return Bb(Nb(e,{lvl:n-1}));if(!Cb(r)&&!Cb(r.l)){let t=r.l,i=Fb(t)?r.lvl-1:r.lvl;return Nb(t,{l:Nb(e,{lvl:n-1,r:t.l}),lvl:t.lvl+1,r:Bb(Nb(r,{l:t.r,lvl:i}))})}throw Error(`Unexpected empty nodes`)}function Nb(e,t){return Lb(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 Pb(e){return Cb(e.r)?e.l:Mb(Nb(e,{r:Pb(e.r)}))}function Fb(e){return Cb(e)||e.lvl>e.r.lvl}function Ib(e){return Cb(e.r)?[e.k,e.v]:Ib(e.r)}function Lb(e,t,n,r=xb,i=xb){return{k:e,l:r,lvl:n,r:i,v:t}}function Rb(e){return Bb(zb(e))}function zb(e){let{l:t}=e;return!Cb(t)&&t.lvl===e.lvl?Nb(t,{r:Nb(e,{l:t.r})}):e}function Bb(e){let{lvl:t,r:n}=e;return!Cb(n)&&!Cb(n.r)&&n.lvl===t&&n.r.lvl===t?Nb(n,{l:Nb(e,{r:n.l}),lvl:t+1}):e}function Vb(e){return Sb(e,({k:e,v:t})=>({index:e,value:t}))}function Hb(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Ub(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}var Wb=$y(()=>({recalcInProgress:Jy(!1)}),[],{singleton:!0});function Gb(e,t,n){return e[Kb(e,t,n)]}function Kb(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 qb(e,t,n,r){let i=Kb(e,t,r),a=Kb(e,n,r,i);return e.slice(i,a+1)}function Jb(e,t){return Math.round(e.getBoundingClientRect()[t])}function Yb(e){return!Cb(e.groupOffsetTree)}function Xb({index:e},t){return t===e?0:t<e?-1:1}function Zb(){return{groupIndices:[],groupOffsetTree:Db(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Db()}}function Qb(e,t){let n=Cb(e)?0:1/0;for(let r of t){let{endIndex:t,size:i,startIndex:a}=r;if(n=Math.min(n,a),Cb(e)){e=Eb(e,0,i);continue}let o=Ob(e,a-1,t+1);if(o.some(ux(r)))continue;let s=!1,c=!1;for(let{end:n,start:r,value:a}of o)s?(t>=r||i===a)&&(e=kb(e,r)):(c=a!==i,s=!0),n>t&&t>=r&&a!==i&&(e=Eb(e,t+1,a));c&&(e=Eb(e,a,i))}return[e,n]}function $b(e){return e.groupIndex!==void 0}function ex({offset:e},t){return t===e?0:t<e?-1:1}function tx(e,t,n){if(t.length===0)return 0;let{index:r,offset:i,size:a}=Gb(t,e,Xb),o=e-r,s=a*o+(o-1)*n+i;return s>0?s+n:s}function nx(e,t){if(!Yb(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function rx(e,t,n){if($b(e))return t.groupIndices[e.groupIndex]+1;let r=nx(e.index===`LAST`?n:e.index,t);return r=Math.max(0,Math.min(n,r)),r}function ix(e,t,n,r=0){return r>0&&(t=Math.max(t,Gb(e,r,Xb).offset)),Sb(qb(e,t,n,ex),lx)}function ax(e,[t,n,r,i]){t.length>0&&r(`received item sizes`,t,ab.DEBUG);let a=e.sizeTree,o=a,s=0;if(n.length>0&&Cb(a)&&t.length===2){let e=t[0].size,r=t[1].size;o=n.reduce((t,n)=>Eb(Eb(t,n,e),n+1,r),o)}else[o,s]=Qb(o,t);if(o===a)return e;let{lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d}=cx(e.offsetTree,s,o,i);return{groupIndices:n,groupOffsetTree:n.reduce((e,t)=>Eb(e,t,tx(t,d,i)),Db()),lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d,sizeTree:o}}function ox(e){return Ab(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 sx(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 cx(e,t,n,r){let i=e,a=0,o=0,s=0,c=0;if(t===0)i=[];else{c=Kb(i,t-1,Xb),s=i[c].offset;let e=Tb(n,t-1);a=e[0],o=e[1],i.length&&i[c].size===Tb(n,t)[1]&&--c,i=i.slice(0,c+1)}for(let{start:e,value:c}of Ob(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 lx(e){return{index:e.index,value:e}}function ux(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 dx={offsetHeight:`height`,offsetWidth:`width`},fx=$y(([{log:e},{recalcInProgress:t}])=>{let n=Xy(),r=Xy(),i=Yy(r,0),a=Xy(),o=Xy(),s=Jy(0),c=Jy([]),l=Jy(void 0),u=Jy(void 0),d=Jy(void 0),f=Jy(void 0),p=Jy((e,t)=>Jb(e,dx[t])),m=Jy(void 0),h=Jy(0),g=Zb(),_=Yy($(n,Gy(c,e,h),Hy(ax,g),Ry()),g),v=Yy($(c,Ry(),Hy((e,t)=>({current:t,prev:e.current}),{current:[],prev:[]}),By(({prev:e})=>e)),[]);Py($(c,zy(e=>e.length>0),Gy(_,h),By(([e,t,n])=>{let r=e.reduce((e,r,i)=>Eb(e,r,tx(r,t.offsetTree,n)||i),Db());return{...t,groupIndices:e,groupOffsetTree:r}})),_),Py($(r,Gy(_),zy(([e,{lastIndex:t}])=>e<t),By(([e,{lastIndex:t,lastSize:n}])=>[{endIndex:t,size:n,startIndex:e}])),n),Py(l,u);let y=Yy($(l,By(e=>e===void 0)),!0);Py($(u,zy(e=>e!==void 0&&Cb(Ny(_).sizeTree)),By(e=>{let t=Ny(d),n=Ny(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),Py($(f,zy(e=>e!==void 0&&e.length>0&&Cb(Ny(_).sizeTree)),By(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),Py($(c,Gy(d,u),zy(([,e,t])=>e!==void 0&&t!==void 0),By(([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=Zy($(n,Gy(_),Hy(({sizes:e},[t,n])=>({changed:n!==e,sizes:n}),{changed:!1,sizes:g}),By(e=>e.changed)));Ay($(s,Hy((e,t)=>({diff:e.prev-t,prev:t}),{diff:0,prev:0}),By(e=>e.diff)),e=>{let{groupIndices:n}=Ny(_);if(e>0)jy(t,!0),jy(a,e+sx(e,n));else if(e<0){let t=Ny(v);t.length>0&&(e-=sx(-e,t)),jy(o,e)}}),Ay($(s,Gy(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},ab.ERROR)});let x=Zy(a);Py($(a,Gy(_),By(([e,t])=>{let n=t.groupIndices.length>0,r=[],i=t.lastSize;if(n){let n=wb(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=Ab(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 Ab(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=Zy($(o,Gy(_,h),By(([e,{offsetTree:t},n])=>tx(-e,t,n))));return Py($(o,Gy(_,h),By(([e,t,n])=>{if(t.groupIndices.length>0){if(Cb(t.sizeTree))return t;let r=Db(),i=Ny(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=Ab(t.sizeTree).reduce((t,{k:n,v:r})=>Eb(t,Math.max(0,n+e),r),r),a!==-e){let n=wb(t.sizeTree,s);r=Eb(r,0,n);let i=Tb(t.sizeTree,-e+1)[1];r=Eb(r,1,i)}return{...t,sizeTree:r,...cx(t.offsetTree,0,r,n)}}let r=Ab(t.sizeTree).reduce((t,{k:n,v:r})=>Eb(t,Math.max(0,n+e),r),Db());return{...t,sizeTree:r,...cx(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}},ky(cb,Wb),{singleton:!0});function px(e){return e.reduce((e,t)=>(e.groupIndices.push(e.totalCount),e.totalCount+=t+1,e),{groupIndices:[],totalCount:0})}var mx=$y(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:i}])=>{let a=Xy(),o=Xy(),s=Zy($(a,By(px)));return Py($(s,By(e=>e.totalCount)),n),Py($(s,By(e=>e.groupIndices)),e),Py($(nb(i,t,r),zy(([e,t])=>Yb(t)),By(([e,t,n])=>Tb(t.groupOffsetTree,Math.max(e-n,0),`v`)[0]),Ry(),By(e=>[e])),o),{groupCounts:a,topItemsIndexes:o}},ky(fx,bb)),hx=$y(([{log:e}])=>{let t=Jy(!1),n=Zy($(t,zy(e=>e),Ry()));return Ay(t,t=>{t&&Ny(e)(`props updated`,{},ab.DEBUG)}),{didMount:n,propsReady:t}},ky(cb),{singleton:!0}),gx=typeof document<`u`&&`scrollBehavior`in document.documentElement.style;function _x(e){let t=typeof e==`number`?{index:e}:{...e};return t.align||=`start`,(!t.behavior||!gx)&&(t.behavior=`auto`),t.offset===void 0&&(t.offset=0),t}var vx=$y(([{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=Xy(),m=Xy(),h=Jy(0),g=null,_=null,v=null;function y(){g!==null&&(g(),g=null),v!==null&&(v(),v=null),_&&=(clearTimeout(_),null),jy(c,!1)}return Py($(p,Gy(n,d,r,h,s,o,f),Gy(e,a,i),By(([[e,n,r,i,a,o,s,l],d,f,h])=>{let b=_x(e),{align:x,behavior:S,offset:C}=b,w=i-1,T=rx(b,n,w),E=tx(T,n.offsetTree,d)+o;x===`end`?(E+=f+Tb(n.sizeTree,T)[1]-r+h,T===w&&(E+=s)):x===`center`?E+=(f+Tb(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},ab.DEBUG),jy(p,e)):(jy(m,!0),l(`list did not change, scroll successful`,{},ab.DEBUG))};if(y(),S===`smooth`){let e=!1;v=Ay(t,t=>{e||=t}),g=Fy(u,()=>{D(e)})}else g=Fy($(t,yx(150)),D);return _=setTimeout(()=>{y()},1200),jy(c,!0),l(`scrolling from index to`,{behavior:S,index:T,top:E},ab.DEBUG),{behavior:S,top:E}})),l),{scrollTargetReached:m,scrollToIndex:p,topListHeight:h}},ky(fx,bb,cb),{singleton:!0});function yx(e){return t=>{let n=setTimeout(()=>{t(!1)},e);return e=>{e&&(t(!0),clearTimeout(n))}}}function bx(e,t){e===0?t():requestAnimationFrame(()=>{bx(e-1,t)})}function xx(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 Sx(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 Cx=$y(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:i,scrollToIndex:a},{didMount:o}])=>{let s=Jy(!0),c=Jy(0),l=Jy(!0);return Py($(o,Gy(c),zy(([e,t])=>!Sx(t)),Vy(!1)),s),Py($(o,Gy(c),zy(([e,t])=>!Sx(t)),Vy(!1)),l),Ay($(nb(t,o),Gy(s,n,e,l),zy(([[,e],t,{sizeTree:n},r,i])=>e&&(!Cb(n)||wy(r))&&!t&&!i),Gy(c)),([,e])=>{if(e===void 0){jy(s,!0),jy(l,!0);return}Fy(i,()=>{jy(l,!0)}),bx(4,()=>{Fy(r,()=>{jy(s,!0)}),jy(a,e)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:c,scrolledToInitialItem:s}},ky(fx,bb,vx,hx),{singleton:!0});function wx(e,t){return Math.abs(e-t)<1.01}var Tx=`up`,Ex=`down`,Dx=`none`,Ox={atBottom:!1,notAtBottomBecause:`NOT_SHOWING_LAST_ITEM`,state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},kx=0,Ax=$y(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:i,viewportHeight:a}])=>{let o=Jy(!1),s=Jy(!0),c=Xy(),l=Xy(),u=Jy(4),d=Jy(kx),f=Yy($(ib($(rb(i),Uy(1),Vy(!0)),$(rb(i),Uy(1),Vy(!1),Iy(100))),Ry()),!1),p=Yy($(ib($(n,Vy(!0)),$(n,Vy(!1),Iy(200))),Ry()),!1);Py($(nb(rb(i),rb(d)),By(([e,t])=>e<=t),Ry()),s),Py($(s,Wy(50)),l);let m=Zy($(nb(r,rb(a),rb(t),rb(e),rb(u)),Hy((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}},Ox),Ry((e,t)=>e!==void 0&&e.atBottom===t.atBottom))),h=Yy($(r,Hy((e,{scrollHeight:t,scrollTop:n,viewportHeight:r})=>{if(!wx(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}),zy(e=>e.changed),By(e=>e.jump)),0);Py($(m,By(e=>e.atBottom)),o),Py($(o,Wy(50)),c);let g=Jy(Ex);Py($(r,By(({scrollTop:e})=>e),Ry(),Hy((e,t)=>Ny(p)?{direction:e.direction,prevScrollTop:t}:{direction:t<e.prevScrollTop?Tx:Ex,prevScrollTop:t},{direction:Ex,prevScrollTop:0}),By(e=>e.direction)),g),Py($(r,Wy(50),Vy(Dx)),g);let _=Jy(0);return Py($(f,zy(e=>!e),Vy(0)),_),Py($(i,Wy(100),Gy(f),zy(([e,t])=>t),Hy(([e,t],[n])=>[t,n],[0,0]),By(([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:_}},ky(bb)),jx=`top`,Mx=`bottom`,Nx=`none`;function Px(e,t,n){return typeof e==`number`?n===Tx&&t===jx||n===Ex&&t===Mx?e:0:n===Tx?t===jx?e.main:e.reverse:t===Mx?e.main:e.reverse}function Fx(e,t){return typeof e==`number`?e:e[t]??0}var Ix=$y(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:i}])=>{let a=Xy(),o=Jy(0),s=Jy(0),c=Jy(0);return{increaseViewportBy:s,listBoundary:a,overscan:c,topListHeight:o,visibleRange:Yy($(nb(rb(r),rb(i),rb(n),rb(a,Ub),rb(c),rb(o),rb(t),rb(e),rb(s)),By(([e,t,n,[r,i],a,o,s,c,l])=>{let u=e-c,d=o+s,f=Math.max(n-u,0),p=Nx,m=Fx(l,jx),h=Fx(l,Mx);return r-=c,r+=n+s,i+=n+s,i-=c,r>e+d-m&&(p=Tx),i<e-f+t+h&&(p=Ex),p===Nx?null:[Math.max(u-n-Px(a,jx,p)-m,0),u-f-s+t+Px(a,Mx,p)+h]}),zy(e=>e!==null),Ry(Ub)),[0,0])}},ky(bb),{singleton:!0});function Lx(e,t,n){if(Yb(t)){let r=nx(e,t);return[{index:Tb(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 Rx={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function zx(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:Vx(e,i,a),offsetBottom:m,offsetTop:l,top:p,topItems:Vx(t,i,a),topListHeight:t.reduce((e,t)=>t.size+e,0),totalCount:n}}function Bx(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=xx(t,c?l:s),d=c?Math.max(0,Math.min(s,l-u)):s;return zx(Array.from({length:d}).map((e,t)=>({data:a?.[t+u],index:t+u,offset:0,size:0})),[],d,i,n,r)}function Vx(e,t,n){if(e.length===0)return[];if(!Yb(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=Ob(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 Hx(e,t){return e===void 0?0:typeof e==`number`?e:e[t]??0}var Ux=$y(([{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=Jy([]),g=Jy(0),_=Xy(),v=Jy(0);Py(a.topItemsIndexes,h);let y=Yy($(nb(p,m,rb(c,Ub),rb(i),rb(r),rb(l),u,rb(h),rb(t),rb(n),rb(v),e,rb(g)),zy(([e,t,,n,,,,,,,,r])=>{let i=r!==void 0&&r.length!==n;return e&&!t&&!i}),By(([,,[e,t],n,r,i,a,o,s,c,l,u,d])=>{let f=r,{offsetTree:p,sizeTree:m}=f;if(n===0)return{...Rx,totalCount:n};if(e===0&&t===0)return d===0?{...Rx,totalCount:n}:Bx(d,i,r,s,c,u);if(Cb(m))return d>0?null:zx(Lx(xx(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 Ob(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 zx([],h,n,c,f,s);let g=o.length>0?o[o.length-1]+1:0,_=ix(p,e,t,g);if(_.length===0)return null;let v=n-1,y=Dy([],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=Hx(l,jx),x=Hx(l,Mx);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=Ob(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=Ob(m,r,r)[0]?.value??t.size;y.push({data:u?.[r],index:r,offset:n,size:e}),n+=e+c}}}return zx(y,h,n,c,f,s)}),zy(e=>e!==null),Ry()),Rx);Py($(e,zy(wy),By(e=>e?.length)),i),Py($(y,By(e=>e.topListHeight)),d),Py(d,s),Py($(y,By(e=>[e.top,e.bottom])),o),Py($(y,By(e=>e.items)),_);let b=Zy($(y,zy(({items:e})=>e.length>0),Gy(i,e),zy(([{items:e},t])=>e[e.length-1].originalIndex===t-1),By(([,e,t])=>[e-1,t]),Ry(Ub),By(([e])=>e))),x=Zy($(y,Wy(200),zy(({items:e,topItems:t})=>e.length>0&&e[0].originalIndex===t.length),By(({items:e})=>e[0].index),Ry()));return{endReached:b,initialItemCount:g,itemsRendered:_,listState:y,minOverscanItemCount:v,rangeChanged:Zy($(y,zy(({items:e})=>e.length>0),By(({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}}),Ry(Hb))),startReached:x,topItemsIndexes:h,...f}},ky(fx,mx,Ix,Cx,vx,Ax,hx,Wb),{singleton:!0}),Wx=$y(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:i}])=>{let a=Xy(),o=Yy($(nb(n,e,r,t,i),By(([e,t,n,r,i])=>e+t+n+r+i.offsetBottom+i.bottom)),0);return Py(rb(o),a),{totalListHeight:o,totalListHeightChanged:a}},ky(bb,Ux),{singleton:!0}),Gx=$y(([{viewportHeight:e},{totalListHeight:t}])=>{let n=Jy(!1);return{alignToBottom:n,paddingTopAddition:Yy($(nb(n,e,t),zy(([e])=>e),By(([,e,t])=>Math.max(0,e-t)),Wy(0),Ry()),0)}},ky(bb,Wx),{singleton:!0}),Kx=$y(()=>({context:Jy(null)})),qx=({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,Jx=$y(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:i,headerHeight:a,scrollingInProgress:o,scrollTop:s,viewportHeight:c},{scrollToIndex:l}])=>{let u=Xy();return Py($(u,Gy(t,c,n,a,i,r,s),Gy(e),By(([[e,t,n,r,i,a,s,c],l])=>{let{calculateViewLocation:u=qx,done:d,...f}=e,p=rx(e,t,r-1),m=tx(p,t.offsetTree,l)+i+a,h=m+Tb(t.sizeTree,p)[1],g=c+a,_=u({itemBottom:h,itemTop:m,locationParams:f,viewportBottom:c+n-s,viewportTop:g});return _===null?d?.():d&&Fy($(o,zy(e=>!e),Uy(Ny(o)?1:2)),d),_}),zy(e=>e!==null)),l),{scrollIntoView:u}},ky(fx,bb,vx,Ux,cb),{singleton:!0});function Yx(e){return e===!1?!1:e===`smooth`?`smooth`:`auto`}var Xx=(e,t)=>typeof e==`function`?Yx(e(t)):t&&Yx(e),Zx=$y(([{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=Jy(!1),h=Xy(),g=null;function _(e){jy(o,{align:`end`,behavior:e,index:`LAST`})}Ay($(nb($(rb(t),Uy(1)),c),Gy(rb(m),a,s,d),By(([[e,t],n,r,i,a])=>{let o=t&&i,s=`auto`;return o&&(s=Xx(n,r||a),o&&=s!==!1),{followOutputBehavior:s,shouldFollow:o,totalCount:e}}),zy(({shouldFollow:e})=>e)),({followOutputBehavior:t,totalCount:r})=>{g!==null&&(g(),g=null),Ny(n)===void 0?g=Fy(e,()=>{Ny(u)(`following output to `,{totalCount:r},ab.DEBUG),_(t),g=null}):requestAnimationFrame(()=>{Ny(u)(`following output to `,{totalCount:r},ab.DEBUG),_(t)})});function v(e){let t=Fy(i,t=>{e&&!t.atBottom&&t.notAtBottomBecause===`SIZE_INCREASED`&&g===null&&(Ny(u)(`scrolling to bottom due to increased size`,{},ab.DEBUG),_(`auto`))});setTimeout(t,100)}Ay($(nb(rb(m),t,l),zy(([e,,t])=>e!==!1&&t),Hy(({value:e},[,t])=>({refreshed:e===t,value:t}),{refreshed:!1,value:0}),zy(({refreshed:e})=>e),Gy(m,t)),([,e])=>{Ny(s)&&v(e!==!1)}),Ay(h,()=>{v(Ny(m)!==!1)}),Ay(nb(rb(m),i),([e,t])=>{e!==!1&&!t.atBottom&&t.notAtBottomBecause===`VIEWPORT_HEIGHT_DECREASING`&&_(`auto`)});let y=Jy(null),b=Xy();return Py(ib($(rb(r),By(e=>e?.length??0)),$(rb(t))),b),Ay($(nb($(b,Uy(1)),c),Gy(rb(y),s,d,f),By(([[e,t],n,r,i,a])=>t&&r&&n?.({context:a,totalCount:e,scrollingInProgress:i})),zy(e=>!!e),Wy(0)),t=>{g!==null&&(g(),g=null),Ny(n)===void 0?g=Fy(e,()=>{Ny(u)(`scrolling into view`,{}),jy(p,t),g=null}):requestAnimationFrame(()=>{Ny(u)(`scrolling into view`,{}),jy(p,t)})}),{autoscrollToBottom:h,followOutput:m,scrollIntoViewOnChange:y}},ky(fx,Ax,vx,Cx,hx,cb,bb,Kx,Jx)),Qx=$y(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:i},{initialItemCount:a,listState:o},{didMount:s}])=>(Py($(s,Gy(a),zy(([,e])=>e!==0),Gy(i,r,t,n,e),By(([[,e],t,n,r,i,a])=>Bx(e,t,n,r,i,a))),o),{}),ky(fx,Cx,Ux,hx),{singleton:!0}),$x=$y(([{didMount:e},{scrollTo:t},{listState:n}])=>{let r=Jy(0);return Ay($(e,Gy(r),zy(([,e])=>e!==0),By(([,e])=>({top:e}))),e=>{Fy($(n,Uy(1),zy(e=>e.items.length>1)),()=>{requestAnimationFrame(()=>{jy(t,e)})})}),{initialScrollTop:r}},ky(hx,bb,Ux),{singleton:!0}),eS=$y(([{scrollVelocity:e}])=>{let t=Jy(!1),n=Xy(),r=Jy(!1);return Py($(e,Gy(r,t,n),zy(([e,t])=>t!==!1&&t!==void 0),By(([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}),Ry()),t),Ay($(nb(t,e,n),Gy(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}},ky(Ax),{singleton:!0}),tS=$y(([{scrollContainerState:e,scrollTo:t}])=>{let n=Xy(),r=Xy(),i=Xy(),a=Jy(!1),o=Jy(void 0);return Py($(nb(n,r),By(([{scrollTop:e,viewportHeight:t},{offsetTop:n,listHeight:r}])=>({scrollHeight:r,scrollTop:Math.max(0,e-n),viewportHeight:t}))),e),Py($(t,Gy(r),By(([e,{offsetTop:t}])=>({...e,top:e.top+t}))),i),{customScrollParent:o,useWindowScroll:a,windowScrollContainerState:n,windowScrollTo:i,windowViewportRect:r}},ky(bb)),nS=$y(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:i},{didMount:a},{useWindowScroll:o,windowScrollContainerState:s,windowViewportRect:c}])=>{let l=Xy(),u=Jy(void 0),d=Jy(null),f=Jy(null);return Py(s,d),Py(c,f),Ay($(l,Gy(t,r,o,d,f,n)),([e,t,n,r,i,a,o])=>{let s=ox(t.sizeTree);r&&i!==null&&a!==null&&(n=i.scrollTop-a.offsetTop),n-=o,e({ranges:s,scrollTop:n})}),Py($(u,zy(wy),By(rS)),i),Py($(a,Gy(u),zy(([,e])=>e!==void 0),Ry(),By(([,e])=>e.ranges)),e),{getState:l,restoreStateFrom:u}},ky(fx,bb,Cx,hx,tS));function rS(e){return{align:`start`,index:0,offset:e.scrollTop}}var iS=$y(([{topItemsIndexes:e}])=>{let t=Jy(0);return Py($(t,zy(e=>e>=0),By(e=>Array.from({length:e}).map((e,t)=>t))),e),{topItemCount:t}},ky(Ux));function aS(e){let t=!1,n;return(()=>(t||(t=!0,n=e()),n))}var oS=aS(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),sS=$y(([{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 Py(k,T.scrollSeekRangeChanged),Py($(nb(T.windowViewportRect,_.headerHeight,_.fixedHeaderHeight),By(([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}},ky(fx,Cx,bb,nS,Zx,Ux,vx,$y(([{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=Zy($(l,Gy(s),Hy(([,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]),zy(([e])=>e!==0),Gy(i,c,r,a,m,h),zy(([,e,t,n,,,r])=>!r&&!n&&e!==0&&t===Tx),By(([[e],,,,,t])=>(t(`Upward scrolling compensation`,{amount:e},ab.DEBUG),e))));function _(t){t>0?(jy(n,{behavior:`auto`,top:-t}),jy(e,0)):(jy(e,0),jy(n,{behavior:`auto`,top:-t}))}Ay($(g,Gy(e,o)),([t,n,r])=>{r&&oS()?jy(e,n-t):_(-t)}),Ay($(nb(Yy(o,!1),e,h),zy(([e,t,n])=>!e&&!n&&t!==0),By(([e,t])=>t),Wy(1)),_),Py($(f,By(e=>({top:-e}))),n);let v=null;function y(){if(v===null)return;let{offset:t}=v;v=null,jy(n,{top:t}),requestAnimationFrame(()=>{jy(e,0),jy(h,!1)})}return Ay(t,e=>{v===null||!v.acknowledgeable||e===v.offset&&y()}),Ay($(u,Gy(p,d),By(([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=wb(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:Ny(e)!==t,offset:t},jy(e,t),requestAnimationFrame(y)}),{deviation:e}},ky(bb,Ax,Ux,fx,cb,Wb)),iS,mx,$y(([e,t,n,r,i,a,o,s,c,l,u])=>({...e,...t,...n,...r,...i,...a,...o,...s,...c,...l,...u}),ky(Ix,Qx,hx,eS,Wx,$x,Gx,tS,Jx,cb,Kx))));function cS(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 lS=typeof document>`u`?Q.useEffect:Q.useLayoutEffect;function uS(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&&jy(e.propsReady,!1);for(let i of r){let r=e[t.required[i]];jy(r,n[i])}for(let r of i)if(r in n){let i=e[t.optional[r]];jy(i,n[r])}e.propsReady!==void 0&&jy(e.propsReady,!0)}function l(e){return a.reduce((n,r)=>(n[r]=n=>{let i=e[t.methods[r]];jy(i,n)},n),{})}function u(e){return o.reduce((n,r)=>(n[r]=qy(e[t.events[r]]),n),{})}return{Component:Q.forwardRef(function(t,a){let{children:d,...f}=t,[p]=Q.useState(()=>Dy(tb(e),e=>{c(e,f)})),[m]=Q.useState(Sy(u,p));lS(()=>{for(let e of o)e in f&&Ay(m[e],f[e]);return()=>{Object.values(m).map(My)}},[f,m,p]),lS(()=>{c(p,f)}),Q.useImperativeHandle(a,yy(l(p)));let h=n;return(0,Z.jsx)(s.Provider,{value:p,children:n===void 0?d:(0,Z.jsx)(h,{...cS([...r,...i,...o],f),children:d})})}),useEmitter:(e,t)=>{let n=Q.useContext(s)[e];lS(()=>Ay(n,t),[t,n])},useEmitterValue:e=>{let t=Q.useContext(s)[e],n=Q.useCallback(e=>Ay(t,e),[t]);return Q.useSyncExternalStore(n,()=>Ny(t),()=>Ny(t))},usePublisher:e=>{let t=Q.useContext(s);return Q.useCallback(n=>{jy(t[e],n)},[t,e])}}}var dS=Q.createContext(void 0),fS=Q.createContext(void 0),pS=`-webkit-sticky`,mS=`sticky`,hS=aS(()=>{if(typeof document>`u`)return mS;let e=document.createElement(`div`);return e.style.position=pS,e.style.position===pS?pS:mS});function gS(e){return`self`in e}function _S(e){return`body`in e}function vS(e,t,n,r=Ey,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(_S(l)||gS(l)){let e=gS(l)?l:l.defaultView;o=a===!0?db(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?db(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():Is.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;gS(r)?(u=Math.max(Jb(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?db(r,r.scrollX):r.scrollY):(u=r[a===!0?`scrollWidth`:`scrollHeight`],l=Jb(r,a===!0?`width`:`height`),d=a===!0?db(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,wx(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:fb(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:fb(o.current,e.top)}}),o.current.scrollBy(e)},[a]),scrollerRef:o,scrollToCallback:u}}function yS(e){return e}var bS=$y(([e,t])=>({...e,...t}),ky(sS,$y(()=>{let e=Jy(e=>`Item ${e}`),t=Jy(e=>`Group ${e}`),n=Jy({}),r=Jy(yS),i=Jy(`div`),a=Jy(Ey),o=(e,t=null)=>Yy($(n,By(t=>t[e]),Ry()),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`)}}))),xS=({height:e})=>(0,Z.jsx)(`div`,{style:{height:e}}),SS={overflowAnchor:`none`,position:hS(),zIndex:1},CS={overflowAnchor:`none`},wS={...CS,display:`inline-block`,height:`100%`},TS=Q.memo(function({showTopList:e=!1}){let t=HS(`listState`),n=US(`sizeRanges`),r=HS(`useWindowScroll`),i=HS(`customScrollParent`),a=US(`windowScrollContainerState`),o=US(`scrollContainerState`),s=i||r?a:o,c=HS(`itemContent`),l=HS(`context`),u=HS(`groupContent`),d=HS(`trackItemSizes`),f=HS(`itemSize`),p=HS(`log`),m=US(`gap`),h=HS(`horizontalDirection`),{callbackRef:g}=hb(n,f,d,e?Ey:s,p,m,i,h,HS(`skipAnimationFrameInResizeObserver`)),[_,v]=Q.useState(0);VS(`deviation`,e=>{_!==e&&v(e)});let y=US(`deviationCommitted`);vb(()=>{y(_)},[_,y]);let b=HS(`EmptyPlaceholder`),x=HS(`ScrollSeekPlaceholder`)??xS,S=HS(`ListComponent`),C=HS(`ItemComponent`),w=HS(`GroupComponent`),T=HS(`computeItemKey`),E=HS(`isSeeking`),D=HS(`groupIndices`).length>0,O=HS(`alignToBottom`),k=HS(`initialItemFinalLocationReached`),A=e?{}:{boxSizing:`border-box`,...h?{display:`inline-block`,height:`100%`,marginInlineStart:_===0?O?`auto`:0:_,paddingInlineEnd:t.offsetBottom,paddingInlineStart:t.offsetTop,whiteSpace:`nowrap`}:{marginTop:_===0?O?`auto`:0:_,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...k?{}:{visibility:`hidden`}};return!e&&t.totalCount===0&&b!=null?(0,Z.jsx)(b,{...jS(b,l)}):(0,Z.jsx)(S,{...jS(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,{...jS(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,{...jS(w,l),"data-index":n,"data-item-index":e.index,"data-known-size":e.size,key:r,style:SS},u(e.index,l)):(0,Q.createElement)(C,{...jS(C,l),...MS(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?wS:CS},D?c(e.index,e.groupIndex,e.data,l):c(e.index,e.data,l))})})}),ES={height:`100%`,outline:`none`,overflowY:`auto`,position:`relative`,WebkitOverflowScrolling:`touch`},DS={outline:`none`,overflowX:`auto`,position:`relative`},OS=e=>({height:`100%`,position:`absolute`,top:0,width:`100%`,...e?{display:`flex`,flexDirection:`column`}:void 0}),kS=(e,t,n=0)=>({...OS(e),position:t?`relative`:`absolute`,top:t?-n:0}),AS={position:hS(),top:0,width:`100%`,zIndex:1};function jS(e,t){if(typeof e!=`string`)return{context:t}}function MS(e,t){return{item:typeof e==`string`?void 0:t}}var NS=Q.memo(function(){let e=HS(`HeaderComponent`),t=US(`headerHeight`),n=HS(`HeaderFooterTag`),r=pb(Q.useMemo(()=>e=>{t(Jb(e,`height`))},[t]),!0,HS(`skipAnimationFrameInResizeObserver`)),i=HS(`context`);return e==null?null:(0,Z.jsx)(n,{ref:r,children:(0,Z.jsx)(e,{...jS(e,i)})})}),PS=Q.memo(function(){let e=HS(`FooterComponent`),t=US(`footerHeight`),n=HS(`HeaderFooterTag`),r=pb(Q.useMemo(()=>e=>{t(Jb(e,`height`))},[t]),!0,HS(`skipAnimationFrameInResizeObserver`)),i=HS(`context`);return e==null?null:(0,Z.jsx)(n,{ref:r,children:(0,Z.jsx)(e,{...jS(e,i)})})});function FS({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}=vS(s,l,c,u,void 0,d);return e(`scrollTo`,m),e(`scrollBy`,f),(0,Z.jsx)(c,{"data-testid":`virtuoso-scroller`,"data-virtuoso-scroller":!0,ref:p,style:{...d?DS:ES,...i},tabIndex:0,...o,...jS(c,a),children:r})})}function IS({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}=vS(s,l,c,t(`scrollerRef`),f);return vb(()=>(h.current=f??p.current?.ownerDocument.defaultView,()=>{h.current=null}),[h,f]),e(`windowScrollTo`,g),e(`scrollBy`,m),(0,Z.jsx)(c,{ref:p,"data-virtuoso-scroller":!0,style:{position:`relative`,...i,...u===0?void 0:{height:u+d}},...o,...jS(c,a),children:r})})}var LS=({children:e})=>{let t=Q.useContext(dS),n=US(`viewportHeight`),r=US(`fixedItemHeight`),i=HS(`alignToBottom`),a=HS(`horizontalDirection`),o=pb(Q.useMemo(()=>xy(n,e=>Jb(e,a?`width`:`height`)),[n,a]),!0,HS(`skipAnimationFrameInResizeObserver`));return Q.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),(0,Z.jsx)(`div`,{"data-viewport-type":`element`,ref:o,style:OS(i),children:e})},RS=({children:e})=>{let t=Q.useContext(dS),n=US(`windowViewportRect`),r=US(`fixedItemHeight`),i=HS(`customScrollParent`),a=HS(`useWindowScroll`),o=HS(`topListHeight`),s=yb(n,i,HS(`skipAnimationFrameInResizeObserver`)),c=HS(`alignToBottom`);return Q.useEffect(()=>{t&&(r(t.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),(0,Z.jsx)(`div`,{"data-viewport-type":`window`,ref:s,style:kS(c,a,o),children:e})},zS=({children:e})=>{let t=HS(`TopItemListComponent`)??`div`,n=HS(`headerHeight`);return(0,Z.jsx)(t,{style:{...AS,marginTop:`${n}px`},...jS(t,HS(`context`)),children:e})},{Component:BS,useEmitter:VS,useEmitterValue:HS,usePublisher:US}=uS(bS,{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=HS(`useWindowScroll`),n=HS(`topItemsIndexes`).length>0,r=HS(`customScrollParent`),i=HS(`context`);return(0,Z.jsxs)(r||t?GS:WS,{...e,context:i,children:[n&&(0,Z.jsx)(zS,{children:(0,Z.jsx)(TS,{showTopList:!0})}),(0,Z.jsxs)(r||t?RS:LS,{children:[(0,Z.jsx)(NS,{}),(0,Z.jsx)(TS,{}),(0,Z.jsx)(PS,{})]})]})})),WS=FS({useEmitter:VS,useEmitterValue:HS,usePublisher:US}),GS=IS({useEmitter:VS,useEmitterValue:HS,usePublisher:US}),KS=BS,qS=$y(([e,t])=>({...e,...t}),ky(sS,$y(()=>{let e=Jy(e=>(0,Z.jsxs)(`td`,{children:[`Item $`,e]})),t=Jy(null),n=Jy(e=>(0,Z.jsxs)(`td`,{colSpan:1e3,children:[`Group `,e]})),r=Jy(null),i=Jy(null),a=Jy({}),o=Jy(yS),s=Jy(Ey),c=(e,t=null)=>Yy($(a,By(t=>t[e]),Ry()),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`)}}))),JS=({height:e})=>(0,Z.jsx)(`tr`,{children:(0,Z.jsx)(`td`,{style:{height:e}})}),YS=({height:e})=>(0,Z.jsx)(`tr`,{children:(0,Z.jsx)(`td`,{style:{border:0,height:e,padding:0}})}),XS={overflowAnchor:`none`},ZS={position:hS(),zIndex:2,overflowAnchor:`none`},QS=Q.memo(function({showTopList:e=!1}){let t=iC(`listState`),n=iC(`computeItemKey`),r=iC(`firstItemIndex`),i=iC(`context`),a=iC(`isSeeking`),o=iC(`fixedHeaderHeight`),s=iC(`groupIndices`).length>0,c=iC(`itemContent`),l=iC(`groupContent`),u=iC(`ScrollSeekPlaceholder`)??JS,d=iC(`GroupComponent`),f=iC(`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,{...jS(u,i),height:t.size,index:t.index,key:h,type:t.type||`item`}):t.type===`group`?(0,Q.createElement)(d,{...jS(d,i),"data-index":m,"data-item-index":t.index,"data-known-size":t.size,key:h,style:{...ZS,top:o}},l(t.index,i)):(0,Q.createElement)(f,{...jS(f,i),...MS(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?{...ZS,top:o+g}:XS},s?c(t.index,t.groupIndex,t.data,i):c(t.index,t.data,i))})}),$S=Q.memo(function(){let e=iC(`listState`),t=iC(`topItemsIndexes`).length>0,n=aC(`sizeRanges`),r=iC(`useWindowScroll`),i=iC(`customScrollParent`),a=aC(`windowScrollContainerState`),o=aC(`scrollContainerState`),s=i||r?a:o,c=iC(`trackItemSizes`),{callbackRef:l,ref:u}=hb(n,iC(`itemSize`),c,s,iC(`log`),void 0,i,!1,iC(`skipAnimationFrameInResizeObserver`)),[d,f]=Q.useState(0);rC(`deviation`,e=>{d!==e&&(u.current.style.marginTop=`${e}px`,f(e))});let p=aC(`deviationCommitted`);vb(()=>{p(d)},[d,p]);let m=iC(`EmptyPlaceholder`),h=iC(`FillerRow`)??YS,g=iC(`TableBodyComponent`),_=iC(`paddingTopAddition`),v=iC(`statefulTotalCount`),y=iC(`context`);if(v===0&&m!=null)return(0,Z.jsx)(m,{...jS(m,y)});let b=(t?e.topItems:[]).reduce((e,t)=>e+t.size,0),x=e.offsetTop+_+d-b,S=e.offsetBottom,C=x>0?(0,Z.jsx)(h,{context:y,height:x},`padding-top`):null,w=S>0?(0,Z.jsx)(h,{context:y,height:S},`padding-bottom`):null;return(0,Z.jsxs)(g,{"data-testid":`virtuoso-item-list`,ref:l,...jS(g,y),children:[C,t&&(0,Z.jsx)(QS,{showTopList:!0}),(0,Z.jsx)(QS,{}),w]})}),eC=({children:e})=>{let t=Q.useContext(dS),n=aC(`viewportHeight`),r=aC(`fixedItemHeight`),i=pb(Q.useMemo(()=>xy(n,e=>Jb(e,`height`)),[n]),!0,iC(`skipAnimationFrameInResizeObserver`));return Q.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),(0,Z.jsx)(`div`,{"data-viewport-type":`element`,ref:i,style:OS(!1),children:e})},tC=({children:e})=>{let t=Q.useContext(dS),n=aC(`windowViewportRect`),r=aC(`fixedItemHeight`),i=iC(`customScrollParent`),a=iC(`useWindowScroll`),o=yb(n,i,iC(`skipAnimationFrameInResizeObserver`));return Q.useEffect(()=>{t&&(r(t.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),(0,Z.jsx)(`div`,{"data-viewport-type":`window`,ref:o,style:kS(!1,a),children:e})},{Component:nC,useEmitter:rC,useEmitterValue:iC,usePublisher:aC}=uS(qS,{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=iC(`useWindowScroll`),n=iC(`customScrollParent`),r=aC(`fixedHeaderHeight`),i=aC(`fixedFooterHeight`),a=iC(`fixedHeaderContent`),o=iC(`fixedFooterContent`),s=iC(`context`),c=pb(Q.useMemo(()=>xy(r,e=>Jb(e,`height`)),[r]),!0,iC(`skipAnimationFrameInResizeObserver`)),l=pb(Q.useMemo(()=>xy(i,e=>Jb(e,`height`)),[i]),!0,iC(`skipAnimationFrameInResizeObserver`)),u=n||t?sC:oC,d=n||t?tC:eC,f=iC(`TableComponent`),p=iC(`TableHeadComponent`),m=iC(`TableFooterComponent`),h=a?(0,Z.jsx)(p,{ref:c,style:{position:`sticky`,top:0,zIndex:2},...jS(p,s),children:a()},`TableHead`):null,g=o?(0,Z.jsx)(m,{ref:l,style:{bottom:0,position:`sticky`,zIndex:1},...jS(m,s),children:o()},`TableFoot`):null;return(0,Z.jsx)(u,{...e,...jS(u,s),children:(0,Z.jsx)(d,{children:(0,Z.jsxs)(f,{style:{borderSpacing:0,overflowAnchor:`none`},...jS(f,s),children:[h,(0,Z.jsx)($S,{},`TableBody`),g]})})})})),oC=FS({useEmitter:rC,useEmitterValue:iC,usePublisher:aC}),sC=IS({useEmitter:rC,useEmitterValue:iC,usePublisher:aC}),cC={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},lC={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:uC,floor:dC,max:fC,min:pC,round:mC}=Math;function hC(e,t,n){return Array.from({length:t-e+1}).map((t,r)=>({data:n===null?null:n[r+e],index:r+e}))}function gC(e){return{...lC,items:e}}function _C(e,t){return e!==void 0&&e.width===t.width&&e.height===t.height}function vC(e,t){return e!==void 0&&e.column===t.column&&e.row===t.row}var yC=$y(([{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=Jy(0),C=Jy(0),w=Jy(cC),T=Jy({height:0,width:0}),E=Jy({height:0,width:0}),D=Xy(),O=Xy(),k=Jy(0),A=Jy(null),j=Jy({column:0,row:0}),M=Xy(),N=Xy(),P=Jy(!1),F=Jy(0),I=Jy(!0),L=Jy(!1),R=Jy(!1);Ay($(m,Gy(F),zy(([e,t])=>!Sx(t))),()=>{jy(I,!1)}),Ay($(nb(m,I,E,T,F,L),zy(([e,t,n,r,,i])=>e&&!t&&n.height!==0&&r.height!==0&&!i)),([,,,,e])=>{if(e===void 0){jy(I,!0);return}jy(L,!0),bx(1,()=>{jy(D,e)}),Fy($(l),()=>{jy(t,[0,0]),jy(I,!0)})}),Py($(N,zy(e=>e!=null&&e.scrollTop>0),Vy(0)),C),Ay($(m,Gy(N),zy(([,e])=>e!=null)),([,e])=>{e&&(jy(T,e.viewport),jy(E,e.item),jy(j,e.gap),e.scrollTop>0&&(jy(P,!0),Fy($(l,Uy(1)),e=>{jy(P,!1)}),jy(c,{top:e.scrollTop})))}),Py($(T,By(({height:e})=>e)),d),Py($(nb(rb(T,_C),rb(E,_C),rb(j,(e,t)=>e!==void 0&&e.column===t.column&&e.row===t.row),rb(l)),By(([e,t,n,r])=>({gap:n,item:t,scrollTop:r,viewport:e}))),M),Py($(nb(rb(S),r,rb(j,vC),rb(E,_C),rb(T,_C),rb(A),rb(C),rb(P),rb(I),rb(F)),zy(([,,,,,,,e])=>!e),By(([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 cC;if(p===0){let t=xx(l,e);return gC(hC(t,t+Math.max(s-1,0),o))}let h=bC(m,p,u),g,_;c?t===0&&n===0&&s>0?(g=0,_=s-1):(g=h*dC((t+d)/(f+d)),_=h*uC((n+d)/(f+d))-1,_=pC(e-1,fC(_,h-1)),g=pC(_,fC(0,g))):(g=0,_=-1);let v=hC(g,_,o),{bottom:y,top:b}=xC(a,r,i,v),x=uC(e/h);return{bottom:y,itemHeight:f,items:v,itemWidth:p,offsetBottom:x*f+(x-1)*d-y,offsetTop:b,top:b}})),w),Py($(A,zy(e=>e!==null),By(e=>e.length)),S),Py($(nb(T,E,w,j),zy(([e,t,{items:n}])=>n.length>0&&t.height!==0&&e.height!==0),By(([e,t,{items:n},r])=>{let{bottom:i,top:a}=xC(e,r,t,n);return[a,i]}),Ry(Ub)),t);let z=Jy(!1);Py($(l,Gy(z),By(([e,t])=>t||e!==0)),z);let B=Zy($(nb(w,S),zy(([{items:e}])=>e.length>0),Gy(z),zy(([[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}),By(([[,e]])=>e-1),Ry())),V=Zy($(rb(w),zy(({items:e})=>e.length>0&&e[0].index===0),Vy(0),Ry())),H=Zy($(rb(w),Gy(P),zy(([{items:e},t])=>e.length>0&&!t),By(([{items:e}])=>({endIndex:e[e.length-1].index,startIndex:e[0].index})),Ry(Hb),Wy(0)));Py(H,p.scrollSeekRangeChanged),Py($(D,Gy(T,E,S,j),By(([e,t,n,r,i])=>{let a=_x(e),{align:o,behavior:s,offset:c}=a,l=a.index;l===`LAST`&&(l=r-1),l=fC(0,l,pC(r-1,l));let u=SC(t,i,n,l);return o===`end`?u=mC(u-t.height+n.height):o===`center`&&(u=mC(u-t.height/2+n.height/2)),c!==void 0&&c!==0&&(u+=c),{behavior:s,top:u}})),c);let U=Yy($(w,By(e=>e.offsetBottom+e.bottom)),0);return Py($(b,By(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}},ky(Ix,bb,Ax,eS,hx,tS,cb));function bC(e,t,n){return fC(1,dC((e+n)/(dC(t)+n)))}function xC(e,t,n,r){let{height:i}=n;if(i===void 0||r.length===0)return{bottom:0,top:0};let a=SC(e,t,n,r[0].index);return{bottom:SC(e,t,n,r[r.length-1].index)+i,top:a}}function SC(e,t,n,r){let i=dC(r/bC(e.width,n.width,t.column)),a=i*n.height+fC(0,i-1)*t.row;return a>0?a+t.row:a}var CC=$y(([e,t])=>({...e,...t}),ky(yC,$y(()=>{let e=Jy(e=>`Item ${e}`),t=Jy({}),n=Jy(null),r=Jy(`virtuoso-grid-item`),i=Jy(`virtuoso-grid-list`),a=Jy(yS),o=Jy(`div`),s=Jy(Ey),c=(e,n=null)=>Yy($(t,By(t=>t[e]),Ry()),n),l=Jy(!1),u=Jy(!1);return Py(rb(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`)}}))),wC=Q.memo(function(){let e=jC(`gridState`),t=jC(`listClassName`),n=jC(`itemClassName`),r=jC(`itemContent`),i=jC(`computeItemKey`),a=jC(`isSeeking`),o=MC(`scrollHeight`),s=jC(`ItemComponent`),c=jC(`ListComponent`),l=jC(`ScrollSeekPlaceholder`),u=jC(`context`),d=MC(`itemDimensions`),f=MC(`gap`),p=jC(`log`),m=jC(`stateRestoreInProgress`),h=MC(`reportReadyState`),g=pb(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:FC(`column-gap`,getComputedStyle(e).columnGap,p),row:FC(`row-gap`,getComputedStyle(e).rowGap,p)})},[o,d,f,p]),!0,!1);return vb(()=>{e.itemHeight>0&&e.itemWidth>0&&h(!0)},[e]),m?null:(0,Z.jsx)(c,{className:t,ref:g,...jS(c,u),"data-testid":`virtuoso-item-list`,style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(t=>{let o=i(t.index,t.data,u);return a?(0,Z.jsx)(l,{...jS(l,u),height:e.itemHeight,index:t.index,width:e.itemWidth},o):(0,Q.createElement)(s,{...jS(s,u),className:n,"data-index":t.index,key:o},r(t.index,t.data,u))})})}),TC=Q.memo(function(){let e=jC(`HeaderComponent`),t=MC(`headerHeight`),n=jC(`headerFooterTag`),r=pb(Q.useMemo(()=>e=>{t(Jb(e,`height`))},[t]),!0,!1),i=jC(`context`);return e==null?null:(0,Z.jsx)(n,{ref:r,children:(0,Z.jsx)(e,{...jS(e,i)})})}),EC=Q.memo(function(){let e=jC(`FooterComponent`),t=MC(`footerHeight`),n=jC(`headerFooterTag`),r=pb(Q.useMemo(()=>e=>{t(Jb(e,`height`))},[t]),!0,!1),i=jC(`context`);return e==null?null:(0,Z.jsx)(n,{ref:r,children:(0,Z.jsx)(e,{...jS(e,i)})})}),DC=({children:e})=>{let t=Q.useContext(fS),n=MC(`itemDimensions`),r=MC(`viewportDimensions`),i=pb(Q.useMemo(()=>e=>{r(e.getBoundingClientRect())},[r]),!0,!1);return Q.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),(0,Z.jsx)(`div`,{ref:i,style:OS(!1),children:e})},OC=({children:e})=>{let t=Q.useContext(fS),n=MC(`windowViewportRect`),r=MC(`itemDimensions`),i=jC(`customScrollParent`),a=jC(`useWindowScroll`),o=yb(n,i,!1);return Q.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),(0,Z.jsx)(`div`,{ref:o,style:kS(!1,a),children:e})},{Component:kC,useEmitter:AC,useEmitterValue:jC,usePublisher:MC}=uS(CC,{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=jC(`useWindowScroll`),n=jC(`customScrollParent`),r=n||t?PC:NC,i=n||t?OC:DC,a=jC(`context`);return(0,Z.jsx)(r,{...e,...jS(r,a),children:(0,Z.jsxs)(i,{children:[(0,Z.jsx)(TC,{}),(0,Z.jsx)(wC,{}),(0,Z.jsx)(EC,{})]})})})),NC=FS({useEmitter:AC,useEmitterValue:jC,usePublisher:MC}),PC=IS({useEmitter:AC,useEmitterValue:jC,usePublisher:MC});function FC(e,t,n){return t!==`normal`&&t?.endsWith(`px`)!==!0&&n(`${e} was not resolved to pixel value correctly`,t,ab.WARN),t===`normal`?0:parseInt(t??`0`,10)}function IC(e){return e.scrollHeight-e.scrollTop-e.clientHeight}function LC(e,t=96){return IC(e)<=t}function RC(e){Math.abs(IC(e))>.5&&(e.scrollTop=e.scrollHeight)}function zC(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 BC(){return typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}var VC=new WeakMap;function HC(e,t){return VC.set(e,t),()=>{VC.get(e)===t&&VC.delete(e)}}function UC(e){return VC.get(e)}function WC(e){e.dispatchEvent(new Event(`chat-scroll-reading`))}function GC({context:e}){return e?.footer}var KC={Footer:GC},qC={top:800,bottom:800};function JC({rows:e,scrollRef:t,renderRow:n,footer:r}){let i=(0,Q.useRef)(null),[a,o]=(0,Q.useState)(),[s,c]=(0,Q.useState)(qC),[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 HC(a,{reveal:t=>{let n=e.findIndex(e=>e.index===t||e.aliases.includes(t));return n<0?!1:(WC(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&&BC()===`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=qC.top+(e?a.scrollTop-e.start:0),r=qC.bottom+(e?e.end-a.scrollTop:0);c(e=>e.top===n&&e.bottom===r?e:{top:n,bottom:r})},n=()=>{e!==null&&t()};return document.addEventListener(`selectionchange`,t),a.addEventListener(`scroll`,n,{passive:!0}),()=>{document.removeEventListener(`selectionchange`,t),a.removeEventListener(`scroll`,n)}},[a]),a?(0,Z.jsx)(KS,{ref:i,customScrollParent:a,data:e,skipAnimationFrameInResizeObserver:!0,components:KC,context:{footer:r},firstItemIndex:l.first,initialTopMostItemIndex:{index:e.length-1,align:`end`},defaultItemHeight:160,increaseViewportBy:s,computeItemKey:(e,t)=>t.key,itemContent:(t,r)=>(0,Z.jsx)(`div`,{className:r===e[0]?void 0:`pt-8`,children:n(r.index)})}):null}var YC=e=>{},XC=(0,Q.memo)(function(e){let t=(0,X.c)(47),{messages:n,timelineEntries:r,personal:i,authToken:a,conversationId:o,workspaceConversationId:s,projectId:c,streaming:l,sending:u,progress:d,reasoningLevel:f,registerListContentRef:p,onPickWelcomePrompt:m,welcomeSpotlight:g,welcomeOverlay:_,compactWelcome:v,onDeleteRound:b,onRetryUserMessageRound:x,deleteRoundDisabled:S,onSaveAssistantAsNote:C,onSaveAssistantToSourceNote:w,onExtractAssistantTask:T,onForkAssistantTurn:E,onEditUserMessage:D,editLatestUserOnly:O,editRequiresTurnId:k,responseFeedbackEnabled:A,showAssistantWorkLog:j,hideAssistantActions:M,trailingContent:N,replySpaceRef:P,scrollRef:F}=e,I=r===void 0?[]:r,L=i!==void 0&&i,R=u!==void 0&&u,z=v!==void 0&&v,B=O!==void 0&&O,V=k!==void 0&&k,H=j===void 0||j,U=M!==void 0&&M,W=h(ZC),G;t[0]===W?G=t[1]:(G=y(W),t[0]=W,t[1]=G);let ee=G,[te]=(0,Q.useState)(!!(F&&n.length>=300));if(n.length===0&&I.length===0&&!l&&!R){if(_){let e;return t[2]===_?e=t[3]:(e=(0,Z.jsx)(`div`,{className:`pb-1.5`,children:_}),t[2]=_,t[3]=e),e}let e;t[4]!==ee||t[5]!==g?(e=g??{headline:ee.chat.welcomeSpotlight.headline,contextKind:`empty`,contextStatus:`ready`},t[4]=ee,t[5]=g,t[6]=e):e=t[6];let n=m??YC,r;return t[7]!==z||t[8]!==e||t[9]!==n?(r=(0,Z.jsx)(`div`,{className:`pb-1.5`,children:(0,Z.jsx)(am,{spotlight:e,onPickPrompt:n,compact:z})}),t[7]=z,t[8]=e,t[9]=n,t[10]=r):r=t[10],r}let ne=Date.now(),re;t[11]===n?re=t[12]:(re=n.findLastIndex(QC),t[11]=n,t[12]=re);let ie=re,ae;t[13]!==n.length||t[14]!==R||t[15]!==l?(ae=(e,t)=>!!((l||R||e.pendingResponseStatus)&&t===n.length-1&&e.role===`assistant`),t[13]=n.length,t[14]=R,t[15]=l,t[16]=ae):ae=t[16];let oe=ae,se;t[17]===n?se=t[18]:(se=(e,t)=>e.role===`assistant`&&e.turnId&&n[t-1]?.role===`task`&&n[t-1]?.turnId===e.turnId?n[t-1].taskTrigger:void 0,t[17]=n,t[18]=se);let ce=se,le;t[19]!==ce||t[20]!==oe||t[21]!==n||t[22]!==L||t[23]!==f||t[24]!==H?(le=(e,t)=>!Lv(e,{personal:L,isStreaming:oe(e,t),reasoningLevel:f,showAssistantWorkLog:H,followUpTrigger:ce(e,t)})||e.role===`task`&&e.taskTrigger&&e.turnId&&n[t+1]?.role===`assistant`&&n[t+1]?.turnId===e.turnId?[]:[{key:sy(e,t),index:t,aliases:e.role===`assistant`&&n[t-1]?.role===`task`&&e.turnId===n[t-1]?.turnId?[t-1]:[]}],t[19]=ce,t[20]=oe,t[21]=n,t[22]=L,t[23]=f,t[24]=H,t[25]=le):le=t[25];let ue=n.flatMap(le),K;t[26]===n.length?K=t[27]:(K=(e,t)=>({key:e.id,index:n.length+t,aliases:[]}),t[26]=n.length,t[27]=K),ue.push(...I.map(K));let q=0,de=n.map(e=>(q=Math.max(e.timestamp??q,q),q));I.length&&ue.sort((e,t)=>{let r=e=>e<n.length?de[e]:I[e-n.length].timestamp;return r(e.index)-r(t.index)||e.index-t.index});let fe=new Map(ue.map((e,t)=>[e.index,ue[t-1]?.index])),pe=e=>{if(e>=n.length){let t=I[e-n.length];return(0,Z.jsx)(`div`,{"data-chat-timeline-entry":t.id,children:t.content},t.id)}let t=n[e],r=oe(t,e),i=e===ie,l=n[e-1],u=ce(t,e),p=fe.get(e),m=p===void 0?void 0:n[p],h=m&&p!==void 0?ce(m,p)?n[p-1]?.timestamp??m.timestamp:m.timestamp:void 0,g=sy(t,e),_=u?l?.timestamp??t.timestamp:t.timestamp,v=py(_,h);return(0,Z.jsxs)(`div`,{id:`chat-message-${e}`,className:Y(`scroll-mt-4`,m&&(m.role===`user`||m.role===`task`)&&!u&&!v&&`-mt-5`),"data-chat-message-index":e,"data-chat-message-row":!0,"data-client-submission-id":t.clientSubmissionId,"data-message-render-key":t.renderKey,children:[u?(0,Z.jsx)(`span`,{id:`chat-message-${e-1}`,className:`block h-0 scroll-mt-4`,"aria-hidden":!0}):null,v&&_?(0,Z.jsx)(`div`,{className:`mb-8 flex justify-center`,"data-chat-time-separator":!0,children:(0,Z.jsx)(`time`,{suppressHydrationWarning:!0,className:`rounded-md px-2 py-1 text-xs tabular-nums text-fg-disabled`,dateTime:new Date(_).toISOString(),children:my(_,ne,W)})}):null,t.role===`task`&&t.taskTrigger?(0,Z.jsx)(Uv,{trigger:t.taskTrigger}):(0,Z.jsx)(oy,{message:t,personal:L,followUpTrigger:u,authToken:a,conversationId:o,workspaceConversationId:s,projectId:c,isStreaming:r,progress:r?d:null,reasoningLevel:f,messageIndex:e,onDeleteRound:b,onRetryUserMessageRound:x,userMessageCanRetry:!!x&&i,deleteRoundDisabled:!!(S&&i),onSaveAssistantAsNote:C,onSaveAssistantToSourceNote:w,onExtractAssistantTask:T,onForkAssistantTurn:E,suppressAssistantActions:U,onEditUserMessage:D,userMessageCanEdit:(!B||i)&&(!V||!!t.turnId)&&t.deliveryStatus!==`sending`,responseFeedbackEnabled:A,showAssistantWorkLog:H})]},g)},J=te?`pt-8`:`contents`,me;t[28]===J?me=t[29]:(me=Y(J),t[28]=J,t[29]=me);let he;t[30]!==P||t[31]!==te?(he=P&&(0,Z.jsx)(`div`,{ref:P,className:Y(!te&&`-mt-8`,`shrink-0 transition-none`),"aria-hidden":!0,"data-chat-reply-space":!0}),t[30]=P,t[31]=te,t[32]=he):he=t[32];let ge;t[33]!==me||t[34]!==he||t[35]!==N?(ge=(0,Z.jsxs)(`div`,{className:me,children:[N,he]}),t[33]=me,t[34]=he,t[35]=N,t[36]=ge):ge=t[36];let _e=ge,ve=aa,ye=!te&&`flex flex-col gap-8`,be;t[37]===ye?be=t[38]:(be=Y(`w-full min-w-0 pb-8`,ye),t[37]=ye,t[38]=be);let xe=te||void 0,Se=te&&F?(0,Z.jsx)(JC,{rows:ue,scrollRef:F,renderRow:pe,footer:_e}):(0,Z.jsxs)(Z.Fragment,{children:[ue.map(e=>pe(e.index)),_e]}),Ce;t[39]!==p||t[40]!==be||t[41]!==xe||t[42]!==Se?(Ce=(0,Z.jsx)(`div`,{ref:p,className:be,"data-chat-virtualized":xe,children:Se}),t[39]=p,t[40]=be,t[41]=xe,t[42]=Se,t[43]=Ce):Ce=t[43];let we;return t[44]!==ve||t[45]!==Ce?(we=(0,Z.jsx)(ve,{children:Ce}),t[44]=ve,t[45]=Ce,t[46]=we):we=t[46],we});function ZC(e){return e.language}function QC(e){return e.role===`user`}function $C(e){let t=(0,X.c)(8),{alt:n,className:r,"aria-hidden":i}=e,a=n?.trim()?n:void 0,o=i??(!a||void 0),s;t[0]===r?s=t[1]:(s=Y(`xopc-loop-logo relative inline-block shrink-0`,r),t[0]=r,t[1]=s);let c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsxs)(`linearGradient`,{id:`xopc-onboarding-ai-glass`,x1:`198`,y1:`180`,x2:`826`,y2:`844`,gradientUnits:`userSpaceOnUse`,children:[(0,Z.jsx)(`stop`,{stopColor:`var(--xopc-loop-ai-highlight)`}),(0,Z.jsx)(`stop`,{offset:`0.46`,stopColor:`var(--xopc-loop-ai)`}),(0,Z.jsx)(`stop`,{offset:`1`,stopColor:`var(--xopc-loop-ai-shadow)`})]}),t[2]=c):c=t[2];let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsxs)(`svg`,{className:`size-full overflow-visible`,viewBox:`0 0 1024 1024`,fill:`none`,"aria-hidden":`true`,children:[(0,Z.jsxs)(`defs`,{children:[c,(0,Z.jsxs)(`linearGradient`,{id:`xopc-onboarding-human-glass`,x1:`340`,y1:`224`,x2:`700`,y2:`816`,gradientUnits:`userSpaceOnUse`,children:[(0,Z.jsx)(`stop`,{stopColor:`var(--xopc-loop-human-highlight)`}),(0,Z.jsx)(`stop`,{offset:`0.52`,stopColor:`var(--xopc-loop-human)`}),(0,Z.jsx)(`stop`,{offset:`1`,stopColor:`var(--xopc-loop-human-shadow)`})]})]}),(0,Z.jsx)(`circle`,{className:`xopc-loop-logo__ambient`,cx:`512`,cy:`512`,r:`330`}),(0,Z.jsx)(`circle`,{className:`xopc-loop-logo__origin`,cx:`512`,cy:`512`,r:`330`}),(0,Z.jsx)(`circle`,{className:`xopc-loop-logo__ai-glow`,cx:`512`,cy:`512`,r:`330`,strokeDasharray:`1419.162121 654.289030`,transform:`rotate(11.8 512 512)`}),(0,Z.jsx)(`circle`,{className:`xopc-loop-logo__ai`,cx:`512`,cy:`512`,r:`330`,stroke:`url(#xopc-onboarding-ai-glass)`,strokeDasharray:`1419.162121 654.289030`,transform:`rotate(11.8 512 512)`}),(0,Z.jsx)(`circle`,{className:`xopc-loop-logo__human`,cx:`512`,cy:`512`,r:`330`,stroke:`url(#xopc-onboarding-human-glass)`,strokeDasharray:`354.790530 1718.660621`,transform:`rotate(284.2 512 512)`}),(0,Z.jsx)(`circle`,{className:`xopc-loop-logo__liquid-front`,cx:`512`,cy:`512`,r:`330`,strokeDasharray:`58 2015.451151`,transform:`rotate(11.8 512 512)`})]}),t[3]=l):l=t[3];let u;return t[4]!==o||t[5]!==a||t[6]!==s?(u=(0,Z.jsx)(`span`,{className:s,role:`img`,"aria-hidden":o,"aria-label":a,children:l}),t[4]=o,t[5]=a,t[6]=s,t[7]=u):u=t[7],u}var ew=(0,Q.memo)(function(e){let t=(0,X.c)(19),{visible:n,onClick:r,edge:i,running:a}=e,o=i===void 0?`top`:i,s=a!==void 0&&a,c=h(tw),l;t[0]===c?l=t[1]:(l=y(c),t[0]=c,t[1]=l);let u=l,d=!n,f=o===`top`?`-top-2 -translate-y-full`:`bottom-2`,p=n?`opacity-100`:`opacity-0`,m;t[2]!==f||t[3]!==p?(m=Y(`pointer-events-none absolute inset-x-0 z-20 flex items-center justify-center transition-opacity duration-150 ease-out motion-reduce:transition-none`,f,p),t[2]=f,t[3]=p,t[4]=m):m=t[4];let g=n?`scale-100 opacity-100`:`pointer-events-none translate-y-1 scale-95 opacity-0`,_;t[5]===g?_=t[6]:(_=Y(`group relative pointer-events-auto flex size-11 sm:size-8 shrink-0 items-center justify-center rounded-full border border-edge-subtle bg-surface-overlay text-fg-muted shadow-surface`,`hover:border-edge-strong hover:text-fg`,ca.transition,ca.press,ca.focusRingPanel,g,`motion-reduce:translate-y-0 motion-reduce:scale-100`),t[5]=g,t[6]=_);let v=n?void 0:-1,b;t[7]===s?b=t[8]:(b=s?(0,Z.jsx)(`span`,{"data-scroll-to-bottom-running-logo":!0,className:`flex size-5 items-center justify-center`,"aria-hidden":!0,children:(0,Z.jsx)($C,{className:`xopc-loop-logo--stream size-5`})}):(0,Z.jsx)(as,{"data-scroll-to-bottom-arrow":!0,className:`size-4 transition-transform duration-150 ease-out group-hover:translate-y-0.5 motion-reduce:transition-none`,strokeWidth:1.8,"aria-hidden":!0}),t[7]=s,t[8]=b);let x;t[9]!==u.chat.scrollToBottom||t[10]!==r||t[11]!==v||t[12]!==b||t[13]!==_?(x=(0,Z.jsx)(`button`,{type:`button`,className:_,tabIndex:v,onClick:r,title:u.chat.scrollToBottom,"aria-label":u.chat.scrollToBottom,children:b}),t[9]=u.chat.scrollToBottom,t[10]=r,t[11]=v,t[12]=b,t[13]=_,t[14]=x):x=t[14];let S;return t[15]!==x||t[16]!==d||t[17]!==m?(S=(0,Z.jsx)(`div`,{"data-scroll-to-bottom-dock":!0,"aria-hidden":d,className:m,children:x}),t[15]=x,t[16]=d,t[17]=m,t[18]=S):S=t[18],S});function tw(e){return e.language}function nw(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 rw(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 iw(e){return e.webkitDirectionInvertedFromDevice===!0?e.deltaY>0:e.deltaY<0}function aw(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 ow(e){let t=(0,X.c)(48),{hasToken:n,showSessionLoading:r,conversationId:i,chatMessages:a,streaming:o,hasMore:s,loadingMore:c,loadMoreMessages:l}=e,u=(0,Q.useRef)(null),d=(0,Q.useRef)(null),f=(0,Q.useRef)(null),p=(0,Q.useRef)(!0),m=(0,Q.useRef)(null),h=(0,Q.useRef)(null),g=(0,Q.useRef)(null),_=(0,Q.useRef)(null),v=(0,Q.useRef)(0),y=(0,Q.useRef)(0),b=(0,Q.useRef)(null),x=(0,Q.useRef)(null),S=(0,Q.useRef)(null),C=(0,Q.useRef)(null),w=(0,Q.useRef)(0),T=(0,Q.useRef)(0),[E,D]=(0,Q.useState)(!0),O=(0,Q.useRef)(!0),k=(0,Q.useRef)(0),A=(0,Q.useRef)(o),j;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(j={first:void 0,len:0,scrollHeight:0},t[0]=j):j=t[0];let M=(0,Q.useRef)(j),N;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>{p.current=e,e&&(S.current=null)},t[1]=N):N=t[1];let P=N,F;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(F=e=>{let t=u.current;if(!t)return;let n=LC(t);P(n),D(n),_.current=n?e:null,n||(S.current=nw(t))},t[2]=F):F=t[2];let I=F,L;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(L=()=>{let e=u.current,t=m.current;if(!e||!t||!p.current||!_.current&&!h.current)return!1;let n=_.current??h.current;if(!n)return!1;let r=!_.current&&g.current?.isConnected?g.current:Array.from(e.querySelectorAll(`[data-chat-message-row]`)).find(e=>e.dataset.messageRenderKey===n||e.dataset.clientSubmissionId===n);if(!r)return!1;_.current&&(h.current=n,g.current=r,_.current=null,v.current=Math.min(64,Math.max(0,e.clientHeight)*.1),y.current=v.current);let i=parseFloat(getComputedStyle(t.parentElement).paddingTop)||0,a=Math.max(i,t.getBoundingClientRect().top-r.getBoundingClientRect().bottom),o=Math.max(y.current,a),s=Math.min(v.current,Math.min(64,Math.max(0,e.clientHeight)*.1)),c=Math.max(0,Math.min(s,o-a));return y.current=a+c,t.style.height===`${c}px`?!1:(t.style.height=`${c}px`,!0)},t[3]=L):L=t[3];let R=L,z;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>{let t=u.current;if(!t||!e?.force&&!p.current)return;e?.force&&P(!0);let n=UC(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:BC()});return}RC(t),w.current=t.scrollHeight,T.current=t.clientHeight,D(LC(t))},t[4]=z):z=t[4];let B=z,V;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(V=()=>{let e=u.current;!e||e.scrollHeight<=e.clientHeight||(P(!1),D(LC(e)))},t[5]=V):V=t[5];let H=V,U;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(U=()=>{let e=u.current;if(!e)return;!p.current&&!UC(e)&&rw(e,S.current);let t=R(),n=e.scrollHeight>w.current,r=e.clientHeight<T.current;w.current=e.scrollHeight,T.current=e.clientHeight,(n||r||t)&&B(),D(LC(e))},t[6]=U):U=t[6];let W=U,G;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(G=()=>{let e=u.current;e&&p.current&&(UC(e)?RC(e):e.scrollHeight>w.current&&B()),C.current===null&&(C.current=requestAnimationFrame(()=>{C.current=null,W()}))},t[7]=G):G=t[7];let ee=G,te;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(te=e=>{if(f.current===e||(x.current?.disconnect(),b.current?.disconnect(),b.current=null,x.current=null,f.current=e,!e))return;let t=new ResizeObserver(ee);t.observe(e),x.current=t;let n=new MutationObserver(e=>{let t=u.current;!t||!p.current||!UC(t)||(R()||e.some(sw))&&RC(t)});n.observe(e,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:[`style`]}),b.current=n},t[8]=te):te=t[8];let ne=te,re,ie;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(re=()=>()=>{x.current?.disconnect(),b.current?.disconnect(),C.current!==null&&(cancelAnimationFrame(C.current),C.current=null)},ie=[],t[9]=re,t[10]=ie):(re=t[9],ie=t[10]),(0,Q.useEffect)(re,ie);let ae;t[11]!==s||t[12]!==l||t[13]!==c?(ae=()=>{let e=u.current;if(!e)return;let t=LC(e),n=T.current>0&&(e.scrollHeight!==w.current||e.clientHeight!==T.current);if(!t&&p.current&&n){D(!1),ee();return}P(t),t||(S.current=nw(e)),D(t),t&&R(),e.scrollTop<100&&!t&&s&&!c&&l()},t[11]=s,t[12]=l,t[13]=c,t[14]=ae):ae=t[14];let oe=ae,se;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(se=e=>{B({force:!0,smooth:e===void 0||e})},t[15]=se):se=t[15];let ce=se,le,ue;t[16]!==n||t[17]!==r?(le=()=>{if(n){if(r){O.current=!0;return}O.current===!0&&(O.current=!1,P(!0),B({force:!0}))}},ue=[r,n,P,B],t[16]=n,t[17]=r,t[18]=le,t[19]=ue):(le=t[18],ue=t[19]),(0,Q.useLayoutEffect)(le,ue);let K;t[20]!==n||t[21]!==r?(K=()=>{!n||r||(M.current={first:void 0,len:0,scrollHeight:0},k.current=0,w.current=0,T.current=0,h.current=null,g.current=null,y.current=0,Array.from(u.current?.querySelectorAll(`[data-chat-message-row]`)??[]).some(e=>e.dataset.messageRenderKey===_.current||e.dataset.clientSubmissionId===_.current)||(_.current=null),m.current&&(m.current.style.height=`0px`),P(!0),B({force:!0}))},t[20]=n,t[21]=r,t[22]=K):K=t[22];let q;t[23]!==i||t[24]!==n||t[25]!==r?(q=[i,n,r,P,B],t[23]=i,t[24]=n,t[25]=r,t[26]=q):q=t[26],(0,Q.useLayoutEffect)(K,q);let de,fe;t[27]!==a||t[28]!==r||t[29]!==o?(de=()=>{if(r)return;let e=A.current&&!o;A.current=o;let t=R(),n=a.length,i=k.current;k.current=n;let s=(u.current?.scrollHeight??0)>w.current;p.current&&(n>i||s||t||e)&&B()},fe=[a,o,r,B,R],t[27]=a,t[28]=r,t[29]=o,t[30]=de,t[31]=fe):(de=t[30],fe=t[31]),(0,Q.useLayoutEffect)(de,fe);let pe,J;t[32]!==a||t[33]!==r?(pe=()=>{let e=u.current;if(!e||r)return;let t=M.current,n=a[0],i=a.length,o=e.scrollHeight,s=i-t.len;s>0&&t.len>0&&!aw(n,t.first)&&aw(a[s],t.first)&&!UC(e)&&t.scrollHeight>0&&!rw(e,S.current)&&(e.scrollTop+=o-t.scrollHeight),M.current={first:n,len:i,scrollHeight:o}},J=[a,r],t[32]=a,t[33]=r,t[34]=pe,t[35]=J):(pe=t[34],J=t[35]),(0,Q.useLayoutEffect)(pe,J);let me,he;t[36]!==n||t[37]!==r?(me=()=>{if(!n||r)return;let e=u.current;if(!e)return;let t=new ResizeObserver(ee);t.observe(e);let i=e=>{Math.abs(e.deltaY)<Math.abs(e.deltaX)||Math.abs(e.deltaY)<.25||iw(e)&&H()},a=0,o=e=>{e.touches.length===1&&(a=e.touches[0].clientY)},s=e=>{if(e.touches.length!==1)return;let t=e.touches[0].clientY,n=t-a;a=t,n>2&&H()},c=t=>{if(t.button!==0)return;let n=e.offsetWidth-e.clientWidth;if(n<=0)return;let r=e.getBoundingClientRect();t.clientX>=r.right-n&&H()},l=()=>{let t=window.getSelection();!t||t.isCollapsed||!e.contains(t.anchorNode)||(H(),S.current=nw(e))},d=t=>{(t.target instanceof Element?t.target:null)?.closest(`button[aria-expanded="false"]:not([aria-haspopup]), summary`)&&(H(),S.current=nw(e))};return e.addEventListener(`chat-scroll-reading`,H),e.addEventListener(`wheel`,i,{passive:!0}),e.addEventListener(`pointerdown`,c),e.addEventListener(`touchstart`,o,{passive:!0}),e.addEventListener(`touchmove`,s,{passive:!0}),e.addEventListener(`click`,d,!0),document.addEventListener(`selectionchange`,l),()=>{t.disconnect(),e.removeEventListener(`chat-scroll-reading`,H),e.removeEventListener(`wheel`,i),e.removeEventListener(`pointerdown`,c),e.removeEventListener(`touchstart`,o),e.removeEventListener(`touchmove`,s),e.removeEventListener(`click`,d,!0),document.removeEventListener(`selectionchange`,l)}},he=[n,r,H,ee],t[36]=n,t[37]=r,t[38]=me,t[39]=he):(me=t[38],he=t[39]),(0,Q.useLayoutEffect)(me,he);let ge;t[40]===n?ge=t[41]:(ge=()=>{if(!n)return;let e=u.current,t=d.current;if(!e||!t)return;let r=()=>{let n=`${t.getBoundingClientRect().height+16}px`;e.style.paddingBottom=n,e.style.scrollPaddingBottom=n,ee()};r();let i=new ResizeObserver(r);return i.observe(t),()=>{i.disconnect(),e.style.removeProperty(`padding-bottom`),e.style.removeProperty(`scroll-padding-bottom`)}},t[40]=n,t[41]=ge);let _e;t[42]!==n||t[43]!==r?(_e=[n,r,ee],t[42]=n,t[43]=r,t[44]=_e):_e=t[44],(0,Q.useLayoutEffect)(ge,_e);let ve;return t[45]!==E||t[46]!==oe?(ve={scrollRef:u,composerDockRef:d,atBottom:E,registerListContentRef:ne,scrollToBottom:ce,onScroll:oe,replySpaceRef:m,reserveReplySpace:I},t[45]=E,t[46]=oe,t[47]=ve):ve=t[47],ve}function sw(e){return e.target instanceof HTMLElement&&e.target.hasAttribute(`data-virtuoso-scroller`)}var cw=256*1024,lw=new TextEncoder;function uw(e){return lw.encode(e).byteLength}function dw(e){return uw(e)<=262144?e:new TextDecoder().decode(lw.encode(e).subarray(0,cw),{stream:!0})}function fw(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(`
60
- `);if((i.content.some(e=>e.type!==`text`)||i.attachments?.length)&&(n=!0),!e)continue;if(t<=256){n=!0;continue}let a=lw.encode(e),o=a.byteLength+256>t?new TextDecoder().decode(a.subarray(0,t-256),{stream:!0}):e;o!==e&&(n=!0);let s=uw(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 pw=`xopc:side-chat-panes:v3`,mw={text:``,attachments:[]};function hw(e){return Math.min(760,Math.max(360,Math.round(e)))}function gw(){return{panes:{},tabs:[],widthPx:520}}function _w(){try{let e=JSON.parse(sessionStorage.getItem(pw)||`{}`),t=e.identity;if(t&&t!==m.getState().conversationId)return gw();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:hw(typeof e.widthPx==`number`?e.widthPx:520)}}catch{return gw()}}function vw(e){try{sessionStorage.setItem(pw,JSON.stringify({...e,identity:m.getState().conversationId}))}catch{}}var yw=_w(),bw=_((e,t)=>{let n=n=>{e(n),queueMicrotask(()=>{let e=t();vw({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{...yw,drafts:{},readings:{},setDraftText:(n,r)=>e({drafts:{...t().drafts,[n]:{...t().drafts[n]??mw,text:r}}}),setDraftAttachments:(n,r)=>e({drafts:{...t().drafts,[n]:{...t().drafts[n]??mw,attachments:r}}}),rememberMessages:(n,r)=>{let i={...t().readings};delete i[n],i[n]=fw(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)=>{mi.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]??mw},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:()=>{mi.getState().reset(),e({drafts:{},readings:{},pendingCreate:null,creatingRequests:{}}),n({panes:{},tabs:[]})},pendingCreate:null,creatingRequests:{},requestCreate:(n,i=[])=>{mi.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)=>{mi.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;mi.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&&(mi.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(mi.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&&mi.getState().activate(`side:${o.id}`,e),o||i.requestCreate(e)},setWidthPx:e=>n({widthPx:hw(e)})}});m.subscribe((e,t)=>{if(e.conversationId&&!t.conversationId&&e.baseUrl===t.baseUrl){let e=_w();bw.setState(e)}if(e.baseUrl!==t.baseUrl||t.conversationId!==void 0&&e.conversationId!==t.conversationId){bw.getState().reset();try{sessionStorage.removeItem(`xopc:side-chat-client-id`)}catch{}}});function xw(e){return e.acceptsArgs?`/${e.name} `:`/${e.name}`}var Sw=3e4,Cw=null;function ww(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 Tw(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(Cw&&Cw.key===n&&e-Cw.at<Sw)return Cw.items.map(e=>({...e,...o.has(e.relativePath)?{isRecent:!0}:{isRecent:void 0}}))}let s={conversationId:n,agentId:r},c=ww(a.length===0?await Ha(``,s):await Ba(a,s,i),o);return n&&a.length===0&&(Cw={key:n,at:Date.now(),items:c}),c}async function Ew(e,t){return Ha(e,{conversationId:t.conversationId,agentId:t.agentId})}function Dw(e,...t){let n=e.trim().toLocaleLowerCase();return!n||t.some(e=>e?.toLocaleLowerCase().includes(n))}async function Ow(e){let t=await f(p(e)),n=await t.json().catch(()=>({}));if(!t.ok||!n.payload)throw Error(typeof n.error==`string`?n.error:`HTTP ${t.status}`);return n.payload}var kw=[{kind:`file`,search:(e,t)=>Tw(e,{conversationId:t.conversationId,agentId:t.currentAgentId,limit:10,recentPaths:t.recentPaths})},{kind:`note`,async search(e,t){return(await ze({...e.trim()?{search:e.trim()}:{},limit:5,sortBy:`updatedAt`,sortOrder:`desc`})).items.filter(e=>e.status!==`trashed`&&!t.selectedContextKeys.has(`note:${e.id}`)).map(e=>({id:`note:${e.id}`,kind:`note`,name:e.title?.trim()||e.snippet?.trim()||y(t.language).chat.commandPalette.untitledNote,description:e.snippet?.trim()||``,noteRef:{sourceId:e.id,expectedVersion:String(e.updatedAt)}}))}},{kind:`session`,async search(e,t){return(await dn({...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 ho(t.currentAgentId,t.conversationId)).skills.flatMap(n=>{if(!n.availableForCurrentAgent)return[];let r=xo(n,t.language);return Dw(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 ni(),r=y(t.language).agentsSettings;return n.items.flatMap(t=>{let n=qo(t,r),i=Jo(t,r);return Dw(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 Ow(`/api/browser/tabs?${new URLSearchParams({conversationId:t.conversationId})}`)).tabs.flatMap(n=>!Dw(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}}])}}],Aw=(0,Q.createContext)({target:null,register:()=>()=>{}});function jw(e){let t=(0,X.c)(9),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],t[0]=r):r=t[0];let[i,a]=(0,Q.useState)(r),o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=e=>(a(t=>[...t,e]),()=>a(t=>t.filter(t=>t!==e))),t[1]=o):o=t[1];let s=o,c;t[2]===i?c=t[3]:(c=i.at(-1)??null,t[2]=i,t[3]=c);let l;t[4]===c?l=t[5]:(l={target:c,register:s},t[4]=c,t[5]=l);let u=l,d;return t[6]!==n||t[7]!==u?(d=(0,Z.jsx)(Aw,{value:u,children:n}),t[6]=n,t[7]=u,t[8]=d):d=t[8],d}function Mw(){let e=(0,X.c)(2),{register:t}=(0,Q.useContext)(Aw),n;return e[0]===t?n=e[1]:(n=(0,Z.jsx)(`div`,{ref:t,className:`min-w-0 shrink-0`}),e[0]=t,e[1]=n),n}function Nw(){return(0,Q.useContext)(Aw).target}function Pw({conversationId:e,turnId:t,messages:n,ready:r,hasMore:i,loadingMore:a,loadMore:o,reveal:s,onLocated:c}){let l=(0,Q.useRef)({key:``,finished:!1,requestedLength:-1});(0,Q.useEffect)(()=>{let u=`${e??``}:${t??``}`;if(l.current.key!==u&&(l.current={key:u,finished:!1,requestedLength:-1}),!t||!r||l.current.finished)return;let d=l.current,f=n.findIndex(e=>e.turnId===t);if(f>=0){let e=0,t=!1,n=0,r=()=>{t||l.current===d&&(s(f)?(d.finished=!0,c?.(!0)):++n<3?e=requestAnimationFrame(r):(d.finished=!0,c?.(!1)))};return e=requestAnimationFrame(r),()=>{t=!0,cancelAnimationFrame(e)}}if(!a){if(!i||l.current.requestedLength===n.length){l.current.finished=!0,c?.(!1);return}l.current.requestedLength=n.length,o().catch(()=>{l.current===d&&(d.finished=!0,c?.(!1))})}},[e,t,n,r,i,a,o,s,c])}function Fw({interaction:e,path:t,complete:n}){let r=h(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 g(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,Z.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,Z.jsx)(`p`,{className:`font-medium text-fg`,children:r?`设备需要补充信息`:`Device needs input`}),(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-fg-muted`,children:e.message}),d.length?(0,Z.jsx)(`ul`,{className:`max-h-24 overflow-y-auto text-xs text-fg-muted`,children:d.map(([t,n])=>(0,Z.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,Z.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,Z.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:r?`输入不符合要求,或设备请求已结束。`:`The input is invalid or the device request has ended.`}):null,(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(pi,{type:`button`,variant:`secondary`,disabled:o,onClick:()=>void u(`decline`),children:r?`拒绝`:`Decline`}),(0,Z.jsx)(pi,{type:`submit`,disabled:o,children:r?`提交给设备`:`Send to device`})]})]})}function Iw(e){let t=(0,X.c)(8),{conversationId:n,active:r}=e,i;t[0]===n?i=t[1]:(i=n?p(`/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}=Gr(a,Lw,s),u=c?.payload?.[0],d;return t[4]!==u||t[5]!==l||t[6]!==a?(d=a&&u?(0,Z.jsx)(Fw,{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 Lw(e){return g(e)}function Rw(e){let t=(0,X.c)(24),{sk:n,onPick:r,disabled:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Rt,{className:`size-4`,"aria-hidden":!0}),t[0]=a):a=t[0];let o;t[1]===n.findCapability?o=t[2]:(o=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-sm text-accent-fg`,children:[a,n.findCapability]}),t[1]=n.findCapability,t[2]=o);let s;t[3]===n.findWelcome?s=t[4]:(s=(0,Z.jsx)(`h1`,{className:`text-xl font-semibold text-fg`,children:n.findWelcome}),t[3]=n.findWelcome,t[4]=s);let c;t[5]===n.findDescription?c=t[6]:(c=(0,Z.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:n.findDescription}),t[5]=n.findDescription,t[6]=c);let l;if(t[7]!==i||t[8]!==r||t[9]!==n.findExamples){let e;t[11]!==i||t[12]!==r?(e=e=>(0,Z.jsx)(pi,{disabled:i,onClick:()=>r(e),children:e},e),t[11]=i,t[12]=r,t[13]=e):e=t[13],l=n.findExamples.map(e),t[7]=i,t[8]=r,t[9]=n.findExamples,t[10]=l}else l=t[10];let d;t[14]===l?d=t[15]:(d=(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:l}),t[14]=l,t[15]=d);let f;t[16]===n.findBack?f=t[17]:(f=(0,Z.jsx)(u,{to:`/capabilities/skills`,className:`text-sm text-accent-fg hover:underline`,children:n.findBack}),t[16]=n.findBack,t[17]=f);let p;return t[18]!==o||t[19]!==s||t[20]!==c||t[21]!==d||t[22]!==f?(p=(0,Z.jsxs)(`section`,{className:`mx-auto flex max-w-xl flex-col items-start gap-4 py-8 sm:py-12`,children:[o,s,c,d,f]}),t[18]=o,t[19]=s,t[20]=c,t[21]=d,t[22]=f,t[23]=p):p=t[23],p}function zw(e){let t=`/api/sessions/${encodeURIComponent(e)}/connection-wait`,n=Nn(t=>t.sessions[e]?.localDraft),{data:r,mutate:i,isLoading:a}=Gr(n?null:[t,n===!1?`persisted`:`unknown`],async()=>await wr(e)?null:(await g(p(t))).payload,{refreshInterval:e=>e?.wait?5e3:0,revalidateOnFocus:!0}),o=(0,Q.useRef)(r);o.current=r;let s=(0,Q.useRef)(!1),c=(0,Q.useRef)(!1),l=(0,Q.useRef)(0),u=(0,Q.useRef)(null),[d,f]=(0,Q.useState)(!1),[m,_]=(0,Q.useState)(),[v,y]=(0,Q.useState)(),b=(0,Q.useCallback)(async(e,n,r,a,d)=>{let m=o.current,v=m?.wait;if(!v||(e===`cancel`?c.current:s.current||c.current))return!1;e===`cancel`?c.current=!0:s.current=!0,l.current+=1,f(!0),_(void 0),e===`cancel`&&y(void 0);let b=e===`connect`?Qo():null,x=JSON.stringify([v.id,v.objectiveRevision,e,n,r,a,d]);u.current?.signature!==x&&(u.current={signature:x,key:crypto.randomUUID()});let S=u.current.key,C=i=>g(p(`${t}/actions`),{method:`POST`,body:JSON.stringify({action:e,needKey:n,accountId:r,candidateRef:a,instanceId:d,waitId:v.id,expectedTranscriptId:i.transcriptId,expectedVersion:i.wait.version,...e===`cancel`?{expectedObjectiveRevision:v.objectiveRevision}:{},idempotencyKey:S})});try{let n;try{n=await C(m)}catch(r){if(e!==`cancel`||r.status!==409)throw r;let a=(await g(p(t))).payload;if(await i(e=>!e||e.transcriptId!==a.transcriptId||a.revision>=e.revision?a:e,!1),a.transcriptId!==m.transcriptId||a.wait?.id!==v.id||a.wait.objectiveRevision!==v.objectiveRevision)throw r;n=await C(a)}let r=n.payload.snapshot;if(await i(e=>!e||e.transcriptId!==r.transcriptId||r.revision>=e.revision?r:e,!1),n.payload.authorizationUrl){if(!await Zo(n.payload.authorizationUrl,b))throw Error(`Unable to open the authorization window. Allow pop-ups, then retry.`)}else $o(b);return u.current?.signature===x&&(u.current=null),!0}catch(t){if($o(b),t.status===409&&e===`cancel`){let e=h.getState().language===`zh`?`目标状态已变化,未能取消。请检查当前任务状态后再试。`:`The objective state changed and cancellation was not confirmed. Check its current status and try again.`;_(e),y(e)}else if(t.status!==409){let n=t instanceof Error?t.message:String(t);_(n),e===`cancel`&&y(n)}return await i(),!1}finally{e===`cancel`?c.current=!1:s.current=!1,--l.current,f(l.current>0)}},[t,i]);return(0,Q.useEffect)(()=>{let t=t=>{let n=t.detail;n?.conversationId===e&&(n.revision??1/0)>(o.current?.revision??0)&&i()};window.addEventListener(`session-connection-wait-changed`,t);let n=()=>{i()};return window.addEventListener(`gateway-realtime-connected`,n),()=>{window.removeEventListener(`session-connection-wait-changed`,t),window.removeEventListener(`gateway-realtime-connected`,n)}},[e,i]),{wait:r?.wait,isLoading:a,busy:d,error:m,cancellationError:v,act:b,dismissError:()=>{_(void 0),y(void 0)}}}function Bw(e){let t=(0,X.c)(39),{need:n,language:r,disabled:i,onSelect:a,onConnect:o}=e,s=(0,Q.useId)(),[c,l]=(0,Q.useState)(),u=r===`zh`,d;if(t[0]!==n.accounts||t[1]!==c){let e;t[3]===c?e=t[4]:(e=e=>e.id===c,t[3]=c,t[4]=e),d=n.accounts.some(e),t[0]=n.accounts,t[1]=c,t[2]=d}else d=t[2];let f=d,p=u?`这次使用哪个 ${n.label} 账号或工作区?`:`Which ${n.label} account or workspace should this request use?`,m;t[5]===p?m=t[6]:(m=(0,Z.jsx)(`legend`,{className:`float-left mb-3 w-full text-sm font-medium text-fg`,children:p}),t[5]=p,t[6]=m);let h;if(t[7]!==s||t[8]!==n.accounts||t[9]!==c){let e;t[11]!==s||t[12]!==c?(e=e=>(0,Z.jsxs)(`label`,{className:`flex min-h-11 cursor-pointer items-center gap-3 rounded-lg border px-3 py-2 text-sm text-fg hover:bg-surface-hover ${c===e.id?`border-accent bg-surface-hover`:`border-edge`}`,children:[(0,Z.jsx)(`input`,{type:`radio`,name:s,value:e.id,checked:c===e.id,onChange:()=>l(e.id),className:`shrink-0 accent-accent focus-visible:outline-2 focus-visible:outline-accent`}),(0,Z.jsx)(`span`,{className:`min-w-0 break-words`,children:e.label})]},e.id),t[11]=s,t[12]=c,t[13]=e):e=t[13],h=n.accounts.map(e),t[7]=s,t[8]=n.accounts,t[9]=c,t[10]=h}else h=t[10];let g;t[14]===h?g=t[15]:(g=(0,Z.jsx)(`div`,{className:`clear-both grid max-h-48 gap-2 overflow-y-auto sm:grid-cols-2`,children:h}),t[14]=h,t[15]=g);let _=u?`选择仅用于本次目标,选定后会自动继续。`:`This choice applies to this objective only. It will continue after selection.`,v;t[16]===_?v=t[17]:(v=(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:_}),t[16]=_,t[17]=v);let y=i||!f,b;t[18]!==a||t[19]!==c||t[20]!==f?(b=()=>{f&&c&&a(c)},t[18]=a,t[19]=c,t[20]=f,t[21]=b):b=t[21];let x=u?`使用所选账号并继续`:`Use selected account and continue`,S;t[22]!==x||t[23]!==y||t[24]!==b?(S=(0,Z.jsx)(`button`,{type:`button`,disabled:y,onClick:b,className:`min-h-11 rounded-lg bg-accent px-3 py-2 text-sm text-on-accent disabled:opacity-50`,children:x}),t[22]=x,t[23]=y,t[24]=b,t[25]=S):S=t[25];let C=u?`连接其他账号`:`Connect another account`,w;t[26]!==i||t[27]!==o||t[28]!==C?(w=(0,Z.jsx)(`button`,{type:`button`,disabled:i,onClick:o,className:`min-h-11 rounded-lg px-3 py-2 text-sm text-accent hover:bg-surface-hover disabled:opacity-50`,children:C}),t[26]=i,t[27]=o,t[28]=C,t[29]=w):w=t[29];let T;t[30]!==S||t[31]!==w?(T=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[S,w]}),t[30]=S,t[31]=w,t[32]=T):T=t[32];let E;return t[33]!==i||t[34]!==T||t[35]!==m||t[36]!==g||t[37]!==v?(E=(0,Z.jsxs)(`fieldset`,{disabled:i,className:`mt-3 min-w-0 space-y-3 border-t border-edge-subtle pt-3`,children:[m,g,v,T]}),t[33]=i,t[34]=T,t[35]=m,t[36]=g,t[37]=v,t[38]=E):E=t[38],E}var Vw=(0,Q.lazy)(()=>o(()=>import(`./mcp-conversation-setup-page-382BGqQC.js`).then(e=>({default:e.McpConversationSetupDialog})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29])));function Hw(e){let t=(0,X.c)(35),{conversationId:n}=e,r=h(Gw),[i,a]=l(),o;t[0]===i?o=t[1]:(o=i.get(`mcpSetup`),t[0]=i,t[1]=o);let s=o,c;t[2]!==i||t[3]!==a?(c=e=>{let t=new URLSearchParams(i);e?t.set(`mcpSetup`,e):t.delete(`mcpSetup`),a(t,{replace:!e})},t[2]=i,t[3]=a,t[4]=c):c=t[4];let d=c,f;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(f={refreshInterval:Uw,shouldRetryOnError:!1},t[5]=f):f=t[5];let{data:p,mutate:m}=Gr(`/api/mcp/setup/conversations/${encodeURIComponent(n)}`,Ww,f),g;t[6]!==n||t[7]!==p?.permitted||t[8]!==m?(g=()=>{if(p?.permitted===!1)return;let e=e=>{let t=e.detail;(t?.conversationId??t?.key)===n&&m()},t=()=>{m()};return window.addEventListener(`session-mcp-setup-changed`,e),window.addEventListener(`session-transcript-updated`,e),window.addEventListener(`gateway-realtime-connected`,t),()=>{window.removeEventListener(`session-mcp-setup-changed`,e),window.removeEventListener(`session-transcript-updated`,e),window.removeEventListener(`gateway-realtime-connected`,t)}},t[6]=n,t[7]=p?.permitted,t[8]=m,t[9]=g):g=t[9];let _=p?.permitted,v;t[10]!==n||t[11]!==m||t[12]!==_?(v=[n,m,_],t[10]=n,t[11]=m,t[12]=_,t[13]=v):v=t[13],(0,Q.useEffect)(g,v);let y;t[14]!==m||t[15]!==s||t[16]!==d?(y=s?(0,Z.jsx)(Q.Suspense,{fallback:null,children:(0,Z.jsx)(Vw,{setupId:s,onClose:()=>{d(null),m()}})}):null,t[14]=m,t[15]=s,t[16]=d,t[17]=y):y=t[17];let b=y;if(!p?.setup)return b;let x=p.setup,S=r===`zh`?`服务连接`:`Service connection`,C=x.expired?r===`zh`?`连接请求已过期`:`Connection request expired`:r===`zh`?`连接`:`Connect`,w=x.displayName||x.serverId,T;t[18]!==w||t[19]!==C?(T=(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 break-all text-sm text-fg`,role:`status`,children:[C,` `,w]}),t[18]=w,t[19]=C,t[20]=T):T=t[20];let E=`/mcp-setup/${encodeURIComponent(x.setupId)}`,D;t[21]!==d||t[22]!==x.setupId?(D=e=>{e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),d(x.setupId))},t[21]=d,t[22]=x.setupId,t[23]=D):D=t[23];let O=r===`zh`?`完成连接`:`Complete connection`,k;t[24]!==E||t[25]!==D||t[26]!==O?(k=(0,Z.jsx)(u,{className:`inline-flex min-h-11 items-center rounded-lg px-3 text-sm text-accent-fg hover:bg-surface-hover`,to:E,onClick:D,children:O}),t[24]=E,t[25]=D,t[26]=O,t[27]=k):k=t[27];let A;t[28]!==T||t[29]!==k||t[30]!==S?(A=(0,Z.jsxs)(`section`,{className:`mb-2 flex flex-wrap items-center gap-3 rounded-xl border border-edge bg-surface-panel px-3 py-2`,"aria-label":S,children:[T,k]}),t[28]=T,t[29]=k,t[30]=S,t[31]=A):A=t[31];let j;return t[32]!==b||t[33]!==A?(j=(0,Z.jsxs)(Z.Fragment,{children:[A,b]}),t[32]=b,t[33]=A,t[34]=j):j=t[34],j}function Uw(e){return e?.setup?5e3:0}async function Ww(e){try{return{permitted:!0,...(await g(p(e))).payload}}catch(e){let t=e;if([403,404].includes(t.status??0))return{permitted:!1,setup:null};throw t}}function Gw(e){return e.language}var Kw={zh:{waiting:`等待连接`,install:`安装`,installing:`正在准备安装`,connect:`连接`,reconnect:`重新连接`,details:`查看详情`,skip:`跳过连接`,cancel:`取消这个目标`,ready:`已连接`,check:`我已完成授权`,authorizing:`等待完成授权`,queued:`已连接,等待继续`,queuedSkipped:`等待使用现有信息继续`,checkingConnection:`正在检查连接`,checkingTools:`已连接,正在验证工具`,queueHint:`目标已保存,正在等待当前执行结束。`,interruptedInputHint:`有条补充消息在重启时中断。请重新发送要求,或移除上方中断的消息后继续。`,checkFailed:`连接检查暂时失败,目标已保存`,interrupted:`恢复检查曾中断,目标已保存`,lastChecked:`最近检查`,scope:`确认后继续`,scopeHint:`这个目标已等待了一段时间。请确认仍要按下方原始要求继续;如需修改时间范围,请先在聊天中说明。未读等条件将以实际执行时为准。`,account:`选择账号`,all:`查看全部连接`,close:`关闭`,intro:`完成连接后,将自动恢复当前目标。你也可以继续发送消息。`,callbackHint:`远程 Gateway 无法接收本地回调时,粘贴浏览器地址栏中的完整回调 URL。`,callbackPlaceholder:`完整回调 URL`,callbackSubmit:`完成连接`,replace:`更换应用`,confirmReplace:`确认改用`,apps:`个应用需要连接`,preserved:`目标已保留`,retry:`重试检查`,toolsUnavailable:`应用工具暂不可用`,toolsHint:`账号已连接,当前无法使用任务所需工具。可以重试检查,无需重新授权。`},en:{waiting:`Waiting for connection`,install:`Install`,installing:`Preparing installation`,connect:`Connect`,reconnect:`Reconnect`,details:`Details`,skip:`Skip connection`,cancel:`Cancel this objective`,ready:`Connected`,check:`Check authorization`,authorizing:`Waiting for authorization`,queued:`Connected, waiting to continue`,queuedSkipped:`Waiting to continue with available information`,checkingConnection:`Checking connection`,checkingTools:`Connected, checking tools`,queueHint:`Your objective is saved. Waiting for the current execution to finish.`,interruptedInputHint:`A message was interrupted during restart. Resend the requirement or remove the interrupted message above before continuing.`,checkFailed:`Connection check failed; objective saved`,interrupted:`Recovery check interrupted; objective saved`,lastChecked:`Last checked`,scope:`Confirm and continue`,scopeHint:`This objective has been waiting for a while. Confirm the original request below, or send a message to change the time range first. Conditions such as unread status are evaluated at execution time.`,account:`Choose an account`,all:`View all connections`,close:`Close`,intro:`The current objective resumes automatically after connecting. You can keep sending messages.`,callbackHint:`If a remote Gateway cannot receive the local callback, paste the complete callback URL from the browser address bar.`,callbackPlaceholder:`Complete callback URL`,callbackSubmit:`Complete connection`,replace:`Change app`,confirmReplace:`Confirm switch to`,apps:`apps need connecting`,preserved:`Objective preserved`,retry:`Retry check`,toolsUnavailable:`App tools unavailable`,toolsHint:`The account is connected, but the tools needed for this task are unavailable. Retry the check without reconnecting.`}},qw=`rounded-lg border border-edge px-3 py-1.5 text-sm text-fg hover:bg-surface-hover disabled:opacity-50`,Jw=`rounded-lg bg-accent px-3 py-1.5 text-sm text-on-accent disabled:opacity-50`;function Yw({conversationId:e}){let{wait:t,busy:n,error:r,cancellationError:i,act:a,dismissError:o}=zw(e),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(),[d,f]=(0,Q.useState)(),[p,m]=(0,Q.useState)(),[g,_]=(0,Q.useState)(!1),[v,x]=(0,Q.useState)(),O=h(e=>e.language),k=Kw[O];if(!t)return i?(0,Z.jsxs)(`div`,{role:`alert`,className:`mb-2 flex items-center gap-2 rounded-xl border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,children:[(0,Z.jsx)(`p`,{className:`min-w-0 flex-1`,children:i}),(0,Z.jsx)(`button`,{type:`button`,onClick:o,className:qw,children:k.close})]}):(0,Z.jsx)(Hw,{conversationId:e});let A=t.needs[0],j=t.needs.length===1,M=t.phase===`queued`,N=t.recoveryStage===`checking_connection`||t.recoveryStage===`checking_tools`,P=t.needs.find(e=>e.phase===`choose_account`),F=t.needs.some(e=>e.capabilityError);if(t.phase===`ready`&&!N&&!t.recoveryError)return(0,Z.jsx)(Hw,{conversationId:e});let I=t.recoveryStage===`checking_connection`?k.checkingConnection:t.recoveryStage===`checking_tools`?k.checkingTools:M?t.resolution===`skipped`?k.queuedSkipped:k.queued:t.recoveryError===`check_failed`?k.checkFailed:t.recoveryError?k.interrupted:F?k.toolsUnavailable:P?k.account:j&&A.phase===`authorizing`?k.authorizing:k.waiting,L=M||N?k.details:t.recoveryError?k.retry:t.phase===`review_scope`?k.scope:j&&A.phase===`install`?g?k.installing:`${k.install} ${A.label}`:j&&A.phase===`connect`?O===`zh`?`连接 ${A.label}`:`Connect ${A.label}`:j&&A.phase===`reconnect`?k.reconnect:j&&A.phase===`authorizing`?k.check:k.details;async function R(e=A){if(e.target.type===`store-connector`){_(!0),x(void 0);try{let t=await ga(e.target.packageName,e.target.version);if(t.reviewHash!==e.target.reviewHash||t.definition.id!==e.target.connectorId||t.definition.provenance?.sha256!==e.target.sha256)throw Error(O===`zh`?`Connector 包在审查后发生了变化,请重新发起推荐。`:`The Connector package changed after review. Request a new recommendation.`);f(Ct(t.definition,{packageName:t.packageName,version:t.version,reviewHash:t.reviewHash,permissions:t.permissions})),m(e.key)}catch(e){x(e instanceof Error?e.message:String(e))}finally{_(!1)}}}function z(){M||N?c(!0):t?.recoveryError?a(`check`):t?.phase===`review_scope`?c(!0):j&&A.phase===`install`?R():j&&[`connect`,`reconnect`].includes(A.phase)?a(`connect`,A.key):j&&A.phase===`authorizing`?a(`check`):c(!0)}return(0,Z.jsxs)(`section`,{className:`mb-2 rounded-xl border border-edge bg-surface-panel px-3 py-2`,"aria-label":I,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(Ge,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,Z.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left text-sm text-fg`,onClick:()=>c(!0),children:[(0,Z.jsx)(`span`,{role:`status`,children:j?`${I} · ${A.label}`:`${I} · ${t.needs.length} ${k.apps}`}),(0,Z.jsx)(te,{className:`ml-1 inline size-3`,"aria-hidden":!0})]}),(0,Z.jsxs)(`button`,{type:`button`,className:P||M||N?qw:Jw,disabled:n&&!N||g,onClick:z,children:[n&&(0,Z.jsx)(Je,{className:`mr-1 inline size-3 animate-spin`,"aria-hidden":!0}),L]}),!M&&!N&&(0,Z.jsx)(`button`,{type:`button`,className:`text-xs text-fg-muted hover:text-fg`,disabled:n,onClick:()=>void a(`skip`),children:k.skip}),(0,Z.jsx)(`button`,{type:`button`,className:`min-h-11 px-2 text-xs text-fg-muted hover:text-fg`,onClick:()=>void a(`cancel`),children:k.cancel})]}),t.queueBlocked&&(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.blockedInputId?k.interruptedInputHint:k.queueHint}),t.lastCheckedAt&&(0,Z.jsxs)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:[k.lastChecked,`: `,new Date(t.lastCheckedAt).toLocaleTimeString(O===`zh`?`zh-CN`:`en-US`)]}),P&&!M&&(0,Z.jsx)(`p`,{className:`mt-2 line-clamp-2 break-words text-sm text-fg-muted`,children:t.summary}),P&&!M&&(0,Z.jsx)(Bw,{need:P,language:O,disabled:n||N,onSelect:e=>void a(`select_account`,P.key,e),onConnect:()=>void a(`connect`,P.key)},`${t.id}:${t.objectiveRevision}:${P.key}`),(r||v)&&(0,Z.jsxs)(`p`,{role:`alert`,className:`mt-2 text-xs text-fg-muted`,children:[r??v,` `,(0,Z.jsx)(`button`,{type:`button`,className:`text-accent`,onClick:()=>void a(`check`),children:k.retry})]}),(0,Z.jsx)(D,{open:s,onOpenChange:c,children:(0,Z.jsxs)(w,{children:[(0,Z.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[2px]`}),(0,Z.jsxs)(T,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(90dvh,34rem)] w-[min(94vw,34rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-5 py-4`,children:[(0,Z.jsx)(E,{className:`font-medium text-fg`,children:k.preserved}),(0,Z.jsx)(C,{"aria-label":k.close,children:(0,Z.jsx)(Gt,{className:`size-4`})})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto p-5`,children:[(0,Z.jsx)(S,{className:`text-sm text-fg-muted`,children:F?k.toolsHint:t.phase===`review_scope`?k.scopeHint:k.intro}),(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap rounded-lg border border-edge p-3 text-sm text-fg`,children:t.summary}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:new Date(t.objectiveUpdatedAt).toLocaleString(O===`zh`?`zh-CN`:`en-US`)}),t.timeRange&&(0,Z.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[new Date(t.timeRange.from).toLocaleString(O,{timeZone:t.timeRange.timezone}),` – `,new Date(t.timeRange.to).toLocaleString(O,{timeZone:t.timeRange.timezone}),` (`,t.timeRange.timezone,`)`]}),t.needs.map(e=>(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-edge p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`span`,{className:`text-sm font-medium text-fg`,children:[e.label,e.accountSelector?` · ${e.accountSelector}`:``]}),e.capabilityError?(0,Z.jsx)(`button`,{type:`button`,disabled:n||M,className:qw,onClick:()=>void a(`check`),children:k.retry}):e.phase===`ready`?(0,Z.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[(0,Z.jsx)(G,{className:`mr-1 inline size-3`}),k.ready]}):e.phase===`authorizing`?(0,Z.jsx)(`button`,{type:`button`,disabled:n,className:qw,onClick:()=>void a(`check`),children:k.check}):e.phase===`install`?(0,Z.jsx)(`button`,{type:`button`,disabled:n||M||g,className:Jw,onClick:()=>void R(e),children:k.install}):e.phase!==`blocked`&&e.phase!==`choose_account`?(0,Z.jsx)(`button`,{type:`button`,disabled:n||M,className:Jw,onClick:()=>void a(`connect`,e.key),children:e.phase===`reconnect`?k.reconnect:k.connect}):null]}),e.accountId&&(0,Z.jsx)(`p`,{className:`break-words text-xs text-fg-muted`,children:e.accounts.find(t=>t.id===e.accountId)?.label??e.accountId}),e.alternatives?.length?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(ue,{value:l?.needKey===e.key?l.candidateRef:``,options:e.alternatives.map(e=>({value:e.candidateRef,label:e.label})),placeholder:k.replace,ariaLabel:`${e.label}: ${k.replace}`,disabled:n||M,allowEmpty:!1,onChange:t=>u({needKey:e.key,candidateRef:t,label:e.alternatives.find(e=>e.candidateRef===t).label})}),l?.needKey===e.key&&(0,Z.jsxs)(`button`,{type:`button`,className:qw,disabled:n,onClick:()=>{a(`replace_source`,e.key,void 0,l.candidateRef),u(void 0)},children:[k.confirmReplace,` `,l.label]})]}):null,e.reason&&(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.reason}),e.phase===`authorizing`&&(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:k.authorizing}),(0,Z.jsx)(`button`,{type:`button`,disabled:n,className:`text-accent`,onClick:()=>void a(`connect`,e.key),children:k.reconnect})]})]},e.key)),(0,Z.jsx)(`a`,{href:`#/capabilities/connectors`,className:`text-sm text-accent`,onClick:()=>c(!1),children:k.all})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-t border-edge p-4`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`min-h-11 text-sm text-fg-muted`,onClick:()=>void a(`cancel`),children:k.cancel}),t.phase===`review_scope`?(0,Z.jsx)(`button`,{type:`button`,disabled:n||M,className:Jw,onClick:()=>void a(`confirm_scope`),children:k.scope}):null]})]})]})}),d?(0,Z.jsx)(wt,{draft:d,onChange:f,onClose:()=>{f(void 0),m(void 0)},onInstalled:async e=>{p&&await a(`install_complete`,p,void 0,void 0,e.instanceId)&&(f(void 0),m(void 0))},t:y(O).connectorsSettings}):null]})}var Xw=new Set([`button`,`checkbox`,`color`,`file`,`hidden`,`image`,`radio`,`range`,`reset`,`submit`]);function Zw(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&&!Xw.has(t.type)}function Qw(){return!!document.querySelector(`dialog[open], [aria-modal="true"], [role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]`)}function $w(e,t){return t.disabled||t.editorHidden||e.defaultPrevented||Zw(e.target)||Zw(document.activeElement)?!1:!Qw()}function eT(e){for(let t=e.parentElement;t;t=t.parentElement)if(/(auto|scroll)/.test(getComputedStyle(t).overflowY))return t;return null}function tT({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=eT(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 nT(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 rT(e){let t=nT(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 iT=(0,Q.memo)(function({items:e,disabled:t,editingFollowUpId:n,onEditInComposer:r,onRemove:i,onMove:a,onReorder:o,onSteer:s,onSendSingle:c,queuePaused:l=!1,queueIdle:u=!1,steeringBusyId:d,onOpenSideChat:f}){let p=y(h(e=>e.language)),m=(0,Q.useRef)(!1),g=e.filter(e=>e.status===`queued`),_=!!(t||d),v=tT({items:e,disabled:_,onReorder:o}),b=Y(`inline-flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-lg px-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:pointer-events-none disabled:opacity-35`,ca.focusRingPanel),x=`flex cursor-pointer items-center gap-2 rounded-md px-3 py-2 text-sm text-fg outline-none focus:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-35`;return e.length===0?null:(0,Z.jsxs)(`div`,{ref:v.listRef,className:`space-y-1 px-2 py-2`,onClickCapture:v.onClickCapture,role:`list`,"aria-label":p.chat.followUpQueueAria,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2 pb-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:p.chat.followUpQueueHeading}),(0,Z.jsxs)(`span`,{className:`tabular-nums text-[0.65rem] text-fg-muted`,children:[e.length,`/`,10]})]}),e.map(e=>{let t=e.status===`queued`,o=t||e.status===`interrupted`,h=g.findIndex(t=>t.id===e.id),y=u&&(l||e.status===`interrupted`),S=o&&!!(e.text.trim()||e.attachments?.length||e.contextRefs?.length),C=o&&!e.attachments?.length&&!e.contextRefs?.length&&e.text.trim().length>0,w=d===e.id,T=e.status===`interrupted`?p.chat.followUpStatusInterrupted:null,E=Wn(e.text),D=new Map(e.contextRefs?.flatMap(e=>e.refId?[[e.refId,e.title]]:[])??[]),O=new Set(E?gn(E):[]),k=e.contextRefs?.filter(e=>!e.refId||!O.has(e.refId)),A=Jn(E?br(E,e=>D.get(e)):e.text).trim();return!A&&e.attachments?.length&&(A=e.attachments[0]?.name?.trim()||p.chat.followUpQueueAttachmentOnly),A||=p.chat.followUpQueueEmptyPreview,(0,Z.jsxs)(`div`,{role:`listitem`,"data-follow-up-id":e.id,"data-follow-up-sortable":!_&&t,onPointerDown:t=>v.onPointerDown(t,e),onDragStart:e=>e.preventDefault(),style:{transform:v.view?.shifts[e.id]?`translateY(${v.view.shifts[e.id]}px)`:void 0},className:Y(`relative flex min-h-10 items-center gap-1 rounded-lg px-1.5 py-1 motion-safe:transition-transform motion-safe:duration-150`,!_&&t&&`cursor-grab`,v.view?.id===e.id&&`bg-surface-inset ring-1 ring-inset ring-edge-strong [&>*]:invisible`,n===e.id?`bg-accent-soft ring-1 ring-inset ring-accent/30`:`hover:bg-surface-hover/50`),children:[(0,Z.jsx)(`div`,{"data-follow-up-drag-handle":!0,className:Y(`flex shrink-0 touch-none cursor-grab items-center active:cursor-grabbing`,(_||!t)&&`cursor-not-allowed opacity-40`),title:p.chat.followUpQueueDrag,children:(0,Z.jsx)(hs,{className:`size-3.5 text-fg-muted`,"aria-hidden":!0})}),(0,Z.jsx)(`button`,{type:`button`,"data-follow-up-drag-surface":!0,disabled:_||!t,title:p.chat.followUpQueueClickToEdit,"aria-label":p.chat.followUpQueueClickToEdit,className:Y(`min-h-8 min-w-0 flex-1 cursor-grab rounded-md px-1.5 text-left text-sm text-fg`,ca.focusRingPanel,`disabled:pointer-events-none disabled:opacity-50`),onClick:()=>r(e.id),children:e.attachments?.length?(0,Z.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1`,children:[(0,Z.jsx)(Ce,{className:`size-3 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate`,children:A})]}):(0,Z.jsx)(`span`,{className:`line-clamp-2 break-words [overflow-wrap:anywhere]`,children:A})}),k?.length?(0,Z.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-0.5 rounded bg-accent-soft px-1.5 py-0.5 text-[0.625rem] text-accent-fg`,title:k.map(e=>e.title).join(`, `),children:[(0,Z.jsx)(xs,{className:`size-3`,"aria-hidden":!0}),k.length]}):null,T?(0,Z.jsx)(`span`,{className:`shrink-0 rounded bg-surface-panel px-1.5 py-0.5 text-[0.625rem] text-fg-muted`,children:T}):null,(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:b,disabled:_||(y?!o:!S),title:y?p.chat.sendThisMessage:p.chat.followUpQueueSteerHint,"aria-label":y?p.chat.sendThisMessage:p.chat.followUpQueueSteerNow,"aria-busy":w,onClick:()=>y?c?.(e.id):s(e.id),children:[(0,Z.jsx)(cs,{className:Y(`size-4`,w&&`motion-safe:animate-pulse`),"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`hidden text-xs sm:inline`,children:y?p.chat.sendThisMessage:p.chat.followUpQueueSteerNow})]}),(0,Z.jsx)(`button`,{type:`button`,className:Y(b,`px-1.5 hover:text-danger`),disabled:_||!o,title:p.chat.followUpQueueRemove,"aria-label":p.chat.followUpQueueRemove,onClick:()=>i(e.id),children:(0,Z.jsx)(Bt,{className:`size-4`,"aria-hidden":!0})}),(0,Z.jsxs)(co,{modal:!1,children:[(0,Z.jsx)(lo,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:Y(b,`px-1.5`),disabled:_,title:p.chat.followUpQueueMore,"aria-label":p.chat.followUpQueueMore,children:(0,Z.jsx)(be,{className:`size-4`,"aria-hidden":!0})})}),(0,Z.jsx)(uo,{children:(0,Z.jsxs)(po,{side:`top`,align:`end`,sideOffset:6,onCloseAutoFocus:e=>{m.current&&e.preventDefault(),m.current=!1},className:`z-50 min-w-52 max-w-[calc(100vw-2rem)] rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:[(0,Z.jsxs)(fo,{className:x,disabled:!t,onSelect:()=>{m.current=!0,r(e.id)},children:[(0,Z.jsx)(Dt,{className:`size-4`,"aria-hidden":!0}),p.chat.followUpQueueClickToEdit]}),f?(0,Z.jsxs)(fo,{className:x,disabled:!C,onSelect:()=>f(e,A),children:[(0,Z.jsx)(vs,{className:`size-4`,"aria-hidden":!0}),p.chat.followUpQueueOpenSideChat]}):null,g.length>1?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(mo,{className:`my-1 h-px bg-edge-subtle`}),(0,Z.jsxs)(fo,{className:x,disabled:!t||h===0,onSelect:()=>a(e.id,`up`),children:[(0,Z.jsx)(ne,{className:`size-4`,"aria-hidden":!0}),p.chat.followUpQueueMoveUp]}),(0,Z.jsxs)(fo,{className:x,disabled:!t||h>=g.length-1,onSelect:()=>a(e.id,`down`),children:[(0,Z.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),p.chat.followUpQueueMoveDown]})]}):null]})})]})]})]},e.id)})]})});function aT({conversationId:e}){let t=m(e=>e.conversationId),n=h(e=>e.language).startsWith(`zh`),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(``),s=Gr(e?[`session-preparation`,t,e]:null,async()=>{let t=await wr(e);if(t&&!t.materialization)return null;let n=await g(p(`/api/sessions/${encodeURIComponent(e)}/input-state`));return n.payload.preparation?Er.parse(n.payload.preparation):null},{refreshInterval:e=>e?.state===`preparing`?5e3:0,shouldRetryOnError:!1}),{mutate:c}=s;(0,Q.useEffect)(()=>{let t=t=>{t.detail?.conversationId===e&&c()};return window.addEventListener(`session-input-state`,t),()=>window.removeEventListener(`session-input-state`,t)},[e,c]);let l=s.data;if(!l||l.state===`ready`)return null;let u=async()=>{i(!0),o(``);try{let t=await f(p(`/api/sessions/${encodeURIComponent(e)}/preparation/retry`),{method:`POST`,body:JSON.stringify({operationId:l.operationId,expectedRevision:l.revision,idempotencyKey:`${l.operationId}:${l.revision}`})});if(!t.ok)throw Error(`HTTP ${t.status}`);await c()}catch(e){o(e instanceof Error?e.message:String(e))}finally{i(!1)}};return(0,Z.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 text-sm text-fg-muted`,role:`status`,children:[(0,Z.jsx)(`span`,{children:l.state===`preparing`?n?`正在准备会话环境…`:`Preparing conversation environment…`:l.lastError??(n?`会话环境准备失败`:`Conversation environment preparation failed`)}),l.state===`preparation_failed`?(0,Z.jsx)(`button`,{type:`button`,className:`ml-2 text-accent-fg`,disabled:r,onClick:()=>void u(),children:n?`重试准备`:`Retry preparation`}):null,a?(0,Z.jsx)(`span`,{role:`alert`,className:`ml-2`,children:a}):null]})}function oT(e){let t=(0,X.c)(10),{refs:n,label:r,onRemove:i}=e;if(n.length===0)return null;let a;if(t[0]!==r||t[1]!==i||t[2]!==n){let e;t[4]!==r||t[5]!==i?(e=e=>(0,Z.jsxs)(`span`,{className:`inline-flex h-7 min-w-0 max-w-56 items-center gap-1.5 rounded-md border border-edge-subtle bg-accent-soft/50 px-2 text-xs text-fg`,children:[e.kind===`file`&&e.fileKind===`directory`?(0,Z.jsx)(Oe,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.kind===`file`||e.kind===`result`?(0,Z.jsx)(Te,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.kind===`session`?(0,Z.jsx)(bt,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.kind===`browser_tab`?(0,Z.jsx)(k,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,Z.jsx)(xs,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.title}),(0,Z.jsx)(`button`,{type:`button`,className:`-mr-1 inline-flex size-5 shrink-0 items-center justify-center rounded text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":`${r}: ${e.title}`,onClick:()=>i(e.sourceId),children:(0,Z.jsx)(Gt,{className:`size-3`,"aria-hidden":!0})})]},e.sourceId),t[4]=r,t[5]=i,t[6]=e):e=t[6],a=n.map(e),t[0]=r,t[1]=i,t[2]=n,t[3]=a}else a=t[3];let o;return t[7]!==r||t[8]!==a?(o=(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5 px-4 pt-2`,"aria-label":r,children:a}),t[7]=r,t[8]=a,t[9]=o):o=t[9],o}var sT=`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 cT(e){let t=(0,X.c)(96),{conversationId:n,project:r,workspacePath:i,canChangeWorkspace:a,disabled:o,environmentPicker:s,onProjectChange:c,onWorkspaceChange:l}=e,u=h(fT),d;t[0]===u?d=t[1]:(d=y(u),t[0]=u,t[1]=d);let f=d,p=f.chat.composerContext,g=m(dT),_=m(uT),[v,b]=(0,Q.useState)(``),[x]=Wa(v,200),S;t[2]!==_||t[3]!==x||t[4]!==g?(S=[`composer-projects`,_,g,x],t[2]=_,t[3]=x,t[4]=g,t[5]=S):S=t[5];let C;t[6]===x?C=t[7]:(C=()=>ln({status:`active`,search:x,sortBy:`updatedAt`,sortOrder:`desc`,limit:50}),t[6]=x,t[7]=C);let w;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(w={keepPreviousData:!1,shouldRetryOnError:!1},t[8]=w):w=t[8];let T=Gr(S,C,w),E=mf(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=Ia(N),F=a?`${p.chooseFolder}${k?`: ${k}`:``}`:r?p.projectFolder:p.lockedFolder,I;t[18]===D?I=t[19]:(I=D?.branch||(D?.detached?D.headSha?.slice(0,8):void 0),t[18]=D,t[19]=I);let L=I,R=p.label,z=r&&`bg-surface-hover`,B;t[20]===z?B=t[21]:(B=Y(`flex min-w-0 max-w-full items-center rounded-full`,z),t[20]=z,t[21]=B);let V;t[22]!==o||t[23]!==f.chat.scopeRemoveProject||t[24]!==c||t[25]!==r?(V=r?(0,Z.jsx)(`button`,{type:`button`,disabled:o,title:f.chat.scopeRemoveProject,"aria-label":f.chat.scopeRemoveProject,className:Y(sT,`size-7 shrink-0 px-0 ml-0.5 text-fg-muted`),onClick:()=>c(null),children:(0,Z.jsx)(Gt,{className:`size-3.5`,"aria-hidden":!0})}):null,t[22]=o,t[23]=f.chat.scopeRemoveProject,t[24]=c,t[25]=r,t[26]=V):V=t[26];let H=r?.id??``,U=r?.name,W;t[27]!==T.data?.items||t[28]!==T.error?(W=T.error?[]:T.data?.items??[],t[27]=T.data?.items,t[28]=T.error,t[29]=W):W=t[29];let G;t[30]===W?G=t[31]:(G=W.map(lT),t[30]=W,t[31]=G);let ee=p.chooseProject,te=p.changeProject,ne=p.changeProject,re=p.noProject,ae=p.searchProjects,oe=T.isLoading,se=T.error?p.projectsFailed:T.data?.items.length===0?p.noProjects:void 0,ce=r&&`pl-1`,le;t[32]===ce?le=t[33]:(le=Y(sT,`h-8 w-auto max-w-44 gap-1 border-0 bg-transparent pr-2.5 text-sm [&>svg]:hidden [&>span]:text-fg`,ce),t[32]=ce,t[33]=le);let K;t[34]!==c||t[35]!==r?.id?(K=e=>{e!==(r?.id??``)&&c(e||null)},t[34]=c,t[35]=r?.id,t[36]=K):K=t[36];let q;t[37]!==p.changeProject||t[38]!==p.chooseProject||t[39]!==p.noProject||t[40]!==p.searchProjects||t[41]!==o||t[42]!==T.isLoading||t[43]!==v||t[44]!==H||t[45]!==U||t[46]!==G||t[47]!==se||t[48]!==le||t[49]!==K?(q=(0,Z.jsx)(ue,{value:H,selectedLabel:U,options:G,placeholder:ee,ariaLabel:te,title:ne,emptyLabel:re,disabled:o,side:`top`,align:`start`,searchPlaceholder:ae,searchValue:v,onSearchChange:b,loading:oe,statusMessage:se,triggerClassName:le,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:K}),t[37]=p.changeProject,t[38]=p.chooseProject,t[39]=p.noProject,t[40]=p.searchProjects,t[41]=o,t[42]=T.isLoading,t[43]=v,t[44]=H,t[45]=U,t[46]=G,t[47]=se,t[48]=le,t[49]=K,t[50]=q):q=t[50];let de;t[51]!==B||t[52]!==V||t[53]!==q?(de=(0,Z.jsxs)(`div`,{className:B,children:[V,q]}),t[51]=B,t[52]=V,t[53]=q,t[54]=de):de=t[54];let fe=r?s:null,pe;t[55]!==D||t[56]!==s||t[57]!==r?(pe=!s&&r&&D&&(D.headSha||D.branch)?(0,Z.jsxs)(`span`,{className:`inline-flex h-8 min-w-0 items-center gap-1.5 rounded-full bg-surface-hover px-2.5 text-sm text-fg`,title:D.rootPath,children:[D.kind===`managed_worktree`?(0,Z.jsx)(Ss,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(We,{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]=pe):pe=t[58];let J;t[59]!==p.retryProjects||t[60]!==T?(J=T.error?(0,Z.jsx)(`button`,{type:`button`,className:Y(sT,`size-7 px-0`),"aria-label":p.retryProjects,onClick:()=>void T.mutate(),children:(0,Z.jsx)(At,{className:`size-3.5`,"aria-hidden":!0})}):null,t[59]=p.retryProjects,t[60]=T,t[61]=J):J=t[61];let me;t[62]!==a||t[63]!==E.isLoading||t[64]!==p.chooseFolder||t[65]!==o||t[66]!==P.pick||t[67]!==P.picking||t[68]!==r||t[69]!==k||t[70]!==F?(me=r?null:(0,Z.jsxs)(`button`,{type:`button`,className:Y(sT,`max-w-52`),disabled:o||!a||P.picking,title:F,"aria-label":p.chooseFolder,onClick:P.pick,children:[(0,Z.jsx)(De,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),k?(0,Z.jsx)(`span`,{className:`truncate`,children:Fa(k)}):E.isLoading?(0,Z.jsx)(qt,{className:`h-4 w-16`}):(0,Z.jsx)(`span`,{children:p.chooseFolder})]}),t[62]=a,t[63]=E.isLoading,t[64]=p.chooseFolder,t[65]=o,t[66]=P.pick,t[67]=P.picking,t[68]=r,t[69]=k,t[70]=F,t[71]=me):me=t[71];let he;t[72]!==L||t[73]!==D?(he=L?(0,Z.jsxs)(`span`,{className:`inline-flex h-8 min-w-0 max-w-44 items-center gap-1.5 px-2 text-sm text-fg`,title:`${L}${D?.headSha?` · ${D.headSha.slice(0,8)}`:``}`,children:[(0,Z.jsx)(Me,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate`,children:L})]}):null,t[72]=L,t[73]=D,t[74]=he):he=t[74];let ge;t[75]===A?ge=t[76]:(ge=A?(0,Z.jsx)(`p`,{role:`alert`,className:`w-full px-2 py-1 text-xs text-danger`,children:A}):null,t[75]=A,t[76]=ge);let _e;t[77]!==p.label||t[78]!==de||t[79]!==fe||t[80]!==pe||t[81]!==J||t[82]!==me||t[83]!==he||t[84]!==ge?(_e=(0,Z.jsxs)(`div`,{className:`mx-3 -mb-3 flex min-w-0 shrink-0 flex-wrap items-center gap-x-1 gap-y-1 rounded-t-2xl bg-surface-base px-2 pb-4 pt-1.5 sm:mx-4`,"aria-label":R,children:[de,fe,pe,J,me,he,ge]}),t[77]=p.label,t[78]=de,t[79]=fe,t[80]=pe,t[81]=J,t[82]=me,t[83]=he,t[84]=ge,t[85]=_e):_e=t[85];let ve;t[86]!==f.chat.workingDirectory||t[87]!==P.confirmPick||t[88]!==P.hasNativePicker||t[89]!==P.modalOpen||t[90]!==P.setModalOpen||t[91]!==k?(ve=P.hasNativePicker?null:(0,Z.jsx)(ie,{open:P.modalOpen,onOpenChange:P.setModalOpen,initialAbsolutePath:k||void 0,onConfirm:P.confirmPick,wd:f.chat.workingDirectory}),t[86]=f.chat.workingDirectory,t[87]=P.confirmPick,t[88]=P.hasNativePicker,t[89]=P.modalOpen,t[90]=P.setModalOpen,t[91]=k,t[92]=ve):ve=t[92];let ye;return t[93]!==_e||t[94]!==ve?(ye=(0,Z.jsxs)(Z.Fragment,{children:[_e,ve]}),t[93]=_e,t[94]=ve,t[95]=ye):ye=t[95],ye}function lT(e){return{value:e.id,label:e.name}}function uT(e){return e.baseUrl}function dT(e){return e.conversationId}function fT(e){return e.language}var pT=`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 mT(e){let t=(0,X.c)(10),{disabled:n,attachmentCount:r,maxAttachments:i,chat:a,onPickFiles:o}=e,s=r>=i,c;t[0]!==a.attachFile||t[1]!==a.maxAttachmentsReached||t[2]!==s||t[3]!==i?(c=s?em(a.maxAttachmentsReached,{max:i}):a.attachFile,t[0]=a.attachFile,t[1]=a.maxAttachmentsReached,t[2]=s,t[3]=i,t[4]=c):c=t[4];let l=c,u=n||s,d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(kt,{className:`size-5`,"aria-hidden":!0}),t[5]=d):d=t[5];let f;return t[6]!==l||t[7]!==o||t[8]!==u?(f=(0,Z.jsx)(`button`,{type:`button`,className:pT,disabled:u,"aria-label":l,title:l,onClick:o,children:d}),t[6]=l,t[7]=o,t[8]=u,t[9]=f):f=t[9],f}function hT(e){let t=(0,X.c)(38),{disabled:n,voiceActive:r,runBusy:i,hasDraft:a,chat:o,onStartVoiceInput:s,onSend:c,onQueue:l,onDefer:u,onAbort:d,onInterrupt:f,onSteer:p,steerDisabled:m}=e,h=m!==void 0&&m;if(r)return null;let g=i&&a&&!!l,_=i&&!a,v=_?o.abort:g?o.steeringInterruptSend:o.sendMessage,y;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(xt,{className:`size-[1.125rem]`,"aria-hidden":!0}),t[0]=y):y=t[0];let b;t[1]!==o.voiceInput||t[2]!==n||t[3]!==s?(b=(0,Z.jsx)(`button`,{type:`button`,className:pT,disabled:n,title:o.voiceInput,"aria-label":o.voiceInput,onClick:s,children:y}),t[1]=o.voiceInput,t[2]=n,t[3]=s,t[4]=b):b=t[4];let x;t[5]!==o.abort||t[6]!==o.followUpQueueAdd||t[7]!==o.followUpQueueMore||t[8]!==o.steerCurrentReply||t[9]!==o.steerCurrentReplyHint||t[10]!==o.steeringInterruptSend||t[11]!==n||t[12]!==a||t[13]!==d||t[14]!==u||t[15]!==f||t[16]!==p||t[17]!==i||t[18]!==h?(x=i&&(0,Z.jsxs)(co,{modal:!1,children:[(0,Z.jsx)(lo,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:pT,disabled:n,"aria-label":o.followUpQueueMore,title:o.followUpQueueMore,children:(0,Z.jsx)(be,{className:`size-5`,"aria-hidden":!0})})}),(0,Z.jsx)(uo,{children:(0,Z.jsxs)(po,{side:`top`,align:`end`,sideOffset:8,className:`z-50 min-w-44 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:[p&&(0,Z.jsx)(fo,{disabled:n||h,onSelect:p,title:o.steerCurrentReplyHint,className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none focus:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,children:o.steerCurrentReply}),u&&(0,Z.jsx)(fo,{disabled:!a,onSelect:()=>void u(),className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none focus:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,children:o.followUpQueueAdd}),f&&(0,Z.jsx)(fo,{disabled:!a,onSelect:f,className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none focus:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,children:o.steeringInterruptSend}),(0,Z.jsx)(fo,{onSelect:d,className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none focus:bg-surface-hover`,children:o.abort})]})})]}),t[5]=o.abort,t[6]=o.followUpQueueAdd,t[7]=o.followUpQueueMore,t[8]=o.steerCurrentReply,t[9]=o.steerCurrentReplyHint,t[10]=o.steeringInterruptSend,t[11]=n,t[12]=a,t[13]=d,t[14]=u,t[15]=f,t[16]=p,t[17]=i,t[18]=h,t[19]=x):x=t[19];let S;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(S=Y(pT,`bg-accent text-on-accent hover:bg-accent-hover hover:text-on-accent disabled:bg-surface-hover disabled:text-fg-disabled`),t[20]=S):S=t[20];let C=!_&&(n||!a||i&&!l),w;t[21]!==g||t[22]!==d||t[23]!==l||t[24]!==c||t[25]!==_?(w=_?d:g?()=>void l?.():c,t[21]=g,t[22]=d,t[23]=l,t[24]=c,t[25]=_,t[26]=w):w=t[26];let T;t[27]===_?T=t[28]:(T=_?(0,Z.jsx)(zt,{className:`size-4 fill-current`,"aria-hidden":!0}):(0,Z.jsx)(N,{className:`size-5`,"aria-hidden":!0}),t[27]=_,t[28]=T);let E;t[29]!==v||t[30]!==C||t[31]!==w||t[32]!==T?(E=(0,Z.jsx)(`button`,{type:`button`,className:S,disabled:C,"aria-label":v,title:v,onClick:w,children:T}),t[29]=v,t[30]=C,t[31]=w,t[32]=T,t[33]=E):E=t[33];let D;return t[34]!==b||t[35]!==x||t[36]!==E?(D=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[b,x,E]}),t[34]=b,t[35]=x,t[36]=E,t[37]=D):D=t[37],D}function gT(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 _T=100,vT=400,yT=900;function bT(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 xT(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 ST(e){let t=(0,X.c)(8),{name:n,query:r}=e,i;t[0]!==n||t[1]!==r?(i=xT(n,r),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a=i;if(a.length===0){let e;return t[3]===n?e=t[4]:(e=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:n}),t[3]=n,t[4]=e),e}let o;if(t[5]!==n||t[6]!==a){let e=[],r=0;a.forEach(t=>{let[i,a]=t;i>r&&e.push((0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:n.slice(r,i)},`pre-${i}`)),e.push((0,Z.jsx)(`span`,{className:`font-semibold text-accent-fg`,children:n.slice(i,a)},`hl-${i}-${a}`)),r=a}),r<n.length&&e.push((0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:n.slice(r)},`tail`)),o=(0,Z.jsx)(Z.Fragment,{children:e}),t[5]=n,t[6]=a,t[7]=o}else o=t[7];return o}var CT=(0,Q.memo)(function(e){let t=(0,X.c)(42),{open:n,anchorRef:r,items:i,selectedIndex:a,loading:o,query:s,noResults:c,conversationId:l,recentLabel:u,sectionLabels:d,ariaLabel:f,onSelectItem:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m={box:null,hoverPreview:null},t[0]=m):m=t[0];let[h,g]=(0,Q.useReducer)(bT,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&&za(i,{conversationId:l}).then(e=>{let{content:i}=e,a=i.length>yT?`${i.slice(0,yT)}…`:i;r===b.current&&g({type:`set-hover`,hoverPreview:{text:a,x:t,y:n}})}).catch(()=>{r===b.current&&g({type:`set-hover`,hoverPreview:null})})},420)},t[2]=l,t[3]=w);let T=w,E,D;t[4]!==r||t[5]!==n?(E=()=>{if(!n){g({type:`reset`}),C(),b.current+=1;return}let e=()=>{let e=r.current;if(!e)return;let t=e.getBoundingClientRect();g({type:`set-box`,box:{left:t.left,top:t.top,width:t.width}})};e();let t=r.current,i=t&&typeof ResizeObserver<`u`?new ResizeObserver(()=>{e()}):null;return t&&i&&i.observe(t),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{t&&i&&i.disconnect(),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},D=[n,r],t[4]=r,t[5]=n,t[6]=E,t[7]=D):(E=t[6],D=t[7]),(0,Q.useLayoutEffect)(E,D);let O,A;if(t[8]!==i.length||t[9]!==n||t[10]!==a?(O=()=>{!n||a<0||a>=i.length||(x.current?.querySelector(`#at-mention-${a}`))?.scrollIntoView({block:`nearest`})},A=[n,a,i.length],t[8]=i.length,t[9]=n,t[10]=a,t[11]=O,t[12]=A):(O=t[11],A=t[12]),(0,Q.useLayoutEffect)(O,A),!n||typeof document>`u`||_===null)return null;let j=i.length,M=Math.min(_.width,vT),N;t[13]!==_.left||t[14]!==_.top||t[15]!==M?(N={position:`fixed`,left:_.left,top:_.top,width:M,transform:`translateY(calc(-100% - 8px))`,zIndex:_T},t[13]=_.left,t[14]=_.top,t[15]=M,t[16]=N):N=t[16];let P=a>=0&&a<j?`at-mention-${a}`:void 0,F;t[17]!==o||t[18]!==j?(F=o&&j===0?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2.5 text-sm text-fg-muted`,children:[(0,Z.jsx)(Je,{className:`size-4 shrink-0 animate-spin`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:`…`})]}):null,t[17]=o,t[18]=j,t[19]=F):F=t[19];let I;t[20]!==i||t[21]!==o||t[22]!==c||t[23]!==p||t[24]!==s||t[25]!==u||t[26]!==T||t[27]!==d||t[28]!==a||t[29]!==j?(I=!o&&j===0?(0,Z.jsx)(`div`,{className:`px-3 py-2 text-sm text-fg-muted`,children:c}):(0,Z.jsxs)(Z.Fragment,{children:[i.map((e,t)=>{let n=i[t-1]?.kind,r=d[e.kind],o=e.kind===`file`&&e.isRecent;return(0,Z.jsxs)(Q.Fragment,{children:[n===e.kind?null:(0,Z.jsx)(`div`,{className:`border-t border-edge-subtle px-3 pb-1 pt-2 text-[0.65rem] font-medium uppercase tracking-wide text-fg-muted first:border-t-0`,children:r}),(0,Z.jsxs)(`div`,{id:`at-mention-${t}`,role:`option`,"aria-selected":a===t,tabIndex:-1,className:Y(`flex cursor-pointer items-start gap-2 px-3 py-2 text-left text-sm`,a===t?`bg-surface-hover text-fg`:`text-fg-subtle hover:bg-surface-hover/80`,o&&`border-l-2 border-l-accent/60`),onPointerDown:t=>{t.pointerType===`mouse`&&t.button!==0||(t.preventDefault(),p(e))},onPointerEnter:t=>T(e,t.clientX,t.clientY),onPointerLeave:()=>{C(),b.current+=1,g({type:`set-hover`,hoverPreview:null})},children:[(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:e.kind===`note`?(0,Z.jsx)(xs,{className:`size-3.5 text-accent-fg`,"aria-hidden":!0}):e.kind===`session`?(0,Z.jsx)(bt,{className:`size-3.5 text-violet-600 dark:text-violet-400`,"aria-hidden":!0}):e.kind===`skill`?(0,Z.jsx)(Rt,{className:`size-3.5 text-cyan-600 dark:text-cyan-400`,"aria-hidden":!0}):e.kind===`agent`?(0,Z.jsx)(W,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):e.kind===`browser_tab`?(0,Z.jsx)(k,{className:`size-3.5 text-blue-600 dark:text-blue-400`,"aria-hidden":!0}):e.isBrowseUp?(0,Z.jsx)(Oe,{className:`size-3.5 text-fg-muted`,"aria-hidden":!0}):e.isDirectory?(0,Z.jsx)(Oe,{className:`size-3.5 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}):(0,Z.jsx)(Te,{className:Y(`size-3.5`,_e(e.name)),"aria-hidden":!0})}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 truncate`,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:(0,Z.jsx)(ST,{name:e.name,query:s})}),o?(0,Z.jsx)(`span`,{className:`shrink-0 rounded bg-accent-soft px-1 py-0 text-[0.65rem] text-accent-fg`,children:u}):null]}),(0,Z.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:e.description||r})]})]})]},e.id)}),o&&j>0?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-edge-subtle px-3 py-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(Je,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:`…`})]}):null]}),t[20]=i,t[21]=o,t[22]=c,t[23]=p,t[24]=s,t[25]=u,t[26]=T,t[27]=d,t[28]=a,t[29]=j,t[30]=I):I=t[30];let L;t[31]!==f||t[32]!==F||t[33]!==I||t[34]!==P?(L=(0,Z.jsxs)(`div`,{ref:x,className:`max-h-[min(26rem,54vh)] overflow-y-auto`,role:`listbox`,"aria-label":f,"aria-activedescendant":P,children:[F,I]}),t[31]=f,t[32]=F,t[33]=I,t[34]=P,t[35]=L):L=t[35];let R;t[36]===v?R=t[37]:(R=v?(0,Z.jsx)(`div`,{className:`pointer-events-none fixed z-[200] max-h-48 max-w-sm overflow-auto rounded-md border border-edge bg-surface-overlay p-2 font-mono text-[0.7rem] text-fg shadow-lg`,style:{left:Math.min(v.x+12,window.innerWidth-320),top:Math.min(v.y+12,window.innerHeight-200)},children:v.text}):null,t[36]=v,t[37]=R);let z;return t[38]!==L||t[39]!==R||t[40]!==N?(z=(0,Is.createPortal)((0,Z.jsxs)(`div`,{"data-composer-picker-panel":!0,className:`pointer-events-auto max-h-[min(28rem,60vh)] min-h-[2.5rem] overflow-hidden rounded-lg border border-edge bg-surface-overlay shadow-lg`,style:N,role:`presentation`,children:[L,R]}),document.body),t[38]=L,t[39]=R,t[40]=N,t[41]=z):z=t[41],z});function wT(e,t){let n=e=>{e!==!1&&(e&&typeof e==`object`?t(e.conversationId):t())};e instanceof Promise?e.then(n).catch(e=>{ya(`error`,e instanceof Error?e.message:String(e))}):n(e)}var TT=new Set([`abort`,`stop`,`cancel`]);function ET(e){if(e.kind!==`command`)return!1;if(TT.has(e.name.toLowerCase()))return!0;for(let t of e.aliases??[])if(TT.has(t.toLowerCase()))return!0;return!1}function DT(e,t,n,r){return e.slice(0,t)+r+e.slice(n)}var OT=(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=DT(t.editor.valueRef.current,n.start,n.end,r),a=n.start+r.length;t.editor.resetEditor({nextText:i,caretOffset:a,focus:!0})},kT=(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=DT(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(ET(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}wT(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()})},AT=(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 jT(e,t){switch(e.kind){case`skill`:OT(e,t);return;case`command`:kT(e,t);return;case`agent`:AT(e,t)}}var MT={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},NT=new Set([`abort`,`archive`]);function PT(e){if(e.kind===`command`){let t=e.name.toLowerCase();if(MT[t]!==void 0)return 0;if(NT.has(t))return 2}return 1}function FT(e,t){let n=PT(e),r=PT(t);if(n!==r)return n-r;if(n===0){let n=MT[e.name.toLowerCase()]??999,r=MT[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 IT(e){if(e.kind!==`command`)return!1;if(TT.has(e.name.toLowerCase()))return!0;for(let t of e.aliases??[])if(TT.has(t.toLowerCase()))return!0;return!1}function LT(e,t){return e.kind!==`command`||e.acceptsArgs===!0||IT(e)||!(t.runBusy||t.pendingFollowUpsCount>0)?!1:t.pendingFollowUpsCount>=t.maxPendingFollowUps}function RT(e,t){return e.kind!==`command`||e.acceptsArgs===!0||IT(e)||!(t.runBusy||t.pendingFollowUpsCount>0)?!1:t.pendingFollowUpsCount<t.maxPendingFollowUps}function zT(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 BT(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 VT(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(BT(e,a))return null;let o=i[0],s=o.slice(1);return zT(s)||o.startsWith(`/skill:`)?null:{start:i.index,end:r,query:s}}function HT(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 UT(e,t){return t===0?0:Math.min(e,t-1)}function WT(e,t){let{query:n,value:r,commandsAllowed:i,agentsAllowed:a}=t,o=n.trim()===``,s=yp(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=HT(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?FT(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 GT(e,t,n){let r=(0,X.c)(49),[i,a]=(0,Q.useState)(0),[o,s]=(0,Q.useState)(0),c=h(JT),l=n?.capabilities??ep,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:VT(e,t),r[0]=t,r[1]=u,r[2]=n?.isComposing,r[3]=e,r[4]=d):d=r[4];let f=d,p=!!(f&&!n?.suppress),m,g;r[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{let e=e=>{let t=e.detail;t&&typeof t==`object`&&`section`in t&&(t.section===`skills`||t.section===`agents`)&&s(qT)};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},g=[],r[5]=m,r[6]=g):(m=r[5],g=r[6]),(0,Q.useEffect)(m,g);let _;r[7]!==c||r[8]!==n?.conversationId||r[9]!==n?.currentAgentId?(_=async()=>{let[e,t,r]=await Promise.allSettled([bo(),ho(n?.currentAgentId,n?.conversationId),ni()]),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(KT),o=(t.status===`fulfilled`?t.value.skills:[]).map(e=>{let t=xo(e,c);return{kind:`skill`,id:`skill:${e.name}`,name:t.displayName,canonicalName:e.name,description:t.description,aliases:t.aliases,searchTerms:t.searchTerms,category:`skill`,source:e.source,availability:{status:e.availableForCurrentAgent?`available`:e.unavailableReason??`agent-denied`,reason:e.unavailableReason??void 0}}}),s=y(c).agentsSettings,l=r.status===`fulfilled`?r.value:null,u=l&&l.items.length>1?l.items.map(e=>({kind:`agent`,id:`agent:${e.id}`,agentId:e.id,name:qo(e,s),description:Jo(e,s),category:`agent`,...e.avatar?{avatar:e.avatar}:{},aliases:[e.id,...e.name?[e.name]:[]]})):[];return{items:[...o,...a,...u],failedKinds:i}},r[7]=c,r[8]=n?.conversationId,r[9]=n?.currentAgentId,r[10]=_):_=r[10];let v=n?.currentAgentId,b=n?.conversationId,x;r[11]!==c||r[12]!==o||r[13]!==v||r[14]!==b?(x=[c,v,b,o],r[11]=c,r[12]=o,r[13]=v,r[14]=b,r[15]=x):x=r[15];let S;r[16]===Symbol.for(`react.memo_cache_sentinel`)?(S=[],r[16]=S):S=r[16];let C;r[17]===Symbol.for(`react.memo_cache_sentinel`)?(C=[],r[17]=C):C=r[17];let w,T;r[18]===Symbol.for(`react.memo_cache_sentinel`)?(T={items:S,failedKinds:C},w=[],r[18]=w,r[19]=T):(w=r[18],T=r[19]);let E;r[20]===Symbol.for(`react.memo_cache_sentinel`)?(E=[],r[20]=E):E=r[20];let D;r[21]===Symbol.for(`react.memo_cache_sentinel`)?(D={items:w,failedKinds:E},r[21]=D):D=r[21];let O;r[22]===p?O=r[23]:(O={enabled:p,initial:T,errorData:D},r[22]=p,r[23]=O);let k=Da(_,x,O),A=k.data.items,j=k.error==null?null:k.error instanceof Error?k.error.message:String(k.error),M=f?.query??``,N=l.commands&&f!==null&&f.start===0,P=l.agentSwitch&&f!==null&&f.start===0,F;r[24]!==P||r[25]!==A||r[26]!==l.skills||r[27]!==N||r[28]!==M||r[29]!==e?(F=WT(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=UT(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 KT(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 qT(e){return e+1}function JT(e){return e.language}var YT=100,XT=560;function ZT(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase().indexOf(n);if(r>=0)return(0,Z.jsxs)(Z.Fragment,{children:[e.slice(0,r),(0,Z.jsx)(`span`,{className:`text-accent-fg`,children:e.slice(r,r+n.length)}),e.slice(r+n.length)]});let i=[],a=0,o=0;for(let t of e){let e=n[a],r=`${String(o)}-${t}`;e!==void 0&&t.toLowerCase()===e?(i.push((0,Z.jsx)(`span`,{className:`text-accent-fg`,children:t},r)),a+=1):i.push((0,Z.jsx)(Q.Fragment,{children:t},r)),o+=1}return(0,Z.jsx)(Z.Fragment,{children:i})}function QT(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase().indexOf(n);return r<0?e:(0,Z.jsxs)(Z.Fragment,{children:[e.slice(0,r),(0,Z.jsx)(`span`,{className:`text-accent-fg`,children:e.slice(r,r+n.length)}),e.slice(r+n.length)]})}var $T=(0,Q.memo)(function(e){let t=(0,X.c)(46),{item:n,index:r,selectedIndex:i,showHighlight:a,filterQuery:o,currentAgentId:s,currentBadgeLabel:c,runBusy:l,pendingFollowUpsCount:u,maxPendingFollowUps:d,queueBadgeLabel:f,queueFullBadgeLabel:p,queueFullTooltip:m,skillUnavailableLabel:h,skillAgentDeniedLabel:g,skillSourceLabels:_,onSelectItem:v}=e,y=n.kind===`skill`,b=n.kind===`agent`,x;t[0]!==b||t[1]!==y||t[2]!==n.agentId||t[3]!==n.avatar?(x=b?(0,Z.jsx)(Aa,{agentId:n.agentId,avatar:n.avatar,size:18,className:`size-[18px] shrink-0`}):y?(0,Z.jsx)(Rt,{className:`size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,Z.jsx)(Kt,{className:`size-4 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}),t[0]=b,t[1]=y,t[2]=n.agentId,t[3]=n.avatar,t[4]=x):x=t[4];let S=x,C;t[5]!==o||t[6]!==b||t[7]!==n.name||t[8]!==a?(C=b?a?(0,Z.jsx)(Z.Fragment,{children:ZT(n.name,o)}):(0,Z.jsx)(`span`,{className:`text-fg`,children:n.name}):a?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`text-fg`,children:`/`}),ZT(n.name,o)]}):(0,Z.jsxs)(`span`,{className:`text-fg`,children:[`/`,n.name]}),t[5]=o,t[6]=b,t[7]=n.name,t[8]=a,t[9]=C):C=t[9];let w=C,T=b&&s!=null&&s.length>0&&n.agentId===s,E=y&&n.availability.status!==`available`,D,O;if(t[10]!==n||t[11]!==d||t[12]!==u||t[13]!==l){let e={runBusy:l,pendingFollowUpsCount:u,maxPendingFollowUps:d};O=RT(n,e),D=LT(n,e),t[10]=n,t[11]=d,t[12]=u,t[13]=l,t[14]=D,t[15]=O}else D=t[14],O=t[15];let k=D,A=null;if(T){let e;t[16]===c?e=t[17]:(e=(0,Z.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-accent-soft px-1 py-px text-[0.6rem] font-medium leading-none text-accent-fg`,"aria-label":c,children:c}),t[16]=c,t[17]=e),A=e}else if(E){let e=n.availability.reason??`unavailable`,r=n.availability.status===`agent-denied`?g:h,i;t[18]!==e||t[19]!==r?(i=(0,Z.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-surface-hover px-1 py-px text-[0.6rem] font-medium leading-none text-fg-muted`,"aria-label":e,children:r}),t[18]=e,t[19]=r,t[20]=i):i=t[20],A=i}else if(y&&n.source){let e=_[n.source]??n.source,r;t[21]===e?r=t[22]:(r=(0,Z.jsx)(`span`,{className:`ml-2 shrink-0 text-[11px] font-normal text-fg-muted`,children:e}),t[21]=e,t[22]=r),A=r}else if(k){let e;t[23]===p?e=t[24]:(e=(0,Z.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-red-100 px-1 py-px text-[0.6rem] font-medium leading-none text-red-700 dark:bg-red-900/40 dark:text-red-300`,"aria-label":p,children:p}),t[23]=p,t[24]=e),A=e}else if(O){let e;t[25]===f?e=t[26]:(e=(0,Z.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-surface-hover px-1 py-px text-[0.6rem] font-medium leading-none text-fg-muted`,"aria-label":f,children:f}),t[25]=f,t[26]=e),A=e}let j=i===r,M=`palette-${r}`,N;t[27]!==o||t[28]!==n.description||t[29]!==a?(N=n.description?a?QT(n.description,o):n.description:null,t[27]=o,t[28]=n.description,t[29]=a,t[30]=N):N=t[30];let P=k?m:void 0,F;t[31]!==n||t[32]!==v?(F=()=>v(n),t[31]=n,t[32]=v,t[33]=F):F=t[33];let I;return t[34]!==S||t[35]!==k||t[36]!==n||t[37]!==w||t[38]!==a||t[39]!==j||t[40]!==M||t[41]!==N||t[42]!==P||t[43]!==F||t[44]!==A?(I=(0,Z.jsx)(tE,{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}),eE=(0,Q.memo)(function(e){let t=(0,X.c)(53),{open:n,anchorRef:r,sections:i,flatItems:a,loading:o,failedKinds:s,selectedIndex:c,noResults:l,sectionLoadFailedLabel:u,query:d,skillsLabel:f,commandsLabel:p,agentsLabel:m,currentAgentId:h,currentBadgeLabel:g,runBusy:_,pendingFollowUpsCount:v,maxPendingFollowUps:y,queueBadgeLabel:b,queueFullBadgeLabel:x,queueFullTooltip:S,skillUnavailableLabel:C,skillAgentDeniedLabel:w,skillSourceLabels:T,onSelectItem:E,panelRef:D}=e,[O,k]=(0,Q.useState)(null),A,j;t[0]!==r||t[1]!==n?(A=()=>{if(!n){k(null);return}let e=()=>{let e=r.current;if(!e)return;let t=e.getBoundingClientRect();k({left:t.left,top:t.top,width:t.width})};e();let t=r.current,i=t&&typeof ResizeObserver<`u`?new ResizeObserver(()=>{e()}):null;return t&&i&&i.observe(t),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{t&&i&&i.disconnect(),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},j=[n,r],t[0]=r,t[1]=n,t[2]=A,t[3]=j):(A=t[2],j=t[3]),(0,Q.useLayoutEffect)(A,j);let M,N;if(t[4]!==a.length||t[5]!==n||t[6]!==c?(M=()=>{!n||a.length===0||document.getElementById(`palette-${c}`)?.scrollIntoView?.({block:`nearest`})},N=[a.length,n,c],t[4]=a.length,t[5]=n,t[6]=c,t[7]=M,t[8]=N):(M=t[7],N=t[8]),(0,Q.useEffect)(M,N),!n||typeof document>`u`||O===null)return null;let P=a.length,F=a[c],I=Math.min(O.width,XT),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(nE)),n=[`skill`,`command`,`agent`].filter(t=>e.has(t)||s.includes(t)),r=0;W=o&&P===0?(0,Z.jsx)(`div`,{className:`space-y-2 p-2.5`,"aria-busy":`true`,children:Array.from({length:6},rE)}):P===0&&s.length===0?(0,Z.jsx)(`div`,{className:`p-2.5 text-xs leading-normal text-fg-muted`,children:l}):n.map((t,n)=>{let i=e.get(t)?.items??[],a=r;r+=i.length;let o=`palette-section-${t}`;return(0,Z.jsxs)(`div`,{role:`group`,"aria-labelledby":o,className:Y(n>0&&`border-t border-edge-subtle`),children:[(0,Z.jsxs)(`div`,{id:o,className:`sticky top-0 z-10 flex items-center justify-between bg-surface-overlay px-2.5 py-2 text-[0.65rem] font-medium uppercase leading-none tracking-wide text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:V[t]}),(0,Z.jsx)(`span`,{className:`tabular-nums`,"aria-hidden":!0,children:i.length})]}),s.includes(t)?(0,Z.jsx)(`div`,{className:`px-2.5 pb-2 text-[11px] leading-relaxed text-fg-muted`,children:u}):i.map((e,t)=>(0,Z.jsx)($T,{item:e,index:a+t,...U},e.id))]},t)}),t[31]=s,t[32]=o,t[33]=l,t[34]=U,t[35]=V,t[36]=u,t[37]=i,t[38]=P,t[39]=W}else W=t[39];let G=W,ee;t[40]!==O.left||t[41]!==O.top||t[42]!==I?(ee={position:`fixed`,left:O.left,top:O.top,width:I,transform:`translateY(calc(-100% - 8px))`,zIndex:YT},t[40]=O.left,t[41]=O.top,t[42]=I,t[43]=ee):ee=t[43];let te=`${f}, ${p}, ${m}`,ne=F?`${V[F.kind]}: ${F.name}`:``,re;t[44]===ne?re=t[45]:(re=(0,Z.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:ne}),t[44]=ne,t[45]=re);let ie;return t[46]!==G||t[47]!==o||t[48]!==D||t[49]!==te||t[50]!==re||t[51]!==ee?(ie=(0,Is.createPortal)((0,Z.jsx)(Ga,{delayDuration:0,skipDelayDuration:0,disableHoverableContent:!1,children:(0,Z.jsxs)(`div`,{ref:D,className:`pointer-events-auto max-h-[min(32rem,60vh)] min-h-8 overflow-y-auto rounded-md border border-edge bg-surface-overlay text-xs leading-4 shadow-lg`,style:ee,role:`listbox`,"aria-label":te,"aria-busy":o,children:[re,G]})}),document.body),t[46]=G,t[47]=o,t[48]=D,t[49]=te,t[50]=re,t[51]=ee,t[52]=ie):ie=t[52],ie}),tE=(0,Q.memo)(function(e){let t=(0,X.c)(39),{item:n,icon:r,selected:i,id:a,nameLine:o,descriptionLine:s,dimCategoryBadge:c,trailingBadge:l,disabled:u,disabledTooltip:d,onSelect:f}=e,p;t[0]===n.description?p=t[1]:(p=n.description.trim(),t[0]=n.description,t[1]=p);let m=p,h=m.length>0&&s!=null,g=m.length>0,_=n.description,v=n.category&&n.kind!==`skill`&&!c&&!(n.kind===`agent`&&l),y;t[2]===o?y=t[3]:(y=(0,Z.jsx)(`span`,{className:`min-w-0 max-w-[min(12rem,46%)] shrink-0 truncate font-semibold text-fg`,children:o}),t[2]=o,t[3]=y);let b;t[4]!==n.category||t[5]!==v?(b=v?(0,Z.jsx)(`span`,{className:`shrink-0 rounded bg-surface-hover px-1 py-px text-[0.6rem] font-normal leading-none text-fg-muted`,children:n.category}):null,t[4]=n.category,t[5]=v,t[6]=b):b=t[6];let x;t[7]!==s||t[8]!==h?(x=h?(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] font-normal leading-tight text-fg-muted`,children:s}):null,t[7]=s,t[8]=h,t[9]=x):x=t[9];let S;t[10]!==y||t[11]!==b||t[12]!==x?(S=(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-1`,children:[y,b,x]}),t[10]=y,t[11]=b,t[12]=x,t[13]=S):S=t[13];let C=S,w=u?`cursor-not-allowed opacity-50 text-fg-muted`:i?`cursor-pointer bg-surface-hover text-fg`:`cursor-pointer text-fg-subtle hover:bg-surface-hover/80`,T;t[14]===w?T=t[15]:(T=Y(`flex min-h-11 w-full min-w-0 items-center gap-2 px-2.5 py-1.5 text-left text-sm leading-5 sm:min-h-9`,w),t[14]=w,t[15]=T);let E=T,D;t[16]!==u||t[17]!==f?(D=e=>{u||e.pointerType===`mouse`&&e.button!==0||(e.preventDefault(),f())},t[16]=u,t[17]=f,t[18]=D):D=t[18];let O=D,k;t[19]===r?k=t[20]:(k=(0,Z.jsx)(`span`,{className:`shrink-0 [&_svg]:align-middle`,children:r}),t[19]=r,t[20]=k);let A;t[21]!==k||t[22]!==C||t[23]!==l?(A=(0,Z.jsxs)(Z.Fragment,{children:[k,C,l]}),t[21]=k,t[22]=C,t[23]=l,t[24]=A):A=t[24];let j=A,M=u&&d?d:g?_:null,N=u||void 0,P;t[25]!==a||t[26]!==O||t[27]!==E||t[28]!==j||t[29]!==i||t[30]!==N?(P=(0,Z.jsx)(`div`,{id:a,role:`option`,"aria-selected":i,"aria-disabled":N,tabIndex:-1,className:E,onPointerDown:O,children:j}),t[25]=a,t[26]=O,t[27]=E,t[28]=j,t[29]=i,t[30]=N,t[31]=P):P=t[31];let F=P;if(M!==null){let e;t[32]===F?e=t[33]:(e=(0,Z.jsx)(Ya,{asChild:!0,children:F}),t[32]=F,t[33]=e);let n;t[34]===M?n=t[35]:(n=(0,Z.jsx)(Ka,{children:(0,Z.jsx)(Ja,{side:`right`,align:`start`,sideOffset:8,collisionPadding:12,className:`!z-[10000] max-h-[min(12rem,40vh)] max-w-sm overflow-y-auto rounded-md border border-edge bg-surface-overlay px-2 py-1.5 text-left text-[11px] leading-snug text-fg shadow-lg select-text [max-width:min(20rem,90vw)]`,"data-slash-palette-tooltip":``,children:(0,Z.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:M})})}),t[34]=M,t[35]=n);let r;return t[36]!==e||t[37]!==n?(r=(0,Z.jsxs)(qa,{delayDuration:0,children:[e,n]}),t[36]=e,t[37]=n,t[38]=r):r=t[38],r}return F});function nE(e){return[e.kind,e]}function rE(e,t){return(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,Z.jsx)(qt,{className:`size-4 shrink-0`}),(0,Z.jsx)(qt,{className:`h-3 w-28`}),(0,Z.jsx)(qt,{className:`h-3 flex-1`})]},t)}var iE=new Map;function aE(e){let t=iE.get(e);return t||(t={items:[],loadPromise:null,loaded:!1,writeQueue:Promise.resolve(),mutationVersion:0,clearVersion:0},iE.set(e,t)),t}function oE(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 sE(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}oE(e,t)}function cE(e){return aE(e).items.map(e=>e.text)}function lE(e,t=!1){let n=aE(e);if(n.loaded&&!t)return Promise.resolve();if(n.loadPromise)return n.loadPromise;let r=n.mutationVersion,i=!1;return n.loadPromise=n.writeQueue.then(()=>g(`/api/composer-history?conversationId=${encodeURIComponent(e)}`)).then(t=>{n.mutationVersion===r?(n.items=t.items.filter(t=>t.conversationId===e).slice(0,100),n.loaded=!0):i=!0}).catch(()=>{}).finally(()=>{n.loadPromise=null,i&&n.writeQueue.then(()=>lE(e,!0))}),n.loadPromise}function uE(e,t){let n=t.trim();if(!n)return;let r=aE(e),i=r.clearVersion;r.mutationVersion+=1,oE(r,{conversationId:e,id:0,text:n,createdAt:Date.now()}),r.writeQueue=r.writeQueue.then(async()=>{let t=await g(`/api/composer-history`,{method:`POST`,body:JSON.stringify({conversationId:e,text:n})});r.clearVersion===i&&t.item.conversationId===e&&sE(r,t.item)}).catch(()=>{})}function dE(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=aE(t.conversationId);return n.mutationVersion+=1,sE(n,t),t.conversationId}function fE(e){if(!e||typeof e!=`object`||!(`conversationId`in e)||typeof e.conversationId!=`string`)return null;let t=aE(e.conversationId);return t.mutationVersion+=1,t.clearVersion+=1,t.items=[],e.conversationId}function pE(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&&lE(t,!0);let e=e=>{dE(e.detail)===t&&c()},n=e=>{fE(e.detail)===t&&c()},r=()=>{t&&lE(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&&!Wn(e)&&uE(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=cE(t);if(a.length===0)return!1;let o=s.current,c=n.current,l=c?bp(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 mE(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 hE(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 gE(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=mE(t.current);if(n===`blocked`)return;if(n===`queue`){D.current();return}let r=hE({voiceActive:i,cancelVoiceInput:a,...w});if(!r)return;if(n===`saveFollowUp`){if(O.current||!o)return;O.current=!0,Promise.resolve().then(()=>g(o,r.text,r.attachments,d(),r.contextRefs)).then(n=>{if(n===!1)return;C?.(r.text);let i=t.current;i.draftScope!==e.draftScope||i.editingFollowUpId!==o||i.getTextValue()!==r.text||JSON.stringify(i.wireAttachmentsPayload())!==JSON.stringify(r.attachments)||JSON.stringify(i.getContextRefs())!==JSON.stringify(r.contextRefs)||(i.onFinishFollowUpEdit?.(),S())}).catch(e=>ya(`error`,e instanceof Error?e.message:String(e))).finally(()=>{O.current=!1});return}let s=[r.text,r.attachments.length>0?r.attachments:void 0,d(),r.contextRefs.length>0?r.contextRefs:void 0,{onDispatched:e=>p?.(e,r)}];wT(f(...s),i=>{C?.(r.text,i);let a=t.current,o=e.draftScope,s=a.draftScope;if(!(!(n===`send`&&o?.conversationId===null&&i!==void 0&&s?.conversationId===i&&s.gatewayIdentity===o.gatewayIdentity)&&s!==o||a.getTextValue()!==r.text||JSON.stringify(a.wireAttachmentsPayload())!==JSON.stringify(r.attachments)||JSON.stringify(a.getContextRefs())!==JSON.stringify(r.contextRefs))){if(n===`replaceTurn`){a.editingUserTurnId===e.editingUserTurnId&&a.onFinishUserEdit?.();return}y(),b(),x()}})},[r,o,g,S,i,a,f,p,e.editingUserTurnId,e.draftScope,d,C,y,b,x,s,c,l,u]),A=(0,Q.useCallback)(async(o=e.personal?!0:void 0,s)=>{if(t.current.editingFollowUpId||t.current.editingUserTurnId){k();return}if(!r&&v===0)return;let c=hE({voiceActive:i,cancelVoiceInput:a,...w});if(c&&!t.current.blocked&&m&&!T.current){if(v>=10){ya(`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){ya(`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=hE({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=>ya(`error`,e instanceof Error?e.message:String(e))).finally(()=>{E.current=!1}))},[r,i,a,o,_,h,e.draftScope,C,S,y,b,x,s,c,l,u]),steerCurrentReply:(0,Q.useCallback)(()=>{let e=t.current;if(!(!e.runBusy||e.blocked||e.voiceActive||e.steeringPending||e.editingFollowUpId||e.editingUserTurnId)){if(e.pendingFollowUpsCount>0){e.firstPendingFollowUpId&&e.onSteerPendingFollowUp?.(e.firstPendingFollowUpId);return}A(!1,`steer`)}},[A])}}var _E=e=>e?.kind===`editTurn`?`turn:${e.turnId}`:e?.kind===`editFollowUp`?`input:${e.inputId}:${e.version}`:`compose`,vE=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),yE=new Map;function bE(e,t){let n=(yE.get(e)??Promise.resolve()).catch(()=>{}).then(t);yE.set(e,n);let r=()=>{yE.get(e)===n&&yE.delete(e)};return n.then(r,r),n}function xE(e,t,n,r,i,a,o,s){let c=_E(a?.snapshot().mode),l=m(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),[h,g]=(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:Dr(e)};f.current=i;let a=!1,c=yE.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,g(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||!vE(i.attachments,e.snapshot.attachments)||!vE(i.refs,e.snapshot.refs)||_E(i.editSession?.mode)!==_E(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;bE(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,h,t.value,n.attachments,r,c]),(0,Q.useEffect)(()=>{let e=f.current;if(!(!e?.ready||!u))return Hs(u,async(t,n)=>{if(await yE.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 bE(u,()=>e.storage.write(t))}catch(n){throw e.receipts=e.receipts.filter(e=>e!==t),n}})},[u,h])}function SE(e){let{conversationId:t,agentId:n,modelKey:r,locale:i,enabled:a,draftText:o,canShow:s}=e,c=m(e=>e.conversationId),[l,u]=(0,Q.useState)(null),[d,h]=(0,Q.useState)(null),g=(0,Q.useRef)(null),_=(0,Q.useRef)(o),v=(0,Q.useRef)(-1),y=(0,Q.useCallback)((e,t,n)=>{f(p(`/api/sessions/${encodeURIComponent(e.suggestion.conversationId)}/next-turn-suggestion-feedback`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({suggestionId:e.suggestion.id,impressionId:e.impressionId,event:t,...n===void 0?{}:{edited:n}})}).catch(()=>{})},[]);(0,Q.useEffect)(()=>{_.current.length>0&&o.length===0&&(g.current=null),_.current=o},[o]),(0,Q.useEffect)(()=>{g.current=null,v.current=-1,u(null),h(null)},[t,n,r,i,c]),(0,Q.useEffect)(()=>{if(u(null),!a||!t)return;let e=!1,r=0,o,s=0,c=new AbortController,l=async()=>{let a=++r;try{if(await wr(t))return;let d=await f(p(`/api/sessions/${encodeURIComponent(t)}/next-turn-suggestion?locale=${i}`),{signal:c.signal});if(!d.ok)return;let m=Ns.safeParse(await d.json());if(e||a!==r||!m.success)return;let h=m.data.suggestion;if(m.data.status===`ready`&&h&&h.conversationId===t&&h.locale===i&&(!n||h.agentId===n)&&h.inputRevision>=v.current&&h.expiresAt>Date.now()&&h.transcriptId===await Ar(t)){if(e||a!==r)return;u(e=>e?.suggestion.id===h.id?e:{suggestion:h,impressionId:crypto.randomUUID()}),o=setTimeout(()=>{u(null)},Math.max(0,h.expiresAt-Date.now()))}else u(null),m.data.status===`pending`&&s++<7&&(o=setTimeout(()=>{l()},600))}catch{}},d=e=>{let n=e.detail;if(!(n?.conversationId!==t&&n?.key!==t)){if(typeof n.revision==`number`){if(n.revision<v.current)return;v.current=n.revision}r++,s=0,o&&clearTimeout(o),u(null),e.type===`session-transcript-updated`?o=setTimeout(()=>{l()},150):l()}},m=()=>{r++,s=0,o&&clearTimeout(o),u(null),l()},h=e=>{e.detail?.topic===`sessions`&&m()};l();let g=[`session-next-turn-suggestion-changed`,`session-input-state`,`session-updated`,`session-transcript-updated`];return g.forEach(e=>window.addEventListener(e,d)),window.addEventListener(`gateway-realtime-connected`,m),window.addEventListener(`config-reload`,m),window.addEventListener(`realtime-gap`,h),()=>{e=!0,r++,c.abort(),o&&clearTimeout(o),g.forEach(e=>window.removeEventListener(e,d)),window.removeEventListener(`gateway-realtime-connected`,m),window.removeEventListener(`config-reload`,m),window.removeEventListener(`realtime-gap`,h)}},[t,n,r,i,c,a]);let b=a&&s&&o.length===0&&l?.suggestion.id!==d&&l?.suggestion.conversationId===t&&l.suggestion.expiresAt>Date.now()?l:null,x=(0,Q.useCallback)(()=>{b&&y(b,`shown`)},[b,y]),S=(0,Q.useCallback)(()=>b?(g.current=b,y(b,`accepted`),b.suggestion.prompt):null,[b,y]),C=(0,Q.useCallback)(()=>{b&&(h(b.suggestion.id),y(b,`dismissed`))},[b,y]),w=(0,Q.useCallback)(e=>{let n=g.current;!n||n.suggestion.conversationId!==t||(h(n.suggestion.id),y(n,`submitted`,e.trim()!==n.suggestion.prompt),g.current=null)},[t,y]);return{suggestion:b?.suggestion??null,shown:x,accept:S,dismiss:C,submitted:w}}function CE(e){let t=(0,X.c)(6),{active:n,anchors:r,ignoreSelector:i,onDismiss:a}=e,o,s;t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a?(o=()=>{if(!n)return;let e=e=>{let t=e.target;if(t instanceof Node){for(let e of r){let n=e.current;if(n&&n.contains(t))return}i&&t instanceof Element&&t.closest(i)||a()}};return window.addEventListener(`pointerdown`,e,!0),()=>window.removeEventListener(`pointerdown`,e,!0)},s=[n,r,i,a],t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s):(o=t[4],s=t[5]),(0,Q.useEffect)(o,s)}var wE=20,TE=`xopc.atMention.recent:`;function EE(e){return`${TE}${e.trim()}`}function DE(e){let t=e?.trim();if(!t||typeof localStorage>`u`)return[];try{let e=localStorage.getItem(EE(t));if(!e)return[];let n=JSON.parse(e);return Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.length>0).slice(0,wE):[]}catch{return[]}}function OE(e,t){let n=e?.trim(),r=t.trim();if(!(!n||!r||typeof localStorage>`u`))try{let e=[r,...DE(n).filter(e=>e!==r)].slice(0,wE);localStorage.setItem(EE(n),JSON.stringify(e))}catch{}}var kE=150,AE=[`file`,`note`,`session`,`browser_tab`,`skill`,`agent`];function jE(e){let t={items:[],loading:e,error:null};return{file:{...t},note:{...t},session:{...t},skill:{...t},agent:{...t},browser_tab:{...t}}}function ME(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 NE(e){return e.replace(/[\\\s]/gu,e=>`\\${e}`)}function PE(e){let t=e.trim();return t.length>0&&t.endsWith(`/`)&&!/^https?:\/\//i.test(t)}function FE(e){return e.replace(/\/+$/,``).trim()}function IE(e){let t=e.replace(/\/+$/,``);if(!t)return``;let n=t.lastIndexOf(`/`);return n<=0?``:t.slice(0,n)}function LE(e,t){return t===0?0:Math.min(e,t-1)}function RE(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 zE(e,t,n){let r=(0,X.c)(55),i=n.capabilities??ep,[a,o]=(0,Q.useState)(0),[s,c]=(0,Q.useState)(WE),l=(0,Q.useRef)(0),u=h(UE),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=ME(e,t),r[0]=t,r[1]=e,r[2]=i):i=r[2],d=i}let f=d,p=f!==null,[m]=Wa(p?f.query:``,kE),g=p?m:``,_;r[3]===n.conversationId?_=r[4]:(_=n.conversationId?.trim()??``,r[3]=n.conversationId,r[4]=_);let v=_,y;r[5]===n.selectedContextKeys?y=r[6]:(y=[...n.selectedContextKeys??new Set].sort().join(`\0`),r[5]=n.selectedContextKeys,r[6]=y);let b=y,x;r[7]!==i.agentSwitch||r[8]!==i.skills||r[9]!==v||r[10]!==g||r[11]!==u||r[12]!==n||r[13]!==p||r[14]!==b?(x=()=>{let e=l.current+=1;if(!p){c(jE(!1));return}if(!v){c(jE(!!n.prepareSession)),n.prepareSession&&n.prepareSession().catch(()=>{l.current===e&&c(jE(!1))});return}let t={conversationId:v,currentAgentId:n.currentAgentId,language:u,selectedContextKeys:new Set(b?b.split(`\0`):[]),recentPaths:new Set(DE(v))};if(PE(g)){let t=jE(!1);t.file={items:[],loading:!0,error:null},c(t);let r=FE(g);Ew(r,{conversationId:v,agentId:n.currentAgentId}).then(t=>{if(l.current!==e)return;let n={id:`browse-up:${r}`,kind:`file`,name:`..`,description:IE(r)||`/`,relativePath:``,isDirectory:!0,isBrowseUp:!0};c(e=>({...e,file:{items:[n,...t.map(RE)],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(jE(!0));for(let n of kw.filter(e=>(e.kind!==`skill`||i.skills)&&(e.kind!==`agent`||i.agentSwitch)))n.search(g,t).then(t=>{l.current===e&&c(e=>({...e,[n.kind]:{items:t,loading:!1,error:null}}))}).catch(t=>{l.current===e&&c(e=>({...e,[n.kind]:{items:[],loading:!1,error:t instanceof Error?t.message:String(t)}}))})},r[7]=i.agentSwitch,r[8]=i.skills,r[9]=v,r[10]=g,r[11]=u,r[12]=n,r[13]=p,r[14]=b,r[15]=x):x=r[15];let S;r[16]!==i.agentSwitch||r[17]!==i.skills||r[18]!==v||r[19]!==g||r[20]!==u||r[21]!==n.currentAgentId||r[22]!==n.prepareSession||r[23]!==p||r[24]!==b?(S=[p,v,g,u,n.currentAgentId,n.prepareSession,b,i.skills,i.agentSwitch],r[16]=i.agentSwitch,r[17]=i.skills,r[18]=v,r[19]=g,r[20]=u,r[21]=n.currentAgentId,r[22]=n.prepareSession,r[23]=p,r[24]=b,r[25]=S):S=r[25],(0,Q.useEffect)(x,S);let C;if(r[26]!==i.agentSwitch||r[27]!==i.skills||r[28]!==s){let e;r[30]!==i.agentSwitch||r[31]!==i.skills?(e=e=>(e!==`skill`||i.skills)&&(e!==`agent`||i.agentSwitch),r[30]=i.agentSwitch,r[31]=i.skills,r[32]=e):e=r[32];let t;r[33]===s?t=r[34]:(t=e=>({kind:e,...s[e]}),r[33]=s,r[34]=t),C=AE.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(HE):[],E;r[35]!==p||r[36]!==w?(E=p&&w.some(VE),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(BE),r[38]=w,r[39]=O);let k=O,A=!D&&T.length===0?k[0]??null:null,j=`${f?.start??``}:${f?.end??``}:${g}`,M;r[40]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>o(0),r[40]=M):M=r[40];let N;r[41]===j?N=r[42]:(N=[j],r[41]=j,r[42]=N),(0,Q.useEffect)(M,N);let P=LE(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 BE(e){return e.error?[e.error]:[]}function VE(e){return e.loading}function HE(e){return e.items}function UE(e){return e.language}function WE(){return jE(!1)}function GE(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 KE(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??ep,D=(0,Q.useMemo)(()=>ME(n,r),[n,r]),O=GT(n,r,{suppress:D!=null,capabilities:E,isComposing:i,currentAgentId:m,conversationId:t}),k=zE(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`||jT(e,j())},[j,E]),N=(0,Q.useCallback)(e=>{let n=k.atRange;if(!n)return;let r=GE(e);if(r){let i=_(r);if(!i?.refId)return;let a=`${_r(i.refId)} `,o=DT(c.current,n.start,n.end,a);l({nextText:o,caretOffset:n.start+a.length,focus:!0}),t&&e.kind===`file`&&OE(t,e.relativePath);return}if(e.kind===`skill`){if(!E.skills)return;let t=`/skill:${e.canonicalName} `,r=DT(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=DT(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=`@${NE(e.isBrowseUp?(()=>{let e=IE(FE(n.query));return e?`${e}/`:``})():`${e.relativePath.replace(/\/+$/,``)}/`)}`,a=DT(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]);CE({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=DT(r,n.start,n.end,``);return l({nextText:i,caretOffset:n.start,focus:!0}),!0}if(t.items.length===0)return!1;if(e.key===`ArrowDown`)return e.preventDefault(),t.onNavigate(`down`),!0;if(e.key===`ArrowUp`)return e.preventDefault(),t.onNavigate(`up`),!0;if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let n=t.items[t.selectedIndex];return n&&H.current(n),!0}return!1}}),[l,F]),G=(0,Q.useMemo)(()=>({name:`slash-palette`,isActive:()=>z.current.open&&!B.current,handleKey:e=>{let t=z.current;if(t.flatItems.length>0){if(e.key===`ArrowDown`)return e.preventDefault(),t.onNavigate(`down`),!0;if(e.key===`ArrowUp`)return e.preventDefault(),t.onNavigate(`up`),!0;if((e.key===`Enter`||e.key===`Tab`)&&!e.shiftKey){e.preventDefault();let n=t.flatItems[t.selectedIndex];return!n||LT(n,U.current)||V.current(n),!0}}if(e.key===`Escape`){e.preventDefault();let n=t.slashRange;if(n){let e=F.current,t=DT(e,n.start,n.end,``);l({nextText:t,caretOffset:n.start,focus:!0})}return!0}return!1}}),[l,F]);return{palette:O,atPicker:k,shouldSyncSelection:A,adapters:(0,Q.useMemo)(()=>[W,G],[W,G]),applyPalette:M,applyAtMention:N}}function qE(e){return/^[A-Za-z0-9._/@:-]+$/.test(e)?e:JSON.stringify(e)}function JE(e,t){let n=t?.trim();return n?`${e} --instructions ${qE(n)}`:e}function YE(e){if(e.preset===`base`){if(!e.baseBranch?.trim())throw Error(`Missing base branch.`);return JE(`/review --base ${qE(e.baseBranch.trim())}`,e.instructions)}if(e.preset===`commit`){if(!e.commitSha?.trim())throw Error(`Missing commit SHA.`);return JE(`/review --commit ${qE(e.commitSha.trim())}`,e.instructions)}return e.preset,JE(`/review --uncommitted`,e.instructions)}async function XE(e){let t=await f(p(`/api/review/context?${new URLSearchParams({conversationId:e}).toString()}`)),n=await t.json().catch(()=>({}));if(!t.ok||!n.ok||!n.payload)throw Error(v(t.status,t.statusText,n.error?.message));return n.payload}function ZE(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 QE(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 $E(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 eD(e){let t=(0,X.c)(15),{icon:n,title:r,description:i,disabled:a,onClick:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=Y(`flex min-h-16 w-full items-center gap-3 rounded-lg border border-edge bg-surface-panel px-3 py-2.5 text-left`,`hover:border-accent/45 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:cursor-not-allowed disabled:opacity-50`,ca.transition),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,Z.jsx)(`span`,{className:`inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:n}),t[1]=n,t[2]=c);let l;t[3]===r?l=t[4]:(l=(0,Z.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:r}),t[3]=r,t[4]=l);let u;t[5]===i?u=t[6]:(u=(0,Z.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:i}),t[5]=i,t[6]=u);let d;t[7]!==l||t[8]!==u?(d=(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[l,u]}),t[7]=l,t[8]=u,t[9]=d):d=t[9];let f;return t[10]!==a||t[11]!==o||t[12]!==c||t[13]!==d?(f=(0,Z.jsxs)(`button`,{type:`button`,disabled:a,className:s,onClick:o,children:[c,d]}),t[10]=a,t[11]=o,t[12]=c,t[13]=d,t[14]=f):f=t[14],f}function tD(e){let t=(0,X.c)(89),{open:n,conversationId:r,disabled:i,chat:a,onClose:o,onSendCommand:s}=e,c=a.reviewLauncher,[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(`presets`),[_,v]=(0,Q.useState)(``),[y,x]=(0,Q.useState)(``),C;t[0]!==r||t[1]!==c.noSession?(C=()=>{if(!r){u(null),m(c.noSession);return}f(!0),m(null),XE(r).then(e=>u(e)).catch(e=>{u(null),m(e instanceof Error?e.message:String(e))}).finally(()=>f(!1))},t[0]=r,t[1]=c.noSession,t[2]=C):C=t[2];let O=C,k,A;t[3]!==O||t[4]!==n?(k=()=>{n&&(g(`presets`),v(``),x(``),O())},A=[O,n],t[3]=O,t[4]=n,t[5]=k,t[6]=A):(k=t[5],A=t[6]),(0,Q.useEffect)(k,A);let M;t[7]!==l||t[8]!==_?(M=QE(l,_),t[7]=l,t[8]=_,t[9]=M):M=t[9];let N=M,P;t[10]!==l||t[11]!==_?(P=$E(l,_),t[10]=l,t[11]=_,t[12]=P):P=t[12];let F=P,I;t[13]!==l||t[14]!==c?(I=ZE(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=YE({preset:e,baseBranch:t?.branch,commitSha:t?.commit,instructions:y});s(n),o()},t[16]=y,t[17]=o,t[18]=s,t[19]=R):R=t[19];let z=R,B=h===`base`?c.baseTitle:h===`commit`?c.commitTitle:h===`custom`?c.customTitle:c.title,V;t[20]===o?V=t[21]:(V=e=>!e&&o(),t[20]=o,t[21]=V);let H;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,Z.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[120] bg-scrim backdrop-blur-[1px]`}),t[22]=H):H=t[22];let U;t[23]!==c.back||t[24]!==h?(U=h===`presets`?null:(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":c.back,onClick:()=>{g(`presets`),v(``)},children:(0,Z.jsx)(j,{className:`size-4`})}),t[23]=c.back,t[24]=h,t[25]=U):U=t[25];let W;t[26]===B?W=t[27]:(W=(0,Z.jsx)(E,{className:`truncate text-sm font-semibold text-fg`,children:B}),t[26]=B,t[27]=W);let G=l?.cwd??c.description,ee;t[28]===G?ee=t[29]:(ee=(0,Z.jsx)(S,{className:`truncate text-xs text-fg-muted`,children:G}),t[28]=G,t[29]=ee);let te;t[30]!==W||t[31]!==ee?(te=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[W,ee]}),t[30]=W,t[31]=ee,t[32]=te):te=t[32];let ne;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,Z.jsx)(Gt,{className:`size-4`}),t[33]=ne):ne=t[33];let re;t[34]!==c.close||t[35]!==o?(re=(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":c.close,onClick:o,children:ne}),t[34]=c.close,t[35]=o,t[36]=re):re=t[36];let ie;t[37]!==U||t[38]!==te||t[39]!==re?(ie=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-4 py-3`,children:[U,te,re]}),t[37]=U,t[38]=te,t[39]=re,t[40]=ie):ie=t[40];let ae;t[41]!==N||t[42]!==F||t[43]!==l||t[44]!==i||t[45]!==p||t[46]!==y||t[47]!==O||t[48]!==d||t[49]!==c.customDescription||t[50]!==c.customPlaceholder||t[51]!==c.defaultBadge||t[52]!==c.errorTitle||t[53]!==c.loading||t[54]!==c.localBadge||t[55]!==c.noBranches||t[56]!==c.noCommits||t[57]!==c.presetBase||t[58]!==c.presetBaseDescription||t[59]!==c.presetBaseDescriptionNoDefault||t[60]!==c.presetCommit||t[61]!==c.presetCommitDescription||t[62]!==c.presetCustom||t[63]!==c.presetCustomDescription||t[64]!==c.presetUncommitted||t[65]!==c.remoteBadge||t[66]!==c.retry||t[67]!==c.searchBranches||t[68]!==c.searchCommits||t[69]!==_||t[70]!==z||t[71]!==L||t[72]!==h?(ae=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:d?(0,Z.jsxs)(`div`,{className:`flex h-full min-h-56 items-center justify-center text-sm text-fg-muted`,children:[(0,Z.jsx)(At,{className:`mr-2 size-4 animate-spin`}),c.loading]}):p?(0,Z.jsxs)(`div`,{className:`rounded-lg border border-danger/30 bg-danger/5 p-4`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:c.errorTitle}),(0,Z.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:p}),(0,Z.jsxs)(pi,{type:`button`,className:`mt-4 h-9 rounded-lg`,variant:`secondary`,onClick:O,children:[(0,Z.jsx)(At,{className:`size-4`}),c.retry]})]}):h===`presets`?(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Z.jsx)(eD,{icon:(0,Z.jsx)(Me,{className:`size-4`}),title:c.presetBase,description:l?.defaultBaseBranch?c.presetBaseDescription.replace(`{{branch}}`,l.defaultBaseBranch):c.presetBaseDescriptionNoDefault,disabled:i,onClick:()=>g(`base`)}),(0,Z.jsx)(eD,{icon:(0,Z.jsx)(Ke,{className:`size-4`}),title:c.presetUncommitted,description:L,disabled:i,onClick:()=>z(`uncommitted`)}),(0,Z.jsx)(eD,{icon:(0,Z.jsx)(ps,{className:`size-4`}),title:c.presetCommit,description:c.presetCommitDescription.replace(`{{count}}`,String(l?.commits.length??0)),disabled:i,onClick:()=>g(`commit`)}),(0,Z.jsx)(eD,{icon:(0,Z.jsx)(Ke,{className:`size-4`}),title:c.presetCustom,description:c.presetCustomDescription,disabled:i,onClick:()=>g(`custom`)})]}):h===`base`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(nD,{value:_,placeholder:c.searchBranches,onChange:v}),(0,Z.jsx)(`div`,{className:`grid gap-1`,children:N.length===0?(0,Z.jsx)(`div`,{className:`rounded-lg border border-edge-subtle px-3 py-6 text-center text-sm text-fg-muted`,children:c.noBranches}):N.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`flex items-center justify-between gap-3 rounded-lg px-3 py-2 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,disabled:i,onClick:()=>z(`base`,{branch:e.name}),children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-sm text-fg`,children:e.name}),(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:e.name===l?.defaultBaseBranch?c.defaultBadge:e.remote?c.remoteBadge:c.localBadge})]},e.name))})]}):h===`commit`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(nD,{value:_,placeholder:c.searchCommits,onChange:v}),(0,Z.jsx)(`div`,{className:`grid gap-1`,children:F.length===0?(0,Z.jsx)(`div`,{className:`rounded-lg border border-edge-subtle px-3 py-6 text-center text-sm text-fg-muted`,children:c.noCommits}):F.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`flex items-center gap-3 rounded-lg px-3 py-2 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,disabled:i,onClick:()=>z(`commit`,{commit:e.sha}),children:[(0,Z.jsx)(`span`,{className:`font-mono text-xs text-fg-muted`,children:e.shortSha}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg`,children:e.subject}),e.date?(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:e.date.slice(0,10)}):null]},e.sha))})]}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(`textarea`,{className:`h-40 resize-none rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-disabled focus:border-accent focus:ring-2 focus:ring-accent/25`,value:y,placeholder:c.customPlaceholder,onChange:e=>x(e.target.value)}),(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:c.customDescription})]})}),t[41]=N,t[42]=F,t[43]=l,t[44]=i,t[45]=p,t[46]=y,t[47]=O,t[48]=d,t[49]=c.customDescription,t[50]=c.customPlaceholder,t[51]=c.defaultBadge,t[52]=c.errorTitle,t[53]=c.loading,t[54]=c.localBadge,t[55]=c.noBranches,t[56]=c.noCommits,t[57]=c.presetBase,t[58]=c.presetBaseDescription,t[59]=c.presetBaseDescriptionNoDefault,t[60]=c.presetCommit,t[61]=c.presetCommitDescription,t[62]=c.presetCustom,t[63]=c.presetCustomDescription,t[64]=c.presetUncommitted,t[65]=c.remoteBadge,t[66]=c.retry,t[67]=c.searchBranches,t[68]=c.searchCommits,t[69]=_,t[70]=z,t[71]=L,t[72]=h,t[73]=ae):ae=t[73];let oe;t[74]!==i||t[75]!==c.cancel||t[76]!==c.runReview||t[77]!==o||t[78]!==z||t[79]!==h?(oe=h===`custom`?(0,Z.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-4 py-3`,children:[(0,Z.jsx)(pi,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg`,onClick:o,children:c.cancel}),(0,Z.jsx)(pi,{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]=oe):oe=t[80];let se;t[81]!==ie||t[82]!==ae||t[83]!==oe?(se=(0,Z.jsxs)(w,{children:[H,(0,Z.jsxs)(T,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[121] flex h-[min(86vh,34rem)] w-[min(100vw-2rem,40rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:[ie,ae,oe]})]}),t[81]=ie,t[82]=ae,t[83]=oe,t[84]=se):se=t[84];let ce;return t[85]!==n||t[86]!==se||t[87]!==V?(ce=(0,Z.jsx)(D,{open:n,onOpenChange:V,children:se}),t[85]=n,t[86]=se,t[87]=V,t[88]=ce):ce=t[88],ce}function nD(e){let t=(0,X.c)(7),{value:n,placeholder:r,onChange:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Nt,{className:`size-4 shrink-0 text-fg-muted`}),t[0]=a):a=t[0];let o;t[1]===i?o=t[2]:(o=e=>i(e.target.value),t[1]=i,t[2]=o);let s;return t[3]!==r||t[4]!==o||t[5]!==n?(s=(0,Z.jsxs)(`label`,{className:`flex h-9 items-center gap-2 rounded-lg border border-edge bg-surface-base px-3 text-sm text-fg focus-within:border-accent focus-within:ring-2 focus-within:ring-accent/25`,children:[a,(0,Z.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent outline-none placeholder:text-fg-disabled`,value:n,placeholder:r,onChange:o})]}),t[3]=r,t[4]=o,t[5]=n,t[6]=s):s=t[6],s}function rD(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 iD=(0,Q.memo)(function({personal:e=!1,placeholder:t,nextTurnSuggestionsEnabled:n=!1,disabled:r,sendDisabled:i=!1,sending:a,streaming:o,conversationId:s,composerContext:c,pageContextPreview:u,contextRefs:d,setContextRefs:f,onDraftAttachmentsChange:p,thinkingLevel:g,modelSupportsThinking:_,onThinkingChange:v,onSend:b,onPersonalSendDispatched:x,onAbort:S,onAddPendingFollowUp:C,onSteeringInterrupt:w,pendingFollowUps:T,editingFollowUpId:E,onBeginEditFollowUp:D,onCancelEditFollowUp:O,onCommitEditFollowUp:k,onPendingFollowUpRemove:A,onPendingFollowUpMove:j,onPendingFollowUpReorder:M,onPendingFollowUpSteer:N,onPendingFollowUpSend:P,steeringFollowUpId:F,welcomeDraftSeed:I,welcomeSuggestion:L,onAcceptWelcomeSuggestion:R,sessionModel:z,showModelSelector:B,onModelChange:V,modelDisabled:H,onChatAgentChange:U,currentAgentId:W,voiceAgentName:G,voiceTaskId:ee,voiceMode:te,prepareVoiceSession:ne,prepareContextSession:re,unboundDraftKey:ie,getDraftHandoffTarget:ae,editingUserTurnId:oe,composerMode:se,inputControl:ce,onResumeQueue:le,onRestoreEditor:ue,onReacquireEdit:K,onCancelUserMessageEdit:q}){let de=ba(),fe=(0,Q.useRef)(!1);r||=de.conversationId===s&&de.active;let pe=h(e=>e.language),J=y(pe),[me,he]=l();(0,Q.useEffect)(()=>{bo()},[]);let ge=(...e)=>{if(i)return!1;let t=b(...e);return t instanceof Promise?t.then(t=>(t!==!1&&at.submitted(e[0]),t)):(t!==!1&&at.submitted(e[0]),t)},_e=(0,Q.useRef)(!1),ve=(0,Q.useRef)(null),ye=(0,Q.useRef)(null),be=(0,Q.useRef)(null),xe=(0,Q.useRef)(!1),[Se,Ce]=(0,Q.useState)(!1),[we,Te]=(0,Q.useState)(null),[Ee,De]=(0,Q.useState)(null),[Oe,Ae]=(0,Q.useState)(!1),je=(0,Q.useRef)(ge),Me=(0,Q.useRef)(g);je.current=ge,Me.current=g,(0,Q.useEffect)(()=>{if(!s||Ee===s){Te(null);return}let e=!1;return wr(s).then(e=>e?null:wo(s)).then(t=>{e||Te(t&&t.required&&!t.trusted&&t.decision===null?t:null)}).catch(()=>{e||Te(null)}),()=>{e=!0}},[s,Ee]);let Ne=(0,Q.useCallback)(()=>{!s||Oe||(Ae(!0),go(s,!0).then(()=>{Te(null)}).catch(e=>{ya(`error`,J.chat.commandPalette.workspaceTrustFailed,{error:e instanceof Error?e.message:String(e)})}).finally(()=>Ae(!1)))},[J.chat.commandPalette,s,Oe]),Pe=$r({conversationId:s??`new`,chat:J.chat,onAttachmentsChange:e=>p?.(e.map((e,t)=>({id:e.uri||e.id||`draft:${t}:${e.name}`,title:e.name})))}),Fe=(0,Q.useRef)(d);Fe.current=d;let Ie=(0,Q.useCallback)(e=>{let t=d.find(t=>t.refId===e);return t?{title:t.title,kind:t.kind,fileKind:t.fileKind}:void 0},[d]),Le=(0,Q.useCallback)(e=>{let t=e?.contextRefs??[];if(Fe.current=t,f(t),e?.attachments){Pe.setAttachments(e.attachments.map(rD));return}Pe.clearAttachments()},[Pe.clearAttachments,Pe.setAttachments,f]),Re=(0,Q.useCallback)(e=>{let t=Fe.current,n=t.find(t=>t.kind===e.kind&&t.sourceId===e.sourceId);if(n){if(n.refId)return n;let r={...n,refId:e.refId},i=t.map(e=>e===n?r:e);return Fe.current=i,f(i),r}if(t.length>=5)return ya(`warning`,J.chat.commandPalette.contextLimitReached,{max:5}),null;let r=[...t,e];return Fe.current=r,f(r),e},[J.chat.commandPalette.contextLimitReached,f]);(0,Q.useEffect)(()=>{let e=e=>{let t=e.detail;t?.conversationId!==s||t.reference.kind!==`result`||Re(t.reference)};return window.addEventListener(`chat-result-reference`,e),()=>window.removeEventListener(`chat-result-reference`,e)},[s,Re]);let ze=(0,Q.useCallback)(e=>{let t=e.availability.status===`agent-denied`?J.chat.commandPalette.skillAgentDeniedReason:J.chat.commandPalette.skillDisabledReason,n=em(J.chat.commandPalette.skillUnavailableMessage,{name:e.name,agent:W||`main`,reason:t});if(e.availability.status===`agent-denied`&&window.confirm(`${n}\n\n${J.chat.commandPalette.skillAddToAllowlistConfirm}`)){To(W,e.canonicalName,s).catch(e=>{window.alert(e instanceof Error?e.message:String(e))});return}window.alert(n)},[W,J.chat.commandPalette,s]),Be=Xp({capabilities:e?tp:ep,disabled:r,agentId:W,conversationId:s,autoFocusKey:s,welcomeDraftSeed:I,onExternalTextReplace:Le,shouldSyncSelectionRef:_e,resolveContextRef:Ie}),Ve=me.get(`attachmentHandoff`);(0,Q.useEffect)(()=>{if(!Ve)return;let e=ke(Ve);he(e=>{let t=new URLSearchParams(e);return t.delete(`attachmentHandoff`),t},{replace:!0}),e&&Pe.processFiles([e]).then(()=>Be.editorRef.current?.focus({preventScroll:!0}))},[Ve,Pe.processFiles,Be.editorRef,s,he]);let{onUserTextCommitted:He,onWireInputClearWalk:Ue,tryInputHistoryArrow:We}=pE({conversationId:s,editorRef:Be.editorRef,valueRef:Be.valueRef,resetEditor:Be.resetEditor,onWireInput:Be.onWireInput}),Ge=(0,Q.useCallback)((e,t)=>{Ue(e,t);let n=Wn(e),r=new Set(n?gn(n):[]),i=Fe.current,a=i.filter(e=>!e.refId||r.has(e.refId));a.length!==i.length&&(Fe.current=a,f(a))},[Ue,f]),Ke=Pf(s??``),qe=a||o||Ke||ce?.phase===`running`||ce?.phase===`stopping`;xe.current=qe;let Je=(0,Q.useCallback)(()=>{xe.current||Ce(!0)},[]),Ye=(0,Q.useCallback)(e=>{wT(je.current(e,void 0,Me.current,d),t=>{He?.(e,t),f([])})},[d,He,f]),Xe=KE({capabilities:e?tp:ep,conversationId:s,editorValue:Be.value,editorCursor:Be.cursor,isComposing:Be.isComposing,runBusy:qe,thinkingLevel:g,editorRef:Be.editorRef,valueRef:Be.valueRef,resetEditor:Be.resetEditor,clearAttachments:Pe.clearAttachments,onSend:ge,onUserTextCommitted:He,onChatAgentChange:U,currentAgentId:W,prepareSession:re,contextRefs:d,onAddContextRef:Re,onUnavailableSkill:ze,onReviewLauncher:Je,onAddPendingFollowUp:C,onAbort:S,pendingFollowUpsCount:T.length,maxPendingFollowUps:10,clearContextRefs:()=>f([]),commandPalettePanelRef:ve});_e.current=Xe.shouldSyncSelection;let Ze=_a({disabled:r||de.active,chat:J.chat,onTranscript:e=>{let t=Be.valueRef.current,n=Di(t,e);Be.resetEditor({nextText:n,caretOffset:n.length,focus:!0})}}),{phase:Qe,voiceActive:$e,startVoiceInput:et,cancelVoiceInput:tt,confirmVoiceInput:nt}=Ze;(0,Q.useEffect)(()=>{let e=e=>{if(!$w(e,{disabled:r,editorHidden:$e&&Qe!==`error`}))return;let t=Vp(e.clipboardData);t&&(e.preventDefault(),Be.focusForExternalPaste(),Hp(t,{processFiles:Pe.processFiles,processPastedText:Pe.processPastedText,insertText:e=>document.execCommand(`insertText`,!1,e),onUnsupportedFiles:()=>ya(`warning`,J.chat.clipboardFileTypeUnsupported)}))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[Pe.processFiles,Pe.processPastedText,r,Be.focusForExternalPaste,J.chat.clipboardFileTypeUnsupported,$e,Qe]),(0,Q.useEffect)(()=>{let e=e=>{let t=e?.detail?.target;if(!(t&&t!==`chat`)&&(e?.preventDefault(),!r)){if(Qe===`recording`){nt();return}(Qe===`idle`||Qe===`error`)&&(Be.editorRef.current?.focus({preventScroll:!0}),et())}},t=e=>{let t=e.detail?.target;t&&t!==`chat`||!$e||(e.preventDefault(),tt(),Be.editorRef.current?.focus({preventScroll:!0}))};window.addEventListener(ko,e),window.addEventListener(Do,t);let n=window.setTimeout(()=>{if(Ao()){if(r){Oo();return}e()}},0);return()=>{window.clearTimeout(n),window.removeEventListener(ko,e),window.removeEventListener(Do,t)}},[tt,nt,r,Be.editorRef,et,$e,Qe]);let rt=(0,Q.useCallback)(()=>{be.current=null},[]),it=n&&!r&&!i&&!qe&&!E&&!oe&&!Ze.voiceActive&&!Be.isComposing&&Be.value.length===0&&Pe.attachments.length===0&&d.length===0&&T.length===0,at=SE({conversationId:s,agentId:W,modelKey:z,locale:pe,enabled:n,draftText:Be.value,canShow:it}),ot=()=>{if(!it||Be.valueRef.current.length>0||Fe.current.length>0)return!1;let e=at.accept();return e?(Be.resetEditor({nextText:e,focus:!0}),!0):!1};(0,Q.useEffect)(()=>{it&&at.suggestion&&!Xe.palette.open&&at.shown()},[it,at.suggestion,at.shown,Xe.palette.open]);let st=m(e=>e.conversationId),ct=(0,Q.useMemo)(()=>({gatewayIdentity:st,conversationId:s,unboundDraftKey:ie}),[st,s,ie]),lt=(0,Q.useRef)(new Map),ut=(0,Q.useRef)(`compose`),dt=se??(E?{kind:`editFollowUp`,inputId:E,version:0}:{kind:`compose`}),ft=dt.kind===`editTurn`?`turn:${dt.turnId}`:dt.kind===`editFollowUp`?`input:${dt.inputId}`:`compose`;(0,Q.useLayoutEffect)(()=>{lt.current.clear(),ut.current=`compose`},[ct]),xE(s,Be,Pe,d,f,{snapshot:()=>({mode:dt,drafts:Object.fromEntries(lt.current)}),restore:e=>{lt.current=new Map(Object.entries(e.drafts)),ut.current=e.mode.kind===`editTurn`?`turn:${e.mode.turnId}`:e.mode.kind===`editFollowUp`?`input:${e.mode.inputId}`:`compose`,ue?.(e.mode)}},ie,ae);let pt=dt.kind!==`compose`&&!!(ce&&!ce.paused),mt=gE({personal:e,chat:J.chat,runBusy:qe,draftScope:ct,queuePaused:ce?.paused,editingUserTurnId:oe,blocked:r||i||pt||ce?.phase===`stopping`,onFinishUserEdit:q,onFinishFollowUpEdit:O,voiceActive:Ze.voiceActive,cancelVoiceInput:Ze.cancelVoiceInput,editingFollowUpId:E,getTextValue:()=>Be.valueRef.current,getAttachmentCount:()=>Pe.attachmentsRef.current.length,wireAttachmentsPayload:Pe.wireAttachmentsPayload,getContextRefs:()=>d,getThinkingLevel:()=>Me.current,onSend:ge,onDispatched:e&&x?(e,t)=>{let n=Be.editorRef.current?.getBoundingClientRect();n&&x(e,n,t)}:void 0,onAddPendingFollowUp:C,onSteeringInterrupt:w,onCommitEditFollowUp:k,onPendingFollowUpRemove:A,pendingFollowUpsCount:T.length,firstPendingFollowUpId:T[0]?.id,onSteerPendingFollowUp:N,steeringPending:!!F,resetEditor:()=>{Be.resetEditor()},clearAttachments:Pe.clearAttachments,clearContextRefs:()=>f([]),clearEditFollowUpRef:rt,onUserTextCommitted:He}),ht=(0,Q.useCallback)((e=!1)=>mt.flushSteeringDraft(e),[mt.flushSteeringDraft]),gt=(0,Q.useCallback)((e,t)=>{!s||s===`new`||bw.getState().requestCreate(s,[{id:e.id,type:`text`,text:t,label:J.chat.followUpQueueHeading}])},[s,J.chat.followUpQueueHeading]);(0,Q.useLayoutEffect)(()=>{if(ut.current===ft)return;lt.current.set(ut.current,{text:Be.valueRef.current,attachments:Pe.wireAttachmentsPayload(),contextRefs:Fe.current,thinkingLevel:Me.current}),ut.current=ft;let e=dt.kind===`editFollowUp`?T.find(e=>e.id===dt.inputId):void 0;e?.thinkingLevel&&_&&v(e.thinkingLevel);let t=(dt.kind===`compose`?dt.draft:void 0)??lt.current.get(ft)??(dt.kind===`editTurn`?dt.draft:e?{text:e.text,attachments:e.attachments??[],contextRefs:e.contextRefs??[]}:void 0);t?.thinkingLevel&&_&&v(t.thinkingLevel),Pe.setAttachments(gT(t?.attachments??[])),f(t?.contextRefs??[]),Be.resetEditor({nextText:t?.text??``,focus:!0})},[ft,dt,T,Pe,Be,f]);let _t=(0,Q.useCallback)(e=>{D(e)},[D]),vt=(0,Q.useRef)({});vt.current={adapters:Xe.adapters,send:mt.send,runBusy:qe,pendingFollowUpsCount:T.length,flushSteeringDraft:ht,steerDraft:()=>mt.flushSteeringDraft(!1,`steer`),steerCurrentReply:mt.steerCurrentReply,interruptDraft:mt.interruptDraft,editingFollowUpId:E,editingUserTurnId:oe,onCancelUserMessageEdit:q,onCancelEditFollowUp:O,attachmentsLen:Pe.attachments.length,contextRefsLen:d.length,isComposing:Be.isComposing,valueRef:Be.valueRef,adjustHeight:Be.adjustHeight,editorRef:Be.editorRef,tryInputHistoryArrow:We,acceptEmptySuggestion:at.suggestion&&it?ot:!qe&&!r&&!i&&!oe&&!Ze.voiceActive&&L&&R?()=>(R(L),!0):void 0,dismissEmptySuggestion:at.suggestion?at.dismiss:void 0};let yt=qe&&!E&&!oe,bt={...J.chat,sendMessage:E?J.chat.followUpSaveEdit:oe?J.chat.userMessageReplaceSend:ce?.paused?J.chat.sendThisMessage:J.chat.sendMessage},xt=!!Be.value.trim()||Pe.attachments.length>0||d.length>0,St=!yt||!!F||ce?.phase===`stopping`||!xt&&T.length===0,Ct=xt&&!!w,wt=Xo(`(hover: hover) and (pointer: fine)`),Tt=!yt&&!E&&L?`${L.prompt}${wt?` · ${J.chat.welcomeSpotlight.acceptSuggestionHint}`:``}`:null;return(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 w-full flex-col`,children:[s?(0,Z.jsx)(Yw,{conversationId:s},s):null,c?(0,Z.jsx)(cT,{...c,conversationId:s,disabled:(c.disabled??r)||a||o}):null,(0,Z.jsxs)($p,{className:e?`rounded-[1.65rem]`:void 0,dragging:Pe.isDragging,onDragOver:e=>{(e.dataTransfer?.types.includes(`Files`)||Wf(e.dataTransfer))&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,Pe.setIsDragging(!0))},onDragLeave:e=>{e.relatedTarget===null&&Pe.setIsDragging(!1)},onDrop:async e=>{e.preventDefault(),Pe.setIsDragging(!1);let t=e.dataTransfer?.files;if(t?.length){await Pe.processFiles(Array.from(t));return}let n=Gf(e.dataTransfer);if(n)try{let e=await Ra(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 Pe.processFiles([new File([e],n.name,{type:r})])}catch{ya(`error`,J.chat.attachmentLoadFailed,{name:n.name})}},children:[Pe.isDragging?(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-10 flex items-center justify-center rounded-xl bg-accent-soft/80 text-sm font-medium text-accent-fg backdrop-blur-[1px]`,children:J.chat.dropFiles}):null,oe?(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-edge-subtle bg-accent-soft/40 px-4 py-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:J.chat.userMessageEditing}),(0,Z.jsx)(`button`,{type:`button`,className:`font-medium text-accent-fg hover:underline`,onClick:q,children:J.chat.userMessageEditCancel})]}):null,pt&&(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge-subtle px-4 py-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:J.chat.editQueueResumed}),(0,Z.jsx)(`button`,{type:`button`,disabled:r||i,className:`text-accent-fg disabled:opacity-40`,onClick:()=>K?.({text:Be.valueRef.current,attachments:Pe.wireAttachmentsPayload(),contextRefs:Fe.current}),children:J.chat.editPauseAgain})]}),ce?.paused&&(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge-subtle px-4 py-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:ce.phase===`stopping`?J.chat.inputStopping:ce.reviewRequired?J.chat.queueReviewRequired:J.chat.queuePaused}),(0,Z.jsx)(`button`,{type:`button`,disabled:r||i||!!(E||oe)||ce.phase!==`idle`,className:`text-accent-fg disabled:opacity-40`,onClick:le,children:J.chat.queueResume})]}),(0,Z.jsx)(aT,{conversationId:s}),T.length>0?(0,Z.jsx)(`div`,{className:`max-h-[min(30vh,11rem)] shrink-0 overflow-y-auto overflow-x-hidden border-b border-edge-subtle/80 [scrollbar-gutter:stable] dark:border-edge-subtle/70`,children:(0,Z.jsx)(iT,{items:T,disabled:r||i||!!(oe||E),editingFollowUpId:E,onEditInComposer:_t,onRemove:A,onMove:j,onReorder:M,onSteer:N,onSendSingle:P,queuePaused:ce?.paused,queueIdle:ce?.phase===`idle`,steeringBusyId:F,onOpenSideChat:s&&s!==`new`?gt:void 0})}):null,(E||oe)&&(0,Z.jsx)(`div`,{className:`flex items-center justify-end px-4 py-1 text-xs`,children:(0,Z.jsx)(`button`,{type:`button`,disabled:i,className:`text-accent-fg disabled:opacity-40`,onClick:()=>ue?.({kind:`compose`,draft:{text:Be.valueRef.current,attachments:Pe.wireAttachmentsPayload(),contextRefs:Fe.current}}),children:J.chat.editAsNewMessage})}),dt.kind===`editFollowUp`&&T.some(e=>e.id===dt.inputId&&e.version!==dt.version)&&(0,Z.jsxs)(`div`,{className:`border-b border-edge-subtle px-4 py-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`p`,{children:J.chat.followUpEditConflict}),(0,Z.jsx)(`p`,{className:`my-1 max-h-20 overflow-auto whitespace-pre-wrap`,children:T.find(e=>e.id===dt.inputId)?.text}),(0,Z.jsx)(`button`,{type:`button`,disabled:i,className:`text-accent-fg`,onClick:()=>D(dt.inputId),children:J.chat.followUpKeepMyEdit})]}),E?(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-4 py-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:J.chat.inputPlaceholderSteeringEdit}),(0,Z.jsx)(`button`,{type:`button`,onClick:O,className:`shrink-0 rounded px-1 text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:J.chat.userMessageEditCancel})]}):null,(0,Z.jsx)(Yr,{attachments:Pe.attachments,conversationId:s,topPadded:T.length>0,onRemove:Pe.removeAttachment}),(0,Z.jsx)(oT,{refs:d.filter(e=>!e.refId),label:J.chat.commandPalette.contextLabel,onRemove:e=>f(t=>t.filter(t=>t.sourceId!==e))}),u,(0,Z.jsxs)(`div`,{className:e?`flex min-h-0 shrink-0 items-end gap-1 px-1.5 py-1.5 sm:px-2`:`flex min-h-0 shrink-0 flex-col`,children:[(0,Z.jsx)(`input`,{ref:ye,type:`file`,multiple:!0,className:`hidden`,onChange:async e=>{let t=e.target.files;t&&await Pe.processFiles(Array.from(t)),e.target.value=``}}),e&&!Ze.voiceActive&&(0,Z.jsx)(mT,{disabled:r||i,attachmentCount:Pe.attachments.length,maxAttachments:10,chat:J.chat,onPickFiles:()=>ye.current?.click()}),(0,Z.jsxs)(`div`,{className:e?`relative min-w-0 flex-1 px-1`:Y(`relative px-3 pb-0 pt-1 sm:px-4`,Pe.attachments.length>0&&`pt-2`),children:[(0,Z.jsx)(CT,{open:Xe.atPicker.open,anchorRef:Be.editorRef,items:Xe.atPicker.items,selectedIndex:Xe.atPicker.selectedIndex,loading:Xe.atPicker.loading,query:Xe.atPicker.query,noResults:Xe.atPicker.error??J.chat.atMention.noResults,conversationId:s,recentLabel:J.chat.atMention.recentBadge,sectionLabels:{file:J.chat.atMention.files,note:J.chat.atMention.notes,session:J.chat.atMention.chats,skill:J.chat.atMention.skills,agent:J.chat.atMention.agents,browser_tab:J.chat.atMention.browserTabs},ariaLabel:J.chat.atMention.placeholder,onSelectItem:Xe.applyAtMention}),(0,Z.jsx)(eE,{open:Xe.palette.open,anchorRef:Be.editorRef,panelRef:ve,sections:Xe.palette.loadError?[]:Xe.palette.sections,flatItems:Xe.palette.loadError?[]:Xe.palette.flatItems,loading:Xe.palette.loading,failedKinds:Xe.palette.failedKinds,selectedIndex:Xe.palette.selectedIndex,noResults:Xe.palette.loadError??J.chat.commandPalette.noResults,sectionLoadFailedLabel:J.chat.commandPalette.sectionLoadFailed,query:Xe.palette.query,skillsLabel:J.chat.commandPalette.skillsSection,commandsLabel:J.chat.commandPalette.commandsSection,agentsLabel:J.chat.commandPalette.agentsSection,currentAgentId:W,currentBadgeLabel:J.chat.commandPalette.currentBadge,runBusy:qe,pendingFollowUpsCount:T.length,maxPendingFollowUps:10,queueBadgeLabel:J.chat.commandPalette.queueBadge,queueFullBadgeLabel:J.chat.commandPalette.queueFullBadge,queueFullTooltip:J.chat.commandPalette.queueFullTooltip,skillUnavailableLabel:J.chat.commandPalette.skillUnavailableBadge,skillAgentDeniedLabel:J.chat.commandPalette.skillAgentDeniedBadge,skillSourceLabels:{builtin:J.chat.commandPalette.sourceBuiltin,workspace:J.chat.commandPalette.sourceWorkspace,global:J.chat.commandPalette.sourceGlobal,extra:J.chat.commandPalette.sourceExtra},onSelectItem:Xe.applyPalette}),Ze.voiceActive?(0,Z.jsx)(Mi,{phase:Ze.phase,elapsedLabel:Ze.elapsedLabel,recordedDictation:Ze.recordedDictation,audioLevel:Ze.audioLevel,partialTranscript:Ze.partialTranscript,finalTranscript:Ze.finalTranscript,error:Ze.error,settingsRequired:Ze.settingsRequired,disabled:r,chat:J.chat,onCancel:Ze.cancelVoiceInput,onConfirm:Ze.confirmVoiceInput,onRetry:Ze.retryVoiceInput}):null,(0,Z.jsx)(Zp,{editorRef:Be.editorRef,disabled:r,hidden:Ze.voiceActive&&Ze.phase!==`error`,compact:e,ariaLabel:t??J.chat.inputPlaceholder,placeholder:(it&&at.suggestion?`${at.suggestion.prompt}${wt?` · ${J.chat.welcomeSpotlight.acceptSuggestionHint}`:``}`:null)??t??Tt??(yt?E?J.chat.inputPlaceholderSteeringEdit:e?J.chat.inputPlaceholderImmediate:J.chat.inputPlaceholderSteering:J.chat.inputPlaceholder),onWireInput:Ge,adjustHeight:Be.adjustHeight,processFiles:Pe.processFiles,processPastedText:Pe.processPastedText,setIsComposing:Be.setIsComposing,kbdRef:vt,chatMessages:J.chat})]}),e?(0,Z.jsx)(hT,{disabled:r||i||pt,voiceActive:Ze.voiceActive,runBusy:yt,hasDraft:xt,chat:bt,onStartVoiceInput:Ze.startVoiceInput,onSend:mt.send,onQueue:C?mt.send:void 0,onDefer:C?()=>mt.flushSteeringDraft(!1):void 0,onAbort:S,onInterrupt:mt.interruptDraft,onSteer:mt.steerCurrentReply,steerDisabled:St}):(0,Z.jsx)(im,{disabled:r,sendDisabled:i||pt,sending:a,streaming:o,runBusy:yt,chat:bt,hasDraft:xt,showSteeringInterrupt:Ct,attachmentCount:Pe.attachments.length,maxAttachments:10,onPickFiles:()=>ye.current?.click(),thinkingLevel:g,onThinkingChange:v,voiceActive:Ze.voiceActive,onStartVoiceInput:Ze.startVoiceInput,voiceConversationEnabled:!!(s||ne),onStartVoiceConversation:()=>{if(!fe.current){if(s){de.open({conversationId:s,name:G||W||`xopc`,taskId:ee,mode:te});return}ne&&(fe.current=!0,ne().then(e=>{if(e)return de.open({conversationId:e,name:G||W||`xopc`,taskId:ee,mode:te})}).catch(e=>ya(`error`,e instanceof Error?e.message:J.chat.callFailed)).finally(()=>{fe.current=!1}))}},onSend:mt.send,onAbort:S,onInterrupt:mt.interruptDraft,sessionModel:z,showModelSelector:B,onModelChange:V,modelDisabled:H})]}),(0,Z.jsx)(tD,{open:Se,conversationId:s,disabled:r||yt,chat:J.chat,onClose:()=>Ce(!1),onSendCommand:Ye}),(0,Z.jsx)(La,{open:we!==null,title:J.chat.commandPalette.workspaceTrustTitle,description:em(J.chat.commandPalette.workspaceTrustDescription,{path:we?.workspacePath??``}),confirmLabel:Oe?J.chat.commandPalette.workspaceTrustSaving:J.chat.commandPalette.workspaceTrustConfirm,cancelLabel:J.chat.commandPalette.workspaceTrustCancel,onConfirm:Ne,onCancel:()=>{Te(null),De(s)}})]})]})});function aD(e){let t=(0,X.c)(42),{draft:n,onRemove:r,disabled:i,waiting:a}=e,o=i!==void 0&&i,s=a!==void 0&&a,c=h(sD),l;t[0]===c?l=t[1]:(l=y(c),t[0]=c,t[1]=l);let u=l.chat.pageContext,d=u.label,f;t[2]!==n.title||t[3]!==u.preview?(f=(0,Z.jsxs)(`summary`,{className:`cursor-pointer break-words rounded text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[u.preview,`: `,n.title]}),t[2]=n.title,t[3]=u.preview,t[4]=f):f=t[4];let p;t[5]===u.frozen?p=t[6]:(p=(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:u.frozen}),t[5]=u.frozen,t[6]=p);let m;t[7]===n.envelope.resourceRefs?m=t[8]:(m=n.envelope.resourceRefs.map(oD).join(`, `),t[7]=n.envelope.resourceRefs,t[8]=m);let g;t[9]===m?g=t[10]:(g=(0,Z.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:m}),t[9]=m,t[10]=g);let _;t[11]===n.preview?_=t[12]:(_=(0,Z.jsx)(`pre`,{className:`mt-2 max-h-48 overflow-y-auto whitespace-pre-wrap break-words font-sans text-sm text-fg`,children:n.preview}),t[11]=n.preview,t[12]=_);let v;t[13]!==n.truncated||t[14]!==u.truncated?(v=n.truncated?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:u.truncated}):null,t[13]=n.truncated,t[14]=u.truncated,t[15]=v):v=t[15];let b;t[16]!==n.envelope.selection||t[17]!==u.draft||t[18]!==u.selection?(b=n.envelope.selection?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`mt-2 text-xs font-medium text-fg`,children:n.envelope.selection.draft?u.draft:u.selection}),(0,Z.jsx)(`pre`,{className:`mt-1 max-h-36 overflow-y-auto whitespace-pre-wrap break-words font-sans text-sm text-fg`,children:n.envelope.selection.text})]}):null,t[16]=n.envelope.selection,t[17]=u.draft,t[18]=u.selection,t[19]=b):b=t[19];let x;t[20]!==v||t[21]!==b||t[22]!==f||t[23]!==p||t[24]!==g||t[25]!==_?(x=(0,Z.jsxs)(`details`,{className:`min-w-0 flex-1`,children:[f,p,g,_,v,b]}),t[20]=v,t[21]=b,t[22]=f,t[23]=p,t[24]=g,t[25]=_,t[26]=x):x=t[26];let S=`${u.remove}: ${n.title}`,C;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Z.jsx)(Gt,{className:`size-4`,"aria-hidden":!0}),t[27]=C):C=t[27];let w;t[28]!==o||t[29]!==r||t[30]!==S?(w=(0,Z.jsx)(`button`,{type:`button`,onClick:r,disabled:o,"aria-label":S,className:`inline-flex size-8 shrink-0 items-center justify-center rounded text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:C}),t[28]=o,t[29]=r,t[30]=S,t[31]=w):w=t[31];let T;t[32]!==x||t[33]!==w?(T=(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[x,w]}),t[32]=x,t[33]=w,t[34]=T):T=t[34];let E;t[35]!==u.pending||t[36]!==s?(E=s?(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,role:`status`,children:u.pending}):null,t[35]=u.pending,t[36]=s,t[37]=E):E=t[37];let D;return t[38]!==u.label||t[39]!==T||t[40]!==E?(D=(0,Z.jsxs)(`section`,{className:`mx-4 mt-2 min-w-0 rounded-lg border border-edge bg-surface-hover p-3`,"aria-label":d,children:[T,E]}),t[38]=u.label,t[39]=T,t[40]=E,t[41]=D):D=t[41],D}function oD(e){return`${e.kind} · ${e.id} · v${e.revision}`}function sD(e){return e.language}function cD(e){let t=(0,X.c)(30),{selection:n}=e,r=h(lD)===`zh`,{mode:i,options:a,checking:o,checkFailed:s,failure:c,busy:l,changeMode:u,retry:d}=n,f=s?r?`无法检查运行环境,请重试。`:`Could not check the environment. Retry.`:a?.worktreeUnavailableReason===`workspace_unavailable`?r?`项目目录不可用,请在项目设置中检查路径。`:`Project directory unavailable. Check its path in project settings.`:null;if(!s&&a?.worktreeUnavailableReason===`git_commit_required`){let e;return t[0]===c?e=t[1]:(e=c?(0,Z.jsx)(`p`,{role:`alert`,className:`w-full px-2 py-1 text-xs text-danger`,children:c}):null,t[0]=c,t[1]=e),e}let p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(We,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[2]=p):p=t[2];let m=p,g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsx)(Ss,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[3]=g):g=t[3];let _=g,v=r?`运行位置`:`Work in`,y;t[4]!==l||t[5]!==u||t[6]!==s||t[7]!==v||t[8]!==i||t[9]!==a||t[10]!==r?(y=!a&&!s?(0,Z.jsx)(qt,{className:`h-8 w-36 rounded-full`}):(0,Z.jsx)(ue,{ariaLabel:r?`新会话运行位置`:`New session environment`,placeholder:v,title:r?`Local 指 xopc Gateway 所在机器;首次发送时创建所选环境。`:`Local means the machine running xopc Gateway. The selected environment is created on first send.`,triggerIcon:l?(0,Z.jsx)(Je,{className:`size-4 shrink-0 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}):i===`managed_worktree`?_:m,triggerClassName:`h-8 w-auto max-w-full justify-start gap-1.5 rounded-full border-0 bg-surface-hover px-2.5 hover:bg-surface-active [&>svg:last-child]:hidden`,contentClassName:`xopc-composer-config-popover w-max min-w-0 max-w-[calc(100vw-1.5rem)]`,side:`top`,allowEmpty:!1,value:i,disabled:l||s,options:[{value:`local_checkout`,label:`Local`,icon:m,group:v,disabled:!a?.localAvailable},{value:`managed_worktree`,label:`New local worktree`,icon:_,group:v,disabled:!a||!!a.worktreeUnavailableReason}],onChange:e=>u(e)}),t[4]=l,t[5]=u,t[6]=s,t[7]=v,t[8]=i,t[9]=a,t[10]=r,t[11]=y):y=t[11];let b;t[12]!==l||t[13]!==o||t[14]!==c||t[15]!==i||t[16]!==a?.worktreeUnavailableReason||t[17]!==f||t[18]!==d||t[19]!==r?(b=f||c||i===`managed_worktree`&&a?.worktreeUnavailableReason?(0,Z.jsx)(pi,{variant:`ghost`,className:`size-8 rounded-full p-0`,disabled:l||o,onClick:d,"aria-label":r?`重新检查环境`:`Recheck environment`,children:(0,Z.jsx)(At,{className:`size-3.5 `+(o?`animate-spin motion-reduce:animate-none`:``),"aria-hidden":!0})}):null,t[12]=l,t[13]=o,t[14]=c,t[15]=i,t[16]=a?.worktreeUnavailableReason,t[17]=f,t[18]=d,t[19]=r,t[20]=b):b=t[20];let x;t[21]===f?x=t[22]:(x=f?(0,Z.jsx)(`p`,{role:`status`,className:`w-full px-2 py-1 text-xs leading-5 text-fg-muted`,children:f}):null,t[21]=f,t[22]=x);let S;t[23]===c?S=t[24]:(S=c?(0,Z.jsx)(`p`,{role:`alert`,className:`max-h-20 w-full overflow-y-auto break-words px-2 py-1 text-xs leading-5 text-danger`,children:c}):null,t[23]=c,t[24]=S);let C;return t[25]!==y||t[26]!==b||t[27]!==x||t[28]!==S?(C=(0,Z.jsxs)(Z.Fragment,{children:[y,b,x,S]}),t[25]=y,t[26]=b,t[27]=x,t[28]=S,t[29]=C):C=t[29],C}function lD(e){return e.language}function uD({preparation:e,conversationId:t,ready:n,onSend:r}){let i=m(e=>e.conversationId),a=m(e=>e.baseUrl),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(null),f=(0,Q.useRef)(null),h=(0,Q.useRef)(!1),_=(0,Q.useRef)(r);_.current=r;let v=(0,Q.useRef)(t);v.current=t;let{data:y,error:b,isValidating:x,mutate:S}=Gr(e?[`project-environment-options`,a,i,e.project.id]:null,async()=>(await g(p(`/api/projects/${encodeURIComponent(e.project.id)}/environment-options`))).options,{keepPreviousData:!1,revalidateOnFocus:!1,shouldRetryOnError:!1}),C=y?.localAvailable&&y.worktreeUnavailableReason!==`git_commit_required`&&y.worktreeUnavailableReason!==`workspace_unavailable`?o?.preparation===e?o.mode:e?zr(Hr(),e.project.id)??`local_checkout`:`local_checkout`:`local_checkout`,w=!!(!b&&y?.localAvailable&&(C===`local_checkout`||!y.worktreeUnavailableReason)),T=(0,Q.useCallback)(e=>{let t=f.current;f.current=null,d(null),t?.resolve(e?t.conversationId:null)},[]),E=(0,Q.useCallback)(()=>{let e=f.current,t=m.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;Ir(e.project.id,C);let n={...s,conversationId:t};f.current=n,d(n)}).catch(t=>{f.current===s&&(l({preparation:e,message:t instanceof Error?t.message:String(t)}),S(),T(!1))}),o},[w,a,T,x,C,S,e,t,i]);return{mode:C,options:y,checking:x,checkFailed:!!b,allowed:w,busy:!!(u&&(u.preparation===e||u.conversationId&&u.conversationId===t)),failure:c?.preparation===e?c.message:null,changeMode:t=>{!e||f.current||(s({preparation:e,mode:t}),l(null))},retry:()=>void S(),getDraftHandoffTarget:E,prepareSession:D,send:async(...n)=>{let r=t;if(e){if(h.current)return!1;h.current=!0;try{let e=await D();if(!e)return!1;r=e,n[2]=void 0}finally{h.current=!1}}return!r||v.current!==r?!1:await _.current(...n)!==!1&&{conversationId:r}}}}function dD(e,t){let n=(0,X.c)(12),r=m(pD),i=m(fD),a;n[0]===e?a=n[1]:(a=t=>e?t.sessions[e]?.localDraft:void 0,n[0]=e,n[1]=a);let o=Nn(a),s;n[2]!==i||n[3]!==e||n[4]!==t||n[5]!==o||n[6]!==r?(s=e||t?[`chat-project-scope`,i,r,e,t,o===!0?`draft`:o===!1?`persisted`:`unknown`]:null,n[2]=i,n[3]=e,n[4]=t,n[5]=o,n[6]=r,n[7]=s):s=n[7];let c;n[8]!==e||n[9]!==t?(c=async()=>{let n=e?await wr(e):void 0,r=n?n.creation.projectId:e?(await un(e)).projectId:t;return r?sn(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}=Gr(s,c,l);return d?null:u??null}function fD(e){return e.baseUrl}function pD(e){return e.conversationId}function mD(e,t){let n=qo(e,t),r=Jo(e,t);return`${e.id} ${n} ${r}`.toLowerCase()}function hD(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=mD(e,n);return i.every(e=>t.includes(e))})}function gD(e){let t=(0,X.c)(57),{items:n,value:r,disabled:i,placeholder:a,searchPlaceholder:o,noMatches:s,compact:c,contentSide:l,contentAlign:u,className:d,onChange:f}=e,p=l===void 0?`bottom`:l,m=u===void 0?`end`:u,g=h(vD),_;t[0]===g?_=t[1]:(_=y(g),t[0]=g,t[1]=_);let v=_.agentsSettings,[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(``),w;t[2]!==v||t[3]!==n||t[4]!==S?(w=hD(n,S,v),t[2]=v,t[3]=n,t[4]=S,t[5]=w):w=t[5];let T=w,E,D,O;if(t[6]!==v||t[7]!==n||t[8]!==a||t[9]!==r){let e;t[13]===r?e=t[14]:(e=e=>e.id===r,t[13]=r,t[14]=e),D=n.find(e),E=D?qo(D,v):r||a,O=D?[qo(D,v),Jo(D,v)].filter(Boolean).join(` — `):void 0,t[6]=v,t[7]=n,t[8]=a,t[9]=r,t[10]=E,t[11]=D,t[12]=O}else E=t[10],D=t[11],O=t[12];let k=O??a,A=c&&`min-w-0 max-w-[min(calc(15ch+3rem),calc(100vw-8rem))] py-1.5 text-[13px]`,j;t[15]!==d||t[16]!==A?(j=Y(Ca,`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`,ca.transition,`hover:border-edge hover:bg-surface-hover/45`,wa,Sa,`disabled:cursor-not-allowed disabled:opacity-50`,`dark:border-edge-subtle dark:hover:bg-surface-hover/55`,A,d),t[15]=d,t[16]=A,t[17]=j):j=t[17];let M;t[18]!==D?.avatar||t[19]!==r?(M=r?(0,Z.jsx)(Aa,{agentId:r,avatar:D?.avatar,size:28,className:`shrink-0`}):null,t[18]=D?.avatar,t[19]=r,t[20]=M):M=t[20];let N=c?`max-w-[15ch] shrink`:`flex-1`,P;t[21]===N?P=t[22]:(P=Y(`min-w-0 truncate text-left`,N),t[21]=N,t[22]=P);let F;t[23]!==E||t[24]!==P?(F=(0,Z.jsx)(`span`,{className:P,children:E}),t[23]=E,t[24]=P,t[25]=F):F=t[25];let I;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(oe,{className:`size-4 shrink-0 text-fg-subtle opacity-70`,"aria-hidden":!0}),t[26]=I):I=t[26];let L;t[27]!==i||t[28]!==F||t[29]!==k||t[30]!==j||t[31]!==M?(L=(0,Z.jsx)(yi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,disabled:i,title:k,className:j,children:[M,F,I]})}),t[27]=i,t[28]=F,t[29]=k,t[30]=j,t[31]=M,t[32]=L):L=t[32];let R;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(R=Y(ae,`z-50 w-[var(--radix-popover-trigger-width)] min-w-[12rem] rounded-lg border border-edge bg-surface-overlay shadow-md`,ca),t[33]=R):R=t[33];let z;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>C(e.target.value),t[34]=z):z=t[34];let B;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(B=Y(`w-full rounded-md border border-edge bg-surface-panel px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-muted`,wa),t[35]=B):B=t[35];let V;t[36]!==S||t[37]!==o?(V=(0,Z.jsx)(`div`,{className:`shrink-0 border-b border-edge p-2`,children:(0,Z.jsx)(`input`,{type:`search`,value:S,onChange:z,placeholder:o,className:B,"aria-label":o})}),t[36]=S,t[37]=o,t[38]=V):V=t[38];let H;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(H=Y(ce,`max-h-64 p-1`),t[39]=H):H=t[39];let U;t[40]!==v||t[41]!==T||t[42]!==s||t[43]!==f||t[44]!==r?(U=T.length===0?(0,Z.jsx)(`li`,{className:`p-2 text-sm text-fg-muted`,children:s}):T.map(e=>{let t=e.id===r,n=qo(e,v),i=Jo(e,v),a=i.length>0?i:void 0;return(0,Z.jsx)(`li`,{role:`option`,"aria-selected":t,children:(0,Z.jsxs)(`button`,{type:`button`,className:Y(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-fg`,t?`bg-surface-hover`:`hover:bg-surface-hover`),onClick:()=>{f(e.id),x(!1),C(``)},children:[(0,Z.jsx)(Aa,{agentId:e.id,avatar:e.avatar,size:32,className:`shrink-0`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`block truncate font-medium leading-tight`,title:n,children:n}),i?(0,Z.jsx)(`span`,{className:`mt-0.5 block truncate text-xs leading-tight text-fg-muted`,title:a,children:i}):null]}),(0,Z.jsx)(G,{className:Y(`size-4 shrink-0`,t?`opacity-100`:`opacity-0`),"aria-hidden":!0})]})},e.id)}),t[40]=v,t[41]=T,t[42]=s,t[43]=f,t[44]=r,t[45]=U):U=t[45];let W;t[46]===U?W=t[47]:(W=(0,Z.jsx)(`ul`,{"data-select-scroll-region":!0,className:H,role:`listbox`,children:U}),t[46]=U,t[47]=W);let ee;t[48]!==m||t[49]!==p||t[50]!==V||t[51]!==W?(ee=(0,Z.jsx)(hi,{children:(0,Z.jsxs)(gi,{side:p,align:m,sideOffset:4,collisionPadding:8,className:R,onOpenAutoFocus:_D,children:[V,W]})}),t[48]=m,t[49]=p,t[50]=V,t[51]=W,t[52]=ee):ee=t[52];let te;return t[53]!==b||t[54]!==L||t[55]!==ee?(te=(0,Z.jsxs)(_i,{open:b,onOpenChange:x,children:[L,ee]}),t[53]=b,t[54]=L,t[55]=ee,t[56]=te):te=t[56],te}function _D(e){return e.preventDefault()}function vD(e){return e.language}function yD(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 bD(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 xD=`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`,SD=`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 CD({conversationId:e,draftRefs:t=[],draftAttachments:n=[],draftPage:r,project:i,...a}){let[o,s]=(0,Q.useState)(!1),[l,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),[m,g]=(0,Q.useState)(!1),_=bD(h(e=>e.language)),v=c(),y=`${v.pathname}${v.search}`,{data:b,error:x,isLoading:S,isValidating:C,mutate:w}=mf(e,o),T=x?void 0:b,E=T?.work.project??(!e&&i?{id:i.id,title:i.name}:void 0),D=T?.work.task,O=T?.work.delegatedTasks??[],A=yD(T?.sources??[],t,n,r),j=T?.environment,M=!!(E||D||O.length),N=!!T?.unavailableSections.includes(`work`),P=!!T?.unavailableSections.includes(`sources`),F=!!T?.unavailableSections.includes(`environment`),I=[E?.title,D?.title,A.length?`${_.sources} ${A.length}${T?.sourcesHasMore?`+`:``}`:null,j?.kind===`managed_worktree`?`Worktree`:null].filter(Boolean).join(` · `)||_.title,L=()=>s(!1),R=A.some(e=>e.kind===`note`&&!e.unavailable&&e.origins.some(e=>e.kind===`session`)),z=()=>{j?.rootPath&&Ci(j.rootPath).then(e=>{e&&(g(!0),window.setTimeout(()=>g(!1),1200))})},B=()=>(0,Z.jsx)(`button`,{type:`button`,className:SD,"aria-label":_.refresh,disabled:C,onClick:()=>void w(),children:(0,Z.jsx)(At,{className:`size-3.5 ${C?`animate-spin motion-reduce:animate-none`:``}`,"aria-hidden":!0})});return(0,Z.jsxs)(_i,{open:o,onOpenChange:s,children:[(0,Z.jsx)(yi,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,"aria-label":_.title,title:I,className:`group inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-[background-color,color,transform] duration-150 hover:bg-surface-hover hover:text-fg active:scale-95 data-[state=open]:bg-surface-hover data-[state=open]:text-fg motion-reduce:transition-none motion-reduce:transform-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,Z.jsx)(qe,{className:`size-4 transition-transform duration-200 group-data-[state=open]:scale-110 motion-reduce:transform-none motion-reduce:transition-none`,strokeWidth:1.75,"aria-hidden":!0})})}),(0,Z.jsx)(hi,{children:(0,Z.jsx)(gi,{align:`end`,sideOffset:8,collisionPadding:12,"aria-label":_.title,onCloseAutoFocus:e=>{document.activeElement?.closest(`[data-primary-chat-composer]`)&&e.preventDefault()},className:`xopc-session-context-popover z-50 w-[min(23rem,calc(100vw-1.5rem))] rounded-xl border border-edge bg-surface-overlay shadow-popover`,children:(0,Z.jsxs)(`div`,{className:`max-h-[min(30rem,var(--radix-popover-content-available-height))] overflow-y-auto rounded-xl p-3`,children:[(0,Z.jsx)(`h2`,{className:`mb-2 px-2 text-sm font-medium text-fg`,children:_.title}),S?(0,Z.jsx)(`div`,{className:`space-y-2 px-2`,"aria-busy":`true`,children:[0,1,2].map(e=>(0,Z.jsx)(qt,{className:`h-8 w-full`},e))}):x?(0,Z.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-2 text-sm text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:_.unavailable}),B()]}):(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`section`,{"aria-label":_.work,children:[E?(0,Z.jsxs)(u,{className:xD,to:Qe(y,`/projects/${encodeURIComponent(E.id)}`),onClick:L,children:[(0,Z.jsx)(Ee,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:E.title,children:E.title})]}):null,D?(0,Z.jsxs)(u,{className:xD,to:$e(y,D.id),onClick:L,children:[(0,Z.jsx)(ws,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:D.title,children:D.title}),(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:D.phase})]}):null,O.length?(0,Z.jsxs)(Z.Fragment,{children:[O.length>2?(0,Z.jsxs)(`button`,{type:`button`,className:`${xD} w-full text-left`,onClick:()=>d(!l),"aria-expanded":l,children:[(0,Z.jsx)(ws,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,Z.jsxs)(`span`,{className:`flex-1`,children:[_.delegatedTasks,` · `,T?.work.delegatedTaskCount??O.length]}),(0,Z.jsx)(`span`,{className:`text-xs text-fg-muted`,children:l?_.collapse:_.expand})]}):(0,Z.jsxs)(`p`,{className:`px-2 pt-2 text-xs text-fg-subtle`,children:[_.delegatedTasks,` · `,T?.work.delegatedTaskCount??O.length]}),(l?O:O.slice(0,2)).map(e=>(0,Z.jsxs)(u,{className:`${xD} pl-9`,to:$e(y,e.id),onClick:L,children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.title,children:e.title}),(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:e.runStatus??e.phase})]},e.id))]}):null,M?null:(0,Z.jsx)(`p`,{className:`px-2 py-2 text-sm text-fg-muted`,children:N?_.unavailable:_.independent}),N?(0,Z.jsxs)(`div`,{className:`flex items-center justify-between px-2 text-xs text-fg-muted`,children:[M?_.partialUnavailable:null,B()]}):null,E&&a.onLeaveProject?(0,Z.jsx)(`button`,{type:`button`,className:SD,onClick:()=>{L(),a.onLeaveProject?.()},children:a.leaveProjectLabel}):null]}),A.length||P?(0,Z.jsxs)(`section`,{className:`border-t border-edge-subtle pt-3`,children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex items-center justify-between px-2`,children:[(0,Z.jsxs)(`h3`,{className:`text-sm text-fg-subtle`,children:[_.sources,` `,A.length?`${A.length}${T?.sourcesHasMore?`+`:``}`:``]}),P?B():null]}),(f?A:A.slice(0,3)).map(e=>{let t=e.origins.some(e=>e.kind===`session`)?_.session:e.origins.some(e=>e.kind===`task`)?_.task:e.origins.some(e=>e.kind===`recent`)?_.recent:_.draft,n=e.pending&&e.origins.length?`${t} · ${_.draft}`:e.pending?_.draft:t,r=e.kind===`file`&&e.fileKind===`directory`?Oe:e.kind===`file`?Te:e.kind===`session`?bt:e.kind===`browser_tab`||e.kind===`browser_page`||e.kind===`app_context`?k:e.kind===`mcp_resource`?ye:e.kind===`attachment`?Tt:Te,i=e.unavailable?_.unavailable:e.title||(e.kind===`note`?_.untitled:_.untitledSource),a=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(r,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.unavailable?void 0:e.title,children:i}),(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:n})]}),o=e.kind===`note`?tt(y,e.id):e.kind===`session`?`/chat/${encodeURIComponent(e.id)}`:null,s=`${e.kind}:${e.id}`;return!e.unavailable&&o?(0,Z.jsx)(u,{className:xD,to:o,onClick:L,children:a},s):(0,Z.jsx)(`div`,{className:`flex min-w-0 items-center gap-3 px-2 py-2 text-sm text-fg-muted`,children:a},s)}),A.length?null:(0,Z.jsx)(`p`,{className:`px-2 py-2 text-xs text-fg-muted`,children:_.unavailable}),A.length>0&&P?(0,Z.jsx)(`p`,{className:`px-2 py-1 text-xs text-fg-muted`,children:_.partialUnavailable}):null,A.length>3?(0,Z.jsx)(`button`,{type:`button`,className:SD,onClick:()=>p(!f),"aria-expanded":f,children:f?_.collapse:_.expand}):null,T?.sourcesHasMore?(0,Z.jsx)(`p`,{className:`px-2 py-1 text-xs text-fg-muted`,children:_.more}):null,R&&a.onDraftSourceNote?(0,Z.jsx)(`button`,{type:`button`,className:SD,onClick:()=>{L(),a.onDraftSourceNote?.()},children:a.draftSourceNoteLabel}):null]}):null,e&&(j||F)||a.environmentAction?(0,Z.jsxs)(`section`,{className:`border-t border-edge-subtle pt-3`,children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex items-center justify-between px-2`,children:[(0,Z.jsx)(`h3`,{className:`text-sm text-fg-subtle`,children:_.environment}),F?B():null]}),j?null:a.environmentAction,j?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 px-2 py-2 text-sm text-fg`,children:[(0,Z.jsx)(St,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:j.kind===`managed_worktree`?_.worktree:_.local}),j.branch||j.headSha?(0,Z.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-40 items-center gap-1 text-xs text-fg-muted`,children:[(0,Z.jsx)(Me,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate`,children:j.branch||(j.detached?`${_.detached} · ${j.headSha?.slice(0,8)}`:j.headSha?.slice(0,8))})]}):null]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 pl-9 pr-1`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,title:j.rootPath,children:j.rootPath}),(0,Z.jsx)(`button`,{type:`button`,className:SD,"aria-label":m?_.copied:_.copyEnvironmentPath,title:m?_.copied:_.copyEnvironmentPath,onClick:z,children:m?(0,Z.jsx)(G,{className:`size-3.5`,"aria-hidden":!0}):(0,Z.jsx)(ve,{className:`size-3.5`,"aria-hidden":!0})})]}),a.environmentAction,j.available?null:(0,Z.jsx)(`p`,{className:`px-2 py-1 text-xs text-fg-muted`,children:_.unavailableEnvironment}),E&&i?.workspaceRoot?(0,Z.jsx)(fe,{className:SD,to:Xr(E.id),state:{forceNewChat:!0,agentId:a.agentId,temporary:a.temporary},onClick:L,children:_.newEnvironment}):null]}):(0,Z.jsx)(`p`,{className:`px-2 py-2 text-xs text-fg-muted`,children:_.unavailable})]}):null]}),a.executionDeviceAction]})})})]})}var wD=`min(36dvh, 320px)`;function TD(e){return e&&Number.isFinite(e.width)&&Number.isFinite(e.height)&&e.width>0&&e.height>0?e.width/e.height:void 0}function ED(e){let t=TD(e);return t?`min(calc(100vw - 2rem), ${36*t}dvh, ${Math.min(480,320*t)}px)`:`min(320px, calc(100vw - 2rem))`}function DD(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 OD(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 kD({conversationId:e,onFrameSizeChange:t}){let n=OD(e),[r,i]=(0,Q.useState)(!0),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),l=(0,Q.useRef)(null),u=h(e=>e.language===`zh`),d=n.state?.previewId;if((0,Q.useEffect)(()=>{n.frameSize&&t?.(n.frameSize)},[n.frameSize,t]),(0,Q.useEffect)(()=>{c(!1)},[d]),(0,Q.useEffect)(()=>{if(!l.current||typeof IntersectionObserver>`u`)return;let e=new IntersectionObserver(e=>i(e.some(e=>e.isIntersecting)),{rootMargin:`160px`});return e.observe(l.current),()=>e.disconnect()},[d]),(0,Q.useEffect)(()=>{!n.subscriptionId||!n.api||n.api.setPreset(n.subscriptionId,n.visible&&r?`compact`:`paused`).catch(()=>{})},[n.api,n.subscriptionId,n.visible,r]),!n.state||n.state.conversationId!==e||n.state.status===`ended`)return null;let f=n.state.status===`unavailable`,p=s?u?`重试切换`:`Retry switch`:n.stale?u?`等待新画面`:`Waiting for a new frame`:DD(n.state.activity,u),m=async()=>{let t=window.electronAPI?.computer;if(!(!t?.focusTarget||!e||!d||a)){o(!0),c(!1);try{await t.focusTarget(e,d)}catch{c(!0)}finally{o(!1)}}};return(0,Z.jsxs)(`section`,{ref:l,"aria-label":u?`电脑操作预览`:`Computer activity`,className:`relative w-full overflow-hidden rounded-xl bg-transparent`,style:{aspectRatio:TD(n.frameSize)??16/10,maxHeight:wD},children:[!n.hasFrame&&!f&&(0,Z.jsx)(qt,{className:`absolute inset-0`}),(0,Z.jsx)(`canvas`,{ref:n.registerCanvas,role:`img`,"aria-label":u?`${n.state.appName}窗口预览`:`${n.state.appName} window preview`,className:`absolute inset-0 h-full w-full object-contain ${n.hasFrame&&!f?``:`invisible`}`}),!f&&(0,Z.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`absolute left-2 top-2 z-10 max-w-[calc(100%-1rem)]`,children:(0,Z.jsxs)(`button`,{type:`button`,disabled:a||!window.electronAPI?.computer?.focusTarget,"aria-label":u?`切换到正在操作的应用`:`Switch to the active app`,title:s?u?`暂时无法切换应用,请重试`:`Could not switch to the app. Try again.`:u?`切换到应用`:`Switch to app`,className:`inline-flex min-h-11 min-w-11 max-w-full sm:min-h-9 sm:min-w-9 items-center justify-center gap-1.5 rounded-md bg-surface-overlay/80 px-2 text-xs text-fg backdrop-blur-sm hover:bg-surface-overlay focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>{m()},children:[(0,Z.jsx)(St,{size:14,className:`shrink-0`,"aria-hidden":!0}),p&&(0,Z.jsx)(`span`,{className:`truncate`,children:p})]})}),f&&(0,Z.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-surface-panel/90`,children:(0,Z.jsx)(`button`,{className:`min-h-11 rounded-md px-3 text-sm text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:n.retry,children:u?`预览暂时不可用,点击重试`:`Preview unavailable. Retry preview`})})]})}function AD(e){let t=(0,X.c)(26),{conversationId:n}=e,{state:r}=OD(n,!1),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(),c=h(MD),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{a(!1),s(void 0)},t[0]=l):l=t[0];let u=r?.previewId,d;if(t[1]!==n||t[2]!==u?(d=[n,u],t[1]=n,t[2]=u,t[3]=d):d=t[3],(0,Q.useEffect)(l,d),!r||r.conversationId!==n||r.status===`ended`)return null;let f=c?`查看电脑预览`:`View computer preview`,p=c?`查看电脑预览`:`View computer preview`,m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(St,{className:`size-4 shrink-0`,"aria-hidden":!0}),t[4]=m):m=t[4];let g=c?`电脑`:`Computer`,_;t[5]===g?_=t[6]:(_=(0,Z.jsx)(`span`,{className:`hidden whitespace-nowrap text-xs xl:inline`,children:g}),t[5]=g,t[6]=_);let v;t[7]!==f||t[8]!==p||t[9]!==_?(v=(0,Z.jsx)(yi,{asChild:!0,children:(0,Z.jsxs)(pi,{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,_]})}),t[7]=f,t[8]=p,t[9]=_,t[10]=v):v=t[10];let y=c?`电脑预览`:`Computer preview`,b;t[11]===o?b=t[12]:(b=ED(o),t[11]=o,t[12]=b);let x;t[13]===b?x=t[14]:(x={"--computer-preview-width":b},t[13]=b,t[14]=x);let S=x,C;t[15]!==n||t[16]!==r.previewId?(C=(0,Z.jsx)(kD,{conversationId:n,onFrameSizeChange:s},r.previewId),t[15]=n,t[16]=r.previewId,t[17]=C):C=t[17];let w;t[18]!==y||t[19]!==S||t[20]!==C?(w=(0,Z.jsx)(hi,{children:(0,Z.jsx)(gi,{align:`end`,sideOffset:8,collisionPadding:16,"aria-label":y,onOpenAutoFocus:jD,style:S,className:`z-40 w-[var(--computer-preview-width)] max-h-[calc(100dvh-5rem)] overflow-hidden rounded-xl bg-transparent p-0 outline-none`,children:C})}),t[18]=y,t[19]=S,t[20]=C,t[21]=w):w=t[21];let T;return t[22]!==i||t[23]!==w||t[24]!==v?(T=(0,Z.jsxs)(_i,{open:i,onOpenChange:a,children:[v,w]}),t[22]=i,t[23]=w,t[24]=v,t[25]=T):T=t[25],T}function jD(e){return e.preventDefault()}function MD(e){return e.language===`zh`}function ND({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),[m,h]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(!1),y=p(`/api/endpoint-tools/artifact-transfers`),{data:O,isLoading:k}=Gr(r?`${y}?conversationId=${encodeURIComponent(e)}`:null,e=>g(e),{shouldRetryOnError:!1}),A=O?.payload.files??[],j=O?.payload.tools??[],M=j.find(e=>e.toolName===s);return(0,Z.jsxs)(D,{open:r,onOpenChange:e=>{i(e),e&&(o(``),c(``),u(``),h(!1),v(!1))},children:[(0,Z.jsx)(x,{asChild:!0,children:(0,Z.jsx)(pi,{variant:`ghost`,className:`h-8 px-2 text-sm`,children:n?`传递文件`:`Transfer file`})}),(0,Z.jsxs)(w,{children:[(0,Z.jsx)(b,{className:`fixed inset-0 z-[120] bg-black/50`}),(0,Z.jsxs)(T,{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,Z.jsx)(E,{className:`text-base font-semibold`,children:n?`向执行设备传递文件`:`Transfer file to execution device`}),(0,Z.jsx)(S,{className:`mt-1 text-sm text-fg-muted`,children:t}),(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto py-3`,children:[k?(0,Z.jsx)(qt,{className:`h-20 w-full`}):A.length&&j.length?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ue,{value:a,onChange:o,placeholder:n?`选择源文件`:`Select source file`,options:A.map(e=>({value:e.fileId,label:`${e.name} · ${e.sourceName} · ${Math.ceil(e.size/1024)} KB`}))}),(0,Z.jsx)(ue,{value:s,onChange:c,placeholder:n?`选择接收能力`:`Select receiving capability`,options:j.map(e=>({value:e.toolName,label:e.title}))})]}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`当前没有可传递的文件或接收能力。`:`No eligible file or receiving capability is available.`}),l?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`在两分钟内将这段请求发到当前对话。`:`Send this request in this chat within two minutes.`}),(0,Z.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,_?(0,Z.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:n?`文件授权失败,请重新选择设备或文件。`:`Unable to authorize transfer. Reselect the device or file.`}):null]}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(C,{asChild:!0,children:(0,Z.jsx)(pi,{variant:`secondary`,children:n?`关闭`:`Close`})}),l?(0,Z.jsx)(pi,{onClick:async()=>{try{await navigator.clipboard.writeText(l),h(!0)}catch{h(!1)}},children:m?n?`已复制`:`Copied`:n?`复制请求`:`Copy request`}):(0,Z.jsx)(pi,{disabled:d||!M||!A.some(e=>e.fileId===a),onClick:async()=>{if(M){f(!0),v(!1);try{let t=await g(y,{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{v(!0)}finally{f(!1)}}},children:d?n?`授权中…`:`Authorizing…`:n?`生成一次性授权`:`Authorize one transfer`})]})]})]})]})}function PD({conversationId:e,disabled:t}){let n=h(e=>e.language)===`zh`,r=e&&/^[0-9a-f-]{36}$/i.test(e)?p(`/api/endpoint-tools/targets/${encodeURIComponent(e)}`):null,i=Gr(r,async e=>{let t=await f(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=Gr(r?ns():null,rs,{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,m=(a.data??[]).find(e=>e.id===d?.principalId),_=m?.endpoints.some(e=>e.endpointId===d?.endpointId&&e.connectionId===d?.connectionId),v=d&&(!_||d.expiresAt<=Date.now()),y=d?`${m?.displayName??(n?`所选设备`:`Selected device`)}${v?n?` · 需要重新选择`:` · Reselect required`:``}`:void 0;return d&&!u.some(e=>e.value===d.endpointId)&&u.push({value:d.endpointId,label:y,disabled:!0}),(0,Z.jsxs)(`section`,{className:`mt-3 space-y-2 border-t border-edge-subtle px-2 pt-3`,children:[(0,Z.jsx)(`h3`,{className:`text-sm text-fg-subtle`,children:n?`执行设备`:`Execution device`}),i.isLoading||a.isLoading?(0,Z.jsx)(qt,{className:`h-10 w-full rounded-lg`}):(0,Z.jsx)(ue,{value:d?.endpointId??``,options:u,allowEmpty:!0,emptyLabel:n?`由对话选择`:`Choose in conversation`,placeholder:n?`由对话选择`:`Choose in conversation`,title:y,selectedLabel:y,ariaLabel:n?`选择执行设备`:`Select execution device`,triggerIcon:(0,Z.jsx)(St,{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 g(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&&!v&&!t?(0,Z.jsx)(ND,{conversationId:e,deviceName:m?.displayName??d.endpointId,zh:n},d.connectionId):null,c?(0,Z.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:n?`无法更改设备,请先结束正在进行的操作并重试。`:`Unable to change device. Finish active operations and retry.`}):null]})}function FD(e){let t=(0,X.c)(23),{conversationId:n}=e,{data:r}=Qs(n),i=h(LD)===`zh`,a=sc(ID),o,s;if(t[0]!==n||t[1]!==r||t[2]!==a){let e=r?oc(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||Gs(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=()=>mi.getState().openPhone(r.report.deviceId??r.report.sessionId,r.report.deviceName,n,!0),t[5]=n,t[6]=r.report.deviceId,t[7]=r.report.deviceName,t[8]=r.report.sessionId,t[9]=d):d=t[9];let f;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(Lt,{className:`size-4`,"aria-hidden":!0}),t[10]=f):f=t[10];let p;t[11]===c?p=t[12]:(p=c&&(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`absolute -right-1 -top-1 size-1.5 rounded-full bg-accent`}),t[11]=c,t[12]=p);let m;t[13]===p?m=t[14]:(m=(0,Z.jsxs)(`span`,{className:`relative`,children:[f,p]}),t[13]=p,t[14]=m);let g=i?`手机`:`Phone`,_;t[15]===g?_=t[16]:(_=(0,Z.jsx)(`span`,{className:`text-xs`,children:g}),t[15]=g,t[16]=_);let v;return t[17]!==_||t[18]!==l||t[19]!==u||t[20]!==d||t[21]!==m?(v=(0,Z.jsxs)(pi,{variant:`ghost`,className:`min-h-10 gap-1.5 px-2`,title:l,"aria-label":u,onClick:d,children:[m,_]}),t[17]=_,t[18]=l,t[19]=u,t[20]=d,t[21]=m,t[22]=v):v=t[22],v}function ID(e){return e.seen}function LD(e){return e.language}function RD(e){let t=(0,X.c)(57),{conversationId:n,directoryOnly:r,workspacePath:i,canChangeWorkspace:a,disabled:o,available:s,onWorkspaceChange:c}=e,l=r!==void 0&&r,u=s===void 0||s,d=h(HD),f;t[0]===d?f=t[1]:(f=y(d),t[0]=d,t[1]=f);let p=f,m=$f(VD),g;t[2]===n?g=t[3]:(g=e=>e.panes[n??`new`]?.open===!0,t[2]=n,t[3]=g);let _=mi(g),[v,x]=(0,Q.useState)(null),C,O;t[4]!==p.chat.workingDirectory.notSet||t[5]!==i?(C=i?.trim()??``,O=C?Fa(C):p.chat.workingDirectory.notSet,t[4]=p.chat.workingDirectory.notSet,t[5]=i,t[6]=C,t[7]=O):(C=t[6],O=t[7]);let k=O,A;t[8]===c?A=t[9]:(A=async e=>{try{await c(e)}catch(e){let t=e;x(t instanceof Error?t.message:String(t))}},t[8]=c,t[9]=A);let j=A,M;t[10]!==j||t[11]!==C?(M={initialPath:C,onPicked:j},t[10]=j,t[11]=C,t[12]=M):M=t[12];let N=Ia(M),P=o||!u||N.picking,F;t[13]!==n||t[14]!==m?(F=()=>{let e=mi.getState(),t=n??`new`;e.setScope(t);let r=e.panes[t]?.tabs.find(BD);r?e.activate(r.id,t):e.openTools(t),m(n??``)},t[13]=n,t[14]=m,t[15]=F):F=t[15];let I=F,L;t[16]!==l||t[17]!==d||t[18]!==I||t[19]!==_?(L=l?null:(0,Z.jsx)(`button`,{type:`button`,className:Y(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors`,`hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,_&&`bg-surface-hover text-fg`),title:d===`zh`?`打开工具`:`Open workspace tools`,"aria-label":d===`zh`?`打开工具`:`Open workspace tools`,"aria-pressed":_,"aria-controls":`app-workspace-panel`,"data-workspace-trigger":!0,onClick:I,children:(0,Z.jsx)(Cs,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0})}),t[16]=l,t[17]=d,t[18]=I,t[19]=_,t[20]=L):L=t[20];let R;t[21]!==a||t[22]!==l||t[23]!==N||t[24]!==p.chat.workingDirectory.chooseFolder||t[25]!==C||t[26]!==P||t[27]!==k?(R=l&&a?(0,Z.jsxs)(`button`,{type:`button`,disabled:P,className:Y(`inline-flex h-8 max-w-full shrink-0 px-2 items-center justify-center rounded-lg text-fg-muted transition-colors`,`hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,P&&`cursor-not-allowed opacity-50`),title:`${p.chat.workingDirectory.chooseFolder}: ${C||k}`,"aria-label":p.chat.workingDirectory.chooseFolder,onClick:N.pick,children:[(0,Z.jsx)(re,{className:`mr-2 size-4`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate text-xs`,children:p.chat.workingDirectory.chooseFolder})]}):null,t[21]=a,t[22]=l,t[23]=N,t[24]=p.chat.workingDirectory.chooseFolder,t[25]=C,t[26]=P,t[27]=k,t[28]=R):R=t[28];let z;t[29]!==R||t[30]!==L?(z=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-0.5`,children:[L,R]}),t[29]=R,t[30]=L,t[31]=z):z=t[31];let B;t[32]!==l||t[33]!==N||t[34]!==p.chat.workingDirectory||t[35]!==C?(B=l&&!N.hasNativePicker?(0,Z.jsx)(ie,{open:N.modalOpen,onOpenChange:N.setModalOpen,initialAbsolutePath:C||void 0,onConfirm:N.confirmPick,wd:p.chat.workingDirectory}):null,t[32]=l,t[33]=N,t[34]=p.chat.workingDirectory,t[35]=C,t[36]=B):B=t[36];let V=v!==null,H;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(H=e=>{e||x(null)},t[37]=H):H=t[37];let U;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Z.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),t[38]=U):U=t[38];let W;t[39]===p.chat.workingDirectory.applyErrorTitle?W=t[40]:(W=(0,Z.jsx)(E,{className:`text-base font-semibold text-fg`,children:p.chat.workingDirectory.applyErrorTitle}),t[39]=p.chat.workingDirectory.applyErrorTitle,t[40]=W);let G;t[41]===v?G=t[42]:(G=v?(0,Z.jsx)(S,{className:`mt-2 whitespace-pre-wrap text-sm leading-relaxed text-fg-muted`,children:v}):null,t[41]=v,t[42]=G);let ee;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(ee=()=>x(null),t[43]=ee):ee=t[43];let te;t[44]===p.chat.workingDirectory.applyErrorClose?te=t[45]:(te=(0,Z.jsx)(`div`,{className:`mt-4 flex justify-end border-t border-edge-subtle pt-3`,children:(0,Z.jsx)(pi,{type:`button`,onClick:ee,children:p.chat.workingDirectory.applyErrorClose})}),t[44]=p.chat.workingDirectory.applyErrorClose,t[45]=te);let ne;t[46]!==W||t[47]!==G||t[48]!==te?(ne=(0,Z.jsxs)(w,{children:[U,(0,Z.jsxs)(T,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[81] w-[min(100%-2rem,26rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover`,onOpenAutoFocus:zD,children:[W,G,te]})]}),t[46]=W,t[47]=G,t[48]=te,t[49]=ne):ne=t[49];let ae;t[50]!==V||t[51]!==ne?(ae=(0,Z.jsx)(D,{open:V,onOpenChange:H,children:ne}),t[50]=V,t[51]=ne,t[52]=ae):ae=t[52];let oe;return t[53]!==z||t[54]!==B||t[55]!==ae?(oe=(0,Z.jsxs)(Z.Fragment,{children:[z,B,ae]}),t[53]=z,t[54]=B,t[55]=ae,t[56]=oe):oe=t[56],oe}function zD(e){return e.preventDefault()}function BD(e){return e.kind===`home`}function VD(e){return e.openForSession}function HD(e){return e.language}function UD(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 WD({conversationId:e,dialogOpen:t,onDialogOpenChange:n,hideTrigger:r=!1}){let i=h(e=>e.language),a=i===`zh`?KD:qD,[o,s]=(0,Q.useState)(!1),c=t??o,l=e=>{s(e),n?.(e)},[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(null),[m,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(null),[y,O]=(0,Q.useState)(864e5),[k,A]=(0,Q.useState)(null),[j,M]=(0,Q.useState)(``),[N,P]=(0,Q.useState)(!1),[F,I]=(0,Q.useState)([]),[L,R]=(0,Q.useState)(`hosted`),[z,B]=(0,Q.useState)(!1),[V,H]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(!c||u||f)return;let t=!1;return g(!0),v(null),Promise.all([$a(e),ro(e),Qa()]).then(async([n,r,i])=>{if(t)return;d(n),B(i);let a=i?await io().catch(()=>null):null;if(t)return;H(a?.publishing.allowed===!0);let o=i?await ao(e).catch(()=>[]):[];if(t)return;let s=[...o,...r].find(e=>!e.revoked&&!e.expired);s&&p(s)}).catch(e=>{t||v(e instanceof Error?e.message:String(e))}).finally(()=>{t||g(!1)}),()=>{t=!0}},[c,u,f,e]);let U=()=>{d(null),p(null),v(null),g(!1),M(``),P(!1),I([]),H(!1)},W=async()=>{if(!(!u||m)){g(!0),v(null);try{p(await(L===`hosted`?no:to)(e,{expectedTranscriptId:u.transcriptId,expectedCutoffSeq:u.cutoffSeq,expectedMetadataUpdatedAt:u.metadataUpdatedAt,ttlMs:y,maxViews:k,description:j.trim()||void 0,includeToolActivities:N,attachmentIds:F}))}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(!1)}}},G=async()=>{if(!(!f||m)){g(!0),v(null);try{let t=await $a(e);d(t);let n=f.delivery===`hosted`?eo:Xa;p(await n(e,f.id,{expectedTranscriptId:t.transcriptId,expectedCutoffSeq:t.cutoffSeq,expectedMetadataUpdatedAt:t.metadataUpdatedAt}))}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(!1)}}},ee=async()=>{if(!(!f||m)){g(!0),v(null);try{f.delivery===`hosted`?await oo(e,f.id):await Za(f.id),l(!1),U()}catch(e){v(e instanceof Error?e.message:String(e)),g(!1)}}};return(0,Z.jsxs)(D,{open:c,onOpenChange:e=>{l(e),e||U()},children:[r?null:(0,Z.jsx)(x,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`rounded-md p-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,title:a.share,"aria-label":a.share,children:(0,Z.jsx)(ys,{className:`size-4`})})}),(0,Z.jsxs)(w,{children:[(0,Z.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),(0,Z.jsxs)(T,{onCloseAutoFocus:e=>{r&&(e.preventDefault(),document.querySelector(`[data-chat-menu-trigger]`)?.focus())},className:Y(`xopc-dialog-content fixed left-1/2 top-1/2 z-[71] flex h-[min(35rem,calc(100dvh-2rem))] w-[min(34rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col`,`overflow-hidden rounded-xl border border-edge bg-surface-overlay outline-none`),children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(E,{className:`text-base font-semibold text-fg`,children:f?a.created:a.title}),(0,Z.jsx)(S,{className:`mt-0.5 text-xs text-fg-muted`,children:f?a.createdHint:a.hint})]}),(0,Z.jsx)(C,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`touch-target flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":a.close,children:(0,Z.jsx)(Gt,{className:`size-4`})})})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:[m&&!u&&!f?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,Z.jsx)(Je,{className:`size-4 animate-spin`}),a.loading]}):f?(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f.fileName}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.snapshotMessages.replace(`{{count}}`,String(f.messageCount))}),(0,Z.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[f.delivery===`hosted`?a.hosted:a.local,` · `,a.revision.replace(`{{revision}}`,String(f.snapshotRevision)),` · `,a.sharedAttachments.replace(`{{count}}`,String(f.attachmentCount))]})]}),(0,Z.jsx)(Ht,{shareUrl:f.shareUrl,lanUrl:f.lanUrl,reachability:f.reachability}),(0,Z.jsx)(Ut,{reachability:f.reachability,reachabilityHint:f.reachabilityHint}),(0,Z.jsxs)(`a`,{href:f.shareUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-sm font-medium text-accent hover:underline`,children:[a.open,(0,Z.jsx)(xe,{className:`size-3.5`})]})]}):u?(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-inset p-3`,children:[(0,Z.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:u.title}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.snapshotMessages.replace(`{{count}}`,String(u.messageCount))}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:new Date(u.snapshotAt).toLocaleString(i===`zh`?`zh-CN`:`en-US`)})]}),(0,Z.jsxs)(`details`,{className:`rounded-lg border border-edge`,children:[(0,Z.jsx)(`summary`,{className:`touch-target cursor-pointer px-3 py-2.5 text-xs font-medium text-fg transition-colors hover:bg-surface-hover`,children:a.reviewContent}),(0,Z.jsx)(`div`,{className:`max-h-64 space-y-3 overflow-y-auto border-t border-edge p-3`,children:u.messages.map(e=>(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-inset px-3 py-2`,children:[(0,Z.jsx)(`p`,{className:`mb-1 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:e.role===`user`?a.you:a.assistant}),(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm leading-6 text-fg`,children:e.markdown})]},e.id))})]}),(0,Z.jsxs)(`div`,{className:`flex gap-2 rounded-lg border border-accent/20 bg-accent-soft px-3 py-2.5 text-xs leading-5 text-fg-muted`,children:[(0,Z.jsx)(It,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{children:a.scope})]}),(0,Z.jsxs)(`label`,{className:`block space-y-1.5 text-xs font-medium text-fg`,children:[(0,Z.jsx)(`span`,{children:a.delivery}),(0,Z.jsxs)(se,{value:L,disabled:m,onChange:e=>R(e.target.value),children:[(0,Z.jsx)(le,{value:`hosted`,children:a.hosted}),(0,Z.jsx)(le,{value:`local`,children:a.local})]})]}),L===`hosted`&&!z?(0,Z.jsx)(Yo,{providerId:`xopc-share`,displayName:a.hosted,connected:!1,onConnected:()=>{B(!0),io().then(e=>H(e.publishing.allowed)).catch(()=>H(!1))}}):null,L===`hosted`&&z&&!V?(0,Z.jsx)(`p`,{className:`rounded-lg border border-warning/30 bg-warning-soft px-3 py-2 text-xs text-warning`,children:a.hostedDisabled}):null,u.toolActivities.length?(0,Z.jsxs)(`label`,{className:`flex items-start gap-2 rounded-lg border border-edge bg-surface-inset px-3 py-2.5 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:N,disabled:m,onChange:e=>P(e.target.checked),className:`mt-0.5 size-4 rounded border-edge`}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`block font-medium`,children:a.includeTools.replace(`{{count}}`,String(u.toolActivities.length))}),(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-muted`,children:a.toolDisclosure})]})]}):null,u.attachmentCandidates.length?(0,Z.jsxs)(`fieldset`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2.5`,children:[(0,Z.jsx)(`legend`,{className:`px-1 text-xs font-medium text-fg`,children:a.attachments}),(0,Z.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:a.attachmentDisclosure}),(0,Z.jsx)(`div`,{className:`space-y-2`,children:u.attachmentCandidates.map(e=>(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:F.includes(e.id),disabled:m,onChange:t=>I(n=>t.target.checked?[...n,e.id]:n.filter(t=>t!==e.id)),className:`size-4 rounded border-edge`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.fileName}),(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:GD(e.size)})]},e.id))})]}):null,(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg`,children:[(0,Z.jsx)(`span`,{children:a.ttl}),(0,Z.jsxs)(se,{value:y,disabled:m,onChange:e=>O(Number(e.target.value)),children:[(0,Z.jsx)(le,{value:36e5,children:a.oneHour}),(0,Z.jsx)(le,{value:864e5,children:a.oneDay}),(0,Z.jsx)(le,{value:6048e5,children:a.sevenDays}),(0,Z.jsx)(le,{value:2592e6,children:a.thirtyDays})]})]}),(0,Z.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg`,children:[(0,Z.jsx)(`span`,{children:a.maxViews}),(0,Z.jsxs)(se,{value:k??`unlimited`,disabled:m,onChange:e=>A(e.target.value===`unlimited`?null:Number(e.target.value)),children:[(0,Z.jsx)(le,{value:`unlimited`,children:a.unlimited}),(0,Z.jsx)(le,{value:1,children:`1`}),(0,Z.jsx)(le,{value:10,children:`10`}),(0,Z.jsx)(le,{value:50,children:`50`})]})]})]}),(0,Z.jsxs)(`label`,{className:`block space-y-1.5 text-xs font-medium text-fg`,children:[(0,Z.jsx)(`span`,{children:a.description}),(0,Z.jsx)(`input`,{value:j,disabled:m,onChange:e=>M(e.target.value),className:`h-10 w-full rounded-lg border border-edge bg-surface-inset px-3 text-sm font-normal text-fg outline-none focus-visible:border-accent/50 focus-visible:ring-2 focus-visible:ring-accent/20`})]}),(0,Z.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-300`,children:a.publicWarning})]}):null,_?(0,Z.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:_}):null]}),(0,Z.jsx)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-edge bg-surface-overlay px-4 py-3`,children:f?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(pi,{type:`button`,variant:`ghost`,disabled:m,onClick:()=>p(null),children:a.newShare}),(0,Z.jsxs)(pi,{type:`button`,variant:`ghost`,disabled:m,onClick:()=>void ee(),children:[(0,Z.jsx)(Bt,{className:`size-4`}),a.revoke]}),(0,Z.jsxs)(pi,{type:`button`,disabled:m||f.delivery===`hosted`&&!V,onClick:()=>void G(),children:[m?(0,Z.jsx)(Je,{className:`size-4 animate-spin`}):(0,Z.jsx)(At,{className:`size-4`}),a.refresh]})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(C,{asChild:!0,children:(0,Z.jsx)(pi,{type:`button`,variant:`ghost`,children:a.cancel})}),(0,Z.jsxs)(pi,{type:`button`,disabled:!u||m||u.messageCount===0||L===`hosted`&&(!z||!V),onClick:()=>void W(),children:[m?(0,Z.jsx)(Je,{className:`size-4 animate-spin`}):null,a.create]})]})})]})]})]})}function GD(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var KD={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:`助手`},qD={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`},JD=`(max-width: 767px)`,YD=(0,Q.memo)(function(e){let t=(0,X.c)(141),{inline:n,chatHeadline:r,chatAgents:i,showChatAgentSelector:a,chatAgentId:o,onChatAgentChange:c,chatAgentDisabled:l,conversationId:u,hasMessages:d,workspacePath:f,userContextMode:p,canChangeWorkspace:m,workspaceDisabled:g,onWorkspaceChange:_,prepareTerminalSession:v,terminalDisabled:b,showContextControls:x,onFindOpen:S,projectId:C,context:w}=e,T=n!==void 0&&n,E=d!==void 0&&d,D=p===void 0?`enabled`:p,O=m!==void 0&&m,k=g!==void 0&&g,A=b!==void 0&&b,j=x===void 0||x,M=h(XD),{conversationId:N}=s(),P=N&&N!==`new`?decodeURIComponent(N):null,F;t[0]!==u||t[1]!==P?(F=u?.trim()||P,t[0]=u,t[1]=P,t[2]=F):F=t[2];let L=F,{data:R,error:z,mutate:B}=mf(L??null,!1),V=!z&&(!R||!!R.environment?.available),H;t[3]===L?H=t[4]:(H=e=>e.panes[L??`new`]?.open===!0,t[3]=L,t[4]=H);let U=mi(H),W;t[5]===M?W=t[6]:(W=y(M),t[5]=M,t[6]=W);let G=W,ee=Ef(ZD),te=bw(QD),ne=Go($D),re=Go(eO),[ie,ae]=(0,Q.useState)(!1),oe=(0,Q.useRef)(!1),[se,ce]=(0,Q.useState)(!1),le=Df(tO),ue=Ea(nO),K=Ea(rO),q=window.electronAPI?.platform,de=!!(j&&window.electronAPI?.terminal&&(L||v)),pe;t[7]!==L||t[8]!==re||t[9]!==v||t[10]!==de||t[11]!==A||t[12]!==se||t[13]!==ne?(pe=()=>{if(!(!de||A||se)){if(L){ne(L);return}v&&(ce(!0),v().then(e=>{e&&re(e)}).finally(()=>ce(!1)))}},t[7]=L,t[8]=re,t[9]=v,t[10]=de,t[11]=A,t[12]=se,t[13]=ne,t[14]=pe):pe=t[14];let J=pe,me;t[15]!==L||t[16]!==E||t[17]!==te?(me=()=>{if(!L||!E)return;let e=mi.getState().panes[L],t=bw.getState().pendingCreate?.parentConversationId===L||!!bw.getState().creatingRequests[L],n=e?.open===!0&&(e.activeId?.startsWith(`side:`)===!0||t);te(L,!n)},t[15]=L,t[16]=E,t[17]=te,t[18]=me):me=t[18];let he=me,ge=Xo(JD),_e;t[19]!==le||t[20]!==ee?(_e=vf({runtime:_f(),sidebarCollapsed:ee,mobileNavOpen:le}),t[19]=le,t[20]=ee,t[21]=_e):_e=t[21];let ve=ge?!le:_e.collapsedNewChatVisible,ye,xe;t[22]!==K||t[23]!==T?(ye=()=>{if(!T)return()=>K()},xe=[K,T],t[22]=K,t[23]=T,t[24]=ye,t[25]=xe):(ye=t[24],xe=t[25]),(0,Q.useLayoutEffect)(ye,xe);let Se,Ce;t[26]!==J||t[27]!==de?(Se=()=>{if(!de)return;let e=e=>{UD(e,q)&&(e.preventDefault(),J())};return window.addEventListener(`keydown`,e),window.addEventListener(`workspace-open-terminal`,J),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`workspace-open-terminal`,J)}},Ce=[J,de,q],t[26]=J,t[27]=de,t[28]=Se,t[29]=Ce):(Se=t[28],Ce=t[29]),(0,Q.useEffect)(Se,Ce);let we,Te;t[30]!==L||t[31]!==he||t[32]!==E?(we=()=>{if(!L||!E)return;let e=e=>{is(e,q)&&(e.preventDefault(),he())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},Te=[L,he,E,q],t[30]=L,t[31]=he,t[32]=E,t[33]=we,t[34]=Te):(we=t[33],Te=t[34]),(0,Q.useEffect)(we,Te);let Ee;t[35]!==o||t[36]!==G.sidebar.newTask||t[37]!==C||t[38]!==ve||t[39]!==D?(Ee=ve?(0,Z.jsx)(fe,{to:Xr(C),state:{forceNewChat:!0,agentId:o,temporary:D===`temporary`},className:Y(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-panel text-sm font-medium leading-none text-fg transition-colors hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,xa),title:G.sidebar.newTask,children:(0,Z.jsx)(kt,{className:`size-4 shrink-0 text-accent-fg`,strokeWidth:2,"aria-hidden":!0})}):null,t[35]=o,t[36]=G.sidebar.newTask,t[37]=C,t[38]=ve,t[39]=D,t[40]=Ee):Ee=t[40];let De=ve?`text-left md:text-center`:`text-left`,Oe;t[41]===De?Oe=t[42]:(Oe=Y(`min-w-0 flex-1 truncate text-[0.9375rem] font-semibold leading-5 tracking-tight text-fg`,De),t[41]=De,t[42]=Oe);let ke;t[43]!==r||t[44]!==Oe?(ke=(0,Z.jsx)(`div`,{className:`flex w-full min-w-0 max-w-(--max-width-chat-frame) items-center gap-3 px-3 sm:px-5 xl:px-6`,children:(0,Z.jsx)(`h1`,{className:Oe,title:r,children:r})}),t[43]=r,t[44]=Oe,t[45]=ke):ke=t[45];let Ae;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=Y(`flex min-w-0 max-w-[min(32rem,calc(100vw-8rem))] shrink-0 items-center justify-end gap-2`,xa),t[46]=Ae):Ae=t[46];let je;t[47]!==l||t[48]!==o||t[49]!==i||t[50]!==G.chat.agentNoMatches||t[51]!==G.chat.agentPlaceholder||t[52]!==G.chat.agentSearchPlaceholder||t[53]!==c||t[54]!==a?(je=a?(0,Z.jsx)(gD,{items:i,value:o,disabled:l,placeholder:G.chat.agentPlaceholder,searchPlaceholder:G.chat.agentSearchPlaceholder,noMatches:G.chat.agentNoMatches,compact:!0,contentSide:`bottom`,contentAlign:`end`,onChange:c}):null,t[47]=l,t[48]=o,t[49]=i,t[50]=G.chat.agentNoMatches,t[51]=G.chat.agentPlaceholder,t[52]=G.chat.agentSearchPlaceholder,t[53]=c,t[54]=a,t[55]=je):je=t[55];let Me=M===`zh`?`聊天菜单`:`Chat menu`,Ne=M===`zh`?`聊天菜单`:`Chat menu`,Pe;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=(0,Z.jsx)(be,{className:`size-4`,"aria-hidden":!0}),t[56]=Pe):Pe=t[56];let Fe;t[57]!==Me||t[58]!==Ne?(Fe=(0,Z.jsx)(lo,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,"data-chat-menu-trigger":!0,"aria-label":Me,title:Ne,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover data-[state=open]:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:Pe})}),t[57]=Me,t[58]=Ne,t[59]=Fe):Fe=t[59];let Ie;t[60]===S?Ie=t[61]:(Ie=e=>{oe.current&&(e.preventDefault(),oe.current=!1,document.querySelector(`[data-chat-menu-trigger]`)?.focus(),S?.())},t[60]=S,t[61]=Ie);let Le=!E||!S,Re;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(Re=()=>{oe.current=!0},t[62]=Re):Re=t[62];let ze;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(ze=(0,Z.jsx)(Nt,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t[63]=ze):ze=t[63];let Be;t[64]===G.chat.find.input?Be=t[65]:(Be=(0,Z.jsx)(`span`,{className:`flex-1`,children:G.chat.find.input}),t[64]=G.chat.find.input,t[65]=Be);let Ve;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(Ve=(0,Z.jsx)(`span`,{className:`text-xs text-fg-muted`,children:q===`darwin`?`⌘F`:`Ctrl+F`}),t[66]=Ve):Ve=t[66];let He;t[67]!==Le||t[68]!==Be?(He=(0,Z.jsxs)(fo,{disabled:Le,onSelect:Re,className:`flex cursor-default items-center gap-3 rounded-lg px-3 py-2 text-fg outline-none data-[highlighted]:bg-surface-hover data-[disabled]:opacity-40`,children:[ze,Be,Ve]}),t[67]=Le,t[68]=Be,t[69]=He):He=t[69];let Ue=!L||!E,We;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(We=()=>ae(!0),t[70]=We):We=t[70];let Ge;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(Ge=(0,Z.jsx)(I,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t[71]=Ge):Ge=t[71];let Ke=M===`zh`?`分享对话`:`Share conversation`,qe;t[72]===Ke?qe=t[73]:(qe=(0,Z.jsx)(`span`,{children:Ke}),t[72]=Ke,t[73]=qe);let Je;t[74]!==Ue||t[75]!==qe?(Je=(0,Z.jsxs)(fo,{disabled:Ue,onSelect:We,className:`flex cursor-default items-center gap-3 rounded-lg px-3 py-2 text-fg outline-none data-[highlighted]:bg-surface-hover data-[disabled]:opacity-40`,children:[Ge,qe]}),t[74]=Ue,t[75]=qe,t[76]=Je):Je=t[76];let Ye;t[77]!==Ie||t[78]!==He||t[79]!==Je?(Ye=(0,Z.jsx)(uo,{children:(0,Z.jsxs)(po,{onCloseAutoFocus:Ie,align:`end`,sideOffset:8,className:`workspace-menu z-[125] min-w-60 rounded-xl border border-edge bg-surface-overlay p-1.5 text-sm shadow-popover outline-none`,children:[He,Je]})}),t[77]=Ie,t[78]=He,t[79]=Je,t[80]=Ye):Ye=t[80];let Xe;t[81]!==Fe||t[82]!==Ye?(Xe=(0,Z.jsxs)(co,{modal:!1,children:[Fe,Ye]}),t[81]=Fe,t[82]=Ye,t[83]=Xe):Xe=t[83];let Ze;t[84]!==L||t[85]!==E||t[86]!==ie?(Ze=L&&E?(0,Z.jsx)(WD,{conversationId:L,hideTrigger:!0,dialogOpen:ie,onDialogOpenChange:ae},`share:${L}`):null,t[84]=L,t[85]=E,t[86]=ie,t[87]=Ze):Ze=t[87];let Qe;t[88]!==L||t[89]!==O||t[90]!==l||t[91]!==o||t[92]!==w||t[93]!==_||t[94]!==B||t[95]!==j||t[96]!==D||t[97]!==V||t[98]!==k||t[99]!==f?(Qe=j?(0,Z.jsx)(CD,{...w,agentId:o,executionDeviceAction:L?(0,Z.jsx)(PD,{conversationId:L,disabled:l}):null,environmentAction:O&&_?(0,Z.jsx)(RD,{directoryOnly:!0,conversationId:L,workspacePath:L?f:w?.project?.workspaceRoot,available:V,canChangeWorkspace:!0,disabled:k,onWorkspaceChange:async e=>{await _(e),await B()}}):null,temporary:D===`temporary`,conversationId:L??null},`context:${L??w?.project?.id??`new`}`):null,t[88]=L,t[89]=O,t[90]=l,t[91]=o,t[92]=w,t[93]=_,t[94]=B,t[95]=j,t[96]=D,t[97]=V,t[98]=k,t[99]=f,t[100]=Qe):Qe=t[100];let $e;t[101]!==j||t[102]!==U?($e=j&&!U?(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`mx-0.5 h-6 w-px shrink-0 bg-edge-subtle`}):null,t[101]=j,t[102]=U,t[103]=$e):$e=t[103];let et;t[104]===L?et=t[105]:(et=L?(0,Z.jsx)(AD,{conversationId:L},L):null,t[104]=L,t[105]=et);let tt;t[106]===L?tt=t[107]:(tt=L?(0,Z.jsx)(FD,{conversationId:L}):null,t[106]=L,t[107]=tt);let nt;t[108]!==L||t[109]!==w?.project?.workspaceRoot||t[110]!==_||t[111]!==C||t[112]!==B||t[113]!==j||t[114]!==V||t[115]!==k||t[116]!==U||t[117]!==f?(nt=j&&!U?(0,Z.jsx)(RD,{conversationId:L,workspacePath:L?f:w?.project?.workspaceRoot,available:V,canChangeWorkspace:!1,disabled:k,onWorkspaceChange:async e=>{await _?.(e),await B()}},`workspace:${L??C}`):null,t[108]=L,t[109]=w?.project?.workspaceRoot,t[110]=_,t[111]=C,t[112]=B,t[113]=j,t[114]=V,t[115]=k,t[116]=U,t[117]=f,t[118]=nt):nt=t[118];let rt;t[119]!==je||t[120]!==Xe||t[121]!==Ze||t[122]!==Qe||t[123]!==$e||t[124]!==et||t[125]!==tt||t[126]!==nt?(rt=(0,Z.jsxs)(`div`,{className:Ae,children:[je,Xe,Ze,Qe,$e,et,tt,nt]}),t[119]=je,t[120]=Xe,t[121]=Ze,t[122]=Qe,t[123]=$e,t[124]=et,t[125]=tt,t[126]=nt,t[127]=rt):rt=t[127];let it;t[128]!==Ee||t[129]!==ke||t[130]!==rt?(it={className:`bg-surface-panel`,startExtra:Ee,main:ke,end:rt},t[128]=Ee,t[129]=ke,t[130]=rt,t[131]=it):it=t[131];let at=it,ot,st;t[132]!==at||t[133]!==T||t[134]!==ue?(ot=()=>{T||ue(at)},st=[at,T,ue],t[132]=at,t[133]=T,t[134]=ue,t[135]=ot,t[136]=st):(ot=t[135],st=t[136]),(0,Q.useLayoutEffect)(ot,st);let ct;return t[137]!==at||t[138]!==T||t[139]!==M?(ct=T?(0,Z.jsxs)(`header`,{"aria-label":M===`zh`?`聊天工具栏`:`Chat toolbar`,className:`flex min-h-14 shrink-0 items-center justify-between gap-2 border-b border-edge-subtle px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:at.main}),at.end]}):null,t[137]=at,t[138]=T,t[139]=M,t[140]=ct):ct=t[140],ct});function XD(e){return e.language}function ZD(e){return e.collapsed}function QD(e){return e.setOpen}function $D(e){return e.toggle}function eO(e){return e.open}function tO(e){return e.mobileNavOpen}function nO(e){return e.setPageHeader}function rO(e){return e.clearPageHeader}var iO=(0,Q.memo)(function(){let e=(0,X.c)(13),t=h(aO),n;e[0]===t?n=e[1]:(n=y(t),e[0]=t,e[1]=n);let r=n,i=li(oO),a=li(sO);if(i===`idle`)return null;if(i===`error`&&a){let t;e[2]===a?t=e[3]:(t=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:a}),e[2]=a,e[3]=t);let n;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(n=Y(`shrink-0 rounded-xl border border-red-200 bg-white px-2.5 py-1 text-xs font-medium text-red-700`,`hover:bg-red-50 dark:border-red-800 dark:bg-red-950/40 dark:text-red-300 dark:hover:bg-red-950/70`,ca.transition,ca.press,ca.focusRingPanel),e[4]=n):n=e[4];let i;e[5]===r.connection.reconnect?i=e[6]:(i=(0,Z.jsx)(`button`,{type:`button`,className:n,onClick:cO,children:r.connection.reconnect}),e[5]=r.connection.reconnect,e[6]=i);let o;return e[7]!==t||e[8]!==i?(o=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-red-100 bg-red-50 px-4 py-2 text-sm text-red-600 dark:border-red-900/40 dark:bg-red-950/50 dark:text-red-400`,children:[t,i]}),e[7]=t,e[8]=i,e[9]=o):o=e[9],o}if(i===`connecting`||i===`reconnecting`){let t;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`span`,{className:`inline-block size-3 animate-spin rounded-full border-2 border-amber-500 border-t-transparent`,"aria-hidden":!0}),e[10]=t):t=e[10];let n=i===`reconnecting`?r.connection.reconnecting:r.connection.connecting,a;return e[11]===n?a=e[12]:(a=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-amber-100 bg-amber-50 px-4 py-2 text-sm text-amber-800 dark:border-amber-900/40 dark:bg-amber-950/50 dark:text-amber-200`,children:[t,(0,Z.jsx)(`span`,{children:n})]}),e[11]=n,e[12]=a),a}return null});function aO(e){return e.language}function oO(e){return e.connectionState}function sO(e){return e.error}function cO(){return ci()}function lO(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function uO(e){let t=(0,X.c)(4),{status:n}=e;if(n===`completed`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(`span`,{className:`mt-0.5 inline-flex size-4 shrink-0 items-center justify-center rounded-full bg-fg-muted text-surface-panel`,children:(0,Z.jsx)(G,{className:`size-3`,strokeWidth:2.5,"aria-hidden":!0})}),t[0]=e):e=t[0],e}if(n===`in_progress`){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(q,{className:`mt-0.5 size-4 shrink-0 text-accent`,strokeWidth:2,"aria-hidden":!0}),t[1]=e):e=t[1],e}if(n===`cancelled`){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(os,{className:`mt-0.5 size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),t[2]=e):e=t[2],e}let r;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(J,{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 dO(e,t){return e?`${lO(e.files.length===1?t.filesChangedOne:t.filesChangedOther,{count:e.files.length})} · +${e.added} -${e.removed}`:null}function fO(e){let t=(0,X.c)(61),{plan:n,changeSummary:r,isStreaming:i,labels:a}=e,o=n.currentIndex==null?void 0:n.items[n.currentIndex-1],s;t[0]===n.items?s=t[1]:(s=n.items.every(hO),t[0]=n.items,t[1]=s);let c=s,l=n.items.every(mO),u;t[2]!==a.completedProgress||t[3]!==n.completedCount||t[4]!==n.totalCount?(u=lO(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=lO(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=dO(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`,ca.transition,`hover:border-edge hover:text-accent-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),t[17]=v):v=t[17];let y=`${a.heading}: ${_}`,b;t[18]!==o||t[19]!==c?(b=c?(0,Z.jsx)(G,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:2,"aria-hidden":!0}):o?(0,Z.jsx)(q,{className:`size-4 shrink-0 text-accent`,strokeWidth:2,"aria-hidden":!0}):(0,Z.jsx)(Ke,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[18]=o,t[19]=c,t[20]=b):b=t[20];let x;t[21]===f?x=t[22]:(x=(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:f}),t[21]=f,t[22]=x);let S;t[23]===o?S=t[24]:(S=o?(0,Z.jsxs)(`span`,{className:`min-w-0 truncate text-fg-muted`,children:[`· `,o.title]}):null,t[23]=o,t[24]=S);let C;t[25]===m?C=t[26]:(C=m?(0,Z.jsxs)(`span`,{className:`hidden shrink-0 tabular-nums text-fg-subtle sm:inline`,children:[`· `,m]}):null,t[25]=m,t[26]=C);let w;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(ee,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[27]=w):w=t[27];let T;t[28]!==S||t[29]!==C||t[30]!==y||t[31]!==b||t[32]!==x?(T=(0,Z.jsx)(yi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:v,"aria-label":y,children:[b,x,S,C,w]})}),t[28]=S,t[29]=C,t[30]=y,t[31]=b,t[32]=x,t[33]=T):T=t[33];let E;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsx)(Ke,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[34]=E):E=t[34];let D;t[35]===a.heading?D=t[36]:(D=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[E,(0,Z.jsx)(`span`,{children:a.heading})]}),t[35]=a.heading,t[36]=D);let O;t[37]===n.explanation?O=t[38]:(O=n.explanation?(0,Z.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:n.explanation}):null,t[37]=n.explanation,t[38]=O);let k;t[39]!==D||t[40]!==O?(k=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[D,O]}),t[39]=D,t[40]=O,t[41]=k):k=t[41];let A;t[42]===d?A=t[43]:(A=(0,Z.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-fg-subtle`,children:d}),t[42]=d,t[43]=A);let j;t[44]!==k||t[45]!==A?(j=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge-subtle px-4 py-3`,children:[k,A]}),t[44]=k,t[45]=A,t[46]=j):j=t[46];let M=a.heading,N;t[47]===n.items?N=t[48]:(N=n.items.map(pO),t[47]=n.items,t[48]=N);let P;t[49]!==a.heading||t[50]!==N?(P=(0,Z.jsx)(`ol`,{className:`max-h-[min(22rem,55vh)] overflow-y-auto px-4 py-3`,"aria-label":M,children:N}),t[49]=a.heading,t[50]=N,t[51]=P):P=t[51];let F;t[52]===m?F=t[53]:(F=m?(0,Z.jsx)(`div`,{className:`border-t border-edge-subtle px-4 py-2 text-right text-xs tabular-nums text-fg-subtle`,children:m}):null,t[52]=m,t[53]=F);let I;t[54]!==j||t[55]!==P||t[56]!==F?(I=(0,Z.jsx)(hi,{children:(0,Z.jsxs)(gi,{side:`top`,align:`center`,sideOffset:8,collisionPadding:16,className:`z-[120] w-[min(28rem,calc(100vw-2rem))] overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:[j,P,F]})}),t[54]=j,t[55]=P,t[56]=F,t[57]=I):I=t[57];let L;return t[58]!==T||t[59]!==I?(L=(0,Z.jsx)(`div`,{className:`mx-auto flex w-full max-w-80 justify-center pb-2 pt-1`,children:(0,Z.jsxs)(_i,{children:[T,I]})}),t[58]=T,t[59]=I,t[60]=L):L=t[60],L}function pO(e){return(0,Z.jsxs)(`li`,{className:Y(`flex gap-3 py-2 text-sm leading-relaxed text-fg-muted`,e.status===`in_progress`&&`font-medium text-fg`,e.status===`cancelled`&&`text-fg-disabled`),children:[(0,Z.jsx)(uO,{status:e.status}),(0,Z.jsx)(`span`,{className:`min-w-0 [overflow-wrap:anywhere]`,children:e.title})]},e.id)}function mO(e){return e.status===`completed`||e.status===`cancelled`}function hO(e){return e.status===`completed`}function gO(e){let t=SO(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 _O=new Set([`pending`,`in_progress`,`completed`,`cancelled`]);function vO(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function yO(e){return e.trim().toLowerCase().replace(/-/g,`_`).split(`__`).at(-1)??``}function bO(e){let t=vO(e.details);return t&&Object.keys(t).length>0?t:ma(e.result).details}function xO(e){let t=typeof e==`string`?e.trim():``;return _O.has(t)?t:null}function SO(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 CO(e){if(!Array.isArray(e.plan))return null;let t=e.plan.flatMap((e,t)=>{let n=vO(e),r=typeof n?.id==`string`&&n.id.trim()?n.id.trim():`update-plan-${t}`,i=typeof n?.step==`string`?n.step.trim():``,a=xO(n?.status);return i&&a?[{id:r,title:i,status:a}]:[]});return SO(`update_plan`,typeof e.explanation==`string`&&e.explanation.trim()?e.explanation.trim():void 0,t)}function wO(e){return Array.isArray(e.items)?SO(`todo`,void 0,e.items.flatMap((e,t)=>{let n=vO(e),r=typeof n?.id==`string`&&n.id.trim()?n.id.trim():`todo-${t}`,i=typeof n?.content==`string`?n.content.trim():``,a=xO(n?.status);return i&&a?[{id:r,title:i,status:a}]:[]})):null}function TO(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=yO(n.name),i=bO(n);if(i){if(r===`update_plan`)return{found:!0,plan:CO(i)};if(r===`todo`)return{found:!0,plan:wO(i)}}}return{found:!1,plan:null}}function EO(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:0}function DO(e){let t=new Set,n=0,r=0;for(let i of e){if(i.type!==`tool_use`||i.status===`error`||yO(i.name)!==`apply_patch`)continue;let e=bO(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=vO(n),r=typeof e?.moveTo==`string`?e.moveTo:typeof e?.path==`string`?e.path:``;r.trim()&&t.add(r.trim())}n+=EO(e.added),r+=EO(e.removed)}}return t.size>0||n>0||r>0?{files:[...t],added:n,removed:r}:null}function OO(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.role!==`assistant`)continue;let r=TO(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:DO(i)}}return null}function kO(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 OO(e.slice(n+1))}function AO(e,t){return e.bottom>t.top&&e.top<t.bottom&&e.right>t.left&&e.left<t.right}function jO(e,t,n){let r=n.getBoundingClientRect(),i=t.getBoundingClientRect();if(!AO(e,{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight})||!AO(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&&!AO(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 MO(e){let t=(0,X.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=jO(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 NO(e){let t=(0,X.c)(61),{open:n,query:r,activeIndex:i,resultCount:a,searching:o,truncated:s,limitedToLoaded:c,inputRef:l,labels:u,onQueryChange:d,onPrevious:f,onNext:p,onClose:m}=e,h=o!==void 0&&o,g=s!==void 0&&s,_=c!==void 0&&c;if(!n)return null;let v;t[0]===r?v=t[1]:(v=r.trim(),t[0]=r,t[1]=v);let y=!!v,b;t[2]!==i||t[3]!==y||t[4]!==u.noResults||t[5]!==u.resultCount||t[6]!==u.searching||t[7]!==a||t[8]!==h||t[9]!==g?(b=h?u.searching:y&&a===0?u.noResults:y?u.resultCount.replace(`{{current}}`,String(i+1)).replace(`{{total}}`,`${a}${g?`+`:``}`):``,t[2]=i,t[3]=y,t[4]=u.noResults,t[5]=u.resultCount,t[6]=u.searching,t[7]=a,t[8]=h,t[9]=g,t[10]=b):b=t[10];let x=b,S;t[11]!==x||t[12]!==y||t[13]!==u.loadedOnly||t[14]!==_?(S=_&&y?[x,u.loadedOnly].filter(Boolean).join(` · `):x,t[11]=x,t[12]=y,t[13]=u.loadedOnly,t[14]=_,t[15]=S):S=t[15];let C=S,w=h||a===0,T=u.input,E;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsx)(Nt,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[16]=E):E=t[16];let D;t[17]===d?D=t[18]:(D=e=>d(e.target.value),t[17]=d,t[18]=D);let O;t[19]!==p||t[20]!==f?(O=e=>{e.nativeEvent.isComposing||e.key===`Enter`&&(e.preventDefault(),e.shiftKey?f():p())},t[19]=p,t[20]=f,t[21]=O):O=t[21];let k;t[22]!==l||t[23]!==u.input||t[24]!==r||t[25]!==O||t[26]!==D?(k=(0,Z.jsx)(`input`,{ref:l,value:r,type:`search`,autoComplete:`off`,spellCheck:!1,"aria-label":u.input,className:`h-12 min-w-0 flex-1 bg-transparent text-base text-fg outline-none placeholder:text-fg-subtle`,placeholder:u.input,onChange:D,onKeyDown:O}),t[22]=l,t[23]=u.input,t[24]=r,t[25]=O,t[26]=D,t[27]=k):k=t[27];let A;t[28]===h?A=t[29]:(A=h?(0,Z.jsx)(Je,{className:`size-4 shrink-0 animate-spin text-fg-muted`,"aria-hidden":!0}):null,t[28]=h,t[29]=A);let j;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(j=Y(`inline-flex size-11 shrink-0 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,ca.focusRingPanel,ca.press),t[30]=j):j=t[30];let M;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Z.jsx)(Gt,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[31]=M):M=t[31];let N;t[32]!==u.close||t[33]!==m?(N=(0,Z.jsx)(`button`,{type:`button`,onClick:m,className:j,"aria-label":u.close,children:M}),t[32]=u.close,t[33]=m,t[34]=N):N=t[34];let P;t[35]!==k||t[36]!==A||t[37]!==N?(P=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 px-3`,children:[E,k,A,N]}),t[35]=k,t[36]=A,t[37]=N,t[38]=P):P=t[38];let F;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(F=Y(`inline-flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,ca.focusRingPanel,ca.press,ca.disabled),t[39]=F):F=t[39];let I;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(ne,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[40]=I):I=t[40];let L;t[41]!==u.previous||t[42]!==w||t[43]!==f?(L=(0,Z.jsx)(`button`,{type:`button`,disabled:w,onClick:f,className:F,"aria-label":u.previous,children:I}),t[41]=u.previous,t[42]=w,t[43]=f,t[44]=L):L=t[44];let R;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(R=Y(`inline-flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,ca.focusRingPanel,ca.press,ca.disabled),t[45]=R):R=t[45];let z;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Z.jsx)(ee,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[46]=z):z=t[46];let B;t[47]!==u.next||t[48]!==w||t[49]!==p?(B=(0,Z.jsx)(`button`,{type:`button`,disabled:w,onClick:p,className:R,"aria-label":u.next,children:z}),t[47]=u.next,t[48]=w,t[49]=p,t[50]=B):B=t[50];let V;t[51]===C?V=t[52]:(V=(0,Z.jsx)(`span`,{className:`ml-auto px-2 text-sm tabular-nums text-fg-muted`,"aria-live":`polite`,"aria-atomic":`true`,children:C}),t[51]=C,t[52]=V);let H;t[53]!==L||t[54]!==B||t[55]!==V?(H=(0,Z.jsxs)(`div`,{className:`flex h-11 items-center border-t border-edge-subtle px-1.5`,children:[L,B,V]}),t[53]=L,t[54]=B,t[55]=V,t[56]=H):H=t[56];let U;return t[57]!==u.input||t[58]!==P||t[59]!==H?(U=(0,Z.jsxs)(`section`,{"data-chat-find-bar":!0,role:`search`,"aria-label":T,className:`absolute right-3 top-3 z-30 w-[min(25rem,calc(100%-1.5rem))] overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover`,children:[P,H]}),t[57]=u.input,t[58]=P,t[59]=H,t[60]=U):U=t[60],U}async function PO(e,t,n={}){let r=await f(p(`${n.taskId?`/api/tasks/${encodeURIComponent(n.taskId)}/conversation/find`:`/api/sessions/${encodeURIComponent(e)}/find`}?${new URLSearchParams({q:t,limit:`1000`})}`),{signal:n.signal});if(!r.ok)throw Error(`HTTP ${r.status}: ${r.statusText}`);let i=await r.json();if(i.ok!==!0||!Array.isArray(i.matches)||typeof i.total!=`number`)throw Error(`Invalid chat find response`);return{query:typeof i.query==`string`?i.query:t,total:i.total,truncated:i.truncated===!0,matches:i.matches.filter(e=>Number.isInteger(e?.displayIndex)&&e.displayIndex>=0&&Number.isInteger(e?.occurrence)&&e.occurrence>=0)}}var FO=`chat-find-match`,IO=`chat-find-active`,LO=`chat-find-highlight-styles`;function RO(){let e=globalThis.CSS,t=globalThis.Highlight;return!e?.highlights||!t?null:{registry:e.highlights,Highlight:t}}function zO(){if(document.getElementById(LO))return;let e=document.createElement(`style`);e.id=LO,e.textContent=`
61
- ::highlight(${FO}) {
56
+ <script>${lv(n,`script`)}<\/script>
57
+ <script>${lv(e.script,`script`)}<\/script>
58
+ </body></html>`}function fv(e,t,n){let r=r=>{if(r.source!==e.contentWindow)return;let i=uv(r.data);!i||i.channel!==t||n(i)};return window.addEventListener(`message`,r),()=>window.removeEventListener(`message`,r)}function pv({leaseId:e,reference:t,sourceHash:n,preferredHeight:r,language:i}){let a=d(),o=c(),s=(0,Q.useRef)(null),[l,u]=(0,Q.useState)(0),[f,p]=(0,Q.useState)(`booting`),[m,h]=(0,Q.useState)([]),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(null),b=ra(e),x=Math.min(720,Math.max(240,r)),S=(0,Q.useMemo)(()=>crypto.randomUUID(),[l,n]),C=Gr(b.active?[`chat-preview-revision`,t.id,n]:null,()=>ov(t.id,n),{revalidateOnFocus:!1,shouldRetryOnError:!1}),w=C.data?dv(C.data,S):void 0;(0,Q.useEffect)(()=>{let e=s.current;if(!e||!w)return;p(`booting`),h([]);let t=window.setTimeout(()=>{p(e=>e===`booting`?`timeout`:e)},7e3),n=fv(e,S,t=>{t.type===`ready`&&p(`healthy`),t.type===`resize`&&(e.style.height=`${Math.min(720,Math.max(240,t.height))}px`),t.type===`error`&&(p(`failed`),h(e=>[...e,t.diagnostic].slice(-20)))});return()=>{window.clearTimeout(t),n()}},[S,w]);let T=()=>{y(null),u(e=>e+1)},E=async()=>{if(m.length){_(`fix`),y(null);try{Wp((await sv(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 cv(t.id,n);a(Qe(`${o.pathname}${o.search}`,`/local-apps/${encodeURIComponent(e.id)}`))}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(null)}},O=`content-block-action-scope mt-3 overflow-hidden rounded-2xl border border-edge bg-surface-panel`;if(!b.active)return(0,Z.jsxs)(`section`,{ref:b.containerRef,className:O,"data-inline-chat-preview":t.id,children:[(0,Z.jsxs)(`header`,{className:`border-b border-edge-subtle px-4 py-3`,children:[(0,Z.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:t.title}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:b.state===`queued`?i===`zh`?`正在等待预览资源`:`Waiting for a preview slot`:i===`zh`?`预览尚未加载`:`Preview not loaded`})]}),(0,Z.jsx)(`div`,{className:`grid place-items-center bg-surface-base`,style:{height:x},children:(0,Z.jsx)(pi,{variant:`secondary`,className:`min-h-11`,onClick:b.activate,children:i===`zh`?`加载交互预览`:`Load interactive preview`})})]});if(C.isLoading)return(0,Z.jsxs)(`section`,{ref:b.containerRef,className:O,"aria-busy":`true`,"aria-label":i===`zh`?`正在加载预览`:`Loading preview`,children:[(0,Z.jsx)(`div`,{className:`border-b border-edge-subtle px-4 py-3`,children:(0,Z.jsx)(qt,{className:`h-5 w-40`})}),(0,Z.jsx)(qt,{className:`m-3 w-[calc(100%-1.5rem)]`,style:{height:x}})]});if(!C.data||!w){let e=C.error instanceof Error?C.error.message:i===`zh`?`无法加载预览`:`Unable to load preview`;return(0,Z.jsx)(`section`,{ref:b.containerRef,className:`mt-3 rounded-2xl border border-danger/30 bg-danger-soft p-4 text-sm text-danger`,role:`alert`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Vt,{className:`size-4`}),e]})})}let k=f===`failed`||f===`timeout`,A=f===`healthy`?i===`zh`?`运行正常`:`Running`:f===`booting`?i===`zh`?`正在启动`:`Starting`:f===`timeout`?i===`zh`?`启动超时`:`Start timed out`:i===`zh`?`运行错误`:`Runtime error`;return(0,Z.jsxs)(`section`,{ref:b.containerRef,className:O,"data-inline-chat-preview":t.id,children:[(0,Z.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-2 border-b border-edge-subtle px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:t.title}),(0,Z.jsx)(`p`,{className:Y(`mt-0.5 text-xs`,k?`text-danger`:`text-fg-muted`),"aria-live":`polite`,children:A})]}),(0,Z.jsx)(pi,{variant:`ghost`,className:`content-block-action`,onClick:T,"data-action-visible":k,title:i===`zh`?`重新加载预览`:`Reload preview`,"aria-label":i===`zh`?`重新加载预览`:`Reload preview`,children:(0,Z.jsx)(At,{className:`size-4`,"aria-hidden":!0})}),(0,Z.jsx)(pi,{variant:`ghost`,className:`content-block-action`,disabled:g!==null,onClick:()=>void D(),"aria-busy":g===`promote`,title:g===`promote`?i===`zh`?`保存中…`:`Saving…`:i===`zh`?`保存为应用`:`Save as app`,"aria-label":g===`promote`?i===`zh`?`保存中…`:`Saving…`:i===`zh`?`保存为应用`:`Save as app`,children:(0,Z.jsx)(Mt,{className:Y(`size-4`,g===`promote`&&`motion-safe:animate-pulse`),"aria-hidden":!0})})]}),(0,Z.jsxs)(`div`,{className:`relative bg-surface-base`,style:{minHeight:x},children:[(0,Z.jsx)(`iframe`,{ref:s,title:i===`zh`?`${t.title} 交互预览`:`${t.title} interactive preview`,srcDoc:w,sandbox:`allow-scripts allow-forms`,className:`block w-full border-0 bg-white`,style:{height:x}},l),f===`booting`?(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-0 grid place-items-center bg-surface-base/75`,children:(0,Z.jsx)(qt,{className:`h-10 w-40`})}):null]}),k?(0,Z.jsx)(`footer`,{className:`border-t border-danger/20 bg-danger-soft/60 px-4 py-3`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Z.jsx)(`p`,{className:`min-w-0 flex-1 text-xs text-danger`,role:`alert`,children:m.at(-1)?.message??(i===`zh`?`预览未能正常启动`:`The preview did not start correctly`)}),(0,Z.jsxs)(pi,{variant:`secondary`,className:`min-h-11 px-3 text-xs`,disabled:!m.length||g!==null,onClick:()=>void E(),children:[(0,Z.jsx)(Wt,{className:`size-4`}),g===`fix`?i===`zh`?`生成中…`:`Preparing…`:i===`zh`?`让 AI 修复`:`Ask AI to fix`]})]})}):null,v?(0,Z.jsx)(`p`,{className:`border-t border-danger/20 px-4 py-2 text-xs text-danger`,role:`alert`,children:v}):null]})}function mv(e){let t=(0,X.c)(8),{children:n,label:r,className:i}=e,a;t[0]===i?a=t[1]:(a=Y(`mt-2 w-full min-w-0 max-w-full self-start`,i),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,Z.jsx)(`div`,{className:`min-w-0`,children:n}),t[2]=n,t[3]=o);let s;return t[4]!==r||t[5]!==a||t[6]!==o?(s=(0,Z.jsx)(`section`,{className:a,"aria-label":r,"data-turn-tail":!0,children:o}),t[4]=r,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function hv(e){return{id:e.artifactId,name:e.title,type:e.kind,mimeType:e.mimeType,size:e.sizeBytes,uri:e.uri,workspaceRelativePath:e.workspaceRelativePath}}function gv(e){let t=e.mimeType?.toLowerCase()??``,n=e.type?.toLowerCase()??``;return t.startsWith(`image/`)||n===`image`?we:t.startsWith(`audio/`)||n===`audio`||n===`voice`?ls:t.startsWith(`video/`)||n===`video`?ge:t.includes(`spreadsheet`)||[`spreadsheet`,`csv`,`xlsx`,`xls`].includes(n)?he:t.includes(`zip`)||[`archive`,`zip`].includes(n)?A:n===`site`?U:Te}function _v(e,t,n){return!!(e.uri||ai(e)||e.workspaceRelativePath?.trim()&&(t?.trim()||n?.trim()))}function vv(e){let t=(0,X.c)(43),{item:n,authToken:r,conversationId:i,projectId:a,onOpen:o}=e,s=h(yv),c;t[0]===s?c=t[1]:(c=y(s),t[0]=s,t[1]=c);let l=c.chat.productDelivery.kinds.file,u;t[2]!==r||t[3]!==i?(u={authToken:r,conversationId:i},t[2]=r,t[3]=i,t[4]=u):u=t[4];let d=lm(n.attachment,u),f;t[5]===n.attachment?f=t[6]:(f=gv(n.attachment),t[5]=n.attachment,t[6]=f);let p=f,m;t[7]!==i||t[8]!==n.attachment||t[9]!==a?(m=_v(n.attachment,i,a),t[7]=i,t[8]=n.attachment,t[9]=a,t[10]=m):m=t[10];let g=m,_=g||!!n.href,v;t[11]!==p||t[12]!==d.src||t[13]!==n.failed?(v=d.src?(0,Z.jsx)(`img`,{src:d.src,alt:``,className:`size-[18px] rounded object-cover`,decoding:`async`,loading:`lazy`}):(0,Z.jsx)(p,{strokeWidth:1.75,className:n.failed?`text-danger`:void 0}),t[11]=p,t[12]=d.src,t[13]=n.failed,t[14]=v):v=t[14];let b=n.attachment.name??l,x;t[15]===_?x=t[16]:(x=_?(0,Z.jsx)(te,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}):null,t[15]=_,t[16]=x);let S;t[17]!==n.meta||t[18]!==v||t[19]!==b||t[20]!==x?(S=(0,Z.jsx)(Po,{icon:v,title:b,meta:n.meta,trailing:x}),t[17]=n.meta,t[18]=v,t[19]=b,t[20]=x,t[21]=S):S=t[21];let C=S,w=_?`cursor-pointer`:`cursor-default`,T;t[22]===w?T=t[23]:(T=Y(Mo,w),t[22]=w,t[23]=T);let E=T,D=n.attachment.name??l,O;t[24]!==n.meta||t[25]!==D?(O=[D,n.meta],t[24]=n.meta,t[25]=D,t[26]=O):O=t[26];let k=O.join(` · `);if(!g&&n.href){let e;return t[27]!==E||t[28]!==C||t[29]!==n.href||t[30]!==k?(e=(0,Z.jsx)(`li`,{className:`min-w-0 max-w-full`,"data-result-attachment":!0,children:(0,Z.jsx)(`a`,{title:k,href:n.href,target:`_blank`,rel:`noreferrer`,className:E,children:C})}),t[27]=E,t[28]=C,t[29]=n.href,t[30]=k,t[31]=e):e=t[31],e}if(!g){let e;return t[32]!==E||t[33]!==C?(e=(0,Z.jsx)(`li`,{className:E,"data-result-attachment":!0,children:C}),t[32]=E,t[33]=C,t[34]=e):e=t[34],e}let A;t[35]!==n.attachment||t[36]!==o?(A=()=>o(n.attachment),t[35]=n.attachment,t[36]=o,t[37]=A):A=t[37];let j;return t[38]!==E||t[39]!==C||t[40]!==A||t[41]!==k?(j=(0,Z.jsx)(`li`,{className:`min-w-0 max-w-full`,"data-result-attachment":!0,children:(0,Z.jsx)(`button`,{type:`button`,className:E,title:k,onClick:A,children:C})}),t[38]=E,t[39]=C,t[40]=A,t[41]=k,t[42]=j):j=t[42],j}function yv(e){return e.language}function bv(e){let t=(0,X.c)(25),{attachments:n,authToken:r,conversationId:i,projectId:a,onOpen:o,language:s}=e,c;t[0]!==n.length||t[1]!==s?(c=y(s).chat.turnOutcome.fileCount.replace(`{{count}}`,String(n.length)),t[0]=n.length,t[1]=s,t[2]=c):c=t[2];let l=c,u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=Y(Mo,`cursor-pointer list-none`),t[3]=u):u=t[3];let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(fs,{strokeWidth:1.75}),t[4]=d):d=t[4];let f;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(te,{className:`size-3.5 shrink-0 text-fg-subtle transition-transform duration-150 group-open:rotate-90 motion-reduce:transition-none`,"aria-hidden":!0}),t[5]=f):f=t[5];let p;t[6]===l?p=t[7]:(p=(0,Z.jsx)(`summary`,{className:u,children:(0,Z.jsx)(Po,{icon:d,title:l,trailing:f})}),t[6]=l,t[7]=p);let m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m=Y(No,jo),t[8]=m):m=t[8];let h;if(t[9]!==n||t[10]!==r||t[11]!==i||t[12]!==o||t[13]!==a){let e;t[15]!==r||t[16]!==i||t[17]!==o||t[18]!==a?(e=e=>(0,Z.jsx)(vv,{item:e,authToken:r,conversationId:i,projectId:a,onOpen:o},e.key),t[15]=r,t[16]=i,t[17]=o,t[18]=a,t[19]=e):e=t[19],h=n.map(e),t[9]=n,t[10]=r,t[11]=i,t[12]=o,t[13]=a,t[14]=h}else h=t[14];let g;t[20]===h?g=t[21]:(g=(0,Z.jsx)(`ul`,{className:m,children:h}),t[20]=h,t[21]=g);let _;return t[22]!==p||t[23]!==g?(_=(0,Z.jsx)(`li`,{className:`min-w-0 max-w-full`,"data-result-attachment-group":!0,children:(0,Z.jsxs)(`details`,{className:`group`,children:[p,g]})}),t[22]=p,t[23]=g,t[24]=_):_=t[24],_}function xv(e,t){if(!e)return[];let n=y(t).chat.turnOutcome;return e.deliverables.map(e=>{let t=hv(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:oi(e.sizeBytes)].filter(Boolean).join(` · `)}})}function Sv(e,t){let n=y(t).chat.turnOutcome;return(e??[]).map((e,t)=>({key:`attachment:${e.id??e.uri??e.name??t}`,attachment:e,meta:[n.generatedFile,typeof e.size==`number`?oi(e.size):null].filter(Boolean).join(` · `)}))}function Cv(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 wv(e){let t=(0,X.c)(46),{view:n,authToken:r,conversationId:i,projectId:a}=e,o=h(kv)===`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=fm(s),l=n.deliveries.filter(Ov),u=A_(l),d=M_(l),f=N_(l),p=j_(l),m=(0,Q.useContext)(V_),g=new Set(Cv(n.outcome));if(m)for(let{delivery:e,reference:t}of P_(l))t.kind===`automation`&&!t.runId&&e.operation!==`failed`&&g.add(`automation:${t.id}`);let _=P_(l,g).length,v,b,x,S;if(t[3]!==o||t[4]!==c||t[5]!==n.attachments||t[6]!==n.outcome||t[7]!==n.resultRevision){v=[...xv(n.outcome,o),...Sv(n.attachments,o)];let e;t[12]!==n.outcome?.deliverables||t[13]!==n.resultRevision?(e=e=>!!(n.resultRevision&&n.outcome?.deliverables.some(t=>t.artifactId===e.id)),t[12]=n.outcome?.deliverables,t[13]=n.resultRevision,t[14]=e):e=t[14],b=e;let r;t[15]!==b||t[16]!==c||t[17]!==n.resultRevision?(r=e=>{c.openAttachment(e,b(e)?n.resultRevision:void 0)},t[15]=b,t[16]=c,t[17]=n.resultRevision,t[18]=r):r=t[18],x=r,S=v.filter(Dv),t[3]=o,t[4]=c,t[5]=n.attachments,t[6]=n.outcome,t[7]=n.resultRevision,t[8]=v,t[9]=b,t[10]=x,t[11]=S}else v=t[8],b=t[9],x=t[10],S=t[11];let C=S,w;t[19]!==v||t[20]!==C?(w=v.filter(e=>!C.includes(e)),t[19]=v,t[20]=C,t[21]=w):w=t[21];let T=w,E=_>0||T.length>0;if(u.length===0&&d.length===0&&f.length===0&&!E&&!C.length)return null;let D;t[22]!==r||t[23]!==i||t[24]!==C?(D=C.length>0?(0,Z.jsx)(xm,{attachments:C.map(Ev),authToken:r,conversationId:i,workspaceConversationId:i,layout:`assistant`}):null,t[22]=r,t[23]=i,t[24]=C,t[25]=D):D=t[25];let O=u.map(Tv),k;t[26]===o?k=t[27]:(k=e=>{let{key:t,presentation:n}=e;return(0,Z.jsx)(av,{previewId:`${t}:${n.reference.id}:${n.snapshot.sourceHash}`,reference:n.reference,sourceHash:n.snapshot.sourceHash,preferredHeight:n.preferredHeight,language:o},t)},t[26]=o,t[27]=k);let A=d.map(k),j;t[28]===o?j=t[29]:(j=e=>{let{key:t,presentation:n}=e;return(0,Z.jsx)(pv,{leaseId:`${t}:${n.reference.id}:${n.sourceHash}`,reference:n.reference,sourceHash:n.sourceHash,preferredHeight:n.preferredHeight,language:o},t)},t[28]=o,t[29]=j);let M=f.map(j),N=E?(0,Z.jsxs)(mv,{label:y(o).chat.productDelivery.heading,children:[(0,Z.jsxs)(`ul`,{className:No,children:[(0,Z.jsx)(Q_,{deliveries:l,language:o,excludedReferenceKeys:g,conversationId:i,projectId:a}),T.length>1?(0,Z.jsx)(bv,{attachments:T,authToken:r,conversationId:i,projectId:a,onOpen:x,language:o}):T.map(e=>(0,Z.jsx)(vv,{item:e,authToken:r,conversationId:i,projectId:a,onOpen:x},e.key))]}),p.truncated?(0,Z.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-fg-muted`,children:y(o).chat.productDelivery.partialResults}):null]}):null,P;t[30]!==T.length||t[31]!==r||t[32]!==i||t[33]!==b||t[34]!==c.active||t[35]!==c.closePreview||t[36]!==c.open||t[37]!==n.resultRevision?(P=T.length>0?(0,Z.jsx)(Zr,{open:c.open,attachment:c.active,resultRevision:c.active&&b(c.active)?n.resultRevision:void 0,authToken:r,conversationId:i,onClose:c.closePreview}):null,t[30]=T.length,t[31]=r,t[32]=i,t[33]=b,t[34]=c.active,t[35]=c.closePreview,t[36]=c.open,t[37]=n.resultRevision,t[38]=P):P=t[38];let F;return t[39]!==N||t[40]!==P||t[41]!==D||t[42]!==O||t[43]!==A||t[44]!==M?(F=(0,Z.jsxs)(Z.Fragment,{children:[D,O,A,M,N,P]}),t[39]=N,t[40]=P,t[41]=D,t[42]=O,t[43]=A,t[44]=M,t[45]=F):F=t[45],F}function Tv(e){let{key:t,presentation:n}=e;return(0,Z.jsx)(rv,{presentation:n},t)}function Ev(e){return e.attachment}function Dv(e){return!e.failed&&e.attachment.mimeType?.startsWith(`image/`)}function Ov(e){let{delivery:t}=e;return k_(t)}function kv(e){return e.language}function Av(e){let t=(0,X.c)(33),{outcome:n}=e,r=h(Nv),i,a,o,s,c,l,u,d;if(t[0]!==r||t[1]!==n.changeSet||t[2]!==n.evidence||t[3]!==n.status||t[4]!==n.summary){d=Symbol.for(`react.early_return_sentinel`);bb0:{if(o=y(r).chat.turnOutcome,i=!!n.changeSet,a=n.evidence.length>0,!i&&!a){d=n.status===`failed`?(0,Z.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:n.summary||o.statusFailed}):null;break bb0}let e=n.evidence.filter(Mv).length,f=n.evidence.filter(jv).length,p=n.status===`succeeded`?o.statusSucceeded:n.status===`failed`?o.statusFailed:o.statusPartial,m=n.status===`succeeded`?G:n.status===`failed`?pe:K,h=[n.changeSet?o.changedFileCount.replace(`{{count}}`,String(n.changeSet.files.length)):null,e>0?o.passedCount.replace(`{{count}}`,String(e)):null,f>0?o.failedCount.replace(`{{count}}`,String(f)):null,a&&e===0&&f===0?o.evidenceCount.replace(`{{count}}`,String(n.evidence.length)):null].filter(Boolean).join(` · `);l=`group mt-2 min-w-0 max-w-full text-sm`;let g=n.status===`succeeded`?`text-success`:n.status===`failed`?`text-danger`:`text-warning`,_;t[13]!==m||t[14]!==g?(_=(0,Z.jsx)(m,{className:g,"aria-hidden":!0}),t[13]=m,t[14]=g,t[15]=_):_=t[15];let v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(te,{className:`size-3.5 shrink-0 text-fg-subtle transition-transform group-open:rotate-90 motion-reduce:transition-none`,strokeWidth:1.75,"aria-hidden":!0}),t[16]=v):v=t[16],u=(0,Z.jsx)(`summary`,{className:`${Mo} cursor-pointer list-none`,title:`${p} · ${h}`,children:(0,Z.jsx)(Po,{icon:_,title:p,meta:h,trailing:v})}),s=jo,c=n.changeSet?(0,Z.jsxs)(`section`,{"aria-label":o.changes,children:[(0,Z.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:o.changeSetTitle}),(0,Z.jsx)(`span`,{className:`shrink-0 text-fg-subtle`,children:o.changeStats.replace(`{{files}}`,String(n.changeSet.files.length)).replace(`{{added}}`,String(n.changeSet.added)).replace(`{{removed}}`,String(n.changeSet.removed))})]}),(0,Z.jsxs)(`div`,{className:`mt-2 border-t border-edge-subtle/70 pt-2`,children:[n.changeSet.files.slice(0,8).map(e=>(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 py-1 text-xs`,children:[(0,Z.jsx)(`span`,{className:`w-14 shrink-0 text-fg-subtle`,children:o.fileStatus[e.status??`modified`]}),(0,Z.jsx)(`code`,{className:`min-w-0 truncate text-fg-muted`,children:e.path})]},e.path)),n.changeSet.files.length>8?(0,Z.jsx)(`div`,{className:`pt-1 text-xs text-fg-subtle`,children:o.moreFiles.replace(`{{count}}`,String(n.changeSet.files.length-8))}):null]}),n.changeSet.diff?(0,Z.jsxs)(`details`,{className:`mt-2`,children:[(0,Z.jsx)(`summary`,{className:`w-fit cursor-pointer rounded-md px-1.5 py-1 text-xs font-medium text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:o.viewDiff}),n.changeSet.diffTruncated?(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-warning`,children:o.diffTruncated}):null,(0,Z.jsx)(`pre`,{className:`mt-2 max-h-72 overflow-auto rounded-lg bg-surface-inset p-3 text-xs leading-5 text-fg-muted`,children:(0,Z.jsx)(`code`,{children:n.changeSet.diff})})]}):null]}):null}t[0]=r,t[1]=n.changeSet,t[2]=n.evidence,t[3]=n.status,t[4]=n.summary,t[5]=i,t[6]=a,t[7]=o,t[8]=s,t[9]=c,t[10]=l,t[11]=u,t[12]=d}else i=t[5],a=t[6],o=t[7],s=t[8],c=t[9],l=t[10],u=t[11],d=t[12];if(d!==Symbol.for(`react.early_return_sentinel`))return d;let f;t[17]!==i||t[18]!==a?(f=i&&a?(0,Z.jsx)(`div`,{className:`my-2 border-t border-edge-subtle`}):null,t[17]=i,t[18]=a,t[19]=f):f=t[19];let p;t[20]!==a||t[21]!==n.evidence||t[22]!==o?(p=a?(0,Z.jsxs)(`section`,{"aria-label":o.evidence,children:[(0,Z.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg`,children:o.evidence}),n.evidence.map(e=>(0,Z.jsxs)(`div`,{className:`flex min-h-10 items-center gap-2.5 border-b border-edge-subtle/60 py-1.5 last:border-b-0`,children:[(0,Z.jsx)(Ke,{className:e.status===`passed`?`size-4 shrink-0 text-success`:e.status===`failed`?`size-4 shrink-0 text-danger`:`size-4 shrink-0 text-warning`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:e.label}),(0,Z.jsx)(`span`,{className:e.status===`passed`?`text-xs font-medium text-success`:e.status===`failed`?`text-xs font-medium text-danger`:`text-xs font-medium text-warning`,children:e.status===`passed`?o.passed:e.status===`failed`?o.failed:o.warning})]},e.evidenceId))]}):null,t[20]=a,t[21]=n.evidence,t[22]=o,t[23]=p):p=t[23];let m;t[24]!==s||t[25]!==c||t[26]!==f||t[27]!==p?(m=(0,Z.jsxs)(`div`,{className:s,children:[c,f,p]}),t[24]=s,t[25]=c,t[26]=f,t[27]=p,t[28]=m):m=t[28];let g;return t[29]!==l||t[30]!==u||t[31]!==m?(g=(0,Z.jsxs)(`details`,{className:l,children:[u,m]}),t[29]=l,t[30]=u,t[31]=m,t[32]=g):g=t[32],g}function jv(e){return e.status===`failed`}function Mv(e){return e.status===`passed`}function Nv(e){return e.language}function Pv(e){let t=(0,X.c)(14),{view:n,authToken:r,conversationId:i,projectId:a,sourcesLabel:o}=e,s;t[0]!==r||t[1]!==i||t[2]!==a||t[3]!==n?(s=(0,Z.jsx)(wv,{view:n,authToken:r,conversationId:i,projectId:a}),t[0]=r,t[1]=i,t[2]=a,t[3]=n,t[4]=s):s=t[4];let c;t[5]===n.outcome?c=t[6]:(c=n.outcome?(0,Z.jsx)(Av,{outcome:n.outcome}):null,t[5]=n.outcome,t[6]=c);let l;t[7]!==o||t[8]!==n.sources?(l=n.sources.length>0?(0,Z.jsxs)(`details`,{className:`group min-w-0 max-w-full`,"aria-label":o,children:[(0,Z.jsx)(`summary`,{className:`${Mo} cursor-pointer list-none`,children:(0,Z.jsx)(Po,{icon:(0,Z.jsx)(Ne,{}),title:o,trailing:(0,Z.jsx)(te,{className:`size-3.5 shrink-0 text-fg-subtle transition-transform group-open:rotate-90 motion-reduce:transition-none`,"aria-hidden":!0})})}),(0,Z.jsx)(`div`,{className:jo,children:(0,Z.jsx)(L_,{sources:n.sources,className:``})})]}):null,t[7]=o,t[8]=n.sources,t[9]=l):l=t[9];let u;return t[10]!==s||t[11]!==c||t[12]!==l?(u=(0,Z.jsxs)(Z.Fragment,{children:[s,c,l]}),t[10]=s,t[11]=c,t[12]=l,t[13]=u):u=t[13],u}var Fv=`NO_REPLY`;function Iv(e,t){if(e.role!==`assistant`||!e.content?.length)return e;if(t?.hideSilentReply){let n=e.content.filter(e=>e.type!==`text`||e.text.trim()!==Fv);if(n.length!==e.content.length)return Iv({...e,content:n},t)}let n=e.content.findIndex(e=>e.type===`text`);if(n<0)return e;let r=e.content[n];if(r.type!==`text`)return e;let i=r.text.trimStart();if(t?.hideSilentReply&&(i===Fv||t.streaming&&i.length>0&&Fv.startsWith(i)))return{...e,content:e.content.filter((e,t)=>t!==n)};if(!i.startsWith(Fv))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 Lv(e,t){return t||e.workLog.items.some(e=>e.type===`tool_use`&&(e.status===`error`||e.activity?.status===`failed`))}function Rv(e,t){if(e.role!==`assistant`||t.isStreaming||t.followUpTrigger)return!0;let n=I_({message:Iv(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||Lv(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 zv(e,t){let n=In(e.content).some(e=>e.type===`review`&&(!e.status||e.status===`complete`)||e.type===`text`&&!!e.text.trim()),r=e.fromHistory&&n,i=e.outcome??e.taskResultDelivery?.outcome,a=!t&&e.runStatus!==`suspended`&&!!(e.runStatus||i||r),o=e.runStatus===`error`||e.runStatus===`cancelled`||i?.status===`failed`;return{settled:a,defaultCollapsed:a&&n&&!o,outcome:i}}function Bv(e){let t=(0,X.c)(17),{message:n,isStreaming:r,enabled:i,items:a,durationMs:o}=e,s=(0,Q.useRef)(null),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(null),f=h(Vv),p=y(f).chat,m;t[0]!==r||t[1]!==n?(m=zv(n,r),t[0]=r,t[1]=n,t[2]=m):m=t[2];let g=m,_=i&&g.settled&&a.length>0,v,b;t[3]===r?(v=t[4],b=t[5]):(v=()=>{r&&d(null)},b=[r],t[3]=r,t[4]=v,t[5]=b),(0,Q.useEffect)(v,b);let x,S;t[6]!==i||t[7]!==a.length?(x=()=>{if(!i||a.length===0)return;let e=()=>{let e=window.getSelection();l(!!(s.current&&[...s.current.querySelectorAll(`[data-assistant-process-item]`)].some(t=>e&&!e.isCollapsed&&e.containsNode(t,!0)||t.contains(document.activeElement))))};return e(),document.addEventListener(`selectionchange`,e),document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,e),()=>{document.removeEventListener(`selectionchange`,e),document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,e)}},S=[i,a.length],t[6]=i,t[7]=a.length,t[8]=x,t[9]=S):(x=t[8],S=t[9]),(0,Q.useEffect)(x,S);let C=u??(!g.defaultCollapsed||c),w=o==null?null:Ng(o,f),T=n.runStatus===`cancelled`?p.processStopped:n.runStatus===`error`||g.outcome?.status===`failed`?p.processFailed:g.outcome?.status===`partial`?p.processPartial:null,E=T?`${T}${w?` · ${w}`:``}`:w?p.processWorkedFor.replace(`{{duration}}`,w):p.processView,D=_&&!C,O;t[10]!==C||t[11]!==E||t[12]!==_?(O=_?(0,Z.jsxs)(`button`,{type:`button`,"data-assistant-process-toggle":!0,"aria-expanded":C,onClick:()=>d(!C),className:`flex min-h-11 w-full items-center gap-1.5 border-b border-edge-subtle py-2 text-left text-sm text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,children:[(0,Z.jsx)(`span`,{children:E}),(0,Z.jsx)(te,{"aria-hidden":!0,className:`size-4 shrink-0 transition-transform motion-reduce:transition-none ${C?`rotate-90`:``}`})]}):null,t[10]=C,t[11]=E,t[12]=_,t[13]=O):O=t[13];let k;return t[14]!==D||t[15]!==O?(k={contentRef:s,collapsed:D,summary:O},t[14]=D,t[15]=O,t[16]=k):k=t[16],k}function Vv(e){return e.language}function Hv(e,t=!1){return t||e.textSurface===`conversation`}function Uv(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 Wv(e){let t=(0,X.c)(23),{trigger:n}=e,r=c(),i=h(Gv),a;t[0]===i?a=t[1]:(a=y(i),t[0]=i,t[1]=a);let o=a.chat.taskTrigger,s=n.entryId,l;t[2]===o.about?l=t[3]:(l=(0,Z.jsx)(`span`,{className:`shrink-0`,children:o.about}),t[2]=o.about,t[3]=l);let d=`${r.pathname}${r.search}`,f;t[4]!==d||t[5]!==n.taskId?(f=et(d,n.taskId),t[4]=d,t[5]=n.taskId,t[6]=f):f=t[6];let p=n.taskTitle,m=`${o.openTask}:${n.taskTitle}`,g;t[7]===n.taskTitle?g=t[8]:(g=Uv(n.taskTitle),t[7]=n.taskTitle,t[8]=g);let _;t[9]===g?_=t[10]:(_=(0,Z.jsxs)(`span`,{className:`truncate`,children:[`「`,g,`」`]}),t[9]=g,t[10]=_);let v;t[11]!==f||t[12]!==m||t[13]!==_||t[14]!==n.taskTitle?(v=(0,Z.jsx)(u,{className:`inline-flex min-w-0 max-w-[min(48vw,30rem)] font-medium text-fg hover:text-accent hover:underline`,to:f,title:p,"aria-label":m,children:_}),t[11]=f,t[12]=m,t[13]=_,t[14]=n.taskTitle,t[15]=v):v=t[15];let b=o[n.kind],x;t[16]===b?x=t[17]:(x=(0,Z.jsxs)(`span`,{className:`shrink-0 whitespace-nowrap`,children:[`· `,b]}),t[16]=b,t[17]=x);let S;return t[18]!==v||t[19]!==x||t[20]!==l||t[21]!==n.entryId?(S=(0,Z.jsxs)(`div`,{className:`mb-4 flex min-w-0 max-w-full items-center gap-1.5 border-t border-edge-subtle pt-5 text-sm text-fg-muted`,"data-task-trigger":s,children:[l,v,x]}),t[18]=v,t[19]=x,t[20]=l,t[21]=n.entryId,t[22]=S):S=t[22],S}function Gv(e){return e.language}var Kv=3;function qv(e){let t=(0,X.c)(36),{refs:n,groupLabel:r,noteLabel:i,fileLabel:a,folderLabel:o,sessionLabel:s,browserTabLabel:c,mcpResourceLabel:l,truncatedLabel:u,showMoreLabel:d,showLessLabel:f,onOpen:p}=e,[m,h]=(0,Q.useState)(!1);if(n.length===0)return null;let g=n.length>Kv,_;t[0]!==m||t[1]!==n?(_=m?n:n.slice(0,Kv),t[0]=m,t[1]=n,t[2]=_):_=t[2];let v=_,y=n.length-Kv,b;if(t[3]!==c||t[4]!==a||t[5]!==o||t[6]!==r||t[7]!==l||t[8]!==i||t[9]!==p||t[10]!==s||t[11]!==u||t[12]!==v){let e;t[14]!==c||t[15]!==a||t[16]!==o||t[17]!==r||t[18]!==l||t[19]!==i||t[20]!==p||t[21]!==s||t[22]!==u?(e=e=>{let t=e.kind===`note`,n=t?`button`:`div`,d=e.kind===`result`?a:e.kind===`file`?e.fileKind===`directory`?o:a:e.kind===`session`?s:e.kind===`browser_tab`?c:e.kind===`mcp_resource`?l:i;return(0,Z.jsxs)(n,{...t?{type:`button`,onClick:()=>p(e)}:{},className:Y(`group inline-flex min-h-9 min-w-0 max-w-full items-center gap-2 rounded-lg border border-edge-subtle bg-surface-panel/80 px-2 py-1.5 text-left`,t&&`transition-colors hover:border-accent/40 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),...t?{"aria-label":`${r}: ${e.title}`}:{},title:e.truncated?u:e.title,children:[(0,Z.jsx)(`span`,{className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md bg-accent-soft text-accent-fg`,children:e.kind===`file`&&e.fileKind===`directory`?(0,Z.jsx)(Oe,{className:`size-3.5`,"aria-hidden":!0}):e.kind===`file`||e.kind===`result`?(0,Z.jsx)(Te,{className:`size-3.5`,"aria-hidden":!0}):e.kind===`session`?(0,Z.jsx)(bt,{className:`size-3.5`,"aria-hidden":!0}):e.kind===`browser_tab`?(0,Z.jsx)(k,{className:`size-3.5`,"aria-hidden":!0}):e.kind===`mcp_resource`?(0,Z.jsx)(ye,{className:`size-3.5`,"aria-hidden":!0}):(0,Z.jsx)(xs,{className:`size-3.5`,"aria-hidden":!0})}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`shrink-0 text-[11px] text-fg-muted`,children:d}),(0,Z.jsx)(`span`,{className:`max-w-56 truncate text-xs font-medium text-fg sm:max-w-72`,children:e.title})]}),t?(0,Z.jsx)(te,{className:`size-3.5 shrink-0 text-fg-disabled transition-transform group-hover:translate-x-0.5 group-hover:text-fg-muted`,"aria-hidden":!0}):null]},`${e.kind}:${e.sourceId}`)},t[14]=c,t[15]=a,t[16]=o,t[17]=r,t[18]=l,t[19]=i,t[20]=p,t[21]=s,t[22]=u,t[23]=e):e=t[23],b=v.map(e),t[3]=c,t[4]=a,t[5]=o,t[6]=r,t[7]=l,t[8]=i,t[9]=p,t[10]=s,t[11]=u,t[12]=v,t[13]=b}else b=t[13];let x;t[24]===b?x=t[25]:(x=(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-wrap gap-1.5`,children:b}),t[24]=b,t[25]=x);let S;t[26]!==g||t[27]!==m||t[28]!==y||t[29]!==f||t[30]!==d?(S=g?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-8 w-fit items-center gap-1 rounded-md px-2 text-xs text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-expanded":m,onClick:()=>h(Jv),children:[m?(0,Z.jsx)(ne,{className:`size-3.5`,"aria-hidden":!0}):(0,Z.jsx)(ee,{className:`size-3.5`,"aria-hidden":!0}),m?f:d.replace(`{{count}}`,String(y))]}):null,t[26]=g,t[27]=m,t[28]=y,t[29]=f,t[30]=d,t[31]=S):S=t[31];let C;return t[32]!==r||t[33]!==x||t[34]!==S?(C=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,role:`group`,"aria-label":r,children:[x,S]}),t[32]=r,t[33]=x,t[34]=S,t[35]=C):C=t[35],C}function Jv(e){return!e}function Yv(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 Xv(e){let t=(0,X.c)(67),{open:n,onOpenChange:r,items:i,labels:a}=e,o;t[0]!==i||t[1]!==a.origins?(o=Yv(i,a.origins),t[0]=i,t[1]=a.origins,t[2]=o):o=t[2];let s=o,c=s.reduce(ey,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($v):[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(Qv)))},t[12]=h,t[13]=s,t[14]=g):g=t[14];let _=g,v;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(v=e=>{d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},t[15]=v):v=t[15];let y=v,x;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim/60 backdrop-blur-[1px]`}),t[16]=x):x=t[16];let O;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(O=Y(`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(36rem,calc(100dvh-2rem))]`,`w-[min(42rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-popover outline-none`),t[17]=O):O=t[17];let k;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,Z.jsx)(`span`,{className:`mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-lg bg-accent-soft text-accent-fg`,children:(0,Z.jsx)(ss,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[18]=k):k=t[18];let A;t[19]===a.title?A=t[20]:(A=(0,Z.jsx)(E,{className:`text-base font-semibold text-fg`,children:a.title}),t[19]=a.title,t[20]=A);let j;t[21]===a.hint?j=t[22]:(j=(0,Z.jsx)(S,{className:`mt-1 text-sm leading-5 text-fg-muted`,children:a.hint}),t[21]=a.hint,t[22]=j);let M;t[23]!==c||t[24]!==a.itemsSummary?(M=a.itemsSummary.replace(`{{count}}`,String(c)),t[23]=c,t[24]=a.itemsSummary,t[25]=M):M=t[25];let N;t[26]===M?N=t[27]:(N=(0,Z.jsx)(`p`,{className:`mt-2 text-xs font-medium text-fg-subtle`,children:M}),t[26]=M,t[27]=N);let P;t[28]!==A||t[29]!==j||t[30]!==N?(P=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[A,j,N]}),t[28]=A,t[29]=j,t[30]=N,t[31]=P):P=t[31];let F;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Z.jsx)(Gt,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[32]=F):F=t[32];let I;t[33]===a.close?I=t[34]:(I=(0,Z.jsx)(C,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors duration-150 hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":a.close,title:a.close,children:F})}),t[33]=a.close,t[34]=I);let L;t[35]!==P||t[36]!==I?(L=(0,Z.jsxs)(`header`,{className:`flex shrink-0 items-start gap-3 border-b border-edge-subtle px-4 py-4 sm:px-5`,children:[k,P,I]}),t[35]=P,t[36]=I,t[37]=L):L=t[37];let R;t[38]!==s.length||t[39]!==a.groupSummary?(R=a.groupSummary.replace(`{{count}}`,String(s.length)),t[38]=s.length,t[39]=a.groupSummary,t[40]=R):R=t[40];let z;t[41]===R?z=t[42]:(z=(0,Z.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:R}),t[41]=R,t[42]=z);let B;t[43]!==h||t[44]!==s.length||t[45]!==a.collapseAll||t[46]!==a.expandAll||t[47]!==_?(B=s.length>1?(0,Z.jsx)(`button`,{type:`button`,className:`rounded-md px-2 py-1 text-xs font-medium text-accent-fg transition-colors duration-150 hover:bg-accent-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:_,children:h?a.collapseAll:a.expandAll}):null,t[43]=h,t[44]=s.length,t[45]=a.collapseAll,t[46]=a.expandAll,t[47]=_,t[48]=B):B=t[48];let V;t[49]!==z||t[50]!==B?(V=(0,Z.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center justify-between gap-3 border-b border-edge-subtle px-4 sm:px-5`,children:[z,B]}),t[49]=z,t[50]=B,t[51]=V):V=t[51];let H;if(t[52]!==u||t[53]!==s){let e;t[55]===u?e=t[56]:(e=e=>{let t=u.has(e.id);return(0,Z.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`flex min-h-12 w-full items-center gap-3 px-3.5 py-2.5 text-left transition-colors duration-150 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,"aria-expanded":t,onClick:()=>y(e.id),children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-fg`,children:e.label}),(0,Z.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] tabular-nums text-fg-muted`,children:e.items.length}),(0,Z.jsx)(ee,{className:Y(`size-4 shrink-0 text-fg-subtle transition-transform duration-200`,t&&`rotate-180`),strokeWidth:1.75,"aria-hidden":!0})]}),t?(0,Z.jsx)(`div`,{className:`border-t border-edge-subtle px-3.5`,children:e.items.map(Zv)}):null]},e.id)},t[55]=u,t[56]=e),H=s.map(e),t[52]=u,t[53]=s,t[54]=H}else H=t[54];let U;t[57]===H?U=t[58]:(U=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-3 py-3 sm:px-4`,"data-testid":`response-context-scroll-region`,children:(0,Z.jsx)(`div`,{className:`space-y-2`,children:H})}),t[57]=H,t[58]=U);let W;t[59]!==L||t[60]!==V||t[61]!==U?(W=(0,Z.jsxs)(w,{children:[x,(0,Z.jsxs)(T,{className:O,children:[L,V,U]})]}),t[59]=L,t[60]=V,t[61]=U,t[62]=W):W=t[62];let G;return t[63]!==r||t[64]!==n||t[65]!==W?(G=(0,Z.jsx)(D,{open:n,onOpenChange:r,children:W}),t[63]=r,t[64]=n,t[65]=W,t[66]=G):G=t[66],G}function Zv(e){return(0,Z.jsx)(`p`,{className:`border-b border-edge-subtle py-3 text-sm leading-6 text-fg last:border-b-0`,children:e.statement},e.id)}function Qv(e){return e.id}function $v(e){return e.id}function ey(e,t){return e+t.items.length}var ty=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`,ca.disabled),ny=[`misunderstood_intent`,`incorrect`,`did_not_act`,`tone_mismatch`,`too_verbose`,`other`],ry=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`,ca.disabled),iy=700,ay=120,oy=(0,Q.memo)(function({message:e,personal:t=!1,followUpTrigger:n,authToken:r,conversationId:i,workspaceConversationId:a,projectId:o,isStreaming:s,progress:l,reasoningLevel:u=`on`,messageIndex:f,onDeleteRound:m,onRetryUserMessageRound:_,userMessageCanRetry:v=!1,deleteRoundDisabled:b=!1,onSaveAssistantAsNote:x,onSaveAssistantToSourceNote:S,onExtractAssistantTask:C,onForkAssistantTurn:w,readonly:T=!1,density:E=`normal`,suppressAssistantActions:D=!1,onEditUserMessage:O,userMessageCanEdit:k=!0,responseFeedbackEnabled:A=!0,showAssistantWorkLog:j=!0}){let M=(0,Q.useMemo)(()=>Iv(e,{hideSilentReply:Hv(e,t),streaming:s}),[e,t,s]),N=h(e=>e.language),I=y(N),L=d(),B=c(),H=M.role===`user`,U=M.role===`assistant`,W=(0,Q.useRef)(H&&M.deliveryStatus===`sending`).current,te=H&&M.deliveryStatus===`sending`,re=H&&M.deliveryStatus===`failed`,[ie,ae]=(0,Q.useState)(!1),[oe,se]=(0,Q.useState)(!1),[ce,le]=(0,Q.useState)(()=>typeof navigator<`u`&&navigator.onLine===!1),ue=H?I.chat.you:U?I.chat.assistant:I.chat.tool;(0,Q.useEffect)(()=>{if(!te||typeof window>`u`)return;let e=()=>le(window.navigator.onLine===!1);return window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}},[te]),(0,Q.useEffect)(()=>{if(te){if(ie)return;let e=window.setTimeout(()=>ae(!0),ce?0:iy);return()=>window.clearTimeout(e)}if(!ie)return;let e=0,t=window.requestAnimationFrame(()=>{se(!0),e=window.setTimeout(()=>{ae(!1),se(!1)},ay)});return()=>{window.cancelAnimationFrame(t),window.clearTimeout(e)}},[te,ce,ie]);let q=re||ie,de=re?`failed`:`sending`,fe=(0,Q.useCallback)(e=>{let t=`${B.pathname}${B.search}`;L(tt(t,e))},[B.pathname,B.search,L]),pe=(0,Q.useMemo)(()=>({input:I.chat.toolInput,output:I.chat.toolOutput,noOutput:I.chat.noOutput}),[I.chat.toolInput,I.chat.toolOutput,I.chat.noOutput]),J=(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]),me=(0,Q.useMemo)(()=>({ing:I.chat.stepsClusterIng}),[I.chat.stepsClusterIng]),he=(0,Q.useMemo)(()=>I.chat.toolCard,[I.chat.toolCard]),ge=u===`off`,_e=(0,Q.useMemo)(()=>U?I_({message:M,isStreaming:s,reasoningLevel:u,personal:t}):null,[U,s,M,u,t]),ye=(0,Q.useMemo)(()=>{if(!_e)return(M.content??[]).filter(e=>e.type!==`image`);if(t)return _e.answerContent;if(!ge&&j)return(M.content??[]).filter(e=>e.type!==`image`);let e=new Set(_e.answerContent);return(M.content??[]).filter(t=>e.has(t)||t.type===`tool_use`&&(t.status===`error`||t.activity?.status===`failed`))},[_e,M.content,t,ge,j]),xe=(0,Q.useMemo)(()=>_e?_e.attachments:M.attachments,[_e,M.attachments]),Ce=U&&!t&&!ge&&j,we=Bv({message:M,isStreaming:s,enabled:Ce,items:_e?.workLog.items??[],durationMs:M.completedAt==null?void 0:_e?.workLog.durationMs}),Ee=(0,Q.useMemo)(()=>Ce?new Set(_e?.workLog.items):void 0,[Ce,_e]),De=(0,Q.useMemo)(()=>{let e=new Set(M.userTurnDocument?.parts.flatMap(e=>e.type===`context_ref`?[e.refId]:[])??[]);return M.contextRefs?.filter(t=>!t.refId||!e.has(t.refId))},[M.contextRefs,M.userTurnDocument]),Oe=!!(_e?.workLog.active||_e?.workLog.items.length),ke=!!_e?.answer.started,Ae=ge||U&&(Oe||ke)?null:l,je=!ge&&!!M.content?.some(e=>e.type===`thinking`&&e.streaming),Me=U?!!_e?.answer.showStreamingCursor:s,Ne=t&&U&&s&&!_e?.answer.started&&!xe?.length,Pe=s&&!je&&(!U||!Oe&&!ke),Fe=!!Ae?.message||Pe,Ie=U&&!T&&!s&&!D,Le=U&&s&&!T&&!D&&ke,Re=(0,Q.useMemo)(()=>Ie?Em(M.content??[]):``,[Ie,M]),ze=(0,Q.useMemo)(()=>Ie&&Re?Om(M.content??[]):``,[Ie,Re,M]),Be=(0,Q.useMemo)(()=>Ie&&Re?z(Re):``,[Ie,Re]),Ve=(0,Q.useMemo)(()=>({source:{type:`chat-message`,id:`${i??`chat`}:${M.timestamp??f??Re.length}`,title:Be.split(`
59
+ `)[0]?.slice(0,48)||I.chat.messageReadAloudTitle,href:i?`#/chat/${encodeURIComponent(i)}`:void 0,targetId:f==null?void 0:`chat-message-${f}`},text:Be,language:F(Be,N)}),[Re.length,N,I.chat.messageReadAloudTitle,M.timestamp,f,i,Be]),He=(0,Q.useMemo)(()=>{if(!H)return``;if(M.userTurnDocument){let e=new Map(M.contextRefs?.flatMap(e=>e.refId?[[e.refId,e.title]]:[])??[]);return br(M.userTurnDocument,t=>e.get(t))}return Rn(M.content)},[H,M.content,M.contextRefs,M.userTurnDocument]),[Ue,We]=(0,Q.useState)(null),[Ge,Ke]=(0,Q.useState)(!1),[Je,Ye]=(0,Q.useState)(null),[Xe,Ze]=(0,Q.useState)(null),[Qe,$e]=(0,Q.useState)(!1),[et,nt]=(0,Q.useState)(null),[rt,it]=(0,Q.useState)(!1),[at,ot]=(0,Q.useState)(!1),[st,ct]=(0,Q.useState)(!1),[lt,ut]=(0,Q.useState)(!1),[dt,ft]=(0,Q.useState)(null),[pt,mt]=(0,Q.useState)([]),[ht,gt]=(0,Q.useState)(!1),[_t,vt]=(0,Q.useState)(!1),[yt,bt]=(0,Q.useState)(null),[xt,St]=(0,Q.useState)(!1),[Ct,wt]=(0,Q.useState)(!1),Tt=(0,Q.useRef)(null),Et=(0,Q.useCallback)((e,t)=>{let n=wm(e,t);n&&bt(n)},[]),Ot=(0,Q.useCallback)(()=>{!i||!M.renderKey||Nn.getState().completeProgressiveRender(i,M.renderKey)},[M.renderKey,i]),kt=(0,Q.useCallback)(()=>{ze&&Ci(ze).then(e=>{e&&(We(`plain`),window.setTimeout(()=>We(e=>e===`plain`?null:e),2e3))})},[ze]),jt=(0,Q.useCallback)(()=>{Re&&Ci(Re).then(e=>{e&&(We(`markdown`),window.setTimeout(()=>We(e=>e===`markdown`?null:e),2e3))})},[Re]),Mt=(0,Q.useCallback)(()=>{!Re||!x||Xe||(Ze(`create-note`),Promise.resolve(x(Re)).then(()=>{Ye(`create-note`),window.setTimeout(()=>Ye(e=>e===`create-note`?null:e),2e3)}).catch(()=>void 0).finally(()=>Ze(null)))},[Xe,Re,x]),Nt=(0,Q.useCallback)(()=>{!Re||!S||Xe||(Ze(`save-source-note`),Promise.resolve(S(Re)).then(()=>{Ye(`save-source-note`),window.setTimeout(()=>Ye(e=>e===`save-source-note`?null:e),2e3)}).catch(()=>void 0).finally(()=>Ze(null)))},[Xe,Re,S]),Pt=(0,Q.useCallback)(()=>{!ze&&!Re||!C||Xe||(Ze(`extract-task`),Promise.resolve(C(ze||Re)).then(()=>{Ye(`extract-task`),window.setTimeout(()=>Ye(e=>e===`extract-task`?null:e),2e3)}).catch(()=>void 0).finally(()=>Ze(null)))},[Xe,Re,ze,C]),Ft=(0,Q.useCallback)(()=>{He&&Ci(He).then(e=>{e&&(We(`user`),window.setTimeout(()=>We(e=>e===`user`?null:e),2e3))})},[He]),It=(0,Q.useCallback)(()=>{!M.turnId||!w||Qe||($e(!0),Promise.resolve(w(M.turnId)).catch(()=>void 0).finally(()=>$e(!1)))},[Qe,M.turnId,w]),Lt=(0,Q.useCallback)((e,t)=>{!M.turnId||at||(ot(!0),it(!0),ct(!1),g(p(`/api/turns/${encodeURIComponent(M.turnId)}/execution-context/feedback`),{method:`POST`,body:JSON.stringify({rating:e===`helpful`?`helpful`:`irrelevant`,reason:t})}).then(()=>{nt(e),ft(t??null),ut(!1)}).catch(()=>ct(!0)).finally(()=>ot(!1)))},[M.turnId,at]),Rt=(0,Q.useCallback)(()=>{dt&&Wp(I.chat.messageFeedbackRepairPrompts[dt])},[I.chat.messageFeedbackRepairPrompts,dt]),zt=(0,Q.useCallback)(()=>{!M.turnId||rt||at||(ot(!0),g(p(`/api/turns/${encodeURIComponent(M.turnId)}/execution-context`)).then(e=>{mt(e.resolvedItems.filter(e=>e.included).map(e=>({id:`${e.objectType}:${e.objectId}`,statement:e.content,origin:e.origin,sourceName:e.sourceLabel})))}).catch(()=>void 0).finally(()=>{it(!0),ot(!1)}))},[M.turnId,at,rt]),Vt=(0,Q.useCallback)(()=>{f==null||!m||vt(!0)},[f,m]),Ht=(0,Q.useCallback)(()=>{f==null||!m||(m(f),vt(!1))},[f,m]),Ut=(0,Q.useCallback)(()=>{vt(!1)},[]);(0,Q.useLayoutEffect)(()=>{if(!H)return;let e=Tt.current;if(!e)return;let t=()=>{let t=window.getComputedStyle(e),n=Number.parseFloat(t.lineHeight),r=Number.parseFloat(t.fontSize)||14,i=Number.isFinite(n)?n:r*1.625;wt(e.scrollHeight>i*10+1)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[H,ye,He]),(0,Q.useLayoutEffect)(()=>{St(!1)},[H,He]);let Wt=b||!v,Gt=_e&&Lv(_e,j)&&(_e.workLog.active||_e.workLog.items.length>0)?(0,Z.jsx)(Ug,{workLog:_e.workLog,pendingStatus:M.pendingResponseStatus,toolLabels:pe,stepLabels:J,clusterLabels:me,cardLabels:he,conversationId:i,simplified:!t,personal:t,surfacesOnly:!t,answerStarted:_e.answer.started}):null;return(0,Z.jsx)(ld.Provider,{value:ud(_e?.deliveries??[]),children:(0,Z.jsxs)(`article`,{className:Y(`group/msg flex w-full min-w-0`,H?`justify-end`:`justify-start`,W&&`xopc-chat-user-message-enter`),children:[(0,Z.jsxs)(`div`,{className:Y(`min-w-0`,H?`flex w-full max-w-[min(78%,var(--max-width-chat-user))] flex-col items-end`:`w-full max-w-[var(--max-width-chat-reading)]`,T&&`max-w-full`),children:[(0,Z.jsx)(`span`,{className:`sr-only`,children:ue}),n?(0,Z.jsx)(Wv,{trigger:n}):null,H&&Fe?(0,Z.jsxs)(`div`,{className:`mb-2 flex w-full min-w-0 flex-wrap items-center justify-end gap-x-2 gap-y-0.5 text-xs`,children:[Ae?.message&&!Oe?(0,Z.jsx)(`span`,{className:`text-fg-subtle`,title:Ae.detail??``,children:Ae.message}):null,Pe&&!Ae?.message?(0,Z.jsx)(`span`,{className:`text-fg-subtle`,children:I.chat.thinkingLabel}):null]}):null,!H&&Fe&&!Ne?(0,Z.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-baseline gap-x-2 gap-y-0.5 text-xs text-fg-disabled`,children:[Ae?.message&&!Oe?(0,Z.jsx)(`span`,{className:`text-fg-subtle`,title:Ae.detail??``,children:Ae.message}):null,Pe&&!Ae?.message?(0,Z.jsx)(`span`,{className:`text-fg-subtle`,children:I.chat.thinkingLabel}):null]}):null,(0,Z.jsx)(`div`,{dir:H?`auto`:void 0,className:Y(`min-w-0 text-fg`,H&&`chat-user-message`,E===`compact`?`text-sm leading-relaxed`:H?`text-[0.9375rem] leading-[1.6667]`:`text-base leading-[1.6875]`,H&&`w-fit max-w-full rounded-2xl bg-surface-hover/80 px-4 py-3 text-left dark:bg-surface-hover/50`,Ne&&`bg-transparent p-0`),children:(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[Ne?(0,Z.jsx)(`div`,{className:`xopc-personal-thinking`,role:`status`,"aria-label":I.chat.thinkingLabel,children:(0,Z.jsxs)(`span`,{className:`xopc-personal-thinking-dots`,"aria-hidden":`true`,children:[(0,Z.jsx)(`i`,{}),(0,Z.jsx)(`i`,{}),(0,Z.jsx)(`i`,{})]})}):null,t?Gt:null,(ye?.length??0)>0?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{ref:H?Tt:we.contentRef,"data-chat-find-text":!0,className:Y(`relative min-w-0`,`flex flex-col gap-3`,H&&!xt&&`overflow-hidden`),style:H&&!xt?{maxHeight:`calc(10lh)`}:void 0,children:[we.summary,(0,Z.jsx)(Ah,{taskRunId:M.taskResultDelivery?.taskRunId,content:ye,isUser:H,isAssistantMessageStreaming:U&&s,imagePreviewLabel:I.chat.attachmentPreviewImage,onImagePreview:Et,conversationId:i,workspaceConversationId:a,projectId:o,progressiveRender:!!M.progressiveRender,onProgressiveRenderComplete:Ot,userTurnDocument:M.userTurnDocument,contextRefs:M.contextRefs,responseRunId:U?M.turnId:void 0,immediateFirstCommit:Hv(M,t),processItems:Ee,processCollapsed:we.collapsed,renderActivity:!t&&_e?(e,t)=>{let n=s&&(t||e.some(e=>e.type===`tool_use`&&e.status===`running`)),r=y_(e);return(0,Z.jsx)(Ug,{workLog:{items:e,active:n,status:n?`running`:e.some(e=>e.type===`tool_use`&&(e.status===`error`||e.activity?.status===`failed`))?`failed`:`completed`,compact:!1,expandedByDefault:u===`stream`&&n,startedAt:r.startedAt,durationMs:r.durationMs},toolLabels:pe,stepLabels:J,clusterLabels:me,cardLabels:he,conversationId:i,simplified:!1,showThinking:!0,renderSurfaces:!1})}:void 0}),Me?(0,Z.jsx)(`span`,{"aria-hidden":!0,"data-chat-streaming-cursor":!0,className:`pointer-events-none absolute start-0 top-full mt-1 h-3 w-0.5 bg-accent opacity-60`}):null]}),H&&Ct?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex w-fit items-center gap-1 rounded-md px-1.5 py-1 text-xs font-medium text-accent transition-colors hover:bg-accent/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,onClick:()=>St(e=>!e),"aria-expanded":xt,children:[xt?(0,Z.jsx)(ne,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(ee,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:xt?I.chat.userMessageCollapse:I.chat.userMessageExpand})]}):null]}):null,t?null:Gt,!t&&_e&&!_e.answer.started&&s&&!ye.some(e=>e.type===`thinking`||e.type===`tool_use`)?(0,Z.jsx)(Ug,{workLog:{items:[],active:!0,status:`running`,compact:!0,expandedByDefault:!1},pendingStatus:M.pendingResponseStatus,toolLabels:pe,stepLabels:J,clusterLabels:me,cardLabels:he,conversationId:i}):null,!t&&!H&&M.taskResultDelivery&&i?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,"data-result-follow-up":!0,children:[M.taskResultDelivery.resultRevision?(0,Z.jsxs)(`span`,{className:`text-xs text-fg-muted`,"data-result-revision":!0,children:[N===`zh`?`成果版本`:`Result version`,` `,M.taskResultDelivery.resultRevision]}):null,[{sourceId:`body`,title:M.taskResultDelivery.taskTitle},...M.taskResultDelivery.outcome.deliverables.filter(e=>e.availability===`available`).map(e=>({sourceId:e.artifactId,title:e.title}))].map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`max-w-64 truncate rounded-md border border-edge-subtle px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>{let t=M.taskResultDelivery;window.dispatchEvent(new CustomEvent(`chat-result-reference`,{detail:{conversationId:i,reference:{kind:`result`,sourceId:Ps(t.deliveryId.replace(/^reply:/,``),e.sourceId),expectedVersion:Fs(t),title:e.title}}}))},children:[N===`zh`?`询问:`:`Ask about: `,e.title]},e.sourceId))]}):null,_e?(0,Z.jsx)(Pv,{view:_e,authToken:r,conversationId:a??i,projectId:o,sourcesLabel:I.chat.searchSourcesHeading.replace(`{{count}}`,String(_e.sources.length))}):null,H&&M.sourceDevice?(0,Z.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[N===`zh`?`来自 `:`From `,M.sourceDevice.name]}):null,H&&De?.length?(0,Z.jsx)(qv,{refs:De,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,truncatedLabel:I.chat.commandPalette.contextTruncated,showMoreLabel:I.chat.contextReferencesMore,showLessLabel:I.chat.contextReferencesLess,onOpen:e=>fe(e.sourceId)}):null,H&&xe?.length?(0,Z.jsx)(xm,{attachments:xe,authToken:r,conversationId:i,workspaceConversationId:a,layout:`user`,centerUserVoiceRow:He.length===0}):null]})}),q?(0,Z.jsxs)(`div`,{"data-delivery-status":de,role:re?`alert`:`status`,"aria-live":`polite`,"aria-hidden":oe&&!re?!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`,re?`text-danger`:`text-fg-subtle`,oe&&!re&&`opacity-0`),children:[re?(0,Z.jsx)(K,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}):null,(0,Z.jsx)(`span`,{children:re?I.chat.userMessageSendFailed:ce&&te?I.chat.userMessageWaitingForNetwork:I.chat.userMessageSending}),re&&_&&f!=null?(0,Z.jsx)(`button`,{type:`button`,className:`rounded-md px-1.5 py-0.5 font-medium text-danger underline-offset-2 hover:bg-danger/10 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-danger/40`,onClick:()=>_(f),children:I.chat.userMessageRetry}):null]}):null,!H&&M.personalProvenance&&!s&&(0,Z.jsx)(sm,{provenance:M.personalProvenance}),H&&!s&&!T?(0,Z.jsxs)(`div`,{"data-user-message-actions":!0,className:Y(`mt-1 flex h-8 w-full min-w-0 shrink-0 items-center justify-end gap-0.5 sm:gap-2`,`pointer-events-none opacity-0 transition-opacity duration-150 ease-out`,`group-hover/msg:pointer-events-auto group-hover/msg:opacity-100`,`group-focus-within/msg:pointer-events-auto group-focus-within/msg:opacity-100`,`[@media(hover:none)_and_(pointer:coarse)]:pointer-events-auto [@media(hover:none)_and_(pointer:coarse)]:opacity-100`),children:[_&&f!=null&&M.deliveryStatus!==`failed`?(0,Z.jsxs)(`button`,{type:`button`,className:Y(ry,Wt&&`opacity-40`),onClick:()=>_(f),disabled:Wt,title:b?I.chat.userMessageActionsWait:v?I.chat.userMessageRetry:I.chat.userMessageRetryDisabledHint,"aria-label":I.chat.userMessageRetry,children:[(0,Z.jsx)(At,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`max-w-[4.5rem] truncate sm:max-w-none`,children:I.chat.userMessageRetry})]}):null,(0,Z.jsx)(`button`,{type:`button`,className:Y(ry,`size-8 px-0`),onClick:()=>{if(O&&f!=null){O(M,f);return}Wp(He,Ln(M.attachments))},disabled:!He&&!M.attachments?.length&&!M.contextRefs?.length||!k,title:k?b?I.chat.userMessageStopAndEdit:I.chat.userMessageEdit:I.chat.userMessageEditDisabledHint,"aria-label":I.chat.userMessageEdit,children:(0,Z.jsx)(Dt,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})}),(0,Z.jsx)(`button`,{type:`button`,className:Y(ry,`size-8 px-0`),onClick:Ft,disabled:!He,title:Ue===`user`?I.chat.messageCopied:I.chat.userMessageCopy,"aria-label":Ue===`user`?I.chat.messageCopied:I.chat.userMessageCopy,children:Ue===`user`?(0,Z.jsx)(G,{className:`size-3.5 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(ve,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})}),m&&f!=null&&!b?(0,Z.jsx)(`button`,{type:`button`,className:Y(ry,`size-8 px-0 hover:text-red-500 dark:hover:text-red-400`),onClick:Vt,title:I.chat.userMessageDelete,"aria-label":I.chat.userMessageDelete,children:(0,Z.jsx)(Bt,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})}):null]}):null,Le?(0,Z.jsx)(`div`,{"data-assistant-actions-placeholder":!0,className:`mt-1 min-h-9 shrink-0`,"aria-hidden":`true`}):null,Ie&&Re?(0,Z.jsx)(__,{children:(0,Z.jsxs)(`div`,{"data-assistant-message-actions":!0,className:Y(`mt-1 flex min-h-9 shrink-0 items-center gap-1 overflow-visible transition-opacity duration-150 ease-out motion-reduce:transition-none`,`pointer-events-none opacity-0 group-hover/msg:pointer-events-auto group-hover/msg:opacity-100`,`group-focus-within/msg:pointer-events-auto group-focus-within/msg:opacity-100`,`[@media(hover:none)_and_(pointer:coarse)]:pointer-events-auto [@media(hover:none)_and_(pointer:coarse)]:opacity-100`,(Ge||lt||st)&&`pointer-events-auto opacity-100`),children:[(0,Z.jsx)(v_,{label:Ue===`plain`?I.chat.messageCopied:I.chat.messageCopyPlainText,children:(0,Z.jsx)(`button`,{type:`button`,className:ty,onClick:kt,disabled:!ze,"aria-label":Ue===`plain`?I.chat.messageCopied:I.chat.messageCopyPlainText,children:Ue===`plain`?(0,Z.jsx)(G,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(ve,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})})}),(0,Z.jsx)(v_,{label:I.chat.messageReadAloud,children:(0,Z.jsx)(P,{input:Ve,labels:{read:I.chat.messageReadAloud,preparing:I.chat.messageReadAloudPreparing,pause:I.chat.messageReadAloudPause,resume:I.chat.messageReadAloudResume,retry:I.chat.messageReadAloudRetry},hideNativeTitle:!0})}),(0,Z.jsxs)(_i,{open:Ge,onOpenChange:e=>{Ke(e),e&&zt()},children:[(0,Z.jsx)(v_,{label:I.chat.messageMoreActions,children:(0,Z.jsx)(yi,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:ty,"aria-label":I.chat.messageMoreActions,children:(0,Z.jsx)(be,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})})})}),(0,Z.jsx)(hi,{children:(0,Z.jsxs)(gi,{side:`bottom`,align:`start`,sideOffset:6,className:`z-[70] w-56 rounded-xl border border-edge bg-surface-overlay p-1.5 shadow-popover outline-none`,children:[(0,Z.jsx)(vi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:jt,children:[Ue===`markdown`?(0,Z.jsx)(G,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(Se,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),Ue===`markdown`?I.chat.messageCopied:I.chat.messageCopyMarkdown]})}),w&&M.turnId?(0,Z.jsx)(vi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:It,disabled:Qe,children:[(0,Z.jsx)(ms,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),Qe?I.chat.messageForkCreating:I.chat.messageForkFromHere]})}):null,x?(0,Z.jsx)(vi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:Mt,disabled:Xe!==null,children:[Je===`create-note`?(0,Z.jsx)(G,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(ds,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),Je===`create-note`?I.chat.messageSavedToNote:I.chat.messageSaveToNote]})}):null,A&&i&&M.timestamp?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`my-1 border-t border-edge-subtle`,role:`separator`}),(0,Z.jsx)(vi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>Lt(`helpful`),disabled:at,"aria-pressed":et===`helpful`,children:[(0,Z.jsx)(R,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),I.chat.messageHelpful]})}),(0,Z.jsx)(vi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>ut(e=>!e),disabled:at,"aria-pressed":et===`not_helpful`,children:[(0,Z.jsx)(V,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),I.chat.messageNotHelpful]})})]}):null,st?(0,Z.jsx)(`p`,{className:`px-2.5 py-1 text-xs text-danger`,role:`status`,children:I.chat.messageFeedbackUnavailable}):null,pt.length>0?(0,Z.jsx)(vi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>gt(e=>!e),children:[(0,Z.jsx)(ss,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),I.chat.messageWhyThisAnswer]})}):null,S?(0,Z.jsx)(vi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-40`,onClick:Nt,disabled:!Re||Xe!==null,children:[Je===`save-source-note`?(0,Z.jsx)(G,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(Te,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),Je===`save-source-note`?I.chat.messageSavedToSourceNote:I.chat.messageSaveToSourceNote]})}):null,C?(0,Z.jsx)(vi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-40`,onClick:Pt,disabled:!ze&&!Re||Xe!==null,children:[Je===`extract-task`?(0,Z.jsx)(G,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(qe,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),Je===`extract-task`?I.chat.messageTaskExtracted:I.chat.messageExtractTask]})}):null]})})]})]})}):null,Ie&&pt.length>0?(0,Z.jsx)(Xv,{open:ht,onOpenChange:gt,items:pt,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,Ie&&lt?(0,Z.jsxs)(`div`,{className:`mt-2 w-full max-w-xl rounded-xl border border-edge-subtle bg-surface-panel p-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:I.chat.messageFeedbackReasonTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:I.chat.messageFeedbackReasonHint}),(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:ny.map(e=>(0,Z.jsx)(`button`,{type:`button`,className:`rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,disabled:at,onClick:()=>Lt(`not_helpful`,e),children:I.chat.messageFeedbackReasons[e]},e))})]}):null,Ie&&et===`not_helpful`&&dt?(0,Z.jsxs)(`button`,{type:`button`,className:`mt-2 inline-flex w-fit items-center gap-1.5 rounded-lg bg-accent-soft px-3 py-1.5 text-xs font-medium text-accent-fg hover:bg-accent-soft/80`,onClick:Rt,children:[(0,Z.jsx)(At,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),I.chat.messageFeedbackRepair]}):null]}),H&&m&&f!=null&&!T?(0,Z.jsx)(La,{open:_t,title:I.chat.userMessageDeleteConfirmTitle,description:I.chat.userMessageDeleteConfirm,confirmLabel:I.chat.userMessageDeleteOk,cancelLabel:I.chat.userMessageDeleteCancel,destructive:!0,onConfirm:Ht,onCancel:Ut}):null,(0,Z.jsx)(Zr,{open:yt!==null,attachment:yt,images:(M.content??[]).flatMap((e,t)=>{if(e.type!==`image`)return[];let n=wm(e,t);return n?[n]:[]}),onAttachmentChange:bt,authToken:r,conversationId:i,onClose:()=>bt(null)})]})})}),sy=(0,Q.memo)(function(e){let t=(0,X.c)(3),n=Bm(e.conversationId,e.message.renderKey)??e.message,r;return t[0]!==n||t[1]!==e?(r=(0,Z.jsx)(oy,{...e,message:n}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r});function cy(e,t){return e.renderKey??`${e.timestamp??`n`}-${t}`}var ly=new Map;function uy(e,t=`time`){let n=`${e??`default`}:${t}`,r=ly.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}),ly.set(n,r)),r}function dy(e){return e?uy().format(e):``}var fy=1800*1e3;function py(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function my(e,t){return e?!t||!py(new Date(e),new Date(t))||e-t>=fy:!1}function hy(e,t,n){let r=new Date(e),i=new Date(t),a=new Date(i);return a.setDate(i.getDate()-1),`${py(r,i)?n===`zh`?`今天`:`Today`:py(r,a)?n===`zh`?`昨天`:`Yesterday`:uy(n,r.getFullYear()===i.getFullYear()?`date`:`year`).format(r)} ${uy(n).format(r)}`}var gy=0,_y=1,vy=2,yy=4;function by(e){return()=>e}function xy(e){e()}function Sy(e,t){return n=>e(t(n))}function Cy(e,t){return()=>e(t)}function wy(e,t){return n=>e(t,n)}function Ty(e){return e!==void 0}function Ey(...e){return()=>{e.map(xy)}}function Dy(){}function Oy(e,t){return t(e),e}function ky(e,t){return t(e)}function Ay(...e){return e}function jy(e,t){return e(_y,t)}function My(e,t){e(gy,t)}function Ny(e){e(vy)}function Py(e){return e(yy)}function Fy(e,t){return jy(e,wy(t,gy))}function Iy(e,t){let n=e(_y,e=>{n(),t(e)});return n}function Ly(e){let t,n;return r=>i=>{t=i,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Ry(e,t){return e===t}function zy(e=Ry){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function By(e){return t=>n=>{e(n)&&t(n)}}function Vy(e){return t=>Sy(t,e)}function Hy(e){return t=>()=>{t(e)}}function $(e,...t){let n=qy(...t);return((t,r)=>{switch(t){case vy:Ny(e);return;case _y:return jy(e,n(r))}})}function Uy(e,t){return n=>r=>{n(t=e(t,r))}}function Wy(e){return t=>n=>{e>0?e--:t(n)}}function Gy(e){let t=null,n;return r=>i=>{t=i,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Ky(...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;jy(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 qy(...e){return t=>e.reduceRight(ky,t)}function Jy(e){let t,n,r=()=>t?.();return function(i,a){switch(i){case _y:return a?n===a?void 0:(r(),n=a,t=jy(e,a),t):(r(),Dy);case vy:r(),n=null;return}}}function Yy(e){let t=e,n=Zy();return((e,r)=>{switch(e){case gy:t=r;break;case _y:r(t);break;case yy:return t}return n(e,r)})}function Xy(e,t){return Oy(Yy(t),t=>Fy(e,t))}function Zy(){let e=[];return((t,n)=>{switch(t){case gy:e.slice().forEach(e=>{e(n)});return;case vy:e.splice(0);return;case _y:return e.push(n),()=>{let t=e.indexOf(n);t>-1&&e.splice(t,1)}}})}function Qy(e){return Oy(Zy(),t=>Fy(e,t))}var $y={singleton:!0};function eb(e,t=[],n=$y){let{singleton:r}=n;return{constructor:e,dependencies:t,id:tb(),singleton:r}}var tb=()=>Symbol(`id`);function nb(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 rb(...e){let t=Zy(),n=Array.from({length:e.length}),r=0,i=2**e.length-1;return e.forEach((e,a)=>{let o=2**a;jy(e,e=>{n[a]=e,r|=o,r===i&&My(t,n)})}),function(e,a){switch(e){case vy:Ny(t);return;case _y:return r===i&&a(n),jy(t,a)}}}function ib(e,t=Ry){return $(e,zy(t))}function ab(...e){return function(t,n){switch(t){case vy:return;case _y:return Ey(...e.map(e=>jy(e,n)))}}}var ob={DEBUG:0,INFO:1,WARN:2,ERROR:3},sb={[ob.DEBUG]:`debug`,[ob.ERROR]:`error`,[ob.INFO]:`log`,[ob.WARN]:`warn`},cb=()=>typeof globalThis>`u`?window:globalThis,lb=eb(()=>{let e=Yy(ob.ERROR);return{log:Yy((t,n,r=ob.INFO)=>{r>=(cb().VIRTUOSO_LOG_LEVEL??Py(e))&&console[sb[r]](`%creact-virtuoso: %c%s %o`,`color: #0253b3; font-weight: bold`,`color: initial`,t,n)}),logLevel:e}},[],{singleton:!0});function ub(e){return`self`in e?e.document.documentElement:e}function db(e){let t=ub(e);return t.ownerDocument.defaultView.getComputedStyle(t).direction===`rtl`}function fb(e,t){return db(e)?-t:t}function pb(e,t){return db(e)?-t:t}function mb(e,t,n){return hb(e,t,n).callbackRef}function hb(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 gb(e,t,n,r,i,a,o,s,c){return hb(Q.useCallback(n=>{let c=_b(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?fb(o,o.scrollLeft):o.scrollTop:u?s?fb(d,d.scrollX||d.document.documentElement.scrollLeft):d.scrollY||d.document.documentElement.scrollTop:s?fb(l,l.scrollLeft):l.scrollTop;r({scrollHeight:f,scrollTop:Math.max(m,0),viewportHeight:p}),a?.(s?vb(`column-gap`,getComputedStyle(n).columnGap,i):vb(`row-gap`,getComputedStyle(n).rowGap,i)),c!==null&&e(c)},[e,t,i,a,o,r,s]),n,c)}function _b(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},ob.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 vb(e,t,n){return t!==`normal`&&t?.endsWith(`px`)!==!0&&n(`${e} was not resolved to pixel value correctly`,t,ob.WARN),t===`normal`?0:parseInt(t??`0`,10)}var yb=typeof document>`u`?Q.useEffect:Q.useLayoutEffect;function bb(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}=hb(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 xb=eb(()=>{let e=Zy(),t=Zy(),n=Yy(0),r=Zy(),i=Zy(),a=Yy(0),o=Zy(),s=Zy(),c=Yy(0),l=Yy(0),u=Yy(0),d=Yy(0),f=Zy(),p=Zy(),m=Yy(!1),h=Yy(!1),g=Yy(!1);return Fy($(e,Vy(({scrollTop:e})=>e)),t),Fy($(e,Vy(({scrollHeight:e})=>e)),s),Fy(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}),Sb={lvl:0};function Cb(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 wb(e){return e===Sb}function Tb(e,t){if(!wb(e))return t===e.k?e.v:t<e.k?Tb(e.l,t):Tb(e.r,t)}function Eb(e,t,n=`k`){if(wb(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){let r=Eb(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return Eb(e.l,t,n)}function Db(e,t,n){return wb(e)?Rb(t,n,1):t===e.k?Pb(e,{k:t,v:n}):t<e.k?zb(Pb(e,{l:Db(e.l,t,n)})):zb(Pb(e,{r:Db(e.r,t,n)}))}function Ob(){return Sb}function kb(e,t,n){if(wb(e))return[];let r=Eb(e,t)[0];return Hb(Mb(e,r,n))}function Ab(e,t){if(wb(e))return Sb;let{k:n,l:r,r:i}=e;if(t===n){if(wb(r))return i;if(wb(i))return r;let[t,n]=Lb(r);return Nb(Pb(e,{k:t,l:Fb(r),v:n}))}return Nb(t<n?Pb(e,{l:Ab(r,t)}):Pb(e,{r:Ab(i,t)}))}function jb(e){return wb(e)?[]:[...jb(e.l),{k:e.k,v:e.v},...jb(e.r)]}function Mb(e,t,n){if(wb(e))return[];let{k:r,l:i,r:a,v:o}=e,s=[];return r>t&&(s=s.concat(Mb(i,t,n))),r>=t&&r<=n&&s.push({k:r,v:o}),r<=n&&(s=s.concat(Mb(a,t,n))),s}function Nb(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(Ib(t))return Bb(Pb(e,{lvl:n-1}));if(!wb(t)&&!wb(t.r))return Pb(t.r,{l:Pb(t,{r:t.r.l}),lvl:n,r:Pb(e,{l:t.r.r,lvl:n-1})});throw Error(`Unexpected empty nodes`)}if(Ib(e))return Vb(Pb(e,{lvl:n-1}));if(!wb(r)&&!wb(r.l)){let t=r.l,i=Ib(t)?r.lvl-1:r.lvl;return Pb(t,{l:Pb(e,{lvl:n-1,r:t.l}),lvl:t.lvl+1,r:Vb(Pb(r,{l:t.r,lvl:i}))})}throw Error(`Unexpected empty nodes`)}function Pb(e,t){return Rb(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 Fb(e){return wb(e.r)?e.l:Nb(Pb(e,{r:Fb(e.r)}))}function Ib(e){return wb(e)||e.lvl>e.r.lvl}function Lb(e){return wb(e.r)?[e.k,e.v]:Lb(e.r)}function Rb(e,t,n,r=Sb,i=Sb){return{k:e,l:r,lvl:n,r:i,v:t}}function zb(e){return Vb(Bb(e))}function Bb(e){let{l:t}=e;return!wb(t)&&t.lvl===e.lvl?Pb(t,{r:Pb(e,{l:t.r})}):e}function Vb(e){let{lvl:t,r:n}=e;return!wb(n)&&!wb(n.r)&&n.lvl===t&&n.r.lvl===t?Pb(n,{l:Pb(e,{r:n.l}),lvl:t+1}):e}function Hb(e){return Cb(e,({k:e,v:t})=>({index:e,value:t}))}function Ub(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Wb(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}var Gb=eb(()=>({recalcInProgress:Yy(!1)}),[],{singleton:!0});function Kb(e,t,n){return e[qb(e,t,n)]}function qb(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 Jb(e,t,n,r){let i=qb(e,t,r),a=qb(e,n,r,i);return e.slice(i,a+1)}function Yb(e,t){return Math.round(e.getBoundingClientRect()[t])}function Xb(e){return!wb(e.groupOffsetTree)}function Zb({index:e},t){return t===e?0:t<e?-1:1}function Qb(){return{groupIndices:[],groupOffsetTree:Ob(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Ob()}}function $b(e,t){let n=wb(e)?0:1/0;for(let r of t){let{endIndex:t,size:i,startIndex:a}=r;if(n=Math.min(n,a),wb(e)){e=Db(e,0,i);continue}let o=kb(e,a-1,t+1);if(o.some(dx(r)))continue;let s=!1,c=!1;for(let{end:n,start:r,value:a}of o)s?(t>=r||i===a)&&(e=Ab(e,r)):(c=a!==i,s=!0),n>t&&t>=r&&a!==i&&(e=Db(e,t+1,a));c&&(e=Db(e,a,i))}return[e,n]}function ex(e){return e.groupIndex!==void 0}function tx({offset:e},t){return t===e?0:t<e?-1:1}function nx(e,t,n){if(t.length===0)return 0;let{index:r,offset:i,size:a}=Kb(t,e,Zb),o=e-r,s=a*o+(o-1)*n+i;return s>0?s+n:s}function rx(e,t){if(!Xb(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function ix(e,t,n){if(ex(e))return t.groupIndices[e.groupIndex]+1;let r=rx(e.index===`LAST`?n:e.index,t);return r=Math.max(0,Math.min(n,r)),r}function ax(e,t,n,r=0){return r>0&&(t=Math.max(t,Kb(e,r,Zb).offset)),Cb(Jb(e,t,n,tx),ux)}function ox(e,[t,n,r,i]){t.length>0&&r(`received item sizes`,t,ob.DEBUG);let a=e.sizeTree,o=a,s=0;if(n.length>0&&wb(a)&&t.length===2){let e=t[0].size,r=t[1].size;o=n.reduce((t,n)=>Db(Db(t,n,e),n+1,r),o)}else[o,s]=$b(o,t);if(o===a)return e;let{lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d}=lx(e.offsetTree,s,o,i);return{groupIndices:n,groupOffsetTree:n.reduce((e,t)=>Db(e,t,nx(t,d,i)),Ob()),lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d,sizeTree:o}}function sx(e){return jb(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 cx(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 lx(e,t,n,r){let i=e,a=0,o=0,s=0,c=0;if(t===0)i=[];else{c=qb(i,t-1,Zb),s=i[c].offset;let e=Eb(n,t-1);a=e[0],o=e[1],i.length&&i[c].size===Eb(n,t)[1]&&--c,i=i.slice(0,c+1)}for(let{start:e,value:c}of kb(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 ux(e){return{index:e.index,value:e}}function dx(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 fx={offsetHeight:`height`,offsetWidth:`width`},px=eb(([{log:e},{recalcInProgress:t}])=>{let n=Zy(),r=Zy(),i=Xy(r,0),a=Zy(),o=Zy(),s=Yy(0),c=Yy([]),l=Yy(void 0),u=Yy(void 0),d=Yy(void 0),f=Yy(void 0),p=Yy((e,t)=>Yb(e,fx[t])),m=Yy(void 0),h=Yy(0),g=Qb(),_=Xy($(n,Ky(c,e,h),Uy(ox,g),zy()),g),v=Xy($(c,zy(),Uy((e,t)=>({current:t,prev:e.current}),{current:[],prev:[]}),Vy(({prev:e})=>e)),[]);Fy($(c,By(e=>e.length>0),Ky(_,h),Vy(([e,t,n])=>{let r=e.reduce((e,r,i)=>Db(e,r,nx(r,t.offsetTree,n)||i),Ob());return{...t,groupIndices:e,groupOffsetTree:r}})),_),Fy($(r,Ky(_),By(([e,{lastIndex:t}])=>e<t),Vy(([e,{lastIndex:t,lastSize:n}])=>[{endIndex:t,size:n,startIndex:e}])),n),Fy(l,u);let y=Xy($(l,Vy(e=>e===void 0)),!0);Fy($(u,By(e=>e!==void 0&&wb(Py(_).sizeTree)),Vy(e=>{let t=Py(d),n=Py(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),Fy($(f,By(e=>e!==void 0&&e.length>0&&wb(Py(_).sizeTree)),Vy(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),Fy($(c,Ky(d,u),By(([,e,t])=>e!==void 0&&t!==void 0),Vy(([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=Qy($(n,Ky(_),Uy(({sizes:e},[t,n])=>({changed:n!==e,sizes:n}),{changed:!1,sizes:g}),Vy(e=>e.changed)));jy($(s,Uy((e,t)=>({diff:e.prev-t,prev:t}),{diff:0,prev:0}),Vy(e=>e.diff)),e=>{let{groupIndices:n}=Py(_);if(e>0)My(t,!0),My(a,e+cx(e,n));else if(e<0){let t=Py(v);t.length>0&&(e-=cx(-e,t)),My(o,e)}}),jy($(s,Ky(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},ob.ERROR)});let x=Qy(a);Fy($(a,Ky(_),Vy(([e,t])=>{let n=t.groupIndices.length>0,r=[],i=t.lastSize;if(n){let n=Tb(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=jb(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 jb(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=Qy($(o,Ky(_,h),Vy(([e,{offsetTree:t},n])=>nx(-e,t,n))));return Fy($(o,Ky(_,h),Vy(([e,t,n])=>{if(t.groupIndices.length>0){if(wb(t.sizeTree))return t;let r=Ob(),i=Py(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=jb(t.sizeTree).reduce((t,{k:n,v:r})=>Db(t,Math.max(0,n+e),r),r),a!==-e){let n=Tb(t.sizeTree,s);r=Db(r,0,n);let i=Eb(t.sizeTree,-e+1)[1];r=Db(r,1,i)}return{...t,sizeTree:r,...lx(t.offsetTree,0,r,n)}}let r=jb(t.sizeTree).reduce((t,{k:n,v:r})=>Db(t,Math.max(0,n+e),r),Ob());return{...t,sizeTree:r,...lx(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}},Ay(lb,Gb),{singleton:!0});function mx(e){return e.reduce((e,t)=>(e.groupIndices.push(e.totalCount),e.totalCount+=t+1,e),{groupIndices:[],totalCount:0})}var hx=eb(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:i}])=>{let a=Zy(),o=Zy(),s=Qy($(a,Vy(mx)));return Fy($(s,Vy(e=>e.totalCount)),n),Fy($(s,Vy(e=>e.groupIndices)),e),Fy($(rb(i,t,r),By(([e,t])=>Xb(t)),Vy(([e,t,n])=>Eb(t.groupOffsetTree,Math.max(e-n,0),`v`)[0]),zy(),Vy(e=>[e])),o),{groupCounts:a,topItemsIndexes:o}},Ay(px,xb)),gx=eb(([{log:e}])=>{let t=Yy(!1),n=Qy($(t,By(e=>e),zy()));return jy(t,t=>{t&&Py(e)(`props updated`,{},ob.DEBUG)}),{didMount:n,propsReady:t}},Ay(lb),{singleton:!0}),_x=typeof document<`u`&&`scrollBehavior`in document.documentElement.style;function vx(e){let t=typeof e==`number`?{index:e}:{...e};return t.align||=`start`,(!t.behavior||!_x)&&(t.behavior=`auto`),t.offset===void 0&&(t.offset=0),t}var yx=eb(([{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=Zy(),m=Zy(),h=Yy(0),g=null,_=null,v=null;function y(){g!==null&&(g(),g=null),v!==null&&(v(),v=null),_&&=(clearTimeout(_),null),My(c,!1)}return Fy($(p,Ky(n,d,r,h,s,o,f),Ky(e,a,i),Vy(([[e,n,r,i,a,o,s,l],d,f,h])=>{let b=vx(e),{align:x,behavior:S,offset:C}=b,w=i-1,T=ix(b,n,w),E=nx(T,n.offsetTree,d)+o;x===`end`?(E+=f+Eb(n.sizeTree,T)[1]-r+h,T===w&&(E+=s)):x===`center`?E+=(f+Eb(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},ob.DEBUG),My(p,e)):(My(m,!0),l(`list did not change, scroll successful`,{},ob.DEBUG))};if(y(),S===`smooth`){let e=!1;v=jy(t,t=>{e||=t}),g=Iy(u,()=>{D(e)})}else g=Iy($(t,bx(150)),D);return _=setTimeout(()=>{y()},1200),My(c,!0),l(`scrolling from index to`,{behavior:S,index:T,top:E},ob.DEBUG),{behavior:S,top:E}})),l),{scrollTargetReached:m,scrollToIndex:p,topListHeight:h}},Ay(px,xb,lb),{singleton:!0});function bx(e){return t=>{let n=setTimeout(()=>{t(!1)},e);return e=>{e&&(t(!0),clearTimeout(n))}}}function xx(e,t){e===0?t():requestAnimationFrame(()=>{xx(e-1,t)})}function Sx(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 Cx(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 wx=eb(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:i,scrollToIndex:a},{didMount:o}])=>{let s=Yy(!0),c=Yy(0),l=Yy(!0);return Fy($(o,Ky(c),By(([e,t])=>!Cx(t)),Hy(!1)),s),Fy($(o,Ky(c),By(([e,t])=>!Cx(t)),Hy(!1)),l),jy($(rb(t,o),Ky(s,n,e,l),By(([[,e],t,{sizeTree:n},r,i])=>e&&(!wb(n)||Ty(r))&&!t&&!i),Ky(c)),([,e])=>{if(e===void 0){My(s,!0),My(l,!0);return}Iy(i,()=>{My(l,!0)}),xx(4,()=>{Iy(r,()=>{My(s,!0)}),My(a,e)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:c,scrolledToInitialItem:s}},Ay(px,xb,yx,gx),{singleton:!0});function Tx(e,t){return Math.abs(e-t)<1.01}var Ex=`up`,Dx=`down`,Ox=`none`,kx={atBottom:!1,notAtBottomBecause:`NOT_SHOWING_LAST_ITEM`,state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Ax=0,jx=eb(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:i,viewportHeight:a}])=>{let o=Yy(!1),s=Yy(!0),c=Zy(),l=Zy(),u=Yy(4),d=Yy(Ax),f=Xy($(ab($(ib(i),Wy(1),Hy(!0)),$(ib(i),Wy(1),Hy(!1),Ly(100))),zy()),!1),p=Xy($(ab($(n,Hy(!0)),$(n,Hy(!1),Ly(200))),zy()),!1);Fy($(rb(ib(i),ib(d)),Vy(([e,t])=>e<=t),zy()),s),Fy($(s,Gy(50)),l);let m=Qy($(rb(r,ib(a),ib(t),ib(e),ib(u)),Uy((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}},kx),zy((e,t)=>e!==void 0&&e.atBottom===t.atBottom))),h=Xy($(r,Uy((e,{scrollHeight:t,scrollTop:n,viewportHeight:r})=>{if(!Tx(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}),By(e=>e.changed),Vy(e=>e.jump)),0);Fy($(m,Vy(e=>e.atBottom)),o),Fy($(o,Gy(50)),c);let g=Yy(Dx);Fy($(r,Vy(({scrollTop:e})=>e),zy(),Uy((e,t)=>Py(p)?{direction:e.direction,prevScrollTop:t}:{direction:t<e.prevScrollTop?Ex:Dx,prevScrollTop:t},{direction:Dx,prevScrollTop:0}),Vy(e=>e.direction)),g),Fy($(r,Gy(50),Hy(Ox)),g);let _=Yy(0);return Fy($(f,By(e=>!e),Hy(0)),_),Fy($(i,Gy(100),Ky(f),By(([e,t])=>t),Uy(([e,t],[n])=>[t,n],[0,0]),Vy(([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:_}},Ay(xb)),Mx=`top`,Nx=`bottom`,Px=`none`;function Fx(e,t,n){return typeof e==`number`?n===Ex&&t===Mx||n===Dx&&t===Nx?e:0:n===Ex?t===Mx?e.main:e.reverse:t===Nx?e.main:e.reverse}function Ix(e,t){return typeof e==`number`?e:e[t]??0}var Lx=eb(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:i}])=>{let a=Zy(),o=Yy(0),s=Yy(0),c=Yy(0);return{increaseViewportBy:s,listBoundary:a,overscan:c,topListHeight:o,visibleRange:Xy($(rb(ib(r),ib(i),ib(n),ib(a,Wb),ib(c),ib(o),ib(t),ib(e),ib(s)),Vy(([e,t,n,[r,i],a,o,s,c,l])=>{let u=e-c,d=o+s,f=Math.max(n-u,0),p=Px,m=Ix(l,Mx),h=Ix(l,Nx);return r-=c,r+=n+s,i+=n+s,i-=c,r>e+d-m&&(p=Ex),i<e-f+t+h&&(p=Dx),p===Px?null:[Math.max(u-n-Fx(a,Mx,p)-m,0),u-f-s+t+Fx(a,Nx,p)+h]}),By(e=>e!==null),zy(Wb)),[0,0])}},Ay(xb),{singleton:!0});function Rx(e,t,n){if(Xb(t)){let r=rx(e,t);return[{index:Eb(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 zx={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Bx(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:Hx(e,i,a),offsetBottom:m,offsetTop:l,top:p,topItems:Hx(t,i,a),topListHeight:t.reduce((e,t)=>t.size+e,0),totalCount:n}}function Vx(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=Sx(t,c?l:s),d=c?Math.max(0,Math.min(s,l-u)):s;return Bx(Array.from({length:d}).map((e,t)=>({data:a?.[t+u],index:t+u,offset:0,size:0})),[],d,i,n,r)}function Hx(e,t,n){if(e.length===0)return[];if(!Xb(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=kb(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 Ux(e,t){return e===void 0?0:typeof e==`number`?e:e[t]??0}var Wx=eb(([{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=Yy([]),g=Yy(0),_=Zy(),v=Yy(0);Fy(a.topItemsIndexes,h);let y=Xy($(rb(p,m,ib(c,Wb),ib(i),ib(r),ib(l),u,ib(h),ib(t),ib(n),ib(v),e,ib(g)),By(([e,t,,n,,,,,,,,r])=>{let i=r!==void 0&&r.length!==n;return e&&!t&&!i}),Vy(([,,[e,t],n,r,i,a,o,s,c,l,u,d])=>{let f=r,{offsetTree:p,sizeTree:m}=f;if(n===0)return{...zx,totalCount:n};if(e===0&&t===0)return d===0?{...zx,totalCount:n}:Vx(d,i,r,s,c,u);if(wb(m))return d>0?null:Bx(Rx(Sx(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 kb(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 Bx([],h,n,c,f,s);let g=o.length>0?o[o.length-1]+1:0,_=ax(p,e,t,g);if(_.length===0)return null;let v=n-1,y=Oy([],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=Ux(l,Mx),x=Ux(l,Nx);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=kb(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=kb(m,r,r)[0]?.value??t.size;y.push({data:u?.[r],index:r,offset:n,size:e}),n+=e+c}}}return Bx(y,h,n,c,f,s)}),By(e=>e!==null),zy()),zx);Fy($(e,By(Ty),Vy(e=>e?.length)),i),Fy($(y,Vy(e=>e.topListHeight)),d),Fy(d,s),Fy($(y,Vy(e=>[e.top,e.bottom])),o),Fy($(y,Vy(e=>e.items)),_);let b=Qy($(y,By(({items:e})=>e.length>0),Ky(i,e),By(([{items:e},t])=>e[e.length-1].originalIndex===t-1),Vy(([,e,t])=>[e-1,t]),zy(Wb),Vy(([e])=>e))),x=Qy($(y,Gy(200),By(({items:e,topItems:t})=>e.length>0&&e[0].originalIndex===t.length),Vy(({items:e})=>e[0].index),zy()));return{endReached:b,initialItemCount:g,itemsRendered:_,listState:y,minOverscanItemCount:v,rangeChanged:Qy($(y,By(({items:e})=>e.length>0),Vy(({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}}),zy(Ub))),startReached:x,topItemsIndexes:h,...f}},Ay(px,hx,Lx,wx,yx,jx,gx,Gb),{singleton:!0}),Gx=eb(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:i}])=>{let a=Zy(),o=Xy($(rb(n,e,r,t,i),Vy(([e,t,n,r,i])=>e+t+n+r+i.offsetBottom+i.bottom)),0);return Fy(ib(o),a),{totalListHeight:o,totalListHeightChanged:a}},Ay(xb,Wx),{singleton:!0}),Kx=eb(([{viewportHeight:e},{totalListHeight:t}])=>{let n=Yy(!1);return{alignToBottom:n,paddingTopAddition:Xy($(rb(n,e,t),By(([e])=>e),Vy(([,e,t])=>Math.max(0,e-t)),Gy(0),zy()),0)}},Ay(xb,Gx),{singleton:!0}),qx=eb(()=>({context:Yy(null)})),Jx=({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,Yx=eb(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:i,headerHeight:a,scrollingInProgress:o,scrollTop:s,viewportHeight:c},{scrollToIndex:l}])=>{let u=Zy();return Fy($(u,Ky(t,c,n,a,i,r,s),Ky(e),Vy(([[e,t,n,r,i,a,s,c],l])=>{let{calculateViewLocation:u=Jx,done:d,...f}=e,p=ix(e,t,r-1),m=nx(p,t.offsetTree,l)+i+a,h=m+Eb(t.sizeTree,p)[1],g=c+a,_=u({itemBottom:h,itemTop:m,locationParams:f,viewportBottom:c+n-s,viewportTop:g});return _===null?d?.():d&&Iy($(o,By(e=>!e),Wy(Py(o)?1:2)),d),_}),By(e=>e!==null)),l),{scrollIntoView:u}},Ay(px,xb,yx,Wx,lb),{singleton:!0});function Xx(e){return e===!1?!1:e===`smooth`?`smooth`:`auto`}var Zx=(e,t)=>typeof e==`function`?Xx(e(t)):t&&Xx(e),Qx=eb(([{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=Yy(!1),h=Zy(),g=null;function _(e){My(o,{align:`end`,behavior:e,index:`LAST`})}jy($(rb($(ib(t),Wy(1)),c),Ky(ib(m),a,s,d),Vy(([[e,t],n,r,i,a])=>{let o=t&&i,s=`auto`;return o&&(s=Zx(n,r||a),o&&=s!==!1),{followOutputBehavior:s,shouldFollow:o,totalCount:e}}),By(({shouldFollow:e})=>e)),({followOutputBehavior:t,totalCount:r})=>{g!==null&&(g(),g=null),Py(n)===void 0?g=Iy(e,()=>{Py(u)(`following output to `,{totalCount:r},ob.DEBUG),_(t),g=null}):requestAnimationFrame(()=>{Py(u)(`following output to `,{totalCount:r},ob.DEBUG),_(t)})});function v(e){let t=Iy(i,t=>{e&&!t.atBottom&&t.notAtBottomBecause===`SIZE_INCREASED`&&g===null&&(Py(u)(`scrolling to bottom due to increased size`,{},ob.DEBUG),_(`auto`))});setTimeout(t,100)}jy($(rb(ib(m),t,l),By(([e,,t])=>e!==!1&&t),Uy(({value:e},[,t])=>({refreshed:e===t,value:t}),{refreshed:!1,value:0}),By(({refreshed:e})=>e),Ky(m,t)),([,e])=>{Py(s)&&v(e!==!1)}),jy(h,()=>{v(Py(m)!==!1)}),jy(rb(ib(m),i),([e,t])=>{e!==!1&&!t.atBottom&&t.notAtBottomBecause===`VIEWPORT_HEIGHT_DECREASING`&&_(`auto`)});let y=Yy(null),b=Zy();return Fy(ab($(ib(r),Vy(e=>e?.length??0)),$(ib(t))),b),jy($(rb($(b,Wy(1)),c),Ky(ib(y),s,d,f),Vy(([[e,t],n,r,i,a])=>t&&r&&n?.({context:a,totalCount:e,scrollingInProgress:i})),By(e=>!!e),Gy(0)),t=>{g!==null&&(g(),g=null),Py(n)===void 0?g=Iy(e,()=>{Py(u)(`scrolling into view`,{}),My(p,t),g=null}):requestAnimationFrame(()=>{Py(u)(`scrolling into view`,{}),My(p,t)})}),{autoscrollToBottom:h,followOutput:m,scrollIntoViewOnChange:y}},Ay(px,jx,yx,wx,gx,lb,xb,qx,Yx)),$x=eb(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:i},{initialItemCount:a,listState:o},{didMount:s}])=>(Fy($(s,Ky(a),By(([,e])=>e!==0),Ky(i,r,t,n,e),Vy(([[,e],t,n,r,i,a])=>Vx(e,t,n,r,i,a))),o),{}),Ay(px,wx,Wx,gx),{singleton:!0}),eS=eb(([{didMount:e},{scrollTo:t},{listState:n}])=>{let r=Yy(0);return jy($(e,Ky(r),By(([,e])=>e!==0),Vy(([,e])=>({top:e}))),e=>{Iy($(n,Wy(1),By(e=>e.items.length>1)),()=>{requestAnimationFrame(()=>{My(t,e)})})}),{initialScrollTop:r}},Ay(gx,xb,Wx),{singleton:!0}),tS=eb(([{scrollVelocity:e}])=>{let t=Yy(!1),n=Zy(),r=Yy(!1);return Fy($(e,Ky(r,t,n),By(([e,t])=>t!==!1&&t!==void 0),Vy(([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}),zy()),t),jy($(rb(t,e,n),Ky(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}},Ay(jx),{singleton:!0}),nS=eb(([{scrollContainerState:e,scrollTo:t}])=>{let n=Zy(),r=Zy(),i=Zy(),a=Yy(!1),o=Yy(void 0);return Fy($(rb(n,r),Vy(([{scrollTop:e,viewportHeight:t},{offsetTop:n,listHeight:r}])=>({scrollHeight:r,scrollTop:Math.max(0,e-n),viewportHeight:t}))),e),Fy($(t,Ky(r),Vy(([e,{offsetTop:t}])=>({...e,top:e.top+t}))),i),{customScrollParent:o,useWindowScroll:a,windowScrollContainerState:n,windowScrollTo:i,windowViewportRect:r}},Ay(xb)),rS=eb(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:i},{didMount:a},{useWindowScroll:o,windowScrollContainerState:s,windowViewportRect:c}])=>{let l=Zy(),u=Yy(void 0),d=Yy(null),f=Yy(null);return Fy(s,d),Fy(c,f),jy($(l,Ky(t,r,o,d,f,n)),([e,t,n,r,i,a,o])=>{let s=sx(t.sizeTree);r&&i!==null&&a!==null&&(n=i.scrollTop-a.offsetTop),n-=o,e({ranges:s,scrollTop:n})}),Fy($(u,By(Ty),Vy(iS)),i),Fy($(a,Ky(u),By(([,e])=>e!==void 0),zy(),Vy(([,e])=>e.ranges)),e),{getState:l,restoreStateFrom:u}},Ay(px,xb,wx,gx,nS));function iS(e){return{align:`start`,index:0,offset:e.scrollTop}}var aS=eb(([{topItemsIndexes:e}])=>{let t=Yy(0);return Fy($(t,By(e=>e>=0),Vy(e=>Array.from({length:e}).map((e,t)=>t))),e),{topItemCount:t}},Ay(Wx));function oS(e){let t=!1,n;return(()=>(t||(t=!0,n=e()),n))}var sS=oS(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),cS=eb(([{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 Fy(k,T.scrollSeekRangeChanged),Fy($(rb(T.windowViewportRect,_.headerHeight,_.fixedHeaderHeight),Vy(([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}},Ay(px,wx,xb,rS,Qx,Wx,yx,eb(([{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=Qy($(l,Ky(s),Uy(([,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]),By(([e])=>e!==0),Ky(i,c,r,a,m,h),By(([,e,t,n,,,r])=>!r&&!n&&e!==0&&t===Ex),Vy(([[e],,,,,t])=>(t(`Upward scrolling compensation`,{amount:e},ob.DEBUG),e))));function _(t){t>0?(My(n,{behavior:`auto`,top:-t}),My(e,0)):(My(e,0),My(n,{behavior:`auto`,top:-t}))}jy($(g,Ky(e,o)),([t,n,r])=>{r&&sS()?My(e,n-t):_(-t)}),jy($(rb(Xy(o,!1),e,h),By(([e,t,n])=>!e&&!n&&t!==0),Vy(([e,t])=>t),Gy(1)),_),Fy($(f,Vy(e=>({top:-e}))),n);let v=null;function y(){if(v===null)return;let{offset:t}=v;v=null,My(n,{top:t}),requestAnimationFrame(()=>{My(e,0),My(h,!1)})}return jy(t,e=>{v===null||!v.acknowledgeable||e===v.offset&&y()}),jy($(u,Ky(p,d),Vy(([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=Tb(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:Py(e)!==t,offset:t},My(e,t),requestAnimationFrame(y)}),{deviation:e}},Ay(xb,jx,Wx,px,lb,Gb)),aS,hx,eb(([e,t,n,r,i,a,o,s,c,l,u])=>({...e,...t,...n,...r,...i,...a,...o,...s,...c,...l,...u}),Ay(Lx,$x,gx,tS,Gx,eS,Kx,nS,Yx,lb,qx))));function lS(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 uS=typeof document>`u`?Q.useEffect:Q.useLayoutEffect;function dS(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&&My(e.propsReady,!1);for(let i of r){let r=e[t.required[i]];My(r,n[i])}for(let r of i)if(r in n){let i=e[t.optional[r]];My(i,n[r])}e.propsReady!==void 0&&My(e.propsReady,!0)}function l(e){return a.reduce((n,r)=>(n[r]=n=>{let i=e[t.methods[r]];My(i,n)},n),{})}function u(e){return o.reduce((n,r)=>(n[r]=Jy(e[t.events[r]]),n),{})}return{Component:Q.forwardRef(function(t,a){let{children:d,...f}=t,[p]=Q.useState(()=>Oy(nb(e),e=>{c(e,f)})),[m]=Q.useState(Cy(u,p));uS(()=>{for(let e of o)e in f&&jy(m[e],f[e]);return()=>{Object.values(m).map(Ny)}},[f,m,p]),uS(()=>{c(p,f)}),Q.useImperativeHandle(a,by(l(p)));let h=n;return(0,Z.jsx)(s.Provider,{value:p,children:n===void 0?d:(0,Z.jsx)(h,{...lS([...r,...i,...o],f),children:d})})}),useEmitter:(e,t)=>{let n=Q.useContext(s)[e];uS(()=>jy(n,t),[t,n])},useEmitterValue:e=>{let t=Q.useContext(s)[e],n=Q.useCallback(e=>jy(t,e),[t]);return Q.useSyncExternalStore(n,()=>Py(t),()=>Py(t))},usePublisher:e=>{let t=Q.useContext(s);return Q.useCallback(n=>{My(t[e],n)},[t,e])}}}var fS=Q.createContext(void 0),pS=Q.createContext(void 0),mS=`-webkit-sticky`,hS=`sticky`,gS=oS(()=>{if(typeof document>`u`)return hS;let e=document.createElement(`div`);return e.style.position=mS,e.style.position===mS?mS:hS});function _S(e){return`self`in e}function vS(e){return`body`in e}function yS(e,t,n,r=Dy,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(vS(l)||_S(l)){let e=_S(l)?l:l.defaultView;o=a===!0?fb(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?fb(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():Is.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;_S(r)?(u=Math.max(Yb(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?fb(r,r.scrollX):r.scrollY):(u=r[a===!0?`scrollWidth`:`scrollHeight`],l=Yb(r,a===!0?`width`:`height`),d=a===!0?fb(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,Tx(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:pb(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:pb(o.current,e.top)}}),o.current.scrollBy(e)},[a]),scrollerRef:o,scrollToCallback:u}}function bS(e){return e}var xS=eb(([e,t])=>({...e,...t}),Ay(cS,eb(()=>{let e=Yy(e=>`Item ${e}`),t=Yy(e=>`Group ${e}`),n=Yy({}),r=Yy(bS),i=Yy(`div`),a=Yy(Dy),o=(e,t=null)=>Xy($(n,Vy(t=>t[e]),zy()),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`)}}))),SS=({height:e})=>(0,Z.jsx)(`div`,{style:{height:e}}),CS={overflowAnchor:`none`,position:gS(),zIndex:1},wS={overflowAnchor:`none`},TS={...wS,display:`inline-block`,height:`100%`},ES=Q.memo(function({showTopList:e=!1}){let t=US(`listState`),n=WS(`sizeRanges`),r=US(`useWindowScroll`),i=US(`customScrollParent`),a=WS(`windowScrollContainerState`),o=WS(`scrollContainerState`),s=i||r?a:o,c=US(`itemContent`),l=US(`context`),u=US(`groupContent`),d=US(`trackItemSizes`),f=US(`itemSize`),p=US(`log`),m=WS(`gap`),h=US(`horizontalDirection`),{callbackRef:g}=gb(n,f,d,e?Dy:s,p,m,i,h,US(`skipAnimationFrameInResizeObserver`)),[_,v]=Q.useState(0);HS(`deviation`,e=>{_!==e&&v(e)});let y=WS(`deviationCommitted`);yb(()=>{y(_)},[_,y]);let b=US(`EmptyPlaceholder`),x=US(`ScrollSeekPlaceholder`)??SS,S=US(`ListComponent`),C=US(`ItemComponent`),w=US(`GroupComponent`),T=US(`computeItemKey`),E=US(`isSeeking`),D=US(`groupIndices`).length>0,O=US(`alignToBottom`),k=US(`initialItemFinalLocationReached`),A=e?{}:{boxSizing:`border-box`,...h?{display:`inline-block`,height:`100%`,marginInlineStart:_===0?O?`auto`:0:_,paddingInlineEnd:t.offsetBottom,paddingInlineStart:t.offsetTop,whiteSpace:`nowrap`}:{marginTop:_===0?O?`auto`:0:_,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...k?{}:{visibility:`hidden`}};return!e&&t.totalCount===0&&b!=null?(0,Z.jsx)(b,{...MS(b,l)}):(0,Z.jsx)(S,{...MS(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,{...MS(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,{...MS(w,l),"data-index":n,"data-item-index":e.index,"data-known-size":e.size,key:r,style:CS},u(e.index,l)):(0,Q.createElement)(C,{...MS(C,l),...NS(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?TS:wS},D?c(e.index,e.groupIndex,e.data,l):c(e.index,e.data,l))})})}),DS={height:`100%`,outline:`none`,overflowY:`auto`,position:`relative`,WebkitOverflowScrolling:`touch`},OS={outline:`none`,overflowX:`auto`,position:`relative`},kS=e=>({height:`100%`,position:`absolute`,top:0,width:`100%`,...e?{display:`flex`,flexDirection:`column`}:void 0}),AS=(e,t,n=0)=>({...kS(e),position:t?`relative`:`absolute`,top:t?-n:0}),jS={position:gS(),top:0,width:`100%`,zIndex:1};function MS(e,t){if(typeof e!=`string`)return{context:t}}function NS(e,t){return{item:typeof e==`string`?void 0:t}}var PS=Q.memo(function(){let e=US(`HeaderComponent`),t=WS(`headerHeight`),n=US(`HeaderFooterTag`),r=mb(Q.useMemo(()=>e=>{t(Yb(e,`height`))},[t]),!0,US(`skipAnimationFrameInResizeObserver`)),i=US(`context`);return e==null?null:(0,Z.jsx)(n,{ref:r,children:(0,Z.jsx)(e,{...MS(e,i)})})}),FS=Q.memo(function(){let e=US(`FooterComponent`),t=WS(`footerHeight`),n=US(`HeaderFooterTag`),r=mb(Q.useMemo(()=>e=>{t(Yb(e,`height`))},[t]),!0,US(`skipAnimationFrameInResizeObserver`)),i=US(`context`);return e==null?null:(0,Z.jsx)(n,{ref:r,children:(0,Z.jsx)(e,{...MS(e,i)})})});function IS({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}=yS(s,l,c,u,void 0,d);return e(`scrollTo`,m),e(`scrollBy`,f),(0,Z.jsx)(c,{"data-testid":`virtuoso-scroller`,"data-virtuoso-scroller":!0,ref:p,style:{...d?OS:DS,...i},tabIndex:0,...o,...MS(c,a),children:r})})}function LS({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}=yS(s,l,c,t(`scrollerRef`),f);return yb(()=>(h.current=f??p.current?.ownerDocument.defaultView,()=>{h.current=null}),[h,f]),e(`windowScrollTo`,g),e(`scrollBy`,m),(0,Z.jsx)(c,{ref:p,"data-virtuoso-scroller":!0,style:{position:`relative`,...i,...u===0?void 0:{height:u+d}},...o,...MS(c,a),children:r})})}var RS=({children:e})=>{let t=Q.useContext(fS),n=WS(`viewportHeight`),r=WS(`fixedItemHeight`),i=US(`alignToBottom`),a=US(`horizontalDirection`),o=mb(Q.useMemo(()=>Sy(n,e=>Yb(e,a?`width`:`height`)),[n,a]),!0,US(`skipAnimationFrameInResizeObserver`));return Q.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),(0,Z.jsx)(`div`,{"data-viewport-type":`element`,ref:o,style:kS(i),children:e})},zS=({children:e})=>{let t=Q.useContext(fS),n=WS(`windowViewportRect`),r=WS(`fixedItemHeight`),i=US(`customScrollParent`),a=US(`useWindowScroll`),o=US(`topListHeight`),s=bb(n,i,US(`skipAnimationFrameInResizeObserver`)),c=US(`alignToBottom`);return Q.useEffect(()=>{t&&(r(t.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),(0,Z.jsx)(`div`,{"data-viewport-type":`window`,ref:s,style:AS(c,a,o),children:e})},BS=({children:e})=>{let t=US(`TopItemListComponent`)??`div`,n=US(`headerHeight`);return(0,Z.jsx)(t,{style:{...jS,marginTop:`${n}px`},...MS(t,US(`context`)),children:e})},{Component:VS,useEmitter:HS,useEmitterValue:US,usePublisher:WS}=dS(xS,{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=US(`useWindowScroll`),n=US(`topItemsIndexes`).length>0,r=US(`customScrollParent`),i=US(`context`);return(0,Z.jsxs)(r||t?KS:GS,{...e,context:i,children:[n&&(0,Z.jsx)(BS,{children:(0,Z.jsx)(ES,{showTopList:!0})}),(0,Z.jsxs)(r||t?zS:RS,{children:[(0,Z.jsx)(PS,{}),(0,Z.jsx)(ES,{}),(0,Z.jsx)(FS,{})]})]})})),GS=IS({useEmitter:HS,useEmitterValue:US,usePublisher:WS}),KS=LS({useEmitter:HS,useEmitterValue:US,usePublisher:WS}),qS=VS,JS=eb(([e,t])=>({...e,...t}),Ay(cS,eb(()=>{let e=Yy(e=>(0,Z.jsxs)(`td`,{children:[`Item $`,e]})),t=Yy(null),n=Yy(e=>(0,Z.jsxs)(`td`,{colSpan:1e3,children:[`Group `,e]})),r=Yy(null),i=Yy(null),a=Yy({}),o=Yy(bS),s=Yy(Dy),c=(e,t=null)=>Xy($(a,Vy(t=>t[e]),zy()),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`)}}))),YS=({height:e})=>(0,Z.jsx)(`tr`,{children:(0,Z.jsx)(`td`,{style:{height:e}})}),XS=({height:e})=>(0,Z.jsx)(`tr`,{children:(0,Z.jsx)(`td`,{style:{border:0,height:e,padding:0}})}),ZS={overflowAnchor:`none`},QS={position:gS(),zIndex:2,overflowAnchor:`none`},$S=Q.memo(function({showTopList:e=!1}){let t=aC(`listState`),n=aC(`computeItemKey`),r=aC(`firstItemIndex`),i=aC(`context`),a=aC(`isSeeking`),o=aC(`fixedHeaderHeight`),s=aC(`groupIndices`).length>0,c=aC(`itemContent`),l=aC(`groupContent`),u=aC(`ScrollSeekPlaceholder`)??YS,d=aC(`GroupComponent`),f=aC(`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,{...MS(u,i),height:t.size,index:t.index,key:h,type:t.type||`item`}):t.type===`group`?(0,Q.createElement)(d,{...MS(d,i),"data-index":m,"data-item-index":t.index,"data-known-size":t.size,key:h,style:{...QS,top:o}},l(t.index,i)):(0,Q.createElement)(f,{...MS(f,i),...NS(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?{...QS,top:o+g}:ZS},s?c(t.index,t.groupIndex,t.data,i):c(t.index,t.data,i))})}),eC=Q.memo(function(){let e=aC(`listState`),t=aC(`topItemsIndexes`).length>0,n=oC(`sizeRanges`),r=aC(`useWindowScroll`),i=aC(`customScrollParent`),a=oC(`windowScrollContainerState`),o=oC(`scrollContainerState`),s=i||r?a:o,c=aC(`trackItemSizes`),{callbackRef:l,ref:u}=gb(n,aC(`itemSize`),c,s,aC(`log`),void 0,i,!1,aC(`skipAnimationFrameInResizeObserver`)),[d,f]=Q.useState(0);iC(`deviation`,e=>{d!==e&&(u.current.style.marginTop=`${e}px`,f(e))});let p=oC(`deviationCommitted`);yb(()=>{p(d)},[d,p]);let m=aC(`EmptyPlaceholder`),h=aC(`FillerRow`)??XS,g=aC(`TableBodyComponent`),_=aC(`paddingTopAddition`),v=aC(`statefulTotalCount`),y=aC(`context`);if(v===0&&m!=null)return(0,Z.jsx)(m,{...MS(m,y)});let b=(t?e.topItems:[]).reduce((e,t)=>e+t.size,0),x=e.offsetTop+_+d-b,S=e.offsetBottom,C=x>0?(0,Z.jsx)(h,{context:y,height:x},`padding-top`):null,w=S>0?(0,Z.jsx)(h,{context:y,height:S},`padding-bottom`):null;return(0,Z.jsxs)(g,{"data-testid":`virtuoso-item-list`,ref:l,...MS(g,y),children:[C,t&&(0,Z.jsx)($S,{showTopList:!0}),(0,Z.jsx)($S,{}),w]})}),tC=({children:e})=>{let t=Q.useContext(fS),n=oC(`viewportHeight`),r=oC(`fixedItemHeight`),i=mb(Q.useMemo(()=>Sy(n,e=>Yb(e,`height`)),[n]),!0,aC(`skipAnimationFrameInResizeObserver`));return Q.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),(0,Z.jsx)(`div`,{"data-viewport-type":`element`,ref:i,style:kS(!1),children:e})},nC=({children:e})=>{let t=Q.useContext(fS),n=oC(`windowViewportRect`),r=oC(`fixedItemHeight`),i=aC(`customScrollParent`),a=aC(`useWindowScroll`),o=bb(n,i,aC(`skipAnimationFrameInResizeObserver`));return Q.useEffect(()=>{t&&(r(t.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),(0,Z.jsx)(`div`,{"data-viewport-type":`window`,ref:o,style:AS(!1,a),children:e})},{Component:rC,useEmitter:iC,useEmitterValue:aC,usePublisher:oC}=dS(JS,{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=aC(`useWindowScroll`),n=aC(`customScrollParent`),r=oC(`fixedHeaderHeight`),i=oC(`fixedFooterHeight`),a=aC(`fixedHeaderContent`),o=aC(`fixedFooterContent`),s=aC(`context`),c=mb(Q.useMemo(()=>Sy(r,e=>Yb(e,`height`)),[r]),!0,aC(`skipAnimationFrameInResizeObserver`)),l=mb(Q.useMemo(()=>Sy(i,e=>Yb(e,`height`)),[i]),!0,aC(`skipAnimationFrameInResizeObserver`)),u=n||t?cC:sC,d=n||t?nC:tC,f=aC(`TableComponent`),p=aC(`TableHeadComponent`),m=aC(`TableFooterComponent`),h=a?(0,Z.jsx)(p,{ref:c,style:{position:`sticky`,top:0,zIndex:2},...MS(p,s),children:a()},`TableHead`):null,g=o?(0,Z.jsx)(m,{ref:l,style:{bottom:0,position:`sticky`,zIndex:1},...MS(m,s),children:o()},`TableFoot`):null;return(0,Z.jsx)(u,{...e,...MS(u,s),children:(0,Z.jsx)(d,{children:(0,Z.jsxs)(f,{style:{borderSpacing:0,overflowAnchor:`none`},...MS(f,s),children:[h,(0,Z.jsx)(eC,{},`TableBody`),g]})})})})),sC=IS({useEmitter:iC,useEmitterValue:aC,usePublisher:oC}),cC=LS({useEmitter:iC,useEmitterValue:aC,usePublisher:oC}),lC={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},uC={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:dC,floor:fC,max:pC,min:mC,round:hC}=Math;function gC(e,t,n){return Array.from({length:t-e+1}).map((t,r)=>({data:n===null?null:n[r+e],index:r+e}))}function _C(e){return{...uC,items:e}}function vC(e,t){return e!==void 0&&e.width===t.width&&e.height===t.height}function yC(e,t){return e!==void 0&&e.column===t.column&&e.row===t.row}var bC=eb(([{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=Yy(0),C=Yy(0),w=Yy(lC),T=Yy({height:0,width:0}),E=Yy({height:0,width:0}),D=Zy(),O=Zy(),k=Yy(0),A=Yy(null),j=Yy({column:0,row:0}),M=Zy(),N=Zy(),P=Yy(!1),F=Yy(0),I=Yy(!0),L=Yy(!1),R=Yy(!1);jy($(m,Ky(F),By(([e,t])=>!Cx(t))),()=>{My(I,!1)}),jy($(rb(m,I,E,T,F,L),By(([e,t,n,r,,i])=>e&&!t&&n.height!==0&&r.height!==0&&!i)),([,,,,e])=>{if(e===void 0){My(I,!0);return}My(L,!0),xx(1,()=>{My(D,e)}),Iy($(l),()=>{My(t,[0,0]),My(I,!0)})}),Fy($(N,By(e=>e!=null&&e.scrollTop>0),Hy(0)),C),jy($(m,Ky(N),By(([,e])=>e!=null)),([,e])=>{e&&(My(T,e.viewport),My(E,e.item),My(j,e.gap),e.scrollTop>0&&(My(P,!0),Iy($(l,Wy(1)),e=>{My(P,!1)}),My(c,{top:e.scrollTop})))}),Fy($(T,Vy(({height:e})=>e)),d),Fy($(rb(ib(T,vC),ib(E,vC),ib(j,(e,t)=>e!==void 0&&e.column===t.column&&e.row===t.row),ib(l)),Vy(([e,t,n,r])=>({gap:n,item:t,scrollTop:r,viewport:e}))),M),Fy($(rb(ib(S),r,ib(j,yC),ib(E,vC),ib(T,vC),ib(A),ib(C),ib(P),ib(I),ib(F)),By(([,,,,,,,e])=>!e),Vy(([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 lC;if(p===0){let t=Sx(l,e);return _C(gC(t,t+Math.max(s-1,0),o))}let h=xC(m,p,u),g,_;c?t===0&&n===0&&s>0?(g=0,_=s-1):(g=h*fC((t+d)/(f+d)),_=h*dC((n+d)/(f+d))-1,_=mC(e-1,pC(_,h-1)),g=mC(_,pC(0,g))):(g=0,_=-1);let v=gC(g,_,o),{bottom:y,top:b}=SC(a,r,i,v),x=dC(e/h);return{bottom:y,itemHeight:f,items:v,itemWidth:p,offsetBottom:x*f+(x-1)*d-y,offsetTop:b,top:b}})),w),Fy($(A,By(e=>e!==null),Vy(e=>e.length)),S),Fy($(rb(T,E,w,j),By(([e,t,{items:n}])=>n.length>0&&t.height!==0&&e.height!==0),Vy(([e,t,{items:n},r])=>{let{bottom:i,top:a}=SC(e,r,t,n);return[a,i]}),zy(Wb)),t);let z=Yy(!1);Fy($(l,Ky(z),Vy(([e,t])=>t||e!==0)),z);let B=Qy($(rb(w,S),By(([{items:e}])=>e.length>0),Ky(z),By(([[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}),Vy(([[,e]])=>e-1),zy())),V=Qy($(ib(w),By(({items:e})=>e.length>0&&e[0].index===0),Hy(0),zy())),H=Qy($(ib(w),Ky(P),By(([{items:e},t])=>e.length>0&&!t),Vy(([{items:e}])=>({endIndex:e[e.length-1].index,startIndex:e[0].index})),zy(Ub),Gy(0)));Fy(H,p.scrollSeekRangeChanged),Fy($(D,Ky(T,E,S,j),Vy(([e,t,n,r,i])=>{let a=vx(e),{align:o,behavior:s,offset:c}=a,l=a.index;l===`LAST`&&(l=r-1),l=pC(0,l,mC(r-1,l));let u=CC(t,i,n,l);return o===`end`?u=hC(u-t.height+n.height):o===`center`&&(u=hC(u-t.height/2+n.height/2)),c!==void 0&&c!==0&&(u+=c),{behavior:s,top:u}})),c);let U=Xy($(w,Vy(e=>e.offsetBottom+e.bottom)),0);return Fy($(b,Vy(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}},Ay(Lx,xb,jx,tS,gx,nS,lb));function xC(e,t,n){return pC(1,fC((e+n)/(fC(t)+n)))}function SC(e,t,n,r){let{height:i}=n;if(i===void 0||r.length===0)return{bottom:0,top:0};let a=CC(e,t,n,r[0].index);return{bottom:CC(e,t,n,r[r.length-1].index)+i,top:a}}function CC(e,t,n,r){let i=fC(r/xC(e.width,n.width,t.column)),a=i*n.height+pC(0,i-1)*t.row;return a>0?a+t.row:a}var wC=eb(([e,t])=>({...e,...t}),Ay(bC,eb(()=>{let e=Yy(e=>`Item ${e}`),t=Yy({}),n=Yy(null),r=Yy(`virtuoso-grid-item`),i=Yy(`virtuoso-grid-list`),a=Yy(bS),o=Yy(`div`),s=Yy(Dy),c=(e,n=null)=>Xy($(t,Vy(t=>t[e]),zy()),n),l=Yy(!1),u=Yy(!1);return Fy(ib(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`)}}))),TC=Q.memo(function(){let e=MC(`gridState`),t=MC(`listClassName`),n=MC(`itemClassName`),r=MC(`itemContent`),i=MC(`computeItemKey`),a=MC(`isSeeking`),o=NC(`scrollHeight`),s=MC(`ItemComponent`),c=MC(`ListComponent`),l=MC(`ScrollSeekPlaceholder`),u=MC(`context`),d=NC(`itemDimensions`),f=NC(`gap`),p=MC(`log`),m=MC(`stateRestoreInProgress`),h=NC(`reportReadyState`),g=mb(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:IC(`column-gap`,getComputedStyle(e).columnGap,p),row:IC(`row-gap`,getComputedStyle(e).rowGap,p)})},[o,d,f,p]),!0,!1);return yb(()=>{e.itemHeight>0&&e.itemWidth>0&&h(!0)},[e]),m?null:(0,Z.jsx)(c,{className:t,ref:g,...MS(c,u),"data-testid":`virtuoso-item-list`,style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(t=>{let o=i(t.index,t.data,u);return a?(0,Z.jsx)(l,{...MS(l,u),height:e.itemHeight,index:t.index,width:e.itemWidth},o):(0,Q.createElement)(s,{...MS(s,u),className:n,"data-index":t.index,key:o},r(t.index,t.data,u))})})}),EC=Q.memo(function(){let e=MC(`HeaderComponent`),t=NC(`headerHeight`),n=MC(`headerFooterTag`),r=mb(Q.useMemo(()=>e=>{t(Yb(e,`height`))},[t]),!0,!1),i=MC(`context`);return e==null?null:(0,Z.jsx)(n,{ref:r,children:(0,Z.jsx)(e,{...MS(e,i)})})}),DC=Q.memo(function(){let e=MC(`FooterComponent`),t=NC(`footerHeight`),n=MC(`headerFooterTag`),r=mb(Q.useMemo(()=>e=>{t(Yb(e,`height`))},[t]),!0,!1),i=MC(`context`);return e==null?null:(0,Z.jsx)(n,{ref:r,children:(0,Z.jsx)(e,{...MS(e,i)})})}),OC=({children:e})=>{let t=Q.useContext(pS),n=NC(`itemDimensions`),r=NC(`viewportDimensions`),i=mb(Q.useMemo(()=>e=>{r(e.getBoundingClientRect())},[r]),!0,!1);return Q.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),(0,Z.jsx)(`div`,{ref:i,style:kS(!1),children:e})},kC=({children:e})=>{let t=Q.useContext(pS),n=NC(`windowViewportRect`),r=NC(`itemDimensions`),i=MC(`customScrollParent`),a=MC(`useWindowScroll`),o=bb(n,i,!1);return Q.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),(0,Z.jsx)(`div`,{ref:o,style:AS(!1,a),children:e})},{Component:AC,useEmitter:jC,useEmitterValue:MC,usePublisher:NC}=dS(wC,{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=MC(`useWindowScroll`),n=MC(`customScrollParent`),r=n||t?FC:PC,i=n||t?kC:OC,a=MC(`context`);return(0,Z.jsx)(r,{...e,...MS(r,a),children:(0,Z.jsxs)(i,{children:[(0,Z.jsx)(EC,{}),(0,Z.jsx)(TC,{}),(0,Z.jsx)(DC,{})]})})})),PC=IS({useEmitter:jC,useEmitterValue:MC,usePublisher:NC}),FC=LS({useEmitter:jC,useEmitterValue:MC,usePublisher:NC});function IC(e,t,n){return t!==`normal`&&t?.endsWith(`px`)!==!0&&n(`${e} was not resolved to pixel value correctly`,t,ob.WARN),t===`normal`?0:parseInt(t??`0`,10)}function LC(e){return e.scrollHeight-e.scrollTop-e.clientHeight}function RC(e,t=96){return LC(e)<=t}function zC(e){Math.abs(LC(e))>.5&&(e.scrollTop=e.scrollHeight)}function BC(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 VC(){return typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}var HC=new WeakMap;function UC(e,t){return HC.set(e,t),()=>{HC.get(e)===t&&HC.delete(e)}}function WC(e){return HC.get(e)}function GC(e){e.dispatchEvent(new Event(`chat-scroll-reading`))}function KC({context:e}){return e?.footer}var qC={Footer:KC},JC={top:800,bottom:800};function YC({rows:e,scrollRef:t,renderRow:n,footer:r}){let i=(0,Q.useRef)(null),[a,o]=(0,Q.useState)(),[s,c]=(0,Q.useState)(JC),[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 UC(a,{reveal:t=>{let n=e.findIndex(e=>e.index===t||e.aliases.includes(t));return n<0?!1:(GC(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&&VC()===`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=JC.top+(e?a.scrollTop-e.start:0),r=JC.bottom+(e?e.end-a.scrollTop:0);c(e=>e.top===n&&e.bottom===r?e:{top:n,bottom:r})},n=()=>{e!==null&&t()};return document.addEventListener(`selectionchange`,t),a.addEventListener(`scroll`,n,{passive:!0}),()=>{document.removeEventListener(`selectionchange`,t),a.removeEventListener(`scroll`,n)}},[a]),a?(0,Z.jsx)(qS,{ref:i,customScrollParent:a,data:e,skipAnimationFrameInResizeObserver:!0,components:qC,context:{footer:r},firstItemIndex:l.first,initialTopMostItemIndex:{index:e.length-1,align:`end`},defaultItemHeight:160,increaseViewportBy:s,computeItemKey:(e,t)=>t.key,itemContent:(t,r)=>(0,Z.jsx)(`div`,{className:r===e[0]?void 0:`pt-8`,children:n(r.index)})}):null}var XC=e=>{},ZC=(0,Q.memo)(function(e){let t=(0,X.c)(47),{messages:n,timelineEntries:r,personal:i,authToken:a,conversationId:o,workspaceConversationId:s,projectId:c,streaming:l,sending:u,progress:d,reasoningLevel:f,registerListContentRef:p,onPickWelcomePrompt:m,welcomeSpotlight:g,welcomeOverlay:_,compactWelcome:v,onDeleteRound:b,onRetryUserMessageRound:x,deleteRoundDisabled:S,onSaveAssistantAsNote:C,onSaveAssistantToSourceNote:w,onExtractAssistantTask:T,onForkAssistantTurn:E,onEditUserMessage:D,editLatestUserOnly:O,editRequiresTurnId:k,responseFeedbackEnabled:A,showAssistantWorkLog:j,hideAssistantActions:M,trailingContent:N,replySpaceRef:P,scrollRef:F}=e,I=r===void 0?[]:r,L=i!==void 0&&i,R=u!==void 0&&u,z=v!==void 0&&v,B=O!==void 0&&O,V=k!==void 0&&k,H=j===void 0||j,U=M!==void 0&&M,W=h(QC),G;t[0]===W?G=t[1]:(G=y(W),t[0]=W,t[1]=G);let ee=G,[te]=(0,Q.useState)(!!(F&&n.length>=300));if(n.length===0&&I.length===0&&!l&&!R){if(_){let e;return t[2]===_?e=t[3]:(e=(0,Z.jsx)(`div`,{className:`pb-1.5`,children:_}),t[2]=_,t[3]=e),e}let e;t[4]!==ee||t[5]!==g?(e=g??{headline:ee.chat.welcomeSpotlight.headline,contextKind:`empty`,contextStatus:`ready`},t[4]=ee,t[5]=g,t[6]=e):e=t[6];let n=m??XC,r;return t[7]!==z||t[8]!==e||t[9]!==n?(r=(0,Z.jsx)(`div`,{className:`pb-1.5`,children:(0,Z.jsx)(am,{spotlight:e,onPickPrompt:n,compact:z})}),t[7]=z,t[8]=e,t[9]=n,t[10]=r):r=t[10],r}let ne=Date.now(),re;t[11]===n?re=t[12]:(re=n.findLastIndex($C),t[11]=n,t[12]=re);let ie=re,ae;t[13]!==n.length||t[14]!==R||t[15]!==l?(ae=(e,t)=>!!((l||R||e.pendingResponseStatus)&&t===n.length-1&&e.role===`assistant`),t[13]=n.length,t[14]=R,t[15]=l,t[16]=ae):ae=t[16];let oe=ae,se;t[17]===n?se=t[18]:(se=(e,t)=>e.role===`assistant`&&e.turnId&&n[t-1]?.role===`task`&&n[t-1]?.turnId===e.turnId?n[t-1].taskTrigger:void 0,t[17]=n,t[18]=se);let ce=se,le;t[19]!==ce||t[20]!==oe||t[21]!==n||t[22]!==L||t[23]!==f||t[24]!==H?(le=(e,t)=>!Rv(e,{personal:L,isStreaming:oe(e,t),reasoningLevel:f,showAssistantWorkLog:H,followUpTrigger:ce(e,t)})||e.role===`task`&&e.taskTrigger&&e.turnId&&n[t+1]?.role===`assistant`&&n[t+1]?.turnId===e.turnId?[]:[{key:cy(e,t),index:t,aliases:e.role===`assistant`&&n[t-1]?.role===`task`&&e.turnId===n[t-1]?.turnId?[t-1]:[]}],t[19]=ce,t[20]=oe,t[21]=n,t[22]=L,t[23]=f,t[24]=H,t[25]=le):le=t[25];let ue=n.flatMap(le),K;t[26]===n.length?K=t[27]:(K=(e,t)=>({key:e.id,index:n.length+t,aliases:[]}),t[26]=n.length,t[27]=K),ue.push(...I.map(K));let q=0,de=n.map(e=>(q=Math.max(e.timestamp??q,q),q));I.length&&ue.sort((e,t)=>{let r=e=>e<n.length?de[e]:I[e-n.length].timestamp;return r(e.index)-r(t.index)||e.index-t.index});let fe=new Map(ue.map((e,t)=>[e.index,ue[t-1]?.index])),pe=e=>{if(e>=n.length){let t=I[e-n.length];return(0,Z.jsx)(`div`,{"data-chat-timeline-entry":t.id,children:t.content},t.id)}let t=n[e],r=oe(t,e),i=e===ie,l=n[e-1],u=ce(t,e),p=fe.get(e),m=p===void 0?void 0:n[p],h=m&&p!==void 0?ce(m,p)?n[p-1]?.timestamp??m.timestamp:m.timestamp:void 0,g=cy(t,e),_=u?l?.timestamp??t.timestamp:t.timestamp,v=my(_,h);return(0,Z.jsxs)(`div`,{id:`chat-message-${e}`,className:Y(`scroll-mt-4`,m&&(m.role===`user`||m.role===`task`)&&!u&&!v&&`-mt-5`),"data-chat-message-index":e,"data-chat-message-row":!0,"data-client-submission-id":t.clientSubmissionId,"data-message-render-key":t.renderKey,children:[u?(0,Z.jsx)(`span`,{id:`chat-message-${e-1}`,className:`block h-0 scroll-mt-4`,"aria-hidden":!0}):null,v&&_?(0,Z.jsx)(`div`,{className:`mb-8 flex justify-center`,"data-chat-time-separator":!0,children:(0,Z.jsx)(`time`,{suppressHydrationWarning:!0,className:`rounded-md px-2 py-1 text-xs tabular-nums text-fg-disabled`,dateTime:new Date(_).toISOString(),children:hy(_,ne,W)})}):null,t.role===`task`&&t.taskTrigger?(0,Z.jsx)(Wv,{trigger:t.taskTrigger}):(0,Z.jsx)(sy,{message:t,personal:L,followUpTrigger:u,authToken:a,conversationId:o,workspaceConversationId:s,projectId:c,isStreaming:r,progress:r?d:null,reasoningLevel:f,messageIndex:e,onDeleteRound:b,onRetryUserMessageRound:x,userMessageCanRetry:!!x&&i,deleteRoundDisabled:!!(S&&i),onSaveAssistantAsNote:C,onSaveAssistantToSourceNote:w,onExtractAssistantTask:T,onForkAssistantTurn:E,suppressAssistantActions:U,onEditUserMessage:D,userMessageCanEdit:(!B||i)&&(!V||!!t.turnId)&&t.deliveryStatus!==`sending`,responseFeedbackEnabled:A,showAssistantWorkLog:H})]},g)},J=te?`pt-8`:`contents`,me;t[28]===J?me=t[29]:(me=Y(J),t[28]=J,t[29]=me);let he;t[30]!==P||t[31]!==te?(he=P&&(0,Z.jsx)(`div`,{ref:P,className:Y(!te&&`-mt-8`,`shrink-0 transition-none`),"aria-hidden":!0,"data-chat-reply-space":!0}),t[30]=P,t[31]=te,t[32]=he):he=t[32];let ge;t[33]!==me||t[34]!==he||t[35]!==N?(ge=(0,Z.jsxs)(`div`,{className:me,children:[N,he]}),t[33]=me,t[34]=he,t[35]=N,t[36]=ge):ge=t[36];let _e=ge,ve=aa,ye=!te&&`flex flex-col gap-8`,be;t[37]===ye?be=t[38]:(be=Y(`w-full min-w-0 pb-8`,ye),t[37]=ye,t[38]=be);let xe=te||void 0,Se=te&&F?(0,Z.jsx)(YC,{rows:ue,scrollRef:F,renderRow:pe,footer:_e}):(0,Z.jsxs)(Z.Fragment,{children:[ue.map(e=>pe(e.index)),_e]}),Ce;t[39]!==p||t[40]!==be||t[41]!==xe||t[42]!==Se?(Ce=(0,Z.jsx)(`div`,{ref:p,className:be,"data-chat-virtualized":xe,children:Se}),t[39]=p,t[40]=be,t[41]=xe,t[42]=Se,t[43]=Ce):Ce=t[43];let we;return t[44]!==ve||t[45]!==Ce?(we=(0,Z.jsx)(ve,{children:Ce}),t[44]=ve,t[45]=Ce,t[46]=we):we=t[46],we});function QC(e){return e.language}function $C(e){return e.role===`user`}function ew(e){let t=(0,X.c)(8),{alt:n,className:r,"aria-hidden":i}=e,a=n?.trim()?n:void 0,o=i??(!a||void 0),s;t[0]===r?s=t[1]:(s=Y(`xopc-loop-logo relative inline-block shrink-0`,r),t[0]=r,t[1]=s);let c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsxs)(`linearGradient`,{id:`xopc-onboarding-ai-glass`,x1:`198`,y1:`180`,x2:`826`,y2:`844`,gradientUnits:`userSpaceOnUse`,children:[(0,Z.jsx)(`stop`,{stopColor:`var(--xopc-loop-ai-highlight)`}),(0,Z.jsx)(`stop`,{offset:`0.46`,stopColor:`var(--xopc-loop-ai)`}),(0,Z.jsx)(`stop`,{offset:`1`,stopColor:`var(--xopc-loop-ai-shadow)`})]}),t[2]=c):c=t[2];let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsxs)(`svg`,{className:`size-full overflow-visible`,viewBox:`0 0 1024 1024`,fill:`none`,"aria-hidden":`true`,children:[(0,Z.jsxs)(`defs`,{children:[c,(0,Z.jsxs)(`linearGradient`,{id:`xopc-onboarding-human-glass`,x1:`340`,y1:`224`,x2:`700`,y2:`816`,gradientUnits:`userSpaceOnUse`,children:[(0,Z.jsx)(`stop`,{stopColor:`var(--xopc-loop-human-highlight)`}),(0,Z.jsx)(`stop`,{offset:`0.52`,stopColor:`var(--xopc-loop-human)`}),(0,Z.jsx)(`stop`,{offset:`1`,stopColor:`var(--xopc-loop-human-shadow)`})]})]}),(0,Z.jsx)(`circle`,{className:`xopc-loop-logo__ambient`,cx:`512`,cy:`512`,r:`330`}),(0,Z.jsx)(`circle`,{className:`xopc-loop-logo__origin`,cx:`512`,cy:`512`,r:`330`}),(0,Z.jsx)(`circle`,{className:`xopc-loop-logo__ai-glow`,cx:`512`,cy:`512`,r:`330`,strokeDasharray:`1419.162121 654.289030`,transform:`rotate(11.8 512 512)`}),(0,Z.jsx)(`circle`,{className:`xopc-loop-logo__ai`,cx:`512`,cy:`512`,r:`330`,stroke:`url(#xopc-onboarding-ai-glass)`,strokeDasharray:`1419.162121 654.289030`,transform:`rotate(11.8 512 512)`}),(0,Z.jsx)(`circle`,{className:`xopc-loop-logo__human`,cx:`512`,cy:`512`,r:`330`,stroke:`url(#xopc-onboarding-human-glass)`,strokeDasharray:`354.790530 1718.660621`,transform:`rotate(284.2 512 512)`}),(0,Z.jsx)(`circle`,{className:`xopc-loop-logo__liquid-front`,cx:`512`,cy:`512`,r:`330`,strokeDasharray:`58 2015.451151`,transform:`rotate(11.8 512 512)`})]}),t[3]=l):l=t[3];let u;return t[4]!==o||t[5]!==a||t[6]!==s?(u=(0,Z.jsx)(`span`,{className:s,role:`img`,"aria-hidden":o,"aria-label":a,children:l}),t[4]=o,t[5]=a,t[6]=s,t[7]=u):u=t[7],u}var tw=(0,Q.memo)(function(e){let t=(0,X.c)(19),{visible:n,onClick:r,edge:i,running:a}=e,o=i===void 0?`top`:i,s=a!==void 0&&a,c=h(nw),l;t[0]===c?l=t[1]:(l=y(c),t[0]=c,t[1]=l);let u=l,d=!n,f=o===`top`?`-top-2 -translate-y-full`:`bottom-2`,p=n?`opacity-100`:`opacity-0`,m;t[2]!==f||t[3]!==p?(m=Y(`pointer-events-none absolute inset-x-0 z-20 flex items-center justify-center transition-opacity duration-150 ease-out motion-reduce:transition-none`,f,p),t[2]=f,t[3]=p,t[4]=m):m=t[4];let g=n?`scale-100 opacity-100`:`pointer-events-none translate-y-1 scale-95 opacity-0`,_;t[5]===g?_=t[6]:(_=Y(`group relative pointer-events-auto flex size-11 sm:size-8 shrink-0 items-center justify-center rounded-full border border-edge-subtle bg-surface-overlay text-fg-muted shadow-surface`,`hover:border-edge-strong hover:text-fg`,ca.transition,ca.press,ca.focusRingPanel,g,`motion-reduce:translate-y-0 motion-reduce:scale-100`),t[5]=g,t[6]=_);let v=n?void 0:-1,b;t[7]===s?b=t[8]:(b=s?(0,Z.jsx)(`span`,{"data-scroll-to-bottom-running-logo":!0,className:`flex size-5 items-center justify-center`,"aria-hidden":!0,children:(0,Z.jsx)(ew,{className:`xopc-loop-logo--stream size-5`})}):(0,Z.jsx)(as,{"data-scroll-to-bottom-arrow":!0,className:`size-4 transition-transform duration-150 ease-out group-hover:translate-y-0.5 motion-reduce:transition-none`,strokeWidth:1.8,"aria-hidden":!0}),t[7]=s,t[8]=b);let x;t[9]!==u.chat.scrollToBottom||t[10]!==r||t[11]!==v||t[12]!==b||t[13]!==_?(x=(0,Z.jsx)(`button`,{type:`button`,className:_,tabIndex:v,onClick:r,title:u.chat.scrollToBottom,"aria-label":u.chat.scrollToBottom,children:b}),t[9]=u.chat.scrollToBottom,t[10]=r,t[11]=v,t[12]=b,t[13]=_,t[14]=x):x=t[14];let S;return t[15]!==x||t[16]!==d||t[17]!==m?(S=(0,Z.jsx)(`div`,{"data-scroll-to-bottom-dock":!0,"aria-hidden":d,className:m,children:x}),t[15]=x,t[16]=d,t[17]=m,t[18]=S):S=t[18],S});function nw(e){return e.language}function rw(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 iw(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 aw(e){return e.webkitDirectionInvertedFromDevice===!0?e.deltaY>0:e.deltaY<0}function ow(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 sw(e){let t=(0,X.c)(48),{hasToken:n,showSessionLoading:r,conversationId:i,chatMessages:a,streaming:o,hasMore:s,loadingMore:c,loadMoreMessages:l}=e,u=(0,Q.useRef)(null),d=(0,Q.useRef)(null),f=(0,Q.useRef)(null),p=(0,Q.useRef)(!0),m=(0,Q.useRef)(null),h=(0,Q.useRef)(null),g=(0,Q.useRef)(null),_=(0,Q.useRef)(null),v=(0,Q.useRef)(0),y=(0,Q.useRef)(0),b=(0,Q.useRef)(null),x=(0,Q.useRef)(null),S=(0,Q.useRef)(null),C=(0,Q.useRef)(null),w=(0,Q.useRef)(0),T=(0,Q.useRef)(0),[E,D]=(0,Q.useState)(!0),O=(0,Q.useRef)(!0),k=(0,Q.useRef)(0),A=(0,Q.useRef)(o),j;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(j={first:void 0,len:0,scrollHeight:0},t[0]=j):j=t[0];let M=(0,Q.useRef)(j),N;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>{p.current=e,e&&(S.current=null)},t[1]=N):N=t[1];let P=N,F;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(F=e=>{let t=u.current;if(!t)return;let n=RC(t);P(n),D(n),_.current=n?e:null,n||(S.current=rw(t))},t[2]=F):F=t[2];let I=F,L;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(L=()=>{let e=u.current,t=m.current;if(!e||!t||!p.current||!_.current&&!h.current)return!1;let n=_.current??h.current;if(!n)return!1;let r=!_.current&&g.current?.isConnected?g.current:Array.from(e.querySelectorAll(`[data-chat-message-row]`)).find(e=>e.dataset.messageRenderKey===n||e.dataset.clientSubmissionId===n);if(!r)return!1;_.current&&(h.current=n,g.current=r,_.current=null,v.current=Math.min(64,Math.max(0,e.clientHeight)*.1),y.current=v.current);let i=parseFloat(getComputedStyle(t.parentElement).paddingTop)||0,a=Math.max(i,t.getBoundingClientRect().top-r.getBoundingClientRect().bottom),o=Math.max(y.current,a),s=Math.min(v.current,Math.min(64,Math.max(0,e.clientHeight)*.1)),c=Math.max(0,Math.min(s,o-a));return y.current=a+c,t.style.height===`${c}px`?!1:(t.style.height=`${c}px`,!0)},t[3]=L):L=t[3];let R=L,z;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>{let t=u.current;if(!t||!e?.force&&!p.current)return;e?.force&&P(!0);let n=WC(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:VC()});return}zC(t),w.current=t.scrollHeight,T.current=t.clientHeight,D(RC(t))},t[4]=z):z=t[4];let B=z,V;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(V=()=>{let e=u.current;!e||e.scrollHeight<=e.clientHeight||(P(!1),D(RC(e)))},t[5]=V):V=t[5];let H=V,U;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(U=()=>{let e=u.current;if(!e)return;!p.current&&!WC(e)&&iw(e,S.current);let t=R(),n=e.scrollHeight>w.current,r=e.clientHeight<T.current;w.current=e.scrollHeight,T.current=e.clientHeight,(n||r||t)&&B(),D(RC(e))},t[6]=U):U=t[6];let W=U,G;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(G=()=>{let e=u.current;e&&p.current&&(WC(e)?zC(e):e.scrollHeight>w.current&&B()),C.current===null&&(C.current=requestAnimationFrame(()=>{C.current=null,W()}))},t[7]=G):G=t[7];let ee=G,te;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(te=e=>{if(f.current===e||(x.current?.disconnect(),b.current?.disconnect(),b.current=null,x.current=null,f.current=e,!e))return;let t=new ResizeObserver(ee);t.observe(e),x.current=t;let n=new MutationObserver(e=>{let t=u.current;!t||!p.current||!WC(t)||(R()||e.some(cw))&&zC(t)});n.observe(e,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:[`style`]}),b.current=n},t[8]=te):te=t[8];let ne=te,re,ie;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(re=()=>()=>{x.current?.disconnect(),b.current?.disconnect(),C.current!==null&&(cancelAnimationFrame(C.current),C.current=null)},ie=[],t[9]=re,t[10]=ie):(re=t[9],ie=t[10]),(0,Q.useEffect)(re,ie);let ae;t[11]!==s||t[12]!==l||t[13]!==c?(ae=()=>{let e=u.current;if(!e)return;let t=RC(e),n=T.current>0&&(e.scrollHeight!==w.current||e.clientHeight!==T.current);if(!t&&p.current&&n){D(!1),ee();return}P(t),t||(S.current=rw(e)),D(t),t&&R(),e.scrollTop<100&&!t&&s&&!c&&l()},t[11]=s,t[12]=l,t[13]=c,t[14]=ae):ae=t[14];let oe=ae,se;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(se=e=>{B({force:!0,smooth:e===void 0||e})},t[15]=se):se=t[15];let ce=se,le,ue;t[16]!==n||t[17]!==r?(le=()=>{if(n){if(r){O.current=!0;return}O.current===!0&&(O.current=!1,P(!0),B({force:!0}))}},ue=[r,n,P,B],t[16]=n,t[17]=r,t[18]=le,t[19]=ue):(le=t[18],ue=t[19]),(0,Q.useLayoutEffect)(le,ue);let K;t[20]!==n||t[21]!==r?(K=()=>{!n||r||(M.current={first:void 0,len:0,scrollHeight:0},k.current=0,w.current=0,T.current=0,h.current=null,g.current=null,y.current=0,Array.from(u.current?.querySelectorAll(`[data-chat-message-row]`)??[]).some(e=>e.dataset.messageRenderKey===_.current||e.dataset.clientSubmissionId===_.current)||(_.current=null),m.current&&(m.current.style.height=`0px`),P(!0),B({force:!0}))},t[20]=n,t[21]=r,t[22]=K):K=t[22];let q;t[23]!==i||t[24]!==n||t[25]!==r?(q=[i,n,r,P,B],t[23]=i,t[24]=n,t[25]=r,t[26]=q):q=t[26],(0,Q.useLayoutEffect)(K,q);let de,fe;t[27]!==a||t[28]!==r||t[29]!==o?(de=()=>{if(r)return;let e=A.current&&!o;A.current=o;let t=R(),n=a.length,i=k.current;k.current=n;let s=(u.current?.scrollHeight??0)>w.current;p.current&&(n>i||s||t||e)&&B()},fe=[a,o,r,B,R],t[27]=a,t[28]=r,t[29]=o,t[30]=de,t[31]=fe):(de=t[30],fe=t[31]),(0,Q.useLayoutEffect)(de,fe);let pe,J;t[32]!==a||t[33]!==r?(pe=()=>{let e=u.current;if(!e||r)return;let t=M.current,n=a[0],i=a.length,o=e.scrollHeight,s=i-t.len;s>0&&t.len>0&&!ow(n,t.first)&&ow(a[s],t.first)&&!WC(e)&&t.scrollHeight>0&&!iw(e,S.current)&&(e.scrollTop+=o-t.scrollHeight),M.current={first:n,len:i,scrollHeight:o}},J=[a,r],t[32]=a,t[33]=r,t[34]=pe,t[35]=J):(pe=t[34],J=t[35]),(0,Q.useLayoutEffect)(pe,J);let me,he;t[36]!==n||t[37]!==r?(me=()=>{if(!n||r)return;let e=u.current;if(!e)return;let t=new ResizeObserver(ee);t.observe(e);let i=e=>{Math.abs(e.deltaY)<Math.abs(e.deltaX)||Math.abs(e.deltaY)<.25||aw(e)&&H()},a=0,o=e=>{e.touches.length===1&&(a=e.touches[0].clientY)},s=e=>{if(e.touches.length!==1)return;let t=e.touches[0].clientY,n=t-a;a=t,n>2&&H()},c=t=>{if(t.button!==0)return;let n=e.offsetWidth-e.clientWidth;if(n<=0)return;let r=e.getBoundingClientRect();t.clientX>=r.right-n&&H()},l=()=>{let t=window.getSelection();!t||t.isCollapsed||!e.contains(t.anchorNode)||(H(),S.current=rw(e))},d=t=>{(t.target instanceof Element?t.target:null)?.closest(`button[aria-expanded="false"]:not([aria-haspopup]), summary`)&&(H(),S.current=rw(e))};return e.addEventListener(`chat-scroll-reading`,H),e.addEventListener(`wheel`,i,{passive:!0}),e.addEventListener(`pointerdown`,c),e.addEventListener(`touchstart`,o,{passive:!0}),e.addEventListener(`touchmove`,s,{passive:!0}),e.addEventListener(`click`,d,!0),document.addEventListener(`selectionchange`,l),()=>{t.disconnect(),e.removeEventListener(`chat-scroll-reading`,H),e.removeEventListener(`wheel`,i),e.removeEventListener(`pointerdown`,c),e.removeEventListener(`touchstart`,o),e.removeEventListener(`touchmove`,s),e.removeEventListener(`click`,d,!0),document.removeEventListener(`selectionchange`,l)}},he=[n,r,H,ee],t[36]=n,t[37]=r,t[38]=me,t[39]=he):(me=t[38],he=t[39]),(0,Q.useLayoutEffect)(me,he);let ge;t[40]===n?ge=t[41]:(ge=()=>{if(!n)return;let e=u.current,t=d.current;if(!e||!t)return;let r=()=>{let n=`${t.getBoundingClientRect().height+16}px`;e.style.paddingBottom=n,e.style.scrollPaddingBottom=n,ee()};r();let i=new ResizeObserver(r);return i.observe(t),()=>{i.disconnect(),e.style.removeProperty(`padding-bottom`),e.style.removeProperty(`scroll-padding-bottom`)}},t[40]=n,t[41]=ge);let _e;t[42]!==n||t[43]!==r?(_e=[n,r,ee],t[42]=n,t[43]=r,t[44]=_e):_e=t[44],(0,Q.useLayoutEffect)(ge,_e);let ve;return t[45]!==E||t[46]!==oe?(ve={scrollRef:u,composerDockRef:d,atBottom:E,registerListContentRef:ne,scrollToBottom:ce,onScroll:oe,replySpaceRef:m,reserveReplySpace:I},t[45]=E,t[46]=oe,t[47]=ve):ve=t[47],ve}function cw(e){return e.target instanceof HTMLElement&&e.target.hasAttribute(`data-virtuoso-scroller`)}var lw=256*1024,uw=new TextEncoder;function dw(e){return uw.encode(e).byteLength}function fw(e){return dw(e)<=262144?e:new TextDecoder().decode(uw.encode(e).subarray(0,lw),{stream:!0})}function pw(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(`
60
+ `);if((i.content.some(e=>e.type!==`text`)||i.attachments?.length)&&(n=!0),!e)continue;if(t<=256){n=!0;continue}let a=uw.encode(e),o=a.byteLength+256>t?new TextDecoder().decode(a.subarray(0,t-256),{stream:!0}):e;o!==e&&(n=!0);let s=dw(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 mw=`xopc:side-chat-panes:v3`,hw={text:``,attachments:[]};function gw(e){return Math.min(760,Math.max(360,Math.round(e)))}function _w(){return{panes:{},tabs:[],widthPx:520}}function vw(){try{let e=JSON.parse(sessionStorage.getItem(mw)||`{}`),t=e.identity;if(t&&t!==m.getState().conversationId)return _w();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:gw(typeof e.widthPx==`number`?e.widthPx:520)}}catch{return _w()}}function yw(e){try{sessionStorage.setItem(mw,JSON.stringify({...e,identity:m.getState().conversationId}))}catch{}}var bw=vw(),xw=_((e,t)=>{let n=n=>{e(n),queueMicrotask(()=>{let e=t();yw({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{...bw,drafts:{},readings:{},setDraftText:(n,r)=>e({drafts:{...t().drafts,[n]:{...t().drafts[n]??hw,text:r}}}),setDraftAttachments:(n,r)=>e({drafts:{...t().drafts,[n]:{...t().drafts[n]??hw,attachments:r}}}),rememberMessages:(n,r)=>{let i={...t().readings};delete i[n],i[n]=pw(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)=>{mi.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]??hw},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:()=>{mi.getState().reset(),e({drafts:{},readings:{},pendingCreate:null,creatingRequests:{}}),n({panes:{},tabs:[]})},pendingCreate:null,creatingRequests:{},requestCreate:(n,i=[])=>{mi.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)=>{mi.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;mi.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&&(mi.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(mi.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&&mi.getState().activate(`side:${o.id}`,e),o||i.requestCreate(e)},setWidthPx:e=>n({widthPx:gw(e)})}});m.subscribe((e,t)=>{if(e.conversationId&&!t.conversationId&&e.baseUrl===t.baseUrl){let e=vw();xw.setState(e)}if(e.baseUrl!==t.baseUrl||t.conversationId!==void 0&&e.conversationId!==t.conversationId){xw.getState().reset();try{sessionStorage.removeItem(`xopc:side-chat-client-id`)}catch{}}});function Sw(e){return e.acceptsArgs?`/${e.name} `:`/${e.name}`}var Cw=3e4,ww=null;function Tw(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 Ew(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(ww&&ww.key===n&&e-ww.at<Cw)return ww.items.map(e=>({...e,...o.has(e.relativePath)?{isRecent:!0}:{isRecent:void 0}}))}let s={conversationId:n,agentId:r},c=Tw(a.length===0?await Ha(``,s):await Ba(a,s,i),o);return n&&a.length===0&&(ww={key:n,at:Date.now(),items:c}),c}async function Dw(e,t){return Ha(e,{conversationId:t.conversationId,agentId:t.agentId})}function Ow(e,...t){let n=e.trim().toLocaleLowerCase();return!n||t.some(e=>e?.toLocaleLowerCase().includes(n))}async function kw(e){let t=await f(p(e)),n=await t.json().catch(()=>({}));if(!t.ok||!n.payload)throw Error(typeof n.error==`string`?n.error:`HTTP ${t.status}`);return n.payload}var Aw=[{kind:`file`,search:(e,t)=>Ew(e,{conversationId:t.conversationId,agentId:t.currentAgentId,limit:10,recentPaths:t.recentPaths})},{kind:`note`,async search(e,t){return(await ze({...e.trim()?{search:e.trim()}:{},limit:5,sortBy:`updatedAt`,sortOrder:`desc`})).items.filter(e=>e.status!==`trashed`&&!t.selectedContextKeys.has(`note:${e.id}`)).map(e=>({id:`note:${e.id}`,kind:`note`,name:e.title?.trim()||e.snippet?.trim()||y(t.language).chat.commandPalette.untitledNote,description:e.snippet?.trim()||``,noteRef:{sourceId:e.id,expectedVersion:String(e.updatedAt)}}))}},{kind:`session`,async search(e,t){return(await dn({...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 ho(t.currentAgentId,t.conversationId)).skills.flatMap(n=>{if(!n.availableForCurrentAgent)return[];let r=xo(n,t.language);return Ow(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 ni(),r=y(t.language).agentsSettings;return n.items.flatMap(t=>{let n=qo(t,r),i=Jo(t,r);return Ow(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 kw(`/api/browser/tabs?${new URLSearchParams({conversationId:t.conversationId})}`)).tabs.flatMap(n=>!Ow(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}}])}}],jw=(0,Q.createContext)({target:null,register:()=>()=>{}});function Mw(e){let t=(0,X.c)(9),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],t[0]=r):r=t[0];let[i,a]=(0,Q.useState)(r),o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=e=>(a(t=>[...t,e]),()=>a(t=>t.filter(t=>t!==e))),t[1]=o):o=t[1];let s=o,c;t[2]===i?c=t[3]:(c=i.at(-1)??null,t[2]=i,t[3]=c);let l;t[4]===c?l=t[5]:(l={target:c,register:s},t[4]=c,t[5]=l);let u=l,d;return t[6]!==n||t[7]!==u?(d=(0,Z.jsx)(jw,{value:u,children:n}),t[6]=n,t[7]=u,t[8]=d):d=t[8],d}function Nw(){let e=(0,X.c)(2),{register:t}=(0,Q.useContext)(jw),n;return e[0]===t?n=e[1]:(n=(0,Z.jsx)(`div`,{ref:t,className:`min-w-0 shrink-0`}),e[0]=t,e[1]=n),n}function Pw(){return(0,Q.useContext)(jw).target}function Fw({conversationId:e,turnId:t,messages:n,ready:r,hasMore:i,loadingMore:a,loadMore:o,reveal:s,onLocated:c}){let l=(0,Q.useRef)({key:``,finished:!1,requestedLength:-1});(0,Q.useEffect)(()=>{let u=`${e??``}:${t??``}`;if(l.current.key!==u&&(l.current={key:u,finished:!1,requestedLength:-1}),!t||!r||l.current.finished)return;let d=l.current,f=n.findIndex(e=>e.turnId===t);if(f>=0){let e=0,t=!1,n=0,r=()=>{t||l.current===d&&(s(f)?(d.finished=!0,c?.(!0)):++n<3?e=requestAnimationFrame(r):(d.finished=!0,c?.(!1)))};return e=requestAnimationFrame(r),()=>{t=!0,cancelAnimationFrame(e)}}if(!a){if(!i||l.current.requestedLength===n.length){l.current.finished=!0,c?.(!1);return}l.current.requestedLength=n.length,o().catch(()=>{l.current===d&&(d.finished=!0,c?.(!1))})}},[e,t,n,r,i,a,o,s,c])}function Iw({interaction:e,path:t,complete:n}){let r=h(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 g(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,Z.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,Z.jsx)(`p`,{className:`font-medium text-fg`,children:r?`设备需要补充信息`:`Device needs input`}),(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-fg-muted`,children:e.message}),d.length?(0,Z.jsx)(`ul`,{className:`max-h-24 overflow-y-auto text-xs text-fg-muted`,children:d.map(([t,n])=>(0,Z.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,Z.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,Z.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:r?`输入不符合要求,或设备请求已结束。`:`The input is invalid or the device request has ended.`}):null,(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(pi,{type:`button`,variant:`secondary`,disabled:o,onClick:()=>void u(`decline`),children:r?`拒绝`:`Decline`}),(0,Z.jsx)(pi,{type:`submit`,disabled:o,children:r?`提交给设备`:`Send to device`})]})]})}function Lw(e){let t=(0,X.c)(8),{conversationId:n,active:r}=e,i;t[0]===n?i=t[1]:(i=n?p(`/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}=Gr(a,Rw,s),u=c?.payload?.[0],d;return t[4]!==u||t[5]!==l||t[6]!==a?(d=a&&u?(0,Z.jsx)(Iw,{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 Rw(e){return g(e)}function zw(e){let t=(0,X.c)(24),{sk:n,onPick:r,disabled:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Rt,{className:`size-4`,"aria-hidden":!0}),t[0]=a):a=t[0];let o;t[1]===n.findCapability?o=t[2]:(o=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-sm text-accent-fg`,children:[a,n.findCapability]}),t[1]=n.findCapability,t[2]=o);let s;t[3]===n.findWelcome?s=t[4]:(s=(0,Z.jsx)(`h1`,{className:`text-xl font-semibold text-fg`,children:n.findWelcome}),t[3]=n.findWelcome,t[4]=s);let c;t[5]===n.findDescription?c=t[6]:(c=(0,Z.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:n.findDescription}),t[5]=n.findDescription,t[6]=c);let l;if(t[7]!==i||t[8]!==r||t[9]!==n.findExamples){let e;t[11]!==i||t[12]!==r?(e=e=>(0,Z.jsx)(pi,{disabled:i,onClick:()=>r(e),children:e},e),t[11]=i,t[12]=r,t[13]=e):e=t[13],l=n.findExamples.map(e),t[7]=i,t[8]=r,t[9]=n.findExamples,t[10]=l}else l=t[10];let d;t[14]===l?d=t[15]:(d=(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:l}),t[14]=l,t[15]=d);let f;t[16]===n.findBack?f=t[17]:(f=(0,Z.jsx)(u,{to:`/capabilities/skills`,className:`text-sm text-accent-fg hover:underline`,children:n.findBack}),t[16]=n.findBack,t[17]=f);let p;return t[18]!==o||t[19]!==s||t[20]!==c||t[21]!==d||t[22]!==f?(p=(0,Z.jsxs)(`section`,{className:`mx-auto flex max-w-xl flex-col items-start gap-4 py-8 sm:py-12`,children:[o,s,c,d,f]}),t[18]=o,t[19]=s,t[20]=c,t[21]=d,t[22]=f,t[23]=p):p=t[23],p}function Bw(e){let t=`/api/sessions/${encodeURIComponent(e)}/connection-wait`,n=Nn(t=>t.sessions[e]?.localDraft),{data:r,mutate:i,isLoading:a}=Gr(n?null:[t,n===!1?`persisted`:`unknown`],async()=>await wr(e)?null:(await g(p(t))).payload,{refreshInterval:e=>e?.wait?5e3:0,revalidateOnFocus:!0}),o=(0,Q.useRef)(r);o.current=r;let s=(0,Q.useRef)(!1),c=(0,Q.useRef)(!1),l=(0,Q.useRef)(0),u=(0,Q.useRef)(null),[d,f]=(0,Q.useState)(!1),[m,_]=(0,Q.useState)(),[v,y]=(0,Q.useState)(),b=(0,Q.useCallback)(async(e,n,r,a,d)=>{let m=o.current,v=m?.wait;if(!v||(e===`cancel`?c.current:s.current||c.current))return!1;e===`cancel`?c.current=!0:s.current=!0,l.current+=1,f(!0),_(void 0),e===`cancel`&&y(void 0);let b=e===`connect`?Qo():null,x=JSON.stringify([v.id,v.objectiveRevision,e,n,r,a,d]);u.current?.signature!==x&&(u.current={signature:x,key:crypto.randomUUID()});let S=u.current.key,C=i=>g(p(`${t}/actions`),{method:`POST`,body:JSON.stringify({action:e,needKey:n,accountId:r,candidateRef:a,instanceId:d,waitId:v.id,expectedTranscriptId:i.transcriptId,expectedVersion:i.wait.version,...e===`cancel`?{expectedObjectiveRevision:v.objectiveRevision}:{},idempotencyKey:S})});try{let n;try{n=await C(m)}catch(r){if(e!==`cancel`||r.status!==409)throw r;let a=(await g(p(t))).payload;if(await i(e=>!e||e.transcriptId!==a.transcriptId||a.revision>=e.revision?a:e,!1),a.transcriptId!==m.transcriptId||a.wait?.id!==v.id||a.wait.objectiveRevision!==v.objectiveRevision)throw r;n=await C(a)}let r=n.payload.snapshot;if(await i(e=>!e||e.transcriptId!==r.transcriptId||r.revision>=e.revision?r:e,!1),n.payload.authorizationUrl){if(!await Zo(n.payload.authorizationUrl,b))throw Error(`Unable to open the authorization window. Allow pop-ups, then retry.`)}else $o(b);return u.current?.signature===x&&(u.current=null),!0}catch(t){if($o(b),t.status===409&&e===`cancel`){let e=h.getState().language===`zh`?`目标状态已变化,未能取消。请检查当前任务状态后再试。`:`The objective state changed and cancellation was not confirmed. Check its current status and try again.`;_(e),y(e)}else if(t.status!==409){let n=t instanceof Error?t.message:String(t);_(n),e===`cancel`&&y(n)}return await i(),!1}finally{e===`cancel`?c.current=!1:s.current=!1,--l.current,f(l.current>0)}},[t,i]);return(0,Q.useEffect)(()=>{let t=t=>{let n=t.detail;n?.conversationId===e&&(n.revision??1/0)>(o.current?.revision??0)&&i()};window.addEventListener(`session-connection-wait-changed`,t);let n=()=>{i()};return window.addEventListener(`gateway-realtime-connected`,n),()=>{window.removeEventListener(`session-connection-wait-changed`,t),window.removeEventListener(`gateway-realtime-connected`,n)}},[e,i]),{wait:r?.wait,isLoading:a,busy:d,error:m,cancellationError:v,act:b,dismissError:()=>{_(void 0),y(void 0)}}}function Vw(e){let t=(0,X.c)(39),{need:n,language:r,disabled:i,onSelect:a,onConnect:o}=e,s=(0,Q.useId)(),[c,l]=(0,Q.useState)(),u=r===`zh`,d;if(t[0]!==n.accounts||t[1]!==c){let e;t[3]===c?e=t[4]:(e=e=>e.id===c,t[3]=c,t[4]=e),d=n.accounts.some(e),t[0]=n.accounts,t[1]=c,t[2]=d}else d=t[2];let f=d,p=u?`这次使用哪个 ${n.label} 账号或工作区?`:`Which ${n.label} account or workspace should this request use?`,m;t[5]===p?m=t[6]:(m=(0,Z.jsx)(`legend`,{className:`float-left mb-3 w-full text-sm font-medium text-fg`,children:p}),t[5]=p,t[6]=m);let h;if(t[7]!==s||t[8]!==n.accounts||t[9]!==c){let e;t[11]!==s||t[12]!==c?(e=e=>(0,Z.jsxs)(`label`,{className:`flex min-h-11 cursor-pointer items-center gap-3 rounded-lg border px-3 py-2 text-sm text-fg hover:bg-surface-hover ${c===e.id?`border-accent bg-surface-hover`:`border-edge`}`,children:[(0,Z.jsx)(`input`,{type:`radio`,name:s,value:e.id,checked:c===e.id,onChange:()=>l(e.id),className:`shrink-0 accent-accent focus-visible:outline-2 focus-visible:outline-accent`}),(0,Z.jsx)(`span`,{className:`min-w-0 break-words`,children:e.label})]},e.id),t[11]=s,t[12]=c,t[13]=e):e=t[13],h=n.accounts.map(e),t[7]=s,t[8]=n.accounts,t[9]=c,t[10]=h}else h=t[10];let g;t[14]===h?g=t[15]:(g=(0,Z.jsx)(`div`,{className:`clear-both grid max-h-48 gap-2 overflow-y-auto sm:grid-cols-2`,children:h}),t[14]=h,t[15]=g);let _=u?`选择仅用于本次目标,选定后会自动继续。`:`This choice applies to this objective only. It will continue after selection.`,v;t[16]===_?v=t[17]:(v=(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:_}),t[16]=_,t[17]=v);let y=i||!f,b;t[18]!==a||t[19]!==c||t[20]!==f?(b=()=>{f&&c&&a(c)},t[18]=a,t[19]=c,t[20]=f,t[21]=b):b=t[21];let x=u?`使用所选账号并继续`:`Use selected account and continue`,S;t[22]!==x||t[23]!==y||t[24]!==b?(S=(0,Z.jsx)(`button`,{type:`button`,disabled:y,onClick:b,className:`min-h-11 rounded-lg bg-accent px-3 py-2 text-sm text-on-accent disabled:opacity-50`,children:x}),t[22]=x,t[23]=y,t[24]=b,t[25]=S):S=t[25];let C=u?`连接其他账号`:`Connect another account`,w;t[26]!==i||t[27]!==o||t[28]!==C?(w=(0,Z.jsx)(`button`,{type:`button`,disabled:i,onClick:o,className:`min-h-11 rounded-lg px-3 py-2 text-sm text-accent hover:bg-surface-hover disabled:opacity-50`,children:C}),t[26]=i,t[27]=o,t[28]=C,t[29]=w):w=t[29];let T;t[30]!==S||t[31]!==w?(T=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[S,w]}),t[30]=S,t[31]=w,t[32]=T):T=t[32];let E;return t[33]!==i||t[34]!==T||t[35]!==m||t[36]!==g||t[37]!==v?(E=(0,Z.jsxs)(`fieldset`,{disabled:i,className:`mt-3 min-w-0 space-y-3 border-t border-edge-subtle pt-3`,children:[m,g,v,T]}),t[33]=i,t[34]=T,t[35]=m,t[36]=g,t[37]=v,t[38]=E):E=t[38],E}var Hw=(0,Q.lazy)(()=>o(()=>import(`./mcp-conversation-setup-page-Bn49Ph1n.js`).then(e=>({default:e.McpConversationSetupDialog})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29])));function Uw(e){let t=(0,X.c)(35),{conversationId:n}=e,r=h(Kw),[i,a]=l(),o;t[0]===i?o=t[1]:(o=i.get(`mcpSetup`),t[0]=i,t[1]=o);let s=o,c;t[2]!==i||t[3]!==a?(c=e=>{let t=new URLSearchParams(i);e?t.set(`mcpSetup`,e):t.delete(`mcpSetup`),a(t,{replace:!e})},t[2]=i,t[3]=a,t[4]=c):c=t[4];let d=c,f;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(f={refreshInterval:Ww,shouldRetryOnError:!1},t[5]=f):f=t[5];let{data:p,mutate:m}=Gr(`/api/mcp/setup/conversations/${encodeURIComponent(n)}`,Gw,f),g;t[6]!==n||t[7]!==p?.permitted||t[8]!==m?(g=()=>{if(p?.permitted===!1)return;let e=e=>{let t=e.detail;(t?.conversationId??t?.key)===n&&m()},t=()=>{m()};return window.addEventListener(`session-mcp-setup-changed`,e),window.addEventListener(`session-transcript-updated`,e),window.addEventListener(`gateway-realtime-connected`,t),()=>{window.removeEventListener(`session-mcp-setup-changed`,e),window.removeEventListener(`session-transcript-updated`,e),window.removeEventListener(`gateway-realtime-connected`,t)}},t[6]=n,t[7]=p?.permitted,t[8]=m,t[9]=g):g=t[9];let _=p?.permitted,v;t[10]!==n||t[11]!==m||t[12]!==_?(v=[n,m,_],t[10]=n,t[11]=m,t[12]=_,t[13]=v):v=t[13],(0,Q.useEffect)(g,v);let y;t[14]!==m||t[15]!==s||t[16]!==d?(y=s?(0,Z.jsx)(Q.Suspense,{fallback:null,children:(0,Z.jsx)(Hw,{setupId:s,onClose:()=>{d(null),m()}})}):null,t[14]=m,t[15]=s,t[16]=d,t[17]=y):y=t[17];let b=y;if(!p?.setup)return b;let x=p.setup,S=r===`zh`?`服务连接`:`Service connection`,C=x.expired?r===`zh`?`连接请求已过期`:`Connection request expired`:r===`zh`?`连接`:`Connect`,w=x.displayName||x.serverId,T;t[18]!==w||t[19]!==C?(T=(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 break-all text-sm text-fg`,role:`status`,children:[C,` `,w]}),t[18]=w,t[19]=C,t[20]=T):T=t[20];let E=`/mcp-setup/${encodeURIComponent(x.setupId)}`,D;t[21]!==d||t[22]!==x.setupId?(D=e=>{e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),d(x.setupId))},t[21]=d,t[22]=x.setupId,t[23]=D):D=t[23];let O=r===`zh`?`完成连接`:`Complete connection`,k;t[24]!==E||t[25]!==D||t[26]!==O?(k=(0,Z.jsx)(u,{className:`inline-flex min-h-11 items-center rounded-lg px-3 text-sm text-accent-fg hover:bg-surface-hover`,to:E,onClick:D,children:O}),t[24]=E,t[25]=D,t[26]=O,t[27]=k):k=t[27];let A;t[28]!==T||t[29]!==k||t[30]!==S?(A=(0,Z.jsxs)(`section`,{className:`mb-2 flex flex-wrap items-center gap-3 rounded-xl border border-edge bg-surface-panel px-3 py-2`,"aria-label":S,children:[T,k]}),t[28]=T,t[29]=k,t[30]=S,t[31]=A):A=t[31];let j;return t[32]!==b||t[33]!==A?(j=(0,Z.jsxs)(Z.Fragment,{children:[A,b]}),t[32]=b,t[33]=A,t[34]=j):j=t[34],j}function Ww(e){return e?.setup?5e3:0}async function Gw(e){try{return{permitted:!0,...(await g(p(e))).payload}}catch(e){let t=e;if([403,404].includes(t.status??0))return{permitted:!1,setup:null};throw t}}function Kw(e){return e.language}var qw={zh:{waiting:`等待连接`,install:`安装`,installing:`正在准备安装`,connect:`连接`,reconnect:`重新连接`,details:`查看详情`,skip:`跳过连接`,cancel:`取消这个目标`,ready:`已连接`,check:`我已完成授权`,authorizing:`等待完成授权`,queued:`已连接,等待继续`,queuedSkipped:`等待使用现有信息继续`,checkingConnection:`正在检查连接`,checkingTools:`已连接,正在验证工具`,queueHint:`目标已保存,正在等待当前执行结束。`,interruptedInputHint:`有条补充消息在重启时中断。请重新发送要求,或移除上方中断的消息后继续。`,checkFailed:`连接检查暂时失败,目标已保存`,interrupted:`恢复检查曾中断,目标已保存`,lastChecked:`最近检查`,scope:`确认后继续`,scopeHint:`这个目标已等待了一段时间。请确认仍要按下方原始要求继续;如需修改时间范围,请先在聊天中说明。未读等条件将以实际执行时为准。`,account:`选择账号`,all:`查看全部连接`,close:`关闭`,intro:`完成连接后,将自动恢复当前目标。你也可以继续发送消息。`,callbackHint:`远程 Gateway 无法接收本地回调时,粘贴浏览器地址栏中的完整回调 URL。`,callbackPlaceholder:`完整回调 URL`,callbackSubmit:`完成连接`,replace:`更换应用`,confirmReplace:`确认改用`,apps:`个应用需要连接`,preserved:`目标已保留`,retry:`重试检查`,toolsUnavailable:`应用工具暂不可用`,toolsHint:`账号已连接,当前无法使用任务所需工具。可以重试检查,无需重新授权。`},en:{waiting:`Waiting for connection`,install:`Install`,installing:`Preparing installation`,connect:`Connect`,reconnect:`Reconnect`,details:`Details`,skip:`Skip connection`,cancel:`Cancel this objective`,ready:`Connected`,check:`Check authorization`,authorizing:`Waiting for authorization`,queued:`Connected, waiting to continue`,queuedSkipped:`Waiting to continue with available information`,checkingConnection:`Checking connection`,checkingTools:`Connected, checking tools`,queueHint:`Your objective is saved. Waiting for the current execution to finish.`,interruptedInputHint:`A message was interrupted during restart. Resend the requirement or remove the interrupted message above before continuing.`,checkFailed:`Connection check failed; objective saved`,interrupted:`Recovery check interrupted; objective saved`,lastChecked:`Last checked`,scope:`Confirm and continue`,scopeHint:`This objective has been waiting for a while. Confirm the original request below, or send a message to change the time range first. Conditions such as unread status are evaluated at execution time.`,account:`Choose an account`,all:`View all connections`,close:`Close`,intro:`The current objective resumes automatically after connecting. You can keep sending messages.`,callbackHint:`If a remote Gateway cannot receive the local callback, paste the complete callback URL from the browser address bar.`,callbackPlaceholder:`Complete callback URL`,callbackSubmit:`Complete connection`,replace:`Change app`,confirmReplace:`Confirm switch to`,apps:`apps need connecting`,preserved:`Objective preserved`,retry:`Retry check`,toolsUnavailable:`App tools unavailable`,toolsHint:`The account is connected, but the tools needed for this task are unavailable. Retry the check without reconnecting.`}},Jw=`rounded-lg border border-edge px-3 py-1.5 text-sm text-fg hover:bg-surface-hover disabled:opacity-50`,Yw=`rounded-lg bg-accent px-3 py-1.5 text-sm text-on-accent disabled:opacity-50`;function Xw({conversationId:e}){let{wait:t,busy:n,error:r,cancellationError:i,act:a,dismissError:o}=Bw(e),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(),[d,f]=(0,Q.useState)(),[p,m]=(0,Q.useState)(),[g,_]=(0,Q.useState)(!1),[v,x]=(0,Q.useState)(),O=h(e=>e.language),k=qw[O];if(!t)return i?(0,Z.jsxs)(`div`,{role:`alert`,className:`mb-2 flex items-center gap-2 rounded-xl border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,children:[(0,Z.jsx)(`p`,{className:`min-w-0 flex-1`,children:i}),(0,Z.jsx)(`button`,{type:`button`,onClick:o,className:Jw,children:k.close})]}):(0,Z.jsx)(Uw,{conversationId:e});let A=t.needs[0],j=t.needs.length===1,M=t.phase===`queued`,N=t.recoveryStage===`checking_connection`||t.recoveryStage===`checking_tools`,P=t.needs.find(e=>e.phase===`choose_account`),F=t.needs.some(e=>e.capabilityError);if(t.phase===`ready`&&!N&&!t.recoveryError)return(0,Z.jsx)(Uw,{conversationId:e});let I=t.recoveryStage===`checking_connection`?k.checkingConnection:t.recoveryStage===`checking_tools`?k.checkingTools:M?t.resolution===`skipped`?k.queuedSkipped:k.queued:t.recoveryError===`check_failed`?k.checkFailed:t.recoveryError?k.interrupted:F?k.toolsUnavailable:P?k.account:j&&A.phase===`authorizing`?k.authorizing:k.waiting,L=M||N?k.details:t.recoveryError?k.retry:t.phase===`review_scope`?k.scope:j&&A.phase===`install`?g?k.installing:`${k.install} ${A.label}`:j&&A.phase===`connect`?O===`zh`?`连接 ${A.label}`:`Connect ${A.label}`:j&&A.phase===`reconnect`?k.reconnect:j&&A.phase===`authorizing`?k.check:k.details;async function R(e=A){if(e.target.type===`store-connector`){_(!0),x(void 0);try{let t=await ga(e.target.packageName,e.target.version);if(t.reviewHash!==e.target.reviewHash||t.definition.id!==e.target.connectorId||t.definition.provenance?.sha256!==e.target.sha256)throw Error(O===`zh`?`Connector 包在审查后发生了变化,请重新发起推荐。`:`The Connector package changed after review. Request a new recommendation.`);f(Ct(t.definition,{packageName:t.packageName,version:t.version,reviewHash:t.reviewHash,permissions:t.permissions})),m(e.key)}catch(e){x(e instanceof Error?e.message:String(e))}finally{_(!1)}}}function z(){M||N?c(!0):t?.recoveryError?a(`check`):t?.phase===`review_scope`?c(!0):j&&A.phase===`install`?R():j&&[`connect`,`reconnect`].includes(A.phase)?a(`connect`,A.key):j&&A.phase===`authorizing`?a(`check`):c(!0)}return(0,Z.jsxs)(`section`,{className:`mb-2 rounded-xl border border-edge bg-surface-panel px-3 py-2`,"aria-label":I,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(Ge,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,Z.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left text-sm text-fg`,onClick:()=>c(!0),children:[(0,Z.jsx)(`span`,{role:`status`,children:j?`${I} · ${A.label}`:`${I} · ${t.needs.length} ${k.apps}`}),(0,Z.jsx)(te,{className:`ml-1 inline size-3`,"aria-hidden":!0})]}),(0,Z.jsxs)(`button`,{type:`button`,className:P||M||N?Jw:Yw,disabled:n&&!N||g,onClick:z,children:[n&&(0,Z.jsx)(Je,{className:`mr-1 inline size-3 animate-spin`,"aria-hidden":!0}),L]}),!M&&!N&&(0,Z.jsx)(`button`,{type:`button`,className:`text-xs text-fg-muted hover:text-fg`,disabled:n,onClick:()=>void a(`skip`),children:k.skip}),(0,Z.jsx)(`button`,{type:`button`,className:`min-h-11 px-2 text-xs text-fg-muted hover:text-fg`,onClick:()=>void a(`cancel`),children:k.cancel})]}),t.queueBlocked&&(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.blockedInputId?k.interruptedInputHint:k.queueHint}),t.lastCheckedAt&&(0,Z.jsxs)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:[k.lastChecked,`: `,new Date(t.lastCheckedAt).toLocaleTimeString(O===`zh`?`zh-CN`:`en-US`)]}),P&&!M&&(0,Z.jsx)(`p`,{className:`mt-2 line-clamp-2 break-words text-sm text-fg-muted`,children:t.summary}),P&&!M&&(0,Z.jsx)(Vw,{need:P,language:O,disabled:n||N,onSelect:e=>void a(`select_account`,P.key,e),onConnect:()=>void a(`connect`,P.key)},`${t.id}:${t.objectiveRevision}:${P.key}`),(r||v)&&(0,Z.jsxs)(`p`,{role:`alert`,className:`mt-2 text-xs text-fg-muted`,children:[r??v,` `,(0,Z.jsx)(`button`,{type:`button`,className:`text-accent`,onClick:()=>void a(`check`),children:k.retry})]}),(0,Z.jsx)(D,{open:s,onOpenChange:c,children:(0,Z.jsxs)(w,{children:[(0,Z.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[2px]`}),(0,Z.jsxs)(T,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(90dvh,34rem)] w-[min(94vw,34rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-5 py-4`,children:[(0,Z.jsx)(E,{className:`font-medium text-fg`,children:k.preserved}),(0,Z.jsx)(C,{"aria-label":k.close,children:(0,Z.jsx)(Gt,{className:`size-4`})})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto p-5`,children:[(0,Z.jsx)(S,{className:`text-sm text-fg-muted`,children:F?k.toolsHint:t.phase===`review_scope`?k.scopeHint:k.intro}),(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap rounded-lg border border-edge p-3 text-sm text-fg`,children:t.summary}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:new Date(t.objectiveUpdatedAt).toLocaleString(O===`zh`?`zh-CN`:`en-US`)}),t.timeRange&&(0,Z.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[new Date(t.timeRange.from).toLocaleString(O,{timeZone:t.timeRange.timezone}),` – `,new Date(t.timeRange.to).toLocaleString(O,{timeZone:t.timeRange.timezone}),` (`,t.timeRange.timezone,`)`]}),t.needs.map(e=>(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-edge p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`span`,{className:`text-sm font-medium text-fg`,children:[e.label,e.accountSelector?` · ${e.accountSelector}`:``]}),e.capabilityError?(0,Z.jsx)(`button`,{type:`button`,disabled:n||M,className:Jw,onClick:()=>void a(`check`),children:k.retry}):e.phase===`ready`?(0,Z.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[(0,Z.jsx)(G,{className:`mr-1 inline size-3`}),k.ready]}):e.phase===`authorizing`?(0,Z.jsx)(`button`,{type:`button`,disabled:n,className:Jw,onClick:()=>void a(`check`),children:k.check}):e.phase===`install`?(0,Z.jsx)(`button`,{type:`button`,disabled:n||M||g,className:Yw,onClick:()=>void R(e),children:k.install}):e.phase!==`blocked`&&e.phase!==`choose_account`?(0,Z.jsx)(`button`,{type:`button`,disabled:n||M,className:Yw,onClick:()=>void a(`connect`,e.key),children:e.phase===`reconnect`?k.reconnect:k.connect}):null]}),e.accountId&&(0,Z.jsx)(`p`,{className:`break-words text-xs text-fg-muted`,children:e.accounts.find(t=>t.id===e.accountId)?.label??e.accountId}),e.alternatives?.length?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(ue,{value:l?.needKey===e.key?l.candidateRef:``,options:e.alternatives.map(e=>({value:e.candidateRef,label:e.label})),placeholder:k.replace,ariaLabel:`${e.label}: ${k.replace}`,disabled:n||M,allowEmpty:!1,onChange:t=>u({needKey:e.key,candidateRef:t,label:e.alternatives.find(e=>e.candidateRef===t).label})}),l?.needKey===e.key&&(0,Z.jsxs)(`button`,{type:`button`,className:Jw,disabled:n,onClick:()=>{a(`replace_source`,e.key,void 0,l.candidateRef),u(void 0)},children:[k.confirmReplace,` `,l.label]})]}):null,e.reason&&(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.reason}),e.phase===`authorizing`&&(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:k.authorizing}),(0,Z.jsx)(`button`,{type:`button`,disabled:n,className:`text-accent`,onClick:()=>void a(`connect`,e.key),children:k.reconnect})]})]},e.key)),(0,Z.jsx)(`a`,{href:`#/capabilities/connectors`,className:`text-sm text-accent`,onClick:()=>c(!1),children:k.all})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-t border-edge p-4`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`min-h-11 text-sm text-fg-muted`,onClick:()=>void a(`cancel`),children:k.cancel}),t.phase===`review_scope`?(0,Z.jsx)(`button`,{type:`button`,disabled:n||M,className:Yw,onClick:()=>void a(`confirm_scope`),children:k.scope}):null]})]})]})}),d?(0,Z.jsx)(wt,{draft:d,onChange:f,onClose:()=>{f(void 0),m(void 0)},onInstalled:async e=>{p&&await a(`install_complete`,p,void 0,void 0,e.instanceId)&&(f(void 0),m(void 0))},t:y(O).connectorsSettings}):null]})}var Zw=new Set([`button`,`checkbox`,`color`,`file`,`hidden`,`image`,`radio`,`range`,`reset`,`submit`]);function Qw(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&&!Zw.has(t.type)}function $w(){return!!document.querySelector(`dialog[open], [aria-modal="true"], [role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]`)}function eT(e,t){return t.disabled||t.editorHidden||e.defaultPrevented||Qw(e.target)||Qw(document.activeElement)?!1:!$w()}function tT(e){for(let t=e.parentElement;t;t=t.parentElement)if(/(auto|scroll)/.test(getComputedStyle(t).overflowY))return t;return null}function nT({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=tT(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 rT(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 iT(e){let t=rT(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 aT=(0,Q.memo)(function({items:e,disabled:t,editingFollowUpId:n,onEditInComposer:r,onRemove:i,onMove:a,onReorder:o,onSteer:s,onSendSingle:c,queuePaused:l=!1,queueIdle:u=!1,steeringBusyId:d,onOpenSideChat:f}){let p=y(h(e=>e.language)),m=(0,Q.useRef)(!1),g=e.filter(e=>e.status===`queued`),_=!!(t||d),v=nT({items:e,disabled:_,onReorder:o}),b=Y(`inline-flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-lg px-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:pointer-events-none disabled:opacity-35`,ca.focusRingPanel),x=`flex cursor-pointer items-center gap-2 rounded-md px-3 py-2 text-sm text-fg outline-none focus:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-35`;return e.length===0?null:(0,Z.jsxs)(`div`,{ref:v.listRef,className:`space-y-1 px-2 py-2`,onClickCapture:v.onClickCapture,role:`list`,"aria-label":p.chat.followUpQueueAria,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2 pb-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:p.chat.followUpQueueHeading}),(0,Z.jsxs)(`span`,{className:`tabular-nums text-[0.65rem] text-fg-muted`,children:[e.length,`/`,10]})]}),e.map(e=>{let t=e.status===`queued`,o=t||e.status===`interrupted`,h=g.findIndex(t=>t.id===e.id),y=u&&(l||e.status===`interrupted`),S=o&&!!(e.text.trim()||e.attachments?.length||e.contextRefs?.length),C=o&&!e.attachments?.length&&!e.contextRefs?.length&&e.text.trim().length>0,w=d===e.id,T=e.status===`interrupted`?p.chat.followUpStatusInterrupted:null,E=Wn(e.text),D=new Map(e.contextRefs?.flatMap(e=>e.refId?[[e.refId,e.title]]:[])??[]),O=new Set(E?gn(E):[]),k=e.contextRefs?.filter(e=>!e.refId||!O.has(e.refId)),A=Jn(E?br(E,e=>D.get(e)):e.text).trim();return!A&&e.attachments?.length&&(A=e.attachments[0]?.name?.trim()||p.chat.followUpQueueAttachmentOnly),A||=p.chat.followUpQueueEmptyPreview,(0,Z.jsxs)(`div`,{role:`listitem`,"data-follow-up-id":e.id,"data-follow-up-sortable":!_&&t,onPointerDown:t=>v.onPointerDown(t,e),onDragStart:e=>e.preventDefault(),style:{transform:v.view?.shifts[e.id]?`translateY(${v.view.shifts[e.id]}px)`:void 0},className:Y(`relative flex min-h-10 items-center gap-1 rounded-lg px-1.5 py-1 motion-safe:transition-transform motion-safe:duration-150`,!_&&t&&`cursor-grab`,v.view?.id===e.id&&`bg-surface-inset ring-1 ring-inset ring-edge-strong [&>*]:invisible`,n===e.id?`bg-accent-soft ring-1 ring-inset ring-accent/30`:`hover:bg-surface-hover/50`),children:[(0,Z.jsx)(`div`,{"data-follow-up-drag-handle":!0,className:Y(`flex shrink-0 touch-none cursor-grab items-center active:cursor-grabbing`,(_||!t)&&`cursor-not-allowed opacity-40`),title:p.chat.followUpQueueDrag,children:(0,Z.jsx)(hs,{className:`size-3.5 text-fg-muted`,"aria-hidden":!0})}),(0,Z.jsx)(`button`,{type:`button`,"data-follow-up-drag-surface":!0,disabled:_||!t,title:p.chat.followUpQueueClickToEdit,"aria-label":p.chat.followUpQueueClickToEdit,className:Y(`min-h-8 min-w-0 flex-1 cursor-grab rounded-md px-1.5 text-left text-sm text-fg`,ca.focusRingPanel,`disabled:pointer-events-none disabled:opacity-50`),onClick:()=>r(e.id),children:e.attachments?.length?(0,Z.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1`,children:[(0,Z.jsx)(Ce,{className:`size-3 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate`,children:A})]}):(0,Z.jsx)(`span`,{className:`line-clamp-2 break-words [overflow-wrap:anywhere]`,children:A})}),k?.length?(0,Z.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-0.5 rounded bg-accent-soft px-1.5 py-0.5 text-[0.625rem] text-accent-fg`,title:k.map(e=>e.title).join(`, `),children:[(0,Z.jsx)(xs,{className:`size-3`,"aria-hidden":!0}),k.length]}):null,T?(0,Z.jsx)(`span`,{className:`shrink-0 rounded bg-surface-panel px-1.5 py-0.5 text-[0.625rem] text-fg-muted`,children:T}):null,(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:b,disabled:_||(y?!o:!S),title:y?p.chat.sendThisMessage:p.chat.followUpQueueSteerHint,"aria-label":y?p.chat.sendThisMessage:p.chat.followUpQueueSteerNow,"aria-busy":w,onClick:()=>y?c?.(e.id):s(e.id),children:[(0,Z.jsx)(cs,{className:Y(`size-4`,w&&`motion-safe:animate-pulse`),"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`hidden text-xs sm:inline`,children:y?p.chat.sendThisMessage:p.chat.followUpQueueSteerNow})]}),(0,Z.jsx)(`button`,{type:`button`,className:Y(b,`px-1.5 hover:text-danger`),disabled:_||!o,title:p.chat.followUpQueueRemove,"aria-label":p.chat.followUpQueueRemove,onClick:()=>i(e.id),children:(0,Z.jsx)(Bt,{className:`size-4`,"aria-hidden":!0})}),(0,Z.jsxs)(co,{modal:!1,children:[(0,Z.jsx)(lo,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:Y(b,`px-1.5`),disabled:_,title:p.chat.followUpQueueMore,"aria-label":p.chat.followUpQueueMore,children:(0,Z.jsx)(be,{className:`size-4`,"aria-hidden":!0})})}),(0,Z.jsx)(uo,{children:(0,Z.jsxs)(po,{side:`top`,align:`end`,sideOffset:6,onCloseAutoFocus:e=>{m.current&&e.preventDefault(),m.current=!1},className:`z-50 min-w-52 max-w-[calc(100vw-2rem)] rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:[(0,Z.jsxs)(fo,{className:x,disabled:!t,onSelect:()=>{m.current=!0,r(e.id)},children:[(0,Z.jsx)(Dt,{className:`size-4`,"aria-hidden":!0}),p.chat.followUpQueueClickToEdit]}),f?(0,Z.jsxs)(fo,{className:x,disabled:!C,onSelect:()=>f(e,A),children:[(0,Z.jsx)(vs,{className:`size-4`,"aria-hidden":!0}),p.chat.followUpQueueOpenSideChat]}):null,g.length>1?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(mo,{className:`my-1 h-px bg-edge-subtle`}),(0,Z.jsxs)(fo,{className:x,disabled:!t||h===0,onSelect:()=>a(e.id,`up`),children:[(0,Z.jsx)(ne,{className:`size-4`,"aria-hidden":!0}),p.chat.followUpQueueMoveUp]}),(0,Z.jsxs)(fo,{className:x,disabled:!t||h>=g.length-1,onSelect:()=>a(e.id,`down`),children:[(0,Z.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),p.chat.followUpQueueMoveDown]})]}):null]})})]})]})]},e.id)})]})});function oT({conversationId:e}){let t=m(e=>e.conversationId),n=h(e=>e.language).startsWith(`zh`),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(``),s=Gr(e?[`session-preparation`,t,e]:null,async()=>{let t=await wr(e);if(t&&!t.materialization)return null;let n=await g(p(`/api/sessions/${encodeURIComponent(e)}/input-state`));return n.payload.preparation?Er.parse(n.payload.preparation):null},{refreshInterval:e=>e?.state===`preparing`?5e3:0,shouldRetryOnError:!1}),{mutate:c}=s;(0,Q.useEffect)(()=>{let t=t=>{t.detail?.conversationId===e&&c()};return window.addEventListener(`session-input-state`,t),()=>window.removeEventListener(`session-input-state`,t)},[e,c]);let l=s.data;if(!l||l.state===`ready`)return null;let u=async()=>{i(!0),o(``);try{let t=await f(p(`/api/sessions/${encodeURIComponent(e)}/preparation/retry`),{method:`POST`,body:JSON.stringify({operationId:l.operationId,expectedRevision:l.revision,idempotencyKey:`${l.operationId}:${l.revision}`})});if(!t.ok)throw Error(`HTTP ${t.status}`);await c()}catch(e){o(e instanceof Error?e.message:String(e))}finally{i(!1)}};return(0,Z.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 text-sm text-fg-muted`,role:`status`,children:[(0,Z.jsx)(`span`,{children:l.state===`preparing`?n?`正在准备会话环境…`:`Preparing conversation environment…`:l.lastError??(n?`会话环境准备失败`:`Conversation environment preparation failed`)}),l.state===`preparation_failed`?(0,Z.jsx)(`button`,{type:`button`,className:`ml-2 text-accent-fg`,disabled:r,onClick:()=>void u(),children:n?`重试准备`:`Retry preparation`}):null,a?(0,Z.jsx)(`span`,{role:`alert`,className:`ml-2`,children:a}):null]})}function sT(e){let t=(0,X.c)(10),{refs:n,label:r,onRemove:i}=e;if(n.length===0)return null;let a;if(t[0]!==r||t[1]!==i||t[2]!==n){let e;t[4]!==r||t[5]!==i?(e=e=>(0,Z.jsxs)(`span`,{className:`inline-flex h-7 min-w-0 max-w-56 items-center gap-1.5 rounded-md border border-edge-subtle bg-accent-soft/50 px-2 text-xs text-fg`,children:[e.kind===`file`&&e.fileKind===`directory`?(0,Z.jsx)(Oe,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.kind===`file`||e.kind===`result`?(0,Z.jsx)(Te,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.kind===`session`?(0,Z.jsx)(bt,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.kind===`browser_tab`?(0,Z.jsx)(k,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,Z.jsx)(xs,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.title}),(0,Z.jsx)(`button`,{type:`button`,className:`-mr-1 inline-flex size-5 shrink-0 items-center justify-center rounded text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":`${r}: ${e.title}`,onClick:()=>i(e.sourceId),children:(0,Z.jsx)(Gt,{className:`size-3`,"aria-hidden":!0})})]},e.sourceId),t[4]=r,t[5]=i,t[6]=e):e=t[6],a=n.map(e),t[0]=r,t[1]=i,t[2]=n,t[3]=a}else a=t[3];let o;return t[7]!==r||t[8]!==a?(o=(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5 px-4 pt-2`,"aria-label":r,children:a}),t[7]=r,t[8]=a,t[9]=o):o=t[9],o}var cT=`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 lT(e){let t=(0,X.c)(96),{conversationId:n,project:r,workspacePath:i,canChangeWorkspace:a,disabled:o,environmentPicker:s,onProjectChange:c,onWorkspaceChange:l}=e,u=h(pT),d;t[0]===u?d=t[1]:(d=y(u),t[0]=u,t[1]=d);let f=d,p=f.chat.composerContext,g=m(fT),_=m(dT),[v,b]=(0,Q.useState)(``),[x]=Wa(v,200),S;t[2]!==_||t[3]!==x||t[4]!==g?(S=[`composer-projects`,_,g,x],t[2]=_,t[3]=x,t[4]=g,t[5]=S):S=t[5];let C;t[6]===x?C=t[7]:(C=()=>ln({status:`active`,search:x,sortBy:`updatedAt`,sortOrder:`desc`,limit:50}),t[6]=x,t[7]=C);let w;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(w={keepPreviousData:!1,shouldRetryOnError:!1},t[8]=w):w=t[8];let T=Gr(S,C,w),E=mf(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=Ia(N),F=a?`${p.chooseFolder}${k?`: ${k}`:``}`:r?p.projectFolder:p.lockedFolder,I;t[18]===D?I=t[19]:(I=D?.branch||(D?.detached?D.headSha?.slice(0,8):void 0),t[18]=D,t[19]=I);let L=I,R=p.label,z=r&&`bg-surface-hover`,B;t[20]===z?B=t[21]:(B=Y(`flex min-w-0 max-w-full items-center rounded-full`,z),t[20]=z,t[21]=B);let V;t[22]!==o||t[23]!==f.chat.scopeRemoveProject||t[24]!==c||t[25]!==r?(V=r?(0,Z.jsx)(`button`,{type:`button`,disabled:o,title:f.chat.scopeRemoveProject,"aria-label":f.chat.scopeRemoveProject,className:Y(cT,`size-7 shrink-0 px-0 ml-0.5 text-fg-muted`),onClick:()=>c(null),children:(0,Z.jsx)(Gt,{className:`size-3.5`,"aria-hidden":!0})}):null,t[22]=o,t[23]=f.chat.scopeRemoveProject,t[24]=c,t[25]=r,t[26]=V):V=t[26];let H=r?.id??``,U=r?.name,W;t[27]!==T.data?.items||t[28]!==T.error?(W=T.error?[]:T.data?.items??[],t[27]=T.data?.items,t[28]=T.error,t[29]=W):W=t[29];let G;t[30]===W?G=t[31]:(G=W.map(uT),t[30]=W,t[31]=G);let ee=p.chooseProject,te=p.changeProject,ne=p.changeProject,re=p.noProject,ae=p.searchProjects,oe=T.isLoading,se=T.error?p.projectsFailed:T.data?.items.length===0?p.noProjects:void 0,ce=r&&`pl-1`,le;t[32]===ce?le=t[33]:(le=Y(cT,`h-8 w-auto max-w-44 gap-1 border-0 bg-transparent pr-2.5 text-sm [&>svg]:hidden [&>span]:text-fg`,ce),t[32]=ce,t[33]=le);let K;t[34]!==c||t[35]!==r?.id?(K=e=>{e!==(r?.id??``)&&c(e||null)},t[34]=c,t[35]=r?.id,t[36]=K):K=t[36];let q;t[37]!==p.changeProject||t[38]!==p.chooseProject||t[39]!==p.noProject||t[40]!==p.searchProjects||t[41]!==o||t[42]!==T.isLoading||t[43]!==v||t[44]!==H||t[45]!==U||t[46]!==G||t[47]!==se||t[48]!==le||t[49]!==K?(q=(0,Z.jsx)(ue,{value:H,selectedLabel:U,options:G,placeholder:ee,ariaLabel:te,title:ne,emptyLabel:re,disabled:o,side:`top`,align:`start`,searchPlaceholder:ae,searchValue:v,onSearchChange:b,loading:oe,statusMessage:se,triggerClassName:le,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:K}),t[37]=p.changeProject,t[38]=p.chooseProject,t[39]=p.noProject,t[40]=p.searchProjects,t[41]=o,t[42]=T.isLoading,t[43]=v,t[44]=H,t[45]=U,t[46]=G,t[47]=se,t[48]=le,t[49]=K,t[50]=q):q=t[50];let de;t[51]!==B||t[52]!==V||t[53]!==q?(de=(0,Z.jsxs)(`div`,{className:B,children:[V,q]}),t[51]=B,t[52]=V,t[53]=q,t[54]=de):de=t[54];let fe=r?s:null,pe;t[55]!==D||t[56]!==s||t[57]!==r?(pe=!s&&r&&D&&(D.headSha||D.branch)?(0,Z.jsxs)(`span`,{className:`inline-flex h-8 min-w-0 items-center gap-1.5 rounded-full bg-surface-hover px-2.5 text-sm text-fg`,title:D.rootPath,children:[D.kind===`managed_worktree`?(0,Z.jsx)(Ss,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(We,{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]=pe):pe=t[58];let J;t[59]!==p.retryProjects||t[60]!==T?(J=T.error?(0,Z.jsx)(`button`,{type:`button`,className:Y(cT,`size-7 px-0`),"aria-label":p.retryProjects,onClick:()=>void T.mutate(),children:(0,Z.jsx)(At,{className:`size-3.5`,"aria-hidden":!0})}):null,t[59]=p.retryProjects,t[60]=T,t[61]=J):J=t[61];let me;t[62]!==a||t[63]!==E.isLoading||t[64]!==p.chooseFolder||t[65]!==o||t[66]!==P.pick||t[67]!==P.picking||t[68]!==r||t[69]!==k||t[70]!==F?(me=r?null:(0,Z.jsxs)(`button`,{type:`button`,className:Y(cT,`max-w-52`),disabled:o||!a||P.picking,title:F,"aria-label":p.chooseFolder,onClick:P.pick,children:[(0,Z.jsx)(De,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),k?(0,Z.jsx)(`span`,{className:`truncate`,children:Fa(k)}):E.isLoading?(0,Z.jsx)(qt,{className:`h-4 w-16`}):(0,Z.jsx)(`span`,{children:p.chooseFolder})]}),t[62]=a,t[63]=E.isLoading,t[64]=p.chooseFolder,t[65]=o,t[66]=P.pick,t[67]=P.picking,t[68]=r,t[69]=k,t[70]=F,t[71]=me):me=t[71];let he;t[72]!==L||t[73]!==D?(he=L?(0,Z.jsxs)(`span`,{className:`inline-flex h-8 min-w-0 max-w-44 items-center gap-1.5 px-2 text-sm text-fg`,title:`${L}${D?.headSha?` · ${D.headSha.slice(0,8)}`:``}`,children:[(0,Z.jsx)(Me,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate`,children:L})]}):null,t[72]=L,t[73]=D,t[74]=he):he=t[74];let ge;t[75]===A?ge=t[76]:(ge=A?(0,Z.jsx)(`p`,{role:`alert`,className:`w-full px-2 py-1 text-xs text-danger`,children:A}):null,t[75]=A,t[76]=ge);let _e;t[77]!==p.label||t[78]!==de||t[79]!==fe||t[80]!==pe||t[81]!==J||t[82]!==me||t[83]!==he||t[84]!==ge?(_e=(0,Z.jsxs)(`div`,{className:`mx-3 -mb-3 flex min-w-0 shrink-0 flex-wrap items-center gap-x-1 gap-y-1 rounded-t-2xl bg-surface-base px-2 pb-4 pt-1.5 sm:mx-4`,"aria-label":R,children:[de,fe,pe,J,me,he,ge]}),t[77]=p.label,t[78]=de,t[79]=fe,t[80]=pe,t[81]=J,t[82]=me,t[83]=he,t[84]=ge,t[85]=_e):_e=t[85];let ve;t[86]!==f.chat.workingDirectory||t[87]!==P.confirmPick||t[88]!==P.hasNativePicker||t[89]!==P.modalOpen||t[90]!==P.setModalOpen||t[91]!==k?(ve=P.hasNativePicker?null:(0,Z.jsx)(ie,{open:P.modalOpen,onOpenChange:P.setModalOpen,initialAbsolutePath:k||void 0,onConfirm:P.confirmPick,wd:f.chat.workingDirectory}),t[86]=f.chat.workingDirectory,t[87]=P.confirmPick,t[88]=P.hasNativePicker,t[89]=P.modalOpen,t[90]=P.setModalOpen,t[91]=k,t[92]=ve):ve=t[92];let ye;return t[93]!==_e||t[94]!==ve?(ye=(0,Z.jsxs)(Z.Fragment,{children:[_e,ve]}),t[93]=_e,t[94]=ve,t[95]=ye):ye=t[95],ye}function uT(e){return{value:e.id,label:e.name}}function dT(e){return e.baseUrl}function fT(e){return e.conversationId}function pT(e){return e.language}var mT=`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 hT(e){let t=(0,X.c)(10),{disabled:n,attachmentCount:r,maxAttachments:i,chat:a,onPickFiles:o}=e,s=r>=i,c;t[0]!==a.attachFile||t[1]!==a.maxAttachmentsReached||t[2]!==s||t[3]!==i?(c=s?em(a.maxAttachmentsReached,{max:i}):a.attachFile,t[0]=a.attachFile,t[1]=a.maxAttachmentsReached,t[2]=s,t[3]=i,t[4]=c):c=t[4];let l=c,u=n||s,d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(kt,{className:`size-5`,"aria-hidden":!0}),t[5]=d):d=t[5];let f;return t[6]!==l||t[7]!==o||t[8]!==u?(f=(0,Z.jsx)(`button`,{type:`button`,className:mT,disabled:u,"aria-label":l,title:l,onClick:o,children:d}),t[6]=l,t[7]=o,t[8]=u,t[9]=f):f=t[9],f}function gT(e){let t=(0,X.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,Z.jsx)(xt,{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,Z.jsx)(`button`,{type:`button`,className:mT,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(mT,`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,Z.jsx)(zt,{className:`size-4 fill-current`,"aria-hidden":!0}):(0,Z.jsx)(N,{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,Z.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,Z.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 _T(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 vT=100,yT=400,bT=900;function xT(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 ST(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 CT(e){let t=(0,X.c)(8),{name:n,query:r}=e,i;t[0]!==n||t[1]!==r?(i=ST(n,r),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a=i;if(a.length===0){let e;return t[3]===n?e=t[4]:(e=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:n}),t[3]=n,t[4]=e),e}let o;if(t[5]!==n||t[6]!==a){let e=[],r=0;a.forEach(t=>{let[i,a]=t;i>r&&e.push((0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:n.slice(r,i)},`pre-${i}`)),e.push((0,Z.jsx)(`span`,{className:`font-semibold text-accent-fg`,children:n.slice(i,a)},`hl-${i}-${a}`)),r=a}),r<n.length&&e.push((0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:n.slice(r)},`tail`)),o=(0,Z.jsx)(Z.Fragment,{children:e}),t[5]=n,t[6]=a,t[7]=o}else o=t[7];return o}var wT=(0,Q.memo)(function(e){let t=(0,X.c)(42),{open:n,anchorRef:r,items:i,selectedIndex:a,loading:o,query:s,noResults:c,conversationId:l,recentLabel:u,sectionLabels:d,ariaLabel:f,onSelectItem:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m={box:null,hoverPreview:null},t[0]=m):m=t[0];let[h,g]=(0,Q.useReducer)(xT,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&&za(i,{conversationId:l}).then(e=>{let{content:i}=e,a=i.length>bT?`${i.slice(0,bT)}…`:i;r===b.current&&g({type:`set-hover`,hoverPreview:{text:a,x:t,y:n}})}).catch(()=>{r===b.current&&g({type:`set-hover`,hoverPreview:null})})},420)},t[2]=l,t[3]=w);let T=w,E,D;t[4]!==r||t[5]!==n?(E=()=>{if(!n){g({type:`reset`}),C(),b.current+=1;return}let e=()=>{let e=r.current;if(!e)return;let t=e.getBoundingClientRect();g({type:`set-box`,box:{left:t.left,top:t.top,width:t.width}})};e();let t=r.current,i=t&&typeof ResizeObserver<`u`?new ResizeObserver(()=>{e()}):null;return t&&i&&i.observe(t),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{t&&i&&i.disconnect(),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},D=[n,r],t[4]=r,t[5]=n,t[6]=E,t[7]=D):(E=t[6],D=t[7]),(0,Q.useLayoutEffect)(E,D);let O,A;if(t[8]!==i.length||t[9]!==n||t[10]!==a?(O=()=>{!n||a<0||a>=i.length||(x.current?.querySelector(`#at-mention-${a}`))?.scrollIntoView({block:`nearest`})},A=[n,a,i.length],t[8]=i.length,t[9]=n,t[10]=a,t[11]=O,t[12]=A):(O=t[11],A=t[12]),(0,Q.useLayoutEffect)(O,A),!n||typeof document>`u`||_===null)return null;let j=i.length,M=Math.min(_.width,yT),N;t[13]!==_.left||t[14]!==_.top||t[15]!==M?(N={position:`fixed`,left:_.left,top:_.top,width:M,transform:`translateY(calc(-100% - 8px))`,zIndex:vT},t[13]=_.left,t[14]=_.top,t[15]=M,t[16]=N):N=t[16];let P=a>=0&&a<j?`at-mention-${a}`:void 0,F;t[17]!==o||t[18]!==j?(F=o&&j===0?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2.5 text-sm text-fg-muted`,children:[(0,Z.jsx)(Je,{className:`size-4 shrink-0 animate-spin`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:`…`})]}):null,t[17]=o,t[18]=j,t[19]=F):F=t[19];let I;t[20]!==i||t[21]!==o||t[22]!==c||t[23]!==p||t[24]!==s||t[25]!==u||t[26]!==T||t[27]!==d||t[28]!==a||t[29]!==j?(I=!o&&j===0?(0,Z.jsx)(`div`,{className:`px-3 py-2 text-sm text-fg-muted`,children:c}):(0,Z.jsxs)(Z.Fragment,{children:[i.map((e,t)=>{let n=i[t-1]?.kind,r=d[e.kind],o=e.kind===`file`&&e.isRecent;return(0,Z.jsxs)(Q.Fragment,{children:[n===e.kind?null:(0,Z.jsx)(`div`,{className:`border-t border-edge-subtle px-3 pb-1 pt-2 text-[0.65rem] font-medium uppercase tracking-wide text-fg-muted first:border-t-0`,children:r}),(0,Z.jsxs)(`div`,{id:`at-mention-${t}`,role:`option`,"aria-selected":a===t,tabIndex:-1,className:Y(`flex cursor-pointer items-start gap-2 px-3 py-2 text-left text-sm`,a===t?`bg-surface-hover text-fg`:`text-fg-subtle hover:bg-surface-hover/80`,o&&`border-l-2 border-l-accent/60`),onPointerDown:t=>{t.pointerType===`mouse`&&t.button!==0||(t.preventDefault(),p(e))},onPointerEnter:t=>T(e,t.clientX,t.clientY),onPointerLeave:()=>{C(),b.current+=1,g({type:`set-hover`,hoverPreview:null})},children:[(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:e.kind===`note`?(0,Z.jsx)(xs,{className:`size-3.5 text-accent-fg`,"aria-hidden":!0}):e.kind===`session`?(0,Z.jsx)(bt,{className:`size-3.5 text-violet-600 dark:text-violet-400`,"aria-hidden":!0}):e.kind===`skill`?(0,Z.jsx)(Rt,{className:`size-3.5 text-cyan-600 dark:text-cyan-400`,"aria-hidden":!0}):e.kind===`agent`?(0,Z.jsx)(W,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):e.kind===`browser_tab`?(0,Z.jsx)(k,{className:`size-3.5 text-blue-600 dark:text-blue-400`,"aria-hidden":!0}):e.isBrowseUp?(0,Z.jsx)(Oe,{className:`size-3.5 text-fg-muted`,"aria-hidden":!0}):e.isDirectory?(0,Z.jsx)(Oe,{className:`size-3.5 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}):(0,Z.jsx)(Te,{className:Y(`size-3.5`,_e(e.name)),"aria-hidden":!0})}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 truncate`,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:(0,Z.jsx)(CT,{name:e.name,query:s})}),o?(0,Z.jsx)(`span`,{className:`shrink-0 rounded bg-accent-soft px-1 py-0 text-[0.65rem] text-accent-fg`,children:u}):null]}),(0,Z.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:e.description||r})]})]})]},e.id)}),o&&j>0?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-edge-subtle px-3 py-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(Je,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:`…`})]}):null]}),t[20]=i,t[21]=o,t[22]=c,t[23]=p,t[24]=s,t[25]=u,t[26]=T,t[27]=d,t[28]=a,t[29]=j,t[30]=I):I=t[30];let L;t[31]!==f||t[32]!==F||t[33]!==I||t[34]!==P?(L=(0,Z.jsxs)(`div`,{ref:x,className:`max-h-[min(26rem,54vh)] overflow-y-auto`,role:`listbox`,"aria-label":f,"aria-activedescendant":P,children:[F,I]}),t[31]=f,t[32]=F,t[33]=I,t[34]=P,t[35]=L):L=t[35];let R;t[36]===v?R=t[37]:(R=v?(0,Z.jsx)(`div`,{className:`pointer-events-none fixed z-[200] max-h-48 max-w-sm overflow-auto rounded-md border border-edge bg-surface-overlay p-2 font-mono text-[0.7rem] text-fg shadow-lg`,style:{left:Math.min(v.x+12,window.innerWidth-320),top:Math.min(v.y+12,window.innerHeight-200)},children:v.text}):null,t[36]=v,t[37]=R);let z;return t[38]!==L||t[39]!==R||t[40]!==N?(z=(0,Is.createPortal)((0,Z.jsxs)(`div`,{"data-composer-picker-panel":!0,className:`pointer-events-auto max-h-[min(28rem,60vh)] min-h-[2.5rem] overflow-hidden rounded-lg border border-edge bg-surface-overlay shadow-lg`,style:N,role:`presentation`,children:[L,R]}),document.body),t[38]=L,t[39]=R,t[40]=N,t[41]=z):z=t[41],z});function TT(e,t){let n=e=>{e!==!1&&(e&&typeof e==`object`?t(e.conversationId):t())};e instanceof Promise?e.then(n).catch(e=>{ya(`error`,e instanceof Error?e.message:String(e))}):n(e)}var ET=new Set([`abort`,`stop`,`cancel`]);function DT(e){if(e.kind!==`command`)return!1;if(ET.has(e.name.toLowerCase()))return!0;for(let t of e.aliases??[])if(ET.has(t.toLowerCase()))return!0;return!1}function OT(e,t,n,r){return e.slice(0,t)+r+e.slice(n)}var kT=(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=OT(t.editor.valueRef.current,n.start,n.end,r),a=n.start+r.length;t.editor.resetEditor({nextText:i,caretOffset:a,focus:!0})},AT=(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=OT(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(DT(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}TT(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()})},jT=(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 MT(e,t){switch(e.kind){case`skill`:kT(e,t);return;case`command`:AT(e,t);return;case`agent`:jT(e,t)}}var NT={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},PT=new Set([`abort`,`archive`]);function FT(e){if(e.kind===`command`){let t=e.name.toLowerCase();if(NT[t]!==void 0)return 0;if(PT.has(t))return 2}return 1}function IT(e,t){let n=FT(e),r=FT(t);if(n!==r)return n-r;if(n===0){let n=NT[e.name.toLowerCase()]??999,r=NT[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 LT(e){if(e.kind!==`command`)return!1;if(ET.has(e.name.toLowerCase()))return!0;for(let t of e.aliases??[])if(ET.has(t.toLowerCase()))return!0;return!1}function RT(e,t){return e.kind!==`command`||e.acceptsArgs===!0||LT(e)||!(t.runBusy||t.pendingFollowUpsCount>0)?!1:t.pendingFollowUpsCount>=t.maxPendingFollowUps}function zT(e,t){return e.kind!==`command`||e.acceptsArgs===!0||LT(e)||!(t.runBusy||t.pendingFollowUpsCount>0)?!1:t.pendingFollowUpsCount<t.maxPendingFollowUps}function BT(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 VT(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 HT(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(VT(e,a))return null;let o=i[0],s=o.slice(1);return BT(s)||o.startsWith(`/skill:`)?null:{start:i.index,end:r,query:s}}function UT(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 WT(e,t){return t===0?0:Math.min(e,t-1)}function GT(e,t){let{query:n,value:r,commandsAllowed:i,agentsAllowed:a}=t,o=n.trim()===``,s=yp(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=UT(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?IT(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 KT(e,t,n){let r=(0,X.c)(49),[i,a]=(0,Q.useState)(0),[o,s]=(0,Q.useState)(0),c=h(YT),l=n?.capabilities??ep,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:HT(e,t),r[0]=t,r[1]=u,r[2]=n?.isComposing,r[3]=e,r[4]=d):d=r[4];let f=d,p=!!(f&&!n?.suppress),m,g;r[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{let e=e=>{let t=e.detail;t&&typeof t==`object`&&`section`in t&&(t.section===`skills`||t.section===`agents`)&&s(JT)};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},g=[],r[5]=m,r[6]=g):(m=r[5],g=r[6]),(0,Q.useEffect)(m,g);let _;r[7]!==c||r[8]!==n?.conversationId||r[9]!==n?.currentAgentId?(_=async()=>{let[e,t,r]=await Promise.allSettled([bo(),ho(n?.currentAgentId,n?.conversationId),ni()]),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(qT),o=(t.status===`fulfilled`?t.value.skills:[]).map(e=>{let t=xo(e,c);return{kind:`skill`,id:`skill:${e.name}`,name:t.displayName,canonicalName:e.name,description:t.description,aliases:t.aliases,searchTerms:t.searchTerms,category:`skill`,source:e.source,availability:{status:e.availableForCurrentAgent?`available`:e.unavailableReason??`agent-denied`,reason:e.unavailableReason??void 0}}}),s=y(c).agentsSettings,l=r.status===`fulfilled`?r.value:null,u=l&&l.items.length>1?l.items.map(e=>({kind:`agent`,id:`agent:${e.id}`,agentId:e.id,name:qo(e,s),description:Jo(e,s),category:`agent`,...e.avatar?{avatar:e.avatar}:{},aliases:[e.id,...e.name?[e.name]:[]]})):[];return{items:[...o,...a,...u],failedKinds:i}},r[7]=c,r[8]=n?.conversationId,r[9]=n?.currentAgentId,r[10]=_):_=r[10];let v=n?.currentAgentId,b=n?.conversationId,x;r[11]!==c||r[12]!==o||r[13]!==v||r[14]!==b?(x=[c,v,b,o],r[11]=c,r[12]=o,r[13]=v,r[14]=b,r[15]=x):x=r[15];let S;r[16]===Symbol.for(`react.memo_cache_sentinel`)?(S=[],r[16]=S):S=r[16];let C;r[17]===Symbol.for(`react.memo_cache_sentinel`)?(C=[],r[17]=C):C=r[17];let w,T;r[18]===Symbol.for(`react.memo_cache_sentinel`)?(T={items:S,failedKinds:C},w=[],r[18]=w,r[19]=T):(w=r[18],T=r[19]);let E;r[20]===Symbol.for(`react.memo_cache_sentinel`)?(E=[],r[20]=E):E=r[20];let D;r[21]===Symbol.for(`react.memo_cache_sentinel`)?(D={items:w,failedKinds:E},r[21]=D):D=r[21];let O;r[22]===p?O=r[23]:(O={enabled:p,initial:T,errorData:D},r[22]=p,r[23]=O);let k=Da(_,x,O),A=k.data.items,j=k.error==null?null:k.error instanceof Error?k.error.message:String(k.error),M=f?.query??``,N=l.commands&&f!==null&&f.start===0,P=l.agentSwitch&&f!==null&&f.start===0,F;r[24]!==P||r[25]!==A||r[26]!==l.skills||r[27]!==N||r[28]!==M||r[29]!==e?(F=GT(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=WT(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 qT(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 JT(e){return e+1}function YT(e){return e.language}var XT=100,ZT=560;function QT(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase().indexOf(n);if(r>=0)return(0,Z.jsxs)(Z.Fragment,{children:[e.slice(0,r),(0,Z.jsx)(`span`,{className:`text-accent-fg`,children:e.slice(r,r+n.length)}),e.slice(r+n.length)]});let i=[],a=0,o=0;for(let t of e){let e=n[a],r=`${String(o)}-${t}`;e!==void 0&&t.toLowerCase()===e?(i.push((0,Z.jsx)(`span`,{className:`text-accent-fg`,children:t},r)),a+=1):i.push((0,Z.jsx)(Q.Fragment,{children:t},r)),o+=1}return(0,Z.jsx)(Z.Fragment,{children:i})}function $T(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase().indexOf(n);return r<0?e:(0,Z.jsxs)(Z.Fragment,{children:[e.slice(0,r),(0,Z.jsx)(`span`,{className:`text-accent-fg`,children:e.slice(r,r+n.length)}),e.slice(r+n.length)]})}var eE=(0,Q.memo)(function(e){let t=(0,X.c)(46),{item:n,index:r,selectedIndex:i,showHighlight:a,filterQuery:o,currentAgentId:s,currentBadgeLabel:c,runBusy:l,pendingFollowUpsCount:u,maxPendingFollowUps:d,queueBadgeLabel:f,queueFullBadgeLabel:p,queueFullTooltip:m,skillUnavailableLabel:h,skillAgentDeniedLabel:g,skillSourceLabels:_,onSelectItem:v}=e,y=n.kind===`skill`,b=n.kind===`agent`,x;t[0]!==b||t[1]!==y||t[2]!==n.agentId||t[3]!==n.avatar?(x=b?(0,Z.jsx)(Aa,{agentId:n.agentId,avatar:n.avatar,size:18,className:`size-[18px] shrink-0`}):y?(0,Z.jsx)(Rt,{className:`size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,Z.jsx)(Kt,{className:`size-4 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}),t[0]=b,t[1]=y,t[2]=n.agentId,t[3]=n.avatar,t[4]=x):x=t[4];let S=x,C;t[5]!==o||t[6]!==b||t[7]!==n.name||t[8]!==a?(C=b?a?(0,Z.jsx)(Z.Fragment,{children:QT(n.name,o)}):(0,Z.jsx)(`span`,{className:`text-fg`,children:n.name}):a?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`text-fg`,children:`/`}),QT(n.name,o)]}):(0,Z.jsxs)(`span`,{className:`text-fg`,children:[`/`,n.name]}),t[5]=o,t[6]=b,t[7]=n.name,t[8]=a,t[9]=C):C=t[9];let w=C,T=b&&s!=null&&s.length>0&&n.agentId===s,E=y&&n.availability.status!==`available`,D,O;if(t[10]!==n||t[11]!==d||t[12]!==u||t[13]!==l){let e={runBusy:l,pendingFollowUpsCount:u,maxPendingFollowUps:d};O=zT(n,e),D=RT(n,e),t[10]=n,t[11]=d,t[12]=u,t[13]=l,t[14]=D,t[15]=O}else D=t[14],O=t[15];let k=D,A=null;if(T){let e;t[16]===c?e=t[17]:(e=(0,Z.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-accent-soft px-1 py-px text-[0.6rem] font-medium leading-none text-accent-fg`,"aria-label":c,children:c}),t[16]=c,t[17]=e),A=e}else if(E){let e=n.availability.reason??`unavailable`,r=n.availability.status===`agent-denied`?g:h,i;t[18]!==e||t[19]!==r?(i=(0,Z.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-surface-hover px-1 py-px text-[0.6rem] font-medium leading-none text-fg-muted`,"aria-label":e,children:r}),t[18]=e,t[19]=r,t[20]=i):i=t[20],A=i}else if(y&&n.source){let e=_[n.source]??n.source,r;t[21]===e?r=t[22]:(r=(0,Z.jsx)(`span`,{className:`ml-2 shrink-0 text-[11px] font-normal text-fg-muted`,children:e}),t[21]=e,t[22]=r),A=r}else if(k){let e;t[23]===p?e=t[24]:(e=(0,Z.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-red-100 px-1 py-px text-[0.6rem] font-medium leading-none text-red-700 dark:bg-red-900/40 dark:text-red-300`,"aria-label":p,children:p}),t[23]=p,t[24]=e),A=e}else if(O){let e;t[25]===f?e=t[26]:(e=(0,Z.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-surface-hover px-1 py-px text-[0.6rem] font-medium leading-none text-fg-muted`,"aria-label":f,children:f}),t[25]=f,t[26]=e),A=e}let j=i===r,M=`palette-${r}`,N;t[27]!==o||t[28]!==n.description||t[29]!==a?(N=n.description?a?$T(n.description,o):n.description:null,t[27]=o,t[28]=n.description,t[29]=a,t[30]=N):N=t[30];let P=k?m:void 0,F;t[31]!==n||t[32]!==v?(F=()=>v(n),t[31]=n,t[32]=v,t[33]=F):F=t[33];let I;return t[34]!==S||t[35]!==k||t[36]!==n||t[37]!==w||t[38]!==a||t[39]!==j||t[40]!==M||t[41]!==N||t[42]!==P||t[43]!==F||t[44]!==A?(I=(0,Z.jsx)(nE,{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}),tE=(0,Q.memo)(function(e){let t=(0,X.c)(53),{open:n,anchorRef:r,sections:i,flatItems:a,loading:o,failedKinds:s,selectedIndex:c,noResults:l,sectionLoadFailedLabel:u,query:d,skillsLabel:f,commandsLabel:p,agentsLabel:m,currentAgentId:h,currentBadgeLabel:g,runBusy:_,pendingFollowUpsCount:v,maxPendingFollowUps:y,queueBadgeLabel:b,queueFullBadgeLabel:x,queueFullTooltip:S,skillUnavailableLabel:C,skillAgentDeniedLabel:w,skillSourceLabels:T,onSelectItem:E,panelRef:D}=e,[O,k]=(0,Q.useState)(null),A,j;t[0]!==r||t[1]!==n?(A=()=>{if(!n){k(null);return}let e=()=>{let e=r.current;if(!e)return;let t=e.getBoundingClientRect();k({left:t.left,top:t.top,width:t.width})};e();let t=r.current,i=t&&typeof ResizeObserver<`u`?new ResizeObserver(()=>{e()}):null;return t&&i&&i.observe(t),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{t&&i&&i.disconnect(),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},j=[n,r],t[0]=r,t[1]=n,t[2]=A,t[3]=j):(A=t[2],j=t[3]),(0,Q.useLayoutEffect)(A,j);let M,N;if(t[4]!==a.length||t[5]!==n||t[6]!==c?(M=()=>{!n||a.length===0||document.getElementById(`palette-${c}`)?.scrollIntoView?.({block:`nearest`})},N=[a.length,n,c],t[4]=a.length,t[5]=n,t[6]=c,t[7]=M,t[8]=N):(M=t[7],N=t[8]),(0,Q.useEffect)(M,N),!n||typeof document>`u`||O===null)return null;let P=a.length,F=a[c],I=Math.min(O.width,ZT),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(rE)),n=[`skill`,`command`,`agent`].filter(t=>e.has(t)||s.includes(t)),r=0;W=o&&P===0?(0,Z.jsx)(`div`,{className:`space-y-2 p-2.5`,"aria-busy":`true`,children:Array.from({length:6},iE)}):P===0&&s.length===0?(0,Z.jsx)(`div`,{className:`p-2.5 text-xs leading-normal text-fg-muted`,children:l}):n.map((t,n)=>{let i=e.get(t)?.items??[],a=r;r+=i.length;let o=`palette-section-${t}`;return(0,Z.jsxs)(`div`,{role:`group`,"aria-labelledby":o,className:Y(n>0&&`border-t border-edge-subtle`),children:[(0,Z.jsxs)(`div`,{id:o,className:`sticky top-0 z-10 flex items-center justify-between bg-surface-overlay px-2.5 py-2 text-[0.65rem] font-medium uppercase leading-none tracking-wide text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:V[t]}),(0,Z.jsx)(`span`,{className:`tabular-nums`,"aria-hidden":!0,children:i.length})]}),s.includes(t)?(0,Z.jsx)(`div`,{className:`px-2.5 pb-2 text-[11px] leading-relaxed text-fg-muted`,children:u}):i.map((e,t)=>(0,Z.jsx)(eE,{item:e,index:a+t,...U},e.id))]},t)}),t[31]=s,t[32]=o,t[33]=l,t[34]=U,t[35]=V,t[36]=u,t[37]=i,t[38]=P,t[39]=W}else W=t[39];let G=W,ee;t[40]!==O.left||t[41]!==O.top||t[42]!==I?(ee={position:`fixed`,left:O.left,top:O.top,width:I,transform:`translateY(calc(-100% - 8px))`,zIndex:XT},t[40]=O.left,t[41]=O.top,t[42]=I,t[43]=ee):ee=t[43];let te=`${f}, ${p}, ${m}`,ne=F?`${V[F.kind]}: ${F.name}`:``,re;t[44]===ne?re=t[45]:(re=(0,Z.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:ne}),t[44]=ne,t[45]=re);let ie;return t[46]!==G||t[47]!==o||t[48]!==D||t[49]!==te||t[50]!==re||t[51]!==ee?(ie=(0,Is.createPortal)((0,Z.jsx)(Ga,{delayDuration:0,skipDelayDuration:0,disableHoverableContent:!1,children:(0,Z.jsxs)(`div`,{ref:D,className:`pointer-events-auto max-h-[min(32rem,60vh)] min-h-8 overflow-y-auto rounded-md border border-edge bg-surface-overlay text-xs leading-4 shadow-lg`,style:ee,role:`listbox`,"aria-label":te,"aria-busy":o,children:[re,G]})}),document.body),t[46]=G,t[47]=o,t[48]=D,t[49]=te,t[50]=re,t[51]=ee,t[52]=ie):ie=t[52],ie}),nE=(0,Q.memo)(function(e){let t=(0,X.c)(39),{item:n,icon:r,selected:i,id:a,nameLine:o,descriptionLine:s,dimCategoryBadge:c,trailingBadge:l,disabled:u,disabledTooltip:d,onSelect:f}=e,p;t[0]===n.description?p=t[1]:(p=n.description.trim(),t[0]=n.description,t[1]=p);let m=p,h=m.length>0&&s!=null,g=m.length>0,_=n.description,v=n.category&&n.kind!==`skill`&&!c&&!(n.kind===`agent`&&l),y;t[2]===o?y=t[3]:(y=(0,Z.jsx)(`span`,{className:`min-w-0 max-w-[min(12rem,46%)] shrink-0 truncate font-semibold text-fg`,children:o}),t[2]=o,t[3]=y);let b;t[4]!==n.category||t[5]!==v?(b=v?(0,Z.jsx)(`span`,{className:`shrink-0 rounded bg-surface-hover px-1 py-px text-[0.6rem] font-normal leading-none text-fg-muted`,children:n.category}):null,t[4]=n.category,t[5]=v,t[6]=b):b=t[6];let x;t[7]!==s||t[8]!==h?(x=h?(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] font-normal leading-tight text-fg-muted`,children:s}):null,t[7]=s,t[8]=h,t[9]=x):x=t[9];let S;t[10]!==y||t[11]!==b||t[12]!==x?(S=(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-1`,children:[y,b,x]}),t[10]=y,t[11]=b,t[12]=x,t[13]=S):S=t[13];let C=S,w=u?`cursor-not-allowed opacity-50 text-fg-muted`:i?`cursor-pointer bg-surface-hover text-fg`:`cursor-pointer text-fg-subtle hover:bg-surface-hover/80`,T;t[14]===w?T=t[15]:(T=Y(`flex min-h-11 w-full min-w-0 items-center gap-2 px-2.5 py-1.5 text-left text-sm leading-5 sm:min-h-9`,w),t[14]=w,t[15]=T);let E=T,D;t[16]!==u||t[17]!==f?(D=e=>{u||e.pointerType===`mouse`&&e.button!==0||(e.preventDefault(),f())},t[16]=u,t[17]=f,t[18]=D):D=t[18];let O=D,k;t[19]===r?k=t[20]:(k=(0,Z.jsx)(`span`,{className:`shrink-0 [&_svg]:align-middle`,children:r}),t[19]=r,t[20]=k);let A;t[21]!==k||t[22]!==C||t[23]!==l?(A=(0,Z.jsxs)(Z.Fragment,{children:[k,C,l]}),t[21]=k,t[22]=C,t[23]=l,t[24]=A):A=t[24];let j=A,M=u&&d?d:g?_:null,N=u||void 0,P;t[25]!==a||t[26]!==O||t[27]!==E||t[28]!==j||t[29]!==i||t[30]!==N?(P=(0,Z.jsx)(`div`,{id:a,role:`option`,"aria-selected":i,"aria-disabled":N,tabIndex:-1,className:E,onPointerDown:O,children:j}),t[25]=a,t[26]=O,t[27]=E,t[28]=j,t[29]=i,t[30]=N,t[31]=P):P=t[31];let F=P;if(M!==null){let e;t[32]===F?e=t[33]:(e=(0,Z.jsx)(Ya,{asChild:!0,children:F}),t[32]=F,t[33]=e);let n;t[34]===M?n=t[35]:(n=(0,Z.jsx)(Ka,{children:(0,Z.jsx)(Ja,{side:`right`,align:`start`,sideOffset:8,collisionPadding:12,className:`!z-[10000] max-h-[min(12rem,40vh)] max-w-sm overflow-y-auto rounded-md border border-edge bg-surface-overlay px-2 py-1.5 text-left text-[11px] leading-snug text-fg shadow-lg select-text [max-width:min(20rem,90vw)]`,"data-slash-palette-tooltip":``,children:(0,Z.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:M})})}),t[34]=M,t[35]=n);let r;return t[36]!==e||t[37]!==n?(r=(0,Z.jsxs)(qa,{delayDuration:0,children:[e,n]}),t[36]=e,t[37]=n,t[38]=r):r=t[38],r}return F});function rE(e){return[e.kind,e]}function iE(e,t){return(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,Z.jsx)(qt,{className:`size-4 shrink-0`}),(0,Z.jsx)(qt,{className:`h-3 w-28`}),(0,Z.jsx)(qt,{className:`h-3 flex-1`})]},t)}var aE=new Map;function oE(e){let t=aE.get(e);return t||(t={items:[],loadPromise:null,loaded:!1,writeQueue:Promise.resolve(),mutationVersion:0,clearVersion:0},aE.set(e,t)),t}function sE(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 cE(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}sE(e,t)}function lE(e){return oE(e).items.map(e=>e.text)}function uE(e,t=!1){let n=oE(e);if(n.loaded&&!t)return Promise.resolve();if(n.loadPromise)return n.loadPromise;let r=n.mutationVersion,i=!1;return n.loadPromise=n.writeQueue.then(()=>g(`/api/composer-history?conversationId=${encodeURIComponent(e)}`)).then(t=>{n.mutationVersion===r?(n.items=t.items.filter(t=>t.conversationId===e).slice(0,100),n.loaded=!0):i=!0}).catch(()=>{}).finally(()=>{n.loadPromise=null,i&&n.writeQueue.then(()=>uE(e,!0))}),n.loadPromise}function dE(e,t){let n=t.trim();if(!n)return;let r=oE(e),i=r.clearVersion;r.mutationVersion+=1,sE(r,{conversationId:e,id:0,text:n,createdAt:Date.now()}),r.writeQueue=r.writeQueue.then(async()=>{let t=await g(`/api/composer-history`,{method:`POST`,body:JSON.stringify({conversationId:e,text:n})});r.clearVersion===i&&t.item.conversationId===e&&cE(r,t.item)}).catch(()=>{})}function fE(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=oE(t.conversationId);return n.mutationVersion+=1,cE(n,t),t.conversationId}function pE(e){if(!e||typeof e!=`object`||!(`conversationId`in e)||typeof e.conversationId!=`string`)return null;let t=oE(e.conversationId);return t.mutationVersion+=1,t.clearVersion+=1,t.items=[],e.conversationId}function mE(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&&uE(t,!0);let e=e=>{fE(e.detail)===t&&c()},n=e=>{pE(e.detail)===t&&c()},r=()=>{t&&uE(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&&!Wn(e)&&dE(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=lE(t);if(a.length===0)return!1;let o=s.current,c=n.current,l=c?bp(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 hE(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 gE(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 _E(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=hE(t.current);if(n===`blocked`)return;if(n===`queue`){D.current();return}let r=gE({voiceActive:i,cancelVoiceInput:a,...w});if(!r)return;if(n===`saveFollowUp`){if(O.current||!o)return;O.current=!0,Promise.resolve().then(()=>g(o,r.text,r.attachments,d(),r.contextRefs)).then(n=>{if(n===!1)return;C?.(r.text);let i=t.current;i.draftScope!==e.draftScope||i.editingFollowUpId!==o||i.getTextValue()!==r.text||JSON.stringify(i.wireAttachmentsPayload())!==JSON.stringify(r.attachments)||JSON.stringify(i.getContextRefs())!==JSON.stringify(r.contextRefs)||(i.onFinishFollowUpEdit?.(),S())}).catch(e=>ya(`error`,e instanceof Error?e.message:String(e))).finally(()=>{O.current=!1});return}let s=[r.text,r.attachments.length>0?r.attachments:void 0,d(),r.contextRefs.length>0?r.contextRefs:void 0,{onDispatched:e=>p?.(e,r)}];TT(f(...s),i=>{C?.(r.text,i);let a=t.current,o=e.draftScope,s=a.draftScope;if(!(!(n===`send`&&o?.conversationId===null&&i!==void 0&&s?.conversationId===i&&s.gatewayIdentity===o.gatewayIdentity)&&s!==o||a.getTextValue()!==r.text||JSON.stringify(a.wireAttachmentsPayload())!==JSON.stringify(r.attachments)||JSON.stringify(a.getContextRefs())!==JSON.stringify(r.contextRefs))){if(n===`replaceTurn`){a.editingUserTurnId===e.editingUserTurnId&&a.onFinishUserEdit?.();return}y(),b(),x()}})},[r,o,g,S,i,a,f,p,e.editingUserTurnId,e.draftScope,d,C,y,b,x,s,c,l,u]),A=(0,Q.useCallback)(async(o=!e.personal&&void 0,s=e.personal?`steer`:void 0)=>{if(t.current.editingFollowUpId||t.current.editingUserTurnId){k();return}if(!r&&v===0)return;let c=gE({voiceActive:i,cancelVoiceInput:a,...w});if(c&&!t.current.blocked&&m&&!T.current){if(v>=10){ya(`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){ya(`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=gE({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=>ya(`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 vE=e=>e?.kind===`editTurn`?`turn:${e.turnId}`:e?.kind===`editFollowUp`?`input:${e.inputId}:${e.version}`:`compose`,yE=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),bE=new Map;function xE(e,t){let n=(bE.get(e)??Promise.resolve()).catch(()=>{}).then(t);bE.set(e,n);let r=()=>{bE.get(e)===n&&bE.delete(e)};return n.then(r,r),n}function SE(e,t,n,r,i,a,o,s){let c=vE(a?.snapshot().mode),l=m(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),[h,g]=(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:Dr(e)};f.current=i;let a=!1,c=bE.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,g(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||!yE(i.attachments,e.snapshot.attachments)||!yE(i.refs,e.snapshot.refs)||vE(i.editSession?.mode)!==vE(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;xE(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,h,t.value,n.attachments,r,c]),(0,Q.useEffect)(()=>{let e=f.current;if(!(!e?.ready||!u))return Hs(u,async(t,n)=>{if(await bE.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 xE(u,()=>e.storage.write(t))}catch(n){throw e.receipts=e.receipts.filter(e=>e!==t),n}})},[u,h])}function CE(e){let{conversationId:t,agentId:n,modelKey:r,locale:i,enabled:a,draftText:o,canShow:s}=e,c=m(e=>e.conversationId),[l,u]=(0,Q.useState)(null),[d,h]=(0,Q.useState)(null),g=(0,Q.useRef)(null),_=(0,Q.useRef)(o),v=(0,Q.useRef)(-1),y=(0,Q.useCallback)((e,t,n)=>{f(p(`/api/sessions/${encodeURIComponent(e.suggestion.conversationId)}/next-turn-suggestion-feedback`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({suggestionId:e.suggestion.id,impressionId:e.impressionId,event:t,...n===void 0?{}:{edited:n}})}).catch(()=>{})},[]);(0,Q.useEffect)(()=>{_.current.length>0&&o.length===0&&(g.current=null),_.current=o},[o]),(0,Q.useEffect)(()=>{g.current=null,v.current=-1,u(null),h(null)},[t,n,r,i,c]),(0,Q.useEffect)(()=>{if(u(null),!a||!t)return;let e=!1,r=0,o,s=0,c=new AbortController,l=async()=>{let a=++r;try{if(await wr(t))return;let d=await f(p(`/api/sessions/${encodeURIComponent(t)}/next-turn-suggestion?locale=${i}`),{signal:c.signal});if(!d.ok)return;let m=Ns.safeParse(await d.json());if(e||a!==r||!m.success)return;let h=m.data.suggestion;if(m.data.status===`ready`&&h&&h.conversationId===t&&h.locale===i&&(!n||h.agentId===n)&&h.inputRevision>=v.current&&h.expiresAt>Date.now()&&h.transcriptId===await Ar(t)){if(e||a!==r)return;u(e=>e?.suggestion.id===h.id?e:{suggestion:h,impressionId:crypto.randomUUID()}),o=setTimeout(()=>{u(null)},Math.max(0,h.expiresAt-Date.now()))}else u(null),m.data.status===`pending`&&s++<7&&(o=setTimeout(()=>{l()},600))}catch{}},d=e=>{let n=e.detail;if(!(n?.conversationId!==t&&n?.key!==t)){if(typeof n.revision==`number`){if(n.revision<v.current)return;v.current=n.revision}r++,s=0,o&&clearTimeout(o),u(null),e.type===`session-transcript-updated`?o=setTimeout(()=>{l()},150):l()}},m=()=>{r++,s=0,o&&clearTimeout(o),u(null),l()},h=e=>{e.detail?.topic===`sessions`&&m()};l();let g=[`session-next-turn-suggestion-changed`,`session-input-state`,`session-updated`,`session-transcript-updated`];return g.forEach(e=>window.addEventListener(e,d)),window.addEventListener(`gateway-realtime-connected`,m),window.addEventListener(`config-reload`,m),window.addEventListener(`realtime-gap`,h),()=>{e=!0,r++,c.abort(),o&&clearTimeout(o),g.forEach(e=>window.removeEventListener(e,d)),window.removeEventListener(`gateway-realtime-connected`,m),window.removeEventListener(`config-reload`,m),window.removeEventListener(`realtime-gap`,h)}},[t,n,r,i,c,a]);let b=a&&s&&o.length===0&&l?.suggestion.id!==d&&l?.suggestion.conversationId===t&&l.suggestion.expiresAt>Date.now()?l:null,x=(0,Q.useCallback)(()=>{b&&y(b,`shown`)},[b,y]),S=(0,Q.useCallback)(()=>b?(g.current=b,y(b,`accepted`),b.suggestion.prompt):null,[b,y]),C=(0,Q.useCallback)(()=>{b&&(h(b.suggestion.id),y(b,`dismissed`))},[b,y]),w=(0,Q.useCallback)(e=>{let n=g.current;!n||n.suggestion.conversationId!==t||(h(n.suggestion.id),y(n,`submitted`,e.trim()!==n.suggestion.prompt),g.current=null)},[t,y]);return{suggestion:b?.suggestion??null,shown:x,accept:S,dismiss:C,submitted:w}}function wE(e){let t=(0,X.c)(6),{active:n,anchors:r,ignoreSelector:i,onDismiss:a}=e,o,s;t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a?(o=()=>{if(!n)return;let e=e=>{let t=e.target;if(t instanceof Node){for(let e of r){let n=e.current;if(n&&n.contains(t))return}i&&t instanceof Element&&t.closest(i)||a()}};return window.addEventListener(`pointerdown`,e,!0),()=>window.removeEventListener(`pointerdown`,e,!0)},s=[n,r,i,a],t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s):(o=t[4],s=t[5]),(0,Q.useEffect)(o,s)}var TE=20,EE=`xopc.atMention.recent:`;function DE(e){return`${EE}${e.trim()}`}function OE(e){let t=e?.trim();if(!t||typeof localStorage>`u`)return[];try{let e=localStorage.getItem(DE(t));if(!e)return[];let n=JSON.parse(e);return Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.length>0).slice(0,TE):[]}catch{return[]}}function kE(e,t){let n=e?.trim(),r=t.trim();if(!(!n||!r||typeof localStorage>`u`))try{let e=[r,...OE(n).filter(e=>e!==r)].slice(0,TE);localStorage.setItem(DE(n),JSON.stringify(e))}catch{}}var AE=150,jE=[`file`,`note`,`session`,`browser_tab`,`skill`,`agent`];function ME(e){let t={items:[],loading:e,error:null};return{file:{...t},note:{...t},session:{...t},skill:{...t},agent:{...t},browser_tab:{...t}}}function NE(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 PE(e){return e.replace(/[\\\s]/gu,e=>`\\${e}`)}function FE(e){let t=e.trim();return t.length>0&&t.endsWith(`/`)&&!/^https?:\/\//i.test(t)}function IE(e){return e.replace(/\/+$/,``).trim()}function LE(e){let t=e.replace(/\/+$/,``);if(!t)return``;let n=t.lastIndexOf(`/`);return n<=0?``:t.slice(0,n)}function RE(e,t){return t===0?0:Math.min(e,t-1)}function zE(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 BE(e,t,n){let r=(0,X.c)(55),i=n.capabilities??ep,[a,o]=(0,Q.useState)(0),[s,c]=(0,Q.useState)(GE),l=(0,Q.useRef)(0),u=h(WE),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=NE(e,t),r[0]=t,r[1]=e,r[2]=i):i=r[2],d=i}let f=d,p=f!==null,[m]=Wa(p?f.query:``,AE),g=p?m:``,_;r[3]===n.conversationId?_=r[4]:(_=n.conversationId?.trim()??``,r[3]=n.conversationId,r[4]=_);let v=_,y;r[5]===n.selectedContextKeys?y=r[6]:(y=[...n.selectedContextKeys??new Set].sort().join(`\0`),r[5]=n.selectedContextKeys,r[6]=y);let b=y,x;r[7]!==i.agentSwitch||r[8]!==i.skills||r[9]!==v||r[10]!==g||r[11]!==u||r[12]!==n||r[13]!==p||r[14]!==b?(x=()=>{let e=l.current+=1;if(!p){c(ME(!1));return}if(!v){c(ME(!!n.prepareSession)),n.prepareSession&&n.prepareSession().catch(()=>{l.current===e&&c(ME(!1))});return}let t={conversationId:v,currentAgentId:n.currentAgentId,language:u,selectedContextKeys:new Set(b?b.split(`\0`):[]),recentPaths:new Set(OE(v))};if(FE(g)){let t=ME(!1);t.file={items:[],loading:!0,error:null},c(t);let r=IE(g);Dw(r,{conversationId:v,agentId:n.currentAgentId}).then(t=>{if(l.current!==e)return;let n={id:`browse-up:${r}`,kind:`file`,name:`..`,description:LE(r)||`/`,relativePath:``,isDirectory:!0,isBrowseUp:!0};c(e=>({...e,file:{items:[n,...t.map(zE)],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(ME(!0));for(let n of Aw.filter(e=>(e.kind!==`skill`||i.skills)&&(e.kind!==`agent`||i.agentSwitch)))n.search(g,t).then(t=>{l.current===e&&c(e=>({...e,[n.kind]:{items:t,loading:!1,error:null}}))}).catch(t=>{l.current===e&&c(e=>({...e,[n.kind]:{items:[],loading:!1,error:t instanceof Error?t.message:String(t)}}))})},r[7]=i.agentSwitch,r[8]=i.skills,r[9]=v,r[10]=g,r[11]=u,r[12]=n,r[13]=p,r[14]=b,r[15]=x):x=r[15];let S;r[16]!==i.agentSwitch||r[17]!==i.skills||r[18]!==v||r[19]!==g||r[20]!==u||r[21]!==n.currentAgentId||r[22]!==n.prepareSession||r[23]!==p||r[24]!==b?(S=[p,v,g,u,n.currentAgentId,n.prepareSession,b,i.skills,i.agentSwitch],r[16]=i.agentSwitch,r[17]=i.skills,r[18]=v,r[19]=g,r[20]=u,r[21]=n.currentAgentId,r[22]=n.prepareSession,r[23]=p,r[24]=b,r[25]=S):S=r[25],(0,Q.useEffect)(x,S);let C;if(r[26]!==i.agentSwitch||r[27]!==i.skills||r[28]!==s){let e;r[30]!==i.agentSwitch||r[31]!==i.skills?(e=e=>(e!==`skill`||i.skills)&&(e!==`agent`||i.agentSwitch),r[30]=i.agentSwitch,r[31]=i.skills,r[32]=e):e=r[32];let t;r[33]===s?t=r[34]:(t=e=>({kind:e,...s[e]}),r[33]=s,r[34]=t),C=jE.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(UE):[],E;r[35]!==p||r[36]!==w?(E=p&&w.some(HE),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(VE),r[38]=w,r[39]=O);let k=O,A=!D&&T.length===0?k[0]??null:null,j=`${f?.start??``}:${f?.end??``}:${g}`,M;r[40]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>o(0),r[40]=M):M=r[40];let N;r[41]===j?N=r[42]:(N=[j],r[41]=j,r[42]=N),(0,Q.useEffect)(M,N);let P=RE(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 VE(e){return e.error?[e.error]:[]}function HE(e){return e.loading}function UE(e){return e.items}function WE(e){return e.language}function GE(){return ME(!1)}function KE(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 qE(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??ep,D=(0,Q.useMemo)(()=>NE(n,r),[n,r]),O=KT(n,r,{suppress:D!=null,capabilities:E,isComposing:i,currentAgentId:m,conversationId:t}),k=BE(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`||MT(e,j())},[j,E]),N=(0,Q.useCallback)(e=>{let n=k.atRange;if(!n)return;let r=KE(e);if(r){let i=_(r);if(!i?.refId)return;let a=`${_r(i.refId)} `,o=OT(c.current,n.start,n.end,a);l({nextText:o,caretOffset:n.start+a.length,focus:!0}),t&&e.kind===`file`&&kE(t,e.relativePath);return}if(e.kind===`skill`){if(!E.skills)return;let t=`/skill:${e.canonicalName} `,r=OT(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=OT(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=`@${PE(e.isBrowseUp?(()=>{let e=LE(IE(n.query));return e?`${e}/`:``})():`${e.relativePath.replace(/\/+$/,``)}/`)}`,a=OT(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]);wE({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=OT(r,n.start,n.end,``);return l({nextText:i,caretOffset:n.start,focus:!0}),!0}if(t.items.length===0)return!1;if(e.key===`ArrowDown`)return e.preventDefault(),t.onNavigate(`down`),!0;if(e.key===`ArrowUp`)return e.preventDefault(),t.onNavigate(`up`),!0;if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let n=t.items[t.selectedIndex];return n&&H.current(n),!0}return!1}}),[l,F]),G=(0,Q.useMemo)(()=>({name:`slash-palette`,isActive:()=>z.current.open&&!B.current,handleKey:e=>{let t=z.current;if(t.flatItems.length>0){if(e.key===`ArrowDown`)return e.preventDefault(),t.onNavigate(`down`),!0;if(e.key===`ArrowUp`)return e.preventDefault(),t.onNavigate(`up`),!0;if((e.key===`Enter`||e.key===`Tab`)&&!e.shiftKey){e.preventDefault();let n=t.flatItems[t.selectedIndex];return!n||RT(n,U.current)||V.current(n),!0}}if(e.key===`Escape`){e.preventDefault();let n=t.slashRange;if(n){let e=F.current,t=OT(e,n.start,n.end,``);l({nextText:t,caretOffset:n.start,focus:!0})}return!0}return!1}}),[l,F]);return{palette:O,atPicker:k,shouldSyncSelection:A,adapters:(0,Q.useMemo)(()=>[W,G],[W,G]),applyPalette:M,applyAtMention:N}}function JE(e){return/^[A-Za-z0-9._/@:-]+$/.test(e)?e:JSON.stringify(e)}function YE(e,t){let n=t?.trim();return n?`${e} --instructions ${JE(n)}`:e}function XE(e){if(e.preset===`base`){if(!e.baseBranch?.trim())throw Error(`Missing base branch.`);return YE(`/review --base ${JE(e.baseBranch.trim())}`,e.instructions)}if(e.preset===`commit`){if(!e.commitSha?.trim())throw Error(`Missing commit SHA.`);return YE(`/review --commit ${JE(e.commitSha.trim())}`,e.instructions)}return e.preset,YE(`/review --uncommitted`,e.instructions)}async function ZE(e){let t=await f(p(`/api/review/context?${new URLSearchParams({conversationId:e}).toString()}`)),n=await t.json().catch(()=>({}));if(!t.ok||!n.ok||!n.payload)throw Error(v(t.status,t.statusText,n.error?.message));return n.payload}function QE(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 $E(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 eD(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 tD(e){let t=(0,X.c)(15),{icon:n,title:r,description:i,disabled:a,onClick:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=Y(`flex min-h-16 w-full items-center gap-3 rounded-lg border border-edge bg-surface-panel px-3 py-2.5 text-left`,`hover:border-accent/45 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:cursor-not-allowed disabled:opacity-50`,ca.transition),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,Z.jsx)(`span`,{className:`inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:n}),t[1]=n,t[2]=c);let l;t[3]===r?l=t[4]:(l=(0,Z.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:r}),t[3]=r,t[4]=l);let u;t[5]===i?u=t[6]:(u=(0,Z.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:i}),t[5]=i,t[6]=u);let d;t[7]!==l||t[8]!==u?(d=(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[l,u]}),t[7]=l,t[8]=u,t[9]=d):d=t[9];let f;return t[10]!==a||t[11]!==o||t[12]!==c||t[13]!==d?(f=(0,Z.jsxs)(`button`,{type:`button`,disabled:a,className:s,onClick:o,children:[c,d]}),t[10]=a,t[11]=o,t[12]=c,t[13]=d,t[14]=f):f=t[14],f}function nD(e){let t=(0,X.c)(89),{open:n,conversationId:r,disabled:i,chat:a,onClose:o,onSendCommand:s}=e,c=a.reviewLauncher,[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(`presets`),[_,v]=(0,Q.useState)(``),[y,x]=(0,Q.useState)(``),C;t[0]!==r||t[1]!==c.noSession?(C=()=>{if(!r){u(null),m(c.noSession);return}f(!0),m(null),ZE(r).then(e=>u(e)).catch(e=>{u(null),m(e instanceof Error?e.message:String(e))}).finally(()=>f(!1))},t[0]=r,t[1]=c.noSession,t[2]=C):C=t[2];let O=C,k,A;t[3]!==O||t[4]!==n?(k=()=>{n&&(g(`presets`),v(``),x(``),O())},A=[O,n],t[3]=O,t[4]=n,t[5]=k,t[6]=A):(k=t[5],A=t[6]),(0,Q.useEffect)(k,A);let M;t[7]!==l||t[8]!==_?(M=$E(l,_),t[7]=l,t[8]=_,t[9]=M):M=t[9];let N=M,P;t[10]!==l||t[11]!==_?(P=eD(l,_),t[10]=l,t[11]=_,t[12]=P):P=t[12];let F=P,I;t[13]!==l||t[14]!==c?(I=QE(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=XE({preset:e,baseBranch:t?.branch,commitSha:t?.commit,instructions:y});s(n),o()},t[16]=y,t[17]=o,t[18]=s,t[19]=R):R=t[19];let z=R,B=h===`base`?c.baseTitle:h===`commit`?c.commitTitle:h===`custom`?c.customTitle:c.title,V;t[20]===o?V=t[21]:(V=e=>!e&&o(),t[20]=o,t[21]=V);let H;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,Z.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[120] bg-scrim backdrop-blur-[1px]`}),t[22]=H):H=t[22];let U;t[23]!==c.back||t[24]!==h?(U=h===`presets`?null:(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":c.back,onClick:()=>{g(`presets`),v(``)},children:(0,Z.jsx)(j,{className:`size-4`})}),t[23]=c.back,t[24]=h,t[25]=U):U=t[25];let W;t[26]===B?W=t[27]:(W=(0,Z.jsx)(E,{className:`truncate text-sm font-semibold text-fg`,children:B}),t[26]=B,t[27]=W);let G=l?.cwd??c.description,ee;t[28]===G?ee=t[29]:(ee=(0,Z.jsx)(S,{className:`truncate text-xs text-fg-muted`,children:G}),t[28]=G,t[29]=ee);let te;t[30]!==W||t[31]!==ee?(te=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[W,ee]}),t[30]=W,t[31]=ee,t[32]=te):te=t[32];let ne;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,Z.jsx)(Gt,{className:`size-4`}),t[33]=ne):ne=t[33];let re;t[34]!==c.close||t[35]!==o?(re=(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":c.close,onClick:o,children:ne}),t[34]=c.close,t[35]=o,t[36]=re):re=t[36];let ie;t[37]!==U||t[38]!==te||t[39]!==re?(ie=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-4 py-3`,children:[U,te,re]}),t[37]=U,t[38]=te,t[39]=re,t[40]=ie):ie=t[40];let ae;t[41]!==N||t[42]!==F||t[43]!==l||t[44]!==i||t[45]!==p||t[46]!==y||t[47]!==O||t[48]!==d||t[49]!==c.customDescription||t[50]!==c.customPlaceholder||t[51]!==c.defaultBadge||t[52]!==c.errorTitle||t[53]!==c.loading||t[54]!==c.localBadge||t[55]!==c.noBranches||t[56]!==c.noCommits||t[57]!==c.presetBase||t[58]!==c.presetBaseDescription||t[59]!==c.presetBaseDescriptionNoDefault||t[60]!==c.presetCommit||t[61]!==c.presetCommitDescription||t[62]!==c.presetCustom||t[63]!==c.presetCustomDescription||t[64]!==c.presetUncommitted||t[65]!==c.remoteBadge||t[66]!==c.retry||t[67]!==c.searchBranches||t[68]!==c.searchCommits||t[69]!==_||t[70]!==z||t[71]!==L||t[72]!==h?(ae=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:d?(0,Z.jsxs)(`div`,{className:`flex h-full min-h-56 items-center justify-center text-sm text-fg-muted`,children:[(0,Z.jsx)(At,{className:`mr-2 size-4 animate-spin`}),c.loading]}):p?(0,Z.jsxs)(`div`,{className:`rounded-lg border border-danger/30 bg-danger/5 p-4`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:c.errorTitle}),(0,Z.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:p}),(0,Z.jsxs)(pi,{type:`button`,className:`mt-4 h-9 rounded-lg`,variant:`secondary`,onClick:O,children:[(0,Z.jsx)(At,{className:`size-4`}),c.retry]})]}):h===`presets`?(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Z.jsx)(tD,{icon:(0,Z.jsx)(Me,{className:`size-4`}),title:c.presetBase,description:l?.defaultBaseBranch?c.presetBaseDescription.replace(`{{branch}}`,l.defaultBaseBranch):c.presetBaseDescriptionNoDefault,disabled:i,onClick:()=>g(`base`)}),(0,Z.jsx)(tD,{icon:(0,Z.jsx)(Ke,{className:`size-4`}),title:c.presetUncommitted,description:L,disabled:i,onClick:()=>z(`uncommitted`)}),(0,Z.jsx)(tD,{icon:(0,Z.jsx)(ps,{className:`size-4`}),title:c.presetCommit,description:c.presetCommitDescription.replace(`{{count}}`,String(l?.commits.length??0)),disabled:i,onClick:()=>g(`commit`)}),(0,Z.jsx)(tD,{icon:(0,Z.jsx)(Ke,{className:`size-4`}),title:c.presetCustom,description:c.presetCustomDescription,disabled:i,onClick:()=>g(`custom`)})]}):h===`base`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(rD,{value:_,placeholder:c.searchBranches,onChange:v}),(0,Z.jsx)(`div`,{className:`grid gap-1`,children:N.length===0?(0,Z.jsx)(`div`,{className:`rounded-lg border border-edge-subtle px-3 py-6 text-center text-sm text-fg-muted`,children:c.noBranches}):N.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`flex items-center justify-between gap-3 rounded-lg px-3 py-2 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,disabled:i,onClick:()=>z(`base`,{branch:e.name}),children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-sm text-fg`,children:e.name}),(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:e.name===l?.defaultBaseBranch?c.defaultBadge:e.remote?c.remoteBadge:c.localBadge})]},e.name))})]}):h===`commit`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(rD,{value:_,placeholder:c.searchCommits,onChange:v}),(0,Z.jsx)(`div`,{className:`grid gap-1`,children:F.length===0?(0,Z.jsx)(`div`,{className:`rounded-lg border border-edge-subtle px-3 py-6 text-center text-sm text-fg-muted`,children:c.noCommits}):F.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`flex items-center gap-3 rounded-lg px-3 py-2 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,disabled:i,onClick:()=>z(`commit`,{commit:e.sha}),children:[(0,Z.jsx)(`span`,{className:`font-mono text-xs text-fg-muted`,children:e.shortSha}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg`,children:e.subject}),e.date?(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:e.date.slice(0,10)}):null]},e.sha))})]}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(`textarea`,{className:`h-40 resize-none rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-disabled focus:border-accent focus:ring-2 focus:ring-accent/25`,value:y,placeholder:c.customPlaceholder,onChange:e=>x(e.target.value)}),(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:c.customDescription})]})}),t[41]=N,t[42]=F,t[43]=l,t[44]=i,t[45]=p,t[46]=y,t[47]=O,t[48]=d,t[49]=c.customDescription,t[50]=c.customPlaceholder,t[51]=c.defaultBadge,t[52]=c.errorTitle,t[53]=c.loading,t[54]=c.localBadge,t[55]=c.noBranches,t[56]=c.noCommits,t[57]=c.presetBase,t[58]=c.presetBaseDescription,t[59]=c.presetBaseDescriptionNoDefault,t[60]=c.presetCommit,t[61]=c.presetCommitDescription,t[62]=c.presetCustom,t[63]=c.presetCustomDescription,t[64]=c.presetUncommitted,t[65]=c.remoteBadge,t[66]=c.retry,t[67]=c.searchBranches,t[68]=c.searchCommits,t[69]=_,t[70]=z,t[71]=L,t[72]=h,t[73]=ae):ae=t[73];let oe;t[74]!==i||t[75]!==c.cancel||t[76]!==c.runReview||t[77]!==o||t[78]!==z||t[79]!==h?(oe=h===`custom`?(0,Z.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-4 py-3`,children:[(0,Z.jsx)(pi,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg`,onClick:o,children:c.cancel}),(0,Z.jsx)(pi,{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]=oe):oe=t[80];let se;t[81]!==ie||t[82]!==ae||t[83]!==oe?(se=(0,Z.jsxs)(w,{children:[H,(0,Z.jsxs)(T,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[121] flex h-[min(86vh,34rem)] w-[min(100vw-2rem,40rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:[ie,ae,oe]})]}),t[81]=ie,t[82]=ae,t[83]=oe,t[84]=se):se=t[84];let ce;return t[85]!==n||t[86]!==se||t[87]!==V?(ce=(0,Z.jsx)(D,{open:n,onOpenChange:V,children:se}),t[85]=n,t[86]=se,t[87]=V,t[88]=ce):ce=t[88],ce}function rD(e){let t=(0,X.c)(7),{value:n,placeholder:r,onChange:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Nt,{className:`size-4 shrink-0 text-fg-muted`}),t[0]=a):a=t[0];let o;t[1]===i?o=t[2]:(o=e=>i(e.target.value),t[1]=i,t[2]=o);let s;return t[3]!==r||t[4]!==o||t[5]!==n?(s=(0,Z.jsxs)(`label`,{className:`flex h-9 items-center gap-2 rounded-lg border border-edge bg-surface-base px-3 text-sm text-fg focus-within:border-accent focus-within:ring-2 focus-within:ring-accent/25`,children:[a,(0,Z.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent outline-none placeholder:text-fg-disabled`,value:n,placeholder:r,onChange:o})]}),t[3]=r,t[4]=o,t[5]=n,t[6]=s):s=t[6],s}function iD(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 aD=(0,Q.memo)(function({personal:e=!1,placeholder:t,nextTurnSuggestionsEnabled:n=!1,disabled:r,sendDisabled:i=!1,sending:a,streaming:o,conversationId:s,composerContext:c,pageContextPreview:u,contextRefs:d,setContextRefs:f,onDraftAttachmentsChange:p,thinkingLevel:g,modelSupportsThinking:_,onThinkingChange:v,onSend:b,onPersonalSendDispatched:x,onAbort:S,onAddPendingFollowUp:C,onSteeringInterrupt:w,pendingFollowUps:T,editingFollowUpId:E,onBeginEditFollowUp:D,onCancelEditFollowUp:O,onCommitEditFollowUp:k,onPendingFollowUpRemove:A,onPendingFollowUpMove:j,onPendingFollowUpReorder:M,onPendingFollowUpSteer:N,onPendingFollowUpSend:P,steeringFollowUpId:F,welcomeDraftSeed:I,welcomeSuggestion:L,onAcceptWelcomeSuggestion:R,sessionModel:z,showModelSelector:B,onModelChange:V,modelDisabled:H,onChatAgentChange:U,currentAgentId:W,voiceAgentName:G,voiceTaskId:ee,voiceMode:te,prepareVoiceSession:ne,prepareContextSession:re,unboundDraftKey:ie,getDraftHandoffTarget:ae,editingUserTurnId:oe,composerMode:se,inputControl:ce,onResumeQueue:le,onRestoreEditor:ue,onReacquireEdit:K,onCancelUserMessageEdit:q}){let de=ba(),fe=(0,Q.useRef)(!1);r||=de.conversationId===s&&de.active;let pe=h(e=>e.language),J=y(pe),[me,he]=l();(0,Q.useEffect)(()=>{bo()},[]);let ge=(...e)=>{if(i)return!1;let t=b(...e);return t instanceof Promise?t.then(t=>(t!==!1&&at.submitted(e[0]),t)):(t!==!1&&at.submitted(e[0]),t)},_e=(0,Q.useRef)(!1),ve=(0,Q.useRef)(null),ye=(0,Q.useRef)(null),be=(0,Q.useRef)(null),xe=(0,Q.useRef)(!1),[Se,Ce]=(0,Q.useState)(!1),[we,Te]=(0,Q.useState)(null),[Ee,De]=(0,Q.useState)(null),[Oe,Ae]=(0,Q.useState)(!1),je=(0,Q.useRef)(ge),Me=(0,Q.useRef)(g);je.current=ge,Me.current=g,(0,Q.useEffect)(()=>{if(!s||Ee===s){Te(null);return}let e=!1;return wr(s).then(e=>e?null:wo(s)).then(t=>{e||Te(t&&t.required&&!t.trusted&&t.decision===null?t:null)}).catch(()=>{e||Te(null)}),()=>{e=!0}},[s,Ee]);let Ne=(0,Q.useCallback)(()=>{!s||Oe||(Ae(!0),go(s,!0).then(()=>{Te(null)}).catch(e=>{ya(`error`,J.chat.commandPalette.workspaceTrustFailed,{error:e instanceof Error?e.message:String(e)})}).finally(()=>Ae(!1)))},[J.chat.commandPalette,s,Oe]),Pe=$r({conversationId:s??`new`,chat:J.chat,onAttachmentsChange:e=>p?.(e.map((e,t)=>({id:e.uri||e.id||`draft:${t}:${e.name}`,title:e.name})))}),Fe=(0,Q.useRef)(d);Fe.current=d;let Ie=(0,Q.useCallback)(e=>{let t=d.find(t=>t.refId===e);return t?{title:t.title,kind:t.kind,fileKind:t.fileKind}:void 0},[d]),Le=(0,Q.useCallback)(e=>{let t=e?.contextRefs??[];if(Fe.current=t,f(t),e?.attachments){Pe.setAttachments(e.attachments.map(iD));return}Pe.clearAttachments()},[Pe.clearAttachments,Pe.setAttachments,f]),Re=(0,Q.useCallback)(e=>{let t=Fe.current,n=t.find(t=>t.kind===e.kind&&t.sourceId===e.sourceId);if(n){if(n.refId)return n;let r={...n,refId:e.refId},i=t.map(e=>e===n?r:e);return Fe.current=i,f(i),r}if(t.length>=5)return ya(`warning`,J.chat.commandPalette.contextLimitReached,{max:5}),null;let r=[...t,e];return Fe.current=r,f(r),e},[J.chat.commandPalette.contextLimitReached,f]);(0,Q.useEffect)(()=>{let e=e=>{let t=e.detail;t?.conversationId!==s||t.reference.kind!==`result`||Re(t.reference)};return window.addEventListener(`chat-result-reference`,e),()=>window.removeEventListener(`chat-result-reference`,e)},[s,Re]);let ze=(0,Q.useCallback)(e=>{let t=e.availability.status===`agent-denied`?J.chat.commandPalette.skillAgentDeniedReason:J.chat.commandPalette.skillDisabledReason,n=em(J.chat.commandPalette.skillUnavailableMessage,{name:e.name,agent:W||`main`,reason:t});if(e.availability.status===`agent-denied`&&window.confirm(`${n}\n\n${J.chat.commandPalette.skillAddToAllowlistConfirm}`)){To(W,e.canonicalName,s).catch(e=>{window.alert(e instanceof Error?e.message:String(e))});return}window.alert(n)},[W,J.chat.commandPalette,s]),Be=Xp({capabilities:e?tp:ep,disabled:r,agentId:W,conversationId:s,autoFocusKey:s,welcomeDraftSeed:I,onExternalTextReplace:Le,shouldSyncSelectionRef:_e,resolveContextRef:Ie}),Ve=me.get(`attachmentHandoff`);(0,Q.useEffect)(()=>{if(!Ve)return;let e=ke(Ve);he(e=>{let t=new URLSearchParams(e);return t.delete(`attachmentHandoff`),t},{replace:!0}),e&&Pe.processFiles([e]).then(()=>Be.editorRef.current?.focus({preventScroll:!0}))},[Ve,Pe.processFiles,Be.editorRef,s,he]);let{onUserTextCommitted:He,onWireInputClearWalk:Ue,tryInputHistoryArrow:We}=mE({conversationId:s,editorRef:Be.editorRef,valueRef:Be.valueRef,resetEditor:Be.resetEditor,onWireInput:Be.onWireInput}),Ge=(0,Q.useCallback)((e,t)=>{Ue(e,t);let n=Wn(e),r=new Set(n?gn(n):[]),i=Fe.current,a=i.filter(e=>!e.refId||r.has(e.refId));a.length!==i.length&&(Fe.current=a,f(a))},[Ue,f]),Ke=Pf(s??``),qe=a||o||Ke||ce?.phase===`running`||ce?.phase===`stopping`;xe.current=qe;let Je=(0,Q.useCallback)(()=>{xe.current||Ce(!0)},[]),Ye=(0,Q.useCallback)(e=>{TT(je.current(e,void 0,Me.current,d),t=>{He?.(e,t),f([])})},[d,He,f]),Xe=qE({capabilities:e?tp:ep,conversationId:s,editorValue:Be.value,editorCursor:Be.cursor,isComposing:Be.isComposing,runBusy:qe,thinkingLevel:g,editorRef:Be.editorRef,valueRef:Be.valueRef,resetEditor:Be.resetEditor,clearAttachments:Pe.clearAttachments,onSend:ge,onUserTextCommitted:He,onChatAgentChange:U,currentAgentId:W,prepareSession:re,contextRefs:d,onAddContextRef:Re,onUnavailableSkill:ze,onReviewLauncher:Je,onAddPendingFollowUp:C,onAbort:S,pendingFollowUpsCount:T.length,maxPendingFollowUps:10,clearContextRefs:()=>f([]),commandPalettePanelRef:ve});_e.current=Xe.shouldSyncSelection;let Ze=_a({disabled:r||de.active,chat:J.chat,onTranscript:e=>{let t=Be.valueRef.current,n=Di(t,e);Be.resetEditor({nextText:n,caretOffset:n.length,focus:!0})}}),{phase:Qe,voiceActive:$e,startVoiceInput:et,cancelVoiceInput:tt,confirmVoiceInput:nt}=Ze;(0,Q.useEffect)(()=>{let e=e=>{if(!eT(e,{disabled:r,editorHidden:$e&&Qe!==`error`}))return;let t=Vp(e.clipboardData);t&&(e.preventDefault(),Be.focusForExternalPaste(),Hp(t,{processFiles:Pe.processFiles,processPastedText:Pe.processPastedText,insertText:e=>document.execCommand(`insertText`,!1,e),onUnsupportedFiles:()=>ya(`warning`,J.chat.clipboardFileTypeUnsupported)}))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[Pe.processFiles,Pe.processPastedText,r,Be.focusForExternalPaste,J.chat.clipboardFileTypeUnsupported,$e,Qe]),(0,Q.useEffect)(()=>{let e=e=>{let t=e?.detail?.target;if(!(t&&t!==`chat`)&&(e?.preventDefault(),!r)){if(Qe===`recording`){nt();return}(Qe===`idle`||Qe===`error`)&&(Be.editorRef.current?.focus({preventScroll:!0}),et())}},t=e=>{let t=e.detail?.target;t&&t!==`chat`||!$e||(e.preventDefault(),tt(),Be.editorRef.current?.focus({preventScroll:!0}))};window.addEventListener(ko,e),window.addEventListener(Do,t);let n=window.setTimeout(()=>{if(Ao()){if(r){Oo();return}e()}},0);return()=>{window.clearTimeout(n),window.removeEventListener(ko,e),window.removeEventListener(Do,t)}},[tt,nt,r,Be.editorRef,et,$e,Qe]);let rt=(0,Q.useCallback)(()=>{be.current=null},[]),it=n&&!r&&!i&&!qe&&!E&&!oe&&!Ze.voiceActive&&!Be.isComposing&&Be.value.length===0&&Pe.attachments.length===0&&d.length===0&&T.length===0,at=CE({conversationId:s,agentId:W,modelKey:z,locale:pe,enabled:n,draftText:Be.value,canShow:it}),ot=()=>{if(!it||Be.valueRef.current.length>0||Fe.current.length>0)return!1;let e=at.accept();return e?(Be.resetEditor({nextText:e,focus:!0}),!0):!1};(0,Q.useEffect)(()=>{it&&at.suggestion&&!Xe.palette.open&&at.shown()},[it,at.suggestion,at.shown,Xe.palette.open]);let st=m(e=>e.conversationId),ct=(0,Q.useMemo)(()=>({gatewayIdentity:st,conversationId:s,unboundDraftKey:ie}),[st,s,ie]),lt=(0,Q.useRef)(new Map),ut=(0,Q.useRef)(`compose`),dt=se??(E?{kind:`editFollowUp`,inputId:E,version:0}:{kind:`compose`}),ft=dt.kind===`editTurn`?`turn:${dt.turnId}`:dt.kind===`editFollowUp`?`input:${dt.inputId}`:`compose`;(0,Q.useLayoutEffect)(()=>{lt.current.clear(),ut.current=`compose`},[ct]),SE(s,Be,Pe,d,f,{snapshot:()=>({mode:dt,drafts:Object.fromEntries(lt.current)}),restore:e=>{lt.current=new Map(Object.entries(e.drafts)),ut.current=e.mode.kind===`editTurn`?`turn:${e.mode.turnId}`:e.mode.kind===`editFollowUp`?`input:${e.mode.inputId}`:`compose`,ue?.(e.mode)}},ie,ae);let pt=dt.kind!==`compose`&&!!(ce&&!ce.paused),mt=_E({personal:e,chat:J.chat,runBusy:qe,draftScope:ct,queuePaused:ce?.paused,editingUserTurnId:oe,blocked:r||i||pt||ce?.phase===`stopping`,onFinishUserEdit:q,onFinishFollowUpEdit:O,voiceActive:Ze.voiceActive,cancelVoiceInput:Ze.cancelVoiceInput,editingFollowUpId:E,getTextValue:()=>Be.valueRef.current,getAttachmentCount:()=>Pe.attachmentsRef.current.length,wireAttachmentsPayload:Pe.wireAttachmentsPayload,getContextRefs:()=>d,getThinkingLevel:()=>Me.current,onSend:ge,onDispatched:e&&x?(e,t)=>{let n=Be.editorRef.current?.getBoundingClientRect();n&&x(e,n,t)}:void 0,onAddPendingFollowUp:C,onSteeringInterrupt:w,onCommitEditFollowUp:k,onPendingFollowUpRemove:A,pendingFollowUpsCount:T.length,firstPendingFollowUpId:T[0]?.id,onSteerPendingFollowUp:N,steeringPending:!!F,resetEditor:()=>{Be.resetEditor()},clearAttachments:Pe.clearAttachments,clearContextRefs:()=>f([]),clearEditFollowUpRef:rt,onUserTextCommitted:He}),ht=(0,Q.useCallback)((e=!1)=>mt.flushSteeringDraft(e),[mt.flushSteeringDraft]),gt=(0,Q.useCallback)((e,t)=>{!s||s===`new`||xw.getState().requestCreate(s,[{id:e.id,type:`text`,text:t,label:J.chat.followUpQueueHeading}])},[s,J.chat.followUpQueueHeading]);(0,Q.useLayoutEffect)(()=>{if(ut.current===ft)return;lt.current.set(ut.current,{text:Be.valueRef.current,attachments:Pe.wireAttachmentsPayload(),contextRefs:Fe.current,thinkingLevel:Me.current}),ut.current=ft;let e=dt.kind===`editFollowUp`?T.find(e=>e.id===dt.inputId):void 0;e?.thinkingLevel&&_&&v(e.thinkingLevel);let t=(dt.kind===`compose`?dt.draft:void 0)??lt.current.get(ft)??(dt.kind===`editTurn`?dt.draft:e?{text:e.text,attachments:e.attachments??[],contextRefs:e.contextRefs??[]}:void 0);t?.thinkingLevel&&_&&v(t.thinkingLevel),Pe.setAttachments(_T(t?.attachments??[])),f(t?.contextRefs??[]),Be.resetEditor({nextText:t?.text??``,focus:!0})},[ft,dt,T,Pe,Be,f]);let _t=(0,Q.useCallback)(e=>{D(e)},[D]),vt=(0,Q.useRef)({});vt.current={adapters:Xe.adapters,send:mt.send,runBusy:qe,pendingFollowUpsCount:T.length,flushSteeringDraft:ht,steerDraft:()=>mt.flushSteeringDraft(!1,`steer`),steerCurrentReply:mt.steerCurrentReply,interruptDraft:mt.interruptDraft,editingFollowUpId:E,editingUserTurnId:oe,onCancelUserMessageEdit:q,onCancelEditFollowUp:O,attachmentsLen:Pe.attachments.length,contextRefsLen:d.length,isComposing:Be.isComposing,valueRef:Be.valueRef,adjustHeight:Be.adjustHeight,editorRef:Be.editorRef,tryInputHistoryArrow:We,acceptEmptySuggestion:at.suggestion&&it?ot:!qe&&!r&&!i&&!oe&&!Ze.voiceActive&&L&&R?()=>(R(L),!0):void 0,dismissEmptySuggestion:at.suggestion?at.dismiss:void 0};let yt=qe&&!E&&!oe,bt={...J.chat,sendMessage:E?J.chat.followUpSaveEdit:oe?J.chat.userMessageReplaceSend:ce?.paused?J.chat.sendThisMessage:J.chat.sendMessage},xt=!!Be.value.trim()||Pe.attachments.length>0||d.length>0,St=xt&&!!w,Ct=Xo(`(hover: hover) and (pointer: fine)`),wt=!yt&&!E&&L?`${L.prompt}${Ct?` · ${J.chat.welcomeSpotlight.acceptSuggestionHint}`:``}`:null;return(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 w-full flex-col`,children:[s?(0,Z.jsx)(Xw,{conversationId:s},s):null,c?(0,Z.jsx)(lT,{...c,conversationId:s,disabled:(c.disabled??r)||a||o}):null,(0,Z.jsxs)($p,{className:e?`rounded-[1.65rem]`:void 0,dragging:Pe.isDragging,onDragOver:e=>{(e.dataTransfer?.types.includes(`Files`)||Wf(e.dataTransfer))&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,Pe.setIsDragging(!0))},onDragLeave:e=>{e.relatedTarget===null&&Pe.setIsDragging(!1)},onDrop:async e=>{e.preventDefault(),Pe.setIsDragging(!1);let t=e.dataTransfer?.files;if(t?.length){await Pe.processFiles(Array.from(t));return}let n=Gf(e.dataTransfer);if(n)try{let e=await Ra(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 Pe.processFiles([new File([e],n.name,{type:r})])}catch{ya(`error`,J.chat.attachmentLoadFailed,{name:n.name})}},children:[Pe.isDragging?(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-10 flex items-center justify-center rounded-xl bg-accent-soft/80 text-sm font-medium text-accent-fg backdrop-blur-[1px]`,children:J.chat.dropFiles}):null,oe?(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-edge-subtle bg-accent-soft/40 px-4 py-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:J.chat.userMessageEditing}),(0,Z.jsx)(`button`,{type:`button`,className:`font-medium text-accent-fg hover:underline`,onClick:q,children:J.chat.userMessageEditCancel})]}):null,pt&&(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge-subtle px-4 py-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:J.chat.editQueueResumed}),(0,Z.jsx)(`button`,{type:`button`,disabled:r||i,className:`text-accent-fg disabled:opacity-40`,onClick:()=>K?.({text:Be.valueRef.current,attachments:Pe.wireAttachmentsPayload(),contextRefs:Fe.current}),children:J.chat.editPauseAgain})]}),ce?.paused&&(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge-subtle px-4 py-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:ce.phase===`stopping`?J.chat.inputStopping:ce.reviewRequired?J.chat.queueReviewRequired:J.chat.queuePaused}),(0,Z.jsx)(`button`,{type:`button`,disabled:r||i||!!(E||oe)||ce.phase!==`idle`,className:`text-accent-fg disabled:opacity-40`,onClick:le,children:J.chat.queueResume})]}),(0,Z.jsx)(oT,{conversationId:s}),T.length>0?(0,Z.jsx)(`div`,{className:`max-h-[min(30vh,11rem)] shrink-0 overflow-y-auto overflow-x-hidden border-b border-edge-subtle/80 [scrollbar-gutter:stable] dark:border-edge-subtle/70`,children:(0,Z.jsx)(aT,{items:T,disabled:r||i||!!(oe||E),editingFollowUpId:E,onEditInComposer:_t,onRemove:A,onMove:j,onReorder:M,onSteer:N,onSendSingle:P,queuePaused:ce?.paused,queueIdle:ce?.phase===`idle`,steeringBusyId:F,onOpenSideChat:s&&s!==`new`?gt:void 0})}):null,(E||oe)&&(0,Z.jsx)(`div`,{className:`flex items-center justify-end px-4 py-1 text-xs`,children:(0,Z.jsx)(`button`,{type:`button`,disabled:i,className:`text-accent-fg disabled:opacity-40`,onClick:()=>ue?.({kind:`compose`,draft:{text:Be.valueRef.current,attachments:Pe.wireAttachmentsPayload(),contextRefs:Fe.current}}),children:J.chat.editAsNewMessage})}),dt.kind===`editFollowUp`&&T.some(e=>e.id===dt.inputId&&e.version!==dt.version)&&(0,Z.jsxs)(`div`,{className:`border-b border-edge-subtle px-4 py-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`p`,{children:J.chat.followUpEditConflict}),(0,Z.jsx)(`p`,{className:`my-1 max-h-20 overflow-auto whitespace-pre-wrap`,children:T.find(e=>e.id===dt.inputId)?.text}),(0,Z.jsx)(`button`,{type:`button`,disabled:i,className:`text-accent-fg`,onClick:()=>D(dt.inputId),children:J.chat.followUpKeepMyEdit})]}),E?(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-4 py-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:J.chat.inputPlaceholderSteeringEdit}),(0,Z.jsx)(`button`,{type:`button`,onClick:O,className:`shrink-0 rounded px-1 text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:J.chat.userMessageEditCancel})]}):null,(0,Z.jsx)(Yr,{attachments:Pe.attachments,conversationId:s,topPadded:T.length>0,onRemove:Pe.removeAttachment}),(0,Z.jsx)(sT,{refs:d.filter(e=>!e.refId),label:J.chat.commandPalette.contextLabel,onRemove:e=>f(t=>t.filter(t=>t.sourceId!==e))}),u,(0,Z.jsxs)(`div`,{className:e?`flex min-h-0 shrink-0 items-end gap-1 px-1.5 py-1.5 sm:px-2`:`flex min-h-0 shrink-0 flex-col`,children:[(0,Z.jsx)(`input`,{ref:ye,type:`file`,multiple:!0,className:`hidden`,onChange:async e=>{let t=e.target.files;t&&await Pe.processFiles(Array.from(t)),e.target.value=``}}),e&&!Ze.voiceActive&&(0,Z.jsx)(hT,{disabled:r||i,attachmentCount:Pe.attachments.length,maxAttachments:10,chat:J.chat,onPickFiles:()=>ye.current?.click()}),(0,Z.jsxs)(`div`,{className:e?`relative min-w-0 flex-1 px-1`:Y(`relative px-3 pb-0 pt-1 sm:px-4`,Pe.attachments.length>0&&`pt-2`),children:[(0,Z.jsx)(wT,{open:Xe.atPicker.open,anchorRef:Be.editorRef,items:Xe.atPicker.items,selectedIndex:Xe.atPicker.selectedIndex,loading:Xe.atPicker.loading,query:Xe.atPicker.query,noResults:Xe.atPicker.error??J.chat.atMention.noResults,conversationId:s,recentLabel:J.chat.atMention.recentBadge,sectionLabels:{file:J.chat.atMention.files,note:J.chat.atMention.notes,session:J.chat.atMention.chats,skill:J.chat.atMention.skills,agent:J.chat.atMention.agents,browser_tab:J.chat.atMention.browserTabs},ariaLabel:J.chat.atMention.placeholder,onSelectItem:Xe.applyAtMention}),(0,Z.jsx)(tE,{open:Xe.palette.open,anchorRef:Be.editorRef,panelRef:ve,sections:Xe.palette.loadError?[]:Xe.palette.sections,flatItems:Xe.palette.loadError?[]:Xe.palette.flatItems,loading:Xe.palette.loading,failedKinds:Xe.palette.failedKinds,selectedIndex:Xe.palette.selectedIndex,noResults:Xe.palette.loadError??J.chat.commandPalette.noResults,sectionLoadFailedLabel:J.chat.commandPalette.sectionLoadFailed,query:Xe.palette.query,skillsLabel:J.chat.commandPalette.skillsSection,commandsLabel:J.chat.commandPalette.commandsSection,agentsLabel:J.chat.commandPalette.agentsSection,currentAgentId:W,currentBadgeLabel:J.chat.commandPalette.currentBadge,runBusy:qe,pendingFollowUpsCount:T.length,maxPendingFollowUps:10,queueBadgeLabel:J.chat.commandPalette.queueBadge,queueFullBadgeLabel:J.chat.commandPalette.queueFullBadge,queueFullTooltip:J.chat.commandPalette.queueFullTooltip,skillUnavailableLabel:J.chat.commandPalette.skillUnavailableBadge,skillAgentDeniedLabel:J.chat.commandPalette.skillAgentDeniedBadge,skillSourceLabels:{builtin:J.chat.commandPalette.sourceBuiltin,workspace:J.chat.commandPalette.sourceWorkspace,global:J.chat.commandPalette.sourceGlobal,extra:J.chat.commandPalette.sourceExtra},onSelectItem:Xe.applyPalette}),Ze.voiceActive?(0,Z.jsx)(Mi,{phase:Ze.phase,elapsedLabel:Ze.elapsedLabel,recordedDictation:Ze.recordedDictation,audioLevel:Ze.audioLevel,partialTranscript:Ze.partialTranscript,finalTranscript:Ze.finalTranscript,error:Ze.error,settingsRequired:Ze.settingsRequired,disabled:r,chat:J.chat,onCancel:Ze.cancelVoiceInput,onConfirm:Ze.confirmVoiceInput,onRetry:Ze.retryVoiceInput}):null,(0,Z.jsx)(Zp,{editorRef:Be.editorRef,disabled:r,hidden:Ze.voiceActive&&Ze.phase!==`error`,compact:e,ariaLabel:t??J.chat.inputPlaceholder,placeholder:(it&&at.suggestion?`${at.suggestion.prompt}${Ct?` · ${J.chat.welcomeSpotlight.acceptSuggestionHint}`:``}`:null)??t??wt??(yt?E?J.chat.inputPlaceholderSteeringEdit:e?J.chat.inputPlaceholderPersonal:J.chat.inputPlaceholderSteering:J.chat.inputPlaceholder),onWireInput:Ge,adjustHeight:Be.adjustHeight,processFiles:Pe.processFiles,processPastedText:Pe.processPastedText,setIsComposing:Be.setIsComposing,kbdRef:vt,chatMessages:J.chat})]}),e?(0,Z.jsx)(gT,{disabled:r||i||pt,voiceActive:Ze.voiceActive,runBusy:yt,hasDraft:xt,chat:bt,onStartVoiceInput:Ze.startVoiceInput,onSend:mt.send,onAbort:S}):(0,Z.jsx)(im,{disabled:r,sendDisabled:i||pt,sending:a,streaming:o,runBusy:yt,chat:bt,hasDraft:xt,showSteeringInterrupt:St,attachmentCount:Pe.attachments.length,maxAttachments:10,onPickFiles:()=>ye.current?.click(),thinkingLevel:g,onThinkingChange:v,voiceActive:Ze.voiceActive,onStartVoiceInput:Ze.startVoiceInput,voiceConversationEnabled:!!(s||ne),onStartVoiceConversation:()=>{if(!fe.current){if(s){de.open({conversationId:s,name:G||W||`xopc`,taskId:ee,mode:te});return}ne&&(fe.current=!0,ne().then(e=>{if(e)return de.open({conversationId:e,name:G||W||`xopc`,taskId:ee,mode:te})}).catch(e=>ya(`error`,e instanceof Error?e.message:J.chat.callFailed)).finally(()=>{fe.current=!1}))}},onSend:mt.send,onAbort:S,onInterrupt:mt.interruptDraft,sessionModel:z,showModelSelector:B,onModelChange:V,modelDisabled:H})]}),(0,Z.jsx)(nD,{open:Se,conversationId:s,disabled:r||yt,chat:J.chat,onClose:()=>Ce(!1),onSendCommand:Ye}),(0,Z.jsx)(La,{open:we!==null,title:J.chat.commandPalette.workspaceTrustTitle,description:em(J.chat.commandPalette.workspaceTrustDescription,{path:we?.workspacePath??``}),confirmLabel:Oe?J.chat.commandPalette.workspaceTrustSaving:J.chat.commandPalette.workspaceTrustConfirm,cancelLabel:J.chat.commandPalette.workspaceTrustCancel,onConfirm:Ne,onCancel:()=>{Te(null),De(s)}})]})]})});function oD(e){let t=(0,X.c)(42),{draft:n,onRemove:r,disabled:i,waiting:a}=e,o=i!==void 0&&i,s=a!==void 0&&a,c=h(cD),l;t[0]===c?l=t[1]:(l=y(c),t[0]=c,t[1]=l);let u=l.chat.pageContext,d=u.label,f;t[2]!==n.title||t[3]!==u.preview?(f=(0,Z.jsxs)(`summary`,{className:`cursor-pointer break-words rounded text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[u.preview,`: `,n.title]}),t[2]=n.title,t[3]=u.preview,t[4]=f):f=t[4];let p;t[5]===u.frozen?p=t[6]:(p=(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:u.frozen}),t[5]=u.frozen,t[6]=p);let m;t[7]===n.envelope.resourceRefs?m=t[8]:(m=n.envelope.resourceRefs.map(sD).join(`, `),t[7]=n.envelope.resourceRefs,t[8]=m);let g;t[9]===m?g=t[10]:(g=(0,Z.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:m}),t[9]=m,t[10]=g);let _;t[11]===n.preview?_=t[12]:(_=(0,Z.jsx)(`pre`,{className:`mt-2 max-h-48 overflow-y-auto whitespace-pre-wrap break-words font-sans text-sm text-fg`,children:n.preview}),t[11]=n.preview,t[12]=_);let v;t[13]!==n.truncated||t[14]!==u.truncated?(v=n.truncated?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:u.truncated}):null,t[13]=n.truncated,t[14]=u.truncated,t[15]=v):v=t[15];let b;t[16]!==n.envelope.selection||t[17]!==u.draft||t[18]!==u.selection?(b=n.envelope.selection?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`mt-2 text-xs font-medium text-fg`,children:n.envelope.selection.draft?u.draft:u.selection}),(0,Z.jsx)(`pre`,{className:`mt-1 max-h-36 overflow-y-auto whitespace-pre-wrap break-words font-sans text-sm text-fg`,children:n.envelope.selection.text})]}):null,t[16]=n.envelope.selection,t[17]=u.draft,t[18]=u.selection,t[19]=b):b=t[19];let x;t[20]!==v||t[21]!==b||t[22]!==f||t[23]!==p||t[24]!==g||t[25]!==_?(x=(0,Z.jsxs)(`details`,{className:`min-w-0 flex-1`,children:[f,p,g,_,v,b]}),t[20]=v,t[21]=b,t[22]=f,t[23]=p,t[24]=g,t[25]=_,t[26]=x):x=t[26];let S=`${u.remove}: ${n.title}`,C;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Z.jsx)(Gt,{className:`size-4`,"aria-hidden":!0}),t[27]=C):C=t[27];let w;t[28]!==o||t[29]!==r||t[30]!==S?(w=(0,Z.jsx)(`button`,{type:`button`,onClick:r,disabled:o,"aria-label":S,className:`inline-flex size-8 shrink-0 items-center justify-center rounded text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:C}),t[28]=o,t[29]=r,t[30]=S,t[31]=w):w=t[31];let T;t[32]!==x||t[33]!==w?(T=(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[x,w]}),t[32]=x,t[33]=w,t[34]=T):T=t[34];let E;t[35]!==u.pending||t[36]!==s?(E=s?(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,role:`status`,children:u.pending}):null,t[35]=u.pending,t[36]=s,t[37]=E):E=t[37];let D;return t[38]!==u.label||t[39]!==T||t[40]!==E?(D=(0,Z.jsxs)(`section`,{className:`mx-4 mt-2 min-w-0 rounded-lg border border-edge bg-surface-hover p-3`,"aria-label":d,children:[T,E]}),t[38]=u.label,t[39]=T,t[40]=E,t[41]=D):D=t[41],D}function sD(e){return`${e.kind} · ${e.id} · v${e.revision}`}function cD(e){return e.language}function lD(e){let t=(0,X.c)(30),{selection:n}=e,r=h(uD)===`zh`,{mode:i,options:a,checking:o,checkFailed:s,failure:c,busy:l,changeMode:u,retry:d}=n,f=s?r?`无法检查运行环境,请重试。`:`Could not check the environment. Retry.`:a?.worktreeUnavailableReason===`workspace_unavailable`?r?`项目目录不可用,请在项目设置中检查路径。`:`Project directory unavailable. Check its path in project settings.`:null;if(!s&&a?.worktreeUnavailableReason===`git_commit_required`){let e;return t[0]===c?e=t[1]:(e=c?(0,Z.jsx)(`p`,{role:`alert`,className:`w-full px-2 py-1 text-xs text-danger`,children:c}):null,t[0]=c,t[1]=e),e}let p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(We,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[2]=p):p=t[2];let m=p,g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsx)(Ss,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[3]=g):g=t[3];let _=g,v=r?`运行位置`:`Work in`,y;t[4]!==l||t[5]!==u||t[6]!==s||t[7]!==v||t[8]!==i||t[9]!==a||t[10]!==r?(y=!a&&!s?(0,Z.jsx)(qt,{className:`h-8 w-36 rounded-full`}):(0,Z.jsx)(ue,{ariaLabel:r?`新会话运行位置`:`New session environment`,placeholder:v,title:r?`Local 指 xopc Gateway 所在机器;首次发送时创建所选环境。`:`Local means the machine running xopc Gateway. The selected environment is created on first send.`,triggerIcon:l?(0,Z.jsx)(Je,{className:`size-4 shrink-0 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}):i===`managed_worktree`?_:m,triggerClassName:`h-8 w-auto max-w-full justify-start gap-1.5 rounded-full border-0 bg-surface-hover px-2.5 hover:bg-surface-active [&>svg:last-child]:hidden`,contentClassName:`xopc-composer-config-popover w-max min-w-0 max-w-[calc(100vw-1.5rem)]`,side:`top`,allowEmpty:!1,value:i,disabled:l||s,options:[{value:`local_checkout`,label:`Local`,icon:m,group:v,disabled:!a?.localAvailable},{value:`managed_worktree`,label:`New local worktree`,icon:_,group:v,disabled:!a||!!a.worktreeUnavailableReason}],onChange:e=>u(e)}),t[4]=l,t[5]=u,t[6]=s,t[7]=v,t[8]=i,t[9]=a,t[10]=r,t[11]=y):y=t[11];let b;t[12]!==l||t[13]!==o||t[14]!==c||t[15]!==i||t[16]!==a?.worktreeUnavailableReason||t[17]!==f||t[18]!==d||t[19]!==r?(b=f||c||i===`managed_worktree`&&a?.worktreeUnavailableReason?(0,Z.jsx)(pi,{variant:`ghost`,className:`size-8 rounded-full p-0`,disabled:l||o,onClick:d,"aria-label":r?`重新检查环境`:`Recheck environment`,children:(0,Z.jsx)(At,{className:`size-3.5 `+(o?`animate-spin motion-reduce:animate-none`:``),"aria-hidden":!0})}):null,t[12]=l,t[13]=o,t[14]=c,t[15]=i,t[16]=a?.worktreeUnavailableReason,t[17]=f,t[18]=d,t[19]=r,t[20]=b):b=t[20];let x;t[21]===f?x=t[22]:(x=f?(0,Z.jsx)(`p`,{role:`status`,className:`w-full px-2 py-1 text-xs leading-5 text-fg-muted`,children:f}):null,t[21]=f,t[22]=x);let S;t[23]===c?S=t[24]:(S=c?(0,Z.jsx)(`p`,{role:`alert`,className:`max-h-20 w-full overflow-y-auto break-words px-2 py-1 text-xs leading-5 text-danger`,children:c}):null,t[23]=c,t[24]=S);let C;return t[25]!==y||t[26]!==b||t[27]!==x||t[28]!==S?(C=(0,Z.jsxs)(Z.Fragment,{children:[y,b,x,S]}),t[25]=y,t[26]=b,t[27]=x,t[28]=S,t[29]=C):C=t[29],C}function uD(e){return e.language}function dD({preparation:e,conversationId:t,ready:n,onSend:r}){let i=m(e=>e.conversationId),a=m(e=>e.baseUrl),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(null),f=(0,Q.useRef)(null),h=(0,Q.useRef)(!1),_=(0,Q.useRef)(r);_.current=r;let v=(0,Q.useRef)(t);v.current=t;let{data:y,error:b,isValidating:x,mutate:S}=Gr(e?[`project-environment-options`,a,i,e.project.id]:null,async()=>(await g(p(`/api/projects/${encodeURIComponent(e.project.id)}/environment-options`))).options,{keepPreviousData:!1,revalidateOnFocus:!1,shouldRetryOnError:!1}),C=y?.localAvailable&&y.worktreeUnavailableReason!==`git_commit_required`&&y.worktreeUnavailableReason!==`workspace_unavailable`?o?.preparation===e?o.mode:e?zr(Hr(),e.project.id)??`local_checkout`:`local_checkout`:`local_checkout`,w=!!(!b&&y?.localAvailable&&(C===`local_checkout`||!y.worktreeUnavailableReason)),T=(0,Q.useCallback)(e=>{let t=f.current;f.current=null,d(null),t?.resolve(e?t.conversationId:null)},[]),E=(0,Q.useCallback)(()=>{let e=f.current,t=m.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;Ir(e.project.id,C);let n={...s,conversationId:t};f.current=n,d(n)}).catch(t=>{f.current===s&&(l({preparation:e,message:t instanceof Error?t.message:String(t)}),S(),T(!1))}),o},[w,a,T,x,C,S,e,t,i]);return{mode:C,options:y,checking:x,checkFailed:!!b,allowed:w,busy:!!(u&&(u.preparation===e||u.conversationId&&u.conversationId===t)),failure:c?.preparation===e?c.message:null,changeMode:t=>{!e||f.current||(s({preparation:e,mode:t}),l(null))},retry:()=>void S(),getDraftHandoffTarget:E,prepareSession:D,send:async(...n)=>{let r=t;if(e){if(h.current)return!1;h.current=!0;try{let e=await D();if(!e)return!1;r=e,n[2]=void 0}finally{h.current=!1}}return!r||v.current!==r?!1:await _.current(...n)!==!1&&{conversationId:r}}}}function fD(e,t){let n=(0,X.c)(12),r=m(mD),i=m(pD),a;n[0]===e?a=n[1]:(a=t=>e?t.sessions[e]?.localDraft:void 0,n[0]=e,n[1]=a);let o=Nn(a),s;n[2]!==i||n[3]!==e||n[4]!==t||n[5]!==o||n[6]!==r?(s=e||t?[`chat-project-scope`,i,r,e,t,o===!0?`draft`:o===!1?`persisted`:`unknown`]:null,n[2]=i,n[3]=e,n[4]=t,n[5]=o,n[6]=r,n[7]=s):s=n[7];let c;n[8]!==e||n[9]!==t?(c=async()=>{let n=e?await wr(e):void 0,r=n?n.creation.projectId:e?(await un(e)).projectId:t;return r?sn(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}=Gr(s,c,l);return d?null:u??null}function pD(e){return e.baseUrl}function mD(e){return e.conversationId}function hD(e,t){let n=qo(e,t),r=Jo(e,t);return`${e.id} ${n} ${r}`.toLowerCase()}function gD(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=hD(e,n);return i.every(e=>t.includes(e))})}function _D(e){let t=(0,X.c)(57),{items:n,value:r,disabled:i,placeholder:a,searchPlaceholder:o,noMatches:s,compact:c,contentSide:l,contentAlign:u,className:d,onChange:f}=e,p=l===void 0?`bottom`:l,m=u===void 0?`end`:u,g=h(yD),_;t[0]===g?_=t[1]:(_=y(g),t[0]=g,t[1]=_);let v=_.agentsSettings,[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(``),w;t[2]!==v||t[3]!==n||t[4]!==S?(w=gD(n,S,v),t[2]=v,t[3]=n,t[4]=S,t[5]=w):w=t[5];let T=w,E,D,O;if(t[6]!==v||t[7]!==n||t[8]!==a||t[9]!==r){let e;t[13]===r?e=t[14]:(e=e=>e.id===r,t[13]=r,t[14]=e),D=n.find(e),E=D?qo(D,v):r||a,O=D?[qo(D,v),Jo(D,v)].filter(Boolean).join(` — `):void 0,t[6]=v,t[7]=n,t[8]=a,t[9]=r,t[10]=E,t[11]=D,t[12]=O}else E=t[10],D=t[11],O=t[12];let k=O??a,A=c&&`min-w-0 max-w-[min(calc(15ch+3rem),calc(100vw-8rem))] py-1.5 text-[13px]`,j;t[15]!==d||t[16]!==A?(j=Y(Ca,`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`,ca.transition,`hover:border-edge hover:bg-surface-hover/45`,wa,Sa,`disabled:cursor-not-allowed disabled:opacity-50`,`dark:border-edge-subtle dark:hover:bg-surface-hover/55`,A,d),t[15]=d,t[16]=A,t[17]=j):j=t[17];let M;t[18]!==D?.avatar||t[19]!==r?(M=r?(0,Z.jsx)(Aa,{agentId:r,avatar:D?.avatar,size:28,className:`shrink-0`}):null,t[18]=D?.avatar,t[19]=r,t[20]=M):M=t[20];let N=c?`max-w-[15ch] shrink`:`flex-1`,P;t[21]===N?P=t[22]:(P=Y(`min-w-0 truncate text-left`,N),t[21]=N,t[22]=P);let F;t[23]!==E||t[24]!==P?(F=(0,Z.jsx)(`span`,{className:P,children:E}),t[23]=E,t[24]=P,t[25]=F):F=t[25];let I;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(oe,{className:`size-4 shrink-0 text-fg-subtle opacity-70`,"aria-hidden":!0}),t[26]=I):I=t[26];let L;t[27]!==i||t[28]!==F||t[29]!==k||t[30]!==j||t[31]!==M?(L=(0,Z.jsx)(yi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,disabled:i,title:k,className:j,children:[M,F,I]})}),t[27]=i,t[28]=F,t[29]=k,t[30]=j,t[31]=M,t[32]=L):L=t[32];let R;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(R=Y(ae,`z-50 w-[var(--radix-popover-trigger-width)] min-w-[12rem] rounded-lg border border-edge bg-surface-overlay shadow-md`,ca),t[33]=R):R=t[33];let z;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>C(e.target.value),t[34]=z):z=t[34];let B;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(B=Y(`w-full rounded-md border border-edge bg-surface-panel px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-muted`,wa),t[35]=B):B=t[35];let V;t[36]!==S||t[37]!==o?(V=(0,Z.jsx)(`div`,{className:`shrink-0 border-b border-edge p-2`,children:(0,Z.jsx)(`input`,{type:`search`,value:S,onChange:z,placeholder:o,className:B,"aria-label":o})}),t[36]=S,t[37]=o,t[38]=V):V=t[38];let H;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(H=Y(ce,`max-h-64 p-1`),t[39]=H):H=t[39];let U;t[40]!==v||t[41]!==T||t[42]!==s||t[43]!==f||t[44]!==r?(U=T.length===0?(0,Z.jsx)(`li`,{className:`p-2 text-sm text-fg-muted`,children:s}):T.map(e=>{let t=e.id===r,n=qo(e,v),i=Jo(e,v),a=i.length>0?i:void 0;return(0,Z.jsx)(`li`,{role:`option`,"aria-selected":t,children:(0,Z.jsxs)(`button`,{type:`button`,className:Y(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-fg`,t?`bg-surface-hover`:`hover:bg-surface-hover`),onClick:()=>{f(e.id),x(!1),C(``)},children:[(0,Z.jsx)(Aa,{agentId:e.id,avatar:e.avatar,size:32,className:`shrink-0`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`block truncate font-medium leading-tight`,title:n,children:n}),i?(0,Z.jsx)(`span`,{className:`mt-0.5 block truncate text-xs leading-tight text-fg-muted`,title:a,children:i}):null]}),(0,Z.jsx)(G,{className:Y(`size-4 shrink-0`,t?`opacity-100`:`opacity-0`),"aria-hidden":!0})]})},e.id)}),t[40]=v,t[41]=T,t[42]=s,t[43]=f,t[44]=r,t[45]=U):U=t[45];let W;t[46]===U?W=t[47]:(W=(0,Z.jsx)(`ul`,{"data-select-scroll-region":!0,className:H,role:`listbox`,children:U}),t[46]=U,t[47]=W);let ee;t[48]!==m||t[49]!==p||t[50]!==V||t[51]!==W?(ee=(0,Z.jsx)(hi,{children:(0,Z.jsxs)(gi,{side:p,align:m,sideOffset:4,collisionPadding:8,className:R,onOpenAutoFocus:vD,children:[V,W]})}),t[48]=m,t[49]=p,t[50]=V,t[51]=W,t[52]=ee):ee=t[52];let te;return t[53]!==b||t[54]!==L||t[55]!==ee?(te=(0,Z.jsxs)(_i,{open:b,onOpenChange:x,children:[L,ee]}),t[53]=b,t[54]=L,t[55]=ee,t[56]=te):te=t[56],te}function vD(e){return e.preventDefault()}function yD(e){return e.language}function bD(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 xD(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 SD=`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`,CD=`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 wD({conversationId:e,draftRefs:t=[],draftAttachments:n=[],draftPage:r,project:i,...a}){let[o,s]=(0,Q.useState)(!1),[l,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),[m,g]=(0,Q.useState)(!1),_=xD(h(e=>e.language)),v=c(),y=`${v.pathname}${v.search}`,{data:b,error:x,isLoading:S,isValidating:C,mutate:w}=mf(e,o),T=x?void 0:b,E=T?.work.project??(!e&&i?{id:i.id,title:i.name}:void 0),D=T?.work.task,O=T?.work.delegatedTasks??[],A=bD(T?.sources??[],t,n,r),j=T?.environment,M=!!(E||D||O.length),N=!!T?.unavailableSections.includes(`work`),P=!!T?.unavailableSections.includes(`sources`),F=!!T?.unavailableSections.includes(`environment`),I=[E?.title,D?.title,A.length?`${_.sources} ${A.length}${T?.sourcesHasMore?`+`:``}`:null,j?.kind===`managed_worktree`?`Worktree`:null].filter(Boolean).join(` · `)||_.title,L=()=>s(!1),R=A.some(e=>e.kind===`note`&&!e.unavailable&&e.origins.some(e=>e.kind===`session`)),z=()=>{j?.rootPath&&Ci(j.rootPath).then(e=>{e&&(g(!0),window.setTimeout(()=>g(!1),1200))})},B=()=>(0,Z.jsx)(`button`,{type:`button`,className:CD,"aria-label":_.refresh,disabled:C,onClick:()=>void w(),children:(0,Z.jsx)(At,{className:`size-3.5 ${C?`animate-spin motion-reduce:animate-none`:``}`,"aria-hidden":!0})});return(0,Z.jsxs)(_i,{open:o,onOpenChange:s,children:[(0,Z.jsx)(yi,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,"aria-label":_.title,title:I,className:`group inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-[background-color,color,transform] duration-150 hover:bg-surface-hover hover:text-fg active:scale-95 data-[state=open]:bg-surface-hover data-[state=open]:text-fg motion-reduce:transition-none motion-reduce:transform-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,Z.jsx)(qe,{className:`size-4 transition-transform duration-200 group-data-[state=open]:scale-110 motion-reduce:transform-none motion-reduce:transition-none`,strokeWidth:1.75,"aria-hidden":!0})})}),(0,Z.jsx)(hi,{children:(0,Z.jsx)(gi,{align:`end`,sideOffset:8,collisionPadding:12,"aria-label":_.title,onCloseAutoFocus:e=>{document.activeElement?.closest(`[data-primary-chat-composer]`)&&e.preventDefault()},className:`xopc-session-context-popover z-50 w-[min(23rem,calc(100vw-1.5rem))] rounded-xl border border-edge bg-surface-overlay shadow-popover`,children:(0,Z.jsxs)(`div`,{className:`max-h-[min(30rem,var(--radix-popover-content-available-height))] overflow-y-auto rounded-xl p-3`,children:[(0,Z.jsx)(`h2`,{className:`mb-2 px-2 text-sm font-medium text-fg`,children:_.title}),S?(0,Z.jsx)(`div`,{className:`space-y-2 px-2`,"aria-busy":`true`,children:[0,1,2].map(e=>(0,Z.jsx)(qt,{className:`h-8 w-full`},e))}):x?(0,Z.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-2 text-sm text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:_.unavailable}),B()]}):(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`section`,{"aria-label":_.work,children:[E?(0,Z.jsxs)(u,{className:SD,to:Qe(y,`/projects/${encodeURIComponent(E.id)}`),onClick:L,children:[(0,Z.jsx)(Ee,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:E.title,children:E.title})]}):null,D?(0,Z.jsxs)(u,{className:SD,to:$e(y,D.id),onClick:L,children:[(0,Z.jsx)(ws,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:D.title,children:D.title}),(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:D.phase})]}):null,O.length?(0,Z.jsxs)(Z.Fragment,{children:[O.length>2?(0,Z.jsxs)(`button`,{type:`button`,className:`${SD} w-full text-left`,onClick:()=>d(!l),"aria-expanded":l,children:[(0,Z.jsx)(ws,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,Z.jsxs)(`span`,{className:`flex-1`,children:[_.delegatedTasks,` · `,T?.work.delegatedTaskCount??O.length]}),(0,Z.jsx)(`span`,{className:`text-xs text-fg-muted`,children:l?_.collapse:_.expand})]}):(0,Z.jsxs)(`p`,{className:`px-2 pt-2 text-xs text-fg-subtle`,children:[_.delegatedTasks,` · `,T?.work.delegatedTaskCount??O.length]}),(l?O:O.slice(0,2)).map(e=>(0,Z.jsxs)(u,{className:`${SD} pl-9`,to:$e(y,e.id),onClick:L,children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.title,children:e.title}),(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:e.runStatus??e.phase})]},e.id))]}):null,M?null:(0,Z.jsx)(`p`,{className:`px-2 py-2 text-sm text-fg-muted`,children:N?_.unavailable:_.independent}),N?(0,Z.jsxs)(`div`,{className:`flex items-center justify-between px-2 text-xs text-fg-muted`,children:[M?_.partialUnavailable:null,B()]}):null,E&&a.onLeaveProject?(0,Z.jsx)(`button`,{type:`button`,className:CD,onClick:()=>{L(),a.onLeaveProject?.()},children:a.leaveProjectLabel}):null]}),A.length||P?(0,Z.jsxs)(`section`,{className:`border-t border-edge-subtle pt-3`,children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex items-center justify-between px-2`,children:[(0,Z.jsxs)(`h3`,{className:`text-sm text-fg-subtle`,children:[_.sources,` `,A.length?`${A.length}${T?.sourcesHasMore?`+`:``}`:``]}),P?B():null]}),(f?A:A.slice(0,3)).map(e=>{let t=e.origins.some(e=>e.kind===`session`)?_.session:e.origins.some(e=>e.kind===`task`)?_.task:e.origins.some(e=>e.kind===`recent`)?_.recent:_.draft,n=e.pending&&e.origins.length?`${t} · ${_.draft}`:e.pending?_.draft:t,r=e.kind===`file`&&e.fileKind===`directory`?Oe:e.kind===`file`?Te:e.kind===`session`?bt:e.kind===`browser_tab`||e.kind===`browser_page`||e.kind===`app_context`?k:e.kind===`mcp_resource`?ye:e.kind===`attachment`?Tt:Te,i=e.unavailable?_.unavailable:e.title||(e.kind===`note`?_.untitled:_.untitledSource),a=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(r,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.unavailable?void 0:e.title,children:i}),(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:n})]}),o=e.kind===`note`?tt(y,e.id):e.kind===`session`?`/chat/${encodeURIComponent(e.id)}`:null,s=`${e.kind}:${e.id}`;return!e.unavailable&&o?(0,Z.jsx)(u,{className:SD,to:o,onClick:L,children:a},s):(0,Z.jsx)(`div`,{className:`flex min-w-0 items-center gap-3 px-2 py-2 text-sm text-fg-muted`,children:a},s)}),A.length?null:(0,Z.jsx)(`p`,{className:`px-2 py-2 text-xs text-fg-muted`,children:_.unavailable}),A.length>0&&P?(0,Z.jsx)(`p`,{className:`px-2 py-1 text-xs text-fg-muted`,children:_.partialUnavailable}):null,A.length>3?(0,Z.jsx)(`button`,{type:`button`,className:CD,onClick:()=>p(!f),"aria-expanded":f,children:f?_.collapse:_.expand}):null,T?.sourcesHasMore?(0,Z.jsx)(`p`,{className:`px-2 py-1 text-xs text-fg-muted`,children:_.more}):null,R&&a.onDraftSourceNote?(0,Z.jsx)(`button`,{type:`button`,className:CD,onClick:()=>{L(),a.onDraftSourceNote?.()},children:a.draftSourceNoteLabel}):null]}):null,e&&(j||F)||a.environmentAction?(0,Z.jsxs)(`section`,{className:`border-t border-edge-subtle pt-3`,children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex items-center justify-between px-2`,children:[(0,Z.jsx)(`h3`,{className:`text-sm text-fg-subtle`,children:_.environment}),F?B():null]}),j?null:a.environmentAction,j?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 px-2 py-2 text-sm text-fg`,children:[(0,Z.jsx)(St,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:j.kind===`managed_worktree`?_.worktree:_.local}),j.branch||j.headSha?(0,Z.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-40 items-center gap-1 text-xs text-fg-muted`,children:[(0,Z.jsx)(Me,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate`,children:j.branch||(j.detached?`${_.detached} · ${j.headSha?.slice(0,8)}`:j.headSha?.slice(0,8))})]}):null]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 pl-9 pr-1`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,title:j.rootPath,children:j.rootPath}),(0,Z.jsx)(`button`,{type:`button`,className:CD,"aria-label":m?_.copied:_.copyEnvironmentPath,title:m?_.copied:_.copyEnvironmentPath,onClick:z,children:m?(0,Z.jsx)(G,{className:`size-3.5`,"aria-hidden":!0}):(0,Z.jsx)(ve,{className:`size-3.5`,"aria-hidden":!0})})]}),a.environmentAction,j.available?null:(0,Z.jsx)(`p`,{className:`px-2 py-1 text-xs text-fg-muted`,children:_.unavailableEnvironment}),E&&i?.workspaceRoot?(0,Z.jsx)(fe,{className:CD,to:Xr(E.id),state:{forceNewChat:!0,agentId:a.agentId,temporary:a.temporary},onClick:L,children:_.newEnvironment}):null]}):(0,Z.jsx)(`p`,{className:`px-2 py-2 text-xs text-fg-muted`,children:_.unavailable})]}):null]}),a.executionDeviceAction]})})})]})}var TD=`min(36dvh, 320px)`;function ED(e){return e&&Number.isFinite(e.width)&&Number.isFinite(e.height)&&e.width>0&&e.height>0?e.width/e.height:void 0}function DD(e){let t=ED(e);return t?`min(calc(100vw - 2rem), ${36*t}dvh, ${Math.min(480,320*t)}px)`:`min(320px, calc(100vw - 2rem))`}function OD(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 kD(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 AD({conversationId:e,onFrameSizeChange:t}){let n=kD(e),[r,i]=(0,Q.useState)(!0),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),l=(0,Q.useRef)(null),u=h(e=>e.language===`zh`),d=n.state?.previewId;if((0,Q.useEffect)(()=>{n.frameSize&&t?.(n.frameSize)},[n.frameSize,t]),(0,Q.useEffect)(()=>{c(!1)},[d]),(0,Q.useEffect)(()=>{if(!l.current||typeof IntersectionObserver>`u`)return;let e=new IntersectionObserver(e=>i(e.some(e=>e.isIntersecting)),{rootMargin:`160px`});return e.observe(l.current),()=>e.disconnect()},[d]),(0,Q.useEffect)(()=>{!n.subscriptionId||!n.api||n.api.setPreset(n.subscriptionId,n.visible&&r?`compact`:`paused`).catch(()=>{})},[n.api,n.subscriptionId,n.visible,r]),!n.state||n.state.conversationId!==e||n.state.status===`ended`)return null;let f=n.state.status===`unavailable`,p=s?u?`重试切换`:`Retry switch`:n.stale?u?`等待新画面`:`Waiting for a new frame`:OD(n.state.activity,u),m=async()=>{let t=window.electronAPI?.computer;if(!(!t?.focusTarget||!e||!d||a)){o(!0),c(!1);try{await t.focusTarget(e,d)}catch{c(!0)}finally{o(!1)}}};return(0,Z.jsxs)(`section`,{ref:l,"aria-label":u?`电脑操作预览`:`Computer activity`,className:`relative w-full overflow-hidden rounded-xl bg-transparent`,style:{aspectRatio:ED(n.frameSize)??16/10,maxHeight:TD},children:[!n.hasFrame&&!f&&(0,Z.jsx)(qt,{className:`absolute inset-0`}),(0,Z.jsx)(`canvas`,{ref:n.registerCanvas,role:`img`,"aria-label":u?`${n.state.appName}窗口预览`:`${n.state.appName} window preview`,className:`absolute inset-0 h-full w-full object-contain ${n.hasFrame&&!f?``:`invisible`}`}),!f&&(0,Z.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`absolute left-2 top-2 z-10 max-w-[calc(100%-1rem)]`,children:(0,Z.jsxs)(`button`,{type:`button`,disabled:a||!window.electronAPI?.computer?.focusTarget,"aria-label":u?`切换到正在操作的应用`:`Switch to the active app`,title:s?u?`暂时无法切换应用,请重试`:`Could not switch to the app. Try again.`:u?`切换到应用`:`Switch to app`,className:`inline-flex min-h-11 min-w-11 max-w-full sm:min-h-9 sm:min-w-9 items-center justify-center gap-1.5 rounded-md bg-surface-overlay/80 px-2 text-xs text-fg backdrop-blur-sm hover:bg-surface-overlay focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>{m()},children:[(0,Z.jsx)(St,{size:14,className:`shrink-0`,"aria-hidden":!0}),p&&(0,Z.jsx)(`span`,{className:`truncate`,children:p})]})}),f&&(0,Z.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-surface-panel/90`,children:(0,Z.jsx)(`button`,{className:`min-h-11 rounded-md px-3 text-sm text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:n.retry,children:u?`预览暂时不可用,点击重试`:`Preview unavailable. Retry preview`})})]})}function jD(e){let t=(0,X.c)(26),{conversationId:n}=e,{state:r}=kD(n,!1),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(),c=h(ND),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{a(!1),s(void 0)},t[0]=l):l=t[0];let u=r?.previewId,d;if(t[1]!==n||t[2]!==u?(d=[n,u],t[1]=n,t[2]=u,t[3]=d):d=t[3],(0,Q.useEffect)(l,d),!r||r.conversationId!==n||r.status===`ended`)return null;let f=c?`查看电脑预览`:`View computer preview`,p=c?`查看电脑预览`:`View computer preview`,m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(St,{className:`size-4 shrink-0`,"aria-hidden":!0}),t[4]=m):m=t[4];let g=c?`电脑`:`Computer`,_;t[5]===g?_=t[6]:(_=(0,Z.jsx)(`span`,{className:`hidden whitespace-nowrap text-xs xl:inline`,children:g}),t[5]=g,t[6]=_);let v;t[7]!==f||t[8]!==p||t[9]!==_?(v=(0,Z.jsx)(yi,{asChild:!0,children:(0,Z.jsxs)(pi,{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,_]})}),t[7]=f,t[8]=p,t[9]=_,t[10]=v):v=t[10];let y=c?`电脑预览`:`Computer preview`,b;t[11]===o?b=t[12]:(b=DD(o),t[11]=o,t[12]=b);let x;t[13]===b?x=t[14]:(x={"--computer-preview-width":b},t[13]=b,t[14]=x);let S=x,C;t[15]!==n||t[16]!==r.previewId?(C=(0,Z.jsx)(AD,{conversationId:n,onFrameSizeChange:s},r.previewId),t[15]=n,t[16]=r.previewId,t[17]=C):C=t[17];let w;t[18]!==y||t[19]!==S||t[20]!==C?(w=(0,Z.jsx)(hi,{children:(0,Z.jsx)(gi,{align:`end`,sideOffset:8,collisionPadding:16,"aria-label":y,onOpenAutoFocus:MD,style:S,className:`z-40 w-[var(--computer-preview-width)] max-h-[calc(100dvh-5rem)] overflow-hidden rounded-xl bg-transparent p-0 outline-none`,children:C})}),t[18]=y,t[19]=S,t[20]=C,t[21]=w):w=t[21];let T;return t[22]!==i||t[23]!==w||t[24]!==v?(T=(0,Z.jsxs)(_i,{open:i,onOpenChange:a,children:[v,w]}),t[22]=i,t[23]=w,t[24]=v,t[25]=T):T=t[25],T}function MD(e){return e.preventDefault()}function ND(e){return e.language===`zh`}function PD({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),[m,h]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(!1),y=p(`/api/endpoint-tools/artifact-transfers`),{data:O,isLoading:k}=Gr(r?`${y}?conversationId=${encodeURIComponent(e)}`:null,e=>g(e),{shouldRetryOnError:!1}),A=O?.payload.files??[],j=O?.payload.tools??[],M=j.find(e=>e.toolName===s);return(0,Z.jsxs)(D,{open:r,onOpenChange:e=>{i(e),e&&(o(``),c(``),u(``),h(!1),v(!1))},children:[(0,Z.jsx)(x,{asChild:!0,children:(0,Z.jsx)(pi,{variant:`ghost`,className:`h-8 px-2 text-sm`,children:n?`传递文件`:`Transfer file`})}),(0,Z.jsxs)(w,{children:[(0,Z.jsx)(b,{className:`fixed inset-0 z-[120] bg-black/50`}),(0,Z.jsxs)(T,{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,Z.jsx)(E,{className:`text-base font-semibold`,children:n?`向执行设备传递文件`:`Transfer file to execution device`}),(0,Z.jsx)(S,{className:`mt-1 text-sm text-fg-muted`,children:t}),(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto py-3`,children:[k?(0,Z.jsx)(qt,{className:`h-20 w-full`}):A.length&&j.length?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ue,{value:a,onChange:o,placeholder:n?`选择源文件`:`Select source file`,options:A.map(e=>({value:e.fileId,label:`${e.name} · ${e.sourceName} · ${Math.ceil(e.size/1024)} KB`}))}),(0,Z.jsx)(ue,{value:s,onChange:c,placeholder:n?`选择接收能力`:`Select receiving capability`,options:j.map(e=>({value:e.toolName,label:e.title}))})]}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`当前没有可传递的文件或接收能力。`:`No eligible file or receiving capability is available.`}),l?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`在两分钟内将这段请求发到当前对话。`:`Send this request in this chat within two minutes.`}),(0,Z.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,_?(0,Z.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:n?`文件授权失败,请重新选择设备或文件。`:`Unable to authorize transfer. Reselect the device or file.`}):null]}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(C,{asChild:!0,children:(0,Z.jsx)(pi,{variant:`secondary`,children:n?`关闭`:`Close`})}),l?(0,Z.jsx)(pi,{onClick:async()=>{try{await navigator.clipboard.writeText(l),h(!0)}catch{h(!1)}},children:m?n?`已复制`:`Copied`:n?`复制请求`:`Copy request`}):(0,Z.jsx)(pi,{disabled:d||!M||!A.some(e=>e.fileId===a),onClick:async()=>{if(M){f(!0),v(!1);try{let t=await g(y,{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{v(!0)}finally{f(!1)}}},children:d?n?`授权中…`:`Authorizing…`:n?`生成一次性授权`:`Authorize one transfer`})]})]})]})]})}function FD({conversationId:e,disabled:t}){let n=h(e=>e.language)===`zh`,r=e&&/^[0-9a-f-]{36}$/i.test(e)?p(`/api/endpoint-tools/targets/${encodeURIComponent(e)}`):null,i=Gr(r,async e=>{let t=await f(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=Gr(r?ns():null,rs,{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,m=(a.data??[]).find(e=>e.id===d?.principalId),_=m?.endpoints.some(e=>e.endpointId===d?.endpointId&&e.connectionId===d?.connectionId),v=d&&(!_||d.expiresAt<=Date.now()),y=d?`${m?.displayName??(n?`所选设备`:`Selected device`)}${v?n?` · 需要重新选择`:` · Reselect required`:``}`:void 0;return d&&!u.some(e=>e.value===d.endpointId)&&u.push({value:d.endpointId,label:y,disabled:!0}),(0,Z.jsxs)(`section`,{className:`mt-3 space-y-2 border-t border-edge-subtle px-2 pt-3`,children:[(0,Z.jsx)(`h3`,{className:`text-sm text-fg-subtle`,children:n?`执行设备`:`Execution device`}),i.isLoading||a.isLoading?(0,Z.jsx)(qt,{className:`h-10 w-full rounded-lg`}):(0,Z.jsx)(ue,{value:d?.endpointId??``,options:u,allowEmpty:!0,emptyLabel:n?`由对话选择`:`Choose in conversation`,placeholder:n?`由对话选择`:`Choose in conversation`,title:y,selectedLabel:y,ariaLabel:n?`选择执行设备`:`Select execution device`,triggerIcon:(0,Z.jsx)(St,{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 g(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&&!v&&!t?(0,Z.jsx)(PD,{conversationId:e,deviceName:m?.displayName??d.endpointId,zh:n},d.connectionId):null,c?(0,Z.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:n?`无法更改设备,请先结束正在进行的操作并重试。`:`Unable to change device. Finish active operations and retry.`}):null]})}function ID(e){let t=(0,X.c)(23),{conversationId:n}=e,{data:r}=Qs(n),i=h(RD)===`zh`,a=sc(LD),o,s;if(t[0]!==n||t[1]!==r||t[2]!==a){let e=r?oc(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||Gs(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=()=>mi.getState().openPhone(r.report.deviceId??r.report.sessionId,r.report.deviceName,n,!0),t[5]=n,t[6]=r.report.deviceId,t[7]=r.report.deviceName,t[8]=r.report.sessionId,t[9]=d):d=t[9];let f;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(Lt,{className:`size-4`,"aria-hidden":!0}),t[10]=f):f=t[10];let p;t[11]===c?p=t[12]:(p=c&&(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`absolute -right-1 -top-1 size-1.5 rounded-full bg-accent`}),t[11]=c,t[12]=p);let m;t[13]===p?m=t[14]:(m=(0,Z.jsxs)(`span`,{className:`relative`,children:[f,p]}),t[13]=p,t[14]=m);let g=i?`手机`:`Phone`,_;t[15]===g?_=t[16]:(_=(0,Z.jsx)(`span`,{className:`text-xs`,children:g}),t[15]=g,t[16]=_);let v;return t[17]!==_||t[18]!==l||t[19]!==u||t[20]!==d||t[21]!==m?(v=(0,Z.jsxs)(pi,{variant:`ghost`,className:`min-h-10 gap-1.5 px-2`,title:l,"aria-label":u,onClick:d,children:[m,_]}),t[17]=_,t[18]=l,t[19]=u,t[20]=d,t[21]=m,t[22]=v):v=t[22],v}function LD(e){return e.seen}function RD(e){return e.language}function zD(e){let t=(0,X.c)(57),{conversationId:n,directoryOnly:r,workspacePath:i,canChangeWorkspace:a,disabled:o,available:s,onWorkspaceChange:c}=e,l=r!==void 0&&r,u=s===void 0||s,d=h(UD),f;t[0]===d?f=t[1]:(f=y(d),t[0]=d,t[1]=f);let p=f,m=$f(HD),g;t[2]===n?g=t[3]:(g=e=>e.panes[n??`new`]?.open===!0,t[2]=n,t[3]=g);let _=mi(g),[v,x]=(0,Q.useState)(null),C,O;t[4]!==p.chat.workingDirectory.notSet||t[5]!==i?(C=i?.trim()??``,O=C?Fa(C):p.chat.workingDirectory.notSet,t[4]=p.chat.workingDirectory.notSet,t[5]=i,t[6]=C,t[7]=O):(C=t[6],O=t[7]);let k=O,A;t[8]===c?A=t[9]:(A=async e=>{try{await c(e)}catch(e){let t=e;x(t instanceof Error?t.message:String(t))}},t[8]=c,t[9]=A);let j=A,M;t[10]!==j||t[11]!==C?(M={initialPath:C,onPicked:j},t[10]=j,t[11]=C,t[12]=M):M=t[12];let N=Ia(M),P=o||!u||N.picking,F;t[13]!==n||t[14]!==m?(F=()=>{let e=mi.getState(),t=n??`new`;e.setScope(t);let r=e.panes[t]?.tabs.find(VD);r?e.activate(r.id,t):e.openTools(t),m(n??``)},t[13]=n,t[14]=m,t[15]=F):F=t[15];let I=F,L;t[16]!==l||t[17]!==d||t[18]!==I||t[19]!==_?(L=l?null:(0,Z.jsx)(`button`,{type:`button`,className:Y(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors`,`hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,_&&`bg-surface-hover text-fg`),title:d===`zh`?`打开工具`:`Open workspace tools`,"aria-label":d===`zh`?`打开工具`:`Open workspace tools`,"aria-pressed":_,"aria-controls":`app-workspace-panel`,"data-workspace-trigger":!0,onClick:I,children:(0,Z.jsx)(Cs,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0})}),t[16]=l,t[17]=d,t[18]=I,t[19]=_,t[20]=L):L=t[20];let R;t[21]!==a||t[22]!==l||t[23]!==N||t[24]!==p.chat.workingDirectory.chooseFolder||t[25]!==C||t[26]!==P||t[27]!==k?(R=l&&a?(0,Z.jsxs)(`button`,{type:`button`,disabled:P,className:Y(`inline-flex h-8 max-w-full shrink-0 px-2 items-center justify-center rounded-lg text-fg-muted transition-colors`,`hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,P&&`cursor-not-allowed opacity-50`),title:`${p.chat.workingDirectory.chooseFolder}: ${C||k}`,"aria-label":p.chat.workingDirectory.chooseFolder,onClick:N.pick,children:[(0,Z.jsx)(re,{className:`mr-2 size-4`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate text-xs`,children:p.chat.workingDirectory.chooseFolder})]}):null,t[21]=a,t[22]=l,t[23]=N,t[24]=p.chat.workingDirectory.chooseFolder,t[25]=C,t[26]=P,t[27]=k,t[28]=R):R=t[28];let z;t[29]!==R||t[30]!==L?(z=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-0.5`,children:[L,R]}),t[29]=R,t[30]=L,t[31]=z):z=t[31];let B;t[32]!==l||t[33]!==N||t[34]!==p.chat.workingDirectory||t[35]!==C?(B=l&&!N.hasNativePicker?(0,Z.jsx)(ie,{open:N.modalOpen,onOpenChange:N.setModalOpen,initialAbsolutePath:C||void 0,onConfirm:N.confirmPick,wd:p.chat.workingDirectory}):null,t[32]=l,t[33]=N,t[34]=p.chat.workingDirectory,t[35]=C,t[36]=B):B=t[36];let V=v!==null,H;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(H=e=>{e||x(null)},t[37]=H):H=t[37];let U;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Z.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),t[38]=U):U=t[38];let W;t[39]===p.chat.workingDirectory.applyErrorTitle?W=t[40]:(W=(0,Z.jsx)(E,{className:`text-base font-semibold text-fg`,children:p.chat.workingDirectory.applyErrorTitle}),t[39]=p.chat.workingDirectory.applyErrorTitle,t[40]=W);let G;t[41]===v?G=t[42]:(G=v?(0,Z.jsx)(S,{className:`mt-2 whitespace-pre-wrap text-sm leading-relaxed text-fg-muted`,children:v}):null,t[41]=v,t[42]=G);let ee;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(ee=()=>x(null),t[43]=ee):ee=t[43];let te;t[44]===p.chat.workingDirectory.applyErrorClose?te=t[45]:(te=(0,Z.jsx)(`div`,{className:`mt-4 flex justify-end border-t border-edge-subtle pt-3`,children:(0,Z.jsx)(pi,{type:`button`,onClick:ee,children:p.chat.workingDirectory.applyErrorClose})}),t[44]=p.chat.workingDirectory.applyErrorClose,t[45]=te);let ne;t[46]!==W||t[47]!==G||t[48]!==te?(ne=(0,Z.jsxs)(w,{children:[U,(0,Z.jsxs)(T,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[81] w-[min(100%-2rem,26rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover`,onOpenAutoFocus:BD,children:[W,G,te]})]}),t[46]=W,t[47]=G,t[48]=te,t[49]=ne):ne=t[49];let ae;t[50]!==V||t[51]!==ne?(ae=(0,Z.jsx)(D,{open:V,onOpenChange:H,children:ne}),t[50]=V,t[51]=ne,t[52]=ae):ae=t[52];let oe;return t[53]!==z||t[54]!==B||t[55]!==ae?(oe=(0,Z.jsxs)(Z.Fragment,{children:[z,B,ae]}),t[53]=z,t[54]=B,t[55]=ae,t[56]=oe):oe=t[56],oe}function BD(e){return e.preventDefault()}function VD(e){return e.kind===`home`}function HD(e){return e.openForSession}function UD(e){return e.language}function WD(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 GD({conversationId:e,dialogOpen:t,onDialogOpenChange:n,hideTrigger:r=!1}){let i=h(e=>e.language),a=i===`zh`?qD:JD,[o,s]=(0,Q.useState)(!1),c=t??o,l=e=>{s(e),n?.(e)},[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(null),[m,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(null),[y,O]=(0,Q.useState)(864e5),[k,A]=(0,Q.useState)(null),[j,M]=(0,Q.useState)(``),[N,P]=(0,Q.useState)(!1),[F,I]=(0,Q.useState)([]),[L,R]=(0,Q.useState)(`hosted`),[z,B]=(0,Q.useState)(!1),[V,H]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(!c||u||f)return;let t=!1;return g(!0),v(null),Promise.all([$a(e),ro(e),Qa()]).then(async([n,r,i])=>{if(t)return;d(n),B(i);let a=i?await io().catch(()=>null):null;if(t)return;H(a?.publishing.allowed===!0);let o=i?await ao(e).catch(()=>[]):[];if(t)return;let s=[...o,...r].find(e=>!e.revoked&&!e.expired);s&&p(s)}).catch(e=>{t||v(e instanceof Error?e.message:String(e))}).finally(()=>{t||g(!1)}),()=>{t=!0}},[c,u,f,e]);let U=()=>{d(null),p(null),v(null),g(!1),M(``),P(!1),I([]),H(!1)},W=async()=>{if(!(!u||m)){g(!0),v(null);try{p(await(L===`hosted`?no:to)(e,{expectedTranscriptId:u.transcriptId,expectedCutoffSeq:u.cutoffSeq,expectedMetadataUpdatedAt:u.metadataUpdatedAt,ttlMs:y,maxViews:k,description:j.trim()||void 0,includeToolActivities:N,attachmentIds:F}))}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(!1)}}},G=async()=>{if(!(!f||m)){g(!0),v(null);try{let t=await $a(e);d(t);let n=f.delivery===`hosted`?eo:Xa;p(await n(e,f.id,{expectedTranscriptId:t.transcriptId,expectedCutoffSeq:t.cutoffSeq,expectedMetadataUpdatedAt:t.metadataUpdatedAt}))}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(!1)}}},ee=async()=>{if(!(!f||m)){g(!0),v(null);try{f.delivery===`hosted`?await oo(e,f.id):await Za(f.id),l(!1),U()}catch(e){v(e instanceof Error?e.message:String(e)),g(!1)}}};return(0,Z.jsxs)(D,{open:c,onOpenChange:e=>{l(e),e||U()},children:[r?null:(0,Z.jsx)(x,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`rounded-md p-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,title:a.share,"aria-label":a.share,children:(0,Z.jsx)(ys,{className:`size-4`})})}),(0,Z.jsxs)(w,{children:[(0,Z.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),(0,Z.jsxs)(T,{onCloseAutoFocus:e=>{r&&(e.preventDefault(),document.querySelector(`[data-chat-menu-trigger]`)?.focus())},className:Y(`xopc-dialog-content fixed left-1/2 top-1/2 z-[71] flex h-[min(35rem,calc(100dvh-2rem))] w-[min(34rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col`,`overflow-hidden rounded-xl border border-edge bg-surface-overlay outline-none`),children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(E,{className:`text-base font-semibold text-fg`,children:f?a.created:a.title}),(0,Z.jsx)(S,{className:`mt-0.5 text-xs text-fg-muted`,children:f?a.createdHint:a.hint})]}),(0,Z.jsx)(C,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`touch-target flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":a.close,children:(0,Z.jsx)(Gt,{className:`size-4`})})})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:[m&&!u&&!f?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,Z.jsx)(Je,{className:`size-4 animate-spin`}),a.loading]}):f?(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f.fileName}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.snapshotMessages.replace(`{{count}}`,String(f.messageCount))}),(0,Z.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[f.delivery===`hosted`?a.hosted:a.local,` · `,a.revision.replace(`{{revision}}`,String(f.snapshotRevision)),` · `,a.sharedAttachments.replace(`{{count}}`,String(f.attachmentCount))]})]}),(0,Z.jsx)(Ht,{shareUrl:f.shareUrl,lanUrl:f.lanUrl,reachability:f.reachability}),(0,Z.jsx)(Ut,{reachability:f.reachability,reachabilityHint:f.reachabilityHint}),(0,Z.jsxs)(`a`,{href:f.shareUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-sm font-medium text-accent hover:underline`,children:[a.open,(0,Z.jsx)(xe,{className:`size-3.5`})]})]}):u?(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-inset p-3`,children:[(0,Z.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:u.title}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.snapshotMessages.replace(`{{count}}`,String(u.messageCount))}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:new Date(u.snapshotAt).toLocaleString(i===`zh`?`zh-CN`:`en-US`)})]}),(0,Z.jsxs)(`details`,{className:`rounded-lg border border-edge`,children:[(0,Z.jsx)(`summary`,{className:`touch-target cursor-pointer px-3 py-2.5 text-xs font-medium text-fg transition-colors hover:bg-surface-hover`,children:a.reviewContent}),(0,Z.jsx)(`div`,{className:`max-h-64 space-y-3 overflow-y-auto border-t border-edge p-3`,children:u.messages.map(e=>(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-inset px-3 py-2`,children:[(0,Z.jsx)(`p`,{className:`mb-1 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:e.role===`user`?a.you:a.assistant}),(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm leading-6 text-fg`,children:e.markdown})]},e.id))})]}),(0,Z.jsxs)(`div`,{className:`flex gap-2 rounded-lg border border-accent/20 bg-accent-soft px-3 py-2.5 text-xs leading-5 text-fg-muted`,children:[(0,Z.jsx)(It,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{children:a.scope})]}),(0,Z.jsxs)(`label`,{className:`block space-y-1.5 text-xs font-medium text-fg`,children:[(0,Z.jsx)(`span`,{children:a.delivery}),(0,Z.jsxs)(se,{value:L,disabled:m,onChange:e=>R(e.target.value),children:[(0,Z.jsx)(le,{value:`hosted`,children:a.hosted}),(0,Z.jsx)(le,{value:`local`,children:a.local})]})]}),L===`hosted`&&!z?(0,Z.jsx)(Yo,{providerId:`xopc-share`,displayName:a.hosted,connected:!1,onConnected:()=>{B(!0),io().then(e=>H(e.publishing.allowed)).catch(()=>H(!1))}}):null,L===`hosted`&&z&&!V?(0,Z.jsx)(`p`,{className:`rounded-lg border border-warning/30 bg-warning-soft px-3 py-2 text-xs text-warning`,children:a.hostedDisabled}):null,u.toolActivities.length?(0,Z.jsxs)(`label`,{className:`flex items-start gap-2 rounded-lg border border-edge bg-surface-inset px-3 py-2.5 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:N,disabled:m,onChange:e=>P(e.target.checked),className:`mt-0.5 size-4 rounded border-edge`}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`block font-medium`,children:a.includeTools.replace(`{{count}}`,String(u.toolActivities.length))}),(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-muted`,children:a.toolDisclosure})]})]}):null,u.attachmentCandidates.length?(0,Z.jsxs)(`fieldset`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2.5`,children:[(0,Z.jsx)(`legend`,{className:`px-1 text-xs font-medium text-fg`,children:a.attachments}),(0,Z.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:a.attachmentDisclosure}),(0,Z.jsx)(`div`,{className:`space-y-2`,children:u.attachmentCandidates.map(e=>(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:F.includes(e.id),disabled:m,onChange:t=>I(n=>t.target.checked?[...n,e.id]:n.filter(t=>t!==e.id)),className:`size-4 rounded border-edge`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.fileName}),(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:KD(e.size)})]},e.id))})]}):null,(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg`,children:[(0,Z.jsx)(`span`,{children:a.ttl}),(0,Z.jsxs)(se,{value:y,disabled:m,onChange:e=>O(Number(e.target.value)),children:[(0,Z.jsx)(le,{value:36e5,children:a.oneHour}),(0,Z.jsx)(le,{value:864e5,children:a.oneDay}),(0,Z.jsx)(le,{value:6048e5,children:a.sevenDays}),(0,Z.jsx)(le,{value:2592e6,children:a.thirtyDays})]})]}),(0,Z.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg`,children:[(0,Z.jsx)(`span`,{children:a.maxViews}),(0,Z.jsxs)(se,{value:k??`unlimited`,disabled:m,onChange:e=>A(e.target.value===`unlimited`?null:Number(e.target.value)),children:[(0,Z.jsx)(le,{value:`unlimited`,children:a.unlimited}),(0,Z.jsx)(le,{value:1,children:`1`}),(0,Z.jsx)(le,{value:10,children:`10`}),(0,Z.jsx)(le,{value:50,children:`50`})]})]})]}),(0,Z.jsxs)(`label`,{className:`block space-y-1.5 text-xs font-medium text-fg`,children:[(0,Z.jsx)(`span`,{children:a.description}),(0,Z.jsx)(`input`,{value:j,disabled:m,onChange:e=>M(e.target.value),className:`h-10 w-full rounded-lg border border-edge bg-surface-inset px-3 text-sm font-normal text-fg outline-none focus-visible:border-accent/50 focus-visible:ring-2 focus-visible:ring-accent/20`})]}),(0,Z.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-300`,children:a.publicWarning})]}):null,_?(0,Z.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:_}):null]}),(0,Z.jsx)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-edge bg-surface-overlay px-4 py-3`,children:f?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(pi,{type:`button`,variant:`ghost`,disabled:m,onClick:()=>p(null),children:a.newShare}),(0,Z.jsxs)(pi,{type:`button`,variant:`ghost`,disabled:m,onClick:()=>void ee(),children:[(0,Z.jsx)(Bt,{className:`size-4`}),a.revoke]}),(0,Z.jsxs)(pi,{type:`button`,disabled:m||f.delivery===`hosted`&&!V,onClick:()=>void G(),children:[m?(0,Z.jsx)(Je,{className:`size-4 animate-spin`}):(0,Z.jsx)(At,{className:`size-4`}),a.refresh]})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(C,{asChild:!0,children:(0,Z.jsx)(pi,{type:`button`,variant:`ghost`,children:a.cancel})}),(0,Z.jsxs)(pi,{type:`button`,disabled:!u||m||u.messageCount===0||L===`hosted`&&(!z||!V),onClick:()=>void W(),children:[m?(0,Z.jsx)(Je,{className:`size-4 animate-spin`}):null,a.create]})]})})]})]})]})}function KD(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var qD={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:`助手`},JD={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`},YD=`(max-width: 767px)`,XD=(0,Q.memo)(function(e){let t=(0,X.c)(141),{inline:n,chatHeadline:r,chatAgents:i,showChatAgentSelector:a,chatAgentId:o,onChatAgentChange:c,chatAgentDisabled:l,conversationId:u,hasMessages:d,workspacePath:f,userContextMode:p,canChangeWorkspace:m,workspaceDisabled:g,onWorkspaceChange:_,prepareTerminalSession:v,terminalDisabled:b,showContextControls:x,onFindOpen:S,projectId:C,context:w}=e,T=n!==void 0&&n,E=d!==void 0&&d,D=p===void 0?`enabled`:p,O=m!==void 0&&m,k=g!==void 0&&g,A=b!==void 0&&b,j=x===void 0||x,M=h(ZD),{conversationId:N}=s(),P=N&&N!==`new`?decodeURIComponent(N):null,F;t[0]!==u||t[1]!==P?(F=u?.trim()||P,t[0]=u,t[1]=P,t[2]=F):F=t[2];let L=F,{data:R,error:z,mutate:B}=mf(L??null,!1),V=!z&&(!R||!!R.environment?.available),H;t[3]===L?H=t[4]:(H=e=>e.panes[L??`new`]?.open===!0,t[3]=L,t[4]=H);let U=mi(H),W;t[5]===M?W=t[6]:(W=y(M),t[5]=M,t[6]=W);let G=W,ee=Ef(QD),te=xw($D),ne=Go(eO),re=Go(tO),[ie,ae]=(0,Q.useState)(!1),oe=(0,Q.useRef)(!1),[se,ce]=(0,Q.useState)(!1),le=Df(nO),ue=Ea(rO),K=Ea(iO),q=window.electronAPI?.platform,de=!!(j&&window.electronAPI?.terminal&&(L||v)),pe;t[7]!==L||t[8]!==re||t[9]!==v||t[10]!==de||t[11]!==A||t[12]!==se||t[13]!==ne?(pe=()=>{if(!(!de||A||se)){if(L){ne(L);return}v&&(ce(!0),v().then(e=>{e&&re(e)}).finally(()=>ce(!1)))}},t[7]=L,t[8]=re,t[9]=v,t[10]=de,t[11]=A,t[12]=se,t[13]=ne,t[14]=pe):pe=t[14];let J=pe,me;t[15]!==L||t[16]!==E||t[17]!==te?(me=()=>{if(!L||!E)return;let e=mi.getState().panes[L],t=xw.getState().pendingCreate?.parentConversationId===L||!!xw.getState().creatingRequests[L],n=e?.open===!0&&(e.activeId?.startsWith(`side:`)===!0||t);te(L,!n)},t[15]=L,t[16]=E,t[17]=te,t[18]=me):me=t[18];let he=me,ge=Xo(YD),_e;t[19]!==le||t[20]!==ee?(_e=vf({runtime:_f(),sidebarCollapsed:ee,mobileNavOpen:le}),t[19]=le,t[20]=ee,t[21]=_e):_e=t[21];let ve=ge?!le:_e.collapsedNewChatVisible,ye,xe;t[22]!==K||t[23]!==T?(ye=()=>{if(!T)return()=>K()},xe=[K,T],t[22]=K,t[23]=T,t[24]=ye,t[25]=xe):(ye=t[24],xe=t[25]),(0,Q.useLayoutEffect)(ye,xe);let Se,Ce;t[26]!==J||t[27]!==de?(Se=()=>{if(!de)return;let e=e=>{WD(e,q)&&(e.preventDefault(),J())};return window.addEventListener(`keydown`,e),window.addEventListener(`workspace-open-terminal`,J),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`workspace-open-terminal`,J)}},Ce=[J,de,q],t[26]=J,t[27]=de,t[28]=Se,t[29]=Ce):(Se=t[28],Ce=t[29]),(0,Q.useEffect)(Se,Ce);let we,Te;t[30]!==L||t[31]!==he||t[32]!==E?(we=()=>{if(!L||!E)return;let e=e=>{is(e,q)&&(e.preventDefault(),he())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},Te=[L,he,E,q],t[30]=L,t[31]=he,t[32]=E,t[33]=we,t[34]=Te):(we=t[33],Te=t[34]),(0,Q.useEffect)(we,Te);let Ee;t[35]!==o||t[36]!==G.sidebar.newTask||t[37]!==C||t[38]!==ve||t[39]!==D?(Ee=ve?(0,Z.jsx)(fe,{to:Xr(C),state:{forceNewChat:!0,agentId:o,temporary:D===`temporary`},className:Y(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-panel text-sm font-medium leading-none text-fg transition-colors hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,xa),title:G.sidebar.newTask,children:(0,Z.jsx)(kt,{className:`size-4 shrink-0 text-accent-fg`,strokeWidth:2,"aria-hidden":!0})}):null,t[35]=o,t[36]=G.sidebar.newTask,t[37]=C,t[38]=ve,t[39]=D,t[40]=Ee):Ee=t[40];let De=ve?`text-left md:text-center`:`text-left`,Oe;t[41]===De?Oe=t[42]:(Oe=Y(`min-w-0 flex-1 truncate text-[0.9375rem] font-semibold leading-5 tracking-tight text-fg`,De),t[41]=De,t[42]=Oe);let ke;t[43]!==r||t[44]!==Oe?(ke=(0,Z.jsx)(`div`,{className:`flex w-full min-w-0 max-w-(--max-width-chat-frame) items-center gap-3 px-3 sm:px-5 xl:px-6`,children:(0,Z.jsx)(`h1`,{className:Oe,title:r,children:r})}),t[43]=r,t[44]=Oe,t[45]=ke):ke=t[45];let Ae;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=Y(`flex min-w-0 max-w-[min(32rem,calc(100vw-8rem))] shrink-0 items-center justify-end gap-2`,xa),t[46]=Ae):Ae=t[46];let je;t[47]!==l||t[48]!==o||t[49]!==i||t[50]!==G.chat.agentNoMatches||t[51]!==G.chat.agentPlaceholder||t[52]!==G.chat.agentSearchPlaceholder||t[53]!==c||t[54]!==a?(je=a?(0,Z.jsx)(_D,{items:i,value:o,disabled:l,placeholder:G.chat.agentPlaceholder,searchPlaceholder:G.chat.agentSearchPlaceholder,noMatches:G.chat.agentNoMatches,compact:!0,contentSide:`bottom`,contentAlign:`end`,onChange:c}):null,t[47]=l,t[48]=o,t[49]=i,t[50]=G.chat.agentNoMatches,t[51]=G.chat.agentPlaceholder,t[52]=G.chat.agentSearchPlaceholder,t[53]=c,t[54]=a,t[55]=je):je=t[55];let Me=M===`zh`?`聊天菜单`:`Chat menu`,Ne=M===`zh`?`聊天菜单`:`Chat menu`,Pe;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=(0,Z.jsx)(be,{className:`size-4`,"aria-hidden":!0}),t[56]=Pe):Pe=t[56];let Fe;t[57]!==Me||t[58]!==Ne?(Fe=(0,Z.jsx)(lo,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,"data-chat-menu-trigger":!0,"aria-label":Me,title:Ne,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover data-[state=open]:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:Pe})}),t[57]=Me,t[58]=Ne,t[59]=Fe):Fe=t[59];let Ie;t[60]===S?Ie=t[61]:(Ie=e=>{oe.current&&(e.preventDefault(),oe.current=!1,document.querySelector(`[data-chat-menu-trigger]`)?.focus(),S?.())},t[60]=S,t[61]=Ie);let Le=!E||!S,Re;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(Re=()=>{oe.current=!0},t[62]=Re):Re=t[62];let ze;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(ze=(0,Z.jsx)(Nt,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t[63]=ze):ze=t[63];let Be;t[64]===G.chat.find.input?Be=t[65]:(Be=(0,Z.jsx)(`span`,{className:`flex-1`,children:G.chat.find.input}),t[64]=G.chat.find.input,t[65]=Be);let Ve;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(Ve=(0,Z.jsx)(`span`,{className:`text-xs text-fg-muted`,children:q===`darwin`?`⌘F`:`Ctrl+F`}),t[66]=Ve):Ve=t[66];let He;t[67]!==Le||t[68]!==Be?(He=(0,Z.jsxs)(fo,{disabled:Le,onSelect:Re,className:`flex cursor-default items-center gap-3 rounded-lg px-3 py-2 text-fg outline-none data-[highlighted]:bg-surface-hover data-[disabled]:opacity-40`,children:[ze,Be,Ve]}),t[67]=Le,t[68]=Be,t[69]=He):He=t[69];let Ue=!L||!E,We;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(We=()=>ae(!0),t[70]=We):We=t[70];let Ge;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(Ge=(0,Z.jsx)(I,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t[71]=Ge):Ge=t[71];let Ke=M===`zh`?`分享对话`:`Share conversation`,qe;t[72]===Ke?qe=t[73]:(qe=(0,Z.jsx)(`span`,{children:Ke}),t[72]=Ke,t[73]=qe);let Je;t[74]!==Ue||t[75]!==qe?(Je=(0,Z.jsxs)(fo,{disabled:Ue,onSelect:We,className:`flex cursor-default items-center gap-3 rounded-lg px-3 py-2 text-fg outline-none data-[highlighted]:bg-surface-hover data-[disabled]:opacity-40`,children:[Ge,qe]}),t[74]=Ue,t[75]=qe,t[76]=Je):Je=t[76];let Ye;t[77]!==Ie||t[78]!==He||t[79]!==Je?(Ye=(0,Z.jsx)(uo,{children:(0,Z.jsxs)(po,{onCloseAutoFocus:Ie,align:`end`,sideOffset:8,className:`workspace-menu z-[125] min-w-60 rounded-xl border border-edge bg-surface-overlay p-1.5 text-sm shadow-popover outline-none`,children:[He,Je]})}),t[77]=Ie,t[78]=He,t[79]=Je,t[80]=Ye):Ye=t[80];let Xe;t[81]!==Fe||t[82]!==Ye?(Xe=(0,Z.jsxs)(co,{modal:!1,children:[Fe,Ye]}),t[81]=Fe,t[82]=Ye,t[83]=Xe):Xe=t[83];let Ze;t[84]!==L||t[85]!==E||t[86]!==ie?(Ze=L&&E?(0,Z.jsx)(GD,{conversationId:L,hideTrigger:!0,dialogOpen:ie,onDialogOpenChange:ae},`share:${L}`):null,t[84]=L,t[85]=E,t[86]=ie,t[87]=Ze):Ze=t[87];let Qe;t[88]!==L||t[89]!==O||t[90]!==l||t[91]!==o||t[92]!==w||t[93]!==_||t[94]!==B||t[95]!==j||t[96]!==D||t[97]!==V||t[98]!==k||t[99]!==f?(Qe=j?(0,Z.jsx)(wD,{...w,agentId:o,executionDeviceAction:L?(0,Z.jsx)(FD,{conversationId:L,disabled:l}):null,environmentAction:O&&_?(0,Z.jsx)(zD,{directoryOnly:!0,conversationId:L,workspacePath:L?f:w?.project?.workspaceRoot,available:V,canChangeWorkspace:!0,disabled:k,onWorkspaceChange:async e=>{await _(e),await B()}}):null,temporary:D===`temporary`,conversationId:L??null},`context:${L??w?.project?.id??`new`}`):null,t[88]=L,t[89]=O,t[90]=l,t[91]=o,t[92]=w,t[93]=_,t[94]=B,t[95]=j,t[96]=D,t[97]=V,t[98]=k,t[99]=f,t[100]=Qe):Qe=t[100];let $e;t[101]!==j||t[102]!==U?($e=j&&!U?(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`mx-0.5 h-6 w-px shrink-0 bg-edge-subtle`}):null,t[101]=j,t[102]=U,t[103]=$e):$e=t[103];let et;t[104]===L?et=t[105]:(et=L?(0,Z.jsx)(jD,{conversationId:L},L):null,t[104]=L,t[105]=et);let tt;t[106]===L?tt=t[107]:(tt=L?(0,Z.jsx)(ID,{conversationId:L}):null,t[106]=L,t[107]=tt);let nt;t[108]!==L||t[109]!==w?.project?.workspaceRoot||t[110]!==_||t[111]!==C||t[112]!==B||t[113]!==j||t[114]!==V||t[115]!==k||t[116]!==U||t[117]!==f?(nt=j&&!U?(0,Z.jsx)(zD,{conversationId:L,workspacePath:L?f:w?.project?.workspaceRoot,available:V,canChangeWorkspace:!1,disabled:k,onWorkspaceChange:async e=>{await _?.(e),await B()}},`workspace:${L??C}`):null,t[108]=L,t[109]=w?.project?.workspaceRoot,t[110]=_,t[111]=C,t[112]=B,t[113]=j,t[114]=V,t[115]=k,t[116]=U,t[117]=f,t[118]=nt):nt=t[118];let rt;t[119]!==je||t[120]!==Xe||t[121]!==Ze||t[122]!==Qe||t[123]!==$e||t[124]!==et||t[125]!==tt||t[126]!==nt?(rt=(0,Z.jsxs)(`div`,{className:Ae,children:[je,Xe,Ze,Qe,$e,et,tt,nt]}),t[119]=je,t[120]=Xe,t[121]=Ze,t[122]=Qe,t[123]=$e,t[124]=et,t[125]=tt,t[126]=nt,t[127]=rt):rt=t[127];let it;t[128]!==Ee||t[129]!==ke||t[130]!==rt?(it={className:`bg-surface-panel`,startExtra:Ee,main:ke,end:rt},t[128]=Ee,t[129]=ke,t[130]=rt,t[131]=it):it=t[131];let at=it,ot,st;t[132]!==at||t[133]!==T||t[134]!==ue?(ot=()=>{T||ue(at)},st=[at,T,ue],t[132]=at,t[133]=T,t[134]=ue,t[135]=ot,t[136]=st):(ot=t[135],st=t[136]),(0,Q.useLayoutEffect)(ot,st);let ct;return t[137]!==at||t[138]!==T||t[139]!==M?(ct=T?(0,Z.jsxs)(`header`,{"aria-label":M===`zh`?`聊天工具栏`:`Chat toolbar`,className:`flex min-h-14 shrink-0 items-center justify-between gap-2 border-b border-edge-subtle px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:at.main}),at.end]}):null,t[137]=at,t[138]=T,t[139]=M,t[140]=ct):ct=t[140],ct});function ZD(e){return e.language}function QD(e){return e.collapsed}function $D(e){return e.setOpen}function eO(e){return e.toggle}function tO(e){return e.open}function nO(e){return e.mobileNavOpen}function rO(e){return e.setPageHeader}function iO(e){return e.clearPageHeader}var aO=(0,Q.memo)(function(){let e=(0,X.c)(13),t=h(oO),n;e[0]===t?n=e[1]:(n=y(t),e[0]=t,e[1]=n);let r=n,i=li(sO),a=li(cO);if(i===`idle`)return null;if(i===`error`&&a){let t;e[2]===a?t=e[3]:(t=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:a}),e[2]=a,e[3]=t);let n;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(n=Y(`shrink-0 rounded-xl border border-red-200 bg-white px-2.5 py-1 text-xs font-medium text-red-700`,`hover:bg-red-50 dark:border-red-800 dark:bg-red-950/40 dark:text-red-300 dark:hover:bg-red-950/70`,ca.transition,ca.press,ca.focusRingPanel),e[4]=n):n=e[4];let i;e[5]===r.connection.reconnect?i=e[6]:(i=(0,Z.jsx)(`button`,{type:`button`,className:n,onClick:lO,children:r.connection.reconnect}),e[5]=r.connection.reconnect,e[6]=i);let o;return e[7]!==t||e[8]!==i?(o=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-red-100 bg-red-50 px-4 py-2 text-sm text-red-600 dark:border-red-900/40 dark:bg-red-950/50 dark:text-red-400`,children:[t,i]}),e[7]=t,e[8]=i,e[9]=o):o=e[9],o}if(i===`connecting`||i===`reconnecting`){let t;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`span`,{className:`inline-block size-3 animate-spin rounded-full border-2 border-amber-500 border-t-transparent`,"aria-hidden":!0}),e[10]=t):t=e[10];let n=i===`reconnecting`?r.connection.reconnecting:r.connection.connecting,a;return e[11]===n?a=e[12]:(a=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-amber-100 bg-amber-50 px-4 py-2 text-sm text-amber-800 dark:border-amber-900/40 dark:bg-amber-950/50 dark:text-amber-200`,children:[t,(0,Z.jsx)(`span`,{children:n})]}),e[11]=n,e[12]=a),a}return null});function oO(e){return e.language}function sO(e){return e.connectionState}function cO(e){return e.error}function lO(){return ci()}function uO(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function dO(e){let t=(0,X.c)(4),{status:n}=e;if(n===`completed`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(`span`,{className:`mt-0.5 inline-flex size-4 shrink-0 items-center justify-center rounded-full bg-fg-muted text-surface-panel`,children:(0,Z.jsx)(G,{className:`size-3`,strokeWidth:2.5,"aria-hidden":!0})}),t[0]=e):e=t[0],e}if(n===`in_progress`){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(q,{className:`mt-0.5 size-4 shrink-0 text-accent`,strokeWidth:2,"aria-hidden":!0}),t[1]=e):e=t[1],e}if(n===`cancelled`){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(os,{className:`mt-0.5 size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),t[2]=e):e=t[2],e}let r;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(J,{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 fO(e,t){return e?`${uO(e.files.length===1?t.filesChangedOne:t.filesChangedOther,{count:e.files.length})} · +${e.added} -${e.removed}`:null}function pO(e){let t=(0,X.c)(61),{plan:n,changeSummary:r,isStreaming:i,labels:a}=e,o=n.currentIndex==null?void 0:n.items[n.currentIndex-1],s;t[0]===n.items?s=t[1]:(s=n.items.every(gO),t[0]=n.items,t[1]=s);let c=s,l=n.items.every(hO),u;t[2]!==a.completedProgress||t[3]!==n.completedCount||t[4]!==n.totalCount?(u=uO(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=uO(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=fO(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`,ca.transition,`hover:border-edge hover:text-accent-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),t[17]=v):v=t[17];let y=`${a.heading}: ${_}`,b;t[18]!==o||t[19]!==c?(b=c?(0,Z.jsx)(G,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:2,"aria-hidden":!0}):o?(0,Z.jsx)(q,{className:`size-4 shrink-0 text-accent`,strokeWidth:2,"aria-hidden":!0}):(0,Z.jsx)(Ke,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[18]=o,t[19]=c,t[20]=b):b=t[20];let x;t[21]===f?x=t[22]:(x=(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:f}),t[21]=f,t[22]=x);let S;t[23]===o?S=t[24]:(S=o?(0,Z.jsxs)(`span`,{className:`min-w-0 truncate text-fg-muted`,children:[`· `,o.title]}):null,t[23]=o,t[24]=S);let C;t[25]===m?C=t[26]:(C=m?(0,Z.jsxs)(`span`,{className:`hidden shrink-0 tabular-nums text-fg-subtle sm:inline`,children:[`· `,m]}):null,t[25]=m,t[26]=C);let w;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(ee,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[27]=w):w=t[27];let T;t[28]!==S||t[29]!==C||t[30]!==y||t[31]!==b||t[32]!==x?(T=(0,Z.jsx)(yi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:v,"aria-label":y,children:[b,x,S,C,w]})}),t[28]=S,t[29]=C,t[30]=y,t[31]=b,t[32]=x,t[33]=T):T=t[33];let E;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsx)(Ke,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[34]=E):E=t[34];let D;t[35]===a.heading?D=t[36]:(D=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[E,(0,Z.jsx)(`span`,{children:a.heading})]}),t[35]=a.heading,t[36]=D);let O;t[37]===n.explanation?O=t[38]:(O=n.explanation?(0,Z.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:n.explanation}):null,t[37]=n.explanation,t[38]=O);let k;t[39]!==D||t[40]!==O?(k=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[D,O]}),t[39]=D,t[40]=O,t[41]=k):k=t[41];let A;t[42]===d?A=t[43]:(A=(0,Z.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-fg-subtle`,children:d}),t[42]=d,t[43]=A);let j;t[44]!==k||t[45]!==A?(j=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge-subtle px-4 py-3`,children:[k,A]}),t[44]=k,t[45]=A,t[46]=j):j=t[46];let M=a.heading,N;t[47]===n.items?N=t[48]:(N=n.items.map(mO),t[47]=n.items,t[48]=N);let P;t[49]!==a.heading||t[50]!==N?(P=(0,Z.jsx)(`ol`,{className:`max-h-[min(22rem,55vh)] overflow-y-auto px-4 py-3`,"aria-label":M,children:N}),t[49]=a.heading,t[50]=N,t[51]=P):P=t[51];let F;t[52]===m?F=t[53]:(F=m?(0,Z.jsx)(`div`,{className:`border-t border-edge-subtle px-4 py-2 text-right text-xs tabular-nums text-fg-subtle`,children:m}):null,t[52]=m,t[53]=F);let I;t[54]!==j||t[55]!==P||t[56]!==F?(I=(0,Z.jsx)(hi,{children:(0,Z.jsxs)(gi,{side:`top`,align:`center`,sideOffset:8,collisionPadding:16,className:`z-[120] w-[min(28rem,calc(100vw-2rem))] overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:[j,P,F]})}),t[54]=j,t[55]=P,t[56]=F,t[57]=I):I=t[57];let L;return t[58]!==T||t[59]!==I?(L=(0,Z.jsx)(`div`,{className:`mx-auto flex w-full max-w-80 justify-center pb-2 pt-1`,children:(0,Z.jsxs)(_i,{children:[T,I]})}),t[58]=T,t[59]=I,t[60]=L):L=t[60],L}function mO(e){return(0,Z.jsxs)(`li`,{className:Y(`flex gap-3 py-2 text-sm leading-relaxed text-fg-muted`,e.status===`in_progress`&&`font-medium text-fg`,e.status===`cancelled`&&`text-fg-disabled`),children:[(0,Z.jsx)(dO,{status:e.status}),(0,Z.jsx)(`span`,{className:`min-w-0 [overflow-wrap:anywhere]`,children:e.title})]},e.id)}function hO(e){return e.status===`completed`||e.status===`cancelled`}function gO(e){return e.status===`completed`}function _O(e){let t=CO(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 vO=new Set([`pending`,`in_progress`,`completed`,`cancelled`]);function yO(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function bO(e){return e.trim().toLowerCase().replace(/-/g,`_`).split(`__`).at(-1)??``}function xO(e){let t=yO(e.details);return t&&Object.keys(t).length>0?t:ma(e.result).details}function SO(e){let t=typeof e==`string`?e.trim():``;return vO.has(t)?t:null}function CO(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 wO(e){if(!Array.isArray(e.plan))return null;let t=e.plan.flatMap((e,t)=>{let n=yO(e),r=typeof n?.id==`string`&&n.id.trim()?n.id.trim():`update-plan-${t}`,i=typeof n?.step==`string`?n.step.trim():``,a=SO(n?.status);return i&&a?[{id:r,title:i,status:a}]:[]});return CO(`update_plan`,typeof e.explanation==`string`&&e.explanation.trim()?e.explanation.trim():void 0,t)}function TO(e){return Array.isArray(e.items)?CO(`todo`,void 0,e.items.flatMap((e,t)=>{let n=yO(e),r=typeof n?.id==`string`&&n.id.trim()?n.id.trim():`todo-${t}`,i=typeof n?.content==`string`?n.content.trim():``,a=SO(n?.status);return i&&a?[{id:r,title:i,status:a}]:[]})):null}function EO(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=bO(n.name),i=xO(n);if(i){if(r===`update_plan`)return{found:!0,plan:wO(i)};if(r===`todo`)return{found:!0,plan:TO(i)}}}return{found:!1,plan:null}}function DO(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:0}function OO(e){let t=new Set,n=0,r=0;for(let i of e){if(i.type!==`tool_use`||i.status===`error`||bO(i.name)!==`apply_patch`)continue;let e=xO(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=yO(n),r=typeof e?.moveTo==`string`?e.moveTo:typeof e?.path==`string`?e.path:``;r.trim()&&t.add(r.trim())}n+=DO(e.added),r+=DO(e.removed)}}return t.size>0||n>0||r>0?{files:[...t],added:n,removed:r}:null}function kO(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.role!==`assistant`)continue;let r=EO(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:OO(i)}}return null}function AO(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 kO(e.slice(n+1))}function jO(e,t){return e.bottom>t.top&&e.top<t.bottom&&e.right>t.left&&e.left<t.right}function MO(e,t,n){let r=n.getBoundingClientRect(),i=t.getBoundingClientRect();if(!jO(e,{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight})||!jO(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&&!jO(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 NO(e){let t=(0,X.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=MO(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 PO(e){let t=(0,X.c)(61),{open:n,query:r,activeIndex:i,resultCount:a,searching:o,truncated:s,limitedToLoaded:c,inputRef:l,labels:u,onQueryChange:d,onPrevious:f,onNext:p,onClose:m}=e,h=o!==void 0&&o,g=s!==void 0&&s,_=c!==void 0&&c;if(!n)return null;let v;t[0]===r?v=t[1]:(v=r.trim(),t[0]=r,t[1]=v);let y=!!v,b;t[2]!==i||t[3]!==y||t[4]!==u.noResults||t[5]!==u.resultCount||t[6]!==u.searching||t[7]!==a||t[8]!==h||t[9]!==g?(b=h?u.searching:y&&a===0?u.noResults:y?u.resultCount.replace(`{{current}}`,String(i+1)).replace(`{{total}}`,`${a}${g?`+`:``}`):``,t[2]=i,t[3]=y,t[4]=u.noResults,t[5]=u.resultCount,t[6]=u.searching,t[7]=a,t[8]=h,t[9]=g,t[10]=b):b=t[10];let x=b,S;t[11]!==x||t[12]!==y||t[13]!==u.loadedOnly||t[14]!==_?(S=_&&y?[x,u.loadedOnly].filter(Boolean).join(` · `):x,t[11]=x,t[12]=y,t[13]=u.loadedOnly,t[14]=_,t[15]=S):S=t[15];let C=S,w=h||a===0,T=u.input,E;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsx)(Nt,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[16]=E):E=t[16];let D;t[17]===d?D=t[18]:(D=e=>d(e.target.value),t[17]=d,t[18]=D);let O;t[19]!==p||t[20]!==f?(O=e=>{e.nativeEvent.isComposing||e.key===`Enter`&&(e.preventDefault(),e.shiftKey?f():p())},t[19]=p,t[20]=f,t[21]=O):O=t[21];let k;t[22]!==l||t[23]!==u.input||t[24]!==r||t[25]!==O||t[26]!==D?(k=(0,Z.jsx)(`input`,{ref:l,value:r,type:`search`,autoComplete:`off`,spellCheck:!1,"aria-label":u.input,className:`h-12 min-w-0 flex-1 bg-transparent text-base text-fg outline-none placeholder:text-fg-subtle`,placeholder:u.input,onChange:D,onKeyDown:O}),t[22]=l,t[23]=u.input,t[24]=r,t[25]=O,t[26]=D,t[27]=k):k=t[27];let A;t[28]===h?A=t[29]:(A=h?(0,Z.jsx)(Je,{className:`size-4 shrink-0 animate-spin text-fg-muted`,"aria-hidden":!0}):null,t[28]=h,t[29]=A);let j;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(j=Y(`inline-flex size-11 shrink-0 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,ca.focusRingPanel,ca.press),t[30]=j):j=t[30];let M;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Z.jsx)(Gt,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[31]=M):M=t[31];let N;t[32]!==u.close||t[33]!==m?(N=(0,Z.jsx)(`button`,{type:`button`,onClick:m,className:j,"aria-label":u.close,children:M}),t[32]=u.close,t[33]=m,t[34]=N):N=t[34];let P;t[35]!==k||t[36]!==A||t[37]!==N?(P=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 px-3`,children:[E,k,A,N]}),t[35]=k,t[36]=A,t[37]=N,t[38]=P):P=t[38];let F;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(F=Y(`inline-flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,ca.focusRingPanel,ca.press,ca.disabled),t[39]=F):F=t[39];let I;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(ne,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[40]=I):I=t[40];let L;t[41]!==u.previous||t[42]!==w||t[43]!==f?(L=(0,Z.jsx)(`button`,{type:`button`,disabled:w,onClick:f,className:F,"aria-label":u.previous,children:I}),t[41]=u.previous,t[42]=w,t[43]=f,t[44]=L):L=t[44];let R;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(R=Y(`inline-flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,ca.focusRingPanel,ca.press,ca.disabled),t[45]=R):R=t[45];let z;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Z.jsx)(ee,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[46]=z):z=t[46];let B;t[47]!==u.next||t[48]!==w||t[49]!==p?(B=(0,Z.jsx)(`button`,{type:`button`,disabled:w,onClick:p,className:R,"aria-label":u.next,children:z}),t[47]=u.next,t[48]=w,t[49]=p,t[50]=B):B=t[50];let V;t[51]===C?V=t[52]:(V=(0,Z.jsx)(`span`,{className:`ml-auto px-2 text-sm tabular-nums text-fg-muted`,"aria-live":`polite`,"aria-atomic":`true`,children:C}),t[51]=C,t[52]=V);let H;t[53]!==L||t[54]!==B||t[55]!==V?(H=(0,Z.jsxs)(`div`,{className:`flex h-11 items-center border-t border-edge-subtle px-1.5`,children:[L,B,V]}),t[53]=L,t[54]=B,t[55]=V,t[56]=H):H=t[56];let U;return t[57]!==u.input||t[58]!==P||t[59]!==H?(U=(0,Z.jsxs)(`section`,{"data-chat-find-bar":!0,role:`search`,"aria-label":T,className:`absolute right-3 top-3 z-30 w-[min(25rem,calc(100%-1.5rem))] overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover`,children:[P,H]}),t[57]=u.input,t[58]=P,t[59]=H,t[60]=U):U=t[60],U}async function FO(e,t,n={}){let r=await f(p(`${n.taskId?`/api/tasks/${encodeURIComponent(n.taskId)}/conversation/find`:`/api/sessions/${encodeURIComponent(e)}/find`}?${new URLSearchParams({q:t,limit:`1000`})}`),{signal:n.signal});if(!r.ok)throw Error(`HTTP ${r.status}: ${r.statusText}`);let i=await r.json();if(i.ok!==!0||!Array.isArray(i.matches)||typeof i.total!=`number`)throw Error(`Invalid chat find response`);return{query:typeof i.query==`string`?i.query:t,total:i.total,truncated:i.truncated===!0,matches:i.matches.filter(e=>Number.isInteger(e?.displayIndex)&&e.displayIndex>=0&&Number.isInteger(e?.occurrence)&&e.occurrence>=0)}}var IO=`chat-find-match`,LO=`chat-find-active`,RO=`chat-find-highlight-styles`;function zO(){let e=globalThis.CSS,t=globalThis.Highlight;return!e?.highlights||!t?null:{registry:e.highlights,Highlight:t}}function BO(){if(document.getElementById(RO))return;let e=document.createElement(`style`);e.id=RO,e.textContent=`
61
+ ::highlight(${IO}) {
62
62
  color: inherit;
63
63
  background-color: color-mix(in srgb, var(--color-warning) 38%, transparent);
64
64
  }
65
- ::highlight(${IO}) {
65
+ ::highlight(${LO}) {
66
66
  color: inherit;
67
67
  background-color: color-mix(in srgb, var(--color-warning) 78%, transparent);
68
68
  text-decoration: underline 2px var(--color-fg);
69
69
  }
70
- `,document.head.appendChild(e)}function BO(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 VO(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 HO(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 UO(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=BO(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 HO(s,n)){let t=VO(o,e.start,e.end);t&&(r.push({messageIndex:i,occurrence:a,range:t}),a+=1)}}}return r}function WO(e,t){let n=RO();if(!n||(zO(),n.registry.delete(FO),n.registry.delete(IO),e.length===0))return;n.registry.set(FO,new n.Highlight(...e.map(e=>e.range)));let r=e[t];r&&n.registry.set(IO,new n.Highlight(r.range))}function GO(){let e=RO();e?.registry.delete(FO),e?.registry.delete(IO)}function KO(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||(WC(e),e.scrollTo({top:Math.max(0,e.scrollTop+r.top-a),behavior:window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}))}function qO(e,t){return t===0?0:(e+t)%t}function JO(e){return`${e.displayIndex}:${e.occurrence}`}function YO(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 XO(e){let t=(0,X.c)(66),{conversationId:n,taskId:r,messages:i,displayOffset:a,viewportRef:o,onRevealDisplayIndex:s}=e,[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(``),f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=[],t[0]=f):f=t[0];let[p,m]=(0,Q.useState)(f),h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h=[],t[1]=h):h=t[1];let[g,_]=(0,Q.useState)(h),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(0),E=(0,Q.useRef)(null),D=(0,Q.useRef)(null),O=(0,Q.useRef)(n),k=(0,Q.useDeferredValue)(u),A;if(t[2]!==a||t[3]!==p||t[4]!==g){let e=new Map(g.map(tk));for(let t of p){let n={displayIndex:a+t.messageIndex,occurrence:t.occurrence};e.set(JO(n),n)}A=[...e.values()].sort(ek),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),GO(),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=>qO(t+e,j.length))},t[14]=j.length,t[15]=H);let U=H,W,G;t[16]!==U||t[17]!==c||t[18]!==F?(W=()=>{let e=e=>{let t=e.metaKey||e.ctrlKey;if(t&&!e.altKey&&!e.shiftKey&&e.key.toLowerCase()===`f`){if(document.querySelector(`[role="dialog"][data-state="open"]`))return;e.preventDefault(),F();return}if(c){if(t&&!e.altKey&&e.key.toLowerCase()===`g`){e.preventDefault(),U(e.shiftKey?-1:1);return}e.key===`Escape`&&(e.preventDefault(),z())}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},G=[z,U,c,F],t[16]=U,t[17]=c,t[18]=F,t[19]=W,t[20]=G):(W=t[19],G=t[20]),(0,Q.useEffect)(W,G);let ee;t[21]!==k||t[22]!==c||t[23]!==o?(ee=()=>{let e=o.current;if(!c||!e||!k.trim()){m($O),GO();return}let t=()=>{let t=UO(e,k);m(e=>YO(e,t)?e:t)};t();let n=null,r=new MutationObserver(()=>{n===null&&(n=requestAnimationFrame(()=>{n=null,t()}))});return r.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>{r.disconnect(),n!==null&&cancelAnimationFrame(n)}},t[21]=k,t[22]=c,t[23]=o,t[24]=ee):ee=t[24];let te;t[25]!==k||t[26]!==i||t[27]!==c||t[28]!==o?(te=[k,i,c,o],t[25]=k,t[26]=i,t[27]=c,t[28]=o,t[29]=te):te=t[29],(0,Q.useLayoutEffect)(ee,te);let ne,re;t[30]!==n||t[31]!==k||t[32]!==c||t[33]!==r?(ne=()=>{let e=k.trim();if(!c||!n||!e){_([]),y(!1),x(!1),C(!1);return}let t=new AbortController;_([]),y(!1),x(!1),C(!0);let i=window.setTimeout(()=>{PO(n,e,{taskId:r,signal:t.signal}).then(e=>{_(e.matches),y(e.truncated)}).catch(e=>{e?.name!==`AbortError`&&(_([]),y(!1),x(!0))}).finally(()=>{t.signal.aborted||C(!1)})},150);return()=>{window.clearTimeout(i),t.abort()}},re=[n,k,c,r],t[30]=n,t[31]=k,t[32]=c,t[33]=r,t[34]=ne,t[35]=re):(ne=t[34],re=t[35]),(0,Q.useEffect)(ne,re);let ie,ae;t[36]===j.length?(ie=t[37],ae=t[38]):(ie=()=>{T(e=>Math.min(e,Math.max(0,j.length-1)))},ae=[j.length],t[36]=j.length,t[37]=ie,t[38]=ae),(0,Q.useEffect)(ie,ae);let oe,se;t[39]!==w||t[40]!==j||t[41]!==a||t[42]!==p||t[43]!==s||t[44]!==o?(oe=()=>{let e=j[w],t=o.current;if(!t||!e){WO(p,-1);return}let n=e.displayIndex-a,r=p.findIndex(t=>t.messageIndex===n&&t.occurrence===e.occurrence);WO(p,r),r>=0?KO(t,p[r]):s(e.displayIndex)},se=[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]=oe,t[46]=se):(oe=t[45],se=t[46]),(0,Q.useLayoutEffect)(oe,se);let ce;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(ce=[],t[47]=ce):ce=t[47],(0,Q.useEffect)(ZO,ce);let le,ue;t[48]!==n||t[49]!==c?(le=()=>{O.current!==n&&(O.current=n,c&&z())},ue=[z,n,c],t[48]=n,t[49]=c,t[50]=le,t[51]=ue):(le=t[50],ue=t[51]),(0,Q.useEffect)(le,ue);let K,q;t[52]===U?(K=t[53],q=t[54]):(K=()=>U(-1),q=()=>U(1),t[52]=U,t[53]=K,t[54]=q);let de;return t[55]!==w||t[56]!==j.length||t[57]!==b||t[58]!==c||t[59]!==u||t[60]!==v||t[61]!==S||t[62]!==F||t[63]!==K||t[64]!==q?(de={open:c,query:u,inputRef:E,activeIndex:w,resultCount:j.length,truncated:v,limitedToLoaded:b,searching:S,setQuery:V,show:F,close:z,previous:K,next:q},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]=K,t[64]=q,t[65]=de):de=t[65],de}function ZO(){return QO}function QO(){return GO()}function $O(e){return e.length===0?e:[]}function ek(e,t){return e.displayIndex-t.displayIndex||e.occurrence-t.occurrence}function tk(e){return[JO(e),e]}function nk(e){let t=String(e??``).trim();return!t||t===`new`?null:t}function rk(e){let t=String(e.streamConversationId??``).trim(),n=nk(e.routeConversationId);return!t||!n?!1:t===n}function ik(e){let t=nk(e.routeConversationId);return t?e.cacheConversationId===t:!1}function ak(e){let t=String(e.chatId??``).trim();if(!t)return!1;let n=nk(e.routeConversationId);return n?n===t:!1}function ok(e,t){return e?`new`:t??null}function sk(e,t){if(!(e||!t))return decodeURIComponent(t)}function ck(e){if(!e.viewConversationId||e.conversationId!==e.viewConversationId)return[];if(!e.streamingMsg)return e.messages;let t=e.messages[e.messages.length-1];if(t?.role===`assistant`&&e.streamingMsg.role===`assistant`){let n=dr([t,e.streamingMsg]);return[...e.messages.slice(0,-1),...n]}return[...e.messages,e.streamingMsg]}function lk(e,t){let n=e[e.length-1];return n?.role!==`assistant`||n.turnId!==t?null:{messagesWithoutTail:e.slice(0,-1),tail:n}}function uk(e){e()}function dk(e,t){return!!(e&&(e.localDraft||e.configVersion!==void 0)&&t?.some(t=>t.id===e.model))}function fk(e){e.sendingRef.current=!1,e.streamingRef.current=!1}function pk(e){return e.isNewRoute?`creating-session`:e.sessionRoutePending||e.showSessionLoading||e.sessionContentLoading?`loading-history`:e.messageCount===0?`ready-empty`:`ready-conversation`}var mk=new Map;async function hk(e,t,n,r,i){let a=m.getState(),o=Tr([a.baseUrl,a.conversationId,e,t]),s=Tr({action:n,submission:r}),c=mk.get(o);if(c){if(c.signature!==s)throw Error(`An answer is already being submitted`);return(await c.promise).clone()}let l=gk(e,t,n,r,i).then(e=>{for(e.ok||mk.delete(o);mk.size>64;)mk.delete(mk.keys().next().value);return e},e=>{throw mk.delete(o),e});return mk.set(o,{signature:s,promise:l}),(await l).clone()}async function gk(e,t,n,r,i){let a=m.getState().conversationId,o=uf(e,t,`submission`,i),s={schemaVersion:2,action:n,...r,expectedVersion:t},c=Tr(s),l=await o.read();if(l&&l.signature!==c)throw Error(`The previous answer is awaiting confirmation. Retry the original answer before changing it.`);let u=l??{signature:c,body:{...s,idempotencyKey:crypto.randomUUID()}};if(await o.write(u),window.dispatchEvent(new CustomEvent(`clarification-submission-state`,{detail:{requestId:e,pending:!0}})),m.getState().conversationId!==a)throw Error(`Active Gateway changed`);let d=await f(p(`/api/clarifications/${encodeURIComponent(e)}/responses`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(u.body)});return(d.ok||d.status>=400&&d.status<500)&&(await o.write(void 0),window.dispatchEvent(new CustomEvent(`clarification-submission-state`,{detail:{requestId:e,pending:!1}})),d.ok&&await uf(e,t,`draft`,i).write(void 0)),d}async function _k(e,t,n){let r=()=>{if(!n())throw new DOMException(`Conversation changed`,`AbortError`)},i=await Or(e);if(r(),i&&(i.kind!==`append`||i.execution||i.delivery!==t.delivery||Tr(i.input)!==Tr(t.input)||!!i.interrupt!=!!t.interrupt))throw Error(`The previous input is awaiting confirmation`);let a=kr.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 f(p(`/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 jr(e,a.clientMessageId),r(),t);if(i){let e=await s();if(e!==void 0)return c(e)}let{origin:l,...u}=a;await Mr(e,u),r();let d,m;try{d=await f(p(`/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`);m=o(t.payload)}catch(t){if(r(),d&&d.status>=400&&d.status<500&&d.status!==408)throw await jr(e,a.clientMessageId),t;if(m=await s(AbortSignal.timeout(3e3)).catch(()=>void 0),r(),m===void 0)throw t}return c(m)}function vk(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:{...Vn(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 yk(e){let{conversationId:t,decodedKey:n,conversationIdRef:r,sendingRef:i,streamingRef:a,modelSupportsThinking:o,thinkingLevel:s,shouldApplyStreamUpdate:c}=e,l=m(e=>e.conversationId),u=(0,Q.useRef)({gateway:l,conversationId:t});(u.current.gateway!==l||u.current.conversationId!==t)&&(u.current={gateway:l,conversationId:t});let d=(0,Q.useCallback)(()=>{let e=u.current;return()=>u.current===e&&r.current===e.conversationId&&m.getState().conversationId===e.gateway},[r]),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(null),x=(0,Q.useRef)(null),S=(0,Q.useRef)(0),C=(0,Q.useRef)(null),[w,T]=(0,Q.useState)([]),E=(0,Q.useRef)([]),[D,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(()=>({scope:u.current,mode:{kind:`compose`}})),j=k.scope===u.current?k.mode:{kind:`compose`},M=(0,Q.useCallback)(e=>A({scope:u.current,mode:e}),[]),N=(0,Q.useRef)(j);N.current=j;let P=j.kind===`editFollowUp`?j.inputId:null,F=e=>M(e?{kind:`editFollowUp`,inputId:e,version:E.current.find(t=>t.id===e)?.version??0}:{kind:`compose`}),[I,L]=(0,Q.useState)(()=>$n(t??``)),[R,z]=(0,Q.useState)(!1),B=(0,Q.useRef)(!1),V=(0,Q.useRef)(null),H=(0,Q.useRef)(-1);x.current=h,E.current=w,V.current=P;let U=(0,Q.useCallback)(e=>{if(!e||typeof e!=`object`)return;let t=e;if(t.conversationId!==r.current||typeof t.revision!=`number`||!Array.isArray(t.inputs)||t.revision<H.current)return;if(t.control){if(!Hn(t.conversationId,t.control,t.revision))return;L(t.control)}let n=rT({control:t.control,inputs:t.inputs,activeRunId:t.activeRunId,preparation:t.preparation});H.current=t.revision,E.current=n,T(n)},[r]),W=(0,Q.useCallback)(async e=>{if(e!==r.current)return;let t=d();if(await wr(e)||!t())return;let n=await f(p(`/api/sessions/${encodeURIComponent(e)}/input-state`)).catch(()=>null);if(!n?.ok||r.current!==e)return;let i=await n.json().catch(()=>null);t()&&U(i?.payload)},[U,d,r]),G=(0,Q.useCallback)(async e=>{if(e!==r.current)return;let t=d(),n=++S.current;if(await wr(e)||!t())return;let i=await f(p(`/api/sessions/${encodeURIComponent(e)}/clarification`)).catch(()=>null);if(!i?.ok||r.current!==e)return;let a=await i.json().catch(()=>null);!t()||n!==S.current||r.current!==e||(b(null),g(vk(a?.payload,e)),C.current=null)},[d,r]);(0,Q.useLayoutEffect)(()=>{H.current=-1,B.current=!1,z(!1),O(null),S.current++,L($n(t??``)),M({kind:`compose`}),E.current=[],T([]),F(null),g(null)},[t,l]),(0,Q.useEffect)(()=>{!t||t!==n||(W(t),G(t))},[n,G,W,t,l]),(0,Q.useEffect)(()=>{let e=e=>{let t=e.detail;U(t);let n=r.current;n&&t&&typeof t==`object`&&t.conversationId===n&&G(n)},t=e=>{let t=r.current;if(!t)return;let n=e.detail;if(n&&typeof n==`object`){let e=n.conversationId;if(typeof e==`string`&&e!==t)return}b(null),S.current++,g(vk(n,t)),C.current=null},n=()=>{let e=r.current;e&&(W(e),G(e))};return window.addEventListener(`session-input-state`,e),window.addEventListener(`clarification-updated`,t),window.addEventListener(`gateway-realtime-connected`,n),()=>{window.removeEventListener(`session-input-state`,e),window.removeEventListener(`clarification-updated`,t),window.removeEventListener(`gateway-realtime-connected`,n)}},[U,G,W,r]),(0,Q.useEffect)(()=>{if(!h?.expiresAt)return;let e=Math.max(0,h.expiresAt-Date.now())+250,t=window.setTimeout(()=>{let e=r.current;e&&G(e)},e);return()=>window.clearTimeout(t)},[h?.expiresAt,G,r]);let ee=(0,Q.useCallback)(()=>{b(null),g(null)},[]),te=(0,Q.useCallback)(e=>{let t=String(e??``).trim();t&&r.current===t&&(b(null),g(null))},[r]),ne=(0,Q.useCallback)(()=>{b(null),g(null)},[]),re=(0,Q.useCallback)(()=>{F(null)},[]),ie=(0,Q.useCallback)(()=>{b(null),g(null),F(null)},[]),ae=(0,Q.useCallback)(e=>t=>{c(e)&&(i.current=!1,a.current=!1,Nn.getState().setSessionFlags(e,{sending:!1,streaming:!1}),Nn.getState().setSessionProgress(e,null),b(null),S.current++,g({...t,conversationId:e}),C.current=null)},[c,i,a]),oe=(0,Q.useCallback)(async(e,t,n,i,a,o)=>{let s=e.trim();if(!s&&!t?.length&&!n?.length)return;let c=r.current;if(!c)throw Error(`No active session`);let l=d(),u=$n(c),f=await Ar(c);if(!l())throw new DOMException(`Conversation changed`,`AbortError`);let p=await ir();if(!l())throw new DOMException(`Conversation changed`,`AbortError`);if(!f)throw Error(`Reload the conversation before sending`);let m=Nn.getState().sessions[c]?.configVersion;if(m===void 0)throw Error(`Reload the conversation before sending`);let h=await _k(c,{kind:`append`,expectedTranscriptId:f,configVersion:m,clientMessageId:crypto.randomUUID(),delivery:o??`next`,interrupt:a,controlVersion:u.version,input:{content:s||e,attachments:t?.length?t:void 0,contextRefs:n?.map(({refId:e,kind:t,sourceId:n,expectedVersion:r})=>({refId:e,kind:t,sourceId:n,expectedVersion:r})),appContext:i},origin:p},l);l()&&U(h)},[U,d,r]),se=(0,Q.useCallback)(async(e,t)=>{let n=r.current;if(!n||B.current)throw Error(`Wait for the current operation`);let i=d(),a=()=>{if(!i())throw new DOMException(`Conversation changed`,`AbortError`)};B.current=!0,z(!0);try{let r=await Ar(n);a();let i=Date.now()+15e3;for(;!r&&e===`stop`&&Date.now()<i;)await new Promise(e=>setTimeout(e,100)),r=await Ar(n),a();if(!r)throw Error(`Input acceptance is awaiting confirmation`);let o={action:e,operationId:crypto.randomUUID(),expectedTranscriptId:r,expectedVersion:$n(n).version,...t},s=await cr(n,o);if(a(),U(s),e===`steer`){let e=s.inputs?.find(e=>e.id===t?.inputId);if(e?.status===`interrupted`)throw Error(e.error??`Current reply ended before steering`)}if(e===`stop`){let e=Date.now()+15e3;for(;$n(n).phase===`stopping`;){if(a(),Date.now()>=e)throw Error(`Stop is awaiting confirmation`);await new Promise(e=>setTimeout(e,100)),await W(n)}}if(a(),e===`stop`||e===`pause`){let t=$n(n);if(!t.paused||t.version!==o.expectedVersion+1)throw Error(`Queue control changed on another device`);if(e===`stop`&&t.phase!==`idle`)throw Error(`Another input has started`)}}catch(e){throw!i()||(await W(n),!i())||ya(`error`,e instanceof Error?e.message:String(e)),e}finally{i()&&(B.current=!1,z(!1))}},[U,d,r,W]),ce=(0,Q.useCallback)(()=>se(`stop`),[se]),le=(0,Q.useCallback)(()=>se(`resume`),[se]),ue=(0,Q.useCallback)(async(e,t)=>{let n=d();try{return await se(`stop`,{turnId:e}),n()?(M({kind:`editTurn`,turnId:e,draft:t}),!0):!1}catch{return!1}},[d,se]),K=(0,Q.useCallback)(async e=>{let t=E.current.find(t=>t.id===e);if(!t)return!1;let n=d();try{return await se(`pause`,{inputId:e,inputVersion:t.version}),n()?(M({kind:`editFollowUp`,inputId:e,version:t.version}),!0):!1}catch{return!1}},[d,se]),q=(0,Q.useCallback)(()=>M({kind:`compose`}),[]),de=(0,Q.useCallback)(async(e,t,n,i,a)=>{let c=r.current;if(!c||j.kind!==`editFollowUp`||j.inputId!==e||!t.trim()&&!n?.length&&!a?.length)return!1;let l=d(),u=await f(p(`/api/sessions/${encodeURIComponent(c)}/inputs/${encodeURIComponent(e)}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({version:j.version,content:t,attachments:n??[],thinking:o?i??s:`off`,contextRefs:(a??[]).map(({refId:e,kind:t,sourceId:n,expectedVersion:r})=>({refId:e,kind:t,sourceId:n,expectedVersion:r}))})}),m=await u.json();if(!l())return!1;if(U(m.payload),!u.ok)throw Error(m.error?.message??`This input changed; your draft has been preserved`);if(N.current===j){let t=m.payload?.inputs?.find(t=>t.id===e);t&&M({...j,version:t.version})}return!0},[U,d,j,r,o,s]),fe=(0,Q.useCallback)(e=>{V.current===e&&F(null);let t=r.current,n=E.current.find(t=>t.id===e);if(!t||!n)return;let i=d();f(p(`/api/sessions/${encodeURIComponent(t)}/inputs/${encodeURIComponent(e)}?version=${n.version}`),{method:`DELETE`}).then(async e=>{let t=await e.json().catch(()=>null);i()&&U(t?.payload)}).catch(()=>{W(t)})},[U,d,W,r]),pe=(0,Q.useCallback)((e,t)=>{let n=E.current.filter(e=>e.status===`queued`),i=n.findIndex(t=>t.id===e);if(i<0)return;let a=t===`up`?i-1:i+1,o=r.current,s=n[i];if(!o||!s||a<0||a>=n.length)return;let c=d();f(p(`/api/sessions/${encodeURIComponent(o)}/inputs/${encodeURIComponent(s.id)}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({version:s.version,position:a})}).then(async e=>{let t=await e.json().catch(()=>null);c()&&U(t?.payload)}).catch(()=>{W(o)})},[U,d,W,r]),J=(0,Q.useCallback)((e,t)=>{let n=r.current,i=E.current[e],a=E.current[t],o=E.current.filter(e=>e.status===`queued`),s=a?o.findIndex(e=>e.id===a.id):-1;if(!n||i?.status!==`queued`||a?.status!==`queued`||s<0)return;let c=d();f(p(`/api/sessions/${encodeURIComponent(n)}/inputs/${encodeURIComponent(i.id)}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({version:i.version,position:s})}).then(async e=>{let t=await e.json().catch(()=>null);c()&&U(t?.payload)}).catch(()=>{W(n)})},[U,d,W,r]),me=(0,Q.useCallback)(async(e,t)=>{let n=E.current.find(t=>t.id===e);if(!n)return;let r=d();O(e);try{await se(t,{inputId:e,inputVersion:n.version})}finally{r()&&O(null)}},[d,se]),he=(0,Q.useCallback)(e=>me(e,`steer`),[me]),ge=(0,Q.useCallback)(e=>me(e,`send`),[me]),_e=(0,Q.useCallback)(async(e,t)=>{let n=x.current;if(!n)return;let i=JSON.stringify([n.requestId,n.version,e,t]);C.current?.signature!==i&&(C.current={signature:i,idempotencyKey:crypto.randomUUID()});let a=C.current.idempotencyKey;v(!0),b(null);try{let i=n.schemaVersion===2?await hk(n.requestId,n.version,e,t,r.current??void 0):await f(p(`/api/clarifications/${encodeURIComponent(n.requestId)}/responses`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:e,...t,expectedVersion:n.version,idempotencyKey:a})});if(x.current?.requestId!==n.requestId)return;if(!i.ok){let e=await i.json().catch(()=>({}));b(e.error?.message??i.statusText??`Clarify failed`);let t=r.current;t&&(i.status===409||i.status===410)&&G(t);return}C.current=null,g(null),b(null)}catch(e){x.current?.requestId===n.requestId&&b(e instanceof Error?e.message:String(e))}finally{v(!1)}},[G,r]);return{clarifyPrompt:h,clarifySubmitting:_,clarifySubmitError:y,clarifyPromptRef:x,pendingFollowUps:w,pendingFollowUpsRef:E,steeringFollowUpId:D,composerMode:j,control:I,controlPending:R,stopSession:ce,resumeQueue:le,sendQueuedInput:ge,beginEditTurn:ue,cancelEditor:q,restoreEditor:M,editingFollowUpId:P,addPendingFollowUp:oe,beginEditFollowUp:K,cancelEditFollowUp:q,commitEditFollowUp:de,removePendingFollowUp:fe,movePendingFollowUp:pe,reorderPendingFollowUp:J,steerPendingFollowUp:he,submitClarifyAnswer:(0,Q.useCallback)(e=>_e(`answer`,e),[_e]),letAgentDecideClarification:(0,Q.useCallback)(()=>_e(`agent_decide`),[_e]),cancelClarification:(0,Q.useCallback)(()=>_e(`cancel`),[_e]),clearVisibleClarify:ee,dismissClarify:ne,dismissClarifyForSession:te,clearPendingFollowUps:re,dismissClarifyAndClearPending:ie,makeOnClarifyRequest:ae}}async function bk(e){let t=await wr(e);if(t)return{agentId:t.creation.agentId.trim().toLowerCase(),projectId:t.creation.projectId?.trim()||null};let n=await un(e);return{agentId:(n.routing?.agentId??n.agentId).trim().toLowerCase(),projectId:n.projectId?.trim()||null}}function xk(e){let t=(0,X.c)(59),{navigate:n,conversationIdRef:r,conversationId:i,isNewRoute:a,locationState:o,locationSearch:s,personal:c}=e,l=c!==void 0&&c,u=m(Tk),d;t[0]===i?d=t[1]:(d=i?.trim()??``,t[0]=i,t[1]=d);let f=d,p;t[2]===u?p=t[3]:(p=u?[`gateway-chat-agents`,u]:null,t[2]=u,t[3]=p);let h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h={revalidateOnFocus:!1},t[4]=h):h=t[4];let{data:g,mutate:_}=Gr(p,ni,h),v;t[5]!==f||t[6]!==u?(v=u&&f?[`gateway-chat-session-agent`,u,f]:null,t[5]=f,t[6]=u,t[7]=v):v=t[7];let y;t[8]===f?y=t[9]:(y=()=>bk(f),t[8]=f,t[9]=y);let b;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(b={revalidateOnFocus:!1},t[10]=b):b=t[10];let{data:x}=Gr(v,y,b),S=x?.agentId??``,C,w;t[11]===_?(C=t[12],w=t[13]):(C=()=>{let e=e=>{ti(e.detail)||_()};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},w=[_],t[11]=_,t[12]=C,t[13]=w),(0,Q.useEffect)(C,w);let[T,E]=(0,Q.useState)(wk),D=(0,Q.useRef)(g??null),O;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(O=Hr().selectedAgentId??null,t[14]=O):O=t[14];let k=(0,Q.useRef)(O),A,j;t[15]===g?(A=t[16],j=t[17]):(A=()=>{D.current=g??null},j=[g],t[15]=g,t[16]=A,t[17]=j),(0,Q.useEffect)(A,j);let M,N;t[18]===T?(M=t[19],N=t[20]):(M=()=>{k.current=T},N=[T],t[18]=T,t[19]=M,t[20]=N),(0,Q.useEffect)(M,N);let P,F;t[21]===g?(P=t[22],F=t[23]):(P=()=>{if(!g)return;let e=new Set(g.items.map(Ck));E(t=>t==null||t===``||!e.has(t)?g.defaultId:t)},F=[g],t[21]=g,t[22]=P,t[23]=F),(0,Q.useEffect)(P,F);let I;t[24]!==r||t[25]!==S?(I=()=>{if(r.current&&S)return S;let e=D.current,t=(k.current??``).trim().toLowerCase();if(!e)return t||void 0;let n=new Set(e.items.map(Sk));return t&&n.has(t)?t:e.defaultId},t[24]=r,t[25]=S,t[26]=I):I=t[26];let L=I,R;t[27]!==r||t[28]!==S||t[29]!==x?.projectId||t[30]!==a||t[31]!==s||t[32]!==o||t[33]!==n?(R=e=>{let t=e.trim().toLowerCase(),i=r.current?S||k.current:null;k.current=t,E(t),Pr(t),i!==t&&n(a?`/chat/new${s}`:Xr(x?.projectId),{replace:!1,state:{...a&&o&&typeof o==`object`?o:{},agentId:t,forceNewChat:!0}})},t[27]=r,t[28]=S,t[29]=x?.projectId,t[30]=a,t[31]=s,t[32]=o,t[33]=n,t[34]=R):R=t[34],x?.projectId;let z=R,B,V;t[35]===z?(B=t[36],V=t[37]):(B=()=>{let e=e=>{let t=e.detail?.agentId;typeof t!=`string`||!t.trim()||z(t)};return window.addEventListener(`xopc-set-chat-agent`,e),()=>window.removeEventListener(`xopc-set-chat-agent`,e)},V=[z],t[35]=z,t[36]=B,t[37]=V),(0,Q.useEffect)(B,V);let H,U;t[38]!==i||t[39]!==S||t[40]!==l?(H=()=>{if(!i||l)return;let e=S;!e||k.current===e||(k.current=e,E(e),Pr(e))},U=[S,i,l],t[38]=i,t[39]=S,t[40]=l,t[41]=H,t[42]=U):(H=t[41],U=t[42]),(0,Q.useLayoutEffect)(H,U);let W,G;t[43]!==i||t[44]!==x?(W=()=>{!i||!x||Br(x.projectId)},G=[x,i],t[43]=i,t[44]=x,t[45]=W,t[46]=G):(W=t[45],G=t[46]),(0,Q.useLayoutEffect)(W,G);let ee,te;t[47]!==a||t[48]!==o?(ee=()=>{if(!a)return;let e=o,t=typeof e?.agentId==`string`?e.agentId.trim().toLowerCase():``;t&&(k.current=t,E(t),Pr(t))},te=[a,o],t[47]=a,t[48]=o,t[49]=ee,t[50]=te):(ee=t[49],te=t[50]),(0,Q.useLayoutEffect)(ee,te);let ne=S||T||g?.defaultId||`main`,re=(g?.items.length??0)>1,ie=x?.projectId??null,ae;return t[51]!==g||t[52]!==ne||t[53]!==z||t[54]!==L||t[55]!==re||t[56]!==ie||t[57]!==u?(ae={token:u,chatAgentsData:g,resolveAgentIdForPost:L,onChatAgentChange:z,displayAgentId:ne,showChatAgentSelector:re,currentSessionProjectId:ie},t[51]=g,t[52]=ne,t[53]=z,t[54]=L,t[55]=re,t[56]=ie,t[57]=u,t[58]=ae):ae=t[58],ae}function Sk(e){return e.id}function Ck(e){return e.id}function wk(){return Hr().selectedAgentId??null}function Tk(e){return e.conversationId}async function Ek(e){let t=await e.sessionMgr.createSession(e);return{kind:`create`,conversationId:t.key,session:t}}var Dk=new Map,Ok=0;function kk(e){let t=m.getState(),n=Fr(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=Dk.get(r);if(i)return i.target.opts=e,i.target.generation=++Ok,i.promise;let a={opts:e,generation:++Ok},o=e=>{if(a.generation!==Ok)return;let t=a.opts;!t.routeConversationId&&mi.getState().scope===`new`&&mi.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 Ek({sessionMgr:e.sessionMgr,agentId:t?.trim()||`main`,projectId:e.projectId,currentConversationId:e.currentConversationId,forceNew:e.forceNew,temporary:e.temporary,initialAgentConfig:e.initialAgentConfig,executionMode:e.executionMode});return o(n),n})().finally(()=>{Dk.delete(r)});return Dk.set(r,{promise:s,target:a}),s}var Ak={current:null},jk={current:null};function Mk(e){return!!(e&&typeof e==`object`&&e.forceNewChat===!0)}function Nk(e){let t=c(),{conversationId:n}=s(),r=!e&&t.pathname.endsWith(`/new`),i=r&&Mk(t.state),a=e??sk(r,n),o=ok(r,a),l=nk(o),u=r?null:a??null,d=(0,Q.useRef)(o);return d.current=o,Ak.current=u,!r&&a&&(jk.current=a),(0,Q.useLayoutEffect)(()=>{Nn.getState().focusedConversationId!==u&&Nn.getState().setFocusedConversationId(u)},[u]),{isNewRoute:r,forceNewChat:i,decodedKey:a,routedConversationId:o,viewConversationId:l,routedFocusedConversationId:u,routeConversationIdRef:d,locationKey:t.key,locationSearch:t.search,locationState:t.state}}var Pk={get current(){return jk.current}},Fk={get current(){return Ak.current},set current(e){Ak.current=e,Nn.getState().setFocusedConversationId(e)}};function Ik(e){let{token:t,isNewRoute:n,forceNewChat:r,temporary:i=!1,requestedAgentId:a,decodedKey:o,locationKey:s,locationSearch:c,sessionMgrRef:l,resolveAgentIdForPost:u,navigateToSession:d,loadSessionById:f,tryResumeAgentRun:p,restoreLiveCacheIfNeeded:h,adoptEmptySession:g,applyAgentConfig:_,patchInitUi:v}=e,y=(0,Q.useRef)(0),b=m(e=>e.baseUrl),[x,S]=(0,Q.useState)(null),C=n?c:``,w=n?`new:${s}`:o?`session:${o}`:`fallback:${s}`,T=(0,Q.useRef)({isNewRoute:n,forceNewChat:r,temporary:i,requestedAgentId:a,decodedKey:o,newRouteLocationSearch:C});T.current={isNewRoute:n,forceNewChat:r,temporary:i,requestedAgentId:a,decodedKey:o,newRouteLocationSearch:C};let E=(0,Q.useRef)({sessionMgrRef:l,resolveAgentIdForPost:u,navigateToSession:d,loadSessionById:f,tryResumeAgentRun:p,restoreLiveCacheIfNeeded:h,adoptEmptySession:g,applyAgentConfig:_,patchInitUi:v});return E.current={sessionMgrRef:l,resolveAgentIdForPost:u,navigateToSession:d,loadSessionById:f,tryResumeAgentRun:p,restoreLiveCacheIfNeeded:h,adoptEmptySession:g,applyAgentConfig:_,patchInitUi:v},(0,Q.useEffect)(()=>{let e=T.current,n=E.current;if(!t){n.patchInitUi({loading:!1});return}let r=++y.current,i=!1,a=()=>!i&&r===y.current,o=e=>{a()&&n.sessionMgrRef.current.loadSessionAgentConfig(e).then(t=>{a()&&n.applyAgentConfig(e,t)}).catch(()=>{})},s=async()=>{if(!a())return Promise.resolve();let r=Hr(),i=n.resolveAgentIdForPost(),s=Lr({origin:`web-route`,project:Qr(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 sn(s.projectId):null;if(!a())return;!e.requestedAgentId&&c?.defaultAgentId&&(s.agentId=c.defaultAgentId);let l=Vr(r,s.agentId),u=(t,r,i)=>kk({sessionMgr:n.sessionMgrRef.current,agentId:s.agentId,currentConversationId:Pk.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:Kr(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=Un(e)?.messages??t??yr(e);return n.tryResumeAgentRun(e,r)},l=e=>a()?Un(e)?.historyStatus===`ready`?(o(e),c(e,yr(e))):n.loadSessionById(e,0).then(t=>{if(a())return c(e,t??yr(e))}):Promise.resolve(),u=()=>a()?n.sessionMgrRef.current.loadSessions().then(e=>{if(!a())return;let t=e.filter(e=>(e.messageCount??0)>0)[0]??e[0];if(t)return a()?n.loadSessionById(t.key,0).then(e=>{if(!a())return;n.restoreLiveCacheIfNeeded(t.key);let r=Un(t.key)?.messages??e??yr(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 kk({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 Lk(e){let t=m(e=>e.conversationId),n=m(e=>e.baseUrl),[r,i]=(0,Q.useState)(null),{data:a,error:o}=Gr(e?[`prepared-session-model`,n,t,e.create]:null,async()=>{let t=Vr(Hr(),e.agentId),[n,r]=await Promise.all([ui(),t?.modelRef??fi(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?Ur(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&&Rr(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=Vr(Hr(),e.agentId)?.thinkingByModel?.[t],c=r.thinking?Ur(r.thinking,n??s?.thinkingLevel,n===void 0?o:void 0):n??s?.thinkingLevel??`medium`;i({preparation:e,selection:{model:t,thinkingLevel:c}})};return{preparation:f,model:s?.model??``,thinkingLevel:s?.thinkingLevel??`medium`,modelSupportsThinking:!!c?.reasoning,ready:l,error:o,onModelChange:e=>p(e),onThinkingChange:e=>p(s?.model??``,e)}}async function Rk(e){let t=e.trim();if(!t)return!1;try{return!!(await ui()).find(e=>e.id===t)?.reasoning}catch{return!1}}function zk(e){let{sessionMgrRef:t,routeConversationIdRef:n,sendingRef:r,streamingRef:i,loadingSessionRef:a,messagesLenRef:o,thinkingSupportGenRef:s,navigateToSession:c,resolveAgentIdForPost:l,detachForNewConversation:u,conversationId:d,sessionAgentId:f,currentProjectId:p,taskId:m,hasMore:h}=e,g=()=>Nn.getState(),_=(0,Q.useRef)(Promise.resolve(void 0)),v=(0,Q.useRef)(null),y=(0,Q.useRef)(0),b=(0,Q.useCallback)(e=>{let t=g().focusedConversationId;if(!e.trim())return++s.current===s.current&&t&&g().patchSessionMeta(t,{modelSupportsThinking:!1}),Promise.resolve();let n=++s.current;return Rk(e).then(t=>{if(n!==s.current)return;let r=g().focusedConversationId;r&&g().sessions[r]?.model===e&&g().patchSessionMeta(r,{modelSupportsThinking:t})})},[s]),x=(0,Q.useCallback)(async e=>{try{let n=await t.current.loadSessionAgentConfig(e);Kn(e,n),b(n.model)}catch{}},[t,b]),S=(0,Q.useCallback)(()=>{let e=g().focusedConversationId;if(!e||(g().sessions[e]?.name)?.trim())return;let n=++y.current,r=[700,900,900,1e3,1e3],i=a=>{a>=5||n===y.current&&g().focusedConversationId===e&&(g().sessions[e]?.name?.trim()||window.setTimeout(()=>{n===y.current&&g().focusedConversationId===e&&(g().sessions[e]?.name?.trim()||t.current.fetchSessionName(e).then(t=>{if(n===y.current){if(t){g().patchSessionMeta(e,{name:t});return}i(a+1)}}).catch(()=>{i(a+1)}))},r[a]??900))};i(0)},[t]),C=(0,Q.useCallback)(e=>ak({chatId:e,routeConversationId:n.current}),[n]),w=(0,Q.useCallback)((e,t,n)=>{let r=g().sessions[e];if(n&&r?.messages!==n.messages&&!hn(r))return!1;let i=t.hasMore&&xr(r?.messages??[],t.messages)>0;return g().mergeCommittedFromServer(e,t.messages,t.hasMore),t.name!==void 0&&g().patchSessionMeta(e,{name:t.name||null}),C(e)&&(i||(v.current=t.nextBeforeCursor??null)),!0},[C]),T=(0,Q.useCallback)(async(e,r=0,i)=>{let o=async(e,r,i)=>{let s=r===0&&!i;a.current=!0;let u=s&&vr(g().sessions[e]?.historyStatus);u&&g().setSessionHistoryStatus(e,`loading`);try{let n={messages:g().sessions[e]?.messages},{messages:a,hasMore:o,name:c,nextBeforeCursor:l}=await t.current.loadSession(e,r,i,m,n.messages);if(s){if(!w(e,{messages:a,hasMore:o,name:c,nextBeforeCursor:l},n))return g().sessions[e]?.messages;if(!C(e))return a;let r=await t.current.loadSessionAgentConfig(e);return C(e)?(Kn(e,r),b(r.model),a):a}if(v.current=l??null,!C(e))return;g().prependHistoryMessages(e,a,o);return}catch(a){if(r===0&&!i){v.current=null;let r=a instanceof Error?a.message:`Failed to load session`;g().setShellError(/^HTTP 404\b/.test(r)?JSON.stringify(Yn(r)):`Failed to load session`);let i=nk(n.current);if(i&&i===e)return;let s=await t.current.loadSessions().catch(()=>[]),u=s.filter(e=>(e.messageCount??0)>0)[0]??s[0];if(u)return c(u.key,!0),await o(u.key,0,null);{v.current=null;let e=l();kk({sessionMgr:t.current,agentId:e,currentConversationId:null,routeConversationId:null,navigateToSession:c,replaceNavigate:!0,onOpened:e=>{g().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:null}),x(e)}})}}return}finally{a.current=!1,u&&g().sessions[e]?.historyStatus===`loading`&&g().setSessionHistoryStatus(e,`ready`)}},s=_.current,u,d=new Promise(e=>{u=e});_.current=s.then(()=>d),await s;try{return await o(e,r,i)}finally{u()}},[n,C,r,i,a,c,b,l,t,m,w]),E=(0,Q.useCallback)(async()=>{let e=g().focusedConversationId;if(!(!e||g().loadingMore||!h)){g().setLoadingMore(!0);try{await T(e,o.current,v.current)}finally{g().setLoadingMore(!1)}}},[h,T,o]),D=(0,Q.useCallback)(async(e,n)=>{if(!d)throw Error(`No active session`);let r=g().sessions[d];if(r?.modelConfigSaving)throw Error(`Model configuration is being saved`);if(!(r?.model===e&&n!==void 0&&r.thinkingLevel===n)){g().patchSessionMeta(d,{modelConfigSaving:!0});try{if(g().setShellError(null),n===void 0){let t=(await ui()).find(t=>t.id===e);if(t?.thinking){let i=Vr(Hr(),f)?.thinkingByModel?.[e];n=Ur(t.thinking,r?.thinkingLevel,i)}}let i=m?await t.current.patchTaskConversationModel(m,e,n,r?.configVersion):await t.current.patchSessionAgentConfig(d,{model:e,thinkingLevel:n,configVersion:r?.configVersion});Kn(d,i),Rr(f,{modelRef:i.model,thinkingLevel:i.thinkingLevel}),i.model!==r?.model&&b(i.model)}catch(e){let n=e instanceof Error?e.message:`Failed to update model configuration`;g().setShellError(n);let r=await t.current.loadSessionAgentConfig(d).catch(()=>null);throw r&&Kn(d,r),e}finally{g().patchSessionMeta(d,{modelConfigSaving:!1})}}},[d,f,m,t,b]);return{refreshModelThinkingSupport:b,pollSessionNameAfterTurn:S,applyLoadedSessionSnapshot:w,loadSessionById:T,loadMoreMessages:E,onSessionModelChange:D,onSessionThinkingLevelChange:(0,Q.useCallback)(async e=>{let t=d?g().sessions[d]?.model:void 0;t&&await D(t,e)},[d,D]),onSessionWorkingDirectoryChange:(0,Q.useCallback)(async e=>{let n=e.trim();if(!(!d||!n))try{g().setShellError(null),await t.current.patchSessionAgentConfig(d,{workingDirectory:n}),await x(d)}catch(e){throw g().setShellError(e instanceof Error?e.message:`Failed to update working directory`),e}},[x,d,t]),createNewSession:(0,Q.useCallback)(async e=>{g().setShellError(null);let n=l(),r=Vr(Hr(),n??`main`);await kk({sessionMgr:t.current,agentId:n,currentConversationId:d,routeConversationId:d,forceNew:e?.forceNew,temporary:e?.temporary,executionMode:e?.executionMode,projectId:e?.projectId===void 0?p:e.projectId,initialAgentConfig:r?{model:r.modelRef,...r.thinkingLevel?{thinkingLevel:r.thinkingLevel}:{}}:void 0,navigateToSession:c,onOpened:e=>{u(),v.current=null,g().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:null}),x(e)}})},[u,c,l,p,d,t,x]),resetCurrentSession:(0,Q.useCallback)(async()=>{if(d){g().setShellError(null);try{await t.current.resetSession(d),u(),v.current=null,g().setCommittedSnapshot(d,{messages:[],hasMore:!1,name:null}),x(d)}catch(e){g().setShellError(e instanceof Error?e.message:`Failed to reset session`)}}},[x,d,u,t])}}function Bk(e){return new Promise(t=>{Promise.resolve().then(()=>e(()=>t(!0))).then(()=>t(!1),()=>t(!1))})}function Vk(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 Hk(e){return e!==`suspended`}function Uk(e){let{chatId:t,shouldApplyStreamUpdate:n,beforeAssistantDelta:r,reconcileHydratedAssistantText:i,setStreamingOnStreamStart:a,clearResumeRunIdOnBackgroundTerminal:o,clearResumeRunIdOnVisibleError:s,setError:c,sessionMgrRef:l,applyLoadedSessionSnapshot:u,finalizeMessage:d,fq:f}=e,p=e.isCurrentRun??(()=>!0),m=()=>Nn.getState(),g=()=>{let e={messages:m().sessions[t]?.messages};return l.current.loadSession(t,0,void 0,void 0,e.messages).then(n=>{p()&&u(t,n,e)}).catch(()=>{})},_=new Map,v,b=()=>{if(v!==void 0&&(window.clearTimeout(v),v=void 0),!p()){_.clear();return}if(_.size===0)return;let e=Array.from(_.entries());_.clear(),r(),m().mutateSessionStreaming(t,t=>{for(let[n,r]of e)_n(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&&bn.setResumeRunId(t,null),m().setSessionFlags(t,{sending:!1,streaming:!1}),m().setSessionProgress(t,null),Hk(e)&&f.dismissClarifyForSession(t),g()},C={onTextSurface:e=>{r(),m().mutateSessionStreaming(t,t=>{t.textSurface=e})},onReplayGap:g,onUserMessage:e=>{n(t)&&m().appendUserMessageIfMissing(t,e)},onStreamStart:(e,n,i)=>{Lf(t),r(),i&&m().updateSessionMessages(t,t=>rr([...t,{role:`task`,content:[],taskTrigger:i,turnId:e,timestamp:Date.now()}])),m().updateSessionMessages(t,t=>Cn(t,e)),m().mutateSessionStreaming(t,t=>{t.turnId=e,n&&(t.startsNewBubble=!0)}),m().setSessionFlags(t,{streaming:!0})},onToken:(e,a,o)=>{r(),m().mutateSessionStreaming(t,t=>{Dn(t.content,e,a,{offset:o,reconcileHydratedSegment:i})}),n(t)&&m().setSessionFlags(t,{streaming:!0})},onAssistantMessageEnd:(e,n,i)=>{r(),m().mutateSessionStreaming(t,t=>{Cr(t.content,e,n),i&&(t.usage=i)})},onThinking:(e,n,i)=>{r(),m().mutateSessionStreaming(t,t=>{!n&&e===``?xn(t.content):tr(t.content,e,n,i)})},onThinkingEnd:e=>{r(),m().mutateSessionStreaming(t,t=>{wn(t.content,e)})},onToolStart:(e,n,i,a,o,s)=>{r(),m().mutateSessionStreaming(t,t=>{pn(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=>{Tn(t.content,e,n,i,a,o,s,c)})},onToolUpdate:(e,n,i)=>{r(),m().mutateSessionStreaming(t,t=>{Pn(t.content,e,n,i)})},onTaskPlanUpdated:e=>{m().setSessionTaskPlan(t,e)},onTurnOutcome:e=>{r(),m().mutateSessionStreaming(t,t=>{t.outcome=e})},onReview:({review:e})=>{r(),m().mutateSessionStreaming(t,t=>{vn(t.content,e)}),n(t)&&m().setSessionFlags(t,{streaming:!0})},onReviewStart:e=>{r(),m().mutateSessionStreaming(t,t=>{Fn(t.content,e)}),n(t)&&m().setSessionFlags(t,{streaming:!0})},onReviewDelta:({reviewId:e,delta:t})=>{x(e,t)},onReviewEnd:({reviewId:e,status:n,message:i})=>{b(),r(),m().mutateSessionStreaming(t,t=>{An(t.content,e,n,i)})},onProgress:e=>{m().setSessionProgress(t,e)},onTtsAudio:e=>{n(t)&&m().appendAttachmentToCurrentAssistant(t,{name:e.name,mimeType:e.mimeType,type:`voice`,uri:e.uri,size:0},{attachTo:e.attachTo,messageId:e.messageId})},onCompaction:e=>{if(!n(t))return;let r=y(h.getState().language).chat;if(e.status===`started`)m().setSessionProgress(t,{stage:`compaction`,message:r.compactingContext,timestamp:Date.now()});else if(e.status===`completed`){let n=e.tokensBefore&&e.tokensAfter?` (${r.contextTokensFreed.replace(`{{count}}`,String(Math.round((e.tokensBefore-e.tokensAfter)/1e3)))})`:``;m().setSessionProgress(t,{stage:`compaction`,message:`${r.contextCompacted}${n}`,timestamp:Date.now()})}else m().setSessionProgress(t,null)},onClarifyRequest:f.makeOnClarifyRequest(t),onSessionConfigUpdated:()=>{m().patchSessionMeta(t,{modelConfigSaving:!0}),l.current.loadSessionAgentConfig(t).then(e=>Kn(t,e)).catch(()=>{}).finally(()=>m().patchSessionMeta(t,{modelConfigSaving:!1}))},onResult:({status:e})=>{b();let r=n(t);if(bn.takeUserAborted(t)||e===`cancelled`){Bf(t),r?d(t,e):S(e);return}if(e===`error`){if(zf(t,!r),!r){S(e);return}d(t,e),g();return}if(e===`suspended`?Vf(t):Rf(t,!r),!r){S(e);return}d(t,e)},onError:e=>{b();let r=n(t);if(zf(t,!r),!r){S(`error`);return}m().clearStreamingState(t),s&&bn.setResumeRunId(t,null),m().setSessionFlags(t,{sending:!1,streaming:!1}),m().setSessionProgress(t,null),c(e),f.dismissClarifyForSession(t)}};return Object.fromEntries(Object.entries(C).map(([e,t])=>[e,(...e)=>{if(p())return Reflect.apply(t,void 0,e)}]))}function Wk(e){return Un(e)?.streamingMsg??null}var Gk=80;function Kk(e){let t=e.trim();(t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`))&&(t=t.slice(1,-1).trim());let n=t.indexOf(`
71
- `);return n!==-1&&(t=t.slice(0,n).trim()),t.length>Gk&&(t=t.slice(0,Gk-1).trimEnd()+`…`),t}function qk(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 Jk(e){let t=e.trimStart().match(/^\/skill:([^\s]+)(?:\s+([\s\S]*))?$/i);return t&&(t[2]?.trim()||t[1]?.trim())||e}function Yk(e){let t=Jk(qk(Rn([{type:`text`,text:e}]))).split(/\n/)[0]?.trim();if(!t)return null;let n=Kk(t);return n.length>0?n:null}function Xk(e,t){let n=e.trim(),r=t.trim();!n||!r||window.dispatchEvent(new CustomEvent(`session-updated`,{detail:{key:n,name:r},bubbles:!0}))}var Zk=new Set([`new`,`reset`,`restart`]),Qk=new Set([...Zk,`clear`,`archive`]);function $k(e){let t=e.trim(),n=/^\/([^\s@]+)(?:@[^\s]+)?(?:\s+([\s\S]*))?$/.exec(t);return n?{name:n[1].toLowerCase(),args:n[2]?.trim()??``}:null}function eA(e){let t=$k(e);return!!(t&&Zk.has(t.name)&&!t.args)}function tA(e){let t=$k(e);return!!(t&&Qk.has(t.name))}function nA(e){let{conversationId:t,taskId:n,thinkingLevel:r,modelSupportsThinking:i,conversationIdRef:a,sendingRef:o,streamingRef:s,sessionMgrRef:c,sendMessageRef:l,shouldApplyStreamUpdate:u,fq:d,applyLoadedSessionSnapshot:f,loadSessionById:p,resetCurrentSession:h,pollSessionNameAfterTurn:g}=e,_=()=>Nn.getState(),v=e=>_().setShellError(e),y=()=>_().setShellError(null),b=(0,Q.useCallback)((e,t)=>{let n=e??a.current;if(n&&!u(n))return;let r=n?Wk(n):null,i=null;if(r){let e=En(r,Date.now());e.runStatus=t,On(e.content,t===`success`),wn(e.content),t!==`suspended`&&Sn(e.content,t===`success`),yn(e.content),e.completedAt=t&&t!==`suspended`?Date.now():void 0,i=er(e)}i&&mn(i)&&n?_().finalizeStreamingTurn(n,i):n&&_().clearStreamingState(n),o.current=!1,s.current=!1,n&&bn.resetRunTracking(n),(!t||Hk(t))&&d.dismissClarify(),g();let c=a.current;c&&window.setTimeout(()=>{a.current===c&&(o.current||s.current||p(c,0))},400)},[o,s,a,d.dismissClarify,d.pendingFollowUpsRef,g,p,u]),x=(0,Q.useCallback)(async(e,t)=>{if(!u(e))return;let r=m.getState().conversationId,i=()=>m.getState().conversationId===r,a=bn.getGeneration(e),l=_().sessions[e]?.streamingMsg,h=_().sessions[e]?.messages.findLast(e=>e.role===`user`)?.clientSubmissionId,g=await ur(e);if(!i()||bn.getGeneration(e)!==a)return;if(!g){let t=_().sessions[e]?.streamingMsg;if(t?.pendingResponseStatus||t&&t!==l||bn.isStreamingFor(e))return;let n=bn.getResumeRunId(e);n&&bn.reconcileInactive(e,n),_().clearStreamingState(e,{preservePendingResponse:!0}),Bf(e);return}let y=()=>{let t=_().sessions[e]?.streamingMsg,n=_().sessions[e]?.messages.findLast(e=>e.role===`user`)?.clientSubmissionId;return!i()||bn.getGeneration(e)!==a||!!(n&&n!==h)||!!(Gn(e)&&Gn(e)!==g)||!!(t?.turnId&&t.turnId!==g&&t.turnId!==l?.turnId)||!!(t?.pendingResponseStatus&&t!==l)};if(y()||bn.isTrackingRun(e,g))return;let x=()=>{let t=_().sessions[e]?.streamingMsg;!t?.turnId||t.turnId===g||t.turnId!==l?.turnId||(mn(t)?_().finalizeStreamingTurn(e,er(t)):_().clearStreamingState(e))},S=t??yr(e),C=Un(e)?.hasMore??!1;try{let t=await c.current.loadSession(e,0,void 0,n,_().sessions[e]?.messages);if(y()||bn.isTrackingRun(e,g))return;x(),_().mergeCommittedFromServer(e,t.messages,t.hasMore),S=t.messages,C=t.hasMore}catch{}if(y()||bn.isTrackingRun(e,g))return;x(),a=bn.advanceGeneration(e),bn.setUserAborted(e,!1),bn.setResumeRunId(e,g),o.current=!0,s.current=!0,_().seedSessionIfEmpty(e,S,!0,!0,C),_().setSessionFlags(e,{sending:!0,streaming:!0}),_().setSessionProgress(e,null),Lf(e);let w=!1,T=()=>{if(w||!u(e))return;w=!0;let t=lk(yr(e),g);t&&_().applyHydratedTail(e,t.messagesWithoutTail,er(t.tail))},E=()=>{_().clearStreamingState(e),bn.getResumeRunId(e)===g&&bn.setResumeRunId(e,null),u(e)&&(o.current=!1,s.current=!1)};try{let t=Uk({chatId:e,shouldApplyStreamUpdate:u,isCurrentRun:()=>i()&&bn.getGeneration(e)===a,beforeAssistantDelta:T,reconcileHydratedAssistantText:!0,setStreamingOnStreamStart:!1,clearResumeRunIdOnBackgroundTerminal:!0,clearResumeRunIdOnVisibleError:!0,setError:v,sessionMgrRef:c,applyLoadedSessionSnapshot:f,finalizeMessage:b,fq:d}),n=await bn.senderFor(e).resume(g,e,t,{replayFromStart:l?.turnId!==g||!mn(l)});if(!i()||bn.getGeneration(e)!==a)return;n||(Bf(e),E(),await p(e,0).catch(()=>void 0))}catch(t){if(!i()||bn.getGeneration(e)!==a)return;t.name!==`AbortError`&&console.error(`[chat] resume failed:`,t),Bf(e),E()}finally{bn.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&&!bn.isStreamingFor(c))return!1;let l=e.trim();if(n&&tA(l))return v(`A task has one continuous conversation.`),!1;if(eA(l)&&!t?.length){await h();return}return await d.addPendingFollowUp(e,t,i,void 0,!0),!0},[o,s,a,d.addPendingFollowUp,h,n]),C=(0,Q.useCallback)(async(e,a,l,g,x,S,C,w)=>{if(!t||!u(t)||!e.trim()&&!a?.length&&!g?.length||o.current||s.current||bn.isStreamingFor(t))return!1;let T=e.trim();if(n&&tA(T))return v(`A task has one continuous conversation.`),!1;if(eA(T)&&!a?.length){await h();return}let E=i?l??r:`off`,D=t,O=bn.advanceGeneration(D),k=m.getState().conversationId,A=()=>m.getState().conversationId===k&&bn.getGeneration(D)===O,j=crypto.randomUUID(),M=`assistant-stream:${D}:${j}`,N=yr(D),P=w?N.filter(e=>e.clientSubmissionId!==w):N,F=x?P.findIndex(e=>e.role===`user`&&e.turnId===x):-1;if(x&&F<0)return!1;bn.setUserAborted(D,!1),o.current=!0,s.current=!1,y(),d.dismissClarify();let I=F>=0?P.slice(0,F):P,L=Wn(e)??void 0,R=new Map(g?.flatMap(e=>e.refId?[[e.refId,e.title]]:[])??[]),z=L?br(L,e=>R.get(e)):e,B=[...I,{role:`user`,content:z?[{type:`text`,text:z}]:[],userTurnDocument:L,deliveryStatus:`sending`,clientSubmissionId:j,pendingAppContext:S===void 0?void 0:structuredClone(S),attachments:a,contextRefs:g?.map(e=>({refId:e.refId,kind:e.kind,sourceId:e.sourceId,version:e.expectedVersion,title:e.title,fileKind:e.fileKind})),timestamp:Date.now()}];C?.(j);let V=Un(D);if(_().initSessionSnapshot(D,{...V??{...lr(),historyStatus:`ready`,hasMore:!1,streamingMsg:null,progress:null,taskPlan:null,sending:!1,streaming:!1},messages:B,hasMore:V?.hasMore??!1,streamingMsg:{role:`assistant`,content:[],timestamp:Date.now(),renderKey:M,pendingResponseStatus:`sending`},progress:null,sending:!0,streaming:!1}),Lf(D),!V?.name?.trim()&&z.trim()){let e=Yk(z.trim());e&&(_().patchSessionMeta(D,{name:e}),Xk(D,e))}let H=e=>{_().updateSessionMessages(D,t=>Vk(t,j,e))};return Bk(async t=>{let r=!1;try{let i=Uk({chatId:D,shouldApplyStreamUpdate:u,isCurrentRun:A,beforeAssistantDelta:()=>{},reconcileHydratedAssistantText:!1,setStreamingOnStreamStart:!0,clearResumeRunIdOnBackgroundTerminal:!1,clearResumeRunIdOnVisibleError:!1,setError:v,sessionMgrRef:c,applyLoadedSessionSnapshot:f,finalizeMessage:b,fq:d});i.onInputAccepted=()=>{r=!0,H(`accepted`),A()&&_().setPendingResponseStatus(D,`waiting`),t()},await bn.senderFor(D).send(e,D,a,E,i,n,x,g,S)}catch(e){if(!A())return;if(e.name!==`AbortError`)_().clearStreamingState(D),Bf(D),u(D)&&v(e instanceof Error?e.message:String(e)),x&&p(D,0);else{Bf(D);let e=Un(D)?.streamingMsg;e?.renderKey===M&&e.pendingResponseStatus&&_().clearStreamingState(D)}}finally{A()&&(r||H(`failed`),u(D)&&(o.current=!1,s.current=!1),_().setSessionFlags(D,{sending:!1}),bn.releaseIdleSender(D))}})},[t,r,i,o,s,u,c,f,b,d.dismissClarify,h,n,p]),w=(0,Q.useCallback)((e,t,n,r,i)=>C(t,n,r,i,e),[C]),T=(0,Q.useCallback)((e,t)=>{let n=a.current;if(!n||$n(n).phase!==`idle`||bn.getGeneration(n)!==e)return;let r=bn.getResumeRunId(n),i=_().sessions[n]?.streamingMsg?.turnId;r&&r!==t||i&&i!==t||(d.dismissClarify(),bn.abort(n,!1),Bf(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=bn.getGeneration(e),n=bn.getResumeRunId(e)??_().sessions[e]?.streamingMsg?.turnId??null;await d.stopSession(),a.current===e&&T(t,n)},[d.stopSession,a,T]),settleStoppedRun:T,deleteMessageRound:(0,Q.useCallback)(e=>{let t=a.current;if(!t||o.current||s.current)return;let n=yr(t),r=n[e];if(!r||!kn(r.role))return;if(r.deliveryStatus===`failed`){let r=[...n];r.splice(e,1),_().updateSessionMessages(t,()=>r);return}let i=qn(n,e);if(i===null)return;let l=fn(n,e),u=[...n];u.splice(e,l),_().updateSessionMessages(t,()=>u),c.current.deleteMessages(t,{userRoundIndex:i}).catch(()=>{p(t,0)})},[a,o,s,c,p]),retryUserMessageRound:(0,Q.useCallback)(e=>{let t=a.current;if(!t||o.current||s.current)return;let n=yr(t),r=n[e];if(!r||!kn(r.role))return;for(let t=e+1;t<n.length;t++){let e=n[t];if(e&&kn(e.role))return}let i=r.userTurnDocument?Mn(r.userTurnDocument):Rn(r.content),c=Ln(r.attachments);if(!i.trim()&&!c?.length&&!r.contextRefs?.length)return;let u=r.contextRefs?.flatMap(e=>e.kind===`mcp_resource`?[]:[{refId:e.refId,kind:e.kind,sourceId:e.sourceId,expectedVersion:e.version,title:e.title,fileKind:e.fileKind}]),d=r.deliveryStatus===`failed`?r.clientSubmissionId:void 0;!d&&!r.turnId||l.current(i,c,void 0,u,r.turnId,r.pendingAppContext,void 0,d).catch(()=>{p(t,0)})},[a,o,s,p,l])}}function rA(e){let t=(0,X.c)(11),{conversationId:n,conversationIdRef:r,sessionMgrRef:i,loadSessionById:a,loadTimelineById:o,applyAgentConfig:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=[],t[0]=c):c=t[0],(0,Q.useEffect)(aA,c);let l,u;t[1]!==n||t[2]!==a||t[3]!==o?(l=()=>{let e=e=>{let t=e.detail;!t?.key||t.key!==n||(a(n,0),o(n))};return window.addEventListener(`session-transcript-updated`,e),()=>window.removeEventListener(`session-transcript-updated`,e)},u=[n,a,o],t[1]=n,t[2]=a,t[3]=o,t[4]=l,t[5]=u):(l=t[4],u=t[5]),(0,Q.useEffect)(l,u);let d,f;t[6]!==s||t[7]!==r||t[8]!==i?(d=()=>{let e=e=>{if(ti(e.detail))return;let t=r.current;t&&i.current.loadSessionAgentConfig(t).then(e=>{s(t,e)}).catch(iA)};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},f=[r,i,s],t[6]=s,t[7]=r,t[8]=i,t[9]=d,t[10]=f):(d=t[9],f=t[10]),(0,Q.useEffect)(d,f)}function iA(){}function aA(){let e=oA;return window.addEventListener(`session-updated`,e),()=>window.removeEventListener(`session-updated`,e)}function oA(e){let t=e.detail;!t?.key||t.name===void 0||Nn.getState().patchSessionMeta(t.key,{name:t.name||null})}function sA(e){let t=d(),{isNewRoute:n,forceNewChat:r,decodedKey:i,viewConversationId:a,routedFocusedConversationId:o,routeConversationIdRef:s,locationKey:c,locationSearch:l,locationState:u}=Nk(e?.fixedConversationId),f=(0,Q.useRef)(new fr),p=(0,Q.useRef)(!1),m=(0,Q.useRef)(!1),h=(0,Q.useRef)(!1),g=(0,Q.useRef)(0),_=(0,Q.useRef)(!1),[v,y]=(0,Q.useState)([]),b=(0,Q.useRef)(async()=>{}),x=(0,Q.useRef)(0),S=o,C=Nn(e=>e.initLoading),w=Nn(e=>e.loadingMore),T=Nn(e=>e.shellError),E=a,D=Rm(E),O=E?hn(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=dk(D,Gr(di,ui,{revalidateOnFocus:!1}).data),L=D?.modelConfigSaving??!1,R=D?.thinkingLevel??`medium`,z=D?.reasoningLevel??`on`,B=D?.modelSupportsThinking??!1,V=D?.effectiveWorkspacePath??``,H=D?.workspaceSource??`agent_default_root`,U=D?.userContextMode??`enabled`;(0,Q.useEffect)(()=>{!E||A||k||f.current.loadSessionAgentConfig(E).then(e=>Kn(E,e)).catch(()=>void 0)},[E,A,k]),(0,Q.useEffect)(()=>{let e=e=>{let t=e.detail.conversationId;f.current.loadSessionAgentConfig(t).then(e=>Kn(t,e)).catch(()=>void 0)};return window.addEventListener(`session-model-config-stale`,e),()=>window.removeEventListener(`session-model-config-stale`,e)},[]),(0,Q.useEffect)(()=>{x.current=D?.messages.length??0},[D?.messages.length]),(0,Q.useEffect)(()=>{m.current=A,h.current=k},[A,k]);let{token:W,chatAgentsData:G,resolveAgentIdForPost:ee,onChatAgentChange:te,displayAgentId:ne,showChatAgentSelector:re,currentSessionProjectId:ie}=xk({navigate:t,personal:e?.personal,conversationIdRef:Fk,conversationId:S,isNewRoute:n,locationState:u,locationSearch:l}),ae=i!==void 0&&S!==i,oe=!!(i&&D?.historyStatus===`loading`&&!ae),se=(0,Q.useMemo)(()=>C&&(S==null||i===void 0),[C,S,i]),ce=pk({isNewRoute:n,sessionRoutePending:ae,showSessionLoading:se,sessionContentLoading:oe,messageCount:D?.messages.length??0}),le=(0,Q.useCallback)((e,n=!1,r)=>{let i=r??``;t({pathname:`/chat/${encodeURIComponent(e)}`,search:i},{replace:n})},[t]),ue=(0,Q.useCallback)(e=>rk({streamConversationId:e,routeConversationId:s.current}),[s]),K=(0,Q.useCallback)(()=>{fk({sendingRef:m,streamingRef:h})},[]),q=yk({conversationId:S,decodedKey:i,conversationIdRef:Fk,sendingRef:m,streamingRef:h,modelSupportsThinking:B,thinkingLevel:R,shouldApplyStreamUpdate:ue}),de=(0,Q.useCallback)(()=>{q.clearVisibleClarify();let e=Fk.current;e&&bn.resetRunTracking(e),uk(K)},[q.clearVisibleClarify,Fk,K]),{refreshModelThinkingSupport:fe,pollSessionNameAfterTurn:pe,applyLoadedSessionSnapshot:J,loadSessionById:me,loadMoreMessages:he,onSessionModelChange:ge,onSessionThinkingLevelChange:_e,onSessionWorkingDirectoryChange:ve,createNewSession:ye,resetCurrentSession:be}=zk({sessionMgrRef:f,routeConversationIdRef:s,sendingRef:m,streamingRef:h,loadingSessionRef:p,messagesLenRef:x,thinkingSupportGenRef:g,navigateToSession:le,resolveAgentIdForPost:ee,detachForNewConversation:de,conversationId:S,sessionAgentId:ne,currentProjectId:ie,hasMore:N,taskId:e?.taskId}),xe=(0,Q.useCallback)(e=>{if(!ik({cacheConversationId:e,routeConversationId:s.current}))return!1;let t=Un(e);return!t||!hn(t)&&!sr(e)&&!bn.isStreamingFor(e)?!1:(m.current=t.sending,h.current=t.streaming,!0)},[s]),{tryResumeAgentRun:Se,sendMessage:Ce,replaceLatestUserTurn:we,interruptAndSend:Te,abort:Ee,settleStoppedRun:De,deleteMessageRound:Oe,retryUserMessageRound:ke}=nA({conversationId:S,taskId:e?.taskId,thinkingLevel:R,modelSupportsThinking:B,conversationIdRef:Fk,sendingRef:m,streamingRef:h,sessionMgrRef:f,sendMessageRef:b,shouldApplyStreamUpdate:ue,fq:q,applyLoadedSessionSnapshot:J,loadSessionById:me,resetCurrentSession:be,pollSessionNameAfterTurn:pe});(0,Q.useEffect)(()=>{n&&de()},[n,de]);let Ae=(0,Q.useMemo)(()=>ck({viewConversationId:a,conversationId:E,messages:D?.messages??[],streamingMsg:O?D?.streamingMsg??null:null}),[a,E,D?.messages,D?.streamingMsg,O]),je=(0,Q.useCallback)((e,t)=>{Nn.getState().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:t}),K()},[K]),Me=(0,Q.useCallback)((e,t)=>{Kn(e,t),fe(t.model)},[fe]),Ne=(0,Q.useCallback)(e=>{let t=Nn.getState();e.loading!==void 0&&t.setInitLoading(e.loading),e.error!==void 0&&t.setShellError(e.error)},[]),Pe=(0,Q.useCallback)(async t=>{try{let n=await f.current.loadTimeline(t,e?.taskId);if(s.current!==t)return;y(n)}catch{s.current===t&&y([])}},[s,e?.taskId]);(0,Q.useEffect)(()=>{if(n||!S){y([]);return}Pe(S)},[S,n,Pe]),rA({conversationId:S,conversationIdRef:Fk,sendingRef:m,streamingRef:h,sessionMgrRef:f,loadSessionById:me,loadTimelineById:Pe,applyAgentConfig:Me});let Fe=Ik({token:W,isNewRoute:n,forceNewChat:r,temporary:u?.temporary===!0,requestedAgentId:typeof u?.agentId==`string`?u.agentId:void 0,decodedKey:i,locationKey:c,locationSearch:l,sessionMgrRef:f,resolveAgentIdForPost:ee,navigateToSession:le,loadSessionById:me,tryResumeAgentRun:Se,restoreLiveCacheIfNeeded:xe,adoptEmptySession:je,applyAgentConfig:Me,patchInitUi:Ne}),Ie=Lk(Fe);return(0,Q.useEffect)(()=>{Fe&&Ie.error&&Nn.getState().setShellError(Ie.error instanceof Error?Ie.error.message:`Failed to load model configuration`)},[Fe,Ie.error]),(0,Q.useEffect)(()=>{let e=e=>{let t=e.detail,n=t?.conversationId,r=t?.runId;!n||!r?.trim()||(nr(n,r),bn.setResumeRunId(n,r),ue(n)&&(bn.isTrackingRun(n,r)||queueMicrotask(()=>{ue(n)&&(bn.isTrackingRun(n,r)||Se(n,yr(n)))})))};return window.addEventListener(`run-started`,e),()=>window.removeEventListener(`run-started`,e)},[Se,ue]),(0,Q.useEffect)(()=>{let e=k||A,t=_.current;if(_.current=e,!t||e)return;let n=Fk.current;n&&queueMicrotask(()=>{!n||!ue(n)||bn.isStreamingFor(n)||sr(n)&&Se(n,yr(n))})},[k,A,Se,ue]),b.current=Ce,{auth:{hasToken:!!W},session:{projectPreparation:Ie.preparation,conversationId:S,sessionName:P,decodedKey:i,sessionRoutePending:ae,sessionContentLoading:oe,showSessionLoading:se,conversationPhase:ce,loading:C,sessionModel:Fe?Ie.model:F,modelConfigReady:Fe?Ie.ready:I,modelConfigSaving:L,thinkingLevel:Fe?Ie.thinkingLevel:R,onSessionThinkingLevelChange:Fe?Ie.onThinkingChange:_e,onSessionWorkingDirectoryChange:ve,reasoningLevel:z,modelSupportsThinking:Fe?Ie.modelSupportsThinking:B,effectiveWorkspacePath:V,workspaceSource:H,userContextMode:Fe?.temporary?`temporary`:U,hasMore:N,loadingMore:w,loadMoreMessages:he,onSessionModelChange:Fe?Ie.onModelChange:ge,createNewSession:ye,sessionManager:f.current},messages:{items:Ae},timeline:{items:v,refresh:Pe},stream:{error:T,streaming:k,sending:A,progress:j,taskPlan:M,sendMessage:Ce,replaceLatestUserTurn:we,abort:Ee,settleStoppedRun:De,interruptAndSend:Te,deleteMessageRound:Oe,retryUserMessageRound:ke},followUp:{composerMode:q.composerMode,control:q.control,controlPending:q.controlPending,beginEditTurn:q.beginEditTurn,cancelEditor:q.cancelEditor,restoreEditor:q.restoreEditor,resumeQueue:q.resumeQueue,sendQueuedInput:q.sendQueuedInput,addPendingFollowUp:q.addPendingFollowUp,pendingFollowUps:q.pendingFollowUps,editingFollowUpId:q.editingFollowUpId,beginEditFollowUp:q.beginEditFollowUp,cancelEditFollowUp:q.cancelEditFollowUp,commitEditFollowUp:q.commitEditFollowUp,removePendingFollowUp:q.removePendingFollowUp,movePendingFollowUp:q.movePendingFollowUp,reorderPendingFollowUp:q.reorderPendingFollowUp,steerPendingFollowUp:q.steerPendingFollowUp,steeringFollowUpId:q.steeringFollowUpId},clarify:{clarifyPrompt:q.clarifyPrompt,clarifySubmitting:q.clarifySubmitting,clarifySubmitError:q.clarifySubmitError,submitClarifyAnswer:q.submitClarifyAnswer,letAgentDecideClarification:q.letAgentDecideClarification,cancelClarification:q.cancelClarification},agents:{chatAgents:G,displayAgentId:Fe?.agentId??ne,showChatAgentSelector:re,onChatAgentChange:te}}}function cA(e){let t=(0,X.c)(11),n=m(lA),r;t[0]===e?r=t[1]:(r=e?.trim()||null,t[0]=e,t[1]=r);let i=r,a;t[2]===i?a=t[3]:(a=e=>i?e.sessions[i]?.localDraft:void 0,t[2]=i,t[3]=a);let o=Nn(a),s;t[4]!==o||t[5]!==n||t[6]!==i?(s=n&&i&&!o?[`chat-session-meta`,i,n,o===!1?`persisted`:`unknown`]:null,t[4]=o,t[5]=n,t[6]=i,t[7]=s):s=t[7];let c;t[8]===i?c=t[9]:(c=async()=>{if(await wr(i))return;let e=await un(i),t=typeof e.sessionType==`string`&&e.sessionType.trim()?e.sessionType.trim():null,n=typeof e.routing?.agentId==`string`&&e.routing.agentId.trim()?e.routing.agentId.trim():null,r=e.customData?.sourceBinding,a=r&&typeof r==`object`?r:null,o=a?.kind===`note`&&typeof a.sourceId==`string`&&a.sourceId.trim()?a.sourceId.trim():null,s=typeof e.parentConversationId==`string`&&e.parentConversationId.trim()?e.parentConversationId.trim():null,c=e.customData?.forkedFromSessionName;return{identity:{sourceChannel:e.sourceChannel,sessionType:e.sessionType,customData:e.customData},ownerAgentId:n,sessionType:t,sourceNoteId:o,sourceNoteTitle:null,parentConversationId:s,forkedFromSessionName:typeof c==`string`&&c.trim()?c.trim():null}},t[8]=i,t[9]=c);let l;return t[10]===Symbol.for(`react.memo_cache_sentinel`)?(l={revalidateOnFocus:!1},t[10]=l):l=t[10],Gr(s,c,l)}function lA(e){return e.conversationId}function uA(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 dA(e,t){return uA(zn(e??``),t)}function fA(e,t){return da(e,t)}function pA(e){return e===`context`||e===`branch`||e===`compaction`?e:null}function mA(e){return uA(e.preview||e.title,72)||e.kind}function hA(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:dA(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:fA(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=pA(a.kind);if(!e)continue;let o=`${a.id}:${a.kind}`;r.events.some(e=>e.key===o)||r.events.push({key:o,label:mA(a),tone:e})}return n}function gA(e,t){return(e===1?t.toolCount_one:t.toolCount_other).replace(`{{count}}`,String(e))}function _A(e,t){let n=e[0]?.id;for(let r of e)r.messageIndex<=t&&(n=r.id);return n}function vA(e){let t=(0,X.c)(53),{turn:n,active:r,labels:i,currentLabel:a,onSelect:o}=e,s,c,l,u,d,f,p,m;if(t[0]!==r||t[1]!==a||t[2]!==i||t[3]!==o||t[4]!==n.events||t[5]!==n.preview||t[6]!==n.timestamp||t[7]!==n.title||t[8]!==n.tools){let e=n.tools.slice(0,2),h=n.events.slice(0,Math.max(0,3-e.length)),g=Math.max(0,n.tools.length-e.length)+Math.max(0,n.events.length-h.length);d=`button`;let _=r&&`bg-accent-soft/70`;t[17]===_?f=t[18]:(f=Y(`flex w-full min-w-0 items-start gap-3 border-b border-edge-subtle px-4 py-3 text-left transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,_),t[17]=_,t[18]=f),p=o;let v=r&&`border-accent bg-accent`,y;t[19]===v?y=t[20]:(y=Y(`mt-1 size-2.5 shrink-0 rounded-full border border-edge-strong bg-surface-panel`,v),t[19]=v,t[20]=y),t[21]===y?m=t[22]:(m=(0,Z.jsx)(`span`,{className:y,"aria-hidden":!0}),t[21]=y,t[22]=m),s=`min-w-0 flex-1`;let b;t[23]===n.preview?b=t[24]:(b=(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:n.preview}),t[23]=n.preview,t[24]=b);let x;t[25]!==r||t[26]!==a?(x=r?(0,Z.jsx)(`span`,{className:`shrink-0 rounded-full bg-accent px-1.5 py-0.5 text-[10px] font-medium text-on-accent`,children:a}):null,t[25]=r,t[26]=a,t[27]=x):x=t[27],t[28]!==b||t[29]!==x?(c=(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[b,x]}),t[28]=b,t[29]=x,t[30]=c):c=t[30];let S;t[31]===n.title?S=t[32]:(S=(0,Z.jsx)(`span`,{children:n.title}),t[31]=n.title,t[32]=S);let C;t[33]===n.timestamp?C=t[34]:(C=n.timestamp?(0,Z.jsx)(`time`,{suppressHydrationWarning:!0,dateTime:new Date(n.timestamp).toISOString(),children:uy(n.timestamp)}):null,t[33]=n.timestamp,t[34]=C);let w;t[35]!==i||t[36]!==n.tools.length?(w=n.tools.length>0?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Z.jsx)(Wt,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),gA(n.tools.length,i)]}):null,t[35]=i,t[36]=n.tools.length,t[37]=w):w=t[37],t[38]!==S||t[39]!==C||t[40]!==w?(l=(0,Z.jsxs)(`span`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[S,C,w]}),t[38]=S,t[39]=C,t[40]=w,t[41]=l):l=t[41],u=e.length>0||n.events.length>0?(0,Z.jsxs)(`span`,{className:`mt-2 flex min-w-0 flex-wrap gap-1.5`,children:[e.map(bA),h.map(yA),g>0?(0,Z.jsxs)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:[`+`,g]}):null]}):null,t[0]=r,t[1]=a,t[2]=i,t[3]=o,t[4]=n.events,t[5]=n.preview,t[6]=n.timestamp,t[7]=n.title,t[8]=n.tools,t[9]=s,t[10]=c,t[11]=l,t[12]=u,t[13]=d,t[14]=f,t[15]=p,t[16]=m}else s=t[9],c=t[10],l=t[11],u=t[12],d=t[13],f=t[14],p=t[15],m=t[16];let h;t[42]!==s||t[43]!==c||t[44]!==l||t[45]!==u?(h=(0,Z.jsxs)(`span`,{className:s,children:[c,l,u]}),t[42]=s,t[43]=c,t[44]=l,t[45]=u,t[46]=h):h=t[46];let g;return t[47]!==d||t[48]!==f||t[49]!==p||t[50]!==m||t[51]!==h?(g=(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`button`,{type:d,className:f,onClick:p,children:[m,h]})}),t[47]=d,t[48]=f,t[49]=p,t[50]=m,t[51]=h,t[52]=g):g=t[52],g}function yA(e){return(0,Z.jsxs)(`span`,{className:`inline-flex max-w-[10rem] items-center gap-1 rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:[(0,Z.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current opacity-70`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.label})]},e.key)}function bA(e){return(0,Z.jsxs)(`span`,{className:Y(`inline-flex max-w-[9rem] items-center gap-1 rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,e.running&&`text-accent-fg`),children:[(0,Z.jsx)(Wt,{className:`size-3 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.label})]},e.key)}function xA(e){let t=(0,X.c)(39),{items:n,activeMessageIndex:r,labels:i,openLabel:a,closeLabel:o,currentLabel:s,onSelectMessage:c}=e,l;t[0]!==n||t[1]!==i?(l=hA(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=_A(u,r),t[3]=r,t[4]=u,t[5]=p):p=t[5];let m=p,h;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(Pe,{className:`size-[1.125rem]`,strokeWidth:1.8,"aria-hidden":!0}),t[6]=h):h=t[6];let g;t[7]===a?g=t[8]:(g=(0,Z.jsx)(x,{asChild:!0,children:(0,Z.jsx)(pi,{type:`button`,variant:`ghost`,className:`size-10 shrink-0 rounded-full p-0 sm:size-9 xl:hidden`,"aria-label":a,title:a,children:h})}),t[7]=a,t[8]=g);let _;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Z.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim/60 backdrop-blur-[1px] xl:hidden`}),t[9]=_):_=t[9];let v;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(v=Y(`xopc-dialog-content-pane fixed inset-x-2 bottom-[max(.5rem,env(safe-area-inset-bottom))] z-[90] flex h-[min(72dvh,34rem)] flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-popover outline-none`,`sm:left-auto sm:right-3 sm:w-[min(24rem,calc(100vw-1.5rem))]`,`md:bottom-[max(1rem,env(safe-area-inset-bottom))] md:right-4 md:h-[min(calc(100dvh-6rem),40rem)]`,`xl:hidden`),t[10]=v):v=t[10];let y;t[11]===i.title?y=t[12]:(y=(0,Z.jsx)(E,{className:`min-w-0 truncate text-base font-semibold text-fg`,children:i.title}),t[11]=i.title,t[12]=y);let S;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(Gt,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=S):S=t[13];let O;t[14]===o?O=t[15]:(O=(0,Z.jsx)(C,{asChild:!0,children:(0,Z.jsx)(pi,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":o,children:S})}),t[14]=o,t[15]=O);let k;t[16]!==y||t[17]!==O?(k=(0,Z.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-between gap-3 border-b border-edge-subtle px-3.5 py-3`,children:[y,O]}),t[16]=y,t[17]=O,t[18]=k):k=t[18];let A;if(t[19]!==m||t[20]!==s||t[21]!==i||t[22]!==c||t[23]!==u){let e;t[25]!==m||t[26]!==s||t[27]!==i||t[28]!==c?(e=e=>(0,Z.jsx)(vA,{turn:e,active:e.id===m,labels:i,currentLabel:s,onSelect:()=>{c(e.messageIndex),f(!1)}},e.id),t[25]=m,t[26]=s,t[27]=i,t[28]=c,t[29]=e):e=t[29],A=u.map(e),t[19]=m,t[20]=s,t[21]=i,t[22]=c,t[23]=u,t[24]=A}else A=t[24];let j;t[30]===A?j=t[31]:(j=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,Z.jsx)(`ol`,{className:`min-w-0`,children:A})}),t[30]=A,t[31]=j);let M;t[32]!==k||t[33]!==j?(M=(0,Z.jsxs)(w,{children:[_,(0,Z.jsxs)(T,{className:v,"aria-describedby":void 0,children:[k,j]})]}),t[32]=k,t[33]=j,t[34]=M):M=t[34];let N;return t[35]!==d||t[36]!==M||t[37]!==g?(N=(0,Z.jsxs)(D,{open:d,onOpenChange:f,children:[g,M]}),t[35]=d,t[36]=M,t[37]=g,t[38]=N):N=t[38],N}function SA(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 CA(e){let t=(0,X.c)(40),{turn:n,labels:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n.events||t[2]!==n.preview||t[3]!==n.timestamp||t[4]!==n.title||t[5]!==n.tools){let e=n.tools.slice(0,3),p=Math.max(0,n.tools.length-e.length),m=n.events.slice(0,Math.max(0,3-e.length));i=p+Math.max(0,n.events.length-m.length);let h=n.tools.length>0||n.events.length>0?[...e.map(DA),...m.map(EA),...i>0?[`+${i}`]:[]].join(` · `):n.title;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(l=Y(`pointer-events-auto absolute right-12 top-1/2 z-[100] w-[min(25rem,calc(100vw-8rem))] -translate-y-1/2`,`rounded-2xl border border-edge bg-surface-overlay p-3 text-left shadow-popover backdrop-blur`),t[15]=l):l=t[15],t[16]===n.timestamp?u=t[17]:(u=n.timestamp?(0,Z.jsx)(`div`,{className:`mb-1 flex min-w-0 justify-end text-xs`,children:(0,Z.jsx)(`time`,{suppressHydrationWarning:!0,className:`shrink-0 tabular-nums text-fg-disabled`,dateTime:new Date(n.timestamp).toISOString(),children:uy(n.timestamp)})}):null,t[16]=n.timestamp,t[17]=u),t[18]===n.preview?d=t[19]:(d=(0,Z.jsx)(`div`,{className:`min-w-0 text-sm font-semibold leading-5 text-fg`,children:(0,Z.jsx)(`span`,{className:`line-clamp-1`,children:n.preview})}),t[18]=n.preview,t[19]=d),t[20]===h?f=t[21]:(f=(0,Z.jsx)(`div`,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:h}),t[20]=h,t[21]=f),a=`mt-3 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 text-sm text-fg-subtle`,t[22]!==r||t[23]!==n.title||t[24]!==n.tools.length?(o=n.tools.length>0?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Z.jsx)(Wt,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:gA(n.tools.length,r)})]}):(0,Z.jsx)(`span`,{children:n.title}),t[22]=r,t[23]=n.title,t[24]=n.tools.length,t[25]=o):o=t[25],s=e.map(TA),c=m.map(wA),t[0]=r,t[1]=n.events,t[2]=n.preview,t[3]=n.timestamp,t[4]=n.title,t[5]=n.tools,t[6]=i,t[7]=a,t[8]=o,t[9]=s,t[10]=c,t[11]=l,t[12]=u,t[13]=d,t[14]=f}else i=t[6],a=t[7],o=t[8],s=t[9],c=t[10],l=t[11],u=t[12],d=t[13],f=t[14];let p;t[26]===i?p=t[27]:(p=i>0?(0,Z.jsxs)(`span`,{children:[`+`,i]}):null,t[26]=i,t[27]=p);let m;t[28]!==a||t[29]!==o||t[30]!==s||t[31]!==c||t[32]!==p?(m=(0,Z.jsxs)(`div`,{className:a,children:[o,s,c,p]}),t[28]=a,t[29]=o,t[30]=s,t[31]=c,t[32]=p,t[33]=m):m=t[33];let h;return t[34]!==m||t[35]!==l||t[36]!==u||t[37]!==d||t[38]!==f?(h=(0,Z.jsxs)(`div`,{className:l,children:[u,d,f,m]}),t[34]=m,t[35]=l,t[36]=u,t[37]=d,t[38]=f,t[39]=h):h=t[39],h}function wA(e){return(0,Z.jsxs)(`span`,{className:Y(`inline-flex min-w-0 max-w-[10rem] items-center gap-1.5`,e.tone===`branch`&&`text-accent`,e.tone===`compaction`&&`text-fg-muted`),children:[(0,Z.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current opacity-70`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.label})]},e.key)}function TA(e){return(0,Z.jsxs)(`span`,{className:Y(`inline-flex min-w-0 max-w-[9rem] items-center gap-1.5`,e.running&&`text-accent`),children:[(0,Z.jsx)(Wt,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.label})]},e.key)}function EA(e){return e.label}function DA(e){return e.label}function OA(e){let t=(0,X.c)(44),{items:n,activeMessageIndex:r,labels:i,onSelectMessage:a}=e,o;t[0]!==n||t[1]!==i?(o=hA(n,i),t[0]=n,t[1]=i,t[2]=o):o=t[2];let s=o,[c,l]=(0,Q.useState)(null),u=(0,Q.useRef)(null),d,f;if(t[3]===c?(d=t[4],f=t[5]):(d=()=>{if(!c)return;let e=()=>{l(null)},t=t=>{let n=t.target;n instanceof Node&&(u.current?.contains(n)||e())},n=t=>{t.key===`Escape`&&e()};return document.addEventListener(`pointerdown`,t,!0),document.addEventListener(`keydown`,n),()=>{document.removeEventListener(`pointerdown`,t,!0),document.removeEventListener(`keydown`,n)}},f=[c],t[3]=c,t[4]=d,t[5]=f),(0,Q.useEffect)(d,f),s.length<4)return null;let p;if(t[6]!==r||t[7]!==s){p=s[0]?.id;for(let e of s)e.messageIndex<=r&&(p=e.id);t[6]=r,t[7]=s,t[8]=p}else p=t[8];let m=c??p,h;t[9]!==c||t[10]!==s?(h=c?s.find(e=>e.id===c):null,t[9]=c,t[10]=s,t[11]=h):h=t[11];let g=h,_=c!==null,v;if(t[12]!==m||t[13]!==s){let e;t[15]===m?e=t[16]:(e=e=>e.id===m,t[15]=m,t[16]=e),v=s.findIndex(e),t[12]=m,t[13]=s,t[14]=v}else v=t[14];let y=Math.max(0,v),b=i.title,x,S;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{l(null)},S=e=>{let t=e.relatedTarget;(!(t instanceof Node)||!e.currentTarget.contains(t))&&l(null)},t[17]=x,t[18]=S):(x=t[17],S=t[18]);let C;t[19]===p?C=t[20]:(C=()=>l(e=>e??p??null),t[19]=p,t[20]=C);let w;if(t[21]!==a||t[22]!==_||t[23]!==m||t[24]!==y||t[25]!==s){let e;t[27]!==a||t[28]!==_||t[29]!==m||t[30]!==y?(e=(e,t)=>{let n=e.id===m,r=Math.abs(t-y);return(0,Z.jsx)(`li`,{className:`group relative flex h-3.5 w-full shrink-0 items-center justify-end`,onMouseEnter:()=>l(e.id),onFocus:()=>l(e.id),children:(0,Z.jsx)(`button`,{type:`button`,className:Y(`flex h-3.5 w-full items-center justify-end rounded-sm pr-1.5`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),onClick:()=>a(e.messageIndex),"aria-label":`${e.title}: ${e.preview}`,children:(0,Z.jsx)(`span`,{className:Y(`block h-0.5 rounded-full transition-[width,background-color] duration-150 ease-out`,SA({active:n,scrubbing:_,distance:r}),`group-hover:bg-fg`),"aria-hidden":!0})})},e.id)},t[27]=a,t[28]=_,t[29]=m,t[30]=y,t[31]=e):e=t[31],w=s.map(e),t[21]=a,t[22]=_,t[23]=m,t[24]=y,t[25]=s,t[26]=w}else w=t[26];let T;t[32]!==w||t[33]!==C?(T=(0,Z.jsx)(`div`,{className:`chat-timeline-scroll flex min-h-0 w-full flex-col`,children:(0,Z.jsx)(`ol`,{className:`my-auto flex w-full shrink-0 flex-col items-end py-1`,onMouseEnter:C,children:w})}),t[32]=w,t[33]=C,t[34]=T):T=t[34];let E;t[35]!==i||t[36]!==g?(E=g?(0,Z.jsx)(CA,{turn:g,labels:i}):null,t[35]=i,t[36]=g,t[37]=E):E=t[37];let D;t[38]!==T||t[39]!==E?(D=(0,Z.jsxs)(`div`,{className:`relative z-[90] flex h-full min-h-0 w-full flex-col justify-center overflow-visible`,children:[T,E]}),t[38]=T,t[39]=E,t[40]=D):D=t[40];let O;return t[41]!==i.title||t[42]!==D?(O=(0,Z.jsx)(`aside`,{ref:u,className:`hidden h-full min-h-0 max-h-full w-12 shrink-0 items-center overflow-visible py-4 xl:flex`,"aria-label":b,onMouseLeave:x,onBlur:S,children:D}),t[41]=i.title,t[42]=D,t[43]=O):O=t[43],O}function kA(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 AA(e){let t=kA(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 jA(e){let{enabled:t,conversationId:n,sourceContextPending:r,sourceContextFailed:i,suppressProjectContext:a,project:o,task:s}=e,c=kA(e),[l,u]=(0,Q.useState)(()=>AA(e));(0,Q.useEffect)(()=>{let e=!1,l=AA({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 wr(n);r=e?e.creation.projectId?.trim()||null:(await un(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):sn(r),cn(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:AA(e);return{context:d.context,status:d.status}}var MA=[Rt,Pt,_s];function NA(e){let t=(0,X.c)(20),{agentName:n,messages:r,disabled:i,onPick:a}=e,o;t[0]!==r.setupPromptComplete||t[1]!==r.setupPromptIdentity||t[2]!==r.setupPromptProject?(o=[r.setupPromptIdentity,r.setupPromptProject,r.setupPromptComplete],t[0]=r.setupPromptComplete,t[1]=r.setupPromptIdentity,t[2]=r.setupPromptProject,t[3]=o):o=t[3];let s=o,c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-2xl bg-accent-soft text-accent`,children:(0,Z.jsx)(Rt,{className:`size-6`,strokeWidth:1.75,"aria-hidden":!0})}),t[4]=c):c=t[4];let l;t[5]===r.setupTitle?l=t[6]:(l=(0,Z.jsx)(`h1`,{id:`agent-setup-title`,className:`mt-4 text-balance text-xl font-semibold tracking-tight text-fg`,children:r.setupTitle}),t[5]=r.setupTitle,t[6]=l);let u;t[7]!==n||t[8]!==r.setupDescription?(u=r.setupDescription.replace(`{{name}}`,n),t[7]=n,t[8]=r.setupDescription,t[9]=u):u=t[9];let d;t[10]===u?d=t[11]:(d=(0,Z.jsx)(`p`,{className:`mt-2 max-w-xl text-pretty text-sm leading-relaxed text-fg-muted`,children:u}),t[10]=u,t[11]=d);let f;t[12]!==i||t[13]!==a||t[14]!==s?(f=(0,Z.jsx)(`div`,{className:`mt-7 grid w-full gap-3 md:grid-cols-3`,children:s.map((e,t)=>{let n=MA[t]??Rt;return(0,Z.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>a(e),className:Y(`flex min-h-24 items-center gap-3 rounded-xl border border-edge bg-surface-panel px-4 py-4 text-left text-sm font-medium leading-relaxed text-fg`,`hover:border-accent/30 hover:bg-surface-hover`,ca.transition,ca.pressCard,ca.focusRingPanel,ca.disabled),children:[(0,Z.jsx)(n,{className:`size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:e})]},e)})}),t[12]=i,t[13]=a,t[14]=s,t[15]=f):f=t[15];let p;return t[16]!==l||t[17]!==d||t[18]!==f?(p=(0,Z.jsxs)(`section`,{className:`mx-auto flex w-full max-w-4xl flex-col items-center px-2 pb-4 pt-12 text-center sm:pt-16`,"aria-labelledby":`agent-setup-title`,children:[c,l,d,f]}),t[16]=l,t[17]=d,t[18]=f,t[19]=p):p=t[19],p}var PA=t({ChatPage:()=>IA}),FA=(0,Q.lazy)(async()=>({default:(await o(()=>import(`./chat-terminal-dock-0PJ9dURQ.js`),__vite__mapDeps([30,1,2,5,6,31,11,32,26,27,17,18,33,34,35,36,37,38,39,40,41,42,43,4,44,45,28,29,9,46,47,48,49]))).ChatTerminalDock}));function IA({beforeSend:e,draftSeed:t,sourceNoteInView:n=!1,embedded:r=!1,conversationId:i,taskId:a,personal:o=!1,personalWelcome:s,automationWorkspace:f=!1,automationTimelineEntries:p,readOnly:g=!1,onHistoryReady:_,automationExecution:v=!1,initialTurnId:x,onInitialTurnLocated:C}={}){let O=h(e=>e.language),k=y(O),A=m(e=>e.conversationId),j=d(),M=c(),{pathname:N}=M,[P,F]=l(),I=(0,Q.useRef)(null),L=(0,Q.useRef)(0),R=(0,Q.useRef)(null),[z,V]=(0,Q.useState)(null),[H,U]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{U(t??null)},[t]);let[W,G]=(0,Q.useState)(()=>!!(i&&window.localStorage.getItem(`personal-calibration:${i}`))),[ee,te]=(0,Q.useState)(null),[ne,re]=(0,Q.useState)(null),[ie,ae]=(0,Q.useState)(!1),[oe,se]=(0,Q.useState)(null),ce=a?.trim()||null,{data:le}=zs(ce??``),{auth:ue,session:K,messages:q,timeline:de,stream:fe,followUp:pe,clarify:J,agents:me}=sA({fixedConversationId:i,taskId:ce??void 0,personal:o}),he=pe.composerMode.kind===`editTurn`?pe.composerMode:null,ge=Nn(e=>!!(K.conversationId&&!e.shellError&&e.sessions[K.conversationId]?.historyStatus===`ready`));(0,Q.useEffect)(()=>{ge&&q.items.length>0&&_?.()},[ge,q.items.length,_]),(0,Q.useLayoutEffect)(()=>{if(!f&&!v||!K.conversationId)return;let e=K.conversationId;return $f.setState({conversationIdOverride:e}),()=>{$f.getState().conversationIdOverride===e&&$f.setState({conversationIdOverride:null})}},[f,v,K.conversationId]);let _e=!o&&!r&&!ce&&P.get(`scene`)===`find-skills`,ve=f||P.get(`setup`)===`automation`,ye=!r&&!ce&&P.get(`agentSetup`)===`1`,be=o?``:P.get(`skill`)?.trim()??``,xe=o?``:P.get(`slash`)?.trim()??``;(0,Q.useEffect)(()=>{if(!o||!P.has(`skill`)&&!P.has(`slash`))return;let e=new URLSearchParams(P);e.delete(`skill`),e.delete(`slash`),F(e,{replace:!0})},[o,P,F]);let Se=P.get(f?`chatDraft`:`draft`)??``,Ce=P.get(`autoSend`)===`1`,we=P.get(`attachmentHandoff`),Ee=P.get(`attachmentsHandoff`),De=K.decodedKey??K.conversationId,[Oe,ke]=(0,Q.useState)(null),je=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(we){let e=Ae(we);e&&ke(e),je.current=De;return}je.current!==De&&(je.current=De,ke(null))},[we,De]);let Me=If(e=>e.markViewed),Ne=If(e=>De?e.runs[De]?.unread:!1);(0,Q.useEffect)(()=>{De&&Ne&&Me(De)},[De,Ne,Me]);let{data:Pe}=cA(De),Fe=ve||!!Pe?.identity?.customData?.automationSetup,Ie=!!Pe?.identity?.customData?.automationSetup?.automationId,Le=(0,Q.useCallback)(async e=>{if(De)try{let t=await K.sessionManager.forkSessionAtTurn(De,e);window.dispatchEvent(new CustomEvent(`session-created`,{detail:{key:t.conversationId,conversationId:t.conversationId}})),ya(`success`,k.chat.messageForkCreated),j(`/chat/${encodeURIComponent(t.conversationId)}`)}catch(e){throw ya(`error`,e instanceof Error?e.message:k.chat.messageForkFailed),e}},[De,k.chat.messageForkCreated,k.chat.messageForkFailed,j,K.sessionManager]),ze=q.items.at(-1),Ue=o&&!W&&!fe.streaming&&!fe.sending&&ze?.role===`assistant`&&q.items.filter(e=>e.role===`user`).length===1&&q.items.filter(e=>e.role===`assistant`).length===1&&!q.items.some(e=>e.role===`task`),We=e=>{G(!0),i&&window.localStorage.setItem(`personal-calibration:${i}`,`1`),e&&(L.current+=1,V({id:L.current,text:e}))};(0,Q.useEffect)(()=>{I.current=null},[K.conversationId]),(0,Q.useEffect)(()=>{if(!ue.hasToken||!be&&!xe&&!Se&&!(K.projectPreparation&&Ee)||Ce&&!K.projectPreparation||K.showSessionLoading||K.sessionRoutePending||!K.conversationId&&!K.projectPreparation)return;let e=K.projectPreparation&&Ee?ki(Ee)??void 0:void 0,t=()=>{let e=new URLSearchParams(P);e.delete(`skill`),e.delete(`slash`),e.delete(f?`chatDraft`:`draft`),K.projectPreparation&&(e.delete(`autoSend`),e.delete(`attachmentsHandoff`));let t=e.toString();j({pathname:N,search:t?`?${t}`:``},{replace:!0})},n=(n,r)=>{I.current!==r&&(I.current=r,queueMicrotask(()=>{e?.length?Wp(n,e):(L.current+=1,V({id:L.current,text:n})),t()}))},r=Jr(be,Se);if(r||e?.length){let e=`${K.conversationId}:draft:${r}`;n(r??``,e);return}if(be){t();return}if(!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(xe)){t();return}let i=`${K.conversationId}:slash:${xe}`;I.current!==i&&queueMicrotask(()=>{(async()=>{try{let e=await bo(),t=xe.toLowerCase(),n=e.find(e=>e.name.toLowerCase()===t||Array.isArray(e.aliases)&&e.aliases.some(e=>e.toLowerCase()===t));if(n){if(I.current===i)return;I.current=i,L.current+=1,V({id:L.current,text:xw(n)})}}finally{t()}})()})},[ue.hasToken,f,be,xe,Se,Ce,Ee,K.projectPreparation,P,K.showSessionLoading,K.sessionRoutePending,K.conversationId,j,N]);let{scrollRef:Ge,composerDockRef:Ke,atBottom:qe,registerListContentRef:Je,scrollToBottom:Ye,replySpaceRef:Xe,reserveReplySpace:Ze,onScroll:Qe}=ow({hasToken:ue.hasToken,showSessionLoading:K.showSessionLoading,conversationId:K.conversationId,chatMessages:q.items,streaming:fe.streaming,hasMore:K.hasMore,loadingMore:K.loadingMore,loadMoreMessages:K.loadMoreMessages});(0,Q.useEffect)(()=>{if(!f||!qe||!p?.length)return;let e=requestAnimationFrame(()=>Ye(!1));return()=>cancelAnimationFrame(e)},[f,p,qe,Ye]);let $e=MO({enabled:o,conversationId:K.conversationId,messages:q.items,viewportRef:Ge}),[et,nt]=(0,Q.useState)(0),rt=(0,Q.useRef)(null),it=(0,Q.useRef)(null),at=(0,Q.useMemo)(()=>{let e=-1;for(let t of de.items)typeof t.displayIndex==`number`&&Number.isFinite(t.displayIndex)&&(e=Math.max(e,t.displayIndex));return e<0?0:Math.max(0,e+1-q.items.length)},[q.items.length,de.items]),ot=(0,Q.useCallback)(e=>{let t=Ge.current;if(!t)return!1;let n=t.querySelector(`[data-chat-message-index="${e}"]`);if(!n){let n=UC(t)?.reveal(e)??!1;return n&&nt(e),n}WC(t),nt(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:BC()}),!0},[Ge]),st=(0,Q.useCallback)(()=>{let e=Ge.current;if(!e)return;let t=zC(e);nt(e=>e===t?e:t)},[Ge]),ct=(0,Q.useCallback)(()=>{rt.current??=requestAnimationFrame(()=>{rt.current=null,st()})},[st]),lt=(0,Q.useCallback)(()=>{Qe(),ct()},[Qe,ct]),ut=(0,Q.useCallback)(e=>{let t=e-at;if(t<0||t>=q.items.length){t<0&&K.hasMore&&!K.loadingMore&&(it.current=e,K.loadMoreMessages());return}it.current=null,ot(t)},[q.items.length,ot,K.hasMore,K.loadMoreMessages,K.loadingMore,at]);Pw({conversationId:K.conversationId,turnId:x,messages:q.items,ready:ge,hasMore:K.hasMore,loadingMore:K.loadingMore,loadMore:K.loadMoreMessages,reveal:ot,onLocated:C});let dt=XO({conversationId:K.conversationId,taskId:ce,messages:q.items,displayOffset:at,viewportRef:Ge,onRevealDisplayIndex:ut});(0,Q.useEffect)(()=>{let e=it.current;if(e==null)return;let t=e-at;if(t>=0&&t<q.items.length){it.current=null,requestAnimationFrame(()=>ot(t));return}if(t<0&&K.hasMore&&!K.loadingMore){K.loadMoreMessages();return}(t>=q.items.length||!K.hasMore)&&(it.current=null)},[q.items.length,ot,K.hasMore,K.loadMoreMessages,K.loadingMore,at]),(0,Q.useEffect)(()=>{ct()},[q.items.length,ct,K.conversationId,at]),(0,Q.useEffect)(()=>()=>{rt.current!=null&&cancelAnimationFrame(rt.current)},[]),(0,Q.useEffect)(()=>{V(null)},[K.conversationId]);let ft=(0,Q.useCallback)(e=>{L.current+=1,V({id:L.current,text:e.prompt})},[]),pt=!!(K.conversationId&&!K.showSessionLoading&&!K.sessionRoutePending&&K.workspaceSource!==`project`&&K.workspaceSource!==`execution_environment`&&q.items.length===0),mt=so(e=>e.setAgentId);(0,Q.useEffect)(()=>{if(ue.hasToken)return mt(me.displayAgentId),()=>mt(``)},[ue.hasToken,me.displayAgentId,mt]);let ht=K.conversationPhase===`creating-session`,gt=K.conversationPhase===`loading-history`;kf(o&&!gt?De:null,o);let _t=ht||gt,vt=gt,yt=!vt&&q.items.length===0&&!p?.length&&!fe.streaming,bt=(0,Q.useMemo)(()=>{if(fe.taskPlan){let e=gO(fe.taskPlan);return e?{plan:e,changeSummary:kO(q.items,fe.streaming)?.changeSummary??null}:null}return kO(q.items,fe.streaming)},[q.items,fe.streaming,fe.taskPlan]),xt=(0,Q.useMemo)(()=>(K.sessionRoutePending&&K.decodedKey?K.decodedKey:K.conversationId)?K.sessionName?.trim()||k.chat.newSession:k.nav.chat,[K.conversationId,K.sessionName,K.sessionRoutePending,K.decodedKey,k.nav.chat,k.chat.newSession]),St=Pe?.sourceNoteId??null,Ct=dD(De,P.get(`projectId`)),wt=K.projectPreparation?.project??Ct,[Tt,Et]=(0,Q.useState)([]),[Dt,Ot]=(0,Q.useState)([]),kt=m(e=>e.baseUrl),At=De?ts(kt,A,De):null,jt=es.store(e=>At?e.drafts[At]:void 0),Mt=(0,Q.useRef)(void 0),[Nt,Pt]=(0,Q.useState)(!1);(0,Q.useLayoutEffect)(()=>{De&&De!==Mt.current&&(Mt.current=void 0)},[De]),(0,Q.useEffect)(()=>{let e=!1;if(te(null),St)return Re(St).then(t=>{e||te(t?.title?.trim()||null)}).catch(()=>{e||te(null)}),()=>{e=!0}},[St]);let Ft=ee||Pe?.sourceNoteTitle||k.chat.sourceNoteFallbackTitle,It=jA({enabled:ue.hasToken&&!!(De||wt)&&!ye&&q.items.length===0&&!K.showSessionLoading&&!K.sessionRoutePending,conversationId:De,suppressProjectContext:!!(St||Oe||K.workspaceSource===`execution_environment`||K.workspaceSource===`session_override`||K.workspaceSource===`agent_workspace`),project:wt,task:le}),Lt=(0,Q.useMemo)(()=>me.chatAgents?.items.find(e=>e.id===me.displayAgentId)??{id:me.displayAgentId},[me.chatAgents?.items,me.displayAgentId]),Rt=(0,Q.useMemo)(()=>js(It.context,k.chat.welcomeSpotlight,{contextStatus:It.status}),[k.chat.welcomeSpotlight,It.context,It.status]),zt=(0,Q.useMemo)(()=>Rt.recommendation?{suggestionId:Rt.recommendation.id,contextKind:Rt.contextKind,prompt:Rt.recommendation.prompt}:null,[Rt]),Bt=(0,Q.useRef)(0);(0,Q.useEffect)(()=>(Bt.current++,()=>{Bt.current++}),[i,A]);let Vt=(0,Q.useCallback)((...t)=>{let n=()=>{let[e,n,r,i,a]=t;if(jt&&(he||e.trim().startsWith(`/`)))return Nn.getState().setShellError(k.chat.pageContext.pending),!1;if(he)return fe.replaceLatestUserTurn(he.turnId,e,n,r,i);let o=!1,s=fe.sendMessage(e,n,r,i,void 0,jt?.envelope,(e,t)=>{o=!0,Ze(t??e),a?.onDispatched?.({clientSubmissionId:e,messageRenderKey:t})});return o?(At&&jt&&es.remove(At,jt),!0):s};if(!e)return n();let r=Bt.current;return e().then(e=>e&&r===Bt.current?n():!1)},[e,he,fe.replaceLatestUserTurn,fe.sendMessage,jt,At,k.chat.pageContext.pending,Ze]),Ht=uD({preparation:K.projectPreparation,conversationId:De,ready:K.modelConfigReady&&!_t,onSend:Vt}),Ut=(0,Q.useCallback)(e=>{if(!e.turnId||!K.conversationId)return;let t=bn.getGeneration(K.conversationId),n=bn.getResumeRunId(K.conversationId);pe.beginEditTurn(e.turnId,{text:e.userTurnDocument?Mn(e.userTurnDocument):Rn(e.content),attachments:Ln(e.attachments)??[],contextRefs:e.contextRefs?.flatMap(e=>e.kind===`mcp_resource`?[]:[{refId:e.refId,kind:e.kind,sourceId:e.sourceId,expectedVersion:e.version,title:e.title,fileKind:e.fileKind}])??[]}).then(e=>{e&&fe.settleStoppedRun(t,n)})},[pe.beginEditTurn,fe.settleStoppedRun,K.conversationId]),Wt=(0,Q.useCallback)(e=>{if(pe.composerMode.kind===`editFollowUp`)pe.beginEditFollowUp(pe.composerMode.inputId);else if(pe.composerMode.kind===`editTurn`&&K.conversationId){let t=bn.getGeneration(K.conversationId),n=bn.getResumeRunId(K.conversationId);pe.beginEditTurn(pe.composerMode.turnId,e).then(e=>{e&&fe.settleStoppedRun(t,n)})}},[pe.composerMode,pe.beginEditFollowUp,pe.beginEditTurn,K.conversationId,fe.settleStoppedRun]),Gt=pe.cancelEditor;(0,Q.useEffect)(()=>{if(!Ce||!Se.trim()&&!Ee||!ue.hasToken||K.showSessionLoading||K.sessionRoutePending||!K.conversationId||fe.sending||fe.streaming)return;let e=Jr(be,Se),t=Ee?ki(Ee):void 0;if(!e&&!t?.length)return;let n=`${K.conversationId}:auto-send:${e??``}:${Ee??``}`;if(I.current===n)return;I.current=n;let r=new URLSearchParams(P);r.delete(`skill`),r.delete(`slash`),r.delete(`draft`),r.delete(`autoSend`),r.delete(`attachmentsHandoff`);let i=r.toString();j({pathname:N,search:i?`?${i}`:``},{replace:!0}),Vt(e??``,t??void 0)},[ue.hasToken,Ce,Ee,Se,Vt,j,N,P,K.conversationId,K.sessionRoutePending,K.showSessionLoading,be,fe.sending,fe.streaming]);let Kt=(0,Q.useCallback)(()=>{R.current?.reject(),R.current=null,re(null),ae(!1)},[]);(0,Q.useEffect)(()=>{Kt()},[Kt,St]);let Jt=(0,Q.useMemo)(()=>({title:k.chat.timelineTitle,turn:k.chat.timelineTurn,messageFallback:k.chat.timelineMessageFallback,toolCount_one:k.chat.timelineToolCount_one,toolCount_other:k.chat.timelineToolCount_other,searchedWeb:k.chat.stepSearchedWeb,searchedMemory:k.chat.stepSearchedMemory,searchedCode:k.chat.stepSearchedCode,searched:k.chat.stepSearched,readFile:k.chat.stepReadFile,runCommand:k.chat.stepRunCommand,listDirectory:k.chat.stepListDirectory,writeFile:k.chat.stepWriteFile,editFile:k.chat.stepEditFile,openUrl:k.chat.stepOpenUrl,fetchUrl:k.chat.stepFetchUrl,unknownTool:k.chat.stepUnknownTool}),[k.chat.timelineTitle,k.chat.timelineTurn,k.chat.timelineMessageFallback,k.chat.timelineToolCount_one,k.chat.timelineToolCount_other,k.chat.stepSearchedWeb,k.chat.stepSearchedMemory,k.chat.stepSearchedCode,k.chat.stepSearched,k.chat.stepReadFile,k.chat.stepRunCommand,k.chat.stepListDirectory,k.chat.stepWriteFile,k.chat.stepEditFile,k.chat.stepOpenUrl,k.chat.stepFetchUrl,k.chat.stepUnknownTool]),Yt=(0,Q.useCallback)(async e=>{if(!St)return;R.current?.reject(),ae(!1);let t=k.chat.sourceNoteAppendSourceLine.replace(`{{time}}`,new Date().toLocaleString(O));return re({heading:k.chat.sourceNoteAppendHeading,content:`${t}\n\n${e.trim()}`}),new Promise((e,t)=>{R.current={sourceNoteId:St,resolve:e,reject:t}})},[O,k.chat.sourceNoteAppendHeading,k.chat.sourceNoteAppendSourceLine,St]),Xt=`${M.pathname}${M.search}`,Zt=(0,Q.useCallback)(async e=>{try{let t=await He(e.trim(),`web`);ya(`success`,k.chat.messageSavedToNote,void 0,{href:tt(Xt,t.id)})}catch(e){throw ya(`error`,e instanceof Error?e.message:k.notes.quickCaptureFailed),e}},[Xt,k.chat.messageSavedToNote,k.notes.quickCaptureFailed]),Qt=(0,Q.useCallback)(async()=>{let e=R.current;if(!e||!ne)return;let t=ne.heading.trim()||k.chat.sourceNoteAppendHeading,n=ne.content.trim();if(n){ae(!0),se(null);try{await Ve(e.sourceNoteId,n,t),window.dispatchEvent(new CustomEvent(`note-updated`,{detail:{noteId:e.sourceNoteId,source:`chat`,conversationId:De}})),e.resolve(),R.current=null,re(null)}catch(e){se(e instanceof Error?e.message:k.chat.sourceNoteSaveFailed)}finally{ae(!1)}}},[De,k.chat.sourceNoteAppendHeading,k.chat.sourceNoteSaveFailed,k.chat.sourceNoteSaveSuccess,ne]),$t=(0,Q.useCallback)(async e=>{if(!St)return;let t=e.trim().split(/\n+/)[0]?.replace(/^[-#*>\s]+/,``).trim()||k.chat.sourceNoteTaskFallbackTitle;try{await Be(t.slice(0,120),{sourceNoteId:St,sourceConversationId:De})}catch(e){throw ya(`error`,e instanceof Error?e.message:k.chat.sourceNoteTaskFailed),e}},[De,k.chat.sourceNoteTaskFailed,k.chat.sourceNoteTaskFallbackTitle,k.chat.sourceNoteTaskSuccess,St]),en=(0,Q.useCallback)(async()=>{if(!St)return;let t=Bt.current;if(e&&(!await e()||t!==Bt.current))return;let n=k.chat.sourceNoteDigestPrompt.replace(`{{title}}`,Ft);if(fe.streaming||fe.sending){pe.addPendingFollowUp(n),va({tone:`info`,status:`done`,title:k.chat.sourceNoteDigestQueued,source:O===`zh`?`笔记整理`:`Note digest`,dedupeKey:St?`note-digest:${St}`:void 0});return}fe.sendMessage(n)},[e,pe,O,k.chat.sourceNoteDigestPrompt,k.chat.sourceNoteDigestQueued,St,Ft,fe]),tn=(0,Q.useCallback)(async e=>{if(!(Nt||Ht.busy)){if(K.projectPreparation){j(Xr(e),{state:{forceNewChat:!0,agentId:me.displayAgentId,temporary:K.userContextMode===`temporary`}});return}if(!(Mt.current!==void 0||fe.sending||fe.streaming||_t)){Mt.current=De,Pt(!0);try{e?j(Xr(e),{state:{forceNewChat:!0,agentId:me.displayAgentId,temporary:K.userContextMode===`temporary`}}):await K.createNewSession({forceNew:!0,projectId:e,temporary:K.userContextMode===`temporary`})}catch(e){Mt.current=void 0,ya(`error`,k.chat.composerContext.changeFailed,{error:e instanceof Error?e.message:String(e)})}finally{Pt(!1)}}}},[De,_t,k.chat.composerContext.changeFailed,Nt,Ht.busy,K.createNewSession,K.projectPreparation,K.userContextMode,fe.sending,fe.streaming,j,me.displayAgentId]),nn=(0,Q.useCallback)(()=>tn(null),[tn]),rn=(0,Q.useCallback)(async e=>{if(!(Nt||_t||fe.sending||fe.streaming||!pt)){Pt(!0);try{await K.onSessionWorkingDirectoryChange(e)}finally{Pt(!1)}}},[Nt,_t,fe.sending,fe.streaming,pt,K.onSessionWorkingDirectoryChange]),an=(0,Q.useMemo)(()=>({project:wt,draftRefs:Tt,draftAttachments:Dt,draftPage:jt?{id:`${jt.envelope.tabId}:${jt.envelope.sequence}`,title:jt.title||(O===`zh`?`当前页面`:`Current page`)}:void 0,onLeaveProject:Nt||Ht.busy?void 0:nn,leaveProjectLabel:k.chat.scopeRemoveProject,onDraftSourceNote:St?en:void 0,draftSourceNoteLabel:k.chat.sourceNoteDigestAction}),[Nt,Ht.busy,wt,Tt,Dt,jt,O,nn,k.chat.scopeRemoveProject,St,en,k.chat.sourceNoteDigestAction]);return ue.hasToken?(fe.error?Bn(fe.error):null)?.code===`session_not_found`?(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col overflow-hidden bg-surface-panel`,children:[(0,Z.jsx)(iO,{}),(0,Z.jsx)(YD,{chatHeadline:k.chat.sessionNotFoundTitle,chatAgents:me.chatAgents?.items??[],showChatAgentSelector:!1,chatAgentId:me.displayAgentId,onChatAgentChange:me.onChatAgentChange,chatAgentDisabled:!0}),(0,Z.jsx)(`main`,{className:`mx-auto flex w-full max-w-xl flex-1 items-center px-4 py-12 sm:px-6`,children:(0,Z.jsx)(`div`,{className:`w-full`,children:(0,Z.jsx)(oh,{errorText:fe.error})})})]}):(0,Z.jsx)(B_,{value:Fe,children:(0,Z.jsxs)(`div`,{className:Y(`flex h-full min-h-0 flex-1 flex-col bg-surface-panel`,f?`overflow-clip`:`overflow-hidden`),children:[(0,Z.jsx)(iO,{}),!r||f?(0,Z.jsx)(YD,{inline:f,chatHeadline:_e&&q.items.length===0?k.skills.findTitle:xt,chatAgents:me.chatAgents?.items??[],showChatAgentSelector:!f&&!ye&&me.showChatAgentSelector,chatAgentId:me.displayAgentId,onChatAgentChange:me.onChatAgentChange,chatAgentDisabled:Ht.busy||Nt||_t&&!K.projectPreparation,conversationId:K.conversationId,hasMessages:!_t&&q.items.length>0,workspacePath:K.effectiveWorkspacePath,userContextMode:K.userContextMode,projectId:wt?.id,context:an,canChangeWorkspace:!1,workspaceDisabled:_t||fe.sending||fe.streaming,onWorkspaceChange:K.onSessionWorkingDirectoryChange,prepareTerminalSession:K.projectPreparation?Ht.prepareSession:void 0,terminalDisabled:!!(K.projectPreparation&&(Ht.busy||!Ht.allowed||Ht.checking)),showContextControls:!ye,onFindOpen:dt.show}):null,(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 w-full flex-1 flex-col`,children:[!r&&Pe?.parentConversationId?(0,Z.jsxs)(`div`,{className:`shrink-0 border-b border-edge-subtle bg-surface-panel/80 px-3 py-2 text-xs text-fg-muted sm:px-5 xl:px-6`,children:[(0,Z.jsx)(u,{to:`/chat/${encodeURIComponent(Pe.parentConversationId)}`,className:`font-medium text-accent transition-colors hover:text-accent-fg`,children:k.chat.forkedFromConversation.replace(`{{name}}`,Pe.forkedFromSessionName||k.chat.forkedFromConversationFallback)}),(0,Z.jsx)(`span`,{className:`ms-2`,children:k.chat.forkSharedWorkspaceNotice})]}):null,M.state?.fromAgentEditor&&me.displayAgentId?(0,Z.jsx)(`div`,{className:`shrink-0 border-b border-edge-subtle bg-surface-panel/80 px-3 py-1.5 sm:px-5 xl:px-6`,children:(0,Z.jsxs)(u,{to:Ko(me.displayAgentId),className:`inline-flex items-center gap-1 text-xs font-medium text-accent transition-colors hover:text-accent-fg`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`←`}),k.agentsSettings.backToEditor]})}):null,r&&St&&!n?(0,Z.jsx)(`div`,{className:`shrink-0 border-b border-edge-subtle bg-surface-panel/80 px-3 py-1.5 sm:px-5 xl:px-6`,children:(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:k.chat.sourceNoteBanner.replace(`{{title}}`,Ft)}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex h-7 items-center gap-1.5 rounded-md border border-edge-subtle px-2 font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,onClick:en,children:[(0,Z.jsx)(Te,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:k.chat.sourceNoteDigestAction})]}),(0,Z.jsx)(u,{to:tt(`${M.pathname}${M.search}`,St),className:`font-medium text-accent transition-colors hover:text-accent-fg`,children:k.chat.sourceNoteOpen})]})]})}):null,(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(NO,{open:dt.open,query:dt.query,activeIndex:dt.activeIndex,resultCount:dt.resultCount,searching:dt.searching,truncated:dt.truncated,limitedToLoaded:dt.limitedToLoaded,inputRef:dt.inputRef,labels:k.chat.find,onQueryChange:dt.setQuery,onPrevious:dt.previous,onNext:dt.next,onClose:dt.close}),!r||f?(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 left-1/2 z-20 hidden w-full max-w-[calc(var(--max-width-chat-frame)+8rem)] -translate-x-1/2 xl:block`,children:(0,Z.jsx)(`div`,{className:`pointer-events-auto absolute inset-y-0 right-0`,children:(0,Z.jsx)(OA,{items:de.items,activeMessageIndex:et+at,labels:Jt,onSelectMessage:ut})})}):null,(0,Z.jsx)(`div`,{ref:Ge,"data-chat-scroll-viewport":!0,className:Y(`chat-messages chat-messages--wide-viewport relative min-h-0 flex-1 overflow-y-auto overflow-x-hidden [overflow-anchor:none] [scrollbar-gutter:stable_both-edges]`,yt?`chat-messages--compact-welcome pt-5 pb-2`:`py-4`),onScroll:lt,"data-chat-find-open":dt.open?``:void 0,children:(0,Z.jsx)(`div`,{className:r&&!o?`px-3`:`px-3 sm:px-5 xl:px-6`,children:(0,Z.jsx)(`div`,{"data-chat-message-frame":!0,className:Y(`mx-auto w-full min-w-0`,(!r||o||f)&&`max-w-[var(--max-width-chat-frame)]`),children:gt?(0,Z.jsxs)(`div`,{className:`flex min-h-[min(40vh,20rem)] w-full flex-col gap-10 py-8`,"aria-busy":`true`,children:[(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(qt,{className:`h-11 w-[min(70%,22rem)] rounded-2xl`})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(qt,{className:`h-4 w-24`}),(0,Z.jsx)(qt,{className:`h-4 w-[min(82%,36rem)]`}),(0,Z.jsx)(qt,{className:`h-4 w-[min(74%,32rem)]`}),(0,Z.jsx)(qt,{className:`h-4 w-[min(48%,22rem)]`})]}),(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(qt,{className:`h-11 w-[min(62%,18rem)] rounded-2xl`})})]}):(0,Z.jsxs)(Z.Fragment,{children:[K.loadingMore?(0,Z.jsx)(`div`,{className:`mb-3 text-center text-xs text-fg-muted`,children:k.chat.loadOlder}):null,fe.error?(0,Z.jsx)(`div`,{className:Y(`sticky z-20 shrink-0 bg-transparent pe-2`,yt?`-top-5`:`-top-4`),children:(0,Z.jsx)(oh,{errorText:fe.error})}):null,Fe&&!f&&De?(0,Z.jsx)(Io,{conversationId:De,language:O,running:fe.streaming||fe.sending}):null,Fe&&!f&&q.items.length>0?(0,Z.jsx)(u,{className:`mb-4 inline-block rounded-md px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover`,to:`/automations`,children:O===`zh`?`← 定时任务`:`← Scheduled tasks`}):null,!r&&ce?(0,Z.jsx)(`div`,{className:`hidden md:block`,children:(0,Z.jsx)(lc,{taskId:ce})}):null,null,null,!r&&De?(0,Z.jsx)(B,{eventType:`session.transcript.updated`,source:`sessions`,payloadKey:`conversationId`,payloadValue:De,className:`mb-6`}):null,(0,Z.jsx)(XC,{scrollRef:Ge,messages:q.items,timelineEntries:p,personal:o,authToken:A??void 0,conversationId:K.decodedKey??K.conversationId,projectId:wt?.id,streaming:fe.streaming,sending:fe.sending,progress:fe.progress,reasoningLevel:K.reasoningLevel,showAssistantWorkLog:!0,registerListContentRef:Je,replySpaceRef:Xe,onPickWelcomePrompt:ft,welcomeSpotlight:Rt,welcomeOverlay:o&&s?(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col items-start gap-3 px-4 py-8 text-fg`,children:[(0,Z.jsx)(`div`,{className:`flex size-16 items-center justify-center rounded-3xl bg-accent/10 text-3xl text-accent`,"aria-hidden":!0,children:s.avatar??`✦`}),(0,Z.jsx)(`h2`,{className:`text-2xl font-semibold`,children:O===`zh`?`你好${s.addressAs?`,${s.addressAs}`:``}。我们从哪里开始?`:`Hello${s.addressAs?`, ${s.addressAs}`:``}. Where should we start?`}),(0,Z.jsx)(`p`,{className:`max-w-xl text-sm leading-relaxed text-fg-muted`,children:s.opening??(O===`zh`?`想讨论问题、整理思路或推进工作,都可以直接说。`:`Bring a question, an idea, or work to move forward.`)})]}):Fe?(0,Z.jsxs)(`div`,{className:`mx-auto max-w-xl px-4 py-10 text-center`,children:[(0,Z.jsx)(`h2`,{className:`text-xl font-semibold text-fg`,children:Ie?O===`zh`?`想怎么调整这个任务?`:`What would you like to change?`:O===`zh`?`你想安排什么任务?`:`What would you like to schedule?`}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:Ie?O===`zh`?`直接说要改的内容、时间,或告诉我暂停、恢复。`:`Change what it does or when it runs, or ask to pause or resume.`:O===`zh`?`说说要做的事,时间和细节我们一起确定。`:`Tell us what to do. We’ll work out the timing and details together.`}),f?null:(0,Z.jsx)(u,{className:`mt-4 inline-block text-xs text-fg-muted hover:text-fg`,to:`/automations`,children:O===`zh`?`← 返回定时任务`:`← Back to scheduled tasks`})]}):ye?(0,Z.jsx)(NA,{agentName:Lt.name?.trim()||me.displayAgentId,messages:k.agentsSettings,disabled:K.sessionRoutePending||K.showSessionLoading,onPick:e=>{L.current+=1,V({id:L.current,text:e})}}):_e?(0,Z.jsx)(Rw,{sk:k.skills,disabled:K.sessionRoutePending||K.showSessionLoading,onPick:e=>{L.current+=1,V({id:L.current,text:Jr(`find-skills`,e)})}}):void 0,compactWelcome:r,onDeleteRound:ce?void 0:fe.deleteMessageRound,onRetryUserMessageRound:ce?void 0:fe.retryUserMessageRound,deleteRoundDisabled:fe.streaming||fe.sending,onEditUserMessage:ce?void 0:Ut,editLatestUserOnly:!0,editRequiresTurnId:!0,onSaveAssistantAsNote:Zt,onSaveAssistantToSourceNote:St?Yt:void 0,onExtractAssistantTask:St?$t:void 0,onForkAssistantTurn:!ce&&Pe?.sessionType===`chat`?Le:void 0,trailingContent:Ue?(0,Z.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl rounded-2xl border border-edge-subtle bg-surface-panel px-4 py-3 text-sm`,children:[(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:O===`zh`?`这个回答合适吗?点选后可以在输入框修改,再发给我。`:`Did that response work for you? Pick an adjustment, edit it, then send.`}),(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[[[O===`zh`?`再短一点`:`Make it shorter`,O===`zh`?`这次回答再短一点。`:`Please make this answer shorter.`],[O===`zh`?`更温和一点`:`A little gentler`,O===`zh`?`这次回答的语气更温和一点。`:`Please make this answer a little gentler.`]].map(([e,t])=>(0,Z.jsx)(`button`,{type:`button`,onClick:()=>We(t),className:`rounded-full border border-edge px-3 py-1.5 text-xs text-fg transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:e},e)),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>We(),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:O===`zh`?`这样就好`:`Looks good`})]})]}):null},De)]})})})}),(0,Z.jsx)(`div`,{ref:Ke,className:Y(`chat-composer-dock pointer-events-none absolute inset-x-0 bottom-0 z-10`,o?`[--chat-composer-bottom-radius:1.65rem]`:`[--chat-composer-bottom-radius:1rem]`,yt?`[--chat-composer-bottom-space:max(0.625rem,env(safe-area-inset-bottom))]`:`[--chat-composer-bottom-space:max(0.5rem,env(safe-area-inset-bottom))] sm:[--chat-composer-bottom-space:max(1rem,env(safe-area-inset-bottom))]`),children:(0,Z.jsx)(`div`,{className:r&&!o?`px-3`:`px-3 sm:px-5 xl:px-6`,children:(0,Z.jsxs)(`div`,{"data-chat-composer-frame":!0,"data-primary-chat-composer":!r||void 0,className:Y(`pointer-events-auto relative mx-auto w-full min-w-0 pb-[var(--chat-composer-bottom-space)]`,(!r||o||f)&&`max-w-[calc(var(--max-width-chat-frame)+14px)]`,yt?`pt-2.5`:`pt-2 sm:pt-4`),children:[(0,Z.jsx)(ew,{visible:!K.showSessionLoading&&!qe,onClick:()=>Ye(!0),running:fe.streaming||fe.sending}),(0,Z.jsx)(`div`,{className:`absolute bottom-full right-0 z-20 mb-2 flex items-center rounded-full border border-edge-subtle bg-surface-overlay p-1 shadow-elevated backdrop-blur-sm empty:hidden xl:hidden`,children:!r||f?(0,Z.jsx)(xA,{items:de.items,activeMessageIndex:et+at,labels:Jt,openLabel:k.chat.timelineOpen,closeLabel:k.chat.timelineClose,currentLabel:k.chat.timelineCurrent,onSelectMessage:ut}):null}),(0,Z.jsx)(ff,{prompt:J.clarifyPrompt,submitting:J.clarifySubmitting,submitError:J.clarifySubmitError,labels:k.chat,onSubmit:J.submitClarifyAnswer,onAgentDecide:J.letAgentDecideClarification,onCancel:J.cancelClarification}),bt?(0,Z.jsx)(fO,{plan:bt.plan,changeSummary:bt.changeSummary,isStreaming:fe.streaming,labels:{heading:k.chat.planHeading,stepProgress:k.chat.planStepProgress,completedProgress:k.chat.planCompletedProgress,finished:k.chat.planFinished,ended:k.chat.planEnded,planned:k.chat.planPlanned,filesChangedOne:k.chat.planFilesChanged_one,filesChangedOther:k.chat.planFilesChanged_other}}):null,_e&&q.items.length>0?(0,Z.jsx)(`div`,{className:`mb-2 text-right`,children:(0,Z.jsx)(u,{to:`/capabilities/skills`,className:`text-xs text-accent-fg hover:underline`,children:k.skills.findBack})}):null,(0,Z.jsx)(Mw,{}),(0,Z.jsx)(Iw,{conversationId:K.conversationId,active:fe.streaming||fe.sending}),(0,Z.jsx)(iD,{personal:o,nextTurnSuggestionsEnabled:!fe.streaming,onPersonalSendDispatched:o?$e:void 0,placeholder:o?fe.streaming||fe.sending?O===`zh`?`继续聊,或补充要求…`:`Keep talking or add a detail…`:O===`zh`?`发消息给「${s?.name||`Personal AI`}」…`:`Message ${s?.name||`Personal AI`}…`:ye?k.agentsSettings.setupComposerPlaceholder:_e?k.skills.findPlaceholder:void 0,composerContext:!ye&&!r&&!ce&&!he&&!vt&&q.items.length===0?{project:wt,disabled:Nt||Ht.busy||_t&&!K.projectPreparation,environmentPicker:K.projectPreparation?(0,Z.jsx)(cD,{selection:Ht}):void 0,workspacePath:K.effectiveWorkspacePath,canChangeWorkspace:pt,onProjectChange:tn,onWorkspaceChange:rn}:void 0,contextRefs:Tt,pageContextPreview:jt&&At?(0,Z.jsx)(aD,{draft:jt,disabled:fe.sending,waiting:fe.streaming,onRemove:()=>es.remove(At,jt)}):void 0,setContextRefs:Et,onDraftAttachmentsChange:Ot,disabled:g||gt||Ht.busy||Nt,sendDisabled:pe.controlPending||pe.control.phase===`stopping`||g||!K.modelConfigReady||!K.projectPreparation&&_t||!!(K.projectPreparation&&!Ht.allowed)||K.modelConfigSaving||Ht.busy||Nt,sending:fe.sending,streaming:fe.streaming,conversationId:K.conversationId,unboundDraftKey:K.conversationId?void 0:JSON.stringify([N,P.get(`projectId`)]),getDraftHandoffTarget:Ht.getDraftHandoffTarget,prepareContextSession:K.projectPreparation?Ht.prepareSession:void 0,welcomeDraftSeed:H??z,welcomeSuggestion:!_e&&yt?zt:null,onAcceptWelcomeSuggestion:ft,thinkingLevel:K.thinkingLevel,modelSupportsThinking:K.modelSupportsThinking,onThinkingChange:K.onSessionThinkingLevelChange,onSend:Ht.send,composerMode:pe.composerMode,onRestoreEditor:pe.restoreEditor,onReacquireEdit:Wt,inputControl:pe.control,onResumeQueue:()=>void pe.resumeQueue().catch(()=>{}),editingUserTurnId:he?.turnId,onCancelUserMessageEdit:Gt,onAbort:()=>void fe.abort().catch(()=>{}),onAddPendingFollowUp:async(t,n,r,i,a)=>{let o=Bt.current;if(e&&(!await e()||o!==Bt.current))throw Error(O===`zh`?`请先保存笔记,再发送消息。`:`Save the note before sending.`);await pe.addPendingFollowUp(t,n,r,jt?.envelope,i,a),At&&jt&&es.remove(At,jt)},onSteeringInterrupt:jt?void 0:async(t,n,r)=>{let i=Bt.current;return e&&(!await e()||i!==Bt.current)?!1:fe.interruptAndSend(t,n,void 0,r)},pendingFollowUps:pe.pendingFollowUps,editingFollowUpId:pe.editingFollowUpId,onBeginEditFollowUp:pe.beginEditFollowUp,onCancelEditFollowUp:pe.cancelEditFollowUp,onCommitEditFollowUp:(e,t,n,r,i)=>pe.commitEditFollowUp(e,t,n,r,i),onPendingFollowUpRemove:pe.removePendingFollowUp,onPendingFollowUpMove:pe.movePendingFollowUp,onPendingFollowUpReorder:pe.reorderPendingFollowUp,onPendingFollowUpSteer:e=>void pe.steerPendingFollowUp(e).catch(()=>{}),onPendingFollowUpSend:e=>void pe.sendQueuedInput(e).catch(()=>{}),steeringFollowUpId:pe.steeringFollowUpId,sessionModel:K.sessionModel,showModelSelector:!o,onModelChange:K.onSessionModelChange,modelDisabled:_t&&!K.projectPreparation||Ht.busy||K.modelConfigSaving,onChatAgentChange:!o&&!ye&&!ce&&me.showChatAgentSelector?me.onChatAgentChange:void 0,currentAgentId:me.displayAgentId,voiceAgentName:o&&s?s.name:Lt.name,voiceTaskId:ce??void 0,prepareVoiceSession:K.projectPreparation?Ht.prepareSession:void 0})]})})})]})]}),(!r||f)&&De&&window.electronAPI?.terminal?(0,Z.jsx)(Q.Suspense,{fallback:null,children:(0,Z.jsx)(FA,{conversationId:De},De)}):null,(0,Z.jsx)(D,{open:ne!==null,onOpenChange:e=>{!e&&!ie&&Kt()},children:(0,Z.jsxs)(w,{children:[(0,Z.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[1px]`}),(0,Z.jsxs)(T,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(82vh,42rem)] w-[min(100%-2rem,44rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:[(0,Z.jsxs)(`div`,{className:`shrink-0 border-b border-edge-subtle px-5 py-4`,children:[(0,Z.jsx)(E,{className:`text-base font-semibold text-fg`,children:k.chat.sourceNoteSaveDialogTitle}),(0,Z.jsx)(S,{className:`mt-1 text-sm text-fg-muted`,children:k.chat.sourceNoteSaveDialogDescription.replace(`{{title}}`,Ft)})]}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-5 py-4`,children:[oe?(0,Z.jsxs)(`p`,{className:`rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-sm text-danger`,role:`alert`,children:[k.chat.sourceNoteSaveFailed,`: `,oe]}):null,(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium text-fg`,children:[(0,Z.jsx)(`span`,{children:k.chat.sourceNoteSaveDialogHeadingLabel}),(0,Z.jsx)(`input`,{value:ne?.heading??``,onChange:e=>re(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:ie})]}),(0,Z.jsxs)(`label`,{className:`flex min-h-0 flex-1 flex-col gap-1.5 text-sm font-medium text-fg`,children:[(0,Z.jsx)(`span`,{children:k.chat.sourceNoteSaveDialogContentLabel}),(0,Z.jsx)(`textarea`,{value:ne?.content??``,onChange:e=>re(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:ie})]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:[(0,Z.jsx)(pi,{type:`button`,variant:`secondary`,onClick:Kt,disabled:ie,children:k.chat.sourceNoteSaveDialogCancel}),(0,Z.jsx)(pi,{type:`button`,variant:`primary`,onClick:()=>void Qt(),disabled:ie||!ne?.content.trim(),children:ie?k.chat.sourceNoteSaveDialogSaving:k.chat.sourceNoteSaveDialogConfirm})]})]})]})})]})}):(0,Z.jsx)(`div`,{className:`mx-auto w-full max-w-[var(--max-width-chat-frame)] px-3 py-16 text-center text-sm leading-relaxed text-fg-muted sm:px-5`,children:k.chat.needToken})}export{Qs as $,If as A,ff as B,$f as C,as as Ct,zf as D,Rf as E,Cf as F,sc as G,lc as H,Ef as I,Gs as J,nc as K,_f as L,Of as M,kf as N,Lf as O,Df as P,ac as Q,vf as R,Xf as S,os as St,Bf as T,cc as U,cf as V,oc as W,rc as X,Ks as Y,ic as Z,rm as _,ds as _t,Tw as a,Cs as at,Xp as b,cs as bt,cw as c,bs as ct,uw as d,_s as dt,Us as et,ow as f,gs as ft,nm as g,fs as gt,tm as h,ps as ht,Nw as i,ws as it,Pf as j,Vf as k,fw as l,ys as lt,XC as m,ms as mt,PA as n,zs as nt,xw as o,Ss as ot,ew as p,hs as pt,Ws as q,jw as r,Ts as rt,bw as s,xs as st,IA as t,Ls as tt,dw as u,vs as ut,$p as v,us as vt,Uf as w,Wp as x,ss as xt,Zp as y,ls as yt,mf as z};
70
+ `,document.head.appendChild(e)}function VO(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 HO(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 UO(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 WO(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=VO(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 UO(s,n)){let t=HO(o,e.start,e.end);t&&(r.push({messageIndex:i,occurrence:a,range:t}),a+=1)}}}return r}function GO(e,t){let n=zO();if(!n||(BO(),n.registry.delete(IO),n.registry.delete(LO),e.length===0))return;n.registry.set(IO,new n.Highlight(...e.map(e=>e.range)));let r=e[t];r&&n.registry.set(LO,new n.Highlight(r.range))}function KO(){let e=zO();e?.registry.delete(IO),e?.registry.delete(LO)}function qO(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||(GC(e),e.scrollTo({top:Math.max(0,e.scrollTop+r.top-a),behavior:window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}))}function JO(e,t){return t===0?0:(e+t)%t}function YO(e){return`${e.displayIndex}:${e.occurrence}`}function XO(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 ZO(e){let t=(0,X.c)(66),{conversationId:n,taskId:r,messages:i,displayOffset:a,viewportRef:o,onRevealDisplayIndex:s}=e,[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(``),f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=[],t[0]=f):f=t[0];let[p,m]=(0,Q.useState)(f),h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h=[],t[1]=h):h=t[1];let[g,_]=(0,Q.useState)(h),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(0),E=(0,Q.useRef)(null),D=(0,Q.useRef)(null),O=(0,Q.useRef)(n),k=(0,Q.useDeferredValue)(u),A;if(t[2]!==a||t[3]!==p||t[4]!==g){let e=new Map(g.map(nk));for(let t of p){let n={displayIndex:a+t.messageIndex,occurrence:t.occurrence};e.set(YO(n),n)}A=[...e.values()].sort(tk),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),KO(),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=>JO(t+e,j.length))},t[14]=j.length,t[15]=H);let U=H,W,G;t[16]!==U||t[17]!==c||t[18]!==F?(W=()=>{let e=e=>{let t=e.metaKey||e.ctrlKey;if(t&&!e.altKey&&!e.shiftKey&&e.key.toLowerCase()===`f`){if(document.querySelector(`[role="dialog"][data-state="open"]`))return;e.preventDefault(),F();return}if(c){if(t&&!e.altKey&&e.key.toLowerCase()===`g`){e.preventDefault(),U(e.shiftKey?-1:1);return}e.key===`Escape`&&(e.preventDefault(),z())}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},G=[z,U,c,F],t[16]=U,t[17]=c,t[18]=F,t[19]=W,t[20]=G):(W=t[19],G=t[20]),(0,Q.useEffect)(W,G);let ee;t[21]!==k||t[22]!==c||t[23]!==o?(ee=()=>{let e=o.current;if(!c||!e||!k.trim()){m(ek),KO();return}let t=()=>{let t=WO(e,k);m(e=>XO(e,t)?e:t)};t();let n=null,r=new MutationObserver(()=>{n===null&&(n=requestAnimationFrame(()=>{n=null,t()}))});return r.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>{r.disconnect(),n!==null&&cancelAnimationFrame(n)}},t[21]=k,t[22]=c,t[23]=o,t[24]=ee):ee=t[24];let te;t[25]!==k||t[26]!==i||t[27]!==c||t[28]!==o?(te=[k,i,c,o],t[25]=k,t[26]=i,t[27]=c,t[28]=o,t[29]=te):te=t[29],(0,Q.useLayoutEffect)(ee,te);let ne,re;t[30]!==n||t[31]!==k||t[32]!==c||t[33]!==r?(ne=()=>{let e=k.trim();if(!c||!n||!e){_([]),y(!1),x(!1),C(!1);return}let t=new AbortController;_([]),y(!1),x(!1),C(!0);let i=window.setTimeout(()=>{FO(n,e,{taskId:r,signal:t.signal}).then(e=>{_(e.matches),y(e.truncated)}).catch(e=>{e?.name!==`AbortError`&&(_([]),y(!1),x(!0))}).finally(()=>{t.signal.aborted||C(!1)})},150);return()=>{window.clearTimeout(i),t.abort()}},re=[n,k,c,r],t[30]=n,t[31]=k,t[32]=c,t[33]=r,t[34]=ne,t[35]=re):(ne=t[34],re=t[35]),(0,Q.useEffect)(ne,re);let ie,ae;t[36]===j.length?(ie=t[37],ae=t[38]):(ie=()=>{T(e=>Math.min(e,Math.max(0,j.length-1)))},ae=[j.length],t[36]=j.length,t[37]=ie,t[38]=ae),(0,Q.useEffect)(ie,ae);let oe,se;t[39]!==w||t[40]!==j||t[41]!==a||t[42]!==p||t[43]!==s||t[44]!==o?(oe=()=>{let e=j[w],t=o.current;if(!t||!e){GO(p,-1);return}let n=e.displayIndex-a,r=p.findIndex(t=>t.messageIndex===n&&t.occurrence===e.occurrence);GO(p,r),r>=0?qO(t,p[r]):s(e.displayIndex)},se=[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]=oe,t[46]=se):(oe=t[45],se=t[46]),(0,Q.useLayoutEffect)(oe,se);let ce;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(ce=[],t[47]=ce):ce=t[47],(0,Q.useEffect)(QO,ce);let le,ue;t[48]!==n||t[49]!==c?(le=()=>{O.current!==n&&(O.current=n,c&&z())},ue=[z,n,c],t[48]=n,t[49]=c,t[50]=le,t[51]=ue):(le=t[50],ue=t[51]),(0,Q.useEffect)(le,ue);let K,q;t[52]===U?(K=t[53],q=t[54]):(K=()=>U(-1),q=()=>U(1),t[52]=U,t[53]=K,t[54]=q);let de;return t[55]!==w||t[56]!==j.length||t[57]!==b||t[58]!==c||t[59]!==u||t[60]!==v||t[61]!==S||t[62]!==F||t[63]!==K||t[64]!==q?(de={open:c,query:u,inputRef:E,activeIndex:w,resultCount:j.length,truncated:v,limitedToLoaded:b,searching:S,setQuery:V,show:F,close:z,previous:K,next:q},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]=K,t[64]=q,t[65]=de):de=t[65],de}function QO(){return $O}function $O(){return KO()}function ek(e){return e.length===0?e:[]}function tk(e,t){return e.displayIndex-t.displayIndex||e.occurrence-t.occurrence}function nk(e){return[YO(e),e]}function rk(e){let t=String(e??``).trim();return!t||t===`new`?null:t}function ik(e){let t=String(e.streamConversationId??``).trim(),n=rk(e.routeConversationId);return!t||!n?!1:t===n}function ak(e){let t=rk(e.routeConversationId);return t?e.cacheConversationId===t:!1}function ok(e){let t=String(e.chatId??``).trim();if(!t)return!1;let n=rk(e.routeConversationId);return n?n===t:!1}function sk(e,t){return e?`new`:t??null}function ck(e,t){if(!(e||!t))return decodeURIComponent(t)}function lk(e){if(!e.viewConversationId||e.conversationId!==e.viewConversationId)return[];if(!e.streamingMsg)return e.messages;let t=e.messages[e.messages.length-1];if(t?.role===`assistant`&&e.streamingMsg.role===`assistant`){let n=dr([t,e.streamingMsg]);return[...e.messages.slice(0,-1),...n]}return[...e.messages,e.streamingMsg]}function uk(e,t){let n=e[e.length-1];return n?.role!==`assistant`||n.turnId!==t?null:{messagesWithoutTail:e.slice(0,-1),tail:n}}function dk(e){e()}function fk(e,t){return!!(e&&(e.localDraft||e.configVersion!==void 0)&&t?.some(t=>t.id===e.model))}function pk(e){e.sendingRef.current=!1,e.streamingRef.current=!1}function mk(e){return e.isNewRoute?`creating-session`:e.sessionRoutePending||e.showSessionLoading||e.sessionContentLoading?`loading-history`:e.messageCount===0?`ready-empty`:`ready-conversation`}var hk=new Map;async function gk(e,t,n,r,i){let a=m.getState(),o=Tr([a.baseUrl,a.conversationId,e,t]),s=Tr({action:n,submission:r}),c=hk.get(o);if(c){if(c.signature!==s)throw Error(`An answer is already being submitted`);return(await c.promise).clone()}let l=_k(e,t,n,r,i).then(e=>{for(e.ok||hk.delete(o);hk.size>64;)hk.delete(hk.keys().next().value);return e},e=>{throw hk.delete(o),e});return hk.set(o,{signature:s,promise:l}),(await l).clone()}async function _k(e,t,n,r,i){let a=m.getState().conversationId,o=uf(e,t,`submission`,i),s={schemaVersion:2,action:n,...r,expectedVersion:t},c=Tr(s),l=await o.read();if(l&&l.signature!==c)throw Error(`The previous answer is awaiting confirmation. Retry the original answer before changing it.`);let u=l??{signature:c,body:{...s,idempotencyKey:crypto.randomUUID()}};if(await o.write(u),window.dispatchEvent(new CustomEvent(`clarification-submission-state`,{detail:{requestId:e,pending:!0}})),m.getState().conversationId!==a)throw Error(`Active Gateway changed`);let d=await f(p(`/api/clarifications/${encodeURIComponent(e)}/responses`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(u.body)});return(d.ok||d.status>=400&&d.status<500)&&(await o.write(void 0),window.dispatchEvent(new CustomEvent(`clarification-submission-state`,{detail:{requestId:e,pending:!1}})),d.ok&&await uf(e,t,`draft`,i).write(void 0)),d}async function vk(e,t,n){let r=()=>{if(!n())throw new DOMException(`Conversation changed`,`AbortError`)},i=await Or(e);if(r(),i&&(i.kind!==`append`||i.execution||i.delivery!==t.delivery||Tr(i.input)!==Tr(t.input)||!!i.interrupt!=!!t.interrupt))throw Error(`The previous input is awaiting confirmation`);let a=kr.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 f(p(`/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 jr(e,a.clientMessageId),r(),t);if(i){let e=await s();if(e!==void 0)return c(e)}let{origin:l,...u}=a;await Mr(e,u),r();let d,m;try{d=await f(p(`/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`);m=o(t.payload)}catch(t){if(r(),d&&d.status>=400&&d.status<500&&d.status!==408)throw await jr(e,a.clientMessageId),t;if(m=await s(AbortSignal.timeout(3e3)).catch(()=>void 0),r(),m===void 0)throw t}return c(m)}function yk(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:{...Vn(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 bk(e){let{conversationId:t,decodedKey:n,conversationIdRef:r,sendingRef:i,streamingRef:a,modelSupportsThinking:o,thinkingLevel:s,shouldApplyStreamUpdate:c}=e,l=m(e=>e.conversationId),u=(0,Q.useRef)({gateway:l,conversationId:t});(u.current.gateway!==l||u.current.conversationId!==t)&&(u.current={gateway:l,conversationId:t});let d=(0,Q.useCallback)(()=>{let e=u.current;return()=>u.current===e&&r.current===e.conversationId&&m.getState().conversationId===e.gateway},[r]),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(null),x=(0,Q.useRef)(null),S=(0,Q.useRef)(0),C=(0,Q.useRef)(null),[w,T]=(0,Q.useState)([]),E=(0,Q.useRef)([]),[D,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(()=>({scope:u.current,mode:{kind:`compose`}})),j=k.scope===u.current?k.mode:{kind:`compose`},M=(0,Q.useCallback)(e=>A({scope:u.current,mode:e}),[]),N=(0,Q.useRef)(j);N.current=j;let P=j.kind===`editFollowUp`?j.inputId:null,F=e=>M(e?{kind:`editFollowUp`,inputId:e,version:E.current.find(t=>t.id===e)?.version??0}:{kind:`compose`}),[I,L]=(0,Q.useState)(()=>$n(t??``)),[R,z]=(0,Q.useState)(!1),B=(0,Q.useRef)(!1),V=(0,Q.useRef)(null),H=(0,Q.useRef)(-1);x.current=h,E.current=w,V.current=P;let U=(0,Q.useCallback)(e=>{if(!e||typeof e!=`object`)return;let t=e;if(t.conversationId!==r.current||typeof t.revision!=`number`||!Array.isArray(t.inputs)||t.revision<H.current)return;if(t.control){if(!Hn(t.conversationId,t.control,t.revision))return;L(t.control)}let n=iT({control:t.control,inputs:t.inputs,activeRunId:t.activeRunId,preparation:t.preparation});H.current=t.revision,E.current=n,T(n)},[r]),W=(0,Q.useCallback)(async e=>{if(e!==r.current)return;let t=d();if(await wr(e)||!t())return;let n=await f(p(`/api/sessions/${encodeURIComponent(e)}/input-state`)).catch(()=>null);if(!n?.ok||r.current!==e)return;let i=await n.json().catch(()=>null);t()&&U(i?.payload)},[U,d,r]),G=(0,Q.useCallback)(async e=>{if(e!==r.current)return;let t=d(),n=++S.current;if(await wr(e)||!t())return;let i=await f(p(`/api/sessions/${encodeURIComponent(e)}/clarification`)).catch(()=>null);if(!i?.ok||r.current!==e)return;let a=await i.json().catch(()=>null);!t()||n!==S.current||r.current!==e||(b(null),g(yk(a?.payload,e)),C.current=null)},[d,r]);(0,Q.useLayoutEffect)(()=>{H.current=-1,B.current=!1,z(!1),O(null),S.current++,L($n(t??``)),M({kind:`compose`}),E.current=[],T([]),F(null),g(null)},[t,l]),(0,Q.useEffect)(()=>{!t||t!==n||(W(t),G(t))},[n,G,W,t,l]),(0,Q.useEffect)(()=>{let e=e=>{let t=e.detail;U(t);let n=r.current;n&&t&&typeof t==`object`&&t.conversationId===n&&G(n)},t=e=>{let t=r.current;if(!t)return;let n=e.detail;if(n&&typeof n==`object`){let e=n.conversationId;if(typeof e==`string`&&e!==t)return}b(null),S.current++,g(yk(n,t)),C.current=null},n=()=>{let e=r.current;e&&(W(e),G(e))};return window.addEventListener(`session-input-state`,e),window.addEventListener(`clarification-updated`,t),window.addEventListener(`gateway-realtime-connected`,n),()=>{window.removeEventListener(`session-input-state`,e),window.removeEventListener(`clarification-updated`,t),window.removeEventListener(`gateway-realtime-connected`,n)}},[U,G,W,r]),(0,Q.useEffect)(()=>{if(!h?.expiresAt)return;let e=Math.max(0,h.expiresAt-Date.now())+250,t=window.setTimeout(()=>{let e=r.current;e&&G(e)},e);return()=>window.clearTimeout(t)},[h?.expiresAt,G,r]);let ee=(0,Q.useCallback)(()=>{b(null),g(null)},[]),te=(0,Q.useCallback)(e=>{let t=String(e??``).trim();t&&r.current===t&&(b(null),g(null))},[r]),ne=(0,Q.useCallback)(()=>{b(null),g(null)},[]),re=(0,Q.useCallback)(()=>{F(null)},[]),ie=(0,Q.useCallback)(()=>{b(null),g(null),F(null)},[]),ae=(0,Q.useCallback)(e=>t=>{c(e)&&(i.current=!1,a.current=!1,Nn.getState().setSessionFlags(e,{sending:!1,streaming:!1}),Nn.getState().setSessionProgress(e,null),b(null),S.current++,g({...t,conversationId:e}),C.current=null)},[c,i,a]),oe=(0,Q.useCallback)(async(e,t,n,i,a,o)=>{let s=e.trim();if(!s&&!t?.length&&!n?.length)return;let c=r.current;if(!c)throw Error(`No active session`);let l=d(),u=$n(c),f=await Ar(c);if(!l())throw new DOMException(`Conversation changed`,`AbortError`);let p=await ir();if(!l())throw new DOMException(`Conversation changed`,`AbortError`);if(!f)throw Error(`Reload the conversation before sending`);let m=Nn.getState().sessions[c]?.configVersion;if(m===void 0)throw Error(`Reload the conversation before sending`);let h=await vk(c,{kind:`append`,expectedTranscriptId:f,configVersion:m,clientMessageId:crypto.randomUUID(),delivery:o??`next`,interrupt:a,controlVersion:u.version,input:{content:s||e,attachments:t?.length?t:void 0,contextRefs:n?.map(({refId:e,kind:t,sourceId:n,expectedVersion:r})=>({refId:e,kind:t,sourceId:n,expectedVersion:r})),appContext:i},origin:p},l);l()&&U(h)},[U,d,r]),se=(0,Q.useCallback)(async(e,t)=>{let n=r.current;if(!n||B.current)throw Error(`Wait for the current operation`);let i=d(),a=()=>{if(!i())throw new DOMException(`Conversation changed`,`AbortError`)};B.current=!0,z(!0);try{let r=await Ar(n);a();let i=Date.now()+15e3;for(;!r&&e===`stop`&&Date.now()<i;)await new Promise(e=>setTimeout(e,100)),r=await Ar(n),a();if(!r)throw Error(`Input acceptance is awaiting confirmation`);let o={action:e,operationId:crypto.randomUUID(),expectedTranscriptId:r,expectedVersion:$n(n).version,...t},s=await cr(n,o);if(a(),U(s),e===`steer`){let e=s.inputs?.find(e=>e.id===t?.inputId);if(e?.status===`interrupted`)throw Error(e.error??`Current reply ended before steering`)}if(e===`stop`){let e=Date.now()+15e3;for(;$n(n).phase===`stopping`;){if(a(),Date.now()>=e)throw Error(`Stop is awaiting confirmation`);await new Promise(e=>setTimeout(e,100)),await W(n)}}if(a(),e===`stop`||e===`pause`){let t=$n(n);if(!t.paused||t.version!==o.expectedVersion+1)throw Error(`Queue control changed on another device`);if(e===`stop`&&t.phase!==`idle`)throw Error(`Another input has started`)}}catch(e){throw!i()||(await W(n),!i())||ya(`error`,e instanceof Error?e.message:String(e)),e}finally{i()&&(B.current=!1,z(!1))}},[U,d,r,W]),ce=(0,Q.useCallback)(()=>se(`stop`),[se]),le=(0,Q.useCallback)(()=>se(`resume`),[se]),ue=(0,Q.useCallback)(async(e,t)=>{let n=d();try{return await se(`stop`,{turnId:e}),n()?(M({kind:`editTurn`,turnId:e,draft:t}),!0):!1}catch{return!1}},[d,se]),K=(0,Q.useCallback)(async e=>{let t=E.current.find(t=>t.id===e);if(!t)return!1;let n=d();try{return await se(`pause`,{inputId:e,inputVersion:t.version}),n()?(M({kind:`editFollowUp`,inputId:e,version:t.version}),!0):!1}catch{return!1}},[d,se]),q=(0,Q.useCallback)(()=>M({kind:`compose`}),[]),de=(0,Q.useCallback)(async(e,t,n,i,a)=>{let c=r.current;if(!c||j.kind!==`editFollowUp`||j.inputId!==e||!t.trim()&&!n?.length&&!a?.length)return!1;let l=d(),u=await f(p(`/api/sessions/${encodeURIComponent(c)}/inputs/${encodeURIComponent(e)}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({version:j.version,content:t,attachments:n??[],thinking:o?i??s:`off`,contextRefs:(a??[]).map(({refId:e,kind:t,sourceId:n,expectedVersion:r})=>({refId:e,kind:t,sourceId:n,expectedVersion:r}))})}),m=await u.json();if(!l())return!1;if(U(m.payload),!u.ok)throw Error(m.error?.message??`This input changed; your draft has been preserved`);if(N.current===j){let t=m.payload?.inputs?.find(t=>t.id===e);t&&M({...j,version:t.version})}return!0},[U,d,j,r,o,s]),fe=(0,Q.useCallback)(e=>{V.current===e&&F(null);let t=r.current,n=E.current.find(t=>t.id===e);if(!t||!n)return;let i=d();f(p(`/api/sessions/${encodeURIComponent(t)}/inputs/${encodeURIComponent(e)}?version=${n.version}`),{method:`DELETE`}).then(async e=>{let t=await e.json().catch(()=>null);i()&&U(t?.payload)}).catch(()=>{W(t)})},[U,d,W,r]),pe=(0,Q.useCallback)((e,t)=>{let n=E.current.filter(e=>e.status===`queued`),i=n.findIndex(t=>t.id===e);if(i<0)return;let a=t===`up`?i-1:i+1,o=r.current,s=n[i];if(!o||!s||a<0||a>=n.length)return;let c=d();f(p(`/api/sessions/${encodeURIComponent(o)}/inputs/${encodeURIComponent(s.id)}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({version:s.version,position:a})}).then(async e=>{let t=await e.json().catch(()=>null);c()&&U(t?.payload)}).catch(()=>{W(o)})},[U,d,W,r]),J=(0,Q.useCallback)((e,t)=>{let n=r.current,i=E.current[e],a=E.current[t],o=E.current.filter(e=>e.status===`queued`),s=a?o.findIndex(e=>e.id===a.id):-1;if(!n||i?.status!==`queued`||a?.status!==`queued`||s<0)return;let c=d();f(p(`/api/sessions/${encodeURIComponent(n)}/inputs/${encodeURIComponent(i.id)}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({version:i.version,position:s})}).then(async e=>{let t=await e.json().catch(()=>null);c()&&U(t?.payload)}).catch(()=>{W(n)})},[U,d,W,r]),me=(0,Q.useCallback)(async(e,t)=>{let n=E.current.find(t=>t.id===e);if(!n)return;let r=d();O(e);try{await se(t,{inputId:e,inputVersion:n.version})}finally{r()&&O(null)}},[d,se]),he=(0,Q.useCallback)(e=>me(e,`steer`),[me]),ge=(0,Q.useCallback)(e=>me(e,`send`),[me]),_e=(0,Q.useCallback)(async(e,t)=>{let n=x.current;if(!n)return;let i=JSON.stringify([n.requestId,n.version,e,t]);C.current?.signature!==i&&(C.current={signature:i,idempotencyKey:crypto.randomUUID()});let a=C.current.idempotencyKey;v(!0),b(null);try{let i=n.schemaVersion===2?await gk(n.requestId,n.version,e,t,r.current??void 0):await f(p(`/api/clarifications/${encodeURIComponent(n.requestId)}/responses`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:e,...t,expectedVersion:n.version,idempotencyKey:a})});if(x.current?.requestId!==n.requestId)return;if(!i.ok){let e=await i.json().catch(()=>({}));b(e.error?.message??i.statusText??`Clarify failed`);let t=r.current;t&&(i.status===409||i.status===410)&&G(t);return}C.current=null,g(null),b(null)}catch(e){x.current?.requestId===n.requestId&&b(e instanceof Error?e.message:String(e))}finally{v(!1)}},[G,r]);return{clarifyPrompt:h,clarifySubmitting:_,clarifySubmitError:y,clarifyPromptRef:x,pendingFollowUps:w,pendingFollowUpsRef:E,steeringFollowUpId:D,composerMode:j,control:I,controlPending:R,stopSession:ce,resumeQueue:le,sendQueuedInput:ge,beginEditTurn:ue,cancelEditor:q,restoreEditor:M,editingFollowUpId:P,addPendingFollowUp:oe,beginEditFollowUp:K,cancelEditFollowUp:q,commitEditFollowUp:de,removePendingFollowUp:fe,movePendingFollowUp:pe,reorderPendingFollowUp:J,steerPendingFollowUp:he,submitClarifyAnswer:(0,Q.useCallback)(e=>_e(`answer`,e),[_e]),letAgentDecideClarification:(0,Q.useCallback)(()=>_e(`agent_decide`),[_e]),cancelClarification:(0,Q.useCallback)(()=>_e(`cancel`),[_e]),clearVisibleClarify:ee,dismissClarify:ne,dismissClarifyForSession:te,clearPendingFollowUps:re,dismissClarifyAndClearPending:ie,makeOnClarifyRequest:ae}}async function xk(e){let t=await wr(e);if(t)return{agentId:t.creation.agentId.trim().toLowerCase(),projectId:t.creation.projectId?.trim()||null};let n=await un(e);return{agentId:(n.routing?.agentId??n.agentId).trim().toLowerCase(),projectId:n.projectId?.trim()||null}}function Sk(e){let t=(0,X.c)(59),{navigate:n,conversationIdRef:r,conversationId:i,isNewRoute:a,locationState:o,locationSearch:s,personal:c}=e,l=c!==void 0&&c,u=m(Ek),d;t[0]===i?d=t[1]:(d=i?.trim()??``,t[0]=i,t[1]=d);let f=d,p;t[2]===u?p=t[3]:(p=u?[`gateway-chat-agents`,u]:null,t[2]=u,t[3]=p);let h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h={revalidateOnFocus:!1},t[4]=h):h=t[4];let{data:g,mutate:_}=Gr(p,ni,h),v;t[5]!==f||t[6]!==u?(v=u&&f?[`gateway-chat-session-agent`,u,f]:null,t[5]=f,t[6]=u,t[7]=v):v=t[7];let y;t[8]===f?y=t[9]:(y=()=>xk(f),t[8]=f,t[9]=y);let b;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(b={revalidateOnFocus:!1},t[10]=b):b=t[10];let{data:x}=Gr(v,y,b),S=x?.agentId??``,C,w;t[11]===_?(C=t[12],w=t[13]):(C=()=>{let e=e=>{ti(e.detail)||_()};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},w=[_],t[11]=_,t[12]=C,t[13]=w),(0,Q.useEffect)(C,w);let[T,E]=(0,Q.useState)(Tk),D=(0,Q.useRef)(g??null),O;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(O=Hr().selectedAgentId??null,t[14]=O):O=t[14];let k=(0,Q.useRef)(O),A,j;t[15]===g?(A=t[16],j=t[17]):(A=()=>{D.current=g??null},j=[g],t[15]=g,t[16]=A,t[17]=j),(0,Q.useEffect)(A,j);let M,N;t[18]===T?(M=t[19],N=t[20]):(M=()=>{k.current=T},N=[T],t[18]=T,t[19]=M,t[20]=N),(0,Q.useEffect)(M,N);let P,F;t[21]===g?(P=t[22],F=t[23]):(P=()=>{if(!g)return;let e=new Set(g.items.map(wk));E(t=>t==null||t===``||!e.has(t)?g.defaultId:t)},F=[g],t[21]=g,t[22]=P,t[23]=F),(0,Q.useEffect)(P,F);let I;t[24]!==r||t[25]!==S?(I=()=>{if(r.current&&S)return S;let e=D.current,t=(k.current??``).trim().toLowerCase();if(!e)return t||void 0;let n=new Set(e.items.map(Ck));return t&&n.has(t)?t:e.defaultId},t[24]=r,t[25]=S,t[26]=I):I=t[26];let L=I,R;t[27]!==r||t[28]!==S||t[29]!==x?.projectId||t[30]!==a||t[31]!==s||t[32]!==o||t[33]!==n?(R=e=>{let t=e.trim().toLowerCase(),i=r.current?S||k.current:null;k.current=t,E(t),Pr(t),i!==t&&n(a?`/chat/new${s}`:Xr(x?.projectId),{replace:!1,state:{...a&&o&&typeof o==`object`?o:{},agentId:t,forceNewChat:!0}})},t[27]=r,t[28]=S,t[29]=x?.projectId,t[30]=a,t[31]=s,t[32]=o,t[33]=n,t[34]=R):R=t[34],x?.projectId;let z=R,B,V;t[35]===z?(B=t[36],V=t[37]):(B=()=>{let e=e=>{let t=e.detail?.agentId;typeof t!=`string`||!t.trim()||z(t)};return window.addEventListener(`xopc-set-chat-agent`,e),()=>window.removeEventListener(`xopc-set-chat-agent`,e)},V=[z],t[35]=z,t[36]=B,t[37]=V),(0,Q.useEffect)(B,V);let H,U;t[38]!==i||t[39]!==S||t[40]!==l?(H=()=>{if(!i||l)return;let e=S;!e||k.current===e||(k.current=e,E(e),Pr(e))},U=[S,i,l],t[38]=i,t[39]=S,t[40]=l,t[41]=H,t[42]=U):(H=t[41],U=t[42]),(0,Q.useLayoutEffect)(H,U);let W,G;t[43]!==i||t[44]!==x?(W=()=>{!i||!x||Br(x.projectId)},G=[x,i],t[43]=i,t[44]=x,t[45]=W,t[46]=G):(W=t[45],G=t[46]),(0,Q.useLayoutEffect)(W,G);let ee,te;t[47]!==a||t[48]!==o?(ee=()=>{if(!a)return;let e=o,t=typeof e?.agentId==`string`?e.agentId.trim().toLowerCase():``;t&&(k.current=t,E(t),Pr(t))},te=[a,o],t[47]=a,t[48]=o,t[49]=ee,t[50]=te):(ee=t[49],te=t[50]),(0,Q.useLayoutEffect)(ee,te);let ne=S||T||g?.defaultId||`main`,re=(g?.items.length??0)>1,ie=x?.projectId??null,ae;return t[51]!==g||t[52]!==ne||t[53]!==z||t[54]!==L||t[55]!==re||t[56]!==ie||t[57]!==u?(ae={token:u,chatAgentsData:g,resolveAgentIdForPost:L,onChatAgentChange:z,displayAgentId:ne,showChatAgentSelector:re,currentSessionProjectId:ie},t[51]=g,t[52]=ne,t[53]=z,t[54]=L,t[55]=re,t[56]=ie,t[57]=u,t[58]=ae):ae=t[58],ae}function Ck(e){return e.id}function wk(e){return e.id}function Tk(){return Hr().selectedAgentId??null}function Ek(e){return e.conversationId}async function Dk(e){let t=await e.sessionMgr.createSession(e);return{kind:`create`,conversationId:t.key,session:t}}var Ok=new Map,kk=0;function Ak(e){let t=m.getState(),n=Fr(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=Ok.get(r);if(i)return i.target.opts=e,i.target.generation=++kk,i.promise;let a={opts:e,generation:++kk},o=e=>{if(a.generation!==kk)return;let t=a.opts;!t.routeConversationId&&mi.getState().scope===`new`&&mi.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 Dk({sessionMgr:e.sessionMgr,agentId:t?.trim()||`main`,projectId:e.projectId,currentConversationId:e.currentConversationId,forceNew:e.forceNew,temporary:e.temporary,initialAgentConfig:e.initialAgentConfig,executionMode:e.executionMode});return o(n),n})().finally(()=>{Ok.delete(r)});return Ok.set(r,{promise:s,target:a}),s}var jk={current:null},Mk={current:null};function Nk(e){return!!(e&&typeof e==`object`&&e.forceNewChat===!0)}function Pk(e){let t=c(),{conversationId:n}=s(),r=!e&&t.pathname.endsWith(`/new`),i=r&&Nk(t.state),a=e??ck(r,n),o=sk(r,a),l=rk(o),u=r?null:a??null,d=(0,Q.useRef)(o);return d.current=o,jk.current=u,!r&&a&&(Mk.current=a),(0,Q.useLayoutEffect)(()=>{Nn.getState().focusedConversationId!==u&&Nn.getState().setFocusedConversationId(u)},[u]),{isNewRoute:r,forceNewChat:i,decodedKey:a,routedConversationId:o,viewConversationId:l,routedFocusedConversationId:u,routeConversationIdRef:d,locationKey:t.key,locationSearch:t.search,locationState:t.state}}var Fk={get current(){return Mk.current}},Ik={get current(){return jk.current},set current(e){jk.current=e,Nn.getState().setFocusedConversationId(e)}};function Lk(e){let{token:t,isNewRoute:n,forceNewChat:r,temporary:i=!1,requestedAgentId:a,decodedKey:o,locationKey:s,locationSearch:c,sessionMgrRef:l,resolveAgentIdForPost:u,navigateToSession:d,loadSessionById:f,tryResumeAgentRun:p,restoreLiveCacheIfNeeded:h,adoptEmptySession:g,applyAgentConfig:_,patchInitUi:v}=e,y=(0,Q.useRef)(0),b=m(e=>e.baseUrl),[x,S]=(0,Q.useState)(null),C=n?c:``,w=n?`new:${s}`:o?`session:${o}`:`fallback:${s}`,T=(0,Q.useRef)({isNewRoute:n,forceNewChat:r,temporary:i,requestedAgentId:a,decodedKey:o,newRouteLocationSearch:C});T.current={isNewRoute:n,forceNewChat:r,temporary:i,requestedAgentId:a,decodedKey:o,newRouteLocationSearch:C};let E=(0,Q.useRef)({sessionMgrRef:l,resolveAgentIdForPost:u,navigateToSession:d,loadSessionById:f,tryResumeAgentRun:p,restoreLiveCacheIfNeeded:h,adoptEmptySession:g,applyAgentConfig:_,patchInitUi:v});return E.current={sessionMgrRef:l,resolveAgentIdForPost:u,navigateToSession:d,loadSessionById:f,tryResumeAgentRun:p,restoreLiveCacheIfNeeded:h,adoptEmptySession:g,applyAgentConfig:_,patchInitUi:v},(0,Q.useEffect)(()=>{let e=T.current,n=E.current;if(!t){n.patchInitUi({loading:!1});return}let r=++y.current,i=!1,a=()=>!i&&r===y.current,o=e=>{a()&&n.sessionMgrRef.current.loadSessionAgentConfig(e).then(t=>{a()&&n.applyAgentConfig(e,t)}).catch(()=>{})},s=async()=>{if(!a())return Promise.resolve();let r=Hr(),i=n.resolveAgentIdForPost(),s=Lr({origin:`web-route`,project:Qr(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 sn(s.projectId):null;if(!a())return;!e.requestedAgentId&&c?.defaultAgentId&&(s.agentId=c.defaultAgentId);let l=Vr(r,s.agentId),u=(t,r,i)=>Ak({sessionMgr:n.sessionMgrRef.current,agentId:s.agentId,currentConversationId:Fk.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:Kr(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=Un(e)?.messages??t??yr(e);return n.tryResumeAgentRun(e,r)},l=e=>a()?Un(e)?.historyStatus===`ready`?(o(e),c(e,yr(e))):n.loadSessionById(e,0).then(t=>{if(a())return c(e,t??yr(e))}):Promise.resolve(),u=()=>a()?n.sessionMgrRef.current.loadSessions().then(e=>{if(!a())return;let t=e.filter(e=>(e.messageCount??0)>0)[0]??e[0];if(t)return a()?n.loadSessionById(t.key,0).then(e=>{if(!a())return;n.restoreLiveCacheIfNeeded(t.key);let r=Un(t.key)?.messages??e??yr(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 Ak({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 Rk(e){let t=m(e=>e.conversationId),n=m(e=>e.baseUrl),[r,i]=(0,Q.useState)(null),{data:a,error:o}=Gr(e?[`prepared-session-model`,n,t,e.create]:null,async()=>{let t=Vr(Hr(),e.agentId),[n,r]=await Promise.all([ui(),t?.modelRef??fi(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?Ur(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&&Rr(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=Vr(Hr(),e.agentId)?.thinkingByModel?.[t],c=r.thinking?Ur(r.thinking,n??s?.thinkingLevel,n===void 0?o:void 0):n??s?.thinkingLevel??`medium`;i({preparation:e,selection:{model:t,thinkingLevel:c}})};return{preparation:f,model:s?.model??``,thinkingLevel:s?.thinkingLevel??`medium`,modelSupportsThinking:!!c?.reasoning,ready:l,error:o,onModelChange:e=>p(e),onThinkingChange:e=>p(s?.model??``,e)}}async function zk(e){let t=e.trim();if(!t)return!1;try{return!!(await ui()).find(e=>e.id===t)?.reasoning}catch{return!1}}function Bk(e){let{sessionMgrRef:t,routeConversationIdRef:n,sendingRef:r,streamingRef:i,loadingSessionRef:a,messagesLenRef:o,thinkingSupportGenRef:s,navigateToSession:c,resolveAgentIdForPost:l,detachForNewConversation:u,conversationId:d,sessionAgentId:f,currentProjectId:p,taskId:m,hasMore:h}=e,g=()=>Nn.getState(),_=(0,Q.useRef)(Promise.resolve(void 0)),v=(0,Q.useRef)(null),y=(0,Q.useRef)(0),b=(0,Q.useCallback)(e=>{let t=g().focusedConversationId;if(!e.trim())return++s.current===s.current&&t&&g().patchSessionMeta(t,{modelSupportsThinking:!1}),Promise.resolve();let n=++s.current;return zk(e).then(t=>{if(n!==s.current)return;let r=g().focusedConversationId;r&&g().sessions[r]?.model===e&&g().patchSessionMeta(r,{modelSupportsThinking:t})})},[s]),x=(0,Q.useCallback)(async e=>{try{let n=await t.current.loadSessionAgentConfig(e);Kn(e,n),b(n.model)}catch{}},[t,b]),S=(0,Q.useCallback)(()=>{let e=g().focusedConversationId;if(!e||(g().sessions[e]?.name)?.trim())return;let n=++y.current,r=[700,900,900,1e3,1e3],i=a=>{a>=5||n===y.current&&g().focusedConversationId===e&&(g().sessions[e]?.name?.trim()||window.setTimeout(()=>{n===y.current&&g().focusedConversationId===e&&(g().sessions[e]?.name?.trim()||t.current.fetchSessionName(e).then(t=>{if(n===y.current){if(t){g().patchSessionMeta(e,{name:t});return}i(a+1)}}).catch(()=>{i(a+1)}))},r[a]??900))};i(0)},[t]),C=(0,Q.useCallback)(e=>ok({chatId:e,routeConversationId:n.current}),[n]),w=(0,Q.useCallback)((e,t,n)=>{let r=g().sessions[e];if(n&&r?.messages!==n.messages&&!hn(r))return!1;let i=t.hasMore&&xr(r?.messages??[],t.messages)>0;return g().mergeCommittedFromServer(e,t.messages,t.hasMore),t.name!==void 0&&g().patchSessionMeta(e,{name:t.name||null}),C(e)&&(i||(v.current=t.nextBeforeCursor??null)),!0},[C]),T=(0,Q.useCallback)(async(e,r=0,i)=>{let o=async(e,r,i)=>{let s=r===0&&!i;a.current=!0;let u=s&&vr(g().sessions[e]?.historyStatus);u&&g().setSessionHistoryStatus(e,`loading`);try{let n={messages:g().sessions[e]?.messages},{messages:a,hasMore:o,name:c,nextBeforeCursor:l}=await t.current.loadSession(e,r,i,m,n.messages);if(s){if(!w(e,{messages:a,hasMore:o,name:c,nextBeforeCursor:l},n))return g().sessions[e]?.messages;if(!C(e))return a;let r=await t.current.loadSessionAgentConfig(e);return C(e)?(Kn(e,r),b(r.model),a):a}if(v.current=l??null,!C(e))return;g().prependHistoryMessages(e,a,o);return}catch(a){if(r===0&&!i){v.current=null;let r=a instanceof Error?a.message:`Failed to load session`;g().setShellError(/^HTTP 404\b/.test(r)?JSON.stringify(Yn(r)):`Failed to load session`);let i=rk(n.current);if(i&&i===e)return;let s=await t.current.loadSessions().catch(()=>[]),u=s.filter(e=>(e.messageCount??0)>0)[0]??s[0];if(u)return c(u.key,!0),await o(u.key,0,null);{v.current=null;let e=l();Ak({sessionMgr:t.current,agentId:e,currentConversationId:null,routeConversationId:null,navigateToSession:c,replaceNavigate:!0,onOpened:e=>{g().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:null}),x(e)}})}}return}finally{a.current=!1,u&&g().sessions[e]?.historyStatus===`loading`&&g().setSessionHistoryStatus(e,`ready`)}},s=_.current,u,d=new Promise(e=>{u=e});_.current=s.then(()=>d),await s;try{return await o(e,r,i)}finally{u()}},[n,C,r,i,a,c,b,l,t,m,w]),E=(0,Q.useCallback)(async()=>{let e=g().focusedConversationId;if(!(!e||g().loadingMore||!h)){g().setLoadingMore(!0);try{await T(e,o.current,v.current)}finally{g().setLoadingMore(!1)}}},[h,T,o]),D=(0,Q.useCallback)(async(e,n)=>{if(!d)throw Error(`No active session`);let r=g().sessions[d];if(r?.modelConfigSaving)throw Error(`Model configuration is being saved`);if(!(r?.model===e&&n!==void 0&&r.thinkingLevel===n)){g().patchSessionMeta(d,{modelConfigSaving:!0});try{if(g().setShellError(null),n===void 0){let t=(await ui()).find(t=>t.id===e);if(t?.thinking){let i=Vr(Hr(),f)?.thinkingByModel?.[e];n=Ur(t.thinking,r?.thinkingLevel,i)}}let i=m?await t.current.patchTaskConversationModel(m,e,n,r?.configVersion):await t.current.patchSessionAgentConfig(d,{model:e,thinkingLevel:n,configVersion:r?.configVersion});Kn(d,i),Rr(f,{modelRef:i.model,thinkingLevel:i.thinkingLevel}),i.model!==r?.model&&b(i.model)}catch(e){let n=e instanceof Error?e.message:`Failed to update model configuration`;g().setShellError(n);let r=await t.current.loadSessionAgentConfig(d).catch(()=>null);throw r&&Kn(d,r),e}finally{g().patchSessionMeta(d,{modelConfigSaving:!1})}}},[d,f,m,t,b]);return{refreshModelThinkingSupport:b,pollSessionNameAfterTurn:S,applyLoadedSessionSnapshot:w,loadSessionById:T,loadMoreMessages:E,onSessionModelChange:D,onSessionThinkingLevelChange:(0,Q.useCallback)(async e=>{let t=d?g().sessions[d]?.model:void 0;t&&await D(t,e)},[d,D]),onSessionWorkingDirectoryChange:(0,Q.useCallback)(async e=>{let n=e.trim();if(!(!d||!n))try{g().setShellError(null),await t.current.patchSessionAgentConfig(d,{workingDirectory:n}),await x(d)}catch(e){throw g().setShellError(e instanceof Error?e.message:`Failed to update working directory`),e}},[x,d,t]),createNewSession:(0,Q.useCallback)(async e=>{g().setShellError(null);let n=l(),r=Vr(Hr(),n??`main`);await Ak({sessionMgr:t.current,agentId:n,currentConversationId:d,routeConversationId:d,forceNew:e?.forceNew,temporary:e?.temporary,executionMode:e?.executionMode,projectId:e?.projectId===void 0?p:e.projectId,initialAgentConfig:r?{model:r.modelRef,...r.thinkingLevel?{thinkingLevel:r.thinkingLevel}:{}}:void 0,navigateToSession:c,onOpened:e=>{u(),v.current=null,g().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:null}),x(e)}})},[u,c,l,p,d,t,x]),resetCurrentSession:(0,Q.useCallback)(async()=>{if(d){g().setShellError(null);try{await t.current.resetSession(d),u(),v.current=null,g().setCommittedSnapshot(d,{messages:[],hasMore:!1,name:null}),x(d)}catch(e){g().setShellError(e instanceof Error?e.message:`Failed to reset session`)}}},[x,d,u,t])}}function Vk(e){return new Promise(t=>{Promise.resolve().then(()=>e(()=>t(!0))).then(()=>t(!1),()=>t(!1))})}function Hk(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 Uk(e){return e!==`suspended`}function Wk(e){let{chatId:t,shouldApplyStreamUpdate:n,beforeAssistantDelta:r,reconcileHydratedAssistantText:i,setStreamingOnStreamStart:a,clearResumeRunIdOnBackgroundTerminal:o,clearResumeRunIdOnVisibleError:s,setError:c,sessionMgrRef:l,applyLoadedSessionSnapshot:u,finalizeMessage:d,fq:f}=e,p=e.isCurrentRun??(()=>!0),m=()=>Nn.getState(),g=()=>{let e={messages:m().sessions[t]?.messages};return l.current.loadSession(t,0,void 0,void 0,e.messages).then(n=>{p()&&u(t,n,e)}).catch(()=>{})},_=new Map,v,b=()=>{if(v!==void 0&&(window.clearTimeout(v),v=void 0),!p()){_.clear();return}if(_.size===0)return;let e=Array.from(_.entries());_.clear(),r(),m().mutateSessionStreaming(t,t=>{for(let[n,r]of e)_n(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&&bn.setResumeRunId(t,null),m().setSessionFlags(t,{sending:!1,streaming:!1}),m().setSessionProgress(t,null),Uk(e)&&f.dismissClarifyForSession(t),g()},C={onTextSurface:e=>{r(),m().mutateSessionStreaming(t,t=>{t.textSurface=e})},onReplayGap:g,onUserMessage:e=>{n(t)&&m().appendUserMessageIfMissing(t,e)},onStreamStart:(e,n,i)=>{Lf(t),r(),i&&m().updateSessionMessages(t,t=>rr([...t,{role:`task`,content:[],taskTrigger:i,turnId:e,timestamp:Date.now()}])),m().updateSessionMessages(t,t=>Cn(t,e)),m().mutateSessionStreaming(t,t=>{t.turnId=e,n&&(t.startsNewBubble=!0)}),m().setSessionFlags(t,{streaming:!0})},onToken:(e,a,o)=>{r(),m().mutateSessionStreaming(t,t=>{Dn(t.content,e,a,{offset:o,reconcileHydratedSegment:i})}),n(t)&&m().setSessionFlags(t,{streaming:!0})},onAssistantMessageEnd:(e,n,i)=>{r(),m().mutateSessionStreaming(t,t=>{Cr(t.content,e,n),i&&(t.usage=i)})},onThinking:(e,n,i)=>{r(),m().mutateSessionStreaming(t,t=>{!n&&e===``?xn(t.content):tr(t.content,e,n,i)})},onThinkingEnd:e=>{r(),m().mutateSessionStreaming(t,t=>{wn(t.content,e)})},onToolStart:(e,n,i,a,o,s)=>{r(),m().mutateSessionStreaming(t,t=>{pn(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=>{Tn(t.content,e,n,i,a,o,s,c)})},onToolUpdate:(e,n,i)=>{r(),m().mutateSessionStreaming(t,t=>{Pn(t.content,e,n,i)})},onTaskPlanUpdated:e=>{m().setSessionTaskPlan(t,e)},onTurnOutcome:e=>{r(),m().mutateSessionStreaming(t,t=>{t.outcome=e})},onReview:({review:e})=>{r(),m().mutateSessionStreaming(t,t=>{vn(t.content,e)}),n(t)&&m().setSessionFlags(t,{streaming:!0})},onReviewStart:e=>{r(),m().mutateSessionStreaming(t,t=>{Fn(t.content,e)}),n(t)&&m().setSessionFlags(t,{streaming:!0})},onReviewDelta:({reviewId:e,delta:t})=>{x(e,t)},onReviewEnd:({reviewId:e,status:n,message:i})=>{b(),r(),m().mutateSessionStreaming(t,t=>{An(t.content,e,n,i)})},onProgress:e=>{m().setSessionProgress(t,e)},onTtsAudio:e=>{n(t)&&m().appendAttachmentToCurrentAssistant(t,{name:e.name,mimeType:e.mimeType,type:`voice`,uri:e.uri,size:0},{attachTo:e.attachTo,messageId:e.messageId})},onCompaction:e=>{if(!n(t))return;let r=y(h.getState().language).chat;if(e.status===`started`)m().setSessionProgress(t,{stage:`compaction`,message:r.compactingContext,timestamp:Date.now()});else if(e.status===`completed`){let n=e.tokensBefore&&e.tokensAfter?` (${r.contextTokensFreed.replace(`{{count}}`,String(Math.round((e.tokensBefore-e.tokensAfter)/1e3)))})`:``;m().setSessionProgress(t,{stage:`compaction`,message:`${r.contextCompacted}${n}`,timestamp:Date.now()})}else m().setSessionProgress(t,null)},onClarifyRequest:f.makeOnClarifyRequest(t),onSessionConfigUpdated:()=>{m().patchSessionMeta(t,{modelConfigSaving:!0}),l.current.loadSessionAgentConfig(t).then(e=>Kn(t,e)).catch(()=>{}).finally(()=>m().patchSessionMeta(t,{modelConfigSaving:!1}))},onResult:({status:e})=>{b();let r=n(t);if(bn.takeUserAborted(t)||e===`cancelled`){Bf(t),r?d(t,e):S(e);return}if(e===`error`){if(zf(t,!r),!r){S(e);return}d(t,e),g();return}if(e===`suspended`?Vf(t):Rf(t,!r),!r){S(e);return}d(t,e)},onError:e=>{b();let r=n(t);if(zf(t,!r),!r){S(`error`);return}m().clearStreamingState(t),s&&bn.setResumeRunId(t,null),m().setSessionFlags(t,{sending:!1,streaming:!1}),m().setSessionProgress(t,null),c(e),f.dismissClarifyForSession(t)}};return Object.fromEntries(Object.entries(C).map(([e,t])=>[e,(...e)=>{if(p())return Reflect.apply(t,void 0,e)}]))}function Gk(e){return Un(e)?.streamingMsg??null}var Kk=80;function qk(e){let t=e.trim();(t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`))&&(t=t.slice(1,-1).trim());let n=t.indexOf(`
71
+ `);return n!==-1&&(t=t.slice(0,n).trim()),t.length>Kk&&(t=t.slice(0,Kk-1).trimEnd()+`…`),t}function Jk(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 Yk(e){let t=e.trimStart().match(/^\/skill:([^\s]+)(?:\s+([\s\S]*))?$/i);return t&&(t[2]?.trim()||t[1]?.trim())||e}function Xk(e){let t=Yk(Jk(Rn([{type:`text`,text:e}]))).split(/\n/)[0]?.trim();if(!t)return null;let n=qk(t);return n.length>0?n:null}function Zk(e,t){let n=e.trim(),r=t.trim();!n||!r||window.dispatchEvent(new CustomEvent(`session-updated`,{detail:{key:n,name:r},bubbles:!0}))}var Qk=new Set([`new`,`reset`,`restart`]),$k=new Set([...Qk,`clear`,`archive`]);function eA(e){let t=e.trim(),n=/^\/([^\s@]+)(?:@[^\s]+)?(?:\s+([\s\S]*))?$/.exec(t);return n?{name:n[1].toLowerCase(),args:n[2]?.trim()??``}:null}function tA(e){let t=eA(e);return!!(t&&Qk.has(t.name)&&!t.args)}function nA(e){let t=eA(e);return!!(t&&$k.has(t.name))}function rA(e){let{conversationId:t,taskId:n,thinkingLevel:r,modelSupportsThinking:i,conversationIdRef:a,sendingRef:o,streamingRef:s,sessionMgrRef:c,sendMessageRef:l,shouldApplyStreamUpdate:u,fq:d,applyLoadedSessionSnapshot:f,loadSessionById:p,resetCurrentSession:h,pollSessionNameAfterTurn:g}=e,_=()=>Nn.getState(),v=e=>_().setShellError(e),y=()=>_().setShellError(null),b=(0,Q.useCallback)((e,t)=>{let n=e??a.current;if(n&&!u(n))return;let r=n?Gk(n):null,i=null;if(r){let e=En(r,Date.now());e.runStatus=t,On(e.content,t===`success`),wn(e.content),t!==`suspended`&&Sn(e.content,t===`success`),yn(e.content),e.completedAt=t&&t!==`suspended`?Date.now():void 0,i=er(e)}i&&mn(i)&&n?_().finalizeStreamingTurn(n,i):n&&_().clearStreamingState(n),o.current=!1,s.current=!1,n&&bn.resetRunTracking(n),(!t||Uk(t))&&d.dismissClarify(),g();let c=a.current;c&&window.setTimeout(()=>{a.current===c&&(o.current||s.current||p(c,0))},400)},[o,s,a,d.dismissClarify,d.pendingFollowUpsRef,g,p,u]),x=(0,Q.useCallback)(async(e,t)=>{if(!u(e))return;let r=m.getState().conversationId,i=()=>m.getState().conversationId===r,a=bn.getGeneration(e),l=_().sessions[e]?.streamingMsg,h=_().sessions[e]?.messages.findLast(e=>e.role===`user`)?.clientSubmissionId,g=await ur(e);if(!i()||bn.getGeneration(e)!==a)return;if(!g){let t=_().sessions[e]?.streamingMsg;if(t?.pendingResponseStatus||t&&t!==l||bn.isStreamingFor(e))return;let n=bn.getResumeRunId(e);n&&bn.reconcileInactive(e,n),_().clearStreamingState(e,{preservePendingResponse:!0}),Bf(e);return}let y=()=>{let t=_().sessions[e]?.streamingMsg,n=_().sessions[e]?.messages.findLast(e=>e.role===`user`)?.clientSubmissionId;return!i()||bn.getGeneration(e)!==a||!!(n&&n!==h)||!!(Gn(e)&&Gn(e)!==g)||!!(t?.turnId&&t.turnId!==g&&t.turnId!==l?.turnId)||!!(t?.pendingResponseStatus&&t!==l)};if(y()||bn.isTrackingRun(e,g))return;let x=()=>{let t=_().sessions[e]?.streamingMsg;!t?.turnId||t.turnId===g||t.turnId!==l?.turnId||(mn(t)?_().finalizeStreamingTurn(e,er(t)):_().clearStreamingState(e))},S=t??yr(e),C=Un(e)?.hasMore??!1;try{let t=await c.current.loadSession(e,0,void 0,n,_().sessions[e]?.messages);if(y()||bn.isTrackingRun(e,g))return;x(),_().mergeCommittedFromServer(e,t.messages,t.hasMore),S=t.messages,C=t.hasMore}catch{}if(y()||bn.isTrackingRun(e,g))return;x(),a=bn.advanceGeneration(e),bn.setUserAborted(e,!1),bn.setResumeRunId(e,g),o.current=!0,s.current=!0,_().seedSessionIfEmpty(e,S,!0,!0,C),_().setSessionFlags(e,{sending:!0,streaming:!0}),_().setSessionProgress(e,null),Lf(e);let w=!1,T=()=>{if(w||!u(e))return;w=!0;let t=uk(yr(e),g);t&&_().applyHydratedTail(e,t.messagesWithoutTail,er(t.tail))},E=()=>{_().clearStreamingState(e),bn.getResumeRunId(e)===g&&bn.setResumeRunId(e,null),u(e)&&(o.current=!1,s.current=!1)};try{let t=Wk({chatId:e,shouldApplyStreamUpdate:u,isCurrentRun:()=>i()&&bn.getGeneration(e)===a,beforeAssistantDelta:T,reconcileHydratedAssistantText:!0,setStreamingOnStreamStart:!1,clearResumeRunIdOnBackgroundTerminal:!0,clearResumeRunIdOnVisibleError:!0,setError:v,sessionMgrRef:c,applyLoadedSessionSnapshot:f,finalizeMessage:b,fq:d}),n=await bn.senderFor(e).resume(g,e,t,{replayFromStart:l?.turnId!==g||!mn(l)});if(!i()||bn.getGeneration(e)!==a)return;n||(Bf(e),E(),await p(e,0).catch(()=>void 0))}catch(t){if(!i()||bn.getGeneration(e)!==a)return;t.name!==`AbortError`&&console.error(`[chat] resume failed:`,t),Bf(e),E()}finally{bn.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&&!bn.isStreamingFor(c))return!1;let l=e.trim();if(n&&nA(l))return v(`A task has one continuous conversation.`),!1;if(tA(l)&&!t?.length){await h();return}return await d.addPendingFollowUp(e,t,i,void 0,!0),!0},[o,s,a,d.addPendingFollowUp,h,n]),C=(0,Q.useCallback)(async(e,a,l,g,x,S,C,w)=>{if(!t||!u(t)||!e.trim()&&!a?.length&&!g?.length||o.current||s.current||bn.isStreamingFor(t))return!1;let T=e.trim();if(n&&nA(T))return v(`A task has one continuous conversation.`),!1;if(tA(T)&&!a?.length){await h();return}let E=i?l??r:`off`,D=t,O=bn.advanceGeneration(D),k=m.getState().conversationId,A=()=>m.getState().conversationId===k&&bn.getGeneration(D)===O,j=crypto.randomUUID(),M=`assistant-stream:${D}:${j}`,N=yr(D),P=w?N.filter(e=>e.clientSubmissionId!==w):N,F=x?P.findIndex(e=>e.role===`user`&&e.turnId===x):-1;if(x&&F<0)return!1;bn.setUserAborted(D,!1),o.current=!0,s.current=!1,y(),d.dismissClarify();let I=F>=0?P.slice(0,F):P,L=Wn(e)??void 0,R=new Map(g?.flatMap(e=>e.refId?[[e.refId,e.title]]:[])??[]),z=L?br(L,e=>R.get(e)):e,B=[...I,{role:`user`,content:z?[{type:`text`,text:z}]:[],userTurnDocument:L,deliveryStatus:`sending`,clientSubmissionId:j,pendingAppContext:S===void 0?void 0:structuredClone(S),attachments:a,contextRefs:g?.map(e=>({refId:e.refId,kind:e.kind,sourceId:e.sourceId,version:e.expectedVersion,title:e.title,fileKind:e.fileKind})),timestamp:Date.now()}];C?.(j);let V=Un(D);if(_().initSessionSnapshot(D,{...V??{...lr(),historyStatus:`ready`,hasMore:!1,streamingMsg:null,progress:null,taskPlan:null,sending:!1,streaming:!1},messages:B,hasMore:V?.hasMore??!1,streamingMsg:{role:`assistant`,content:[],timestamp:Date.now(),renderKey:M,pendingResponseStatus:`sending`},progress:null,sending:!0,streaming:!1}),Lf(D),!V?.name?.trim()&&z.trim()){let e=Xk(z.trim());e&&(_().patchSessionMeta(D,{name:e}),Zk(D,e))}let H=e=>{_().updateSessionMessages(D,t=>Hk(t,j,e))};return Vk(async t=>{let r=!1;try{let i=Wk({chatId:D,shouldApplyStreamUpdate:u,isCurrentRun:A,beforeAssistantDelta:()=>{},reconcileHydratedAssistantText:!1,setStreamingOnStreamStart:!0,clearResumeRunIdOnBackgroundTerminal:!1,clearResumeRunIdOnVisibleError:!1,setError:v,sessionMgrRef:c,applyLoadedSessionSnapshot:f,finalizeMessage:b,fq:d});i.onInputAccepted=()=>{r=!0,H(`accepted`),A()&&_().setPendingResponseStatus(D,`waiting`),t()},await bn.senderFor(D).send(e,D,a,E,i,n,x,g,S)}catch(e){if(!A())return;if(e.name!==`AbortError`)_().clearStreamingState(D),Bf(D),u(D)&&v(e instanceof Error?e.message:String(e)),x&&p(D,0);else{Bf(D);let e=Un(D)?.streamingMsg;e?.renderKey===M&&e.pendingResponseStatus&&_().clearStreamingState(D)}}finally{A()&&(r||H(`failed`),u(D)&&(o.current=!1,s.current=!1),_().setSessionFlags(D,{sending:!1}),bn.releaseIdleSender(D))}})},[t,r,i,o,s,u,c,f,b,d.dismissClarify,h,n,p]),w=(0,Q.useCallback)((e,t,n,r,i)=>C(t,n,r,i,e),[C]),T=(0,Q.useCallback)((e,t)=>{let n=a.current;if(!n||$n(n).phase!==`idle`||bn.getGeneration(n)!==e)return;let r=bn.getResumeRunId(n),i=_().sessions[n]?.streamingMsg?.turnId;r&&r!==t||i&&i!==t||(d.dismissClarify(),bn.abort(n,!1),Bf(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=bn.getGeneration(e),n=bn.getResumeRunId(e)??_().sessions[e]?.streamingMsg?.turnId??null;await d.stopSession(),a.current===e&&T(t,n)},[d.stopSession,a,T]),settleStoppedRun:T,deleteMessageRound:(0,Q.useCallback)(e=>{let t=a.current;if(!t||o.current||s.current)return;let n=yr(t),r=n[e];if(!r||!kn(r.role))return;if(r.deliveryStatus===`failed`){let r=[...n];r.splice(e,1),_().updateSessionMessages(t,()=>r);return}let i=qn(n,e);if(i===null)return;let l=fn(n,e),u=[...n];u.splice(e,l),_().updateSessionMessages(t,()=>u),c.current.deleteMessages(t,{userRoundIndex:i}).catch(()=>{p(t,0)})},[a,o,s,c,p]),retryUserMessageRound:(0,Q.useCallback)(e=>{let t=a.current;if(!t||o.current||s.current)return;let n=yr(t),r=n[e];if(!r||!kn(r.role))return;for(let t=e+1;t<n.length;t++){let e=n[t];if(e&&kn(e.role))return}let i=r.userTurnDocument?Mn(r.userTurnDocument):Rn(r.content),c=Ln(r.attachments);if(!i.trim()&&!c?.length&&!r.contextRefs?.length)return;let u=r.contextRefs?.flatMap(e=>e.kind===`mcp_resource`?[]:[{refId:e.refId,kind:e.kind,sourceId:e.sourceId,expectedVersion:e.version,title:e.title,fileKind:e.fileKind}]),d=r.deliveryStatus===`failed`?r.clientSubmissionId:void 0;!d&&!r.turnId||l.current(i,c,void 0,u,r.turnId,r.pendingAppContext,void 0,d).catch(()=>{p(t,0)})},[a,o,s,p,l])}}function iA(e){let t=(0,X.c)(11),{conversationId:n,conversationIdRef:r,sessionMgrRef:i,loadSessionById:a,loadTimelineById:o,applyAgentConfig:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=[],t[0]=c):c=t[0],(0,Q.useEffect)(oA,c);let l,u;t[1]!==n||t[2]!==a||t[3]!==o?(l=()=>{let e=e=>{let t=e.detail;!t?.key||t.key!==n||(a(n,0),o(n))};return window.addEventListener(`session-transcript-updated`,e),()=>window.removeEventListener(`session-transcript-updated`,e)},u=[n,a,o],t[1]=n,t[2]=a,t[3]=o,t[4]=l,t[5]=u):(l=t[4],u=t[5]),(0,Q.useEffect)(l,u);let d,f;t[6]!==s||t[7]!==r||t[8]!==i?(d=()=>{let e=e=>{if(ti(e.detail))return;let t=r.current;t&&i.current.loadSessionAgentConfig(t).then(e=>{s(t,e)}).catch(aA)};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},f=[r,i,s],t[6]=s,t[7]=r,t[8]=i,t[9]=d,t[10]=f):(d=t[9],f=t[10]),(0,Q.useEffect)(d,f)}function aA(){}function oA(){let e=sA;return window.addEventListener(`session-updated`,e),()=>window.removeEventListener(`session-updated`,e)}function sA(e){let t=e.detail;!t?.key||t.name===void 0||Nn.getState().patchSessionMeta(t.key,{name:t.name||null})}function cA(e){let t=d(),{isNewRoute:n,forceNewChat:r,decodedKey:i,viewConversationId:a,routedFocusedConversationId:o,routeConversationIdRef:s,locationKey:c,locationSearch:l,locationState:u}=Pk(e?.fixedConversationId),f=(0,Q.useRef)(new fr),p=(0,Q.useRef)(!1),m=(0,Q.useRef)(!1),h=(0,Q.useRef)(!1),g=(0,Q.useRef)(0),_=(0,Q.useRef)(!1),[v,y]=(0,Q.useState)([]),b=(0,Q.useRef)(async()=>{}),x=(0,Q.useRef)(0),S=o,C=Nn(e=>e.initLoading),w=Nn(e=>e.loadingMore),T=Nn(e=>e.shellError),E=a,D=Rm(E),O=E?hn(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=fk(D,Gr(di,ui,{revalidateOnFocus:!1}).data),L=D?.modelConfigSaving??!1,R=D?.thinkingLevel??`medium`,z=D?.reasoningLevel??`on`,B=D?.modelSupportsThinking??!1,V=D?.effectiveWorkspacePath??``,H=D?.workspaceSource??`agent_default_root`,U=D?.userContextMode??`enabled`;(0,Q.useEffect)(()=>{!E||A||k||f.current.loadSessionAgentConfig(E).then(e=>Kn(E,e)).catch(()=>void 0)},[E,A,k]),(0,Q.useEffect)(()=>{let e=e=>{let t=e.detail.conversationId;f.current.loadSessionAgentConfig(t).then(e=>Kn(t,e)).catch(()=>void 0)};return window.addEventListener(`session-model-config-stale`,e),()=>window.removeEventListener(`session-model-config-stale`,e)},[]),(0,Q.useEffect)(()=>{x.current=D?.messages.length??0},[D?.messages.length]),(0,Q.useEffect)(()=>{m.current=A,h.current=k},[A,k]);let{token:W,chatAgentsData:G,resolveAgentIdForPost:ee,onChatAgentChange:te,displayAgentId:ne,showChatAgentSelector:re,currentSessionProjectId:ie}=Sk({navigate:t,personal:e?.personal,conversationIdRef:Ik,conversationId:S,isNewRoute:n,locationState:u,locationSearch:l}),ae=i!==void 0&&S!==i,oe=!!(i&&D?.historyStatus===`loading`&&!ae),se=(0,Q.useMemo)(()=>C&&(S==null||i===void 0),[C,S,i]),ce=mk({isNewRoute:n,sessionRoutePending:ae,showSessionLoading:se,sessionContentLoading:oe,messageCount:D?.messages.length??0}),le=(0,Q.useCallback)((e,n=!1,r)=>{let i=r??``;t({pathname:`/chat/${encodeURIComponent(e)}`,search:i},{replace:n})},[t]),ue=(0,Q.useCallback)(e=>ik({streamConversationId:e,routeConversationId:s.current}),[s]),K=(0,Q.useCallback)(()=>{pk({sendingRef:m,streamingRef:h})},[]),q=bk({conversationId:S,decodedKey:i,conversationIdRef:Ik,sendingRef:m,streamingRef:h,modelSupportsThinking:B,thinkingLevel:R,shouldApplyStreamUpdate:ue}),de=(0,Q.useCallback)(()=>{q.clearVisibleClarify();let e=Ik.current;e&&bn.resetRunTracking(e),dk(K)},[q.clearVisibleClarify,Ik,K]),{refreshModelThinkingSupport:fe,pollSessionNameAfterTurn:pe,applyLoadedSessionSnapshot:J,loadSessionById:me,loadMoreMessages:he,onSessionModelChange:ge,onSessionThinkingLevelChange:_e,onSessionWorkingDirectoryChange:ve,createNewSession:ye,resetCurrentSession:be}=Bk({sessionMgrRef:f,routeConversationIdRef:s,sendingRef:m,streamingRef:h,loadingSessionRef:p,messagesLenRef:x,thinkingSupportGenRef:g,navigateToSession:le,resolveAgentIdForPost:ee,detachForNewConversation:de,conversationId:S,sessionAgentId:ne,currentProjectId:ie,hasMore:N,taskId:e?.taskId}),xe=(0,Q.useCallback)(e=>{if(!ak({cacheConversationId:e,routeConversationId:s.current}))return!1;let t=Un(e);return!t||!hn(t)&&!sr(e)&&!bn.isStreamingFor(e)?!1:(m.current=t.sending,h.current=t.streaming,!0)},[s]),{tryResumeAgentRun:Se,sendMessage:Ce,replaceLatestUserTurn:we,interruptAndSend:Te,abort:Ee,settleStoppedRun:De,deleteMessageRound:Oe,retryUserMessageRound:ke}=rA({conversationId:S,taskId:e?.taskId,thinkingLevel:R,modelSupportsThinking:B,conversationIdRef:Ik,sendingRef:m,streamingRef:h,sessionMgrRef:f,sendMessageRef:b,shouldApplyStreamUpdate:ue,fq:q,applyLoadedSessionSnapshot:J,loadSessionById:me,resetCurrentSession:be,pollSessionNameAfterTurn:pe});(0,Q.useEffect)(()=>{n&&de()},[n,de]);let Ae=(0,Q.useMemo)(()=>lk({viewConversationId:a,conversationId:E,messages:D?.messages??[],streamingMsg:O?D?.streamingMsg??null:null}),[a,E,D?.messages,D?.streamingMsg,O]),je=(0,Q.useCallback)((e,t)=>{Nn.getState().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:t}),K()},[K]),Me=(0,Q.useCallback)((e,t)=>{Kn(e,t),fe(t.model)},[fe]),Ne=(0,Q.useCallback)(e=>{let t=Nn.getState();e.loading!==void 0&&t.setInitLoading(e.loading),e.error!==void 0&&t.setShellError(e.error)},[]),Pe=(0,Q.useCallback)(async t=>{try{let n=await f.current.loadTimeline(t,e?.taskId);if(s.current!==t)return;y(n)}catch{s.current===t&&y([])}},[s,e?.taskId]);(0,Q.useEffect)(()=>{if(n||!S){y([]);return}Pe(S)},[S,n,Pe]),iA({conversationId:S,conversationIdRef:Ik,sendingRef:m,streamingRef:h,sessionMgrRef:f,loadSessionById:me,loadTimelineById:Pe,applyAgentConfig:Me});let Fe=Lk({token:W,isNewRoute:n,forceNewChat:r,temporary:u?.temporary===!0,requestedAgentId:typeof u?.agentId==`string`?u.agentId:void 0,decodedKey:i,locationKey:c,locationSearch:l,sessionMgrRef:f,resolveAgentIdForPost:ee,navigateToSession:le,loadSessionById:me,tryResumeAgentRun:Se,restoreLiveCacheIfNeeded:xe,adoptEmptySession:je,applyAgentConfig:Me,patchInitUi:Ne}),Ie=Rk(Fe);return(0,Q.useEffect)(()=>{Fe&&Ie.error&&Nn.getState().setShellError(Ie.error instanceof Error?Ie.error.message:`Failed to load model configuration`)},[Fe,Ie.error]),(0,Q.useEffect)(()=>{let e=e=>{let t=e.detail,n=t?.conversationId,r=t?.runId;!n||!r?.trim()||(nr(n,r),bn.setResumeRunId(n,r),ue(n)&&(bn.isTrackingRun(n,r)||queueMicrotask(()=>{ue(n)&&(bn.isTrackingRun(n,r)||Se(n,yr(n)))})))};return window.addEventListener(`run-started`,e),()=>window.removeEventListener(`run-started`,e)},[Se,ue]),(0,Q.useEffect)(()=>{let e=k||A,t=_.current;if(_.current=e,!t||e)return;let n=Ik.current;n&&queueMicrotask(()=>{!n||!ue(n)||bn.isStreamingFor(n)||sr(n)&&Se(n,yr(n))})},[k,A,Se,ue]),b.current=Ce,{auth:{hasToken:!!W},session:{projectPreparation:Ie.preparation,conversationId:S,sessionName:P,decodedKey:i,sessionRoutePending:ae,sessionContentLoading:oe,showSessionLoading:se,conversationPhase:ce,loading:C,sessionModel:Fe?Ie.model:F,modelConfigReady:Fe?Ie.ready:I,modelConfigSaving:L,thinkingLevel:Fe?Ie.thinkingLevel:R,onSessionThinkingLevelChange:Fe?Ie.onThinkingChange:_e,onSessionWorkingDirectoryChange:ve,reasoningLevel:z,modelSupportsThinking:Fe?Ie.modelSupportsThinking:B,effectiveWorkspacePath:V,workspaceSource:H,userContextMode:Fe?.temporary?`temporary`:U,hasMore:N,loadingMore:w,loadMoreMessages:he,onSessionModelChange:Fe?Ie.onModelChange:ge,createNewSession:ye,sessionManager:f.current},messages:{items:Ae},timeline:{items:v,refresh:Pe},stream:{error:T,streaming:k,sending:A,progress:j,taskPlan:M,sendMessage:Ce,replaceLatestUserTurn:we,abort:Ee,settleStoppedRun:De,interruptAndSend:Te,deleteMessageRound:Oe,retryUserMessageRound:ke},followUp:{composerMode:q.composerMode,control:q.control,controlPending:q.controlPending,beginEditTurn:q.beginEditTurn,cancelEditor:q.cancelEditor,restoreEditor:q.restoreEditor,resumeQueue:q.resumeQueue,sendQueuedInput:q.sendQueuedInput,addPendingFollowUp:q.addPendingFollowUp,pendingFollowUps:q.pendingFollowUps,editingFollowUpId:q.editingFollowUpId,beginEditFollowUp:q.beginEditFollowUp,cancelEditFollowUp:q.cancelEditFollowUp,commitEditFollowUp:q.commitEditFollowUp,removePendingFollowUp:q.removePendingFollowUp,movePendingFollowUp:q.movePendingFollowUp,reorderPendingFollowUp:q.reorderPendingFollowUp,steerPendingFollowUp:q.steerPendingFollowUp,steeringFollowUpId:q.steeringFollowUpId},clarify:{clarifyPrompt:q.clarifyPrompt,clarifySubmitting:q.clarifySubmitting,clarifySubmitError:q.clarifySubmitError,submitClarifyAnswer:q.submitClarifyAnswer,letAgentDecideClarification:q.letAgentDecideClarification,cancelClarification:q.cancelClarification},agents:{chatAgents:G,displayAgentId:Fe?.agentId??ne,showChatAgentSelector:re,onChatAgentChange:te}}}function lA(e){let t=(0,X.c)(11),n=m(uA),r;t[0]===e?r=t[1]:(r=e?.trim()||null,t[0]=e,t[1]=r);let i=r,a;t[2]===i?a=t[3]:(a=e=>i?e.sessions[i]?.localDraft:void 0,t[2]=i,t[3]=a);let o=Nn(a),s;t[4]!==o||t[5]!==n||t[6]!==i?(s=n&&i&&!o?[`chat-session-meta`,i,n,o===!1?`persisted`:`unknown`]:null,t[4]=o,t[5]=n,t[6]=i,t[7]=s):s=t[7];let c;t[8]===i?c=t[9]:(c=async()=>{if(await wr(i))return;let e=await un(i),t=typeof e.sessionType==`string`&&e.sessionType.trim()?e.sessionType.trim():null,n=typeof e.routing?.agentId==`string`&&e.routing.agentId.trim()?e.routing.agentId.trim():null,r=e.customData?.sourceBinding,a=r&&typeof r==`object`?r:null,o=a?.kind===`note`&&typeof a.sourceId==`string`&&a.sourceId.trim()?a.sourceId.trim():null,s=typeof e.parentConversationId==`string`&&e.parentConversationId.trim()?e.parentConversationId.trim():null,c=e.customData?.forkedFromSessionName;return{identity:{sourceChannel:e.sourceChannel,sessionType:e.sessionType,customData:e.customData},ownerAgentId:n,sessionType:t,sourceNoteId:o,sourceNoteTitle:null,parentConversationId:s,forkedFromSessionName:typeof c==`string`&&c.trim()?c.trim():null}},t[8]=i,t[9]=c);let l;return t[10]===Symbol.for(`react.memo_cache_sentinel`)?(l={revalidateOnFocus:!1},t[10]=l):l=t[10],Gr(s,c,l)}function uA(e){return e.conversationId}function dA(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 fA(e,t){return dA(zn(e??``),t)}function pA(e,t){return da(e,t)}function mA(e){return e===`context`||e===`branch`||e===`compaction`?e:null}function hA(e){return dA(e.preview||e.title,72)||e.kind}function gA(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:fA(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:pA(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=mA(a.kind);if(!e)continue;let o=`${a.id}:${a.kind}`;r.events.some(e=>e.key===o)||r.events.push({key:o,label:hA(a),tone:e})}return n}function _A(e,t){return(e===1?t.toolCount_one:t.toolCount_other).replace(`{{count}}`,String(e))}function vA(e,t){let n=e[0]?.id;for(let r of e)r.messageIndex<=t&&(n=r.id);return n}function yA(e){let t=(0,X.c)(53),{turn:n,active:r,labels:i,currentLabel:a,onSelect:o}=e,s,c,l,u,d,f,p,m;if(t[0]!==r||t[1]!==a||t[2]!==i||t[3]!==o||t[4]!==n.events||t[5]!==n.preview||t[6]!==n.timestamp||t[7]!==n.title||t[8]!==n.tools){let e=n.tools.slice(0,2),h=n.events.slice(0,Math.max(0,3-e.length)),g=Math.max(0,n.tools.length-e.length)+Math.max(0,n.events.length-h.length);d=`button`;let _=r&&`bg-accent-soft/70`;t[17]===_?f=t[18]:(f=Y(`flex w-full min-w-0 items-start gap-3 border-b border-edge-subtle px-4 py-3 text-left transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,_),t[17]=_,t[18]=f),p=o;let v=r&&`border-accent bg-accent`,y;t[19]===v?y=t[20]:(y=Y(`mt-1 size-2.5 shrink-0 rounded-full border border-edge-strong bg-surface-panel`,v),t[19]=v,t[20]=y),t[21]===y?m=t[22]:(m=(0,Z.jsx)(`span`,{className:y,"aria-hidden":!0}),t[21]=y,t[22]=m),s=`min-w-0 flex-1`;let b;t[23]===n.preview?b=t[24]:(b=(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:n.preview}),t[23]=n.preview,t[24]=b);let x;t[25]!==r||t[26]!==a?(x=r?(0,Z.jsx)(`span`,{className:`shrink-0 rounded-full bg-accent px-1.5 py-0.5 text-[10px] font-medium text-on-accent`,children:a}):null,t[25]=r,t[26]=a,t[27]=x):x=t[27],t[28]!==b||t[29]!==x?(c=(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[b,x]}),t[28]=b,t[29]=x,t[30]=c):c=t[30];let S;t[31]===n.title?S=t[32]:(S=(0,Z.jsx)(`span`,{children:n.title}),t[31]=n.title,t[32]=S);let C;t[33]===n.timestamp?C=t[34]:(C=n.timestamp?(0,Z.jsx)(`time`,{suppressHydrationWarning:!0,dateTime:new Date(n.timestamp).toISOString(),children:dy(n.timestamp)}):null,t[33]=n.timestamp,t[34]=C);let w;t[35]!==i||t[36]!==n.tools.length?(w=n.tools.length>0?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Z.jsx)(Wt,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),_A(n.tools.length,i)]}):null,t[35]=i,t[36]=n.tools.length,t[37]=w):w=t[37],t[38]!==S||t[39]!==C||t[40]!==w?(l=(0,Z.jsxs)(`span`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[S,C,w]}),t[38]=S,t[39]=C,t[40]=w,t[41]=l):l=t[41],u=e.length>0||n.events.length>0?(0,Z.jsxs)(`span`,{className:`mt-2 flex min-w-0 flex-wrap gap-1.5`,children:[e.map(xA),h.map(bA),g>0?(0,Z.jsxs)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:[`+`,g]}):null]}):null,t[0]=r,t[1]=a,t[2]=i,t[3]=o,t[4]=n.events,t[5]=n.preview,t[6]=n.timestamp,t[7]=n.title,t[8]=n.tools,t[9]=s,t[10]=c,t[11]=l,t[12]=u,t[13]=d,t[14]=f,t[15]=p,t[16]=m}else s=t[9],c=t[10],l=t[11],u=t[12],d=t[13],f=t[14],p=t[15],m=t[16];let h;t[42]!==s||t[43]!==c||t[44]!==l||t[45]!==u?(h=(0,Z.jsxs)(`span`,{className:s,children:[c,l,u]}),t[42]=s,t[43]=c,t[44]=l,t[45]=u,t[46]=h):h=t[46];let g;return t[47]!==d||t[48]!==f||t[49]!==p||t[50]!==m||t[51]!==h?(g=(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`button`,{type:d,className:f,onClick:p,children:[m,h]})}),t[47]=d,t[48]=f,t[49]=p,t[50]=m,t[51]=h,t[52]=g):g=t[52],g}function bA(e){return(0,Z.jsxs)(`span`,{className:`inline-flex max-w-[10rem] items-center gap-1 rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:[(0,Z.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current opacity-70`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.label})]},e.key)}function xA(e){return(0,Z.jsxs)(`span`,{className:Y(`inline-flex max-w-[9rem] items-center gap-1 rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,e.running&&`text-accent-fg`),children:[(0,Z.jsx)(Wt,{className:`size-3 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.label})]},e.key)}function SA(e){let t=(0,X.c)(39),{items:n,activeMessageIndex:r,labels:i,openLabel:a,closeLabel:o,currentLabel:s,onSelectMessage:c}=e,l;t[0]!==n||t[1]!==i?(l=gA(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=vA(u,r),t[3]=r,t[4]=u,t[5]=p):p=t[5];let m=p,h;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(Pe,{className:`size-[1.125rem]`,strokeWidth:1.8,"aria-hidden":!0}),t[6]=h):h=t[6];let g;t[7]===a?g=t[8]:(g=(0,Z.jsx)(x,{asChild:!0,children:(0,Z.jsx)(pi,{type:`button`,variant:`ghost`,className:`size-10 shrink-0 rounded-full p-0 sm:size-9 xl:hidden`,"aria-label":a,title:a,children:h})}),t[7]=a,t[8]=g);let _;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Z.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim/60 backdrop-blur-[1px] xl:hidden`}),t[9]=_):_=t[9];let v;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(v=Y(`xopc-dialog-content-pane fixed inset-x-2 bottom-[max(.5rem,env(safe-area-inset-bottom))] z-[90] flex h-[min(72dvh,34rem)] flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-popover outline-none`,`sm:left-auto sm:right-3 sm:w-[min(24rem,calc(100vw-1.5rem))]`,`md:bottom-[max(1rem,env(safe-area-inset-bottom))] md:right-4 md:h-[min(calc(100dvh-6rem),40rem)]`,`xl:hidden`),t[10]=v):v=t[10];let y;t[11]===i.title?y=t[12]:(y=(0,Z.jsx)(E,{className:`min-w-0 truncate text-base font-semibold text-fg`,children:i.title}),t[11]=i.title,t[12]=y);let S;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(Gt,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=S):S=t[13];let O;t[14]===o?O=t[15]:(O=(0,Z.jsx)(C,{asChild:!0,children:(0,Z.jsx)(pi,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":o,children:S})}),t[14]=o,t[15]=O);let k;t[16]!==y||t[17]!==O?(k=(0,Z.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-between gap-3 border-b border-edge-subtle px-3.5 py-3`,children:[y,O]}),t[16]=y,t[17]=O,t[18]=k):k=t[18];let A;if(t[19]!==m||t[20]!==s||t[21]!==i||t[22]!==c||t[23]!==u){let e;t[25]!==m||t[26]!==s||t[27]!==i||t[28]!==c?(e=e=>(0,Z.jsx)(yA,{turn:e,active:e.id===m,labels:i,currentLabel:s,onSelect:()=>{c(e.messageIndex),f(!1)}},e.id),t[25]=m,t[26]=s,t[27]=i,t[28]=c,t[29]=e):e=t[29],A=u.map(e),t[19]=m,t[20]=s,t[21]=i,t[22]=c,t[23]=u,t[24]=A}else A=t[24];let j;t[30]===A?j=t[31]:(j=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,Z.jsx)(`ol`,{className:`min-w-0`,children:A})}),t[30]=A,t[31]=j);let M;t[32]!==k||t[33]!==j?(M=(0,Z.jsxs)(w,{children:[_,(0,Z.jsxs)(T,{className:v,"aria-describedby":void 0,children:[k,j]})]}),t[32]=k,t[33]=j,t[34]=M):M=t[34];let N;return t[35]!==d||t[36]!==M||t[37]!==g?(N=(0,Z.jsxs)(D,{open:d,onOpenChange:f,children:[g,M]}),t[35]=d,t[36]=M,t[37]=g,t[38]=N):N=t[38],N}function CA(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 wA(e){let t=(0,X.c)(40),{turn:n,labels:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n.events||t[2]!==n.preview||t[3]!==n.timestamp||t[4]!==n.title||t[5]!==n.tools){let e=n.tools.slice(0,3),p=Math.max(0,n.tools.length-e.length),m=n.events.slice(0,Math.max(0,3-e.length));i=p+Math.max(0,n.events.length-m.length);let h=n.tools.length>0||n.events.length>0?[...e.map(OA),...m.map(DA),...i>0?[`+${i}`]:[]].join(` · `):n.title;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(l=Y(`pointer-events-auto absolute right-12 top-1/2 z-[100] w-[min(25rem,calc(100vw-8rem))] -translate-y-1/2`,`rounded-2xl border border-edge bg-surface-overlay p-3 text-left shadow-popover backdrop-blur`),t[15]=l):l=t[15],t[16]===n.timestamp?u=t[17]:(u=n.timestamp?(0,Z.jsx)(`div`,{className:`mb-1 flex min-w-0 justify-end text-xs`,children:(0,Z.jsx)(`time`,{suppressHydrationWarning:!0,className:`shrink-0 tabular-nums text-fg-disabled`,dateTime:new Date(n.timestamp).toISOString(),children:dy(n.timestamp)})}):null,t[16]=n.timestamp,t[17]=u),t[18]===n.preview?d=t[19]:(d=(0,Z.jsx)(`div`,{className:`min-w-0 text-sm font-semibold leading-5 text-fg`,children:(0,Z.jsx)(`span`,{className:`line-clamp-1`,children:n.preview})}),t[18]=n.preview,t[19]=d),t[20]===h?f=t[21]:(f=(0,Z.jsx)(`div`,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:h}),t[20]=h,t[21]=f),a=`mt-3 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 text-sm text-fg-subtle`,t[22]!==r||t[23]!==n.title||t[24]!==n.tools.length?(o=n.tools.length>0?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Z.jsx)(Wt,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:_A(n.tools.length,r)})]}):(0,Z.jsx)(`span`,{children:n.title}),t[22]=r,t[23]=n.title,t[24]=n.tools.length,t[25]=o):o=t[25],s=e.map(EA),c=m.map(TA),t[0]=r,t[1]=n.events,t[2]=n.preview,t[3]=n.timestamp,t[4]=n.title,t[5]=n.tools,t[6]=i,t[7]=a,t[8]=o,t[9]=s,t[10]=c,t[11]=l,t[12]=u,t[13]=d,t[14]=f}else i=t[6],a=t[7],o=t[8],s=t[9],c=t[10],l=t[11],u=t[12],d=t[13],f=t[14];let p;t[26]===i?p=t[27]:(p=i>0?(0,Z.jsxs)(`span`,{children:[`+`,i]}):null,t[26]=i,t[27]=p);let m;t[28]!==a||t[29]!==o||t[30]!==s||t[31]!==c||t[32]!==p?(m=(0,Z.jsxs)(`div`,{className:a,children:[o,s,c,p]}),t[28]=a,t[29]=o,t[30]=s,t[31]=c,t[32]=p,t[33]=m):m=t[33];let h;return t[34]!==m||t[35]!==l||t[36]!==u||t[37]!==d||t[38]!==f?(h=(0,Z.jsxs)(`div`,{className:l,children:[u,d,f,m]}),t[34]=m,t[35]=l,t[36]=u,t[37]=d,t[38]=f,t[39]=h):h=t[39],h}function TA(e){return(0,Z.jsxs)(`span`,{className:Y(`inline-flex min-w-0 max-w-[10rem] items-center gap-1.5`,e.tone===`branch`&&`text-accent`,e.tone===`compaction`&&`text-fg-muted`),children:[(0,Z.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current opacity-70`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.label})]},e.key)}function EA(e){return(0,Z.jsxs)(`span`,{className:Y(`inline-flex min-w-0 max-w-[9rem] items-center gap-1.5`,e.running&&`text-accent`),children:[(0,Z.jsx)(Wt,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.label})]},e.key)}function DA(e){return e.label}function OA(e){return e.label}function kA(e){let t=(0,X.c)(44),{items:n,activeMessageIndex:r,labels:i,onSelectMessage:a}=e,o;t[0]!==n||t[1]!==i?(o=gA(n,i),t[0]=n,t[1]=i,t[2]=o):o=t[2];let s=o,[c,l]=(0,Q.useState)(null),u=(0,Q.useRef)(null),d,f;if(t[3]===c?(d=t[4],f=t[5]):(d=()=>{if(!c)return;let e=()=>{l(null)},t=t=>{let n=t.target;n instanceof Node&&(u.current?.contains(n)||e())},n=t=>{t.key===`Escape`&&e()};return document.addEventListener(`pointerdown`,t,!0),document.addEventListener(`keydown`,n),()=>{document.removeEventListener(`pointerdown`,t,!0),document.removeEventListener(`keydown`,n)}},f=[c],t[3]=c,t[4]=d,t[5]=f),(0,Q.useEffect)(d,f),s.length<4)return null;let p;if(t[6]!==r||t[7]!==s){p=s[0]?.id;for(let e of s)e.messageIndex<=r&&(p=e.id);t[6]=r,t[7]=s,t[8]=p}else p=t[8];let m=c??p,h;t[9]!==c||t[10]!==s?(h=c?s.find(e=>e.id===c):null,t[9]=c,t[10]=s,t[11]=h):h=t[11];let g=h,_=c!==null,v;if(t[12]!==m||t[13]!==s){let e;t[15]===m?e=t[16]:(e=e=>e.id===m,t[15]=m,t[16]=e),v=s.findIndex(e),t[12]=m,t[13]=s,t[14]=v}else v=t[14];let y=Math.max(0,v),b=i.title,x,S;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{l(null)},S=e=>{let t=e.relatedTarget;(!(t instanceof Node)||!e.currentTarget.contains(t))&&l(null)},t[17]=x,t[18]=S):(x=t[17],S=t[18]);let C;t[19]===p?C=t[20]:(C=()=>l(e=>e??p??null),t[19]=p,t[20]=C);let w;if(t[21]!==a||t[22]!==_||t[23]!==m||t[24]!==y||t[25]!==s){let e;t[27]!==a||t[28]!==_||t[29]!==m||t[30]!==y?(e=(e,t)=>{let n=e.id===m,r=Math.abs(t-y);return(0,Z.jsx)(`li`,{className:`group relative flex h-3.5 w-full shrink-0 items-center justify-end`,onMouseEnter:()=>l(e.id),onFocus:()=>l(e.id),children:(0,Z.jsx)(`button`,{type:`button`,className:Y(`flex h-3.5 w-full items-center justify-end rounded-sm pr-1.5`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),onClick:()=>a(e.messageIndex),"aria-label":`${e.title}: ${e.preview}`,children:(0,Z.jsx)(`span`,{className:Y(`block h-0.5 rounded-full transition-[width,background-color] duration-150 ease-out`,CA({active:n,scrubbing:_,distance:r}),`group-hover:bg-fg`),"aria-hidden":!0})})},e.id)},t[27]=a,t[28]=_,t[29]=m,t[30]=y,t[31]=e):e=t[31],w=s.map(e),t[21]=a,t[22]=_,t[23]=m,t[24]=y,t[25]=s,t[26]=w}else w=t[26];let T;t[32]!==w||t[33]!==C?(T=(0,Z.jsx)(`div`,{className:`chat-timeline-scroll flex min-h-0 w-full flex-col`,children:(0,Z.jsx)(`ol`,{className:`my-auto flex w-full shrink-0 flex-col items-end py-1`,onMouseEnter:C,children:w})}),t[32]=w,t[33]=C,t[34]=T):T=t[34];let E;t[35]!==i||t[36]!==g?(E=g?(0,Z.jsx)(wA,{turn:g,labels:i}):null,t[35]=i,t[36]=g,t[37]=E):E=t[37];let D;t[38]!==T||t[39]!==E?(D=(0,Z.jsxs)(`div`,{className:`relative z-[90] flex h-full min-h-0 w-full flex-col justify-center overflow-visible`,children:[T,E]}),t[38]=T,t[39]=E,t[40]=D):D=t[40];let O;return t[41]!==i.title||t[42]!==D?(O=(0,Z.jsx)(`aside`,{ref:u,className:`hidden h-full min-h-0 max-h-full w-12 shrink-0 items-center overflow-visible py-4 xl:flex`,"aria-label":b,onMouseLeave:x,onBlur:S,children:D}),t[41]=i.title,t[42]=D,t[43]=O):O=t[43],O}function AA(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 jA(e){let t=AA(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 MA(e){let{enabled:t,conversationId:n,sourceContextPending:r,sourceContextFailed:i,suppressProjectContext:a,project:o,task:s}=e,c=AA(e),[l,u]=(0,Q.useState)(()=>jA(e));(0,Q.useEffect)(()=>{let e=!1,l=jA({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 wr(n);r=e?e.creation.projectId?.trim()||null:(await un(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):sn(r),cn(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:jA(e);return{context:d.context,status:d.status}}var NA=[Rt,Pt,_s];function PA(e){let t=(0,X.c)(20),{agentName:n,messages:r,disabled:i,onPick:a}=e,o;t[0]!==r.setupPromptComplete||t[1]!==r.setupPromptIdentity||t[2]!==r.setupPromptProject?(o=[r.setupPromptIdentity,r.setupPromptProject,r.setupPromptComplete],t[0]=r.setupPromptComplete,t[1]=r.setupPromptIdentity,t[2]=r.setupPromptProject,t[3]=o):o=t[3];let s=o,c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-2xl bg-accent-soft text-accent`,children:(0,Z.jsx)(Rt,{className:`size-6`,strokeWidth:1.75,"aria-hidden":!0})}),t[4]=c):c=t[4];let l;t[5]===r.setupTitle?l=t[6]:(l=(0,Z.jsx)(`h1`,{id:`agent-setup-title`,className:`mt-4 text-balance text-xl font-semibold tracking-tight text-fg`,children:r.setupTitle}),t[5]=r.setupTitle,t[6]=l);let u;t[7]!==n||t[8]!==r.setupDescription?(u=r.setupDescription.replace(`{{name}}`,n),t[7]=n,t[8]=r.setupDescription,t[9]=u):u=t[9];let d;t[10]===u?d=t[11]:(d=(0,Z.jsx)(`p`,{className:`mt-2 max-w-xl text-pretty text-sm leading-relaxed text-fg-muted`,children:u}),t[10]=u,t[11]=d);let f;t[12]!==i||t[13]!==a||t[14]!==s?(f=(0,Z.jsx)(`div`,{className:`mt-7 grid w-full gap-3 md:grid-cols-3`,children:s.map((e,t)=>{let n=NA[t]??Rt;return(0,Z.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>a(e),className:Y(`flex min-h-24 items-center gap-3 rounded-xl border border-edge bg-surface-panel px-4 py-4 text-left text-sm font-medium leading-relaxed text-fg`,`hover:border-accent/30 hover:bg-surface-hover`,ca.transition,ca.pressCard,ca.focusRingPanel,ca.disabled),children:[(0,Z.jsx)(n,{className:`size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:e})]},e)})}),t[12]=i,t[13]=a,t[14]=s,t[15]=f):f=t[15];let p;return t[16]!==l||t[17]!==d||t[18]!==f?(p=(0,Z.jsxs)(`section`,{className:`mx-auto flex w-full max-w-4xl flex-col items-center px-2 pb-4 pt-12 text-center sm:pt-16`,"aria-labelledby":`agent-setup-title`,children:[c,l,d,f]}),t[16]=l,t[17]=d,t[18]=f,t[19]=p):p=t[19],p}var FA=t({ChatPage:()=>LA}),IA=(0,Q.lazy)(async()=>({default:(await o(()=>import(`./chat-terminal-dock-CAaHWS7F.js`),__vite__mapDeps([30,1,2,5,6,31,11,32,26,27,17,18,33,34,35,36,37,38,39,40,41,42,43,4,44,45,28,29,9,46,47,48,49]))).ChatTerminalDock}));function LA({beforeSend:e,draftSeed:t,sourceNoteInView:n=!1,embedded:r=!1,conversationId:i,taskId:a,personal:o=!1,personalWelcome:s,automationWorkspace:f=!1,automationTimelineEntries:p,readOnly:g=!1,onHistoryReady:_,automationExecution:v=!1,initialTurnId:x,onInitialTurnLocated:C}={}){let O=h(e=>e.language),k=y(O),A=m(e=>e.conversationId),j=d(),M=c(),{pathname:N}=M,[P,F]=l(),I=(0,Q.useRef)(null),L=(0,Q.useRef)(0),R=(0,Q.useRef)(null),[z,V]=(0,Q.useState)(null),[H,U]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{U(t??null)},[t]);let[W,G]=(0,Q.useState)(()=>!!(i&&window.localStorage.getItem(`personal-calibration:${i}`))),[ee,te]=(0,Q.useState)(null),[ne,re]=(0,Q.useState)(null),[ie,ae]=(0,Q.useState)(!1),[oe,se]=(0,Q.useState)(null),ce=a?.trim()||null,{data:le}=zs(ce??``),{auth:ue,session:K,messages:q,timeline:de,stream:fe,followUp:pe,clarify:J,agents:me}=cA({fixedConversationId:i,taskId:ce??void 0,personal:o}),he=pe.composerMode.kind===`editTurn`?pe.composerMode:null,ge=Nn(e=>!!(K.conversationId&&!e.shellError&&e.sessions[K.conversationId]?.historyStatus===`ready`));(0,Q.useEffect)(()=>{ge&&q.items.length>0&&_?.()},[ge,q.items.length,_]),(0,Q.useLayoutEffect)(()=>{if(!f&&!v||!K.conversationId)return;let e=K.conversationId;return $f.setState({conversationIdOverride:e}),()=>{$f.getState().conversationIdOverride===e&&$f.setState({conversationIdOverride:null})}},[f,v,K.conversationId]);let _e=!o&&!r&&!ce&&P.get(`scene`)===`find-skills`,ve=f||P.get(`setup`)===`automation`,ye=!r&&!ce&&P.get(`agentSetup`)===`1`,be=o?``:P.get(`skill`)?.trim()??``,xe=o?``:P.get(`slash`)?.trim()??``;(0,Q.useEffect)(()=>{if(!o||!P.has(`skill`)&&!P.has(`slash`))return;let e=new URLSearchParams(P);e.delete(`skill`),e.delete(`slash`),F(e,{replace:!0})},[o,P,F]);let Se=P.get(f?`chatDraft`:`draft`)??``,Ce=P.get(`autoSend`)===`1`,we=P.get(`attachmentHandoff`),Ee=P.get(`attachmentsHandoff`),De=K.decodedKey??K.conversationId,[Oe,ke]=(0,Q.useState)(null),je=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(we){let e=Ae(we);e&&ke(e),je.current=De;return}je.current!==De&&(je.current=De,ke(null))},[we,De]);let Me=If(e=>e.markViewed),Ne=If(e=>De?e.runs[De]?.unread:!1);(0,Q.useEffect)(()=>{De&&Ne&&Me(De)},[De,Ne,Me]);let{data:Pe}=lA(De),Fe=ve||!!Pe?.identity?.customData?.automationSetup,Ie=!!Pe?.identity?.customData?.automationSetup?.automationId,Le=(0,Q.useCallback)(async e=>{if(De)try{let t=await K.sessionManager.forkSessionAtTurn(De,e);window.dispatchEvent(new CustomEvent(`session-created`,{detail:{key:t.conversationId,conversationId:t.conversationId}})),ya(`success`,k.chat.messageForkCreated),j(`/chat/${encodeURIComponent(t.conversationId)}`)}catch(e){throw ya(`error`,e instanceof Error?e.message:k.chat.messageForkFailed),e}},[De,k.chat.messageForkCreated,k.chat.messageForkFailed,j,K.sessionManager]),ze=q.items.at(-1),Ue=o&&!W&&!fe.streaming&&!fe.sending&&ze?.role===`assistant`&&q.items.filter(e=>e.role===`user`).length===1&&q.items.filter(e=>e.role===`assistant`).length===1&&!q.items.some(e=>e.role===`task`),We=e=>{G(!0),i&&window.localStorage.setItem(`personal-calibration:${i}`,`1`),e&&(L.current+=1,V({id:L.current,text:e}))};(0,Q.useEffect)(()=>{I.current=null},[K.conversationId]),(0,Q.useEffect)(()=>{if(!ue.hasToken||!be&&!xe&&!Se&&!(K.projectPreparation&&Ee)||Ce&&!K.projectPreparation||K.showSessionLoading||K.sessionRoutePending||!K.conversationId&&!K.projectPreparation)return;let e=K.projectPreparation&&Ee?ki(Ee)??void 0:void 0,t=()=>{let e=new URLSearchParams(P);e.delete(`skill`),e.delete(`slash`),e.delete(f?`chatDraft`:`draft`),K.projectPreparation&&(e.delete(`autoSend`),e.delete(`attachmentsHandoff`));let t=e.toString();j({pathname:N,search:t?`?${t}`:``},{replace:!0})},n=(n,r)=>{I.current!==r&&(I.current=r,queueMicrotask(()=>{e?.length?Wp(n,e):(L.current+=1,V({id:L.current,text:n})),t()}))},r=Jr(be,Se);if(r||e?.length){let e=`${K.conversationId}:draft:${r}`;n(r??``,e);return}if(be){t();return}if(!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(xe)){t();return}let i=`${K.conversationId}:slash:${xe}`;I.current!==i&&queueMicrotask(()=>{(async()=>{try{let e=await bo(),t=xe.toLowerCase(),n=e.find(e=>e.name.toLowerCase()===t||Array.isArray(e.aliases)&&e.aliases.some(e=>e.toLowerCase()===t));if(n){if(I.current===i)return;I.current=i,L.current+=1,V({id:L.current,text:Sw(n)})}}finally{t()}})()})},[ue.hasToken,f,be,xe,Se,Ce,Ee,K.projectPreparation,P,K.showSessionLoading,K.sessionRoutePending,K.conversationId,j,N]);let{scrollRef:Ge,composerDockRef:Ke,atBottom:qe,registerListContentRef:Je,scrollToBottom:Ye,replySpaceRef:Xe,reserveReplySpace:Ze,onScroll:Qe}=sw({hasToken:ue.hasToken,showSessionLoading:K.showSessionLoading,conversationId:K.conversationId,chatMessages:q.items,streaming:fe.streaming,hasMore:K.hasMore,loadingMore:K.loadingMore,loadMoreMessages:K.loadMoreMessages});(0,Q.useEffect)(()=>{if(!f||!qe||!p?.length)return;let e=requestAnimationFrame(()=>Ye(!1));return()=>cancelAnimationFrame(e)},[f,p,qe,Ye]);let $e=NO({enabled:o,conversationId:K.conversationId,messages:q.items,viewportRef:Ge}),[et,nt]=(0,Q.useState)(0),rt=(0,Q.useRef)(null),it=(0,Q.useRef)(null),at=(0,Q.useMemo)(()=>{let e=-1;for(let t of de.items)typeof t.displayIndex==`number`&&Number.isFinite(t.displayIndex)&&(e=Math.max(e,t.displayIndex));return e<0?0:Math.max(0,e+1-q.items.length)},[q.items.length,de.items]),ot=(0,Q.useCallback)(e=>{let t=Ge.current;if(!t)return!1;let n=t.querySelector(`[data-chat-message-index="${e}"]`);if(!n){let n=WC(t)?.reveal(e)??!1;return n&&nt(e),n}GC(t),nt(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:VC()}),!0},[Ge]),st=(0,Q.useCallback)(()=>{let e=Ge.current;if(!e)return;let t=BC(e);nt(e=>e===t?e:t)},[Ge]),ct=(0,Q.useCallback)(()=>{rt.current??=requestAnimationFrame(()=>{rt.current=null,st()})},[st]),lt=(0,Q.useCallback)(()=>{Qe(),ct()},[Qe,ct]),ut=(0,Q.useCallback)(e=>{let t=e-at;if(t<0||t>=q.items.length){t<0&&K.hasMore&&!K.loadingMore&&(it.current=e,K.loadMoreMessages());return}it.current=null,ot(t)},[q.items.length,ot,K.hasMore,K.loadMoreMessages,K.loadingMore,at]);Fw({conversationId:K.conversationId,turnId:x,messages:q.items,ready:ge,hasMore:K.hasMore,loadingMore:K.loadingMore,loadMore:K.loadMoreMessages,reveal:ot,onLocated:C});let dt=ZO({conversationId:K.conversationId,taskId:ce,messages:q.items,displayOffset:at,viewportRef:Ge,onRevealDisplayIndex:ut});(0,Q.useEffect)(()=>{let e=it.current;if(e==null)return;let t=e-at;if(t>=0&&t<q.items.length){it.current=null,requestAnimationFrame(()=>ot(t));return}if(t<0&&K.hasMore&&!K.loadingMore){K.loadMoreMessages();return}(t>=q.items.length||!K.hasMore)&&(it.current=null)},[q.items.length,ot,K.hasMore,K.loadMoreMessages,K.loadingMore,at]),(0,Q.useEffect)(()=>{ct()},[q.items.length,ct,K.conversationId,at]),(0,Q.useEffect)(()=>()=>{rt.current!=null&&cancelAnimationFrame(rt.current)},[]),(0,Q.useEffect)(()=>{V(null)},[K.conversationId]);let ft=(0,Q.useCallback)(e=>{L.current+=1,V({id:L.current,text:e.prompt})},[]),pt=!!(K.conversationId&&!K.showSessionLoading&&!K.sessionRoutePending&&K.workspaceSource!==`project`&&K.workspaceSource!==`execution_environment`&&q.items.length===0),mt=so(e=>e.setAgentId);(0,Q.useEffect)(()=>{if(ue.hasToken)return mt(me.displayAgentId),()=>mt(``)},[ue.hasToken,me.displayAgentId,mt]);let ht=K.conversationPhase===`creating-session`,gt=K.conversationPhase===`loading-history`;kf(o&&!gt?De:null,o);let _t=ht||gt,vt=gt,yt=!vt&&q.items.length===0&&!p?.length&&!fe.streaming,bt=(0,Q.useMemo)(()=>{if(fe.taskPlan){let e=_O(fe.taskPlan);return e?{plan:e,changeSummary:AO(q.items,fe.streaming)?.changeSummary??null}:null}return AO(q.items,fe.streaming)},[q.items,fe.streaming,fe.taskPlan]),xt=(0,Q.useMemo)(()=>(K.sessionRoutePending&&K.decodedKey?K.decodedKey:K.conversationId)?K.sessionName?.trim()||k.chat.newSession:k.nav.chat,[K.conversationId,K.sessionName,K.sessionRoutePending,K.decodedKey,k.nav.chat,k.chat.newSession]),St=Pe?.sourceNoteId??null,Ct=fD(De,P.get(`projectId`)),wt=K.projectPreparation?.project??Ct,[Tt,Et]=(0,Q.useState)([]),[Dt,Ot]=(0,Q.useState)([]),kt=m(e=>e.baseUrl),At=De?ts(kt,A,De):null,jt=es.store(e=>At?e.drafts[At]:void 0),Mt=(0,Q.useRef)(void 0),[Nt,Pt]=(0,Q.useState)(!1);(0,Q.useLayoutEffect)(()=>{De&&De!==Mt.current&&(Mt.current=void 0)},[De]),(0,Q.useEffect)(()=>{let e=!1;if(te(null),St)return Re(St).then(t=>{e||te(t?.title?.trim()||null)}).catch(()=>{e||te(null)}),()=>{e=!0}},[St]);let Ft=ee||Pe?.sourceNoteTitle||k.chat.sourceNoteFallbackTitle,It=MA({enabled:ue.hasToken&&!!(De||wt)&&!ye&&q.items.length===0&&!K.showSessionLoading&&!K.sessionRoutePending,conversationId:De,suppressProjectContext:!!(St||Oe||K.workspaceSource===`execution_environment`||K.workspaceSource===`session_override`||K.workspaceSource===`agent_workspace`),project:wt,task:le}),Lt=(0,Q.useMemo)(()=>me.chatAgents?.items.find(e=>e.id===me.displayAgentId)??{id:me.displayAgentId},[me.chatAgents?.items,me.displayAgentId]),Rt=(0,Q.useMemo)(()=>js(It.context,k.chat.welcomeSpotlight,{contextStatus:It.status}),[k.chat.welcomeSpotlight,It.context,It.status]),zt=(0,Q.useMemo)(()=>Rt.recommendation?{suggestionId:Rt.recommendation.id,contextKind:Rt.contextKind,prompt:Rt.recommendation.prompt}:null,[Rt]),Bt=(0,Q.useRef)(0);(0,Q.useEffect)(()=>(Bt.current++,()=>{Bt.current++}),[i,A]);let Vt=(0,Q.useCallback)((...t)=>{let n=()=>{let[e,n,r,i,a]=t;if(jt&&(he||e.trim().startsWith(`/`)))return Nn.getState().setShellError(k.chat.pageContext.pending),!1;if(he)return fe.replaceLatestUserTurn(he.turnId,e,n,r,i);let o=!1,s=fe.sendMessage(e,n,r,i,void 0,jt?.envelope,(e,t)=>{o=!0,Ze(t??e),a?.onDispatched?.({clientSubmissionId:e,messageRenderKey:t})});return o?(At&&jt&&es.remove(At,jt),!0):s};if(!e)return n();let r=Bt.current;return e().then(e=>e&&r===Bt.current?n():!1)},[e,he,fe.replaceLatestUserTurn,fe.sendMessage,jt,At,k.chat.pageContext.pending,Ze]),Ht=dD({preparation:K.projectPreparation,conversationId:De,ready:K.modelConfigReady&&!_t,onSend:Vt}),Ut=(0,Q.useCallback)(e=>{if(!e.turnId||!K.conversationId)return;let t=bn.getGeneration(K.conversationId),n=bn.getResumeRunId(K.conversationId);pe.beginEditTurn(e.turnId,{text:e.userTurnDocument?Mn(e.userTurnDocument):Rn(e.content),attachments:Ln(e.attachments)??[],contextRefs:e.contextRefs?.flatMap(e=>e.kind===`mcp_resource`?[]:[{refId:e.refId,kind:e.kind,sourceId:e.sourceId,expectedVersion:e.version,title:e.title,fileKind:e.fileKind}])??[]}).then(e=>{e&&fe.settleStoppedRun(t,n)})},[pe.beginEditTurn,fe.settleStoppedRun,K.conversationId]),Wt=(0,Q.useCallback)(e=>{if(pe.composerMode.kind===`editFollowUp`)pe.beginEditFollowUp(pe.composerMode.inputId);else if(pe.composerMode.kind===`editTurn`&&K.conversationId){let t=bn.getGeneration(K.conversationId),n=bn.getResumeRunId(K.conversationId);pe.beginEditTurn(pe.composerMode.turnId,e).then(e=>{e&&fe.settleStoppedRun(t,n)})}},[pe.composerMode,pe.beginEditFollowUp,pe.beginEditTurn,K.conversationId,fe.settleStoppedRun]),Gt=pe.cancelEditor;(0,Q.useEffect)(()=>{if(!Ce||!Se.trim()&&!Ee||!ue.hasToken||K.showSessionLoading||K.sessionRoutePending||!K.conversationId||fe.sending||fe.streaming)return;let e=Jr(be,Se),t=Ee?ki(Ee):void 0;if(!e&&!t?.length)return;let n=`${K.conversationId}:auto-send:${e??``}:${Ee??``}`;if(I.current===n)return;I.current=n;let r=new URLSearchParams(P);r.delete(`skill`),r.delete(`slash`),r.delete(`draft`),r.delete(`autoSend`),r.delete(`attachmentsHandoff`);let i=r.toString();j({pathname:N,search:i?`?${i}`:``},{replace:!0}),Vt(e??``,t??void 0)},[ue.hasToken,Ce,Ee,Se,Vt,j,N,P,K.conversationId,K.sessionRoutePending,K.showSessionLoading,be,fe.sending,fe.streaming]);let Kt=(0,Q.useCallback)(()=>{R.current?.reject(),R.current=null,re(null),ae(!1)},[]);(0,Q.useEffect)(()=>{Kt()},[Kt,St]);let Jt=(0,Q.useMemo)(()=>({title:k.chat.timelineTitle,turn:k.chat.timelineTurn,messageFallback:k.chat.timelineMessageFallback,toolCount_one:k.chat.timelineToolCount_one,toolCount_other:k.chat.timelineToolCount_other,searchedWeb:k.chat.stepSearchedWeb,searchedMemory:k.chat.stepSearchedMemory,searchedCode:k.chat.stepSearchedCode,searched:k.chat.stepSearched,readFile:k.chat.stepReadFile,runCommand:k.chat.stepRunCommand,listDirectory:k.chat.stepListDirectory,writeFile:k.chat.stepWriteFile,editFile:k.chat.stepEditFile,openUrl:k.chat.stepOpenUrl,fetchUrl:k.chat.stepFetchUrl,unknownTool:k.chat.stepUnknownTool}),[k.chat.timelineTitle,k.chat.timelineTurn,k.chat.timelineMessageFallback,k.chat.timelineToolCount_one,k.chat.timelineToolCount_other,k.chat.stepSearchedWeb,k.chat.stepSearchedMemory,k.chat.stepSearchedCode,k.chat.stepSearched,k.chat.stepReadFile,k.chat.stepRunCommand,k.chat.stepListDirectory,k.chat.stepWriteFile,k.chat.stepEditFile,k.chat.stepOpenUrl,k.chat.stepFetchUrl,k.chat.stepUnknownTool]),Yt=(0,Q.useCallback)(async e=>{if(!St)return;R.current?.reject(),ae(!1);let t=k.chat.sourceNoteAppendSourceLine.replace(`{{time}}`,new Date().toLocaleString(O));return re({heading:k.chat.sourceNoteAppendHeading,content:`${t}\n\n${e.trim()}`}),new Promise((e,t)=>{R.current={sourceNoteId:St,resolve:e,reject:t}})},[O,k.chat.sourceNoteAppendHeading,k.chat.sourceNoteAppendSourceLine,St]),Xt=`${M.pathname}${M.search}`,Zt=(0,Q.useCallback)(async e=>{try{let t=await He(e.trim(),`web`);ya(`success`,k.chat.messageSavedToNote,void 0,{href:tt(Xt,t.id)})}catch(e){throw ya(`error`,e instanceof Error?e.message:k.notes.quickCaptureFailed),e}},[Xt,k.chat.messageSavedToNote,k.notes.quickCaptureFailed]),Qt=(0,Q.useCallback)(async()=>{let e=R.current;if(!e||!ne)return;let t=ne.heading.trim()||k.chat.sourceNoteAppendHeading,n=ne.content.trim();if(n){ae(!0),se(null);try{await Ve(e.sourceNoteId,n,t),window.dispatchEvent(new CustomEvent(`note-updated`,{detail:{noteId:e.sourceNoteId,source:`chat`,conversationId:De}})),e.resolve(),R.current=null,re(null)}catch(e){se(e instanceof Error?e.message:k.chat.sourceNoteSaveFailed)}finally{ae(!1)}}},[De,k.chat.sourceNoteAppendHeading,k.chat.sourceNoteSaveFailed,k.chat.sourceNoteSaveSuccess,ne]),$t=(0,Q.useCallback)(async e=>{if(!St)return;let t=e.trim().split(/\n+/)[0]?.replace(/^[-#*>\s]+/,``).trim()||k.chat.sourceNoteTaskFallbackTitle;try{await Be(t.slice(0,120),{sourceNoteId:St,sourceConversationId:De})}catch(e){throw ya(`error`,e instanceof Error?e.message:k.chat.sourceNoteTaskFailed),e}},[De,k.chat.sourceNoteTaskFailed,k.chat.sourceNoteTaskFallbackTitle,k.chat.sourceNoteTaskSuccess,St]),en=(0,Q.useCallback)(async()=>{if(!St)return;let t=Bt.current;if(e&&(!await e()||t!==Bt.current))return;let n=k.chat.sourceNoteDigestPrompt.replace(`{{title}}`,Ft);if(fe.streaming||fe.sending){pe.addPendingFollowUp(n),va({tone:`info`,status:`done`,title:k.chat.sourceNoteDigestQueued,source:O===`zh`?`笔记整理`:`Note digest`,dedupeKey:St?`note-digest:${St}`:void 0});return}fe.sendMessage(n)},[e,pe,O,k.chat.sourceNoteDigestPrompt,k.chat.sourceNoteDigestQueued,St,Ft,fe]),tn=(0,Q.useCallback)(async e=>{if(!(Nt||Ht.busy)){if(K.projectPreparation){j(Xr(e),{state:{forceNewChat:!0,agentId:me.displayAgentId,temporary:K.userContextMode===`temporary`}});return}if(!(Mt.current!==void 0||fe.sending||fe.streaming||_t)){Mt.current=De,Pt(!0);try{e?j(Xr(e),{state:{forceNewChat:!0,agentId:me.displayAgentId,temporary:K.userContextMode===`temporary`}}):await K.createNewSession({forceNew:!0,projectId:e,temporary:K.userContextMode===`temporary`})}catch(e){Mt.current=void 0,ya(`error`,k.chat.composerContext.changeFailed,{error:e instanceof Error?e.message:String(e)})}finally{Pt(!1)}}}},[De,_t,k.chat.composerContext.changeFailed,Nt,Ht.busy,K.createNewSession,K.projectPreparation,K.userContextMode,fe.sending,fe.streaming,j,me.displayAgentId]),nn=(0,Q.useCallback)(()=>tn(null),[tn]),rn=(0,Q.useCallback)(async e=>{if(!(Nt||_t||fe.sending||fe.streaming||!pt)){Pt(!0);try{await K.onSessionWorkingDirectoryChange(e)}finally{Pt(!1)}}},[Nt,_t,fe.sending,fe.streaming,pt,K.onSessionWorkingDirectoryChange]),an=(0,Q.useMemo)(()=>({project:wt,draftRefs:Tt,draftAttachments:Dt,draftPage:jt?{id:`${jt.envelope.tabId}:${jt.envelope.sequence}`,title:jt.title||(O===`zh`?`当前页面`:`Current page`)}:void 0,onLeaveProject:Nt||Ht.busy?void 0:nn,leaveProjectLabel:k.chat.scopeRemoveProject,onDraftSourceNote:St?en:void 0,draftSourceNoteLabel:k.chat.sourceNoteDigestAction}),[Nt,Ht.busy,wt,Tt,Dt,jt,O,nn,k.chat.scopeRemoveProject,St,en,k.chat.sourceNoteDigestAction]);return ue.hasToken?(fe.error?Bn(fe.error):null)?.code===`session_not_found`?(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col overflow-hidden bg-surface-panel`,children:[(0,Z.jsx)(aO,{}),(0,Z.jsx)(XD,{chatHeadline:k.chat.sessionNotFoundTitle,chatAgents:me.chatAgents?.items??[],showChatAgentSelector:!1,chatAgentId:me.displayAgentId,onChatAgentChange:me.onChatAgentChange,chatAgentDisabled:!0}),(0,Z.jsx)(`main`,{className:`mx-auto flex w-full max-w-xl flex-1 items-center px-4 py-12 sm:px-6`,children:(0,Z.jsx)(`div`,{className:`w-full`,children:(0,Z.jsx)(oh,{errorText:fe.error})})})]}):(0,Z.jsx)(V_,{value:Fe,children:(0,Z.jsxs)(`div`,{className:Y(`flex h-full min-h-0 flex-1 flex-col bg-surface-panel`,f?`overflow-clip`:`overflow-hidden`),children:[(0,Z.jsx)(aO,{}),!r||f?(0,Z.jsx)(XD,{inline:f,chatHeadline:_e&&q.items.length===0?k.skills.findTitle:xt,chatAgents:me.chatAgents?.items??[],showChatAgentSelector:!f&&!ye&&me.showChatAgentSelector,chatAgentId:me.displayAgentId,onChatAgentChange:me.onChatAgentChange,chatAgentDisabled:Ht.busy||Nt||_t&&!K.projectPreparation,conversationId:K.conversationId,hasMessages:!_t&&q.items.length>0,workspacePath:K.effectiveWorkspacePath,userContextMode:K.userContextMode,projectId:wt?.id,context:an,canChangeWorkspace:!1,workspaceDisabled:_t||fe.sending||fe.streaming,onWorkspaceChange:K.onSessionWorkingDirectoryChange,prepareTerminalSession:K.projectPreparation?Ht.prepareSession:void 0,terminalDisabled:!!(K.projectPreparation&&(Ht.busy||!Ht.allowed||Ht.checking)),showContextControls:!ye,onFindOpen:dt.show}):null,(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 w-full flex-1 flex-col`,children:[!r&&Pe?.parentConversationId?(0,Z.jsxs)(`div`,{className:`shrink-0 border-b border-edge-subtle bg-surface-panel/80 px-3 py-2 text-xs text-fg-muted sm:px-5 xl:px-6`,children:[(0,Z.jsx)(u,{to:`/chat/${encodeURIComponent(Pe.parentConversationId)}`,className:`font-medium text-accent transition-colors hover:text-accent-fg`,children:k.chat.forkedFromConversation.replace(`{{name}}`,Pe.forkedFromSessionName||k.chat.forkedFromConversationFallback)}),(0,Z.jsx)(`span`,{className:`ms-2`,children:k.chat.forkSharedWorkspaceNotice})]}):null,M.state?.fromAgentEditor&&me.displayAgentId?(0,Z.jsx)(`div`,{className:`shrink-0 border-b border-edge-subtle bg-surface-panel/80 px-3 py-1.5 sm:px-5 xl:px-6`,children:(0,Z.jsxs)(u,{to:Ko(me.displayAgentId),className:`inline-flex items-center gap-1 text-xs font-medium text-accent transition-colors hover:text-accent-fg`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`←`}),k.agentsSettings.backToEditor]})}):null,r&&St&&!n?(0,Z.jsx)(`div`,{className:`shrink-0 border-b border-edge-subtle bg-surface-panel/80 px-3 py-1.5 sm:px-5 xl:px-6`,children:(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:k.chat.sourceNoteBanner.replace(`{{title}}`,Ft)}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex h-7 items-center gap-1.5 rounded-md border border-edge-subtle px-2 font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,onClick:en,children:[(0,Z.jsx)(Te,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:k.chat.sourceNoteDigestAction})]}),(0,Z.jsx)(u,{to:tt(`${M.pathname}${M.search}`,St),className:`font-medium text-accent transition-colors hover:text-accent-fg`,children:k.chat.sourceNoteOpen})]})]})}):null,(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(PO,{open:dt.open,query:dt.query,activeIndex:dt.activeIndex,resultCount:dt.resultCount,searching:dt.searching,truncated:dt.truncated,limitedToLoaded:dt.limitedToLoaded,inputRef:dt.inputRef,labels:k.chat.find,onQueryChange:dt.setQuery,onPrevious:dt.previous,onNext:dt.next,onClose:dt.close}),!r||f?(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 left-1/2 z-20 hidden w-full max-w-[calc(var(--max-width-chat-frame)+8rem)] -translate-x-1/2 xl:block`,children:(0,Z.jsx)(`div`,{className:`pointer-events-auto absolute inset-y-0 right-0`,children:(0,Z.jsx)(kA,{items:de.items,activeMessageIndex:et+at,labels:Jt,onSelectMessage:ut})})}):null,(0,Z.jsx)(`div`,{ref:Ge,"data-chat-scroll-viewport":!0,className:Y(`chat-messages chat-messages--wide-viewport relative min-h-0 flex-1 overflow-y-auto overflow-x-hidden [overflow-anchor:none] [scrollbar-gutter:stable_both-edges]`,yt?`chat-messages--compact-welcome pt-5 pb-2`:`py-4`),onScroll:lt,"data-chat-find-open":dt.open?``:void 0,children:(0,Z.jsx)(`div`,{className:r&&!o?`px-3`:`px-3 sm:px-5 xl:px-6`,children:(0,Z.jsx)(`div`,{"data-chat-message-frame":!0,className:Y(`mx-auto w-full min-w-0`,(!r||o||f)&&`max-w-[var(--max-width-chat-frame)]`),children:gt?(0,Z.jsxs)(`div`,{className:`flex min-h-[min(40vh,20rem)] w-full flex-col gap-10 py-8`,"aria-busy":`true`,children:[(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(qt,{className:`h-11 w-[min(70%,22rem)] rounded-2xl`})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(qt,{className:`h-4 w-24`}),(0,Z.jsx)(qt,{className:`h-4 w-[min(82%,36rem)]`}),(0,Z.jsx)(qt,{className:`h-4 w-[min(74%,32rem)]`}),(0,Z.jsx)(qt,{className:`h-4 w-[min(48%,22rem)]`})]}),(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(qt,{className:`h-11 w-[min(62%,18rem)] rounded-2xl`})})]}):(0,Z.jsxs)(Z.Fragment,{children:[K.loadingMore?(0,Z.jsx)(`div`,{className:`mb-3 text-center text-xs text-fg-muted`,children:k.chat.loadOlder}):null,fe.error?(0,Z.jsx)(`div`,{className:Y(`sticky z-20 shrink-0 bg-transparent pe-2`,yt?`-top-5`:`-top-4`),children:(0,Z.jsx)(oh,{errorText:fe.error})}):null,Fe&&!f&&De?(0,Z.jsx)(Io,{conversationId:De,language:O,running:fe.streaming||fe.sending}):null,Fe&&!f&&q.items.length>0?(0,Z.jsx)(u,{className:`mb-4 inline-block rounded-md px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover`,to:`/automations`,children:O===`zh`?`← 定时任务`:`← Scheduled tasks`}):null,!r&&ce?(0,Z.jsx)(`div`,{className:`hidden md:block`,children:(0,Z.jsx)(lc,{taskId:ce})}):null,null,null,!r&&De?(0,Z.jsx)(B,{eventType:`session.transcript.updated`,source:`sessions`,payloadKey:`conversationId`,payloadValue:De,className:`mb-6`}):null,(0,Z.jsx)(ZC,{scrollRef:Ge,messages:q.items,timelineEntries:p,personal:o,authToken:A??void 0,conversationId:K.decodedKey??K.conversationId,projectId:wt?.id,streaming:fe.streaming,sending:fe.sending,progress:fe.progress,reasoningLevel:K.reasoningLevel,showAssistantWorkLog:!0,registerListContentRef:Je,replySpaceRef:Xe,onPickWelcomePrompt:ft,welcomeSpotlight:Rt,welcomeOverlay:o&&s?(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col items-start gap-3 px-4 py-8 text-fg`,children:[(0,Z.jsx)(`div`,{className:`flex size-16 items-center justify-center rounded-3xl bg-accent/10 text-3xl text-accent`,"aria-hidden":!0,children:s.avatar??`✦`}),(0,Z.jsx)(`h2`,{className:`text-2xl font-semibold`,children:O===`zh`?`你好${s.addressAs?`,${s.addressAs}`:``}。我们从哪里开始?`:`Hello${s.addressAs?`, ${s.addressAs}`:``}. Where should we start?`}),(0,Z.jsx)(`p`,{className:`max-w-xl text-sm leading-relaxed text-fg-muted`,children:s.opening??(O===`zh`?`想讨论问题、整理思路或推进工作,都可以直接说。`:`Bring a question, an idea, or work to move forward.`)})]}):Fe?(0,Z.jsxs)(`div`,{className:`mx-auto max-w-xl px-4 py-10 text-center`,children:[(0,Z.jsx)(`h2`,{className:`text-xl font-semibold text-fg`,children:Ie?O===`zh`?`想怎么调整这个任务?`:`What would you like to change?`:O===`zh`?`你想安排什么任务?`:`What would you like to schedule?`}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:Ie?O===`zh`?`直接说要改的内容、时间,或告诉我暂停、恢复。`:`Change what it does or when it runs, or ask to pause or resume.`:O===`zh`?`说说要做的事,时间和细节我们一起确定。`:`Tell us what to do. We’ll work out the timing and details together.`}),f?null:(0,Z.jsx)(u,{className:`mt-4 inline-block text-xs text-fg-muted hover:text-fg`,to:`/automations`,children:O===`zh`?`← 返回定时任务`:`← Back to scheduled tasks`})]}):ye?(0,Z.jsx)(PA,{agentName:Lt.name?.trim()||me.displayAgentId,messages:k.agentsSettings,disabled:K.sessionRoutePending||K.showSessionLoading,onPick:e=>{L.current+=1,V({id:L.current,text:e})}}):_e?(0,Z.jsx)(zw,{sk:k.skills,disabled:K.sessionRoutePending||K.showSessionLoading,onPick:e=>{L.current+=1,V({id:L.current,text:Jr(`find-skills`,e)})}}):void 0,compactWelcome:r,onDeleteRound:ce?void 0:fe.deleteMessageRound,onRetryUserMessageRound:ce?void 0:fe.retryUserMessageRound,deleteRoundDisabled:fe.streaming||fe.sending,onEditUserMessage:ce?void 0:Ut,editLatestUserOnly:!0,editRequiresTurnId:!0,onSaveAssistantAsNote:Zt,onSaveAssistantToSourceNote:St?Yt:void 0,onExtractAssistantTask:St?$t:void 0,onForkAssistantTurn:!ce&&Pe?.sessionType===`chat`?Le:void 0,trailingContent:Ue?(0,Z.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl rounded-2xl border border-edge-subtle bg-surface-panel px-4 py-3 text-sm`,children:[(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:O===`zh`?`这个回答合适吗?点选后可以在输入框修改,再发给我。`:`Did that response work for you? Pick an adjustment, edit it, then send.`}),(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[[[O===`zh`?`再短一点`:`Make it shorter`,O===`zh`?`这次回答再短一点。`:`Please make this answer shorter.`],[O===`zh`?`更温和一点`:`A little gentler`,O===`zh`?`这次回答的语气更温和一点。`:`Please make this answer a little gentler.`]].map(([e,t])=>(0,Z.jsx)(`button`,{type:`button`,onClick:()=>We(t),className:`rounded-full border border-edge px-3 py-1.5 text-xs text-fg transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:e},e)),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>We(),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:O===`zh`?`这样就好`:`Looks good`})]})]}):null},De)]})})})}),(0,Z.jsx)(`div`,{ref:Ke,className:Y(`chat-composer-dock pointer-events-none absolute inset-x-0 bottom-0 z-10`,o?`[--chat-composer-bottom-radius:1.65rem]`:`[--chat-composer-bottom-radius:1rem]`,yt?`[--chat-composer-bottom-space:max(0.625rem,env(safe-area-inset-bottom))]`:`[--chat-composer-bottom-space:max(0.5rem,env(safe-area-inset-bottom))] sm:[--chat-composer-bottom-space:max(1rem,env(safe-area-inset-bottom))]`),children:(0,Z.jsx)(`div`,{className:r&&!o?`px-3`:`px-3 sm:px-5 xl:px-6`,children:(0,Z.jsxs)(`div`,{"data-chat-composer-frame":!0,"data-primary-chat-composer":!r||void 0,className:Y(`pointer-events-auto relative mx-auto w-full min-w-0 pb-[var(--chat-composer-bottom-space)]`,(!r||o||f)&&`max-w-[calc(var(--max-width-chat-frame)+14px)]`,yt?`pt-2.5`:`pt-2 sm:pt-4`),children:[(0,Z.jsx)(tw,{visible:!K.showSessionLoading&&!qe,onClick:()=>Ye(!0),running:fe.streaming||fe.sending}),(0,Z.jsx)(`div`,{className:`absolute bottom-full right-0 z-20 mb-2 flex items-center rounded-full border border-edge-subtle bg-surface-overlay p-1 shadow-elevated backdrop-blur-sm empty:hidden xl:hidden`,children:!r||f?(0,Z.jsx)(SA,{items:de.items,activeMessageIndex:et+at,labels:Jt,openLabel:k.chat.timelineOpen,closeLabel:k.chat.timelineClose,currentLabel:k.chat.timelineCurrent,onSelectMessage:ut}):null}),(0,Z.jsx)(ff,{prompt:J.clarifyPrompt,submitting:J.clarifySubmitting,submitError:J.clarifySubmitError,labels:k.chat,onSubmit:J.submitClarifyAnswer,onAgentDecide:J.letAgentDecideClarification,onCancel:J.cancelClarification}),bt?(0,Z.jsx)(pO,{plan:bt.plan,changeSummary:bt.changeSummary,isStreaming:fe.streaming,labels:{heading:k.chat.planHeading,stepProgress:k.chat.planStepProgress,completedProgress:k.chat.planCompletedProgress,finished:k.chat.planFinished,ended:k.chat.planEnded,planned:k.chat.planPlanned,filesChangedOne:k.chat.planFilesChanged_one,filesChangedOther:k.chat.planFilesChanged_other}}):null,_e&&q.items.length>0?(0,Z.jsx)(`div`,{className:`mb-2 text-right`,children:(0,Z.jsx)(u,{to:`/capabilities/skills`,className:`text-xs text-accent-fg hover:underline`,children:k.skills.findBack})}):null,(0,Z.jsx)(Nw,{}),(0,Z.jsx)(Lw,{conversationId:K.conversationId,active:fe.streaming||fe.sending}),(0,Z.jsx)(aD,{personal:o,nextTurnSuggestionsEnabled:!fe.streaming,onPersonalSendDispatched:o?$e:void 0,placeholder:o?fe.streaming||fe.sending?O===`zh`?`继续聊,或补充要求…`:`Keep talking or add a detail…`:O===`zh`?`发消息给「${s?.name||`Personal AI`}」…`:`Message ${s?.name||`Personal AI`}…`:ye?k.agentsSettings.setupComposerPlaceholder:_e?k.skills.findPlaceholder:void 0,composerContext:!ye&&!r&&!ce&&!he&&!vt&&q.items.length===0?{project:wt,disabled:Nt||Ht.busy||_t&&!K.projectPreparation,environmentPicker:K.projectPreparation?(0,Z.jsx)(lD,{selection:Ht}):void 0,workspacePath:K.effectiveWorkspacePath,canChangeWorkspace:pt,onProjectChange:tn,onWorkspaceChange:rn}:void 0,contextRefs:Tt,pageContextPreview:jt&&At?(0,Z.jsx)(oD,{draft:jt,disabled:fe.sending,waiting:fe.streaming,onRemove:()=>es.remove(At,jt)}):void 0,setContextRefs:Et,onDraftAttachmentsChange:Ot,disabled:g||gt||Ht.busy||Nt,sendDisabled:pe.controlPending||pe.control.phase===`stopping`||g||!K.modelConfigReady||!K.projectPreparation&&_t||!!(K.projectPreparation&&!Ht.allowed)||K.modelConfigSaving||Ht.busy||Nt,sending:fe.sending,streaming:fe.streaming,conversationId:K.conversationId,unboundDraftKey:K.conversationId?void 0:JSON.stringify([N,P.get(`projectId`)]),getDraftHandoffTarget:Ht.getDraftHandoffTarget,prepareContextSession:K.projectPreparation?Ht.prepareSession:void 0,welcomeDraftSeed:H??z,welcomeSuggestion:!_e&&yt?zt:null,onAcceptWelcomeSuggestion:ft,thinkingLevel:K.thinkingLevel,modelSupportsThinking:K.modelSupportsThinking,onThinkingChange:K.onSessionThinkingLevelChange,onSend:Ht.send,composerMode:pe.composerMode,onRestoreEditor:pe.restoreEditor,onReacquireEdit:Wt,inputControl:pe.control,onResumeQueue:()=>void pe.resumeQueue().catch(()=>{}),editingUserTurnId:he?.turnId,onCancelUserMessageEdit:Gt,onAbort:()=>void fe.abort().catch(()=>{}),onAddPendingFollowUp:async(t,n,r,i,a)=>{let o=Bt.current;if(e&&(!await e()||o!==Bt.current))throw Error(O===`zh`?`请先保存笔记,再发送消息。`:`Save the note before sending.`);await pe.addPendingFollowUp(t,n,r,jt?.envelope,i,a),At&&jt&&es.remove(At,jt)},onSteeringInterrupt:jt?void 0:async(t,n,r)=>{let i=Bt.current;return e&&(!await e()||i!==Bt.current)?!1:fe.interruptAndSend(t,n,void 0,r)},pendingFollowUps:pe.pendingFollowUps,editingFollowUpId:pe.editingFollowUpId,onBeginEditFollowUp:pe.beginEditFollowUp,onCancelEditFollowUp:pe.cancelEditFollowUp,onCommitEditFollowUp:(e,t,n,r,i)=>pe.commitEditFollowUp(e,t,n,r,i),onPendingFollowUpRemove:pe.removePendingFollowUp,onPendingFollowUpMove:pe.movePendingFollowUp,onPendingFollowUpReorder:pe.reorderPendingFollowUp,onPendingFollowUpSteer:e=>void pe.steerPendingFollowUp(e).catch(()=>{}),onPendingFollowUpSend:e=>void pe.sendQueuedInput(e).catch(()=>{}),steeringFollowUpId:pe.steeringFollowUpId,sessionModel:K.sessionModel,showModelSelector:!o,onModelChange:K.onSessionModelChange,modelDisabled:_t&&!K.projectPreparation||Ht.busy||K.modelConfigSaving,onChatAgentChange:!o&&!ye&&!ce&&me.showChatAgentSelector?me.onChatAgentChange:void 0,currentAgentId:me.displayAgentId,voiceAgentName:o&&s?s.name:Lt.name,voiceTaskId:ce??void 0,prepareVoiceSession:K.projectPreparation?Ht.prepareSession:void 0})]})})})]})]}),(!r||f)&&De&&window.electronAPI?.terminal?(0,Z.jsx)(Q.Suspense,{fallback:null,children:(0,Z.jsx)(IA,{conversationId:De},De)}):null,(0,Z.jsx)(D,{open:ne!==null,onOpenChange:e=>{!e&&!ie&&Kt()},children:(0,Z.jsxs)(w,{children:[(0,Z.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[1px]`}),(0,Z.jsxs)(T,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(82vh,42rem)] w-[min(100%-2rem,44rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:[(0,Z.jsxs)(`div`,{className:`shrink-0 border-b border-edge-subtle px-5 py-4`,children:[(0,Z.jsx)(E,{className:`text-base font-semibold text-fg`,children:k.chat.sourceNoteSaveDialogTitle}),(0,Z.jsx)(S,{className:`mt-1 text-sm text-fg-muted`,children:k.chat.sourceNoteSaveDialogDescription.replace(`{{title}}`,Ft)})]}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-5 py-4`,children:[oe?(0,Z.jsxs)(`p`,{className:`rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-sm text-danger`,role:`alert`,children:[k.chat.sourceNoteSaveFailed,`: `,oe]}):null,(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium text-fg`,children:[(0,Z.jsx)(`span`,{children:k.chat.sourceNoteSaveDialogHeadingLabel}),(0,Z.jsx)(`input`,{value:ne?.heading??``,onChange:e=>re(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:ie})]}),(0,Z.jsxs)(`label`,{className:`flex min-h-0 flex-1 flex-col gap-1.5 text-sm font-medium text-fg`,children:[(0,Z.jsx)(`span`,{children:k.chat.sourceNoteSaveDialogContentLabel}),(0,Z.jsx)(`textarea`,{value:ne?.content??``,onChange:e=>re(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:ie})]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:[(0,Z.jsx)(pi,{type:`button`,variant:`secondary`,onClick:Kt,disabled:ie,children:k.chat.sourceNoteSaveDialogCancel}),(0,Z.jsx)(pi,{type:`button`,variant:`primary`,onClick:()=>void Qt(),disabled:ie||!ne?.content.trim(),children:ie?k.chat.sourceNoteSaveDialogSaving:k.chat.sourceNoteSaveDialogConfirm})]})]})]})})]})}):(0,Z.jsx)(`div`,{className:`mx-auto w-full max-w-[var(--max-width-chat-frame)] px-3 py-16 text-center text-sm leading-relaxed text-fg-muted sm:px-5`,children:k.chat.needToken})}export{Qs as $,If as A,ff as B,$f as C,as as Ct,zf as D,Rf as E,Cf as F,sc as G,lc as H,Ef as I,Gs as J,nc as K,_f as L,Of as M,kf as N,Lf as O,Df as P,ac as Q,vf as R,Xf as S,os as St,Bf as T,cc as U,cf as V,oc as W,rc as X,Ks as Y,ic as Z,rm as _,ds as _t,Ew as a,Cs as at,Xp as b,cs as bt,lw as c,bs as ct,dw as d,_s as dt,Us as et,sw as f,gs as ft,nm as g,fs as gt,tm as h,ps as ht,Pw as i,ws as it,Pf as j,Vf as k,pw as l,ys as lt,ZC as m,ms as mt,FA as n,zs as nt,Sw as o,Ss as ot,tw as p,hs as pt,Ws as q,Mw as r,Ts as rt,xw as s,xs as st,LA as t,Ls as tt,fw as u,vs as ut,$p as v,us as vt,Uf as w,Wp as x,ss as xt,Zp as y,ls as yt,mf as z};