@codexhost/cli-win32-x64 0.32.1 → 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/README.md +2 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +559 -15
  4. package/app/console-web.js +1361 -192
  5. package/app/desktop-controller.mjs +620 -16
  6. package/app/desktop-mcp-client.mjs +619 -0
  7. package/app/host-runtime.mjs +10370 -5625
  8. package/app/plugins/antigravity/plugin.mjs +888 -73
  9. package/app/plugins/claude-code/assets/icon.svg +1 -1
  10. package/app/plugins/claude-code/manifest.json +1 -1
  11. package/app/plugins/claude-code/plugin.mjs +1280 -198
  12. package/app/plugins/codebuddy/plugin.mjs +643 -35
  13. package/app/plugins/codex-usage/plugin.mjs +544 -12
  14. package/app/plugins/copilot/assets/icon.svg +1 -1
  15. package/app/plugins/copilot/manifest.json +1 -1
  16. package/app/plugins/copilot/plugin.mjs +546 -14
  17. package/app/plugins/cursor-cli/plugin.mjs +544 -12
  18. package/app/plugins/deepseek-harness/assets/icon.svg +1 -1
  19. package/app/plugins/deepseek-harness/manifest.json +1 -1
  20. package/app/plugins/deepseek-harness/plugin.mjs +983 -153
  21. package/app/plugins/devin/assets/icon.svg +1 -1
  22. package/app/plugins/devin/manifest.json +1 -1
  23. package/app/plugins/devin/plugin.mjs +546 -13
  24. package/app/plugins/enabled.json +1 -0
  25. package/app/plugins/grok/plugin.mjs +544 -12
  26. package/app/plugins/hermes/plugin.mjs +544 -12
  27. package/app/plugins/kimi-code/plugin.mjs +544 -12
  28. package/app/plugins/kiro-cli/plugin.mjs +544 -12
  29. package/app/plugins/omp/assets/icon.svg +1 -1
  30. package/app/plugins/omp/plugin.mjs +1381 -243
  31. package/app/plugins/opencode/plugin.mjs +548 -13
  32. package/app/plugins/pi/assets/icon.svg +1 -1
  33. package/app/plugins/pi/manifest.json +1 -1
  34. package/app/plugins/pi/plugin.mjs +572 -14
  35. package/app/plugins/qoder/assets/icon.svg +1 -1
  36. package/app/plugins/qoder/plugin.mjs +570 -12
  37. package/app/plugins/qoder-cn/assets/icon.svg +1 -1
  38. package/app/plugins/qoder-cn/plugin.mjs +570 -12
  39. package/app/plugins/qwen-code/assets/icon.svg +1 -1
  40. package/app/plugins/qwen-code/plugin.mjs +573 -12
  41. package/app/plugins/workbuddy/plugin.mjs +1263 -472
  42. package/app/plugins/workbuddy-cn/assets/icon.svg +27 -0
  43. package/app/plugins/workbuddy-cn/manifest.json +32 -0
  44. package/app/plugins/workbuddy-cn/plugin.mjs +36211 -0
  45. package/app/plugins/zcode/plugin.mjs +564 -19
  46. package/app/renderer-extension.js +2932 -262
  47. package/app/web/assets/{abnfDiagram-XWFEHMT6-7XITZmBH.js → abnfDiagram-XWFEHMT6-Cg-E7mc4.js} +1 -1
  48. package/app/web/assets/{architectureDiagram-CSQXQB3N-C8Usdzd8.js → architectureDiagram-CSQXQB3N-B__CwXjW.js} +1 -1
  49. package/app/web/assets/{blockDiagram-BEDRHYPZ-CyN9yE_Q.js → blockDiagram-BEDRHYPZ-Bk2gCIVM.js} +1 -1
  50. package/app/web/assets/{c4Diagram-M2UUVUY5-CjhY1l3g.js → c4Diagram-M2UUVUY5-DU_TpjJ3.js} +1 -1
  51. package/app/web/assets/{chunk-2Q5K7J3B-o24_rh4_.js → chunk-2Q5K7J3B-DnJEi6e4.js} +1 -1
  52. package/app/web/assets/{chunk-3GCGMST5-D7bw3E1a.js → chunk-3GCGMST5-Dia9jGkf.js} +1 -1
  53. package/app/web/assets/{chunk-5VM5RSS4-D0v4acf7.js → chunk-5VM5RSS4-2PGDiDvK.js} +1 -1
  54. package/app/web/assets/{chunk-7U7NFRK5-CYJxP4rV.js → chunk-7U7NFRK5-BLPm3d5H.js} +1 -1
  55. package/app/web/assets/{chunk-CNRTWJTD-DTgCtcCl.js → chunk-CNRTWJTD-GH_nAEXs.js} +1 -1
  56. package/app/web/assets/{chunk-D5HYT7QG-qRNelehW.js → chunk-D5HYT7QG-DnIm-Ely.js} +1 -1
  57. package/app/web/assets/{chunk-EBZ3SEQC-BgJPPYdu.js → chunk-EBZ3SEQC-C6N5qLCR.js} +2 -2
  58. package/app/web/assets/{chunk-JWPE2WC7-C50ZnSQQ.js → chunk-JWPE2WC7-D_kMgdmr.js} +1 -1
  59. package/app/web/assets/{chunk-KTR4FSNJ-Cifh4XHc.js → chunk-KTR4FSNJ-BRb9femQ.js} +1 -1
  60. package/app/web/assets/{chunk-XXDRQBXY-D23WAHPW.js → chunk-XXDRQBXY-BFaK95zq.js} +1 -1
  61. package/app/web/assets/{classDiagram-v2-KXABOMEV-B3cezFGj.js → classDiagram-v2-KXABOMEV--_hR_XrU.js} +1 -1
  62. package/app/web/assets/{cose-bilkent-JH36ORCC-VSMi4La2.js → cose-bilkent-JH36ORCC-C7ghEB3_.js} +1 -1
  63. package/app/web/assets/{cynefin-EF2NZ3EQ-qQnfHq16.js → cynefin-EF2NZ3EQ-Ce1lURwZ.js} +1 -1
  64. package/app/web/assets/{cynefinDiagram-NJNITYFG-BJELApXD.js → cynefinDiagram-NJNITYFG-Cgr5aSTS.js} +1 -1
  65. package/app/web/assets/{dagre-KIHZ2IZ3-C8B5ZMVs.js → dagre-KIHZ2IZ3-BBFKmRP1.js} +1 -1
  66. package/app/web/assets/{diagram-7YQZDPLS-HIWoNpzV.js → diagram-7YQZDPLS-CJQih32K.js} +1 -1
  67. package/app/web/assets/{diagram-QBROCOUO-3_vS1jbp.js → diagram-QBROCOUO-Cl3S7IUT.js} +1 -1
  68. package/app/web/assets/{diagram-RJJCUUZO-C_Kndn_e.js → diagram-RJJCUUZO-B6C8N2cV.js} +1 -1
  69. package/app/web/assets/{diagram-WERXNKYE-BLWdOwya.js → diagram-WERXNKYE-NkciBSQl.js} +1 -1
  70. package/app/web/assets/{diagram-YHHI257C-DJeOs6eS.js → diagram-YHHI257C-DlEvljeY.js} +1 -1
  71. package/app/web/assets/{diagram-YR4HJLHV-BKNULu-g.js → diagram-YR4HJLHV-e4_Gzbt6.js} +1 -1
  72. package/app/web/assets/{ebnfDiagram-N527522P-Bu8aReoF.js → ebnfDiagram-N527522P-WvQEFmPi.js} +1 -1
  73. package/app/web/assets/{elk-O5DQBFGD-CIp7Z0ER.js → elk-O5DQBFGD-CkyJsjzf.js} +1 -1
  74. package/app/web/assets/{erDiagram-K3K3BIDK-BTsor1Lp.js → erDiagram-K3K3BIDK-B93gK3X0.js} +1 -1
  75. package/app/web/assets/{flowDiagram-Z6JWZHQI-p_h5PKQr.js → flowDiagram-Z6JWZHQI-NFaGX6B4.js} +1 -1
  76. package/app/web/assets/{ganttDiagram-3PRQTZWP-DKjfPPJ1.js → ganttDiagram-3PRQTZWP-Czh68CQm.js} +1 -1
  77. package/app/web/assets/{gitGraphDiagram-VXDFKS5L-RnPOf2fj.js → gitGraphDiagram-VXDFKS5L-t95UHKja.js} +1 -1
  78. package/app/web/assets/{grid-E2QIVN74-C96GnBO1.js → grid-E2QIVN74-C87DucDN.js} +1 -1
  79. package/app/web/assets/index-CGI50Nfg.css +1 -0
  80. package/app/web/assets/index-Dr6wHi0A.js +208 -0
  81. package/app/web/assets/{infoDiagram-EZ3ZOAHP-B68eZHsb.js → infoDiagram-EZ3ZOAHP-CxFlfQbY.js} +1 -1
  82. package/app/web/assets/{ishikawaDiagram-S3EKX5GW-BLj7PFLt.js → ishikawaDiagram-S3EKX5GW-D4IwQJde.js} +1 -1
  83. package/app/web/assets/{journeyDiagram-POQNLL5X-Bo-_In0d.js → journeyDiagram-POQNLL5X-C0Bf5W4T.js} +1 -1
  84. package/app/web/assets/{kanban-definition-BH5XI6FM-BpHvxprW.js → kanban-definition-BH5XI6FM-Cda7r2yr.js} +1 -1
  85. package/app/web/assets/langs/{graphql-D6Z3qcRW.js → graphql-2R4AZ1iu.js} +1 -1
  86. package/app/web/assets/langs/{http-XiU9G9In.js → http-q2Qm0vBh.js} +1 -1
  87. package/app/web/assets/langs/{php-DL3xwS-7.js → php-Cz2gDBnd.js} +1 -1
  88. package/app/web/assets/langs/{rst-DudRVJ9g.js → rst-_9muvx-X.js} +1 -1
  89. package/app/web/assets/langs/{ruby-_FqsfqJi.js → ruby-cn7REk4H.js} +1 -1
  90. package/app/web/assets/langs/{svelte-ClsVJoBT.js → svelte-CPnL2mcy.js} +1 -1
  91. package/app/web/assets/langs/{vue-BiKMXCyK.js → vue-DO0YwyVz.js} +1 -1
  92. package/app/web/assets/{mermaid.core-COb9i2Gl.js → mermaid.core-f4LJm6AC.js} +5 -5
  93. package/app/web/assets/{mindmap-definition-WVAN44T4-DG15AlXd.js → mindmap-definition-WVAN44T4-DKapinG7.js} +1 -1
  94. package/app/web/assets/{pegDiagram-D4NLKWP3-GMBk8RM6.js → pegDiagram-D4NLKWP3-D7iEZGN2.js} +1 -1
  95. package/app/web/assets/{pieDiagram-36ENHN4W-BzeJgVnn.js → pieDiagram-36ENHN4W-CopXZ5qt.js} +1 -1
  96. package/app/web/assets/{quadrantDiagram-ZQUDMS73-C--Kif6a.js → quadrantDiagram-ZQUDMS73-mmkKPDGK.js} +1 -1
  97. package/app/web/assets/{railroadDiagram-JIZHGYPL-NPLVu_R7.js → railroadDiagram-JIZHGYPL-BAGwIIkV.js} +1 -1
  98. package/app/web/assets/{render-VIF2ZAQL-DdpQ8E0J.js → render-VIF2ZAQL-dXxGa09y.js} +2 -2
  99. package/app/web/assets/{requirementDiagram-AXW2TVFA-WWRwRbkA.js → requirementDiagram-AXW2TVFA-C35tmLFs.js} +1 -1
  100. package/app/web/assets/{sankeyDiagram-FBCJTAIF-hBr6pZ0V.js → sankeyDiagram-FBCJTAIF-BbSo5yeK.js} +1 -1
  101. package/app/web/assets/{sequenceDiagram-3LA2ROMG-DvzZWy5J.js → sequenceDiagram-3LA2ROMG-Cgm2unNy.js} +1 -1
  102. package/app/web/assets/{sizeCapture-2Q2CQKSF-C2B86W70.js → sizeCapture-2Q2CQKSF-DCXFjl2x.js} +1 -1
  103. package/app/web/assets/{stateDiagram-v2-ATKHQDJO-Jwj3XqMx.js → stateDiagram-v2-ATKHQDJO-B349iAao.js} +1 -1
  104. package/app/web/assets/{swimlanes-YQL5WMAO-DxI0hC09.js → swimlanes-YQL5WMAO-6OvL1sEz.js} +1 -1
  105. package/app/web/assets/swimlanesDiagram-UCCPES4V-CIKaQUvP.js +8 -0
  106. package/app/web/assets/{timeline-definition-7Z437IG3-m8Ew8iuN.js → timeline-definition-7Z437IG3-Bh1E3mhW.js} +1 -1
  107. package/app/web/assets/{usecaseDiagram-RDK6N6HP-BsiPSzIT.js → usecaseDiagram-RDK6N6HP-Dr5A05lL.js} +1 -1
  108. package/app/web/assets/{vendor-BKfNgqAm.js → vendor-BMCjWFMy.js} +20 -20
  109. package/app/web/assets/{vennDiagram-SHRQU5PJ-yYfXhiGp.js → vennDiagram-SHRQU5PJ-CQPPBa27.js} +1 -1
  110. package/app/web/assets/{wardleyDiagram-F3OXNVQS-DHLEfnsg.js → wardleyDiagram-F3OXNVQS-BHin00q8.js} +1 -1
  111. package/app/web/assets/{xychartDiagram-GDYJKCDI-Drn_UxYt.js → xychartDiagram-GDYJKCDI-D4BAWlQZ.js} +1 -1
  112. package/app/web/codex-agent.png +0 -0
  113. package/app/web/codex.png +0 -0
  114. package/app/web/codexhost-settings.js +337 -137
  115. package/app/web/index.html +3 -3
  116. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +65 -65
  117. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +69 -69
  118. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +75 -75
  119. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +162 -74
  120. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +104 -100
  121. package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
  122. package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +114 -2
  123. package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +5 -5
  124. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +6 -6
  125. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +80 -80
  126. package/app/web/plugins/deepseek-ai__dsh-client-ui-user-questions/client.js +1 -1
  127. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +69 -69
  128. package/app/web/role-avatars/builtin/advisor-otter.webp +0 -0
  129. package/app/web/role-avatars/builtin/architect-otter.webp +0 -0
  130. package/app/web/role-avatars/builtin/audio-otter.webp +0 -0
  131. package/app/web/role-avatars/builtin/backend-otter.webp +0 -0
  132. package/app/web/role-avatars/builtin/builder-otter.webp +0 -0
  133. package/app/web/role-avatars/builtin/classic-otter.webp +0 -0
  134. package/app/web/role-avatars/builtin/data-otter.webp +0 -0
  135. package/app/web/role-avatars/builtin/debugger-otter.webp +0 -0
  136. package/app/web/role-avatars/builtin/frontend-otter.webp +0 -0
  137. package/app/web/role-avatars/builtin/idea-otter.webp +0 -0
  138. package/app/web/role-avatars/builtin/ops-otter.webp +0 -0
  139. package/app/web/role-avatars/builtin/pm-otter.webp +0 -0
  140. package/app/web/role-avatars/builtin/researcher-otter.webp +0 -0
  141. package/app/web/role-avatars/builtin/reviewer-otter.webp +0 -0
  142. package/app/web/role-avatars/builtin/sailor-otter.webp +0 -0
  143. package/app/web/role-avatars/builtin/scholar-otter.webp +0 -0
  144. package/app/web/role-avatars/builtin/security-otter.webp +0 -0
  145. package/app/web/role-avatars/builtin/tester-otter.webp +0 -0
  146. package/app/web/role-avatars/builtin/wizard-otter.webp +0 -0
  147. package/app/web/role-avatars/builtin/writer-otter.webp +0 -0
  148. package/app/web-modules/node_modules/@deepseek-ai/dsh-host-webserver/index.js +7 -1
  149. package/app/web-modules/server.mjs +6951 -2390
  150. package/bin/codexhost.exe +0 -0
  151. package/libexec/codexhost-node-repl.exe +0 -0
  152. package/libexec/codexhost-screenshot.exe +0 -0
  153. package/libexec/codexhost-shell.exe +0 -0
  154. package/libexec/codexhost-shim.exe +0 -0
  155. package/libexec/codexhost-updater.exe +0 -0
  156. package/package.json +1 -1
  157. package/app/web/assets/index-CDRWzs-u.js +0 -205
  158. package/app/web/assets/index-Dwdnvinl.css +0 -1
  159. package/app/web/assets/swimlanesDiagram-UCCPES4V-CR0nv8kJ.js +0 -8
@@ -1,6 +1,6 @@
1
- window.__ModuleLoader__.load({id:`@deepseek-ai/dsh-client-ui-chat`,factory:e=>{var t={exports:{}},n=t.exports;Object.defineProperty(n,Symbol.toStringTag,{value:`Module`});var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var s=o(t),l=0,u=s.length,d;l<u;l++)d=s[l],!c.call(e,d)&&d!==n&&i(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=a(t,d))||r.enumerable});return e},u=(e,t,n)=>(n=e==null?{}:r(s(e)),l(t||!e||!e.__esModule||!c.call(e,`default`)?i(n,`default`,{value:e,enumerable:!0}):n,e));let d=e("react");d=u(d,1);let f=e("react/jsx-runtime"),p=e("@deepseek-ai/dsh-client-ui-primitives"),m=e("@deepseek-ai/dsh-client-store"),h=e("react-dom"),g=`@deepseek-ai/dsh-client-ui-chat/ChangeStat.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(g)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=g,e.textContent=`._6NQHLq_stat{font-size:var(--dsh-change-stat-font-size,inherit);font-variant-numeric:tabular-nums;white-space:nowrap;gap:6px;display:inline-flex}._6NQHLq_added{color:var(--dsw-alias-state-success-primary)}._6NQHLq_removed{color:var(--dsw-alias-state-error-primary)}`,document.head.appendChild(e)}var _={added:`_6NQHLq_added`,removed:`_6NQHLq_removed`,stat:`_6NQHLq_stat`};function v({added:e,removed:t}){return/* @__PURE__ */ (0,f.jsxs)(`span`,{className:_.stat,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:_.added,children:`+${e}`}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:_.removed,children:`-${t}`})]})}let y=[],b={getSnapshot:()=>void 0,subscribe:()=>()=>{}};function x(e){let t=/* @__PURE__ */ new Map;for(let n of e){let{parentCallId:e,isError:r,meta:i}=n;if(e!==void 0||r===!0||!Array.isArray(i?.diffs))continue;let a=/* @__PURE__ */ new Map;for(let e of i.diffs)typeof e?.path==`string`&&a.set(e.path,[...a.get(e.path)??[],e]);for(let[e,n]of a)t.set(e,n)}return[...t].map(([e,t])=>({path:e,...(0,p.diffTotals)(t),hunks:t}))}function S(e,t,n){let r=n(`codexhostTurnChanges`,e=>t===void 0?void 0:e?.[t]),i=t===void 0||r!==void 0?b:e.turnDataSource(t,`tool-call`),a=(0,d.useSyncExternalStore)(i.subscribe,i.getSnapshot);return r===void 0?a===void 0?y:x(a.map(e=>e.root)):r}function C(e){return{added:e.reduce((e,t)=>e+t.added,0),removed:e.reduce((e,t)=>e+t.removed,0)}}function w(e){return e.split(/[\\/]/).at(-1)??e}let T=`@deepseek-ai/dsh-client-ui-chat/ChangesDock.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(T)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=T,e.textContent=`.iSRiBq_root{justify-content:center;margin-bottom:6px;display:flex}.iSRiBq_anchor{corner-shape:round;border-radius:16px;position:relative}.iSRiBq_anchor:focus-visible{outline:2px solid var(--dsw-alias-label-tertiary);outline-offset:2px}.iSRiBq_pill{border:1px solid var(--dsw-alias-border-l1);border-radius:inherit;corner-shape:round;color:var(--dsw-alias-label-tertiary);font-size:calc(var(--dsh-content-font-size-secondary,13px) + 2px);white-space:nowrap;--dsh-change-stat-font-size:calc(var(--dsh-content-font-size-secondary,13px) + 1px);--dsw-alias-state-success-primary:var(--dsw-alias-file-diff-added-marker);--dsw-alias-state-error-primary:var(--dsw-alias-file-diff-deleted-marker);background:0 0;align-items:center;gap:4px;padding:8px 12px;line-height:20px;display:inline-flex}.iSRiBq_list{corner-shape:round;background:var(--dsw-alias-button-floating-fill);box-shadow:var(--dsw-elevation-panel);color:var(--dsw-alias-label-primary);font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);white-space:nowrap;border-radius:12px;margin:0;padding:4px 12px;list-style:none;display:none;position:absolute;bottom:calc(100% + 6px);left:50%;transform:translate(-50%)}.iSRiBq_anchor:is(:hover,:focus-visible) .iSRiBq_list{display:block}.iSRiBq_file{justify-content:space-between;gap:16px;max-width:360px;padding:3px 0;display:flex}.iSRiBq_path{text-overflow:ellipsis;overflow:hidden}`,document.head.appendChild(e)}var E={anchor:`iSRiBq_anchor`,file:`iSRiBq_file`,list:`iSRiBq_list`,path:`iSRiBq_path`,pill:`iSRiBq_pill`,root:`iSRiBq_root`};let D=(0,d.memo)(function({useChat:e,useSession:t,useProjection:n,t:r}){let i=t(e=>e.running),a=e(e=>e.nodes),o=e(e=>e.navigation.items().at(-1)?.turn),s=S(a,i?o:void 0,n);if(!i||s.length===0)return null;let{added:c,removed:l}=C(s);return/* @__PURE__ */ (0,f.jsx)(`div`,{className:E.root,children:/* @__PURE__ */ (0,f.jsxs)(`div`,{className:E.anchor,tabIndex:0,children:[/* @__PURE__ */ (0,f.jsx)(`ul`,{className:E.list,children:s.map(e=>/* @__PURE__ */ (0,f.jsxs)(`li`,{className:E.file,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:E.path,children:w(e.path)}),/* @__PURE__ */ (0,f.jsx)(v,{added:e.added,removed:e.removed})]},e.path))}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:E.pill,role:`status`,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{children:r(`chat.filesChanged`,{count:s.length})}),/* @__PURE__ */ (0,f.jsx)(v,{added:c,removed:l})]})]})})});function O(e){return encodeURIComponent(e).replace(/%3A/gi,`:`)}function k(e){return e.split(`/`).map(O).join(`/`)}function A(e,t){let n=t.replace(/\\/g,`/`).replace(/^(?:\.\/)+/,``);return`dsh-resource://file/session/${O(e)}/${k(n)}`}function ee(e){return/^[A-Za-z]:[/\\]/.test(e)||e.startsWith(`\\\\`)}function j(e){return e.startsWith(`/`)||ee(e)}function te(e,t){if(j(t)||e===void 0||e===``)return t;let n=ee(e)&&e.includes(`\\`)?`\\`:`/`;return`${e.replace(/[/\\]+$/,``)}${n}${t.replace(/^[/\\]+/,``)}`}function ne(e,t,n){let r=n.replace(/\\/g,`/`);if(!j(r))return A(e,r);let i=t===void 0?``:t.replace(/\\/g,`/`).replace(/\/+$/,``);return i!==``&&r===i?A(e,``):i!==``&&r.startsWith(`${i}/`)?A(e,r.slice(i.length+1)):A(e,r)}function re(e,t){if(!(!/^https?:/u.test(e)&&!e.startsWith(`dsh-app://app/`)||!j(t)||/^[/\\]{2}/u.test(t)||/[\u0000-\u001f\u007f]/u.test(t)))return new URL(`api/file?path=${encodeURIComponent(t)}`,e).href}let ie=[],ae={turnOrder:ie,turns:/* @__PURE__ */ new Map},oe={getSnapshot:()=>void 0,subscribe:()=>()=>{}},se={getSnapshot:()=>void 0,subscribe:()=>()=>{}},ce={getSnapshot:()=>ie,subscribe:()=>()=>{}},le={order:ie,nodes:{get:()=>void 0,source:()=>oe,turnDataSource:()=>ce,processSource:()=>se,values:()=>ie},locations:{getTurn:()=>ie,getStep:()=>ie},navigation:{items:()=>ie},timeline:ae,legacy:{nodes:ie,turnTimings:/* @__PURE__ */ new Map,turnEnds:/* @__PURE__ */ new Map,partial:null,runningCalls:ie}};function ue(e){if(e!==void 0)try{let t=JSON.parse(e.argsRaw);return typeof t.command==`string`?t.command:void 0}catch{return}}function M({callId:e,useChat:t}){return t(t=>{for(let n of t.nodes.values()){let t=n.kind===`tool-call`?n.data.root:void 0;if(t!==void 0&&t.callId===e&&!(`kind`in t)&&t.phase===`start`)return ue(t)}})??null}function de(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function fe(e,t=`|`){return e.map(e=>Le(e)).join(t)}function pe(e,t){return typeof t==`bigint`?t.toString():t}var me=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function he(e){return new me(e)}function ge(e){return e==null}function _e(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function ve(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}let ye=/* @__PURE__*/ Symbol(`evaluating`);function be(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==ye)return r===void 0&&(r=ye,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function xe(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Se(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function N(e){return Se(e._zod.def)??e._zod.def.shape}function Ce(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return xe(this,t,e),e},enumerable:!0,configurable:!0})}function we(e,t,n){t in e?xe(e,t,n):e[t]=n}function P(e,t,n,r){let i=N(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?Ce(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):we(e,a,r?r(n.value,a):n.value))}}function Te(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?Ce(e,n,()=>t[n]):we(e,n,r.value))}}function Ee(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function De(e){return JSON.stringify(e)}function Oe(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}let ke=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Ae(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}let je=/* @__PURE__*/ he(()=>{if(Et.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Me(e){if(Ae(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Ae(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Ne(e){return Me(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}let Pe=/* @__PURE__*/ new Set([`string`,`number`,`symbol`]);function Fe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Ie(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function F(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Le(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function Re(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}let ze={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Be={int64:[/* @__PURE__*/ BigInt(`-9223372036854775808`),/* @__PURE__*/ BigInt(`9223372036854775807`)],uint64:[/* @__PURE__*/ BigInt(0),/* @__PURE__*/ BigInt(`18446744073709551615`)]};function Ve(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return P(i,e,He(e,t)),Ie(e,Ee(n,{shape:i,checks:[]}))}function He(e,t){let n=N(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function Ue(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(He(e,t)),a={};return P(a,e,Reflect.ownKeys(N(e)).filter(e=>!i.has(e))),Ie(e,Ee(n,{shape:a,checks:[]}))}function We(e,t){if(!Me(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=N(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Ie(e,Ee(e._zod.def,{shape:Ge(e,t)}))}function Ge(e,t){let n={};return P(n,e,Reflect.ownKeys(N(e))),Te(n,t),n}function Ke(e,t){if(!Me(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Ie(e,Ee(e._zod.def,{shape:Ge(e,t)}))}function qe(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return P(n,e,Reflect.ownKeys(N(e))),P(n,t,Reflect.ownKeys(N(t))),Ie(e,Ee(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Je(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(He(t,n)):void 0,o={};return P(o,t,Reflect.ownKeys(N(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),Ie(t,Ee(t._zod.def,{shape:o,checks:[]}))}function Ye(e,t,n){let r=n?new Set(He(t,n)):void 0,i={};return P(i,t,Reflect.ownKeys(N(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),Ie(t,Ee(t._zod.def,{shape:i}))}function Xe(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Ze(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Qe(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function $e(e){return typeof e==`string`?e:e?.message}function et(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function tt(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function nt(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:$e(e.inst?._zod.def?.error?.(e))??$e(a?.(e))??$e(t?.error?.(e))??$e(n.customError?.(e))??$e(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}let rt=/[\uD800-\uDBFF]/;function it(e){let t=e.length;if(!rt.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function at(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function ot(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function st(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function ct(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):ft(e,n,r.value)}}function lt(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function ut(e,t,n){return lt(e,t,n,!1)}function dt(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return lt(this,n,r(this))},set(e){lt(this,n,e)}})}return t}function ft(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:lt(this,t,n.bind(this))},set(e){lt(this,t,e)}})}function pt(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}let mt,ht=!1,gt={configurable:!0,get(){ht=!0}};function I(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&mt!==e._zod?mt=void 0:(mt=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,gt);let e=ht;ht=!1;try{let r=n(this);return ht?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),ht||=e,r}catch(n){throw delete this[t],ht||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function _t(e,t,n,r){let i=pt(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}function vt(e){let t=()=>e;return t[`~constantCatch`]=!0,t}var yt;let bt=/*@__PURE__*/ Object.freeze({status:`aborted`}),xt={value:void 0,enumerable:!1},St=`captureStackTrace`in Error?Error:null;function Ct(e){let t=St;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return St=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function L(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=/* @__PURE__ */ new Set}a.prototype=i;let o=n,s=o&&/* @__PURE__ */ new WeakSet;function c(n,r){if(!n._zod){xt.value=new a(r);try{Object.defineProperty(n,"_zod",xt)}finally{xt.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),ct(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?Ct(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var wt=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Tt=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(yt=globalThis).__zod_globalConfig??(yt.__zod_globalConfig={});let Et=globalThis.__zod_globalConfig;function Dt(e){return e&&Object.assign(Et,e),Et}function Ot(){let e=this._zod;return e.message??=JSON.stringify(e.def,pe,2),e.message}function kt(e){this._zod.message=e}let At={get:Ot,set:kt,enumerable:!0,configurable:!0},jt={value:void 0,enumerable:!1},Mt=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]),Nt=(e,t)=>{e.name=`$ZodError`,jt.value=t,Object.defineProperty(e,"issues",jt),jt.value=void 0,Object.defineProperty(e,"message",At);let n=Object.getPrototypeOf(e);Mt.has(n)||(Mt.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},Pt=L(`$ZodError`,Nt);L(`$ZodError`,Nt,void 0,{Parent:Error});function Ft(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function It(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?Ft(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Lt(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function Rt(e,t){return{callee:t?.callee??e,Err:t?.Err}}let zt=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new wt;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>nt(e,o,Dt())));throw ke(n,a?.callee??t),n}return s.value};return t},Bt=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>nt(e,o,Dt())));throw ke(n,a?.callee??t),n}return s.value};return t},Vt=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new wt;return a.issues.length?Ht(e,a.issues,i):{success:!0,data:a.value}};function Ht(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>nt(e,n,Dt()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}let Ut=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?Ht(e,a.issues,i):{success:!0,data:a.value}},Wt=/* @__PURE__ */ Symbol.for(`zod.compile.invalid`),Gt=/* @__PURE__ */ Symbol.for(`zod.compile.fallback`),Kt=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Wt)return!0;if(r.definite===!0&&n===void 0)return!1}return qt(e,t,n)});function qt(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[Gt]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new wt;return a.issues.length===0}let Jt=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},Yt=e=>{let t=zt(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,Rt(n,a))};return n},Xt=e=>{let t=zt(e),n=(e,r,i,a)=>t(e,r,i,Rt(n,a));return n},Zt=e=>{let t=Bt(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,Rt(n,a))};return n},Qt=e=>{let t=Bt(e),n=async(e,r,i,a)=>await t(e,r,i,Rt(n,a));return n},$t=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Vt(e)(t,n,i)},en=e=>(t,n,r)=>Vt(e)(t,n,r),tn=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Ut(e)(t,n,i)},nn=e=>async(t,n,r)=>Ut(e)(t,n,r),rn=/^[cC][0-9a-z]{6,}$/,an=/^[0-9a-z]+$/,on=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,sn=/^[0-9a-vA-V]{20}$/,cn=/^[A-Za-z0-9]{27}$/,ln=/^[a-zA-Z0-9_-]{21}$/;function un(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}let dn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,fn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,pn=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,mn=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function hn(){return RegExp(`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,`u`)}let gn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,_n=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,vn=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,yn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,bn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,xn=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Sn=/^https?$/,Cn=/^\+[1-9]\d{6,14}$/,wn=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function Tn(e){return RegExp(`^${e}$`)}let En=/*@__PURE__*/ Tn(wn);function Dn(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function On(e){return RegExp(`^${Dn(e)}$`)}function kn(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${Dn({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${Dn({precision:e.precision})}`:n;return RegExp(`^${wn}T(?:${r})$`)}let An=/^[\s\S]{0,}$/,jn=/^-?\d+$/,Mn=/^-?\d+(?:\.\d+)?$/,Nn=/^(?:true|false)$/i,Pn=/^null$/i,Fn=/^[^A-Z]*$/,In=/^[^a-z]*$/,Ln=/*@__PURE__*/ L(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Rn=e=>{let t=e.value;return!ge(t)&&t.length!==void 0},zn={number:`number`,bigint:`bigint`,object:`date`},Bn=/*@__PURE__*/ L(`$ZodCheckLessThan`,(e,t)=>{Ln.init(e,t);let n=zn[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:zn[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Vn=/*@__PURE__*/ L(`$ZodCheckGreaterThan`,(e,t)=>{Ln.init(e,t);let n=zn[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:zn[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Hn=/*@__PURE__*/ L(`$ZodCheckMultipleOf`,(e,t)=>{Ln.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):ve(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Un=/*@__PURE__*/ L(`$ZodCheckNumberFormat`,(e,t)=>{Ln.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=ze[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Wn=/*@__PURE__*/ L(`$ZodCheckMaxLength`,(e,t)=>{var n;Ln.init(e,t),(n=e._zod.def).when??(n.when=Rn),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?it(r):i)<=t.maximum)return;let a=at(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Gn=/*@__PURE__*/ L(`$ZodCheckMinLength`,(e,t)=>{var n;Ln.init(e,t),(n=e._zod.def).when??(n.when=Rn),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?it(r):i)>=t.minimum)return;let a=at(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Kn=/*@__PURE__*/ L(`$ZodCheckLengthEquals`,(e,t)=>{var n;Ln.init(e,t),(n=e._zod.def).when??(n.when=Rn),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?it(r):i;if(a===t.length)return;let o=at(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),qn=/*@__PURE__*/ L(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Ln.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Jn=/*@__PURE__*/ L(`$ZodCheckRegex`,(e,t)=>{qn.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Yn=/*@__PURE__*/ L(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Fn,qn.init(e,t)}),Xn=/*@__PURE__*/ L(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=In,qn.init(e,t)}),Zn=/*@__PURE__*/ L(`$ZodCheckIncludes`,(e,t)=>{Ln.init(e,t);let n=Fe(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Qn=/*@__PURE__*/ L(`$ZodCheckStartsWith`,(e,t)=>{Ln.init(e,t);let n=RegExp(`^${Fe(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),$n=/*@__PURE__*/ L(`$ZodCheckEndsWith`,(e,t)=>{Ln.init(e,t);let n=RegExp(`.*${Fe(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),er=/*@__PURE__*/ L(`$ZodCheckOverwrite`,(e,t)=>{Ln.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var tr=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
1
+ window.__ModuleLoader__.load({id:`@deepseek-ai/dsh-client-ui-chat`,factory:e=>{var t={exports:{}},n=t.exports;Object.defineProperty(n,Symbol.toStringTag,{value:`Module`});var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var s=o(t),l=0,u=s.length,d;l<u;l++)d=s[l],!c.call(e,d)&&d!==n&&i(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=a(t,d))||r.enumerable});return e},u=(e,t,n)=>(n=e==null?{}:r(s(e)),l(t||!e||!e.__esModule||!c.call(e,`default`)?i(n,`default`,{value:e,enumerable:!0}):n,e));let d=e("react");d=u(d,1);let f=e("react/jsx-runtime"),p=e("@deepseek-ai/dsh-client-ui-primitives"),m=e("@deepseek-ai/dsh-client-store"),h=e("react-dom"),g=`@deepseek-ai/dsh-client-ui-chat/ChangeStat.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(g)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=g,e.textContent=`._6NQHLq_stat{font-size:var(--dsh-change-stat-font-size,inherit);font-variant-numeric:tabular-nums;white-space:nowrap;gap:6px;display:inline-flex}._6NQHLq_added{color:var(--dsw-alias-state-success-primary)}._6NQHLq_removed{color:var(--dsw-alias-state-error-primary)}`,document.head.appendChild(e)}var _={added:`_6NQHLq_added`,removed:`_6NQHLq_removed`,stat:`_6NQHLq_stat`};function v({added:e,removed:t}){return/* @__PURE__ */ (0,f.jsxs)(`span`,{className:_.stat,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:_.added,children:`+${e}`}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:_.removed,children:`-${t}`})]})}let y=[],b={getSnapshot:()=>void 0,subscribe:()=>()=>{}};function x(e){let t=/* @__PURE__ */ new Map;for(let n of e){let{parentCallId:e,isError:r,meta:i}=n;if(e!==void 0||r===!0||!Array.isArray(i?.diffs))continue;let a=/* @__PURE__ */ new Map;for(let e of i.diffs)typeof e?.path==`string`&&a.set(e.path,[...a.get(e.path)??[],e]);for(let[e,n]of a)t.set(e,n)}return[...t].map(([e,t])=>({path:e,...(0,p.diffTotals)(t),hunks:t}))}function S(e,t,n){let r=n(`codexhostTurnChanges`,e=>t===void 0?void 0:e?.[t]),i=t===void 0||r!==void 0?b:e.turnDataSource(t,`tool-call`),a=(0,d.useSyncExternalStore)(i.subscribe,i.getSnapshot);return r===void 0?a===void 0?y:x(a.map(e=>e.root)):r}function C(e){return{added:e.reduce((e,t)=>e+t.added,0),removed:e.reduce((e,t)=>e+t.removed,0)}}function w(e){return e.split(/[\\/]/).at(-1)??e}let T=`@deepseek-ai/dsh-client-ui-chat/ChangesDock.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(T)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=T,e.textContent=`.iSRiBq_root{justify-content:center;margin-bottom:6px;display:flex}.iSRiBq_anchor{corner-shape:round;border-radius:16px;position:relative}.iSRiBq_anchor:focus-visible{outline:2px solid var(--dsw-alias-label-tertiary);outline-offset:2px}.iSRiBq_pill{border:1px solid var(--dsw-alias-border-l1);border-radius:inherit;corner-shape:round;color:var(--dsw-alias-label-tertiary);font-size:calc(var(--dsh-content-font-size-secondary,13px) + 2px);white-space:nowrap;--dsh-change-stat-font-size:calc(var(--dsh-content-font-size-secondary,13px) + 1px);--dsw-alias-state-success-primary:var(--dsw-alias-file-diff-added-marker);--dsw-alias-state-error-primary:var(--dsw-alias-file-diff-deleted-marker);background:0 0;align-items:center;gap:4px;padding:8px 12px;line-height:20px;display:inline-flex}.iSRiBq_list{corner-shape:round;background:var(--dsw-alias-button-floating-fill);box-shadow:var(--dsw-elevation-panel);color:var(--dsw-alias-label-primary);font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);white-space:nowrap;border-radius:12px;margin:0;padding:4px 12px;list-style:none;display:none;position:absolute;bottom:calc(100% + 6px);left:50%;transform:translate(-50%)}.iSRiBq_anchor:is(:hover,:focus-visible) .iSRiBq_list{display:block}.iSRiBq_file{justify-content:space-between;gap:16px;max-width:360px;padding:3px 0;display:flex}.iSRiBq_path{text-overflow:ellipsis;overflow:hidden}`,document.head.appendChild(e)}var E={anchor:`iSRiBq_anchor`,file:`iSRiBq_file`,list:`iSRiBq_list`,path:`iSRiBq_path`,pill:`iSRiBq_pill`,root:`iSRiBq_root`};let ee=(0,d.memo)(function({useChat:e,useSession:t,useProjection:n,t:r}){let i=t(e=>e.running),a=e(e=>e.nodes),o=e(e=>e.navigation.items().at(-1)?.turn),s=S(a,i?o:void 0,n);if(!i||s.length===0)return null;let{added:c,removed:l}=C(s);return/* @__PURE__ */ (0,f.jsx)(`div`,{className:E.root,children:/* @__PURE__ */ (0,f.jsxs)(`div`,{className:E.anchor,tabIndex:0,children:[/* @__PURE__ */ (0,f.jsx)(`ul`,{className:E.list,children:s.map(e=>/* @__PURE__ */ (0,f.jsxs)(`li`,{className:E.file,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:E.path,children:w(e.path)}),/* @__PURE__ */ (0,f.jsx)(v,{added:e.added,removed:e.removed})]},e.path))}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:E.pill,role:`status`,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{children:r(`chat.filesChanged`,{count:s.length})}),/* @__PURE__ */ (0,f.jsx)(v,{added:c,removed:l})]})]})})});function D(e){return encodeURIComponent(e).replace(/%3A/gi,`:`)}function O(e){return e.split(`/`).map(D).join(`/`)}function te(e,t){let n=t.replace(/\\/g,`/`).replace(/^(?:\.\/)+/,``);return`dsh-resource://file/session/${D(e)}/${O(n)}`}function ne(e){return/^[A-Za-z]:[/\\]/.test(e)||e.startsWith(`\\\\`)}function re(e){return e.startsWith(`/`)||ne(e)}function ie(e,t){if(re(t)||e===void 0||e===``)return t;let n=ne(e)&&e.includes(`\\`)?`\\`:`/`;return`${e.replace(/[/\\]+$/,``)}${n}${t.replace(/^[/\\]+/,``)}`}function ae(e,t,n){let r=n.replace(/\\/g,`/`);if(!re(r))return te(e,r);let i=t===void 0?``:t.replace(/\\/g,`/`).replace(/\/+$/,``);return i!==``&&r===i?te(e,``):i!==``&&r.startsWith(`${i}/`)?te(e,r.slice(i.length+1)):te(e,r)}function oe(e,t){if(!(!/^https?:/u.test(e)&&!e.startsWith(`dsh-app://app/`)||!re(t)||/^[/\\]{2}/u.test(t)||/[\u0000-\u001f\u007f]/u.test(t)))return new URL(`api/file?path=${encodeURIComponent(t)}`,e).href}let se=[],ce={turnOrder:se,turns:/* @__PURE__ */ new Map},le={getSnapshot:()=>void 0,subscribe:()=>()=>{}},ue={getSnapshot:()=>void 0,subscribe:()=>()=>{}},de={getSnapshot:()=>se,subscribe:()=>()=>{}},fe={order:se,nodes:{get:()=>void 0,source:()=>le,turnDataSource:()=>de,processSource:()=>ue,values:()=>se},locations:{getTurn:()=>se,getStep:()=>se},navigation:{items:()=>se},timeline:ce,legacy:{nodes:se,turnTimings:/* @__PURE__ */ new Map,turnEnds:/* @__PURE__ */ new Map,partial:null,runningCalls:se}};function pe(e){if(e!==void 0)try{let t=JSON.parse(e.argsRaw);return typeof t.command==`string`?t.command:void 0}catch{return}}function k({callId:e,useChat:t}){return t(t=>{for(let n of t.nodes.values()){let t=n.kind===`tool-call`?n.data.root:void 0;if(t!==void 0&&t.callId===e&&!(`kind`in t)&&t.phase===`start`)return pe(t)}})??null}function me(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function he(e,t=`|`){return e.map(e=>Ue(e)).join(t)}function ge(e,t){return typeof t==`bigint`?t.toString():t}var _e=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function ve(e){return new _e(e)}function ye(e){return e==null}function be(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function xe(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}let Se=/* @__PURE__*/ Symbol(`evaluating`);function Ce(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Se)return r===void 0&&(r=Se,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function we(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Te(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function Ee(e){return Te(e._zod.def)??e._zod.def.shape}function De(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return we(this,t,e),e},enumerable:!0,configurable:!0})}function Oe(e,t,n){t in e?we(e,t,n):e[t]=n}function ke(e,t,n,r){let i=Ee(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?De(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):Oe(e,a,r?r(n.value,a):n.value))}}function Ae(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?De(e,n,()=>t[n]):Oe(e,n,r.value))}}function je(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Me(e){return JSON.stringify(e)}function Ne(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}let Pe=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Fe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}let Ie=/* @__PURE__*/ ve(()=>{if(Mt.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Le(e){if(Fe(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Fe(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Re(e){return Le(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}let ze=/* @__PURE__*/ new Set([`string`,`number`,`symbol`]),Be=/* @__PURE__*/ new Set([`string`,`number`,`bigint`,`boolean`,`symbol`,`undefined`]);function Ve(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function He(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function A(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Ue(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function We(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}let Ge={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Ke={int64:[/* @__PURE__*/ BigInt(`-9223372036854775808`),/* @__PURE__*/ BigInt(`9223372036854775807`)],uint64:[/* @__PURE__*/ BigInt(0),/* @__PURE__*/ BigInt(`18446744073709551615`)]};function qe(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return ke(i,e,Je(e,t)),He(e,je(n,{shape:i,checks:[]}))}function Je(e,t){let n=Ee(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function Ye(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(Je(e,t)),a={};return ke(a,e,Reflect.ownKeys(Ee(e)).filter(e=>!i.has(e))),He(e,je(n,{shape:a,checks:[]}))}function Xe(e,t){if(!Le(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=Ee(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return He(e,je(e._zod.def,{shape:Ze(e,t)}))}function Ze(e,t){let n={};return ke(n,e,Reflect.ownKeys(Ee(e))),Ae(n,t),n}function Qe(e,t){if(!Le(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return He(e,je(e._zod.def,{shape:Ze(e,t)}))}function $e(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return ke(n,e,Reflect.ownKeys(Ee(e))),ke(n,t,Reflect.ownKeys(Ee(t))),He(e,je(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function et(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(Je(t,n)):void 0,o={};return ke(o,t,Reflect.ownKeys(Ee(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),He(t,je(t._zod.def,{shape:o,checks:[]}))}function tt(e,t,n){let r=n?new Set(Je(t,n)):void 0,i={};return ke(i,t,Reflect.ownKeys(Ee(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),He(t,je(t._zod.def,{shape:i}))}function nt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function rt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function it(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function at(e){return typeof e==`string`?e:e?.message}function ot(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function st(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function ct(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:at(e.inst?._zod.def?.error?.(e))??at(a?.(e))??at(t?.error?.(e))??at(n.customError?.(e))??at(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}let lt=/[\uD800-\uDBFF]/;function ut(e){let t=e.length;if(!lt.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function dt(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function ft(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function pt(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function mt(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):vt(e,n,r.value)}}function ht(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function gt(e,t,n){return ht(e,t,n,!1)}function _t(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return ht(this,n,r(this))},set(e){ht(this,n,e)}})}return t}function vt(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:ht(this,t,n.bind(this))},set(e){ht(this,t,e)}})}function yt(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}let bt,xt=!1,St={configurable:!0,get(){xt=!0}};function j(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&bt!==e._zod?bt=void 0:(bt=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,St);let e=xt;xt=!1;try{let r=n(this);return xt?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),xt||=e,r}catch(n){throw delete this[t],xt||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function Ct(e,t,n,r){let i=yt(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}function wt(e){let t=()=>e;return t[`~constantCatch`]=!0,t}var Tt;let Et=/*@__PURE__*/ Object.freeze({status:`aborted`}),Dt={value:void 0,enumerable:!1},Ot=`captureStackTrace`in Error?Error:null;function kt(e){let t=Ot;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return Ot=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function M(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=/* @__PURE__ */ new Set}a.prototype=i;let o=n,s=o&&/* @__PURE__ */ new WeakSet;function c(n,r){if(!n._zod){Dt.value=new a(r);try{Object.defineProperty(n,"_zod",Dt)}finally{Dt.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),mt(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?kt(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var At=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},jt=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Tt=globalThis).__zod_globalConfig??(Tt.__zod_globalConfig={});let Mt=globalThis.__zod_globalConfig;function Nt(e){return e&&Object.assign(Mt,e),Mt}function Pt(){let e=this._zod;return e.message??=JSON.stringify(e.def,ge,2),e.message}function Ft(e){this._zod.message=e}let It={get:Pt,set:Ft,enumerable:!0,configurable:!0},Lt={value:void 0,enumerable:!1},Rt=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]),zt=(e,t)=>{e.name=`$ZodError`,Lt.value=t,Object.defineProperty(e,"issues",Lt),Lt.value=void 0,Object.defineProperty(e,"message",It);let n=Object.getPrototypeOf(e);Rt.has(n)||(Rt.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},Bt=M(`$ZodError`,zt);M(`$ZodError`,zt,void 0,{Parent:Error});function Vt(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function Ht(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?Vt(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Ut(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function Wt(e,t){return{callee:t?.callee??e,Err:t?.Err}}let Gt=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new At;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>ct(e,o,Nt())));throw Pe(n,a?.callee??t),n}return s.value};return t},Kt=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>ct(e,o,Nt())));throw Pe(n,a?.callee??t),n}return s.value};return t},qt=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new At;return a.issues.length?Jt(e,a.issues,i):{success:!0,data:a.value}};function Jt(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>ct(e,n,Nt()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}let Yt=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?Jt(e,a.issues,i):{success:!0,data:a.value}},Xt=/* @__PURE__ */ Symbol.for(`zod.compile.invalid`),Zt=/* @__PURE__ */ Symbol.for(`zod.compile.fallback`),Qt=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Xt)return!0;if(r.definite===!0&&n===void 0)return!1}return $t(e,t,n)});function $t(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[Zt]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new At;return a.issues.length===0}let en=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},tn=e=>{let t=Gt(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,Wt(n,a))};return n},nn=e=>{let t=Gt(e),n=(e,r,i,a)=>t(e,r,i,Wt(n,a));return n},rn=e=>{let t=Kt(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,Wt(n,a))};return n},an=e=>{let t=Kt(e),n=async(e,r,i,a)=>await t(e,r,i,Wt(n,a));return n},on=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return qt(e)(t,n,i)},sn=e=>(t,n,r)=>qt(e)(t,n,r),cn=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Yt(e)(t,n,i)},ln=e=>async(t,n,r)=>Yt(e)(t,n,r),un=/^[cC][0-9a-z]{6,}$/,dn=/^[0-9a-z]+$/,fn=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,pn=/^[0-9a-vA-V]{20}$/,mn=/^[A-Za-z0-9]{27}$/,hn=/^[a-zA-Z0-9_-]{21}$/;function gn(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}let _n=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,vn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,yn=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,bn=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function xn(){return RegExp(`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,`u`)}let Sn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Cn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,wn=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Tn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,En=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Dn=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,On=/^https?$/,kn=/^\+[1-9]\d{6,14}$/,An=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function jn(e){return RegExp(`^${e}$`)}let Mn=/*@__PURE__*/ jn(An);function Nn(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Pn(e){return RegExp(`^${Nn(e)}$`)}function Fn(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${Nn({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${Nn({precision:e.precision})}`:n;return RegExp(`^${An}T(?:${r})$`)}let In=/^[\s\S]{0,}$/,Ln=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Rn=/^-?\d+$/,zn=/^-?\d+(?:\.\d+)?$/,Bn=/^(?:true|false)$/i,Vn=/^null$/i,Hn=/^[^A-Z]*$/,Un=/^[^a-z]*$/,Wn=/*@__PURE__*/ M(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Gn=e=>{let t=e.value;return!ye(t)&&t.length!==void 0},Kn={number:`number`,bigint:`bigint`,object:`date`},qn=/*@__PURE__*/ M(`$ZodCheckLessThan`,(e,t)=>{Wn.init(e,t);let n=Kn[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:Kn[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Jn=/*@__PURE__*/ M(`$ZodCheckGreaterThan`,(e,t)=>{Wn.init(e,t);let n=Kn[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:Kn[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Yn=/*@__PURE__*/ M(`$ZodCheckMultipleOf`,(e,t)=>{Wn.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):xe(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Xn=/*@__PURE__*/ M(`$ZodCheckNumberFormat`,(e,t)=>{Wn.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Ge[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Zn=/*@__PURE__*/ M(`$ZodCheckMaxLength`,(e,t)=>{var n;Wn.init(e,t),(n=e._zod.def).when??(n.when=Gn),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?ut(r):i)<=t.maximum)return;let a=dt(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Qn=/*@__PURE__*/ M(`$ZodCheckMinLength`,(e,t)=>{var n;Wn.init(e,t),(n=e._zod.def).when??(n.when=Gn),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?ut(r):i)>=t.minimum)return;let a=dt(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),$n=/*@__PURE__*/ M(`$ZodCheckLengthEquals`,(e,t)=>{var n;Wn.init(e,t),(n=e._zod.def).when??(n.when=Gn),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?ut(r):i;if(a===t.length)return;let o=dt(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),er=/*@__PURE__*/ M(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Wn.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),tr=/*@__PURE__*/ M(`$ZodCheckRegex`,(e,t)=>{er.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),nr=/*@__PURE__*/ M(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Hn,er.init(e,t)}),rr=/*@__PURE__*/ M(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Un,er.init(e,t)}),ir=/*@__PURE__*/ M(`$ZodCheckIncludes`,(e,t)=>{Wn.init(e,t);let n=Ve(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),ar=/*@__PURE__*/ M(`$ZodCheckStartsWith`,(e,t)=>{Wn.init(e,t);let n=RegExp(`^${Ve(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),or=/*@__PURE__*/ M(`$ZodCheckEndsWith`,(e,t)=>{Wn.init(e,t);let n=RegExp(`.*${Ve(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),sr=/*@__PURE__*/ M(`$ZodCheckOverwrite`,(e,t)=>{Wn.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var cr=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
2
2
  `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
3
- `)}\n};`)(...Object.values(this.closed))}};let nr={major:4,minor:6,patch:7},R=/*@__PURE__*/ L(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=nr;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=Xe(t),a;for(let o of n){if(o._zod.def.when){if(Ze(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new wt;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(tt(t.issues,n,e),i||=Xe(t,n))});else{if(t.issues.length===n)continue;tt(t.issues,n,e),i||=Xe(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(Xe(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new wt;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new wt;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return ut(this,`~standard`,ar(this))},set"~standard"(e){lt(this,`~standard`,e)}}),rr=(e,t)=>e.issues.length?{issues:e.issues.map(e=>nt(e,t,Dt()))}:{value:e.value};async function ir(e,t){let n={async:!0};return rr(await e._zod.run({value:t,issues:[]},n),n)}function ar(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return rr(r,n)}catch{}return ir(e,t)},vendor:`zod`,version:1}}let or=/*@__PURE__*/ L(`$ZodString`,(e,t)=>{R.init(e,t),e._zod.pattern=t.pattern??An,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),sr=/*@__PURE__*/ L(`$ZodStringFormat`,(e,t)=>{qn.init(e,t),or.init(e,t)}),cr=/*@__PURE__*/ L(`$ZodGUID`,(e,t)=>{t.pattern??=fn,sr.init(e,t)}),lr=/*@__PURE__*/ L(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=pn(e)}else t.pattern??=pn();sr.init(e,t)}),ur=/*@__PURE__*/ L(`$ZodEmail`,(e,t)=>{t.pattern??=mn,sr.init(e,t)});function dr(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function fr(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?dr(e)||2:pr(e,t)}function pr(e,t){if(!t.normalize&&t.protocol?.source===Sn.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}let mr=/[\t\n\r]/g;function hr(e){return e.replace(mr,``)}function gr(e,t){return t.lastIndex=0,t.test(e.hostname)}function _r(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}let vr=/*@__PURE__*/ L(`$ZodURL`,(e,t)=>{sr.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=fr(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=hr(r);return}t.hostname&&!gr(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!_r(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:hr(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),yr=/*@__PURE__*/ L(`$ZodEmoji`,(e,t)=>{t.pattern??=hn(),sr.init(e,t)}),br=/*@__PURE__*/ L(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?ln:un(t.length),sr.init(e,t)}),xr=/*@__PURE__*/ L(`$ZodCUID`,(e,t)=>{t.pattern??=rn,sr.init(e,t)}),Sr=/*@__PURE__*/ L(`$ZodCUID2`,(e,t)=>{t.pattern??=an,sr.init(e,t)}),Cr=/*@__PURE__*/ L(`$ZodULID`,(e,t)=>{t.pattern??=on,sr.init(e,t)}),wr=/*@__PURE__*/ L(`$ZodXID`,(e,t)=>{t.pattern??=sn,sr.init(e,t)}),Tr=/*@__PURE__*/ L(`$ZodKSUID`,(e,t)=>{t.pattern??=cn,sr.init(e,t)}),Er=/*@__PURE__*/ L(`$ZodISODateTime`,(e,t)=>{t.pattern??=kn(t),sr.init(e,t)}),Dr=/*@__PURE__*/ L(`$ZodISODate`,(e,t)=>{t.pattern??=En,sr.init(e,t)}),Or=/*@__PURE__*/ L(`$ZodISOTime`,(e,t)=>{t.pattern??=On(t),sr.init(e,t)}),kr=/*@__PURE__*/ L(`$ZodISODuration`,(e,t)=>{t.pattern??=dn,sr.init(e,t)}),Ar=/*@__PURE__*/ L(`$ZodIPv4`,(e,t)=>{t.pattern??=gn,sr.init(e,t)}),jr=/^[0-9a-fA-F:.]+$/;function Mr(e){return jr.test(e)?dr(`http://[${e}]`):!1}let Nr=/*@__PURE__*/ L(`$ZodIPv6`,(e,t)=>{t.pattern??=_n,sr.init(e,t),e._zod.check=n=>{Mr(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),Pr=/*@__PURE__*/ L(`$ZodCIDRv4`,(e,t)=>{t.pattern??=vn,sr.init(e,t)});function Fr(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:Mr(n)}let Ir=/*@__PURE__*/ L(`$ZodCIDRv6`,(e,t)=>{t.pattern??=yn,sr.init(e,t),e._zod.check=n=>{Fr(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function Lr(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let Rr=/^[0-9a-zA-Z+/]*={0,2}$/,zr=/*@__PURE__*/ L(`$ZodBase64`,(e,t)=>{t.pattern??=Rr,sr.init(e,t),e._zod.check=n=>{Lr(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),Br=/^[A-Za-z0-9_-]*$/;function Vr(e){if(!Br.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Lr(t.padEnd(Math.ceil(t.length/4)*4,`=`))}let Hr=/*@__PURE__*/ L(`$ZodBase64URL`,(e,t)=>{t.pattern??=Br,sr.init(e,t),e._zod.check=n=>{Vr(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Ur=/*@__PURE__*/ L(`$ZodE164`,(e,t)=>{t.pattern??=Cn,sr.init(e,t)});function Wr(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}let Gr=/*@__PURE__*/ L(`$ZodJWT`,(e,t)=>{sr.init(e,t),e._zod.check=n=>{Wr(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Kr=/*@__PURE__*/ L(`$ZodNumber`,(e,t)=>{R.init(e,t),e._zod.pattern=Mn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),qr=/*@__PURE__*/ L(`$ZodNumberFormat`,(e,t)=>{Un.init(e,t),Kr.init(e,t)}),Jr=/*@__PURE__*/ L(`$ZodBoolean`,(e,t)=>{R.init(e,t),e._zod.pattern=Nn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Yr=/*@__PURE__*/ L(`$ZodNull`,(e,t)=>{R.init(e,t),e._zod.pattern=Pn,e._zod.values=/* @__PURE__ */ new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),Xr=/*@__PURE__*/ L(`$ZodUnknown`,(e,t)=>{R.init(e,t),e._zod.parse=e=>e}),Zr=/*@__PURE__*/ L(`$ZodNever`,(e,t)=>{R.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Qr(e,t){let n=et(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of et(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,tt(n.issues,t,e),n}}return i(n,a)}}let $r=e=>Array.isArray(e)?e.length:-1;function ei(e,t,n){e.issues.length&&t.issues.push(...Qe(n,e.issues)),t.value[n]=e.value}let ti=/*@__PURE__*/ L(`$ZodArray`,(e,t)=>{R.init(e,t);let n=Et.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>ei(t,r,e)));else if(ei(c,r,e),s&&c.issues.length!==0&&Xe(c))break}return o.length?Promise.all(o).then(()=>r):r},Qr(e,$r)});function ni(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...Qe(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}let ri=[];function ii(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:ri,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=Re(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function ai(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(Xe(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>ni(e,n,i,t,d,f))):ni(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}let oi=/*@__PURE__*/ L(`$ZodObject`,(e,t)=>{R.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=he(()=>ii(t));I(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||xe(n,e,/* @__PURE__ */ new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=Ae,o=t.catchall,s,c=Et.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(Xe(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>ni(n,t,e,r,a,o))):ni(s,t,e,r,a,o)}return o?ai(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),si=/*@__PURE__*/ L(`$ZodObjectJIT`,(e,t)=>{oi.init(e,t);let n=e._zod.parse,r=he(()=>ii(t)),i=Et.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new tr([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
3
+ `)}\n};`)(...Object.values(this.closed))}};let lr={major:4,minor:6,patch:7},N=/*@__PURE__*/ M(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=lr;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=nt(t),a;for(let o of n){if(o._zod.def.when){if(rt(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new At;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(st(t.issues,n,e),i||=nt(t,n))});else{if(t.issues.length===n)continue;st(t.issues,n,e),i||=nt(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(nt(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new At;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new At;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return gt(this,`~standard`,fr(this))},set"~standard"(e){ht(this,`~standard`,e)}}),ur=(e,t)=>e.issues.length?{issues:e.issues.map(e=>ct(e,t,Nt()))}:{value:e.value};async function dr(e,t){let n={async:!0};return ur(await e._zod.run({value:t,issues:[]},n),n)}function fr(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return ur(r,n)}catch{}return dr(e,t)},vendor:`zod`,version:1}}let pr=/*@__PURE__*/ M(`$ZodString`,(e,t)=>{N.init(e,t),e._zod.pattern=t.pattern??In,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),mr=/*@__PURE__*/ M(`$ZodStringFormat`,(e,t)=>{er.init(e,t),pr.init(e,t)}),hr=/*@__PURE__*/ M(`$ZodGUID`,(e,t)=>{t.pattern??=vn,mr.init(e,t)}),gr=/*@__PURE__*/ M(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=yn(e)}else t.pattern??=yn();mr.init(e,t)}),_r=/*@__PURE__*/ M(`$ZodEmail`,(e,t)=>{t.pattern??=bn,mr.init(e,t)});function vr(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function yr(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?vr(e)||2:br(e,t)}function br(e,t){if(!t.normalize&&t.protocol?.source===On.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}let xr=/[\t\n\r]/g;function Sr(e){return e.replace(xr,``)}function Cr(e,t){return t.lastIndex=0,t.test(e.hostname)}function wr(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}let Tr=/*@__PURE__*/ M(`$ZodURL`,(e,t)=>{mr.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=yr(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=Sr(r);return}t.hostname&&!Cr(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!wr(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:Sr(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Er=/*@__PURE__*/ M(`$ZodEmoji`,(e,t)=>{t.pattern??=xn(),mr.init(e,t)}),Dr=/*@__PURE__*/ M(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?hn:gn(t.length),mr.init(e,t)}),Or=/*@__PURE__*/ M(`$ZodCUID`,(e,t)=>{t.pattern??=un,mr.init(e,t)}),kr=/*@__PURE__*/ M(`$ZodCUID2`,(e,t)=>{t.pattern??=dn,mr.init(e,t)}),Ar=/*@__PURE__*/ M(`$ZodULID`,(e,t)=>{t.pattern??=fn,mr.init(e,t)}),jr=/*@__PURE__*/ M(`$ZodXID`,(e,t)=>{t.pattern??=pn,mr.init(e,t)}),Mr=/*@__PURE__*/ M(`$ZodKSUID`,(e,t)=>{t.pattern??=mn,mr.init(e,t)}),Nr=/*@__PURE__*/ M(`$ZodISODateTime`,(e,t)=>{t.pattern??=Fn(t),mr.init(e,t)}),Pr=/*@__PURE__*/ M(`$ZodISODate`,(e,t)=>{t.pattern??=Mn,mr.init(e,t)}),Fr=/*@__PURE__*/ M(`$ZodISOTime`,(e,t)=>{t.pattern??=Pn(t),mr.init(e,t)}),Ir=/*@__PURE__*/ M(`$ZodISODuration`,(e,t)=>{t.pattern??=_n,mr.init(e,t)}),Lr=/*@__PURE__*/ M(`$ZodIPv4`,(e,t)=>{t.pattern??=Sn,mr.init(e,t)}),Rr=/^[0-9a-fA-F:.]+$/;function zr(e){return Rr.test(e)?vr(`http://[${e}]`):!1}let Br=/*@__PURE__*/ M(`$ZodIPv6`,(e,t)=>{t.pattern??=Cn,mr.init(e,t),e._zod.check=n=>{zr(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),Vr=/*@__PURE__*/ M(`$ZodCIDRv4`,(e,t)=>{t.pattern??=wn,mr.init(e,t)});function Hr(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:zr(n)}let Ur=/*@__PURE__*/ M(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Tn,mr.init(e,t),e._zod.check=n=>{Hr(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function Wr(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let Gr=/^[0-9a-zA-Z+/]*={0,2}$/,Kr=/*@__PURE__*/ M(`$ZodBase64`,(e,t)=>{t.pattern??=Gr,mr.init(e,t),e._zod.check=n=>{Wr(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),qr=/^[A-Za-z0-9_-]*$/;function Jr(e){if(!qr.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Wr(t.padEnd(Math.ceil(t.length/4)*4,`=`))}let Yr=/*@__PURE__*/ M(`$ZodBase64URL`,(e,t)=>{t.pattern??=qr,mr.init(e,t),e._zod.check=n=>{Jr(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Xr=/*@__PURE__*/ M(`$ZodE164`,(e,t)=>{t.pattern??=kn,mr.init(e,t)});function Zr(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}let Qr=/*@__PURE__*/ M(`$ZodJWT`,(e,t)=>{mr.init(e,t),e._zod.check=n=>{Zr(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),$r=/*@__PURE__*/ M(`$ZodNumber`,(e,t)=>{N.init(e,t),e._zod.pattern=zn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),ei=/*@__PURE__*/ M(`$ZodNumberFormat`,(e,t)=>{Xn.init(e,t),$r.init(e,t)}),ti=/*@__PURE__*/ M(`$ZodBoolean`,(e,t)=>{N.init(e,t),e._zod.pattern=Bn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),ni=/*@__PURE__*/ M(`$ZodNull`,(e,t)=>{N.init(e,t),e._zod.pattern=Vn,e._zod.values=/* @__PURE__ */ new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),ri=/*@__PURE__*/ M(`$ZodUnknown`,(e,t)=>{N.init(e,t),e._zod.parse=e=>e}),ii=/*@__PURE__*/ M(`$ZodNever`,(e,t)=>{N.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function ai(e,t){let n=ot(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of ot(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,st(n.issues,t,e),n}}return i(n,a)}}let oi=e=>Array.isArray(e)?e.length:-1;function si(e,t,n){e.issues.length&&t.issues.push(...it(n,e.issues)),t.value[n]=e.value}let ci=/*@__PURE__*/ M(`$ZodArray`,(e,t)=>{N.init(e,t);let n=Mt.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>si(t,r,e)));else if(si(c,r,e),s&&c.issues.length!==0&&nt(c))break}return o.length?Promise.all(o).then(()=>r):r},ai(e,oi)});function li(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...it(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}let ui=[];function di(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:ui,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=We(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function fi(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(nt(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>li(e,n,i,t,d,f))):li(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}let pi=/*@__PURE__*/ M(`$ZodObject`,(e,t)=>{N.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=ve(()=>di(t));j(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||we(n,e,/* @__PURE__ */ new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=Fe,o=t.catchall,s,c=Mt.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(nt(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>li(n,t,e,r,a,o))):li(s,t,e,r,a,o)}return o?fi(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),mi=/*@__PURE__*/ M(`$ZodObjectJIT`,(e,t)=>{pi.init(e,t);let n=e._zod.parse,r=ve(()=>di(t)),i=Mt.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new cr([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
4
4
  let ${e}_ab = false;
5
5
  for (let i = 0; i < ${e}.issues.length; i++) {
6
6
  const iss = ${e}.issues[i];
@@ -11,7 +11,7 @@ window.__ModuleLoader__.load({id:`@deepseek-ai/dsh-client-ui-chat`,factory:e=>{v
11
11
  if (${e}_ab && ctx && ctx.abortEarly) {
12
12
  payload.value = newResult;
13
13
  return payload;
14
- }`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:De(e),i=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
14
+ }`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:Me(e),i=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
15
15
  const ${n}_present = ${i};
16
16
  if (!${n}.issues.length || ${n}_present) {
17
17
  if (${n}.issues.length) {${c(n,r)}
@@ -50,82 +50,82 @@ window.__ModuleLoader__.load({id:`@deepseek-ai/dsh-client-ui-chat`,factory:e=>{v
50
50
  newResult[${r}] = ${n}.value;
51
51
  }
52
52
 
53
- `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=Ae,c=!Et.jitless,l=c&&je.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?ai([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function ci(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Xe(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>nt(e,r,Dt())))}),t)}let li=/*@__PURE__*/ L(`$ZodUnion`,(e,t)=>{R.init(e,t),I(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),I(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),I(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),I(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>_e(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>ci(t,r,e,i)):ci(o,r,e,i)}});function ui(e){let t=/* @__PURE__ */ new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let e of r)if(t.has(e)){if(e!==void 0)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,n)}return t}let di=/*@__PURE__*/ L(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,li.init(e,t);let n=e._zod.parse;I(e,`propValues`,e=>{let t={},n=0;for(let r of e.def.options){let i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);i[e.def.discriminator]?.has(void 0)&&n++;for(let[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||xe(t,e,/* @__PURE__ */ new Set);for(let r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{let r=Se(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=he(()=>ui(t));e._zod.parse=(i,a)=>{let o=i.value;if(!Ae(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=o?.[t.discriminator],c=r.value.get(s);return c&&(s!==void 0||a.direction!==`backward`)?c._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(e=>r.value.get(e)!==null),input:o,path:[t.discriminator],inst:e}),i)}}),fi=/*@__PURE__*/ L(`$ZodIntersection`,(e,t)=>{R.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>mi(e,t,n)):mi(e,i,a)}});function pi(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Me(e)&&Me(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=pi(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=pi(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function mi(e,t,n){let r=/* @__PURE__ */ new Map,i,a=/* @__PURE__ */ new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=pi(t.value,n.value);if(!c.valid){if(Xe(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}let hi=/*@__PURE__*/ L(`$ZodTuple`,(e,t)=>{R.init(e,t);let n=t.items,r=Et.memoizer;r?.attach(e),e._zod.parse=(i,a)=>{let o=i.value;if(!Array.isArray(o))return i.issues.push({input:o,inst:e,expected:`tuple`,code:`invalid_type`}),i;i.value=r?r.alloc(e,i,[],a):[];let s=[],c=gi(n,`optin`),l=gi(n,`optout`);if(!t.rest){if(o.length<c)return i.issues.push({code:`too_small`,minimum:c,inclusive:!0,input:o,inst:e,origin:`array`}),i;o.length>n.length&&i.issues.push({code:`too_big`,maximum:n.length,inclusive:!0,input:o,inst:e,origin:`array`})}let u=Array(n.length),d=t.rest?a?.abortEarly:void 0,f=!1;for(let e=0;e<n.length;e++){let t=n[e]._zod.run({value:o[e],issues:[]},a);t instanceof Promise?s.push(t.then(t=>{u[e]=t})):(u[e]=t,d&&!f&&t.issues.length&&(f=Xe(t)))}if(t.rest&&!f){let e=n.length-1,r=o.slice(n.length),c=i.issues.length;for(let n of r){if(d&&i.issues.length!==c){if(Xe(i,c))break;c=i.issues.length}e++;let r=t.rest._zod.run({value:n,issues:[]},a);r instanceof Promise?s.push(r.then(t=>_i(t,i,e))):_i(r,i,e)}}return s.length?Promise.all(s).then(()=>vi(u,i,n,o,l)):vi(u,i,n,o,l)}});function gi(e,t){for(let n=e.length-1;n>=0;n--)if(!(t===`optin`?e[n]._zod.optin!==void 0:e[n]._zod.optout===`optional`))return n+1;return 0}function _i(e,t,n){e.issues.length&&t.issues.push(...Qe(n,e.issues)),t.value[n]=e.value}function vi(e,t,n,r,i){for(let a=0;a<n.length;a++){let o=e[a],s=a<r.length;if(!s&&a>=i&&n[a]._zod.optin===`optional`){t.value.length=a;break}if(o.issues.length){if(!s&&a>=i){t.value.length=a;break}t.issues.push(...Qe(a,o.issues))}t.value[a]=o.value}for(let e=t.value.length-1;e>=r.length&&n[e]._zod.optout===`optional`&&t.value[e]===void 0;e--)t.value.length=e;return t}let yi=/*@__PURE__*/ L(`$ZodRecord`,(e,t)=>{R.init(e,t);let n=Et.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Me(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=/* @__PURE__ */ new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>nt(e,i,Dt())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...Qe(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...Qe(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&Mn.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>nt(e,i,Dt())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...Qe(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...Qe(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),bi=/*@__PURE__*/ L(`$ZodEnum`,(e,t)=>{R.init(e,t);let n=de(t.entries),r=new Set(n);e._zod.values=r,I(e,`pattern`,e=>{let t=de(e.def.entries).filter(e=>Pe.has(typeof e));return RegExp(t.length?`^(${t.map(e=>Fe(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),xi=/*@__PURE__*/ L(`$ZodLiteral`,(e,t)=>{R.init(e,t);let n=new Set(t.values);e._zod.values=n,I(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?Fe(e):e?Fe(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Si=/*@__PURE__*/ L(`$ZodTransform`,(e,t)=>{R.init(e,t),e._zod.optin=`optional`,Et.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Tt(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new wt;return n.value=i,n}});function Ci(e,t){return e.value=t.issues.length?void 0:t.value,e}let wi=/*@__PURE__*/ L(`$ZodOptional`,(e,t)=>{R.init(e,t),I(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,I(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?/* @__PURE__ */ new Set([...t,void 0]):void 0}),I(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${_e(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>Ci(e,t)):Ci(e,r)}return t.innerType._zod.run(e,n)}}),Ti=/*@__PURE__*/ L(`$ZodExactOptional`,(e,t)=>{wi.init(e,t),I(e,`values`,e=>e.def.innerType._zod.values),I(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Ei=/*@__PURE__*/ L(`$ZodNullable`,(e,t)=>{R.init(e,t),I(e,`optin`,e=>e.def.innerType._zod.optin),I(e,`optout`,e=>e.def.innerType._zod.optout),I(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${_e(t.source)}|null)$`):void 0}),I(e,`values`,e=>e.def.innerType._zod.values?/* @__PURE__ */ new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Di=/*@__PURE__*/ L(`$ZodDefault`,(e,t)=>{R.init(e,t),e._zod.optin=`defaulted`,I(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Oi(e,t)):Oi(r,t)}});function Oi(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}let ki=/*@__PURE__*/ L(`$ZodPrefault`,(e,t)=>{R.init(e,t),e._zod.optin=`defaulted`,I(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Ai=/*@__PURE__*/ L(`$ZodNonOptional`,(e,t)=>{R.init(e,t),I(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>ji(t,e)):ji(i,e)}});function ji(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function Mi(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>nt(e,r,Dt()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}let Ni=/*@__PURE__*/ L(`$ZodCatch`,(e,t)=>{R.init(e,t),I(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),I(e,`optout`,e=>e.def.innerType._zod.optout),I(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>Mi(e,r,t,n)):Mi(e,r,t,n)}}),Pi=/*@__PURE__*/ L(`$ZodPipe`,(e,t)=>{R.init(e,t),I(e,`values`,e=>e.def.in._zod.values),I(e,`optin`,e=>e.def.in._zod.optin),I(e,`optout`,e=>e.def.out._zod.optout),I(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Fi(e,t.in,n)):Fi(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Fi(e,t.out,n)):Fi(r,t.out,n)}});function Fi(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}let Ii=/*@__PURE__*/ L(`$ZodReadonly`,(e,t)=>{R.init(e,t),I(e,`propValues`,e=>e.def.innerType._zod.propValues),I(e,`values`,e=>e.def.innerType._zod.values),I(e,`optin`,e=>e.def.innerType?._zod?.optin),I(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Li):Li(r)}});function Li(e){return e.memo||(e.value=Object.freeze(e.value)),e}let Ri=/*@__PURE__*/ L(`$ZodLazy`,(e,t)=>{R.init(e,t),be(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),I(e,`pattern`,e=>e.innerType?._zod?.pattern),I(e,`propValues`,e=>e.innerType?._zod?.propValues),I(e,`optin`,e=>e.innerType?._zod?.optin??void 0),I(e,`optout`,e=>e.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),zi=/*@__PURE__*/ L(`$ZodCustom`,(e,t)=>{Ln.init(e,t),R.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Bi(t,n,r,e));Bi(i,n,r,e)}});function Bi(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(st(e))}}var Vi=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}};let Hi=`~memo`,Ui=[];function Wi(e){return typeof e==`object`&&!!e}function Gi(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}let Ki=/*@__PURE__*/ new WeakMap;function qi(e,t,n){let r=Ki.get(e);if(r!==void 0)return r?2:0;if(t.has(e))return 2;t.add(e);let i=0,a=e=>{if(i!==2&&e?._zod){let r=qi(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=0;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?1:o.value?._zod?qi(o.value,t,n):0;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=Se(c);s(e?o(e,!0):1),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?qi(r,t,!1):1);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),Ji(e,i)}function Ji(e,t){return t!==1&&Ki.set(e,t===2),t}function Yi(e,t){let n=e.buckets.get(t);return n||(n=/* @__PURE__ */ new WeakMap,e.buckets.set(t,n)),n}let Xi,Zi=[],Qi={alloc(e,t,n){let r=Xi;if(!r)return n;Xi=void 0;let i={value:n,issues:null};return r.set(t.value,i),Zi.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&ea(n,e.value))throw new Vi;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=qi(e,/* @__PURE__ */ new Set,!1);if(i===0)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===2||r?n=!0:r=!0}let l=s.value;if(!Wi(l))return t(s,c);let u=c[Hi];u||(u={buckets:/* @__PURE__ */ new WeakMap,backEdges:void 0},c[Hi]=u);let d;i===c?d=a:(d=Yi(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...Gi(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=/* @__PURE__ */ new WeakSet),u.backEdges.add(f.value)),s;Xi=d;let p=Zi.length,m=t(s,c);Xi=void 0;let h=Zi.length>p?Zi.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?Gi(e.issues):Ui),e)):(h&&(h.issues=m.issues.length?Gi(m.issues):Ui),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function $i(){return Qi}function ea(e,t){let n=e[Hi]?.backEdges;return n!==void 0&&Wi(t)&&n.has(t)}let ta=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(ot(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${Le(e.values[0])}`:`Invalid option: expected one of ${fe(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${fe(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function na(){return{localeError:ta()}}var ra,ia=class{constructor(){this._map=/* @__PURE__ */ new WeakMap,this._idmap=/* @__PURE__ */ new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=/* @__PURE__ */ new WeakMap,this._idmap=/* @__PURE__ */ new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function aa(){return new ia}(ra=globalThis).__zod_globalRegistry??(ra.__zod_globalRegistry=aa());let oa=globalThis.__zod_globalRegistry;function sa(e){return e.checks&&=[...e.checks],e}// @__NO_SIDE_EFFECTS__
54
- function ca(e,t){return new e(sa({type:`string`,...F(t)}))}// @__NO_SIDE_EFFECTS__
55
- function la(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...F(t)})}// @__NO_SIDE_EFFECTS__
56
- function ua(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...F(t)})}// @__NO_SIDE_EFFECTS__
57
- function da(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...F(t)})}// @__NO_SIDE_EFFECTS__
58
- function fa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...F(t)})}// @__NO_SIDE_EFFECTS__
59
- function pa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...F(t)})}// @__NO_SIDE_EFFECTS__
60
- function ma(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...F(t)})}// @__NO_SIDE_EFFECTS__
61
- function ha(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...F(t)})}// @__NO_SIDE_EFFECTS__
62
- function ga(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...F(t)})}// @__NO_SIDE_EFFECTS__
63
- function _a(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...F(t)})}// @__NO_SIDE_EFFECTS__
64
- function va(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...F(t)})}// @__NO_SIDE_EFFECTS__
65
- function ya(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...F(t)})}// @__NO_SIDE_EFFECTS__
66
- function ba(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...F(t)})}// @__NO_SIDE_EFFECTS__
67
- function xa(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...F(t)})}// @__NO_SIDE_EFFECTS__
68
- function Sa(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...F(t)})}// @__NO_SIDE_EFFECTS__
69
- function Ca(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...F(t)})}// @__NO_SIDE_EFFECTS__
70
- function wa(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...F(t)})}// @__NO_SIDE_EFFECTS__
71
- function Ta(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...F(t)})}// @__NO_SIDE_EFFECTS__
72
- function Ea(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...F(t)})}// @__NO_SIDE_EFFECTS__
73
- function Da(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...F(t)})}// @__NO_SIDE_EFFECTS__
74
- function Oa(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...F(t)})}// @__NO_SIDE_EFFECTS__
75
- function ka(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...F(t)})}// @__NO_SIDE_EFFECTS__
76
- function Aa(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...F(t)})}// @__NO_SIDE_EFFECTS__
77
- function ja(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...F(t)})}// @__NO_SIDE_EFFECTS__
78
- function Ma(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...F(t)})}// @__NO_SIDE_EFFECTS__
79
- function Na(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...F(t)})}// @__NO_SIDE_EFFECTS__
80
- function Pa(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...F(t)})}// @__NO_SIDE_EFFECTS__
81
- function Fa(e,t){return new e(sa({type:`number`,checks:[],...F(t)}))}// @__NO_SIDE_EFFECTS__
82
- function Ia(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...F(t)})}// @__NO_SIDE_EFFECTS__
83
- function La(e,t){return new e({type:`boolean`,...F(t)})}// @__NO_SIDE_EFFECTS__
84
- function Ra(e,t){return new e({type:`null`,...F(t)})}// @__NO_SIDE_EFFECTS__
85
- function za(e){return new e({type:`unknown`})}// @__NO_SIDE_EFFECTS__
86
- function Ba(e,t){return new e({type:`never`,...F(t)})}// @__NO_SIDE_EFFECTS__
87
- function Va(e,t){return new Bn({check:`less_than`,...F(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
88
- function Ha(e,t){return new Bn({check:`less_than`,...F(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
89
- function Ua(e,t){return new Vn({check:`greater_than`,...F(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
90
- function Wa(e,t){return new Vn({check:`greater_than`,...F(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
91
- function Ga(e,t){return new Hn({check:`multiple_of`,...F(t),value:e})}// @__NO_SIDE_EFFECTS__
92
- function Ka(e,t){return new Wn({check:`max_length`,...F(t),maximum:e})}// @__NO_SIDE_EFFECTS__
93
- function qa(e,t){return new Gn({check:`min_length`,...F(t),minimum:e})}// @__NO_SIDE_EFFECTS__
94
- function Ja(e,t){return new Kn({check:`length_equals`,...F(t),length:e})}// @__NO_SIDE_EFFECTS__
95
- function Ya(e,t){return new Jn({check:`string_format`,format:`regex`,...F(t),pattern:e})}// @__NO_SIDE_EFFECTS__
96
- function Xa(e){return new Yn({check:`string_format`,format:`lowercase`,...F(e)})}// @__NO_SIDE_EFFECTS__
97
- function Za(e){return new Xn({check:`string_format`,format:`uppercase`,...F(e)})}// @__NO_SIDE_EFFECTS__
98
- function Qa(e,t){return new Zn({check:`string_format`,format:`includes`,...F(t),includes:e})}// @__NO_SIDE_EFFECTS__
99
- function $a(e,t){return new Qn({check:`string_format`,format:`starts_with`,...F(t),prefix:e})}// @__NO_SIDE_EFFECTS__
100
- function eo(e,t){return new $n({check:`string_format`,format:`ends_with`,...F(t),suffix:e})}// @__NO_SIDE_EFFECTS__
101
- function to(e){return new er({check:`overwrite`,tx:e})}// @__NO_SIDE_EFFECTS__
102
- function no(e){return/* @__PURE__ */ to(t=>t.normalize(e))}// @__NO_SIDE_EFFECTS__
103
- function ro(){return/* @__PURE__ */ to(e=>e.trim())}// @__NO_SIDE_EFFECTS__
104
- function io(){return/* @__PURE__ */ to(e=>e.toLowerCase())}// @__NO_SIDE_EFFECTS__
105
- function ao(){return/* @__PURE__ */ to(e=>e.toUpperCase())}// @__NO_SIDE_EFFECTS__
106
- function oo(){return/* @__PURE__ */ to(e=>Oe(e))}// @__NO_SIDE_EFFECTS__
107
- function so(e,t,n){return new e({type:`array`,element:t,...F(n)})}// @__NO_SIDE_EFFECTS__
108
- function co(e,t,n){let r=F(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}// @__NO_SIDE_EFFECTS__
109
- function lo(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...F(n)})}// @__NO_SIDE_EFFECTS__
110
- function uo(e,t){let n=/* @__PURE__ */ fo(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(st(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(st(r))}},e(t.value,t)),t);return n}// @__NO_SIDE_EFFECTS__
111
- function fo(e,t){let n=new Ln({check:`custom`,...F(t)});return n._zod.check=e,n}function po(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&xe(e,t,n[t]);return e}function mo(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??oa,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:/* @__PURE__ */ new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function ho(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function go(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,go(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&po(o.schema,c),t.io===`input`&&Eo(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function _o(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function vo(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=/* @__PURE__ */ new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${_o(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+_o(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
53
+ `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=Fe,c=!Mt.jitless,l=c&&Ie.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?fi([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function hi(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!nt(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>ct(e,r,Nt())))}),t)}let gi=/*@__PURE__*/ M(`$ZodUnion`,(e,t)=>{N.init(e,t),j(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),j(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),j(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),j(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>be(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>hi(t,r,e,i)):hi(o,r,e,i)}});function _i(e){let t=/* @__PURE__ */ new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let e of r)if(t.has(e)){if(e!==void 0)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,n)}return t}let vi=/*@__PURE__*/ M(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,gi.init(e,t);let n=e._zod.parse;j(e,`propValues`,e=>{let t={},n=0;for(let r of e.def.options){let i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);i[e.def.discriminator]?.has(void 0)&&n++;for(let[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||we(t,e,/* @__PURE__ */ new Set);for(let r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{let r=Te(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=ve(()=>_i(t));e._zod.parse=(i,a)=>{let o=i.value;if(!Fe(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=o?.[t.discriminator],c=r.value.get(s);return c&&(s!==void 0||a.direction!==`backward`)?c._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(e=>r.value.get(e)!==null),input:o,path:[t.discriminator],inst:e}),i)}}),yi=/*@__PURE__*/ M(`$ZodIntersection`,(e,t)=>{N.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>xi(e,t,n)):xi(e,i,a)}});function bi(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Le(e)&&Le(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=bi(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=bi(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function xi(e,t,n){let r=/* @__PURE__ */ new Map,i,a=/* @__PURE__ */ new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=bi(t.value,n.value);if(!c.valid){if(nt(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}let Si=/*@__PURE__*/ M(`$ZodTuple`,(e,t)=>{N.init(e,t);let n=t.items,r=Mt.memoizer;r?.attach(e),e._zod.parse=(i,a)=>{let o=i.value;if(!Array.isArray(o))return i.issues.push({input:o,inst:e,expected:`tuple`,code:`invalid_type`}),i;i.value=r?r.alloc(e,i,[],a):[];let s=[],c=Ci(n,`optin`),l=Ci(n,`optout`);if(!t.rest){if(o.length<c)return i.issues.push({code:`too_small`,minimum:c,inclusive:!0,input:o,inst:e,origin:`array`}),i;o.length>n.length&&i.issues.push({code:`too_big`,maximum:n.length,inclusive:!0,input:o,inst:e,origin:`array`})}let u=Array(n.length),d=t.rest?a?.abortEarly:void 0,f=!1;for(let e=0;e<n.length;e++){let t=n[e]._zod.run({value:o[e],issues:[]},a);t instanceof Promise?s.push(t.then(t=>{u[e]=t})):(u[e]=t,d&&!f&&t.issues.length&&(f=nt(t)))}if(t.rest&&!f){let e=n.length-1,r=o.slice(n.length),c=i.issues.length;for(let n of r){if(d&&i.issues.length!==c){if(nt(i,c))break;c=i.issues.length}e++;let r=t.rest._zod.run({value:n,issues:[]},a);r instanceof Promise?s.push(r.then(t=>wi(t,i,e))):wi(r,i,e)}}return s.length?Promise.all(s).then(()=>Ti(u,i,n,o,l)):Ti(u,i,n,o,l)}});function Ci(e,t){for(let n=e.length-1;n>=0;n--)if(!(t===`optin`?e[n]._zod.optin!==void 0:e[n]._zod.optout===`optional`))return n+1;return 0}function wi(e,t,n){e.issues.length&&t.issues.push(...it(n,e.issues)),t.value[n]=e.value}function Ti(e,t,n,r,i){for(let a=0;a<n.length;a++){let o=e[a],s=a<r.length;if(!s&&a>=i&&n[a]._zod.optin===`optional`){t.value.length=a;break}if(o.issues.length){if(!s&&a>=i){t.value.length=a;break}t.issues.push(...it(a,o.issues))}t.value[a]=o.value}for(let e=t.value.length-1;e>=r.length&&n[e]._zod.optout===`optional`&&t.value[e]===void 0;e--)t.value.length=e;return t}let Ei=/*@__PURE__*/ M(`$ZodRecord`,(e,t)=>{N.init(e,t);let n=Mt.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Le(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=/* @__PURE__ */ new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>ct(e,i,Nt())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...it(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...it(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&zn.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>ct(e,i,Nt())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...it(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...it(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),Di=/*@__PURE__*/ M(`$ZodEnum`,(e,t)=>{N.init(e,t);let n=me(t.entries),r=new Set(n);e._zod.values=r,j(e,`pattern`,e=>{let t=me(e.def.entries).filter(e=>ze.has(typeof e));return RegExp(t.length?`^(${t.map(e=>Ve(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Oi=/*@__PURE__*/ M(`$ZodLiteral`,(e,t)=>{N.init(e,t);let n=new Set(t.values);e._zod.values=n,j(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?Ve(e):e?Ve(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),ki=/*@__PURE__*/ M(`$ZodTransform`,(e,t)=>{N.init(e,t),e._zod.optin=`optional`,Mt.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new jt(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new At;return n.value=i,n}});function Ai(e,t){return e.value=t.issues.length?void 0:t.value,e}let ji=/*@__PURE__*/ M(`$ZodOptional`,(e,t)=>{N.init(e,t),j(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,j(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?/* @__PURE__ */ new Set([...t,void 0]):void 0}),j(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${be(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>Ai(e,t)):Ai(e,r)}return t.innerType._zod.run(e,n)}}),Mi=/*@__PURE__*/ M(`$ZodExactOptional`,(e,t)=>{ji.init(e,t),j(e,`values`,e=>e.def.innerType._zod.values),j(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Ni=/*@__PURE__*/ M(`$ZodNullable`,(e,t)=>{N.init(e,t),j(e,`optin`,e=>e.def.innerType._zod.optin),j(e,`optout`,e=>e.def.innerType._zod.optout),j(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${be(t.source)}|null)$`):void 0}),j(e,`values`,e=>e.def.innerType._zod.values?/* @__PURE__ */ new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Pi=/*@__PURE__*/ M(`$ZodDefault`,(e,t)=>{N.init(e,t),e._zod.optin=`defaulted`,j(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Fi(e,t)):Fi(r,t)}});function Fi(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}let Ii=/*@__PURE__*/ M(`$ZodPrefault`,(e,t)=>{N.init(e,t),e._zod.optin=`defaulted`,j(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Li=/*@__PURE__*/ M(`$ZodNonOptional`,(e,t)=>{N.init(e,t),j(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Ri(t,e)):Ri(i,e)}});function Ri(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function zi(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>ct(e,r,Nt()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}let Bi=/*@__PURE__*/ M(`$ZodCatch`,(e,t)=>{N.init(e,t),j(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),j(e,`optout`,e=>e.def.innerType._zod.optout),j(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>zi(e,r,t,n)):zi(e,r,t,n)}}),Vi=/*@__PURE__*/ M(`$ZodPipe`,(e,t)=>{N.init(e,t),j(e,`values`,e=>e.def.in._zod.values),j(e,`optin`,e=>e.def.in._zod.optin),j(e,`optout`,e=>e.def.out._zod.optout),j(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Hi(e,t.in,n)):Hi(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Hi(e,t.out,n)):Hi(r,t.out,n)}});function Hi(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}let Ui=/*@__PURE__*/ M(`$ZodReadonly`,(e,t)=>{N.init(e,t),j(e,`propValues`,e=>e.def.innerType._zod.propValues),j(e,`values`,e=>e.def.innerType._zod.values),j(e,`optin`,e=>e.def.innerType?._zod?.optin),j(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Wi):Wi(r)}});function Wi(e){return e.memo||(e.value=Object.freeze(e.value)),e}function Gi(e){let t=e._zod.def,n=t.pattern,r=!!t.format?.includes(`int`),i,a;for(let e of t.checks??[]){let t=e._zod.def;t.pattern&&(n=t.pattern),r||=!!t.format?.includes(`int`);let o=t.minimum??t.length,s=t.maximum??t.length;o!==void 0&&(i===void 0||o>i)&&(i=o),s!==void 0&&(a===void 0||s<a)&&(a=s)}if(n)return n.source;if(i!==void 0&&a!==void 0&&i>a)return`(?!)`;if(i!==void 0||a!==void 0)return Ln({minimum:i,maximum:a}).source;let o=e._zod.pattern;return(r&&o===zn?Rn:o)?.source}function Ki(e){let t=e._zod.def,n=e._zod.pattern?.source,r=t.innerType??e._zod.innerType;if(r){let e=r._zod.pattern?.source,t=Ki(r);return n&&e&&t&&t!==e?n.replace(be(e),()=>be(t)):n}if(t.options){let e=t.options.map(Ki);if(e.every(Boolean))return`^(${e.map(e=>be(e)).join(`|`)})$`}return Gi(e)}let qi=/*@__PURE__*/ M(`$ZodTemplateLiteral`,(e,t)=>{N.init(e,t);let n=[];for(let e of t.parts)if(typeof e==`object`&&e){let t=Ki(e);if(!t)throw Error(`Invalid template literal part, no pattern found: ${[...e._zod.traits].shift()}`);n.push(be(t))}else if(e===null||Be.has(typeof e))n.push(Ve(`${e}`));else throw Error(`Invalid template literal part: ${e}`);e._zod.pattern=RegExp(`^${n.join(``)}$`),e._zod.parse=(n,r)=>typeof n.value==`string`?(e._zod.pattern.lastIndex=0,e._zod.pattern.test(n.value)||n.issues.push({input:n.value,inst:e,code:`invalid_format`,format:t.format??`template_literal`,pattern:e._zod.pattern.source}),n):(n.issues.push({input:n.value,inst:e,expected:`string`,code:`invalid_type`}),n)}),Ji=/*@__PURE__*/ M(`$ZodLazy`,(e,t)=>{N.init(e,t),Ce(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),j(e,`pattern`,e=>e.innerType?._zod?.pattern),j(e,`propValues`,e=>e.innerType?._zod?.propValues),j(e,`optin`,e=>e.innerType?._zod?.optin??void 0),j(e,`optout`,e=>e.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),Yi=/*@__PURE__*/ M(`$ZodCustom`,(e,t)=>{Wn.init(e,t),N.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Xi(t,n,r,e));Xi(i,n,r,e)}});function Xi(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(pt(e))}}var Zi=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}};let Qi=`~memo`,$i=[];function ea(e){return typeof e==`object`&&!!e}function ta(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}let na=/*@__PURE__*/ new WeakMap;function ra(e,t,n){let r=na.get(e);if(r!==void 0)return r?2:0;if(t.has(e))return 2;t.add(e);let i=0,a=e=>{if(i!==2&&e?._zod){let r=ra(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=0;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?1:o.value?._zod?ra(o.value,t,n):0;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=Te(c);s(e?o(e,!0):1),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?ra(r,t,!1):1);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),ia(e,i)}function ia(e,t){return t!==1&&na.set(e,t===2),t}function aa(e,t){let n=e.buckets.get(t);return n||(n=/* @__PURE__ */ new WeakMap,e.buckets.set(t,n)),n}let oa,sa=[],ca={alloc(e,t,n){let r=oa;if(!r)return n;oa=void 0;let i={value:n,issues:null};return r.set(t.value,i),sa.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&ua(n,e.value))throw new Zi;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=ra(e,/* @__PURE__ */ new Set,!1);if(i===0)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===2||r?n=!0:r=!0}let l=s.value;if(!ea(l))return t(s,c);let u=c[Qi];u||(u={buckets:/* @__PURE__ */ new WeakMap,backEdges:void 0},c[Qi]=u);let d;i===c?d=a:(d=aa(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...ta(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=/* @__PURE__ */ new WeakSet),u.backEdges.add(f.value)),s;oa=d;let p=sa.length,m=t(s,c);oa=void 0;let h=sa.length>p?sa.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?ta(e.issues):$i),e)):(h&&(h.issues=m.issues.length?ta(m.issues):$i),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function la(){return ca}function ua(e,t){let n=e[Qi]?.backEdges;return n!==void 0&&ea(t)&&n.has(t)}let da=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(ft(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${Ue(e.values[0])}`:`Invalid option: expected one of ${he(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${he(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function fa(){return{localeError:da()}}var pa,ma=class{constructor(){this._map=/* @__PURE__ */ new WeakMap,this._idmap=/* @__PURE__ */ new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=/* @__PURE__ */ new WeakMap,this._idmap=/* @__PURE__ */ new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function ha(){return new ma}(pa=globalThis).__zod_globalRegistry??(pa.__zod_globalRegistry=ha());let ga=globalThis.__zod_globalRegistry;function _a(e){return e.checks&&=[...e.checks],e}// @__NO_SIDE_EFFECTS__
54
+ function va(e,t){return new e(_a({type:`string`,...A(t)}))}// @__NO_SIDE_EFFECTS__
55
+ function ya(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...A(t)})}// @__NO_SIDE_EFFECTS__
56
+ function ba(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...A(t)})}// @__NO_SIDE_EFFECTS__
57
+ function xa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...A(t)})}// @__NO_SIDE_EFFECTS__
58
+ function Sa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...A(t)})}// @__NO_SIDE_EFFECTS__
59
+ function Ca(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...A(t)})}// @__NO_SIDE_EFFECTS__
60
+ function wa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...A(t)})}// @__NO_SIDE_EFFECTS__
61
+ function Ta(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...A(t)})}// @__NO_SIDE_EFFECTS__
62
+ function Ea(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...A(t)})}// @__NO_SIDE_EFFECTS__
63
+ function Da(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...A(t)})}// @__NO_SIDE_EFFECTS__
64
+ function Oa(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...A(t)})}// @__NO_SIDE_EFFECTS__
65
+ function ka(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...A(t)})}// @__NO_SIDE_EFFECTS__
66
+ function Aa(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...A(t)})}// @__NO_SIDE_EFFECTS__
67
+ function ja(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...A(t)})}// @__NO_SIDE_EFFECTS__
68
+ function Ma(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...A(t)})}// @__NO_SIDE_EFFECTS__
69
+ function Na(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...A(t)})}// @__NO_SIDE_EFFECTS__
70
+ function Pa(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...A(t)})}// @__NO_SIDE_EFFECTS__
71
+ function Fa(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...A(t)})}// @__NO_SIDE_EFFECTS__
72
+ function Ia(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...A(t)})}// @__NO_SIDE_EFFECTS__
73
+ function La(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...A(t)})}// @__NO_SIDE_EFFECTS__
74
+ function Ra(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...A(t)})}// @__NO_SIDE_EFFECTS__
75
+ function za(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...A(t)})}// @__NO_SIDE_EFFECTS__
76
+ function Ba(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...A(t)})}// @__NO_SIDE_EFFECTS__
77
+ function Va(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...A(t)})}// @__NO_SIDE_EFFECTS__
78
+ function Ha(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...A(t)})}// @__NO_SIDE_EFFECTS__
79
+ function Ua(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...A(t)})}// @__NO_SIDE_EFFECTS__
80
+ function Wa(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...A(t)})}// @__NO_SIDE_EFFECTS__
81
+ function Ga(e,t){return new e(_a({type:`number`,checks:[],...A(t)}))}// @__NO_SIDE_EFFECTS__
82
+ function Ka(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...A(t)})}// @__NO_SIDE_EFFECTS__
83
+ function qa(e,t){return new e({type:`boolean`,...A(t)})}// @__NO_SIDE_EFFECTS__
84
+ function Ja(e,t){return new e({type:`null`,...A(t)})}// @__NO_SIDE_EFFECTS__
85
+ function Ya(e){return new e({type:`unknown`})}// @__NO_SIDE_EFFECTS__
86
+ function Xa(e,t){return new e({type:`never`,...A(t)})}// @__NO_SIDE_EFFECTS__
87
+ function Za(e,t){return new qn({check:`less_than`,...A(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
88
+ function Qa(e,t){return new qn({check:`less_than`,...A(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
89
+ function $a(e,t){return new Jn({check:`greater_than`,...A(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
90
+ function eo(e,t){return new Jn({check:`greater_than`,...A(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
91
+ function to(e,t){return new Yn({check:`multiple_of`,...A(t),value:e})}// @__NO_SIDE_EFFECTS__
92
+ function no(e,t){return new Zn({check:`max_length`,...A(t),maximum:e})}// @__NO_SIDE_EFFECTS__
93
+ function ro(e,t){return new Qn({check:`min_length`,...A(t),minimum:e})}// @__NO_SIDE_EFFECTS__
94
+ function io(e,t){return new $n({check:`length_equals`,...A(t),length:e})}// @__NO_SIDE_EFFECTS__
95
+ function ao(e,t){return new tr({check:`string_format`,format:`regex`,...A(t),pattern:e})}// @__NO_SIDE_EFFECTS__
96
+ function oo(e){return new nr({check:`string_format`,format:`lowercase`,...A(e)})}// @__NO_SIDE_EFFECTS__
97
+ function so(e){return new rr({check:`string_format`,format:`uppercase`,...A(e)})}// @__NO_SIDE_EFFECTS__
98
+ function co(e,t){return new ir({check:`string_format`,format:`includes`,...A(t),includes:e})}// @__NO_SIDE_EFFECTS__
99
+ function lo(e,t){return new ar({check:`string_format`,format:`starts_with`,...A(t),prefix:e})}// @__NO_SIDE_EFFECTS__
100
+ function uo(e,t){return new or({check:`string_format`,format:`ends_with`,...A(t),suffix:e})}// @__NO_SIDE_EFFECTS__
101
+ function fo(e){return new sr({check:`overwrite`,tx:e})}// @__NO_SIDE_EFFECTS__
102
+ function po(e){return/* @__PURE__ */ fo(t=>t.normalize(e))}// @__NO_SIDE_EFFECTS__
103
+ function mo(){return/* @__PURE__ */ fo(e=>e.trim())}// @__NO_SIDE_EFFECTS__
104
+ function ho(){return/* @__PURE__ */ fo(e=>e.toLowerCase())}// @__NO_SIDE_EFFECTS__
105
+ function go(){return/* @__PURE__ */ fo(e=>e.toUpperCase())}// @__NO_SIDE_EFFECTS__
106
+ function _o(){return/* @__PURE__ */ fo(e=>Ne(e))}// @__NO_SIDE_EFFECTS__
107
+ function vo(e,t,n){return new e({type:`array`,element:t,...A(n)})}// @__NO_SIDE_EFFECTS__
108
+ function yo(e,t,n){let r=A(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}// @__NO_SIDE_EFFECTS__
109
+ function bo(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...A(n)})}// @__NO_SIDE_EFFECTS__
110
+ function xo(e,t){let n=/* @__PURE__ */ So(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(pt(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(pt(r))}},e(t.value,t)),t);return n}// @__NO_SIDE_EFFECTS__
111
+ function So(e,t){let n=new Wn({check:`custom`,...A(t)});return n._zod.check=e,n}function Co(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&we(e,t,n[t]);return e}function wo(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??ga,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:/* @__PURE__ */ new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function To(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function Eo(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,Eo(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Co(o.schema,c),t.io===`input`&&Io(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Do(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Oo(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=/* @__PURE__ */ new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${Do(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+Do(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
112
112
 
113
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function yo(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;yo(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}let bo=/* @__PURE__ */ new Set([`type`,`properties`,`required`,`additionalProperties`]),xo=[`oneOf`,`anyOf`];function So(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Co(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!bo.has(e))return null;t.push(n)}let n={},r=/* @__PURE__ */ new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??So(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}xe(n,r,e.length===1?e[0]:Co(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=So(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function wo(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of bo)if(t in e)return;let n=t.filter(e=>xo.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Co(t);else{let e=n[0],i=xo.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Co([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,po(e,r))}function To(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):po(i,s),po(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())yo(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=/* @__PURE__ */ new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])wo(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}po(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,xe(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Oo(t,`input`,e.processors),output:Oo(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Eo(e,t){let n=t??{seen:/* @__PURE__ */ new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Eo(r.element,n);if(r.type===`set`)return Eo(r.valueType,n);if(r.type===`lazy`)return Eo(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return Eo(r.innerType,n);if(r.type===`intersection`)return Eo(r.left,n)||Eo(r.right,n);if(r.type===`record`||r.type===`map`)return Eo(r.keyType,n)||Eo(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Eo(r.in,n)||Eo(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Eo(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Eo(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Eo(e,n))return!0;return!!(r.rest&&Eo(r.rest,n))}return!1}let Do=(e,t={})=>n=>{let r=mo({...n,processors:t});return go(e,r),vo(r,e),To(r,e)},Oo=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=mo({...i??{},target:a,io:t,processors:n});return go(e,o),vo(o,e),To(o,e)},ko=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Ao=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},jo=(e,t)=>{ko(e,`minimum`,t),Ao(e,`maximum`,t)},Mo=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},No=(e,t)=>{e.patterns??=/* @__PURE__ */ new Set,e.patterns.add(t)},Po=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Fo=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Io=(e,t)=>ko(e,`minimum`,t.minimum),Lo=(e,t)=>Ao(e,`maximum`,t.maximum),Ro=e=>(t,n)=>{Fo(t,n.format);let[r,i]=e[n.format];ko(t,`minimum`,r),Ao(t,`maximum`,i)},zo={greater_than:(e,t)=>ko(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Ao(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Mo(e,t.value),number_format:Ro(ze),bigint_format:Ro(Be),min_length:Io,max_length:Lo,length_equals:(e,t)=>jo(e,t.length),min_size:Io,max_size:Lo,size_equals:(e,t)=>jo(e,t.size),string_format:(e,t)=>{Fo(e,t.format),t.pattern&&No(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Po(e,t.mime)};function Bo(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)zo[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&ko(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&ko(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Ao(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Ao(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Mo(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Po(t,i.mime);for(let e of i.patterns??[])No(t,e);return t}let Vo={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Ho=/* @__PURE__ */ new Map([[Rr,bn],[Br,xn]]),Uo=e=>Ho.get(e)??e,Wo=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=Bo(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Vo[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(Uo);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Go=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Bo(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=/* @__PURE__ */ new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):ho(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},Ko=(e,t,n,r)=>{n.type=`boolean`},qo=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},Jo=(e,t,n,r)=>{n.not={}},Yo=(e,t,n,r)=>{let i=e._zod.def,a=de(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},Xo=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(ho(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(ho(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},Zo=(e,t,n,r)=>{ho(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},Qo=(e,t,n,r)=>{ho(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},$o=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=Bo(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=go(a.element,t,{...r,path:[...r.path,`items`]})};function es(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?es(t.out):t.type===`catch`?es(t.innerType):e._zod.optin}let ts=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&ho(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)xe(i.properties,e,go(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?es(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=go(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},ns=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>go(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},rs=(e,t,n,r)=>{let i=e._zod.def,a=go(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=go(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},is=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>go(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?go(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null,u=a.items.length;for(;u>0;){let e=a.items[u-1];if(!(t.io===`input`?es(e)!==void 0:e._zod.optout===`optional`))break;u--}let d=a.items.length,f=!a.rest;t.target===`draft-2020-12`?(i.prefixItems=c,f?i.items=!1:l&&(i.items=l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):(i.items=c,f?i.additionalItems=!1:l&&(i.additionalItems=l),u>0&&(i.minItems=u),f&&(i.maxItems=d));let{minimum:p,maximum:m}=Bo(e);typeof p==`number`&&(i.minItems=p),typeof m==`number`&&(i.maxItems=m)};function as(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=as(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>as(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i&&(p.type=`string`,a||(p.pattern=(r.includes(`number`)?Mn:jn).source)),p}let os=/* @__PURE__ */ new WeakMap;function ss(e){let t=/* @__PURE__ */ new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=/* @__PURE__ */ new Map;for(let r of os.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=as(t,a,/* @__PURE__ */ new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}let cs=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=Bo(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=go(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)xe(i.patternProperties,Uo(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=go(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=os.get(t);n||(n=[],os.set(t,n),t.deferred.push(()=>ss(t))),n.push(e)}i.additionalProperties=go(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&es(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},ls=(e,t,n,r)=>{let i=e._zod.def,a=go(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},us=(e,t,n,r)=>{let i=e._zod.def;go(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ds=Symbol();function fs(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(ho(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),ds):JSON.parse(o)}let ps=(e,t,n,r)=>{let i=e._zod.def;go(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=fs(i.defaultValue,e,t,n,r);o!==ds&&(n.default=o)},ms=(e,t,n,r)=>{let i=e._zod.def;go(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=fs(i.defaultValue,e,t,n,r);o!==ds&&(n._prefault=o)},hs=(e,t,n,r)=>{let i=e._zod.def;go(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{ho(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},gs=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;go(o,t,r);let s=t.seen.get(e);s.ref=o},_s=(e,t,n,r)=>{let i=e._zod.def;go(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},vs=(e,t,n,r)=>{let i=e._zod.def;go(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ys=(e,t,n,r)=>{let i=e._zod.innerType;go(i,t,r);let a=t.seen.get(e);a.ref=i},bs=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]);function xs(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}let Ss=/*@__PURE__*/ L(`ZodError`,(e,t)=>{Pt.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);bs.has(n)||(bs.add(n),xs(n,`format`,e=>t=>Lt(e,t)),xs(n,`flatten`,e=>t=>It(e,t)),xs(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,pe,2)}),xs(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,pe,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Cs=/* @__PURE__ */ zt(Ss),ws=/* @__PURE__ */ Bt(Ss),Ts=/* @__PURE__ */ Vt(Ss),Es=/* @__PURE__ */ Ut(Ss),Ds=/* @__PURE__ */ Yt(Ss),Os=/* @__PURE__ */ Xt(Ss),ks=/* @__PURE__ */ Zt(Ss),As=/* @__PURE__ */ Qt(Ss),js=/* @__PURE__ */ $t(Ss),Ms=/* @__PURE__ */ en(Ss),Ns=/* @__PURE__ */ tn(Ss),Ps=/* @__PURE__ */ nn(Ss);function Fs(){Et.localeError||Dt(na())}function Is(){Et.memoizer||Dt({memoizer:$i()})}let Ls=/*@__PURE__*/ L(`ZodType`,(e,t)=>(Fs(),R.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Ee(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Ie(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(ol(e,t))},superRefine(e,t){return this.check(sl(e,t))},overwrite(e){return this.check(/* @__PURE__ */ to(e))},optional(){return zc(this)},exactOptional(){return Vc(this)},nullable(){return Uc(this)},nullish(){return zc(Uc(this))},nonoptional(e){return Yc(this,e)},array(){return H(this)},or(e){return Tc([this,e])},and(e){return kc(this,e)},transform(e){return $c(this,Lc(e))},default(e){return Gc(this,e)},prefault(e){return qc(this,e)},catch(e){return Zc(this,e)},pipe(e){return $c(this,e)},readonly(){return tl(this)},describe(e){let t=this.clone();return oa.add(t,{description:e}),t},meta(...e){if(e.length===0)return oa.get(this);let t=this.clone();return oa.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return ut(this,`~standard`,{...ar(this),jsonSchema:{input:Oo(this,`input`),output:Oo(this,`output`)}})},set"~standard"(e){lt(this,`~standard`,e)},parse:function e(t,n){return Cs(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await ws(this,t,n,{callee:e})},safeParse(e,t){return Ts(this,e,t)},async safeParseAsync(e,t){return Es(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){lt(this,`spa`,e)},validate(e,t){return Kt(this,e,t)},validateAsync(e,t){return Jt(this,e,t)},encode:function e(t,n){return Ds(this,t,n,{callee:e})},decode:function e(t,n){return Os(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await ks(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await As(this,t,n,{callee:e})},safeEncode(e,t){return js(this,e,t)},safeDecode(e,t){return Ms(this,e,t)},async safeEncodeAsync(e,t){return Ns(this,e,t)},async safeDecodeAsync(e,t){return Ps(this,e,t)},toJSONSchema(e){return Do(this,{})(e)},get description(){return oa.get(this)?.description},get _def(){return this._zod.def}}),Rs=/*@__PURE__*/ L(`_ZodString`,(e,t)=>{or.init(e,t),Ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wo(e,t,n,r)},/*@__PURE__*/ dt({format:e=>Bo(e).format??null,minLength:e=>Bo(e).minimum??null,maxLength:e=>Bo(e).maximum??null},{regex(...e){return this.check(/* @__PURE__ */ Ya(...e))},includes(...e){return this.check(/* @__PURE__ */ Qa(...e))},startsWith(...e){return this.check(/* @__PURE__ */ $a(...e))},endsWith(...e){return this.check(/* @__PURE__ */ eo(...e))},min(...e){return this.check(/* @__PURE__ */ qa(...e))},max(...e){return this.check(/* @__PURE__ */ Ka(...e))},length(...e){return this.check(/* @__PURE__ */ Ja(...e))},nonempty(...e){return this.check(/* @__PURE__ */ qa(1,...e))},lowercase(e){return this.check(/* @__PURE__ */ Xa(e))},uppercase(e){return this.check(/* @__PURE__ */ Za(e))},trim(){return this.check(/* @__PURE__ */ ro())},normalize(...e){return this.check(/* @__PURE__ */ no(...e))},toLowerCase(){return this.check(/* @__PURE__ */ io())},toUpperCase(){return this.check(/* @__PURE__ */ ao())},slugify(){return this.check(/* @__PURE__ */ oo())}})),zs=/*@__PURE__*/ L(`ZodString`,(e,t)=>{or.init(e,t),Rs.init(e,t)},{email(e){return this.check(/* @__PURE__ */ la(Gs,e))},url(e){return this.check(/* @__PURE__ */ ha(Ys,e))},jwt(e){return this.check(/* @__PURE__ */ Aa(dc,e))},emoji(e){return this.check(/* @__PURE__ */ ga(Zs,e))},guid(e){return this.check(/* @__PURE__ */ ua(Ks,e))},uuid(e){return this.check(/* @__PURE__ */ da(qs,e))},uuidv4(e){return this.check(/* @__PURE__ */ fa(qs,e))},uuidv6(e){return this.check(/* @__PURE__ */ pa(qs,e))},uuidv7(e){return this.check(/* @__PURE__ */ ma(qs,e))},nanoid(e){return this.check(/* @__PURE__ */ _a(Qs,e))},cuid(e){return this.check(/* @__PURE__ */ va($s,e))},cuid2(e){return this.check(/* @__PURE__ */ ya(ec,e))},ulid(e){return this.check(/* @__PURE__ */ ba(tc,e))},base64(e){return this.check(/* @__PURE__ */ Da(cc,e))},base64url(e){return this.check(/* @__PURE__ */ Oa(lc,e))},xid(e){return this.check(/* @__PURE__ */ xa(nc,e))},ksuid(e){return this.check(/* @__PURE__ */ Sa(rc,e))},ipv4(e){return this.check(/* @__PURE__ */ Ca(ic,e))},ipv6(e){return this.check(/* @__PURE__ */ wa(ac,e))},cidrv4(e){return this.check(/* @__PURE__ */ Ta(oc,e))},cidrv6(e){return this.check(/* @__PURE__ */ Ea(sc,e))},e164(e){return this.check(/* @__PURE__ */ ka(uc,e))},datetime(e){return this.check(/* @__PURE__ */ ja(Vs,e))},date(e){return this.check(/* @__PURE__ */ Ma(Hs,e))},time(e){return this.check(/* @__PURE__ */ Na(Us,e))},duration(e){return this.check(/* @__PURE__ */ Pa(Ws,e))}});function z(e){return/* @__PURE__ */ ca(zs,e)}let Bs=/*@__PURE__*/ L(`ZodStringFormat`,(e,t)=>{sr.init(e,t),Rs.init(e,t)}),Vs=/*@__PURE__*/ L(`ZodISODateTime`,(e,t)=>{Er.init(e,t),Bs.init(e,t)}),Hs=/*@__PURE__*/ L(`ZodISODate`,(e,t)=>{Dr.init(e,t),Bs.init(e,t)}),Us=/*@__PURE__*/ L(`ZodISOTime`,(e,t)=>{Or.init(e,t),Bs.init(e,t)}),Ws=/*@__PURE__*/ L(`ZodISODuration`,(e,t)=>{kr.init(e,t),Bs.init(e,t)}),Gs=/*@__PURE__*/ L(`ZodEmail`,(e,t)=>{ur.init(e,t),Bs.init(e,t)}),Ks=/*@__PURE__*/ L(`ZodGUID`,(e,t)=>{cr.init(e,t),Bs.init(e,t)}),qs=/*@__PURE__*/ L(`ZodUUID`,(e,t)=>{lr.init(e,t),Bs.init(e,t)});function Js(e){return/* @__PURE__ */ da(qs,e)}let Ys=/*@__PURE__*/ L(`ZodURL`,(e,t)=>{vr.init(e,t),Bs.init(e,t)});function Xs(e){return/* @__PURE__ */ ha(Ys,e)}let Zs=/*@__PURE__*/ L(`ZodEmoji`,(e,t)=>{yr.init(e,t),Bs.init(e,t)}),Qs=/*@__PURE__*/ L(`ZodNanoID`,(e,t)=>{br.init(e,t),Bs.init(e,t)}),$s=/*@__PURE__*/ L(`ZodCUID`,(e,t)=>{xr.init(e,t),Bs.init(e,t)}),ec=/*@__PURE__*/ L(`ZodCUID2`,(e,t)=>{Sr.init(e,t),Bs.init(e,t)}),tc=/*@__PURE__*/ L(`ZodULID`,(e,t)=>{Cr.init(e,t),Bs.init(e,t)}),nc=/*@__PURE__*/ L(`ZodXID`,(e,t)=>{wr.init(e,t),Bs.init(e,t)}),rc=/*@__PURE__*/ L(`ZodKSUID`,(e,t)=>{Tr.init(e,t),Bs.init(e,t)}),ic=/*@__PURE__*/ L(`ZodIPv4`,(e,t)=>{Ar.init(e,t),Bs.init(e,t)}),ac=/*@__PURE__*/ L(`ZodIPv6`,(e,t)=>{Nr.init(e,t),Bs.init(e,t)}),oc=/*@__PURE__*/ L(`ZodCIDRv4`,(e,t)=>{Pr.init(e,t),Bs.init(e,t)}),sc=/*@__PURE__*/ L(`ZodCIDRv6`,(e,t)=>{Ir.init(e,t),Bs.init(e,t)}),cc=/*@__PURE__*/ L(`ZodBase64`,(e,t)=>{zr.init(e,t),Bs.init(e,t)}),lc=/*@__PURE__*/ L(`ZodBase64URL`,(e,t)=>{Hr.init(e,t),Bs.init(e,t)}),uc=/*@__PURE__*/ L(`ZodE164`,(e,t)=>{Ur.init(e,t),Bs.init(e,t)}),dc=/*@__PURE__*/ L(`ZodJWT`,(e,t)=>{Gr.init(e,t),Bs.init(e,t)}),fc=/*@__PURE__*/ L(`ZodNumber`,(e,t)=>{Kr.init(e,t),Ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Go(e,t,n,r),e.isFinite=!0},/*@__PURE__*/ dt({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=Bo(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=Bo(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=Bo(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>Bo(e).format??null},{gt(e,t){return this.check(/* @__PURE__ */ Ua(e,t))},gte(e,t){return this.check(/* @__PURE__ */ Wa(e,t))},min(e,t){return this.check(/* @__PURE__ */ Wa(e,t))},lt(e,t){return this.check(/* @__PURE__ */ Va(e,t))},lte(e,t){return this.check(/* @__PURE__ */ Ha(e,t))},max(e,t){return this.check(/* @__PURE__ */ Ha(e,t))},int(e){return this.check(mc(e))},safe(e){return this.check(mc(e))},positive(e){return this.check(/* @__PURE__ */ Ua(0,e))},nonnegative(e){return this.check(/* @__PURE__ */ Wa(0,e))},negative(e){return this.check(/* @__PURE__ */ Va(0,e))},nonpositive(e){return this.check(/* @__PURE__ */ Ha(0,e))},multipleOf(e,t){return this.check(/* @__PURE__ */ Ga(e,t))},step(e,t){return this.check(/* @__PURE__ */ Ga(e,t))},finite(){return this}}));function B(e){return/* @__PURE__ */ Fa(fc,e)}let pc=/*@__PURE__*/ L(`ZodNumberFormat`,(e,t)=>{qr.init(e,t),fc.init(e,t)});function mc(e){return/* @__PURE__ */ Ia(pc,e)}let hc=/*@__PURE__*/ L(`ZodBoolean`,(e,t)=>{Jr.init(e,t),Ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ko(e,t,n,r)});function V(e){return/* @__PURE__ */ La(hc,e)}let gc=/*@__PURE__*/ L(`ZodNull`,(e,t)=>{Yr.init(e,t),Ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qo(e,t,n,r)});function _c(e){return/* @__PURE__ */ Ra(gc,e)}let vc=/*@__PURE__*/ L(`ZodUnknown`,(e,t)=>{Xr.init(e,t),Ls.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function yc(){return/* @__PURE__ */ za(vc)}let bc=/*@__PURE__*/ L(`ZodNever`,(e,t)=>{Zr.init(e,t),Ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jo(e,t,n,r)});function xc(e){return/* @__PURE__ */ Ba(bc,e)}let Sc=/*@__PURE__*/ L(`ZodArray`,(e,t)=>{Is(),ti.init(e,t),Ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$o(e,t,n,r),e.element=t.element},{min(e,t){return this.check(/* @__PURE__ */ qa(e,t))},nonempty(e){return this.check(/* @__PURE__ */ qa(1,e))},max(e,t){return this.check(/* @__PURE__ */ Ka(e,t))},length(e,t){return this.check(/* @__PURE__ */ Ja(e,t))},unwrap(){return this.element}});function H(e,t){return/* @__PURE__ */ so(Sc,e,t)}let Cc=/*@__PURE__*/ L(`ZodObject`,(e,t)=>{Is(),si.init(e,t),Ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ts(e,t,n,r),_t(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return G(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Ee(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Ee(this._zod.def,{catchall:yc()}))},loose(){return this.clone(Ee(this._zod.def,{catchall:yc()}))},strict(){return this.clone(Ee(this._zod.def,{catchall:xc()}))},strip(){return this.clone(Ee(this._zod.def,{catchall:void 0}))},extend(e){return We(this,e)},safeExtend(e){return Ke(this,e)},merge(e){return qe(this,e)},pick(e){return Ve(this,e)},omit(e){return Ue(this,e)},partial(...e){return Je(Rc,this,e[0])},exactPartial(...e){return Je(Bc,this,e[0],`exactPartial`)},required(...e){return Ye(Jc,this,e[0])}});function U(e,t){let n={type:`object`,shape:e??{},...F(t)};return new Cc(n)}function W(e,t){return new Cc({type:`object`,shape:e,catchall:xc(),...F(t)})}let wc=/*@__PURE__*/ L(`ZodUnion`,(e,t)=>{li.init(e,t),Ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ns(e,t,n,r),e.options=t.options});function Tc(e,t){return new wc({type:`union`,options:e,...F(t)})}let Ec=/*@__PURE__*/ L(`ZodDiscriminatedUnion`,(e,t)=>{wc.init(e,t),di.init(e,t)});function Dc(e,t,n){return new Ec({type:`union`,options:t,discriminator:e,...F(n)})}let Oc=/*@__PURE__*/ L(`ZodIntersection`,(e,t)=>{fi.init(e,t),Ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rs(e,t,n,r)});function kc(e,t){return new Oc({type:`intersection`,left:e,right:t})}let Ac=/*@__PURE__*/ L(`ZodTuple`,(e,t)=>{Is(),hi.init(e,t),Ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>is(e,t,n,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(`.partial() cannot be used on tuple schemas containing refinements`);return this.clone({...e,items:e.items.map(e=>new Rc({type:`optional`,innerType:e}))})}});function jc(e,t,n){let r=t instanceof R;return new Ac({type:`tuple`,items:e,rest:r?t:null,...F(r?n:t)})}let Mc=/*@__PURE__*/ L(`ZodRecord`,(e,t)=>{Is(),yi.init(e,t),Ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cs(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Nc(e,t,n){return!t||!t._zod?new Mc({type:`record`,keyType:z(),valueType:e,...F(t)}):new Mc({type:`record`,keyType:e,valueType:t,...F(n)})}let Pc=/*@__PURE__*/ L(`ZodEnum`,(e,t)=>{bi.init(e,t),Ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yo(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Pc({...t,checks:[],...F(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Pc({...t,checks:[],...F(r),entries:i})}});function G(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Pc({type:`enum`,entries:n,...F(t)})}let Fc=/*@__PURE__*/ L(`ZodLiteral`,(e,t)=>{xi.init(e,t),Ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xo(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function K(e,t){return new Fc({type:`literal`,values:Array.isArray(e)?e:[e],...F(t)})}let Ic=/*@__PURE__*/ L(`ZodTransform`,(e,t)=>{Is(),Si.init(e,t),Ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qo(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Tt(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(st(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(st(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Lc(e){return new Ic({type:`transform`,transform:e})}let Rc=/*@__PURE__*/ L(`ZodOptional`,(e,t)=>{wi.init(e,t),Ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function zc(e){return new Rc({type:`optional`,innerType:e})}let Bc=/*@__PURE__*/ L(`ZodExactOptional`,(e,t)=>{Ti.init(e,t),Ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Vc(e){return new Bc({type:`optional`,innerType:e})}let Hc=/*@__PURE__*/ L(`ZodNullable`,(e,t)=>{Ei.init(e,t),Ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ls(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Uc(e){return new Hc({type:`nullable`,innerType:e})}let Wc=/*@__PURE__*/ L(`ZodDefault`,(e,t)=>{Di.init(e,t),Ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ps(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Gc(e,t){return new Wc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ne(t)}})}let Kc=/*@__PURE__*/ L(`ZodPrefault`,(e,t)=>{ki.init(e,t),Ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function qc(e,t){return new Kc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ne(t)}})}let Jc=/*@__PURE__*/ L(`ZodNonOptional`,(e,t)=>{Ai.init(e,t),Ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>us(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Yc(e,t){return new Jc({type:`nonoptional`,innerType:e,...F(t)})}let Xc=/*@__PURE__*/ L(`ZodCatch`,(e,t)=>{Ni.init(e,t),Ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Zc(e,t){return new Xc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:vt(t)})}let Qc=/*@__PURE__*/ L(`ZodPipe`,(e,t)=>{Pi.init(e,t),Ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gs(e,t,n,r),e.in=t.in,e.out=t.out});function $c(e,t){return new Qc({type:`pipe`,in:e,out:t})}let el=/*@__PURE__*/ L(`ZodReadonly`,(e,t)=>{Ii.init(e,t),Ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_s(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function tl(e){return new el({type:`readonly`,innerType:e})}let nl=/*@__PURE__*/ L(`ZodLazy`,(e,t)=>{Ri.init(e,t),Ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ys(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function rl(e){return new nl({type:`lazy`,getter:e})}let il=/*@__PURE__*/ L(`ZodCustom`,(e,t)=>{zi.init(e,t),Ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zo(e,t,n,r)});function al(e,t){return/* @__PURE__ */ co(il,e??(()=>!0),t)}function ol(e,t={}){return/* @__PURE__ */ lo(il,e,t)}function sl(e,t){return/* @__PURE__ */ uo(e,t)}function cl(e){return/* @__PURE__ */ ja(Vs,e)}function ll(e){return(t,n)=>{for(let r of e)Object.hasOwn(t,r)&&t[r]===void 0&&n.addIssue({code:`custom`,path:[r],message:`Explicit undefined is not valid JSON`})}}let ul=Tc([z(),B(),V(),_c()]);function dl(e){let t=/* @__PURE__ */ new WeakSet,n=[{value:e,leaving:!1}];try{for(;n.length>0;){let e=n.pop();if(!e)break;if(e.leaving)t.delete(e.value);else if(typeof e.value==`object`&&e.value!==null){if(t.has(e.value))return!1;t.add(e.value),n.push({value:e.value,leaving:!0});for(let t of Object.values(e.value))n.push({value:t,leaving:!1})}}}catch{return!1}return!0}let fl=al(dl,{message:`JSON value must not contain circular references`}),pl=rl(()=>Tc([ul,H(pl),Nc(z(),pl)])),ml=fl.pipe(pl);fl.pipe(H(pl));let hl=fl.pipe(Nc(z(),pl)),gl=W({code:z().min(1),message:z().min(1),retryable:V(),diagnostic:z().min(1).optional(),stage:z().min(1).optional(),durationMs:B().int().nonnegative().optional(),stderrTail:z().min(1).optional()}).superRefine(ll([`diagnostic`,`stage`,`durationMs`,`stderrTail`])),_l=z().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u),vl=e=>z().min(1).max(e).refine(e=>e.trim().length>0),yl=Nc(_l,U({label:vl(256).optional(),description:vl(1024).optional()}).strict()).refine(e=>Object.keys(e).length<=16,`Too many locales`),bl=Nc(_l,vl(4096)).refine(e=>typeof e.en==`string`,`English fallback is required`).refine(e=>Object.keys(e).length<=16,`Too many locales`),xl=z().refine(e=>e.trim().length>0,{message:`Identifier must not be empty or whitespace`}),Sl=xl.brand(),q=xl.brand(),Cl=xl.brand();xl.brand(),xl.brand();let wl=z().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),Tl=wl.max(128).regex(/^[A-Za-z0-9._~:-]+$/u,`Permission Mode ID must use transport-safe characters`).brand(),El=U({modes:H(U({id:Tl,label:wl.max(256),description:wl.max(1024).optional(),dangerous:V().optional(),localizations:yl.optional()}).strict()).min(1).max(32),defaultModeId:Tl}).strict().superRefine((e,t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.modes.entries())n.has(i.id)&&t.addIssue({code:`custom`,message:`Permission Mode IDs must be unique`,path:[`modes`,r,`id`]}),n.add(i.id);n.has(e.defaultModeId)||t.addIssue({code:`custom`,message:`Default Permission Mode must exist in the catalog`,path:[`defaultModeId`]})});U({threadId:q,permissionModeId:Tl}).strict();let Dl=z().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`});U({sourceThreadId:q,lastTurnId:Cl.optional(),targetHarnessId:Sl,targetModel:Dl.max(1024).optional(),targetThinkingOptionId:Dl.max(128).regex(/^[A-Za-z0-9._~-]+$/u,`Thinking option ID must use transport-safe characters`).optional()}).strict();let Ol=U({sourceThreadId:q,sourceHarnessId:Sl,sourceHarnessLabel:Dl.max(256).optional(),sourceModel:Dl.max(1024).optional(),targetHarnessId:Sl,targetHarnessLabel:Dl.max(256).optional(),targetModel:Dl.max(1024).optional(),totalTurns:B().int().min(1),boundaryTurnNumber:B().int().min(1),includedTurnNumbers:H(B().int().min(1)),omittedTurns:B().int().min(0),preview:z().max(32e3),createdAtMs:B().int().nonnegative()}).strict();U({threadId:q,handoff:Ol}).strict();let kl=B().int().safe().nonnegative(),Al=B().finite().nonnegative(),jl=B().finite().min(0).max(100),Ml=U({version:Tc([K(3),K(4)]).optional(),requestId:z().min(1),turnId:z().min(1).max(1024),outputTokens:kl,startedAtMs:kl,completedAtMs:kl}).strict().refine(e=>e.completedAtMs>e.startedAtMs),Nl=U({version:Tc([K(2),K(3),K(4)]).optional(),value:Al,turnId:z().min(1).max(1024),at:kl}).strict();U({outputTimings:H(Ml).transform(e=>e.filter(e=>e.version===4)).optional(),outputTokensPerSecond:Nl.refine(e=>e.version===4).optional().catch(void 0),timeToFirstOutputMs:Nl.extend({value:kl}).optional()}).strict();let Pl=e=>bl.refine(t=>Object.values(t).every(t=>t.length<=e)),Fl=U({composerIndicators:H(U({kind:K(`countdown`),id:z().min(1).max(64),expiresAtUnix:kl,label:Pl(256).optional(),tooltip:Pl(1024).optional()}).strict()).max(2).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,{message:`Composer indicator IDs must be unique`}).optional(),inputTokens:kl.optional(),cachedInputTokens:kl.optional(),cacheWriteInputTokens:kl.optional(),outputTokens:kl.optional(),outputTokensPerSecond:Al.optional(),sessionOutputTokensPerSecond:Al.optional(),apiOutputTokensPerSecond:Al.optional(),reasoningOutputTokens:kl.optional(),totalTokens:kl.optional(),totalCostUsd:Al.optional(),totalCredits:Al.optional(),contextUsagePercent:Al.optional(),cacheHitRatePercent:jl.optional(),contextWindowTokens:kl.optional(),contextUsedTokens:kl.optional(),planFiveHourUsedPercent:jl.optional(),planFiveHourResetsAtUnix:kl.optional(),planSevenDayUsedPercent:jl.optional(),planSevenDayResetsAtUnix:kl.optional(),sessionCacheHitRatePercent:jl.optional(),timeToFirstOutputMs:kl.optional(),latestRequestTimeToFirstOutputMs:kl.optional(),costSource:G([`publicPrice`,`native`]).optional(),unpricedModels:H(z().min(1)).min(1).optional()}).strict().superRefine((e,t)=>{Object.keys(e).length===0&&t.addIssue({code:`custom`,message:`Thread Usage must contain a reliable field`});let n=e.contextUsedTokens!==void 0;n!==(e.contextWindowTokens!==void 0)&&t.addIssue({code:`custom`,message:`Thread Usage context fields must be provided together`,path:[n?`contextWindowTokens`:`contextUsedTokens`]}),e.contextWindowTokens===0&&t.addIssue({code:`custom`,message:`Thread Usage contextWindowTokens must be greater than zero`,path:[`contextWindowTokens`]}),e.costSource!==void 0&&e.totalCostUsd===void 0&&t.addIssue({code:`custom`,message:`Thread Usage costSource must be provided with totalCostUsd`,path:[`costSource`]}),e.unpricedModels!==void 0&&e.costSource!==`publicPrice`&&t.addIssue({code:`custom`,message:`Thread Usage unpricedModels must be provided with a publicPrice cost`,path:[`unpricedModels`]}),e.planFiveHourResetsAtUnix!==void 0&&e.planFiveHourUsedPercent===void 0&&t.addIssue({code:`custom`,message:`Thread Usage planFiveHourResetsAtUnix must be provided with planFiveHourUsedPercent`,path:[`planFiveHourResetsAtUnix`]}),e.planSevenDayResetsAtUnix!==void 0&&e.planSevenDayUsedPercent===void 0&&t.addIssue({code:`custom`,message:`Thread Usage planSevenDayResetsAtUnix must be provided with planSevenDayUsedPercent`,path:[`planSevenDayResetsAtUnix`]})}),Il=B().finite().min(0).max(100),Ll=G([`weekly`,`monthly`,`five_hour`,`seven_day`,`unknown`]),Rl=U({id:z().min(1).max(256),label:z().min(1).max(256),localizations:yl.optional()}).strict(),zl=U({product:z().min(1),periodType:Ll.optional(),scope:Rl.optional(),localizations:yl.optional(),used:B().finite().nonnegative().optional(),limit:B().finite().nonnegative().optional(),unit:z().min(1).max(32).optional(),usagePercent:Il,resetsAt:z().min(1).optional()}).strict(),Bl=U({availableCount:B().int().safe().positive(),nextExpiresAt:z().min(1).optional(),expiresAt:H(z().min(1)).min(1).max(32).optional()}).strict(),Vl=U({used:B().finite().nonnegative().optional(),limit:B().finite().nonnegative().optional(),unit:z().min(1).max(32).optional(),label:z().min(1).optional(),scope:Rl.optional(),localizations:yl.optional(),usedPercent:Il,resetsAt:z().min(1).optional(),periodType:Ll,productUsage:H(zl).min(1).optional(),resetCredits:Bl.optional()}).strict(),Hl=U({amount:B().finite().nonnegative(),currency:z().trim().min(1).max(8),label:z().trim().min(1).max(128).optional()}).strict();U({threadId:q,refresh:K(`exact`).optional()}).strict(),U({threadId:q,usage:Fl.nullable(),accountCredits:Vl.optional(),accountBalance:Hl.optional(),accountCreditsSupported:V().optional()}).strict();let Ul=z().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),Wl=z().min(1).max(512).refine(e=>!/\p{Cc}/u.test(e),`Model Ref must not contain control characters`).brand(),Gl=G([`priority`,`ultrafast`]),Kl=U({id:Wl,serviceTier:Gl.optional()}).strict();function ql(e,t){return e?.id===t?.id&&e?.serviceTier===t?.serviceTier}let Jl=Ul.max(128).regex(/^[A-Za-z0-9._~-]+$/u,`Thinking option ID must use transport-safe characters`).brand(),Yl=Ul.max(256),Xl=U({id:Jl,label:Ul.max(256)}).strict(),Zl=U({ref:Kl,label:Ul.max(256),resolvedModelLabel:Yl.optional(),fastModel:Kl.optional(),supportedThinkingOptionIds:H(Jl).optional()}).strict().refine(e=>e.fastModel?.serviceTier===void 0||e.fastModel.id===e.ref.id,{path:[`fastModel`,`id`],message:`A tiered Fast Model must share the base Model ID`});function Ql(e,t){if(t)return e?.models.find(e=>ql(e.ref,t)||ql(e.fastModel,t))}let $l=H(Xl).superRefine((e,t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.entries())n.has(i.id)&&t.addIssue({code:`custom`,message:`Thinking option IDs must be unique`,path:[r,`id`]}),n.add(i.id)}),eu=G([`catalog`,`activeModel`]),tu=U({models:H(Zl),defaultModel:Kl.optional(),thinkingOptions:$l,defaultThinkingOptionId:Jl.optional(),thinkingOptionsScope:eu.optional()}).strict().superRefine((e,t)=>{let n=[],r=new Set(e.thinkingOptions.map(({id:e})=>e));for(let[i,a]of e.models.entries()){n.some(e=>ql(e,a.ref))&&t.addIssue({code:`custom`,message:`Model Catalog refs must be unique`,path:[`models`,i,`ref`,`id`]}),n.push(a.ref),a.fastModel&&(n.some(e=>ql(e,a.fastModel))&&t.addIssue({code:`custom`,message:`Fast Model refs must be distinct and unique`,path:[`models`,i,`fastModel`]}),n.push(a.fastModel));let e=/* @__PURE__ */ new Set;for(let[n,o]of(a.supportedThinkingOptionIds??[]).entries())e.has(o)&&t.addIssue({code:`custom`,message:`Supported Thinking option IDs must be unique per Model`,path:[`models`,i,`supportedThinkingOptionIds`,n]}),e.add(o),r.has(o)||t.addIssue({code:`custom`,message:`Supported Thinking option must exist in the catalog`,path:[`models`,i,`supportedThinkingOptionIds`,n]})}e.defaultModel&&!Ql(e,e.defaultModel)&&t.addIssue({code:`custom`,message:`Default Model must exist in the Model Catalog`,path:[`defaultModel`,`id`]}),e.defaultThinkingOptionId&&!r.has(e.defaultThinkingOptionId)&&t.addIssue({code:`custom`,message:`Default Thinking option must exist in the catalog`,path:[`defaultThinkingOptionId`]})}),nu=U({fork:V(),forkAcrossCwd:V(),rollbackLastTurn:V()}).strict().refine(e=>e.fork||!e.forkAcrossCwd,{path:[`forkAcrossCwd`],message:`Cross-cwd Fork requires exact history Fork support`}),ru=G([`live`,`atCreate`]),iu=U({configuration:U({selectModel:V(),selectThinkingOption:V(),selectPermissionMode:V(),permissionModeScope:ru.default(`live`)}).strict(),history:nu,subagents:U({observe:V(),readTranscript:V()}).strict().optional(),autonomousTurns:U({observe:V()}).strict().optional(),steer:V().optional(),persistentPlan:V().optional()}).strict();U({effectiveModel:Kl.optional(),resolvedModelLabel:Yl.optional(),effectiveThinkingOptionId:Jl.optional(),availableThinkingOptions:$l.optional(),effectivePermissionModeId:Tl.optional()}).strict().superRefine((e,t)=>{e.effectiveThinkingOptionId&&e.availableThinkingOptions&&!e.availableThinkingOptions.some(({id:t})=>t===e.effectiveThinkingOptionId)&&t.addIssue({code:`custom`,message:`Effective Thinking option must be currently available`,path:[`effectiveThinkingOptionId`]})});let au=U({open:K(!0)}).strict();Tc([U({status:K(`ready`),catalog:tu,permissionModes:El.optional(),capabilities:iu,webUi:au.optional()}).strict().superRefine((e,t)=>{let n=e.capabilities.configuration.selectPermissionMode;n!==!!e.permissionModes&&t.addIssue({code:`custom`,message:`Permission Mode catalog and capability must agree`,path:n?[`permissionModes`]:[`capabilities`,`configuration`,`selectPermissionMode`]})}),U({status:G([`notInstalled`,`unavailable`,`error`]),error:gl}).strict()]),U({harnessId:Sl,cwd:Ul.max(16384).optional(),refresh:V().optional(),purpose:K(`availability`).optional(),credentialAccess:G([`allow`,`retry`]).optional()}).strict(),U({harnessId:Sl}).strict(),U({}).strict(),U({threadId:q,model:Kl}).strict(),U({threadId:q,thinkingOptionId:Jl}).strict(),U({threadId:q,includeReferenceCapability:V().optional()}).strict(),Dc(`owner`,[U({owner:K(`codex`),locked:V(),effectiveModel:Kl.optional(),resolvedModelLabel:Yl.optional(),effectiveThinkingOptionId:Jl.optional(),effectivePermissionModeId:Tl.optional(),history:nu.optional(),supportsThreadReferences:K(!0).optional(),handoff:Ol.optional()}).strict(),U({owner:K(`external`),harnessId:Ul.max(256),transportModelId:Ul.max(8192),effectiveModel:Kl.optional(),resolvedModelLabel:Yl.optional(),effectiveThinkingOptionId:Jl.optional(),availableThinkingOptions:$l.optional(),effectivePermissionModeId:Tl.optional(),catalog:tu.optional(),history:nu,usage:Fl.optional(),handoff:Ol.optional(),locked:K(!0)}).strict()]),U({threadIds:H(q).min(1).max(100)}).strict().superRefine(({threadIds:e},t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.entries())n.has(i)&&t.addIssue({code:`custom`,message:`Thread ownership-list IDs must be unique`,path:[`threadIds`,r]}),n.add(i)});let ou=Dc(`owner`,[U({threadId:q,owner:K(`codex`)}).strict(),U({threadId:q,owner:K(`external`),harnessId:z().max(256).pipe(Sl)}).strict()]);U({threads:H(ou).min(1).max(100)}).strict().superRefine(({threads:e},t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.entries())n.has(i.threadId)&&t.addIssue({code:`custom`,message:`Thread ownership-list results must be unique`,path:[`threads`,r,`threadId`]}),n.add(i.threadId)}),U({threadId:q,text:z().optional()}).strict(),U({kind:K(`application`),value:z().transform((e,t)=>{try{return JSON.parse(e)}catch{return t.addIssue({code:`custom`,message:`Invalid steering context JSON`}),bt}}).pipe(U({expectedTurnId:Cl,clientUserMessageId:z().min(1),delivery:G([`newTurn`,`activeTurn`])}).strict())}).strict().transform(e=>e.value),G([`activeTurn`,`newTurn`]),U({delivery:G([`official`,`activeTurn`,`newTurn`])}).strict();let su=z().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u),cu=su.pipe(Sl),lu=cu.refine(e=>e!==`codex`,`The official Codex identity is reserved`),uu=z().min(1).max(512).refine(e=>!/[\\\u0000:#?]/u.test(e)&&!e.startsWith(`/`)&&!e.split(`/`).some(e=>e===`..`||e===``),`Plugin resources must be relative paths inside the plugin`),du=Xs().refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Plugin documentation links must be credential-free HTTPS URLs`),fu=U({en:z().max(4096),"zh-CN":z().max(4096).optional()}).strict(),pu=U({commands:H(U({terminal:z().max(256),command:z().max(4096)}).strict()).max(8),before:fu.optional(),after:fu.optional(),downloads:H(U({label:z().max(128),url:du}).strict()).max(8).optional()}).strict(),mu={id:cu,name:z().trim().min(1).max(128),version:z().min(1).max(128),kind:K(`usage`).optional(),iconStyle:U({vector:U({viewBox:z().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),color:z().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),paths:H(U({d:z().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),fillRule:G([`evenodd`,`nonzero`]).optional(),fill:z().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()}).strict()).min(1).max(32)}).strict().optional(),background:z().regex(/^#[a-f0-9]{6}$/iu).optional(),borderRadius:B().min(0).max(50).optional(),paddingRatio:B().min(0).max(.25).optional()}).strict().optional(),installation:pu.optional(),notice:fu.optional(),launchCommand:K(!0).optional(),links:U({website:du.optional(),documentation:du.optional(),installation:du.optional()}).strict().optional()};U({manifestVersion:K(1),...mu,adapterApiVersion:B().int().positive(),entry:uu,icon:uu.optional()}).strict();let hu=z().max(174828).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u),gu=U({...mu,icon:hu.optional()}).strict();U({}).strict(),U({plugins:H(gu.extend({id:lu})).max(128)}).strict(),U({version:K(1),enabled:H(cu).max(128)}).strict().refine(e=>new Set(e.enabled).size===e.enabled.length,{message:`Enabled plugin IDs must be unique`,path:[`enabled`]});let _u=131072,vu=524288,yu=su,bu=G([`sidebar.thread-layout`,`sidebar.thread-badge`,`appearance.theme`]),xu=G([`appearance`,`interface`,`workflow`,`analytics`,`integrations`,`tools`]),Su=z().trim().min(1).max(128);function Cu(e){switch(e.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()){case`png`:return`image/png`;case`jpg`:case`jpeg`:return`image/jpeg`;case`webp`:return`image/webp`;default:return}}let wu=e=>e.split(`/`).every(e=>!/[. ]$/u.test(e)),Tu=uu.refine(e=>Cu(e)!==void 0&&wu(e),`Images must be relative .png, .jpg, .jpeg, or .webp paths with no segments ending in a dot or space`),Eu=z().trim().max(2048).regex(/^https?:\/\/[^/?#\\\s]+/iu,`Expected an HTTP(S) URL`).pipe(Xs({protocol:/^https?$/u})).refine(e=>{let{username:t,password:n}=new URL(e);return!t&&!n&&!/[\\\s]/u.test(e)},`URL must not contain credentials, backslashes, or whitespace`);function Du(e){return W({en:e,"zh-CN":e})}let Ou=Du(z().trim().min(1)),ku=H(xu).max(xu.options.length).refine(e=>new Set(e).size===e.length,`Duplicate categories`),Au=H(bu).max(bu.options.length).refine(e=>new Set(e).size===e.length,`Duplicate slots`),ju={key:z().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),label:Ou,description:Ou.optional()},Mu={...ju,step:B().positive().optional(),default:B().optional()},Nu=W({value:z(),label:Ou}),Pu=Dc(`type`,[W({...ju,type:K(`boolean`),default:V().optional()}),W({...ju,type:K(`string`),placeholder:Ou.optional(),default:z().optional()}),W({...Mu,type:K(`number`),min:B().optional(),max:B().optional()}),W({...Mu,type:K(`range`),min:B(),max:B()}),W({...ju,type:K(`select`),options:H(Nu).min(1),default:z().optional()})]).superRefine((e,t)=>{let n=(e,n)=>t.addIssue({code:`custom`,path:[e],message:n});if(e.type===`number`||e.type===`range`){let{min:t=-1/0,max:r=1/0,default:i}=e;t>r&&n(`max`,`Must be at least min`),i!==void 0&&(i<t||i>r)&&n(`default`,`Must be within min and max`)}else if(e.type===`select`){let t=new Set(e.options.map(({value:e})=>e));t.size!==e.options.length&&n(`options`,`Duplicate option values`),e.default!==void 0&&!t.has(e.default)&&n(`default`,`Must match an option value`)}}),Fu=U({manifestVersion:mc().positive(),id:yu,name:Tc([Su,Du(Su)]),version:z().min(1).max(128),desktopApi:mc().positive()}).passthrough().extend({manifestVersion:K(1),desktopApi:K(1),description:W({en:z().max(4096),"zh-CN":z().max(4096).optional()}).optional(),author:z().trim().min(1).max(128).optional(),repository:Eu.optional(),details:W({en:z().max(16384),"zh-CN":z().max(16384).optional()}).optional(),icon:Tu.optional(),screenshots:H(Tu).max(4).refine(e=>new Set(e).size===e.length,`Duplicate screenshots`).optional(),desktop:W({script:uu,style:uu.optional()}).optional(),backend:W({script:uu.refine(wu)}).optional(),slots:Au.default(()=>[]),settingsSchema:H(Pu).max(32).refine(e=>new Set(e.map(({key:e})=>e)).size===e.length,`Duplicate setting keys`).optional(),categories:ku.optional()}).strict().refine(e=>e.desktop!==void 0||e.backend!==void 0,`Expected at least one desktop or backend entry`),Iu=z().regex(/^[a-f0-9]{64}$/u),Lu=W({state:G([`running`,`disabled`,`invalid`,`incompatible`,`conflict`,`failed`,`waiting`]),hash:Iu.optional(),error:z().optional(),conflictWith:yu.optional()});W({controllerPid:mc().positive(),targetId:z().nullable(),updatedAt:cl(),handledReloadToken:Js().optional(),extensions:Nc(z(),Lu),surfaces:Nc(z(),Lu).optional()});let Ru=G([`official`,`community`]);function zu(e){return e.origin===`https://api.github.com`&&/^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(e.pathname)}let Bu=Eu.refine(e=>{let t=new URL(e);return/\.zip$/iu.test(t.pathname)||zu(t)||t.origin===`https://github.com`&&/^\/[\w-]+\/[\w.-]+\/zipball(?:\/.+)?\/?$/u.test(t.pathname)||t.origin===`https://codeload.github.com`&&/^\/[\w-]+\/[\w.-]+\/(?:zip|zipball|legacy\.zip)\/.+$/u.test(t.pathname)},`Expected a .zip download URL or a GitHub zipball URL`),Vu=W({id:yu,version:z().trim().min(1).max(128),name:Ou.extend({en:Su,"zh-CN":Su}),description:Du(z().trim().min(1).max(4096)),details:Du(z().trim().min(1).max(16384)).optional(),author:z().trim().min(1).max(128),repository:Eu,stars:B().int().min(0).optional(),downloads:B().int().min(0).optional(),categories:ku.optional(),trustTier:Ru.default(`community`),icon:Eu.optional(),screenshots:H(Eu).max(4).optional(),downloadUrl:Bu,sha256:Iu,slots:Au.optional(),publishedAt:z().optional(),updatedAt:z().optional(),minCodexHostVersion:z().optional()});W({schemaVersion:K(1),generatedAt:z(),extensions:H(Vu).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,`Duplicate extension IDs`)});let Hu=z().trim().min(1).max(128),Uu=/^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³]) *(?:\.|$)/iu,Wu=yu.refine(e=>!Uu.test(e),`Reserved extension ID`),Gu=G([`desktop`,`web`]),Ku=Iu,qu=Js(),Ju=uu.refine(e=>!/[\x00-\x1f\x7f<>"|*]/u.test(e)&&e.split(`/`).every(e=>!/[. ]$/u.test(e)&&!Uu.test(e)),`Expected a portable relative resource path`).refine(e=>e.split(`/`).length<=32,`Extension resources may be at most 32 segments deep`),Yu=Fu.shape,Xu=(e,t=0)=>W({en:z().trim().min(t).max(e),"zh-CN":z().trim().min(t).max(e)}),Zu=e=>Ju.refine(t=>t.endsWith(e),`Expected a ${e} file`),Qu=Zu(`.mjs`),$u=Zu(`.css`).optional(),ed=e=>e.normalize(`NFC`).toLowerCase(),td=W({manifestVersion:K(2),id:Wu,name:Xu(128,1),version:z().trim().min(1).max(128),description:Xu(4096),details:Xu(16384).optional(),author:Yu.author,repository:Yu.repository,icon:Yu.icon.refine(e=>e===void 0||Ju.safeParse(e).success),screenshots:Yu.screenshots.refine(e=>e===void 0||e.every(e=>Ju.safeParse(e).success)),categories:Yu.categories,settingsSchema:Yu.settingsSchema,slots:Yu.slots.removeDefault().optional(),page:W({apiVersion:K(1),entry:Qu,style:$u,title:Xu(128,1).optional()}).optional(),widget:W({apiVersion:K(1),entry:Qu,style:$u}).optional(),desktop:W({apiVersion:K(1),script:Zu(`.js`),style:$u}).optional(),web:W({apiVersion:K(1),entry:Qu.optional(),style:$u}).refine(({entry:e,style:t})=>e!==void 0||t!==void 0,`Expected a Web entry or style`).optional(),backend:W({apiVersion:K(1),entry:Qu}).optional()}).refine(({page:e,widget:t,desktop:n,web:r,backend:i})=>!!(e||t||n||r||i),`Expected at least one page, widget, desktop, web, or backend entry`).refine(({page:e,widget:t,web:n,backend:r})=>!r||[e?.entry,t?.entry,n?.entry].every(e=>e===void 0||ed(e)!==ed(r.entry)),{path:[`backend`,`entry`],message:`A backend entry cannot also be a frontend entry`});function nd({hasPage:e,hasWidget:t,hasDesktop:n,hasWeb:r,hasBackend:i}){if(e||t||i&&!n&&!r)return[`desktop`,`web`];let a=[];return n&&a.push(`desktop`),r&&a.push(`web`),a}let rd=Hu,id=G([`running`,`waiting`,`idle`,`unknown`]),ad=W({sourceThreadId:q,createdAtMs:B().int().nonnegative()}),od=W({harnessId:Sl,title:z().optional(),status:id,archived:V(),updatedAtMs:B().int().nonnegative().optional()}),sd=W({revision:mc().nonnegative(),parents:Nc(q,q),handoffs:Nc(q,ad).optional(),nodes:Nc(q,od),truncated:V()}).refine(e=>Object.keys(e.nodes).length<=5e3,`Too many Thread tree nodes`).refine(({parents:e,handoffs:t,nodes:n})=>Object.entries(e).every(([e,t])=>Object.hasOwn(n,e)&&Object.hasOwn(n,t))&&Object.entries(t??{}).every(([e,{sourceThreadId:t}])=>Object.hasOwn(n,e)&&Object.hasOwn(n,t)),`Missing Thread tree node`),cd=z().min(1).max(128);W({});let ld=W({subscriptionId:cd});W({}),ld.extend({snapshot:sd});let ud=mc().nonnegative(),dd=W({revision:ud,enabled:H(Wu).max(64).refine(e=>new Set(e).size===e.length,`Duplicate extension IDs`)});W({version:K(1),seeded:H(Wu).max(64).refine(e=>new Set(e).size===e.length,`Duplicate extension IDs`)});let fd=U({version:z().trim().min(1).max(128),publishedAt:z().trim().min(1).max(64).optional(),notes:z().trim().min(1).max(8192),url:Eu.optional()}),{downloadUrl:pd,...md}=Vu.shape,hd=U({...md,id:Wu,format:K(`codexhost`),targets:H(Gu).min(1).max(2).refine(e=>new Set(e).size===e.length,`Duplicate targets`),apis:W({page:mc().positive().optional(),widget:mc().positive().optional(),desktop:mc().positive().optional(),web:mc().positive().optional(),backend:mc().positive().optional()}),downloadUrl:pd.refine(e=>e.startsWith(`https://`),`Expected HTTPS`),featured:V().optional(),featuredOrder:mc().nonnegative().optional(),changelog:H(fd).max(20).optional()}).refine(({targets:e,apis:t})=>{let n=nd({hasPage:!!t.page,hasWidget:!!t.widget,hasDesktop:!!t.desktop,hasWeb:!!t.web,hasBackend:!!t.backend});return e.length===n.length&&n.every(t=>e.includes(t))},`Catalog targets must match the declared APIs`);U({schemaVersion:K(2),generatedAt:z().min(1),extensions:H(hd).max(1e4).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,`Duplicate extension IDs`)}).extend({catalogUrl:Eu,fetchedAt:cl(),cached:V(),stale:V().optional()});let gd={id:Wu},_d={...gd,activationId:qu,digest:Ku},vd={...gd,activationId:_d.activationId.optional()},yd=z().min(1).max(4096).refine(e=>/^(?:\/|[a-z]:[/\\])/iu.test(e)&&!e.includes(`\0`)&&!e.split(/[/\\]/u).some(e=>e===`.`||e===`..`),`Expected an absolute local path without dot segments`),bd=z().min(1).max(256).refine(e=>e.split(`/`).every(e=>e&&/^[a-z0-9_.-]+$/iu.test(e)&&e!==`.`&&e!==`..`),`Invalid GitHub ref`);function xd(e){return z().max(4*Math.ceil(e/3)).refine(t=>{let n=t.endsWith(`==`)?2:+!!t.endsWith(`=`);return t.length%4==0&&t.length*3/4-n<=e&&/^[A-Za-z0-9+/]*={0,2}$/u.test(t)},`Expected bounded standard padded base64`)}let Sd=W({type:K(`github`),repository:z().max(150).regex(/^[a-z0-9-]+\/[a-z0-9_-][a-z0-9_.-]*$/iu),ref:bd.optional(),tag:bd.optional(),asset:z().max(255).regex(/^[a-z0-9_.-]+\.zip$/iu).optional(),subpath:Ju.optional()}).refine(({ref:e,tag:t,asset:n})=>!e||!t&&!n,`Use either a zipball ref or a release tag/asset`),Cd=Tc([W({type:K(`catalog`),...gd}),Sd,W({type:K(`zip`),base64:xd(67108864).min(4)}),W({type:K(`zip`),localZipPath:yd}),W({type:K(`localDir`),localDir:yd})]),wd=Dc(`type`,[W({type:K(`catalog`),...gd}),Sd,W({type:K(`zip`)}),W({type:K(`localDir`)})]),Td=W({..._d,manifest:td,installedAt:cl(),source:wd.optional()}),Ed=e=>z().max(23+4*Math.ceil(e/3)).regex(/^data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2}$/u),Dd={desktopConflictWith:Wu.optional()},Od=G([`none`,`inactive`,`starting`,`running`,`failed`]),kd=Dc(`state`,[Td.extend({state:K(`valid`),enabled:V(),...Dd,iconDataUrl:Ed(_u).optional(),screenshotDataUrls:H(Ed(vu)).max(4).optional(),backendState:Od.optional(),backendError:z().optional()}),W({state:G([`invalid`,`incompatible`]),id:z().min(1),enabled:V(),error:z()})]);W({revision:ud,configuration:dd,diagnostics:H(z()),extensions:H(kd)}),W({revision:ud,extensions:H(Td.extend({...Dd,settingsRevision:ud})).max(64)});let Ad={list:`codexhost/extensions/list`,snapshot:`codexhost/extensions/snapshot`,catalog:`codexhost/extensions/catalog`,catalogIcon:`codexhost/extensions/catalogIcon`,catalogScreenshot:`codexhost/extensions/catalogScreenshot`,install:`codexhost/extensions/install`,update:`codexhost/extensions/update`,enable:`codexhost/extensions/enable`,disable:`codexhost/extensions/disable`,uninstall:`codexhost/extensions/uninstall`,recover:`codexhost/extensions/recover`,asset:`codexhost/extensions/asset`,settingsGet:`codexhost/extensions/settings/get`,settingsSet:`codexhost/extensions/settings/set`,backendInvoke:`codexhost/extensions/backend/invoke`,threadTree:`codexhost/extensions/threadTree`},jd=Object.freeze(Object.values(Ad));new Set(jd),W({});let Md={expectedRevision:ud};W({...gd,...Md}),Td.extend({replaced:V()}),Dc(`state`,[W({state:K(`saved`),configuration:dd}),W({state:K(`revision-conflict`),revision:ud})]),W({...vd,digest:_d.digest.optional(),path:Ju}),W({mimeType:z().min(1),base64:xd(16777216),digest:_d.digest}),W({mimeType:G([`image/png`,`image/jpeg`,`image/webp`]),base64:xd(_u)});let Nd=mc().min(0).max(3);W({mimeType:G([`image/png`,`image/jpeg`,`image/webp`]),base64:xd(vu)}),W({settingsRevision:ud,values:hl}),Ad.list,Ad.snapshot,Ad.catalog,W({forceRefresh:V().optional(),staleWhileRevalidate:V().optional()}),Ad.catalogIcon,W({...gd}),Ad.catalogScreenshot,W({...gd,index:Nd}),Ad.install,W({source:Cd}),Ad.update,W({...gd,expectedDigest:_d.digest,expectedActivationId:_d.activationId.optional(),source:Cd.optional()}),Ad.enable,Ad.disable,Ad.uninstall,W({...gd,removeData:V().optional(),expectedDigest:_d.digest.optional()}),W({...gd,removed:V()}),Ad.recover,W({expectedRevision:Md.expectedRevision.optional()}),Ad.asset,Ad.settingsGet,W(vd),Ad.settingsSet,W({...vd,expectedSettingsRevision:ud,values:hl}),Ad.backendInvoke,W({...vd,method:rd,params:ml.optional()}),W({result:ml}),Ad.threadTree,U({threadId:q}).strict(),U({confirmed:V()}).strict();let Pd=[`codex-desktop`,`web`,`web-desktop-shell`,`web-mobile`,`ssh-remote`,`cli`],Fd=[`darwin`,`win32`,`linux`],Id=[`arm64`,`x64`,`ia32`,`arm`],Ld=[`zh`,`en`,`ja`,`ko`,`de`,`fr`,`es`,`pt`,`ru`,`other`],Rd=[`codex`,`claude-code`,`antigravity`,`pi`,`opencode`,`cursor-cli`,`deepseek-harness`,`grok`,`omp`,`qwen-code`,`kiro-cli`,`codebuddy`,`workbuddy`,`devin`,`hermes`,`qoder`,`qoder-cn`,`kimi-code`,`zcode`,`copilot`,`custom`],zd=[`official-relay`,`self-hosted-relay`,`tailscale-serve`,`tailscale-funnel`,`tailscale-ip`,`lan`,`custom-proxy`,`remote-peer`],Bd=z().min(1).max(40).regex(/^[0-9A-Za-z._+-]+$/u),Vd=G(Pd),Hd=G(Ld),Ud=G(Rd),Wd=G(zd);new Set(Rd),new Set(Ld),U({enabled:V(),forcedOffByEnv:V()}).strict(),U({enabled:V()}).strict(),U({surfaces:H(Vd).max(12).optional(),harnesses:H(Ud).max(32).optional(),remoteAccess:H(Wd).max(12).optional()}).strict(),U({dailyActive:K(!0).optional(),weeklyActive:K(!0).optional(),monthlyActive:K(!0).optional(),newInstall:K(!0).optional(),retainedD1:K(!0).optional(),retainedD7:K(!0).optional(),remoteAny:K(!0).optional(),appVersion:Bd.optional(),codexDesktopVersion:Bd.optional(),os:G(Fd).optional(),arch:G(Id).optional(),uiLanguage:Hd.optional(),surfaces:H(Vd).min(1).max(12).optional(),harnesses:H(Ud).min(1).max(32).optional(),remoteAccess:H(Wd).min(1).max(12).optional()}).strict().refine(e=>Object.keys(e).length>0,{message:`Telemetry heartbeat must contain at least one countable field`});let Gd=4e3,Kd={threadId:q};Dc(`action`,[W({...Kd,action:G([`get`,`pause`,`resume`,`clear`])}),W({...Kd,action:G([`create`,`edit`]),objective:z().trim().min(1).refine(e=>Array.from(e).length<=Gd,`A goal objective can have up to ${Gd} characters.`)})]),U({goal:U({threadId:q,objective:z(),status:G([`active`,`paused`,`blocked`,`usageLimited`,`budgetLimited`,`complete`]),tokenBudget:mc().positive().nullable().default(null),tokensUsed:mc().nonnegative(),timeUsedSeconds:mc().nonnegative()}).nullable()});let qd=z().trim().min(1),Jd=z().min(1),Yd=U({icon:z().nullable(),color:z().nullable()}),Xd=Yd.nullable(),Zd={create:{method:`codexhost/thread/sections/create`,params:U({name:qd}).strict()},update:{method:`codexhost/thread/sections/update`,params:U({sectionId:Jd,name:qd,appearance:Yd.strict().nullable().optional()}).strict()},delete:{method:`codexhost/thread/sections/delete`,params:U({sectionId:Jd}).strict()}};Dc(`status`,[U({status:K(`unknown`)}),U({status:K(`confirmed`),sectionId:Jd,section:U({id:Jd,name:z().min(1),appearance:Xd}).nullable(),syncPending:V()})]),[Zd.create.method,Zd.update.method,Zd.delete.method,...jd],U({threadSectionsV1:K(!0).optional(),complete:K(!1).optional(),sections:H(U({id:z().min(1),name:z().min(1),appearance:Xd.optional(),threads:H(hl)}))}),U({threadId:z().min(1).max(1024),sectionId:z().min(1).max(1024).nullable(),beforeThreadId:z().min(1).max(1024).nullable().optional(),expectedSourceSectionId:z().min(1).max(1024).optional()}).refine(e=>e.expectedSourceSectionId===void 0||e.sectionId===null),U({threadIds:H(z().min(1))}).strict(),U({threadId:z().min(1).max(1024),pinned:V()}).strict(),U({}).strict(),U({parents:Nc(z().min(1),z().min(1))}).strict(),U({prompt:z().max(16384).optional()}).strict(),U({projects:H(U({id:z(),name:z(),rootPaths:H(z()),createdAt:B().int().optional()})),nativeProjects:K(!0).optional(),assignments:Nc(z(),z()),projectless:H(z()),pinned:H(z()),sectionProjects:Nc(z(),H(z())).optional(),pinnedProjects:H(z()).optional()});let Qd=Nc(z(),yc()),$d=U({epoch:z().uuid(),sequence:B().int().nonnegative()});Dc(`type`,[U({type:K(`projects-changed`),cursor:$d}),U({type:K(`skills-changed`),cursor:$d,cwd:z().optional()}),U({type:K(`harness-inspection-changed`),cursor:$d,harnessId:z().min(1)}),U({type:K(`display-settings-changed`),cursor:$d}),U({type:K(`sections-changed`),cursor:$d}),U({type:K(`preferences-changed`),cursor:$d,revision:B().int().nonnegative()}),U({type:K(`extensions-changed`),cursor:$d,revision:ud}),U({type:K(`hello`),version:K(1),cursor:$d,reset:V()}),U({type:K(`changed`),cursor:$d,threadId:z().min(1),method:z().min(1)})]);let ef=Dc(`type`,[U({type:K(`text`),id:z(),prompt:z(),secret:V().optional(),optional:V().optional()}),U({type:K(`choice`),id:z(),prompt:z(),multiple:V(),allowOther:V(),optional:V().optional(),options:H(U({value:z(),label:z(),description:z().optional()}))})]),tf=Dc(`type`,[U({type:K(`approval`),title:z(),description:z().optional(),subject:yc().optional(),actions:H(U({id:z(),label:z(),effect:z()}))}),U({type:K(`question`),title:z().optional(),questions:H(ef)})]),nf=U({requestId:Tc([z(),B().int()]),threadId:z(),kind:G([`approval`,`question`]),interaction:tf,request:Qd}),rf=U({id:z().min(1),clientUserMessageId:z().min(1),input:H(Qd),presentationInput:H(Qd).nullable().optional()}).passthrough();U({fields:H(U({path:H(Tc([z(),B().int().nonnegative()])),originalLength:B().int().nonnegative()}))});let af=U({id:z().min(1),status:z().min(1),codexhostTurnOutcome:U({status:K(`unknown`),reason:z()}).optional(),items:H(U({id:z().min(1),type:z().min(1)}).passthrough()),codexhostFileOperations:H(U({beforeItemId:z().nullable(),item:U({id:z().min(1),type:z().min(1)}).passthrough()})).optional(),error:U({message:z().optional()}).passthrough().nullable().optional(),fingerprint:z().min(1).optional(),unchanged:K(!0).optional()}).passthrough(),of=U({id:z().min(1).max(512),fingerprint:z().min(1).max(128)});U({threadId:z().min(1),knownTurns:H(of).max(64).optional(),truncateToolOutput:V().optional()});let sf=U({harnessId:z().min(1),nativeSessionId:z().min(1)});U({cursor:$d,activeTurnId:z().min(1).nullable().optional(),command:U({name:z().min(1),turn:af,subsequentTurnId:z().min(1).optional()}).optional(),thread:U({id:z().min(1),cwd:z(),modelProvider:z().min(1),createdAt:B(),updatedAt:B(),recencyAt:B().nullable().optional(),status:U({type:z()}).passthrough(),name:z().nullable().optional(),preview:z().optional(),codexhostImportSource:sf.optional(),turns:H(af).length(0)}).passthrough(),turnsPage:U({data:H(af).max(5),nextCursor:z().nullable()}),configuration:U({codexCollaborationMode:G([`plan`,`default`]).optional(),native:U({model:z().min(1).max(1024).optional(),reasoningEffort:z().min(1).max(128).optional()}).optional(),effectiveModel:Kl.optional(),effectiveThinkingOptionId:Jl.optional(),effectivePermissionModeId:Tl.optional()}),queue:U({items:H(rf),pausedReason:G([`interrupted`,`outcome-unknown`,`failed`]).nullable()}).optional(),interactions:H(nf),handoff:Ol.optional()}),U({version:K(1),owner:K(`service`).optional(),pid:B().int().positive(),port:B().int().min(1).max(65535),token:z().regex(/^[0-9a-f]{64}$/u),startedAt:B(),epoch:z().uuid(),capabilities:U({peerDelegation:K(1).optional(),threadReferenceContext:K(1).optional()}).optional()}),U({epoch:z().uuid(),threadId:z().min(1),requestId:Tc([z(),B().int()]),result:Qd}),U({includeArchived:V().optional(),officialCursor:U({live:z().nullable(),archived:z().nullable().optional()}).strict().optional(),scope:Tc([U({cwd:z().min(1).max(4096),excludeCwds:H(z().min(1).max(4096)).max(1024)}).strict(),U({projectId:z().min(1).max(1024),legacyThreadIds:H(z().min(1).max(1024)).max(1024),rootPaths:H(z().min(1).max(4096)).max(1024).optional()}).strict()]).optional()}).strict(),U({threads:H(hl),ownership:H(ou),archivedThreadIds:H(q),officialCursor:U({live:z().nullable(),archived:z().nullable().optional()}).strict().optional()}).strict(),gu.pick({id:!0,name:!0,icon:!0,iconStyle:!0});let cf=W({threadId:z().max(1024),title:z().max(240),project:z().max(240),harness:W({id:z().min(1).max(128),name:z().min(1).max(128)}).optional(),state:G([`idle`,`running`,`waiting`,`completed`,`failed`]),updatedAt:B().nonnegative()});W({epoch:z().max(128),revision:mc().nonnegative(),running:mc().nonnegative(),waiting:mc().nonnegative(),sessions:H(cf).max(32).default([]),notifications:H(W({threadId:z().max(1024),key:z().max(4096),kind:G([`completed`,`failed`,`approval`,`question`]),revision:mc().nonnegative()})).max(256)});let lf=z().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);U({available:V()}).strict(),U({path:z().min(1),mimeType:lf}).strict();let uf=G([`credentials-unavailable`,`login-expired`,`rate-limited`,`service-rejected`,`host-incompatible`,`network`,`timeout`,`audio-empty`,`audio-too-large`,`audio-format`,`audio-invalid`]);Dc(`ok`,[U({ok:K(!0),text:z()}).strict(),U({ok:K(!1),error:U({code:uf}).strict()}).strict()]),U({threadId:q.optional(),cwd:z().min(1).optional()}).strict().refine(e=>!(e.threadId&&e.cwd),{message:`Specify threadId or cwd, not both`});let df=U({name:z().min(1).regex(/^[^\s[\]]+$/u),description:z().optional(),path:z().min(1),scope:G([`project`,`global`]),source:z().min(1)}).strict();U({revision:B().int().nonnegative(),complete:V(),skills:H(df),warnings:H(z()).optional()}).strict(),U({cwd:z().min(1).optional()}).strict();let ff=U({kind:G([`public`,`relay`,`tailscale-funnel`,`tailscale-https`,`tailscale`,`lan`,`virtual`]),url:z().min(1)}).strict(),pf=Dc(`status`,[U({status:K(`not-installed`)}),U({status:K(`not-running`)}),U({status:K(`not-logged-in`)}),U({status:K(`https-disabled`)}),U({status:K(`not-serving`),command:z()}),U({status:K(`occupied`),target:z()}),U({status:K(`serving`),url:z(),funnel:V()}),U({status:K(`error`),message:z()})]);U({state:pf,error:z().optional()}).strict();let mf=Dc(`status`,[U({status:K(`on`)}),U({status:K(`off`)}),U({status:K(`invalid`),reason:z()})]),hf=U({lan:V(),autostart:mf}).strict(),gf=U({expiresAt:z().optional(),issuing:V(),failure:U({detail:z().optional(),retryAt:z(),paused:V()}).optional()}),_f=Dc(`status`,[U({status:K(`off`),reason:G([`invite`,`name-taken`,`banned`]).optional()}),U({status:K(`connecting`),reason:G([`full`,`unreachable`]).optional()}),U({status:K(`connected`),url:z(),certificate:gf}),U({status:K(`missing-certificate`),url:z(),certificate:gf}),U({status:K(`stopped`),reason:G([`replaced`,`rejected`,`unsupported-version`])})]);z().max(253).regex(/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?$/i).transform(e=>e.toLowerCase()),z().regex(/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)?$/);let vf=G([`official`,`self-hosted`]);U({secret:z().min(1),lastUsedAt:B().nullable(),networkUrls:H(ff),directCandidates:H(ff).optional(),tailscale:pf,background:hf.optional(),relay:U({state:_f,enabled:V(),kind:vf,officialHost:z(),customHost:z().optional(),officialHostname:z().optional(),customHostname:z().optional(),quotaUntil:z().optional()}).strict().optional()}).strict();let yf=W({threadId:z().min(1).max(1024),view:G([`result`,`messages`]),from:B().int().min(1).max(2**53-1).optional(),to:B().int().min(1).max(2**53-1).optional()}),bf=/^[a-zA-Z0-9_-]{1,64}$/u,xf=z().regex(bf),Sf=z().regex(bf),Cf=z().regex(/^remote-peer:[a-zA-Z0-9_-]{1,64}$/u),wf=G([`relay`,`tailscale`,`lan`,`custom`]),Tf=[`blue`,`purple`,`cyan`,`green`,`amber`,`rose`,`slate`],Ef=G(Tf);new Set(Tf);let Df=G([`connected`,`connecting`,`auth-error`,`offline`,`disabled`]),Of=U({peerId:xf,hostId:Cf,nodeId:Sf.optional(),name:z().min(1).max(120),color:Ef.optional(),origin:z().min(1).max(2048),transportKind:wf,encrypted:V(),enabled:V(),state:Df,supportsPeerPairing:V().optional(),pairedBack:V().optional(),linkedPeerIds:H(xf).max(128).optional(),latencyMs:B().int().nonnegative().optional(),version:z().max(128).optional(),platform:z().max(64).optional(),hostname:z().max(255).optional(),homeDir:z().max(4096).optional(),lastError:z().max(1e3).optional(),projectCount:B().int().nonnegative(),createdAt:z(),updatedAt:z()});U({localPlatform:z().max(64).optional(),peers:H(Of)}),U({connectionUrl:z().min(1).max(4096).optional(),origin:z().min(1).max(2048).optional(),token:z().min(1).max(2048).optional(),name:z().trim().min(1).max(120).optional(),color:Ef.optional(),pairBack:V().optional(),meshPeerIds:H(xf).max(64).optional(),selfOrigin:z().min(1).max(2048).optional()}).refine(e=>!!e.connectionUrl||!!e.origin&&!!e.token,`Provide either connectionUrl or both origin and token`),W({origin:z().min(1).max(2048),token:z().min(1).max(2048),name:z().trim().min(1).max(120).optional(),color:Ef.optional(),expectedNodeId:Sf.optional()}),U({status:G([`added`,`updated`,`existing`]),peerId:xf,hostId:Cf,nodeId:Sf.optional()});let kf=G([`added`,`updated`,`existing`,`failed`,`skipped`]);U({results:H(U({targetPeerId:xf,targetName:z().min(1).max(120),introducedHost:Tc([K(`local`),xf]),introducedName:z().min(1).max(120),status:kf,error:z().max(1e3).optional()}))}),U({peerIds:H(xf).max(64).optional(),includeSelf:V().optional(),includeMesh:V().optional(),selfOrigin:z().min(1).max(2048).optional()}),U({peerId:xf,name:z().trim().min(1).max(120).optional(),color:Ef.nullable().optional(),connectionUrl:z().min(1).max(4096).optional(),origin:z().min(1).max(2048).optional(),token:z().min(1).max(2048).optional(),enabled:V().optional()}),U({peerId:xf}),U({removed:V()}),U({peerId:xf.optional(),connectionUrl:z().min(1).max(4096).optional(),origin:z().min(1).max(2048).optional(),token:z().min(1).max(2048).optional()}).refine(e=>!!e.peerId||!!e.connectionUrl||!!e.origin&&!!e.token,`Provide peerId, connectionUrl, or both origin and token`);let Af=U({id:z().min(1).max(1024),name:z().min(1).max(512),path:z().min(1).max(8192)});U({ok:V(),nodeId:Sf.optional(),supportsPeerPairing:V().optional(),pairedBack:V().optional(),latencyMs:B().int().nonnegative().optional(),origin:z().max(2048).optional(),transportKind:wf.optional(),encrypted:V().optional(),version:z().max(128).optional(),platform:z().max(64).optional(),hostname:z().max(255).optional(),homeDir:z().max(4096).optional(),projectCount:B().int().nonnegative().optional(),projects:H(Af).optional(),error:z().max(1e3).optional()});let jf=U({id:z().min(1).max(1024),name:z().min(1).max(512),path:z().min(1).max(8192),threadIds:H(z().min(1).max(1024))}),Mf=U({attachments:K(1).optional(),workspaceFiles:K(1).optional(),officePreview:K(1).optional(),delegation:K(1).optional(),peerPairing:K(1).optional()}),Nf=U({version:z().max(128),platform:z().max(64),hostname:z().max(255),homeDir:z().max(4096).optional(),epoch:z().min(1).max(256),nodeId:Sf.optional(),peerNodes:Nc(Cf,Sf).refine(e=>Object.keys(e).length<=128).optional(),projects:H(jf),capabilities:Mf.optional()});W({threadId:z().min(1).max(1024),scope:z().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u).optional(),requestId:z().min(1).max(256).optional(),mode:G([`queue`,`steer`]).optional(),expectedTurnId:z().min(1).max(1024).nullable().optional(),content:H(Dc(`type`,[W({type:K(`text`),text:z()}),W({type:K(`file`),receiptId:z().min(1).max(128)})])).min(1).max(64)});let Pf=U({ok:K(!1),error:U({code:z(),message:z(),details:Nc(z(),yc()).optional()})});Tc([U({ok:K(!0),value:U({receiptId:z().min(1),file:U({attachmentId:z(),name:z(),bytes:B().int().nonnegative()})})}),Pf]),Tc([U({ok:K(!0),value:U({accepted:K(!0)})}),Pf]);let Ff=U({name:z().min(1).max(512),path:z().min(1).max(8192),kind:K(`directory`)});U({peerId:xf,path:z().min(1).max(8192).optional()}),U({path:z().min(1).max(8192),parentPath:z().min(1).max(8192).nullable(),homeDir:z().min(1).max(8192).optional(),entries:H(Ff)}),U({peerId:xf,parentPath:z().min(1).max(8192),name:z().min(1).max(255).refine(e=>e.trim().length>0,`Directory name cannot be blank`)}),U({path:z().min(1).max(8192),name:z().min(1).max(255)}),U({peerId:xf,path:z().min(1).max(8192),title:z().trim().min(1).max(255).optional()}),U({peerId:xf,workspaceId:z().min(1).max(1024),title:z().trim().min(1).max(255)}),U({peerId:xf,workspaceId:z().min(1).max(1024)}),U({workspaceId:z().min(1).max(1024).optional(),manifest:Nf}),U({sessionHostId:z().min(1).max(128).optional()}),U({hosts:H(U({hostId:Tc([K(`local`),Cf]),name:z().min(1).max(120),isLocal:V().optional(),color:Ef.optional(),hostname:z().max(255).optional()}))}),U({hostId:Tc([K(`local`),Cf])}),U({harnesses:H(U({id:z().regex(/^[a-z0-9][a-z0-9-]*$/u),name:z().min(1).max(120)}))});let If=G([`listHarnesses`,`inspect`,`start`,`send`,`cancel`,`read`,`answer`,`list`]);W({operation:If,hopCount:B().int().min(0).max(16),sourceId:xf.optional(),input:hl});let Lf=W({code:z().min(1).max(128),message:z().max(4096),details:hl.optional()});Tc([W({ok:K(!0),value:ml}),W({ok:K(!1),error:Lf})]);let Rf=W({id:z().min(1).max(1024),name:z().min(1).max(512),path:z().min(1).max(8192)});W({hosts:H(W({hostId:Cf,nodeId:Sf.optional(),displayName:z().min(1).max(120),online:V(),state:Df,delegation:V(),projects:H(Rf),platform:z().max(64).optional(),hostname:z().max(255).optional(),homeDir:z().max(4096).optional()}))}),W({version:K(1),instanceId:z().min(1).max(128),pid:B().int().positive(),endpoint:z().min(1).max(256),token:z().regex(/^[0-9a-f]{64}$/u),startedAt:B().int().nonnegative()}),Tc([W({operation:K(`hosts`)}),W({operation:If,hostId:Cf,hopCount:B().int().min(0).max(16),timeoutMs:B().int().min(1).max(12e4).optional(),input:hl})]);let zf=U({id:z().min(1).max(256),harnessId:z().min(1),label:z().min(1).max(512),provider:G([`openai-codex`,`xai`])}).strict(),Bf=z().regex(/^[a-z][a-z0-9-]{0,47}$/),Vf=U({name:Bf,source:zf,importedAt:z()}).strict(),Hf=Dc(`action`,[U({action:K(`list`)}).strict(),U({action:K(`import`),sourceId:z().min(1).max(256),name:Bf,confirmed:K(!0)}).strict(),U({action:K(`reimport`),sourceId:z().min(1).max(256),name:Bf,confirmed:K(!0)}).strict(),U({action:K(`remove`),name:Bf,confirmed:K(!0)}).strict()]),Uf=U({provider:z().min(1).max(128),type:G([`oauth`,`api_key`,`unknown`]),label:z().min(1).max(512).optional(),vendor:G([`openai-codex`,`xai`]).optional()}).strict();U({sources:H(zf),targets:H(U({harnessId:z(),providers:H(G([`openai-codex`,`xai`])),imports:H(Vf),others:H(Uf).default([])}).strict())}).strict(),U({targetHarnessId:z().min(1).max(128).optional(),request:Hf}).strict(),U({events:V()});let Wf=H(W({agent:z().min(1).max(128),section:G([`main`,`more`,`auto`])})).max(256).refine(e=>new Set(e.map(e=>e.agent)).size===e.length,`Duplicate Harness IDs`);W({entries:Wf.nullable()}),W({}),W({entries:Wf,initializeOnly:V().optional()});let Gf=W({enabled:V(),timeoutMinutes:B().int().min(5).max(1440)});Object.freeze({enabled:!0,timeoutMinutes:10});let Kf=z().regex(/^external$/u),qf=Sl.transform(e=>String(e)),Jf=W({model:Kl.optional(),thinkingOptionId:Jl.optional(),permissionModeId:Tl.optional()}).refine(e=>!!(e.model||e.thinkingOptionId||e.permissionModeId),`A default configuration must contain a preference`);Dc(`mode`,[W({mode:K(`global`)}),W({mode:K(`last`)}),W({mode:K(`manual`),harnessId:Sl})]);let Yf=W({lastHarness:Sl.optional(),byHarness:Nc(qf,Jf)}),Xf=W({model:Kl.optional(),thinkingOptionId:Jl.optional()}).refine(e=>!!(e.model||e.thinkingOptionId),`A delegation default must contain a Model or Thinking option`),Zf=W({byHarness:Nc(qf,Xf)}),Qf=z().min(1).max(1024),$f=W({idleRelease:Gf.optional(),favorites:Nc(qf,H(Qf).max(2048)).default({}),newThread:Yf.optional(),delegation:Zf.optional()});W({scope:Kf,revision:B().int().nonnegative(),values:$f}),W({scope:Kf.default(`external`)});let ep=Dc(`kind`,[W({kind:K(`idleRelease`),value:Gf}),W({kind:K(`favorite`),harnessId:Sl,modelId:Qf,enabled:V()}),W({kind:K(`favorites`),harnessId:Sl,modelIds:H(Qf).max(2048)}),W({kind:K(`newThread`),lastHarness:Sl.optional(),harnessId:Sl.optional(),configuration:Jf.optional()}),W({kind:K(`delegation`),harnessId:Sl,configuration:Xf.nullable()})]);W({scope:Kf.default(`external`),operations:H(ep).min(1).max(256),initializeOnly:V().optional(),expectedRevision:B().int().nonnegative().optional()}).superRefine((e,t)=>{for(let n of e.operations)n.kind===`newThread`&&(!n.lastHarness&&!n.configuration||!!n.harnessId!=!!n.configuration)&&t.addIssue({code:`custom`,message:`A default Harness or complete configuration is required`})}),W({version:K(1),revision:B().int().nonnegative(),scopes:Nc(Kf,$f)});let tp=B().finite().nonnegative(),np=W({input:tp,output:tp,cacheRead:tp.optional(),cacheWrite:tp.optional(),cacheWrite1h:tp.optional()}),rp=z().max(512).refine(e=>e.trim()===e&&e.length>0,`Model ID is required`);W({path:z(),entries:H(W({key:z(),price:np})),error:z().nullable()}),W({}),W({key:rp,price:np.nullable(),previousKey:rp.optional()}),W({model:rp});let ip=W({official:V().optional(),canonicalModelId:z().min(1).optional(),provider:z().min(1).max(512),model:z().min(1).max(512),price:np});W({price:np.nullable(),suggestions:H(ip).max(6).optional()});let ap=[`today`,`7d`,`30d`,`90d`,`all`],op=B().int().min(0).max(2**53-1),sp=z().regex(/^\d{4}-\d{2}-\d{2}$/u),cp=z().min(1).max(128),lp=z().min(1).max(512),up=z().min(1).max(4096);W({range:G(ap),timeZone:z().min(1).max(128).refine(e=>{try{return new Intl.DateTimeFormat(`en`,{timeZone:e}),!0}catch{return!1}},`Unsupported usage statistics timezone`).optional(),harness:cp.optional(),model:lp.nullable().optional(),project:up.nullable().optional(),date:sp.optional()});let dp=W({requests:op,inputTokens:op,cachedInputTokens:op,cacheWriteInputTokens:op,cacheKnownInputTokens:op,cacheHitCachedInputTokens:op,cacheHitInputTokens:op,outputTokens:op,reasoningOutputTokens:op,costUsd:B().finite().min(0),unpricedRequests:op,unmeteredRequests:op}),fp=dp.shape,pp=W({harness:cp,sessionId:z().min(1).max(512),project:up.nullable(),title:z().min(1).max(200).optional(),models:H(lp).max(16),firstAtMs:op,lastAtMs:op,...fp});W({range:G(ap),from:sp.nullable(),to:sp,filters:W({harness:cp.nullable(),model:lp.nullable(),unknownModel:V(),project:up.nullable(),unknownProject:V(),date:sp.nullable()}),reading:W({complete:V(),sources:op,read:op}),failures:H(W({harness:cp,message:z().max(2048)})).max(256),options:W({harnesses:H(cp).max(256),models:H(lp.nullable()).max(4096),projects:H(up.nullable()).max(4096)}),modelLabels:H(W({harness:cp,model:lp,label:lp})).max(4096).optional(),credits:H(W({harness:cp,model:lp.nullable(),credits:B().finite().min(0),reportedRequests:op,requests:op})).max(4096).optional(),totals:dp,daily:H(W({date:sp,harness:cp,...fp})).max(2e5),hourly:H(W({weekday:B().int().min(0).max(6),hour:B().int().min(0).max(23),...fp})).max(168),byHarness:H(W({harness:cp,...fp})).max(256),byModel:H(W({model:lp.nullable(),...fp,harnessPricedRequests:op})).max(4096),byProject:H(W({project:up.nullable(),...fp})).max(4096),sessions:H(pp).max(100),recentSessions:H(pp).max(100).optional()}),U({threadId:q}),U({discarded:V()});let mp=Dc(`type`,[U({id:z().min(1),type:K(`choice`),prompt:z(),options:H(U({value:z().min(1),label:z(),description:z().optional()})).min(1),multiple:V(),allowOther:V(),optional:V()}),U({id:z().min(1),type:K(`text`),prompt:z(),multiline:V(),secret:K(!1),optional:V(),placeholder:z().optional(),prefill:z().optional()})]),hp=U({interactionId:z().min(1),turnId:z().min(1),title:z().optional(),questions:H(mp).min(1)}).refine(({questions:e})=>e.some(e=>e.type===`choice`&&e.multiple),{message:`Shared cards require at least one multi-select question`});W({threadId:z().min(1)}),U({questions:H(hp)}),W({threadId:z().min(1),turnId:z().min(1),interactionId:z().min(1),answers:Nc(z(),H(z())),cancelled:V().default(!1)}),U({accepted:K(!0)});let gp=U({path:z(),oldText:z().nullable(),newText:z()});U({sessionId:z().min(1),turn:B().int().nonnegative(),path:z().min(1).optional()}),U({diffs:H(gp)}),W({}),W({}),U({reference:U({sessionId:z().min(1),epoch:z().min(1),turn:B().int().nonnegative(),seq:B().int().nonnegative(),callId:z().min(1),part:B().int().nonnegative(),version:z().min(1)}),length:B().int().nonnegative(),bytes:B().int().nonnegative()}),W({title:z().trim().min(1).max(200),type:G([`info`,`warning`,`danger`]),body:z().trim().min(1).max(16384)}),W({}),W({url:z().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)}),Object.freeze(/* @__PURE__ */ `codexhost/console/remote-connections.codexhost/runtime/status.codexhost/remote/ssh-setup.codexhost/harness/plugins/list.codexhost/harness/display-settings/capabilities.codexhost/harness/display-settings/get.codexhost/harness/display-settings/set.codexhost/harness/inspect.codexhost/harness/installation.codexhost/harness/installation/start.codexhost/harness/installation/status.codexhost/harness/launch-settings/get.codexhost/harness/launch-settings/set.codexhost/harness/web-ui/open.codexhost/harness/accounts/sources.codexhost/harness/accounts/list.codexhost/harness/accounts/inspect.codexhost/harness/credential-imports.codexhost/harness/session-import/sources.codexhost/harness/session-import/list.codexhost/harness/session-import/import.codexhost/account/list.codexhost/account/refresh.codexhost/account/usage/inspect.codexhost/usage/model-prices/get.codexhost/usage/model-prices/set.codexhost/usage/model-prices/default.codexhost/usage/statistics/get.codexhost/update/check.codexhost/update/start.codexhost/update/status.codexhost/update/macos-signing/status.codexhost/update/macos-signing/setup.codexhost/update/macos-signing/remove`.split(`.`));let _p=G([`idle`,`running`,`busy`,`closing`,`failed`,`blocked`]),vp=G([`none`,`disabled`,`timeout`,`operation`,`background`,`identity`,`persistence`,`closeFailed`]);W({threadId:z(),title:z(),harnessId:z(),state:_p,reason:vp,inactiveMs:B().nonnegative()}),W({threadId:q,turnId:Cl});let yp=U({email:z().trim().min(1).max(320).optional(),label:z().trim().min(1).max(256).optional(),plan:z().trim().min(1).max(128).optional(),credits:Vl.optional(),balance:Hl.optional()}).strict();function bp(e){return e.refine(e=>{let t=e;return t.credits!==void 0||t.balance!==void 0},{message:`Account must report either credits or a balance`})}let xp=bp(yp),Sp={harnessId:Sl,harnessName:z().trim().min(1).max(128)},Cp=U(Sp).strict();U({}).strict(),U({sources:H(Cp).max(128)}).strict(),U({harnessId:Sl,refresh:V().optional()}).strict(),U({...Sp,account:xp.nullable(),accounts:H(xp).max(8).optional()}).strict(),U({refresh:V().optional()}).strict(),U({accounts:H(bp(yp.extend(Sp))).max(128)}).strict(),U({harnessId:lu,model:Kl.optional(),thinkingOptionId:Jl.optional(),permissionModeId:Tl.optional(),prewarm:K(!0).optional()}).strict();let wp=z().trim().min(1).max(4096).refine(e=>!/[\u0000\r\n]/u.test(e),`Invalid entrypoint path`);U({harnessId:lu}).strict().extend({path:wp.nullable()}),U({path:wp.nullable(),restartRequired:V()}).strict(),U({harnessId:Sl,action:G([`check`,`update`,`install`]),confirmedVersion:z().min(1).max(128).optional()}).strict().refine(({action:e,confirmedVersion:t})=>e===`update`||t===void 0);let Tp=U({currentVersion:z().min(1).max(128),latestVersion:z().min(1).max(128),updateAvailable:V(),canUpdate:V(),latestVerifiedVersion:z().min(1).max(128).optional(),confirmationRequired:K(!0).optional(),versionKind:G([`cli`,`application`]).optional(),manualUpdateUrl:Xs().max(2048).refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Manual updates require a credential-free HTTPS URL`).optional(),message:z().max(2048).optional(),messageCode:z().min(1).max(128).optional(),notice:bl.optional(),latestVersionKind:G([`unknown`,`tracking-branch`]).optional()}).strict();U({taskId:z().uuid()}).strict(),Dc(`status`,[U({taskId:z().uuid(),status:K(`running`)}).strict(),U({taskId:z().uuid(),status:K(`succeeded`),result:Tp}).strict(),U({taskId:z().uuid(),status:K(`failed`),error:U({code:B().int(),message:z().min(1).max(2048)}).strict()}).strict()]);let Ep=z().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u),Dp=z().trim().min(1),Op=G([`free`,`go`,`plus`,`pro`,`prolite`,`team`,`self_serve_business_prolite`,`self_serve_business_usage_based`,`business`,`ent26`,`enterprise_cbp_automation`,`enterprise_cbp_usage_based`,`enterprise`,`edu`,`edu_plus`,`edu_pro`,`unknown`]),kp=U({accountId:Ep,label:Dp.max(256),email:z().email().max(320).optional(),planType:Op.optional()}).strict(),Ap=G([`ready`,`unavailable`]);U({version:K(2),currentAccountId:Ep.nullable(),phase:Ap,revision:B().int().nonnegative(),instanceId:Dp.max(1024).optional(),accounts:H(kp).max(1)}).strict(),U({accountId:Ep,refresh:V().optional()}).strict(),U({accountId:Ep,usage:Fl.nullable(),accountCredits:Vl.optional(),freshness:G([`live`,`cached`]),observedAt:z().datetime().nullable()}).strict();let jp=1e3,Mp=z().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),Np=Mp.max(1024),Pp=U({nativeSessionId:Np,title:Mp.max(4096).nullable(),updatedAt:B().int().nonnegative().max(864e13),cwd:Mp.max(16384),running:V().nullable()}).strict();U({}).strict(),U({harnesses:H(U({harnessId:lu,name:Mp.max(128)}).strict()).max(128)}).strict(),U({harnessId:lu,query:z().trim().max(4096).refine(e=>!e.includes(`\0`)).optional(),offset:B().int().nonnegative().safe().optional(),limit:B().int().min(1).max(jp).optional()}).strict(),U({candidates:H(Pp).max(jp),total:B().int().nonnegative().safe()}).strict(),U({harnessId:lu,nativeSessionId:Np}).strict(),U({threadId:Mp.max(1024).pipe(q)}).strict();let Fp=z().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),Ip=Np,Lp=Pp;U({}).strict(),U({candidates:H(Lp).max(1e3)}).strict(),U({nativeSessionId:Ip}).strict(),U({threadId:Fp.max(1024).pipe(q)}).strict(),U({threadId:q,lastTurnId:Cl}).strict(),U({threadId:q}).strict();let Rp=z().trim().min(1).max(128).regex(/^[A-Za-z0-9._:-]+$/u).brand();U({commands:H(U({id:Rp,invocation:z().min(1).max(128),label:z().trim().min(1).max(128),description:z().trim().min(1).max(512).optional(),localizations:yl.optional(),argumentMode:G([`none`,`text`]),kind:G([`command`,`skill`]).optional()}).strict()),warnings:H(z().min(1)).optional(),source:G([`live`,`static`]).optional()}).strict().superRefine((e,t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.commands.entries())n.has(i.id)&&t.addIssue({code:`custom`,message:`Harness command IDs must be unique`,path:[`commands`,r,`id`]}),n.add(i.id)}),U({harnessId:Sl,cwd:z().min(1).optional()}).strict(),U({threadId:q}).strict(),U({threadId:q,commandId:Rp,turnId:Cl.optional(),arguments:hl.optional()}).strict(),U({accepted:K(!0),turnId:Cl.optional()}).strict();let zp=K(`2.0`).optional(),Bp=xc().optional(),Vp=z().min(1),Hp=Tc([z(),B().int()]),Up=U({code:B().int(),message:z(),data:ml.optional()}).catchall(ml).superRefine(ll([`data`]));Tc([U({jsonrpc:zp,id:Hp,method:Vp,params:ml.optional(),result:Bp,error:Bp}).catchall(ml).superRefine(ll([`jsonrpc`,`params`,`result`,`error`])),U({jsonrpc:zp,id:Bp,method:Vp,params:ml.optional(),result:Bp,error:Bp}).catchall(ml).superRefine(ll([`jsonrpc`,`id`,`params`,`result`,`error`])),U({jsonrpc:zp,id:Hp,method:Bp,params:Bp,result:ml,error:Bp}).catchall(ml).superRefine(ll([`jsonrpc`,`method`,`params`,`error`])),U({jsonrpc:zp,id:Hp,method:Bp,params:Bp,result:Bp,error:Up}).catchall(ml).superRefine(ll([`jsonrpc`,`method`,`params`,`result`]))]);let Wp=z().refine(e=>e.trim().length>0,{message:`Native identifier must not be empty or whitespace`});W({harnessId:Sl,nativeSessionId:Wp,locator:ml.optional(),formatVersion:K(1)}).superRefine(ll([`locator`])),W({harnessId:Sl,nativeSessionId:Wp,nativeTurnKey:Wp,formatVersion:K(1)}),W({harnessId:Sl,nativeSessionId:Wp,checkpointId:Wp,locator:ml.optional(),formatVersion:K(1)}).superRefine(ll([`locator`]));let Gp=z().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u),Kp=G([`npm`,`windows-installer`,`macos-dmg`,`linux-archive`]),qp=G([`prepared`,`downloading`,`waiting-for-exit`,`installing`,`restarting`,`succeeded`,`failed`]),Jp=W({completed:B().int().nonnegative(),total:B().int().positive()}).refine(e=>e.completed<=e.total,{path:[`completed`],message:`completed must not exceed total`}),Yp=W({version:Gp,installation:Kp,phase:qp,updatedAt:B().int().nonnegative(),downloadedBytes:B().int().nonnegative().optional(),totalBytes:B().int().positive().optional(),npmDownload:Jp.optional(),error:z().min(1).max(500).nullable(),serviceStopOutput:z().optional()}).superRefine((e,t)=>{e.downloadedBytes!==void 0&&e.totalBytes!==void 0&&e.downloadedBytes>e.totalBytes&&t.addIssue({code:`custom`,path:[`downloadedBytes`],message:`downloadedBytes must not exceed totalBytes`})});W({});let Xp=z().max(300).regex(/^https:\/\/github\.com\/BytePioneer-AI\/codex-host\/releases\/tag\/v[0-9A-Za-z.+-]+$/u,`release notes URL must identify a codexhost GitHub Release`),Zp=G([`idle`,`downloading`,`ready`,`failed`]),Qp=W({downloadedBytes:B().int().nonnegative(),totalBytes:B().int().positive()}).refine(e=>e.downloadedBytes<=e.totalBytes,{path:[`downloadedBytes`],message:`downloadedBytes must not exceed totalBytes`});U({currentVersion:Gp,installation:Kp.nullable(),latestVersion:Gp.nullable(),updateAvailable:V(),installationAvailable:V(),releaseNotes:z().min(1).max(2e4).nullable(),releaseNotesUrl:Xp.nullable(),status:Yp.nullable(),error:z().min(1).max(500).nullable(),stagedVersion:Gp.nullable().optional(),backgroundPhase:Zp.optional(),backgroundDownload:Qp.nullable().optional(),backgroundError:z().min(1).max(500).nullable().optional(),runningTaskCount:B().int().nonnegative().optional()}),W({status:Yp}),W({status:Yp.nullable()}),W({supported:V(),enabled:V(),certificatePresent:V(),appSignedWithLocalCert:V(),appPath:z().min(1).nullable(),certificateName:z().min(1),certificateSha1:z().regex(/^[0-9A-Fa-f]{40}$/u).nullable()});let $p=W({icon:z().min(1).max(16).optional(),title:z().min(1).max(120),body:z().min(1).max(1200),contributors:H(z().min(1).max(39)).max(30)}),em=W({summary:z().min(1).max(600).optional(),themes:H($p).min(1).max(12)}),tm=W({version:Gp,publishedAt:cl(),url:z().max(300).regex(/^https:\/\/github\.com\/BytePioneer-AI\/codex-host\/releases\/tag\/v[0-9A-Za-z.+-]+$/u),zh:em.nullable(),en:em.nullable()}).refine(e=>e.zh!==null||e.en!==null,{message:`an announcement needs at least one language`});W({manual:V().optional()}),W({announcement:tm.nullable(),unread:V()}),W({version:Gp});let nm=RegExp(String.raw`^- \[([^\]\n]+)\]\(thread://([^\s()<>"?#/]+)\): `+`(${[`completed`,`failed`,`interrupted`,`needsInput`,`timedOut`,`unreadable`,`notFound`].join(`|`)})(?:\. (.+))?$`,`u`);function rm(e){let[t,...n]=e.trim().split(/\r?\n/u);if(t!==`[codexhost thread watch] Read each Thread's result, then continue your task:`)return;let r=[];for(let e of n){if(!e.trim())continue;let t=nm.exec(e);if(!t)return;let[,n=``,i=``,a,o]=t;r.push({threadId:i,label:n,outcome:a,...o?{note:o}:{}})}return r.length>0?r:void 0}let im=`<response-annotations>`,am=`</response-annotations>`,om=/## My request(?: for Codex)?:/gu;function sm(e){if(e.length===0)return``;let t=e.map(({text:e,annotation:t})=>({text:e,...t===void 0?{}:{annotation:t}}));return`\n# Response annotations:\nEach item contains text selected from an earlier Codex response and may include a user comment. Treat items as Annotation 1, Annotation 2, and so on in array order. Use every selection as context and address every comment. For every annotation you address, include its inline directive \`:codex-annotation{index="N"}\`, where N is its one-based array position (for example, \`:codex-annotation{index="1"}\`). Do not use unstructured annotation labels.\n${im}\n${JSON.stringify(t)}\n${am}\n`}function cm(e,t){let n=sm(e);return n===``?t:`${n}\n## My request:\n${t}\n`}function lm(e){let t=e.trimStart().startsWith(`# Response annotations:`)?0:e.length,n=e.indexOf(`\n${im}\n`,t);if(n<0)return;let r=n+1+22+1,i=e.indexOf(`\n${am}`,r);if(!(i<0))return{json:e.slice(r,i),closeEnd:i+1+23}}function um(e){return{annotations:mm(e),body:dm(e)}}function dm(e){let t=0;for(let n of e.matchAll(om))t=n.index+n[0].length;return e.slice(t).trim()}function fm(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function pm(e){if(e===``)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!Array.isArray(t)||t.length===0)return[];let n=[];for(let e of t){if(!fm(e))return[];let{text:t,annotation:r}=e;if(typeof t!=`string`||t.length===0||r!==void 0&&(typeof r!=`string`||r.length===0))return[];n.push({text:t,...r===void 0?{}:{annotation:r}})}return n}function mm(e){let t=lm(e);return t===void 0?[]:pm(t.json)}function hm(e){return mm(e)}let gm=G([`idle`,`installing`,`restarting`,`succeeded`,`failed`]);U({runningVersion:z().nullable(),installedVersion:z().nullable(),restartRequired:V(),remote:V(),updateSupported:V(),update:U({phase:gm,targetVersion:z().nullable(),error:z().nullable()})});let _m=U({version:z().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)}).strict();U({hostname:z().min(1).max(1024).refine(e=>!e.startsWith(`-`)&&!/\s/u.test(e)),port:B().int().min(1).max(65535).nullable(),identity:z().max(4096).nullable(),action:G([`inspect`,`install`,`update`,`repair`,`uninstall`]),uninstallPackage:V().optional(),version:z().regex(/^\d+\.\d+\.\d+$/u).nullable()}).strict(),U({state:G([`installed`,`not-installed`])}).strict();let J=z().min(1).max(1024),vm={hostId:J.regex(/^(?:remote-(?:ssh(?:-|:)|control:)|remote-peer:[a-zA-Z0-9_-]{1,64}$)/u)},ym={...vm,threadId:J},bm=z().min(1).max(8e3),xm={text:bm,requestId:J};Dc(`accepted`,[U({accepted:K(!0),startQueuedItemId:J.optional()}),U({accepted:K(!1),code:G([`remote/queue-unavailable`,`remote/steer-unavailable`,`remote/turn-changed`,`remote/send-rejected`,`session/queue-item-not-found`,`session/queue-item-starting`]),message:z()})]),Dc(`available`,[U({available:K(!1)}),U({available:K(!0),items:H(U({id:J,clientUserMessageId:J,preview:z().max(801)})).max(100)})]);let Sm=Dc(`kind`,[W({kind:K(`hosts`)}),W({kind:K(`create`),...vm,cwd:z().min(1).max(8192),epoch:J}),W({kind:K(`projectHarnesses`),...vm,epoch:J}),W({kind:K(`inspectHarness`),...vm,epoch:J,cwd:z().min(1).max(8192),harnessId:J}),W({kind:K(`startSelected`),...vm,epoch:J,cwd:z().min(1).max(8192),harnessId:J,model:z().min(1).max(4096),serviceTier:G([`priority`,`ultrafast`]).optional(),reasoningEffort:J.optional()}),W({kind:K(`status`),...ym}),W({kind:K(`list`),...vm,cursor:z().nullable(),archived:V(),includeLoaded:K(!0).optional()}),W({kind:K(`read`),...ym,page:W({cursor:z().min(1).max(8192).nullable(),epoch:J.optional(),sortDirection:G([`asc`,`desc`]).optional(),limit:B().int().min(1).max(20).optional()}).refine(e=>e.cursor===null||e.epoch!==void 0,{message:`A history continuation requires its connection epoch`}).optional()}),W({kind:K(`usage`),...ym,epoch:J}),W({kind:K(`configure`),...ym,epoch:J,modelId:J.optional(),serviceTier:Gl.optional(),thinkingOptionId:J.optional(),permissionModeId:J.optional()}).refine(e=>[e.modelId,e.thinkingOptionId,e.permissionModeId].filter(e=>e!==void 0).length===1,`Select exactly one remote setting`).refine(e=>e.serviceTier===void 0||e.modelId!==void 0,{message:`A service tier requires a Model ID`}),W({kind:K(`prompt`),...ym,epoch:J,text:bm,requestId:J.optional()}),W({kind:K(`queue`),...ym,epoch:J}),W({kind:K(`delivery`),...ym,epoch:J,action:Dc(`kind`,[W({kind:K(`enqueue`),...xm}),W({kind:K(`steer`),...xm,turnId:J}),W({kind:K(`remove`),itemId:J}),W({kind:K(`start`),itemId:J,onlyIfHead:K(!0).optional()}),W({kind:K(`sendNow`),itemId:J})])}),W({kind:K(`interrupt`),...ym,epoch:J,turnId:J}),W({kind:K(`rename`),...ym,epoch:J,name:z().min(1).max(512)}),W({kind:K(`archive`),...ym,epoch:J,archived:V()}),W({kind:K(`respond`),...ym,epoch:J,requestId:Tc([J,B().int()]),result:Nc(z(),yc())})]),Cm=z().min(1).max(1024),wm=U({hostId:Cm,displayName:z().min(1).max(1024),source:G([`codex-managed`,`discovered`]),sshAlias:z().max(1024).nullable(),sshHost:z().min(1).max(1024),sshPort:B().int().min(1).max(65535).nullable(),identity:z().max(4096).nullable(),autoConnect:V(),connectionAnalyticsId:z().max(1024).optional()}),Tm=W({displayName:z().min(1).max(1024),hostname:z().min(1).max(1024),sshPort:B().int().min(1).max(65535).nullable(),identity:z().max(4096).nullable()});Dc(`action`,[W({action:K(`session`),operation:Sm}),W({action:K(`list`)}),W({action:K(`catalog`)}),W({action:K(`read-thread`),hostId:Cm.refine(e=>e!==`local`),input:yf}),W({action:K(`save`),draft:Tm,previous:wm.nullable()}),W({action:K(`remove`),previous:wm}),W({action:K(`connect`),hostId:Cm,enabled:V()}),W({action:K(`state`),hostId:Cm}),W({action:K(`runtime`),hostId:Cm}),W({action:K(`update`),hostId:Cm.refine(e=>e!==`local`),version:_m.shape.version})]),Tc([W({result:ml}),W({error:W({code:B().int(),message:z()})})]),W({prompt:z().trim().min(1).max(2e3),cwd:z().max(4096).nullable()}),z().trim().min(1).max(60).nullable();let Em=z().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u),Dm=Tc([z(),U({en:z()}).catchall(z())]),Om=U({title:Dm.optional(),description:Dm.optional(),icon:z().max(349592).regex(/^data:image\/(?:svg\+xml|png|jpeg|webp);base64,[A-Za-z0-9+/]*={0,2}$/u).optional(),error:z().optional()});U({extensions:H(U({id:Em,name:z().min(1).max(214),version:z().min(1).max(128),format:K(`dsh`),supportedTargets:jc([K(`web`)]),enabledTargets:H(K(`web`)).max(1),source:z().min(1).max(4096),projectUrl:z().max(4096).url({protocol:/^https?$/u}).optional(),installedAt:z(),meta:Om.optional(),loadError:z().optional()})),loadedIds:H(Em),safeMode:V(),storeError:z().optional()});let km=z().trim().max(2048).url({protocol:/^https?$/u,normalize:!0}).refine(e=>!/[\s\\?#]/u.test(e)&&!e.split(`/`)[2]?.includes(`@`),`Use an HTTP(S) registry URL without credentials, a query, or a fragment.`).transform(e=>e.endsWith(`/`)?e:`${e}/`);U({spec:z().trim().min(1).max(4096),registry:km.optional()}).strict(),U({id:Em,enabled:V()}).strict(),U({id:Em}).strict(),K(1);function Am(e){return{code:{copyLabel:e(`copy`),copiedLabel:e(`copied`),toolbarLabels:{codeLabel:e(`codeBlock.title`),wrapLabel:e(`codeBlock.wrap`),unwrapLabel:e(`codeBlock.unwrap`)}},footnotes:e(`markdown.footnotes`),mermaid:{expand:e(`markdown.mermaid.expand`),close:e(`markdown.mermaid.close`),zoomIn:e(`markdown.mermaid.zoomIn`),zoomOut:e(`markdown.mermaid.zoomOut`),fit:e(`markdown.mermaid.fit`),download:e(`markdown.mermaid.download`),downloading:e(`markdown.mermaid.downloading`),downloadFailed:e(`markdown.mermaid.downloadFailed`),diagram:e(`markdown.mermaid.diagram`),source:e(`markdown.mermaid.source`),failed:e(`markdown.mermaid.failed`)}}}function jm(e){return{label:t=>e(`annotation.label`,{index:t}),railLabel:t=>e(`annotation.chipLabel`,{index:t}),railTitle:(t,n)=>e(`annotation.title`,{index:t,excerpt:n}),remove:t=>e(`annotation.remove`,{index:t}),selectedText:e(`annotation.selectedText`),userComment:e(`annotation.userComment`),editPlaceholder:e(`selection.commentPlaceholder`),save:e(`annotation.save`),cancel:e(`message.edit.cancel`),removeAction:e(`annotation.removeAction`)}}let Mm=`@deepseek-ai/dsh-client-ui-chat/ThreadWatchNotice.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Mm)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Mm,e.textContent=`._5b1uNW_card{box-sizing:border-box;border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-bg-base);width:fit-content;max-width:100%;color:var(--dsw-alias-label-secondary);font-size:var(--dsh-content-font-size-secondary,13px);align-items:flex-start;gap:10px;padding:10px 14px;line-height:20px;display:flex}._5b1uNW_list{min-width:0;margin:0;padding:0;list-style:none}._5b1uNW_entry+._5b1uNW_entry{margin-top:10px}._5b1uNW_line{align-items:center;gap:8px;min-width:0;display:flex}._5b1uNW_line>svg,._5b1uNW_bell{flex-shrink:0}._5b1uNW_bell{color:var(--dsw-alias-label-tertiary);margin-top:3px}._5b1uNW_title,._5b1uNW_titleLink{text-overflow:ellipsis;white-space:nowrap;min-width:0;color:var(--dsw-alias-label-primary);overflow:hidden}._5b1uNW_titleLink{text-decoration:none}._5b1uNW_titleLink:hover{text-decoration:underline}._5b1uNW_titleLink:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:2px;border-radius:2px}._5b1uNW_outcome,._5b1uNW_open{white-space:nowrap;flex-shrink:0}._5b1uNW_outcome[data-outcome=completed]{color:var(--dsw-alias-state-success-primary)}._5b1uNW_outcome[data-outcome=failed]{color:var(--dsw-alias-state-error-primary)}._5b1uNW_open a{color:var(--dsw-alias-state-business-primary);text-decoration:none}._5b1uNW_open a:hover{text-decoration:underline}._5b1uNW_open a:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:2px}._5b1uNW_note{color:var(--dsw-alias-label-tertiary);overflow-wrap:anywhere;margin:4px 0 0 24px}@media (width<=480px){._5b1uNW_line{flex-wrap:wrap}._5b1uNW_title,._5b1uNW_titleLink{flex:calc(100% - 52px)}._5b1uNW_outcome{margin-left:24px}}`,document.head.appendChild(e)}var Nm={bell:`_5b1uNW_bell`,card:`_5b1uNW_card`,entry:`_5b1uNW_entry`,line:`_5b1uNW_line`,list:`_5b1uNW_list`,note:`_5b1uNW_note`,open:`_5b1uNW_open`,outcome:`_5b1uNW_outcome`,title:`_5b1uNW_title`,titleLink:`_5b1uNW_titleLink`};let Pm=()=>()=>{};function Fm({entry:e,links:t,sessionId:n,t:r}){let i=e.outcome===`notFound`||n===void 0?void 0:t?.watchTarget?.(n,e.threadId),a=i?.href??`codex://threads/${e.threadId}`,o=()=>t?.describe?.(a)?.title,s=(0,d.useSyncExternalStore)(t?.resolve.subscribe??Pm,o,o),c=s!==void 0,l=s??e.label,u=i===void 0?void 0:e=>{e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),i.open())};return/* @__PURE__ */ (0,f.jsxs)(`li`,{className:Nm.entry,"data-thread-watch-entry":e.threadId,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Nm.line,children:[c?t?.describe?.(a)?.icon:/* @__PURE__ */ (0,f.jsx)(p.ReferenceIconRegular,{kind:`session`,size:14}),i===void 0?/* @__PURE__ */ (0,f.jsx)(`span`,{className:Nm.title,title:l,children:l}):/* @__PURE__ */ (0,f.jsx)(`a`,{className:Nm.titleLink,href:i.sessionUrl,title:l,onClick:u,children:l}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Nm.outcome,"data-outcome":e.outcome,children:r(`message.watch.${e.outcome}`)}),i===void 0?e.outcome!==`notFound`&&c&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:Nm.open,children:/* @__PURE__ */ (0,f.jsx)(p.MarkdownAnchor,{href:a,glyph:!1,children:[r(`message.watch.open`)]})}):/* @__PURE__ */ (0,f.jsx)(`span`,{className:Nm.open,children:/* @__PURE__ */ (0,f.jsx)(`a`,{href:i.sessionUrl,onClick:u,children:r(`message.watch.open`)})})]}),e.note!==void 0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:Nm.note,children:e.note})]})}function Im({entries:e,links:t,sessionId:n,t:r}){return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Nm.card,"data-thread-watch-notice":!0,children:[/* @__PURE__ */ (0,f.jsx)(p.IconBellOutlineRegular,{className:Nm.bell}),/* @__PURE__ */ (0,f.jsx)(`ul`,{className:Nm.list,children:e.map((e,i)=>/* @__PURE__ */ (0,f.jsx)(Fm,{entry:e,links:t,sessionId:n,t:r},i))})]})}let Lm=`@deepseek-ai/dsh-client-ui-chat/MessageItem.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Lm)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Lm,e.textContent=`.h5bUAG_userRow{flex-direction:column;align-items:flex-end;gap:6px;display:flex}.h5bUAG_noticeRow{flex-direction:column;align-items:center;gap:6px;min-width:0;display:flex}.h5bUAG_noticeStack{min-width:0;max-width:100%}.h5bUAG_userStack{min-width:0;max-width:min(calc(var(--dsh-chat-content-width,748px) * .702), 82%);flex-direction:column;align-items:flex-end;gap:8px;display:flex}.h5bUAG_annotationRow{flex-wrap:wrap;justify-content:flex-end;gap:6px;display:flex}.h5bUAG_bubble{background:var(--dsw-specific-bubble);border-radius:var(--dsw-radius-xl);max-width:100%;font-size:var(--dsh-content-font-size,14px);line-height:calc(22px + var(--dsh-content-font-delta,0px));color:var(--dsw-alias-label-primary);white-space:pre-wrap;word-break:break-word;padding:10px 16px}body[data-codexhost-wallpaper] .h5bUAG_bubble{background:color-mix(in srgb, var(--dsw-specific-bubble) 84%, transparent);backdrop-filter:blur(12px)}body[data-codexhost-wallpaper] [data-chat-flow-key]:not([data-chat-flow-key] *,[data-chat-near-viewport]) .h5bUAG_bubble{backdrop-filter:none}@supports (-webkit-touch-callout:none){body[data-codexhost-wallpaper] .h5bUAG_userRow{transform:translateZ(0)}}.h5bUAG_referenceSummary{color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px))}.h5bUAG_contextRow{padding:2px 0}.h5bUAG_compactionRow{--dsh-compaction-header-height:calc(24px + var(--dsh-content-font-delta,0px));padding:2px 0}.h5bUAG_compactionButton{width:100%;height:var(--dsh-compaction-header-height);border-radius:var(--dsw-radius-sm);min-width:0;color:var(--dsw-alias-label-tertiary);font:inherit;text-align:left;background:0 0;border:none;align-items:center;padding:0;transition:color .1s;display:flex}.h5bUAG_compactionRow:has(.h5bUAG_compactionBody) .h5bUAG_compactionButton{z-index:7;background:var(--dsw-alias-bg-base);border-radius:0;position:sticky;top:0}body[data-codexhost-wallpaper] .h5bUAG_compactionRow:has(.h5bUAG_compactionBody) .h5bUAG_compactionButton{background:color-mix(in srgb, var(--dsw-alias-bg-base) 78%, transparent);backdrop-filter:blur(12px)}body[data-codexhost-wallpaper] [data-chat-flow-key]:not([data-chat-flow-key] *,[data-chat-near-viewport]) .h5bUAG_compactionRow:has(.h5bUAG_compactionBody) .h5bUAG_compactionButton{backdrop-filter:none}.h5bUAG_compactionBody :has(>[data-code-block-banner]){top:var(--dsh-compaction-header-height)}@media (hover:hover){.h5bUAG_compactionRow:has(.h5bUAG_compactionBody) .h5bUAG_compactionButton:hover{background:var(--dsw-alias-interactive-bg-hover-solid)}.h5bUAG_compactionButton:hover{color:var(--dsw-alias-label-secondary)}.h5bUAG_compactionButton:not(:disabled):hover{background:var(--dsw-alias-interactive-bg-hover)}}.h5bUAG_compactionButton:not(:disabled){cursor:pointer}.h5bUAG_compactionButton:not(:disabled):active{color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-interactive-bg-hover)}.h5bUAG_compactionLeading{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px));color:inherit;flex:none;place-items:center;margin-right:6px;display:inline-grid}.h5bUAG_compactionLeading svg{width:calc(14px + var(--dsh-content-font-delta,0px));height:calc(14px + var(--dsh-content-font-delta,0px))}.h5bUAG_compactionContextIcon,.h5bUAG_compactionDisclosureIcon{grid-area:1/1;justify-content:center;align-items:center;display:inline-flex}.h5bUAG_compactionDisclosureIcon,.h5bUAG_compactionButton:not(:disabled):hover .h5bUAG_compactionContextIcon,.h5bUAG_compactionButton:not(:disabled):focus-visible .h5bUAG_compactionContextIcon{opacity:0}.h5bUAG_compactionButton:not(:disabled):hover .h5bUAG_compactionDisclosureIcon,.h5bUAG_compactionButton:not(:disabled):focus-visible .h5bUAG_compactionDisclosureIcon{opacity:1}.h5bUAG_compactionTitle{font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));color:inherit;flex:none}.h5bUAG_compactionSep{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.h5bUAG_compactionSummary{min-width:0;color:inherit;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}.h5bUAG_compactionBody{padding:4px 0 4px calc(22px + var(--dsh-content-font-delta,0px));color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px))}.h5bUAG_retryRow{color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px))}.h5bUAG_retrySummary{border-radius:var(--dsw-radius-sm);width:fit-content;max-width:100%;color:inherit;cursor:pointer;user-select:none;align-items:center;gap:7px;padding:2px 0;list-style:none;display:inline-flex}.h5bUAG_retrySummary::-webkit-details-marker{display:none}.h5bUAG_retrySummary:after{content:"";border-bottom:1.5px solid;border-right:1.5px solid;flex:none;width:6px;height:6px;margin-right:2px;transition:transform .12s;transform:rotate(-45deg)}.h5bUAG_retrySummary:hover{color:var(--dsw-alias-label-secondary)}@media (prefers-reduced-motion:reduce){.h5bUAG_compactionButton{transition:none}}.h5bUAG_retrySummary:focus-visible{outline:1.5px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}.h5bUAG_retryText{overflow-wrap:anywhere;min-width:0}.h5bUAG_retryRow[open] .h5bUAG_retrySummary:after{transform:rotate(45deg)}.h5bUAG_retryDetails{overflow-wrap:anywhere;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px));gap:2px;margin-top:3px;padding-left:14px;display:grid}.h5bUAG_retryDetailLabel{color:var(--dsw-alias-label-secondary)}.h5bUAG_turnErrorRow{font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));grid-template-columns:10px minmax(0,1fr) auto;align-items:start;gap:8px;padding:2px 0;display:grid}.h5bUAG_turnErrorDot{margin-top:5px}.h5bUAG_turnErrorCopy{overflow-wrap:anywhere;min-width:0}.h5bUAG_turnErrorTitle{color:var(--dsw-alias-state-error-primary);margin-right:6px;font-weight:600}.h5bUAG_turnErrorMessage{color:var(--dsw-alias-label-secondary)}.h5bUAG_turnErrorCode{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-markdown-code-block-small)}.h5bUAG_maxTokensTitle{color:var(--dsw-alias-state-warn-primary);margin-right:6px;font-weight:600}.h5bUAG_attachmentRow{flex-wrap:wrap;justify-content:flex-end;gap:8px;max-width:100%;display:flex}.h5bUAG_pendingAttachment{flex-direction:column;align-items:flex-end;gap:4px;min-width:0;display:flex}.h5bUAG_fileCard{border:.5px solid var(--dsw-alias-border-l2,#0000001f);border-radius:var(--dsw-radius-xl);background:var(--dsw-specific-input-major,transparent);box-sizing:border-box;flex:none;align-items:center;gap:10px;width:240px;min-height:64px;padding:8px 12px;display:inline-flex}.h5bUAG_fileIcon{flex:none;width:28px;height:28px}.h5bUAG_fileContent{flex-direction:column;flex:1;min-width:0;display:flex}.h5bUAG_fileName{white-space:nowrap;text-overflow:ellipsis;color:var(--dsw-alias-label-primary);font-size:14px;font-weight:500;line-height:22px;overflow:hidden}.h5bUAG_fileMeta{white-space:nowrap;text-overflow:ellipsis;color:var(--dsw-alias-label-tertiary,#00000073);font-size:12px;line-height:15px;overflow:hidden}.h5bUAG_editAction{color:inherit;cursor:pointer;border-radius:var(--dsw-radius-sm);background:0 0;border:0;justify-content:center;align-items:center;width:28px;height:28px;padding:6px;display:inline-flex}.h5bUAG_editAction:hover{background:var(--dsw-alias-interactive-bg-hover)}.h5bUAG_editAction svg{width:15px;height:15px}.h5bUAG_userStack:has(.h5bUAG_sentEditor){width:100%}.h5bUAG_sentEditor{box-sizing:border-box;border:1px solid var(--dsw-alias-border-main);border-radius:12px;width:100%;min-width:0;padding:12px}.h5bUAG_sentEditor textarea{resize:vertical;width:100%;min-height:100px;color:inherit;font:inherit;box-sizing:border-box;background:0 0;border:0;outline:0;line-height:1.6}.h5bUAG_sentEditor:focus-within{outline:1.5px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary))}.h5bUAG_sentEditorActions{justify-content:flex-end;gap:8px;margin-top:8px;display:flex}`,document.head.appendChild(e)}var Y={annotationRow:`h5bUAG_annotationRow`,attachmentRow:`h5bUAG_attachmentRow`,bubble:`h5bUAG_bubble`,compactionBody:`h5bUAG_compactionBody`,compactionButton:`h5bUAG_compactionButton`,compactionContextIcon:`h5bUAG_compactionContextIcon`,compactionDisclosureIcon:`h5bUAG_compactionDisclosureIcon`,compactionLeading:`h5bUAG_compactionLeading`,compactionRow:`h5bUAG_compactionRow`,compactionSep:`h5bUAG_compactionSep`,compactionSummary:`h5bUAG_compactionSummary`,compactionTitle:`h5bUAG_compactionTitle`,contextRow:`h5bUAG_contextRow`,editAction:`h5bUAG_editAction`,fileCard:`h5bUAG_fileCard`,fileContent:`h5bUAG_fileContent`,fileIcon:`h5bUAG_fileIcon`,fileMeta:`h5bUAG_fileMeta`,fileName:`h5bUAG_fileName`,maxTokensTitle:`h5bUAG_maxTokensTitle`,noticeRow:`h5bUAG_noticeRow`,noticeStack:`h5bUAG_noticeStack`,pendingAttachment:`h5bUAG_pendingAttachment`,referenceSummary:`h5bUAG_referenceSummary`,retryDetailLabel:`h5bUAG_retryDetailLabel`,retryDetails:`h5bUAG_retryDetails`,retryRow:`h5bUAG_retryRow`,retrySummary:`h5bUAG_retrySummary`,retryText:`h5bUAG_retryText`,sentEditor:`h5bUAG_sentEditor`,sentEditorActions:`h5bUAG_sentEditorActions`,turnErrorCode:`h5bUAG_turnErrorCode`,turnErrorCopy:`h5bUAG_turnErrorCopy`,turnErrorDot:`h5bUAG_turnErrorDot`,turnErrorMessage:`h5bUAG_turnErrorMessage`,turnErrorRow:`h5bUAG_turnErrorRow`,turnErrorTitle:`h5bUAG_turnErrorTitle`,userRow:`h5bUAG_userRow`,userStack:`h5bUAG_userStack`};let Rm=(0,d.memo)(function({node:e,title:t,fallbackSummary:n,t:r}){let[i,a]=(0,d.useState)(!1),o=(0,d.useMemo)(()=>Am(r),[r]),s=e.summary!==null,c=s&&i,l=e.shadowedItemCount!==null&&e.shadowedTokenCount!==null?r(`message.compaction.completed`,{items:e.shadowedItemCount,tokens:e.shadowedTokenCount}):n??r(s?`message.compaction.expand`:`message.compaction.unavailable`);return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Y.compactionRow,children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Y.compactionButton,disabled:!s,"aria-expanded":s?c:void 0,onClick:()=>{a(e=>!e)},children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:Y.compactionLeading,"aria-hidden":!0,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.compactionContextIcon,"data-compaction-icon":`context`,children:/* @__PURE__ */ (0,f.jsx)(p.IconApiOutlineRegular,{})}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.compactionDisclosureIcon,"data-compaction-disclosure":c?`expanded`:`collapsed`,children:c?/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{}):/* @__PURE__ */ (0,f.jsx)(p.IconChevronRightOutlineRegular,{})})]}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.compactionTitle,children:t??r(`message.compaction`)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.compactionSep,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.compactionSummary,children:l})]}),c&&e.summary!==null&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:Y.compactionBody,children:/* @__PURE__ */ (0,f.jsx)(p.MarkdownText,{text:e.summary,labels:o})})]})}),zm=`@deepseek-ai/dsh-client-ui-chat/ContextBody.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(zm)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=zm,e.textContent=`.p4W7kq_text{color:var(--dsw-alias-label-secondary);font:inherit;white-space:pre-wrap;overflow-wrap:anywhere;margin:0}.p4W7kq_fields{border-top:.5px solid var(--dsw-alias-border-l2);flex-direction:column;gap:2px;margin:8px 0 0;padding-top:8px;display:flex}.p4W7kq_field{gap:8px;min-width:0;display:flex}.p4W7kq_fieldKey{min-width:96px;color:var(--dsw-alias-label-caption);flex:none}.p4W7kq_fieldValue{min-width:0;color:var(--dsw-alias-label-tertiary);overflow-wrap:anywhere;flex:auto;margin:0}.p4W7kq_files{flex-wrap:wrap;gap:4px 12px;margin:0 0 8px;padding:0;list-style:none;display:flex}.p4W7kq_file{align-items:baseline;gap:6px;min-width:0;display:flex}.p4W7kq_filePath{color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere}.p4W7kq_fileAction{color:var(--dsw-alias-label-caption)}.p4W7kq_catalogNotice{color:var(--dsw-alias-label-caption);margin:0 0 6px}.p4W7kq_entries{flex-direction:column;gap:4px;margin:0;padding:0;list-style:none;display:flex}.p4W7kq_entry{gap:8px;min-width:0;display:flex}.p4W7kq_entryName{color:var(--dsw-alias-label-secondary);flex:none}.p4W7kq_entryDescription{min-width:0;color:var(--dsw-alias-label-tertiary);text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}.p4W7kq_sections{flex-direction:column;gap:8px;margin:0;display:flex}.p4W7kq_section{flex-direction:column;gap:2px;min-width:0;display:flex}.p4W7kq_sectionName{color:var(--dsw-alias-label-caption)}.p4W7kq_sectionText{color:var(--dsw-alias-label-secondary);white-space:pre-wrap;overflow-wrap:anywhere;margin:0}.p4W7kq_relaySender{color:var(--dsw-alias-label-caption);overflow-wrap:anywhere;margin:0 0 6px}.p4W7kq_recalls{flex-direction:column;gap:2px;margin:0 0 8px;padding:0;list-style:none;display:flex}.p4W7kq_recall{gap:8px;min-width:0;display:flex}.p4W7kq_recallLabel{color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere}.p4W7kq_recallCounts{color:var(--dsw-alias-label-caption);flex:none}`,document.head.appendChild(e)}var Bm={catalogNotice:`p4W7kq_catalogNotice`,entries:`p4W7kq_entries`,entry:`p4W7kq_entry`,entryDescription:`p4W7kq_entryDescription`,entryName:`p4W7kq_entryName`,field:`p4W7kq_field`,fieldKey:`p4W7kq_fieldKey`,fieldValue:`p4W7kq_fieldValue`,fields:`p4W7kq_fields`,file:`p4W7kq_file`,fileAction:`p4W7kq_fileAction`,filePath:`p4W7kq_filePath`,files:`p4W7kq_files`,recall:`p4W7kq_recall`,recallCounts:`p4W7kq_recallCounts`,recallLabel:`p4W7kq_recallLabel`,recalls:`p4W7kq_recalls`,relaySender:`p4W7kq_relaySender`,section:`p4W7kq_section`,sectionName:`p4W7kq_sectionName`,sectionText:`p4W7kq_sectionText`,sections:`p4W7kq_sections`,text:`p4W7kq_text`};let Vm=2e4;function Hm(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Um(e){let t=[];for(let n of e){if(n.type!==`text`){t.push({block:n});continue}let e=t[t.length-1];e!==void 0&&`text`in e?e.text+=n.text:t.push({text:n.text})}return t}function Wm(e){return Um(e).flatMap(e=>`block`in e?[e.block]:[])}function Gm(e,t){return e.length>Vm?`${e.slice(0,Vm)}\n${t(`json.truncated`,{total:e.length})}`:e}function Km(e,t){return Gm(typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e),t)}function qm({source:e,formRendered:t,t:n}){let r=Hm(e);if(r===null)return null;let i=t?[`kind`,`form`]:[`kind`],a=Object.entries(r).filter(([e])=>!i.includes(e));return a.length===0?null:/* @__PURE__ */ (0,f.jsx)(`dl`,{className:Bm.fields,"data-context-fields":!0,children:a.map(([e,t])=>/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Bm.field,children:[/* @__PURE__ */ (0,f.jsx)(`dt`,{className:Bm.fieldKey,children:e}),/* @__PURE__ */ (0,f.jsx)(`dd`,{className:Bm.fieldValue,children:Km(t,n)})]},e))})}function Jm({blocks:e,t}){return/* @__PURE__ */ (0,f.jsx)(f.Fragment,{children:e.map((e,n)=>/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:t(`message.unknownBlock`),payload:e,truncatedLabel:e=>t(`json.truncated`,{total:e})},n))})}function Ym({content:e,t}){return/* @__PURE__ */ (0,f.jsx)(f.Fragment,{children:Um(e).map((e,n)=>`text`in e?e.text!==``&&/* @__PURE__ */ (0,f.jsx)(`pre`,{className:Bm.text,"data-context-text":!0,children:Gm(e.text,t)},n):/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:t(`message.unknownBlock`),payload:e.block,truncatedLabel:e=>t(`json.truncated`,{total:e})},n))})}function Xm({content:e,source:t,t:n}){return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(Ym,{content:e,t:n}),/* @__PURE__ */ (0,f.jsx)(qm,{source:t,formRendered:!1,t:n})]})}function Zm(e){let t=Hm(e),n=t===null?void 0:t.changes;if(!Array.isArray(n))return null;let r=[],i=/* @__PURE__ */ new Set;for(let e of n){let t=Hm(e);if(t===null)return null;let n=t.path;if(typeof n!=`string`||n===``)return null;let a=t.action;if(a!==`set`&&a!==`replace`&&a!==`remove`)return null;let o=t.digest;i.has(n)||(i.add(n),r.push({action:a,path:n,...typeof o==`string`?{digest:o}:{}}))}return r.length===0?null:r}function Qm(e,t){return e===`remove`?`message.context.instructions.removed`:t?`message.context.instructions.loaded`:e===`set`?`message.context.instructions.added`:`message.context.instructions.updated`}function $m({content:e,source:t,t:n}){let r=Zm(t);if(r===null)return/* @__PURE__ */ (0,f.jsx)(Xm,{content:e,source:t,t:n});let i=Hm(t)?.baseline===!0;return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`ul`,{className:Bm.files,"data-context-files":!0,children:r.map(e=>/* @__PURE__ */ (0,f.jsxs)(`li`,{className:Bm.file,title:e.digest,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Bm.filePath,children:e.path}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Bm.fileAction,children:n(Qm(e.action,i))})]},e.path))}),/* @__PURE__ */ (0,f.jsx)(Ym,{content:e,t:n})]})}function eh(e){let t=Hm(e),n=t===null?void 0:t.entries;if(!Array.isArray(n))return null;let r=[];for(let e of n){let t=Hm(e);if(t===null)return null;let n=t.name,i=t.description;if(typeof n!=`string`||n===``||typeof i!=`string`)return null;r.push({name:n,description:i})}return r}function th({content:e,source:t,t:n}){let r=eh(t);if(r===null)return/* @__PURE__ */ (0,f.jsx)(Xm,{content:e,source:t,t:n});let i=Hm(t)?.update===!0,a=r.slice(0,200),o=Wm(e);return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[i&&/* @__PURE__ */ (0,f.jsx)(`p`,{className:Bm.catalogNotice,"data-context-catalog-update":!0,children:n(`message.context.catalog.replaced`)}),/* @__PURE__ */ (0,f.jsx)(`ul`,{className:Bm.entries,"data-context-entries":!0,children:a.map((e,t)=>/* @__PURE__ */ (0,f.jsxs)(`li`,{className:Bm.entry,children:[/* @__PURE__ */ (0,f.jsx)(`code`,{className:Bm.entryName,children:e.name}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Bm.entryDescription,children:e.description})]},t))}),a.length<r.length&&/* @__PURE__ */ (0,f.jsx)(`p`,{className:Bm.catalogNotice,"data-context-entries-truncated":!0,children:n(`message.context.catalog.more`,{count:r.length-a.length})}),/* @__PURE__ */ (0,f.jsx)(Jm,{blocks:o,t:n})]})}function nh(e){let t=Hm(e),n=t===null?void 0:t.sections;if(!Array.isArray(n))return null;let r=[];for(let e of n){let t=Hm(e);if(t===null)return null;let n=t.name,i=t.text;if(typeof n!=`string`||n===``||typeof i!=`string`)return null;r.push({name:n,text:i})}return r.length===0?null:r}function rh({content:e,source:t,t:n}){let r=nh(t);return r===null?/* @__PURE__ */ (0,f.jsx)(Xm,{content:e,source:t,t:n}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`p`,{className:Bm.catalogNotice,"data-context-snapshot-supersedes":!0,children:n(`message.context.snapshot.supersedes`)}),/* @__PURE__ */ (0,f.jsx)(`dl`,{className:Bm.sections,"data-context-sections":!0,children:r.map((e,t)=>/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Bm.section,children:[/* @__PURE__ */ (0,f.jsx)(`dt`,{className:Bm.sectionName,children:e.name}),/* @__PURE__ */ (0,f.jsx)(`dd`,{className:Bm.sectionText,children:Gm(e.text,n)})]},t))})]})}function ih({content:e,t}){return/* @__PURE__ */ (0,f.jsx)(Ym,{content:e,t})}function ah({content:e,source:t,t:n}){let r=oh(t);return r===null?/* @__PURE__ */ (0,f.jsx)(Xm,{content:e,source:t,t:n}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`p`,{className:Bm.relaySender,"data-context-relay-sender":!0,children:n(`message.context.relay.from`,{session:r})}),/* @__PURE__ */ (0,f.jsx)(Ym,{content:e,t:n})]})}function oh(e){let t=Hm(e)?.senderSessionId;return typeof t==`string`&&t!==``?t:null}function sh(e){let t=Hm(e),n=t===null?void 0:t.references;if(!Array.isArray(n))return null;let r=[];for(let e of n){let t=Hm(e);if(t===null)return null;let n=t.label,i=t.retainedMessages,a=t.omittedMessages,o=t.truncated;if(typeof n!=`string`||n===``||typeof i!=`number`||typeof a!=`number`||typeof o!=`boolean`)return null;r.push({label:n,retained:i,omitted:a,truncated:o})}return r.length===0?null:r}function ch({content:e,source:t,t:n}){let r=sh(t);return r===null?/* @__PURE__ */ (0,f.jsx)(Xm,{content:e,source:t,t:n}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`ul`,{className:Bm.recalls,"data-context-recalls":!0,children:r.map((e,t)=>/* @__PURE__ */ (0,f.jsxs)(`li`,{className:Bm.recall,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Bm.recallLabel,children:e.label}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Bm.recallCounts,children:n(`message.context.recall.counts`,{retained:e.retained,omitted:e.omitted})}),e.truncated&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:Bm.recallCounts,children:n(`message.context.recall.truncated`)})]},t))}),/* @__PURE__ */ (0,f.jsx)(Ym,{content:e,t:n})]})}function lh(e){let t=Hm(e)?.summary;return typeof t==`string`&&t!==``?t:null}function uh(e,t){let n={rendered:null,summary:null,body:/* @__PURE__ */ (0,f.jsx)(Xm,{...t})};switch(e){case`instructions`:return Zm(t.source)===null?n:{rendered:`instructions`,summary:null,body:/* @__PURE__ */ (0,f.jsx)($m,{...t})};case`catalog`:return eh(t.source)===null?n:{rendered:`catalog`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(th,{...t})};case`snapshot`:return nh(t.source)===null?n:{rendered:`snapshot`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(rh,{...t})};case`notice`:{let e=lh(t.source);return e===null?n:{rendered:`notice`,summary:e,body:/* @__PURE__ */ (0,f.jsx)(ih,{...t})}}case`relay`:return oh(t.source)===null?n:{rendered:`relay`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(ah,{...t})};case`recall`:return sh(t.source)===null?n:{rendered:`recall`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(ch,{...t})};case null:return n;
113
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function ko(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;ko(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}let Ao=/* @__PURE__ */ new Set([`type`,`properties`,`required`,`additionalProperties`]),jo=[`oneOf`,`anyOf`];function Mo(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function No(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Ao.has(e))return null;t.push(n)}let n={},r=/* @__PURE__ */ new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??Mo(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}we(n,r,e.length===1?e[0]:No(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=Mo(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function Po(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Ao)if(t in e)return;let n=t.filter(e=>jo.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=No(t);else{let e=n[0],i=jo.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>No([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Co(e,r))}function Fo(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Co(i,s),Co(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())ko(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=/* @__PURE__ */ new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])Po(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Co(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,we(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Ro(t,`input`,e.processors),output:Ro(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Io(e,t){let n=t??{seen:/* @__PURE__ */ new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Io(r.element,n);if(r.type===`set`)return Io(r.valueType,n);if(r.type===`lazy`)return Io(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return Io(r.innerType,n);if(r.type===`intersection`)return Io(r.left,n)||Io(r.right,n);if(r.type===`record`||r.type===`map`)return Io(r.keyType,n)||Io(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Io(r.in,n)||Io(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Io(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Io(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Io(e,n))return!0;return!!(r.rest&&Io(r.rest,n))}return!1}let Lo=(e,t={})=>n=>{let r=wo({...n,processors:t});return Eo(e,r),Oo(r,e),Fo(r,e)},Ro=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=wo({...i??{},target:a,io:t,processors:n});return Eo(e,o),Oo(o,e),Fo(o,e)},zo=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Bo=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Vo=(e,t)=>{zo(e,`minimum`,t),Bo(e,`maximum`,t)},Ho=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Uo=(e,t)=>{e.patterns??=/* @__PURE__ */ new Set,e.patterns.add(t)},Wo=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Go=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Ko=(e,t)=>zo(e,`minimum`,t.minimum),qo=(e,t)=>Bo(e,`maximum`,t.maximum),Jo=e=>(t,n)=>{Go(t,n.format);let[r,i]=e[n.format];zo(t,`minimum`,r),Bo(t,`maximum`,i)},Yo={greater_than:(e,t)=>zo(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Bo(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Ho(e,t.value),number_format:Jo(Ge),bigint_format:Jo(Ke),min_length:Ko,max_length:qo,length_equals:(e,t)=>Vo(e,t.length),min_size:Ko,max_size:qo,size_equals:(e,t)=>Vo(e,t.size),string_format:(e,t)=>{Go(e,t.format),t.pattern&&Uo(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Wo(e,t.mime)};function Xo(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Yo[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&zo(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&zo(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Bo(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Bo(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Ho(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Wo(t,i.mime);for(let e of i.patterns??[])Uo(t,e);return t}let Zo={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Qo=/* @__PURE__ */ new Map([[Gr,En],[qr,Dn]]),$o=e=>Qo.get(e)??e,es=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=Xo(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Zo[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map($o);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},ts=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Xo(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=/* @__PURE__ */ new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):To(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},ns=(e,t,n,r)=>{n.type=`boolean`},rs=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},is=(e,t,n,r)=>{n.not={}},as=(e,t,n,r)=>{let i=e._zod.def,a=me(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},os=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(To(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(To(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},ss=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},cs=(e,t,n,r)=>{To(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},ls=(e,t,n,r)=>{To(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},us=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=Xo(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Eo(a.element,t,{...r,path:[...r.path,`items`]})};function ds(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?ds(t.out):t.type===`catch`?ds(t.innerType):e._zod.optin}let fs=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&To(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)we(i.properties,e,Eo(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?ds(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Eo(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},ps=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Eo(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},ms=(e,t,n,r)=>{let i=e._zod.def,a=Eo(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Eo(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},hs=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>Eo(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?Eo(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null,u=a.items.length;for(;u>0;){let e=a.items[u-1];if(!(t.io===`input`?ds(e)!==void 0:e._zod.optout===`optional`))break;u--}let d=a.items.length,f=!a.rest;t.target===`draft-2020-12`?(i.prefixItems=c,f?i.items=!1:l&&(i.items=l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):(i.items=c,f?i.additionalItems=!1:l&&(i.additionalItems=l),u>0&&(i.minItems=u),f&&(i.maxItems=d));let{minimum:p,maximum:m}=Xo(e);typeof p==`number`&&(i.minItems=p),typeof m==`number`&&(i.maxItems=m)};function gs(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=gs(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>gs(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i&&(p.type=`string`,a||(p.pattern=(r.includes(`number`)?zn:Rn).source)),p}let _s=/* @__PURE__ */ new WeakMap;function vs(e){let t=/* @__PURE__ */ new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=/* @__PURE__ */ new Map;for(let r of _s.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=gs(t,a,/* @__PURE__ */ new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}let ys=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=Xo(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Eo(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)we(i.patternProperties,$o(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=Eo(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=_s.get(t);n||(n=[],_s.set(t,n),t.deferred.push(()=>vs(t))),n.push(e)}i.additionalProperties=Eo(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&ds(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},bs=(e,t,n,r)=>{let i=e._zod.def,a=Eo(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},xs=(e,t,n,r)=>{let i=e._zod.def;Eo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ss=Symbol();function Cs(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(To(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),Ss):JSON.parse(o)}let ws=(e,t,n,r)=>{let i=e._zod.def;Eo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=Cs(i.defaultValue,e,t,n,r);o!==Ss&&(n.default=o)},Ts=(e,t,n,r)=>{let i=e._zod.def;Eo(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=Cs(i.defaultValue,e,t,n,r);o!==Ss&&(n._prefault=o)},Es=(e,t,n,r)=>{let i=e._zod.def;Eo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{To(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},Ds=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;Eo(o,t,r);let s=t.seen.get(e);s.ref=o},Os=(e,t,n,r)=>{let i=e._zod.def;Eo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},ks=(e,t,n,r)=>{let i=e._zod.def;Eo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},As=(e,t,n,r)=>{let i=e._zod.innerType;Eo(i,t,r);let a=t.seen.get(e);a.ref=i},js=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]);function Ms(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}let Ns=/*@__PURE__*/ M(`ZodError`,(e,t)=>{Bt.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);js.has(n)||(js.add(n),Ms(n,`format`,e=>t=>Ut(e,t)),Ms(n,`flatten`,e=>t=>Ht(e,t)),Ms(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,ge,2)}),Ms(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,ge,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Ps=/* @__PURE__ */ Gt(Ns),Fs=/* @__PURE__ */ Kt(Ns),Is=/* @__PURE__ */ qt(Ns),Ls=/* @__PURE__ */ Yt(Ns),Rs=/* @__PURE__ */ tn(Ns),zs=/* @__PURE__ */ nn(Ns),Bs=/* @__PURE__ */ rn(Ns),Vs=/* @__PURE__ */ an(Ns),Hs=/* @__PURE__ */ on(Ns),Us=/* @__PURE__ */ sn(Ns),Ws=/* @__PURE__ */ cn(Ns),Gs=/* @__PURE__ */ ln(Ns);function Ks(){Mt.localeError||Nt(fa())}function qs(){Mt.memoizer||Nt({memoizer:la()})}let P=/*@__PURE__*/ M(`ZodType`,(e,t)=>(Ks(),N.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(je(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return He(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(_l(e,t))},superRefine(e,t){return this.check(vl(e,t))},overwrite(e){return this.check(/* @__PURE__ */ fo(e))},optional(){return Jc(this)},exactOptional(){return Xc(this)},nullable(){return Qc(this)},nullish(){return Jc(Qc(this))},nonoptional(e){return il(this,e)},array(){return R(this)},or(e){return V([this,e])},and(e){return Rc(this,e)},transform(e){return cl(this,Kc(e))},default(e){return el(this,e)},prefault(e){return nl(this,e)},catch(e){return ol(this,e)},pipe(e){return cl(this,e)},readonly(){return ul(this)},describe(e){let t=this.clone();return ga.add(t,{description:e}),t},meta(...e){if(e.length===0)return ga.get(this);let t=this.clone();return ga.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return gt(this,`~standard`,{...fr(this),jsonSchema:{input:Ro(this,`input`),output:Ro(this,`output`)}})},set"~standard"(e){ht(this,`~standard`,e)},parse:function e(t,n){return Ps(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Fs(this,t,n,{callee:e})},safeParse(e,t){return Is(this,e,t)},async safeParseAsync(e,t){return Ls(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){ht(this,`spa`,e)},validate(e,t){return Qt(this,e,t)},validateAsync(e,t){return en(this,e,t)},encode:function e(t,n){return Rs(this,t,n,{callee:e})},decode:function e(t,n){return zs(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Bs(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Vs(this,t,n,{callee:e})},safeEncode(e,t){return Hs(this,e,t)},safeDecode(e,t){return Us(this,e,t)},async safeEncodeAsync(e,t){return Ws(this,e,t)},async safeDecodeAsync(e,t){return Gs(this,e,t)},toJSONSchema(e){return Lo(this,{})(e)},get description(){return ga.get(this)?.description},get _def(){return this._zod.def}}),Js=/*@__PURE__*/ M(`_ZodString`,(e,t)=>{pr.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>es(e,t,n,r)},/*@__PURE__*/ _t({format:e=>Xo(e).format??null,minLength:e=>Xo(e).minimum??null,maxLength:e=>Xo(e).maximum??null},{regex(...e){return this.check(/* @__PURE__ */ ao(...e))},includes(...e){return this.check(/* @__PURE__ */ co(...e))},startsWith(...e){return this.check(/* @__PURE__ */ lo(...e))},endsWith(...e){return this.check(/* @__PURE__ */ uo(...e))},min(...e){return this.check(/* @__PURE__ */ ro(...e))},max(...e){return this.check(/* @__PURE__ */ no(...e))},length(...e){return this.check(/* @__PURE__ */ io(...e))},nonempty(...e){return this.check(/* @__PURE__ */ ro(1,...e))},lowercase(e){return this.check(/* @__PURE__ */ oo(e))},uppercase(e){return this.check(/* @__PURE__ */ so(e))},trim(){return this.check(/* @__PURE__ */ mo())},normalize(...e){return this.check(/* @__PURE__ */ po(...e))},toLowerCase(){return this.check(/* @__PURE__ */ ho())},toUpperCase(){return this.check(/* @__PURE__ */ go())},slugify(){return this.check(/* @__PURE__ */ _o())}})),Ys=/*@__PURE__*/ M(`ZodString`,(e,t)=>{pr.init(e,t),Js.init(e,t)},{email(e){return this.check(/* @__PURE__ */ ya(tc,e))},url(e){return this.check(/* @__PURE__ */ Ta(oc,e))},jwt(e){return this.check(/* @__PURE__ */ Ba(Sc,e))},emoji(e){return this.check(/* @__PURE__ */ Ea(cc,e))},guid(e){return this.check(/* @__PURE__ */ ba(nc,e))},uuid(e){return this.check(/* @__PURE__ */ xa(rc,e))},uuidv4(e){return this.check(/* @__PURE__ */ Sa(rc,e))},uuidv6(e){return this.check(/* @__PURE__ */ Ca(rc,e))},uuidv7(e){return this.check(/* @__PURE__ */ wa(rc,e))},nanoid(e){return this.check(/* @__PURE__ */ Da(lc,e))},cuid(e){return this.check(/* @__PURE__ */ Oa(uc,e))},cuid2(e){return this.check(/* @__PURE__ */ ka(dc,e))},ulid(e){return this.check(/* @__PURE__ */ Aa(fc,e))},base64(e){return this.check(/* @__PURE__ */ La(yc,e))},base64url(e){return this.check(/* @__PURE__ */ Ra(bc,e))},xid(e){return this.check(/* @__PURE__ */ ja(pc,e))},ksuid(e){return this.check(/* @__PURE__ */ Ma(mc,e))},ipv4(e){return this.check(/* @__PURE__ */ Na(hc,e))},ipv6(e){return this.check(/* @__PURE__ */ Pa(gc,e))},cidrv4(e){return this.check(/* @__PURE__ */ Fa(_c,e))},cidrv6(e){return this.check(/* @__PURE__ */ Ia(vc,e))},e164(e){return this.check(/* @__PURE__ */ za(xc,e))},datetime(e){return this.check(/* @__PURE__ */ Va(Zs,e))},date(e){return this.check(/* @__PURE__ */ Ha(Qs,e))},time(e){return this.check(/* @__PURE__ */ Ua($s,e))},duration(e){return this.check(/* @__PURE__ */ Wa(ec,e))}});function F(e){return/* @__PURE__ */ va(Ys,e)}let Xs=/*@__PURE__*/ M(`ZodStringFormat`,(e,t)=>{mr.init(e,t),Js.init(e,t)}),Zs=/*@__PURE__*/ M(`ZodISODateTime`,(e,t)=>{Nr.init(e,t),Xs.init(e,t)}),Qs=/*@__PURE__*/ M(`ZodISODate`,(e,t)=>{Pr.init(e,t),Xs.init(e,t)}),$s=/*@__PURE__*/ M(`ZodISOTime`,(e,t)=>{Fr.init(e,t),Xs.init(e,t)}),ec=/*@__PURE__*/ M(`ZodISODuration`,(e,t)=>{Ir.init(e,t),Xs.init(e,t)}),tc=/*@__PURE__*/ M(`ZodEmail`,(e,t)=>{_r.init(e,t),Xs.init(e,t)}),nc=/*@__PURE__*/ M(`ZodGUID`,(e,t)=>{hr.init(e,t),Xs.init(e,t)}),rc=/*@__PURE__*/ M(`ZodUUID`,(e,t)=>{gr.init(e,t),Xs.init(e,t)});function ic(e){return/* @__PURE__ */ xa(rc,e)}function ac(e){return/* @__PURE__ */ Sa(rc,e)}let oc=/*@__PURE__*/ M(`ZodURL`,(e,t)=>{Tr.init(e,t),Xs.init(e,t)});function sc(e){return/* @__PURE__ */ Ta(oc,e)}let cc=/*@__PURE__*/ M(`ZodEmoji`,(e,t)=>{Er.init(e,t),Xs.init(e,t)}),lc=/*@__PURE__*/ M(`ZodNanoID`,(e,t)=>{Dr.init(e,t),Xs.init(e,t)}),uc=/*@__PURE__*/ M(`ZodCUID`,(e,t)=>{Or.init(e,t),Xs.init(e,t)}),dc=/*@__PURE__*/ M(`ZodCUID2`,(e,t)=>{kr.init(e,t),Xs.init(e,t)}),fc=/*@__PURE__*/ M(`ZodULID`,(e,t)=>{Ar.init(e,t),Xs.init(e,t)}),pc=/*@__PURE__*/ M(`ZodXID`,(e,t)=>{jr.init(e,t),Xs.init(e,t)}),mc=/*@__PURE__*/ M(`ZodKSUID`,(e,t)=>{Mr.init(e,t),Xs.init(e,t)}),hc=/*@__PURE__*/ M(`ZodIPv4`,(e,t)=>{Lr.init(e,t),Xs.init(e,t)}),gc=/*@__PURE__*/ M(`ZodIPv6`,(e,t)=>{Br.init(e,t),Xs.init(e,t)}),_c=/*@__PURE__*/ M(`ZodCIDRv4`,(e,t)=>{Vr.init(e,t),Xs.init(e,t)}),vc=/*@__PURE__*/ M(`ZodCIDRv6`,(e,t)=>{Ur.init(e,t),Xs.init(e,t)}),yc=/*@__PURE__*/ M(`ZodBase64`,(e,t)=>{Kr.init(e,t),Xs.init(e,t)}),bc=/*@__PURE__*/ M(`ZodBase64URL`,(e,t)=>{Yr.init(e,t),Xs.init(e,t)}),xc=/*@__PURE__*/ M(`ZodE164`,(e,t)=>{Xr.init(e,t),Xs.init(e,t)}),Sc=/*@__PURE__*/ M(`ZodJWT`,(e,t)=>{Qr.init(e,t),Xs.init(e,t)}),Cc=/*@__PURE__*/ M(`ZodNumber`,(e,t)=>{$r.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ts(e,t,n,r),e.isFinite=!0},/*@__PURE__*/ _t({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=Xo(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=Xo(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=Xo(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>Xo(e).format??null},{gt(e,t){return this.check(/* @__PURE__ */ $a(e,t))},gte(e,t){return this.check(/* @__PURE__ */ eo(e,t))},min(e,t){return this.check(/* @__PURE__ */ eo(e,t))},lt(e,t){return this.check(/* @__PURE__ */ Za(e,t))},lte(e,t){return this.check(/* @__PURE__ */ Qa(e,t))},max(e,t){return this.check(/* @__PURE__ */ Qa(e,t))},int(e){return this.check(Tc(e))},safe(e){return this.check(Tc(e))},positive(e){return this.check(/* @__PURE__ */ $a(0,e))},nonnegative(e){return this.check(/* @__PURE__ */ eo(0,e))},negative(e){return this.check(/* @__PURE__ */ Za(0,e))},nonpositive(e){return this.check(/* @__PURE__ */ Qa(0,e))},multipleOf(e,t){return this.check(/* @__PURE__ */ to(e,t))},step(e,t){return this.check(/* @__PURE__ */ to(e,t))},finite(){return this}}));function I(e){return/* @__PURE__ */ Ga(Cc,e)}let wc=/*@__PURE__*/ M(`ZodNumberFormat`,(e,t)=>{ei.init(e,t),Cc.init(e,t)});function Tc(e){return/* @__PURE__ */ Ka(wc,e)}let Ec=/*@__PURE__*/ M(`ZodBoolean`,(e,t)=>{ti.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ns(e,t,n,r)});function L(e){return/* @__PURE__ */ qa(Ec,e)}let Dc=/*@__PURE__*/ M(`ZodNull`,(e,t)=>{ni.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rs(e,t,n,r)});function Oc(e){return/* @__PURE__ */ Ja(Dc,e)}let kc=/*@__PURE__*/ M(`ZodUnknown`,(e,t)=>{ri.init(e,t),P.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Ac(){return/* @__PURE__ */ Ya(kc)}let jc=/*@__PURE__*/ M(`ZodNever`,(e,t)=>{ii.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>is(e,t,n,r)});function Mc(e){return/* @__PURE__ */ Xa(jc,e)}let Nc=/*@__PURE__*/ M(`ZodArray`,(e,t)=>{qs(),ci.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>us(e,t,n,r),e.element=t.element},{min(e,t){return this.check(/* @__PURE__ */ ro(e,t))},nonempty(e){return this.check(/* @__PURE__ */ ro(1,e))},max(e,t){return this.check(/* @__PURE__ */ no(e,t))},length(e,t){return this.check(/* @__PURE__ */ io(e,t))},unwrap(){return this.element}});function R(e,t){return/* @__PURE__ */ vo(Nc,e,t)}let Pc=/*@__PURE__*/ M(`ZodObject`,(e,t)=>{qs(),mi.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fs(e,t,n,r),Ct(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return U(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(je(this._zod.def,{catchall:e}))},passthrough(){return this.clone(je(this._zod.def,{catchall:Ac()}))},loose(){return this.clone(je(this._zod.def,{catchall:Ac()}))},strict(){return this.clone(je(this._zod.def,{catchall:Mc()}))},strip(){return this.clone(je(this._zod.def,{catchall:void 0}))},extend(e){return Xe(this,e)},safeExtend(e){return Qe(this,e)},merge(e){return $e(this,e)},pick(e){return qe(this,e)},omit(e){return Ye(this,e)},partial(...e){return et(qc,this,e[0])},exactPartial(...e){return et(Yc,this,e[0],`exactPartial`)},required(...e){return tt(rl,this,e[0])}});function z(e,t){let n={type:`object`,shape:e??{},...A(t)};return new Pc(n)}function B(e,t){return new Pc({type:`object`,shape:e,catchall:Mc(),...A(t)})}let Fc=/*@__PURE__*/ M(`ZodUnion`,(e,t)=>{gi.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ps(e,t,n,r),e.options=t.options});function V(e,t){return new Fc({type:`union`,options:e,...A(t)})}let Ic=/*@__PURE__*/ M(`ZodDiscriminatedUnion`,(e,t)=>{Fc.init(e,t),vi.init(e,t)});function H(e,t,n){return new Ic({type:`union`,options:t,discriminator:e,...A(n)})}let Lc=/*@__PURE__*/ M(`ZodIntersection`,(e,t)=>{yi.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(e,t,n,r)});function Rc(e,t){return new Lc({type:`intersection`,left:e,right:t})}let zc=/*@__PURE__*/ M(`ZodTuple`,(e,t)=>{qs(),Si.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(`.partial() cannot be used on tuple schemas containing refinements`);return this.clone({...e,items:e.items.map(e=>new qc({type:`optional`,innerType:e}))})}});function Bc(e,t,n){let r=t instanceof N;return new zc({type:`tuple`,items:e,rest:r?t:null,...A(r?n:t)})}let Vc=/*@__PURE__*/ M(`ZodRecord`,(e,t)=>{qs(),Ei.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ys(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Hc(e,t,n){return!t||!t._zod?new Vc({type:`record`,keyType:F(),valueType:e,...A(t)}):new Vc({type:`record`,keyType:e,valueType:t,...A(n)})}let Uc=/*@__PURE__*/ M(`ZodEnum`,(e,t)=>{Di.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>as(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Uc({...t,checks:[],...A(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Uc({...t,checks:[],...A(r),entries:i})}});function U(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Uc({type:`enum`,entries:n,...A(t)})}let Wc=/*@__PURE__*/ M(`ZodLiteral`,(e,t)=>{Oi.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>os(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function W(e,t){return new Wc({type:`literal`,values:Array.isArray(e)?e:[e],...A(t)})}let Gc=/*@__PURE__*/ M(`ZodTransform`,(e,t)=>{qs(),ki.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ls(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new jt(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(pt(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(pt(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Kc(e){return new Gc({type:`transform`,transform:e})}let qc=/*@__PURE__*/ M(`ZodOptional`,(e,t)=>{ji.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ks(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Jc(e){return new qc({type:`optional`,innerType:e})}let Yc=/*@__PURE__*/ M(`ZodExactOptional`,(e,t)=>{Mi.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ks(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Xc(e){return new Yc({type:`optional`,innerType:e})}let Zc=/*@__PURE__*/ M(`ZodNullable`,(e,t)=>{Ni.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qc(e){return new Zc({type:`nullable`,innerType:e})}let $c=/*@__PURE__*/ M(`ZodDefault`,(e,t)=>{Pi.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ws(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function el(e,t){return new $c({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Re(t)}})}let tl=/*@__PURE__*/ M(`ZodPrefault`,(e,t)=>{Ii.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ts(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function nl(e,t){return new tl({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Re(t)}})}let rl=/*@__PURE__*/ M(`ZodNonOptional`,(e,t)=>{Li.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function il(e,t){return new rl({type:`nonoptional`,innerType:e,...A(t)})}let al=/*@__PURE__*/ M(`ZodCatch`,(e,t)=>{Bi.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Es(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ol(e,t){return new al({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:wt(t)})}let sl=/*@__PURE__*/ M(`ZodPipe`,(e,t)=>{Vi.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ds(e,t,n,r),e.in=t.in,e.out=t.out});function cl(e,t){return new sl({type:`pipe`,in:e,out:t})}let ll=/*@__PURE__*/ M(`ZodReadonly`,(e,t)=>{Ui.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Os(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ul(e){return new ll({type:`readonly`,innerType:e})}let dl=/*@__PURE__*/ M(`ZodTemplateLiteral`,(e,t)=>{qi.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ss(e,t,n,r)});function fl(e,t){return new dl({type:`template_literal`,parts:e,...A(t)})}let pl=/*@__PURE__*/ M(`ZodLazy`,(e,t)=>{Ji.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>As(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function ml(e){return new pl({type:`lazy`,getter:e})}let hl=/*@__PURE__*/ M(`ZodCustom`,(e,t)=>{Yi.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cs(e,t,n,r)});function gl(e,t){return/* @__PURE__ */ yo(hl,e??(()=>!0),t)}function _l(e,t={}){return/* @__PURE__ */ bo(hl,e,t)}function vl(e,t){return/* @__PURE__ */ xo(e,t)}function yl(e){return/* @__PURE__ */ Va(Zs,e)}function bl(e){return(t,n)=>{for(let r of e)Object.hasOwn(t,r)&&t[r]===void 0&&n.addIssue({code:`custom`,path:[r],message:`Explicit undefined is not valid JSON`})}}let xl=V([F(),I(),L(),Oc()]);function Sl(e){let t=/* @__PURE__ */ new WeakSet,n=[{value:e,leaving:!1}];try{for(;n.length>0;){let e=n.pop();if(!e)break;if(e.leaving)t.delete(e.value);else if(typeof e.value==`object`&&e.value!==null){if(t.has(e.value))return!1;t.add(e.value),n.push({value:e.value,leaving:!0});for(let t of Object.values(e.value))n.push({value:t,leaving:!1})}}}catch{return!1}return!0}let Cl=gl(Sl,{message:`JSON value must not contain circular references`}),wl=ml(()=>V([xl,R(wl),Hc(F(),wl)])),Tl=Cl.pipe(wl);Cl.pipe(R(wl));let El=Cl.pipe(Hc(F(),wl)),Dl=B({code:F().min(1),message:F().min(1),retryable:L(),diagnostic:F().min(1).optional(),stage:F().min(1).optional(),durationMs:I().int().nonnegative().optional(),stderrTail:F().min(1).optional()}).superRefine(bl([`diagnostic`,`stage`,`durationMs`,`stderrTail`])),Ol=F().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u),kl=e=>F().min(1).max(e).refine(e=>e.trim().length>0),Al=Hc(Ol,z({label:kl(256).optional(),description:kl(1024).optional()}).strict()).refine(e=>Object.keys(e).length<=16,`Too many locales`),jl=Hc(Ol,kl(4096)).refine(e=>typeof e.en==`string`,`English fallback is required`).refine(e=>Object.keys(e).length<=16,`Too many locales`),Ml=F().refine(e=>e.trim().length>0,{message:`Identifier must not be empty or whitespace`}),G=Ml.brand(),K=Ml.brand(),Nl=Ml.brand();Ml.brand();let Pl=Ml.max(128).regex(/^[A-Za-z0-9._~-]+$/u,`Thinking option ID must use transport-safe characters`).brand();Ml.brand();let Fl=F().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),Il=Fl.max(128).regex(/^[A-Za-z0-9._~:-]+$/u,`Permission Mode ID must use transport-safe characters`).brand(),Ll=z({modes:R(z({id:Il,label:Fl.max(256),description:Fl.max(1024).optional(),dangerous:L().optional(),localizations:Al.optional()}).strict()).min(1).max(32),defaultModeId:Il}).strict().superRefine((e,t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.modes.entries())n.has(i.id)&&t.addIssue({code:`custom`,message:`Permission Mode IDs must be unique`,path:[`modes`,r,`id`]}),n.add(i.id);n.has(e.defaultModeId)||t.addIssue({code:`custom`,message:`Default Permission Mode must exist in the catalog`,path:[`defaultModeId`]})});z({threadId:K,permissionModeId:Il}).strict();let Rl=F().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`});z({sourceThreadId:K,lastTurnId:Nl.optional(),targetHarnessId:G,targetModel:Rl.max(1024).optional(),targetThinkingOptionId:Rl.max(128).regex(/^[A-Za-z0-9._~-]+$/u,`Thinking option ID must use transport-safe characters`).optional()}).strict();let zl=z({sourceThreadId:K,sourceHarnessId:G,sourceHarnessLabel:Rl.max(256).optional(),sourceModel:Rl.max(1024).optional(),targetHarnessId:G,targetHarnessLabel:Rl.max(256).optional(),targetModel:Rl.max(1024).optional(),totalTurns:I().int().min(1),boundaryTurnNumber:I().int().min(1),includedTurnNumbers:R(I().int().min(1)),omittedTurns:I().int().min(0),preview:F().max(32e3),createdAtMs:I().int().nonnegative()}).strict();z({threadId:K,handoff:zl}).strict();let Bl=F().regex(/^[a-z0-9][a-z0-9-]{0,63}$/u),Vl=F().min(1).max(512).refine(e=>!/\p{Cc}/u.test(e),`Role model must not contain control characters`),Hl=U([`stone`,`rose`,`mist`,`sage`,`amber`,`aqua`]),Ul=fl([`builtin:`,U([`pm-otter`,`frontend-otter`,`backend-otter`,`reviewer-otter`,`idea-otter`,`researcher-otter`,`writer-otter`,`architect-otter`,`debugger-otter`,`tester-otter`,`classic-otter`,`ops-otter`,`security-otter`,`audio-otter`,`scholar-otter`,`data-otter`,`advisor-otter`,`builder-otter`,`wizard-otter`,`sailor-otter`])]),Wl=/^[a-zA-Z0-9_-]{1,64}\.(png|jpg|jpeg|webp)$/u,Gl=fl([`custom:`,F().regex(Wl)]),Kl=fl([`catalog:`,F().regex(Wl)]),ql=V([Ul,Gl]),Jl=V([Ul,Kl]),Yl=V([ql,Kl]),Xl=F().url().max(2048).refine(e=>/^https:\/\//i.test(e),`URL must use https://`),Zl=z({en:F().trim().min(1).max(2e3),"zh-CN":F().trim().min(1).max(2e3)}),Ql=z({slug:Bl,name:Zl,description:Zl,avatar:Jl,accentColor:Hl,recommendedHarnessId:G.optional(),author:F().trim().min(1).max(128),authorUrl:Xl.optional(),sourceUrl:Xl.optional(),license:F().trim().min(1).max(64).optional(),official:L().optional(),instructions:F().trim().min(1).max(1e5),updatedAt:yl()});z({formatVersion:W(1),generatedAt:yl(),roles:R(Ql)});let $l=z({slug:Bl,name:F().refine(e=>e.trim().length>0),avatar:ql,accentColor:Hl}),eu=$l.readonly(),tu=$l.extend({description:F(),harnessId:G,model:Vl.optional(),thinkingOptionId:Pl.optional(),instructions:F(),updatedAt:yl()});tu.omit({updatedAt:!0,avatar:!0}).extend({avatar:Yl}).partial({slug:!0}),z({locale:F().trim().min(1).max(64).optional()}),z({roles:R(tu)}),z({slug:Bl}),z({role:tu.nullable()}),z({role:tu}),z({deleted:L()}),z({refresh:L().optional()}),z({roles:R(Ql),fetchedAt:yl(),likes:Hc(Bl,I().int().nonnegative()).optional(),myLikes:Hc(Bl,I().int().min(0).max(5)).optional(),stale:L().optional(),error:F().optional()}),z({slug:Bl}),z({slug:Bl,likes:I().int().nonnegative(),myLikes:I().int().min(0).max(5),maxLikes:W(5),limitReached:L().optional()});let nu=I().int().safe().nonnegative(),ru=I().finite().nonnegative(),iu=I().finite().min(0).max(100),au=z({version:V([W(3),W(4)]).optional(),requestId:F().min(1),turnId:F().min(1).max(1024),outputTokens:nu,startedAtMs:nu,completedAtMs:nu}).strict().refine(e=>e.completedAtMs>e.startedAtMs),ou=z({version:V([W(2),W(3),W(4)]).optional(),value:ru,turnId:F().min(1).max(1024),at:nu}).strict();z({outputTimings:R(au).transform(e=>e.filter(e=>e.version===4)).optional(),outputTokensPerSecond:ou.refine(e=>e.version===4).optional().catch(void 0),timeToFirstOutputMs:ou.extend({value:nu}).optional()}).strict();let su=e=>jl.refine(t=>Object.values(t).every(t=>t.length<=e)),cu=z({composerIndicators:R(z({kind:W(`countdown`),id:F().min(1).max(64),expiresAtUnix:nu,label:su(256).optional(),tooltip:su(1024).optional()}).strict()).max(2).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,{message:`Composer indicator IDs must be unique`}).optional(),inputTokens:nu.optional(),cachedInputTokens:nu.optional(),cacheWriteInputTokens:nu.optional(),outputTokens:nu.optional(),outputTokensPerSecond:ru.optional(),sessionOutputTokensPerSecond:ru.optional(),apiOutputTokensPerSecond:ru.optional(),reasoningOutputTokens:nu.optional(),totalTokens:nu.optional(),totalCostUsd:ru.optional(),totalCredits:ru.optional(),contextUsagePercent:ru.optional(),cacheHitRatePercent:iu.optional(),contextWindowTokens:nu.optional(),contextUsedTokens:nu.optional(),planFiveHourUsedPercent:iu.optional(),planFiveHourResetsAtUnix:nu.optional(),planSevenDayUsedPercent:iu.optional(),planSevenDayResetsAtUnix:nu.optional(),sessionCacheHitRatePercent:iu.optional(),timeToFirstOutputMs:nu.optional(),latestRequestTimeToFirstOutputMs:nu.optional(),costSource:U([`publicPrice`,`native`]).optional(),unpricedModels:R(F().min(1)).min(1).optional()}).strict().superRefine((e,t)=>{Object.keys(e).length===0&&t.addIssue({code:`custom`,message:`Thread Usage must contain a reliable field`});let n=e.contextUsedTokens!==void 0;n!==(e.contextWindowTokens!==void 0)&&t.addIssue({code:`custom`,message:`Thread Usage context fields must be provided together`,path:[n?`contextWindowTokens`:`contextUsedTokens`]}),e.contextWindowTokens===0&&t.addIssue({code:`custom`,message:`Thread Usage contextWindowTokens must be greater than zero`,path:[`contextWindowTokens`]}),e.costSource!==void 0&&e.totalCostUsd===void 0&&t.addIssue({code:`custom`,message:`Thread Usage costSource must be provided with totalCostUsd`,path:[`costSource`]}),e.unpricedModels!==void 0&&e.costSource!==`publicPrice`&&t.addIssue({code:`custom`,message:`Thread Usage unpricedModels must be provided with a publicPrice cost`,path:[`unpricedModels`]}),e.planFiveHourResetsAtUnix!==void 0&&e.planFiveHourUsedPercent===void 0&&t.addIssue({code:`custom`,message:`Thread Usage planFiveHourResetsAtUnix must be provided with planFiveHourUsedPercent`,path:[`planFiveHourResetsAtUnix`]}),e.planSevenDayResetsAtUnix!==void 0&&e.planSevenDayUsedPercent===void 0&&t.addIssue({code:`custom`,message:`Thread Usage planSevenDayResetsAtUnix must be provided with planSevenDayUsedPercent`,path:[`planSevenDayResetsAtUnix`]})}),lu=I().finite().min(0).max(100),uu=U([`weekly`,`monthly`,`five_hour`,`seven_day`,`unknown`]),du=z({id:F().min(1).max(256),label:F().min(1).max(256),localizations:Al.optional()}).strict(),fu=z({product:F().min(1),periodType:uu.optional(),scope:du.optional(),localizations:Al.optional(),used:I().finite().nonnegative().optional(),limit:I().finite().nonnegative().optional(),unit:F().min(1).max(32).optional(),usagePercent:lu,resetsAt:F().min(1).optional()}).strict(),pu=z({availableCount:I().int().safe().positive(),nextExpiresAt:F().min(1).optional(),expiresAt:R(F().min(1)).min(1).max(32).optional()}).strict(),mu=z({used:I().finite().nonnegative().optional(),limit:I().finite().nonnegative().optional(),unit:F().min(1).max(32).optional(),label:F().min(1).optional(),scope:du.optional(),localizations:Al.optional(),usedPercent:lu,resetsAt:F().min(1).optional(),periodType:uu,productUsage:R(fu).min(1).optional(),resetCredits:pu.optional()}).strict(),hu=z({amount:I().finite().nonnegative(),currency:F().trim().min(1).max(8),label:F().trim().min(1).max(128).optional()}).strict();z({threadId:K,refresh:W(`exact`).optional()}).strict(),z({threadId:K,usage:cu.nullable(),accountCredits:mu.optional(),accountBalance:hu.optional(),accountCreditsSupported:L().optional()}).strict();let gu=F().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),_u=F().min(1).max(512).refine(e=>!/\p{Cc}/u.test(e),`Model Ref must not contain control characters`).brand(),vu=U([`priority`,`ultrafast`]),yu=z({id:_u,serviceTier:vu.optional()}).strict();function bu(e,t){return e?.id===t?.id&&e?.serviceTier===t?.serviceTier}let xu=gu.max(256),Su=z({id:Pl,label:gu.max(256)}).strict(),Cu=z({ref:yu,label:gu.max(256),resolvedModelLabel:xu.optional(),fastModel:yu.optional(),supportedThinkingOptionIds:R(Pl).optional()}).strict().refine(e=>e.fastModel?.serviceTier===void 0||e.fastModel.id===e.ref.id,{path:[`fastModel`,`id`],message:`A tiered Fast Model must share the base Model ID`});function wu(e,t){if(t)return e?.models.find(e=>bu(e.ref,t)||bu(e.fastModel,t))}let Tu=R(Su).superRefine((e,t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.entries())n.has(i.id)&&t.addIssue({code:`custom`,message:`Thinking option IDs must be unique`,path:[r,`id`]}),n.add(i.id)}),Eu=U([`catalog`,`activeModel`]),Du=z({models:R(Cu),defaultModel:yu.optional(),thinkingOptions:Tu,defaultThinkingOptionId:Pl.optional(),thinkingOptionsScope:Eu.optional()}).strict().superRefine((e,t)=>{let n=[],r=new Set(e.thinkingOptions.map(({id:e})=>e));for(let[i,a]of e.models.entries()){n.some(e=>bu(e,a.ref))&&t.addIssue({code:`custom`,message:`Model Catalog refs must be unique`,path:[`models`,i,`ref`,`id`]}),n.push(a.ref),a.fastModel&&(n.some(e=>bu(e,a.fastModel))&&t.addIssue({code:`custom`,message:`Fast Model refs must be distinct and unique`,path:[`models`,i,`fastModel`]}),n.push(a.fastModel));let e=/* @__PURE__ */ new Set;for(let[n,o]of(a.supportedThinkingOptionIds??[]).entries())e.has(o)&&t.addIssue({code:`custom`,message:`Supported Thinking option IDs must be unique per Model`,path:[`models`,i,`supportedThinkingOptionIds`,n]}),e.add(o),r.has(o)||t.addIssue({code:`custom`,message:`Supported Thinking option must exist in the catalog`,path:[`models`,i,`supportedThinkingOptionIds`,n]})}e.defaultModel&&!wu(e,e.defaultModel)&&t.addIssue({code:`custom`,message:`Default Model must exist in the Model Catalog`,path:[`defaultModel`,`id`]}),e.defaultThinkingOptionId&&!r.has(e.defaultThinkingOptionId)&&t.addIssue({code:`custom`,message:`Default Thinking option must exist in the catalog`,path:[`defaultThinkingOptionId`]})}),Ou=z({fork:L(),forkAcrossCwd:L(),rollbackLastTurn:L()}).strict().refine(e=>e.fork||!e.forkAcrossCwd,{path:[`forkAcrossCwd`],message:`Cross-cwd Fork requires exact history Fork support`}),ku=U([`live`,`atCreate`]),Au=z({configuration:z({selectModel:L(),selectThinkingOption:L(),selectPermissionMode:L(),permissionModeScope:ku.default(`live`)}).strict(),history:Ou,subagents:z({observe:L(),readTranscript:L()}).strict().optional(),autonomousTurns:z({observe:L()}).strict().optional(),steer:L().optional(),persistentPlan:L().optional()}).strict();z({effectiveModel:yu.optional(),resolvedModelLabel:xu.optional(),effectiveThinkingOptionId:Pl.optional(),availableThinkingOptions:Tu.optional(),effectivePermissionModeId:Il.optional()}).strict().superRefine((e,t)=>{e.effectiveThinkingOptionId&&e.availableThinkingOptions&&!e.availableThinkingOptions.some(({id:t})=>t===e.effectiveThinkingOptionId)&&t.addIssue({code:`custom`,message:`Effective Thinking option must be currently available`,path:[`effectiveThinkingOptionId`]})});let ju=z({open:W(!0)}).strict();V([z({status:W(`ready`),catalog:Du,permissionModes:Ll.optional(),capabilities:Au,webUi:ju.optional()}).strict().superRefine((e,t)=>{let n=e.capabilities.configuration.selectPermissionMode;n!==!!e.permissionModes&&t.addIssue({code:`custom`,message:`Permission Mode catalog and capability must agree`,path:n?[`permissionModes`]:[`capabilities`,`configuration`,`selectPermissionMode`]})}),z({status:U([`notInstalled`,`unavailable`,`error`]),error:Dl}).strict()]),z({harnessId:G,cwd:gu.max(16384).optional(),refresh:L().optional(),purpose:W(`availability`).optional(),credentialAccess:U([`allow`,`retry`]).optional()}).strict(),z({harnessId:G}).strict(),z({}).strict(),z({threadId:K,model:yu}).strict(),z({threadId:K,thinkingOptionId:Pl}).strict(),z({threadId:K,includeReferenceCapability:L().optional()}).strict(),H(`owner`,[z({owner:W(`codex`),locked:L(),effectiveModel:yu.optional(),resolvedModelLabel:xu.optional(),effectiveThinkingOptionId:Pl.optional(),effectivePermissionModeId:Il.optional(),history:Ou.optional(),supportsThreadReferences:W(!0).optional(),handoff:zl.optional(),roleSnapshot:eu.optional(),nativeSessionRef:Mc().optional()}),z({owner:W(`external`),harnessId:gu.max(256),transportModelId:gu.max(8192),effectiveModel:yu.optional(),resolvedModelLabel:xu.optional(),effectiveThinkingOptionId:Pl.optional(),availableThinkingOptions:Tu.optional(),effectivePermissionModeId:Il.optional(),catalog:Du.optional(),history:Ou,usage:cu.optional(),handoff:zl.optional(),roleSnapshot:eu.optional(),nativeSessionRef:Mc().optional(),locked:W(!0)})]),z({threadIds:R(K).min(1).max(100)}).strict().superRefine(({threadIds:e},t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.entries())n.has(i)&&t.addIssue({code:`custom`,message:`Thread ownership-list IDs must be unique`,path:[`threadIds`,r]}),n.add(i)});let Mu=H(`owner`,[z({threadId:K,owner:W(`codex`)}).strict(),z({threadId:K,owner:W(`external`),harnessId:F().max(256).pipe(G)}).strict()]);z({threads:R(Mu).min(1).max(100)}).strict().superRefine(({threads:e},t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.entries())n.has(i.threadId)&&t.addIssue({code:`custom`,message:`Thread ownership-list results must be unique`,path:[`threads`,r,`threadId`]}),n.add(i.threadId)}),z({threadId:K,text:F().optional()}).strict(),z({kind:W(`application`),value:F().transform((e,t)=>{try{return JSON.parse(e)}catch{return t.addIssue({code:`custom`,message:`Invalid steering context JSON`}),Et}}).pipe(z({expectedTurnId:Nl,clientUserMessageId:F().min(1),delivery:U([`newTurn`,`activeTurn`])}).strict())}).strict().transform(e=>e.value),U([`activeTurn`,`newTurn`]),z({delivery:U([`official`,`activeTurn`,`newTurn`])}).strict();let Nu=F().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u),Pu=Nu.pipe(G),Fu=Pu.refine(e=>e!==`codex`,`The official Codex identity is reserved`),Iu=F().min(1).max(512).refine(e=>!/[\\\u0000:#?]/u.test(e)&&!e.startsWith(`/`)&&!e.split(`/`).some(e=>e===`..`||e===``),`Plugin resources must be relative paths inside the plugin`),Lu=sc().refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Plugin documentation links must be credential-free HTTPS URLs`),Ru=z({en:F().max(4096),"zh-CN":F().max(4096).optional()}).strict(),zu=z({commands:R(z({terminal:F().max(256),command:F().max(4096)}).strict()).max(8),before:Ru.optional(),after:Ru.optional(),downloads:R(z({label:F().max(128),url:Lu}).strict()).max(8).optional()}).strict(),Bu={id:Pu,name:F().trim().min(1).max(128),version:F().min(1).max(128),kind:W(`usage`).optional(),iconStyle:z({vector:z({viewBox:F().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),color:F().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),paths:R(z({d:F().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),fillRule:U([`evenodd`,`nonzero`]).optional(),fill:F().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()}).strict()).min(1).max(32)}).strict().optional(),background:F().regex(/^#[a-f0-9]{6}$/iu).optional(),borderRadius:I().min(0).max(50).optional(),paddingRatio:I().min(0).max(.25).optional()}).strict().optional(),installation:zu.optional(),notice:Ru.optional(),launchCommand:W(!0).optional(),links:z({website:Lu.optional(),documentation:Lu.optional(),installation:Lu.optional()}).strict().optional()};z({manifestVersion:W(1),...Bu,adapterApiVersion:I().int().positive(),entry:Iu,icon:Iu.optional()}).strict();let Vu=F().max(174828).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u),Hu=z({...Bu,icon:Vu.optional()}).strict();z({}).strict(),z({plugins:R(Hu.extend({id:Fu})).max(128)}).strict(),z({version:W(1),enabled:R(Pu).max(128)}).strict().refine(e=>new Set(e.enabled).size===e.enabled.length,{message:`Enabled plugin IDs must be unique`,path:[`enabled`]});let Uu=131072,Wu=524288,Gu=Nu,Ku=U([`sidebar.thread-layout`,`sidebar.thread-badge`,`appearance.theme`]),qu=U([`appearance`,`interface`,`workflow`,`analytics`,`integrations`,`tools`]),Ju=F().trim().min(1).max(128);function Yu(e){switch(e.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()){case`png`:return`image/png`;case`jpg`:case`jpeg`:return`image/jpeg`;case`webp`:return`image/webp`;default:return}}let Xu=e=>e.split(`/`).every(e=>!/[. ]$/u.test(e)),Zu=Iu.refine(e=>Yu(e)!==void 0&&Xu(e),`Images must be relative .png, .jpg, .jpeg, or .webp paths with no segments ending in a dot or space`),Qu=F().trim().max(2048).regex(/^https?:\/\/[^/?#\\\s]+/iu,`Expected an HTTP(S) URL`).pipe(sc({protocol:/^https?$/u})).refine(e=>{let{username:t,password:n}=new URL(e);return!t&&!n&&!/[\\\s]/u.test(e)},`URL must not contain credentials, backslashes, or whitespace`);function $u(e){return B({en:e,"zh-CN":e})}let ed=$u(F().trim().min(1)),td=R(qu).max(qu.options.length).refine(e=>new Set(e).size===e.length,`Duplicate categories`),nd=R(Ku).max(Ku.options.length).refine(e=>new Set(e).size===e.length,`Duplicate slots`),rd={key:F().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),label:ed,description:ed.optional()},id={...rd,step:I().positive().optional(),default:I().optional()},ad=B({value:F(),label:ed}),od=H(`type`,[B({...rd,type:W(`boolean`),default:L().optional()}),B({...rd,type:W(`string`),placeholder:ed.optional(),default:F().optional()}),B({...id,type:W(`number`),min:I().optional(),max:I().optional()}),B({...id,type:W(`range`),min:I(),max:I()}),B({...rd,type:W(`select`),options:R(ad).min(1),default:F().optional()})]).superRefine((e,t)=>{let n=(e,n)=>t.addIssue({code:`custom`,path:[e],message:n});if(e.type===`number`||e.type===`range`){let{min:t=-1/0,max:r=1/0,default:i}=e;t>r&&n(`max`,`Must be at least min`),i!==void 0&&(i<t||i>r)&&n(`default`,`Must be within min and max`)}else if(e.type===`select`){let t=new Set(e.options.map(({value:e})=>e));t.size!==e.options.length&&n(`options`,`Duplicate option values`),e.default!==void 0&&!t.has(e.default)&&n(`default`,`Must match an option value`)}}),sd=z({manifestVersion:Tc().positive(),id:Gu,name:V([Ju,$u(Ju)]),version:F().min(1).max(128),desktopApi:Tc().positive()}).passthrough().extend({manifestVersion:W(1),desktopApi:W(1),description:B({en:F().max(4096),"zh-CN":F().max(4096).optional()}).optional(),author:F().trim().min(1).max(128).optional(),repository:Qu.optional(),details:B({en:F().max(16384),"zh-CN":F().max(16384).optional()}).optional(),icon:Zu.optional(),screenshots:R(Zu).max(4).refine(e=>new Set(e).size===e.length,`Duplicate screenshots`).optional(),desktop:B({script:Iu,style:Iu.optional()}).optional(),backend:B({script:Iu.refine(Xu)}).optional(),slots:nd.default(()=>[]),settingsSchema:R(od).max(32).refine(e=>new Set(e.map(({key:e})=>e)).size===e.length,`Duplicate setting keys`).optional(),categories:td.optional()}).strict().refine(e=>e.desktop!==void 0||e.backend!==void 0,`Expected at least one desktop or backend entry`),cd=F().regex(/^[a-f0-9]{64}$/u),ld=B({state:U([`running`,`disabled`,`invalid`,`incompatible`,`conflict`,`failed`,`waiting`]),hash:cd.optional(),error:F().optional(),conflictWith:Gu.optional()});B({controllerPid:Tc().positive(),targetId:F().nullable(),updatedAt:yl(),handledReloadToken:ic().optional(),extensions:Hc(F(),ld),surfaces:Hc(F(),ld).optional()});let ud=U([`official`,`community`]);function dd(e){return e.origin===`https://api.github.com`&&/^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(e.pathname)}let fd=Qu.refine(e=>{let t=new URL(e);return/\.zip$/iu.test(t.pathname)||dd(t)||t.origin===`https://github.com`&&/^\/[\w-]+\/[\w.-]+\/zipball(?:\/.+)?\/?$/u.test(t.pathname)||t.origin===`https://codeload.github.com`&&/^\/[\w-]+\/[\w.-]+\/(?:zip|zipball|legacy\.zip)\/.+$/u.test(t.pathname)},`Expected a .zip download URL or a GitHub zipball URL`),pd=B({id:Gu,version:F().trim().min(1).max(128),name:ed.extend({en:Ju,"zh-CN":Ju}),description:$u(F().trim().min(1).max(4096)),details:$u(F().trim().min(1).max(16384)).optional(),author:F().trim().min(1).max(128),repository:Qu,stars:I().int().min(0).optional(),downloads:I().int().min(0).optional(),categories:td.optional(),trustTier:ud.default(`community`),icon:Qu.optional(),screenshots:R(Qu).max(4).optional(),downloadUrl:fd,sha256:cd,slots:nd.optional(),publishedAt:F().optional(),updatedAt:F().optional(),minCodexHostVersion:F().optional()});B({schemaVersion:W(1),generatedAt:F(),extensions:R(pd).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,`Duplicate extension IDs`)});let md=F().trim().min(1).max(128),hd=/^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³]) *(?:\.|$)/iu,gd=Gu.refine(e=>!hd.test(e),`Reserved extension ID`),_d=U([`desktop`,`web`]),vd=cd,yd=ic(),bd=Iu.refine(e=>!/[\x00-\x1f\x7f<>"|*]/u.test(e)&&e.split(`/`).every(e=>!/[. ]$/u.test(e)&&!hd.test(e)),`Expected a portable relative resource path`).refine(e=>e.split(`/`).length<=32,`Extension resources may be at most 32 segments deep`),xd=sd.shape,Sd=(e,t=0)=>B({en:F().trim().min(t).max(e),"zh-CN":F().trim().min(t).max(e)}),Cd=e=>bd.refine(t=>t.endsWith(e),`Expected a ${e} file`),wd=Cd(`.mjs`),Td=Cd(`.css`).optional(),Ed=e=>e.normalize(`NFC`).toLowerCase(),Dd=B({manifestVersion:W(2),id:gd,name:Sd(128,1),version:F().trim().min(1).max(128),description:Sd(4096),details:Sd(16384).optional(),author:xd.author,repository:xd.repository,icon:xd.icon.refine(e=>e===void 0||bd.safeParse(e).success),screenshots:xd.screenshots.refine(e=>e===void 0||e.every(e=>bd.safeParse(e).success)),categories:xd.categories,settingsSchema:xd.settingsSchema,slots:xd.slots.removeDefault().optional(),page:B({apiVersion:W(1),entry:wd,style:Td,title:Sd(128,1).optional()}).optional(),widget:B({apiVersion:W(1),entry:wd,style:Td}).optional(),desktop:B({apiVersion:W(1),script:Cd(`.js`),style:Td}).optional(),web:B({apiVersion:W(1),entry:wd.optional(),style:Td}).refine(({entry:e,style:t})=>e!==void 0||t!==void 0,`Expected a Web entry or style`).optional(),backend:B({apiVersion:W(1),entry:wd}).optional()}).refine(({page:e,widget:t,desktop:n,web:r,backend:i})=>!!(e||t||n||r||i),`Expected at least one page, widget, desktop, web, or backend entry`).refine(({page:e,widget:t,web:n,backend:r})=>!r||[e?.entry,t?.entry,n?.entry].every(e=>e===void 0||Ed(e)!==Ed(r.entry)),{path:[`backend`,`entry`],message:`A backend entry cannot also be a frontend entry`});function Od({hasPage:e,hasWidget:t,hasDesktop:n,hasWeb:r,hasBackend:i}){if(e||t||i&&!n&&!r)return[`desktop`,`web`];let a=[];return n&&a.push(`desktop`),r&&a.push(`web`),a}let kd=md,Ad=U([`running`,`waiting`,`idle`,`unknown`]),jd=z({createdAtMs:I().int().nonnegative()}),Md=B({sourceThreadId:K,createdAtMs:I().int().nonnegative()}),Nd=B({harnessId:G,title:F().optional(),status:Ad,archived:L(),updatedAtMs:I().int().nonnegative().optional()}),Pd=z({revision:Tc().nonnegative(),parents:Hc(K,K),delegations:Hc(K,jd).optional(),handoffs:Hc(K,Md).optional(),nodes:Hc(K,Nd),truncated:L()}).refine(e=>Object.keys(e.nodes).length<=5e3,`Too many Thread tree nodes`).refine(({parents:e,handoffs:t,nodes:n})=>Object.entries(e).every(([e,t])=>Object.hasOwn(n,e)&&Object.hasOwn(n,t))&&Object.entries(t??{}).every(([e,{sourceThreadId:t}])=>Object.hasOwn(n,e)&&Object.hasOwn(n,t)),`Missing Thread tree node`).refine(({parents:e,delegations:t})=>Object.keys(t??{}).every(t=>Object.hasOwn(e,t)),`Delegation metadata requires a matching parent edge`),Fd=F().min(1).max(128);B({});let Id=B({subscriptionId:Fd});B({}),Id.extend({snapshot:Pd});let Ld=Tc().nonnegative(),Rd=B({revision:Ld,enabled:R(gd).max(64).refine(e=>new Set(e).size===e.length,`Duplicate extension IDs`)});B({version:W(1),seeded:R(gd).max(64).refine(e=>new Set(e).size===e.length,`Duplicate extension IDs`)});let zd=z({version:F().trim().min(1).max(128),publishedAt:F().trim().min(1).max(64).optional(),notes:F().trim().min(1).max(8192),url:Qu.optional()}),{downloadUrl:Bd,...Vd}=pd.shape,Hd=z({...Vd,id:gd,format:W(`codexhost`),targets:R(_d).min(1).max(2).refine(e=>new Set(e).size===e.length,`Duplicate targets`),apis:B({page:Tc().positive().optional(),widget:Tc().positive().optional(),desktop:Tc().positive().optional(),web:Tc().positive().optional(),backend:Tc().positive().optional()}),downloadUrl:Bd.refine(e=>e.startsWith(`https://`),`Expected HTTPS`),featured:L().optional(),featuredOrder:Tc().nonnegative().optional(),changelog:R(zd).max(20).optional()}).refine(({targets:e,apis:t})=>{let n=Od({hasPage:!!t.page,hasWidget:!!t.widget,hasDesktop:!!t.desktop,hasWeb:!!t.web,hasBackend:!!t.backend});return e.length===n.length&&n.every(t=>e.includes(t))},`Catalog targets must match the declared APIs`);z({schemaVersion:W(2),generatedAt:F().min(1),extensions:R(Hd).max(1e4).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,`Duplicate extension IDs`)}).extend({catalogUrl:Qu,fetchedAt:yl(),cached:L(),stale:L().optional()});let Ud={id:gd},Wd={...Ud,activationId:yd,digest:vd},Gd={...Ud,activationId:Wd.activationId.optional()},Kd=F().min(1).max(4096).refine(e=>/^(?:\/|[a-z]:[/\\])/iu.test(e)&&!e.includes(`\0`)&&!e.split(/[/\\]/u).some(e=>e===`.`||e===`..`),`Expected an absolute local path without dot segments`),qd=F().min(1).max(256).refine(e=>e.split(`/`).every(e=>e&&/^[a-z0-9_.-]+$/iu.test(e)&&e!==`.`&&e!==`..`),`Invalid GitHub ref`);function Jd(e){return F().max(4*Math.ceil(e/3)).refine(t=>{let n=t.endsWith(`==`)?2:+!!t.endsWith(`=`);return t.length%4==0&&t.length*3/4-n<=e&&/^[A-Za-z0-9+/]*={0,2}$/u.test(t)},`Expected bounded standard padded base64`)}let Yd=B({type:W(`github`),repository:F().max(150).regex(/^[a-z0-9-]+\/[a-z0-9_-][a-z0-9_.-]*$/iu),ref:qd.optional(),tag:qd.optional(),asset:F().max(255).regex(/^[a-z0-9_.-]+\.zip$/iu).optional(),subpath:bd.optional()}).refine(({ref:e,tag:t,asset:n})=>!e||!t&&!n,`Use either a zipball ref or a release tag/asset`),Xd=V([B({type:W(`catalog`),...Ud}),Yd,B({type:W(`zip`),base64:Jd(67108864).min(4)}),B({type:W(`zip`),localZipPath:Kd}),B({type:W(`localDir`),localDir:Kd})]),Zd=H(`type`,[B({type:W(`catalog`),...Ud}),Yd,B({type:W(`zip`)}),B({type:W(`localDir`)})]),Qd=B({...Wd,manifest:Dd,installedAt:yl(),source:Zd.optional()}),$d=e=>F().max(23+4*Math.ceil(e/3)).regex(/^data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2}$/u),ef={desktopConflictWith:gd.optional()},tf=U([`none`,`inactive`,`starting`,`running`,`failed`]),nf=H(`state`,[Qd.extend({state:W(`valid`),enabled:L(),...ef,iconDataUrl:$d(Uu).optional(),screenshotDataUrls:R($d(Wu)).max(4).optional(),backendState:tf.optional(),backendError:F().optional()}),B({state:U([`invalid`,`incompatible`]),id:F().min(1),enabled:L(),error:F()})]);B({revision:Ld,configuration:Rd,diagnostics:R(F()),extensions:R(nf)}),B({revision:Ld,extensions:R(Qd.extend({...ef,settingsRevision:Ld})).max(64)});let rf={list:`codexhost/extensions/list`,snapshot:`codexhost/extensions/snapshot`,catalog:`codexhost/extensions/catalog`,catalogIcon:`codexhost/extensions/catalogIcon`,catalogScreenshot:`codexhost/extensions/catalogScreenshot`,install:`codexhost/extensions/install`,update:`codexhost/extensions/update`,enable:`codexhost/extensions/enable`,disable:`codexhost/extensions/disable`,uninstall:`codexhost/extensions/uninstall`,recover:`codexhost/extensions/recover`,asset:`codexhost/extensions/asset`,settingsGet:`codexhost/extensions/settings/get`,settingsSet:`codexhost/extensions/settings/set`,backendInvoke:`codexhost/extensions/backend/invoke`,threadTree:`codexhost/extensions/threadTree`},af=Object.freeze(Object.values(rf));new Set(af),B({});let of={expectedRevision:Ld};B({...Ud,...of}),Qd.extend({replaced:L()}),H(`state`,[B({state:W(`saved`),configuration:Rd}),B({state:W(`revision-conflict`),revision:Ld})]),B({...Gd,digest:Wd.digest.optional(),path:bd}),B({mimeType:F().min(1),base64:Jd(16777216),digest:Wd.digest}),B({mimeType:U([`image/png`,`image/jpeg`,`image/webp`]),base64:Jd(Uu)});let sf=Tc().min(0).max(3);B({mimeType:U([`image/png`,`image/jpeg`,`image/webp`]),base64:Jd(Wu)}),B({settingsRevision:Ld,values:El}),rf.list,rf.snapshot,rf.catalog,B({forceRefresh:L().optional(),staleWhileRevalidate:L().optional()}),rf.catalogIcon,B({...Ud}),rf.catalogScreenshot,B({...Ud,index:sf}),rf.install,B({source:Xd}),rf.update,B({...Ud,expectedDigest:Wd.digest,expectedActivationId:Wd.activationId.optional(),source:Xd.optional()}),rf.enable,rf.disable,rf.uninstall,B({...Ud,removeData:L().optional(),expectedDigest:Wd.digest.optional()}),B({...Ud,removed:L()}),rf.recover,B({expectedRevision:of.expectedRevision.optional()}),rf.asset,rf.settingsGet,B(Gd),rf.settingsSet,B({...Gd,expectedSettingsRevision:Ld,values:El}),rf.backendInvoke,B({...Gd,method:kd,params:Tl.optional()}),B({result:Tl}),rf.threadTree;let cf=F().regex(/^remote:[A-Za-z0-9_-]{8,512}$/u),lf=V([ac(),cf]),uf=ac(),df=F().regex(/^[a-z0-9][a-z0-9_-]{0,47}$/u),ff=U([`none`,`last_speaker`,`all`]),pf=U([`active`,`muted`,`removed`]),mf=Tc().nonnegative(),hf=Tc().positive(),gf=hf.max(20),_f=F().refine(e=>e.trim().length>0),vf=yl(),yf={handle:df.optional(),displayName:_f.optional(),note:F().optional()},bf=z({memberId:uf,threadId:K,handle:df,displayName:_f,note:F().optional(),roleSlug:Bl.optional(),roleSnapshot:eu.optional(),harnessId:G,status:pf,projectless:L().optional(),joinedAtSeq:mf,lastDeliveredSeq:mf,lastRosterVersion:mf,createdAt:vf}),xf=z({workspaceRoot:_f,outputDirectory:_f}),Sf=z({hostId:_f,displayName:_f,state:_f.optional(),color:F().optional(),filePreview:L().optional()}),Cf=z({roomId:lf,title:_f,defaultCwd:_f,projectlessWorkspace:xf.optional(),unmentionedPolicy:ff.default(`none`),allowAgentMentions:L().default(!0),maxAgentHops:gf.default(5),lastSeq:mf,lastSpeakerMemberId:uf.optional(),rosterVersion:mf,humanEpoch:mf,relayPaused:L(),pinned:L(),createdAt:vf,updatedAt:vf,members:R(bf),remote:Sf.optional()}).superRefine(({members:e},t)=>{let n=/* @__PURE__ */ new Set;for(let[r,{handle:i,status:a}]of e.entries())a!==`removed`&&(n.has(i)&&t.addIssue({code:`custom`,path:[`members`,r,`handle`],message:`Handle must be unique among non-removed members`}),n.add(i))}),wf=z({kind:U([`image`,`file`]),attachmentId:_f.max(256),name:_f.max(256),path:_f.max(4096),bytes:mf,mediaType:_f.max(128).optional(),width:hf.optional(),height:hf.optional()}),Tf=z({roomId:lf,seq:hf,messageId:_f,senderType:U([`user`,`agent`,`system`]),senderMemberId:uf.optional(),senderHandle:df.optional(),senderName:F().optional(),senderThreadId:K.optional(),sourceTurnId:_f.optional(),replyToSeq:hf.optional(),content:F(),attachments:R(wf).max(12).optional(),mentionedMemberIds:R(uf),mentionAll:L().optional(),hopCount:mf,createdAt:vf}),Ef={...yf,model:Vl.optional(),thinkingOptionId:Pl.optional(),worktree:L().optional()},Df=H(`kind`,[B({kind:W(`role`),roleSlug:Bl,...Ef}),B({kind:W(`harness`),harnessId:G,...Ef}),B({kind:W(`existing`),threadId:K,...yf,includeRecentHistory:L().default(!0).optional()})]),Of={roomId:lf},kf={...Of,memberId:uf},Af={title:_f.optional(),unmentionedPolicy:ff.optional(),allowAgentMentions:L().optional(),maxAgentHops:gf.optional()};B({}),z({rooms:R(Cf)}),B({...Of,limit:hf.optional(),beforeSeq:hf.optional()}),z({room:Cf.nullable(),messages:R(Tf),hasMore:L()}),B({...Af,defaultCwd:_f.optional(),members:R(Df)}),z({room:Cf}),B({...Of,...Af,pinned:L().optional(),relayPaused:L().optional()}),B(Of),z({deleted:L()}),B({...Of,member:Df}),z({room:Cf,member:bf}),B({...kf,...yf,status:pf.optional()}),B(kf),B({...kf,threadId:K,redeliverFrom:hf.optional(),note:F().optional()}),B({...Of,memberId:uf.optional(),memberHandle:df.optional(),threadId:K,redeliverFrom:hf.optional(),note:F().optional()}).refine(e=>e.memberId!==void 0!=(e.memberHandle!==void 0),`Provide exactly one of memberId or memberHandle`),z({room:Cf,member:bf,previousThreadId:K,awakened:L()});let jf=z({roomId:lf,title:_f,memberCount:mf,updatedAt:vf,member:z({memberId:uf,threadId:K,handle:df,displayName:_f,status:pf,harnessId:G,roleSlug:Bl.optional(),roleName:_f.optional()}).optional()});B({threadId:K.optional()}),z({rooms:R(jf)}),B({...Of,content:F().max(64e3),attachments:R(wf).max(12).optional(),replyToSeq:hf.optional(),targetMemberIds:R(uf).optional(),mentionAll:L().optional(),notice:L().optional()}).superRefine((e,t)=>{e.notice===!0?(e.content.trim().length===0&&t.addIssue({code:`custom`,path:[`content`],message:`Notice content is required`}),e.content.length>2e3&&t.addIssue({code:`custom`,path:[`content`],message:`Notice content must be at most 2000 characters`}),((e.targetMemberIds?.length??0)>0||e.mentionAll===!0||(e.attachments?.length??0)>0)&&t.addIssue({code:`custom`,path:[`notice`],message:`System notices cannot target members or include attachments`})):e.content.trim().length===0&&(e.attachments?.length??0)===0&&t.addIssue({code:`custom`,path:[`content`],message:`Message content or at least one attachment is required`})}),z({room:Cf,message:Tf,awakenedMemberIds:R(uf)}),B({...Of,fromSeq:hf.optional(),toSeq:hf.optional(),limit:hf.optional()}),z({...Of,messages:R(Tf),totalSeq:mf}),B({cwd:_f,roomId:lf.optional()}),z({isGitRepo:L()});let Mf=/\[@([^\]\n]+)\]\(group-member:\/\/([A-Za-z0-9._:%-]+)\)/gu;function Nf(e){try{let t=decodeURIComponent(e).trim();return t.length>0?t:null}catch{return null}}function Pf(e){let t=[],n=0;for(let r of e.matchAll(Mf)){let i=r.index??0,a=r[0],o=r[1]?.trim()??``,s=r[2]?Nf(r[2]):null;o&&s!==null&&(i>n&&t.push({kind:`text`,text:e.slice(n,i)}),t.push({kind:`mention`,label:o,target:s,raw:a}),n=i+a.length)}return n<e.length&&t.push({kind:`text`,text:e.slice(n)}),t}function Ff(e){return e.replace(/&(amp|lt|gt|quot|#(\d+));/gu,(e,t,n)=>{if(n!==void 0)return String.fromCharCode(Number(n));switch(t){case`amp`:return`&`;case`lt`:return`<`;case`gt`:return`>`;case`quot`:return`"`;default:return e}})}function If(e,t){let n=RegExp(`(?:^|\\s)${t}="([^"]*)"`,`u`).exec(e);return n?.[1]===void 0?void 0:Ff(n[1])}function Lf(e){let t=e.trim();if(!t.startsWith(`<codexhost_group `)||!t.endsWith(`</codexhost_group>`))return null;let n=/^<codexhost_group(\s[^>]*)>/u.exec(t);if(!n?.[1])return null;let r=n[1],i=If(r,`room`);if(i===void 0)return null;let a=If(r,`room_id`),o=If(r,`you`),s=t.indexOf(`<messages>`),c=t.lastIndexOf(`</messages>`);if(s<0||c<s)return null;let l=t.slice(s+10,c),u=[];for(let e of l.matchAll(/<msg(\s[^>]*)>([\s\S]*?)<\/msg>/gu)){let t=e[1]??``,n=e[2]??``,r=If(t,`from`)??`user`,i=If(t,`seq`),a=i!==void 0&&/^\d+$/u.test(i)?Number(i):void 0,o=If(t,`sender_type`),s=o===`user`||o===`agent`||o===`system`?o:r===`user`?`user`:`agent`;u.push({...a===void 0?{}:{seq:a},from:r,senderType:s,content:Ff(n)})}return{roomTitle:i,...a===void 0?{}:{roomId:a},...o===void 0?{}:{you:o},messages:u,hasOmittedEarlier:t.slice(0,s).includes(`Earlier messages (`)}}z({threadId:K}).strict(),z({confirmed:L()}).strict();let Rf=[`codex-desktop`,`web`,`web-desktop-shell`,`web-mobile`,`ssh-remote`,`cli`],zf=[`darwin`,`win32`,`linux`],Bf=[`arm64`,`x64`,`ia32`,`arm`],Vf=[`zh`,`en`,`ja`,`ko`,`de`,`fr`,`es`,`pt`,`ru`,`other`],Hf=[`codex`,`claude-code`,`antigravity`,`pi`,`opencode`,`cursor-cli`,`deepseek-harness`,`grok`,`omp`,`qwen-code`,`kiro-cli`,`codebuddy`,`workbuddy`,`workbuddy-cn`,`devin`,`hermes`,`qoder`,`qoder-cn`,`kimi-code`,`zcode`,`copilot`,`custom`],Uf=[`official-relay`,`self-hosted-relay`,`tailscale-serve`,`tailscale-funnel`,`tailscale-ip`,`lan`,`custom-proxy`,`remote-peer`],Wf=F().min(1).max(40).regex(/^[0-9A-Za-z._+-]+$/u),Gf=U(Rf),Kf=U(Vf),qf=U(Hf),Jf=U(Uf);new Set(Hf),new Set(Vf),z({enabled:L(),forcedOffByEnv:L()}).strict(),z({enabled:L()}).strict(),z({surfaces:R(Gf).max(12).optional(),harnesses:R(qf).max(32).optional(),remoteAccess:R(Jf).max(12).optional()}).strict(),z({dailyActive:W(!0).optional(),weeklyActive:W(!0).optional(),monthlyActive:W(!0).optional(),newInstall:W(!0).optional(),retainedD1:W(!0).optional(),retainedD7:W(!0).optional(),remoteAny:W(!0).optional(),appVersion:Wf.optional(),codexDesktopVersion:Wf.optional(),os:U(zf).optional(),arch:U(Bf).optional(),uiLanguage:Kf.optional(),surfaces:R(Gf).min(1).max(12).optional(),harnesses:R(qf).min(1).max(32).optional(),remoteAccess:R(Jf).min(1).max(12).optional()}).strict().refine(e=>Object.keys(e).length>0,{message:`Telemetry heartbeat must contain at least one countable field`});let Yf=4e3,Xf={threadId:K};H(`action`,[B({...Xf,action:U([`get`,`pause`,`resume`,`clear`])}),B({...Xf,action:U([`create`,`edit`]),objective:F().trim().min(1).refine(e=>Array.from(e).length<=Yf,`A goal objective can have up to ${Yf} characters.`)})]),z({goal:z({threadId:K,objective:F(),status:U([`active`,`paused`,`blocked`,`usageLimited`,`budgetLimited`,`complete`]),tokenBudget:Tc().positive().nullable().default(null),tokensUsed:Tc().nonnegative(),timeUsedSeconds:Tc().nonnegative()}).nullable()});let Zf=F().trim().min(1),Qf=F().min(1),$f=z({icon:F().nullable(),color:F().nullable()}),ep=$f.nullable(),tp={create:{method:`codexhost/thread/sections/create`,params:z({name:Zf}).strict()},update:{method:`codexhost/thread/sections/update`,params:z({sectionId:Qf,name:Zf,appearance:$f.strict().nullable().optional()}).strict()},delete:{method:`codexhost/thread/sections/delete`,params:z({sectionId:Qf}).strict()}};H(`status`,[z({status:W(`unknown`)}),z({status:W(`confirmed`),sectionId:Qf,section:z({id:Qf,name:F().min(1),appearance:ep}).nullable(),syncPending:L()})]),[tp.create.method,tp.update.method,tp.delete.method,...af],z({threadSectionsV1:W(!0).optional(),complete:W(!1).optional(),sections:R(z({id:F().min(1),name:F().min(1),appearance:ep.optional(),threads:R(El)}))}),z({threadId:F().min(1).max(1024),sectionId:F().min(1).max(1024).nullable(),beforeThreadId:F().min(1).max(1024).nullable().optional(),expectedSourceSectionId:F().min(1).max(1024).optional()}).refine(e=>e.expectedSourceSectionId===void 0||e.sectionId===null),z({threadIds:R(F().min(1))}).strict(),z({threadId:F().min(1).max(1024),pinned:L()}).strict(),z({}).strict(),z({parents:Hc(F().min(1),F().min(1))}).strict(),z({prompt:F().max(16384).optional()}).strict(),z({projects:R(z({id:F(),name:F(),rootPaths:R(F()),createdAt:I().int().optional()})),nativeProjects:W(!0).optional(),assignments:Hc(F(),F()),projectless:R(F()),pinned:R(F()),sectionProjects:Hc(F(),R(F())).optional(),pinnedProjects:R(F()).optional()});let np=Hc(F(),Ac()),rp=z({epoch:F().uuid(),sequence:I().int().nonnegative()});H(`type`,[z({type:W(`projects-changed`),cursor:rp}),z({type:W(`skills-changed`),cursor:rp,cwd:F().optional()}),z({type:W(`harness-inspection-changed`),cursor:rp,harnessId:F().min(1)}),z({type:W(`display-settings-changed`),cursor:rp}),z({type:W(`sections-changed`),cursor:rp}),z({type:W(`groups-changed`),cursor:rp,roomId:F().optional()}),z({type:W(`preferences-changed`),cursor:rp,revision:I().int().nonnegative()}),z({type:W(`extensions-changed`),cursor:rp,revision:Ld}),z({type:W(`hello`),version:W(1),cursor:rp,reset:L()}),z({type:W(`changed`),cursor:rp,threadId:F().min(1),method:F().min(1)})]);let ip=H(`type`,[z({type:W(`text`),id:F(),prompt:F(),secret:L().optional(),optional:L().optional()}),z({type:W(`choice`),id:F(),prompt:F(),multiple:L(),allowOther:L(),optional:L().optional(),options:R(z({value:F(),label:F(),description:F().optional()}))})]),ap=H(`type`,[z({type:W(`approval`),title:F(),description:F().optional(),subject:Ac().optional(),actions:R(z({id:F(),label:F(),effect:F()}))}),z({type:W(`question`),title:F().optional(),questions:R(ip)})]),op=z({requestId:V([F(),I().int()]),threadId:F(),kind:U([`approval`,`question`]),interaction:ap,request:np}),sp=z({id:F().min(1),clientUserMessageId:F().min(1),input:R(np),presentationInput:R(np).nullable().optional()}).passthrough();z({fields:R(z({path:R(V([F(),I().int().nonnegative()])),originalLength:I().int().nonnegative()}))});let cp=z({id:F().min(1),status:F().min(1),codexhostTurnOutcome:z({status:W(`unknown`),reason:F()}).optional(),items:R(z({id:F().min(1),type:F().min(1)}).passthrough()),codexhostFileOperations:R(z({beforeItemId:F().nullable(),item:z({id:F().min(1),type:F().min(1)}).passthrough()})).optional(),error:z({message:F().optional()}).passthrough().nullable().optional(),fingerprint:F().min(1).optional(),unchanged:W(!0).optional()}).passthrough(),lp=z({id:F().min(1).max(512),fingerprint:F().min(1).max(128)});z({threadId:F().min(1),knownTurns:R(lp).max(64).optional(),truncateToolOutput:L().optional()});let up=z({harnessId:F().min(1),nativeSessionId:F().min(1)});z({cursor:rp,activeTurnId:F().min(1).nullable().optional(),command:z({name:F().min(1),turn:cp,subsequentTurnId:F().min(1).optional()}).optional(),thread:z({id:F().min(1),cwd:F(),modelProvider:F().min(1),createdAt:I(),updatedAt:I(),recencyAt:I().nullable().optional(),status:z({type:F()}).passthrough(),name:F().nullable().optional(),preview:F().optional(),roleSnapshot:eu.optional(),codexhostImportSource:up.optional(),turns:R(cp).length(0)}).passthrough(),turnsPage:z({data:R(cp).max(5),nextCursor:F().nullable()}),configuration:z({codexCollaborationMode:U([`plan`,`default`]).optional(),native:z({model:F().min(1).max(1024).optional(),reasoningEffort:F().min(1).max(128).optional()}).optional(),effectiveModel:yu.optional(),effectiveThinkingOptionId:Pl.optional(),effectivePermissionModeId:Il.optional()}),queue:z({items:R(sp),pausedReason:U([`interrupted`,`outcome-unknown`,`failed`]).nullable()}).optional(),interactions:R(op),handoff:zl.optional()}),z({version:W(1),owner:W(`service`).optional(),pid:I().int().positive(),port:I().int().min(1).max(65535),token:F().regex(/^[0-9a-f]{64}$/u),startedAt:I(),epoch:F().uuid(),capabilities:z({peerDelegation:W(1).optional(),threadReferenceContext:W(1).optional()}).optional()}),z({epoch:F().uuid(),threadId:F().min(1),requestId:V([F(),I().int()]),result:np}),z({includeArchived:L().optional(),officialCursor:z({live:F().nullable(),archived:F().nullable().optional()}).strict().optional(),scope:V([z({cwd:F().min(1).max(4096),excludeCwds:R(F().min(1).max(4096)).max(1024)}).strict(),z({projectId:F().min(1).max(1024),legacyThreadIds:R(F().min(1).max(1024)).max(1024),rootPaths:R(F().min(1).max(4096)).max(1024).optional()}).strict()]).optional()}).strict(),z({threads:R(El),ownership:R(Mu),archivedThreadIds:R(K),officialCursor:z({live:F().nullable(),archived:F().nullable().optional()}).strict().optional()}).strict(),Hu.pick({id:!0,name:!0,icon:!0,iconStyle:!0});let dp=B({threadId:F().max(1024),title:F().max(240),project:F().max(240),harness:B({id:F().min(1).max(128),name:F().min(1).max(128)}).optional(),state:U([`idle`,`running`,`waiting`,`completed`,`failed`]),updatedAt:I().nonnegative()});B({epoch:F().max(128),revision:Tc().nonnegative(),running:Tc().nonnegative(),waiting:Tc().nonnegative(),sessions:R(dp).max(32).default([]),notifications:R(B({threadId:F().max(1024),key:F().max(4096),kind:U([`completed`,`failed`,`approval`,`question`]),revision:Tc().nonnegative()})).max(256)});let fp=F().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);z({available:L()}).strict(),z({path:F().min(1),mimeType:fp}).strict();let pp=U([`credentials-unavailable`,`login-expired`,`rate-limited`,`service-rejected`,`host-incompatible`,`network`,`timeout`,`audio-empty`,`audio-too-large`,`audio-format`,`audio-invalid`]);H(`ok`,[z({ok:W(!0),text:F()}).strict(),z({ok:W(!1),error:z({code:pp}).strict()}).strict()]),z({threadId:K.optional(),cwd:F().min(1).optional()}).strict().refine(e=>!(e.threadId&&e.cwd),{message:`Specify threadId or cwd, not both`});let mp=z({name:F().min(1).regex(/^[^\s[\]]+$/u),description:F().optional(),path:F().min(1),scope:U([`project`,`global`]),source:F().min(1)}).strict();z({revision:I().int().nonnegative(),complete:L(),skills:R(mp),warnings:R(F()).optional()}).strict(),z({cwd:F().min(1).optional()}).strict();let hp=z({kind:U([`public`,`relay`,`tailscale-funnel`,`tailscale-https`,`tailscale`,`lan`,`virtual`]),url:F().min(1)}).strict(),gp=H(`status`,[z({status:W(`not-installed`)}),z({status:W(`not-running`)}),z({status:W(`not-logged-in`)}),z({status:W(`https-disabled`)}),z({status:W(`not-serving`),command:F()}),z({status:W(`occupied`),target:F()}),z({status:W(`serving`),url:F(),funnel:L()}),z({status:W(`error`),message:F()})]);z({state:gp,error:F().optional()}).strict();let _p=H(`status`,[z({status:W(`on`)}),z({status:W(`off`)}),z({status:W(`invalid`),reason:F()})]),vp=z({lan:L(),autostart:_p}).strict(),yp=z({expiresAt:F().optional(),issuing:L(),failure:z({detail:F().optional(),retryAt:F(),paused:L()}).optional()}),bp=H(`status`,[z({status:W(`off`),reason:U([`invite`,`name-taken`,`banned`]).optional()}),z({status:W(`connecting`),reason:U([`full`,`unreachable`]).optional()}),z({status:W(`connected`),url:F(),certificate:yp}),z({status:W(`missing-certificate`),url:F(),certificate:yp}),z({status:W(`stopped`),reason:U([`replaced`,`rejected`,`unsupported-version`])})]);F().max(253).regex(/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?$/i).transform(e=>e.toLowerCase()),F().regex(/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)?$/);let xp=U([`official`,`self-hosted`]);z({secret:F().min(1),lastUsedAt:I().nullable(),networkUrls:R(hp),directCandidates:R(hp).optional(),tailscale:gp,background:vp.optional(),relay:z({state:bp,enabled:L(),kind:xp,officialHost:F(),customHost:F().optional(),officialHostname:F().optional(),customHostname:F().optional(),quotaUntil:F().optional()}).strict().optional()}).strict();let Sp=B({threadId:F().min(1).max(1024),view:U([`result`,`messages`]),from:I().int().min(1).max(2**53-1).optional(),to:I().int().min(1).max(2**53-1).optional()}),Cp=/^[a-zA-Z0-9_-]{1,64}$/u,wp=F().regex(Cp),Tp=F().regex(Cp),Ep=F().regex(/^remote-peer:[a-zA-Z0-9_-]{1,64}$/u),Dp=U([`relay`,`tailscale`,`lan`,`ssh`,`custom`]),Op=U([`auto`,`key`,`password`]);z({host:F().trim().min(1).max(255),port:I().int().min(1).max(65535).optional(),user:F().trim().min(1).max(128).optional(),identityFile:F().trim().min(1).max(1024).optional(),authMode:Op.default(`auto`),remoteDataDir:F().trim().min(1).max(1024).optional()});let kp=z({host:F().min(1).max(255),port:I().int().min(1).max(65535).optional(),user:F().min(1).max(128).optional(),authMode:Op,keyInstalled:L().optional()}),Ap=[`blue`,`purple`,`cyan`,`green`,`amber`,`rose`,`slate`],jp=U(Ap);new Set(Ap);let Mp=U([`connected`,`connecting`,`auth-error`,`offline`,`disabled`]),Np=z({peerId:wp,hostId:Ep,nodeId:Tp.optional(),name:F().min(1).max(120),color:jp.optional(),origin:F().min(1).max(2048),transportKind:Dp,ssh:kp.optional(),encrypted:L(),enabled:L(),state:Mp,supportsPeerPairing:L().optional(),pairedBack:L().optional(),linkedPeerIds:R(wp).max(128).optional(),latencyMs:I().int().nonnegative().optional(),version:F().max(128).optional(),platform:F().max(64).optional(),hostname:F().max(255).optional(),homeDir:F().max(4096).optional(),lastError:F().max(1e3).optional(),projectCount:I().int().nonnegative(),createdAt:F(),updatedAt:F()});z({localPlatform:F().max(64).optional(),peers:R(Np)}),z({connectionUrl:F().min(1).max(4096).optional(),origin:F().min(1).max(2048).optional(),token:F().min(1).max(2048).optional(),name:F().trim().min(1).max(120).optional(),color:jp.optional(),pairBack:L().optional(),meshPeerIds:R(wp).max(64).optional(),selfOrigin:F().min(1).max(2048).optional()}).refine(e=>!!e.connectionUrl||!!e.origin&&!!e.token,`Provide either connectionUrl or both origin and token`),B({origin:F().min(1).max(2048),token:F().min(1).max(2048),name:F().trim().min(1).max(120).optional(),color:jp.optional(),expectedNodeId:Tp.optional()}),z({status:U([`added`,`updated`,`existing`]),peerId:wp,hostId:Ep,nodeId:Tp.optional()});let Pp=U([`added`,`updated`,`existing`,`failed`,`skipped`]);z({results:R(z({targetPeerId:wp,targetName:F().min(1).max(120),introducedHost:V([W(`local`),wp]),introducedName:F().min(1).max(120),status:Pp,error:F().max(1e3).optional()}))}),z({peerIds:R(wp).max(64).optional(),includeSelf:L().optional(),includeMesh:L().optional(),selfOrigin:F().min(1).max(2048).optional()}),z({peerId:wp,name:F().trim().min(1).max(120).optional(),color:jp.nullable().optional(),connectionUrl:F().min(1).max(4096).optional(),origin:F().min(1).max(2048).optional(),token:F().min(1).max(2048).optional(),enabled:L().optional()}),z({peerId:wp}),z({removed:L()}),z({peerId:wp.optional(),connectionUrl:F().min(1).max(4096).optional(),origin:F().min(1).max(2048).optional(),token:F().min(1).max(2048).optional()}).refine(e=>!!e.peerId||!!e.connectionUrl||!!e.origin&&!!e.token,`Provide peerId, connectionUrl, or both origin and token`);let Fp=z({id:F().min(1).max(1024),name:F().min(1).max(512),path:F().min(1).max(8192)});z({ok:L(),nodeId:Tp.optional(),supportsPeerPairing:L().optional(),pairedBack:L().optional(),latencyMs:I().int().nonnegative().optional(),origin:F().max(2048).optional(),transportKind:Dp.optional(),encrypted:L().optional(),version:F().max(128).optional(),platform:F().max(64).optional(),hostname:F().max(255).optional(),homeDir:F().max(4096).optional(),projectCount:I().int().nonnegative().optional(),projects:R(Fp).optional(),error:F().max(1e3).optional()});let Ip=z({id:F().min(1).max(1024),name:F().min(1).max(512),path:F().min(1).max(8192),threadIds:R(F().min(1).max(1024))}),Lp=z({attachments:W(1).optional(),workspaceFiles:W(1).optional(),officePreview:W(1).optional(),delegation:W(1).optional(),peerPairing:W(1).optional()}),Rp=z({version:F().max(128),platform:F().max(64),hostname:F().max(255),homeDir:F().max(4096).optional(),epoch:F().min(1).max(256),nodeId:Tp.optional(),peerNodes:Hc(Ep,Tp).refine(e=>Object.keys(e).length<=128).optional(),projects:R(Ip),capabilities:Lp.optional()});B({threadId:F().min(1).max(1024),scope:F().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u).optional(),requestId:F().min(1).max(256).optional(),mode:U([`queue`,`steer`]).optional(),expectedTurnId:F().min(1).max(1024).nullable().optional(),content:R(H(`type`,[B({type:W(`text`),text:F()}),B({type:W(`file`),receiptId:F().min(1).max(128)})])).min(1).max(64)});let zp=z({ok:W(!1),error:z({code:F(),message:F(),details:Hc(F(),Ac()).optional()})});V([z({ok:W(!0),value:z({receiptId:F().min(1),file:z({attachmentId:F(),name:F(),bytes:I().int().nonnegative()})})}),zp]),V([z({ok:W(!0),value:z({accepted:W(!0)})}),zp]);let Bp=z({name:F().min(1).max(512),path:F().min(1).max(8192),kind:W(`directory`)});z({peerId:wp,path:F().min(1).max(8192).optional()}),z({path:F().min(1).max(8192),parentPath:F().min(1).max(8192).nullable(),homeDir:F().min(1).max(8192).optional(),entries:R(Bp)}),z({peerId:wp,parentPath:F().min(1).max(8192),name:F().min(1).max(255).refine(e=>e.trim().length>0,`Directory name cannot be blank`)}),z({path:F().min(1).max(8192),name:F().min(1).max(255)}),z({peerId:wp,path:F().min(1).max(8192),title:F().trim().min(1).max(255).optional()}),z({peerId:wp,workspaceId:F().min(1).max(1024),title:F().trim().min(1).max(255)}),z({peerId:wp,workspaceId:F().min(1).max(1024)}),z({workspaceId:F().min(1).max(1024).optional(),manifest:Rp}),z({sessionHostId:F().min(1).max(128).optional()}),z({hosts:R(z({hostId:V([W(`local`),Ep]),name:F().min(1).max(120),isLocal:L().optional(),color:jp.optional(),hostname:F().max(255).optional()}))}),z({hostId:V([W(`local`),Ep])}),z({harnesses:R(z({id:F().regex(/^[a-z0-9][a-z0-9-]*$/u),name:F().min(1).max(120)}))}),z({hosts:R(z({alias:F().min(1).max(255),hostName:F().max(255).optional(),user:F().max(128).optional(),port:I().int().min(1).max(65535).optional(),identityFile:F().max(1024).optional()}))}),z({host:F().trim().min(1).max(255),port:I().int().min(1).max(65535).optional(),user:F().trim().min(1).max(128).optional(),identityFile:F().trim().min(1).max(1024).optional(),authMode:Op.default(`auto`),password:F().max(1024).optional(),installAuthorizedKey:L().optional(),name:F().trim().min(1).max(120).optional(),color:jp.optional(),remoteDataDir:F().trim().min(1).max(1024).optional(),sessionId:F().min(1).max(128).optional()}),z({ok:L(),codexhostInstalled:L(),version:F().max(128).optional(),nodeId:Tp.optional(),platform:F().max(64).optional(),hostname:F().max(255).optional(),latencyMs:I().int().nonnegative().optional(),errorCode:F().max(128).optional(),error:F().max(1e3).optional()}),z({ok:L(),version:F().max(128).optional(),message:F().max(1e3).optional()}),z({promptId:F().min(1).max(128),sessionId:F().min(1).max(128).optional(),peerId:wp.optional(),host:F().min(1).max(255),kind:U([`host-key`,`password`,`passphrase`,`otp`,`generic`]),prompt:F().min(1).max(1e3),echo:L()}),z({promptId:F().min(1).max(128),sessionId:F().min(1).max(128).optional(),response:F().max(1024).optional(),cancel:L().optional()}),B({hostId:Ep,threadId:F().min(1).max(1024).optional()});let Vp=U([`listHarnesses`,`inspect`,`start`,`send`,`cancel`,`read`,`answer`,`list`]);B({operation:Vp,hopCount:I().int().min(0).max(16),sourceId:wp.optional(),input:El});let Hp=B({code:F().min(1).max(128),message:F().max(4096),details:El.optional()});V([B({ok:W(!0),value:Tl}),B({ok:W(!1),error:Hp})]);let Up=B({id:F().min(1).max(1024),name:F().min(1).max(512),path:F().min(1).max(8192)});B({hosts:R(B({hostId:Ep,nodeId:Tp.optional(),displayName:F().min(1).max(120),online:L(),state:Mp,delegation:L(),projects:R(Up),platform:F().max(64).optional(),hostname:F().max(255).optional(),homeDir:F().max(4096).optional()}))}),B({version:W(1),instanceId:F().min(1).max(128),pid:I().int().positive(),endpoint:F().min(1).max(256),token:F().regex(/^[0-9a-f]{64}$/u),startedAt:I().int().nonnegative()}),V([B({operation:W(`hosts`)}),B({operation:Vp,hostId:Ep,hopCount:I().int().min(0).max(16),timeoutMs:I().int().min(1).max(12e4).optional(),input:El})]);let Wp=z({id:F().min(1).max(256),harnessId:F().min(1),label:F().min(1).max(512),provider:U([`openai-codex`,`xai`])}).strict(),Gp=F().regex(/^[a-z][a-z0-9-]{0,47}$/),Kp=z({name:Gp,source:Wp,importedAt:F()}).strict(),qp=H(`action`,[z({action:W(`list`)}).strict(),z({action:W(`import`),sourceId:F().min(1).max(256),name:Gp,confirmed:W(!0)}).strict(),z({action:W(`reimport`),sourceId:F().min(1).max(256),name:Gp,confirmed:W(!0)}).strict(),z({action:W(`remove`),name:Gp,confirmed:W(!0)}).strict()]),Jp=z({provider:F().min(1).max(128),type:U([`oauth`,`api_key`,`unknown`]),label:F().min(1).max(512).optional(),vendor:U([`openai-codex`,`xai`]).optional()}).strict();z({sources:R(Wp),targets:R(z({harnessId:F(),providers:R(U([`openai-codex`,`xai`])),imports:R(Kp),others:R(Jp).default([])}).strict())}).strict(),z({targetHarnessId:F().min(1).max(128).optional(),request:qp}).strict(),z({events:L()});let Yp=R(B({agent:F().min(1).max(128),section:U([`main`,`more`,`auto`])})).max(256).refine(e=>new Set(e.map(e=>e.agent)).size===e.length,`Duplicate Harness IDs`);B({entries:Yp.nullable()}),B({}),B({entries:Yp,initializeOnly:L().optional()});let Xp=B({enabled:L(),timeoutMinutes:I().int().min(5).max(1440)});Object.freeze({enabled:!0,timeoutMinutes:10});let Zp=F().regex(/^external$/u),Qp=G.transform(e=>String(e)),$p=B({model:yu.optional(),thinkingOptionId:Pl.optional(),permissionModeId:Il.optional()}).refine(e=>!!(e.model||e.thinkingOptionId||e.permissionModeId),`A default configuration must contain a preference`);H(`mode`,[B({mode:W(`global`)}),B({mode:W(`last`)}),B({mode:W(`manual`),harnessId:G})]);let em=B({lastHarness:G.optional(),byHarness:Hc(Qp,$p)}),tm=B({model:yu.optional(),thinkingOptionId:Pl.optional()}).refine(e=>!!(e.model||e.thinkingOptionId),`A delegation default must contain a Model or Thinking option`),nm=B({byHarness:Hc(Qp,tm)}),rm=F().min(1).max(1024),im=z({idleRelease:Xp.optional(),favorites:Hc(Qp,R(rm).max(2048)).default({}),newThread:em.optional(),delegation:nm.optional(),showGroupChatsInSidebar:L().optional()});B({scope:Zp,revision:I().int().nonnegative(),values:im}),B({scope:Zp.default(`external`)});let am=H(`kind`,[B({kind:W(`idleRelease`),value:Xp}),B({kind:W(`favorite`),harnessId:G,modelId:rm,enabled:L()}),B({kind:W(`favorites`),harnessId:G,modelIds:R(rm).max(2048)}),B({kind:W(`newThread`),lastHarness:G.optional(),harnessId:G.optional(),configuration:$p.optional()}),B({kind:W(`delegation`),harnessId:G,configuration:tm.nullable()}),B({kind:W(`groupChatsSidebar`),visible:L()})]);B({scope:Zp.default(`external`),operations:R(am).min(1).max(256),initializeOnly:L().optional(),expectedRevision:I().int().nonnegative().optional()}).superRefine((e,t)=>{for(let n of e.operations)n.kind===`newThread`&&(!n.lastHarness&&!n.configuration||!!n.harnessId!=!!n.configuration)&&t.addIssue({code:`custom`,message:`A default Harness or complete configuration is required`})}),B({version:W(1),revision:I().int().nonnegative(),scopes:Hc(Zp,im)});let om=I().finite().nonnegative(),sm=B({input:om,output:om,cacheRead:om.optional(),cacheWrite:om.optional(),cacheWrite1h:om.optional()}),cm=F().max(512).refine(e=>e.trim()===e&&e.length>0,`Model ID is required`);B({path:F(),entries:R(B({key:F(),price:sm})),error:F().nullable()}),B({}),B({key:cm,price:sm.nullable(),previousKey:cm.optional()}),B({model:cm});let lm=B({official:L().optional(),canonicalModelId:F().min(1).optional(),provider:F().min(1).max(512),model:F().min(1).max(512),price:sm});B({price:sm.nullable(),suggestions:R(lm).max(6).optional()});let um=[`today`,`7d`,`30d`,`90d`,`all`],dm=I().int().min(0).max(2**53-1),fm=F().regex(/^\d{4}-\d{2}-\d{2}$/u),pm=F().min(1).max(128),mm=F().min(1).max(512),hm=F().min(1).max(4096);B({range:U(um),timeZone:F().min(1).max(128).refine(e=>{try{return new Intl.DateTimeFormat(`en`,{timeZone:e}),!0}catch{return!1}},`Unsupported usage statistics timezone`).optional(),harness:pm.optional(),model:mm.nullable().optional(),project:hm.nullable().optional(),date:fm.optional()});let gm=B({requests:dm,inputTokens:dm,cachedInputTokens:dm,cacheWriteInputTokens:dm,cacheKnownInputTokens:dm,cacheHitCachedInputTokens:dm,cacheHitInputTokens:dm,outputTokens:dm,reasoningOutputTokens:dm,costUsd:I().finite().min(0),unpricedRequests:dm,unmeteredRequests:dm}),_m=gm.shape,vm=B({harness:pm,sessionId:F().min(1).max(512),project:hm.nullable(),title:F().min(1).max(200).optional(),models:R(mm).max(16),firstAtMs:dm,lastAtMs:dm,..._m});B({range:U(um),from:fm.nullable(),to:fm,filters:B({harness:pm.nullable(),model:mm.nullable(),unknownModel:L(),project:hm.nullable(),unknownProject:L(),date:fm.nullable()}),reading:B({complete:L(),sources:dm,read:dm}),failures:R(B({harness:pm,message:F().max(2048)})).max(256),options:B({harnesses:R(pm).max(256),models:R(mm.nullable()).max(4096),projects:R(hm.nullable()).max(4096)}),modelLabels:R(B({harness:pm,model:mm,label:mm})).max(4096).optional(),credits:R(B({harness:pm,model:mm.nullable(),credits:I().finite().min(0),reportedRequests:dm,requests:dm})).max(4096).optional(),totals:gm,daily:R(B({date:fm,harness:pm,..._m})).max(2e5),hourly:R(B({weekday:I().int().min(0).max(6),hour:I().int().min(0).max(23),..._m})).max(168),byHarness:R(B({harness:pm,..._m})).max(256),byModel:R(B({model:mm.nullable(),..._m,harnessPricedRequests:dm})).max(4096),byProject:R(B({project:hm.nullable(),..._m})).max(4096),sessions:R(vm).max(100),recentSessions:R(vm).max(100).optional()}),z({threadId:K}),z({discarded:L()});let ym=H(`type`,[z({id:F().min(1),type:W(`choice`),prompt:F(),options:R(z({value:F().min(1),label:F(),description:F().optional()})).min(1),multiple:L(),allowOther:L(),optional:L()}),z({id:F().min(1),type:W(`text`),prompt:F(),multiline:L(),secret:W(!1),optional:L(),placeholder:F().optional(),prefill:F().optional()})]),bm=z({interactionId:F().min(1),turnId:F().min(1),title:F().optional(),questions:R(ym).min(1)}).refine(({questions:e})=>e.some(e=>e.type===`choice`&&e.multiple),{message:`Shared cards require at least one multi-select question`});B({threadId:F().min(1)}),z({questions:R(bm)}),B({threadId:F().min(1),turnId:F().min(1),interactionId:F().min(1),answers:Hc(F(),R(F())),cancelled:L().default(!1)}),z({accepted:W(!0)});let xm=z({path:F(),oldText:F().nullable(),newText:F()});z({sessionId:F().min(1),turn:I().int().nonnegative(),path:F().min(1).optional()}),z({diffs:R(xm)}),B({}),B({}),z({reference:z({sessionId:F().min(1),epoch:F().min(1),turn:I().int().nonnegative(),seq:I().int().nonnegative(),callId:F().min(1),part:I().int().nonnegative(),version:F().min(1)}),length:I().int().nonnegative(),bytes:I().int().nonnegative()}),B({}),B({}),B({title:F().trim().min(1).max(200),type:U([`info`,`warning`,`danger`]),body:F().trim().min(1).max(16384)}),B({}),B({url:F().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)}),Object.freeze(/* @__PURE__ */ `codexhost/console/remote-connections.codexhost/runtime/status.codexhost/remote/ssh-setup.codexhost/harness/plugins/list.codexhost/harness/display-settings/capabilities.codexhost/harness/display-settings/get.codexhost/harness/display-settings/set.codexhost/harness/inspect.codexhost/harness/installation.codexhost/harness/installation/start.codexhost/harness/installation/status.codexhost/harness/launch-settings/get.codexhost/harness/launch-settings/set.codexhost/harness/web-ui/open.codexhost/harness/accounts/sources.codexhost/harness/accounts/list.codexhost/harness/accounts/inspect.codexhost/harness/credential-imports.codexhost/harness/session-import/sources.codexhost/harness/session-import/list.codexhost/harness/session-import/import.codexhost/account/list.codexhost/account/refresh.codexhost/account/usage/inspect.codexhost/usage/model-prices/get.codexhost/usage/model-prices/set.codexhost/usage/model-prices/default.codexhost/usage/statistics/get.codexhost/update/check.codexhost/update/start.codexhost/update/status.codexhost/update/macos-signing/status.codexhost/update/macos-signing/setup.codexhost/update/macos-signing/remove`.split(`.`));let Sm=U([`idle`,`running`,`busy`,`closing`,`failed`,`blocked`]),Cm=U([`none`,`disabled`,`timeout`,`operation`,`background`,`identity`,`persistence`,`closeFailed`]);B({threadId:F(),title:F(),harnessId:F(),state:Sm,reason:Cm,inactiveMs:I().nonnegative()}),B({threadId:K,turnId:Nl});let wm=z({email:F().trim().min(1).max(320).optional(),label:F().trim().min(1).max(256).optional(),plan:F().trim().min(1).max(128).optional(),credits:mu.optional(),balance:hu.optional()}).strict();function Tm(e){return e.refine(e=>{let t=e;return t.credits!==void 0||t.balance!==void 0},{message:`Account must report either credits or a balance`})}let Em=Tm(wm),Dm={harnessId:G,harnessName:F().trim().min(1).max(128)},Om=z(Dm).strict();z({}).strict(),z({sources:R(Om).max(128)}).strict(),z({harnessId:G,refresh:L().optional()}).strict(),z({...Dm,account:Em.nullable(),accounts:R(Em).max(8).optional()}).strict(),z({refresh:L().optional()}).strict(),z({accounts:R(Tm(wm.extend(Dm))).max(128)}).strict(),z({harnessId:Fu,model:yu.optional(),thinkingOptionId:Pl.optional(),permissionModeId:Il.optional(),prewarm:W(!0).optional()}).strict();let km=F().trim().min(1).max(4096).refine(e=>!/[\u0000\r\n]/u.test(e),`Invalid entrypoint path`);z({harnessId:Fu}).strict().extend({path:km.nullable()}),z({path:km.nullable(),restartRequired:L()}).strict(),z({harnessId:G,action:U([`check`,`update`,`install`]),confirmedVersion:F().min(1).max(128).optional()}).strict().refine(({action:e,confirmedVersion:t})=>e===`update`||t===void 0);let Am=z({currentVersion:F().min(1).max(128),latestVersion:F().min(1).max(128),updateAvailable:L(),canUpdate:L(),latestVerifiedVersion:F().min(1).max(128).optional(),confirmationRequired:W(!0).optional(),versionKind:U([`cli`,`application`]).optional(),manualUpdateUrl:sc().max(2048).refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Manual updates require a credential-free HTTPS URL`).optional(),message:F().max(2048).optional(),messageCode:F().min(1).max(128).optional(),notice:jl.optional(),latestVersionKind:U([`unknown`,`tracking-branch`]).optional()}).strict();z({taskId:F().uuid()}).strict(),H(`status`,[z({taskId:F().uuid(),status:W(`running`)}).strict(),z({taskId:F().uuid(),status:W(`succeeded`),result:Am}).strict(),z({taskId:F().uuid(),status:W(`failed`),error:z({code:I().int(),message:F().min(1).max(2048)}).strict()}).strict()]);let jm=F().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u),Mm=F().trim().min(1),Nm=U([`free`,`go`,`plus`,`pro`,`prolite`,`team`,`self_serve_business_prolite`,`self_serve_business_usage_based`,`business`,`ent26`,`enterprise_cbp_automation`,`enterprise_cbp_usage_based`,`enterprise`,`edu`,`edu_plus`,`edu_pro`,`unknown`]),Pm=z({accountId:jm,label:Mm.max(256),email:F().email().max(320).optional(),planType:Nm.optional()}).strict(),Fm=U([`ready`,`unavailable`]);z({version:W(2),currentAccountId:jm.nullable(),phase:Fm,revision:I().int().nonnegative(),instanceId:Mm.max(1024).optional(),accounts:R(Pm).max(1)}).strict(),z({accountId:jm,refresh:L().optional()}).strict(),z({accountId:jm,usage:cu.nullable(),accountCredits:mu.optional(),freshness:U([`live`,`cached`]),observedAt:F().datetime().nullable()}).strict();let Im=1e3,Lm=F().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),Rm=Lm.max(1024),zm=z({nativeSessionId:Rm,title:Lm.max(4096).nullable(),updatedAt:I().int().nonnegative().max(864e13),cwd:Lm.max(16384),running:L().nullable()}).strict();z({}).strict(),z({harnesses:R(z({harnessId:Fu,name:Lm.max(128)}).strict()).max(128)}).strict(),z({harnessId:Fu,query:F().trim().max(4096).refine(e=>!e.includes(`\0`)).optional(),offset:I().int().nonnegative().safe().optional(),limit:I().int().min(1).max(Im).optional()}).strict(),z({candidates:R(zm).max(Im),total:I().int().nonnegative().safe()}).strict(),z({harnessId:Fu,nativeSessionId:Rm}).strict(),z({threadId:Lm.max(1024).pipe(K)}).strict();let Bm=F().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),Vm=Rm,Hm=zm;z({}).strict(),z({candidates:R(Hm).max(1e3)}).strict(),z({nativeSessionId:Vm}).strict(),z({threadId:Bm.max(1024).pipe(K)}).strict(),z({threadId:K,lastTurnId:Nl}).strict(),z({threadId:K}).strict();let Um=F().trim().min(1).max(128).regex(/^[A-Za-z0-9._:-]+$/u).brand();z({commands:R(z({id:Um,invocation:F().min(1).max(128),label:F().trim().min(1).max(128),description:F().trim().min(1).max(512).optional(),localizations:Al.optional(),argumentMode:U([`none`,`text`]),kind:U([`command`,`skill`]).optional()}).strict()),warnings:R(F().min(1)).optional(),source:U([`live`,`static`]).optional()}).strict().superRefine((e,t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.commands.entries())n.has(i.id)&&t.addIssue({code:`custom`,message:`Harness command IDs must be unique`,path:[`commands`,r,`id`]}),n.add(i.id)}),z({harnessId:G,cwd:F().min(1).optional()}).strict(),z({threadId:K}).strict(),z({threadId:K,commandId:Um,turnId:Nl.optional(),arguments:El.optional()}).strict(),z({accepted:W(!0),turnId:Nl.optional()}).strict();let Wm=W(`2.0`).optional(),Gm=Mc().optional(),Km=F().min(1),qm=V([F(),I().int()]),Jm=z({code:I().int(),message:F(),data:Tl.optional()}).catchall(Tl).superRefine(bl([`data`]));V([z({jsonrpc:Wm,id:qm,method:Km,params:Tl.optional(),result:Gm,error:Gm}).catchall(Tl).superRefine(bl([`jsonrpc`,`params`,`result`,`error`])),z({jsonrpc:Wm,id:Gm,method:Km,params:Tl.optional(),result:Gm,error:Gm}).catchall(Tl).superRefine(bl([`jsonrpc`,`id`,`params`,`result`,`error`])),z({jsonrpc:Wm,id:qm,method:Gm,params:Gm,result:Tl,error:Gm}).catchall(Tl).superRefine(bl([`jsonrpc`,`method`,`params`,`error`])),z({jsonrpc:Wm,id:qm,method:Gm,params:Gm,result:Gm,error:Jm}).catchall(Tl).superRefine(bl([`jsonrpc`,`method`,`params`,`result`]))]);let Ym=F().refine(e=>e.trim().length>0,{message:`Native identifier must not be empty or whitespace`});B({harnessId:G,nativeSessionId:Ym,locator:Tl.optional(),formatVersion:W(1)}).superRefine(bl([`locator`])),B({harnessId:G,nativeSessionId:Ym,nativeTurnKey:Ym,formatVersion:W(1)}),B({harnessId:G,nativeSessionId:Ym,checkpointId:Ym,locator:Tl.optional(),formatVersion:W(1)}).superRefine(bl([`locator`]));let Xm=F().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u),Zm=U([`npm`,`windows-installer`,`macos-dmg`,`linux-archive`]),Qm=U([`prepared`,`downloading`,`waiting-for-exit`,`installing`,`restarting`,`succeeded`,`failed`]),$m=B({completed:I().int().nonnegative(),total:I().int().positive()}).refine(e=>e.completed<=e.total,{path:[`completed`],message:`completed must not exceed total`}),eh=B({version:Xm,installation:Zm,phase:Qm,updatedAt:I().int().nonnegative(),downloadedBytes:I().int().nonnegative().optional(),totalBytes:I().int().positive().optional(),npmDownload:$m.optional(),error:F().min(1).max(500).nullable(),serviceStopOutput:F().optional()}).superRefine((e,t)=>{e.downloadedBytes!==void 0&&e.totalBytes!==void 0&&e.downloadedBytes>e.totalBytes&&t.addIssue({code:`custom`,path:[`downloadedBytes`],message:`downloadedBytes must not exceed totalBytes`})});B({});let th=F().max(300).regex(/^https:\/\/github\.com\/BytePioneer-AI\/codex-host\/releases\/tag\/v[0-9A-Za-z.+-]+$/u,`release notes URL must identify a codexhost GitHub Release`),nh=U([`idle`,`downloading`,`ready`,`failed`]),rh=B({downloadedBytes:I().int().nonnegative(),totalBytes:I().int().positive()}).refine(e=>e.downloadedBytes<=e.totalBytes,{path:[`downloadedBytes`],message:`downloadedBytes must not exceed totalBytes`});z({currentVersion:Xm,installation:Zm.nullable(),latestVersion:Xm.nullable(),updateAvailable:L(),installationAvailable:L(),releaseNotes:F().min(1).max(2e4).nullable(),releaseNotesUrl:th.nullable(),status:eh.nullable(),error:F().min(1).max(500).nullable(),stagedVersion:Xm.nullable().optional(),backgroundPhase:nh.optional(),backgroundDownload:rh.nullable().optional(),backgroundError:F().min(1).max(500).nullable().optional(),runningTaskCount:I().int().nonnegative().optional()}),B({status:eh}),B({status:eh.nullable()}),B({supported:L(),enabled:L(),certificatePresent:L(),appSignedWithLocalCert:L(),appPath:F().min(1).nullable(),certificateName:F().min(1),certificateSha1:F().regex(/^[0-9A-Fa-f]{40}$/u).nullable()});let ih=B({icon:F().min(1).max(16).optional(),title:F().min(1).max(120),body:F().min(1).max(1200),contributors:R(F().min(1).max(39)).max(30)}),ah=B({summary:F().min(1).max(600).optional(),themes:R(ih).min(1).max(12)}),oh=B({version:Xm,publishedAt:yl(),url:F().max(300).regex(/^https:\/\/github\.com\/BytePioneer-AI\/codex-host\/releases\/tag\/v[0-9A-Za-z.+-]+$/u),zh:ah.nullable(),en:ah.nullable()}).refine(e=>e.zh!==null||e.en!==null,{message:`an announcement needs at least one language`});B({manual:L().optional()}),B({announcement:oh.nullable(),unread:L()}),B({version:Xm});let sh=RegExp(String.raw`^- \[([^\]\n]+)\]\(thread://([^\s()<>"?#/]+)(?:\?hostId=([^\s()<>"?#/&]+))?\): `+`(${[`completed`,`failed`,`interrupted`,`needsInput`,`timedOut`,`unreadable`,`notFound`].join(`|`)})(?:\. (.+))?$`,`u`);function ch(e){let[t,...n]=e.trim().split(/\r?\n/u);if(t!==`[codexhost thread watch] Read each Thread's result, then continue your task:`)return;let r=[];for(let e of n){if(!e.trim())continue;let t=sh.exec(e);if(!t)return;let[,n=``,i=``,a,o,s]=t,c;if(a!==void 0){try{c=decodeURIComponent(a)}catch{return}if(!c.trim()||/[\u0000-\u001f\u007f]/u.test(c))return}r.push({...c?{hostId:c}:{},threadId:i,label:n,outcome:o,...s?{note:s}:{}})}return r.length>0?r:void 0}let lh=`<response-annotations>`,uh=`</response-annotations>`,dh=/## My request(?: for Codex)?:/gu;function fh(e){if(e.length===0)return``;let t=e.map(({text:e,annotation:t})=>({text:e,...t===void 0?{}:{annotation:t}}));return`\n# Response annotations:\nEach item contains text selected from an earlier Codex response and may include a user comment. Treat items as Annotation 1, Annotation 2, and so on in array order. Use every selection as context and address every comment. For every annotation you address, include its inline directive \`:codex-annotation{index="N"}\`, where N is its one-based array position (for example, \`:codex-annotation{index="1"}\`). Do not use unstructured annotation labels.\n${lh}\n${JSON.stringify(t)}\n${uh}\n`}function ph(e,t){let n=fh(e);return n===``?t:`${n}\n## My request:\n${t}\n`}function mh(e){let t=e.trimStart().startsWith(`# Response annotations:`)?0:e.length,n=e.indexOf(`\n${lh}\n`,t);if(n<0)return;let r=n+1+22+1,i=e.indexOf(`\n${uh}`,r);if(!(i<0))return{json:e.slice(r,i),closeEnd:i+1+23}}function hh(e){return{annotations:yh(e),body:gh(e)}}function gh(e){let t=0;for(let n of e.matchAll(dh))t=n.index+n[0].length;return e.slice(t).trim()}function _h(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function vh(e){if(e===``)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!Array.isArray(t)||t.length===0)return[];let n=[];for(let e of t){if(!_h(e))return[];let{text:t,annotation:r}=e;if(typeof t!=`string`||t.length===0||r!==void 0&&(typeof r!=`string`||r.length===0))return[];n.push({text:t,...r===void 0?{}:{annotation:r}})}return n}function yh(e){let t=mh(e);return t===void 0?[]:vh(t.json)}function bh(e){return yh(e)}let xh=U([`idle`,`installing`,`restarting`,`succeeded`,`failed`]);z({runningVersion:F().nullable(),installedVersion:F().nullable(),restartRequired:L(),remote:L(),updateSupported:L(),update:z({phase:xh,targetVersion:F().nullable(),error:F().nullable()})});let Sh=z({version:F().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)}).strict();z({hostname:F().min(1).max(1024).refine(e=>!e.startsWith(`-`)&&!/\s/u.test(e)),port:I().int().min(1).max(65535).nullable(),identity:F().max(4096).nullable(),action:U([`inspect`,`install`,`update`,`restart`,`repair`,`uninstall`]),uninstallPackage:L().optional(),version:F().regex(/^\d+\.\d+\.\d+$/u).nullable()}).strict(),z({state:U([`installed`,`not-installed`])}).strict();let q=F().min(1).max(1024),Ch={hostId:q.regex(/^(?:remote-(?:ssh(?:-|:)|control:)|remote-peer:[a-zA-Z0-9_-]{1,64}$)/u)},wh={...Ch,threadId:q},Th=F().min(1).max(8e3),Eh={text:Th,requestId:q},Dh=R(q).min(2).max(100).refine(e=>new Set(e).size===e.length,`Queued submission IDs must be distinct`);H(`accepted`,[z({accepted:W(!0),startQueuedItemId:q.optional()}),z({accepted:W(!1),code:U([`remote/queue-unavailable`,`remote/steer-unavailable`,`remote/turn-changed`,`remote/send-rejected`,`session/queue-item-not-found`,`session/queue-item-starting`]),message:F()})]),H(`available`,[z({available:W(!1)}),z({available:W(!0),canReorder:W(!0).optional(),items:R(z({id:q,clientUserMessageId:q,preview:F().max(801)})).max(100)})]);let Oh=H(`kind`,[B({kind:W(`hosts`)}),B({kind:W(`create`),...Ch,cwd:F().min(1).max(8192),epoch:q}),B({kind:W(`projectHarnesses`),...Ch,epoch:q}),B({kind:W(`inspectHarness`),...Ch,epoch:q,cwd:F().min(1).max(8192),harnessId:q}),B({kind:W(`startSelected`),...Ch,epoch:q,cwd:F().min(1).max(8192),harnessId:q,model:F().min(1).max(4096),serviceTier:U([`priority`,`ultrafast`]).optional(),reasoningEffort:q.optional()}),B({kind:W(`status`),...wh}),B({kind:W(`list`),...Ch,cursor:F().nullable(),archived:L(),includeLoaded:W(!0).optional()}),B({kind:W(`read`),...wh,page:B({cursor:F().min(1).max(8192).nullable(),epoch:q.optional(),sortDirection:U([`asc`,`desc`]).optional(),limit:I().int().min(1).max(20).optional()}).refine(e=>e.cursor===null||e.epoch!==void 0,{message:`A history continuation requires its connection epoch`}).optional()}),B({kind:W(`usage`),...wh,epoch:q}),B({kind:W(`configure`),...wh,epoch:q,modelId:q.optional(),serviceTier:vu.optional(),thinkingOptionId:q.optional(),permissionModeId:q.optional()}).refine(e=>[e.modelId,e.thinkingOptionId,e.permissionModeId].filter(e=>e!==void 0).length===1,`Select exactly one remote setting`).refine(e=>e.serviceTier===void 0||e.modelId!==void 0,{message:`A service tier requires a Model ID`}),B({kind:W(`prompt`),...wh,epoch:q,text:Th,requestId:q.optional()}),B({kind:W(`queue`),...wh,epoch:q}),B({kind:W(`delivery`),...wh,epoch:q,action:H(`kind`,[B({kind:W(`enqueue`),...Eh}),B({kind:W(`steer`),...Eh,turnId:q}),B({kind:W(`remove`),itemId:q}),B({kind:W(`reorder`),itemIds:Dh}),B({kind:W(`start`),itemId:q,onlyIfHead:W(!0).optional()}),B({kind:W(`sendNow`),itemId:q})])}),B({kind:W(`interrupt`),...wh,epoch:q,turnId:q}),B({kind:W(`rename`),...wh,epoch:q,name:F().min(1).max(512)}),B({kind:W(`archive`),...wh,epoch:q,archived:L()}),B({kind:W(`respond`),...wh,epoch:q,requestId:V([q,I().int()]),result:Hc(F(),Ac())})]),kh=F().min(1).max(1024),Ah=z({hostId:kh,displayName:F().min(1).max(1024),source:U([`codex-managed`,`discovered`]),sshAlias:F().max(1024).nullable(),sshHost:F().min(1).max(1024),sshPort:I().int().min(1).max(65535).nullable(),identity:F().max(4096).nullable(),autoConnect:L(),connectionAnalyticsId:F().max(1024).optional()}),jh=B({displayName:F().min(1).max(1024),hostname:F().min(1).max(1024),sshPort:I().int().min(1).max(65535).nullable(),identity:F().max(4096).nullable()});H(`action`,[B({action:W(`session`),operation:Oh}),B({action:W(`list`)}),B({action:W(`catalog`)}),B({action:W(`read-thread`),hostId:kh.refine(e=>e!==`local`),input:Sp}),B({action:W(`save`),draft:jh,previous:Ah.nullable()}),B({action:W(`remove`),previous:Ah}),B({action:W(`connect`),hostId:kh,enabled:L()}),B({action:W(`state`),hostId:kh}),B({action:W(`runtime`),hostId:kh}),B({action:W(`update`),hostId:kh.refine(e=>e!==`local`),version:Sh.shape.version})]),V([B({result:Tl}),B({error:B({code:I().int(),message:F()})})]),B({prompt:F().trim().min(1).max(2e3),cwd:F().max(4096).nullable()}),F().trim().min(1).max(60).nullable();let Mh=F().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u),Nh=V([F(),z({en:F()}).catchall(F())]),Ph=z({title:Nh.optional(),description:Nh.optional(),icon:F().max(349592).regex(/^data:image\/(?:svg\+xml|png|jpeg|webp);base64,[A-Za-z0-9+/]*={0,2}$/u).optional(),error:F().optional()});z({extensions:R(z({id:Mh,name:F().min(1).max(214),version:F().min(1).max(128),format:W(`dsh`),supportedTargets:Bc([W(`web`)]),enabledTargets:R(W(`web`)).max(1),source:F().min(1).max(4096),projectUrl:F().max(4096).url({protocol:/^https?$/u}).optional(),installedAt:F(),meta:Ph.optional(),loadError:F().optional()})),loadedIds:R(Mh),safeMode:L(),storeError:F().optional()});let Fh=F().trim().max(2048).url({protocol:/^https?$/u,normalize:!0}).refine(e=>!/[\s\\?#]/u.test(e)&&!e.split(`/`)[2]?.includes(`@`),`Use an HTTP(S) registry URL without credentials, a query, or a fragment.`).transform(e=>e.endsWith(`/`)?e:`${e}/`);z({spec:F().trim().min(1).max(4096),registry:Fh.optional()}).strict(),z({id:Mh,enabled:L()}).strict(),z({id:Mh}).strict(),W(1);function Ih(e){return{code:{copyLabel:e(`copy`),copiedLabel:e(`copied`),toolbarLabels:{codeLabel:e(`codeBlock.title`),wrapLabel:e(`codeBlock.wrap`),unwrapLabel:e(`codeBlock.unwrap`)}},footnotes:e(`markdown.footnotes`),mermaid:{expand:e(`markdown.mermaid.expand`),close:e(`markdown.mermaid.close`),zoomIn:e(`markdown.mermaid.zoomIn`),zoomOut:e(`markdown.mermaid.zoomOut`),fit:e(`markdown.mermaid.fit`),download:e(`markdown.mermaid.download`),downloading:e(`markdown.mermaid.downloading`),downloadFailed:e(`markdown.mermaid.downloadFailed`),diagram:e(`markdown.mermaid.diagram`),source:e(`markdown.mermaid.source`),failed:e(`markdown.mermaid.failed`)}}}function Lh(e){return{label:t=>e(`annotation.label`,{index:t}),railLabel:t=>e(`annotation.chipLabel`,{index:t}),railTitle:(t,n)=>e(`annotation.title`,{index:t,excerpt:n}),remove:t=>e(`annotation.remove`,{index:t}),selectedText:e(`annotation.selectedText`),userComment:e(`annotation.userComment`),editPlaceholder:e(`selection.commentPlaceholder`),save:e(`annotation.save`),cancel:e(`message.edit.cancel`),removeAction:e(`annotation.removeAction`)}}let Rh=`@deepseek-ai/dsh-client-ui-chat/GroupContextMessage.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Rh)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Rh,e.textContent=`.jHNr5W_card{border-radius:var(--dsw-radius-xl,16px);background:var(--dsw-specific-bubble);min-width:0;max-width:100%;color:var(--dsw-alias-label-primary);font-size:var(--dsh-content-font-size,14px);line-height:calc(22px + var(--dsh-content-font-delta,0px));flex-direction:column;gap:6px;padding:10px 16px;display:flex}.jHNr5W_header{align-items:center;gap:6px;display:flex}.jHNr5W_badge{color:var(--dsw-alias-label-tertiary);align-items:center;gap:5px;font-size:11.5px;font-weight:500;line-height:16px;display:inline-flex}.jHNr5W_contextSection{flex-direction:column;gap:6px;display:flex}.jHNr5W_contextToggle{border:.5px solid var(--dsw-alias-border-l1);background:color-mix(in srgb, var(--dsw-alias-bg-base) 65%, transparent);color:var(--dsw-alias-label-secondary);cursor:pointer;border-radius:999px;align-self:flex-start;align-items:center;gap:4px;padding:2px 8px;font-size:11.5px;font-weight:500;line-height:18px;transition:background-color .12s,color .12s,border-color .12s;display:inline-flex}.jHNr5W_contextToggle:hover{border-color:var(--dsw-alias-border-l2);background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}.jHNr5W_contextList{border:.5px solid var(--dsw-alias-border-l1);background:color-mix(in srgb, var(--dsw-alias-bg-base) 70%, transparent);border-radius:10px;flex-direction:column;gap:6px;max-height:220px;margin:0;padding:8px 10px;list-style:none;display:flex;overflow-y:auto}.jHNr5W_contextItem{flex-direction:column;gap:2px;font-size:12.5px;line-height:1.45;display:flex}.jHNr5W_contextItem+.jHNr5W_contextItem{border-top:.5px solid var(--dsw-alias-border-l1);padding-top:6px}.jHNr5W_contextSender{color:var(--dsw-alias-label-secondary);font-size:11.5px;font-weight:550}.jHNr5W_contextBody{color:var(--dsw-alias-label-secondary);white-space:pre-wrap;word-break:break-word}.jHNr5W_triggerBody{white-space:pre-wrap;word-break:break-word}.jHNr5W_triggerSender{color:var(--dsw-alias-label-secondary);font-weight:550}.jHNr5W_triggerText{color:var(--dsw-alias-label-primary)}.jHNr5W_mentionChip{background:color-mix(in srgb, var(--dsw-alias-state-business-primary) 11%, transparent);color:var(--dsw-alias-state-business-primary);border-radius:6px;margin:0 1px;padding:1px 6px;font-weight:500;display:inline}`,document.head.appendChild(e)}var zh={badge:`jHNr5W_badge`,card:`jHNr5W_card`,contextBody:`jHNr5W_contextBody`,contextItem:`jHNr5W_contextItem`,contextList:`jHNr5W_contextList`,contextSection:`jHNr5W_contextSection`,contextSender:`jHNr5W_contextSender`,contextToggle:`jHNr5W_contextToggle`,header:`jHNr5W_header`,mentionChip:`jHNr5W_mentionChip`,triggerBody:`jHNr5W_triggerBody`,triggerSender:`jHNr5W_triggerSender`,triggerText:`jHNr5W_triggerText`};function Bh(){return/* @__PURE__ */ (0,f.jsxs)(`svg`,{width:13,height:13,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,f.jsx)(`circle`,{cx:`6`,cy:`5.5`,r:`2.25`,stroke:`currentColor`,strokeWidth:`1.4`}),/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M2.25 12.75c0-1.95 1.68-3.25 3.75-3.25s3.75 1.3 3.75 3.25`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`}),/* @__PURE__ */ (0,f.jsx)(`circle`,{cx:`11.25`,cy:`6.25`,r:`1.75`,stroke:`currentColor`,strokeWidth:`1.3`}),/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M11.25 9.75c1.45 0 2.75.95 2.75 2.5`,stroke:`currentColor`,strokeWidth:`1.3`,strokeLinecap:`round`})]})}function Vh(e,t){return e.senderType===`user`||e.from===`user`?t(`message.group.you`):e.from.replace(/^@/u,``)}function Hh(e){let t=Pf(e);return t.length===1&&t[0]?.kind===`text`?e:t.map((e,t)=>e.kind===`mention`?/* @__PURE__ */ (0,f.jsxs)(`span`,{className:zh.mentionChip,"data-group-mention":e.target,children:[`@`,e.label]},t):/* @__PURE__ */ (0,f.jsx)(`span`,{children:e.text},t))}function Uh({context:e,t}){let[n,r]=(0,d.useState)(!1),i=e.messages.at(-1),a=e.messages.slice(0,-1);return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:zh.card,"data-group-context-message":!0,children:[/* @__PURE__ */ (0,f.jsx)(`div`,{className:zh.header,children:/* @__PURE__ */ (0,f.jsxs)(`span`,{className:zh.badge,children:[/* @__PURE__ */ (0,f.jsx)(Bh,{}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:t(`message.group.from`,{room:e.roomTitle})})]})}),a.length>0&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:zh.contextSection,children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:zh.contextToggle,"aria-expanded":n,onClick:()=>r(e=>!e),children:[/* @__PURE__ */ (0,f.jsx)(`span`,{children:t(`message.group.contextCount`,{count:a.length})}),n?/* @__PURE__ */ (0,f.jsx)(p.IconChevronUpOutlineRegular,{size:12}):/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:12})]}),n&&/* @__PURE__ */ (0,f.jsx)(`ul`,{className:zh.contextList,children:a.map((e,n)=>/* @__PURE__ */ (0,f.jsxs)(`li`,{className:zh.contextItem,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:zh.contextSender,children:Vh(e,t)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:zh.contextBody,children:Hh(e.content)})]},e.seq??n))})]}),i?/* @__PURE__ */ (0,f.jsxs)(`div`,{className:zh.triggerBody,children:[i.senderType!==`user`&&i.from!==`user`&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:zh.triggerSender,children:t(`message.group.senderPrefix`,{sender:Vh(i,t)})}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:zh.triggerText,children:Hh(i.content)})]}):null]})}let Wh=`@deepseek-ai/dsh-client-ui-chat/ThreadWatchNotice.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Wh)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Wh,e.textContent=`._5b1uNW_card{box-sizing:border-box;border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-bg-base);width:fit-content;max-width:100%;color:var(--dsw-alias-label-secondary);font-size:var(--dsh-content-font-size-secondary,13px);align-items:flex-start;gap:10px;padding:10px 14px;line-height:20px;display:flex}._5b1uNW_list{min-width:0;margin:0;padding:0;list-style:none}._5b1uNW_entry+._5b1uNW_entry{margin-top:10px}._5b1uNW_line{align-items:center;gap:8px;min-width:0;display:flex}._5b1uNW_line>svg,._5b1uNW_bell{flex-shrink:0}._5b1uNW_bell{color:var(--dsw-alias-label-tertiary);margin-top:3px}._5b1uNW_title,._5b1uNW_titleLink{text-overflow:ellipsis;white-space:nowrap;min-width:0;color:var(--dsw-alias-label-primary);overflow:hidden}._5b1uNW_titleLink{text-decoration:none}._5b1uNW_titleLink:hover{text-decoration:underline}._5b1uNW_titleLink:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:2px;border-radius:2px}._5b1uNW_outcome,._5b1uNW_open{white-space:nowrap;flex-shrink:0}._5b1uNW_outcome[data-outcome=completed]{color:var(--dsw-alias-state-success-primary)}._5b1uNW_outcome[data-outcome=failed]{color:var(--dsw-alias-state-error-primary)}._5b1uNW_open a{color:var(--dsw-alias-state-business-primary);text-decoration:none}._5b1uNW_open a:hover{text-decoration:underline}._5b1uNW_open a:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:2px}._5b1uNW_note{color:var(--dsw-alias-label-tertiary);overflow-wrap:anywhere;margin:4px 0 0 24px}@media (width<=480px){._5b1uNW_line{flex-wrap:wrap}._5b1uNW_title,._5b1uNW_titleLink{flex:calc(100% - 52px)}._5b1uNW_outcome{margin-left:24px}}`,document.head.appendChild(e)}var Gh={bell:`_5b1uNW_bell`,card:`_5b1uNW_card`,entry:`_5b1uNW_entry`,line:`_5b1uNW_line`,list:`_5b1uNW_list`,note:`_5b1uNW_note`,open:`_5b1uNW_open`,outcome:`_5b1uNW_outcome`,title:`_5b1uNW_title`,titleLink:`_5b1uNW_titleLink`};let Kh=()=>()=>{};function qh({entry:e,links:t,sessionId:n,t:r}){let i=e.outcome===`notFound`||n===void 0?void 0:t?.watchTarget?.(n,e.threadId,e.hostId),a=i?.href??(e.hostId?`thread://${e.threadId}?hostId=${encodeURIComponent(e.hostId)}`:`codex://threads/${e.threadId}`),o=()=>t?.describe?.(a)?.title,s=(0,d.useSyncExternalStore)(t?.resolve.subscribe??Kh,o,o),c=s!==void 0,l=s??e.label,u=i===void 0?void 0:e=>{e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),i.open())};return/* @__PURE__ */ (0,f.jsxs)(`li`,{className:Gh.entry,"data-thread-watch-entry":e.threadId,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Gh.line,children:[c?t?.describe?.(a)?.icon:/* @__PURE__ */ (0,f.jsx)(p.ReferenceIconRegular,{kind:`session`,size:14}),i===void 0?/* @__PURE__ */ (0,f.jsx)(`span`,{className:Gh.title,title:l,children:l}):/* @__PURE__ */ (0,f.jsx)(`a`,{className:Gh.titleLink,href:i.sessionUrl,title:l,onClick:u,children:l}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Gh.outcome,"data-outcome":e.outcome,children:r(`message.watch.${e.outcome}`)}),i===void 0?e.outcome!==`notFound`&&c&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:Gh.open,children:/* @__PURE__ */ (0,f.jsx)(p.MarkdownAnchor,{href:a,glyph:!1,children:[r(`message.watch.open`)]})}):/* @__PURE__ */ (0,f.jsx)(`span`,{className:Gh.open,children:/* @__PURE__ */ (0,f.jsx)(`a`,{href:i.sessionUrl,onClick:u,children:r(`message.watch.open`)})})]}),e.note!==void 0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:Gh.note,children:e.note})]})}function Jh({entries:e,links:t,sessionId:n,t:r}){return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Gh.card,"data-thread-watch-notice":!0,children:[/* @__PURE__ */ (0,f.jsx)(p.IconBellOutlineRegular,{className:Gh.bell}),/* @__PURE__ */ (0,f.jsx)(`ul`,{className:Gh.list,children:e.map((e,i)=>/* @__PURE__ */ (0,f.jsx)(qh,{entry:e,links:t,sessionId:n,t:r},i))})]})}let Yh=`@deepseek-ai/dsh-client-ui-chat/MessageItem.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Yh)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Yh,e.textContent=`.h5bUAG_userRow{flex-direction:column;align-items:flex-end;gap:6px;display:flex}.h5bUAG_noticeRow{flex-direction:column;align-items:center;gap:6px;min-width:0;display:flex}.h5bUAG_noticeStack{min-width:0;max-width:100%}.h5bUAG_userStack{min-width:0;max-width:min(calc(var(--dsh-chat-content-width,748px) * .702), 82%);flex-direction:column;align-items:flex-end;gap:8px;display:flex}.h5bUAG_annotationRow{flex-wrap:wrap;justify-content:flex-end;gap:6px;display:flex}.h5bUAG_bubble{background:var(--dsw-specific-bubble);border-radius:var(--dsw-radius-xl);max-width:100%;font-size:var(--dsh-content-font-size,14px);line-height:calc(22px + var(--dsh-content-font-delta,0px));color:var(--dsw-alias-label-primary);white-space:pre-wrap;word-break:break-word;padding:10px 16px}.h5bUAG_bubbleCollapsible{padding-bottom:6px}.h5bUAG_bubbleContent{min-width:0}.h5bUAG_bubbleContentCollapsed{max-height:220px;overflow:hidden;-webkit-mask-image:linear-gradient(#000 calc(100% - 36px),#0000);mask-image:linear-gradient(#000 calc(100% - 36px),#0000)}.h5bUAG_bubbleToggleRow{justify-content:center;margin-top:4px;display:flex}.h5bUAG_bubbleToggleRowExpanded{border-top:.5px solid var(--dsw-alias-border-l1,#80808029);margin-top:8px;padding-top:4px}.h5bUAG_bubbleToggle{border-radius:var(--dsw-radius-md,8px);width:100%;min-height:26px;color:var(--dsw-alias-label-secondary);font-family:inherit;font-size:var(--dsh-content-font-size-secondary,13px);font-weight:500;line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px));white-space:nowrap;cursor:pointer;-webkit-user-select:none;user-select:none;background:0 0;border:0;justify-content:center;align-items:center;gap:4px;padding:3px 10px;transition:background-color .12s,color .12s;display:inline-flex}@media (hover:hover){.h5bUAG_bubbleToggle:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}}.h5bUAG_bubbleToggle:active{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}.h5bUAG_bubbleToggle:focus-visible{outline:1.5px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}.h5bUAG_bubbleToggleIcon{width:calc(13px + var(--dsh-content-font-delta-secondary,0px));height:calc(13px + var(--dsh-content-font-delta-secondary,0px));flex:none}@media (prefers-reduced-motion:reduce){.h5bUAG_bubbleToggle{transition:none}}body[data-codexhost-wallpaper] .h5bUAG_bubble{background:color-mix(in srgb, var(--dsw-specific-bubble) 84%, transparent);backdrop-filter:blur(12px)}body[data-codexhost-wallpaper] [data-chat-flow-key]:not([data-chat-flow-key] *,[data-chat-near-viewport]) .h5bUAG_bubble{backdrop-filter:none}@supports (-webkit-touch-callout:none){body[data-codexhost-wallpaper] .h5bUAG_userRow{transform:translateZ(0)}}.h5bUAG_referenceSummary{color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px))}.h5bUAG_contextRow{padding:2px 0}.h5bUAG_compactionRow{--dsh-compaction-header-height:calc(24px + var(--dsh-content-font-delta,0px));padding:2px 0}.h5bUAG_compactionButton{width:100%;height:var(--dsh-compaction-header-height);border-radius:var(--dsw-radius-sm);min-width:0;color:var(--dsw-alias-label-tertiary);font:inherit;text-align:left;background:0 0;border:none;align-items:center;padding:0;transition:color .1s;display:flex}.h5bUAG_compactionRow:has(.h5bUAG_compactionBody) .h5bUAG_compactionButton{z-index:7;background:var(--dsw-alias-bg-base);border-radius:0;position:sticky;top:0}body[data-codexhost-wallpaper] .h5bUAG_compactionRow:has(.h5bUAG_compactionBody) .h5bUAG_compactionButton{background:color-mix(in srgb, var(--dsw-alias-bg-base) 78%, transparent);backdrop-filter:blur(12px)}body[data-codexhost-wallpaper] [data-chat-flow-key]:not([data-chat-flow-key] *,[data-chat-near-viewport]) .h5bUAG_compactionRow:has(.h5bUAG_compactionBody) .h5bUAG_compactionButton{backdrop-filter:none}.h5bUAG_compactionBody :has(>[data-code-block-banner]){top:var(--dsh-compaction-header-height)}@media (hover:hover){.h5bUAG_compactionRow:has(.h5bUAG_compactionBody) .h5bUAG_compactionButton:hover{background:var(--dsw-alias-interactive-bg-hover-solid)}.h5bUAG_compactionButton:hover{color:var(--dsw-alias-label-secondary)}.h5bUAG_compactionButton:not(:disabled):hover{background:var(--dsw-alias-interactive-bg-hover)}}.h5bUAG_compactionButton:not(:disabled){cursor:pointer}.h5bUAG_compactionButton:not(:disabled):active{color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-interactive-bg-hover)}.h5bUAG_compactionLeading{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px));color:inherit;flex:none;place-items:center;margin-right:6px;display:inline-grid}.h5bUAG_compactionLeading svg{width:calc(14px + var(--dsh-content-font-delta,0px));height:calc(14px + var(--dsh-content-font-delta,0px))}.h5bUAG_compactionContextIcon,.h5bUAG_compactionDisclosureIcon{grid-area:1/1;justify-content:center;align-items:center;display:inline-flex}.h5bUAG_compactionDisclosureIcon,.h5bUAG_compactionButton:not(:disabled):hover .h5bUAG_compactionContextIcon,.h5bUAG_compactionButton:not(:disabled):focus-visible .h5bUAG_compactionContextIcon{opacity:0}.h5bUAG_compactionButton:not(:disabled):hover .h5bUAG_compactionDisclosureIcon,.h5bUAG_compactionButton:not(:disabled):focus-visible .h5bUAG_compactionDisclosureIcon{opacity:1}.h5bUAG_compactionTitle{font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));color:inherit;flex:none}.h5bUAG_compactionSep{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.h5bUAG_compactionSummary{min-width:0;color:inherit;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}.h5bUAG_compactionBody{padding:4px 0 4px calc(22px + var(--dsh-content-font-delta,0px));color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px))}.h5bUAG_retryRow{color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px))}.h5bUAG_retrySummary{border-radius:var(--dsw-radius-sm);width:fit-content;max-width:100%;color:inherit;cursor:pointer;user-select:none;align-items:center;gap:7px;padding:2px 0;list-style:none;display:inline-flex}.h5bUAG_retrySummary::-webkit-details-marker{display:none}.h5bUAG_retrySummary:after{content:"";border-bottom:1.5px solid;border-right:1.5px solid;flex:none;width:6px;height:6px;margin-right:2px;transition:transform .12s;transform:rotate(-45deg)}.h5bUAG_retrySummary:hover{color:var(--dsw-alias-label-secondary)}@media (prefers-reduced-motion:reduce){.h5bUAG_compactionButton{transition:none}}.h5bUAG_retrySummary:focus-visible{outline:1.5px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}.h5bUAG_retryText{overflow-wrap:anywhere;min-width:0}.h5bUAG_retryRow[open] .h5bUAG_retrySummary:after{transform:rotate(45deg)}.h5bUAG_retryDetails{overflow-wrap:anywhere;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px));gap:2px;margin-top:3px;padding-left:14px;display:grid}.h5bUAG_retryDetailLabel{color:var(--dsw-alias-label-secondary)}.h5bUAG_turnErrorRow{font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));grid-template-columns:10px minmax(0,1fr) auto;align-items:start;gap:8px;padding:2px 0;display:grid}.h5bUAG_turnErrorDot{margin-top:5px}.h5bUAG_turnErrorCopy{overflow-wrap:anywhere;min-width:0}.h5bUAG_turnErrorTitle{color:var(--dsw-alias-state-error-primary);margin-right:6px;font-weight:600}.h5bUAG_turnErrorMessage{color:var(--dsw-alias-label-secondary)}.h5bUAG_turnErrorCode{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-markdown-code-block-small)}.h5bUAG_maxTokensTitle{color:var(--dsw-alias-state-warn-primary);margin-right:6px;font-weight:600}.h5bUAG_attachmentRow{flex-wrap:wrap;justify-content:flex-end;gap:8px;max-width:100%;display:flex}.h5bUAG_pendingAttachment{flex-direction:column;align-items:flex-end;gap:4px;min-width:0;display:flex}.h5bUAG_fileCard{border:.5px solid var(--dsw-alias-border-l2,#0000001f);border-radius:var(--dsw-radius-xl);background:var(--dsw-specific-input-major,transparent);box-sizing:border-box;flex:none;align-items:center;gap:10px;width:240px;min-height:64px;padding:8px 12px;display:inline-flex}.h5bUAG_fileIcon{flex:none;width:28px;height:28px}.h5bUAG_fileContent{flex-direction:column;flex:1;min-width:0;display:flex}.h5bUAG_fileName{white-space:nowrap;text-overflow:ellipsis;color:var(--dsw-alias-label-primary);font-size:14px;font-weight:500;line-height:22px;overflow:hidden}.h5bUAG_fileMeta{white-space:nowrap;text-overflow:ellipsis;color:var(--dsw-alias-label-tertiary,#00000073);font-size:12px;line-height:15px;overflow:hidden}.h5bUAG_editAction{color:inherit;cursor:pointer;border-radius:var(--dsw-radius-sm);background:0 0;border:0;justify-content:center;align-items:center;width:28px;height:28px;padding:6px;display:inline-flex}.h5bUAG_editAction:hover{background:var(--dsw-alias-interactive-bg-hover)}.h5bUAG_editAction svg{width:15px;height:15px}.h5bUAG_userStack:has(.h5bUAG_sentEditor){width:100%}.h5bUAG_sentEditor{box-sizing:border-box;border:1px solid var(--dsw-alias-border-main);border-radius:12px;width:100%;min-width:0;padding:12px}.h5bUAG_sentEditor textarea{resize:vertical;width:100%;min-height:100px;color:inherit;font:inherit;box-sizing:border-box;background:0 0;border:0;outline:0;line-height:1.6}.h5bUAG_sentEditor:focus-within{outline:1.5px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary))}.h5bUAG_sentEditorActions{justify-content:flex-end;gap:8px;margin-top:8px;display:flex}`,document.head.appendChild(e)}var J={annotationRow:`h5bUAG_annotationRow`,attachmentRow:`h5bUAG_attachmentRow`,bubble:`h5bUAG_bubble`,bubbleCollapsible:`h5bUAG_bubbleCollapsible`,bubbleContent:`h5bUAG_bubbleContent`,bubbleContentCollapsed:`h5bUAG_bubbleContentCollapsed`,bubbleToggle:`h5bUAG_bubbleToggle`,bubbleToggleIcon:`h5bUAG_bubbleToggleIcon`,bubbleToggleRow:`h5bUAG_bubbleToggleRow`,bubbleToggleRowExpanded:`h5bUAG_bubbleToggleRowExpanded`,compactionBody:`h5bUAG_compactionBody`,compactionButton:`h5bUAG_compactionButton`,compactionContextIcon:`h5bUAG_compactionContextIcon`,compactionDisclosureIcon:`h5bUAG_compactionDisclosureIcon`,compactionLeading:`h5bUAG_compactionLeading`,compactionRow:`h5bUAG_compactionRow`,compactionSep:`h5bUAG_compactionSep`,compactionSummary:`h5bUAG_compactionSummary`,compactionTitle:`h5bUAG_compactionTitle`,contextRow:`h5bUAG_contextRow`,editAction:`h5bUAG_editAction`,fileCard:`h5bUAG_fileCard`,fileContent:`h5bUAG_fileContent`,fileIcon:`h5bUAG_fileIcon`,fileMeta:`h5bUAG_fileMeta`,fileName:`h5bUAG_fileName`,maxTokensTitle:`h5bUAG_maxTokensTitle`,noticeRow:`h5bUAG_noticeRow`,noticeStack:`h5bUAG_noticeStack`,pendingAttachment:`h5bUAG_pendingAttachment`,referenceSummary:`h5bUAG_referenceSummary`,retryDetailLabel:`h5bUAG_retryDetailLabel`,retryDetails:`h5bUAG_retryDetails`,retryRow:`h5bUAG_retryRow`,retrySummary:`h5bUAG_retrySummary`,retryText:`h5bUAG_retryText`,sentEditor:`h5bUAG_sentEditor`,sentEditorActions:`h5bUAG_sentEditorActions`,turnErrorCode:`h5bUAG_turnErrorCode`,turnErrorCopy:`h5bUAG_turnErrorCopy`,turnErrorDot:`h5bUAG_turnErrorDot`,turnErrorMessage:`h5bUAG_turnErrorMessage`,turnErrorRow:`h5bUAG_turnErrorRow`,turnErrorTitle:`h5bUAG_turnErrorTitle`,userRow:`h5bUAG_userRow`,userStack:`h5bUAG_userStack`};let Xh=(0,d.memo)(function({node:e,title:t,fallbackSummary:n,t:r}){let[i,a]=(0,d.useState)(!1),o=(0,d.useMemo)(()=>Ih(r),[r]),s=e.summary!==null,c=s&&i,l=e.shadowedItemCount!==null&&e.shadowedTokenCount!==null?r(`message.compaction.completed`,{items:e.shadowedItemCount,tokens:e.shadowedTokenCount}):n??r(s?`message.compaction.expand`:`message.compaction.unavailable`);return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:J.compactionRow,children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:J.compactionButton,disabled:!s,"aria-expanded":s?c:void 0,onClick:()=>{a(e=>!e)},children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:J.compactionLeading,"aria-hidden":!0,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.compactionContextIcon,"data-compaction-icon":`context`,children:/* @__PURE__ */ (0,f.jsx)(p.IconApiOutlineRegular,{})}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.compactionDisclosureIcon,"data-compaction-disclosure":c?`expanded`:`collapsed`,children:c?/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{}):/* @__PURE__ */ (0,f.jsx)(p.IconChevronRightOutlineRegular,{})})]}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.compactionTitle,children:t??r(`message.compaction`)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.compactionSep,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.compactionSummary,children:l})]}),c&&e.summary!==null&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:J.compactionBody,children:/* @__PURE__ */ (0,f.jsx)(p.MarkdownText,{text:e.summary,labels:o})})]})}),Zh=`@deepseek-ai/dsh-client-ui-chat/ContextBody.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Zh)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Zh,e.textContent=`.p4W7kq_text{color:var(--dsw-alias-label-secondary);font:inherit;white-space:pre-wrap;overflow-wrap:anywhere;margin:0}.p4W7kq_fields{border-top:.5px solid var(--dsw-alias-border-l2);flex-direction:column;gap:2px;margin:8px 0 0;padding-top:8px;display:flex}.p4W7kq_field{gap:8px;min-width:0;display:flex}.p4W7kq_fieldKey{min-width:96px;color:var(--dsw-alias-label-caption);flex:none}.p4W7kq_fieldValue{min-width:0;color:var(--dsw-alias-label-tertiary);overflow-wrap:anywhere;flex:auto;margin:0}.p4W7kq_files{flex-wrap:wrap;gap:4px 12px;margin:0 0 8px;padding:0;list-style:none;display:flex}.p4W7kq_file{align-items:baseline;gap:6px;min-width:0;display:flex}.p4W7kq_filePath{color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere}.p4W7kq_fileAction{color:var(--dsw-alias-label-caption)}.p4W7kq_catalogNotice{color:var(--dsw-alias-label-caption);margin:0 0 6px}.p4W7kq_entries{flex-direction:column;gap:4px;margin:0;padding:0;list-style:none;display:flex}.p4W7kq_entry{gap:8px;min-width:0;display:flex}.p4W7kq_entryName{color:var(--dsw-alias-label-secondary);flex:none}.p4W7kq_entryDescription{min-width:0;color:var(--dsw-alias-label-tertiary);text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}.p4W7kq_sections{flex-direction:column;gap:8px;margin:0;display:flex}.p4W7kq_section{flex-direction:column;gap:2px;min-width:0;display:flex}.p4W7kq_sectionName{color:var(--dsw-alias-label-caption)}.p4W7kq_sectionText{color:var(--dsw-alias-label-secondary);white-space:pre-wrap;overflow-wrap:anywhere;margin:0}.p4W7kq_relaySender{color:var(--dsw-alias-label-caption);overflow-wrap:anywhere;margin:0 0 6px}.p4W7kq_recalls{flex-direction:column;gap:2px;margin:0 0 8px;padding:0;list-style:none;display:flex}.p4W7kq_recall{gap:8px;min-width:0;display:flex}.p4W7kq_recallLabel{color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere}.p4W7kq_recallCounts{color:var(--dsw-alias-label-caption);flex:none}`,document.head.appendChild(e)}var Y={catalogNotice:`p4W7kq_catalogNotice`,entries:`p4W7kq_entries`,entry:`p4W7kq_entry`,entryDescription:`p4W7kq_entryDescription`,entryName:`p4W7kq_entryName`,field:`p4W7kq_field`,fieldKey:`p4W7kq_fieldKey`,fieldValue:`p4W7kq_fieldValue`,fields:`p4W7kq_fields`,file:`p4W7kq_file`,fileAction:`p4W7kq_fileAction`,filePath:`p4W7kq_filePath`,files:`p4W7kq_files`,recall:`p4W7kq_recall`,recallCounts:`p4W7kq_recallCounts`,recallLabel:`p4W7kq_recallLabel`,recalls:`p4W7kq_recalls`,relaySender:`p4W7kq_relaySender`,section:`p4W7kq_section`,sectionName:`p4W7kq_sectionName`,sectionText:`p4W7kq_sectionText`,sections:`p4W7kq_sections`,text:`p4W7kq_text`};let Qh=2e4;function $h(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function eg(e){let t=[];for(let n of e){if(n.type!==`text`){t.push({block:n});continue}let e=t[t.length-1];e!==void 0&&`text`in e?e.text+=n.text:t.push({text:n.text})}return t}function tg(e){return eg(e).flatMap(e=>`block`in e?[e.block]:[])}function ng(e,t){return e.length>Qh?`${e.slice(0,Qh)}\n${t(`json.truncated`,{total:e.length})}`:e}function rg(e,t){return ng(typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e),t)}function ig({source:e,formRendered:t,t:n}){let r=$h(e);if(r===null)return null;let i=t?[`kind`,`form`]:[`kind`],a=Object.entries(r).filter(([e])=>!i.includes(e));return a.length===0?null:/* @__PURE__ */ (0,f.jsx)(`dl`,{className:Y.fields,"data-context-fields":!0,children:a.map(([e,t])=>/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Y.field,children:[/* @__PURE__ */ (0,f.jsx)(`dt`,{className:Y.fieldKey,children:e}),/* @__PURE__ */ (0,f.jsx)(`dd`,{className:Y.fieldValue,children:rg(t,n)})]},e))})}function ag({blocks:e,t}){return/* @__PURE__ */ (0,f.jsx)(f.Fragment,{children:e.map((e,n)=>/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:t(`message.unknownBlock`),payload:e,truncatedLabel:e=>t(`json.truncated`,{total:e})},n))})}function og({content:e,t}){return/* @__PURE__ */ (0,f.jsx)(f.Fragment,{children:eg(e).map((e,n)=>`text`in e?e.text!==``&&/* @__PURE__ */ (0,f.jsx)(`pre`,{className:Y.text,"data-context-text":!0,children:ng(e.text,t)},n):/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:t(`message.unknownBlock`),payload:e.block,truncatedLabel:e=>t(`json.truncated`,{total:e})},n))})}function sg({content:e,source:t,t:n}){return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(og,{content:e,t:n}),/* @__PURE__ */ (0,f.jsx)(ig,{source:t,formRendered:!1,t:n})]})}function cg(e){let t=$h(e),n=t===null?void 0:t.changes;if(!Array.isArray(n))return null;let r=[],i=/* @__PURE__ */ new Set;for(let e of n){let t=$h(e);if(t===null)return null;let n=t.path;if(typeof n!=`string`||n===``)return null;let a=t.action;if(a!==`set`&&a!==`replace`&&a!==`remove`)return null;let o=t.digest;i.has(n)||(i.add(n),r.push({action:a,path:n,...typeof o==`string`?{digest:o}:{}}))}return r.length===0?null:r}function lg(e,t){return e===`remove`?`message.context.instructions.removed`:t?`message.context.instructions.loaded`:e===`set`?`message.context.instructions.added`:`message.context.instructions.updated`}function ug({content:e,source:t,t:n}){let r=cg(t);if(r===null)return/* @__PURE__ */ (0,f.jsx)(sg,{content:e,source:t,t:n});let i=$h(t)?.baseline===!0;return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`ul`,{className:Y.files,"data-context-files":!0,children:r.map(e=>/* @__PURE__ */ (0,f.jsxs)(`li`,{className:Y.file,title:e.digest,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.filePath,children:e.path}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.fileAction,children:n(lg(e.action,i))})]},e.path))}),/* @__PURE__ */ (0,f.jsx)(og,{content:e,t:n})]})}function dg(e){let t=$h(e),n=t===null?void 0:t.entries;if(!Array.isArray(n))return null;let r=[];for(let e of n){let t=$h(e);if(t===null)return null;let n=t.name,i=t.description;if(typeof n!=`string`||n===``||typeof i!=`string`)return null;r.push({name:n,description:i})}return r}function fg({content:e,source:t,t:n}){let r=dg(t);if(r===null)return/* @__PURE__ */ (0,f.jsx)(sg,{content:e,source:t,t:n});let i=$h(t)?.update===!0,a=r.slice(0,200),o=tg(e);return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[i&&/* @__PURE__ */ (0,f.jsx)(`p`,{className:Y.catalogNotice,"data-context-catalog-update":!0,children:n(`message.context.catalog.replaced`)}),/* @__PURE__ */ (0,f.jsx)(`ul`,{className:Y.entries,"data-context-entries":!0,children:a.map((e,t)=>/* @__PURE__ */ (0,f.jsxs)(`li`,{className:Y.entry,children:[/* @__PURE__ */ (0,f.jsx)(`code`,{className:Y.entryName,children:e.name}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.entryDescription,children:e.description})]},t))}),a.length<r.length&&/* @__PURE__ */ (0,f.jsx)(`p`,{className:Y.catalogNotice,"data-context-entries-truncated":!0,children:n(`message.context.catalog.more`,{count:r.length-a.length})}),/* @__PURE__ */ (0,f.jsx)(ag,{blocks:o,t:n})]})}function pg(e){let t=$h(e),n=t===null?void 0:t.sections;if(!Array.isArray(n))return null;let r=[];for(let e of n){let t=$h(e);if(t===null)return null;let n=t.name,i=t.text;if(typeof n!=`string`||n===``||typeof i!=`string`)return null;r.push({name:n,text:i})}return r.length===0?null:r}function mg({content:e,source:t,t:n}){let r=pg(t);return r===null?/* @__PURE__ */ (0,f.jsx)(sg,{content:e,source:t,t:n}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`p`,{className:Y.catalogNotice,"data-context-snapshot-supersedes":!0,children:n(`message.context.snapshot.supersedes`)}),/* @__PURE__ */ (0,f.jsx)(`dl`,{className:Y.sections,"data-context-sections":!0,children:r.map((e,t)=>/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Y.section,children:[/* @__PURE__ */ (0,f.jsx)(`dt`,{className:Y.sectionName,children:e.name}),/* @__PURE__ */ (0,f.jsx)(`dd`,{className:Y.sectionText,children:ng(e.text,n)})]},t))})]})}function hg({content:e,t}){return/* @__PURE__ */ (0,f.jsx)(og,{content:e,t})}function gg({content:e,source:t,t:n}){let r=_g(t);return r===null?/* @__PURE__ */ (0,f.jsx)(sg,{content:e,source:t,t:n}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`p`,{className:Y.relaySender,"data-context-relay-sender":!0,children:n(`message.context.relay.from`,{session:r})}),/* @__PURE__ */ (0,f.jsx)(og,{content:e,t:n})]})}function _g(e){let t=$h(e)?.senderSessionId;return typeof t==`string`&&t!==``?t:null}function vg(e){let t=$h(e),n=t===null?void 0:t.references;if(!Array.isArray(n))return null;let r=[];for(let e of n){let t=$h(e);if(t===null)return null;let n=t.label,i=t.retainedMessages,a=t.omittedMessages,o=t.truncated;if(typeof n!=`string`||n===``||typeof i!=`number`||typeof a!=`number`||typeof o!=`boolean`)return null;r.push({label:n,retained:i,omitted:a,truncated:o})}return r.length===0?null:r}function yg({content:e,source:t,t:n}){let r=vg(t);return r===null?/* @__PURE__ */ (0,f.jsx)(sg,{content:e,source:t,t:n}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`ul`,{className:Y.recalls,"data-context-recalls":!0,children:r.map((e,t)=>/* @__PURE__ */ (0,f.jsxs)(`li`,{className:Y.recall,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.recallLabel,children:e.label}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.recallCounts,children:n(`message.context.recall.counts`,{retained:e.retained,omitted:e.omitted})}),e.truncated&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.recallCounts,children:n(`message.context.recall.truncated`)})]},t))}),/* @__PURE__ */ (0,f.jsx)(og,{content:e,t:n})]})}function bg(e){let t=$h(e)?.summary;return typeof t==`string`&&t!==``?t:null}function xg(e,t){let n={rendered:null,summary:null,body:/* @__PURE__ */ (0,f.jsx)(sg,{...t})};switch(e){case`instructions`:return cg(t.source)===null?n:{rendered:`instructions`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(ug,{...t})};case`catalog`:return dg(t.source)===null?n:{rendered:`catalog`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(fg,{...t})};case`snapshot`:return pg(t.source)===null?n:{rendered:`snapshot`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(mg,{...t})};case`notice`:{let e=bg(t.source);return e===null?n:{rendered:`notice`,summary:e,body:/* @__PURE__ */ (0,f.jsx)(hg,{...t})}}case`relay`:return _g(t.source)===null?n:{rendered:`relay`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(gg,{...t})};case`recall`:return vg(t.source)===null?n:{rendered:`recall`,summary:null,body:/* @__PURE__ */ (0,f.jsx)(yg,{...t})};case null:return n;
114
114
  /* v8 ignore next 4 -- closed-union backstop; the compiler rejects a new
115
115
  KnownContextForm here rather than letting it degrade to opaque silently. */
116
- default:throw Error(`unreachable context form: ${String(e)}`)}}let dh=`@deepseek-ai/dsh-client-ui-chat/ContextInjectionRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(dh)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=dh,e.textContent=`.uawKOW_root{min-width:0}.uawKOW_root[data-open]{padding-bottom:4px}.uawKOW_chevron{color:var(--dsw-alias-label-secondary)}.uawKOW_sep{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.uawKOW_source{min-width:0;color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;flex:none;overflow:hidden}.uawKOW_summary{min-width:0;color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}.uawKOW_body{box-sizing:border-box;width:calc(100% - 22px - var(--dsh-content-font-delta,0px));max-height:141px;margin:4px 0 0 calc(22px + var(--dsh-content-font-delta,0px));border-radius:var(--dsw-radius-md);background:var(--dsw-alias-markdown-code-block);color:var(--dsw-alias-label-tertiary);font:400 11px/16px var(--ds-font-family-code);border:none;padding:10px 16px 12px 12px;overflow:auto}.uawKOW_toolChanges{white-space:nowrap}`,document.head.appendChild(e)}var fh={body:`uawKOW_body`,chevron:`uawKOW_chevron`,root:`uawKOW_root`,sep:`uawKOW_sep`,source:`uawKOW_source`,summary:`uawKOW_summary`,toolChanges:`uawKOW_toolChanges`};function ph({content:e,source:t,producer:n,form:r,t:i}){let[a,o]=(0,d.useState)(!1),{rendered:s,summary:c,body:l}=uh(r,{content:e,source:t,t:i}),u=e.length>0&&e.every(e=>e.type===`tool-addition`||e.type===`tool-removal`)?e:void 0,m=u?.flatMap(e=>e.type===`tool-addition`?[e.toolName]:[])??[],h=u?.flatMap(e=>e.type===`tool-removal`?[e.toolName]:[])??[],g=u?.length===1?u[0]:void 0,_=u===void 0||g!==void 0?null:m.length>0&&h.length>0?i(`message.toolsChanged`,{added:m.length,removed:h.length}):m.length>0?i(`message.toolsAddedCount`,{count:m.length}):i(`message.toolsRemovedCount`,{count:h.length});return/* @__PURE__ */ (0,f.jsx)(p.DisclosureRow,{className:fh.root,icon:u===void 0?n.role===`recall`?/* @__PURE__ */ (0,f.jsx)(`span`,{"data-context-recall-icon":!0,children:/* @__PURE__ */ (0,f.jsx)(p.ReferenceIconRegular,{kind:`session`})}):/* @__PURE__ */ (0,f.jsx)(p.IconContextInjectionOutlineRegular,{size:14}):/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),chevronClassName:fh.chevron,title:g===void 0?i(u===void 0?n.role===`recall`?`message.contextRecall`:`message.contextInjection`:`message.toolsUpdated`):i(g.type===`tool-addition`?`message.toolAdded`:`message.toolRemoved`,{name:g.toolName}),collapsedContent:_===null?u!==void 0||n.label===null?void 0:/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:fh.sep,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:fh.source,"data-context-source":!0,children:n.label}),c!==null&&/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:fh.sep,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:fh.summary,"data-context-summary":!0,children:c})]})]}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:fh.sep,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:fh.summary,children:_})]}),keepContentWhenOpen:!0,open:a&&g===void 0,expandable:g===void 0,expandOnRowClick:!0,onToggle:()=>{o(e=>!e)},children:/* @__PURE__ */ (0,f.jsx)(`div`,{className:fh.body,"data-context-injection-body":!0,"data-context-form":s??void 0,children:u===void 0?l:/* @__PURE__ */ (0,f.jsxs)(`div`,{className:fh.toolChanges,children:[m.length>0&&/* @__PURE__ */ (0,f.jsx)(`div`,{children:i(`message.toolsAdded`,{names:m.join(`, `)})}),h.length>0&&/* @__PURE__ */ (0,f.jsx)(`div`,{children:i(`message.toolsRemoved`,{names:h.join(`, `)})})]})})})}function mh(e){return String(e).padStart(2,`0`)}function hh(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function gh(e){let t=new Date(e);return t.setHours(24,0,0,0),Math.max(t.getTime()-e,1)}function _h(e,t){let n=Math.max(0,Math.floor(e/1e3)),r=Math.floor(n/3600),i=Math.floor(n/60)%60,a=n%60,o=[];return r>0&&o.push({text:String(r),numeric:!0},{text:t(`duration.hourUnit`),numeric:!1}),n>=60&&o.push({text:String(i),numeric:!0},{text:t(`duration.minuteUnit`),numeric:!1}),o.push({text:String(a),numeric:!0},{text:t(`duration.secondUnit`),numeric:!1}),o}function vh(e,t,n=Date.now()){let r=new Date(e),i=new Date(n),a=`${mh(r.getHours())}:${mh(r.getMinutes())}`;if(r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()&&r.getDate()===i.getDate())return a;let o={y:r.getFullYear(),m:r.getMonth()+1,d:r.getDate()};return`${r.getFullYear()===i.getFullYear()?t(`clock.md`,o):t(`clock.ymd`,o)} ${a}`}function yh(e){let t=e.harnessLabel?.trim()||e.harnessId,n=bh(e.model,e.harnessId);return n===void 0?{display:t,title:t}:{display:n,title:n.toLowerCase()===t.toLowerCase()?n:`${t} · ${n}`}}function bh(e,t){if(e===void 0)return;let n=e.trim();if(n===``)return;let r=n.indexOf(``);r!==-1&&(n=n.slice(0,r).trim()),n=n.replace(/^codexhost[:/]+/iu,``),n=n.replace(/^(?:harness|external|route)\/+/iu,``);let i=t.replace(/[.*+?^${}()|[\]\\]/gu,`\\$&`);if(n=n.replace(RegExp(`^${i}[:/]+`,`iu`),``),n=n.trim(),n!==``&&n.toLowerCase()!==`harness`)return n}function xh({size:e=16,className:t}){return/* @__PURE__ */ (0,f.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 16 16`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,className:t,"aria-hidden":`true`,stroke:`currentColor`,strokeWidth:`1.35`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M2.5 5.25H13.25`}),/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M10.5 2.75L13.25 5.25L10.5 7.75`}),/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M13.5 10.75H2.75`}),/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M5.5 8.25L2.75 10.75L5.5 13.25`})]})}function Sh({harnessId:e,label:t,hostId:n,size:r=15,className:i}){let a=(0,p.harnessIconSources)(e,n);return/* @__PURE__ */ (0,f.jsx)(`span`,{className:i,"data-harness-id":e,"aria-hidden":`true`,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:r,height:r,flexShrink:0},children:e===`codex`?/* @__PURE__ */ (0,f.jsx)(`img`,{src:a.src,width:r,height:r,alt:t??``,style:{display:`block`,width:r,height:r,objectFit:`contain`}}):/* @__PURE__ */ (0,f.jsx)(p.RemotePluginIcon,{id:e,src:a.src,presentationUrl:a.presentationUrl,size:r,fallback:/* @__PURE__ */ (0,f.jsx)(p.IconDataOutlineRegular,{size:r})})})}function Ch(){let[e,t]=(0,d.useState)(()=>hh(Date.now()));return(0,d.useEffect)(()=>{let e,n=()=>{let r=Date.now();t(hh(r)),e=setTimeout(n,gh(r))};return e=setTimeout(n,gh(Date.now())),()=>{clearTimeout(e)}},[]),e}let wh=`@deepseek-ai/dsh-client-ui-chat/MessageIconActions.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(wh)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=wh,e.textContent=`.MIPpJq_actions{height:calc(28px + var(--dsh-content-font-delta,0px));-webkit-user-select:none;user-select:none;align-items:center;gap:8px;display:flex}.MIPpJq_timeStart{font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));color:var(--dsw-alias-label-tertiary);white-space:nowrap;padding-right:12px}.MIPpJq_timeEnd{font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);line-height:calc(24px + var(--dsh-content-font-delta,0px));color:inherit;white-space:nowrap}.MIPpJq_endInfo{min-width:0;color:var(--dsw-alias-label-tertiary);align-items:center;gap:8px;margin-left:8px;display:inline-flex}@media (hover:hover){[data-actions-reveal=hover] .MIPpJq_actions,:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering]):has(~:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering])) .MIPpJq_actions{opacity:0;transition:opacity 80ms}[data-actions-reveal=hover]:hover .MIPpJq_actions,[data-actions-reveal=hover]:focus-within .MIPpJq_actions,:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering]):has(~:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering])):hover .MIPpJq_actions,:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering]):has(~:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering])):focus-within .MIPpJq_actions{opacity:1}}.MIPpJq_action{width:calc(28px + var(--dsh-content-font-delta,0px));height:calc(28px + var(--dsh-content-font-delta,0px));border-radius:var(--dsw-radius-sm);color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:6px;display:inline-flex}.MIPpJq_action svg{width:calc(15px + var(--dsh-content-font-delta,0px));height:calc(15px + var(--dsh-content-font-delta,0px))}.MIPpJq_actions[data-clock=end] .MIPpJq_action svg{width:calc(17px + var(--dsh-content-font-delta,0px));height:calc(17px + var(--dsh-content-font-delta,0px))}.MIPpJq_action:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}.MIPpJq_action[data-unavailable]{cursor:default;opacity:.4}.MIPpJq_action[data-unavailable]:hover{color:var(--dsw-alias-label-tertiary);background:0 0}.MIPpJq_visuallyHidden{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}`,document.head.appendChild(e)}var Th={action:`MIPpJq_action`,actions:`MIPpJq_actions`,endInfo:`MIPpJq_endInfo`,timeEnd:`MIPpJq_timeEnd`,timeStart:`MIPpJq_timeStart`,visuallyHidden:`MIPpJq_visuallyHidden`};function Eh({text:e,time:t,clock:n,onBranch:r,branchUnavailable:i=!1,onHandoff:a,handoffUnavailable:o=!1,className:s,extraActions:c,t:l}){let u=Ch(),m=(0,d.useId)(),h=(0,d.useId)(),[g,_]=(0,d.useState)(!1),v=(0,d.useRef)(!1),y=(0,d.useRef)(null),b=(0,d.useRef)(0);(0,d.useEffect)(()=>()=>{b.current+=1,v.current=!1,y.current!==null&&clearTimeout(y.current)},[]);let x=(0,d.useCallback)(()=>{if(g||v.current)return;let t=b.current;v.current=!0,(0,p.writeClipboard)(e).then(e=>{t===b.current&&(v.current=!1,e&&(_(!0),y.current=window.setTimeout(()=>{y.current=null,_(!1)},1e3)))})},[g,e]),S=t===void 0?null:/* @__PURE__ */ (0,f.jsx)(`span`,{className:n===`start`?Th.timeStart:Th.timeEnd,children:vh(t,l,u)});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:s===void 0?Th.actions:`${Th.actions} ${s}`,"data-clock":n,children:[n===`start`?S:null,/* @__PURE__ */ (0,f.jsx)(p.Tooltip,{label:l(g?`copied`:`copy`),side:`bottom`,portal:!0,children:/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Th.action,"aria-label":l(g?`copied`:`copy`),onClick:x,children:g?/* @__PURE__ */ (0,f.jsx)(p.IconCheckOutlineRegular,{}):/* @__PURE__ */ (0,f.jsx)(p.IconCopyOutlineRegular,{})})}),c,r!==void 0&&/* @__PURE__ */ (0,f.jsx)(p.Tooltip,{label:l(i?`message.branchUnavailable`:`message.branch`),side:`bottom`,portal:!0,children:/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Th.action,"aria-label":l(`message.branch`),"aria-disabled":i||void 0,"aria-describedby":i?m:void 0,"data-unavailable":i||void 0,onClick:i?void 0:r,children:/* @__PURE__ */ (0,f.jsx)(p.IconBranchOutlineRegular,{})})}),r!==void 0&&i&&/* @__PURE__ */ (0,f.jsx)(`span`,{id:m,className:Th.visuallyHidden,children:l(`message.branchUnavailable`)}),a!==void 0&&/* @__PURE__ */ (0,f.jsx)(p.Tooltip,{label:l(o?`message.handoffUnavailable`:`message.handoff`),side:`bottom`,portal:!0,children:/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Th.action,"aria-label":l(`message.handoff`),"aria-disabled":o||void 0,"aria-describedby":o?h:void 0,"data-unavailable":o||void 0,"data-action-handoff":``,onClick:o?void 0:a,children:/* @__PURE__ */ (0,f.jsx)(xh,{})})}),a!==void 0&&o&&/* @__PURE__ */ (0,f.jsx)(`span`,{id:h,className:Th.visuallyHidden,children:l(`message.handoffUnavailable`)}),n===`end`?/* @__PURE__ */ (0,f.jsx)(`span`,{className:Th.endInfo,children:S}):null]})}let Dh=[`[data-code-block-controls]`,`[data-selection-actions]`,`[contenteditable='true']`,`textarea`].join(`,`),Oh=/* @__PURE__ */ new Set([`BLOCKQUOTE`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`LI`,`P`,`PRE`]);function kh(e){let t=e.startContainer.ownerDocument;if(t===null)return``;let n=t.createElement(`div`);n.append(e.cloneContents());for(let e of n.querySelectorAll(Dh))e.remove();for(let e of n.querySelectorAll(`ol, ul`))e.replaceWith(`
117
- `,...Array.from(e.childNodes));let r=e.commonAncestorContainer;return Ih(n,r.nodeType===1?r.tagName:r.parentElement?.tagName??n.tagName).trim()}function Ah(e,t){let n=e.getAttribute(`data-selection-answer`);if(!n||t.collapsed||!e.contains(t.startContainer)||!e.contains(t.endContainer))return;let r=0,i=0;for(let n of Nh(e)){let e=t.comparePoint(n,n.length);if(n===t.startContainer?r+=t.startOffset:e<0&&(r+=n.length),n===t.endContainer){i+=t.endOffset;break}if(e>0)break;i+=n.length}return i>r&&kh(t)!==``?{answerKey:n,start:r,end:i}:void 0}function jh(e,t,n){if(e.getAttribute(`data-selection-answer`)!==t.answerKey||!Number.isSafeInteger(t.start)||!Number.isSafeInteger(t.end)||t.start<0||t.end<=t.start)return;let r=0,i;for(let a of Nh(e)){let o=r+a.length;if(i===void 0&&t.start<o&&(i=e.ownerDocument.createRange(),i.setStart(a,t.start-r)),i!==void 0&&t.end<=o)return i.setEnd(a,t.end-r),kh(i)===n?i:void 0;r=o}}function Mh(e,t,n){let r=e.matches(`[data-selection-answer]`)?[e,...e.querySelectorAll(`[data-selection-answer]`)]:Array.from(e.querySelectorAll(`[data-selection-answer]`));for(let e of r){if(e.getAttribute(`data-selection-answer`)!==t.answerKey)continue;let r=jh(e,t,n);if(r!==void 0)return{host:e,range:r}}}function*Nh(e){let t=e.ownerDocument.createTreeWalker(e,4);for(let e=t.nextNode();e!==null;e=t.nextNode()){let t=e;t.length>0&&t.parentElement?.closest(Dh)==null&&(yield t)}}function Ph(e,t){let n=e.ownerDocument.createTreeWalker(e,4),r=null;for(let i=n.nextNode();i!==null;i=n.nextNode()){let n=i.parentElement;i.nodeValue&&n!==null&&n.closest(Dh)===null&&!t?.(n,e)&&(r=i)}return r}function Fh(e,t){let n=e.ownerDocument.defaultView?.getSelection();if(!n||n.rangeCount===0||n.isCollapsed)return;let r=n.getRangeAt(0);if(!e.contains(r.startContainer)||e.contains(r.endContainer)||!(e.compareDocumentPosition(r.endContainer)&Node.DOCUMENT_POSITION_FOLLOWING)||(r.startContainer instanceof Element?r.startContainer:r.startContainer.parentElement)?.closest(Dh)!=null)return;let i=Ph(e,t);if(i===null)return;let a=r.cloneRange();a.setEnd(i,i.data.length),n.removeAllRanges(),a.collapsed||n.addRange(a)}function Ih(e,t=e.tagName){let n=``;for(let r of e.childNodes)n+=Lh(r,t);return n}function Lh(e,t){if(e.nodeType===3)return e.textContent??``;if(e.nodeType!==1)return``;let n=e;switch(n.tagName){case`BR`:return`
118
- `;case`TABLE`:return`${Array.from(n.querySelectorAll(`tr`)).map(Rh).join(`
119
- `)}\n`;case`TD`:case`TH`:return`${n.previousElementSibling?.matches(`td, th`)?` `:``}${Ih(n).trimEnd()}`;case`TR`:return`${Rh(n)}\n`;case`THEAD`:case`TBODY`:case`TFOOT`:return Ih(n);case`P`:return zh(n,t);default:{let e=Ih(n);return Oh.has(n.tagName)?`${e}\n`:e}}}function Rh(e){return Array.from(e.children).filter(e=>e.tagName===`TH`||e.tagName===`TD`).map(e=>Ih(e).trim()).join(` `)}function zh(e,t){let n=e.previousElementSibling;return`${n?.tagName===`P`&&n.textContent?.trim()!==``&&e.textContent?.trim()!==``&&t!==`LI`?`
120
- `:``}${Ih(e)}\n`}function Bh(e,t,n){return e(`codexhostTurnTimes`,e=>t===void 0?void 0:e?.[t]?.[n]??void 0)}function Vh(e,t,n){let[r,i]=(0,d.useState)(null),a=(0,d.useRef)(!1);return(0,d.useMemo)(()=>({targetSeq:e&&!n?t:null,draft:r,begin(e,r,o,s=[]){a.current||n||e!==t||i({seq:e,text:r,content:o,responseAnnotations:s,pending:!1,blocked:!1})},change(e){i(t=>t&&!t.pending?{...t,text:e}:t)},cancel(){a.current||i(null)},send(){!e||!r||r.blocked||a.current||n||!r.text.trim()&&r.responseAnnotations.length===0||(a.current=!0,i({...r,pending:!0,error:void 0}),e(r.seq,cm(r.responseAnnotations,r.text)).then(e=>{e.status===`accepted`?i(null):i({...r,pending:!1,blocked:e.status!==`rejected`,error:e.message})},e=>{i({...r,pending:!1,blocked:!0,error:e instanceof Error?e.message:String(e)})}).finally(()=>{a.current=!1}))}}),[e,t,n,r])}function Hh({editing:e,t}){let n=e.draft,r=(0,d.useRef)(null),i=n!==null;return(0,d.useEffect)(()=>{let e=r.current;if(!i||!e||e.disabled)return;e.focus({preventScroll:!0});let t=e.value.length;e.setSelectionRange(t,t),e.scrollTop=e.scrollHeight},[i]),n?/* @__PURE__ */ (0,f.jsxs)(`form`,{className:Y.sentEditor,"data-sent-message-editor":!0,onSubmit:t=>{t.preventDefault(),e.send()},children:[/* @__PURE__ */ (0,f.jsx)(`textarea`,{ref:r,"aria-label":t(`message.edit`),value:n.text,disabled:n.pending,onChange:t=>e.change(t.target.value),onKeyDown:t=>{t.nativeEvent.isComposing||t.keyCode===229||(t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),e.send()),t.key===`Escape`&&(t.preventDefault(),e.cancel()))}}),!n.pending&&!n.error&&e.targetSeq!==n.seq&&/* @__PURE__ */ (0,f.jsx)(`div`,{role:`status`,children:t(`message.edit.changed`)}),n.error&&/* @__PURE__ */ (0,f.jsxs)(`div`,{role:`alert`,children:[n.error,n.blocked?` ${t(`message.edit.checkHistory`)}`:``]}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Y.sentEditorActions,children:[/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`outline`,size:`sm`,disabled:n.pending,onClick:e.cancel,children:t(`message.edit.cancel`)}),/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`primary`,size:`sm`,type:`submit`,disabled:n.pending||n.blocked||!n.text.trim()&&n.responseAnnotations.length===0||e.targetSeq!==n.seq,children:n.pending?t(`message.edit.sending`):t(`message.edit.send`)})]})]}):null}function Uh(e){return`nativePath`in e&&typeof e.nativePath==`string`?e.nativePath:void 0}function Wh({upload:e,t}){let n=(0,d.useSyncExternalStore)(e.subscribe,e.getSnapshot);return n?.status===`uploading`?/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.fileMeta,role:`status`,"data-upload-progress":!0,children:n.total===void 0||n.total===0?t(`message.uploading`):t(`message.uploadingPercent`,{percent:Math.round(Math.min(1,(n.loaded??0)/n.total)*100)})}):null}function Gh(e){let t=[],n=[],r=[];for(let i of e){let e=i;e.type===`text`&&typeof e.text==`string`?t.push(um(e.text).body):e.type===`image`&&e.attachment!==void 0?n.push({type:`image`,image:{attachment:e.attachment}}):e.type===`file`&&e.attachment!==void 0?n.push({type:`file`,file:e.attachment}):r.push(i)}return{text:t.join(``),attachments:n,rest:r}}function Kh(e){return Math.max(1,Math.ceil(e/1e3))}function qh(e,t,n){return t===`ACCOUNT_SIGNED_OUT`?n(`message.failure.accountSignedOut`):t===`ACCOUNT_SIGN_IN_REQUIRED`?n(`message.failure.accountSignInRequired`):t===`QUOTA`||t===`ACCOUNT_QUOTA`?n(`message.failure.quota`):t===`AUTH`?n(`message.failure.auth`):e}function Jh({node:e,active:t,t:n}){let r=(0,d.useMemo)(()=>Date.now()+e.delayMs,[e.delayMs,e.seq]),i=Kh(e.delayMs),a=e.mode===`normal`?e.maxRetries:`∞`,[o,s]=(0,d.useState)(()=>({deadline:r,seconds:Kh(r-Date.now())})),c=o.deadline===r?o.seconds:Kh(r-Date.now());(0,d.useEffect)(()=>{if(!t)return;let e=()=>{let e=Kh(r-Date.now());return s(t=>t.deadline===r&&t.seconds===e?t:{deadline:r,seconds:e}),e};if(e()===1)return;let n=window.setInterval(()=>{e()===1&&window.clearInterval(n)},250);return()=>{window.clearInterval(n)}},[t,r]);let l=t?n(`message.retry.active`):e.retryState===`cancelled`?n(`message.retry.cancelled`):e.retryState===`started`?n(`message.retry.started`):n(`message.retry.scheduled`),u=t?c:i;return/* @__PURE__ */ (0,f.jsxs)(`details`,{className:Y.retryRow,"data-active":t||void 0,children:[/* @__PURE__ */ (0,f.jsx)(`summary`,{className:Y.retrySummary,children:/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.retryText,role:`status`,children:/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{active:t,children:n(`message.retry.status`,{label:l,retry:e.retry,maximum:a,seconds:u})})})}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Y.retryDetails,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.retryDetailLabel,children:n(`message.retry.delay`)}),n(`duration.milliseconds`,{milliseconds:Math.round(e.delayMs)})]}),/* @__PURE__ */ (0,f.jsxs)(`div`,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.retryDetailLabel,children:n(`message.retry.failure`)}),qh(e.failure.message,e.failure.code,n)]})]})]})}function Yh({node:e,t}){return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Y.turnErrorRow,role:`status`,children:[/* @__PURE__ */ (0,f.jsx)(p.StateDot,{state:`error`,className:Y.turnErrorDot}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Y.turnErrorCopy,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.turnErrorTitle,children:e.code===`ACCOUNT_SIGNED_OUT`?t(`message.accountStopped`):t(`message.turnError`)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.turnErrorMessage,children:qh(e.message,e.code,t)})]}),e.code!==void 0&&/* @__PURE__ */ (0,f.jsx)(`code`,{className:Y.turnErrorCode,children:e.code})]})}function Xh({t:e}){return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Y.turnErrorRow,role:`status`,children:[/* @__PURE__ */ (0,f.jsx)(p.StateDot,{state:`warning`,className:Y.turnErrorDot}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Y.turnErrorCopy,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.maxTokensTitle,children:e(`message.maxTokens`)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.turnErrorMessage,children:e(`message.maxTokens.hint`)})]})]})}function Zh({content:e,renderMessageImages:t,actions:n,pending:r=!1,echo:i=!1,referenceLabels:a=[],skillNames:o=[],responseAnnotations:s=[],previewAttachments:c,references:l,links:u,sessionId:d,editor:m,t:h}){let{text:g,attachments:_,rest:v}=Gh(e),y=c??_,b=y.length>1,x=e=>h(`json.truncated`,{total:e}),S=g!==``||v.length>0,C=rm(g);return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:C?Y.noticeRow:Y.userRow,"data-pending-steering":r||void 0,"data-submission-echo":i||void 0,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:C?Y.noticeStack:Y.userStack,children:[s.length>0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:Y.annotationRow,"data-message-annotations":!0,children:s.map((e,t)=>/* @__PURE__ */ (0,f.jsx)(p.ResponseAnnotationChip,{index:t+1,annotation:e,labels:jm(h)},`${String(t)}:${e.text}`))}),y.length>0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:Y.attachmentRow,"data-message-attachments":!0,children:y.map((e,n)=>/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Y.pendingAttachment,children:[e.type===`image`?t({images:[e.image],align:`end`,compact:b}):/* @__PURE__ */ (0,f.jsxs)(`span`,{className:Y.fileCard,title:Uh(e.file)??e.file.name,children:[/* @__PURE__ */ (0,f.jsx)(p.FileTypeIcon,{path:e.file.name,className:Y.fileIcon}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:Y.fileContent,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.fileName,children:e.file.name}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Y.fileMeta,children:[(0,p.fileExtension)(e.file.name).toUpperCase().slice(0,8),Uh(e.file)===void 0?(0,p.fileSizeText)(e.file.bytes):void 0].filter(Boolean).join(` `)})]})]}),e.upload&&/* @__PURE__ */ (0,f.jsx)(Wh,{upload:e.upload,t:h})]},n))}),m??(S&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:C?void 0:Y.bubble,onClick:e=>{e.detail>=2&&Fh(e.currentTarget)},children:[C?/* @__PURE__ */ (0,f.jsx)(Im,{entries:C,links:u,sessionId:d,t:h}):(0,p.projectUserText)(g,a,o,`skill`,l),v.map((e,t)=>/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:h(`message.extraBlock`),payload:e,truncatedLabel:x},t))]})),a.length>0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:Y.referenceSummary,children:h(`message.referenceSummary`,{labels:a.join(h(`message.referenceSeparator`))})})]}),!C&&n?.(g)]})}function Qh({content:e,renderMessageImages:t,t:n}){let r=(0,d.useMemo)(()=>{let t=[];for(let n of e){let e=n;e.type===`text`&&typeof e.text==`string`&&t.push(...hm(e.text))}return t},[e]);return/* @__PURE__ */ (0,f.jsx)(Zh,{content:e,responseAnnotations:r,renderMessageImages:t,pending:!0,t:n,actions:e=>/* @__PURE__ */ (0,f.jsx)(Eh,{text:e,clock:`start`,className:Y.actions,t:n})})}function $h({submission:e,renderMessageImages:t,t:n}){let r=(0,d.useMemo)(()=>e.text===``?[]:[{type:`text`,text:e.text}],[e.text]),i=(0,d.useMemo)(()=>hm(e.text),[e.text]),a=(0,d.useMemo)(()=>e.attachments.map(e=>({upload:e.upload,...e.type===`image`?{type:`image`,image:{preview:{url:e.value.previewUrl,...e.value.name===void 0?{}:{name:e.value.name},...e.value.width===void 0?{}:{width:e.value.width},...e.value.height===void 0?{}:{height:e.value.height}}}}:{type:`file`,file:e.value}})),[e.attachments]);return/* @__PURE__ */ (0,f.jsx)(Zh,{content:r,responseAnnotations:i,previewAttachments:a,renderMessageImages:t,pending:e.placement===`steering`,echo:!0,t:n,actions:t=>/* @__PURE__ */ (0,f.jsx)(Eh,{text:t,time:e.time,clock:`start`,className:Y.actions,t:n})})}let eg=(0,d.memo)(function({node:e,renderMessageImages:t,openFile:n,openSkill:r,messageEditing:i,useProjection:a,links:o,sessionId:s,t:c}){let l=e.data,u=Bh(a,e.location.kind===`turn`||e.location.kind===`step`?e.location.turn.turn:void 0,`start`);return/* @__PURE__ */ (0,f.jsx)(Zh,{content:l.content,editor:i?.draft?.seq===l.seq?/* @__PURE__ */ (0,f.jsx)(Hh,{editing:i,t:c}):void 0,references:{openFile:n,openSkill:r},links:o,sessionId:s,renderMessageImages:t,responseAnnotations:l.responseAnnotations,...l.referenceLabels===void 0?{}:{referenceLabels:l.referenceLabels},...l.skillNames===void 0?{}:{skillNames:l.skillNames},t:c,actions:t=>/* @__PURE__ */ (0,f.jsx)(Eh,{extraActions:e.kind===`user`&&i?.targetSeq===l.seq&&!i.draft?/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Y.editAction,"aria-label":c(`message.edit`),title:c(`message.edit`),onClick:()=>i.begin(l.seq,t,l.content,l.responseAnnotations),children:/* @__PURE__ */ (0,f.jsx)(p.IconEditOutlineRegular,{})}):null,text:t,time:e.kind===`user`?u:void 0,clock:`start`,className:Y.actions,t:c})})});function tg({editing:e,renderMessageImages:t,t:n}){return/* @__PURE__ */ (0,f.jsx)(Zh,{content:e.draft?.content??[],responseAnnotations:e.draft?.responseAnnotations,renderMessageImages:t,editor:/* @__PURE__ */ (0,f.jsx)(Hh,{editing:e,t:n}),t:n})}let ng=(0,d.memo)(function({node:e,t}){let n=e.data;return/* @__PURE__ */ (0,f.jsx)(ph,{content:n.content,source:n.source,producer:n.producer,form:n.form,t})}),rg=(0,d.memo)(function({node:e,t}){return/* @__PURE__ */ (0,f.jsx)(Rm,{node:e.data,t})}),ig=(0,d.memo)(function({node:e,t}){let n=e.data;return/* @__PURE__ */ (0,f.jsx)(Jh,{node:n.current,active:n.current.retryState===`scheduled`,t})}),ag=(0,d.memo)(function({node:e,t}){return/* @__PURE__ */ (0,f.jsx)(Yh,{node:e.data,t})}),og=(0,d.memo)(function({t:e}){return/* @__PURE__ */ (0,f.jsx)(Xh,{t:e})}),sg=(0,d.memo)(function({node:e,t}){let n=e.data;return/* @__PURE__ */ (0,f.jsx)(`div`,{className:Y.contextRow,children:/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:t(`message.unknownSurface`,{type:n.type}),payload:n.data,truncatedLabel:e=>t(`json.truncated`,{total:e})})})}),cg=/* @__PURE__ */ new Set([`system-prompt`,`user`,`steering`,`turn-trigger`,`turn-process`,`turn-error`,`turn-max-tokens`,`turn-tail`]);function lg(e,t){return e.turn===t.turn&&e.controlAnchorSeq===t.controlAnchorSeq&&e.processStartSeq===t.processStartSeq&&e.answerAnchorSeq===t.answerAnchorSeq&&e.answerStep===t.answerStep&&e.inlineReasoning===t.inlineReasoning&&e.messageCount===t.messageCount&&e.toolCallCount===t.toolCallCount&&e.subagentCount===t.subagentCount}function ug(e){return e===`subagent`||e.startsWith(`subagent_`)}function dg(e){return e===`compact_context`}function fg(e){let t=e?.location;if(t?.kind!==`turn`&&t?.kind!==`step`)return!1;let n=t.turn.end?.data.reason.kind;return t.turn.status===`open`||t.turn.end?.data.finalAssistantStep===null||n===`aborted`||n===`error`}function pg(e,t){return e.turnProcesses.find(e=>e.turn===t)}function mg(){return(0,m.defineStore)({init:()=>({turnProcesses:[]}),actions:{setTurnProcessOpen:(e,t,n,r)=>{let i=e.turnProcesses.findIndex(e=>e.turn===t);if(!r){i>=0&&e.turnProcesses.splice(i,1);return}let a={turn:t,answerStep:n};i<0?e.turnProcesses.push(a):e.turnProcesses[i]=a}}})}let hg=`data-chat-near-viewport`;function gg(e){if(!Number.isFinite(e)||e<=0)return 440;let t=Math.ceil(e*.75/80)*80;return Math.max(240,Math.min(720,t))}let _g=/* @__PURE__ */ new WeakMap;function vg(e,t){let n=_g.get(e);if(n!==void 0&&(n.marginPx===t||n.observedCount>0))return n;n?.observer.disconnect();let r=/* @__PURE__ */ new WeakSet,i={marginPx:t,observer:new IntersectionObserver(e=>{for(let t of e)r.has(t.target)&&t.target.toggleAttribute(hg,t.isIntersecting)},{root:e,rootMargin:`${t}px 0px`}),observedRows:r,observedCount:0};return _g.set(e,i),i}function yg(e,t,n){if(t.clientHeight<=0)return!0;let r=t.getBoundingClientRect(),i=e.getBoundingClientRect();return r.height<=0&&i.height<=0||i.bottom>=r.top-n&&i.top<=r.bottom+n}function bg(e,t){(0,d.useLayoutEffect)(()=>{let n=e.current;if(n===null)return;if(!t||n.matches(`[data-chat-flow-key] *`)){n.removeAttribute(hg);return}let r=n.closest(`[data-conversation-scroll]`);if(r===null||typeof IntersectionObserver>`u`){n.setAttribute(hg,``);return}let i=vg(r,gg(r.clientHeight));return n.toggleAttribute(hg,yg(n,r,i.marginPx)),i.observedRows.add(n),i.observedCount+=1,i.observer.observe(n),()=>{i.observedRows.delete(n),i.observer.unobserve(n),i.observedCount=Math.max(0,i.observedCount-1),n.removeAttribute(hg)}},[e,t])}function xg(e,t){let n=(0,d.useRef)(null);return(0,d.useLayoutEffect)(()=>{let r=n.current;r!==null&&(e&&r.contains(r.ownerDocument.activeElement)?t():e?r.setAttribute(`hidden`,`until-found`):r.removeAttribute(`hidden`))},[e,t]),(0,d.useEffect)(()=>{let e=n.current;if(e!==null)return e.addEventListener(`beforematch`,t),()=>{e.removeEventListener(`beforematch`,t)}},[t]),n}let Sg=[],Cg={getSnapshot:()=>Sg,subscribe:()=>()=>{}};function wg(e){let t=Sg;return{getSnapshot:()=>{let n=e.getSnapshot().flatMap(e=>e.responseAnnotations??[]);return n.length===t.length&&n.every((e,n)=>e===t[n])||(t=n.length===0?Sg:n),t},subscribe:e.subscribe}}function Tg(e,t){let n=(0,d.useMemo)(()=>t===void 0?Cg:wg(e.turnDataSource(t,`user`)),[e,t]);return(0,d.useSyncExternalStore)(n.subscribe,n.getSnapshot)}let Eg=`@deepseek-ai/dsh-client-ui-chat/ChatView.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Eg)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Eg,e.textContent=`.BZ5KQW_frame{flex-direction:column;flex:auto;min-height:0;display:flex;position:relative}.BZ5KQW_root{flex-direction:column;flex:auto;min-height:0;display:flex;position:relative;overflow:visible clip}.BZ5KQW_scroll{--dsh-chat-scroll-pad-x:calc(var(--dsh-composer-side-clearance,0px) + 16px);min-height:0;padding:16px var(--dsh-chat-scroll-pad-x);flex:auto;overflow-y:auto}.BZ5KQW_root:is([data-chat-following-tail],[data-chat-virtualizing]) .BZ5KQW_scroll,[data-conversation-scroll]:has(.BZ5KQW_root:is([data-chat-following-tail],[data-chat-virtualizing])){overflow-anchor:none}[data-conversation-scroll] .BZ5KQW_frame,[data-conversation-scroll] .BZ5KQW_root{flex:none;height:auto;min-height:auto}[data-conversation-scroll] .BZ5KQW_scroll{flex:none;min-height:auto;overflow:visible}.BZ5KQW_column{max-width:var(--dsh-chat-content-width);flex-direction:column;width:100%;margin:0 auto;display:flex}.BZ5KQW_column>:not([hidden]):not(.BZ5KQW_flowItem:not([data-chat-virtualized]):is(:empty,[data-chat-empty]))~:not([hidden]):not(.BZ5KQW_flowItem:not([data-chat-virtualized]):is(:empty,[data-chat-empty])){margin-top:var(--dsh-chat-flow-gap,6px)}.BZ5KQW_flowItem[data-chat-group-part=response],.BZ5KQW_column>[data-chat-group-part=response]:not([hidden]):not(:is(:empty,[data-chat-empty]):not([data-chat-virtualized]))+:not([hidden]):not(.BZ5KQW_flowItem:not([data-chat-virtualized]):is(:empty,[data-chat-empty])):not(.BZ5KQW_running){--dsh-chat-flow-gap:12px}.BZ5KQW_flowItem{min-width:0}.BZ5KQW_flowItem[data-chat-flow-kind=turn-process],.BZ5KQW_flowItem[data-turn-process-answer],.BZ5KQW_column>[data-chat-flow-kind=turn-process]+:not([hidden]):not(.BZ5KQW_flowItem:not([data-chat-virtualized]):is(:empty,[data-chat-empty])):not(.BZ5KQW_running){--dsh-chat-flow-gap:16px}.BZ5KQW_flowItem:not([data-chat-virtualized]):is(:empty,[data-chat-empty]){height:0}.BZ5KQW_callRow{border-radius:var(--dsw-radius-sm)}.BZ5KQW_syncing{color:var(--dsw-alias-label-secondary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px));-webkit-user-select:none;user-select:none;align-items:center;gap:6px;padding-block:8px;display:flex}@media (prefers-reduced-motion:reduce){.BZ5KQW_syncingIcon{display:none}}.BZ5KQW_hint{color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px));-webkit-user-select:none;user-select:none}.BZ5KQW_running{--dsh-chat-flow-gap:12px;--dsw-alias-label-shimmer:var(--dsw-alias-label-deep-diving-shimmer);color:var(--dsw-alias-label-deep-diving);font-size:calc(var(--dsh-content-font-size,14px) - 2px);line-height:calc(22px + var(--dsh-content-font-delta,0px));-webkit-user-select:none;user-select:none;flex-direction:column;align-items:flex-start;display:flex}.BZ5KQW_column>:nth-last-child(2 of :not([hidden]):not(.BZ5KQW_flowItem:not([data-chat-virtualized]):is(:empty,[data-chat-empty]))):is(.BZ5KQW_flowItem:not([data-chat-flow-kind=user]):not([data-chat-flow-kind=steering]):not([data-chat-flow-kind=turn-trigger]),[data-chat-group-key])~.BZ5KQW_running>.BZ5KQW_runningDivider{display:block}.BZ5KQW_runningDivider{background:color-mix(in srgb, var(--dsw-alias-border-l1) 75%, var(--dsw-alias-border-l2));pointer-events:none;width:100%;height:.5px;margin:8px 0 10px;display:none}.BZ5KQW_runningContent{align-items:center;gap:6px;min-width:0;display:inline-flex}.BZ5KQW_runningText{font-variant-numeric:tabular-nums;min-width:0}.BZ5KQW_runningIcon{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px));contain:strict;flex:none;display:inline-flex;overflow:hidden}.BZ5KQW_runningIconMotion{transform-origin:50% 60%;width:100%;height:100%;display:inline-flex}@keyframes BZ5KQW_runningIconSway{0%,to{transform:translateY(.5px)rotate(-20deg)}50%{transform:translateY(-.6px)rotate(20deg)}}@media (prefers-reduced-motion:no-preference) and (forced-colors:none){.BZ5KQW_runningIconMotion{animation:1.6s ease-in-out infinite BZ5KQW_runningIconSway}}.BZ5KQW_openError{color:var(--dsw-alias-state-error-primary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px))}.BZ5KQW_older{min-height:28px;color:var(--dsw-alias-label-secondary);-webkit-user-select:none;user-select:none;flex-wrap:wrap;justify-content:center;align-items:center;gap:8px;font-size:12px;display:flex}.BZ5KQW_older button{border-radius:var(--dsw-radius-sm);color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-interactive-bg-hover-solid);cursor:pointer;border:none;padding:4px 12px;font-size:12px}.BZ5KQW_older button:disabled{cursor:default;opacity:.6}.BZ5KQW_toBottomSlot{z-index:8;height:0;padding-right:max(calc(var(--dsh-composer-side-clearance) + 16px), calc((100% - var(--dsh-chat-content-width)) / 2));pointer-events:none;-webkit-user-select:none;user-select:none;justify-content:flex-end;display:flex;position:absolute;bottom:16px;left:0;right:0}[data-conversation-scroll] .BZ5KQW_toBottomSlot{bottom:calc(var(--dsh-composer-height,152px) + 16px);position:sticky}.BZ5KQW_toBottom{--dsw-elevation-stroke-color:var(--dsw-alias-border-l3);corner-shape:round;width:34px;height:34px;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-button-floating-fill);box-shadow:var(--dsw-elevation-panel);cursor:pointer;pointer-events:auto;border:0;border-radius:100px;justify-content:center;align-items:center;margin-top:-34px;padding:0;display:flex}.BZ5KQW_toBottom:hover{background:var(--dsw-alias-button-floating-hover)}.BZ5KQW_modalAction{min-width:72px}`,document.head.appendChild(e)}var Dg={callRow:`BZ5KQW_callRow`,column:`BZ5KQW_column`,flowItem:`BZ5KQW_flowItem`,frame:`BZ5KQW_frame`,hint:`BZ5KQW_hint`,modalAction:`BZ5KQW_modalAction`,older:`BZ5KQW_older`,openError:`BZ5KQW_openError`,root:`BZ5KQW_root`,running:`BZ5KQW_running`,runningContent:`BZ5KQW_runningContent`,runningDivider:`BZ5KQW_runningDivider`,runningIcon:`BZ5KQW_runningIcon`,runningIconMotion:`BZ5KQW_runningIconMotion`,runningIconSway:`BZ5KQW_runningIconSway`,runningText:`BZ5KQW_runningText`,scroll:`BZ5KQW_scroll`,syncing:`BZ5KQW_syncing`,syncingIcon:`BZ5KQW_syncingIcon`,toBottom:`BZ5KQW_toBottom`,toBottomSlot:`BZ5KQW_toBottomSlot`};function Og(e){let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn.data:void 0}function kg(e){let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn.turn:void 0}function Ag(e){return e?.kind===`tool-call`&&dg(e.data.root.name)}let jg=`data-chat-empty`;function Mg(e){for(let t=e.firstElementChild;t!==null;t=t.nextElementSibling)if(t.getAttribute(`data-slot`)===`conversation.chat.node`)return t;return null}function Ng(e){for(let t=e.firstChild;t!==null;t=t.nextSibling)if(t.nodeType===Node.ELEMENT_NODE||(t.nodeType===Node.TEXT_NODE||t.nodeType===Node.CDATA_SECTION_NODE)&&(t.nodeValue?.length??0)>0)return!1;return!0}function Pg(e,t){t!==null&&Ng(t)?e.hasAttribute(jg)||e.setAttribute(jg,``):e.hasAttribute(jg)&&e.removeAttribute(jg)}let Fg=/* @__PURE__ */ new WeakMap;function Ig(e){if(typeof MutationObserver>`u`)return null;let t=Fg.get(e);if(t!==void 0)return t;let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new WeakMap,i=/* @__PURE__ */ new WeakSet,a=0,o=!1,s=(e,t)=>{i.has(t)||(e.observe(t,{childList:!0}),i.add(t),a+=1)},c,l=e=>{let t=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Set;for(let a of e){let e=a.target;if(n.has(e)){let n=e;t.add(n),i.add(n)}else if(e.nodeType===1){let i=r.get(e);i!==void 0&&n.has(i)&&t.add(i)}}for(let e of t){let t=n.get(e)??null;if(i.has(e)){let i=Mg(e);i!==t&&(t!==null&&r.delete(t),n.set(e,i),i!==null&&(r.set(i,e),s(c,i)),t=i)}Pg(e,t)}};c=new MutationObserver(l);let u=()=>{if(o=!1,n.size===0){c.disconnect(),i=/* @__PURE__ */ new WeakSet,a=0;return}if(a<=Math.max(128,n.size*4))return;let e=c.takeRecords();e.length>0&&l(e),c.disconnect(),i=/* @__PURE__ */ new WeakSet,a=0;for(let[e,t]of n){let i=Mg(e);i!==t&&(t!==null&&r.delete(t),n.set(e,i)),s(c,e),i!==null&&(r.set(i,e),s(c,i)),Pg(e,i)}},d=()=>{o||(o=!0,queueMicrotask(u))},f={observe(e){let t=n.get(e),i=Mg(e);t!=null&&t!==i&&r.delete(t),n.set(e,i),s(c,e),i!==null&&(r.set(i,e),s(c,i)),Pg(e,i)},unobserve(e){if(!n.has(e))return;let t=n.get(e);t!=null&&r.delete(t),n.delete(e),n.size===0?(o=!1,c.disconnect(),i=/* @__PURE__ */ new WeakSet,a=0):a>Math.max(128,n.size*4)&&d()}};return Fg.set(e,f),f}let Lg=(0,d.memo)(function({nodeKey:e,groupPart:t,nodeStore:n,useChatNode:r,useChatNodeProcess:i,usePresentation:a,cwd:o,openFile:s,openSkill:c,inspectCall:l,forkAt:u,handoffAt:h,loadTurnDiffs:g,messageEditing:_,loadImage:v,renderMessageImages:y,fileMentions:b,useStore:x,actions:S,renderSlot:C,t:w,mounted:T=!0,placeholderHeight:E,registerRow:D}){let O=r(e),k=O,A=kg(k),ee=i(e),j=ee?.spec,te=x(e=>j===void 0?void 0:pg(e,j.turn)),ne=j!==void 0&&te?.answerStep===(j.answerStep??0)?te:void 0,re=ee!==void 0&&!ee.turnClosed,ie=ee?.hasInterleavedInput===!0,ae=re||ie||fg(k),oe=ae||ne!==void 0,se=(0,d.useCallback)(e=>{j!==void 0&&!ae&&S.setTurnProcessOpen(j.turn,j.answerStep??0,e)},[S,j,ae]),ce=a(e=>e.foldCompletedTurns),le=j!==void 0&&ee!==void 0&&ce&&ee.turn===j.turn&&(ee.turnStarted||ee.turnClosed),ue=k!==void 0&&le&&!re&&t!==`reasoning`&&k.kind===`assistant-step`&&k.data.step===j.answerStep,M=k!==void 0&&le&&!ue&&!cg.has(k.kind)&&!Ag(k)&&k.anchorSeq>=j.processStartSeq,de=k?.kind===`turn-process`||ue,fe=le&&(re||M||de),pe=(0,d.useMemo)(()=>j===void 0?void 0:{spec:j,foldable:fe,hasContent:!ie&&(ee?.hasExternalProcess===!0||j.inlineReasoning),open:oe,setOpen:se},[fe,ie,oe,j,ee?.hasExternalProcess,se]),me=k?.kind===`turn-process`&&ce&&!fe,he=ue&&fe&&ee.compactAnswer&&!oe,ge=me||fe&&M&&!oe,_e=xg(ge,(0,d.useCallback)(()=>{M&&se(!0)},[M,se]));bg(_e,!!T&&O!==void 0&&!ge);let ve=k===void 0?void 0:t===void 0||t===`response`?k.key:JSON.stringify([k.key,t]),ye=k!==void 0&&ve!==void 0,be=k?.kind;(0,d.useLayoutEffect)(()=>{let e=_e.current;if(e===null)return;if(!T||!ye){e.hasAttribute(jg)&&e.removeAttribute(jg);return}let t=Ig(e.ownerDocument);if(t===null)Pg(e,Mg(e));else return t.observe(e),()=>{t.unobserve(e)}},[T,ye,ve,be,_e]),(0,d.useLayoutEffect)(()=>{if(D===void 0||ve===void 0)return;let e=_e.current;if(e!==null)return D(ve,e),()=>{D(ve,null)}},[D,ve,_e]);let[xe]=(0,d.useState)(()=>(0,m.createSnapshotStore)(0)),Se=(0,p.useCodeBlockFoldMemory)(),N=(0,d.useRef)(null);Se===void 0&&N.current===null&&(N.current=/* @__PURE__ */ new Map);let Ce=Se??N.current,we=Tg(n,A),P=Og(k),Te=(0,d.useMemo)(()=>({turnData:P,disclosureReset:xe}),[P,xe]);(0,d.useEffect)(()=>{M&&ge&&_e.current?.hasAttribute(`hidden`)&&xe.set(xe.getSnapshot()+1)},[M,ge,_e,xe]);let Ee=(0,d.useMemo)(()=>O===void 0?null:{...t===void 0?{}:{groupPart:t},cwd:o,openFile:s,openSkill:c,inspectCall:l,forkAt:u,handoffAt:h,loadTurnDiffs:g,messageEditing:_,loadImage:v,renderMessageImages:y,fileMentions:b,turnProcess:pe,responseAnnotations:we},[O,t,o,s,c,l,u,h,g,_,v,y,b,pe,we]);if(k===void 0||Ee===null||ve===void 0)return null;let De={...Ee,node:k},Oe=!T&&!ge&&E!==void 0&&E>0;return/* @__PURE__ */ (0,f.jsx)(`div`,{ref:_e,className:Dg.flowItem,"data-chat-anchor-key":ve,"data-chat-flow-key":ve,"data-chat-paging-anchor":k.kind!==`turn-process`||void 0,"data-chat-node-key":k.key,"data-chat-group-part":t,"data-chat-flow-kind":k.kind,"data-chat-turn":A,"data-turn-process-member":M||void 0,"data-turn-process-hidden":ge||void 0,"data-turn-process-answer":he||void 0,"data-chat-virtualized":Oe?``:void 0,style:Oe?{minHeight:E}:void 0,children:T?/* @__PURE__ */ (0,f.jsx)(p.CodeBlockFoldMemoryProvider,{memory:Ce,scope:ve,children:C(`conversation.chat.node`,De,{entryKey:k.kind,hookContext:Te,fallback:/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:w(`message.unknownSurface`,{type:k.kind}),payload:k.data,truncatedLabel:e=>w(`json.truncated`,{total:e})})})}):null})}),Rg={'"':`"`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:`
121
- `,r:`\r`,t:` `},zg=/[\\\u0000-\u001f]/u;function Bg(e){return e===` `||e===`
122
- `||e===`\r`||e===` `}function Vg(e){return e>=`0`&&e<=`9`||e>=`a`&&e<=`f`||e>=`A`&&e<=`F`}var Hg=class e{static EMPTY=e.fromObject({});static fromText(t){let n=new e;return n.append(t),n.sealed=!0,n}static fromObject(t){let n=new e;return n.object=typeof t==`object`&&t&&!Array.isArray(t)?t:{},n.sealed=!0,n}chunks=[];object;sealed=!1;#e=[];#t=0;#n=0;#r=`root`;#i=!1;#a=0;#o=!1;#s=``;#c=null;#l=[];#u=!1;#d;#f=!1;#p=/* @__PURE__ */ new Map;#m=[];#h=/* @__PURE__ */ new Map;get isSealed(){return this.sealed}get invalid(){return this.scan(),this.#r===`invalid`||this.#f}append(e){if(this.sealed)throw Error(`PartialArguments: cannot append to a sealed view`);e.length!==0&&(this.chunks.push(e),this.#t+=e.length,this.#e.push(this.#t))}settle(t){if(this.object!==void 0||t.length!==this.#t)return e.fromText(t);let n=0;for(let r of this.chunks){if(!t.startsWith(r,n))return e.fromText(t);n+=r.length}return this.chunks=t.length===0?[]:[t],this.#e=t.length===0?[]:[t.length],this.sealed=!0,this}refresh(){if(this.#h.size===0)return!1;this.scan();let e=!1,t=!1;for(let n of this.#h.values())n.completion?t=!0:e=this.refreshRead(n)||e;if(t)for(let t of this.#h.values())t.completion&&(e=this.refreshRead(t)||e);return this.sealed&&this.#h.clear(),e}refreshRead(e){let t=e.answer();return!Object.is(t,e.last)&&(e.last=t,!0)}closed(){return this.remember(`closed`,``,()=>this.closedNow())}keys(){return this.remember(`keys`,``,()=>this.keysNow(),e=>e.length)}has(e){return this.remember(`has`,e,()=>this.hasNow(e))}complete(e){return this.remember(`complete`,e,()=>this.completeNow(e))}stringLength(e,t){let n=Math.max(1,Math.floor(t?.step??1)),r=t?.offset??0;return this.remember(`length:${n}:${r}`,e,()=>this.lengthNow(e),e=>e===void 0?void 0:Math.ceil((e+r)/n))}stringExceeds(e,t){let n=Math.max(0,Math.floor(t));return this.remember(`exceeds:${n}`,e,()=>(this.lengthNow(e,n+1)??0)>n)}text(e){return this.remember(`text`,e,()=>this.textNow(e))}textPrefix(e,t){let n=Math.max(1,Math.floor(t));return this.remember(`prefix:${n}`,e,()=>this.textPrefixNow(e,n))}value(e){return this.remember(`value`,e,()=>this.valueNow(e))}remember(e,t,n,r){this.scan();let i=n();if(!this.sealed){let a=`${e}/${t}`;this.#h.has(a)||this.#h.set(a,{completion:e===`complete`,answer:r===void 0?n:()=>r(n()),last:r===void 0?i:r(i)})}return i}closedNow(){return this.sealed||this.#r===`closed`||this.#r===`invalid`}keysNow(){return this.object===void 0?this.#m:Object.keys(this.object)}hasNow(e){return this.object===void 0?this.#p.has(e):Object.hasOwn(this.object,e)}completeNow(e){if(this.object!==void 0)return Object.hasOwn(this.object,e);let t=this.#p.get(e);return t!==void 0&&t.end>=0&&(t.kind===`string`?t.invalidAt===void 0:!t.invalid)}lengthNow(e,t=1/0){if(this.object!==void 0){let t=Object.hasOwn(this.object,e)?this.object[e]:void 0;return typeof t==`string`?t.length:void 0}let n=this.#p.get(e);if(n?.kind!==`string`)return;if(n.text!==void 0&&n.text.at===n.end)return n.text.length;let r=n.length??={at:n.start,length:0,text:``};return this.readString(n,r,t,!1),r.length}textNow(e){if(this.object!==void 0){let t=Object.hasOwn(this.object,e)?this.object[e]:void 0;return typeof t==`string`?t:void 0}let t=this.#p.get(e);if(t?.kind!==`string`)return;if(t.text===void 0&&t.end>=0&&t.needsDecoding&&t.invalidAt===void 0){let e;try{e=JSON.parse(`"${this.slice(t.start,t.end)}"`)}catch{}e!==void 0&&(t.text={at:t.end,length:e.length,text:e})}let n=t.text??={at:t.start,length:0,text:``};return this.readString(t,n,1/0,!0),n.text}textPrefixNow(e,t){if(this.object!==void 0){let n=Object.hasOwn(this.object,e)?this.object[e]:void 0;return typeof n==`string`?n.slice(0,t):void 0}let n=this.#p.get(e);if(n?.kind!==`string`)return;let r=n.prefixes??=/* @__PURE__ */ new Map,i=r.get(t);return i===void 0&&(i={at:n.start,length:0,text:``},r.set(t,i)),this.readString(n,i,t,!0),i.text}valueNow(e){if(this.object!==void 0){if(!Object.hasOwn(this.object,e))return;let t=this.object[e];return typeof t==`string`?void 0:t}let t=this.#p.get(e);if(!(t?.kind!==`value`||t.end<0||t.invalid)){if(t.parsed===void 0)try{t.parsed=JSON.parse(this.slice(t.start,t.end))}catch{t.invalid=!0,this.#f=!0}return t.parsed}}chunkAt(e){let t=0,n=this.#e.length;for(;t<n;){let r=t+n>>>1;this.#e[r]<=e?t=r+1:n=r}return t}slice(e,t){if(e>=t)return``;let n=this.chunkAt(e),r=this.chunkAt(t-1),i=n===0?0:this.#e[n-1];if(n===r)return this.chunks[n].slice(e-i,t-i);let a=[this.chunks[n].slice(e-i)];for(let e=n+1;e<r;e++)a.push(this.chunks[e]);return a.push(this.chunks[r].slice(0,t-this.#e[r-1])),a.join(``)}readString(e,t,n,r){let i=Math.min(e.end<0?this.#n:e.end,e.invalidAt??1/0,this.#d??1/0);if(!e.needsDecoding){let e=Math.min(i-t.at,n-t.length);if(e<=0)return;r&&(t.text+=this.slice(t.at,t.at+e)),t.at+=e,t.length+=e;return}let a=this.chunkAt(t.at);for(;t.at<i&&t.length<n;){let o=a===0?0:this.#e[a-1],s=this.chunks[a],c=s.slice(t.at-o,Math.min(s.length,i-o)),l=c.search(zg),u=Math.min(l<0?c.length:l,n-t.length);if(u>0){r&&(t.text+=c.slice(0,u)),t.at+=u,t.length+=u,t.at===o+s.length&&a++;continue}let d=c.length>1?c[1]:t.at+1<i?this.chunks[a+1][0]:void 0,f,p=2;if(c[0]===`\\`&&d===void 0&&e.end<0)return;if(c[0]===`\\`&&d===`u`){let n=this.slice(t.at+2,Math.min(i,t.at+6)),r=!0;for(let e=0;e<n.length;e++)Vg(n[e])||(r=!1);if(r){if(n.length<4&&e.end<0)return;n.length===4&&(f=String.fromCharCode(Number.parseInt(n,16)))}p=6}else c[0]===`\\`&&d!==void 0&&(f=Rg[d]);if(f===void 0){e.invalidAt=t.at,this.#f=!0;return}for(r&&(t.text+=f),t.length++,t.at+=p;a<this.chunks.length&&t.at>=this.#e[a];)a++}}scan(){if(this.object===void 0&&this.#n!==this.#t)for(let e=this.chunkAt(this.#n);e<this.chunks.length&&this.#d===void 0;e++){let t=this.chunks[e],n=e===0?0:this.#e[e-1];for(let e=this.#n-n;e<t.length&&this.#r!==`invalid`;e++){if(this.#r===`string`||this.#r===`nested`&&this.#u){let n=this.stringBoundary(t,e);if(this.#n+=n-e,e=n,e===t.length)break}this.step(t[e],this.#n),this.#n++}}}stringBoundary(e,t){let n=t;for(;;){let t=e.indexOf(`"`,n),r=t<0?e.length:t;if(this.#r===`string`){let t=this.#c;!t.needsDecoding&&zg.test(e.slice(n,r))&&(t.needsDecoding=!0)}let i=r;for(;i>n&&e[i-1]===`\\`;)i--;let a=(r-i)%2==1!==(i===n&&this.#i);if(this.#i=t<0&&a,t<0||!a)return r;n=t+1}}step(e,t){switch(this.#r){case`root`:if(Bg(e))return;if(e===`{`){this.#r=`key-or-end`;return}this.fail();return;case`key-or-end`:if(Bg(e))return;if(e===`}`){this.#r=`closed`;return}if(e===`"`){this.beginKey(t);return}this.fail();return;case`key-only`:if(Bg(e))return;if(e===`"`){this.beginKey(t);return}this.fail();return;case`key`:this.stepKey(e,t);return;case`colon`:if(Bg(e))return;if(e===`:`){this.#r=`value`;return}this.fail();return;case`value`:this.beginValue(e,t);return;case`string`:{let e=this.#c;e.end=t,this.#c=null,this.#r=`comma-or-end`;return}case`scalar`:this.stepScalar(e,t);return;case`nested`:this.stepNested(e,t);return;case`comma-or-end`:if(Bg(e))return;if(e===`,`){this.#r=`key-only`;return}if(e===`}`){this.#r=`closed`;return}this.fail();return;case`closed`:if(Bg(e))return;this.fail();return;
116
+ default:throw Error(`unreachable context form: ${String(e)}`)}}let Sg=`@deepseek-ai/dsh-client-ui-chat/ContextInjectionRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Sg)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Sg,e.textContent=`.uawKOW_root{min-width:0}.uawKOW_root[data-open]{padding-bottom:4px}.uawKOW_chevron{color:var(--dsw-alias-label-secondary)}.uawKOW_sep{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.uawKOW_source{min-width:0;color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;flex:none;overflow:hidden}.uawKOW_summary{min-width:0;color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}.uawKOW_body{box-sizing:border-box;width:calc(100% - 22px - var(--dsh-content-font-delta,0px));max-height:141px;margin:4px 0 0 calc(22px + var(--dsh-content-font-delta,0px));border-radius:var(--dsw-radius-md);background:var(--dsw-alias-markdown-code-block);color:var(--dsw-alias-label-tertiary);font:400 11px/16px var(--ds-font-family-code);border:none;padding:10px 16px 12px 12px;overflow:auto}.uawKOW_toolChanges{white-space:nowrap}`,document.head.appendChild(e)}var Cg={body:`uawKOW_body`,chevron:`uawKOW_chevron`,root:`uawKOW_root`,sep:`uawKOW_sep`,source:`uawKOW_source`,summary:`uawKOW_summary`,toolChanges:`uawKOW_toolChanges`};function wg({content:e,source:t,producer:n,form:r,t:i}){let[a,o]=(0,d.useState)(!1),{rendered:s,summary:c,body:l}=xg(r,{content:e,source:t,t:i}),u=e.length>0&&e.every(e=>e.type===`tool-addition`||e.type===`tool-removal`)?e:void 0,m=u?.flatMap(e=>e.type===`tool-addition`?[e.toolName]:[])??[],h=u?.flatMap(e=>e.type===`tool-removal`?[e.toolName]:[])??[],g=u?.length===1?u[0]:void 0,_=u===void 0||g!==void 0?null:m.length>0&&h.length>0?i(`message.toolsChanged`,{added:m.length,removed:h.length}):m.length>0?i(`message.toolsAddedCount`,{count:m.length}):i(`message.toolsRemovedCount`,{count:h.length});return/* @__PURE__ */ (0,f.jsx)(p.DisclosureRow,{className:Cg.root,icon:u===void 0?n.role===`recall`?/* @__PURE__ */ (0,f.jsx)(`span`,{"data-context-recall-icon":!0,children:/* @__PURE__ */ (0,f.jsx)(p.ReferenceIconRegular,{kind:`session`})}):/* @__PURE__ */ (0,f.jsx)(p.IconContextInjectionOutlineRegular,{size:14}):/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),chevronClassName:Cg.chevron,title:g===void 0?i(u===void 0?n.role===`recall`?`message.contextRecall`:`message.contextInjection`:`message.toolsUpdated`):i(g.type===`tool-addition`?`message.toolAdded`:`message.toolRemoved`,{name:g.toolName}),collapsedContent:_===null?u!==void 0||n.label===null?void 0:/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Cg.sep,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Cg.source,"data-context-source":!0,children:n.label}),c!==null&&/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Cg.sep,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Cg.summary,"data-context-summary":!0,children:c})]})]}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Cg.sep,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Cg.summary,children:_})]}),keepContentWhenOpen:!0,open:a&&g===void 0,expandable:g===void 0,expandOnRowClick:!0,onToggle:()=>{o(e=>!e)},children:/* @__PURE__ */ (0,f.jsx)(`div`,{className:Cg.body,"data-context-injection-body":!0,"data-context-form":s??void 0,children:u===void 0?l:/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Cg.toolChanges,children:[m.length>0&&/* @__PURE__ */ (0,f.jsx)(`div`,{children:i(`message.toolsAdded`,{names:m.join(`, `)})}),h.length>0&&/* @__PURE__ */ (0,f.jsx)(`div`,{children:i(`message.toolsRemoved`,{names:h.join(`, `)})})]})})})}function Tg(e){return String(e).padStart(2,`0`)}function Eg(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function Dg(e){let t=new Date(e);return t.setHours(24,0,0,0),Math.max(t.getTime()-e,1)}function Og(e,t){let n=Math.max(0,Math.floor(e/1e3)),r=Math.floor(n/3600),i=Math.floor(n/60)%60,a=n%60,o=[];return r>0&&o.push({text:String(r),numeric:!0},{text:t(`duration.hourUnit`),numeric:!1}),n>=60&&o.push({text:String(i),numeric:!0},{text:t(`duration.minuteUnit`),numeric:!1}),o.push({text:String(a),numeric:!0},{text:t(`duration.secondUnit`),numeric:!1}),o}function kg(e,t,n=Date.now()){let r=new Date(e),i=new Date(n),a=`${Tg(r.getHours())}:${Tg(r.getMinutes())}`;if(r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()&&r.getDate()===i.getDate())return a;let o={y:r.getFullYear(),m:r.getMonth()+1,d:r.getDate()};return`${r.getFullYear()===i.getFullYear()?t(`clock.md`,o):t(`clock.ymd`,o)} ${a}`}function Ag(e){let t=e.harnessLabel?.trim()||e.harnessId,n=jg(e.model,e.harnessId);return n===void 0?{display:t,title:t}:{display:n,title:n.toLowerCase()===t.toLowerCase()?n:`${t} · ${n}`}}function jg(e,t){if(e===void 0)return;let n=e.trim();if(n===``)return;let r=n.indexOf(``);r!==-1&&(n=n.slice(0,r).trim()),n=n.replace(/^codexhost[:/]+/iu,``),n=n.replace(/^(?:harness|external|route)\/+/iu,``);let i=t.replace(/[.*+?^${}()|[\]\\]/gu,`\\$&`);if(n=n.replace(RegExp(`^${i}[:/]+`,`iu`),``),n=n.trim(),n!==``&&n.toLowerCase()!==`harness`)return n}function Mg({size:e=16,className:t}){return/* @__PURE__ */ (0,f.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 16 16`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,className:t,"aria-hidden":`true`,stroke:`currentColor`,strokeWidth:`1.35`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M2.5 5.25H13.25`}),/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M10.5 2.75L13.25 5.25L10.5 7.75`}),/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M13.5 10.75H2.75`}),/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M5.5 8.25L2.75 10.75L5.5 13.25`})]})}function Ng({harnessId:e,label:t,hostId:n,size:r=15,className:i}){let a=(0,p.harnessIconSources)(e,n);return/* @__PURE__ */ (0,f.jsx)(`span`,{className:i,"data-harness-id":e,"aria-hidden":`true`,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:r,height:r,flexShrink:0},children:e===`codex`?/* @__PURE__ */ (0,f.jsx)(`img`,{src:a.src,width:r,height:r,alt:t??``,style:{display:`block`,width:r,height:r,objectFit:`contain`}}):/* @__PURE__ */ (0,f.jsx)(p.RemotePluginIcon,{id:e,src:a.src,presentationUrl:a.presentationUrl,size:r,fallback:/* @__PURE__ */ (0,f.jsx)(p.IconDataOutlineRegular,{size:r})})})}function Pg(){let[e,t]=(0,d.useState)(()=>Eg(Date.now()));return(0,d.useEffect)(()=>{let e,n=()=>{let r=Date.now();t(Eg(r)),e=setTimeout(n,Dg(r))};return e=setTimeout(n,Dg(Date.now())),()=>{clearTimeout(e)}},[]),e}let Fg=`@deepseek-ai/dsh-client-ui-chat/MessageIconActions.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Fg)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Fg,e.textContent=`.MIPpJq_actions{height:calc(28px + var(--dsh-content-font-delta,0px));-webkit-user-select:none;user-select:none;align-items:center;gap:8px;display:flex}.MIPpJq_timeStart{font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));color:var(--dsw-alias-label-tertiary);white-space:nowrap;padding-right:12px}.MIPpJq_timeEnd{font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);line-height:calc(24px + var(--dsh-content-font-delta,0px));color:inherit;white-space:nowrap}.MIPpJq_endInfo{min-width:0;color:var(--dsw-alias-label-tertiary);align-items:center;gap:8px;margin-left:8px;display:inline-flex}@media (hover:hover){[data-actions-reveal=hover] .MIPpJq_actions,:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering]):has(~:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering])) .MIPpJq_actions{opacity:0;transition:opacity 80ms}[data-actions-reveal=hover]:hover .MIPpJq_actions,[data-actions-reveal=hover]:focus-within .MIPpJq_actions,:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering]):has(~:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering])):hover .MIPpJq_actions,:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering]):has(~:is([data-chat-flow-kind=user],[data-chat-flow-kind=steering])):focus-within .MIPpJq_actions{opacity:1}}.MIPpJq_action{width:calc(28px + var(--dsh-content-font-delta,0px));height:calc(28px + var(--dsh-content-font-delta,0px));border-radius:var(--dsw-radius-sm);color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:6px;display:inline-flex}.MIPpJq_action svg{width:calc(15px + var(--dsh-content-font-delta,0px));height:calc(15px + var(--dsh-content-font-delta,0px))}.MIPpJq_actions[data-clock=end] .MIPpJq_action svg{width:calc(17px + var(--dsh-content-font-delta,0px));height:calc(17px + var(--dsh-content-font-delta,0px))}.MIPpJq_action:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}.MIPpJq_action[data-unavailable]{cursor:default;opacity:.4}.MIPpJq_action[data-unavailable]:hover{color:var(--dsw-alias-label-tertiary);background:0 0}.MIPpJq_visuallyHidden{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}`,document.head.appendChild(e)}var Ig={action:`MIPpJq_action`,actions:`MIPpJq_actions`,endInfo:`MIPpJq_endInfo`,timeEnd:`MIPpJq_timeEnd`,timeStart:`MIPpJq_timeStart`,visuallyHidden:`MIPpJq_visuallyHidden`};function Lg({text:e,time:t,clock:n,onBranch:r,branchUnavailable:i=!1,onHandoff:a,handoffUnavailable:o=!1,className:s,extraActions:c,t:l}){let u=Pg(),m=(0,d.useId)(),h=(0,d.useId)(),[g,_]=(0,d.useState)(!1),v=(0,d.useRef)(!1),y=(0,d.useRef)(null),b=(0,d.useRef)(0);(0,d.useEffect)(()=>()=>{b.current+=1,v.current=!1,y.current!==null&&clearTimeout(y.current)},[]);let x=(0,d.useCallback)(()=>{if(g||v.current)return;let t=b.current;v.current=!0,(0,p.writeClipboard)(e).then(e=>{t===b.current&&(v.current=!1,e&&(_(!0),y.current=window.setTimeout(()=>{y.current=null,_(!1)},1e3)))})},[g,e]),S=t===void 0?null:/* @__PURE__ */ (0,f.jsx)(`span`,{className:n===`start`?Ig.timeStart:Ig.timeEnd,children:kg(t,l,u)});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:s===void 0?Ig.actions:`${Ig.actions} ${s}`,"data-clock":n,children:[n===`start`?S:null,/* @__PURE__ */ (0,f.jsx)(p.Tooltip,{label:l(g?`copied`:`copy`),side:`bottom`,portal:!0,children:/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Ig.action,"aria-label":l(g?`copied`:`copy`),onClick:x,children:g?/* @__PURE__ */ (0,f.jsx)(p.IconCheckOutlineRegular,{}):/* @__PURE__ */ (0,f.jsx)(p.IconCopyOutlineRegular,{})})}),c,r!==void 0&&/* @__PURE__ */ (0,f.jsx)(p.Tooltip,{label:l(i?`message.branchUnavailable`:`message.branch`),side:`bottom`,portal:!0,children:/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Ig.action,"aria-label":l(`message.branch`),"aria-disabled":i||void 0,"aria-describedby":i?m:void 0,"data-unavailable":i||void 0,onClick:i?void 0:r,children:/* @__PURE__ */ (0,f.jsx)(p.IconBranchOutlineRegular,{})})}),r!==void 0&&i&&/* @__PURE__ */ (0,f.jsx)(`span`,{id:m,className:Ig.visuallyHidden,children:l(`message.branchUnavailable`)}),a!==void 0&&/* @__PURE__ */ (0,f.jsx)(p.Tooltip,{label:l(o?`message.handoffUnavailable`:`message.handoff`),side:`bottom`,portal:!0,children:/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Ig.action,"aria-label":l(`message.handoff`),"aria-disabled":o||void 0,"aria-describedby":o?h:void 0,"data-unavailable":o||void 0,"data-action-handoff":``,onClick:o?void 0:a,children:/* @__PURE__ */ (0,f.jsx)(Mg,{})})}),a!==void 0&&o&&/* @__PURE__ */ (0,f.jsx)(`span`,{id:h,className:Ig.visuallyHidden,children:l(`message.handoffUnavailable`)}),n===`end`?/* @__PURE__ */ (0,f.jsx)(`span`,{className:Ig.endInfo,children:S}):null]})}let Rg=[`[data-code-block-controls]`,`[data-selection-actions]`,`[contenteditable='true']`,`textarea`].join(`,`),zg=/* @__PURE__ */ new Set([`BLOCKQUOTE`,`DIV`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`LI`,`P`,`PRE`]);function Bg(e){let t=e.startContainer.ownerDocument;if(t===null)return``;let n=t.createElement(`div`);n.append(e.cloneContents());for(let e of n.querySelectorAll(Rg))e.remove();for(let e of n.querySelectorAll(`ol, ul`))e.replaceWith(`
117
+ `,...Array.from(e.childNodes));let r=e.commonAncestorContainer;return qg(n,r.nodeType===1?r.tagName:r.parentElement?.tagName??n.tagName).trim()}function Vg(e,t){let n=e.getAttribute(`data-selection-answer`);if(!n||t.collapsed||!e.contains(t.startContainer)||!e.contains(t.endContainer))return;let r=0,i=0;for(let n of Wg(e)){let e=t.comparePoint(n,n.length);if(n===t.startContainer?r+=t.startOffset:e<0&&(r+=n.length),n===t.endContainer){i+=t.endOffset;break}if(e>0)break;i+=n.length}return i>r&&Bg(t)!==``?{answerKey:n,start:r,end:i}:void 0}function Hg(e,t,n){if(e.getAttribute(`data-selection-answer`)!==t.answerKey||!Number.isSafeInteger(t.start)||!Number.isSafeInteger(t.end)||t.start<0||t.end<=t.start)return;let r=0,i;for(let a of Wg(e)){let o=r+a.length;if(i===void 0&&t.start<o&&(i=e.ownerDocument.createRange(),i.setStart(a,t.start-r)),i!==void 0&&t.end<=o)return i.setEnd(a,t.end-r),Bg(i)===n?i:void 0;r=o}}function Ug(e,t,n){let r=e.matches(`[data-selection-answer]`)?[e,...e.querySelectorAll(`[data-selection-answer]`)]:Array.from(e.querySelectorAll(`[data-selection-answer]`));for(let e of r){if(e.getAttribute(`data-selection-answer`)!==t.answerKey)continue;let r=Hg(e,t,n);if(r!==void 0)return{host:e,range:r}}}function*Wg(e){let t=e.ownerDocument.createTreeWalker(e,4);for(let e=t.nextNode();e!==null;e=t.nextNode()){let t=e;t.length>0&&t.parentElement?.closest(Rg)==null&&(yield t)}}function Gg(e,t){let n=e.ownerDocument.createTreeWalker(e,4),r=null;for(let i=n.nextNode();i!==null;i=n.nextNode()){let n=i.parentElement;i.nodeValue&&n!==null&&n.closest(Rg)===null&&!t?.(n,e)&&(r=i)}return r}function Kg(e,t){let n=e.ownerDocument.defaultView?.getSelection();if(!n||n.rangeCount===0||n.isCollapsed)return;let r=n.getRangeAt(0);if(!e.contains(r.startContainer)||e.contains(r.endContainer)||!(e.compareDocumentPosition(r.endContainer)&Node.DOCUMENT_POSITION_FOLLOWING)||(r.startContainer instanceof Element?r.startContainer:r.startContainer.parentElement)?.closest(Rg)!=null)return;let i=Gg(e,t);if(i===null)return;let a=r.cloneRange();a.setEnd(i,i.data.length),n.removeAllRanges(),a.collapsed||n.addRange(a)}function qg(e,t=e.tagName){let n=``;for(let r of e.childNodes)n+=Jg(r,t);return n}function Jg(e,t){if(e.nodeType===3)return e.textContent??``;if(e.nodeType!==1)return``;let n=e;switch(n.tagName){case`BR`:return`
118
+ `;case`TABLE`:return`${Array.from(n.querySelectorAll(`tr`)).map(Yg).join(`
119
+ `)}\n`;case`TD`:case`TH`:return`${n.previousElementSibling?.matches(`td, th`)?` `:``}${qg(n).trimEnd()}`;case`TR`:return`${Yg(n)}\n`;case`THEAD`:case`TBODY`:case`TFOOT`:return qg(n);case`P`:return Xg(n,t);default:{let e=qg(n);return zg.has(n.tagName)?`${e}\n`:e}}}function Yg(e){return Array.from(e.children).filter(e=>e.tagName===`TH`||e.tagName===`TD`).map(e=>qg(e).trim()).join(` `)}function Xg(e,t){let n=e.previousElementSibling;return`${n?.tagName===`P`&&n.textContent?.trim()!==``&&e.textContent?.trim()!==``&&t!==`LI`?`
120
+ `:``}${qg(e)}\n`}function Zg(e,t,n){return e(`codexhostTurnTimes`,e=>t===void 0?void 0:e?.[t]?.[n]??void 0)}function Qg(e,t,n){let[r,i]=(0,d.useState)(null),a=(0,d.useRef)(!1);return(0,d.useMemo)(()=>({targetSeq:e&&!n?t:null,draft:r,begin(e,r,o,s=[]){a.current||n||e!==t||i({seq:e,text:r,content:o,responseAnnotations:s,pending:!1,blocked:!1})},change(e){i(t=>t&&!t.pending?{...t,text:e}:t)},cancel(){a.current||i(null)},send(){!e||!r||r.blocked||a.current||n||!r.text.trim()&&r.responseAnnotations.length===0||(a.current=!0,i({...r,pending:!0,error:void 0}),e(r.seq,ph(r.responseAnnotations,r.text)).then(e=>{e.status===`accepted`?i(null):i({...r,pending:!1,blocked:e.status!==`rejected`,error:e.message})},e=>{i({...r,pending:!1,blocked:!0,error:e instanceof Error?e.message:String(e)})}).finally(()=>{a.current=!1}))}}),[e,t,n,r])}function $g({editing:e,t}){let n=e.draft,r=(0,d.useRef)(null),i=n!==null;return(0,d.useEffect)(()=>{let e=r.current;if(!i||!e||e.disabled)return;e.focus({preventScroll:!0});let t=e.value.length;e.setSelectionRange(t,t),e.scrollTop=e.scrollHeight},[i]),n?/* @__PURE__ */ (0,f.jsxs)(`form`,{className:J.sentEditor,"data-sent-message-editor":!0,onSubmit:t=>{t.preventDefault(),e.send()},children:[/* @__PURE__ */ (0,f.jsx)(`textarea`,{ref:r,"aria-label":t(`message.edit`),value:n.text,disabled:n.pending,onChange:t=>e.change(t.target.value),onKeyDown:t=>{if(!(t.nativeEvent.isComposing||t.keyCode===229)){if(t.key===`Enter`&&!t.shiftKey){if((0,p.hasCoarsePrimaryPointer)()&&!t.ctrlKey&&!t.metaKey)return;t.preventDefault(),e.send()}t.key===`Escape`&&(t.preventDefault(),e.cancel())}}}),!n.pending&&!n.error&&e.targetSeq!==n.seq&&/* @__PURE__ */ (0,f.jsx)(`div`,{role:`status`,children:t(`message.edit.changed`)}),n.error&&/* @__PURE__ */ (0,f.jsxs)(`div`,{role:`alert`,children:[n.error,n.blocked?` ${t(`message.edit.checkHistory`)}`:``]}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:J.sentEditorActions,children:[/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`outline`,size:`sm`,disabled:n.pending,onClick:e.cancel,children:t(`message.edit.cancel`)}),/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`primary`,size:`sm`,type:`submit`,disabled:n.pending||n.blocked||!n.text.trim()&&n.responseAnnotations.length===0||e.targetSeq!==n.seq,children:n.pending?t(`message.edit.sending`):t(`message.edit.send`)})]})]}):null}function e_(e,t){return!Number.isFinite(e)||e<=0?!1:t?e>220:e>260}function t_(e){let t=e.closest(`[data-conversation-scroll]`);if(t!==null)return t;let n=e.parentElement;for(;n!==null;){let e=getComputedStyle(n).overflowY;if(e===`auto`||e===`scroll`)return n;n=n.parentElement}return null}function n_(e,t){let n=(0,d.useRef)(null),r=(0,d.useRef)(null),i=(0,d.useRef)(!1),[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1);(0,d.useLayoutEffect)(()=>{if(!e){o(!1);return}let t=r.current;if(t===null)return;let n=()=>{let e=t.scrollHeight;o(t=>e_(e,t===!0))};if(n(),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(()=>{n()});return i.observe(t),()=>{i.disconnect()}},[e,t]),(0,d.useLayoutEffect)(()=>{if(s||!i.current)return;i.current=!1;let e=n.current;if(e===null)return;let t=t_(e);if(t===null)return;let r=t.getBoundingClientRect().top,a=e.getBoundingClientRect().top;if(a<r+16){let e=a-(r+16);t.scrollTop=Math.max(0,t.scrollTop+e)}},[s]);let l=(0,d.useCallback)(()=>{c(e=>{if(e){let e=n.current,t=e===null?null:t_(e);if(e!==null&&t!==null){let n=t.getBoundingClientRect().top,r=e.getBoundingClientRect().top;i.current=r<n+16}}else i.current=!1;return!e})},[]);return{bubbleRef:n,contentRef:r,collapsible:e&&a===!0,expanded:s,collapsed:e&&a!==!1&&!s,toggle:l}}function r_(e){return`nativePath`in e&&typeof e.nativePath==`string`?e.nativePath:void 0}function i_({upload:e,t}){let n=(0,d.useSyncExternalStore)(e.subscribe,e.getSnapshot);return n?.status===`uploading`?/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.fileMeta,role:`status`,"data-upload-progress":!0,children:n.total===void 0||n.total===0?t(`message.uploading`):t(`message.uploadingPercent`,{percent:Math.round(Math.min(1,(n.loaded??0)/n.total)*100)})}):null}function a_(e){let t=[],n=[],r=[];for(let i of e){let e=i;e.type===`text`&&typeof e.text==`string`?t.push(hh(e.text).body):e.type===`image`&&e.attachment!==void 0?n.push({type:`image`,image:{attachment:e.attachment}}):e.type===`file`&&e.attachment!==void 0?n.push({type:`file`,file:e.attachment}):r.push(i)}return{text:t.join(``),attachments:n,rest:r}}function o_(e){return Math.max(1,Math.ceil(e/1e3))}function s_(e,t,n){return t===`ACCOUNT_SIGNED_OUT`?n(`message.failure.accountSignedOut`):t===`ACCOUNT_SIGN_IN_REQUIRED`?n(`message.failure.accountSignInRequired`):t===`QUOTA`||t===`ACCOUNT_QUOTA`?n(`message.failure.quota`):t===`AUTH`?n(`message.failure.auth`):e}function c_({node:e,active:t,t:n}){let r=(0,d.useMemo)(()=>Date.now()+e.delayMs,[e.delayMs,e.seq]),i=o_(e.delayMs),a=e.mode===`normal`?e.maxRetries:`∞`,[o,s]=(0,d.useState)(()=>({deadline:r,seconds:o_(r-Date.now())})),c=o.deadline===r?o.seconds:o_(r-Date.now());(0,d.useEffect)(()=>{if(!t)return;let e=()=>{let e=o_(r-Date.now());return s(t=>t.deadline===r&&t.seconds===e?t:{deadline:r,seconds:e}),e};if(e()===1)return;let n=window.setInterval(()=>{e()===1&&window.clearInterval(n)},250);return()=>{window.clearInterval(n)}},[t,r]);let l=t?n(`message.retry.active`):e.retryState===`cancelled`?n(`message.retry.cancelled`):e.retryState===`started`?n(`message.retry.started`):n(`message.retry.scheduled`),u=t?c:i;return/* @__PURE__ */ (0,f.jsxs)(`details`,{className:J.retryRow,"data-active":t||void 0,children:[/* @__PURE__ */ (0,f.jsx)(`summary`,{className:J.retrySummary,children:/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.retryText,role:`status`,children:/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{active:t,children:n(`message.retry.status`,{label:l,retry:e.retry,maximum:a,seconds:u})})})}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:J.retryDetails,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.retryDetailLabel,children:n(`message.retry.delay`)}),n(`duration.milliseconds`,{milliseconds:Math.round(e.delayMs)})]}),/* @__PURE__ */ (0,f.jsxs)(`div`,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.retryDetailLabel,children:n(`message.retry.failure`)}),s_(e.failure.message,e.failure.code,n)]})]})]})}function l_({node:e,t}){return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:J.turnErrorRow,role:`status`,children:[/* @__PURE__ */ (0,f.jsx)(p.StateDot,{state:`error`,className:J.turnErrorDot}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:J.turnErrorCopy,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.turnErrorTitle,children:e.code===`ACCOUNT_SIGNED_OUT`?t(`message.accountStopped`):t(`message.turnError`)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.turnErrorMessage,children:s_(e.message,e.code,t)})]}),e.code!==void 0&&/* @__PURE__ */ (0,f.jsx)(`code`,{className:J.turnErrorCode,children:e.code})]})}function u_({t:e}){return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:J.turnErrorRow,role:`status`,children:[/* @__PURE__ */ (0,f.jsx)(p.StateDot,{state:`warning`,className:J.turnErrorDot}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:J.turnErrorCopy,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.maxTokensTitle,children:e(`message.maxTokens`)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.turnErrorMessage,children:e(`message.maxTokens.hint`)})]})]})}function d_({content:e,renderMessageImages:t,actions:n,pending:r=!1,echo:i=!1,referenceLabels:a=[],skillNames:o=[],responseAnnotations:s=[],previewAttachments:c,references:l,links:u,sessionId:d,editor:m,t:h}){let{text:g,attachments:_,rest:v}=a_(e),y=c??_,b=y.length>1,x=e=>h(`json.truncated`,{total:e}),S=g!==``||v.length>0,C=ch(g),w=C?null:Lf(g),T=n_(!C&&!w&&!m&&S,`${g}\0${String(v.length)}`);return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:C?J.noticeRow:J.userRow,"data-pending-steering":r||void 0,"data-submission-echo":i||void 0,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:C?J.noticeStack:J.userStack,children:[s.length>0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:J.annotationRow,"data-message-annotations":!0,children:s.map((e,t)=>/* @__PURE__ */ (0,f.jsx)(p.ResponseAnnotationChip,{index:t+1,annotation:e,labels:Lh(h)},`${String(t)}:${e.text}`))}),y.length>0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:J.attachmentRow,"data-message-attachments":!0,children:y.map((e,n)=>/* @__PURE__ */ (0,f.jsxs)(`div`,{className:J.pendingAttachment,children:[e.type===`image`?t({images:[e.image],align:`end`,compact:b}):/* @__PURE__ */ (0,f.jsxs)(`span`,{className:J.fileCard,title:r_(e.file)??e.file.name,children:[/* @__PURE__ */ (0,f.jsx)(p.FileTypeIcon,{path:e.file.name,className:J.fileIcon}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:J.fileContent,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.fileName,children:e.file.name}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:J.fileMeta,children:[(0,p.fileExtension)(e.file.name).toUpperCase().slice(0,8),r_(e.file)===void 0?(0,p.fileSizeText)(e.file.bytes):void 0].filter(Boolean).join(` `)})]})]}),e.upload&&/* @__PURE__ */ (0,f.jsx)(i_,{upload:e.upload,t:h})]},n))}),m??(S&&(C?/* @__PURE__ */ (0,f.jsxs)(`div`,{onClick:e=>{e.detail>=2&&Kg(e.currentTarget)},children:[/* @__PURE__ */ (0,f.jsx)(Jh,{entries:C,links:u,sessionId:d,t:h}),v.map((e,t)=>/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:h(`message.extraBlock`),payload:e,truncatedLabel:x},t))]}):w?/* @__PURE__ */ (0,f.jsxs)(`div`,{onClick:e=>{e.detail>=2&&Kg(e.currentTarget)},children:[/* @__PURE__ */ (0,f.jsx)(Uh,{context:w,t:h}),v.map((e,t)=>/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:h(`message.extraBlock`),payload:e,truncatedLabel:x},t))]}):/* @__PURE__ */ (0,f.jsxs)(`div`,{ref:T.bubbleRef,className:T.collapsible?`${J.bubble} ${J.bubbleCollapsible}`:J.bubble,"data-user-bubble-collapsed":T.collapsed||void 0,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{ref:T.contentRef,className:T.collapsed?`${J.bubbleContent} ${J.bubbleContentCollapsed}`:J.bubbleContent,onClick:e=>{e.detail>=2&&Kg(e.currentTarget)},children:[(0,p.projectUserText)(g,a,o,`skill`,l,!0),v.map((e,t)=>/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:h(`message.extraBlock`),payload:e,truncatedLabel:x},t))]}),T.collapsible&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:T.expanded?`${J.bubbleToggleRow} ${J.bubbleToggleRowExpanded}`:J.bubbleToggleRow,"data-user-bubble-toggle-row":!0,children:/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:J.bubbleToggle,"aria-expanded":T.expanded,"data-user-bubble-toggle":!0,onClick:T.toggle,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{children:T.expanded?h(`message.collapse`):h(`message.expand`)}),T.expanded?/* @__PURE__ */ (0,f.jsx)(p.IconChevronUpOutlineRegular,{className:J.bubbleToggleIcon}):/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{className:J.bubbleToggleIcon})]})})]}))),a.length>0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:J.referenceSummary,children:h(`message.referenceSummary`,{labels:a.join(h(`message.referenceSeparator`))})})]}),!C&&n?.(g)]})}function f_({content:e,renderMessageImages:t,t:n}){let r=(0,d.useMemo)(()=>{let t=[];for(let n of e){let e=n;e.type===`text`&&typeof e.text==`string`&&t.push(...bh(e.text))}return t},[e]);return/* @__PURE__ */ (0,f.jsx)(d_,{content:e,responseAnnotations:r,renderMessageImages:t,pending:!0,t:n,actions:e=>/* @__PURE__ */ (0,f.jsx)(Lg,{text:e,clock:`start`,className:J.actions,t:n})})}function p_({submission:e,renderMessageImages:t,t:n}){let r=(0,d.useMemo)(()=>e.text===``?[]:[{type:`text`,text:e.text}],[e.text]),i=(0,d.useMemo)(()=>bh(e.text),[e.text]),a=(0,d.useMemo)(()=>e.attachments.map(e=>({upload:e.upload,...e.type===`image`?{type:`image`,image:{preview:{url:e.value.previewUrl,...e.value.name===void 0?{}:{name:e.value.name},...e.value.width===void 0?{}:{width:e.value.width},...e.value.height===void 0?{}:{height:e.value.height}}}}:{type:`file`,file:e.value}})),[e.attachments]);return/* @__PURE__ */ (0,f.jsx)(d_,{content:r,responseAnnotations:i,previewAttachments:a,renderMessageImages:t,pending:e.placement===`steering`,echo:!0,t:n,actions:t=>/* @__PURE__ */ (0,f.jsx)(Lg,{text:t,time:e.time,clock:`start`,className:J.actions,t:n})})}let m_=(0,d.memo)(function({node:e,renderMessageImages:t,openFile:n,openSkill:r,messageEditing:i,useProjection:a,links:o,sessionId:s,t:c}){let l=e.data,u=Zg(a,e.location.kind===`turn`||e.location.kind===`step`?e.location.turn.turn:void 0,`start`);return/* @__PURE__ */ (0,f.jsx)(d_,{content:l.content,editor:i?.draft?.seq===l.seq?/* @__PURE__ */ (0,f.jsx)($g,{editing:i,t:c}):void 0,references:{openFile:n,openSkill:r},links:o,sessionId:s,renderMessageImages:t,responseAnnotations:l.responseAnnotations,...l.referenceLabels===void 0?{}:{referenceLabels:l.referenceLabels},...l.skillNames===void 0?{}:{skillNames:l.skillNames},t:c,actions:t=>/* @__PURE__ */ (0,f.jsx)(Lg,{extraActions:e.kind===`user`&&i?.targetSeq===l.seq&&!i.draft?/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:J.editAction,"aria-label":c(`message.edit`),title:c(`message.edit`),onClick:()=>i.begin(l.seq,t,l.content,l.responseAnnotations),children:/* @__PURE__ */ (0,f.jsx)(p.IconEditOutlineRegular,{})}):null,text:t,time:e.kind===`user`?u:void 0,clock:`start`,className:J.actions,t:c})})});function h_({editing:e,renderMessageImages:t,t:n}){return/* @__PURE__ */ (0,f.jsx)(d_,{content:e.draft?.content??[],responseAnnotations:e.draft?.responseAnnotations,renderMessageImages:t,editor:/* @__PURE__ */ (0,f.jsx)($g,{editing:e,t:n}),t:n})}let g_=(0,d.memo)(function({node:e,t}){let n=e.data;return/* @__PURE__ */ (0,f.jsx)(wg,{content:n.content,source:n.source,producer:n.producer,form:n.form,t})}),__=(0,d.memo)(function({node:e,t}){return/* @__PURE__ */ (0,f.jsx)(Xh,{node:e.data,t})}),v_=(0,d.memo)(function({node:e,t}){let n=e.data;return/* @__PURE__ */ (0,f.jsx)(c_,{node:n.current,active:n.current.retryState===`scheduled`,t})}),y_=(0,d.memo)(function({node:e,t}){return/* @__PURE__ */ (0,f.jsx)(l_,{node:e.data,t})}),b_=(0,d.memo)(function({t:e}){return/* @__PURE__ */ (0,f.jsx)(u_,{t:e})}),x_=(0,d.memo)(function({node:e,t}){let n=e.data;return/* @__PURE__ */ (0,f.jsx)(`div`,{className:J.contextRow,children:/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:t(`message.unknownSurface`,{type:n.type}),payload:n.data,truncatedLabel:e=>t(`json.truncated`,{total:e})})})}),S_=/* @__PURE__ */ new Set([`system-prompt`,`user`,`steering`,`turn-trigger`,`turn-process`,`turn-error`,`turn-max-tokens`,`turn-tail`]);function C_(e,t){return e.turn===t.turn&&e.controlAnchorSeq===t.controlAnchorSeq&&e.processStartSeq===t.processStartSeq&&e.answerAnchorSeq===t.answerAnchorSeq&&e.answerStep===t.answerStep&&e.inlineReasoning===t.inlineReasoning&&e.messageCount===t.messageCount&&e.toolCallCount===t.toolCallCount&&e.subagentCount===t.subagentCount}function w_(e){return e===`subagent`||e.startsWith(`subagent_`)}function T_(e){return e===`compact_context`}function E_(e){let t=e?.location;if(t?.kind!==`turn`&&t?.kind!==`step`)return!1;let n=t.turn.end?.data.reason.kind;return t.turn.status===`open`||t.turn.end?.data.finalAssistantStep===null||n===`aborted`||n===`error`}function D_(e,t){return e.turnProcesses.find(e=>e.turn===t)}function O_(){return(0,m.defineStore)({init:()=>({turnProcesses:[]}),actions:{setTurnProcessOpen:(e,t,n,r)=>{let i=e.turnProcesses.findIndex(e=>e.turn===t);if(!r){i>=0&&e.turnProcesses.splice(i,1);return}let a={turn:t,answerStep:n};i<0?e.turnProcesses.push(a):e.turnProcesses[i]=a}}})}let k_=`data-chat-near-viewport`;function A_(e){if(!Number.isFinite(e)||e<=0)return 440;let t=Math.ceil(e*.75/80)*80;return Math.max(240,Math.min(720,t))}let j_=/* @__PURE__ */ new WeakMap;function M_(e,t){let n=j_.get(e);if(n!==void 0&&(n.marginPx===t||n.observedCount>0))return n;n?.observer.disconnect();let r=/* @__PURE__ */ new WeakSet,i={marginPx:t,observer:new IntersectionObserver(e=>{for(let t of e)r.has(t.target)&&t.target.toggleAttribute(k_,t.isIntersecting)},{root:e,rootMargin:`${t}px 0px`}),observedRows:r,observedCount:0};return j_.set(e,i),i}function N_(e,t,n){if(t.clientHeight<=0)return!0;let r=t.getBoundingClientRect(),i=e.getBoundingClientRect();return r.height<=0&&i.height<=0||i.bottom>=r.top-n&&i.top<=r.bottom+n}function P_(e,t){(0,d.useLayoutEffect)(()=>{let n=e.current;if(n===null)return;if(!t||n.matches(`[data-chat-flow-key] *`)){n.removeAttribute(k_);return}let r=n.closest(`[data-conversation-scroll]`);if(r===null||typeof IntersectionObserver>`u`){n.setAttribute(k_,``);return}let i=M_(r,A_(r.clientHeight));return n.toggleAttribute(k_,N_(n,r,i.marginPx)),i.observedRows.add(n),i.observedCount+=1,i.observer.observe(n),()=>{i.observedRows.delete(n),i.observer.unobserve(n),i.observedCount=Math.max(0,i.observedCount-1),n.removeAttribute(k_)}},[e,t])}function F_(e,t){let n=(0,d.useRef)(null);return(0,d.useLayoutEffect)(()=>{let r=n.current;r!==null&&(e&&r.contains(r.ownerDocument.activeElement)?t():e?r.setAttribute(`hidden`,`until-found`):r.removeAttribute(`hidden`))},[e,t]),(0,d.useEffect)(()=>{let e=n.current;if(e!==null)return e.addEventListener(`beforematch`,t),()=>{e.removeEventListener(`beforematch`,t)}},[t]),n}let I_=[],L_={getSnapshot:()=>I_,subscribe:()=>()=>{}};function R_(e){let t=I_;return{getSnapshot:()=>{let n=e.getSnapshot().flatMap(e=>e.responseAnnotations??[]);return n.length===t.length&&n.every((e,n)=>e===t[n])||(t=n.length===0?I_:n),t},subscribe:e.subscribe}}function z_(e,t){let n=(0,d.useMemo)(()=>t===void 0?L_:R_(e.turnDataSource(t,`user`)),[e,t]);return(0,d.useSyncExternalStore)(n.subscribe,n.getSnapshot)}let B_=`@deepseek-ai/dsh-client-ui-chat/ChatView.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(B_)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=B_,e.textContent=`.BZ5KQW_frame{flex-direction:column;flex:auto;min-height:0;display:flex;position:relative}.BZ5KQW_root{flex-direction:column;flex:auto;min-height:0;display:flex;position:relative;overflow:visible clip}.BZ5KQW_scroll{overscroll-behavior-y:none;--dsh-chat-scroll-pad-x:calc(var(--dsh-composer-side-clearance,0px) + 16px);min-height:0;padding:16px var(--dsh-chat-scroll-pad-x);flex:auto;overflow:clip auto}.BZ5KQW_root[data-chat-following-tail] .BZ5KQW_scroll,[data-conversation-scroll]:has(.BZ5KQW_root[data-chat-following-tail]){overflow-anchor:none}[data-conversation-scroll] .BZ5KQW_frame,[data-conversation-scroll] .BZ5KQW_root{flex:none;height:auto;min-height:auto}[data-conversation-scroll] .BZ5KQW_scroll{flex:none;min-height:auto;overflow:clip visible}.BZ5KQW_column{max-width:var(--dsh-chat-content-width);flex-direction:column;width:100%;margin:0 auto;display:flex}.BZ5KQW_column>:not([hidden]):not(.BZ5KQW_flowItem:is(:empty,[data-chat-empty]))~:not([hidden]):not(.BZ5KQW_flowItem:is(:empty,[data-chat-empty])){margin-top:var(--dsh-chat-flow-gap,6px)}.BZ5KQW_flowItem[data-chat-group-part=response],.BZ5KQW_column>[data-chat-group-part=response]:not([hidden]):not(:is(:empty,[data-chat-empty]))+:not([hidden]):not(.BZ5KQW_flowItem:is(:empty,[data-chat-empty])):not(.BZ5KQW_running){--dsh-chat-flow-gap:12px}.BZ5KQW_flowItem{min-width:0}.BZ5KQW_flowItem[data-chat-flow-kind=turn-process],.BZ5KQW_flowItem[data-turn-process-answer],.BZ5KQW_column>[data-chat-flow-kind=turn-process]+:not([hidden]):not(.BZ5KQW_flowItem:is(:empty,[data-chat-empty])):not(.BZ5KQW_running){--dsh-chat-flow-gap:16px}.BZ5KQW_flowItem:is(:empty,[data-chat-empty]){height:0}.BZ5KQW_callRow{border-radius:var(--dsw-radius-sm)}.BZ5KQW_syncing{color:var(--dsw-alias-label-secondary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px));-webkit-user-select:none;user-select:none;align-items:center;gap:6px;padding-block:8px;display:flex}@media (prefers-reduced-motion:reduce){.BZ5KQW_syncingIcon{display:none}}.BZ5KQW_hint{color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px));-webkit-user-select:none;user-select:none}.BZ5KQW_running{--dsh-chat-flow-gap:12px;--dsw-alias-label-shimmer:var(--dsw-alias-label-deep-diving-shimmer);color:var(--dsw-alias-label-deep-diving);font-size:calc(var(--dsh-content-font-size,14px) - 2px);line-height:calc(22px + var(--dsh-content-font-delta,0px));-webkit-user-select:none;user-select:none;flex-direction:column;align-items:flex-start;display:flex}.BZ5KQW_column>:nth-last-child(2 of :not([hidden]):not(.BZ5KQW_flowItem:is(:empty,[data-chat-empty]))):is(.BZ5KQW_flowItem:not([data-chat-flow-kind=user]):not([data-chat-flow-kind=steering]):not([data-chat-flow-kind=turn-trigger]),[data-chat-group-key])~.BZ5KQW_running>.BZ5KQW_runningDivider{display:block}.BZ5KQW_runningDivider{background:color-mix(in srgb, var(--dsw-alias-border-l1) 75%, var(--dsw-alias-border-l2));pointer-events:none;width:100%;height:.5px;margin:8px 0 10px;display:none}.BZ5KQW_runningContent{align-items:center;gap:6px;min-width:0;display:inline-flex}.BZ5KQW_runningText{font-variant-numeric:tabular-nums;min-width:0}.BZ5KQW_runningIcon{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px));contain:strict;flex:none;display:inline-flex;overflow:hidden}.BZ5KQW_runningIconMotion{transform-origin:50% 60%;width:100%;height:100%;display:inline-flex}@keyframes BZ5KQW_runningIconSway{0%,to{transform:translateY(.5px)rotate(-20deg)}50%{transform:translateY(-.6px)rotate(20deg)}}@media (prefers-reduced-motion:no-preference) and (forced-colors:none){.BZ5KQW_runningIconMotion{animation:1.6s ease-in-out infinite BZ5KQW_runningIconSway}}.BZ5KQW_openError{color:var(--dsw-alias-state-error-primary);font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(18px + var(--dsh-content-font-delta-secondary,0px))}.BZ5KQW_older{overflow-anchor:none;min-height:28px;color:var(--dsw-alias-label-secondary);-webkit-user-select:none;user-select:none;flex-wrap:wrap;justify-content:center;align-items:center;gap:8px;font-size:12px;display:flex}.BZ5KQW_older button{border-radius:var(--dsw-radius-sm);color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-interactive-bg-hover-solid);cursor:pointer;border:none;padding:4px 12px;font-size:12px}.BZ5KQW_older button:disabled{cursor:default;opacity:.6}.BZ5KQW_toBottomSlot{z-index:8;height:0;padding-right:max(calc(var(--dsh-composer-side-clearance) + 16px), calc((100% - var(--dsh-chat-content-width)) / 2));pointer-events:none;-webkit-user-select:none;user-select:none;justify-content:flex-end;display:flex;position:absolute;bottom:16px;left:0;right:0}[data-conversation-scroll] .BZ5KQW_toBottomSlot{bottom:calc(var(--dsh-composer-height,152px) + 16px);position:sticky}.BZ5KQW_toBottom{--dsw-elevation-stroke-color:var(--dsw-alias-border-l3);corner-shape:round;width:34px;height:34px;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-button-floating-fill);box-shadow:var(--dsw-elevation-panel);cursor:pointer;pointer-events:auto;border:0;border-radius:100px;justify-content:center;align-items:center;margin-top:-34px;padding:0;display:flex}.BZ5KQW_toBottom:hover{background:var(--dsw-alias-button-floating-hover)}.BZ5KQW_modalAction{min-width:72px}`,document.head.appendChild(e)}var V_={callRow:`BZ5KQW_callRow`,column:`BZ5KQW_column`,flowItem:`BZ5KQW_flowItem`,frame:`BZ5KQW_frame`,hint:`BZ5KQW_hint`,modalAction:`BZ5KQW_modalAction`,older:`BZ5KQW_older`,openError:`BZ5KQW_openError`,root:`BZ5KQW_root`,running:`BZ5KQW_running`,runningContent:`BZ5KQW_runningContent`,runningDivider:`BZ5KQW_runningDivider`,runningIcon:`BZ5KQW_runningIcon`,runningIconMotion:`BZ5KQW_runningIconMotion`,runningIconSway:`BZ5KQW_runningIconSway`,runningText:`BZ5KQW_runningText`,scroll:`BZ5KQW_scroll`,syncing:`BZ5KQW_syncing`,syncingIcon:`BZ5KQW_syncingIcon`,toBottom:`BZ5KQW_toBottom`,toBottomSlot:`BZ5KQW_toBottomSlot`};function H_(e){let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn.data:void 0}function U_(e){let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn.turn:void 0}function W_(e){return e?.kind===`tool-call`&&T_(e.data.root.name)}let G_=`data-chat-empty`;function K_(e){for(let t=e.firstElementChild;t!==null;t=t.nextElementSibling)if(t.getAttribute(`data-slot`)===`conversation.chat.node`)return t;return null}function q_(e){for(let t=e.firstChild;t!==null;t=t.nextSibling)if(t.nodeType===Node.ELEMENT_NODE||(t.nodeType===Node.TEXT_NODE||t.nodeType===Node.CDATA_SECTION_NODE)&&(t.nodeValue?.length??0)>0)return!1;return!0}function J_(e,t){t!==null&&q_(t)?e.hasAttribute(G_)||e.setAttribute(G_,``):e.hasAttribute(G_)&&e.removeAttribute(G_)}let Y_=/* @__PURE__ */ new WeakMap;function X_(e){if(typeof MutationObserver>`u`)return null;let t=Y_.get(e);if(t!==void 0)return t;let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new WeakMap,i=/* @__PURE__ */ new WeakSet,a=0,o=!1,s=(e,t)=>{i.has(t)||(e.observe(t,{childList:!0}),i.add(t),a+=1)},c,l=e=>{let t=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Set;for(let a of e){let e=a.target;if(n.has(e)){let n=e;t.add(n),i.add(n)}else if(e.nodeType===1){let i=r.get(e);i!==void 0&&n.has(i)&&t.add(i)}}for(let e of t){let t=n.get(e)??null;if(i.has(e)){let i=K_(e);i!==t&&(t!==null&&r.delete(t),n.set(e,i),i!==null&&(r.set(i,e),s(c,i)),t=i)}J_(e,t)}};c=new MutationObserver(l);let u=()=>{if(o=!1,n.size===0){c.disconnect(),i=/* @__PURE__ */ new WeakSet,a=0;return}if(a<=Math.max(128,n.size*4))return;let e=c.takeRecords();e.length>0&&l(e),c.disconnect(),i=/* @__PURE__ */ new WeakSet,a=0;for(let[e,t]of n){let i=K_(e);i!==t&&(t!==null&&r.delete(t),n.set(e,i)),s(c,e),i!==null&&(r.set(i,e),s(c,i)),J_(e,i)}},d=()=>{o||(o=!0,queueMicrotask(u))},f={observe(e){let t=n.get(e),i=K_(e);t!=null&&t!==i&&r.delete(t),n.set(e,i),s(c,e),i!==null&&(r.set(i,e),s(c,i)),J_(e,i)},unobserve(e){if(!n.has(e))return;let t=n.get(e);t!=null&&r.delete(t),n.delete(e),n.size===0?(o=!1,c.disconnect(),i=/* @__PURE__ */ new WeakSet,a=0):a>Math.max(128,n.size*4)&&d()}};return Y_.set(e,f),f}let Z_=(0,d.memo)(function({nodeKey:e,groupPart:t,nodeStore:n,useChatNode:r,useChatNodeProcess:i,usePresentation:a,cwd:o,openFile:s,openSkill:c,inspectCall:l,forkAt:u,handoffAt:h,loadTurnDiffs:g,messageEditing:_,loadImage:v,renderMessageImages:y,fileMentions:b,useStore:x,actions:S,renderSlot:C,t:w}){let T=r(e),E=T,ee=U_(E),D=i(e),O=D?.spec,te=x(e=>O===void 0?void 0:D_(e,O.turn)),ne=O!==void 0&&te?.answerStep===(O.answerStep??0)?te:void 0,re=D!==void 0&&!D.turnClosed,ie=D?.hasInterleavedInput===!0,ae=re||ie||E_(E),oe=ae||ne!==void 0,se=(0,d.useCallback)(e=>{O!==void 0&&!ae&&S.setTurnProcessOpen(O.turn,O.answerStep??0,e)},[S,O,ae]),ce=a(e=>e.foldCompletedTurns),le=O!==void 0&&D!==void 0&&ce&&D.turn===O.turn&&(D.turnStarted||D.turnClosed),ue=E!==void 0&&le&&!re&&t!==`reasoning`&&E.kind===`assistant-step`&&E.data.step===O.answerStep,de=E!==void 0&&le&&!ue&&!S_.has(E.kind)&&!W_(E)&&E.anchorSeq>=O.processStartSeq,fe=E?.kind===`turn-process`||ue,pe=le&&(re||de||fe),k=(0,d.useMemo)(()=>O===void 0?void 0:{spec:O,foldable:pe,hasContent:!ie&&(D?.hasExternalProcess===!0||O.inlineReasoning),open:oe,setOpen:se},[pe,ie,oe,O,D?.hasExternalProcess,se]),me=E?.kind===`turn-process`&&ce&&!pe,he=ue&&pe&&D.compactAnswer&&!oe,ge=me||pe&&de&&!oe,_e=F_(ge,(0,d.useCallback)(()=>{de&&se(!0)},[de,se]));P_(_e,T!==void 0&&!ge);let ve=E===void 0?void 0:t===void 0||t===`response`?E.key:JSON.stringify([E.key,t]),ye=E!==void 0&&ve!==void 0,be=E?.kind;(0,d.useLayoutEffect)(()=>{let e=_e.current;if(e===null)return;if(!ye){e.hasAttribute(G_)&&e.removeAttribute(G_);return}let t=X_(e.ownerDocument);if(t===null)J_(e,K_(e));else return t.observe(e),()=>{t.unobserve(e)}},[ye,ve,be,_e]);let[xe]=(0,d.useState)(()=>(0,m.createSnapshotStore)(0)),Se=z_(n,ee),Ce=H_(E),we=(0,d.useMemo)(()=>({turnData:Ce,disclosureReset:xe}),[Ce,xe]);(0,d.useEffect)(()=>{de&&ge&&_e.current?.hasAttribute(`hidden`)&&xe.set(xe.getSnapshot()+1)},[de,ge,_e,xe]);let Te=(0,d.useMemo)(()=>T===void 0?null:{...t===void 0?{}:{groupPart:t},cwd:o,openFile:s,openSkill:c,inspectCall:l,forkAt:u,handoffAt:h,loadTurnDiffs:g,messageEditing:_,loadImage:v,renderMessageImages:y,fileMentions:b,turnProcess:k,responseAnnotations:Se},[T,t,o,s,c,l,u,h,g,_,v,y,b,k,Se]);if(E===void 0||Te===null||ve===void 0)return null;let Ee={...Te,node:E};return/* @__PURE__ */ (0,f.jsx)(`div`,{ref:_e,className:V_.flowItem,"data-chat-anchor-key":ve,"data-chat-flow-key":ve,"data-chat-paging-anchor":E.kind!==`turn-process`||void 0,"data-chat-node-key":E.key,"data-chat-group-part":t,"data-chat-flow-kind":E.kind,"data-chat-turn":ee,"data-turn-process-member":de||void 0,"data-turn-process-hidden":ge||void 0,"data-turn-process-answer":he||void 0,children:C(`conversation.chat.node`,Ee,{entryKey:E.kind,hookContext:we,fallback:/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:w(`message.unknownSurface`,{type:E.kind}),payload:E.data,truncatedLabel:e=>w(`json.truncated`,{total:e})})})})}),Q_={'"':`"`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:`
121
+ `,r:`\r`,t:` `},$_=/[\\\u0000-\u001f]/u;function ev(e){return e===` `||e===`
122
+ `||e===`\r`||e===` `}function tv(e){return e>=`0`&&e<=`9`||e>=`a`&&e<=`f`||e>=`A`&&e<=`F`}var nv=class e{static EMPTY=e.fromObject({});static fromText(t){let n=new e;return n.append(t),n.sealed=!0,n}static fromObject(t){let n=new e;return n.object=typeof t==`object`&&t&&!Array.isArray(t)?t:{},n.sealed=!0,n}chunks=[];object;sealed=!1;#e=[];#t=0;#n=0;#r=`root`;#i=!1;#a=0;#o=!1;#s=``;#c=null;#l=[];#u=!1;#d;#f=!1;#p=/* @__PURE__ */ new Map;#m=[];#h=/* @__PURE__ */ new Map;get isSealed(){return this.sealed}get invalid(){return this.scan(),this.#r===`invalid`||this.#f}append(e){if(this.sealed)throw Error(`PartialArguments: cannot append to a sealed view`);e.length!==0&&(this.chunks.push(e),this.#t+=e.length,this.#e.push(this.#t))}settle(t){if(this.object!==void 0||t.length!==this.#t)return e.fromText(t);let n=0;for(let r of this.chunks){if(!t.startsWith(r,n))return e.fromText(t);n+=r.length}return this.chunks=t.length===0?[]:[t],this.#e=t.length===0?[]:[t.length],this.sealed=!0,this}refresh(){if(this.#h.size===0)return!1;this.scan();let e=!1,t=!1;for(let n of this.#h.values())n.completion?t=!0:e=this.refreshRead(n)||e;if(t)for(let t of this.#h.values())t.completion&&(e=this.refreshRead(t)||e);return this.sealed&&this.#h.clear(),e}refreshRead(e){let t=e.answer();return!Object.is(t,e.last)&&(e.last=t,!0)}closed(){return this.remember(`closed`,``,()=>this.closedNow())}keys(){return this.remember(`keys`,``,()=>this.keysNow(),e=>e.length)}has(e){return this.remember(`has`,e,()=>this.hasNow(e))}complete(e){return this.remember(`complete`,e,()=>this.completeNow(e))}stringLength(e,t){let n=Math.max(1,Math.floor(t?.step??1)),r=t?.offset??0;return this.remember(`length:${n}:${r}`,e,()=>this.lengthNow(e),e=>e===void 0?void 0:Math.ceil((e+r)/n))}stringExceeds(e,t){let n=Math.max(0,Math.floor(t));return this.remember(`exceeds:${n}`,e,()=>(this.lengthNow(e,n+1)??0)>n)}text(e){return this.remember(`text`,e,()=>this.textNow(e))}textPrefix(e,t){let n=Math.max(1,Math.floor(t));return this.remember(`prefix:${n}`,e,()=>this.textPrefixNow(e,n))}value(e){return this.remember(`value`,e,()=>this.valueNow(e))}remember(e,t,n,r){this.scan();let i=n();if(!this.sealed){let a=`${e}/${t}`;this.#h.has(a)||this.#h.set(a,{completion:e===`complete`,answer:r===void 0?n:()=>r(n()),last:r===void 0?i:r(i)})}return i}closedNow(){return this.sealed||this.#r===`closed`||this.#r===`invalid`}keysNow(){return this.object===void 0?this.#m:Object.keys(this.object)}hasNow(e){return this.object===void 0?this.#p.has(e):Object.hasOwn(this.object,e)}completeNow(e){if(this.object!==void 0)return Object.hasOwn(this.object,e);let t=this.#p.get(e);return t!==void 0&&t.end>=0&&(t.kind===`string`?t.invalidAt===void 0:!t.invalid)}lengthNow(e,t=1/0){if(this.object!==void 0){let t=Object.hasOwn(this.object,e)?this.object[e]:void 0;return typeof t==`string`?t.length:void 0}let n=this.#p.get(e);if(n?.kind!==`string`)return;if(n.text!==void 0&&n.text.at===n.end)return n.text.length;let r=n.length??={at:n.start,length:0,text:``};return this.readString(n,r,t,!1),r.length}textNow(e){if(this.object!==void 0){let t=Object.hasOwn(this.object,e)?this.object[e]:void 0;return typeof t==`string`?t:void 0}let t=this.#p.get(e);if(t?.kind!==`string`)return;if(t.text===void 0&&t.end>=0&&t.needsDecoding&&t.invalidAt===void 0){let e;try{e=JSON.parse(`"${this.slice(t.start,t.end)}"`)}catch{}e!==void 0&&(t.text={at:t.end,length:e.length,text:e})}let n=t.text??={at:t.start,length:0,text:``};return this.readString(t,n,1/0,!0),n.text}textPrefixNow(e,t){if(this.object!==void 0){let n=Object.hasOwn(this.object,e)?this.object[e]:void 0;return typeof n==`string`?n.slice(0,t):void 0}let n=this.#p.get(e);if(n?.kind!==`string`)return;let r=n.prefixes??=/* @__PURE__ */ new Map,i=r.get(t);return i===void 0&&(i={at:n.start,length:0,text:``},r.set(t,i)),this.readString(n,i,t,!0),i.text}valueNow(e){if(this.object!==void 0){if(!Object.hasOwn(this.object,e))return;let t=this.object[e];return typeof t==`string`?void 0:t}let t=this.#p.get(e);if(!(t?.kind!==`value`||t.end<0||t.invalid)){if(t.parsed===void 0)try{t.parsed=JSON.parse(this.slice(t.start,t.end))}catch{t.invalid=!0,this.#f=!0}return t.parsed}}chunkAt(e){let t=0,n=this.#e.length;for(;t<n;){let r=t+n>>>1;this.#e[r]<=e?t=r+1:n=r}return t}slice(e,t){if(e>=t)return``;let n=this.chunkAt(e),r=this.chunkAt(t-1),i=n===0?0:this.#e[n-1];if(n===r)return this.chunks[n].slice(e-i,t-i);let a=[this.chunks[n].slice(e-i)];for(let e=n+1;e<r;e++)a.push(this.chunks[e]);return a.push(this.chunks[r].slice(0,t-this.#e[r-1])),a.join(``)}readString(e,t,n,r){let i=Math.min(e.end<0?this.#n:e.end,e.invalidAt??1/0,this.#d??1/0);if(!e.needsDecoding){let e=Math.min(i-t.at,n-t.length);if(e<=0)return;r&&(t.text+=this.slice(t.at,t.at+e)),t.at+=e,t.length+=e;return}let a=this.chunkAt(t.at);for(;t.at<i&&t.length<n;){let o=a===0?0:this.#e[a-1],s=this.chunks[a],c=s.slice(t.at-o,Math.min(s.length,i-o)),l=c.search($_),u=Math.min(l<0?c.length:l,n-t.length);if(u>0){r&&(t.text+=c.slice(0,u)),t.at+=u,t.length+=u,t.at===o+s.length&&a++;continue}let d=c.length>1?c[1]:t.at+1<i?this.chunks[a+1][0]:void 0,f,p=2;if(c[0]===`\\`&&d===void 0&&e.end<0)return;if(c[0]===`\\`&&d===`u`){let n=this.slice(t.at+2,Math.min(i,t.at+6)),r=!0;for(let e=0;e<n.length;e++)tv(n[e])||(r=!1);if(r){if(n.length<4&&e.end<0)return;n.length===4&&(f=String.fromCharCode(Number.parseInt(n,16)))}p=6}else c[0]===`\\`&&d!==void 0&&(f=Q_[d]);if(f===void 0){e.invalidAt=t.at,this.#f=!0;return}for(r&&(t.text+=f),t.length++,t.at+=p;a<this.chunks.length&&t.at>=this.#e[a];)a++}}scan(){if(this.object===void 0&&this.#n!==this.#t)for(let e=this.chunkAt(this.#n);e<this.chunks.length&&this.#d===void 0;e++){let t=this.chunks[e],n=e===0?0:this.#e[e-1];for(let e=this.#n-n;e<t.length&&this.#r!==`invalid`;e++){if(this.#r===`string`||this.#r===`nested`&&this.#u){let n=this.stringBoundary(t,e);if(this.#n+=n-e,e=n,e===t.length)break}this.step(t[e],this.#n),this.#n++}}}stringBoundary(e,t){let n=t;for(;;){let t=e.indexOf(`"`,n),r=t<0?e.length:t;if(this.#r===`string`){let t=this.#c;!t.needsDecoding&&$_.test(e.slice(n,r))&&(t.needsDecoding=!0)}let i=r;for(;i>n&&e[i-1]===`\\`;)i--;let a=(r-i)%2==1!==(i===n&&this.#i);if(this.#i=t<0&&a,t<0||!a)return r;n=t+1}}step(e,t){switch(this.#r){case`root`:if(ev(e))return;if(e===`{`){this.#r=`key-or-end`;return}this.fail();return;case`key-or-end`:if(ev(e))return;if(e===`}`){this.#r=`closed`;return}if(e===`"`){this.beginKey(t);return}this.fail();return;case`key-only`:if(ev(e))return;if(e===`"`){this.beginKey(t);return}this.fail();return;case`key`:this.stepKey(e,t);return;case`colon`:if(ev(e))return;if(e===`:`){this.#r=`value`;return}this.fail();return;case`value`:this.beginValue(e,t);return;case`string`:{let e=this.#c;e.end=t,this.#c=null,this.#r=`comma-or-end`;return}case`scalar`:this.stepScalar(e,t);return;case`nested`:this.stepNested(e,t);return;case`comma-or-end`:if(ev(e))return;if(e===`,`){this.#r=`key-only`;return}if(e===`}`){this.#r=`closed`;return}this.fail();return;case`closed`:if(ev(e))return;this.fail();return;
123
123
  /* v8 ignore next 2 -- scan() stops stepping once the view is invalid. */
124
124
  case`invalid`:return;
125
125
  /* v8 ignore next 2 -- Every scanner mode has a handler above. */
126
- default:Ug(this.#r)}}fail(){this.#d=this.#n,this.#r=`invalid`,this.#c=null}beginKey(e){this.#r=`key`,this.#a=e+1,this.#o=!1,this.#i=!1}stepKey(e,t){if(e<` `){this.fail();return}if(this.#i){this.#i=!1;return}if(e===`\\`){this.#i=!0,this.#o=!0;return}if(e!==`"`)return;let n=this.slice(this.#a,t);if(this.#o)try{this.#s=JSON.parse(`"${n}"`)}catch{this.fail();return}else this.#s=n;this.#r=`colon`}open(e){this.#p.has(this.#s)||this.#m.push(this.#s),this.#p.set(this.#s,e),this.#c=e}beginValue(e,t){Bg(e)||(e===`"`?(this.open({kind:`string`,start:t+1,end:-1,needsDecoding:!1,invalidAt:void 0,length:void 0,text:void 0,prefixes:void 0}),this.#i=!1,this.#r=`string`):e===`}`||e===`,`||e===`:`||e===`]`?this.fail():(this.open({kind:`value`,start:t,end:-1,parsed:void 0,invalid:!1}),e===`{`||e===`[`?(this.#r=`nested`,this.#l=[e===`{`?`}`:`]`],this.#u=!1,this.#i=!1):this.#r=`scalar`))}stepScalar(e,t){(e===`,`||e===`}`||Bg(e))&&(this.closeValue(t),this.#r=e===`,`?`key-only`:e===`}`?`closed`:`comma-or-end`)}stepNested(e,t){if(this.#u)this.#u=!1;else if(e===`"`)this.#u=!0;else if(e===`{`||e===`[`)this.#l.push(e===`{`?`}`:`]`);else if(e===`}`||e===`]`){if(this.#l.pop()!==e){this.fail();return}this.#l.length===0&&(this.closeValue(t+1),this.#r=`comma-or-end`)}}closeValue(e){let t=this.#c;t.end=e,this.#c=null}};function Ug(e,t){let n=JSON.stringify(e)??String(e);throw Error(`unreachable variant${t?` in ${t}`:``}: ${n}`)}function Wg(e){switch(e.kind){case`node`:return JSON.stringify([`node`,e.key,e.groupPart??null]);case`group`:return JSON.stringify([`group`,e.key]);default:return Ug(e)}}function Gg(e,t){let n=e.counts.slice(0,3).map(({kind:e})=>t(`message.stepProcess.done.${e}`)),r=n[0];if(r===void 0)return t(`message.stepProcess.done.thinking`);let i=e=>e.charAt(0).toLowerCase()+e.slice(1),a=n[1];if(a===void 0)return r;if(n.length===2){let e=t(`message.stepProcess.sharedPrefix`);return t(`message.stepProcess.joinTwo`,{first:r,second:i(e!==``&&r.startsWith(e)&&a.startsWith(e)?a.slice(e.length):a)})}let o=[r,...n.slice(1).map(i)].join(t(`message.stepProcess.comma`));return e.counts.length>3?t(`message.stepProcess.more`,{title:o}):o}function Kg(e=0){let[t,n]=(0,d.useState)(null);return{expanded:t===e,setExpanded:(0,d.useCallback)(t=>{n(t?e:null)},[e]),toggle:(0,d.useCallback)(()=>{n(t=>t===e?null:e)},[e])}}function qg(e){let t=t=>e.subscribe(t),n=()=>e.getSnapshot();return function(){return Kg((0,d.useSyncExternalStore)(t,n))}}function Jg(e){let t=e.clientHeight;return{top:e.scrollTop,height:t,floor:Math.max(0,e.scrollHeight-t)}}var Yg=class e{following;threshold;static owners=/* @__PURE__ */ new WeakMap;target=null;sampledTop;constructor(e,t){this.following=e,this.threshold=t}static forElement(e){return this.owners.get(e)}bind(t){return e.owners.set(t,this),()=>{e.owners.get(t)===this&&e.owners.delete(t)}}get active(){return this.following}get animating(){return this.target!==null}nearBottom(e){return e.floor-e.top<=this.threshold}setFollowing(e){this.following=e,e||(this.target=null)}reset(){this.setFollowing(!1),this.sampledTop=void 0}sample(e,t=this.sampledTop===void 0||Math.abs(e.top-this.sampledTop)>.5){return this.sampledTop=e.top,!this.animating&&t&&(this.following=this.nearBottom(e)),this.active}settle(e){let t=this.target;return this.target=null,this.sample(e,t===null?void 0:Math.abs(e.top-Math.min(t,e.floor))>this.threshold)}jump(e,t,n){let r=this.animating;this.target=null;let i=Math.max(0,Math.min(t.floor,n));r?e.scrollTo({top:i,behavior:`instant`}):i!==t.top&&(e.scrollTop=i);let a={...t,top:e.scrollTop};return this.sampledTop=a.top,this.following=this.nearBottom(a),a}toBottom(e,t,n){return this.following=!0,n===`instant`||t.top>=t.floor||!this.animating&&this.nearBottom(t)||typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches?this.jump(e,t,t.floor):(this.target===null&&(this.target=t.floor,e.scrollTo({top:t.floor,behavior:`smooth`})),t)}interrupt(e,t){this.animating&&(this.target=null,this.sampledTop=t.top,e.scrollTo({top:t.top,behavior:`instant`}))}};function Xg(e,t){let[n]=(0,d.useState)(()=>new Yg(e,t));return n}let Zg={canScrollUp:!1,canScrollDown:!1},Qg=/* @__PURE__ */ new Set([`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `]);function $g(e,t,n,r){let i=Xg(!1,1),a=(0,d.useRef)(null),[o,s]=(0,d.useState)(Zg),c=(0,d.useCallback)(e=>{a.current=e},[]),l=(0,d.useCallback)(t=>{let n=e.current,r=Zg;if(n!==null&&n.closest(`[hidden], [data-group-expanded-mode]`)===null){let e=Jg(n),o=t===`resize`?a.current:null;if(o!==null)e=i.jump(n,e,o===`bottom`?e.floor:0),o===`top`&&i.setFollowing(!1),a.current=null;else{let r=i.animating;t===`scrollend`?i.settle(e):i.sample(e),i.active&&(t===`resize`||t===`scrollend`&&r)&&(e=i.toBottom(n,e,`smooth`))}r={canScrollUp:e.top>1,canScrollDown:e.top<e.floor-1}}else i.reset();s(e=>e.canScrollUp===r.canScrollUp&&e.canScrollDown===r.canScrollDown?e:r)},[e,i]),u=(0,d.useCallback)(()=>{let t=e.current;t!==null&&i.animating&&i.interrupt(t,Jg(t))},[e,i]),f=(0,d.useMemo)(()=>({onScroll:()=>{l(`scroll`)},onWheel:u,onTouchStart:u,onPointerDown:u,onKeyDown:e=>{!e.defaultPrevented&&Qg.has(e.key)&&u()}}),[u,l]);return(0,d.useLayoutEffect)(()=>{u(),i.reset(),(!r||!n)&&(a.current=null)},[i,r,u,n]),(0,d.useLayoutEffect)(()=>{let r=e.current;if(r===null||!n||typeof ResizeObserver>`u`)return;let a=i.bind(r),o=new ResizeObserver(()=>{l(`resize`)}),s=e=>{e.target===r&&l(`scrollend`)};return r.addEventListener(`scrollend`,s),o.observe(r),t.current!==null&&o.observe(t.current),()=>{a(),o.disconnect(),r.removeEventListener(`scrollend`,s)}},[e,t,i,n,l]),{edges:o,events:f,initialize:c}}let e_=`@deepseek-ai/dsh-client-ui-chat/ChatGroupSeat.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(e_)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=e_,e.textContent=`.M49uyW_root{min-width:0}.M49uyW_title{max-width:100%;color:var(--dsw-alias-label-tertiary);font:inherit;font-size:var(--dsh-content-font-size,14px);text-align:left;cursor:pointer;background:0 0;border:0;align-items:center;gap:6px;padding:0;transition:color .1s;display:flex}@media (hover:hover){.M49uyW_title:hover{color:var(--dsw-alias-label-secondary)}}.M49uyW_title:active{color:var(--dsw-alias-label-secondary)}.M49uyW_leading{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px));color:inherit;flex:none;justify-content:center;align-items:center;display:inline-flex;position:relative}.M49uyW_leading svg{width:calc(14px + var(--dsh-content-font-delta,0px));height:calc(14px + var(--dsh-content-font-delta,0px))}.M49uyW_leading svg[width="16"]{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px))}.M49uyW_activityIcon,.M49uyW_chevron{justify-content:center;align-items:center;transition:opacity .1s;display:inline-flex;position:absolute;inset:0}.M49uyW_activityIcon{opacity:1}.M49uyW_chevron{opacity:0}html:not([data-input-modality=pointer]) .M49uyW_title:focus-visible .M49uyW_activityIcon{opacity:0}html:not([data-input-modality=pointer]) .M49uyW_title:focus-visible .M49uyW_chevron{opacity:1}@media (hover:hover){.M49uyW_title:hover .M49uyW_activityIcon{opacity:0}.M49uyW_title:hover .M49uyW_chevron{opacity:1}}.M49uyW_title[aria-expanded=true] .M49uyW_activityIcon{opacity:0}.M49uyW_title[aria-expanded=true] .M49uyW_chevron{opacity:1}.M49uyW_title[aria-expanded=true]{padding-bottom:8px}.M49uyW_body{--dsh-chat-flow-gap:6px;overscroll-behavior-y:auto;scrollbar-gutter:stable;max-height:min(400px,50vh);overflow-y:auto}.M49uyW_label{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.M49uyW_fadeTop{mask-image:linear-gradient(#0000 0,#000 24px 100%)}.M49uyW_fadeBottom{mask-image:linear-gradient(#000 0 calc(100% - 24px),#0000 100%)}.M49uyW_fadeTop.M49uyW_fadeBottom{mask-image:linear-gradient(#0000 0,#000 24px calc(100% - 24px),#0000 100%)}@media (prefers-reduced-motion:reduce){.M49uyW_title,.M49uyW_activityIcon,.M49uyW_chevron{transition:none}}.M49uyW_content{flex-direction:column;display:flex}.M49uyW_content>*{flex-shrink:0}.M49uyW_content>:not([hidden]):not(:empty)~:not([hidden]):not(:empty){margin-top:var(--dsh-chat-flow-gap,6px)}.M49uyW_expandedBody{scrollbar-gutter:auto;max-height:none;overflow:visible}`,document.head.appendChild(e)}var t_={activityIcon:`M49uyW_activityIcon`,body:`M49uyW_body`,chevron:`M49uyW_chevron`,content:`M49uyW_content`,expandedBody:`M49uyW_expandedBody`,fadeBottom:`M49uyW_fadeBottom`,fadeTop:`M49uyW_fadeTop`,label:`M49uyW_label`,leading:`M49uyW_leading`,root:`M49uyW_root`,title:`M49uyW_title`};let n_={thinking:/* @__PURE__ */ (0,f.jsx)(p.IconThinkOutlineRegular,{}),read:/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),readImage:/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),search:/* @__PURE__ */ (0,f.jsx)(p.IconSearchOutlineRegular,{size:14}),edit:/* @__PURE__ */ (0,f.jsx)(p.IconEditOutlineRegular,{size:14}),write:/* @__PURE__ */ (0,f.jsx)(p.IconEditOutlineRegular,{size:14}),commands:/* @__PURE__ */ (0,f.jsx)(p.IconApiOutlineRegular,{}),code:/* @__PURE__ */ (0,f.jsx)(p.IconCodeOutlineRegular,{size:14}),webSearch:/* @__PURE__ */ (0,f.jsx)(p.IconGlobeOutlineRegular,{}),webFetch:/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),subagents:/* @__PURE__ */ (0,f.jsx)(p.IconAgentPresetOutlineRegular,{size:14}),plan:/* @__PURE__ */ (0,f.jsx)(p.IconPlanOutlineRegular,{}),questions:/* @__PURE__ */ (0,f.jsx)(p.IconQuestionOutlineRegular,{}),tools:/* @__PURE__ */ (0,f.jsx)(p.IconSparkleRegular,{size:14})};function r_(e,t){return e.activity===t.activity&&e.detail===t.detail&&e.preparing===t.preparing}function i_(e,t){let[n,r]=(0,d.useState)(e),i=(0,d.useRef)(n),a=(0,d.useRef)(e),o=(0,d.useRef)(Date.now());return(0,d.useEffect)(()=>{if(a.current=e,!t||r_(i.current,e))return;let n=150-(Date.now()-o.current),s=()=>{let e=a.current;i.current=e,o.current=Date.now(),r(e)};if(n<=0){s();return}let c=setTimeout(s,n);return()=>{clearTimeout(c)}},[t,e.activity,e.detail,e.preparing]),t?n:e}let a_=(0,d.memo)(function({members:e,...t}){return e.map(e=>/* @__PURE__ */ (0,d.createElement)(Lg,{...t,key:Wg(e),nodeKey:e.key,...e.groupPart===void 0?{}:{groupPart:e.groupPart}}))}),o_=(0,d.memo)(function({groupKey:e,useChatGroup:t,usePresentation:n,t:r,open:i,bodyId:a,toggle:o}){let s=t(e,e=>e?.data),c=n(e=>s?.closed===!1&&e.liveProcessDetail),l=i_({activity:s?.summary.running??`thinking`,detail:s?.summary.runningDetail??``,preparing:s?.summary.preparing===!0},s!==void 0&&!s.closed);if(s===void 0)return null;let u=s.closed?Gg(s.summary,r):l.preparing?r(`message.stepProcess.prepare.${l.activity===`thinking`?`tools`:l.activity}`):r(`message.stepProcess.${l.activity}`),d=c&&!s.closed?l.detail:``,m=d===``?u:`${u}${r(`message.turnProcess.separator`)}${d}`,h=s.closed?s.summary.counts[0]?.kind??`thinking`:l.activity;return/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:t_.title,"aria-expanded":i,"aria-controls":a,"data-process-activity":h,onClick:e=>{let t=e.currentTarget,n=t.ownerDocument.getElementById(a);i&&n?.contains(t.ownerDocument.activeElement)&&(e.detail!==0||(0,p.pointerModality)()?(0,p.focusWithoutRing)(t,{preventScroll:!0}):t.focus({preventScroll:!0})),o()},children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:t_.leading,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:t_.activityIcon,"data-step-process-icon":!0,children:n_[h]}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:t_.chevron,"data-step-process-chevron":!0,children:i?/* @__PURE__ */ (0,f.jsx)(p.IconChevronUpOutlineRegular,{}):/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{})})]}),/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{active:!s.closed,children:/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{className:t_.label,children:m})})]})}),s_=(0,d.memo)(function({groupKey:e,useChatGroup:t,members:n,closed:r,grouped:i,open:a,setOpen:o,...s}){let c=(0,d.useCallback)(()=>{o(!0)},[o]),l=xg(i&&!a,c),u=(0,d.useRef)(null),p=(0,d.useId)(),{edges:m,events:h,initialize:g}=$g(l,u,a,i),_=(0,d.useCallback)(()=>{a||g(r===!1?`bottom`:`top`),o(!a)},[r,g,a,o]),v=[t_.body,i?``:t_.expandedBody,i&&m.canScrollUp?t_.fadeTop:``,i&&m.canScrollDown?t_.fadeBottom:``];return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`div`,{hidden:!i,children:/* @__PURE__ */ (0,f.jsx)(o_,{groupKey:e,useChatGroup:t,usePresentation:s.usePresentation,t:s.t,open:a,bodyId:p,toggle:_})}),/* @__PURE__ */ (0,f.jsx)(`div`,{ref:l,id:p,className:v.join(` `),"data-step-process-body":!0,"data-scroll-up":m.canScrollUp||void 0,"data-scroll-down":m.canScrollDown||void 0,...h,children:/* @__PURE__ */ (0,f.jsx)(`div`,{ref:u,className:t_.content,"data-step-process-content":!0,"data-chat-flow":``,children:/* @__PURE__ */ (0,f.jsx)(a_,{...s,members:n})})})]})}),c_=(0,d.memo)(function({groupKey:e,useChatGroup:t,mounted:n=!0,placeholderHeight:r,registerRow:i,...a}){let o=t(e,e=>e?.members),s=t(e,e=>e?.data.turn),c=t(e,e=>e?.data.closed),l=a.usePresentation(e=>e.foldCompletedTurns),{expanded:u,setExpanded:m}=Kg(),h=o?.[0]?.key??``,g=a.useChatNodeProcess(h),_=a.useChatNode(h,e=>{let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn:void 0}),v=a.usePresentation(e=>e.stepGrouping===`collapsed`||e.stepGrouping===`history`&&_?.status!==`open`),y=_?.end?.data.reason.kind,b=g?.turnClosed===!1||g?.hasInterleavedInput===!0||_?.end?.data.finalAssistantStep===null||y===`aborted`||y===`error`,x=g?.spec,S=(0,d.useCallback)(e=>s===void 0?void 0:pg(e,s),[s]),C=a.useStore(S),w=l&&g?.turnClosed===!0&&x!==void 0&&!b&&C?.answerStep!==(x.answerStep??0),T=xg(w,(0,d.useCallback)(()=>{x!==void 0&&!b&&a.actions.setTurnProcessOpen(x.turn,x.answerStep??0,!0)},[a.actions,x,b])),E=(0,d.useRef)(null);if(E.current===null&&(E.current=/* @__PURE__ */ new Map),bg(T,!!n&&o!==void 0&&!w),(0,d.useLayoutEffect)(()=>{if(i===void 0||o===void 0)return;let t=T.current;if(t!==null)return i(e,t),()=>{i(e,null)}},[i,e,T,o!==void 0]),(0,d.useEffect)(()=>{w&&T.current?.hasAttribute(`hidden`)&&m(!1)},[w,T,m]),o===void 0)return null;let D=!n&&!w&&r!==void 0&&r>0;return/* @__PURE__ */ (0,f.jsx)(`div`,{ref:T,className:t_.root,"data-chat-group-key":e,"data-chat-flow-key":e,"data-chat-anchor-key":`group:${e}`,"data-chat-turn":s,"data-chat-paging-anchor":v&&!u||void 0,"data-step-process":!0,"data-group-expanded-mode":!v||void 0,"data-chat-virtualized":D?``:void 0,style:D?{minHeight:r}:void 0,children:n?/* @__PURE__ */ (0,f.jsx)(p.CodeBlockFoldMemoryProvider,{memory:E.current,scope:e,children:/* @__PURE__ */ (0,f.jsx)(s_,{...a,groupKey:e,useChatGroup:t,members:o,closed:c,grouped:v,open:u,setOpen:m})}):null})});function l_(e){return typeof e==`object`?e.key:e}function u_(e,t){let n=e.length;return new Proxy(e,{get(e,r,i){if(typeof r==`string`){let i=r.charCodeAt(0);if(i>=48&&i<=57){let i=+r;if(Number.isInteger(i)&&i>=0&&i<n){let n=e[i];if(typeof n!=`object`){let r=t[i*2];n=e[i]={index:i,key:n,start:r,size:t[i*2+1],end:r+t[i*2+1],lane:0}}return n}}if(r===`length`)return n}return Reflect.get(e,r,i)}})}function d_(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return(o.length!==r.length||o.some((e,t)=>r[t]!==e))&&(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1),i}return o.updateDeps=e=>{r=e},o}function f_(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}let p_=(e,t)=>Math.abs(e-t)<1.01,m_=(e,t,n)=>{let r;return Object.assign(function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)},{cancel:()=>{e.clearTimeout(r)}})},h_,g_=()=>{if(h_!==void 0)return h_;if(typeof navigator>`u`)return h_=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return h_=!0;let e=navigator.maxTouchPoints;return h_=navigator.platform===`MacIntel`&&e!==void 0&&e>0},__=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},v_=e=>e,y_=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},b_=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(__(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(__(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},x_={passive:!0},S_=typeof window>`u`||`onscrollend`in window,C_=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&S_,o=0,s=a?null:m_(i,()=>t(n(r),!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,x_),a&&r.addEventListener(`scrollend`,u,x_),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u),s?.cancel()}},w_=(e,t)=>C_(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),T_=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},E_=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})};function D_(e,t,n,r){if(t===0)return!1;let i=r(0),a=/* @__PURE__ */ new Set,o=0;for(;o<e;){let e=n(o);if(e===i)break;a.add(e),o++}let s=e-o;if(s===0||s>=t)return!1;for(let e=0;e<s;e++)if(r(e)!==n(o+e))return!1;for(let e=s;e<t;e++)if(a.has(r(e)))return!1;return!0}var O_=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache=/* @__PURE__ */ new Map,this.itemSizeCacheVersion=0,this.laneAssignments=/* @__PURE__ */ new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this._clampedAdjustment=null,this.elementsCache=/* @__PURE__ */ new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=/* @__PURE__ */ (()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(t.isConnected)this.isIndexInRange(n)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this));else{this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}}};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:v_,rangeExtractor:y_,onChange:()=>{},measureElement:T_,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=this._singleLaneMeasurements?.items??s,l=e=>l_(c[e]),u=e>0?l(0):null,d=e>0?l(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==u||t.getItemKey(o-1)!==d)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>0&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==d)&&(o>e||D_(e,o,l,t.getItemKey))&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=!1,s=0;if(r&&this.scrollOffset!==null){let[e,t]=r,n=this.getMeasurements(),{count:a,getItemKey:c}=this.options,l=0;for(;l<a&&c(l)!==e;)l++;if(l<a){let e=n[l];if(e){let n=Math.max(0,e.start+t);!i&&n!==this.scrollOffset&&(s=n-this.scrollOffset,this.scrollOffset=n,o=!0)}}}(o||i)&&(this.pendingScrollAnchor=[o?r[0]:null,o?r[1]:0,i,s])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=d_(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.isScrolling=!1,this.scrollDirection=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._clampedAdjustment=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.targetWindow=this.scrollElement&&`ownerDocument`in this.scrollElement?this.scrollElement.ownerDocument.defaultView:this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{if(t&&this._intendedScrollOffset===null&&e===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this._clampedAdjustment!==null&&Math.abs(e-this._clampedAdjustment.maxAtWrite)>=1.5&&(this._clampedAdjustment=null),this.scrollAdjustments=0;let n=this.getScrollOffset();this.scrollDirection=t?n===e?this.scrollDirection:n<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,g_()&&this.targetWindow!=null&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,x_),e.addEventListener(`touchend`,n,x_),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r,i]=t;e!==null&&!r&&(g_()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):this.scrollState?.behavior===`smooth`&&!p_(this.getScrollOffset()-i,this.scrollState.lastTargetOffset)||this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}this._retryClampedAdjustment()},this._retryClampedAdjustment=()=>{if(this._clampedAdjustment===null||!this.scrollElement||!this.options.enabled)return;let{target:e,maxAtWrite:t}=this._clampedAdjustment,n=this.getMaxScrollOffset();n>t+.5&&(this._clampedAdjustment=e>n+.5?{target:e,maxAtWrite:n}:null,this._scrollToOffset(e,{adjustments:void 0,behavior:void 0}))},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;if(this._iosDeferredAdjustment<0&&e>=t-1){this._iosDeferredAdjustment=0;return}let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=d_(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,t,n,r,i,a,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s}),{key:!1}),this.isIndexInRange=e=>e>=0&&e<this.options.count,this.getMeasurements=d_(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s},c)=>{let l=this.itemSizeCache;if(!i)return this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let u=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=e*2,a=this._singleLaneMeasurements?.flat;if(!a||a.length<i){let e=new Float64Array(i);a&&u>0&&e.set(a.subarray(0,u*2)),a=e}let o=u===0?Array(e):this._singleLaneMeasurements.items.slice(),c;if(u===0)c=t+n;else{let e=u-1;c=a[e*2]+a[e*2+1]+s}for(let t=u;t<e;t++){let e=r(t);o[t]=e;let n=l.get(e),i=typeof n==`number`?n:this.options.estimateSize(t);a[t*2]=c,a[t*2+1]=i,c+=i+s}this._singleLaneMeasurements={flat:a,items:o};let d=u_(o,a);return this.measurementsCache=d,d}let d=this.measurementsCache.slice(0,u),f=Array(a).fill(void 0),p=new Float64Array(a),m=0;for(let e=0;e<u;e++){let t=d[e];t&&(f[t.lane]===void 0&&m++,f[t.lane]=e,p[t.lane]=t.end)}for(let i=u;i<e;i++){let e=r(i),c=this.laneAssignments.get(i),u,h,g=o===`estimate`||l.has(e);if(c!==void 0&&this.options.lanes>1){u=c;let e=f[u],r=e===void 0?void 0:d[e];h=r?r.end+s:t+n}else if(m===a){let e=0,t=p[0],n=f[0];for(let r=1;r<a;r++){let i=p[r];(i<t||i===t&&f[r]<n)&&(e=r,t=i,n=f[r])}u=e,h=t+s,g&&this.laneAssignments.set(i,u)}else u=i%this.options.lanes,h=t+n,g&&this.laneAssignments.set(i,u);let _=l.get(e),v=typeof _==`number`?_:this.options.estimateSize(i),y=h+v;d[i]={index:i,start:h,size:v,end:y,key:e,lane:u},f[u]===void 0&&m++,f[u]=i,p[u]=y}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=d_(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=j_(e,t,n,r,r===1&&this._singleLaneMeasurements!==null?this._singleLaneMeasurements.flat:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=d_(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e);if(!this.isIndexInRange(t))return;let n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(!this.isIndexInRange(e))return;let n,r,i,a=this._singleLaneMeasurements?.flat;if(this.options.lanes===1&&a!=null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=this.itemSizeCache.get(i)??n,s=t-o;if(s!==0){let a=this.options.anchorTo===`end`&&this.scrollState?.behavior!==`smooth`&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,c=a?this.getTotalSize():0,l=this.getScrollOffset()+this.scrollAdjustments,u=this.itemSizeCache.has(i)?r+o<=l&&this.scrollDirection!==`backward`:r<l,d=this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?u:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},s,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++;let f=!1;a?f=this.applyScrollAdjustment(this.getTotalSize()-c):d&&(f=this.applyScrollAdjustment(s)),this.notify(f),this._retryClampedAdjustment()}},this.getVirtualItems=d_(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._singleLaneMeasurements?.flat,r=this.options.lanes===1&&n!=null;return f_(t[k_(0,t.length-1,r?e=>n[e*2]:e=>f_(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`){if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t]}if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0;let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0,e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{this.options.count>0?this.scrollToIndex(this.options.count-1,{align:`end`,behavior:e}):this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._singleLaneMeasurements?.flat;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){if(e===0)return!1;if(g_()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded))return this._iosDeferredAdjustment+=e,!1;{let n=this.getScrollOffset()+this.scrollAdjustments+e,r=this.scrollElement,i=r!==null&&(`scrollHeight`in r||`document`in r)?this.getMaxScrollOffset():null;return this._clampedAdjustment=i!==null&&n>i+.5?{target:n,maxAtWrite:i}:null,this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0}}scheduleScrollReconcile(){this.targetWindow?this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}):this.scrollState=null}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&p_(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}};let k_=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function A_(e,t,n){let r=0;for(;r<=t;){let i=(r+t)/2|0,a=e[i*2];if(a<n)r=i+1;else if(a>n)t=i-1;else return i}return r>0?r-1:0}function j_(e,t,n,r,i){let a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&i!==null){let e=A_(i,a,n),r=e,o=n+t;for(;r<a&&i[r*2]+i[r*2+1]<o;)r++;return{startIndex:e,endIndex:r}}let o=k_(0,a,t=>e[t].start,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){let i=Array(r).fill(0);for(;s<a&&i.some(e=>e<n+t);){let t=e[s];i[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}let M_=typeof document<`u`?d.useLayoutEffect:d.useEffect;function N_({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=d.useReducer(e=>e+1,0)[1],a=d.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:/* @__PURE__ */ new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=d.useRef(!1),s=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}},c=e=>{let t=a.current;if(!t.enabled||!t.container)return;s(e);let n=!!e.options.horizontal,r=t.mode===`transform`,i=n?`left`:`top`,o=e.options.scrollMargin,c=e.getVirtualItems();for(let a of c){let s=a.start-o,c=e.elementsCache.get(a.key);c&&t.lastPositions.get(c)!==s&&(t.lastPositions.set(c,s),r?c.style.transform=n?`translate3d(${s}px, 0, 0)`:`translate3d(0, ${s}px, 0)`:c.style[i]=`${s}px`)}},l={...r,onChange:(t,n)=>{var s;let l=a.current,u=!0;if(l.enabled){c(t);let e=t.range,n=l.prevRange;u=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,u&&(l.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}u&&(e&&n&&!o.current?(0,h.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[u]=d.useState(()=>{let e=new O_(l),t=e.measureElement;return e.measureElement=e=>{o.current=!0;try{t(e)}finally{o.current=!1}},Object.assign(e,{containerRef:t=>{let n=a.current;if(n.container=t,n.lastSize=null,t&&n.enabled){let r=e.getTotalSize();n.lastSize=r;let i=e.options.horizontal?`width`:`height`;t.style[i]=`${r}px`}}})});return u.setOptions(l),M_(()=>u._didMount(),[]),M_(()=>(s(u),u._willUpdate())),M_(()=>{c(u)}),u}function P_(e){return N_({observeElementRect:b_,observeElementOffset:w_,scrollToFn:E_,...e})}let F_=`@deepseek-ai/dsh-client-ui-chat/TurnNavigator.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(F_)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=F_,e.textContent=`.R6aBma_slot{z-index:7;height:0;padding-inline:calc(var(--dsh-composer-side-clearance) + 16px);pointer-events:none;position:absolute;top:0;left:0;right:0;container-type:inline-size}[data-conversation-scroll] .R6aBma_slot{position:sticky}.R6aBma_frame{--turn-rail-band:calc(var(--dsh-conversation-viewport-height,100dvh) - var(--dsh-composer-height,152px));--turn-preview-height:104px;top:calc(var(--turn-rail-band) / 2);width:36px;max-height:min(max(0px, calc(var(--turn-rail-band) - 64px)), 70vh, 640px);contain:layout;cursor:pointer;pointer-events:auto;position:absolute;left:12px;transform:translateY(-50%)}.R6aBma_frame[hidden]{display:none}.R6aBma_scroller{max-height:inherit;overscroll-behavior:contain;scrollbar-width:none;position:relative;overflow-y:auto}.R6aBma_scroller::-webkit-scrollbar{display:none}.R6aBma_fadeTop{mask-image:linear-gradient(#0000 0,#000 40px 100%)}.R6aBma_fadeBottom{mask-image:linear-gradient(#000 0 calc(100% - 40px),#0000 100%)}.R6aBma_fadeTop.R6aBma_fadeBottom{mask-image:linear-gradient(#0000 0,#000 40px calc(100% - 40px),#0000 100%)}.R6aBma_marks{position:relative}.R6aBma_mark{cursor:pointer;background:0 0;border:0;border-radius:8px;height:10px;padding:0;position:absolute;top:0;left:0;right:0}.R6aBma_mark:before{background:var(--dsw-alias-label-tertiary);opacity:.4;content:"";transform-origin:0;width:26px;height:2px;transition:transform .16s cubic-bezier(.2,.8,.2,1),background-color .16s,opacity .16s;position:absolute;top:50%;left:0;transform:translateY(-50%)scaleX(.230769)}.R6aBma_markUnloaded:before{opacity:.25}.R6aBma_mark[data-neighbor-distance="3"]:before{transform:translateY(-50%)scaleX(.384615)}.R6aBma_mark[data-neighbor-distance="2"]:before{transform:translateY(-50%)scaleX(.538462)}.R6aBma_mark[data-neighbor-distance="1"]:before{transform:translateY(-50%)scaleX(.769231)}.R6aBma_markBusy:before{animation:1s ease-in-out infinite R6aBma_dsh-turn-mark-busy}.R6aBma_markActive:before{background:var(--dsw-alias-label-primary);opacity:.6}.R6aBma_frame[data-previewing] .R6aBma_markActive:not(.R6aBma_markPreview):not(:focus-visible):before{background:var(--dsw-alias-label-tertiary);opacity:.4}.R6aBma_markPreview:before{background:var(--dsw-alias-label-primary);opacity:1;transform:translateY(-50%)scaleX(1)}.R6aBma_frame[data-scrubbing] .R6aBma_mark:before{transition:none}.R6aBma_mark:focus-visible:before{background:var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));opacity:1;transform:translateY(-50%)scaleX(1)}.R6aBma_mark:focus-visible{outline:none}.R6aBma_mark:focus-visible:after{border-radius:inherit;outline:1px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-1px;content:"";width:28px;position:absolute;inset:0 auto 0 0}.R6aBma_preview{top:clamp(0px, calc(var(--turn-preview-center) - var(--turn-preview-height) / 2), calc(100% - var(--turn-preview-height)));box-sizing:border-box;width:min(320px,100cqw - 48px);max-height:var(--turn-preview-height);border:.5px solid var(--dsw-alias-border-l4);color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-1);box-shadow:var(--dsw-elevation-panel);pointer-events:none;border-radius:12px;padding:8px;transition:top .14s cubic-bezier(.2,.8,.2,1);animation:.12s ease-out R6aBma_dsh-turn-preview-enter;position:absolute;left:100%;overflow:hidden}.R6aBma_previewPrompt,.R6aBma_previewResponse{-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.R6aBma_previewPrompt{-webkit-line-clamp:1;font-size:14px;font-weight:500;line-height:20px}.R6aBma_previewResponse{color:var(--dsw-alias-label-caption);-webkit-line-clamp:3;margin-top:4px;font-size:14px;line-height:20px}@keyframes R6aBma_dsh-turn-preview-enter{0%{opacity:0;transform:translate(-4px)}to{opacity:1;transform:translate(0)}}@keyframes R6aBma_dsh-turn-mark-busy{0%,to{opacity:1}50%{opacity:.35}}@media (prefers-reduced-motion:reduce){.R6aBma_frame,.R6aBma_scroller,.R6aBma_mark:before,.R6aBma_markBusy:before,.R6aBma_preview{scroll-behavior:auto;transition:none;animation:none}}`,document.head.appendChild(e)}var I_={"dsh-turn-mark-busy":`R6aBma_dsh-turn-mark-busy`,"dsh-turn-preview-enter":`R6aBma_dsh-turn-preview-enter`,fadeBottom:`R6aBma_fadeBottom`,fadeTop:`R6aBma_fadeTop`,frame:`R6aBma_frame`,mark:`R6aBma_mark`,markActive:`R6aBma_markActive`,markBusy:`R6aBma_markBusy`,markPreview:`R6aBma_markPreview`,markUnloaded:`R6aBma_markUnloaded`,marks:`R6aBma_marks`,preview:`R6aBma_preview`,previewPrompt:`R6aBma_previewPrompt`,previewResponse:`R6aBma_previewResponse`,scroller:`R6aBma_scroller`,slot:`R6aBma_slot`};function L_(){return typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}let R_=(0,d.memo)(function({item:e,index:t,active:n,busy:r,previewId:i,neighborDistance:a,registerElement:o,onNavigate:s,onPreview:c,onFocusChange:l,t:u}){let d=[I_.mark];return e.anchor.kind===`unloaded`&&d.push(I_.markUnloaded),n&&d.push(I_.markActive),a===0&&d.push(I_.markPreview),r&&d.push(I_.markBusy),/* @__PURE__ */ (0,f.jsx)(`button`,{ref:o,"data-index":t,"data-neighbor-distance":a,type:`button`,className:d.join(` `),"aria-label":u(e.anchor.kind===`loaded`?`chat.turnNavigation.jump`:`chat.turnNavigation.jumpLoad`,{turn:t+1}),"aria-current":n?`true`:void 0,"aria-busy":r?`true`:void 0,"aria-describedby":i,onPointerMove:t=>{t.buttons===0&&c(e.turn)},onClick:()=>{s(e)},onFocus:()=>{l(e.turn)},onBlur:()=>{l(null)}})});function z_({items:e,activeTurn:t,busyTurn:n,onNavigate:r,t:i},a){let[o,s]=(0,d.useState)(null),[c,l]=(0,d.useState)(null),[u,p]=(0,d.useState)(!1),[m,h]=(0,d.useState)(!1),[g,_]=(0,d.useState)(!1),v=(0,d.useRef)(null),y=(0,d.useRef)(null),b=(0,d.useRef)(!1),x=(0,d.useRef)(void 0),S=(0,d.useRef)(null),C=(0,d.useRef)({placed:!1,index:0,follow:null,publishOffset:null}),w=(0,d.useRef)(!1),T=(0,d.useId)(),E=e.length>=2;(0,d.useLayoutEffect)(()=>{let e=v.current,t=e?.parentElement?.querySelector(`[data-chat-flow]`),n=e?.closest(`[data-conversation-scroll]`)??e?.parentElement;if(!t||!n)return;let r=()=>{let e=n.getBoundingClientRect(),r=n.offsetWidth>0?e.width/n.offsetWidth:1;h((t.getBoundingClientRect().left-e.left)/(r||1)>=48)},i=new ResizeObserver(r);return i.observe(t),i.observe(n),r(),()=>i.disconnect()},[E]),(0,d.useEffect)(()=>{if(o===null){p(!1);return}if(u)return;let e=setTimeout(()=>p(!0),150);return()=>clearTimeout(e)},[o,u]),(0,d.useEffect)(()=>()=>{clearTimeout(x.current);let e=y.current;y.current=null,e?.button.hasPointerCapture(e.pointerId)&&e.button.releasePointerCapture(e.pointerId)},[]);let D=(0,d.useMemo)(()=>{let t=/* @__PURE__ */ new Map;return e.forEach((e,n)=>{t.set(e.turn,n)}),t},[e]),O=t===null?void 0:D.get(t);(0,d.useLayoutEffect)(()=>{C.current.index=O??0},[O]);let k=c===null?void 0:D.get(c),A=o===null?void 0:D.get(o),ee=(0,d.useCallback)(e=>{l(e),s(e),p(e!==null)},[]),j=P_({count:e.length,enabled:E,directDomUpdates:!0,directDomUpdatesMode:`transform`,useScrollendEvent:!0,getScrollElement:(0,d.useCallback)(()=>S.current,[]),getItemKey:(0,d.useCallback)(t=>e[t]?.turn??t,[e]),estimateSize:()=>10,measureElement:()=>10,initialRect:{width:0,height:0},initialOffset:0,scrollToFn:(e,t,n)=>{C.current.placed&&E_(e,t,n)},observeElementOffset:(e,t)=>{C.current.publishOffset=t;let n=w_(e,t);return()=>{n?.(),C.current.placed=!1,C.current.follow=null,C.current.publishOffset=null}},observeElementRect:(e,t)=>{let n=e.scrollElement,r=e.targetWindow?.ResizeObserver;if(n===null||r===void 0)return;let i=new r(([r])=>{if(r===void 0)return;let i=r.borderBoxSize[0],a={width:Math.round(i?.inlineSize??r.contentRect.width),height:Math.round(i?.blockSize??r.contentRect.height)},o=C.current;if(!o.placed&&a.height>0){let t=Math.max(0,e.getTotalSize()-a.height),r=o.index*10+6,i=Math.max(0,Math.min(t,r-a.height/2));o.placed=!0,o.follow={index:o.index,count:e.options.count,height:a.height},n.scrollTop=i,o.publishOffset?.(i,!1)}t(a)});return i.observe(n,{box:`border-box`}),()=>{i.disconnect()}},paddingStart:1,paddingEnd:1,scrollPaddingStart:40,scrollPaddingEnd:40,overscan:3,rangeExtractor:(0,d.useCallback)(e=>{let t=y_(e);if(k!==void 0){let n=Math.min(e.count-1,k+1);for(let e=Math.max(0,k-1);e<=n;e++)t.includes(e)||t.push(e);t.sort((e,t)=>e-t)}return t},[k])}),te=j.scrollOffset??0,ne=j.scrollRect?.height??0,re=j.getVirtualItems(),ie=(0,d.useCallback)((e,t,n=L_())=>{let r=j.measurementsCache[e],i=j.scrollRect?.height??0;if(r===void 0||i<=0)return;let a=j.scrollOffset??0,o=r.start+r.size/2;if(t===`if-needed`){let{scrollPaddingStart:e,scrollPaddingEnd:t}=j.options;if(o>=a+e&&o<=a+i-t)return}let s=o-i/2,c=Math.max(0,j.getTotalSize()-i),l=Math.max(0,Math.min(c,s))-a;l!==0&&j.scrollBy(l,{behavior:n})},[j]);(0,d.useImperativeHandle)(a,()=>({activateTurn(t){let n=D.get(t),i=n===void 0?void 0:e[n];i!==void 0&&r(i)},scrollToTurn(e){let t=D.get(e);t!==void 0&&ie(t,`always`)}}),[e,D,r,ie]),(0,d.useEffect)(()=>{if(ne<=0){C.current.follow=null;return}if(O===void 0||w.current)return;let t=C.current.follow;if(t?.index===O&&t.count===e.length&&t.height===ne)return;C.current.follow={index:O,count:e.length,height:ne};let n=t?.count===e.length&&t.height===ne?L_():`instant`;ie(O,`if-needed`,n)},[O,e.length,ne,ie]);let ae=(0,d.useCallback)(e=>{b.current?b.current=!1:r(e)},[r]),oe=t=>{if(t.button!==0||!(t.target instanceof Element))return;let n=t.target.closest(`button[data-index]`);if(!n||!S.current?.contains(n))return;let r=e[Number(n.dataset.index)];r&&(clearTimeout(x.current),b.current=!1,y.current={pointerId:t.pointerId,button:n,turn:r.turn,moved:!1},n.setPointerCapture(t.pointerId),_(!0),s(r.turn),p(!0))},se=t=>{let n=y.current,i=S.current;if(!n||!i||t.pointerId!==n.pointerId||!(t.buttons&1))return;let a=i.getBoundingClientRect(),o=Math.max(a.top,Math.min(t.clientY,a.bottom-1)),c=e[Math.max(0,Math.min(e.length-1,Math.round((o-a.top+i.scrollTop-6)/10)))];c&&c.turn!==n.turn&&(n.turn=c.turn,n.moved=!0,s(c.turn),c.anchor.kind===`loaded`&&r(c))},ce=e=>{let t=y.current;t&&e.pointerId===t.pointerId&&(y.current=null,_(!1),b.current=t.moved,t.button.hasPointerCapture(e.pointerId)&&t.button.releasePointerCapture(e.pointerId),x.current=setTimeout(()=>{b.current=!1},0),w.current||s(null))};if(!E)return null;let le=!u||A===void 0?void 0:e[A],ue=re.find(e=>e.index===A),M=[I_.scroller];return te>1&&M.push(I_.fadeTop),te<j.getTotalSize()-ne-1&&M.push(I_.fadeBottom),/* @__PURE__ */ (0,f.jsx)(`div`,{ref:v,className:I_.slot,children:/* @__PURE__ */ (0,f.jsxs)(`nav`,{className:I_.frame,hidden:!m,"data-turn-navigation":``,"data-previewing":A!==void 0||void 0,"data-scrubbing":g||void 0,onPointerDownCapture:oe,onPointerMove:se,onPointerUpCapture:ce,onPointerCancelCapture:ce,onLostPointerCapture:ce,"aria-label":i(`chat.turnNavigation.label`),onPointerEnter:()=>{w.current=!0},onPointerLeave:()=>{w.current=!1,y.current||s(null)},children:[/* @__PURE__ */ (0,f.jsx)(`div`,{ref:S,className:M.join(` `),children:/* @__PURE__ */ (0,f.jsx)(`div`,{ref:j.containerRef,className:I_.marks,children:re.map(({index:r,key:a})=>{let c=e[r];return c===void 0?null:/* @__PURE__ */ (0,f.jsx)(R_,{item:c,index:r,active:c.turn===t,busy:c.turn===n,previewId:u&&c.turn===o?T:void 0,neighborDistance:A!==void 0&&Math.abs(r-A)<=3?Math.abs(r-A):void 0,registerElement:j.measureElement,onNavigate:ae,onPreview:s,onFocusChange:ee,t:i},a)})})}),le!==void 0&&ue!==void 0&&/* @__PURE__ */ (0,f.jsxs)(`div`,{id:T,role:`tooltip`,className:I_.preview,style:{"--turn-preview-center":`${String(ue.start+ue.size/2-te)}px`},children:[/* @__PURE__ */ (0,f.jsx)(`div`,{className:I_.previewPrompt,children:le.prompt||i(`chat.turnNavigation.turn`,{turn:(A??0)+1})}),le.response!==``&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:I_.previewResponse,children:le.response})]})]})})}let B_=(0,d.memo)((0,d.forwardRef)(z_));function V_(){return/* @__PURE__ */ (0,f.jsx)(`span`,{className:Dg.runningIcon,"aria-hidden":`true`,children:/* @__PURE__ */ (0,f.jsx)(`span`,{className:Dg.runningIconMotion,children:/* @__PURE__ */ (0,f.jsxs)(`svg`,{width:`100%`,height:`100%`,viewBox:`2 2 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:1.2,strokeLinecap:`round`,strokeLinejoin:`round`,children:[/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M16.1 5.3C11.8 2.9 6.6 5 5.1 9.4c-1.8 5.4 1.7 10.2 6.9 10.3 4.8.2 8-3.8 7.2-8.3-.4 3.2-2 5.1-4.2 5.8`}),/* @__PURE__ */ (0,f.jsx)(`rect`,{x:`9.5`,y:`9.1`,width:`4.6`,height:`4.6`,rx:`1`,transform:`rotate(-10 11.8 11.4)`})]})})})}let H_=`@deepseek-ai/dsh-client-ui-chat/accessibility.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(H_)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=H_,e.textContent=`.F76jpa_visuallyHidden{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}`,document.head.appendChild(e)}var U_={visuallyHidden:`F76jpa_visuallyHidden`};let W_=(0,d.memo)(function({startTime:e,compacting:t,stale:n,t:r}){let[i,a]=(0,d.useState)(Date.now);(0,d.useEffect)(()=>{if(e===void 0||t||n)return;a(Date.now());let r=setInterval(()=>{a(Date.now())},1e3);return()=>{clearInterval(r)}},[e,t,n]);let o=n?r(`chat.statusUnconfirmed`):t?r(`message.compaction.running`):e===void 0?r(`chat.deepDiving`):r(`chat.deepDivingFor`,{duration:_h(Math.max(1e3,i-e),r).map(e=>e.text).join(``)});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Dg.running,"data-chat-running":!0,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:U_.visuallyHidden,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:r(n?`chat.statusUnconfirmed`:t?`message.compaction.running`:`chat.deepDiving`)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Dg.runningDivider,"aria-hidden":`true`}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:Dg.runningContent,children:[n?null:/* @__PURE__ */ (0,f.jsx)(V_,{}),/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{active:!n,className:Dg.runningText,children:o})]})]})});function G_(e){return e}function K_(e){return e}function q_(e){if(!Number.isSafeInteger(e)||e<0||Object.is(e,-0))throw TypeError(`SessionSeq must be a non-negative safe integer, got ${String(e)}`);return K_(e)}let J_=[];function Y_(e){if(typeof e!=`object`||!e)return;let t=e;if(!(typeof t.turn!=`number`||!Number.isSafeInteger(t.turn)||t.turn<0)&&!(typeof t.seq!=`number`||!Number.isSafeInteger(t.seq)||t.seq<0||Object.is(t.seq,-0)))return{turn:t.turn,seq:q_(t.seq),prompt:typeof t.prompt==`string`?t.prompt:``,response:typeof t.response==`string`?t.response:``}}function X_(e){return Array.isArray(e)?e:J_}function Z_(e,t){let n=/* @__PURE__ */ new Map;for(let e of X_(t)){let t=Y_(e);t!==void 0&&n.set(t.turn,{turn:t.turn,prompt:t.prompt,response:t.response,anchor:{kind:`unloaded`,seq:t.seq}})}for(let t of e){let e=n.get(t.turn);n.set(t.turn,{turn:t.turn,prompt:t.prompt===``?e?.prompt??``:t.prompt,response:t.response===``?e?.response??``:t.response,anchor:{kind:`loaded`,key:t.anchorKey}})}return n.size===0?J_:[...n.values()].sort((e,t)=>e.turn-t.turn)}var Q_=class{viewport;reading;input;onBusyTurn;jump=null;settleFrame=null;requestedHead;constructor(e,t,n,r){this.viewport=e,this.reading=t,this.input=n,this.onBusyTurn=r}setInput(e){this.input=e}reset(){this.requestedHead=void 0,this.cancel()}dispose(){this.clearTask()}cancel(){this.clearTask(),this.onBusyTurn(null)}clearTask(){this.cancelFrame(),this.jump=null,this.viewport.stopPreserving()}navigateToTurn=e=>{if(e.anchor.kind===`loaded`){this.cancel();let t=this.viewport.scrollToTurn(e.turn);if(t===null)return;this.reading.acceptNavigation(t),this.input.loadingOlder&&this.viewport.beginPreserving(t.position);return}if(!this.input.historyReady)return;this.cancel(),this.viewport.beginPreserving(),this.reading.pauseFollowing();let t={turn:e.turn,seq:e.anchor.seq,phase:`loading`,landing:`pending`,repageHead:null};this.jump=t,this.onBusyTurn(t.turn),this.request(t)};autoLoadEarlier=()=>{if(this.jump!==null||this.input.olderFailed||this.requestedHead===this.input.firstSeq)return;let e=this.viewport.readScroll();e===null||e.metrics.top>240||this.loadEarlier()};loadEarlier=()=>{this.input.historyReady&&this.input.hasMore&&!this.input.loadingOlder&&(this.requestedHead=this.input.firstSeq,this.cancel(),this.viewport.beginPaging(),this.reading.pauseFollowing(),this.input.loadOlder())};readerSampled(e){e.movedByReader&&this.jump?.landing===`landed`&&(this.jump.landing=`interrupted`),e.followingTail?this.viewport.stopPreserving():e.movedByReader&&(this.input.loadingOlder&&this.jump===null?this.viewport.preserving||this.viewport.beginPreserving(e.position):this.viewport.stopPreserving())}contentCommitted(e=!1){if(!this.viewport.preserving||this.reading.pending&&!e)return!1;if(this.landJump(!1))return!0;let t=this.viewport.preserve(e);return t!==null&&((!e||!this.reading.pending)&&this.reading.preservePosition(t),!0)}readerSettled(){this.input.loadingOlder&&this.jump===null&&!this.viewport.preserving&&!this.reading.followingTail&&this.viewport.beginPreserving()}reconcile(){let e=this.jump;if(!this.input.historyReady||e===null||this.reading.pending)return;if(e.phase===`loading`){e.landing===`pending`&&this.landJump(!1);return}if(this.input.loadingOlder||this.landJump(!0))return;if((this.input.firstSeq===null||this.input.firstSeq>e.seq)&&this.input.hasMore&&e.repageHead!==this.input.firstSeq){e.repageHead=this.input.firstSeq,this.viewport.beginPreserving(),this.request(e);return}let t=this.viewport.scrollToTurnAtOrAfter(e.turn);this.cancel(),t!==null&&this.reading.acceptNavigation(t)}landJump(e){let t=this.jump;if(t===null)return!1;if(t.landing===`interrupted`)return e?(this.cancel(),!0):!1;let n=this.viewport.scrollToTurn(t.turn);return n!==null&&(this.reading.acceptNavigation(n),e?this.cancel():(this.viewport.beginPreserving(n.position),t.landing=`landed`),!0)}request(e){e.phase=`loading`;let t=()=>{this.jump===e&&(e.phase=`settled`,this.cancelFrame(),typeof requestAnimationFrame==`function`?this.settleFrame=requestAnimationFrame(()=>{this.settleFrame=null,this.jump===e&&this.reconcile()}):this.reconcile())};this.input.loadThrough(e.seq).then(t,t)}cancelFrame(){this.settleFrame!==null&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(this.settleFrame),this.settleFrame=null}};function $_(e,t,n){let[r,i]=(0,d.useState)(null),[a]=(0,d.useState)(()=>new Q_(e,t,n,i));return(0,d.useLayoutEffect)(()=>{a.setInput(n)},[a,n]),(0,d.useLayoutEffect)(()=>()=>{a.dispose()},[a]),{navigation:a,busyTurn:r}}var ev=class{viewport;store;state;onChange;follow;sampleTimer=null;probeFrame=null;sampled=null;pendingMovedByReader=!1;constructor(e,t,n,r,i){this.viewport=e,this.store=t,this.state=n,this.onChange=r,this.follow=i}get pending(){return this.sampleTimer!==null}get followingTail(){return this.state.followingTail}setStore(e){this.store=e}connect(e){return this.sampled=e,()=>{this.sampled===e&&(this.sampled=null)}}dispose(){this.cancelPending(),this.sampled=null}pauseFollowing(){this.cancelPending(),this.publish({...this.state,followingTail:!1})}followTail(){let e=this.viewport.scrollToBottom(this.follow);e!==null&&(this.cancelPending(),this.commit(e,!0,this.viewport.latestTurn))}restore(){let e=this.store.read();if(e===null){this.followTail();return}let t=this.viewport.restore(e);if(t===null)return;this.cancelPending();let n=this.follow.nearBottom(t.metrics);if(this.commit(t,n,n?this.viewport.latestTurn:this.state.activeTurn,n),!this.state.followingTail&&t.position===null){let e=this.viewport.capturePosition();e!==null&&this.store.save(e)}this.refreshActiveTurn()}acceptNavigation(e){this.cancelPending();let t=this.follow.nearBottom(e.metrics);this.commit(e,t,e.turn??(t?this.viewport.latestTurn:this.state.activeTurn))}preservePosition(e){this.cancelPending(),this.commit(e,this.state.followingTail,this.state.activeTurn)}onScroll=e=>{let t=e.movedByReader||this.pendingMovedByReader;!t&&this.state.followingTail||t&&e.metrics.top>=e.metrics.floor?(this.followTail(),this.sampled?.({position:null,movedByReader:t,followingTail:!0})):(e.movedByReader&&(this.pendingMovedByReader=!0),this.sampleTimer??=window.setTimeout(this.flushSample,500))};onScrollEnd=()=>{this.flushSample()};onResize(){this.pending||(this.state.followingTail?this.followTail():this.refreshActiveTurn())}refreshActiveTurn(){this.pending||(this.state.followingTail?this.publish({...this.state,initialized:!0,activeTurn:this.viewport.latestTurn}):this.probeFrame===null&&(typeof requestAnimationFrame==`function`?this.probeFrame=requestAnimationFrame(this.probe):this.probe()))}commit(e,t,n,r=!0){t?this.store.save(null):e.position!==null&&this.store.save(e.position),this.publish({initialized:r,followingTail:t,activeTurn:n})}publish(e){this.follow.setFollowing(e.followingTail),(e.initialized!==this.state.initialized||e.followingTail!==this.state.followingTail||e.activeTurn!==this.state.activeTurn)&&(this.state=e,this.onChange(e))}cancelPending(){this.sampleTimer!==null&&window.clearTimeout(this.sampleTimer),this.probeFrame!==null&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(this.probeFrame),this.sampleTimer=null,this.probeFrame=null,this.pendingMovedByReader=!1}probe=()=>{if(this.probeFrame=null,this.pending)return;let e=this.viewport.readScroll();if(e===null)return;let t=this.follow.nearBottom(e.metrics)?this.viewport.latestTurn:this.viewport.readVisibleTurn(e.metrics);this.publish({...this.state,initialized:!0,activeTurn:t})};flushSample=()=>{if(!this.pending)return;let e=this.pendingMovedByReader;this.cancelPending();let t=this.viewport.readScroll();if(t===null)return;let n=e||t.movedByReader,r=this.follow.sample(t.metrics,n),i=null;if(!n&&r)this.followTail();else{i=r?null:this.viewport.capturePosition(),this.viewport.acknowledge(t.metrics),(r||i!==null)&&this.store.save(i);let e=this.follow.nearBottom(t.metrics)?this.viewport.latestTurn:this.viewport.readVisibleTurn(t.metrics);this.publish({initialized:!0,followingTail:r,activeTurn:e})}this.sampled?.({position:i,movedByReader:n,followingTail:r})}};function tv(e,t,n){let[r,i]=(0,d.useState)(()=>({initialized:!1,followingTail:t.read()===null,activeTurn:n})),a=Xg(r.followingTail,25),[o]=(0,d.useState)(()=>new ev(e,t,r,i,a));return(0,d.useLayoutEffect)(()=>{o.setStore(t)},[o,t]),(0,d.useLayoutEffect)(()=>()=>{o.dispose()},[o]),{reading:o,state:r}}let nv=[`wheel`,`touchstart`,`touchmove`,`touchend`,`touchcancel`,`pointerdown`,`keydown`,`beforematch`],rv=/* @__PURE__ */ new Set([`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `]);var iv=class{elements=null;observer=null;events=null;turns=[];observation={top:0,landing:null};paging=null;touchY=null;viewportWidth=null;attach(e,t){this.detach();let n=e.closest(`[data-conversation-scroll]`)??e,r=n.querySelector(`[data-composer-seat]`),i={list:e,column:t,scroller:n,composer:r};this.elements=i,this.syncViewportWidth(),n.addEventListener(`scroll`,this.onScroll,{passive:!0}),n.addEventListener(`scrollend`,this.onScrollEnd,{passive:!0,capture:!0});for(let e of nv)n.addEventListener(e,this.onIntent,{passive:!0,capture:!0});typeof ResizeObserver<`u`&&(this.observer=new ResizeObserver(()=>{this.elements===i&&(this.syncViewportWidth(),this.invalidate(),this.events?.resize())}),this.observer.observe(t),this.observer.observe(n),e!==n&&this.observer.observe(e),r!==null&&this.observer.observe(r))}detach(){this.stopPreserving(),this.elements?.list.style.removeProperty(`--dsh-chat-viewport-width`),this.elements?.scroller.removeEventListener(`scroll`,this.onScroll),this.elements?.scroller.removeEventListener(`scrollend`,this.onScrollEnd,!0);for(let e of nv)this.elements?.scroller.removeEventListener(e,this.onIntent,!0);this.observer?.disconnect(),this.observer=null,this.elements=null,this.events=null,this.turns=[],this.touchY=null,this.viewportWidth=null,this.observation={top:0,landing:null}}syncViewportWidth(){let e=this.elements?.list;if(e===void 0)return;let t=e.clientWidth;t>0&&t!==this.viewportWidth&&(this.viewportWidth=t,e.style.setProperty(`--dsh-chat-viewport-width`,`${t}px`))}connect(e){return this.events=e,()=>{this.events===e&&(this.events=null)}}updateTurns(e){this.turns=e}get latestTurn(){return this.turns.at(-1)?.turn??null}invalidate(){this.observation.landing=null}acknowledge(e){this.observation={top:e.top,landing:null}}shiftObservation(e){Number.isFinite(e)&&e!==0&&(this.observation={top:Math.max(0,this.observation.top+e),landing:null},this.paging!==null&&(this.paging={...this.paging,position:{...this.paging.position,scrollTop:Math.max(0,this.paging.position.scrollTop+e)}}))}readScroll(){let e=this.metrics();return e===null?null:{metrics:e,movedByReader:Math.abs(e.top-Math.min(this.observation.top,e.floor))>.5,towardStart:e.top<Math.min(this.observation.top,e.floor)-.5}}metrics(){let e=this.elements?.scroller;return e===void 0?null:Jg(e)}anchor(e,t=`position`){if(this.elements===null)return null;let n=null;for(let r of this.elements.list.querySelectorAll(`[data-chat-anchor-key]:not([hidden]):not([hidden] *)`)){if(r.dataset.chatAnchorKey===e||t===`node`&&r.dataset.chatNodeKey===e)return r;n===null&&r.dataset.chatNodeKey===e&&(n=r)}return n}capturePosition(){let e=this.elements;if(e===null)return null;let{list:t,scroller:n,composer:r}=e,i=n.getBoundingClientRect(),a=r?.getBoundingClientRect().top??i.bottom,o=null;if(typeof document.elementsFromPoint==`function`&&a>i.top){let e=t.getBoundingClientRect(),n=Math.max(i.left,e.left),r=Math.min(i.right,e.right);for(let e of document.elementsFromPoint(n+Math.max(0,r-n)/2,i.top+1)){let n=e instanceof HTMLElement?e.closest(`[data-chat-anchor-key]`):null;if(n!==null&&n.dataset.chatFlowKind!==`turn-process`&&t.contains(n)){o=n.dataset.chatGroupKey===void 0?n:n.querySelector(`[data-step-process-content] > [data-chat-anchor-key]:not(:empty:not([data-chat-virtualized])):not([hidden]):not([hidden] *)`)??n;break}}}if(o===null){let e=t.querySelectorAll(`[data-chat-flow-key]:not([data-chat-group-key]):not([data-chat-flow-kind="turn-process"]):not(:empty:not([data-chat-virtualized])):not([hidden]):not([hidden] *)`),n=0,r=e.length;for(;n<r;){let t=n+r>>>1;e.item(t).getBoundingClientRect().bottom>i.top?r=t:n=t+1}let s=e[n];o=s!==void 0&&s.getBoundingClientRect().top<a?s:e[0]??null}let s=o?.dataset.chatAnchorKey;return o===null||s===void 0?null:{anchorKey:s,anchorTop:o.getBoundingClientRect().top-i.top,scrollTop:n.scrollTop}}readVisibleTurn(e=this.metrics()){let t=this.observation.landing?.turn;if(t!=null&&e?.top===this.observation.top)return t;let n=this.elements,r=this.turns[0];if(n===null||e===null||r===void 0)return null;let i=n.scroller.getBoundingClientRect().top+Math.min(96,e.height*.2),a=n.column.children,o=0,s=a.length,c=r.turn;for(;o<s;){let e=o+s>>>1,t=a[e];if(t.getBoundingClientRect().top>i)s=e;else{let n=t.getAttribute(`data-chat-turn`),r=n===null?NaN:Number(n);Number.isSafeInteger(r)&&(c=r),o=e+1}}return c}scrollToTurn(e){let t=this.turns.find(t=>t.turn===e);if(t===void 0)return null;let n=this.anchor(t.anchorKey,`node`);return n===null?null:this.align(n,24,e)}scrollToTurnAtOrAfter(e){if(this.elements===null)return null;for(let t of this.elements.list.querySelectorAll(`[data-chat-turn]:not([hidden]):not([hidden] *)`)){let n=Number(t.dataset.chatTurn);if(Number.isSafeInteger(n)&&n>=e)return this.align(t,24,n)}return null}scrollToResponseAnnotation(e){let t=this.elements,n=e.anchor;if(t===null||n===void 0)return null;let r=Mh(t.column,n,e.text);if(r===void 0)return null;let i=Array.from(r.range.getClientRects()).find(e=>e.width!==0||e.height!==0)??(()=>{let e=r.range.getBoundingClientRect();return e.width===0&&e.height===0?void 0:e})(),a=this.metrics();if(i===void 0||a===null)return null;let o=t.scroller.getBoundingClientRect().top,s=r.host.closest(`[data-chat-anchor-key]`),c=r.host.closest(`[data-chat-turn]`)?.getAttribute(`data-chat-turn`),l=c==null?NaN:Number(c),u=Number.isSafeInteger(l)?l:null,d=a.top+i.top-o-a.height*.3;return s===null?this.write(d,a,u):this.write(d,a,u,{key:s.getAttribute(`data-chat-anchor-key`)??void 0,top:s.getBoundingClientRect().top-o})}restore(e){let t=this.anchor(e.anchorKey);if(t!==null)return this.align(t,e.anchorTop,null);let n=this.metrics();return n===null?null:this.write(e.scrollTop,n,null)}beginPaging(){this.stopPreserving();let e=this.elements?.list.querySelector(`[data-chat-paging-anchor]:not(:empty:not([data-chat-virtualized])):not([hidden]):not([hidden] *)`);e!=null&&this.retain(e)}beginPreserving(e=this.capturePosition()){if(this.stopPreserving(),e===null)return;let t=this.anchor(e.anchorKey);t!==null&&this.retain(t,e)}retain(e,t,n){let r=this.elements,i=e.dataset.chatAnchorKey;if(r===null||i===void 0)return null;let a=this.paging?.group;a!=null&&this.observer?.unobserve(a.content);let o=e.getBoundingClientRect().top,s=e.closest(`[data-step-process-body]`),c=s?.querySelector(`[data-step-process-content]`),l=s===null||c==null?null:{body:s,content:c,top:n??o-s.getBoundingClientRect().top};return this.paging={row:e,group:l,position:t??{anchorKey:i,anchorTop:o-r.scroller.getBoundingClientRect().top,scrollTop:r.scroller.scrollTop}},l!==null&&this.observer?.observe(l.content),this.paging}stopPreserving(){let e=this.paging?.group;e!=null&&this.observer?.unobserve(e.content),this.paging=null}get preserving(){return this.paging!==null}refreshPagingPosition(e){let t=this.paging,n=this.elements;if(t===null||n===null||!n.list.contains(t.row))return;let r=t.row.getBoundingClientRect().top-n.scroller.getBoundingClientRect().top;this.paging={...t,position:{...t.position,anchorTop:r,scrollTop:e.top}}}isPagingDisplaced(e){let t=this.paging,n=this.elements;if(t===null||n===null||!n.list.contains(t.row)||!(Math.abs(e.top-Math.min(t.position.scrollTop,e.floor))>.5))return!1;let r=t.row.getBoundingClientRect().top-n.scroller.getBoundingClientRect().top;return Math.abs(r-t.position.anchorTop)>.5}preserve(e=!1){let t=this.paging,n=this.elements;if(t===null||n===null)return null;if(!n.list.contains(t.row)){let e=this.anchor(t.position.anchorKey);if(e===null)return this.stopPreserving(),null;if(t=this.retain(e,t.position,t.group?.top),t===null)return null}let{row:r,group:i,position:a}=t;if(r.closest(`[hidden]`)!==null||r.matches(`:empty:not([data-chat-virtualized])`))return this.stopPreserving(),null;let o=this.metrics();if(o===null)return null;let s=this.isPagingDisplaced(o),c=null;if(s){let t=r.getBoundingClientRect().top-n.scroller.getBoundingClientRect().top,i=o.top+t-(a.scrollTop+a.anchorTop);if(!e||i<=.5)return this.stopPreserving(),null;c=i}if(i!==null&&i.body.contains(r)){let e=r.getBoundingClientRect().top-i.body.getBoundingClientRect().top,t=Jg(i.body),n=Math.max(0,Math.min(t.floor,t.top+e-i.top));if(t.top!==n){let e=Yg.forElement(i.body);e===void 0?i.body.scrollTop=n:(e.jump(i.body,t,n),e.setFollowing(!1))}}let l=this.metrics();if(l===null)return null;let u=r.getBoundingClientRect().top-n.scroller.getBoundingClientRect().top,d=c===null?l.top+u-a.anchorTop:l.top+c,f=this.write(d,l,null,{key:a.anchorKey,top:u});return f!==null&&this.paging===t&&(this.paging={...t,position:{...a,anchorTop:f.position?.anchorTop??a.anchorTop,scrollTop:f.metrics.top}}),f}scrollToBottom(e){let t=this.metrics();if(t===null||this.elements===null)return null;let n={metrics:t.top>t.floor?t:e.toBottom(this.elements.scroller,t,`instant`),position:null,turn:this.latestTurn};return this.observation={top:n.metrics.top,landing:n},n}align(e,t,n){let r=this.metrics();if(r===null||this.elements===null)return null;let i=e.getBoundingClientRect().top-this.elements.scroller.getBoundingClientRect().top;return this.write(r.top+i-t,r,n,{key:e.dataset.chatAnchorKey,top:i})}write(e,t,n,r){if(this.elements===null)return null;let i=Math.max(0,Math.min(t.floor,e));i!==t.top&&(this.elements.scroller.scrollTop=i);let a=this.elements.scroller.scrollTop,o={metrics:{...t,top:a},turn:n,position:r?.key===void 0?null:{anchorKey:r.key,anchorTop:r.top-(a-t.top),scrollTop:a}};return this.observation={top:a,landing:o},o}onScroll=e=>{if(this.elements===null||e.target!==this.elements.scroller||this.observation.landing!==null&&this.elements.scroller.scrollTop===this.observation.top)return;this.invalidate();let t=this.readScroll();t!==null&&(this.paging!==null&&this.isPagingDisplaced(t.metrics)&&(t.towardStart||t.metrics.top<=.5?this.refreshPagingPosition(t.metrics):this.stopPreserving()),this.events?.scroll(t))};onScrollEnd=e=>{(e.target===this.elements?.scroller||e.target instanceof HTMLElement&&e.target.hasAttribute(`data-step-process-body`))&&this.events?.scrollEnd()};onIntent=e=>{if(e.type===`touchend`||e.type===`touchcancel`){this.touchY=null;return}let t=e instanceof WheelEvent;if(e.target instanceof Element&&(e.target.closest(`[data-turn-navigation]`)||!t&&e.target.closest(`[data-composer-seat], input, textarea, [contenteditable="true"]`))||t&&e.deltaY===0||e.type===`keydown`&&(!(e instanceof KeyboardEvent)||!rv.has(e.key)))return;let n=t?e.deltaY<0:e instanceof KeyboardEvent&&([`ArrowUp`,`PageUp`,`Home`].includes(e.key)||e.key===` `&&e.shiftKey);if(typeof TouchEvent<`u`&&e instanceof TouchEvent){let t=e.touches[0]?.clientY;if(e.type===`touchstart`||t===void 0||this.touchY===null){this.touchY=t??null;return}let r=t-this.touchY;if(Math.abs(r)<2)return;this.touchY=t,n=r>0}if(!(e instanceof PointerEvent&&e.pointerType===`touch`)){if(e.target instanceof Element){for(let r=e.target;r&&r!==this.elements?.scroller;r=r.parentElement)if(r instanceof HTMLElement&&r.scrollHeight>r.clientHeight&&/auto|scroll/.test(getComputedStyle(r).overflowY)){if(t){let t=e.deltaY<0&&r.scrollTop>0,n=e.deltaY>0&&r.scrollTop+r.clientHeight<r.scrollHeight-1;if(t||n)return}else if(n&&r.scrollTop>0){n=!1;break}}}this.paging!==null&&!n&&(this.stopPreserving(),this.events?.interact()),n&&this.events?.olderIntent()}}};function av(){let e=(0,d.useRef)(null),t=(0,d.useRef)(null),[n]=(0,d.useState)(()=>new iv);return(0,d.useLayoutEffect)(()=>{if(e.current!==null&&t.current!==null)return n.attach(e.current,t.current),()=>{n.detach()}},[n]),{viewport:n,listRef:e,columnRef:t}}function ov(e){let{displayReady:t,historyReady:n,order:r,firstSeq:i,lastKey:a,lastIsUser:o,steeringId:s,submissionId:c,running:l,loadedTurns:u,chatScroll:f,hasMore:p,loadingOlder:m,olderFailed:h,loadOlder:g,loadThrough:_}=e,{viewport:v,listRef:y,columnRef:b}=av(),{reading:x,state:S}=tv(v,f,u.at(-1)?.turn??null),C=(0,d.useMemo)(()=>({historyReady:n,firstSeq:i,loadingOlder:m,olderFailed:h,hasMore:p,loadOlder:g,loadThrough:_}),[n,i,m,h,p,g,_]),{navigation:w,busyTurn:T}=$_(v,x,C),E=(0,d.useRef)({input:e,applied:null,opened:!1}),D=(0,d.useCallback)(()=>{let e=E.current.input,t=E.current.applied,n=e.lastIsUser&&e.lastKey!==t?.lastKey||e.steeringId!==null&&e.steeringId!==t?.steeringId&&e.steeringId!==t?.submissionId||e.submissionId!==null&&e.submissionId!==t?.submissionId&&e.submissionId!==t?.steeringId,r=t!==null&&e.firstSeq!==null&&t.firstSeq!==null&&e.firstSeq<t.firstSeq;(!x.pending||n||r)&&(E.current.applied=e,e.displayReady&&!E.current.opened?(E.current.opened=!0,w.reset(),x.restore()):n?(w.cancel(),x.followTail()):w.contentCommitted(r)?w.reconcile():(t===null||e.displayReady!==t.displayReady||e.firstSeq!==t.firstSeq||e.lastKey!==t.lastKey||e.order.length!==t.order.length||e.running!==t.running||e.steeringId!==t.steeringId||e.submissionId!==t.submissionId)&&x.followingTail?(w.cancel(),x.followTail()):w.reconcile())},[x,w]);(0,d.useLayoutEffect)(()=>{let e=null,t=()=>{e===null&&E.current.opened&&E.current.input.historyReady&&(e=requestAnimationFrame(()=>{e=null,E.current.opened&&E.current.input.historyReady&&w.autoLoadEarlier()}))},n=v.connect({scroll:e=>{x.onScroll(e),e.movedByReader&&e.towardStart&&t()},olderIntent:t,scrollEnd:()=>{x.onScrollEnd(),w.readerSettled()},interact:()=>{w.cancel()},resize:()=>{w.contentCommitted()||x.onResize(),w.reconcile()}}),r=x.connect(e=>{w.readerSampled(e),D()});return()=>{e!==null&&cancelAnimationFrame(e),n(),r(),E.current.opened=!1,E.current.applied=null}},[v,x,w,D]),(0,d.useLayoutEffect)(()=>{let e=E.current.input;E.current.input={displayReady:t,order:r,lastKey:a,lastIsUser:o,steeringId:s,submissionId:c,running:l,loadedTurns:u,chatScroll:f,...C},v.updateTurns(u);let n=e.order!==r||e.displayReady!==t;n&&v.invalidate(),D(),n&&x.refreshActiveTurn()},[v,x,D,C,t,r,a,o,s,c,l,u,f]);let O=(0,d.useCallback)(()=>{w.cancel(),x.followTail()},[w,x]),k=(0,d.useCallback)(()=>{x.followingTail&&!x.pending&&x.followTail()},[x]),A=(0,d.useCallback)(e=>{v.shiftObservation(e)},[v]),ee=(0,d.useCallback)(e=>{w.cancel();let t=v.scrollToResponseAnnotation(e);t!==null&&(x.acceptNavigation(t),E.current.input.loadingOlder&&v.beginPreserving(t.position))},[w,x,v]);return{listRef:y,columnRef:b,...S,busyTurn:T,navigateToTurn:w.navigateToTurn,revealResponseAnnotation:ee,loadEarlier:w.loadEarlier,returnToBottom:O,reconcileTail:k,adjustBaseline:A}}let sv=`1200px 0px`,cv=/* @__PURE__ */ new Set;function lv(e){return!Number.isFinite(e)||e<=0?sv:`${Math.max(320,Math.ceil(e*1.5/160)*160)}px 0px`}function uv(e,t,n=160,r=10,i){if(i===void 0||i.length!==e){if(e<=n)return null;let i=Math.min(Math.max(0,r),e),a=e-i,o=Math.max(0,n-i);if(o===0||a<=0)return{start:a,end:e-1};let s=Math.max(0,Math.min(a-1,Math.trunc(t))),c=Math.floor(o/2),l=Math.max(0,s-c),u=l+o-1;return u>=a&&(u=a-1,l=Math.max(0,u-o+1)),{start:l,end:u}}let a=0;for(let t=0;t<e;t+=1)a+=Math.max(1,i[t]??1);if(a<=n)return null;let o=e-Math.min(Math.max(0,r),e);if(o<=0)return{start:0,end:e-1};let s=0;for(let t=o;t<e;t+=1)s+=Math.max(1,i[t]??1);let c=Math.max(1,n-s),l=Math.max(0,Math.min(o-1,Math.trunc(t))),u=l,d=l,f=Math.max(1,i[l]??1);for(;u>0||d<o-1;){let e=!1;if(u>0){let t=Math.max(1,i[u-1]??1);f+t<=c&&(--u,f+=t,e=!0)}if(d<o-1){let t=Math.max(1,i[d+1]??1);f+t<=c&&(d+=1,f+=t,e=!0)}if(!e)break}return{start:u,end:d}}function dv(e,t){if(e.kind!==`group`||t===void 0)return 1;let n=t.groupSource(e.key).getSnapshot()?.members.length??0;return Math.max(1,n)}function fv(e,t,n=10,r=20,i=2){let a=e.length;if(a<=0)return 0;let o=Math.min(a,Math.max(0,n));if(o<=0)return a;let s=Math.min(o,Math.max(0,i)),c=a,l=0,u=0;for(let n=a-1;n>=a-o;--n){let i=dv(e[n],t);if(l>=s&&u+i>r)break;c=n,l+=1,u+=i}return c}function pv(e,t,n,r,i=24){let a=e.length;if(a===0)return null;let o=Math.max(1,i);if(t!==null&&t>=0&&t<a){let n=t,i=t,s=dv(e[t],r);for(;n>0||i<a-1;){let t=!1;if(i<a-1){let n=dv(e[i+1],r);s+n<=o&&(i+=1,s+=n,t=!0)}if(n>0){let i=dv(e[n-1],r);s+i<=o&&(--n,s+=i,t=!0)}if(!t)break}return{start:n,end:i}}if(n){let t=a-1,n=dv(e[t],r);for(;t>0;){let i=dv(e[t-1],r);if(a-t>=2&&n+i>o)break;--t,n+=i}return{start:t,end:a-1}}let s=0,c=dv(e[0],r);for(;s<a-1;){let t=dv(e[s+1],r);if(s+1>=2&&c+t>o)break;s+=1,c+=t}return{start:0,end:s}}function mv(e,t){if(e.length>48)return!0;if(e.length<=10||t===void 0)return!1;let n=0;for(let r of e)if(n+=dv(r,t),n>48)return!0;return!1}function hv(e){return e.kind===`group`||e.groupPart===void 0||e.groupPart===`response`?e.key:JSON.stringify([e.key,e.groupPart])}function gv(e){try{let t=JSON.parse(e);if(!Array.isArray(t)||typeof t[0]!=`string`)return null;let[n,r]=t;return r==null||r===`response`?n:JSON.stringify([n,String(r)])}catch{return null}}function _v(e,t,n){let r=gv(e);if(r===null)return null;for(let e of t){if(hv(e)===r)return r;if(e.kind===`node`&&e.key===r)return hv(e)}if(n!==void 0)for(let e of t){if(e.kind!==`group`)continue;let t=n.groupSource(e.key).getSnapshot()?.members;if(t!==void 0&&t.some(e=>hv(e)===r||e.key===r))return e.key}return r}function vv(e){return e.startsWith(`group:`)?e.slice(6):e}function yv(e,t,n,r){if(e==null||e===``)return null;let i=vv(e),a=n.get(i);if(a!==void 0)return a;for(let e=0;e<t.length;e+=1){let n=t[e];if(n.kind===`node`&&n.key===i)return e}if(r!==void 0)for(let e=0;e<t.length;e+=1){let n=t[e];if(n.kind!==`group`)continue;let a=r.groupSource(n.key).getSnapshot()?.members;if(a!==void 0&&a.some(e=>hv(e)===i||e.key===i))return e}return null}function bv(e){return(e.metaKey||e.ctrlKey)&&!e.altKey&&e.key.toLowerCase()===`f`}function xv(e){if(typeof e!=`object`||!e)return!1;let t=e,n=typeof t.tagName==`string`?t.tagName.toUpperCase():``;if(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t.isContentEditable===!0)return!0;if(typeof t.getAttribute==`function`){let e=t.getAttribute(`contenteditable`);if(e===``||e===`true`)return!0}return typeof t.closest==`function`&&t.closest(`[contenteditable=''], [contenteditable='true']`)!==null}function Sv(e){return!!(bv(e)||(e.metaKey||e.ctrlKey)&&!e.altKey&&e.key.toLowerCase()===`g`||e.key===`F3`||e.key===`Enter`&&!xv(e.target))}function Cv(e){let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn.turn:void 0}function wv(e){if(e.childNodes.length===0)return!0;if(e.childElementCount===1){let t=e.firstElementChild;if(t?.hasAttribute(`data-slot`)&&t.childNodes.length===0)return!0}return!1}function Tv(e){let t=e.getBoundingClientRect().height;return t>0?t:e.offsetHeight}function Ev(e){return Math.round(e*100)/100}function Dv(e,t,n,r){if(n.hasAttribute(`hidden`)||n.hasAttribute(`data-chat-virtualized`))return;let i=r!==void 0&&r>0?r:Tv(n);i>0?e.set(t,Ev(i)):wv(n)&&e.set(t,0)}function Ov(e,t){if(e===null)return null;let n=e instanceof Element?e:e.parentElement;if(n===null||!t.contains(n))return null;for(;n!==null&&n.parentElement!==t;)n=n.parentElement;return n===null||n.parentElement!==t?null:n.getAttribute(`data-chat-flow-key`)}function kv(e,t,n,r){let i=e.childNodes.length;for(let a=t;a>=0&&a<i;a+=n){let t=e.childNodes[a];if(t instanceof Element){let e=t.getAttribute(`data-chat-flow-key`);if(e!==null){let t=r.get(e);if(t!==void 0)return t}}}return null}function Av(e,t,n,r,i){let a=r.childNodes.length;if(a===0)return null;let o=n===`end`?-1:1;if(e===r)return n===`end`&&t<=0||n===`start`&&t>=a?null:kv(r,n===`end`?Math.min(t-1,a-1):Math.max(0,t),o,i);let s=e;for(;s!==null&&s.parentNode!==r;)s=s.parentNode;if(s===null||s.parentNode!==r)return null;if(s instanceof Element){let e=s.getAttribute(`data-chat-flow-key`);if(e!==null)return i.get(e)??null}for(let e=0;e<a;e+=1)if(r.childNodes[e]===s)return kv(r,e+o,o,i);return null}function jv(e,t,n,r){if(e===null||e.rangeCount===0||e.isCollapsed||n.length===0)return null;let i=t.ownerDocument.createRange();t.parentNode===null?i.selectNodeContents(t):i.selectNode(t);let a=1/0,o=-1;for(let s=0;s<e.rangeCount;s+=1){let c=e.getRangeAt(s);if(c.collapsed)continue;let l,u;try{l=c.compareBoundaryPoints(c.END_TO_START,i)<0,u=c.compareBoundaryPoints(c.START_TO_END,i)>0}catch{continue}if(!l||!u)continue;let d=t.contains(c.startContainer),f=t.contains(c.endContainer),p;p=d?Av(c.startContainer,c.startOffset,`start`,t,r):c.compareBoundaryPoints(c.START_TO_START,i)<=0?0:null;let m;m=f?Av(c.endContainer,c.endOffset,`end`,t,r):c.compareBoundaryPoints(c.END_TO_END,i)>=0?n.length-1:null,!(p===null||m===null||p>m)&&(a=Math.min(a,p),o=Math.max(o,m))}if(o<0||!Number.isFinite(a))return null;let s=n[a],c=n[o];return s===void 0||c===void 0?null:{startKey:s,endKey:c}}function Mv(e,t){return e===t?!0:e===null||t===null?!1:e.startKey===t.startKey&&e.endKey===t.endKey}function Nv(e,t){return e===t?!0:e===null||t===null?!1:e.turn===t.turn&&e.anchorKey===t.anchorKey}function Pv(e,t){if(e.size!==t.size)return!0;for(let n of e)if(!t.has(n))return!0;return!1}function Fv({sessionId:e,entries:t,nodeStore:n,groupedView:r,listRef:i,columnRef:a,followingTail:o,editingFlowKey:s=null,composingFlowKey:c=null,revealTargetFlowKey:l=null,savedAnchorFlowKey:u=null,busyTurn:f=null,findLeaseTimeoutMs:p=15e3,findLeaseMaxDurationMs:m=6e4,findLeaseMaxMountedRows:h=160,overscanMargin:g,onTailScrollClamp:_,onScrollCompensated:v}){let y=typeof IntersectionObserver<`u`&&mv(t,r),b=(0,d.useRef)(e),x=(0,d.useRef)(/* @__PURE__ */ new Map),S=(0,d.useRef)(/* @__PURE__ */ new Map),C=(0,d.useRef)(/* @__PURE__ */ new Set),w=(0,d.useRef)(cv),T=(0,d.useRef)(null),E=(0,d.useRef)(!1),D=(0,d.useRef)(null),O=(0,d.useRef)(/* @__PURE__ */ new Set),k=(0,d.useRef)(null),A=(0,d.useRef)(null),ee=(0,d.useRef)(null),j=(0,d.useRef)(null),te=(0,d.useRef)(null),ne=(0,d.useRef)(0),re=(0,d.useRef)(_);re.current=_;let ie=(0,d.useRef)(v);ie.current=v,b.current!==e&&(b.current=e,x.current.clear(),C.current=/* @__PURE__ */ new Set,w.current=cv,E.current=!1,A.current=null,ee.current=null,j.current=null,te.current=null);let[ae,oe]=(0,d.useState)(()=>({sessionId:e,keys:/* @__PURE__ */ new Set})),[se,ce]=(0,d.useState)(()=>({sessionId:e,settled:!1})),[le,ue]=(0,d.useState)(sv),[M,de]=(0,d.useState)(()=>({sessionId:e,range:null})),[fe,pe]=(0,d.useState)(()=>({sessionId:e,flowKey:null})),[me,he]=(0,d.useState)(()=>({sessionId:e,target:null})),[ge,_e]=(0,d.useState)(()=>({sessionId:e,active:!1})),ve=ae.sessionId===e?ae.keys:C.current,ye=y&&se.sessionId===e&&se.settled,be=g??le,xe=M.sessionId===e?M.range:null,Se=fe.sessionId===e?fe.flowKey:null,N=me.sessionId===e?me.target:null,Ce=y&&ge.sessionId===e&&ge.active,{flowKeys:we,flowKeyToIndex:P}=(0,d.useMemo)(()=>{let e=Array(t.length),n=/* @__PURE__ */ new Map;for(let r=0;r<t.length;r+=1){let i=hv(t[r]);e[r]=i,n.set(i,r)}return{flowKeys:e,flowKeyToIndex:n}},[t]),Te=(0,d.useRef)(we),Ee=(0,d.useRef)(P);Te.current=we,Ee.current=P;let De=(0,d.useCallback)(()=>{let e=x.current,t=S.current;for(let n of w.current){let r=t.get(n);r!==void 0&&Dv(e,n,r)}},[]),Oe=(0,d.useCallback)(()=>{k.current!==null&&(clearTimeout(k.current),k.current=null)},[]),ke=(0,d.useCallback)(()=>{Oe(),A.current=null,De(),_e(t=>t.sessionId===e&&!t.active?t:{sessionId:e,active:!1})},[Oe,De,e]),Ae=(0,d.useCallback)(t=>{Oe(),k.current=setTimeout(()=>{k.current=null,A.current=null,De(),_e(t=>t.sessionId===e&&!t.active?t:{sessionId:e,active:!1})},t)},[Oe,De,e]),je=(0,d.useCallback)(()=>{A.current=Date.now(),_e(t=>t.sessionId===e&&t.active?t:{sessionId:e,active:!0}),Ae(Math.min(p,m))},[m,p,Ae,e]),Me=(0,d.useCallback)(()=>{let e=A.current??Date.now();A.current=e;let t=m-(Date.now()-e);t<=0?ke():Ae(Math.min(p,t))},[m,p,ke,Ae]);(0,d.useEffect)(()=>{if(!y)Oe(),A.current=null,E.current=!1,_e(t=>t.sessionId===e&&!t.active?t:{sessionId:e,active:!1}),ce(t=>t.sessionId===e&&!t.settled?t:{sessionId:e,settled:!1});else return()=>{Oe()}},[Oe,y,e]),(0,d.useLayoutEffect)(()=>{if(!y||g!==void 0)return;let e=i.current,t=e?.closest(`[data-conversation-scroll]`)??e??null;if(t===null)return;let n=e=>{let t=lv(e);ue(e=>e===t?e:t)};if(n(t.clientHeight),typeof ResizeObserver>`u`)return;let r=new ResizeObserver(e=>{let r=e.at(-1)?.contentRect.height??t.clientHeight;n(r>0?r:t.clientHeight)});return r.observe(t),()=>{r.disconnect()}},[y,i,g,e]),(0,d.useLayoutEffect)(()=>{if(!y)return;let e=i.current,t=e?.closest(`[data-conversation-scroll]`)??e??null;if(t===null)return;let n=()=>{ne.current+=1};return t.addEventListener(`scroll`,n,{passive:!0}),()=>{t.removeEventListener(`scroll`,n)}},[y,i,e]),(0,d.useLayoutEffect)(()=>{if(!y){T.current=null,E.current=!1;return}let t=i.current,n=t?.closest(`[data-conversation-scroll]`)??t??null,r=new IntersectionObserver(t=>{if(T.current!==r)return;let n=!1,i=new Set(C.current);for(let e of t){let t=e.target;if(!(t instanceof HTMLElement))continue;let r=t.dataset.chatFlowKey;if(r!==void 0){if(e.isIntersecting)i.has(r)||(i.add(r),n=!0);else{if(w.current.has(r)&&!x.current.has(r)){let n=e.boundingClientRect?.height;Dv(x.current,r,t,n)}i.has(r)&&(i.delete(r),n=!0)}}}E.current||(E.current=!0,ce(t=>t.sessionId===e&&t.settled?t:{sessionId:e,settled:!0})),n&&(C.current=i,oe({sessionId:e,keys:i}))},{root:n,rootMargin:be});T.current=r;for(let e of S.current.values())r.observe(e);return()=>{r.disconnect(),T.current===r&&(T.current=null)}},[be,y,i,e]),(0,d.useEffect)(()=>{if(!y||typeof document>`u`)return;let t=()=>{let t=a.current,n=t===null?null:jv(document.getSelection(),t,Te.current,Ee.current);de(t=>{let r=t.sessionId===e?t.range:null;return Mv(r,n)?t:(r!==null&&De(),{sessionId:e,range:n})})};return t(),document.addEventListener(`selectionchange`,t),()=>{document.removeEventListener(`selectionchange`,t)}},[a,y,De,e]),(0,d.useEffect)(()=>{if(!y||typeof document>`u`)return;let t=a.current;if(t===null)return;let n=t=>{pe(n=>{let r=n.sessionId===e?n.flowKey:null;return r===t?n:(r!==null&&De(),{sessionId:e,flowKey:t})})},r=()=>{n(Ov(document.activeElement,t))},i=e=>{let r=e.target instanceof Node?e.target:document.activeElement;n(Ov(r,t))},o=e=>{e.relatedTarget instanceof Node?n(Ov(e.relatedTarget,t)):queueMicrotask(()=>{t.isConnected&&r()})};return r(),t.addEventListener(`focusin`,i),t.addEventListener(`focusout`,o),()=>{t.removeEventListener(`focusin`,i),t.removeEventListener(`focusout`,o)}},[a,y,De,e]);let Ne=(0,d.useRef)(Ce);Ne.current=Ce,(0,d.useEffect)(()=>{if(!y||typeof window>`u`)return;let e=i.current,t=e?.closest(`[data-conversation-scroll]`)??e??null,n=e=>{bv(e)?je():Ne.current&&(e.key===`Escape`?ke():Sv(e)&&Me())},r=()=>{Ne.current&&Me()},a=e=>{Ne.current&&xv(e.target)&&ke()},o=()=>{Ne.current&&Me()},s=()=>{if(!Ne.current)return;let e=document.getSelection();e!==null&&e.rangeCount>0&&!e.isCollapsed&&Me()};return window.addEventListener(`keydown`,n,!0),document.addEventListener(`beforematch`,r,!0),document.addEventListener(`focusin`,a,!0),document.addEventListener(`selectionchange`,s),t?.addEventListener(`scroll`,o,{passive:!0}),()=>{window.removeEventListener(`keydown`,n,!0),document.removeEventListener(`beforematch`,r,!0),document.removeEventListener(`focusin`,a,!0),document.removeEventListener(`selectionchange`,s),t?.removeEventListener(`scroll`,o)}},[je,y,i,ke,Me,e]);let Pe=(0,d.useMemo)(()=>{let e=/* @__PURE__ */ new Set,i=(n,r)=>{let i=Math.min(t.length-1,n+r);for(let t=n;t<=i;t+=1){let n=we[t];n!==void 0&&e.add(n)}},a=(e,n=0)=>{let a=yv(e,t,P,r);a!==null&&i(a,n)},o=e=>{if(e!=null)for(let r=0;r<t.length;r+=1){let a=t[r];if(a.kind===`node`&&Cv(n.get(a.key))===e){i(r,2);return}}};return s!==null&&e.add(s),c!==null&&a(c,0),Se!==null&&e.add(Se),l!==null&&a(l,0),u!==null&&a(u,2),f!==null&&o(f),N!==null&&(N.anchorKey===null?N.turn!==null&&o(N.turn):a(N.anchorKey,2)),e},[f,c,s,t,P,we,Se,r,N,n,l,u]),Fe=(0,d.useMemo)(()=>{if(xe===null)return null;let e=P.get(xe.startKey),t=P.get(xe.endKey);return e===void 0||t===void 0?null:e<=t?{start:e,end:t}:{start:t,end:e}},[P,xe]),Ie=(0,d.useMemo)(()=>fv(t,r),[t,r]),F=Math.max(0,t.length-Ie),Le=(0,d.useMemo)(()=>{if(!Ce)return null;let e=r===void 0?void 0:t.map(e=>dv(e,r));if(e===void 0&&t.length<=h)return null;let n=null;if(ve.size>0){let e=1/0,t=-1;for(let n of ve){let r=P.get(n);r!==void 0&&(r<e&&(e=r),r>t&&(t=r))}t>=0&&Number.isFinite(e)&&(n=Math.floor((e+t)/2))}if(n===null){let e=Se??(N?.anchorKey==null?null:vv(N.anchorKey));n=e===null?t.length-1:P.get(e)??t.length-1}return uv(t.length,n,h,F,e)},[F,t,Ce,h,P,Se,r,N?.anchorKey,ve]);ye?te.current=null:u!=null&&(te.current=u);let Re=u??te.current,ze=y&&!(Ce&&Le===null),Be=(0,d.useMemo)(()=>{if(!ze||ye)return null;let e=e=>yv(e,t,P,r),a=e=>{if(e==null)return null;for(let r=0;r<t.length;r+=1){let i=t[r];if(i.kind===`node`&&Cv(n.get(i.key))===e)return r}return null};return pv(t,e(Re)??e(l)??e(s)??e(c)??(N===null?null:e(N.anchorKey)??a(N.turn))??a(f),o??(i.current!==null&&i.current.closest(`[data-chat-following-tail]`)!==null),r)},[f,c,s,Re,t,P,o,r,ye,i,N,n,l,ze]),Ve=ze&&ye?ve:null,He=ze?Pe:null,Ue=ze?Fe:null,We=ze?Le:null,Ge=ze?Ie:0,Ke=(0,d.useCallback)((e,t)=>!!(!ze||e>=Ge||Be!==null&&e>=Be.start&&e<=Be.end||We!==null&&e>=We.start&&e<=We.end||Ve!==null&&Ve.has(t)||He!==null&&He.has(t)||Ue!==null&&e>=Ue.start&&e<=Ue.end),[We,He,Ue,Ge,Ve,Be,ze]),qe=(0,d.useMemo)(()=>{if(!y)return cv;let e=/* @__PURE__ */ new Set;for(let n=0;n<t.length;n+=1){let t=we[n];Ke(n,t)&&e.add(t)}return e},[y,t.length,we,Ke]);if(ee.current=null,j.current=null,y&&w.current.size>0){let e=w.current,t=i.current,n=t?.closest(`[data-conversation-scroll]`)??t??null;if(n!==null&&n.isConnected){let r=Math.max(0,n.scrollHeight-n.clientHeight),i=n.scrollTop,a=t?.closest(`[data-chat-following-tail]`)!==null;if(r<=0||r-i<=24)a&&r>0&&Pv(e,qe)&&(j.current=n);else{let t=n.getBoundingClientRect().top,r=S.current,a=!1;for(let n of qe){if(e.has(n))continue;let i=r.get(n);if(i!==void 0&&i.isConnected&&!i.hasAttribute(`hidden`)&&i.getBoundingClientRect().top<t){a=!0;break}}if(!a)for(let n of e){if(qe.has(n))continue;let e=r.get(n);if(e!==void 0&&e.isConnected&&!e.hasAttribute(`hidden`)&&e.getBoundingClientRect().top<t){a=!0;break}}if(a){let a=null,o=1/0,s=null,c=1/0;for(let n of e){if(!qe.has(n))continue;let e=r.get(n);if(e===void 0||!e.isConnected||e.hasAttribute(`hidden`))continue;let i=e.getBoundingClientRect();i.bottom<=t||(i.top>=t&&i.top<o?(a=e,o=i.top):i.top<c&&(s=e,c=i.top))}if(a===null&&s===null)for(let e of r.values()){if(!e.isConnected||e.hasAttribute(`hidden`))continue;let n=e.getBoundingClientRect();n.bottom<=t||n.top>=t&&n.top<o&&(a=e,o=n.top)}let l=a??s,u=a===null?c:o;l!==null&&Number.isFinite(u)&&(ee.current={scroller:n,anchorEl:l,prevTop:u,prevScrollTop:i,scrollVersion:ne.current})}}}}(0,d.useLayoutEffect)(()=>{let e=w.current;w.current=qe;let t=j.current;if(j.current=null,t!==null&&t.isConnected){let e=Math.max(0,t.scrollHeight-t.clientHeight);e>0&&e-t.scrollTop>.5&&(re.current===void 0?t.scrollTop=e:re.current())}let n=ee.current;if(ee.current=null,n!==null&&n.scroller.isConnected&&n.anchorEl.isConnected&&n.scrollVersion===ne.current){let e=n.scroller.scrollTop,t=n.anchorEl.getBoundingClientRect().top-n.prevTop;if(Math.abs(t)>.5){n.scroller.scrollTop=e+t;let r=n.scroller.scrollTop-n.prevScrollTop;Math.abs(r)>.01&&ie.current?.(r)}}if(!y){D.current?.disconnect(),D.current=null,O.current.clear();return}typeof ResizeObserver<`u`&&D.current===null&&(D.current=new ResizeObserver(e=>{for(let t of e){let e=t.target;if(!(e instanceof HTMLElement))continue;let n=e.dataset.chatFlowKey;if(n===void 0||!w.current.has(n))continue;let r=t.borderBoxSize?.[0]?.blockSize??t.contentRect.height;Dv(x.current,n,e,r)}}));let r=D.current,i=O.current,a=S.current;for(let e of Array.from(i)){let t=e.dataset.chatFlowKey;(t===void 0||!qe.has(t)||a.get(t)!==e)&&(r?.unobserve(e),i.delete(e))}for(let t of qe){let n=a.get(t);n!==void 0&&(((r===null?!e.has(t):!i.has(n))||!x.current.has(t))&&Dv(x.current,t,n),r!==null&&!i.has(n)&&(r.observe(n),i.add(n)))}},[qe,y,e]),(0,d.useEffect)(()=>()=>{D.current?.disconnect(),D.current=null,O.current.clear()},[]);let Je=(0,d.useCallback)((e,t)=>{let n=S.current,r=n.get(e);r!==void 0&&r!==t&&(T.current?.unobserve(r),D.current?.unobserve(r),O.current.delete(r)),t===null?n.delete(e):(n.set(e,t),T.current?.observe(t),w.current.has(e)&&(Dv(x.current,e,t),D.current!==null&&!O.current.has(t)&&(D.current.observe(t),O.current.add(t))))},[]),Ye=(0,d.useCallback)((e,t)=>{if(w.current.has(e)){let t=S.current.get(e);if(t!==void 0&&!t.hasAttribute(`hidden`)&&!t.hasAttribute(`data-chat-virtualized`)){let n=Tv(t);if(n>0){let t=Ev(n);return x.current.set(e,t),t}if(wv(t))return x.current.set(e,0),0}}let n=x.current.get(e);return n===void 0?t===`group`?32:80:n},[]),Xe=(0,d.useCallback)(e=>{if(!ze)return!0;let n=yv(e,t,P,r);return n!==null&&Ke(n,we[n])},[t,P,we,r,Ke,ze]),Ze=(0,d.useCallback)(t=>{he(n=>{let r=n.sessionId===e?n.target:null;return Nv(r,t)?n:(r!==null&&De(),{sessionId:e,target:t})})},[De,e]),Qe=(0,d.useCallback)(()=>{Ze(null)},[Ze]);return(0,d.useMemo)(()=>({active:y,findLeaseActive:Ce,isMounted:Ke,isAnchorMounted:Xe,placeholderHeight:Ye,registerRow:Je,pinNavigationTarget:Ze,clearNavigationPin:Qe}),[Qe,y,Ce,Xe,Ke,Ze,Ye,Je])}function Iv(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Iv(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function Lv(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Iv(e))&&(r&&(r+=` `),r+=t);return r}let Rv=`@deepseek-ai/dsh-client-ui-chat/SelectionActions.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Rv)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Rv,e.textContent=`._4l2sSq_popover{z-index:30;background:var(--dsw-alias-button-primary-fill);color:var(--dsw-alias-label-primary-foreground);border:.5px solid color-mix(in srgb, var(--dsw-alias-label-primary-foreground) 16%, transparent);box-shadow:var(--dsw-shadow-lv3);border-radius:9999px;padding:2px;animation:.14s cubic-bezier(.175,.885,.32,1.275) _4l2sSq_selection-island-in;display:flex;position:fixed;overflow:hidden}._4l2sSq_action{height:24px;color:inherit;font-family:var(--dsw-font-family);letter-spacing:-.01em;white-space:nowrap;cursor:pointer;background:0 0;border:none;border-radius:9999px;align-items:center;gap:5px;padding:0 10px;font-size:12px;font-weight:500;transition:background-color .12s,transform .12s cubic-bezier(.175,.885,.32,1.275);display:inline-flex}._4l2sSq_action+._4l2sSq_action{margin-left:1px;position:relative}._4l2sSq_action+._4l2sSq_action:before{content:"";background:color-mix(in srgb, currentColor 24%, transparent);width:1px;position:absolute;top:5px;bottom:5px;left:-1px}._4l2sSq_action svg{color:currentColor;flex-shrink:0}._4l2sSq_action:hover{background:color-mix(in srgb, currentColor 14%, transparent)}._4l2sSq_action:active{background:color-mix(in srgb, currentColor 22%, transparent);transform:scale(.96)}._4l2sSq_answer{position:relative}::highlight(codexhost-response-annotation){background-color:color-mix(in srgb, var(--dsw-alias-state-business-primary) 16%, transparent);text-decoration:underline color-mix(in srgb, var(--dsw-alias-state-business-primary) 65%, transparent)}::highlight(codexhost-response-annotation-hover){background-color:color-mix(in srgb, var(--dsw-alias-state-business-primary) 30%, transparent);text-decoration:underline var(--dsw-alias-state-business-primary)}._4l2sSq_annotationMark{z-index:1;user-select:none;position:absolute;inset-inline-start:100%}._4l2sSq_annotationMark button{justify-content:center;width:24px;height:24px}._4l2sSq_annotationNumber{box-sizing:border-box;background:color-mix(in srgb, var(--dsw-alias-state-business-primary) 14%, var(--dsw-alias-bg-base));min-width:18px;min-height:18px;color:var(--dsw-alias-state-business-primary);font-variant-numeric:tabular-nums;border-radius:999px;place-items:center;padding:0 5px;font-size:10.5px;font-weight:600;line-height:1;transition:background-color .12s,transform .12s;display:inline-grid}._4l2sSq_annotationNumberHovered{background:color-mix(in srgb, var(--dsw-alias-state-business-primary) 28%, var(--dsw-alias-bg-base));transform:scale(1.1)}@keyframes _4l2sSq_selection-island-in{0%{opacity:0;scale:.9}to{opacity:1;scale:1}}@media (prefers-reduced-motion:reduce){._4l2sSq_popover{animation:none}._4l2sSq_action,._4l2sSq_annotationNumber{transition:none}}`,document.head.appendChild(e)}var zv={action:`_4l2sSq_action`,annotationMark:`_4l2sSq_annotationMark`,annotationNumber:`_4l2sSq_annotationNumber`,annotationNumberHovered:`_4l2sSq_annotationNumberHovered`,answer:`_4l2sSq_answer`,popover:`_4l2sSq_popover`,"selection-island-in":`_4l2sSq_selection-island-in`};let Bv=`codexhost-response-annotation`,Vv=[`a`,`button`,`input`,`textarea`,`select`,`summary`,`label`,`[contenteditable='true']`,`[data-selection-actions]`,`[data-code-block-controls]`].join(`,`);function Hv(e,t,n){let r=null,i=1/0;for(let{annotation:a,range:o}of e){let e=o.getClientRects(),s=!1;for(let r=0;r<e.length;r+=1){let i=e[r];if(!(i===void 0||i.width===0&&i.height===0)&&t>=i.left-1&&t<=i.right+1&&n>=i.top-1&&n<=i.bottom+2){s=!0;break}}if(!s)continue;let c=a.anchor===void 0?1/0:a.anchor.end-a.anchor.start;(r===null||c<i)&&(r=a.id,i=c)}return r}function Uv(e){let t=e.getClientRects();for(let e=t.length-1;e>=0;--e){let n=t[e];if(n!==void 0&&(n.width!==0||n.height!==0))return n}let n=e.getBoundingClientRect();return n.width===0&&n.height===0?void 0:n}function Wv(e,t=Bv,n=0){let r=globalThis.CSS?.highlights;if(e.length===0||r===void 0||typeof Highlight>`u`)return()=>{};let i=r.get(t)??new Highlight;i.priority=n;for(let t of e)i.add(t);return r.set(t,i),()=>{for(let t of e)i.delete(t);i.size===0&&r.get(t)===i&&r.delete(t)}}let Gv=[];function Kv({answer:e,answerKey:t,useInput:n,inputActions:r,labels:i}){let a=n(e=>e.responseAnnotations),o=n(e=>e.phase===`adjudicating`||e.phase===`submitting`),[s,c]=(0,d.useState)(null),l=(0,d.useRef)(null);l.current=s;let u=(0,d.useRef)(null),m=n(e=>{let n=e.hoveredResponseAnnotationId;if(n!==void 0)return e.responseAnnotations?.some(e=>e.id===n&&e.anchor?.answerKey===t)?n:void 0}),h=(0,d.useMemo)(()=>a?.flatMap((e,n)=>e.anchor?.answerKey===t?[{annotation:e,index:n+1}]:[]),[a,t]),[g,_]=(0,d.useState)(Gv),v=(0,d.useRef)([]),[y,b]=(0,d.useState)(0),x=(0,d.useRef)(null),S=(0,d.useRef)(r);return S.current=r,(0,d.useEffect)(()=>()=>{x.current!==null&&(x.current=null,S.current?.hoverResponseAnnotation(null))},[]),(0,d.useLayoutEffect)(()=>{let t=e.current;if(t===null||h===void 0||h.length===0){v.current=[],_(Gv),b(e=>e+1);return}let n=()=>{},r=()=>{if(!t.isConnected)return;let e=t.getBoundingClientRect().top,n=v.current.flatMap(({annotation:t,index:n,range:r})=>{let i=Uv(r);return i===void 0?[]:[{annotation:t,index:n,top:i.top-e+(i.height-24)/2}]});n.sort((e,t)=>e.top-t.top);let r=0,i=n.length===0?Gv:n.map(e=>{let t=Math.max(e.top,r);return r=t+24+2,{...e,top:t}});_(e=>e.length===i.length&&e.every((e,t)=>e.annotation===i[t]?.annotation&&e.index===i[t]?.index&&Math.abs(e.top-(i[t]?.top??0))<.5)?e:i)},i=()=>{n(),n=()=>{},t.isConnected?(v.current=h.flatMap(e=>{let{anchor:n,text:r}=e.annotation,i=n&&jh(t,n,r);return i===void 0?[]:[{...e,range:i}]}),n=Wv(v.current.map(({range:e})=>e),Bv),b(e=>e+1),r()):(v.current=[],_(Gv),b(e=>e+1))};i();let a=typeof ResizeObserver>`u`?null:new ResizeObserver(r);a?.observe(t);let o=typeof MutationObserver>`u`?null:new MutationObserver(i),s=t.firstElementChild;return s!==null&&!s.hasAttribute(`data-selection-actions`)&&o?.observe(s,{childList:!0,characterData:!0,subtree:!0,attributes:!0,attributeFilter:[`hidden`,`open`]}),t.addEventListener(`scroll`,r,!0),()=>{n(),n=()=>{},v.current=[],a?.disconnect(),o?.disconnect(),t.removeEventListener(`scroll`,r,!0)}},[e,h]),(0,d.useEffect)(()=>{s!==null&&!h?.some(({annotation:e})=>e.id===s)&&c(null)},[h,s]),(0,d.useEffect)(()=>{let t=e.current;if(t===null||h===void 0||h.length===0)return;let n=()=>{u.current=l.current},r=e=>{let n=u.current;if(u.current=null,e.defaultPrevented||e.button!==0||e.detail>1)return;let r=t.ownerDocument.defaultView?.getSelection();if(r!=null&&!r.isCollapsed||(e.target instanceof Element?e.target:e.target instanceof Node?e.target.parentElement:null)?.closest(Vv)!=null)return;let i=Hv(v.current,e.clientX,e.clientY);i!==null&&i!==n&&c(i)};return t.addEventListener(`pointerdown`,n,!0),t.addEventListener(`click`,r),()=>{t.removeEventListener(`pointerdown`,n,!0),t.removeEventListener(`click`,r)}},[e,h]),(0,d.useLayoutEffect)(()=>{if(m!==void 0)return Wv(v.current.filter(({annotation:e})=>e.id===m).map(({range:e})=>e),`codexhost-response-annotation-hover`,1)},[m,y]),g.map(({annotation:e,index:t,top:n})=>{let a=m===e.id;return/* @__PURE__ */ (0,f.jsx)(`div`,{className:zv.annotationMark,style:{top:n},"data-selection-actions":!0,onPointerEnter:t=>{t.pointerType!==`touch`&&(x.current=e.id,r?.hoverResponseAnnotation(e.id))},onPointerLeave:t=>{t.pointerType!==`touch`&&(x.current===e.id&&(x.current=null),r?.hoverResponseAnnotation(null))},onFocus:t=>{t.target instanceof Element&&t.target.matches(`:focus-visible`)&&(x.current=e.id,r?.hoverResponseAnnotation(e.id))},onBlur:t=>{!t.currentTarget.contains(t.relatedTarget)&&m===e.id&&(x.current===e.id&&(x.current=null),r?.hoverResponseAnnotation(null))},children:/* @__PURE__ */ (0,f.jsx)(p.ResponseAnnotationPopover,{annotation:e,index:t,labels:i,title:i.label(t),open:s===e.id,onOpenChange:t=>{c(t?e.id:null)},editDisabled:o,onUpdate:r===void 0?void 0:t=>{r.updateResponseAnnotation(e.id,t)},onRemove:r===void 0?void 0:()=>{r.removeResponseAnnotation(e.id)},anchor:/* @__PURE__ */ (0,f.jsx)(`span`,{className:Lv(zv.annotationNumber,a&&zv.annotationNumberHovered),"data-hovered":a||void 0,"aria-label":i.label(t),children:t})})},e.id)})}let qv=`@deepseek-ai/dsh-client-ui-chat/SelectionCommentCard.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(qv)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=qv,e.textContent=`.lPRhsq_card{z-index:30;box-sizing:border-box;border:.5px solid var(--dsw-alias-border-l2);background:var(--dsw-specific-input-major);width:344px;box-shadow:var(--dsw-shadow-lv3);color:var(--dsw-alias-label-primary);font-family:var(--dsw-font-family);border-radius:16px;flex-direction:column;gap:8px;padding:12px;animation:.14s cubic-bezier(.175,.885,.32,1.275) lPRhsq_selection-comment-in;display:flex;position:fixed}.lPRhsq_header{align-items:flex-start;gap:8px;display:flex}.lPRhsq_excerpt{border-left:2px solid var(--dsw-alias-border-l3);min-width:0;color:var(--dsw-alias-label-tertiary);-webkit-line-clamp:2;overflow-wrap:anywhere;-webkit-box-orient:vertical;flex:auto;margin:0;padding-left:9px;font-size:12px;line-height:17px;display:-webkit-box;overflow:hidden}.lPRhsq_close{width:22px;height:22px;color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:0;border-radius:6px;flex:none;place-items:center;margin:-3px -4px 0 0;padding:0;transition:background-color .11s,color .11s;display:inline-grid}@media (hover:hover) and (pointer:fine){.lPRhsq_close:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}}.lPRhsq_close:focus-visible{outline:1.5px solid var(--dsw-alias-state-business-primary);outline-offset:0}.lPRhsq_inputRow{align-items:flex-end;gap:8px;display:flex}.lPRhsq_field{box-sizing:border-box;field-sizing:content;min-width:0;min-height:28px;max-height:116px;color:var(--dsw-alias-label-primary);font:inherit;resize:none;background:0 0;border:0;outline:none;flex:auto;padding:4px 0;font-size:13px;line-height:19px}.lPRhsq_field::placeholder{color:var(--dsw-alias-label-tertiary)}.lPRhsq_submit{background:var(--dsw-alias-button-primary-fill);height:28px;color:var(--dsw-alias-label-primary-foreground);font:inherit;white-space:nowrap;cursor:pointer;touch-action:manipulation;user-select:none;-webkit-tap-highlight-color:transparent;border:0;border-radius:9999px;flex:none;justify-content:center;align-items:center;gap:5px;padding:0 12px;font-size:12px;font-weight:500;line-height:16px;transition:background-color .12s,opacity .12s,transform .12s cubic-bezier(.175,.885,.32,1.275);display:inline-flex}@media (hover:hover) and (pointer:fine){.lPRhsq_submit:hover:not(:disabled){background:var(--dsw-alias-button-primary-hover)}}.lPRhsq_submit:disabled{opacity:.35;cursor:default}.lPRhsq_submit:not(:disabled):active{transform:scale(.96)}.lPRhsq_kbd{color:currentColor;opacity:.72;background:0 0;border:0;justify-content:center;align-items:center;padding:0;font-family:inherit;font-size:11px;font-weight:500;line-height:1;display:inline-flex}.lPRhsq_error{color:var(--dsw-alias-state-error-primary);font-size:11.5px;line-height:16px}@media (hover:none),(pointer:coarse){.lPRhsq_card{width:min(344px,100vw - 16px)}.lPRhsq_field{font-size:16px;line-height:22px}.lPRhsq_submit{height:32px;padding:0 14px;font-size:13px}.lPRhsq_kbd{display:none}}@keyframes lPRhsq_selection-comment-in{0%{opacity:0;scale:.96}to{opacity:1;scale:1}}@media (prefers-reduced-motion:reduce){.lPRhsq_card{animation:none}.lPRhsq_submit,.lPRhsq_close{transition:none}}`,document.head.appendChild(e)}var Jv={card:`lPRhsq_card`,close:`lPRhsq_close`,error:`lPRhsq_error`,excerpt:`lPRhsq_excerpt`,field:`lPRhsq_field`,header:`lPRhsq_header`,inputRow:`lPRhsq_inputRow`,kbd:`lPRhsq_kbd`,"selection-comment-in":`lPRhsq_selection-comment-in`,submit:`lPRhsq_submit`};function Yv(){return typeof CSS<`u`&&typeof CSS.supports==`function`&&CSS.supports(`field-sizing`,`content`)}function Xv({excerpt:e,labels:t,fieldRef:n,style:r,below:i,onSubmit:a,onCancel:o}){let[s,c]=(0,d.useState)(``),[l,u]=(0,d.useState)(!1),m=(0,d.useRef)(null),h=s.trim();(0,d.useEffect)(()=>{n.current?.focus({preventScroll:!0});let e=(0,p.observeComposition)(document);return m.current=e,()=>{e.dispose(),m.current===e&&(m.current=null)}},[n]),(0,d.useLayoutEffect)(()=>{let e=n.current;e===null||Yv()||(e.style.height=`auto`,e.style.height=`${String(Math.min(e.scrollHeight,116))}px`)},[n,s]);let g=()=>{h!==``&&(u(!1),a(h)||u(!0))};return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Jv.card,role:`dialog`,"aria-label":t.placeholder,"data-placement":i?`below`:`above`,style:r,"data-selection-actions":!0,onKeyDown:e=>{e.key===`Escape`&&m.current?.guards(e.nativeEvent)!==!0&&(e.preventDefault(),e.stopPropagation(),o())},onMouseDown:e=>{e.target!==n.current&&e.preventDefault()},children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Jv.header,children:[/* @__PURE__ */ (0,f.jsx)(`blockquote`,{className:Jv.excerpt,children:e.replace(/\s+/gu,` `)}),/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Jv.close,"aria-label":t.cancel,title:t.cancel,onClick:o,children:/* @__PURE__ */ (0,f.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M2.5 2.5l7 7M9.5 2.5l-7 7`})})})]}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Jv.inputRow,children:[/* @__PURE__ */ (0,f.jsx)(`textarea`,{ref:n,className:Jv.field,rows:1,value:s,placeholder:t.placeholder,"aria-label":t.placeholder,onChange:e=>{l&&u(!1),c(e.target.value)},onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||m.current?.guards(e.nativeEvent)!==!0&&(e.preventDefault(),g())}}),/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Jv.submit,disabled:h===``,onClick:g,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{children:t.submit}),/* @__PURE__ */ (0,f.jsx)(`kbd`,{className:Jv.kbd,"aria-hidden":`true`,children:`↵`})]})]}),l&&/* @__PURE__ */ (0,f.jsx)(`div`,{role:`alert`,className:Jv.error,children:t.unavailable})]})}function Zv(e){return e instanceof Element?e:e.parentElement}function Qv(e){if(e===null||typeof window>`u`)return null;let t=window.getSelection();if(t===null||t.rangeCount===0||t.isCollapsed)return null;let n=t.getRangeAt(0),r=Zv(n.startContainer),i=Zv(n.endContainer),a=r?.closest(`[data-selection-answer]`);if(a==null||!e.contains(a)||i?.closest(`[data-selection-answer]`)!==a||a.hasAttribute(`data-selection-answer-streaming`)||r?.closest(Dh)!=null||i?.closest(Dh)!=null)return null;let o=kh(n),s=Uv(n);return o===``||s===void 0?null:{text:o,rect:s,range:n.cloneRange(),host:a}}function $v(e){let t=window.getSelection();t!==null&&e.contains(t.anchorNode)&&e.contains(t.focusNode)&&t.removeAllRanges()}function ey(e,t=0){let n=window.visualViewport,r=n?.width??window.innerWidth,i=n?.offsetLeft??0,a=e.right-i,o=window.matchMedia(`(hover: none)`).matches,s=n?.offsetTop??0,c=s+(n?.height??window.innerHeight),l=e.top-8-t>=s+8,u=e.bottom+8+t<=c-8,d=t===0?o:o?u||!l:!l&&u,f=r-8-a,p=d?e.bottom+8:e.top-8,m=s+8+(d?0:t),h=c-8-(d?t:0);return{left:e.right,top:t===0?p:Math.max(m,Math.min(p,h)),maxWidth:r-16,transform:`translateX(clamp(${String(8-a)}px, -100%, calc(${String(f)}px - 100%)))`+(d?``:` translateY(-100%)`),below:d}}function ty({labels:e,onAdd:t,container:n,onComposingAnswerChange:r}){let[i,a]=(0,d.useState)(null),[o,s]=(0,d.useState)(null),c=(0,d.useRef)(null),l=(0,d.useRef)(!1),u=(0,d.useRef)(null),p=(0,d.useRef)(!1),m=(0,d.useRef)(null),g=(0,d.useRef)(null),_=(0,d.useCallback)(e=>{g.current=e,a(e)},[]),v=(0,d.useCallback)(()=>{l.current=!1,s(null)},[]),y=(0,d.useCallback)(()=>{if(u.current=null,p.current||l.current)return;let e=Qv(n.current),t=m.current;e!==null&&t!==null&&e.host===t.host&&e.text===t.text?_(null):((e===null||t===null||e.host!==t.host||e.text!==t.text)&&(m.current=null),_(e))},[n,_]),b=(0,d.useCallback)(()=>{u.current===null&&(u.current=window.requestAnimationFrame(y))},[y]);(0,d.useEffect)(()=>{let e=()=>{p.current=!1,b()},t=e=>{let t=e.target;(t instanceof Element?t:t instanceof Node?t.parentElement:null)?.closest(`[data-selection-actions]`)??(p.current=!0,m.current=null,_(null),v())},n=()=>{let e=window.getSelection();e===null||e.rangeCount===0||e.isCollapsed?(m.current=null,_(null)):b()},r=e=>{let t=e.target;if(t instanceof Element&&t.closest(`[data-selection-actions]`)!==null)return;let n=c.current,r=n?.closest(`[data-selection-actions]`)??null;(n===null||n!==document.activeElement&&r?.contains(document.activeElement)!==!0&&n.value===``)&&(_(null),v())},i=e=>{let t=g.current;e.key!==`Escape`||e.defaultPrevented||e.isComposing||l.current||t===null||(e.preventDefault(),m.current={host:t.host,text:t.text},_(null))};return document.addEventListener(`pointerdown`,t,!0),document.addEventListener(`pointerup`,e,!0),document.addEventListener(`pointercancel`,e,!0),document.addEventListener(`selectionchange`,n),document.addEventListener(`keydown`,i),window.addEventListener(`keyup`,b),window.addEventListener(`scroll`,r,!0),()=>{document.removeEventListener(`pointerdown`,t,!0),document.removeEventListener(`pointerup`,e,!0),document.removeEventListener(`pointercancel`,e,!0),document.removeEventListener(`selectionchange`,n),document.removeEventListener(`keydown`,i),window.removeEventListener(`keyup`,b),window.removeEventListener(`scroll`,r,!0),u.current!==null&&window.cancelAnimationFrame(u.current),u.current=null}},[b,v,_]);let x=o?.rect,S=o?.range;(0,d.useEffect)(()=>{if(x===void 0||S===void 0)return;let e=window.visualViewport,t=c.current?.closest(`[data-selection-actions]`),n=()=>{let e=t?.offsetHeight??104,n=ey(x,e);s(e=>e?.rect===x?{...e,placement:n}:e)},r=Wv([S]),i=typeof ResizeObserver>`u`?null:new ResizeObserver(n);return t!=null&&i?.observe(t),window.addEventListener(`resize`,n),e?.addEventListener(`resize`,n),e?.addEventListener(`scroll`,n,{passive:!0}),n(),()=>{r(),i?.disconnect(),window.removeEventListener(`resize`,n),e?.removeEventListener(`resize`,n),e?.removeEventListener(`scroll`,n)}},[x,S]);let C=o?.anchor?.answerKey??null;if((0,d.useEffect)(()=>(r?.(C),()=>{C!==null&&r?.(null)}),[C,r]),o!==null){let r=o.placement;return(0,h.createPortal)(/* @__PURE__ */ (0,f.jsx)(Xv,{excerpt:o.text,labels:e,fieldRef:c,below:r.below,style:{left:r.left,top:r.top,maxWidth:r.maxWidth,transform:`${r.transform} translateZ(0)`},onSubmit:e=>n.current===null||!t(o.anchor===void 0?{text:o.text,annotation:e}:{text:o.text,annotation:e,anchor:o.anchor})?!1:(o.host.isConnected&&$v(o.host),v(),!0),onCancel:v}),document.body)}if(i===null)return null;let w=ey(i.rect),T=()=>i.host.isConnected&&n.current?.contains(i.host)===!0;return(0,h.createPortal)(/* @__PURE__ */ (0,f.jsxs)(`div`,{className:zv.popover,"data-placement":w.below?`below`:`above`,style:{left:w.left,top:w.top,maxWidth:w.maxWidth,transform:`${w.transform} translateZ(0)`},"data-selection-actions":!0,onPointerDown:e=>{e.preventDefault()},children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:zv.action,onClick:()=>{if(!T())return;let e=Ah(i.host,i.range);t(e===void 0?{text:i.text}:{text:i.text,anchor:e})&&($v(i.host),_(null))},children:[/* @__PURE__ */ (0,f.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`}),/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M12 7v6`}),/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M9 10h6`})]}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:e.addToChat})]}),/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:zv.action,onClick:()=>{if(!T())return;let e=Ah(i.host,i.range);$v(i.host),l.current=!0,s({...i,anchor:e,placement:ey(i.rect,104)}),_(null)},children:/* @__PURE__ */ (0,f.jsx)(`span`,{children:e.comment})})]}),document.body)}let ny=`@deepseek-ai/dsh-client-ui-chat/ChatMarkdown.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(ny)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=ny,e.textContent=`.DT2SAW_linkMenu[data-menu-material]{--link-menu-fill:color-mix(in srgb, var(--dsw-alias-bg-layer-2) 68%, var(--dsw-alias-bg-overlay));--dsw-menu-surface-fill:color-mix(in srgb, var(--link-menu-fill) 78%, transparent);--dsw-menu-backdrop-filter:blur(20px) saturate(140%);--dsw-alias-interactive-bg-hover:color-mix(in srgb, var(--dsw-alias-link) 18%, transparent);--dsw-alias-menu-icon:var(--dsw-alias-label-primary);border:1px solid var(--dsw-alias-border-l4);min-width:148px;padding:4px;box-shadow:inset 0 1px #fff3,0 2px 5px #0000001a,0 9px 22px #0000002e}.DT2SAW_linkMenu[data-menu-material] [role=menuitem]{min-height:24px;font:500 13px/18px var(--dsw-font-family);border-radius:6px;gap:8px;padding:2px 8px}.DT2SAW_linkMenu[data-menu-material] [role=menuitem]>span:has(>svg),.DT2SAW_linkMenu[data-menu-material] [role=menuitem] svg{width:14px;height:14px}@media (pointer:coarse){.DT2SAW_linkMenu[data-menu-material] [role=menuitem]{min-height:44px}}@media (prefers-reduced-transparency:reduce),(prefers-contrast:more){.DT2SAW_linkMenu[data-menu-material]{--dsw-menu-surface-fill:var(--link-menu-fill);--dsw-menu-backdrop-filter:none}}@media (forced-colors:active){.DT2SAW_linkMenu[data-menu-material]{--dsw-menu-surface-fill:Canvas;--dsw-menu-backdrop-filter:none;border-color:canvastext}.DT2SAW_linkMenu[data-menu-material] [role=menuitem]:is(:hover,:focus-visible){outline-offset:-1px;outline:1px solid highlight}}`,document.head.appendChild(e)}var ry={linkMenu:`DT2SAW_linkMenu`};function iy({children:e,openFile:t,openLinkInSidebar:n,hideLocalFileActions:r=!1,t:i,...a}){let[o,s]=(0,d.useState)(null),[c,l]=(0,d.useState)(!1),u=(0,d.useCallback)(()=>s(null),[]),m=(0,d.useCallback)(()=>o?.position??null,[o]),h=(0,d.useCallback)(e=>i(`codeBlock.expand`,{count:e}),[i]),g=i(`codeBlock.collapse`);return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(p.MarkdownDelegateProvider,{collapsibleCodeBlocks:!0,expandCodeLabel:h,collapseCodeLabel:g,...a,openFile:t,onLinkContextMenu:s,children:e}),/* @__PURE__ */ (0,f.jsx)(p.Menu,{anchor:null,open:o!==null,portal:!0,compact:!0,autoFocus:!0,listClassName:ry.linkMenu,getAnchorRect:m,focusReturnTarget:o?.trigger,onClose:u,children:o!==null&&/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[(o.kind===`file`||n!==void 0)&&/* @__PURE__ */ (0,f.jsx)(p.MenuItemButton,{icon:o.kind===`file`?/* @__PURE__ */ (0,f.jsx)(p.LinkIconMedium,{kind:`document`}):/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineMedium,{}),onSelect:()=>{u(),o.kind===`file`?t(o.path,o.line===void 0?void 0:{line:o.line}):n?.(o.href)},children:i(`linkMenu.openInCodexhost`)}),/* @__PURE__ */ (0,f.jsx)(p.MenuItemButton,{icon:/* @__PURE__ */ (0,f.jsx)(p.IconLinkOutlineMedium,{}),onSelect:()=>{u(),(0,p.writeClipboard)(o.href).then(e=>l(!e))},children:i(`linkMenu.copy`)}),(o.kind===`web`||!r)&&/* @__PURE__ */ (0,f.jsx)(p.MenuItemButton,{icon:/* @__PURE__ */ (0,f.jsx)(p.IconRightUpOutlineMedium,{}),onSelect:()=>{u(),o.kind===`web`?window.open(o.href,`_blank`,`noopener,noreferrer`):t(o.path,{external:!0,...o.line===void 0?{}:{line:o.line}})},children:i(o.kind===`web`?`linkMenu.openBrowser`:`linkMenu.openFile`)}),o.kind===`file`&&!r&&/* @__PURE__ */ (0,f.jsx)(p.MenuItemButton,{icon:/* @__PURE__ */ (0,f.jsx)(p.IconFolderOpenOutlineMedium,{}),onSelect:()=>{u(),t(o.path,{reveal:!0})},children:i(`linkMenu.openFolder`)})]})}),c&&/* @__PURE__ */ (0,f.jsx)(p.Toast,{text:i(`linkMenu.copyFailed`),onDone:()=>l(!1)})]})}let ay=`@deepseek-ai/dsh-client-ui-chat/HandoffDivider.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(ay)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=ay,e.textContent=`.SfZcya_root{flex-direction:column;gap:10px;width:100%;min-width:0;padding:6px 0 8px;display:flex}.SfZcya_dividerBar{align-items:center;gap:10px;width:100%;min-width:0;display:flex}.SfZcya_line{background:var(--dsw-alias-border-l2);opacity:.72;flex:20px;min-width:12px;height:1px}.SfZcya_trigger{border-radius:var(--dsw-radius-sm,8px);min-width:0;max-width:calc(100% - 36px);color:var(--dsw-alias-label-tertiary);font:inherit;font-size:var(--dsh-content-font-size-secondary,13px);cursor:pointer;background:0 0;border:none;flex-wrap:wrap;justify-content:center;align-items:center;gap:4px 7px;padding:4px 10px;line-height:20px;transition:background-color .12s,color .12s;display:inline-flex}.SfZcya_trigger:hover,.SfZcya_trigger[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover)}.SfZcya_trigger:focus-visible{outline:2px solid var(--dsw-alias-link);outline-offset:1px}.SfZcya_titleGroup{color:var(--dsw-alias-label-tertiary);flex-shrink:0;align-items:center;gap:5px;display:inline-flex}.SfZcya_swapIcon{opacity:.85;flex-shrink:0}.SfZcya_endpoints{flex-wrap:wrap;justify-content:center;align-items:center;gap:2px 6px;min-width:0;max-width:100%;display:inline-flex}.SfZcya_endpoint{align-items:center;gap:5px;min-width:0;max-width:100%;display:inline-flex}.SfZcya_sourceLabel{color:var(--dsw-alias-label-secondary);text-overflow:ellipsis;white-space:nowrap;max-width:240px;font-weight:450;overflow:hidden}.SfZcya_arrow{color:var(--dsw-alias-label-caption);flex-shrink:0;font-size:12px;line-height:1}.SfZcya_targetLabel{color:color-mix(in srgb, var(--dsw-alias-link) 82%, var(--dsw-alias-label-secondary));text-overflow:ellipsis;white-space:nowrap;max-width:240px;font-weight:500;overflow:hidden}.SfZcya_chevron{color:var(--dsw-alias-label-caption);opacity:.55;flex-shrink:0;align-items:center;transition:transform .14s,opacity .12s;display:inline-flex}.SfZcya_trigger:hover .SfZcya_chevron,.SfZcya_trigger[aria-expanded=true] .SfZcya_chevron{opacity:.95}.SfZcya_chevronOpen{transform:rotate(180deg)}.SfZcya_panel{border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-md,10px);background:var(--dsw-alias-bg-module-platform);flex-direction:column;gap:10px;min-width:0;padding:12px 14px;display:flex}body[data-codexhost-wallpaper] .SfZcya_panel{background:color-mix(in srgb, var(--dsw-alias-bg-module-platform) 84%, transparent);backdrop-filter:blur(12px)}body[data-codexhost-wallpaper] [data-chat-flow-key]:not([data-chat-flow-key] *,[data-chat-near-viewport]) .SfZcya_panel,body[data-codexhost-wallpaper] [data-chat-near-viewport-gate]:not([data-chat-near-viewport]) .SfZcya_panel{backdrop-filter:none}.SfZcya_panelHeader{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:8px;display:flex}.SfZcya_turnSummary{color:var(--dsw-alias-label-secondary);font-size:12.5px;line-height:18px}.SfZcya_sourceButton{border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm,6px);background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);font:inherit;cursor:pointer;flex-shrink:0;align-items:center;gap:5px;padding:4px 10px;font-size:12px;font-weight:500;line-height:16px;transition:background-color .12s,border-color .12s;display:inline-flex}.SfZcya_sourceButton:hover{background:var(--dsw-alias-interactive-bg-hover-solid);border-color:var(--dsw-alias-border-l3)}.SfZcya_sourceButton:focus-visible{outline:2px solid var(--dsw-alias-link);outline-offset:1px}.SfZcya_preview{border:1px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-sm,6px);background:var(--dsw-alias-bg-base);max-height:260px;color:var(--dsw-alias-label-secondary);white-space:pre-wrap;overflow-wrap:anywhere;margin:0;padding:10px 12px;font-family:inherit;font-size:12.5px;line-height:1.55;overflow-y:auto}.SfZcya_previewEmpty{color:var(--dsw-alias-label-tertiary);font-style:italic}@media (width<=520px){.SfZcya_dividerBar{gap:6px}.SfZcya_line{flex-basis:10px;min-width:8px}.SfZcya_trigger{column-gap:5px;max-width:calc(100% - 28px);padding:4px 6px;font-size:12px;line-height:18px}.SfZcya_sourceLabel,.SfZcya_targetLabel{max-width:148px}.SfZcya_panel{padding:10px 12px}}`,document.head.appendChild(e)}var oy={arrow:`SfZcya_arrow`,chevron:`SfZcya_chevron`,chevronOpen:`SfZcya_chevronOpen`,dividerBar:`SfZcya_dividerBar`,endpoint:`SfZcya_endpoint`,endpoints:`SfZcya_endpoints`,line:`SfZcya_line`,panel:`SfZcya_panel`,panelHeader:`SfZcya_panelHeader`,preview:`SfZcya_preview`,previewEmpty:`SfZcya_previewEmpty`,root:`SfZcya_root`,sourceButton:`SfZcya_sourceButton`,sourceLabel:`SfZcya_sourceLabel`,swapIcon:`SfZcya_swapIcon`,targetLabel:`SfZcya_targetLabel`,titleGroup:`SfZcya_titleGroup`,trigger:`SfZcya_trigger`,turnSummary:`SfZcya_turnSummary`};let sy=(0,d.memo)(function({handoff:e,hostId:t,onOpenSource:n,t:r}){let[i,a]=(0,d.useState)(!1),o=(0,d.useId)(),s=yh({harnessId:e.sourceHarnessId,harnessLabel:e.sourceHarnessLabel,model:e.sourceModel}),c=yh({harnessId:e.targetHarnessId,harnessLabel:e.targetHarnessLabel,model:e.targetModel}),l=e.includedTurnNumbers.length,u=e.omittedTurns>0?r(`handoff.divider.turnsPartial`,{included:l,total:e.totalTurns,omitted:e.omittedTurns,boundary:e.boundaryTurnNumber}):e.boundaryTurnNumber<e.totalTurns?r(`handoff.divider.turnsPrefix`,{boundary:e.boundaryTurnNumber,total:e.totalTurns}):r(`handoff.divider.turnsAll`,{total:e.totalTurns}),m=e.preview.trim();return/* @__PURE__ */ (0,f.jsxs)(`section`,{className:oy.root,"data-handoff-divider":``,"aria-label":r(`handoff.divider.label`),children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:oy.dividerBar,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:oy.line,"aria-hidden":`true`}),/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:oy.trigger,"aria-expanded":i,"aria-controls":o,"aria-label":r(i?`handoff.divider.collapse`:`handoff.divider.expand`),onClick:()=>{a(e=>!e)},children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:oy.titleGroup,children:[/* @__PURE__ */ (0,f.jsx)(xh,{size:14,className:oy.swapIcon}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:r(`handoff.divider.label`)})]}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:oy.endpoints,children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:oy.endpoint,title:s.title,children:[/* @__PURE__ */ (0,f.jsx)(Sh,{harnessId:e.sourceHarnessId,label:e.sourceHarnessLabel??e.sourceHarnessId,hostId:t,size:15}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:oy.sourceLabel,children:s.display})]}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:oy.arrow,"aria-hidden":`true`,children:`→`}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:oy.endpoint,title:c.title,children:[/* @__PURE__ */ (0,f.jsx)(Sh,{harnessId:e.targetHarnessId,label:e.targetHarnessLabel??e.targetHarnessId,hostId:t,size:15}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:oy.targetLabel,children:c.display})]})]}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:i?`${oy.chevron} ${oy.chevronOpen}`:oy.chevron,"aria-hidden":`true`,children:/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:12})})]}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:oy.line,"aria-hidden":`true`})]}),i&&/* @__PURE__ */ (0,f.jsxs)(`div`,{id:o,className:oy.panel,"data-handoff-panel":``,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:oy.panelHeader,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:oy.turnSummary,children:u}),/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:oy.sourceButton,onClick:()=>{n(e.sourceThreadId)},children:[/* @__PURE__ */ (0,f.jsx)(`span`,{children:r(`handoff.divider.openSource`)}),/* @__PURE__ */ (0,f.jsx)(`span`,{"aria-hidden":`true`,children:`↗`})]})]}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:m===``?`${oy.preview} ${oy.previewEmpty}`:oy.preview,children:m===``?r(`handoff.divider.previewEmpty`):e.preview})]})]})}),cy=`@deepseek-ai/dsh-client-ui-chat/HandoffModal.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(cy)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=cy,e.textContent=`.psMsOW_dialog{width:min(440px,100%)}.psMsOW_sections{flex-direction:column;gap:16px;min-width:0;display:flex}.psMsOW_section{flex-direction:column;gap:8px;min-width:0;display:flex}.psMsOW_sectionLabel{color:var(--dsw-alias-label-secondary);font-size:12.5px;font-weight:500;line-height:18px}.psMsOW_harnessGrid{grid-template-columns:repeat(auto-fill,minmax(128px,1fr));gap:8px;display:grid}.psMsOW_harnessOption{border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm,8px);background:var(--dsw-alias-bg-base);min-width:0;color:var(--dsw-alias-label-primary);font:inherit;text-align:left;cursor:pointer;align-items:center;gap:8px;padding:8px 10px;font-size:13px;line-height:18px;transition:background-color .12s,border-color .12s;display:flex}.psMsOW_harnessOption:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);border-color:var(--dsw-alias-border-l3)}.psMsOW_harnessOption[data-selected]{border-color:var(--dsw-alias-link);background:color-mix(in srgb, var(--dsw-alias-link) 10%, var(--dsw-alias-bg-base))}.psMsOW_harnessOption:disabled{opacity:.55;cursor:default}.psMsOW_harnessName{text-overflow:ellipsis;white-space:nowrap;flex:auto;min-width:0;font-weight:500;overflow:hidden}.psMsOW_checkIcon{color:var(--dsw-alias-link);flex-shrink:0}.psMsOW_searchInput{width:100%}.psMsOW_modelList{border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm,8px);background:var(--dsw-alias-bg-module-platform);flex-direction:column;gap:4px;max-height:216px;padding:4px;display:flex;overflow-y:auto}.psMsOW_modelOption{border-radius:var(--dsw-radius-sm,6px);width:100%;min-width:0;color:var(--dsw-alias-label-primary);font:inherit;text-align:left;cursor:pointer;background:0 0;border:none;justify-content:space-between;align-items:center;gap:8px;padding:7px 10px;font-size:13px;line-height:18px;transition:background-color .1s;display:flex}.psMsOW_modelOption:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.psMsOW_modelOption[data-selected]{background:var(--dsw-alias-bg-base);box-shadow:inset 0 0 0 1px color-mix(in srgb, var(--dsw-alias-link) 45%, var(--dsw-alias-border-l2))}.psMsOW_modelOption:disabled{opacity:.55;cursor:default}.psMsOW_modelInfo{flex-direction:column;flex:auto;min-width:0;display:flex}.psMsOW_modelTitleRow{align-items:center;gap:6px;min-width:0;display:flex}.psMsOW_modelName{text-overflow:ellipsis;white-space:nowrap;font-weight:450;overflow:hidden}.psMsOW_defaultBadge{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-tertiary);border-radius:4px;flex-shrink:0;padding:1px 5px;font-size:11px;line-height:14px}.psMsOW_modelDesc{text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-tertiary);font-size:11.5px;line-height:16px;overflow:hidden}.psMsOW_status{color:var(--dsw-alias-label-secondary);align-items:center;gap:8px;padding:12px 2px;font-size:13px;line-height:18px;display:flex}.psMsOW_empty{color:var(--dsw-alias-label-tertiary);padding:10px;font-size:12.5px;line-height:18px}.psMsOW_errorBox{border-radius:var(--dsw-radius-sm,8px);border:1px solid color-mix(in srgb, var(--dsw-alias-state-error-primary) 28%, transparent);background:color-mix(in srgb, var(--dsw-alias-state-error-primary) 8%, transparent);color:var(--dsw-alias-state-error-primary);justify-content:space-between;align-items:center;gap:8px;padding:9px 11px;font-size:12.5px;line-height:18px;display:flex}.psMsOW_errorText{overflow-wrap:anywhere;min-width:0}.psMsOW_modalAction{min-width:78px}.psMsOW_submittingContent{align-items:center;gap:6px;display:inline-flex}@media (width<=640px){.psMsOW_harnessGrid{grid-template-columns:repeat(2,minmax(0,1fr))}}`,document.head.appendChild(e)}var X={checkIcon:`psMsOW_checkIcon`,defaultBadge:`psMsOW_defaultBadge`,dialog:`psMsOW_dialog`,empty:`psMsOW_empty`,errorBox:`psMsOW_errorBox`,errorText:`psMsOW_errorText`,harnessGrid:`psMsOW_harnessGrid`,harnessName:`psMsOW_harnessName`,harnessOption:`psMsOW_harnessOption`,modalAction:`psMsOW_modalAction`,modelDesc:`psMsOW_modelDesc`,modelInfo:`psMsOW_modelInfo`,modelList:`psMsOW_modelList`,modelName:`psMsOW_modelName`,modelOption:`psMsOW_modelOption`,modelTitleRow:`psMsOW_modelTitleRow`,searchInput:`psMsOW_searchInput`,section:`psMsOW_section`,sectionLabel:`psMsOW_sectionLabel`,sections:`psMsOW_sections`,status:`psMsOW_status`,submittingContent:`psMsOW_submittingContent`};function ly(e,t){if(t===void 0||t.models.length===0)return;let n=e.rememberedSelections?.[t.id]?.model;return n!==void 0&&t.models.some(e=>e.id===n)?n:e.default?.provider===t.id&&t.models.some(t=>t.id===e.default?.model)?e.default.model:t.models[0]?.id}function uy(e,t,n){if(e===null||t===void 0||n===void 0)return;let r=t.models.find(e=>e.id===n),i=r?.reasoning?.efforts;if(i===void 0||i.length===0)return;let a=e.rememberedSelections?.[t.id];if(a?.model===n&&a.reasoningEffort!==void 0&&i.some(e=>e.id===a.reasoningEffort))return a.reasoningEffort;if(r?.reasoning?.defaultEffort!==void 0&&i.some(e=>e.id===r.reasoning?.defaultEffort))return r.reasoning.defaultEffort}function dy(e){if(e===null)return[];let t=e.harnessOrder??[];return[...e.groups].sort((e,n)=>{let r=t.indexOf(e.id),i=t.indexOf(n.id);return(r<0?1/0:r)-(i<0?1/0:i)})}function fy(e,t,n){if(e.length!==0){if(n!==void 0){let t=e.find(e=>e.id===n);if(t!==void 0)return t}return e.find(e=>e.id!==t)??e[0]}}function py({open:e,atSeq:t,currentHarnessId:n,initialHarnessId:r,loadModelCatalog:i,onSubmit:a,onClose:o,t:s}){let[c,l]=(0,d.useState)(null),[u,m]=(0,d.useState)(`idle`),[h,g]=(0,d.useState)(null),[_,v]=(0,d.useState)(null),[y,b]=(0,d.useState)(void 0),[x,S]=(0,d.useState)(``),[C,w]=(0,d.useState)(!1),[T,E]=(0,d.useState)(null),D=(0,d.useCallback)(()=>{let e=!0;return m(`loading`),g(null),i().then(t=>{if(!e)return;let i=fy(dy(t),n,r);l(t),m(`ready`),v(i?.id??null),b(ly(t,i))},t=>{e&&(m(`error`),g(t instanceof Error?t.message:String(t)))}),()=>{e=!1}},[n,r,i]);(0,d.useEffect)(()=>{if(e)return E(null),S(``),D()},[e,D]);let O=(0,d.useMemo)(()=>dy(c),[c]),k=(0,d.useMemo)(()=>O.find(e=>e.id===_),[O,_]),A=(0,d.useMemo)(()=>c===null?void 0:ly(c,k),[c,k]),ee=(k?.models.length??0)>6,j=(0,d.useMemo)(()=>{let e=k?.models??[];return!ee||x.trim()===``?e:(0,p.rankByName)(e,x.trim())},[x,k?.models,ee]),te=e=>{C||(v(e.id),b(c===null?e.models[0]?.id:ly(c,e)),S(``),E(null))},ne=()=>{if(C||_===null)return;let e=uy(c,k,y),n=y===void 0||y===`harness`?void 0:y;w(!0),E(null),a({...t===void 0?{}:{atSeq:t},targetHarnessId:_,...n===void 0?{}:{targetModel:n},...e===void 0?{}:{targetThinkingOptionId:e}}).then(()=>{w(!1),o()},e=>{w(!1),E(e instanceof Error?e.message:String(e))})},re=!C&&u===`ready`&&_!==null;return/* @__PURE__ */ (0,f.jsx)(p.Modal,{open:e,onClose:C?()=>{}:o,closeLabel:s(`close`),title:s(`handoff.modal.title`),description:s(`handoff.modal.description`),className:X.dialog,footer:/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`outline`,className:X.modalAction,disabled:C,onClick:o,children:s(`cancel`)}),/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`primary`,className:X.modalAction,disabled:!re,onClick:ne,children:C?/* @__PURE__ */ (0,f.jsxs)(`span`,{className:X.submittingContent,children:[/* @__PURE__ */ (0,f.jsx)(p.StateDot,{state:`ongoing`}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:s(`handoff.modal.submitting`)})]}):s(`handoff.modal.confirm`)})]}),children:/* @__PURE__ */ (0,f.jsxs)(`div`,{className:X.sections,"data-handoff-modal":``,children:[u===`loading`&&c===null&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:X.status,role:`status`,children:[/* @__PURE__ */ (0,f.jsx)(p.StateDot,{state:`ongoing`}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:s(`handoff.modal.loadingCatalog`)})]}),u===`error`&&h!==null&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:X.errorBox,role:`alert`,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.errorText,children:s(`handoff.modal.catalogError`,{message:h})}),/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`outline`,size:`sm`,onClick:()=>void D(),children:s(`retry`)})]}),c!==null&&O.length===0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.empty,children:s(`handoff.modal.noHarnesses`)}),O.length>0&&/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:X.section,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.sectionLabel,children:s(`handoff.modal.targetHarness`)}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.harnessGrid,role:`radiogroup`,"aria-label":s(`handoff.modal.targetHarness`),children:O.map(e=>{let t=e.id===_;return/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,"data-selected":t||void 0,disabled:C,className:X.harnessOption,onClick:()=>te(e),children:[/* @__PURE__ */ (0,f.jsx)(Sh,{harnessId:e.id,label:e.name,size:16}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.harnessName,children:e.name}),t&&/* @__PURE__ */ (0,f.jsx)(p.IconCheckOutlineRegular,{size:14,className:X.checkIcon})]},e.id)})})]}),k!==void 0&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:X.section,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.sectionLabel,children:s(`handoff.modal.targetModel`)}),ee&&/* @__PURE__ */ (0,f.jsx)(p.Input,{className:X.searchInput,type:`text`,role:`searchbox`,placeholder:s(`handoff.modal.searchModels`),"aria-label":s(`handoff.modal.searchModels`),value:x,disabled:C,onChange:e=>{S(e.target.value)}}),k.models.length===0?/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.empty,children:s(`handoff.modal.noModels`)}):/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.modelList,role:`radiogroup`,"aria-label":s(`handoff.modal.targetModel`),children:j.length===0?/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.empty,children:s(`handoff.modal.noMatchingModels`)}):j.map(e=>{let t=e.id===y,n=e.id===A;return/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,"data-selected":t||void 0,disabled:C,className:X.modelOption,onClick:()=>{b(e.id),E(null)},children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:X.modelInfo,children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:X.modelTitleRow,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.modelName,children:e.name}),n&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.defaultBadge,children:s(`handoff.modal.defaultBadge`)})]}),e.description!==void 0&&e.description!==``&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.modelDesc,children:e.description})]}),t&&/* @__PURE__ */ (0,f.jsx)(p.IconCheckOutlineRegular,{size:14,className:X.checkIcon})]},e.id)})})]})]}),T!==null&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.errorBox,role:`alert`,children:/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.errorText,children:s(`handoff.modal.failed`,{message:T})})})]})})}function my(e,t,n){if(/^https?:/u.test(e)&&n!==``&&!/[\u0000-\u001f\u007f]/u.test(n))return new URL(`/api/remote-peer/file?sessionId=${encodeURIComponent(t)}&path=${encodeURIComponent(n)}`,e).href}function hy(e,t){let n=e instanceof Error?e.message:String(e);return n===``?t:n}function gy(e,t){let n=/* @__PURE__ */ new Set,r;for(let i of e){let e=t.get(i);if(e===void 0||e.kind!==`user`&&e.kind!==`steering`&&e.kind!==`turn-trigger`||((e.location.kind===`turn`||e.location.kind===`step`)&&(r=e.location.turn.turn),e.kind===`turn-trigger`))continue;let a=e.data.source;a?.kind===`user`&&typeof a.rpcId==`string`&&n.add(a.rpcId)}return{rpcIds:n,lastInputTurn:r}}let _y=(0,d.memo)(function({entries:e,useChatGroup:t,pendingInputs:n,lastInputTurn:r,virtualization:i,...a}){let o=i.active?i.registerRow:void 0,s=e.map((e,n)=>{let r=hv(e),s=i.isMounted(n,r),c=s?void 0:i.placeholderHeight(r,e.kind);switch(e.kind){case`node`:return/* @__PURE__ */ (0,d.createElement)(Lg,{...a,key:Wg(e),nodeKey:e.key,mounted:s,placeholderHeight:c,registerRow:o,...e.groupPart===void 0?{}:{groupPart:e.groupPart}});case`group`:return/* @__PURE__ */ (0,d.createElement)(c_,{...a,key:Wg(e),groupKey:e.key,useChatGroup:t,mounted:s,placeholderHeight:c,registerRow:o});default:return Ug(e)}}),c=n.map(e=>`requestId`in e?/* @__PURE__ */ (0,f.jsx)($h,{submission:e,renderMessageImages:a.renderMessageImages,t:a.t},e.requestId):/* @__PURE__ */ (0,f.jsx)(Qh,{content:e.content,renderMessageImages:a.renderMessageImages,t:a.t},e.id)),l=e.at(-1),u=l?.kind===`node`?a.nodeStore.get(l.key):void 0;if(u?.kind===`turn-process`&&u.location.kind===`turn`&&u.location.turn.status===`open`&&u.location.turn.turn!==r){let e=n.findIndex(e=>`requestId`in e&&e.placement===`transcript`);e!==-1&&s.splice(s.length-1,0,...c.splice(e,1))}return[...s,...c]});function vy({connection:e,useSession:t,useChat:n,useChatNode:r,useChatNodeProcess:i,useChatGroup:a,useConversation:o,useSessions:s,useStore:c,actions:l,renderSlot:u,sessionId:m,openFile:h,openSkill:g,openExternalLink:_,openLinkInSidebar:v,useBrowserAvailable:y,resolveLink:b,loadOlder:x,loadThrough:S,loadImage:C,inspectCall:w,chatScroll:T,forkAt:E,openSession:D,handoff:O,clearHandoffRequest:k,loadModelCatalog:A,loadTurnDiffs:ee,editMessage:j,fileMentions:ne,usePresentation:ie,useHandoffRequest:ae,useProjection:oe,useInput:se,inputActions:ce,viewRequest:le,completeViewRequest:ue,t:M}){let de=n(e=>e.order),fe=y(e=>e),pe=o(e=>e.views.grouped(`chat`)),me=o(e=>e.views.grouped(`chat`)?.entries),he=(0,d.useMemo)(()=>me??de.map(e=>({kind:`node`,key:e})),[me,de]),ge=n(e=>e.nodes),_e=n(e=>e.navigation.items()),ve=_e.at(-1)?.anchorKey,ye=r(ve??``,e=>{let t=e?.location;return(t?.kind===`turn`||t?.kind===`step`)&&t.turn.status===`open`?t.turn.start?.time:void 0}),be=oe(`turnOutline`),xe=(0,d.useMemo)(()=>Z_(_e,be),[_e,be]),Se=oe(`inbox`),N=s(e=>e.byId[m]?.cwd),Ce=s(e=>e.byId[m]?.projectionValues?.remoteHost?.hostId),we=s(e=>(e.byId[m]?.projectionValues)?.harnessIdentity?.id),P=s(e=>!!e.byId[m]?.projectionValues?.remoteHost),Te=s(e=>{let t=e.byId[m]?.projectionValues?.remoteHost;return t?.hostId.startsWith(`remote-peer:`)===!0&&t.filePreview===!0}),Ee=(0,d.useMemo)(()=>({resolve:e=>{if(Te)return my(document.baseURI,m,e);if(!P)return re(document.baseURI,te(N,e))},labels:{open:M(`image.open`),loading:M(`image.loading`),failed:M(`image.failed`),dialog:M(`image.dialog`),close:M(`image.close`)}}),[N,P,Te,m,M]),De=(0,d.useCallback)(e=>ce?.addResponseAnnotation(e,{focus:`end`})!==void 0,[ce]),Oe=t(e=>e.running),ke=t(e=>e.subagent),Ae=t(e=>e.removed),je=ce!==void 0&&!Ae&&(ke===null||ke.address.mode===`continuable`&&ke.parentAvailable===!0),[Me,Ne]=(0,d.useState)(null),Pe=(0,d.useSyncExternalStore)(e.state.subscribe,e.state.getSnapshot),Fe=(0,p.useSustainedRecovery)(Pe!==`connected`),Ie=oe(`compacting`),F=oe(`codexhostHandoff`),Le=ae(e=>e),[Re,ze]=(0,d.useState)(null),Be=Re?.sessionId===m?Re:null,Ve=(0,d.useCallback)(e=>{ze({sessionId:m,atSeq:e})},[m]),He=(0,d.useCallback)(()=>{ze(null)},[]),Ue=O!==void 0&&A!==void 0;(0,d.useEffect)(()=>{Le!==null&&Le.sessionId===m&&Ue&&(ze({sessionId:m,...Le.atSeq===void 0?{}:{atSeq:Le.atSeq},...Le.targetHarnessId===void 0?{}:{initialHarnessId:Le.targetHarnessId}}),k(Le.seq))},[k,Ue,Le,m]);let We=t(e=>e.openState),Ge=oe(`remoteHistoryError`),Ke=oe(`nativeConnection`),qe=Pe===`disconnected`||Fe||We===`error`||!!Ge||Ke?.state===`reconnecting`,Je=t(e=>e.openError),Ye=t(e=>e.hasMore),Xe=t(e=>e.loadingOlder),Ze=t(e=>e.olderError),[Qe,$e]=(0,d.useState)(null),[et,tt]=(0,d.useState)(!1),nt=(0,d.useRef)(0),rt=(0,d.useCallback)((e,t)=>{let n=++nt.current;tt(!0),(t===void 0?h(e):h(e,t)).then(()=>{n===nt.current&&($e(null),tt(!1))},r=>{n===nt.current&&($e({path:e,options:t,message:hy(r,M(t?.reveal?`fileOpen.folder`:`fileOpen.unknown`))}),tt(!1))})},[h,M]),it=(0,d.useCallback)(()=>{nt.current+=1,$e(null),tt(!1)},[]),at=(0,d.useMemo)(()=>Se?.[`next-step`].filter(e=>e.source.kind===`user`)??[],[Se]),ot=t(e=>e.pendingSubmissions),st=Vh(j,oe(`sentMessageEdit`)?.seq??null,We!==`open`||Oe||ot.length>0||(Se?.[`next-turn`].length??0)>0),ct=st.draft&&de.some(e=>{let t=ge.get(e);return t?.kind===`user`&&t.data.seq===st.draft?.seq}),lt=Oe||ot.some(e=>e.placement!==`queued`),[ut,dt]=(0,d.useMemo)(()=>{if(ot.length===0)return[ot,void 0];let e=gy(de,ge);return[ot.filter(t=>t.placement!==`queued`&&!e.rpcIds.has(t.requestId)),e.lastInputTurn]},[ot,de,ge]),ft=(0,d.useMemo)(()=>{let e=new Map(ut.map(e=>[e.requestId,e])),t=new Set(ot.filter(e=>e.placement!==`queued`).map(e=>e.requestId));return[...at.flatMap(n=>{let r=n.source;if(r.kind!==`user`||!(`rpcId`in r))return[n];let i=e.get(r.rpcId);return i===void 0?t.has(r.rpcId)?[]:[n]:(e.delete(r.rpcId),[i])}),...e.values()]},[at,ot,ut]),pt=(0,d.useCallback)(e=>u(`conversation.message.images`,{...e,loadImage:C}),[C,u]),mt=de[0],ht=mt===void 0?null:ge.get(mt)?.anchorSeq??null,gt=de.at(-1)??null,I=ft.findLast(e=>`source`in e),_t=I?.source.kind===`user`&&`rpcId`in I.source?I.source.rpcId:I?.id??null,vt=ov({displayReady:We===`open`||de.length>0,historyReady:We===`open`,order:de,firstSeq:ht,lastKey:gt,running:Oe,loadingOlder:Xe,olderFailed:Ze!=null,hasMore:Ye,chatScroll:T,loadOlder:x,loadThrough:S,lastIsUser:gt!==null&&ge.get(gt)?.kind===`user`,steeringId:_t,submissionId:ut.at(-1)?.requestId??null,loadedTurns:_e}),yt=se(e=>e.responseAnnotations.find(e=>e.id===le?.focus)),bt=(0,d.useMemo)(()=>{let e=st.draft?.seq;if(e===void 0)return null;for(let t of he){if(t.kind!==`node`)continue;let n=ge.get(t.key);if(n?.kind===`user`&&n.data.seq===e)return hv(t)}return null},[he,st.draft?.seq,ge]),xt=(0,d.useMemo)(()=>Me===null?null:_v(Me,he,pe),[Me,he,pe]),St=(0,d.useMemo)(()=>le?.view===`chat`&&yt?.anchor!==void 0?_v(yt.anchor.answerKey,he,pe):null,[yt?.anchor,he,pe,le?.view]),{initialized:Ct,revealResponseAnnotation:L}=vt,wt=(0,d.useMemo)(()=>{if(Ct)return null;let e=T.read();return e===null?null:vv(e.anchorKey)},[T,Ct,m]),Tt=Fv({sessionId:m,entries:he,nodeStore:ge,groupedView:pe,listRef:vt.listRef,columnRef:vt.columnRef,followingTail:vt.followingTail,editingFlowKey:bt,composingFlowKey:xt,revealTargetFlowKey:St,savedAnchorFlowKey:wt,busyTurn:vt.busyTurn,onTailScrollClamp:vt.reconcileTail,onScrollCompensated:vt.adjustBaseline}),Et=(0,d.useRef)(null),Dt=!Ye&&F!=null;bg(Et,Dt);let[Ot,kt]=(0,d.useState)(null),At=Ot?.sessionId===m?Ot.item:null,jt=(0,d.useCallback)(e=>{let t=e.anchor.kind===`loaded`?e.anchor.key:null;Tt.pinNavigationTarget({turn:e.turn,anchorKey:t}),e.anchor.kind===`loaded`&&Tt.active&&t!==null&&!Tt.isAnchorMounted(t)?kt({sessionId:m,item:e}):(kt(null),vt.navigateToTurn(e))},[vt,m,Tt]),Mt=(0,d.useCallback)(()=>{kt(null),Tt.clearNavigationPin(),vt.returnToBottom()},[vt,Tt]);return(0,d.useLayoutEffect)(()=>{At!==null&&(kt(null),vt.navigateToTurn(At))},[At,vt]),(0,d.useLayoutEffect)(()=>{if(Ct&&le?.view===`chat`){if(St!==null){Tt.pinNavigationTarget({turn:null,anchorKey:St});let e=he.some(e=>hv(e)===St||e.kind===`node`&&e.key===St);if(Tt.active&&e&&!Tt.isAnchorMounted(St))return}yt!==void 0&&L(yt),ue()}},[Ct,le,yt,he,L,St,ue,Tt]),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Dg.frame,children:[vt.initialized&&/* @__PURE__ */ (0,f.jsx)(B_,{items:xe,activeTurn:vt.activeTurn,busyTurn:vt.busyTurn,onNavigate:jt,t:M}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:Dg.root,"data-chat-following-tail":vt.followingTail?``:void 0,"data-chat-virtualizing":Tt.active?``:void 0,children:/* @__PURE__ */ (0,f.jsx)(`div`,{ref:vt.listRef,className:Dg.scroll,children:/* @__PURE__ */ (0,f.jsxs)(`div`,{ref:vt.columnRef,className:Dg.column,"data-chat-flow":``,children:[We===`loading`&&de.length===0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:Dg.hint,children:M(`chat.loadingHistory`)}),We===`error`&&Je!==null&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:Dg.openError,children:M(`chat.loadError`,{message:Je.message,code:Je.code})}),Ye&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:Dg.older,children:Ze==null?/* @__PURE__ */ (0,f.jsx)(`span`,{role:Xe?`status`:void 0,children:M(Xe?`chat.loadingOlder`:`chat.scrollOlder`)}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{role:`alert`,children:M(`chat.loadOlderError`,{message:Ze.message})}),/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,disabled:Xe,onClick:vt.loadEarlier,children:M(`chat.retryOlder`)})]})}),Dt&&/* @__PURE__ */ (0,f.jsx)(`div`,{ref:Et,"data-chat-near-viewport-gate":``,children:/* @__PURE__ */ (0,f.jsx)(sy,{handoff:F,hostId:Ce,onOpenSource:D,t:M})}),/* @__PURE__ */ (0,f.jsx)(iy,{openExternalLink:_,openLinkInSidebar:fe?v:void 0,hideLocalFileActions:P,resolveLink:b,openFile:rt,fileImages:Ee,t:M,children:/* @__PURE__ */ (0,f.jsx)(_y,{entries:he,pendingInputs:ft,lastInputTurn:dt,nodeStore:ge,useChatGroup:a,useChatNode:r,useChatNodeProcess:i,usePresentation:ie,useStore:c,actions:l,cwd:N,openFile:rt,openSkill:g,inspectCall:w,forkAt:E,handoffAt:Ue?Ve:void 0,loadTurnDiffs:ee,messageEditing:st,loadImage:C,renderMessageImages:pt,fileMentions:ne,renderSlot:u,virtualization:Tt,t:M})},m),st.draft&&!ct&&/* @__PURE__ */ (0,f.jsx)(tg,{editing:st,renderMessageImages:pt,t:M}),lt&&/* @__PURE__ */ (0,f.jsx)(W_,{startTime:ye,compacting:Ie,stale:qe,t:M}),We===`loading`&&de.length>0&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Dg.syncing,role:`status`,"data-history-syncing":!0,children:[/* @__PURE__ */ (0,f.jsx)(p.StateDot,{state:`ongoing`,className:Dg.syncingIcon}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:M(`chat.syncing`)})]})]})})}),je&&/* @__PURE__ */ (0,f.jsx)(ty,{labels:{addToChat:M(`selection.addToChat`),comment:M(`selection.comment`),placeholder:M(`selection.commentPlaceholder`),submit:M(`selection.commentSubmit`),cancel:M(`message.edit.cancel`),unavailable:M(`selection.commentUnavailable`)},onAdd:De,container:vt.columnRef,onComposingAnswerChange:Ne},m),!vt.followingTail&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:Dg.toBottomSlot,children:/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Dg.toBottom,"aria-label":M(`chat.toBottom`),onClick:Mt,children:/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{})})}),Be!==null&&O!==void 0&&A!==void 0&&/* @__PURE__ */ (0,f.jsx)(py,{open:!0,atSeq:Be.atSeq,currentHarnessId:we,initialHarnessId:Be.initialHarnessId,loadModelCatalog:A,onSubmit:O,onClose:He,t:M},`${m}:${Be.atSeq??`latest`}:${Be.initialHarnessId??`auto`}`),Qe!==null&&/* @__PURE__ */ (0,f.jsx)(yy,{title:M(Qe.options?.reveal?`fileOpen.folder`:`fileOpen.title`),message:Qe.message,busy:et,onClose:it,onRetry:()=>{rt(Qe.path,Qe.options)},t:M})]})}function yy({title:e,message:t,busy:n,onClose:r,onRetry:i,t:a}){return/* @__PURE__ */ (0,f.jsx)(p.Modal,{open:!0,onClose:r,closeLabel:a(`close`),title:e,description:t,footer:/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`outline`,className:Dg.modalAction,onClick:r,children:a(`cancel`)}),/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`primary`,className:Dg.modalAction,disabled:n,onClick:i,children:a(`retry`)})]})})}let by=`chat`,xy={"message.stepProcess.thinking":`正在分析请求`,"message.stepProcess.read":`正在读取文件`,"message.stepProcess.readImage":`正在读取图片`,"message.stepProcess.write":`正在写入文件`,"message.stepProcess.search":`正在搜索代码`,"message.stepProcess.edit":`正在编辑文件`,"message.stepProcess.commands":`正在运行命令`,"message.stepProcess.code":`正在运行代码`,"message.stepProcess.webSearch":`正在搜索网页`,"message.stepProcess.webFetch":`正在访问网页`,"message.stepProcess.subagents":`正在协调子智能体`,"message.stepProcess.plan":`正在更新计划`,"message.stepProcess.questions":`等待你的操作`,"message.stepProcess.tools":`正在调用工具`,"message.stepProcess.prepare.read":`准备读取文件`,"message.stepProcess.prepare.readImage":`准备读取图片`,"message.stepProcess.prepare.write":`准备写入文件`,"message.stepProcess.prepare.search":`准备搜索代码`,"message.stepProcess.prepare.edit":`准备编辑文件`,"message.stepProcess.prepare.commands":`准备运行命令`,"message.stepProcess.prepare.code":`准备运行代码`,"message.stepProcess.prepare.webSearch":`准备搜索网页`,"message.stepProcess.prepare.webFetch":`准备访问网页`,"message.stepProcess.prepare.subagents":`准备协调子智能体`,"message.stepProcess.prepare.plan":`准备更新计划`,"message.stepProcess.prepare.questions":`准备提问`,"message.stepProcess.prepare.tools":`准备调用工具`,"message.stepProcess.done.thinking":`已完成分析`,"message.stepProcess.done.read":`已读取文件`,"message.stepProcess.done.readImage":`已读取图片`,"message.stepProcess.done.write":`已写入文件`,"message.stepProcess.done.search":`已搜索代码`,"message.stepProcess.done.edit":`修改了文件`,"message.stepProcess.done.commands":`执行了命令`,"message.stepProcess.done.code":`运行了代码`,"message.stepProcess.done.webSearch":`已搜索网页`,"message.stepProcess.done.webFetch":`已访问网页`,"message.stepProcess.done.subagents":`已协调子智能体`,"message.stepProcess.done.plan":`更新了计划`,"message.stepProcess.done.questions":`向用户提出了问题`,"message.stepProcess.done.tools":`已调用工具`,"message.stepProcess.joinTwo":`{first}并{second}`,"message.stepProcess.comma":`,`,"message.stepProcess.sharedPrefix":`已`,"message.stepProcess.more":`{title}等`,"message.trigger.request":`收到执行请求`,"message.trigger.goal":`继续执行目标`,"message.trigger.agent":`收到任务消息`,"message.trigger.team":`收到团队消息`,"message.trigger.subagent":`子任务状态更新`,"message.trigger.github":`收到 GitHub 事件`,"message.trigger.webhook":`收到外部事件`,"message.trigger.schedule":`自动化任务`,"message.trigger.job":`后台任务状态更新`,"message.trigger.plugin":`插件状态更新`,"message.trigger.explanation":`这条通知触发了本轮回复。`,"message.turnProcess.worked":`已完成`,"message.turnProcess.unknown":`已结束`,"message.turnProcess.took":`已完成,用时 `,"message.turnProcess.failed":`处理失败`,"view.chat":`对话`,"image.open":`查看大图`,"image.loading":`加载图片…`,"image.failed":`图片无法预览`,"image.dialog":`图片预览`,"image.close":`关闭图片预览`,"message.imageViews.one":`已查看 1 张图像`,"message.imageViews.many":`已查看 {count} 张图像`,"duration.milliseconds":`{milliseconds}毫秒`,"chat.loadingHistory":`载入历史…`,"selection.addToChat":`添加到对话`,"selection.comment":`添加批注`,"selection.commentPlaceholder":`写下你的批注…`,"selection.commentSubmit":`添加`,"selection.commentUnavailable":`当前无法添加批注,请稍后重试。`,"annotation.label":`批注 {index}`,"annotation.chipLabel":`{index}.`,"annotation.title":`批注 {index}:{excerpt}`,"annotation.remove":`移除批注 {index}`,"annotation.removeAction":`移除`,"annotation.save":`保存`,"annotation.selectedText":`选中文字:`,"annotation.userComment":`你的批注:`,"chat.syncing":`正在获取最新消息…`,"chat.loadingDiff":`载入差异…`,"chat.retryDiff":`重试`,"chat.loadError":`历史加载失败:{message}({code})`,"chat.loadOlder":`加载更早`,"chat.scrollOlder":`向上滚动查看更早消息`,"chat.loadingOlder":`正在加载更早消息…`,"chat.loadOlderError":`更早消息加载失败:{message}`,"chat.retryOlder":`重试加载`,"chat.toBottom":`回到底部`,"chat.filesChanged":`{count} 个文件已更改`,"chat.fileEdited":`已编辑 {name}`,"chat.filesEdited":`已编辑 {count} 个文件`,"chat.viewChanges":`查看变更`,"chat.hideChanges":`收起变更`,"chat.openFile":`打开 {path}`,"chat.showMoreFiles":`再显示 {count} 个文件`,"chat.collapseFiles":`收起文件`,"diff.code":`代码`,"diff.wrap":`自动换行`,"diff.unwrap":`取消换行`,"diff.copy":`复制`,"diff.copied":`已复制`,"diff.collapseAria":`折叠差异`,"diff.expandAria":`展开 {count} 行隐藏内容`,"diff.collapse":`折叠`,"diff.expand":`展开 {count} 行`,"codeBlock.expand":`展开全部(共 {count} 行)`,"codeBlock.collapse":`收起代码`,"chat.deepDiving":`正在处理`,"chat.statusUnconfirmed":`任务状态待确认`,"chat.deepDivingFor":`正在处理 · {duration}`,"chat.turnNavigation.label":`轮次导航`,"chat.turnNavigation.jump":`跳转到用户消息 {turn}`,"chat.turnNavigation.jumpLoad":`加载并跳转到用户消息 {turn}`,"chat.turnNavigation.turn":`用户消息 {turn}`,"settings.links.title":`网页链接默认打开方式`,"settings.links.description":`对话中网页链接的打开位置`,"settings.links.sidebar":`应用内侧边栏`,"settings.links.newTab":`默认浏览器`,"settings.transcript.title":`工作步骤展示`,"settings.transcript.description":`选择希望看到多少工具调用细节`,"settings.transcript.compact":`简洁`,"settings.transcript.standard":`标准`,"settings.transcript.detailed":`详细`,"settings.transcript.verbose":`完全展开`,"fileOpen.title":`无法打开文件`,"fileOpen.folder":`无法打开所在文件夹`,"fileOpen.unknown":`无法打开此文件`,"linkMenu.copy":`复制链接`,"linkMenu.copyFailed":`无法复制链接`,"linkMenu.openBrowser":`在浏览器中打开`,"linkMenu.openFile":`用默认应用打开`,"linkMenu.openFolder":`打开所在文件夹`,"linkMenu.openInCodexhost":`在 codexhost 中打开`,"message.watch.completed":`已完成`,"message.watch.failed":`失败`,"message.watch.interrupted":`已中断`,"message.watch.timedOut":`监听已到期`,"message.watch.unreadable":`状态未知`,"message.watch.notFound":`会话不存在`,"message.watch.open":`打开会话`,"message.extraBlock":`附加内容块`,"message.uploading":`上传中…`,"message.uploadingPercent":`上传中 {percent}%`,"message.systemPrompt":`系统提示词`,"message.systemPromptUpdate":`系统提示词更新`,"message.toolAdded":`已添加工具:{name}`,"message.toolRemoved":`已移除工具:{name}`,"message.toolsAdded":`新增:{names}`,"message.toolsAddedCount":`新增 {count} 个`,"message.toolsChanged":`新增 {added} 个,移除 {removed} 个`,"message.toolsRemoved":`移除:{names}`,"message.toolsRemovedCount":`移除 {count} 个`,"message.toolsUpdated":`工具已更新`,"message.contextInjection":`上下文注入`,"message.contextRecall":`跨会话召回`,"message.referenceSummary":`引用会话 · {labels}`,"message.referenceSeparator":`、`,"message.context.instructions.loaded":`已载入`,"message.context.instructions.added":`已新增`,"message.context.instructions.updated":`已更新`,"message.context.instructions.removed":`已移除`,"message.context.catalog.replaced":`替换目录`,"message.context.catalog.more":`…还有 {count} 条`,"message.context.snapshot.supersedes":`取代先前的快照`,"message.context.relay.from":`来自会话 {session}`,"message.context.recall.counts":`保留 {retained} 条 · 省略 {omitted} 条`,"message.context.recall.truncated":`已截断`,"message.compaction":`上下文已压缩`,"message.compaction.running":`正在压缩…`,"message.compaction.completed":`已压缩 {items} 条历史记录(约 {tokens} tokens)`,"message.compaction.expand":`点击查看压缩摘要`,"message.compaction.unavailable":`压缩摘要不可用`,"message.compaction.commandTitle":`compact`,"message.think":`思考`,"message.unknownSurface":`未知 surface 事件:{type}`,"message.unknownBlock":`未知内容块`,"message.turnProcess.toolCalls.one":`{count} 次工具调用`,"message.turnProcess.toolCalls.other":`{count} 次工具调用`,"message.turnProcess.messages.one":`{count} 条消息`,"message.turnProcess.messages.other":`{count} 条消息`,"message.turnProcess.subagents.one":`{count} 个 subagent`,"message.turnProcess.subagents.other":`{count} 个 subagent`,"message.turnProcess.thoughtForAWhile":`已思考`,"message.turnProcess.separator":` · `,"message.stopped":`已停止`,"message.edit":`编辑消息`,"message.edit.changed":`会话状态已变化,请核对当前历史后继续。`,"message.edit.cancel":`取消`,"message.edit.send":`发送`,"message.edit.sending":`正在回退并重跑…`,"message.edit.checkHistory":`请核对当前历史后再继续;编辑文本已保留,不会自动重发。`,"message.branch":`在新对话中分支`,"message.branchFailed":`分叉未完成:{message}`,"message.branchUnavailable":`仅可从已完成轮次的最后一条消息分支`,"message.handoff":`上下文交接`,"message.handoffUnavailable":`仅可从已完成轮次的最后一条消息交接`,"handoff.divider.label":`上下文交接`,"handoff.divider.expand":`展开上下文交接详情`,"handoff.divider.collapse":`收起上下文交接详情`,"handoff.divider.turnsAll":`已携带全部 {total} 轮对话`,"handoff.divider.turnsPrefix":`已携带前 {boundary} / {total} 轮对话`,"handoff.divider.turnsPartial":`已携带 {included} / {total} 轮对话(省略 {omitted} 轮,截至第 {boundary} 轮)`,"handoff.divider.openSource":`跳回源会话`,"handoff.divider.previewEmpty":`暂无交接上下文预览`,"handoff.modal.title":`上下文交接`,"handoff.modal.description":`将当前对话上下文整理并交接到新的会话中继续处理。`,"handoff.modal.targetHarness":`目标 Agent`,"handoff.modal.targetModel":`模型`,"handoff.modal.searchModels":`搜索模型…`,"handoff.modal.noModels":`该 Agent 未提供可选模型,将使用默认配置`,"handoff.modal.noHarnesses":`暂无可用的目标 Agent`,"handoff.modal.noMatchingModels":`没有匹配的模型`,"handoff.modal.loadingCatalog":`正在加载可用 Agent 与模型…`,"handoff.modal.catalogError":`加载模型目录失败:{message}`,"handoff.modal.confirm":`确认交接`,"handoff.modal.submitting":`正在交接…`,"handoff.modal.failed":`交接失败:{message}`,"handoff.modal.defaultBadge":`默认`,"message.retry.active":`正在重试模型请求`,"message.retry.cancelled":`模型请求重试已取消`,"message.retry.started":`已重试模型请求`,"message.retry.scheduled":`等待重试模型请求`,"message.retry.status":`{label}({retry}/{maximum}) · {seconds}s`,"message.retry.delay":`重试延迟:`,"message.retry.failure":`失败原因:`,"message.failure.auth":`API 密钥无效`,"message.accountStopped":`任务已停止`,"message.failure.accountSignedOut":`任务已因退出 DeepSeek 登录而停止。`,"message.failure.accountSignInRequired":`请先登录 DeepSeek,并确认请求地址支持账号认证。`,"message.failure.quota":`当前请求的额度已用尽`,"message.turnError":`本轮运行失败`,"message.maxTokens":`已达到输出 token 上限`,"message.maxTokens.hint":`回答被截断,已有输出保留在对话中。发送“继续”可让模型接着输出。`,"duration.secondUnit":`秒`,"duration.minuteUnit":`分`,"duration.hourUnit":`小时`,"command.running":`执行中…`,"command.failed":`指令失败`,"command.done":`已完成`,"command.title":`指令`,"row.running":`运行中`,"row.failed":`失败`,"json.truncated":`… 已截断,共 {total} 字符`,"clock.md":`{m}月{d}日`,"clock.ymd":`{y}年{m}月{d}日`},Sy={"message.stepProcess.thinking":`Analyzing the request`,"message.stepProcess.read":`Reading files`,"message.stepProcess.readImage":`Reading images`,"message.stepProcess.write":`Writing files`,"message.stepProcess.search":`Searching code`,"message.stepProcess.edit":`Editing files`,"message.stepProcess.commands":`Running commands`,"message.stepProcess.code":`Running code`,"message.stepProcess.webSearch":`Searching the web`,"message.stepProcess.webFetch":`Visiting web pages`,"message.stepProcess.subagents":`Coordinating subagents`,"message.stepProcess.plan":`Updating the plan`,"message.stepProcess.questions":`Waiting for your action`,"message.stepProcess.tools":`Calling tools`,"message.stepProcess.prepare.read":`Preparing to read files`,"message.stepProcess.prepare.readImage":`Preparing to read images`,"message.stepProcess.prepare.write":`Preparing to write files`,"message.stepProcess.prepare.search":`Preparing to search code`,"message.stepProcess.prepare.edit":`Preparing to edit files`,"message.stepProcess.prepare.commands":`Preparing to run commands`,"message.stepProcess.prepare.code":`Preparing to run code`,"message.stepProcess.prepare.webSearch":`Preparing to search the web`,"message.stepProcess.prepare.webFetch":`Preparing to visit web pages`,"message.stepProcess.prepare.subagents":`Preparing to coordinate subagents`,"message.stepProcess.prepare.plan":`Preparing to update the plan`,"message.stepProcess.prepare.questions":`Preparing questions`,"message.stepProcess.prepare.tools":`Preparing tool calls`,"message.stepProcess.done.thinking":`Analysis completed`,"message.stepProcess.done.read":`Read files`,"message.stepProcess.done.readImage":`Read images`,"message.stepProcess.done.write":`Wrote files`,"message.stepProcess.done.search":`Searched code`,"message.stepProcess.done.edit":`Edited files`,"message.stepProcess.done.commands":`Ran commands`,"message.stepProcess.done.code":`Ran code`,"message.stepProcess.done.webSearch":`Searched the web`,"message.stepProcess.done.webFetch":`Visited web pages`,"message.stepProcess.done.subagents":`Coordinated subagents`,"message.stepProcess.done.plan":`Updated the plan`,"message.stepProcess.done.questions":`Asked questions`,"message.stepProcess.done.tools":`Called tools`,"message.stepProcess.joinTwo":`{first} and {second}`,"message.stepProcess.comma":`, `,"message.stepProcess.sharedPrefix":``,"message.stepProcess.more":`{title}, etc.`,"message.trigger.request":`Execution requested`,"message.trigger.goal":`Continuing goal`,"message.trigger.agent":`Task message received`,"message.trigger.team":`Team message received`,"message.trigger.subagent":`Subtask status updated`,"message.trigger.github":`GitHub event received`,"message.trigger.webhook":`External event received`,"message.trigger.schedule":`Automation task`,"message.trigger.job":`Background task updated`,"message.trigger.plugin":`Plugin status updated`,"message.trigger.explanation":`This notification triggered this response.`,"message.turnProcess.worked":`Completed`,"message.turnProcess.unknown":`Ended`,"message.turnProcess.took":`Completed in `,"message.turnProcess.failed":`Failed`,"view.chat":`Chat`,"image.open":`View full image`,"image.loading":`Loading image…`,"image.failed":`Image preview unavailable`,"image.dialog":`Image preview`,"image.close":`Close image preview`,"message.imageViews.one":`Viewed 1 image`,"message.imageViews.many":`Viewed {count} images`,"duration.milliseconds":`{milliseconds}ms`,"chat.loadingHistory":`Loading history…`,"selection.addToChat":`Add to chat`,"selection.comment":`Add comment`,"selection.commentPlaceholder":`Add a comment…`,"selection.commentSubmit":`Add`,"selection.commentUnavailable":`Could not add the comment. Try again in a moment.`,"annotation.label":`Annotation {index}`,"annotation.chipLabel":`{index}.`,"annotation.title":`Annotation {index}: {excerpt}`,"annotation.remove":`Remove annotation {index}`,"annotation.removeAction":`Remove`,"annotation.save":`Save`,"annotation.selectedText":`Selected text:`,"annotation.userComment":`Your comment:`,"chat.syncing":`Fetching latest messages…`,"chat.loadingDiff":`Loading diff…`,"chat.retryDiff":`Retry`,"chat.loadError":`Failed to load history: {message} ({code})`,"chat.loadOlder":`Load earlier`,"chat.scrollOlder":`Scroll up for earlier messages`,"chat.loadingOlder":`Loading earlier messages…`,"chat.loadOlderError":`Could not load earlier messages: {message}`,"chat.retryOlder":`Retry loading`,"chat.toBottom":`Back to bottom`,"chat.filesChanged":`{count} files changed`,"chat.fileEdited":`Edited {name}`,"chat.filesEdited":`Edited {count} files`,"chat.viewChanges":`View changes`,"chat.hideChanges":`Hide changes`,"chat.openFile":`Open {path}`,"chat.showMoreFiles":`Show {count} more`,"chat.collapseFiles":`Collapse files`,"diff.code":`Code`,"diff.wrap":`Wrap lines`,"diff.unwrap":`Unwrap lines`,"diff.copy":`Copy`,"diff.copied":`Copied`,"diff.collapseAria":`Collapse diff`,"diff.expandAria":`Expand {count} hidden lines`,"diff.collapse":`Collapse`,"diff.expand":`Expand {count} lines`,"codeBlock.expand":`Expand all ({count} lines)`,"codeBlock.collapse":`Collapse code`,"chat.deepDiving":`Working`,"chat.statusUnconfirmed":`Task status unconfirmed`,"chat.deepDivingFor":`Working · {duration}`,"chat.turnNavigation.label":`Turn navigation`,"chat.turnNavigation.jump":`Jump to user message {turn}`,"chat.turnNavigation.jumpLoad":`Load and jump to user message {turn}`,"chat.turnNavigation.turn":`User message {turn}`,"settings.links.title":`Open chat links in`,"settings.links.description":`Choose where to open web links`,"settings.links.sidebar":`In-App Sidebar`,"settings.links.newTab":`Default Browser`,"settings.transcript.title":`Work details`,"settings.transcript.description":`Choose how much detail to show for tool calls`,"settings.transcript.compact":`Compact`,"settings.transcript.standard":`Standard`,"settings.transcript.detailed":`Detailed`,"settings.transcript.verbose":`Verbose`,"fileOpen.title":`Couldn’t open file`,"fileOpen.folder":`Couldn’t open containing folder`,"fileOpen.unknown":`Couldn’t open this file`,"linkMenu.copy":`Copy link`,"linkMenu.copyFailed":`Couldn’t copy link`,"linkMenu.openBrowser":`Open in browser`,"linkMenu.openFile":`Open in default app`,"linkMenu.openFolder":`Open containing folder`,"linkMenu.openInCodexhost":`Open in codexhost`,"message.watch.completed":`Completed`,"message.watch.failed":`Failed`,"message.watch.interrupted":`Interrupted`,"message.watch.timedOut":`Watch expired`,"message.watch.unreadable":`State unknown`,"message.watch.notFound":`Session not found`,"message.watch.open":`Open session`,"message.extraBlock":`Extra content block`,"message.uploading":`Uploading…`,"message.uploadingPercent":`Uploading {percent}%`,"message.systemPrompt":`System prompt`,"message.systemPromptUpdate":`System prompt update`,"message.toolAdded":`Tool added: {name}`,"message.toolRemoved":`Tool removed: {name}`,"message.toolsAdded":`Added: {names}`,"message.toolsAddedCount":`{count} added`,"message.toolsChanged":`{added} added, {removed} removed`,"message.toolsRemoved":`Removed: {names}`,"message.toolsRemovedCount":`{count} removed`,"message.toolsUpdated":`Tools updated`,"message.contextInjection":`Context injection`,"message.contextRecall":`Session recall`,"message.referenceSummary":`Referenced session · {labels}`,"message.referenceSeparator":`, `,"message.context.instructions.loaded":`loaded`,"message.context.instructions.added":`added`,"message.context.instructions.updated":`updated`,"message.context.instructions.removed":`removed`,"message.context.catalog.replaced":`Replacement catalog`,"message.context.catalog.more":`… {count} more`,"message.context.snapshot.supersedes":`Supersedes earlier snapshots`,"message.context.relay.from":`From session {session}`,"message.context.recall.counts":`{retained} kept · {omitted} omitted`,"message.context.recall.truncated":`truncated`,"message.compaction":`Context compacted`,"message.compaction.running":`Compacting context…`,"message.compaction.completed":`Compacted {items} history items (~{tokens} tokens)`,"message.compaction.expand":`View compaction summary`,"message.compaction.unavailable":`Compaction summary unavailable`,"message.compaction.commandTitle":`compact`,"message.think":`Think`,"message.unknownSurface":`Unknown surface event: {type}`,"message.unknownBlock":`Unknown content block`,"message.turnProcess.toolCalls.one":`{count} tool call`,"message.turnProcess.toolCalls.other":`{count} tool calls`,"message.turnProcess.messages.one":`{count} message`,"message.turnProcess.messages.other":`{count} messages`,"message.turnProcess.subagents.one":`{count} subagent`,"message.turnProcess.subagents.other":`{count} subagents`,"message.turnProcess.thoughtForAWhile":`Thought for a while`,"message.turnProcess.separator":` · `,"message.stopped":`Stopped`,"message.edit":`Edit message`,"message.edit.changed":`Conversation state changed. Check current history before continuing.`,"message.edit.cancel":`Cancel`,"message.edit.send":`Send`,"message.edit.sending":`Reverting and rerunning…`,"message.edit.checkHistory":`Check current history before continuing. Your edit is retained and will not be resent automatically.`,"message.branch":`Branch into a new conversation`,"message.branchFailed":`Fork did not complete: {message}`,"message.branchUnavailable":`Available only on the last message of a completed turn`,"message.handoff":`Hand off context`,"message.handoffUnavailable":`Available only on the last message of a completed turn`,"handoff.divider.label":`Context handoff`,"handoff.divider.expand":`Expand context handoff details`,"handoff.divider.collapse":`Collapse context handoff details`,"handoff.divider.turnsAll":`Carried all {total} turns`,"handoff.divider.turnsPrefix":`Carried first {boundary} of {total} turns`,"handoff.divider.turnsPartial":`Carried {included} of {total} turns ({omitted} omitted, up to turn {boundary})`,"handoff.divider.openSource":`Open source session`,"handoff.divider.previewEmpty":`No handoff context preview available`,"handoff.modal.title":`Context handoff`,"handoff.modal.description":`Package the current conversation context and continue in a new session.`,"handoff.modal.targetHarness":`Target Agent`,"handoff.modal.targetModel":`Model`,"handoff.modal.searchModels":`Search models…`,"handoff.modal.noModels":`No selectable models — default configuration will be used`,"handoff.modal.noHarnesses":`No available target Agents`,"handoff.modal.noMatchingModels":`No matching models`,"handoff.modal.loadingCatalog":`Loading available Agents and models…`,"handoff.modal.catalogError":`Failed to load model catalog: {message}`,"handoff.modal.confirm":`Hand off`,"handoff.modal.submitting":`Handing off…`,"handoff.modal.failed":`Handoff failed: {message}`,"handoff.modal.defaultBadge":`Default`,"message.retry.active":`Retrying model request`,"message.retry.cancelled":`Model request retry cancelled`,"message.retry.started":`Retried model request`,"message.retry.scheduled":`Waiting to retry model request`,"message.retry.status":`{label} ({retry}/{maximum}) · {seconds}s`,"message.retry.delay":`Retry delay: `,"message.retry.failure":`Failure reason: `,"message.failure.auth":`API key is invalid`,"message.accountStopped":`Task stopped`,"message.failure.accountSignedOut":`Stopped because you signed out of DeepSeek.`,"message.failure.accountSignInRequired":`Sign in to DeepSeek and ensure the request destination supports account authentication.`,"message.failure.quota":`Request quota exhausted.`,"message.turnError":`This turn failed`,"message.maxTokens":`Output token limit reached`,"message.maxTokens.hint":`The reply was cut off; earlier output is preserved in the conversation. Send "continue" to let the model resume.`,"duration.secondUnit":`s`,"duration.minuteUnit":`m `,"duration.hourUnit":`h `,"command.running":`Running…`,"command.failed":`Command failed`,"command.done":`Completed`,"command.title":`Command`,"row.running":`Running`,"row.failed":`Failed`,"json.truncated":`… truncated, {total} characters total`,"clock.md":`{m}/{d}`,"clock.ymd":`{y}-{m}-{d}`},Cy=`@deepseek-ai/dsh-client-ui-chat/ReasoningRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Cy)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Cy,e.textContent=`.akEvLW_root{flex-direction:column;display:flex}.akEvLW_root:not([data-expanded]){contain:size layout;height:calc(24px + var(--dsh-content-font-delta,0px))}.akEvLW_row{overflow:hidden}.akEvLW_root[data-expanded] [data-open] [data-disclosure-row]{z-index:1;background:var(--dsw-alias-bg-base);position:sticky;top:0}body[data-codexhost-wallpaper] .akEvLW_root[data-expanded] [data-open] [data-disclosure-row]{background:color-mix(in srgb, var(--dsw-alias-bg-base) 76%, transparent);backdrop-filter:blur(12px);border-radius:var(--dsw-radius-sm,8px)}body[data-codexhost-wallpaper] [data-chat-flow-key]:not([data-chat-flow-key] *,[data-chat-near-viewport]) .akEvLW_root[data-expanded] [data-open] [data-disclosure-row]{backdrop-filter:none}.akEvLW_leading{flex-shrink:0}.akEvLW_title{font-weight:400}.akEvLW_separator{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.akEvLW_summary{min-width:0;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));white-space:nowrap;flex:auto;overflow:hidden}.akEvLW_summaryText{text-overflow:ellipsis;display:block;overflow:hidden}.akEvLW_summary[data-streaming]{mask-image:linear-gradient(90deg,#000 calc(100% - 48px),#0000)}.akEvLW_summary[data-streaming] .akEvLW_summaryText{text-overflow:clip;overflow:visible}.akEvLW_root:not([data-preview]) .akEvLW_separator,.akEvLW_root:not([data-preview]) .akEvLW_summary{display:none}.akEvLW_thinkBody{padding:4px 0 4px calc(22px + var(--dsh-content-font-delta,0px));min-width:0}`,document.head.appendChild(e)}var wy={leading:`akEvLW_leading`,root:`akEvLW_root`,row:`akEvLW_row`,separator:`akEvLW_separator`,summary:`akEvLW_summary`,summaryText:`akEvLW_summaryText`,thinkBody:`akEvLW_thinkBody`,title:`akEvLW_title`};let Ty=/* @__PURE__ */ (0,f.jsx)(p.IconThinkOutlineRegular,{size:14});function Ey(e){let t=e.indexOf(`
127
- `);return t===-1?e:e.slice(0,t)}function Dy(e){let t=``,n=0,r=/\r?\n(?:[\t ]*\r?\n)+/g;for(;;){let i=r.exec(e),a=i===null?e.length:i.index+i[0].indexOf(`
126
+ default:rv(this.#r)}}fail(){this.#d=this.#n,this.#r=`invalid`,this.#c=null}beginKey(e){this.#r=`key`,this.#a=e+1,this.#o=!1,this.#i=!1}stepKey(e,t){if(e<` `){this.fail();return}if(this.#i){this.#i=!1;return}if(e===`\\`){this.#i=!0,this.#o=!0;return}if(e!==`"`)return;let n=this.slice(this.#a,t);if(this.#o)try{this.#s=JSON.parse(`"${n}"`)}catch{this.fail();return}else this.#s=n;this.#r=`colon`}open(e){this.#p.has(this.#s)||this.#m.push(this.#s),this.#p.set(this.#s,e),this.#c=e}beginValue(e,t){ev(e)||(e===`"`?(this.open({kind:`string`,start:t+1,end:-1,needsDecoding:!1,invalidAt:void 0,length:void 0,text:void 0,prefixes:void 0}),this.#i=!1,this.#r=`string`):e===`}`||e===`,`||e===`:`||e===`]`?this.fail():(this.open({kind:`value`,start:t,end:-1,parsed:void 0,invalid:!1}),e===`{`||e===`[`?(this.#r=`nested`,this.#l=[e===`{`?`}`:`]`],this.#u=!1,this.#i=!1):this.#r=`scalar`))}stepScalar(e,t){(e===`,`||e===`}`||ev(e))&&(this.closeValue(t),this.#r=e===`,`?`key-only`:e===`}`?`closed`:`comma-or-end`)}stepNested(e,t){if(this.#u)this.#u=!1;else if(e===`"`)this.#u=!0;else if(e===`{`||e===`[`)this.#l.push(e===`{`?`}`:`]`);else if(e===`}`||e===`]`){if(this.#l.pop()!==e){this.fail();return}this.#l.length===0&&(this.closeValue(t+1),this.#r=`comma-or-end`)}}closeValue(e){let t=this.#c;t.end=e,this.#c=null}};function rv(e,t){let n=JSON.stringify(e)??String(e);throw Error(`unreachable variant${t?` in ${t}`:``}: ${n}`)}function iv(e){switch(e.kind){case`node`:return JSON.stringify([`node`,e.key,e.groupPart??null]);case`group`:return JSON.stringify([`group`,e.key]);default:return rv(e)}}function av(e,t){let n=e.counts.slice(0,3).map(({kind:e})=>t(`message.stepProcess.done.${e}`)),r=n[0];if(r===void 0)return t(`message.stepProcess.done.thinking`);let i=e=>e.charAt(0).toLowerCase()+e.slice(1),a=n[1];if(a===void 0)return r;if(n.length===2){let e=t(`message.stepProcess.sharedPrefix`);return t(`message.stepProcess.joinTwo`,{first:r,second:i(e!==``&&r.startsWith(e)&&a.startsWith(e)?a.slice(e.length):a)})}let o=[r,...n.slice(1).map(i)].join(t(`message.stepProcess.comma`));return e.counts.length>3?t(`message.stepProcess.more`,{title:o}):o}function ov(e=0){let[t,n]=(0,d.useState)(null);return{expanded:t===e,setExpanded:(0,d.useCallback)(t=>{n(t?e:null)},[e]),toggle:(0,d.useCallback)(()=>{n(t=>t===e?null:e)},[e])}}function sv(e){let t=t=>e.subscribe(t),n=()=>e.getSnapshot();return function(){return ov((0,d.useSyncExternalStore)(t,n))}}function cv(e){let t=e.clientHeight;return{top:e.scrollTop,height:t,floor:Math.max(0,e.scrollHeight-t)}}var lv=class e{following;threshold;static owners=/* @__PURE__ */ new WeakMap;target=null;sampledTop;constructor(e,t){this.following=e,this.threshold=t}static forElement(e){return this.owners.get(e)}bind(t){return e.owners.set(t,this),()=>{e.owners.get(t)===this&&e.owners.delete(t)}}get active(){return this.following}get animating(){return this.target!==null}nearBottom(e){return e.floor-e.top<=this.threshold}setFollowing(e){this.following=e,e||(this.target=null)}reset(){this.setFollowing(!1),this.sampledTop=void 0}sample(e,t=this.sampledTop===void 0||Math.abs(e.top-this.sampledTop)>.5){return this.sampledTop=e.top,!this.animating&&t&&(this.following=this.nearBottom(e)),this.active}settle(e){let t=this.target;return this.target=null,this.sample(e,t===null?void 0:Math.abs(e.top-Math.min(t,e.floor))>this.threshold)}jump(e,t,n){let r=this.animating;this.target=null;let i=Math.max(0,Math.min(t.floor,n));r?e.scrollTo({top:i,behavior:`instant`}):i!==t.top&&(e.scrollTop=i);let a={...t,top:e.scrollTop};return this.sampledTop=a.top,this.following=this.nearBottom(a),a}toBottom(e,t,n){return this.following=!0,n===`instant`||t.top>=t.floor||!this.animating&&this.nearBottom(t)||typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches?this.jump(e,t,t.floor):(this.target===null&&(this.target=t.floor,e.scrollTo({top:t.floor,behavior:`smooth`})),t)}interrupt(e,t){this.animating&&(this.target=null,this.sampledTop=t.top,e.scrollTo({top:t.top,behavior:`instant`}))}};function uv(e,t){let[n]=(0,d.useState)(()=>new lv(e,t));return n}let dv={canScrollUp:!1,canScrollDown:!1},fv=/* @__PURE__ */ new Set([`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `]);function pv(e,t,n,r){let i=uv(!1,1),a=(0,d.useRef)(null),[o,s]=(0,d.useState)(dv),c=(0,d.useCallback)(e=>{a.current=e},[]),l=(0,d.useCallback)(t=>{let n=e.current,r=dv;if(n!==null&&n.closest(`[hidden], [data-group-expanded-mode]`)===null){let e=cv(n),o=t===`resize`?a.current:null;if(o!==null)e=i.jump(n,e,o===`bottom`?e.floor:0),o===`top`&&i.setFollowing(!1),a.current=null;else{let r=i.animating;t===`scrollend`?i.settle(e):i.sample(e),i.active&&(t===`resize`||t===`scrollend`&&r)&&(e=i.toBottom(n,e,`smooth`))}r={canScrollUp:e.top>1,canScrollDown:e.top<e.floor-1}}else i.reset();s(e=>e.canScrollUp===r.canScrollUp&&e.canScrollDown===r.canScrollDown?e:r)},[e,i]),u=(0,d.useCallback)(()=>{let t=e.current;t!==null&&i.animating&&i.interrupt(t,cv(t))},[e,i]),f=(0,d.useMemo)(()=>({onScroll:()=>{l(`scroll`)},onWheel:u,onTouchStart:u,onPointerDown:u,onKeyDown:e=>{!e.defaultPrevented&&fv.has(e.key)&&u()}}),[u,l]);return(0,d.useLayoutEffect)(()=>{u(),i.reset(),(!r||!n)&&(a.current=null)},[i,r,u,n]),(0,d.useLayoutEffect)(()=>{let r=e.current;if(r===null||!n||typeof ResizeObserver>`u`)return;let a=i.bind(r),o=new ResizeObserver(()=>{l(`resize`)}),s=e=>{e.target===r&&l(`scrollend`)};return r.addEventListener(`scrollend`,s),o.observe(r),t.current!==null&&o.observe(t.current),()=>{a(),o.disconnect(),r.removeEventListener(`scrollend`,s)}},[e,t,i,n,l]),{edges:o,events:f,initialize:c}}let mv=`@deepseek-ai/dsh-client-ui-chat/ChatGroupSeat.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(mv)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=mv,e.textContent=`.M49uyW_root{min-width:0}.M49uyW_title{max-width:100%;color:var(--dsw-alias-label-tertiary);font:inherit;font-size:var(--dsh-content-font-size,14px);text-align:left;cursor:pointer;background:0 0;border:0;align-items:center;gap:6px;padding:0;transition:color .1s;display:flex}@media (hover:hover){.M49uyW_title:hover{color:var(--dsw-alias-label-secondary)}}.M49uyW_title:active{color:var(--dsw-alias-label-secondary)}.M49uyW_leading{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px));color:inherit;flex:none;justify-content:center;align-items:center;display:inline-flex;position:relative}.M49uyW_leading svg{width:calc(14px + var(--dsh-content-font-delta,0px));height:calc(14px + var(--dsh-content-font-delta,0px))}.M49uyW_leading svg[width="16"]{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px))}.M49uyW_activityIcon,.M49uyW_chevron{justify-content:center;align-items:center;transition:opacity .1s;display:inline-flex;position:absolute;inset:0}.M49uyW_activityIcon{opacity:1}.M49uyW_chevron{opacity:0}html:not([data-input-modality=pointer]) .M49uyW_title:focus-visible .M49uyW_activityIcon{opacity:0}html:not([data-input-modality=pointer]) .M49uyW_title:focus-visible .M49uyW_chevron{opacity:1}@media (hover:hover){.M49uyW_title:hover .M49uyW_activityIcon{opacity:0}.M49uyW_title:hover .M49uyW_chevron{opacity:1}}.M49uyW_title[aria-expanded=true] .M49uyW_activityIcon{opacity:0}.M49uyW_title[aria-expanded=true] .M49uyW_chevron{opacity:1}.M49uyW_title[aria-expanded=true]{padding-bottom:8px}.M49uyW_body{--dsh-chat-flow-gap:6px;overscroll-behavior-y:auto;scrollbar-gutter:stable;max-height:min(400px,50vh);overflow-y:auto}.M49uyW_body[hidden=until-found]{overflow:clip}.M49uyW_label{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.M49uyW_fadeTop{mask-image:linear-gradient(#0000 0,#000 24px 100%)}.M49uyW_fadeBottom{mask-image:linear-gradient(#000 0 calc(100% - 24px),#0000 100%)}.M49uyW_fadeTop.M49uyW_fadeBottom{mask-image:linear-gradient(#0000 0,#000 24px calc(100% - 24px),#0000 100%)}@media (prefers-reduced-motion:reduce){.M49uyW_title,.M49uyW_activityIcon,.M49uyW_chevron{transition:none}}.M49uyW_content{flex-direction:column;display:flex}.M49uyW_content>*{flex-shrink:0}.M49uyW_content>:not([hidden]):not(:empty)~:not([hidden]):not(:empty){margin-top:var(--dsh-chat-flow-gap,6px)}.M49uyW_expandedBody{scrollbar-gutter:auto;max-height:none;overflow:visible}`,document.head.appendChild(e)}var hv={activityIcon:`M49uyW_activityIcon`,body:`M49uyW_body`,chevron:`M49uyW_chevron`,content:`M49uyW_content`,expandedBody:`M49uyW_expandedBody`,fadeBottom:`M49uyW_fadeBottom`,fadeTop:`M49uyW_fadeTop`,label:`M49uyW_label`,leading:`M49uyW_leading`,root:`M49uyW_root`,title:`M49uyW_title`};let gv={thinking:/* @__PURE__ */ (0,f.jsx)(p.IconThinkOutlineRegular,{}),read:/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),readImage:/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),search:/* @__PURE__ */ (0,f.jsx)(p.IconSearchOutlineRegular,{size:14}),edit:/* @__PURE__ */ (0,f.jsx)(p.IconEditOutlineRegular,{size:14}),write:/* @__PURE__ */ (0,f.jsx)(p.IconEditOutlineRegular,{size:14}),commands:/* @__PURE__ */ (0,f.jsx)(p.IconApiOutlineRegular,{}),code:/* @__PURE__ */ (0,f.jsx)(p.IconCodeOutlineRegular,{size:14}),webSearch:/* @__PURE__ */ (0,f.jsx)(p.IconGlobeOutlineRegular,{}),webFetch:/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),subagents:/* @__PURE__ */ (0,f.jsx)(p.IconAgentPresetOutlineRegular,{size:14}),plan:/* @__PURE__ */ (0,f.jsx)(p.IconPlanOutlineRegular,{}),questions:/* @__PURE__ */ (0,f.jsx)(p.IconQuestionOutlineRegular,{}),tools:/* @__PURE__ */ (0,f.jsx)(p.IconSparkleRegular,{size:14})};function _v(e,t){return e.activity===t.activity&&e.detail===t.detail&&e.preparing===t.preparing}function vv(e,t){let[n,r]=(0,d.useState)(e),i=(0,d.useRef)(n),a=(0,d.useRef)(e),o=(0,d.useRef)(Date.now());return(0,d.useEffect)(()=>{if(a.current=e,!t||_v(i.current,e))return;let n=150-(Date.now()-o.current),s=()=>{let e=a.current;i.current=e,o.current=Date.now(),r(e)};if(n<=0){s();return}let c=setTimeout(s,n);return()=>{clearTimeout(c)}},[t,e.activity,e.detail,e.preparing]),t?n:e}let yv=(0,d.memo)(function({members:e,...t}){return e.map(e=>/* @__PURE__ */ (0,d.createElement)(Z_,{...t,key:iv(e),nodeKey:e.key,...e.groupPart===void 0?{}:{groupPart:e.groupPart}}))}),bv=(0,d.memo)(function({groupKey:e,useChatGroup:t,usePresentation:n,t:r,open:i,bodyId:a,toggle:o}){let s=t(e,e=>e?.data),c=n(e=>s?.closed===!1&&e.liveProcessDetail),l=vv({activity:s?.summary.running??`thinking`,detail:s?.summary.runningDetail??``,preparing:s?.summary.preparing===!0},s!==void 0&&!s.closed);if(s===void 0)return null;let u=s.closed?av(s.summary,r):l.preparing?r(`message.stepProcess.prepare.${l.activity===`thinking`?`tools`:l.activity}`):r(`message.stepProcess.${l.activity}`),d=c&&!s.closed?l.detail:``,m=d===``?u:`${u}${r(`message.turnProcess.separator`)}${d}`,h=s.closed?s.summary.counts[0]?.kind??`thinking`:l.activity;return/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:hv.title,"aria-expanded":i,"aria-controls":a,"data-process-activity":h,onClick:e=>{let t=e.currentTarget,n=t.ownerDocument.getElementById(a);i&&n?.contains(t.ownerDocument.activeElement)&&(e.detail!==0||(0,p.pointerModality)()?(0,p.focusWithoutRing)(t,{preventScroll:!0}):t.focus({preventScroll:!0})),o()},children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:hv.leading,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:hv.activityIcon,"data-step-process-icon":!0,children:gv[h]}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:hv.chevron,"data-step-process-chevron":!0,children:i?/* @__PURE__ */ (0,f.jsx)(p.IconChevronUpOutlineRegular,{}):/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{})})]}),/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{active:!s.closed,children:/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{className:hv.label,children:m})})]})}),xv=(0,d.memo)(function({groupKey:e,useChatGroup:t,members:n,closed:r,grouped:i,open:a,setOpen:o,...s}){let c=(0,d.useCallback)(()=>{o(!0)},[o]),l=F_(i&&!a,c),u=(0,d.useRef)(null),p=(0,d.useId)(),{edges:m,events:h,initialize:g}=pv(l,u,a,i),_=(0,d.useCallback)(()=>{a||g(r===!1?`bottom`:`top`),o(!a)},[r,g,a,o]),v=[hv.body,i?``:hv.expandedBody,i&&m.canScrollUp?hv.fadeTop:``,i&&m.canScrollDown?hv.fadeBottom:``];return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`div`,{hidden:!i,children:/* @__PURE__ */ (0,f.jsx)(bv,{groupKey:e,useChatGroup:t,usePresentation:s.usePresentation,t:s.t,open:a,bodyId:p,toggle:_})}),/* @__PURE__ */ (0,f.jsx)(`div`,{ref:l,id:p,className:v.join(` `),"data-step-process-body":!0,"data-scroll-up":m.canScrollUp||void 0,"data-scroll-down":m.canScrollDown||void 0,...h,children:/* @__PURE__ */ (0,f.jsx)(`div`,{ref:u,className:hv.content,"data-step-process-content":!0,"data-chat-flow":``,children:/* @__PURE__ */ (0,f.jsx)(yv,{...s,members:n})})})]})}),Sv=(0,d.memo)(function({groupKey:e,useChatGroup:t,...n}){let r=t(e,e=>e?.members),i=t(e,e=>e?.data.turn),a=t(e,e=>e?.data.closed),o=n.usePresentation(e=>e.foldCompletedTurns),{expanded:s,setExpanded:c}=ov(),l=r?.[0]?.key??``,u=n.useChatNodeProcess(l),p=n.useChatNode(l,e=>{let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn:void 0}),m=n.usePresentation(e=>e.stepGrouping===`collapsed`||e.stepGrouping===`history`&&p?.status!==`open`),h=p?.end?.data.reason.kind,g=u?.turnClosed===!1||u?.hasInterleavedInput===!0||p?.end?.data.finalAssistantStep===null||h===`aborted`||h===`error`,_=u?.spec,v=(0,d.useCallback)(e=>i===void 0?void 0:D_(e,i),[i]),y=n.useStore(v),b=o&&u?.turnClosed===!0&&_!==void 0&&!g&&y?.answerStep!==(_.answerStep??0),x=F_(b,(0,d.useCallback)(()=>{_!==void 0&&!g&&n.actions.setTurnProcessOpen(_.turn,_.answerStep??0,!0)},[n.actions,_,g]));return P_(x,r!==void 0&&!b),(0,d.useEffect)(()=>{b&&x.current?.hasAttribute(`hidden`)&&c(!1)},[b,x,c]),r===void 0?null:/* @__PURE__ */ (0,f.jsx)(`div`,{ref:x,className:hv.root,"data-chat-group-key":e,"data-chat-flow-key":e,"data-chat-anchor-key":`group:${e}`,"data-chat-turn":i,"data-chat-paging-anchor":m&&!s||void 0,"data-step-process":!0,"data-group-expanded-mode":!m||void 0,children:/* @__PURE__ */ (0,f.jsx)(xv,{...n,groupKey:e,useChatGroup:t,members:r,closed:a,grouped:m,open:s,setOpen:c})})});function Cv(e){return typeof e==`object`?e.key:e}function wv(e,t){let n=e.length;return new Proxy(e,{get(e,r,i){if(typeof r==`string`){let i=r.charCodeAt(0);if(i>=48&&i<=57){let i=+r;if(Number.isInteger(i)&&i>=0&&i<n){let n=e[i];if(typeof n!=`object`){let r=t[i*2];n=e[i]={index:i,key:n,start:r,size:t[i*2+1],end:r+t[i*2+1],lane:0}}return n}}if(r===`length`)return n}return Reflect.get(e,r,i)}})}function Tv(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return(o.length!==r.length||o.some((e,t)=>r[t]!==e))&&(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1),i}return o.updateDeps=e=>{r=e},o}function Ev(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}let Dv=(e,t)=>Math.abs(e-t)<1.01,Ov=(e,t,n)=>{let r;return Object.assign(function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)},{cancel:()=>{e.clearTimeout(r)}})},kv,Av=()=>{if(kv!==void 0)return kv;if(typeof navigator>`u`)return kv=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return kv=!0;let e=navigator.maxTouchPoints;return kv=navigator.platform===`MacIntel`&&e!==void 0&&e>0},jv=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Mv=e=>e,Nv=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},Pv=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(jv(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(jv(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},Fv={passive:!0},Iv=typeof window>`u`||`onscrollend`in window,Lv=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&Iv,o=0,s=a?null:Ov(i,()=>t(n(r),!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,Fv),a&&r.addEventListener(`scrollend`,u,Fv),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u),s?.cancel()}},Rv=(e,t)=>Lv(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),zv=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},Bv=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})};function Vv(e,t,n,r){if(t===0)return!1;let i=r(0),a=/* @__PURE__ */ new Set,o=0;for(;o<e;){let e=n(o);if(e===i)break;a.add(e),o++}let s=e-o;if(s===0||s>=t)return!1;for(let e=0;e<s;e++)if(r(e)!==n(o+e))return!1;for(let e=s;e<t;e++)if(a.has(r(e)))return!1;return!0}var Hv=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache=/* @__PURE__ */ new Map,this.itemSizeCacheVersion=0,this.laneAssignments=/* @__PURE__ */ new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this._clampedAdjustment=null,this.elementsCache=/* @__PURE__ */ new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=/* @__PURE__ */ (()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(t.isConnected)this.isIndexInRange(n)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this));else{this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}}};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Mv,rangeExtractor:Nv,onChange:()=>{},measureElement:zv,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=this._singleLaneMeasurements?.items??s,l=e=>Cv(c[e]),u=e>0?l(0):null,d=e>0?l(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==u||t.getItemKey(o-1)!==d)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>0&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==d)&&(o>e||Vv(e,o,l,t.getItemKey))&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=!1,s=0;if(r&&this.scrollOffset!==null){let[e,t]=r,n=this.getMeasurements(),{count:a,getItemKey:c}=this.options,l=0;for(;l<a&&c(l)!==e;)l++;if(l<a){let e=n[l];if(e){let n=Math.max(0,e.start+t);!i&&n!==this.scrollOffset&&(s=n-this.scrollOffset,this.scrollOffset=n,o=!0)}}}(o||i)&&(this.pendingScrollAnchor=[o?r[0]:null,o?r[1]:0,i,s])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=Tv(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.isScrolling=!1,this.scrollDirection=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._clampedAdjustment=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.targetWindow=this.scrollElement&&`ownerDocument`in this.scrollElement?this.scrollElement.ownerDocument.defaultView:this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{if(t&&this._intendedScrollOffset===null&&e===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this._clampedAdjustment!==null&&Math.abs(e-this._clampedAdjustment.maxAtWrite)>=1.5&&(this._clampedAdjustment=null),this.scrollAdjustments=0;let n=this.getScrollOffset();this.scrollDirection=t?n===e?this.scrollDirection:n<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,Av()&&this.targetWindow!=null&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,Fv),e.addEventListener(`touchend`,n,Fv),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r,i]=t;e!==null&&!r&&(Av()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):this.scrollState?.behavior===`smooth`&&!Dv(this.getScrollOffset()-i,this.scrollState.lastTargetOffset)||this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}this._retryClampedAdjustment()},this._retryClampedAdjustment=()=>{if(this._clampedAdjustment===null||!this.scrollElement||!this.options.enabled)return;let{target:e,maxAtWrite:t}=this._clampedAdjustment,n=this.getMaxScrollOffset();n>t+.5&&(this._clampedAdjustment=e>n+.5?{target:e,maxAtWrite:n}:null,this._scrollToOffset(e,{adjustments:void 0,behavior:void 0}))},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;if(this._iosDeferredAdjustment<0&&e>=t-1){this._iosDeferredAdjustment=0;return}let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=Tv(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,t,n,r,i,a,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s}),{key:!1}),this.isIndexInRange=e=>e>=0&&e<this.options.count,this.getMeasurements=Tv(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s},c)=>{let l=this.itemSizeCache;if(!i)return this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let u=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=e*2,a=this._singleLaneMeasurements?.flat;if(!a||a.length<i){let e=new Float64Array(i);a&&u>0&&e.set(a.subarray(0,u*2)),a=e}let o=u===0?Array(e):this._singleLaneMeasurements.items.slice(),c;if(u===0)c=t+n;else{let e=u-1;c=a[e*2]+a[e*2+1]+s}for(let t=u;t<e;t++){let e=r(t);o[t]=e;let n=l.get(e),i=typeof n==`number`?n:this.options.estimateSize(t);a[t*2]=c,a[t*2+1]=i,c+=i+s}this._singleLaneMeasurements={flat:a,items:o};let d=wv(o,a);return this.measurementsCache=d,d}let d=this.measurementsCache.slice(0,u),f=Array(a).fill(void 0),p=new Float64Array(a),m=0;for(let e=0;e<u;e++){let t=d[e];t&&(f[t.lane]===void 0&&m++,f[t.lane]=e,p[t.lane]=t.end)}for(let i=u;i<e;i++){let e=r(i),c=this.laneAssignments.get(i),u,h,g=o===`estimate`||l.has(e);if(c!==void 0&&this.options.lanes>1){u=c;let e=f[u],r=e===void 0?void 0:d[e];h=r?r.end+s:t+n}else if(m===a){let e=0,t=p[0],n=f[0];for(let r=1;r<a;r++){let i=p[r];(i<t||i===t&&f[r]<n)&&(e=r,t=i,n=f[r])}u=e,h=t+s,g&&this.laneAssignments.set(i,u)}else u=i%this.options.lanes,h=t+n,g&&this.laneAssignments.set(i,u);let _=l.get(e),v=typeof _==`number`?_:this.options.estimateSize(i),y=h+v;d[i]={index:i,start:h,size:v,end:y,key:e,lane:u},f[u]===void 0&&m++,f[u]=i,p[u]=y}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Tv(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=Gv(e,t,n,r,r===1&&this._singleLaneMeasurements!==null?this._singleLaneMeasurements.flat:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Tv(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e);if(!this.isIndexInRange(t))return;let n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(!this.isIndexInRange(e))return;let n,r,i,a=this._singleLaneMeasurements?.flat;if(this.options.lanes===1&&a!=null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=this.itemSizeCache.get(i)??n,s=t-o;if(s!==0){let a=this.options.anchorTo===`end`&&this.scrollState?.behavior!==`smooth`&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,c=a?this.getTotalSize():0,l=this.getScrollOffset()+this.scrollAdjustments,u=this.itemSizeCache.has(i)?r+o<=l&&this.scrollDirection!==`backward`:r<l,d=this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?u:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},s,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++;let f=!1;a?f=this.applyScrollAdjustment(this.getTotalSize()-c):d&&(f=this.applyScrollAdjustment(s)),this.notify(f),this._retryClampedAdjustment()}},this.getVirtualItems=Tv(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._singleLaneMeasurements?.flat,r=this.options.lanes===1&&n!=null;return Ev(t[Uv(0,t.length-1,r?e=>n[e*2]:e=>Ev(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`){if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t]}if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0;let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0,e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{this.options.count>0?this.scrollToIndex(this.options.count-1,{align:`end`,behavior:e}):this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._singleLaneMeasurements?.flat;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){if(e===0)return!1;if(Av()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded))return this._iosDeferredAdjustment+=e,!1;{let n=this.getScrollOffset()+this.scrollAdjustments+e,r=this.scrollElement,i=r!==null&&(`scrollHeight`in r||`document`in r)?this.getMaxScrollOffset():null;return this._clampedAdjustment=i!==null&&n>i+.5?{target:n,maxAtWrite:i}:null,this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0}}scheduleScrollReconcile(){this.targetWindow?this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}):this.scrollState=null}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&Dv(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}};let Uv=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function Wv(e,t,n){let r=0;for(;r<=t;){let i=(r+t)/2|0,a=e[i*2];if(a<n)r=i+1;else if(a>n)t=i-1;else return i}return r>0?r-1:0}function Gv(e,t,n,r,i){let a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&i!==null){let e=Wv(i,a,n),r=e,o=n+t;for(;r<a&&i[r*2]+i[r*2+1]<o;)r++;return{startIndex:e,endIndex:r}}let o=Uv(0,a,t=>e[t].start,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){let i=Array(r).fill(0);for(;s<a&&i.some(e=>e<n+t);){let t=e[s];i[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}let Kv=typeof document<`u`?d.useLayoutEffect:d.useEffect;function qv({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=d.useReducer(e=>e+1,0)[1],a=d.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:/* @__PURE__ */ new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=d.useRef(!1),s=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}},c=e=>{let t=a.current;if(!t.enabled||!t.container)return;s(e);let n=!!e.options.horizontal,r=t.mode===`transform`,i=n?`left`:`top`,o=e.options.scrollMargin,c=e.getVirtualItems();for(let a of c){let s=a.start-o,c=e.elementsCache.get(a.key);c&&t.lastPositions.get(c)!==s&&(t.lastPositions.set(c,s),r?c.style.transform=n?`translate3d(${s}px, 0, 0)`:`translate3d(0, ${s}px, 0)`:c.style[i]=`${s}px`)}},l={...r,onChange:(t,n)=>{var s;let l=a.current,u=!0;if(l.enabled){c(t);let e=t.range,n=l.prevRange;u=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,u&&(l.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}u&&(e&&n&&!o.current?(0,h.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[u]=d.useState(()=>{let e=new Hv(l),t=e.measureElement;return e.measureElement=e=>{o.current=!0;try{t(e)}finally{o.current=!1}},Object.assign(e,{containerRef:t=>{let n=a.current;if(n.container=t,n.lastSize=null,t&&n.enabled){let r=e.getTotalSize();n.lastSize=r;let i=e.options.horizontal?`width`:`height`;t.style[i]=`${r}px`}}})});return u.setOptions(l),Kv(()=>u._didMount(),[]),Kv(()=>(s(u),u._willUpdate())),Kv(()=>{c(u)}),u}function Jv(e){return qv({observeElementRect:Pv,observeElementOffset:Rv,scrollToFn:Bv,...e})}let Yv=`@deepseek-ai/dsh-client-ui-chat/TurnNavigator.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Yv)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Yv,e.textContent=`.R6aBma_slot{z-index:7;height:0;padding-inline:calc(var(--dsh-composer-side-clearance) + 16px);pointer-events:none;position:absolute;top:0;left:0;right:0;container-type:inline-size}[data-conversation-scroll] .R6aBma_slot{position:sticky}.R6aBma_frame{--turn-rail-band:calc(var(--dsh-conversation-viewport-height,100dvh) - var(--dsh-composer-height,152px));--turn-preview-height:104px;top:calc(var(--turn-rail-band) / 2);width:36px;max-height:min(max(0px, calc(var(--turn-rail-band) - 64px)), 70vh, 640px);contain:layout;cursor:pointer;pointer-events:auto;position:absolute;left:12px;transform:translateY(-50%)}.R6aBma_frame[hidden]{display:none}.R6aBma_scroller{max-height:inherit;overscroll-behavior:contain;scrollbar-width:none;position:relative;overflow-y:auto}.R6aBma_scroller::-webkit-scrollbar{display:none}.R6aBma_fadeTop{mask-image:linear-gradient(#0000 0,#000 40px 100%)}.R6aBma_fadeBottom{mask-image:linear-gradient(#000 0 calc(100% - 40px),#0000 100%)}.R6aBma_fadeTop.R6aBma_fadeBottom{mask-image:linear-gradient(#0000 0,#000 40px calc(100% - 40px),#0000 100%)}.R6aBma_marks{position:relative}.R6aBma_mark{cursor:pointer;background:0 0;border:0;border-radius:8px;height:10px;padding:0;position:absolute;top:0;left:0;right:0}.R6aBma_mark:before{background:var(--dsw-alias-label-tertiary);opacity:.4;content:"";transform-origin:0;width:26px;height:2px;transition:transform .16s cubic-bezier(.2,.8,.2,1),background-color .16s,opacity .16s;position:absolute;top:50%;left:0;transform:translateY(-50%)scaleX(.230769)}.R6aBma_markUnloaded:before{opacity:.25}.R6aBma_mark[data-neighbor-distance="3"]:before{transform:translateY(-50%)scaleX(.384615)}.R6aBma_mark[data-neighbor-distance="2"]:before{transform:translateY(-50%)scaleX(.538462)}.R6aBma_mark[data-neighbor-distance="1"]:before{transform:translateY(-50%)scaleX(.769231)}.R6aBma_markBusy:before{animation:1s ease-in-out infinite R6aBma_dsh-turn-mark-busy}.R6aBma_markActive:before{background:var(--dsw-alias-label-primary);opacity:.6}.R6aBma_frame[data-previewing] .R6aBma_markActive:not(.R6aBma_markPreview):not(:focus-visible):before{background:var(--dsw-alias-label-tertiary);opacity:.4}.R6aBma_markPreview:before{background:var(--dsw-alias-label-primary);opacity:1;transform:translateY(-50%)scaleX(1)}.R6aBma_frame[data-scrubbing] .R6aBma_mark:before{transition:none}.R6aBma_mark:focus-visible:before{background:var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));opacity:1;transform:translateY(-50%)scaleX(1)}.R6aBma_mark:focus-visible{outline:none}.R6aBma_mark:focus-visible:after{border-radius:inherit;outline:1px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-1px;content:"";width:28px;position:absolute;inset:0 auto 0 0}.R6aBma_preview{top:clamp(0px, calc(var(--turn-preview-center) - var(--turn-preview-height) / 2), calc(100% - var(--turn-preview-height)));box-sizing:border-box;width:min(320px,100cqw - 48px);max-height:var(--turn-preview-height);border:.5px solid var(--dsw-alias-border-l4);color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-1);box-shadow:var(--dsw-elevation-panel);pointer-events:none;border-radius:12px;padding:8px;transition:top .14s cubic-bezier(.2,.8,.2,1);animation:.12s ease-out R6aBma_dsh-turn-preview-enter;position:absolute;left:100%;overflow:hidden}.R6aBma_previewPrompt,.R6aBma_previewResponse{-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.R6aBma_previewPrompt{-webkit-line-clamp:1;font-size:14px;font-weight:500;line-height:20px}.R6aBma_previewResponse{color:var(--dsw-alias-label-caption);-webkit-line-clamp:3;margin-top:4px;font-size:14px;line-height:20px}@keyframes R6aBma_dsh-turn-preview-enter{0%{opacity:0;transform:translate(-4px)}to{opacity:1;transform:translate(0)}}@keyframes R6aBma_dsh-turn-mark-busy{0%,to{opacity:1}50%{opacity:.35}}@media (prefers-reduced-motion:reduce){.R6aBma_frame,.R6aBma_scroller,.R6aBma_mark:before,.R6aBma_markBusy:before,.R6aBma_preview{scroll-behavior:auto;transition:none;animation:none}}`,document.head.appendChild(e)}var Xv={"dsh-turn-mark-busy":`R6aBma_dsh-turn-mark-busy`,"dsh-turn-preview-enter":`R6aBma_dsh-turn-preview-enter`,fadeBottom:`R6aBma_fadeBottom`,fadeTop:`R6aBma_fadeTop`,frame:`R6aBma_frame`,mark:`R6aBma_mark`,markActive:`R6aBma_markActive`,markBusy:`R6aBma_markBusy`,markPreview:`R6aBma_markPreview`,markUnloaded:`R6aBma_markUnloaded`,marks:`R6aBma_marks`,preview:`R6aBma_preview`,previewPrompt:`R6aBma_previewPrompt`,previewResponse:`R6aBma_previewResponse`,scroller:`R6aBma_scroller`,slot:`R6aBma_slot`};function Zv(){return typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}let Qv=(0,d.memo)(function({item:e,index:t,active:n,busy:r,previewId:i,neighborDistance:a,registerElement:o,onNavigate:s,onPreview:c,onFocusChange:l,t:u}){let d=[Xv.mark];return e.anchor.kind===`unloaded`&&d.push(Xv.markUnloaded),n&&d.push(Xv.markActive),a===0&&d.push(Xv.markPreview),r&&d.push(Xv.markBusy),/* @__PURE__ */ (0,f.jsx)(`button`,{ref:o,"data-index":t,"data-neighbor-distance":a,type:`button`,className:d.join(` `),"aria-label":u(e.anchor.kind===`loaded`?`chat.turnNavigation.jump`:`chat.turnNavigation.jumpLoad`,{turn:t+1}),"aria-current":n?`true`:void 0,"aria-busy":r?`true`:void 0,"aria-describedby":i,onPointerMove:t=>{t.buttons===0&&c(e.turn)},onClick:()=>{s(e)},onFocus:()=>{l(e.turn)},onBlur:()=>{l(null)}})});function $v({items:e,activeTurn:t,busyTurn:n,onNavigate:r,t:i},a){let[o,s]=(0,d.useState)(null),[c,l]=(0,d.useState)(null),[u,p]=(0,d.useState)(!1),[m,h]=(0,d.useState)(!1),[g,_]=(0,d.useState)(!1),v=(0,d.useRef)(null),y=(0,d.useRef)(null),b=(0,d.useRef)(!1),x=(0,d.useRef)(void 0),S=(0,d.useRef)(null),C=(0,d.useRef)({placed:!1,index:0,follow:null,publishOffset:null}),w=(0,d.useRef)(!1),T=(0,d.useId)(),E=e.length>=2;(0,d.useLayoutEffect)(()=>{let e=v.current,t=e?.parentElement?.querySelector(`[data-chat-flow]`),n=e?.closest(`[data-conversation-scroll]`)??e?.parentElement;if(!t||!n)return;let r=()=>{let e=n.getBoundingClientRect(),r=n.offsetWidth>0?e.width/n.offsetWidth:1;h((t.getBoundingClientRect().left-e.left)/(r||1)>=48)},i=new ResizeObserver(r);return i.observe(t),i.observe(n),r(),()=>i.disconnect()},[E]),(0,d.useEffect)(()=>{if(o===null){p(!1);return}if(u)return;let e=setTimeout(()=>p(!0),150);return()=>clearTimeout(e)},[o,u]),(0,d.useEffect)(()=>()=>{clearTimeout(x.current);let e=y.current;y.current=null,e?.button.hasPointerCapture(e.pointerId)&&e.button.releasePointerCapture(e.pointerId)},[]);let ee=(0,d.useMemo)(()=>{let t=/* @__PURE__ */ new Map;return e.forEach((e,n)=>{t.set(e.turn,n)}),t},[e]),D=t===null?void 0:ee.get(t);(0,d.useLayoutEffect)(()=>{C.current.index=D??0},[D]);let O=c===null?void 0:ee.get(c),te=o===null?void 0:ee.get(o),ne=(0,d.useCallback)(e=>{l(e),s(e),p(e!==null)},[]),re=Jv({count:e.length,enabled:E,directDomUpdates:!0,directDomUpdatesMode:`transform`,useScrollendEvent:!0,getScrollElement:(0,d.useCallback)(()=>S.current,[]),getItemKey:(0,d.useCallback)(t=>e[t]?.turn??t,[e]),estimateSize:()=>10,measureElement:()=>10,initialRect:{width:0,height:0},initialOffset:0,scrollToFn:(e,t,n)=>{C.current.placed&&Bv(e,t,n)},observeElementOffset:(e,t)=>{C.current.publishOffset=t;let n=Rv(e,t);return()=>{n?.(),C.current.placed=!1,C.current.follow=null,C.current.publishOffset=null}},observeElementRect:(e,t)=>{let n=e.scrollElement,r=e.targetWindow?.ResizeObserver;if(n===null||r===void 0)return;let i=new r(([r])=>{if(r===void 0)return;let i=r.borderBoxSize[0],a={width:Math.round(i?.inlineSize??r.contentRect.width),height:Math.round(i?.blockSize??r.contentRect.height)},o=C.current;if(!o.placed&&a.height>0){let t=Math.max(0,e.getTotalSize()-a.height),r=o.index*10+6,i=Math.max(0,Math.min(t,r-a.height/2));o.placed=!0,o.follow={index:o.index,count:e.options.count,height:a.height},n.scrollTop=i,o.publishOffset?.(i,!1)}t(a)});return i.observe(n,{box:`border-box`}),()=>{i.disconnect()}},paddingStart:1,paddingEnd:1,scrollPaddingStart:40,scrollPaddingEnd:40,overscan:3,rangeExtractor:(0,d.useCallback)(e=>{let t=Nv(e);if(O!==void 0){let n=Math.min(e.count-1,O+1);for(let e=Math.max(0,O-1);e<=n;e++)t.includes(e)||t.push(e);t.sort((e,t)=>e-t)}return t},[O])}),ie=re.scrollOffset??0,ae=re.scrollRect?.height??0,oe=re.getVirtualItems(),se=(0,d.useCallback)((e,t,n=Zv())=>{let r=re.measurementsCache[e],i=re.scrollRect?.height??0;if(r===void 0||i<=0)return;let a=re.scrollOffset??0,o=r.start+r.size/2;if(t===`if-needed`){let{scrollPaddingStart:e,scrollPaddingEnd:t}=re.options;if(o>=a+e&&o<=a+i-t)return}let s=o-i/2,c=Math.max(0,re.getTotalSize()-i),l=Math.max(0,Math.min(c,s))-a;l!==0&&re.scrollBy(l,{behavior:n})},[re]);(0,d.useImperativeHandle)(a,()=>({activateTurn(t){let n=ee.get(t),i=n===void 0?void 0:e[n];i!==void 0&&r(i)},scrollToTurn(e){let t=ee.get(e);t!==void 0&&se(t,`always`)}}),[e,ee,r,se]),(0,d.useEffect)(()=>{if(ae<=0){C.current.follow=null;return}if(D===void 0||w.current)return;let t=C.current.follow;if(t?.index===D&&t.count===e.length&&t.height===ae)return;C.current.follow={index:D,count:e.length,height:ae};let n=t?.count===e.length&&t.height===ae?Zv():`instant`;se(D,`if-needed`,n)},[D,e.length,ae,se]);let ce=(0,d.useCallback)(e=>{b.current?b.current=!1:r(e)},[r]),le=t=>{if(t.button!==0||!(t.target instanceof Element))return;let n=t.target.closest(`button[data-index]`);if(!n||!S.current?.contains(n))return;let r=e[Number(n.dataset.index)];r&&(clearTimeout(x.current),b.current=!1,y.current={pointerId:t.pointerId,button:n,turn:r.turn,moved:!1},n.setPointerCapture(t.pointerId),_(!0),s(r.turn),p(!0))},ue=t=>{let n=y.current,i=S.current;if(!n||!i||t.pointerId!==n.pointerId||!(t.buttons&1))return;let a=i.getBoundingClientRect(),o=Math.max(a.top,Math.min(t.clientY,a.bottom-1)),c=e[Math.max(0,Math.min(e.length-1,Math.round((o-a.top+i.scrollTop-6)/10)))];c&&c.turn!==n.turn&&(n.turn=c.turn,n.moved=!0,s(c.turn),c.anchor.kind===`loaded`&&r(c))},de=e=>{let t=y.current;t&&e.pointerId===t.pointerId&&(y.current=null,_(!1),b.current=t.moved,t.button.hasPointerCapture(e.pointerId)&&t.button.releasePointerCapture(e.pointerId),x.current=setTimeout(()=>{b.current=!1},0),w.current||s(null))};if(!E)return null;let fe=!u||te===void 0?void 0:e[te],pe=oe.find(e=>e.index===te),k=[Xv.scroller];return ie>1&&k.push(Xv.fadeTop),ie<re.getTotalSize()-ae-1&&k.push(Xv.fadeBottom),/* @__PURE__ */ (0,f.jsx)(`div`,{ref:v,className:Xv.slot,children:/* @__PURE__ */ (0,f.jsxs)(`nav`,{className:Xv.frame,hidden:!m,"data-turn-navigation":``,"data-previewing":te!==void 0||void 0,"data-scrubbing":g||void 0,onPointerDownCapture:le,onPointerMove:ue,onPointerUpCapture:de,onPointerCancelCapture:de,onLostPointerCapture:de,"aria-label":i(`chat.turnNavigation.label`),onPointerEnter:()=>{w.current=!0},onPointerLeave:()=>{w.current=!1,y.current||s(null)},children:[/* @__PURE__ */ (0,f.jsx)(`div`,{ref:S,className:k.join(` `),children:/* @__PURE__ */ (0,f.jsx)(`div`,{ref:re.containerRef,className:Xv.marks,children:oe.map(({index:r,key:a})=>{let c=e[r];return c===void 0?null:/* @__PURE__ */ (0,f.jsx)(Qv,{item:c,index:r,active:c.turn===t,busy:c.turn===n,previewId:u&&c.turn===o?T:void 0,neighborDistance:te!==void 0&&Math.abs(r-te)<=3?Math.abs(r-te):void 0,registerElement:re.measureElement,onNavigate:ce,onPreview:s,onFocusChange:ne,t:i},a)})})}),fe!==void 0&&pe!==void 0&&/* @__PURE__ */ (0,f.jsxs)(`div`,{id:T,role:`tooltip`,className:Xv.preview,style:{"--turn-preview-center":`${String(pe.start+pe.size/2-ie)}px`},children:[/* @__PURE__ */ (0,f.jsx)(`div`,{className:Xv.previewPrompt,children:fe.prompt||i(`chat.turnNavigation.turn`,{turn:(te??0)+1})}),fe.response!==``&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:Xv.previewResponse,children:fe.response})]})]})})}let ey=(0,d.memo)((0,d.forwardRef)($v));function ty(){return/* @__PURE__ */ (0,f.jsx)(`span`,{className:V_.runningIcon,"aria-hidden":`true`,children:/* @__PURE__ */ (0,f.jsx)(`span`,{className:V_.runningIconMotion,children:/* @__PURE__ */ (0,f.jsxs)(`svg`,{width:`100%`,height:`100%`,viewBox:`2 2 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:1.2,strokeLinecap:`round`,strokeLinejoin:`round`,children:[/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M16.1 5.3C11.8 2.9 6.6 5 5.1 9.4c-1.8 5.4 1.7 10.2 6.9 10.3 4.8.2 8-3.8 7.2-8.3-.4 3.2-2 5.1-4.2 5.8`}),/* @__PURE__ */ (0,f.jsx)(`rect`,{x:`9.5`,y:`9.1`,width:`4.6`,height:`4.6`,rx:`1`,transform:`rotate(-10 11.8 11.4)`})]})})})}let ny=`@deepseek-ai/dsh-client-ui-chat/accessibility.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(ny)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=ny,e.textContent=`.F76jpa_visuallyHidden{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}`,document.head.appendChild(e)}var ry={visuallyHidden:`F76jpa_visuallyHidden`};let iy=(0,d.memo)(function({startTime:e,compacting:t,stale:n,t:r}){let[i,a]=(0,d.useState)(Date.now);(0,d.useEffect)(()=>{if(e===void 0||t||n)return;a(Date.now());let r=setInterval(()=>{a(Date.now())},1e3);return()=>{clearInterval(r)}},[e,t,n]);let o=n?r(`chat.statusUnconfirmed`):t?r(`message.compaction.running`):e===void 0?r(`chat.deepDiving`):r(`chat.deepDivingFor`,{duration:Og(Math.max(1e3,i-e),r).map(e=>e.text).join(``)});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:V_.running,"data-chat-running":!0,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:ry.visuallyHidden,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:r(n?`chat.statusUnconfirmed`:t?`message.compaction.running`:`chat.deepDiving`)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:V_.runningDivider,"aria-hidden":`true`}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:V_.runningContent,children:[n?null:/* @__PURE__ */ (0,f.jsx)(ty,{}),/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{active:!n,className:V_.runningText,children:o})]})]})});function ay(e){return e}function oy(e){return e}function sy(e){if(!Number.isSafeInteger(e)||e<0||Object.is(e,-0))throw TypeError(`SessionSeq must be a non-negative safe integer, got ${String(e)}`);return oy(e)}let cy=[];function ly(e){if(typeof e!=`object`||!e)return;let t=e;if(!(typeof t.turn!=`number`||!Number.isSafeInteger(t.turn)||t.turn<0)&&!(typeof t.seq!=`number`||!Number.isSafeInteger(t.seq)||t.seq<0||Object.is(t.seq,-0)))return{turn:t.turn,seq:sy(t.seq),prompt:typeof t.prompt==`string`?t.prompt:``,response:typeof t.response==`string`?t.response:``}}function uy(e){return Array.isArray(e)?e:cy}function dy(e,t){let n=/* @__PURE__ */ new Map;for(let e of uy(t)){let t=ly(e);t!==void 0&&n.set(t.turn,{turn:t.turn,prompt:t.prompt,response:t.response,anchor:{kind:`unloaded`,seq:t.seq}})}for(let t of e){let e=n.get(t.turn);n.set(t.turn,{turn:t.turn,prompt:t.prompt===``?e?.prompt??``:t.prompt,response:t.response===``?e?.response??``:t.response,anchor:{kind:`loaded`,key:t.anchorKey}})}return n.size===0?cy:[...n.values()].sort((e,t)=>e.turn-t.turn)}var fy=class{viewport;reading;input;onBusyTurn;jump=null;settleFrame=null;requestedHead;constructor(e,t,n,r){this.viewport=e,this.reading=t,this.input=n,this.onBusyTurn=r}setInput(e){this.input=e}reset(){this.requestedHead=void 0,this.cancel()}dispose(){this.clearTask()}cancel(){this.clearTask(),this.onBusyTurn(null)}clearTask(){this.cancelFrame(),this.jump=null,this.viewport.stopPreserving()}navigateToTurn=e=>{if(e.anchor.kind===`loaded`){this.cancel();let t=this.viewport.scrollToTurn(e.turn);if(t===null)return;this.reading.acceptNavigation(t),this.input.loadingOlder&&this.viewport.beginPreserving(t.position);return}if(!this.input.historyReady)return;this.cancel(),this.viewport.beginPreserving(),this.reading.pauseFollowing();let t={turn:e.turn,seq:e.anchor.seq,phase:`loading`,landing:`pending`,repageHead:null};this.jump=t,this.onBusyTurn(t.turn),this.request(t)};autoLoadEarlier=()=>{if(this.jump!==null||this.input.olderFailed||this.requestedHead===this.input.firstSeq)return;let e=this.viewport.readScroll();e===null||e.metrics.top>240||this.loadEarlier()};loadEarlier=()=>{this.input.historyReady&&this.input.hasMore&&!this.input.loadingOlder&&(this.requestedHead=this.input.firstSeq,this.cancel(),this.viewport.beginPaging(),this.reading.pauseFollowing(),this.input.loadOlder())};readerSampled(e){e.movedByReader&&this.jump?.landing===`landed`&&(this.jump.landing=`interrupted`),e.followingTail?this.viewport.stopPreserving():e.movedByReader&&(this.input.loadingOlder&&this.jump===null?this.viewport.preserving||this.viewport.beginPreserving(e.position):this.viewport.stopPreserving())}contentCommitted(e=!1){if(!this.viewport.preserving||this.reading.pending&&!e)return!1;if(this.landJump(!1))return!0;let t=this.viewport.preserve(e);return t!==null&&((!e||!this.reading.pending)&&this.reading.preservePosition(t),!0)}readerSettled(){this.input.loadingOlder&&this.jump===null&&!this.viewport.preserving&&!this.reading.followingTail&&this.viewport.beginPreserving()}reconcile(){let e=this.jump;if(!this.input.historyReady||e===null||this.reading.pending)return;if(e.phase===`loading`){e.landing===`pending`&&this.landJump(!1);return}if(this.input.loadingOlder||this.landJump(!0))return;if((this.input.firstSeq===null||this.input.firstSeq>e.seq)&&this.input.hasMore&&e.repageHead!==this.input.firstSeq){e.repageHead=this.input.firstSeq,this.viewport.beginPreserving(),this.request(e);return}let t=this.viewport.scrollToTurnAtOrAfter(e.turn);this.cancel(),t!==null&&this.reading.acceptNavigation(t)}landJump(e){let t=this.jump;if(t===null)return!1;if(t.landing===`interrupted`)return e?(this.cancel(),!0):!1;let n=this.viewport.scrollToTurn(t.turn);return n!==null&&(this.reading.acceptNavigation(n),e?this.cancel():(this.viewport.beginPreserving(n.position),t.landing=`landed`),!0)}request(e){e.phase=`loading`;let t=()=>{this.jump===e&&(e.phase=`settled`,this.cancelFrame(),typeof requestAnimationFrame==`function`?this.settleFrame=requestAnimationFrame(()=>{this.settleFrame=null,this.jump===e&&this.reconcile()}):this.reconcile())};this.input.loadThrough(e.seq).then(t,t)}cancelFrame(){this.settleFrame!==null&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(this.settleFrame),this.settleFrame=null}};function py(e,t,n){let[r,i]=(0,d.useState)(null),[a]=(0,d.useState)(()=>new fy(e,t,n,i));return(0,d.useLayoutEffect)(()=>{a.setInput(n)},[a,n]),(0,d.useLayoutEffect)(()=>()=>{a.dispose()},[a]),{navigation:a,busyTurn:r}}var my=class{viewport;store;state;onChange;follow;sampleTimer=null;probeFrame=null;sampled=null;pendingMovedByReader=!1;constructor(e,t,n,r,i){this.viewport=e,this.store=t,this.state=n,this.onChange=r,this.follow=i}get pending(){return this.sampleTimer!==null}get followingTail(){return this.state.followingTail}setStore(e){this.store=e}connect(e){return this.sampled=e,()=>{this.sampled===e&&(this.sampled=null)}}dispose(){this.cancelPending(),this.sampled=null}pauseFollowing(){this.cancelPending(),this.publish({...this.state,followingTail:!1})}followTail(){let e=this.viewport.scrollToBottom(this.follow);e!==null&&(this.cancelPending(),this.commit(e,!0,this.viewport.latestTurn))}restore(){let e=this.store.read();if(e===null){this.followTail();return}let t=this.viewport.restore(e);if(t===null)return;this.cancelPending();let n=this.follow.nearBottom(t.metrics);if(this.commit(t,n,n?this.viewport.latestTurn:this.state.activeTurn,n),!this.state.followingTail&&t.position===null){let e=this.viewport.capturePosition();e!==null&&this.store.save(e)}this.refreshActiveTurn()}acceptNavigation(e){this.cancelPending();let t=this.follow.nearBottom(e.metrics);this.commit(e,t,e.turn??(t?this.viewport.latestTurn:this.state.activeTurn))}preservePosition(e){this.cancelPending(),this.commit(e,this.state.followingTail,this.state.activeTurn)}onScroll=e=>{let t=e.movedByReader||this.pendingMovedByReader;!t&&this.state.followingTail||t&&e.metrics.top>=e.metrics.floor?(this.followTail(),this.sampled?.({position:null,movedByReader:t,followingTail:!0})):(e.movedByReader&&(this.pendingMovedByReader=!0),this.sampleTimer??=window.setTimeout(this.flushSample,500))};onScrollEnd=()=>{this.flushSample()};onResize(){this.pending||(this.state.followingTail?this.followTail():this.refreshActiveTurn())}refreshActiveTurn(){this.pending||(this.state.followingTail?this.publish({...this.state,initialized:!0,activeTurn:this.viewport.latestTurn}):this.probeFrame===null&&(typeof requestAnimationFrame==`function`?this.probeFrame=requestAnimationFrame(this.probe):this.probe()))}commit(e,t,n,r=!0){t?this.store.save(null):e.position!==null&&this.store.save(e.position),this.publish({initialized:r,followingTail:t,activeTurn:n})}publish(e){this.follow.setFollowing(e.followingTail),(e.initialized!==this.state.initialized||e.followingTail!==this.state.followingTail||e.activeTurn!==this.state.activeTurn)&&(this.state=e,this.onChange(e))}cancelPending(){this.sampleTimer!==null&&window.clearTimeout(this.sampleTimer),this.probeFrame!==null&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(this.probeFrame),this.sampleTimer=null,this.probeFrame=null,this.pendingMovedByReader=!1}probe=()=>{if(this.probeFrame=null,this.pending)return;let e=this.viewport.readScroll();if(e===null)return;let t=this.follow.nearBottom(e.metrics)?this.viewport.latestTurn:this.viewport.readVisibleTurn(e.metrics);this.publish({...this.state,initialized:!0,activeTurn:t})};flushSample=()=>{if(!this.pending)return;let e=this.pendingMovedByReader;this.cancelPending();let t=this.viewport.readScroll();if(t===null)return;let n=e||t.movedByReader,r=this.follow.sample(t.metrics,n),i=null;if(!n&&r)this.followTail();else{i=r?null:this.viewport.capturePosition(),this.viewport.acknowledge(t.metrics),(r||i!==null)&&this.store.save(i);let e=this.follow.nearBottom(t.metrics)?this.viewport.latestTurn:this.viewport.readVisibleTurn(t.metrics);this.publish({initialized:!0,followingTail:r,activeTurn:e})}this.sampled?.({position:i,movedByReader:n,followingTail:r})}};function hy(e,t,n){let[r,i]=(0,d.useState)(()=>({initialized:!1,followingTail:t.read()===null,activeTurn:n})),a=uv(r.followingTail,25),[o]=(0,d.useState)(()=>new my(e,t,r,i,a));return(0,d.useLayoutEffect)(()=>{o.setStore(t)},[o,t]),(0,d.useLayoutEffect)(()=>()=>{o.dispose()},[o]),{reading:o,state:r}}let gy=[`wheel`,`touchstart`,`touchmove`,`touchend`,`touchcancel`,`pointerdown`,`keydown`,`beforematch`],_y=/* @__PURE__ */ new Set([`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `]);var vy=class{elements=null;observer=null;events=null;turns=[];observation={top:0,landing:null};paging=null;touchY=null;viewportWidth=null;attach(e,t){this.detach();let n=e.closest(`[data-conversation-scroll]`)??e,r=n.querySelector(`[data-composer-seat]`),i={list:e,column:t,scroller:n,composer:r};this.elements=i,this.syncViewportWidth(),n.addEventListener(`scroll`,this.onScroll,{passive:!0}),n.addEventListener(`scrollend`,this.onScrollEnd,{passive:!0,capture:!0});for(let e of gy)n.addEventListener(e,this.onIntent,{passive:!0,capture:!0});typeof ResizeObserver<`u`&&(this.observer=new ResizeObserver(()=>{this.elements===i&&(this.syncViewportWidth(),this.invalidate(),this.events?.resize())}),this.observer.observe(t),this.observer.observe(n),e!==n&&this.observer.observe(e),r!==null&&this.observer.observe(r))}detach(){this.stopPreserving(),this.elements?.list.style.removeProperty(`--dsh-chat-viewport-width`),this.elements?.scroller.removeEventListener(`scroll`,this.onScroll),this.elements?.scroller.removeEventListener(`scrollend`,this.onScrollEnd,!0);for(let e of gy)this.elements?.scroller.removeEventListener(e,this.onIntent,!0);this.observer?.disconnect(),this.observer=null,this.elements=null,this.events=null,this.turns=[],this.touchY=null,this.viewportWidth=null,this.observation={top:0,landing:null}}syncViewportWidth(){let e=this.elements?.list;if(e===void 0)return;let t=e.clientWidth;t>0&&t!==this.viewportWidth&&(this.viewportWidth=t,e.style.setProperty(`--dsh-chat-viewport-width`,`${t}px`))}connect(e){return this.events=e,()=>{this.events===e&&(this.events=null)}}updateTurns(e){this.turns=e}get latestTurn(){return this.turns.at(-1)?.turn??null}invalidate(){this.observation.landing=null}acknowledge(e){this.observation={top:e.top,landing:null}}readScroll(){let e=this.metrics();return e===null?null:{metrics:e,movedByReader:Math.abs(e.top-Math.min(this.observation.top,e.floor))>.5,towardStart:e.top<Math.min(this.observation.top,e.floor)-.5}}metrics(){let e=this.elements?.scroller;return e===void 0?null:cv(e)}anchor(e,t=`position`){if(this.elements===null)return null;let n=null;for(let r of this.elements.list.querySelectorAll(`[data-chat-anchor-key]:not([hidden]):not([hidden] *)`)){if(r.dataset.chatAnchorKey===e||t===`node`&&r.dataset.chatNodeKey===e)return r;n===null&&r.dataset.chatNodeKey===e&&(n=r)}return n}capturePosition(){let e=this.elements;if(e===null)return null;let{list:t,scroller:n,composer:r}=e,i=n.getBoundingClientRect(),a=r?.getBoundingClientRect().top??i.bottom,o=null;if(typeof document.elementsFromPoint==`function`&&a>i.top){let e=t.getBoundingClientRect(),n=Math.max(i.left,e.left),r=Math.min(i.right,e.right);for(let e of document.elementsFromPoint(n+Math.max(0,r-n)/2,i.top+1)){let n=e instanceof HTMLElement?e.closest(`[data-chat-anchor-key]`):null;if(n!==null&&n.dataset.chatFlowKind!==`turn-process`&&t.contains(n)){o=n.dataset.chatGroupKey===void 0?n:n.querySelector(`[data-step-process-content] > [data-chat-anchor-key]:not(:empty):not([hidden]):not([hidden] *)`)??n;break}}}if(o===null){let e=t.querySelectorAll(`[data-chat-flow-key]:not([data-chat-group-key]):not([data-chat-flow-kind="turn-process"]):not(:empty):not([hidden]):not([hidden] *)`),n=0,r=e.length;for(;n<r;){let t=n+r>>>1;e.item(t).getBoundingClientRect().bottom>i.top?r=t:n=t+1}let s=e[n];o=s!==void 0&&s.getBoundingClientRect().top<a?s:e[0]??null}let s=o?.dataset.chatAnchorKey;return o===null||s===void 0?null:{anchorKey:s,anchorTop:o.getBoundingClientRect().top-i.top,scrollTop:n.scrollTop}}readVisibleTurn(e=this.metrics()){let t=this.observation.landing?.turn;if(t!=null&&e?.top===this.observation.top)return t;let n=this.elements,r=this.turns[0];if(n===null||e===null||r===void 0)return null;let i=n.scroller.getBoundingClientRect().top+Math.min(96,e.height*.2),a=n.column.children,o=0,s=a.length,c=r.turn;for(;o<s;){let e=o+s>>>1,t=a[e];if(t.getBoundingClientRect().top>i)s=e;else{let n=t.getAttribute(`data-chat-turn`),r=n===null?NaN:Number(n);Number.isSafeInteger(r)&&(c=r),o=e+1}}return c}scrollToTurn(e){let t=this.turns.find(t=>t.turn===e);if(t===void 0)return null;let n=this.anchor(t.anchorKey,`node`);return n===null?null:this.align(n,24,e)}scrollToTurnAtOrAfter(e){if(this.elements===null)return null;for(let t of this.elements.list.querySelectorAll(`[data-chat-turn]:not([hidden]):not([hidden] *)`)){let n=Number(t.dataset.chatTurn);if(Number.isSafeInteger(n)&&n>=e)return this.align(t,24,n)}return null}scrollToResponseAnnotation(e){let t=this.elements,n=e.anchor;if(t===null||n===void 0)return null;let r=Ug(t.column,n,e.text);if(r===void 0)return null;let i=Array.from(r.range.getClientRects()).find(e=>e.width!==0||e.height!==0)??(()=>{let e=r.range.getBoundingClientRect();return e.width===0&&e.height===0?void 0:e})(),a=this.metrics();if(i===void 0||a===null)return null;let o=t.scroller.getBoundingClientRect().top,s=r.host.closest(`[data-chat-anchor-key]`),c=r.host.closest(`[data-chat-turn]`)?.getAttribute(`data-chat-turn`),l=c==null?NaN:Number(c),u=Number.isSafeInteger(l)?l:null,d=a.top+i.top-o-a.height*.3;return s===null?this.write(d,a,u):this.write(d,a,u,{key:s.getAttribute(`data-chat-anchor-key`)??void 0,top:s.getBoundingClientRect().top-o})}restore(e){let t=this.anchor(e.anchorKey);if(t!==null)return this.align(t,e.anchorTop,null);let n=this.metrics();return n===null?null:this.write(e.scrollTop,n,null)}beginPaging(){this.stopPreserving();let e=this.elements?.list.querySelector(`[data-chat-paging-anchor]:not(:empty):not([hidden]):not([hidden] *)`);e!=null&&this.retain(e)}beginPreserving(e=this.capturePosition()){if(this.stopPreserving(),e===null)return;let t=this.anchor(e.anchorKey);t!==null&&this.retain(t,e)}retain(e,t,n){let r=this.elements,i=e.dataset.chatAnchorKey;if(r===null||i===void 0)return null;let a=this.paging?.group;a!=null&&this.observer?.unobserve(a.content);let o=e.getBoundingClientRect().top,s=e.closest(`[data-step-process-body]`),c=s?.querySelector(`[data-step-process-content]`),l=s===null||c==null?null:{body:s,content:c,top:n??o-s.getBoundingClientRect().top};return this.paging={row:e,group:l,position:t??{anchorKey:i,anchorTop:o-r.scroller.getBoundingClientRect().top,scrollTop:r.scroller.scrollTop}},l!==null&&this.observer?.observe(l.content),this.paging}stopPreserving(){let e=this.paging?.group;e!=null&&this.observer?.unobserve(e.content),this.paging=null}get preserving(){return this.paging!==null}refreshPagingPosition(e){let t=this.paging,n=this.elements;if(t===null||n===null||!n.list.contains(t.row))return;let r=t.row.getBoundingClientRect().top-n.scroller.getBoundingClientRect().top;this.paging={...t,position:{...t.position,anchorTop:r,scrollTop:e.top}}}isPagingDisplaced(e){let t=this.paging,n=this.elements;if(t===null||n===null||!n.list.contains(t.row)||!(Math.abs(e.top-Math.min(t.position.scrollTop,e.floor))>.5))return!1;let r=t.row.getBoundingClientRect().top-n.scroller.getBoundingClientRect().top;return Math.abs(r-t.position.anchorTop)>.5}preserve(e=!1){let t=this.paging,n=this.elements;if(t===null||n===null)return null;if(!n.list.contains(t.row)){let e=this.anchor(t.position.anchorKey);if(e===null)return this.stopPreserving(),null;if(t=this.retain(e,t.position,t.group?.top),t===null)return null}let{row:r,group:i,position:a}=t;if(r.closest(`[hidden]`)!==null||r.matches(`:empty`))return this.stopPreserving(),null;let o=this.metrics();if(o===null)return null;let s=this.isPagingDisplaced(o),c=null;if(s){let t=r.getBoundingClientRect().top-n.scroller.getBoundingClientRect().top,i=o.top+t-(a.scrollTop+a.anchorTop);if(!e||i<=.5)return this.stopPreserving(),null;c=i}if(i!==null&&i.body.contains(r)){let e=r.getBoundingClientRect().top-i.body.getBoundingClientRect().top,t=cv(i.body),n=Math.max(0,Math.min(t.floor,t.top+e-i.top));if(t.top!==n){let e=lv.forElement(i.body);e===void 0?i.body.scrollTop=n:(e.jump(i.body,t,n),e.setFollowing(!1))}}let l=this.metrics();if(l===null)return null;let u=r.getBoundingClientRect().top-n.scroller.getBoundingClientRect().top,d=c===null?l.top+u-a.anchorTop:l.top+c,f=this.write(d,l,null,{key:a.anchorKey,top:u});return f!==null&&this.paging===t&&(this.paging={...t,position:{...a,anchorTop:f.position?.anchorTop??a.anchorTop,scrollTop:f.metrics.top}}),f}scrollToBottom(e){let t=this.metrics();if(t===null||this.elements===null)return null;let n={metrics:t.top>t.floor?t:e.toBottom(this.elements.scroller,t,`instant`),position:null,turn:this.latestTurn};return this.observation={top:n.metrics.top,landing:n},n}align(e,t,n){let r=this.metrics();if(r===null||this.elements===null)return null;let i=e.getBoundingClientRect().top-this.elements.scroller.getBoundingClientRect().top;return this.write(r.top+i-t,r,n,{key:e.dataset.chatAnchorKey,top:i})}write(e,t,n,r){if(this.elements===null)return null;let i=Math.max(0,Math.min(t.floor,e));i!==t.top&&(this.elements.scroller.scrollTop=i);let a=this.elements.scroller.scrollTop,o={metrics:{...t,top:a},turn:n,position:r?.key===void 0?null:{anchorKey:r.key,anchorTop:r.top-(a-t.top),scrollTop:a}};return this.observation={top:a,landing:o},o}onScroll=e=>{if(this.elements===null||e.target!==this.elements.scroller||this.observation.landing!==null&&this.elements.scroller.scrollTop===this.observation.top)return;this.invalidate();let t=this.readScroll();t!==null&&(this.paging!==null&&this.isPagingDisplaced(t.metrics)&&(t.towardStart||t.metrics.top<=.5?this.refreshPagingPosition(t.metrics):this.stopPreserving()),this.events?.scroll(t))};onScrollEnd=e=>{(e.target===this.elements?.scroller||e.target instanceof HTMLElement&&e.target.hasAttribute(`data-step-process-body`))&&this.events?.scrollEnd()};onIntent=e=>{if(e.type===`touchend`||e.type===`touchcancel`){this.touchY=null;return}let t=e instanceof WheelEvent;if(e.target instanceof Element&&(e.target.closest(`[data-turn-navigation]`)||!t&&e.target.closest(`[data-composer-seat], input, textarea, [contenteditable="true"]`))||t&&e.deltaY===0||e.type===`keydown`&&(!(e instanceof KeyboardEvent)||!_y.has(e.key)))return;let n=t?e.deltaY<0:e instanceof KeyboardEvent&&([`ArrowUp`,`PageUp`,`Home`].includes(e.key)||e.key===` `&&e.shiftKey);if(typeof TouchEvent<`u`&&e instanceof TouchEvent){let t=e.touches[0]?.clientY;if(e.type===`touchstart`||t===void 0||this.touchY===null){this.touchY=t??null;return}let r=t-this.touchY;if(Math.abs(r)<2)return;this.touchY=t,n=r>0}if(!(e instanceof PointerEvent&&e.pointerType===`touch`)){if(e.target instanceof Element){for(let r=e.target;r&&r!==this.elements?.scroller;r=r.parentElement)if(r instanceof HTMLElement&&r.scrollHeight>r.clientHeight&&/auto|scroll/.test(getComputedStyle(r).overflowY)){if(t){let t=e.deltaY<0&&r.scrollTop>0,n=e.deltaY>0&&r.scrollTop+r.clientHeight<r.scrollHeight-1;if(t||n)return}else if(n&&r.scrollTop>0){n=!1;break}}}this.paging!==null&&!n&&(this.stopPreserving(),this.events?.interact()),n&&this.events?.olderIntent()}}};function yy(){let e=(0,d.useRef)(null),t=(0,d.useRef)(null),[n]=(0,d.useState)(()=>new vy);return(0,d.useLayoutEffect)(()=>{if(e.current!==null&&t.current!==null)return n.attach(e.current,t.current),()=>{n.detach()}},[n]),{viewport:n,listRef:e,columnRef:t}}function by(e){let{displayReady:t,historyReady:n,order:r,firstSeq:i,lastKey:a,lastIsUser:o,steeringId:s,submissionId:c,running:l,loadedTurns:u,chatScroll:f,hasMore:p,loadingOlder:m,olderFailed:h,loadOlder:g,loadThrough:_}=e,{viewport:v,listRef:y,columnRef:b}=yy(),{reading:x,state:S}=hy(v,f,u.at(-1)?.turn??null),C=(0,d.useMemo)(()=>({historyReady:n,firstSeq:i,loadingOlder:m,olderFailed:h,hasMore:p,loadOlder:g,loadThrough:_}),[n,i,m,h,p,g,_]),{navigation:w,busyTurn:T}=py(v,x,C),E=(0,d.useRef)({input:e,applied:null,opened:!1}),ee=(0,d.useCallback)(()=>{let e=E.current.input,t=E.current.applied,n=e.lastIsUser&&e.lastKey!==t?.lastKey||e.steeringId!==null&&e.steeringId!==t?.steeringId&&e.steeringId!==t?.submissionId||e.submissionId!==null&&e.submissionId!==t?.submissionId&&e.submissionId!==t?.steeringId,r=t!==null&&e.firstSeq!==null&&t.firstSeq!==null&&e.firstSeq<t.firstSeq;(!x.pending||n||r)&&(E.current.applied=e,e.displayReady&&!E.current.opened?(E.current.opened=!0,w.reset(),x.restore()):n?(w.cancel(),x.followTail()):w.contentCommitted(r)?w.reconcile():(t===null||e.displayReady!==t.displayReady||e.firstSeq!==t.firstSeq||e.lastKey!==t.lastKey||e.order.length!==t.order.length||e.running!==t.running||e.steeringId!==t.steeringId||e.submissionId!==t.submissionId)&&x.followingTail?(w.cancel(),x.followTail()):w.reconcile())},[x,w]);(0,d.useLayoutEffect)(()=>{let e=null,t=()=>{e===null&&E.current.opened&&E.current.input.historyReady&&(e=requestAnimationFrame(()=>{e=null,E.current.opened&&E.current.input.historyReady&&w.autoLoadEarlier()}))},n=v.connect({scroll:e=>{x.onScroll(e),e.movedByReader&&e.towardStart&&t()},olderIntent:t,scrollEnd:()=>{x.onScrollEnd(),w.readerSettled()},interact:()=>{w.cancel()},resize:()=>{w.contentCommitted()||x.onResize(),w.reconcile()}}),r=x.connect(e=>{w.readerSampled(e),ee()});return()=>{e!==null&&cancelAnimationFrame(e),n(),r(),E.current.opened=!1,E.current.applied=null}},[v,x,w,ee]),(0,d.useLayoutEffect)(()=>{let e=E.current.input;E.current.input={displayReady:t,order:r,lastKey:a,lastIsUser:o,steeringId:s,submissionId:c,running:l,loadedTurns:u,chatScroll:f,...C},v.updateTurns(u);let n=e.order!==r||e.displayReady!==t;n&&v.invalidate(),ee(),n&&x.refreshActiveTurn()},[v,x,ee,C,t,r,a,o,s,c,l,u,f]);let D=(0,d.useCallback)(()=>{w.cancel(),x.followTail()},[w,x]),O=(0,d.useCallback)(e=>{w.cancel();let t=v.scrollToResponseAnnotation(e);t!==null&&(x.acceptNavigation(t),E.current.input.loadingOlder&&v.beginPreserving(t.position))},[w,x,v]);return{listRef:y,columnRef:b,...S,busyTurn:T,navigateToTurn:w.navigateToTurn,revealResponseAnnotation:O,loadEarlier:w.loadEarlier,returnToBottom:D}}function xy(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=xy(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function Sy(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=xy(e))&&(r&&(r+=` `),r+=t);return r}let Cy=`@deepseek-ai/dsh-client-ui-chat/SelectionActions.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Cy)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Cy,e.textContent=`._4l2sSq_popover{z-index:30;background:var(--dsw-alias-button-primary-fill);color:var(--dsw-alias-label-primary-foreground);border:.5px solid color-mix(in srgb, var(--dsw-alias-label-primary-foreground) 16%, transparent);box-shadow:var(--dsw-shadow-lv3);border-radius:9999px;padding:2px;animation:.14s cubic-bezier(.175,.885,.32,1.275) _4l2sSq_selection-island-in;display:flex;position:fixed;overflow:hidden}._4l2sSq_action{height:24px;color:inherit;font-family:var(--dsw-font-family);letter-spacing:-.01em;white-space:nowrap;cursor:pointer;background:0 0;border:none;border-radius:9999px;align-items:center;gap:5px;padding:0 10px;font-size:12px;font-weight:500;transition:background-color .12s,transform .12s cubic-bezier(.175,.885,.32,1.275);display:inline-flex}._4l2sSq_action+._4l2sSq_action{margin-left:1px;position:relative}._4l2sSq_action+._4l2sSq_action:before{content:"";background:color-mix(in srgb, currentColor 24%, transparent);width:1px;position:absolute;top:5px;bottom:5px;left:-1px}._4l2sSq_action svg{color:currentColor;flex-shrink:0}._4l2sSq_action:hover{background:color-mix(in srgb, currentColor 14%, transparent)}._4l2sSq_action:active{background:color-mix(in srgb, currentColor 22%, transparent);transform:scale(.96)}._4l2sSq_answer{position:relative}::highlight(codexhost-response-annotation){background-color:color-mix(in srgb, var(--dsw-alias-state-business-primary) 16%, transparent);text-decoration:underline color-mix(in srgb, var(--dsw-alias-state-business-primary) 65%, transparent)}::highlight(codexhost-response-annotation-hover){background-color:color-mix(in srgb, var(--dsw-alias-state-business-primary) 30%, transparent);text-decoration:underline var(--dsw-alias-state-business-primary)}._4l2sSq_annotationMark{z-index:1;user-select:none;position:absolute;inset-inline-start:100%}._4l2sSq_annotationMark button{justify-content:center;width:24px;height:24px}._4l2sSq_annotationNumber{box-sizing:border-box;background:color-mix(in srgb, var(--dsw-alias-state-business-primary) 14%, var(--dsw-alias-bg-base));min-width:18px;min-height:18px;color:var(--dsw-alias-state-business-primary);font-variant-numeric:tabular-nums;border-radius:999px;place-items:center;padding:0 5px;font-size:10.5px;font-weight:600;line-height:1;transition:background-color .12s,transform .12s;display:inline-grid}._4l2sSq_annotationNumberHovered{background:color-mix(in srgb, var(--dsw-alias-state-business-primary) 28%, var(--dsw-alias-bg-base));transform:scale(1.1)}@keyframes _4l2sSq_selection-island-in{0%{opacity:0;scale:.9}to{opacity:1;scale:1}}@media (prefers-reduced-motion:reduce){._4l2sSq_popover{animation:none}._4l2sSq_action,._4l2sSq_annotationNumber{transition:none}}`,document.head.appendChild(e)}var wy={action:`_4l2sSq_action`,annotationMark:`_4l2sSq_annotationMark`,annotationNumber:`_4l2sSq_annotationNumber`,annotationNumberHovered:`_4l2sSq_annotationNumberHovered`,answer:`_4l2sSq_answer`,popover:`_4l2sSq_popover`,"selection-island-in":`_4l2sSq_selection-island-in`};let Ty=`codexhost-response-annotation`,Ey=[`a`,`button`,`input`,`textarea`,`select`,`summary`,`label`,`[contenteditable='true']`,`[data-selection-actions]`,`[data-code-block-controls]`].join(`,`);function Dy(e,t,n){let r=null,i=1/0;for(let{annotation:a,range:o}of e){let e=o.getClientRects(),s=!1;for(let r=0;r<e.length;r+=1){let i=e[r];if(!(i===void 0||i.width===0&&i.height===0)&&t>=i.left-1&&t<=i.right+1&&n>=i.top-1&&n<=i.bottom+2){s=!0;break}}if(!s)continue;let c=a.anchor===void 0?1/0:a.anchor.end-a.anchor.start;(r===null||c<i)&&(r=a.id,i=c)}return r}function Oy(e){let t=e.getClientRects();for(let e=t.length-1;e>=0;--e){let n=t[e];if(n!==void 0&&(n.width!==0||n.height!==0))return n}let n=e.getBoundingClientRect();return n.width===0&&n.height===0?void 0:n}function ky(e,t=Ty,n=0){let r=globalThis.CSS?.highlights;if(e.length===0||r===void 0||typeof Highlight>`u`)return()=>{};let i=r.get(t)??new Highlight;i.priority=n;for(let t of e)i.add(t);return r.set(t,i),()=>{for(let t of e)i.delete(t);i.size===0&&r.get(t)===i&&r.delete(t)}}let Ay=[];function jy({answer:e,answerKey:t,useInput:n,inputActions:r,labels:i}){let a=n(e=>e.responseAnnotations),o=n(e=>e.phase===`adjudicating`||e.phase===`submitting`),[s,c]=(0,d.useState)(null),l=(0,d.useRef)(null);l.current=s;let u=(0,d.useRef)(null),m=n(e=>{let n=e.hoveredResponseAnnotationId;if(n!==void 0)return e.responseAnnotations?.some(e=>e.id===n&&e.anchor?.answerKey===t)?n:void 0}),h=(0,d.useMemo)(()=>a?.flatMap((e,n)=>e.anchor?.answerKey===t?[{annotation:e,index:n+1}]:[]),[a,t]),[g,_]=(0,d.useState)(Ay),v=(0,d.useRef)([]),[y,b]=(0,d.useState)(0),x=(0,d.useRef)(null),S=(0,d.useRef)(r);return S.current=r,(0,d.useEffect)(()=>()=>{x.current!==null&&(x.current=null,S.current?.hoverResponseAnnotation(null))},[]),(0,d.useLayoutEffect)(()=>{let t=e.current;if(t===null||h===void 0||h.length===0){v.current=[],_(Ay),b(e=>e+1);return}let n=()=>{},r=()=>{if(!t.isConnected)return;let e=t.getBoundingClientRect().top,n=v.current.flatMap(({annotation:t,index:n,range:r})=>{let i=Oy(r);return i===void 0?[]:[{annotation:t,index:n,top:i.top-e+(i.height-24)/2}]});n.sort((e,t)=>e.top-t.top);let r=0,i=n.length===0?Ay:n.map(e=>{let t=Math.max(e.top,r);return r=t+24+2,{...e,top:t}});_(e=>e.length===i.length&&e.every((e,t)=>e.annotation===i[t]?.annotation&&e.index===i[t]?.index&&Math.abs(e.top-(i[t]?.top??0))<.5)?e:i)},i=()=>{n(),n=()=>{},t.isConnected?(v.current=h.flatMap(e=>{let{anchor:n,text:r}=e.annotation,i=n&&Hg(t,n,r);return i===void 0?[]:[{...e,range:i}]}),n=ky(v.current.map(({range:e})=>e),Ty),b(e=>e+1),r()):(v.current=[],_(Ay),b(e=>e+1))};i();let a=typeof ResizeObserver>`u`?null:new ResizeObserver(r);a?.observe(t);let o=typeof MutationObserver>`u`?null:new MutationObserver(i),s=t.firstElementChild;return s!==null&&!s.hasAttribute(`data-selection-actions`)&&o?.observe(s,{childList:!0,characterData:!0,subtree:!0,attributes:!0,attributeFilter:[`hidden`,`open`]}),t.addEventListener(`scroll`,r,!0),()=>{n(),n=()=>{},v.current=[],a?.disconnect(),o?.disconnect(),t.removeEventListener(`scroll`,r,!0)}},[e,h]),(0,d.useEffect)(()=>{s!==null&&!h?.some(({annotation:e})=>e.id===s)&&c(null)},[h,s]),(0,d.useEffect)(()=>{let t=e.current;if(t===null||h===void 0||h.length===0)return;let n=()=>{u.current=l.current},r=e=>{let n=u.current;if(u.current=null,e.defaultPrevented||e.button!==0||e.detail>1)return;let r=t.ownerDocument.defaultView?.getSelection();if(r!=null&&!r.isCollapsed||(e.target instanceof Element?e.target:e.target instanceof Node?e.target.parentElement:null)?.closest(Ey)!=null)return;let i=Dy(v.current,e.clientX,e.clientY);i!==null&&i!==n&&c(i)};return t.addEventListener(`pointerdown`,n,!0),t.addEventListener(`click`,r),()=>{t.removeEventListener(`pointerdown`,n,!0),t.removeEventListener(`click`,r)}},[e,h]),(0,d.useLayoutEffect)(()=>{if(m!==void 0)return ky(v.current.filter(({annotation:e})=>e.id===m).map(({range:e})=>e),`codexhost-response-annotation-hover`,1)},[m,y]),g.map(({annotation:e,index:t,top:n})=>{let a=m===e.id;return/* @__PURE__ */ (0,f.jsx)(`div`,{className:wy.annotationMark,style:{top:n},"data-selection-actions":!0,onPointerEnter:t=>{t.pointerType!==`touch`&&(x.current=e.id,r?.hoverResponseAnnotation(e.id))},onPointerLeave:t=>{t.pointerType!==`touch`&&(x.current===e.id&&(x.current=null),r?.hoverResponseAnnotation(null))},onFocus:t=>{t.target instanceof Element&&t.target.matches(`:focus-visible`)&&(x.current=e.id,r?.hoverResponseAnnotation(e.id))},onBlur:t=>{!t.currentTarget.contains(t.relatedTarget)&&m===e.id&&(x.current===e.id&&(x.current=null),r?.hoverResponseAnnotation(null))},children:/* @__PURE__ */ (0,f.jsx)(p.ResponseAnnotationPopover,{annotation:e,index:t,labels:i,title:i.label(t),open:s===e.id,onOpenChange:t=>{c(t?e.id:null)},editDisabled:o,onUpdate:r===void 0?void 0:t=>{r.updateResponseAnnotation(e.id,t)},onRemove:r===void 0?void 0:()=>{r.removeResponseAnnotation(e.id)},anchor:/* @__PURE__ */ (0,f.jsx)(`span`,{className:Sy(wy.annotationNumber,a&&wy.annotationNumberHovered),"data-hovered":a||void 0,"aria-label":i.label(t),children:t})})},e.id)})}let My=`@deepseek-ai/dsh-client-ui-chat/SelectionCommentCard.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(My)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=My,e.textContent=`.lPRhsq_card{z-index:30;box-sizing:border-box;border:.5px solid var(--dsw-alias-border-l2);background:var(--dsw-specific-input-major);width:344px;box-shadow:var(--dsw-shadow-lv3);color:var(--dsw-alias-label-primary);font-family:var(--dsw-font-family);border-radius:16px;flex-direction:column;gap:8px;padding:12px;animation:.14s cubic-bezier(.175,.885,.32,1.275) lPRhsq_selection-comment-in;display:flex;position:fixed}.lPRhsq_header{align-items:flex-start;gap:8px;display:flex}.lPRhsq_excerpt{border-left:2px solid var(--dsw-alias-border-l3);min-width:0;color:var(--dsw-alias-label-tertiary);-webkit-line-clamp:2;overflow-wrap:anywhere;-webkit-box-orient:vertical;flex:auto;margin:0;padding-left:9px;font-size:12px;line-height:17px;display:-webkit-box;overflow:hidden}.lPRhsq_close{width:22px;height:22px;color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:0;border-radius:6px;flex:none;place-items:center;margin:-3px -4px 0 0;padding:0;transition:background-color .11s,color .11s;display:inline-grid}@media (hover:hover) and (pointer:fine){.lPRhsq_close:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}}.lPRhsq_close:focus-visible{outline:1.5px solid var(--dsw-alias-state-business-primary);outline-offset:0}.lPRhsq_inputRow{align-items:flex-end;gap:8px;display:flex}.lPRhsq_field{box-sizing:border-box;field-sizing:content;min-width:0;min-height:28px;max-height:116px;color:var(--dsw-alias-label-primary);font:inherit;resize:none;background:0 0;border:0;outline:none;flex:auto;padding:4px 0;font-size:13px;line-height:19px}.lPRhsq_field::placeholder{color:var(--dsw-alias-label-tertiary)}.lPRhsq_submit{background:var(--dsw-alias-button-primary-fill);height:28px;color:var(--dsw-alias-label-primary-foreground);font:inherit;white-space:nowrap;cursor:pointer;touch-action:manipulation;user-select:none;-webkit-tap-highlight-color:transparent;border:0;border-radius:9999px;flex:none;justify-content:center;align-items:center;gap:5px;padding:0 12px;font-size:12px;font-weight:500;line-height:16px;transition:background-color .12s,opacity .12s,transform .12s cubic-bezier(.175,.885,.32,1.275);display:inline-flex}@media (hover:hover) and (pointer:fine){.lPRhsq_submit:hover:not(:disabled){background:var(--dsw-alias-button-primary-hover)}}.lPRhsq_submit:disabled{opacity:.35;cursor:default}.lPRhsq_submit:not(:disabled):active{transform:scale(.96)}.lPRhsq_kbd{color:currentColor;opacity:.72;background:0 0;border:0;justify-content:center;align-items:center;padding:0;font-family:inherit;font-size:11px;font-weight:500;line-height:1;display:inline-flex}.lPRhsq_error{color:var(--dsw-alias-state-error-primary);font-size:11.5px;line-height:16px}@media (hover:none),(pointer:coarse){.lPRhsq_card{width:min(344px,100vw - 16px)}.lPRhsq_field{font-size:16px;line-height:22px}.lPRhsq_submit{height:32px;padding:0 14px;font-size:13px}.lPRhsq_kbd{display:none}}@keyframes lPRhsq_selection-comment-in{0%{opacity:0;scale:.96}to{opacity:1;scale:1}}@media (prefers-reduced-motion:reduce){.lPRhsq_card{animation:none}.lPRhsq_submit,.lPRhsq_close{transition:none}}`,document.head.appendChild(e)}var Ny={card:`lPRhsq_card`,close:`lPRhsq_close`,error:`lPRhsq_error`,excerpt:`lPRhsq_excerpt`,field:`lPRhsq_field`,header:`lPRhsq_header`,inputRow:`lPRhsq_inputRow`,kbd:`lPRhsq_kbd`,"selection-comment-in":`lPRhsq_selection-comment-in`,submit:`lPRhsq_submit`};function Py(){return typeof CSS<`u`&&typeof CSS.supports==`function`&&CSS.supports(`field-sizing`,`content`)}function Fy({excerpt:e,labels:t,fieldRef:n,style:r,below:i,onSubmit:a,onCancel:o}){let[s,c]=(0,d.useState)(``),[l,u]=(0,d.useState)(!1),m=(0,d.useRef)(null),h=s.trim();(0,d.useEffect)(()=>{n.current?.focus({preventScroll:!0});let e=(0,p.observeComposition)(document);return m.current=e,()=>{e.dispose(),m.current===e&&(m.current=null)}},[n]),(0,d.useLayoutEffect)(()=>{let e=n.current;e===null||Py()||(e.style.height=`auto`,e.style.height=`${String(Math.min(e.scrollHeight,116))}px`)},[n,s]);let g=()=>{h!==``&&(u(!1),a(h)||u(!0))};return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Ny.card,role:`dialog`,"aria-label":t.placeholder,"data-placement":i?`below`:`above`,style:r,"data-selection-actions":!0,onKeyDown:e=>{e.key===`Escape`&&m.current?.guards(e.nativeEvent)!==!0&&(e.preventDefault(),e.stopPropagation(),o())},onMouseDown:e=>{e.target!==n.current&&e.preventDefault()},children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Ny.header,children:[/* @__PURE__ */ (0,f.jsx)(`blockquote`,{className:Ny.excerpt,children:e.replace(/\s+/gu,` `)}),/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Ny.close,"aria-label":t.cancel,title:t.cancel,onClick:o,children:/* @__PURE__ */ (0,f.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,"aria-hidden":`true`,children:/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M2.5 2.5l7 7M9.5 2.5l-7 7`})})})]}),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Ny.inputRow,children:[/* @__PURE__ */ (0,f.jsx)(`textarea`,{ref:n,className:Ny.field,rows:1,value:s,placeholder:t.placeholder,"aria-label":t.placeholder,onChange:e=>{l&&u(!1),c(e.target.value)},onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||m.current?.guards(e.nativeEvent)!==!0&&(e.preventDefault(),g())}}),/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Ny.submit,disabled:h===``,onClick:g,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{children:t.submit}),/* @__PURE__ */ (0,f.jsx)(`kbd`,{className:Ny.kbd,"aria-hidden":`true`,children:`↵`})]})]}),l&&/* @__PURE__ */ (0,f.jsx)(`div`,{role:`alert`,className:Ny.error,children:t.unavailable})]})}function Iy(e){return e instanceof Element?e:e.parentElement}function Ly(e){if(e===null||typeof window>`u`)return null;let t=window.getSelection();if(t===null||t.rangeCount===0||t.isCollapsed)return null;let n=t.getRangeAt(0),r=Iy(n.startContainer),i=Iy(n.endContainer),a=r?.closest(`[data-selection-answer]`);if(a==null||!e.contains(a)||i?.closest(`[data-selection-answer]`)!==a||a.hasAttribute(`data-selection-answer-streaming`)||r?.closest(Rg)!=null||i?.closest(Rg)!=null)return null;let o=Bg(n),s=Oy(n);return o===``||s===void 0?null:{text:o,rect:s,range:n.cloneRange(),host:a}}function Ry(e){let t=window.getSelection();t!==null&&e.contains(t.anchorNode)&&e.contains(t.focusNode)&&t.removeAllRanges()}function zy(e,t=0){let n=window.visualViewport,r=n?.width??window.innerWidth,i=n?.offsetLeft??0,a=e.right-i,o=window.matchMedia(`(hover: none)`).matches,s=n?.offsetTop??0,c=s+(n?.height??window.innerHeight),l=e.top-8-t>=s+8,u=e.bottom+8+t<=c-8,d=t===0?o:o?u||!l:!l&&u,f=r-8-a,p=d?e.bottom+8:e.top-8,m=s+8+(d?0:t),h=c-8-(d?t:0);return{left:e.right,top:t===0?p:Math.max(m,Math.min(p,h)),maxWidth:r-16,transform:`translateX(clamp(${String(8-a)}px, -100%, calc(${String(f)}px - 100%)))`+(d?``:` translateY(-100%)`),below:d}}function By({labels:e,onAdd:t,container:n,onComposingAnswerChange:r}){let[i,a]=(0,d.useState)(null),[o,s]=(0,d.useState)(null),c=(0,d.useRef)(null),l=(0,d.useRef)(!1),u=(0,d.useRef)(null),p=(0,d.useRef)(!1),m=(0,d.useRef)(null),g=(0,d.useRef)(null),_=(0,d.useCallback)(e=>{g.current=e,a(e)},[]),v=(0,d.useCallback)(()=>{l.current=!1,s(null)},[]),y=(0,d.useCallback)(()=>{if(u.current=null,p.current||l.current)return;let e=Ly(n.current),t=m.current;e!==null&&t!==null&&e.host===t.host&&e.text===t.text?_(null):((e===null||t===null||e.host!==t.host||e.text!==t.text)&&(m.current=null),_(e))},[n,_]),b=(0,d.useCallback)(()=>{u.current===null&&(u.current=window.requestAnimationFrame(y))},[y]);(0,d.useEffect)(()=>{let e=()=>{p.current=!1,b()},t=e=>{let t=e.target;(t instanceof Element?t:t instanceof Node?t.parentElement:null)?.closest(`[data-selection-actions]`)??(p.current=!0,m.current=null,_(null),v())},n=()=>{let e=window.getSelection();e===null||e.rangeCount===0||e.isCollapsed?(m.current=null,_(null)):b()},r=e=>{let t=e.target;if(t instanceof Element&&t.closest(`[data-selection-actions]`)!==null)return;let n=c.current,r=n?.closest(`[data-selection-actions]`)??null;(n===null||n!==document.activeElement&&r?.contains(document.activeElement)!==!0&&n.value===``)&&(_(null),v())},i=e=>{let t=g.current;e.key!==`Escape`||e.defaultPrevented||e.isComposing||l.current||t===null||(e.preventDefault(),m.current={host:t.host,text:t.text},_(null))};return document.addEventListener(`pointerdown`,t,!0),document.addEventListener(`pointerup`,e,!0),document.addEventListener(`pointercancel`,e,!0),document.addEventListener(`selectionchange`,n),document.addEventListener(`keydown`,i),window.addEventListener(`keyup`,b),window.addEventListener(`scroll`,r,!0),()=>{document.removeEventListener(`pointerdown`,t,!0),document.removeEventListener(`pointerup`,e,!0),document.removeEventListener(`pointercancel`,e,!0),document.removeEventListener(`selectionchange`,n),document.removeEventListener(`keydown`,i),window.removeEventListener(`keyup`,b),window.removeEventListener(`scroll`,r,!0),u.current!==null&&window.cancelAnimationFrame(u.current),u.current=null}},[b,v,_]);let x=o?.rect,S=o?.range;(0,d.useEffect)(()=>{if(x===void 0||S===void 0)return;let e=window.visualViewport,t=c.current?.closest(`[data-selection-actions]`),n=()=>{let e=t?.offsetHeight??104,n=zy(x,e);s(e=>e?.rect===x?{...e,placement:n}:e)},r=ky([S]),i=typeof ResizeObserver>`u`?null:new ResizeObserver(n);return t!=null&&i?.observe(t),window.addEventListener(`resize`,n),e?.addEventListener(`resize`,n),e?.addEventListener(`scroll`,n,{passive:!0}),n(),()=>{r(),i?.disconnect(),window.removeEventListener(`resize`,n),e?.removeEventListener(`resize`,n),e?.removeEventListener(`scroll`,n)}},[x,S]);let C=o?.anchor?.answerKey??null;if((0,d.useEffect)(()=>(r?.(C),()=>{C!==null&&r?.(null)}),[C,r]),o!==null){let r=o.placement;return(0,h.createPortal)(/* @__PURE__ */ (0,f.jsx)(Fy,{excerpt:o.text,labels:e,fieldRef:c,below:r.below,style:{left:r.left,top:r.top,maxWidth:r.maxWidth,transform:`${r.transform} translateZ(0)`},onSubmit:e=>n.current===null||!t(o.anchor===void 0?{text:o.text,annotation:e}:{text:o.text,annotation:e,anchor:o.anchor})?!1:(o.host.isConnected&&Ry(o.host),v(),!0),onCancel:v}),document.body)}if(i===null)return null;let w=zy(i.rect),T=()=>i.host.isConnected&&n.current?.contains(i.host)===!0;return(0,h.createPortal)(/* @__PURE__ */ (0,f.jsxs)(`div`,{className:wy.popover,"data-placement":w.below?`below`:`above`,style:{left:w.left,top:w.top,maxWidth:w.maxWidth,transform:`${w.transform} translateZ(0)`},"data-selection-actions":!0,onPointerDown:e=>{e.preventDefault()},children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:wy.action,onClick:()=>{if(!T())return;let e=Vg(i.host,i.range);t(e===void 0?{text:i.text}:{text:i.text,anchor:e})&&(Ry(i.host),_(null))},children:[/* @__PURE__ */ (0,f.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`}),/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M12 7v6`}),/* @__PURE__ */ (0,f.jsx)(`path`,{d:`M9 10h6`})]}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:e.addToChat})]}),/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:wy.action,onClick:()=>{if(!T())return;let e=Vg(i.host,i.range);Ry(i.host),l.current=!0,s({...i,anchor:e,placement:zy(i.rect,104)}),_(null)},children:/* @__PURE__ */ (0,f.jsx)(`span`,{children:e.comment})})]}),document.body)}let Vy=`@deepseek-ai/dsh-client-ui-chat/ChatMarkdown.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Vy)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Vy,e.textContent=`.DT2SAW_linkMenu[data-menu-material]{--link-menu-fill:color-mix(in srgb, var(--dsw-alias-bg-layer-2) 68%, var(--dsw-alias-bg-overlay));--dsw-menu-surface-fill:color-mix(in srgb, var(--link-menu-fill) 78%, transparent);--dsw-menu-backdrop-filter:blur(20px) saturate(140%);--dsw-alias-interactive-bg-hover:color-mix(in srgb, var(--dsw-alias-link) 18%, transparent);--dsw-alias-menu-icon:var(--dsw-alias-label-primary);border:1px solid var(--dsw-alias-border-l4);min-width:148px;padding:4px;box-shadow:inset 0 1px #fff3,0 2px 5px #0000001a,0 9px 22px #0000002e}.DT2SAW_linkMenu[data-menu-material] [role=menuitem]{min-height:24px;font:500 13px/18px var(--dsw-font-family);border-radius:6px;gap:8px;padding:2px 8px}.DT2SAW_linkMenu[data-menu-material] [role=menuitem]>span:has(>svg),.DT2SAW_linkMenu[data-menu-material] [role=menuitem] svg{width:14px;height:14px}@media (pointer:coarse){.DT2SAW_linkMenu[data-menu-material] [role=menuitem]{min-height:44px}}@media (prefers-reduced-transparency:reduce),(prefers-contrast:more){.DT2SAW_linkMenu[data-menu-material]{--dsw-menu-surface-fill:var(--link-menu-fill);--dsw-menu-backdrop-filter:none}}@media (forced-colors:active){.DT2SAW_linkMenu[data-menu-material]{--dsw-menu-surface-fill:Canvas;--dsw-menu-backdrop-filter:none;border-color:canvastext}.DT2SAW_linkMenu[data-menu-material] [role=menuitem]:is(:hover,:focus-visible){outline-offset:-1px;outline:1px solid highlight}}`,document.head.appendChild(e)}var Hy={linkMenu:`DT2SAW_linkMenu`};function Uy({children:e,openFile:t,openLinkInSidebar:n,hideLocalFileActions:r=!1,t:i,...a}){let[o,s]=(0,d.useState)(null),[c,l]=(0,d.useState)(!1),u=(0,d.useCallback)(()=>s(null),[]),m=(0,d.useCallback)(()=>o?.position??null,[o]),h=(0,d.useCallback)(e=>i(`codeBlock.expand`,{count:e}),[i]),g=i(`codeBlock.collapse`);return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(p.MarkdownDelegateProvider,{collapsibleCodeBlocks:!0,expandCodeLabel:h,collapseCodeLabel:g,...a,openFile:t,onLinkContextMenu:s,children:e}),/* @__PURE__ */ (0,f.jsx)(p.Menu,{anchor:null,open:o!==null,portal:!0,compact:!0,autoFocus:!0,listClassName:Hy.linkMenu,getAnchorRect:m,focusReturnTarget:o?.trigger,onClose:u,children:o!==null&&/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[(o.kind===`file`||n!==void 0)&&/* @__PURE__ */ (0,f.jsx)(p.MenuItemButton,{icon:o.kind===`file`?/* @__PURE__ */ (0,f.jsx)(p.LinkIconMedium,{kind:`document`}):/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineMedium,{}),onSelect:()=>{u(),o.kind===`file`?t(o.path,o.line===void 0?void 0:{line:o.line}):n?.(o.href)},children:i(`linkMenu.openInCodexhost`)}),/* @__PURE__ */ (0,f.jsx)(p.MenuItemButton,{icon:/* @__PURE__ */ (0,f.jsx)(p.IconLinkOutlineMedium,{}),onSelect:()=>{u(),(0,p.writeClipboard)(o.href).then(e=>l(!e))},children:i(`linkMenu.copy`)}),(o.kind===`web`||!r)&&/* @__PURE__ */ (0,f.jsx)(p.MenuItemButton,{icon:/* @__PURE__ */ (0,f.jsx)(p.IconRightUpOutlineMedium,{}),onSelect:()=>{u(),o.kind===`web`?window.open(o.href,`_blank`,`noopener,noreferrer`):t(o.path,{external:!0,...o.line===void 0?{}:{line:o.line}})},children:i(o.kind===`web`?`linkMenu.openBrowser`:`linkMenu.openFile`)}),o.kind===`file`&&!r&&/* @__PURE__ */ (0,f.jsx)(p.MenuItemButton,{icon:/* @__PURE__ */ (0,f.jsx)(p.IconFolderOpenOutlineMedium,{}),onSelect:()=>{u(),t(o.path,{reveal:!0})},children:i(`linkMenu.openFolder`)})]})}),c&&/* @__PURE__ */ (0,f.jsx)(p.Toast,{text:i(`linkMenu.copyFailed`),onDone:()=>l(!1)})]})}let Wy=`@deepseek-ai/dsh-client-ui-chat/HandoffDivider.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Wy)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Wy,e.textContent=`.SfZcya_root{flex-direction:column;gap:10px;width:100%;min-width:0;padding:6px 0 8px;display:flex}.SfZcya_dividerBar{align-items:center;gap:10px;width:100%;min-width:0;display:flex}.SfZcya_line{background:var(--dsw-alias-border-l2);opacity:.72;flex:20px;min-width:12px;height:1px}.SfZcya_trigger{border-radius:var(--dsw-radius-sm,8px);min-width:0;max-width:calc(100% - 36px);color:var(--dsw-alias-label-tertiary);font:inherit;font-size:var(--dsh-content-font-size-secondary,13px);cursor:pointer;background:0 0;border:none;flex-wrap:wrap;justify-content:center;align-items:center;gap:4px 7px;padding:4px 10px;line-height:20px;transition:background-color .12s,color .12s;display:inline-flex}.SfZcya_trigger:hover,.SfZcya_trigger[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover)}.SfZcya_trigger:focus-visible{outline:2px solid var(--dsw-alias-link);outline-offset:1px}.SfZcya_titleGroup{color:var(--dsw-alias-label-tertiary);flex-shrink:0;align-items:center;gap:5px;display:inline-flex}.SfZcya_swapIcon{opacity:.85;flex-shrink:0}.SfZcya_endpoints{flex-wrap:wrap;justify-content:center;align-items:center;gap:2px 6px;min-width:0;max-width:100%;display:inline-flex}.SfZcya_endpoint{align-items:center;gap:5px;min-width:0;max-width:100%;display:inline-flex}.SfZcya_sourceLabel{color:var(--dsw-alias-label-secondary);text-overflow:ellipsis;white-space:nowrap;max-width:240px;font-weight:450;overflow:hidden}.SfZcya_arrow{color:var(--dsw-alias-label-caption);flex-shrink:0;font-size:12px;line-height:1}.SfZcya_targetLabel{color:color-mix(in srgb, var(--dsw-alias-link) 82%, var(--dsw-alias-label-secondary));text-overflow:ellipsis;white-space:nowrap;max-width:240px;font-weight:500;overflow:hidden}.SfZcya_chevron{color:var(--dsw-alias-label-caption);opacity:.55;flex-shrink:0;align-items:center;transition:transform .14s,opacity .12s;display:inline-flex}.SfZcya_trigger:hover .SfZcya_chevron,.SfZcya_trigger[aria-expanded=true] .SfZcya_chevron{opacity:.95}.SfZcya_chevronOpen{transform:rotate(180deg)}.SfZcya_panel{border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-md,10px);background:var(--dsw-alias-bg-module-platform);flex-direction:column;gap:10px;min-width:0;padding:12px 14px;display:flex}body[data-codexhost-wallpaper] .SfZcya_panel{background:color-mix(in srgb, var(--dsw-alias-bg-module-platform) 84%, transparent);backdrop-filter:blur(12px)}body[data-codexhost-wallpaper] [data-chat-flow-key]:not([data-chat-flow-key] *,[data-chat-near-viewport]) .SfZcya_panel,body[data-codexhost-wallpaper] [data-chat-near-viewport-gate]:not([data-chat-near-viewport]) .SfZcya_panel{backdrop-filter:none}.SfZcya_panelHeader{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:8px;display:flex}.SfZcya_turnSummary{color:var(--dsw-alias-label-secondary);font-size:12.5px;line-height:18px}.SfZcya_sourceButton{border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm,6px);background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);font:inherit;cursor:pointer;flex-shrink:0;align-items:center;gap:5px;padding:4px 10px;font-size:12px;font-weight:500;line-height:16px;transition:background-color .12s,border-color .12s;display:inline-flex}.SfZcya_sourceButton:hover{background:var(--dsw-alias-interactive-bg-hover-solid);border-color:var(--dsw-alias-border-l3)}.SfZcya_sourceButton:focus-visible{outline:2px solid var(--dsw-alias-link);outline-offset:1px}.SfZcya_preview{border:1px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-sm,6px);background:var(--dsw-alias-bg-base);max-height:260px;color:var(--dsw-alias-label-secondary);white-space:pre-wrap;overflow-wrap:anywhere;margin:0;padding:10px 12px;font-family:inherit;font-size:12.5px;line-height:1.55;overflow-y:auto}.SfZcya_previewEmpty{color:var(--dsw-alias-label-tertiary);font-style:italic}@media (width<=520px){.SfZcya_dividerBar{gap:6px}.SfZcya_line{flex-basis:10px;min-width:8px}.SfZcya_trigger{column-gap:5px;max-width:calc(100% - 28px);padding:4px 6px;font-size:12px;line-height:18px}.SfZcya_sourceLabel,.SfZcya_targetLabel{max-width:148px}.SfZcya_panel{padding:10px 12px}}`,document.head.appendChild(e)}var Gy={arrow:`SfZcya_arrow`,chevron:`SfZcya_chevron`,chevronOpen:`SfZcya_chevronOpen`,dividerBar:`SfZcya_dividerBar`,endpoint:`SfZcya_endpoint`,endpoints:`SfZcya_endpoints`,line:`SfZcya_line`,panel:`SfZcya_panel`,panelHeader:`SfZcya_panelHeader`,preview:`SfZcya_preview`,previewEmpty:`SfZcya_previewEmpty`,root:`SfZcya_root`,sourceButton:`SfZcya_sourceButton`,sourceLabel:`SfZcya_sourceLabel`,swapIcon:`SfZcya_swapIcon`,targetLabel:`SfZcya_targetLabel`,titleGroup:`SfZcya_titleGroup`,trigger:`SfZcya_trigger`,turnSummary:`SfZcya_turnSummary`};let Ky=(0,d.memo)(function({handoff:e,hostId:t,onOpenSource:n,t:r}){let[i,a]=(0,d.useState)(!1),o=(0,d.useId)(),s=Ag({harnessId:e.sourceHarnessId,harnessLabel:e.sourceHarnessLabel,model:e.sourceModel}),c=Ag({harnessId:e.targetHarnessId,harnessLabel:e.targetHarnessLabel,model:e.targetModel}),l=e.includedTurnNumbers.length,u=e.omittedTurns>0?r(`handoff.divider.turnsPartial`,{included:l,total:e.totalTurns,omitted:e.omittedTurns,boundary:e.boundaryTurnNumber}):e.boundaryTurnNumber<e.totalTurns?r(`handoff.divider.turnsPrefix`,{boundary:e.boundaryTurnNumber,total:e.totalTurns}):r(`handoff.divider.turnsAll`,{total:e.totalTurns}),m=e.preview.trim();return/* @__PURE__ */ (0,f.jsxs)(`section`,{className:Gy.root,"data-handoff-divider":``,"aria-label":r(`handoff.divider.label`),children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Gy.dividerBar,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Gy.line,"aria-hidden":`true`}),/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Gy.trigger,"aria-expanded":i,"aria-controls":o,"aria-label":r(i?`handoff.divider.collapse`:`handoff.divider.expand`),onClick:()=>{a(e=>!e)},children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:Gy.titleGroup,children:[/* @__PURE__ */ (0,f.jsx)(Mg,{size:14,className:Gy.swapIcon}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:r(`handoff.divider.label`)})]}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:Gy.endpoints,children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:Gy.endpoint,title:s.title,children:[/* @__PURE__ */ (0,f.jsx)(Ng,{harnessId:e.sourceHarnessId,label:e.sourceHarnessLabel??e.sourceHarnessId,hostId:t,size:15}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Gy.sourceLabel,children:s.display})]}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Gy.arrow,"aria-hidden":`true`,children:`→`}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:Gy.endpoint,title:c.title,children:[/* @__PURE__ */ (0,f.jsx)(Ng,{harnessId:e.targetHarnessId,label:e.targetHarnessLabel??e.targetHarnessId,hostId:t,size:15}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Gy.targetLabel,children:c.display})]})]}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:i?`${Gy.chevron} ${Gy.chevronOpen}`:Gy.chevron,"aria-hidden":`true`,children:/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:12})})]}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Gy.line,"aria-hidden":`true`})]}),i&&/* @__PURE__ */ (0,f.jsxs)(`div`,{id:o,className:Gy.panel,"data-handoff-panel":``,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Gy.panelHeader,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Gy.turnSummary,children:u}),/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Gy.sourceButton,onClick:()=>{n(e.sourceThreadId)},children:[/* @__PURE__ */ (0,f.jsx)(`span`,{children:r(`handoff.divider.openSource`)}),/* @__PURE__ */ (0,f.jsx)(`span`,{"aria-hidden":`true`,children:`↗`})]})]}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:m===``?`${Gy.preview} ${Gy.previewEmpty}`:Gy.preview,children:m===``?r(`handoff.divider.previewEmpty`):e.preview})]})]})}),qy=`@deepseek-ai/dsh-client-ui-chat/HandoffModal.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(qy)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=qy,e.textContent=`.psMsOW_dialog{width:min(440px,100%)}.psMsOW_sections{flex-direction:column;gap:16px;min-width:0;display:flex}.psMsOW_section{flex-direction:column;gap:8px;min-width:0;display:flex}.psMsOW_sectionLabel{color:var(--dsw-alias-label-secondary);font-size:12.5px;font-weight:500;line-height:18px}.psMsOW_harnessGrid{grid-template-columns:repeat(auto-fill,minmax(128px,1fr));gap:8px;display:grid}.psMsOW_harnessOption{border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm,8px);background:var(--dsw-alias-bg-base);min-width:0;color:var(--dsw-alias-label-primary);font:inherit;text-align:left;cursor:pointer;align-items:center;gap:8px;padding:8px 10px;font-size:13px;line-height:18px;transition:background-color .12s,border-color .12s;display:flex}.psMsOW_harnessOption:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);border-color:var(--dsw-alias-border-l3)}.psMsOW_harnessOption[data-selected]{border-color:var(--dsw-alias-link);background:color-mix(in srgb, var(--dsw-alias-link) 10%, var(--dsw-alias-bg-base))}.psMsOW_harnessOption:disabled{opacity:.55;cursor:default}.psMsOW_harnessName{text-overflow:ellipsis;white-space:nowrap;flex:auto;min-width:0;font-weight:500;overflow:hidden}.psMsOW_checkIcon{color:var(--dsw-alias-link);flex-shrink:0}.psMsOW_searchInput{width:100%}.psMsOW_modelList{border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm,8px);background:var(--dsw-alias-bg-module-platform);flex-direction:column;gap:4px;max-height:216px;padding:4px;display:flex;overflow-y:auto}.psMsOW_modelOption{border-radius:var(--dsw-radius-sm,6px);width:100%;min-width:0;color:var(--dsw-alias-label-primary);font:inherit;text-align:left;cursor:pointer;background:0 0;border:none;justify-content:space-between;align-items:center;gap:8px;padding:7px 10px;font-size:13px;line-height:18px;transition:background-color .1s;display:flex}.psMsOW_modelOption:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.psMsOW_modelOption[data-selected]{background:var(--dsw-alias-bg-base);box-shadow:inset 0 0 0 1px color-mix(in srgb, var(--dsw-alias-link) 45%, var(--dsw-alias-border-l2))}.psMsOW_modelOption:disabled{opacity:.55;cursor:default}.psMsOW_modelInfo{flex-direction:column;flex:auto;min-width:0;display:flex}.psMsOW_modelTitleRow{align-items:center;gap:6px;min-width:0;display:flex}.psMsOW_modelName{text-overflow:ellipsis;white-space:nowrap;font-weight:450;overflow:hidden}.psMsOW_defaultBadge{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-tertiary);border-radius:4px;flex-shrink:0;padding:1px 5px;font-size:11px;line-height:14px}.psMsOW_modelDesc{text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-tertiary);font-size:11.5px;line-height:16px;overflow:hidden}.psMsOW_status{color:var(--dsw-alias-label-secondary);align-items:center;gap:8px;padding:12px 2px;font-size:13px;line-height:18px;display:flex}.psMsOW_empty{color:var(--dsw-alias-label-tertiary);padding:10px;font-size:12.5px;line-height:18px}.psMsOW_errorBox{border-radius:var(--dsw-radius-sm,8px);border:1px solid color-mix(in srgb, var(--dsw-alias-state-error-primary) 28%, transparent);background:color-mix(in srgb, var(--dsw-alias-state-error-primary) 8%, transparent);color:var(--dsw-alias-state-error-primary);justify-content:space-between;align-items:center;gap:8px;padding:9px 11px;font-size:12.5px;line-height:18px;display:flex}.psMsOW_errorText{overflow-wrap:anywhere;min-width:0}.psMsOW_modalAction{min-width:78px}.psMsOW_submittingContent{align-items:center;gap:6px;display:inline-flex}@media (width<=640px){.psMsOW_harnessGrid{grid-template-columns:repeat(2,minmax(0,1fr))}}`,document.head.appendChild(e)}var X={checkIcon:`psMsOW_checkIcon`,defaultBadge:`psMsOW_defaultBadge`,dialog:`psMsOW_dialog`,empty:`psMsOW_empty`,errorBox:`psMsOW_errorBox`,errorText:`psMsOW_errorText`,harnessGrid:`psMsOW_harnessGrid`,harnessName:`psMsOW_harnessName`,harnessOption:`psMsOW_harnessOption`,modalAction:`psMsOW_modalAction`,modelDesc:`psMsOW_modelDesc`,modelInfo:`psMsOW_modelInfo`,modelList:`psMsOW_modelList`,modelName:`psMsOW_modelName`,modelOption:`psMsOW_modelOption`,modelTitleRow:`psMsOW_modelTitleRow`,searchInput:`psMsOW_searchInput`,section:`psMsOW_section`,sectionLabel:`psMsOW_sectionLabel`,sections:`psMsOW_sections`,status:`psMsOW_status`,submittingContent:`psMsOW_submittingContent`};function Jy(e,t){if(t===void 0||t.models.length===0)return;let n=e.rememberedSelections?.[t.id]?.model;return n!==void 0&&t.models.some(e=>e.id===n)?n:e.default?.provider===t.id&&t.models.some(t=>t.id===e.default?.model)?e.default.model:t.models[0]?.id}function Yy(e,t,n){if(e===null||t===void 0||n===void 0)return;let r=t.models.find(e=>e.id===n),i=r?.reasoning?.efforts;if(i===void 0||i.length===0)return;let a=e.rememberedSelections?.[t.id];if(a?.model===n&&a.reasoningEffort!==void 0&&i.some(e=>e.id===a.reasoningEffort))return a.reasoningEffort;if(r?.reasoning?.defaultEffort!==void 0&&i.some(e=>e.id===r.reasoning?.defaultEffort))return r.reasoning.defaultEffort}function Xy(e){if(e===null)return[];let t=e.harnessOrder??[];return[...e.groups].sort((e,n)=>{let r=t.indexOf(e.id),i=t.indexOf(n.id);return(r<0?1/0:r)-(i<0?1/0:i)})}function Zy(e,t,n){if(e.length!==0){if(n!==void 0){let t=e.find(e=>e.id===n);if(t!==void 0)return t}return e.find(e=>e.id!==t)??e[0]}}function Qy({open:e,atSeq:t,currentHarnessId:n,initialHarnessId:r,loadModelCatalog:i,onSubmit:a,onClose:o,t:s}){let[c,l]=(0,d.useState)(null),[u,m]=(0,d.useState)(`idle`),[h,g]=(0,d.useState)(null),[_,v]=(0,d.useState)(null),[y,b]=(0,d.useState)(void 0),[x,S]=(0,d.useState)(``),[C,w]=(0,d.useState)(!1),[T,E]=(0,d.useState)(null),ee=(0,d.useCallback)(()=>{let e=!0;return m(`loading`),g(null),i().then(t=>{if(!e)return;let i=Zy(Xy(t),n,r);l(t),m(`ready`),v(i?.id??null),b(Jy(t,i))},t=>{e&&(m(`error`),g(t instanceof Error?t.message:String(t)))}),()=>{e=!1}},[n,r,i]);(0,d.useEffect)(()=>{if(e)return E(null),S(``),ee()},[e,ee]);let D=(0,d.useMemo)(()=>Xy(c),[c]),O=(0,d.useMemo)(()=>D.find(e=>e.id===_),[D,_]),te=(0,d.useMemo)(()=>c===null?void 0:Jy(c,O),[c,O]),ne=(O?.models.length??0)>6,re=(0,d.useMemo)(()=>{let e=O?.models??[];return!ne||x.trim()===``?e:(0,p.rankByName)(e,x.trim())},[x,O?.models,ne]),ie=e=>{C||(v(e.id),b(c===null?e.models[0]?.id:Jy(c,e)),S(``),E(null))},ae=()=>{if(C||_===null)return;let e=Yy(c,O,y),n=y===void 0||y===`harness`?void 0:y;w(!0),E(null),a({...t===void 0?{}:{atSeq:t},targetHarnessId:_,...n===void 0?{}:{targetModel:n},...e===void 0?{}:{targetThinkingOptionId:e}}).then(()=>{w(!1),o()},e=>{w(!1),E(e instanceof Error?e.message:String(e))})},oe=!C&&u===`ready`&&_!==null;return/* @__PURE__ */ (0,f.jsx)(p.Modal,{open:e,onClose:C?()=>{}:o,closeLabel:s(`close`),title:s(`handoff.modal.title`),description:s(`handoff.modal.description`),className:X.dialog,footer:/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`outline`,className:X.modalAction,disabled:C,onClick:o,children:s(`cancel`)}),/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`primary`,className:X.modalAction,disabled:!oe,onClick:ae,children:C?/* @__PURE__ */ (0,f.jsxs)(`span`,{className:X.submittingContent,children:[/* @__PURE__ */ (0,f.jsx)(p.StateDot,{state:`ongoing`}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:s(`handoff.modal.submitting`)})]}):s(`handoff.modal.confirm`)})]}),children:/* @__PURE__ */ (0,f.jsxs)(`div`,{className:X.sections,"data-handoff-modal":``,children:[u===`loading`&&c===null&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:X.status,role:`status`,children:[/* @__PURE__ */ (0,f.jsx)(p.StateDot,{state:`ongoing`}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:s(`handoff.modal.loadingCatalog`)})]}),u===`error`&&h!==null&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:X.errorBox,role:`alert`,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.errorText,children:s(`handoff.modal.catalogError`,{message:h})}),/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`outline`,size:`sm`,onClick:()=>void ee(),children:s(`retry`)})]}),c!==null&&D.length===0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.empty,children:s(`handoff.modal.noHarnesses`)}),D.length>0&&/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:X.section,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.sectionLabel,children:s(`handoff.modal.targetHarness`)}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.harnessGrid,role:`radiogroup`,"aria-label":s(`handoff.modal.targetHarness`),children:D.map(e=>{let t=e.id===_;return/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,"data-selected":t||void 0,disabled:C,className:X.harnessOption,onClick:()=>ie(e),children:[/* @__PURE__ */ (0,f.jsx)(Ng,{harnessId:e.id,label:e.name,size:16}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.harnessName,children:e.name}),t&&/* @__PURE__ */ (0,f.jsx)(p.IconCheckOutlineRegular,{size:14,className:X.checkIcon})]},e.id)})})]}),O!==void 0&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:X.section,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.sectionLabel,children:s(`handoff.modal.targetModel`)}),ne&&/* @__PURE__ */ (0,f.jsx)(p.Input,{className:X.searchInput,type:`text`,role:`searchbox`,placeholder:s(`handoff.modal.searchModels`),"aria-label":s(`handoff.modal.searchModels`),value:x,disabled:C,onChange:e=>{S(e.target.value)}}),O.models.length===0?/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.empty,children:s(`handoff.modal.noModels`)}):/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.modelList,role:`radiogroup`,"aria-label":s(`handoff.modal.targetModel`),children:re.length===0?/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.empty,children:s(`handoff.modal.noMatchingModels`)}):re.map(e=>{let t=e.id===y,n=e.id===te;return/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,"data-selected":t||void 0,disabled:C,className:X.modelOption,onClick:()=>{b(e.id),E(null)},children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:X.modelInfo,children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:X.modelTitleRow,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.modelName,children:e.name}),n&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.defaultBadge,children:s(`handoff.modal.defaultBadge`)})]}),e.description!==void 0&&e.description!==``&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.modelDesc,children:e.description})]}),t&&/* @__PURE__ */ (0,f.jsx)(p.IconCheckOutlineRegular,{size:14,className:X.checkIcon})]},e.id)})})]})]}),T!==null&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:X.errorBox,role:`alert`,children:/* @__PURE__ */ (0,f.jsx)(`span`,{className:X.errorText,children:s(`handoff.modal.failed`,{message:T})})})]})})}function $y(e,t,n){if(/^https?:/u.test(e)&&n!==``&&!/[\u0000-\u001f\u007f]/u.test(n))return new URL(`/api/remote-peer/file?sessionId=${encodeURIComponent(t)}&path=${encodeURIComponent(n)}`,e).href}function eb(e,t){let n=e instanceof Error?e.message:String(e);return n===``?t:n}function tb(e,t){let n=/* @__PURE__ */ new Set,r;for(let i of e){let e=t.get(i);if(e===void 0||e.kind!==`user`&&e.kind!==`steering`&&e.kind!==`turn-trigger`||((e.location.kind===`turn`||e.location.kind===`step`)&&(r=e.location.turn.turn),e.kind===`turn-trigger`))continue;let a=e.data.source;a?.kind===`user`&&typeof a.rpcId==`string`&&n.add(a.rpcId)}return{rpcIds:n,lastInputTurn:r}}let nb=(0,d.memo)(function({entries:e,useChatGroup:t,pendingInputs:n,lastInputTurn:r,...i}){let a=e.map(e=>{switch(e.kind){case`node`:return/* @__PURE__ */ (0,d.createElement)(Z_,{...i,key:iv(e),nodeKey:e.key,...e.groupPart===void 0?{}:{groupPart:e.groupPart}});case`group`:return/* @__PURE__ */ (0,d.createElement)(Sv,{...i,key:iv(e),groupKey:e.key,useChatGroup:t});default:return rv(e)}}),o=n.map(e=>`requestId`in e?/* @__PURE__ */ (0,f.jsx)(p_,{submission:e,renderMessageImages:i.renderMessageImages,t:i.t},e.requestId):/* @__PURE__ */ (0,f.jsx)(f_,{content:e.content,renderMessageImages:i.renderMessageImages,t:i.t},e.id)),s=e.at(-1),c=s?.kind===`node`?i.nodeStore.get(s.key):void 0;if(c?.kind===`turn-process`&&c.location.kind===`turn`&&c.location.turn.status===`open`&&c.location.turn.turn!==r){let e=n.findIndex(e=>`requestId`in e&&e.placement===`transcript`);e!==-1&&a.splice(a.length-1,0,...o.splice(e,1))}return[...a,...o]});function rb({connection:e,useSession:t,useChat:n,useChatNode:r,useChatNodeProcess:i,useChatGroup:a,useConversation:o,useSessions:s,useStore:c,actions:l,renderSlot:u,sessionId:m,openFile:h,openSkill:g,openExternalLink:_,openLinkInSidebar:v,useBrowserAvailable:y,resolveLink:b,loadOlder:x,loadThrough:S,loadImage:C,inspectCall:w,chatScroll:T,forkAt:E,openSession:ee,handoff:D,clearHandoffRequest:O,loadModelCatalog:te,loadTurnDiffs:ne,editMessage:re,fileMentions:ae,usePresentation:se,useHandoffRequest:ce,useProjection:le,useInput:ue,inputActions:de,viewRequest:fe,completeViewRequest:pe,t:k}){let me=n(e=>e.order),he=y(e=>e),ge=o(e=>e.views.grouped(`chat`)?.entries),_e=(0,d.useMemo)(()=>ge??me.map(e=>({kind:`node`,key:e})),[ge,me]),ve=n(e=>e.nodes),ye=n(e=>e.navigation.items()),be=ye.at(-1)?.anchorKey,xe=r(be??``,e=>{let t=e?.location;return(t?.kind===`turn`||t?.kind===`step`)&&t.turn.status===`open`?t.turn.start?.time:void 0}),Se=le(`turnOutline`),Ce=(0,d.useMemo)(()=>dy(ye,Se),[ye,Se]),we=le(`inbox`),Te=s(e=>e.byId[m]?.cwd),Ee=s(e=>e.byId[m]?.projectionValues?.remoteHost?.hostId),De=s(e=>(e.byId[m]?.projectionValues)?.harnessIdentity?.id),Oe=s(e=>!!e.byId[m]?.projectionValues?.remoteHost),ke=s(e=>{let t=e.byId[m]?.projectionValues?.remoteHost;return t?.hostId.startsWith(`remote-peer:`)===!0&&t.filePreview===!0}),Ae=(0,d.useMemo)(()=>({resolve:e=>{if(ke)return $y(document.baseURI,m,e);if(!Oe)return oe(document.baseURI,ie(Te,e))},labels:{open:k(`image.open`),loading:k(`image.loading`),failed:k(`image.failed`),dialog:k(`image.dialog`),close:k(`image.close`)}}),[Te,Oe,ke,m,k]),je=(0,d.useCallback)(e=>de?.addResponseAnnotation(e,{focus:`end`})!==void 0,[de]),Me=t(e=>e.running),Ne=t(e=>e.subagent),Pe=t(e=>e.removed),Fe=de!==void 0&&!Pe&&(Ne===null||Ne.address.mode===`continuable`&&Ne.parentAvailable===!0),Ie=(0,d.useSyncExternalStore)(e.state.subscribe,e.state.getSnapshot),Le=(0,p.useSustainedRecovery)(Ie!==`connected`),Re=le(`compacting`),ze=le(`codexhostHandoff`),Be=ce(e=>e),[Ve,He]=(0,d.useState)(null),A=Ve?.sessionId===m?Ve:null,Ue=(0,d.useCallback)(e=>{He({sessionId:m,atSeq:e})},[m]),We=(0,d.useCallback)(()=>{He(null)},[]),Ge=D!==void 0&&te!==void 0;(0,d.useEffect)(()=>{Be!==null&&Be.sessionId===m&&Ge&&(He({sessionId:m,...Be.atSeq===void 0?{}:{atSeq:Be.atSeq},...Be.targetHarnessId===void 0?{}:{initialHarnessId:Be.targetHarnessId}}),O(Be.seq))},[O,Ge,Be,m]);let Ke=t(e=>e.openState),qe=le(`remoteHistoryError`),Je=le(`nativeConnection`),Ye=Ie===`disconnected`||Le||Ke===`error`||!!qe||Je?.state===`reconnecting`,Xe=t(e=>e.openError),Ze=t(e=>e.hasMore),Qe=t(e=>e.loadingOlder),$e=t(e=>e.olderError),[et,tt]=(0,d.useState)(null),[nt,rt]=(0,d.useState)(!1),it=(0,d.useRef)(0),at=(0,d.useCallback)((e,t)=>{let n=++it.current;rt(!0),(t===void 0?h(e):h(e,t)).then(()=>{n===it.current&&(tt(null),rt(!1))},r=>{n===it.current&&(tt({path:e,options:t,message:eb(r,k(t?.reveal?`fileOpen.folder`:`fileOpen.unknown`))}),rt(!1))})},[h,k]),ot=(0,d.useCallback)(()=>{it.current+=1,tt(null),rt(!1)},[]),st=(0,d.useMemo)(()=>we?.[`next-step`].filter(e=>e.source.kind===`user`)??[],[we]),ct=t(e=>e.pendingSubmissions),lt=Qg(re,le(`sentMessageEdit`)?.seq??null,Ke!==`open`||Me||ct.length>0||(we?.[`next-turn`].length??0)>0),ut=lt.draft&&me.some(e=>{let t=ve.get(e);return t?.kind===`user`&&t.data.seq===lt.draft?.seq}),dt=Me||ct.some(e=>e.placement!==`queued`),[ft,pt]=(0,d.useMemo)(()=>{if(ct.length===0)return[ct,void 0];let e=tb(me,ve);return[ct.filter(t=>t.placement!==`queued`&&!e.rpcIds.has(t.requestId)),e.lastInputTurn]},[ct,me,ve]),mt=(0,d.useMemo)(()=>{let e=new Map(ft.map(e=>[e.requestId,e])),t=new Set(ct.filter(e=>e.placement!==`queued`).map(e=>e.requestId));return[...st.flatMap(n=>{let r=n.source;if(r.kind!==`user`||!(`rpcId`in r))return[n];let i=e.get(r.rpcId);return i===void 0?t.has(r.rpcId)?[]:[n]:(e.delete(r.rpcId),[i])}),...e.values()]},[st,ct,ft]),ht=(0,d.useCallback)(e=>u(`conversation.message.images`,{...e,loadImage:C}),[C,u]),gt=me[0],_t=gt===void 0?null:ve.get(gt)?.anchorSeq??null,vt=me.at(-1)??null,yt=mt.findLast(e=>`source`in e),bt=yt?.source.kind===`user`&&`rpcId`in yt.source?yt.source.rpcId:yt?.id??null,xt=by({displayReady:Ke===`open`||me.length>0,historyReady:Ke===`open`,order:me,firstSeq:_t,lastKey:vt,running:Me,loadingOlder:Qe,olderFailed:$e!=null,hasMore:Ze,chatScroll:T,loadOlder:x,loadThrough:S,lastIsUser:vt!==null&&ve.get(vt)?.kind===`user`,steeringId:bt,submissionId:ft.at(-1)?.requestId??null,loadedTurns:ye}),St=ue(e=>e.responseAnnotations.find(e=>e.id===fe?.focus)),{initialized:j,revealResponseAnnotation:Ct}=xt,wt=(0,d.useRef)(null),Tt=!Ze&&ze!=null;return P_(wt,Tt),(0,d.useLayoutEffect)(()=>{j&&fe?.view===`chat`&&(St!==void 0&&Ct(St),pe())},[j,fe,St,Ct,pe]),/* @__PURE__ */ (0,f.jsxs)(`div`,{className:V_.frame,children:[xt.initialized&&/* @__PURE__ */ (0,f.jsx)(ey,{items:Ce,activeTurn:xt.activeTurn,busyTurn:xt.busyTurn,onNavigate:xt.navigateToTurn,t:k}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:V_.root,"data-chat-following-tail":xt.followingTail?``:void 0,children:/* @__PURE__ */ (0,f.jsx)(`div`,{ref:xt.listRef,className:V_.scroll,children:/* @__PURE__ */ (0,f.jsxs)(`div`,{ref:xt.columnRef,className:V_.column,"data-chat-flow":``,children:[Ke===`loading`&&me.length===0&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:V_.hint,children:k(`chat.loadingHistory`)}),Ke===`error`&&Xe!==null&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:V_.openError,children:k(`chat.loadError`,{message:Xe.message,code:Xe.code})}),Ze&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:V_.older,children:$e==null?/* @__PURE__ */ (0,f.jsx)(`span`,{role:Qe?`status`:void 0,children:k(Qe?`chat.loadingOlder`:`chat.scrollOlder`)}):/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{role:`alert`,children:k(`chat.loadOlderError`,{message:$e.message})}),/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,disabled:Qe,onClick:xt.loadEarlier,children:k(`chat.retryOlder`)})]})}),Tt&&/* @__PURE__ */ (0,f.jsx)(`div`,{ref:wt,"data-chat-near-viewport-gate":``,children:/* @__PURE__ */ (0,f.jsx)(Ky,{handoff:ze,hostId:Ee,onOpenSource:ee,t:k})}),/* @__PURE__ */ (0,f.jsx)(Uy,{openExternalLink:_,openLinkInSidebar:he?v:void 0,hideLocalFileActions:Oe,resolveLink:b,openFile:at,fileImages:Ae,t:k,children:/* @__PURE__ */ (0,f.jsx)(nb,{entries:_e,pendingInputs:mt,lastInputTurn:pt,nodeStore:ve,useChatGroup:a,useChatNode:r,useChatNodeProcess:i,usePresentation:se,useStore:c,actions:l,cwd:Te,openFile:at,openSkill:g,inspectCall:w,forkAt:E,handoffAt:Ge?Ue:void 0,loadTurnDiffs:ne,messageEditing:lt,loadImage:C,renderMessageImages:ht,fileMentions:ae,renderSlot:u,t:k})},m),lt.draft&&!ut&&/* @__PURE__ */ (0,f.jsx)(h_,{editing:lt,renderMessageImages:ht,t:k}),dt&&/* @__PURE__ */ (0,f.jsx)(iy,{startTime:xe,compacting:Re,stale:Ye,t:k}),Ke===`loading`&&me.length>0&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:V_.syncing,role:`status`,"data-history-syncing":!0,children:[/* @__PURE__ */ (0,f.jsx)(p.StateDot,{state:`ongoing`,className:V_.syncingIcon}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:k(`chat.syncing`)})]})]})})}),Fe&&/* @__PURE__ */ (0,f.jsx)(By,{labels:{addToChat:k(`selection.addToChat`),comment:k(`selection.comment`),placeholder:k(`selection.commentPlaceholder`),submit:k(`selection.commentSubmit`),cancel:k(`message.edit.cancel`),unavailable:k(`selection.commentUnavailable`)},onAdd:je,container:xt.columnRef},m),!xt.followingTail&&/* @__PURE__ */ (0,f.jsx)(`div`,{className:V_.toBottomSlot,children:/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:V_.toBottom,"aria-label":k(`chat.toBottom`),onClick:xt.returnToBottom,children:/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{})})}),A!==null&&D!==void 0&&te!==void 0&&/* @__PURE__ */ (0,f.jsx)(Qy,{open:!0,atSeq:A.atSeq,currentHarnessId:De,initialHarnessId:A.initialHarnessId,loadModelCatalog:te,onSubmit:D,onClose:We,t:k},`${m}:${A.atSeq??`latest`}:${A.initialHarnessId??`auto`}`),et!==null&&/* @__PURE__ */ (0,f.jsx)(ib,{title:k(et.options?.reveal?`fileOpen.folder`:`fileOpen.title`),message:et.message,busy:nt,onClose:ot,onRetry:()=>{at(et.path,et.options)},t:k})]})}function ib({title:e,message:t,busy:n,onClose:r,onRetry:i,t:a}){return/* @__PURE__ */ (0,f.jsx)(p.Modal,{open:!0,onClose:r,closeLabel:a(`close`),title:e,description:t,footer:/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`outline`,className:V_.modalAction,onClick:r,children:a(`cancel`)}),/* @__PURE__ */ (0,f.jsx)(p.Button,{variant:`primary`,className:V_.modalAction,disabled:n,onClick:i,children:a(`retry`)})]})})}let ab=`chat`,ob={"message.stepProcess.thinking":`正在分析请求`,"message.stepProcess.read":`正在读取文件`,"message.stepProcess.readImage":`正在读取图片`,"message.stepProcess.write":`正在写入文件`,"message.stepProcess.search":`正在搜索代码`,"message.stepProcess.edit":`正在编辑文件`,"message.stepProcess.commands":`正在运行命令`,"message.stepProcess.code":`正在运行代码`,"message.stepProcess.webSearch":`正在搜索网页`,"message.stepProcess.webFetch":`正在访问网页`,"message.stepProcess.subagents":`正在协调子智能体`,"message.stepProcess.plan":`正在更新计划`,"message.stepProcess.questions":`等待你的操作`,"message.stepProcess.tools":`正在调用工具`,"message.stepProcess.prepare.read":`准备读取文件`,"message.stepProcess.prepare.readImage":`准备读取图片`,"message.stepProcess.prepare.write":`准备写入文件`,"message.stepProcess.prepare.search":`准备搜索代码`,"message.stepProcess.prepare.edit":`准备编辑文件`,"message.stepProcess.prepare.commands":`准备运行命令`,"message.stepProcess.prepare.code":`准备运行代码`,"message.stepProcess.prepare.webSearch":`准备搜索网页`,"message.stepProcess.prepare.webFetch":`准备访问网页`,"message.stepProcess.prepare.subagents":`准备协调子智能体`,"message.stepProcess.prepare.plan":`准备更新计划`,"message.stepProcess.prepare.questions":`准备提问`,"message.stepProcess.prepare.tools":`准备调用工具`,"message.stepProcess.done.thinking":`已完成分析`,"message.stepProcess.done.read":`已读取文件`,"message.stepProcess.done.readImage":`已读取图片`,"message.stepProcess.done.write":`已写入文件`,"message.stepProcess.done.search":`已搜索代码`,"message.stepProcess.done.edit":`修改了文件`,"message.stepProcess.done.commands":`执行了命令`,"message.stepProcess.done.code":`运行了代码`,"message.stepProcess.done.webSearch":`已搜索网页`,"message.stepProcess.done.webFetch":`已访问网页`,"message.stepProcess.done.subagents":`已协调子智能体`,"message.stepProcess.done.plan":`更新了计划`,"message.stepProcess.done.questions":`向用户提出了问题`,"message.stepProcess.done.tools":`已调用工具`,"message.stepProcess.joinTwo":`{first}并{second}`,"message.stepProcess.comma":`,`,"message.stepProcess.sharedPrefix":`已`,"message.stepProcess.more":`{title}等`,"message.trigger.request":`收到执行请求`,"message.trigger.goal":`继续执行目标`,"message.trigger.agent":`收到任务消息`,"message.trigger.team":`收到团队消息`,"message.trigger.subagent":`子任务状态更新`,"message.trigger.github":`收到 GitHub 事件`,"message.trigger.webhook":`收到外部事件`,"message.trigger.schedule":`自动化任务`,"message.trigger.job":`后台任务状态更新`,"message.trigger.plugin":`插件状态更新`,"message.trigger.explanation":`这条通知触发了本轮回复。`,"message.turnProcess.worked":`已完成`,"message.turnProcess.unknown":`已结束`,"message.turnProcess.took":`已完成,用时 `,"message.turnProcess.failed":`处理失败`,"view.chat":`对话`,"image.open":`查看大图`,"image.loading":`加载图片…`,"image.failed":`图片无法预览`,"image.dialog":`图片预览`,"image.close":`关闭图片预览`,"message.imageViews.one":`已查看 1 张图像`,"message.imageViews.many":`已查看 {count} 张图像`,"duration.milliseconds":`{milliseconds}毫秒`,"chat.loadingHistory":`载入历史…`,"selection.addToChat":`添加到对话`,"selection.comment":`添加批注`,"selection.commentPlaceholder":`写下你的批注…`,"selection.commentSubmit":`添加`,"selection.commentUnavailable":`当前无法添加批注,请稍后重试。`,"annotation.label":`批注 {index}`,"annotation.chipLabel":`{index}.`,"annotation.title":`批注 {index}:{excerpt}`,"annotation.remove":`移除批注 {index}`,"annotation.removeAction":`移除`,"annotation.save":`保存`,"annotation.selectedText":`选中文字:`,"annotation.userComment":`你的批注:`,"chat.syncing":`正在获取最新消息…`,"chat.loadingDiff":`载入差异…`,"chat.retryDiff":`重试`,"chat.loadError":`历史加载失败:{message}({code})`,"chat.loadOlder":`加载更早`,"chat.scrollOlder":`向上滚动查看更早消息`,"chat.loadingOlder":`正在加载更早消息…`,"chat.loadOlderError":`更早消息加载失败:{message}`,"chat.retryOlder":`重试加载`,"chat.toBottom":`回到底部`,"chat.filesChanged":`{count} 个文件已更改`,"chat.fileEdited":`已编辑 {name}`,"chat.filesEdited":`已编辑 {count} 个文件`,"chat.viewChanges":`查看变更`,"chat.hideChanges":`收起变更`,"chat.openFile":`打开 {path}`,"chat.showMoreFiles":`再显示 {count} 个文件`,"chat.collapseFiles":`收起文件`,"diff.code":`代码`,"diff.wrap":`自动换行`,"diff.unwrap":`取消换行`,"diff.copy":`复制`,"diff.copied":`已复制`,"diff.collapseAria":`折叠差异`,"diff.expandAria":`展开 {count} 行隐藏内容`,"diff.collapse":`折叠`,"diff.expand":`展开 {count} 行`,"codeBlock.expand":`展开全部(共 {count} 行)`,"codeBlock.collapse":`收起代码`,"chat.deepDiving":`正在处理`,"chat.statusUnconfirmed":`任务状态待确认`,"chat.deepDivingFor":`正在处理 · {duration}`,"chat.turnNavigation.label":`轮次导航`,"chat.turnNavigation.jump":`跳转到用户消息 {turn}`,"chat.turnNavigation.jumpLoad":`加载并跳转到用户消息 {turn}`,"chat.turnNavigation.turn":`用户消息 {turn}`,"settings.links.title":`网页链接默认打开方式`,"settings.links.description":`对话中网页链接的打开位置`,"settings.links.sidebar":`应用内侧边栏`,"settings.links.newTab":`默认浏览器`,"settings.transcript.title":`工作步骤展示`,"settings.transcript.description":`选择希望看到多少工具调用细节`,"settings.transcript.compact":`简洁`,"settings.transcript.standard":`标准`,"settings.transcript.detailed":`详细`,"settings.transcript.verbose":`完全展开`,"fileOpen.title":`无法打开文件`,"fileOpen.folder":`无法打开所在文件夹`,"fileOpen.unknown":`无法打开此文件`,"linkMenu.copy":`复制链接`,"linkMenu.copyFailed":`无法复制链接`,"linkMenu.openBrowser":`在浏览器中打开`,"linkMenu.openFile":`用默认应用打开`,"linkMenu.openFolder":`打开所在文件夹`,"linkMenu.openInCodexhost":`在 codexhost 中打开`,"message.watch.completed":`已完成`,"message.watch.failed":`失败`,"message.watch.interrupted":`已中断`,"message.watch.timedOut":`监听已到期`,"message.watch.unreadable":`状态未知`,"message.watch.notFound":`会话不存在`,"message.watch.open":`打开会话`,"message.group.from":`来自群聊 · {room}`,"message.group.contextCount":`附带 {count} 条群聊背景`,"message.group.you":`我`,"message.group.senderPrefix":`{sender}:`,"message.extraBlock":`附加内容块`,"message.uploading":`上传中…`,"message.uploadingPercent":`上传中 {percent}%`,"message.systemPrompt":`系统提示词`,"message.systemPromptUpdate":`系统提示词更新`,"message.toolAdded":`已添加工具:{name}`,"message.toolRemoved":`已移除工具:{name}`,"message.toolsAdded":`新增:{names}`,"message.toolsAddedCount":`新增 {count} 个`,"message.toolsChanged":`新增 {added} 个,移除 {removed} 个`,"message.toolsRemoved":`移除:{names}`,"message.toolsRemovedCount":`移除 {count} 个`,"message.toolsUpdated":`工具已更新`,"message.contextInjection":`上下文注入`,"message.contextRecall":`跨会话召回`,"message.referenceSummary":`引用会话 · {labels}`,"message.referenceSeparator":`、`,"message.context.instructions.loaded":`已载入`,"message.context.instructions.added":`已新增`,"message.context.instructions.updated":`已更新`,"message.context.instructions.removed":`已移除`,"message.context.catalog.replaced":`替换目录`,"message.context.catalog.more":`…还有 {count} 条`,"message.context.snapshot.supersedes":`取代先前的快照`,"message.context.relay.from":`来自会话 {session}`,"message.context.recall.counts":`保留 {retained} 条 · 省略 {omitted} 条`,"message.context.recall.truncated":`已截断`,"message.compaction":`上下文已压缩`,"message.compaction.running":`正在压缩…`,"message.compaction.completed":`已压缩 {items} 条历史记录(约 {tokens} tokens)`,"message.compaction.expand":`点击查看压缩摘要`,"message.compaction.unavailable":`压缩摘要不可用`,"message.compaction.commandTitle":`compact`,"message.think":`思考`,"message.unknownSurface":`未知 surface 事件:{type}`,"message.unknownBlock":`未知内容块`,"message.turnProcess.toolCalls.one":`{count} 次工具调用`,"message.turnProcess.toolCalls.other":`{count} 次工具调用`,"message.turnProcess.messages.one":`{count} 条消息`,"message.turnProcess.messages.other":`{count} 条消息`,"message.turnProcess.subagents.one":`{count} 个 subagent`,"message.turnProcess.subagents.other":`{count} 个 subagent`,"message.turnProcess.thoughtForAWhile":`已思考`,"message.turnProcess.separator":` · `,"message.stopped":`已停止`,"message.expand":`展开`,"message.collapse":`收起`,"message.edit":`编辑消息`,"message.edit.changed":`会话状态已变化,请核对当前历史后继续。`,"message.edit.cancel":`取消`,"message.edit.send":`发送`,"message.edit.sending":`正在回退并重跑…`,"message.edit.checkHistory":`请核对当前历史后再继续;编辑文本已保留,不会自动重发。`,"message.branch":`在新对话中分支`,"message.branchFailed":`分叉未完成:{message}`,"message.branchUnavailable":`仅可从已完成轮次的最后一条消息分支`,"message.handoff":`上下文交接`,"message.handoffUnavailable":`仅可从已完成轮次的最后一条消息交接`,"handoff.divider.label":`上下文交接`,"handoff.divider.expand":`展开上下文交接详情`,"handoff.divider.collapse":`收起上下文交接详情`,"handoff.divider.turnsAll":`已携带全部 {total} 轮对话`,"handoff.divider.turnsPrefix":`已携带前 {boundary} / {total} 轮对话`,"handoff.divider.turnsPartial":`已携带 {included} / {total} 轮对话(省略 {omitted} 轮,截至第 {boundary} 轮)`,"handoff.divider.openSource":`跳回源会话`,"handoff.divider.previewEmpty":`暂无交接上下文预览`,"handoff.modal.title":`上下文交接`,"handoff.modal.description":`将当前对话上下文整理并交接到新的会话中继续处理。`,"handoff.modal.targetHarness":`目标 Agent`,"handoff.modal.targetModel":`模型`,"handoff.modal.searchModels":`搜索模型…`,"handoff.modal.noModels":`该 Agent 未提供可选模型,将使用默认配置`,"handoff.modal.noHarnesses":`暂无可用的目标 Agent`,"handoff.modal.noMatchingModels":`没有匹配的模型`,"handoff.modal.loadingCatalog":`正在加载可用 Agent 与模型…`,"handoff.modal.catalogError":`加载模型目录失败:{message}`,"handoff.modal.confirm":`确认交接`,"handoff.modal.submitting":`正在交接…`,"handoff.modal.failed":`交接失败:{message}`,"handoff.modal.defaultBadge":`默认`,"message.retry.active":`正在重试模型请求`,"message.retry.cancelled":`模型请求重试已取消`,"message.retry.started":`已重试模型请求`,"message.retry.scheduled":`等待重试模型请求`,"message.retry.status":`{label}({retry}/{maximum}) · {seconds}s`,"message.retry.delay":`重试延迟:`,"message.retry.failure":`失败原因:`,"message.failure.auth":`API 密钥无效`,"message.accountStopped":`任务已停止`,"message.failure.accountSignedOut":`任务已因退出 DeepSeek 登录而停止。`,"message.failure.accountSignInRequired":`请先登录 DeepSeek,并确认请求地址支持账号认证。`,"message.failure.quota":`当前请求的额度已用尽`,"message.turnError":`本轮运行失败`,"message.maxTokens":`已达到输出 token 上限`,"message.maxTokens.hint":`回答被截断,已有输出保留在对话中。发送“继续”可让模型接着输出。`,"duration.secondUnit":`秒`,"duration.minuteUnit":`分`,"duration.hourUnit":`小时`,"command.running":`执行中…`,"command.failed":`指令失败`,"command.done":`已完成`,"command.title":`指令`,"row.running":`运行中`,"row.failed":`失败`,"json.truncated":`… 已截断,共 {total} 字符`,"clock.md":`{m}月{d}日`,"clock.ymd":`{y}年{m}月{d}日`},sb={"message.stepProcess.thinking":`Analyzing the request`,"message.stepProcess.read":`Reading files`,"message.stepProcess.readImage":`Reading images`,"message.stepProcess.write":`Writing files`,"message.stepProcess.search":`Searching code`,"message.stepProcess.edit":`Editing files`,"message.stepProcess.commands":`Running commands`,"message.stepProcess.code":`Running code`,"message.stepProcess.webSearch":`Searching the web`,"message.stepProcess.webFetch":`Visiting web pages`,"message.stepProcess.subagents":`Coordinating subagents`,"message.stepProcess.plan":`Updating the plan`,"message.stepProcess.questions":`Waiting for your action`,"message.stepProcess.tools":`Calling tools`,"message.stepProcess.prepare.read":`Preparing to read files`,"message.stepProcess.prepare.readImage":`Preparing to read images`,"message.stepProcess.prepare.write":`Preparing to write files`,"message.stepProcess.prepare.search":`Preparing to search code`,"message.stepProcess.prepare.edit":`Preparing to edit files`,"message.stepProcess.prepare.commands":`Preparing to run commands`,"message.stepProcess.prepare.code":`Preparing to run code`,"message.stepProcess.prepare.webSearch":`Preparing to search the web`,"message.stepProcess.prepare.webFetch":`Preparing to visit web pages`,"message.stepProcess.prepare.subagents":`Preparing to coordinate subagents`,"message.stepProcess.prepare.plan":`Preparing to update the plan`,"message.stepProcess.prepare.questions":`Preparing questions`,"message.stepProcess.prepare.tools":`Preparing tool calls`,"message.stepProcess.done.thinking":`Analysis completed`,"message.stepProcess.done.read":`Read files`,"message.stepProcess.done.readImage":`Read images`,"message.stepProcess.done.write":`Wrote files`,"message.stepProcess.done.search":`Searched code`,"message.stepProcess.done.edit":`Edited files`,"message.stepProcess.done.commands":`Ran commands`,"message.stepProcess.done.code":`Ran code`,"message.stepProcess.done.webSearch":`Searched the web`,"message.stepProcess.done.webFetch":`Visited web pages`,"message.stepProcess.done.subagents":`Coordinated subagents`,"message.stepProcess.done.plan":`Updated the plan`,"message.stepProcess.done.questions":`Asked questions`,"message.stepProcess.done.tools":`Called tools`,"message.stepProcess.joinTwo":`{first} and {second}`,"message.stepProcess.comma":`, `,"message.stepProcess.sharedPrefix":``,"message.stepProcess.more":`{title}, etc.`,"message.trigger.request":`Execution requested`,"message.trigger.goal":`Continuing goal`,"message.trigger.agent":`Task message received`,"message.trigger.team":`Team message received`,"message.trigger.subagent":`Subtask status updated`,"message.trigger.github":`GitHub event received`,"message.trigger.webhook":`External event received`,"message.trigger.schedule":`Automation task`,"message.trigger.job":`Background task updated`,"message.trigger.plugin":`Plugin status updated`,"message.trigger.explanation":`This notification triggered this response.`,"message.turnProcess.worked":`Completed`,"message.turnProcess.unknown":`Ended`,"message.turnProcess.took":`Completed in `,"message.turnProcess.failed":`Failed`,"view.chat":`Chat`,"image.open":`View full image`,"image.loading":`Loading image…`,"image.failed":`Image preview unavailable`,"image.dialog":`Image preview`,"image.close":`Close image preview`,"message.imageViews.one":`Viewed 1 image`,"message.imageViews.many":`Viewed {count} images`,"duration.milliseconds":`{milliseconds}ms`,"chat.loadingHistory":`Loading history…`,"selection.addToChat":`Add to chat`,"selection.comment":`Add comment`,"selection.commentPlaceholder":`Add a comment…`,"selection.commentSubmit":`Add`,"selection.commentUnavailable":`Could not add the comment. Try again in a moment.`,"annotation.label":`Annotation {index}`,"annotation.chipLabel":`{index}.`,"annotation.title":`Annotation {index}: {excerpt}`,"annotation.remove":`Remove annotation {index}`,"annotation.removeAction":`Remove`,"annotation.save":`Save`,"annotation.selectedText":`Selected text:`,"annotation.userComment":`Your comment:`,"chat.syncing":`Fetching latest messages…`,"chat.loadingDiff":`Loading diff…`,"chat.retryDiff":`Retry`,"chat.loadError":`Failed to load history: {message} ({code})`,"chat.loadOlder":`Load earlier`,"chat.scrollOlder":`Scroll up for earlier messages`,"chat.loadingOlder":`Loading earlier messages…`,"chat.loadOlderError":`Could not load earlier messages: {message}`,"chat.retryOlder":`Retry loading`,"chat.toBottom":`Back to bottom`,"chat.filesChanged":`{count} files changed`,"chat.fileEdited":`Edited {name}`,"chat.filesEdited":`Edited {count} files`,"chat.viewChanges":`View changes`,"chat.hideChanges":`Hide changes`,"chat.openFile":`Open {path}`,"chat.showMoreFiles":`Show {count} more`,"chat.collapseFiles":`Collapse files`,"diff.code":`Code`,"diff.wrap":`Wrap lines`,"diff.unwrap":`Unwrap lines`,"diff.copy":`Copy`,"diff.copied":`Copied`,"diff.collapseAria":`Collapse diff`,"diff.expandAria":`Expand {count} hidden lines`,"diff.collapse":`Collapse`,"diff.expand":`Expand {count} lines`,"codeBlock.expand":`Expand all ({count} lines)`,"codeBlock.collapse":`Collapse code`,"chat.deepDiving":`Working`,"chat.statusUnconfirmed":`Task status unconfirmed`,"chat.deepDivingFor":`Working · {duration}`,"chat.turnNavigation.label":`Turn navigation`,"chat.turnNavigation.jump":`Jump to user message {turn}`,"chat.turnNavigation.jumpLoad":`Load and jump to user message {turn}`,"chat.turnNavigation.turn":`User message {turn}`,"settings.links.title":`Open chat links in`,"settings.links.description":`Choose where to open web links`,"settings.links.sidebar":`In-App Sidebar`,"settings.links.newTab":`Default Browser`,"settings.transcript.title":`Work details`,"settings.transcript.description":`Choose how much detail to show for tool calls`,"settings.transcript.compact":`Compact`,"settings.transcript.standard":`Standard`,"settings.transcript.detailed":`Detailed`,"settings.transcript.verbose":`Verbose`,"fileOpen.title":`Couldn’t open file`,"fileOpen.folder":`Couldn’t open containing folder`,"fileOpen.unknown":`Couldn’t open this file`,"linkMenu.copy":`Copy link`,"linkMenu.copyFailed":`Couldn’t copy link`,"linkMenu.openBrowser":`Open in browser`,"linkMenu.openFile":`Open in default app`,"linkMenu.openFolder":`Open containing folder`,"linkMenu.openInCodexhost":`Open in codexhost`,"message.watch.completed":`Completed`,"message.watch.failed":`Failed`,"message.watch.interrupted":`Interrupted`,"message.watch.timedOut":`Watch expired`,"message.watch.unreadable":`State unknown`,"message.watch.notFound":`Session not found`,"message.watch.open":`Open session`,"message.group.from":`From group · {room}`,"message.group.contextCount":`{count} earlier group messages`,"message.group.you":`You`,"message.group.senderPrefix":`{sender}: `,"message.extraBlock":`Extra content block`,"message.uploading":`Uploading…`,"message.uploadingPercent":`Uploading {percent}%`,"message.systemPrompt":`System prompt`,"message.systemPromptUpdate":`System prompt update`,"message.toolAdded":`Tool added: {name}`,"message.toolRemoved":`Tool removed: {name}`,"message.toolsAdded":`Added: {names}`,"message.toolsAddedCount":`{count} added`,"message.toolsChanged":`{added} added, {removed} removed`,"message.toolsRemoved":`Removed: {names}`,"message.toolsRemovedCount":`{count} removed`,"message.toolsUpdated":`Tools updated`,"message.contextInjection":`Context injection`,"message.contextRecall":`Session recall`,"message.referenceSummary":`Referenced session · {labels}`,"message.referenceSeparator":`, `,"message.context.instructions.loaded":`loaded`,"message.context.instructions.added":`added`,"message.context.instructions.updated":`updated`,"message.context.instructions.removed":`removed`,"message.context.catalog.replaced":`Replacement catalog`,"message.context.catalog.more":`… {count} more`,"message.context.snapshot.supersedes":`Supersedes earlier snapshots`,"message.context.relay.from":`From session {session}`,"message.context.recall.counts":`{retained} kept · {omitted} omitted`,"message.context.recall.truncated":`truncated`,"message.compaction":`Context compacted`,"message.compaction.running":`Compacting context…`,"message.compaction.completed":`Compacted {items} history items (~{tokens} tokens)`,"message.compaction.expand":`View compaction summary`,"message.compaction.unavailable":`Compaction summary unavailable`,"message.compaction.commandTitle":`compact`,"message.think":`Think`,"message.unknownSurface":`Unknown surface event: {type}`,"message.unknownBlock":`Unknown content block`,"message.turnProcess.toolCalls.one":`{count} tool call`,"message.turnProcess.toolCalls.other":`{count} tool calls`,"message.turnProcess.messages.one":`{count} message`,"message.turnProcess.messages.other":`{count} messages`,"message.turnProcess.subagents.one":`{count} subagent`,"message.turnProcess.subagents.other":`{count} subagents`,"message.turnProcess.thoughtForAWhile":`Thought for a while`,"message.turnProcess.separator":` · `,"message.stopped":`Stopped`,"message.expand":`Show more`,"message.collapse":`Show less`,"message.edit":`Edit message`,"message.edit.changed":`Conversation state changed. Check current history before continuing.`,"message.edit.cancel":`Cancel`,"message.edit.send":`Send`,"message.edit.sending":`Reverting and rerunning…`,"message.edit.checkHistory":`Check current history before continuing. Your edit is retained and will not be resent automatically.`,"message.branch":`Branch into a new conversation`,"message.branchFailed":`Fork did not complete: {message}`,"message.branchUnavailable":`Available only on the last message of a completed turn`,"message.handoff":`Hand off context`,"message.handoffUnavailable":`Available only on the last message of a completed turn`,"handoff.divider.label":`Context handoff`,"handoff.divider.expand":`Expand context handoff details`,"handoff.divider.collapse":`Collapse context handoff details`,"handoff.divider.turnsAll":`Carried all {total} turns`,"handoff.divider.turnsPrefix":`Carried first {boundary} of {total} turns`,"handoff.divider.turnsPartial":`Carried {included} of {total} turns ({omitted} omitted, up to turn {boundary})`,"handoff.divider.openSource":`Open source session`,"handoff.divider.previewEmpty":`No handoff context preview available`,"handoff.modal.title":`Context handoff`,"handoff.modal.description":`Package the current conversation context and continue in a new session.`,"handoff.modal.targetHarness":`Target Agent`,"handoff.modal.targetModel":`Model`,"handoff.modal.searchModels":`Search models…`,"handoff.modal.noModels":`No selectable models — default configuration will be used`,"handoff.modal.noHarnesses":`No available target Agents`,"handoff.modal.noMatchingModels":`No matching models`,"handoff.modal.loadingCatalog":`Loading available Agents and models…`,"handoff.modal.catalogError":`Failed to load model catalog: {message}`,"handoff.modal.confirm":`Hand off`,"handoff.modal.submitting":`Handing off…`,"handoff.modal.failed":`Handoff failed: {message}`,"handoff.modal.defaultBadge":`Default`,"message.retry.active":`Retrying model request`,"message.retry.cancelled":`Model request retry cancelled`,"message.retry.started":`Retried model request`,"message.retry.scheduled":`Waiting to retry model request`,"message.retry.status":`{label} ({retry}/{maximum}) · {seconds}s`,"message.retry.delay":`Retry delay: `,"message.retry.failure":`Failure reason: `,"message.failure.auth":`API key is invalid`,"message.accountStopped":`Task stopped`,"message.failure.accountSignedOut":`Stopped because you signed out of DeepSeek.`,"message.failure.accountSignInRequired":`Sign in to DeepSeek and ensure the request destination supports account authentication.`,"message.failure.quota":`Request quota exhausted.`,"message.turnError":`This turn failed`,"message.maxTokens":`Output token limit reached`,"message.maxTokens.hint":`The reply was cut off; earlier output is preserved in the conversation. Send "continue" to let the model resume.`,"duration.secondUnit":`s`,"duration.minuteUnit":`m `,"duration.hourUnit":`h `,"command.running":`Running…`,"command.failed":`Command failed`,"command.done":`Completed`,"command.title":`Command`,"row.running":`Running`,"row.failed":`Failed`,"json.truncated":`… truncated, {total} characters total`,"clock.md":`{m}/{d}`,"clock.ymd":`{y}-{m}-{d}`},cb=`@deepseek-ai/dsh-client-ui-chat/ReasoningRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(cb)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=cb,e.textContent=`.akEvLW_root{flex-direction:column;display:flex}.akEvLW_root:not([data-expanded]){contain:size layout;height:calc(24px + var(--dsh-content-font-delta,0px))}.akEvLW_row{overflow:hidden}.akEvLW_root[data-expanded] [data-open] [data-disclosure-row]{z-index:1;background:var(--dsw-alias-bg-base);position:sticky;top:0}body[data-codexhost-wallpaper] .akEvLW_root[data-expanded] [data-open] [data-disclosure-row]{background:color-mix(in srgb, var(--dsw-alias-bg-base) 76%, transparent);backdrop-filter:blur(12px);border-radius:var(--dsw-radius-sm,8px)}body[data-codexhost-wallpaper] [data-chat-flow-key]:not([data-chat-flow-key] *,[data-chat-near-viewport]) .akEvLW_root[data-expanded] [data-open] [data-disclosure-row]{backdrop-filter:none}.akEvLW_leading{flex-shrink:0}.akEvLW_title{font-weight:400}.akEvLW_separator{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.akEvLW_summary{min-width:0;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));white-space:nowrap;flex:auto;overflow:hidden}.akEvLW_summaryText{text-overflow:ellipsis;display:block;overflow:hidden}.akEvLW_summary[data-streaming]{mask-image:linear-gradient(90deg,#000 calc(100% - 48px),#0000)}.akEvLW_summary[data-streaming] .akEvLW_summaryText{text-overflow:clip;overflow:visible}.akEvLW_root:not([data-preview]) .akEvLW_separator,.akEvLW_root:not([data-preview]) .akEvLW_summary{display:none}.akEvLW_thinkBody{padding:4px 0 4px calc(22px + var(--dsh-content-font-delta,0px));min-width:0}`,document.head.appendChild(e)}var lb={leading:`akEvLW_leading`,root:`akEvLW_root`,row:`akEvLW_row`,separator:`akEvLW_separator`,summary:`akEvLW_summary`,summaryText:`akEvLW_summaryText`,thinkBody:`akEvLW_thinkBody`,title:`akEvLW_title`};let ub=/* @__PURE__ */ (0,f.jsx)(p.IconThinkOutlineRegular,{size:14});function db(e){let t=e.indexOf(`
127
+ `);return t===-1?e:e.slice(0,t)}function fb(e){let t=``,n=0,r=/\r?\n(?:[\t ]*\r?\n)+/g;for(;;){let i=r.exec(e),a=i===null?e.length:i.index+i[0].indexOf(`
128
128
  `),o=e.indexOf(`
129
- `,n);if(o!==-1&&o<=a){let r=e.slice(n,o).trim();r!==``&&(t=r)}if(i===null)return t;n=i.index+i[0].length}}let Oy=(0,d.memo)(function({text:e,running:t,usePresentation:n,useDisclosure:r,t:i}){let{expanded:a,toggle:o}=r(),s=(0,d.useMemo)(()=>Am(i),[i]),c=t?Dy(e):Ey(e),l=(0,d.useMemo)(()=>c.replaceAll(`**`,``),[c]),u=n(e=>!a&&l!==``&&(t||e.settledReasoningPreview)),m=(0,d.useMemo)(()=>/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:wy.separator,"data-shimmer-decoration":!0,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:wy.summary,"data-streaming":t||void 0,children:/* @__PURE__ */ (0,f.jsx)(`span`,{className:wy.summaryText,children:/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{children:l})})})]}),[t,l]),h=(0,d.useMemo)(()=>a?/* @__PURE__ */ (0,f.jsx)(`div`,{className:wy.thinkBody,children:/* @__PURE__ */ (0,f.jsx)(p.MarkdownText,{text:e,streaming:t,labels:s,variant:`compact`})}):void 0,[a,s,t,e]);return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:wy.root,"data-variant":`think`,"data-state":t?`running`:`ok`,"data-expanded":a||void 0,"data-preview":u||void 0,children:[t&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:U_.visuallyHidden,children:i(`row.running`)}),/* @__PURE__ */ (0,f.jsx)(p.DisclosureRow,{rowClassName:wy.row,leadingClassName:wy.leading,titleClassName:wy.title,icon:Ty,title:i(`message.think`),running:t,open:a,expandable:!0,expandOnRowClick:!0,onToggle:o,collapsedContent:m,children:h})]})}),ky=`@deepseek-ai/dsh-client-ui-chat/AssistantMarkdown.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(ky)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=ky,e.textContent=`.-BFQla_root{font-size:var(--dsh-content-font-size,14px);line-height:calc(24px + var(--dsh-content-font-delta,0px));color:var(--dsw-alias-label-primary);flex-direction:column;display:flex}.-BFQla_body{flex-direction:column;gap:16px;display:flex}.-BFQla_viewedImages{flex-direction:column;align-items:flex-start;gap:10px;display:flex}.-BFQla_viewedImagesToggle{min-height:24px;color:var(--dsw-alias-label-tertiary);font:inherit;cursor:pointer;background:0 0;border:none;align-items:center;gap:6px;padding:0;display:inline-flex}.-BFQla_viewedImagesToggle:hover{color:var(--dsw-alias-label-secondary)}.-BFQla_viewedImagesToggle:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-alias-state-business-primary);outline-offset:2px;border-radius:var(--dsw-radius-sm)}.-BFQla_viewedImagesIcon{flex:none;width:16px;height:16px;position:relative}.-BFQla_viewedImagesIcon:before,.-BFQla_viewedImagesIcon:after{content:"";border:1px solid;border-radius:3px;width:11px;height:9px;position:absolute}.-BFQla_viewedImagesIcon:before{top:2px;left:2px}.-BFQla_viewedImagesIcon:after{top:5px;left:5px}.-BFQla_viewedImagesChevron{flex:none;width:12px;height:12px}.-BFQla_body .md-table-wide{--dsh-table-viewport:calc(var(--dsh-chat-viewport-width,var(--dsh-chat-content-width) + 2 * var(--dsh-chat-scroll-pad-x,0px)) - 2 * var(--dsh-chat-scroll-pad-x,0px));--dsh-table-spare:max(0px, calc((var(--dsh-table-viewport) - var(--dsh-chat-content-width)) / 2));--dsh-table-lead:calc(var(--dsh-table-spare) + min(var(--dsh-chat-content-width), var(--dsh-table-viewport)) - 100%);box-sizing:border-box;width:calc(100% + var(--dsh-table-lead) + var(--dsh-table-spare));max-width:none;margin-left:calc(-1 * var(--dsh-table-lead));padding-left:var(--dsh-table-lead)}.-BFQla_body .md-table-wide>table{z-index:1;position:relative}.-BFQla_body>[data-turn-process-inline][hidden]{margin-bottom:-16px}.-BFQla_stopped{border-radius:var(--dsw-radius-sm);background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-tertiary);align-self:flex-start;padding:0 6px;font-size:11px;line-height:18px}.-BFQla_actions{margin-top:16px;margin-left:-6px}`,document.head.appendChild(e)}var Ay={actions:`-BFQla_actions`,body:`-BFQla_body`,root:`-BFQla_root`,stopped:`-BFQla_stopped`,viewedImages:`-BFQla_viewedImages`,viewedImagesChevron:`-BFQla_viewedImagesChevron`,viewedImagesIcon:`-BFQla_viewedImagesIcon`,viewedImagesToggle:`-BFQla_viewedImagesToggle`};function jy({images:e,renderMessageImages:t,t:n}){let[r,i]=(0,d.useState)(!1),a=e.length===1?n(`message.imageViews.one`):n(`message.imageViews.many`,{count:e.length});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Ay.viewedImages,children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Ay.viewedImagesToggle,"aria-expanded":r,onClick:()=>{i(e=>!e)},children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Ay.viewedImagesIcon,"aria-hidden":`true`}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:a}),r?/* @__PURE__ */ (0,f.jsx)(p.IconChevronUpOutlineRegular,{className:Ay.viewedImagesChevron}):/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{className:Ay.viewedImagesChevron})]}),r&&t({images:e,align:`start`})]})}function My(e,t,n){let r;try{r=decodeURIComponent(t.split(/[?#]/u)[0]??``)}catch{return}return n===void 0?re(e,r):n(r)}let Ny=(0,d.memo)(function({blocks:e,streaming:t,interrupted:n,renderMessageImages:r,groupPart:i,useDisclosure:a,reasoningHidden:o=!1,usePresentation:s,revealProcess:c,mentions:l,fileCitations:u,responseAnnotations:m,t:h}){let g=(0,d.useMemo)(()=>Am(h),[h]),{fileImages:_}=(0,p.useMarkdownDelegate)(),v=(0,d.useMemo)(()=>({resolve:e=>My(document.baseURI,e,_?.resolve)}),[_]),y=e.length-1;if(!(t||n===!0||e.some(e=>e.kind!==`tool-call`)))return null;let b=[];for(let n=0;n<e.length;n++){let _=e[n];if(_!==void 0&&(i!==`reasoning`||_.kind===`reasoning`)&&(i!==`response`||_.kind!==`reasoning`))switch(_.kind){case`text`:b.push(/* @__PURE__ */ (0,f.jsx)(p.MarkdownText,{text:_.text,streaming:t,breaks:!0,labels:g,fileMentions:l,fileCitations:u,pathImages:v,responseAnnotations:m},n));break;case`reasoning`:b.push(/* @__PURE__ */ (0,f.jsx)(Py,{hidden:o,reveal:c,children:/* @__PURE__ */ (0,f.jsx)(Oy,{text:_.text,running:t&&n===y,usePresentation:s,useDisclosure:a,t:h})},n));break;case`image`:{let t=n,i=[_];for(;n+1<e.length;){let t=e[n+1];if(t===void 0||t.kind!==`image`)break;i.push(t),n+=1}b.push(/* @__PURE__ */ (0,f.jsx)(d.Fragment,{children:r({images:i.map(({attachment:e})=>({attachment:e})),align:`start`})},t));break}case`viewed-images`:{let t=n,i=[_];for(;n+1<e.length;){let t=e[n+1];if(t===void 0||t.kind!==`viewed-images`)break;i.push(t),n+=1}b.push(/* @__PURE__ */ (0,f.jsx)(jy,{images:i.map(({attachment:e})=>({attachment:e})),renderMessageImages:r,t:h},t));break}case`tool-call`:break;default:b.push(/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:h(`message.unknownBlock`),payload:_.block,truncatedLabel:e=>h(`json.truncated`,{total:e})},n))}}return/* @__PURE__ */ (0,f.jsx)(`div`,{className:Ay.root,"data-streaming":t||void 0,children:/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Ay.body,children:[b,n&&(i===void 0||i===`response`||!e.some(e=>e.kind!==`reasoning`&&e.kind!==`tool-call`))&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:Ay.stopped,children:h(`message.stopped`)})]})})});function Py({hidden:e,reveal:t,children:n}){let r=xg(e,t??Fy);return/* @__PURE__ */ (0,f.jsx)(`div`,{ref:r,"data-turn-process-inline":e||void 0,children:n})}let Fy=()=>{};function Iy(e,t){for(let n=e;n!==null&&n!==t;n=n.parentElement)if(n.classList.contains(zv.annotationMark))return!0;return!1}let Ly=(0,d.memo)(function({node:e,groupPart:t,useDisclosure:n,useTurnData:r,turnProcess:i,openFile:a,renderMessageImages:o,fileMentions:s,responseAnnotations:c,useInput:l,inputActions:u,usePresentation:p,t:m}){let h=e.data,g=(0,d.useRef)(null),_=JSON.stringify([e.key,t??null]),v=e.location.kind===`turn`||e.location.kind===`step`?e.location.turn:void 0,y=r(`turn-tail`),b=(0,d.useMemo)(()=>{if(v?.status===`closed`&&h.finalNode!==void 0&&y?.closing?.finalNode.seq===h.finalNode.seq)return{turn:v,seq:h.finalNode.seq,openFile:a}},[h.finalNode,a,y,v]),x=(0,d.useMemo)(()=>b===void 0?void 0:s(b),[s,b]),S=(0,d.useMemo)(()=>{if(a!==void 0)return{resolve:e=>{if(e.trim()!==``)return{open:()=>{a(e)},label:e,title:e}}}},[a]),C=i!==void 0&&i.foldable&&i.spec.answerStep===h.step&&i.spec.inlineReasoning&&!i.open,w=(0,d.useCallback)(()=>{i?.setOpen(!0)},[i]),T=(0,d.useMemo)(()=>jm(m),[m]),E=(0,d.useMemo)(()=>({labels:T,resolve:e=>c[e-1]}),[T,c]),D=(0,d.useCallback)(e=>{e.detail>=2&&g.current!==null&&Fh(g.current,Iy)},[]);return/* @__PURE__ */ (0,f.jsxs)(`div`,{ref:g,className:zv.answer,"data-selection-answer":_,"data-selection-answer-streaming":h.status===`running`||void 0,onClick:D,children:[/* @__PURE__ */ (0,f.jsx)(Ny,{blocks:h.blocks,groupPart:t,useDisclosure:n,streaming:h.status===`running`,interrupted:h.status===`interrupted`,renderMessageImages:o,reasoningHidden:C,usePresentation:p,revealProcess:w,mentions:x,fileCitations:S,responseAnnotations:E,t:m}),h.status!==`running`&&/* @__PURE__ */ (0,f.jsx)(Kv,{answer:g,answerKey:_,useInput:l,inputActions:u,labels:T})]})}),Ry=`@deepseek-ai/dsh-client-ui-chat/GenericCommandCard.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Ry)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Ry,e.textContent=`.lHK2Ya_root{flex-direction:column;display:flex}.lHK2Ya_leading{flex-shrink:0}.lHK2Ya_title{font-weight:400}.lHK2Ya_separator{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.lHK2Ya_summary{min-width:0;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}.lHK2Ya_summary[data-error],.lHK2Ya_body[data-error]{color:var(--dsw-alias-state-error-primary)}.lHK2Ya_body{border:.5px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-markdown-code-block);max-height:260px;color:var(--dsw-alias-label-primary);font:var(--dsw-font-markdown-code-block-small);white-space:pre-wrap;margin:4px 0 4px 4px;padding:12px 16px;overflow:auto}`,document.head.appendChild(e)}var zy={body:`lHK2Ya_body`,leading:`lHK2Ya_leading`,root:`lHK2Ya_root`,separator:`lHK2Ya_separator`,summary:`lHK2Ya_summary`,title:`lHK2Ya_title`};let By=/* @__PURE__ */ (0,f.jsx)(p.IconApiOutlineRegular,{size:14});function Vy(e){return e===null?`running`:e.kind===`error`?`error`:`ok`}let Hy=(0,d.memo)(function({node:e,t,runningSummary:n,successSummary:r}){let[i,a]=(0,d.useState)(!1),o=e.outcome?.text,s=e.outcome===null?n??t(`command.running`):o??(e.outcome.kind===`error`?t(`command.failed`):r??t(`command.done`)),c=e.name??t(`command.title`),l=Vy(e.outcome),u=l===`running`,m=o!==void 0&&o.includes(`
130
- `)?o:null,h=i&&m!==null,g=(0,d.useCallback)(()=>{a(e=>!e)},[]),_=(0,d.useMemo)(()=>/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:zy.separator,"data-shimmer-decoration":!0,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:zy.summary,"data-error":l===`error`||void 0,children:/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{children:s})})]}),[u,l,s]),v=(0,d.useMemo)(()=>h?/* @__PURE__ */ (0,f.jsx)(`pre`,{className:zy.body,"data-error":l===`error`||void 0,children:m}):void 0,[m,h,l]);return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:zy.root,"data-variant":`others`,"data-command":e.name??void 0,"data-state":l,children:[l===`running`&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:U_.visuallyHidden,children:t(`row.running`)}),l===`error`&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:U_.visuallyHidden,children:t(`row.failed`)}),/* @__PURE__ */ (0,f.jsx)(p.DisclosureRow,{leadingClassName:zy.leading,titleClassName:zy.title,icon:By,title:c,running:u,open:h,expandable:m!==null,expandOnRowClick:!0,keepContentWhenOpen:!0,onToggle:g,collapsedContent:_,children:v})]})});function Uy({node:e,compaction:t,t:n}){return t===void 0?/* @__PURE__ */ (0,f.jsx)(Hy,{node:e,t:n,runningSummary:n(`message.compaction.running`),successSummary:n(`message.compaction`)}):/* @__PURE__ */ (0,f.jsx)(Rm,{node:t,title:n(`message.compaction.commandTitle`),fallbackSummary:e.outcome?.text??null,t:n})}let Wy=(0,d.memo)(function({node:e,renderSlot:t,t:n}){let r=e.data,i=(0,d.useMemo)(()=>({node:r}),[r]);return/* @__PURE__ */ (0,f.jsx)(`div`,{className:Dg.callRow,children:t(`conversation.chat.commandview`,i,{entryKey:r.name??``,fallback:/* @__PURE__ */ (0,f.jsx)(Hy,{...i,t:n})})})}),Gy=(0,d.memo)(function({node:e,t}){let n=e.data;return/* @__PURE__ */ (0,f.jsx)(`div`,{className:Dg.callRow,children:/* @__PURE__ */ (0,f.jsx)(Uy,{node:n.command,...n.compaction===null?{}:{compaction:n.compaction},t})})});function Ky({text:e,update:t=!1,t:n}){let[r,i]=(0,d.useState)(!1);return/* @__PURE__ */ (0,f.jsx)(p.DisclosureRow,{className:fh.root,icon:/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),chevronClassName:fh.chevron,title:n(t?`message.systemPromptUpdate`:`message.systemPrompt`),open:r,expandable:!0,expandOnRowClick:!0,onToggle:()=>{i(e=>!e)},children:/* @__PURE__ */ (0,f.jsx)(`div`,{className:fh.body,"data-system-prompt-body":!0,children:/* @__PURE__ */ (0,f.jsx)(Xm,{content:[{type:`text`,text:e}],source:null,t:n})})})}let qy=(0,d.memo)(function({node:e,t}){return/* @__PURE__ */ (0,f.jsx)(Ky,{text:e.data.text,update:e.data.update===!0,t})}),Jy=`@deepseek-ai/dsh-client-ui-chat/TurnProcessNodeView.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Jy)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Jy,e.textContent=`.NsInEG_root{box-sizing:border-box;width:100%;min-width:0;height:calc(33px + var(--dsh-content-font-delta,0px));border:none;border-bottom:.5px solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-tertiary);font:inherit;font-size:var(--dsh-content-font-size,14px);cursor:pointer;text-align:left;background:0 0;align-items:center;padding:0 0 8px;transition:color .1s;display:flex}.NsInEG_root:disabled{cursor:default}@media (hover:hover){.NsInEG_root:hover:not(:disabled){color:var(--dsw-alias-label-secondary)}}.NsInEG_root:active:not(:disabled){color:var(--dsw-alias-label-secondary)}.NsInEG_chevron{width:14px;height:14px;color:inherit;flex:none;margin-left:4px;transition:transform .1s}.NsInEG_root[data-open] .NsInEG_chevron{transform:rotate(180deg)}.NsInEG_label{min-width:0;font-size:inherit;line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.NsInEG_durationNumber{font-family:var(--ds-font-family-code);font-variant-numeric:tabular-nums}@media (prefers-reduced-motion:reduce){.NsInEG_root,.NsInEG_chevron{transition:none}}`,document.head.appendChild(e)}var Yy={chevron:`NsInEG_chevron`,durationNumber:`NsInEG_durationNumber`,label:`NsInEG_label`,root:`NsInEG_root`};let Xy=(0,d.memo)(function({node:e,turnProcess:t,t:n}){if(t===void 0)throw Error(`turn-process node requires Turn process owner state`);let r=!t.foldable||t.open,i=e.location.kind===`turn`||e.location.kind===`step`?e.location.turn:void 0;if(i?.status!==`closed`)return null;let a=t.foldable&&t.hasContent&&!fg(e),o=i.end?.data.reason.kind,s=i.start===void 0||i.end===void 0||i.end.time<=i.start.time?void 0:Math.max(1e3,i.end.time-i.start.time),c=s===void 0||o===`aborted`||o===`error`||o===`unknown`?void 0:_h(s,n),l=n(o===`unknown`?`message.turnProcess.unknown`:o===`aborted`?`message.stopped`:o===`error`?`message.turnProcess.failed`:c===void 0?`message.turnProcess.worked`:`message.turnProcess.took`),u=n(o===`unknown`?`message.turnProcess.unknown`:o===`aborted`?`message.stopped`:o===`error`?`message.turnProcess.failed`:`message.turnProcess.worked`);return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:U_.visuallyHidden,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:u}),/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Yy.root,"data-open":r||void 0,"data-turn-process":e.data.turn,"data-turn-process-messages":e.data.messageCount,"data-turn-process-tool-calls":e.data.toolCallCount,"data-turn-process-subagents":e.data.subagentCount,disabled:!a,"aria-expanded":t.hasContent?r:void 0,onClick:n=>{let i=n.currentTarget,a=i.ownerDocument.activeElement,o=a instanceof Element&&a.closest(`[data-turn-process-member], [data-step-process]`)?.getAttribute(`data-chat-turn`)===String(e.data.turn);r&&o&&(n.detail!==0||(0,p.pointerModality)()?(0,p.focusWithoutRing)(i,{preventScroll:!0}):i.focus({preventScroll:!0})),t.setOpen(!r)},children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:Yy.label,children:[l,c?.map((e,t)=>/* @__PURE__ */ (0,f.jsx)(`span`,{className:e.numeric?Yy.durationNumber:void 0,children:e.text},t))]}),a&&/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{className:Yy.chevron})]})]})});function Zy(e,t,n,r){let[i,a]=(0,d.useState)({}),[o,s]=(0,d.useState)(),[c,l]=(0,d.useState)(0),u=JSON.stringify(t.filter(e=>n.has(e.path)&&e.hunks===void 0).map(e=>[e.path,e.revision]));return(0,d.useEffect)(()=>{let t=JSON.parse(u).filter(([e,t])=>i[e]?.revision!==t);if(!r||t.length===0)return;let n=!0;return s(void 0),Promise.all(t.map(async([t,n])=>[t,{revision:n,diffs:(await r(e,t)).filter(e=>e.path===t)}])).then(e=>{n&&a(t=>({...t,...Object.fromEntries(e)}))},e=>{n&&s(e instanceof Error?e.message:String(e))}),()=>{n=!1}},[e,u,r,i,c]),{diffs:e=>e.hunks??(i[e.path]?.revision===e.revision?i[e.path]?.diffs:void 0),error:o,retry:()=>l(e=>e+1)}}let Qy=`@deepseek-ai/dsh-client-ui-chat/TurnChangesCard.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Qy)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Qy,e.textContent=`.U56YlW_card{border:1px solid var(--dsw-alias-border-l2);corner-shape:round;color:var(--dsw-alias-label-primary);font-size:calc(var(--dsh-content-font-size-secondary,13px) + 2px);--dsh-change-stat-font-size:calc(var(--dsh-content-font-size-secondary,13px) + 1px);--dsw-alias-state-success-primary:var(--dsw-alias-file-diff-added-marker);--dsw-alias-state-error-primary:var(--dsw-alias-file-diff-deleted-marker);border-radius:12px;margin:8px 0;line-height:20px;overflow:hidden}.U56YlW_header{-webkit-user-select:none;user-select:none;align-items:center;gap:12px;padding:12px;display:flex}.U56YlW_icon{corner-shape:round;background:color-mix(in srgb, var(--dsw-alias-label-primary) 4%, transparent);width:44px;height:44px;color:var(--dsw-alias-label-secondary);border-radius:12px;flex:none;place-items:center;display:grid}.U56YlW_text{flex-direction:column;flex:auto;gap:2px;min-width:0;display:flex}.U56YlW_title{text-overflow:ellipsis;white-space:nowrap;font-weight:600;overflow:hidden}.U56YlW_titleLink{max-width:100%;color:inherit;font-family:inherit;font-size:inherit;line-height:inherit;text-align:left;cursor:pointer;background:0 0;border:0;align-self:flex-start;margin:0;padding:0}.U56YlW_review,.U56YlW_fileHead,.U56YlW_openFile,.U56YlW_more{color:inherit;font:inherit;text-align:left;cursor:pointer;-webkit-user-select:none;user-select:none;background:0 0;border:0}.U56YlW_review{border:1px solid var(--dsw-alias-border-l2);corner-shape:round;font-size:var(--dsh-content-font-size,14px);white-space:nowrap;border-radius:12px;flex:none;padding:4px 8px;font-weight:500}@media (hover:hover){.U56YlW_review:hover,.U56YlW_fileHead:hover,.U56YlW_openFile:hover,.U56YlW_more:hover{background:var(--dsw-alias-interactive-bg-hover)}.U56YlW_titleLink:hover{text-underline-offset:3px;text-decoration:underline}}.U56YlW_review:active,.U56YlW_fileHead:active,.U56YlW_openFile:active,.U56YlW_more:active{background:var(--dsw-alias-interactive-bg-hover)}.U56YlW_review:focus-visible,.U56YlW_fileHead:focus-visible,.U56YlW_openFile:focus-visible,.U56YlW_more:focus-visible{outline:2px solid var(--dsw-alias-label-tertiary);outline-offset:-2px}.U56YlW_titleLink:focus-visible{outline:2px solid var(--dsw-alias-label-tertiary);outline-offset:2px}.U56YlW_files{border-top:1px solid var(--dsw-alias-border-l2);margin:0;padding:0;list-style:none}.U56YlW_fileRow{align-items:center;display:flex}.U56YlW_fileRow .U56YlW_fileHead{flex:auto;min-width:0}.U56YlW_openFile{corner-shape:round;width:28px;height:28px;color:var(--dsw-alias-label-secondary);border-radius:8px;flex:none;place-items:center;margin-right:8px;padding:0;display:grid}.U56YlW_fileHead{justify-content:space-between;align-items:center;gap:12px;width:100%;min-height:40px;padding:8px 12px;display:flex}.U56YlW_fileHead .U56YlW_path{min-width:0;font-size:inherit;--dsw-alias-label-tertiary:var(--dsw-alias-label-secondary);flex:1}.U56YlW_diff{padding:0 12px 12px}.U56YlW_file:first-child .U56YlW_diff:first-child{padding-top:12px}.U56YlW_more{align-items:center;gap:8px;width:100%;min-height:40px;padding:8px 12px;font-weight:500;display:flex}.U56YlW_mobileChevron,.U56YlW_mobileFileIcon,.U56YlW_mobilePath,.U56YlW_mobileFullPath{display:none}.U56YlW_chevron{flex:none;transition:transform .15s}.U56YlW_chevron[data-open=true]{transform:rotate(180deg)}@media (width<=480px){.U56YlW_header{grid-template-columns:36px minmax(0,1fr);gap:8px;display:grid}.U56YlW_icon{width:36px;height:36px}.U56YlW_review{grid-column:2;justify-self:start}}[data-phone] .U56YlW_card{-webkit-text-size-adjust:100%;text-size-adjust:100%;min-width:0;max-width:100%;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));--dsh-change-stat-font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);--dsh-diff-inline-padding:12px;--dsh-diff-body-padding:4px 0 8px}[data-phone] .U56YlW_header{grid-template-columns:20px minmax(0,1fr) 44px;gap:8px;min-height:52px;padding:0 4px 0 12px;display:grid}[data-phone] .U56YlW_icon{background:0 0;border-radius:0;width:20px;height:20px}[data-phone] .U56YlW_icon>svg{width:16px;height:16px}[data-phone] .U56YlW_text{flex-direction:row;align-items:center;gap:8px}[data-phone] .U56YlW_title{flex:auto;min-width:0;font-weight:500}[data-phone] .U56YlW_review{border-radius:var(--dsw-radius-sm);border:0;grid-column:auto;justify-self:stretch;place-items:center;width:44px;height:44px;padding:0;display:grid}[data-phone] .U56YlW_reviewLabel{display:none}[data-phone] .U56YlW_mobileChevron,[data-phone] .U56YlW_mobileFileIcon{color:var(--dsw-alias-label-secondary);flex:none;display:block}[data-phone] .U56YlW_mobileChevron{transition:transform .15s}[data-phone] .U56YlW_mobileChevron[data-open=true]{transform:rotate(180deg)}[data-phone] .U56YlW_fileHead,[data-phone] .U56YlW_more{gap:8px;min-height:44px;padding:0 12px}[data-phone] .U56YlW_titleLink{align-self:center;min-height:44px}[data-phone] .U56YlW_openFile{border-radius:var(--dsw-radius-sm);width:44px;height:44px;margin-right:0}[data-phone] .U56YlW_file+.U56YlW_file{border-top:1px solid var(--dsw-alias-border-l2)}[data-phone] .U56YlW_path{display:none}[data-phone] .U56YlW_mobilePath{flex-direction:column;flex:1;min-width:0;padding-block:4px;display:flex}[data-phone] .U56YlW_fileName{text-overflow:ellipsis;white-space:nowrap;font-weight:500;overflow:hidden}[data-phone] .U56YlW_directory,[data-phone] .U56YlW_mobileFullPath{color:var(--dsw-alias-label-secondary);font-size:calc(11px + var(--dsh-content-font-delta-secondary,0px));line-height:calc(16px + var(--dsh-content-font-delta-secondary,0px));white-space:normal;overflow-wrap:anywhere}[data-phone] .U56YlW_mobileFullPath{user-select:text;padding:4px 12px;display:block}[data-phone] .U56YlW_diff,[data-phone] .U56YlW_file:first-child .U56YlW_diff:first-child{padding:0}[data-phone] .U56YlW_diffStatus{overflow-wrap:anywhere;padding:12px;display:block}[data-phone] .U56YlW_diffStatus button{min-width:44px;min-height:44px}[data-phone] .U56YlW_inlineDiff{border-radius:0;min-width:0;max-width:100%;margin:0}[data-phone] .U56YlW_inlineDiff [data-diff-body]{box-sizing:border-box;-webkit-text-size-adjust:100%;text-size-adjust:100%;width:100%;min-width:0;font-size:calc(var(--dsw-font-markdown-code-block-font-size,11px) + var(--dsh-content-font-delta,0px));line-height:calc(var(--dsw-font-markdown-code-block-line-height,19px) + var(--dsh-content-font-delta,0px));tab-size:2;overscroll-behavior-x:contain}[data-phone] .U56YlW_inlineDiff [data-diff-row=path]{display:none}[data-phone] .U56YlW_inlineDiff [data-code-block-banner]{gap:8px;min-height:44px;padding:0 8px 0 12px}[data-phone] .U56YlW_inlineDiff [data-code-block-banner] button{width:44px;height:44px}@media (prefers-reduced-motion:reduce){[data-phone] .U56YlW_mobileChevron{transition:none}}`,document.head.appendChild(e)}var Z={card:`U56YlW_card`,chevron:`U56YlW_chevron`,diff:`U56YlW_diff`,diffStatus:`U56YlW_diffStatus`,directory:`U56YlW_directory`,file:`U56YlW_file`,fileHead:`U56YlW_fileHead`,fileName:`U56YlW_fileName`,fileRow:`U56YlW_fileRow`,files:`U56YlW_files`,header:`U56YlW_header`,icon:`U56YlW_icon`,inlineDiff:`U56YlW_inlineDiff`,mobileChevron:`U56YlW_mobileChevron`,mobileFileIcon:`U56YlW_mobileFileIcon`,mobileFullPath:`U56YlW_mobileFullPath`,mobilePath:`U56YlW_mobilePath`,more:`U56YlW_more`,openFile:`U56YlW_openFile`,path:`U56YlW_path`,review:`U56YlW_review`,reviewLabel:`U56YlW_reviewLabel`,text:`U56YlW_text`,title:`U56YlW_title`,titleLink:`U56YlW_titleLink`};let $y=(0,d.memo)(function({nodeStore:e,turn:t,t:n,useProjection:r,loadTurnDiffs:i,openFile:a}){let o=S(e,t,r),s=(0,d.useMemo)(()=>{let e=/* @__PURE__ */ new Map;for(let t of o){let n=w(t.path);e.set(n,(e.get(n)??0)+1)}return e},[o]),[c,l]=(0,d.useState)(()=>/* @__PURE__ */ new Set),[u,m]=(0,d.useState)(!1),h=Zy(t,o,c,i),g=(0,d.useMemo)(()=>({codeLabel:n(`diff.code`),wrapLabel:n(`diff.wrap`),unwrapLabel:n(`diff.unwrap`),copy:n(`diff.copy`),copied:n(`diff.copied`),collapseAria:n(`diff.collapseAria`),expandAria:e=>n(`diff.expandAria`,{count:e}),collapse:n(`diff.collapse`),expand:e=>n(`diff.expand`,{count:e})}),[n]);if(o.length===0)return null;let{added:_,removed:y}=C(o),[b]=o,x=o.length===1&&b!==void 0?n(`chat.fileEdited`,{name:w(b.path)}):n(`chat.filesEdited`,{count:o.length}),T=o.some(e=>c.has(e.path)),E=u?o:o.slice(0,3),D=o.length-E.length;return/* @__PURE__ */ (0,f.jsxs)(`section`,{className:Z.card,"data-turn-changes":t,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Z.header,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.icon,"aria-hidden":`true`,children:/* @__PURE__ */ (0,f.jsx)(p.IconFileDiffOutlineRegular,{size:24})}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:Z.text,children:[o.length===1&&b!==void 0&&a!==void 0?/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:`${Z.title} ${Z.titleLink}`,title:n(`chat.openFile`,{path:b.path}),onClick:()=>a(b.path),children:x}):/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.title,title:x,children:x}),/* @__PURE__ */ (0,f.jsx)(v,{added:_,removed:y})]}),/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Z.review,"aria-expanded":T,"aria-label":n(T?`chat.hideChanges`:`chat.viewChanges`),onClick:()=>{l(new Set(T?[]:o.map(e=>e.path))),T||m(!0)},children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.reviewLabel,children:n(T?`chat.hideChanges`:`chat.viewChanges`)}),/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:16,className:Z.mobileChevron,"data-open":T})]})]}),(o.length>1||T)&&/* @__PURE__ */ (0,f.jsxs)(`ul`,{className:Z.files,children:[E.map(e=>{let t=h.diffs(e),r=w(e.path);return/* @__PURE__ */ (0,f.jsxs)(`li`,{className:Z.file,children:[o.length>1&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Z.fileRow,children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Z.fileHead,"aria-expanded":c.has(e.path),onClick:()=>{l(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n})},children:[/* @__PURE__ */ (0,f.jsx)(p.IconFileDiffOutlineRegular,{size:16,className:Z.mobileFileIcon}),/* @__PURE__ */ (0,f.jsx)(p.PathLabel,{path:e.path,className:Z.path}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:Z.mobilePath,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.fileName,"aria-hidden":`true`,children:r}),(s.get(r)??0)>1&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.directory,"aria-hidden":`true`,children:e.path.slice(0,e.path.length-r.length)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:U_.visuallyHidden,children:e.path})]}),/* @__PURE__ */ (0,f.jsx)(v,{added:e.added,removed:e.removed}),/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:16,className:Z.mobileChevron,"data-open":c.has(e.path)})]}),a!==void 0&&/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Z.openFile,"aria-label":n(`chat.openFile`,{path:e.path}),title:n(`chat.openFile`,{path:e.path}),onClick:()=>a(e.path),children:/* @__PURE__ */ (0,f.jsx)(p.IconRightUpOutlineRegular,{size:16})})]}),c.has(e.path)&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Z.diff,children:[/* @__PURE__ */ (0,f.jsx)(`div`,{className:Z.mobileFullPath,children:e.path}),t===void 0?h.error?/* @__PURE__ */ (0,f.jsxs)(`div`,{role:`alert`,className:Z.diffStatus,children:[h.error,` `,/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,onClick:h.retry,children:n(`chat.retryDiff`)})]}):/* @__PURE__ */ (0,f.jsx)(`span`,{role:`status`,className:Z.diffStatus,children:n(`chat.loadingDiff`)}):/* @__PURE__ */ (0,f.jsx)(p.DiffBlock,{diffs:[...t],labels:g,maxLines:1/0,className:Z.inlineDiff})]})]},e.path)}),o.length>3&&/* @__PURE__ */ (0,f.jsx)(`li`,{children:/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Z.more,"aria-expanded":u,onClick:()=>m(e=>!e),children:[D>0?n(`chat.showMoreFiles`,{count:D}):n(`chat.collapseFiles`),/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:16,className:Z.chevron,"data-open":u})]})})]})]})});function eb(e){return e.flatMap(e=>e.kind===`text`?[e.text]:[]).join(``)}function tb(e){return e.some(e=>e.kind===`reasoning`||e.kind===`tool-call`?!1:e.kind!==`text`||e.text.trim()!==``)}let nb=`@deepseek-ai/dsh-client-ui-chat/TurnTailNodeView.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(nb)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=nb,e.textContent=`.zJ_1ta_root{flex-direction:column;gap:16px;display:flex}.zJ_1ta_actions{margin-top:4px;margin-left:-6px}`,document.head.appendChild(e)}var rb={actions:`zJ_1ta_actions`,root:`zJ_1ta_root`};function ib(e,t,n){let r=e.locations.getTurn(t);for(let t=r.length-1;t>=0;t--){let i=e.nodes.get(r[t]);if(!(i===void 0||i.kind===`turn-tail`||i.kind===`turn-process`||n&&i.kind===`turn-max-tokens`))return i}}let ab=(0,d.memo)(function({node:e,openFile:t,forkAt:n,handoffAt:r,loadTurnDiffs:i,renderSlot:a,t:o,useChat:s,useSession:c,useProjection:l}){let u=c(e=>e.openState===`open`),p=(0,d.useRef)(!1),[m,h]=(0,d.useState)(!1),[g,_]=(0,d.useState)(),v=e.data,y=s(e=>e.nodes),b=s(e=>(ib(e,v.turn,!0)?.anchorSeq??-1)>(v.closing?.finalNode.seq??v.seq)),x=s(e=>{if(e.timeline.turnOrder.at(-1)!==v.turn)return!1;let t=ib(e,v.turn,!1),n=t?.kind===`assistant-step`?t.data.blocks.findLast(e=>e.kind!==`text`&&e.kind!==`reasoning`||e.text.trim()!==``):void 0;return n!==void 0&&tb([n])}),S=e.location.kind===`turn`||e.location.kind===`step`?e.location.turn:void 0,C=Bh(l,S?.turn,`end`);if(S===void 0)return null;let w=v.closing,T=a(`conversation.chat.turnTail`,{turn:S,seq:w?.finalNode.seq??v.seq,openFile:t});if(w===null)return T===null?null:/* @__PURE__ */ (0,f.jsx)(`div`,{className:rb.root,"data-turn-tail":v.turn,children:T});let E=w.finalNode.messageId,D=E===void 0?null:a(`conversation.chat.assistant-actions`,{messageId:E});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:rb.root,"data-turn-tail":v.turn,"data-actions-reveal":x?`always`:`hover`,children:[/* @__PURE__ */ (0,f.jsx)($y,{nodeStore:y,turn:v.turn,t:o,useProjection:l,loadTurnDiffs:i,openFile:t}),T,/* @__PURE__ */ (0,f.jsx)(Eh,{text:eb(w.blocks),time:C,clock:`end`,onBranch:n===void 0?void 0:()=>{!p.current&&u&&(p.current=!0,h(!0),_(void 0),n(v.seq).catch(e=>{_(e instanceof Error?e.message:String(e))}).finally(()=>{p.current=!1,h(!1)}))},branchUnavailable:!u||m||v.branchUnavailable||b,onHandoff:r===void 0?void 0:()=>{u&&r(v.seq)},handoffUnavailable:!u||v.branchUnavailable||b,className:rb.actions,extraActions:D,t:o}),g!==void 0&&/* @__PURE__ */ (0,f.jsx)(`p`,{role:`alert`,children:o(`message.branchFailed`,{message:g})})]})});function ob(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function sb(e,t){return typeof e[t]==`string`?e[t]:``}function cb(e){let t=ob(e.source),n=sb(t,`kind`),r=`message.trigger.request`,i=`request`;switch(n){case`goal`:r=`message.trigger.goal`,i=`goal`;break;case`agent-message`:r=`message.trigger.agent`,i=`agent`;break;case`team-message`:r=`message.trigger.team`,i=`team`;break;case`subagent-settled`:r=`message.trigger.subagent`,i=`subagent`;break;case`webhook`:{let e=sb(t,`provider`)===`github`;r=e?`message.trigger.github`:`message.trigger.webhook`,i=e?`github`:`webhook`;break}case`schedule`:r=`message.trigger.schedule`,i=`schedule`;break;case`tool-jobs`:r=`message.trigger.job`,i=`job`;break;case`cordis-host-runner`:r=`message.trigger.plugin`,i=`plugin`}return{title:r,icon:i}}let lb=`@deepseek-ai/dsh-client-ui-chat/TurnTriggerNodeView.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(lb)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=lb,e.textContent=`.kkOUVW_root{border:.5px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-xl);background:var(--dsw-alias-turn-trigger-bg,var(--dsw-alias-markdown-code-block));min-width:0;transition:background-color .1s}@media (hover:hover){.kkOUVW_root:hover{background:var(--dsw-alias-turn-trigger-bg-hover,var(--dsw-alias-interactive-bg-hover))}}.kkOUVW_header{width:100%;color:var(--dsw-alias-label-tertiary);font:inherit;text-align:left;cursor:pointer;background:0 0;border:0;align-items:center;gap:10px;padding:12px 16px;transition:color .1s;display:flex}@media (hover:hover){.kkOUVW_header:hover{color:var(--dsw-alias-label-secondary)}}.kkOUVW_header:active{color:var(--dsw-alias-label-secondary)}.kkOUVW_icon{color:inherit;flex:none;display:inline-flex}.kkOUVW_title{font-size:var(--dsh-content-font-size,14px);flex:none}.kkOUVW_time{color:inherit;font:var(--dsw-font-xxs-12);flex:none;margin-left:auto}.kkOUVW_chevron,.kkOUVW_openChevron{color:inherit;flex:none}.kkOUVW_openChevron{transform:rotate(180deg)}.kkOUVW_body{padding:0 16px 12px 40px}.kkOUVW_explanation{color:var(--dsw-alias-label-secondary);font:var(--dsw-font-xxs-12);margin:8px 0}.kkOUVW_content{white-space:pre-wrap;overflow-wrap:anywhere;max-height:240px;font:var(--dsw-font-xxs-12);overflow:auto}@media (prefers-reduced-motion:reduce){.kkOUVW_root,.kkOUVW_header{transition:none}}`,document.head.appendChild(e)}var ub={body:`kkOUVW_body`,chevron:`kkOUVW_chevron`,content:`kkOUVW_content`,explanation:`kkOUVW_explanation`,header:`kkOUVW_header`,icon:`kkOUVW_icon`,openChevron:`kkOUVW_openChevron`,root:`kkOUVW_root`,time:`kkOUVW_time`,title:`kkOUVW_title`};let db={request:p.IconContextInjectionOutlineRegular,goal:p.IconGoalOutlineRegular,agent:p.IconPaperPlaneOutlineRegular,team:p.IconAgentPresetOutlineRegular,subagent:p.IconAgentPresetOutlineRegular,github:p.IconBranchOutlineRegular,webhook:p.IconGlobeOutlineRegular,schedule:p.IconClockOutlineRegular,job:p.IconQueueOutlineRegular,plugin:p.IconCordisPluginOutlineRegular};function fb({node:e,t}){let[n,r]=(0,d.useState)(!1),i=(0,d.useId)(),a=cb(e.data),o=db[a.icon],s=new Date(e.data.time),c=vh(e.data.time,t);return/* @__PURE__ */ (0,f.jsxs)(`section`,{className:ub.root,"data-turn-trigger":!0,children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{className:ub.header,type:`button`,"aria-expanded":n,"aria-controls":i,onClick:()=>{r(!n)},children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:ub.icon,"aria-hidden":!0,children:/* @__PURE__ */ (0,f.jsx)(o,{size:14})}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:ub.title,children:t(a.title)}),/* @__PURE__ */ (0,f.jsx)(`time`,{className:ub.time,dateTime:s.toISOString(),children:c}),/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:12,className:n?ub.openChevron:ub.chevron})]}),n&&/* @__PURE__ */ (0,f.jsxs)(`div`,{id:i,className:ub.body,children:[/* @__PURE__ */ (0,f.jsx)(`p`,{className:ub.explanation,children:t(`message.trigger.explanation`)}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:ub.content,children:/* @__PURE__ */ (0,f.jsx)(ih,{content:e.data.content,source:e.data.source,t})})]})]})}function pb(e,t){e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`user`,locale:by,inject:t=>({links:e.get(`chatLinks`),sessionId:t})},eg)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`steering`,locale:by,inject:t=>({links:e.get(`chatLinks`),sessionId:t})},eg)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`context`,locale:by},ng)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-trigger`,locale:by},fb)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`system-prompt`,locale:by},qy)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`assistant-step`,locale:by,inject:()=>({hooks:{presentation:t}})},Ly)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`command`,locale:by,children:{"conversation.chat.commandview":{kind:`keyed`,scope:`session`}}},Wy)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`manual-compaction`,locale:by},Gy)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`compaction`,locale:by},rg)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`model-retry`,locale:by},ig)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-error`,locale:by},ag)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-max-tokens`,locale:by},og)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-process`,locale:by},Xy)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-tail`,locale:by,children:{"conversation.chat.turnTail":{kind:`list`,scope:`session`},"conversation.chat.assistant-actions":{kind:`list`,scope:`session`}}},ab)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`unknown`,locale:by},sg))}let mb={interruptedAssistant:-.9,interruptedFollowup:-.8,processControl:-.1,maxTokensNotice:.05,finalizedFollowup:.1};function hb(e){return e.start?.location??e.matches[0]?.location??{kind:`unresolved`}}function gb(e,t,n,r,i={}){return{key:e.key,kind:t,id:e.id,target:`chat`,anchorSeq:n,location:i.location??hb(e),visibility:i.visibility??`visible`,data:r}}function _b(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function vb(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function yb(e,t,n){let r=e[t];if(!Array.isArray(r))return[];let i=[];for(let e of r){let t=_b(e),r=t===null?null:vb(t,n);r!==null&&!i.includes(r)&&i.push(r)}return i}function bb(e){return e.length>0?e.join(`, `):null}let xb=[`instructions`,`catalog`,`snapshot`,`notice`,`relay`,`recall`];function Sb(e){let t=_b(e),n=t===null?null:vb(t,`form`);return n!==null&&xb.includes(n)?n:null}function Cb(e){let t=_b(e),n=t===null?null:vb(t,`kind`);if(t===null||n===null)return{role:`inject`,label:null};switch(n){case`session-reference`:return{role:`recall`,label:bb(yb(t,`references`,`label`))??n};case`agent-instructions`:return{role:`inject`,label:bb(yb(t,`changes`,`path`))??n};case`skill-invocation`:return{role:`inject`,label:vb(t,`name`)??n};default:return{role:`inject`,label:n}}}function wb(e){let t=_b(e);return t===null||vb(t,`kind`)!==`session-reference`?[]:yb(t,`references`,`label`)}function Tb(e){let t=_b(e);return t===null||vb(t,`kind`)!==`skill-invocation`?null:vb(t,`name`)}function Eb(e){return e.map(Db)}function Db(e){switch(e.type){case`text`:return{kind:`text`,text:e.text};case`reasoning`:return{kind:`reasoning`,text:e.text};case`image`:return e.codexhostImageView===!0?{kind:`viewed-images`,attachment:e.attachment}:{kind:`image`,attachment:e.attachment};case`tool-call`:return{kind:`tool-call`,callId:String(e.id),name:e.name,argsRaw:e.arguments};default:return{kind:`other`,block:e}}}function Ob(e){switch(e){case`text`:return{kind:`text`,text:``};case`reasoning`:return{kind:`reasoning`,text:``};case`tool-call`:return{kind:`tool-call`,callId:``,name:``,argsRaw:``};default:return{kind:`other`,block:null}}}function kb(e){if(typeof e!=`object`||!e)return{message:String(e)};let t=e,n=typeof t.code==`string`?t.code:void 0;return n===`AUTH`?{code:n,message:``}:{...n===void 0?{}:{code:n},message:typeof t.message==`string`?t.message:JSON.stringify(e)}}function Ab(e){switch(e.type){case`text-delta`:case`reasoning-delta`:return e.text!==``;case`tool-call-delta`:return e.argumentsDelta!==``||e.name!==void 0;default:return!1}}function jb(e,t){return{turn:e,step:t,blocks:[],visibleByIndex:[],visibleBlocks:0,firstVisibleSeq:void 0,firstVisibleTime:void 0,firstTokenTime:void 0,final:void 0,usage:void 0}}function Mb(e){return e.filter(e=>e!==void 0)}function Nb(e){return e===void 0||e.kind===`tool-call`?!1:e.kind===`text`||e.kind===`reasoning`?e.text.trim()!==``:!0}function Pb(e){return e.some(Nb)}function Fb(e){return e.some(e=>e.kind===`text`||e.kind===`reasoning`?e.text.trim()!==``:!0)}function Ib(e){return{...jb(e.turn,e.step),firstTokenTime:e.firstTokenTime}}function Lb(e,t,n,r){if(t.type===`tool-call-delta`){let n=e.blocks[t.index];if(n?.kind===`tool-call`&&n.callId!==``&&(t.name===void 0||t.name===n.name)&&(e.firstTokenTime!==void 0||!Ab(t)))return e}let i=[...e.blocks],a=-1,o=!1,s=!1;switch(t.type){case`block-start`:a=t.index,o=e.visibleByIndex[t.index]===!0,i[t.index]=Ob(t.blockType),s=Nb(i[t.index]);break;case`text-delta`:{let n=i[t.index];a=t.index,o=e.visibleByIndex[t.index]===!0,i[t.index]={kind:`text`,text:(n?.kind===`text`?n.text:``)+t.text},s=n?.kind===`text`&&o||t.text.trim()!==``;break}case`reasoning-delta`:{let n=i[t.index];a=t.index,o=e.visibleByIndex[t.index]===!0,i[t.index]={kind:`reasoning`,text:(n?.kind===`reasoning`?n.text:``)+t.text},s=n?.kind===`reasoning`&&o||t.text.trim()!==``;break}case`tool-call-delta`:{let n=i[t.index];a=t.index,o=e.visibleByIndex[t.index]===!0,i[t.index]={kind:`tool-call`,callId:(n?.kind===`tool-call`?n.callId:``)||String(t.id),name:t.name??(n?.kind===`tool-call`?n.name:``),argsRaw:n?.kind===`tool-call`?n.argsRaw:``};break}case`block-end`:a=t.index,o=e.visibleByIndex[t.index]===!0,i[t.index]=Db(t.block),s=Nb(i[t.index]);break;case`usage`:return{...e,usage:t.usage};default:return e}let c=e.visibleBlocks-Number(o)+Number(s),l=e.visibleByIndex;if(o!==s){let e=[...l];e[a]=s,l=e}let u=Ab(t);return{...e,blocks:i,visibleByIndex:l,visibleBlocks:c,...c>0&&e.firstVisibleSeq===void 0?{firstVisibleSeq:n,firstVisibleTime:r}:{},...u&&e.firstTokenTime===void 0?{firstTokenTime:r}:{}}}function Rb(e,t,n){let r=Eb(n.data.message.content),i=r.map(Nb);return{...e,blocks:r,visibleByIndex:i,visibleBlocks:i.reduce((e,t)=>e+Number(t),0),final:t,usage:n.data.usage}}function zb(e){if(e.kind===`step`&&e.step.status===`closed`&&e.step.end!==void 0)return e.step.end;if((e.kind===`step`||e.kind===`turn`)&&e.turn.status===`closed`&&e.turn.end!==void 0)return e.turn.end}function Bb(e,t){let n=e.final;if(n?.event.type===`assistant/message`){let r=n.event;return{kind:`assistant`,seq:r.seq,messageId:r.data.message.id,time:r.time,turn:e.turn,step:e.step,blocks:Eb(r.data.message.content),usage:r.data.usage,timing:{stepStartTime:t.start?.event.time??null,firstTokenTime:e.firstTokenTime??null,completedTime:r.time},...r.data.interrupted===!0?{interrupted:!0}:{}}}let r=t.start?.location??t.matches.at(-1)?.location,i=r===void 0?void 0:zb(r);if(i===void 0)return;let a=Mb(e.blocks);if(Fb(a))return{kind:`assistant`,seq:i.seq+mb.interruptedAssistant,time:i.time,turn:e.turn,step:e.step,blocks:a,interrupted:!0}}function Vb(e){let t;for(let n of e.matches)n.event.type===`assistant/live-chunk`?(t??=jb(n.event.data.turn,n.event.data.step),t=Lb(t,n.event.data.chunk,n.event.seq,n.event.time)):n.event.type===`assistant/message`?(t??=jb(n.event.data.turn,n.event.data.step),t=Rb(t,n,n.event)):n.event.type===`llm/retry`&&t!==void 0&&(t=Ib(t));return t}function Hb(e){let t=e.state??Vb(e);if(t===void 0)return;let n=Bb(t,e),r=n?.blocks??Mb(t.blocks),i=n===void 0?t.visibleBlocks>0:Pb(r),a=n?.interrupted===!0?`interrupted`:n===void 0?`running`:`settled`,o=(n?.interrupted===!0?n.seq:t.firstVisibleSeq??n?.seq)??e.matches[0]?.event.seq??0,s=n?.time??t.firstVisibleTime??e.matches[0]?.event.time??0;return{anchorSeq:o,visible:i,settled:n,data:{status:a,turn:t.turn,step:t.step,blocks:r,time:s,...t.usage===void 0?{}:{usage:t.usage},...n===void 0?{}:{finalNode:n}}}}function Ub(e){let t=e.start?.location??e.matches.at(-1)?.location;return t?.kind===`step`?t.step.data.get(`assistant-step`):void 0}let Wb={kind:`assistant-step`,target:`chat`,match:e=>e.type===`step/start`?{id:`${e.data.turn}:${e.data.step}`,role:`start`}:e.type===`assistant/live-chunk`||e.type===`assistant/message`&&e.surfaceOp===`append`||e.type===`llm/retry`?{id:`${e.data.turn}:${e.data.step}`,role:`update`}:null,start:(e,t)=>{if(t.event.type!==`step/start`)throw Error(`assistant-step start requires step/start`);return jb(t.event.data.turn,t.event.data.step)},update:(e,t)=>t.event.type===`assistant/live-chunk`?Lb(e.state,t.event.data.chunk,t.event.seq,t.event.time):t.event.type===`assistant/message`?Rb(e.state,t,t.event):t.event.type===`llm/retry`?Ib(e.state):e.state,publication:e=>{if(e.event.type===`step/start`)return`none`;if(e.event.type!==`assistant/live-chunk`)return`immediate`;let t=e.event.data.chunk.type;return t===`usage`||t===`finish`?`none`:`animation-frame`},buildLocationData:(e,t)=>{if(t!==`step`)return null;let n=Hb(e);return n===void 0?null:{kind:`step`,turn:n.data.turn,step:n.data.step,key:`assistant-step`,value:n.data}},buildViewNode:e=>{let t=e.current.get(`chat`),n=e.state??Vb(e),r=Ub(e);if(n===void 0||r===void 0)return t==null?null:{...t,visibility:`hidden`};let i=r.finalNode,a=i===void 0?n.visibleBlocks>0:Pb(r.blocks);return i===void 0&&!a&&t==null?null:gb(e,`assistant-step`,(i?.interrupted===!0?i.seq:n.firstVisibleSeq??i?.seq)??e.matches[0]?.event.seq??0,r,{visibility:i?.interrupted===!0||a?`visible`:`hidden`})}};function Gb(e){let t=Wb.match.bind(Wb);e.uiConversation.events.register({...Wb,match:{"step/start":t,"assistant/live-chunk":t,"assistant/message":t,"llm/retry":t}})}function Kb(e){return`kind`in e}function qb(e){return!Kb(e)}function Jb(e){return e.visibility===`visible`&&e.kind!==`system-prompt`&&(e.kind!==`context`||e.data.content.some(e=>e.type===`tool-addition`||e.type===`tool-removal`))&&(e.kind!==`command`||e.data.name!==`permission`)}function Yb(e,t){let n=``,r=!1;for(let i of e){if(n.length>=t*2){r=!0;break}let e=i.length>t*2,a=e?i.slice(0,t*2):i;if(n+=n===``?a:` ${a}`,e){r=!0;break}}let i=n.replace(/\s+/g,` `).trim();return i.length>t-1?`${i.slice(0,t-1).trimEnd()}…`:r?`${i}…`:i}function Xb(e){return e.kind===`user`?Yb(e.data.content.flatMap(e=>e.type===`text`?[e.text]:[]),50):``}function Zb(e){return e.kind===`assistant-step`?Yb(e.data.blocks.flatMap(e=>e.kind===`text`?[e.text]:[]),120):``}function Qb(e,t){return e===void 0||t===void 0?e===t:e.turn===t.turn&&e.anchorKey===t.anchorKey&&e.prompt===t.prompt&&e.response===t.response}function $b(e,t,n){let r=t.getTurn(e).map(e=>n.get(e)).filter(e=>e!==void 0&&Jb(e)),i=r.find(e=>e.kind===`user`),a=i??r[0];if(a===void 0)return;let o=r.findLast(e=>Zb(e)!==``);return{turn:e,anchorKey:a.key,prompt:i===void 0?``:Xb(i),response:o===void 0?``:Zb(o)}}function ex(e){let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn.turn:void 0}function tx(e,t){return e===t||e!==void 0&&t!==void 0&&e.spec===t.spec&&e.turn===t.turn&&e.turnStarted===t.turnStarted&&e.turnClosed===t.turnClosed&&e.hasExternalProcess===t.hasExternalProcess&&e.hasInterleavedInput===t.hasInterleavedInput&&e.compactAnswer===t.compactAnswer}function nx(e,t,n){let r=t.getTurn(e),i=r.map(e=>n.get(e)).find(e=>e?.kind===`turn-process`);if(i===void 0)return;let a=i.data,o=i.location;if(o.kind!==`turn`&&o.kind!==`step`)return;let s;for(let e of r){let t=n.get(e);(t?.kind===`user`||t?.kind===`steering`||t?.kind===`turn-trigger`)&&(a.controlAnchorSeq===o.turn.start?.seq||t.anchorSeq<a.controlAnchorSeq)&&(s=Math.max(s??t.anchorSeq,t.anchorSeq))}let c=!1,l=!1,u=!0;for(let e of r){let t=n.get(e);t!==void 0&&Jb(t)&&t.kind!==`turn-process`&&((t.kind===`user`||t.kind===`steering`||t.kind===`turn-trigger`)&&(s===void 0||t.anchorSeq>s)&&(l=!0,(a.answerAnchorSeq===null||t.anchorSeq<a.answerAnchorSeq)&&(u=!1)),!(cg.has(t.kind)||t.anchorSeq<a.processStartSeq)&&(t.kind!==`assistant-step`||a.answerStep===null||t.data.step!==a.answerStep)&&(c=!0))}return{turn:e,spec:a,turnStarted:o.turn.start!==void 0,turnClosed:o.turn.status===`closed`,hasExternalProcess:c,hasInterleavedInput:l,compactAnswer:u}}var rx=class{presentations=/* @__PURE__ */ new Map;get(e){let t=ex(e);return t===void 0?void 0:this.presentations.get(t)}replace(e,t,n){let r=/* @__PURE__ */ new Set;for(let t of e){let e=ex(n.get(t));e!==void 0&&r.add(e)}let i=/* @__PURE__ */ new Set;for(let e of/* @__PURE__ */ new Set([...this.presentations.keys(),...r]))this.set(e,r.has(e)?nx(e,t,n):void 0)&&i.add(e);return i}update(e,t,n){let r=/* @__PURE__ */ new Set;for(let i of e)this.set(i,nx(i,t,n))&&r.add(i);return r}set(e,t){return!tx(this.presentations.get(e),t)&&(t===void 0?this.presentations.delete(e):this.presentations.set(e,t),!0)}};let ix=[],ax=[],ox=[],sx=[];function cx(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function lx(e,t,n){let r=e.get(t);return r===void 0&&(r=n(),e.set(t,r)),r}var ux=class{read;label;listeners=/* @__PURE__ */ new Set;published;constructor(e,t){this.read=e,this.label=t,this.published=e()}getSnapshot=()=>this.read();subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});publish(){let e=this.getSnapshot();this.published!==e&&(this.published=e,(0,m.notifySubscribers)(this.listeners,this.label))}},dx=class{nodes=/* @__PURE__ */ new Map;current=sx;dirty=!1;observable;source(){return this.observable??=new ux(()=>this.read(),`[ui-chat] turn kind nodes`)}set(e){let t=this.nodes.get(e.key);this.nodes.set(e.key,e),(t===void 0||t.data!==e.data||t.anchorSeq!==e.anchorSeq)&&(this.dirty=!0)}delete(e){this.nodes.delete(e),this.dirty=!0}publish(){this.observable?.publish()}read(){return this.dirty&&=(this.current=[...this.nodes.values()].sort((e,t)=>e.anchorSeq-t.anchorSeq).map(e=>e.data),!1),this.current}},fx=class{byKey=/* @__PURE__ */ new Map;turnProcesses=new rx;sources=/* @__PURE__ */ new Map;processSources=/* @__PURE__ */ new Map;dirtyKeys=/* @__PURE__ */ new Set;dirtyProcessKeys=/* @__PURE__ */ new Set;turnKinds=/* @__PURE__ */ new Map;dirtyTurnKinds=/* @__PURE__ */ new Set;valuesCache=sx;valuesDirty=!1;get(e){return this.byKey.get(e)}source(e){return lx(this.sources,e,()=>new ux(()=>this.get(e),`[ui-chat] node source ${e}`))}turnDataSource(e,t){return this.turnKind(e,t).source()}turnKind(e,t){return lx(lx(this.turnKinds,e,()=>/* @__PURE__ */ new Map),t,()=>new dx)}updateTurnKind(e,t){let n=e===void 0?void 0:_x(e.location).turn,r=t===void 0?void 0:_x(t.location).turn;if(e!==void 0&&n!==void 0&&(n!==r||e.kind!==t?.kind)){let t=this.turnKind(n,e.kind);t.delete(e.key),this.dirtyTurnKinds.add(t)}if(t!==void 0&&r!==void 0){let e=this.turnKind(r,t.kind);e.set(t),this.dirtyTurnKinds.add(e)}}processSource(e){return lx(this.processSources,e,()=>new ux(()=>this.process(e),`[ui-chat] node process source ${e}`))}process(e){return this.turnProcesses.get(this.get(e))}values(){return this.valuesDirty&&=(this.valuesCache=[...this.byKey.values()],!1),this.valuesCache}replace(e){let t=new Map(this.byKey);this.byKey.clear();for(let n of e)this.byKey.set(n.key,n),t.get(n.key)!==n&&(this.updateTurnKind(t.get(n.key),n),this.dirtyKeys.add(n.key),this.dirtyProcessKeys.add(n.key)),t.delete(n.key);for(let e of t.keys())this.updateTurnKind(t.get(e),void 0),this.dirtyKeys.add(e),this.dirtyProcessKeys.add(e);this.valuesCache=[...this.byKey.values()],this.valuesDirty=!1}upsert(e){let t=!1;for(let n of e)this.byKey.get(n.key)!==n&&(this.updateTurnKind(this.byKey.get(n.key),n),this.byKey.set(n.key,n),this.dirtyKeys.add(n.key),this.dirtyProcessKeys.add(n.key),t=!0);t&&(this.valuesDirty=!0)}touchProcesses(e,t){for(let n of e)for(let e of t.getTurn(n))this.dirtyProcessKeys.add(e)}replaceProcesses(e,t){this.touchProcesses(this.turnProcesses.replace(e,t,this),t)}updateProcesses(e,t){this.touchProcesses(this.turnProcesses.update(e,t,this),t)}publish(){let e=[...this.dirtyKeys],t=[...this.dirtyProcessKeys],n=[...this.dirtyTurnKinds];this.dirtyKeys.clear(),this.dirtyProcessKeys.clear(),this.dirtyTurnKinds.clear();for(let t of e)this.sources.get(t)?.publish();for(let e of t)this.processSources.get(e)?.publish();for(let e of n)e.publish()}},px=class{turns=/* @__PURE__ */ new Map;steps=/* @__PURE__ */ new Map;positions=/* @__PURE__ */ new Map;getTurn(e){return this.turns.get(e)??ix}getStep(e,t){return this.steps.get(gx(e,t))??ix}getPosition(e){return this.positions.get(e)}rebuild(e,t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Set;for(let[o,s]of e.entries()){let c=t.get(s)?.location;if(c===void 0)continue;let l=_x(c),u=this.positions.get(s),d={turn:l.turn,previous:e[o-1],next:e[o+1]},f=u!==void 0&&u.turn===d.turn&&u.previous===d.previous&&u.next===d.next;if(i.set(s,f?u:d),f||(u?.turn!==void 0&&a.add(u.turn),d.turn!==void 0&&a.add(d.turn)),l.turn===void 0)continue;let p=n.get(l.turn)??[];if(p.push(s),n.set(l.turn,p),l.step===void 0)continue;let m=gx(l.turn,l.step),h=r.get(m)??[];h.push(s),r.set(m,h)}for(let[e,t]of this.positions)!i.has(e)&&t.turn!==void 0&&a.add(t.turn);return this.positions=i,this.turns=mx(this.turns,n),this.steps=mx(this.steps,r),[...a]}touch(e){let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Set;for(let r of e){let e=_x(r.location);e.turn!==void 0&&this.turns.get(e.turn)?.includes(r.key)&&(t.add(e.turn),e.step!==void 0&&n.add(gx(e.turn,e.step)))}for(let e of t){let t=this.turns.get(e);t!==void 0&&this.turns.set(e,[...t])}for(let e of n){let t=this.steps.get(e);t!==void 0&&this.steps.set(e,[...t])}}};function mx(e,t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Set([...e.keys(),...t.keys()]);for(let i of r){let r=e.get(i)??ix,a=t.get(i)??ix,o=cx(r,a)?r:a;a.length>0&&n.set(i,o)}return n}var hx=class{current=ox;byTurn=/* @__PURE__ */ new Map;items(){return this.current}rebuild(e,t,n){let r=[],i=/* @__PURE__ */ new Map;for(let a of e.turnOrder){let e=$b(a,t,n);if(e===void 0)continue;let o=this.byTurn.get(a),s=o!==void 0&&Qb(o,e)?o:e;r.push(s),i.set(a,s)}this.byTurn=i,r.length===this.current.length&&r.every((e,t)=>e===this.current[t])||(this.current=r)}touch(e,t,n){if(e.size===0)return;let r=this.current.map(r=>{if(!e.has(r.turn))return r;let i=$b(r.turn,t,n);return i===void 0||Qb(r,i)?r:(this.byTurn.set(r.turn,i),i)});r.some((e,t)=>e!==this.current[t])&&(this.current=r)}};function gx(e,t){return`${e}:${t}`}function _x(e){return e.kind===`step`?{turn:e.turn.turn,step:e.step.step}:e.kind===`turn`?{turn:e.turn.turn}:{}}function vx(e){return e.kind===`turn`||e.kind===`step`?e.turn.status:void 0}function yx(e,t,n){return n||e===void 0||vx(e.location)!==vx(t.location)?!0:e.kind===`turn-process`&&t.kind===`turn-process`?e.data!==t.data:e.kind===`assistant-step`&&t.kind===`assistant-step`&&e.data.step!==t.data.step}function bx(e){let t=/* @__PURE__ */ new Map;for(let n of e){let e=n;e.kind===`turn-process`&&t.set(e.data.turn,{...t.get(e.data.turn),control:e})}for(let n of e){let e=n,r=e.location;if(r.kind!==`turn`&&r.kind!==`step`)continue;let i=t.get(r.turn.turn)??{},a=i.control?.data.controlAnchorSeq;(e.kind===`user`||e.kind===`turn-trigger`||e.kind===`steering`)&&a!==void 0&&(a===r.turn.start?.seq||e.anchorSeq<a)?t.set(r.turn.turn,{...i,openingInputAnchor:Math.max(i.openingInputAnchor??e.anchorSeq,e.anchorSeq)}):cg.has(e.kind)||t.set(r.turn.turn,{...i,earliestProcessAnchor:Math.min(i.earliestProcessAnchor??e.anchorSeq,e.anchorSeq)})}return t}function xx(e,t){let n=e,r=n.location;if(r.kind!==`turn`&&r.kind!==`step`)return{anchor:n.anchorSeq,rank:0,originalAnchor:n.anchorSeq};let i=t.get(r.turn.turn);if(i===void 0)return{anchor:n.anchorSeq,rank:0,originalAnchor:n.anchorSeq};let a=i.openingInputAnchor;return a!==void 0&&n.anchorSeq<a&&!cg.has(n.kind)?{anchor:a,rank:2,originalAnchor:n.anchorSeq}:i.control!==void 0&&n.key===i.control.key?a===void 0?{anchor:i.earliestProcessAnchor??n.anchorSeq,rank:-1,originalAnchor:n.anchorSeq}:{anchor:a,rank:1,originalAnchor:n.anchorSeq}:{anchor:n.anchorSeq,rank:0,originalAnchor:n.anchorSeq}}function Sx(e){let t=e.filter(e=>Jb(e)),n=bx(t);return t.sort((e,t)=>{let r=xx(e,n),i=xx(t,n);return r.anchor-i.anchor||r.rank-i.rank||r.originalAnchor-i.originalAnchor||e.key.localeCompare(t.key)})}function Cx(e){let t=e;return t.kind===`user`||t.kind===`steering`?t.data.seq:void 0}function wx(e){let t=e;if(t.kind===`context`)return{messageSeq:t.data.seq-1,labels:wb(t.data.source)}}function Tx(e,t){let n=e;if(n.kind!==`user`&&n.kind!==`steering`)return e;let r=n.data.referenceLabels??ix,i=Object.hasOwn(n.data,`referenceLabels`);if(cx(r,t)&&i===t.length>0)return e;let a={...n.data};return t.length===0?delete a.referenceLabels:a.referenceLabels=t,{...n,data:a}}var Ex=class{messagesBySeq=/* @__PURE__ */ new Map;labelsByMessageSeq=/* @__PURE__ */ new Map;replace(e){this.messagesBySeq.clear(),this.labelsByMessageSeq.clear();for(let t of e){let e=Cx(t);e!==void 0&&this.messagesBySeq.set(e,t.key);let n=wx(t);n!==void 0&&n.labels.length>0&&this.labelsByMessageSeq.set(n.messageSeq,n.labels)}return e.map(e=>{let t=Cx(e);return t===void 0?e:Tx(e,this.labelsByMessageSeq.get(t)??ix)})}apply(e,t){let n=new Map(e.map(e=>[e.key,e])),r=/* @__PURE__ */ new Set;for(let t of e){let e=Cx(t);e!==void 0&&(this.messagesBySeq.set(e,t.key),r.add(e));let n=wx(t);if(n===void 0)continue;let i=this.labelsByMessageSeq.get(n.messageSeq);n.labels.length===0?this.labelsByMessageSeq.delete(n.messageSeq):this.labelsByMessageSeq.set(n.messageSeq,i!==void 0&&cx(i,n.labels)?i:n.labels),r.add(n.messageSeq)}for(let e of r){let r=this.messagesBySeq.get(e);if(r===void 0)continue;let i=n.get(r)??t.get(r);i!==void 0&&n.set(r,Tx(i,this.labelsByMessageSeq.get(e)??ix))}return[...n.values()]}};function Dx(e,t){let n=e;if(n.kind!==`user`&&n.kind!==`steering`)return e;let r=n.data.skillNames??ix,i=Object.hasOwn(n.data,`skillNames`);if(cx(r,t)&&i===t.length>0)return e;let a={...n.data};return t.length===0?delete a.skillNames:a.skillNames=t,{...n,data:a}}function Ox(e){let t=e;if(t.kind===`user`||t.kind===`steering`)return{key:e.key,seq:e.anchorSeq,kind:`message`,name:null};if(t.kind===`context`){let n=Tb(t.data.source);return n===null?null:{key:e.key,seq:e.anchorSeq,kind:`skill`,name:n}}return{key:e.key,seq:e.anchorSeq,kind:`boundary`,name:null}}function kx(e,t){return e.seq===t.seq&&e.kind===t.kind&&e.name===t.name}var Ax=class{entries=/* @__PURE__ */ new Map;sorted=[];replace(e){this.entries.clear(),this.sorted=[];for(let t of e){let e=Ox(t);e!==null&&(this.entries.set(e.key,e),this.sorted.push(e))}this.sorted.sort((e,t)=>e.seq-t.seq);let t=/* @__PURE__ */ new Map;for(let e=0;e<this.sorted.length;e++){if(this.sorted[e]?.kind===`boundary`)continue;let n=this.runEnd(e);this.assignRun(e,n,t),e=n}return e.map(e=>Dx(e,t.get(e.key)??ix))}apply(e,t){let n=[];for(let t of e){let e=Ox(t),r=this.entries.get(t.key);if(r!==void 0){if(e!==null&&kx(r,e)){e.kind===`message`&&n.push(e.seq);continue}this.remove(r),n.push(r.seq)}e!==null&&(this.insert(e),n.push(e.seq))}if(n.length===0)return e;let r=/* @__PURE__ */ new Map;for(let e of n)this.collectAround(e,r);let i=new Map(e.map(e=>[e.key,e]));for(let[e,n]of r){let r=i.get(e)??t.get(e);if(r===void 0)continue;let a=Dx(r,n);(a!==r||i.has(e))&&i.set(e,a)}return[...i.values()]}insert(e){this.sorted.splice(this.lowerBound(e.seq),0,e),this.entries.set(e.key,e)}remove(e){this.sorted.splice(this.sorted.indexOf(e),1),this.entries.delete(e.key)}lowerBound(e){let t=0,n=this.sorted.length;for(;t<n;){let r=t+n>>>1;(this.sorted[r]?.seq??1/0)<e?t=r+1:n=r}return t}runEnd(e){let t=e;for(;t+1<this.sorted.length&&this.sorted[t+1]?.kind!==`boundary`;)t++;return t}runStart(e){let t=e;for(;t-1>=0&&this.sorted[t-1]?.kind!==`boundary`;)t--;return t}assignRun(e,t,n){let r=[];for(let n=e;n<=t;n++){let e=this.sorted[n];e?.kind===`skill`&&e.name!==null&&!r.includes(e.name)&&r.push(e.name)}for(let i=e;i<=t;i++){let e=this.sorted[i];e?.kind===`message`&&n.set(e.key,r)}}collectAround(e,t){let n=this.lowerBound(e),r=this.sorted[n];if(r!==void 0&&r.seq===e&&r.kind!==`boundary`){this.assignRun(this.runStart(n),this.runEnd(n),t);return}n-1>=0&&this.sorted[n-1]?.kind!==`boundary`&&this.assignRun(this.runStart(n-1),n-1,t);let i=r!==void 0&&r.seq===e?n+1:n;i<this.sorted.length&&this.sorted[i]?.kind!==`boundary`&&this.assignRun(i,this.runEnd(i),t)}};let jx={anchorSeq:0,nodes:sx,partial:null,running:null};function Mx(e){let t=e;if(e.visibility!==`visible`&&t.kind!==`assistant-step`)return jx;switch(t.kind){case`user`:case`steering`:case`context`:case`command`:case`compaction`:case`turn-error`:case`turn-max-tokens`:case`unknown`:return{anchorSeq:t.anchorSeq,nodes:[t.data],partial:null,running:null};case`assistant-step`:{let n=t.data;return n.status===`running`?e.visibility===`visible`?{anchorSeq:t.anchorSeq,nodes:sx,partial:{turn:n.turn,step:n.step,blocks:n.blocks},running:null}:jx:{anchorSeq:t.anchorSeq,nodes:n.finalNode===void 0?sx:[n.finalNode],partial:null,running:null}}case`tool-call`:{let e=t.data.root;return qb(e)?{anchorSeq:t.anchorSeq,nodes:sx,partial:null,running:e}:{anchorSeq:t.anchorSeq,nodes:[e],partial:null,running:null}}case`manual-compaction`:{let e=t.data;return{anchorSeq:t.anchorSeq,nodes:e.compaction===null?[e.command]:[e.command,e.compaction],partial:null,running:null}}case`model-retry`:return{anchorSeq:t.anchorSeq,nodes:t.data.attempts,partial:null,running:null};case`turn-tail`:case`system-prompt`:return jx;default:return jx}}function Nx(e,t){return e!==void 0&&e.anchorSeq===t.anchorSeq&&e.partial?.blocks===t.partial?.blocks&&e.partial?.turn===t.partial?.turn&&e.partial?.step===t.partial?.step&&e.running===t.running&&cx(e.nodes,t.nodes)}var Px=class{contributions=/* @__PURE__ */ new Map;finalizedContributions=/* @__PURE__ */ new Map;runningContributions=/* @__PURE__ */ new Map;partialContributions=/* @__PURE__ */ new Map;finalized=sx;runningCalls=sx;partial=null;timeline;turnTimings=/* @__PURE__ */ new Map;turnEnds=/* @__PURE__ */ new Map;replace(e,t){this.contributions.clear(),this.finalizedContributions.clear(),this.runningContributions.clear(),this.partialContributions.clear();for(let t of e){let e=Mx(t);this.contributions.set(t.key,e),this.indexContribution(t.key,e)}return this.rebuildFinalized(),this.rebuildRunning(),this.rebuildPartial(),this.updateTimeline(t),this.snapshot()}apply(e,t){let n=!1,r=!1,i=!1;for(let t of e){let e=Mx(t),a=this.contributions.get(t.key);Nx(a,e)||(n||=Ix(a,e),r||=Lx(a,e),i||=Rx(a,e),this.contributions.set(t.key,e),this.indexContribution(t.key,e))}return n&&this.rebuildFinalized(),r&&this.rebuildRunning(),i&&this.rebuildPartial(),this.updateTimeline(t),this.snapshot()}indexContribution(e,t){Fx(this.finalizedContributions,e,t,t.nodes.length>0),Fx(this.runningContributions,e,t,t.running!==null),Fx(this.partialContributions,e,t,t.partial!==null)}rebuildFinalized(){let e=[...this.finalizedContributions.values()].flatMap(e=>e.nodes).sort((e,t)=>e.seq-t.seq);cx(this.finalized,e)||(this.finalized=e)}rebuildRunning(){let e=[...this.runningContributions.values()].sort((e,t)=>e.anchorSeq-t.anchorSeq).flatMap(e=>e.running===null?[]:[e.running]);cx(this.runningCalls,e)||(this.runningCalls=e)}rebuildPartial(){let e=[...this.partialContributions.values()].sort((e,t)=>e.anchorSeq-t.anchorSeq).findLast(e=>e.partial!==null)?.partial??null;(this.partial?.blocks!==e?.blocks||this.partial?.turn!==e?.turn||this.partial?.step!==e?.step)&&(this.partial=e)}updateTimeline(e){if(this.timeline===e)return;this.timeline=e;let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map;for(let r of e.turns.values())r.start!==void 0&&t.set(r.turn,{startTime:r.start.time,...r.end===void 0?{}:{endTime:r.end.time}}),r.end!==void 0&&n.set(r.turn,r.end.seq);this.turnTimings=t,this.turnEnds=n}snapshot(){return{nodes:this.finalized,turnTimings:this.turnTimings,turnEnds:this.turnEnds,partial:this.partial,runningCalls:this.runningCalls}}};function Fx(e,t,n,r){r?e.set(t,n):e.delete(t)}function Ix(e,t){let n=e?.nodes??sx;return!cx(n,t.nodes)||(n.length>0||t.nodes.length>0)&&e?.anchorSeq!==t.anchorSeq}function Lx(e,t){return e?.running!==t.running||(e.running!==null||t.running!==null)&&e.anchorSeq!==t.anchorSeq}function Rx(e,t){return e?.partial?.blocks!==t.partial?.blocks||e?.partial?.turn!==t.partial?.turn||e?.partial?.step!==t.partial?.step||((e?.partial??null)!==null||t.partial!==null)&&e?.anchorSeq!==t.anchorSeq}var zx=class{store=new fx;locations=new px;navigation=new hx;legacy=new Px;referenceLabels=new Ex;skillNames=new Ax;order=ix;latestGroupInput;readGroupNode=e=>this.store.get(e);readGroupTurn=e=>this.locations.getTurn(e);readGroupPosition=e=>this.locations.getPosition(e);timeline=null;empty;constructor(){this.empty=this.snapshot({turnOrder:ax,turns:/* @__PURE__ */ new Map}),this.latestGroupInput={kind:`replace`,order:this.order,readNode:this.readGroupNode,readTurn:this.readGroupTurn,readPosition:this.readGroupPosition,timeline:this.empty.timeline}}replace(e){let t=this.skillNames.replace(this.referenceLabels.replace(e.nodes));return this.store.replace(t),this.order=Sx(t).map(e=>e.key),this.locations.rebuild(this.order,this.store),this.store.replaceProcesses(this.order,this.locations),this.navigation.rebuild(e.timeline,this.locations,this.store),this.timeline=e.timeline,this.latestGroupInput={kind:`replace`,order:this.order,readNode:this.readGroupNode,readTurn:this.readGroupTurn,readPosition:this.readGroupPosition,timeline:e.timeline},this.snapshot(e.timeline,this.legacy.replace(t,e.timeline))}apply(e){let t=this.skillNames.apply(this.referenceLabels.apply(e.upserts,this.store),this.store),n=/* @__PURE__ */ new Set,r=!1,i=[],a=[];for(let e of t){let t=this.store.get(e.key);t!==e&&a.push({previous:t,current:e});let o=t===void 0||t.kind!==e.kind||t.anchorSeq!==e.anchorSeq||t.visibility!==e.visibility||Vx(t.location)!==Vx(e.location);if(r||=o,o||i.push(e),yx(t,e,o)){let r=t===void 0?void 0:_x(t.location).turn,i=_x(e.location).turn;r!==void 0&&n.add(r),i!==void 0&&n.add(i)}}this.store.upsert(t);let o=ax;if(r){let e=Sx(this.store.values()).map(e=>e.key);this.order=cx(this.order,e)?this.order:e,o=this.locations.rebuild(this.order,this.store)}return this.locations.touch(i),this.store.updateProcesses(n,this.locations),r||e.timeline!==this.timeline?this.navigation.rebuild(e.timeline,this.locations,this.store):this.navigation.touch(Bx(i),this.locations,this.store),this.timeline=e.timeline,this.latestGroupInput={kind:`apply`,changes:a,order:this.order,readNode:this.readGroupNode,readTurn:this.readGroupTurn,readPosition:this.readGroupPosition,timeline:e.timeline,changedTurns:e.changedTurns??ax,changedTurnOrders:o},this.snapshot(e.timeline,this.legacy.apply(t,e.timeline))}groupInput(){return this.latestGroupInput}publish(){this.store.publish()}snapshot(e,t=this.legacy.replace(sx,e)){return{order:this.order,nodes:this.store,locations:this.locations,navigation:this.navigation,timeline:e,legacy:t}}};function Bx(e){let t=/* @__PURE__ */ new Set;for(let n of e){let e=_x(n.location).turn;e!==void 0&&t.add(e)}return t}function Vx(e){let t=_x(e);return`${e.kind}:${t.turn??``}:${t.step??``}`}let Hx={target:`chat`,create:()=>new zx,isActive:e=>e.order.some(t=>e.nodes.get(t)?.kind!==`command`)};function Ux(e){e.uiConversation.views.register(Hx)}let Wx=/* @__PURE__ */ new Set([`system/message`,`developer/message`,`user/message`,`assistant/message`,`tool/result`]);function Gx(e){return Wx.has(e.type)?e.surfaceOp!==void 0:!1}function Kx(e){return Gx(e)&&e.surfaceOp===`append`}function qx(e){return Gx(e)&&e.surfaceOp!==`append`}function Jx(e){if(e.event.type!==`command/run`)throw Error(`command start requires command/run`);let t=e.event.data;return{kind:`command`,seq:e.event.seq,time:e.event.time,commandId:t.commandId,name:t.name,args:t.args??null,outcome:null}}function Yx(e,t){if(e.event.type!==`command/done`)throw Error(`command update requires command/done`);let n=e.event.data,r=n.kind===`success`&&n.sourceEventSeq!==void 0&&Number.isSafeInteger(n.sourceEventSeq)&&n.sourceEventSeq>=0?n.sourceEventSeq:void 0;return{kind:`command`,seq:t?.seq??e.event.seq,time:t?.time??e.event.time,commandId:n.commandId,name:t?.name??null,args:t?.args??null,outcome:{kind:n.kind,...n.text===void 0?{}:{text:n.text},...r===void 0?{}:{sourceEventSeq:r}}}}function Xx(e){if(e.type!==`user/message`||!qx(e))return;let t=e.data.source;if(t.kind===`compact-checkpoint`&&typeof t.compactionId==`string`)return{compactionId:t.compactionId,...t.sourceCommandId===void 0?{}:{sourceCommandId:t.sourceCommandId}}}function Zx(e,t){let n=null,r=null,i=null;if(e?.event.type===`compaction/summary`){let t=e.event.data;if(Array.isArray(t.summary)){let e=t.summary.map(e=>e.type===`text`?e.text:``).join(``);n=e.trim()===``?null:e}r=Array.isArray(t.shadowedSeqs)&&t.shadowedSeqs.every(e=>Number.isSafeInteger(e)&&e>=0)?t.shadowedSeqs.length:null,i=Number.isSafeInteger(t.shadowedTokenCount)&&t.shadowedTokenCount>=0?t.shadowedTokenCount:null}return{kind:`compaction`,seq:t.event.seq,time:t.event.time,summary:n,summaryEventSeq:e?.event.seq??null,shadowedItemCount:r,shadowedTokenCount:i}}function Qx(e){let t=e.matches.find(e=>e.event.type===`command/done`),n=e.matches.find(e=>Xx(e.event)!==void 0),r=e.matches.find(e=>e.event.type===`compaction/summary`);if(n===void 0)return t===void 0?void 0:{command:Yx(t)};let i=Xx(n.event);return i?.sourceCommandId===void 0?t===void 0?void 0:{command:Yx(t)}:{command:t===void 0?{kind:`command`,seq:n.event.seq,time:n.event.time,commandId:i.sourceCommandId,name:`compact`,args:null,outcome:null}:{...Yx(t),name:`compact`},checkpoint:n,...r===void 0?{}:{summary:r}}}function $x(e,t){return t.event.type===`compaction/summary`?{...e,summary:t}:Xx(t.event)===void 0?e:{...e,checkpoint:t}}let eS={kind:`command`,target:`chat`,match:e=>{if(e.type===`command/run`)return{id:String(e.data.commandId),role:`start`};if(e.type===`command/done`)return{id:String(e.data.commandId),role:`update`};let t=Xx(e);return t?.sourceCommandId===void 0?(e.type===`compaction/start`||e.type===`compaction/summary`||e.type===`compaction/end`)&&e.data.sourceCommandId!==void 0?{id:String(e.data.sourceCommandId),role:`update`}:null:{id:String(t.sourceCommandId),role:`update`}},start:(e,t)=>({command:Jx(t)}),update:(e,t)=>t.event.type===`command/done`?{...e.state,command:Yx(t,e.state.command)}:$x(e.state,t),buildViewNode:e=>{let t=e.state??Qx(e);if(t===void 0)return null;if(t.command.name!==`compact`)return gb(e,`command`,t.command.seq,t.command);let n=t.checkpoint===void 0?null:Zx(t.summary,t.checkpoint),r={command:t.command,compaction:n};return gb(e,`manual-compaction`,n?.seq??t.command.seq,r)}};function tS(e){e.uiConversation.events.register(eS)}function nS(e){let t=e.matches.find(e=>e.event.type===`compaction/summary`),n=e.matches.find(e=>Xx(e.event)!==void 0);return{...t===void 0?{}:{summary:t},...n===void 0?{}:{checkpoint:n}}}let rS={kind:`compaction`,target:`chat`,match:e=>{let t=Xx(e);if(t!==void 0&&t.sourceCommandId===void 0)return{id:t.compactionId,role:`update`};if(e.type===`compaction/start`||e.type===`compaction/summary`||e.type===`compaction/end`){if(e.data.sourceCommandId!==void 0)return null;let t=e.data.compactionId;return typeof t!=`string`||t===``?null:{id:t,role:e.type===`compaction/start`?`start`:`update`}}return null},start:()=>({}),update:(e,t)=>$x(e.state,t),buildViewNode:e=>{let t=e.state??nS(e);if(t.checkpoint===void 0)return null;let n=Zx(t.summary,t.checkpoint);return gb(e,`compaction`,n.seq,n)}};function iS(e){e.uiConversation.events.register(rS)}let aS={kind:`unknown-surface`,target:`chat`,match:e=>e.type!==`assistant/live-chunk`&&Kx(e)?{id:String(e.seq),role:`start`}:null,start:(e,t)=>({kind:`unknown`,seq:t.event.seq,time:t.event.time,type:t.event.type,data:t.event.data}),update:e=>e.state,buildViewNode:e=>e.state===void 0?null:gb(e,`unknown`,e.state.seq,e.state)};function oS(e){e.uiConversation.events.registerFallback(aS)}let sS={kind:`snapshot`,ids:[]},cS=/* @__PURE__ */ new Set;function lS(e){let t=[],n=e;for(;n.kind===`splice`;)t.push(n),n=n.previous;let r=[...n.ids];for(let e of t.reverse())r.splice(e.start,e.removedCount,...e.inserted);return r}function uS(e,t){let n;for(let{id:r}of t)e.has(r)&&(n??=new Set(e),n.delete(r));return n??e}function dS(e,t,n){let r=e?.state.pending??sS,i=t.inserted,a=t.removedCount??0;if(a>0&&t.outcome!==`canceled`){let e=lS(r),o=e.splice(t.start,a,...i);return{pending:{kind:`snapshot`,ids:e},currentClaimed:new Set(o.map(e=>e.id)),claimSeq:n,claimedHuman:o.some(e=>e.source.kind===`user`)}}let o=uS(e?.state.currentClaimed??cS,i);return{pending:{kind:`splice`,previous:r,start:t.start,removedCount:a,inserted:i},currentClaimed:o,claimSeq:e?.state.claimSeq??-1,claimedHuman:e?.state.claimedHuman??!1}}function fS(e){let t=`inbox-${e}`;return{kind:t,match:t=>t.type===`agent/inbox/spliced`&&t.data.target===e?{id:String(t.seq),role:`start`}:null,start:(e,n,r)=>{if(n.event.type!==`agent/inbox/spliced`)throw Error(`inbox start requires agent/inbox/spliced`);return dS(r.previous(t),n.event.data,n.event.seq)},update:e=>e.state,publication:()=>`none`}}let pS=fS(`next-step`),mS=fS(`next-turn`);function hS(e){e.uiConversation.events.register(pS),e.uiConversation.events.register(mS)}function gS(e){return e.type!==`user/message`||!qx(e)?!1:e.data.source.kind===`compact-checkpoint`}function _S(e,t){return{kind:`context`,seq:e.seq,time:e.time,content:t.content,source:t.source,producer:Cb(t.source),form:Sb(t.source)}}let vS={kind:`input-message`,target:`chat`,match:e=>e.type===`user/message`&&Kx(e)&&!gS(e)?{id:String(e.data.id),role:`start`}:null,start:(e,t,n)=>{let r=t.event;if(r.type!==`user/message`)throw Error(`input-message start requires user/message`);if(r.data.source.kind!==`user`){let e=n.previous(`inbox-next-turn`)?.state,i=n.previous(`inbox-next-step`)?.state,a=t.location,o=a.kind===`step`?a.turn.start?.seq:void 0,s=a.kind===`step`&&a.step.step===1&&o!==void 0&&(i?.claimSeq??-1)>o&&(e?.claimSeq??-1)<o&&i?.claimedHuman===!1&&i.currentClaimed.has(String(r.data.id));return{..._S(r,r.data),waking:e?.currentClaimed.has(String(r.data.id))===!0||s}}return n.previous(`inbox-next-step`)?.state.currentClaimed.has(String(r.data.id))===!0?{kind:`steering`,messageId:r.data.id,seq:r.seq,time:r.time,content:r.data.content,source:r.data.source}:{kind:`user`,seq:r.seq,time:r.time,content:r.data.content,source:r.data.source}},update:e=>e.state,buildViewNode:e=>{if(e.state===void 0)return null;let t=e.state.kind===`context`&&e.start?.event.type===`user/message`&&e.state.waking===!0,n=e.state.kind===`user`||e.state.kind===`steering`?{...e.state,...yS(e.state)}:e.state;return gb(e,t?`turn-trigger`:e.state.kind,e.state.seq,n)}};function yS(e){let t=hm(e.content.flatMap(e=>e.type===`text`?[e.text]:[]).join(`
131
- `));return t.length===0?{}:{responseAnnotations:t}}let bS={...vS,kind:`developer-message`,match:e=>e.type===`developer/message`?{id:String(e.data.message.id),role:`start`}:null,start:(e,t)=>{let n=t.event;if(n.type!==`developer/message`)throw Error(`developer-message start requires developer/message`);return _S(n,n.data.message)}};function xS(e){e.uiConversation.events.register(vS),e.uiConversation.events.register(bS)}function SS(e,t,n){return e.location.kind!==`step`||t===void 0&&!n||t?.turn===e.location.turn.turn&&t.step===e.location.step.step?e.event.seq:e.location.step.step===1?e.location.turn.start?.seq??e.location.step.start?.seq??e.event.seq:e.location.step.start?.seq??e.event.seq}function CS(e,t,n,r){let i=e.current.get(`chat`);return i?.kind===`system-prompt`?i.anchorSeq:SS(t,n,r)}function wS(e){return{kind:`system-message`,target:`chat`,match:e=>e.type===`system/message`||`surfaceOp`in e&&e.surfaceOp!==`append`?{id:String(e.seq),role:`start`}:null,start:(t,n,r)=>{if(n.event.type===`assistant/live-chunk`)throw Error(`system-message requires a durable event`);return e(r.previous(`system-message`)?.state,n.event)},update:e=>e.state,buildViewNode:e=>{let t=e.state?.introduced;return t===void 0||t.text===``||e.start?.event.type!==`system/message`||e.start.event.surfaceOp!==`append`?null:gb(e,`system-prompt`,t.update?t.seq:SS(e.start,void 0,!0),{text:t.text,...t.update?{update:!0}:{}})}}}function TS(e){return{kind:`request-prompt`,target:`chat`,match:e=>e.type===`request/header`?{id:String(e.seq),role:`start`}:null,start:(t,n,r)=>{if(n.event.type!==`request/header`)throw Error(`request-prompt start requires request/header`);let i=r.previous(`request-prompt`)?.state,a=r.previous(`system-message`),o=a?.state.effective,s=n.location.kind===`step`?{turn:n.location.turn.turn,step:n.location.step.step}:{},c=e(i?.prompt,n.event,o),l=c.change?.kind,u=a?.matches[0]?.event,d=o!==void 0&&u?.type===`system/message`&&u.surfaceOp===`append`&&(o.update||i===void 0)&&o.turn===s.turn&&o.step===s.step;return{anchorSeq:CS(t,n,i,n.event.data.reason===`initial`),showsPrompt:!d&&(i===void 0||n.event.data.reason!==`change`||n.event.data.startsSeries===!0||l===`system`||l===`system-and-tools`),...s,...c}},update:e=>e.state,buildViewNode:e=>{let t=e.state;if(t===void 0)return null;let n=e.current.get(`chat`),r=t.showsPrompt&&t.prompt.system!==``;return!r&&n?.kind!==`system-prompt`?null:gb(e,`system-prompt`,t.anchorSeq,{text:t.prompt.system},{visibility:r?`visible`:`hidden`})}}}function ES(e){e.uiConversation.events.register(wS((t,n)=>e.uiConversation.inspectSystemPrompt(t,n))),e.uiConversation.events.register(TS((t,n,r)=>e.uiConversation.inspectRequestPrompt(t,n,r)))}function DS(e){if(e.event.type===`llm/retry`)return{kind:`model-retry`,seq:e.event.seq,time:e.event.time,retryState:`scheduled`,...e.event.data}}function OS(e){return e.kind===`step`&&e.step.status===`closed`||(e.kind===`step`||e.kind===`turn`)&&e.turn.status===`closed`}let kS={kind:`model-retry`,target:`chat`,match:e=>{if(e.type===`llm/retry`){let t=e.data.retryId;return typeof t!=`string`||t===``?null:{id:t,role:e.data.retry===1?`start`:`update`}}if(e.type===`llm/retry-started`){let t=e.data.retryId;return typeof t==`string`&&t!==``?{id:t,role:`update`}:null}return null},start:(e,t)=>{let n=DS(t);if(n===void 0)throw Error(`model-retry start requires a valid llm/retry event`);return{turn:n.turn,step:n.step,attempts:[n]}},update:(e,t)=>{if(t.event.type===`llm/retry`){let n=DS(t);return n===void 0?e.state:{...e.state,attempts:[...e.state.attempts,n]}}if(t.event.type!==`llm/retry-started`)return e.state;let n=t.event.data.retry;return{...e.state,attempts:e.state.attempts.map(e=>e.retry===n?{...e,retryState:`started`}:e)}},buildViewNode:e=>{if(e.state===void 0||e.state.attempts.length===0)return null;let t=e.start?.location??e.matches[0]?.location??{kind:`unresolved`},n=e.state.attempts,r=n.map((e,r)=>r===n.length-1&&e.retryState===`scheduled`&&OS(t)?{...e,retryState:`cancelled`}:e),i=r.at(-1);if(i===void 0)return null;let a={attempts:r,current:i};return gb(e,`model-retry`,r[0]?.seq??i.seq,a)}};function AS(e){e.uiConversation.events.register(kS)}let jS=/* @__PURE__ */ new WeakMap;function MS(e){return JSON.stringify(e)}function NS(e,t){if(e.event.type!==`tool/call`)throw Error(`tool-call start requires tool/call`);return{phase:`start`,callId:String(e.event.data.callId),name:e.event.data.name,argsRaw:e.event.data.arguments,args:t===void 0?Hg.fromText(e.event.data.arguments):t.args.settle(e.event.data.arguments),turn:e.event.data.turn,step:e.event.data.step,time:e.event.time,subCalls:[]}}function PS(e,t){let n=t.event;if(n.type!==`assistant/live-chunk`)return e;let r=n.data.chunk,i=e.root;if(r.type===`block-end`&&r.block.type===`tool-call`)return i===void 0||`kind`in i||i.phase!==`preparing`?e:{...e,root:{...i,name:r.block.name,args:i.args.settle(r.block.arguments)}};if(r.type!==`tool-call-delta`)return e;if(i===void 0){if(!r.name)return e;let t=new Hg;return t.append(r.argumentsDelta),{...e,root:{phase:`preparing`,callId:String(r.id),name:r.name,turn:n.data.turn,step:n.data.step,time:n.time,subCalls:[],args:t}}}return`kind`in i||i.phase!==`preparing`||i.args.isSealed||i.args.append(r.argumentsDelta),e}function FS(e,t){let n=e.args.refresh();return!n&&t!==void 0&&!(`kind`in t)&&t.phase===`preparing`&&t.name===e.name&&t.args===e.args?t:n?{...e}:e}function IS(e,t){if(e.event.type!==`tool/result`)return;let n=e.event.data.message;return{kind:`tool-result`,seq:e.event.seq,time:e.event.time,callId:String(n.source.callId),name:t?.name??``,args:t?.args??Hg.EMPTY,call:t===void 0?null:{name:t.name,argsRaw:t.argsRaw},callTime:t?.time??null,content:n.content,isError:n.isError===!0,...e.event.data.error===void 0?{}:{error:e.event.data.error},meta:e.event.data.meta,subCalls:[]}}function LS(e,t){return{phase:`start`,callId:t.subCallId,parentCallId:t.parentCallId,name:t.name,argsRaw:MS(t.arguments),args:Hg.fromObject(t.arguments),turn:zS(e),step:BS(e),time:e.event.time,subCalls:[]}}function RS(e,t,n){return{kind:`tool-result`,seq:e.event.seq,time:e.event.time,callId:t.subCallId,parentCallId:t.parentCallId,name:t.name,args:n!==void 0&&!(`kind`in n)?n.args:Hg.fromObject(t.arguments),call:{name:t.name,argsRaw:MS(t.arguments)},callTime:n?.time??null,content:t.content??[],isError:t.isError===!0,...t.error===void 0?{}:{error:t.error},subCalls:[]}}function zS(e){return e.location.kind===`step`||e.location.kind===`turn`?e.location.turn.turn:0}function BS(e){return e.location.kind===`step`?e.location.step.step:0}function VS(e,t,n){if(t===n||e.parents.has(n))return!1;let r=t,i=0,a=/* @__PURE__ */ new Set;for(;r!==void 0;){if(r===n||a.has(r))return!1;a.add(r),i++,r=e.parents.get(r)}let o=[{callId:n,depth:1}],s=/* @__PURE__ */ new Set,c=0;for(let t of o){if(s.has(t.callId))return!1;s.add(t.callId),c=Math.max(c,t.depth);for(let n of e.children.get(t.callId)??[])o.push({callId:n.callId,depth:t.depth+1})}return i+c<=256}function HS(e,t){let n=t.event;if(n.type!==`tool/ptc-dispatch-start`&&n.type!==`tool/ptc-dispatch`)return e;let r=n.data,i=String(r.parentCallId),a=String(r.subCallId),o=e.children.get(i)??[],s=o.findIndex(e=>e.callId===a);if(n.type===`tool/ptc-dispatch-start`){if(s>=0||!VS(e,i,a))return e;let n=new Map(e.children);n.set(i,[...o,LS(t,r)]);let c=new Map(e.parents);return c.set(a,i),{...e,children:n,parents:c}}if(s<0&&!VS(e,i,a))return e;let c=RS(t,r,s<0?void 0:o[s]),l=new Map(e.children);l.set(i,s<0?[...o,c]:o.map((e,t)=>t===s?c:e));let u=new Map(e.parents);return s<0&&u.set(a,i),{...e,children:l,parents:u}}function US(e,t,n,r=/* @__PURE__ */ new Set,i=1){if(!(`kind`in e)&&e.phase===`preparing`)return e;if(r.has(e.callId)||i>256)return{...e,subCalls:[]};let a=new Set(r);a.add(e.callId);let o=(t.children.get(e.callId)??e.subCalls).map(e=>US(e,t,n,a,i+1)),s=`kind`in e?void 0:n?.seq,c=`kind`in e?void 0:n?.time,l=jS.get(e);if(l!==void 0&&l.interruptionSeq===s&&l.interruptionTime===c&&WS(l.children,o))return l.value;let u=`kind`in e||n===void 0?WS(e.subCalls,o)?e:{...e,subCalls:o}:{kind:`tool-result`,seq:n.seq+mb.interruptedFollowup,time:n.time,callId:e.callId,...e.parentCallId===void 0?{}:{parentCallId:e.parentCallId},name:e.name,args:e.args,call:{name:e.name,argsRaw:e.argsRaw},callTime:e.time,content:[],isError:!0,error:{name:`Interrupted`,code:`interrupted`},subCalls:o};return jS.set(e,{children:o,interruptionSeq:s,interruptionTime:c,value:u}),u}function WS(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function GS(e){let t=e.start?.location;if(t?.kind===`step`&&t.step.status===`closed`)return t.step.end;if((t?.kind===`step`||t?.kind===`turn`)&&t.turn.status===`closed`)return t.turn.end}function KS(e){let t=e.matches.find(e=>e.event.type===`tool/result`),n=t===void 0?void 0:IS(t);if(n===void 0)return;let r={root:n,children:/* @__PURE__ */ new Map,parents:/* @__PURE__ */ new Map};for(let t of e.matches)r=HS(r,t);return r}let qS={kind:`tool-call`,target:`chat`,match:e=>{if(e.type===`assistant/live-chunk`){let t=e.data.chunk;return t.type===`block-end`&&t.block.type===`tool-call`?{id:String(t.block.id),role:`start`}:t.type===`tool-call-delta`?{id:String(t.id),role:`start`}:null}if(e.type===`tool/call`)return{id:String(e.data.callId),role:`start`};if(e.type===`tool/result`&&Kx(e))return{id:String(e.data.message.source.callId),role:`update`};if(e.type===`tool/ptc-dispatch-start`||e.type===`tool/ptc-dispatch`){let t=e.data.rootCallId;return typeof t==`string`&&t!==``?{id:t,role:`update`}:null}return null},start:(e,t)=>{let n={root:void 0,children:/* @__PURE__ */ new Map,parents:/* @__PURE__ */ new Map};return t.event.type===`tool/call`?{...n,root:NS(t)}:PS(n,t)},update:(e,t)=>{if(t.event.type===`assistant/live-chunk`)return PS(e.state,t);if(t.event.type===`tool/call`)return{...e.state,root:NS(t,e.state.root)};if(t.event.type===`tool/result`){let n=e.state.root,r=IS(t,n!==void 0&&!(`kind`in n)&&n.phase===`start`?n:void 0);return r===void 0?e.state:{...e.state,root:r}}return HS(e.state,t)},publication:e=>e.event.type===`assistant/live-chunk`?`animation-frame`:`immediate`,buildViewNode:e=>{let t=e.current.get(`chat`),n=e.state??KS(e);if(n?.root===void 0)return t==null?null:t.visibility===`hidden`?t:{...t,visibility:`hidden`};let r=GS(e),i=US(!(`kind`in n.root)&&n.root.phase===`preparing`?FS(n.root,t?.data.root):n.root,n,r),a=e.start?.event.seq??(`kind`in n.root?n.root.seq:e.matches[0]?.event.seq??0),o=!(`kind`in i)&&i.phase===`preparing`&&r!==void 0?`hidden`:`visible`,s=hb(e),c=dg(i.name)&&s.kind===`step`?{kind:`turn`,turn:s.turn}:s,l=t?.data.root===i?t.data:{root:i};return t?.data===l&&t.anchorSeq===a&&t.visibility===o&&t.location===c?t:gb(e,`tool-call`,a,l,{visibility:o,location:c})}};function JS(e){let t=qS.match.bind(qS);e.uiConversation.events.register({...qS,match:{"assistant/live-chunk":t,"tool/call":t,"tool/result":t,"tool/ptc-dispatch-start":t,"tool/ptc-dispatch":t}})}function YS(e){let t=e.start?.location??e.matches[0]?.location;return t?.kind!==`turn`&&t?.kind!==`step`?0:t.turn.steps.at(-1)?.step??0}function XS(e){if(e.event.type!==`turn/end`)return;let t=e.event.data.reason,n=t.kind===`error`?t.error:t.kind===`aborted`&&t.reason.kind===`hook`&&t.reason.reason===`deepseek-account/signed-out`?{message:`Stopped because you signed out of DeepSeek.`,code:`ACCOUNT_SIGNED_OUT`}:void 0;if(n===void 0)return;let r=kb(n);return{seq:e.event.seq,time:e.event.time,message:r.message,...r.code===void 0?{}:{code:r.code}}}function ZS(e){let t=e.matches.find(e=>XS(e)!==void 0);if(t?.event.type!==`turn/end`)return;let n=XS(t);if(n!==void 0)return{turn:t.event.data.turn,failure:n}}let QS={kind:`turn-error`,target:`chat`,match:e=>e.type===`turn/start`?{id:String(e.data.turn),role:`start`}:e.type===`turn/end`&&(e.data.reason.kind===`error`||e.data.reason.kind===`aborted`&&e.data.reason.reason.kind===`hook`&&e.data.reason.reason.reason===`deepseek-account/signed-out`)?{id:String(e.data.turn),role:`update`}:null,start:(e,t)=>{if(t.event.type!==`turn/start`)throw Error(`turn-error start requires turn/start`);return{turn:t.event.data.turn}},update:(e,t)=>{let n=XS(t);return n===void 0?e.state:{...e.state,failure:n}},buildViewNode:e=>{let t=e.state??ZS(e);if(t?.failure===void 0)return null;let n=t.failure,r={kind:`turn-error`,seq:n.seq,time:n.time,turn:t.turn,step:YS(e),message:n.message,...n.code===void 0?{}:{code:n.code}};return gb(e,`turn-error`,r.seq,r)}};function $S(e){e.uiConversation.events.register(QS)}function eC(e){let t=e.start?.location??e.matches[0]?.location;return t?.kind!==`turn`&&t?.kind!==`step`?0:t.turn.steps.at(-1)?.step??0}function tC(e,t){let n=e.start?.location??e.matches[0]?.location;if(n?.kind!==`turn`&&n?.kind!==`step`)return t;let r=n.turn.data.get(`turn-tail`)?.closing;return r==null?t:r.finalNode.seq+mb.maxTokensNotice}function nC(e){if(e.event.type===`turn/end`&&e.event.data.reason.kind===`max-tokens`)return{turn:e.event.data.turn,seq:e.event.seq,time:e.event.time}}let rC={kind:`turn-max-tokens`,target:`chat`,match:e=>e.type===`turn/end`&&e.data.reason.kind===`max-tokens`?{id:String(e.data.turn),role:`start`}:null,start:(e,t)=>{let n=nC(t);if(n===void 0)throw Error(`turn-max-tokens start requires a max-tokens turn/end`);return n},update:e=>e.state,buildViewNode:e=>{let t=e.state;if(t===void 0)return null;let n={kind:`turn-max-tokens`,seq:t.seq,time:t.time,turn:t.turn,step:eC(e)};return gb(e,`turn-max-tokens`,tC(e,t.seq),n)}};function iC(e){e.uiConversation.events.register(rC)}function aC(e){let t=e.data;return typeof t.turn==`number`?t.turn:void 0}function oC(e){if(e.type===`text-delta`||e.type===`reasoning-delta`)return e.text.trim()!==``;if(e.type===`block-start`)return e.blockType!==`text`&&e.blockType!==`reasoning`&&e.blockType!==`tool-call`;if(e.type!==`block-end`)return!1;let t=e.block;return t.type===`tool-call`?!1:t.type===`text`||t.type===`reasoning`?t.text.trim()!==``:!0}function sC(e){return e.type===`assistant/live-chunk`?oC(e.data.chunk):e.type!==`assistant/attempt`&&e.type===`assistant/message`&&e.surfaceOp===`append`&&Eb(e.data.message.content).some(e=>e.kind===`tool-call`?!1:e.kind===`text`||e.kind===`reasoning`?e.text.trim()!==``:!0)}function cC(e,t){return e.type===`tool/call`?dg(e.data.name):e.type===`tool/result`&&t.has(String(e.data.message.source.callId))}function lC(e,t){if(sC(e))return e.type!==`assistant/live-chunk`&&e.type!==`assistant/message`&&e.type!==`assistant/attempt`?void 0:{kind:`assistant`,seq:e.seq,step:e.data.step};if(!cC(e,t)&&(e.type===`tool/call`||e.type===`tool/result`&&e.surfaceOp===`append`||e.type===`llm/retry`))return{kind:`other`,seq:e.seq}}function uC(e){let t=e.start?.location??e.matches.at(-1)?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn:void 0}function dC(e){let t=e.matches.map(e=>aC(e.event)).find(e=>e!==void 0);if(t===void 0)return;let n={turn:t,assistantStartByStep:/* @__PURE__ */ new Map,messageCountByStep:/* @__PURE__ */ new Map,messageCount:0,toolCallCount:0,subagentCount:0,contextCompactionCalls:/* @__PURE__ */ new Set};for(let t of e.matches)n=hC(n,t.event);return n}function fC(e){return e?.finalNode!==void 0}function pC(e){let t=e.end?.data.finalAssistantStep;if(t===null)return null;let n=(t===void 0?e.steps.at(-1):e.steps.find(e=>e.step===t))?.data.get(`assistant-step`);return!fC(n)||n.finalNode.interrupted===!0||!tb(n.blocks)||t===void 0&&n.blocks.some(e=>e.kind===`tool-call`)?null:n}function mC(e,t){let n=e.controlAnchorSeq??t.start?.seq;if(n===void 0)return null;let r=pC(t),i={messageCount:r===null?e.messageCount:[...e.messageCountByStep].filter(([e])=>e!==r.step).reduce((e,[,t])=>e+t,0),toolCallCount:e.toolCallCount,subagentCount:e.subagentCount};if(r===null)return{turn:t.turn,controlAnchorSeq:n,processStartSeq:n,answerAnchorSeq:null,answerStep:null,inlineReasoning:!1,...i};let a=r.blocks.some(e=>e.kind===`reasoning`&&e.text.trim()!==``),o=Math.min(...[...e.assistantStartByStep].filter(([e])=>e<r.step).map(([,e])=>e)),s=Math.min(e.otherStartSeq??1/0,o);return{turn:t.turn,controlAnchorSeq:n,processStartSeq:t.start?.seq??(Number.isFinite(s)?s:r.finalNode.seq),answerAnchorSeq:r.finalNode.seq,answerStep:r.step,inlineReasoning:a,...i}}function hC(e,t){let n=e;if(t.type===`assistant/message`&&t.surfaceOp===`append`&&tb(Eb(t.data.message.content))){let e=new Map(n.messageCountByStep);e.set(t.data.step,(e.get(t.data.step)??0)+1),n={...n,messageCountByStep:e,messageCount:n.messageCount+1}}if(t.type===`tool/call`){if(dg(t.data.name)){let e=new Set(n.contextCompactionCalls);e.add(String(t.data.callId)),n={...n,contextCompactionCalls:e}}else{let e=ug(t.data.name);n={...n,toolCallCount:n.toolCallCount+ +!e,subagentCount:n.subagentCount+ +!!e}}}let r=lC(t,n.contextCompactionCalls);if(r===void 0)return n;if(r.kind===`other`)return n.otherStartSeq===void 0?{...n,otherStartSeq:r.seq,controlAnchorSeq:Math.min(n.controlAnchorSeq??1/0,r.seq)}:n;if(n.assistantStartByStep.has(r.step))return n;let i=new Map(n.assistantStartByStep);return i.set(r.step,r.seq),{...n,assistantStartByStep:i,controlAnchorSeq:Math.min(n.controlAnchorSeq??1/0,r.seq)}}let gC={kind:`turn-process`,target:`chat`,match:e=>{if(e.type===`turn/start`)return{id:String(e.data.turn),role:`start`};let t=aC(e);return t===void 0?null:e.type===`assistant/live-chunk`||e.type===`assistant/message`||e.type===`tool/call`||e.type===`tool/result`||e.type===`llm/retry`||e.type===`step/start`||e.type===`step/end`||e.type===`turn/end`?{id:String(t),role:`update`}:null},start:(e,t)=>{if(t.event.type!==`turn/start`)throw Error(`turn-process start requires turn/start`);return{turn:t.event.data.turn,assistantStartByStep:/* @__PURE__ */ new Map,messageCountByStep:/* @__PURE__ */ new Map,messageCount:0,toolCallCount:0,subagentCount:0,contextCompactionCalls:/* @__PURE__ */ new Set}},update:(e,t)=>hC(e.state,t.event),publication:e=>{if(e.event.type===`assistant/live-chunk`){let t=e.event.data.chunk.type;return t===`usage`||t===`finish`?`none`:`animation-frame`}return`immediate`},buildLocationData:(e,t,n)=>{if(t!==`turn`)return null;let r=e.state??dC(e);if(r===void 0)return null;let i=uC(e);if(i===void 0)return null;let a=e.current.get(`chat`),o=i.steps.at(-1);if(n?.kind===`turn`&&n.key===`turn-process`&&a?.kind===`turn-process`&&a.data.answerAnchorSeq===null&&a.data.controlAnchorSeq===r.controlAnchorSeq&&a.data.messageCount===r.messageCount&&a.data.toolCallCount===r.toolCallCount&&a.data.subagentCount===r.subagentCount&&i.status!==`closed`&&o?.status!==`closed`)return n;let s=mC(r,i);return s===null?null:n?.kind===`turn`&&n.turn===s.turn&&n.key===`turn-process`&&lg(n.value,s)?n:{kind:`turn`,turn:i.turn,key:`turn-process`,value:s}},buildViewNode:e=>{let t=uC(e),n=t?.data.get(`turn-process`);if(t===void 0||n===void 0)return null;let r=e.current.get(`chat`),i=e.state;return r?.kind===`turn-process`&&i!==void 0&&r.data.answerAnchorSeq===null&&r.data.controlAnchorSeq===i.controlAnchorSeq&&r.data.messageCount===i.messageCount&&r.data.toolCallCount===i.toolCallCount&&r.data.subagentCount===i.subagentCount&&t.status!==`closed`&&t.steps.at(-1)?.status!==`closed`&&r.location===(e.start?.location??e.matches[0]?.location)?r:gb(e,`turn-process`,n.controlAnchorSeq+mb.processControl,n)}};function _C(e){let t=gC.match.bind(gC);e.uiConversation.events.register({...gC,match:{"turn/start":t,"assistant/live-chunk":t,"assistant/message":t,"tool/call":t,"tool/result":t,"llm/retry":t,"step/start":t,"step/end":t,"turn/end":t}})}function vC(e,t){for(let n=e.length-1;n>=0;--n){let r=e[n];if(r.type===`chunk`&&r.chunk.type===t)return r.chunk}}function yC(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function bC(e){let t=0;for(let n of e)if(t+=n,!Number.isSafeInteger(t))return;return t}function xC(e){let{provider:t,model:n}=e.source;return t.length>0&&n.length>0?{provider:t,model:n}:void 0}function SC(e){return vC(e,`usage`)?.usage}function CC(e,t){let{inputTokens:n,outputTokens:r,cacheReadTokens:i,cacheWriteTokens:a,reasoningTokens:o,totalTokens:s}=e;if(!yC(n)||!yC(r)||i!==void 0&&!yC(i)||a!==void 0&&!yC(a)||o!==void 0&&(!yC(o)||o>r))return;let c=bC([n,...i===void 0?[]:[i],...a===void 0?[]:[a]]);if(c===void 0)return;let l;if(s!==void 0){if(!yC(s))return;let e=s-r;if(!yC(e)||e<c||i!==void 0&&a!==void 0&&e!==c)return;l=s}else{if(i===void 0||a===void 0)return;let e=bC([c,r]);if(e===void 0)return;l=e}return{inputTokens:n,outputTokens:r,totalTokens:l,...i===void 0?{}:{cacheReadTokens:i},...a===void 0?{}:{cacheWriteTokens:a},...o===void 0?{}:{reasoningTokens:o},...t===void 0?{}:{route:t}}}function wC(e){if(e.length===0)return;let t=bC(e.map(e=>e.inputTokens)),n=bC(e.map(e=>e.outputTokens)),r=bC(e.map(e=>e.totalTokens));if(t===void 0||n===void 0||r===void 0)return;let i=e.map(e=>e.cacheReadTokens),a=e.map(e=>e.cacheWriteTokens),o=e.map(e=>e.reasoningTokens),s=i.every(yC)?bC(i):void 0,c=a.every(yC)?bC(a):void 0,l=o.every(yC)?bC(o):void 0,u,d=e.map(e=>e.route);if(d.every(e=>e!==void 0)){let e=/* @__PURE__ */ new Map;for(let t of d)e.set(`${t.provider}\0${t.model}`,t);u=[...e.values()]}return{uncachedInputTokens:t,outputTokens:n,totalTokens:r,...s===void 0?{}:{cacheReadTokens:s},...c===void 0?{}:{cacheWriteTokens:c},...l===void 0?{}:{reasoningTokens:l},...u===void 0?{}:{routes:u}}}function TC(e,t,n){return e.turn===t&&e.step===n}function EC(e){let t={kind:`idle`},n=[],r,i=!1,a=!1,o=e=>{if(t.kind!==`open`||t.sample===void 0)return!1;let r=CC(t.sample,e);return r!==void 0&&(n.push(r),!0)};for(let n of e){if(a)break;if(n.type===`turn/start`)r!==void 0||t.kind!==`idle`?a=!0:r=n.data.turn;else{if(r===void 0){a=!0;break}if(n.type===`turn/end`)n.data.turn!==r||t.kind!==`idle`||i?a=!0:i=!0;else{if(i){a=!0;break}if(n.type===`step/start`)n.data.turn!==r||t.kind!==`idle`?a=!0:t={kind:`open`,turn:r,step:n.data.step};else if(n.type===`llm/retry-started`)n.data.turn!==r||t.kind!==`settled`||t.by!==`retry`||!TC(t,n.data.turn,n.data.step)?a=!0:t={kind:`open`,turn:r,step:n.data.step};else if(n.type===`assistant/attempt`){if(n.data.turn!==r||t.kind!==`open`||!TC(t,n.data.turn,n.data.step)){a=!0;continue}let e=SC(n.data.stream)??t.sample;t={kind:`open`,turn:r,step:n.data.step,...e===void 0?{}:{sample:e}},o()?t={kind:`finishClosed`,turn:r,step:n.data.step}:a=!0}else if(n.type===`assistant/message`){if(n.data.turn!==r||t.kind!==`open`||!TC(t,n.data.turn,n.data.step)){a=!0;continue}let e=n.data.usage??SC(n.data.stream);e!==void 0&&(t={...t,sample:e}),o(xC(n.data.message))?t={kind:`settled`,turn:r,step:n.data.step,by:`message`}:a=!0}else if(n.type===`llm/retry`){if(n.data.turn!==r||t.kind===`idle`||!TC(t,n.data.turn,n.data.step)){a=!0;continue}(t.kind===`settled`||t.kind===`open`&&!o())&&(a=!0),a||(t={kind:`settled`,turn:r,step:n.data.step,by:`retry`})}else if(n.type===`step/end`){if(n.data.turn!==r||t.kind===`idle`||!TC(t,n.data.turn,n.data.step)){a=!0;continue}t.kind===`open`&&!o()&&(a=!0),a||(t={kind:`idle`})}}}}return a||!i||t.kind!==`idle`?void 0:wC(n)}function DC(e){return e.type!==`assistant/live-chunk`}function OC(e){if(e.type===`assistant/message`||e.type===`assistant/attempt`||e.type===`assistant/live-chunk`||e.type===`step/start`||e.type===`step/end`||e.type===`llm/retry`||e.type===`llm/retry-started`)return{turn:e.data.turn,step:e.data.step}}function kC(e){let t=e.start?.location??e.matches[0]?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn:void 0}function AC(e){return e.finalNode!==void 0&&e.blocks.some(e=>e.kind===`text`&&e.text.trim()!==``)}function jC(e){let t=e.state===void 0?e.matches.find(e=>e.event.type===`turn/end`):e.state.end;if(t?.event.type!==`turn/end`)return null;let n=kC(e);if(n===void 0)return null;let r=n.steps.map(e=>e.data.get(`assistant-step`)).filter(e=>e!==void 0).filter(e=>e.finalNode!==void 0).sort((e,t)=>e.finalNode.seq-t.finalNode.seq),i=r.findLast(AC)??null,a=r.at(-1)?.finalNode.seq;for(let t of e.matches){let e=t.event,n=e.type===`tool/call`||e.type===`tool/result`&&e.surfaceOp===`append`||e.type===`turn/end`&&e.data.reason.kind===`error`||e.type===`llm/retry`?e.seq:void 0;n!==void 0&&(a===void 0||n>a)&&(a=n)}let o=e.start?.event.type===`turn/start`?EC(e.matches.map(e=>e.event).filter(DC)):void 0;return{turn:t.event.data.turn,seq:t.event.seq,time:t.event.time,closing:i,branchUnavailable:i===null||a!==i.finalNode.seq,...o===void 0?{}:{tokenUsage:o}}}let MC={kind:`turn-tail`,target:`chat`,match:e=>{if(e.type===`turn/start`)return{id:String(e.data.turn),role:`start`};if(e.type===`turn/end`||e.type===`tool/call`||e.type===`tool/result`)return{id:String(e.data.turn),role:`update`};let t=OC(e);return t===void 0?null:{id:String(t.turn),role:`update`}},start:(e,t)=>{if(t.event.type!==`turn/start`)throw Error(`turn-tail start requires turn/start`);return{turn:t.event.data.turn}},update:(e,t)=>t.event.type===`turn/end`?{...e.state,end:t}:e.state,publication:e=>e.event.type===`turn/end`?`immediate`:`none`,buildLocationData:(e,t)=>{if(t!==`turn`)return null;let n=jC(e);return n===null?null:{kind:`turn`,turn:n.turn,key:`turn-tail`,value:n}},buildViewNode:e=>{let t=kC(e)?.data.get(`turn-tail`);return t===void 0?null:gb(e,`turn-tail`,t.seq+mb.finalizedFollowup,t)}};function NC(e){let t=MC.match.bind(MC);e.uiConversation.events.register({...MC,match:{"turn/start":t,"turn/end":t,"tool/call":t,"tool/result":t,"assistant/message":t,"assistant/attempt":t,"assistant/live-chunk":t,"step/start":t,"step/end":t,"llm/retry":t,"llm/retry-started":t}})}function PC(e){return e===`read`?`read`:e===`read_image`?`readImage`:e===`grep`||e===`glob`||e.endsWith(`_inspect`)?`search`:e===`write`?`write`:e===`edit`||e===`apply_patch`?`edit`:[`bash`,`pwsh`,`exec_command`,`write_stdin`].includes(e)||e.startsWith(`terminal_`)?`commands`:e===`run_code`?`code`:e===`web_search`?`webSearch`:e===`web_fetch`?`webFetch`:e===`subagent`||e.startsWith(`subagent_`)?`subagents`:[`todo_write`,`create_goal`,`update_goal`,`get_goal`].includes(e)?`plan`:e===`ask_user_question`||e===`request_user_input`?`questions`:`tools`}let FC=new Intl.Segmenter(void 0,{granularity:`grapheme`}),IC=[`title`,`description`,`objective`,`task`,`task_name`,`name`,`question`,`questions`,`prompt`,`message`,`command`,`cmd`,`queries`,`query`,`pattern`,`url`,`uri`,`file_path`,`path`,`target`,`action`,`status`];function LC(e){let t=e.replace(/\s+/g,` `).trim();if(t.length<=160)return{text:t,truncated:!1};let n=[];for(let{segment:e}of FC.segment(t)){if(n.length===160)return{text:`${n.slice(0,159).join(``).trimEnd()}…`,truncated:!0};n.push(e)}return{text:t,truncated:!1}}function RC(e){return LC(typeof e==`string`?e:Array.isArray(e)&&e.every(e=>typeof e==`string`)?e.join(`, `):``).text}function zC(e,t){let n=512;for(;;){let r=e.textPrefix(t,n);if(r===void 0)return;let i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319){let i=e.textPrefix(t,n+1),a=i.charCodeAt(r.length);a>=56320&&a<=57343?(r=i,n++):i.length===r.length&&!e.isSealed&&!e.complete(t)&&(r=r.slice(0,-1))}let a=LC(r);if(a.truncated||!e.stringExceeds(t,n))return a.text;n*=2}}function BC(e){if(!Array.isArray(e))return``;for(let t of e){if(typeof t!=`object`||!t)continue;let e=RC(Reflect.get(t,`question`));if(e!==``)return e}return``}function VC(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.kind===`assistant-step`&&n.data.status===`running`)for(let e=n.data.blocks.length-1;e>=0;e--){let t=n.data.blocks[e];if(t?.kind!==`reasoning`)continue;let r=t.text.split(/\r?\n[\t ]*\r?\n/);for(let e=r.length-1;e>=0;e--){let t=RC(r[e]?.replaceAll(`**`,``));if(t!==``)return t}}}return``}function HC(e,t){for(let e of IC){if(!t.has(e))continue;let n=e===`questions`?BC(t.value(e)):zC(t,e)??RC(t.value(e));if(n!==``)return n}return t.closed()?RC(e):``}function UC(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Set,r,i=``,a=-1/0,o,s=e=>{if(n.has(e.callId))return;n.add(e.callId);let c=qb(e)?e:e.call;if(c!==null){let n=PC(c.name);qb(e)&&e.time>=a&&(r=n,o=e.phase===`preparing`,i=HC(e.name,e.args),a=e.time),t.set(n,(t.get(n)??0)+1)}for(let t of e.subCalls)s(t)};for(let t of e)t.kind===`tool-call`&&s(t.data.root);return r===void 0&&(i=VC(e)),{counts:[...t].map(([e,t])=>({kind:e,count:t})).sort((e,t)=>t.count-e.count),running:r,runningDetail:i,...o?{preparing:!0}:{}}}let WC=/* @__PURE__ */ new Set([`user`,`steering`,`turn-trigger`,`model-retry`,`turn-error`,`turn-max-tokens`,`turn-tail`]);function GC(e){let t=e.location;return t.kind===`turn`||t.kind===`step`?t.turn.turn:void 0}function KC(e){return WC.has(e.kind)||e.kind===`tool-call`&&dg(e.data.root.name)}function qC(e){return e.kind===`assistant-step`&&e.data.blocks.some(e=>e.kind===`reasoning`&&e.text.trim()!==``)}function JC(e){return e.kind===`assistant-step`&&tb(e.data.blocks)}function YC(e,t){return e.running===t.running&&e.runningDetail===t.runningDetail&&e.preparing===t.preparing&&e.counts.length===t.counts.length&&e.counts.every((e,n)=>e.kind===t.counts[n]?.kind&&e.count===t.counts[n].count)}function XC(e,t){return e.length===t.length&&e.every((e,n)=>e.key===t[n]?.key&&e.groupPart===t[n].groupPart)}function ZC(e,t){return!Jb(t)&&(e===void 0||!Jb(e))?!1:e===void 0||e.kind!==t.kind||GC(e)!==GC(t)||Jb(e)!==Jb(t)||qC(e)!==qC(t)||JC(e)!==JC(t)}function QC(e,t){let n=e.readNode(t);if(n===void 0)throw Error(`Chat grouping input is missing Node ${t}`);return n}function $C(e,t){let n=/* @__PURE__ */ new Set;for(let r of t){let t=QC(e,r);t.kind===`question-reply`&&n.add(t.id)}return n}var ew=class{key;turn;members;nodes=[];forceClosed=!1;sameTurnFollowed=!1;snapshot;constructor(e,t,n){this.key=e,this.turn=t,this.members=n,this.snapshot={key:e,members:n,data:{turn:t,closed:!1,summary:{counts:[],running:void 0,runningDetail:``}}}}get isForceClosed(){return this.forceClosed}get isSameTurnFollowed(){return this.sameTurnFollowed}refresh(e,t,n,r){this.forceClosed=t,this.sameTurnFollowed=n;let i=this.members.map(t=>QC(e,t.key)),a=i.length===this.nodes.length&&i.every((e,t)=>e===this.nodes[t]),o=this.snapshot.data,s=r===`closed`||t||n&&r!==`open`,c=a&&(!o.closed||s)?o.summary:UC(i),l=s||n&&c.running===void 0,u=l?{counts:c.counts,running:void 0,runningDetail:``}:c;this.nodes=i,(o.closed!==l||!YC(o.summary,u))&&(this.snapshot={key:this.key,members:this.members,data:{turn:this.turn,closed:l,summary:u}})}},tw=class{turn;groups=/* @__PURE__ */ new Map;membership=/* @__PURE__ */ new Map;roots=/* @__PURE__ */ new Map;lastTurnStatus;constructor(e){this.turn=e}references(e){return this.roots.get(e)??[]}snapshots(){return[...this.groups.values()].map(e=>e.snapshot)}refresh(e,t){let n=/* @__PURE__ */ new Set;for(let e of t){let t=this.membership.get(e);t!==void 0&&n.add(t)}let r=e.timeline.turns.get(this.turn)?.status;if(r!==this.lastTurnStatus){for(let e of this.groups.values())n.add(e.key);this.lastTurnStatus=r}let i=[];for(let t of n){let n=this.groups.get(t),a=n.snapshot;n.refresh(e,n.isForceClosed,n.isSameTurnFollowed,r),n.snapshot!==a&&i.push(n.snapshot)}return i}rebuild(e,t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map,a=[],o=[],s=e.timeline.turns.get(this.turn)?.status;this.lastTurnStatus=s;let c=(e,t)=>{n.set(e,[...n.get(e)??[],t])},l=(n,l)=>{let u=a[0];if(u===void 0)return;let d=this.extendedGroup(a,t)?.key??G_(JSON.stringify([`process`,u.key,u.groupPart??null])),f=this.groups.get(d),p=f?.snapshot,m=f!==void 0&&XC(f.members,a)?f:new ew(d,this.turn,a);m.refresh(e,n,l,s),r.set(m.key,m),c(u.key,{kind:`group`,key:m.key});for(let e of a)i.set(e.key,m.key);m.snapshot!==p&&o.push(m.snapshot),a=[]},u,d=!1,f=e.readTurn(this.turn),p=$C(e,f);for(let t of f){let n=nw(e,t);u!==void 0&&n.previous!==u&&l(!0,!1),u=t,d=n.next!==void 0;let r=QC(e,t);r.kind===`turn-trigger`&&p.has(r.id)||(KC(r)?(l(!1,!0),c(t,{kind:`node`,key:t})):r.kind===`turn-process`?c(a[0]?.key??t,{kind:`node`,key:t}):r.kind===`assistant-step`?(qC(r)&&a.push({kind:`node`,key:t,groupPart:`reasoning`}),JC(r)&&(l(!1,!0),c(t,{kind:`node`,key:t,groupPart:`response`}))):a.push({kind:`node`,key:t}))}l(d,!1);let m=[...this.groups.keys()].filter(e=>!r.has(e));return this.groups=r,this.membership=i,this.roots=n,{upserts:o,removes:m}}extendedGroup(e,t){let n=e.findIndex(e=>!t.has(e.key)),r=e[n];if(r===void 0)return;let i=this.membership.get(r.key),a=i===void 0?void 0:this.groups.get(i);if(!(a===void 0||n+a.members.length>e.length)){for(let t=0;t<a.members.length;t++){let r=a.members[t],i=e[n+t];if(r.key!==i.key||r.groupPart!==i.groupPart)return}for(let r=n+a.members.length;r<e.length;r++)if(!t.has(e[r].key))return;return a}}};function nw(e,t){let n=e.readPosition(t);if(n===void 0)throw Error(`Chat grouping order is missing position for Node ${t}`);return n}var rw=class{turns=/* @__PURE__ */ new Map;order=[];pending=null;accept(e){if(e.kind===`replace`){let t=new Set(this.order),n=new Set(e.order.filter(e=>!t.has(e))),r=/* @__PURE__ */ new Map;for(let t of e.order){let i=nw(e,t).turn;if(i===void 0||r.has(i))continue;let a=this.turns.get(i)??new tw(i);a.rebuild(e,n),r.set(i,a)}this.turns=r,this.order=e.order,this.pending={entries:this.rootEntries(e),groups:{kind:`replace`,snapshots:[...r.values()].flatMap(e=>e.snapshots())}};return}let t=new Set(e.changedTurnOrders),n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Map,i=e=>{let t=r.get(e);return t===void 0&&(t=/* @__PURE__ */ new Set,r.set(e,t)),t};for(let r of e.changes){let e=r.previous,a=r.current,o=GC(a);if((e===void 0||!Jb(e))&&n.add(a.key),ZC(e,a)){let n=e===void 0?void 0:GC(e);n!==void 0&&t.add(n),o!==void 0&&t.add(o)}o!==void 0&&i(o).add(a.key)}for(let t of e.changedTurns)i(t);let a=[],o=[];for(let r of t){let t=this.turns.get(r)??new tw(r),i=t.rebuild(e,n);a.push(...i.upserts),o.push(...i.removes),e.readTurn(r).length===0?this.turns.delete(r):this.turns.set(r,t)}for(let[n,i]of r)t.has(n)||a.push(...this.turns.get(n)?.refresh(e,i)??[]);let s=e.order!==this.order||t.size>0;this.order=e.order;let c=new Set(a.map(e=>e.key));this.pending=s||a.length>0||o.length>0?{...s?{entries:this.rootEntries(e)}:{},groups:{kind:`apply`,upserts:a,removes:o.filter(e=>!c.has(e))}}:null}rootEntries(e){let t=$C(e,e.order.filter(t=>nw(e,t).turn===void 0));return e.order.flatMap(n=>{let r=nw(e,n).turn;if(r===void 0){let r=QC(e,n);return r.kind===`turn-trigger`&&t.has(r.id)?[]:[{kind:`node`,key:n}]}let i=this.turns.get(r);if(i===void 0)throw Error(`Chat grouping order is missing Turn ${r}`);return i.references(n)})}output(){return this.pending}};let iw={kind:`process-groups`,target:`chat`,create:()=>new rw,update:(e,t)=>(e.state.accept(t),e.state),buildGroups:e=>e.state.output()};function aw(e){hS(e),xS(e),ES(e),Gb(e),_C(e),JS(e),tS(e),iS(e),AS(e),$S(e),iC(e),NC(e),oS(e),Ux(e),e.uiConversation.groups.register(iw)}function ow({useNotice:e,dismissNotice:t,keepNoticeOpen:n,renderSlotChain:r,t:i}){let a=e(e=>e);if(a===null)return null;let o={code:a.code,message:i(`message.failure.quota`),dismiss:t,keepOpen:n};return/* @__PURE__ */ (0,f.jsx)(d.Fragment,{children:r(`shell.quota-notice`,o,{fallback:/* @__PURE__ */ (0,f.jsx)(p.Toast,{text:o.message,icon:/* @__PURE__ */ (0,f.jsx)(p.IconWarningOutlineRegular,{size:18}),onDone:t})})},`quota-notice-${String(a.seq)}`)}function sw(e){return e==null}function cw(e){return e&&typeof e==`object`&&!Array.isArray(e)}function lw(e,t){return Object.fromEntries(Object.entries(e).filter(([e,n])=>t(e,n)))}function uw(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(n,e)]))}function dw(e,t,n){if(!t)return{...e};let r={};for(let i of t)(n||e[i]!==void 0)&&(r[i]=e[i]);return r}let fw=Symbol.for(`cosmokit.volatile.write`);function pw(e,t=/* @__PURE__ */ new Set){if(typeof e==`function`)throw TypeError(`volatile config cannot contain functions`);if(typeof e!=`object`||!e)return e;if(t.has(e))throw TypeError(`volatile config cannot contain cycles`);t.add(e);try{if(Array.isArray(e))return Object.freeze(e.map(e=>pw(e,t)));if(Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw TypeError(`volatile config objects must be plain objects or arrays`);return Object.freeze(Object.fromEntries(Object.entries(e).map(([e,n])=>[e,pw(n,t)])))}finally{t.delete(e)}}function mw(e){let t=pw(e);return Object.freeze({get:()=>t,[fw]:e=>{t=e}})}function hw(e){return typeof e==`object`&&!!e&&fw in e}function gw(e,t){return arguments.length===1?t=>gw(e,t):e in globalThis&&t instanceof globalThis[e]||Object.prototype.toString.call(t).slice(8,-1)===e}function _w(e){return gw(`ArrayBuffer`,e)||gw(`SharedArrayBuffer`,e)}function vw(e){return _w(e)||ArrayBuffer.isView(e)}let yw;(function(e){e.is=_w,e.isSource=vw;function t(e){return ArrayBuffer.isView(e)?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):e}e.fromSource=t;function n(e){if(e=t(e),typeof Buffer<`u`)return Buffer.from(e).toString(`base64`);let n=``,r=new Uint8Array(e);for(let e=0;e<r.byteLength;e++)n+=String.fromCharCode(r[e]);return btoa(n)}e.toBase64=n;function r(e){return typeof Buffer<`u`?t(Buffer.from(e,`base64`)):Uint8Array.from(atob(e),e=>e.charCodeAt(0))}e.fromBase64=r;function i(e){return e=t(e),typeof Buffer<`u`?Buffer.from(e).toString(`hex`):Array.from(new Uint8Array(e),e=>e.toString(16).padStart(2,`0`)).join(``)}e.toHex=i;function a(e){if(typeof Buffer<`u`)return t(Buffer.from(e,`hex`));let n=e.length%2==0?e:e.slice(0,e.length-1),r=[];for(let e=0;e<n.length;e+=2)r.push(parseInt(`${n[e]}${n[e+1]}`,16));return Uint8Array.from(r).buffer}e.fromHex=a})(yw||={}),yw.fromBase64,yw.toBase64,yw.fromHex,yw.toHex;function bw(e,t=/* @__PURE__ */ new Map){if(!e||typeof e!=`object`)return e;if(gw(`Date`,e))return new Date(e.valueOf());if(gw(`RegExp`,e))return new RegExp(e.source,e.flags);if(_w(e))return e.slice(0);if(ArrayBuffer.isView(e))return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);let n=t.get(e);if(n)return n;if(Array.isArray(e)){let n=[];return t.set(e,n),e.forEach((e,r)=>{n[r]=Reflect.apply(bw,null,[e,t])}),n}let r=Object.create(Object.getPrototypeOf(e));t.set(e,r);for(let n of Reflect.ownKeys(e)){let i={...Reflect.getOwnPropertyDescriptor(e,n)};`value`in i&&(i.value=Reflect.apply(bw,null,[i.value,t])),Reflect.defineProperty(r,n,i)}return r}function xw(e,t,n){let r=/* @__PURE__ */ new Set;function i(e,t){if(e===t)return!0;if(hw(e)||hw(t))return hw(e)&&hw(t);if(!n&&sw(e)&&sw(t))return!0;if(typeof e!=typeof t||typeof e!=`object`||!e||!t||r.has(e))return!1;function a(n,r){return n(e)?n(t)?r(e,t):!1:!n(t)&&void 0}r.add(e);try{return a(Array.isArray,(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!i(e[n],t[n]))return!1;return!0})??a(gw(`Date`),(e,t)=>e.valueOf()===t.valueOf())??a(gw(`URL`),(e,t)=>e.href===t.href)??a(gw(`RegExp`),(e,t)=>e.source===t.source&&e.flags===t.flags)??a(_w,(e,t)=>{if(e.byteLength!==t.byteLength)return!1;let n=new Uint8Array(e),r=new Uint8Array(t);for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0})??((!n||[e,t].every(e=>Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null))&&Object.keys({...e,...t}).every(n=>i(e[n],t[n])))}finally{r.delete(e)}}return i(e,t)}let Sw;(function(e){e.millisecond=1;let t=e.second=1e3,n=e.minute=t*60,r=e.hour=n*60,i=e.day=r*24,a=e.week=i*7,o=(/* @__PURE__ */ new Date()).getTimezoneOffset();function s(e){o=e}e.setTimezoneOffset=s;function c(){return o}e.getTimezoneOffset=c;function l(e=/* @__PURE__ */ new Date,t){return typeof e==`number`&&(e=new Date(e)),t===void 0&&(t=o),Math.floor((e.valueOf()/n-t)/1440)}e.getDateNumber=l;function u(e,t){let r=new Date(e*i);return t===void 0&&(t=o),new Date(+r+t*n)}e.fromDateNumber=u;let d=RegExp(`^${[`w(?:eek(?:s)?)?`,`d(?:ay(?:s)?)?`,`h(?:our(?:s)?)?`,`m(?:in(?:ute)?(?:s)?)?`,`s(?:ec(?:ond)?(?:s)?)?`].map(e=>`(\\d+(?:\\.\\d+)?${e})?`).join(``)}$`);function f(e){let o=d.exec(e);return o?(parseFloat(o[1])*a||0)+(parseFloat(o[2])*i||0)+(parseFloat(o[3])*r||0)+(parseFloat(o[4])*n||0)+(parseFloat(o[5])*t||0):0}e.parseTime=f;function p(e){let t=f(e);return t?e=Date.now()+t:/^\d{1,2}(:\d{1,2}){1,2}$/.test(e)?e=`${(/* @__PURE__ */ new Date()).toLocaleDateString()}-${e}`:/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(e)&&(e=`${(/* @__PURE__ */ new Date()).getFullYear()}-${e}`),e?new Date(e):/* @__PURE__ */ new Date}e.parseDate=p;function m(e){let a=Math.abs(e);return a>=i-r/2?Math.round(e/i)+`d`:a>=r-n/2?Math.round(e/r)+`h`:a>=n-t/2?Math.round(e/n)+`m`:a>=t?Math.round(e/t)+`s`:e+`ms`}e.format=m;function h(e,t=2){return e.toString().padStart(t,`0`)}e.toDigits=h;function g(e,t=/* @__PURE__ */ new Date){return e.replace(`yyyy`,t.getFullYear().toString()).replace(`yy`,t.getFullYear().toString().slice(2)).replace(`MM`,h(t.getMonth()+1)).replace(`dd`,h(t.getDate())).replace(`hh`,h(t.getHours())).replace(`mm`,h(t.getMinutes())).replace(`ss`,h(t.getSeconds())).replace(`SSS`,h(t.getMilliseconds(),3))}e.template=g})(Sw||={});let Cw=Symbol.for(`schemastery`),ww=Symbol.for(`ValidationError`);globalThis.__schemastery_index__??=0,globalThis.__schemastery_refs__=void 0;var Q=class extends TypeError{options;name=`ValidationError`;constructor(e,t){let n=`$`;for(let e of t.path||[])typeof e==`string`?n+=`.`+e:typeof e==`number`?n+=`[`+e+`]`:typeof e==`symbol`&&(n+=`[Symbol(${e.toString()})]`);n.startsWith(`.`)&&(n=n.slice(1)),super((n===`$`?``:`${n} `)+e),this.options=t}static is(e){return!!e?.[ww]}};Object.defineProperty(Q.prototype,ww,{value:!0});let $=function(e){let t=function(e,n={}){return $.resolve(e,t,n)[0]};if(e.refs){let t=uw(e.refs,e=>new $(e)),n=e=>t[e];for(let e in t){let r=t[e];r.sKey=n(r.sKey),r.inner=n(r.inner),r.list=r.list&&r.list.map(n),r.dict=r.dict&&uw(r.dict,n)}return t[e.uid]}if(Object.assign(t,e),typeof t.callback==`string`)try{t.callback=Function(`return `+t.callback)()}catch{}return Object.defineProperty(t,"uid",{value:globalThis.__schemastery_index__++}),Object.setPrototypeOf(t,$.prototype),t.meta||={},t.toString=t.toString.bind(t),t};$.prototype=Object.create(Function.prototype),$.prototype[Cw]=!0,Object.defineProperty($.prototype,"~standard",{get(){return{version:1,vendor:`schemastery`,validate:e=>{try{return{value:$.resolve(e,this,{})[0]}}catch(e){if(Q.is(e))return{issues:[{message:e.message,path:e.options.path}]};throw e}}}}}),$.ValidationError=Q,$.prototype.toJSON=function(){if(globalThis.__schemastery_refs__)return globalThis.__schemastery_refs__[this.uid]??=JSON.parse(JSON.stringify({...this})),this.uid;globalThis.__schemastery_refs__={[this.uid]:{...this}},globalThis.__schemastery_refs__[this.uid]=JSON.parse(JSON.stringify({...this}));let e={uid:this.uid,refs:globalThis.__schemastery_refs__};return globalThis.__schemastery_refs__=void 0,e},$.prototype.set=function(e,t){return this.dict[e]=t,this},$.prototype.push=function(e){return this.list.push(e),this};function Tw(e,t){let n=typeof e==`string`?{"":e}:{...e};for(let e in t){let r=t[e];r?.$description||r?.$desc?n[e]=r.$description||r.$desc:typeof r==`string`&&(n[e]=r)}return n}function Ew(e){return e?.$value??e?.$inner}function Dw(e){return lw(e??{},e=>!e.startsWith(`$`))}$.prototype.i18n=function(e){let t=$(this),n=Tw(t.meta.description,e);return Object.keys(n).length&&(t.meta.description=n),t.dict&&=uw(t.dict,(t,n)=>t.i18n(uw(e,e=>Ew(e)?.[n]??e?.[n]))),t.list&&=t.list.map((t,n)=>t.i18n(uw(e,(e={})=>Array.isArray(Ew(e))?Ew(e)[n]:Array.isArray(e)?e[n]:Dw(e)))),t.inner&&=t.inner.i18n(uw(e,e=>Ew(e)?Ew(e):Dw(e))),t.sKey&&=t.sKey.i18n(uw(e,e=>e?.$key)),t},$.prototype.extra=function(e,t){let n=$(this);return n.meta={...n.meta,[e]:t},n};for(let e of[`required`,`disabled`,`collapse`,`hidden`,`loose`])Object.assign($.prototype,{[e](t=!0){let n=$(this);return n.meta={...n.meta,[e]:t},n}});$.prototype.deprecated=function(){let e=$(this);return e.meta.badges||=[],e.meta.badges.push({text:`deprecated`,type:`danger`}),e},$.prototype.experimental=function(){let e=$(this);return e.meta.badges||=[],e.meta.badges.push({text:`experimental`,type:`warning`}),e},$.prototype.pattern=function(e){let t=$(this),n=dw(e,[`source`,`flags`]);return t.meta={...t.meta,pattern:n},t},$.prototype.simplify=function(e){if(hw(e)&&(e=e.get()),xw(e,this.meta.default,this.type===`dict`))return null;if(sw(e))return e;if(this.type===`object`||this.type===`dict`){let t={};for(let n in e){let r=(this.type===`object`?this.dict[n]:this.inner)?.simplify(e[n]);(this.type===`dict`||!sw(r))&&(t[n]=r)}return xw(t,this.meta.default,this.type===`dict`)?null:t}if(this.type===`array`||this.type===`tuple`){let t=[];return e.forEach((e,n)=>{let r=this.type===`array`?this.inner:this.list[n],i=r?r.simplify(e):e;t.push(i)}),t}if(this.type===`intersect`){let t={};for(let n of this.list)Object.assign(t,n.simplify(e));return t}if(this.type===`union`)for(let t of this.list)try{return $.resolve(e,t,{}),t.simplify(e)}catch{}return e},$.prototype.toString=function(e){return Iw[this.type]?.(this,e)??`Schema<${this.type}>`},$.prototype.role=function(e,t){let n=$(this);return n.meta={...n.meta,role:e,extra:t},n};for(let e of[`default`,`link`,`comment`,`description`,`max`,`min`,`step`])Object.assign($.prototype,{[e](t){let n=$(this);return n.meta={...n.meta,[e]:t},n}});$.prototype.volatile=function(){if(this.meta.volatile)throw TypeError(`volatile schema is already wrapped`);return this.extra(`volatile`,!0)};let Ow={},kw=Symbol(`checked-volatile-schema`);function Aw(e,t=[],n=!1,r=/* @__PURE__ */ new Map){let i=r.get(e)??/* @__PURE__ */ new Set;if(i.has(n))return;if(i.add(n),r.set(e,i),e.meta?.volatile&&n)throw new Q(`volatile fields require a fixed object path without an enclosing volatile field`,{path:t});let a=n||!!e.meta?.volatile;if(e.dict)for(let[n,i]of Object.entries(e.dict))Aw(i,[...t,n],a,r);if(e.sKey&&Aw(e.sKey,[...t,`<key>`],!0,r),e.inner&&(e.type!==`lazy`||e.inner[Cw])&&Aw(e.inner,[...t,`*`],!0,r),e.list)for(let n=0;n<e.list.length;n++)Aw(e.list[n],[...t,String(n)],!0,r)}$.extend=function(e,t){Ow[e]=t},$.resolve=function(e,t,n={},r=!1){if(!t)return[e];if(n[kw]||(Aw(t,n.path),n={...n,[kw]:!0}),t.meta?.volatile){let i=$(t);i.meta={...t.meta,volatile:!1};let[a,o]=$.resolve(e,i,n,r);try{return[mw(a),o]}catch(e){throw new Q(e instanceof Error?e.message:String(e),n)}}if(n.ignore?.(e,t))return[e];if(sw(e)&&t.type!==`lazy`){if(t.meta.required)throw new Q(`missing required value`,n);let r=t,i=t.meta.default;for(;r?.type===`intersect`&&sw(i);)r=r.list[0],i=r?.meta.default;if(sw(i))return[e];e=bw(i)}let i=Ow[t.type];if(!i)throw new Q(`unsupported type "${t.type}"`,n);try{return i(e,t,n,r)}catch(e){if(!t.meta.loose)throw e;return[t.meta.default]}},$.from=function(e){if(sw(e))return $.any();if([`string`,`number`,`boolean`].includes(typeof e))return $.const(e).required();if(e[Cw])return e;if(typeof e==`function`)switch(e){case String:return $.string().required();case Number:return $.number().required();case Boolean:return $.boolean().required();case Function:return $.function().required();default:return $.is(e).required()}else throw TypeError(`cannot infer schema from ${e}`)},$.lazy=function(e){let t=new $({type:`lazy`,builder:e,inner:{toJSON:()=>(t.inner[Cw]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta}),t.inner.toJSON())}});return t},$.natural=function(){return $.number().step(1).min(0)},$.percent=function(){return $.number().step(.01).min(0).max(1).role(`slider`)},$.date=function(){return $.union([$.is(Date),$.transform($.string().role(`datetime`),(e,t)=>{let n=new Date(e);if(isNaN(+n))throw new Q(`invalid date "${e}"`,t);return n},!0)])},$.regExp=function(e=``){return $.union([$.is(RegExp),$.transform($.string().role(`regexp`,{flag:e}),(t,n)=>{try{return new RegExp(t,e)}catch(e){throw new Q(e.message,n)}},!0)])},$.arrayBuffer=function(e){return $.union([$.is(ArrayBuffer),$.is(SharedArrayBuffer),$.transform($.any(),(e,t)=>{if(yw.isSource(e))return yw.fromSource(e);throw new Q(`expected ArrayBufferSource but got ${e}`,t)},!0),...e?[$.transform($.string(),(t,n)=>{try{return e===`base64`?yw.fromBase64(t):yw.fromHex(t)}catch(e){throw new Q(e.message,n)}},!0)]:[]])},$.extend(`lazy`,(e,t,n,r)=>(t.inner[Cw]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta},Aw(t.inner,n.path,!0)),$.resolve(e,t.inner,n,r))),$.extend(`any`,e=>[e]),$.extend(`never`,(e,t,n)=>{throw new Q(`expected nullable but got ${e}`,n)}),$.extend(`const`,(e,{value:t},n)=>{if(xw(e,t))return[t];throw new Q(`expected ${t} but got ${e}`,n)});function jw(e,t,n,r,i=!1){let{max:a=1/0,min:o=-1/0}=t;if(e>a)throw new Q(`expected ${n} <= ${a} but got ${e}`,r);if(e<o&&!i)throw new Q(`expected ${n} >= ${o} but got ${e}`,r)}$.extend(`string`,(e,{meta:t},n)=>{if(typeof e!=`string`)throw new Q(`expected string but got ${e}`,n);if(t.pattern){let r=new RegExp(t.pattern.source,t.pattern.flags);if(!r.test(e))throw new Q(`expect string to match regexp ${r}`,n)}return jw(e.length,t,`string length`,n),[e]});function Mw(e,t){let n=e.toString();if(n.includes(`e`))return e*10**t;let r=n.indexOf(`.`);if(r===-1)return e*10**t;let i=n.slice(r+1),a=n.slice(0,r);return i.length<=t?+(a+i.padEnd(t,`0`)):+(a+i.slice(0,t)+`.`+i.slice(t))}function Nw(e,t,n){if(n=Math.abs(n),!/^\d+\.\d+$/.test(n.toString()))return(e-t)%n===0;let r=n.toString().indexOf(`.`),i=n.toString().slice(r+1).length;return Math.abs(Mw(e,i)-Mw(t,i))%Mw(n,i)===0}$.extend(`number`,(e,{meta:t},n)=>{if(typeof e!=`number`)throw new Q(`expected number but got ${e}`,n);jw(e,t,`number`,n);let{step:r}=t;if(r&&!Nw(e,t.min??0,r))throw new Q(`expected number multiple of ${r} but got ${e}`,n);return[e]}),$.extend(`boolean`,(e,t,n)=>{if(typeof e==`boolean`)return[e];throw new Q(`expected boolean but got ${e}`,n)}),$.extend(`bitset`,(e,{bits:t,meta:n},r)=>{let i=0,a=[];if(typeof e==`number`){i=e;for(let n in t)e&t[n]&&a.push(n)}else if(Array.isArray(e)){a=e;for(let e of a){if(typeof e!=`string`)throw new Q(`expected string but got ${e}`,r);e in t&&(i|=t[e])}}else throw new Q(`expected number or array but got ${e}`,r);return i===n.default?[i]:[i,a]}),$.extend(`function`,(e,t,n)=>{if(typeof e==`function`)return[e];throw new Q(`expected function but got ${e}`,n)}),$.extend(`is`,(e,{constructor:t},n)=>{if(typeof t==`function`){if(e instanceof t)return[e];throw new Q(`expected ${t.name} but got ${e}`,n)}{if(sw(e))throw new Q(`expected ${t} but got ${e}`,n);let r=Object.getPrototypeOf(e);for(;r;){if(r.constructor?.name===t)return[e];r=Object.getPrototypeOf(r)}throw new Q(`expected ${t} but got ${e}`,n)}});function Pw(e,t,n,r){try{let[i,a]=$.resolve(e[t],n,{...r,path:[...r.path||[],t]});return a!==void 0&&(e[t]=a),i}catch(i){if(!r?.autofix)throw i;return delete e[t],n.meta.volatile?mw(n.meta.default):n.meta.default}}$.extend(`array`,(e,{inner:t,meta:n},r)=>{if(!Array.isArray(e))throw new Q(`expected array but got ${e}`,r);return jw(e.length,n,`array length`,r,!sw(t.meta.default)),[e.map((n,i)=>Pw(e,i,t,r))]}),$.extend(`dict`,(e,{inner:t,sKey:n},r,i)=>{if(!cw(e))throw new Q(`expected object but got ${e}`,r);let a={};for(let o in e){let s;try{s=$.resolve(o,n,r)[0]}catch(e){if(i)continue;throw e}a[s]=Pw(e,o,t,r),e[s]=e[o],o!==s&&delete e[o]}return[a]}),$.extend(`tuple`,(e,{list:t},n,r)=>{if(!Array.isArray(e))throw new Q(`expected array but got ${e}`,n);let i=t.map((t,r)=>Pw(e,r,t,n));return r||i.push(...e.slice(t.length)),[i]});function Fw(e,t){for(let n in t)n in e||(e[n]=t[n])}$.extend(`object`,(e,{dict:t},n,r)=>{if(!cw(e))throw new Q(`expected object but got ${e}`,n);let i={};for(let r in t){let a=Pw(e,r,t[r],n);(!sw(a)||r in e)&&(i[r]=a)}return r||Fw(i,e),[i]}),$.extend(`union`,(e,{list:t,toString:n},r,i)=>{let a=[];for(let n of t)try{return $.resolve(e,n,r,i)}catch(e){a.push(e)}throw new Q(`expected ${n()} but got ${JSON.stringify(e)}`,r)}),$.extend(`intersect`,(e,{list:t,toString:n},r,i)=>{if(!t.length)return[e];let a;for(let i of t){let t=$.resolve(e,i,r,!0)[0];if(!sw(t)){if(sw(a))a=t;else if(typeof a!=typeof t)throw new Q(`expected ${n()} but got ${JSON.stringify(e)}`,r);else if(typeof t==`object`)Fw(a??={},t);else if(a!==t)throw new Q(`expected ${n()} but got ${JSON.stringify(e)}`,r)}}return!i&&cw(e)&&Fw(a,e),[a]}),$.extend(`transform`,(e,{inner:t,callback:n,preserve:r},i)=>{let[a,o=e]=$.resolve(e,t,i,!0);return r?[n(a)]:[n(a),n(o)]});let Iw={};function Lw(e,t,n){Iw[e]=n,Object.assign($,{[e](...n){let r=new $({type:e});return t.forEach((e,t)=>{switch(e){case`sKey`:r.sKey=n[t]??$.string();break;case`inner`:r.inner=$.from(n[t]);break;case`list`:r.list=n[t].map($.from);break;case`dict`:r.dict=uw(n[t],$.from);break;case`bits`:r.bits={};for(let e in n[t])typeof n[t][e]==`number`&&(r.bits[e]=n[t][e]);break;case`callback`:{let e=r.callback=n[t];e.toJSON||=()=>e.toString();break}case`constructor`:{let e=r.constructor=n[t];typeof e==`function`&&(e.toJSON||=()=>e.name);break}default:r[e]=n[t]}}),e===`object`||e===`dict`?r.meta.default={}:e===`array`||e===`tuple`?r.meta.default=[]:e===`bitset`&&(r.meta.default=0),r}})}Lw(`is`,[`constructor`],({constructor:e})=>typeof e==`function`?e.name:e),Lw(`any`,[],()=>`any`),Lw(`never`,[],()=>`never`),Lw(`const`,[`value`],({value:e})=>typeof e==`string`?JSON.stringify(e):e),Lw(`string`,[],()=>`string`),Lw(`number`,[],()=>`number`),Lw(`boolean`,[],()=>`boolean`),Lw(`bitset`,[`bits`],()=>`bitset`),Lw(`function`,[],()=>`function`),Lw(`array`,[`inner`],({inner:e})=>`${e.toString(!0)}[]`),Lw(`dict`,[`inner`,`sKey`],({inner:e,sKey:t})=>`{ [key: ${t.toString()}]: ${e.toString()} }`),Lw(`tuple`,[`list`],({list:e})=>`[${e.map(e=>e.toString()).join(`, `)}]`),Lw(`object`,[`dict`],({dict:e})=>Object.keys(e).length===0?`{}`:`{ ${Object.entries(e).map(([e,t])=>`${e}${t.meta.required?``:`?`}: ${t.toString()}`).join(`, `)} }`),Lw(`union`,[`list`],({list:e},t)=>{let n=e.map(({toString:e})=>e()).join(` | `);return t?`(${n})`:n}),Lw(`intersect`,[`list`],({list:e})=>`${e.map(e=>e.toString(!0)).join(` & `)}`),Lw(`transform`,[`inner`,`callback`,`preserve`],({inner:e},t)=>e.toString(t));let Rw=`transcriptView`,zw=[`compact`,`standard`,`detailed`,`verbose`],Bw=[...zw,`normal`,`expanded`],Vw=`standard`,Hw={linkOpening:$.union([`sidebar`,`new-tab`]).default(`sidebar`),[Rw]:$.union([...Bw]).loose()};$.object(Hw);let Uw=`@deepseek-ai/dsh-client-ui-chat/PreferenceRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Uw)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Uw,e.textContent=`.B8MZ0a_row{border-bottom:.5px solid var(--dsw-alias-border-l2);align-items:center;gap:8px;padding:16px 0;display:flex}.B8MZ0a_rowText{flex-direction:column;flex:1;gap:4px;min-width:0;padding-right:48px;display:flex}.B8MZ0a_title{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:400;line-height:22px}.B8MZ0a_desc{color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:400;line-height:18px}.B8MZ0a_selector{border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-module-platform);height:36px;font:inherit;color:var(--dsw-alias-label-primary);cursor:pointer;touch-action:manipulation;user-select:none;-webkit-tap-highlight-color:transparent;border:none;flex-shrink:0;align-items:center;gap:12px;padding:0 14px;font-size:14px;line-height:22px;display:inline-flex}.B8MZ0a_selector:active{background:var(--dsw-alias-interactive-bg-active)}.B8MZ0a_chevron{flex:none}@media (hover:hover) and (pointer:fine){.B8MZ0a_selector:hover{background:var(--dsw-alias-interactive-bg-hover)}}@media (width<=640px){.B8MZ0a_row{gap:12px;min-height:44px;padding:12px 0}.B8MZ0a_rowText{padding-right:0}.B8MZ0a_selector{gap:8px;height:44px;min-height:44px;padding:0 12px;font-size:13.5px}}`,document.head.appendChild(e)}var Ww={chevron:`B8MZ0a_chevron`,desc:`B8MZ0a_desc`,row:`B8MZ0a_row`,rowText:`B8MZ0a_rowText`,selector:`B8MZ0a_selector`,title:`B8MZ0a_title`};function Gw({title:e,description:t,value:n,selectedLabel:r,options:i,onSelect:a}){let[o,s]=(0,d.useState)(!1),c=(0,d.useRef)(null),l=()=>{s(!1)},u=e=>{c.current?.focus({preventScroll:!0}),l(),a(e)},m=/* @__PURE__ */ (0,f.jsxs)(`button`,{ref:c,type:`button`,className:Ww.selector,"aria-haspopup":`menu`,"aria-expanded":o,onClick:()=>{s(e=>!e)},children:[r,/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{className:Ww.chevron})]});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Ww.row,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Ww.rowText,children:[/* @__PURE__ */ (0,f.jsx)(`div`,{className:Ww.title,children:e}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:Ww.desc,children:t})]}),/* @__PURE__ */ (0,f.jsx)(p.Menu,{open:o,onClose:l,items:i,selectedId:n,onSelect:u,align:`end`,portal:!0,anchor:m})]})}let Kw={compact:`settings.transcript.compact`,standard:`settings.transcript.standard`,detailed:`settings.transcript.detailed`,verbose:`settings.transcript.verbose`};function qw({useTranscriptView:e,setTranscriptView:t,t:n}){let r=e(e=>e);return/* @__PURE__ */ (0,f.jsx)(Gw,{title:n(`settings.transcript.title`),description:n(`settings.transcript.description`),value:r,selectedLabel:n(Kw[r]),options:zw.map(e=>({id:e,label:n(Kw[e])})),onSelect:e=>{t(e)}})}var Jw=class{host;defaultMode;unsubscribe;mode;constructor(e,t=Vw){this.host=e,this.defaultMode=t,this.mode=(0,m.createSnapshotStore)(t),this.unsubscribe=e.subscribe(()=>{this.adopt()}),this.adopt()}dispose(){this.unsubscribe()}setMode(e){this.mode.getSnapshot()!==e&&(this.mode.set(e),this.host.set(Rw,e))}adopt(){let e=this.host.getSnapshot().value;if(e===void 0)return;let t=e.transcriptView,n=t===`normal`||t===`expanded`?`detailed`:t??this.defaultMode;this.mode.getSnapshot()!==n&&this.mode.set(n)}};let Yw={compact:{mode:`compact`,foldCompletedTurns:!0,stepGrouping:`collapsed`,liveProcessDetail:!1,settledReasoningPreview:!1},standard:{mode:`standard`,foldCompletedTurns:!0,stepGrouping:`collapsed`,liveProcessDetail:!0,settledReasoningPreview:!0},detailed:{mode:`detailed`,foldCompletedTurns:!0,stepGrouping:`history`,liveProcessDetail:!0,settledReasoningPreview:!0},verbose:{mode:`verbose`,foldCompletedTurns:!1,stepGrouping:`none`,liveProcessDetail:!1,settledReasoningPreview:!0}};function Xw(e){return{getSnapshot:()=>Yw[e.getSnapshot()],subscribe:t=>e.subscribe(t)}}function Zw({useLinkOpening:e,useBrowserAvailable:t,setLinkOpening:n,t:r}){let i=e(e=>e);return t(e=>e)?/* @__PURE__ */ (0,f.jsx)(Gw,{title:r(`settings.links.title`),description:r(`settings.links.description`),value:i,selectedLabel:r(i===`sidebar`?`settings.links.sidebar`:`settings.links.newTab`),options:[{id:`sidebar`,label:r(`settings.links.sidebar`)},{id:`new-tab`,label:r(`settings.links.newTab`)}],onSelect:e=>{n(e)}}):null}async function Qw(e,t,n,r,i,a){let o=await e.stat(n,i);t.mounted.getSnapshot()===n&&(!o.ok&&o.error.code===`workspace-file/not-regular-file`&&o.error.details.kind===`directory`?t.openTabIn(n,`files`,{params:{directory:o.error.details.path}}):t.openResourceIn(n,ne(n,r,i),a===void 0?void 0:{params:{line:a}}))}let $w={getSnapshot:()=>void 0,subscribe:()=>()=>{}};function eT(e,t){let n=e?.source(t)??$w;return(0,d.useSyncExternalStore)(n.subscribe,n.getSnapshot)}let tT={hooks:{turnData:(e,{turnData:t})=>function(e){return eT(t,e)},disclosure:(e,{disclosureReset:t})=>qg(t)}},nT=[`slots`,`sessions`,`uiWorkspace`,`uiSession`,`uiConversation`,`locale`,`configForms`,`remote`,`remote.session`,`remote.workspaceFiles`,`sidebarRight`];function rT(e){let t=(0,m.createSnapshotStore)(null),n=0,r=(0,m.createSnapshotStore)(null),i=0;e.provide(`chatHandoffLauncher`,{open(e,t){r.set({seq:++i,sessionId:e,...t?.targetHarnessId===void 0?{}:{targetHarnessId:t.targetHarnessId},...t?.atSeq===void 0?{}:{atSeq:t.atSeq}})}});let a=/* @__PURE__ */ new Set,o=/* @__PURE__ */ new WeakMap,s=/* @__PURE__ */ new Set;e.effect(()=>async()=>{await Promise.all([...s].map(e=>e()))},`ui-chat: live quota notices`);let c=r=>{let i=o.get(r);if(i===void 0){let c=r.ctx.effect(()=>{let e=r.eventSource.subscribe(()=>{let{change:e}=r.eventSource.getSnapshot();if(e.kind===`append`)for(let{event:r}of e.entries){if(r.type!==`turn/end`||r.data.reason.kind!==`error`)continue;let{code:e}=r.data.reason.error;a.size>0||e!==`QUOTA`&&e!==`ACCOUNT_QUOTA`||t.set({code:e,seq:++n})}});return()=>{e(),o.delete(r),s.delete(c)}},`ui-chat: Provider binding quota notices`);s.add(c);let l=e.uiConversation.binding(r).target(`chat`);i={getSnapshot:()=>l.getSnapshot()??le,subscribe:e=>l.subscribe(e)},o.set(r,i)}return i};aw(e),e.uiSession.provide({hooks:[`chat`],resolve:e=>({hooks:{chat:c(e)}})}),e.effect(()=>e.locale.register(by,{zh:xy,en:Sy}),`ui-chat: dictionaries`);let l=e.locale.bind(by),u=mg(),d=/* @__PURE__ */ new Map,f=e.configForms.get(`ui-chat`),p=(0,m.createSnapshotStore)(f.getSnapshot().value?.linkOpening??`sidebar`);e.effect(()=>f.subscribe(()=>{let e=f.getSnapshot().value?.linkOpening;e!==void 0&&p.set(e)}));let h={getSnapshot:()=>e.get(`sidebarRightTabs`)?.get(`browser`)!==void 0,subscribe:t=>e.get(`sidebarRightTabs`)?.subscribe(t)??(()=>{})},g=t=>h.getSnapshot()?(e.sidebarRight.openTab(`browser`,{params:{url:t}}),!0):!1;e.inject([`sidebarRightTabs`],e=>{e.slots.inject(`settings.general.item`,()=>e.slots.register({name:`settings.general.item`,id:`link-opening`,order:17,locale:by,inject:()=>({hooks:{linkOpening:p,browserAvailable:h},setLinkOpening:e=>{p.set(e),f.set(`linkOpening`,e).catch(()=>{})}})},Zw))});let _=new Jw(f,`dshDesktop`in globalThis?`standard`:Vw),v=Xw(_.mode);e.effect(()=>()=>{_.dispose()}),pb(e,v),e.slots.inject(`settings.general.item`,()=>e.slots.register({name:`settings.general.item`,id:`transcript-view`,order:12,locale:by,inject:()=>({hooks:{transcriptView:_.mode},setTranscriptView:e=>{_.setMode(e)}})},qw)),e.slots.inject(`conversation.view`,()=>e.slots.register({name:`conversation.view`,id:`chat`,order:0,label:()=>l(`view.chat`),locale:by,children:{"conversation.chat.node":{kind:`keyed`,scope:`session`,inject:tT},"conversation.message.images":{kind:`single`,scope:`session`}},store:u,inject:t=>{let n=e.sessions.binding(t);if(n===void 0)throw Error(`ui-chat: unknown session "${t}"`);let i=n.session,a=c(n),o=e.uiConversation.binding(n),s=e.get(`chatMessageEditing`),l=e.get(`chatTurnDiffs`),u=e.get(`chatHandoff`),f=String(t).startsWith(`web-remote:`)||e.sessions.list.getSnapshot().byId[t]?.projectionValues?.remoteHost!=null,m=!f,_=u!==void 0&&!f&&e.sessions.subagentAddress(t)===void 0;return{connection:e.get(`connection`),hooks:{presentation:v,browserAvailable:h,handoffRequest:r},keyedHooks:{chatNode:e=>a.getSnapshot().nodes.source(e),chatNodeProcess:e=>a.getSnapshot().nodes.processSource(e),chatGroup:e=>o.snapshot.getSnapshot().views.grouped(`chat`)?.groupSource(e)},fileMentions:n=>e.get(`chatFileMentions`)?.forClosing(n,t),openFile:async(n,r)=>{let i=e.sessions.list.getSnapshot().byId[t]?.cwd;if(r?.external||r?.reveal){let a=te(i,n);if(!r.reveal||!j(a)){let r=await e.remote.workspaceFiles.stat(t,n);if(!r.ok)throw Error(r.error.message);a=r.value.absolutePath}let o=await e.remote.session.openWorkspacePath({sessionId:t,path:a,...r.reveal?{action:`reveal`}:{}});if(!o.ok)throw Error(o.error.message)}else await Qw(e.remote.workspaceFiles,e.sidebarRight,t,i,n,r?.line)},openSkill:n=>{let r=e.sessions.scope(t);r!==void 0&&e.get(`inputTriggers`)?.sessionOf(r).openReference(`skill`,{ref:`/${n}`})},resolveLink:e.get(`chatLinks`)?.resolve,openLinkInSidebar:g,openExternalLink:e=>{p.getSnapshot()===`sidebar`&&g(e)||window.open(e,`_blank`,`noopener,noreferrer`)},loadOlder:()=>{i.loadOlder()},loadThrough:e=>i.loadThrough(e),loadImage:Object.assign(n=>e.uiConversation.imageUrl(t,n),{peek:n=>e.uiConversation.peekImageUrl(t,n)}),chatScroll:{save:e=>{e===null?d.delete(t):d.set(t,e)},read:()=>d.get(t)??null},loadTurnDiffs:l?(e,n)=>l.read(t,e,n):void 0,editMessage:s?(e,n)=>s.send(t,e,n):void 0,forkAt:m?n=>{let r=[...a.getSnapshot().timeline.turns.values()].find(e=>e.end?.seq===n)?.data.get(`turn-tail`)?.closing?.finalNode.messageId;return e.sessions.fork({sessionId:t,atSeq:n,increaseTitle:!0,onCreated:n=>{e.get(`productAnalytics`)?.track(`branch_session_click`,{session_id:n,parent_session_id:t,...r===void 0?{}:{parent_message_id:r},click_position:`footer`})}}).then(t=>{e.uiWorkspace.openSession(t)})}:void 0,openSession:t=>{let n=t;e.sessions.list.getSnapshot().byId[n]===void 0?e.sessions.loadSummary(n).catch(()=>void 0).finally(()=>{e.uiWorkspace.openSession(n)}):e.uiWorkspace.openSession(n)},clearHandoffRequest:e=>{r.getSnapshot()?.seq===e&&r.set(null)},loadModelCatalog:_?async()=>{let t=await e.remote.session.modelCatalog(void 0);if(!t.ok)throw Error(t.error.message);return t.value}:void 0,handoff:_?async({atSeq:n,targetHarnessId:r,targetModel:i,targetThinkingOptionId:a})=>{let o=(await u.handoff({sessionId:t,...n===void 0?{}:{atSeq:n},targetHarnessId:r,...i===void 0?{}:{targetModel:i},...a===void 0?{}:{targetThinkingOptionId:a}})).sessionId;e.sessions.list.getSnapshot().byId[o]===void 0&&await e.sessions.loadSummary(o).catch(()=>void 0),e.uiWorkspace.openSession(o)}:void 0}}},vy)),e.slots.inject(`shell.overlay`,()=>e.slots.register({name:`shell.overlay`,id:`chat.quota-notice`,locale:by,children:{"shell.quota-notice":{kind:`chain`,scope:`root`}},inject:()=>({hooks:{notice:t},dismissNotice:()=>{a.clear(),t.set(null)},keepNoticeOpen:()=>{if(t.getSnapshot()===null)return()=>{};let e=Symbol(`ui-chat quota notice hold`);return a.add(e),()=>{a.delete(e)}}})},ow)),e.slots.inject(`conversation.input.dock`,()=>e.slots.register({name:`conversation.input.dock`,id:`file-changes`,order:5,locale:by},D)),e.slots.inject(`conversation.approval.detail`,()=>e.slots.register({name:`conversation.approval.detail`},M))}return n.EMPTY_CHAT_SNAPSHOT=le,n.apply=rT,n.inject=nT,n.isRunningTool=qb,n.isSettledTool=Kb,t.exports}});
129
+ `,n);if(o!==-1&&o<=a){let r=e.slice(n,o).trim();r!==``&&(t=r)}if(i===null)return t;n=i.index+i[0].length}}let pb=(0,d.memo)(function({text:e,running:t,usePresentation:n,useDisclosure:r,t:i}){let{expanded:a,toggle:o}=r(),s=(0,d.useMemo)(()=>Ih(i),[i]),c=t?fb(e):db(e),l=(0,d.useMemo)(()=>c.replaceAll(`**`,``),[c]),u=n(e=>!a&&l!==``&&(t||e.settledReasoningPreview)),m=(0,d.useMemo)(()=>/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:lb.separator,"data-shimmer-decoration":!0,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:lb.summary,"data-streaming":t||void 0,children:/* @__PURE__ */ (0,f.jsx)(`span`,{className:lb.summaryText,children:/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{children:l})})})]}),[t,l]),h=(0,d.useMemo)(()=>a?/* @__PURE__ */ (0,f.jsx)(`div`,{className:lb.thinkBody,children:/* @__PURE__ */ (0,f.jsx)(p.MarkdownText,{text:e,streaming:t,labels:s,variant:`compact`})}):void 0,[a,s,t,e]);return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:lb.root,"data-variant":`think`,"data-state":t?`running`:`ok`,"data-expanded":a||void 0,"data-preview":u||void 0,children:[t&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:ry.visuallyHidden,children:i(`row.running`)}),/* @__PURE__ */ (0,f.jsx)(p.DisclosureRow,{rowClassName:lb.row,leadingClassName:lb.leading,titleClassName:lb.title,icon:ub,title:i(`message.think`),running:t,open:a,expandable:!0,expandOnRowClick:!0,onToggle:o,collapsedContent:m,children:h})]})}),mb=`@deepseek-ai/dsh-client-ui-chat/AssistantMarkdown.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(mb)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=mb,e.textContent=`.-BFQla_root{font-size:var(--dsh-content-font-size,14px);line-height:calc(24px + var(--dsh-content-font-delta,0px));color:var(--dsw-alias-label-primary);flex-direction:column;display:flex}.-BFQla_body{flex-direction:column;gap:16px;display:flex}.-BFQla_viewedImages{flex-direction:column;align-items:flex-start;gap:10px;display:flex}.-BFQla_viewedImagesToggle{min-height:24px;color:var(--dsw-alias-label-tertiary);font:inherit;cursor:pointer;background:0 0;border:none;align-items:center;gap:6px;padding:0;display:inline-flex}.-BFQla_viewedImagesToggle:hover{color:var(--dsw-alias-label-secondary)}.-BFQla_viewedImagesToggle:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-alias-state-business-primary);outline-offset:2px;border-radius:var(--dsw-radius-sm)}.-BFQla_viewedImagesIcon{flex:none;width:16px;height:16px;position:relative}.-BFQla_viewedImagesIcon:before,.-BFQla_viewedImagesIcon:after{content:"";border:1px solid;border-radius:3px;width:11px;height:9px;position:absolute}.-BFQla_viewedImagesIcon:before{top:2px;left:2px}.-BFQla_viewedImagesIcon:after{top:5px;left:5px}.-BFQla_viewedImagesChevron{flex:none;width:12px;height:12px}.-BFQla_body .md-table-wide{--dsh-table-viewport:calc(var(--dsh-chat-viewport-width,var(--dsh-chat-content-width) + 2 * var(--dsh-chat-scroll-pad-x,0px)) - 2 * var(--dsh-chat-scroll-pad-x,0px));--dsh-table-spare:max(0px, calc((var(--dsh-table-viewport) - var(--dsh-chat-content-width)) / 2));--dsh-table-lead:calc(var(--dsh-table-spare) + min(var(--dsh-chat-content-width), var(--dsh-table-viewport)) - 100%);box-sizing:border-box;width:calc(100% + var(--dsh-table-lead) + var(--dsh-table-spare));max-width:none;margin-left:calc(-1 * var(--dsh-table-lead));padding-left:var(--dsh-table-lead)}.-BFQla_body .md-table-wide>table{z-index:1;position:relative}.-BFQla_body>[data-turn-process-inline][hidden]{margin-bottom:-16px}.-BFQla_stopped{border-radius:var(--dsw-radius-sm);background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-tertiary);align-self:flex-start;padding:0 6px;font-size:11px;line-height:18px}.-BFQla_actions{margin-top:16px;margin-left:-6px}`,document.head.appendChild(e)}var hb={actions:`-BFQla_actions`,body:`-BFQla_body`,root:`-BFQla_root`,stopped:`-BFQla_stopped`,viewedImages:`-BFQla_viewedImages`,viewedImagesChevron:`-BFQla_viewedImagesChevron`,viewedImagesIcon:`-BFQla_viewedImagesIcon`,viewedImagesToggle:`-BFQla_viewedImagesToggle`};function gb({images:e,renderMessageImages:t,t:n}){let[r,i]=(0,d.useState)(!1),a=e.length===1?n(`message.imageViews.one`):n(`message.imageViews.many`,{count:e.length});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:hb.viewedImages,children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:hb.viewedImagesToggle,"aria-expanded":r,onClick:()=>{i(e=>!e)},children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:hb.viewedImagesIcon,"aria-hidden":`true`}),/* @__PURE__ */ (0,f.jsx)(`span`,{children:a}),r?/* @__PURE__ */ (0,f.jsx)(p.IconChevronUpOutlineRegular,{className:hb.viewedImagesChevron}):/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{className:hb.viewedImagesChevron})]}),r&&t({images:e,align:`start`})]})}function _b(e,t,n){let r;try{r=decodeURIComponent(t.split(/[?#]/u)[0]??``)}catch{return}return n===void 0?oe(e,r):n(r)}let vb=(0,d.memo)(function({blocks:e,streaming:t,interrupted:n,renderMessageImages:r,groupPart:i,useDisclosure:a,reasoningHidden:o=!1,usePresentation:s,revealProcess:c,mentions:l,fileCitations:u,responseAnnotations:m,t:h}){let g=(0,d.useMemo)(()=>Ih(h),[h]),{fileImages:_}=(0,p.useMarkdownDelegate)(),v=(0,d.useMemo)(()=>({resolve:e=>_b(document.baseURI,e,_?.resolve)}),[_]),y=e.length-1;if(!(t||n===!0||e.some(e=>e.kind!==`tool-call`)))return null;let b=[];for(let n=0;n<e.length;n++){let _=e[n];if(_!==void 0&&(i!==`reasoning`||_.kind===`reasoning`)&&(i!==`response`||_.kind!==`reasoning`))switch(_.kind){case`text`:b.push(/* @__PURE__ */ (0,f.jsx)(p.MarkdownText,{text:_.text,streaming:t,breaks:!0,labels:g,fileMentions:l,fileCitations:u,pathImages:v,responseAnnotations:m},n));break;case`reasoning`:b.push(/* @__PURE__ */ (0,f.jsx)(yb,{hidden:o,reveal:c,children:/* @__PURE__ */ (0,f.jsx)(pb,{text:_.text,running:t&&n===y,usePresentation:s,useDisclosure:a,t:h})},n));break;case`image`:{let t=n,i=[_];for(;n+1<e.length;){let t=e[n+1];if(t===void 0||t.kind!==`image`)break;i.push(t),n+=1}b.push(/* @__PURE__ */ (0,f.jsx)(d.Fragment,{children:r({images:i.map(({attachment:e})=>({attachment:e})),align:`start`})},t));break}case`viewed-images`:{let t=n,i=[_];for(;n+1<e.length;){let t=e[n+1];if(t===void 0||t.kind!==`viewed-images`)break;i.push(t),n+=1}b.push(/* @__PURE__ */ (0,f.jsx)(gb,{images:i.map(({attachment:e})=>({attachment:e})),renderMessageImages:r,t:h},t));break}case`tool-call`:break;default:b.push(/* @__PURE__ */ (0,f.jsx)(p.JsonBlock,{label:h(`message.unknownBlock`),payload:_.block,truncatedLabel:e=>h(`json.truncated`,{total:e})},n))}}return/* @__PURE__ */ (0,f.jsx)(`div`,{className:hb.root,"data-streaming":t||void 0,children:/* @__PURE__ */ (0,f.jsxs)(`div`,{className:hb.body,children:[b,n&&(i===void 0||i===`response`||!e.some(e=>e.kind!==`reasoning`&&e.kind!==`tool-call`))&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:hb.stopped,children:h(`message.stopped`)})]})})});function yb({hidden:e,reveal:t,children:n}){let r=F_(e,t??bb);return/* @__PURE__ */ (0,f.jsx)(`div`,{ref:r,"data-turn-process-inline":e||void 0,children:n})}let bb=()=>{};function xb(e,t){for(let n=e;n!==null&&n!==t;n=n.parentElement)if(n.classList.contains(wy.annotationMark))return!0;return!1}let Sb=(0,d.memo)(function({node:e,groupPart:t,useDisclosure:n,useTurnData:r,turnProcess:i,openFile:a,renderMessageImages:o,fileMentions:s,responseAnnotations:c,useInput:l,inputActions:u,usePresentation:p,t:m}){let h=e.data,g=(0,d.useRef)(null),_=JSON.stringify([e.key,t??null]),v=e.location.kind===`turn`||e.location.kind===`step`?e.location.turn:void 0,y=r(`turn-tail`),b=(0,d.useMemo)(()=>{if(v?.status===`closed`&&h.finalNode!==void 0&&y?.closing?.finalNode.seq===h.finalNode.seq)return{turn:v,seq:h.finalNode.seq,openFile:a}},[h.finalNode,a,y,v]),x=(0,d.useMemo)(()=>b===void 0?void 0:s(b),[s,b]),S=(0,d.useMemo)(()=>{if(a!==void 0)return{resolve:e=>{if(e.trim()!==``)return{open:()=>{a(e)},label:e,title:e}}}},[a]),C=i!==void 0&&i.foldable&&i.spec.answerStep===h.step&&i.spec.inlineReasoning&&!i.open,w=(0,d.useCallback)(()=>{i?.setOpen(!0)},[i]),T=(0,d.useMemo)(()=>Lh(m),[m]),E=(0,d.useMemo)(()=>({labels:T,resolve:e=>c[e-1]}),[T,c]),ee=(0,d.useCallback)(e=>{e.detail>=2&&g.current!==null&&Kg(g.current,xb)},[]);return/* @__PURE__ */ (0,f.jsxs)(`div`,{ref:g,className:wy.answer,"data-selection-answer":_,"data-selection-answer-streaming":h.status===`running`||void 0,onClick:ee,children:[/* @__PURE__ */ (0,f.jsx)(vb,{blocks:h.blocks,groupPart:t,useDisclosure:n,streaming:h.status===`running`,interrupted:h.status===`interrupted`,renderMessageImages:o,reasoningHidden:C,usePresentation:p,revealProcess:w,mentions:x,fileCitations:S,responseAnnotations:E,t:m}),h.status!==`running`&&/* @__PURE__ */ (0,f.jsx)(jy,{answer:g,answerKey:_,useInput:l,inputActions:u,labels:T})]})}),Cb=`@deepseek-ai/dsh-client-ui-chat/GenericCommandCard.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Cb)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Cb,e.textContent=`.lHK2Ya_root{flex-direction:column;display:flex}.lHK2Ya_leading{flex-shrink:0}.lHK2Ya_title{font-weight:400}.lHK2Ya_separator{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.lHK2Ya_summary{min-width:0;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}.lHK2Ya_summary[data-error],.lHK2Ya_body[data-error]{color:var(--dsw-alias-state-error-primary)}.lHK2Ya_body{border:.5px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-markdown-code-block);max-height:260px;color:var(--dsw-alias-label-primary);font:var(--dsw-font-markdown-code-block-small);white-space:pre-wrap;margin:4px 0 4px 4px;padding:12px 16px;overflow:auto}`,document.head.appendChild(e)}var wb={body:`lHK2Ya_body`,leading:`lHK2Ya_leading`,root:`lHK2Ya_root`,separator:`lHK2Ya_separator`,summary:`lHK2Ya_summary`,title:`lHK2Ya_title`};let Tb=/* @__PURE__ */ (0,f.jsx)(p.IconApiOutlineRegular,{size:14});function Eb(e){return e===null?`running`:e.kind===`error`?`error`:`ok`}let Db=(0,d.memo)(function({node:e,t,runningSummary:n,successSummary:r}){let[i,a]=(0,d.useState)(!1),o=e.outcome?.text,s=e.outcome===null?n??t(`command.running`):o??(e.outcome.kind===`error`?t(`command.failed`):r??t(`command.done`)),c=e.name??t(`command.title`),l=Eb(e.outcome),u=l===`running`,m=o!==void 0&&o.includes(`
130
+ `)?o:null,h=i&&m!==null,g=(0,d.useCallback)(()=>{a(e=>!e)},[]),_=(0,d.useMemo)(()=>/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:wb.separator,"data-shimmer-decoration":!0,"aria-hidden":!0}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:wb.summary,"data-error":l===`error`||void 0,children:/* @__PURE__ */ (0,f.jsx)(p.TextShimmer,{children:s})})]}),[u,l,s]),v=(0,d.useMemo)(()=>h?/* @__PURE__ */ (0,f.jsx)(`pre`,{className:wb.body,"data-error":l===`error`||void 0,children:m}):void 0,[m,h,l]);return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:wb.root,"data-variant":`others`,"data-command":e.name??void 0,"data-state":l,children:[l===`running`&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:ry.visuallyHidden,children:t(`row.running`)}),l===`error`&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:ry.visuallyHidden,children:t(`row.failed`)}),/* @__PURE__ */ (0,f.jsx)(p.DisclosureRow,{leadingClassName:wb.leading,titleClassName:wb.title,icon:Tb,title:c,running:u,open:h,expandable:m!==null,expandOnRowClick:!0,keepContentWhenOpen:!0,onToggle:g,collapsedContent:_,children:v})]})});function Ob({node:e,compaction:t,t:n}){return t===void 0?/* @__PURE__ */ (0,f.jsx)(Db,{node:e,t:n,runningSummary:n(`message.compaction.running`),successSummary:n(`message.compaction`)}):/* @__PURE__ */ (0,f.jsx)(Xh,{node:t,title:n(`message.compaction.commandTitle`),fallbackSummary:e.outcome?.text??null,t:n})}let kb=(0,d.memo)(function({node:e,renderSlot:t,t:n}){let r=e.data,i=(0,d.useMemo)(()=>({node:r}),[r]);return/* @__PURE__ */ (0,f.jsx)(`div`,{className:V_.callRow,children:t(`conversation.chat.commandview`,i,{entryKey:r.name??``,fallback:/* @__PURE__ */ (0,f.jsx)(Db,{...i,t:n})})})}),Ab=(0,d.memo)(function({node:e,t}){let n=e.data;return/* @__PURE__ */ (0,f.jsx)(`div`,{className:V_.callRow,children:/* @__PURE__ */ (0,f.jsx)(Ob,{node:n.command,...n.compaction===null?{}:{compaction:n.compaction},t})})});function jb({text:e,update:t=!1,t:n}){let[r,i]=(0,d.useState)(!1);return/* @__PURE__ */ (0,f.jsx)(p.DisclosureRow,{className:Cg.root,icon:/* @__PURE__ */ (0,f.jsx)(p.IconBrowseOutlineRegular,{size:14}),chevronClassName:Cg.chevron,title:n(t?`message.systemPromptUpdate`:`message.systemPrompt`),open:r,expandable:!0,expandOnRowClick:!0,onToggle:()=>{i(e=>!e)},children:/* @__PURE__ */ (0,f.jsx)(`div`,{className:Cg.body,"data-system-prompt-body":!0,children:/* @__PURE__ */ (0,f.jsx)(sg,{content:[{type:`text`,text:e}],source:null,t:n})})})}let Mb=(0,d.memo)(function({node:e,t}){return/* @__PURE__ */ (0,f.jsx)(jb,{text:e.data.text,update:e.data.update===!0,t})}),Nb=`@deepseek-ai/dsh-client-ui-chat/TurnProcessNodeView.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Nb)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Nb,e.textContent=`.NsInEG_root{box-sizing:border-box;width:100%;min-width:0;height:calc(33px + var(--dsh-content-font-delta,0px));border:none;border-bottom:.5px solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-tertiary);font:inherit;font-size:var(--dsh-content-font-size,14px);cursor:pointer;text-align:left;background:0 0;align-items:center;padding:0 0 8px;transition:color .1s;display:flex}.NsInEG_root:disabled{cursor:default}@media (hover:hover){.NsInEG_root:hover:not(:disabled){color:var(--dsw-alias-label-secondary)}}.NsInEG_root:active:not(:disabled){color:var(--dsw-alias-label-secondary)}.NsInEG_chevron{width:14px;height:14px;color:inherit;flex:none;margin-left:4px;transition:transform .1s}.NsInEG_root[data-open] .NsInEG_chevron{transform:rotate(180deg)}.NsInEG_label{min-width:0;font-size:inherit;line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.NsInEG_durationNumber{font-family:var(--ds-font-family-code);font-variant-numeric:tabular-nums}@media (prefers-reduced-motion:reduce){.NsInEG_root,.NsInEG_chevron{transition:none}}`,document.head.appendChild(e)}var Pb={chevron:`NsInEG_chevron`,durationNumber:`NsInEG_durationNumber`,label:`NsInEG_label`,root:`NsInEG_root`};let Fb=(0,d.memo)(function({node:e,turnProcess:t,t:n}){if(t===void 0)throw Error(`turn-process node requires Turn process owner state`);let r=!t.foldable||t.open,i=e.location.kind===`turn`||e.location.kind===`step`?e.location.turn:void 0;if(i?.status!==`closed`)return null;let a=t.foldable&&t.hasContent&&!E_(e),o=i.end?.data.reason.kind,s=i.start===void 0||i.end===void 0||i.end.time<=i.start.time?void 0:Math.max(1e3,i.end.time-i.start.time),c=s===void 0||o===`aborted`||o===`error`||o===`unknown`?void 0:Og(s,n),l=n(o===`unknown`?`message.turnProcess.unknown`:o===`aborted`?`message.stopped`:o===`error`?`message.turnProcess.failed`:c===void 0?`message.turnProcess.worked`:`message.turnProcess.took`),u=n(o===`unknown`?`message.turnProcess.unknown`:o===`aborted`?`message.stopped`:o===`error`?`message.turnProcess.failed`:`message.turnProcess.worked`);return/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:ry.visuallyHidden,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:u}),/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Pb.root,"data-open":r||void 0,"data-turn-process":e.data.turn,"data-turn-process-messages":e.data.messageCount,"data-turn-process-tool-calls":e.data.toolCallCount,"data-turn-process-subagents":e.data.subagentCount,disabled:!a,"aria-expanded":t.hasContent?r:void 0,onClick:n=>{let i=n.currentTarget,a=i.ownerDocument.activeElement,o=a instanceof Element&&a.closest(`[data-turn-process-member], [data-step-process]`)?.getAttribute(`data-chat-turn`)===String(e.data.turn);r&&o&&(n.detail!==0||(0,p.pointerModality)()?(0,p.focusWithoutRing)(i,{preventScroll:!0}):i.focus({preventScroll:!0})),t.setOpen(!r)},children:[/* @__PURE__ */ (0,f.jsxs)(`span`,{className:Pb.label,children:[l,c?.map((e,t)=>/* @__PURE__ */ (0,f.jsx)(`span`,{className:e.numeric?Pb.durationNumber:void 0,children:e.text},t))]}),a&&/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{className:Pb.chevron})]})]})});function Ib(e,t,n,r){let[i,a]=(0,d.useState)({}),[o,s]=(0,d.useState)(),[c,l]=(0,d.useState)(0),u=JSON.stringify(t.filter(e=>n.has(e.path)&&e.hunks===void 0).map(e=>[e.path,e.revision]));return(0,d.useEffect)(()=>{let t=JSON.parse(u).filter(([e,t])=>i[e]?.revision!==t);if(!r||t.length===0)return;let n=!0;return s(void 0),Promise.all(t.map(async([t,n])=>[t,{revision:n,diffs:(await r(e,t)).filter(e=>e.path===t)}])).then(e=>{n&&a(t=>({...t,...Object.fromEntries(e)}))},e=>{n&&s(e instanceof Error?e.message:String(e))}),()=>{n=!1}},[e,u,r,i,c]),{diffs:e=>e.hunks??(i[e.path]?.revision===e.revision?i[e.path]?.diffs:void 0),error:o,retry:()=>l(e=>e+1)}}let Lb=`@deepseek-ai/dsh-client-ui-chat/TurnChangesCard.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Lb)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Lb,e.textContent=`.U56YlW_card{border:1px solid var(--dsw-alias-border-l2);corner-shape:round;color:var(--dsw-alias-label-primary);font-size:calc(var(--dsh-content-font-size-secondary,13px) + 2px);--dsh-change-stat-font-size:calc(var(--dsh-content-font-size-secondary,13px) + 1px);--dsw-alias-state-success-primary:var(--dsw-alias-file-diff-added-marker);--dsw-alias-state-error-primary:var(--dsw-alias-file-diff-deleted-marker);border-radius:12px;margin:8px 0;line-height:20px;overflow:hidden}.U56YlW_header{-webkit-user-select:none;user-select:none;align-items:center;gap:12px;padding:12px;display:flex}.U56YlW_icon{corner-shape:round;background:color-mix(in srgb, var(--dsw-alias-label-primary) 4%, transparent);width:44px;height:44px;color:var(--dsw-alias-label-secondary);border-radius:12px;flex:none;place-items:center;display:grid}.U56YlW_text{flex-direction:column;flex:auto;gap:2px;min-width:0;display:flex}.U56YlW_title{text-overflow:ellipsis;white-space:nowrap;font-weight:600;overflow:hidden}.U56YlW_titleLink{max-width:100%;color:inherit;font-family:inherit;font-size:inherit;line-height:inherit;text-align:left;cursor:pointer;background:0 0;border:0;align-self:flex-start;margin:0;padding:0}.U56YlW_review,.U56YlW_fileHead,.U56YlW_openFile,.U56YlW_more{color:inherit;font:inherit;text-align:left;cursor:pointer;-webkit-user-select:none;user-select:none;background:0 0;border:0}.U56YlW_review{border:1px solid var(--dsw-alias-border-l2);corner-shape:round;font-size:var(--dsh-content-font-size,14px);white-space:nowrap;border-radius:12px;flex:none;padding:4px 8px;font-weight:500}@media (hover:hover){.U56YlW_review:hover,.U56YlW_fileHead:hover,.U56YlW_openFile:hover,.U56YlW_more:hover{background:var(--dsw-alias-interactive-bg-hover)}.U56YlW_titleLink:hover{text-underline-offset:3px;text-decoration:underline}}.U56YlW_review:active,.U56YlW_fileHead:active,.U56YlW_openFile:active,.U56YlW_more:active{background:var(--dsw-alias-interactive-bg-hover)}.U56YlW_review:focus-visible,.U56YlW_fileHead:focus-visible,.U56YlW_openFile:focus-visible,.U56YlW_more:focus-visible{outline:2px solid var(--dsw-alias-label-tertiary);outline-offset:-2px}.U56YlW_titleLink:focus-visible{outline:2px solid var(--dsw-alias-label-tertiary);outline-offset:2px}.U56YlW_files{border-top:1px solid var(--dsw-alias-border-l2);margin:0;padding:0;list-style:none}.U56YlW_fileRow{align-items:center;display:flex}.U56YlW_fileRow .U56YlW_fileHead{flex:auto;min-width:0}.U56YlW_openFile{corner-shape:round;width:28px;height:28px;color:var(--dsw-alias-label-secondary);border-radius:8px;flex:none;place-items:center;margin-right:8px;padding:0;display:grid}.U56YlW_fileHead{justify-content:space-between;align-items:center;gap:12px;width:100%;min-height:40px;padding:8px 12px;display:flex}.U56YlW_fileHead .U56YlW_path{min-width:0;font-size:inherit;--dsw-alias-label-tertiary:var(--dsw-alias-label-secondary);flex:1}.U56YlW_diff{padding:0 12px 12px}.U56YlW_file:first-child .U56YlW_diff:first-child{padding-top:12px}.U56YlW_more{align-items:center;gap:8px;width:100%;min-height:40px;padding:8px 12px;font-weight:500;display:flex}.U56YlW_mobileChevron,.U56YlW_mobileFileIcon,.U56YlW_mobilePath,.U56YlW_mobileFullPath{display:none}.U56YlW_chevron{flex:none;transition:transform .15s}.U56YlW_chevron[data-open=true]{transform:rotate(180deg)}@media (width<=480px){.U56YlW_header{grid-template-columns:36px minmax(0,1fr);gap:8px;display:grid}.U56YlW_icon{width:36px;height:36px}.U56YlW_review{grid-column:2;justify-self:start}}[data-phone] .U56YlW_card{-webkit-text-size-adjust:100%;text-size-adjust:100%;min-width:0;max-width:100%;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));--dsh-change-stat-font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);--dsh-diff-inline-padding:12px;--dsh-diff-body-padding:4px 0 8px}[data-phone] .U56YlW_header{grid-template-columns:20px minmax(0,1fr) 44px;gap:8px;min-height:52px;padding:0 4px 0 12px;display:grid}[data-phone] .U56YlW_icon{background:0 0;border-radius:0;width:20px;height:20px}[data-phone] .U56YlW_icon>svg{width:16px;height:16px}[data-phone] .U56YlW_text{flex-direction:row;align-items:center;gap:8px}[data-phone] .U56YlW_title{flex:auto;min-width:0;font-weight:500}[data-phone] .U56YlW_review{border-radius:var(--dsw-radius-sm);border:0;grid-column:auto;justify-self:stretch;place-items:center;width:44px;height:44px;padding:0;display:grid}[data-phone] .U56YlW_reviewLabel{display:none}[data-phone] .U56YlW_mobileChevron,[data-phone] .U56YlW_mobileFileIcon{color:var(--dsw-alias-label-secondary);flex:none;display:block}[data-phone] .U56YlW_mobileChevron{transition:transform .15s}[data-phone] .U56YlW_mobileChevron[data-open=true]{transform:rotate(180deg)}[data-phone] .U56YlW_fileHead,[data-phone] .U56YlW_more{gap:8px;min-height:44px;padding:0 12px}[data-phone] .U56YlW_titleLink{align-self:center;min-height:44px}[data-phone] .U56YlW_openFile{border-radius:var(--dsw-radius-sm);width:44px;height:44px;margin-right:0}[data-phone] .U56YlW_file+.U56YlW_file{border-top:1px solid var(--dsw-alias-border-l2)}[data-phone] .U56YlW_path{display:none}[data-phone] .U56YlW_mobilePath{flex-direction:column;flex:1;min-width:0;padding-block:4px;display:flex}[data-phone] .U56YlW_fileName{text-overflow:ellipsis;white-space:nowrap;font-weight:500;overflow:hidden}[data-phone] .U56YlW_directory,[data-phone] .U56YlW_mobileFullPath{color:var(--dsw-alias-label-secondary);font-size:calc(11px + var(--dsh-content-font-delta-secondary,0px));line-height:calc(16px + var(--dsh-content-font-delta-secondary,0px));white-space:normal;overflow-wrap:anywhere}[data-phone] .U56YlW_mobileFullPath{user-select:text;padding:4px 12px;display:block}[data-phone] .U56YlW_diff,[data-phone] .U56YlW_file:first-child .U56YlW_diff:first-child{padding:0}[data-phone] .U56YlW_diffStatus{overflow-wrap:anywhere;padding:12px;display:block}[data-phone] .U56YlW_diffStatus button{min-width:44px;min-height:44px}[data-phone] .U56YlW_inlineDiff{border-radius:0;min-width:0;max-width:100%;margin:0}[data-phone] .U56YlW_inlineDiff [data-diff-body]{box-sizing:border-box;-webkit-text-size-adjust:100%;text-size-adjust:100%;width:100%;min-width:0;font-size:calc(var(--dsw-font-markdown-code-block-font-size,11px) + var(--dsh-content-font-delta,0px));line-height:calc(var(--dsw-font-markdown-code-block-line-height,19px) + var(--dsh-content-font-delta,0px));tab-size:2;overscroll-behavior-x:contain}[data-phone] .U56YlW_inlineDiff [data-diff-row=path]{display:none}[data-phone] .U56YlW_inlineDiff [data-code-block-banner]{gap:8px;min-height:44px;padding:0 8px 0 12px}[data-phone] .U56YlW_inlineDiff [data-code-block-banner] button{width:44px;height:44px}@media (prefers-reduced-motion:reduce){[data-phone] .U56YlW_mobileChevron{transition:none}}`,document.head.appendChild(e)}var Z={card:`U56YlW_card`,chevron:`U56YlW_chevron`,diff:`U56YlW_diff`,diffStatus:`U56YlW_diffStatus`,directory:`U56YlW_directory`,file:`U56YlW_file`,fileHead:`U56YlW_fileHead`,fileName:`U56YlW_fileName`,fileRow:`U56YlW_fileRow`,files:`U56YlW_files`,header:`U56YlW_header`,icon:`U56YlW_icon`,inlineDiff:`U56YlW_inlineDiff`,mobileChevron:`U56YlW_mobileChevron`,mobileFileIcon:`U56YlW_mobileFileIcon`,mobileFullPath:`U56YlW_mobileFullPath`,mobilePath:`U56YlW_mobilePath`,more:`U56YlW_more`,openFile:`U56YlW_openFile`,path:`U56YlW_path`,review:`U56YlW_review`,reviewLabel:`U56YlW_reviewLabel`,text:`U56YlW_text`,title:`U56YlW_title`,titleLink:`U56YlW_titleLink`};let Rb=(0,d.memo)(function({nodeStore:e,turn:t,t:n,useProjection:r,loadTurnDiffs:i,openFile:a}){let o=S(e,t,r),s=(0,d.useMemo)(()=>{let e=/* @__PURE__ */ new Map;for(let t of o){let n=w(t.path);e.set(n,(e.get(n)??0)+1)}return e},[o]),[c,l]=(0,d.useState)(()=>/* @__PURE__ */ new Set),[u,m]=(0,d.useState)(!1),h=Ib(t,o,c,i),g=(0,d.useMemo)(()=>({codeLabel:n(`diff.code`),wrapLabel:n(`diff.wrap`),unwrapLabel:n(`diff.unwrap`),copy:n(`diff.copy`),copied:n(`diff.copied`),collapseAria:n(`diff.collapseAria`),expandAria:e=>n(`diff.expandAria`,{count:e}),collapse:n(`diff.collapse`),expand:e=>n(`diff.expand`,{count:e})}),[n]);if(o.length===0)return null;let{added:_,removed:y}=C(o),[b]=o,x=o.length===1&&b!==void 0?n(`chat.fileEdited`,{name:w(b.path)}):n(`chat.filesEdited`,{count:o.length}),T=o.some(e=>c.has(e.path)),E=u?o:o.slice(0,3),ee=o.length-E.length;return/* @__PURE__ */ (0,f.jsxs)(`section`,{className:Z.card,"data-turn-changes":t,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Z.header,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.icon,"aria-hidden":`true`,children:/* @__PURE__ */ (0,f.jsx)(p.IconFileDiffOutlineRegular,{size:24})}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:Z.text,children:[o.length===1&&b!==void 0&&a!==void 0?/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:`${Z.title} ${Z.titleLink}`,title:n(`chat.openFile`,{path:b.path}),onClick:()=>a(b.path),children:x}):/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.title,title:x,children:x}),/* @__PURE__ */ (0,f.jsx)(v,{added:_,removed:y})]}),/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Z.review,"aria-expanded":T,"aria-label":n(T?`chat.hideChanges`:`chat.viewChanges`),onClick:()=>{l(new Set(T?[]:o.map(e=>e.path))),T||m(!0)},children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.reviewLabel,children:n(T?`chat.hideChanges`:`chat.viewChanges`)}),/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:16,className:Z.mobileChevron,"data-open":T})]})]}),(o.length>1||T)&&/* @__PURE__ */ (0,f.jsxs)(`ul`,{className:Z.files,children:[E.map(e=>{let t=h.diffs(e),r=w(e.path);return/* @__PURE__ */ (0,f.jsxs)(`li`,{className:Z.file,children:[o.length>1&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Z.fileRow,children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Z.fileHead,"aria-expanded":c.has(e.path),onClick:()=>{l(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n})},children:[/* @__PURE__ */ (0,f.jsx)(p.IconFileDiffOutlineRegular,{size:16,className:Z.mobileFileIcon}),/* @__PURE__ */ (0,f.jsx)(p.PathLabel,{path:e.path,className:Z.path}),/* @__PURE__ */ (0,f.jsxs)(`span`,{className:Z.mobilePath,children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.fileName,"aria-hidden":`true`,children:r}),(s.get(r)??0)>1&&/* @__PURE__ */ (0,f.jsx)(`span`,{className:Z.directory,"aria-hidden":`true`,children:e.path.slice(0,e.path.length-r.length)}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:ry.visuallyHidden,children:e.path})]}),/* @__PURE__ */ (0,f.jsx)(v,{added:e.added,removed:e.removed}),/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:16,className:Z.mobileChevron,"data-open":c.has(e.path)})]}),a!==void 0&&/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,className:Z.openFile,"aria-label":n(`chat.openFile`,{path:e.path}),title:n(`chat.openFile`,{path:e.path}),onClick:()=>a(e.path),children:/* @__PURE__ */ (0,f.jsx)(p.IconRightUpOutlineRegular,{size:16})})]}),c.has(e.path)&&/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Z.diff,children:[/* @__PURE__ */ (0,f.jsx)(`div`,{className:Z.mobileFullPath,children:e.path}),t===void 0?h.error?/* @__PURE__ */ (0,f.jsxs)(`div`,{role:`alert`,className:Z.diffStatus,children:[h.error,` `,/* @__PURE__ */ (0,f.jsx)(`button`,{type:`button`,onClick:h.retry,children:n(`chat.retryDiff`)})]}):/* @__PURE__ */ (0,f.jsx)(`span`,{role:`status`,className:Z.diffStatus,children:n(`chat.loadingDiff`)}):/* @__PURE__ */ (0,f.jsx)(p.DiffBlock,{diffs:[...t],labels:g,maxLines:1/0,className:Z.inlineDiff})]})]},e.path)}),o.length>3&&/* @__PURE__ */ (0,f.jsx)(`li`,{children:/* @__PURE__ */ (0,f.jsxs)(`button`,{type:`button`,className:Z.more,"aria-expanded":u,onClick:()=>m(e=>!e),children:[ee>0?n(`chat.showMoreFiles`,{count:ee}):n(`chat.collapseFiles`),/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:16,className:Z.chevron,"data-open":u})]})})]})]})});function zb(e){return e.flatMap(e=>e.kind===`text`?[e.text]:[]).join(``)}function Bb(e){return e.some(e=>e.kind===`reasoning`||e.kind===`tool-call`?!1:e.kind!==`text`||e.text.trim()!==``)}let Vb=`@deepseek-ai/dsh-client-ui-chat/TurnTailNodeView.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Vb)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Vb,e.textContent=`.zJ_1ta_root{flex-direction:column;gap:16px;display:flex}.zJ_1ta_actions{margin-top:4px;margin-left:-6px}`,document.head.appendChild(e)}var Hb={actions:`zJ_1ta_actions`,root:`zJ_1ta_root`};function Ub(e,t,n){let r=e.locations.getTurn(t);for(let t=r.length-1;t>=0;t--){let i=e.nodes.get(r[t]);if(!(i===void 0||i.kind===`turn-tail`||i.kind===`turn-process`||n&&i.kind===`turn-max-tokens`))return i}}let Wb=(0,d.memo)(function({node:e,openFile:t,forkAt:n,handoffAt:r,loadTurnDiffs:i,renderSlot:a,t:o,useChat:s,useSession:c,useProjection:l}){let u=c(e=>e.openState===`open`),p=(0,d.useRef)(!1),[m,h]=(0,d.useState)(!1),[g,_]=(0,d.useState)(),v=e.data,y=s(e=>e.nodes),b=s(e=>(Ub(e,v.turn,!0)?.anchorSeq??-1)>(v.closing?.finalNode.seq??v.seq)),x=s(e=>{if(e.timeline.turnOrder.at(-1)!==v.turn)return!1;let t=Ub(e,v.turn,!1),n=t?.kind===`assistant-step`?t.data.blocks.findLast(e=>e.kind!==`text`&&e.kind!==`reasoning`||e.text.trim()!==``):void 0;return n!==void 0&&Bb([n])}),S=e.location.kind===`turn`||e.location.kind===`step`?e.location.turn:void 0,C=Zg(l,S?.turn,`end`);if(S===void 0)return null;let w=v.closing,T=a(`conversation.chat.turnTail`,{turn:S,seq:w?.finalNode.seq??v.seq,openFile:t});if(w===null)return T===null?null:/* @__PURE__ */ (0,f.jsx)(`div`,{className:Hb.root,"data-turn-tail":v.turn,children:T});let E=w.finalNode.messageId,ee=E===void 0?null:a(`conversation.chat.assistant-actions`,{messageId:E});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:Hb.root,"data-turn-tail":v.turn,"data-actions-reveal":x?`always`:`hover`,children:[/* @__PURE__ */ (0,f.jsx)(Rb,{nodeStore:y,turn:v.turn,t:o,useProjection:l,loadTurnDiffs:i,openFile:t}),T,/* @__PURE__ */ (0,f.jsx)(Lg,{text:zb(w.blocks),time:C,clock:`end`,onBranch:n===void 0?void 0:()=>{!p.current&&u&&(p.current=!0,h(!0),_(void 0),n(v.seq).catch(e=>{_(e instanceof Error?e.message:String(e))}).finally(()=>{p.current=!1,h(!1)}))},branchUnavailable:!u||m||v.branchUnavailable||b,onHandoff:r===void 0?void 0:()=>{u&&r(v.seq)},handoffUnavailable:!u||v.branchUnavailable||b,className:Hb.actions,extraActions:ee,t:o}),g!==void 0&&/* @__PURE__ */ (0,f.jsx)(`p`,{role:`alert`,children:o(`message.branchFailed`,{message:g})})]})});function Gb(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function Kb(e,t){return typeof e[t]==`string`?e[t]:``}function qb(e){let t=Gb(e.source),n=Kb(t,`kind`),r=`message.trigger.request`,i=`request`;switch(n){case`goal`:r=`message.trigger.goal`,i=`goal`;break;case`agent-message`:r=`message.trigger.agent`,i=`agent`;break;case`team-message`:r=`message.trigger.team`,i=`team`;break;case`subagent-settled`:r=`message.trigger.subagent`,i=`subagent`;break;case`webhook`:{let e=Kb(t,`provider`)===`github`;r=e?`message.trigger.github`:`message.trigger.webhook`,i=e?`github`:`webhook`;break}case`schedule`:r=`message.trigger.schedule`,i=`schedule`;break;case`tool-jobs`:r=`message.trigger.job`,i=`job`;break;case`cordis-host-runner`:r=`message.trigger.plugin`,i=`plugin`}return{title:r,icon:i}}let Jb=`@deepseek-ai/dsh-client-ui-chat/TurnTriggerNodeView.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Jb)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=Jb,e.textContent=`.kkOUVW_root{border:.5px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-xl);background:var(--dsw-alias-turn-trigger-bg,var(--dsw-alias-markdown-code-block));min-width:0;transition:background-color .1s}@media (hover:hover){.kkOUVW_root:hover{background:var(--dsw-alias-turn-trigger-bg-hover,var(--dsw-alias-interactive-bg-hover))}}.kkOUVW_header{width:100%;color:var(--dsw-alias-label-tertiary);font:inherit;text-align:left;cursor:pointer;background:0 0;border:0;align-items:center;gap:10px;padding:12px 16px;transition:color .1s;display:flex}@media (hover:hover){.kkOUVW_header:hover{color:var(--dsw-alias-label-secondary)}}.kkOUVW_header:active{color:var(--dsw-alias-label-secondary)}.kkOUVW_icon{color:inherit;flex:none;display:inline-flex}.kkOUVW_title{font-size:var(--dsh-content-font-size,14px);flex:none}.kkOUVW_time{color:inherit;font:var(--dsw-font-xxs-12);flex:none;margin-left:auto}.kkOUVW_chevron,.kkOUVW_openChevron{color:inherit;flex:none}.kkOUVW_openChevron{transform:rotate(180deg)}.kkOUVW_body{padding:0 16px 12px 40px}.kkOUVW_explanation{color:var(--dsw-alias-label-secondary);font:var(--dsw-font-xxs-12);margin:8px 0}.kkOUVW_content{white-space:pre-wrap;overflow-wrap:anywhere;max-height:240px;font:var(--dsw-font-xxs-12);overflow:auto}@media (prefers-reduced-motion:reduce){.kkOUVW_root,.kkOUVW_header{transition:none}}`,document.head.appendChild(e)}var Yb={body:`kkOUVW_body`,chevron:`kkOUVW_chevron`,content:`kkOUVW_content`,explanation:`kkOUVW_explanation`,header:`kkOUVW_header`,icon:`kkOUVW_icon`,openChevron:`kkOUVW_openChevron`,root:`kkOUVW_root`,time:`kkOUVW_time`,title:`kkOUVW_title`};let Xb={request:p.IconContextInjectionOutlineRegular,goal:p.IconGoalOutlineRegular,agent:p.IconPaperPlaneOutlineRegular,team:p.IconAgentPresetOutlineRegular,subagent:p.IconAgentPresetOutlineRegular,github:p.IconBranchOutlineRegular,webhook:p.IconGlobeOutlineRegular,schedule:p.IconClockOutlineRegular,job:p.IconQueueOutlineRegular,plugin:p.IconCordisPluginOutlineRegular};function Zb({node:e,t}){let[n,r]=(0,d.useState)(!1),i=(0,d.useId)(),a=qb(e.data),o=Xb[a.icon],s=new Date(e.data.time),c=kg(e.data.time,t);return/* @__PURE__ */ (0,f.jsxs)(`section`,{className:Yb.root,"data-turn-trigger":!0,children:[/* @__PURE__ */ (0,f.jsxs)(`button`,{className:Yb.header,type:`button`,"aria-expanded":n,"aria-controls":i,onClick:()=>{r(!n)},children:[/* @__PURE__ */ (0,f.jsx)(`span`,{className:Yb.icon,"aria-hidden":!0,children:/* @__PURE__ */ (0,f.jsx)(o,{size:14})}),/* @__PURE__ */ (0,f.jsx)(`span`,{className:Yb.title,children:t(a.title)}),/* @__PURE__ */ (0,f.jsx)(`time`,{className:Yb.time,dateTime:s.toISOString(),children:c}),/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{size:12,className:n?Yb.openChevron:Yb.chevron})]}),n&&/* @__PURE__ */ (0,f.jsxs)(`div`,{id:i,className:Yb.body,children:[/* @__PURE__ */ (0,f.jsx)(`p`,{className:Yb.explanation,children:t(`message.trigger.explanation`)}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:Yb.content,children:/* @__PURE__ */ (0,f.jsx)(hg,{content:e.data.content,source:e.data.source,t})})]})]})}function Qb(e,t){e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`user`,locale:ab,inject:t=>({links:e.get(`chatLinks`),sessionId:t})},m_)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`steering`,locale:ab,inject:t=>({links:e.get(`chatLinks`),sessionId:t})},m_)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`context`,locale:ab},g_)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-trigger`,locale:ab},Zb)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`system-prompt`,locale:ab},Mb)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`assistant-step`,locale:ab,inject:()=>({hooks:{presentation:t}})},Sb)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`command`,locale:ab,children:{"conversation.chat.commandview":{kind:`keyed`,scope:`session`}}},kb)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`manual-compaction`,locale:ab},Ab)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`compaction`,locale:ab},__)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`model-retry`,locale:ab},v_)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-error`,locale:ab},y_)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-max-tokens`,locale:ab},b_)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-process`,locale:ab},Fb)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`turn-tail`,locale:ab,children:{"conversation.chat.turnTail":{kind:`list`,scope:`session`},"conversation.chat.assistant-actions":{kind:`list`,scope:`session`}}},Wb)),e.slots.inject(`conversation.chat.node`,()=>e.slots.register({name:`conversation.chat.node`,key:`unknown`,locale:ab},x_))}let $b={interruptedAssistant:-.9,interruptedFollowup:-.8,processControl:-.1,maxTokensNotice:.05,finalizedFollowup:.1};function ex(e){return e.start?.location??e.matches[0]?.location??{kind:`unresolved`}}function tx(e,t,n,r,i={}){return{key:e.key,kind:t,id:e.id,target:`chat`,anchorSeq:n,location:i.location??ex(e),visibility:i.visibility??`visible`,data:r}}function nx(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function rx(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function ix(e,t,n){let r=e[t];if(!Array.isArray(r))return[];let i=[];for(let e of r){let t=nx(e),r=t===null?null:rx(t,n);r!==null&&!i.includes(r)&&i.push(r)}return i}function ax(e){return e.length>0?e.join(`, `):null}let ox=[`instructions`,`catalog`,`snapshot`,`notice`,`relay`,`recall`];function sx(e){let t=nx(e),n=t===null?null:rx(t,`form`);return n!==null&&ox.includes(n)?n:null}function cx(e){let t=nx(e),n=t===null?null:rx(t,`kind`);if(t===null||n===null)return{role:`inject`,label:null};switch(n){case`session-reference`:return{role:`recall`,label:ax(ix(t,`references`,`label`))??n};case`agent-instructions`:return{role:`inject`,label:ax(ix(t,`changes`,`path`))??n};case`skill-invocation`:return{role:`inject`,label:rx(t,`name`)??n};default:return{role:`inject`,label:n}}}function lx(e){let t=nx(e);return t===null||rx(t,`kind`)!==`session-reference`?[]:ix(t,`references`,`label`)}function ux(e){let t=nx(e);return t===null||rx(t,`kind`)!==`skill-invocation`?null:rx(t,`name`)}function dx(e){return e.map(fx)}function fx(e){switch(e.type){case`text`:return{kind:`text`,text:e.text};case`reasoning`:return{kind:`reasoning`,text:e.text};case`image`:return e.codexhostImageView===!0?{kind:`viewed-images`,attachment:e.attachment}:{kind:`image`,attachment:e.attachment};case`tool-call`:return{kind:`tool-call`,callId:String(e.id),name:e.name,argsRaw:e.arguments};default:return{kind:`other`,block:e}}}function px(e){switch(e){case`text`:return{kind:`text`,text:``};case`reasoning`:return{kind:`reasoning`,text:``};case`tool-call`:return{kind:`tool-call`,callId:``,name:``,argsRaw:``};default:return{kind:`other`,block:null}}}function mx(e){if(typeof e!=`object`||!e)return{message:String(e)};let t=e,n=typeof t.code==`string`?t.code:void 0;return n===`AUTH`?{code:n,message:``}:{...n===void 0?{}:{code:n},message:typeof t.message==`string`?t.message:JSON.stringify(e)}}function hx(e){switch(e.type){case`text-delta`:case`reasoning-delta`:return e.text!==``;case`tool-call-delta`:return e.argumentsDelta!==``||e.name!==void 0;default:return!1}}function gx(e,t){return{turn:e,step:t,blocks:[],visibleByIndex:[],visibleBlocks:0,firstVisibleSeq:void 0,firstVisibleTime:void 0,firstTokenTime:void 0,final:void 0,usage:void 0}}function _x(e){return e.filter(e=>e!==void 0)}function vx(e){return e===void 0||e.kind===`tool-call`?!1:e.kind===`text`||e.kind===`reasoning`?e.text.trim()!==``:!0}function yx(e){return e.some(vx)}function bx(e){return e.some(e=>e.kind===`text`||e.kind===`reasoning`?e.text.trim()!==``:!0)}function xx(e){return{...gx(e.turn,e.step),firstTokenTime:e.firstTokenTime}}function Sx(e,t,n,r){if(t.type===`tool-call-delta`){let n=e.blocks[t.index];if(n?.kind===`tool-call`&&n.callId!==``&&(t.name===void 0||t.name===n.name)&&(e.firstTokenTime!==void 0||!hx(t)))return e}let i=[...e.blocks],a=-1,o=!1,s=!1;switch(t.type){case`block-start`:a=t.index,o=e.visibleByIndex[t.index]===!0,i[t.index]=px(t.blockType),s=vx(i[t.index]);break;case`text-delta`:{let n=i[t.index];a=t.index,o=e.visibleByIndex[t.index]===!0,i[t.index]={kind:`text`,text:(n?.kind===`text`?n.text:``)+t.text},s=n?.kind===`text`&&o||t.text.trim()!==``;break}case`reasoning-delta`:{let n=i[t.index];a=t.index,o=e.visibleByIndex[t.index]===!0,i[t.index]={kind:`reasoning`,text:(n?.kind===`reasoning`?n.text:``)+t.text},s=n?.kind===`reasoning`&&o||t.text.trim()!==``;break}case`tool-call-delta`:{let n=i[t.index];a=t.index,o=e.visibleByIndex[t.index]===!0,i[t.index]={kind:`tool-call`,callId:(n?.kind===`tool-call`?n.callId:``)||String(t.id),name:t.name??(n?.kind===`tool-call`?n.name:``),argsRaw:n?.kind===`tool-call`?n.argsRaw:``};break}case`block-end`:a=t.index,o=e.visibleByIndex[t.index]===!0,i[t.index]=fx(t.block),s=vx(i[t.index]);break;case`usage`:return{...e,usage:t.usage};default:return e}let c=e.visibleBlocks-Number(o)+Number(s),l=e.visibleByIndex;if(o!==s){let e=[...l];e[a]=s,l=e}let u=hx(t);return{...e,blocks:i,visibleByIndex:l,visibleBlocks:c,...c>0&&e.firstVisibleSeq===void 0?{firstVisibleSeq:n,firstVisibleTime:r}:{},...u&&e.firstTokenTime===void 0?{firstTokenTime:r}:{}}}function Cx(e,t,n){let r=dx(n.data.message.content),i=r.map(vx);return{...e,blocks:r,visibleByIndex:i,visibleBlocks:i.reduce((e,t)=>e+Number(t),0),final:t,usage:n.data.usage}}function wx(e){if(e.kind===`step`&&e.step.status===`closed`&&e.step.end!==void 0)return e.step.end;if((e.kind===`step`||e.kind===`turn`)&&e.turn.status===`closed`&&e.turn.end!==void 0)return e.turn.end}function Tx(e,t){let n=e.final;if(n?.event.type===`assistant/message`){let r=n.event;return{kind:`assistant`,seq:r.seq,messageId:r.data.message.id,time:r.time,turn:e.turn,step:e.step,blocks:dx(r.data.message.content),usage:r.data.usage,timing:{stepStartTime:t.start?.event.time??null,firstTokenTime:e.firstTokenTime??null,completedTime:r.time},...r.data.interrupted===!0?{interrupted:!0}:{}}}let r=t.start?.location??t.matches.at(-1)?.location,i=r===void 0?void 0:wx(r);if(i===void 0)return;let a=_x(e.blocks);if(bx(a))return{kind:`assistant`,seq:i.seq+$b.interruptedAssistant,time:i.time,turn:e.turn,step:e.step,blocks:a,interrupted:!0}}function Ex(e){let t;for(let n of e.matches)n.event.type===`assistant/live-chunk`?(t??=gx(n.event.data.turn,n.event.data.step),t=Sx(t,n.event.data.chunk,n.event.seq,n.event.time)):n.event.type===`assistant/message`?(t??=gx(n.event.data.turn,n.event.data.step),t=Cx(t,n,n.event)):n.event.type===`llm/retry`&&t!==void 0&&(t=xx(t));return t}function Dx(e){let t=e.state??Ex(e);if(t===void 0)return;let n=Tx(t,e),r=n?.blocks??_x(t.blocks),i=n===void 0?t.visibleBlocks>0:yx(r),a=n?.interrupted===!0?`interrupted`:n===void 0?`running`:`settled`,o=(n?.interrupted===!0?n.seq:t.firstVisibleSeq??n?.seq)??e.matches[0]?.event.seq??0,s=n?.time??t.firstVisibleTime??e.matches[0]?.event.time??0;return{anchorSeq:o,visible:i,settled:n,data:{status:a,turn:t.turn,step:t.step,blocks:r,time:s,...t.usage===void 0?{}:{usage:t.usage},...n===void 0?{}:{finalNode:n}}}}function Ox(e){let t=e.start?.location??e.matches.at(-1)?.location;return t?.kind===`step`?t.step.data.get(`assistant-step`):void 0}let kx={kind:`assistant-step`,target:`chat`,match:e=>e.type===`step/start`?{id:`${e.data.turn}:${e.data.step}`,role:`start`}:e.type===`assistant/live-chunk`||e.type===`assistant/message`&&e.surfaceOp===`append`||e.type===`llm/retry`?{id:`${e.data.turn}:${e.data.step}`,role:`update`}:null,start:(e,t)=>{if(t.event.type!==`step/start`)throw Error(`assistant-step start requires step/start`);return gx(t.event.data.turn,t.event.data.step)},update:(e,t)=>t.event.type===`assistant/live-chunk`?Sx(e.state,t.event.data.chunk,t.event.seq,t.event.time):t.event.type===`assistant/message`?Cx(e.state,t,t.event):t.event.type===`llm/retry`?xx(e.state):e.state,publication:e=>{if(e.event.type===`step/start`)return`none`;if(e.event.type!==`assistant/live-chunk`)return`immediate`;let t=e.event.data.chunk.type;return t===`usage`||t===`finish`?`none`:`animation-frame`},buildLocationData:(e,t)=>{if(t!==`step`)return null;let n=Dx(e);return n===void 0?null:{kind:`step`,turn:n.data.turn,step:n.data.step,key:`assistant-step`,value:n.data}},buildViewNode:e=>{let t=e.current.get(`chat`),n=e.state??Ex(e),r=Ox(e);if(n===void 0||r===void 0)return t==null?null:{...t,visibility:`hidden`};let i=r.finalNode,a=i===void 0?n.visibleBlocks>0:yx(r.blocks);return i===void 0&&!a&&t==null?null:tx(e,`assistant-step`,(i?.interrupted===!0?i.seq:n.firstVisibleSeq??i?.seq)??e.matches[0]?.event.seq??0,r,{visibility:i?.interrupted===!0||a?`visible`:`hidden`})}};function Ax(e){let t=kx.match.bind(kx);e.uiConversation.events.register({...kx,match:{"step/start":t,"assistant/live-chunk":t,"assistant/message":t,"llm/retry":t}})}function jx(e){return`kind`in e}function Mx(e){return!jx(e)}function Nx(e){return e.visibility===`visible`&&e.kind!==`system-prompt`&&(e.kind!==`context`||e.data.content.some(e=>e.type===`tool-addition`||e.type===`tool-removal`))&&(e.kind!==`command`||e.data.name!==`permission`)}function Px(e,t){let n=``,r=!1;for(let i of e){if(n.length>=t*2){r=!0;break}let e=i.length>t*2,a=e?i.slice(0,t*2):i;if(n+=n===``?a:` ${a}`,e){r=!0;break}}let i=n.replace(/\s+/g,` `).trim();return i.length>t-1?`${i.slice(0,t-1).trimEnd()}…`:r?`${i}…`:i}function Fx(e){return e.kind===`user`?Px(e.data.content.flatMap(e=>e.type===`text`?[e.text]:[]),50):``}function Ix(e){return e.kind===`assistant-step`?Px(e.data.blocks.flatMap(e=>e.kind===`text`?[e.text]:[]),120):``}function Lx(e,t){return e===void 0||t===void 0?e===t:e.turn===t.turn&&e.anchorKey===t.anchorKey&&e.prompt===t.prompt&&e.response===t.response}function Rx(e,t,n){let r=t.getTurn(e).map(e=>n.get(e)).filter(e=>e!==void 0&&Nx(e)),i=r.find(e=>e.kind===`user`),a=i??r[0];if(a===void 0)return;let o=r.findLast(e=>Ix(e)!==``);return{turn:e,anchorKey:a.key,prompt:i===void 0?``:Fx(i),response:o===void 0?``:Ix(o)}}function zx(e){let t=e?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn.turn:void 0}function Bx(e,t){return e===t||e!==void 0&&t!==void 0&&e.spec===t.spec&&e.turn===t.turn&&e.turnStarted===t.turnStarted&&e.turnClosed===t.turnClosed&&e.hasExternalProcess===t.hasExternalProcess&&e.hasInterleavedInput===t.hasInterleavedInput&&e.compactAnswer===t.compactAnswer}function Vx(e,t,n){let r=t.getTurn(e),i=r.map(e=>n.get(e)).find(e=>e?.kind===`turn-process`);if(i===void 0)return;let a=i.data,o=i.location;if(o.kind!==`turn`&&o.kind!==`step`)return;let s;for(let e of r){let t=n.get(e);(t?.kind===`user`||t?.kind===`steering`||t?.kind===`turn-trigger`)&&(a.controlAnchorSeq===o.turn.start?.seq||t.anchorSeq<a.controlAnchorSeq)&&(s=Math.max(s??t.anchorSeq,t.anchorSeq))}let c=!1,l=!1,u=!0;for(let e of r){let t=n.get(e);t!==void 0&&Nx(t)&&t.kind!==`turn-process`&&((t.kind===`user`||t.kind===`steering`||t.kind===`turn-trigger`)&&(s===void 0||t.anchorSeq>s)&&(l=!0,(a.answerAnchorSeq===null||t.anchorSeq<a.answerAnchorSeq)&&(u=!1)),!(S_.has(t.kind)||t.anchorSeq<a.processStartSeq)&&(t.kind!==`assistant-step`||a.answerStep===null||t.data.step!==a.answerStep)&&(c=!0))}return{turn:e,spec:a,turnStarted:o.turn.start!==void 0,turnClosed:o.turn.status===`closed`,hasExternalProcess:c,hasInterleavedInput:l,compactAnswer:u}}var Hx=class{presentations=/* @__PURE__ */ new Map;get(e){let t=zx(e);return t===void 0?void 0:this.presentations.get(t)}replace(e,t,n){let r=/* @__PURE__ */ new Set;for(let t of e){let e=zx(n.get(t));e!==void 0&&r.add(e)}let i=/* @__PURE__ */ new Set;for(let e of/* @__PURE__ */ new Set([...this.presentations.keys(),...r]))this.set(e,r.has(e)?Vx(e,t,n):void 0)&&i.add(e);return i}update(e,t,n){let r=/* @__PURE__ */ new Set;for(let i of e)this.set(i,Vx(i,t,n))&&r.add(i);return r}set(e,t){return!Bx(this.presentations.get(e),t)&&(t===void 0?this.presentations.delete(e):this.presentations.set(e,t),!0)}};let Ux=[],Wx=[],Gx=[],Kx=[];function qx(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function Jx(e,t,n){let r=e.get(t);return r===void 0&&(r=n(),e.set(t,r)),r}var Yx=class{read;label;listeners=/* @__PURE__ */ new Set;published;constructor(e,t){this.read=e,this.label=t,this.published=e()}getSnapshot=()=>this.read();subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});publish(){let e=this.getSnapshot();this.published!==e&&(this.published=e,(0,m.notifySubscribers)(this.listeners,this.label))}},Xx=class{nodes=/* @__PURE__ */ new Map;current=Kx;dirty=!1;observable;source(){return this.observable??=new Yx(()=>this.read(),`[ui-chat] turn kind nodes`)}set(e){let t=this.nodes.get(e.key);this.nodes.set(e.key,e),(t===void 0||t.data!==e.data||t.anchorSeq!==e.anchorSeq)&&(this.dirty=!0)}delete(e){this.nodes.delete(e),this.dirty=!0}publish(){this.observable?.publish()}read(){return this.dirty&&=(this.current=[...this.nodes.values()].sort((e,t)=>e.anchorSeq-t.anchorSeq).map(e=>e.data),!1),this.current}},Zx=class{byKey=/* @__PURE__ */ new Map;turnProcesses=new Hx;sources=/* @__PURE__ */ new Map;processSources=/* @__PURE__ */ new Map;dirtyKeys=/* @__PURE__ */ new Set;dirtyProcessKeys=/* @__PURE__ */ new Set;turnKinds=/* @__PURE__ */ new Map;dirtyTurnKinds=/* @__PURE__ */ new Set;valuesCache=Kx;valuesDirty=!1;get(e){return this.byKey.get(e)}source(e){return Jx(this.sources,e,()=>new Yx(()=>this.get(e),`[ui-chat] node source ${e}`))}turnDataSource(e,t){return this.turnKind(e,t).source()}turnKind(e,t){return Jx(Jx(this.turnKinds,e,()=>/* @__PURE__ */ new Map),t,()=>new Xx)}updateTurnKind(e,t){let n=e===void 0?void 0:nS(e.location).turn,r=t===void 0?void 0:nS(t.location).turn;if(e!==void 0&&n!==void 0&&(n!==r||e.kind!==t?.kind)){let t=this.turnKind(n,e.kind);t.delete(e.key),this.dirtyTurnKinds.add(t)}if(t!==void 0&&r!==void 0){let e=this.turnKind(r,t.kind);e.set(t),this.dirtyTurnKinds.add(e)}}processSource(e){return Jx(this.processSources,e,()=>new Yx(()=>this.process(e),`[ui-chat] node process source ${e}`))}process(e){return this.turnProcesses.get(this.get(e))}values(){return this.valuesDirty&&=(this.valuesCache=[...this.byKey.values()],!1),this.valuesCache}replace(e){let t=new Map(this.byKey);this.byKey.clear();for(let n of e)this.byKey.set(n.key,n),t.get(n.key)!==n&&(this.updateTurnKind(t.get(n.key),n),this.dirtyKeys.add(n.key),this.dirtyProcessKeys.add(n.key)),t.delete(n.key);for(let e of t.keys())this.updateTurnKind(t.get(e),void 0),this.dirtyKeys.add(e),this.dirtyProcessKeys.add(e);this.valuesCache=[...this.byKey.values()],this.valuesDirty=!1}upsert(e){let t=!1;for(let n of e)this.byKey.get(n.key)!==n&&(this.updateTurnKind(this.byKey.get(n.key),n),this.byKey.set(n.key,n),this.dirtyKeys.add(n.key),this.dirtyProcessKeys.add(n.key),t=!0);t&&(this.valuesDirty=!0)}touchProcesses(e,t){for(let n of e)for(let e of t.getTurn(n))this.dirtyProcessKeys.add(e)}replaceProcesses(e,t){this.touchProcesses(this.turnProcesses.replace(e,t,this),t)}updateProcesses(e,t){this.touchProcesses(this.turnProcesses.update(e,t,this),t)}publish(){let e=[...this.dirtyKeys],t=[...this.dirtyProcessKeys],n=[...this.dirtyTurnKinds];this.dirtyKeys.clear(),this.dirtyProcessKeys.clear(),this.dirtyTurnKinds.clear();for(let t of e)this.sources.get(t)?.publish();for(let e of t)this.processSources.get(e)?.publish();for(let e of n)e.publish()}},Qx=class{turns=/* @__PURE__ */ new Map;steps=/* @__PURE__ */ new Map;positions=/* @__PURE__ */ new Map;getTurn(e){return this.turns.get(e)??Ux}getStep(e,t){return this.steps.get(tS(e,t))??Ux}getPosition(e){return this.positions.get(e)}rebuild(e,t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Set;for(let[o,s]of e.entries()){let c=t.get(s)?.location;if(c===void 0)continue;let l=nS(c),u=this.positions.get(s),d={turn:l.turn,previous:e[o-1],next:e[o+1]},f=u!==void 0&&u.turn===d.turn&&u.previous===d.previous&&u.next===d.next;if(i.set(s,f?u:d),f||(u?.turn!==void 0&&a.add(u.turn),d.turn!==void 0&&a.add(d.turn)),l.turn===void 0)continue;let p=n.get(l.turn)??[];if(p.push(s),n.set(l.turn,p),l.step===void 0)continue;let m=tS(l.turn,l.step),h=r.get(m)??[];h.push(s),r.set(m,h)}for(let[e,t]of this.positions)!i.has(e)&&t.turn!==void 0&&a.add(t.turn);return this.positions=i,this.turns=$x(this.turns,n),this.steps=$x(this.steps,r),[...a]}touch(e){let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Set;for(let r of e){let e=nS(r.location);e.turn!==void 0&&this.turns.get(e.turn)?.includes(r.key)&&(t.add(e.turn),e.step!==void 0&&n.add(tS(e.turn,e.step)))}for(let e of t){let t=this.turns.get(e);t!==void 0&&this.turns.set(e,[...t])}for(let e of n){let t=this.steps.get(e);t!==void 0&&this.steps.set(e,[...t])}}};function $x(e,t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Set([...e.keys(),...t.keys()]);for(let i of r){let r=e.get(i)??Ux,a=t.get(i)??Ux,o=qx(r,a)?r:a;a.length>0&&n.set(i,o)}return n}var eS=class{current=Gx;byTurn=/* @__PURE__ */ new Map;items(){return this.current}rebuild(e,t,n){let r=[],i=/* @__PURE__ */ new Map;for(let a of e.turnOrder){let e=Rx(a,t,n);if(e===void 0)continue;let o=this.byTurn.get(a),s=o!==void 0&&Lx(o,e)?o:e;r.push(s),i.set(a,s)}this.byTurn=i,r.length===this.current.length&&r.every((e,t)=>e===this.current[t])||(this.current=r)}touch(e,t,n){if(e.size===0)return;let r=this.current.map(r=>{if(!e.has(r.turn))return r;let i=Rx(r.turn,t,n);return i===void 0||Lx(r,i)?r:(this.byTurn.set(r.turn,i),i)});r.some((e,t)=>e!==this.current[t])&&(this.current=r)}};function tS(e,t){return`${e}:${t}`}function nS(e){return e.kind===`step`?{turn:e.turn.turn,step:e.step.step}:e.kind===`turn`?{turn:e.turn.turn}:{}}function rS(e){return e.kind===`turn`||e.kind===`step`?e.turn.status:void 0}function iS(e,t,n){return n||e===void 0||rS(e.location)!==rS(t.location)?!0:e.kind===`turn-process`&&t.kind===`turn-process`?e.data!==t.data:e.kind===`assistant-step`&&t.kind===`assistant-step`&&e.data.step!==t.data.step}function aS(e){let t=/* @__PURE__ */ new Map;for(let n of e){let e=n;e.kind===`turn-process`&&t.set(e.data.turn,{...t.get(e.data.turn),control:e})}for(let n of e){let e=n,r=e.location;if(r.kind!==`turn`&&r.kind!==`step`)continue;let i=t.get(r.turn.turn)??{},a=i.control?.data.controlAnchorSeq;(e.kind===`user`||e.kind===`turn-trigger`||e.kind===`steering`)&&a!==void 0&&(a===r.turn.start?.seq||e.anchorSeq<a)?t.set(r.turn.turn,{...i,openingInputAnchor:Math.max(i.openingInputAnchor??e.anchorSeq,e.anchorSeq)}):S_.has(e.kind)||t.set(r.turn.turn,{...i,earliestProcessAnchor:Math.min(i.earliestProcessAnchor??e.anchorSeq,e.anchorSeq)})}return t}function oS(e,t){let n=e,r=n.location;if(r.kind!==`turn`&&r.kind!==`step`)return{anchor:n.anchorSeq,rank:0,originalAnchor:n.anchorSeq};let i=t.get(r.turn.turn);if(i===void 0)return{anchor:n.anchorSeq,rank:0,originalAnchor:n.anchorSeq};let a=i.openingInputAnchor;return a!==void 0&&n.anchorSeq<a&&!S_.has(n.kind)?{anchor:a,rank:2,originalAnchor:n.anchorSeq}:i.control!==void 0&&n.key===i.control.key?a===void 0?{anchor:i.earliestProcessAnchor??n.anchorSeq,rank:-1,originalAnchor:n.anchorSeq}:{anchor:a,rank:1,originalAnchor:n.anchorSeq}:{anchor:n.anchorSeq,rank:0,originalAnchor:n.anchorSeq}}function sS(e){let t=e.filter(e=>Nx(e)),n=aS(t);return t.sort((e,t)=>{let r=oS(e,n),i=oS(t,n);return r.anchor-i.anchor||r.rank-i.rank||r.originalAnchor-i.originalAnchor||e.key.localeCompare(t.key)})}function cS(e){let t=e;return t.kind===`user`||t.kind===`steering`?t.data.seq:void 0}function lS(e){let t=e;if(t.kind===`context`)return{messageSeq:t.data.seq-1,labels:lx(t.data.source)}}function uS(e,t){let n=e;if(n.kind!==`user`&&n.kind!==`steering`)return e;let r=n.data.referenceLabels??Ux,i=Object.hasOwn(n.data,`referenceLabels`);if(qx(r,t)&&i===t.length>0)return e;let a={...n.data};return t.length===0?delete a.referenceLabels:a.referenceLabels=t,{...n,data:a}}var dS=class{messagesBySeq=/* @__PURE__ */ new Map;labelsByMessageSeq=/* @__PURE__ */ new Map;replace(e){this.messagesBySeq.clear(),this.labelsByMessageSeq.clear();for(let t of e){let e=cS(t);e!==void 0&&this.messagesBySeq.set(e,t.key);let n=lS(t);n!==void 0&&n.labels.length>0&&this.labelsByMessageSeq.set(n.messageSeq,n.labels)}return e.map(e=>{let t=cS(e);return t===void 0?e:uS(e,this.labelsByMessageSeq.get(t)??Ux)})}apply(e,t){let n=new Map(e.map(e=>[e.key,e])),r=/* @__PURE__ */ new Set;for(let t of e){let e=cS(t);e!==void 0&&(this.messagesBySeq.set(e,t.key),r.add(e));let n=lS(t);if(n===void 0)continue;let i=this.labelsByMessageSeq.get(n.messageSeq);n.labels.length===0?this.labelsByMessageSeq.delete(n.messageSeq):this.labelsByMessageSeq.set(n.messageSeq,i!==void 0&&qx(i,n.labels)?i:n.labels),r.add(n.messageSeq)}for(let e of r){let r=this.messagesBySeq.get(e);if(r===void 0)continue;let i=n.get(r)??t.get(r);i!==void 0&&n.set(r,uS(i,this.labelsByMessageSeq.get(e)??Ux))}return[...n.values()]}};function fS(e,t){let n=e;if(n.kind!==`user`&&n.kind!==`steering`)return e;let r=n.data.skillNames??Ux,i=Object.hasOwn(n.data,`skillNames`);if(qx(r,t)&&i===t.length>0)return e;let a={...n.data};return t.length===0?delete a.skillNames:a.skillNames=t,{...n,data:a}}function pS(e){let t=e;if(t.kind===`user`||t.kind===`steering`)return{key:e.key,seq:e.anchorSeq,kind:`message`,name:null};if(t.kind===`context`){let n=ux(t.data.source);return n===null?null:{key:e.key,seq:e.anchorSeq,kind:`skill`,name:n}}return{key:e.key,seq:e.anchorSeq,kind:`boundary`,name:null}}function mS(e,t){return e.seq===t.seq&&e.kind===t.kind&&e.name===t.name}var hS=class{entries=/* @__PURE__ */ new Map;sorted=[];replace(e){this.entries.clear(),this.sorted=[];for(let t of e){let e=pS(t);e!==null&&(this.entries.set(e.key,e),this.sorted.push(e))}this.sorted.sort((e,t)=>e.seq-t.seq);let t=/* @__PURE__ */ new Map;for(let e=0;e<this.sorted.length;e++){if(this.sorted[e]?.kind===`boundary`)continue;let n=this.runEnd(e);this.assignRun(e,n,t),e=n}return e.map(e=>fS(e,t.get(e.key)??Ux))}apply(e,t){let n=[];for(let t of e){let e=pS(t),r=this.entries.get(t.key);if(r!==void 0){if(e!==null&&mS(r,e)){e.kind===`message`&&n.push(e.seq);continue}this.remove(r),n.push(r.seq)}e!==null&&(this.insert(e),n.push(e.seq))}if(n.length===0)return e;let r=/* @__PURE__ */ new Map;for(let e of n)this.collectAround(e,r);let i=new Map(e.map(e=>[e.key,e]));for(let[e,n]of r){let r=i.get(e)??t.get(e);if(r===void 0)continue;let a=fS(r,n);(a!==r||i.has(e))&&i.set(e,a)}return[...i.values()]}insert(e){this.sorted.splice(this.lowerBound(e.seq),0,e),this.entries.set(e.key,e)}remove(e){this.sorted.splice(this.sorted.indexOf(e),1),this.entries.delete(e.key)}lowerBound(e){let t=0,n=this.sorted.length;for(;t<n;){let r=t+n>>>1;(this.sorted[r]?.seq??1/0)<e?t=r+1:n=r}return t}runEnd(e){let t=e;for(;t+1<this.sorted.length&&this.sorted[t+1]?.kind!==`boundary`;)t++;return t}runStart(e){let t=e;for(;t-1>=0&&this.sorted[t-1]?.kind!==`boundary`;)t--;return t}assignRun(e,t,n){let r=[];for(let n=e;n<=t;n++){let e=this.sorted[n];e?.kind===`skill`&&e.name!==null&&!r.includes(e.name)&&r.push(e.name)}for(let i=e;i<=t;i++){let e=this.sorted[i];e?.kind===`message`&&n.set(e.key,r)}}collectAround(e,t){let n=this.lowerBound(e),r=this.sorted[n];if(r!==void 0&&r.seq===e&&r.kind!==`boundary`){this.assignRun(this.runStart(n),this.runEnd(n),t);return}n-1>=0&&this.sorted[n-1]?.kind!==`boundary`&&this.assignRun(this.runStart(n-1),n-1,t);let i=r!==void 0&&r.seq===e?n+1:n;i<this.sorted.length&&this.sorted[i]?.kind!==`boundary`&&this.assignRun(i,this.runEnd(i),t)}};let gS={anchorSeq:0,nodes:Kx,partial:null,running:null};function _S(e){let t=e;if(e.visibility!==`visible`&&t.kind!==`assistant-step`)return gS;switch(t.kind){case`user`:case`steering`:case`context`:case`command`:case`compaction`:case`turn-error`:case`turn-max-tokens`:case`unknown`:return{anchorSeq:t.anchorSeq,nodes:[t.data],partial:null,running:null};case`assistant-step`:{let n=t.data;return n.status===`running`?e.visibility===`visible`?{anchorSeq:t.anchorSeq,nodes:Kx,partial:{turn:n.turn,step:n.step,blocks:n.blocks},running:null}:gS:{anchorSeq:t.anchorSeq,nodes:n.finalNode===void 0?Kx:[n.finalNode],partial:null,running:null}}case`tool-call`:{let e=t.data.root;return Mx(e)?{anchorSeq:t.anchorSeq,nodes:Kx,partial:null,running:e}:{anchorSeq:t.anchorSeq,nodes:[e],partial:null,running:null}}case`manual-compaction`:{let e=t.data;return{anchorSeq:t.anchorSeq,nodes:e.compaction===null?[e.command]:[e.command,e.compaction],partial:null,running:null}}case`model-retry`:return{anchorSeq:t.anchorSeq,nodes:t.data.attempts,partial:null,running:null};case`turn-tail`:case`system-prompt`:return gS;default:return gS}}function vS(e,t){return e!==void 0&&e.anchorSeq===t.anchorSeq&&e.partial?.blocks===t.partial?.blocks&&e.partial?.turn===t.partial?.turn&&e.partial?.step===t.partial?.step&&e.running===t.running&&qx(e.nodes,t.nodes)}var yS=class{contributions=/* @__PURE__ */ new Map;finalizedContributions=/* @__PURE__ */ new Map;runningContributions=/* @__PURE__ */ new Map;partialContributions=/* @__PURE__ */ new Map;finalized=Kx;runningCalls=Kx;partial=null;timeline;turnTimings=/* @__PURE__ */ new Map;turnEnds=/* @__PURE__ */ new Map;replace(e,t){this.contributions.clear(),this.finalizedContributions.clear(),this.runningContributions.clear(),this.partialContributions.clear();for(let t of e){let e=_S(t);this.contributions.set(t.key,e),this.indexContribution(t.key,e)}return this.rebuildFinalized(),this.rebuildRunning(),this.rebuildPartial(),this.updateTimeline(t),this.snapshot()}apply(e,t){let n=!1,r=!1,i=!1;for(let t of e){let e=_S(t),a=this.contributions.get(t.key);vS(a,e)||(n||=xS(a,e),r||=SS(a,e),i||=CS(a,e),this.contributions.set(t.key,e),this.indexContribution(t.key,e))}return n&&this.rebuildFinalized(),r&&this.rebuildRunning(),i&&this.rebuildPartial(),this.updateTimeline(t),this.snapshot()}indexContribution(e,t){bS(this.finalizedContributions,e,t,t.nodes.length>0),bS(this.runningContributions,e,t,t.running!==null),bS(this.partialContributions,e,t,t.partial!==null)}rebuildFinalized(){let e=[...this.finalizedContributions.values()].flatMap(e=>e.nodes).sort((e,t)=>e.seq-t.seq);qx(this.finalized,e)||(this.finalized=e)}rebuildRunning(){let e=[...this.runningContributions.values()].sort((e,t)=>e.anchorSeq-t.anchorSeq).flatMap(e=>e.running===null?[]:[e.running]);qx(this.runningCalls,e)||(this.runningCalls=e)}rebuildPartial(){let e=[...this.partialContributions.values()].sort((e,t)=>e.anchorSeq-t.anchorSeq).findLast(e=>e.partial!==null)?.partial??null;(this.partial?.blocks!==e?.blocks||this.partial?.turn!==e?.turn||this.partial?.step!==e?.step)&&(this.partial=e)}updateTimeline(e){if(this.timeline===e)return;this.timeline=e;let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map;for(let r of e.turns.values())r.start!==void 0&&t.set(r.turn,{startTime:r.start.time,...r.end===void 0?{}:{endTime:r.end.time}}),r.end!==void 0&&n.set(r.turn,r.end.seq);this.turnTimings=t,this.turnEnds=n}snapshot(){return{nodes:this.finalized,turnTimings:this.turnTimings,turnEnds:this.turnEnds,partial:this.partial,runningCalls:this.runningCalls}}};function bS(e,t,n,r){r?e.set(t,n):e.delete(t)}function xS(e,t){let n=e?.nodes??Kx;return!qx(n,t.nodes)||(n.length>0||t.nodes.length>0)&&e?.anchorSeq!==t.anchorSeq}function SS(e,t){return e?.running!==t.running||(e.running!==null||t.running!==null)&&e.anchorSeq!==t.anchorSeq}function CS(e,t){return e?.partial?.blocks!==t.partial?.blocks||e?.partial?.turn!==t.partial?.turn||e?.partial?.step!==t.partial?.step||((e?.partial??null)!==null||t.partial!==null)&&e?.anchorSeq!==t.anchorSeq}var wS=class{store=new Zx;locations=new Qx;navigation=new eS;legacy=new yS;referenceLabels=new dS;skillNames=new hS;order=Ux;latestGroupInput;readGroupNode=e=>this.store.get(e);readGroupTurn=e=>this.locations.getTurn(e);readGroupPosition=e=>this.locations.getPosition(e);timeline=null;empty;constructor(){this.empty=this.snapshot({turnOrder:Wx,turns:/* @__PURE__ */ new Map}),this.latestGroupInput={kind:`replace`,order:this.order,readNode:this.readGroupNode,readTurn:this.readGroupTurn,readPosition:this.readGroupPosition,timeline:this.empty.timeline}}replace(e){let t=this.skillNames.replace(this.referenceLabels.replace(e.nodes));return this.store.replace(t),this.order=sS(t).map(e=>e.key),this.locations.rebuild(this.order,this.store),this.store.replaceProcesses(this.order,this.locations),this.navigation.rebuild(e.timeline,this.locations,this.store),this.timeline=e.timeline,this.latestGroupInput={kind:`replace`,order:this.order,readNode:this.readGroupNode,readTurn:this.readGroupTurn,readPosition:this.readGroupPosition,timeline:e.timeline},this.snapshot(e.timeline,this.legacy.replace(t,e.timeline))}apply(e){let t=this.skillNames.apply(this.referenceLabels.apply(e.upserts,this.store),this.store),n=/* @__PURE__ */ new Set,r=!1,i=[],a=[];for(let e of t){let t=this.store.get(e.key);t!==e&&a.push({previous:t,current:e});let o=t===void 0||t.kind!==e.kind||t.anchorSeq!==e.anchorSeq||t.visibility!==e.visibility||ES(t.location)!==ES(e.location);if(r||=o,o||i.push(e),iS(t,e,o)){let r=t===void 0?void 0:nS(t.location).turn,i=nS(e.location).turn;r!==void 0&&n.add(r),i!==void 0&&n.add(i)}}this.store.upsert(t);let o=Wx;if(r){let e=sS(this.store.values()).map(e=>e.key);this.order=qx(this.order,e)?this.order:e,o=this.locations.rebuild(this.order,this.store)}return this.locations.touch(i),this.store.updateProcesses(n,this.locations),r||e.timeline!==this.timeline?this.navigation.rebuild(e.timeline,this.locations,this.store):this.navigation.touch(TS(i),this.locations,this.store),this.timeline=e.timeline,this.latestGroupInput={kind:`apply`,changes:a,order:this.order,readNode:this.readGroupNode,readTurn:this.readGroupTurn,readPosition:this.readGroupPosition,timeline:e.timeline,changedTurns:e.changedTurns??Wx,changedTurnOrders:o},this.snapshot(e.timeline,this.legacy.apply(t,e.timeline))}groupInput(){return this.latestGroupInput}publish(){this.store.publish()}snapshot(e,t=this.legacy.replace(Kx,e)){return{order:this.order,nodes:this.store,locations:this.locations,navigation:this.navigation,timeline:e,legacy:t}}};function TS(e){let t=/* @__PURE__ */ new Set;for(let n of e){let e=nS(n.location).turn;e!==void 0&&t.add(e)}return t}function ES(e){let t=nS(e);return`${e.kind}:${t.turn??``}:${t.step??``}`}let DS={target:`chat`,create:()=>new wS,isActive:e=>e.order.some(t=>e.nodes.get(t)?.kind!==`command`)};function OS(e){e.uiConversation.views.register(DS)}let kS=/* @__PURE__ */ new Set([`system/message`,`developer/message`,`user/message`,`assistant/message`,`tool/result`]);function AS(e){return kS.has(e.type)?e.surfaceOp!==void 0:!1}function jS(e){return AS(e)&&e.surfaceOp===`append`}function MS(e){return AS(e)&&e.surfaceOp!==`append`}function NS(e){if(e.event.type!==`command/run`)throw Error(`command start requires command/run`);let t=e.event.data;return{kind:`command`,seq:e.event.seq,time:e.event.time,commandId:t.commandId,name:t.name,args:t.args??null,outcome:null}}function PS(e,t){if(e.event.type!==`command/done`)throw Error(`command update requires command/done`);let n=e.event.data,r=n.kind===`success`&&n.sourceEventSeq!==void 0&&Number.isSafeInteger(n.sourceEventSeq)&&n.sourceEventSeq>=0?n.sourceEventSeq:void 0;return{kind:`command`,seq:t?.seq??e.event.seq,time:t?.time??e.event.time,commandId:n.commandId,name:t?.name??null,args:t?.args??null,outcome:{kind:n.kind,...n.text===void 0?{}:{text:n.text},...r===void 0?{}:{sourceEventSeq:r}}}}function FS(e){if(e.type!==`user/message`||!MS(e))return;let t=e.data.source;if(t.kind===`compact-checkpoint`&&typeof t.compactionId==`string`)return{compactionId:t.compactionId,...t.sourceCommandId===void 0?{}:{sourceCommandId:t.sourceCommandId}}}function IS(e,t){let n=null,r=null,i=null;if(e?.event.type===`compaction/summary`){let t=e.event.data;if(Array.isArray(t.summary)){let e=t.summary.map(e=>e.type===`text`?e.text:``).join(``);n=e.trim()===``?null:e}r=Array.isArray(t.shadowedSeqs)&&t.shadowedSeqs.every(e=>Number.isSafeInteger(e)&&e>=0)?t.shadowedSeqs.length:null,i=Number.isSafeInteger(t.shadowedTokenCount)&&t.shadowedTokenCount>=0?t.shadowedTokenCount:null}return{kind:`compaction`,seq:t.event.seq,time:t.event.time,summary:n,summaryEventSeq:e?.event.seq??null,shadowedItemCount:r,shadowedTokenCount:i}}function LS(e){let t=e.matches.find(e=>e.event.type===`command/done`),n=e.matches.find(e=>FS(e.event)!==void 0),r=e.matches.find(e=>e.event.type===`compaction/summary`);if(n===void 0)return t===void 0?void 0:{command:PS(t)};let i=FS(n.event);return i?.sourceCommandId===void 0?t===void 0?void 0:{command:PS(t)}:{command:t===void 0?{kind:`command`,seq:n.event.seq,time:n.event.time,commandId:i.sourceCommandId,name:`compact`,args:null,outcome:null}:{...PS(t),name:`compact`},checkpoint:n,...r===void 0?{}:{summary:r}}}function RS(e,t){return t.event.type===`compaction/summary`?{...e,summary:t}:FS(t.event)===void 0?e:{...e,checkpoint:t}}let zS={kind:`command`,target:`chat`,match:e=>{if(e.type===`command/run`)return{id:String(e.data.commandId),role:`start`};if(e.type===`command/done`)return{id:String(e.data.commandId),role:`update`};let t=FS(e);return t?.sourceCommandId===void 0?(e.type===`compaction/start`||e.type===`compaction/summary`||e.type===`compaction/end`)&&e.data.sourceCommandId!==void 0?{id:String(e.data.sourceCommandId),role:`update`}:null:{id:String(t.sourceCommandId),role:`update`}},start:(e,t)=>({command:NS(t)}),update:(e,t)=>t.event.type===`command/done`?{...e.state,command:PS(t,e.state.command)}:RS(e.state,t),buildViewNode:e=>{let t=e.state??LS(e);if(t===void 0)return null;if(t.command.name!==`compact`)return tx(e,`command`,t.command.seq,t.command);let n=t.checkpoint===void 0?null:IS(t.summary,t.checkpoint),r={command:t.command,compaction:n};return tx(e,`manual-compaction`,n?.seq??t.command.seq,r)}};function BS(e){e.uiConversation.events.register(zS)}function VS(e){let t=e.matches.find(e=>e.event.type===`compaction/summary`),n=e.matches.find(e=>FS(e.event)!==void 0);return{...t===void 0?{}:{summary:t},...n===void 0?{}:{checkpoint:n}}}let HS={kind:`compaction`,target:`chat`,match:e=>{let t=FS(e);if(t!==void 0&&t.sourceCommandId===void 0)return{id:t.compactionId,role:`update`};if(e.type===`compaction/start`||e.type===`compaction/summary`||e.type===`compaction/end`){if(e.data.sourceCommandId!==void 0)return null;let t=e.data.compactionId;return typeof t!=`string`||t===``?null:{id:t,role:e.type===`compaction/start`?`start`:`update`}}return null},start:()=>({}),update:(e,t)=>RS(e.state,t),buildViewNode:e=>{let t=e.state??VS(e);if(t.checkpoint===void 0)return null;let n=IS(t.summary,t.checkpoint);return tx(e,`compaction`,n.seq,n)}};function US(e){e.uiConversation.events.register(HS)}let WS={kind:`unknown-surface`,target:`chat`,match:e=>e.type!==`assistant/live-chunk`&&jS(e)?{id:String(e.seq),role:`start`}:null,start:(e,t)=>({kind:`unknown`,seq:t.event.seq,time:t.event.time,type:t.event.type,data:t.event.data}),update:e=>e.state,buildViewNode:e=>e.state===void 0?null:tx(e,`unknown`,e.state.seq,e.state)};function GS(e){e.uiConversation.events.registerFallback(WS)}let KS={kind:`snapshot`,ids:[]},qS=/* @__PURE__ */ new Set;function JS(e){let t=[],n=e;for(;n.kind===`splice`;)t.push(n),n=n.previous;let r=[...n.ids];for(let e of t.reverse())r.splice(e.start,e.removedCount,...e.inserted);return r}function YS(e,t){let n;for(let{id:r}of t)e.has(r)&&(n??=new Set(e),n.delete(r));return n??e}function XS(e,t,n){let r=e?.state.pending??KS,i=t.inserted,a=t.removedCount??0;if(a>0&&t.outcome!==`canceled`){let e=JS(r),o=e.splice(t.start,a,...i);return{pending:{kind:`snapshot`,ids:e},currentClaimed:new Set(o.map(e=>e.id)),claimSeq:n,claimedHuman:o.some(e=>e.source.kind===`user`)}}let o=YS(e?.state.currentClaimed??qS,i);return{pending:{kind:`splice`,previous:r,start:t.start,removedCount:a,inserted:i},currentClaimed:o,claimSeq:e?.state.claimSeq??-1,claimedHuman:e?.state.claimedHuman??!1}}function ZS(e){let t=`inbox-${e}`;return{kind:t,match:t=>t.type===`agent/inbox/spliced`&&t.data.target===e?{id:String(t.seq),role:`start`}:null,start:(e,n,r)=>{if(n.event.type!==`agent/inbox/spliced`)throw Error(`inbox start requires agent/inbox/spliced`);return XS(r.previous(t),n.event.data,n.event.seq)},update:e=>e.state,publication:()=>`none`}}let QS=ZS(`next-step`),$S=ZS(`next-turn`);function eC(e){e.uiConversation.events.register(QS),e.uiConversation.events.register($S)}function tC(e){return e.type!==`user/message`||!MS(e)?!1:e.data.source.kind===`compact-checkpoint`}function nC(e,t){return{kind:`context`,seq:e.seq,time:e.time,content:t.content,source:t.source,producer:cx(t.source),form:sx(t.source)}}let rC={kind:`input-message`,target:`chat`,match:e=>e.type===`user/message`&&jS(e)&&!tC(e)?{id:String(e.data.id),role:`start`}:null,start:(e,t,n)=>{let r=t.event;if(r.type!==`user/message`)throw Error(`input-message start requires user/message`);if(r.data.source.kind!==`user`){let e=n.previous(`inbox-next-turn`)?.state,i=n.previous(`inbox-next-step`)?.state,a=t.location,o=a.kind===`step`?a.turn.start?.seq:void 0,s=a.kind===`step`&&a.step.step===1&&o!==void 0&&(i?.claimSeq??-1)>o&&(e?.claimSeq??-1)<o&&i?.claimedHuman===!1&&i.currentClaimed.has(String(r.data.id));return{...nC(r,r.data),waking:e?.currentClaimed.has(String(r.data.id))===!0||s}}return n.previous(`inbox-next-step`)?.state.currentClaimed.has(String(r.data.id))===!0?{kind:`steering`,messageId:r.data.id,seq:r.seq,time:r.time,content:r.data.content,source:r.data.source}:{kind:`user`,seq:r.seq,time:r.time,content:r.data.content,source:r.data.source}},update:e=>e.state,buildViewNode:e=>{if(e.state===void 0)return null;let t=e.state.kind===`context`&&e.start?.event.type===`user/message`&&e.state.waking===!0,n=e.state.kind===`user`||e.state.kind===`steering`?{...e.state,...iC(e.state)}:e.state;return tx(e,t?`turn-trigger`:e.state.kind,e.state.seq,n)}};function iC(e){let t=bh(e.content.flatMap(e=>e.type===`text`?[e.text]:[]).join(`
131
+ `));return t.length===0?{}:{responseAnnotations:t}}let aC={...rC,kind:`developer-message`,match:e=>e.type===`developer/message`?{id:String(e.data.message.id),role:`start`}:null,start:(e,t)=>{let n=t.event;if(n.type!==`developer/message`)throw Error(`developer-message start requires developer/message`);return nC(n,n.data.message)}};function oC(e){e.uiConversation.events.register(rC),e.uiConversation.events.register(aC)}function sC(e,t,n){return e.location.kind!==`step`||t===void 0&&!n||t?.turn===e.location.turn.turn&&t.step===e.location.step.step?e.event.seq:e.location.step.step===1?e.location.turn.start?.seq??e.location.step.start?.seq??e.event.seq:e.location.step.start?.seq??e.event.seq}function cC(e,t,n,r){let i=e.current.get(`chat`);return i?.kind===`system-prompt`?i.anchorSeq:sC(t,n,r)}function lC(e){return{kind:`system-message`,target:`chat`,match:e=>e.type===`system/message`||`surfaceOp`in e&&e.surfaceOp!==`append`?{id:String(e.seq),role:`start`}:null,start:(t,n,r)=>{if(n.event.type===`assistant/live-chunk`)throw Error(`system-message requires a durable event`);return e(r.previous(`system-message`)?.state,n.event)},update:e=>e.state,buildViewNode:e=>{let t=e.state?.introduced;return t===void 0||t.text===``||e.start?.event.type!==`system/message`||e.start.event.surfaceOp!==`append`?null:tx(e,`system-prompt`,t.update?t.seq:sC(e.start,void 0,!0),{text:t.text,...t.update?{update:!0}:{}})}}}function uC(e){return{kind:`request-prompt`,target:`chat`,match:e=>e.type===`request/header`?{id:String(e.seq),role:`start`}:null,start:(t,n,r)=>{if(n.event.type!==`request/header`)throw Error(`request-prompt start requires request/header`);let i=r.previous(`request-prompt`)?.state,a=r.previous(`system-message`),o=a?.state.effective,s=n.location.kind===`step`?{turn:n.location.turn.turn,step:n.location.step.step}:{},c=e(i?.prompt,n.event,o),l=c.change?.kind,u=a?.matches[0]?.event,d=o!==void 0&&u?.type===`system/message`&&u.surfaceOp===`append`&&(o.update||i===void 0)&&o.turn===s.turn&&o.step===s.step;return{anchorSeq:cC(t,n,i,n.event.data.reason===`initial`),showsPrompt:!d&&(i===void 0||n.event.data.reason!==`change`||n.event.data.startsSeries===!0||l===`system`||l===`system-and-tools`),...s,...c}},update:e=>e.state,buildViewNode:e=>{let t=e.state;if(t===void 0)return null;let n=e.current.get(`chat`),r=t.showsPrompt&&t.prompt.system!==``;return!r&&n?.kind!==`system-prompt`?null:tx(e,`system-prompt`,t.anchorSeq,{text:t.prompt.system},{visibility:r?`visible`:`hidden`})}}}function dC(e){e.uiConversation.events.register(lC((t,n)=>e.uiConversation.inspectSystemPrompt(t,n))),e.uiConversation.events.register(uC((t,n,r)=>e.uiConversation.inspectRequestPrompt(t,n,r)))}function fC(e){if(e.event.type===`llm/retry`)return{kind:`model-retry`,seq:e.event.seq,time:e.event.time,retryState:`scheduled`,...e.event.data}}function pC(e){return e.kind===`step`&&e.step.status===`closed`||(e.kind===`step`||e.kind===`turn`)&&e.turn.status===`closed`}let mC={kind:`model-retry`,target:`chat`,match:e=>{if(e.type===`llm/retry`){let t=e.data.retryId;return typeof t!=`string`||t===``?null:{id:t,role:e.data.retry===1?`start`:`update`}}if(e.type===`llm/retry-started`){let t=e.data.retryId;return typeof t==`string`&&t!==``?{id:t,role:`update`}:null}return null},start:(e,t)=>{let n=fC(t);if(n===void 0)throw Error(`model-retry start requires a valid llm/retry event`);return{turn:n.turn,step:n.step,attempts:[n]}},update:(e,t)=>{if(t.event.type===`llm/retry`){let n=fC(t);return n===void 0?e.state:{...e.state,attempts:[...e.state.attempts,n]}}if(t.event.type!==`llm/retry-started`)return e.state;let n=t.event.data.retry;return{...e.state,attempts:e.state.attempts.map(e=>e.retry===n?{...e,retryState:`started`}:e)}},buildViewNode:e=>{if(e.state===void 0||e.state.attempts.length===0)return null;let t=e.start?.location??e.matches[0]?.location??{kind:`unresolved`},n=e.state.attempts,r=n.map((e,r)=>r===n.length-1&&e.retryState===`scheduled`&&pC(t)?{...e,retryState:`cancelled`}:e),i=r.at(-1);if(i===void 0)return null;let a={attempts:r,current:i};return tx(e,`model-retry`,r[0]?.seq??i.seq,a)}};function hC(e){e.uiConversation.events.register(mC)}let gC=/* @__PURE__ */ new WeakMap;function _C(e){return JSON.stringify(e)}function vC(e,t){if(e.event.type!==`tool/call`)throw Error(`tool-call start requires tool/call`);return{phase:`start`,callId:String(e.event.data.callId),name:e.event.data.name,argsRaw:e.event.data.arguments,args:t===void 0?nv.fromText(e.event.data.arguments):t.args.settle(e.event.data.arguments),turn:e.event.data.turn,step:e.event.data.step,time:e.event.time,subCalls:[]}}function yC(e,t){let n=t.event;if(n.type!==`assistant/live-chunk`)return e;let r=n.data.chunk,i=e.root;if(r.type===`block-end`&&r.block.type===`tool-call`)return i===void 0||`kind`in i||i.phase!==`preparing`?e:{...e,root:{...i,name:r.block.name,args:i.args.settle(r.block.arguments)}};if(r.type!==`tool-call-delta`)return e;if(i===void 0){if(!r.name)return e;let t=new nv;return t.append(r.argumentsDelta),{...e,root:{phase:`preparing`,callId:String(r.id),name:r.name,turn:n.data.turn,step:n.data.step,time:n.time,subCalls:[],args:t}}}return`kind`in i||i.phase!==`preparing`||i.args.isSealed||i.args.append(r.argumentsDelta),e}function bC(e,t){let n=e.args.refresh();return!n&&t!==void 0&&!(`kind`in t)&&t.phase===`preparing`&&t.name===e.name&&t.args===e.args?t:n?{...e}:e}function xC(e,t){if(e.event.type!==`tool/result`)return;let n=e.event.data.message;return{kind:`tool-result`,seq:e.event.seq,time:e.event.time,callId:String(n.source.callId),name:t?.name??``,args:t?.args??nv.EMPTY,call:t===void 0?null:{name:t.name,argsRaw:t.argsRaw},callTime:t?.time??null,content:n.content,isError:n.isError===!0,...e.event.data.error===void 0?{}:{error:e.event.data.error},meta:e.event.data.meta,subCalls:[]}}function SC(e,t){return{phase:`start`,callId:t.subCallId,parentCallId:t.parentCallId,name:t.name,argsRaw:_C(t.arguments),args:nv.fromObject(t.arguments),turn:wC(e),step:TC(e),time:e.event.time,subCalls:[]}}function CC(e,t,n){return{kind:`tool-result`,seq:e.event.seq,time:e.event.time,callId:t.subCallId,parentCallId:t.parentCallId,name:t.name,args:n!==void 0&&!(`kind`in n)?n.args:nv.fromObject(t.arguments),call:{name:t.name,argsRaw:_C(t.arguments)},callTime:n?.time??null,content:t.content??[],isError:t.isError===!0,...t.error===void 0?{}:{error:t.error},subCalls:[]}}function wC(e){return e.location.kind===`step`||e.location.kind===`turn`?e.location.turn.turn:0}function TC(e){return e.location.kind===`step`?e.location.step.step:0}function EC(e,t,n){if(t===n||e.parents.has(n))return!1;let r=t,i=0,a=/* @__PURE__ */ new Set;for(;r!==void 0;){if(r===n||a.has(r))return!1;a.add(r),i++,r=e.parents.get(r)}let o=[{callId:n,depth:1}],s=/* @__PURE__ */ new Set,c=0;for(let t of o){if(s.has(t.callId))return!1;s.add(t.callId),c=Math.max(c,t.depth);for(let n of e.children.get(t.callId)??[])o.push({callId:n.callId,depth:t.depth+1})}return i+c<=256}function DC(e,t){let n=t.event;if(n.type!==`tool/ptc-dispatch-start`&&n.type!==`tool/ptc-dispatch`)return e;let r=n.data,i=String(r.parentCallId),a=String(r.subCallId),o=e.children.get(i)??[],s=o.findIndex(e=>e.callId===a);if(n.type===`tool/ptc-dispatch-start`){if(s>=0||!EC(e,i,a))return e;let n=new Map(e.children);n.set(i,[...o,SC(t,r)]);let c=new Map(e.parents);return c.set(a,i),{...e,children:n,parents:c}}if(s<0&&!EC(e,i,a))return e;let c=CC(t,r,s<0?void 0:o[s]),l=new Map(e.children);l.set(i,s<0?[...o,c]:o.map((e,t)=>t===s?c:e));let u=new Map(e.parents);return s<0&&u.set(a,i),{...e,children:l,parents:u}}function OC(e,t,n,r=/* @__PURE__ */ new Set,i=1){if(!(`kind`in e)&&e.phase===`preparing`)return e;if(r.has(e.callId)||i>256)return{...e,subCalls:[]};let a=new Set(r);a.add(e.callId);let o=(t.children.get(e.callId)??e.subCalls).map(e=>OC(e,t,n,a,i+1)),s=`kind`in e?void 0:n?.seq,c=`kind`in e?void 0:n?.time,l=gC.get(e);if(l!==void 0&&l.interruptionSeq===s&&l.interruptionTime===c&&kC(l.children,o))return l.value;let u=`kind`in e||n===void 0?kC(e.subCalls,o)?e:{...e,subCalls:o}:{kind:`tool-result`,seq:n.seq+$b.interruptedFollowup,time:n.time,callId:e.callId,...e.parentCallId===void 0?{}:{parentCallId:e.parentCallId},name:e.name,args:e.args,call:{name:e.name,argsRaw:e.argsRaw},callTime:e.time,content:[],isError:!0,error:{name:`Interrupted`,code:`interrupted`},subCalls:o};return gC.set(e,{children:o,interruptionSeq:s,interruptionTime:c,value:u}),u}function kC(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function AC(e){let t=e.start?.location;if(t?.kind===`step`&&t.step.status===`closed`)return t.step.end;if((t?.kind===`step`||t?.kind===`turn`)&&t.turn.status===`closed`)return t.turn.end}function jC(e){let t=e.matches.find(e=>e.event.type===`tool/result`),n=t===void 0?void 0:xC(t);if(n===void 0)return;let r={root:n,children:/* @__PURE__ */ new Map,parents:/* @__PURE__ */ new Map};for(let t of e.matches)r=DC(r,t);return r}let MC={kind:`tool-call`,target:`chat`,match:e=>{if(e.type===`assistant/live-chunk`){let t=e.data.chunk;return t.type===`block-end`&&t.block.type===`tool-call`?{id:String(t.block.id),role:`start`}:t.type===`tool-call-delta`?{id:String(t.id),role:`start`}:null}if(e.type===`tool/call`)return{id:String(e.data.callId),role:`start`};if(e.type===`tool/result`&&jS(e))return{id:String(e.data.message.source.callId),role:`update`};if(e.type===`tool/ptc-dispatch-start`||e.type===`tool/ptc-dispatch`){let t=e.data.rootCallId;return typeof t==`string`&&t!==``?{id:t,role:`update`}:null}return null},start:(e,t)=>{let n={root:void 0,children:/* @__PURE__ */ new Map,parents:/* @__PURE__ */ new Map};return t.event.type===`tool/call`?{...n,root:vC(t)}:yC(n,t)},update:(e,t)=>{if(t.event.type===`assistant/live-chunk`)return yC(e.state,t);if(t.event.type===`tool/call`)return{...e.state,root:vC(t,e.state.root)};if(t.event.type===`tool/result`){let n=e.state.root,r=xC(t,n!==void 0&&!(`kind`in n)&&n.phase===`start`?n:void 0);return r===void 0?e.state:{...e.state,root:r}}return DC(e.state,t)},publication:e=>e.event.type===`assistant/live-chunk`?`animation-frame`:`immediate`,buildViewNode:e=>{let t=e.current.get(`chat`),n=e.state??jC(e);if(n?.root===void 0)return t==null?null:t.visibility===`hidden`?t:{...t,visibility:`hidden`};let r=AC(e),i=OC(!(`kind`in n.root)&&n.root.phase===`preparing`?bC(n.root,t?.data.root):n.root,n,r),a=e.start?.event.seq??(`kind`in n.root?n.root.seq:e.matches[0]?.event.seq??0),o=!(`kind`in i)&&i.phase===`preparing`&&r!==void 0?`hidden`:`visible`,s=ex(e),c=T_(i.name)&&s.kind===`step`?{kind:`turn`,turn:s.turn}:s,l=t?.data.root===i?t.data:{root:i};return t?.data===l&&t.anchorSeq===a&&t.visibility===o&&t.location===c?t:tx(e,`tool-call`,a,l,{visibility:o,location:c})}};function NC(e){let t=MC.match.bind(MC);e.uiConversation.events.register({...MC,match:{"assistant/live-chunk":t,"tool/call":t,"tool/result":t,"tool/ptc-dispatch-start":t,"tool/ptc-dispatch":t}})}function PC(e){let t=e.start?.location??e.matches[0]?.location;return t?.kind!==`turn`&&t?.kind!==`step`?0:t.turn.steps.at(-1)?.step??0}function FC(e){if(e.event.type!==`turn/end`)return;let t=e.event.data.reason,n=t.kind===`error`?t.error:t.kind===`aborted`&&t.reason.kind===`hook`&&t.reason.reason===`deepseek-account/signed-out`?{message:`Stopped because you signed out of DeepSeek.`,code:`ACCOUNT_SIGNED_OUT`}:void 0;if(n===void 0)return;let r=mx(n);return{seq:e.event.seq,time:e.event.time,message:r.message,...r.code===void 0?{}:{code:r.code}}}function IC(e){let t=e.matches.find(e=>FC(e)!==void 0);if(t?.event.type!==`turn/end`)return;let n=FC(t);if(n!==void 0)return{turn:t.event.data.turn,failure:n}}let LC={kind:`turn-error`,target:`chat`,match:e=>e.type===`turn/start`?{id:String(e.data.turn),role:`start`}:e.type===`turn/end`&&(e.data.reason.kind===`error`||e.data.reason.kind===`aborted`&&e.data.reason.reason.kind===`hook`&&e.data.reason.reason.reason===`deepseek-account/signed-out`)?{id:String(e.data.turn),role:`update`}:null,start:(e,t)=>{if(t.event.type!==`turn/start`)throw Error(`turn-error start requires turn/start`);return{turn:t.event.data.turn}},update:(e,t)=>{let n=FC(t);return n===void 0?e.state:{...e.state,failure:n}},buildViewNode:e=>{let t=e.state??IC(e);if(t?.failure===void 0)return null;let n=t.failure,r={kind:`turn-error`,seq:n.seq,time:n.time,turn:t.turn,step:PC(e),message:n.message,...n.code===void 0?{}:{code:n.code}};return tx(e,`turn-error`,r.seq,r)}};function RC(e){e.uiConversation.events.register(LC)}function zC(e){let t=e.start?.location??e.matches[0]?.location;return t?.kind!==`turn`&&t?.kind!==`step`?0:t.turn.steps.at(-1)?.step??0}function BC(e,t){let n=e.start?.location??e.matches[0]?.location;if(n?.kind!==`turn`&&n?.kind!==`step`)return t;let r=n.turn.data.get(`turn-tail`)?.closing;return r==null?t:r.finalNode.seq+$b.maxTokensNotice}function VC(e){if(e.event.type===`turn/end`&&e.event.data.reason.kind===`max-tokens`)return{turn:e.event.data.turn,seq:e.event.seq,time:e.event.time}}let HC={kind:`turn-max-tokens`,target:`chat`,match:e=>e.type===`turn/end`&&e.data.reason.kind===`max-tokens`?{id:String(e.data.turn),role:`start`}:null,start:(e,t)=>{let n=VC(t);if(n===void 0)throw Error(`turn-max-tokens start requires a max-tokens turn/end`);return n},update:e=>e.state,buildViewNode:e=>{let t=e.state;if(t===void 0)return null;let n={kind:`turn-max-tokens`,seq:t.seq,time:t.time,turn:t.turn,step:zC(e)};return tx(e,`turn-max-tokens`,BC(e,t.seq),n)}};function UC(e){e.uiConversation.events.register(HC)}function WC(e){let t=e.data;return typeof t.turn==`number`?t.turn:void 0}function GC(e){if(e.type===`text-delta`||e.type===`reasoning-delta`)return e.text.trim()!==``;if(e.type===`block-start`)return e.blockType!==`text`&&e.blockType!==`reasoning`&&e.blockType!==`tool-call`;if(e.type!==`block-end`)return!1;let t=e.block;return t.type===`tool-call`?!1:t.type===`text`||t.type===`reasoning`?t.text.trim()!==``:!0}function KC(e){return e.type===`assistant/live-chunk`?GC(e.data.chunk):e.type!==`assistant/attempt`&&e.type===`assistant/message`&&e.surfaceOp===`append`&&dx(e.data.message.content).some(e=>e.kind===`tool-call`?!1:e.kind===`text`||e.kind===`reasoning`?e.text.trim()!==``:!0)}function qC(e,t){return e.type===`tool/call`?T_(e.data.name):e.type===`tool/result`&&t.has(String(e.data.message.source.callId))}function JC(e,t){if(KC(e))return e.type!==`assistant/live-chunk`&&e.type!==`assistant/message`&&e.type!==`assistant/attempt`?void 0:{kind:`assistant`,seq:e.seq,step:e.data.step};if(!qC(e,t)&&(e.type===`tool/call`||e.type===`tool/result`&&e.surfaceOp===`append`||e.type===`llm/retry`))return{kind:`other`,seq:e.seq}}function YC(e){let t=e.start?.location??e.matches.at(-1)?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn:void 0}function XC(e){let t=e.matches.map(e=>WC(e.event)).find(e=>e!==void 0);if(t===void 0)return;let n={turn:t,assistantStartByStep:/* @__PURE__ */ new Map,messageCountByStep:/* @__PURE__ */ new Map,messageCount:0,toolCallCount:0,subagentCount:0,contextCompactionCalls:/* @__PURE__ */ new Set};for(let t of e.matches)n=ew(n,t.event);return n}function ZC(e){return e?.finalNode!==void 0}function QC(e){let t=e.end?.data.finalAssistantStep;if(t===null)return null;let n=(t===void 0?e.steps.at(-1):e.steps.find(e=>e.step===t))?.data.get(`assistant-step`);return!ZC(n)||n.finalNode.interrupted===!0||!Bb(n.blocks)||t===void 0&&n.blocks.some(e=>e.kind===`tool-call`)?null:n}function $C(e,t){let n=e.controlAnchorSeq??t.start?.seq;if(n===void 0)return null;let r=QC(t),i={messageCount:r===null?e.messageCount:[...e.messageCountByStep].filter(([e])=>e!==r.step).reduce((e,[,t])=>e+t,0),toolCallCount:e.toolCallCount,subagentCount:e.subagentCount};if(r===null)return{turn:t.turn,controlAnchorSeq:n,processStartSeq:n,answerAnchorSeq:null,answerStep:null,inlineReasoning:!1,...i};let a=r.blocks.some(e=>e.kind===`reasoning`&&e.text.trim()!==``),o=Math.min(...[...e.assistantStartByStep].filter(([e])=>e<r.step).map(([,e])=>e)),s=Math.min(e.otherStartSeq??1/0,o);return{turn:t.turn,controlAnchorSeq:n,processStartSeq:t.start?.seq??(Number.isFinite(s)?s:r.finalNode.seq),answerAnchorSeq:r.finalNode.seq,answerStep:r.step,inlineReasoning:a,...i}}function ew(e,t){let n=e;if(t.type===`assistant/message`&&t.surfaceOp===`append`&&Bb(dx(t.data.message.content))){let e=new Map(n.messageCountByStep);e.set(t.data.step,(e.get(t.data.step)??0)+1),n={...n,messageCountByStep:e,messageCount:n.messageCount+1}}if(t.type===`tool/call`){if(T_(t.data.name)){let e=new Set(n.contextCompactionCalls);e.add(String(t.data.callId)),n={...n,contextCompactionCalls:e}}else{let e=w_(t.data.name);n={...n,toolCallCount:n.toolCallCount+ +!e,subagentCount:n.subagentCount+ +!!e}}}let r=JC(t,n.contextCompactionCalls);if(r===void 0)return n;if(r.kind===`other`)return n.otherStartSeq===void 0?{...n,otherStartSeq:r.seq,controlAnchorSeq:Math.min(n.controlAnchorSeq??1/0,r.seq)}:n;if(n.assistantStartByStep.has(r.step))return n;let i=new Map(n.assistantStartByStep);return i.set(r.step,r.seq),{...n,assistantStartByStep:i,controlAnchorSeq:Math.min(n.controlAnchorSeq??1/0,r.seq)}}let tw={kind:`turn-process`,target:`chat`,match:e=>{if(e.type===`turn/start`)return{id:String(e.data.turn),role:`start`};let t=WC(e);return t===void 0?null:e.type===`assistant/live-chunk`||e.type===`assistant/message`||e.type===`tool/call`||e.type===`tool/result`||e.type===`llm/retry`||e.type===`step/start`||e.type===`step/end`||e.type===`turn/end`?{id:String(t),role:`update`}:null},start:(e,t)=>{if(t.event.type!==`turn/start`)throw Error(`turn-process start requires turn/start`);return{turn:t.event.data.turn,assistantStartByStep:/* @__PURE__ */ new Map,messageCountByStep:/* @__PURE__ */ new Map,messageCount:0,toolCallCount:0,subagentCount:0,contextCompactionCalls:/* @__PURE__ */ new Set}},update:(e,t)=>ew(e.state,t.event),publication:e=>{if(e.event.type===`assistant/live-chunk`){let t=e.event.data.chunk.type;return t===`usage`||t===`finish`?`none`:`animation-frame`}return`immediate`},buildLocationData:(e,t,n)=>{if(t!==`turn`)return null;let r=e.state??XC(e);if(r===void 0)return null;let i=YC(e);if(i===void 0)return null;let a=e.current.get(`chat`),o=i.steps.at(-1);if(n?.kind===`turn`&&n.key===`turn-process`&&a?.kind===`turn-process`&&a.data.answerAnchorSeq===null&&a.data.controlAnchorSeq===r.controlAnchorSeq&&a.data.messageCount===r.messageCount&&a.data.toolCallCount===r.toolCallCount&&a.data.subagentCount===r.subagentCount&&i.status!==`closed`&&o?.status!==`closed`)return n;let s=$C(r,i);return s===null?null:n?.kind===`turn`&&n.turn===s.turn&&n.key===`turn-process`&&C_(n.value,s)?n:{kind:`turn`,turn:i.turn,key:`turn-process`,value:s}},buildViewNode:e=>{let t=YC(e),n=t?.data.get(`turn-process`);if(t===void 0||n===void 0)return null;let r=e.current.get(`chat`),i=e.state;return r?.kind===`turn-process`&&i!==void 0&&r.data.answerAnchorSeq===null&&r.data.controlAnchorSeq===i.controlAnchorSeq&&r.data.messageCount===i.messageCount&&r.data.toolCallCount===i.toolCallCount&&r.data.subagentCount===i.subagentCount&&t.status!==`closed`&&t.steps.at(-1)?.status!==`closed`&&r.location===(e.start?.location??e.matches[0]?.location)?r:tx(e,`turn-process`,n.controlAnchorSeq+$b.processControl,n)}};function nw(e){let t=tw.match.bind(tw);e.uiConversation.events.register({...tw,match:{"turn/start":t,"assistant/live-chunk":t,"assistant/message":t,"tool/call":t,"tool/result":t,"llm/retry":t,"step/start":t,"step/end":t,"turn/end":t}})}function rw(e,t){for(let n=e.length-1;n>=0;--n){let r=e[n];if(r.type===`chunk`&&r.chunk.type===t)return r.chunk}}function iw(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function aw(e){let t=0;for(let n of e)if(t+=n,!Number.isSafeInteger(t))return;return t}function ow(e){let{provider:t,model:n}=e.source;return t.length>0&&n.length>0?{provider:t,model:n}:void 0}function sw(e){return rw(e,`usage`)?.usage}function cw(e,t){let{inputTokens:n,outputTokens:r,cacheReadTokens:i,cacheWriteTokens:a,reasoningTokens:o,totalTokens:s}=e;if(!iw(n)||!iw(r)||i!==void 0&&!iw(i)||a!==void 0&&!iw(a)||o!==void 0&&(!iw(o)||o>r))return;let c=aw([n,...i===void 0?[]:[i],...a===void 0?[]:[a]]);if(c===void 0)return;let l;if(s!==void 0){if(!iw(s))return;let e=s-r;if(!iw(e)||e<c||i!==void 0&&a!==void 0&&e!==c)return;l=s}else{if(i===void 0||a===void 0)return;let e=aw([c,r]);if(e===void 0)return;l=e}return{inputTokens:n,outputTokens:r,totalTokens:l,...i===void 0?{}:{cacheReadTokens:i},...a===void 0?{}:{cacheWriteTokens:a},...o===void 0?{}:{reasoningTokens:o},...t===void 0?{}:{route:t}}}function lw(e){if(e.length===0)return;let t=aw(e.map(e=>e.inputTokens)),n=aw(e.map(e=>e.outputTokens)),r=aw(e.map(e=>e.totalTokens));if(t===void 0||n===void 0||r===void 0)return;let i=e.map(e=>e.cacheReadTokens),a=e.map(e=>e.cacheWriteTokens),o=e.map(e=>e.reasoningTokens),s=i.every(iw)?aw(i):void 0,c=a.every(iw)?aw(a):void 0,l=o.every(iw)?aw(o):void 0,u,d=e.map(e=>e.route);if(d.every(e=>e!==void 0)){let e=/* @__PURE__ */ new Map;for(let t of d)e.set(`${t.provider}\0${t.model}`,t);u=[...e.values()]}return{uncachedInputTokens:t,outputTokens:n,totalTokens:r,...s===void 0?{}:{cacheReadTokens:s},...c===void 0?{}:{cacheWriteTokens:c},...l===void 0?{}:{reasoningTokens:l},...u===void 0?{}:{routes:u}}}function uw(e,t,n){return e.turn===t&&e.step===n}function dw(e){let t={kind:`idle`},n=[],r,i=!1,a=!1,o=e=>{if(t.kind!==`open`||t.sample===void 0)return!1;let r=cw(t.sample,e);return r!==void 0&&(n.push(r),!0)};for(let n of e){if(a)break;if(n.type===`turn/start`)r!==void 0||t.kind!==`idle`?a=!0:r=n.data.turn;else{if(r===void 0){a=!0;break}if(n.type===`turn/end`)n.data.turn!==r||t.kind!==`idle`||i?a=!0:i=!0;else{if(i){a=!0;break}if(n.type===`step/start`)n.data.turn!==r||t.kind!==`idle`?a=!0:t={kind:`open`,turn:r,step:n.data.step};else if(n.type===`llm/retry-started`)n.data.turn!==r||t.kind!==`settled`||t.by!==`retry`||!uw(t,n.data.turn,n.data.step)?a=!0:t={kind:`open`,turn:r,step:n.data.step};else if(n.type===`assistant/attempt`){if(n.data.turn!==r||t.kind!==`open`||!uw(t,n.data.turn,n.data.step)){a=!0;continue}let e=sw(n.data.stream)??t.sample;t={kind:`open`,turn:r,step:n.data.step,...e===void 0?{}:{sample:e}},o()?t={kind:`finishClosed`,turn:r,step:n.data.step}:a=!0}else if(n.type===`assistant/message`){if(n.data.turn!==r||t.kind!==`open`||!uw(t,n.data.turn,n.data.step)){a=!0;continue}let e=n.data.usage??sw(n.data.stream);e!==void 0&&(t={...t,sample:e}),o(ow(n.data.message))?t={kind:`settled`,turn:r,step:n.data.step,by:`message`}:a=!0}else if(n.type===`llm/retry`){if(n.data.turn!==r||t.kind===`idle`||!uw(t,n.data.turn,n.data.step)){a=!0;continue}(t.kind===`settled`||t.kind===`open`&&!o())&&(a=!0),a||(t={kind:`settled`,turn:r,step:n.data.step,by:`retry`})}else if(n.type===`step/end`){if(n.data.turn!==r||t.kind===`idle`||!uw(t,n.data.turn,n.data.step)){a=!0;continue}t.kind===`open`&&!o()&&(a=!0),a||(t={kind:`idle`})}}}}return a||!i||t.kind!==`idle`?void 0:lw(n)}function fw(e){return e.type!==`assistant/live-chunk`}function pw(e){if(e.type===`assistant/message`||e.type===`assistant/attempt`||e.type===`assistant/live-chunk`||e.type===`step/start`||e.type===`step/end`||e.type===`llm/retry`||e.type===`llm/retry-started`)return{turn:e.data.turn,step:e.data.step}}function mw(e){let t=e.start?.location??e.matches[0]?.location;return t?.kind===`turn`||t?.kind===`step`?t.turn:void 0}function hw(e){return e.finalNode!==void 0&&e.blocks.some(e=>e.kind===`text`&&e.text.trim()!==``)}function gw(e){let t=e.state===void 0?e.matches.find(e=>e.event.type===`turn/end`):e.state.end;if(t?.event.type!==`turn/end`)return null;let n=mw(e);if(n===void 0)return null;let r=n.steps.map(e=>e.data.get(`assistant-step`)).filter(e=>e!==void 0).filter(e=>e.finalNode!==void 0).sort((e,t)=>e.finalNode.seq-t.finalNode.seq),i=r.findLast(hw)??null,a=r.at(-1)?.finalNode.seq;for(let t of e.matches){let e=t.event,n=e.type===`tool/call`||e.type===`tool/result`&&e.surfaceOp===`append`||e.type===`turn/end`&&e.data.reason.kind===`error`||e.type===`llm/retry`?e.seq:void 0;n!==void 0&&(a===void 0||n>a)&&(a=n)}let o=e.start?.event.type===`turn/start`?dw(e.matches.map(e=>e.event).filter(fw)):void 0;return{turn:t.event.data.turn,seq:t.event.seq,time:t.event.time,closing:i,branchUnavailable:i===null||a!==i.finalNode.seq,...o===void 0?{}:{tokenUsage:o}}}let _w={kind:`turn-tail`,target:`chat`,match:e=>{if(e.type===`turn/start`)return{id:String(e.data.turn),role:`start`};if(e.type===`turn/end`||e.type===`tool/call`||e.type===`tool/result`)return{id:String(e.data.turn),role:`update`};let t=pw(e);return t===void 0?null:{id:String(t.turn),role:`update`}},start:(e,t)=>{if(t.event.type!==`turn/start`)throw Error(`turn-tail start requires turn/start`);return{turn:t.event.data.turn}},update:(e,t)=>t.event.type===`turn/end`?{...e.state,end:t}:e.state,publication:e=>e.event.type===`turn/end`?`immediate`:`none`,buildLocationData:(e,t)=>{if(t!==`turn`)return null;let n=gw(e);return n===null?null:{kind:`turn`,turn:n.turn,key:`turn-tail`,value:n}},buildViewNode:e=>{let t=mw(e)?.data.get(`turn-tail`);return t===void 0?null:tx(e,`turn-tail`,t.seq+$b.finalizedFollowup,t)}};function vw(e){let t=_w.match.bind(_w);e.uiConversation.events.register({..._w,match:{"turn/start":t,"turn/end":t,"tool/call":t,"tool/result":t,"assistant/message":t,"assistant/attempt":t,"assistant/live-chunk":t,"step/start":t,"step/end":t,"llm/retry":t,"llm/retry-started":t}})}function yw(e){return e===`read`?`read`:e===`read_image`?`readImage`:e===`grep`||e===`glob`||e.endsWith(`_inspect`)?`search`:e===`write`?`write`:e===`edit`||e===`apply_patch`?`edit`:[`bash`,`pwsh`,`exec_command`,`write_stdin`].includes(e)||e.startsWith(`terminal_`)?`commands`:e===`run_code`?`code`:e===`web_search`?`webSearch`:e===`web_fetch`?`webFetch`:e===`subagent`||e.startsWith(`subagent_`)?`subagents`:[`todo_write`,`create_goal`,`update_goal`,`get_goal`].includes(e)?`plan`:e===`ask_user_question`||e===`request_user_input`?`questions`:`tools`}let bw=new Intl.Segmenter(void 0,{granularity:`grapheme`}),xw=[`title`,`description`,`objective`,`task`,`task_name`,`name`,`question`,`questions`,`prompt`,`message`,`command`,`cmd`,`queries`,`query`,`pattern`,`url`,`uri`,`file_path`,`path`,`target`,`action`,`status`];function Sw(e){let t=e.replace(/\s+/g,` `).trim();if(t.length<=160)return{text:t,truncated:!1};let n=[];for(let{segment:e}of bw.segment(t)){if(n.length===160)return{text:`${n.slice(0,159).join(``).trimEnd()}…`,truncated:!0};n.push(e)}return{text:t,truncated:!1}}function Cw(e){return Sw(typeof e==`string`?e:Array.isArray(e)&&e.every(e=>typeof e==`string`)?e.join(`, `):``).text}function ww(e,t){let n=512;for(;;){let r=e.textPrefix(t,n);if(r===void 0)return;let i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319){let i=e.textPrefix(t,n+1),a=i.charCodeAt(r.length);a>=56320&&a<=57343?(r=i,n++):i.length===r.length&&!e.isSealed&&!e.complete(t)&&(r=r.slice(0,-1))}let a=Sw(r);if(a.truncated||!e.stringExceeds(t,n))return a.text;n*=2}}function Tw(e){if(!Array.isArray(e))return``;for(let t of e){if(typeof t!=`object`||!t)continue;let e=Cw(Reflect.get(t,`question`));if(e!==``)return e}return``}function Ew(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.kind===`assistant-step`&&n.data.status===`running`)for(let e=n.data.blocks.length-1;e>=0;e--){let t=n.data.blocks[e];if(t?.kind!==`reasoning`)continue;let r=t.text.split(/\r?\n[\t ]*\r?\n/);for(let e=r.length-1;e>=0;e--){let t=Cw(r[e]?.replaceAll(`**`,``));if(t!==``)return t}}}return``}function Dw(e,t){for(let e of xw){if(!t.has(e))continue;let n=e===`questions`?Tw(t.value(e)):ww(t,e)??Cw(t.value(e));if(n!==``)return n}return t.closed()?Cw(e):``}function Ow(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Set,r,i=``,a=-1/0,o,s=e=>{if(n.has(e.callId))return;n.add(e.callId);let c=Mx(e)?e:e.call;if(c!==null){let n=yw(c.name);Mx(e)&&e.time>=a&&(r=n,o=e.phase===`preparing`,i=Dw(e.name,e.args),a=e.time),t.set(n,(t.get(n)??0)+1)}for(let t of e.subCalls)s(t)};for(let t of e)t.kind===`tool-call`&&s(t.data.root);return r===void 0&&(i=Ew(e)),{counts:[...t].map(([e,t])=>({kind:e,count:t})).sort((e,t)=>t.count-e.count),running:r,runningDetail:i,...o?{preparing:!0}:{}}}let kw=/* @__PURE__ */ new Set([`user`,`steering`,`turn-trigger`,`model-retry`,`turn-error`,`turn-max-tokens`,`turn-tail`]);function Aw(e){let t=e.location;return t.kind===`turn`||t.kind===`step`?t.turn.turn:void 0}function jw(e){return kw.has(e.kind)||e.kind===`tool-call`&&T_(e.data.root.name)}function Mw(e){return e.kind===`assistant-step`&&e.data.blocks.some(e=>e.kind===`reasoning`&&e.text.trim()!==``)}function Nw(e){return e.kind===`assistant-step`&&Bb(e.data.blocks)}function Pw(e,t){return e.running===t.running&&e.runningDetail===t.runningDetail&&e.preparing===t.preparing&&e.counts.length===t.counts.length&&e.counts.every((e,n)=>e.kind===t.counts[n]?.kind&&e.count===t.counts[n].count)}function Fw(e,t){return e.length===t.length&&e.every((e,n)=>e.key===t[n]?.key&&e.groupPart===t[n].groupPart)}function Iw(e,t){return!Nx(t)&&(e===void 0||!Nx(e))?!1:e===void 0||e.kind!==t.kind||Aw(e)!==Aw(t)||Nx(e)!==Nx(t)||Mw(e)!==Mw(t)||Nw(e)!==Nw(t)}function Lw(e,t){let n=e.readNode(t);if(n===void 0)throw Error(`Chat grouping input is missing Node ${t}`);return n}function Rw(e,t){let n=/* @__PURE__ */ new Set;for(let r of t){let t=Lw(e,r);t.kind===`question-reply`&&n.add(t.id)}return n}var zw=class{key;turn;members;nodes=[];forceClosed=!1;sameTurnFollowed=!1;snapshot;constructor(e,t,n){this.key=e,this.turn=t,this.members=n,this.snapshot={key:e,members:n,data:{turn:t,closed:!1,summary:{counts:[],running:void 0,runningDetail:``}}}}get isForceClosed(){return this.forceClosed}get isSameTurnFollowed(){return this.sameTurnFollowed}refresh(e,t,n,r){this.forceClosed=t,this.sameTurnFollowed=n;let i=this.members.map(t=>Lw(e,t.key)),a=i.length===this.nodes.length&&i.every((e,t)=>e===this.nodes[t]),o=this.snapshot.data,s=r===`closed`||t||n&&r!==`open`,c=a&&(!o.closed||s)?o.summary:Ow(i),l=s||n&&c.running===void 0,u=l?{counts:c.counts,running:void 0,runningDetail:``}:c;this.nodes=i,(o.closed!==l||!Pw(o.summary,u))&&(this.snapshot={key:this.key,members:this.members,data:{turn:this.turn,closed:l,summary:u}})}},Bw=class{turn;groups=/* @__PURE__ */ new Map;membership=/* @__PURE__ */ new Map;roots=/* @__PURE__ */ new Map;lastTurnStatus;constructor(e){this.turn=e}references(e){return this.roots.get(e)??[]}snapshots(){return[...this.groups.values()].map(e=>e.snapshot)}refresh(e,t){let n=/* @__PURE__ */ new Set;for(let e of t){let t=this.membership.get(e);t!==void 0&&n.add(t)}let r=e.timeline.turns.get(this.turn)?.status;if(r!==this.lastTurnStatus){for(let e of this.groups.values())n.add(e.key);this.lastTurnStatus=r}let i=[];for(let t of n){let n=this.groups.get(t),a=n.snapshot;n.refresh(e,n.isForceClosed,n.isSameTurnFollowed,r),n.snapshot!==a&&i.push(n.snapshot)}return i}rebuild(e,t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map,a=[],o=[],s=e.timeline.turns.get(this.turn)?.status;this.lastTurnStatus=s;let c=(e,t)=>{n.set(e,[...n.get(e)??[],t])},l=(n,l)=>{let u=a[0];if(u===void 0)return;let d=this.extendedGroup(a,t)?.key??ay(JSON.stringify([`process`,u.key,u.groupPart??null])),f=this.groups.get(d),p=f?.snapshot,m=f!==void 0&&Fw(f.members,a)?f:new zw(d,this.turn,a);m.refresh(e,n,l,s),r.set(m.key,m),c(u.key,{kind:`group`,key:m.key});for(let e of a)i.set(e.key,m.key);m.snapshot!==p&&o.push(m.snapshot),a=[]},u,d=!1,f=e.readTurn(this.turn),p=Rw(e,f);for(let t of f){let n=Vw(e,t);u!==void 0&&n.previous!==u&&l(!0,!1),u=t,d=n.next!==void 0;let r=Lw(e,t);r.kind===`turn-trigger`&&p.has(r.id)||(jw(r)?(l(!1,!0),c(t,{kind:`node`,key:t})):r.kind===`turn-process`?c(a[0]?.key??t,{kind:`node`,key:t}):r.kind===`assistant-step`?(Mw(r)&&a.push({kind:`node`,key:t,groupPart:`reasoning`}),Nw(r)&&(l(!1,!0),c(t,{kind:`node`,key:t,groupPart:`response`}))):a.push({kind:`node`,key:t}))}l(d,!1);let m=[...this.groups.keys()].filter(e=>!r.has(e));return this.groups=r,this.membership=i,this.roots=n,{upserts:o,removes:m}}extendedGroup(e,t){let n=e.findIndex(e=>!t.has(e.key)),r=e[n];if(r===void 0)return;let i=this.membership.get(r.key),a=i===void 0?void 0:this.groups.get(i);if(!(a===void 0||n+a.members.length>e.length)){for(let t=0;t<a.members.length;t++){let r=a.members[t],i=e[n+t];if(r.key!==i.key||r.groupPart!==i.groupPart)return}for(let r=n+a.members.length;r<e.length;r++)if(!t.has(e[r].key))return;return a}}};function Vw(e,t){let n=e.readPosition(t);if(n===void 0)throw Error(`Chat grouping order is missing position for Node ${t}`);return n}var Hw=class{turns=/* @__PURE__ */ new Map;order=[];pending=null;accept(e){if(e.kind===`replace`){let t=new Set(this.order),n=new Set(e.order.filter(e=>!t.has(e))),r=/* @__PURE__ */ new Map;for(let t of e.order){let i=Vw(e,t).turn;if(i===void 0||r.has(i))continue;let a=this.turns.get(i)??new Bw(i);a.rebuild(e,n),r.set(i,a)}this.turns=r,this.order=e.order,this.pending={entries:this.rootEntries(e),groups:{kind:`replace`,snapshots:[...r.values()].flatMap(e=>e.snapshots())}};return}let t=new Set(e.changedTurnOrders),n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Map,i=e=>{let t=r.get(e);return t===void 0&&(t=/* @__PURE__ */ new Set,r.set(e,t)),t};for(let r of e.changes){let e=r.previous,a=r.current,o=Aw(a);if((e===void 0||!Nx(e))&&n.add(a.key),Iw(e,a)){let n=e===void 0?void 0:Aw(e);n!==void 0&&t.add(n),o!==void 0&&t.add(o)}o!==void 0&&i(o).add(a.key)}for(let t of e.changedTurns)i(t);let a=[],o=[];for(let r of t){let t=this.turns.get(r)??new Bw(r),i=t.rebuild(e,n);a.push(...i.upserts),o.push(...i.removes),e.readTurn(r).length===0?this.turns.delete(r):this.turns.set(r,t)}for(let[n,i]of r)t.has(n)||a.push(...this.turns.get(n)?.refresh(e,i)??[]);let s=e.order!==this.order||t.size>0;this.order=e.order;let c=new Set(a.map(e=>e.key));this.pending=s||a.length>0||o.length>0?{...s?{entries:this.rootEntries(e)}:{},groups:{kind:`apply`,upserts:a,removes:o.filter(e=>!c.has(e))}}:null}rootEntries(e){let t=Rw(e,e.order.filter(t=>Vw(e,t).turn===void 0));return e.order.flatMap(n=>{let r=Vw(e,n).turn;if(r===void 0){let r=Lw(e,n);return r.kind===`turn-trigger`&&t.has(r.id)?[]:[{kind:`node`,key:n}]}let i=this.turns.get(r);if(i===void 0)throw Error(`Chat grouping order is missing Turn ${r}`);return i.references(n)})}output(){return this.pending}};let Uw={kind:`process-groups`,target:`chat`,create:()=>new Hw,update:(e,t)=>(e.state.accept(t),e.state),buildGroups:e=>e.state.output()};function Ww(e){eC(e),oC(e),dC(e),Ax(e),nw(e),NC(e),BS(e),US(e),hC(e),RC(e),UC(e),vw(e),GS(e),OS(e),e.uiConversation.groups.register(Uw)}function Gw({useNotice:e,dismissNotice:t,keepNoticeOpen:n,renderSlotChain:r,t:i}){let a=e(e=>e);if(a===null)return null;let o={code:a.code,message:i(`message.failure.quota`),dismiss:t,keepOpen:n};return/* @__PURE__ */ (0,f.jsx)(d.Fragment,{children:r(`shell.quota-notice`,o,{fallback:/* @__PURE__ */ (0,f.jsx)(p.Toast,{text:o.message,icon:/* @__PURE__ */ (0,f.jsx)(p.IconWarningOutlineRegular,{size:18}),onDone:t})})},`quota-notice-${String(a.seq)}`)}function Kw(e){return e==null}function qw(e){return e&&typeof e==`object`&&!Array.isArray(e)}function Jw(e,t){return Object.fromEntries(Object.entries(e).filter(([e,n])=>t(e,n)))}function Yw(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(n,e)]))}function Xw(e,t,n){if(!t)return{...e};let r={};for(let i of t)(n||e[i]!==void 0)&&(r[i]=e[i]);return r}let Zw=Symbol.for(`cosmokit.volatile.write`);function Qw(e,t=/* @__PURE__ */ new Set){if(typeof e==`function`)throw TypeError(`volatile config cannot contain functions`);if(typeof e!=`object`||!e)return e;if(t.has(e))throw TypeError(`volatile config cannot contain cycles`);t.add(e);try{if(Array.isArray(e))return Object.freeze(e.map(e=>Qw(e,t)));if(Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw TypeError(`volatile config objects must be plain objects or arrays`);return Object.freeze(Object.fromEntries(Object.entries(e).map(([e,n])=>[e,Qw(n,t)])))}finally{t.delete(e)}}function $w(e){let t=Qw(e);return Object.freeze({get:()=>t,[Zw]:e=>{t=e}})}function eT(e){return typeof e==`object`&&!!e&&Zw in e}function tT(e,t){return arguments.length===1?t=>tT(e,t):e in globalThis&&t instanceof globalThis[e]||Object.prototype.toString.call(t).slice(8,-1)===e}function nT(e){return tT(`ArrayBuffer`,e)||tT(`SharedArrayBuffer`,e)}function rT(e){return nT(e)||ArrayBuffer.isView(e)}let iT;(function(e){e.is=nT,e.isSource=rT;function t(e){return ArrayBuffer.isView(e)?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):e}e.fromSource=t;function n(e){if(e=t(e),typeof Buffer<`u`)return Buffer.from(e).toString(`base64`);let n=``,r=new Uint8Array(e);for(let e=0;e<r.byteLength;e++)n+=String.fromCharCode(r[e]);return btoa(n)}e.toBase64=n;function r(e){return typeof Buffer<`u`?t(Buffer.from(e,`base64`)):Uint8Array.from(atob(e),e=>e.charCodeAt(0))}e.fromBase64=r;function i(e){return e=t(e),typeof Buffer<`u`?Buffer.from(e).toString(`hex`):Array.from(new Uint8Array(e),e=>e.toString(16).padStart(2,`0`)).join(``)}e.toHex=i;function a(e){if(typeof Buffer<`u`)return t(Buffer.from(e,`hex`));let n=e.length%2==0?e:e.slice(0,e.length-1),r=[];for(let e=0;e<n.length;e+=2)r.push(parseInt(`${n[e]}${n[e+1]}`,16));return Uint8Array.from(r).buffer}e.fromHex=a})(iT||={}),iT.fromBase64,iT.toBase64,iT.fromHex,iT.toHex;function aT(e,t=/* @__PURE__ */ new Map){if(!e||typeof e!=`object`)return e;if(tT(`Date`,e))return new Date(e.valueOf());if(tT(`RegExp`,e))return new RegExp(e.source,e.flags);if(nT(e))return e.slice(0);if(ArrayBuffer.isView(e))return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);let n=t.get(e);if(n)return n;if(Array.isArray(e)){let n=[];return t.set(e,n),e.forEach((e,r)=>{n[r]=Reflect.apply(aT,null,[e,t])}),n}let r=Object.create(Object.getPrototypeOf(e));t.set(e,r);for(let n of Reflect.ownKeys(e)){let i={...Reflect.getOwnPropertyDescriptor(e,n)};`value`in i&&(i.value=Reflect.apply(aT,null,[i.value,t])),Reflect.defineProperty(r,n,i)}return r}function oT(e,t,n){let r=/* @__PURE__ */ new Set;function i(e,t){if(e===t)return!0;if(eT(e)||eT(t))return eT(e)&&eT(t);if(!n&&Kw(e)&&Kw(t))return!0;if(typeof e!=typeof t||typeof e!=`object`||!e||!t||r.has(e))return!1;function a(n,r){return n(e)?n(t)?r(e,t):!1:!n(t)&&void 0}r.add(e);try{return a(Array.isArray,(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!i(e[n],t[n]))return!1;return!0})??a(tT(`Date`),(e,t)=>e.valueOf()===t.valueOf())??a(tT(`URL`),(e,t)=>e.href===t.href)??a(tT(`RegExp`),(e,t)=>e.source===t.source&&e.flags===t.flags)??a(nT,(e,t)=>{if(e.byteLength!==t.byteLength)return!1;let n=new Uint8Array(e),r=new Uint8Array(t);for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0})??((!n||[e,t].every(e=>Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null))&&Object.keys({...e,...t}).every(n=>i(e[n],t[n])))}finally{r.delete(e)}}return i(e,t)}let sT;(function(e){e.millisecond=1;let t=e.second=1e3,n=e.minute=t*60,r=e.hour=n*60,i=e.day=r*24,a=e.week=i*7,o=(/* @__PURE__ */ new Date()).getTimezoneOffset();function s(e){o=e}e.setTimezoneOffset=s;function c(){return o}e.getTimezoneOffset=c;function l(e=/* @__PURE__ */ new Date,t){return typeof e==`number`&&(e=new Date(e)),t===void 0&&(t=o),Math.floor((e.valueOf()/n-t)/1440)}e.getDateNumber=l;function u(e,t){let r=new Date(e*i);return t===void 0&&(t=o),new Date(+r+t*n)}e.fromDateNumber=u;let d=RegExp(`^${[`w(?:eek(?:s)?)?`,`d(?:ay(?:s)?)?`,`h(?:our(?:s)?)?`,`m(?:in(?:ute)?(?:s)?)?`,`s(?:ec(?:ond)?(?:s)?)?`].map(e=>`(\\d+(?:\\.\\d+)?${e})?`).join(``)}$`);function f(e){let o=d.exec(e);return o?(parseFloat(o[1])*a||0)+(parseFloat(o[2])*i||0)+(parseFloat(o[3])*r||0)+(parseFloat(o[4])*n||0)+(parseFloat(o[5])*t||0):0}e.parseTime=f;function p(e){let t=f(e);return t?e=Date.now()+t:/^\d{1,2}(:\d{1,2}){1,2}$/.test(e)?e=`${(/* @__PURE__ */ new Date()).toLocaleDateString()}-${e}`:/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(e)&&(e=`${(/* @__PURE__ */ new Date()).getFullYear()}-${e}`),e?new Date(e):/* @__PURE__ */ new Date}e.parseDate=p;function m(e){let a=Math.abs(e);return a>=i-r/2?Math.round(e/i)+`d`:a>=r-n/2?Math.round(e/r)+`h`:a>=n-t/2?Math.round(e/n)+`m`:a>=t?Math.round(e/t)+`s`:e+`ms`}e.format=m;function h(e,t=2){return e.toString().padStart(t,`0`)}e.toDigits=h;function g(e,t=/* @__PURE__ */ new Date){return e.replace(`yyyy`,t.getFullYear().toString()).replace(`yy`,t.getFullYear().toString().slice(2)).replace(`MM`,h(t.getMonth()+1)).replace(`dd`,h(t.getDate())).replace(`hh`,h(t.getHours())).replace(`mm`,h(t.getMinutes())).replace(`ss`,h(t.getSeconds())).replace(`SSS`,h(t.getMilliseconds(),3))}e.template=g})(sT||={});let cT=Symbol.for(`schemastery`),lT=Symbol.for(`ValidationError`);globalThis.__schemastery_index__??=0,globalThis.__schemastery_refs__=void 0;var Q=class extends TypeError{options;name=`ValidationError`;constructor(e,t){let n=`$`;for(let e of t.path||[])typeof e==`string`?n+=`.`+e:typeof e==`number`?n+=`[`+e+`]`:typeof e==`symbol`&&(n+=`[Symbol(${e.toString()})]`);n.startsWith(`.`)&&(n=n.slice(1)),super((n===`$`?``:`${n} `)+e),this.options=t}static is(e){return!!e?.[lT]}};Object.defineProperty(Q.prototype,lT,{value:!0});let $=function(e){let t=function(e,n={}){return $.resolve(e,t,n)[0]};if(e.refs){let t=Yw(e.refs,e=>new $(e)),n=e=>t[e];for(let e in t){let r=t[e];r.sKey=n(r.sKey),r.inner=n(r.inner),r.list=r.list&&r.list.map(n),r.dict=r.dict&&Yw(r.dict,n)}return t[e.uid]}if(Object.assign(t,e),typeof t.callback==`string`)try{t.callback=Function(`return `+t.callback)()}catch{}return Object.defineProperty(t,"uid",{value:globalThis.__schemastery_index__++}),Object.setPrototypeOf(t,$.prototype),t.meta||={},t.toString=t.toString.bind(t),t};$.prototype=Object.create(Function.prototype),$.prototype[cT]=!0,Object.defineProperty($.prototype,"~standard",{get(){return{version:1,vendor:`schemastery`,validate:e=>{try{return{value:$.resolve(e,this,{})[0]}}catch(e){if(Q.is(e))return{issues:[{message:e.message,path:e.options.path}]};throw e}}}}}),$.ValidationError=Q,$.prototype.toJSON=function(){if(globalThis.__schemastery_refs__)return globalThis.__schemastery_refs__[this.uid]??=JSON.parse(JSON.stringify({...this})),this.uid;globalThis.__schemastery_refs__={[this.uid]:{...this}},globalThis.__schemastery_refs__[this.uid]=JSON.parse(JSON.stringify({...this}));let e={uid:this.uid,refs:globalThis.__schemastery_refs__};return globalThis.__schemastery_refs__=void 0,e},$.prototype.set=function(e,t){return this.dict[e]=t,this},$.prototype.push=function(e){return this.list.push(e),this};function uT(e,t){let n=typeof e==`string`?{"":e}:{...e};for(let e in t){let r=t[e];r?.$description||r?.$desc?n[e]=r.$description||r.$desc:typeof r==`string`&&(n[e]=r)}return n}function dT(e){return e?.$value??e?.$inner}function fT(e){return Jw(e??{},e=>!e.startsWith(`$`))}$.prototype.i18n=function(e){let t=$(this),n=uT(t.meta.description,e);return Object.keys(n).length&&(t.meta.description=n),t.dict&&=Yw(t.dict,(t,n)=>t.i18n(Yw(e,e=>dT(e)?.[n]??e?.[n]))),t.list&&=t.list.map((t,n)=>t.i18n(Yw(e,(e={})=>Array.isArray(dT(e))?dT(e)[n]:Array.isArray(e)?e[n]:fT(e)))),t.inner&&=t.inner.i18n(Yw(e,e=>dT(e)?dT(e):fT(e))),t.sKey&&=t.sKey.i18n(Yw(e,e=>e?.$key)),t},$.prototype.extra=function(e,t){let n=$(this);return n.meta={...n.meta,[e]:t},n};for(let e of[`required`,`disabled`,`collapse`,`hidden`,`loose`])Object.assign($.prototype,{[e](t=!0){let n=$(this);return n.meta={...n.meta,[e]:t},n}});$.prototype.deprecated=function(){let e=$(this);return e.meta.badges||=[],e.meta.badges.push({text:`deprecated`,type:`danger`}),e},$.prototype.experimental=function(){let e=$(this);return e.meta.badges||=[],e.meta.badges.push({text:`experimental`,type:`warning`}),e},$.prototype.pattern=function(e){let t=$(this),n=Xw(e,[`source`,`flags`]);return t.meta={...t.meta,pattern:n},t},$.prototype.simplify=function(e){if(eT(e)&&(e=e.get()),oT(e,this.meta.default,this.type===`dict`))return null;if(Kw(e))return e;if(this.type===`object`||this.type===`dict`){let t={};for(let n in e){let r=(this.type===`object`?this.dict[n]:this.inner)?.simplify(e[n]);(this.type===`dict`||!Kw(r))&&(t[n]=r)}return oT(t,this.meta.default,this.type===`dict`)?null:t}if(this.type===`array`||this.type===`tuple`){let t=[];return e.forEach((e,n)=>{let r=this.type===`array`?this.inner:this.list[n],i=r?r.simplify(e):e;t.push(i)}),t}if(this.type===`intersect`){let t={};for(let n of this.list)Object.assign(t,n.simplify(e));return t}if(this.type===`union`)for(let t of this.list)try{return $.resolve(e,t,{}),t.simplify(e)}catch{}return e},$.prototype.toString=function(e){return xT[this.type]?.(this,e)??`Schema<${this.type}>`},$.prototype.role=function(e,t){let n=$(this);return n.meta={...n.meta,role:e,extra:t},n};for(let e of[`default`,`link`,`comment`,`description`,`max`,`min`,`step`])Object.assign($.prototype,{[e](t){let n=$(this);return n.meta={...n.meta,[e]:t},n}});$.prototype.volatile=function(){if(this.meta.volatile)throw TypeError(`volatile schema is already wrapped`);return this.extra(`volatile`,!0)};let pT={},mT=Symbol(`checked-volatile-schema`);function hT(e,t=[],n=!1,r=/* @__PURE__ */ new Map){let i=r.get(e)??/* @__PURE__ */ new Set;if(i.has(n))return;if(i.add(n),r.set(e,i),e.meta?.volatile&&n)throw new Q(`volatile fields require a fixed object path without an enclosing volatile field`,{path:t});let a=n||!!e.meta?.volatile;if(e.dict)for(let[n,i]of Object.entries(e.dict))hT(i,[...t,n],a,r);if(e.sKey&&hT(e.sKey,[...t,`<key>`],!0,r),e.inner&&(e.type!==`lazy`||e.inner[cT])&&hT(e.inner,[...t,`*`],!0,r),e.list)for(let n=0;n<e.list.length;n++)hT(e.list[n],[...t,String(n)],!0,r)}$.extend=function(e,t){pT[e]=t},$.resolve=function(e,t,n={},r=!1){if(!t)return[e];if(n[mT]||(hT(t,n.path),n={...n,[mT]:!0}),t.meta?.volatile){let i=$(t);i.meta={...t.meta,volatile:!1};let[a,o]=$.resolve(e,i,n,r);try{return[$w(a),o]}catch(e){throw new Q(e instanceof Error?e.message:String(e),n)}}if(n.ignore?.(e,t))return[e];if(Kw(e)&&t.type!==`lazy`){if(t.meta.required)throw new Q(`missing required value`,n);let r=t,i=t.meta.default;for(;r?.type===`intersect`&&Kw(i);)r=r.list[0],i=r?.meta.default;if(Kw(i))return[e];e=aT(i)}let i=pT[t.type];if(!i)throw new Q(`unsupported type "${t.type}"`,n);try{return i(e,t,n,r)}catch(e){if(!t.meta.loose)throw e;return[t.meta.default]}},$.from=function(e){if(Kw(e))return $.any();if([`string`,`number`,`boolean`].includes(typeof e))return $.const(e).required();if(e[cT])return e;if(typeof e==`function`)switch(e){case String:return $.string().required();case Number:return $.number().required();case Boolean:return $.boolean().required();case Function:return $.function().required();default:return $.is(e).required()}else throw TypeError(`cannot infer schema from ${e}`)},$.lazy=function(e){let t=new $({type:`lazy`,builder:e,inner:{toJSON:()=>(t.inner[cT]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta}),t.inner.toJSON())}});return t},$.natural=function(){return $.number().step(1).min(0)},$.percent=function(){return $.number().step(.01).min(0).max(1).role(`slider`)},$.date=function(){return $.union([$.is(Date),$.transform($.string().role(`datetime`),(e,t)=>{let n=new Date(e);if(isNaN(+n))throw new Q(`invalid date "${e}"`,t);return n},!0)])},$.regExp=function(e=``){return $.union([$.is(RegExp),$.transform($.string().role(`regexp`,{flag:e}),(t,n)=>{try{return new RegExp(t,e)}catch(e){throw new Q(e.message,n)}},!0)])},$.arrayBuffer=function(e){return $.union([$.is(ArrayBuffer),$.is(SharedArrayBuffer),$.transform($.any(),(e,t)=>{if(iT.isSource(e))return iT.fromSource(e);throw new Q(`expected ArrayBufferSource but got ${e}`,t)},!0),...e?[$.transform($.string(),(t,n)=>{try{return e===`base64`?iT.fromBase64(t):iT.fromHex(t)}catch(e){throw new Q(e.message,n)}},!0)]:[]])},$.extend(`lazy`,(e,t,n,r)=>(t.inner[cT]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta},hT(t.inner,n.path,!0)),$.resolve(e,t.inner,n,r))),$.extend(`any`,e=>[e]),$.extend(`never`,(e,t,n)=>{throw new Q(`expected nullable but got ${e}`,n)}),$.extend(`const`,(e,{value:t},n)=>{if(oT(e,t))return[t];throw new Q(`expected ${t} but got ${e}`,n)});function gT(e,t,n,r,i=!1){let{max:a=1/0,min:o=-1/0}=t;if(e>a)throw new Q(`expected ${n} <= ${a} but got ${e}`,r);if(e<o&&!i)throw new Q(`expected ${n} >= ${o} but got ${e}`,r)}$.extend(`string`,(e,{meta:t},n)=>{if(typeof e!=`string`)throw new Q(`expected string but got ${e}`,n);if(t.pattern){let r=new RegExp(t.pattern.source,t.pattern.flags);if(!r.test(e))throw new Q(`expect string to match regexp ${r}`,n)}return gT(e.length,t,`string length`,n),[e]});function _T(e,t){let n=e.toString();if(n.includes(`e`))return e*10**t;let r=n.indexOf(`.`);if(r===-1)return e*10**t;let i=n.slice(r+1),a=n.slice(0,r);return i.length<=t?+(a+i.padEnd(t,`0`)):+(a+i.slice(0,t)+`.`+i.slice(t))}function vT(e,t,n){if(n=Math.abs(n),!/^\d+\.\d+$/.test(n.toString()))return(e-t)%n===0;let r=n.toString().indexOf(`.`),i=n.toString().slice(r+1).length;return Math.abs(_T(e,i)-_T(t,i))%_T(n,i)===0}$.extend(`number`,(e,{meta:t},n)=>{if(typeof e!=`number`)throw new Q(`expected number but got ${e}`,n);gT(e,t,`number`,n);let{step:r}=t;if(r&&!vT(e,t.min??0,r))throw new Q(`expected number multiple of ${r} but got ${e}`,n);return[e]}),$.extend(`boolean`,(e,t,n)=>{if(typeof e==`boolean`)return[e];throw new Q(`expected boolean but got ${e}`,n)}),$.extend(`bitset`,(e,{bits:t,meta:n},r)=>{let i=0,a=[];if(typeof e==`number`){i=e;for(let n in t)e&t[n]&&a.push(n)}else if(Array.isArray(e)){a=e;for(let e of a){if(typeof e!=`string`)throw new Q(`expected string but got ${e}`,r);e in t&&(i|=t[e])}}else throw new Q(`expected number or array but got ${e}`,r);return i===n.default?[i]:[i,a]}),$.extend(`function`,(e,t,n)=>{if(typeof e==`function`)return[e];throw new Q(`expected function but got ${e}`,n)}),$.extend(`is`,(e,{constructor:t},n)=>{if(typeof t==`function`){if(e instanceof t)return[e];throw new Q(`expected ${t.name} but got ${e}`,n)}{if(Kw(e))throw new Q(`expected ${t} but got ${e}`,n);let r=Object.getPrototypeOf(e);for(;r;){if(r.constructor?.name===t)return[e];r=Object.getPrototypeOf(r)}throw new Q(`expected ${t} but got ${e}`,n)}});function yT(e,t,n,r){try{let[i,a]=$.resolve(e[t],n,{...r,path:[...r.path||[],t]});return a!==void 0&&(e[t]=a),i}catch(i){if(!r?.autofix)throw i;return delete e[t],n.meta.volatile?$w(n.meta.default):n.meta.default}}$.extend(`array`,(e,{inner:t,meta:n},r)=>{if(!Array.isArray(e))throw new Q(`expected array but got ${e}`,r);return gT(e.length,n,`array length`,r,!Kw(t.meta.default)),[e.map((n,i)=>yT(e,i,t,r))]}),$.extend(`dict`,(e,{inner:t,sKey:n},r,i)=>{if(!qw(e))throw new Q(`expected object but got ${e}`,r);let a={};for(let o in e){let s;try{s=$.resolve(o,n,r)[0]}catch(e){if(i)continue;throw e}a[s]=yT(e,o,t,r),e[s]=e[o],o!==s&&delete e[o]}return[a]}),$.extend(`tuple`,(e,{list:t},n,r)=>{if(!Array.isArray(e))throw new Q(`expected array but got ${e}`,n);let i=t.map((t,r)=>yT(e,r,t,n));return r||i.push(...e.slice(t.length)),[i]});function bT(e,t){for(let n in t)n in e||(e[n]=t[n])}$.extend(`object`,(e,{dict:t},n,r)=>{if(!qw(e))throw new Q(`expected object but got ${e}`,n);let i={};for(let r in t){let a=yT(e,r,t[r],n);(!Kw(a)||r in e)&&(i[r]=a)}return r||bT(i,e),[i]}),$.extend(`union`,(e,{list:t,toString:n},r,i)=>{let a=[];for(let n of t)try{return $.resolve(e,n,r,i)}catch(e){a.push(e)}throw new Q(`expected ${n()} but got ${JSON.stringify(e)}`,r)}),$.extend(`intersect`,(e,{list:t,toString:n},r,i)=>{if(!t.length)return[e];let a;for(let i of t){let t=$.resolve(e,i,r,!0)[0];if(!Kw(t)){if(Kw(a))a=t;else if(typeof a!=typeof t)throw new Q(`expected ${n()} but got ${JSON.stringify(e)}`,r);else if(typeof t==`object`)bT(a??={},t);else if(a!==t)throw new Q(`expected ${n()} but got ${JSON.stringify(e)}`,r)}}return!i&&qw(e)&&bT(a,e),[a]}),$.extend(`transform`,(e,{inner:t,callback:n,preserve:r},i)=>{let[a,o=e]=$.resolve(e,t,i,!0);return r?[n(a)]:[n(a),n(o)]});let xT={};function ST(e,t,n){xT[e]=n,Object.assign($,{[e](...n){let r=new $({type:e});return t.forEach((e,t)=>{switch(e){case`sKey`:r.sKey=n[t]??$.string();break;case`inner`:r.inner=$.from(n[t]);break;case`list`:r.list=n[t].map($.from);break;case`dict`:r.dict=Yw(n[t],$.from);break;case`bits`:r.bits={};for(let e in n[t])typeof n[t][e]==`number`&&(r.bits[e]=n[t][e]);break;case`callback`:{let e=r.callback=n[t];e.toJSON||=()=>e.toString();break}case`constructor`:{let e=r.constructor=n[t];typeof e==`function`&&(e.toJSON||=()=>e.name);break}default:r[e]=n[t]}}),e===`object`||e===`dict`?r.meta.default={}:e===`array`||e===`tuple`?r.meta.default=[]:e===`bitset`&&(r.meta.default=0),r}})}ST(`is`,[`constructor`],({constructor:e})=>typeof e==`function`?e.name:e),ST(`any`,[],()=>`any`),ST(`never`,[],()=>`never`),ST(`const`,[`value`],({value:e})=>typeof e==`string`?JSON.stringify(e):e),ST(`string`,[],()=>`string`),ST(`number`,[],()=>`number`),ST(`boolean`,[],()=>`boolean`),ST(`bitset`,[`bits`],()=>`bitset`),ST(`function`,[],()=>`function`),ST(`array`,[`inner`],({inner:e})=>`${e.toString(!0)}[]`),ST(`dict`,[`inner`,`sKey`],({inner:e,sKey:t})=>`{ [key: ${t.toString()}]: ${e.toString()} }`),ST(`tuple`,[`list`],({list:e})=>`[${e.map(e=>e.toString()).join(`, `)}]`),ST(`object`,[`dict`],({dict:e})=>Object.keys(e).length===0?`{}`:`{ ${Object.entries(e).map(([e,t])=>`${e}${t.meta.required?``:`?`}: ${t.toString()}`).join(`, `)} }`),ST(`union`,[`list`],({list:e},t)=>{let n=e.map(({toString:e})=>e()).join(` | `);return t?`(${n})`:n}),ST(`intersect`,[`list`],({list:e})=>`${e.map(e=>e.toString(!0)).join(` & `)}`),ST(`transform`,[`inner`,`callback`,`preserve`],({inner:e},t)=>e.toString(t));let CT=`transcriptView`,wT=[`compact`,`standard`,`detailed`,`verbose`],TT=[...wT,`normal`,`expanded`],ET=`standard`,DT={linkOpening:$.union([`sidebar`,`new-tab`]).default(`sidebar`),[CT]:$.union([...TT]).loose()};$.object(DT);let OT=`@deepseek-ai/dsh-client-ui-chat/PreferenceRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(OT)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-chat`,e.dataset.pluginCss=OT,e.textContent=`.B8MZ0a_row{border-bottom:.5px solid var(--dsw-alias-border-l2);align-items:center;gap:8px;padding:16px 0;display:flex}.B8MZ0a_rowText{flex-direction:column;flex:1;gap:4px;min-width:0;padding-right:48px;display:flex}.B8MZ0a_title{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:400;line-height:22px}.B8MZ0a_desc{color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:400;line-height:18px}.B8MZ0a_selector{border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-module-platform);height:36px;font:inherit;color:var(--dsw-alias-label-primary);cursor:pointer;touch-action:manipulation;user-select:none;-webkit-tap-highlight-color:transparent;border:none;flex-shrink:0;align-items:center;gap:12px;padding:0 14px;font-size:14px;line-height:22px;display:inline-flex}.B8MZ0a_selector:active{background:var(--dsw-alias-interactive-bg-active)}.B8MZ0a_chevron{flex:none}@media (hover:hover) and (pointer:fine){.B8MZ0a_selector:hover{background:var(--dsw-alias-interactive-bg-hover)}}@media (width<=640px){.B8MZ0a_row{gap:12px;min-height:44px;padding:12px 0}.B8MZ0a_rowText{padding-right:0}.B8MZ0a_selector{gap:8px;height:44px;min-height:44px;padding:0 12px;font-size:13.5px}}`,document.head.appendChild(e)}var kT={chevron:`B8MZ0a_chevron`,desc:`B8MZ0a_desc`,row:`B8MZ0a_row`,rowText:`B8MZ0a_rowText`,selector:`B8MZ0a_selector`,title:`B8MZ0a_title`};function AT({title:e,description:t,value:n,selectedLabel:r,options:i,onSelect:a}){let[o,s]=(0,d.useState)(!1),c=(0,d.useRef)(null),l=()=>{s(!1)},u=e=>{c.current?.focus({preventScroll:!0}),l(),a(e)},m=/* @__PURE__ */ (0,f.jsxs)(`button`,{ref:c,type:`button`,className:kT.selector,"aria-haspopup":`menu`,"aria-expanded":o,onClick:()=>{s(e=>!e)},children:[r,/* @__PURE__ */ (0,f.jsx)(p.IconChevronDownOutlineRegular,{className:kT.chevron})]});return/* @__PURE__ */ (0,f.jsxs)(`div`,{className:kT.row,children:[/* @__PURE__ */ (0,f.jsxs)(`div`,{className:kT.rowText,children:[/* @__PURE__ */ (0,f.jsx)(`div`,{className:kT.title,children:e}),/* @__PURE__ */ (0,f.jsx)(`div`,{className:kT.desc,children:t})]}),/* @__PURE__ */ (0,f.jsx)(p.Menu,{open:o,onClose:l,items:i,selectedId:n,onSelect:u,align:`end`,portal:!0,anchor:m})]})}let jT={compact:`settings.transcript.compact`,standard:`settings.transcript.standard`,detailed:`settings.transcript.detailed`,verbose:`settings.transcript.verbose`};function MT({useTranscriptView:e,setTranscriptView:t,t:n}){let r=e(e=>e);return/* @__PURE__ */ (0,f.jsx)(AT,{title:n(`settings.transcript.title`),description:n(`settings.transcript.description`),value:r,selectedLabel:n(jT[r]),options:wT.map(e=>({id:e,label:n(jT[e])})),onSelect:e=>{t(e)}})}var NT=class{host;defaultMode;unsubscribe;mode;constructor(e,t=ET){this.host=e,this.defaultMode=t,this.mode=(0,m.createSnapshotStore)(t),this.unsubscribe=e.subscribe(()=>{this.adopt()}),this.adopt()}dispose(){this.unsubscribe()}setMode(e){this.mode.getSnapshot()!==e&&(this.mode.set(e),this.host.set(CT,e))}adopt(){let e=this.host.getSnapshot().value;if(e===void 0)return;let t=e.transcriptView,n=t===`normal`||t===`expanded`?`detailed`:t??this.defaultMode;this.mode.getSnapshot()!==n&&this.mode.set(n)}};let PT={compact:{mode:`compact`,foldCompletedTurns:!0,stepGrouping:`collapsed`,liveProcessDetail:!1,settledReasoningPreview:!1},standard:{mode:`standard`,foldCompletedTurns:!0,stepGrouping:`collapsed`,liveProcessDetail:!0,settledReasoningPreview:!0},detailed:{mode:`detailed`,foldCompletedTurns:!0,stepGrouping:`history`,liveProcessDetail:!0,settledReasoningPreview:!0},verbose:{mode:`verbose`,foldCompletedTurns:!1,stepGrouping:`none`,liveProcessDetail:!1,settledReasoningPreview:!0}};function FT(e){return{getSnapshot:()=>PT[e.getSnapshot()],subscribe:t=>e.subscribe(t)}}function IT({useLinkOpening:e,useBrowserAvailable:t,setLinkOpening:n,t:r}){let i=e(e=>e);return t(e=>e)?/* @__PURE__ */ (0,f.jsx)(AT,{title:r(`settings.links.title`),description:r(`settings.links.description`),value:i,selectedLabel:r(i===`sidebar`?`settings.links.sidebar`:`settings.links.newTab`),options:[{id:`sidebar`,label:r(`settings.links.sidebar`)},{id:`new-tab`,label:r(`settings.links.newTab`)}],onSelect:e=>{n(e)}}):null}async function LT(e,t,n,r,i,a){let o=await e.stat(n,i);t.mounted.getSnapshot()===n&&(!o.ok&&o.error.code===`workspace-file/not-regular-file`&&o.error.details.kind===`directory`?t.openTabIn(n,`files`,{params:{directory:o.error.details.path}}):t.openResourceIn(n,ae(n,r,i),a===void 0?void 0:{params:{line:a}}))}let RT={getSnapshot:()=>void 0,subscribe:()=>()=>{}};function zT(e,t){let n=e?.source(t)??RT;return(0,d.useSyncExternalStore)(n.subscribe,n.getSnapshot)}let BT={hooks:{turnData:(e,{turnData:t})=>function(e){return zT(t,e)},disclosure:(e,{disclosureReset:t})=>sv(t)}},VT=[`slots`,`sessions`,`uiWorkspace`,`uiSession`,`uiConversation`,`locale`,`configForms`,`remote`,`remote.session`,`remote.workspaceFiles`,`sidebarRight`];function HT(e){let t=(0,m.createSnapshotStore)(null),n=0,r=(0,m.createSnapshotStore)(null),i=0;e.provide(`chatHandoffLauncher`,{open(e,t){r.set({seq:++i,sessionId:e,...t?.targetHarnessId===void 0?{}:{targetHarnessId:t.targetHarnessId},...t?.atSeq===void 0?{}:{atSeq:t.atSeq}})}});let a=/* @__PURE__ */ new Set,o=/* @__PURE__ */ new WeakMap,s=/* @__PURE__ */ new Set;e.effect(()=>async()=>{await Promise.all([...s].map(e=>e()))},`ui-chat: live quota notices`);let c=r=>{let i=o.get(r);if(i===void 0){let c=r.ctx.effect(()=>{let e=r.eventSource.subscribe(()=>{let{change:e}=r.eventSource.getSnapshot();if(e.kind===`append`)for(let{event:r}of e.entries){if(r.type!==`turn/end`||r.data.reason.kind!==`error`)continue;let{code:e}=r.data.reason.error;a.size>0||e!==`QUOTA`&&e!==`ACCOUNT_QUOTA`||t.set({code:e,seq:++n})}});return()=>{e(),o.delete(r),s.delete(c)}},`ui-chat: Provider binding quota notices`);s.add(c);let l=e.uiConversation.binding(r).target(`chat`);i={getSnapshot:()=>l.getSnapshot()??fe,subscribe:e=>l.subscribe(e)},o.set(r,i)}return i};Ww(e),e.uiSession.provide({hooks:[`chat`],resolve:e=>({hooks:{chat:c(e)}})}),e.effect(()=>e.locale.register(ab,{zh:ob,en:sb}),`ui-chat: dictionaries`);let l=e.locale.bind(ab),u=O_(),d=/* @__PURE__ */ new Map,f=e.configForms.get(`ui-chat`),p=(0,m.createSnapshotStore)(f.getSnapshot().value?.linkOpening??`sidebar`);e.effect(()=>f.subscribe(()=>{let e=f.getSnapshot().value?.linkOpening;e!==void 0&&p.set(e)}));let h={getSnapshot:()=>e.get(`sidebarRightTabs`)?.get(`browser`)!==void 0,subscribe:t=>e.get(`sidebarRightTabs`)?.subscribe(t)??(()=>{})},g=t=>h.getSnapshot()?(e.sidebarRight.openTab(`browser`,{params:{url:t}}),!0):!1;e.inject([`sidebarRightTabs`],e=>{e.slots.inject(`settings.general.item`,()=>e.slots.register({name:`settings.general.item`,id:`link-opening`,order:17,locale:ab,inject:()=>({hooks:{linkOpening:p,browserAvailable:h},setLinkOpening:e=>{p.set(e),f.set(`linkOpening`,e).catch(()=>{})}})},IT))});let _=new NT(f,`dshDesktop`in globalThis?`standard`:ET),v=FT(_.mode);e.effect(()=>()=>{_.dispose()}),Qb(e,v),e.slots.inject(`settings.general.item`,()=>e.slots.register({name:`settings.general.item`,id:`transcript-view`,order:12,locale:ab,inject:()=>({hooks:{transcriptView:_.mode},setTranscriptView:e=>{_.setMode(e)}})},MT)),e.slots.inject(`conversation.view`,()=>e.slots.register({name:`conversation.view`,id:`chat`,order:0,label:()=>l(`view.chat`),locale:ab,children:{"conversation.chat.node":{kind:`keyed`,scope:`session`,inject:BT},"conversation.message.images":{kind:`single`,scope:`session`}},store:u,inject:t=>{let n=e.sessions.binding(t);if(n===void 0)throw Error(`ui-chat: unknown session "${t}"`);let i=n.session,a=c(n),o=e.uiConversation.binding(n),s=e.get(`chatMessageEditing`),l=e.get(`chatTurnDiffs`),u=e.get(`chatHandoff`),f=String(t).startsWith(`web-remote:`)||e.sessions.list.getSnapshot().byId[t]?.projectionValues?.remoteHost!=null,m=!f,_=u!==void 0&&!f&&e.sessions.subagentAddress(t)===void 0;return{connection:e.get(`connection`),hooks:{presentation:v,browserAvailable:h,handoffRequest:r},keyedHooks:{chatNode:e=>a.getSnapshot().nodes.source(e),chatNodeProcess:e=>a.getSnapshot().nodes.processSource(e),chatGroup:e=>o.snapshot.getSnapshot().views.grouped(`chat`)?.groupSource(e)},fileMentions:n=>e.get(`chatFileMentions`)?.forClosing(n,t),openFile:async(n,r)=>{let i=e.sessions.list.getSnapshot().byId[t]?.cwd;if(r?.external||r?.reveal){let a=ie(i,n);if(!r.reveal||!re(a)){let r=await e.remote.workspaceFiles.stat(t,n);if(!r.ok)throw Error(r.error.message);a=r.value.absolutePath}let o=await e.remote.session.openWorkspacePath({sessionId:t,path:a,...r.reveal?{action:`reveal`}:{}});if(!o.ok)throw Error(o.error.message)}else await LT(e.remote.workspaceFiles,e.sidebarRight,t,i,n,r?.line)},openSkill:n=>{let r=e.sessions.scope(t);r!==void 0&&e.get(`inputTriggers`)?.sessionOf(r).openReference(`skill`,{ref:`/${n}`})},resolveLink:e.get(`chatLinks`)?.resolve,openLinkInSidebar:g,openExternalLink:e=>{p.getSnapshot()===`sidebar`&&g(e)||window.open(e,`_blank`,`noopener,noreferrer`)},loadOlder:()=>{i.loadOlder()},loadThrough:e=>i.loadThrough(e),loadImage:Object.assign(n=>e.uiConversation.imageUrl(t,n),{peek:n=>e.uiConversation.peekImageUrl(t,n)}),chatScroll:{save:e=>{e===null?d.delete(t):d.set(t,e)},read:()=>d.get(t)??null},loadTurnDiffs:l?(e,n)=>l.read(t,e,n):void 0,editMessage:s?(e,n)=>s.send(t,e,n):void 0,forkAt:m?n=>{let r=[...a.getSnapshot().timeline.turns.values()].find(e=>e.end?.seq===n)?.data.get(`turn-tail`)?.closing?.finalNode.messageId;return e.sessions.fork({sessionId:t,atSeq:n,increaseTitle:!0,onCreated:n=>{e.get(`productAnalytics`)?.track(`branch_session_click`,{session_id:n,parent_session_id:t,...r===void 0?{}:{parent_message_id:r},click_position:`footer`})}}).then(t=>{e.uiWorkspace.openSession(t)})}:void 0,openSession:t=>{let n=t;e.sessions.list.getSnapshot().byId[n]===void 0?e.sessions.loadSummary(n).catch(()=>void 0).finally(()=>{e.uiWorkspace.openSession(n)}):e.uiWorkspace.openSession(n)},clearHandoffRequest:e=>{r.getSnapshot()?.seq===e&&r.set(null)},loadModelCatalog:_?async()=>{let t=await e.remote.session.modelCatalog(void 0);if(!t.ok)throw Error(t.error.message);return t.value}:void 0,handoff:_?async({atSeq:n,targetHarnessId:r,targetModel:i,targetThinkingOptionId:a})=>{let o=(await u.handoff({sessionId:t,...n===void 0?{}:{atSeq:n},targetHarnessId:r,...i===void 0?{}:{targetModel:i},...a===void 0?{}:{targetThinkingOptionId:a}})).sessionId;e.sessions.list.getSnapshot().byId[o]===void 0&&await e.sessions.loadSummary(o).catch(()=>void 0),e.uiWorkspace.openSession(o)}:void 0}}},rb)),e.slots.inject(`shell.overlay`,()=>e.slots.register({name:`shell.overlay`,id:`chat.quota-notice`,locale:ab,children:{"shell.quota-notice":{kind:`chain`,scope:`root`}},inject:()=>({hooks:{notice:t},dismissNotice:()=>{a.clear(),t.set(null)},keepNoticeOpen:()=>{if(t.getSnapshot()===null)return()=>{};let e=Symbol(`ui-chat quota notice hold`);return a.add(e),()=>{a.delete(e)}}})},Gw)),e.slots.inject(`conversation.input.dock`,()=>e.slots.register({name:`conversation.input.dock`,id:`file-changes`,order:5,locale:ab},ee)),e.slots.inject(`conversation.approval.detail`,()=>e.slots.register({name:`conversation.approval.detail`},k))}return n.EMPTY_CHAT_SNAPSHOT=fe,n.apply=HT,n.inject=VT,n.isRunningTool=Mx,n.isSettledTool=jx,t.exports}});