@xopcai/xopc 0.0.462 → 0.0.464
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.
- package/dist/browser-ext/_locales/en/messages.json +1 -0
- package/dist/browser-ext/_locales/zh_CN/messages.json +1 -0
- package/dist/browser-ext/dist/assets/{auth-CQmxIyWw.js → auth-YPMDpWOW.js} +32 -1
- package/dist/browser-ext/dist/background.js +24 -19
- package/dist/browser-ext/dist/sidepanel.html +1 -1
- package/dist/browser-ext/dist/sidepanel.js +12 -7
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-CQHh48Zf.js → activity-store-B9heFbtJ.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CAz-Ke6Q.js → agent-avatar-dicebear-nzhB7Xjk.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-display-loBdGw_i.js → agent-avatar-display-DBzgoHMD.js} +2 -2
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-By2Q-6JS.js → agent-defaults-settings-panel-BJrNV93g.js} +1 -1
- package/dist/gateway/static/root/assets/agent-plugin-dialog-DLbTHALG.js +1 -0
- package/dist/gateway/static/root/assets/agents-C2xG8f56.js +77 -0
- package/dist/gateway/static/root/assets/{agents-admin-api-D0N09mqJ.js → agents-admin-api-CqQbYIiY.js} +1 -1
- package/dist/gateway/static/root/assets/{api-B1J5ajiP.js → api-8tNOT72p.js} +1 -1
- package/dist/gateway/static/root/assets/{api-B4FJ51EC.js → api-BGodd--L.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-BHlUDZOG.js → app-management-settings-panel-Q7apF7KE.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-Du5JLyV1.js → appearance-settings-ClVZeUmo.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-QLOYw2QR.js → apps-page-BsJJwpKj.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-BAvglLfu.js → archive-plugin-Bl_M0WJp.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-api-DxBmyzp0.js → automation-api-BOnIc_vw.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-result-state-CAsqgMNR.js → automation-result-state-BwDSJs05.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-run-list-BmYeWB_N.js → automation-run-list-CqlIq4BG.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-task-card-CJbIHRxN.js → automation-task-card-D3WXVKRs.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-DpKnqajR.js → automations-page-Bimqx5Pc.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-2SOvmw-f.js +9 -0
- package/dist/gateway/static/root/assets/{binary-plugins-D2bFqG6K.js → binary-plugins-DDNKe1Io.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-DrZyRQQ0.js → block-editor-BQ3amsRP.js} +5 -5
- package/dist/gateway/static/root/assets/{browser-settings-page-CGcgZOWh.js → browser-settings-page-CHf1_RVl.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-hSb-qEgL.js → capabilities-C5oWMC-Z.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-Dr-vvMez.js → capabilities-Cj8vl1ZY.js} +1 -1
- package/dist/gateway/static/root/assets/capabilities-page-rTjkjo71.js +2 -0
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-B08mjrGB.js → capabilities-settings-panel-k5CcwhXN.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-B--IHNs4.js → channels-DvB2fwPI.js} +1 -1
- package/dist/gateway/static/root/assets/chat-agents-api-C3JChTsh.js +1 -0
- package/dist/gateway/static/root/assets/{chat-chart-block-ClCZyIi0.js → chat-chart-block-DrtmYOIo.js} +1 -1
- package/dist/gateway/static/root/assets/chat-page-qnsMsF_s.js +71 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-eneTvxV3.js → chat-terminal-dock-B0D220I-.js} +1 -1
- package/dist/gateway/static/root/assets/{command-palette-api-CP0F6sIm.js → command-palette-api-CkJ6_Yf3.js} +1 -1
- package/dist/gateway/static/root/assets/composer-handoff-params-GKGdXjMZ.js +1 -0
- package/dist/gateway/static/root/assets/{composer-model-config-control-DAagrRx_.js → composer-model-config-control-DQCOWHzJ.js} +1 -1
- package/dist/gateway/static/root/assets/{composer-notifications-CqV6Xj-H.js → composer-notifications-D__OU_xx.js} +1 -1
- package/dist/gateway/static/root/assets/{composer-payload-handoff-Dc43dgSg.js → composer-payload-handoff-BBTbJ1bO.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-f-vcEpeF.js → computer-settings-page-DGRUCkOt.js} +1 -1
- package/dist/gateway/static/root/assets/{connected-providers-grid-CZ-FXxaW.js → connected-providers-grid-BoDipD2g.js} +1 -1
- package/dist/gateway/static/root/assets/{connection-usage-guide-Cibh2lrV.js → connection-usage-guide-B1VUqibv.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-Btz68iy8.js → connector-service-page-bwQ1PekA.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-api-CTuVWwBf.js → connectors-api-BvYGL65q.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-Bs29RvXz.js → connectors-page-BX6Jt6w5.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-XnE3iFhG.js → date-picker-ClRDaNBJ.js} +1 -1
- package/dist/gateway/static/root/assets/{date-time-picker-VGKm0HVn.js → date-time-picker-CA6H47M6.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-CBm3DySQ.js → desktop-pet-Bi8Hgf-x.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-6O77QXGo.js → desktop-pet-settings-CQ6qE8lf.js} +1 -1
- package/dist/gateway/static/root/assets/{dev-view-store-B8fGILny.js → dev-view-store-UCqQeWa2.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-qtUvtdDT.js → device-pairing-wizard-gC-XZxt2.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-ByDqf5fE.js → directory-picker-path-field-Y8snl5Xl.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-authoritative-grants-BfL8dMBf.js → extension-authoritative-grants-D2abOXTl.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-Bn_5xu_M.js → extension-debug-page-OOlRCInL.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-iframe-host-Vs6USa0c.js → extension-iframe-host-D_WXBf6a.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-marketplace-api-BIzkukYp.js → extension-marketplace-api-Bmtm6-L1.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-message-router-GIekDj_w.js → extension-message-router-xqjjSxcp.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-C_3bIjSB.js → extension-page-bpQnyNz-.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-provider-D-LolObs.js → extension-provider-l7SvHEK1.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-BV51dk16.js → extension-settings-page-DKAJE4h9.js} +1 -1
- package/dist/gateway/static/root/assets/{file-preview-surface-i5UOFnQF.js → file-preview-surface-B-r2ZnCV.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-1Rk0LeEM.js → gateway-config-swr-DOwezeL2.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-realtime-DIs1pjkQ.js → gateway-realtime-Br7dErHY.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-OaEqjNTb.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-restart-DTmlcJps.js → gateway-restart-B3Xro3qd.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-ClcCloqQ.js → gateway-settings-DCnP-HPj.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-D6WPS0RW.js → gateway-startup-retry-vteSIhYI.js} +1 -1
- package/dist/gateway/static/root/assets/{global-defaults-api-BpDMnJe7.js → global-defaults-api-Bpje9rVk.js} +1 -1
- package/dist/gateway/static/root/assets/grip-horizontal-CqVA8V1e.js +1 -0
- package/dist/gateway/static/root/assets/home-page-CNEgNWEQ.js +8 -0
- package/dist/gateway/static/root/assets/{image-generation-api-sbtx4NiC.js → image-generation-api-BvpAa3Lj.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-CBlaxUhl.js → imports-page-Dx5T5pqw.js} +1 -1
- package/dist/gateway/static/root/assets/index-BGA-G-Bp.css +1 -0
- package/dist/gateway/static/root/assets/index-pmlYYCCU.js +11 -0
- package/dist/gateway/static/root/assets/{install-connector-dialog-DxSv1wS2.js → install-connector-dialog-Cb4ufypG.js} +1 -1
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CnAV96nr.js → keyboard-shortcuts-settings-BEuXrnv0.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-CfnixDO3.js → local-app-workbench-page-CPFIbEbv.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-BI3Be5qo.js → local-apps-page-DxHcRSxc.js} +1 -1
- package/dist/gateway/static/root/assets/local-session-drafts-Cmc-GCVa.js +4 -0
- package/dist/gateway/static/root/assets/{locale-store-Dy1EByeG.js → locale-store-tI9VX7dp.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-CMW34T31.js → logs-page-BcibwftP.js} +1 -1
- package/dist/gateway/static/root/assets/{management-api-B5w5DdXH.js → management-api-C9tFjLcE.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-DfcMIqbQ.js → management-settings-DbnAlXoB.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-CNJaAdNN.js → markdown-view-CSpQhSka.js} +1 -1
- package/dist/gateway/static/root/assets/mcp-conversation-setup-page-DedbjJbF.js +1 -0
- package/dist/gateway/static/root/assets/{media-plugins-DGhWjPIU.js → media-plugins-BYnP_orq.js} +1 -1
- package/dist/gateway/static/root/assets/{messages-BAnhwALN.js → messages-e5MhDONm.js} +2 -2
- package/dist/gateway/static/root/assets/{model-selector-C-CqPBao.js → model-selector-B4oTiJI6.js} +1 -1
- package/dist/gateway/static/root/assets/{models-hub-cache-Bgh3Gfgl.js → models-hub-cache-DpEClnsE.js} +1 -1
- package/dist/gateway/static/root/assets/{note-detail-panel-D_l5jkV9.js → note-detail-panel-D8asMfBm.js} +3 -3
- package/dist/gateway/static/root/assets/note-image-lightbox-DcDw5kp4.js +1 -0
- package/dist/gateway/static/root/assets/{notes-api-BOIM9Q_D.js → notes-api-pVC1amyp.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-R4uJroeD.js → notes-page-CG1_6PLz.js} +1 -1
- package/dist/gateway/static/root/assets/{oauth-api-B560CHeD.js → oauth-api-BsVPwufr.js} +1 -1
- package/dist/gateway/static/root/assets/{oauth-provider-connect-D63M8Iv7.js → oauth-provider-connect-Bu20kmPq.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-capture-button-B_Vdo2Ai.js → page-context-capture-button-CDsnNXjS.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-draft-Cr5GqS2D.js → page-context-draft-D6tu8c_9.js} +1 -1
- package/dist/gateway/static/root/assets/page-header-store-DeaRqZgV.js +1 -0
- package/dist/gateway/static/root/assets/panels-top-left-BKvp2Dag.js +1 -0
- package/dist/gateway/static/root/assets/{personal-avatar-BMRVyTrE.js → personal-avatar-BboNc6e2.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-page-BsONyPfQ.js → personal-page-gMRmLCWG.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-profile-settings-C4CxmQLQ.js → personal-profile-settings-Cd4QyseL.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-settings-panel-CnxI2TL0.js → personal-settings-panel-CtBY_Uk1.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-dependencies-card-flTci8mm.js → phone-dependencies-card-BgH1LluB.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-model-connection-Vi_Swyv6.js → phone-model-connection-DkdKU5Kv.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-model-picker-BOv3mb_F.js → phone-model-picker-0g1z4RPL.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-settings-page-vD0bTcHj.js → phone-settings-page-DlIUajBY.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-workspace-store-Ltrevdsx.js → phone-workspace-store-DW2sZtkh.js} +1 -1
- package/dist/gateway/static/root/assets/{plugin-details-dialog-nSDw8sfo.js → plugin-details-dialog-9KUkZk_t.js} +1 -1
- package/dist/gateway/static/root/assets/{preference-select-fields-D1pZekPs.js → preference-select-fields-DH5QZhIc.js} +1 -1
- package/dist/gateway/static/root/assets/{product-automation-feedback-CGso8wGv.js → product-automation-feedback-a1thJ0M9.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-BO8lUvw3.js → product-open-page-DCzQh7tr.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-content-Dgtb4LF7.js → product-preview-content-C5TLcagj.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-modal-C35EWUps.js → product-preview-modal-D9f-7kcI.js} +2 -2
- package/dist/gateway/static/root/assets/{project-detail-page-xNSy6SAv.js → project-detail-page-C4Z2HTRZ.js} +2 -2
- package/dist/gateway/static/root/assets/{project-understanding-Cg8WbBNB.js → project-understanding-CoPBvlqf.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-C6Pt6OdT.js → projects-page-k1v8Fry8.js} +1 -1
- package/dist/gateway/static/root/assets/{providers-api-Nytkkop9.js → providers-api-BSJZyO8n.js} +1 -1
- package/dist/gateway/static/root/assets/{recording-upload-CFX7CANT.js → recording-upload-CExCePtr.js} +1 -1
- package/dist/gateway/static/root/assets/{registry-api-DuDIthjL.js → registry-api-CqcJj60w.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-DePwafOK.js → remote-access-hub-BLFkNl1y.js} +1 -1
- package/dist/gateway/static/root/assets/{resource-unavailable-BRKhKJA0.js → resource-unavailable-B_BXTQa7.js} +1 -1
- package/dist/gateway/static/root/assets/{right-workspace-store-HPw7Gw0n.js → right-workspace-store-OceFhUjM.js} +1 -1
- package/dist/gateway/static/root/assets/route-preload-5iwjWERk.js +2 -0
- package/dist/gateway/static/root/assets/{routine-panel-KH1VaEdC.js → routine-panel-BsE9o9uu.js} +2 -2
- package/dist/gateway/static/root/assets/{runtime-tools-api-Dd8a07eo.js → runtime-tools-api-aAZChVm4.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-CvHQoqHu.js → runtime-tools-settings-panel-Bn9HTrK5.js} +1 -1
- package/dist/gateway/static/root/assets/{service-recommendation-list-DDlMyPvC.js → service-recommendation-list-BNIVRGDf.js} +1 -1
- package/dist/gateway/static/root/assets/{session-api-BFiIYodK.js → session-api-DdW7Wix2.js} +1 -1
- package/dist/gateway/static/root/assets/session-channel-icon-DUJbB-Km.js +1 -0
- package/dist/gateway/static/root/assets/{session-identity-label-D5SAi0Uh.js → session-identity-label-DjhlQ6LU.js} +1 -1
- package/dist/gateway/static/root/assets/session-manager-XgtApqIh.js +25 -0
- package/dist/gateway/static/root/assets/sessions-page-CfhKeUkZ.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-BBG8dTIY.js +1 -0
- package/dist/gateway/static/root/assets/{settings-advanced-section-B-H1gYOs.js → settings-advanced-section-BOoJfJuB.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-mode-store-YH60sibB.js → settings-mode-store-BMh_BQ9a.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-8MiJzbbl.js → settings-page-DNiRlM5x.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-header-DEZZ8D0S.js → settings-page-header-Bfu4cuQd.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-De2j64Lo.js → settings-page-layout-BnZa1qHH.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-interaction-page-Dh6BPwv0.js → setup-interaction-page-CVlrVNrm.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-DGAAczL-.js → setup-status-panel-FFyDODEx.js} +1 -1
- package/dist/gateway/static/root/assets/{share-link-dialog-C1t_HB6f.js → share-link-dialog-Cv-eDEw_.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-Cqy-7-rd.js → share-preview-page-BctH6eFs.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-api-Dm07CnXw.js → shares-api-cLTEcQLE.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-DcetAN8K.js +1 -0
- package/dist/gateway/static/root/assets/{skill-api-BV8oFqeE.js → skill-api-CgEZJoy9.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-list-api-1o_YRCu9.js → skill-list-api-BWVr2PL5.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-fGsO9Y86.js → skill-reload-api-BLhHNvaK.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-DReUQ4Ug.js → skills-page-DIjcAvA0.js} +1 -1
- package/dist/gateway/static/root/assets/sliding-segmented-DagP0myu.js +1 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-CUI6QHEP.js → system-settings-panel-C7LAPaN_.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-DxKXoBbE.js → task-detail-page-DmNEMg-l.js} +1 -1
- package/dist/gateway/static/root/assets/{task-result-evidence-CW_tN93T.js → task-result-evidence-BsBn3n_l.js} +1 -1
- package/dist/gateway/static/root/assets/{terminal-panel-store-Du53Upr2.js → terminal-panel-store-DJbLuUku.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-BaWep_o7.js → theme-store-QGcjV6pN.js} +1 -1
- package/dist/gateway/static/root/assets/{tracing-settings-page-CnciBMVH.js → tracing-settings-page-BKCiPwYL.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-Iz7JCBt3.js → tunnel-api-S7J5Lpzt.js} +1 -1
- package/dist/gateway/static/root/assets/{understanding-activity-store-BFc8PamJ.js → understanding-activity-store-BNVhtJkn.js} +1 -1
- package/dist/gateway/static/root/assets/{understanding-refresh-store-CdEfR40A.js → understanding-refresh-store-Cf0DUO_C.js} +1 -1
- package/dist/gateway/static/root/assets/undo-2-6IMTwK4M.js +1 -0
- package/dist/gateway/static/root/assets/{unlink-BEuthaaq.js → unlink-NsCMuCT1.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-DL2fmeOh.js → usage-page-D-AqzjIx.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-N_SjHXTw.js → use-autosave-CqZbhhCc.js} +1 -1
- package/dist/gateway/static/root/assets/use-composer-attachments-BfLhIb2_.js +2 -0
- package/dist/gateway/static/root/assets/{use-file-preview-expanded-D0IBFhM9.js → use-file-preview-expanded-DufxDues.js} +3 -3
- package/dist/gateway/static/root/assets/{use-personal-profile-C1vqD9yV.js → use-personal-profile-RnjxZnLa.js} +1 -1
- package/dist/gateway/static/root/assets/{use-realtime-voice-B5IsKrRW.js → use-realtime-voice-w3aHR2dr.js} +1 -1
- package/dist/gateway/static/root/assets/{use-workspace-tree-7X2ydgS8.js → use-workspace-tree-2Ck-ql5c.js} +1 -1
- package/dist/gateway/static/root/assets/{user-model-page-D2FHjLi7.js → user-model-page-CdB9qH57.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-B_GApUQP.js → voice-api-key-field-C4rhpgco.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-DhJ3l8fk.js → voice-config-api-7AHN-ns6.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-input-shortcut-events-CEeFBhp3.js → voice-input-shortcut-events-BbRrj833.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-settings-57pwZeKD.js → voice-settings-wamtp0lg.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-UvWbDUXi.js → work-discovery-overlay-fVofN7aP.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-page-BM1HsYz6.js → work-discovery-page-DcQG5GWy.js} +1 -1
- package/dist/gateway/static/root/assets/{working-directory-picker-modal-BGZduAXV.js → working-directory-picker-modal-D8Stwszr.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-api-Dd_UDfeo.js → workspace-api-D3iuTdNK.js} +2 -2
- package/dist/gateway/static/root/assets/workspace-editor-agent-store-C-J7vr2o.js +1 -0
- package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-Clj9hMj5.js → workspace-file-preview-dialog-BXbL5Y1h.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-open-location-menu-CvZxU9de.js → workspace-open-location-menu-1gFO_BdL.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-preview-store-imhtuEIP.js → workspace-preview-store-adwmi4nx.js} +1 -1
- package/dist/gateway/static/root/assets/{xopc-cloud-account-card-Q_jezTUy.js → xopc-cloud-account-card-DhGh4rm7.js} +1 -1
- package/dist/gateway/static/root/index.html +97 -93
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/session-input-command.js +5 -0
- package/dist/src/agent/embedded/session-runner.js +2 -2
- package/dist/src/agent/external-tools/gateway-tools.js +8 -1
- package/dist/src/agent/mcp/connection-setup.js +46 -42
- package/dist/src/agent/mcp/conversation-setup.js +13 -8
- package/dist/src/agent/mcp/discovery.d.ts +22 -1
- package/dist/src/agent/mcp/discovery.js +19 -3
- package/dist/src/agent/mcp/managed-discovery.d.ts +8 -0
- package/dist/src/agent/mcp/managed-discovery.js +77 -0
- package/dist/src/agent/mcp/tool-catalog.js +1 -1
- package/dist/src/agent/prompt/conversational-configuration-guide.js +1 -1
- package/dist/src/agent/prompt/response-language.js +9 -1
- package/dist/src/agent/prompt/service-prompt-builder.js +3 -0
- package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.d.ts +6 -2
- package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.js +10 -7
- package/dist/src/agent/tool-manuals/xopc-configuration.d.ts +1 -1
- package/dist/src/agent/tool-manuals/xopc-configuration.js +12 -4
- package/dist/src/cli/commands/extension-agent-plugin.js +1 -1
- package/dist/src/config/schema.d.ts +1 -1
- package/dist/src/connectors/connection-recovery-service.js +38 -5
- package/dist/src/connectors/excluded-connectors.d.ts +1 -0
- package/dist/src/connectors/excluded-connectors.js +5 -1
- package/dist/src/connectors/plugin-connection.d.ts +10 -0
- package/dist/src/connectors/plugin-connection.js +105 -0
- package/dist/src/extensions/agent-plugins/setup.js +1 -1
- package/dist/src/extensions/agent-plugins/skill-catalog.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.d.ts +1 -1
- package/dist/src/gateway/hono/routes/agent-plugins.js +2 -2
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
- package/dist/src/gateway/security/gateway-scopes.js +1 -0
- package/dist/src/gateway/service/config-coordinator.d.ts +1 -1
- package/dist/src/i18n/response-language.d.ts +1 -1
- package/dist/src/storage/sqlite/session-creation-repository.js +6 -1
- package/dist/src/tui/tui-management.js +2 -2
- package/dist/src/user-context/config.d.ts +1 -1
- package/package.json +2 -2
- package/dist/extensions/demo-memory/src/index.d.ts +0 -6
- package/dist/extensions/demo-memory/src/index.js +0 -146
- package/dist/extensions/demo-memory/xopc.extension.json +0 -15
- package/dist/gateway/static/root/assets/agent-plugin-dialog-CikzCYAG.js +0 -1
- package/dist/gateway/static/root/assets/agents-DC0lHtl5.js +0 -77
- package/dist/gateway/static/root/assets/automations-workspace-BXT_EDON.js +0 -9
- package/dist/gateway/static/root/assets/capabilities-page-CnU0htlO.js +0 -2
- package/dist/gateway/static/root/assets/chat-agents-api-CjlzCSmC.js +0 -1
- package/dist/gateway/static/root/assets/chat-page-U2a7d6wP.js +0 -71
- package/dist/gateway/static/root/assets/gateway-realtime-store-sx7B8kdC.js +0 -1
- package/dist/gateway/static/root/assets/home-page-DefKShSW.js +0 -8
- package/dist/gateway/static/root/assets/index-CChzK_5b.css +0 -1
- package/dist/gateway/static/root/assets/index-CEBDMkde.js +0 -11
- package/dist/gateway/static/root/assets/local-session-drafts-BIBHRkpM.js +0 -4
- package/dist/gateway/static/root/assets/mcp-conversation-setup-page-CsTSmjmX.js +0 -1
- package/dist/gateway/static/root/assets/note-image-lightbox-D6mvMSKr.js +0 -1
- package/dist/gateway/static/root/assets/page-header-store-Bm8oxpFR.js +0 -1
- package/dist/gateway/static/root/assets/route-preload-Dwb_N8L-.js +0 -2
- package/dist/gateway/static/root/assets/session-channel-icon-BzkFo-Ci.js +0 -1
- package/dist/gateway/static/root/assets/session-manager-63NaXb1s.js +0 -25
- package/dist/gateway/static/root/assets/sessions-page-DQEq_VJS.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-Cvx7DnU8.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-BDr50uTV.js +0 -1
- package/dist/gateway/static/root/assets/sliding-segmented-CgQ3BFdb.js +0 -1
- package/dist/gateway/static/root/assets/use-composer-attachments-Xn6eUus2.js +0 -2
- package/dist/gateway/static/root/assets/workspace-editor-agent-store-DVPJcbuE.js +0 -1
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mcp-conversation-setup-page-DedbjJbF.js","assets/rolldown-runtime-aKtaBQYM.js","assets/vendor-react-BOUWij0V.js","assets/chunk-KS7C4IRE-CiwuuyV8.js","assets/preload-helper-Czpn1I53.js","assets/locale-store-tI9VX7dp.js","assets/messages-e5MhDONm.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/agent-plugin-dialog-DLbTHALG.js","assets/arrow-left-D880xG-P.js","assets/chevron-down-ccbiQQz_.js","assets/working-directory-picker-modal-D8Stwszr.js","assets/file-archive-DanfQJNe.js","assets/settings-form-draft-Dy10ldo8.js","assets/circle-alert-BEjgurr2.js","assets/circle-BoO4YvTx.js","assets/folder-open-CyzJ19I9.js","assets/package-wATCyihJ.js","assets/shield-check-BU58siTV.js","assets/upload-rrb46c3c.js","assets/capability-links-MZdYfPKx.js","assets/connection-usage-BhdQRWgQ.js","assets/browser-BLJWD7WI.js","assets/capability-icon-CmvCZOJX.js","assets/chat-terminal-dock-B0D220I-.js","assets/plus-Q2yW6OE7.js","assets/square-terminal-K87bylpZ.js","assets/session-api-DdW7Wix2.js","assets/schemas-CCWMleym.js","assets/gateway-startup-retry-vteSIhYI.js","assets/session-manager-XgtApqIh.js","assets/diagnostics-Bo0Z42P_.js","assets/constants-Bg1wM2nv.js","assets/local-session-drafts-Cmc-GCVa.js","assets/tool-activity-BtJkgjFf.js","assets/attachment-utils-core-BIOUBrpT.js","assets/gateway-realtime-Br7dErHY.js","assets/gateway-realtime-store-OaEqjNTb.js","assets/registry-api-CqcJj60w.js","assets/agents-admin-api-CqQbYIiY.js","assets/gateway-config-swr-DOwezeL2.js","assets/sliding-tab-list-CmcrqRzN.js","assets/sliding-indicator-hwz0sx3h.js","assets/terminal-panel-store-DJbLuUku.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{n,r,t as i}from"./diagnostics-Bo0Z42P_.js";import{a,i as o,n as s,t as c}from"./vendor-react-BOUWij0V.js";import{t as l}from"./preload-helper-Czpn1I53.js";import{f as u,l as d,m as f,t as p,u as m}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{a as h,i as g,l as _,n as v,o as y,p as b,u as x}from"./locale-store-tI9VX7dp.js";import{t as S}from"./messages-e5MhDONm.js";import{a as C,c as w,i as T,n as E,o as D,r as O,s as k,t as A}from"./dist-CY7CS_D3.js";import{t as j}from"./createLucideIcon-DPHK1VkS.js";import{t as M}from"./app-window-DXFNqt_0.js";import{t as N}from"./archive-Dz0hferG.js";import{t as P}from"./arrow-left-D880xG-P.js";import{t as F}from"./arrow-up-right-T72JbQ1Q.js";import{t as I}from"./arrow-up-D5ZtR1QT.js";import{a as L,c as R,d as z,f as B,l as ee,s as V,t as H,u as U}from"./product-automation-feedback-a1thJ0M9.js";import{n as W,t as te}from"./earth-C9Z4bTTG.js";import{t as ne}from"./bot-DjLkhyZL.js";import{t as re}from"./check-DUBLcKHA.js";import{t as ie}from"./chevron-down-ccbiQQz_.js";import{t as ae}from"./chevron-right-BweFrslA.js";import{i as oe,r as se,t as ce}from"./working-directory-picker-modal-D8Stwszr.js";import{a as le,d as ue,n as de,o as G,r as K,t as fe}from"./popover-select-CLsphyzA.js";import{t as q}from"./circle-alert-BEjgurr2.js";import{i as pe,r as me,t as J}from"./new-chat-navigation-B6NPQ4h4.js";import{t as he}from"./circle-x-DFsCKeya.js";import{t as ge}from"./circle-BoO4YvTx.js";import{i as _e,n as ve,r as ye,t as be}from"./file-tree-utils-DJs1faGv.js";import{t as xe}from"./copy-Dv6d4Dvw.js";import{t as Se}from"./database-CjjeZfRG.js";import{t as Ce}from"./ellipsis-0k4rZLoy.js";import{t as we}from"./external-link-DjqjBmc3.js";import{n as Te,t as Ee}from"./file-BqMS_3DT.js";import{t as De}from"./file-image-CDUPkZvG.js";import{t as Oe}from"./file-text-D12HbeVy.js";import{t as ke}from"./folder-kanban-CpLlFI1o.js";import{t as Ae}from"./folder-open-CyzJ19I9.js";import{t as je}from"./folder-CN-pC3XL.js";import{i as Me,r as Ne,u as Pe}from"./use-file-preview-expanded-DufxDues.js";import{t as Fe}from"./git-branch-Dh9uxTot.js";import{t as Ie}from"./globe-DSSGFWFn.js";import{t as Le}from"./history-DXH_9jsE.js";import{F as Re,L as ze,P as Be,c as Ve,g as He,o as Ue,t as We,v as Ge}from"./notes-api-pVC1amyp.js";import{t as Ke}from"./key-round-DWbpyU2U.js";import{t as qe}from"./laptop-CI3hBVrl.js";import{t as Je}from"./link-2-D_ZKYUW7.js";import{t as Ye}from"./list-checks-BbsExAoq.js";import{t as Xe}from"./list-todo-CTVRto8O.js";import{t as Ze}from"./loader-circle-CifKLtgG.js";import{C as Qe,E as $e,F as et,I as tt,O as nt,T as rt,V as it,_ as at,b as ot,c as st,d as ct,f as lt,g as ut,h as dt,j as ft,l as pt,m as mt,n as ht,p as gt,r as _t,u as vt,v as yt,w as bt,x as xt,y as St,z as Ct}from"./markdown-view-CSpQhSka.js";import{t as wt}from"./messages-square-BckAJrEW.js";import{t as Tt}from"./mic-CuUb7zc-.js";import{t as Et}from"./monitor-Af5eAvF7.js";import{s as Dt,t as Ot}from"./install-connector-dialog-Cb4ufypG.js";import{t as kt}from"./paperclip-f1HujQY1.js";import{t as At}from"./pause-DuPxgSxk.js";import{t as jt}from"./pencil-DmIY3Oa-.js";import{t as Mt}from"./play-kxZvpBg8.js";import{t as Nt}from"./plus-Q2yW6OE7.js";import{t as Pt}from"./refresh-cw-BRlGaq2w.js";import{t as Ft}from"./rotate-ccw-JM1TBLpp.js";import{t as It}from"./save-DRDABU--.js";import{t as Lt}from"./search-DA7gz22f.js";import{t as Rt}from"./settings-2-D-csvaET.js";import{t as zt}from"./settings-uiTATseT.js";import{t as Bt}from"./shield-check-BU58siTV.js";import{t as Vt}from"./smartphone-DSSsQFqA.js";import{t as Ht}from"./sparkles-DHlfQFAF.js";import{t as Ut}from"./square-DMK_fB-3.js";import{t as Wt}from"./trash-2-DusmjVPV.js";import{t as Gt}from"./triangle-alert-2JXFNNKU.js";import{a as Kt,r as qt,t as Jt}from"./share-link-dialog-Cv-eDEw_.js";import{t as Yt}from"./wrench-DFb4r8bH.js";import{t as Xt}from"./x-B_N4OPjy.js";import{t as Zt}from"./zap-dximCGjy.js";import{t as Y}from"./cn-0WouolD0.js";import{t as Qt}from"./skeleton-DzdOeGYz.js";import{a as $t,d as en,m as tn,n as nn,u as rn}from"./schemas-CCWMleym.js";import{t as an}from"./tasks-BTLabOMp.js";import{i as on,n as sn,o as cn,s as ln,t as un}from"./product-delivery-BFfqdKLe.js";import{o as dn}from"./local-apps-DeqzkJiF.js";import{a as fn,c as pn,d as mn}from"./api-BGodd--L.js";import{a as hn,s as gn}from"./session-api-DdW7Wix2.js";import{$ as _n,A as vn,B as yn,C as bn,Ct as xn,D as Sn,E as Cn,F as wn,G as Tn,H as En,I as Dn,J as On,K as kn,L as An,M as jn,N as Mn,O as Nn,P as Pn,Q as Fn,R as In,S as Ln,St as Rn,T as zn,Tt as Bn,U as Vn,V as Hn,W as Un,X as Wn,Y as Gn,Z as Kn,_ as qn,_t as Jn,b as Yn,bt as Xn,c as Zn,ct as Qn,d as $n,dt as er,et as tr,f as nr,ft as rr,g as ir,gt as ar,it as or,j as sr,k as cr,l as lr,lt as ur,mt as dr,nt as fr,o as pr,ot as mr,p as hr,r as gr,rt as _r,st as vr,t as yr,tt as br,u as xr,v as Sr,vt as Cr,w as wr,wt as Tr,x as Er,xt as Dr,y as Or,yt as kr,z as Ar}from"./session-manager-XgtApqIh.js";import{c as jr,d as Mr,f as Nr,h as Pr,m as Fr,n as Ir,o as Lr,s as Rr,t as zr}from"./local-session-drafts-Cmc-GCVa.js";import{t as Br}from"./tool-activity-BtJkgjFf.js";import{a as Vr,c as Hr,i as Ur,l as Wr,n as Gr,o as Kr,r as qr,s as Jr,t as Yr}from"./new-session-preferences-gb411vZP.js";import{n as Xr,t as Zr}from"./composer-model-config-control-DQCOWHzJ.js";import{i as Qr}from"./vendor-swr-CdRzEUwF.js";import{g as $r,i as ei,n as ti,o as ni,p as ri,r as ii,t as ai}from"./workspace-preview-store-adwmi4nx.js";import{a as oi}from"./gateway-config-swr-DOwezeL2.js";import{t as si}from"./chat-agents-api-C3JChTsh.js";import{a as ci,c as li,i as ui,r as di,s as fi}from"./attachment-utils-core-BIOUBrpT.js";import{n as pi}from"./gateway-realtime-Br7dErHY.js";import{n as mi}from"./gateway-realtime-store-OaEqjNTb.js";import{n as hi,t as gi}from"./registry-api-CqcJj60w.js";import{a as _i}from"./agents-admin-api-CqQbYIiY.js";import{t as vi}from"./button-Cc4hUNTt.js";import{n as yi}from"./right-workspace-store-OceFhUjM.js";import{a as bi,i as xi,o as Si,r as Ci,s as wi}from"./dist-GJ8-1PAx.js";import{t as Ti}from"./middleware-Pd0e8Igk.js";import{i as Ei,r as Di}from"./app-link-DImAfVs5.js";import{t as Oi}from"./copy-to-clipboard-HOJ79TWv.js";import{a as ki,c as Ai,i as ji,n as Mi,o as Ni,r as Pi,s as Fi}from"./composer-payload-handoff-BBTbJ1bO.js";import{C as Ii,D as Li,E as Ri,T as zi,_ as Bi,b as Vi,c as Hi,d as Ui,f as Wi,g as Gi,h as Ki,m as qi,n as Ji,o as Yi,p as Xi,r as Zi,s as Qi,u as $i,v as ea,w as ta,x as na,y as ra}from"./chunk-D32TOXHM-DQIy-Baq.js";import{i as ia,n as aa,r as oa,t as sa}from"./chat-chart-block-DrtmYOIo.js";import{t as ca}from"./linkify-it-BkqEorO0.js";import{n as la}from"./interaction-BdhHBbYa.js";import{a as ua,i as da,n as fa,o as pa,r as ma,s as ha,t as ga}from"./tool-friendly-title-CP35P4VA.js";import{s as _a}from"./connectors-api-BvYGL65q.js";import{t as va}from"./use-realtime-voice-w3aHR2dr.js";import{t as ya}from"./activity-store-B9heFbtJ.js";import{t as ba}from"./composer-notifications-D__OU_xx.js";import{n as xa}from"./voice-call-context-BM2A4bLz.js";import{r as Sa}from"./app-chrome-BeB4KgOf.js";import{i as Ca,n as wa,r as Ta}from"./form-field-width-DJw_jULe.js";import{n as Ea}from"./electron-env-DHOGevH3.js";import{t as Da}from"./page-header-store-DeaRqZgV.js";import{t as Oa}from"./use-async-resource-BHFGZCY2.js";import{t as ka}from"./loopi-CNtmi9FU.js";import{a as Aa}from"./extension-provider-l7SvHEK1.js";import{t as ja}from"./agent-avatar-display-DBzgoHMD.js";import{a as Ma,n as Na,r as Pa,t as Fa}from"./skill-wire-pattern-BPpeIcCi.js";import{a as Ia,i as La,o as Ra,t as za}from"./composer-handoff-params-GKGdXjMZ.js";import{n as Ba,t as Va}from"./agent-display-names-Bje7vfSn.js";import{n as Ha,t as Ua}from"./use-directory-picker-C4p7AgWY.js";import{t as Wa}from"./confirm-dialog-DrA5mTQp.js";import{a as Ga,c as Ka,f as qa,l as Ja,s as Ya,u as Xa}from"./workspace-api-D3iuTdNK.js";import{n as Za}from"./index.module-Cd9ENXfk.js";import{a as Qa,i as $a,o as eo,r as to,s as no}from"./copy-text-row-CpiRzq4G.js";import{_ as ro,b as io,d as ao,f as oo,h as so,i as co,n as lo,p as uo,s as fo,u as po,y as mo}from"./shares-api-cLTEcQLE.js";import{t as ho}from"./workspace-editor-agent-store-C-J7vr2o.js";import{l as go,m as _o,o as vo,r as yo,t as bo,u as xo}from"./dist-ZrL34Ps4.js";import{n as So,r as Co,t as wo}from"./use-composer-attachments-BfLhIb2_.js";import{a as To,c as Eo,d as Do,f as Oo,h as ko,i as Ao,l as jo,m as Mo,p as No,s as Po,t as Fo,u as Io}from"./command-palette-api-CkJ6_Yf3.js";import{n as Lo,o as Ro,r as zo,s as Bo}from"./voice-input-shortcut-events-BbRrj833.js";import{_ as Vo,g as Ho,h as Uo,i as Wo,t as Go,v as Ko}from"./automation-task-card-D3WXVKRs.js";import{t as qo}from"./dev-view-store-UCqQeWa2.js";import{t as Jo}from"./extension-iframe-host-D_WXBf6a.js";import{i as Yo,r as Xo,t as Zo}from"./runtime-health-zDkHcOZO.js";import{c as Qo,i as $o,r as es}from"./api-8tNOT72p.js";import{r as ts}from"./terminal-panel-store-DJbLuUku.js";import{n as ns}from"./agents-app-path-ciChvpCS.js";import{t as rs}from"./oauth-provider-connect-Bu20kmPq.js";import{t as is}from"./use-media-query-ady-FgjK.js";import{n as as,r as os,t as ss}from"./oauth-authorization-window-o6URRos4.js";import{n as cs,t as ls}from"./page-context-draft-D6tu8c_9.js";import{i as us,r as ds}from"./management-api-C9tFjLcE.js";import{t as fs}from"./side-chat-shortcut-BIw-1TTD.js";var ps=j(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),ms=j(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),hs=j(`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`}]]),gs=j(`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`}]]),_s=j(`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`}]]),vs=j(`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`}]]),ys=j(`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`}]]),bs=j(`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`}]]),xs=j(`git-commit-horizontal`,[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]]),Ss=j(`git-fork`,[[`circle`,{cx:`12`,cy:`18`,r:`3`,key:`1mpf1b`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`path`,{d:`M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9`,key:`1uq4wg`}],[`path`,{d:`M12 12v3`,key:`158kv8`}]]),Cs=j(`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`}]]),ws=j(`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`}]]),Ts=j(`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`}]]),Es=j(`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`}]]),Ds=j(`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`}]]),Os=j(`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`}]]),ks=j(`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`}]]),As=j(`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`}]]),js=j(`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`}]]),Ms=j(`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`}]]),Ns=j(`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 Ps(e,t){return e.replace(/\{\{(\w+)}}/g,(e,n)=>t[n]?.trim()??``).replace(/[ \t]{2,}/g,` `).trim()}function Fs(e,t,n){return{id:e,title:Ps(t.title,n),prompt:Ps(t.prompt,n),reason:Ps(t.reason,n)}}function Is(e,t){let n={projectName:e.projectName,blockedReason:e.blockedReason,recentFailure:e.recentFailure,nextAction:e.recommendedAction};if(e.blockedReason?.trim())return Fs(`project-blocked`,t.recommendations.projectBlocked,n);if(e.recentFailure?.trim())return Fs(`project-failure`,t.recommendations.projectFailure,n);if(e.recommendedAction?.trim())return Fs(`project-next-action`,t.recommendations.projectNextAction,n)}function Ls(e,t){let n={taskTitle:e.taskTitle,attentionSummary:e.attentionSummary,recentFailure:e.recentFailure,nextAction:e.nextAction};if(e.attentionSummary?.trim())return Fs(`task-attention`,t.recommendations.taskAttention,n);if(e.recentFailure?.trim())return Fs(`task-failure`,t.recommendations.taskFailure,n);if(e.phase===`review`||e.operationalState===`verifying`)return Fs(`task-review`,t.recommendations.taskReview,n);if(e.phase===`closed`)return Fs(`task-closed`,t.recommendations.taskClosed,n);if(e.nextAction?.trim())return Fs(`task-next-action`,t.recommendations.taskNextAction,n)}function Rs(e,t){switch(e.kind){case`project`:return Is(e,t);case`task`:return Ls(e,t);default:return}}function zs(e,t,n={}){let r=n.contextStatus??`ready`;return{headline:e.kind===`project`&&t.projectHeadline?Ps(t.projectHeadline,{projectName:e.projectName}):t.headline,contextKind:e.kind,contextStatus:r,recommendation:r===`ready`?Rs(e,t):void 0}}var Bs=en({id:tn().uuid(),conversationId:tn(),transcriptId:tn(),sourceRunId:tn(),inputRevision:rn().int().nonnegative(),transcriptCursor:rn().int().nonnegative(),agentId:tn(),locale:nn([`zh`,`en`]),prompt:tn().min(1).max(160),expiresAt:rn()}),Vs=en({status:nn([`ready`,`pending`,`none`]),suggestion:Bs.optional()});en({suggestionId:tn().uuid(),impressionId:tn().uuid(),event:nn([`shown`,`accepted`,`dismissed`,`submitted`]),edited:$t().optional()}).strict();function Hs(e,t=`body`){return`result:${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Us(e){return`${e.taskRunId}:${e.assignmentEpoch}:${e.outcome.outcomeId}`}var Ws=e(o(),1),X=s(),Z=c(),Q=e(a(),1);function Gs(e,t){return e?[`task-detail`,e,t??``]:null}function Ks(e,t){return t.source!==`user`||e===void 0||t.version>e}function qs(e){let t=_(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=Qr(Gs(e,t),()=>$r(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),ri(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=an.safeParse(t.detail);!i.success||i.data.taskId!==e||Ks(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 Js=new Map,Ys=new Set;function Xs(e,t){Js.set(e,t);for(let e of Ys)e();return()=>{Js.get(e)===t&&Js.delete(e)}}async function Zs(e,t,n){await(Js.get(e)??await new Promise((t,n)=>{let r=()=>{let n=Js.get(e);n&&(clearTimeout(i),Ys.delete(r),t(n))},i=setTimeout(()=>{Ys.delete(r),n(Error(`Chat input is not ready. Please retry.`))},15e3);Ys.add(r),r()}))(t,n)}var Qs=crypto.randomUUID(),$s=e=>e===`closed`;function ec(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 tc=e=>`/api/phone/conversations/${encodeURIComponent(e)}`,nc=new Map,rc=()=>{let e=_.getState();return`${e.baseUrl}:${e.conversationId}`};function ic(e,t,n=rc()){let r=`${n}:${e}`,i=nc.get(r);return t&&i&&t.report.sessionId===i.report.sessionId&&(t.report.revision??0)<(i.report.revision??0)?i:(t?(nc.set(r,t),nc.size>100&&nc.delete(nc.keys().next().value)):nc.delete(r),t)}async function ac(e,t=rc()){let n=await h(g(e)),r=decodeURIComponent(e.split(`/conversations/`)[1]?.split(`?`)[0]??``);if(n.status===404)return ic(r,null,t);if((n.status===401||n.status===403)&&ic(r,null,t),!n.ok)throw Object.assign(Error(`Phone view unavailable (HTTP ${n.status})`),{status:n.status});return ic(r,(await n.json()).payload,t)}function oc(e,t){let n=(0,X.c)(5),r=t===void 0||t,i=_(lc),a;n[0]!==e||n[1]!==r||n[2]!==i?(a=r&&/^(?:device:)?[\da-f]{8}-[\da-f-]{27}$/i.test(e)?[`${tc(e)}?clientId=${Qs}`,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:sc,errorRetryCount:6,errorRetryInterval:2e3,refreshWhenHidden:!1},n[4]=o):o=n[4],Qr(a,cc,o)}function sc(e){return e.status!==401&&e.status!==403}function cc(e){let[t,n]=e;return ac(t,n)}function lc(e){return`${e.baseUrl}:${e.conversationId}`}async function uc(e,t,n,r={},i=!1){let a=rc();return ic(e,(await y(g(`${tc(e)}/${t.report.sessionId}/control`),{method:`POST`,keepalive:i,body:JSON.stringify({expectedTranscriptId:t.report.transcriptId,clientId:Qs,assistanceId:t.report.assistanceId,assistanceVersion:t.report.assistanceVersion,operationId:crypto.randomUUID(),epoch:t.report.controlEpoch,op:n,...r})})).payload,a)}async function dc(e,t,n){let r=await h(g(`${tc(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 fc(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 pc(e,t,n,r=!1){return(await y(g(`${tc(e)}/${t.report.sessionId}/execution-mode`),{method:`POST`,body:JSON.stringify({executionMode:n,applyCurrent:r,epoch:t.report.controlEpoch,clientId:Qs})})).payload}function mc(e,t){if(!t.assistanceId||![`needs_user`,`paused`].includes(t.status))return null;let n=_.getState();return JSON.stringify([n.baseUrl,n.conversationId,e,t.transcriptId,t.assistanceId,t.assistanceVersion??1])}var hc=b(Ti(e=>({seen:[],markSeen:t=>e(e=>e.seen.includes(t)?e:{seen:[...e.seen.slice(-99),t]})}),{name:`xopc-phone-attention-v1`}));function gc(e){let t=(0,X.c)(15),{detail:n,language:r}=e,i;t[0]===n?i=t[1]:(i=ni(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 _c=(0,Q.memo)(function(e){let t=(0,X.c)(58),{taskId:n}=e,r=d(),i=v(vc),a;t[0]===i?a=t[1]:(a=Ai(i),t[0]=i,t[1]=a);let o=a,{data:s}=qs(n);if(!s)return null;let{task:c,operationalState:l}=s,u,f,m,h;if(t[2]!==o.noDecisionNeeded||t[3]!==s||t[4]!==l||t[5]!==c.phase){let e=ti(s);m=s.attention.length>0;let n;t[10]!==l||t[11]!==c.phase?(n=c.phase!==`closed`&&[`queued`,`running`,`verifying`].includes(l),t[10]=l,t[11]=c.phase,t[12]=n):n=t[12],f=n,u=m?s.attention[0]?.summary??e?.nextAction??e?.summary:c.phase===`closed`?e?.summary:e?.nextAction??e?.summary??o.noDecisionNeeded,h=e?.evidence.filter(yc).length??0,t[2]=o.noDecisionNeeded,t[3]=s,t[4]=l,t[5]=c.phase,t[6]=u,t[7]=f,t[8]=m,t[9]=h}else u=t[6],f=t[7],m=t[8],h=t[9];let g=h,_=o.taskProgress.title,y;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(Ms,{className:`size-4`,"aria-hidden":!0}),t[13]=y):y=t[13];let b;t[14]===f?b=t[15]:(b=f?(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]=f,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(ii(s))),t[20]=s,t[21]=C);let w=o.detailStatuses[ii(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]!==g?(E=g>0?(0,Z.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[g,` `,o.taskProgress.evidence]}):null,t[25]=o.taskProgress.evidence,t[26]=g,t[27]=E):E=t[27];let D;t[28]!==T||t[29]!==E||t[30]!==S?(D=(0,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]===c.title?O=t[33]:(O=(0,Z.jsx)(`p`,{className:`mt-1 text-sm font-medium leading-5 text-fg`,children:c.title}),t[32]=c.title,t[33]=O);let k;t[34]===u?k=t[35]:(k=u?(0,Z.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:u}):null,t[34]=u,t[35]=k);let A;t[36]!==D||t[37]!==O||t[38]!==k?(A=(0,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]!==c.id?(M=tt(j,c.id),t[40]=j,t[41]=c.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)(we,{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)(p,{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)(gc,{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":_,"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 vc(e){return e.language}function yc(e){return e.strength===`verified`}function bc(e){return e===-5||e===-4||e===-3?`
|
|
3
|
+
`:e<0?` `:String.fromCharCode(e)}var xc={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 Sc(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?Qe(a):bt(a))?(c&&t.exit(`xopcMathValue`),t.exit(l),n(i)):r(i)}function f(n){if(n===null)return d(n);let l=bc(n);if(l===`
|
|
4
|
+
`)return e&&i.interrupt||!e||o?d(n):(c&&t.exit(`xopcMathValue`),c=!1,t.attempt(xc,e=>(a+=`
|
|
5
|
+
`,s=!1,f(e)),e=>d(e))(n));if(o){if(!e)return/\d/.test(l)&&a.startsWith(`$`)?r(n):d(n);if(l!==` `&&l!==` `)return r(n)}if(c||=(t.enter(`xopcMathValue`),!0),t.consume(n),a+=l,l===`
|
|
6
|
+
`&&(s=!1),l===`%`&&!ot(a,a.length-1)&&(s=!0),a.length===1&&l===`\\`)return f;if(a.length===2&&a.startsWith(`\\`)&&a!==(e?`\\[`:`\\(`)||!e&&a.startsWith(`$$`)||e&&a.startsWith(`$`)&&a.length===2&&a!==`$$`)return r;let u=a.startsWith(`\\`)?e?`\\]`:`\\)`:e?`$$`:`$`,p=u.length;return o=!s&&a.length>=p*2&&a.endsWith(u)&&!ot(a,a.length-p),f}}}var Cc={name:`xopcMathInline`,tokenize:Sc(!1)},wc={name:`xopcMathFlow`,tokenize:Sc(!0),concrete:!0},Tc={text:{92:Cc,36:Cc},flow:{92:wc,36:wc}};function Ec(e){return{hName:`code`,hProperties:{className:[e.display?`math-display`:`math-inline`],"data-xopc-math-source":St(e)},hChildren:[{type:`text`,value:e.raw}]}}var Dc={enter:{xopcMathInline(e){this.enter({type:`inlineCode`,value:``},e)},xopcMathFlow(e){this.enter({type:`code`,value:``},e)}},exit:{xopcMathInline(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-1],r=bt(t);Object.assign(n,{value:t,data:Ec(r)}),this.exit(e)},xopcMathFlow(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-1],r=Qe(t);Object.assign(n,{value:t,data:Ec(r)}),this.exit(e)}}};function Oc(){let e=this.data();return(e.micromarkExtensions??=[]).push(Tc),(e.fromMarkdownExtensions??=[]).push(Dc),(e,t)=>{function n(e){if(e.type===`code`&&e.lang===`math`){let n=e.value??``,r=String(t.value).slice(e.position?.start.offset,e.position?.end.offset);e.data=Ec(rt(r)??xt(r,n))}for(let t of e.children??[])n(t)}n(e)}}var kc=new Map,Ac=0;function jc(e){if(!/\\[([]|\$|^\s*```math/m.test(e))return[];let t=kc.get(e);if(t)return t;let n=Ii(e,{extensions:[Tc],mdastExtensions:[Dc]}),r=[];function i(e){if(!(e.type===`image`||e.type===`html`)){if(e.data?.hProperties||e.type===`code`&&e.lang===`math`){let t=e.position?.start.offset,n=e.position?.end.offset;t!==void 0&&n!==void 0&&r.push({start:t,end:n})}for(let t of e.children??[])i(t)}}if(i(n),e.length<=262144){for(;kc.size>=256||Ac+e.length>1048576;){let e=kc.keys().next().value;Ac-=e.length,kc.delete(e)}kc.set(e,r),Ac+=e.length}return r}function Mc(e=e=>jc(e).length){let t=[],n=[];return r=>{let i=0,a=[],o=r.map((n,r)=>{let o=Math.max(0,256-i),s=t[r],c=s?.source===n?s:{source:n,count:e(n)};return a.push(c),i+=c.count,o});return t=a,o.length===n.length&&o.every((e,t)=>e===n[t])?n:(n=o,o)}}var Nc=/^(?:查看(?:高清|原|大)?图片|查看大图|查看原图|view(?: (?:full[- ]size|original|hd))? image)$/i;function Pc(e){return Nc.test(e)}function Fc(){let e=new Set,t;function n(e){let t=e.closest(`p`);if(!t||t.querySelector(`a`)!==e)return;let n=!1,r=e.textContent?.trim()??``;if(r===t.textContent?.trim()&&Pc(r)){let r=t.nextElementSibling,i=r&&!r.matches(`[data-xopc-watermark]`)?r:t.closest(`.markdown-stream-block`)?.nextElementSibling?.firstElementChild;if(i?.matches(`[data-chat-media]`)){let t=i.querySelectorAll(`[data-chat-media-source]`);n=t.length===1&&t[0].dataset.chatMediaSource===e.getAttribute(`href`)}}t.hidden!==n&&(t.hidden=n)}return r=>{if(!r)return;let i=r.closest(`p`),a=r.closest(`.markdown-render-boundary`);if(!(!i||!a))return e.add(r),n(r),t||(t=new MutationObserver(()=>{for(let t of e)n(t)}),t.observe(a,{subtree:!0,childList:!0,characterData:!0,attributeFilter:[`href`,`data-chat-media`,`data-chat-media-source`]})),()=>{e.delete(r),i.hidden&&=!1,e.size||(t?.disconnect(),t=void 0)}}}var Ic={abandonedHeadElementChild:{reason:`Unexpected metadata element after head`,description:"Unexpected element after head. Expected the element before `</head>`",url:!1},abruptClosingOfEmptyComment:{reason:`Unexpected abruptly closed empty comment`,description:"Unexpected `>` or `->`. Expected `-->` to close comments"},abruptDoctypePublicIdentifier:{reason:`Unexpected abruptly closed public identifier`,description:"Unexpected `>`. Expected a closing `\"` or `'` after the public identifier"},abruptDoctypeSystemIdentifier:{reason:`Unexpected abruptly closed system identifier`,description:"Unexpected `>`. Expected a closing `\"` or `'` after the identifier identifier"},absenceOfDigitsInNumericCharacterReference:{reason:`Unexpected non-digit at start of numeric character reference`,description:"Unexpected `%c`. Expected `[0-9]` for decimal references or `[0-9a-fA-F]` for hexadecimal references"},cdataInHtmlContent:{reason:`Unexpected CDATA section in HTML`,description:"Unexpected `<![CDATA[` in HTML. Remove it, use a comment, or encode special characters instead"},characterReferenceOutsideUnicodeRange:{reason:`Unexpected too big numeric character reference`,description:`Unexpectedly high character reference. Expected character references to be at most hexadecimal 10ffff (or decimal 1114111)`},closingOfElementWithOpenChildElements:{reason:`Unexpected closing tag with open child elements`,description:`Unexpectedly closing tag. Expected other tags to be closed first`,url:!1},controlCharacterInInputStream:{reason:`Unexpected control character`,description:"Unexpected control character `%x`. Expected a non-control code point, 0x00, or ASCII whitespace"},controlCharacterReference:{reason:`Unexpected control character reference`,description:`Unexpectedly control character in reference. Expected a non-control code point, 0x00, or ASCII whitespace`},disallowedContentInNoscriptInHead:{reason:"Disallowed content inside `<noscript>` in `<head>`",description:"Unexpected text character `%c`. Only use text in `<noscript>`s in `<body>`",url:!1},duplicateAttribute:{reason:`Unexpected duplicate attribute`,description:`Unexpectedly double attribute. Expected attributes to occur only once`},endTagWithAttributes:{reason:`Unexpected attribute on closing tag`,description:"Unexpected attribute. Expected `>` instead"},endTagWithTrailingSolidus:{reason:`Unexpected slash at end of closing tag`,description:"Unexpected `%c-1`. Expected `>` instead"},endTagWithoutMatchingOpenElement:{reason:`Unexpected unopened end tag`,description:`Unexpected end tag. Expected no end tag or another end tag`,url:!1},eofBeforeTagName:{reason:`Unexpected end of file`,description:`Unexpected end of file. Expected tag name instead`},eofInCdata:{reason:`Unexpected end of file in CDATA`,description:"Unexpected end of file. Expected `]]>` to close the CDATA"},eofInComment:{reason:`Unexpected end of file in comment`,description:"Unexpected end of file. Expected `-->` to close the comment"},eofInDoctype:{reason:`Unexpected end of file in doctype`,description:"Unexpected end of file. Expected a valid doctype (such as `<!doctype html>`)"},eofInElementThatCanContainOnlyText:{reason:`Unexpected end of file in element that can only contain text`,description:`Unexpected end of file. Expected text or a closing tag`,url:!1},eofInScriptHtmlCommentLikeText:{reason:`Unexpected end of file in comment inside script`,description:"Unexpected end of file. Expected `-->` to close the comment"},eofInTag:{reason:`Unexpected end of file in tag`,description:"Unexpected end of file. Expected `>` to close the tag"},incorrectlyClosedComment:{reason:`Incorrectly closed comment`,description:"Unexpected `%c-1`. Expected `-->` to close the comment"},incorrectlyOpenedComment:{reason:`Incorrectly opened comment`,description:"Unexpected `%c`. Expected `<!--` to open the comment"},invalidCharacterSequenceAfterDoctypeName:{reason:`Invalid sequence after doctype name`,description:"Unexpected sequence at `%c`. Expected `public` or `system`"},invalidFirstCharacterOfTagName:{reason:`Invalid first character in tag name`,description:"Unexpected `%c`. Expected an ASCII letter instead"},misplacedDoctype:{reason:`Misplaced doctype`,description:`Unexpected doctype. Expected doctype before head`,url:!1},misplacedStartTagForHeadElement:{reason:"Misplaced `<head>` start tag",description:"Unexpected start tag `<head>`. Expected `<head>` directly after doctype",url:!1},missingAttributeValue:{reason:`Missing attribute value`,description:"Unexpected `%c-1`. Expected an attribute value or no `%c-1` instead"},missingDoctype:{reason:`Missing doctype before other content`,description:"Expected a `<!doctype html>` before anything else",url:!1},missingDoctypeName:{reason:`Missing doctype name`,description:"Unexpected doctype end at `%c`. Expected `html` instead"},missingDoctypePublicIdentifier:{reason:`Missing public identifier in doctype`,description:"Unexpected `%c`. Expected identifier for `public` instead"},missingDoctypeSystemIdentifier:{reason:`Missing system identifier in doctype`,description:'Unexpected `%c`. Expected identifier for `system` instead (suggested: `"about:legacy-compat"`)'},missingEndTagName:{reason:`Missing name in end tag`,description:"Unexpected `%c`. Expected an ASCII letter instead"},missingQuoteBeforeDoctypePublicIdentifier:{reason:`Missing quote before public identifier in doctype`,description:"Unexpected `%c`. Expected `\"` or `'` instead"},missingQuoteBeforeDoctypeSystemIdentifier:{reason:`Missing quote before system identifier in doctype`,description:"Unexpected `%c`. Expected `\"` or `'` instead"},missingSemicolonAfterCharacterReference:{reason:`Missing semicolon after character reference`,description:"Unexpected `%c`. Expected `;` instead"},missingWhitespaceAfterDoctypePublicKeyword:{reason:`Missing whitespace after public identifier in doctype`,description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceAfterDoctypeSystemKeyword:{reason:`Missing whitespace after system identifier in doctype`,description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceBeforeDoctypeName:{reason:`Missing whitespace before doctype name`,description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceBetweenAttributes:{reason:`Missing whitespace between attributes`,description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers:{reason:`Missing whitespace between public and system identifiers in doctype`,description:"Unexpected `%c`. Expected ASCII whitespace instead"},nestedComment:{reason:`Unexpected nested comment`,description:"Unexpected `<!--`. Expected `-->`"},nestedNoscriptInHead:{reason:"Unexpected nested `<noscript>` in `<head>`",description:"Unexpected `<noscript>`. Expected a closing tag or a meta element",url:!1},nonConformingDoctype:{reason:`Unexpected non-conforming doctype declaration`,description:'Expected `<!doctype html>` or `<!doctype html system "about:legacy-compat">`',url:!1},nonVoidHtmlElementStartTagWithTrailingSolidus:{reason:`Unexpected trailing slash on start tag of non-void element`,description:"Unexpected `/`. Expected `>` instead"},noncharacterCharacterReference:{reason:`Unexpected noncharacter code point referenced by character reference`,description:`Unexpected code point. Do not use noncharacters in HTML`},noncharacterInInputStream:{reason:`Unexpected noncharacter character`,description:"Unexpected code point `%x`. Do not use noncharacters in HTML"},nullCharacterReference:{reason:`Unexpected NULL character referenced by character reference`,description:`Unexpected code point. Do not use NULL characters in HTML`},openElementsLeftAfterEof:{reason:`Unexpected end of file`,description:`Unexpected end of file. Expected closing tag instead`,url:!1},surrogateCharacterReference:{reason:`Unexpected surrogate character referenced by character reference`,description:`Unexpected code point. Do not use lone surrogate characters in HTML`},surrogateInInputStream:{reason:`Unexpected surrogate character`,description:"Unexpected code point `%x`. Do not use lone surrogate characters in HTML"},unexpectedCharacterAfterDoctypeSystemIdentifier:{reason:`Invalid character after system identifier in doctype`,description:"Unexpected character at `%c`. Expected `>`"},unexpectedCharacterInAttributeName:{reason:`Unexpected character in attribute name`,description:"Unexpected `%c`. Expected whitespace, `/`, `>`, `=`, or probably an ASCII letter"},unexpectedCharacterInUnquotedAttributeValue:{reason:`Unexpected character in unquoted attribute value`,description:"Unexpected `%c`. Quote the attribute value to include it"},unexpectedEqualsSignBeforeAttributeName:{reason:`Unexpected equals sign before attribute name`,description:"Unexpected `%c`. Add an attribute name before it"},unexpectedNullCharacter:{reason:`Unexpected NULL character`,description:"Unexpected code point `%x`. Do not use NULL characters in HTML"},unexpectedQuestionMarkInsteadOfTagName:{reason:`Unexpected question mark instead of tag name`,description:"Unexpected `%c`. Expected an ASCII letter instead"},unexpectedSolidusInTag:{reason:`Unexpected slash in tag`,description:"Unexpected `%c-1`. Expected it followed by `>` or in a quoted attribute value"},unknownNamedCharacterReference:{reason:`Unexpected unknown named character reference`,description:`Unexpected character reference. Expected known named character references`}},Lc=`https://html.spec.whatwg.org/multipage/parsing.html#parse-error-`,Rc=/-[a-z]/g,zc=/%c(?:([-+])(\d+))?/g,Bc=/%x/g,Vc={2:!0,1:!1,0:null},Hc={};function Uc(e,t){let n=t||Hc,r=n.onerror,i=e instanceof Bi?e:new Bi(e),a=n.fragment?Vi:ra,o=String(i);return na(a(o,{sourceCodeLocationInfo:!0,onParseError:n.onerror?s:null,scriptingEnabled:!1}),{file:i,space:n.space,verbose:n.verbose});function s(e){let t=e.code,a=Wc(t),s=n[a]??!0,c=typeof s==`number`?s:+!!s;if(c){let n=Ic[a],o=new ea(l(n.reason),{place:{start:{line:e.startLine,column:e.startCol,offset:e.startOffset},end:{line:e.endLine,column:e.endCol,offset:e.endOffset}},ruleId:t,source:`hast-util-from-html`});i.path&&(o.file=i.path,o.name=i.path+`:`+o.name),o.fatal=Vc[c],o.note=l(n.description),o.url=n.url===!1?void 0:Lc+t,r(o)}function l(t){return t.replace(zc,n).replace(Bc,r);function n(t,n,r){let i=(r?Number.parseInt(r,10):0)*(n===`-`?-1:1);return Kc(o.charAt(e.startOffset+i))}function r(){return qc(o.charCodeAt(e.startOffset))}}}}function Wc(e){return e.replace(Rc,Gc)}function Gc(e){return e.charAt(1).toUpperCase()}function Kc(e){return e==="`"?"` ` `":e}function qc(e){return`0x`+e.toString(16).toUpperCase()}function Jc(e={streaming:!1}){return t=>{let n=0;Gi(t,`element`,(t,r)=>{if(t.tagName!==`code`||typeof t.properties[`data-xopc-math-source`]!=`string`)return;let i=yt(t.properties[`data-xopc-math-source`]);if(!i)return;let a=Uc(_t(i,e,++n>(e.maxCount??256)),{fragment:!0}).children[0],o=r.at(-1),s=r.at(-2);if(!(!o||!a))return o.type===`element`&&o.tagName===`pre`&&s?s.children.splice(s.children.indexOf(o),1,a):o.children.splice(o.children.indexOf(t),1,a),Ki})}}var Yc={carriageReturn:-5,lineFeed:-4,carriageReturnLineFeed:-3,horizontalTab:-2,virtualSpace:-1,eof:null,nul:0,soh:1,stx:2,etx:3,eot:4,enq:5,ack:6,bel:7,bs:8,ht:9,lf:10,vt:11,ff:12,cr:13,so:14,si:15,dle:16,dc1:17,dc2:18,dc3:19,dc4:20,nak:21,syn:22,etb:23,can:24,em:25,sub:26,esc:27,fs:28,gs:29,rs:30,us:31,space:32,exclamationMark:33,quotationMark:34,numberSign:35,dollarSign:36,percentSign:37,ampersand:38,apostrophe:39,leftParenthesis:40,rightParenthesis:41,asterisk:42,plusSign:43,comma:44,dash:45,dot:46,slash:47,digit0:48,digit1:49,digit2:50,digit3:51,digit4:52,digit5:53,digit6:54,digit7:55,digit8:56,digit9:57,colon:58,semicolon:59,lessThan:60,equalsTo:61,greaterThan:62,questionMark:63,atSign:64,uppercaseA:65,uppercaseB:66,uppercaseC:67,uppercaseD:68,uppercaseE:69,uppercaseF:70,uppercaseG:71,uppercaseH:72,uppercaseI:73,uppercaseJ:74,uppercaseK:75,uppercaseL:76,uppercaseM:77,uppercaseN:78,uppercaseO:79,uppercaseP:80,uppercaseQ:81,uppercaseR:82,uppercaseS:83,uppercaseT:84,uppercaseU:85,uppercaseV:86,uppercaseW:87,uppercaseX:88,uppercaseY:89,uppercaseZ:90,leftSquareBracket:91,backslash:92,rightSquareBracket:93,caret:94,underscore:95,graveAccent:96,lowercaseA:97,lowercaseB:98,lowercaseC:99,lowercaseD:100,lowercaseE:101,lowercaseF:102,lowercaseG:103,lowercaseH:104,lowercaseI:105,lowercaseJ:106,lowercaseK:107,lowercaseL:108,lowercaseM:109,lowercaseN:110,lowercaseO:111,lowercaseP:112,lowercaseQ:113,lowercaseR:114,lowercaseS:115,lowercaseT:116,lowercaseU:117,lowercaseV:118,lowercaseW:119,lowercaseX:120,lowercaseY:121,lowercaseZ:122,leftCurlyBrace:123,verticalBar:124,rightCurlyBrace:125,tilde:126,del:127,byteOrderMarker:65279,replacementCharacter:65533},Xc={attentionSideAfter:2,attentionSideBefore:1,atxHeadingOpeningFenceSizeMax:6,autolinkDomainSizeMax:63,autolinkSchemeSizeMax:32,cdataOpeningString:`CDATA[`,characterGroupPunctuation:2,characterGroupWhitespace:1,characterReferenceDecimalSizeMax:7,characterReferenceHexadecimalSizeMax:6,characterReferenceNamedSizeMax:31,codeFencedSequenceSizeMin:3,contentTypeContent:`content`,contentTypeDocument:`document`,contentTypeFlow:`flow`,contentTypeString:`string`,contentTypeText:`text`,hardBreakPrefixSizeMin:2,htmlBasic:6,htmlCdata:5,htmlComment:2,htmlComplete:7,htmlDeclaration:4,htmlInstruction:3,htmlRawSizeMax:8,htmlRaw:1,linkResourceDestinationBalanceMax:32,linkReferenceSizeMax:999,listItemValueSizeMax:10,numericBaseDecimal:10,numericBaseHexadecimal:16,tabSize:4,thematicBreakMarkerCountMin:3,v8MaxSafeChunkSize:1e4},Zc={data:`data`,whitespace:`whitespace`,lineEnding:`lineEnding`,lineEndingBlank:`lineEndingBlank`,linePrefix:`linePrefix`,lineSuffix:`lineSuffix`,atxHeading:`atxHeading`,atxHeadingSequence:`atxHeadingSequence`,atxHeadingText:`atxHeadingText`,autolink:`autolink`,autolinkEmail:`autolinkEmail`,autolinkMarker:`autolinkMarker`,autolinkProtocol:`autolinkProtocol`,characterEscape:`characterEscape`,characterEscapeValue:`characterEscapeValue`,characterReference:`characterReference`,characterReferenceMarker:`characterReferenceMarker`,characterReferenceMarkerNumeric:`characterReferenceMarkerNumeric`,characterReferenceMarkerHexadecimal:`characterReferenceMarkerHexadecimal`,characterReferenceValue:`characterReferenceValue`,codeFenced:`codeFenced`,codeFencedFence:`codeFencedFence`,codeFencedFenceSequence:`codeFencedFenceSequence`,codeFencedFenceInfo:`codeFencedFenceInfo`,codeFencedFenceMeta:`codeFencedFenceMeta`,codeFlowValue:`codeFlowValue`,codeIndented:`codeIndented`,codeText:`codeText`,codeTextData:`codeTextData`,codeTextPadding:`codeTextPadding`,codeTextSequence:`codeTextSequence`,content:`content`,definition:`definition`,definitionDestination:`definitionDestination`,definitionDestinationLiteral:`definitionDestinationLiteral`,definitionDestinationLiteralMarker:`definitionDestinationLiteralMarker`,definitionDestinationRaw:`definitionDestinationRaw`,definitionDestinationString:`definitionDestinationString`,definitionLabel:`definitionLabel`,definitionLabelMarker:`definitionLabelMarker`,definitionLabelString:`definitionLabelString`,definitionMarker:`definitionMarker`,definitionTitle:`definitionTitle`,definitionTitleMarker:`definitionTitleMarker`,definitionTitleString:`definitionTitleString`,emphasis:`emphasis`,emphasisSequence:`emphasisSequence`,emphasisText:`emphasisText`,escapeMarker:`escapeMarker`,hardBreakEscape:`hardBreakEscape`,hardBreakTrailing:`hardBreakTrailing`,htmlFlow:`htmlFlow`,htmlFlowData:`htmlFlowData`,htmlText:`htmlText`,htmlTextData:`htmlTextData`,image:`image`,label:`label`,labelText:`labelText`,labelLink:`labelLink`,labelImage:`labelImage`,labelMarker:`labelMarker`,labelImageMarker:`labelImageMarker`,labelEnd:`labelEnd`,link:`link`,paragraph:`paragraph`,reference:`reference`,referenceMarker:`referenceMarker`,referenceString:`referenceString`,resource:`resource`,resourceDestination:`resourceDestination`,resourceDestinationLiteral:`resourceDestinationLiteral`,resourceDestinationLiteralMarker:`resourceDestinationLiteralMarker`,resourceDestinationRaw:`resourceDestinationRaw`,resourceDestinationString:`resourceDestinationString`,resourceMarker:`resourceMarker`,resourceTitle:`resourceTitle`,resourceTitleMarker:`resourceTitleMarker`,resourceTitleString:`resourceTitleString`,setextHeading:`setextHeading`,setextHeadingText:`setextHeadingText`,setextHeadingLine:`setextHeadingLine`,setextHeadingLineSequence:`setextHeadingLineSequence`,strong:`strong`,strongSequence:`strongSequence`,strongText:`strongText`,thematicBreak:`thematicBreak`,thematicBreakSequence:`thematicBreakSequence`,blockQuote:`blockQuote`,blockQuotePrefix:`blockQuotePrefix`,blockQuoteMarker:`blockQuoteMarker`,blockQuotePrefixWhitespace:`blockQuotePrefixWhitespace`,listOrdered:`listOrdered`,listUnordered:`listUnordered`,listItemIndent:`listItemIndent`,listItemMarker:`listItemMarker`,listItemPrefix:`listItemPrefix`,listItemPrefixWhitespace:`listItemPrefixWhitespace`,listItemValue:`listItemValue`,chunkDocument:`chunkDocument`,chunkContent:`chunkContent`,chunkFlow:`chunkFlow`,chunkText:`chunkText`,chunkString:`chunkString`},Qc=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],$c=[12288,12288,65281,65376,65504,65510],el=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],tl=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],nl=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],rl=(e,t)=>{let n=0,r=Math.floor(e.length/2)-1;for(;n<=r;){let i=Math.floor((n+r)/2),a=i*2;if(t<e[a])r=i-1;else if(t>e[a+1])n=i+1;else return!0}return!1},il=19968,[al,ol]=sl(nl);function sl(e){let t=e[0],n=e[1];for(let r=0;r<e.length;r+=2){let i=e[r],a=e[r+1];if(il>=i&&il<=a)return[i,a];a-i>n-t&&(t=i,n=a)}return[t,n]}var cl=e=>e<161||e>1114109?!1:rl(Qc,e),ll=e=>e<12288||e>65510?!1:rl($c,e),ul=e=>e<8361||e>65518?!1:rl(el,e),dl=e=>e<32||e>10630?!1:rl(tl,e),fl=e=>e>=al&&e<=ol?!0:e<4352||e>262141?!1:rl(nl,e);function pl(e){return cl(e)?`ambiguous`:ll(e)?`fullwidth`:ul(e)?`halfwidth`:dl(e)?`narrow`:fl(e)?`wide`:`neutral`}function ml(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function hl(e){return ml(e),pl(e)}function gl(e){return/^\p{Emoji_Presentation}/u.test(String.fromCodePoint(e))}function _l(e){if(!e||e<4352)return!1;switch(hl(e)){case`fullwidth`:case`halfwidth`:return!0;case`wide`:return!gl(e);case`narrow`:return!1;case`ambiguous`:return 917760<=e&&e<=917999&&null;case`neutral`:return/^\p{sc=Hangul}/u.test(String.fromCodePoint(e))}}function vl(e,t){return t!==65025||!e||e<8216?!1:e===8216||e===8217||e===8220||e===8221}function yl(e){return e!==null&&e>=65024&&e<=65038}var bl=Sl(/\p{P}|\p{S}/u),xl=Sl(/\s/);function Sl(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCodePoint(t))}}function Cl(e){return!!(e&Xc.characterGroupWhitespace)}function wl(e){return(e&Al.cjkPunctuation)===Xc.characterGroupPunctuation}function Tl(e){return!!(e&Al.cjk)}function El(e){return e===Al.ivs}function Dl(e){return!!(e&Al.cjkOrIvs)}function Ol(e){return e===Al.nonEmojiGeneralUseVS}function kl(e){return!!(e&Al.spaceOrPunctuation)}var Al;(function(e){e.spaceOrPunctuation=3,e.cjk=4096,e.cjkPunctuation=4098,e.ivs=8192,e.cjkOrIvs=12288,e.nonEmojiGeneralUseVS=16384,e.variationSelector=24576,e.ivsToCjkRightShift=1})(Al||={});function jl(e){if(e===Yc.eof||zi(e)||xl(e))return Xc.characterGroupWhitespace;let t=0;if(e>=4352){if(yl(e))return Al.nonEmojiGeneralUseVS;switch(_l(e)){case null:return Al.ivs;case!0:t|=Al.cjk;break}}return bl(e)&&(t|=Xc.characterGroupPunctuation),t}function Ml(e,t,n){if(!Ol(e))return e;let r=t(),i=jl(r);return!r||Cl(i)?e:vl(r,n)?Al.cjkPunctuation:Nl(i)}function Nl(e){return e&~Al.ivs}function Pl(e){return!!(e&&e>=55296&&e<=56319)}function Fl(e){return!!(e&&e>=56320&&e<=57343)}function Il(e,t,n){if(t._bufferIndex<2)return e;let r=n({start:{...t,_bufferIndex:t._bufferIndex-2},end:t}).codePointAt(0);return r&&r>=65536?r:e}function Ll(e,t,n){let r=e>=65536?2:1;if(t._bufferIndex<1+r)return null;let i=t._bufferIndex-r-2,a=n({start:{...t,_bufferIndex:i>=0?i:0},end:{...t,_bufferIndex:t._bufferIndex-r}}),o=a.charCodeAt(a.length-1);if(Number.isNaN(o))return null;if(a.length<2||o<56320||57343<o)return o;let s=a.codePointAt(0);return s&&s>=65536?s:o}var Rl=class{cachedValue=void 0;constructor(e,t,n){this.previousCode=e,this.nowPoint=t,this.sliceSerialize=n}value(){return this.cachedValue===void 0&&(this.cachedValue=Ll(this.previousCode,this.nowPoint,this.sliceSerialize)),this.cachedValue}};function zl(e,t,n){let r=n({start:t,end:{...t,_bufferIndex:t._bufferIndex+2}}).codePointAt(0);return r&&r>=65536?r:e}var Bl={name:`attention`,resolveAll:Vl,tokenize:Hl};function Vl(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};Ul(d,-c),Ul(f,c),o={type:c>1?Zc.strongSequence:Zc.emphasisSequence,start:d,end:{...e[r][1].end}},s={type:c>1?Zc.strongSequence:Zc.emphasisSequence,start:{...e[n][1].start},end:f},a={type:c>1?Zc.strongText:Zc.emphasisText,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?Zc.strong:Zc.emphasis,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=Ri(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=Ri(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),t.parser.constructs.insideSpan.null,l=Ri(l,ta(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=Ri(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=Ri(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,Li(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function Hl(e,t){let n=this.parser.constructs.attentionMarkers.null,{now:r,sliceSerialize:i,previous:a}=this,o=Fl(a)?Il(a,r(),i):a,s=jl(o),c=new Rl(o,r(),i),l=Ml(s,c.value.bind(c),o),u;return d;function d(t){return t===Yc.asterisk||Yc.underscore,u=t,e.enter(`attentionSequence`),f(t)}function f(a){if(a===u)return e.consume(a),f;let s=e.exit(`attentionSequence`),c=jl(Pl(a)?zl(a,r(),i):a),d=wl(l),p=o===Yc.asterisk||o===Yc.underscore,m=d||Cl(l)||p,h=wl(c),g=a===Yc.asterisk||a===Yc.underscore,_=h||Cl(c)||g,v=Dl(l),y=!_||h&&(m||v)||n.includes(a)&&a!==Yc.asterisk&&a!==Yc.underscore,b=!m||d&&(_||Tl(c))||n.includes(o)&&o!==Yc.asterisk&&o!==Yc.underscore;return s._open=!!(u===Yc.asterisk?y:y&&(kl(l)||!b)),s._close=!!(u===Yc.asterisk?b:b&&(kl(c)||!y)),t(a)}}function Ul(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}function Wl(){return{text:{[Yc.asterisk]:Bl,[Yc.underscore]:Bl},insideSpan:{null:[Bl]}}}function Gl(){let e=this.data();(e.micromarkExtensions||=[]).push(Wl())}var Kl=`;`.codePointAt(0)??Yc.eof,ql=`&`.codePointAt(0)??Yc.eof;function Jl(){return{handlers:{emphasis:Yl,strong:Xl,text:eu}}}Yl.peek=Zl,Xl.peek=Ql;function Yl(e,t,n,r){return $l(e,t,n,r,Zl(e,t,n),1)}function Xl(e,t,n,r){return $l(e,t,n,r,Ql(e,t,n),2)}function Zl(e,t,n){return n.options.emphasis||`*`}function Ql(e,t,n){return n.options.strong||`*`}function $l(e,t,n,r,i,a){let o=i.repeat(a),s=n.enter(a===1?`emphasis`:`strong`),c=n.createTracker(r),l=c.move(o),u=c.move(n.containerPhrasing(e,{after:i,before:l,...c.current()})),d=cu(e,t,n,r.before),f=lu(e,t,n,r.after),p=tu(d,xu(u),i,`open`);p.inside&&u&&(u=vu(u));let m=tu({current:Su(u),previous:bu(u)},f,i,`close`);m.inside&&u&&(u=yu(u));let h=c.move(o);s();let g=m.outside&&mu(t,n);return n.attentionEncodeSurroundingInfo={after:m.outside&&!g,before:p.outside},hu(n).cjkFriendlyEncodeAfterSupplementaryText=g,l+u+h}function eu(e,t,n,r){let i=hu(n);if(!i.cjkFriendlyEncodeAfterSupplementaryText)return n.safe(e.value,r);i.cjkFriendlyEncodeAfterSupplementaryText=!1;let[a=``]=[...e.value],o=e.value.slice(a.length);return`${_u(a.codePointAt(0)??Yc.eof)}${n.safe(o,{...r,before:`;`})}`}function tu(e,t,n,r){let i=su(e),a=jl(t);if(!Dl(i)&&!Dl(a))return r===`open`?nu(i,a,n):nu(a,i,n);let o={inside:!1,outside:!1},s={inside:!0,outside:!1},c={inside:!1,outside:!0},l={inside:!0,outside:!0};for(let i of[o,s,c,l]){let a=r===`open`?i.outside?Cu:e:i.inside?Cu:e,o=r===`open`?i.inside?wu:t:i.outside?wu:t;if(r===`open`?ru(n,a,o):iu(n,a,o))return i}return l}function nu(e,t,n){return ou(e)?ou(t)?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:Cl(t)?{inside:!0,outside:!0}:{inside:!1,outside:!0}:Cl(e)?ou(t)?{inside:!1,outside:!1}:Cl(t)?{inside:!0,outside:!0}:{inside:!1,outside:!1}:Cl(t)?{inside:!0,outside:!1}:{inside:!1,outside:!1}}function ru(e,t,n){let r=su(t),{close:i,open:a}=au(r,jl(n));return e===`_`?a&&(kl(r)||!i):a}function iu(e,t,n){let r=jl(n),{close:i,open:a}=au(su(t),r);return e===`_`?i&&(kl(r)||!a):i}function au(e,t){let n=wl(e),r=n||Cl(e),i=wl(t),a=i||Cl(t);return{open:!a||i&&(r||Dl(e)),close:!r||n&&(a||Tl(t))}}function ou(e){return!Cl(e)&&!wl(e)}function su(e){let t=jl(e.current);return e.current===null||!Ol(t)?t:Ml(t,()=>e.previous,e.current)}function cu(e,t,n,r){let i=Su(r),a=bu(r);if(uu(i)||fu(i,a)){let r=pu(e,t,n,-1);r&&(i=Su(r),a=bu(r))}return{current:i,previous:a}}function lu(e,t,n,r){let i=xu(r);if(!du(i))return i;let a=pu(e,t,n,1);return a?xu(a):i}function uu(e){return e!==null&&56320<=e&&e<=57343}function du(e){return e!==null&&55296<=e&&e<=56319}function fu(e,t){return Ol(jl(e))&&(t===null||t===Yc.eof)}function pu(e,t,n,r){if(!t)return;let i=n.indexStack.at(-1),a=t.children,o=typeof i==`number`?i:a.indexOf(e);if(o<0)return;let s=a[o+r];return gu(s)||void 0}function mu(e,t){if(!e)return!1;let n=t.indexStack.at(-1);if(typeof n!=`number`)return!1;let r=e.children[n+1];return r?.type===`text`&&(xu(r.value)??0)>65535}function hu(e){return e}function gu(e){return!e||typeof e!=`object`?``:`value`in e&&typeof e.value==`string`?e.value:`alt`in e&&typeof e.alt==`string`?e.alt:`children`in e&&Array.isArray(e.children)?e.children.map(gu).join(``):``}function _u(e){return`&#x${(e??0).toString(16).toUpperCase()};`}function vu(e){let[t=``]=[...e];return _u(t.codePointAt(0)??Yc.eof)+e.slice(t.length)}function yu(e){let t=[...e],n=t.pop();return`${t.join(``)}${_u(n?.codePointAt(0)??Yc.eof)}`}function bu(e){let t=[...e];return t.pop(),t.at(-1)?.codePointAt(0)??Yc.eof}function xu(e){return e.codePointAt(0)??Yc.eof}function Su(e){return[...e].at(-1)?.codePointAt(0)??Yc.eof}var Cu={current:Kl,previous:Yc.eof},wu=ql;function Tu(){let e=this.data();(e.toMarkdownExtensions||=[]).push(Jl())}function Eu(){Gl.call(this),Tu.call(this)}var Du=Eu;function Ou(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{[Yc.tilde]:n},insideSpan:{null:[n]},attentionMarkers:{null:[Yc.tilde]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&Li(o,o.length,0,ta(s,e.slice(r+1,n),t)),Li(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),Li(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=Zc.data);return e}function i(e,n,r){let{now:i,sliceSerialize:a,previous:o}=this,s=Fl(o)?Il(o,i(),a):o,c=jl(s),l=new Rl(s,i(),a),u=Ml(c,l.value.bind(l),s),d=this.events,f=0;return p;function p(t){return Yc.tilde,s===Yc.tilde&&d[d.length-1][1].type!==Zc.characterEscape?r(t):(e.enter(`strikethroughSequenceTemporary`),m(t))}function m(o){let c=jl(s);if(o===Yc.tilde)return f>1?r(o):(e.consume(o),f++,m);if(f<2&&!t)return r(o);let l=e.exit(`strikethroughSequenceTemporary`),d=jl(Pl(o)?zl(o,i(),a):o),p=wl(u)||Cl(u),h=wl(d)||Cl(d),g=Tl(u)||El(c);return l._open=!h||d===Xc.attentionSideAfter&&(p||g),l._close=!p||c===Xc.attentionSideAfter&&(h||Tl(d)),n(o)}}}function ku(e){let t=this.data();(t.micromarkExtensions||=[]).push(Ou(e))}var Au=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`],ju=`;`.codePointAt(0)??Yc.eof,Mu=`&`.codePointAt(0)??Yc.eof;function Nu(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:Au}],handlers:{delete:Pu,text:Fu}}}Pu.peek=Iu;function Pu(e,t,n,r){let i=n.enter(`strikethrough`),a=n.createTracker(r),o=a.move(`~~`),s=a.move(n.containerPhrasing(e,{after:`~`,before:o,...a.current()})),c=Wu(e,t,n,r.before),l=Gu(e,t,n,r.after),u=Lu(c,rd(s),`open`);u.inside&&s&&(s=ed(s));let d=Lu({current:id(s),previous:nd(s)},l,`close`);d.inside&&s&&(s=td(s));let f=a.move(`~~`);i();let p=d.outside&&Xu(t,n);return n.attentionEncodeSurroundingInfo={after:d.outside&&!p,before:u.outside},Zu(n).cjkFriendlyEncodeAfterSupplementaryText=p,o+s+f}function Fu(e,t,n,r){let i=Zu(n);if(!i.cjkFriendlyEncodeAfterSupplementaryText)return n.safe(e.value,r);i.cjkFriendlyEncodeAfterSupplementaryText=!1;let[a=``]=[...e.value],o=e.value.slice(a.length);return`${$u(a.codePointAt(0)??Yc.eof)}${n.safe(o,{...r,before:`;`})}`}function Iu(){return`~`}function Lu(e,t,n){let r=Uu(e),i=jl(t);if(!Dl(r)&&!Dl(i))return n===`open`?Ru(r,i):Ru(i,r);let a={inside:!1,outside:!1},o={inside:!0,outside:!1},s={inside:!1,outside:!0},c={inside:!0,outside:!0};for(let r of[a,o,s,c]){let i=n===`open`?r.outside?ad:e:r.inside?ad:e,a=n===`open`?r.inside?od:t:r.outside?od:t;if(n===`open`?zu(i,a):Bu(i,a))return r}return c}function Ru(e,t){return Hu(e)?Hu(t)?{inside:!1,outside:!1}:Cl(t)?{inside:!0,outside:!0}:{inside:!1,outside:!0}:Cl(e)?Hu(t)?{inside:!1,outside:!1}:Cl(t)?{inside:!0,outside:!0}:{inside:!1,outside:!1}:Cl(t)?{inside:!0,outside:!1}:{inside:!1,outside:!1}}function zu(e,t){let{open:n}=Vu(Uu(e),jl(t));return n}function Bu(e,t){let n=jl(t),{close:r}=Vu(Uu(e),n);return r}function Vu(e,t){let n=wl(e),r=n||Cl(e),i=wl(t),a=i||Cl(t);return{open:!a||i&&(r||Dl(e)),close:!r||n&&(a||Tl(t))}}function Hu(e){return!Cl(e)&&!wl(e)}function Uu(e){let t=jl(e.current);return e.current===null||!Ol(t)?t:Ml(t,()=>e.previous,e.current)}function Wu(e,t,n,r){let i=id(r),a=nd(r);if(Ku(i)||Ju(i,a)){let r=Yu(e,t,n,-1);r&&(i=id(r),a=nd(r))}return{current:i,previous:a}}function Gu(e,t,n,r){let i=rd(r);if(!qu(i))return i;let a=Yu(e,t,n,1);return a?rd(a):i}function Ku(e){return e!==null&&56320<=e&&e<=57343}function qu(e){return e!==null&&55296<=e&&e<=56319}function Ju(e,t){return Ol(jl(e))&&(t===null||t===Yc.eof)}function Yu(e,t,n,r){if(!t)return;let i=n.indexStack.at(-1),a=t.children,o=typeof i==`number`?i:a.indexOf(e);if(o<0)return;let s=a[o+r];return Qu(s)||void 0}function Xu(e,t){if(!e)return!1;let n=t.indexStack.at(-1);if(typeof n!=`number`)return!1;let r=e.children[n+1];return r?.type===`text`&&(rd(r.value)??0)>65535}function Zu(e){return e}function Qu(e){return!e||typeof e!=`object`?``:`value`in e&&typeof e.value==`string`?e.value:`alt`in e&&typeof e.alt==`string`?e.alt:`children`in e&&Array.isArray(e.children)?e.children.map(Qu).join(``):``}function $u(e){return`&#x${(e??0).toString(16).toUpperCase()};`}function ed(e){let[t=``]=[...e];return $u(t.codePointAt(0)??Yc.eof)+e.slice(t.length)}function td(e){let t=[...e],n=t.pop();return`${t.join(``)}${$u(n?.codePointAt(0)??Yc.eof)}`}function nd(e){let t=[...e];return t.pop(),t.at(-1)?.codePointAt(0)??Yc.eof}function rd(e){return e.codePointAt(0)??Yc.eof}function id(e){return[...e].at(-1)?.codePointAt(0)??Yc.eof}var ad={current:ju,previous:Yc.eof},od=Mu;function sd(){let e=this.data();(e.toMarkdownExtensions||=[]).push(Nu())}function cd(e){ku.call(this,e),sd.call(this)}var ld=cd,ud=new Set([`。`,`.`,`,`,`、`,`?`,`!`,`:`,`;`,`(`,`)`,`【`,`】`,`「`,`」`,`『`,`』`,`〈`,`〉`,`《`,`》`]),dd=/^(https?:\/\/|mailto:|www\.)/i,fd=e=>{if(e.children.length!==1)return!1;let t=e.children[0];return t.type===`text`&&t.value===e.url},pd=e=>{let t=0;for(let n of e){if(ud.has(n))return t;t+=n.length}return null},md=(e,t)=>({...t,url:e,children:[{type:`text`,value:e}]}),hd=e=>({type:`text`,value:e}),gd=qi().transforms??[],_d=e=>{let t=[],n=e=>{if(!e)return;let n={type:`paragraph`,children:[hd(e)]};if(dd.exec(e)?.[0]!==e){let e={type:`root`,children:[n]};for(let t of gd)t(e)}t.push(...n.children)},r=0,i=0;for(let t of e)ud.has(t)&&(n(e.slice(r,i)),n(t),r=i+t.length),i+=t.length;return n(e.slice(r)),t},vd=()=>e=>{Xi(e,`link`,(e,t,n)=>{if(!n||typeof t!=`number`||!fd(e)||!dd.test(e.url))return;let r=pd(e.url);if(r===null||r===0)return;let i=[md(e.url.slice(0,r),e),..._d(e.url.slice(r))];return n.children.splice(t,1,...i),t+i.length})};function yd(){let e=[Du],t=[vd,ld];return{name:`cjk`,type:`cjk`,remarkPluginsBefore:e,remarkPluginsAfter:t,remarkPlugins:[...e,...t]}}var bd=yd(),xd=(0,Q.createContext)(new Map);function Sd(e){let t=new Map;for(let{delivery:n}of e){let e=n.primary;if(e?.kind!==`automation`||!e.runId)continue;let r=t.get(e.id)??new Set;r.add(e.runId),t.set(e.id,r)}return new Map([...t].flatMap(([e,t])=>t.size===1?[[e,[...t][0]]]:[]))}function Cd(e){let t=(0,X.c)(50),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({source:o,load:r,onOpen:i,alt:s,className:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=s===void 0?``:s,l=v(Td),u;t[7]===l?u=t[8]:(u=S(l),t[7]=l,t[8]=u);let d=u.chat,{openImage:f}=Re(),[p,m]=(0,Q.useState)(0),[h,g]=(0,Q.useState)(null),[_,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(null),T=(0,Q.useRef)(null),E,D;t[9]!==p||t[10]!==r||t[11]!==o?(E=()=>{if(!r)return;let e=!0,t;return r().then(n=>{e&&(t=URL.createObjectURL(n),g({source:o,url:t,attempt:p}))}).catch(()=>{e&&y(o)}),()=>{e=!1,t&&URL.revokeObjectURL(t)}},D=[o,r,p],t[9]=p,t[10]=r,t[11]=o,t[12]=E,t[13]=D):(E=t[12],D=t[13]),(0,Q.useEffect)(E,D);let O=r?h?.source===o&&h.attempt===p?h.url:void 0:o,k=_===o,A;t[14]===o?A=t[15]:(A=e=>{e.naturalWidth&&(x({source:o,width:e.naturalWidth,height:e.naturalHeight}),w(o))},t[14]=o,t[15]=A);let j=A,M;t[16]===j?M=t[17]:(M=()=>{T.current?.complete&&j(T.current)},t[16]=j,t[17]=M);let N;t[18]===O?N=t[19]:(N=[O],t[18]=O,t[19]=N),(0,Q.useEffect)(M,N);let P=b?.source===o?b:null,F=P?Math.min(1,320/P.width,280/P.height):1,I=C!==o&&!k||void 0,L;t[20]!==F||t[21]!==P?(L=P?{width:P.width*F,aspectRatio:`${P.width} / ${P.height}`}:void 0,t[20]=F,t[21]=P,t[22]=L):L=t[22];let R;t[23]!==k||t[24]!==C||t[25]!==o?(R=C!==o&&!k&&(0,Z.jsx)(Qt,{as:`span`,className:`pointer-events-none absolute inset-0`}),t[23]=k,t[24]=C,t[25]=o,t[26]=R):R=t[26];let z;t[27]!==c||t[28]!==p||t[29]!==n||t[30]!==k||t[31]!==d||t[32]!==j||t[33]!==i||t[34]!==f||t[35]!==a||t[36]!==o||t[37]!==O?(z=!k&&(0,Z.jsx)(`img`,{...a,ref:T,src:O,alt:c,loading:`lazy`,decoding:`async`,"data-chat-image-source":o,title:a.title??d.attachmentPreviewImage,className:[`chat-reading-image`,n].filter(Boolean).join(` `),role:O?`button`:void 0,tabIndex:O?0:void 0,"aria-label":O?`${d.attachmentPreviewImage}${c?`: ${c}`:``}`:void 0,onLoad:e=>j(e.currentTarget),onError:()=>y(o),onClick:e=>{O&&(e.preventDefault(),e.stopPropagation(),i?i():f(O,c))},onKeyDown:e=>{!O||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),e.stopPropagation(),i?i():f(O,c))}},`${o}:${p}`),t[27]=c,t[28]=p,t[29]=n,t[30]=k,t[31]=d,t[32]=j,t[33]=i,t[34]=f,t[35]=a,t[36]=o,t[37]=O,t[38]=z):z=t[38];let B;t[39]!==c||t[40]!==k||t[41]!==d?(B=k&&(0,Z.jsxs)(`span`,{className:`flex min-h-24 flex-col items-start justify-center gap-2 p-3 text-sm text-fg-muted`,role:`status`,children:[(0,Z.jsxs)(`span`,{children:[d.attachmentPreviewLoadError,c?` · ${c}`:``]}),(0,Z.jsx)(`button`,{type:`button`,className:`min-h-11 rounded-md px-2 text-accent-fg focus-visible:outline-2 focus-visible:outline-accent`,onClick:e=>{e.preventDefault(),e.stopPropagation(),y(null),w(null),m(wd)},children:d.userMessageRetry})]}),t[39]=c,t[40]=k,t[41]=d,t[42]=B):B=t[42];let ee;return t[43]!==o||t[44]!==L||t[45]!==R||t[46]!==z||t[47]!==B||t[48]!==I?(ee=(0,Z.jsxs)(`span`,{className:`chat-image-thumbnail`,"data-chat-media-source":o,"data-image-loading":I,style:L,children:[R,z,B]}),t[43]=o,t[44]=L,t[45]=R,t[46]=z,t[47]=B,t[48]=I,t[49]=ee):ee=t[49],ee}function wd(e){return e+1}function Td(e){return e.language}var Ed=class extends Q.Component{state={error:!1,content:this.props.content};static getDerivedStateFromError(){return{error:!0}}static getDerivedStateFromProps(e,t){return e.content===t.content?null:{error:!1,content:e.content}}render(){return this.state.error?(0,Z.jsx)(`div`,{className:`whitespace-pre-wrap break-words`,"data-chat-render-fallback":!0,children:this.props.content}):this.props.children}};function Dd(e){if(/^\s{0,3}\[[^\]]+\]:|\[[^\]]+\]\[[^\]]*\]|\[\^/m.test(e))return[e];let t=Hi(e),n=jc(e);if(!n.length)return t;if(t.join(``)!==e)return[e];let r=[],i=0,a=``;for(let e of t)a+=e,i+=e.length,n.some(e=>e.start<i&&e.end>i)||(r.push(a),a=``);return a&&r.push(a),r}function Od(){let e=``,t=[];return n=>{if(n===e)return t;let r=n.startsWith(e)&&!/\[\^|\]\[/m.test(n)?t.slice(0,-2):[],i=r.reduce((e,t)=>e+t.length,0);return t=[...r,...Dd(n.slice(i))],e=n,t}}function kd(e){let t=(0,X.c)(26),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({node:r,display:a,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a!==void 0&&a,s=v(Ad),c;t[5]===s?c=t[6]:(c=S(s),t[5]=s,t[6]=c);let l=c.chat,[u,d]=(0,Q.useState)(null),f,p;t[7]===u?(f=t[8],p=t[9]):(f=()=>{if(!u)return;let e=window.setTimeout(()=>d(null),2e3);return()=>window.clearTimeout(e)},p=[u],t[7]=u,t[8]=f,t[9]=p),(0,Q.useEffect)(f,p);let m=String(r?.properties.dataXopcMathSource??r?.properties[`data-xopc-math-source`]??``),h;t[10]===m?h=t[11]:(h=yt(m),t[10]=m,t[11]=h);let g=h,_=String(r?.properties.dataXopcMath??r?.properties[`data-xopc-math`]??``),y=_===`pending`?l.mathPending:_===`fallback`?l.mathFailed:void 0,b;t[12]===g?b=t[13]:(b=async e=>{g&&await Oi(e?g.raw:g.latex)&&d(e?`markdown`:`latex`)},t[12]=g,t[13]=b);let x=b,C=o?`div`:`span`,w;t[14]!==u||t[15]!==x||t[16]!==o||t[17]!==l||t[18]!==g?(w=o&&g&&(0,Z.jsxs)(`span`,{className:`markdown-math-actions`,contentEditable:!1,children:[(0,Z.jsx)(`button`,{type:`button`,title:u===`latex`?l.messageCopied:l.mathCopyLatex,"aria-label":l.mathCopyLatex,onClick:()=>void x(!1),dangerouslySetInnerHTML:{__html:ht[u===`latex`?`copied`:`latex`]}}),(0,Z.jsx)(`button`,{type:`button`,title:u===`markdown`?l.messageCopied:l.mathCopyMarkdown,"aria-label":l.mathCopyMarkdown,onClick:()=>void x(!0),dangerouslySetInnerHTML:{__html:ht[u===`markdown`?`copied`:`markdown`]}})]}),t[14]=u,t[15]=x,t[16]=o,t[17]=l,t[18]=g,t[19]=w):w=t[19];let T;return t[20]!==C||t[21]!==n||t[22]!==i||t[23]!==w||t[24]!==y?(T=(0,Z.jsxs)(C,{...i,title:y,children:[n,w]}),t[20]=C,t[21]=n,t[22]=i,t[23]=w,t[24]=y,t[25]=T):T=t[25],T}function Ad(e){return e.language}function jd(e,t,n){if(!t||!n||n<=t)return!1;let r=e.split(/\r?\n/),i=r[t-1]?.match(/(?:^|[\s>])(`{3,}|~{3,})chart(?:\s|$)/)?.[1];if(!i)return!1;let a=r[n-1]?.match(/(?:^|[\s>])(`{3,}|~{3,})[ \t]*$/)?.[1];return!!(a&&a[0]===i[0]&&a.length>=i.length)}var Md=new ca().tlds([`app`,`cloud`,`dev`,`online`,`site`,`tech`,`xyz`],!0);function Nd(e){return(Md.match(e.replace(/[,。;!?、:()【】《》「」『』]/g,` `))??[]).flatMap(e=>{if(e.schema!==``)return[];try{let t=new URL(`https://${e.raw}`);return pt(t.hostname)?[]:[{start:e.index,end:e.lastIndex,label:e.raw,url:t.href}]}catch{return[]}})}function Pd(e,t){let n=new URLSearchParams({path:e});return t&&n.set(`line`,String(t)),`/xopc/workspace/file?${n}`}function Fd(e,t){if(t){let t=Di(e);if(t.kind===`internal-route`)return`#${t.route}`;if(e.startsWith(`#`))return e;let[n]=Nd(e);if(n?.start===0&&n.end===e.length)return n.url}let n=pt(e);return n?Pd(n.path,n.line):e}function Id(){return e=>{Gi(e,`element`,e=>{e.tagName===`a`&&typeof e.properties.href==`string`?e.properties.href=Fd(e.properties.href,!0):e.tagName===`img`&&typeof e.properties.src==`string`&&(e.properties.src=Fd(e.properties.src,!1))})}}function Ld({breaks:e=!1}={}){return t=>{Gi(t,(t,n)=>{if(t.type===`html`){let e=n.at(-1);if(e&&`children`in e){let n=e.children.indexOf(t);e.children.splice(n,1,{type:`text`,value:t.value})}return Ki}if(t.type!==`text`||n.some(e=>e.type===`link`||e.type===`linkReference`))return;let r=[...Array.from(t.value.matchAll(/\[([^\]\n]+)\]\((xopc:\/\/[^\s<>]+?)\)|xopc:\/\/[^\s<>\[\]()"',。;!?、]+/gi),e=>{let t=e[0].replace(/[.,;!?]+$/,``);return{start:e.index,end:e.index+t.length,url:e[2]??t,label:e[1]??t}}),...Nd(t.value)].sort((e,t)=>e.start-t.start);if(!r.length&&!(e&&t.value.includes(`
|
|
7
|
+
`)))return;let i=[],a=t=>{(e?t.split(`
|
|
8
|
+
`):[t]).forEach((e,t)=>{t&&i.push({type:`break`}),e&&i.push({type:`text`,value:e})})},o=0;for(let e of r)e.start<o||(a(t.value.slice(o,e.start)),i.push({type:`link`,url:e.url,children:[{type:`text`,value:e.label}]}),o=e.end);a(t.value.slice(o));let s=n.at(-1);if(s&&`children`in s)return s.children.splice(s.children.indexOf(t),1,...i),Ki})}}function Rd(){return e=>{Gi(e,`text`,(e,t)=>{if(t.some(e=>e.type===`element`&&([`a`,`pre`,`code`,`kbd`,`samp`,`math`,`annotation`].includes(e.tagName)||e.properties.dataXopcMath!==void 0||e.properties[`data-xopc-math`]!==void 0)))return;let n=st(e.value);if(!n.length)return;let r=t.at(-1);if(!r||!(`children`in r))return;let i=[],a=0;for(let t of n)t.start>a&&i.push({type:`text`,value:e.value.slice(a,t.start)}),i.push({type:`element`,tagName:`a`,properties:{href:Pd(t.target.path,t.target.line),className:[`markdown-file-link`]},children:[{type:`text`,value:t.raw}]}),a=t.end;return a<e.value.length&&i.push({type:`text`,value:e.value.slice(a)}),r.children.splice(r.children.indexOf(e),1,...i),Ki})}}function zd({prefix:e}){return t=>{let n=new Map;Gi(t,`element`,t=>{if(typeof t.properties.id!=`string`)return;let r=t.properties.id,i=`${e}-${r}`;n.set(r,i),r.startsWith(`user-content-`)&&n.set(r.slice(13),i),t.properties.id=i}),Gi(t,`element`,e=>{if(typeof e.properties.href==`string`&&e.properties.href.startsWith(`#`)&&!e.properties.href.startsWith(`#/`)){let t=n.get(e.properties.href.slice(1));t&&(e.properties.href=`#${t}`)}for(let t of[`ariaDescribedBy`,`ariaLabelledBy`]){let r=e.properties[t];Array.isArray(r)&&(e.properties[t]=r.map(e=>n.get(String(e))??e))}})}}var Bd=typeof Intl.Segmenter==`function`?new Intl.Segmenter(void 0,{granularity:`word`}):null,Vd=typeof Intl.Segmenter==`function`?new Intl.Segmenter(void 0,{granularity:`grapheme`}):null;function Hd(e){return Bd?Array.from(Bd.segment(e),({segment:e,index:t})=>({text:e,offset:t})):[{text:e,offset:0}]}function Ud(e,t){if(t>=e.length||!Vd)return e.length;let n=Vd.segment(e).containing(t);return n&&n.index!==t?n.index+n.segment.length:t}var Wd=256,Gd=(0,Q.createContext)(null),Kd=(0,Q.createContext)(null);function qd(e){let t=(0,X.c)(13),n;if(t[0]!==e){let{node:r,...i}=e;n=i,t[0]=e,t[1]=n}else n=t[1];let r=(0,Q.useContext)(Gd),i=(0,Q.useContext)(Kd),a=(0,Q.useRef)(null),o=Number(n[`data-xopc-segment`]),s=n[`data-xopc-new`],c=s===!0||s===`true`,l;t[2]!==i||t[3]!==o||t[4]!==c||t[5]!==r?(l=()=>{let e=a.current;if(!r||!e?.animate||document.visibilityState===`hidden`||window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches||i&&i.size>=Wd)return;let t=performance.now(),n=r.starts.get(o);if(n===void 0&&!c)return;if(n===void 0){if(r.starts.size>=Wd)return;r.starts.set(o,t)}let s=t-(n??t);if(s>=700)return;let l=e.animate([{opacity:0},{opacity:1}],{duration:700,easing:`cubic-bezier(.37,.55,.86,.88)`,fill:`both`});l.currentTime=s,i?.add(l);let u=()=>{l.cancel(),i?.delete(l)};return l.onfinish=u,u},t[2]=i,t[3]=o,t[4]=c,t[5]=r,t[6]=l):l=t[6];let u;t[7]!==i||t[8]!==o||t[9]!==r?(u=[o,r,i],t[7]=i,t[8]=o,t[9]=r,t[10]=u):u=t[10],(0,Q.useLayoutEffect)(l,u);let d;return t[11]===n?d=t[12]:(d=(0,Z.jsx)(`span`,{...n,ref:a}),t[11]=n,t[12]=d),d}function Jd(e,t,n,r,i){let a=()=>i=>{let a=t&&document.visibilityState!==`hidden`&&!window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches,o=0,s=0,c=Wd-(r?.size??0),l=performance.now();Gi(i,`text`,(t,r)=>{if(r.some(e=>e.type===`element`&&([`pre`,`svg`,`math`,`annotation`].includes(e.tagName)||e.properties.dataXopcMath!==void 0||e.properties[`data-xopc-math`]!==void 0||e.properties[`data-xopc-segment`]!==void 0)))return;let i=o;if(o+=t.value.length,!a)return;let u=r.at(-1);if(!u||!(`children`in u))return;let d=[],f=Hd(t.value).flatMap(t=>{let n=e.length-i-t.offset;if(n<=0||n>=t.text.length)return[t];let r=Ud(t.text,n);return r>=t.text.length?[t]:[{text:t.text.slice(0,r),offset:t.offset},{text:t.text.slice(r),offset:t.offset+r}]});for(let t of f){let r=i+t.offset,a=!n&&r>=e.length,o=e.starts.get(r),u=o!==void 0&&l-o<700;if(!a&&!u||!t.text.trim()||a&&!u&&s++>=c){let e=d.at(-1);e?.type===`text`?e.value+=t.text:d.push({type:`text`,value:t.text})}else d.push({type:`element`,tagName:`span`,properties:{"data-xopc-segment":r,"data-xopc-new":a},children:[{type:`text`,value:t.text}]})}let p=u.children.indexOf(t);return u.children.splice(p,1,...d),[Ki,p+d.length]}),i.children.push({type:`element`,tagName:`span`,properties:{hidden:!0,"data-xopc-watermark":o},children:[]})};return Object.defineProperty(a,"name",{value:`xopcReveal-${i}-${t}-${n}`}),a}var Yd=(0,Q.createContext)(null),Xd=(0,Q.createContext)(``);function Zd(e){let t=(0,X.c)(56),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({node:i,href:o,children:n,className:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=o===void 0?``:o,c=(0,Q.useContext)(Yd),l=(0,Q.useContext)(xd),{openImage:u}=Re(),d=v(Qd),f;t[6]===d?f=t[7]:(f=S(d),t[6]=d,t[7]=f);let p=f.chat.contentLinks,m;t[8]===s?m=t[9]:(m=s.startsWith(`#`)&&!s.startsWith(`#/`),t[8]=s,t[9]=m);let h=m,g,_,y,b,x,C,w,T,E,D;if(t[10]!==n||t[11]!==c||t[12]!==h||t[13]!==s||t[14]!==p||t[15]!==i||t[16]!==a||t[17]!==l){w=Symbol.for(`react.early_return_sentinel`);bb0:{if(E=i?af(i).trim():typeof n==`string`?n.trim():``,_=Ei(Di(s),E),_.kind===`internal-route`&&_.route.startsWith(`/automations?`)){let e=new URL(_.route,`https://xopc.local`),n=l.get(e.searchParams.get(`automation`)??``);if(e.searchParams.get(`view`)===`run`&&!e.searchParams.has(`run`)&&n){e.searchParams.set(`run`,n);let r=`${e.pathname}${e.search}`,i;t[28]===r?i=t[29]:(i={kind:`internal-route`,route:r},t[28]=r,t[29]=i),_=i}}if(T=!s.startsWith(`#`)&&_.kind!==`internal-route`&&c.openFile?pt(s):null,!h&&!T&&_.kind===`blocked`){let e;t[30]===n?e=t[31]:(e=(0,Z.jsx)(Z.Fragment,{children:n}),t[30]=n,t[31]=e),w=e;break bb0}let e=_.kind===`internal-route`?_.route:void 0;y=!!e;let r=e?e.slice(1).split(/[/?#]/,1)[0]:``;b=p.destinations[r]??p.open,D=y&&/^(?:xopc:\/\/|#\/|Open(?: in xopc)?$|打开$)/i.test(E)?b:n,g=e?`#${e}`:s,x=a,C=Pc(E)?c.trackImageLink:void 0}t[10]=n,t[11]=c,t[12]=h,t[13]=s,t[14]=p,t[15]=i,t[16]=a,t[17]=l,t[18]=g,t[19]=_,t[20]=y,t[21]=b,t[22]=x,t[23]=C,t[24]=w,t[25]=T,t[26]=E,t[27]=D}else g=t[18],_=t[19],y=t[20],b=t[21],x=t[22],C=t[23],w=t[24],T=t[25],E=t[26],D=t[27];if(w!==Symbol.for(`react.early_return_sentinel`))return w;let O=y||T||h?void 0:`_blank`,k;t[32]!==r||t[33]!==T?(k=[r,T?`markdown-file-link`:``].filter(Boolean).join(` `)||void 0,t[32]=r,t[33]=T,t[34]=k):k=t[34];let A=h?`document-fragment`:T?void 0:_.kind,j=T?.path,M=T?.kind,N=T?.line,P=c.linkError===g?p.failed:a.title||(y?b:void 0),F;t[35]!==g||t[36]!==c||t[37]!==h||t[38]!==s||t[39]!==u||t[40]!==T||t[41]!==E?(F=e=>{if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;if(e.preventDefault(),h){let t=e.currentTarget.closest(`.markdown-render-boundary`),n=s.slice(1),r=n;try{r=decodeURIComponent(n)}catch{}let i=Array.from(t?.querySelectorAll(`[id]`)??[]),a=i.find(e=>e.id===n)??i.find(e=>e.id===r);if(!a)return;a.closest(`[data-chat-scroll-viewport]`)?.dispatchEvent(new Event(`chat-scroll-reading`)),a.scrollIntoView({block:`nearest`,behavior:`auto`}),a.hasAttribute(`tabindex`)||a.setAttribute(`tabindex`,`-1`),a.focus({preventScroll:!0});return}let t=Array.from(e.currentTarget.closest(`.markdown-render-boundary`)?.querySelectorAll(`img[data-chat-image-source]`)??[]).find(e=>e.dataset.chatImageSource===s&&e.getAttribute(`src`));if(t?.src&&!/下载|download/i.test(E)){u(t.src,t.alt);return}if(T){c.openFile?.(T);return}c.openLink(g)},t[35]=g,t[36]=c,t[37]=h,t[38]=s,t[39]=u,t[40]=T,t[41]=E,t[42]=F):F=t[42];let I;return t[43]!==g||t[44]!==j||t[45]!==M||t[46]!==N||t[47]!==P||t[48]!==F||t[49]!==x||t[50]!==C||t[51]!==O||t[52]!==k||t[53]!==A||t[54]!==D?(I=(0,Z.jsx)(`a`,{...x,ref:C,href:g,target:O,rel:`noopener noreferrer`,className:k,"data-xopc-link-kind":A,"data-xopc-file-path":j,"data-xopc-file-kind":M,"data-xopc-line":N,title:P,onClick:F,children:D}),t[43]=g,t[44]=j,t[45]=M,t[46]=N,t[47]=P,t[48]=F,t[49]=x,t[50]=C,t[51]=O,t[52]=k,t[53]=A,t[54]=D,t[55]=I):I=t[55],I}function Qd(e){return e.language}function $d({node:e,src:t=``,alt:n,...r}){let i=(0,Q.useContext)(Yd),a=pt(t),o=a?.path,s=a?.line,c=a?.kind,l=(0,Q.useCallback)(()=>!o||!c||!i.loadImage?Promise.reject(Error(`Image unavailable`)):i.loadImage({path:o,line:s,kind:c}),[i.loadImage,o,s,c]);return(0,Z.jsx)(Cd,{...r,source:t,alt:n,load:a?l:void 0})}function ef(e){let t=(0,X.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({node:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=n?.children.some(rf)&&n.children.every(tf),t[3]=n,t[4]=i);let a=i||void 0,o;return t[5]!==r||t[6]!==a?(o=(0,Z.jsx)(`p`,{...r,"data-chat-media":a}),t[5]=r,t[6]=a,t[7]=o):o=t[7],o}function tf(e){return e.type===`text`?!e.value.trim():e.type===`element`&&(e.tagName===`img`||e.tagName===`a`&&e.children.every(nf))}function nf(e){return e.type===`element`&&e.tagName===`img`}function rf(e){return e.type===`element`}function af(e){return e.children.map(e=>e.type===`text`?e.value:e.type===`element`?af(e):``).join(``)}function of(e){let t=(0,X.c)(20),{node:n}=e,r=(0,Q.useContext)(Yd),i=(0,Q.useContext)(Xd),a=Ji(),o,s;if(t[0]!==n?.children){let e=n?.children.find(sf);o=String(e?.properties.className??``).match(/language-([^,\s]+)/)?.[1]??``,s=e?af(e).replace(/\n$/,``):``,t[0]=n?.children,t[1]=o,t[2]=s}else o=t[1],s=t[2];let c=s;if(o===`chart`){let e;t[3]!==i||t[4]!==a||t[5]!==n?.position?.end||t[6]!==n?.position?.start?(e=a||!jd(i,n?.position?.start.line,n?.position?.end.line),t[3]=i,t[4]=a,t[5]=n?.position?.end,t[6]=n?.position?.start,t[7]=e):e=t[7];let o;return t[8]!==c||t[9]!==r.copy||t[10]!==r.streaming||t[11]!==e?(o=(0,Z.jsx)(sa,{source:c,incomplete:e,streaming:r.streaming,copy:r.copy}),t[8]=c,t[9]=r.copy,t[10]=r.streaming,t[11]=e,t[12]=o):o=t[12],o}let l;return t[13]!==c||t[14]!==r.copy||t[15]!==r.mermaidActions||t[16]!==r.renderMermaid||t[17]!==a||t[18]!==o?(l=(0,Z.jsx)(aa,{code:c,language:o,incomplete:a,renderMermaid:r.renderMermaid,actions:r.mermaidActions,copy:r.copy}),t[13]=c,t[14]=r.copy,t[15]=r.mermaidActions,t[16]=r.renderMermaid,t[17]=a,t[18]=o,t[19]=l):l=t[19],l}function sf(e){return e.type===`element`&&e.tagName===`code`}function cf(e){let t=(0,X.c)(14),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({node:r,children:n,style:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]===r?o=t[6]:(o=((r?.children.find(df)??r)?.children.find(uf))?.children.filter(lf).length??1,t[5]=r,t[6]=o);let s=`${o*6}rem`,c;t[7]!==a||t[8]!==s?(c={...a,minWidth:s},t[7]=a,t[8]=s,t[9]=c):c=t[9];let l;return t[10]!==n||t[11]!==i||t[12]!==c?(l=(0,Z.jsx)(`div`,{className:`markdown-table-scroll`,tabIndex:0,children:(0,Z.jsx)(`table`,{...i,style:c,children:n})}),t[10]=n,t[11]=i,t[12]=c,t[13]=l):l=t[13],l}function lf(e){return e.type===`element`&&[`th`,`td`].includes(e.tagName)}function uf(e){return e.type===`element`&&e.tagName===`tr`}function df(e){return e.type===`element`&&e.tagName===`thead`}function ff(e){let t=(0,X.c)(2),n;return t[0]===e?n=t[1]:(n=e.node?.properties.dataXopcMath??e.node?.properties[`data-xopc-math`]?(0,Z.jsx)(kd,{...e}):(0,Z.jsx)(qd,{...e}),t[0]=e,t[1]=n),n}function pf(e){let t=(0,X.c)(2),n;return t[0]===e?n=t[1]:(n=e.node?.properties.dataXopcMath??e.node?.properties[`data-xopc-math`]?(0,Z.jsx)(kd,{...e,display:!0}):(0,Z.jsx)(`div`,{...Object.fromEntries(Object.entries(e).filter(mf))}),t[0]=e,t[1]=n),n}function mf(e){let[t]=e;return t!==`node`}var hf=e=>function({node:t,...n}){let r=(e===`th`||e===`td`)&&typeof t?.properties.align==`string`?t.properties.align:void 0;return(0,Q.createElement)(e,{...n,"data-markdown-align":r})},gf={a:Zd,img:$d,pre:of,span:ff,div:pf,p:ef,h1:hf(`h1`),h2:hf(`h2`),h3:hf(`h3`),h4:hf(`h4`),h5:hf(`h5`),h6:hf(`h6`),ul:hf(`ul`),ol:hf(`ol`),li:hf(`li`),strong:hf(`strong`),em:hf(`em`),blockquote:hf(`blockquote`),code:hf(`code`),table:cf,thead:hf(`thead`),tbody:hf(`tbody`),tr:hf(`tr`),th:hf(`th`),td:hf(`td`),hr:hf(`hr`)},_f=[Id,[Ui,{...Wi,attributes:{...Wi.attributes,code:[...Wi.attributes?.code??[],[`className`,/^language-/,`math-inline`,`math-display`],`data-xopc-math-source`]}}]],vf=e=>/^\s{0,3}\[[^\]]+\]:|\[[^\]]+\]\[[^\]]*\]|\[\^/m.test(e),yf=(0,Q.memo)(function(e){let t=(0,Q.useId)(),n=(0,Q.useContext)(Yd),r=(0,Q.useRef)(null),i=(0,Q.useContext)(Kd),[a]=(0,Q.useState)(()=>({length:0,starts:new Map})),o=(0,Q.useRef)(``),s=(0,Q.useRef)(!1),[c,l]=(0,Q.useState)(0),u=!s.current&&e.index<n.initialBlocks,d=o.current.trimEnd().replace(/[*_~`]+$/,``),f=s.current&&!e.content.startsWith(d),p=(n.streaming||a.starts.size>0)&&!vf(e.content)&&!f,m=(0,Q.useMemo)(()=>Jd(a,p,u,i,t),[a,p,u,c,i,t]),h=n.mathRemaining[e.index]??256,g=(0,Q.useMemo)(()=>[...(e.rehypePlugins??[]).map(e=>Array.isArray(e)&&e[0]===Jc?[Jc,{streaming:n.streaming,maxCount:h}]:e),m],[e.rehypePlugins,m,n.streaming,h]),_=performance.now();return(0,Q.useLayoutEffect)(()=>{n.metricsKey&&mt(n.metricsKey,performance.now()-_),a.length=Number(r.current?.querySelector(`[data-xopc-watermark]`)?.getAttribute(`data-xopc-watermark`)??0),f&&a.starts.clear(),o.current=e.content,s.current=!0;for(let[e,t]of a.starts)performance.now()-t>=700&&a.starts.delete(e)},[e.content,n.metricsKey,a,f]),(0,Q.useEffect)(()=>{let e=()=>{let e=window.getSelection();e&&!e.isCollapsed&&r.current?.contains(e.anchorNode)||r.current?.querySelector(`[data-xopc-segment]`)&&(a.starts.clear(),l(e=>e+1))},t=window.setTimeout(e,750);return document.addEventListener(`selectionchange`,e),()=>{window.clearTimeout(t),document.removeEventListener(`selectionchange`,e)}},[e.content,a]),(0,Z.jsx)(`div`,{ref:r,className:`markdown-stream-block`,children:(0,Z.jsx)(Ed,{content:e.content,children:(0,Z.jsx)(Xd.Provider,{value:e.content,children:(0,Z.jsx)(Gd.Provider,{value:a,children:(0,Z.jsx)(Yi,{...e,shouldParseIncompleteMarkdown:e.shouldParseIncompleteMarkdown&&jc(e.content).length===0,rehypePlugins:g})})})})})}),bf=(0,Q.memo)(function(e){let t=(0,X.c)(94),{content:r,compact:i,breaks:a,className:o,codeCopy:s,onWorkspaceFileOpen:c,onWorkspaceImageLoad:l,renderMermaid:u,mermaidActions:d,streamingMetricsKey:f,responseRunId:p,streaming:m}=e,h=i!==void 0&&i,g=a!==void 0&&a,_=s===void 0||s,y=u===void 0||u,b=d!==void 0&&d,x=m!==void 0&&m,C=(0,Q.useId)(),w=(0,Q.useRef)(null),T=$e(),E=v(xf),[D,O]=(0,Q.useState)(null),k=(0,Q.useRef)(0),A=(0,Q.useRef)(null),j;t[0]===T?j=t[1]:(j=e=>{let t=k.current+=1;A.current=e,O(null),T(e).then(n=>{t===k.current&&(n.ok&&(A.current=null),O(n.ok?null:e))}).catch(()=>{t===k.current&&O(e)})},t[0]=T,t[1]=j);let M=j,N,P;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(N=()=>()=>{k.current+=1},P=[],t[2]=N,t[3]=P):(N=t[2],P=t[3]),(0,Q.useEffect)(N,P);let F;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>{let e=A.current;!e||Array.from(w.current?.querySelectorAll(`a[href]`)??[]).some(t=>t.getAttribute(`href`)===e)||(A.current=null,k.current+=1,O(null))},t[4]=F):F=t[4];let I;t[5]===r?I=t[6]:(I=[r],t[5]=r,t[6]=I),(0,Q.useEffect)(F,I);let[L]=(0,Q.useState)(Sf),R;t[7]!==r||t[8]!==x?(R=()=>x||!r?`streaming`:`static`,t[7]=r,t[8]=x,t[9]=R):R=t[9];let[z]=(0,Q.useState)(R),[B]=(0,Q.useState)(Od),ee;t[10]!==r||t[11]!==z?(ee=()=>z===`streaming`?Dd(r).length:0,t[10]=r,t[11]=z,t[12]=ee):ee=t[12];let[V]=(0,Q.useState)(ee),H;t[13]===x?H=t[14]:(H=[Jc,{streaming:x}],t[13]=x,t[14]=H);let U=H,W;t[15]===U?W=t[16]:(W={cjk:bd,math:{name:`katex`,type:`math`,remarkPlugin:Oc,rehypePlugin:U}},t[15]=U,t[16]=W);let te=W,[ne]=(0,Q.useState)(Mc),[re]=(0,Q.useState)(Fc),ie;t[17]!==B||t[18]!==r||t[19]!==ne?(ie=ne(B(r)),t[17]=B,t[18]=r,t[19]=ne,t[20]=ie):ie=t[20];let ae=ie,oe;t[21]!==_||t[22]!==V||t[23]!==D||t[24]!==ae||t[25]!==b||t[26]!==c||t[27]!==l||t[28]!==M||t[29]!==y||t[30]!==x||t[31]!==f||t[32]!==re?(oe={openLink:M,linkError:D,streaming:x,initialBlocks:V,mathRemaining:ae,metricsKey:f,trackImageLink:re,copy:_,renderMermaid:y,mermaidActions:b,openFile:c,loadImage:l},t[21]=_,t[22]=V,t[23]=D,t[24]=ae,t[25]=b,t[26]=c,t[27]=l,t[28]=M,t[29]=y,t[30]=x,t[31]=f,t[32]=re,t[33]=oe):oe=t[33];let se=oe,ce;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(ce=Object.values($i),t[34]=ce):ce=t[34];let le;t[35]===g?le=t[36]:(le=[...ce,[Ld,{breaks:g}]],t[35]=g,t[36]=le);let ue=le,de;t[37]===c?de=t[38]:(de=c?[Rd]:[],t[37]=c,t[38]=de);let G=`xopc-markdown-${C}`,K;t[39]===G?K=t[40]:(K=[zd,{prefix:G}],t[39]=G,t[40]=K);let fe;t[41]!==de||t[42]!==K?(fe=[..._f,...de,K],t[41]=de,t[42]=K,t[43]=fe):fe=t[43];let q=fe,pe;t[44]!==r||t[45]!==p?(pe=()=>{if(!n||!p||!r.trim())return;let e=requestAnimationFrame(()=>{if(nr(p)){let e=w.current;if(!e?.getClientRects().length||!e.innerText?.trim())return}$n(p,r)});return()=>cancelAnimationFrame(e)},t[44]=r,t[45]=p,t[46]=pe):pe=t[46];let me;t[47]!==r||t[48]!==p||t[49]!==x?(me=[r,p,x],t[47]=r,t[48]=p,t[49]=x,t[50]=me):me=t[50],(0,Q.useLayoutEffect)(pe,me);let J;t[51]===f?J=t[52]:(J=()=>{if(!n||!f)return;let e=w.current?.querySelectorAll(`.markdown-stream-block`);dt(f,Math.max(0,(e?.length??0)-1),e?.item((e.length??1)-1)?.textContent?.length??0)},t[51]=f,t[52]=J);let he;t[53]!==r||t[54]!==f?(he=[r,f],t[53]=r,t[54]=f,t[55]=he):he=t[55],(0,Q.useLayoutEffect)(J,he);let ge;t[56]===E?ge=t[57]:(ge=S(E),t[56]=E,t[57]=ge);let _e=ge.chat.attachmentPreviewClose,ve=h?`markdown-compact`:``,ye=g?`markdown-breaks`:``,be=c?`markdown-workspace-links`:``,xe;t[58]!==o||t[59]!==ve||t[60]!==ye||t[61]!==be?(xe=[`markdown-body xopc-chat-markdown`,ve,ye,be,o].filter(Boolean),t[58]=o,t[59]=ve,t[60]=ye,t[61]=be,t[62]=xe):xe=t[62];let Se=xe.join(` `),Ce;t[63]!==B||t[64]!==r||t[65]!==z||t[66]!==te||t[67]!==q||t[68]!==ue||t[69]!==x||t[70]!==Se?(Ce=(0,Z.jsx)(Qi,{className:Se,mode:z,isAnimating:x,animated:!1,parseIncompleteMarkdown:x,components:gf,plugins:te,controls:!1,BlockComponent:yf,parseMarkdownIntoBlocksFn:B,remarkPlugins:ue,rehypePlugins:q,urlTransform:Zi,children:r}),t[63]=B,t[64]=r,t[65]=z,t[66]=te,t[67]=q,t[68]=ue,t[69]=x,t[70]=Se,t[71]=Ce):Ce=t[71];let we;t[72]!==r||t[73]!==Ce?(we=(0,Z.jsx)(Ed,{content:r,children:Ce}),t[72]=r,t[73]=Ce,t[74]=we):we=t[74];let Te;t[75]!==D||t[76]!==E?(Te=D?(0,Z.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:S(E).chat.contentLinks.failed}):null,t[75]=D,t[76]=E,t[77]=Te):Te=t[77];let Ee;t[78]!==C||t[79]!==we||t[80]!==Te?(Ee=(0,Z.jsxs)(`div`,{ref:w,className:`markdown-render-boundary`,"data-chat-markdown":C,children:[we,Te]}),t[78]=C,t[79]=we,t[80]=Te,t[81]=Ee):Ee=t[81];let De;t[82]!==L||t[83]!==Ee?(De=(0,Z.jsx)(Kd.Provider,{value:L,children:Ee}),t[82]=L,t[83]=Ee,t[84]=De):De=t[84];let Oe;t[85]!==r||t[86]!==De?(Oe=(0,Z.jsx)(Xd.Provider,{value:r,children:De}),t[85]=r,t[86]=De,t[87]=Oe):Oe=t[87];let ke;t[88]!==se||t[89]!==Oe?(ke=(0,Z.jsx)(Yd.Provider,{value:se,children:Oe}),t[88]=se,t[89]=Oe,t[90]=ke):ke=t[90];let Ae;return t[91]!==ge.chat.attachmentPreviewClose||t[92]!==ke?(Ae=(0,Z.jsx)(Be,{interactive:!0,closeLabel:_e,children:ke}),t[91]=ge.chat.attachmentPreviewClose,t[92]=ke,t[93]=Ae):Ae=t[93],Ae});function xf(e){return e.language}function Sf(){return new Set}function Cf(e){let t=(0,X.c)(31),{label:n,description:r,index:i,recommended:a,recommendedLabel:o,selected:s,disabled:c,onClick:l}=e,u=!!s,d=s&&`bg-accent-soft`,f;t[0]===d?f=t[1]:(f=Y(`group min-h-11 w-full justify-start gap-3 rounded-md px-3 py-2.5 text-left font-normal text-fg shadow-none`,d),t[0]=d,t[1]=f);let p=s&&`border-accent text-accent-fg`,m;t[2]===p?m=t[3]:(m=Y(`flex size-6 shrink-0 items-center justify-center rounded-md border border-edge text-xs tabular-nums text-fg-muted`,p),t[2]=p,t[3]=m);let h;t[4]!==i||t[5]!==s?(h=s?(0,Z.jsx)(re,{className:`size-3.5`}):i+1,t[4]=i,t[5]=s,t[6]=h):h=t[6];let g;t[7]!==m||t[8]!==h?(g=(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:m,children:h}),t[7]=m,t[8]=h,t[9]=g):g=t[9];let _;t[10]===n?_=t[11]:(_=(0,Z.jsx)(`span`,{className:`font-medium`,children:n}),t[10]=n,t[11]=_);let v;t[12]!==a||t[13]!==o?(v=a?(0,Z.jsx)(`span`,{className:`text-xs font-normal text-fg-muted`,children:o}):null,t[12]=a,t[13]=o,t[14]=v):v=t[14];let y;t[15]!==_||t[16]!==v?(y=(0,Z.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-0.5`,children:[_,v]}),t[15]=_,t[16]=v,t[17]=y):y=t[17];let b;t[18]===r?b=t[19]:(b=r?(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs leading-relaxed text-fg-muted`,children:r}):null,t[18]=r,t[19]=b);let x;t[20]!==y||t[21]!==b?(x=(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 whitespace-normal break-words`,children:[y,b]}),t[20]=y,t[21]=b,t[22]=x):x=t[22];let S;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(F,{"aria-hidden":`true`,className:`size-4 shrink-0 text-fg-muted opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100 motion-reduce:transition-none`}),t[23]=S):S=t[23];let C;return t[24]!==c||t[25]!==l||t[26]!==u||t[27]!==x||t[28]!==f||t[29]!==g?(C=(0,Z.jsxs)(vi,{variant:`ghost`,disabled:c,onClick:l,"aria-pressed":u,className:f,children:[g,x,S]}),t[24]=c,t[25]=l,t[26]=u,t[27]=x,t[28]=f,t[29]=g,t[30]=C):C=t[30],C}function wf(e,t,n=`draft`,r){let i=_.getState(),a=sessionStorage.getItem(`xopc.clarification.endpoint`);a||(a=crypto.randomUUID(),sessionStorage.setItem(`xopc.clarification.endpoint`,a));let o=`clarification:${i.baseUrl}:${a}:${e}:${t}:${n}`;return i.conversationId?Ir(o,r):{read:async()=>void 0,write:async e=>{}}}function Tf({prompt:e,submitting:t,submitError:n,labels:r,onSubmit:i,onAgentDecide:a,onCancel:o}){let s=S(v(e=>e.language)).chat,[c,l]=(0,Q.useState)({index:0,answers:{}}),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(!1),y=(0,Q.useRef)(!1),b=(0,Q.useRef)(!1),[x,C]=(0,Q.useState)(),w=(0,Q.useRef)(c),T=(0,Q.useRef)(null),E=(0,Q.useRef)(null),D=e?.questions??[],O=D[Math.min(c.index,D.length-1)],k=O?c.answers[O.id]:void 0,A=(0,Q.useRef)(wf(e.requestId,e.version??1,`draft`,e.conversationId)),j=t||m,M=j||g,N=D.filter(e=>{let t=c.answers[e.id];return t&&(t.choiceId||t.text?.trim())}).length;(0,Q.useEffect)(()=>{let t=!0;wf(e.requestId,e.version??1,`submission`,e.conversationId).read().then(e=>{t&&_(!!e)}).catch(()=>{});let n=t=>{let n=t.detail;n.requestId===e.requestId&&_(n.pending)};return window.addEventListener(`clarification-submission-state`,n),()=>{t=!1,window.removeEventListener(`clarification-submission-state`,n)}},[e]),(0,Q.useEffect)(()=>{let e=!1;return A.current.read().then(t=>{e||(t&&!y.current&&t.index>=0&&t.index<D.length&&t.answers&&(w.current=t,l(t)),d(!0))}).catch(()=>{e||d(!0)}),()=>{e=!0}},[D.length]),(0,Q.useEffect)(()=>{if(!u||!y.current)return;let e=window.setTimeout(()=>{A.current.write(c).catch(()=>{})},300);return()=>window.clearTimeout(e)},[c,u]),(0,Q.useEffect)(()=>{x&&E.current?.focus()},[x]);function P(e,t=!1){y.current=!0,w.current=e,l(e),p(``),t&&A.current.write(e).catch(()=>{})}function F(e){P({...c,index:e},!0),T.current?.focus()}async function I(t=w.current){if(!(j||b.current||!e)){b.current=!0,h(!0);try{let n={schemaVersion:2,answers:D.map(e=>t.answers[e.id]??{questionId:e.id})};Cr(e,n),await A.current.write(t),await i(n)}catch(e){p(e instanceof Error?e.message:String(e))}finally{b.current=!1,h(!1)}}}function L(e){if(M||b.current||!O)return;let t={...w.current,answers:{...w.current.answers,[O.id]:{questionId:O.id,choiceId:e}}};P(t);let n=D.findIndex(e=>{let n=t.answers[e.id];return!n?.choiceId&&!n?.text?.trim()});n===-1?I(t):(P({...t,index:n},!0),T.current?.focus())}if(!u)return(0,Z.jsxs)(`div`,{className:`mb-4 space-y-3 rounded-lg border border-edge p-4`,children:[(0,Z.jsx)(Qt,{className:`h-5 w-1/2`}),(0,Z.jsx)(Qt,{className:`h-24 w-full`})]});if(!O)return null;let R=!!(k?.choiceId||k?.text?.trim())&&(k?.text?.length??0)<=2e3,z=O.type!==`single_choice`||x===O.id||!!k?.text,B=`clarify-${e.requestId}-${O.id}`;return(0,Z.jsxs)(`section`,{ref:T,tabIndex:-1,"aria-label":r.clarifyRegionAria,"aria-busy":j,"data-clarification-id":e.requestId,className:Y(`mb-4 flex max-h-[min(36rem,75dvh)] min-h-0 flex-col overflow-hidden rounded-lg border border-edge bg-surface-overlay text-sm text-fg outline-none`,la.focusRingPanel),children:[(0,Z.jsxs)(`header`,{className:`shrink-0 border-b border-edge-subtle px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r.clarifyRegionAria}),(0,Z.jsx)(`span`,{role:`status`,className:`text-xs text-fg-muted`,children:j?r.clarifySubmitting:s.clarifyProgress.replace(`{{answered}}`,String(N)).replace(`{{total}}`,String(D.length))})]}),D.length>1?(0,Z.jsx)(`nav`,{"aria-label":s.clarifyQuestions,className:`mt-2 flex flex-wrap gap-1`,children:D.map((e,t)=>(0,Z.jsxs)(vi,{variant:t===c.index?`secondary`:`ghost`,disabled:M,"aria-current":t===c.index?`step`:void 0,onClick:()=>F(t),children:[t+1,`. `,e.header,c.answers[e.id]?.choiceId||c.answers[e.id]?.text?.trim()?` ✓`:``]},e.id))}):null]}),(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto px-4 py-3`,children:[(0,Z.jsx)(bf,{content:O.question,compact:!0,className:`text-fg [&_p]:font-medium`}),O.type===`single_choice`?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:D.length>1?s.clarifyBatchQuickHint:r.clarifyQuickHint}):null,O.type===`single_choice`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{role:`group`,"aria-label":O.header,className:`space-y-0.5 rounded-lg border border-edge p-1`,children:O.choices.map((e,t)=>(0,Z.jsx)(Cf,{...e,index:t,recommended:O.recommendedChoiceId===e.id,recommendedLabel:r.clarifyRecommended,selected:k?.choiceId===e.id,disabled:M,onClick:()=>L(e.id)},e.id))}),(0,Z.jsxs)(vi,{variant:`ghost`,disabled:M,"aria-expanded":z,"aria-controls":B,className:`min-h-11 justify-start gap-1 px-1 text-xs`,onClick:()=>C(z?void 0:O.id),children:[(0,Z.jsx)(ae,{"aria-hidden":`true`,className:Y(`size-3.5`,z&&`rotate-90`)}),r.clarifyCustomLabel]})]}):null,z?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`label`,{htmlFor:B,className:`sr-only`,children:r.clarifyCustomLabel}),(0,Z.jsx)(`textarea`,{ref:E,id:B,rows:3,disabled:M,value:k?.text??``,"aria-invalid":(k?.text?.length??0)>2e3,onChange:e=>P({...c,answers:{...c.answers,[O.id]:{questionId:O.id,text:e.target.value}}}),onKeyDown:e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&!e.nativeEvent.isComposing&&(e.preventDefault(),c.index===D.length-1?I():R&&F(c.index+1))},className:`min-h-20 w-full resize-y rounded-md border border-edge bg-surface-panel px-3 py-2 focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent`}),(0,Z.jsxs)(`p`,{className:`flex justify-between gap-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:r.clarifyKeyboardHint}),(0,Z.jsxs)(`span`,{children:[k?.text?.length??0,`/2000`]})]})]}):null,n||f?(0,Z.jsx)(`p`,{role:`alert`,className:`text-red-600`,children:n||f}):null]}),(0,Z.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-edge-subtle px-4 py-3`,children:[(0,Z.jsx)(vi,{variant:`ghost`,disabled:M,onClick:()=>void o(),children:r.clarifyCancel}),a?(0,Z.jsx)(vi,{variant:`ghost`,disabled:M,onClick:()=>void a(),children:r.clarifyAgentDecide}):null,D.length>1?(0,Z.jsx)(vi,{variant:`secondary`,disabled:M||c.index===0,onClick:()=>F(c.index-1),children:s.clarifyPrevious}):null,z||g||n||f||N===D.length?c.index<D.length-1&&!g?(0,Z.jsx)(vi,{variant:`primary`,disabled:M||!R,onClick:()=>F(c.index+1),children:s.clarifyNext}):(0,Z.jsx)(vi,{variant:`primary`,disabled:j||N!==D.length||!R,onClick:()=>void I(),children:j?r.clarifySubmitting:g?s.clarifyRetrySubmission:s.clarifySubmitAll}):null]})]})}function Ef(e){let t=(0,X.c)(5);if(e.prompt?.schemaVersion===2&&e.prompt.kind!==`approval`){let n=`${e.prompt.requestId}:${e.prompt.version}`,r;return t[0]!==e||t[1]!==n?(r=(0,Z.jsx)(Tf,{...e},n),t[0]=e,t[1]=n,t[2]=r):r=t[2],r}let n;return t[3]===e?n=t[4]:(n=e.prompt?(0,Z.jsx)(Df,{...e,prompt:e.prompt},e.prompt.requestId):null,t[3]=e,t[4]=n),n}function Df({prompt:e,submitting:t,submitError:n,labels:r,onSubmit:i,onAgentDecide:a,onCancel:o}){let[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(Date.now),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(``),y=(0,Q.useRef)(!1),b=(0,Q.useRef)(null),x=(0,Q.useRef)(null),S=(0,Q.useRef)(null),[C]=(0,Q.useState)(()=>e.serverTime?e.serverTime-Date.now():0),w=e.expiresAt===void 0?null:Math.max(0,Math.ceil((e.expiresAt-p-C)/1e3)),T=w===0,E=t||h||T,D=e.kind===`approval`,O=d||!e.choiceDetails?.length,k=e.choiceDetails??[],A=s.trim().length>Jn,j=`clarify-answer-${e.requestId}`,M=`clarify-error-${e.requestId}`,N=`clarify-hint-${e.requestId}`,P=e.recommendedChoiceId;(0,Q.useEffect)(()=>{b.current?.focus()},[]),(0,Q.useEffect)(()=>{(n||_)&&x.current?.focus()},[n,_]),(0,Q.useEffect)(()=>{d&&S.current?.focus()},[d]),(0,Q.useEffect)(()=>{if(!e.expiresAt)return;let t=window.setInterval(()=>m(Date.now()),1e3);return()=>window.clearInterval(t)},[e.expiresAt]),(0,Q.useEffect)(()=>{S.current&&(S.current.style.height=`auto`,S.current.style.height=`${Math.min(160,S.current.scrollHeight)}px`)},[s]);let F=async t=>{if(!(E||y.current)){y.current=!0,g(!0),v(``);try{Cr(e,t),await i(t)}catch(e){v(e instanceof Error?e.message:String(e))}finally{y.current=!1,g(!1)}}},I=e=>{E||(u(e),F({response:{choiceId:e}}))},L=()=>{A||!s.trim()||F({response:{text:s.trim()||void 0}})};return(0,Z.jsxs)(`section`,{ref:b,tabIndex:-1,"data-clarification-id":e.requestId,"aria-label":D?r.clarifyApprovalTitle:r.clarifyRegionAria,"aria-busy":t||h,className:Y(`mb-4 rounded-lg border border-edge bg-surface-overlay px-4 py-3 text-sm text-fg outline-none`,la.focusRingPanel),children:[(0,Z.jsx)(`p`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:D?r.clarifyApprovalTitle:r.clarifyRegionAria}),(0,Z.jsx)(bf,{content:e.question,compact:!0,className:`mb-3 text-fg [&_p]:font-medium`}),D&&e.approval?(0,Z.jsx)(`dl`,{className:`mb-3 space-y-2`,children:[[r.clarifyOperation,e.approval.operation],[r.clarifyTarget,e.approval.target],[r.clarifyImpact,e.approval.impact]].map(([e,t])=>t?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-xs text-fg-muted`,children:e}),(0,Z.jsx)(`dd`,{className:`whitespace-pre-wrap break-words`,children:t})]},e):null)}):null,D&&e.approval?.argumentsPreview?(0,Z.jsxs)(`details`,{className:`mb-3`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer text-fg-muted`,children:r.clarifyDetails}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-all text-xs`,children:JSON.stringify(e.approval.argumentsPreview,null,2)})]}):null,(0,Z.jsxs)(`div`,{className:`mb-3 space-y-1 text-xs text-fg-muted`,children:[D?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{children:r.clarifyOnce}),(0,Z.jsx)(`p`,{children:r.clarifyApprovalTimeout})]}):null,w===null?null:(0,Z.jsx)(`p`,{role:`status`,children:T?r.clarifyExpired:r.clarifyTimeRemaining.replace(`{{time}}`,`${Math.floor(w/60)}:${String(w%60).padStart(2,`0`)}`)})]}),n||_?(0,Z.jsx)(`div`,{ref:x,tabIndex:-1,id:M,role:`alert`,className:`mb-3 rounded-md border border-edge p-3 text-red-600`,children:n||_}):null,t||h?(0,Z.jsx)(`p`,{role:`status`,className:`mb-2 text-xs text-fg-muted`,children:r.clarifySubmitting}):null,D?(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(vi,{variant:`secondary`,disabled:E,onClick:()=>void F({decision:`deny`}),children:r.clarifyDeny}),(0,Z.jsx)(vi,{variant:`primary`,disabled:E,onClick:()=>void F({decision:`approve`}),children:r.clarifyApprove})]}):(0,Z.jsxs)(Z.Fragment,{children:[k.length?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:r.clarifyQuickHint}),(0,Z.jsx)(`div`,{role:`group`,"aria-label":r.clarifyChoicesGroupAria,className:`max-h-64 space-y-0.5 overflow-y-auto rounded-lg border border-edge p-1`,children:k.map((e,t)=>(0,Z.jsx)(Cf,{...e,index:t,recommended:P===e.id,recommendedLabel:r.clarifyRecommended,selected:l===e.id,disabled:E,onClick:()=>I(e.id)},e.id))}),(0,Z.jsxs)(vi,{variant:`ghost`,disabled:E,"aria-expanded":O,"aria-controls":j,className:`mt-1 min-h-11 justify-start gap-1 px-1 text-xs`,onClick:()=>{f(!d)},children:[(0,Z.jsx)(ae,{"aria-hidden":`true`,className:Y(`size-3.5`,O&&`rotate-90`)}),r.clarifyCustomLabel]})]}):null,O?(0,Z.jsxs)(`form`,{className:`mt-2 space-y-2`,onSubmit:e=>{e.preventDefault(),L()},children:[(0,Z.jsx)(`label`,{htmlFor:j,className:`block text-xs font-medium text-fg-muted`,children:r.clarifyCustomLabel}),(0,Z.jsx)(`textarea`,{id:j,ref:S,value:s,rows:2,disabled:E,placeholder:r.clarifyPlaceholder,"aria-invalid":A,"aria-describedby":`${N}${n?` ${M}`:``}`,onChange:e=>{c(e.target.value),e.target.value&&f(!0)},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&!e.nativeEvent.isComposing&&(e.preventDefault(),L())},className:`max-h-40 min-h-16 w-full resize-none overflow-y-auto rounded-md border border-edge bg-surface-panel px-3 py-2 text-fg placeholder:text-fg-muted focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent disabled:opacity-50`}),(0,Z.jsxs)(`div`,{id:N,className:`flex flex-wrap justify-between gap-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:A?r.clarifyAnswerTooLong:r.clarifyKeyboardHint}),(0,Z.jsxs)(`span`,{"aria-live":A?`polite`:`off`,children:[s.trim().length,`/`,Jn]})]}),(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,Z.jsx)(vi,{type:`submit`,variant:`primary`,disabled:E||A||!s.trim(),children:r.clarifySend})})]}):null,(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-1 border-t border-edge-subtle pt-2`,children:[a?(0,Z.jsx)(vi,{variant:`ghost`,disabled:E,onClick:()=>void a(),children:r.clarifyAgentDecide}):null,(0,Z.jsx)(vi,{variant:`ghost`,disabled:t||h,onClick:()=>void o(),children:r.clarifyCancel})]})]})]})}function Of(e,t){let n=(0,X.c)(13),r=_(Af),i=_(kf),a;n[0]!==i||n[1]!==e||n[2]!==r?(a=e?[`session-context`,i,r,e]:null,n[0]=i,n[1]=e,n[2]=r,n[3]=a):a=n[3];let o;n[4]===e?o=n[5]:(o=async()=>await Lr(e)?void 0:(await y(g(`/api/sessions/${encodeURIComponent(e)}/context-summary`))).summary,n[4]=e,n[5]=o);let s;n[6]===t?s=n[7]:(s={keepPreviousData:!1,revalidateOnFocus:t,revalidateOnReconnect:t,shouldRetryOnError:!1},n[6]=t,n[7]=s);let c=Qr(a,o,s),{mutate:l}=c,u,d;return n[8]!==e||n[9]!==l||n[10]!==t?(u=()=>{if(!t||!e)return;l();let n,r=()=>{window.clearTimeout(n),n=window.setTimeout(()=>{l()},150)},i=[`session-updated`,`run-completed`,`agent-run-ended`,`note-updated`,`task-changed-v2`,`task-collaboration-entry-added`,`gateway-realtime-connected`];for(let e of i)window.addEventListener(e,r);return()=>{window.clearTimeout(n);for(let e of i)window.removeEventListener(e,r)}},d=[t,e,l],n[8]=e,n[9]=l,n[10]=t,n[11]=u,n[12]=d):(u=n[11],d=n[12]),(0,Q.useEffect)(u,d),c}function kf(e){return e.baseUrl}function Af(e){return e.conversationId}function jf(){return Ea()?window.electronAPI?.platform??`web`:`web`}function Mf({runtime:e,sidebarCollapsed:t,mobileNavOpen:n}){let r=e===`darwin`,i=e===`linux`,a=e===`web`,o=a||i||r&&!t&&!n;return{sidebarChromeVisible:o||n,sidebarQuickActionsVisible:o,sidebarChromeDraggable:r,sidebarLeadingInsetClass:r?`pl-[88px]`:``,mainHeaderDraggable:r,mainHeaderQuickActionsVisible:(a||i)&&t||r&&t&&!n,mainHeaderLeadingInsetClass:r&&t?`pl-[88px]`:``,collapsedNewChatVisible:a&&t}}var Nf=`xopc-web-sidebar-collapsed`,Pf=`xopc-web-sidebar-expanded-width-px`;function Ff(){try{return globalThis.localStorage?.getItem(Nf)===`1`}catch{return!1}}function If(e){try{globalThis.localStorage?.setItem(Nf,e?`1`:`0`)}catch{}}function Lf(e){return Math.min(480,Math.max(248,Math.round(e)))}function Rf(){try{let e=globalThis.localStorage?.getItem(Pf);if(e==null)return Lf(256);let t=Number.parseInt(e,10);return Lf(Number.isFinite(t)?t:256)}catch{return Lf(256)}}function zf(e){try{globalThis.localStorage?.setItem(Pf,String(e))}catch{}}var Bf=b((e,t)=>({collapsed:Ff(),setCollapsed:t=>{e({collapsed:t}),queueMicrotask(()=>If(t))},toggleCollapsed:()=>{t().setCollapsed(!t().collapsed)},expandedWidthPx:Rf(),setExpandedWidthPx:n=>{let r=Lf(n);t().expandedWidthPx!==r&&(e({expandedWidthPx:r}),queueMicrotask(()=>zf(r)))}})),Vf=b(e=>({mobileNavOpen:!1,setMobileNavOpen:t=>e({mobileNavOpen:t}),toggleMobileNav:()=>e(e=>({mobileNavOpen:!e.mobileNavOpen}))}));function Hf(e){return e>99?`99+`:String(e)}function Uf(e,t){let n=(0,X.c)(15),r=t===void 0||t,i=_(qf),a;n[0]!==r||n[1]!==i?(a=i&&r?[`personal-agent-unread`,i]:null,n[0]=r,n[1]=i,n[2]=a):a=n[2];let o;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(o={refreshInterval:3e4},n[3]=o):o=n[3];let{data:s,mutate:c}=Qr(a,Kf,o),[l,u]=(0,Q.useState)(Gf),d,f;n[4]!==r||n[5]!==i||n[6]!==c?(d=()=>{if(!r||!i)return;let e=()=>{c()},t=()=>{let t=document.visibilityState===`visible`&&document.hasFocus();u(t),t&&e()},n=[`session-transcript-updated`,`session-task-result`,`agent-run-ended`,`personal-unread-updated`,`gateway-realtime-connected`,`realtime-gap`];return n.forEach(t=>window.addEventListener(t,e)),window.addEventListener(`focus`,t),window.addEventListener(`blur`,t),document.addEventListener(`visibilitychange`,t),()=>{n.forEach(t=>window.removeEventListener(t,e)),window.removeEventListener(`focus`,t),window.removeEventListener(`blur`,t),document.removeEventListener(`visibilitychange`,t)}},f=[c,r,i],n[4]=r,n[5]=i,n[6]=c,n[7]=d,n[8]=f):(d=n[7],f=n[8]),(0,Q.useEffect)(d,f);let p=s?.payload,m,g;return n[9]!==c||n[10]!==p||n[11]!==e||n[12]!==l?(m=()=>{if(!l||!p?.unreadCount||p.conversationId!==e)return;let t=!0;return h(`/api/personal-agent/read`,{method:`POST`,body:JSON.stringify({transcriptId:p.transcriptId,lastSeq:p.lastSeq})}).then(async e=>{if(!e.ok)return;let n=await e.json();t&&await c(n,{revalidate:!1})}).catch(Wf),()=>{t=!1}},g=[l,e,p,c],n[9]=c,n[10]=p,n[11]=e,n[12]=l,n[13]=m,n[14]=g):(m=n[13],g=n[14]),(0,Q.useEffect)(m,g),p?.unreadCount??0}function Wf(){}function Gf(){return document.visibilityState===`visible`&&document.hasFocus()}function Kf(){return y(g(`/api/personal-agent/unread`))}function qf(e){return e.conversationId}function Jf(e,t){return[`gateway-chat-session-agent`,e,t]}function Yf(e){let t=(0,X.c)(5),n=_(Zf),r,i;if(t[0]!==e||t[1]!==n){let a=e?.trim();r=Qr,i=n&&a?Jf(n,a):null,t[0]=e,t[1]=n,t[2]=r,t[3]=i}else r=t[2],i=t[3];let a;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},t[4]=a):a=t[4],r(i,Xf,a)}function Xf(e){let[,,t]=e;return Qf(t)}function Zf(e){return e.conversationId}async function Qf(e){let t=await Lr(e);if(t)return{agentId:t.creation.agentId.trim().toLowerCase(),projectId:t.creation.projectId?.trim()||null,...t.creation.agentSetup?{agentSetup:!0}:{}};let n=await hn(e);return{agentId:(n.routing?.agentId??n.agentId).trim().toLowerCase(),projectId:n.projectId?.trim()||null,...n.customData?.agentSetup===!0?{agentSetup:!0}:{}}}function $f(e){let t=Sn(t=>zn(t.sessions[e])),[n,r]=(0,Q.useState)(()=>wr(e)),i=(0,Q.useRef)(e);return i.current!==e&&(i.current=e,r(wr(e))),(0,Q.useEffect)(()=>{r(wr(e))},[e,t]),(0,Q.useEffect)(()=>{let t=t=>{t.detail?.chatId===e&&r(wr(e))};return window.addEventListener(qn,t),()=>window.removeEventListener(qn,t)},[e]),t||n}function ep(e){return e.trim()}var tp=b(e=>({runs:{},markRunning:t=>{let n=ep(t);if(!n)return;let r=Date.now();e(e=>{let t=e.runs[n];return{runs:{...e.runs,[n]:{status:`running`,startedAt:t?.status===`running`?t.startedAt:r,updatedAt:r,unread:!1}}}})},markCompleted:(t,n)=>{let r=ep(t);if(!r)return;let i=Date.now();e(e=>{let t=e.runs[r];return{runs:{...e.runs,[r]:{status:`completed`,startedAt:t?.startedAt??i,updatedAt:i,unread:n}}}})},markFailed:(t,n)=>{let r=ep(t);if(!r)return;let i=Date.now();e(e=>{let t=e.runs[r];return{runs:{...e.runs,[r]:{status:`failed`,startedAt:t?.startedAt??i,updatedAt:i,unread:n}}}})},markViewed:t=>{let n=ep(t);n&&e(e=>{let t=e.runs[n];return t?.unread?{runs:{...e.runs,[n]:{...t,unread:!1}}}:e})},clear:t=>{let n=ep(t);n&&e(e=>{if(!(n in e.runs))return e;let{[n]:t,...r}=e.runs;return{runs:r}})}}));function np(e){tp.getState().markRunning(e)}function rp(e,t){tp.getState().markCompleted(e,t)}function ip(e,t){tp.getState().markFailed(e,t)}function ap(e){tp.getState().clear(e)}function op(e){tp.setState(t=>({runs:{...t.runs,[e]:{status:`waiting`,startedAt:t.runs[e]?.startedAt??Date.now(),updatedAt:Date.now(),unread:!1}}}))}var sp=`application/x-xopc-workspace-file`;function cp(e,t){e.effectAllowed=`copy`,e.setData(sp,JSON.stringify(t))}function lp(e){return!!(e&&Array.from(e.types).includes(`application/x-xopc-workspace-file`))}function up(e){if(!e)return null;try{let t=JSON.parse(e.getData(sp)),n=typeof t.path==`string`?t.path.trim():``,r=typeof t.name==`string`?t.name.trim():``;return!n||!r?null:{path:n,name:r,...typeof t.conversationId==`string`&&t.conversationId.trim()?{conversationId:t.conversationId.trim()}:{},...typeof t.agentId==`string`&&t.agentId.trim()?{agentId:t.agentId.trim()}:{},...typeof t.projectId==`string`&&t.projectId.trim()?{projectId:t.projectId.trim()}:{}}}catch{return null}}var dp=`xopc-web-workspace-panel-open`,fp=`xopc-web-workspace-panel-width-px`;function pp(){try{return globalThis.localStorage?.getItem(dp)===`1`}catch{return!1}}function mp(e){try{globalThis.localStorage?.setItem(dp,e?`1`:`0`)}catch{}}function hp(e){return Math.min(520,Math.max(200,Math.round(e)))}function gp(){try{let e=globalThis.localStorage?.getItem(fp);if(e==null)return 320;let t=Number.parseInt(e,10);return Number.isFinite(t)?hp(t):320}catch{return 320}}function _p(e){try{globalThis.localStorage?.setItem(fp,String(e))}catch{}}var vp=b((e,t)=>({open:pp(),setOpen:t=>{yi.getState().setOpen(t),e(t?{open:t}:{open:t,conversationIdOverride:null}),queueMicrotask(()=>mp(t))},toggleOpen:()=>{t().setOpen(!t().open)},conversationIdOverride:null,openForSession:t=>{let n=t.trim();yi.getState().setScope(n||`new`),yi.getState().setOpen(!0,n||`new`),e({open:!0,conversationIdOverride:n||null}),queueMicrotask(()=>mp(!0))},widthPx:gp(),setWidthPx:n=>{let r=hp(n);t().widthPx!==r&&(e({widthPx:r}),queueMicrotask(()=>_p(r)))}})),yp={commands:!0,skills:!0,agentSwitch:!0},bp={commands:!1,skills:!1,agentSwitch:!1},xp=new WeakMap,Sp=``,Cp=``,wp=RegExp(`^\\/skill:(${Fa})`);function Tp(e){return!!e.dataset.skill}function Ep(e){return!!e.dataset.contextRefId}function Dp(e){return e.dataset.slashCommand!=null&&e.dataset.slashCommand!==``}var Op=new WeakMap;function kp(e){let t=Dr(),n,r=-1;for(;(n=t.exec(e))!==null;)r=n.index+n[0].length;return r===e.length}function Ap(e){let t=``;for(let n of e)if(n){if(t.length>0){let e=t[t.length-1],r=n[0];if(!/\s/.test(e)&&!/\s/.test(r)){let e=kp(t)||/\/skill:\S+$/.test(t)||ko(t),r=n.startsWith(`@xopc-ref:`)||n.startsWith(`/skill:`)||Do(n);(e||r)&&(t+=` `)}}t+=n}return t}function jp(e){if(e.nodeType!==Node.ELEMENT_NODE)return!1;let t=e.tagName;return t===`DIV`||t===`P`||t===`PRE`||t===`BLOCKQUOTE`}function Mp(e,t){if(e.nodeType===Node.TEXT_NODE)t.push((e.textContent??``).replaceAll(Sp,``));else if(e.nodeType===Node.ELEMENT_NODE){let n=e;if(Tp(n)){let e=n.dataset.skill??``;e&&t.push(`/skill:${e}`)}else if(Ep(n)){let e=n.dataset.contextRefId??``;e&&t.push(Xn(e))}else if(Dp(n)){let e=n.dataset.slashCommand??``;e&&t.push(`/${e}`)}else n.tagName===`BR`?t.push(`
|
|
9
|
+
`):Np(n,t)}}function Np(e,t){let n=Array.from(e.childNodes);for(let e=0;e<n.length;e++){let r=n[e],i=n[e+1];Mp(r,t),i!=null&&(jp(r)||jp(i))&&t.push(`
|
|
10
|
+
`)}}function Pp(e,t){Np(e,t)}function Fp(e){let t=[];return Pp(e,t),Ap(t).replaceAll(Cp,``)}function Ip(e){let t=window.getSelection();if(!t)return;let n=document.createRange(),r=e.firstChild;r&&r.nodeType===Node.TEXT_NODE?(n.setStart(r,0),n.collapse(!0)):(n.setStart(e,0),n.collapse(!0)),t.removeAllRanges(),t.addRange(n)}function Lp(e){let t=Fp(e);return t.length>0||e.childNodes.length===0?t:(Qp(e,``),Ip(e),``)}function Rp(e){let t=new Set,n=Ma(),r;for(;(r=n.exec(e))!==null;){let e=r[1];e&&t.add(e)}return t}function zp(e){let t=window.getSelection();if(!t||t.rangeCount===0)return Fp(e).length;let n=t.getRangeAt(0);if(!e.contains(n.startContainer))return Fp(e).length;let r=document.createRange();r.selectNodeContents(e),r.setEnd(n.startContainer,n.startOffset);let i=document.createElement(`div`);return i.appendChild(r.cloneContents()),Fp(i).length}var Bp=new WeakMap;function Vp(e,t){Bp.set(e,t);for(let n of e.querySelectorAll(`[data-skill]`)){let e=`/${t(n.dataset.skill??``)}`;n.textContent!==e&&(n.textContent=e),n.title=`/${n.dataset.skill}`}}function Hp(e,t){Op.set(e,t);for(let n of e.querySelectorAll(`[data-context-ref-id]`)){let e=t(n.dataset.contextRefId??``);n.textContent=e?`@${e.title}`:`@reference`,n.title=e?.title??``,n.dataset.refKind=e?.kind??``,n.dataset.fileKind=e?.fileKind??``}}function Up(e,t){let n=document.createElement(`span`);n.contentEditable=`false`,n.dataset.skill=t,n.className=`chat-skill-pill`,n.textContent=`/${Bp.get(e)?.(t)??t}`,n.title=`/${t}`,e.appendChild(n),e.appendChild(document.createTextNode(Sp))}function Wp(e,t){let n=Op.get(e)?.(t),r=document.createElement(`span`);r.contentEditable=`false`,r.dataset.contextRefId=t,r.dataset.refKind=n?.kind??``,r.dataset.fileKind=n?.fileKind??``,r.className=`chat-context-ref-pill`,r.textContent=n?`@${n.title}`:`@reference`,r.title=n?.title??``,e.appendChild(r),e.appendChild(document.createTextNode(Sp))}function Gp(e,t){let n=document.createElement(`span`);n.contentEditable=`false`,n.dataset.slashCommand=t,n.className=`chat-command-pill`,n.textContent=`/${t}`,e.appendChild(n),e.appendChild(document.createTextNode(Sp))}function Kp(e,t=yp){let n=[],r=t=>{let r,i=new RegExp(t.source,t.flags);for(;(r=i.exec(e))!==null;)n.push({start:r.index,end:r.index+r[0].length})};t.skills&&r(Ma()),r(Dr());for(let r of t.commands?Io(e):[])n.push(r);return n.sort((e,t)=>e.start-t.start),n}function qp(e,t,n=yp){for(let{start:r,end:i}of Kp(e,n))if(t>r&&t<=i)return{wire:e.slice(0,r)+e.slice(i),caret:r};return null}function Jp(e,t,n=yp){if(t<=0)return null;let r=e.slice(0,t),i=n=>{let i=r.match(n);if(i?.[1]){let n=i[1],a=r.length-n.length;return{wire:e.slice(0,a)+e.slice(t),caret:a}}return null},a=n.skills?[Pa]:[];for(let e of a){let t=i(e);if(t)return t}let o=n.commands?No(r):null;if(o){let n=o.tokenStart;return{wire:e.slice(0,n)+e.slice(t),caret:n}}if(t===e.length){let i=n.skills?[Na]:[];for(let n of i){let i=r.match(n);if(i?.[1]){let n=i[0],a=r.length-n.length;return{wire:e.slice(0,a)+e.slice(t),caret:a}}}let a=n.commands?Oo(r):null;if(a){let n=a.tokenStart;return{wire:e.slice(0,n)+e.slice(t),caret:n}}}return null}function Yp(e){let t=window.getSelection();if(!t||t.rangeCount===0||!t.isCollapsed)return!1;let n=t.getRangeAt(0),r=Fp(e),i=zp(e);i===0&&r.length>0&&n.startContainer===e&&n.startOffset===e.childNodes.length&&(i=r.length);let a=xp.get(e)??yp,o=qp(r,i,a);return o||=Jp(r,i,a),o?(Qp(e,o.wire,o.caret),e.dispatchEvent(new InputEvent(`input`,{bubbles:!0})),!0):!1}function Xp(e,t,n){let r=e.slice(t);return n.skills&&wp.test(r)||Dr().exec(r)?.index===0?!0:n.commands&&Mo(e,t)!=null}function Zp(e,t,n){let r=xp.get(e)??yp,i=t.slice(n),a=[],o=i.match(wp);r.skills&&o?.[0]&&a.push({len:o[0].length,apply:()=>Up(e,o[1]??``)});let s=Dr().exec(i);s?.index===0&&s[0]&&a.push({len:s[0].length,apply:()=>Wp(e,s[1]??``)});let c=r.commands?Mo(t,n):null;if(c&&a.push({len:c.len,apply:()=>Gp(e,c.matchedKey)}),a.length===0){let i=n+1;for(;i<t.length&&!Xp(t,i,r);)i+=1;let a=t.slice(n,i);return a&&e.appendChild(document.createTextNode(a)),i}return a.sort((e,t)=>t.len-e.len),a[0].apply(),n+a[0].len}function Qp(e,t,n,r){r&&xp.set(e,r),e.replaceChildren();let i=t;if(n!==void 0){let e=Math.max(0,Math.min(n,t.length));i=t.slice(0,e)+Cp+t.slice(e)}let a=0;for(;a<i.length;)a=Zp(e,i,a);if(n===void 0)return;let o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),s;for(;s=o.nextNode();){let e=s.textContent??``,t=-1;for(let n=0;n<e.length;n++)if(e[n]===Cp){t=n;break}if(t>=0){let n=s;n.textContent=e.slice(0,t)+e.slice(t+1);let r=window.getSelection(),i=document.createRange();i.setStart(n,t),i.collapse(!0),r?.removeAllRanges(),r?.addRange(i);return}}}function $p(e,t){for(let n of e)if(n.isActive()&&n.handleKey(t))return!0;return!1}var em=8*1024,tm=80,nm=2*1024,rm=20;function im(e){let t=e.trimStart().slice(0,8*1024);if(/^(?:<!doctype\s+html\b|<(?:html|head|body)\b)/i.test(t)||/^<(?:div|span|section|main|article|script|style)\b/i.test(t))return`html`;let n=e.trim();return(n.startsWith(`{`)&&n.endsWith(`}`)||n.startsWith(`[`)&&n.endsWith(`]`))&&/[\":,]/.test(t)?`json`:/(?:^|\n)\s*(?:(?:import|export|const|let|var|function|class|interface|type|def|SELECT|CREATE)\b|#!\/)/m.test(t)||/(?:=>|\{\s*$|;\s*$)/m.test(t)?`code`:`text`}function am(e){let t=new TextEncoder().encode(e).byteLength,n=e.split(/\r\n|\n|\r/).length,r=im(e);return t>=em||n>=tm||r!==`text`&&(t>=nm||n>=rm)?{text:e,...r===`html`?{name:`pasted-text.html`,mimeType:`text/html`}:r===`json`?{name:`pasted-text.json`,mimeType:`application/json`}:r===`code`?{name:`pasted-code.txt`,mimeType:`text/plain`}:{name:`pasted-text.txt`,mimeType:`text/plain`},byteLength:t,lineCount:n}:null}function om(e){if(!e)return null;let t=Fi(e);if(t.length>0)return{kind:`files`,files:t};let n=e.getData(`text/plain`);if(!n)return null;let r=am(n);return r?{kind:`text-attachment`,attachment:r}:{kind:`inline-text`,text:n}}async function sm(e,t){switch(e.kind){case`files`:await t.processFiles(e.files);return;case`unsupported-files`:t.onUnsupportedFiles();return;case`text-attachment`:await t.processPastedText(e.attachment);return;case`inline-text`:t.insertText(e.text)}}var cm=`fill-chat-composer`;function lm(e,t,n){window.dispatchEvent(new CustomEvent(cm,{detail:{text:e,attachments:t,contextRefs:n}}))}function um(e,t,n){let r=(0,X.c)(20),i=n===void 0||n,a=v(pm),o=_(fm),s=_(dm),c;r[0]!==e||r[1]!==s||r[2]!==t||r[3]!==i||r[4]!==o?(c=i&&o?[`chat-skill-labels`,s,o,e??`main`,t??``]:null,r[0]=e,r[1]=s,r[2]=t,r[3]=i,r[4]=o,r[5]=c):c=r[5];let l;r[6]!==e||r[7]!==t?(l=()=>To(e,t),r[6]=e,r[7]=t,r[8]=l):l=r[8];let u;r[9]===Symbol.for(`react.memo_cache_sentinel`)?(u={revalidateOnFocus:!1,shouldRetryOnError:!1},r[9]=u):u=r[9];let{data:d,mutate:f}=Qr(c,l,u),p,m;r[10]!==i||r[11]!==o||r[12]!==f?(p=()=>{if(!i||!o)return;let e=e=>{let t=e.detail?.section;(t===`skills`||t===`agents`)&&f()};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},m=[i,o,f],r[10]=i,r[11]=o,r[12]=f,r[13]=p,r[14]=m):(p=r[13],m=r[14]),(0,Q.useEffect)(p,m);let h;r[15]!==d?.skills||r[16]!==a?(h=new Map(d?.skills.map(e=>[e.name,jo(e,a).displayName])),r[15]=d?.skills,r[16]=a,r[17]=h):h=r[17];let g=h,y;return r[18]===g?y=r[19]:(y=e=>g.get(e)??e,r[18]=g,r[19]=y),y}function dm(e){return e.baseUrl}function fm(e){return e.conversationId}function pm(e){return e.language}function mm(e,t){e.classList.toggle(`composer-input-empty`,t.length===0)}function hm(e){let{disabled:t,initialValue:n=``,onValueChange:r,autoFocusKey:i,welcomeDraftSeed:a,onExternalTextReplace:o,shouldSyncSelectionRef:s,resolveContextRef:c}=e,l=e.capabilities??yp,u=um(e.agentId,e.conversationId,l.skills),[d,f]=(0,Q.useState)(n),[p,m]=(0,Q.useState)(n.length),[h,g]=(0,Q.useState)(!1),_=(0,Q.useRef)(null),v=(0,Q.useRef)(d),y=(0,Q.useRef)(p),b=(0,Q.useRef)(null),x=(0,Q.useRef)(0),S=(0,Q.useRef)(r),C=(0,Q.useRef)(!0),w=(0,Q.useRef)(null),T=(0,Q.useRef)(!1);v.current=d,y.current=p,S.current=r;let E=(0,Q.useRef)(null),D=(0,Q.useCallback)(()=>{let e=_.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,128)}px`)},[]),O=(0,Q.useCallback)(()=>{E.current===null&&(E.current=requestAnimationFrame(()=>{E.current=null,D()}))},[D]);(0,Q.useEffect)(()=>()=>{E.current!==null&&cancelAnimationFrame(E.current),E.current=null},[]),(0,Q.useLayoutEffect)(()=>{let e=_.current;if(!e||typeof ResizeObserver>`u`)return;let t=e.clientWidth,n=new ResizeObserver(()=>{t!==e.clientWidth&&(t=e.clientWidth,O())});return n.observe(e),()=>n.disconnect()},[O]),(0,Q.useLayoutEffect)(()=>{let e=_.current;!e||h||(Vp(e,u),c&&Hp(e,c),D())},[u,c,h,D]),(0,Q.useLayoutEffect)(()=>{if(T.current)return;let e=_.current;e&&(T.current=!0,c&&Hp(e,c),Qp(e,n,n.length,l),mm(e,n),D())},[D,n,c,l]),(0,Q.useLayoutEffect)(()=>{let e=_.current;e&&Qp(e,v.current,zp(e),l)},[l]);let k=(0,Q.useCallback)(()=>{let e=_.current;if(!e)return;e.focus({preventScroll:!0});let t=window.getSelection(),n=b.current;if(t&&n?.startContainer.isConnected&&n.endContainer.isConnected&&e.contains(n.startContainer)&&e.contains(n.endContainer)){t.removeAllRanges(),t.addRange(n);return}Qp(e,v.current,y.current,l)},[l]),A=(0,Q.useCallback)(e=>{let t=e?.nextText??``,n=e?.caretOffset??t.length;f(t),S.current?.(t),v.current=t,m(n),y.current=n,b.current=null;let r=_.current;r&&(Qp(r,t,n,l),mm(r,t),e?.focus&&r.focus({preventScroll:!0})),O()},[O,l]);(0,Q.useEffect)(()=>{O()},[d,O]);let j=(0,Q.useRef)(a?.id??0);return(0,Q.useLayoutEffect)(()=>{!a||a.id===j.current||(j.current=a.id,x.current=a.id,o?.(),A({nextText:a.text,focus:typeof globalThis.matchMedia==`function`&&globalThis.matchMedia(`(hover: hover) and (pointer: fine)`).matches}))},[a,o,A]),(0,Q.useLayoutEffect)(()=>{if(t){C.current=!0;return}let e=i??null,n=C.current,r=e!==w.current;if(!n&&!r)return;C.current=!0;let a=requestAnimationFrame(()=>{if(!(typeof globalThis.matchMedia==`function`&&globalThis.matchMedia(`(hover: hover) and (pointer: fine)`).matches)||document.activeElement?.closest(`[role="dialog"]`))return;let t=_.current;t&&(t.focus({preventScroll:!0}),document.activeElement===t&&(C.current=!1,w.current=e))});return()=>cancelAnimationFrame(a)},[t,i]),(0,Q.useEffect)(()=>{let e=_.current;if(!e)return;let t=!1,n=null,r=!1,i=-1,a=()=>{let t=window.getSelection();if(!t?.rangeCount||!e.contains(t.anchorNode)||!e.contains(t.focusNode))return null;let n=zp(e);return y.current=n,b.current=t.getRangeAt(0).cloneRange(),n},o=()=>{if(n=null,r=!1,document.activeElement!==e)return;let t=a();t!==null&&t!==i&&(i=t,s.current&&m(t))},c=()=>{t&&(r||(r=!0,n=requestAnimationFrame(o)))},l=()=>{t||(t=!0,document.addEventListener(`selectionchange`,c),c())},u=()=>{t&&(t=!1,document.removeEventListener(`selectionchange`,c),n!=null&&cancelAnimationFrame(n),n=null,r=!1)},d=()=>l(),f=()=>{a(),u()};return e.addEventListener(`focus`,d),e.addEventListener(`blur`,f),document.activeElement===e&&l(),()=>{e.removeEventListener(`focus`,d),e.removeEventListener(`blur`,f),u()}},[s]),(0,Q.useEffect)(()=>{let t=t=>{if(e.receiveExternalFill===!1)return;let n=t.detail;typeof n?.text==`string`&&(o?.(n),A({nextText:n.text,focus:!0}))};return window.addEventListener(cm,t),()=>window.removeEventListener(cm,t)},[o,e.receiveExternalFill,A]),{value:d,cursor:p,isComposing:h,setIsComposing:g,editorRef:_,valueRef:v,adjustHeight:O,focusForExternalPaste:k,resetEditor:A,onWireInput:(0,Q.useCallback)((e,t)=>{v.current=e,y.current=t,f(e),S.current?.(e),m(t)},[])}}var gm=(0,Q.memo)(function(e){let t=(0,X.c)(42),{editorRef:n,disabled:r,hidden:i,compact:a,placeholder:o,ariaLabel:s,onWireInput:c,adjustHeight:l,processFiles:u,processPastedText:d,setIsComposing:f,kbdRef:p,chatMessages:m}=e,h=a!==void 0&&a,g=(0,Q.useRef)(!1),_,v;t[0]!==r||t[1]!==n||t[2]!==i?(_=()=>{if(r||i||!n.current)return;let e=requestAnimationFrame(_m);return()=>cancelAnimationFrame(e)},v=[r,i,n],t[0]=r,t[1]=n,t[2]=i,t[3]=_,t[4]=v):(_=t[3],v=t[4]),(0,Q.useEffect)(_,v);let y,b;t[5]!==r||t[6]!==n?(y=()=>{let e=n.current;if(!e||r)return;let t=t=>{t.inputType!==`deleteContentBackward`||!t.cancelable||t.isComposing||g.current||Yp(e)&&t.preventDefault()};return e.addEventListener(`beforeinput`,t),()=>e.removeEventListener(`beforeinput`,t)},b=[r,n],t[5]=r,t[6]=n,t[7]=y,t[8]=b):(y=t[7],b=t[8]),(0,Q.useEffect)(y,b);let x=s??o,S=!r,C=h?`max-h-32 min-h-10 py-2`:`max-h-24 min-h-12 py-1.5 sm:max-h-32 sm:min-h-16 sm:py-2`,w;t[9]===C?w=t[10]:(w=Y(`composer-input box-border m-0 w-full overflow-y-auto border-0 bg-transparent px-0 text-[0.9375rem] leading-6 text-fg focus:outline-none focus:ring-0 disabled:opacity-50`,C,`composer-input-empty`),t[9]=C,t[10]=w);let T;t[11]!==l||t[12]!==c?(T=e=>{let t=e.currentTarget,n=g.current?Fp(t):Lp(t),r=e.nativeEvent.inputType;!g.current&&r?.startsWith(`delete`)&&n===`
|
|
11
|
+
`&&t.children.length===1&&t.firstElementChild?.tagName===`BR`&&Array.from(t.childNodes).every(e=>e===t.firstElementChild||e.nodeType===Node.TEXT_NODE&&!e.textContent)&&(t.replaceChildren(),n=``),mm(t,n),c(n,zp(t)),l()},t[11]=l,t[12]=c,t[13]=T):T=t[13];let E;t[14]===f?E=t[15]:(E=()=>{g.current=!0,f(!0)},t[14]=f,t[15]=E);let D;t[16]!==l||t[17]!==n||t[18]!==c||t[19]!==f?(D=()=>{g.current=!1,f(!1),queueMicrotask(()=>{let e=n.current;if(!e||g.current)return;let t=Lp(e);mm(e,t),c(t,zp(e)),l()})},t[16]=l,t[17]=n,t[18]=c,t[19]=f,t[20]=D):D=t[20];let O;t[21]!==m||t[22]!==u||t[23]!==d?(O=async e=>{let t=om(e.clipboardData);t&&(e.preventDefault(),await sm(t,{processFiles:u,processPastedText:d,insertText:vm,onUnsupportedFiles:()=>ba(`warning`,m.clipboardFileTypeUnsupported)}))},t[21]=m,t[22]=u,t[23]=d,t[24]=O):O=t[24];let k;t[25]!==r||t[26]!==n||t[27]!==i||t[28]!==p?(k=e=>{let t=p.current;if(t.isComposing||g.current||e.nativeEvent.isComposing||e.nativeEvent.keyCode===229)return;if(e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&t.runBusy&&!t.editingUserTurnId&&!t.editingFollowUpId&&!r&&!i){if(e.preventDefault(),e.repeat)return;(t.pendingFollowUpsCount>0||t.valueRef.current.trim()||t.attachmentsLen>0||t.contextRefsLen>0)&&t.steerCurrentReply?.();return}if(e.key===`Backspace`&&!t.isComposing&&!g.current&&!e.nativeEvent.isComposing&&n.current&&Yp(n.current)){e.preventDefault();return}if($p(t.adapters,e))return;if((e.key===`Tab`||e.key===`Enter`)&&!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!t.isComposing&&!g.current&&!e.nativeEvent.isComposing&&!r&&!i&&!t.runBusy&&!t.pendingFollowUpsCount&&!t.editingFollowUpId&&!t.attachmentsLen&&!t.contextRefsLen&&t.valueRef.current.length===0&&t.acceptEmptySuggestion?.()){e.preventDefault();return}if(!t.isComposing&&(e.key===`ArrowUp`||e.key===`ArrowDown`)){let n=e.key===`ArrowUp`?`up`:`down`;if(t.tryInputHistoryArrow?.(n)){e.preventDefault(),t.adjustHeight();return}}if(e.key===`Escape`&&!t.isComposing&&t.editingUserTurnId){e.preventDefault(),t.onCancelUserMessageEdit?.();return}if(e.key===`Escape`&&!t.isComposing&&t.editingFollowUpId){e.preventDefault(),t.onCancelEditFollowUp?.();return}if(e.key===`Escape`&&!t.isComposing&&!g.current&&t.valueRef.current.length===0&&t.dismissEmptySuggestion?.(),e.key===`Enter`&&e.shiftKey&&!t.isComposing){e.preventDefault(),document.execCommand(`insertText`,!1,`
|
|
12
|
+
`);return}let a=typeof KeyboardEvent<`u`&&e.nativeEvent instanceof KeyboardEvent&&e.nativeEvent.isComposing;if(e.key===`Enter`&&!e.shiftKey&&!t.isComposing&&!g.current&&!a&&!r&&!i){e.preventDefault();let n=!!(t.valueRef.current.trim()||t.attachmentsLen>0||t.contextRefsLen>0);if(e.altKey&&!e.metaKey&&!e.ctrlKey&&n&&t.runBusy&&!t.editingUserTurnId&&!t.editingFollowUpId){t.steerDraft?.();return}if(e.metaKey||e.ctrlKey||e.altKey)return;n&&t.send()}},t[25]=r,t[26]=n,t[27]=i,t[28]=p,t[29]=k):k=t[29];let A;return t[30]!==n||t[31]!==i||t[32]!==o||t[33]!==T||t[34]!==E||t[35]!==D||t[36]!==O||t[37]!==k||t[38]!==x||t[39]!==S||t[40]!==w?(A=(0,Z.jsx)(`div`,{ref:n,hidden:i,role:`textbox`,"aria-multiline":`true`,"aria-label":x,contentEditable:S,suppressContentEditableWarning:!0,spellCheck:!0,className:w,"data-placeholder":o,onInput:T,onCompositionStart:E,onCompositionEnd:D,onPaste:O,onKeyDown:k}),t[30]=n,t[31]=i,t[32]=o,t[33]=T,t[34]=E,t[35]=D,t[36]=O,t[37]=k,t[38]=x,t[39]=S,t[40]=w,t[41]=A):A=t[41],A});function _m(){return r(`composer_ready_frame`)}function vm(e){return document.execCommand(`insertText`,!1,e)}function ym(e){let t=(0,X.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({children:n,dragging:a,className:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a!==void 0&&a&&`ring-2 ring-accent ring-inset`,s;t[5]!==r||t[6]!==o?(s=Y(`chat-composer-surface relative flex min-h-0 w-full flex-col overflow-hidden rounded-2xl shadow-elevated ring-1 ring-inset ring-edge-subtle focus-within:ring-edge dark:shadow-surface`,o,r),t[5]=r,t[6]=o,t[7]=s):s=t[7];let c;return t[8]!==n||t[9]!==i||t[10]!==s?(c=(0,Z.jsx)(`div`,{className:s,...i,children:n}),t[8]=n,t[9]=i,t[10]=s,t[11]=c):c=t[11],c}function bm(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function xm(e){let t=(0,X.c)(12),{disabled:n,runBusy:r,attachmentCount:i,maxAttachments:a,chat:o,onPickFiles:s}=e,c=i>=a,l;t[0]!==i||t[1]!==c||t[2]!==o.attachFile||t[3]!==o.maxAttachmentsReached||t[4]!==a?(l=c?bm(o.maxAttachmentsReached,{max:a}):`${o.attachFile} (${i}/${a})`,t[0]=i,t[1]=c,t[2]=o.attachFile,t[3]=o.maxAttachmentsReached,t[4]=a,t[5]=l):l=t[5];let u=l,d;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=Y(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,la.transition,la.press,la.focusRingPanel,`disabled:cursor-not-allowed disabled:opacity-50`),t[6]=d):d=t[6];let f=c||n||r,p;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(Nt,{className:`size-4`}),t[7]=p):p=t[7];let m;return t[8]!==s||t[9]!==f||t[10]!==u?(m=(0,Z.jsx)(`button`,{type:`button`,className:d,disabled:f,title:u,"aria-label":u,onClick:s,children:p}),t[8]=s,t[9]=f,t[10]=u,t[11]=m):m=t[11],m}function Sm(e){let t=(0,X.c)(12),{disabled:n,voiceActive:r,runBusy:i,hasDraft:a,showSteeringInterrupt:o,chat:s,onSend:c,onAbort:l,onInterrupt:u}=e,d;return t[0]!==n||t[1]!==a||t[2]!==s.abort||t[3]!==s.sendMessage||t[4]!==s.steeringInterruptSend||t[5]!==l||t[6]!==u||t[7]!==c||t[8]!==i||t[9]!==o||t[10]!==r?(d=(0,Z.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:i?(0,Z.jsxs)(Z.Fragment,{children:[o&&u?(0,Z.jsx)(`button`,{type:`button`,className:Y(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg border border-transparent text-accent-fg hover:bg-accent-soft dark:hover:bg-accent-soft`,la.transition,la.press,la.focusRingPanel),title:s.steeringInterruptSend,"aria-label":s.steeringInterruptSend,onClick:()=>void u(),children:(0,Z.jsx)(me,{className:`size-4 stroke-[1.75]`})}):null,(0,Z.jsx)(`button`,{type:`button`,className:Y(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover/70 text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/50`,la.transition,la.press,la.focusRingPanel),title:s.abort,"aria-label":s.abort,onClick:l,children:(0,Z.jsx)(Ut,{className:`size-4 stroke-[1.75]`})})]}):(0,Z.jsx)(`button`,{type:`button`,className:Y(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg border transition-colors duration-150 ease-out`,la.press,la.focusRingPanel,a?`border-transparent text-accent-fg hover:bg-accent-soft dark:text-accent-fg dark:hover:bg-accent-soft`:`border-transparent text-fg-disabled`),disabled:n||r||!a,title:s.sendMessage,"aria-label":s.sendMessage,onClick:c,children:(0,Z.jsx)(me,{className:`size-4 stroke-[1.75]`})})}),t[0]=n,t[1]=a,t[2]=s.abort,t[3]=s.sendMessage,t[4]=s.steeringInterruptSend,t[5]=l,t[6]=u,t[7]=c,t[8]=i,t[9]=o,t[10]=r,t[11]=d):d=t[11],d}function Cm(e){let t=(0,X.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Y(`flex flex-wrap items-center gap-2 px-3 py-1.5 sm:px-4 sm:py-2.5`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var wm=(0,Q.memo)(function(e){let t=(0,X.c)(42),{disabled:n,sendDisabled:r,runBusy:i,chat:a,hasDraft:o,showSteeringInterrupt:s,attachmentCount:c,maxAttachments:l,onPickFiles:u,thinkingLevel:d,onThinkingChange:f,voiceActive:p,onStartVoiceInput:m,voiceConversationEnabled:h,onStartVoiceConversation:g,onSend:_,onAbort:v,onInterrupt:y,sessionModel:b,showModelSelector:x,onModelChange:S,modelDisabled:C}=e,w=r!==void 0&&r;if(p)return null;let T;t[0]!==c||t[1]!==n||t[2]!==a||t[3]!==l||t[4]!==u||t[5]!==i?(T=(0,Z.jsx)(xm,{disabled:n,runBusy:i,attachmentCount:c,maxAttachments:l,chat:a,onPickFiles:u}),t[0]=c,t[1]=n,t[2]=a,t[3]=l,t[4]=u,t[5]=i,t[6]=T):T=t[6];let E;t[7]!==n||t[8]!==a||t[9]!==C||t[10]!==S||t[11]!==f||t[12]!==b||t[13]!==x||t[14]!==d?(E=x?(0,Z.jsx)(Zr,{chat:a,sessionModel:b,modelDisabled:C,onModelChange:S,thinkingLevel:d,thinkingDisabled:n||C,onThinkingChange:f}):null,t[7]=n,t[8]=a,t[9]=C,t[10]=S,t[11]=f,t[12]=b,t[13]=x,t[14]=d,t[15]=E):E=t[15];let D;t[16]!==n||t[17]!==a||t[18]!==g||t[19]!==m||t[20]!==p||t[21]!==h?(D=p?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ni,{disabled:n,chat:a,onStart:m}),(0,Z.jsx)(`button`,{type:`button`,className:Y(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg border border-transparent text-fg-subtle hover:bg-surface-hover hover:text-fg`,la.transition,la.press,la.focusRingPanel,`disabled:cursor-not-allowed disabled:opacity-50`),disabled:n||!h,title:a.voiceConversation,"aria-label":a.voiceConversation,onClick:()=>void g(),children:(0,Z.jsx)(B,{className:`size-4 stroke-[1.75]`})})]}),t[16]=n,t[17]=a,t[18]=g,t[19]=m,t[20]=p,t[21]=h,t[22]=D):D=t[22];let O=n||w,k;t[23]!==o||t[24]!==a||t[25]!==v||t[26]!==y||t[27]!==_||t[28]!==i||t[29]!==s||t[30]!==O||t[31]!==p?(k=(0,Z.jsx)(Sm,{disabled:O,voiceActive:p,runBusy:i,hasDraft:o,showSteeringInterrupt:s,chat:a,onSend:_,onAbort:v,onInterrupt:y}),t[23]=o,t[24]=a,t[25]=v,t[26]=y,t[27]=_,t[28]=i,t[29]=s,t[30]=O,t[31]=p,t[32]=k):k=t[32];let A;t[33]!==D||t[34]!==k?(A=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[D,k]}),t[33]=D,t[34]=k,t[35]=A):A=t[35];let j;t[36]!==E||t[37]!==A?(j=(0,Z.jsxs)(`div`,{className:`ml-auto flex min-w-0 items-center gap-2`,children:[E,A]}),t[36]=E,t[37]=A,t[38]=j):j=t[38];let M;return t[39]!==T||t[40]!==j?(M=(0,Z.jsxs)(Cm,{children:[T,j]}),t[39]=T,t[40]=j,t[41]=M):M=t[41],M}),Tm=(0,Q.memo)(function(e){let t=(0,X.c)(18),{spotlight:n,onPickPrompt:r,compact:i}=e,a=i!==void 0&&i,o=v(Em),s=n.recommendation,c=a?`gap-4 pb-3 pt-5`:`gap-5 pb-6 pt-32 sm:pt-36 [@media(max-height:800px)]:pt-12`,l;t[0]===c?l=t[1]:(l=Y(`flex flex-col items-center px-3 text-center`,c),t[0]=c,t[1]=l);let u=a?`size-24`:`size-28 sm:size-32 [@media(max-height:800px)]:size-24`,d;t[2]===u?d=t[3]:(d=Y(`shrink-0`,u),t[2]=u,t[3]=d);let f;t[4]!==o||t[5]!==d?(f=(0,Z.jsx)(ka,{className:d,interactive:!0,language:o,mood:`listen`}),t[4]=o,t[5]=d,t[6]=f):f=t[6];let p;t[7]===n.headline?p=t[8]:(p=(0,Z.jsx)(`h1`,{className:`max-w-xl text-balance text-xl font-semibold tracking-tight text-fg`,children:n.headline}),t[7]=n.headline,t[8]=p);let m;t[9]!==r||t[10]!==s||t[11]!==n.contextKind?(m=s?(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>r({suggestionId:s.id,contextKind:n.contextKind,prompt:s.prompt}),className:Y(`mt-4 flex min-h-16 w-full max-w-xl items-center gap-3 rounded-xl border border-edge bg-surface-panel px-4 py-3 text-left hover:border-edge-strong hover:bg-surface-hover`,la.transition,la.press,la.focusRingPanel),children:[(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`line-clamp-2 block text-sm font-medium leading-snug text-fg sm:text-[0.9375rem]`,children:s.title}),(0,Z.jsx)(`span`,{className:`mt-1 block truncate text-xs text-fg-muted`,children:s.reason})]}),(0,Z.jsx)(ae,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0})]}):null,t[9]=r,t[10]=s,t[11]=n.contextKind,t[12]=m):m=t[12];let h;return t[13]!==l||t[14]!==f||t[15]!==p||t[16]!==m?(h=(0,Z.jsxs)(`div`,{className:l,children:[f,p,m]}),t[13]=l,t[14]=f,t[15]=p,t[16]=m,t[17]=h):h=t[17],h});function Em(e){return e.language}function Dm({provenance:e}){let t=v(e=>e.language),n=t===`zh`,r=S(t).chat.provenanceErrors,[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(0),_=n?{follow_up:`跟进你交代的事情`,discussion:`延续之前的讨论`,change:`关注的事情有新进展`,prepared:`之前的准备有了结果`}:{follow_up:`Following up as requested`,discussion:`Continuing our discussion`,change:`An update on what matters`,prepared:`Your preparation is ready`};(0,Q.useEffect)(()=>{if(!i)return;let t=!0;return s(void 0),l(``),y(g(`/api/personal-agent/outreach/${e.outreachId}/provenance`)).then(e=>{if(!e.ok)throw Error(e.error??r.load);t&&s(ar.parse(e.payload))}).catch(e=>{t&&l(String(e))}),()=>{t=!1}},[i,e.outreachId,m,r.load]);async function b(t,n={}){d(!0),l(``);try{let i=await y(g(`/api/personal-agent/outreach/${e.outreachId}/feedback`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({idempotencyKey:crypto.randomUUID(),kind:t,scope:`thread`,...n})});if(!i.ok)throw Error(i.error??r.save);p(!1),h(e=>e+1)}catch(e){l(String(e))}finally{d(!1)}}async function x(){let e=o?.strategy?.versions[0];if(!(!o||!e||u)){d(!0),l(``);try{let t=await y(g(`/api/personal-agent/attention/${o.thread.id}/strategy/rollback`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({versionId:e.id,revision:o.thread.revision,idempotencyKey:crypto.randomUUID()})});if(!t.ok)throw Error(t.error??r.undo);p(!1),h(e=>e+1)}catch(e){l(String(e))}finally{d(!1)}}}let j=o&&[`completed`,`expired`].includes(o.thread.status);return(0,Z.jsxs)(A,{open:i,onOpenChange:e=>{a(e),p(!1)},children:[(0,Z.jsx)(w,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`${Ho} mt-2`,"aria-label":n?`查看主动联系的缘由`:`Why this message`,children:(0,Z.jsx)(Uo,{icon:(0,Z.jsx)(Ht,{strokeWidth:1.5}),title:_[e.reasonKind],trailing:(0,Z.jsx)(ae,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0})})})}),(0,Z.jsxs)(D,{children:[(0,Z.jsx)(C,{className:`fixed inset-0 z-50 bg-black/20`}),(0,Z.jsxs)(O,{className:`fixed inset-x-0 bottom-0 z-50 flex h-[min(28rem,75dvh)] flex-col overflow-hidden rounded-t-2xl border border-edge bg-surface-overlay sm:inset-x-auto sm:bottom-auto sm:left-1/2 sm:top-1/2 sm:w-[min(25rem,calc(100vw-2rem))] sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-xl`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge px-5 py-4`,children:[(0,Z.jsx)(k,{className:`text-sm font-medium text-fg`,children:n?`为什么联系你`:`Why I reached out`}),(0,Z.jsx)(E,{className:`rounded p-1 text-fg-muted hover:text-fg`,"aria-label":n?`关闭`:`Close`,children:(0,Z.jsx)(Xt,{className:`size-4`})})]}),(0,Z.jsx)(T,{className:`sr-only`,children:n?`消息的依据、时机与后续跟进`:`Sources, timing, and follow-up for this message`}),(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4 text-sm`,children:[!o&&!c&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Qt,{className:`h-5 w-3/4`}),(0,Z.jsx)(Qt,{className:`h-20 w-full`}),(0,Z.jsx)(Qt,{className:`h-12 w-full`})]}),o&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`mb-1 font-medium text-fg`,children:n?`为什么关注`:`Why this topic`}),(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:o.sourcesAvailable?o.thread.subject:n?`原始依据已不可用`:`The original sources are no longer available`}),o.sourcesAvailable&&e.authority===`inferred`&&(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n?`根据之前的讨论判断你可能仍在关注,并非明确委托。`:`Inferred from our discussion; this is not an explicit request.`})]}),o.sourcesAvailable&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`mb-1 font-medium text-fg`,children:n?`为什么现在联系`:`Why now`}),(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:o.whyNow})]}),o.sources.map(e=>(0,Z.jsxs)(`a`,{className:`block rounded border border-edge p-2 text-fg-muted hover:text-accent`,onClick:()=>a(!1),href:`#/chat/${encodeURIComponent(e.conversationId)}?entryId=${encodeURIComponent(e.entryId)}`,children:[(0,Z.jsx)(`span`,{className:`line-clamp-2 text-xs`,children:e.excerpt}),(0,Z.jsxs)(`span`,{className:`mt-1 block text-xs text-accent`,children:[n?`查看相关对话`:`View conversation`,` ↗`]})]},e.entryId)),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`mb-1 font-medium text-fg`,children:n?`后续`:`Next`}),(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:j?n?`已停止关注`:`No longer following`:o.thread.status===`paused`?n?`已延后跟进`:`Follow-up postponed`:n?`有新的有效进展时,再判断是否值得交流。`:`I will reassess when there is something useful to share.`})]}),f&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,disabled:u,className:`rounded border border-edge px-3 py-2`,onClick:()=>void b(`defer`,{until:Date.now()+7*864e5}),children:n?`下周再跟进`:`Next week`}),(0,Z.jsx)(`button`,{type:`button`,disabled:u,className:`rounded border border-edge px-3 py-2`,onClick:()=>void b(`adjust`,{preparation:`thorough`}),children:n?`以后先准备完整`:`Prepare more thoroughly`}),(0,Z.jsx)(`button`,{type:`button`,disabled:u,className:`rounded border border-edge px-3 py-2`,onClick:()=>void b(`adjust`,{preparation:`brief`}),children:n?`以后简短一点`:`Keep it brief`})]}),o.strategy&&(0,Z.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[(0,Z.jsxs)(`p`,{children:[n?`准备方式:`:`Preparation: `,o.strategy.preparation===`thorough`?n?`先准备完整`:`Thorough`:o.strategy.preparation===`brief`?n?`简短交流`:`Brief`:n?`按当前内容判断`:`Based on the topic`]}),o.strategy.versions.length>0&&(0,Z.jsxs)(`details`,{className:`mt-2`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer`,children:n?`查看调整记录`:`View adjustments`}),(0,Z.jsx)(`ul`,{className:`mt-2 space-y-1`,children:o.strategy.versions.map(e=>(0,Z.jsxs)(`li`,{children:[n?{stop:`停止关注`,defer:`延后跟进`,adjust:`调整准备方式`,rollback:`撤销调整`}[e.kind]:{stop:`Stopped`,defer:`Postponed`,adjust:`Preparation changed`,rollback:`Undone`}[e.kind],` · `,new Date(e.createdAt).toLocaleString(n?`zh-CN`:`en`)]},e.id))})]})]})]}),c&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-danger`,children:c})]}),(0,Z.jsxs)(`div`,{className:`flex gap-3 border-t border-edge px-5 py-3 text-xs`,children:[(0,Z.jsx)(`button`,{type:`button`,disabled:!o||u||!!j,onClick:()=>p(e=>!e),className:`text-fg-muted hover:text-fg disabled:opacity-50`,children:n?`调整跟进`:`Adjust follow-up`}),(0,Z.jsx)(`button`,{type:`button`,disabled:!o||u||!!j,onClick:()=>void b(`stop`),className:`text-fg-muted hover:text-fg disabled:opacity-50`,children:n?`停止关注`:`Stop following`}),o?.strategy?.versions.length?(0,Z.jsx)(`button`,{type:`button`,disabled:u||!o.sourcesAvailable,onClick:()=>void x(),className:`ml-auto text-fg-muted hover:text-fg disabled:opacity-50`,children:n?`撤销最近调整`:`Undo latest`}):null]})]})]})]})}function Om(e,t){let n=t?.split(`;`)[0]?.trim();return!n?.startsWith(`image/`)||e.type===n?e:new Blob([e],{type:n})}function km(e,t){let n=(0,X.c)(29),r;n[0]!==e.mimeType||n[1]!==e.type?(r=e.type===`image`||e.mimeType?.startsWith(`image/`)===!0,n[0]=e.mimeType,n[1]=e.type,n[2]=r):r=n[2];let i=r,a;n[3]!==e||n[4]!==i?(a=i?ui(e):void 0,n[3]=e,n[4]=i,n[5]=a):a=n[5];let o=a,s;bb0:{if(!o){s=void 0;break bb0}let t=e.mimeType?.startsWith(`image/`)?e.mimeType:`image/png`,r;n[6]!==o||n[7]!==t?(r=li(t,o),n[6]=o,n[7]=t,n[8]=r):r=n[8],s=r}let c=s,l=`${e.uri??``}\n${t.conversationId??``}\n${e.taskId??``}`,[u,d]=(0,Q.useState)(),f;n[9]!==e.mimeType||n[10]!==e.taskId||n[11]!==e.uri||n[12]!==c||n[13]!==i||n[14]!==t.authToken||n[15]!==t.conversationId||n[16]!==l?(f=()=>{if(c||!e.uri||!i){d(void 0);return}if(!String(t.authToken??``).trim()){d(void 0);return}let n,r=!1;return d({key:l,status:`loading`}),(async()=>{let i=await Pe({uri:e.uri,conversationId:t.conversationId,taskId:e.taskId});if(r)return;if(!i.ok){d({key:l,status:`error`});return}let a=URL.createObjectURL(Om(i.blob,e.mimeType));n=a,d({key:l,blobUrl:a,status:`loaded`})})(),()=>{r=!0,n&&URL.revokeObjectURL(n)}},n[9]=e.mimeType,n[10]=e.taskId,n[11]=e.uri,n[12]=c,n[13]=i,n[14]=t.authToken,n[15]=t.conversationId,n[16]=l,n[17]=f):f=n[17];let p;n[18]!==e.taskId||n[19]!==e.uri||n[20]!==c||n[21]!==i||n[22]!==t.authToken||n[23]!==t.conversationId||n[24]!==l?(p=[c,e.taskId,e.uri,i,t.authToken,t.conversationId,l],n[18]=e.taskId,n[19]=e.uri,n[20]=c,n[21]=i,n[22]=t.authToken,n[23]=t.conversationId,n[24]=l,n[25]=p):p=n[25],(0,Q.useEffect)(f,p);let m=u?.key===l?u:void 0,h=c??m?.blobUrl??``,g=!c&&m?.status===`error`,_;return n[26]!==h||n[27]!==g?(_={src:h,error:g},n[26]=h,n[27]=g,n[28]=_):_=n[28],_}function Am(e){let t=(0,X.c)(51),{attachment:n,authToken:r,conversationId:i,showDelete:a,onDelete:o,imageSize:s,compact:c,className:l,overflowLabel:u,onOpen:d}=e,f=a!==void 0&&a,p=s===void 0?`thumbnail`:s,m=c!==void 0&&c,h=v(jm),g;t[0]===h?g=t[1]:(g=S(h),t[0]=h,t[1]=g);let _=g,y=(0,Q.useId)(),b;t[2]!==n.mimeType||t[3]!==n.type?(b=n.mimeType?.startsWith(`image/`)||n.type===`image`,t[2]=n.mimeType,t[3]=n.type,t[4]=b):b=t[4];let x=b,C;t[5]!==r||t[6]!==i?(C={authToken:r,conversationId:i},t[5]=r,t[6]=i,t[7]=C):C=t[7];let w=km(n,C),T;t[8]===n?T=t[9]:(T=!!n.uri&&!ui(n),t[8]=n,t[9]=T);let E=T,D;t[10]!==r||t[11]!==E?(D=E&&!String(r??``).trim(),t[10]=r,t[11]=E,t[12]=D):D=t[12];let O=D,k=n.mimeType===`application/pdf`,A;t[13]!==n.mimeType||t[14]!==n.name?(A=n.mimeType?.includes(`spreadsheetml`)||n.name?.toLowerCase().endsWith(`.xlsx`)||n.name?.toLowerCase().endsWith(`.xls`),t[13]=n.mimeType,t[14]=n.name,t[15]=A):A=t[15];let j=A,M=n.name??`file`,N=n.type===`pasted_text`,P=N&&!O,F=n.mimeType?.split(`;`,1)[0]?.trim().toLowerCase()===`text/html`?`HTML`:n.mimeType?.split(`;`,1)[0]?.trim().toLowerCase()===`application/json`?`JSON`:`TXT`,I;t[16]!==n.size||t[17]!==F?(I=typeof n.size==`number`?`${F} · ${di(n.size)}`:F,t[16]=n.size,t[17]=F,t[18]=I):I=t[18];let L=I,R=O?`${M} — ${_.chat.attachmentPreviewMissingAuth}`:M,z=_.chat.attachmentPreviewMissingAuth,B=p===`single`?`size-full object-contain`:p===`grid-cell`?`size-full object-cover`:`max-h-16 w-full object-cover`,ee=p===`single`?m?`w-36 max-w-full`:`w-44 max-w-full`:p===`grid-cell`?`min-h-0 w-full`:`max-w-[10rem]`,V=p===`grid-cell`?`relative block aspect-square w-full min-w-0 overflow-hidden rounded-md border border-edge dark:border-edge`:p===`single`?`relative block aspect-[4/3] w-full overflow-hidden rounded-md border border-edge bg-surface-hover dark:border-edge`:`block w-full overflow-hidden rounded-md border border-edge dark:border-edge`,H=p===`grid-cell`?`w-full min-h-0`:`inline-block`,U;t[19]!==l||t[20]!==H?(U=Y(`group relative min-w-0`,H,l),t[19]=l,t[20]=H,t[21]=U):U=t[21];let W;t[22]!==n||t[23]!==M||t[24]!==V||t[25]!==w||t[26]!==B||t[27]!==ee||t[28]!==j||t[29]!==x||t[30]!==N||t[31]!==k||t[32]!==_.chat.attachmentPreviewLoadError||t[33]!==_.chat.pastedText||t[34]!==R||t[35]!==y||t[36]!==z||t[37]!==d||t[38]!==u||t[39]!==L||t[40]!==O||t[41]!==P?(W=x?(0,Z.jsxs)(`div`,{className:ee,children:[(0,Z.jsxs)(`div`,{className:`relative size-full min-h-0`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:Y(V,la.transition,la.press,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),onClick:()=>d(n),title:R,"aria-label":R,"aria-describedby":O?y:void 0,children:[w.src?(0,Z.jsx)(`img`,{src:w.src,alt:M,className:B,decoding:`async`}):w.error||O?(0,Z.jsxs)(`span`,{className:`flex size-full flex-col items-center justify-center gap-1 bg-surface-hover px-2 text-center text-[10px] text-fg-muted`,title:O?z:_.chat.attachmentPreviewLoadError,children:[(0,Z.jsx)(ze,{className:`size-5`,strokeWidth:1.5,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:O?z:_.chat.attachmentPreviewLoadError})]}):(0,Z.jsx)(`span`,{className:`block size-full animate-pulse bg-surface-active`,"aria-hidden":!0}),u?(0,Z.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center bg-black/55 text-lg font-semibold text-white`,children:u}):null]}),k?(0,Z.jsx)(`div`,{className:`pointer-events-none absolute bottom-1 right-1 rounded bg-black/60 px-1.5 py-0.5 text-[10px] font-semibold text-white`,"aria-hidden":!0,children:`PDF`}):null]}),O?(0,Z.jsx)(`p`,{id:y,className:`mt-1 line-clamp-2 text-[10px] leading-snug text-amber-600 dark:text-amber-500`,children:z}):null]}):(0,Z.jsx)(`div`,{className:Y(`max-w-[14rem]`,P&&`inline-flex max-w-full`),children:(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>d(n),title:R,"aria-label":R,"aria-describedby":O?y:void 0,className:Y(`flex min-w-0 border border-edge bg-surface-hover text-left text-xs text-fg-muted hover:bg-surface-active dark:border-edge`,P?`w-auto max-w-full items-center gap-1.5 rounded-full px-2.5 py-1`:`w-full gap-2 rounded-md px-2 py-1.5`,O?`items-start`:`items-center`,la.transition,la.press,la.focusRingPanel),children:[N?(0,Z.jsx)(Te,{className:Y(`shrink-0 text-accent-fg`,P?`size-3.5`:`size-8`),"aria-hidden":!0}):j?(0,Z.jsx)(ve,{className:`size-8 shrink-0 text-fg-subtle`,"aria-hidden":!0}):(0,Z.jsx)(Oe,{className:`size-8 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:Y(`truncate text-fg`,P?`inline`:`block`),children:N?_.chat.pastedText:M}),P?(0,Z.jsxs)(`span`,{className:`ml-1 whitespace-nowrap text-fg-subtle`,children:[`· `,L]}):null,O?(0,Z.jsx)(`span`,{id:y,className:`mt-0.5 line-clamp-2 block text-[10px] font-normal leading-snug text-amber-600 dark:text-amber-500`,children:z}):null]})]})}),t[22]=n,t[23]=M,t[24]=V,t[25]=w,t[26]=B,t[27]=ee,t[28]=j,t[29]=x,t[30]=N,t[31]=k,t[32]=_.chat.attachmentPreviewLoadError,t[33]=_.chat.pastedText,t[34]=R,t[35]=y,t[36]=z,t[37]=d,t[38]=u,t[39]=L,t[40]=O,t[41]=P,t[42]=W):W=t[42];let te;t[43]!==_.chat.attachmentPreviewRemove||t[44]!==o||t[45]!==f?(te=f?(0,Z.jsx)(`button`,{type:`button`,className:Y(`absolute -right-1 -top-1 flex size-5 items-center justify-center rounded-full border border-edge bg-surface-panel text-fg-muted shadow-surface hover:text-fg dark:border-edge`,la.transition,la.press,la.focusRingPanel),onClick:e=>{e.stopPropagation(),o?.()},title:_.chat.attachmentPreviewRemove,"aria-label":_.chat.attachmentPreviewRemove,children:(0,Z.jsx)(Xt,{className:`size-3`})}):null,t[43]=_.chat.attachmentPreviewRemove,t[44]=o,t[45]=f,t[46]=te):te=t[46];let ne;return t[47]!==U||t[48]!==W||t[49]!==te?(ne=(0,Z.jsxs)(`div`,{className:U,children:[W,te]}),t[47]=U,t[48]=W,t[49]=te,t[50]=ne):ne=t[50],ne}function jm(e){return e.language}function Mm(e){let t=(0,X.c)(11),{layout:n,conversationId:r,workspaceConversationId:i,projectId:a}=e,[o,s]=(0,Q.useState)(null),c=ai(Nm),l;t[0]!==r||t[1]!==n||t[2]!==a||t[3]!==c||t[4]!==i?(l=(e,t)=>{let o=i??r;if(n===`assistant`&&e.type!==`image`&&!e.mimeType?.startsWith(`image/`)&&e.workspaceRelativePath?.trim()&&(a?.trim()||o?.trim())){c(e.workspaceRelativePath.trim(),null,a,o,t);return}s(e)},t[0]=r,t[1]=n,t[2]=a,t[3]=c,t[4]=i,t[5]=l):l=t[5];let u=l,d;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>s(null),t[6]=d):d=t[6];let f=d,p=o!==null,m;return t[7]!==o||t[8]!==u||t[9]!==p?(m={active:o,open:p,openAttachment:u,closePreview:f,selectAttachment:s},t[7]=o,t[8]=u,t[9]=p,t[10]=m):m=t[10],m}function Nm(e){return e.setPath}function Pm(e){let t=Math.max(0,Math.floor(e));return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}function Fm(e){return typeof e==`number`&&Number.isFinite(e)&&e>0}function Im(e){let t=(0,X.c)(9),{att:n,conversationId:r}=e,i;t[0]!==n.content||t[1]!==n.data||t[2]!==n.taskId||t[3]!==n.uri||t[4]!==r?(i=JSON.stringify([n.uri,n.content,n.data,n.taskId,r]),t[0]=n.content,t[1]=n.data,t[2]=n.taskId,t[3]=n.uri,t[4]=r,t[5]=i):i=t[5];let a;return t[6]!==e||t[7]!==i?(a=(0,Z.jsx)(Lm,{...e},i),t[6]=e,t[7]=i,t[8]=a):a=t[8],a}function Lm({att:e,align:t=`start`,embedded:n=!1,conversationId:r}){let i=v(e=>e.language),a=i===`zh`,o=S(i).chat,s=(0,Q.useId)(),c=(0,Q.useRef)(null),[l,u]=(0,Q.useState)(),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(0),[_,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(1),[D,O]=(0,Q.useState)(0),k=D||(Fm(e.durationSeconds)?e.durationSeconds:0),[A,j]=(0,Q.useState)(0),M=e.content??e.data;(0,Q.useEffect)(()=>{let t=new AbortController,n;return f(!1),u(void 0),(async()=>{try{if(M){u(`data:${e.mimeType||`audio/mpeg`};base64,${M.replace(/\s/g,``)}`);return}if(!e.uri)throw Error(`Missing audio source`);let i=await h(g(fi(e.uri,r,e.taskId)),{signal:t.signal});if(!i.ok)throw Error(`Audio unavailable`);let a=await i.blob();if(t.signal.aborted)return;n=URL.createObjectURL(a),u(n)}catch{t.signal.aborted||f(!0)}})(),()=>{t.abort(),n&&URL.revokeObjectURL(n)}},[M,e.mimeType,e.uri,e.taskId,r,p]),(0,Q.useEffect)(()=>{let e=c.current,t=()=>e?.pause(),n=e=>{let n=e.detail?.id;n&&n!==s&&t()};return window.addEventListener(`xopc-voice-recording-start`,t),window.addEventListener(`xopc-voice-playback-start`,n),()=>{t(),window.removeEventListener(`xopc-voice-recording-start`,t),window.removeEventListener(`xopc-voice-playback-start`,n)}},[s]);let N=()=>{let e=c.current;if(d){m(e=>e+1);return}!e||!l||(_?e.pause():e.play().catch(e=>{e instanceof DOMException&&e.name===`AbortError`||f(!0)}))},P=()=>{let e=c.current?.duration;Fm(e)&&O(e)},F=a?`播放选项`:`Playback options`;return(0,Z.jsx)(`div`,{className:Y(`flex min-w-0`,t===`end`&&`justify-end`,t===`center`&&`justify-center`),children:(0,Z.jsxs)(`div`,{className:Y(`w-60 max-w-full rounded-xl`,!n&&`bg-surface-base px-1`),role:`group`,"aria-label":o.voiceAriaRegion,children:[!l&&!d?(0,Z.jsx)(`span`,{className:`sr-only`,role:`status`,children:o.voiceLoading}):null,(0,Z.jsxs)(`div`,{className:`flex min-h-14 items-center gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:N,disabled:!l&&!d,className:`inline-flex size-11 shrink-0 items-center justify-center rounded-full text-fg hover:bg-surface-hover disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":d?a?`重试播放`:`Retry playback`:_?o.voicePause:o.voicePlay,children:d?(0,Z.jsx)(Ft,{className:`size-5`,"aria-hidden":!0}):_?(0,Z.jsx)(At,{className:`size-5`,"aria-hidden":!0}):(0,Z.jsx)(Mt,{className:`size-5`,"aria-hidden":!0})}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,"aria-hidden":!0,children:!l&&!d?(0,Z.jsx)(Qt,{className:`h-1 w-full`}):(0,Z.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${k>0?Math.min(100,A/k*100):0}%`}})})}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>x(!b),"aria-label":F,"aria-expanded":b,"aria-controls":`${s}-options`,className:`flex min-h-11 shrink-0 items-center gap-1 rounded-lg px-2 text-[13px] tabular-nums text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[A>0||k>0?Pm(A>0?A:k):`—`,(0,Z.jsx)(ie,{className:Y(`size-3`,b&&`rotate-180`),"aria-hidden":!0})]})]}),d?(0,Z.jsx)(`p`,{role:`alert`,className:`px-2 pb-2 text-xs text-fg-muted`,children:a?`音频无法播放,请重试`:`Audio unavailable. Try again.`}):null,b?(0,Z.jsxs)(`div`,{id:`${s}-options`,className:`space-y-2 px-2 pb-3`,children:[(0,Z.jsxs)(`label`,{className:`block text-xs text-fg-muted`,children:[a?`播放进度`:`Playback position`,(0,Z.jsx)(`input`,{type:`range`,min:0,max:k||1,step:.1,value:Math.min(A,k),disabled:!l||!k||d,onChange:e=>{c.current&&(c.current.currentTime=Number(e.target.value),j(Number(e.target.value)))},className:`block h-11 w-full accent-accent`})]}),(0,Z.jsx)(fe,{contentClassName:`[&_button]:min-h-11`,value:String(T),allowEmpty:!1,placeholder:`1×`,ariaLabel:o.voicePlaybackSpeed,triggerClassName:`min-h-11`,options:[.75,1,1.25,1.5,2].map(e=>({value:String(e),label:`${e}×`})),onChange:e=>{let t=Number(e);E(t),c.current&&(c.current.playbackRate=t)}})]}):null,e.extractedText?.trim()?(0,Z.jsxs)(`div`,{className:`px-2 pb-1`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`min-h-11 rounded-lg text-xs text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>w(!C),"aria-expanded":C,"aria-controls":`${s}-text`,children:C?a?`收起文字`:`Hide transcript`:a?`查看文字`:`Show transcript`}),C?(0,Z.jsx)(`p`,{id:`${s}-text`,className:`whitespace-pre-wrap break-words pb-2 text-sm text-fg-muted`,children:e.extractedText}):null]}):null,(0,Z.jsx)(`audio`,{ref:c,src:l,preload:`metadata`,className:`hidden`,onLoadedMetadata:P,onDurationChange:P,onTimeUpdate:e=>j(e.currentTarget.currentTime),onError:()=>{l&&(y(!1),f(!0))},onPlay:e=>{e.currentTarget.playbackRate=T,y(!0),window.dispatchEvent(new CustomEvent(`xopc-voice-playback-start`,{detail:{id:s}}))},onPause:()=>y(!1),onEnded:()=>{y(!1),j(0)}})]})})}function Rm(e){return e.type===`voice`||e.type===`audio`||e.mimeType?.startsWith(`audio/`)===!0}var zm=9;function Bm(e,t){let n=t?`max-w-[11rem]`:`max-w-52`,r=`gap-1`;return e===1?{container:`grid grid-cols-1 ${n} ${r}`,tileSize:`single`}:e===2?{container:`grid grid-cols-2 ${n} ${r}`,tileSize:`grid-cell`}:e===3?{container:`grid grid-cols-3 ${n} ${r}`,tileSize:`grid-cell`}:e===4?{container:`grid grid-cols-2 ${n} ${r}`,tileSize:`grid-cell`}:e<=zm?{container:`grid grid-cols-3 ${n} ${r}`,tileSize:`grid-cell`}:{container:`grid grid-cols-3 ${n} ${r}`,tileSize:`grid-cell`,overflowCount:e-(zm-1)}}function Vm(e){let t=(0,X.c)(32),{attachments:n,authToken:r,conversationId:i,workspaceConversationId:a,projectId:o,layout:s,centerUserVoiceRow:c}=e,l=s===void 0?`assistant`:s,u=c!==void 0&&c,d;t[0]!==i||t[1]!==l||t[2]!==o||t[3]!==a?(d={layout:l,conversationId:i,workspaceConversationId:a,projectId:o},t[0]=i,t[1]=l,t[2]=o,t[3]=a,t[4]=d):d=t[4];let f=Mm(d);if(!n?.length)return null;let p,m,h,g,_;if(t[5]!==n||t[6]!==r||t[7]!==u||t[8]!==i||t[9]!==l||t[10]!==f.openAttachment){p=n.filter(Um);let e=n.filter(Rm),a=n.filter(Hm);m=`flex flex-col gap-2`,h=p.length>0?(()=>{let e=Bm(p.length,l===`user`),t=e.overflowCount==null?p:p.slice(0,zm-1);return(0,Z.jsxs)(`div`,{className:Y(`w-full min-w-0`,e.container),children:[t.map((t,n)=>(0,Z.jsx)(Am,{attachment:t,authToken:r,conversationId:i,imageSize:e.tileSize,compact:l===`user`,onOpen:f.openAttachment},t.id??`${t.name}-${n}`)),e.overflowCount==null?null:(0,Z.jsx)(Am,{attachment:p[zm-1],authToken:r,conversationId:i,imageSize:`grid-cell`,compact:l===`user`,overflowLabel:`+${e.overflowCount}`,onOpen:f.openAttachment},p[zm-1]?.id??`overflow-${zm-1}`)]})})():null,g=e.length>0?(0,Z.jsx)(`div`,{className:Y(`flex flex-col gap-2`,l===`user`&&(u?`items-center`:`items-end`)),children:e.map((e,t)=>(0,Z.jsx)(Im,{att:e,conversationId:i,align:l===`user`?u?`center`:`end`:`start`,embedded:l===`user`},e.id??`${e.name}-${t}`))}):null,_=a.length>0?(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:a.map((e,t)=>(0,Z.jsx)(Am,{attachment:e,authToken:r,conversationId:i,onOpen:f.openAttachment},e.id??`${e.name}-${t}`))}):null,t[5]=n,t[6]=r,t[7]=u,t[8]=i,t[9]=l,t[10]=f.openAttachment,t[11]=p,t[12]=m,t[13]=h,t[14]=g,t[15]=_}else p=t[11],m=t[12],h=t[13],g=t[14],_=t[15];let v;t[16]!==m||t[17]!==h||t[18]!==g||t[19]!==_?(v=(0,Z.jsxs)(`div`,{className:m,children:[h,g,_]}),t[16]=m,t[17]=h,t[18]=g,t[19]=_,t[20]=v):v=t[20];let y;t[21]!==r||t[22]!==i||t[23]!==p||t[24]!==f.active||t[25]!==f.closePreview||t[26]!==f.open||t[27]!==f.selectAttachment?(y=(0,Z.jsx)(Co,{open:f.open,attachment:f.active,images:p,onAttachmentChange:f.selectAttachment,authToken:r,conversationId:i,onClose:f.closePreview}),t[21]=r,t[22]=i,t[23]=p,t[24]=f.active,t[25]=f.closePreview,t[26]=f.open,t[27]=f.selectAttachment,t[28]=y):y=t[28];let b;return t[29]!==v||t[30]!==y?(b=(0,Z.jsxs)(Z.Fragment,{children:[v,y]}),t[29]=v,t[30]=y,t[31]=b):b=t[31],b}function Hm(e){return e.type!==`image`&&!e.mimeType?.startsWith(`image/`)&&!Rm(e)}function Um(e){return e.type===`image`||e.mimeType?.startsWith(`image/`)}function Wm(e,t){let n=e.source?.data?.trim();if(!n)return null;let r=n.match(/^data:([^;]+);base64,([\s\S]+)$/i);if(r?.[1]&&r[2]){let e=r[2].replace(/\s/g,``);return{name:`image-${t+1}`,mimeType:r[1],type:`image`,content:e,data:e}}if(n.startsWith(`data:`))return{name:`image-${t+1}`,mimeType:`image/png`,type:`image`,content:n,data:n};let i=n.replace(/\s/g,``);return{name:`image-${t+1}`,mimeType:`image/png`,type:`image`,content:i,data:i}}function Gm(e){return e?.length?e.flatMap((e,t)=>{let n=Wm(e,t);return n?[n]:[]}):[]}function Km(e){let t=[],n=new Set(fr(e,{includePending:!0}));for(let r of e)if(r.type===`text`){if(!n.has(r))continue;t.push(r.text)}else r.type===`image`&&t.push(`[image]`);return t.join(`
|
|
13
|
+
|
|
14
|
+
`).trim()}function qm(e){if(!e.trim())return``;let t=at.parse(e,{gfm:!0,breaks:!1});return new DOMParser().parseFromString(`<div>${t}</div>`,`text/html`).body.textContent?.trim()??``}function Jm(e){let t=[],n=new Set(fr(e,{includePending:!0}));for(let r of e)if(r.type===`text`){if(!n.has(r))continue;t.push(qm(r.text))}else r.type===`image`&&t.push(`[image]`);return t.join(`
|
|
15
|
+
|
|
16
|
+
`).trim()}var Ym=new WeakMap,Xm=new WeakMap,Zm=new WeakMap,Qm=new WeakMap;function $m(e,t){if(!e)return;let n=e=>{let t=Zm.get(e);return t||(t=new Map(e.content.flatMap(e=>{let t=or(e);return t?[[t,e]]:[]})),Zm.set(e,t)),t},r=e.streamingMsg&&n(e.streamingMsg).get(t);if(r)return r;let i=Qm.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);Qm.set(e.messages,i)}return i.get(t)}function eh(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 th(){let e;return t=>(eh(e??null,t??null)||(e=t),e)}function nh(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=Xm.get(n);if(r?.previous===t)return r.row;let i=ur([t,n]).at(-1);return Xm.set(n,{previous:t,row:i}),i}let r=Ym.get(e.messages);return r||(r=new Map(e.messages.filter(e=>e.renderKey).map(e=>[e.renderKey,e])),Ym.set(e.messages,r)),r.get(t)}function rh(){let e;return t=>{if(!t||!e)return e=t,t;let n=eh(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 ih(e){let t=(0,X.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=rh(),t[0]=n):n=t[0];let r=n,i;t[1]===e?i=t[2]:(i=()=>r(e?Sn.getState().sessions[e]:void 0),t[1]=e,t[2]=i);let a=i;return(0,Q.useSyncExternalStore)(Sn.subscribe,a,a)}function ah(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=Sn.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 oh(e,t){let n=(0,X.c)(4),r;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=th(),n[0]=r):r=n[0];let i=r,a;return n[1]!==e||n[2]!==t?(a=()=>i(e&&t?nh(Sn.getState().sessions[e],t):void 0),n[1]=e,n[2]=t,n[3]=a):a=n[3],ah(e,a)}function sh(e,t){let n=(0,X.c)(3),r;return n[0]!==e||n[1]!==t?(r=()=>e&&t?$m(Sn.getState().sessions[e],t):void 0,n[0]=e,n[1]=t,n[2]=r):r=n[2],ah(e,r)}function ch(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=Sn.getState().sessions[e],n=o.map(e=>$m(t,e));if(!n.some(uh))return n.map(lh).join(``)},n[4]=e,n[5]=o,n[6]=s):s=n[6],ah(e,s)}function lh(e){return e?.type===`text`?e.text:``}function uh(e){return e?.type!==`text`}function dh(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)})})(Ma(),e=>({kind:`skill`,name:e[1]??``}));for(let n of Io(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 fh(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 ph(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 mh(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)(je,{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)(Oe,{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)(wt,{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)(M,{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)(Se,{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)(ks,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=r):r=t[5],r}var hh=(0,Q.memo)(function(e){let t=(0,X.c)(24),{text:n,conversationId:r,document:i,contextRefs:a}=e,o=v(gh),s;t[0]===o?s=t[1]:(s=S(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=dh(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(_h)??[]);e=i.parts.flatMap(e=>e.type===`text`?dh(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=fh(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(vh),t[9]=u,t[10]=p);let m=um(void 0,r,p);if(!u.some(yh)){let e;return t[11]===n?e=t[12]:(e=(0,Z.jsx)(`div`,{className:`markdown-content min-w-0`,children:(0,Z.jsx)(bf,{content:n,compact:!0,breaks:!0})}),t[11]=n,t[12]=e),e}let h;if(t[13]!==u||t[14]!==f||t[15]!==c||t[16]!==m){let e;t[18]!==u||t[19]!==c||t[20]!==m?(e=(e,t)=>{let{part:n,key:r}=e;return n.kind===`skill`?(0,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`,ph(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)(mh,{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)(bf,{content:n.text,compact:!0,breaks:!0})},r):null},t[18]=u,t[19]=c,t[20]=m,t[21]=e):e=t[21],h=f.map(e),t[13]=u,t[14]=f,t[15]=c,t[16]=m,t[17]=h}else h=t[17];let g;return t[22]===h?g=t[23]:(g=(0,Z.jsx)(`span`,{className:`inline-flex max-w-full flex-wrap items-baseline gap-x-0 gap-y-1 [text-align:inherit]`,children:h}),t[22]=h,t[23]=g),g});function gh(e){return e.language}function _h(e){return e.refId?[[e.refId,e]]:[]}function vh(e){return e.kind===`skill`}function yh(e){return e.kind!==`text`}function bh(e,t){switch(e.code){case`provider_setup_required`:return{title:t.providerSetupRequiredTitle,body:t.providerSetupRequiredBody.replace(`{{provider}}`,e.provider??t.agentRunErrorUnknownProvider),cta:t.providerSetupRequiredCta,deepLink:e.deepLink??`/settings/capabilities/models`};case`provider_auth_invalid`:return{title:t.agentRunErrorAuthInvalidTitle,body:t.agentRunErrorAuthInvalidBody.replace(`{{provider}}`,e.provider??t.agentRunErrorUnknownProvider),cta:t.agentRunErrorCtaProviders,deepLink:e.deepLink??`/settings/capabilities/models`};case`rate_limit`:return{title:t.agentRunErrorRateLimitTitle,body:t.agentRunErrorRateLimitBody};case`timeout`:return{title:t.agentRunErrorTimeoutTitle,body:t.agentRunErrorTimeoutBody};case`provider_connection_error`:return{title:t.agentRunErrorConnectionTitle,body:t.agentRunErrorConnectionBody};case`billing`:return{title:t.agentRunErrorBillingTitle,body:t.agentRunErrorBillingBody};case`credit_budget_exhausted`:return{title:t.creditBudgetExhaustedTitle,body:t.creditBudgetExhaustedBody,cta:t.creditBudgetSettingsCta,deepLink:`/settings/agent-defaults?panel=runtime`};case`model_quota_exhausted`:return{title:t.xopcQuotaExhaustedTitle,body:t.xopcQuotaExhaustedBody};case`platform_token_limit_exceeded`:return{title:t.xopcPlatformLimitTitle,body:t.xopcPlatformLimitBody,cta:t.xopcPlatformLimitCta,deepLink:`/settings/capabilities/models?add=1`};case`send_failed`:return{title:t.agentRunErrorSendFailedTitle,body:t.agentRunErrorSendFailedBody};case`session_not_found`:return{title:t.sessionNotFoundTitle,body:t.sessionNotFoundBody,cta:t.sessionNotFoundCta,deepLink:`/chat/new`};default:return{title:t.agentRunErrorUnknownTitle,body:t.agentRunErrorUnknownBody}}}function xh(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)(Ke,{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)(_e,{className:`size-4`,strokeWidth:1.75}),t[1]=e):e=t[1],e}case`billing`:case`credit_budget_exhausted`:case`model_quota_exhausted`:case`platform_token_limit_exceeded`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Ns,{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)(q,{className:`size-4`,strokeWidth:1.75}),t[3]=e):e=t[3],e}}}function Sh(e){let t=(0,X.c)(34),{payload:n,onRetry:r}=e,i=m(),a=S(v(wh)).chat,[o,s]=(0,Q.useState)(``),c=bh(n,a),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=[`provider_connection_error`,`timeout`,`rate_limit`,`unknown`,`send_failed`],t[0]=l):l=t[0];let u=l.includes(n.code),d=n.code===`model_quota_exhausted`,f=Ch,p;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(p=Y(`flex flex-col gap-2 rounded-xl border p-3`,`border-edge bg-surface-panel`),t[1]=p):p=t[1];let h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=Y(`flex size-8 shrink-0 items-center justify-center rounded-lg`,`bg-surface-inset text-warning`),t[2]=h):h=t[2];let g;t[3]===n.code?g=t[4]:(g=(0,Z.jsx)(`span`,{className:h,"aria-hidden":!0,children:(0,Z.jsx)(xh,{code:n.code})}),t[3]=n.code,t[4]=g);let _;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(_=Y(`text-sm font-semibold`,`text-fg`),t[5]=_):_=t[5];let y;t[6]===c.title?y=t[7]:(y=(0,Z.jsx)(`h3`,{className:_,children:c.title}),t[6]=c.title,t[7]=y);let b;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(b=Y(`mt-1 text-xs leading-relaxed`,`text-fg-muted`),t[8]=b):b=t[8];let x;t[9]===c.body?x=t[10]:(x=(0,Z.jsx)(`p`,{className:b,children:c.body}),t[9]=c.body,t[10]=x);let C;t[11]!==y||t[12]!==x?(C=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[y,x]}),t[11]=y,t[12]=x,t[13]=C):C=t[13];let w;t[14]!==g||t[15]!==C?(w=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[g,C]}),t[14]=g,t[15]=C,t[16]=w):w=t[16];let T;t[17]!==c.cta||t[18]!==c.deepLink||t[19]!==a||t[20]!==i||t[21]!==r||t[22]!==d||t[23]!==u?(T=u?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r?(0,Z.jsx)(`button`,{type:`button`,className:Y(`min-h-9 rounded-md px-3 text-xs font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`bg-accent text-on-accent hover:bg-accent-hover`),onClick:r,children:a.runRecovery.retry}):null,(0,Z.jsx)(`button`,{type:`button`,className:`min-h-9 rounded-md px-3 text-xs text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>i(`/settings/capabilities/models`),children:a.runRecovery.models})]}):d?(0,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`,`bg-accent text-on-accent hover:bg-accent-hover`),onClick:()=>f(`/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:()=>f(`/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:()=>i(`/settings/capabilities/models?add=1`),children:a.xopcQuotaOwnProviderCta})]}):c.cta&&c.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`,`bg-accent text-on-accent hover:bg-accent-hover`),onClick:()=>i(c.deepLink),children:c.cta})}):null,t[17]=c.cta,t[18]=c.deepLink,t[19]=a,t[20]=i,t[21]=r,t[22]=d,t[23]=u,t[24]=T):T=t[24];let E;t[25]!==o||t[26]!==a||t[27]!==n.message||t[28]!==s?(E=n.message?(0,Z.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,Z.jsx)(`summary`,{className:Y(`cursor-pointer select-none underline-offset-2`,`text-fg-muted hover:text-fg`),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]`,`bg-surface-inset text-fg-muted`),children:Yn(n.message)}),(0,Z.jsx)(`button`,{type:`button`,className:`mt-1 min-h-9 rounded-md px-2 text-xs text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:async()=>{try{await navigator.clipboard.writeText(Yn(n.message)),s(a.runRecovery.copied)}catch{s(a.runRecovery.copyFailed)}},children:a.runRecovery.copyDetails}),(0,Z.jsx)(`span`,{role:`status`,"aria-live":`polite`,className:`ml-2 text-fg-muted`,children:o})]}):null,t[25]=o,t[26]=a,t[27]=n.message,t[28]=s,t[29]=E):E=t[29];let D;return t[30]!==w||t[31]!==T||t[32]!==E?(D=(0,Z.jsxs)(`section`,{role:`alert`,"aria-live":`polite`,className:p,children:[w,T,E]}),t[30]=w,t[31]=T,t[32]=E,t[33]=D):D=t[33],D}function Ch(e){return window.open(`https://console.xopc.ai${e}`,`_blank`,`noopener,noreferrer`)}function wh(e){return e.language}function Th(e){let t=(0,X.c)(5),{errorText:n,onRetry:r}=e,i;t[0]===n?i=t[1]:(i=Or(n),t[0]=n,t[1]=i);let a=i;if(!a)return null;let o;return t[2]!==r||t[3]!==a?(o=(0,Z.jsx)(`div`,{className:`mb-4`,children:(0,Z.jsx)(Sh,{payload:a,onRetry:r})}),t[2]=r,t[3]=a,t[4]=o):o=t[4],o}function Eh(e){let t=(0,X.c)(4),{payload:n}=e,r;t[0]===n?r=t[1]:(r=JSON.stringify({...n,code:n.kind,message:n.message??``}),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,Z.jsx)(Th,{errorText:r}),t[2]=r,t[3]=i),i}var Dh=/^No API key found for (\S+)/i;function Oh(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=Dh.exec(t);return n?{kind:`provider_setup_required`,provider:n[1].replace(/[.,]$/,``),deepLink:`/settings/capabilities/models`,message:t}:null}var kh=new WeakMap;function Ah(e){let t=kh.get(e),n=or(e);return t??(n?[n]:[])}function jh(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??``}`},_r(e,t[t.length-1]),kh.set(t[t.length-1],[...Ah(e),...Ah(n)]);continue}t.push(n)}return t}var Mh=/^\s*\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$/m,Nh=/^\s{0,3}(?:[-+*]|\d+[.)])\s+/m,Ph=/^\s{0,3}```/gm;function Fh(e){return(e.match(Ph)?.length??0)%2==1?`code`:Mh.test(e)?`table`:Nh.test(e)?`list`:e.length>=4096?`long_text`:`plain`}var Ih={plain:50,long_text:50,list:50,table:72,code:64};function Lh({tailKind:e,latestParseMs:t}){let n=Ih[e];return!Number.isFinite(t)||t<=16?n:Math.min(120,Math.max(n,Math.ceil(t*2)))}var Rh=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=Ud(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 zh(e,t,n,r=!1,i,a=!1){let[o,s]=(0,Q.useState)(()=>e),[c]=(0,Q.useState)(()=>new Rh(e.length)),l=(0,Q.useRef)(e),u=(0,Q.useRef)(o),d=(0,Q.useRef)(null),f=(0,Q.useRef)(null),p=(0,Q.useRef)(50),m=(0,Q.useRef)(t||r),h=(0,Q.useRef)(!1),g=(0,Q.useRef)(i);return g.current=i,(0,Q.useEffect)(()=>{let r=!e.startsWith(l.current);l.current=e;let i=()=>{d.current!==null&&window.clearTimeout(d.current),f.current!==null&&window.cancelAnimationFrame(f.current),d.current=null,f.current=null},o=()=>{i(),c.reset(e.length),u.current=e,s(e)},_=()=>{m.current&&!h.current&&(h.current=!0,m.current=!1,g.current?.())};if(t&&(m.current=!0,h.current=!1,gt(n,e.length)),r||!e.startsWith(u.current)||document.visibilityState===`hidden`||window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches||!t){o(),t||_();return}if(t&&a&&u.current.length===0){lt(n,e.length),o();return}if(c.observe(e.length,performance.now()),p.current=Lh({tailKind:Fh(e.slice(-8192)),latestParseMs:ct(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,lt(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 Bh(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 Vh(e){let t=(0,X.c)(33),{review:n}=e,r=v(Uh),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=S(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)(Ze,{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)(bf,{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(Hh)}),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 Hh(e,t){let n=Bh(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 Uh(e){return e.language}function Wh({resolution:e,conversationId:t,onClose:n}){let r=v(e=>e.language),i=S(r).chat.fileReference,[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(!1),d=Ea()&&!!window.electronAPI?.shell,f=e.target.path,p=e.status===`ready`?e.ref:null,m=p?.displayName??f.split(/[\\/]/).pop()??f,h=p?.absolutePath??p?.workspaceRelativePath??f,g=(0,Q.useCallback)(()=>{Oi(h).then(e=>{e&&(o(!0),window.setTimeout(()=>o(!1),2e3))})},[h]),_=async e=>{let n=window.electronAPI?.shell;if(!(!p?.fileRefId||!d||!n||l)){c(``),u(!0);try{let r=await Ja(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)(Ze,{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)(q,{className:`size-3.5 shrink-0 text-warning`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(Ee,{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`,la.focusRingPanel),"aria-label":i.closeActions,children:(0,Z.jsx)(Xt,{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:Gh,disabled:l,onClick:()=>void _(`openExternal`),children:[(0,Z.jsx)(we,{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:Gh,disabled:l,onClick:()=>void _(`revealInFolder`),children:[(0,Z.jsx)(Ae,{className:`size-3`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:i.revealInFolder})]}):null,p?.manageRoute?(0,Z.jsxs)(`a`,{className:Gh,href:`#${p.manageRoute}`,children:[(0,Z.jsx)(zt,{className:`size-3`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:S(r).nav.settings})]}):null,(0,Z.jsxs)(`button`,{type:`button`,className:Gh,onClick:g,children:[(0,Z.jsx)(xe,{className:`size-3`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:a?S(r).chat.messageCopied:i.copyPath})]})]}),s?(0,Z.jsx)(`p`,{role:`alert`,className:`text-warning`,children:s}):null]})}var Gh=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`,la.focusRingPanel,la.press);function Kh({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=ch(n,r)??t,p=`assistant-markdown-${(0,Q.useId)()}`,m=zh(f,s,p,c,l,d);(0,Q.useEffect)(()=>{if(s)return ut(p),()=>vt(p)},[p,s]);let h=ai(e=>e.setPath),g=S(v(e=>e.language)).chat.fileReference,[_,y]=(0,Q.useState)(null),b=(0,Q.useRef)(0);(0,Q.useEffect)(()=>()=>{b.current++},[a,o,e]);let x=(0,Q.useCallback)(async t=>{try{return await Ga(t.path,{projectId:o?.trim()||void 0,conversationId:a?.trim()||void 0,taskRunId:e})}catch(n){if(e||o||!a)throw n;return Ga(t.path)}},[o,a,e]),C=(0,Q.useCallback)(t=>{let n=++b.current;if(t.kind===`workspace-relative`){y({status:`loading`,target:t}),(async()=>{let r=await Xa(t.path,{projectId:o?.trim()||void 0,conversationId:a?.trim()||void 0,taskRunId:e});if(n!==b.current)return;if(r?.capabilities.includes(`preview`)&&(r.absolutePath||r.workspaceRelativePath)){h(r.absolutePath||r.workspaceRelativePath,t.line,o,a),y(null);return}let i=!e&&!o&&a?await Xa(t.path):null;if(n===b.current){if(i?.capabilities.includes(`preview`)&&(i.absolutePath||i.workspaceRelativePath)){h(i.absolutePath||i.workspaceRelativePath,t.line),y(null);return}y(r?{status:`ready`,target:t,ref:r}:{status:`error`,target:t,message:g.resolveFailedDescription})}})().catch(e=>{n===b.current&&y({status:`error`,target:t,message:e instanceof Error?e.message:String(e)})});return}y({status:`loading`,target:t}),Xa(t.path,{projectId:o?.trim()||void 0,conversationId:a?.trim()||void 0,taskRunId:e}).then(e=>{if(n===b.current){if(!e){y({status:`error`,target:t,message:g.resolveFailedDescription});return}if(e.capabilities.includes(`preview`)&&(e.absolutePath||e.workspaceRelativePath)){h(e.absolutePath||e.workspaceRelativePath,t.line,o,a),y(null);return}y({status:`ready`,target:t,ref:e})}}).catch(e=>{n===b.current&&y({status:`error`,target:t,message:e instanceof Error?e.message:String(e)})})},[g.resolveFailedDescription,o,a,e,h]),w=Oh(f);return(0,Z.jsxs)(Z.Fragment,{children:[w?(0,Z.jsx)(Eh,{payload:w}):(0,Z.jsx)(bf,{content:m,streaming:s||m!==f,compact:i,onWorkspaceFileOpen:C,onWorkspaceImageLoad:x,renderMermaid:!0,mermaidActions:!0,streamingMetricsKey:p,responseRunId:u}),_?(0,Z.jsx)(Wh,{resolution:_,conversationId:a,onClose:()=>{b.current++,y(null)}}):null]})}function qh(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)(hh,{text:rr(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)(Kh,{content:e.text,sourcePartIds:Ah(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)(Cd,{source:e.source.data,alt:``,title:i,onOpen:a?()=>a(e,n):void 0},t)}return e.type===`review`?(0,Z.jsx)(Vh,{review:e},t):null}function Jh(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:jh(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(Yh),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=qh(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 Yh(e){return e.type===`text`&&e.presentation===`pending`}var Xh=[`readFile`,`editFile`,`writeFile`,`runCommand`,`memorySearch`,`codeSearch`,`webSearch`,`search`,`fetchUrl`,`openUrl`,`listDir`,`other`];function Zh(e,t){return ga(e,t)}function Qh(e){let t=new Map;for(let n of e){if(n.type!==`tool_use`)continue;let e=Zh(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 $h(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 eg(e,t,n){let r=Qh(e),i=[];for(let e of Xh){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)||$h(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 tg(e){return e.filter(e=>e.type!==`thinking`||!!e.text?.trim()||!!e.streaming)}function ng(e,t,n){return eg(e,t,n)}function rg(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function ig(e){if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}}function ag(e){let t=rg(ig(e));if(!t)return[];let n=rg(t.details)?.results??t.results;if(Array.isArray(n))return n.map(rg).filter(e=>e!==null);let r=Array.isArray(t.content)?t.content:[];for(let e of r){let t=rg(e)?.text,n=rg(ig(t));if(Array.isArray(n?.results))return n.results.map(rg).filter(e=>e!==null)}return[]}function og(e,t){return e.replace(/\{\{count\}\}/g,String(t))}function sg(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=ag(e.result),r=e.activity?.count??n.length;return{title:r===0?t.empty:og(r===1?t.found_one:t.found_other,r),purpose:t.purpose}}function cg(e,t){if(e.status===`running`)return{title:t?`正在更新记忆`:`Updating memory`,purpose:``};let n=rg(ig(e.result)),r=rg(n?.details)??n;if(!r?.status&&Array.isArray(n?.content))for(let e of n.content){let t=rg(ig(rg(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=rg(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 lg(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 ug(e){if(e==null)return null;try{return typeof e==`string`?JSON.parse(e):e}catch{return null}}function dg(e){let t=ug(e),n=t?.path??t?.file_path??t?.filepath??t?.file??t?.qualified_name??t?.function_name;return typeof n==`string`?n:``}function fg(e){let t=ug(e),n=t?.url??t?.href??t?.uri??t?.website;return typeof n==`string`?n:``}function pg(e){let t=ug(e),n=t?.command??t?.cmd??t?.shell??t?.script;return typeof n==`string`?n:``}var mg=120;function hg(e){if(e==null)return``;let t=ug(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>mg?`${t.slice(0,mg)}…`:t}if(typeof e==`number`&&Number.isFinite(e))return String(e)}return``}function gg(e){return e.startsWith(`@@`)?`hunk`:e.startsWith(`+++`)||e.startsWith(`---`)||e.startsWith(`diff `)||e.startsWith(`index `)?`meta`:e.startsWith(`+`)?`add`:e.startsWith(`-`)?`del`:`context`}function _g(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=gg(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 vg=`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`,yg=`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`,bg=`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`,xg=`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(vg,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:yg,title:r,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}var wg=(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 Oi(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`,la.transition,la.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)(re,{className:`size-3.5`,"aria-hidden":!0}):(0,Z.jsx)(xe,{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 Tg(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:xg,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 Eg(e){let t=(0,X.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`pre`,{className:bg,children:n}),t[0]=n,t[1]=r),r}function Dg(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>{let r=t[n];return r==null?``:String(r)})}function Og(e){return e.details??{}}var kg=/\[(\d+)\/(\d+) lines\]\s*$/;function Ag(e){let t=e.match(kg);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 jg(e){return e.replace(kg,``).trimEnd()}var Mg=(0,Q.memo)(function(e){let t=(0,X.c)(32),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=dg(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=ha(n.result),t[2]=n.result,t[3]=o);let s=o.text,c;t[4]===s?c=t[5]:(c=Ag(s),t[4]=s,t[5]=c);let l=c,u;t[6]===s?u=t[7]:(u=jg(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
|
+
`),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
|
+
`);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?Dg(r.linesPartial,{shown:l.shown,total:l.total}):Dg(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)(wg,{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)(Tg,{summary:r.viewContent,children:(0,Z.jsx)(Eg,{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 Ng(e){let t=(0,X.c)(4),{lines:n}=e,r;t[0]===n?r=t[1]:(r=n.map(Pg),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 Pg(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 Fg=(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=dg(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=ha(n.result),t[2]=n.result,t[3]=o);let s=o,c;t[4]===s?c=t[5]:(c=_g(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:Dg(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)(wg,{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)(Tg,{summary:r.viewDiff,defaultOpen:!0,children:(0,Z.jsx)(Ng,{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 Ig(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 Lg=(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=dg(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=ha(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=Og(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:Dg(r.sizeBadge,{size:Ig(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)(wg,{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}),Rg=12;function zg(e){if(!e)return{preview:``,truncated:!1};let t=e.split(`
|
|
21
|
+
`);return t.length<=Rg?{preview:e,truncated:!1}:{preview:`${t.slice(0,Rg).join(`
|
|
22
|
+
`)}\n…`,truncated:!0}}var Bg=(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=pg(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=ha(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??Og(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=zg(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)(wg,{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)(Tg,{summary:r.viewOutput,children:(0,Z.jsx)(Eg,{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}),Vg=(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=fg(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=ha(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=Og(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
|
+
`);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:Dg(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)(Tg,{summary:r.viewContent,children:(0,Z.jsx)(Eg,{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}),Hg=e=>e&&typeof e==`object`&&!Array.isArray(e)?e:void 0,Ug=e=>typeof e==`string`&&/^[a-z0-9][a-z0-9_-]{0,63}$/.test(e)?e:void 0;function Wg(e){let t={...ha(e.result).details,...Hg(e.details)},n=Hg(t?.searchInfo)??t,r=Array.isArray(n?.attempts)?n.attempts.slice(0,24).flatMap(e=>{let t=Hg(e),n=Ug(t?.provider);return!n||![`success`,`empty`,`error`,`skipped`].includes(String(t?.outcome))?[]:[{provider:n,upstream:Ug(t?.upstream),outcome:String(t?.outcome),reason:Ug(t?.reason)}]}):[];return{provider:Ug(n?.provider),upstream:Ug(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 Gg(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 Kg(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=Wg(n),u;t[20]===i.unknown?u=t[21]:(u=e=>Gg(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 qg(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 Jg(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)(Jo,{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 Yg(e){let t=Aa();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 Xg(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 Zg(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 Qg(e,t,n){let r=new Map,i=0,a=e.toSorted((e,t)=>Number(ua(e.name))-Number(ua(t.name)));for(let e of a){if(pa(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 $g({path:e,conversationId:t,label:n}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(),s=ai(e=>e.setPath),c=async()=>{i(!0),o(void 0);try{let n=await Xa(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)(vi,{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 e_(e){return/^Full Codemode output: (\.xopc\/codemode-output\/[a-f0-9-]{36}\.txt)(?:\r?\n|$)/.exec(e)?.[1]}function t_(e,t=0){return or(e)??(e.type===`tool_use`?e.id:e.type===`text`?e.segmentId??`narration-${t}`:`thinking-${t}`)}var n_=(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(A_),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?qg(u,a):i==null?null:qg(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 r_(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,h=l===void 0||l,g=u!==void 0&&u,_=d!==void 0&&d,y=f!==void 0&&f,b=p!==void 0&&p,x=m===void 0||m,C=v(__),[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=S(C),t[3]=C,t[4]=O);let k=O.chat,A=qo(g_),j;if(t[5]!==A||t[6]!==y||t[7]!==n.items){let e;t[9]!==A||t[10]!==y?(e=e=>e.type!==`thinking`||A||y,t[9]=A,t[10]=y,t[11]=e):e=t[11],j=n.items.filter(e),t[5]=A,t[6]=y,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(h_),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,ee=L,[V,H]=(0,Q.useState)(!1),U=(0,Q.useRef)(null),[W,te]=(0,Q.useState)(!1),[ne,re]=(0,Q.useState)(!1),ae,oe;t[14]!==I||t[15]!==W?(ae=()=>{if(!I&&!W)return;let e=()=>{let e=window.getSelection();te(!!(e&&!e.isCollapsed&&U.current?.contains(e.anchorNode)))};return document.addEventListener(`selectionchange`,e),()=>document.removeEventListener(`selectionchange`,e)},oe=[I,W],t[14]=I,t[15]=W,t[16]=ae,t[17]=oe):(ae=t[16],oe=t[17]),(0,Q.useEffect)(ae,oe);let se=!n.compact&&M.length>0&&(B??(ee||W)),ce,le;t[18]===se?(ce=t[19],le=t[20]):(ce=()=>{let e=U.current;if(!se||!e)return;let t=e.closest(`.chat-messages`),n=n=>ki(n,e,t);return e.addEventListener(`wheel`,n,{passive:!1}),()=>e.removeEventListener(`wheel`,n)},le=[se],t[18]=se,t[19]=ce,t[20]=le),(0,Q.useEffect)(ce,le);let ue,de;t[21]!==se||t[22]!==ne?(ue=()=>{if(se){re(!0);return}if(!ne)return;let e=window.setTimeout(()=>re(!1),200);return()=>window.clearTimeout(e)},de=[se,ne],t[21]=se,t[22]=ne,t[23]=ue,t[24]=de):(ue=t[23],de=t[24]),(0,Q.useEffect)(ue,de);let G;t[25]===M?G=t[26]:(G=M.every(m_),t[25]=M,t[26]=G);let K=G,fe,q,pe,me,J,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]!==se||t[34]!==C||t[35]!==r||t[36]!==g||t[37]!==x||t[38]!==V||t[39]!==A||t[40]!==y||t[41]!==h||t[42]!==K||t[43]!==a||t[44]!==b||t[45]!==i||t[46]!==M||t[47]!==w||t[48]!==n.durationMs||t[49]!==n.items||t[50]!==n.startedAt){ve=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Zg(M);J=K&&I&&!V&&!A?Math.max(0,e.length-3):0,ye=e.slice(J).flatMap(p_),me=n.startedAt??null,q=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)=>ma(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(f_),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=ng(P,o.ing,e),t[84]=P,t[85]=o.ing,t[86]=e,t[87]=n):n=t[87],m=n}let _=m,v=r===`sending`?k.sendingLabel:r===`waiting`?w?k.waitingLongLabel:k.waitingLabel:null,S;t[88]!==P||t[89]!==k.thinkingLabel||t[90]!==a.workLogRunning?(S=P.some(d_)?k.thinkingLabel:a.workLogRunning,t[88]=P,t[89]=k.thinkingLabel,t[90]=a.workLogRunning,t[91]=S):S=t[91];let T=S;ge=r??(P.some(u_)?`tool`:P.some(l_)?`thinking`:P.length>0?`organizing`:`working`),fe=_??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]!==y||t[99]!==a.thoughts){let e=P.filter(c_);E=y&&e.length>0?Qg(e,e=>he(e,`completed`),{repeated:k.activityRepeated,more:k.activityMore,failed:k.activityFailed,separator:C===`zh`?`、`:`, `}):y?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]=y,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,g||b){let e;t[122]!==I||t[123]!==s||t[124]!==c||t[125]!==x||t[126]!==be||t[127]!==i||t[128]!==n.items?(e=x&&n.items.filter(s_).map(e=>(0,Z.jsx)(D_,{block:e,toolLabels:i,stepLabels:be,cardLabels:s,conversationId:c,surfaceOnly:!0,runActive:I},e.id)),t[122]=I,t[123]=s,t[124]=c,t[125]=x,t[126]=be,t[127]=i,t[128]=n.items,t[129]=e):e=t[129];let r;t[130]===e?r=t[131]:(r=(0,Z.jsx)(Z.Fragment,{children:e}),t[130]=e,t[131]=r),ve=r;break bb0}_e=se&&(!h||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]=se,t[34]=C,t[35]=r,t[36]=g,t[37]=x,t[38]=V,t[39]=A,t[40]=y,t[41]=h,t[42]=K,t[43]=a,t[44]=b,t[45]=i,t[46]=M,t[47]=w,t[48]=n.durationMs,t[49]=n.items,t[50]=n.startedAt,t[51]=fe,t[52]=q,t[53]=pe,t[54]=me,t[55]=J,t[56]=he,t[57]=ge,t[58]=_e,t[59]=ve,t[60]=ye,t[61]=be}else fe=t[51],q=t[52],pe=t[53],me=t[54],J=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]!==fe||t[133]!==I||t[134]!==q||t[135]!==pe||t[136]!==me||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:fe})}),(0,Z.jsx)(n_,{active:I,startedAt:me,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:q==null?a.workLogTitle:a.workLogComplete)}),t[132]=fe,t[133]=I,t[134]=q,t[135]=pe,t[136]=me,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]!==q||t[148]!==me||t[149]!==C?(we=I?null:(0,Z.jsx)(n_,{active:!1,startedAt:me,frozenMs:q,language:C,className:`mt-0.5 tabular-nums text-xs text-fg-muted`}),t[146]=I,t[147]=q,t[148]=me,t[149]=C,t[150]=we):we=t[150];let Te=we,Ee=!n.compact&&F>0;if(h&&!A){let e;t[151]!==_||t[152]!==I||t[153]!==n.items?(e=!I&&!_&&n.items.some(o_),t[151]=_,t[152]=I,t[153]=n.items,t[154]=e):e=t[154];let r=e,o=n.status===`failed`||n.status===`partial`||r,l,u,d,f,p;if(t[155]!==fe||t[156]!==_||t[157]!==I||t[158]!==s||t[159]!==c||t[160]!==o||t[161]!==x||t[162]!==he||t[163]!==be||t[164]!==i||t[165]!==n.items||t[166]!==n.status){let e=I&&!_||o?Xg(n.items,e=>{if(pa(e)||ua(e.name)||!da(e.name)&&Zh(e.name,e.activity)===`other`)return null;let t=he(e,I&&(e.status===`running`||e.activity?.status===`running`)?`running`:`completed`);return I&&t===fe?null:t}):[];l=!0,u=n.status,d=`my-1 min-w-0 w-full text-left`,t[172]!==I||t[173]!==s||t[174]!==c||t[175]!==x||t[176]!==be||t[177]!==i||t[178]!==n.items?(f=x&&n.items.filter(a_).map(e=>(0,Z.jsx)(D_,{block:e,toolLabels:i,stepLabels:be,cardLabels:s,conversationId:c,surfaceOnly:!0,runActive:I},e.id)),t[172]=I,t[173]=s,t[174]=c,t[175]=x,t[176]=be,t[177]=i,t[178]=n.items,t[179]=f):f=t[179],p=e.length>0?(0,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)(D_,{block:e,toolLabels:i,stepLabels:be,cardLabels:s,conversationId:c,runActive:I},t_(e,t)))}):null,t[155]=fe,t[156]=_,t[157]=I,t[158]=s,t[159]=c,t[160]=o,t[161]=x,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)(Ht,{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||se?`w-full`:`w-fit max-w-full`,ke;t[195]===Oe?ke=t[196]:(ke=Y(`my-1 min-w-0`,Oe),t[195]=Oe,t[196]=ke);let Ae;t[197]!==I||t[198]!==se||t[199]!==Te||t[200]!==Ce||t[201]!==Ee||t[202]!==n.compact||t[203]!==n.items.length?(Ae=I||!n.compact&&n.items.length>0?(0,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:!se}):void 0,"aria-expanded":Ee?se:void 0,children:[(0,Z.jsx)(Ht,{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)(ie,{className:Y(`size-4 shrink-0 text-fg-muted transition-transform motion-reduce:transition-none`,se&&`rotate-180`),"aria-hidden":!0}):null]}):null,t[197]=I,t[198]=se,t[199]=Te,t[200]=Ce,t[201]=Ee,t[202]=n.compact,t[203]=n.items.length,t[204]=Ae):Ae=t[204];let je;t[205]!==I||t[206]!==s||t[207]!==c||t[208]!==x||t[209]!==be||t[210]!==i||t[211]!==n.items?(je=x&&n.items.filter(i_).map(e=>(0,Z.jsx)(D_,{block:e,toolLabels:i,stepLabels:be,cardLabels:s,conversationId:c,surfaceOnly:!0,runActive:I},e.id)),t[205]=I,t[206]=s,t[207]=c,t[208]=x,t[209]=be,t[210]=i,t[211]=n.items,t[212]=je):je=t[212];let Me;t[213]!==I||t[214]!==s||t[215]!==k.activityEarlier||t[216]!==c||t[217]!==se||t[218]!==ne||t[219]!==J||t[220]!==V||t[221]!==y||t[222]!==ye||t[223]!==be||t[224]!==i?(Me=se||ne?(0,Z.jsx)(`div`,{className:`assistant-activity-disclosure`,"data-open":se,"aria-hidden":!se,inert:!se,children:(0,Z.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:(0,Z.jsxs)(`div`,{ref:U,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:[J>0?(0,Z.jsx)(`button`,{type:`button`,className:`mb-3 text-xs text-fg-muted hover:text-fg`,onClick:()=>H(!0),children:k.activityEarlier}):null,(0,Z.jsx)(v_,{blocks:ye,toolLabels:i,stepLabels:be,cardLabels:s,conversationId:c,animateNew:I&&se&&!V,runActive:I,showThinking:y})]})})}):null,t[213]=I,t[214]=s,t[215]=k.activityEarlier,t[216]=c,t[217]=se,t[218]=ne,t[219]=J,t[220]=V,t[221]=y,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 i_(e){return e.type===`tool_use`}function a_(e){return e.type===`tool_use`}function o_(e){return e.type===`tool_use`&&pa(e)}function s_(e){return e.type===`tool_use`}function c_(e){return e.type===`tool_use`}function l_(e){return e.type===`thinking`&&e.streaming}function u_(e){return e.type===`tool_use`&&e.status===`running`}function d_(e){return e.type===`thinking`&&e.streaming}function f_(e){return e.type===`tool_use`&&(e.status===`running`||e.activity?.status===`running`)}function p_(e){return e.type===`tools`?e.tools:[e.item]}function m_(e){return or(e)||e.type===`tool_use`||e.type===`text`&&e.segmentId}function h_(e){return e.type!==`text`}function g_(e){return e.showRawToolData}function __(e){return e.language}function v_({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(t_))),u=qo(e=>e.showRawToolData),d=v(e=>e.language),f=u?e.map(e=>({type:`item`,item:e})):Zg(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=t_(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)(y_,{tools:e.tools,runActive:s,labels:n,language:d,renderTool:e=>(0,Z.jsx)(D_,{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)(bf,{content:e.item.text,compact:!0,streaming:!!(s&&e.item.streaming)})}):(0,Z.jsx)(D_,{block:e.item,toolLabels:t,stepLabels:n,cardLabels:r,conversationId:a,runActive:s})},p)})})}):null}function y_(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(x_),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=S(a).chat,s=c?[...n].reverse().find(b_):void 0,_=n.filter(e=>e!==s),v;t[17]!==i||t[18]!==r?(v=e=>ma(e,r&&(e.status===`running`||e.activity?.status===`running`)?`running`:`completed`,i.toolActivity,i,i.runningActions),t[17]=i,t[18]=r,t[19]=v):v=t[19];let y=Qg(_,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:y})}),l=`mt-2 min-w-0 space-y-2.5 border-l border-edge-subtle pl-3`,u=_.map(o)}t[3]=i,t[4]=a,t[5]=o,t[6]=r,t[7]=c,t[8]=n,t[9]=l,t[10]=u,t[11]=d,t[12]=f,t[13]=p,t[14]=m,t[15]=h,t[16]=g}else l=t[9],u=t[10],d=t[11],f=t[12],p=t[13],m=t[14],h=t[15],g=t[16];if(g!==Symbol.for(`react.early_return_sentinel`))return g;let _;t[23]!==l||t[24]!==u?(_=(0,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 y;return t[30]!==v||t[31]!==p||t[32]!==m||t[33]!==h?(y=(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]=y):y=t[34],y}function b_(e){return e.status===`running`||e.activity?.status===`running`}function x_(e){return e.status===`running`||e.activity?.status===`running`}function S_(e){let t=(0,X.c)(15),{toolName:n,toolResult:r}=e,i=Aa(),a=Yg(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)(Jg,{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`]),w_=240;function T_(e){let t=e.split(`
|
|
25
|
+
`).map(e=>e.trim()).find(Boolean)??``;return t.length<=w_?t:`${t.slice(0,w_)}…`}function E_(e,t,n){let r=ha(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 T_(t)}return T_(r.text)||t}function D_(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,u=c===void 0||c,d;t[0]===n?d=t[1]:(d=or(n),t[0]=n,t[1]=d);let f=sh(o,d),m=f?.type===n.type?f:n,h=qo(k_),g=v(O_),_;bb0:{if(m.type!==`tool_use`){_=``;break bb0}if(m.status===`running`){_=``;break bb0}let e=m.result;if(e==null){_=``;break bb0}if(typeof e==`string`){let n;t[2]===e?n=t[3]:(n=e.trim(),t[2]=e,t[3]=n),_=n;break bb0}try{let n;t[4]===e?n=t[5]:(n=JSON.stringify(e,null,2),t[4]=e,t[5]=n),_=n}catch{_=String(e)}}let y=_;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)(bf,{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(!h||!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]!==h||t[16]!==i.rawThinking||t[17]!==e||t[18]!==r?(s=h&&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]=h,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 b=u&&(m.status===`running`||m.activity?.status===`running`),x;t[23]!==m||t[24]!==l?(x=l?m.status===`error`||m.activity?.status===`failed`:pa(m),t[23]=m,t[24]=l,t[25]=x):x=t[25];let C=x,w;t[26]!==m||t[27]!==a||t[28]!==C||t[29]!==i.toolError?(w=C?E_(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=y,D;t[31]!==m.name||t[32]!==E?(D=m.name===`codemode`?e_(E??``):void 0,t[31]=m.name,t[32]=E,t[33]=D):D=t[33];let O=D,k=b&&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]!==b||t[39]!==g||t[40]!==i.editFile||t[41]!==i.fetchUrl||t[42]!==i.listDirectory||t[43]!==i.memoryActivity||t[44]!==i.openUrl||t[45]!==i.readFile||t[46]!==i.runCommand||t[47]!==i.runningActions||t[48]!==i.searched||t[49]!==i.searchedCode||t[50]!==i.searchedMemory||t[51]!==i.searchedWeb||t[52]!==i.toolActivity||t[53]!==i.toolError||t[54]!==i.unknownTool||t[55]!==i.writeFile){M=Zh(m.name,m.activity),j=C_.has(M),N=m.name===`personal_memory`?cg(m,g===`zh`):M===`memorySearch`?sg(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=ma(m,b||C?`running`:`completed`,i.toolActivity,e,i.runningActions);F=C?M===`other`&&!da(m.name)?i.toolError:i.toolActivity.stepFailed.replace(`{{operation}}`,n.replace(/^正在|[.…]+$/g,``)):N?.title??n,P=C?Gt:M.includes(`Search`)||M===`search`?Lt:M===`readFile`?W:M===`editFile`||M===`writeFile`?vs:M===`fetchUrl`||M===`openUrl`?Ie:ge,t[36]=m,t[37]=C,t[38]=b,t[39]=g,t[40]=i.editFile,t[41]=i.fetchUrl,t[42]=i.listDirectory,t[43]=i.memoryActivity,t[44]=i.openUrl,t[45]=i.readFile,t[46]=i.runCommand,t[47]=i.runningActions,t[48]=i.searched,t[49]=i.searchedCode,t[50]=i.searchedMemory,t[51]=i.searchedWeb,t[52]=i.toolActivity,t[53]=i.toolError,t[54]=i.unknownTool,t[55]=i.writeFile,t[56]=j,t[57]=M,t[58]=N,t[59]=P,t[60]=F}else j=t[56],M=t[57],N=t[58],P=t[59],F=t[60];let I=P,L;t[61]!==m.input||t[62]!==N?(L=N?``:hg(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?``:lg(m.input),t[64]=m.input,t[65]=z);let B=z,ee;t[66]!==m||t[67]!==a||t[68]!==j||t[69]!==M?(ee=j?M===`readFile`?(0,Z.jsx)(Mg,{block:m,labels:a}):M===`editFile`?(0,Z.jsx)(Fg,{block:m,labels:a}):M===`writeFile`?(0,Z.jsx)(Lg,{block:m,labels:a}):M===`runCommand`?(0,Z.jsx)(Bg,{block:m,labels:a}):M===`fetchUrl`?(0,Z.jsx)(Vg,{block:m,labels:a}):null:null,t[66]=m,t[67]=a,t[68]=j,t[69]=M,t[70]=ee):ee=t[70];let V=ee;if(l){let e;t[71]!==m.name||t[72]!==m.result||t[73]!==C||t[74]!==b?(e=!b&&!C?(0,Z.jsx)(S_,{toolName:m.name,toolResult:m.result}):null,t[71]=m.name,t[72]=m.result,t[73]=C,t[74]=b,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 H=!b&&h,U=m.parentToolCallId?`ml-4 min-w-0 border-l border-edge pl-3`:`min-w-0`,te=C?`failed`:b?`running`:`completed`,ne=b&&`assistant-activity-busy`,re;t[78]===ne?re=t[79]:(re=Y(`mt-0.5 size-4 shrink-0 text-fg-subtle`,ne),t[78]=ne,t[79]=re);let ie;t[80]!==I||t[81]!==re?(ie=(0,Z.jsx)(I,{className:re,"aria-hidden":!0}),t[80]=I,t[81]=re,t[82]=ie):ie=t[82];let ae;t[83]===F?ae=t[84]:(ae=(0,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]=ae);let oe;t[85]!==te||t[86]!==ie||t[87]!==ae?(oe=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,"data-activity-status":te,children:[ie,ae]}),t[85]=te,t[86]=ie,t[87]=ae,t[88]=oe):oe=t[88];let se;t[89]!==V||t[90]!==i.stepDetails?(se=V?(0,Z.jsxs)(`details`,{className:`min-w-0 text-xs text-fg-muted`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer hover:text-fg`,children:i.stepDetails}),V]}):null,t[89]=V,t[90]=i.stepDetails,t[91]=se):se=t[91];let ce;t[92]!==m||t[93]!==b||t[94]!==M||t[95]!==g||t[96]!==h||t[97]!==i.stepDetails?(ce=M===`webSearch`&&!b?(0,Z.jsx)(Kg,{block:m,summary:i.stepDetails,labels:S(g).chat.searchDetails,developer:h,language:g}):null,t[92]=m,t[93]=b,t[94]=M,t[95]=g,t[96]=h,t[97]=i.stepDetails,t[98]=ce):ce=t[98];let le;t[99]!==N||t[100]!==i.memoryActivity?(le=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)(p,{className:`font-medium text-accent-fg hover:underline`,to:`/user-model`,children:i.memoryActivity.manage}),(0,Z.jsx)(p,{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]=le):le=t[101];let ue;t[102]!==T||t[103]!==h?(ue=T&&h?(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:T}):null,t[102]=T,t[103]=h,t[104]=ue):ue=t[104];let de;t[105]!==R||t[106]!==j||t[107]!==h?(de=h&&!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]=h,t[108]=de):de=t[108];let G;t[109]!==k||t[110]!==h?(G=h&&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]=h,t[111]=G):G=t[111];let K;t[112]!==o||t[113]!==g||t[114]!==O?(K=O?(0,Z.jsx)($g,{path:O,conversationId:o,label:g===`zh`?`查看完整输出`:`View full output`}):null,t[112]=o,t[113]=g,t[114]=O,t[115]=K):K=t[115];let fe;t[116]!==a||t[117]!==j||t[118]!==A||t[119]!==B||t[120]!==H||t[121]!==i.stepDetails||t[122]!==r?(fe=H?(0,Z.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer select-none text-fg-subtle underline-offset-2 hover:text-fg-muted group-open:text-fg-muted`,children: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]=H,t[121]=i.stepDetails,t[122]=r,t[123]=fe):fe=t[123];let q;t[124]!==oe||t[125]!==se||t[126]!==ce||t[127]!==le||t[128]!==ue||t[129]!==de||t[130]!==G||t[131]!==K||t[132]!==fe?(q=(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-1.5`,children:[oe,se,ce,le,ue,de,G,K,fe]}),t[124]=oe,t[125]=se,t[126]=ce,t[127]=le,t[128]=ue,t[129]=de,t[130]=G,t[131]=K,t[132]=fe,t[133]=q):q=t[133];let pe;return t[134]!==U||t[135]!==q?(pe=(0,Z.jsx)(`div`,{className:U,children:q}),t[134]=U,t[135]=q,t[136]=pe):pe=t[136],pe}function O_(e){return e.language}function k_(e){return e.showRawToolData}function A_(e){return e+1}function j_(e){let t=(0,X.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(Qa,{delayDuration:300,skipDelayDuration:100,children:n}),t[0]=n,t[1]=r),r}function M_(e){let t=(0,X.c)(7),{label:n,children:r}=e,i;t[0]===r?i=t[1]:(i=(0,Z.jsx)(no,{asChild:!0,children:r}),t[0]=r,t[1]=i);let a;t[2]===n?a=t[3]:(a=(0,Z.jsx)($a,{children:(0,Z.jsx)(to,{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)(eo,{children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function N_(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 P_(e){return e.filter(e=>e.type===`thinking`||e.type===`tool_use`)}function F_(e){let t=Br(e,`running`);return t.category===`web`&&t.action===`search`}function I_(e){let t=[];for(let n of e)if(!(!F_(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 L_(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function R_(e){let t=L_(e);return t?z_(un(t.delivery)??un(L_(t.details)?.delivery)??un(e),t):null}function z_(e,t){let n=e?.primary;if(!e||n?.kind!==`automation`||n.runId||e.operation!==`started`)return e;let r=L_(t),i=L_((L_(r?.result)??r)?.run);return i?.automationId!==n.id||typeof i.id!=`string`||!i.id?e:{...e,primary:{...n,runId:i.id}}}function B_(e){let t=R_(e.details);if(t)return t;let n=ha(e.result),r=R_(n.details);if(r)return r;let i=sn(n.text);if(i)try{return z_(i,JSON.parse(n.text.split(`
|
|
26
|
+
Open in xopc:`)[0]))}catch{return i}if(typeof e.result==`string`)try{return R_(JSON.parse(e.result))}catch{return null}return R_(e.result)}function V_(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 H_(e){return e.normalize(`NFKC`).trim().replace(/\s+/g,` `).toLowerCase()}function U_(e){return e.operation!==`opened`||e.presentation?.kind===`diff`||e.presentation?.kind===`inline_app`||e.presentation?.kind===`inline_preview`}function W_(e){return e.flatMap(({key:e,delivery:t})=>t.presentation?.kind===`diff`?[{key:e,presentation:t.presentation}]:[])}function G_(e){return{truncated:e.flatMap(({delivery:e})=>e.presentation?.kind===`table`?[e.presentation]:[]).some(e=>e.truncated)}}function K_(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 q_(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 J_(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=H_(e.reference.title);t&&i.set(t,e.reference.id)}return r.filter(e=>{if(e.reference.kind!==`task`)return!0;let t=H_(e.reference.title);return!t||i.get(t)===e.reference.id})}function Y_(e){return U_(e)?e.presentation||e.related?.length?!0:e.primary?e.primary.kind!==`note`||e.operation===`created`||e.operation===`updated`:!1:!1}function X_({message:e,isStreaming:t,reasoningLevel:n}){let r=fr(e.content??[],{includePending:!0}),i=new Set(r),a=tg(P_(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=B_(e);t&&Y_(t)&&u.set(e.id,t)}let d=[...u].map(([e,t])=>({key:e,delivery:t})),f=N_(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=[...Gm(_),...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:I_(c)}}function Z_(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=S(v(ev)),c=a.filter($_),l=r??I_(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(Q_),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 Q_(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 $_(e){return e.type===`tool_use`}function ev(e){return e.language}var tv=(0,Q.createContext)(!1);function nv(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),c=(0,Q.useRef)(null),l=(0,Q.useRef)(0),u=(0,Q.useRef)(!1),f=d(),p;t[0]===f.search?p=t[1]:(p=new URLSearchParams(f.search).has(ft),t[0]=f.search,t[1]=p);let m=p,h,g;t[2]!==n.length||t[3]!==r?(h=S(r).chat.productDelivery,g=h.relatedTaskCount.replace(`{{count}}`,String(n.length)),t[2]=n.length,t[3]=r,t[4]=h,t[5]=g):(h=t[4],g=t[5]);let _=g,v=a&&!m,y;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>{u.current=!e,o(e)},t[6]=y):y=t[6];let b;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(Ms,{}),t[7]=b):b=t[7];let x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(ae,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[8]=x):x=t[8];let j;t[9]===_?j=t[10]:(j=(0,Z.jsx)(w,{asChild:!0,children:(0,Z.jsx)(`button`,{ref:s,type:`button`,className:Ho,children:(0,Z.jsx)(Uo,{icon:b,title:_,trailing:x})})}),t[9]=_,t[10]=j);let M;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Z.jsx)(C,{className:`fixed inset-0 z-[80] bg-scrim`}),t[11]=M):M=t[11];let N,P;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(P=e=>{e.preventDefault(),c.current?.focus({preventScroll:!0})},N=e=>{e.preventDefault(),u.current&&s.current?.focus({preventScroll:!0})},t[12]=N,t[13]=P):(N=t[12],P=t[13]);let F;t[14]===_?F=t[15]:(F=(0,Z.jsx)(k,{ref:c,tabIndex:-1,className:`min-w-0 flex-1 font-medium text-fg focus:outline-none`,children:_}),t[14]=_,t[15]=F);let I;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(Xt,{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)(E,{"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)(T,{className:`sr-only`,children:h.relatedTasksDescription}),t[22]=h.relatedTasksDescription,t[23]=z);let B,ee;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(B=e=>{e&&(e.scrollTop=l.current)},ee=e=>{l.current=e.currentTarget.scrollTop},t[24]=B,t[25]=ee):(B=t[24],ee=t[25]);let V;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),V=n.map(e),t[26]=n,t[27]=i,t[28]=V}else V=t[28];let H;t[31]===V?H=t[32]:(H=(0,Z.jsx)(`div`,{"data-task-delivery-list":!0,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,ref:B,onScroll:ee,children:(0,Z.jsx)(`ul`,{className:`${Ko} p-3`,children:V})}),t[31]=V,t[32]=H);let U;t[33]!==R||t[34]!==z||t[35]!==H?(U=(0,Z.jsxs)(D,{children:[M,(0,Z.jsxs)(O,{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,H]})]}),t[33]=R,t[34]=z,t[35]=H,t[36]=U):U=t[36];let W;return t[37]!==U||t[38]!==v||t[39]!==j?(W=(0,Z.jsx)(`li`,{className:`min-w-0 max-w-full`,"data-product-task-group":!0,children:(0,Z.jsxs)(A,{open:v,onOpenChange:y,children:[j,U]})}),t[37]=U,t[38]=v,t[39]=j,t[40]=W):W=t[40],W}var rv={task:Ms,project:ke,note:ks,automation:ne,local_app:M,chat_preview:ws,file:Oe,session:Os,settings:zt};function iv(e,t){let n=e?.trim();return n?S(t).chat.productDelivery.statuses[n.toLowerCase()]??n:null}function av(e,t,n){let r=S(n).chat.productDelivery.operations[e.operation],i=iv(t.status,n);return i&&e.operation===`opened`?i:i&&i.toLowerCase()!==r.toLowerCase()?`${r} · ${i}`:i??r}function ov(e,t,n){let r=S(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 sv(e,t){let n=S(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 cv(e){let t=(0,X.c)(90),{delivery:n,reference:r,language:i,conversationId:a,projectId:o,fullTitle:s}=e,c=s!==void 0&&s,l=m(),u=d(),f=ai(uv),p=rv[r.kind],h;t[0]===r?h=t[1]:(h=on(r),t[0]=r,t[1]=h);let g=h,v;t[2]!==r.capabilities||t[3]!==r.id||t[4]!==r.kind?(v=r.kind===`file`&&r.capabilities.includes(`preview`)?V_(r.id):null,t[2]=r.capabilities,t[3]=r.id,t[4]=r.kind,t[5]=v):v=t[5];let y=v,b;t[6]!==a||t[7]!==y||t[8]!==o?(b=y&&(a?.trim()||o?.trim()),t[6]=a,t[7]=y,t[8]=o,t[9]=b):b=t[9];let x=!!b,C;t[10]!==x||t[11]!==r.capabilities||t[12]!==g?(C=x||!!(g&&r.capabilities.includes(`open`)),t[10]=x,t[11]=r.capabilities,t[12]=g,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=_(lv),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=()=>$r(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=Qr(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`?ov(n,{phase:M.data?.task.phase,resolution:M.data?.task.resolution,operationalState:M.data?.operationalState??r.status,attention:M.data?.attention},i):av(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)(Wo,{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]!==x||t[44]!==a||t[45]!==y||t[46]!==u||t[47]!==l||t[48]!==o||t[49]!==r.id||t[50]!==r.kind||t[51]!==r.projectId||t[52]!==r.revision||t[53]!==g||t[54]!==f?(L=()=>{if(y&&x){f(y,null,o,a);return}if(r.kind===`task`){l(et(`${u.pathname}${u.search}`,r.id));return}if(r.kind===`note`){l(Ct(`${u.pathname}${u.search}`,r.id));return}if(g){let e=new URL(g,`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),l(it(nt(`${u.pathname}${u.search}`,`${e.pathname}${e.search}`),`${u.pathname}${u.search}`))}},t[43]=x,t[44]=a,t[45]=y,t[46]=u,t[47]=l,t[48]=o,t[49]=r.id,t[50]=r.kind,t[51]=r.projectId,t[52]=r.revision,t[53]=g,t[54]=f,t[55]=L):L=t[55];let R=L,z=r.kind,B=w?R:void 0,ee=!w,V;t[56]===r.summary?V=t[57]:(V=r.summary?.trim(),t[56]=r.summary,t[57]=V);let H;t[58]!==I||t[59]!==r.title||t[60]!==V?(H=[r.title,I,V].filter(Boolean),t[58]=I,t[59]=r.title,t[60]=V,t[61]=H):H=t[61];let U=H.join(` · `),W=w?`cursor-pointer`:`cursor-default`,te=D&&`text-danger`,ne;t[62]!==W||t[63]!==te?(ne=Y(Ho,W,te),t[62]=W,t[63]=te,t[64]=ne):ne=t[64];let re=D?`text-danger`:void 0,ie;t[65]!==p||t[66]!==re?(ie=(0,Z.jsx)(p,{strokeWidth:1.75,className:re}),t[65]=p,t[66]=re,t[67]=ie):ie=t[67];let oe;t[68]===w?oe=t[69]:(oe=w?(0,Z.jsx)(ae,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}):null,t[68]=w,t[69]=oe);let se;t[70]!==I||t[71]!==c||t[72]!==r.title||t[73]!==ie||t[74]!==oe?(se=(0,Z.jsx)(Uo,{icon:ie,title:r.title,meta:I,fullTitle:c,trailing:oe}),t[70]=I,t[71]=c,t[72]=r.title,t[73]=ie,t[74]=oe,t[75]=se):se=t[75];let ce;t[76]!==B||t[77]!==ee||t[78]!==U||t[79]!==ne||t[80]!==se?(ce=(0,Z.jsx)(`button`,{type:`button`,onClick:B,disabled:ee,title:U,className:ne,children:se}),t[76]=B,t[77]=ee,t[78]=U,t[79]=ne,t[80]=se,t[81]=ce):ce=t[81];let le;t[82]!==E||t[83]!==i||t[84]!==r?(le=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`,la.transition,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`),onClick:()=>lm(sv(r,i)),children:S(i).chat.productDelivery.continue}):null,t[82]=E,t[83]=i,t[84]=r,t[85]=le):le=t[85];let ue;return t[86]!==r.kind||t[87]!==ce||t[88]!==le?(ue=(0,Z.jsxs)(`li`,{className:`flex max-w-full min-w-0 flex-wrap items-center gap-2`,"data-product-delivery":z,children:[ce,le]}),t[86]=r.kind,t[87]=ce,t[88]=le,t[89]=ue):ue=t[89],ue}function lv(e){return e.conversationId}function uv(e){return e.setPath}function dv(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=S(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(Ho,`cursor-pointer list-none`),t[3]=c):c=t[3];let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(bs,{strokeWidth:1.75}),t[4]=l):l=t[4];let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(ae,{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)(Uo,{icon:l,title:s,trailing:u})}),t[6]=s,t[7]=d);let f;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(f=Y(Ko,Vo),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)(cv,{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 fv(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=J_(n,i),t=e.filter(gv),l=e.findIndex(hv),u=e.filter(mv),d=e.findIndex(pv);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)(nv,{entries:u,language:r,renderEntry:(e,t)=>(0,Z.jsx)(cv,{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)(cv,{delivery:s,reference:c,language:r,conversationId:a,projectId:o},i):n===l?(0,Z.jsx)(dv,{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 pv(e){let{reference:t}=e;return t.kind===`task`}function mv(e){let{reference:t}=e;return t.kind===`task`}function hv(e){let{reference:t}=e;return t.kind===`file`}function gv(e){let{reference:t}=e;return t.kind===`file`}function _v(e){let t=(0,X.c)(22),{presentation:n}=e,r=v(vv),i;t[0]===r?i=t[1]:(i=S(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 vv(e){return e.language}function yv({previewId:e,reference:t,sourceHash:n,preferredHeight:r,language:i}){let a=m(),o=d(),s=(0,Q.useRef)(null),[c,l]=(0,Q.useState)(0),[u,f]=(0,Q.useState)(`booting`),[p,h]=(0,Q.useState)(null),[_,v]=(0,Q.useState)([]),[y,b]=(0,Q.useState)(!1),[x,C]=(0,Q.useState)(null),w=Math.min(720,Math.max(240,r)),T=ia(e),E=Qr(T.active?[`inline-local-app-snapshot`,t.id,n]:null,()=>$o(t.id,n),{revalidateOnFocus:!1,shouldRetryOnError:!1});(0,Q.useEffect)(()=>{let e=s.current;if(!e||!E.data?.previewUrl)return;f(`booting`),h(null),v([]);let t=window.setTimeout(()=>{f(e=>e===`booting`?`timeout`:e)},7e3),n=Xo(e,e=>{let t=dn(e);if(t){if(t.type===`ready`){f(`healthy`);return}if(t.type===`error`){h(t.detail),f(`failed`),v(e=>[...e,{phase:`runtime`,message:Zo(t.detail),code:t.detail.kind}].slice(-20));return}if(t.type===`acceptance`&&t.detail.status===`failed`){f(`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`&&(f(`failed`),v(e=>[...e,...t.detail.scenarios.filter(e=>e.status===`failed`).map(e=>({phase:e.failureKind===`runner`?`runner`:`acceptance`,code:e.id,message:`${e.name}: ${e.message}`}))].slice(-20)))}});return()=>{window.clearTimeout(t),n()}},[c,E.data?.previewUrl]);let D=()=>{let e=on(t);e&&a(nt(`${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)(vi,{variant:`ghost`,className:`content-block-action`,onClick:D,title:i===`zh`?`查看预览`:`Preview`,"aria-label":i===`zh`?`查看预览`:`Preview`,children:(0,Z.jsx)(we,{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)(vi,{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":S(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)(Gt,{className:`size-4`}),t]})})}let k=O.validation.issues.map(e=>({phase:`build`,code:e.code,message:e.message}))??[],A=u===`timeout`?[{phase:`boot`,code:`boot_timeout`,message:S(i).chat.productDelivery.previewTimeout}]:[],j=[...k,..._,...A],M=O.status===`invalid`||O.validation.status===`failed`,N=M||u===`failed`||u===`timeout`,P=M?i===`zh`?`校验失败`:`Validation failed`:u===`healthy`?i===`zh`?`运行正常`:`Running`:u===`booting`?i===`zh`?`正在启动`:`Starting`:u===`timeout`?i===`zh`?`启动超时`:`Start timed out`:i===`zh`?`运行错误`:`Runtime error`,F=()=>{C(null),l(e=>e+1)},I=async()=>{if(j.length){b(!0),C(null);try{let e=await es(t.id,{sourceHash:O.sourceHash,locale:i,diagnostics:j});if(e.action===`retry`){F();return}let n=await Qo(t.id);a(Yo(n,e.prompt))}catch(e){C(e instanceof Error?e.message:String(e))}finally{b(!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)(vi,{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)(Pt,{className:`size-4`,"aria-hidden":!0})}),(0,Z.jsx)(vi,{variant:`ghost`,className:`content-block-action`,onClick:D,title:i===`zh`?`查看预览`:`Preview`,"aria-label":i===`zh`?`查看预览`:`Preview`,children:(0,Z.jsx)(we,{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:g(O.previewUrl),sandbox:`allow-scripts allow-forms`,className:`h-full w-full border-0 bg-white`},c):null,O.previewUrl&&u===`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:p?.message??j[0]?.message??(i===`zh`?`预览校验失败`:`Preview validation failed`)}),(0,Z.jsxs)(vi,{variant:`secondary`,className:`min-h-9 px-3 text-xs`,disabled:y||j.length===0,onClick:()=>void I(),children:[(0,Z.jsx)(Yt,{className:`size-4`}),y?i===`zh`?`生成修复建议…`:`Preparing fix…`:i===`zh`?`让 Coder 修复`:`Ask Coder to fix`]})]}),x?(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-danger`,role:`alert`,children:x}):null]}):null]})}async function bv(e,t){return(await y(g(`/api/chat-previews/${encodeURIComponent(e)}/revisions/${encodeURIComponent(t)}`))).revision}async function xv(e,t){return(await y(g(`/api/chat-previews/${encodeURIComponent(e)}/fix-guidance`),{method:`POST`,body:JSON.stringify(t)})).guidance}async function Sv(e,t){return(await y(g(`/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 wv(e){let t=ln.safeParse(e);return t.success?t.data:null}function Tv(e,t){let n=`(() => {
|
|
27
|
+
const channel = ${JSON.stringify(t)};
|
|
28
|
+
const bufferedErrors = [];
|
|
29
|
+
const send = (type, detail = {}) => parent.postMessage({
|
|
30
|
+
source: ${JSON.stringify(cn)},
|
|
31
|
+
version: 1, channel, type, ...detail
|
|
32
|
+
}, '*');
|
|
33
|
+
const resize = () => send('resize', { height: Math.max(120, Math.min(2000,
|
|
34
|
+
Math.ceil(document.documentElement.getBoundingClientRect().height))) });
|
|
35
|
+
const report = (diagnostic) => { bufferedErrors.push(diagnostic); send('error', { diagnostic }); };
|
|
36
|
+
addEventListener('error', (event) => report({
|
|
37
|
+
kind: 'script_error', message: String(event.message || 'Script error'),
|
|
38
|
+
filename: event.filename || undefined, line: event.lineno || undefined,
|
|
39
|
+
column: event.colno || undefined
|
|
40
|
+
}));
|
|
41
|
+
addEventListener('unhandledrejection', (event) => report({
|
|
42
|
+
kind: 'unhandled_rejection', message: String(event.reason?.message || event.reason || 'Unhandled rejection')
|
|
43
|
+
}));
|
|
44
|
+
addEventListener('DOMContentLoaded', () => {
|
|
45
|
+
resize(); new ResizeObserver(resize).observe(document.documentElement);
|
|
46
|
+
setTimeout(() => {
|
|
47
|
+
send('ready');
|
|
48
|
+
bufferedErrors.forEach((diagnostic) => send('error', { diagnostic }));
|
|
49
|
+
}, 100);
|
|
50
|
+
});
|
|
51
|
+
})();`;return`<!doctype html>
|
|
52
|
+
<html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
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>
|
|
55
|
+
</head><body>${e.markup}
|
|
56
|
+
<script>${Cv(n,`script`)}<\/script>
|
|
57
|
+
<script>${Cv(e.script,`script`)}<\/script>
|
|
58
|
+
</body></html>`}function Ev(e,t,n){let r=r=>{if(r.source!==e.contentWindow)return;let i=wv(r.data);!i||i.channel!==t||n(i)};return window.addEventListener(`message`,r),()=>window.removeEventListener(`message`,r)}function Dv({leaseId:e,reference:t,sourceHash:n,preferredHeight:r,language:i}){let a=m(),o=d(),s=(0,Q.useRef)(null),[c,l]=(0,Q.useState)(0),[u,f]=(0,Q.useState)(`booting`),[p,h]=(0,Q.useState)([]),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(null),b=ia(e),x=Math.min(720,Math.max(240,r)),S=(0,Q.useMemo)(()=>crypto.randomUUID(),[c,n]),C=Qr(b.active?[`chat-preview-revision`,t.id,n]:null,()=>bv(t.id,n),{revalidateOnFocus:!1,shouldRetryOnError:!1}),w=C.data?Tv(C.data,S):void 0;(0,Q.useEffect)(()=>{let e=s.current;if(!e||!w)return;f(`booting`),h([]);let t=window.setTimeout(()=>{f(e=>e===`booting`?`timeout`:e)},7e3),n=Ev(e,S,t=>{t.type===`ready`&&f(`healthy`),t.type===`resize`&&(e.style.height=`${Math.min(720,Math.max(240,t.height))}px`),t.type===`error`&&(f(`failed`),h(e=>[...e,t.diagnostic].slice(-20)))});return()=>{window.clearTimeout(t),n()}},[S,w]);let T=()=>{y(null),l(e=>e+1)},E=async()=>{if(p.length){_(`fix`),y(null);try{lm((await xv(t.id,{sourceHash:n,diagnostics:p,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(nt(`${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)(vi,{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)(Gt,{className:`size-4`}),e]})})}let k=u===`failed`||u===`timeout`,A=u===`healthy`?i===`zh`?`运行正常`:`Running`:u===`booting`?i===`zh`?`正在启动`:`Starting`:u===`timeout`?i===`zh`?`启动超时`:`Start timed out`:i===`zh`?`运行错误`:`Runtime error`;return(0,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)(vi,{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)(Pt,{className:`size-4`,"aria-hidden":!0})}),(0,Z.jsx)(vi,{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)(It,{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}},c),u===`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:p.at(-1)?.message??(i===`zh`?`预览未能正常启动`:`The preview did not start correctly`)}),(0,Z.jsxs)(vi,{variant:`secondary`,className:`min-h-11 px-3 text-xs`,disabled:!p.length||g!==null,onClick:()=>void E(),children:[(0,Z.jsx)(Yt,{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 Ov(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 kv(e){return{id:e.artifactId,name:e.title,type:e.kind,mimeType:e.mimeType,size:e.sizeBytes,uri:e.uri,workspaceRelativePath:e.workspaceRelativePath}}function Av(e){let t=e.mimeType?.toLowerCase()??``,n=e.type?.toLowerCase()??``;return t.startsWith(`image/`)||n===`image`?De:t.startsWith(`audio/`)||n===`audio`||n===`voice`?_s:t.startsWith(`video/`)||n===`video`?ye:t.includes(`spreadsheet`)||[`spreadsheet`,`csv`,`xlsx`,`xls`].includes(n)?ve:t.includes(`zip`)||[`archive`,`zip`].includes(n)?N:n===`site`?te:Oe}function jv(e,t,n){return!!(e.uri||ui(e)||e.workspaceRelativePath?.trim()&&(t?.trim()||n?.trim()))}function Mv(e){let t=(0,X.c)(43),{item:n,authToken:r,conversationId:i,projectId:a,onOpen:o}=e,s=v(Nv),c;t[0]===s?c=t[1]:(c=S(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=km(n.attachment,u),f;t[5]===n.attachment?f=t[6]:(f=Av(n.attachment),t[5]=n.attachment,t[6]=f);let p=f,m;t[7]!==i||t[8]!==n.attachment||t[9]!==a?(m=jv(n.attachment,i,a),t[7]=i,t[8]=n.attachment,t[9]=a,t[10]=m):m=t[10];let h=m,g=h||!!n.href,_;t[11]!==p||t[12]!==d.src||t[13]!==n.failed?(_=d.src?(0,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]=_):_=t[14];let y=n.attachment.name??l,b;t[15]===g?b=t[16]:(b=g?(0,Z.jsx)(ae,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}):null,t[15]=g,t[16]=b);let x;t[17]!==n.meta||t[18]!==_||t[19]!==y||t[20]!==b?(x=(0,Z.jsx)(Uo,{icon:_,title:y,meta:n.meta,trailing:b}),t[17]=n.meta,t[18]=_,t[19]=y,t[20]=b,t[21]=x):x=t[21];let C=x,w=g?`cursor-pointer`:`cursor-default`,T;t[22]===w?T=t[23]:(T=Y(Ho,w),t[22]=w,t[23]=T);let E=T,D=n.attachment.name??l,O;t[24]!==n.meta||t[25]!==D?(O=[D,n.meta],t[24]=n.meta,t[25]=D,t[26]=O):O=t[26];let k=O.join(` · `);if(!h&&n.href){let e;return t[27]!==E||t[28]!==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(!h){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 Nv(e){return e.language}function Pv(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=S(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(Ho,`cursor-pointer list-none`),t[3]=u):u=t[3];let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(bs,{strokeWidth:1.75}),t[4]=d):d=t[4];let f;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(ae,{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)(Uo,{icon:d,title:l,trailing:f})}),t[6]=l,t[7]=p);let m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m=Y(Ko,Vo),t[8]=m):m=t[8];let h;if(t[9]!==n||t[10]!==r||t[11]!==i||t[12]!==o||t[13]!==a){let e;t[15]!==r||t[16]!==i||t[17]!==o||t[18]!==a?(e=e=>(0,Z.jsx)(Mv,{item:e,authToken:r,conversationId:i,projectId:a,onOpen:o},e.key),t[15]=r,t[16]=i,t[17]=o,t[18]=a,t[19]=e):e=t[19],h=n.map(e),t[9]=n,t[10]=r,t[11]=i,t[12]=o,t[13]=a,t[14]=h}else h=t[14];let g;t[20]===h?g=t[21]:(g=(0,Z.jsx)(`ul`,{className:m,children:h}),t[20]=h,t[21]=g);let _;return t[22]!==p||t[23]!==g?(_=(0,Z.jsx)(`li`,{className:`min-w-0 max-w-full`,"data-result-attachment-group":!0,children:(0,Z.jsxs)(`details`,{className:`group`,children:[p,g]})}),t[22]=p,t[23]=g,t[24]=_):_=t[24],_}function Fv(e,t){if(!e)return[];let n=S(t).chat.turnOutcome;return e.deliverables.map(e=>{let t=kv(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:di(e.sizeBytes)].filter(Boolean).join(` · `)}})}function Iv(e,t){let n=S(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`?di(e.size):null].filter(Boolean).join(` · `)}))}function Lv(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 Rv(e){let t=(0,X.c)(46),{view:n,authToken:r,conversationId:i,projectId:a}=e,o=v(Uv)===`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=Mm(s),l=n.deliveries.filter(Hv),u=W_(l),d=K_(l),f=q_(l),p=G_(l),m=(0,Q.useContext)(tv),h=new Set(Lv(n.outcome));if(m)for(let{delivery:e,reference:t}of J_(l))t.kind===`automation`&&!t.runId&&e.operation!==`failed`&&h.add(`automation:${t.id}`);let g=J_(l,h).length,_,y,b,x;if(t[3]!==o||t[4]!==c||t[5]!==n.attachments||t[6]!==n.outcome||t[7]!==n.resultRevision){_=[...Fv(n.outcome,o),...Iv(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],y=e;let r;t[15]!==y||t[16]!==c||t[17]!==n.resultRevision?(r=e=>{c.openAttachment(e,y(e)?n.resultRevision:void 0)},t[15]=y,t[16]=c,t[17]=n.resultRevision,t[18]=r):r=t[18],b=r,x=_.filter(Vv),t[3]=o,t[4]=c,t[5]=n.attachments,t[6]=n.outcome,t[7]=n.resultRevision,t[8]=_,t[9]=y,t[10]=b,t[11]=x}else _=t[8],y=t[9],b=t[10],x=t[11];let C=x,w;t[19]!==_||t[20]!==C?(w=_.filter(e=>!C.includes(e)),t[19]=_,t[20]=C,t[21]=w):w=t[21];let T=w,E=g>0||T.length>0;if(u.length===0&&d.length===0&&f.length===0&&!E&&!C.length)return null;let D;t[22]!==r||t[23]!==i||t[24]!==C?(D=C.length>0?(0,Z.jsx)(Vm,{attachments:C.map(Bv),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(zv),k;t[26]===o?k=t[27]:(k=e=>{let{key:t,presentation:n}=e;return(0,Z.jsx)(yv,{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)(Dv,{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)(Ov,{label:S(o).chat.productDelivery.heading,children:[(0,Z.jsxs)(`ul`,{className:Ko,children:[(0,Z.jsx)(fv,{deliveries:l,language:o,excludedReferenceKeys:h,conversationId:i,projectId:a}),T.length>1?(0,Z.jsx)(Pv,{attachments:T,authToken:r,conversationId:i,projectId:a,onOpen:b,language:o}):T.map(e=>(0,Z.jsx)(Mv,{item:e,authToken:r,conversationId:i,projectId:a,onOpen:b},e.key))]}),p.truncated?(0,Z.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-fg-muted`,children:S(o).chat.productDelivery.partialResults}):null]}):null,P;t[30]!==T.length||t[31]!==r||t[32]!==i||t[33]!==y||t[34]!==c.active||t[35]!==c.closePreview||t[36]!==c.open||t[37]!==n.resultRevision?(P=T.length>0?(0,Z.jsx)(Co,{open:c.open,attachment:c.active,resultRevision:c.active&&y(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]=y,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 zv(e){let{key:t,presentation:n}=e;return(0,Z.jsx)(_v,{presentation:n},t)}function Bv(e){return e.attachment}function Vv(e){return!e.failed&&e.attachment.mimeType?.startsWith(`image/`)}function Hv(e){let{delivery:t}=e;return U_(t)}function Uv(e){return e.language}var Wv=(0,Q.createContext)({});function Gv(e){let t=(0,X.c)(16),{outcome:n}=e,r=S(v(Jv)).chat.turnOutcome,i=(0,Q.useContext)(Wv),a=!!(i.turnId&&i.turnId===n.turnId),o=n.status===`failed`&&!(a&&i.running)?(0,Z.jsx)(Th,{errorText:a&&i.error||n.summary||r.statusFailed,onRetry:a?i.onRetry:void 0}):null,s=!!n.changeSet,c=n.evidence.length>0;if(!s&&!c)return o;let l=n.evidence.filter(qv).length,u=n.evidence.filter(Kv).length,d=n.status===`succeeded`?r.statusSucceeded:n.status===`failed`?r.statusFailed:r.statusPartial,f=n.status===`succeeded`?re:n.status===`failed`?he:q,p=[n.changeSet?r.changedFileCount.replace(`{{count}}`,String(n.changeSet.files.length)):null,l>0?r.passedCount.replace(`{{count}}`,String(l)):null,u>0?r.failedCount.replace(`{{count}}`,String(u)):null,c&&l===0&&u===0?r.evidenceCount.replace(`{{count}}`,String(n.evidence.length)):null].filter(Boolean).join(` · `),m=n.status===`succeeded`?`text-success`:n.status===`failed`?`text-danger`:`text-warning`,h;t[0]!==f||t[1]!==m?(h=(0,Z.jsx)(f,{className:m,"aria-hidden":!0}),t[0]=f,t[1]=m,t[2]=h):h=t[2];let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsx)(ae,{className:`size-3.5 shrink-0 text-fg-subtle transition-transform group-open:rotate-90 motion-reduce:transition-none`,strokeWidth:1.75,"aria-hidden":!0}),t[3]=g):g=t[3];let _=Vo,y=n.changeSet?(0,Z.jsxs)(`section`,{"aria-label":r.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:r.changeSetTitle}),(0,Z.jsx)(`span`,{className:`shrink-0 text-fg-subtle`,children:r.changeStats.replace(`{{files}}`,String(n.changeSet.files.length)).replace(`{{added}}`,String(n.changeSet.added)).replace(`{{removed}}`,String(n.changeSet.removed))})]}),(0,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:r.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:r.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:r.viewDiff}),n.changeSet.diffTruncated?(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-warning`,children:r.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,b;t[4]!==s||t[5]!==c?(b=s&&c?(0,Z.jsx)(`div`,{className:`my-2 border-t border-edge-subtle`}):null,t[4]=s,t[5]=c,t[6]=b):b=t[6];let x;t[7]!==c||t[8]!==n.evidence||t[9]!==r?(x=c?(0,Z.jsxs)(`section`,{"aria-label":r.evidence,children:[(0,Z.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg`,children:r.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)(Ye,{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`?r.passed:e.status===`failed`?r.failed:r.warning})]},e.evidenceId))]}):null,t[7]=c,t[8]=n.evidence,t[9]=r,t[10]=x):x=t[10];let C;return t[11]!==_||t[12]!==y||t[13]!==b||t[14]!==x?(C=(0,Z.jsxs)(`div`,{className:_,children:[y,b,x]}),t[11]=_,t[12]=y,t[13]=b,t[14]=x,t[15]=C):C=t[15],(0,Z.jsxs)(Z.Fragment,{children:[o,(0,Z.jsxs)(`details`,{className:`group mt-2 min-w-0 max-w-full text-sm`,children:[(0,Z.jsx)(`summary`,{className:`${Ho} cursor-pointer list-none`,title:`${d} · ${p}`,children:(0,Z.jsx)(Uo,{icon:h,title:d,meta:p,trailing:g})}),C]})]})}function Kv(e){return e.status===`failed`}function qv(e){return e.status===`passed`}function Jv(e){return e.language}function Yv(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)(Rv,{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)(Gv,{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:`${Ho} cursor-pointer list-none`,children:(0,Z.jsx)(Uo,{icon:(0,Z.jsx)(Ie,{}),title:o,trailing:(0,Z.jsx)(ae,{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:Vo,children:(0,Z.jsx)(Z_,{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 Xv=`NO_REPLY`;function Zv(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()!==Xv);if(n.length!==e.content.length)return Zv({...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===Xv||t.streaming&&i.length>0&&Xv.startsWith(i)))return{...e,content:e.content.filter((e,t)=>t!==n)};if(!i.startsWith(Xv))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 Qv(e,t){return t||e.workLog.items.some(e=>e.type===`tool_use`&&(e.status===`error`||e.activity?.status===`failed`))}function $v(e,t){if(e.role!==`assistant`||t.isStreaming||t.followUpTrigger)return!0;let n=X_({message:Zv(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||Qv(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 ey(e,t){let n=fr(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 ty(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=v(ny),p=S(f).chat,m;t[0]!==r||t[1]!==n?(m=ey(n,r),t[0]=r,t[1]=n,t[2]=m):m=t[2];let h=m,g=i&&h.settled&&a.length>0,_,y;t[3]===r?(_=t[4],y=t[5]):(_=()=>{r&&d(null)},y=[r],t[3]=r,t[4]=_,t[5]=y),(0,Q.useEffect)(_,y);let b,x;t[6]!==i||t[7]!==a.length?(b=()=>{if(!i||a.length===0)return;let e=()=>{let e=window.getSelection();l(!!(s.current&&[...s.current.querySelectorAll(`[data-assistant-process-item]`)].some(t=>e&&!e.isCollapsed&&e.containsNode(t,!0)||t.contains(document.activeElement))))};return e(),document.addEventListener(`selectionchange`,e),document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,e),()=>{document.removeEventListener(`selectionchange`,e),document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,e)}},x=[i,a.length],t[6]=i,t[7]=a.length,t[8]=b,t[9]=x):(b=t[8],x=t[9]),(0,Q.useEffect)(b,x);let C=u??(!h.defaultCollapsed||c),w=o==null?null:qg(o,f),T=n.runStatus===`cancelled`?p.processStopped:n.runStatus===`error`||h.outcome?.status===`failed`?p.processFailed:h.outcome?.status===`partial`?p.processPartial:null,E=T?`${T}${w?` · ${w}`:``}`:w?p.processWorkedFor.replace(`{{duration}}`,w):p.processView,D=g&&!C,O;t[10]!==C||t[11]!==E||t[12]!==g?(O=g?(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)(ae,{"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]=g,t[13]=O):O=t[13];let k;return t[14]!==D||t[15]!==O?(k={contentRef:s,collapsed:D,summary:O},t[14]=D,t[15]=O,t[16]=k):k=t[16],k}function ny(e){return e.language}function ry(e,t=!1){return t||e.textSurface===`conversation`}function iy(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 ay(e){let t=(0,X.c)(23),{trigger:n}=e,r=d(),i=v(oy),a;t[0]===i?a=t[1]:(a=S(i),t[0]=i,t[1]=a);let o=a.chat.taskTrigger,s=n.entryId,c;t[2]===o.about?c=t[3]:(c=(0,Z.jsx)(`span`,{className:`shrink-0`,children:o.about}),t[2]=o.about,t[3]=c);let l=`${r.pathname}${r.search}`,u;t[4]!==l||t[5]!==n.taskId?(u=et(l,n.taskId),t[4]=l,t[5]=n.taskId,t[6]=u):u=t[6];let f=n.taskTitle,m=`${o.openTask}:${n.taskTitle}`,h;t[7]===n.taskTitle?h=t[8]:(h=iy(n.taskTitle),t[7]=n.taskTitle,t[8]=h);let g;t[9]===h?g=t[10]:(g=(0,Z.jsxs)(`span`,{className:`truncate`,children:[`「`,h,`」`]}),t[9]=h,t[10]=g);let _;t[11]!==u||t[12]!==m||t[13]!==g||t[14]!==n.taskTitle?(_=(0,Z.jsx)(p,{className:`inline-flex min-w-0 max-w-[min(48vw,30rem)] font-medium text-fg hover:text-accent hover:underline`,to:u,title:f,"aria-label":m,children:g}),t[11]=u,t[12]=m,t[13]=g,t[14]=n.taskTitle,t[15]=_):_=t[15];let y=o[n.kind],b;t[16]===y?b=t[17]:(b=(0,Z.jsxs)(`span`,{className:`shrink-0 whitespace-nowrap`,children:[`· `,y]}),t[16]=y,t[17]=b);let x;return t[18]!==_||t[19]!==b||t[20]!==c||t[21]!==n.entryId?(x=(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:[c,_,b]}),t[18]=_,t[19]=b,t[20]=c,t[21]=n.entryId,t[22]=x):x=t[22],x}function oy(e){return e.language}var sy=3;function cy(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>sy,_;t[0]!==m||t[1]!==n?(_=m?n:n.slice(0,sy),t[0]=m,t[1]=n,t[2]=_):_=t[2];let v=_,y=n.length-sy,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)(je,{className:`size-3.5`,"aria-hidden":!0}):e.kind===`file`||e.kind===`result`?(0,Z.jsx)(Oe,{className:`size-3.5`,"aria-hidden":!0}):e.kind===`session`?(0,Z.jsx)(wt,{className:`size-3.5`,"aria-hidden":!0}):e.kind===`browser_tab`?(0,Z.jsx)(M,{className:`size-3.5`,"aria-hidden":!0}):e.kind===`mcp_resource`?(0,Z.jsx)(Se,{className:`size-3.5`,"aria-hidden":!0}):(0,Z.jsx)(ks,{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)(ae,{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(ly),children:[m?(0,Z.jsx)(oe,{className:`size-3.5`,"aria-hidden":!0}):(0,Z.jsx)(ie,{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 ly(e){return!e}function uy(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 dy(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=uy(i,a.origins),t[0]=i,t[1]=a.origins,t[2]=o):o=t[2];let s=o,c=s.reduce(hy,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(my):[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(py)))},t[12]=h,t[13]=s,t[14]=g):g=t[14];let _=g,v;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(v=e=>{d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},t[15]=v):v=t[15];let y=v,b;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(C,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim/60 backdrop-blur-[1px]`}),t[16]=b):b=t[16];let x;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(x=Y(`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(36rem,calc(100dvh-2rem))]`,`w-[min(42rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-popover outline-none`),t[17]=x):x=t[17];let S;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,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)(hs,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[18]=S):S=t[18];let w;t[19]===a.title?w=t[20]:(w=(0,Z.jsx)(k,{className:`text-base font-semibold text-fg`,children:a.title}),t[19]=a.title,t[20]=w);let j;t[21]===a.hint?j=t[22]:(j=(0,Z.jsx)(T,{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]!==w||t[29]!==j||t[30]!==N?(P=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[w,j,N]}),t[28]=w,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)(Xt,{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)(E,{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:[S,P,I]}),t[35]=P,t[36]=I,t[37]=L):L=t[37];let R;t[38]!==s.length||t[39]!==a.groupSummary?(R=a.groupSummary.replace(`{{count}}`,String(s.length)),t[38]=s.length,t[39]=a.groupSummary,t[40]=R):R=t[40];let z;t[41]===R?z=t[42]:(z=(0,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 ee;t[49]!==z||t[50]!==B?(ee=(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]=ee):ee=t[51];let V;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)(ie,{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(fy)}):null]},e.id)},t[55]=u,t[56]=e),V=s.map(e),t[52]=u,t[53]=s,t[54]=V}else V=t[54];let H;t[57]===V?H=t[58]:(H=(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:V})}),t[57]=V,t[58]=H);let U;t[59]!==L||t[60]!==ee||t[61]!==H?(U=(0,Z.jsxs)(D,{children:[b,(0,Z.jsxs)(O,{className:x,children:[L,ee,H]})]}),t[59]=L,t[60]=ee,t[61]=H,t[62]=U):U=t[62];let W;return t[63]!==r||t[64]!==n||t[65]!==U?(W=(0,Z.jsx)(A,{open:n,onOpenChange:r,children:U}),t[63]=r,t[64]=n,t[65]=U,t[66]=W):W=t[66],W}function fy(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 py(e){return e.id}function my(e){return e.id}function hy(e,t){return e+t.items.length}var gy=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`,la.disabled),_y=[`misunderstood_intent`,`incorrect`,`did_not_act`,`tone_mismatch`,`too_verbose`,`other`],vy=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`,la.disabled),yy=700,by=120,xy=(0,Q.memo)(function({message:e,personal:t=!1,followUpTrigger:n,authToken:r,conversationId:i,workspaceConversationId:a,projectId:o,isStreaming:s,progress:c,reasoningLevel:l=`on`,messageIndex:u,onDeleteRound:f,onRetryUserMessageRound:p,userMessageCanRetry:h=!1,deleteRoundDisabled:_=!1,onSaveAssistantAsNote:b,onSaveAssistantToSourceNote:x,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)(()=>Zv(e,{hideSilentReply:ry(e,t),streaming:s}),[e,t,s]),N=v(e=>e.language),P=S(N),F=m(),I=d(),z=M.role===`user`,B=M.role===`assistant`,H=(0,Q.useRef)(z&&M.deliveryStatus===`sending`).current,W=z&&M.deliveryStatus===`sending`,te=z&&M.deliveryStatus===`failed`,[ne,ae]=(0,Q.useState)(!1),[se,ce]=(0,Q.useState)(!1),[le,ue]=(0,Q.useState)(()=>typeof navigator<`u`&&navigator.onLine===!1),de=z?P.chat.you:B?P.chat.assistant:P.chat.tool;(0,Q.useEffect)(()=>{if(!W||typeof window>`u`)return;let e=()=>ue(window.navigator.onLine===!1);return window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}},[W]),(0,Q.useEffect)(()=>{if(W){if(ne)return;let e=window.setTimeout(()=>ae(!0),le?0:yy);return()=>window.clearTimeout(e)}if(!ne)return;let e=0,t=window.requestAnimationFrame(()=>{ce(!0),e=window.setTimeout(()=>{ae(!1),ce(!1)},by)});return()=>{window.cancelAnimationFrame(t),window.clearTimeout(e)}},[W,le,ne]);let G=te||ne,K=te?`failed`:`sending`,fe=(0,Q.useCallback)(e=>{let t=`${I.pathname}${I.search}`;F(Ct(t,e))},[I.pathname,I.search,F]),pe=(0,Q.useMemo)(()=>({input:P.chat.toolInput,output:P.chat.toolOutput,noOutput:P.chat.noOutput}),[P.chat.toolInput,P.chat.toolOutput,P.chat.noOutput]),me=(0,Q.useMemo)(()=>({thoughts:P.chat.thoughts,thoughtsStreaming:P.chat.thoughtsStreaming,workLogTitle:P.chat.workLogTitle,workLogRunning:P.chat.workLogRunning,workLogComplete:P.chat.workLogComplete,workLogPartial:P.chat.workLogPartial,workLogFailed:P.chat.workLogFailed,searchedWeb:P.chat.stepSearchedWeb,searchedMemory:P.chat.stepSearchedMemory,searchedCode:P.chat.stepSearchedCode,searched:P.chat.stepSearched,readFile:P.chat.stepReadFile,stepDetails:P.chat.stepDetails,runCommand:P.chat.stepRunCommand,listDirectory:P.chat.stepListDirectory,writeFile:P.chat.stepWriteFile,editFile:P.chat.stepEditFile,openUrl:P.chat.stepOpenUrl,fetchUrl:P.chat.stepFetchUrl,unknownTool:P.chat.stepUnknownTool,rawThinking:P.chat.rawThinking,toolError:P.chat.toolError,toolActivity:P.chat.toolActivity,memoryActivity:P.chat.memoryActivity}),[P.chat.thoughts,P.chat.thoughtsStreaming,P.chat.workLogTitle,P.chat.workLogRunning,P.chat.workLogComplete,P.chat.workLogPartial,P.chat.workLogFailed,P.chat.stepSearchedWeb,P.chat.stepSearchedMemory,P.chat.stepSearchedCode,P.chat.stepSearched,P.chat.stepReadFile,P.chat.stepDetails,P.chat.stepRunCommand,P.chat.stepListDirectory,P.chat.stepWriteFile,P.chat.stepEditFile,P.chat.stepOpenUrl,P.chat.stepFetchUrl,P.chat.stepUnknownTool,P.chat.rawThinking,P.chat.toolError,P.chat.toolActivity,P.chat.memoryActivity]),J=(0,Q.useMemo)(()=>({ing:P.chat.stepsClusterIng}),[P.chat.stepsClusterIng]),he=(0,Q.useMemo)(()=>P.chat.toolCard,[P.chat.toolCard]),ge=l===`off`,_e=(0,Q.useMemo)(()=>B?X_({message:M,isStreaming:s,reasoningLevel:l,personal:t}):null,[B,s,M,l,t]),ve=(0,Q.useMemo)(()=>{if(!_e)return(M.content??[]).filter(e=>e.type!==`image`);if(t)return _e.answerContent;if(!ge&&j)return(M.content??[]).filter(e=>e.type!==`image`);let e=new Set(_e.answerContent);return(M.content??[]).filter(t=>e.has(t)||t.type===`tool_use`&&(t.status===`error`||t.activity?.status===`failed`))},[_e,M.content,t,ge,j]),ye=(0,Q.useMemo)(()=>_e?_e.attachments:M.attachments,[_e,M.attachments]),be=B&&!t&&!ge&&j,Se=ty({message:M,isStreaming:s,enabled:be,items:_e?.workLog.items??[],durationMs:M.completedAt==null?void 0:_e?.workLog.durationMs}),we=(0,Q.useMemo)(()=>be?new Set(_e?.workLog.items):void 0,[be,_e]),Ee=(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]),De=!!(_e?.workLog.active||_e?.workLog.items.length),ke=!!_e?.answer.started,Ae=ge||B&&(De||ke)?null:c,je=!ge&&!!M.content?.some(e=>e.type===`thinking`&&e.streaming),Me=B?!!_e?.answer.showStreamingCursor:s,Ne=t&&B&&s&&!_e?.answer.started&&!ye?.length,Pe=s&&!je&&(!B||!De&&!ke),Fe=!!Ae?.message||Pe,Ie=B&&!T&&!s&&!D,Le=B&&s&&!T&&!D&&ke,Re=(0,Q.useMemo)(()=>Ie?Km(M.content??[]):``,[Ie,M]),ze=(0,Q.useMemo)(()=>Ie&&Re?Jm(M.content??[]):``,[Ie,Re,M]),Be=(0,Q.useMemo)(()=>Ie&&Re?V(Re):``,[Ie,Re]),Ve=(0,Q.useMemo)(()=>({source:{type:`chat-message`,id:`${i??`chat`}:${M.timestamp??u??Re.length}`,title:Be.split(`
|
|
59
|
+
`)[0]?.slice(0,48)||P.chat.messageReadAloudTitle,href:i?`#/chat/${encodeURIComponent(i)}`:void 0,targetId:u==null?void 0:`chat-message-${u}`},text:Be,language:R(Be,N)}),[Re.length,N,P.chat.messageReadAloudTitle,M.timestamp,u,i,Be]),He=(0,Q.useMemo)(()=>{if(!z)return``;if(M.userTurnDocument){let e=new Map(M.contextRefs?.flatMap(e=>e.refId?[[e.refId,e.title]]:[])??[]);return xn(M.userTurnDocument,t=>e.get(t))}return Wn(M.content)},[z,M.content,M.contextRefs,M.userTurnDocument]),[Ue,We]=(0,Q.useState)(null),[Ge,Ke]=(0,Q.useState)(!1),[qe,Je]=(0,Q.useState)(null),[Ye,Ze]=(0,Q.useState)(null),[Qe,$e]=(0,Q.useState)(!1),[et,tt]=(0,Q.useState)(null),[nt,rt]=(0,Q.useState)(!1),[it,at]=(0,Q.useState)(!1),[ot,st]=(0,Q.useState)(!1),[ct,lt]=(0,Q.useState)(!1),[ut,dt]=(0,Q.useState)(null),[ft,pt]=(0,Q.useState)([]),[mt,ht]=(0,Q.useState)(!1),[gt,_t]=(0,Q.useState)(!1),[vt,yt]=(0,Q.useState)(null),[bt,xt]=(0,Q.useState)(!1),[St,wt]=(0,Q.useState)(!1),Tt=(0,Q.useRef)(null),Et=(0,Q.useCallback)((e,t)=>{let n=Wm(e,t);n&&yt(n)},[]),Dt=(0,Q.useCallback)(()=>{!i||!M.renderKey||Sn.getState().completeProgressiveRender(i,M.renderKey)},[M.renderKey,i]),Ot=(0,Q.useCallback)(()=>{ze&&Oi(ze).then(e=>{e&&(We(`plain`),window.setTimeout(()=>We(e=>e===`plain`?null:e),2e3))})},[ze]),kt=(0,Q.useCallback)(()=>{Re&&Oi(Re).then(e=>{e&&(We(`markdown`),window.setTimeout(()=>We(e=>e===`markdown`?null:e),2e3))})},[Re]),At=(0,Q.useCallback)(()=>{!Re||!b||Ye||(Ze(`create-note`),Promise.resolve(b(Re)).then(()=>{Je(`create-note`),window.setTimeout(()=>Je(e=>e===`create-note`?null:e),2e3)}).catch(()=>void 0).finally(()=>Ze(null)))},[Ye,Re,b]),Mt=(0,Q.useCallback)(()=>{!Re||!x||Ye||(Ze(`save-source-note`),Promise.resolve(x(Re)).then(()=>{Je(`save-source-note`),window.setTimeout(()=>Je(e=>e===`save-source-note`?null:e),2e3)}).catch(()=>void 0).finally(()=>Ze(null)))},[Ye,Re,x]),Nt=(0,Q.useCallback)(()=>{!ze&&!Re||!C||Ye||(Ze(`extract-task`),Promise.resolve(C(ze||Re)).then(()=>{Je(`extract-task`),window.setTimeout(()=>Je(e=>e===`extract-task`?null:e),2e3)}).catch(()=>void 0).finally(()=>Ze(null)))},[Ye,Re,ze,C]),Ft=(0,Q.useCallback)(()=>{He&&Oi(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||it||(at(!0),rt(!0),st(!1),y(g(`/api/turns/${encodeURIComponent(M.turnId)}/execution-context/feedback`),{method:`POST`,body:JSON.stringify({rating:e===`helpful`?`helpful`:`irrelevant`,reason:t})}).then(()=>{tt(e),dt(t??null),lt(!1)}).catch(()=>st(!0)).finally(()=>at(!1)))},[M.turnId,it]),Rt=(0,Q.useCallback)(()=>{ut&&lm(P.chat.messageFeedbackRepairPrompts[ut])},[P.chat.messageFeedbackRepairPrompts,ut]),zt=(0,Q.useCallback)(()=>{!M.turnId||nt||it||(at(!0),y(g(`/api/turns/${encodeURIComponent(M.turnId)}/execution-context`)).then(e=>{pt(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(()=>{rt(!0),at(!1)}))},[M.turnId,it,nt]),Bt=(0,Q.useCallback)(()=>{u==null||!f||_t(!0)},[u,f]),Vt=(0,Q.useCallback)(()=>{u==null||!f||(f(u),_t(!1))},[u,f]),Ht=(0,Q.useCallback)(()=>{_t(!1)},[]);(0,Q.useLayoutEffect)(()=>{if(!z)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()},[z,ve,He]),(0,Q.useLayoutEffect)(()=>{xt(!1)},[z,He]);let Ut=_||!h,Gt=_e&&Qv(_e,j)&&(_e.workLog.active||_e.workLog.items.length>0)?(0,Z.jsx)(r_,{workLog:_e.workLog,pendingStatus:M.pendingResponseStatus,toolLabels:pe,stepLabels:me,clusterLabels:J,cardLabels:he,conversationId:i,simplified:!t,personal:t,surfacesOnly:!t,answerStarted:_e.answer.started}):null;return(0,Z.jsx)(xd.Provider,{value:Sd(_e?.deliveries??[]),children:(0,Z.jsxs)(`article`,{className:Y(`group/msg flex w-full min-w-0`,z?`justify-end`:`justify-start`,H&&`xopc-chat-user-message-enter`),children:[(0,Z.jsxs)(`div`,{className:Y(`min-w-0`,z?`flex w-full max-w-[min(78%,var(--max-width-chat-user))] flex-col items-end`:`w-full max-w-[var(--max-width-chat-reading)]`,T&&`max-w-full`),children:[(0,Z.jsx)(`span`,{className:`sr-only`,children:de}),n?(0,Z.jsx)(ay,{trigger:n}):null,z&&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&&!De?(0,Z.jsx)(`span`,{className:`text-fg-subtle`,title:Ae.detail??``,children:Ae.message}):null,Pe&&!Ae?.message?(0,Z.jsx)(`span`,{className:`text-fg-subtle`,children:P.chat.thinkingLabel}):null]}):null,!z&&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&&!De?(0,Z.jsx)(`span`,{className:`text-fg-subtle`,title:Ae.detail??``,children:Ae.message}):null,Pe&&!Ae?.message?(0,Z.jsx)(`span`,{className:`text-fg-subtle`,children:P.chat.thinkingLabel}):null]}):null,(0,Z.jsx)(`div`,{dir:z?`auto`:void 0,className:Y(`min-w-0 text-fg`,z&&`chat-user-message`,E===`compact`?`text-sm leading-relaxed`:z?`text-[0.9375rem] leading-[1.6667]`:`text-base leading-[1.6875]`,z&&`w-fit max-w-full rounded-2xl bg-surface-hover/80 px-4 py-3 text-left dark:bg-surface-hover/50`,Ne&&`bg-transparent p-0`),children:(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[Ne?(0,Z.jsx)(`div`,{className:`xopc-personal-thinking`,role:`status`,"aria-label":P.chat.thinkingLabel,children:(0,Z.jsxs)(`span`,{className:`xopc-personal-thinking-dots`,"aria-hidden":`true`,children:[(0,Z.jsx)(`i`,{}),(0,Z.jsx)(`i`,{}),(0,Z.jsx)(`i`,{})]})}):null,t?Gt:null,(ve?.length??0)>0?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{ref:z?Tt:Se.contentRef,"data-chat-find-text":!0,className:Y(`relative min-w-0`,`flex flex-col gap-3`,z&&!bt&&`overflow-hidden`),style:z&&!bt?{maxHeight:`calc(10lh)`}:void 0,children:[Se.summary,(0,Z.jsx)(Jh,{taskRunId:M.taskResultDelivery?.taskRunId,content:ve,isUser:z,isAssistantMessageStreaming:B&&s,imagePreviewLabel:P.chat.attachmentPreviewImage,onImagePreview:Et,conversationId:i,workspaceConversationId:a,projectId:o,progressiveRender:!!M.progressiveRender,onProgressiveRenderComplete:Dt,userTurnDocument:M.userTurnDocument,contextRefs:M.contextRefs,responseRunId:B?M.turnId:void 0,immediateFirstCommit:!0,processItems:we,processCollapsed:Se.collapsed,renderActivity:!t&&_e?(e,t)=>{let n=s&&(t||e.some(e=>e.type===`tool_use`&&e.status===`running`)),r=N_(e);return(0,Z.jsx)(r_,{workLog:{items:e,active:n,status:n?`running`:e.some(e=>e.type===`tool_use`&&(e.status===`error`||e.activity?.status===`failed`))?`failed`:`completed`,compact:!1,expandedByDefault:l===`stream`&&n,startedAt:r.startedAt,durationMs:r.durationMs},toolLabels:pe,stepLabels:me,clusterLabels:J,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]}),z&&St?(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:()=>xt(e=>!e),"aria-expanded":bt,children:[bt?(0,Z.jsx)(oe,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(ie,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:bt?P.chat.userMessageCollapse:P.chat.userMessageExpand})]}):null]}):null,t?null:Gt,!t&&_e&&!_e.answer.started&&s&&!ve.some(e=>e.type===`thinking`||e.type===`tool_use`)?(0,Z.jsx)(r_,{workLog:{items:[],active:!0,status:`running`,compact:!0,expandedByDefault:!1},pendingStatus:M.pendingResponseStatus,toolLabels:pe,stepLabels:me,clusterLabels:J,cardLabels:he,conversationId:i}):null,!t&&!z&&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:Hs(t.deliveryId.replace(/^reply:/,``),e.sourceId),expectedVersion:Us(t),title:e.title}}}))},children:[N===`zh`?`询问:`:`Ask about: `,e.title]},e.sourceId))]}):null,_e?(0,Z.jsx)(Yv,{view:_e,authToken:r,conversationId:a??i,projectId:o,sourcesLabel:P.chat.searchSourcesHeading.replace(`{{count}}`,String(_e.sources.length))}):null,z&&M.sourceDevice?(0,Z.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[N===`zh`?`来自 `:`From `,M.sourceDevice.name]}):null,z&&Ee?.length?(0,Z.jsx)(cy,{refs:Ee,groupLabel:P.chat.commandPalette.contextLabel,noteLabel:P.chat.commandPalette.notesSection,fileLabel:P.chat.atMention.files,folderLabel:P.chat.atMention.folders,sessionLabel:P.chat.atMention.chats,browserTabLabel:P.chat.atMention.browserTabs,mcpResourceLabel:P.chat.atMention.mcpResources,truncatedLabel:P.chat.commandPalette.contextTruncated,showMoreLabel:P.chat.contextReferencesMore,showLessLabel:P.chat.contextReferencesLess,onOpen:e=>fe(e.sourceId)}):null,z&&ye?.length?(0,Z.jsx)(Vm,{attachments:ye,authToken:r,conversationId:i,workspaceConversationId:a,layout:`user`,centerUserVoiceRow:He.length===0}):null]})}),G?(0,Z.jsxs)(`div`,{"data-delivery-status":K,role:te?`alert`:`status`,"aria-live":`polite`,"aria-hidden":se&&!te?!0:void 0,className:Y(`mt-1 flex min-h-5 items-center justify-end gap-1.5 pe-1 text-xs transition-opacity duration-[120ms] ease-out motion-reduce:transition-none`,te?`text-danger`:`text-fg-subtle`,se&&!te&&`opacity-0`),children:[te?(0,Z.jsx)(q,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}):null,(0,Z.jsx)(`span`,{children:te?P.chat.userMessageSendFailed:le&&W?P.chat.userMessageWaitingForNetwork:P.chat.userMessageSending}),te&&p&&u!=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:()=>p(u),children:P.chat.userMessageRetry}):null]}):null,!z&&M.personalProvenance&&!s&&(0,Z.jsx)(Dm,{provenance:M.personalProvenance}),z&&!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:[p&&u!=null&&M.deliveryStatus!==`failed`?(0,Z.jsxs)(`button`,{type:`button`,className:Y(vy,Ut&&`opacity-40`),onClick:()=>p(u),disabled:Ut,title:_?P.chat.userMessageActionsWait:h?P.chat.userMessageRetry:P.chat.userMessageRetryDisabledHint,"aria-label":P.chat.userMessageRetry,children:[(0,Z.jsx)(Pt,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`max-w-[4.5rem] truncate sm:max-w-none`,children:P.chat.userMessageRetry})]}):null,(0,Z.jsx)(`button`,{type:`button`,className:Y(vy,`size-8 px-0`),onClick:()=>{if(O&&u!=null){O(M,u);return}lm(He,Kn(M.attachments))},disabled:!He&&!M.attachments?.length&&!M.contextRefs?.length||!k,title:k?_?P.chat.userMessageStopAndEdit:P.chat.userMessageEdit:P.chat.userMessageEditDisabledHint,"aria-label":P.chat.userMessageEdit,children:(0,Z.jsx)(jt,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})}),(0,Z.jsx)(`button`,{type:`button`,className:Y(vy,`size-8 px-0`),onClick:Ft,disabled:!He,title:Ue===`user`?P.chat.messageCopied:P.chat.userMessageCopy,"aria-label":Ue===`user`?P.chat.messageCopied:P.chat.userMessageCopy,children:Ue===`user`?(0,Z.jsx)(re,{className:`size-3.5 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(xe,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})}),f&&u!=null&&!_?(0,Z.jsx)(`button`,{type:`button`,className:Y(vy,`size-8 px-0 hover:text-red-500 dark:hover:text-red-400`),onClick:Bt,title:P.chat.userMessageDelete,"aria-label":P.chat.userMessageDelete,children:(0,Z.jsx)(Wt,{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)(j_,{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||ct||ot)&&`pointer-events-auto opacity-100`),children:[(0,Z.jsx)(M_,{label:Ue===`plain`?P.chat.messageCopied:P.chat.messageCopyPlainText,children:(0,Z.jsx)(`button`,{type:`button`,className:gy,onClick:Ot,disabled:!ze,"aria-label":Ue===`plain`?P.chat.messageCopied:P.chat.messageCopyPlainText,children:Ue===`plain`?(0,Z.jsx)(re,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(xe,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})})}),(0,Z.jsx)(M_,{label:P.chat.messageReadAloud,children:(0,Z.jsx)(L,{input:Ve,labels:{read:P.chat.messageReadAloud,preparing:P.chat.messageReadAloudPreparing,pause:P.chat.messageReadAloudPause,resume:P.chat.messageReadAloudResume,retry:P.chat.messageReadAloudRetry},hideNativeTitle:!0})}),(0,Z.jsxs)(Si,{open:Ge,onOpenChange:e=>{Ke(e),e&&zt()},children:[(0,Z.jsx)(M_,{label:P.chat.messageMoreActions,children:(0,Z.jsx)(wi,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:gy,"aria-label":P.chat.messageMoreActions,children:(0,Z.jsx)(Ce,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})})})}),(0,Z.jsx)(bi,{children:(0,Z.jsxs)(xi,{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)(Ci,{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:kt,children:[Ue===`markdown`?(0,Z.jsx)(re,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(Te,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),Ue===`markdown`?P.chat.messageCopied:P.chat.messageCopyMarkdown]})}),w&&M.turnId?(0,Z.jsx)(Ci,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:It,disabled:Qe,children:[(0,Z.jsx)(Ss,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),Qe?P.chat.messageForkCreating:P.chat.messageForkFromHere]})}):null,b?(0,Z.jsx)(Ci,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:At,disabled:Ye!==null,children:[qe===`create-note`?(0,Z.jsx)(re,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(ys,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),qe===`create-note`?P.chat.messageSavedToNote:P.chat.messageSaveToNote]})}):null,A&&i&&M.timestamp?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`my-1 border-t border-edge-subtle`,role:`separator`}),(0,Z.jsx)(Ci,{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:it,"aria-pressed":et===`helpful`,children:[(0,Z.jsx)(ee,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),P.chat.messageHelpful]})}),(0,Z.jsx)(Ci,{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(e=>!e),disabled:it,"aria-pressed":et===`not_helpful`,children:[(0,Z.jsx)(U,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),P.chat.messageNotHelpful]})})]}):null,ot?(0,Z.jsx)(`p`,{className:`px-2.5 py-1 text-xs text-danger`,role:`status`,children:P.chat.messageFeedbackUnavailable}):null,ft.length>0?(0,Z.jsx)(Ci,{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:()=>ht(e=>!e),children:[(0,Z.jsx)(hs,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),P.chat.messageWhyThisAnswer]})}):null,x?(0,Z.jsx)(Ci,{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:Mt,disabled:!Re||Ye!==null,children:[qe===`save-source-note`?(0,Z.jsx)(re,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(Oe,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),qe===`save-source-note`?P.chat.messageSavedToSourceNote:P.chat.messageSaveToSourceNote]})}):null,C?(0,Z.jsx)(Ci,{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:!ze&&!Re||Ye!==null,children:[qe===`extract-task`?(0,Z.jsx)(re,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(Xe,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),qe===`extract-task`?P.chat.messageTaskExtracted:P.chat.messageExtractTask]})}):null]})})]})]})}):null,Ie&&ft.length>0?(0,Z.jsx)(dy,{open:mt,onOpenChange:ht,items:ft,labels:{title:P.chat.messageWhyThisAnswer,hint:P.chat.messageWhyThisAnswerHint,close:P.chat.messageContextClose,itemsSummary:P.chat.messageContextItemsSummary,expandAll:P.chat.messageContextExpandAll,collapseAll:P.chat.messageContextCollapseAll,groupSummary:P.chat.messageContextGroupSummary,origins:P.chat.messageContextOrigins}}):null,Ie&&ct?(0,Z.jsxs)(`div`,{className:`mt-2 w-full max-w-xl rounded-xl border border-edge-subtle bg-surface-panel p-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:P.chat.messageFeedbackReasonTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:P.chat.messageFeedbackReasonHint}),(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:_y.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:it,onClick:()=>Lt(`not_helpful`,e),children:P.chat.messageFeedbackReasons[e]},e))})]}):null,Ie&&et===`not_helpful`&&ut?(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)(Pt,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),P.chat.messageFeedbackRepair]}):null]}),z&&f&&u!=null&&!T?(0,Z.jsx)(Wa,{open:gt,title:P.chat.userMessageDeleteConfirmTitle,description:P.chat.userMessageDeleteConfirm,confirmLabel:P.chat.userMessageDeleteOk,cancelLabel:P.chat.userMessageDeleteCancel,destructive:!0,onConfirm:Vt,onCancel:Ht}):null,(0,Z.jsx)(Co,{open:vt!==null,attachment:vt,images:(M.content??[]).flatMap((e,t)=>{if(e.type!==`image`)return[];let n=Wm(e,t);return n?[n]:[]}),onAttachmentChange:yt,authToken:r,conversationId:i,onClose:()=>yt(null)})]})})}),Sy=(0,Q.memo)(function(e){let t=(0,X.c)(3),n=oh(e.conversationId,e.message.renderKey)??e.message,r;return t[0]!==n||t[1]!==e?(r=(0,Z.jsx)(xy,{...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 wy=new Map;function Ty(e,t=`time`){let n=`${e??`default`}:${t}`,r=wy.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}),wy.set(n,r)),r}function Ey(e){return e?Ty().format(e):``}var Dy=1800*1e3;function Oy(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function ky(e,t){return e?!t||!Oy(new Date(e),new Date(t))||e-t>=Dy:!1}function Ay(e,t,n){let r=new Date(e),i=new Date(t),a=new Date(i);return a.setDate(i.getDate()-1),`${Oy(r,i)?n===`zh`?`今天`:`Today`:Oy(r,a)?n===`zh`?`昨天`:`Yesterday`:Ty(n,r.getFullYear()===i.getFullYear()?`date`:`year`).format(r)} ${Ty(n).format(r)}`}var jy=0,My=1,Ny=2,Py=4;function Fy(e){return()=>e}function Iy(e){e()}function Ly(e,t){return n=>e(t(n))}function Ry(e,t){return()=>e(t)}function zy(e,t){return n=>e(t,n)}function By(e){return e!==void 0}function Vy(...e){return()=>{e.map(Iy)}}function Hy(){}function Uy(e,t){return t(e),e}function Wy(e,t){return t(e)}function Gy(...e){return e}function Ky(e,t){return e(My,t)}function qy(e,t){e(jy,t)}function Jy(e){e(Ny)}function Yy(e){return e(Py)}function Xy(e,t){return Ky(e,zy(t,jy))}function Zy(e,t){let n=e(My,e=>{n(),t(e)});return n}function Qy(e){let t,n;return r=>i=>{t=i,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function $y(e,t){return e===t}function eb(e=$y){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function tb(e){return t=>n=>{e(n)&&t(n)}}function nb(e){return t=>Ly(t,e)}function rb(e){return t=>()=>{t(e)}}function $(e,...t){let n=cb(...t);return((t,r)=>{switch(t){case Ny:Jy(e);return;case My:return Ky(e,n(r))}})}function ib(e,t){return n=>r=>{n(t=e(t,r))}}function ab(e){return t=>n=>{e>0?e--:t(n)}}function ob(e){let t=null,n;return r=>i=>{t=i,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function sb(...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;Ky(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 cb(...e){return t=>e.reduceRight(Wy,t)}function lb(e){let t,n,r=()=>t?.();return function(i,a){switch(i){case My:return a?n===a?void 0:(r(),n=a,t=Ky(e,a),t):(r(),Hy);case Ny:r(),n=null;return}}}function ub(e){let t=e,n=fb();return((e,r)=>{switch(e){case jy:t=r;break;case My:r(t);break;case Py:return t}return n(e,r)})}function db(e,t){return Uy(ub(t),t=>Xy(e,t))}function fb(){let e=[];return((t,n)=>{switch(t){case jy:e.slice().forEach(e=>{e(n)});return;case Ny:e.splice(0);return;case My:return e.push(n),()=>{let t=e.indexOf(n);t>-1&&e.splice(t,1)}}})}function pb(e){return Uy(fb(),t=>Xy(e,t))}var mb={singleton:!0};function hb(e,t=[],n=mb){let{singleton:r}=n;return{constructor:e,dependencies:t,id:gb(),singleton:r}}var gb=()=>Symbol(`id`);function _b(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 vb(...e){let t=fb(),n=Array.from({length:e.length}),r=0,i=2**e.length-1;return e.forEach((e,a)=>{let o=2**a;Ky(e,e=>{n[a]=e,r|=o,r===i&&qy(t,n)})}),function(e,a){switch(e){case Ny:Jy(t);return;case My:return r===i&&a(n),Ky(t,a)}}}function yb(e,t=$y){return $(e,eb(t))}function bb(...e){return function(t,n){switch(t){case Ny:return;case My:return Vy(...e.map(e=>Ky(e,n)))}}}var xb={DEBUG:0,INFO:1,WARN:2,ERROR:3},Sb={[xb.DEBUG]:`debug`,[xb.ERROR]:`error`,[xb.INFO]:`log`,[xb.WARN]:`warn`},Cb=()=>typeof globalThis>`u`?window:globalThis,wb=hb(()=>{let e=ub(xb.ERROR);return{log:ub((t,n,r=xb.INFO)=>{r>=(Cb().VIRTUOSO_LOG_LEVEL??Yy(e))&&console[Sb[r]](`%creact-virtuoso: %c%s %o`,`color: #0253b3; font-weight: bold`,`color: initial`,t,n)}),logLevel:e}},[],{singleton:!0});function Tb(e){return`self`in e?e.document.documentElement:e}function Eb(e){let t=Tb(e);return t.ownerDocument.defaultView.getComputedStyle(t).direction===`rtl`}function Db(e,t){return Eb(e)?-t:t}function Ob(e,t){return Eb(e)?-t:t}function kb(e,t,n){return Ab(e,t,n).callbackRef}function Ab(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 jb(e,t,n,r,i,a,o,s,c){return Ab(Q.useCallback(n=>{let c=Mb(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?Nb(`column-gap`,getComputedStyle(n).columnGap,i):Nb(`row-gap`,getComputedStyle(n).rowGap,i)),c!==null&&e(c)},[e,t,i,a,o,r,s]),n,c)}function Mb(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},xb.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 Nb(e,t,n){return t!==`normal`&&t?.endsWith(`px`)!==!0&&n(`${e} was not resolved to pixel value correctly`,t,xb.WARN),t===`normal`?0:parseInt(t??`0`,10)}var Pb=typeof document>`u`?Q.useEffect:Q.useLayoutEffect;function Fb(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}=Ab(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 Ib=hb(()=>{let e=fb(),t=fb(),n=ub(0),r=fb(),i=fb(),a=ub(0),o=fb(),s=fb(),c=ub(0),l=ub(0),u=ub(0),d=ub(0),f=fb(),p=fb(),m=ub(!1),h=ub(!1),g=ub(!1);return Xy($(e,nb(({scrollTop:e})=>e)),t),Xy($(e,nb(({scrollHeight:e})=>e)),s),Xy(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}),Lb={lvl:0};function Rb(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 zb(e){return e===Lb}function Bb(e,t){if(!zb(e))return t===e.k?e.v:t<e.k?Bb(e.l,t):Bb(e.r,t)}function Vb(e,t,n=`k`){if(zb(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){let r=Vb(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return Vb(e.l,t,n)}function Hb(e,t,n){return zb(e)?$b(t,n,1):t===e.k?Yb(e,{k:t,v:n}):t<e.k?ex(Yb(e,{l:Hb(e.l,t,n)})):ex(Yb(e,{r:Hb(e.r,t,n)}))}function Ub(){return Lb}function Wb(e,t,n){if(zb(e))return[];let r=Vb(e,t)[0];return rx(qb(e,r,n))}function Gb(e,t){if(zb(e))return Lb;let{k:n,l:r,r:i}=e;if(t===n){if(zb(r))return i;if(zb(i))return r;let[t,n]=Qb(r);return Jb(Yb(e,{k:t,l:Xb(r),v:n}))}return Jb(t<n?Yb(e,{l:Gb(r,t)}):Yb(e,{r:Gb(i,t)}))}function Kb(e){return zb(e)?[]:[...Kb(e.l),{k:e.k,v:e.v},...Kb(e.r)]}function qb(e,t,n){if(zb(e))return[];let{k:r,l:i,r:a,v:o}=e,s=[];return r>t&&(s=s.concat(qb(i,t,n))),r>=t&&r<=n&&s.push({k:r,v:o}),r<=n&&(s=s.concat(qb(a,t,n))),s}function Jb(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(Zb(t))return tx(Yb(e,{lvl:n-1}));if(!zb(t)&&!zb(t.r))return Yb(t.r,{l:Yb(t,{r:t.r.l}),lvl:n,r:Yb(e,{l:t.r.r,lvl:n-1})});throw Error(`Unexpected empty nodes`)}if(Zb(e))return nx(Yb(e,{lvl:n-1}));if(!zb(r)&&!zb(r.l)){let t=r.l,i=Zb(t)?r.lvl-1:r.lvl;return Yb(t,{l:Yb(e,{lvl:n-1,r:t.l}),lvl:t.lvl+1,r:nx(Yb(r,{l:t.r,lvl:i}))})}throw Error(`Unexpected empty nodes`)}function Yb(e,t){return $b(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 Xb(e){return zb(e.r)?e.l:Jb(Yb(e,{r:Xb(e.r)}))}function Zb(e){return zb(e)||e.lvl>e.r.lvl}function Qb(e){return zb(e.r)?[e.k,e.v]:Qb(e.r)}function $b(e,t,n,r=Lb,i=Lb){return{k:e,l:r,lvl:n,r:i,v:t}}function ex(e){return nx(tx(e))}function tx(e){let{l:t}=e;return!zb(t)&&t.lvl===e.lvl?Yb(t,{r:Yb(e,{l:t.r})}):e}function nx(e){let{lvl:t,r:n}=e;return!zb(n)&&!zb(n.r)&&n.lvl===t&&n.r.lvl===t?Yb(n,{l:Yb(e,{r:n.l}),lvl:t+1}):e}function rx(e){return Rb(e,({k:e,v:t})=>({index:e,value:t}))}function ix(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function ax(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}var ox=hb(()=>({recalcInProgress:ub(!1)}),[],{singleton:!0});function sx(e,t,n){return e[cx(e,t,n)]}function cx(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 lx(e,t,n,r){let i=cx(e,t,r),a=cx(e,n,r,i);return e.slice(i,a+1)}function ux(e,t){return Math.round(e.getBoundingClientRect()[t])}function dx(e){return!zb(e.groupOffsetTree)}function fx({index:e},t){return t===e?0:t<e?-1:1}function px(){return{groupIndices:[],groupOffsetTree:Ub(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Ub()}}function mx(e,t){let n=zb(e)?0:1/0;for(let r of t){let{endIndex:t,size:i,startIndex:a}=r;if(n=Math.min(n,a),zb(e)){e=Hb(e,0,i);continue}let o=Wb(e,a-1,t+1);if(o.some(Ex(r)))continue;let s=!1,c=!1;for(let{end:n,start:r,value:a}of o)s?(t>=r||i===a)&&(e=Gb(e,r)):(c=a!==i,s=!0),n>t&&t>=r&&a!==i&&(e=Hb(e,t+1,a));c&&(e=Hb(e,a,i))}return[e,n]}function hx(e){return e.groupIndex!==void 0}function gx({offset:e},t){return t===e?0:t<e?-1:1}function _x(e,t,n){if(t.length===0)return 0;let{index:r,offset:i,size:a}=sx(t,e,fx),o=e-r,s=a*o+(o-1)*n+i;return s>0?s+n:s}function vx(e,t){if(!dx(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function yx(e,t,n){if(hx(e))return t.groupIndices[e.groupIndex]+1;let r=vx(e.index===`LAST`?n:e.index,t);return r=Math.max(0,Math.min(n,r)),r}function bx(e,t,n,r=0){return r>0&&(t=Math.max(t,sx(e,r,fx).offset)),Rb(lx(e,t,n,gx),Tx)}function xx(e,[t,n,r,i]){t.length>0&&r(`received item sizes`,t,xb.DEBUG);let a=e.sizeTree,o=a,s=0;if(n.length>0&&zb(a)&&t.length===2){let e=t[0].size,r=t[1].size;o=n.reduce((t,n)=>Hb(Hb(t,n,e),n+1,r),o)}else[o,s]=mx(o,t);if(o===a)return e;let{lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d}=wx(e.offsetTree,s,o,i);return{groupIndices:n,groupOffsetTree:n.reduce((e,t)=>Hb(e,t,_x(t,d,i)),Ub()),lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d,sizeTree:o}}function Sx(e){return Kb(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 wx(e,t,n,r){let i=e,a=0,o=0,s=0,c=0;if(t===0)i=[];else{c=cx(i,t-1,fx),s=i[c].offset;let e=Vb(n,t-1);a=e[0],o=e[1],i.length&&i[c].size===Vb(n,t)[1]&&--c,i=i.slice(0,c+1)}for(let{start:e,value:c}of Wb(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 Tx(e){return{index:e.index,value:e}}function Ex(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`},Ox=hb(([{log:e},{recalcInProgress:t}])=>{let n=fb(),r=fb(),i=db(r,0),a=fb(),o=fb(),s=ub(0),c=ub([]),l=ub(void 0),u=ub(void 0),d=ub(void 0),f=ub(void 0),p=ub((e,t)=>ux(e,Dx[t])),m=ub(void 0),h=ub(0),g=px(),_=db($(n,sb(c,e,h),ib(xx,g),eb()),g),v=db($(c,eb(),ib((e,t)=>({current:t,prev:e.current}),{current:[],prev:[]}),nb(({prev:e})=>e)),[]);Xy($(c,tb(e=>e.length>0),sb(_,h),nb(([e,t,n])=>{let r=e.reduce((e,r,i)=>Hb(e,r,_x(r,t.offsetTree,n)||i),Ub());return{...t,groupIndices:e,groupOffsetTree:r}})),_),Xy($(r,sb(_),tb(([e,{lastIndex:t}])=>e<t),nb(([e,{lastIndex:t,lastSize:n}])=>[{endIndex:t,size:n,startIndex:e}])),n),Xy(l,u);let y=db($(l,nb(e=>e===void 0)),!0);Xy($(u,tb(e=>e!==void 0&&zb(Yy(_).sizeTree)),nb(e=>{let t=Yy(d),n=Yy(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),Xy($(f,tb(e=>e!==void 0&&e.length>0&&zb(Yy(_).sizeTree)),nb(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),Xy($(c,sb(d,u),tb(([,e,t])=>e!==void 0&&t!==void 0),nb(([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=pb($(n,sb(_),ib(({sizes:e},[t,n])=>({changed:n!==e,sizes:n}),{changed:!1,sizes:g}),nb(e=>e.changed)));Ky($(s,ib((e,t)=>({diff:e.prev-t,prev:t}),{diff:0,prev:0}),nb(e=>e.diff)),e=>{let{groupIndices:n}=Yy(_);if(e>0)qy(t,!0),qy(a,e+Cx(e,n));else if(e<0){let t=Yy(v);t.length>0&&(e-=Cx(-e,t)),qy(o,e)}}),Ky($(s,sb(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},xb.ERROR)});let x=pb(a);Xy($(a,sb(_),nb(([e,t])=>{let n=t.groupIndices.length>0,r=[],i=t.lastSize;if(n){let n=Bb(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=Kb(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 Kb(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=pb($(o,sb(_,h),nb(([e,{offsetTree:t},n])=>_x(-e,t,n))));return Xy($(o,sb(_,h),nb(([e,t,n])=>{if(t.groupIndices.length>0){if(zb(t.sizeTree))return t;let r=Ub(),i=Yy(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=Kb(t.sizeTree).reduce((t,{k:n,v:r})=>Hb(t,Math.max(0,n+e),r),r),a!==-e){let n=Bb(t.sizeTree,s);r=Hb(r,0,n);let i=Vb(t.sizeTree,-e+1)[1];r=Hb(r,1,i)}return{...t,sizeTree:r,...wx(t.offsetTree,0,r,n)}}let r=Kb(t.sizeTree).reduce((t,{k:n,v:r})=>Hb(t,Math.max(0,n+e),r),Ub());return{...t,sizeTree:r,...wx(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}},Gy(wb,ox),{singleton:!0});function kx(e){return e.reduce((e,t)=>(e.groupIndices.push(e.totalCount),e.totalCount+=t+1,e),{groupIndices:[],totalCount:0})}var Ax=hb(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:i}])=>{let a=fb(),o=fb(),s=pb($(a,nb(kx)));return Xy($(s,nb(e=>e.totalCount)),n),Xy($(s,nb(e=>e.groupIndices)),e),Xy($(vb(i,t,r),tb(([e,t])=>dx(t)),nb(([e,t,n])=>Vb(t.groupOffsetTree,Math.max(e-n,0),`v`)[0]),eb(),nb(e=>[e])),o),{groupCounts:a,topItemsIndexes:o}},Gy(Ox,Ib)),jx=hb(([{log:e}])=>{let t=ub(!1),n=pb($(t,tb(e=>e),eb()));return Ky(t,t=>{t&&Yy(e)(`props updated`,{},xb.DEBUG)}),{didMount:n,propsReady:t}},Gy(wb),{singleton:!0}),Mx=typeof document<`u`&&`scrollBehavior`in document.documentElement.style;function Nx(e){let t=typeof e==`number`?{index:e}:{...e};return t.align||=`start`,(!t.behavior||!Mx)&&(t.behavior=`auto`),t.offset===void 0&&(t.offset=0),t}var Px=hb(([{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=fb(),m=fb(),h=ub(0),g=null,_=null,v=null;function y(){g!==null&&(g(),g=null),v!==null&&(v(),v=null),_&&=(clearTimeout(_),null),qy(c,!1)}return Xy($(p,sb(n,d,r,h,s,o,f),sb(e,a,i),nb(([[e,n,r,i,a,o,s,l],d,f,h])=>{let b=Nx(e),{align:x,behavior:S,offset:C}=b,w=i-1,T=yx(b,n,w),E=_x(T,n.offsetTree,d)+o;x===`end`?(E+=f+Vb(n.sizeTree,T)[1]-r+h,T===w&&(E+=s)):x===`center`?E+=(f+Vb(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},xb.DEBUG),qy(p,e)):(qy(m,!0),l(`list did not change, scroll successful`,{},xb.DEBUG))};if(y(),S===`smooth`){let e=!1;v=Ky(t,t=>{e||=t}),g=Zy(u,()=>{D(e)})}else g=Zy($(t,Fx(150)),D);return _=setTimeout(()=>{y()},1200),qy(c,!0),l(`scrolling from index to`,{behavior:S,index:T,top:E},xb.DEBUG),{behavior:S,top:E}})),l),{scrollTargetReached:m,scrollToIndex:p,topListHeight:h}},Gy(Ox,Ib,wb),{singleton:!0});function Fx(e){return t=>{let n=setTimeout(()=>{t(!1)},e);return e=>{e&&(t(!0),clearTimeout(n))}}}function Ix(e,t){e===0?t():requestAnimationFrame(()=>{Ix(e-1,t)})}function Lx(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 Rx(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 zx=hb(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:i,scrollToIndex:a},{didMount:o}])=>{let s=ub(!0),c=ub(0),l=ub(!0);return Xy($(o,sb(c),tb(([e,t])=>!Rx(t)),rb(!1)),s),Xy($(o,sb(c),tb(([e,t])=>!Rx(t)),rb(!1)),l),Ky($(vb(t,o),sb(s,n,e,l),tb(([[,e],t,{sizeTree:n},r,i])=>e&&(!zb(n)||By(r))&&!t&&!i),sb(c)),([,e])=>{if(e===void 0){qy(s,!0),qy(l,!0);return}Zy(i,()=>{qy(l,!0)}),Ix(4,()=>{Zy(r,()=>{qy(s,!0)}),qy(a,e)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:c,scrolledToInitialItem:s}},Gy(Ox,Ib,Px,jx),{singleton:!0});function Bx(e,t){return Math.abs(e-t)<1.01}var Vx=`up`,Hx=`down`,Ux=`none`,Wx={atBottom:!1,notAtBottomBecause:`NOT_SHOWING_LAST_ITEM`,state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Gx=0,Kx=hb(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:i,viewportHeight:a}])=>{let o=ub(!1),s=ub(!0),c=fb(),l=fb(),u=ub(4),d=ub(Gx),f=db($(bb($(yb(i),ab(1),rb(!0)),$(yb(i),ab(1),rb(!1),Qy(100))),eb()),!1),p=db($(bb($(n,rb(!0)),$(n,rb(!1),Qy(200))),eb()),!1);Xy($(vb(yb(i),yb(d)),nb(([e,t])=>e<=t),eb()),s),Xy($(s,ob(50)),l);let m=pb($(vb(r,yb(a),yb(t),yb(e),yb(u)),ib((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}},Wx),eb((e,t)=>e!==void 0&&e.atBottom===t.atBottom))),h=db($(r,ib((e,{scrollHeight:t,scrollTop:n,viewportHeight:r})=>{if(!Bx(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}),tb(e=>e.changed),nb(e=>e.jump)),0);Xy($(m,nb(e=>e.atBottom)),o),Xy($(o,ob(50)),c);let g=ub(Hx);Xy($(r,nb(({scrollTop:e})=>e),eb(),ib((e,t)=>Yy(p)?{direction:e.direction,prevScrollTop:t}:{direction:t<e.prevScrollTop?Vx:Hx,prevScrollTop:t},{direction:Hx,prevScrollTop:0}),nb(e=>e.direction)),g),Xy($(r,ob(50),rb(Ux)),g);let _=ub(0);return Xy($(f,tb(e=>!e),rb(0)),_),Xy($(i,ob(100),sb(f),tb(([e,t])=>t),ib(([e,t],[n])=>[t,n],[0,0]),nb(([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:_}},Gy(Ib)),qx=`top`,Jx=`bottom`,Yx=`none`;function Xx(e,t,n){return typeof e==`number`?n===Vx&&t===qx||n===Hx&&t===Jx?e:0:n===Vx?t===qx?e.main:e.reverse:t===Jx?e.main:e.reverse}function Zx(e,t){return typeof e==`number`?e:e[t]??0}var Qx=hb(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:i}])=>{let a=fb(),o=ub(0),s=ub(0),c=ub(0);return{increaseViewportBy:s,listBoundary:a,overscan:c,topListHeight:o,visibleRange:db($(vb(yb(r),yb(i),yb(n),yb(a,ax),yb(c),yb(o),yb(t),yb(e),yb(s)),nb(([e,t,n,[r,i],a,o,s,c,l])=>{let u=e-c,d=o+s,f=Math.max(n-u,0),p=Yx,m=Zx(l,qx),h=Zx(l,Jx);return r-=c,r+=n+s,i+=n+s,i-=c,r>e+d-m&&(p=Vx),i<e-f+t+h&&(p=Hx),p===Yx?null:[Math.max(u-n-Xx(a,qx,p)-m,0),u-f-s+t+Xx(a,Jx,p)+h]}),tb(e=>e!==null),eb(ax)),[0,0])}},Gy(Ib),{singleton:!0});function $x(e,t,n){if(dx(t)){let r=vx(e,t);return[{index:Vb(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 eS={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function tS(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:rS(e,i,a),offsetBottom:m,offsetTop:l,top:p,topItems:rS(t,i,a),topListHeight:t.reduce((e,t)=>t.size+e,0),totalCount:n}}function nS(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=Lx(t,c?l:s),d=c?Math.max(0,Math.min(s,l-u)):s;return tS(Array.from({length:d}).map((e,t)=>({data:a?.[t+u],index:t+u,offset:0,size:0})),[],d,i,n,r)}function rS(e,t,n){if(e.length===0)return[];if(!dx(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=Wb(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 iS(e,t){return e===void 0?0:typeof e==`number`?e:e[t]??0}var aS=hb(([{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=ub([]),g=ub(0),_=fb(),v=ub(0);Xy(a.topItemsIndexes,h);let y=db($(vb(p,m,yb(c,ax),yb(i),yb(r),yb(l),u,yb(h),yb(t),yb(n),yb(v),e,yb(g)),tb(([e,t,,n,,,,,,,,r])=>{let i=r!==void 0&&r.length!==n;return e&&!t&&!i}),nb(([,,[e,t],n,r,i,a,o,s,c,l,u,d])=>{let f=r,{offsetTree:p,sizeTree:m}=f;if(n===0)return{...eS,totalCount:n};if(e===0&&t===0)return d===0?{...eS,totalCount:n}:nS(d,i,r,s,c,u);if(zb(m))return d>0?null:tS($x(Lx(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 Wb(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 tS([],h,n,c,f,s);let g=o.length>0?o[o.length-1]+1:0,_=bx(p,e,t,g);if(_.length===0)return null;let v=n-1,y=Uy([],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=iS(l,qx),x=iS(l,Jx);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=Wb(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=Wb(m,r,r)[0]?.value??t.size;y.push({data:u?.[r],index:r,offset:n,size:e}),n+=e+c}}}return tS(y,h,n,c,f,s)}),tb(e=>e!==null),eb()),eS);Xy($(e,tb(By),nb(e=>e?.length)),i),Xy($(y,nb(e=>e.topListHeight)),d),Xy(d,s),Xy($(y,nb(e=>[e.top,e.bottom])),o),Xy($(y,nb(e=>e.items)),_);let b=pb($(y,tb(({items:e})=>e.length>0),sb(i,e),tb(([{items:e},t])=>e[e.length-1].originalIndex===t-1),nb(([,e,t])=>[e-1,t]),eb(ax),nb(([e])=>e))),x=pb($(y,ob(200),tb(({items:e,topItems:t})=>e.length>0&&e[0].originalIndex===t.length),nb(({items:e})=>e[0].index),eb()));return{endReached:b,initialItemCount:g,itemsRendered:_,listState:y,minOverscanItemCount:v,rangeChanged:pb($(y,tb(({items:e})=>e.length>0),nb(({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}}),eb(ix))),startReached:x,topItemsIndexes:h,...f}},Gy(Ox,Ax,Qx,zx,Px,Kx,jx,ox),{singleton:!0}),oS=hb(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:i}])=>{let a=fb(),o=db($(vb(n,e,r,t,i),nb(([e,t,n,r,i])=>e+t+n+r+i.offsetBottom+i.bottom)),0);return Xy(yb(o),a),{totalListHeight:o,totalListHeightChanged:a}},Gy(Ib,aS),{singleton:!0}),sS=hb(([{viewportHeight:e},{totalListHeight:t}])=>{let n=ub(!1);return{alignToBottom:n,paddingTopAddition:db($(vb(n,e,t),tb(([e])=>e),nb(([,e,t])=>Math.max(0,e-t)),ob(0),eb()),0)}},Gy(Ib,oS),{singleton:!0}),cS=hb(()=>({context:ub(null)})),lS=({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,uS=hb(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:i,headerHeight:a,scrollingInProgress:o,scrollTop:s,viewportHeight:c},{scrollToIndex:l}])=>{let u=fb();return Xy($(u,sb(t,c,n,a,i,r,s),sb(e),nb(([[e,t,n,r,i,a,s,c],l])=>{let{calculateViewLocation:u=lS,done:d,...f}=e,p=yx(e,t,r-1),m=_x(p,t.offsetTree,l)+i+a,h=m+Vb(t.sizeTree,p)[1],g=c+a,_=u({itemBottom:h,itemTop:m,locationParams:f,viewportBottom:c+n-s,viewportTop:g});return _===null?d?.():d&&Zy($(o,tb(e=>!e),ab(Yy(o)?1:2)),d),_}),tb(e=>e!==null)),l),{scrollIntoView:u}},Gy(Ox,Ib,Px,aS,wb),{singleton:!0});function dS(e){return e===!1?!1:e===`smooth`?`smooth`:`auto`}var fS=(e,t)=>typeof e==`function`?dS(e(t)):t&&dS(e),pS=hb(([{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=ub(!1),h=fb(),g=null;function _(e){qy(o,{align:`end`,behavior:e,index:`LAST`})}Ky($(vb($(yb(t),ab(1)),c),sb(yb(m),a,s,d),nb(([[e,t],n,r,i,a])=>{let o=t&&i,s=`auto`;return o&&(s=fS(n,r||a),o&&=s!==!1),{followOutputBehavior:s,shouldFollow:o,totalCount:e}}),tb(({shouldFollow:e})=>e)),({followOutputBehavior:t,totalCount:r})=>{g!==null&&(g(),g=null),Yy(n)===void 0?g=Zy(e,()=>{Yy(u)(`following output to `,{totalCount:r},xb.DEBUG),_(t),g=null}):requestAnimationFrame(()=>{Yy(u)(`following output to `,{totalCount:r},xb.DEBUG),_(t)})});function v(e){let t=Zy(i,t=>{e&&!t.atBottom&&t.notAtBottomBecause===`SIZE_INCREASED`&&g===null&&(Yy(u)(`scrolling to bottom due to increased size`,{},xb.DEBUG),_(`auto`))});setTimeout(t,100)}Ky($(vb(yb(m),t,l),tb(([e,,t])=>e!==!1&&t),ib(({value:e},[,t])=>({refreshed:e===t,value:t}),{refreshed:!1,value:0}),tb(({refreshed:e})=>e),sb(m,t)),([,e])=>{Yy(s)&&v(e!==!1)}),Ky(h,()=>{v(Yy(m)!==!1)}),Ky(vb(yb(m),i),([e,t])=>{e!==!1&&!t.atBottom&&t.notAtBottomBecause===`VIEWPORT_HEIGHT_DECREASING`&&_(`auto`)});let y=ub(null),b=fb();return Xy(bb($(yb(r),nb(e=>e?.length??0)),$(yb(t))),b),Ky($(vb($(b,ab(1)),c),sb(yb(y),s,d,f),nb(([[e,t],n,r,i,a])=>t&&r&&n?.({context:a,totalCount:e,scrollingInProgress:i})),tb(e=>!!e),ob(0)),t=>{g!==null&&(g(),g=null),Yy(n)===void 0?g=Zy(e,()=>{Yy(u)(`scrolling into view`,{}),qy(p,t),g=null}):requestAnimationFrame(()=>{Yy(u)(`scrolling into view`,{}),qy(p,t)})}),{autoscrollToBottom:h,followOutput:m,scrollIntoViewOnChange:y}},Gy(Ox,Kx,Px,zx,jx,wb,Ib,cS,uS)),mS=hb(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:i},{initialItemCount:a,listState:o},{didMount:s}])=>(Xy($(s,sb(a),tb(([,e])=>e!==0),sb(i,r,t,n,e),nb(([[,e],t,n,r,i,a])=>nS(e,t,n,r,i,a))),o),{}),Gy(Ox,zx,aS,jx),{singleton:!0}),hS=hb(([{didMount:e},{scrollTo:t},{listState:n}])=>{let r=ub(0);return Ky($(e,sb(r),tb(([,e])=>e!==0),nb(([,e])=>({top:e}))),e=>{Zy($(n,ab(1),tb(e=>e.items.length>1)),()=>{requestAnimationFrame(()=>{qy(t,e)})})}),{initialScrollTop:r}},Gy(jx,Ib,aS),{singleton:!0}),gS=hb(([{scrollVelocity:e}])=>{let t=ub(!1),n=fb(),r=ub(!1);return Xy($(e,sb(r,t,n),tb(([e,t])=>t!==!1&&t!==void 0),nb(([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}),eb()),t),Ky($(vb(t,e,n),sb(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}},Gy(Kx),{singleton:!0}),_S=hb(([{scrollContainerState:e,scrollTo:t}])=>{let n=fb(),r=fb(),i=fb(),a=ub(!1),o=ub(void 0);return Xy($(vb(n,r),nb(([{scrollTop:e,viewportHeight:t},{offsetTop:n,listHeight:r}])=>({scrollHeight:r,scrollTop:Math.max(0,e-n),viewportHeight:t}))),e),Xy($(t,sb(r),nb(([e,{offsetTop:t}])=>({...e,top:e.top+t}))),i),{customScrollParent:o,useWindowScroll:a,windowScrollContainerState:n,windowScrollTo:i,windowViewportRect:r}},Gy(Ib)),vS=hb(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:i},{didMount:a},{useWindowScroll:o,windowScrollContainerState:s,windowViewportRect:c}])=>{let l=fb(),u=ub(void 0),d=ub(null),f=ub(null);return Xy(s,d),Xy(c,f),Ky($(l,sb(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})}),Xy($(u,tb(By),nb(yS)),i),Xy($(a,sb(u),tb(([,e])=>e!==void 0),eb(),nb(([,e])=>e.ranges)),e),{getState:l,restoreStateFrom:u}},Gy(Ox,Ib,zx,jx,_S));function yS(e){return{align:`start`,index:0,offset:e.scrollTop}}var bS=hb(([{topItemsIndexes:e}])=>{let t=ub(0);return Xy($(t,tb(e=>e>=0),nb(e=>Array.from({length:e}).map((e,t)=>t))),e),{topItemCount:t}},Gy(aS));function xS(e){let t=!1,n;return(()=>(t||(t=!0,n=e()),n))}var SS=xS(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),CS=hb(([{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 Xy(k,T.scrollSeekRangeChanged),Xy($(vb(T.windowViewportRect,_.headerHeight,_.fixedHeaderHeight),nb(([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}},Gy(Ox,zx,Ib,vS,pS,aS,Px,hb(([{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=pb($(l,sb(s),ib(([,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]),tb(([e])=>e!==0),sb(i,c,r,a,m,h),tb(([,e,t,n,,,r])=>!r&&!n&&e!==0&&t===Vx),nb(([[e],,,,,t])=>(t(`Upward scrolling compensation`,{amount:e},xb.DEBUG),e))));function _(t){t>0?(qy(n,{behavior:`auto`,top:-t}),qy(e,0)):(qy(e,0),qy(n,{behavior:`auto`,top:-t}))}Ky($(g,sb(e,o)),([t,n,r])=>{r&&SS()?qy(e,n-t):_(-t)}),Ky($(vb(db(o,!1),e,h),tb(([e,t,n])=>!e&&!n&&t!==0),nb(([e,t])=>t),ob(1)),_),Xy($(f,nb(e=>({top:-e}))),n);let v=null;function y(){if(v===null)return;let{offset:t}=v;v=null,qy(n,{top:t}),requestAnimationFrame(()=>{qy(e,0),qy(h,!1)})}return Ky(t,e=>{v===null||!v.acknowledgeable||e===v.offset&&y()}),Ky($(u,sb(p,d),nb(([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=Bb(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:Yy(e)!==t,offset:t},qy(e,t),requestAnimationFrame(y)}),{deviation:e}},Gy(Ib,Kx,aS,Ox,wb,ox)),bS,Ax,hb(([e,t,n,r,i,a,o,s,c,l,u])=>({...e,...t,...n,...r,...i,...a,...o,...s,...c,...l,...u}),Gy(Qx,mS,jx,gS,oS,hS,sS,_S,uS,wb,cS))));function wS(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 TS=typeof document>`u`?Q.useEffect:Q.useLayoutEffect;function ES(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&&qy(e.propsReady,!1);for(let i of r){let r=e[t.required[i]];qy(r,n[i])}for(let r of i)if(r in n){let i=e[t.optional[r]];qy(i,n[r])}e.propsReady!==void 0&&qy(e.propsReady,!0)}function l(e){return a.reduce((n,r)=>(n[r]=n=>{let i=e[t.methods[r]];qy(i,n)},n),{})}function u(e){return o.reduce((n,r)=>(n[r]=lb(e[t.events[r]]),n),{})}return{Component:Q.forwardRef(function(t,a){let{children:d,...f}=t,[p]=Q.useState(()=>Uy(_b(e),e=>{c(e,f)})),[m]=Q.useState(Ry(u,p));TS(()=>{for(let e of o)e in f&&Ky(m[e],f[e]);return()=>{Object.values(m).map(Jy)}},[f,m,p]),TS(()=>{c(p,f)}),Q.useImperativeHandle(a,Fy(l(p)));let h=n;return(0,Z.jsx)(s.Provider,{value:p,children:n===void 0?d:(0,Z.jsx)(h,{...wS([...r,...i,...o],f),children:d})})}),useEmitter:(e,t)=>{let n=Q.useContext(s)[e];TS(()=>Ky(n,t),[t,n])},useEmitterValue:e=>{let t=Q.useContext(s)[e],n=Q.useCallback(e=>Ky(t,e),[t]);return Q.useSyncExternalStore(n,()=>Yy(t),()=>Yy(t))},usePublisher:e=>{let t=Q.useContext(s);return Q.useCallback(n=>{qy(t[e],n)},[t,e])}}}var DS=Q.createContext(void 0),OS=Q.createContext(void 0),kS=`-webkit-sticky`,AS=`sticky`,jS=xS(()=>{if(typeof document>`u`)return AS;let e=document.createElement(`div`);return e.style.position=kS,e.style.position===kS?kS:AS});function MS(e){return`self`in e}function NS(e){return`body`in e}function PS(e,t,n,r=Hy,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(NS(l)||MS(l)){let e=MS(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():Ws.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;MS(r)?(u=Math.max(ux(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=ux(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,Bx(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:Ob(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:Ob(o.current,e.top)}}),o.current.scrollBy(e)},[a]),scrollerRef:o,scrollToCallback:u}}function FS(e){return e}var IS=hb(([e,t])=>({...e,...t}),Gy(CS,hb(()=>{let e=ub(e=>`Item ${e}`),t=ub(e=>`Group ${e}`),n=ub({}),r=ub(FS),i=ub(`div`),a=ub(Hy),o=(e,t=null)=>db($(n,nb(t=>t[e]),eb()),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`)}}))),LS=({height:e})=>(0,Z.jsx)(`div`,{style:{height:e}}),RS={overflowAnchor:`none`,position:jS(),zIndex:1},zS={overflowAnchor:`none`},BS={...zS,display:`inline-block`,height:`100%`},VS=Q.memo(function({showTopList:e=!1}){let t=iC(`listState`),n=aC(`sizeRanges`),r=iC(`useWindowScroll`),i=iC(`customScrollParent`),a=aC(`windowScrollContainerState`),o=aC(`scrollContainerState`),s=i||r?a:o,c=iC(`itemContent`),l=iC(`context`),u=iC(`groupContent`),d=iC(`trackItemSizes`),f=iC(`itemSize`),p=iC(`log`),m=aC(`gap`),h=iC(`horizontalDirection`),{callbackRef:g}=jb(n,f,d,e?Hy:s,p,m,i,h,iC(`skipAnimationFrameInResizeObserver`)),[_,v]=Q.useState(0);rC(`deviation`,e=>{_!==e&&v(e)});let y=aC(`deviationCommitted`);Pb(()=>{y(_)},[_,y]);let b=iC(`EmptyPlaceholder`),x=iC(`ScrollSeekPlaceholder`)??LS,S=iC(`ListComponent`),C=iC(`ItemComponent`),w=iC(`GroupComponent`),T=iC(`computeItemKey`),E=iC(`isSeeking`),D=iC(`groupIndices`).length>0,O=iC(`alignToBottom`),k=iC(`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,{...qS(b,l)}):(0,Z.jsx)(S,{...qS(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,{...qS(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,{...qS(w,l),"data-index":n,"data-item-index":e.index,"data-known-size":e.size,key:r,style:RS},u(e.index,l)):(0,Q.createElement)(C,{...qS(C,l),...JS(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?BS:zS},D?c(e.index,e.groupIndex,e.data,l):c(e.index,e.data,l))})})}),HS={height:`100%`,outline:`none`,overflowY:`auto`,position:`relative`,WebkitOverflowScrolling:`touch`},US={outline:`none`,overflowX:`auto`,position:`relative`},WS=e=>({height:`100%`,position:`absolute`,top:0,width:`100%`,...e?{display:`flex`,flexDirection:`column`}:void 0}),GS=(e,t,n=0)=>({...WS(e),position:t?`relative`:`absolute`,top:t?-n:0}),KS={position:jS(),top:0,width:`100%`,zIndex:1};function qS(e,t){if(typeof e!=`string`)return{context:t}}function JS(e,t){return{item:typeof e==`string`?void 0:t}}var YS=Q.memo(function(){let e=iC(`HeaderComponent`),t=aC(`headerHeight`),n=iC(`HeaderFooterTag`),r=kb(Q.useMemo(()=>e=>{t(ux(e,`height`))},[t]),!0,iC(`skipAnimationFrameInResizeObserver`)),i=iC(`context`);return e==null?null:(0,Z.jsx)(n,{ref:r,children:(0,Z.jsx)(e,{...qS(e,i)})})}),XS=Q.memo(function(){let e=iC(`FooterComponent`),t=aC(`footerHeight`),n=iC(`HeaderFooterTag`),r=kb(Q.useMemo(()=>e=>{t(ux(e,`height`))},[t]),!0,iC(`skipAnimationFrameInResizeObserver`)),i=iC(`context`);return e==null?null:(0,Z.jsx)(n,{ref:r,children:(0,Z.jsx)(e,{...qS(e,i)})})});function ZS({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}=PS(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?US:HS,...i},tabIndex:0,...o,...qS(c,a),children:r})})}function QS({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}=PS(s,l,c,t(`scrollerRef`),f);return Pb(()=>(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,...qS(c,a),children:r})})}var $S=({children:e})=>{let t=Q.useContext(DS),n=aC(`viewportHeight`),r=aC(`fixedItemHeight`),i=iC(`alignToBottom`),a=iC(`horizontalDirection`),o=kb(Q.useMemo(()=>Ly(n,e=>ux(e,a?`width`:`height`)),[n,a]),!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:o,style:WS(i),children:e})},eC=({children:e})=>{let t=Q.useContext(DS),n=aC(`windowViewportRect`),r=aC(`fixedItemHeight`),i=iC(`customScrollParent`),a=iC(`useWindowScroll`),o=iC(`topListHeight`),s=Fb(n,i,iC(`skipAnimationFrameInResizeObserver`)),c=iC(`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:GS(c,a,o),children:e})},tC=({children:e})=>{let t=iC(`TopItemListComponent`)??`div`,n=iC(`headerHeight`);return(0,Z.jsx)(t,{style:{...KS,marginTop:`${n}px`},...qS(t,iC(`context`)),children:e})},{Component:nC,useEmitter:rC,useEmitterValue:iC,usePublisher:aC}=ES(IS,{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=iC(`useWindowScroll`),n=iC(`topItemsIndexes`).length>0,r=iC(`customScrollParent`),i=iC(`context`);return(0,Z.jsxs)(r||t?sC:oC,{...e,context:i,children:[n&&(0,Z.jsx)(tC,{children:(0,Z.jsx)(VS,{showTopList:!0})}),(0,Z.jsxs)(r||t?eC:$S,{children:[(0,Z.jsx)(YS,{}),(0,Z.jsx)(VS,{}),(0,Z.jsx)(XS,{})]})]})})),oC=ZS({useEmitter:rC,useEmitterValue:iC,usePublisher:aC}),sC=QS({useEmitter:rC,useEmitterValue:iC,usePublisher:aC}),cC=nC,lC=hb(([e,t])=>({...e,...t}),Gy(CS,hb(()=>{let e=ub(e=>(0,Z.jsxs)(`td`,{children:[`Item $`,e]})),t=ub(null),n=ub(e=>(0,Z.jsxs)(`td`,{colSpan:1e3,children:[`Group `,e]})),r=ub(null),i=ub(null),a=ub({}),o=ub(FS),s=ub(Hy),c=(e,t=null)=>db($(a,nb(t=>t[e]),eb()),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`)}}))),uC=({height:e})=>(0,Z.jsx)(`tr`,{children:(0,Z.jsx)(`td`,{style:{height:e}})}),dC=({height:e})=>(0,Z.jsx)(`tr`,{children:(0,Z.jsx)(`td`,{style:{border:0,height:e,padding:0}})}),fC={overflowAnchor:`none`},pC={position:jS(),zIndex:2,overflowAnchor:`none`},mC=Q.memo(function({showTopList:e=!1}){let t=bC(`listState`),n=bC(`computeItemKey`),r=bC(`firstItemIndex`),i=bC(`context`),a=bC(`isSeeking`),o=bC(`fixedHeaderHeight`),s=bC(`groupIndices`).length>0,c=bC(`itemContent`),l=bC(`groupContent`),u=bC(`ScrollSeekPlaceholder`)??uC,d=bC(`GroupComponent`),f=bC(`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,{...qS(u,i),height:t.size,index:t.index,key:h,type:t.type||`item`}):t.type===`group`?(0,Q.createElement)(d,{...qS(d,i),"data-index":m,"data-item-index":t.index,"data-known-size":t.size,key:h,style:{...pC,top:o}},l(t.index,i)):(0,Q.createElement)(f,{...qS(f,i),...JS(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?{...pC,top:o+g}:fC},s?c(t.index,t.groupIndex,t.data,i):c(t.index,t.data,i))})}),hC=Q.memo(function(){let e=bC(`listState`),t=bC(`topItemsIndexes`).length>0,n=xC(`sizeRanges`),r=bC(`useWindowScroll`),i=bC(`customScrollParent`),a=xC(`windowScrollContainerState`),o=xC(`scrollContainerState`),s=i||r?a:o,c=bC(`trackItemSizes`),{callbackRef:l,ref:u}=jb(n,bC(`itemSize`),c,s,bC(`log`),void 0,i,!1,bC(`skipAnimationFrameInResizeObserver`)),[d,f]=Q.useState(0);yC(`deviation`,e=>{d!==e&&(u.current.style.marginTop=`${e}px`,f(e))});let p=xC(`deviationCommitted`);Pb(()=>{p(d)},[d,p]);let m=bC(`EmptyPlaceholder`),h=bC(`FillerRow`)??dC,g=bC(`TableBodyComponent`),_=bC(`paddingTopAddition`),v=bC(`statefulTotalCount`),y=bC(`context`);if(v===0&&m!=null)return(0,Z.jsx)(m,{...qS(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,...qS(g,y),children:[C,t&&(0,Z.jsx)(mC,{showTopList:!0}),(0,Z.jsx)(mC,{}),w]})}),gC=({children:e})=>{let t=Q.useContext(DS),n=xC(`viewportHeight`),r=xC(`fixedItemHeight`),i=kb(Q.useMemo(()=>Ly(n,e=>ux(e,`height`)),[n]),!0,bC(`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:WS(!1),children:e})},_C=({children:e})=>{let t=Q.useContext(DS),n=xC(`windowViewportRect`),r=xC(`fixedItemHeight`),i=bC(`customScrollParent`),a=bC(`useWindowScroll`),o=Fb(n,i,bC(`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:GS(!1,a),children:e})},{Component:vC,useEmitter:yC,useEmitterValue:bC,usePublisher:xC}=ES(lC,{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=bC(`useWindowScroll`),n=bC(`customScrollParent`),r=xC(`fixedHeaderHeight`),i=xC(`fixedFooterHeight`),a=bC(`fixedHeaderContent`),o=bC(`fixedFooterContent`),s=bC(`context`),c=kb(Q.useMemo(()=>Ly(r,e=>ux(e,`height`)),[r]),!0,bC(`skipAnimationFrameInResizeObserver`)),l=kb(Q.useMemo(()=>Ly(i,e=>ux(e,`height`)),[i]),!0,bC(`skipAnimationFrameInResizeObserver`)),u=n||t?CC:SC,d=n||t?_C:gC,f=bC(`TableComponent`),p=bC(`TableHeadComponent`),m=bC(`TableFooterComponent`),h=a?(0,Z.jsx)(p,{ref:c,style:{position:`sticky`,top:0,zIndex:2},...qS(p,s),children:a()},`TableHead`):null,g=o?(0,Z.jsx)(m,{ref:l,style:{bottom:0,position:`sticky`,zIndex:1},...qS(m,s),children:o()},`TableFoot`):null;return(0,Z.jsx)(u,{...e,...qS(u,s),children:(0,Z.jsx)(d,{children:(0,Z.jsxs)(f,{style:{borderSpacing:0,overflowAnchor:`none`},...qS(f,s),children:[h,(0,Z.jsx)(hC,{},`TableBody`),g]})})})})),SC=ZS({useEmitter:yC,useEmitterValue:bC,usePublisher:xC}),CC=QS({useEmitter:yC,useEmitterValue:bC,usePublisher:xC}),wC={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},TC={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:EC,floor:DC,max:OC,min:kC,round:AC}=Math;function jC(e,t,n){return Array.from({length:t-e+1}).map((t,r)=>({data:n===null?null:n[r+e],index:r+e}))}function MC(e){return{...TC,items:e}}function NC(e,t){return e!==void 0&&e.width===t.width&&e.height===t.height}function PC(e,t){return e!==void 0&&e.column===t.column&&e.row===t.row}var FC=hb(([{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=ub(0),C=ub(0),w=ub(wC),T=ub({height:0,width:0}),E=ub({height:0,width:0}),D=fb(),O=fb(),k=ub(0),A=ub(null),j=ub({column:0,row:0}),M=fb(),N=fb(),P=ub(!1),F=ub(0),I=ub(!0),L=ub(!1),R=ub(!1);Ky($(m,sb(F),tb(([e,t])=>!Rx(t))),()=>{qy(I,!1)}),Ky($(vb(m,I,E,T,F,L),tb(([e,t,n,r,,i])=>e&&!t&&n.height!==0&&r.height!==0&&!i)),([,,,,e])=>{if(e===void 0){qy(I,!0);return}qy(L,!0),Ix(1,()=>{qy(D,e)}),Zy($(l),()=>{qy(t,[0,0]),qy(I,!0)})}),Xy($(N,tb(e=>e!=null&&e.scrollTop>0),rb(0)),C),Ky($(m,sb(N),tb(([,e])=>e!=null)),([,e])=>{e&&(qy(T,e.viewport),qy(E,e.item),qy(j,e.gap),e.scrollTop>0&&(qy(P,!0),Zy($(l,ab(1)),e=>{qy(P,!1)}),qy(c,{top:e.scrollTop})))}),Xy($(T,nb(({height:e})=>e)),d),Xy($(vb(yb(T,NC),yb(E,NC),yb(j,(e,t)=>e!==void 0&&e.column===t.column&&e.row===t.row),yb(l)),nb(([e,t,n,r])=>({gap:n,item:t,scrollTop:r,viewport:e}))),M),Xy($(vb(yb(S),r,yb(j,PC),yb(E,NC),yb(T,NC),yb(A),yb(C),yb(P),yb(I),yb(F)),tb(([,,,,,,,e])=>!e),nb(([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 wC;if(p===0){let t=Lx(l,e);return MC(jC(t,t+Math.max(s-1,0),o))}let h=IC(m,p,u),g,_;c?t===0&&n===0&&s>0?(g=0,_=s-1):(g=h*DC((t+d)/(f+d)),_=h*EC((n+d)/(f+d))-1,_=kC(e-1,OC(_,h-1)),g=kC(_,OC(0,g))):(g=0,_=-1);let v=jC(g,_,o),{bottom:y,top:b}=LC(a,r,i,v),x=EC(e/h);return{bottom:y,itemHeight:f,items:v,itemWidth:p,offsetBottom:x*f+(x-1)*d-y,offsetTop:b,top:b}})),w),Xy($(A,tb(e=>e!==null),nb(e=>e.length)),S),Xy($(vb(T,E,w,j),tb(([e,t,{items:n}])=>n.length>0&&t.height!==0&&e.height!==0),nb(([e,t,{items:n},r])=>{let{bottom:i,top:a}=LC(e,r,t,n);return[a,i]}),eb(ax)),t);let z=ub(!1);Xy($(l,sb(z),nb(([e,t])=>t||e!==0)),z);let B=pb($(vb(w,S),tb(([{items:e}])=>e.length>0),sb(z),tb(([[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}),nb(([[,e]])=>e-1),eb())),ee=pb($(yb(w),tb(({items:e})=>e.length>0&&e[0].index===0),rb(0),eb())),V=pb($(yb(w),sb(P),tb(([{items:e},t])=>e.length>0&&!t),nb(([{items:e}])=>({endIndex:e[e.length-1].index,startIndex:e[0].index})),eb(ix),ob(0)));Xy(V,p.scrollSeekRangeChanged),Xy($(D,sb(T,E,S,j),nb(([e,t,n,r,i])=>{let a=Nx(e),{align:o,behavior:s,offset:c}=a,l=a.index;l===`LAST`&&(l=r-1),l=OC(0,l,kC(r-1,l));let u=RC(t,i,n,l);return o===`end`?u=AC(u-t.height+n.height):o===`center`&&(u=AC(u-t.height/2+n.height/2)),c!==void 0&&c!==0&&(u+=c),{behavior:s,top:u}})),c);let H=db($(w,nb(e=>e.offsetBottom+e.bottom)),0);return Xy($(b,nb(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:H,...f,endReached:B,propsReady:h,rangeChanged:V,startReached:ee,stateChanged:M,stateRestoreInProgress:P,...x}},Gy(Qx,Ib,Kx,gS,jx,_S,wb));function IC(e,t,n){return OC(1,DC((e+n)/(DC(t)+n)))}function LC(e,t,n,r){let{height:i}=n;if(i===void 0||r.length===0)return{bottom:0,top:0};let a=RC(e,t,n,r[0].index);return{bottom:RC(e,t,n,r[r.length-1].index)+i,top:a}}function RC(e,t,n,r){let i=DC(r/IC(e.width,n.width,t.column)),a=i*n.height+OC(0,i-1)*t.row;return a>0?a+t.row:a}var zC=hb(([e,t])=>({...e,...t}),Gy(FC,hb(()=>{let e=ub(e=>`Item ${e}`),t=ub({}),n=ub(null),r=ub(`virtuoso-grid-item`),i=ub(`virtuoso-grid-list`),a=ub(FS),o=ub(`div`),s=ub(Hy),c=(e,n=null)=>db($(t,nb(t=>t[e]),eb()),n),l=ub(!1),u=ub(!1);return Xy(yb(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`)}}))),BC=Q.memo(function(){let e=qC(`gridState`),t=qC(`listClassName`),n=qC(`itemClassName`),r=qC(`itemContent`),i=qC(`computeItemKey`),a=qC(`isSeeking`),o=JC(`scrollHeight`),s=qC(`ItemComponent`),c=qC(`ListComponent`),l=qC(`ScrollSeekPlaceholder`),u=qC(`context`),d=JC(`itemDimensions`),f=JC(`gap`),p=qC(`log`),m=qC(`stateRestoreInProgress`),h=JC(`reportReadyState`),g=kb(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:ZC(`column-gap`,getComputedStyle(e).columnGap,p),row:ZC(`row-gap`,getComputedStyle(e).rowGap,p)})},[o,d,f,p]),!0,!1);return Pb(()=>{e.itemHeight>0&&e.itemWidth>0&&h(!0)},[e]),m?null:(0,Z.jsx)(c,{className:t,ref:g,...qS(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,{...qS(l,u),height:e.itemHeight,index:t.index,width:e.itemWidth},o):(0,Q.createElement)(s,{...qS(s,u),className:n,"data-index":t.index,key:o},r(t.index,t.data,u))})})}),VC=Q.memo(function(){let e=qC(`HeaderComponent`),t=JC(`headerHeight`),n=qC(`headerFooterTag`),r=kb(Q.useMemo(()=>e=>{t(ux(e,`height`))},[t]),!0,!1),i=qC(`context`);return e==null?null:(0,Z.jsx)(n,{ref:r,children:(0,Z.jsx)(e,{...qS(e,i)})})}),HC=Q.memo(function(){let e=qC(`FooterComponent`),t=JC(`footerHeight`),n=qC(`headerFooterTag`),r=kb(Q.useMemo(()=>e=>{t(ux(e,`height`))},[t]),!0,!1),i=qC(`context`);return e==null?null:(0,Z.jsx)(n,{ref:r,children:(0,Z.jsx)(e,{...qS(e,i)})})}),UC=({children:e})=>{let t=Q.useContext(OS),n=JC(`itemDimensions`),r=JC(`viewportDimensions`),i=kb(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:WS(!1),children:e})},WC=({children:e})=>{let t=Q.useContext(OS),n=JC(`windowViewportRect`),r=JC(`itemDimensions`),i=qC(`customScrollParent`),a=qC(`useWindowScroll`),o=Fb(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:GS(!1,a),children:e})},{Component:GC,useEmitter:KC,useEmitterValue:qC,usePublisher:JC}=ES(zC,{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=qC(`useWindowScroll`),n=qC(`customScrollParent`),r=n||t?XC:YC,i=n||t?WC:UC,a=qC(`context`);return(0,Z.jsx)(r,{...e,...qS(r,a),children:(0,Z.jsxs)(i,{children:[(0,Z.jsx)(VC,{}),(0,Z.jsx)(BC,{}),(0,Z.jsx)(HC,{})]})})})),YC=ZS({useEmitter:KC,useEmitterValue:qC,usePublisher:JC}),XC=QS({useEmitter:KC,useEmitterValue:qC,usePublisher:JC});function ZC(e,t,n){return t!==`normal`&&t?.endsWith(`px`)!==!0&&n(`${e} was not resolved to pixel value correctly`,t,xb.WARN),t===`normal`?0:parseInt(t??`0`,10)}function QC(e){return e.scrollHeight-e.scrollTop-e.clientHeight}function $C(e,t=96){return QC(e)<=t}function ew(e){Math.abs(QC(e))>.5&&(e.scrollTop=e.scrollHeight)}function tw(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 nw(){return typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}var rw=new WeakMap;function iw(e,t){return rw.set(e,t),()=>{rw.get(e)===t&&rw.delete(e)}}function aw(e){return rw.get(e)}function ow(e){e.dispatchEvent(new Event(`chat-scroll-reading`))}function sw({context:e}){return e?.footer}var cw={Footer:sw},lw={top:800,bottom:800};function uw({rows:e,scrollRef:t,renderRow:n,footer:r}){let i=(0,Q.useRef)(null),[a,o]=(0,Q.useState)(),[s,c]=(0,Q.useState)(lw),[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 iw(a,{reveal:t=>{let n=e.findIndex(e=>e.index===t||e.aliases.includes(t));return n<0?!1:(ow(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&&nw()===`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=lw.top+(e?a.scrollTop-e.start:0),r=lw.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)(cC,{ref:i,customScrollParent:a,data:e,skipAnimationFrameInResizeObserver:!0,components:cw,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}function dw(e){let t=(0,X.c)(6),{progress:n}=e,r=v(fw),i;if(t[0]!==r||t[1]!==n.completed||t[2]!==n.stage||t[3]!==n.total){let e=S(r).chat.runRecovery,a;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Pt,{className:`size-3.5 shrink-0 motion-safe:animate-spin`,"aria-hidden":!0}),t[5]=a):a=t[5],i=(0,Z.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex flex-wrap items-center gap-2 py-2 text-xs text-fg-muted`,"data-run-recovery":!0,children:[a,(0,Z.jsx)(`span`,{children:n.stage===`model_fallback`?e.fallback:e.retrying}),n.completed!=null&&n.total!=null?(0,Z.jsx)(`span`,{className:`tabular-nums`,children:e.attempt.replace(`{{attempt}}`,String(n.completed)).replace(`{{total}}`,String(n.total))}):null]}),t[0]=r,t[1]=n.completed,t[2]=n.stage,t[3]=n.total,t[4]=i}else i=t[4];return i}function fw(e){return e.language}var pw=e=>{},mw=(0,Q.memo)(function(e){let t=(0,X.c)(72),{messages:n,timelineEntries:r,personal:i,authToken:a,conversationId:o,workspaceConversationId:s,projectId:c,streaming:l,sending:u,progress:d,runError:f,reasoningLevel:p,registerListContentRef:m,onPickWelcomePrompt:h,welcomeSpotlight:g,welcomeOverlay:_,compactWelcome:y,onDeleteRound:b,onRetryUserMessageRound:x,deleteRoundDisabled:C,onSaveAssistantAsNote:w,onSaveAssistantToSourceNote:T,onExtractAssistantTask:E,onForkAssistantTurn:D,onEditUserMessage:O,editLatestUserOnly:k,editRequiresTurnId:A,responseFeedbackEnabled:j,showAssistantWorkLog:M,hideAssistantActions:N,trailingContent:P,replySpaceRef:F,scrollRef:I}=e,L=r===void 0?[]:r,R=i!==void 0&&i,z=u!==void 0&&u,B=y!==void 0&&y,ee=k!==void 0&&k,V=A!==void 0&&A,H=M===void 0||M,U=N!==void 0&&N,W=v(hw),te;t[0]===W?te=t[1]:(te=S(W),t[0]=W,t[1]=te);let ne=te,[re]=(0,Q.useState)(!!(I&&n.length>=300));if(n.length===0&&L.length===0&&!l&&!z&&!f){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]!==ne||t[5]!==g?(e=g??{headline:ne.chat.welcomeSpotlight.headline,contextKind:`empty`,contextStatus:`ready`},t[4]=ne,t[5]=g,t[6]=e):e=t[6];let n=h??pw,r;return t[7]!==B||t[8]!==e||t[9]!==n?(r=(0,Z.jsx)(`div`,{className:`pb-1.5`,children:(0,Z.jsx)(Tm,{spotlight:e,onPickPrompt:n,compact:B})}),t[7]=B,t[8]=e,t[9]=n,t[10]=r):r=t[10],r}let ie=Date.now(),ae=n.findLastIndex(gw),oe,se,ce;if(t[11]!==ae||t[12]!==n||t[13]!==x||t[14]!==z||t[15]!==l){let e=n.slice(ae+1);oe=e.findLast(_w)?.outcome,se=l||z,ce=!se&&x&&ae>=0&&(n[ae].turnId||n[ae].deliveryStatus===`failed`&&n[ae].clientSubmissionId)&&!e.some(yw)?()=>x(ae):void 0,t[11]=ae,t[12]=n,t[13]=x,t[14]=z,t[15]=l,t[16]=oe,t[17]=se,t[18]=ce}else oe=t[16],se=t[17],ce=t[18];let le=ce,ue=oe?.turnId,de;t[19]!==le||t[20]!==f||t[21]!==se||t[22]!==ue?(de={turnId:ue,running:se,error:f,onRetry:le},t[19]=le,t[20]=f,t[21]=se,t[22]=ue,t[23]=de):de=t[23];let G=de,K=se&&(d?.stage===`model_retry`||d?.stage===`model_fallback`),fe;t[24]!==n.length||t[25]!==z||t[26]!==l?(fe=(e,t)=>!!((l||z||e.pendingResponseStatus)&&t===n.length-1&&e.role===`assistant`),t[24]=n.length,t[25]=z,t[26]=l,t[27]=fe):fe=t[27];let q=fe,pe;t[28]===n?pe=t[29]:(pe=(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[28]=n,t[29]=pe);let me=pe,J;t[30]!==me||t[31]!==q||t[32]!==n||t[33]!==R||t[34]!==p||t[35]!==H?(J=(e,t)=>!$v(e,{personal:R,isStreaming:q(e,t),reasoningLevel:p,showAssistantWorkLog:H,followUpTrigger:me(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[30]=me,t[31]=q,t[32]=n,t[33]=R,t[34]=p,t[35]=H,t[36]=J):J=t[36];let he=n.flatMap(J),ge;t[37]===n.length?ge=t[38]:(ge=(e,t)=>({key:e.id,index:n.length+t,aliases:[]}),t[37]=n.length,t[38]=ge),he.push(...L.map(ge));let _e=0,ve=n.map(e=>(_e=Math.max(e.timestamp??_e,_e),_e));L.length&&he.sort((e,t)=>{let r=e=>e<n.length?ve[e]:L[e-n.length].timestamp;return r(e.index)-r(t.index)||e.index-t.index});let ye=new Map(he.map((e,t)=>[e.index,he[t-1]?.index])),be=e=>{if(e>=n.length){let t=L[e-n.length];return(0,Z.jsx)(`div`,{"data-chat-timeline-entry":t.id,children:t.content},t.id)}let t=n[e],r=q(t,e),i=e===ae,l=n[e-1],u=me(t,e),f=ye.get(e),m=f===void 0?void 0:n[f],h=m&&f!==void 0?me(m,f)?n[f-1]?.timestamp??m.timestamp:m.timestamp:void 0,g=Cy(t,e),_=u?l?.timestamp??t.timestamp:t.timestamp,v=ky(_,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:Ay(_,ie,W)})}):null,t.role===`task`&&t.taskTrigger?(0,Z.jsx)(ay,{trigger:t.taskTrigger}):(0,Z.jsx)(Sy,{message:t,personal:R,followUpTrigger:u,authToken:a,conversationId:o,workspaceConversationId:s,projectId:c,isStreaming:r,progress:r&&!K?d:null,reasoningLevel:p,messageIndex:e,onDeleteRound:b,onRetryUserMessageRound:x,userMessageCanRetry:!!x&&i,deleteRoundDisabled:!!(C&&i),onSaveAssistantAsNote:w,onSaveAssistantToSourceNote:T,onExtractAssistantTask:E,onForkAssistantTurn:D,suppressAssistantActions:U,onEditUserMessage:O,userMessageCanEdit:(!ee||i)&&(!V||!!t.turnId)&&t.deliveryStatus!==`sending`,responseFeedbackEnabled:j,showAssistantWorkLog:H})]},g)},xe=re?`pt-8`:`contents`,Se;t[39]===xe?Se=t[40]:(Se=Y(xe),t[39]=xe,t[40]=Se);let Ce;t[41]!==d||t[42]!==K?(Ce=K?(0,Z.jsx)(dw,{progress:d}):null,t[41]=d,t[42]=K,t[43]=Ce):Ce=t[43];let we;t[44]!==oe?.status||t[45]!==le||t[46]!==f||t[47]!==se?(we=!se&&f&&oe?.status!==`failed`?(0,Z.jsx)(Th,{errorText:f,onRetry:le}):null,t[44]=oe?.status,t[45]=le,t[46]=f,t[47]=se,t[48]=we):we=t[48];let Te;t[49]!==F||t[50]!==re?(Te=F&&(0,Z.jsx)(`div`,{ref:F,className:Y(!re&&`-mt-8`,`shrink-0 transition-none`),"aria-hidden":!0,"data-chat-reply-space":!0}),t[49]=F,t[50]=re,t[51]=Te):Te=t[51];let Ee;t[52]!==Se||t[53]!==Ce||t[54]!==we||t[55]!==Te||t[56]!==P?(Ee=(0,Z.jsxs)(`div`,{className:Se,children:[Ce,we,P,Te]}),t[52]=Se,t[53]=Ce,t[54]=we,t[55]=Te,t[56]=P,t[57]=Ee):Ee=t[57];let De=Ee,Oe=Wv,ke=oa,Ae=!re&&`flex flex-col gap-8`,je;t[58]===Ae?je=t[59]:(je=Y(`w-full min-w-0 pb-8`,Ae),t[58]=Ae,t[59]=je);let Me=re||void 0,Ne=re&&I?(0,Z.jsx)(uw,{rows:he,scrollRef:I,renderRow:be,footer:De}):(0,Z.jsxs)(Z.Fragment,{children:[he.map(e=>be(e.index)),De]}),Pe;t[60]!==m||t[61]!==je||t[62]!==Me||t[63]!==Ne?(Pe=(0,Z.jsx)(`div`,{ref:m,className:je,"data-chat-virtualized":Me,children:Ne}),t[60]=m,t[61]=je,t[62]=Me,t[63]=Ne,t[64]=Pe):Pe=t[64];let Fe;t[65]!==ke||t[66]!==Pe?(Fe=(0,Z.jsx)(ke,{children:Pe}),t[65]=ke,t[66]=Pe,t[67]=Fe):Fe=t[67];let Ie;return t[68]!==Oe||t[69]!==G||t[70]!==Fe?(Ie=(0,Z.jsx)(Oe,{value:G,children:Fe}),t[68]=Oe,t[69]=G,t[70]=Fe,t[71]=Ie):Ie=t[71],Ie});function hw(e){return e.language}function gw(e){return e.role===`user`}function _w(e){return e.outcome}function vw(e){return e.type===`tool_use`}function yw(e){return e.content.some(vw)}function bw(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 xw=(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=v(Sw),l;t[0]===c?l=t[1]:(l=S(c),t[0]=c,t[1]=l);let u=l,d=!n,f=o===`top`?`-top-2 -translate-y-full`:`bottom-2`,p=n?`opacity-100`:`opacity-0`,m;t[2]!==f||t[3]!==p?(m=Y(`pointer-events-none absolute inset-x-0 z-20 flex items-center justify-center transition-opacity duration-150 ease-out motion-reduce:transition-none`,f,p),t[2]=f,t[3]=p,t[4]=m):m=t[4];let h=n?`scale-100 opacity-100`:`pointer-events-none translate-y-1 scale-95 opacity-0`,g;t[5]===h?g=t[6]:(g=Y(`group relative pointer-events-auto flex size-11 sm:size-8 shrink-0 items-center justify-center rounded-full border border-edge-subtle bg-surface-overlay text-fg-muted shadow-surface`,`hover:border-edge-strong hover:text-fg`,la.transition,la.press,la.focusRingPanel,h,`motion-reduce:translate-y-0 motion-reduce:scale-100`),t[5]=h,t[6]=g);let _=n?void 0:-1,y;t[7]===s?y=t[8]:(y=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)(bw,{className:`xopc-loop-logo--stream size-5`})}):(0,Z.jsx)(ps,{"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]=y);let b;t[9]!==u.chat.scrollToBottom||t[10]!==r||t[11]!==_||t[12]!==y||t[13]!==g?(b=(0,Z.jsx)(`button`,{type:`button`,className:g,tabIndex:_,onClick:r,title:u.chat.scrollToBottom,"aria-label":u.chat.scrollToBottom,children:y}),t[9]=u.chat.scrollToBottom,t[10]=r,t[11]=_,t[12]=y,t[13]=g,t[14]=b):b=t[14];let x;return t[15]!==b||t[16]!==d||t[17]!==m?(x=(0,Z.jsx)(`div`,{"data-scroll-to-bottom-dock":!0,"aria-hidden":d,className:m,children:b}),t[15]=b,t[16]=d,t[17]=m,t[18]=x):x=t[18],x});function Sw(e){return e.language}function Cw(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 ww(e,t){if(!t)return!1;let n=Array.from(e.querySelectorAll(`[data-chat-message-row]`)).find(e=>e.dataset.messageRenderKey===t.rowId||e.dataset.clientSubmissionId===t.rowId);if(!n)return!1;let r=n.getBoundingClientRect().top-e.getBoundingClientRect().top-t.offset;return Math.abs(r)>.5&&(e.scrollTop+=r),!0}function Tw(e){return e.webkitDirectionInvertedFromDevice===!0?e.deltaY>0:e.deltaY<0}function Ew(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 Dw(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=$C(t);P(n),D(n),_.current=n?e:null,n||(S.current=Cw(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=aw(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:nw()});return}ew(t),w.current=t.scrollHeight,T.current=t.clientHeight,D($C(t))},t[4]=z):z=t[4];let B=z,ee;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(ee=()=>{let e=u.current;!e||e.scrollHeight<=e.clientHeight||(P(!1),D($C(e)))},t[5]=ee):ee=t[5];let V=ee,H;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>{let e=u.current;if(!e)return;!p.current&&!aw(e)&&ww(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($C(e))},t[6]=H):H=t[6];let U=H,W;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(W=()=>{let e=u.current;e&&p.current&&(aw(e)?ew(e):e.scrollHeight>w.current&&B()),C.current===null&&(C.current=requestAnimationFrame(()=>{C.current=null,U()}))},t[7]=W):W=t[7];let te=W,ne;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(ne=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(te);t.observe(e),x.current=t;let n=new MutationObserver(e=>{let t=u.current;!t||!p.current||!aw(t)||(R()||e.some(Ow))&&ew(t)});n.observe(e,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:[`style`]}),b.current=n},t[8]=ne):ne=t[8];let re=ne,ie,ae;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(ie=()=>()=>{x.current?.disconnect(),b.current?.disconnect(),C.current!==null&&(cancelAnimationFrame(C.current),C.current=null)},ae=[],t[9]=ie,t[10]=ae):(ie=t[9],ae=t[10]),(0,Q.useEffect)(ie,ae);let oe;t[11]!==s||t[12]!==l||t[13]!==c?(oe=()=>{let e=u.current;if(!e)return;let t=$C(e),n=T.current>0&&(e.scrollHeight!==w.current||e.clientHeight!==T.current);if(!t&&p.current&&n){D(!1),te();return}P(t),t||(S.current=Cw(e)),D(t),t&&R(),e.scrollTop<100&&!t&&s&&!c&&l()},t[11]=s,t[12]=l,t[13]=c,t[14]=oe):oe=t[14];let se=oe,ce;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(ce=e=>{B({force:!0,smooth:e===void 0||e})},t[15]=ce):ce=t[15];let le=ce,ue,de;t[16]!==n||t[17]!==r?(ue=()=>{if(n){if(r){O.current=!0;return}O.current===!0&&(O.current=!1,P(!0),B({force:!0}))}},de=[r,n,P,B],t[16]=n,t[17]=r,t[18]=ue,t[19]=de):(ue=t[18],de=t[19]),(0,Q.useLayoutEffect)(ue,de);let G;t[20]!==n||t[21]!==r?(G=()=>{!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]=G):G=t[22];let K;t[23]!==i||t[24]!==n||t[25]!==r?(K=[i,n,r,P,B],t[23]=i,t[24]=n,t[25]=r,t[26]=K):K=t[26],(0,Q.useLayoutEffect)(G,K);let fe,q;t[27]!==a||t[28]!==r||t[29]!==o?(fe=()=>{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()},q=[a,o,r,B,R],t[27]=a,t[28]=r,t[29]=o,t[30]=fe,t[31]=q):(fe=t[30],q=t[31]),(0,Q.useLayoutEffect)(fe,q);let pe,me;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&&!Ew(n,t.first)&&Ew(a[s],t.first)&&!aw(e)&&t.scrollHeight>0&&!ww(e,S.current)&&(e.scrollTop+=o-t.scrollHeight),M.current={first:n,len:i,scrollHeight:o}},me=[a,r],t[32]=a,t[33]=r,t[34]=pe,t[35]=me):(pe=t[34],me=t[35]),(0,Q.useLayoutEffect)(pe,me);let J,he;t[36]!==n||t[37]!==r?(J=()=>{if(!n||r)return;let e=u.current;if(!e)return;let t=new ResizeObserver(te);t.observe(e);let i=e=>{Math.abs(e.deltaY)<Math.abs(e.deltaX)||Math.abs(e.deltaY)<.25||Tw(e)&&V()},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&&V()},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&&V()},l=()=>{let t=window.getSelection();!t||t.isCollapsed||!e.contains(t.anchorNode)||(V(),S.current=Cw(e))},d=t=>{(t.target instanceof Element?t.target:null)?.closest(`button[aria-expanded="false"]:not([aria-haspopup]), summary`)&&(V(),S.current=Cw(e))};return e.addEventListener(`chat-scroll-reading`,V),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`,V),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,V,te],t[36]=n,t[37]=r,t[38]=J,t[39]=he):(J=t[38],he=t[39]),(0,Q.useLayoutEffect)(J,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,te()};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,te],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]!==se?(ve={scrollRef:u,composerDockRef:d,atBottom:E,registerListContentRef:re,scrollToBottom:le,onScroll:se,replySpaceRef:m,reserveReplySpace:I},t[45]=E,t[46]=se,t[47]=ve):ve=t[47],ve}function Ow(e){return e.target instanceof HTMLElement&&e.target.hasAttribute(`data-virtuoso-scroller`)}var kw=256*1024,Aw=new TextEncoder;function jw(e){return Aw.encode(e).byteLength}function Mw(e){return jw(e)<=262144?e:new TextDecoder().decode(Aw.encode(e).subarray(0,kw),{stream:!0})}function Nw(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=Aw.encode(e),o=a.byteLength+256>t?new TextDecoder().decode(a.subarray(0,t-256),{stream:!0}):e;o!==e&&(n=!0);let s=jw(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`,Fw={text:``,attachments:[]};function Iw(e){return Math.min(760,Math.max(360,Math.round(e)))}function Lw(){return{panes:{},tabs:[],widthPx:520}}function Rw(){try{let e=JSON.parse(sessionStorage.getItem(Pw)||`{}`),t=e.identity;if(t&&t!==_.getState().conversationId)return Lw();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:Iw(typeof e.widthPx==`number`?e.widthPx:520)}}catch{return Lw()}}function zw(e){try{sessionStorage.setItem(Pw,JSON.stringify({...e,identity:_.getState().conversationId}))}catch{}}var Bw=Rw(),Vw=b((e,t)=>{let n=n=>{e(n),queueMicrotask(()=>{let e=t();zw({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]??Fw,text:r}}}),setDraftAttachments:(n,r)=>e({drafts:{...t().drafts,[n]:{...t().drafts[n]??Fw,attachments:r}}}),rememberMessages:(n,r)=>{let i={...t().readings};delete i[n],i[n]=Nw(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)=>{yi.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]??Fw},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:()=>{yi.getState().reset(),e({drafts:{},readings:{},pendingCreate:null,creatingRequests:{}}),n({panes:{},tabs:[]})},pendingCreate:null,creatingRequests:{},requestCreate:(n,i=[])=>{yi.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)=>{yi.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;yi.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&&(yi.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(yi.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&&yi.getState().activate(`side:${o.id}`,e),o||i.requestCreate(e)},setWidthPx:e=>n({widthPx:Iw(e)})}});_.subscribe((e,t)=>{if(e.conversationId&&!t.conversationId&&e.baseUrl===t.baseUrl){let e=Rw();Vw.setState(e)}if(e.baseUrl!==t.baseUrl||t.conversationId!==void 0&&e.conversationId!==t.conversationId){Vw.getState().reset();try{sessionStorage.removeItem(`xopc:side-chat-client-id`)}catch{}}});function Hw(e){return e.acceptsArgs?`/${e.name} `:`/${e.name}`}var Uw=3e4,Ww=null;function Gw(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 Kw(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<Uw)return Ww.items.map(e=>({...e,...o.has(e.relativePath)?{isRecent:!0}:{isRecent:void 0}}))}let s={conversationId:n,agentId:r},c=Gw(a.length===0?await Ya(``,s):await qa(a,s,i),o);return n&&a.length===0&&(Ww={key:n,at:Date.now(),items:c}),c}async function qw(e,t){return Ya(e,{conversationId:t.conversationId,agentId:t.agentId})}function Jw(e,...t){let n=e.trim().toLocaleLowerCase();return!n||t.some(e=>e?.toLocaleLowerCase().includes(n))}async function Yw(e){let t=await h(g(e)),n=await t.json().catch(()=>({}));if(!t.ok||!n.payload)throw Error(typeof n.error==`string`?n.error:`HTTP ${t.status}`);return n.payload}var Xw=[{kind:`file`,search:(e,t)=>Kw(e,{conversationId:t.conversationId,agentId:t.currentAgentId,limit:10,recentPaths:t.recentPaths})},{kind:`note`,async search(e,t){return(await He({...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()||S(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 gn({...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 To(t.currentAgentId,t.conversationId)).skills.flatMap(n=>{if(!n.availableForCurrentAgent)return[];let r=jo(n,t.language);return Jw(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 si(),r=S(t.language).agentsSettings;return n.items.flatMap(t=>{let n=Ba(t,r),i=Va(t,r);return Jw(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 Yw(`/api/browser/tabs?${new URLSearchParams({conversationId:t.conversationId})}`)).tabs.flatMap(n=>!Jw(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}}])}}],Zw=(0,Q.createContext)({target:null,register:()=>()=>{}});function Qw(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)(Zw,{value:u,children:n}),t[6]=n,t[7]=u,t[8]=d):d=t[8],d}function $w(){let e=(0,X.c)(2),{register:t}=(0,Q.useContext)(Zw),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 eT(){return(0,Q.useContext)(Zw).target}function tT({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 nT({interaction:e,path:t,complete:n}){let r=v(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 y(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)(vi,{type:`button`,variant:`secondary`,disabled:o,onClick:()=>void u(`decline`),children:r?`拒绝`:`Decline`}),(0,Z.jsx)(vi,{type:`submit`,disabled:o,children:r?`提交给设备`:`Send to device`})]})]})}function rT(e){let t=(0,X.c)(8),{conversationId:n,active:r}=e,i;t[0]===n?i=t[1]:(i=n?g(`/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}=Qr(a,iT,s),u=c?.payload?.[0],d;return t[4]!==u||t[5]!==l||t[6]!==a?(d=a&&u?(0,Z.jsx)(nT,{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 iT(e){return y(e)}function aT(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)(Ht,{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)(vi,{disabled:i,onClick:()=>r(e),children:e},e),t[11]=i,t[12]=r,t[13]=e):e=t[13],l=n.findExamples.map(e),t[7]=i,t[8]=r,t[9]=n.findExamples,t[10]=l}else l=t[10];let u;t[14]===l?u=t[15]:(u=(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:l}),t[14]=l,t[15]=u);let d;t[16]===n.findBack?d=t[17]:(d=(0,Z.jsx)(p,{to:`/capabilities/skills`,className:`text-sm text-accent-fg hover:underline`,children:n.findBack}),t[16]=n.findBack,t[17]=d);let f;return t[18]!==o||t[19]!==s||t[20]!==c||t[21]!==u||t[22]!==d?(f=(0,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,u,d]}),t[18]=o,t[19]=s,t[20]=c,t[21]=u,t[22]=d,t[23]=f):f=t[23],f}function oT(e){let t=`/api/sessions/${encodeURIComponent(e)}/connection-wait`,n=Sn(t=>t.sessions[e]?.localDraft),{data:r,mutate:i,isLoading:a}=Qr(n?null:[t,n===!1?`persisted`:`unknown`],async()=>await Lr(e)?null:(await y(g(t))).payload,{refreshInterval:e=>e?.wait?5e3:0,revalidateOnFocus:!0}),o=(0,Q.useRef)(r);o.current=r;let s=(0,Q.useRef)(!1),c=(0,Q.useRef)(!1),l=(0,Q.useRef)(0),u=(0,Q.useRef)(null),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(),[h,_]=(0,Q.useState)(),b=(0,Q.useCallback)(async(e,n,r,a,d)=>{let p=o.current,h=p?.wait;if(!h||(e===`cancel`?c.current:s.current||c.current))return!1;e===`cancel`?c.current=!0:s.current=!0,l.current+=1,f(!0),m(void 0),e===`cancel`&&_(void 0);let b=h.needs.find(e=>e.key===n),x=e===`connect`&&b?.target.type!==`plugin`?os():null,S=JSON.stringify([h.id,h.objectiveRevision,e,n,r,a,d]);u.current?.signature!==S&&(u.current={signature:S,key:crypto.randomUUID()});let C=u.current.key,w=i=>y(g(`${t}/actions`),{method:`POST`,body:JSON.stringify({action:e,needKey:n,accountId:r,candidateRef:a,instanceId:d,waitId:h.id,expectedTranscriptId:i.transcriptId,expectedVersion:i.wait.version,...e===`cancel`?{expectedObjectiveRevision:h.objectiveRevision}:{},idempotencyKey:C})});try{let n;try{n=await w(p)}catch(r){if(e!==`cancel`||r.status!==409)throw r;let a=(await y(g(t))).payload;if(await i(e=>!e||e.transcriptId!==a.transcriptId||a.revision>=e.revision?a:e,!1),a.transcriptId!==p.transcriptId||a.wait?.id!==h.id||a.wait.objectiveRevision!==h.objectiveRevision)throw r;n=await w(a)}let r=n.payload.snapshot;if(await i(e=>!e||e.transcriptId!==r.transcriptId||r.revision>=e.revision?r:e,!1),n.payload.authorizationUrl){if(!await as(n.payload.authorizationUrl,x))throw Error(`Unable to open the authorization window. Allow pop-ups, then retry.`)}else ss(x);return u.current?.signature===S&&(u.current=null),!0}catch(t){if(ss(x),t.status===409&&e===`cancel`){let e=v.getState().language===`zh`?`目标状态已变化,未能取消。请检查当前任务状态后再试。`:`The objective state changed and cancellation was not confirmed. Check its current status and try again.`;m(e),_(e)}else if(t.status!==409){let n=t instanceof Error?t.message:String(t);m(n),e===`cancel`&&_(n)}return await i(),!1}finally{e===`cancel`?c.current=!1:s.current=!1,--l.current,f(l.current>0)}},[t,i]);return(0,Q.useEffect)(()=>{let t=t=>{let n=t.detail;n?.conversationId===e&&(n.revision??1/0)>(o.current?.revision??0)&&i()};window.addEventListener(`session-connection-wait-changed`,t);let n=()=>{i()};return window.addEventListener(`gateway-realtime-connected`,n),()=>{window.removeEventListener(`session-connection-wait-changed`,t),window.removeEventListener(`gateway-realtime-connected`,n)}},[e,i]),{wait:r?.wait,isLoading:a,busy:d,error:p,cancellationError:h,act:b,dismissError:()=>{m(void 0),_(void 0)}}}function sT(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 cT=(0,Q.lazy)(()=>l(()=>import(`./mcp-conversation-setup-page-DedbjJbF.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]))),lT={zh:{connection:`服务连接`,cancel:`取消连接请求`,close:`关闭`,finish:`完成连接`,review:`查看连接`,reconnect:`更新密钥`,expired:`连接请求已过期`,rejected:`服务未接受当前密钥`,token:`需要访问密钥`,oauth:`需要登录授权`,unknown:`无法确认认证方式`,failed:`连接检查未通过`,planned:`正在检查连接`,approval:`请确认服务和资料来源`,reload:`配置已保存,重启 Gateway 后生效`,help:`获取访问密钥`,connected:`连接已完成`,continuing:`连接已完成,原任务将自动继续`,cancelFailed:`暂时无法取消连接,请重试。`},en:{connection:`Service connection`,cancel:`Cancel connection request`,close:`Close`,finish:`Complete connection`,review:`View connection`,reconnect:`Update key`,expired:`Connection request expired`,rejected:`The service rejected the current key`,token:`Access key required`,oauth:`Sign-in required`,unknown:`Could not verify the authentication method`,failed:`Connection check failed`,planned:`Checking the connection`,approval:`Review the service and its sources`,reload:`Settings saved. Restart the Gateway to apply them.`,help:`Get an access key`,connected:`Connection complete`,continuing:`Connection complete. Your task will resume automatically.`,cancelFailed:`Could not cancel the connection. Try again.`}};function uT({conversationId:e}){let t=v(e=>e.language),[n,r]=f(),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(),[c,l]=(0,Q.useState)(),u=lT[t];(0,Q.useEffect)(()=>{if(!c)return;let e=window.setTimeout(()=>l(void 0),8e3);return()=>window.clearTimeout(e)},[c]);let d=n.get(`mcpSetup`),m=e=>{let t=new URLSearchParams(n);e?t.set(`mcpSetup`,e):t.delete(`mcpSetup`),r(t,{replace:!e})},{data:h,mutate:_}=Qr(`/api/mcp/setup/conversations/${encodeURIComponent(e)}`,async e=>{try{return{permitted:!0,...(await y(g(e))).payload}}catch(e){if([403,404].includes(e.status??0))return{permitted:!1,setup:null};throw e}},{refreshInterval:e=>e?.setup?5e3:0,shouldRetryOnError:!1});(0,Q.useEffect)(()=>{if(h?.permitted===!1)return;let t=t=>{let n=t.detail;(n?.conversationId??n?.key)===e&&_()},n=()=>{_()};return window.addEventListener(`session-mcp-setup-changed`,t),window.addEventListener(`session-transcript-updated`,t),window.addEventListener(`gateway-realtime-connected`,n),()=>{window.removeEventListener(`session-mcp-setup-changed`,t),window.removeEventListener(`session-transcript-updated`,t),window.removeEventListener(`gateway-realtime-connected`,n)}},[e,_,h?.permitted]);let b=d?(0,Z.jsx)(Q.Suspense,{fallback:null,children:(0,Z.jsx)(cT,{setupId:d,onClose:t=>{t?.phase===`ready`&&!t.reloadRequired&&t.conversationId===e&&l({conversationId:e,label:t.displayName||t.serverId,continuing:t.continuationQueued===!0&&t.objective!==`connect_only`}),m(null),_()}})}):null;if(!h?.setup)return(0,Z.jsxs)(Z.Fragment,{children:[c?.conversationId===e?(0,Z.jsxs)(`section`,{className:`mb-2 flex items-center gap-3 rounded-xl border border-edge bg-success-soft px-3 py-2 text-sm text-fg`,children:[(0,Z.jsx)(re,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,Z.jsxs)(`p`,{role:`status`,className:`min-w-0 flex-1 break-words`,children:[c.label,` · `,c.continuing?u.continuing:u.connected]}),(0,Z.jsx)(vi,{variant:`ghost`,className:`size-11 shrink-0 p-0`,"aria-label":u.close,onClick:()=>l(void 0),children:(0,Z.jsx)(Xt,{className:`size-4`,"aria-hidden":!0})})]}):null,b]});let x=h.setup,S=async()=>{a(!0),s(void 0);try{await y(g(`/api/mcp/setup/${encodeURIComponent(x.setupId)}`),{method:`POST`,body:JSON.stringify({action:`cancel`,expectedVersion:x.version})}),d===x.setupId&&m(null),await _(e=>e?.setup?.setupId===x.setupId?{...e,setup:null}:e)}catch{s(x.setupId),_()}finally{a(!1)}},C=x.errorCode===`credential_rejected`,w=x.expired?u.expired:x.reloadRequired?u.reload:C?u.rejected:x.phase===`token_required`?u.token:[`oauth_required`,`authorizing`].includes(x.phase)?u.oauth:x.phase===`auth_unknown`?u.unknown:x.phase===`blocked`?u.failed:x.phase===`approval_required`?u.approval:x.phase===`ready`?u.connected:u.planned,T=C&&!x.expired?u.reconnect:x.expired||x.reloadRequired||[`blocked`,`auth_unknown`].includes(x.phase)?u.review:u.finish;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`section`,{className:`mb-2 flex flex-wrap items-center gap-2 rounded-xl border border-edge bg-surface-panel px-3 py-2`,"aria-label":u.connection,children:[(0,Z.jsx)(Je,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 break-words text-sm`,role:`status`,children:[(0,Z.jsx)(`p`,{className:`font-medium text-fg`,children:x.displayName||x.serverId}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:w})]}),(0,Z.jsx)(p,{className:`inline-flex min-h-11 items-center rounded-lg px-3 text-sm text-accent-fg hover:bg-surface-hover`,to:`/mcp-setup/${encodeURIComponent(x.setupId)}`,onClick:e=>{e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),m(x.setupId))},children:T}),(0,Z.jsx)(vi,{variant:`ghost`,className:`size-11 shrink-0 p-0`,"aria-label":u.cancel,title:u.cancel,disabled:i,onClick:()=>void S(),children:(0,Z.jsx)(Xt,{className:`size-4`,"aria-hidden":!0})}),!x.expired&&x.phase===`token_required`&&x.helpUrl?(0,Z.jsx)(`div`,{className:`basis-full pl-6`,children:(0,Z.jsxs)(`a`,{href:x.helpUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex min-h-8 items-center text-sm text-accent-fg hover:underline`,children:[u.help,` ↗`]})}):null,o===x.setupId?(0,Z.jsx)(`span`,{role:`alert`,className:`basis-full text-sm text-fg-muted`,children:u.cancelFailed}):null]}),b]})}var dT=(0,Q.lazy)(()=>l(()=>import(`./agent-plugin-dialog-DLbTHALG.js`).then(e=>e.n).then(e=>({default:e.AgentPluginDialog})),__vite__mapDeps([30,1,2,3,4,5,6,7,8,9,31,11,32,33,34,16,17,18,29,20,21,35,36,13,37,38,39,40,41,27,28,42,43,44,45]))),fT={zh:{waiting:`等待连接`,reconnectRequired:`需要重新授权`,install:`安装`,installing:`正在准备安装`,connect:`连接`,reconnect:`重新连接`,details:`查看详情`,skip:`跳过连接`,cancel:`取消这个目标`,ready:`已连接`,check:`我已完成授权`,authorizing:`等待完成授权`,queued:`已连接,等待继续`,queuedSkipped:`等待使用现有信息继续`,checkingConnection:`正在检查连接`,checkingTools:`已连接,正在验证工具`,queueHint:`目标已保存,正在等待当前执行结束。`,interruptedInputHint:`有条补充消息在重启时中断。请重新发送要求,或移除上方中断的消息后继续。`,checkFailed:`连接检查暂时失败,目标已保存`,interrupted:`恢复检查曾中断,目标已保存`,lastChecked:`最近检查`,scope:`确认后继续`,scopeHint:`这个目标已等待了一段时间。请确认仍要按下方原始要求继续;如需修改时间范围,请先在聊天中说明。未读等条件将以实际执行时为准。`,account:`选择账号`,all:`查看全部连接`,close:`关闭`,intro:`完成连接后,将自动恢复当前目标。你也可以继续发送消息。`,callbackHint:`远程 Gateway 无法接收本地回调时,粘贴浏览器地址栏中的完整回调 URL。`,callbackPlaceholder:`完整回调 URL`,callbackSubmit:`完成连接`,replace:`更换应用`,confirmReplace:`确认改用`,apps:`个应用需要连接`,preserved:`目标已保留`,retry:`重试检查`,toolsUnavailable:`应用工具暂不可用`,toolsHint:`账号已连接,当前无法使用任务所需工具。可以重试检查,无需重新授权。`},en:{waiting:`Waiting for connection`,reconnectRequired:`Reauthorization required`,install:`Install`,installing:`Preparing installation`,connect:`Connect`,reconnect:`Reconnect`,details:`Details`,skip:`Skip connection`,cancel:`Cancel this objective`,ready:`Connected`,check:`Check authorization`,authorizing:`Waiting for authorization`,queued:`Connected, waiting to continue`,queuedSkipped:`Waiting to continue with available information`,checkingConnection:`Checking connection`,checkingTools:`Connected, checking tools`,queueHint:`Your objective is saved. Waiting for the current execution to finish.`,interruptedInputHint:`A message was interrupted during restart. Resend the requirement or remove the interrupted message above before continuing.`,checkFailed:`Connection check failed; objective saved`,interrupted:`Recovery check interrupted; objective saved`,lastChecked:`Last checked`,scope:`Confirm and continue`,scopeHint:`This objective has been waiting for a while. Confirm the original request below, or send a message to change the time range first. Conditions such as unread status are evaluated at execution time.`,account:`Choose an account`,all:`View all connections`,close:`Close`,intro:`The current objective resumes automatically after connecting. You can keep sending messages.`,callbackHint:`If a remote Gateway cannot receive the local callback, paste the complete callback URL from the browser address bar.`,callbackPlaceholder:`Complete callback URL`,callbackSubmit:`Complete connection`,replace:`Change app`,confirmReplace:`Confirm switch to`,apps:`apps need connecting`,preserved:`Objective preserved`,retry:`Retry check`,toolsUnavailable:`App tools unavailable`,toolsHint:`The account is connected, but the tools needed for this task are unavailable. Retry the check without reconnecting.`}},pT=`rounded-lg border border-edge px-3 py-1.5 text-sm text-fg hover:bg-surface-hover disabled:opacity-50`,mT=`rounded-lg bg-accent px-3 py-1.5 text-sm text-on-accent disabled:opacity-50`;function hT({conversationId:e}){let{wait:t,busy:n,error:r,cancellationError:i,act:a,dismissError:o}=oT(e),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(),[d,f]=(0,Q.useState)(),[p,m]=(0,Q.useState)(),[h,_]=(0,Q.useState)(),[b,x]=(0,Q.useState)(!1),[w,j]=(0,Q.useState)(),M=v(e=>e.language),N=fT[M];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:pT,children:N.close})]}):(0,Z.jsx)(uT,{conversationId:e});let P=t.needs[0],F=t.needs.length===1,I=F&&P.phase===`reconnect`,L=t.phase===`queued`,R=t.recoveryStage===`checking_connection`||t.recoveryStage===`checking_tools`,z=t.needs.find(e=>e.phase===`choose_account`),B=t.needs.some(e=>e.capabilityError);if(t.phase===`ready`&&!R&&!t.recoveryError&&!t.needs.some(e=>e.target.type===`plugin`))return(0,Z.jsx)(uT,{conversationId:e});let ee=t.recoveryStage===`checking_connection`?N.checkingConnection:t.recoveryStage===`checking_tools`?N.checkingTools:L?t.resolution===`skipped`?N.queuedSkipped:N.queued:t.recoveryError===`check_failed`?N.checkFailed:t.recoveryError?N.interrupted:t.phase===`ready`?N.ready:B?N.toolsUnavailable:z?N.account:F&&P.phase===`authorizing`?N.authorizing:I?N.reconnectRequired:N.waiting,V=L||R?N.details:t.recoveryError?N.retry:t.phase===`review_scope`?N.scope:F&&P.phase===`install`?b?N.installing:`${N.install} ${P.label}`:F&&P.phase===`connect`?M===`zh`?`连接 ${P.label}`:`Connect ${P.label}`:F&&P.phase===`reconnect`?N.reconnect:F&&P.phase===`authorizing`&&P.target.type!==`plugin`?N.check:N.details;async function H(e=P){if(e.target.type===`store-connector`){x(!0),j(void 0);try{let t=await _a(e.target.packageName,e.target.version);if(t.reviewHash!==e.target.reviewHash||t.definition.id!==e.target.connectorId||t.definition.provenance?.sha256!==e.target.sha256)throw Error(M===`zh`?`Connector 包在审查后发生了变化,请重新发起推荐。`:`The Connector package changed after review. Request a new recommendation.`);f(Dt(t.definition,{packageName:t.packageName,version:t.version,reviewHash:t.reviewHash,permissions:t.permissions})),m(e.key)}catch(e){j(e instanceof Error?e.message:String(e))}finally{x(!1)}}}async function U(e){if(!(e.target.type!==`plugin`||!t)){x(!0),j(void 0);try{let{target:n,pluginId:r}=e,i=r?(await y(g(`/api/extensions/agent-plugins/${encodeURIComponent(r)}`))).payload:void 0,o=`packageName`in n&&!i?`store:${n.packageName}@${n.version}`:void 0;if(!i&&!o||!await a(`connect`,e.key))return;c(!1),_({waitId:t.id,extension:i,source:o})}catch(e){j(e instanceof Error?e.message:String(e))}finally{x(!1)}}}function W(){L||R?c(!0):t?.recoveryError?a(`check`):t?.phase===`review_scope`?c(!0):F&&P.target.type===`plugin`&&[`install`,`connect`,`reconnect`,`authorizing`].includes(P.phase)?U(P):F&&P.phase===`install`?H():F&&[`connect`,`reconnect`].includes(P.phase)?a(`connect`,P.key):F&&P.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":ee,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(Je,{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:F?`${ee} · ${P.label}`:`${ee} · ${t.needs.length} ${N.apps}`}),(0,Z.jsx)(ae,{className:`ml-1 inline size-3`,"aria-hidden":!0})]}),(0,Z.jsxs)(`button`,{type:`button`,className:z||L||R?pT:mT,disabled:n&&!R||b,onClick:W,children:[n&&(0,Z.jsx)(Ze,{className:`mr-1 inline size-3 animate-spin`,"aria-hidden":!0}),V]}),!L&&!R&&(0,Z.jsx)(`button`,{type:`button`,className:`text-xs text-fg-muted hover:text-fg`,disabled:n,onClick:()=>void a(`skip`),children:N.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:N.cancel})]}),I&&!R&&!L?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:N.intro}):null,t.queueBlocked&&(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.blockedInputId?N.interruptedInputHint:N.queueHint}),t.lastCheckedAt&&(0,Z.jsxs)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:[N.lastChecked,`: `,new Date(t.lastCheckedAt).toLocaleTimeString(M===`zh`?`zh-CN`:`en-US`)]}),z&&!L&&(0,Z.jsx)(`p`,{className:`mt-2 line-clamp-2 break-words text-sm text-fg-muted`,children:t.summary}),z&&!L&&(0,Z.jsx)(sT,{need:z,language:M,disabled:n||R,onSelect:e=>void a(`select_account`,z.key,e),onConnect:()=>void a(`connect`,z.key)},`${t.id}:${t.objectiveRevision}:${z.key}`),(r||w)&&(0,Z.jsxs)(`p`,{role:`alert`,className:`mt-2 text-xs text-fg-muted`,children:[r??w,` `,(0,Z.jsx)(`button`,{type:`button`,className:`text-accent`,onClick:()=>void a(`check`),children:N.retry})]}),(0,Z.jsx)(A,{open:s,onOpenChange:c,children:(0,Z.jsxs)(D,{children:[(0,Z.jsx)(C,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[2px]`}),(0,Z.jsxs)(O,{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)(k,{className:`font-medium text-fg`,children:N.preserved}),(0,Z.jsx)(E,{"aria-label":N.close,children:(0,Z.jsx)(Xt,{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)(T,{className:`text-sm text-fg-muted`,children:B?N.toolsHint:t.phase===`review_scope`?N.scopeHint:N.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(M===`zh`?`zh-CN`:`en-US`)}),t.timeRange&&(0,Z.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[new Date(t.timeRange.from).toLocaleString(M,{timeZone:t.timeRange.timezone}),` – `,new Date(t.timeRange.to).toLocaleString(M,{timeZone:t.timeRange.timezone}),` (`,t.timeRange.timezone,`)`]}),t.needs.map(e=>(0,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||L,className:pT,onClick:()=>void a(`check`),children:N.retry}):e.phase===`ready`?(0,Z.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[(0,Z.jsx)(re,{className:`mr-1 inline size-3`}),N.ready]}):e.target.type===`plugin`&&e.phase!==`blocked`?(0,Z.jsx)(`button`,{type:`button`,disabled:n||L||b,className:mT,onClick:()=>void U(e),children:e.phase===`install`?N.install:e.phase===`reconnect`?N.reconnect:N.connect}):e.phase===`authorizing`?(0,Z.jsx)(`button`,{type:`button`,disabled:n,className:pT,onClick:()=>void a(`check`),children:N.check}):e.phase===`install`?(0,Z.jsx)(`button`,{type:`button`,disabled:n||L||b,className:mT,onClick:()=>void H(e),children:N.install}):e.phase!==`blocked`&&e.phase!==`choose_account`?(0,Z.jsx)(`button`,{type:`button`,disabled:n||L,className:mT,onClick:()=>void a(`connect`,e.key),children:e.phase===`reconnect`?N.reconnect:N.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)(fe,{value:l?.needKey===e.key?l.candidateRef:``,options:e.alternatives.map(e=>({value:e.candidateRef,label:e.label})),placeholder:N.replace,ariaLabel:`${e.label}: ${N.replace}`,disabled:n||L,allowEmpty:!1,onChange:t=>u({needKey:e.key,candidateRef:t,label:e.alternatives.find(e=>e.candidateRef===t).label})}),l?.needKey===e.key&&(0,Z.jsxs)(`button`,{type:`button`,className:pT,disabled:n,onClick:()=>{a(`replace_source`,e.key,void 0,l.candidateRef),u(void 0)},children:[N.confirmReplace,` `,l.label]})]}):null,e.reason&&(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.reason}),e.phase===`authorizing`&&e.target.type!==`plugin`&&(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:N.authorizing}),(0,Z.jsx)(`button`,{type:`button`,disabled:n,className:`text-accent`,onClick:()=>void a(`connect`,e.key),children:N.reconnect})]})]},e.key)),(0,Z.jsx)(`a`,{href:`#/capabilities/connectors`,className:`text-sm text-accent`,onClick:()=>c(!1),children:N.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:N.cancel}),t.phase===`review_scope`?(0,Z.jsx)(`button`,{type:`button`,disabled:n||L,className:mT,onClick:()=>void a(`confirm_scope`),children:N.scope}):null]})]})]})}),h?.waitId===t.id?(0,Z.jsx)(Q.Suspense,{fallback:(0,Z.jsx)(Qt,{className:`mt-2 h-10 w-full`}),children:(0,Z.jsx)(dT,{extension:h.extension,initialSource:h.source,connectionFlow:!0,onClose:()=>_(void 0)})}):null,d?(0,Z.jsx)(Ot,{draft:d,onChange:f,onClose:()=>{f(void 0),m(void 0)},onInstalled:async e=>{p&&await a(`install_complete`,p,void 0,void 0,e.instanceId)&&(f(void 0),m(void 0))},t:S(M).connectorsSettings}):null]})}var gT=new Set([`button`,`checkbox`,`color`,`file`,`hidden`,`image`,`radio`,`range`,`reset`,`submit`]);function _T(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&&!gT.has(t.type)}function vT(){return!!document.querySelector(`dialog[open], [aria-modal="true"], [role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]`)}function yT(e,t){return t.disabled||t.editorHidden||e.defaultPrevented||_T(e.target)||_T(document.activeElement)?!1:!vT()}function bT(e){for(let t=e.parentElement;t;t=t.parentElement)if(/(auto|scroll)/.test(getComputedStyle(t).overflowY))return t;return null}function xT({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=bT(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 ST(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 CT(e){let t=ST(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 wT=(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=S(v(e=>e.language)),m=(0,Q.useRef)(!1),h=e.filter(e=>e.status===`queued`),g=!!(t||d),_=xT({items:e,disabled:g,onReorder:o}),y=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`,la.focusRingPanel),b=`flex cursor-pointer items-center gap-2 rounded-md px-3 py-2 text-sm text-fg outline-none focus:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-35`;return e.length===0?null:(0,Z.jsxs)(`div`,{ref:_.listRef,className:`space-y-1 px-2 py-2`,onClickCapture:_.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`,v=h.findIndex(t=>t.id===e.id),x=u&&(l||e.status===`interrupted`),S=o&&!!(e.text.trim()||e.attachments?.length||e.contextRefs?.length),C=o&&!e.attachments?.length&&!e.contextRefs?.length&&e.text.trim().length>0,w=d===e.id,T=e.status===`interrupted`?p.chat.followUpStatusInterrupted:null,E=Rn(e.text),D=new Map(e.contextRefs?.flatMap(e=>e.refId?[[e.refId,e.title]]:[])??[]),O=new Set(E?Bn(E):[]),k=e.contextRefs?.filter(e=>!e.refId||!O.has(e.refId)),A=dr(E?xn(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":!g&&t,onPointerDown:t=>_.onPointerDown(t,e),onDragStart:e=>e.preventDefault(),style:{transform:_.view?.shifts[e.id]?`translateY(${_.view.shifts[e.id]}px)`:void 0},className:Y(`relative flex min-h-10 items-center gap-1 rounded-lg px-1.5 py-1 motion-safe:transition-transform motion-safe:duration-150`,!g&&t&&`cursor-grab`,_.view?.id===e.id&&`bg-surface-inset ring-1 ring-inset ring-edge-strong [&>*]:invisible`,n===e.id?`bg-accent-soft ring-1 ring-inset ring-accent/30`:`hover:bg-surface-hover/50`),children:[(0,Z.jsx)(`div`,{"data-follow-up-drag-handle":!0,className:Y(`flex shrink-0 touch-none cursor-grab items-center active:cursor-grabbing`,(g||!t)&&`cursor-not-allowed opacity-40`),title:p.chat.followUpQueueDrag,children:(0,Z.jsx)(Cs,{className:`size-3.5 text-fg-muted`,"aria-hidden":!0})}),(0,Z.jsx)(`button`,{type:`button`,"data-follow-up-drag-surface":!0,disabled:g||!t,title:p.chat.followUpQueueClickToEdit,"aria-label":p.chat.followUpQueueClickToEdit,className:Y(`min-h-8 min-w-0 flex-1 cursor-grab rounded-md px-1.5 text-left text-sm text-fg`,la.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)(Ee,{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)(ks,{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:y,disabled:g||(x?!o:!S),title:x?p.chat.sendThisMessage:p.chat.followUpQueueSteerHint,"aria-label":x?p.chat.sendThisMessage:p.chat.followUpQueueSteerNow,"aria-busy":w,onClick:()=>x?c?.(e.id):s(e.id),children:[(0,Z.jsx)(gs,{className:Y(`size-4`,w&&`motion-safe:animate-pulse`),"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`hidden text-xs sm:inline`,children:x?p.chat.sendThisMessage:p.chat.followUpQueueSteerNow})]}),(0,Z.jsx)(`button`,{type:`button`,className:Y(y,`px-1.5 hover:text-danger`),disabled:g||!o,title:p.chat.followUpQueueRemove,"aria-label":p.chat.followUpQueueRemove,onClick:()=>i(e.id),children:(0,Z.jsx)(Wt,{className:`size-4`,"aria-hidden":!0})}),(0,Z.jsxs)(go,{modal:!1,children:[(0,Z.jsx)(_o,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:Y(y,`px-1.5`),disabled:g,title:p.chat.followUpQueueMore,"aria-label":p.chat.followUpQueueMore,children:(0,Z.jsx)(Ce,{className:`size-4`,"aria-hidden":!0})})}),(0,Z.jsx)(vo,{children:(0,Z.jsxs)(bo,{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)(yo,{className:b,disabled:!t,onSelect:()=>{m.current=!0,r(e.id)},children:[(0,Z.jsx)(jt,{className:`size-4`,"aria-hidden":!0}),p.chat.followUpQueueClickToEdit]}),f?(0,Z.jsxs)(yo,{className:b,disabled:!C,onSelect:()=>f(e,A),children:[(0,Z.jsx)(Es,{className:`size-4`,"aria-hidden":!0}),p.chat.followUpQueueOpenSideChat]}):null,h.length>1?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(xo,{className:`my-1 h-px bg-edge-subtle`}),(0,Z.jsxs)(yo,{className:b,disabled:!t||v===0,onSelect:()=>a(e.id,`up`),children:[(0,Z.jsx)(oe,{className:`size-4`,"aria-hidden":!0}),p.chat.followUpQueueMoveUp]}),(0,Z.jsxs)(yo,{className:b,disabled:!t||v>=h.length-1,onSelect:()=>a(e.id,`down`),children:[(0,Z.jsx)(ie,{className:`size-4`,"aria-hidden":!0}),p.chat.followUpQueueMoveDown]})]}):null]})})]})]})]},e.id)})]})});function TT({conversationId:e}){let t=_(e=>e.conversationId),n=v(e=>e.language).startsWith(`zh`),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(``),s=Qr(e?[`session-preparation`,t,e]:null,async()=>{let t=await Lr(e);if(t&&!t.materialization)return null;let n=await y(g(`/api/sessions/${encodeURIComponent(e)}/input-state`));return n.payload.preparation?Pr.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 h(g(`/api/sessions/${encodeURIComponent(e)}/preparation/retry`),{method:`POST`,body:JSON.stringify({operationId:l.operationId,expectedRevision:l.revision,idempotencyKey:`${l.operationId}:${l.revision}`})});if(!t.ok)throw Error(`HTTP ${t.status}`);await c()}catch(e){o(e instanceof Error?e.message:String(e))}finally{i(!1)}};return(0,Z.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 text-sm text-fg-muted`,role:`status`,children:[(0,Z.jsx)(`span`,{children:l.state===`preparing`?n?`正在准备会话环境…`:`Preparing conversation environment…`:l.lastError??(n?`会话环境准备失败`:`Conversation environment preparation failed`)}),l.state===`preparation_failed`?(0,Z.jsx)(`button`,{type:`button`,className:`ml-2 text-accent-fg`,disabled:r,onClick:()=>void u(),children:n?`重试准备`:`Retry preparation`}):null,a?(0,Z.jsx)(`span`,{role:`alert`,className:`ml-2`,children:a}):null]})}function ET(e){let t=(0,X.c)(10),{refs:n,label:r,onRemove:i}=e;if(n.length===0)return null;let a;if(t[0]!==r||t[1]!==i||t[2]!==n){let e;t[4]!==r||t[5]!==i?(e=e=>(0,Z.jsxs)(`span`,{className:`inline-flex h-7 min-w-0 max-w-56 items-center gap-1.5 rounded-md border border-edge-subtle bg-accent-soft/50 px-2 text-xs text-fg`,children:[e.kind===`file`&&e.fileKind===`directory`?(0,Z.jsx)(je,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.kind===`file`||e.kind===`result`?(0,Z.jsx)(Oe,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.kind===`session`?(0,Z.jsx)(wt,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.kind===`browser_tab`?(0,Z.jsx)(M,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,Z.jsx)(ks,{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)(Xt,{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 DT=`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 OT(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=v(MT),d;t[0]===u?d=t[1]:(d=S(u),t[0]=u,t[1]=d);let f=d,p=f.chat.composerContext,m=_(jT),h=_(AT),[g,y]=(0,Q.useState)(``),[b]=Za(g,200),x;t[2]!==h||t[3]!==b||t[4]!==m?(x=[`composer-projects`,h,m,b],t[2]=h,t[3]=b,t[4]=m,t[5]=x):x=t[5];let C;t[6]===b?C=t[7]:(C=()=>mn({status:`active`,search:b,sortBy:`updatedAt`,sortOrder:`desc`,limit:50}),t[6]=b,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=Qr(x,C,w),E=Of(n,!1),D=E.error?void 0:E.data?.environment,O;t[9]!==D?.rootPath||t[10]!==i?(O=i?.trim()||D?.rootPath||``,t[9]=D?.rootPath,t[10]=i,t[11]=O):O=t[11];let k=O,[A,j]=(0,Q.useState)(null),M;t[12]!==E||t[13]!==l?(M=async e=>{j(null);try{await l(e),await E.mutate()}catch(e){let t=e;j(t instanceof Error?t.message:String(t))}},t[12]=E,t[13]=l,t[14]=M):M=t[14];let N;t[15]!==k||t[16]!==M?(N={initialPath:k,onPicked:M},t[15]=k,t[16]=M,t[17]=N):N=t[17];let P=Ua(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 ee;t[22]!==o||t[23]!==f.chat.scopeRemoveProject||t[24]!==c||t[25]!==r?(ee=r?(0,Z.jsx)(`button`,{type:`button`,disabled:o,title:f.chat.scopeRemoveProject,"aria-label":f.chat.scopeRemoveProject,className:Y(DT,`size-7 shrink-0 px-0 ml-0.5 text-fg-muted`),onClick:()=>c(null),children:(0,Z.jsx)(Xt,{className:`size-3.5`,"aria-hidden":!0})}):null,t[22]=o,t[23]=f.chat.scopeRemoveProject,t[24]=c,t[25]=r,t[26]=ee):ee=t[26];let V=r?.id??``,H=r?.name,U;t[27]!==T.data?.items||t[28]!==T.error?(U=T.error?[]:T.data?.items??[],t[27]=T.data?.items,t[28]=T.error,t[29]=U):U=t[29];let W;t[30]===U?W=t[31]:(W=U.map(kT),t[30]=U,t[31]=W);let te=p.chooseProject,ne=p.changeProject,re=p.changeProject,ie=p.noProject,ae=p.searchProjects,oe=T.isLoading,se=T.error?p.projectsFailed:T.data?.items.length===0?p.noProjects:void 0,le=r&&`pl-1`,ue;t[32]===le?ue=t[33]:(ue=Y(DT,`h-8 w-auto max-w-44 gap-1 border-0 bg-transparent pr-2.5 text-sm [&>svg]:hidden [&>span]:text-fg`,le),t[32]=le,t[33]=ue);let de;t[34]!==c||t[35]!==r?.id?(de=e=>{e!==(r?.id??``)&&c(e||null)},t[34]=c,t[35]=r?.id,t[36]=de):de=t[36];let G;t[37]!==p.changeProject||t[38]!==p.chooseProject||t[39]!==p.noProject||t[40]!==p.searchProjects||t[41]!==o||t[42]!==T.isLoading||t[43]!==g||t[44]!==V||t[45]!==H||t[46]!==W||t[47]!==se||t[48]!==ue||t[49]!==de?(G=(0,Z.jsx)(fe,{value:V,selectedLabel:H,options:W,placeholder:te,ariaLabel:ne,title:re,emptyLabel:ie,disabled:o,side:`top`,align:`start`,searchPlaceholder:ae,searchValue:g,onSearchChange:y,loading:oe,statusMessage:se,triggerClassName:ue,contentClassName:`xopc-composer-config-popover w-max min-w-[min(12rem,calc(100vw-1.5rem))] max-w-[min(20rem,calc(100vw-1.5rem))] [&>input]:w-0 [&>input]:min-w-full`,onChange:de}),t[37]=p.changeProject,t[38]=p.chooseProject,t[39]=p.noProject,t[40]=p.searchProjects,t[41]=o,t[42]=T.isLoading,t[43]=g,t[44]=V,t[45]=H,t[46]=W,t[47]=se,t[48]=ue,t[49]=de,t[50]=G):G=t[50];let K;t[51]!==B||t[52]!==ee||t[53]!==G?(K=(0,Z.jsxs)(`div`,{className:B,children:[ee,G]}),t[51]=B,t[52]=ee,t[53]=G,t[54]=K):K=t[54];let q=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)(As,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}):(0,Z.jsx)(qe,{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 me;t[59]!==p.retryProjects||t[60]!==T?(me=T.error?(0,Z.jsx)(`button`,{type:`button`,className:Y(DT,`size-7 px-0`),"aria-label":p.retryProjects,onClick:()=>void T.mutate(),children:(0,Z.jsx)(Pt,{className:`size-3.5`,"aria-hidden":!0})}):null,t[59]=p.retryProjects,t[60]=T,t[61]=me):me=t[61];let J;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?(J=r?null:(0,Z.jsxs)(`button`,{type:`button`,className:Y(DT,`max-w-52`),disabled:o||!a||P.picking,title:F,"aria-label":p.chooseFolder,onClick:P.pick,children:[(0,Z.jsx)(Ae,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),k?(0,Z.jsx)(`span`,{className:`truncate`,children:Ha(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]=J):J=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)(Fe,{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]!==K||t[79]!==q||t[80]!==pe||t[81]!==me||t[82]!==J||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:[K,q,pe,me,J,he,ge]}),t[77]=p.label,t[78]=K,t[79]=q,t[80]=pe,t[81]=me,t[82]=J,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)(ce,{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 kT(e){return{value:e.id,label:e.name}}function AT(e){return e.baseUrl}function jT(e){return e.conversationId}function MT(e){return e.language}var NT=`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 PT(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?bm(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)(Nt,{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:NT,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 FT(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)(Tt,{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:NT,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(NT,`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)(Ut,{className:`size-4 fill-current`,"aria-hidden":!0}):(0,Z.jsx)(I,{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 IT(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 LT=100,RT=400,zT=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 VT(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 HT(e){let t=(0,X.c)(8),{name:n,query:r}=e,i;t[0]!==n||t[1]!==r?(i=VT(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 UT=(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&&Ka(i,{conversationId:l}).then(e=>{let{content:i}=e,a=i.length>zT?`${i.slice(0,zT)}…`:i;r===b.current&&g({type:`set-hover`,hoverPreview:{text:a,x:t,y:n}})}).catch(()=>{r===b.current&&g({type:`set-hover`,hoverPreview:null})})},420)},t[2]=l,t[3]=w);let T=w,E,D;t[4]!==r||t[5]!==n?(E=()=>{if(!n){g({type:`reset`}),C(),b.current+=1;return}let e=()=>{let e=r.current;if(!e)return;let t=e.getBoundingClientRect();g({type:`set-box`,box:{left:t.left,top:t.top,width:t.width}})};e();let t=r.current,i=t&&typeof ResizeObserver<`u`?new ResizeObserver(()=>{e()}):null;return t&&i&&i.observe(t),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{t&&i&&i.disconnect(),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},D=[n,r],t[4]=r,t[5]=n,t[6]=E,t[7]=D):(E=t[6],D=t[7]),(0,Q.useLayoutEffect)(E,D);let O,k;if(t[8]!==i.length||t[9]!==n||t[10]!==a?(O=()=>{!n||a<0||a>=i.length||(x.current?.querySelector(`#at-mention-${a}`))?.scrollIntoView({block:`nearest`})},k=[n,a,i.length],t[8]=i.length,t[9]=n,t[10]=a,t[11]=O,t[12]=k):(O=t[11],k=t[12]),(0,Q.useLayoutEffect)(O,k),!n||typeof document>`u`||_===null)return null;let A=i.length,j=Math.min(_.width,RT),N;t[13]!==_.left||t[14]!==_.top||t[15]!==j?(N={position:`fixed`,left:_.left,top:_.top,width:j,transform:`translateY(calc(-100% - 8px))`,zIndex:LT},t[13]=_.left,t[14]=_.top,t[15]=j,t[16]=N):N=t[16];let P=a>=0&&a<A?`at-mention-${a}`:void 0,F;t[17]!==o||t[18]!==A?(F=o&&A===0?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2.5 text-sm text-fg-muted`,children:[(0,Z.jsx)(Ze,{className:`size-4 shrink-0 animate-spin`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:`…`})]}):null,t[17]=o,t[18]=A,t[19]=F):F=t[19];let I;t[20]!==i||t[21]!==o||t[22]!==c||t[23]!==p||t[24]!==s||t[25]!==u||t[26]!==T||t[27]!==d||t[28]!==a||t[29]!==A?(I=!o&&A===0?(0,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)(ks,{className:`size-3.5 text-accent-fg`,"aria-hidden":!0}):e.kind===`session`?(0,Z.jsx)(wt,{className:`size-3.5 text-violet-600 dark:text-violet-400`,"aria-hidden":!0}):e.kind===`skill`?(0,Z.jsx)(Ht,{className:`size-3.5 text-cyan-600 dark:text-cyan-400`,"aria-hidden":!0}):e.kind===`agent`?(0,Z.jsx)(ne,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):e.kind===`browser_tab`?(0,Z.jsx)(M,{className:`size-3.5 text-blue-600 dark:text-blue-400`,"aria-hidden":!0}):e.isBrowseUp?(0,Z.jsx)(je,{className:`size-3.5 text-fg-muted`,"aria-hidden":!0}):e.isDirectory?(0,Z.jsx)(je,{className:`size-3.5 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}):(0,Z.jsx)(Oe,{className:Y(`size-3.5`,be(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)(HT,{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&&A>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)(Ze,{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]=A,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,Ws.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=>{ba(`error`,e instanceof Error?e.message:String(e))}):n(e)}var GT=new Set([`abort`,`stop`,`cancel`]);function KT(e){if(e.kind!==`command`)return!1;if(GT.has(e.name.toLowerCase()))return!0;for(let t of e.aliases??[])if(GT.has(t.toLowerCase()))return!0;return!1}function qT(e,t,n,r){return e.slice(0,t)+r+e.slice(n)}var JT=(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=qT(t.editor.valueRef.current,n.start,n.end,r),a=n.start+r.length;t.editor.resetEditor({nextText:i,caretOffset:a,focus:!0})},YT=(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=qT(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(KT(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()})},XT=(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 ZT(e,t){switch(e.kind){case`skill`:JT(e,t);return;case`command`:YT(e,t);return;case`agent`:XT(e,t)}}var QT={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},$T=new Set([`abort`,`archive`]);function eE(e){if(e.kind===`command`){let t=e.name.toLowerCase();if(QT[t]!==void 0)return 0;if($T.has(t))return 2}return 1}function tE(e,t){let n=eE(e),r=eE(t);if(n!==r)return n-r;if(n===0){let n=QT[e.name.toLowerCase()]??999,r=QT[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 nE(e){if(e.kind!==`command`)return!1;if(GT.has(e.name.toLowerCase()))return!0;for(let t of e.aliases??[])if(GT.has(t.toLowerCase()))return!0;return!1}function rE(e,t){return e.kind!==`command`||e.acceptsArgs===!0||nE(e)||!(t.runBusy||t.pendingFollowUpsCount>0)?!1:t.pendingFollowUpsCount>=t.maxPendingFollowUps}function iE(e,t){return e.kind!==`command`||e.acceptsArgs===!0||nE(e)||!(t.runBusy||t.pendingFollowUpsCount>0)?!1:t.pendingFollowUpsCount<t.maxPendingFollowUps}function aE(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 oE(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 sE(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(oE(e,a))return null;let o=i[0],s=o.slice(1);return aE(s)||o.startsWith(`/skill:`)?null:{start:i.index,end:r,query:s}}function cE(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 lE(e,t){return t===0?0:Math.min(e,t-1)}function uE(e,t){let{query:n,value:r,commandsAllowed:i,agentsAllowed:a}=t,o=n.trim()===``,s=Rp(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=cE(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?tE(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 dE(e,t,n){let r=(0,X.c)(49),[i,a]=(0,Q.useState)(0),[o,s]=(0,Q.useState)(0),c=v(mE),l=n?.capabilities??yp,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:sE(e,t),r[0]=t,r[1]=u,r[2]=n?.isComposing,r[3]=e,r[4]=d):d=r[4];let f=d,p=!!(f&&!n?.suppress),m,h;r[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{let e=e=>{let t=e.detail;t&&typeof t==`object`&&`section`in t&&(t.section===`skills`||t.section===`agents`)&&s(pE)};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},h=[],r[5]=m,r[6]=h):(m=r[5],h=r[6]),(0,Q.useEffect)(m,h);let g;r[7]!==c||r[8]!==n?.conversationId||r[9]!==n?.currentAgentId?(g=async()=>{let[e,t,r]=await Promise.allSettled([Ao(),To(n?.currentAgentId,n?.conversationId),si()]),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(fE),o=(t.status===`fulfilled`?t.value.skills:[]).map(e=>{let t=jo(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=S(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:Ba(e,s),description:Va(e,s),category:`agent`,...e.avatar?{avatar:e.avatar}:{},aliases:[e.id,...e.name?[e.name]:[]]})):[];return{items:[...o,...a,...u],failedKinds:i}},r[7]=c,r[8]=n?.conversationId,r[9]=n?.currentAgentId,r[10]=g):g=r[10];let _=n?.currentAgentId,y=n?.conversationId,b;r[11]!==c||r[12]!==o||r[13]!==_||r[14]!==y?(b=[c,_,y,o],r[11]=c,r[12]=o,r[13]=_,r[14]=y,r[15]=b):b=r[15];let x;r[16]===Symbol.for(`react.memo_cache_sentinel`)?(x=[],r[16]=x):x=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:x,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=Oa(g,b,O),A=k.data.items,j=k.error==null?null:k.error instanceof Error?k.error.message:String(k.error),M=f?.query??``,N=l.commands&&f!==null&&f.start===0,P=l.agentSwitch&&f!==null&&f.start===0,F;r[24]!==P||r[25]!==A||r[26]!==l.skills||r[27]!==N||r[28]!==M||r[29]!==e?(F=uE(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=lE(i,L.length),r[31]=L.length,r[32]=i,r[33]=B):B=r[33];let ee=B,V;r[34]===L.length?V=r[35]:(V=e=>{L.length!==0&&a(t=>e===`down`?(t+1)%L.length:(t-1+L.length)%L.length)},r[34]=L.length,r[35]=V);let H=V,U;return r[36]!==P||r[37]!==N||r[38]!==L||r[39]!==k.data.failedKinds||r[40]!==k.loading||r[41]!==j||r[42]!==H||r[43]!==p||r[44]!==M||r[45]!==ee||r[46]!==I||r[47]!==f?(U={open:p,slashRange:f,commandsAllowed:N,agentsAllowed:P,sections:I,flatItems:L,selectedIndex:ee,query:M,loading:k.loading,failedKinds:k.data.failedKinds,loadError:j,onNavigate:H,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]=H,r[43]=p,r[44]=M,r[45]=ee,r[46]=I,r[47]=f,r[48]=U):U=r[48],U}function fE(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 pE(e){return e+1}function mE(e){return e.language}var hE=100,gE=560;function _E(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 vE(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 yE=(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)(ja,{agentId:n.agentId,avatar:n.avatar,size:18,className:`size-[18px] shrink-0`}):y?(0,Z.jsx)(Ht,{className:`size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,Z.jsx)(Zt,{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:_E(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:`/`}),_E(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=iE(n,e),D=rE(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?vE(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)(xE,{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}),bE=(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,gE),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 ee=B,V;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?(V={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]=V):V=t[30];let H=V,U;if(t[31]!==s||t[32]!==o||t[33]!==l||t[34]!==H||t[35]!==ee||t[36]!==u||t[37]!==i||t[38]!==P){let e=new Map(i.map(SE)),n=[`skill`,`command`,`agent`].filter(t=>e.has(t)||s.includes(t)),r=0;U=o&&P===0?(0,Z.jsx)(`div`,{className:`space-y-2 p-2.5`,"aria-busy":`true`,children:Array.from({length:6},CE)}):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:ee[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)(yE,{item:e,index:a+t,...H},e.id))]},t)}),t[31]=s,t[32]=o,t[33]=l,t[34]=H,t[35]=ee,t[36]=u,t[37]=i,t[38]=P,t[39]=U}else U=t[39];let W=U,te;t[40]!==O.left||t[41]!==O.top||t[42]!==I?(te={position:`fixed`,left:O.left,top:O.top,width:I,transform:`translateY(calc(-100% - 8px))`,zIndex:hE},t[40]=O.left,t[41]=O.top,t[42]=I,t[43]=te):te=t[43];let ne=`${f}, ${p}, ${m}`,re=F?`${ee[F.kind]}: ${F.name}`:``,ie;t[44]===re?ie=t[45]:(ie=(0,Z.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:re}),t[44]=re,t[45]=ie);let ae;return t[46]!==W||t[47]!==o||t[48]!==D||t[49]!==ne||t[50]!==ie||t[51]!==te?(ae=(0,Ws.createPortal)((0,Z.jsx)(Qa,{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:te,role:`listbox`,"aria-label":ne,"aria-busy":o,children:[ie,W]})}),document.body),t[46]=W,t[47]=o,t[48]=D,t[49]=ne,t[50]=ie,t[51]=te,t[52]=ae):ae=t[52],ae}),xE=(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)(no,{asChild:!0,children:F}),t[32]=F,t[33]=e);let n;t[34]===M?n=t[35]:(n=(0,Z.jsx)($a,{children:(0,Z.jsx)(to,{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)(eo,{delayDuration:0,children:[e,n]}),t[36]=e,t[37]=n,t[38]=r):r=t[38],r}return F});function SE(e){return[e.kind,e]}function CE(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 wE=new Map;function TE(e){let t=wE.get(e);return t||(t={items:[],loadPromise:null,loaded:!1,writeQueue:Promise.resolve(),mutationVersion:0,clearVersion:0},wE.set(e,t)),t}function EE(e,t){if(e.items[0]?.text===t.text){t.id>0&&(e.items[0]=t);return}e.items=[t,...e.items].slice(0,100)}function DE(e,t){if(e.items.some(e=>e.id===t.id))return;let n=e.items.findIndex(e=>e.id===0&&e.text===t.text);if(n>=0){e.items[n]=t;return}EE(e,t)}function OE(e){return TE(e).items.map(e=>e.text)}function kE(e,t=!1){let n=TE(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(()=>y(`/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(()=>kE(e,!0))}),n.loadPromise}function AE(e,t){let n=t.trim();if(!n)return;let r=TE(e),i=r.clearVersion;r.mutationVersion+=1,EE(r,{conversationId:e,id:0,text:n,createdAt:Date.now()}),r.writeQueue=r.writeQueue.then(async()=>{let t=await y(`/api/composer-history`,{method:`POST`,body:JSON.stringify({conversationId:e,text:n})});r.clearVersion===i&&t.item.conversationId===e&&DE(r,t.item)}).catch(()=>{})}function jE(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=TE(t.conversationId);return n.mutationVersion+=1,DE(n,t),t.conversationId}function ME(e){if(!e||typeof e!=`object`||!(`conversationId`in e)||typeof e.conversationId!=`string`)return null;let t=TE(e.conversationId);return t.mutationVersion+=1,t.clearVersion+=1,t.items=[],e.conversationId}function NE(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&&kE(t,!0);let e=e=>{jE(e.detail)===t&&c()},n=e=>{ME(e.detail)===t&&c()},r=()=>{t&&kE(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&&!Rn(e)&&AE(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=OE(t);if(a.length===0)return!1;let o=s.current,c=n.current,l=c?zp(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 PE(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 FE(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 IE(e){let t=(0,Q.useRef)(e);t.current=e;let{chat:n,runBusy:r,voiceActive:i,cancelVoiceInput:a,editingFollowUpId:o,getTextValue:s,getAttachmentCount:c,wireAttachmentsPayload:l,getContextRefs:u,getThinkingLevel:d,onSend:f,onDispatched:p,onAddPendingFollowUp:m,onSteeringInterrupt:h,onCommitEditFollowUp:g,onPendingFollowUpRemove:_,pendingFollowUpsCount:v,resetEditor:y,clearAttachments:b,clearContextRefs:x,clearEditFollowUpRef:S,onUserTextCommitted:C}=e,w={getTextValue:s,getAttachmentCount:c,wireAttachmentsPayload:l,getContextRefs:u},T=(0,Q.useRef)(!1),E=(0,Q.useRef)(!1),D=(0,Q.useRef)(()=>{}),O=(0,Q.useRef)(!1),k=(0,Q.useCallback)(()=>{let n=performance.now(),r=PE(t.current);if(r===`blocked`)return;if(r===`queue`){D.current();return}let s=FE({voiceActive:i,cancelVoiceInput:a,...w});if(!s)return;if(r===`saveFollowUp`){if(O.current||!o)return;O.current=!0,Promise.resolve().then(()=>g(o,s.text,s.attachments,d(),s.contextRefs)).then(n=>{if(n===!1)return;C?.(s.text);let r=t.current;r.draftScope!==e.draftScope||r.editingFollowUpId!==o||r.getTextValue()!==s.text||JSON.stringify(r.wireAttachmentsPayload())!==JSON.stringify(s.attachments)||JSON.stringify(r.getContextRefs())!==JSON.stringify(s.contextRefs)||(r.onFinishFollowUpEdit?.(),S())}).catch(e=>ba(`error`,e instanceof Error?e.message:String(e))).finally(()=>{O.current=!1});return}let c=[s.text,s.attachments.length>0?s.attachments:void 0,d(),s.contextRefs.length>0?s.contextRefs:void 0,{submittedAt:n,onDispatched:e=>p?.(e,s)}];WT(f(...c),n=>{C?.(s.text,n);let i=t.current,a=e.draftScope,o=i.draftScope;if(!(!(r===`send`&&a?.conversationId===null&&n!==void 0&&o?.conversationId===n&&o.gatewayIdentity===a.gatewayIdentity)&&o!==a||i.getTextValue()!==s.text||JSON.stringify(i.wireAttachmentsPayload())!==JSON.stringify(s.attachments)||JSON.stringify(i.getContextRefs())!==JSON.stringify(s.contextRefs))){if(r===`replaceTurn`){i.editingUserTurnId===e.editingUserTurnId&&i.onFinishUserEdit?.();return}y(),b(),x()}})},[r,o,g,S,i,a,f,p,e.editingUserTurnId,e.draftScope,d,C,y,b,x,s,c,l,u]),A=(0,Q.useCallback)(async(o=!e.personal&&void 0,s=e.personal?`steer`:void 0)=>{if(t.current.editingFollowUpId||t.current.editingUserTurnId){k();return}if(!r&&v===0)return;let c=FE({voiceActive:i,cancelVoiceInput:a,...w});if(c&&!t.current.blocked&&m&&!T.current){if(v>=10){ba(`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){ba(`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=FE({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=>ba(`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 LE=e=>e?.kind===`editTurn`?`turn:${e.turnId}`:e?.kind===`editFollowUp`?`input:${e.inputId}:${e.version}`:`compose`,RE=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),zE=new Map;function BE(e,t){let n=(zE.get(e)??Promise.resolve()).catch(()=>{}).then(t);zE.set(e,n);let r=()=>{zE.get(e)===n&&zE.delete(e)};return n.then(r,r),n}function VE(e,t,n,r,i,a,o,s){let c=LE(a?.snapshot().mode),l=_(e=>e.conversationId),u=l&&e?JSON.stringify([l,e]):``,d=(0,Q.useRef)({editor:t,attachments:n,refs:r,setRefs:i,editSession:a});d.current={editor:t,attachments:n,refs:r,setRefs:i,editSession:a};let f=(0,Q.useRef)(void 0),p=(0,Q.useRef)(void 0),[m,h]=(0,Q.useState)(0);(0,Q.useLayoutEffect)(()=>{let t=p.current;p.current={identity:l,id:e,unboundDraftKey:o};let n=t?.identity===l&&t?.id===null&&!!e&&e===s?.(),r=t&&(t.identity!==l||t.id!==e||t.unboundDraftKey!==o)&&!n;if(r&&(d.current.editor.resetEditor(),d.current.attachments.clearAttachments(),d.current.setRefs([])),!u||!e){f.current=void 0;return}let i={receipts:[],scope:u,ready:!1,dirty:!1,observe:!1,snapshot:{text:d.current.editor.valueRef.current,attachments:d.current.attachments.attachmentsRef.current,refs:r?[]:d.current.refs,editSession:d.current.editSession?.snapshot()},storage:Ir(e)};f.current=i;let a=!1,c=zE.get(u);return(c?c.catch(()=>{}).then(()=>i.storage.read()):i.storage.read()).then(e=>{if(a=!0,f.current!==i)return;i.receipts=e?.intakeReceipts??[];let t=d.current;e&&!i.dirty&&!t.editor.valueRef.current&&!t.attachments.attachmentsRef.current.length&&!t.refs.length&&(t.editor.resetEditor({nextText:e.text}),t.attachments.setAttachments(e.attachments),t.setRefs(e.refs),e.editSession&&t.editSession?.restore(e.editSession))}).catch(e=>{console.warn(`Composer draft restoration failed`,e)}).finally(()=>{f.current===i&&(i.ready=a,a&&d.current.editSession?.ready?.(),h(e=>e+1))}),()=>{f.current===i&&(f.current=void 0)}},[u,e,l,o,s]),(0,Q.useLayoutEffect)(()=>{let e=f.current;if(!e||e.scope!==u)return;if(!e.observe){e.observe=!0;return}let i={text:t.value,attachments:n.attachments,refs:r,editSession:d.current.editSession?.snapshot()};(i.text!==e.snapshot.text||!RE(i.attachments,e.snapshot.attachments)||!RE(i.refs,e.snapshot.refs)||LE(i.editSession?.mode)!==LE(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,m,t.value,n.attachments,r,c]),(0,Q.useEffect)(()=>{let e=f.current;if(!(!e?.ready||!u))return Xs(u,async(t,n)=>{if(await zE.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,m])}function HE(e){let{conversationId:t,agentId:n,modelKey:r,locale:i,enabled:a,draftText:o,canShow:s}=e,c=_(e=>e.conversationId),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(null),p=(0,Q.useRef)(null),m=(0,Q.useRef)(o),v=(0,Q.useRef)(-1),y=(0,Q.useCallback)((e,t,n)=>{h(g(`/api/sessions/${encodeURIComponent(e.suggestion.conversationId)}/next-turn-suggestion-feedback`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({suggestionId:e.suggestion.id,impressionId:e.impressionId,event:t,...n===void 0?{}:{edited:n}})}).catch(()=>{})},[]);(0,Q.useEffect)(()=>{m.current.length>0&&o.length===0&&(p.current=null),m.current=o},[o]),(0,Q.useEffect)(()=>{p.current=null,v.current=-1,u(null),f(null)},[t,n,r,i,c]),(0,Q.useEffect)(()=>{if(u(null),!a||!t)return;let e=!1,r=0,o,s=0,c=new AbortController,l=async()=>{let a=++r;try{if(await Lr(t))return;let d=await h(g(`/api/sessions/${encodeURIComponent(t)}/next-turn-suggestion?locale=${i}`),{signal:c.signal});if(!d.ok)return;let f=Vs.safeParse(await d.json());if(e||a!==r||!f.success)return;let p=f.data.suggestion;if(f.data.status===`ready`&&p&&p.conversationId===t&&p.locale===i&&(!n||p.agentId===n)&&p.inputRevision>=v.current&&p.expiresAt>Date.now()&&p.transcriptId===await jr(t)){if(e||a!==r)return;u(e=>e?.suggestion.id===p.id?e:{suggestion:p,impressionId:crypto.randomUUID()}),o=setTimeout(()=>{u(null)},Math.max(0,p.expiresAt-Date.now()))}else u(null),f.data.status===`pending`&&s++<7&&(o=setTimeout(()=>{l()},600))}catch{}},d=e=>{let n=e.detail;if(!(n?.conversationId!==t&&n?.key!==t)){if(typeof n.revision==`number`){if(n.revision<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()}},f=()=>{r++,s=0,o&&clearTimeout(o),u(null),l()},p=e=>{e.detail?.topic===`sessions`&&f()};l();let m=[`session-next-turn-suggestion-changed`,`session-input-state`,`session-updated`,`session-transcript-updated`];return m.forEach(e=>window.addEventListener(e,d)),window.addEventListener(`gateway-realtime-connected`,f),window.addEventListener(`config-reload`,f),window.addEventListener(`realtime-gap`,p),()=>{e=!0,r++,c.abort(),o&&clearTimeout(o),m.forEach(e=>window.removeEventListener(e,d)),window.removeEventListener(`gateway-realtime-connected`,f),window.removeEventListener(`config-reload`,f),window.removeEventListener(`realtime-gap`,p)}},[t,n,r,i,c,a]);let b=a&&s&&o.length===0&&l?.suggestion.id!==d&&l?.suggestion.conversationId===t&&l.suggestion.expiresAt>Date.now()?l:null,x=(0,Q.useCallback)(()=>{b&&y(b,`shown`)},[b,y]),S=(0,Q.useCallback)(()=>b?(p.current=b,y(b,`accepted`),b.suggestion.prompt):null,[b,y]),C=(0,Q.useCallback)(()=>{b&&(f(b.suggestion.id),y(b,`dismissed`))},[b,y]),w=(0,Q.useCallback)(e=>{let n=p.current;!n||n.suggestion.conversationId!==t||(f(n.suggestion.id),y(n,`submitted`,e.trim()!==n.suggestion.prompt),p.current=null)},[t,y]);return{suggestion:b?.suggestion??null,shown:x,accept:S,dismiss:C,submitted:w}}function UE(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,GE=`xopc.atMention.recent:`;function KE(e){return`${GE}${e.trim()}`}function qE(e){let t=e?.trim();if(!t||typeof localStorage>`u`)return[];try{let e=localStorage.getItem(KE(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 JE(e,t){let n=e?.trim(),r=t.trim();if(!(!n||!r||typeof localStorage>`u`))try{let e=[r,...qE(n).filter(e=>e!==r)].slice(0,WE);localStorage.setItem(KE(n),JSON.stringify(e))}catch{}}var YE=150,XE=[`file`,`note`,`session`,`browser_tab`,`skill`,`agent`];function ZE(e){let t={items:[],loading:e,error:null};return{file:{...t},note:{...t},session:{...t},skill:{...t},agent:{...t},browser_tab:{...t}}}function QE(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 $E(e){return e.replace(/[\\\s]/gu,e=>`\\${e}`)}function eD(e){let t=e.trim();return t.length>0&&t.endsWith(`/`)&&!/^https?:\/\//i.test(t)}function tD(e){return e.replace(/\/+$/,``).trim()}function nD(e){let t=e.replace(/\/+$/,``);if(!t)return``;let n=t.lastIndexOf(`/`);return n<=0?``:t.slice(0,n)}function rD(e,t){return t===0?0:Math.min(e,t-1)}function iD(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 aD(e,t,n){let r=(0,X.c)(55),i=n.capabilities??yp,[a,o]=(0,Q.useState)(0),[s,c]=(0,Q.useState)(uD),l=(0,Q.useRef)(0),u=v(lD),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=QE(e,t),r[0]=t,r[1]=e,r[2]=i):i=r[2],d=i}let f=d,p=f!==null,[m]=Za(p?f.query:``,YE),h=p?m:``,g;r[3]===n.conversationId?g=r[4]:(g=n.conversationId?.trim()??``,r[3]=n.conversationId,r[4]=g);let _=g,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]!==_||r[10]!==h||r[11]!==u||r[12]!==n||r[13]!==p||r[14]!==b?(x=()=>{let e=l.current+=1;if(!p){c(ZE(!1));return}if(!_){c(ZE(!!n.prepareSession)),n.prepareSession&&n.prepareSession().catch(()=>{l.current===e&&c(ZE(!1))});return}let t={conversationId:_,currentAgentId:n.currentAgentId,language:u,selectedContextKeys:new Set(b?b.split(`\0`):[]),recentPaths:new Set(qE(_))};if(eD(h)){let t=ZE(!1);t.file={items:[],loading:!0,error:null},c(t);let r=tD(h);qw(r,{conversationId:_,agentId:n.currentAgentId}).then(t=>{if(l.current!==e)return;let n={id:`browse-up:${r}`,kind:`file`,name:`..`,description:nD(r)||`/`,relativePath:``,isDirectory:!0,isBrowseUp:!0};c(e=>({...e,file:{items:[n,...t.map(iD)],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(ZE(!0));for(let n of Xw.filter(e=>(e.kind!==`skill`||i.skills)&&(e.kind!==`agent`||i.agentSwitch)))n.search(h,t).then(t=>{l.current===e&&c(e=>({...e,[n.kind]:{items:t,loading:!1,error:null}}))}).catch(t=>{l.current===e&&c(e=>({...e,[n.kind]:{items:[],loading:!1,error:t instanceof Error?t.message:String(t)}}))})},r[7]=i.agentSwitch,r[8]=i.skills,r[9]=_,r[10]=h,r[11]=u,r[12]=n,r[13]=p,r[14]=b,r[15]=x):x=r[15];let S;r[16]!==i.agentSwitch||r[17]!==i.skills||r[18]!==_||r[19]!==h||r[20]!==u||r[21]!==n.currentAgentId||r[22]!==n.prepareSession||r[23]!==p||r[24]!==b?(S=[p,_,h,u,n.currentAgentId,n.prepareSession,b,i.skills,i.agentSwitch],r[16]=i.agentSwitch,r[17]=i.skills,r[18]=_,r[19]=h,r[20]=u,r[21]=n.currentAgentId,r[22]=n.prepareSession,r[23]=p,r[24]=b,r[25]=S):S=r[25],(0,Q.useEffect)(x,S);let C;if(r[26]!==i.agentSwitch||r[27]!==i.skills||r[28]!==s){let e;r[30]!==i.agentSwitch||r[31]!==i.skills?(e=e=>(e!==`skill`||i.skills)&&(e!==`agent`||i.agentSwitch),r[30]=i.agentSwitch,r[31]=i.skills,r[32]=e):e=r[32];let t;r[33]===s?t=r[34]:(t=e=>({kind:e,...s[e]}),r[33]=s,r[34]=t),C=XE.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(cD):[],E;r[35]!==p||r[36]!==w?(E=p&&w.some(sD),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(oD),r[38]=w,r[39]=O);let k=O,A=!D&&T.length===0?k[0]??null:null,j=`${f?.start??``}:${f?.end??``}:${h}`,M;r[40]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>o(0),r[40]=M):M=r[40];let N;r[41]===j?N=r[42]:(N=[j],r[41]=j,r[42]=N),(0,Q.useEffect)(M,N);let P=rD(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 oD(e){return e.error?[e.error]:[]}function sD(e){return e.loading}function cD(e){return e.items}function lD(e){return e.language}function uD(){return ZE(!1)}function dD(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 fD(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??yp,D=(0,Q.useMemo)(()=>QE(n,r),[n,r]),O=dE(n,r,{suppress:D!=null,capabilities:E,isComposing:i,currentAgentId:m,conversationId:t}),k=aD(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`||ZT(e,j())},[j,E]),N=(0,Q.useCallback)(e=>{let n=k.atRange;if(!n)return;let r=dD(e);if(r){let i=_(r);if(!i?.refId)return;let a=`${Xn(i.refId)} `,o=qT(c.current,n.start,n.end,a);l({nextText:o,caretOffset:n.start+a.length,focus:!0}),t&&e.kind===`file`&&JE(t,e.relativePath);return}if(e.kind===`skill`){if(!E.skills)return;let t=`/skill:${e.canonicalName} `,r=qT(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=qT(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=`@${$E(e.isBrowseUp?(()=>{let e=nD(tD(n.query));return e?`${e}/`:``})():`${e.relativePath.replace(/\/+$/,``)}/`)}`,a=qT(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]);UE({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 ee=(0,Q.useRef)(M);ee.current=M;let V=(0,Q.useRef)(N);V.current=N;let H=(0,Q.useRef)({runBusy:a,pendingFollowUpsCount:S,maxPendingFollowUps:C});H.current={runBusy:a,pendingFollowUpsCount:S,maxPendingFollowUps:C};let U=(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=qT(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&&V.current(n),!0}return!1}}),[l,F]),W=(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||rE(n,H.current)||ee.current(n),!0}}if(e.key===`Escape`){e.preventDefault();let n=t.slashRange;if(n){let e=F.current,t=qT(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)(()=>[U,W],[U,W]),applyPalette:M,applyAtMention:N}}function pD(e){return/^[A-Za-z0-9._/@:-]+$/.test(e)?e:JSON.stringify(e)}function mD(e,t){let n=t?.trim();return n?`${e} --instructions ${pD(n)}`:e}function hD(e){if(e.preset===`base`){if(!e.baseBranch?.trim())throw Error(`Missing base branch.`);return mD(`/review --base ${pD(e.baseBranch.trim())}`,e.instructions)}if(e.preset===`commit`){if(!e.commitSha?.trim())throw Error(`Missing commit SHA.`);return mD(`/review --commit ${pD(e.commitSha.trim())}`,e.instructions)}return e.preset,mD(`/review --uncommitted`,e.instructions)}async function gD(e){let t=await h(g(`/api/review/context?${new URLSearchParams({conversationId:e}).toString()}`)),n=await t.json().catch(()=>({}));if(!t.ok||!n.ok||!n.payload)throw Error(x(t.status,t.statusText,n.error?.message));return n.payload}function _D(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 vD(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 yD(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 bD(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`,la.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 xD(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,b]=(0,Q.useState)(``),x;t[0]!==r||t[1]!==c.noSession?(x=()=>{if(!r){u(null),m(c.noSession);return}f(!0),m(null),gD(r).then(e=>u(e)).catch(e=>{u(null),m(e instanceof Error?e.message:String(e))}).finally(()=>f(!1))},t[0]=r,t[1]=c.noSession,t[2]=x):x=t[2];let S=x,w,E;t[3]!==S||t[4]!==n?(w=()=>{n&&(g(`presets`),v(``),b(``),S())},E=[S,n],t[3]=S,t[4]=n,t[5]=w,t[6]=E):(w=t[5],E=t[6]),(0,Q.useEffect)(w,E);let j;t[7]!==l||t[8]!==_?(j=vD(l,_),t[7]=l,t[8]=_,t[9]=j):j=t[9];let M=j,N;t[10]!==l||t[11]!==_?(N=yD(l,_),t[10]=l,t[11]=_,t[12]=N):N=t[12];let F=N,I;t[13]!==l||t[14]!==c?(I=_D(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=hD({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,ee;t[20]===o?ee=t[21]:(ee=e=>!e&&o(),t[20]=o,t[21]=ee);let V;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,Z.jsx)(C,{className:`xopc-dialog-overlay fixed inset-0 z-[120] bg-scrim backdrop-blur-[1px]`}),t[22]=V):V=t[22];let H;t[23]!==c.back||t[24]!==h?(H=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)(P,{className:`size-4`})}),t[23]=c.back,t[24]=h,t[25]=H):H=t[25];let U;t[26]===B?U=t[27]:(U=(0,Z.jsx)(k,{className:`truncate text-sm font-semibold text-fg`,children:B}),t[26]=B,t[27]=U);let W=l?.cwd??c.description,te;t[28]===W?te=t[29]:(te=(0,Z.jsx)(T,{className:`truncate text-xs text-fg-muted`,children:W}),t[28]=W,t[29]=te);let ne;t[30]!==U||t[31]!==te?(ne=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[U,te]}),t[30]=U,t[31]=te,t[32]=ne):ne=t[32];let re;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,Z.jsx)(Xt,{className:`size-4`}),t[33]=re):re=t[33];let ie;t[34]!==c.close||t[35]!==o?(ie=(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:re}),t[34]=c.close,t[35]=o,t[36]=ie):ie=t[36];let ae;t[37]!==H||t[38]!==ne||t[39]!==ie?(ae=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-4 py-3`,children:[H,ne,ie]}),t[37]=H,t[38]=ne,t[39]=ie,t[40]=ae):ae=t[40];let oe;t[41]!==M||t[42]!==F||t[43]!==l||t[44]!==i||t[45]!==p||t[46]!==y||t[47]!==S||t[48]!==d||t[49]!==c.customDescription||t[50]!==c.customPlaceholder||t[51]!==c.defaultBadge||t[52]!==c.errorTitle||t[53]!==c.loading||t[54]!==c.localBadge||t[55]!==c.noBranches||t[56]!==c.noCommits||t[57]!==c.presetBase||t[58]!==c.presetBaseDescription||t[59]!==c.presetBaseDescriptionNoDefault||t[60]!==c.presetCommit||t[61]!==c.presetCommitDescription||t[62]!==c.presetCustom||t[63]!==c.presetCustomDescription||t[64]!==c.presetUncommitted||t[65]!==c.remoteBadge||t[66]!==c.retry||t[67]!==c.searchBranches||t[68]!==c.searchCommits||t[69]!==_||t[70]!==z||t[71]!==L||t[72]!==h?(oe=(0,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)(Pt,{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)(vi,{type:`button`,className:`mt-4 h-9 rounded-lg`,variant:`secondary`,onClick:S,children:[(0,Z.jsx)(Pt,{className:`size-4`}),c.retry]})]}):h===`presets`?(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Z.jsx)(bD,{icon:(0,Z.jsx)(Fe,{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)(bD,{icon:(0,Z.jsx)(Ye,{className:`size-4`}),title:c.presetUncommitted,description:L,disabled:i,onClick:()=>z(`uncommitted`)}),(0,Z.jsx)(bD,{icon:(0,Z.jsx)(xs,{className:`size-4`}),title:c.presetCommit,description:c.presetCommitDescription.replace(`{{count}}`,String(l?.commits.length??0)),disabled:i,onClick:()=>g(`commit`)}),(0,Z.jsx)(bD,{icon:(0,Z.jsx)(Ye,{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)(SD,{value:_,placeholder:c.searchBranches,onChange:v}),(0,Z.jsx)(`div`,{className:`grid gap-1`,children:M.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}):M.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)(SD,{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=>b(e.target.value)}),(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:c.customDescription})]})}),t[41]=M,t[42]=F,t[43]=l,t[44]=i,t[45]=p,t[46]=y,t[47]=S,t[48]=d,t[49]=c.customDescription,t[50]=c.customPlaceholder,t[51]=c.defaultBadge,t[52]=c.errorTitle,t[53]=c.loading,t[54]=c.localBadge,t[55]=c.noBranches,t[56]=c.noCommits,t[57]=c.presetBase,t[58]=c.presetBaseDescription,t[59]=c.presetBaseDescriptionNoDefault,t[60]=c.presetCommit,t[61]=c.presetCommitDescription,t[62]=c.presetCustom,t[63]=c.presetCustomDescription,t[64]=c.presetUncommitted,t[65]=c.remoteBadge,t[66]=c.retry,t[67]=c.searchBranches,t[68]=c.searchCommits,t[69]=_,t[70]=z,t[71]=L,t[72]=h,t[73]=oe):oe=t[73];let se;t[74]!==i||t[75]!==c.cancel||t[76]!==c.runReview||t[77]!==o||t[78]!==z||t[79]!==h?(se=h===`custom`?(0,Z.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-4 py-3`,children:[(0,Z.jsx)(vi,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg`,onClick:o,children:c.cancel}),(0,Z.jsx)(vi,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,disabled:i,onClick:()=>z(`custom`),children:c.runReview})]}):null,t[74]=i,t[75]=c.cancel,t[76]=c.runReview,t[77]=o,t[78]=z,t[79]=h,t[80]=se):se=t[80];let ce;t[81]!==ae||t[82]!==oe||t[83]!==se?(ce=(0,Z.jsxs)(D,{children:[V,(0,Z.jsxs)(O,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[121] flex h-[min(86vh,34rem)] w-[min(100vw-2rem,40rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:[ae,oe,se]})]}),t[81]=ae,t[82]=oe,t[83]=se,t[84]=ce):ce=t[84];let le;return t[85]!==n||t[86]!==ce||t[87]!==ee?(le=(0,Z.jsx)(A,{open:n,onOpenChange:ee,children:ce}),t[85]=n,t[86]=ce,t[87]=ee,t[88]=le):le=t[88],le}function SD(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)(Lt,{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 CD(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 wD=(0,Q.memo)(function({personal:e=!1,placeholder:t,nextTurnSuggestionsEnabled:n=!1,disabled:r,sendDisabled:i=!1,sending:a,streaming:o,conversationId:s,composerContext:c,pageContextPreview:l,contextRefs:u,setContextRefs:d,onDraftAttachmentsChange:p,thinkingLevel:m,modelSupportsThinking:h,onThinkingChange:g,onSend:y,onPersonalSendDispatched:b,onAbort:x,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:ee,modelDisabled:V,onChatAgentChange:H,currentAgentId:U,voiceAgentName:W,voiceTaskId:te,voiceMode:ne,prepareVoiceSession:re,prepareContextSession:ie,unboundDraftKey:ae,getDraftHandoffTarget:oe,editingUserTurnId:se,composerMode:ce,inputControl:le,onResumeQueue:ue,onRestoreEditor:de,onReacquireEdit:G,onComposerHydrated:K,onCancelUserMessageEdit:fe}){let q=xa(),pe=(0,Q.useRef)(!1);r||=q.conversationId===s&&q.active;let me=v(e=>e.language),J=S(me),[he,ge]=f();(0,Q.useEffect)(()=>{Ao()},[]);let _e=(...e)=>{if(i)return!1;let t=y(...e);return t instanceof Promise?t.then(t=>(t!==!1&&ot.submitted(e[0]),t)):(t!==!1&&ot.submitted(e[0]),t)},ve=(0,Q.useRef)(!1),ye=(0,Q.useRef)(null),be=(0,Q.useRef)(null),xe=(0,Q.useRef)(null),Se=(0,Q.useRef)(!1),[Ce,we]=(0,Q.useState)(!1),[Te,Ee]=(0,Q.useState)(null),[De,Oe]=(0,Q.useState)(null),[ke,Ae]=(0,Q.useState)(!1),je=(0,Q.useRef)(_e),Ne=(0,Q.useRef)(m);je.current=_e,Ne.current=m,(0,Q.useEffect)(()=>{if(!s||De===s){Ee(null);return}let e=!1;return Lr(s).then(e=>e?null:Po(s)).then(t=>{e||Ee(t&&t.required&&!t.trusted&&t.decision===null?t:null)}).catch(()=>{e||Ee(null)}),()=>{e=!0}},[s,De]);let Pe=(0,Q.useCallback)(()=>{!s||ke||(Ae(!0),Eo(s,!0).then(()=>{Ee(null)}).catch(e=>{ba(`error`,J.chat.commandPalette.workspaceTrustFailed,{error:e instanceof Error?e.message:String(e)})}).finally(()=>Ae(!1)))},[J.chat.commandPalette,s,ke]),Fe=wo({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})))}),Ie=(0,Q.useRef)(u);Ie.current=u;let Le=(0,Q.useCallback)(e=>{let t=u.find(t=>t.refId===e);return t?{title:t.title,kind:t.kind,fileKind:t.fileKind}:void 0},[u]),Re=(0,Q.useCallback)(e=>{let t=e?.contextRefs??[];if(Ie.current=t,d(t),e?.attachments){Fe.setAttachments(e.attachments.map(CD));return}Fe.clearAttachments()},[Fe.clearAttachments,Fe.setAttachments,d]),ze=(0,Q.useCallback)(e=>{let t=Ie.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 Ie.current=i,d(i),r}if(t.length>=5)return ba(`warning`,J.chat.commandPalette.contextLimitReached,{max:5}),null;let r=[...t,e];return Ie.current=r,d(r),e},[J.chat.commandPalette.contextLimitReached,d]);(0,Q.useEffect)(()=>{let e=e=>{let t=e.detail;t?.conversationId!==s||t.reference.kind!==`result`||ze(t.reference)};return window.addEventListener(`chat-result-reference`,e),()=>window.removeEventListener(`chat-result-reference`,e)},[s,ze]);let Be=(0,Q.useCallback)(e=>{let t=e.availability.status===`agent-denied`?J.chat.commandPalette.skillAgentDeniedReason:J.chat.commandPalette.skillDisabledReason,n=bm(J.chat.commandPalette.skillUnavailableMessage,{name:e.name,agent:U||`main`,reason:t});if(e.availability.status===`agent-denied`&&window.confirm(`${n}\n\n${J.chat.commandPalette.skillAddToAllowlistConfirm}`)){Fo(U,e.canonicalName,s).catch(e=>{window.alert(e instanceof Error?e.message:String(e))});return}window.alert(n)},[U,J.chat.commandPalette,s]),Ve=hm({capabilities:e?bp:yp,disabled:r,agentId:U,conversationId:s,autoFocusKey:s,welcomeDraftSeed:I,onExternalTextReplace:Re,shouldSyncSelectionRef:ve,resolveContextRef:Le}),He=he.get(`attachmentHandoff`);(0,Q.useEffect)(()=>{if(!He)return;let e=Me(He);ge(e=>{let t=new URLSearchParams(e);return t.delete(`attachmentHandoff`),t},{replace:!0}),e&&Fe.processFiles([e]).then(()=>Ve.editorRef.current?.focus({preventScroll:!0}))},[He,Fe.processFiles,Ve.editorRef,s,ge]);let{onUserTextCommitted:Ue,onWireInputClearWalk:We,tryInputHistoryArrow:Ge}=NE({conversationId:s,editorRef:Ve.editorRef,valueRef:Ve.valueRef,resetEditor:Ve.resetEditor,onWireInput:Ve.onWireInput}),Ke=(0,Q.useCallback)((e,t)=>{We(e,t);let n=Rn(e),r=new Set(n?Bn(n):[]),i=Ie.current,a=i.filter(e=>!e.refId||r.has(e.refId));a.length!==i.length&&(Ie.current=a,d(a))},[We,d]),qe=$f(s??``),Je=a||o||qe||le?.phase===`running`||le?.phase===`stopping`;Se.current=Je;let Ye=(0,Q.useCallback)(()=>{Se.current||we(!0)},[]),Xe=(0,Q.useCallback)(e=>{WT(je.current(e,void 0,Ne.current,u),t=>{Ue?.(e,t),d([])})},[u,Ue,d]),Ze=fD({capabilities:e?bp:yp,conversationId:s,editorValue:Ve.value,editorCursor:Ve.cursor,isComposing:Ve.isComposing,runBusy:Je,thinkingLevel:m,editorRef:Ve.editorRef,valueRef:Ve.valueRef,resetEditor:Ve.resetEditor,clearAttachments:Fe.clearAttachments,onSend:_e,onUserTextCommitted:Ue,onChatAgentChange:H,currentAgentId:U,prepareSession:ie,contextRefs:u,onAddContextRef:ze,onUnavailableSkill:Be,onReviewLauncher:Ye,onAddPendingFollowUp:C,onAbort:x,pendingFollowUpsCount:T.length,maxPendingFollowUps:10,clearContextRefs:()=>d([]),commandPalettePanelRef:ye});ve.current=Ze.shouldSyncSelection;let Qe=va({disabled:r||q.active,chat:J.chat,onTranscript:e=>{let t=Ve.valueRef.current,n=ji(t,e);Ve.resetEditor({nextText:n,caretOffset:n.length,focus:!0})}}),{phase:$e,voiceActive:et,startVoiceInput:tt,cancelVoiceInput:nt,confirmVoiceInput:rt}=Qe;(0,Q.useEffect)(()=>{let e=e=>{if(!yT(e,{disabled:r,editorHidden:et&&$e!==`error`}))return;let t=om(e.clipboardData);t&&(e.preventDefault(),Ve.focusForExternalPaste(),sm(t,{processFiles:Fe.processFiles,processPastedText:Fe.processPastedText,insertText:e=>document.execCommand(`insertText`,!1,e),onUnsupportedFiles:()=>ba(`warning`,J.chat.clipboardFileTypeUnsupported)}))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[Fe.processFiles,Fe.processPastedText,r,Ve.focusForExternalPaste,J.chat.clipboardFileTypeUnsupported,et,$e]),(0,Q.useEffect)(()=>{let e=e=>{let t=e?.detail?.target;if(!(t&&t!==`chat`)&&(e?.preventDefault(),!r)){if($e===`recording`){rt();return}($e===`idle`||$e===`error`)&&(Ve.editorRef.current?.focus({preventScroll:!0}),tt())}},t=e=>{let t=e.detail?.target;t&&t!==`chat`||!et||(e.preventDefault(),nt(),Ve.editorRef.current?.focus({preventScroll:!0}))};window.addEventListener(zo,e),window.addEventListener(Lo,t);let n=window.setTimeout(()=>{if(Bo()){if(r){Ro();return}e()}},0);return()=>{window.clearTimeout(n),window.removeEventListener(zo,e),window.removeEventListener(Lo,t)}},[nt,rt,r,Ve.editorRef,tt,et,$e]);let it=(0,Q.useCallback)(()=>{xe.current=null},[]),at=n&&!r&&!i&&!Je&&!E&&!se&&!Qe.voiceActive&&!Ve.isComposing&&Ve.value.length===0&&Fe.attachments.length===0&&u.length===0&&T.length===0,ot=HE({conversationId:s,agentId:U,modelKey:z,locale:me,enabled:n,draftText:Ve.value,canShow:at}),st=()=>{if(!at||Ve.valueRef.current.length>0||Ie.current.length>0)return!1;let e=ot.accept();return e?(Ve.resetEditor({nextText:e,focus:!0}),!0):!1};(0,Q.useEffect)(()=>{at&&ot.suggestion&&!Ze.palette.open&&ot.shown()},[at,ot.suggestion,ot.shown,Ze.palette.open]);let ct=_(e=>e.conversationId),lt=(0,Q.useMemo)(()=>({gatewayIdentity:ct,conversationId:s,unboundDraftKey:ae}),[ct,s,ae]),ut=(0,Q.useRef)(new Map),dt=(0,Q.useRef)(`compose`),ft=ce??(E?{kind:`editFollowUp`,inputId:E,version:0}:{kind:`compose`}),pt=ft.kind===`editTurn`?`turn:${ft.turnId}`:ft.kind===`editFollowUp`?`input:${ft.inputId}`:`compose`;(0,Q.useLayoutEffect)(()=>{ut.current.clear(),dt.current=`compose`},[lt]),VE(s,Ve,Fe,u,d,{ready:K,snapshot:()=>({mode:ft,drafts:Object.fromEntries(ut.current)}),restore:e=>{ut.current=new Map(Object.entries(e.drafts)),dt.current=e.mode.kind===`editTurn`?`turn:${e.mode.turnId}`:e.mode.kind===`editFollowUp`?`input:${e.mode.inputId}`:`compose`,de?.(e.mode)}},ae,oe);let mt=ft.kind!==`compose`&&!!(le&&!le.paused),ht=IE({personal:e,chat:J.chat,runBusy:Je,draftScope:lt,queuePaused:le?.paused,editingUserTurnId:se,blocked:r||i||mt||le?.phase===`stopping`,onFinishUserEdit:fe,onFinishFollowUpEdit:O,voiceActive:Qe.voiceActive,cancelVoiceInput:Qe.cancelVoiceInput,editingFollowUpId:E,getTextValue:()=>Ve.valueRef.current,getAttachmentCount:()=>Fe.attachmentsRef.current.length,wireAttachmentsPayload:Fe.wireAttachmentsPayload,getContextRefs:()=>u,getThinkingLevel:()=>Ne.current,onSend:_e,onDispatched:e&&b?(e,t)=>{let n=Ve.editorRef.current?.getBoundingClientRect();n&&b(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:()=>{Ve.resetEditor()},clearAttachments:Fe.clearAttachments,clearContextRefs:()=>d([]),clearEditFollowUpRef:it,onUserTextCommitted:Ue}),gt=(0,Q.useCallback)((e=!1)=>ht.flushSteeringDraft(e),[ht.flushSteeringDraft]),_t=(0,Q.useCallback)((e,t)=>{!s||s===`new`||Vw.getState().requestCreate(s,[{id:e.id,type:`text`,text:t,label:J.chat.followUpQueueHeading}])},[s,J.chat.followUpQueueHeading]);(0,Q.useLayoutEffect)(()=>{if(dt.current===pt)return;ut.current.set(dt.current,{text:Ve.valueRef.current,attachments:Fe.wireAttachmentsPayload(),contextRefs:Ie.current,thinkingLevel:Ne.current}),dt.current=pt;let e=ft.kind===`editFollowUp`?T.find(e=>e.id===ft.inputId):void 0;e?.thinkingLevel&&h&&g(e.thinkingLevel);let t=(ft.kind===`compose`?ft.draft:void 0)??ut.current.get(pt)??(ft.kind===`editTurn`?ft.draft:e?{text:e.text,attachments:e.attachments??[],contextRefs:e.contextRefs??[]}:void 0);t?.thinkingLevel&&h&&g(t.thinkingLevel),Fe.setAttachments(IT(t?.attachments??[])),d(t?.contextRefs??[]),Ve.resetEditor({nextText:t?.text??``,focus:!0})},[pt,ft,T,Fe,Ve,d]);let vt=(0,Q.useCallback)(e=>{D(e)},[D]),yt=(0,Q.useRef)({});yt.current={adapters:Ze.adapters,send:ht.send,runBusy:Je,pendingFollowUpsCount:T.length,flushSteeringDraft:gt,steerDraft:()=>ht.flushSteeringDraft(!1,`steer`),steerCurrentReply:ht.steerCurrentReply,interruptDraft:ht.interruptDraft,editingFollowUpId:E,editingUserTurnId:se,onCancelUserMessageEdit:fe,onCancelEditFollowUp:O,attachmentsLen:Fe.attachments.length,contextRefsLen:u.length,isComposing:Ve.isComposing,valueRef:Ve.valueRef,adjustHeight:Ve.adjustHeight,editorRef:Ve.editorRef,tryInputHistoryArrow:Ge,acceptEmptySuggestion:ot.suggestion&&at?st:!Je&&!r&&!i&&!se&&!Qe.voiceActive&&L&&R?()=>(R(L),!0):void 0,dismissEmptySuggestion:ot.suggestion?ot.dismiss:void 0};let bt=Je&&!E&&!se,xt={...J.chat,sendMessage:E?J.chat.followUpSaveEdit:se?J.chat.userMessageReplaceSend:le?.paused?J.chat.sendThisMessage:J.chat.sendMessage},St=!!Ve.value.trim()||Fe.attachments.length>0||u.length>0,Ct=St&&!!w,wt=is(`(hover: hover) and (pointer: fine)`),Tt=!bt&&!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)(hT,{conversationId:s},s):null,c?(0,Z.jsx)(OT,{...c,conversationId:s,disabled:(c.disabled??r)||a||o}):null,(0,Z.jsxs)(ym,{className:e?`rounded-[1.65rem]`:void 0,dragging:Fe.isDragging,onDragOver:e=>{(e.dataTransfer?.types.includes(`Files`)||lp(e.dataTransfer))&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,Fe.setIsDragging(!0))},onDragLeave:e=>{e.relatedTarget===null&&Fe.setIsDragging(!1)},onDrop:async e=>{e.preventDefault(),Fe.setIsDragging(!1);let t=e.dataTransfer?.files;if(t?.length){await Fe.processFiles(Array.from(t));return}let n=up(e.dataTransfer);if(n)try{let e=await Ga(n.path,{conversationId:n.conversationId,agentId:n.agentId,projectId:n.projectId}),t=ci(n.name),r=e.type&&e.type!==`application/octet-stream`?e.type:t;await Fe.processFiles([new File([e],n.name,{type:r})])}catch{ba(`error`,J.chat.attachmentLoadFailed,{name:n.name})}},children:[Fe.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,se?(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:fe,children:J.chat.userMessageEditCancel})]}):null,mt&&(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:()=>G?.({text:Ve.valueRef.current,attachments:Fe.wireAttachmentsPayload(),contextRefs:Ie.current}),children:J.chat.editPauseAgain})]}),le?.paused&&(T.length>0||le.phase===`stopping`||ft.kind!==`compose`)&&(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:le.phase===`stopping`?J.chat.inputStopping:le.reviewRequired?J.chat.queueReviewRequired:T.length>0?J.chat.queuePausedCount.replace(`{count}`,String(T.length)):J.chat.queuePaused}),(0,Z.jsx)(`button`,{type:`button`,disabled:r||i||!!(E||se)||le.phase!==`idle`,className:`text-accent-fg disabled:opacity-40`,onClick:ue,children:J.chat.queueResume})]}),(0,Z.jsx)(TT,{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)(wT,{items:T,disabled:r||i||!!(se||E),editingFollowUpId:E,onEditInComposer:vt,onRemove:A,onMove:j,onReorder:M,onSteer:N,onSendSingle:P,queuePaused:le?.paused,queueIdle:le?.phase===`idle`,steeringBusyId:F,onOpenSideChat:s&&s!==`new`?_t:void 0})}):null,(E||se)&&(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:()=>de?.({kind:`compose`,draft:{text:Ve.valueRef.current,attachments:Fe.wireAttachmentsPayload(),contextRefs:Ie.current}}),children:J.chat.editAsNewMessage})}),ft.kind===`editFollowUp`&&T.some(e=>e.id===ft.inputId&&e.version!==ft.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===ft.inputId)?.text}),(0,Z.jsx)(`button`,{type:`button`,disabled:i,className:`text-accent-fg`,onClick:()=>D(ft.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)(So,{attachments:Fe.attachments,conversationId:s,topPadded:T.length>0,onRemove:Fe.removeAttachment}),(0,Z.jsx)(ET,{refs:u.filter(e=>!e.refId),label:J.chat.commandPalette.contextLabel,onRemove:e=>d(t=>t.filter(t=>t.sourceId!==e))}),l,(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:be,type:`file`,multiple:!0,className:`hidden`,onChange:async e=>{let t=e.target.files;t&&await Fe.processFiles(Array.from(t)),e.target.value=``}}),e&&!Qe.voiceActive&&(0,Z.jsx)(PT,{disabled:r||i,attachmentCount:Fe.attachments.length,maxAttachments:10,chat:J.chat,onPickFiles:()=>be.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`,Fe.attachments.length>0&&`pt-2`),children:[(0,Z.jsx)(UT,{open:Ze.atPicker.open,anchorRef:Ve.editorRef,items:Ze.atPicker.items,selectedIndex:Ze.atPicker.selectedIndex,loading:Ze.atPicker.loading,query:Ze.atPicker.query,noResults:Ze.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:Ze.applyAtMention}),(0,Z.jsx)(bE,{open:Ze.palette.open,anchorRef:Ve.editorRef,panelRef:ye,sections:Ze.palette.loadError?[]:Ze.palette.sections,flatItems:Ze.palette.loadError?[]:Ze.palette.flatItems,loading:Ze.palette.loading,failedKinds:Ze.palette.failedKinds,selectedIndex:Ze.palette.selectedIndex,noResults:Ze.palette.loadError??J.chat.commandPalette.noResults,sectionLoadFailedLabel:J.chat.commandPalette.sectionLoadFailed,query:Ze.palette.query,skillsLabel:J.chat.commandPalette.skillsSection,commandsLabel:J.chat.commandPalette.commandsSection,agentsLabel:J.chat.commandPalette.agentsSection,currentAgentId:U,currentBadgeLabel:J.chat.commandPalette.currentBadge,runBusy:Je,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:Ze.applyPalette}),Qe.voiceActive?(0,Z.jsx)(Pi,{phase:Qe.phase,elapsedLabel:Qe.elapsedLabel,recordedDictation:Qe.recordedDictation,audioLevel:Qe.audioLevel,partialTranscript:Qe.partialTranscript,finalTranscript:Qe.finalTranscript,error:Qe.error,settingsRequired:Qe.settingsRequired,disabled:r,chat:J.chat,onCancel:Qe.cancelVoiceInput,onConfirm:Qe.confirmVoiceInput,onRetry:Qe.retryVoiceInput}):null,(0,Z.jsx)(gm,{editorRef:Ve.editorRef,disabled:r,hidden:Qe.voiceActive&&Qe.phase!==`error`,compact:e,ariaLabel:t??J.chat.inputPlaceholder,placeholder:(at&&ot.suggestion?`${ot.suggestion.prompt}${wt?` · ${J.chat.welcomeSpotlight.acceptSuggestionHint}`:``}`:null)??t??Tt??(bt?E?J.chat.inputPlaceholderSteeringEdit:e?J.chat.inputPlaceholderPersonal:J.chat.inputPlaceholderSteering:J.chat.inputPlaceholder),onWireInput:Ke,adjustHeight:Ve.adjustHeight,processFiles:Fe.processFiles,processPastedText:Fe.processPastedText,setIsComposing:Ve.setIsComposing,kbdRef:yt,chatMessages:J.chat})]}),e?(0,Z.jsx)(FT,{disabled:r||i||mt,voiceActive:Qe.voiceActive,runBusy:bt,hasDraft:St,chat:xt,onStartVoiceInput:Qe.startVoiceInput,onSend:ht.send,onAbort:x}):(0,Z.jsx)(wm,{disabled:r,sendDisabled:i||mt,sending:a,streaming:o,runBusy:bt,chat:xt,hasDraft:St,showSteeringInterrupt:Ct,attachmentCount:Fe.attachments.length,maxAttachments:10,onPickFiles:()=>be.current?.click(),thinkingLevel:m,onThinkingChange:g,voiceActive:Qe.voiceActive,onStartVoiceInput:Qe.startVoiceInput,voiceConversationEnabled:!!(s||re),onStartVoiceConversation:()=>{if(!pe.current){if(s){q.open({conversationId:s,name:W||U||`xopc`,taskId:te,mode:ne});return}re&&(pe.current=!0,re().then(e=>{if(e)return q.open({conversationId:e,name:W||U||`xopc`,taskId:te,mode:ne})}).catch(e=>ba(`error`,e instanceof Error?e.message:J.chat.callFailed)).finally(()=>{pe.current=!1}))}},onSend:ht.send,onAbort:x,onInterrupt:ht.interruptDraft,sessionModel:z,showModelSelector:B,onModelChange:ee,modelDisabled:V})]}),(0,Z.jsx)(xD,{open:Ce,conversationId:s,disabled:r||bt,chat:J.chat,onClose:()=>we(!1),onSendCommand:Xe}),(0,Z.jsx)(Wa,{open:Te!==null,title:J.chat.commandPalette.workspaceTrustTitle,description:bm(J.chat.commandPalette.workspaceTrustDescription,{path:Te?.workspacePath??``}),confirmLabel:ke?J.chat.commandPalette.workspaceTrustSaving:J.chat.commandPalette.workspaceTrustConfirm,cancelLabel:J.chat.commandPalette.workspaceTrustCancel,onConfirm:Pe,onCancel:()=>{Ee(null),Oe(s)}})]})]})});function TD(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=v(DD),l;t[0]===c?l=t[1]:(l=S(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(ED).join(`, `),t[7]=n.envelope.resourceRefs,t[8]=m);let h;t[9]===m?h=t[10]:(h=(0,Z.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:m}),t[9]=m,t[10]=h);let g;t[11]===n.preview?g=t[12]:(g=(0,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]=g);let _;t[13]!==n.truncated||t[14]!==u.truncated?(_=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]=_):_=t[15];let y;t[16]!==n.envelope.selection||t[17]!==u.draft||t[18]!==u.selection?(y=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]=y):y=t[19];let b;t[20]!==_||t[21]!==y||t[22]!==f||t[23]!==p||t[24]!==h||t[25]!==g?(b=(0,Z.jsxs)(`details`,{className:`min-w-0 flex-1`,children:[f,p,h,g,_,y]}),t[20]=_,t[21]=y,t[22]=f,t[23]=p,t[24]=h,t[25]=g,t[26]=b):b=t[26];let x=`${u.remove}: ${n.title}`,C;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Z.jsx)(Xt,{className:`size-4`,"aria-hidden":!0}),t[27]=C):C=t[27];let w;t[28]!==o||t[29]!==r||t[30]!==x?(w=(0,Z.jsx)(`button`,{type:`button`,onClick:r,disabled:o,"aria-label":x,className:`inline-flex size-8 shrink-0 items-center justify-center rounded text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:C}),t[28]=o,t[29]=r,t[30]=x,t[31]=w):w=t[31];let T;t[32]!==b||t[33]!==w?(T=(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[b,w]}),t[32]=b,t[33]=w,t[34]=T):T=t[34];let E;t[35]!==u.pending||t[36]!==s?(E=s?(0,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 ED(e){return`${e.kind} · ${e.id} · v${e.revision}`}function DD(e){return e.language}function OD(e){let t=(0,X.c)(30),{selection:n}=e,r=v(kD)===`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)(qe,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[2]=p):p=t[2];let m=p,h;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(As,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[3]=h):h=t[3];let g=h,_=r?`运行位置`:`Work in`,y;t[4]!==l||t[5]!==u||t[6]!==s||t[7]!==_||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)(fe,{ariaLabel:r?`新会话运行位置`:`New session environment`,placeholder:_,title:r?`Local 指 xopc Gateway 所在机器;首次发送时创建所选环境。`:`Local means the machine running xopc Gateway. The selected environment is created on first send.`,triggerIcon:l?(0,Z.jsx)(Ze,{className:`size-4 shrink-0 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}):i===`managed_worktree`?g:m,triggerClassName:`h-8 w-auto max-w-full justify-start gap-1.5 rounded-full border-0 bg-surface-hover px-2.5 hover:bg-surface-active [&>svg:last-child]:hidden`,contentClassName:`xopc-composer-config-popover w-max min-w-0 max-w-[calc(100vw-1.5rem)]`,side:`top`,allowEmpty:!1,value:i,disabled:l||s,options:[{value:`local_checkout`,label:`Local`,icon:m,group:_,disabled:!a?.localAvailable},{value:`managed_worktree`,label:`New local worktree`,icon:g,group:_,disabled:!a||!!a.worktreeUnavailableReason}],onChange:e=>u(e)}),t[4]=l,t[5]=u,t[6]=s,t[7]=_,t[8]=i,t[9]=a,t[10]=r,t[11]=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)(vi,{variant:`ghost`,className:`size-8 rounded-full p-0`,disabled:l||o,onClick:d,"aria-label":r?`重新检查环境`:`Recheck environment`,children:(0,Z.jsx)(Pt,{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 kD(e){return e.language}function AD({preparation:e,conversationId:t,ready:n,onSend:r}){let i=_(e=>e.conversationId),a=_(e=>e.baseUrl),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(null),f=(0,Q.useRef)(null),p=(0,Q.useRef)(!1),m=(0,Q.useRef)(r);m.current=r;let h=(0,Q.useRef)(t);h.current=t;let{data:v,error:b,isValidating:x,mutate:S}=Qr(e?[`project-environment-options`,a,i,e.project.id]:null,async()=>(await y(g(`/api/projects/${encodeURIComponent(e.project.id)}/environment-options`))).options,{keepPreviousData:!1,revalidateOnFocus:!1,shouldRetryOnError:!1}),C=v?.localAvailable&&v.worktreeUnavailableReason!==`git_commit_required`&&v.worktreeUnavailableReason!==`workspace_unavailable`?o?.preparation===e?o.mode:e?Kr(Yr(),e.project.id)??`local_checkout`:`local_checkout`:`local_checkout`,w=!!(!b&&v?.localAvailable&&(C===`local_checkout`||!v.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=_.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;Ur(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:v,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(p.current)return!1;p.current=!0;try{let e=await D();if(!e)return!1;r=e,n[2]=void 0}finally{p.current=!1}}return!r||h.current!==r?!1:await m.current(...n)!==!1&&{conversationId:r}}}}function jD(e,t){let n=(0,X.c)(12),r=_(ND),i=_(MD),a;n[0]===e?a=n[1]:(a=t=>e?t.sessions[e]?.localDraft:void 0,n[0]=e,n[1]=a);let o=Sn(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 Lr(e):void 0,r=n?n.creation.projectId:e?(await hn(e)).projectId:t;return r?fn(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}=Qr(s,c,l);return d?null:u??null}function MD(e){return e.baseUrl}function ND(e){return e.conversationId}function PD(e,t){let n=Ba(e,t),r=Va(e,t);return`${e.id} ${n} ${r}`.toLowerCase()}function FD(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=PD(e,n);return i.every(e=>t.includes(e))})}function ID(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,h=v(RD),g;t[0]===h?g=t[1]:(g=S(h),t[0]=h,t[1]=g);let _=g.agentsSettings,[y,b]=(0,Q.useState)(!1),[x,C]=(0,Q.useState)(``),w;t[2]!==_||t[3]!==n||t[4]!==x?(w=FD(n,x,_),t[2]=_,t[3]=n,t[4]=x,t[5]=w):w=t[5];let T=w,E,D,O;if(t[6]!==_||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?Ba(D,_):r||a,O=D?[Ba(D,_),Va(D,_)].filter(Boolean).join(` — `):void 0,t[6]=_,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(wa,`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`,la.transition,`hover:border-edge hover:bg-surface-hover/45`,Ta,Ca,`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)(ja,{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)(ue,{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)(wi,{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(le,`z-50 w-[var(--radix-popover-trigger-width)] min-w-[12rem] rounded-lg border border-edge bg-surface-overlay shadow-md`,la),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`,Ta),t[35]=B):B=t[35];let ee;t[36]!==x||t[37]!==o?(ee=(0,Z.jsx)(`div`,{className:`shrink-0 border-b border-edge p-2`,children:(0,Z.jsx)(`input`,{type:`search`,value:x,onChange:z,placeholder:o,className:B,"aria-label":o})}),t[36]=x,t[37]=o,t[38]=ee):ee=t[38];let V;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(V=Y(G,`max-h-64 p-1`),t[39]=V):V=t[39];let H;t[40]!==_||t[41]!==T||t[42]!==s||t[43]!==f||t[44]!==r?(H=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=Ba(e,_),i=Va(e,_),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),b(!1),C(``)},children:[(0,Z.jsx)(ja,{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)(re,{className:Y(`size-4 shrink-0`,t?`opacity-100`:`opacity-0`),"aria-hidden":!0})]})},e.id)}),t[40]=_,t[41]=T,t[42]=s,t[43]=f,t[44]=r,t[45]=H):H=t[45];let U;t[46]===H?U=t[47]:(U=(0,Z.jsx)(`ul`,{"data-select-scroll-region":!0,className:V,role:`listbox`,children:H}),t[46]=H,t[47]=U);let W;t[48]!==m||t[49]!==p||t[50]!==ee||t[51]!==U?(W=(0,Z.jsx)(bi,{children:(0,Z.jsxs)(xi,{side:p,align:m,sideOffset:4,collisionPadding:8,className:R,onOpenAutoFocus:LD,children:[ee,U]})}),t[48]=m,t[49]=p,t[50]=ee,t[51]=U,t[52]=W):W=t[52];let te;return t[53]!==y||t[54]!==L||t[55]!==W?(te=(0,Z.jsxs)(Si,{open:y,onOpenChange:b,children:[L,W]}),t[53]=y,t[54]=L,t[55]=W,t[56]=te):te=t[56],te}function LD(e){return e.preventDefault()}function RD(e){return e.language}function zD(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 VD=`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`,HD=`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 UD({conversationId:e,draftRefs:t=[],draftAttachments:n=[],draftPage:r,project:i,...a}){let[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1),[u,f]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(!1),g=BD(v(e=>e.language)),_=d(),y=`${_.pathname}${_.search}`,{data:b,error:x,isLoading:S,isValidating:C,mutate:w}=Of(e,o),T=x?void 0:b,E=T?.work.project??(!e&&i?{id:i.id,title:i.name}:void 0),D=T?.work.task,O=T?.work.delegatedTasks??[],k=zD(T?.sources??[],t,n,r),A=T?.environment,j=!!(E||D||O.length),N=!!T?.unavailableSections.includes(`work`),P=!!T?.unavailableSections.includes(`sources`),F=!!T?.unavailableSections.includes(`environment`),I=[E?.title,D?.title,k.length?`${g.sources} ${k.length}${T?.sourcesHasMore?`+`:``}`:null,A?.kind===`managed_worktree`?`Worktree`:null].filter(Boolean).join(` · `)||g.title,L=()=>s(!1),R=k.some(e=>e.kind===`note`&&!e.unavailable&&e.origins.some(e=>e.kind===`session`)),z=()=>{A?.rootPath&&Oi(A.rootPath).then(e=>{e&&(h(!0),window.setTimeout(()=>h(!1),1200))})},B=()=>(0,Z.jsx)(`button`,{type:`button`,className:HD,"aria-label":g.refresh,disabled:C,onClick:()=>void w(),children:(0,Z.jsx)(Pt,{className:`size-3.5 ${C?`animate-spin motion-reduce:animate-none`:``}`,"aria-hidden":!0})});return(0,Z.jsxs)(Si,{open:o,onOpenChange:s,children:[(0,Z.jsx)(wi,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,"aria-label":g.title,title:I,className:`group inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-[background-color,color,transform] duration-150 hover:bg-surface-hover hover:text-fg active:scale-95 data-[state=open]:bg-surface-hover data-[state=open]:text-fg motion-reduce:transition-none motion-reduce:transform-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,Z.jsx)(Xe,{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)(bi,{children:(0,Z.jsx)(xi,{align:`end`,sideOffset:8,collisionPadding:12,"aria-label":g.title,onCloseAutoFocus:e=>{document.activeElement?.closest(`[data-primary-chat-composer]`)&&e.preventDefault()},className:`xopc-session-context-popover z-50 w-[min(23rem,calc(100vw-1.5rem))] rounded-xl border border-edge bg-surface-overlay shadow-popover`,children:(0,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:g.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:g.unavailable}),B()]}):(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`section`,{"aria-label":g.work,children:[E?(0,Z.jsxs)(p,{className:VD,to:nt(y,`/projects/${encodeURIComponent(E.id)}`),onClick:L,children:[(0,Z.jsx)(ke,{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)(p,{className:VD,to:tt(y,D.id),onClick:L,children:[(0,Z.jsx)(Ms,{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:`${VD} w-full text-left`,onClick:()=>l(!c),"aria-expanded":c,children:[(0,Z.jsx)(Ms,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,Z.jsxs)(`span`,{className:`flex-1`,children:[g.delegatedTasks,` · `,T?.work.delegatedTaskCount??O.length]}),(0,Z.jsx)(`span`,{className:`text-xs text-fg-muted`,children:c?g.collapse:g.expand})]}):(0,Z.jsxs)(`p`,{className:`px-2 pt-2 text-xs text-fg-subtle`,children:[g.delegatedTasks,` · `,T?.work.delegatedTaskCount??O.length]}),(c?O:O.slice(0,2)).map(e=>(0,Z.jsxs)(p,{className:`${VD} pl-9`,to:tt(y,e.id),onClick:L,children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.title,children:e.title}),(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:e.runStatus??e.phase})]},e.id))]}):null,j?null:(0,Z.jsx)(`p`,{className:`px-2 py-2 text-sm text-fg-muted`,children:N?g.unavailable:g.independent}),N?(0,Z.jsxs)(`div`,{className:`flex items-center justify-between px-2 text-xs text-fg-muted`,children:[j?g.partialUnavailable:null,B()]}):null,E&&a.onLeaveProject?(0,Z.jsx)(`button`,{type:`button`,className:HD,onClick:()=>{L(),a.onLeaveProject?.()},children:a.leaveProjectLabel}):null]}),k.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:[g.sources,` `,k.length?`${k.length}${T?.sourcesHasMore?`+`:``}`:``]}),P?B():null]}),(u?k:k.slice(0,3)).map(e=>{let t=e.origins.some(e=>e.kind===`session`)?g.session:e.origins.some(e=>e.kind===`task`)?g.task:e.origins.some(e=>e.kind===`recent`)?g.recent:g.draft,n=e.pending&&e.origins.length?`${t} · ${g.draft}`:e.pending?g.draft:t,r=e.kind===`file`&&e.fileKind===`directory`?je:e.kind===`file`?Oe:e.kind===`session`?wt:e.kind===`browser_tab`||e.kind===`browser_page`||e.kind===`app_context`?M:e.kind===`mcp_resource`?Se:e.kind===`attachment`?kt:Oe,i=e.unavailable?g.unavailable:e.title||(e.kind===`note`?g.untitled:g.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`?Ct(y,e.id):e.kind===`session`?`/chat/${encodeURIComponent(e.id)}`:null,s=`${e.kind}:${e.id}`;return!e.unavailable&&o?(0,Z.jsx)(p,{className:VD,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)}),k.length?null:(0,Z.jsx)(`p`,{className:`px-2 py-2 text-xs text-fg-muted`,children:g.unavailable}),k.length>0&&P?(0,Z.jsx)(`p`,{className:`px-2 py-1 text-xs text-fg-muted`,children:g.partialUnavailable}):null,k.length>3?(0,Z.jsx)(`button`,{type:`button`,className:HD,onClick:()=>f(!u),"aria-expanded":u,children:u?g.collapse:g.expand}):null,T?.sourcesHasMore?(0,Z.jsx)(`p`,{className:`px-2 py-1 text-xs text-fg-muted`,children:g.more}):null,R&&a.onDraftSourceNote?(0,Z.jsx)(`button`,{type:`button`,className:HD,onClick:()=>{L(),a.onDraftSourceNote?.()},children:a.draftSourceNoteLabel}):null]}):null,e&&(A||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:g.environment}),F?B():null]}),A?null:a.environmentAction,A?(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)(Et,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:A.kind===`managed_worktree`?g.worktree:g.local}),A.branch||A.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)(Fe,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate`,children:A.branch||(A.detached?`${g.detached} · ${A.headSha?.slice(0,8)}`:A.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:A.rootPath,children:A.rootPath}),(0,Z.jsx)(`button`,{type:`button`,className:HD,"aria-label":m?g.copied:g.copyEnvironmentPath,title:m?g.copied:g.copyEnvironmentPath,onClick:z,children:m?(0,Z.jsx)(re,{className:`size-3.5`,"aria-hidden":!0}):(0,Z.jsx)(xe,{className:`size-3.5`,"aria-hidden":!0})})]}),a.environmentAction,A.available?null:(0,Z.jsx)(`p`,{className:`px-2 py-1 text-xs text-fg-muted`,children:g.unavailableEnvironment}),E&&i?.workspaceRoot?(0,Z.jsx)(J,{className:HD,to:La(E.id),state:{forceNewChat:!0,agentId:a.agentId,temporary:a.temporary},onClick:L,children:g.newEnvironment}):null]}):(0,Z.jsx)(`p`,{className:`px-2 py-2 text-xs text-fg-muted`,children:g.unavailable})]}):null]}),a.executionDeviceAction]})})})]})}var WD=`min(36dvh, 320px)`;function GD(e){return e&&Number.isFinite(e.width)&&Number.isFinite(e.height)&&e.width>0&&e.height>0?e.width/e.height:void 0}function KD(e){let t=GD(e);return t?`min(calc(100vw - 2rem), ${36*t}dvh, ${Math.min(480,320*t)}px)`:`min(320px, calc(100vw - 2rem))`}function qD(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 JD(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 YD({conversationId:e,onFrameSizeChange:t}){let n=JD(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=v(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`:qD(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:GD(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)(Et,{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 XD(e){let t=(0,X.c)(26),{conversationId:n}=e,{state:r}=JD(n,!1),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(),c=v(QD),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)(Et,{className:`size-4 shrink-0`,"aria-hidden":!0}),t[4]=m):m=t[4];let h=c?`电脑`:`Computer`,g;t[5]===h?g=t[6]:(g=(0,Z.jsx)(`span`,{className:`hidden whitespace-nowrap text-xs xl:inline`,children:h}),t[5]=h,t[6]=g);let _;t[7]!==f||t[8]!==p||t[9]!==g?(_=(0,Z.jsx)(wi,{asChild:!0,children:(0,Z.jsxs)(vi,{variant:`ghost`,className:`size-8 shrink-0 gap-1.5 rounded-lg p-0 xl:w-auto xl:px-2`,title:f,"aria-label":p,children:[m,g]})}),t[7]=f,t[8]=p,t[9]=g,t[10]=_):_=t[10];let y=c?`电脑预览`:`Computer preview`,b;t[11]===o?b=t[12]:(b=KD(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)(YD,{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)(bi,{children:(0,Z.jsx)(xi,{align:`end`,sideOffset:8,collisionPadding:16,"aria-label":y,onOpenAutoFocus:ZD,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]!==_?(T=(0,Z.jsxs)(Si,{open:i,onOpenChange:a,children:[_,w]}),t[22]=i,t[23]=w,t[24]=_,t[25]=T):T=t[25],T}function ZD(e){return e.preventDefault()}function QD(e){return e.language===`zh`}function $D({conversationId:e,deviceName:t,zh:n}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),[h,_]=(0,Q.useState)(!1),v=g(`/api/endpoint-tools/artifact-transfers`),{data:b,isLoading:x}=Qr(r?`${v}?conversationId=${encodeURIComponent(e)}`:null,e=>y(e),{shouldRetryOnError:!1}),S=b?.payload.files??[],j=b?.payload.tools??[],M=j.find(e=>e.toolName===s);return(0,Z.jsxs)(A,{open:r,onOpenChange:e=>{i(e),e&&(o(``),c(``),u(``),m(!1),_(!1))},children:[(0,Z.jsx)(w,{asChild:!0,children:(0,Z.jsx)(vi,{variant:`ghost`,className:`h-8 px-2 text-sm`,children:n?`传递文件`:`Transfer file`})}),(0,Z.jsxs)(D,{children:[(0,Z.jsx)(C,{className:`fixed inset-0 z-[120] bg-black/50`}),(0,Z.jsxs)(O,{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)(k,{className:`text-base font-semibold`,children:n?`向执行设备传递文件`:`Transfer file to execution device`}),(0,Z.jsx)(T,{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:[x?(0,Z.jsx)(Qt,{className:`h-20 w-full`}):S.length&&j.length?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(fe,{value:a,onChange:o,placeholder:n?`选择源文件`:`Select source file`,options:S.map(e=>({value:e.fileId,label:`${e.name} · ${e.sourceName} · ${Math.ceil(e.size/1024)} KB`}))}),(0,Z.jsx)(fe,{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,h?(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)(E,{asChild:!0,children:(0,Z.jsx)(vi,{variant:`secondary`,children:n?`关闭`:`Close`})}),l?(0,Z.jsx)(vi,{onClick:async()=>{try{await navigator.clipboard.writeText(l),m(!0)}catch{m(!1)}},children:p?n?`已复制`:`Copied`:n?`复制请求`:`Copy request`}):(0,Z.jsx)(vi,{disabled:d||!M||!S.some(e=>e.fileId===a),onClick:async()=>{if(M){f(!0),_(!1);try{let t=await y(v,{method:`POST`,body:JSON.stringify({conversationId:e,fileId:a,toolName:s})}),r=JSON.stringify({[M.input]:t.payload.transferId});u(n?`请在当前执行设备调用 ${s} 处理已授权的文件,使用参数 ${r}。`:`Use ${s} on the selected execution device to process the authorized file with argument ${r}.`)}catch{_(!0)}finally{f(!1)}}},children:d?n?`授权中…`:`Authorizing…`:n?`生成一次性授权`:`Authorize one transfer`})]})]})]})]})}function eO({conversationId:e,disabled:t}){let n=v(e=>e.language)===`zh`,r=e&&/^[0-9a-f-]{36}$/i.test(e)?g(`/api/endpoint-tools/targets/${encodeURIComponent(e)}`):null,i=Qr(r,async e=>{let t=await h(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=Qr(r?us():null,ds,{refreshInterval:3e4,shouldRetryOnError:!1}),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1);if(!r)return null;let u=(a.data??[]).filter(e=>!e.principal?.revokedAt&&!e.access?.revokedAt).flatMap(e=>e.endpoints.map(t=>({value:t.endpointId,label:`${e.displayName} · ${e.platform}`}))),d=i.data,f=(a.data??[]).find(e=>e.id===d?.principalId),p=f?.endpoints.some(e=>e.endpointId===d?.endpointId&&e.connectionId===d?.connectionId),m=d&&(!p||d.expiresAt<=Date.now()),_=d?`${f?.displayName??(n?`所选设备`:`Selected device`)}${m?n?` · 需要重新选择`:` · Reselect required`:``}`:void 0;return d&&!u.some(e=>e.value===d.endpointId)&&u.push({value:d.endpointId,label:_,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)(fe,{value:d?.endpointId??``,options:u,allowEmpty:!0,emptyLabel:n?`由对话选择`:`Choose in conversation`,placeholder:n?`由对话选择`:`Choose in conversation`,title:_,selectedLabel:_,ariaLabel:n?`选择执行设备`:`Select execution device`,triggerIcon:(0,Z.jsx)(Et,{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 y(r,{method:e?`PUT`:`DELETE`,...e?{body:JSON.stringify({endpointId:e})}:{}}),await i.mutate()}catch{l(!0),await i.mutate()}finally{s(!1)}}}}),e&&d&&!m&&!t?(0,Z.jsx)($D,{conversationId:e,deviceName:f?.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 tO(e){let t=(0,X.c)(23),{conversationId:n}=e,{data:r}=oc(n),i=v(rO)===`zh`,a=hc(nO),o,s;if(t[0]!==n||t[1]!==r||t[2]!==a){let e=r?mc(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||$s(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=()=>yi.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)(Vt,{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 h=i?`手机`:`Phone`,g;t[15]===h?g=t[16]:(g=(0,Z.jsx)(`span`,{className:`text-xs`,children:h}),t[15]=h,t[16]=g);let _;return t[17]!==g||t[18]!==l||t[19]!==u||t[20]!==d||t[21]!==m?(_=(0,Z.jsxs)(vi,{variant:`ghost`,className:`min-h-10 gap-1.5 px-2`,title:l,"aria-label":u,onClick:d,children:[m,g]}),t[17]=g,t[18]=l,t[19]=u,t[20]=d,t[21]=m,t[22]=_):_=t[22],_}function nO(e){return e.seen}function rO(e){return e.language}function iO(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=v(cO),f;t[0]===d?f=t[1]:(f=S(d),t[0]=d,t[1]=f);let p=f,m=vp(sO),h;t[2]===n?h=t[3]:(h=e=>e.panes[n??`new`]?.open===!0,t[2]=n,t[3]=h);let g=yi(h),[_,y]=(0,Q.useState)(null),b,x;t[4]!==p.chat.workingDirectory.notSet||t[5]!==i?(b=i?.trim()??``,x=b?Ha(b):p.chat.workingDirectory.notSet,t[4]=p.chat.workingDirectory.notSet,t[5]=i,t[6]=b,t[7]=x):(b=t[6],x=t[7]);let w=x,E;t[8]===c?E=t[9]:(E=async e=>{try{await c(e)}catch(e){let t=e;y(t instanceof Error?t.message:String(t))}},t[8]=c,t[9]=E);let j=E,M;t[10]!==j||t[11]!==b?(M={initialPath:b,onPicked:j},t[10]=j,t[11]=b,t[12]=M):M=t[12];let N=Ua(M),P=o||!u||N.picking,F;t[13]!==n||t[14]!==m?(F=()=>{let e=yi.getState(),t=n??`new`;e.setScope(t);let r=e.panes[t]?.tabs.find(oO);r?e.activate(r.id,t):e.openTools(t),m(n??``)},t[13]=n,t[14]=m,t[15]=F):F=t[15];let I=F,L;t[16]!==l||t[17]!==d||t[18]!==I||t[19]!==g?(L=l?null:(0,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`,g&&`bg-surface-hover text-fg`),title:d===`zh`?`打开工具`:`Open workspace tools`,"aria-label":d===`zh`?`打开工具`:`Open workspace tools`,"aria-pressed":g,"aria-controls":`app-workspace-panel`,"data-workspace-trigger":!0,onClick:I,children:(0,Z.jsx)(js,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0})}),t[16]=l,t[17]=d,t[18]=I,t[19]=g,t[20]=L):L=t[20];let R;t[21]!==a||t[22]!==l||t[23]!==N||t[24]!==p.chat.workingDirectory.chooseFolder||t[25]!==b||t[26]!==P||t[27]!==w?(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}: ${b||w}`,"aria-label":p.chat.workingDirectory.chooseFolder,onClick:N.pick,children:[(0,Z.jsx)(se,{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]=b,t[26]=P,t[27]=w,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]!==b?(B=l&&!N.hasNativePicker?(0,Z.jsx)(ce,{open:N.modalOpen,onOpenChange:N.setModalOpen,initialAbsolutePath:b||void 0,onConfirm:N.confirmPick,wd:p.chat.workingDirectory}):null,t[32]=l,t[33]=N,t[34]=p.chat.workingDirectory,t[35]=b,t[36]=B):B=t[36];let ee=_!==null,V;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(V=e=>{e||y(null)},t[37]=V):V=t[37];let H;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,Z.jsx)(C,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),t[38]=H):H=t[38];let U;t[39]===p.chat.workingDirectory.applyErrorTitle?U=t[40]:(U=(0,Z.jsx)(k,{className:`text-base font-semibold text-fg`,children:p.chat.workingDirectory.applyErrorTitle}),t[39]=p.chat.workingDirectory.applyErrorTitle,t[40]=U);let W;t[41]===_?W=t[42]:(W=_?(0,Z.jsx)(T,{className:`mt-2 whitespace-pre-wrap text-sm leading-relaxed text-fg-muted`,children:_}):null,t[41]=_,t[42]=W);let te;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(te=()=>y(null),t[43]=te):te=t[43];let ne;t[44]===p.chat.workingDirectory.applyErrorClose?ne=t[45]:(ne=(0,Z.jsx)(`div`,{className:`mt-4 flex justify-end border-t border-edge-subtle pt-3`,children:(0,Z.jsx)(vi,{type:`button`,onClick:te,children:p.chat.workingDirectory.applyErrorClose})}),t[44]=p.chat.workingDirectory.applyErrorClose,t[45]=ne);let re;t[46]!==U||t[47]!==W||t[48]!==ne?(re=(0,Z.jsxs)(D,{children:[H,(0,Z.jsxs)(O,{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:aO,children:[U,W,ne]})]}),t[46]=U,t[47]=W,t[48]=ne,t[49]=re):re=t[49];let ie;t[50]!==ee||t[51]!==re?(ie=(0,Z.jsx)(A,{open:ee,onOpenChange:V,children:re}),t[50]=ee,t[51]=re,t[52]=ie):ie=t[52];let ae;return t[53]!==z||t[54]!==B||t[55]!==ie?(ae=(0,Z.jsxs)(Z.Fragment,{children:[z,B,ie]}),t[53]=z,t[54]=B,t[55]=ie,t[56]=ae):ae=t[56],ae}function aO(e){return e.preventDefault()}function oO(e){return e.kind===`home`}function sO(e){return e.openForSession}function cO(e){return e.language}function lO(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 uO({conversationId:e,dialogOpen:t,onDialogOpenChange:n,hideTrigger:r=!1}){let i=v(e=>e.language),a=i===`zh`?fO:pO,[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,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(864e5),[x,S]=(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),[ee,V]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(!c||u||f)return;let t=!1;return h(!0),_(null),Promise.all([oo(e),uo(e),ao()]).then(async([n,r,i])=>{if(t)return;d(n),B(i);let a=i?await fo().catch(()=>null):null;if(t)return;V(a?.publishing.allowed===!0);let o=i?await po(e).catch(()=>[]):[];if(t)return;let s=[...o,...r].find(e=>!e.revoked&&!e.expired);s&&p(s)}).catch(e=>{t||_(e instanceof Error?e.message:String(e))}).finally(()=>{t||h(!1)}),()=>{t=!0}},[c,u,f,e]);let H=()=>{d(null),p(null),_(null),h(!1),M(``),P(!1),I([]),V(!1)},U=async()=>{if(!(!u||m)){h(!0),_(null);try{p(await(L===`hosted`?lo:co)(e,{expectedTranscriptId:u.transcriptId,expectedCutoffSeq:u.cutoffSeq,expectedMetadataUpdatedAt:u.metadataUpdatedAt,ttlMs:y,maxViews:x,description:j.trim()||void 0,includeToolActivities:N,attachmentIds:F}))}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(!1)}}},W=async()=>{if(!(!f||m)){h(!0),_(null);try{let t=await oo(e);d(t);let n=f.delivery===`hosted`?so:ro;p(await n(e,f.id,{expectedTranscriptId:t.transcriptId,expectedCutoffSeq:t.cutoffSeq,expectedMetadataUpdatedAt:t.metadataUpdatedAt}))}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(!1)}}},te=async()=>{if(!(!f||m)){h(!0),_(null);try{f.delivery===`hosted`?await mo(e,f.id):await io(f.id),l(!1),H()}catch(e){_(e instanceof Error?e.message:String(e)),h(!1)}}};return(0,Z.jsxs)(A,{open:c,onOpenChange:e=>{l(e),e||H()},children:[r?null:(0,Z.jsx)(w,{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)(Ds,{className:`size-4`})})}),(0,Z.jsxs)(D,{children:[(0,Z.jsx)(C,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),(0,Z.jsxs)(O,{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)(k,{className:`text-base font-semibold text-fg`,children:f?a.created:a.title}),(0,Z.jsx)(T,{className:`mt-0.5 text-xs text-fg-muted`,children:f?a.createdHint:a.hint})]}),(0,Z.jsx)(E,{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)(Xt,{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)(Ze,{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)(qt,{shareUrl:f.shareUrl,lanUrl:f.lanUrl,reachability:f.reachability}),(0,Z.jsx)(Jt,{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)(we,{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)(Bt,{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)(de,{value:L,disabled:m,onChange:e=>R(e.target.value),children:[(0,Z.jsx)(K,{value:`hosted`,children:a.hosted}),(0,Z.jsx)(K,{value:`local`,children:a.local})]})]}),L===`hosted`&&!z?(0,Z.jsx)(rs,{providerId:`xopc-share`,displayName:a.hosted,connected:!1,onConnected:()=>{B(!0),fo().then(e=>V(e.publishing.allowed)).catch(()=>V(!1))}}):null,L===`hosted`&&z&&!ee?(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:dO(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)(de,{value:y,disabled:m,onChange:e=>b(Number(e.target.value)),children:[(0,Z.jsx)(K,{value:36e5,children:a.oneHour}),(0,Z.jsx)(K,{value:864e5,children:a.oneDay}),(0,Z.jsx)(K,{value:6048e5,children:a.sevenDays}),(0,Z.jsx)(K,{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)(de,{value:x??`unlimited`,disabled:m,onChange:e=>S(e.target.value===`unlimited`?null:Number(e.target.value)),children:[(0,Z.jsx)(K,{value:`unlimited`,children:a.unlimited}),(0,Z.jsx)(K,{value:1,children:`1`}),(0,Z.jsx)(K,{value:10,children:`10`}),(0,Z.jsx)(K,{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,g?(0,Z.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:g}):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)(vi,{type:`button`,variant:`ghost`,disabled:m,onClick:()=>p(null),children:a.newShare}),(0,Z.jsxs)(vi,{type:`button`,variant:`ghost`,disabled:m,onClick:()=>void te(),children:[(0,Z.jsx)(Wt,{className:`size-4`}),a.revoke]}),(0,Z.jsxs)(vi,{type:`button`,disabled:m||f.delivery===`hosted`&&!ee,onClick:()=>void W(),children:[m?(0,Z.jsx)(Ze,{className:`size-4 animate-spin`}):(0,Z.jsx)(Pt,{className:`size-4`}),a.refresh]})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(E,{asChild:!0,children:(0,Z.jsx)(vi,{type:`button`,variant:`ghost`,children:a.cancel})}),(0,Z.jsxs)(vi,{type:`button`,disabled:!u||m||u.messageCount===0||L===`hosted`&&(!z||!ee),onClick:()=>void U(),children:[m?(0,Z.jsx)(Ze,{className:`size-4 animate-spin`}):null,a.create]})]})})]})]})]})}function dO(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var fO={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:`助手`},pO={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`},mO=`(max-width: 767px)`,hO=(0,Q.memo)(function(e){let t=(0,X.c)(141),{inline:n,chatHeadline:r,chatAgents:i,showChatAgentSelector:a,chatAgentId:o,onChatAgentChange:s,chatAgentDisabled:c,conversationId:l,hasMessages:d,workspacePath:f,userContextMode:p,canChangeWorkspace:m,workspaceDisabled:h,onWorkspaceChange:g,prepareTerminalSession:_,terminalDisabled:y,showContextControls:b,onFindOpen:x,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=h!==void 0&&h,A=y!==void 0&&y,j=b===void 0||b,M=v(gO),{conversationId:N}=u(),P=N&&N!==`new`?decodeURIComponent(N):null,F;t[0]!==l||t[1]!==P?(F=l?.trim()||P,t[0]=l,t[1]=P,t[2]=F):F=t[2];let I=F,{data:L,error:R,mutate:B}=Of(I??null,!1),ee=!R&&(!L||!!L.environment?.available),V;t[3]===I?V=t[4]:(V=e=>e.panes[I??`new`]?.open===!0,t[3]=I,t[4]=V);let H=yi(V),U;t[5]===M?U=t[6]:(U=S(M),t[5]=M,t[6]=U);let W=U,te=Bf(_O),ne=Vw(vO),re=ts(yO),ie=ts(bO),[ae,oe]=(0,Q.useState)(!1),se=(0,Q.useRef)(!1),[ce,le]=(0,Q.useState)(!1),ue=Vf(xO),de=Da(SO),G=Da(CO),K=window.electronAPI?.platform,fe=!!(j&&window.electronAPI?.terminal&&(I||_)),q;t[7]!==I||t[8]!==ie||t[9]!==_||t[10]!==fe||t[11]!==A||t[12]!==ce||t[13]!==re?(q=()=>{if(!(!fe||A||ce)){if(I){re(I);return}_&&(le(!0),_().then(e=>{e&&ie(e)}).finally(()=>le(!1)))}},t[7]=I,t[8]=ie,t[9]=_,t[10]=fe,t[11]=A,t[12]=ce,t[13]=re,t[14]=q):q=t[14];let pe=q,me;t[15]!==I||t[16]!==E||t[17]!==ne?(me=()=>{if(!I||!E)return;let e=yi.getState().panes[I],t=Vw.getState().pendingCreate?.parentConversationId===I||!!Vw.getState().creatingRequests[I],n=e?.open===!0&&(e.activeId?.startsWith(`side:`)===!0||t);ne(I,!n)},t[15]=I,t[16]=E,t[17]=ne,t[18]=me):me=t[18];let he=me,ge=is(mO),_e;t[19]!==ue||t[20]!==te?(_e=Mf({runtime:jf(),sidebarCollapsed:te,mobileNavOpen:ue}),t[19]=ue,t[20]=te,t[21]=_e):_e=t[21];let ve=ge?!ue:_e.collapsedNewChatVisible,ye,be;t[22]!==G||t[23]!==T?(ye=()=>{if(!T)return()=>G()},be=[G,T],t[22]=G,t[23]=T,t[24]=ye,t[25]=be):(ye=t[24],be=t[25]),(0,Q.useLayoutEffect)(ye,be);let xe,Se;t[26]!==pe||t[27]!==fe?(xe=()=>{if(!fe)return;let e=e=>{lO(e,K)&&(e.preventDefault(),pe())};return window.addEventListener(`keydown`,e),window.addEventListener(`workspace-open-terminal`,pe),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`workspace-open-terminal`,pe)}},Se=[pe,fe,K],t[26]=pe,t[27]=fe,t[28]=xe,t[29]=Se):(xe=t[28],Se=t[29]),(0,Q.useEffect)(xe,Se);let we,Te;t[30]!==I||t[31]!==he||t[32]!==E?(we=()=>{if(!I||!E)return;let e=e=>{fs(e,K)&&(e.preventDefault(),he())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},Te=[I,he,E,K],t[30]=I,t[31]=he,t[32]=E,t[33]=we,t[34]=Te):(we=t[33],Te=t[34]),(0,Q.useEffect)(we,Te);let Ee;t[35]!==o||t[36]!==W.sidebar.newTask||t[37]!==C||t[38]!==ve||t[39]!==D?(Ee=ve?(0,Z.jsx)(J,{to:La(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`,Sa),title:W.sidebar.newTask,children:(0,Z.jsx)(Nt,{className:`size-4 shrink-0 text-accent-fg`,strokeWidth:2,"aria-hidden":!0})}):null,t[35]=o,t[36]=W.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`,Sa),t[46]=Ae):Ae=t[46];let je;t[47]!==c||t[48]!==o||t[49]!==i||t[50]!==W.chat.agentNoMatches||t[51]!==W.chat.agentPlaceholder||t[52]!==W.chat.agentSearchPlaceholder||t[53]!==s||t[54]!==a?(je=a?(0,Z.jsx)(ID,{items:i,value:o,disabled:c,placeholder:W.chat.agentPlaceholder,searchPlaceholder:W.chat.agentSearchPlaceholder,noMatches:W.chat.agentNoMatches,compact:!0,contentSide:`bottom`,contentAlign:`end`,onChange:s}):null,t[47]=c,t[48]=o,t[49]=i,t[50]=W.chat.agentNoMatches,t[51]=W.chat.agentPlaceholder,t[52]=W.chat.agentSearchPlaceholder,t[53]=s,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)(Ce,{className:`size-4`,"aria-hidden":!0}),t[56]=Pe):Pe=t[56];let Fe;t[57]!==Me||t[58]!==Ne?(Fe=(0,Z.jsx)(_o,{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]===x?Ie=t[61]:(Ie=e=>{se.current&&(e.preventDefault(),se.current=!1,document.querySelector(`[data-chat-menu-trigger]`)?.focus(),x?.())},t[60]=x,t[61]=Ie);let Le=!E||!x,Re;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(Re=()=>{se.current=!0},t[62]=Re):Re=t[62];let ze;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(ze=(0,Z.jsx)(Lt,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t[63]=ze):ze=t[63];let Be;t[64]===W.chat.find.input?Be=t[65]:(Be=(0,Z.jsx)(`span`,{className:`flex-1`,children:W.chat.find.input}),t[64]=W.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:K===`darwin`?`⌘F`:`Ctrl+F`}),t[66]=Ve):Ve=t[66];let He;t[67]!==Le||t[68]!==Be?(He=(0,Z.jsxs)(yo,{disabled:Le,onSelect:Re,className:`flex cursor-default items-center gap-3 rounded-lg px-3 py-2 text-fg outline-none data-[highlighted]:bg-surface-hover data-[disabled]:opacity-40`,children:[ze,Be,Ve]}),t[67]=Le,t[68]=Be,t[69]=He):He=t[69];let Ue=!I||!E,We;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(We=()=>oe(!0),t[70]=We):We=t[70];let Ge;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(Ge=(0,Z.jsx)(z,{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)(yo,{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)(vo,{children:(0,Z.jsxs)(bo,{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)(go,{modal:!1,children:[Fe,Ye]}),t[81]=Fe,t[82]=Ye,t[83]=Xe):Xe=t[83];let Ze;t[84]!==I||t[85]!==E||t[86]!==ae?(Ze=I&&E?(0,Z.jsx)(uO,{conversationId:I,hideTrigger:!0,dialogOpen:ae,onDialogOpenChange:oe},`share:${I}`):null,t[84]=I,t[85]=E,t[86]=ae,t[87]=Ze):Ze=t[87];let Qe;t[88]!==I||t[89]!==O||t[90]!==c||t[91]!==o||t[92]!==w||t[93]!==g||t[94]!==B||t[95]!==j||t[96]!==D||t[97]!==ee||t[98]!==k||t[99]!==f?(Qe=j?(0,Z.jsx)(UD,{...w,agentId:o,executionDeviceAction:I?(0,Z.jsx)(eO,{conversationId:I,disabled:c}):null,environmentAction:O&&g?(0,Z.jsx)(iO,{directoryOnly:!0,conversationId:I,workspacePath:I?f:w?.project?.workspaceRoot,available:ee,canChangeWorkspace:!0,disabled:k,onWorkspaceChange:async e=>{await g(e),await B()}}):null,temporary:D===`temporary`,conversationId:I??null},`context:${I??w?.project?.id??`new`}`):null,t[88]=I,t[89]=O,t[90]=c,t[91]=o,t[92]=w,t[93]=g,t[94]=B,t[95]=j,t[96]=D,t[97]=ee,t[98]=k,t[99]=f,t[100]=Qe):Qe=t[100];let $e;t[101]!==j||t[102]!==H?($e=j&&!H?(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]=H,t[103]=$e):$e=t[103];let et;t[104]===I?et=t[105]:(et=I?(0,Z.jsx)(XD,{conversationId:I},I):null,t[104]=I,t[105]=et);let tt;t[106]===I?tt=t[107]:(tt=I?(0,Z.jsx)(tO,{conversationId:I}):null,t[106]=I,t[107]=tt);let nt;t[108]!==I||t[109]!==w?.project?.workspaceRoot||t[110]!==g||t[111]!==C||t[112]!==B||t[113]!==j||t[114]!==ee||t[115]!==k||t[116]!==H||t[117]!==f?(nt=j&&!H?(0,Z.jsx)(iO,{conversationId:I,workspacePath:I?f:w?.project?.workspaceRoot,available:ee,canChangeWorkspace:!1,disabled:k,onWorkspaceChange:async e=>{await g?.(e),await B()}},`workspace:${I??C}`):null,t[108]=I,t[109]=w?.project?.workspaceRoot,t[110]=g,t[111]=C,t[112]=B,t[113]=j,t[114]=ee,t[115]=k,t[116]=H,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]!==de?(ot=()=>{T||de(at)},st=[at,T,de],t[132]=at,t[133]=T,t[134]=de,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 gO(e){return e.language}function _O(e){return e.collapsed}function vO(e){return e.setOpen}function yO(e){return e.toggle}function bO(e){return e.open}function xO(e){return e.mobileNavOpen}function SO(e){return e.setPageHeader}function CO(e){return e.clearPageHeader}var wO=(0,Q.memo)(function(){let e=(0,X.c)(19),t=v(TO),n;e[0]===t?n=e[1]:(n=S(t),e[0]=t,e[1]=n);let r=n.chat.runRecovery,i=mi(EO),a=mi(DO),[o,s]=(0,Q.useState)(!1),c=i===`connecting`||i===`reconnecting`,l,u;if(e[2]===c?(l=e[3],u=e[4]):(l=()=>{if(!c)return;let e=window.setTimeout(()=>s(!0),1500);return()=>{window.clearTimeout(e),s(!1)}},u=[c],e[2]=c,e[3]=l,e[4]=u),(0,Q.useEffect)(l,u),i!==`error`&&!(c&&o))return null;let d=i===`error`,f=d?Kt:Pt,p=`size-3.5 shrink-0 ${c?`motion-safe:animate-spin`:``}`,m;e[5]!==f||e[6]!==p?(m=(0,Z.jsx)(f,{className:p,"aria-hidden":!0}),e[5]=f,e[6]=p,e[7]=m):m=e[7];let h=d?r.connectionFailed:i===`connecting`?r.connecting:r.reconnecting,g;e[8]===h?g=e[9]:(g=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1`,children:h}),e[8]=h,e[9]=g);let _;e[10]!==a||e[11]!==d||e[12]!==r.details||e[13]!==r.reconnect?(_=d?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`button`,{type:`button`,className:`min-h-9 rounded-md border border-edge px-3 text-xs text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:OO,children:r.reconnect}),a?(0,Z.jsxs)(`details`,{className:`w-full min-w-0`,children:[(0,Z.jsx)(`summary`,{className:`w-fit cursor-pointer rounded-md py-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:r.details}),(0,Z.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words rounded-md bg-surface-inset p-2`,children:Yn(a)})]}):null]}):null,e[10]=a,e[11]=d,e[12]=r.details,e[13]=r.reconnect,e[14]=_):_=e[14];let y;return e[15]!==m||e[16]!==g||e[17]!==_?(y=(0,Z.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex flex-wrap items-center gap-2 border-b border-edge-subtle bg-surface-panel px-4 py-2 text-xs text-fg-muted`,children:[m,g,_]}),e[15]=m,e[16]=g,e[17]=_,e[18]=y):y=e[18],y});function TO(e){return e.language}function EO(e){return e.connectionState}function DO(e){return e.error}function OO(){return pi()}function kO(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function AO(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)(re,{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)(pe,{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)(ms,{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)(ge,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[3]=r):r=t[3],r}function jO(e,t){return e?`${kO(e.files.length===1?t.filesChangedOne:t.filesChangedOther,{count:e.files.length})} · +${e.added} -${e.removed}`:null}function MO(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(FO),t[0]=n.items,t[1]=s);let c=s,l=n.items.every(PO),u;t[2]!==a.completedProgress||t[3]!==n.completedCount||t[4]!==n.totalCount?(u=kO(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=kO(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=jO(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`,la.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)(re,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:2,"aria-hidden":!0}):o?(0,Z.jsx)(pe,{className:`size-4 shrink-0 text-accent`,strokeWidth:2,"aria-hidden":!0}):(0,Z.jsx)(Ye,{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)(ie,{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)(wi,{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)(Ye,{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(NO),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)(bi,{children:(0,Z.jsxs)(xi,{side:`top`,align:`center`,sideOffset:8,collisionPadding:16,className:`z-[120] w-[min(28rem,calc(100vw-2rem))] overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:[j,P,F]})}),t[54]=j,t[55]=P,t[56]=F,t[57]=I):I=t[57];let L;return t[58]!==T||t[59]!==I?(L=(0,Z.jsx)(`div`,{className:`mx-auto flex w-full max-w-80 justify-center pb-2 pt-1`,children:(0,Z.jsxs)(Si,{children:[T,I]})}),t[58]=T,t[59]=I,t[60]=L):L=t[60],L}function NO(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)(AO,{status:e.status}),(0,Z.jsx)(`span`,{className:`min-w-0 [overflow-wrap:anywhere]`,children:e.title})]},e.id)}function PO(e){return e.status===`completed`||e.status===`cancelled`}function FO(e){return e.status===`completed`}function IO(e){let t=HO(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 LO=new Set([`pending`,`in_progress`,`completed`,`cancelled`]);function RO(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function zO(e){return e.trim().toLowerCase().replace(/-/g,`_`).split(`__`).at(-1)??``}function BO(e){let t=RO(e.details);return t&&Object.keys(t).length>0?t:ha(e.result).details}function VO(e){let t=typeof e==`string`?e.trim():``;return LO.has(t)?t:null}function HO(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 UO(e){if(!Array.isArray(e.plan))return null;let t=e.plan.flatMap((e,t)=>{let n=RO(e),r=typeof n?.id==`string`&&n.id.trim()?n.id.trim():`update-plan-${t}`,i=typeof n?.step==`string`?n.step.trim():``,a=VO(n?.status);return i&&a?[{id:r,title:i,status:a}]:[]});return HO(`update_plan`,typeof e.explanation==`string`&&e.explanation.trim()?e.explanation.trim():void 0,t)}function WO(e){return Array.isArray(e.items)?HO(`todo`,void 0,e.items.flatMap((e,t)=>{let n=RO(e),r=typeof n?.id==`string`&&n.id.trim()?n.id.trim():`todo-${t}`,i=typeof n?.content==`string`?n.content.trim():``,a=VO(n?.status);return i&&a?[{id:r,title:i,status:a}]:[]})):null}function GO(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=zO(n.name),i=BO(n);if(i){if(r===`update_plan`)return{found:!0,plan:UO(i)};if(r===`todo`)return{found:!0,plan:WO(i)}}}return{found:!1,plan:null}}function KO(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:0}function qO(e){let t=new Set,n=0,r=0;for(let i of e){if(i.type!==`tool_use`||i.status===`error`||zO(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=RO(n),r=typeof e?.moveTo==`string`?e.moveTo:typeof e?.path==`string`?e.path:``;r.trim()&&t.add(r.trim())}n+=KO(e.added),r+=KO(e.removed)}}return t.size>0||n>0||r>0?{files:[...t],added:n,removed:r}:null}function JO(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.role!==`assistant`)continue;let r=GO(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:qO(i)}}return null}function YO(e,t){if(!t)return null;let n=-1;for(let t=e.length-1;t>=0;--t)if(e[t]?.role===`user`){n=t;break}return JO(e.slice(n+1))}function XO(e,t){return e.bottom>t.top&&e.top<t.bottom&&e.right>t.left&&e.left<t.right}function ZO(e,t,n){let r=n.getBoundingClientRect(),i=t.getBoundingClientRect();if(!XO(e,{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight})||!XO(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&&!XO(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 QO(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=ZO(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 $O(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)(Lt,{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)(Ze,{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`,la.focusRingPanel,la.press),t[30]=j):j=t[30];let M;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Z.jsx)(Xt,{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`,la.focusRingPanel,la.press,la.disabled),t[39]=F):F=t[39];let I;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(oe,{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`,la.focusRingPanel,la.press,la.disabled),t[45]=R):R=t[45];let z;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Z.jsx)(ie,{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 ee;t[51]===C?ee=t[52]:(ee=(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]=ee);let V;t[53]!==L||t[54]!==B||t[55]!==ee?(V=(0,Z.jsxs)(`div`,{className:`flex h-11 items-center border-t border-edge-subtle px-1.5`,children:[L,B,ee]}),t[53]=L,t[54]=B,t[55]=ee,t[56]=V):V=t[56];let H;return t[57]!==u.input||t[58]!==P||t[59]!==V?(H=(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,V]}),t[57]=u.input,t[58]=P,t[59]=V,t[60]=H):H=t[60],H}async function ek(e,t,n={}){let r=await h(g(`${n.taskId?`/api/tasks/${encodeURIComponent(n.taskId)}/conversation/find`:`/api/sessions/${encodeURIComponent(e)}/find`}?${new URLSearchParams({q:t,limit:`1000`})}`),{signal:n.signal});if(!r.ok)throw Error(`HTTP ${r.status}: ${r.statusText}`);let i=await r.json();if(i.ok!==!0||!Array.isArray(i.matches)||typeof i.total!=`number`)throw Error(`Invalid chat find response`);return{query:typeof i.query==`string`?i.query:t,total:i.total,truncated:i.truncated===!0,matches:i.matches.filter(e=>Number.isInteger(e?.displayIndex)&&e.displayIndex>=0&&Number.isInteger(e?.occurrence)&&e.occurrence>=0)}}var tk=`chat-find-match`,nk=`chat-find-active`,rk=`chat-find-highlight-styles`;function ik(){let e=globalThis.CSS,t=globalThis.Highlight;return!e?.highlights||!t?null:{registry:e.highlights,Highlight:t}}function ak(){if(document.getElementById(rk))return;let e=document.createElement(`style`);e.id=rk,e.textContent=`
|
|
61
|
+
::highlight(${tk}) {
|
|
62
|
+
color: inherit;
|
|
63
|
+
background-color: color-mix(in srgb, var(--color-warning) 38%, transparent);
|
|
64
|
+
}
|
|
65
|
+
::highlight(${nk}) {
|
|
66
|
+
color: inherit;
|
|
67
|
+
background-color: color-mix(in srgb, var(--color-warning) 78%, transparent);
|
|
68
|
+
text-decoration: underline 2px var(--color-fg);
|
|
69
|
+
}
|
|
70
|
+
`,document.head.appendChild(e)}function ok(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 sk(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 ck(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 lk(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=ok(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 ck(s,n)){let t=sk(o,e.start,e.end);t&&(r.push({messageIndex:i,occurrence:a,range:t}),a+=1)}}}return r}function uk(e,t){let n=ik();if(!n||(ak(),n.registry.delete(tk),n.registry.delete(nk),e.length===0))return;n.registry.set(tk,new n.Highlight(...e.map(e=>e.range)));let r=e[t];r&&n.registry.set(nk,new n.Highlight(r.range))}function dk(){let e=ik();e?.registry.delete(tk),e?.registry.delete(nk)}function fk(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||(ow(e),e.scrollTo({top:Math.max(0,e.scrollTop+r.top-a),behavior:window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}))}function pk(e,t){return t===0?0:(e+t)%t}function mk(e){return`${e.displayIndex}:${e.occurrence}`}function hk(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 gk(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(xk));for(let t of p){let n={displayIndex:a+t.messageIndex,occurrence:t.occurrence};e.set(mk(n),n)}A=[...e.values()].sort(bk),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),dk(),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 ee=B,V;t[14]===j.length?V=t[15]:(V=e=>{T(t=>pk(t+e,j.length))},t[14]=j.length,t[15]=V);let H=V,U,W;t[16]!==H||t[17]!==c||t[18]!==F?(U=()=>{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(),H(e.shiftKey?-1:1);return}e.key===`Escape`&&(e.preventDefault(),z())}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},W=[z,H,c,F],t[16]=H,t[17]=c,t[18]=F,t[19]=U,t[20]=W):(U=t[19],W=t[20]),(0,Q.useEffect)(U,W);let te;t[21]!==k||t[22]!==c||t[23]!==o?(te=()=>{let e=o.current;if(!c||!e||!k.trim()){m(yk),dk();return}let t=()=>{let t=lk(e,k);m(e=>hk(e,t)?e:t)};t();let n=null,r=new MutationObserver(()=>{n===null&&(n=requestAnimationFrame(()=>{n=null,t()}))});return r.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>{r.disconnect(),n!==null&&cancelAnimationFrame(n)}},t[21]=k,t[22]=c,t[23]=o,t[24]=te):te=t[24];let ne;t[25]!==k||t[26]!==i||t[27]!==c||t[28]!==o?(ne=[k,i,c,o],t[25]=k,t[26]=i,t[27]=c,t[28]=o,t[29]=ne):ne=t[29],(0,Q.useLayoutEffect)(te,ne);let re,ie;t[30]!==n||t[31]!==k||t[32]!==c||t[33]!==r?(re=()=>{let e=k.trim();if(!c||!n||!e){_([]),y(!1),x(!1),C(!1);return}let t=new AbortController;_([]),y(!1),x(!1),C(!0);let i=window.setTimeout(()=>{ek(n,e,{taskId:r,signal:t.signal}).then(e=>{_(e.matches),y(e.truncated)}).catch(e=>{e?.name!==`AbortError`&&(_([]),y(!1),x(!0))}).finally(()=>{t.signal.aborted||C(!1)})},150);return()=>{window.clearTimeout(i),t.abort()}},ie=[n,k,c,r],t[30]=n,t[31]=k,t[32]=c,t[33]=r,t[34]=re,t[35]=ie):(re=t[34],ie=t[35]),(0,Q.useEffect)(re,ie);let ae,oe;t[36]===j.length?(ae=t[37],oe=t[38]):(ae=()=>{T(e=>Math.min(e,Math.max(0,j.length-1)))},oe=[j.length],t[36]=j.length,t[37]=ae,t[38]=oe),(0,Q.useEffect)(ae,oe);let se,ce;t[39]!==w||t[40]!==j||t[41]!==a||t[42]!==p||t[43]!==s||t[44]!==o?(se=()=>{let e=j[w],t=o.current;if(!t||!e){uk(p,-1);return}let n=e.displayIndex-a,r=p.findIndex(t=>t.messageIndex===n&&t.occurrence===e.occurrence);uk(p,r),r>=0?fk(t,p[r]):s(e.displayIndex)},ce=[w,j,a,p,s,o],t[39]=w,t[40]=j,t[41]=a,t[42]=p,t[43]=s,t[44]=o,t[45]=se,t[46]=ce):(se=t[45],ce=t[46]),(0,Q.useLayoutEffect)(se,ce);let le;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(le=[],t[47]=le):le=t[47],(0,Q.useEffect)(_k,le);let ue,de;t[48]!==n||t[49]!==c?(ue=()=>{O.current!==n&&(O.current=n,c&&z())},de=[z,n,c],t[48]=n,t[49]=c,t[50]=ue,t[51]=de):(ue=t[50],de=t[51]),(0,Q.useEffect)(ue,de);let G,K;t[52]===H?(G=t[53],K=t[54]):(G=()=>H(-1),K=()=>H(1),t[52]=H,t[53]=G,t[54]=K);let fe;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]!==G||t[64]!==K?(fe={open:c,query:u,inputRef:E,activeIndex:w,resultCount:j.length,truncated:v,limitedToLoaded:b,searching:S,setQuery:ee,show:F,close:z,previous:G,next:K},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]=G,t[64]=K,t[65]=fe):fe=t[65],fe}function _k(){return vk}function vk(){return dk()}function yk(e){return e.length===0?e:[]}function bk(e,t){return e.displayIndex-t.displayIndex||e.occurrence-t.occurrence}function xk(e){return[mk(e),e]}function Sk(e){let t=String(e??``).trim();return!t||t===`new`?null:t}function Ck(e){let t=String(e.streamConversationId??``).trim(),n=Sk(e.routeConversationId);return!t||!n?!1:t===n}function wk(e){let t=Sk(e.routeConversationId);return t?e.cacheConversationId===t:!1}function Tk(e){let t=String(e.chatId??``).trim();if(!t)return!1;let n=Sk(e.routeConversationId);return n?n===t:!1}function Ek(e,t){return e?`new`:t??null}function Dk(e,t){if(!(e||!t))return decodeURIComponent(t)}function Ok(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=ur([t,e.streamingMsg]);return[...e.messages.slice(0,-1),...n]}return[...e.messages,e.streamingMsg]}function kk(e,t){let n=e[e.length-1];return n?.role!==`assistant`||n.turnId!==t?null:{messagesWithoutTail:e.slice(0,-1),tail:n}}function Ak(e){e()}function jk(e,t){return!!(e&&(e.localDraft||e.configVersion!==void 0)&&t?.some(t=>t.id===e.model))}function Mk(e){e.sendingRef.current=!1,e.streamingRef.current=!1}function Nk(e){return e.isNewRoute?`creating-session`:e.sessionRoutePending||e.showSessionLoading||e.sessionContentLoading?`loading-history`:e.messageCount===0?`ready-empty`:`ready-conversation`}var Pk=new Map;async function Fk(e,t,n,r,i){let a=_.getState(),o=Nr([a.baseUrl,a.conversationId,e,t]),s=Nr({action:n,submission:r}),c=Pk.get(o);if(c){if(c.signature!==s)throw Error(`An answer is already being submitted`);return(await c.promise).clone()}let l=Ik(e,t,n,r,i).then(e=>{for(e.ok||Pk.delete(o);Pk.size>64;)Pk.delete(Pk.keys().next().value);return e},e=>{throw Pk.delete(o),e});return Pk.set(o,{signature:s,promise:l}),(await l).clone()}async function Ik(e,t,n,r,i){let a=_.getState().conversationId,o=wf(e,t,`submission`,i),s={schemaVersion:2,action:n,...r,expectedVersion:t},c=Nr(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}})),_.getState().conversationId!==a)throw Error(`Active Gateway changed`);let d=await h(g(`/api/clarifications/${encodeURIComponent(e)}/responses`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(u.body)});return(d.ok||d.status>=400&&d.status<500)&&(await o.write(void 0),window.dispatchEvent(new CustomEvent(`clarification-submission-state`,{detail:{requestId:e,pending:!1}})),d.ok&&await wf(e,t,`draft`,i).write(void 0)),d}async function Lk(e,t,n){let r=()=>{if(!n())throw new DOMException(`Conversation changed`,`AbortError`)},i=await Rr(e);if(r(),i&&(i.kind!==`append`||i.execution||i.delivery!==t.delivery||Nr(i.input)!==Nr(t.input)||!!i.interrupt!=!!t.interrupt))throw Error(`The previous input is awaiting confirmation`);let a=Fr.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 h(g(`/api/sessions/${encodeURIComponent(e)}/input-receipts/${encodeURIComponent(a.clientMessageId)}`),{signal:t}),i=await n.json();if(r(),n.ok)return o(i.payload);if(n.status!==404||i.error?.code!==`NOT_RECEIVED`)throw Error(i.error?.message??`Input receipt lookup failed`)},c=async t=>(r(),await zr(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,f;try{d=await h(g(`/api/sessions/${encodeURIComponent(e)}/inputs`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(a)});let t=await d.json();if(r(),!d.ok)throw Error(typeof t.error==`string`?t.error:t.error?.message??`Message was not accepted`);f=o(t.payload)}catch(t){if(r(),d&&d.status>=400&&d.status<500&&d.status!==408)throw await zr(e,a.clientMessageId),t;if(f=await s(AbortSignal.timeout(3e3)).catch(()=>void 0),r(),f===void 0)throw t}return c(f)}function Rk(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:{...kr(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 zk(e){let{conversationId:t,decodedKey:n,conversationIdRef:r,sendingRef:i,streamingRef:a,modelSupportsThinking:o,thinkingLevel:s,shouldApplyStreamUpdate:c}=e,l=_(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&&_.getState().conversationId===e.gateway},[r]),[f,p]=(0,Q.useState)(null),[m,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)(()=>mr(t??``)),[R,z]=(0,Q.useState)(!1),B=(0,Q.useRef)(!1),ee=(0,Q.useRef)(null),V=(0,Q.useRef)(-1),[H,U]=(0,Q.useState)(!1),W=(0,Q.useRef)(null),[te,ne]=(0,Q.useState)(null),re=(0,Q.useCallback)(()=>ne(u.current),[]);x.current=f,E.current=w,ee.current=P;let ie=(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<V.current)return;if(t.control){if(!vr(t.conversationId,t.control,t.revision))return;L(t.control)}let n=CT({control:t.control,inputs:t.inputs,activeRunId:t.activeRunId,preparation:t.preparation});V.current=t.revision,U(!t.activeRunId&&t.inputs.length===0),E.current=n,T(n)},[r]),ae=(0,Q.useCallback)(async e=>{if(e!==r.current)return;let t=d();if(await Lr(e)||!t())return;let n=await h(g(`/api/sessions/${encodeURIComponent(e)}/input-state`)).catch(()=>null);if(!n?.ok||r.current!==e)return;let i=await n.json().catch(()=>null);t()&&ie(i?.payload)},[ie,d,r]),oe=(0,Q.useCallback)(async e=>{if(e!==r.current)return;let t=d(),n=++S.current;if(await Lr(e)||!t())return;let i=await h(g(`/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),p(Rk(a?.payload,e)),C.current=null)},[d,r]);(0,Q.useLayoutEffect)(()=>{V.current=-1,U(!1),W.current=null,B.current=!1,z(!1),O(null),S.current++,L(mr(t??``)),M({kind:`compose`}),E.current=[],T([]),F(null),p(null)},[t,l]),(0,Q.useEffect)(()=>{!t||t!==n||(ae(t),oe(t))},[n,oe,ae,t,l]),(0,Q.useEffect)(()=>{let e=e=>{let t=e.detail;ie(t);let n=r.current;n&&t&&typeof t==`object`&&t.conversationId===n&&oe(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++,p(Rk(n,t)),C.current=null},n=()=>{let e=r.current;e&&(ae(e),oe(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)}},[ie,oe,ae,r]),(0,Q.useEffect)(()=>{if(!f?.expiresAt)return;let e=Math.max(0,f.expiresAt-Date.now())+250,t=window.setTimeout(()=>{let e=r.current;e&&oe(e)},e);return()=>window.clearTimeout(t)},[f?.expiresAt,oe,r]);let se=(0,Q.useCallback)(()=>{b(null),p(null)},[]),ce=(0,Q.useCallback)(e=>{let t=String(e??``).trim();t&&r.current===t&&(b(null),p(null))},[r]),le=(0,Q.useCallback)(()=>{b(null),p(null)},[]),ue=(0,Q.useCallback)(()=>{F(null)},[]),de=(0,Q.useCallback)(()=>{b(null),p(null),F(null)},[]),G=(0,Q.useCallback)(e=>t=>{c(e)&&(i.current=!1,a.current=!1,Sn.getState().setSessionFlags(e,{sending:!1,streaming:!1}),Sn.getState().setSessionProgress(e,null),b(null),S.current++,p({...t,conversationId:e}),C.current=null)},[c,i,a]),K=(0,Q.useCallback)(async(e,t,n,i,a,o)=>{let s=e.trim();if(!s&&!t?.length&&!n?.length)return;let c=r.current;if(!c)throw Error(`No active session`);let l=d(),u=mr(c),f=await jr(c);if(!l())throw new DOMException(`Conversation changed`,`AbortError`);let p=await ir();if(!l())throw new DOMException(`Conversation changed`,`AbortError`);if(!f)throw Error(`Reload the conversation before sending`);let m=Sn.getState().sessions[c]?.configVersion;if(m===void 0)throw Error(`Reload the conversation before sending`);let h=await Lk(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()&&ie(h)},[ie,d,r]),fe=(0,Q.useCallback)(async(e,t)=>{let n=r.current;if(!n||B.current)throw Error(`Wait for the current operation`);let i=d(),a=()=>{if(!i())throw new DOMException(`Conversation changed`,`AbortError`)};B.current=!0,z(!0);try{let r=await jr(n);a();let i=Date.now()+15e3;for(;!r&&e===`stop`&&Date.now()<i;)await new Promise(e=>setTimeout(e,100)),r=await jr(n),a();if(!r)throw Error(`Input acceptance is awaiting confirmation`);if(t?.onlyIfEmpty&&N.current.kind!==`compose`)return;let o={action:e,operationId:crypto.randomUUID(),expectedTranscriptId:r,expectedVersion:mr(n).version,...t},s=await Qn(n,o);if(a(),ie(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(;mr(n).phase===`stopping`;){if(a(),Date.now()>=e)throw Error(`Stop is awaiting confirmation`);await new Promise(e=>setTimeout(e,100)),await ae(n)}}if(a(),e===`stop`||e===`pause`){let t=mr(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 ae(n),!i())||t?.onlyIfEmpty||ba(`error`,e instanceof Error?e.message:String(e)),e}finally{i()&&(B.current=!1,z(!1))}},[ie,d,r,ae]);(0,Q.useEffect)(()=>{if(!t||!H||!I.paused||I.phase!==`idle`||R||j.kind!==`compose`||te!==u.current)return;let e=`${l}:${t}:${I.version}:${V.current}`;if(W.current===e)return;let n=window.setTimeout(()=>{B.current||N.current.kind!==`compose`||(W.current=e,fe(`resume`,{onlyIfEmpty:!0}).catch(()=>{}))},0);return()=>window.clearTimeout(n)},[fe,j.kind,I.paused,I.phase,I.version,R,t,l,te,H]);let q=(0,Q.useCallback)(()=>fe(`stop`),[fe]),pe=(0,Q.useCallback)(()=>fe(`resume`),[fe]),me=(0,Q.useCallback)(async(e,t)=>{let n=d();try{return await fe(`stop`,{turnId:e}),n()?(M({kind:`editTurn`,turnId:e,draft:t}),!0):!1}catch{return!1}},[d,fe]),J=(0,Q.useCallback)(async e=>{let t=E.current.find(t=>t.id===e);if(!t)return!1;let n=d();try{return await fe(`pause`,{inputId:e,inputVersion:t.version}),n()?(M({kind:`editFollowUp`,inputId:e,version:t.version}),!0):!1}catch{return!1}},[d,fe]),he=(0,Q.useCallback)(()=>M({kind:`compose`}),[]),ge=(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 h(g(`/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}))})}),f=await u.json();if(!l())return!1;if(ie(f.payload),!u.ok)throw Error(f.error?.message??`This input changed; your draft has been preserved`);if(N.current===j){let t=f.payload?.inputs?.find(t=>t.id===e);t&&M({...j,version:t.version})}return!0},[ie,d,j,r,o,s]),_e=(0,Q.useCallback)(e=>{ee.current===e&&F(null);let t=r.current,n=E.current.find(t=>t.id===e);if(!t||!n)return;let i=d();h(g(`/api/sessions/${encodeURIComponent(t)}/inputs/${encodeURIComponent(e)}?version=${n.version}`),{method:`DELETE`}).then(async e=>{let t=await e.json().catch(()=>null);i()&&ie(t?.payload)}).catch(()=>{ae(t)})},[ie,d,ae,r]),ve=(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();h(g(`/api/sessions/${encodeURIComponent(o)}/inputs/${encodeURIComponent(s.id)}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({version:s.version,position:a})}).then(async e=>{let t=await e.json().catch(()=>null);c()&&ie(t?.payload)}).catch(()=>{ae(o)})},[ie,d,ae,r]),ye=(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();h(g(`/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()&&ie(t?.payload)}).catch(()=>{ae(n)})},[ie,d,ae,r]),be=(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 fe(t,{inputId:e,inputVersion:n.version})}finally{r()&&O(null)}},[d,fe]),xe=(0,Q.useCallback)(e=>be(e,`steer`),[be]),Se=(0,Q.useCallback)(e=>be(e,`send`),[be]),Ce=(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 Fk(n.requestId,n.version,e,t,r.current??void 0):await h(g(`/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)&&oe(t);return}C.current=null,p(null),b(null)}catch(e){x.current?.requestId===n.requestId&&b(e instanceof Error?e.message:String(e))}finally{v(!1)}},[oe,r]);return{clarifyPrompt:f,clarifySubmitting:m,clarifySubmitError:y,clarifyPromptRef:x,pendingFollowUps:w,pendingFollowUpsRef:E,steeringFollowUpId:D,composerMode:j,control:I,controlPending:R,stopSession:q,resumeQueue:pe,sendQueuedInput:Se,beginEditTurn:me,cancelEditor:he,restoreEditor:M,markComposerHydrated:re,editingFollowUpId:P,addPendingFollowUp:K,beginEditFollowUp:J,cancelEditFollowUp:he,commitEditFollowUp:ge,removePendingFollowUp:_e,movePendingFollowUp:ve,reorderPendingFollowUp:ye,steerPendingFollowUp:xe,submitClarifyAnswer:(0,Q.useCallback)(e=>Ce(`answer`,e),[Ce]),letAgentDecideClarification:(0,Q.useCallback)(()=>Ce(`agent_decide`),[Ce]),cancelClarification:(0,Q.useCallback)(()=>Ce(`cancel`),[Ce]),clearVisibleClarify:se,dismissClarify:le,dismissClarifyForSession:ce,clearPendingFollowUps:ue,dismissClarifyAndClearPending:de,makeOnClarifyRequest:G}}function Bk(e){let t=(0,X.c)(51),{navigate:n,conversationIdRef:r,conversationId:i,isNewRoute:a,locationState:o,locationSearch:s,personal:c}=e,l=c!==void 0&&c,u=_(Wk),d;t[0]===u?d=t[1]:(d=u?[`gateway-chat-agents`,u]:null,t[0]=u,t[1]=d);let f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f={revalidateOnFocus:!1},t[2]=f):f=t[2];let{data:p,mutate:m}=Qr(d,si,f),{data:h}=Yf(i),g=h?.agentId??``,v,y;t[3]===m?(v=t[4],y=t[5]):(v=()=>{let e=e=>{oi(e.detail)||m()};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},y=[m],t[3]=m,t[4]=v,t[5]=y),(0,Q.useEffect)(v,y);let[b,x]=(0,Q.useState)(Uk),S=(0,Q.useRef)(p??null),C;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(C=Yr().selectedAgentId??null,t[6]=C):C=t[6];let w=(0,Q.useRef)(C),T,E;t[7]===p?(T=t[8],E=t[9]):(T=()=>{S.current=p??null},E=[p],t[7]=p,t[8]=T,t[9]=E),(0,Q.useEffect)(T,E);let D,O;t[10]===b?(D=t[11],O=t[12]):(D=()=>{w.current=b},O=[b],t[10]=b,t[11]=D,t[12]=O),(0,Q.useEffect)(D,O);let k,A;t[13]===p?(k=t[14],A=t[15]):(k=()=>{if(!p)return;let e=new Set(p.items.map(Hk));x(t=>t==null||t===``||!e.has(t)?p.defaultId:t)},A=[p],t[13]=p,t[14]=k,t[15]=A),(0,Q.useEffect)(k,A);let j;t[16]!==r||t[17]!==g?(j=()=>{if(r.current&&g)return g;let e=S.current,t=(w.current??``).trim().toLowerCase();if(!e)return t||void 0;let n=new Set(e.items.map(Vk));return t&&n.has(t)?t:e.defaultId},t[16]=r,t[17]=g,t[18]=j):j=t[18];let M=j,N;t[19]!==r||t[20]!==g||t[21]!==h?.projectId||t[22]!==a||t[23]!==s||t[24]!==o||t[25]!==n?(N=e=>{let t=e.trim().toLowerCase(),i=r.current?g||w.current:null;w.current=t,x(t),Vr(t),i!==t&&n(a?`/chat/new${s}`:La(h?.projectId),{replace:!1,state:{...a&&o&&typeof o==`object`?o:{},agentId:t,forceNewChat:!0}})},t[19]=r,t[20]=g,t[21]=h?.projectId,t[22]=a,t[23]=s,t[24]=o,t[25]=n,t[26]=N):N=t[26],h?.projectId;let P=N,F,I;t[27]===P?(F=t[28],I=t[29]):(F=()=>{let e=e=>{let t=e.detail?.agentId;typeof t!=`string`||!t.trim()||P(t)};return window.addEventListener(`xopc-set-chat-agent`,e),()=>window.removeEventListener(`xopc-set-chat-agent`,e)},I=[P],t[27]=P,t[28]=F,t[29]=I),(0,Q.useEffect)(F,I);let L,R;t[30]!==i||t[31]!==g||t[32]!==l?(L=()=>{if(!i||l)return;let e=g;!e||w.current===e||(w.current=e,x(e),Vr(e))},R=[g,i,l],t[30]=i,t[31]=g,t[32]=l,t[33]=L,t[34]=R):(L=t[33],R=t[34]),(0,Q.useLayoutEffect)(L,R);let z,B;t[35]!==i||t[36]!==h?(z=()=>{!i||!h||qr(h.projectId)},B=[h,i],t[35]=i,t[36]=h,t[37]=z,t[38]=B):(z=t[37],B=t[38]),(0,Q.useLayoutEffect)(z,B);let ee,V;t[39]!==a||t[40]!==o?(ee=()=>{if(!a)return;let e=o,t=typeof e?.agentId==`string`?e.agentId.trim().toLowerCase():``;t&&(w.current=t,x(t),Vr(t))},V=[a,o],t[39]=a,t[40]=o,t[41]=ee,t[42]=V):(ee=t[41],V=t[42]),(0,Q.useLayoutEffect)(ee,V);let H=g||b||p?.defaultId||`main`,U=(p?.items.length??0)>1,W=h?.projectId??null,te;return t[43]!==p||t[44]!==H||t[45]!==P||t[46]!==M||t[47]!==U||t[48]!==W||t[49]!==u?(te={token:u,chatAgentsData:p,resolveAgentIdForPost:M,onChatAgentChange:P,displayAgentId:H,showChatAgentSelector:U,currentSessionProjectId:W},t[43]=p,t[44]=H,t[45]=P,t[46]=M,t[47]=U,t[48]=W,t[49]=u,t[50]=te):te=t[50],te}function Vk(e){return e.id}function Hk(e){return e.id}function Uk(){return Yr().selectedAgentId??null}function Wk(e){return e.conversationId}async function Gk(e){let t=await e.sessionMgr.createSession(e);return{kind:`create`,conversationId:t.key,session:t}}var Kk=new Map,qk=0;function Jk(e){let t=_.getState(),n=Hr(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=Kk.get(r);if(i)return i.target.opts=e,i.target.generation=++qk,i.promise;let a={opts:e,generation:++qk},o=e=>{if(a.generation!==qk)return;let t=a.opts;!t.routeConversationId&&yi.getState().scope===`new`&&yi.getState().migrateScope(`new`,e),t.onOpened(e),(t.routeConversationId?.trim()||null)!==e&&t.navigateToSession(e,t.replaceNavigate??!1,t.search)},s=(async()=>{let t=e.agentId??void 0,{conversationId:n}=await Gk({sessionMgr:e.sessionMgr,agentId:t?.trim()||`main`,projectId:e.projectId,currentConversationId:e.currentConversationId,forceNew:e.forceNew,temporary:e.temporary,...new URLSearchParams(e.search).get(`agentSetup`)===`1`?{agentSetup:!0,agentSetupLanguage:v.getState().language===`zh`?`zh-CN`:`en`}:{},initialAgentConfig:e.initialAgentConfig,executionMode:e.executionMode});return o(n),n})().finally(()=>{Kk.delete(r)});return Kk.set(r,{promise:s,target:a}),s}var Yk={current:null},Xk={current:null};function Zk(e){return!!(e&&typeof e==`object`&&e.forceNewChat===!0)}function Qk(e){let t=d(),{conversationId:n}=u(),r=!e&&t.pathname.endsWith(`/new`),i=r&&Zk(t.state),a=e??Dk(r,n),o=Ek(r,a),s=Sk(o),c=r?null:a??null,l=(0,Q.useRef)(o);return l.current=o,Yk.current=c,!r&&a&&(Xk.current=a),(0,Q.useLayoutEffect)(()=>{Sn.getState().focusedConversationId!==c&&Sn.getState().setFocusedConversationId(c)},[c]),{isNewRoute:r,forceNewChat:i,decodedKey:a,routedConversationId:o,viewConversationId:s,routedFocusedConversationId:c,routeConversationIdRef:l,locationKey:t.key,locationSearch:t.search,locationState:t.state}}var $k={get current(){return Xk.current}},eA={get current(){return Yk.current},set current(e){Yk.current=e,Sn.getState().setFocusedConversationId(e)}};function tA(e){let{token:t,isNewRoute:n,forceNewChat:r,temporary:i=!1,requestedAgentId:a,decodedKey:o,locationKey:s,locationSearch:c,sessionMgrRef:l,resolveAgentIdForPost:u,navigateToSession:d,loadSessionById:f,tryResumeAgentRun:p,restoreLiveCacheIfNeeded:m,adoptEmptySession:h,applyAgentConfig:g,patchInitUi:v}=e,y=(0,Q.useRef)(0),b=_(e=>e.baseUrl),[x,S]=(0,Q.useState)(null),C=n?c:``,w=n?`new:${s}`:o?`session:${o}`:`fallback:${s}`,T=(0,Q.useRef)({isNewRoute:n,forceNewChat:r,temporary:i,requestedAgentId:a,decodedKey:o,newRouteLocationSearch:C});T.current={isNewRoute:n,forceNewChat:r,temporary:i,requestedAgentId:a,decodedKey:o,newRouteLocationSearch:C};let E=(0,Q.useRef)({sessionMgrRef:l,resolveAgentIdForPost:u,navigateToSession:d,loadSessionById:f,tryResumeAgentRun:p,restoreLiveCacheIfNeeded:m,adoptEmptySession:h,applyAgentConfig:g,patchInitUi:v});return E.current={sessionMgrRef:l,resolveAgentIdForPost:u,navigateToSession:d,loadSessionById:f,tryResumeAgentRun:p,restoreLiveCacheIfNeeded:m,adoptEmptySession:h,applyAgentConfig:g,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=Yr(),i=n.resolveAgentIdForPost(),s=Wr({origin:`web-route`,project:Ia(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 fn(s.projectId):null;if(!a())return;!e.requestedAgentId&&c?.defaultAgentId&&(s.agentId=c.defaultAgentId);let l=Jr(r,s.agentId),u=(t,r,i)=>Jk({sessionMgr:n.sessionMgrRef.current,agentId:s.agentId,currentConversationId:$k.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:Ra(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=Ln(e)?.messages??t??bn(e);return n.tryResumeAgentRun(e,r)},l=e=>a()?Ln(e)?.historyStatus===`ready`?(o(e),c(e,bn(e))):n.loadSessionById(e,0).then(t=>{if(a())return c(e,t??bn(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=Ln(t.key)?.messages??e??bn(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 Jk({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 nA(e){let t=_(e=>e.conversationId),n=_(e=>e.baseUrl),[r,i]=(0,Q.useState)(null),{data:a,error:o}=Qr(e?[`prepared-session-model`,n,t,e.create]:null,async()=>{let t=Jr(Yr(),e.agentId),[n,r]=await Promise.all([hi(),t?.modelRef??_i(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?Xr(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&&Gr(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=Jr(Yr(),e.agentId)?.thinkingByModel?.[t],c=r.thinking?Xr(r.thinking,n??s?.thinkingLevel,n===void 0?o:void 0):n??s?.thinkingLevel??`medium`;i({preparation:e,selection:{model:t,thinkingLevel:c}})};return{preparation:f,model:s?.model??``,thinkingLevel:s?.thinkingLevel??`medium`,modelSupportsThinking:!!c?.reasoning,ready:l,error:o,onModelChange:e=>p(e),onThinkingChange:e=>p(s?.model??``,e)}}var rA=class{tails=new Map;run(e,t){let n=this.tails.get(e),r=n?n.then(t,t):Promise.resolve().then(t),i=r.finally(()=>{this.tails.get(e)===i&&this.tails.delete(e)});return this.tails.set(e,i),i.catch(()=>{}),r}};async function iA(e){let t=e.trim();if(!t)return!1;try{return!!(await hi()).find(e=>e.id===t)?.reasoning}catch{return!1}}function aA(e){let{sessionMgrRef:t,routeConversationIdRef:n,sendingRef:r,streamingRef:a,loadingSessionRef:o,messagesLenRef:s,thinkingSupportGenRef:c,navigateToSession:l,resolveAgentIdForPost:u,detachForNewConversation:d,conversationId:f,sessionAgentId:p,currentProjectId:m,taskId:h,hasMore:g}=e,_=()=>Sn.getState(),v=(0,Q.useRef)(new rA),y=(0,Q.useRef)(0),b=(0,Q.useRef)(null),x=(0,Q.useRef)(0),S=(0,Q.useCallback)(e=>{let t=_().focusedConversationId;if(!e.trim())return++c.current===c.current&&t&&_().patchSessionMeta(t,{modelSupportsThinking:!1}),Promise.resolve();let n=++c.current;return iA(e).then(t=>{if(n!==c.current)return;let r=_().focusedConversationId;r&&_().sessions[r]?.model===e&&_().patchSessionMeta(r,{modelSupportsThinking:t})})},[c]),C=(0,Q.useCallback)(async e=>{try{let n=await t.current.loadSessionAgentConfig(e);hr(e,n),S(n.model)}catch{}},[t,S]),w=(0,Q.useCallback)(()=>{let e=_().focusedConversationId;if(!e||(_().sessions[e]?.name)?.trim())return;let n=++x.current,r=[700,900,900,1e3,1e3],i=a=>{a>=5||n===x.current&&_().focusedConversationId===e&&(_().sessions[e]?.name?.trim()||window.setTimeout(()=>{n===x.current&&_().focusedConversationId===e&&(_().sessions[e]?.name?.trim()||t.current.fetchSessionName(e).then(t=>{if(n===x.current){if(t){_().patchSessionMeta(e,{name:t});return}i(a+1)}}).catch(()=>{i(a+1)}))},r[a]??900))};i(0)},[t]),T=(0,Q.useCallback)(e=>Tk({chatId:e,routeConversationId:n.current}),[n]),E=(0,Q.useCallback)((e,t,n)=>{let r=_().sessions[e];if(n&&r?.messages!==n.messages&&!zn(r))return!1;let i=t.hasMore&&Er(r?.messages??[],t.messages)>0;return _().mergeCommittedFromServer(e,t.messages,t.hasMore,n?.completedRunId),t.name!==void 0&&_().patchSessionMeta(e,{name:t.name||null}),T(e)&&(i||(b.current=t.nextBeforeCursor??null)),!0},[T]),D=(0,Q.useCallback)(async(e,r=0,a)=>{let s=i(`session_load`),c=async(e,r,i)=>{let a=r===0&&!i;y.current++,o.current=!0,s(`request_started`);let d=a&&Cn(_().sessions[e]?.historyStatus);d&&_().setSessionHistoryStatus(e,`loading`);let f=a?Promise.resolve().then(()=>t.current.loadSessionAgentConfig(e)).then(e=>(s(`config_received`),{config:e}),e=>({error:e})):void 0;try{let n={messages:_().sessions[e]?.messages},{messages:o,hasMore:c,name:l,nextBeforeCursor:u}=await t.current.loadSession(e,r,i,h,n.messages);if(s(`history_received`),a){if(!E(e,{messages:o,hasMore:c,name:l,nextBeforeCursor:u},n))return _().sessions[e]?.messages;if(!T(e))return o;s(`history_committed`);let t=await f;if(`error`in t)throw t.error;let r=t.config;return T(e)?(hr(e,r),S(r.model),o):o}if(!T(e))return;b.current=u??null,_().prependHistoryMessages(e,o,c);return}catch(a){if(s(`failed`),n.current&&!T(e))return;if(r===0&&!i){b.current=null;let r=a instanceof Error?a.message:`Failed to load session`;_().setShellError(/^HTTP 404\b/.test(r)?JSON.stringify(Sr(r)):`Failed to load session`);let i=Sk(n.current);if(i&&i===e)return;let o=await t.current.loadSessions().catch(()=>[]),s=o.filter(e=>(e.messageCount??0)>0)[0]??o[0];if(s)return l(s.key,!0),await c(s.key,0,null);{b.current=null;let e=u();Jk({sessionMgr:t.current,agentId:e,currentConversationId:null,routeConversationId:null,navigateToSession:l,replaceNavigate:!0,onOpened:e=>{_().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:null}),C(e)}})}}return}finally{y.current--,o.current=y.current>0,s(`settled`),d&&_().sessions[e]?.historyStatus===`loading`&&_().setSessionHistoryStatus(e,`ready`)}};return v.current.run(e,()=>c(e,r,a))},[n,T,r,a,o,l,S,u,t,h,E]),O=(0,Q.useCallback)(async()=>{let e=_().focusedConversationId;if(!(!e||_().loadingMore||!g)){_().setLoadingMore(!0);try{await D(e,s.current,b.current)}finally{_().setLoadingMore(!1)}}},[g,D,s]),k=(0,Q.useCallback)(async(e,n)=>{if(!f)throw Error(`No active session`);let r=_().sessions[f];if(r?.modelConfigSaving)throw Error(`Model configuration is being saved`);if(!(r?.model===e&&n!==void 0&&r.thinkingLevel===n)){_().patchSessionMeta(f,{modelConfigSaving:!0});try{if(_().setShellError(null),n===void 0){let t=(await hi()).find(t=>t.id===e);if(t?.thinking){let i=Jr(Yr(),p)?.thinkingByModel?.[e];n=Xr(t.thinking,r?.thinkingLevel,i)}}let i=h?await t.current.patchTaskConversationModel(h,e,n,r?.configVersion):await t.current.patchSessionAgentConfig(f,{model:e,thinkingLevel:n,configVersion:r?.configVersion});hr(f,i),Gr(p,{modelRef:i.model,thinkingLevel:i.thinkingLevel}),i.model!==r?.model&&S(i.model)}catch(e){let n=e instanceof Error?e.message:`Failed to update model configuration`;_().setShellError(n);let r=await t.current.loadSessionAgentConfig(f).catch(()=>null);throw r&&hr(f,r),e}finally{_().patchSessionMeta(f,{modelConfigSaving:!1})}}},[f,p,h,t,S]);return{refreshModelThinkingSupport:S,pollSessionNameAfterTurn:w,applyLoadedSessionSnapshot:E,loadSessionById:D,loadMoreMessages:O,onSessionModelChange:k,onSessionThinkingLevelChange:(0,Q.useCallback)(async e=>{let t=f?_().sessions[f]?.model:void 0;t&&await k(t,e)},[f,k]),onSessionWorkingDirectoryChange:(0,Q.useCallback)(async e=>{let n=e.trim();if(!(!f||!n))try{_().setShellError(null),await t.current.patchSessionAgentConfig(f,{workingDirectory:n}),await C(f)}catch(e){throw _().setShellError(e instanceof Error?e.message:`Failed to update working directory`),e}},[C,f,t]),createNewSession:(0,Q.useCallback)(async e=>{_().setShellError(null);let n=u(),r=Jr(Yr(),n??`main`);await Jk({sessionMgr:t.current,agentId:n,currentConversationId:f,routeConversationId:f,forceNew:e?.forceNew,temporary:e?.temporary,executionMode:e?.executionMode,projectId:e?.projectId===void 0?m:e.projectId,initialAgentConfig:r?{model:r.modelRef,...r.thinkingLevel?{thinkingLevel:r.thinkingLevel}:{}}:void 0,navigateToSession:l,onOpened:e=>{d(),b.current=null,_().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:null}),C(e)}})},[d,l,u,m,f,t,C]),resetCurrentSession:(0,Q.useCallback)(async()=>{if(f){_().setShellError(null);try{await t.current.resetSession(f),d(),b.current=null,_().setCommittedSnapshot(f,{messages:[],hasMore:!1,name:null}),C(f)}catch(e){_().setShellError(e instanceof Error?e.message:`Failed to reset session`)}}},[C,f,d,t])}}function oA(e){return new Promise(t=>{Promise.resolve().then(()=>e(()=>t(!0))).then(()=>t(!1),()=>t(!1))})}function sA(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 cA(e){return e!==`suspended`}function lA(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=()=>Sn.getState(),h=()=>{m().sessions[t]?.progress?.stage.startsWith(`model_`)&&m().setSessionProgress(t,null)},g=e=>{let n=e?.runId,r={messages:m().sessions[t]?.messages,completedRunId:e?.terminal?n:void 0};return l.current.loadSession(t,0,void 0,void 0,r.messages).then(i=>{!p()||e?.signal.aborted||u(t,i,r)===!1||n&&m().sessions[t]?.messages.some(e=>e.role===`assistant`&&e.turnId===n&&e.content.some(e=>e.type===`text`&&e.text.trim()&&e.text.trim()!==`NO_REPLY`))&&xr(n,`history`)}).catch(()=>{})},_=new Map,y,b=()=>{if(y!==void 0&&(window.clearTimeout(y),y=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)cr(t.content,n,r)})},x=(e,t)=>{_.set(e,`${_.get(e)??``}${t}`),y===void 0&&(y=window.setTimeout(b,120))},C=e=>{m().clearStreamingState(t),o&&kn.setResumeRunId(t,null),m().setSessionFlags(t,{sending:!1,streaming:!1}),m().setSessionProgress(t,null),cA(e)&&f.dismissClarifyForSession(t),g()},w={onTextSurface:e=>{r(),m().mutateSessionStreaming(t,t=>{t.textSurface=e})},onReplayGap:g,onUserMessage:e=>{n(t)&&m().appendUserMessageIfMissing(t,e)},onStreamStart:(e,n,i)=>{np(t),r(),i&&m().updateSessionMessages(t,t=>er([...t,{role:`task`,content:[],taskTrigger:i,turnId:e,timestamp:Date.now()}])),m().updateSessionMessages(t,t=>Gn(t,e)),m().mutateSessionStreaming(t,t=>{t.turnId=e,n&&(t.startsNewBubble=!0)}),m().setSessionFlags(t,{streaming:!0})},onToken:(e,a,o)=>{h(),r(),m().mutateSessionStreaming(t,t=>{vn(t.content,e,a,{offset:o,reconcileHydratedSegment:i})}),n(t)&&m().setSessionFlags(t,{streaming:!0})},onAssistantMessageEnd:(e,n,i)=>{r(),m().mutateSessionStreaming(t,t=>{Hn(t.content,e,n),i&&(t.usage=i)})},onThinking:(e,n,i)=>{h(),r(),m().mutateSessionStreaming(t,t=>{!n&&e===``?Un(t.content):sr(t.content,e,n,i)})},onThinkingEnd:e=>{r(),m().mutateSessionStreaming(t,t=>{Ar(t.content,e)})},onToolStart:(e,n,i,a,o,s)=>{h(),r(),m().mutateSessionStreaming(t,t=>{jn(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=>{Pn(t.content,e,n,i,a,o,s,c)})},onToolUpdate:(e,n,i)=>{r(),m().mutateSessionStreaming(t,t=>{Tn(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=>{Nn(t.content,e)}),n(t)&&m().setSessionFlags(t,{streaming:!0})},onReviewStart:e=>{r(),m().mutateSessionStreaming(t,t=>{Vn(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=>{yn(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=S(v.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=>hr(t,e)).catch(()=>{}).finally(()=>m().patchSessionMeta(t,{modelConfigSaving:!1}))},onResult:({status:e})=>{b();let r=n(t);if(kn.takeUserAborted(t)||e===`cancelled`){ap(t),r?d(t,e):C(e);return}if(e===`error`){if(ip(t,!r),!r){C(e);return}d(t,e),g();return}if(e===`suspended`?op(t):rp(t,!r),!r){C(e);return}d(t,e)},onError:e=>{b();let r=n(t);if(ip(t,!r),!r){C(`error`);return}d(t,`error`),s&&kn.setResumeRunId(t,null),m().setSessionFlags(t,{sending:!1,streaming:!1}),m().setSessionProgress(t,null),c(e),f.dismissClarifyForSession(t)}};return Object.fromEntries(Object.entries(w).map(([e,t])=>[e,(...e)=>{if(p())return Reflect.apply(t,void 0,e)}]))}function uA(e){return Ln(e)?.streamingMsg??null}var dA=80;function fA(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>dA&&(t=t.slice(0,dA-1).trimEnd()+`…`),t}function pA(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 mA(e){let t=e.trimStart().match(/^\/skill:([^\s]+)(?:\s+([\s\S]*))?$/i);return t&&(t[2]?.trim()||t[1]?.trim())||e}function hA(e){let t=mA(pA(Wn([{type:`text`,text:e}]))).split(/\n/)[0]?.trim();if(!t)return null;let n=fA(t);return n.length>0?n:null}function gA(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 _A=new Set([`new`,`reset`,`restart`]),vA=new Set([..._A,`clear`,`archive`]);function yA(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 bA(e){let t=yA(e);return!!(t&&_A.has(t.name)&&!t.args)}function xA(e){let t=yA(e);return!!(t&&vA.has(t.name))}function SA(e){let{conversationId:t,taskId:n,thinkingLevel:r,modelSupportsThinking:i,conversationIdRef:a,sendingRef:o,streamingRef:s,sessionMgrRef:c,sendMessageRef:l,shouldApplyStreamUpdate:u,fq:d,applyLoadedSessionSnapshot:f,loadSessionById:p,resetCurrentSession:m,pollSessionNameAfterTurn:h}=e,g=()=>Sn.getState(),v=e=>g().setShellError(e),y=()=>g().setShellError(null),b=(0,Q.useCallback)((e,t)=>{let n=e??a.current;if(n&&!u(n))return;let r=n?uA(n):null,i=null;if(r){let e=wn(r,Date.now());e.runStatus=t,Dn(e.content,t===`success`),Ar(e.content),t!==`suspended`&&In(e.content,t===`success`),An(e.content),e.completedAt=t&&t!==`suspended`?Date.now():void 0,i=Mn(e)}i&&En(i)&&n?g().finalizeStreamingTurn(n,i):n&&g().clearStreamingState(n),o.current=!1,s.current=!1,n&&kn.resetRunTracking(n),(!t||cA(t))&&d.dismissClarify(),h();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,h,p,u]),x=(0,Q.useCallback)(async(e,t)=>{if(!u(e)||kn.isSubmittingFor(e))return;let r=_.getState().conversationId,i=()=>_.getState().conversationId===r,a=kn.getGeneration(e),l=g().sessions[e]?.streamingMsg,m=g().sessions[e]?.messages.findLast(e=>e.role===`user`)?.clientSubmissionId,h=await gr(e);if(!i()||kn.getGeneration(e)!==a||kn.isSubmittingFor(e))return;if(!h){let t=g().sessions[e]?.streamingMsg;if(t?.pendingResponseStatus||t&&t!==l||kn.isStreamingFor(e))return;let n=kn.getResumeRunId(e);n&&kn.reconcileInactive(e,n),g().clearStreamingState(e,{preservePendingResponse:!0}),ap(e);return}let y=()=>{let t=g().sessions[e]?.streamingMsg,n=g().sessions[e]?.messages.findLast(e=>e.role===`user`)?.clientSubmissionId;return!i()||kn.getGeneration(e)!==a||kn.isSubmittingFor(e)||!!(n&&n!==m)||!!(Zn(e)&&Zn(e)!==h)||!!(t?.turnId&&t.turnId!==h&&t.turnId!==l?.turnId)||!!(t?.pendingResponseStatus&&t!==l)};if(y()||kn.isTrackingRun(e,h))return;let x=()=>{let t=g().sessions[e]?.streamingMsg;!t?.turnId||t.turnId===h||t.turnId!==l?.turnId||(En(t)?g().finalizeStreamingTurn(e,Mn(t)):g().clearStreamingState(e))},S=t??bn(e),C=Ln(e)?.hasMore??!1;try{let t=await c.current.loadSession(e,0,void 0,n,g().sessions[e]?.messages);if(y()||kn.isTrackingRun(e,h))return;x(),g().mergeCommittedFromServer(e,t.messages,t.hasMore),S=t.messages,C=t.hasMore}catch{}if(y()||kn.isTrackingRun(e,h))return;x(),a=kn.advanceGeneration(e),kn.setUserAborted(e,!1),kn.setResumeRunId(e,h),o.current=!0,s.current=!0,g().seedSessionIfEmpty(e,S,!0,!0,C),g().setSessionFlags(e,{sending:!0,streaming:!0}),g().setSessionProgress(e,null),np(e);let w=!1,T=()=>{if(w||!u(e))return;w=!0;let t=kk(bn(e),h);t&&g().applyHydratedTail(e,t.messagesWithoutTail,Mn(t.tail))},E=()=>{g().clearStreamingState(e),kn.getResumeRunId(e)===h&&kn.setResumeRunId(e,null),u(e)&&(o.current=!1,s.current=!1)};try{let t=lA({chatId:e,shouldApplyStreamUpdate:u,isCurrentRun:()=>i()&&kn.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 kn.senderFor(e).resume(h,e,t,{replayFromStart:l?.turnId!==h||!En(l)});if(!i()||kn.getGeneration(e)!==a)return;n||(ap(e),E(),await p(e,0).catch(()=>void 0))}catch(t){if(!i()||kn.getGeneration(e)!==a)return;t.name!==`AbortError`&&console.error(`[chat] resume failed:`,t),ap(e),E()}finally{kn.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&&!kn.isStreamingFor(c))return!1;let l=e.trim();if(n&&xA(l))return v(`A task has one continuous conversation.`),!1;if(bA(l)&&!t?.length){await m();return}return await d.addPendingFollowUp(e,t,i,void 0,!0),!0},[o,s,a,d.addPendingFollowUp,m,n]),C=(0,Q.useCallback)(async(e,a,l,h,x,S,C,w,T)=>{if(!t||!u(t)||!e.trim()&&!a?.length&&!h?.length||o.current||s.current||kn.isStreamingFor(t))return!1;let E=e.trim();if(n&&xA(E))return v(`A task has one continuous conversation.`),!1;if(bA(E)&&!a?.length){await m();return}let D=i?l??r:`off`,O=t,k=kn.advanceGeneration(O),A=_.getState().conversationId,j=()=>_.getState().conversationId===A&&kn.getGeneration(O)===k,M=crypto.randomUUID(),N=`assistant-stream:${O}:${M}`,P=bn(O),F=w?P.filter(e=>e.clientSubmissionId!==w):P,I=x?F.findIndex(e=>e.role===`user`&&e.turnId===x):-1;if(x&&I<0)return!1;kn.setUserAborted(O,!1),o.current=!0,s.current=!1,y(),d.dismissClarify();let L=I>=0?F.slice(0,I):F,R=Rn(e)??void 0,z=new Map(h?.flatMap(e=>e.refId?[[e.refId,e.title]]:[])??[]),B=R?xn(R,e=>z.get(e)):e,ee=[...L,{role:`user`,content:B?[{type:`text`,text:B}]:[],userTurnDocument:R,deliveryStatus:`sending`,clientSubmissionId:M,pendingAppContext:S===void 0?void 0:structuredClone(S),attachments:a,contextRefs:h?.map(e=>({refId:e.refId,kind:e.kind,sourceId:e.sourceId,version:e.expectedVersion,title:e.title,fileKind:e.fileKind})),timestamp:Date.now()}];C?.(M);let V=Ln(O);if(g().initSessionSnapshot(O,{...V??{...On(),historyStatus:`ready`,hasMore:!1,streamingMsg:null,progress:null,taskPlan:null,sending:!1,streaming:!1},messages:ee,hasMore:V?.hasMore??!1,streamingMsg:{role:`assistant`,content:[],timestamp:Date.now(),renderKey:N,pendingResponseStatus:`sending`},progress:null,sending:!0,streaming:!1}),np(O),!V?.name?.trim()&&B.trim()){let e=hA(B.trim());e&&(g().patchSessionMeta(O,{name:e}),gA(O,e))}let H=e=>{g().updateSessionMessages(O,t=>sA(t,M,e))};return oA(async t=>{let r=!1;try{let i=lA({chatId:O,shouldApplyStreamUpdate:u,isCurrentRun:j,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`),j()&&g().setPendingResponseStatus(O,`waiting`),t()},await kn.senderFor(O).send(e,O,a,D,i,n,x,h,S,T)}catch(e){if(!j())return;if(e.name!==`AbortError`)g().clearStreamingState(O),ap(O),u(O)&&v(e instanceof Error?e.message:String(e)),x&&p(O,0);else{ap(O);let e=Ln(O)?.streamingMsg;e?.renderKey===N&&e.pendingResponseStatus&&g().clearStreamingState(O)}}finally{j()&&(r||H(`failed`),u(O)&&(o.current=!1,s.current=!1),g().setSessionFlags(O,{sending:!1}),kn.releaseIdleSender(O))}})},[t,r,i,o,s,u,c,f,b,d.dismissClarify,m,n,p]),w=(0,Q.useCallback)((e,t,n,r,i,a)=>C(t,n,r,i,e,void 0,void 0,void 0,a),[C]),T=(0,Q.useCallback)((e,t)=>{let n=a.current;if(!n||mr(n).phase!==`idle`||kn.getGeneration(n)!==e)return;let r=kn.getResumeRunId(n),i=g().sessions[n]?.streamingMsg?.turnId;r&&r!==t||i&&i!==t||(d.dismissClarify(),kn.abort(n,!1),ap(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=kn.getGeneration(e),n=kn.getResumeRunId(e)??g().sessions[e]?.streamingMsg?.turnId??null;await d.stopSession(),a.current===e&&T(t,n)},[d.stopSession,a,T]),settleStoppedRun:T,deleteMessageRound:(0,Q.useCallback)(e=>{let t=a.current;if(!t||o.current||s.current)return;let n=bn(t),r=n[e];if(!r||!_n(r.role))return;if(r.deliveryStatus===`failed`){let r=[...n];r.splice(e,1),g().updateSessionMessages(t,()=>r);return}let i=br(n,e);if(i===null)return;let l=tr(n,e),u=[...n];u.splice(e,l),g().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=bn(t),r=n[e];if(!r||!_n(r.role))return;for(let t=e+1;t<n.length;t++){let e=n[t];if(e&&_n(e.role))return}let i=r.userTurnDocument?Tr(r.userTurnDocument):Wn(r.content),c=Kn(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 CA(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)(TA,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(oi(e.detail))return;let t=r.current;t&&i.current.loadSessionAgentConfig(t).then(e=>{s(t,e)}).catch(wA)};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 wA(){}function TA(){let e=EA;return window.addEventListener(`session-updated`,e),()=>window.removeEventListener(`session-updated`,e)}function EA(e){let t=e.detail;!t?.key||t.name===void 0||Sn.getState().patchSessionMeta(t.key,{name:t.name||null})}function DA(e){let t=m(),{isNewRoute:n,forceNewChat:r,decodedKey:i,viewConversationId:a,routedFocusedConversationId:o,routeConversationIdRef:s,locationKey:c,locationSearch:l,locationState:u}=Qk(e?.fixedConversationId),d=(0,Q.useRef)(new yr),f=(0,Q.useRef)(!1),p=(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=Sn(e=>e.initLoading),w=Sn(e=>e.loadingMore),T=Sn(e=>e.shellError),E=a,D=ih(E),O=E?zn(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=jk(D,Qr(gi,hi,{revalidateOnFocus:!1}).data),L=D?.modelConfigSaving??!1,R=D?.thinkingLevel??`medium`,z=D?.reasoningLevel??`on`,B=D?.modelSupportsThinking??!1,ee=D?.effectiveWorkspacePath??``,V=D?.workspaceSource??`agent_default_root`,H=D?.userContextMode??`enabled`;(0,Q.useEffect)(()=>{!E||A||k||d.current.loadSessionAgentConfig(E).then(e=>hr(E,e)).catch(()=>void 0)},[E,A,k]),(0,Q.useEffect)(()=>{let e=e=>{let t=e.detail.conversationId;d.current.loadSessionAgentConfig(t).then(e=>hr(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)(()=>{p.current=A,h.current=k},[A,k]);let{token:U,chatAgentsData:W,resolveAgentIdForPost:te,onChatAgentChange:ne,displayAgentId:re,showChatAgentSelector:ie,currentSessionProjectId:ae}=Bk({navigate:t,personal:e?.personal,conversationIdRef:eA,conversationId:S,isNewRoute:n,locationState:u,locationSearch:l}),oe=i!==void 0&&S!==i,se=!!(U&&i&&!T&&D?.historyStatus!==`ready`&&!oe),ce=(0,Q.useMemo)(()=>C&&(S==null||i===void 0),[C,S,i]),le=Nk({isNewRoute:n,sessionRoutePending:oe,showSessionLoading:ce,sessionContentLoading:se,messageCount:D?.messages.length??0}),ue=(0,Q.useCallback)((e,n=!1,r)=>{let i=r??``;t({pathname:`/chat/${encodeURIComponent(e)}`,search:i},{replace:n})},[t]),de=(0,Q.useCallback)(e=>Ck({streamConversationId:e,routeConversationId:s.current}),[s]),G=(0,Q.useCallback)(()=>{Mk({sendingRef:p,streamingRef:h})},[]),K=zk({conversationId:S,decodedKey:i,conversationIdRef:eA,sendingRef:p,streamingRef:h,modelSupportsThinking:B,thinkingLevel:R,shouldApplyStreamUpdate:de}),fe=(0,Q.useCallback)(()=>{K.clearVisibleClarify();let e=eA.current;e&&kn.resetRunTracking(e),Ak(G)},[K.clearVisibleClarify,eA,G]),{refreshModelThinkingSupport:q,pollSessionNameAfterTurn:pe,applyLoadedSessionSnapshot:me,loadSessionById:J,loadMoreMessages:he,onSessionModelChange:ge,onSessionThinkingLevelChange:_e,onSessionWorkingDirectoryChange:ve,createNewSession:ye,resetCurrentSession:be}=aA({sessionMgrRef:d,routeConversationIdRef:s,sendingRef:p,streamingRef:h,loadingSessionRef:f,messagesLenRef:x,thinkingSupportGenRef:g,navigateToSession:ue,resolveAgentIdForPost:te,detachForNewConversation:fe,conversationId:S,sessionAgentId:re,currentProjectId:ae,hasMore:N,taskId:e?.taskId}),xe=(0,Q.useCallback)(e=>{if(!wk({cacheConversationId:e,routeConversationId:s.current}))return!1;let t=Ln(e);return!t||!zn(t)&&!pr(e)&&!kn.isStreamingFor(e)?!1:(p.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}=SA({conversationId:S,taskId:e?.taskId,thinkingLevel:R,modelSupportsThinking:B,conversationIdRef:eA,sendingRef:p,streamingRef:h,sessionMgrRef:d,sendMessageRef:b,shouldApplyStreamUpdate:de,fq:K,applyLoadedSessionSnapshot:me,loadSessionById:J,resetCurrentSession:be,pollSessionNameAfterTurn:pe});(0,Q.useEffect)(()=>{n&&fe()},[n,fe]);let Ae=(0,Q.useMemo)(()=>Ok({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)=>{Sn.getState().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:t}),G()},[G]),Me=(0,Q.useCallback)((e,t)=>{hr(e,t),q(t.model)},[q]),Ne=(0,Q.useCallback)(e=>{let t=Sn.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 d.current.loadTimeline(t,e?.taskId);if(s.current!==t)return;y(n)}catch{s.current===t&&y([])}},[s,e?.taskId]);(0,Q.useEffect)(()=>{if(n||!S){y([]);return}Pe(S)},[S,n,Pe]),CA({conversationId:S,conversationIdRef:eA,sendingRef:p,streamingRef:h,sessionMgrRef:d,loadSessionById:J,loadTimelineById:Pe,applyAgentConfig:Me});let Fe=tA({token:U,isNewRoute:n,forceNewChat:r,temporary:u?.temporary===!0,requestedAgentId:typeof u?.agentId==`string`?u.agentId:void 0,decodedKey:i,locationKey:c,locationSearch:l,sessionMgrRef:d,resolveAgentIdForPost:te,navigateToSession:ue,loadSessionById:J,tryResumeAgentRun:Se,restoreLiveCacheIfNeeded:xe,adoptEmptySession:je,applyAgentConfig:Me,patchInitUi:Ne}),Ie=nA(Fe);return(0,Q.useEffect)(()=>{Fe&&Ie.error&&Sn.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()||(lr(n,r),kn.setResumeRunId(n,r),de(n)&&(kn.isTrackingRun(n,r)||queueMicrotask(()=>{de(n)&&(kn.isTrackingRun(n,r)||Se(n,bn(n)))})))};return window.addEventListener(`run-started`,e),()=>window.removeEventListener(`run-started`,e)},[Se,de]),(0,Q.useEffect)(()=>{let e=k||A,t=_.current;if(_.current=e,!t||e)return;let n=eA.current;n&&queueMicrotask(()=>{!n||!de(n)||kn.isStreamingFor(n)||pr(n)&&Se(n,bn(n))})},[k,A,Se,de]),b.current=Ce,{auth:{hasToken:!!U},session:{projectPreparation:Ie.preparation,conversationId:S,sessionName:P,decodedKey:i,sessionRoutePending:oe,sessionContentLoading:se,showSessionLoading:ce,conversationPhase:le,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:ee,workspaceSource:V,userContextMode:Fe?.temporary?`temporary`:H,hasMore:N,loadingMore:w,loadMoreMessages:he,onSessionModelChange:Fe?Ie.onModelChange:ge,createNewSession:ye,sessionManager:d.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:K.composerMode,control:K.control,controlPending:K.controlPending,beginEditTurn:K.beginEditTurn,cancelEditor:K.cancelEditor,restoreEditor:K.restoreEditor,markComposerHydrated:K.markComposerHydrated,resumeQueue:K.resumeQueue,sendQueuedInput:K.sendQueuedInput,addPendingFollowUp:K.addPendingFollowUp,pendingFollowUps:K.pendingFollowUps,editingFollowUpId:K.editingFollowUpId,beginEditFollowUp:K.beginEditFollowUp,cancelEditFollowUp:K.cancelEditFollowUp,commitEditFollowUp:K.commitEditFollowUp,removePendingFollowUp:K.removePendingFollowUp,movePendingFollowUp:K.movePendingFollowUp,reorderPendingFollowUp:K.reorderPendingFollowUp,steerPendingFollowUp:K.steerPendingFollowUp,steeringFollowUpId:K.steeringFollowUpId},clarify:{clarifyPrompt:K.clarifyPrompt,clarifySubmitting:K.clarifySubmitting,clarifySubmitError:K.clarifySubmitError,submitClarifyAnswer:K.submitClarifyAnswer,letAgentDecideClarification:K.letAgentDecideClarification,cancelClarification:K.cancelClarification},agents:{chatAgents:W,displayAgentId:Fe?.agentId??re,showChatAgentSelector:ie,onChatAgentChange:ne}}}function OA(e){let t=(0,X.c)(11),n=_(kA),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=Sn(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 Lr(i))return;let e=await hn(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],Qr(s,c,l)}function kA(e){return e.conversationId}function AA(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 jA(e,t){return AA(Fn(e??``),t)}function MA(e,t){return fa(e,t)}function NA(e){return e===`context`||e===`branch`||e===`compaction`?e:null}function PA(e){return AA(e.preview||e.title,72)||e.kind}function FA(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:jA(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:MA(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=NA(a.kind);if(!e)continue;let o=`${a.id}:${a.kind}`;r.events.some(e=>e.key===o)||r.events.push({key:o,label:PA(a),tone:e})}return n}function IA(e,t){return(e===1?t.toolCount_one:t.toolCount_other).replace(`{{count}}`,String(e))}function LA(e,t){let n=e[0]?.id;for(let r of e)r.messageIndex<=t&&(n=r.id);return n}function RA(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:Ey(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)(Yt,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),IA(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(zA),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 zA(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)(Yt,{className:`size-3 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.label})]},e.key)}function VA(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=FA(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=LA(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)(Le,{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)(w,{asChild:!0,children:(0,Z.jsx)(vi,{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)(C,{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)(k,{className:`min-w-0 truncate text-base font-semibold text-fg`,children:i.title}),t[11]=i.title,t[12]=y);let b;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(Xt,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=b):b=t[13];let x;t[14]===o?x=t[15]:(x=(0,Z.jsx)(E,{asChild:!0,children:(0,Z.jsx)(vi,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":o,children:b})}),t[14]=o,t[15]=x);let S;t[16]!==y||t[17]!==x?(S=(0,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,x]}),t[16]=y,t[17]=x,t[18]=S):S=t[18];let T;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)(RA,{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],T=u.map(e),t[19]=m,t[20]=s,t[21]=i,t[22]=c,t[23]=u,t[24]=T}else T=t[24];let j;t[30]===T?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:T})}),t[30]=T,t[31]=j);let M;t[32]!==S||t[33]!==j?(M=(0,Z.jsxs)(D,{children:[_,(0,Z.jsxs)(O,{className:v,"aria-describedby":void 0,children:[S,j]})]}),t[32]=S,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)(A,{open:d,onOpenChange:f,children:[g,M]}),t[35]=d,t[36]=M,t[37]=g,t[38]=N):N=t[38],N}function HA(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 UA(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(qA),...m.map(KA),...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:Ey(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)(Yt,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:IA(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(GA),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 GA(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)(Yt,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.label})]},e.key)}function KA(e){return e.label}function qA(e){return e.label}function JA(e){let t=(0,X.c)(44),{items:n,activeMessageIndex:r,labels:i,onSelectMessage:a}=e,o;t[0]!==n||t[1]!==i?(o=FA(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`,HA({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)(UA,{turn:g,labels:i}):null,t[35]=i,t[36]=g,t[37]=E):E=t[37];let D;t[38]!==T||t[39]!==E?(D=(0,Z.jsxs)(`div`,{className:`relative z-[90] flex h-full min-h-0 w-full flex-col justify-center overflow-visible`,children:[T,E]}),t[38]=T,t[39]=E,t[40]=D):D=t[40];let O;return t[41]!==i.title||t[42]!==D?(O=(0,Z.jsx)(`aside`,{ref:u,className:`hidden h-full min-h-0 max-h-full w-12 shrink-0 items-center overflow-visible py-4 xl:flex`,"aria-label":b,onMouseLeave:x,onBlur:S,children:D}),t[41]=i.title,t[42]=D,t[43]=O):O=t[43],O}function YA(e){return e.enabled?e.sourceContextPending?`pending:${e.conversationId??``}`:e.task?`task:${e.task.task.id}:${e.task.task.version}`:e.suppressProjectContext?`suppressed:${e.conversationId??``}`:e.project?`project:${e.project.id}:${e.project.name}`:e.conversationId?`session:${e.conversationId}:failed:${e.sourceContextFailed?`1`:`0`}`:`empty`:`disabled`}function XA(e){let t=YA(e);if(!e.enabled)return{key:t,context:{kind:`empty`},status:`ready`};if(e.sourceContextPending)return{key:t,context:{kind:`empty`},status:`loading`};if(e.task){let n=e.task.receipts[0];return{key:t,context:{kind:`task`,taskId:e.task.task.id,taskTitle:e.task.task.title,phase:e.task.task.phase,operationalState:e.task.operationalState,attentionSummary:e.task.attention[0]?.summary,nextAction:n?.nextAction,recentFailure:n?.failure?.recoveryAction},status:`ready`}}return e.suppressProjectContext?{key:t,context:{kind:`empty`},status:e.sourceContextFailed?`degraded`:`ready`}:e.project?{key:t,context:{kind:`project`,projectId:e.project.id,projectName:e.project.name},status:`ready`}:{key:t,context:{kind:`empty`},status:e.conversationId?`loading`:`ready`}}function ZA(e){let{enabled:t,conversationId:n,sourceContextPending:r,sourceContextFailed:i,suppressProjectContext:a,project:o,task:s}=e,c=YA(e),[l,u]=(0,Q.useState)(()=>XA(e));(0,Q.useEffect)(()=>{let e=!1,l=XA({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 Lr(n);r=e?e.creation.projectId?.trim()||null:(await hn(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):fn(r),pn(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:XA(e);return{context:d.context,status:d.status}}var QA=[Ht,Rt,Ts];function $A(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)(Ht,{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=QA[t]??Ht;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`,la.transition,la.pressCard,la.focusRingPanel,la.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 ej=t({ChatPage:()=>nj}),tj=(0,Q.lazy)(async()=>({default:(await l(()=>import(`./chat-terminal-dock-B0D220I-.js`),__vite__mapDeps([46,1,2,5,6,47,11,48,26,27,17,18,49,50,51,52,53,54,55,56,57,58,59,60,4,61,62,28,29,9,63,64,65,66]))).ChatTerminalDock}));function nj({beforeSend:e,draftSeed:t,sourceNoteInView:n=!1,embedded:r=!1,conversationId:i,taskId:a,personal:o=!1,personalWelcome:s,automationWorkspace:c=!1,automationTimelineEntries:l,readOnly:u=!1,onHistoryReady:h,automationExecution:g=!1,initialTurnId:y,onInitialTurnLocated:b}={}){let x=v(e=>e.language),w=S(x),E=_(e=>e.conversationId),j=m(),M=d(),{pathname:N}=M,[P,F]=f(),I=(0,Q.useRef)(null),L=(0,Q.useRef)(0),R=(0,Q.useRef)(null),[z,B]=(0,Q.useState)(null),[ee,V]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{V(t??null)},[t]);let[U,W]=(0,Q.useState)(()=>!!(i&&window.localStorage.getItem(`personal-calibration:${i}`))),[te,ne]=(0,Q.useState)(null),[re,ie]=(0,Q.useState)(null),[ae,oe]=(0,Q.useState)(!1),[se,ce]=(0,Q.useState)(null),le=a?.trim()||null,{data:ue}=qs(le??``),{auth:de,session:G,messages:K,timeline:fe,stream:q,followUp:pe,clarify:me,agents:J}=DA({fixedConversationId:i,taskId:le??void 0,personal:o}),he=pe.composerMode.kind===`editTurn`?pe.composerMode:null,ge=Sn(e=>!!(G.conversationId&&!e.shellError&&e.sessions[G.conversationId]?.historyStatus===`ready`));(0,Q.useEffect)(()=>{ge&&K.items.length>0&&h?.()},[ge,K.items.length,h]),(0,Q.useLayoutEffect)(()=>{if(!c&&!g||!G.conversationId)return;let e=G.conversationId;return vp.setState({conversationIdOverride:e}),()=>{vp.getState().conversationIdOverride===e&&vp.setState({conversationIdOverride:null})}},[c,g,G.conversationId]);let _e=!o&&!r&&!le&&P.get(`scene`)===`find-skills`,ve=c||P.get(`setup`)===`automation`,ye=!r&&!le&&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(c?`chatDraft`:`draft`)??``,Ce=P.get(`autoSend`)===`1`,we=P.get(`attachmentHandoff`),Te=P.get(`attachmentsHandoff`),Ee=G.decodedKey??G.conversationId,[De,ke]=(0,Q.useState)(null),Ae=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(we){let e=Ne(we);e&&ke(e),Ae.current=Ee;return}Ae.current!==Ee&&(Ae.current=Ee,ke(null))},[we,Ee]);let je=tp(e=>e.markViewed),Me=tp(e=>Ee?e.runs[Ee]?.unread:!1);(0,Q.useEffect)(()=>{Ee&&Me&&je(Ee)},[Ee,Me,je]);let{data:Pe}=OA(Ee),Fe=ve||!!Pe?.identity?.customData?.automationSetup,Ie=!!Pe?.identity?.customData?.automationSetup?.automationId,Le=(0,Q.useCallback)(async e=>{if(Ee)try{let t=await G.sessionManager.forkSessionAtTurn(Ee,e);window.dispatchEvent(new CustomEvent(`session-created`,{detail:{key:t.conversationId,conversationId:t.conversationId}})),ba(`success`,w.chat.messageForkCreated),j(`/chat/${encodeURIComponent(t.conversationId)}`)}catch(e){throw ba(`error`,e instanceof Error?e.message:w.chat.messageForkFailed),e}},[Ee,w.chat.messageForkCreated,w.chat.messageForkFailed,j,G.sessionManager]),Re=K.items.at(-1),ze=o&&!U&&!q.streaming&&!q.sending&&Re?.role===`assistant`&&K.items.filter(e=>e.role===`user`).length===1&&K.items.filter(e=>e.role===`assistant`).length===1&&!K.items.some(e=>e.role===`task`),Be=e=>{W(!0),i&&window.localStorage.setItem(`personal-calibration:${i}`,`1`),e&&(L.current+=1,B({id:L.current,text:e}))};(0,Q.useEffect)(()=>{I.current=null},[G.conversationId]),(0,Q.useEffect)(()=>{if(!de.hasToken||!be&&!xe&&!Se&&!(G.projectPreparation&&Te)||Ce&&!G.projectPreparation||G.showSessionLoading||G.sessionRoutePending||!G.conversationId&&!G.projectPreparation)return;let e=G.projectPreparation&&Te?Mi(Te)??void 0:void 0,t=()=>{let e=new URLSearchParams(P);e.delete(`skill`),e.delete(`slash`),e.delete(c?`chatDraft`:`draft`),G.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?lm(n,e):(L.current+=1,B({id:L.current,text:n})),t()}))},r=za(be,Se);if(r||e?.length){let e=`${G.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=`${G.conversationId}:slash:${xe}`;I.current!==i&&queueMicrotask(()=>{(async()=>{try{let e=await Ao(),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,B({id:L.current,text:Hw(n)})}}finally{t()}})()})},[de.hasToken,c,be,xe,Se,Ce,Te,G.projectPreparation,P,G.showSessionLoading,G.sessionRoutePending,G.conversationId,j,N]);let{scrollRef:He,composerDockRef:Ke,atBottom:qe,registerListContentRef:Je,scrollToBottom:Ye,replySpaceRef:Xe,reserveReplySpace:Ze,onScroll:Qe}=Dw({hasToken:de.hasToken,showSessionLoading:G.showSessionLoading,conversationId:G.conversationId,chatMessages:K.items,streaming:q.streaming,hasMore:G.hasMore,loadingMore:G.loadingMore,loadMoreMessages:G.loadMoreMessages});(0,Q.useEffect)(()=>{if(!c||!qe||!l?.length)return;let e=requestAnimationFrame(()=>Ye(!1));return()=>cancelAnimationFrame(e)},[c,l,qe,Ye]);let $e=QO({enabled:o,conversationId:G.conversationId,messages:K.items,viewportRef:He}),[et,tt]=(0,Q.useState)(0),nt=(0,Q.useRef)(null),rt=(0,Q.useRef)(null),it=(0,Q.useMemo)(()=>{let e=-1;for(let t of fe.items)typeof t.displayIndex==`number`&&Number.isFinite(t.displayIndex)&&(e=Math.max(e,t.displayIndex));return e<0?0:Math.max(0,e+1-K.items.length)},[K.items.length,fe.items]),at=(0,Q.useCallback)(e=>{let t=He.current;if(!t)return!1;let n=t.querySelector(`[data-chat-message-index="${e}"]`);if(!n){let n=aw(t)?.reveal(e)??!1;return n&&tt(e),n}ow(t),tt(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:nw()}),!0},[He]),ot=(0,Q.useCallback)(()=>{let e=He.current;if(!e)return;let t=tw(e);tt(e=>e===t?e:t)},[He]),st=(0,Q.useCallback)(()=>{nt.current??=requestAnimationFrame(()=>{nt.current=null,ot()})},[ot]),ct=(0,Q.useCallback)(()=>{Qe(),st()},[Qe,st]),lt=(0,Q.useCallback)(e=>{let t=e-it;if(t<0||t>=K.items.length){t<0&&G.hasMore&&!G.loadingMore&&(rt.current=e,G.loadMoreMessages());return}rt.current=null,at(t)},[K.items.length,at,G.hasMore,G.loadMoreMessages,G.loadingMore,it]);tT({conversationId:G.conversationId,turnId:y,messages:K.items,ready:ge,hasMore:G.hasMore,loadingMore:G.loadingMore,loadMore:G.loadMoreMessages,reveal:at,onLocated:b});let ut=gk({conversationId:G.conversationId,taskId:le,messages:K.items,displayOffset:it,viewportRef:He,onRevealDisplayIndex:lt});(0,Q.useEffect)(()=>{let e=rt.current;if(e==null)return;let t=e-it;if(t>=0&&t<K.items.length){rt.current=null,requestAnimationFrame(()=>at(t));return}if(t<0&&G.hasMore&&!G.loadingMore){G.loadMoreMessages();return}(t>=K.items.length||!G.hasMore)&&(rt.current=null)},[K.items.length,at,G.hasMore,G.loadMoreMessages,G.loadingMore,it]),(0,Q.useEffect)(()=>{st()},[K.items.length,st,G.conversationId,it]),(0,Q.useEffect)(()=>()=>{nt.current!=null&&cancelAnimationFrame(nt.current)},[]),(0,Q.useEffect)(()=>{B(null)},[G.conversationId]);let dt=(0,Q.useCallback)(e=>{L.current+=1,B({id:L.current,text:e.prompt})},[]),ft=!!(G.conversationId&&!G.showSessionLoading&&!G.sessionRoutePending&&G.workspaceSource!==`project`&&G.workspaceSource!==`execution_environment`&&K.items.length===0),pt=ho(e=>e.setAgentId);(0,Q.useEffect)(()=>{if(de.hasToken)return pt(J.displayAgentId),()=>pt(``)},[de.hasToken,J.displayAgentId,pt]);let mt=G.conversationPhase===`creating-session`,ht=G.conversationPhase===`loading-history`;Uf(o&&!ht?Ee:null,o);let gt=mt||ht,_t=ht,vt=!_t&&K.items.length===0&&!l?.length&&!q.streaming,yt=(0,Q.useMemo)(()=>{if(q.taskPlan){let e=IO(q.taskPlan);return e?{plan:e,changeSummary:YO(K.items,q.streaming)?.changeSummary??null}:null}return YO(K.items,q.streaming)},[K.items,q.streaming,q.taskPlan]),bt=(0,Q.useMemo)(()=>(G.sessionRoutePending&&G.decodedKey?G.decodedKey:G.conversationId)?G.sessionName?.trim()||w.chat.newSession:w.nav.chat,[G.conversationId,G.sessionName,G.sessionRoutePending,G.decodedKey,w.nav.chat,w.chat.newSession]),xt=Pe?.sourceNoteId??null,St=jD(Ee,P.get(`projectId`)),wt=G.projectPreparation?.project??St,[Tt,Et]=(0,Q.useState)([]),[Dt,Ot]=(0,Q.useState)([]),kt=_(e=>e.baseUrl),At=Ee?ls(kt,E,Ee):null,jt=cs.store(e=>At?e.drafts[At]:void 0),Mt=(0,Q.useRef)(void 0),[Nt,Pt]=(0,Q.useState)(!1);(0,Q.useLayoutEffect)(()=>{Ee&&Ee!==Mt.current&&(Mt.current=void 0)},[Ee]),(0,Q.useEffect)(()=>{let e=!1;if(ne(null),xt)return Ve(xt).then(t=>{e||ne(t?.title?.trim()||null)}).catch(()=>{e||ne(null)}),()=>{e=!0}},[xt]);let Ft=te||Pe?.sourceNoteTitle||w.chat.sourceNoteFallbackTitle,It=ZA({enabled:de.hasToken&&!!(Ee||wt)&&!ye&&K.items.length===0&&!G.showSessionLoading&&!G.sessionRoutePending,conversationId:Ee,suppressProjectContext:!!(xt||De||G.workspaceSource===`execution_environment`||G.workspaceSource===`session_override`||G.workspaceSource===`agent_workspace`),project:wt,task:ue}),Lt=(0,Q.useMemo)(()=>J.chatAgents?.items.find(e=>e.id===J.displayAgentId)??{id:J.displayAgentId},[J.chatAgents?.items,J.displayAgentId]),Rt=(0,Q.useMemo)(()=>zs(It.context,w.chat.welcomeSpotlight,{contextStatus:It.status}),[w.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,E]);let Vt=(0,Q.useCallback)((...t)=>{let n=()=>{let[e,n,r,i,a]=t;if(jt&&(he||e.trim().startsWith(`/`)))return Sn.getState().setShellError(w.chat.pageContext.pending),!1;if(he)return q.replaceLatestUserTurn(he.turnId,e,n,r,i,a?.submittedAt);let o=!1,s=q.sendMessage(e,n,r,i,void 0,jt?.envelope,(e,t)=>{o=!0,Ze(t??e),a?.onDispatched?.({clientSubmissionId:e,messageRenderKey:t})},void 0,a?.submittedAt);return o?(At&&jt&&cs.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,q.replaceLatestUserTurn,q.sendMessage,jt,At,w.chat.pageContext.pending,Ze]),Ht=AD({preparation:G.projectPreparation,conversationId:Ee,ready:G.modelConfigReady&&!gt,onSend:Vt}),Ut=(0,Q.useCallback)(e=>{if(!e.turnId||!G.conversationId)return;let t=kn.getGeneration(G.conversationId),n=kn.getResumeRunId(G.conversationId);pe.beginEditTurn(e.turnId,{text:e.userTurnDocument?Tr(e.userTurnDocument):Wn(e.content),attachments:Kn(e.attachments)??[],contextRefs:e.contextRefs?.flatMap(e=>e.kind===`mcp_resource`?[]:[{refId:e.refId,kind:e.kind,sourceId:e.sourceId,expectedVersion:e.version,title:e.title,fileKind:e.fileKind}])??[]}).then(e=>{e&&q.settleStoppedRun(t,n)})},[pe.beginEditTurn,q.settleStoppedRun,G.conversationId]),Wt=(0,Q.useCallback)(e=>{if(pe.composerMode.kind===`editFollowUp`)pe.beginEditFollowUp(pe.composerMode.inputId);else if(pe.composerMode.kind===`editTurn`&&G.conversationId){let t=kn.getGeneration(G.conversationId),n=kn.getResumeRunId(G.conversationId);pe.beginEditTurn(pe.composerMode.turnId,e).then(e=>{e&&q.settleStoppedRun(t,n)})}},[pe.composerMode,pe.beginEditFollowUp,pe.beginEditTurn,G.conversationId,q.settleStoppedRun]),Gt=pe.cancelEditor;(0,Q.useEffect)(()=>{if(!Ce||!Se.trim()&&!Te||!de.hasToken||G.showSessionLoading||G.sessionRoutePending||!G.conversationId||q.sending||q.streaming)return;let e=za(be,Se),t=Te?Mi(Te):void 0;if(!e&&!t?.length)return;let n=`${G.conversationId}:auto-send:${e??``}:${Te??``}`;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)},[de.hasToken,Ce,Te,Se,Vt,j,N,P,G.conversationId,G.sessionRoutePending,G.showSessionLoading,be,q.sending,q.streaming]);let Kt=(0,Q.useCallback)(()=>{R.current?.reject(),R.current=null,ie(null),oe(!1)},[]);(0,Q.useEffect)(()=>{Kt()},[Kt,xt]);let qt=(0,Q.useMemo)(()=>({title:w.chat.timelineTitle,turn:w.chat.timelineTurn,messageFallback:w.chat.timelineMessageFallback,toolCount_one:w.chat.timelineToolCount_one,toolCount_other:w.chat.timelineToolCount_other,searchedWeb:w.chat.stepSearchedWeb,searchedMemory:w.chat.stepSearchedMemory,searchedCode:w.chat.stepSearchedCode,searched:w.chat.stepSearched,readFile:w.chat.stepReadFile,runCommand:w.chat.stepRunCommand,listDirectory:w.chat.stepListDirectory,writeFile:w.chat.stepWriteFile,editFile:w.chat.stepEditFile,openUrl:w.chat.stepOpenUrl,fetchUrl:w.chat.stepFetchUrl,unknownTool:w.chat.stepUnknownTool}),[w.chat.timelineTitle,w.chat.timelineTurn,w.chat.timelineMessageFallback,w.chat.timelineToolCount_one,w.chat.timelineToolCount_other,w.chat.stepSearchedWeb,w.chat.stepSearchedMemory,w.chat.stepSearchedCode,w.chat.stepSearched,w.chat.stepReadFile,w.chat.stepRunCommand,w.chat.stepListDirectory,w.chat.stepWriteFile,w.chat.stepEditFile,w.chat.stepOpenUrl,w.chat.stepFetchUrl,w.chat.stepUnknownTool]),Jt=(0,Q.useCallback)(async e=>{if(!xt)return;R.current?.reject(),oe(!1);let t=w.chat.sourceNoteAppendSourceLine.replace(`{{time}}`,new Date().toLocaleString(x));return ie({heading:w.chat.sourceNoteAppendHeading,content:`${t}\n\n${e.trim()}`}),new Promise((e,t)=>{R.current={sourceNoteId:xt,resolve:e,reject:t}})},[x,w.chat.sourceNoteAppendHeading,w.chat.sourceNoteAppendSourceLine,xt]),Yt=`${M.pathname}${M.search}`,Xt=(0,Q.useCallback)(async e=>{try{let t=await Ge(e.trim(),`web`);ba(`success`,w.chat.messageSavedToNote,void 0,{href:Ct(Yt,t.id)})}catch(e){throw ba(`error`,e instanceof Error?e.message:w.notes.quickCaptureFailed),e}},[Yt,w.chat.messageSavedToNote,w.notes.quickCaptureFailed]),Zt=(0,Q.useCallback)(async()=>{let e=R.current;if(!e||!re)return;let t=re.heading.trim()||w.chat.sourceNoteAppendHeading,n=re.content.trim();if(n){oe(!0),ce(null);try{await We(e.sourceNoteId,n,t),window.dispatchEvent(new CustomEvent(`note-updated`,{detail:{noteId:e.sourceNoteId,source:`chat`,conversationId:Ee}})),e.resolve(),R.current=null,ie(null)}catch(e){ce(e instanceof Error?e.message:w.chat.sourceNoteSaveFailed)}finally{oe(!1)}}},[Ee,w.chat.sourceNoteAppendHeading,w.chat.sourceNoteSaveFailed,w.chat.sourceNoteSaveSuccess,re]),$t=(0,Q.useCallback)(async e=>{if(!xt)return;let t=e.trim().split(/\n+/)[0]?.replace(/^[-#*>\s]+/,``).trim()||w.chat.sourceNoteTaskFallbackTitle;try{await Ue(t.slice(0,120),{sourceNoteId:xt,sourceConversationId:Ee})}catch(e){throw ba(`error`,e instanceof Error?e.message:w.chat.sourceNoteTaskFailed),e}},[Ee,w.chat.sourceNoteTaskFailed,w.chat.sourceNoteTaskFallbackTitle,w.chat.sourceNoteTaskSuccess,xt]),en=(0,Q.useCallback)(async()=>{if(!xt)return;let t=Bt.current;if(e&&(!await e()||t!==Bt.current))return;let n=w.chat.sourceNoteDigestPrompt.replace(`{{title}}`,Ft);if(q.streaming||q.sending){pe.addPendingFollowUp(n),ya({tone:`info`,status:`done`,title:w.chat.sourceNoteDigestQueued,source:x===`zh`?`笔记整理`:`Note digest`,dedupeKey:xt?`note-digest:${xt}`:void 0});return}q.sendMessage(n)},[e,pe,x,w.chat.sourceNoteDigestPrompt,w.chat.sourceNoteDigestQueued,xt,Ft,q]),tn=(0,Q.useCallback)(async e=>{if(!(Nt||Ht.busy)){if(G.projectPreparation){j(La(e),{state:{forceNewChat:!0,agentId:J.displayAgentId,temporary:G.userContextMode===`temporary`}});return}if(!(Mt.current!==void 0||q.sending||q.streaming||gt)){Mt.current=Ee,Pt(!0);try{e?j(La(e),{state:{forceNewChat:!0,agentId:J.displayAgentId,temporary:G.userContextMode===`temporary`}}):await G.createNewSession({forceNew:!0,projectId:e,temporary:G.userContextMode===`temporary`})}catch(e){Mt.current=void 0,ba(`error`,w.chat.composerContext.changeFailed,{error:e instanceof Error?e.message:String(e)})}finally{Pt(!1)}}}},[Ee,gt,w.chat.composerContext.changeFailed,Nt,Ht.busy,G.createNewSession,G.projectPreparation,G.userContextMode,q.sending,q.streaming,j,J.displayAgentId]),nn=(0,Q.useCallback)(()=>tn(null),[tn]),rn=(0,Q.useCallback)(async e=>{if(!(Nt||gt||q.sending||q.streaming||!ft)){Pt(!0);try{await G.onSessionWorkingDirectoryChange(e)}finally{Pt(!1)}}},[Nt,gt,q.sending,q.streaming,ft,G.onSessionWorkingDirectoryChange]),an=(0,Q.useMemo)(()=>({project:wt,draftRefs:Tt,draftAttachments:Dt,draftPage:jt?{id:`${jt.envelope.tabId}:${jt.envelope.sequence}`,title:jt.title||(x===`zh`?`当前页面`:`Current page`)}:void 0,onLeaveProject:Nt||Ht.busy?void 0:nn,leaveProjectLabel:w.chat.scopeRemoveProject,onDraftSourceNote:xt?en:void 0,draftSourceNoteLabel:w.chat.sourceNoteDigestAction}),[Nt,Ht.busy,wt,Tt,Dt,jt,x,nn,w.chat.scopeRemoveProject,xt,en,w.chat.sourceNoteDigestAction]);return de.hasToken?(q.error?Or(q.error):null)?.code===`session_not_found`?(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col overflow-hidden bg-surface-panel`,children:[(0,Z.jsx)(wO,{}),(0,Z.jsx)(hO,{chatHeadline:w.chat.sessionNotFoundTitle,chatAgents:J.chatAgents?.items??[],showChatAgentSelector:!1,chatAgentId:J.displayAgentId,onChatAgentChange:J.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)(Th,{errorText:q.error})})})]}):(0,Z.jsx)(tv,{value:Fe,children:(0,Z.jsxs)(`div`,{className:Y(`flex h-full min-h-0 flex-1 flex-col bg-surface-panel`,c?`overflow-clip`:`overflow-hidden`),children:[(0,Z.jsx)(wO,{}),!r||c?(0,Z.jsx)(hO,{inline:c,chatHeadline:_e&&K.items.length===0?w.skills.findTitle:bt,chatAgents:J.chatAgents?.items??[],showChatAgentSelector:!c&&!ye&&J.showChatAgentSelector,chatAgentId:J.displayAgentId,onChatAgentChange:J.onChatAgentChange,chatAgentDisabled:Ht.busy||Nt||gt&&!G.projectPreparation,conversationId:G.conversationId,hasMessages:!gt&&K.items.length>0,workspacePath:G.effectiveWorkspacePath,userContextMode:G.userContextMode,projectId:wt?.id,context:an,canChangeWorkspace:!1,workspaceDisabled:gt||q.sending||q.streaming,onWorkspaceChange:G.onSessionWorkingDirectoryChange,prepareTerminalSession:G.projectPreparation?Ht.prepareSession:void 0,terminalDisabled:!!(G.projectPreparation&&(Ht.busy||!Ht.allowed||Ht.checking)),showContextControls:!ye,onFindOpen:ut.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)(p,{to:`/chat/${encodeURIComponent(Pe.parentConversationId)}`,className:`font-medium text-accent transition-colors hover:text-accent-fg`,children:w.chat.forkedFromConversation.replace(`{{name}}`,Pe.forkedFromSessionName||w.chat.forkedFromConversationFallback)}),(0,Z.jsx)(`span`,{className:`ms-2`,children:w.chat.forkSharedWorkspaceNotice})]}):null,M.state?.fromAgentEditor&&J.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)(p,{to:ns(J.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:`←`}),w.agentsSettings.backToEditor]})}):null,r&&xt&&!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:w.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)(Oe,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:w.chat.sourceNoteDigestAction})]}),(0,Z.jsx)(p,{to:Ct(`${M.pathname}${M.search}`,xt),className:`font-medium text-accent transition-colors hover:text-accent-fg`,children:w.chat.sourceNoteOpen})]})]})}):null,(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)($O,{open:ut.open,query:ut.query,activeIndex:ut.activeIndex,resultCount:ut.resultCount,searching:ut.searching,truncated:ut.truncated,limitedToLoaded:ut.limitedToLoaded,inputRef:ut.inputRef,labels:w.chat.find,onQueryChange:ut.setQuery,onPrevious:ut.previous,onNext:ut.next,onClose:ut.close}),!r||c?(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)(JA,{items:fe.items,activeMessageIndex:et+it,labels:qt,onSelectMessage:lt})})}):null,(0,Z.jsx)(`div`,{ref:He,"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]`,vt?`chat-messages--compact-welcome pt-5 pb-2`:`py-4`),onScroll:ct,"data-chat-find-open":ut.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||c)&&`max-w-[var(--max-width-chat-frame)]`),children:ht?(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:[G.loadingMore?(0,Z.jsx)(`div`,{className:`mb-3 text-center text-xs text-fg-muted`,children:w.chat.loadOlder}):null,Fe&&!c&&Ee?(0,Z.jsx)(Go,{conversationId:Ee,language:x,running:q.streaming||q.sending}):null,Fe&&!c&&K.items.length>0?(0,Z.jsx)(p,{className:`mb-4 inline-block rounded-md px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover`,to:`/automations`,children:x===`zh`?`← 定时任务`:`← Scheduled tasks`}):null,!r&&le?(0,Z.jsx)(`div`,{className:`hidden md:block`,children:(0,Z.jsx)(_c,{taskId:le})}):null,null,null,!r&&Ee?(0,Z.jsx)(H,{eventType:`session.transcript.updated`,source:`sessions`,payloadKey:`conversationId`,payloadValue:Ee,className:`mb-6`}):null,(0,Z.jsx)(mw,{scrollRef:He,messages:K.items,timelineEntries:l,personal:o,authToken:E??void 0,conversationId:G.decodedKey??G.conversationId,projectId:wt?.id,streaming:q.streaming,sending:q.sending,progress:q.progress,runError:q.error,reasoningLevel:G.reasoningLevel,showAssistantWorkLog:!0,registerListContentRef:Je,replySpaceRef:Xe,onPickWelcomePrompt:dt,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:x===`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??(x===`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?x===`zh`?`想怎么调整这个任务?`:`What would you like to change?`:x===`zh`?`你想安排什么任务?`:`What would you like to schedule?`}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:Ie?x===`zh`?`直接说要改的内容、时间,或告诉我暂停、恢复。`:`Change what it does or when it runs, or ask to pause or resume.`:x===`zh`?`说说要做的事,时间和细节我们一起确定。`:`Tell us what to do. We’ll work out the timing and details together.`}),c?null:(0,Z.jsx)(p,{className:`mt-4 inline-block text-xs text-fg-muted hover:text-fg`,to:`/automations`,children:x===`zh`?`← 返回定时任务`:`← Back to scheduled tasks`})]}):ye?(0,Z.jsx)($A,{agentName:Lt.name?.trim()||J.displayAgentId,messages:w.agentsSettings,disabled:G.sessionRoutePending||G.showSessionLoading,onPick:e=>{L.current+=1,B({id:L.current,text:e})}}):_e?(0,Z.jsx)(aT,{sk:w.skills,disabled:G.sessionRoutePending||G.showSessionLoading,onPick:e=>{L.current+=1,B({id:L.current,text:za(`find-skills`,e)})}}):void 0,compactWelcome:r,onDeleteRound:le?void 0:q.deleteMessageRound,onRetryUserMessageRound:le?void 0:q.retryUserMessageRound,deleteRoundDisabled:q.streaming||q.sending,onEditUserMessage:le?void 0:Ut,editLatestUserOnly:!0,editRequiresTurnId:!0,onSaveAssistantAsNote:Xt,onSaveAssistantToSourceNote:xt?Jt:void 0,onExtractAssistantTask:xt?$t:void 0,onForkAssistantTurn:!le&&Pe?.sessionType===`chat`?Le:void 0,trailingContent:ze?(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:x===`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:[[[x===`zh`?`再短一点`:`Make it shorter`,x===`zh`?`这次回答再短一点。`:`Please make this answer shorter.`],[x===`zh`?`更温和一点`:`A little gentler`,x===`zh`?`这次回答的语气更温和一点。`:`Please make this answer a little gentler.`]].map(([e,t])=>(0,Z.jsx)(`button`,{type:`button`,onClick:()=>Be(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:()=>Be(),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:x===`zh`?`这样就好`:`Looks good`})]})]}):null},Ee)]})})})}),(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]`,vt?`[--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||c)&&`max-w-[calc(var(--max-width-chat-frame)+14px)]`,vt?`pt-2.5`:`pt-2 sm:pt-4`),children:[(0,Z.jsx)(xw,{visible:!G.showSessionLoading&&!qe,onClick:()=>Ye(!0),running:q.streaming||q.sending}),(0,Z.jsx)(`div`,{className:`absolute bottom-full right-0 z-20 mb-2 flex items-center rounded-full border border-edge-subtle bg-surface-overlay p-1 shadow-elevated backdrop-blur-sm empty:hidden xl:hidden`,children:!r||c?(0,Z.jsx)(VA,{items:fe.items,activeMessageIndex:et+it,labels:qt,openLabel:w.chat.timelineOpen,closeLabel:w.chat.timelineClose,currentLabel:w.chat.timelineCurrent,onSelectMessage:lt}):null}),(0,Z.jsx)(Ef,{prompt:me.clarifyPrompt,submitting:me.clarifySubmitting,submitError:me.clarifySubmitError,labels:w.chat,onSubmit:me.submitClarifyAnswer,onAgentDecide:me.letAgentDecideClarification,onCancel:me.cancelClarification}),yt?(0,Z.jsx)(MO,{plan:yt.plan,changeSummary:yt.changeSummary,isStreaming:q.streaming,labels:{heading:w.chat.planHeading,stepProgress:w.chat.planStepProgress,completedProgress:w.chat.planCompletedProgress,finished:w.chat.planFinished,ended:w.chat.planEnded,planned:w.chat.planPlanned,filesChangedOne:w.chat.planFilesChanged_one,filesChangedOther:w.chat.planFilesChanged_other}}):null,_e&&K.items.length>0?(0,Z.jsx)(`div`,{className:`mb-2 text-right`,children:(0,Z.jsx)(p,{to:`/capabilities/skills`,className:`text-xs text-accent-fg hover:underline`,children:w.skills.findBack})}):null,(0,Z.jsx)($w,{}),(0,Z.jsx)(rT,{conversationId:G.conversationId,active:q.streaming||q.sending}),(0,Z.jsx)(wD,{personal:o,nextTurnSuggestionsEnabled:!q.streaming,onPersonalSendDispatched:o?$e:void 0,placeholder:o?q.streaming||q.sending?x===`zh`?`继续聊,或补充要求…`:`Keep talking or add a detail…`:x===`zh`?`发消息给「${s?.name||`Personal AI`}」…`:`Message ${s?.name||`Personal AI`}…`:ye?w.agentsSettings.setupComposerPlaceholder:_e?w.skills.findPlaceholder:void 0,composerContext:!ye&&!r&&!le&&!he&&!_t&&K.items.length===0?{project:wt,disabled:Nt||Ht.busy||gt&&!G.projectPreparation,environmentPicker:G.projectPreparation?(0,Z.jsx)(OD,{selection:Ht}):void 0,workspacePath:G.effectiveWorkspacePath,canChangeWorkspace:ft,onProjectChange:tn,onWorkspaceChange:rn}:void 0,contextRefs:Tt,pageContextPreview:jt&&At?(0,Z.jsx)(TD,{draft:jt,disabled:q.sending,waiting:q.streaming,onRemove:()=>cs.remove(At,jt)}):void 0,setContextRefs:Et,onDraftAttachmentsChange:Ot,disabled:u||ht||Ht.busy||Nt,sendDisabled:pe.controlPending||pe.control.phase===`stopping`||u||!G.modelConfigReady||!G.projectPreparation&>||!!(G.projectPreparation&&!Ht.allowed)||G.modelConfigSaving||Ht.busy||Nt,sending:q.sending,streaming:q.streaming,conversationId:G.conversationId,unboundDraftKey:G.conversationId?void 0:JSON.stringify([N,P.get(`projectId`)]),getDraftHandoffTarget:Ht.getDraftHandoffTarget,prepareContextSession:G.projectPreparation?Ht.prepareSession:void 0,welcomeDraftSeed:ee??z,welcomeSuggestion:!_e&&vt?zt:null,onAcceptWelcomeSuggestion:dt,thinkingLevel:G.thinkingLevel,modelSupportsThinking:G.modelSupportsThinking,onThinkingChange:G.onSessionThinkingLevelChange,onSend:Ht.send,composerMode:pe.composerMode,onRestoreEditor:pe.restoreEditor,onComposerHydrated:pe.markComposerHydrated,onReacquireEdit:Wt,inputControl:pe.control,onResumeQueue:()=>void pe.resumeQueue().catch(()=>{}),editingUserTurnId:he?.turnId,onCancelUserMessageEdit:Gt,onAbort:()=>void q.abort().catch(()=>{}),onAddPendingFollowUp:async(t,n,r,i,a)=>{let o=Bt.current;if(e&&(!await e()||o!==Bt.current))throw Error(x===`zh`?`请先保存笔记,再发送消息。`:`Save the note before sending.`);await pe.addPendingFollowUp(t,n,r,jt?.envelope,i,a),At&&jt&&cs.remove(At,jt)},onSteeringInterrupt:jt?void 0:async(t,n,r)=>{let i=Bt.current;return e&&(!await e()||i!==Bt.current)?!1:q.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:G.sessionModel,showModelSelector:!o,onModelChange:G.onSessionModelChange,modelDisabled:gt&&!G.projectPreparation||Ht.busy||G.modelConfigSaving,onChatAgentChange:!o&&!ye&&!le&&J.showChatAgentSelector?J.onChatAgentChange:void 0,currentAgentId:J.displayAgentId,voiceAgentName:o&&s?s.name:Lt.name,voiceTaskId:le??void 0,prepareVoiceSession:G.projectPreparation?Ht.prepareSession:void 0})]})})})]})]}),(!r||c)&&Ee&&window.electronAPI?.terminal?(0,Z.jsx)(Q.Suspense,{fallback:null,children:(0,Z.jsx)(tj,{conversationId:Ee},Ee)}):null,(0,Z.jsx)(A,{open:re!==null,onOpenChange:e=>{!e&&!ae&&Kt()},children:(0,Z.jsxs)(D,{children:[(0,Z.jsx)(C,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[1px]`}),(0,Z.jsxs)(O,{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)(k,{className:`text-base font-semibold text-fg`,children:w.chat.sourceNoteSaveDialogTitle}),(0,Z.jsx)(T,{className:`mt-1 text-sm text-fg-muted`,children:w.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:[se?(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:[w.chat.sourceNoteSaveFailed,`: `,se]}):null,(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium text-fg`,children:[(0,Z.jsx)(`span`,{children:w.chat.sourceNoteSaveDialogHeadingLabel}),(0,Z.jsx)(`input`,{value:re?.heading??``,onChange:e=>ie(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:ae})]}),(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:w.chat.sourceNoteSaveDialogContentLabel}),(0,Z.jsx)(`textarea`,{value:re?.content??``,onChange:e=>ie(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:ae})]})]}),(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)(vi,{type:`button`,variant:`secondary`,onClick:Kt,disabled:ae,children:w.chat.sourceNoteSaveDialogCancel}),(0,Z.jsx)(vi,{type:`button`,variant:`primary`,onClick:()=>void Zt(),disabled:ae||!re?.content.trim(),children:ae?w.chat.sourceNoteSaveDialogSaving:w.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:w.chat.needToken})}export{fc as $,tp as A,Mf as B,vp as C,hs as Ct,ip as D,rp as E,Uf as F,gc as G,Ef as H,Vf as I,uc as J,mc as K,Lf as L,Jf as M,Yf as N,np as O,Hf as P,dc as Q,Bf as R,hp as S,gs as St,ap as T,ps as Tt,bf as U,Of as V,_c as W,$s as X,Qs as Y,ec as Z,Cm as _,xs as _t,Kw as a,Ns as at,hm as b,vs as bt,kw as c,As as ct,jw as d,Ds as dt,pc as et,Dw as f,Es as ft,Sm as g,Ss as gt,xm as h,Cs as ht,eT as i,qs as it,$f as j,op as k,Nw as l,ks as lt,mw as m,ws as mt,ej as n,Zs as nt,Hw as o,Ms as ot,xw as p,Ts as pt,hc as q,Qw as r,Gs as rt,Vw as s,js as st,nj as t,oc as tt,Mw as u,Os as ut,ym as v,bs as vt,cp as w,ms as wt,lm as x,_s as xt,gm as y,ys as yt,jf as z};
|