@markus-global/cli 0.12.4 → 0.12.5-rc.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/dist/background-maintenance.d.ts +25 -0
  2. package/dist/background-maintenance.d.ts.map +1 -1
  3. package/dist/background-maintenance.js +61 -0
  4. package/dist/background-maintenance.js.map +1 -1
  5. package/dist/commands/im-inbound-origin.d.ts +38 -0
  6. package/dist/commands/im-inbound-origin.d.ts.map +1 -0
  7. package/dist/commands/im-inbound-origin.js +48 -0
  8. package/dist/commands/im-inbound-origin.js.map +1 -0
  9. package/dist/commands/start.d.ts.map +1 -1
  10. package/dist/commands/start.js +211 -46
  11. package/dist/commands/start.js.map +1 -1
  12. package/dist/markus.mjs +18520 -9886
  13. package/dist/web-ui/assets/{AsyncState-BTLUPIr1.js → AsyncState-ByYn1wrM.js} +1 -1
  14. package/dist/web-ui/assets/ChatComponents-Bwh8SlUV.js +14 -0
  15. package/dist/web-ui/assets/{ContentRenderer-BZXRiKE3.js → ContentRenderer-GLgoGp2a.js} +6 -6
  16. package/dist/web-ui/assets/DeliverableShareModal-CRfnRuR3.js +1 -0
  17. package/dist/web-ui/assets/{Deliverables-3Y3zjT_1.js → Deliverables-EFsnf6kU.js} +2 -2
  18. package/dist/web-ui/assets/MarkdownMessage-CaLBeMto.js +4 -0
  19. package/dist/web-ui/assets/{Search-BI3hk-5j.js → Search-COiaXUNr.js} +1 -1
  20. package/dist/web-ui/assets/{SendToChat-D_5zHO-k.js → SendToChat-DleryIlc.js} +1 -1
  21. package/dist/web-ui/assets/Settings-CzY8z2Yh.js +8 -0
  22. package/dist/web-ui/assets/{Store-B8ksRjHF.js → Store-C4VpQCM_.js} +1 -1
  23. package/dist/web-ui/assets/Switch-ByogYoGH.js +1 -0
  24. package/dist/web-ui/assets/Team-Cutq2J24.js +93 -0
  25. package/dist/web-ui/assets/Work-BO-mz-na.js +142 -0
  26. package/dist/web-ui/assets/{arc-VmvI7TpW.js → arc-mYv67jdD.js} +1 -1
  27. package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-CTUtPasm.js → architectureDiagram-3BPJPVTR-Bzpz_1r6.js} +1 -1
  28. package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-xeYAqtZJ.js → blockDiagram-GPEHLZMM-BBrLiivl.js} +1 -1
  29. package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-BiFgoGY5.js → c4Diagram-AAUBKEIU-BwDUoXA_.js} +1 -1
  30. package/dist/web-ui/assets/channel-Bx09lbhA.js +1 -0
  31. package/dist/web-ui/assets/{chunk-2J33WTMH-DueHBqOn.js → chunk-2J33WTMH-DCSfJ-S9.js} +1 -1
  32. package/dist/web-ui/assets/{chunk-4BX2VUAB-B8zgDfSV.js → chunk-4BX2VUAB-CI0n1b2H.js} +1 -1
  33. package/dist/web-ui/assets/{chunk-55IACEB6-DieD55CP.js → chunk-55IACEB6-DqlSWLrm.js} +1 -1
  34. package/dist/web-ui/assets/{chunk-727SXJPM-Do4Z9LQ0.js → chunk-727SXJPM-BtmAfGYV.js} +1 -1
  35. package/dist/web-ui/assets/{chunk-AQP2D5EJ-qrYsW5ml.js → chunk-AQP2D5EJ-BgkA4lpQ.js} +1 -1
  36. package/dist/web-ui/assets/{chunk-FMBD7UC4-BSz3QT1q.js → chunk-FMBD7UC4-DCSr1JH4.js} +1 -1
  37. package/dist/web-ui/assets/{chunk-ND2GUHAM-utDWSydt.js → chunk-ND2GUHAM-CETYBRRm.js} +1 -1
  38. package/dist/web-ui/assets/{chunk-QZHKN3VN-Cd86CYHV.js → chunk-QZHKN3VN-C58yD7lH.js} +1 -1
  39. package/dist/web-ui/assets/classDiagram-4FO5ZUOK-DGZqU3iA.js +1 -0
  40. package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-DGZqU3iA.js +1 -0
  41. package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-Dc6cP9WW.js → cose-bilkent-S5V4N54A-BpvdK03m.js} +1 -1
  42. package/dist/web-ui/assets/{dagre-BM42HDAG-4b0Wf_6D.js → dagre-BM42HDAG-CZ1K-KD5.js} +1 -1
  43. package/dist/web-ui/assets/{diagram-2AECGRRQ-zS_j1Kf4.js → diagram-2AECGRRQ-D136Ok1V.js} +1 -1
  44. package/dist/web-ui/assets/{diagram-5GNKFQAL-CPo-_Ime.js → diagram-5GNKFQAL-Ji6qPYYV.js} +1 -1
  45. package/dist/web-ui/assets/{diagram-KO2AKTUF-CjHOA4_j.js → diagram-KO2AKTUF-B-s2RC-f.js} +1 -1
  46. package/dist/web-ui/assets/{diagram-LMA3HP47-CalZRF6K.js → diagram-LMA3HP47-COWaps70.js} +1 -1
  47. package/dist/web-ui/assets/{diagram-OG6HWLK6-DnLAhsLX.js → diagram-OG6HWLK6-bh6MvwWn.js} +1 -1
  48. package/dist/web-ui/assets/{docx-preview-uRVPnxwM.js → docx-preview-BRynUqJd.js} +1 -1
  49. package/dist/web-ui/assets/{erDiagram-TEJ5UH35-L0nzlMSn.js → erDiagram-TEJ5UH35-DOPh2LlL.js} +1 -1
  50. package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-Bdc3UwtW.js → flowDiagram-I6XJVG4X-B_kxDHIp.js} +1 -1
  51. package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-CFRmj_qc.js → ganttDiagram-6RSMTGT7-DYBKHOkK.js} +1 -1
  52. package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-B5hZwcoJ.js → gitGraphDiagram-PVQCEYII-D8_0BxLC.js} +1 -1
  53. package/dist/web-ui/assets/index-9SXWNIl0.css +1 -0
  54. package/dist/web-ui/assets/index-TAHyKznL.js +867 -0
  55. package/dist/web-ui/assets/{infoDiagram-5YYISTIA-DVT4RgPd.js → infoDiagram-5YYISTIA-DayJP7Ws.js} +1 -1
  56. package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-Bf7pvUY_.js → ishikawaDiagram-YF4QCWOH-vzxCYVSq.js} +1 -1
  57. package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-NVRjJlnd.js → journeyDiagram-JHISSGLW-B-Fud82o.js} +1 -1
  58. package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-Co7BKMut.js → kanban-definition-UN3LZRKU-DzuKdB65.js} +1 -1
  59. package/dist/web-ui/assets/{mermaid.core-CCf28Hq6.js → mermaid.core-D4ql87kI.js} +5 -5
  60. package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-DepMhVEb.js → mindmap-definition-RKZ34NQL-DosvXt2g.js} +1 -1
  61. package/dist/web-ui/assets/{pieDiagram-4H26LBE5-Cq9ANaI0.js → pieDiagram-4H26LBE5-DhXtMWhr.js} +1 -1
  62. package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-CUY0BWhQ.js → quadrantDiagram-W4KKPZXB-D33pLLOq.js} +1 -1
  63. package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-D9fU5rCm.js → requirementDiagram-4Y6WPE33-B-iIz-XM.js} +1 -1
  64. package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-CMHhuSQF.js → sankeyDiagram-5OEKKPKP-BMd9AFEW.js} +1 -1
  65. package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-Bjx53SID.js → sequenceDiagram-3UESZ5HK-CI1MIdwo.js} +1 -1
  66. package/dist/web-ui/assets/{stateDiagram-AJRCARHV-DVvatKnO.js → stateDiagram-AJRCARHV-Bq6FKPW2.js} +1 -1
  67. package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-8nMhmWY5.js +1 -0
  68. package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-9I80LG9m.js → timeline-definition-PNZ67QCA-BDdmmSRo.js} +1 -1
  69. package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-B82Deutq.js → vennDiagram-CIIHVFJN-DP2q5vY2.js} +1 -1
  70. package/dist/web-ui/assets/{wardley-L42UT6IY-BKXtp57W.js → wardley-L42UT6IY-Bw3fjszD.js} +1 -1
  71. package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-DzqTzfYa.js → wardleyDiagram-YWT4CUSO-37bQUocJ.js} +1 -1
  72. package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-TowyDWYu.js → xychartDiagram-2RQKCTM6-DnLDZyNC.js} +1 -1
  73. package/dist/web-ui/index.html +2 -2
  74. package/docs/README.md +50 -16
  75. package/docs/api/guides/websocket.md +43 -0
  76. package/docs/api/reference.md +657 -0
  77. package/docs/architecture/a2a-communication.md +303 -0
  78. package/docs/architecture/agent-runtime.md +145 -28
  79. package/docs/architecture/architecture.md +30 -11
  80. package/docs/architecture/cognitive-architecture.md +189 -15
  81. package/docs/architecture/concurrent-processing.md +190 -31
  82. package/docs/architecture/context-assembly.md +264 -0
  83. package/docs/architecture/derived-views.md +463 -0
  84. package/docs/architecture/desktop-auto-update.md +185 -0
  85. package/docs/architecture/facts.md +406 -0
  86. package/docs/architecture/learning-loop.md +11 -0
  87. package/docs/architecture/limits.md +79 -0
  88. package/docs/architecture/mailbox-system.md +786 -668
  89. package/docs/architecture/memory-system.md +1 -1
  90. package/docs/architecture/messaging-gateway.md +7 -0
  91. package/docs/architecture/notification-delivery.md +221 -0
  92. package/docs/architecture/notification-sounds.md +177 -0
  93. package/docs/architecture/prompt-engineering.md +171 -700
  94. package/docs/{design/remote-access-contract.md → architecture/remote-access.md} +4 -0
  95. package/docs/architecture/state-machines.md +288 -5
  96. package/docs/architecture/tool-loop-harness.md +362 -0
  97. package/docs/architecture/tool-system.md +40 -16
  98. package/docs/design/background-callback-in-turn-delivery-2026-11-22.md +95 -0
  99. package/docs/design/c10-0b-pick-identity-leak-2026-11-22.md +233 -0
  100. package/docs/design/c10-a-identity-columns-2026-11-22.md +182 -0
  101. package/docs/design/c10-c-trust-boundary-2026-11-23.md +222 -0
  102. package/docs/design/c10-external-adapters-plan-2026-11-19.md +448 -0
  103. package/docs/design/c8-residual-mechanisms-2026-11-15.md +984 -0
  104. package/docs/design/external-signal-decision-loop-2026-11-25.md +579 -0
  105. package/docs/guides/development.md +1 -1
  106. package/docs/{architecture → guides}/mailbox-audit-checklist.md +7 -0
  107. package/docs/guides/remote-access.md +1 -1
  108. package/docs/{design/agent-stop-intent-audit.md → records/agent-stop-intent-audit-2026-11-08.md} +4 -0
  109. package/docs/records/c10-l5-gate-verification-2026-11-26.md +72 -0
  110. package/docs/records/c10-l5-live-verification-2026-11-25.md +117 -0
  111. package/docs/records/cut6-c4-verification-2026-11-12.md +268 -0
  112. package/docs/records/cut6-mailbox-address-envelope-design-2026-11-12.md +871 -0
  113. package/docs/records/cut7-c7a-red-green-evidence-2026-11-13.md +105 -0
  114. package/docs/records/cut7-c7a-workunit-implementation-2026-11-13.md +116 -0
  115. package/docs/records/cut7-c7b-verification-2026-11-14.md +90 -0
  116. package/docs/records/cut7-live-verification-2026-11-14.md +33 -0
  117. package/docs/records/cut7-wiring-negative-cache-2026-11-14.md +64 -0
  118. package/docs/records/cut7-workunit-execution-plan-2026-11-13.md +206 -0
  119. package/docs/records/cut8-a-entity-keys-design-2026-11-14.md +377 -0
  120. package/docs/records/cut8-b-turn-delta-injection-2026-11-14.md +362 -0
  121. package/docs/records/cut8-c-single-clock-2026-11-14.md +119 -0
  122. package/docs/records/cut8-c-single-clock-design-2026-11-14.md +150 -0
  123. package/docs/records/cut8-d-2026-11-14.md +231 -0
  124. package/docs/records/cut8-live-verification-2026-11-14.md +1018 -0
  125. package/docs/records/cut9-adjacent-identity-paths-2026-11-15.md +200 -0
  126. package/docs/records/cut9-identity-declaration-2026-11-15.md +163 -0
  127. package/docs/records/cut9-inbox-dual-run-diff-2026-11-15.md +117 -0
  128. package/docs/records/cut9-live-verification-2026-11-15.md +222 -0
  129. package/docs/records/cut9-runtime-probe-2026-11-19.md +520 -0
  130. package/docs/{design/deliverable-sharing.md → records/deliverable-sharing-2026-08-12.md} +10 -3
  131. package/docs/records/identity-backlog-disposition-2026-11-22.md +143 -0
  132. package/docs/records/marketplace-orphan-freeze-2026-11-22.md +239 -0
  133. package/docs/{architecture/notify-user-context-truth.md → records/notify-user-context-truth-2026-10-28.md} +6 -0
  134. package/docs/{handoff → records}/remote-access-handoff.md +1 -1
  135. package/package.json +1 -1
  136. package/templates/roles/HANDBOOK.md +1 -1
  137. package/templates/skills/agent-building/SKILL.md +1 -1
  138. package/dist/web-ui/assets/ChatComponents-DTB3H_n2.js +0 -12
  139. package/dist/web-ui/assets/DeliverableShareModal-BwZP39nd.js +0 -1
  140. package/dist/web-ui/assets/MarkdownMessage-DVfFMzM9.js +0 -4
  141. package/dist/web-ui/assets/Settings-DTUjLhJY.js +0 -8
  142. package/dist/web-ui/assets/Switch-RmZHA47D.js +0 -1
  143. package/dist/web-ui/assets/Team-BRgI1zM9.js +0 -85
  144. package/dist/web-ui/assets/Work-nah0UYFz.js +0 -142
  145. package/dist/web-ui/assets/channel-s7K3KXLr.js +0 -1
  146. package/dist/web-ui/assets/classDiagram-4FO5ZUOK-B2mHhFY8.js +0 -1
  147. package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-B2mHhFY8.js +0 -1
  148. package/dist/web-ui/assets/index-CzHSs0Vd.css +0 -1
  149. package/dist/web-ui/assets/index-TPf50ZeO.js +0 -867
  150. package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-92MmE2MZ.js +0 -1
  151. package/docs/api/api.md +0 -353
  152. package/docs/architecture/llm-provider-timeouts.md +0 -60
  153. package/docs/architecture/state-ownership.md +0 -83
  154. /package/docs/architecture/{frontend/team-chat.md → team-chat.md} +0 -0
  155. /package/docs/{analysis → records}/2026-10-29-a2a-cache-hit-rate.md +0 -0
  156. /package/docs/{fixes → records}/2026-11-12-session-expiry-and-mention-thinking.md +0 -0
  157. /package/docs/{handoff → records}/approval-tri-state-handoff.md +0 -0
  158. /package/docs/{design → records}/overview-attention-redesign.md +0 -0
  159. /package/docs/{remote-access/fast-path-plan.md → records/remote-access-fast-path-plan-2026-10-17.md} +0 -0
@@ -1 +1 @@
1
- import{u as c,j as e}from"./index-TPf50ZeO.js";function a(...t){return t.filter(Boolean).join(" ")}function d({className:t}){return e.jsxs("svg",{className:a("animate-spin shrink-0",t??"w-3.5 h-3.5"),viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2.5",opacity:"0.2"}),e.jsx("path",{d:"M21 12a9 9 0 0 0-9-9",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"})]})}function u({label:t,className:r}){const{t:n}=c("common");return e.jsxs("div",{className:a("flex-1 flex flex-col items-center justify-center gap-2.5 py-10 text-fg-tertiary",r),role:"status","aria-live":"polite",children:[e.jsx(d,{className:"w-5 h-5 text-brand-400"}),e.jsx("span",{className:"text-xs",children:t??n("loading")})]})}function p({rows:t=3,label:r,variant:n="skeleton",className:s}){const{t:i}=c("common");return n==="text"?e.jsxs("div",{className:a("flex items-center gap-2 px-1 py-2 text-xs text-fg-tertiary",s),role:"status","aria-live":"polite",children:[e.jsx(d,{className:"w-3 h-3"}),e.jsx("span",{children:r??i("loading")})]}):e.jsx("div",{className:a("space-y-2.5 p-1",s),role:"status","aria-live":"polite","aria-label":r??i("loading"),children:Array.from({length:t}).map((o,l)=>e.jsxs("div",{className:"animate-pulse space-y-1.5",children:[e.jsx("div",{className:"h-3.5 bg-surface-elevated rounded w-2/3"}),e.jsx("div",{className:"h-2.5 bg-surface-elevated/70 rounded w-1/3"})]},l))})}function f({icon:t,title:r,hint:n,action:s,size:i="md",className:o}){const l=i==="sm"?"py-6":i==="lg"?"py-16":"py-10",x=i==="sm"?"text-xs":"text-sm";return e.jsxs("div",{className:a("flex flex-col items-center justify-center text-center px-4",l,o),children:[t&&e.jsx("div",{className:"mb-2.5 text-fg-muted",children:t}),e.jsx("div",{className:a("font-medium text-fg-secondary",x),children:r}),n&&e.jsx("div",{className:"mt-1 text-xs text-fg-tertiary max-w-xs leading-relaxed",children:n}),s&&e.jsx("button",{onClick:s.onClick,className:a("mt-3 px-3 py-1.5 rounded-md text-xs font-medium transition-colors",s.variant==="secondary"?"border border-border-default text-fg-secondary hover:bg-surface-elevated":"bg-brand-600 hover:bg-brand-500 text-on-brand"),children:s.label})]})}export{f as E,p as L,u as P,d as S};
1
+ import{u as c,j as e}from"./index-TAHyKznL.js";function a(...t){return t.filter(Boolean).join(" ")}function d({className:t}){return e.jsxs("svg",{className:a("animate-spin shrink-0",t??"w-3.5 h-3.5"),viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2.5",opacity:"0.2"}),e.jsx("path",{d:"M21 12a9 9 0 0 0-9-9",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"})]})}function u({label:t,className:r}){const{t:n}=c("common");return e.jsxs("div",{className:a("flex-1 flex flex-col items-center justify-center gap-2.5 py-10 text-fg-tertiary",r),role:"status","aria-live":"polite",children:[e.jsx(d,{className:"w-5 h-5 text-brand-400"}),e.jsx("span",{className:"text-xs",children:t??n("loading")})]})}function p({rows:t=3,label:r,variant:n="skeleton",className:s}){const{t:i}=c("common");return n==="text"?e.jsxs("div",{className:a("flex items-center gap-2 px-1 py-2 text-xs text-fg-tertiary",s),role:"status","aria-live":"polite",children:[e.jsx(d,{className:"w-3 h-3"}),e.jsx("span",{children:r??i("loading")})]}):e.jsx("div",{className:a("space-y-2.5 p-1",s),role:"status","aria-live":"polite","aria-label":r??i("loading"),children:Array.from({length:t}).map((o,l)=>e.jsxs("div",{className:"animate-pulse space-y-1.5",children:[e.jsx("div",{className:"h-3.5 bg-surface-elevated rounded w-2/3"}),e.jsx("div",{className:"h-2.5 bg-surface-elevated/70 rounded w-1/3"})]},l))})}function f({icon:t,title:r,hint:n,action:s,size:i="md",className:o}){const l=i==="sm"?"py-6":i==="lg"?"py-16":"py-10",x=i==="sm"?"text-xs":"text-sm";return e.jsxs("div",{className:a("flex flex-col items-center justify-center text-center px-4",l,o),children:[t&&e.jsx("div",{className:"mb-2.5 text-fg-muted",children:t}),e.jsx("div",{className:a("font-medium text-fg-secondary",x),children:r}),n&&e.jsx("div",{className:"mt-1 text-xs text-fg-tertiary max-w-xs leading-relaxed",children:n}),s&&e.jsx("button",{onClick:s.onClick,className:a("mt-3 px-3 py-1.5 rounded-md text-xs font-medium transition-colors",s.variant==="secondary"?"border border-border-default text-fg-secondary hover:bg-surface-elevated":"bg-brand-600 hover:bg-brand-500 text-on-brand"),children:s.label})]})}export{f as E,p as L,u as P,d as S};
@@ -0,0 +1,14 @@
1
+ import{a4 as lt,j as n,a5 as ct,r as g,u as T,a6 as Y,a1 as ve,k as U,U as Ue,a7 as ie,n as Pe,P as Ke,l as ne,$ as V,a8 as dt,A as We,a9 as ut}from"./index-TAHyKznL.js";import{MarkdownMessage as R}from"./MarkdownMessage-CaLBeMto.js";import{n as pt}from"./chatChips-DVIRVTpT.js";function me({text:e,linkClassName:t="text-brand-500 hover:underline break-all"}){const r=lt(e);return r.length<=1?n.jsx(n.Fragment,{children:e}):n.jsx(n.Fragment,{children:r.map((s,a)=>s.kind==="link"?n.jsx("a",{href:s.value,target:"_blank",rel:"noopener noreferrer",className:t,onClick:o=>{o.preventDefault(),o.stopPropagation(),ct(s.value)},children:s.value},a):n.jsx(g.Fragment,{children:s.value},a))})}const xe=6e4,ze=60*xe,mt=24*ze;function Tn(e,t){const r=new Date(e).getTime();if(!Number.isFinite(r))return"";const s=Date.now()-r;if(s<xe)return t("common:time.now");const a=Math.floor(s/xe);if(a<60)return t("common:time.minutesAgo",{count:a});const o=Math.floor(s/ze);return o<24?t("common:time.hoursAgo",{count:o}):t("common:time.daysAgo",{count:Math.floor(s/mt)})}function Sn(e,t){if(!e)return"";const r=new Date(e);if(Number.isNaN(r.getTime()))return"";try{return new Intl.DateTimeFormat(t||void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(r)}catch{return r.toLocaleString()}}const fe={suppressAdjustUntil:0};function X(e=2500){const t=typeof performance<"u"?performance.now():Date.now();fe.suppressAdjustUntil=Math.max(fe.suppressAdjustUntil,t+e)}function En(){return(typeof performance<"u"?performance.now():Date.now())<fe.suppressAdjustUntil}const Ne={shell_execute:{label:"Running command",icon:"⌨"},list_terminals:{label:"Listing terminals",icon:"⌨"},new_terminal:{label:"Opening terminal",icon:"⌨"},select_terminal:{label:"Selecting terminal",icon:"⌨"},close_terminal:{label:"Closing terminal",icon:"⌨"},read_terminal:{label:"Reading terminal",icon:"⌨"},write_terminal:{label:"Writing terminal",icon:"⌨"},exec_terminal:{label:"Running in terminal",icon:"⌨"},file_read:{label:"Reading file",icon:"📄"},file_write:{label:"Writing file",icon:"✏"},file_edit:{label:"Editing file",icon:"✏"},apply_patch:{label:"Applying patch",icon:"🔀"},list_directory:{label:"Listing directory",icon:"📂"},glob_find:{label:"Finding files",icon:"🔍"},grep_search:{label:"Searching code",icon:"🔍"},web_fetch:{label:"Fetching page",icon:"🌐"},web_search:{label:"Searching web",icon:"🔍"},web_extract:{label:"Extracting content",icon:"📑"},create_task:{label:"Creating task",icon:"📌"},task_create:{label:"Creating task",icon:"📌"},create_subtask:{label:"Adding subtask",icon:"📌"},update_task:{label:"Updating task",icon:"✅"},task_update:{label:"Updating task",icon:"✅"},add_task_note:{label:"Adding note",icon:"📝"},task_add_note:{label:"Adding note",icon:"📝"},task_list:{label:"Listing tasks",icon:"☑️"},task_get:{label:"Getting task",icon:"☑️"},task_note:{label:"Adding note",icon:"📝"},task_assign:{label:"Assigning task",icon:"👥"},task_submit_review:{label:"Submitting for review",icon:"✅"},task_comment:{label:"Commenting task",icon:"💬"},subtask_create:{label:"Adding subtask",icon:"📌"},subtask_complete:{label:"Completing subtask",icon:"✅"},subtask_cancel:{label:"Cancelling subtask",icon:"🚫"},subtask_list:{label:"Listing subtasks",icon:"☑️"},requirement_propose:{label:"Proposing requirement",icon:"🎯"},requirement_list:{label:"Listing requirements",icon:"🎯"},requirement_get:{label:"Getting requirement",icon:"🎯"},requirement_update:{label:"Updating requirement",icon:"🎯"},requirement_update_status:{label:"Updating req status",icon:"✅"},requirement_resubmit:{label:"Resubmitting requirement",icon:"🎯"},requirement_comment:{label:"Commenting requirement",icon:"💬"},list_projects:{label:"Listing projects",icon:"🗂"},get_project:{label:"Getting project",icon:"🗂"},create_project:{label:"Creating project",icon:"🗂"},update_project:{label:"Updating project",icon:"🗂"},deliverable_create:{label:"Creating deliverable",icon:"📦"},deliverable_search:{label:"Searching deliverables",icon:"🔍"},deliverable_list:{label:"Listing deliverables",icon:"📦"},deliverable_update:{label:"Updating deliverable",icon:"📦"},agent_ask_agent:{label:"Asking another agent",icon:"💬"},git_status:{label:"Git status",icon:"🔀"},git_diff:{label:"Git diff",icon:"🔀"},git_log:{label:"Git log",icon:"📜"},git_branch:{label:"Git branch",icon:"🌿"},git_add:{label:"Git add",icon:"➕"},git_commit:{label:"Git commit",icon:"💾"},project_structure:{label:"Project structure",icon:"🗂"},code_stats:{label:"Code stats",icon:"📊"},navigate_page:{label:"Opening page",icon:"🌐"},new_page:{label:"Opening new tab",icon:"🌐"},close_page:{label:"Closing tab",icon:"🌐"},select_page:{label:"Switching tab",icon:"🌐"},list_pages:{label:"Listing tabs",icon:"🌐"},click:{label:"Clicking element",icon:"👆"},hover:{label:"Hovering element",icon:"👆"},fill:{label:"Filling field",icon:"⌨"},fill_form:{label:"Filling form",icon:"⌨"},type_text:{label:"Typing text",icon:"⌨"},press_key:{label:"Pressing key",icon:"⌨"},take_screenshot:{label:"Screenshot",icon:"📸"},take_snapshot:{label:"Page snapshot",icon:"📋"},evaluate_script:{label:"Running script",icon:"⚙"},wait_for:{label:"Waiting",icon:"⏳"},list_console_messages:{label:"Console logs",icon:"🔍"},list_network_requests:{label:"Network requests",icon:"🔍"},lighthouse_audit:{label:"Running audit",icon:"📊"},agent_send_message:{label:"Messaging colleague",icon:"💬"},agent_list_colleagues:{label:"Checking team",icon:"👥"},memory_save:{label:"Saving memory",icon:"💾"},memory_search:{label:"Searching memory",icon:"🔍"},memory_list:{label:"Listing memory",icon:"💾"},memory_update:{label:"Updating memory",icon:"💾"},recall_activity:{label:"Recalling activity",icon:"📜"},notebook_upsert:{label:"Updating notebook",icon:"📝"},kb_search:{label:"Searching knowledge base",icon:"📚"},kb_list:{label:"Listing knowledge base",icon:"📚"},kb_read:{label:"Reading knowledge base",icon:"📚"},notify_user:{label:"Notifying user",icon:"🔔"},request_user_input:{label:"Requesting input",icon:"❓"},request_user_approval:{label:"Requesting approval",icon:"❓"},schedule_wakeup:{label:"Scheduling wakeup",icon:"⏰"},cancel_wakeup:{label:"Cancelling wakeup",icon:"⏰"},set_heartbeat_interval:{label:"Setting heartbeat",icon:"⏱"},discover_tools:{label:"Discovering tools",icon:"🧰"},check_mailbox:{label:"Checking mailbox",icon:"📥"},goal_create:{label:"Creating goal",icon:"🎯"},goal_update:{label:"Updating goal",icon:"🎯"},goal_status:{label:"Goal status",icon:"🎯"},background_exec:{label:"Background command",icon:"⌨"},process:{label:"Managing process",icon:"⚙"},feishu_send_message:{label:"Sending Feishu msg",icon:"✉"},feishu_search_docs:{label:"Searching Feishu",icon:"🔍"},spawn_subagent:{label:"Spawn Subagent",icon:"◎"},spawn_subagents:{label:"Spawn Subagents",icon:"◎"},invoke_coding_tool:{label:"Invoke Coding Tool",icon:"🛠"},coding_tool_apply:{label:"Apply Coding Result",icon:"🔀"},generate_image:{label:"Generating image",icon:"🖼"},text_to_speech:{label:"Generating speech",icon:"🔊"},speech_to_text:{label:"Transcribing audio",icon:"🎙"},generate_video:{label:"Generating video",icon:"🎬"},llm_list_providers:{label:"Listing providers",icon:"⚙"},llm_switch_model:{label:"Switching model",icon:"⚙"},llm_switch_default_provider:{label:"Switching provider",icon:"⚙"},llm_add_provider:{label:"Adding provider",icon:"⚙"},llm_edit_provider:{label:"Editing provider",icon:"⚙"},llm_add_model:{label:"Adding model",icon:"⚙"},llm_get_capability_routing:{label:"Checking capability routing",icon:"⚙"},llm_set_capability_routing:{label:"Setting capability routing",icon:"⚙"},team_list:{label:"Listing teams",icon:"👥"},team_status:{label:"Team status",icon:"👥"},team_start:{label:"Starting team",icon:"👥"},team_stop:{label:"Stopping team",icon:"👥"},team_update:{label:"Updating team",icon:"👥"},agent_start:{label:"Starting agent",icon:"◎"},agent_stop:{label:"Stopping agent",icon:"◎"},agent_update:{label:"Updating agent",icon:"◎"},agent_delegate_task:{label:"Delegating task",icon:"📌"},agent_broadcast_status:{label:"Broadcasting status",icon:"📣"},agent_create_group_chat:{label:"Creating group chat",icon:"💬"},agent_list_group_chats:{label:"Listing group chats",icon:"💬"},agent_send_group_message:{label:"Sending group message",icon:"💬"},delete_project:{label:"Deleting project",icon:"🗂"},project_stats:{label:"Project stats",icon:"📊"},hub_search:{label:"Searching Hub",icon:"🔍"},hub_install:{label:"Installing from Hub",icon:"📦"},package_list:{label:"Listing packages",icon:"📦"},package_install:{label:"Installing package",icon:"📦"},memory_delete:{label:"Deleting memory",icon:"💾"},memory_update_longterm:{label:"Updating long-term memory",icon:"💾"},notebook_clear:{label:"Clearing notebook",icon:"📝"},notebook_read:{label:"Reading notebook",icon:"📝"},recall_context:{label:"Recalling context",icon:"📜"},defer_mailbox_item:{label:"Deferring mailbox item",icon:"📥"},drop_mailbox_item:{label:"Dropping mailbox item",icon:"📥"},prioritize_mailbox_item:{label:"Prioritizing mailbox",icon:"📥"},delegate_message:{label:"Delegating message",icon:"💬"},task_board_health:{label:"Checking task board",icon:"📋"},task_check_duplicates:{label:"Checking duplicates",icon:"📋"},task_cleanup_duplicates:{label:"Cleaning duplicates",icon:"📋"},workflow_list:{label:"Listing workflows",icon:"🔄"},workflow_create:{label:"Creating workflow",icon:"🔄"},workflow_update:{label:"Updating workflow",icon:"🔄"},workflow_delete:{label:"Deleting workflow",icon:"🔄"},workflow_run:{label:"Running workflow",icon:"🔄"},workflow_status:{label:"Workflow status",icon:"🔄"},workflow_cancel:{label:"Cancelling workflow",icon:"🔄"},open_page:{label:"Opening page",icon:"🌐"},resize_page:{label:"Resizing page",icon:"🌐"},drag:{label:"Dragging element",icon:"👆"},upload_file:{label:"Uploading file",icon:"📎"},emulate:{label:"Emulating device",icon:"📱"},handle_dialog:{label:"Handling dialog",icon:"💬"},get_console_message:{label:"Console message",icon:"🔍"},get_network_request:{label:"Network request",icon:"🔍"}},Ce={shell_execute:"square-terminal",background_exec:"square-terminal",process:"settings",list_terminals:"square-terminal",new_terminal:"square-terminal",select_terminal:"square-terminal",close_terminal:"square-terminal",read_terminal:"square-terminal",write_terminal:"square-terminal",exec_terminal:"square-terminal",file_read:"file-text",file_write:"edit",file_edit:"edit",apply_patch:"git-branch",list_directory:"folder",glob_find:"search",grep_search:"search",web_fetch:"globe",web_search:"search",web_extract:"file-text",create_task:"clipboard",task_create:"clipboard",create_subtask:"clipboard",update_task:"check-circle",task_update:"check-circle",add_task_note:"edit",task_add_note:"edit",task_note:"edit",task_list:"clipboard",task_get:"clipboard",task_assign:"users",task_submit_review:"check-circle",task_comment:"message-square",subtask_create:"clipboard",subtask_complete:"check-circle",subtask_cancel:"alert-circle",subtask_list:"clipboard",requirement_propose:"clipboard",requirement_list:"clipboard",requirement_get:"clipboard",requirement_update:"clipboard",requirement_update_status:"check-circle",requirement_resubmit:"clipboard",requirement_comment:"message-square",list_projects:"layers",get_project:"layers",create_project:"layers",update_project:"layers",deliverable_create:"package",deliverable_search:"search",deliverable_list:"package",deliverable_update:"edit",git_status:"git-branch",git_diff:"git-branch",git_log:"book-open",git_branch:"git-branch",git_add:"git-branch",git_commit:"save",project_structure:"layers",code_stats:"bar-chart",navigate_page:"globe",new_page:"globe",close_page:"globe",select_page:"globe",list_pages:"globe",click:"target",hover:"target",fill:"terminal",fill_form:"terminal",type_text:"terminal",press_key:"terminal",take_screenshot:"camera",take_snapshot:"camera",evaluate_script:"code",wait_for:"clock",list_console_messages:"terminal",list_network_requests:"globe",lighthouse_audit:"bar-chart",agent_send_message:"message-square",agent_list_colleagues:"users",memory_save:"database",memory_search:"search",memory_list:"database",memory_update:"database",recall_activity:"book-open",notebook_upsert:"edit",kb_search:"book-open",kb_list:"book-open",kb_read:"book-open",notify_user:"megaphone",request_user_input:"message-square",request_user_approval:"check-circle",schedule_wakeup:"clock",cancel_wakeup:"clock",set_heartbeat_interval:"clock",discover_tools:"wrench",check_mailbox:"message-square",goal_create:"target",goal_update:"target",goal_status:"target",feishu_send_message:"message-square",feishu_search_docs:"search",spawn_subagent:"bot",spawn_subagents:"bot",invoke_coding_tool:"wrench",coding_tool_apply:"git-branch",generate_image:"camera",text_to_speech:"headphones",speech_to_text:"headphones",generate_video:"camera",llm_list_providers:"settings",llm_switch_model:"settings",llm_switch_default_provider:"settings",llm_add_provider:"settings",llm_edit_provider:"settings",llm_add_model:"settings",llm_get_capability_routing:"settings",llm_set_capability_routing:"settings",team_list:"users",team_status:"users",team_start:"users",team_stop:"users",team_update:"users",agent_start:"bot",agent_stop:"bot",agent_update:"bot",agent_delegate_task:"clipboard",agent_broadcast_status:"megaphone",agent_create_group_chat:"message-square",agent_list_group_chats:"message-square",agent_send_group_message:"message-square",delete_project:"layers",project_stats:"bar-chart",hub_search:"search",hub_install:"package",package_list:"package",package_install:"package",memory_delete:"database",memory_update_longterm:"database",notebook_clear:"edit",notebook_read:"edit",recall_context:"book-open",defer_mailbox_item:"message-square",drop_mailbox_item:"message-square",prioritize_mailbox_item:"message-square",delegate_message:"message-square",task_board_health:"clipboard",task_check_duplicates:"clipboard",task_cleanup_duplicates:"clipboard",workflow_list:"git-branch",workflow_create:"git-branch",workflow_update:"git-branch",workflow_delete:"git-branch",workflow_run:"git-branch",workflow_status:"git-branch",workflow_cancel:"git-branch",open_page:"globe",resize_page:"globe",drag:"target",upload_file:"file-text",emulate:"settings",handle_dialog:"message-square",get_console_message:"terminal",get_network_request:"globe"};function P(e){const t=e.includes("__")?e.split("__").pop():e,r=Ne[t]??Ne[e],s=Ce[t]??Ce[e]??"settings";return r?{...r,iconName:s,key:t}:{label:t.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase()),icon:"⚙",iconName:s,key:t}}function K(e){return e==null?"":e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function gt(e){const t=new Date(e);if(isNaN(t.getTime()))return e;const r=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0"),a=String(t.getHours()).padStart(2,"0"),o=String(t.getMinutes()).padStart(2,"0"),i=String(t.getSeconds()).padStart(2,"0");return`${r}-${s} ${a}:${o}:${i}`}function he(e,t){return e.length<=t?e:e.slice(0,t)+"…"}function Te(e){try{const t=JSON.parse(e);return JSON.stringify(t,null,2)}catch{return e}}function He(e){return!e||typeof e!="object"?[]:Object.entries(e).filter(([,r])=>r!=null).map(([r,s])=>({key:r,value:typeof s=="string"?s:JSON.stringify(s,null,2)}))}function xt(e){if(e.tool!=="shell_execute"||!e.args||typeof e.args!="object")return null;const t=e.args.command;return typeof t=="string"?t:null}function be(e){const t=new Set;for(let r=0;r<e.length;r++){const s=e[r];if(s.type==="tool"&&(s.info.status==="done"||s.info.status==="error"))for(let a=r-1;a>=0;a--){const o=e[a];if(o.type==="tool"&&o.info.status==="running"&&o.info.tool===s.info.tool&&!t.has(a)){t.add(a);break}}}return e.filter((r,s)=>!t.has(s))}function je(e){const t=gt(e.createdAt),r=e.createdAt,s=e.metadata;switch(e.type){case"text":return s?.isThinking?{type:"thinking",content:e.content,time:t,timestamp:r}:{type:"text",content:e.content,time:t,timestamp:r};case"status":{const a=s?.action;return a&&["chat","chat_stream","task_execution","respond_in_session"].includes(a)?null:{type:"status",content:e.content,time:t,timestamp:r}}case"error":return{type:"error",content:e.content,time:t,timestamp:r};case"tool_start":return{type:"tool",time:t,timestamp:r,key:`es_${e.seq}`,info:{tool:e.content,status:"running",args:s?.arguments,subagentLogs:s?.subagentLogs}};case"tool_end":return{type:"tool",time:t,timestamp:r,key:`ee_${e.seq}`,info:{tool:e.content,status:s?.success===!1?"error":"done",args:s?.arguments,result:s?.result,error:s?.error,durationMs:s?.durationMs,subagentLogs:s?.subagentLogs}};default:return null}}function Ge(e,t){if(e!=="task_create"&&e!=="create_task"||!t)return null;try{const r=JSON.parse(t);if(!r.task)return null;const s=r.task;return{taskId:s.id,title:s.title,description:s.description,assignedAgentId:s.assignedAgentId,priority:s.priority}}catch{return null}}function Ve(e,t){if(e!=="requirement_propose"||!t)return null;try{const r=JSON.parse(t);if(r.status!=="success"||!r.requirement)return null;const s=r.requirement;return s.status!=="pending"?null:{requirementId:s.id,title:s.title,description:s.description,priority:s.priority}}catch{return null}}function ft(e){const t=[];for(const r of e)if(r.phase!=="output"){if(r.phase==="start"){const s=`${r.tool}_${r.ts}`;t.push({key:s,tool:r.tool,status:"running"})}else for(let s=t.length-1;s>=0;s--)if(t[s].tool===r.tool&&t[s].status==="running"){t[s]={...t[s],status:r.success===!1?"error":"done"};break}}return t}function Xe(){return n.jsxs("svg",{className:"w-3 h-3 animate-spin text-brand-500 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[n.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),n.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}function ht(){return n.jsx("span",{className:"flex items-center gap-0.5",children:[0,150,300].map(e=>n.jsx("span",{className:"w-1 h-1 rounded-full bg-brand-400 animate-bounce",style:{animationDelay:`${e}ms`,animationDuration:"1s"}},e))})}function Se({item:e}){const{t}=T("common"),r=P(e.tool);return n.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",children:[n.jsx(Y,{name:r.iconName,size:15,className:`shrink-0 ${e.status==="running"?"text-brand-500":e.status==="error"?"text-red-500":"text-green-500"}`}),n.jsxs("span",{className:`text-xs ${e.status==="running"?"activity-text-shimmer":e.status==="error"?"text-fg-tertiary":"text-fg-secondary"}`,children:[t(`execution.tools.${r.key}`,{defaultValue:r.label}),e.status==="running"?"…":""]}),e.status==="running"&&n.jsx(Xe,{})]})}function Ee({activities:e,isActive:t,persistent:r}){const{t:s}=T("common"),a=ft(e),[o,i]=g.useState(!1),l=a.length>0,d=l&&a.every(x=>x.status!=="running");if(r&&d){const x=a.filter(v=>v.status==="error").length,j=a.filter(v=>v.status==="done").length;return n.jsxs("div",{className:"mb-3 border-b border-border-default/50 pb-2",children:[n.jsxs("button",{onClick:()=>i(v=>!v),className:"flex items-center gap-1.5 text-xs text-fg-tertiary hover:text-fg-secondary transition-colors select-none",children:[n.jsx("span",{className:`transition-transform duration-150 ${o?"rotate-90":""}`,children:"▶"}),n.jsx("span",{className:"font-medium",children:s("activity.step",{count:j})}),x>0&&n.jsxs("span",{className:"text-red-500 ml-0.5",children:["· ",s("activity.failed",{count:x})]}),!o&&n.jsxs("span",{className:"ml-1 flex items-center gap-1",children:[a.slice(0,5).map(v=>{const y=P(v.tool);return n.jsx(Y,{name:y.iconName,size:13,className:`shrink-0 ${v.status==="error"?"text-red-500":"text-green-500"}`},v.key)}),a.length>5&&n.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["+",a.length-5]})]})]}),o&&n.jsx("div",{className:"mt-2 space-y-0.5",children:a.map((v,y)=>n.jsx(Se,{item:v,idx:y,total:a.length},v.key))})]})}if(!l)return n.jsxs("div",{className:"flex items-center gap-1.5 text-xs py-0.5",children:[n.jsx("span",{className:"mr-0.5 activity-text-shimmer",children:s("activity.thinking")}),n.jsx(ht,{})]});const c=a.filter(x=>x.status==="error").length;let u=null;for(let x=a.length-1;x>=0;x--)if(a[x].status==="running"){u=a[x];break}const b=a[a.length-1];let h;if(u){const x=P(u.tool);h=`${s(`execution.tools.${x.key}`,{defaultValue:x.label})}…`}else if(t&&d)h=s("activity.writingResponse");else{const x=P(b.tool);h=s(`execution.tools.${x.key}`,{defaultValue:x.label})}const f=!!u||t&&d;return n.jsxs("div",{className:"mb-1",children:[n.jsxs("button",{onClick:x=>{x.stopPropagation(),i(j=>!j)},className:"flex items-center gap-1.5 text-xs w-full min-w-0 select-none text-fg-tertiary hover:text-fg-secondary transition-colors",children:[n.jsx("span",{className:`shrink-0 transition-transform duration-150 ${o?"rotate-90":""}`,children:"▶"}),n.jsx("span",{className:`truncate font-medium ${f?"activity-text-shimmer":"text-fg-secondary"}`,children:h}),n.jsxs("span",{className:"shrink-0",children:["· ",s("activity.step",{count:a.length})]}),c>0&&n.jsxs("span",{className:"text-red-500 shrink-0",children:["· ",s("activity.failed",{count:c})]}),f&&n.jsx(Xe,{})]}),o&&n.jsx("div",{className:"mt-1 space-y-0.5",children:a.map((x,j)=>n.jsx(Se,{item:x,idx:j,total:a.length},x.key))})]})}const bt=1920,yt=10*1024*1024,Me=5,vt=.8;function jt(e,t,r){return new Promise((s,a)=>{const o=new Image;o.onload=()=>{let{width:i,height:l}=o;if(i<=t&&l<=t){s(e);return}i>l?(l=Math.round(l*(t/i)),i=t):(i=Math.round(i*(t/l)),l=t);const d=document.createElement("canvas");d.width=i,d.height=l;const c=d.getContext("2d");if(!c){a(new Error("Failed to get canvas context"));return}c.drawImage(o,0,0,i,l),s(d.toDataURL("image/jpeg",r))},o.onerror=()=>a(new Error("Failed to load image")),o.src=e})}function kt({candidates:e,filter:t,anchorRef:r,onSelect:s,selectedIndex:a,onIndexChange:o}){const{t:i}=T("common"),[l,d]=g.useState(null),c=g.useRef(null),u=e.filter(b=>b.name.toLowerCase().includes(t));return g.useEffect(()=>{const b=r.current;if(!b)return;const h=b.getBoundingClientRect();d({top:h.top+window.scrollY-4,left:h.left+window.scrollX+8})},[r,t]),g.useEffect(()=>{if(!c.current||!l)return;if(c.current.getBoundingClientRect().top<8){const h=r.current;if(!h)return;const f=h.getBoundingClientRect();d({top:f.bottom+window.scrollY+4,left:l.left})}},[l,r]),g.useEffect(()=>{a>=u.length&&o(Math.max(0,u.length-1))},[u.length,a,o]),g.useEffect(()=>{if(!c.current)return;c.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"nearest"})},[a]),!l||u.length===0?null:ve.createPortal(n.jsxs("div",{ref:c,style:{position:"absolute",top:l.top,left:l.left,transform:"translateY(-100%)"},className:"w-60 bg-surface-overlay border border-border-default rounded-lg shadow-xl z-[9999] max-h-48 overflow-y-auto",children:[n.jsx("div",{className:"px-2.5 py-1.5 text-[10px] text-fg-tertiary font-medium uppercase tracking-wider border-b border-border-default",children:i("commentInput.mentionHeading")}),u.map((b,h)=>n.jsxs("button",{"data-selected":h===a,onMouseDown:f=>{f.preventDefault(),s(b)},onMouseEnter:()=>o(h),className:`w-full text-left px-3 py-2 text-xs flex items-center gap-2 transition-colors ${h===a?"bg-brand-500/15 text-brand-500":"hover:bg-surface-elevated"}`,children:[n.jsx("span",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-bold shrink-0 ${b.type==="human"?"bg-green-500/20 text-green-500":"bg-brand-500/20 text-brand-500"}`,children:b.name.slice(0,2).toUpperCase()}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("span",{className:"text-fg-primary font-medium",children:b.name}),n.jsx("span",{className:"text-fg-tertiary text-[10px] ml-1.5",children:b.subtitle??b.type})]}),b.type==="agent"&&n.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${b.online?"bg-green-400":"bg-gray-500"}`})]},b.id))]}),document.body)}function wt(e){return/^\w+$/.test(e)?`@${e}`:`@[${e}]`}const Ae=/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu;function Mn(e){const t=[];let r;for(Ae.lastIndex=0;(r=Ae.exec(e))!==null;)t.push(r[1]??r[2]);return t}function An(e,t,r){const s=[];let a=0;const o=t.map(l=>l.name).sort((l,d)=>d.length-l.length);let i=0;for(;i<e.length;){const l=e.indexOf("@",i);if(l<0){s.push(n.jsx("span",{children:e.slice(i)},a++));break}if(l>i&&s.push(n.jsx("span",{children:e.slice(i,l)},a++)),e[l+1]==="["){const f=e.indexOf("]",l+2);if(f>l+2){const x=e.slice(l+2,f),j=t.find(v=>v.name.toLowerCase()===x.toLowerCase());s.push(n.jsxs("span",{className:`text-brand-500 font-medium ${r&&j?"cursor-pointer hover:underline":""}`,onClick:r&&j?v=>r(j,v):void 0,title:j?`${j.name} (${j.role})`:void 0,children:["@",x]},a++)),i=f+1;continue}}const d=e.slice(l+1),c=d.toLowerCase(),u=o.find(f=>c.startsWith(f.toLowerCase()));if(u){const f=t.find(x=>x.name.toLowerCase()===u.toLowerCase());s.push(n.jsxs("span",{className:`text-brand-500 font-medium ${r&&f?"cursor-pointer hover:underline":""}`,onClick:r&&f?x=>r(f,x):void 0,title:f?`${f.name} (${f.role})`:void 0,children:["@",u]},a++)),i=l+1+u.length;continue}const b=/^([\w\p{L}\p{N}]+)/u,h=d.match(b);if(h){const f=h[1],x=t.find(j=>j.name.toLowerCase()===f.toLowerCase());s.push(n.jsxs("span",{className:`text-brand-500 font-medium ${r&&x?"cursor-pointer hover:underline":""}`,onClick:r&&x?j=>r(x,j):void 0,title:x?`${x.name} (${x.role})`:void 0,children:["@",f]},a++)),i=l+1+f.length;continue}s.push(n.jsx("span",{children:"@"},a++)),i=l+1}return s.length>0?s:[n.jsx("span",{children:e},0)]}function Ln({agents:e,humans:t,onSubmit:r,placeholder:s,replyTo:a,onCancelReply:o}){const{t:i}=T("common"),[l,d]=g.useState(""),[c,u]=g.useState(!1),[b,h]=g.useState(null),[f,x]=g.useState(!1),[j,v]=g.useState(""),[y,m]=g.useState([]),[w,k]=g.useState(0),[N,L]=g.useState([]),[ce,B]=g.useState(!1),F=g.useRef(null),$=g.useRef(null),E=g.useRef(null),A=g.useMemo(()=>{const p=(t??[]).map(_=>({id:_.id,name:_.name,type:"human",subtitle:_.role}));for(const _ of e)p.push({id:_.id,name:_.name,type:"agent",subtitle:_.role,online:_.status==="idle"||_.status==="working"});return p},[e,t]),D=A.filter(p=>p.name.toLowerCase().includes(j)),q=g.useCallback(p=>{const _=Array.from(p).filter(C=>C.type.startsWith("image/"));if(_.length!==0)for(const C of _){if(C.size>yt)continue;const M=new FileReader;M.onload=()=>{const te=M.result;jt(te,bt,vt).then(I=>{L(pe=>pe.length>=Me?pe:[...pe,{id:`img_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,dataUrl:I,name:C.name}])})},M.readAsDataURL(C)}},[]),_e=g.useCallback(p=>{L(_=>_.filter(C=>C.id!==p))},[]),H=g.useCallback(p=>{const _=p.clipboardData?.files;if(_&&_.length>0){const C=Array.from(_).filter(M=>M.type.startsWith("image/"));C.length>0&&(p.preventDefault(),q(C))}},[q]),de=g.useCallback(p=>{p.preventDefault(),B(!1);const _=p.dataTransfer?.files;_&&_.length>0&&q(Array.from(_).filter(C=>C.type.startsWith("image/")))},[q]),O=g.useCallback(p=>{p.preventDefault(),B(!0)},[]),G=g.useCallback(()=>{B(!1)},[]),J=async()=>{if(!(!l.trim()&&N.length===0)){u(!0),h(null),E.current={content:l,mentions:[...y],images:[...N]};try{await r(l,y,[...N],a?.id),d(""),m([]),L([]),E.current=null,o?.()}catch(p){h(String(p instanceof Error?p.message:p)||i("commentInput.sendFailed"))}u(!1)}},Q=async()=>{if(!E.current)return;const{content:p,mentions:_,images:C}=E.current;u(!0),h(null);try{await r(p,_,C),d(""),m([]),L([]),E.current=null}catch(M){h(String(M instanceof Error?M.message:M)||i("commentInput.sendFailed"))}u(!1)},Z=g.useCallback(p=>{d(_=>{const C=_.lastIndexOf("@"),M=wt(p.name);return C>=0?_.slice(0,C)+M+" ":_+M+" "}),y.includes(p.id)||m(_=>[..._,p.id]),x(!1),v(""),k(0),F.current?.focus()},[y]),ue=p=>{d(p),h(null);const _=p.lastIndexOf("@");if(_>=0&&(_===0||p[_-1]===" ")){const M=p.slice(_+1).toLowerCase();if(A.some(I=>I.name.toLowerCase().includes(M))){v(M),x(!0),k(0);return}}x(!1)},ee=p=>{if(f&&D.length>0){const _=p.key==="ArrowUp"||p.ctrlKey&&p.key==="p",C=p.key==="ArrowDown"||p.ctrlKey&&p.key==="n",M=p.key==="Enter"||p.key==="Tab",te=p.key==="Escape";if(_){p.preventDefault(),k(I=>(I-1+D.length)%D.length);return}if(C){p.preventDefault(),k(I=>(I+1)%D.length);return}if(M){p.preventDefault();const I=D[w];I&&Z(I);return}if(te){p.preventDefault(),x(!1);return}}p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),J())},W=g.useCallback(()=>{setTimeout(()=>x(!1),200)},[]);return n.jsxs("div",{className:"relative",onDragOver:O,onDragLeave:G,onDrop:de,children:[ce&&n.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-brand-500/10 rounded-lg border-2 border-dashed border-brand-500",children:n.jsx("span",{className:"text-sm text-brand-500 font-medium",children:i("commentInput.dragDropHint")})}),f&&n.jsx(kt,{candidates:A,filter:j,anchorRef:F,onSelect:Z,selectedIndex:w,onIndexChange:k}),n.jsxs("div",{className:"border border-border-default rounded-lg bg-surface-elevated",children:[a&&n.jsxs("div",{className:"flex items-center gap-2 px-2.5 pt-2 pb-1 border-b border-border-default/50",children:[n.jsxs("div",{className:"flex-1 min-w-0 pl-2 border-l-2 border-brand-500/50",children:[n.jsx("span",{className:"text-[10px] font-medium text-brand-500",children:a.authorName}),n.jsx("p",{className:"text-[10px] text-fg-tertiary truncate",children:a.content})]}),n.jsx("button",{onClick:o,className:"text-fg-tertiary hover:text-fg-secondary shrink-0 p-0.5",children:n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),y.length>0&&n.jsx("div",{className:"flex gap-1 px-2.5 pt-2 flex-wrap",children:y.map(p=>{const _=A.find(C=>C.id===p);return n.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded-full ${_?.type==="human"?"bg-green-500/15 text-green-500":"bg-brand-500/15 text-brand-500"}`,children:["@",_?.name??p,n.jsx("button",{onClick:()=>m(C=>C.filter(M=>M!==p)),className:"hover:text-red-400",children:"×"})]},p)})}),n.jsx("textarea",{ref:F,value:l,onChange:p=>ue(p.target.value),onKeyDown:ee,onBlur:W,onPaste:H,placeholder:s??i("commentInput.placeholder"),rows:2,className:"w-full px-2.5 py-2 text-xs bg-transparent text-fg-primary placeholder-fg-tertiary outline-none resize-none"}),N.length>0&&n.jsx("div",{className:"flex items-center gap-1.5 px-2.5 pb-1.5 overflow-x-auto",children:N.map(p=>n.jsxs("div",{className:"relative group/img shrink-0",children:[n.jsx("img",{src:p.dataUrl,alt:p.name,className:"w-12 h-12 rounded-lg object-cover border border-border-default"}),n.jsx("button",{onClick:()=>_e(p.id),className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-surface-secondary border border-gray-600 rounded-full flex items-center justify-center text-fg-secondary hover:text-red-500 hover:border-red-500 text-[10px] opacity-0 group-hover/img:opacity-100 transition-opacity",title:i("commentInput.removeImage"),children:"×"})]},p.id))}),b&&n.jsxs("div",{className:"flex items-center gap-2 px-2.5 pb-1.5",children:[n.jsx("span",{className:"text-[11px] text-red-400 flex-1 truncate",children:b}),n.jsxs("button",{onClick:Q,disabled:c,className:"text-[11px] text-amber-500 hover:text-amber-400 font-medium transition-colors flex items-center gap-1",children:[n.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("polyline",{points:"23 4 23 10 17 10"}),n.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),i("commentInput.retry")]})]}),n.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2",children:[n.jsx("button",{type:"button",onClick:()=>$.current?.click(),disabled:c||N.length>=Me,className:"p-1 text-fg-tertiary hover:text-brand-500 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:i("commentInput.attachImage"),children:n.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),n.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),n.jsx("polyline",{points:"21 15 16 10 5 21"})]})}),n.jsx("input",{ref:$,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:p=>{p.target.files&&q(p.target.files),p.target.value=""}}),n.jsx("button",{onClick:J,disabled:!l.trim()&&N.length===0||c,className:"px-3 py-1 text-[11px] font-medium bg-brand-500 text-on-brand rounded-md hover:bg-brand-600 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:i(c?"commentInput.sending":"commentInput.submit")})]})]}),l.trim()&&!c&&n.jsx("div",{className:"mt-0.5 -mb-0.5 flex justify-end px-2.5 pointer-events-none select-none",children:n.jsx("span",{className:"text-[10px] text-fg-tertiary/80",children:i("common:shiftEnterHint")})}),n.jsx("p",{className:"mt-1 text-center text-[10px] text-fg-tertiary/80 select-none",children:i("aiDisclaimer")})]})}function In(e){const t={id:e.id,sender:"user",text:e.text,time:e.time,rawCreatedAt:e.rawCreatedAt};return e.chips&&e.chips.length>0&&(t.chips=e.chips),e.images&&e.images.length>0&&(t.images=e.images),e.replyTo&&(t.replyToId=e.replyTo.id,t.replyToSender=e.replyTo.sender,t.replyToText=e.replyTo.text),t}function _t(e,t){return!!e&&t==="agent"}const Nt=24e3,Ct=200;function Rn(e,t,r=Nt){const s=(e??"")+t;return s.length<=r?s:s.slice(s.length-r)}function $n(e,t,r=Ct){const s=[...e??[],t];return s.length<=r?s:s.slice(s.length-r)}function Ye(e){return!!e.text?.trim()||(e.segments??[]).some(t=>t.type==="text"&&(t.content||t.thinking)||t.type==="tool")}function Dn(e,t){return!!(e.sender==="user"||Ye(e)||(e.activities?.length??0)>0||(e.images?.length??0)>0||e.emptyReply===!0||t&&!e.isStopped)}function Tt(e,t=8){for(let r=e.length-1;r>=Math.max(0,e.length-t);r--){const s=e[r];if(s.isStreaming&&!s.isStopped)return!0}return!1}function ke(e){if(!e||e.length===0)return e;let t=!1;const r=e.map(s=>s.type==="tool"&&s.status==="running"?(t=!0,{...s,status:"stopped"}):s);return t?r:e}function Je(e,t){if(!Ye(e)&&t!=="done")return null;const s={...e,isStreaming:!1,segments:ke(e.segments)};switch(t){case"done":return{...s,isStopped:!1,isError:!1};case"stopped":return{...s,isStopped:!0,isError:!1};case"error":return{...s,isStopped:!0,isError:!0}}}function qn(e){const t=[...e];for(let r=t.length-1;r>=0;r--)if(t[r].sender==="agent"&&!t[r].isStopped&&!t[r].isError){const s=Je(t[r],"stopped");s===null?t.splice(r,1):t[r]=s;break}return t}function On(e,t){if(t){const r=e.findIndex(s=>s.id===t);if(r>=0){const s=e[r],a=ke(s.segments);if(!s.isStreaming&&a===s.segments)return e;const o=[...e];return o[r]={...s,isStreaming:!1,segments:a},o}}return St(e)}function St(e){return Tt(e)?e.map(t=>t.sender!=="agent"||!t.isStreaming||t.isStopped?t:{...t,isStreaming:!1,segments:ke(t.segments)}):e}function Bn(e,t,r){return!t||!r||t===r?e:e.some(s=>s.id===r)?e.filter(s=>s.id!==t):e.map(s=>s.id===t?{...s,id:r}:s)}function Fn(e){for(let t=e.length-1;t>=0;t--){const r=e[t];if(r.sender==="agent"&&r.isStreaming)return t}return-1}function Un(e){return e.sendSessionId?e.authorityStreaming:!1}function Pn(e){const t=e.liveSessions;return!t||t.size===0||!e.sessionId?!0:!t.has(e.sessionId)&&!t.has(e.placeholderId)}function Kn(e){if(!e.isActive||e.previewMode||e.chatMode!=="direct"||!e.selectedAgent)return null;const t=e.activeSessionId;return!t||t===e.placeholderId?null:t}function Wn(e,t="stopped"){for(let r=e.length-1;r>=0;r--){const s=e[r];if(s.sender==="agent"&&s.isStreaming&&!s.isStopped){const a=Je(s,t);if(a===null)return e.filter((i,l)=>l!==r);const o=[...e];return o[r]=a,o}}return e}function zn(e,t){if(e.some(o=>o.id===t.id))return e;const r=t.rawCreatedAt?Date.parse(t.rawCreatedAt):NaN;if(!Number.isFinite(r)||e.length===0)return[...e,t];let s=e.length;for(;s>0;){const o=e[s-1],i=o.rawCreatedAt?Date.parse(o.rawCreatedAt):NaN;if(!Number.isFinite(i)||i<=r)break;s--}if(s===e.length)return[...e,t];const a=e.slice();return a.splice(s,0,t),a}function Hn(e,t){if(!t)return e;const r=e[e.length-1];return r?.type==="text"?[...e.slice(0,-1),{...r,thinking:(r.thinking??"")+t}]:[...e,{type:"text",content:"",thinking:t,createdAt:new Date().toISOString()}]}function Gn(e,t){if(!t)return e;const r=e[e.length-1];return r?.type==="text"?[...e.slice(0,-1),{...r,content:r.content+t}]:[...e,{type:"text",content:t,createdAt:new Date().toISOString()}]}const Et=/\n*<!--\s*notify_context:\s*([\s\S]*?)-->/g;function we(e){if(!e.includes("notify_context"))return{cleaned:e};let t;const r=e.match(/<!--\s*notify_context:\s*([\s\S]*?)-->/);if(r?.[1]){const s=r[1].match(/priority\s*=\s*(\w+)/i);s&&(t=s[1])}return{cleaned:e.replace(Et,"").trimEnd(),priority:t}}const Mt=/(?:<thinking>| thinking)[\s\S]*?<\/thinking>/g,At=/(?:<thinking>| thinking| thinking| think)[\s\S]*?<\/think>/g;function Vn(e){return e.replace(Mt,"").replace(At,"")}function Lt(e,t,r){if(e.type!=="tool"){const{cleaned:l}=we(e.content??"");return{type:"text",content:l,thinking:e.thinking,createdAt:e.createdAt}}const s=r?.type==="tool"&&r.tool===e.tool?r:void 0,a=e.subagentLogs?.length??0,o=s?.subagentLogs?.length??0,i=a>=o?e.subagentLogs:s?.subagentLogs;return{type:"tool",key:`${e.tool}_${t}`,tool:e.tool,status:e.status,args:e.arguments,result:e.result,error:e.error,durationMs:e.durationMs,createdAt:e.createdAt,...i?.length?{subagentLogs:i}:{}}}function Qe(e,t){const r=(t??[]).filter(a=>a.type==="tool");let s=0;return e.map((a,o)=>{const i=a.type==="tool"?r[s++]:void 0;return Lt(a,o,i)})}const re=new Map,It=2e3;function Ze(e){if(!e)return"";const t=re.get(e);if(t!==void 0)return t;const r=new Date(e),s=isNaN(r.getTime())?"":r.toLocaleTimeString();return re.size>=It&&re.clear(),re.set(e,s),s}function Xn(e){const t={id:e.id,sender:e.role==="user"?"user":"agent",text:e.content,time:Ze(e.createdAt),rawCreatedAt:e.createdAt,agentId:e.role!=="user"?e.agentId:void 0,sessionId:e.sessionId};if(e.metadata?.segmentsTruncated===!0&&(t.needsDetail=!0),e.role!=="user"&&e.metadata?.segments&&e.metadata.segments.length>0&&(t.segments=Qe(e.metadata.segments)),e.role==="assistant"&&(e.content==="[cancelled]"||e.content==="[Stream cancelled]")&&(t.text=""),(e.metadata?.isError||e.role==="assistant"&&e.content.startsWith("⚠"))&&(t.isError=!0,t.errorRaw=e.content),e.metadata?.emptyReply===!0&&(t.emptyReply=!0,t.isStopped||(t.isError=!0)),e.metadata?.isStreaming&&(t.isStreaming=!0),e.metadata?.isStopped&&!e.metadata?.isStreaming&&(t.isStopped=!0),e.metadata?.images?.length&&(t.images=e.metadata.images),e.metadata?.notifyUser&&(t.isNotification=!0,t.notifyPriority=e.metadata.priority,e.metadata.taskId&&(t.taskId=e.metadata.taskId),e.metadata.requirementId&&(t.requirementId=e.metadata.requirementId)),t.text.includes("<!-- notify_context:")){const{cleaned:r,priority:s}=we(t.text);t.text=r,s&&!t.notifyPriority&&(t.notifyPriority=s),t.isNotification=!0}if(e.metadata?.activityLog&&(t.isActivityLog=!0,t.activityType=e.metadata.activityType,t.outcome=e.metadata.outcome,t.mailboxItemId=e.metadata.mailboxItemId,t.taskId=e.metadata.taskId,t.requirementId=e.metadata.requirementId,!t.outcome&&t.text.startsWith("[ACTIVITY:"))){const r=t.text.lastIndexOf(" → ");r!==-1&&(t.outcome=t.text.slice(r+3)),t.text=t.text.replace(/^\[ACTIVITY:\s*\w+\]\s*/,"")}if(e.metadata?.replyToId&&(t.replyToId=e.metadata.replyToId,t.replyToSender=e.metadata.replyToSender,t.replyToText=e.metadata.replyToText,t.text=et(t.text,t.replyToSender,t.replyToText)),e.role==="user"){const r=pt(e.metadata?.chips);r&&(t.chips=r)}return t}function et(e,t,r){if(!e||!t||!r)return e;const s=`> **${t}**: ${r}
2
+
3
+ `;return e.startsWith(s)?e.slice(s.length):e}function Yn(e,t={}){if(t.expectedMessageId)for(let s=e.length-1;s>=0;s--){const a=e[s];if(a.id===t.expectedMessageId&&a.sender==="agent"&&!a.isError)return a}let r=-1;for(let s=e.length-1;s>=0;s--)if(e[s].sender==="user"){r=s;break}for(let s=e.length-1;s>=0;s--){const a=e[s];if(a.sender!=="agent")continue;return a.isStreaming?a:a.isError?void 0:!(a.text?.trim()||(a.segments??[]).some(i=>i.type==="text"&&((i.content??"").trim()||i.thinking)||i.type==="tool"))||t.allowCurrentTurnPartial&&r>=0&&s>r?a:void 0}}function Jn(e){const t=e?.messageId||e?.streamId;return t?`reattach_${t}`:null}function Qn(e,t){const r=e.senderType==="system"||e.senderType==="agent"&&e.text.startsWith("⚠"),s=e.senderType==="human"&&(!t||e.senderId===t);let a=e.text;s&&e.replyToId&&e.replyToSender&&e.replyToText&&(a=et(a,e.replyToSender,e.replyToText));const o={id:e.id,sender:s?"user":"agent",text:a,time:Ze(e.createdAt),rawCreatedAt:e.createdAt,agentName:s?void 0:e.senderName,agentId:s?void 0:e.senderId,isError:r,replyToId:e.replyToId,replyToSender:e.replyToSender,replyToText:e.replyToText},i=e.metadata;if(i?.images?.length&&(o.images=i.images),i&&e.senderType==="agent"){const l=[];if(i.thinking?.length&&l.push({type:"text",content:"",thinking:i.thinking.join(`
4
+
5
+ `)}),i.toolCalls?.length)for(let d=0;d<i.toolCalls.length;d++){const c=i.toolCalls[d];l.push({type:"tool",key:`${c.tool}_${d}`,tool:c.tool,status:c.status==="error"?"error":"done",args:c.arguments,result:c.result,durationMs:c.durationMs})}l.length>0&&(l.push({type:"text",content:e.text}),o.segments=l)}return o}const se=new Map,Rt=2e3;function Zn(e,t,r){const s=new Date,a=new Date(s.getFullYear(),s.getMonth(),s.getDate()).getTime(),o=t?`${t}|${a}|${e}|${r?.yesterday??""}`:null;if(o){const u=se.get(o);if(u!==void 0)return u}const i=t?new Date(t):s;if(isNaN(i.getTime()))return e;const l=i.getTime(),d=i.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});let c;return l>=a?c=d:l>=a-864e5?c=`${r?.yesterday??"Yesterday"} ${d}`:c=i.toLocaleDateString(void 0,{month:"short",day:"numeric"})+" "+d,o&&(se.size>=Rt&&se.clear(),se.set(o,c)),c}function er(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?"":`${t.getFullYear()}-${t.getMonth()+1}-${t.getDate()}`}function tr(e,t){const r=new Date(e);if(isNaN(r.getTime()))return"";const s=new Date,a=new Date(s.getFullYear(),s.getMonth(),s.getDate()).getTime(),o=r.getTime();return o>=a?t?.today??"Today":o>=a-864e5?t?.yesterday??"Yesterday":r.toLocaleDateString(void 0,{weekday:"long",year:"numeric",month:"long",day:"numeric"})}function nr(e,t){return(t?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey)&&!e.altKey&&!e.shiftKey&&e.key.toLowerCase()==="n"?"new-conversation":e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key==="Tab"?e.shiftKey?"cycle-session-prev":"cycle-session-next":null}function rr(e,t,r){if(e.length<=1)return null;const s=t===null?-1:e.indexOf(t),o=((s>=0?s:r===1?-1:0)+r+e.length)%e.length;return e[o]??null}function sr(e,t){let r=0,s=null;return((...a)=>{const o=Date.now(),i=t-(o-r);if(i<=0)return s&&(clearTimeout(s),s=null),r=o,e(...a);s||(s=setTimeout(()=>{r=Date.now(),s=null,e(...a)},i))})}const $t=10,Dt=23,Le={expanded:24,compact:12};function ar(e){const t=e?Le.compact:Le.expanded;return $t*Dt+t}function or(e,t){return e||t}function ir(e){return e?"justify-end":""}function lr(e,t,r){return e?t.includes(e)?"detail":r?"missing":"loading":"missing"}const qt={"claude-code":{label:"Claude Code",icon:"🤖",badgeClass:"bg-orange-500/15 text-orange-500"},codex:{label:"Codex",icon:"⬡",badgeClass:"bg-emerald-500/15 text-emerald-500"},"cursor-agent":{label:"Cursor",icon:"▶",badgeClass:"bg-blue-500/15 text-blue-500"}},z=["created","context_injected","running"],Ot=new Set(["completed","failed","cancelled","timeout"]),Ie={created:"Created",context_injected:"Context injected",running:"Running",completed:"Completed",failed:"Failed",cancelled:"Cancelled",timeout:"Timed out"};function Bt(e){return qt[e]??{label:e.replace(/-/g," ").replace(/\b\w/g,t=>t.toUpperCase()),icon:"⚙",badgeClass:"bg-surface-elevated text-fg-tertiary"}}function Ft(e,t){if(e.cost?.durationMs!=null)return e.cost.durationMs;const r=e.startedAt??e.createdAt,s=new Date(r).getTime();if(!Number.isNaN(s)){if(e.completedAt){const a=new Date(e.completedAt).getTime();return Number.isNaN(a)?void 0:Math.max(0,a-s)}if(e.status==="running"||e.status==="context_injected")return Math.max(0,t-s)}}function Ut(e){if(e==="completed"||Ot.has(e))return z.length;const t=z.indexOf(e);return t>=0?t:0}function Pt({session:e,className:t}){const{t:r}=T("common"),s=Bt(e.tool),[a,o]=g.useState(!1),[i,l]=g.useState(()=>Date.now()),d=e.status==="running"||e.status==="context_injected"||e.status==="created",c=e.status==="failed"||e.status==="timeout"||e.result?.success===!1,u=e.status==="completed"||e.result?.success===!0;g.useEffect(()=>{if(!d)return;const j=setInterval(()=>l(Date.now()),1e3);return()=>clearInterval(j)},[d]);const b=g.useMemo(()=>Ft(e,i),[e,i]),h=Ut(e.status),f=e.result?.rawOutput??(u||c?e.result?.summary:void 0),x=d?"border-brand-500/40 bg-brand-500/5":c?"border-red-500/30 bg-red-500/5":u?"border-green-500/30 bg-green-500/5":"border-border-default bg-surface-secondary/30";return n.jsxs("div",{className:`my-2 rounded-lg border ${x} p-3 max-w-2xl transition-colors ${t??""}`,children:[n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx("span",{className:"text-sm mt-0.5",children:s.icon}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[n.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${s.badgeClass}`,children:s.label}),n.jsx("span",{className:`text-[10px] font-medium ${d?"text-brand-500":c?"text-red-500":u?"text-green-500":"text-fg-tertiary"}`,children:Ie[e.status]??e.status}),b!=null&&n.jsx("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:K(b)}),e.cost?.estimatedCostUsd!=null&&n.jsxs("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:["$",e.cost.estimatedCostUsd.toFixed(4)]})]}),n.jsx("div",{className:"text-xs text-fg-secondary mt-1 line-clamp-2",children:e.prompt})]}),d&&n.jsxs("svg",{className:"w-3.5 h-3.5 animate-spin text-brand-500 shrink-0 mt-0.5",viewBox:"0 0 24 24",fill:"none",children:[n.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),n.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})]}),n.jsxs("div",{className:"flex items-center gap-1 mt-3 ml-6",children:[z.map((j,v)=>{const y=h>v||h===v&&!d&&u,m=h===v&&d,w=c&&v===z.length-1&&e.status!=="completed";return n.jsxs("div",{className:"flex items-center gap-1 flex-1 min-w-0",children:[n.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${w?"bg-red-500":y?"bg-green-500":m?"bg-brand-500 animate-pulse":"bg-gray-600"}`,title:Ie[j]}),v<z.length-1&&n.jsx("div",{className:`h-px flex-1 ${y?"bg-green-500/50":"bg-border-default/60"}`})]},j)}),n.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${c?"bg-red-500":u?"bg-green-500":"bg-gray-600"}`,title:c?"Failed":"Done"})]}),(e.progressMessage||e.progressPercent!=null)&&d&&n.jsxs("div",{className:"mt-2 ml-6 space-y-1",children:[e.progressPercent!=null&&n.jsx("div",{className:"h-1 bg-surface-elevated rounded-full overflow-hidden",children:n.jsx("div",{className:"h-full bg-brand-500 transition-all duration-300",style:{width:`${Math.min(100,Math.max(0,e.progressPercent))}%`}})}),e.progressMessage&&n.jsx("div",{className:"text-[11px] text-fg-tertiary font-mono truncate",children:e.progressMessage})]}),e.result&&!d&&n.jsxs("div",{className:"mt-2 ml-6 space-y-1.5",children:[e.result.summary&&n.jsx("div",{className:"text-xs text-fg-secondary",children:e.result.summary}),e.result.diffStats&&n.jsxs("div",{className:"flex items-center gap-3 text-[10px] font-mono",children:[n.jsx("span",{className:"text-fg-tertiary",children:r("codingTool.files",{n:e.result.diffStats.filesChanged})}),n.jsxs("span",{className:"text-green-500",children:["+",e.result.diffStats.additions]}),n.jsxs("span",{className:"text-red-500",children:["−",e.result.diffStats.deletions]})]}),e.cost&&(e.cost.inputTokens!=null||e.cost.outputTokens!=null)&&n.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[e.cost.inputTokens!=null&&n.jsx("span",{children:r("codingTool.tokensIn",{n:e.cost.inputTokens.toLocaleString()})}),e.cost.inputTokens!=null&&e.cost.outputTokens!=null&&n.jsx("span",{className:"mx-1",children:"·"}),e.cost.outputTokens!=null&&n.jsx("span",{children:r("codingTool.tokensOut",{n:e.cost.outputTokens.toLocaleString()})})]})]}),f&&n.jsxs("div",{className:"mt-2 ml-6 border-t border-border-default/30 pt-2",children:[n.jsxs("button",{type:"button",onClick:()=>o(!a),className:"flex items-center gap-1.5 text-[10px] text-fg-tertiary hover:text-fg-secondary transition-colors",children:[n.jsx("svg",{className:`w-3 h-3 transition-transform ${a?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),n.jsx("span",{className:"font-medium uppercase tracking-wider",children:r("rawOutput")})]}),a&&n.jsx("pre",{className:"mt-2 text-[11px] text-fg-tertiary bg-surface-elevated/70 rounded-lg px-3 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono",children:f})]})]})}function Kt({label:e}){const{t}=T("common");return n.jsxs("div",{className:"flex items-center gap-1.5 text-xs py-0.5",children:[n.jsx("span",{className:"activity-text-shimmer",children:e??t("execution.thinking")}),n.jsx("span",{className:"flex gap-0.5",children:[0,150,300].map(r=>n.jsx("span",{className:"w-1 h-1 rounded-full bg-brand-400 animate-bounce",style:{animationDelay:`${r}ms`,animationDuration:"1s"}},r))})]})}const Re=150;function Wt({content:e,className:t}){const[r,s]=g.useState(e),a=g.useRef(0),o=g.useRef(null);g.useEffect(()=>{const l=Date.now(),d=l-a.current;return d>=Re?(a.current=l,s(e)):o.current||(o.current=setTimeout(()=>{a.current=Date.now(),o.current=null,s(e)},Re-d)),()=>{o.current&&(clearTimeout(o.current),o.current=null)}},[e]);const i=g.useMemo(()=>r,[r]);return n.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg px-3 py-2.5 my-1 min-w-0 overflow-hidden",children:[n.jsx(R,{content:i,className:t??"text-sm text-fg-secondary break-words"}),n.jsx("span",{className:"inline-block w-0.5 h-4 bg-brand-400 animate-pulse ml-0.5 align-middle"})]})}const le=8e3,ae=120;function ge({text:e,className:t}){const{t:r}=T("common"),[s,a]=g.useState(!1),o=e.length>le,i=!o||s?e:`${e.slice(0,le)}
6
+ …`;return n.jsxs("div",{children:[n.jsx("pre",{className:t,children:i}),o&&n.jsx("button",{type:"button",className:"mt-1 text-[11px] text-brand-500 hover:underline",onClick:l=>{l.stopPropagation(),a(d=>!d)},children:r(s?"showLess":"showMore")})]})}function zt({info:e,time:t}){const{t:r}=T("common"),s=He(e.args),a=e.status==="running",o=e.status!=="error",i=s.length>0||!a&&(!!e.result||!!e.error)||!!e.subagentLogs&&e.subagentLogs.length>0,l=g.useRef(null),d=e.subagentLogs?.length??0,c=e.subagentLogs&&e.subagentLogs.length>ae?e.subagentLogs.slice(e.subagentLogs.length-ae):e.subagentLogs;return g.useEffect(()=>{!a||!l.current||(l.current.scrollTop=l.current.scrollHeight)},[d,a]),n.jsxs("div",{className:"space-y-3 py-1",children:[n.jsxs("div",{className:"flex items-center gap-2 text-[10px]",children:[n.jsx("span",{className:`px-1.5 py-0.5 rounded ${a?"bg-brand-500/15 text-brand-500":o?"bg-green-500/15 text-green-600":"bg-surface-overlay text-fg-tertiary"}`,children:r(a?"execution.toolRunning":o?"execution.toolSuccess":"execution.toolFailed")}),t&&n.jsx("span",{className:"text-fg-tertiary tabular-nums",children:t}),e.durationMs!=null&&n.jsx("span",{className:"text-fg-tertiary",children:K(e.durationMs)})]}),s.length>0&&n.jsxs("div",{children:[n.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-1",children:r("execution.arguments")}),n.jsx("div",{className:"space-y-2",children:s.map(({key:u,value:b})=>n.jsxs("div",{children:[n.jsx("div",{className:"text-[11px] text-brand-500 font-medium mb-0.5",children:u}),n.jsx(ge,{text:b,className:"text-xs text-fg-secondary bg-surface-elevated/70 rounded-lg px-3 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono"})]},u))})]}),c&&c.length>0&&n.jsxs("div",{children:[n.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-1",children:r("execution.subagentExecution")}),n.jsxs("div",{ref:l,className:"bg-surface-elevated/50 rounded-lg px-3 py-2 space-y-1",children:[d>ae&&n.jsxs("div",{className:"text-[10px] text-fg-tertiary pb-1",children:["… ",r("execution.earlierStepsOmitted",{n:d-ae})]}),c.map((u,b)=>{const h=u.eventType==="started"?"▶":u.eventType==="completed"?"✓":u.eventType==="error"?"✗":u.eventType==="tool_start"?"◎":u.eventType==="tool_end"?"●":u.eventType==="thinking"?"·":"→",f=u.eventType==="error"?"text-fg-tertiary":u.eventType==="completed"?"text-green-500":u.eventType==="started"||u.eventType==="tool_start"?"text-brand-500":"text-fg-tertiary";return n.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[n.jsx("span",{className:`shrink-0 ${f}`,children:h}),n.jsx("span",{className:`font-mono break-all ${f}`,children:he(u.content,500)})]},b)}),a&&n.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-brand-500 pt-0.5",children:[n.jsxs("svg",{className:"w-3 h-3 animate-spin shrink-0",viewBox:"0 0 24 24",fill:"none",children:[n.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),n.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),n.jsx("span",{children:r("execution.toolRunning")})]})]})]}),!a&&e.result&&n.jsxs("div",{children:[n.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-1",children:r("execution.result")}),n.jsx(ge,{text:Te(e.result),className:"text-xs text-fg-secondary bg-surface-elevated/70 rounded-lg px-3 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono"})]}),!a&&e.error&&n.jsxs("div",{children:[n.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-1",children:r("execution.error")}),n.jsx(ge,{text:Te(String(e.error)),className:"text-xs text-fg-secondary bg-surface-elevated/50 border border-border-default rounded-lg px-3 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono"})]}),!i&&n.jsx("div",{className:"text-xs text-fg-tertiary italic py-2 text-center",children:r("execution.noToolDetail")})]})}const tt={urgent:"text-red-500",high:"text-amber-500",medium:"text-blue-500",low:"text-fg-tertiary"},$e={pending:"pending",in_progress:"in_progress",completed:"completed",review:"review",blocked:"blocked",failed:"failed",rejected:"rejected",revision:"revision",cancelled:"cancelled",archived:"archived"},S=e=>({borderClass:ne[e].border,bgClass:ne[e].surface,badgeClass:ne[e].chip,textClass:ne[e].text}),De={pending:{icon:"⏳",labelKey:"execution.card.pendingApproval",...S("attention")},approving:{icon:"⏳",labelKey:"execution.card.approving",...S("attention")},rejecting:{icon:"⏳",labelKey:"execution.card.rejecting",...S("attention")},in_progress:{icon:"▶",labelKey:"execution.card.inProgress",...S("active")},completed:{icon:"✅",labelKey:"execution.card.completed",...S("success")},review:{icon:"👀",labelKey:"execution.card.inReview",...S("attention")},blocked:{icon:"🚫",labelKey:"execution.card.blocked",...S("blocked")},failed:{icon:"❌",labelKey:"execution.card.failed",...S("danger")},rejected:{icon:"❌",labelKey:"execution.card.rejected",...S("danger")},revision:{icon:"✏️",labelKey:"execution.card.revision",...S("active")},cancelled:{icon:"⊘",labelKey:"execution.card.cancelled",...S("neutral")},archived:{icon:"📦",labelKey:"execution.card.archived",...S("neutral")},loading:{icon:"⏳",labelKey:"execution.card.loading",...S("neutral")}};function nt({info:e}){const{t}=T("common"),[r,s]=g.useState("loading"),[a,o]=g.useState(null);g.useEffect(()=>{let h=!1;return U.tasks.get(e.taskId).then(({task:f})=>{h||s($e[f.status]??"pending")}).catch(()=>{h||s("pending")}),()=>{h=!0}},[e.taskId]),g.useEffect(()=>Ue.on("task:update",h=>{const f=h.payload;f.taskId===e.taskId&&f.status&&s($e[f.status]??"pending")}),[e.taskId]);const i=()=>{window.dispatchEvent(new CustomEvent("markus:mark-read-by-ref",{detail:{taskId:e.taskId}}))},l=async()=>{o(null),s("approving");try{await U.tasks.approve(e.taskId),s("in_progress"),i()}catch{s("pending")}},d=async()=>{o(null),s("rejecting");try{await U.tasks.reject(e.taskId),s("rejected"),i()}catch{s("pending")}},c=r==="pending"||r==="approving"||r==="rejecting",u=De[r]??De.loading,b=()=>Pe.navigate(Ke.WORK,{openTask:e.taskId});return n.jsxs("div",{className:`my-2 rounded-lg border ${u.borderClass} ${u.bgClass} p-3 max-w-md transition-colors`,children:[n.jsxs("div",{className:"flex items-start gap-2 mb-1 cursor-pointer group",role:"button",tabIndex:0,onClick:b,onKeyDown:h=>h.key==="Enter"&&b(),children:[n.jsx("span",{className:"text-sm mt-0.5",children:u.icon}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${u.badgeClass}`,children:t("execution.taskBadge")}),!c&&r!=="loading"&&n.jsx("span",{className:`text-[10px] font-medium ${u.textClass}`,children:t(u.labelKey)})]}),n.jsx("div",{className:`text-sm font-medium truncate mt-1 group-hover:underline ${!c&&r!=="loading"?"text-fg-secondary":"text-fg-primary"}`,children:e.title}),e.description&&n.jsx("div",{className:"text-xs text-fg-secondary mt-0.5 line-clamp-2",children:e.description}),n.jsxs("div",{className:"flex items-center gap-2 mt-1.5 text-[11px] text-fg-tertiary",children:[e.priority&&n.jsx("span",{className:tt[e.priority]??"text-fg-tertiary",children:t(`priority.${e.priority}`,{defaultValue:e.priority})}),n.jsx("span",{className:"opacity-50",children:t("execution.idPrefix",{id:e.taskId.slice(0,8)})})]})]})]}),c&&n.jsxs("div",{className:"flex items-center gap-2 mt-2 pt-2 border-t border-border-default/30",children:[n.jsx("button",{onClick:()=>o("approve"),disabled:r!=="pending",className:"flex-1 px-3 py-1.5 text-xs font-medium rounded-md bg-green-600 hover:bg-green-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:t(r==="approving"?"execution.card.approving":"approve")}),n.jsx("button",{onClick:()=>o("reject"),disabled:r!=="pending",className:"flex-1 px-3 py-1.5 text-xs font-medium rounded-md bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:t(r==="rejecting"?"execution.card.rejecting":"reject")})]}),a==="approve"&&n.jsx(ie,{variant:"primary",title:t("execution.card.confirmApproveTaskTitle"),message:t("execution.card.confirmApproveTaskMessage",{title:e.title}),confirmLabel:t("approve"),onConfirm:()=>{l()},onCancel:()=>o(null)}),a==="reject"&&n.jsx(ie,{variant:"danger",title:t("execution.card.confirmRejectTaskTitle"),message:t("execution.card.confirmRejectTaskMessage",{title:e.title}),confirmLabel:t("reject"),onConfirm:()=>{d()},onCancel:()=>o(null)})]})}const qe={pending:"pending",in_progress:"in_progress",completed:"completed",rejected:"rejected",cancelled:"cancelled",archived:"archived"},Oe={pending:{icon:"📋",labelKey:"execution.card.pendingApproval",...S("attention")},approving:{icon:"⏳",labelKey:"execution.card.approving",...S("attention")},rejecting:{icon:"⏳",labelKey:"execution.card.rejecting",...S("attention")},in_progress:{icon:"▶",labelKey:"execution.card.inProgress",...S("active")},completed:{icon:"✅",labelKey:"execution.card.completed",...S("success")},rejected:{icon:"❌",labelKey:"execution.card.rejected",...S("danger")},cancelled:{icon:"⊘",labelKey:"execution.card.cancelled",...S("neutral")},archived:{icon:"📦",labelKey:"execution.card.archived",...S("neutral")},loading:{icon:"⏳",labelKey:"execution.card.loading",...S("neutral")}},Ht=["requirement:approved","requirement:rejected","requirement:updated","requirement:completed","requirement:cancelled","requirement:resubmitted"];function rt({info:e}){const{t}=T("common"),[r,s]=g.useState("loading"),[a,o]=g.useState(""),[i,l]=g.useState(!1),[d,c]=g.useState(null);g.useEffect(()=>{let y=!1;return U.requirements.get(e.requirementId).then(({requirement:m})=>{y||s(qe[m.status]??"pending")}).catch(()=>{y||s("pending")}),()=>{y=!0}},[e.requirementId]),g.useEffect(()=>{const y=Ht.map(m=>Ue.on(m,w=>{const k=w.payload;k.id===e.requirementId&&k.status&&s(qe[k.status]??"pending")}));return()=>y.forEach(m=>m())},[e.requirementId]);const u=()=>{window.dispatchEvent(new CustomEvent("markus:mark-read-by-ref",{detail:{requirementId:e.requirementId}}))},b=async()=>{c(null),s("approving");try{await U.requirements.approve(e.requirementId),s("in_progress"),u()}catch{s("pending")}},h=async()=>{if(a.trim()){c(null),s("rejecting");try{await U.requirements.reject(e.requirementId,a.trim()),s("rejected"),u()}catch{s("pending")}}},f=()=>{if(!i){l(!0);return}a.trim()&&c("reject")},x=r==="pending"||r==="approving"||r==="rejecting",j=Oe[r]??Oe.loading,v=()=>Pe.navigate(Ke.WORK,{openRequirement:e.requirementId});return n.jsxs("div",{className:`my-2 rounded-lg border ${j.borderClass} ${j.bgClass} p-3 max-w-md transition-colors`,children:[n.jsxs("div",{className:"flex items-start gap-2 mb-1 cursor-pointer group",role:"button",tabIndex:0,onClick:v,onKeyDown:y=>y.key==="Enter"&&v(),children:[n.jsx("span",{className:"text-sm mt-0.5",children:j.icon}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${j.badgeClass}`,children:t("execution.reqBadge")}),!x&&r!=="loading"&&n.jsx("span",{className:`text-[10px] font-medium ${j.textClass}`,children:t(j.labelKey)})]}),n.jsx("div",{className:`text-sm font-medium truncate mt-1 group-hover:underline ${!x&&r!=="loading"?"text-fg-secondary":"text-fg-primary"}`,children:e.title}),e.description&&n.jsx("div",{className:"text-xs text-fg-secondary mt-0.5 line-clamp-3",children:e.description}),n.jsxs("div",{className:"flex items-center gap-2 mt-1.5 text-[11px] text-fg-tertiary",children:[e.priority&&n.jsx("span",{className:tt[e.priority]??"text-fg-tertiary",children:t(`priority.${e.priority}`,{defaultValue:e.priority})}),n.jsx("span",{className:"opacity-50",children:t("execution.idPrefix",{id:e.requirementId.slice(0,8)})})]})]})]}),x&&n.jsxs("div",{className:"mt-2 pt-2 border-t border-border-default/30 space-y-2",children:[i&&n.jsx("input",{type:"text",value:a,onChange:y=>o(y.target.value),placeholder:t("execution.rejectionReasonPlaceholder"),className:"w-full px-2 py-1.5 text-xs rounded-md bg-surface-secondary border border-border-default text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:border-brand-500",onKeyDown:y=>y.key==="Enter"&&f(),autoFocus:!0}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("button",{onClick:()=>c("approve"),disabled:r!=="pending",className:"flex-1 px-3 py-1.5 text-xs font-medium rounded-md bg-green-600 hover:bg-green-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:t(r==="approving"?"execution.card.approving":"approve")}),n.jsx("button",{onClick:f,disabled:r!=="pending"||i&&!a.trim(),className:"flex-1 px-3 py-1.5 text-xs font-medium rounded-md bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:t(r==="rejecting"?"execution.card.rejecting":"reject")})]})]}),d==="approve"&&n.jsx(ie,{variant:"primary",title:t("execution.card.confirmApproveReqTitle"),message:t("execution.card.confirmApproveReqMessage",{title:e.title}),confirmLabel:t("approve"),onConfirm:()=>{b()},onCancel:()=>c(null)}),d==="reject"&&n.jsx(ie,{variant:"danger",title:t("execution.card.confirmRejectReqTitle"),message:t("execution.card.confirmRejectReqMessage",{title:e.title}),confirmLabel:t("reject"),onConfirm:()=>{h()},onCancel:()=>c(null)})]})}const Gt={"claude-code":{label:"Claude Code",badgeClass:"bg-orange-500/15 text-orange-500"},codex:{label:"Codex",badgeClass:"bg-emerald-500/15 text-emerald-500"},"cursor-agent":{label:"Cursor",badgeClass:"bg-blue-500/15 text-blue-500"}};function Vt({session:e,info:t,onClose:r}){const{t:s}=T("common"),a=t.args&&typeof t.args=="object"&&!Array.isArray(t.args)?t.args:{},o=e.status==="running"||e.status==="created"||e.status==="context_injected",i=e.status==="failed"||e.status==="timeout",l=e.status==="completed",d=Gt[e.tool]??{label:e.tool,badgeClass:"bg-surface-elevated text-fg-tertiary"},[c,u]=g.useState(!1);g.useEffect(()=>{const x=j=>{j.key==="Escape"&&r()};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]);const b=e.cost?.durationMs??t.durationMs,h=typeof a.model=="string"?a.model:void 0,f=typeof a.mode=="string"?a.mode:void 0;return n.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",onClick:r,children:[n.jsx("div",{className:"absolute inset-0 bg-black/60"}),n.jsxs("div",{className:"relative bg-surface-secondary border border-border-default rounded-xl shadow-2xl w-[640px] max-w-[92vw] max-h-[80vh] overflow-hidden flex flex-col",onClick:x=>x.stopPropagation(),children:[n.jsxs("div",{className:"px-5 py-3 border-b border-border-default flex items-center justify-between shrink-0",children:[n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsx("span",{className:`text-xs px-2 py-0.5 rounded font-medium ${d.badgeClass}`,children:d.label}),n.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${o?"bg-brand-500/15 text-brand-500":l?"bg-green-500/15 text-green-600":"bg-surface-overlay text-fg-tertiary"}`,children:o?"Running":l?"Completed":i?"Failed":e.status}),b!=null&&n.jsx("span",{className:"text-xs text-fg-tertiary tabular-nums",children:K(b)}),h&&n.jsx("span",{className:"text-[10px] bg-surface-elevated px-1.5 py-0.5 rounded text-fg-tertiary font-mono",children:h}),f&&n.jsx("span",{className:"text-[10px] bg-surface-elevated px-1.5 py-0.5 rounded text-fg-tertiary",children:f})]}),n.jsx("button",{onClick:r,className:"text-fg-tertiary hover:text-fg-secondary text-lg leading-none ml-2",children:"×"})]}),n.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-4",children:[n.jsxs("div",{children:[n.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2",children:s("execution.prompt")}),n.jsx("pre",{className:"text-xs text-fg-secondary bg-surface-elevated/70 rounded-lg px-3 py-2 overflow-x-auto max-h-40 overflow-y-auto whitespace-pre-wrap break-all font-mono",children:e.prompt})]}),Object.keys(a).length>0&&n.jsxs("div",{children:[n.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2",children:s("execution.inputArguments")}),n.jsx("div",{className:"space-y-1.5",children:Object.entries(a).filter(([x])=>x!=="prompt").map(([x,j])=>n.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[n.jsxs("span",{className:"text-brand-500 font-medium shrink-0 font-mono",children:[x,":"]}),n.jsx("span",{className:"text-fg-secondary font-mono break-all",children:typeof j=="string"?j:JSON.stringify(j)})]},x))})]}),e.result&&!o&&n.jsxs("div",{children:[n.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2",children:s("execution.result")}),n.jsxs("div",{className:"space-y-2",children:[e.result.summary&&n.jsx("div",{className:"text-xs text-fg-secondary",children:e.result.summary}),e.result.diffStats&&n.jsxs("div",{className:"flex items-center gap-3 text-xs font-mono",children:[n.jsx("span",{className:"text-fg-tertiary",children:s("execution.filesChanged",{n:e.result.diffStats.filesChanged})}),n.jsxs("span",{className:"text-green-500",children:["+",e.result.diffStats.additions]}),n.jsxs("span",{className:"text-red-500",children:["-",e.result.diffStats.deletions]})]}),e.result.modifiedFiles&&e.result.modifiedFiles.length>0&&n.jsxs("div",{children:[n.jsxs("div",{className:"text-[10px] text-fg-tertiary mb-1",children:[s("execution.modifiedFiles"),":"]}),n.jsx("div",{className:"bg-surface-elevated/70 rounded-lg px-3 py-2 max-h-32 overflow-y-auto",children:e.result.modifiedFiles.map((x,j)=>n.jsx("div",{className:"text-[11px] text-fg-secondary font-mono truncate",children:x},j))})]}),e.result.error&&n.jsx("pre",{className:"text-xs text-fg-secondary bg-surface-elevated/50 border border-border-default rounded-lg px-3 py-2 overflow-x-auto max-h-60 overflow-y-auto whitespace-pre-wrap break-all font-mono",children:e.result.error})]})]}),e.cost&&(e.cost.inputTokens!=null||e.cost.outputTokens!=null||e.cost.estimatedCostUsd!=null)&&n.jsxs("div",{children:[n.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2",children:s("execution.cost")}),n.jsxs("div",{className:"flex items-center gap-4 text-xs text-fg-secondary",children:[e.cost.inputTokens!=null&&n.jsx("span",{children:s("execution.inputTokens",{n:e.cost.inputTokens.toLocaleString()})}),e.cost.outputTokens!=null&&n.jsx("span",{children:s("execution.outputTokens",{n:e.cost.outputTokens.toLocaleString()})}),e.cost.estimatedCostUsd!=null&&n.jsxs("span",{className:"font-medium",children:["$",e.cost.estimatedCostUsd.toFixed(4)]}),b!=null&&n.jsx("span",{className:"text-fg-tertiary",children:K(b)})]})]}),e.result?.rawOutput&&n.jsxs("div",{children:[n.jsxs("button",{type:"button",onClick:()=>u(!c),className:"flex items-center gap-1.5 text-[10px] text-fg-tertiary hover:text-fg-secondary transition-colors",children:[n.jsx("svg",{className:`w-3 h-3 transition-transform ${c?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),n.jsx("span",{className:"font-semibold uppercase tracking-wider",children:s("rawOutput")})]}),c&&n.jsx("pre",{className:"mt-2 text-[11px] text-fg-tertiary bg-surface-elevated/70 rounded-lg px-3 py-2 overflow-x-auto max-h-[50vh] overflow-y-auto whitespace-pre-wrap break-all font-mono",children:e.result.rawOutput})]})]})]})]})}function Xt(e){if(e.tool!=="invoke_coding_tool")return null;const t=e.args&&typeof e.args=="object"&&!Array.isArray(e.args)?e.args:{},r=typeof t.tool=="string"?t.tool:"unknown",s=typeof t.prompt=="string"?t.prompt:"",o={running:"running",done:"completed",error:"failed",stopped:"cancelled"}[e.status]??e.status;let i,l;if(e.result)try{const c=JSON.parse(e.result);if(c&&typeof c=="object"){const u=c.result&&typeof c.result=="object"?c.result:c;i={success:u.success??c.success??e.status==="done",summary:u.summary??u.message??c.summary??c.message??"Completed",diffStats:u.diffStats??c.diffStats,modifiedFiles:u.modifiedFiles??c.modifiedFiles,exitCode:u.exitCode??c.exitCode,rawOutput:u.rawOutput??u.output??c.rawOutput??c.output,error:u.error??c.error},u.cost?l=u.cost:c.cost&&(l=c.cost)}}catch{i={success:e.status==="done",summary:e.result.slice(0,500),rawOutput:e.result}}e.durationMs!=null&&(l={...l,durationMs:e.durationMs});let d;if(e.liveOutput&&e.status==="running"){const c=e.liveOutput.trim().split(`
7
+ `);d=c[c.length-1]?.slice(0,200)}return{id:`tc-${r}-${Date.now()}`,tool:r,status:o,prompt:s,progressMessage:d,result:i,cost:l,createdAt:new Date().toISOString()}}function Yt({info:e,time:t,hideApprovalCards:r}){const{t:s}=T("common"),a=P(e.tool),o=e.status!=="running",i=e.status==="stopped",l=e.tool==="spawn_subagent"||e.tool==="spawn_subagents",d=!!(l&&e.subagentLogs&&e.subagentLogs.length>0),[c,u]=g.useState(()=>l&&e.status==="running"),b=g.useRef(!1),h=g.useMemo(()=>Xt(e),[e]),[f,x]=g.useState(!1),j=xt(e),v=g.useRef(null),y=d?e.subagentLogs[e.subagentLogs.length-1].content:"",m=g.useMemo(()=>He(e.args).length>0||!!e.result||!!e.error||!!e.subagentLogs&&e.subagentLogs.length>0,[e.args,e.result,e.error,e.subagentLogs]);return g.useEffect(()=>{v.current&&(v.current.scrollTop=v.current.scrollHeight)},[e.liveOutput]),g.useEffect(()=>{l&&e.status==="running"&&d&&!b.current&&u(!0)},[l,e.status,d,e.subagentLogs?.length]),h?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"cursor-pointer",onClick:()=>x(!0),children:n.jsx(Pt,{session:h})}),f&&ve.createPortal(n.jsx(Vt,{session:h,info:e,onClose:()=>x(!1)}),document.body)]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"relative py-0.5 min-w-0",children:[n.jsxs("div",{className:`flex items-center gap-2 min-w-0 rounded ${m?"cursor-pointer hover:bg-surface-elevated/30 transition-colors":""}`,onClick:()=>{m&&(X(),u(w=>{const k=!w;return l&&e.status==="running"&&(b.current=!k),k}))},children:[n.jsx(Y,{name:a.iconName,size:15,className:`shrink-0 ${e.status==="running"?"text-brand-500":e.status==="error"||i?"text-fg-tertiary":"text-green-500"}`}),n.jsxs("span",{className:`text-xs leading-snug shrink-0 ${e.status==="running"?"activity-text-shimmer":e.status==="error"||i?"text-fg-tertiary opacity-70":"text-fg-secondary"}`,children:[s(`execution.tools.${a.key}`,{defaultValue:a.label}),e.status==="running"?"…":""]}),m&&n.jsx("svg",{className:`w-3 h-3 shrink-0 text-fg-tertiary transition-transform ${c?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),e.status==="running"&&n.jsxs("svg",{className:"w-3 h-3 animate-spin shrink-0",viewBox:"0 0 24 24",fill:"none",children:[n.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),n.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),e.durationMs!=null&&e.status!=="running"&&n.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:K(e.durationMs)}),j&&n.jsxs("span",{className:"font-mono text-[11px] text-fg-tertiary truncate min-w-0",title:j,children:[n.jsx("span",{className:"select-none opacity-70",children:"$ "}),j.split(`
8
+ `)[0]]}),d&&n.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0 opacity-60",children:s("execution.toolSteps",{count:e.subagentLogs.filter(w=>w.eventType==="tool_end").length})})]}),e.liveOutput&&e.status==="running"&&n.jsx("pre",{ref:v,className:"mt-1 font-mono text-[11px] text-fg-tertiary bg-surface-secondary/60 rounded px-2 py-1.5 overflow-x-hidden whitespace-pre-wrap break-all",children:e.liveOutput.length>le?e.liveOutput.slice(e.liveOutput.length-le):e.liveOutput}),!c&&l&&e.status==="running"&&y&&n.jsx("div",{className:"mt-1 ml-[23px] font-mono text-[11px] text-fg-tertiary truncate",title:y,children:y}),c&&m&&n.jsx("div",{className:"mt-1 ml-[23px] border-l-2 border-border-default/60 pl-3 overflow-x-hidden",children:n.jsx(zt,{info:e,time:t})})]}),o&&!r&&(()=>{const w=Ge(e.tool,e.result);if(w)return n.jsx(nt,{info:w});const k=Ve(e.tool,e.result);return k?n.jsx(rt,{info:k}):null})()]})}function Jt({content:e,time:t,defaultExpanded:r}){const{t:s}=T("common"),[a,o]=g.useState(r??!1);return g.useEffect(()=>{r&&o(!0)},[r]),n.jsxs("div",{className:"min-w-0 py-0.5 overflow-hidden",children:[n.jsxs("button",{onClick:()=>{X(),o(i=>!i)},className:"flex items-center gap-2 text-xs w-full min-w-0",children:[n.jsx(Y,{name:"sparkles",size:15,className:"shrink-0 text-violet-400"}),n.jsx("span",{className:`shrink-0 ${r?"activity-text-shimmer":"text-fg-secondary"}`,children:s("execution.thinking")}),n.jsx("svg",{className:`w-3 h-3 shrink-0 text-fg-tertiary transition-transform ${a?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),a&&t&&n.jsx("span",{className:"ml-auto shrink-0 text-[10px] text-fg-tertiary tabular-nums",children:t})]}),a&&n.jsx("div",{className:"mt-1.5 ml-[23px] border-l-2 border-border-default/60 pl-3 overflow-hidden",children:n.jsx(R,{content:e,className:"text-xs text-fg-tertiary break-words"})})]})}const ye=g.memo(Qt);function Qt({entry:e,showTime:t,isLast:r,defaultThinkingExpanded:s,hideApprovalCards:a}){const{t:o}=T("common");if(e.type==="tool")return n.jsx(Yt,{info:e.info,showTime:t,time:e.time,isLast:r,hideApprovalCards:a},e.key);if(e.type==="thinking")return n.jsx(Jt,{content:e.content,time:e.time,showTime:t,defaultExpanded:s});if(e.type==="text")return e.content.startsWith("⚠")?n.jsx("div",{className:"min-w-0 pl-[23px] pr-1 overflow-hidden",children:n.jsx("p",{className:"text-[13px] text-fg-tertiary leading-relaxed whitespace-pre-wrap break-words",children:e.content.replace(/^⚠\s*/,"")})}):n.jsx("div",{className:"min-w-0 pl-[23px] pr-1 overflow-hidden",children:n.jsx(R,{content:e.content,className:"text-sm text-fg-secondary break-words"})});if(e.type==="status"){const i=e.content==="completed"||e.content==="execution_finished",l=e.content==="started",d=e.content==="resumed",c=i?"text-green-600":l?"text-blue-600":d?"text-amber-600":"text-fg-tertiary",u=i?"bg-green-400":l?"bg-blue-400":d?"bg-amber-400":"bg-gray-500";return n.jsxs("div",{className:"flex items-center gap-2 py-0.5 min-w-0",children:[n.jsx("span",{className:"w-[15px] flex justify-center shrink-0",children:n.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${u}`})}),n.jsx("span",{className:`text-xs capitalize ${c}`,children:o(`execution.statusKnown.${e.content}`,{defaultValue:e.content})})]})}return e.type==="error"?n.jsxs("div",{className:"flex items-start gap-2 py-0.5 min-w-0",children:[n.jsx(Y,{name:"alert-circle",size:15,className:"shrink-0 mt-0.5 text-fg-tertiary"}),n.jsxs("span",{className:"text-xs text-fg-tertiary leading-relaxed break-words min-w-0",children:[n.jsx("span",{className:"font-medium",children:o("execution.errorPrefix")})," ",e.content.replace(/^⚠\s*/,"")]})]}):null}function cr({entries:e,streamingText:t,isActive:r,onExpand:s,showRounds:a,embedded:o}){const{t:i}=T("common"),l=e.length>0?e[e.length-1]:null,d=e.filter(k=>k.type==="tool_end").length,c=e.filter(k=>k.type==="error").length,u=e.length>0?new Date(e[0].createdAt).getTime():Date.now(),b=l?new Date(l.createdAt).getTime():Date.now(),h=r?Date.now()-u:b-u,f=new Set(e.filter(k=>k.executionRound!=null).map(k=>k.executionRound)),x=f.size>0?Math.max(...f):void 0,j=a&&f.size>1;let v,y,m=null;if(r)if(t)v="✍",y=i("execution.compact.writingResponse"),m=he(t.split(`
9
+ `).pop()??"",80);else if(l?.type==="tool_start"){const k=P(l.content);v=k.icon,y=`${i(`execution.tools.${k.key}`,{defaultValue:k.label})}...`;const N=l.metadata?.arguments&&typeof l.metadata.arguments=="object"?l.metadata.arguments.command:void 0;N&&(m=`$ ${he(N.split(`
10
+ `)[0]??"",80)}`)}else if(l?.type==="tool_end"){const k=P(l.content);v=k.icon,y=i(`execution.tools.${k.key}`,{defaultValue:k.label})}else v="💭",y=i("execution.compact.thinking");else if(c>0&&l?.type==="error")v="❌",y=i("execution.compact.failed");else{const N=[...e].reverse().find(L=>L.type==="status")?.content??"";N==="completed"||N==="execution_finished"?(v="✅",y=i("execution.compact.completed")):(v="●",y=i("execution.compact.toolsExecuted",{count:d}))}const w=K(h);return n.jsx("div",{onClick:()=>{X(),s()},className:`overflow-hidden transition-all cursor-pointer min-w-0 ${o?"hover:bg-surface-elevated/20":`rounded-lg border hover:brightness-110 ${r?"border-2 exec-card-active":"border border-border-default bg-surface-elevated/30 hover:border-brand-500/40"}`}`,children:n.jsxs("div",{className:o?"py-2":"px-3 py-2.5 bg-surface-primary/80",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[r?n.jsxs("svg",{className:"w-3.5 h-3.5 animate-spin text-brand-500 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[n.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),n.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}):n.jsx("span",{className:"text-sm shrink-0",children:v}),n.jsx("span",{className:`text-xs font-medium truncate ${r?"text-fg-primary":"text-fg-secondary"}`,children:y})]}),w&&n.jsx("span",{className:"text-[10px] text-fg-tertiary tabular-nums shrink-0",children:w})]}),t?n.jsx("div",{className:`mt-1.5 ml-5.5 text-xs text-fg-secondary whitespace-pre-wrap break-words leading-relaxed ${o?"":"max-h-32 overflow-y-auto"}`,children:n.jsx(R,{content:t,className:"text-xs"})}):m?n.jsx("div",{className:"mt-1 ml-5.5 text-[11px] font-mono text-fg-tertiary truncate",children:m}):null,n.jsxs("div",{className:"flex items-center justify-between mt-2",children:[n.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary",children:[d>0&&n.jsxs("span",{children:["🔧 ",i("execution.compact.toolsLine",{count:d})]}),e.some(k=>k.type==="text"&&!k.metadata?.isThinking)&&n.jsxs("span",{children:["💬 ",i("execution.compact.text")]}),e.some(k=>k.type==="text"&&k.metadata?.isThinking)&&n.jsxs("span",{className:"text-purple-400",children:["💭 ",i("execution.compact.thinkingTag")]}),j&&x!=null&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"opacity-30",children:"·"}),n.jsx("span",{children:i("execution.compact.round",{n:x})}),n.jsx("span",{className:"opacity-30",children:"·"}),n.jsx("span",{children:i("execution.compact.rounds",{count:f.size})})]})]}),n.jsxs("span",{className:"text-[10px] text-brand-500 flex items-center gap-0.5",children:[i("execution.compact.showFullLog"),n.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 20 20",fill:"currentColor",children:n.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]})]})]})})}function Zt(e){const t=new Map;for(const r of e){const s=r.executionRound??1;t.has(s)||t.set(s,[]);const a=je(r);a&&t.get(s).push(a)}return Array.from(t.entries()).sort(([r],[s])=>r-s).map(([r,s])=>({round:r,entries:s}))}function dr({entries:e,streamingText:t,isActive:r,onCollapse:s,showRounds:a,embedded:o,expandThinking:i,hideApprovalCards:l}){const{t:d}=T("common"),c=g.useRef(null),[u,b]=g.useState(new Set),h=Zt(e),f=a&&h.length>1;g.useEffect(()=>{h.length>0&&b(y=>{const m=new Set(y);return m.add(h[h.length-1].round),m})},[h.length]),g.useEffect(()=>{o||!c.current||!r||(c.current.scrollTop=c.current.scrollHeight)},[e.length,t,r,o]);const x=y=>{X(),b(m=>{const w=new Set(m);return w.has(y)?w.delete(y):w.add(y),w})},j=f?null:e.map(je).filter(y=>y!==null),v=j?be(j):null;return n.jsxs("div",{className:`min-w-0 overflow-hidden ${o?"":"rounded-lg border border-border-default bg-surface-primary/50"}`,children:[s&&n.jsxs("div",{onClick:()=>{X(),s()},className:`flex items-center cursor-pointer hover:bg-surface-elevated/40 transition-colors ${o?"justify-end py-0.5":"justify-between px-3 py-1.5 border-b border-border-default"}`,children:[!o&&n.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium uppercase tracking-wider",children:d("execution.fullLog.title")}),n.jsxs("span",{className:"text-[10px] text-brand-500 flex items-center gap-0.5",children:[d("execution.fullLog.collapse"),n.jsx("svg",{className:"w-3 h-3 rotate-180",viewBox:"0 0 20 20",fill:"currentColor",children:n.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]})]}),n.jsxs("div",{ref:o?void 0:c,className:`space-y-2.5 min-w-0 overflow-x-hidden ${o?"py-1":"px-3 py-2 max-h-[60vh] overflow-y-auto scrollbar-thin"}`,children:[f?h.map(y=>{const m=u.has(y.round),w=be(y.entries),k=y.entries.filter(N=>N.type==="tool"&&N.info?.status!=="running").length;return n.jsxs("div",{className:"border border-border-default/50 rounded-lg mb-2 overflow-hidden",children:[n.jsxs("button",{onClick:()=>x(y.round),className:"w-full flex items-center justify-between px-3 py-1.5 bg-surface-elevated/30 hover:bg-surface-elevated/50 transition-colors",children:[n.jsx("span",{className:"text-xs text-fg-secondary font-medium",children:d("execution.compact.round",{n:y.round})}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-[10px] text-fg-tertiary",children:d("execution.compact.toolsLine",{count:k})}),n.jsx("svg",{className:`w-3 h-3 text-fg-tertiary transition-transform ${m?"rotate-180":""}`,viewBox:"0 0 20 20",fill:"currentColor",children:n.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]})]}),m&&n.jsx("div",{className:"px-3 py-1.5 space-y-2.5",children:w.map((N,L)=>n.jsx(ye,{entry:N,showTime:!1,isLast:L===w.length-1,defaultThinkingExpanded:!!i,hideApprovalCards:l},L))})]},y.round)}):v&&v.map((y,m)=>n.jsx(ye,{entry:y,showTime:!1,isLast:m===v.length-1,defaultThinkingExpanded:!!i,hideApprovalCards:l},m)),r&&t&&n.jsx(Wt,{content:t}),r&&!t&&n.jsx(Kt,{})]})]})}function ur(e){return new Set(e.map(t=>t.ref))}function pr(e,t){const r=e?.workUnitRef;return r?t.has(r):!1}function mr(e,t){return e.some(r=>r.taskId!=null&&r.taskId===t)}const en=4e3,tn=120;function nn(e){const t=a=>String(Math.abs(a)).padStart(2,"0"),r=-e.getTimezoneOffset(),s=r>=0?"+":"-";return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}T${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())}${s}${t(Math.floor(Math.abs(r)/60))}:${t(Math.abs(r)%60)}`}function rn(e){const t=e.match(/\[([A-Za-z0-9][\w.-]*):([^\]\s]+)\]/);return t?`${t[1]}:${t[2]}`:void 0}function sn(e,t){const r=e.split(/\r?\n/).map(s=>s.trim()).find(Boolean)??"";return r.length<=t?r:`${r.slice(0,t-1)}…`}function oe(e,t=en){return e.length<=t?e:`${e.slice(0,t-1)}…`}function an(e){const t=(e.rawError??"").trim(),r=(e.friendlyError??"").trim(),s=rn(`${t}
11
+ ${r}`),a=new Date,o=[V.t("common:feedback.draft.autoFilled")];o.push(`raw_error: ${t?oe(t):V.t("common:feedback.draft.noRawError")}`),r&&r!==t&&o.push(`friendly_error: ${oe(r)}`),s&&o.push(`provider:model: ${s}`),o.push(`time: ${nn(a)}`);const i=(e.agentName??"").trim(),l=(e.agentId??"").trim(),d=i&&l?`${i} (${l})`:i||l;d&&o.push(`agent: ${d}`),e.sessionId&&o.push(`session_id: ${e.sessionId}`),o.push(""),o.push(V.t("common:feedback.draft.myAction"));const c=sn(r||t,60)||V.t("common:feedback.draft.unknownError");return{title:oe(V.t("common:feedback.draft.title",{reason:`${s?`${s} · `:""}${c}`}),tn),body:oe(o.join(`
12
+ `))}}function on(e,t){return{rawError:e.errorRaw,friendlyError:e.text,agentName:e.agentName,agentId:e.agentId,sessionId:e.sessionId,appVersion:t?.appVersion,now:t?.now}}function ln({msg:e}){const{t}=T("common"),[r,s]=g.useState(null);return n.jsxs(n.Fragment,{children:[n.jsxs("button",{type:"button",onClick:()=>s(an(on(e))),className:"mt-1 inline-flex items-center gap-1 text-[11px] text-fg-tertiary hover:text-fg-secondary transition-colors",children:[n.jsxs("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[n.jsx("path",{d:"M12 9v4M12 17h.01",strokeLinecap:"round"}),n.jsx("path",{d:"M10.3 3.9 2.4 18a2 2 0 0 0 1.7 3h15.8a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z",strokeLinejoin:"round"})]}),t("feedback.reportThisError")]}),r&&n.jsx(dt,{initialTitle:r.title,initialBody:r.body,onClose:()=>s(null)})]})}function gr({priority:e}){const{t}=T(["common","team"]),r=e==="high"||e==="critical",s=e&&e!=="normal"?` · ${t(`common:priority.${e}`,{defaultValue:e})}`:"";return n.jsxs("div",{className:`inline-flex items-center gap-1 mt-1.5 px-2 py-0.5 rounded-full text-[10px] font-medium ${r?"bg-amber-500/10 text-amber-500 border border-amber-500/20":"bg-brand-500/10 text-brand-400 border border-brand-500/20"}`,children:[n.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),n.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),n.jsxs("span",{children:[t("team:notifications.badgeLabel"),s]})]})}function xr({name:e,agentId:t,agents:r,onViewProfile:s}){const{t:a}=T(["team","common"]),[o,i]=g.useState(!1),l=g.useRef(null),d=t?r.find(c=>c.id===t):r.find(c=>c.name===e);return g.useEffect(()=>{if(!o)return;const c=u=>{l.current&&!l.current.contains(u.target)&&i(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[o]),d?n.jsxs("span",{ref:l,className:"relative inline-block",children:[n.jsx("button",{onClick:()=>i(!o),className:"text-fg-tertiary hover:text-brand-500 cursor-pointer transition-colors",children:e}),o&&n.jsxs("div",{className:"absolute left-0 top-full mt-1.5 bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-40 w-56 p-3 space-y-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(We,{name:d.name,avatarUrl:d.avatarUrl,size:28,bgClass:"bg-brand-500/15 text-brand-600"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"text-xs text-fg-primary font-medium truncate",children:d.name}),n.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[d.role," · ",d.agentRole??a("page.workerRole")]})]}),n.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${d.status==="working"?"bg-blue-400 animate-pulse":d.status==="error"?"bg-red-400":"bg-green-400"}`})]}),n.jsx("button",{onClick:()=>{i(!1),s?.(d.id)},className:"w-full text-center text-[10px] text-brand-500 hover:text-brand-500 border border-border-default hover:border-gray-600 rounded-lg py-1 transition-colors",children:a("page.viewProfileArrow")})]})]}):n.jsx("span",{children:e})}function fr({agent:e,anchorRect:t,onClose:r,onViewProfile:s}){const{t:a}=T(["common","team"]),o=g.useRef(null);g.useEffect(()=>{const c=u=>{o.current&&!o.current.contains(u.target)&&r()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[r]);const i=e.status==="idle"?"bg-green-400":e.status==="working"?"bg-blue-400 animate-pulse":e.status==="error"?"bg-red-400":"bg-gray-500",l=e.status==="idle"?a("common:status.online"):e.status==="working"?a("common:status.working"):e.status==="error"?a("common:status.error"):a("common:status.offline"),d=g.useCallback(c=>{if(!c)return;o.current=c;const u=c.getBoundingClientRect(),b=window.innerWidth,h=window.innerHeight,f=8;u.right>b-f&&(c.style.left=`${Math.max(f,b-u.width-f)}px`),u.left<f&&(c.style.left=`${f}px`),u.bottom>h-f&&(c.style.top=`${Math.max(f,h-u.height-f)}px`)},[]);return n.jsxs("div",{ref:d,className:"fixed z-50 w-64 max-w-[calc(100vw-1rem)] bg-surface-secondary border border-border-default rounded-xl shadow-2xl p-4 space-y-3",style:{top:t.top+40,left:t.left},children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(We,{name:e.name,avatarUrl:e.avatarUrl,size:40,bgClass:"bg-brand-500/15 text-brand-600"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"text-sm text-fg-primary font-medium truncate",children:e.name}),n.jsx("div",{className:"text-[11px] text-fg-tertiary",children:e.role}),n.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[n.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${i}`}),n.jsx("span",{className:"text-[10px] text-fg-secondary",children:l}),e.agentRole&&n.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["· ",e.agentRole]})]})]})]}),n.jsx("button",{onClick:()=>{r(),s(e.id)},className:"w-full py-1.5 text-xs text-brand-500 hover:text-brand-500 border border-border-default hover:border-gray-600 rounded-lg transition-colors text-center",children:a("team:page.viewProfileArrow")})]})}function cn(e){const t=String(e);return t.includes("MARKUS_UPSTREAM_ERROR")?!1:t.includes("CU_EXCEEDED")||t.includes("CU_MONTHLY_EXCEEDED")}const dn="markus:credit-notif-muted";let Be=0;function hr(){try{if(localStorage.getItem(dn))return}catch{}const e=Date.now();e-Be<5*6e4||(Be=e,window.dispatchEvent(new CustomEvent("markus:credit-exhausted")))}function un(e){const t=[...e.matchAll(/"message"\s*:\s*"((?:[^"\\]|\\.)*)"/g)].map(s=>{try{return JSON.parse(`"${s[1]}"`)}catch{return s[1]}}).map(s=>s.replace(/\s*\(request_id:[^)]*\)/gi,"").trim()).filter(Boolean);if(t.length)return t[t.length-1];const r=e.match(/\{[\s\S]*\}/);if(r)try{const s=JSON.parse(r[0]),a=s.error?.message??s.message;if(a)return a}catch{}return""}function pn(e){const t=e.match(/\b(?:API error|HTTP|status(?: code)?)\s*:?\s*(\d{3})\b/i);if(t)return Number(t[1]);const r=e.match(/\b(\d{3})\s+(Unauthorized|Forbidden|Too Many Requests|Bad Gateway|Service Unavailable|Conflict)\b/i);return r?Number(r[1]):null}function mn(e,t){const r=String(e);if(r.includes("AbortError")||r.includes("abort"))return"";const s=un(r),a=(l,d)=>t(`team:errors.${l}`,d);if(ut(e))return a("sessionExpired");if(/CONTEXT OVERFLOW|maximum context length/i.test(r)){const l=r.match(/requested (\d+)\s*tokens/i)?.[1],d=r.match(/maximum context length is (\d+)\s*tokens/i)?.[1],c=u=>u?`${Math.round(Number(u)/1e3).toLocaleString()}k`:"—";return a("aiContextOverflow",{asked:c(l),limit:c(d)})}if(r.includes("MARKUS_UPSTREAM_ERROR"))return a("aiUpstreamBillingMismatch",{detail:s||a("defaultUpstreamBillingMismatch")});if(cn(r)||r.includes("CU_EXCEEDED"))return a("markusCuExceeded");if(r.includes("CU_WINDOW_EXCEEDED"))return a("markusWindowExceeded");if(r.includes("MARKUS_RATE_LIMITED"))return a("markusRateLimited");if(/not available in your region/i.test(r))return a("aiRegionBlocked",{model:(r.match(/\[(?:markus|openrouter):([^\]]+)\]/i)?.[1]||"").trim()||"—"});const o=pn(r);if(o===401||/unauthorized|invalid.?api.?key/i.test(r))return a("ai401",{detail:s||a("defaultInvalidApiKey")});if(o===402)return a("ai402",{detail:s||a("defaultInsufficientCredits")});if(o===429||/rate.?limit/i.test(r))return a("ai429",{detail:s||a("defaultTooManyRequests")});if(o===409||/conflict/i.test(r))return a("ai409",{detail:s||a("defaultConflict")});if(o===502||/bad.?gateway/i.test(r))return a("ai502",{detail:s||a("defaultUpstreamDown")});if(o===503||/service.?unavailable/i.test(r))return a("ai503",{detail:s||a("defaultServiceDown")});const i=(s||r).replace(/https?:\/\/[^\s]*openrouter\.ai[^\s]*/gi,"").trim();return a("aiGeneric",{detail:(i||r).slice(0,120)})}function br({msg:e,onCopy:t,onRetry:r,onResume:s,onReply:a,onRemember:o,isCopied:i,isLastAgentMsg:l,showRemember:d}){const{t:c}=T(["team","common"]),u=e.isError||e.sender==="agent"&&e.text.startsWith("⚠"),b=e.isStopped,h=e.emptyReply===!0,f=l!==!1,x=_t(d,e.sender)&&!!o;return n.jsxs("div",{className:"flex items-center flex-wrap gap-0.5 mt-1",children:[n.jsxs("button",{onClick:()=>t(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-fg-tertiary hover:text-fg-primary hover:bg-surface-overlay/60 transition-colors",title:c("common:copy"),children:[i?n.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:n.jsx("polyline",{points:"20 6 9 17 4 12"})}):n.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),n.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),c(i?"common:copied":"common:copy")]}),f&&s&&n.jsxs("button",{onClick:()=>s(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-green-500 hover:text-green-400 hover:bg-green-500/10 transition-colors",title:c("page.messageActions.resumeTitle"),children:[n.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:n.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),c("page.messageActions.resumeTitle")]}),f&&b&&r&&n.jsxs("button",{onClick:()=>r(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-brand-500 hover:text-brand-500 hover:bg-brand-500/10 transition-colors",title:c("page.messageActions.reaskTitle"),children:[n.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("polyline",{points:"23 4 23 10 17 10"}),n.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),c("page.messageActions.reaskTitle")]}),f&&(u||h)&&!b&&r&&n.jsxs("button",{onClick:()=>r(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-amber-600 hover:text-amber-600 hover:bg-amber-500/10 transition-colors",title:c("page.messageActions.retryTitle"),children:[n.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("polyline",{points:"23 4 23 10 17 10"}),n.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),c("page.messageActions.retryTitle")]}),f&&!u&&!h&&!b&&e.sender==="agent"&&r&&n.jsxs("button",{onClick:()=>r(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-fg-tertiary hover:text-fg-primary hover:bg-surface-overlay/60 transition-colors",title:c("page.messageActions.retryTitle"),children:[n.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("polyline",{points:"23 4 23 10 17 10"}),n.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),c("page.messageActions.retryTitle")]}),a&&n.jsxs("button",{onClick:()=>a(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-fg-tertiary hover:text-fg-primary hover:bg-surface-overlay/60 transition-colors",title:c("page.messageActions.replyTitle"),children:[n.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("polyline",{points:"9 17 4 12 9 7"}),n.jsx("path",{d:"M20 18v-2a4 4 0 00-4-4H4"})]}),c("page.messageActions.replyTitle")]}),x&&n.jsxs("button",{type:"button",onClick:()=>o(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-fg-tertiary hover:text-fg-primary hover:bg-surface-overlay/60 transition-colors",title:c("page.messageActions.rememberTitle"),children:[n.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M12 2a7 7 0 00-4 12.7V19a1 1 0 001 1h6a1 1 0 001-1v-4.3A7 7 0 0012 2z"}),n.jsx("path",{d:"M9 22h6"})]}),c("page.messageActions.rememberTitle")]}),e.sender==="agent"&&n.jsx("span",{className:"ml-1 px-1 text-[10px] leading-none text-fg-tertiary/70 select-none whitespace-nowrap",children:c("page.messageActions.aiGeneratedDisclaimer")})]})}function yr({busy:e,onConfirm:t,onCancel:r}){const{t:s}=T(["team","common"]),[a,o]=g.useState("");return ve.createPortal(n.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10050] p-4",onClick:r,children:n.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[400px] max-w-[calc(100vw-2rem)] shadow-2xl",onClick:i=>i.stopPropagation(),children:[n.jsx("h3",{className:"font-semibold text-base text-fg-primary",children:s("page.messageActions.rememberModalTitle")}),n.jsx("p",{className:"text-sm text-fg-secondary mt-1.5 leading-relaxed",children:s("page.messageActions.rememberModalHint")}),n.jsx("textarea",{value:a,onChange:i=>o(i.target.value),placeholder:s("page.messageActions.rememberModalPlaceholder"),rows:3,disabled:e,className:"mt-3 w-full px-3 py-2 text-sm bg-surface-primary border border-border-default rounded-lg outline-none focus:border-brand-500/50 resize-y min-h-[72px]"}),n.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[n.jsx("button",{type:"button",onClick:r,disabled:e,className:"px-4 py-1.5 text-sm text-fg-secondary hover:text-fg-primary rounded-lg transition-colors",children:s("page.messageActions.rememberCancel")}),n.jsx("button",{type:"button",onClick:()=>t(a),disabled:e,className:"px-4 py-1.5 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-60 text-on-brand rounded-lg transition-colors",children:e?s("common:loading",{defaultValue:"…"}):s("page.messageActions.rememberConfirm")})]})]})}),document.body)}const gn=/[.!?。!?…::]\s*$|["'”’)\]}】》]\s*$|\n\s*$/,xn=/^(?:\n|#{1,6}[ \t]|[-*+][ \t]|\d+[.)][ \t]|>|\||```|~~~|---)/;function fn(e,t){return!(!e.replace(/\s+$/,"")||gn.test(e)||!t.trim()||xn.test(t))}function hn(e,t,r){return/\s$/.test(e)||/^\s/.test(t)?e+t:r?.spaceNeeded?`${e} ${t}`:e+t}function bn(e){const t=o=>o.type!=="text"||o.metadata?.isThinking===!0,r=[];let s=[],a=-1;for(const o of e){if(t(o)){s.push(o);continue}const i=a>=0?r[a]:void 0;if(i&&s.length>0&&o.metadata?.paragraphBreak!==!0&&i.metadata?.paragraphAfter!==!0&&fn(i.content,o.content)){i.content=hn(i.content,o.content,{spaceNeeded:i.metadata?.trailingSpace===!0||o.metadata?.leadingSpace===!0}),r.push(...s),s=[];continue}s.length>0&&(r.push(...s),s=[]),r.push(o),a=r.length-1}return s.length>0&&r.push(...s),r}function yn(e){return e.type!=="text"||e.metadata?.isThinking===!0}function st(e){const t=Date.parse(e[0]?.createdAt??""),r=Date.parse(e[e.length-1]?.createdAt??"");return Number.isFinite(t)&&Number.isFinite(r)&&r>t?r-t:0}function vn(e){let t=0,r=0,s=0,a=null,o=0;for(const l of e){if(l.type==="text"&&l.metadata?.isThinking===!0){t++;continue}if(l.type==="tool_start"){r++,a=l.content;continue}if(l.type==="tool_end"){l.metadata?.success===!1&&o++,a=null;continue}l.type==="subagent_start"&&s++,l.type==="error"&&o++}const i=st(e);return{thinkingCount:t,toolCount:r,subagentCount:s,running:a!==null,...a?{runningTool:a}:{},tailIsThinking:e[e.length-1]?.type==="text"&&e[e.length-1]?.metadata?.isThinking===!0,elapsedMs:i,errorCount:o}}function at(e){const t=[];let r=[],s=0;const a=()=>{r.length!==0&&(t.push({kind:"process",key:`proc_${s}`,entries:r,summary:vn(r)}),r=[])};return e.forEach((o,i)=>{if(yn(o)){r.length===0&&(s=i),r.push(o);return}a(),t.push({kind:"text",key:`text_${i}`,entry:o})}),a(),t}function jn(e){for(let t=e.length-1;t>=0;t--)if(e[t].kind==="text")return t;return-1}function kn(e,t){if(e.length===0)return{blocks:e,foldedCount:0,foldableCount:0};if(t.interrupted)return{blocks:e,foldedCount:0,foldableCount:0};if(t.isStreaming)return{blocks:e,foldedCount:0,foldableCount:0};const r=jn(e),s=r>0?r:0,a=s>0?e.slice(s):e,o=t.expanded?e:a,i=t.expanded?0:e.length-a.length;return{blocks:o,foldedCount:i,foldableCount:s}}function wn(e,t){const r=Math.max(0,Math.round(e/1e3));return r<60?t("common:execution.workedForSeconds",{seconds:r}):t("common:execution.workedForMinutes",{minutes:Math.floor(r/60),seconds:r%60})}function ot({state:e}){return e==="running"?n.jsx("span",{className:"animate-spin inline-flex",children:n.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round","aria-hidden":"true",children:n.jsx("path",{d:"M12 3a9 9 0 1 0 9 9"})})}):n.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:n.jsx("path",{d:"M20 6.5 9.5 17 4 11.5"})})}function it({entries:e,summary:t,isStreaming:r,isLastBlock:s,hideApprovalCards:a,reconnecting:o,onExpand:i}){const{t:l}=T("common"),[d,c]=g.useState(!1),u=g.useMemo(()=>be(e.map(je).filter(y=>y!==null)),[e]),b=!!(r&&(s||t.running))||!!o,h=b?"running":"done",f=o?l("execution.reconnecting"):b&&t.runningTool?l("execution.processRun.runningTool",{tool:l(`execution.tools.${t.runningTool}`,{defaultValue:t.runningTool})}):null,x=[];t.thinkingCount>0&&x.push(l("execution.processRun.thinking")),t.toolCount>0&&x.push(l("execution.processRun.tools",{count:t.toolCount})),t.subagentCount>0&&x.push(l("execution.processRun.subagents",{count:t.subagentCount})),t.errorCount>0&&x.push(l("execution.processRun.errors",{count:t.errorCount})),t.elapsedMs>=1e3&&x.push(K(t.elapsedMs));const j=b?f??l("execution.thinkingEllipsis"):x.join(" · ")||l("execution.processRun.label"),v=l(`execution.processRun.state.${h}`);return n.jsxs("div",{className:"min-w-0",children:[n.jsxs("button",{type:"button",onClick:()=>{c(!d),d||i?.()},"aria-expanded":d,"data-process-state":h,title:j,className:"group relative w-full flex items-center gap-2 px-2 py-1 rounded-lg text-left text-[11px] leading-tight text-fg-tertiary bg-surface-elevated/25 hover:bg-surface-elevated/45 border border-border-default/40 hover:border-border-default/70 overflow-hidden transition-colors cursor-pointer select-none",children:[b&&n.jsx("span",{className:"process-run-sweep","aria-hidden":"true"}),n.jsx("span",{className:`relative shrink-0 flex items-center justify-center w-3 h-3 ${h==="running"?"text-brand-400":""}`,children:n.jsx(ot,{state:h})}),n.jsx("span",{className:"sr-only",children:v}),n.jsx("span",{className:`relative min-w-0 truncate ${b&&!f?"activity-text-shimmer":""}`,children:b||x.length===0?j:x.map((y,m)=>n.jsxs("span",{children:[m>0?" · ":"",y]},y+m))}),n.jsx("svg",{className:`relative ml-auto w-3 h-3 shrink-0 transition-transform ${d?"rotate-180":""}`,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:n.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]}),d&&n.jsx("div",{className:"mt-1 ml-[7px] pl-3 border-l-2 border-border-default/50 space-y-2 min-w-0 overflow-hidden",children:u.length>0?u.map((y,m)=>n.jsx(ye,{entry:y,showTime:!1,hideApprovalCards:a},m)):n.jsx("div",{className:"py-1 text-[11px] text-fg-tertiary",children:l("execution.noToolDetail")})})]})}function vr({entries:e,isStreaming:t,streamingText:r,className:s}){const a=g.useMemo(()=>at(e),[e]);return n.jsxs("div",{className:`space-y-2 min-w-0 overflow-x-hidden ${s??""}`,children:[a.map((o,i)=>o.kind==="text"?o.entry.content.trim()?n.jsx(R,{content:o.entry.content},o.key):null:n.jsx(it,{entries:o.entries,summary:o.summary,isStreaming:t,isLastBlock:t&&i===a.length-1},o.key)),t&&r?n.jsx(R,{content:r}):null]})}function Fe(e,t,r){if(!e)return[];const s=[];let a=0;const o=t??"";let l=r?new Date(r).getTime():Date.now();const d=e.some(m=>m.createdAt),c=m=>{if(m.createdAt)return m.createdAt;if(d)return new Date(l).toISOString();const w=new Date(l).toISOString();return m.type==="tool"&&m.durationMs?l+=m.durationMs:l+=1e3,w};let u="",b="",h="";const f=()=>{const m=u.trim();if(m){const w=s[s.length-1];w&&w.type==="text"&&w.metadata?.isThinking?w.content+=(w.content?`
13
+
14
+ `:"")+m:s.push({id:`cseg_${a}`,sourceType:"chat",sourceId:"",agentId:o,seq:a++,type:"text",content:m,createdAt:h,metadata:{isThinking:!0}})}u=""},x=()=>{const m=b,w=m.trim();if(w){const k={};/^\s*\n/.test(m)&&(k.paragraphBreak=!0),/\n\s*\n\s*$/.test(m)&&(k.paragraphAfter=!0),/\s$/.test(m)&&(k.trailingSpace=!0),/^\s/.test(m)&&(k.leadingSpace=!0),s.push({id:`cseg_${a}`,sourceType:"chat",sourceId:"",agentId:o,seq:a++,type:"text",content:w,createdAt:h,...Object.keys(k).length>0?{metadata:k}:{}})}b=""},j="<think>",v="</think>",y=m=>{let w=0,k=!1;for(;w<m.length;)if(k){const N=m.indexOf(v,w);N===-1?w=m.length:(k=!1,w=N+v.length)}else{const N=m.indexOf(j,w);N===-1?(b+=m.slice(w),w=m.length):(b+=m.slice(w,N),k=!0,w=N+j.length)}};for(const m of e)if(h=c(m),m.type==="tool"){x();const w=m.createdAt&&m.durationMs?new Date(new Date(m.createdAt).getTime()-m.durationMs).toISOString():h;s.push({id:`cseg_${a}`,sourceType:"chat",sourceId:"",agentId:o,seq:a++,type:"tool_start",content:m.tool,metadata:{arguments:m.args,...m.status==="running"&&m.subagentLogs?.length?{subagentLogs:m.subagentLogs}:{}},createdAt:w}),m.status!=="running"&&s.push({id:`cseg_${a}`,sourceType:"chat",sourceId:"",agentId:o,seq:a++,type:"tool_end",content:m.tool,metadata:{arguments:m.args,result:m.result,error:m.error,durationMs:m.durationMs,success:m.status!=="error",...m.subagentLogs?.length?{subagentLogs:m.subagentLogs}:{}},createdAt:h})}else m.thinking&&(x(),u+=m.thinking,f()),y(we(m.content).cleaned);return x(),bn(s)}const jr=g.memo(function({msg:t,isStreaming:r,liveActivities:s,onMentionClick:a,knownNames:o}){const{t:i}=T(["team","common"]),l=t.isStopped,d=!!(t.isError||(t.text??"").startsWith("⚠")),c=g.useMemo(()=>d?((t.errorRaw?mn(t.errorRaw,i):"")||t.text||"").replace(/^⚠\s*/,""):"",[d,t.errorRaw,t.text,i]),[u,b]=g.useState(!1),[h,f]=g.useState(null),x=g.useRef(!1),j=g.useCallback(()=>{!t.needsDetail||!t.sessionId||x.current||(x.current=!0,U.sessions.getMessageDetail(t.sessionId,t.id).then(({message:E})=>{const A=E.metadata?.segments;A?.length&&f(Qe(A))}).catch(()=>{}))},[t.needsDetail,t.sessionId,t.id]);g.useEffect(()=>{u&&j()},[u,j]);const v=h??t.segments,y=E=>E.type==="text"?E.content.length+(E.thinking?.length??0):(E.result?.length??0)+(E.subagentLogs?.length??0)*1e3+(E.liveOutput?.length??0),m=v?v.length+":"+(v.length>0?y(v[v.length-1]):0):"",w=v?v.reduce((E,A)=>E+(A.type==="tool"?A.subagentLogs?.length??0:0),0):0,k=g.useMemo(()=>v&&v.length>0?Fe(v,t.agentId,t.rawCreatedAt):[],[m,w,t.agentId,t.rawCreatedAt]),N=t.committedSegments,L=N?N.length+":"+(N.length>0?y(N[N.length-1]):0):"",ce=N?N.reduce((E,A)=>E+(A.type==="tool"?A.subagentLogs?.length??0:0),0):0,B=g.useMemo(()=>r?k:N&&N.length>0?Fe(N,t.agentId,t.rawCreatedAt):k,[r,L,ce,t.agentId,t.rawCreatedAt,k]);if(v!==void 0&&v.length>0){const E=p=>p.type==="text"&&p.content.startsWith("⚠"),D=v.filter(p=>p.type==="text"&&!E(p)).map(p=>p.content).join(""),q=p=>p.replace(/\n*<!--\s*notify_context:\s*[\s\S]*?-->/g,"").replace(/<think>[\s\S]*?(<\/think>|$)/g,"").replace(/<(invoke|function_calls|antml:\w+)\b[\s\S]*?(<\/\1>|$)/g,"").replace(/<\/?(invoke|function_calls|antml:\w+)[^>]*>/g,"").trim()||null,H=(D?q(D):null)||(d?null:t.text?q(t.text):null),de=d?B.filter(p=>!(p.type==="text"&&p.content.startsWith("⚠"))):B,O=at(de),G=O.some(p=>p.kind==="text"),J=!!(l||t.isError),Q=kn(O,{isStreaming:r,interrupted:J,expanded:u}),Z=Q.blocks,ue=Q.foldableCount>0,ee=wn(st(B),i),W=[];for(const p of v){if(p.type!=="tool")continue;const _=Ge(p.tool,p.result);if(_){W.push({key:`task-${_.taskId}`,kind:"task",info:_});continue}const C=Ve(p.tool,p.result);C&&W.push({key:`req-${C.requirementId}`,kind:"req",info:C})}return n.jsxs("div",{className:"space-y-2 min-h-[1em] min-w-0 overflow-x-hidden",children:[ue&&n.jsxs("button",{type:"button",onClick:()=>b(p=>!p),"aria-expanded":u,"data-worked-summary":"true",title:ee,className:"group relative w-full flex items-center gap-2 px-2 py-1 rounded-lg text-left text-[11px] leading-tight text-fg-tertiary bg-surface-elevated/25 hover:bg-surface-elevated/45 border border-border-default/40 hover:border-border-default/70 overflow-hidden transition-colors cursor-pointer select-none",children:[n.jsx("span",{className:"relative shrink-0 flex items-center justify-center w-3 h-3",children:n.jsx(ot,{state:"done"})}),n.jsx("span",{className:"relative min-w-0 truncate",children:ee}),n.jsx("svg",{className:`relative ml-auto w-3 h-3 shrink-0 transition-transform ${u?"rotate-180":""}`,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:n.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]}),Z.map(p=>p.kind==="text"?n.jsx(R,{content:p.entry.content,onMentionClick:a,knownNames:o},p.key):n.jsx(it,{entries:p.entries,summary:p.summary,isStreaming:r,isLastBlock:p.key===O[O.length-1]?.key,hideApprovalCards:!0,reconnecting:!!t.reconnecting,onExpand:j},p.key)),O.length===0&&r&&n.jsx(Ee,{activities:s,isActive:!0}),!G&&d&&c&&n.jsx("div",{className:"text-[13px] text-fg-tertiary leading-relaxed whitespace-pre-wrap",children:n.jsx(me,{text:c})}),!G&&!d&&H&&n.jsx(R,{content:H,onMentionClick:a,knownNames:o}),W.map(p=>p.kind==="task"?n.jsx(nt,{info:p.info},p.key):n.jsx(rt,{info:p.info},p.key)),!r&&!H&&O.length===0&&W.length===0&&!l&&t.emptyReply===!0&&n.jsx("div",{className:"flex items-start gap-1.5 text-[13px] text-fg-tertiary leading-relaxed",children:n.jsx("span",{children:i("page.emptyReply")})}),!r&&G&&c&&n.jsxs("div",{className:"flex items-start gap-1.5 mt-2 text-[11px] text-fg-tertiary leading-relaxed",children:[n.jsxs("svg",{className:"w-3 h-3 mt-0.5 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[n.jsx("circle",{cx:"12",cy:"12",r:"9"}),n.jsx("path",{d:"M12 8v4.5M12 16h.01",strokeLinecap:"round"})]}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"text-fg-secondary",children:i("page.endedEarly")}),n.jsx("span",{className:"mx-1",children:"·"}),n.jsx("span",{children:n.jsx(me,{text:c})})]})]}),!r&&(t.isError||t.text.startsWith("⚠"))&&t.text&&n.jsx(ln,{msg:t}),l&&n.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5 text-[11px] text-fg-tertiary",children:[n.jsx("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"currentColor",children:n.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),n.jsx("span",{children:i("page.stopped")})]})]})}const F=(t.activities?.length??0)>0,$=t.text?t.text.replace(/<think>[\s\S]*?(<\/think>|$)/g,"").replace(/<(invoke|function_calls|antml:\w+)\b[\s\S]*?(<\/\1>|$)/g,"").replace(/<\/?(invoke|function_calls|antml:\w+)[^>]*>/g,"").trim():"";return n.jsxs(n.Fragment,{children:[(r||F)&&n.jsx(Ee,{activities:r?s:t.activities??[],isActive:r,persistent:!r&&F}),$?t.isError||$.startsWith("⚠")?n.jsx("p",{className:"text-[13px] text-fg-tertiary leading-relaxed whitespace-pre-wrap",children:n.jsx(me,{text:c||$.replace(/^⚠\s*/,"")})}):n.jsx(R,{content:$,onMentionClick:a,knownNames:o}):null,!r&&!$&&!F&&!l&&t.sender==="agent"&&t.emptyReply===!0&&n.jsx("div",{className:"flex items-start gap-1.5 text-[13px] text-fg-tertiary leading-relaxed",children:n.jsx("span",{children:i("page.emptyReply")})}),l&&n.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5 text-[11px] text-fg-tertiary",children:[n.jsx("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"currentColor",children:n.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),n.jsx("span",{children:i("page.stopped")})]})]})});export{rr as $,On as A,Ye as B,Rn as C,sr as D,Qt as E,lr as F,Dn as G,En as H,zn as I,we as J,Zn as K,me as L,er as M,tr as N,xr as O,vr as P,An as Q,Ee as R,jr as S,gr as T,br as U,fr as V,yr as W,ar as X,ir as Y,Kn as Z,nr as _,mn as a,or as a0,Ln as a1,mr as a2,Wt as a3,Kt as a4,be as a5,je as a6,dr as a7,cr as a8,Pn as b,Wn as c,Xn as d,Gn as e,Sn as f,P as g,Hn as h,pr as i,$n as j,Bn as k,ur as l,Qe as m,Un as n,qn as o,Yn as p,Qn as q,Jn as r,Vn as s,Tn as t,cn as u,hr as v,Mn as w,Fn as x,In as y,Je as z};
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownMessage-DVfFMzM9.js","assets/index-TPf50ZeO.js","assets/index-CzHSs0Vd.css"])))=>i.map(i=>d[i]);
2
- import{j as a,r as i,_ as f}from"./index-TPf50ZeO.js";const x=i.lazy(()=>f(()=>import("./MarkdownMessage-DVfFMzM9.js"),__vite__mapDeps([0,1,2])).then(e=>({default:e.MarkdownMessage}))),b=new Set(["ts","tsx","js","jsx","mjs","cjs","py","go","rs","java","kt","kts","c","cc","cpp","cxx","h","hpp","hxx","cs","rb","php","swift","scala","sh","bash","zsh","fish","ps1","sql","yaml","yml","toml","xml","css","scss","less","vue","svelte","graphql","gql","proto","dockerfile","makefile","cmake","rsx","r","lua","pl","pm","ex","exs","erl","hs","clj","zig","nim","dart","gradle","tf","hcl"]);function v(e){const t=e.split(/[/\\]/).pop()?.toLowerCase()||"";if(t==="dockerfile"||t==="makefile")return"code";const r=t.includes(".")?t.split(".").pop():"";switch(r){case"md":case"markdown":return"markdown";case"html":case"htm":return"html";case"json":case"jsonc":return"json";case"csv":case"tsv":return"csv";default:return r&&b.has(r)?"code":r?"text":void 0}}function w(e){const t=e.trimStart();if(/^<!doctype\s+html/i.test(t)||/^<html[\s>]/i.test(t))return"html";if(t.startsWith("{")||t.startsWith("["))try{return JSON.parse(e),"json"}catch{}}function S(e){if(e.format)return e.format;if(e.reference){const t=v(e.reference);if(t)return t}if(e.content){const t=w(e.content);if(t)return t}return e.reference?"text":"markdown"}function y({content:e,className:t,onSelection:r}){const c=i.useRef(null),[l,h]=i.useState(null);i.useEffect(()=>{const o=d=>{d.data?.type==="__htmlpreview_height"&&typeof d.data.height=="number"&&h(d.data.height),d.data?.type==="__htmlpreview_selection"&&r&&r(d.data)};return window.addEventListener("message",o),()=>window.removeEventListener("message",o)},[r]);const m=`<script>
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownMessage-CaLBeMto.js","assets/index-TAHyKznL.js","assets/index-9SXWNIl0.css"])))=>i.map(i=>d[i]);
2
+ import{u as g,j as a,r as i,_ as b}from"./index-TAHyKznL.js";const v=i.lazy(()=>b(()=>import("./MarkdownMessage-CaLBeMto.js"),__vite__mapDeps([0,1,2])).then(e=>({default:e.MarkdownMessage}))),w=new Set(["ts","tsx","js","jsx","mjs","cjs","py","go","rs","java","kt","kts","c","cc","cpp","cxx","h","hpp","hxx","cs","rb","php","swift","scala","sh","bash","zsh","fish","ps1","sql","yaml","yml","toml","xml","css","scss","less","vue","svelte","graphql","gql","proto","dockerfile","makefile","cmake","rsx","r","lua","pl","pm","ex","exs","erl","hs","clj","zig","nim","dart","gradle","tf","hcl"]);function y(e){const t=e.split(/[/\\]/).pop()?.toLowerCase()||"";if(t==="dockerfile"||t==="makefile")return"code";const r=t.includes(".")?t.split(".").pop():"";switch(r){case"md":case"markdown":return"markdown";case"html":case"htm":return"html";case"json":case"jsonc":return"json";case"csv":case"tsv":return"csv";default:return r&&w.has(r)?"code":r?"text":void 0}}function k(e){const t=e.trimStart();if(/^<!doctype\s+html/i.test(t)||/^<html[\s>]/i.test(t))return"html";if(t.startsWith("{")||t.startsWith("["))try{return JSON.parse(e),"json"}catch{}}function _(e){if(e.format)return e.format;if(e.reference){const t=y(e.reference);if(t)return t}if(e.content){const t=k(e.content);if(t)return t}return e.reference?"text":"markdown"}function E({content:e,className:t,onSelection:r}){const{t:c}=g("common"),h=i.useRef(null),[d,m]=i.useState(null);i.useEffect(()=>{const o=l=>{l.data?.type==="__htmlpreview_height"&&typeof l.data.height=="number"&&m(l.data.height),l.data?.type==="__htmlpreview_selection"&&r&&r(l.data)};return window.addEventListener("message",o),()=>window.removeEventListener("message",o)},[r]);const p=`<script>
3
3
  (function(){
4
4
  function getXPath(el){
5
5
  if(!el||el.nodeType!==1)return'';
@@ -45,7 +45,7 @@ import{j as a,r as i,_ as f}from"./index-TPf50ZeO.js";const x=i.lazy(()=>f(()=>i
45
45
  },'*');
46
46
  });
47
47
  })();
48
- <\/script>`,p=`<script>
48
+ <\/script>`,u=`<script>
49
49
  (function(){
50
50
  function send(){
51
51
  var h = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight);
@@ -55,7 +55,7 @@ import{j as a,r as i,_ as f}from"./index-TPf50ZeO.js";const x=i.lazy(()=>f(()=>i
55
55
  else window.addEventListener('load',send);
56
56
  new ResizeObserver(send).observe(document.body);
57
57
  })();
58
- <\/script>`,g="<style>html,body{overflow:hidden!important;height:auto!important;}</style>",u=i.useMemo(()=>{const o=g+p+m;if(/<html[\s>]/i.test(e)){let n=e;return/<\/body>/i.test(n)?n=n.replace(/<\/body>/i,`${o}</body>`):/<\/html>/i.test(n)?n=n.replace(/<\/html>/i,`${o}</html>`):n=n+o,n}const s=!document.documentElement.classList.contains("light")&&(document.documentElement.classList.contains("dark")||document.documentElement.classList.contains("cyberpunk")||!window.matchMedia("(prefers-color-scheme: light)").matches)?{text:"#e4e4e7",bg:"transparent",border:"#3f3f46",thBg:"rgba(63,63,70,0.5)",link:"#818cf8",codeBg:"rgba(63,63,70,0.5)",preBg:"rgba(24,24,27,0.8)",heading:"#fafafa"}:{text:"#1c1c1e",bg:"transparent",border:"#d1d5db",thBg:"rgba(0,0,0,0.04)",link:"#4f46e5",codeBg:"rgba(0,0,0,0.05)",preBg:"rgba(0,0,0,0.03)",heading:"#111827"};return`<!DOCTYPE html>
58
+ <\/script>`,f="<style>html,body{overflow:hidden!important;height:auto!important;}</style>",x=i.useMemo(()=>{const o=f+u+p;if(/<html[\s>]/i.test(e)){let n=e;return/<\/body>/i.test(n)?n=n.replace(/<\/body>/i,`${o}</body>`):/<\/html>/i.test(n)?n=n.replace(/<\/html>/i,`${o}</html>`):n=n+o,n}const s=!document.documentElement.classList.contains("light")&&(document.documentElement.classList.contains("dark")||document.documentElement.classList.contains("cyberpunk")||!window.matchMedia("(prefers-color-scheme: light)").matches)?{text:"#e4e4e7",bg:"transparent",border:"#3f3f46",thBg:"rgba(63,63,70,0.5)",link:"#818cf8",codeBg:"rgba(63,63,70,0.5)",preBg:"rgba(24,24,27,0.8)",heading:"#fafafa"}:{text:"#1c1c1e",bg:"transparent",border:"#d1d5db",thBg:"rgba(0,0,0,0.04)",link:"#4f46e5",codeBg:"rgba(0,0,0,0.05)",preBg:"rgba(0,0,0,0.03)",heading:"#111827"};return`<!DOCTYPE html>
59
59
  <html>
60
60
  <head>
61
61
  <meta charset="utf-8">
@@ -78,5 +78,5 @@ import{j as a,r as i,_ as f}from"./index-TPf50ZeO.js";const x=i.lazy(()=>f(()=>i
78
78
  h1, h2, h3, h4, h5, h6 { color: ${s.heading}; }
79
79
  </style>
80
80
  </head>
81
- <body>${e}${p}${m}</body>
82
- </html>`},[e]);return a.jsx("iframe",{ref:c,srcDoc:u,sandbox:"allow-scripts",className:t,style:{width:"100%",height:l!=null?`${l}px`:"auto",minHeight:l==null?"200px":void 0,border:"none",borderRadius:"8px",background:"transparent"},title:"HTML Preview"})}function k({content:e,className:t}){const r=i.useMemo(()=>{try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}},[e]);return a.jsx("pre",{className:`text-xs font-mono whitespace-pre-wrap break-words bg-surface-primary/50 rounded-lg p-4 leading-relaxed text-fg-secondary ${t??""}`,children:r})}function j({content:e,format:t,className:r,basePath:c,onHtmlSelection:l,copyVariant:h}){switch(t){case"html":return a.jsx(y,{content:e,className:r,onSelection:l});case"json":return a.jsx(k,{content:e,className:r});case"csv":case"text":case"code":return a.jsx("pre",{className:`text-xs font-mono whitespace-pre-wrap break-words bg-surface-primary/50 rounded-lg p-4 leading-relaxed text-fg-secondary ${r??""}`,children:e});default:return a.jsx(i.Suspense,{fallback:a.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading…"}),children:a.jsx(x,{content:e,className:r??"text-sm",basePath:c,copyVariant:h})})}}export{j as ContentRenderer,w as detectFormatFromContent,v as detectFormatFromPath,S as resolveFormat};
81
+ <body>${e}${u}${p}</body>
82
+ </html>`},[e]);return a.jsx("iframe",{ref:h,srcDoc:x,sandbox:"allow-scripts",className:t,style:{width:"100%",height:d!=null?`${d}px`:"auto",minHeight:d==null?"200px":void 0,border:"none",borderRadius:"8px",background:"transparent"},title:c("htmlPreview")})}function S({content:e,className:t}){const r=i.useMemo(()=>{try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}},[e]);return a.jsx("pre",{className:`text-xs font-mono whitespace-pre-wrap break-words bg-surface-primary/50 rounded-lg p-4 leading-relaxed text-fg-secondary ${t??""}`,children:r})}function $({content:e,format:t,className:r,basePath:c,onHtmlSelection:h,copyVariant:d}){const{t:m}=g("common");switch(t){case"html":return a.jsx(E,{content:e,className:r,onSelection:h});case"json":return a.jsx(S,{content:e,className:r});case"csv":case"text":case"code":return a.jsx("pre",{className:`text-xs font-mono whitespace-pre-wrap break-words bg-surface-primary/50 rounded-lg p-4 leading-relaxed text-fg-secondary ${r??""}`,children:e});default:return a.jsx(i.Suspense,{fallback:a.jsx("div",{className:"text-xs text-fg-tertiary",children:m("loading")}),children:a.jsx(v,{content:e,className:r??"text-sm",basePath:c,copyVariant:d})})}}export{$ as ContentRenderer,k as detectFormatFromContent,y as detectFormatFromPath,_ as resolveFormat};
@@ -0,0 +1 @@
1
+ import{$ as M,u as fe,r as u,h as R,V as be,a0 as he,k as N,j as r,a1 as pe}from"./index-TAHyKznL.js";const J=50*1024*1024,ee=new Set(["markdown","html"]);function me(e){return e||"markdown"}function ge(e){return ee.has(me(e))}class S extends Error{constructor(t){super(t),this.name="DeliverableShareError"}}class te extends S{constructor(){super(M.t("deliverables:share.notLoggedIntoHub")),this.name="NotLoggedIntoHubError"}}class xe extends S{bytes;limit;constructor(t,a){super(M.t("deliverables:share.tooLarge",{bytes:t,limit:a})),this.name="DeliverableTooLargeError",this.bytes=t,this.limit=a}}class ye extends S{status;constructor(t,a){super(M.t("deliverables:share.hubRequestFailed",{status:t,message:a})),this.name="HubApiError",this.status=t}}function ve(e){const t=e.replace(/\s+/g,"");if(!t)return 0;let a=0;return t.endsWith("==")?a=2:t.endsWith("=")&&(a=1),Math.floor(t.length*3/4)-a}function C(e,t){const a=e&&typeof e=="object"?e:{},l=a.share??a.deliverable??{},s=m=>a[m]??l[m],i=s("id")??s("shareId")??"",c=s("slug"),o=c!=null?String(c):void 0,d=s("url")??s("shareUrl");let b=null;d!=null?b=String(d):o&&t&&(b=`${t.replace(/\/+$/,"")}/deliverable/${encodeURIComponent(o)}`);const f=s("reason")??s("rejectNote"),p=s("localDeliverableId")??s("localId");return{id:String(i),slug:o,visibility:s("visibility")??"public",status:s("status")??"pending_review",url:b,reason:f!=null?String(f):null,localId:p!=null?String(p):null}}class ke{basePath;fetchImpl;hubOrigin;constructor(t){this.getHubToken=t.getHubToken,this.hubOrigin=t.hubUrl,this.basePath=(t.proxyBasePath??"/api/hub").replace(/\/+$/,""),this.fetchImpl=t.fetch??(globalThis.fetch?globalThis.fetch.bind(globalThis):(()=>{throw new Error("fetch unavailable")}))}getHubToken;isHubLoggedIn(){return!!this.getHubToken()}assertHubLoggedIn(){if(!this.getHubToken())throw new te}async doFetch(t,a){const l=this.getHubToken(),s={"Content-Type":"application/json",...a.headers};l&&(s.Authorization=`Bearer ${l}`);const i=await this.fetchImpl(`${this.basePath}${t}`,{...a,headers:s,credentials:"include"});let c=null;try{c=await i.json()}catch{c=null}if(!i.ok){const o=c&&typeof c=="object"&&"error"in c?String(c.error):i.statusText||`HTTP ${i.status}`;throw new ye(i.status,o)}return{status:i.status,data:c}}async publish(t){this.assertHubLoggedIn();const a=t.fileSizeBytes??(t.fileBase64?ve(t.fileBase64):0);if(a>J)throw new xe(a,J);const l={localDeliverableId:t.localId,visibility:t.visibility,title:t.title,summary:t.summary,tags:t.tags,filename:t.filename,format:t.format,producerAgent:{id:t.producerAgent.id,name:t.producerAgent.name,source:t.producerAgent.source}};t.content&&(l.content=t.content),t.fileBase64&&(l.fileBase64=t.fileBase64);const{data:s}=await this.doFetch("/deliverables/publish",{method:"POST",body:JSON.stringify(l)});return C(s,this.hubOrigin)}async pollStatus(t){this.assertHubLoggedIn();const{data:a}=await this.doFetch(`/deliverables/status?localId=${encodeURIComponent(t)}`,{method:"GET"});return C(a,this.hubOrigin)}async listMine(){this.assertHubLoggedIn();const{data:t}=await this.doFetch("/deliverables/mine",{method:"GET"}),a=t&&typeof t=="object"?t:{};return(Array.isArray(a.shares)?a.shares:[]).map(s=>C(s,this.hubOrigin))}async revoke(t){this.assertHubLoggedIn();const{data:a}=await this.doFetch("/deliverables/revoke",{method:"POST",body:JSON.stringify({localId:t})});return{...C(a,this.hubOrigin),status:"revoked",url:null}}}function je(e,t){return new ke({getHubToken:e,hubUrl:t,proxyBasePath:"/api/hub"})}const we=/\.(png|jpe?g|gif|webp|svg|bmp|avif|ico)$/i,Ne=/\.(mp4|webm|mp3|wav|ogg|m4a|mov|avi|mkv|flac)$/i;function Z(e){return we.test(e)?"image":Ne.test(e)?"media":"other"}function Se(e){return e.replace(/^file:\/\//i,"").replace(/^file:/i,"")}function q(e){const t=e.match(/!?\[[^\]]*\]\(([^)]+)\)/);if(t)return t[1].trim().split(/\s+(?="|')/)[0].trim()||null;const a=e.match(/(?:src|href|poster)\s*=\s*["']([^"']+)["']/i);return a?a[1]:null}function Y(e){return!e||/^(https?:|data:|mailto:|tel:|#)/i.test(e)||e.startsWith("//")?!1:(e.startsWith("/api/files/"),!0)}function Q(e,t){if(!e)return null;const a=e.trim(),l=a.match(/^\/api\/files\/(?:image|stream|preview)\?path=([^&]+)/i);if(l)try{return decodeURIComponent(l[1])||null}catch{return l[1]||null}return/^file:\/\//i.test(a)?Se(a).replace(/\\/g,"/"):/^[a-zA-Z]:[\\/]/.test(a)?a.replace(/\\/g,"/"):a.startsWith("/")?a:t&&(a.startsWith("./")||a.startsWith("../")||!a.includes("://"))?`${t.replace(/\\/g,"/").replace(/\/+$/,"")}/${a.replace(/^\.\//,"").replace(/\\/g,"/")}`:null}function Ve(e,t){const a=[],l=new Set,s=/!?\[[^\]]*\]\(([^)\s]+(?:\s+["'][^"']*["'])?)\)/g;for(const c of e.matchAll(s)){const o=c[0],d=q(o);if(!d||!Y(d))continue;const b=Q(d,t);!b||l.has(o)||(l.add(o),a.push({raw:o,localPath:b,kind:Z(b.split("?")[0])}))}const i=/<[a-zA-Z][^>]*(?:src|href|poster)\s*=\s*["'][^"']+["'][^>]*>/gi;for(const c of e.matchAll(i)){const o=c[0],d=q(o);if(!d||!Y(d))continue;const b=Q(d,t);!b||l.has(o)||(l.add(o),a.push({raw:o,localPath:b,kind:Z(b.split("?")[0])}))}return{refs:a,baseDir:t??""}}function Ie(e,t){let a=e;for(const[l,s]of t){const i=He(l,s);a=a.split(l).join(i)}return a}function He(e,t){const a=e.match(/^(!?\[[^\]]*\])\([^)]*\)$/);if(a)return`${a[1]}(${t})`;const l=e.match(/(src|href|poster)(\s*=\s*)(["'])[^"']*\3/i);return l?e.replace(/(src|href|poster)(\s*=\s*)(["'])[^"']*\3/i,`${l[1]}${l[2]}${l[3]}${t}${l[3]}`):t}function Le(e,t){return/^https?:\/\//i.test(e)?e:`${t.replace(/\/+$/,"")}${e.startsWith("/")?"":"/"}${e}`}function Te(e,t,a){const l=new Map,s=new Map(e.map(i=>[i.localPath,i]));for(const i of t){if(!i.key)continue;const c=s.get(i.key);!c||!i.url||l.set(c.raw,Le(i.url,a))}return l}async function Ce(e){try{const t=N.files.streamUrl(e),a=await fetch(t).then(d=>d.ok?d.blob():null);if(!a)return null;const l=await a.arrayBuffer(),s=new Uint8Array(l);let i="";const c=32768;for(let d=0;d<s.length;d+=c)i+=String.fromCharCode.apply(null,Array.from(s.subarray(d,d+c)));const o=e.split("/").pop()||"media";return{base64:btoa(i),filename:o}}catch{return null}}async function Ee(e,t){const a=new Map;if(e.length===0)return a;const l=[];for(const c of e){const o=await Ce(c.localPath);o&&l.push({key:c.localPath,filename:o.filename,base64:o.base64})}if(l.length===0)return a;const{files:s,errors:i}=await R.uploadMediaBatch(l);return i.length>0&&console.warn("[deliverable-share] media upload errors:",i),Te(e,s,t)}async function Ae(e,t,a){if(!e||t==="directory"||e.startsWith("http://")||e.startsWith("https://"))return{};try{const l=await N.files.preview(e);if((l.type==="text"||l.type==="markdown"||l.type==="html"||l.type==="json"||l.type==="csv")&&typeof l.content=="string"){if(!(l.type==="markdown"||l.type==="html"))return{content:l.content};const i=e.replace(/[/\\]/g,"/").split("/").slice(0,-1).join("/"),{refs:c}=Ve(l.content,i);if(c.length===0)return{content:l.content};const o=await Ee(c,a);return o.size===0?{content:l.content}:{content:Ie(l.content,o),uploadedMedia:o.size}}if(l.type==="image"||l.type==="audio"||l.type==="video"||l.type==="binary"){const s=l.streamUrl||(l.path?N.files.streamUrl(l.path):N.files.streamUrl(e)),c=await(await fetch(s).then(f=>f.blob())).arrayBuffer(),o=new Uint8Array(c);let d="";const b=32768;for(let f=0;f<o.length;f+=b)d+=String.fromCharCode.apply(null,Array.from(o.subarray(f,f+b)));return{fileBase64:btoa(d)}}return{}}catch{return{}}}function Be({item:e,onClose:t,onShared:a,service:l}){const{t:s}=fe(["deliverables","common"]),i=u.useMemo(()=>l??je(be,R.getUrl()),[l]),[c,o]=u.useState(()=>i?i.isHubLoggedIn():null),[d,b]=u.useState(!1),[f,p]=u.useState(()=>{const n=e.shareStatus;return n==="published"?"published":n==="pending_review"?"pending_review":n==="rejected"?"rejected":"form"}),[m,P]=u.useState("public"),[V,re]=u.useState(e.title||""),[E,se]=u.useState(e.summary||""),[x,A]=u.useState(Array.isArray(e.tags)?[...e.tags]:[]),[k,U]=u.useState(""),[$,ae]=u.useState(null),[I,F]=u.useState(!1),[H,g]=u.useState(null),D=u.useRef(a);D.current=a;const y=u.useCallback(n=>{ae(n);const h=n.status;p(h==="published"?"published":h==="rejected"?"rejected":h==="revoked"?"revoked":h==="pending_review"?"pending_review":"form"),D.current?.(n)},[]);u.useEffect(()=>{o(i.isHubLoggedIn())},[i]);const le=u.useCallback(async()=>{b(!0),g(null);try{await he({force:!0}),o(i.isHubLoggedIn())}catch{o(i.isHubLoggedIn())}finally{b(!1)}},[i]),B=u.useCallback(()=>{const n=k.trim().replace(/^#/,"");n&&!x.includes(n)&&A(h=>[...h,n]),U("")},[k,x]),ne=u.useCallback(n=>{A(h=>h.filter(v=>v!==n))},[]),ie=u.useCallback(n=>{n.key==="Enter"||n.key===","?(n.preventDefault(),B()):n.key==="Backspace"&&!k&&x.length&&A(h=>h.slice(0,-1))},[B,k,x.length]),_=u.useCallback(()=>{const n=$?.url??e.shareUrl;n&&navigator.clipboard?.writeText(n).then(()=>{F(!0),setTimeout(()=>F(!1),1500)}).catch(()=>{})},[$,e.shareUrl]),oe=u.useCallback(async()=>{if(!ge(e.format)){g(s("deliverables:share.formatUnsupported",{formats:[...ee].join(" / ")}));return}g(null),p("busy");try{const n=e.reference.replace(/[/\\]/g,"/").split("/").pop()||"deliverable",h=R.getUrl(),{content:v,fileBase64:ce,uploadedMedia:K}=await Ae(e.reference,e.type,h);K&&console.info(`[deliverable-share] uploaded ${K} local media reference(s) to Hub`);const j=e.agentId??"";let G=j;if(j)try{const{agents:de}=await N.agents.list({lean:!0}),X=de.find(ue=>ue.id===j);X&&(G=X.name||j)}catch{}const w=await i.publish({localId:e.id,title:V.trim()||e.title,summary:E.trim(),tags:x,visibility:m,filename:n,format:e.format||"markdown",content:v,fileBase64:ce,producerAgent:{id:j,name:G,source:"local"}});y(w),w.status==="rejected"?g(typeof w.reason=="string"&&w.reason?w.reason:s("deliverables:share.rejectedFallback")):t()}catch(n){if(p("form"),n instanceof te){o(!1);return}g(n instanceof S||n instanceof Error?n.message:String(n))}},[i,e,V,E,x,m,y,s]),W=u.useCallback(async()=>{g(null);try{const n=await i.revoke(e.id);y({...n,status:"revoked",url:null})}catch(n){g(n instanceof S?n.message:String(n))}},[i,e.id,y]),z=u.useCallback(()=>{p("form"),g(null)},[]);u.useEffect(()=>{if(f!=="pending_review")return;let n=!1;const h=setInterval(async()=>{try{const v=await i.pollStatus(e.id);if(n)return;v.status!=="pending_review"&&y(v)}catch{}},8e3);return()=>{n=!0,clearInterval(h)}},[f,i,e.id,y]),u.useEffect(()=>{const n=h=>{h.key==="Escape"&&t()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[t]);const L=m==="link",T=$?.url??e.shareUrl,O=r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:t,children:[r.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),r.jsxs("div",{className:"relative bg-surface-primary rounded-2xl shadow-2xl border border-border-default w-full max-w-md max-h-[85vh] overflow-y-auto",onClick:n=>n.stopPropagation(),children:[r.jsxs("div",{className:"sticky top-0 bg-surface-primary/95 backdrop-blur-sm border-b border-border-default px-5 py-4 flex items-center justify-between rounded-t-2xl z-10",children:[r.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:s("deliverables:share.title",{defaultValue:"分享到 Markus Hub"})}),r.jsx("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary hover:text-fg-primary",children:r.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),r.jsx("div",{className:"px-5 py-4 space-y-4",children:c===!1?r.jsxs("div",{className:"space-y-4 py-2",children:[r.jsxs("div",{className:"flex items-start gap-3 rounded-xl bg-amber-500/10 border border-amber-500/25 p-3",children:[r.jsx("span",{className:"text-lg",children:"🔑"}),r.jsx("p",{className:"text-sm text-fg-secondary",children:s("deliverables:share.needHubLogin",{defaultValue:"需登录 Markus Hub 账号后才能分享产出物。"})})]}),r.jsx("button",{onClick:()=>{le()},disabled:d,className:"w-full px-3 py-2 text-sm font-medium rounded-lg bg-brand-600 text-on-brand hover:bg-brand-500 transition-colors disabled:opacity-60",children:d?s("deliverables:share.loggingIn",{defaultValue:"正在打开登录…"}):s("deliverables:share.loginHub",{defaultValue:"登录 Markus Hub 账号"})}),r.jsx("p",{className:"text-[11px] text-fg-tertiary",children:s("deliverables:share.loginHint",{defaultValue:"解锁后将支持一键公开/链接分享产出物。"})})]}):r.jsx(r.Fragment,{children:f==="published"?r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"px-2 py-0.5 text-[11px] rounded-full bg-green-500/15 text-green-500 font-medium",children:s("deliverables:share.published",{defaultValue:"已发布"})}),r.jsx("span",{className:"text-[11px] text-fg-tertiary",children:m==="link"?s("deliverables:share.linkVisibility",{defaultValue:"有链接可见"}):s("deliverables:share.publicVisibility",{defaultValue:"公开"})})]}),T?r.jsxs("div",{className:"flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[r.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all flex-1 select-all",children:T}),r.jsx("button",{onClick:_,className:`px-2 py-1 text-[10px] rounded transition-colors shrink-0 ${I?"bg-green-500/20 text-green-500":"bg-brand-600/20 text-brand-500 hover:bg-brand-600/30"}`,children:I?s("common:copied",{defaultValue:"已复制"}):s("common:copy",{defaultValue:"复制链接"})})]}):r.jsx("p",{className:"text-xs text-fg-tertiary",children:s("deliverables:share.urlPending",{defaultValue:"链接生成中,稍后刷新查看…"})}),r.jsx("button",{onClick:()=>{W()},className:"w-full px-3 py-2 text-xs font-medium rounded-lg text-red-500 border border-red-500/30 hover:bg-red-500/10 transition-colors",children:s("deliverables:share.revoke",{defaultValue:"取消分享"})})]}):f==="pending_review"?r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-amber-500 animate-pulse"}),r.jsx("span",{className:"px-2 py-0.5 text-[11px] rounded-full bg-amber-500/15 text-amber-500 font-medium",children:s("deliverables:share.pendingReview",{defaultValue:"审核中"})}),r.jsx("span",{className:"text-[11px] text-fg-tertiary",children:m==="link"?s("deliverables:share.linkVisibility",{defaultValue:"有链接可见"}):s("deliverables:share.publicVisibility",{defaultValue:"公开"})})]}),r.jsx("p",{className:"text-sm text-fg-secondary",children:s("deliverables:share.pendingHint",{defaultValue:"你的产出物已公开,其他人现在就能通过链接访问。管理员审核通过后,内容将进入搜索引擎收录。"})}),T?r.jsxs("div",{className:"flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[r.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all flex-1 select-all",children:T}),r.jsx("button",{onClick:_,className:`px-2 py-1 text-[10px] rounded transition-colors shrink-0 ${I?"bg-green-500/20 text-green-500":"bg-brand-600/20 text-brand-500 hover:bg-brand-600/30"}`,children:I?s("common:copied",{defaultValue:"已复制"}):s("common:copy",{defaultValue:"复制链接"})})]}):null,r.jsx("button",{onClick:()=>{W()},className:"w-full px-3 py-2 text-xs font-medium rounded-lg text-red-500 border border-red-500/30 hover:bg-red-500/10 transition-colors",children:s("deliverables:share.revoke",{defaultValue:"取消分享"})})]}):f==="rejected"?r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"flex items-center gap-2",children:r.jsx("span",{className:"px-2 py-0.5 text-[11px] rounded-full bg-red-500/15 text-red-500 font-medium",children:s("deliverables:share.rejected",{defaultValue:"已拒绝"})})}),H&&r.jsx("div",{className:"rounded-lg bg-red-500/10 border border-red-500/25 px-3 py-2 text-xs text-red-500",children:H}),r.jsx("button",{onClick:z,className:"w-full px-3 py-2 text-sm font-medium rounded-lg bg-brand-600 text-on-brand hover:bg-brand-500 transition-colors",children:s("deliverables:share.resubmit",{defaultValue:"重新提交"})})]}):f==="revoked"?r.jsxs("div",{className:"space-y-3",children:[r.jsx("p",{className:"text-sm text-fg-secondary",children:s("deliverables:share.revoked",{defaultValue:"已取消分享,该产出物不再公开可访问。"})}),r.jsx("button",{onClick:z,className:"w-full px-3 py-2 text-sm font-medium rounded-lg bg-brand-600 text-on-brand hover:bg-brand-500 transition-colors",children:s("deliverables:share.shareAgain",{defaultValue:"重新分享"})})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:s("deliverables:share.visibility",{defaultValue:"可见性"})}),r.jsxs("label",{className:`flex items-start gap-3 rounded-xl border p-3 cursor-pointer transition-colors ${L?"border-border-default hover:bg-surface-elevated":"border-brand-500/50 bg-brand-500/5"}`,children:[r.jsx("input",{type:"radio",name:"visibility",checked:!L,onChange:()=>P("public"),className:"mt-0.5 accent-brand-500"}),r.jsxs("span",{className:"space-y-0.5",children:[r.jsx("span",{className:"block text-sm font-medium text-fg-primary",children:s("deliverables:share.public",{defaultValue:"公开(所有人可见 + 搜索引擎)"})}),r.jsx("span",{className:"block text-[11px] text-fg-tertiary",children:s("deliverables:share.publicHint",{defaultValue:"公开产出物需经 Hub 审核后发布,发布后所有人可见并参与搜索"})})]})]}),r.jsxs("label",{className:`flex items-start gap-3 rounded-xl border p-3 cursor-pointer transition-colors ${L?"border-brand-500/50 bg-brand-500/5":"border-border-default hover:bg-surface-elevated"}`,children:[r.jsx("input",{type:"radio",name:"visibility",checked:L,onChange:()=>P("link"),className:"mt-0.5 accent-brand-500"}),r.jsxs("span",{className:"space-y-0.5",children:[r.jsx("span",{className:"block text-sm font-medium text-fg-primary",children:s("deliverables:share.link",{defaultValue:"有链接可见"})}),r.jsx("span",{className:"block text-[11px] text-fg-tertiary",children:s("deliverables:share.linkHint",{defaultValue:"仅获得链接的人可查看,不参与搜索引擎;同样需经 Hub 审核"})})]})]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:s("deliverables:share.titleField",{defaultValue:"标题"})}),r.jsx("input",{value:V,onChange:n=>re(n.target.value),placeholder:s("deliverables:share.titlePlaceholder",{defaultValue:"清晰、可检索的标题"}),className:"w-full px-3 py-2 text-sm rounded-lg bg-surface-elevated border border-border-default focus:border-brand-500/60 outline-none"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:s("deliverables:share.summary",{defaultValue:"摘要"})}),r.jsx("textarea",{value:E,onChange:n=>se(n.target.value),rows:3,placeholder:s("deliverables:share.summaryPlaceholder",{defaultValue:"简要描述该产出物…"}),className:"w-full px-3 py-2 text-sm rounded-lg bg-surface-elevated border border-border-default focus:border-brand-500/60 outline-none resize-y"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:s("deliverables:share.tags",{defaultValue:"标签"})}),r.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5",children:x.map(n=>r.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-[11px] bg-surface-elevated rounded-md text-fg-secondary",children:[n,r.jsx("button",{onClick:()=>ne(n),className:"text-fg-tertiary hover:text-red-500","aria-label":s("remove"),children:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},n))}),r.jsx("input",{value:k,onChange:n=>U(n.target.value),onKeyDown:ie,onBlur:B,placeholder:s("deliverables:share.tagsPlaceholder",{defaultValue:"输入标签后回车添加"}),className:"w-full px-3 py-2 text-sm rounded-lg bg-surface-elevated border border-border-default focus:border-brand-500/60 outline-none"})]}),H&&r.jsx("div",{className:"rounded-lg bg-red-500/10 border border-red-500/25 px-3 py-2 text-xs text-red-500",children:H}),r.jsxs("button",{type:"button",onClick:()=>{oe()},disabled:f==="busy"||!V.trim(),className:"w-full px-3 py-2.5 text-sm font-medium rounded-lg bg-brand-600 text-on-brand hover:bg-brand-500 transition-colors disabled:opacity-60 flex items-center justify-center gap-2",children:[f==="busy"&&r.jsxs("svg",{className:"animate-spin",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",opacity:"0.25"}),r.jsx("path",{d:"M22 12a10 10 0 0 0-10-10",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]}),f==="busy"?s("deliverables:share.sharing",{defaultValue:"分享中…"}):s("deliverables:share.shareToHub",{defaultValue:"分享到 Hub"})]})]})})})]})]});return typeof document<"u"?pe.createPortal(O,document.body):O}export{Be as D,ge as a,je as c};