forge-openclaw-plugin 0.3.16 → 0.3.17

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 (186) hide show
  1. package/dist/assets/{action-bar-DgrmzFrI.js → action-bar-D3CEYlj4.js} +1 -1
  2. package/dist/assets/{activity-page-CF451ueg.js → activity-page-Ce1pHIu5.js} +1 -1
  3. package/dist/assets/{ai-surface-workspace-DtwybxJB.js → ai-surface-workspace-DEliwOjF.js} +1 -1
  4. package/dist/assets/artifacts-page-BgyFVIVM.js +2 -0
  5. package/dist/assets/{atlas-panel-CB3uYk_K.js → atlas-panel-VZOnJa1c.js} +1 -1
  6. package/dist/assets/{board-CuxQRKPJ.js → board-DprRipIG.js} +1 -1
  7. package/dist/assets/{calendar-page-BYsDuLnh.js → calendar-page-Zstsn4uG.js} +1 -1
  8. package/dist/assets/{calendar-rules-DXuOv2J-.js → calendar-rules-BGIBuEDk.js} +1 -1
  9. package/dist/assets/{calendar-week-toolbar-8PJmiUE_.js → calendar-week-toolbar-DXFkMkbq.js} +1 -1
  10. package/dist/assets/{charts-BzT4pUPg.js → charts-C5S0-BL7.js} +1 -1
  11. package/dist/assets/{companion-sync-lab-page-DzWNOaBh.js → companion-sync-lab-page-DIPPLFKt.js} +1 -1
  12. package/dist/assets/{daily-metrics-dashboard-CHcYxDhs.js → daily-metrics-dashboard-CG-OOCJz.js} +1 -1
  13. package/dist/assets/{define-workbench-box-DcI0_QKW.js → define-workbench-box-BEEdtBkQ.js} +1 -1
  14. package/dist/assets/{entity-link-multiselect-C--AiCMb.js → entity-link-multiselect-BfDAROHB.js} +1 -1
  15. package/dist/assets/{entity-note-count-link-xne6mshj.js → entity-note-count-link-BGOiaash.js} +1 -1
  16. package/dist/assets/{entity-notes-surface-jy6Psist.js → entity-notes-surface-DPsJwqQa.js} +1 -1
  17. package/dist/assets/execution-board-Dg-2GSKv.js +1 -0
  18. package/dist/assets/{faceted-token-search-BMQ1Wwzt.js → faceted-token-search-DV7MSVYb.js} +1 -1
  19. package/dist/assets/{flagship-signal-deck-DjcskRwF.js → flagship-signal-deck-D3wVL3bC.js} +1 -1
  20. package/dist/assets/{floating-action-menu-cGhbJ2tc.js → floating-action-menu-BUs382px.js} +1 -1
  21. package/dist/assets/{forms-D1qJ3oOP.js → forms-ByKjodjN.js} +1 -1
  22. package/dist/assets/{generic-node-view-DNVwfqqq.js → generic-node-view-BY5dbPXJ.js} +1 -1
  23. package/dist/assets/{goal-detail-page-dAbyCilO.js → goal-detail-page-MYr6j2B4.js} +1 -1
  24. package/dist/assets/{goal-dialog-DH50D0tP.js → goal-dialog-nkdME5Uy.js} +1 -1
  25. package/dist/assets/goals-page-BsFeBzU1.js +1 -0
  26. package/dist/assets/{graph-BF4IsheG.js → graph-CHVj0Z7n.js} +1 -1
  27. package/dist/assets/habits-page-wO461EVU.js +1 -0
  28. package/dist/assets/{health-boxes-BPTgGM6G.js → health-boxes-BphMeSJj.js} +1 -1
  29. package/dist/assets/index-CSd8ylsy.css +1 -0
  30. package/dist/assets/index-gmPaoLN-.js +2 -0
  31. package/dist/assets/{inline-note-fields-D4mCM1gO.js → inline-note-fields-BvQwmMAv.js} +1 -1
  32. package/dist/assets/{insight-flow-dialog-Btp6bkbV.js → insight-flow-dialog-H_eaOmst.js} +1 -1
  33. package/dist/assets/{insights-page-1qM4mxjS.js → insights-page-DINYe3cB.js} +3 -3
  34. package/dist/assets/{kanban-boxes-u_A-UJG-.js → kanban-boxes-oACOTDYG.js} +1 -1
  35. package/dist/assets/{kanban-page-CKCa_3Qb.js → kanban-page-BGLXH91f.js} +1 -1
  36. package/dist/assets/knowledge-graph-page-VfMvw5jL.js +1 -0
  37. package/dist/assets/{life-force-page-BZlyA144.js → life-force-page-DQPb6UL-.js} +1 -1
  38. package/dist/assets/{life-force-workspace-CtAWZXNw.js → life-force-workspace-BJ1aI3JE.js} +1 -1
  39. package/dist/assets/{maps-BTVHALP8.js → maps-CvEHVkBk.js} +1 -1
  40. package/dist/assets/{metric-tile-Bkx2btO2.js → metric-tile-CbEe19Gd.js} +1 -1
  41. package/dist/assets/{motion-DcgUnXhY.js → motion-BibSzp57.js} +1 -1
  42. package/dist/assets/{movement-boxes-QZ2EIS9q.js → movement-boxes-dtDYhw5c.js} +1 -1
  43. package/dist/assets/{movement-page-B-3ihggI.js → movement-page-BhmwCHjs.js} +1 -1
  44. package/dist/assets/{note-markdown-BWedRE3c.js → note-markdown-CG8u2d6p.js} +1 -1
  45. package/dist/assets/{note-tags-input-DZkCqI1w.js → note-tags-input-D_conqDO.js} +1 -1
  46. package/dist/assets/{notes-boxes-DGFmt7Dp.js → notes-boxes-BLKucFqW.js} +1 -1
  47. package/dist/assets/notes-page-CafVxWjb.js +1 -0
  48. package/dist/assets/{open-in-graph-button-CjvkEj1P.js → open-in-graph-button-DFQ4r6SN.js} +1 -1
  49. package/dist/assets/{orbit-map-CRHSPenk.js → orbit-map-DsEl3ori.js} +1 -1
  50. package/dist/assets/overview-page-BffcX-pM.js +1 -0
  51. package/dist/assets/page-hero-U603l9rQ.js +1 -0
  52. package/dist/assets/pill-cluster-BYVFNppV.js +1 -0
  53. package/dist/assets/{preference-entity-handoff-button-CfCQl3cW.js → preference-entity-handoff-button-cPrTpHsV.js} +1 -1
  54. package/dist/assets/{preferences-page-OltGdsQ2.js → preferences-page-DQjFIOmt.js} +1 -1
  55. package/dist/assets/{project-collections-FfBIVwXu.js → project-collections-B9OGHGqm.js} +1 -1
  56. package/dist/assets/project-detail-page-r1Sw2kcO.js +1 -0
  57. package/dist/assets/{project-dialog-B_J1ESMk.js → project-dialog-B2_PcXAf.js} +1 -1
  58. package/dist/assets/project-management-hierarchy-page-qLNG8hsh.js +1 -0
  59. package/dist/assets/{project-management-section-nav-DBNHt9p5.js → project-management-section-nav-DFUlmMEB.js} +1 -1
  60. package/dist/assets/{projects-boxes-BvlVsO5q.js → projects-boxes-BA7_XaqX.js} +1 -1
  61. package/dist/assets/projects-page-B6ggXWFw.js +1 -0
  62. package/dist/assets/psyche-behaviors-page-ByWpXlLq.js +5 -0
  63. package/dist/assets/{psyche-flashcards-page-05606-97.js → psyche-flashcards-page-B9nSc0mk.js} +1 -1
  64. package/dist/assets/{psyche-goal-map-page-Cw-aqS3Y.js → psyche-goal-map-page-BQU7qI88.js} +1 -1
  65. package/dist/assets/{psyche-graph-0E22QHPe.js → psyche-graph-DCeP7r2b.js} +1 -1
  66. package/dist/assets/{psyche-metrics-page-DBFVPeMa.js → psyche-metrics-page-DD2lOP-J.js} +1 -1
  67. package/dist/assets/psyche-mode-guide-page-DbtZgnjr.js +1 -0
  68. package/dist/assets/psyche-modes-page-3zFJWFQf.js +1 -0
  69. package/dist/assets/psyche-page-D5vXYkfB.js +1 -0
  70. package/dist/assets/psyche-patterns-page-BneAAeKS.js +5 -0
  71. package/dist/assets/{psyche-questionnaire-builder-page-DEt0UDsz.js → psyche-questionnaire-builder-page-BH1la5C9.js} +1 -1
  72. package/dist/assets/{psyche-questionnaire-detail-page-BXQbOE6A.js → psyche-questionnaire-detail-page-DYav634P.js} +1 -1
  73. package/dist/assets/psyche-questionnaire-run-detail-page-9VaijhJm.js +1 -0
  74. package/dist/assets/{psyche-questionnaire-run-page-D_EokOQm.js → psyche-questionnaire-run-page-e1T6k_dS.js} +1 -1
  75. package/dist/assets/{psyche-questionnaires-page-D1Ov2L4n.js → psyche-questionnaires-page-Dyv367z9.js} +1 -1
  76. package/dist/assets/{psyche-report-detail-page-9HyPr8BJ.js → psyche-report-detail-page-hqxHIXw2.js} +3 -3
  77. package/dist/assets/psyche-reports-page-DhIfcGbt.js +1 -0
  78. package/dist/assets/{psyche-schemas-DDol0j-g.js → psyche-schemas-Cg51Ztxz.js} +1 -1
  79. package/dist/assets/psyche-schemas-beliefs-page-Dgb5o9vx.js +9 -0
  80. package/dist/assets/{psyche-screen-time-page-DJMDR5oo.js → psyche-screen-time-page-D6MnJGNa.js} +1 -1
  81. package/dist/assets/{psyche-self-observation-page-DFKXG1Yv.js → psyche-self-observation-page-C1Vyezbv.js} +1 -1
  82. package/dist/assets/{psyche-values-page-TWKth89J.js → psyche-values-page-B_JWVw1Q.js} +2 -2
  83. package/dist/assets/{question-flow-dialog-D-_EvoAt.js → question-flow-dialog-yMYVk998.js} +2 -2
  84. package/dist/assets/{report-chain-fields-Dy-jBQDn.js → report-chain-fields-D4NM9a6I.js} +1 -1
  85. package/dist/assets/rewards-page-B5-bcL4R.js +1 -0
  86. package/dist/assets/{scheduling-rules-editor-CAd290IE.js → scheduling-rules-editor-De72IUax.js} +1 -1
  87. package/dist/assets/{schema-badge-BLaVI1D7.js → schema-badge-jX28kUa6.js} +1 -1
  88. package/dist/assets/{schemas-B0Pa-V-A.js → schemas-BlFy-uPR.js} +1 -1
  89. package/dist/assets/{select-menu-DcS4Ukjf.js → select-menu-BXv1rsVc.js} +1 -1
  90. package/dist/assets/{settings-agents-page-Bt38HhEJ.js → settings-agents-page-DN_np10S.js} +1 -1
  91. package/dist/assets/settings-bin-page-BM5BpK_i.js +1 -0
  92. package/dist/assets/{settings-calendar-page-DPSSZV3s.js → settings-calendar-page-Cg0gSSFs.js} +3 -3
  93. package/dist/assets/{settings-data-page-BdHsD1C_.js → settings-data-page-Dwmp2rLy.js} +1 -1
  94. package/dist/assets/{settings-logs-page-D9OnWoFq.js → settings-logs-page-DQNM21Re.js} +1 -1
  95. package/dist/assets/{settings-mobile-page-DFpsXA4M.js → settings-mobile-page-DQdiRa-a.js} +1 -1
  96. package/dist/assets/settings-models-page-CAEPpuHF.js +1 -0
  97. package/dist/assets/{settings-page-m_3iYPwU.js → settings-page-Cl2KiCFg.js} +1 -1
  98. package/dist/assets/{settings-rewards-page-B2aBm-dA.js → settings-rewards-page-DoIUumhe.js} +1 -1
  99. package/dist/assets/{settings-section-nav-CMeU19Rx.js → settings-section-nav-D_N87IG0.js} +1 -1
  100. package/dist/assets/{settings-users-page-D8jyewJl.js → settings-users-page-CPesR62N.js} +1 -1
  101. package/dist/assets/{settings-wiki-page-DjOgQJAh.js → settings-wiki-page-BxMQM5Vi.js} +1 -1
  102. package/dist/assets/{sleep-page-D8-dA4bE.js → sleep-page-DUYmQKrg.js} +1 -1
  103. package/dist/assets/{sports-page-CK3PgPKB.js → sports-page-Bzi5TF9T.js} +1 -1
  104. package/dist/assets/{state-Bpe5dF3T.js → state-BFyKSULP.js} +1 -1
  105. package/dist/assets/{strategies-page-aFpJath-.js → strategies-page-C-T2MZx4.js} +1 -1
  106. package/dist/assets/{strategy-detail-page-CobF5qLv.js → strategy-detail-page-3tYuSZu-.js} +1 -1
  107. package/dist/assets/{strategy-dialog-Fgoaoob5.js → strategy-dialog-BWm4slo4.js} +1 -1
  108. package/dist/assets/{surface-D0dqgX-k.js → surface-BJObZeRw.js} +1 -1
  109. package/dist/assets/{table-U7otr5go.js → table-CTLroJKN.js} +1 -1
  110. package/dist/assets/task-detail-page-ZZOXSpSF.js +1 -0
  111. package/dist/assets/{task-dialog-eCDTF8xe.js → task-dialog-2wy0xI7f.js} +5 -5
  112. package/dist/assets/timebox-planning-dialog-C6h0Hp71.js +1 -0
  113. package/dist/assets/{today-boxes-CYfskVrM.js → today-boxes-B_TdgSDz.js} +1 -1
  114. package/dist/assets/today-page-Dipns9tl.js +1 -0
  115. package/dist/assets/training-load-page-B78e1-o-.js +1 -0
  116. package/dist/assets/{ui-B9TWEtCx.js → ui-uo_bNP7c.js} +1 -1
  117. package/dist/assets/{use-anchored-overlay-position-BY4kNzPj.js → use-anchored-overlay-position-BSxFX6Hi.js} +1 -1
  118. package/dist/assets/{use-psyche-focus-target-BhNedCZB.js → use-psyche-focus-target-1GLkhYiv.js} +1 -1
  119. package/dist/assets/{user-badge-MEZuJiir.js → user-badge-C4eZu1e_.js} +1 -1
  120. package/dist/assets/{user-select-field-fx129Uh6.js → user-select-field-CmKwcbZt.js} +1 -1
  121. package/dist/assets/{utility-widgets-h5eG2jvc.js → utility-widgets-B06wQFrd.js} +2 -2
  122. package/dist/assets/{vendor-BwL6m4SE.js → vendor-B7FKSwHK.js} +222 -212
  123. package/dist/assets/{vitals-page-eoFnQ3XL.js → vitals-page-BC7QFsm2.js} +1 -1
  124. package/dist/assets/{weekly-review-page-C7BU1gkK.js → weekly-review-page-BjNsNoWj.js} +1 -1
  125. package/dist/assets/{weight-loss-page-Cc7Do3XY.js → weight-loss-page-BOahGY9r.js} +1 -1
  126. package/dist/assets/{wiki-article-markdown-CCKoSptz.js → wiki-article-markdown-DO47HnZf.js} +2 -2
  127. package/dist/assets/{wiki-editor-page-BpbxZrgz.js → wiki-editor-page-OWRUHl4O.js} +5 -5
  128. package/dist/assets/{wiki-ingest-history-page-D5Wfr8pc.js → wiki-ingest-history-page-CuHpg2lZ.js} +1 -1
  129. package/dist/assets/{wiki-ingest-modal-DhRVsEwC.js → wiki-ingest-modal-EZ3kX-vA.js} +1 -1
  130. package/dist/assets/wiki-page-BPV3HIgu.js +1 -0
  131. package/dist/assets/{workbench-flow-page-y9FxDbKO.js → workbench-flow-page-C53KueEz.js} +3 -3
  132. package/dist/assets/{workbench-page-Da16AZvN.js → workbench-page-DJ7nT2JQ.js} +1 -1
  133. package/dist/assets/workout-detail-page-Dhyu0q7o.js +2 -0
  134. package/dist/index.html +8 -8
  135. package/dist/openclaw/parity.d.ts +1 -1
  136. package/dist/openclaw/parity.js +10 -0
  137. package/dist/openclaw/routes.js +78 -0
  138. package/dist/openclaw/tools.js +42 -0
  139. package/dist/server/apps/api/migrations/072_artifact_store.sql +106 -0
  140. package/dist/server/apps/api/src/app.js +364 -3
  141. package/dist/server/apps/api/src/openapi.js +570 -1
  142. package/dist/server/apps/api/src/repositories/entity-links.js +66 -0
  143. package/dist/server/apps/api/src/services/artifacts.js +1059 -0
  144. package/dist/server/apps/api/src/services/entity-crud.js +22 -0
  145. package/dist/server/apps/api/src/services/knowledge-graph.js +45 -0
  146. package/dist/server/apps/api/src/services/psyche-observation-calendar.js +1 -0
  147. package/dist/server/apps/api/src/types.js +2 -0
  148. package/dist/server/apps/web/src/lib/api.js +69 -0
  149. package/dist/server/apps/web/src/lib/entity-visuals.js +10 -1
  150. package/dist/server/apps/web/src/lib/knowledge-graph-types.js +9 -0
  151. package/openclaw.plugin.json +2 -1
  152. package/package.json +1 -1
  153. package/server/migrations/072_artifact_store.sql +106 -0
  154. package/skills/forge-openclaw/SKILL.md +57 -4
  155. package/skills/forge-openclaw/entity_conversation_playbooks.md +212 -14
  156. package/skills/forge-openclaw/psyche_entity_playbooks.md +20 -0
  157. package/dist/assets/execution-board-BSUZCIIx.js +0 -1
  158. package/dist/assets/goals-page-DkMy9mPD.js +0 -1
  159. package/dist/assets/habits-page-CCQR8rg6.js +0 -1
  160. package/dist/assets/index-VzCGTBS_.css +0 -1
  161. package/dist/assets/index-izRKx6JK.js +0 -2
  162. package/dist/assets/knowledge-graph-page-BZOxRv19.js +0 -1
  163. package/dist/assets/notes-page-DYkn04tz.js +0 -1
  164. package/dist/assets/overview-page-D6LsjPWe.js +0 -1
  165. package/dist/assets/page-hero-BLhM8FF3.js +0 -1
  166. package/dist/assets/pill-cluster-B5bYs_e2.js +0 -1
  167. package/dist/assets/project-detail-page-CCm3iZPQ.js +0 -1
  168. package/dist/assets/project-management-hierarchy-page-BNzvtNZj.js +0 -1
  169. package/dist/assets/projects-page-BUf7KV-_.js +0 -1
  170. package/dist/assets/psyche-behaviors-page-jtyhdpJ1.js +0 -5
  171. package/dist/assets/psyche-mode-guide-page-DI-LNEDT.js +0 -1
  172. package/dist/assets/psyche-modes-page-CaMupyfi.js +0 -1
  173. package/dist/assets/psyche-page-CFBq0YKf.js +0 -1
  174. package/dist/assets/psyche-patterns-page-sp4ikoef.js +0 -5
  175. package/dist/assets/psyche-questionnaire-run-detail-page-Cd3ClsSK.js +0 -1
  176. package/dist/assets/psyche-reports-page-BeyJg5fb.js +0 -1
  177. package/dist/assets/psyche-schemas-beliefs-page-DNmf-Vma.js +0 -9
  178. package/dist/assets/rewards-page-D3ymEd2X.js +0 -1
  179. package/dist/assets/settings-bin-page-DqyVI1i1.js +0 -1
  180. package/dist/assets/settings-models-page-DaFXLp-O.js +0 -1
  181. package/dist/assets/task-detail-page-CDK79bzk.js +0 -1
  182. package/dist/assets/timebox-planning-dialog-CNZIGSpd.js +0 -1
  183. package/dist/assets/today-page-Bnh8wopq.js +0 -1
  184. package/dist/assets/training-load-page-C7lq-jqy.js +0 -1
  185. package/dist/assets/wiki-page-1vf-HErs.js +0 -1
  186. package/dist/assets/workout-detail-page-Cq0YamXF.js +0 -2
@@ -1 +1 @@
1
- import{j as e,by as gt,c1 as ht,b7 as ye,bX as We,r as p,c5 as xt}from"./vendor-BwL6m4SE.js";import{b as ft,C as vt,u as bt,a as yt,P as jt,D as It,c as Nt,S as wt,v as kt,d as St}from"./board-CuxQRKPJ.js";import{F as T,a as Ue,Q as Ct}from"./question-flow-dialog-D-_EvoAt.js";import{k as G,b as R,B as Q,I as X,T as ue,c as ce,P as Mt,E as Re,a7 as Tt}from"./index-izRKx6JK.js";import{U as H}from"./user-badge-MEZuJiir.js";import{U as Pt}from"./user-select-field-fx129Uh6.js";import{d as ae,b as Et,a as Gt}from"./user-ownership-DJGl4rAj.js";function Xe(s){return[{id:"title",label:"Strategy title is set",satisfied:s.title.trim().length>0},{id:"graph",label:"Graph contains at least one linked project or task",satisfied:s.graph.nodes.length>0},{id:"targets",label:"At least one target goal or project is selected",satisfied:s.targetGoalIds.length>0||s.targetProjectIds.length>0},{id:"narrative",label:"The plan already names an overview or end state",satisfied:s.overview.trim().length>0||s.endStateDescription.trim().length>0}]}function $t(s){return Xe(s).every(d=>d.satisfied)}function qt(s){return[{id:"coverage",label:"Agreed work moving",value:s.planCoverageScore,detail:`${s.startedNodeCount}/${s.totalNodeCount} agreed steps have started or finished.`},{id:"order",label:"Order respected",value:s.sequencingScore,detail:`${s.outOfOrderNodeIds.length} step${s.outOfOrderNodeIds.length===1?"":"s"} started before prerequisites were complete.`},{id:"scope",label:"Scope held",value:s.scopeDisciplineScore,detail:`${s.offPlanEntityCount} unagreed item${s.offPlanEntityCount===1?"":"s"} are inside the strategy scope, ${s.offPlanActiveEntityCount} still active.`},{id:"satisfaction",label:"End-state satisfaction",value:s.qualityScore,detail:`${s.targetProgressScore}% target progress with ${s.blockedNodeIds.length} blocked step${s.blockedNodeIds.length===1?"":"s"}.`}]}function Dt(s){return s.trim().toLowerCase()}function ee(s,d){return s.includes(d)?s.filter(n=>n!==d):[...s,d]}function Ye(s,d){return s.some(n=>n.entityType===d.entityType&&n.entityId===d.entityId)?s.filter(n=>!(n.entityType===d.entityType&&n.entityId===d.entityId)):[...s,d]}function Oe(s,d){if(s.length!==d.length)return!1;const n=new Set(d);return s.every(m=>n.has(m))}function pe(s="project",d){return{id:`strategy_node_${Math.random().toString(36).slice(2,10)}`,entityType:s,entityId:"",branchLabel:"",notes:"",dependencyMode:"after_previous",customPredecessorIds:[],...d}}function _t(s){const d=new Map(s.graph.nodes.map(g=>[g.id,g])),n=new Map(s.graph.nodes.map(g=>[g.id,0])),m=new Map,c=new Map(s.graph.nodes.map((g,y)=>[g.id,y]));for(const g of s.graph.nodes)m.set(g.id,[]);for(const g of s.graph.edges)n.set(g.to,(n.get(g.to)??0)+1),m.set(g.from,[...m.get(g.from)??[],g.to]);const o=s.graph.nodes.filter(g=>(n.get(g.id)??0)===0).sort((g,y)=>(c.get(g.id)??0)-(c.get(y.id)??0)).map(g=>g.id),x=[];for(;o.length>0;){o.sort((j,S)=>(c.get(j)??0)-(c.get(S)??0));const g=o.shift();if(!g)continue;const y=d.get(g);if(y){x.push(y);for(const j of m.get(g)??[]){const S=(n.get(j)??0)-1;n.set(j,S),S===0&&o.push(j)}}}return x.length===s.graph.nodes.length?x:s.graph.nodes}function Lt(s){const d=new Map;for(const m of s.graph.nodes)d.set(m.id,[]);for(const m of s.graph.edges)d.set(m.to,[...d.get(m.to)??[],m.from]);const n=_t(s);return{title:s.title,overview:s.overview,endStateDescription:s.endStateDescription,status:s.status,userId:s.userId??null,targetGoalIds:s.targetGoalIds,targetProjectIds:s.targetProjectIds,linkedEntities:s.linkedEntities,nodes:n.map((m,c)=>{const o=d.get(m.id)??[],x=n[c-1],g=x?d.get(x.id)??[]:[];let y="custom";return o.length===0?y="start":x&&Oe(o,[x.id])?y="after_previous":x&&o.length>0&&Oe(o,g)&&(y="parallel_with_previous"),pe(m.entityType,{id:m.id,entityId:m.entityId,branchLabel:m.branchLabel,notes:m.notes,dependencyMode:y,customPredecessorIds:o})})}}function Je(s){const d=new Map,n=new Set;for(const[m,c]of s.entries()){const o=s[m-1];let x;switch(c.dependencyMode){case"after_previous":x=o?[o.id]:[];break;case"parallel_with_previous":x=o?[...d.get(o.id)??[]]:[];break;case"custom":x=c.customPredecessorIds.filter(g=>n.has(g));break;case"start":default:x=[];break}d.set(c.id,x),n.add(c.id)}return d}function ze(s){const d=Je(s),n=new Set,m=new Set;function c(o){if(m.has(o))return!0;if(n.has(o))return!1;n.add(o),m.add(o);for(const x of d.get(o)??[])if(c(x))return!0;return m.delete(o),!1}return s.some(o=>c(o.id))}const Qe={title:"",overview:"",endStateDescription:"",status:"active",userId:null,targetGoalIds:[],targetProjectIds:[],linkedEntities:[],nodes:[pe("project",{dependencyMode:"start"})]};function V(s,d){const n=d[0];return{title:"",description:"",goalId:(n==null?void 0:n.goalId)??"",projectId:(n==null?void 0:n.id)??"",userId:(n==null?void 0:n.userId)??s,priority:"medium",effort:"deep",energy:"steady",points:60}}function At(s,d,n){const m=Je(s.nodes),c=new Set(s.nodes.filter(o=>o.entityId).map(o=>o.id));return{nodes:s.nodes.filter(o=>o.entityId).map(o=>{var x,g;return{id:o.id,entityType:o.entityType,entityId:o.entityId,title:o.entityType==="project"?((x=d.get(o.entityId))==null?void 0:x.title)??o.entityId:((g=n.get(o.entityId))==null?void 0:g.title)??o.entityId,branchLabel:o.branchLabel.trim(),notes:o.notes.trim()}}),edges:s.nodes.flatMap(o=>c.has(o.id)?(m.get(o.id)??[]).filter(x=>c.has(x)).map(x=>({from:x,to:o.id,label:"",condition:""})):[])}}function Fe(s){return((s==null?void 0:s.progress)??0)/100}function Bt(s){switch(s==null?void 0:s.status){case"done":return 1;case"in_progress":return .66;case"focus":return .5;case"blocked":return .25;default:return 0}}function Rt(s){const{draft:d,graph:n,goals:m,projects:c,projectsById:o,tasks:x,tasksById:g}=s,y=new Map(n.nodes.map(l=>[l.id,l.entityType==="project"?Fe(o.get(l.entityId)):Bt(g.get(l.entityId))])),j=new Map;for(const l of n.nodes)j.set(l.id,[]);for(const l of n.edges)j.set(l.to,[...j.get(l.to)??[],l.from]);const S=n.nodes.filter(l=>(y.get(l.id)??0)>=1).map(l=>l.id),b=n.nodes.filter(l=>(y.get(l.id)??0)>0).map(l=>l.id),P=n.nodes.filter(l=>{var u,v;return l.entityType==="project"?((u=o.get(l.entityId))==null?void 0:u.status)==="paused":((v=g.get(l.entityId))==null?void 0:v.status)==="blocked"}).map(l=>l.id),a=n.nodes.filter(l=>(y.get(l.id)??0)<=0?!1:(j.get(l.id)??[]).some(v=>(y.get(v)??0)<1)).map(l=>l.id),h=n.nodes.filter(l=>(y.get(l.id)??0)>=1?!1:(j.get(l.id)??[]).every(v=>(y.get(v)??0)>=1)).map(l=>l.id),N=new Map(m.map(l=>[l.id,l])),M=d.targetGoalIds.map(l=>{var v;const u=x.filter(C=>C.goalId===l);return u.length===0?((v=N.get(l))==null?void 0:v.status)==="completed"?1:0:u.filter(C=>C.status==="done").length/u.length}),_=d.targetProjectIds.map(l=>Fe(o.get(l))),w=[...M,..._],$=n.nodes.length===0?0:n.nodes.reduce((l,u)=>l+(y.get(u.id)??0),0)/n.nodes.length,F=w.length===0?$:w.reduce((l,u)=>l+u,0)/w.length,te=new Set(n.nodes.filter(l=>l.entityType==="project").map(l=>l.entityId)),O=new Set(n.nodes.filter(l=>l.entityType==="task").map(l=>l.entityId)),A=new Set,z=new Set,k=new Set;for(const l of d.targetProjectIds){const u=c.find(v=>v.id===l);if(u&&!te.has(u.id)&&u.status!=="completed"){const v=`project:${u.id}`;A.add(v),z.add(v)}for(const v of x.filter(C=>C.projectId===l))if(!O.has(v.id)&&["focus","in_progress","done","blocked"].includes(v.status)){const C=`task:${v.id}`;A.add(C),v.status==="done"?k.add(C):z.add(C)}}for(const l of d.targetGoalIds)for(const u of x.filter(v=>v.goalId===l))if(!O.has(u.id)&&["focus","in_progress","done","blocked"].includes(u.status)){const v=`task:${u.id}`;A.add(v),u.status==="done"?k.add(v):z.add(v)}const L=Math.max(1,n.nodes.length),Y=A.size,K=P.length/L,J=Math.max(0,Math.min(100,Math.round($*100))),q=Math.max(0,Math.min(100,Math.round(100-a.length/L*100))),Z=Math.max(0,Math.min(100,Math.round(100-Y/L*100))),W=Math.max(0,Math.min(100,Math.round(Math.max(0,Math.min(1,F*.8+(1-K)*.2))*100))),D=Math.max(0,Math.min(100,Math.round(F*100)));return{alignmentScore:Math.max(0,Math.min(100,Math.round(J*.35+q*.3+Z*.2+W*.15))),planCoverageScore:J,sequencingScore:q,scopeDisciplineScore:Z,qualityScore:W,targetProgressScore:D,completedNodeCount:S.length,startedNodeCount:b.length,readyNodeCount:h.length,totalNodeCount:L,completedTargetCount:w.filter(l=>l>=1).length,totalTargetCount:w.length,offPlanEntityCount:Y,offPlanActiveEntityCount:z.size,offPlanCompletedEntityCount:k.size,activeNodeIds:h.slice(0,8),nextNodeIds:h.slice(0,5),blockedNodeIds:P,outOfOrderNodeIds:a}}function Ot({node:s,index:d,total:n,projectsById:m,tasksById:c,usersById:o,allNodes:x,onUpdate:g,onRemove:y}){const{attributes:j,listeners:S,setNodeRef:b,transform:P,transition:a,isDragging:h}=ft({id:s.id}),N=s.entityType==="project"?m.get(s.entityId):c.get(s.entityId),M=N&&"userId"in N&&N.userId?o.get(N.userId)??N.user??null:null,_=x.slice(0,d);return e.jsxs("div",{ref:b,style:{transform:vt.Transform.toString(P),transition:a},className:ce("min-w-0 overflow-hidden rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4 shadow-[var(--ui-shadow-soft)]",h&&"opacity-70"),children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx("button",{type:"button",className:"mt-1 rounded-full bg-[var(--ui-surface-2)] p-2 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",...j,...S,children:e.jsx(gt,{className:"size-4"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:["Step ",d+1]}),e.jsx(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:s.entityType}),N?e.jsx(R,{kind:s.entityType,label:N.title,compact:!0,gradient:!1}):null]}),e.jsx("div",{className:"mt-3 text-base font-medium text-[var(--ui-ink-strong)]",children:(N==null?void 0:N.title)||"Select an entity for this step"}),e.jsx("div",{className:"mt-2 break-words text-sm leading-6 text-[var(--ui-ink-soft)]",children:s.notes||(N&&"description"in N?N.description:"")||"Add an optional note if this phase needs intent or setup context."}),M?e.jsx("div",{className:"mt-3",children:e.jsx(H,{user:M,compact:!0})}):null]})]}),e.jsxs(Q,{type:"button",variant:"secondary",size:"sm",className:"w-full sm:w-auto",disabled:n===1,onClick:()=>y(s.id),children:[e.jsx(ht,{className:"size-4"}),"Remove"]})]}),e.jsxs("div",{className:"mt-4 grid gap-4 xl:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[e.jsx(T,{label:"Relationship to the flow",labelHelp:"Keep the sequence mostly linear in the form. Use parallel when this step should open beside the previous one, or custom only when the dependency is special.",children:e.jsx(Ue,{value:s.dependencyMode,columns:2,onChange:w=>g(s.id,{dependencyMode:w}),options:[{value:"start",label:"Start here",description:"This step opens immediately."},{value:"after_previous",label:"After previous",description:"Use the prior step as the gate."},{value:"parallel_with_previous",label:"Parallel with previous",description:"Open beside the prior branch."},{value:"custom",label:"Custom dependency",description:"Pick earlier steps manually."}]})}),e.jsxs("div",{className:"grid gap-4",children:[e.jsx(T,{label:"Branch label",children:e.jsx(X,{value:s.branchLabel,onChange:w=>g(s.id,{branchLabel:w.target.value}),placeholder:"Core path, fallback lane, support branch"})}),e.jsx(T,{label:"Step note",children:e.jsx(ue,{value:s.notes,onChange:w=>g(s.id,{notes:w.target.value}),placeholder:"Explain what has to be true before or after this step."})})]})]}),s.dependencyMode==="custom"?e.jsxs("div",{className:"mt-4 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:"Depends on"}),e.jsx("div",{className:"mt-3 grid gap-2",children:_.length===0?e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"No earlier steps available yet."}):_.map(w=>{const $=w.entityType==="project"?m.get(w.entityId):c.get(w.entityId);return e.jsxs("label",{className:"flex items-start justify-between gap-3 rounded-[16px] bg-[var(--ui-surface-2)] px-4 py-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:($==null?void 0:$.title)||`Step ${x.indexOf(w)+1}`}),e.jsx("div",{className:"mt-1 text-xs leading-5 text-[var(--ui-ink-soft)]",children:w.branchLabel||w.entityType})]}),e.jsx("input",{type:"checkbox",checked:s.customPredecessorIds.includes(w.id),onChange:()=>g(s.id,{customPredecessorIds:ee(s.customPredecessorIds,w.id)})})]},w.id)})})]}):null]})}const ie="min-h-10 rounded-[var(--radius-control)] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-2 text-sm text-[var(--ui-ink-strong)] outline-none transition focus:border-[color-mix(in_srgb,var(--primary)_34%,transparent)]";function zt({draft:s,setDraft:d,sequenceSearchQuery:n,setSequenceSearchQuery:m,openInlineTaskComposer:c,showInlineTaskComposer:o,setShowInlineTaskComposer:x,inlineTaskDraft:g,setInlineTaskDraft:y,inlineTaskError:j,setInlineTaskError:S,inlineTaskPending:b,submitInlineTask:P,defaultUserId:a,goals:h,projects:N,inlineTaskProjects:M,projectsById:_,tasksById:w,usersById:$,goalsById:F,sequenceEntityKeys:te,hasSequenceQuery:O,hasSequenceResults:A,limitedSequenceGoals:z,limitedSequenceProjects:k,limitedSequenceTasks:L,limitedSuggestedProjects:Y,limitedSuggestedTasks:K,appendSequenceNode:J,updateNode:q,removeNode:Z,reorderNodes:W,contractChecks:D,alignmentBreakdown:E}){const l=bt(yt(jt,{activationConstraint:{distance:6}}));return e.jsxs("div",{className:"grid min-w-0 gap-5",children:[e.jsxs("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] px-5 py-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Search and add"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Search goals, projects, tasks, humans, and bots."})]}),e.jsxs(G,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:[s.nodes.length," planned steps"]})]}),e.jsxs("div",{className:"mt-4 flex items-center gap-3 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx(ye,{className:"size-4 text-[var(--ui-ink-faint)]"}),e.jsx(X,{className:"border-none bg-transparent px-0 py-0",value:n,onChange:u=>m(u.target.value),placeholder:"Search goals, projects, tasks, owners, humans, or bots"})]}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsxs(Q,{type:"button",className:"w-full justify-start",variant:"secondary",onClick:c,children:[e.jsx(We,{className:"size-4"}),"Create new task"]}),o?e.jsx(Qt,{inlineTaskDraft:g,setInlineTaskDraft:y,inlineTaskError:j,setInlineTaskError:S,inlineTaskPending:b,setShowInlineTaskComposer:x,submitInlineTask:P,goals:h,projects:N,inlineTaskProjects:M,projectsById:_,defaultUserId:a}):null,e.jsx(Ft,{draft:s,setDraft:d,hasSequenceQuery:O,hasSequenceResults:A,sequenceEntityKeys:te,limitedSequenceGoals:z,limitedSequenceProjects:k,limitedSequenceTasks:L,limitedSuggestedProjects:Y,limitedSuggestedTasks:K,appendSequenceNode:J})]})]}),e.jsxs("div",{className:"grid min-w-0 gap-4",children:[e.jsxs("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-5 py-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Sequence"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Keep the flow mostly linear here. When a step should open beside the previous one, switch it to parallel. Use custom only for special joins."})]}),e.jsxs(G,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:[s.nodes.length," planned steps"]})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[s.targetGoalIds.map(u=>{const v=F.get(u);return v?e.jsx(R,{kind:"goal",label:v.title,compact:!0,gradient:!1},u):null}),s.targetProjectIds.map(u=>{const v=_.get(u);return v?e.jsx(R,{kind:"project",label:v.title,compact:!0,gradient:!1},u):null})]})]}),e.jsx(It,{sensors:l,collisionDetection:Nt,onDragEnd:u=>{!u.over||u.active.id===u.over.id||W(String(u.active.id),String(u.over.id))},children:e.jsx(wt,{items:s.nodes.map(u=>u.id),strategy:kt,children:e.jsx("div",{className:"grid gap-3",children:s.nodes.map((u,v)=>e.jsx(Ot,{node:u,index:v,total:s.nodes.length,projectsById:_,tasksById:w,usersById:$,allNodes:s.nodes,onUpdate:q,onRemove:Z},u.id))})})})]}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Contract readiness"}),e.jsx("div",{className:"mt-3 grid gap-2",children:D.map(u=>e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[14px] bg-[var(--ui-surface-1)] px-3 py-2",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:u.label}),e.jsx(G,{className:u.satisfied?"bg-[var(--ui-success-soft)] text-[var(--success)]":"bg-[var(--ui-warning-soft)] text-[var(--warning)]",children:u.satisfied?"Ready":"Missing"})]},u.id))})]}),e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Alignment preview"}),e.jsx("div",{className:"mt-3 grid gap-3",children:E.map(u=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm text-[var(--ui-ink-muted)]",children:[e.jsx("span",{children:u.label}),e.jsxs("span",{children:[u.value,"%"]})]}),e.jsx(Mt,{value:u.value,className:"mt-2"})]},u.id))})]})]})]})}function Qt({inlineTaskDraft:s,setInlineTaskDraft:d,inlineTaskError:n,setInlineTaskError:m,inlineTaskPending:c,setShowInlineTaskComposer:o,submitInlineTask:x,goals:g,projects:y,inlineTaskProjects:j,projectsById:S,defaultUserId:b}){const P=()=>{o(!1),m(null)};return e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:"New task"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Add the task and place it in the sequence."})]}),e.jsx(Q,{type:"button",variant:"secondary",className:"w-full sm:w-auto",onClick:P,children:"Close"})]}),e.jsxs("div",{className:"mt-4 grid gap-4",children:[e.jsx(T,{label:"Task title",children:e.jsx(X,{value:s.title,onChange:a=>d(h=>({...h,title:a.target.value})),placeholder:"Draft the shared strategy hierarchy view"})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(T,{label:"Goal",children:e.jsxs("select",{value:s.goalId,onChange:a=>{const h=a.target.value,N=y.find(M=>M.goalId===h)??null;d(M=>({...M,goalId:h,projectId:(N==null?void 0:N.id)??"",userId:(N==null?void 0:N.userId)??M.userId??b}))},className:ie,children:[e.jsx("option",{value:"",children:"Select goal"}),g.map(a=>e.jsx("option",{value:a.id,children:a.title},a.id))]})}),e.jsx(T,{label:"Project",children:e.jsxs("select",{value:s.projectId,onChange:a=>d(h=>{var N,M;return{...h,projectId:a.target.value,goalId:((N=S.get(a.target.value))==null?void 0:N.goalId)??h.goalId,userId:((M=S.get(a.target.value))==null?void 0:M.userId)??h.userId}}),className:ie,children:[e.jsx("option",{value:"",children:"Select project"}),j.map(a=>e.jsx("option",{value:a.id,children:a.title},a.id))]})})]}),e.jsx(T,{label:"Notes",children:e.jsx(ue,{value:s.description,onChange:a=>d(h=>({...h,description:a.target.value})),placeholder:"Optional detail or acceptance note."})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(T,{label:"Priority",children:e.jsxs("select",{value:s.priority,onChange:a=>d(h=>({...h,priority:a.target.value})),className:ie,children:[e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"high",children:"High"}),e.jsx("option",{value:"critical",children:"Critical"})]})}),e.jsx(T,{label:"Points",children:e.jsx(X,{type:"number",value:s.points,onChange:a=>d(h=>({...h,points:Number(a.target.value)||0}))})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(T,{label:"Effort",children:e.jsxs("select",{value:s.effort,onChange:a=>d(h=>({...h,effort:a.target.value})),className:ie,children:[e.jsx("option",{value:"light",children:"Light"}),e.jsx("option",{value:"deep",children:"Deep"}),e.jsx("option",{value:"extended",children:"Extended"})]})}),e.jsx(T,{label:"Energy",children:e.jsxs("select",{value:s.energy,onChange:a=>d(h=>({...h,energy:a.target.value})),className:ie,children:[e.jsx("option",{value:"calm",children:"Calm"}),e.jsx("option",{value:"steady",children:"Steady"}),e.jsx("option",{value:"intense",children:"Intense"})]})})]}),n?e.jsx("div",{className:"rounded-[18px] border border-[color-mix(in_srgb,var(--danger)_28%,transparent)] bg-[var(--ui-danger-soft)] px-4 py-3 text-sm text-[var(--danger)]",children:n}):null,e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsx(Q,{type:"button",variant:"secondary",className:"w-full sm:w-auto",onClick:P,children:"Cancel"}),e.jsxs(Q,{type:"button",className:"w-full sm:w-auto",pending:c,pendingLabel:"Creating task",onClick:x,children:[e.jsx(We,{className:"size-4"}),"Create task"]})]})]})]})}function Ft({draft:s,setDraft:d,hasSequenceQuery:n,hasSequenceResults:m,sequenceEntityKeys:c,limitedSequenceGoals:o,limitedSequenceProjects:x,limitedSequenceTasks:g,limitedSuggestedProjects:y,limitedSuggestedTasks:j,appendSequenceNode:S}){return n?m?e.jsxs("div",{className:"grid gap-3",children:[o.length>0?e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Goals"}):null,o.map(b=>{const P=s.targetGoalIds.includes(b.id),a=s.linkedEntities.some(h=>h.entityType==="goal"&&h.entityId===b.id);return e.jsx("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(R,{kind:"goal",label:b.title,compact:!0,gradient:!1}),e.jsx(H,{user:b.user,compact:!0})]}),b.description?e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:b.description}):null]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(Q,{type:"button",className:"w-full sm:w-auto",variant:P?"secondary":"primary",onClick:()=>d(h=>({...h,targetGoalIds:ee(h.targetGoalIds,b.id)})),children:P?"Targeted":"Add target"}),e.jsx(Q,{type:"button",className:"w-full sm:w-auto",variant:"secondary",onClick:()=>d(h=>({...h,linkedEntities:Ye(h.linkedEntities,{entityType:"goal",entityId:b.id})})),children:a?"Unlink":"Link"})]})]})},b.id)}),x.length>0?e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Projects"}):null,x.map(b=>e.jsx(Ke,{project:b,inSequence:c.has(`project:${b.id}`),appendSequenceNode:S},`sequence-project:${b.id}`)),g.length>0?e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Tasks"}):null,g.map(b=>e.jsx(He,{task:b,inSequence:c.has(`task:${b.id}`),appendSequenceNode:S},`sequence-task:${b.id}`))]}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"No goals, projects, or tasks match this search."}):y.length>0||j.length>0?e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Suggested from targets"}),y.map(b=>e.jsx(Ke,{project:b,inSequence:c.has(`project:${b.id}`),appendSequenceNode:S},`suggested-project:${b.id}`)),j.map(b=>e.jsx(He,{task:b,inSequence:c.has(`task:${b.id}`),appendSequenceNode:S},`suggested-task:${b.id}`))]}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Type to search."})}function Ke({project:s,inSequence:d,appendSequenceNode:n}){return e.jsx("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(R,{kind:"project",label:s.title,compact:!0,gradient:!1}),e.jsx(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:s.goalTitle}),e.jsx(H,{user:s.user,compact:!0})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:s.description||s.goalTitle})]}),e.jsx(Q,{type:"button",className:"w-full sm:w-auto",variant:d?"secondary":"primary",disabled:d,onClick:()=>n("project",s.id),children:d?"In sequence":"Add step"})]})})}function He({task:s,inSequence:d,appendSequenceNode:n}){return e.jsx("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(R,{kind:"task",label:s.title,compact:!0,gradient:!1}),e.jsx(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:s.status}),e.jsx(H,{user:s.user,compact:!0})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:s.description||`${s.owner} · ${s.status}`})]}),e.jsx(Q,{type:"button",className:"w-full sm:w-auto",variant:d?"secondary":"primary",disabled:d,onClick:()=>n("task",s.id),children:d?"In sequence":"Add step"})]})})}function Zt({open:s,pending:d=!1,editingStrategy:n,goals:m,projects:c,tasks:o,habits:x,strategies:g,users:y,defaultUserId:j=null,initialStepId:S,onOpenChange:b,onSubmit:P}){const[a,h]=p.useState(Qe),[N,M]=p.useState(""),[_,w]=p.useState(""),[$,F]=p.useState(""),[te,O]=p.useState(null),[A,z]=p.useState([]),[k,L]=p.useState(V(j,c)),[Y,K]=p.useState(!1),[J,q]=p.useState(null),[Z,W]=p.useState(!1);p.useEffect(()=>{var r,i,f;if(!s)return;const t=n?Lt(n):{...Qe,userId:j,nodes:[pe("project",{dependencyMode:"start"})]};h(t),M(""),w(""),F(""),z([]),K(!1),L(V(j,c).projectId&&t.targetProjectIds[0]?{...V(j,c),goalId:((r=c.find(I=>I.id===t.targetProjectIds[0]))==null?void 0:r.goalId)??"",projectId:t.targetProjectIds[0]??((i=c[0])==null?void 0:i.id)??"",userId:((f=c.find(I=>I.id===t.targetProjectIds[0]))==null?void 0:f.userId)??j}:V(j,c)),q(null),O(null)},[j,n,s,c]);const D=p.useDeferredValue(N),E=p.useDeferredValue(_),l=p.useDeferredValue($),u=p.useMemo(()=>{const t=new Set(A.map(r=>r.id));return[...A,...o.filter(r=>!t.has(r.id))]},[A,o]),v=p.useMemo(()=>new Map(m.map(t=>[t.id,t])),[m]),C=p.useMemo(()=>new Map(c.map(t=>[t.id,t])),[c]),se=p.useMemo(()=>new Map(u.map(t=>[t.id,t])),[u]),je=p.useMemo(()=>new Map(y.map(t=>[t.id,t])),[y]),me=y.find(t=>t.id===j)??null,ge=y.find(t=>t.id===a.userId)??me,B=(t,r,i)=>{const f=Dt(t);return f.length===0||Et(r,i).includes(f)},Ie=p.useMemo(()=>m.filter(t=>B(E,[t.title,t.description],t.user)),[E,m]),he=p.useMemo(()=>m.filter(t=>B(D,[t.title,t.description],t.user)),[m,D]),xe=p.useMemo(()=>c.filter(t=>B(D,[t.title,t.description,t.goalTitle,t.status],t.user)),[D,c]),Ne=p.useMemo(()=>c.filter(t=>B(E,[t.title,t.description,t.goalTitle,t.status],t.user)),[E,c]),we=p.useMemo(()=>u.filter(t=>B(E,[t.title,t.description,t.owner,t.status],t.user)),[u,E]),ke=p.useMemo(()=>x.filter(t=>B(E,[t.title,t.description,t.frequency,t.status],t.user)),[E,x]),Se=p.useMemo(()=>g.filter(t=>t.id!==(n==null?void 0:n.id)&&B(E,[t.title,t.overview,t.endStateDescription,t.status],t.user)),[E,n==null?void 0:n.id,g]),fe=p.useMemo(()=>[...Ie.map(r=>({key:`goal:${r.id}`,entityType:"goal",entityId:r.id,label:r.title,description:ae(r.description,r.user,"Goal"),user:r.user??null})),...Ne.map(r=>({key:`project:${r.id}`,entityType:"project",entityId:r.id,label:r.title,description:ae(`${r.goalTitle}${r.goalTitle?" · ":""}${r.status}`,r.user,`Project · ${r.goalTitle}`),user:r.user??null})),...we.map(r=>({key:`task:${r.id}`,entityType:"task",entityId:r.id,label:r.title,description:ae(`${r.status} · ${r.owner}`,r.user,`Task · ${r.owner}`),user:r.user??null})),...ke.map(r=>({key:`habit:${r.id}`,entityType:"habit",entityId:r.id,label:r.title,description:ae(r.description,r.user,"Habit"),user:r.user??null})),...Se.map(r=>({key:`strategy:${r.id}`,entityType:"strategy",entityId:r.id,label:r.title,description:ae(r.overview,r.user,"Strategy"),user:r.user??null}))].sort((r,i)=>r.label.localeCompare(i.label)),[Ie,ke,Ne,Se,we]),U=p.useMemo(()=>At(a,C,se),[a,C,se]),Ce=p.useMemo(()=>Rt({draft:a,graph:U,goals:m,projects:c,projectsById:C,tasks:u,tasksById:se}),[u,a,U,m,c,C,se]),Ze=p.useMemo(()=>[...Xe({title:a.title,overview:a.overview,endStateDescription:a.endStateDescription,targetGoalIds:a.targetGoalIds,targetProjectIds:a.targetProjectIds,graph:U}),{id:"acyclic",label:"Graph stays directed and non-looping",satisfied:!ze(a.nodes)}],[a.endStateDescription,a.nodes,a.overview,a.targetGoalIds,a.targetProjectIds,a.title,U]),ve=p.useMemo(()=>$t({title:a.title,overview:a.overview,endStateDescription:a.endStateDescription,targetGoalIds:a.targetGoalIds,targetProjectIds:a.targetProjectIds,graph:U}),[a.endStateDescription,a.overview,a.targetGoalIds,a.targetProjectIds,a.title,U]),Ve=p.useMemo(()=>qt(Ce),[Ce]),be=p.useMemo(()=>{if(!a.title.trim())return"Strategy title is required.";if(a.nodes.length===0)return"Add at least one project or task step.";const t=new Set;for(const r of a.nodes){if(!r.entityId)return"Every step needs a linked project or task.";const i=`${r.entityType}:${r.entityId}`;if(t.has(i))return"Each project or task should appear only once in the sequence.";t.add(i)}return ze(a.nodes)?"Strategy graph must stay directed and non-loopy.":null},[a.nodes,a.title]),et=t=>t==="sequence"?te??be??(ve?null:"This can still be saved as a draft. Add the target plus the overview or end state later, then lock it as the contract from the strategy detail page."):null,Me=p.useMemo(()=>m.filter(t=>B(l,[t.title,t.description],t.user)),[m,l]),ne=p.useMemo(()=>c.filter(t=>B(l,[t.title,t.description,t.goalTitle,t.status],t.user)),[c,l]),le=p.useMemo(()=>u.filter(t=>B(l,[t.title,t.description,t.owner,t.status],t.user)),[u,l]),de=p.useMemo(()=>new Set(a.targetGoalIds),[a.targetGoalIds]),oe=p.useMemo(()=>new Set(a.targetProjectIds),[a.targetProjectIds]),tt=p.useMemo(()=>new Set(a.nodes.map(t=>`${t.entityType}:${t.entityId}`)),[a.nodes]),Te=p.useMemo(()=>a.targetGoalIds.map(t=>v.get(t)).filter(t=>!!t),[a.targetGoalIds,v]),Pe=p.useMemo(()=>a.targetProjectIds.map(t=>C.get(t)).filter(t=>!!t),[a.targetProjectIds,C]),Ee=p.useMemo(()=>ne.filter(t=>oe.has(t.id)||de.has(t.goalId)),[ne,de,oe]),Ge=p.useMemo(()=>le.filter(t=>oe.has(t.projectId??"")||de.has(t.goalId??"")),[le,de,oe]),$e=p.useMemo(()=>he.slice(0,8),[he]),qe=p.useMemo(()=>xe.slice(0,8),[xe]),De=p.useMemo(()=>fe.slice(0,12),[fe]),_e=p.useMemo(()=>Me.slice(0,6),[Me]),Le=p.useMemo(()=>ne.slice(0,8),[ne]),Ae=p.useMemo(()=>le.slice(0,10),[le]),st=p.useMemo(()=>Ee.slice(0,4),[Ee]),rt=p.useMemo(()=>Ge.slice(0,6),[Ge]),at=p.useMemo(()=>{if(!k.goalId)return c;const t=c.filter(r=>r.goalId===k.goalId);return t.length>0?t:c},[k.goalId,c]),it=l.length>0,nt=_e.length>0||Le.length>0||Ae.length>0,lt=(t,r)=>{h(i=>({...i,nodes:i.nodes.map(f=>f.id===t?{...f,...r}:f)}))},Be=(t,r)=>{a.nodes.some(i=>i.entityType===t&&i.entityId===r)||h(i=>({...i,nodes:[...i.nodes,pe(t,{entityId:r,dependencyMode:i.nodes.length===0?"start":"after_previous"})]}))},dt=t=>{h(r=>{const i=r.nodes.filter(f=>f.id!==t);return{...r,nodes:i.map((f,I)=>({...f,dependencyMode:I===0&&f.dependencyMode==="after_previous"?"start":f.dependencyMode,customPredecessorIds:f.customPredecessorIds.filter(re=>re!==t)}))}})},ot=(t,r)=>{h(i=>{const f=i.nodes.findIndex(re=>re.id===t),I=i.nodes.findIndex(re=>re.id===r);return f<0||I<0?i:{...i,nodes:St(i.nodes,f,I)}})},ct=()=>{const t=$.trim(),r=a.targetProjectIds.map(I=>C.get(I)).find(I=>!!I)??C.get(k.projectId)??c[0]??null,i=(r==null?void 0:r.goalId)??a.targetGoalIds[0]??"",f=c.find(I=>I.goalId===i&&(r?I.id===r.id:!0))??c.find(I=>I.goalId===i)??r;L(I=>({...V(j,c),title:t||I.title,description:I.description,goalId:i,projectId:(f==null?void 0:f.id)??I.projectId,userId:(f==null?void 0:f.userId)??I.userId??j})),q(null),K(!0)},ut=async()=>{const t=C.get(k.projectId);if(!k.title.trim()){q("Task title is required.");return}if(!t){q("Pick a project for the new task.");return}W(!0),q(null);try{const r=je.get(k.userId??t.userId??"")??t.user??ge??me,i=(await Tt({title:k.title.trim(),description:k.description.trim(),level:"task",owner:(r==null?void 0:r.displayName)??"Albert",userId:k.userId??t.userId??a.userId,assigneeUserIds:[],goalId:t.goalId,projectId:t.id,parentWorkItemId:null,priority:k.priority,status:"focus",effort:k.effort,energy:k.energy,dueDate:"",points:k.points,plannedDurationSeconds:86400,aiInstructions:"",executionMode:null,acceptanceCriteria:[],blockerLinks:[],completionReport:null,gitRefs:[],tagIds:[],notes:[]})).task;z(f=>[i,...f]),Be("task",i.id),L({...V(j,c),goalId:t.goalId,projectId:t.id,userId:i.userId??t.userId??a.userId}),F(""),K(!1)}catch(r){q(r instanceof Error?r.message:"Task creation failed.")}finally{W(!1)}},pt=async()=>{if(be){O(be);return}try{await P({title:a.title.trim(),overview:a.overview.trim(),endStateDescription:a.endStateDescription.trim(),status:a.status,userId:a.userId,targetGoalIds:a.targetGoalIds,targetProjectIds:a.targetProjectIds,linkedEntities:a.linkedEntities,graph:U},n==null?void 0:n.id),O(null),b(!1)}catch(t){O(t instanceof Error?t.message:"Strategy save failed.")}},mt=[{id:"foundation",eyebrow:"Foundation",title:"Set the owner and the strategic frame",description:"Start with who owns the strategy, what the plan is called, and whether this should open as active, paused, or already landed.",render:(t,r)=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_minmax(16rem,0.8fr)]",children:[e.jsx(T,{label:"Strategy title",children:e.jsx(X,{value:t.title,onChange:i=>r({title:i.target.value}),placeholder:"Land the multi-user planning system"})}),e.jsx(T,{label:"Status",children:e.jsx(Ue,{value:t.status,onChange:i=>r({status:i}),options:[{value:"active",label:"Active",description:"Use this when the plan should drive work now."},{value:"paused",label:"Paused",description:"Keep the strategy visible without active pressure."},{value:"completed",label:"Completed",description:"The end state is already landed."}]})})]}),e.jsx(Pt,{value:t.userId,users:y,onChange:i=>r({userId:i}),label:"Owner user",defaultLabel:Gt(me),help:"Strategies can belong to a human or a bot even when the sequence spans multiple owners."}),e.jsxs("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-accent-soft)] px-5 py-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Live posture"}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx(R,{kind:"strategy",label:t.title.trim()||"Untitled strategy",compact:!0,gradient:!1}),e.jsx(G,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-strong)]",children:t.status}),ge?e.jsx(H,{user:ge,compact:!0}):null]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"This flow is built to keep strategy creation as guided as the other major entities in Forge: clear questions first, then a focused sequence stage at the end."})]})]})},{id:"objective",eyebrow:"Objective",title:"Define the objective and the end targets",description:"Capture what this strategy is coordinating, what done looks like, and which goals or projects are the real targets.",render:(t,r)=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsx(T,{label:"Overview",children:e.jsx(ue,{value:t.overview,onChange:i=>r({overview:i.target.value}),placeholder:"Explain what this strategy is coordinating and why it matters right now."})}),e.jsx(T,{label:"End state",children:e.jsx(ue,{value:t.endStateDescription,onChange:i=>r({endStateDescription:i.target.value}),placeholder:"Describe what reality should look like when this strategy lands."})})]}),e.jsxs("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] px-5 py-5",children:[e.jsx(T,{label:"Search goals or projects",description:"Keep this page search-first. Add only the targets that truly define what this strategy is trying to land.",children:e.jsxs("div",{className:"flex items-center gap-3 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx(ye,{className:"size-4 text-[var(--ui-ink-faint)]"}),e.jsx(X,{className:"border-none bg-transparent px-0 py-0",value:N,onChange:i=>M(i.target.value),placeholder:"Search goals, projects, owners, humans, or bots"})]})}),e.jsxs("div",{className:"mt-5 grid gap-4 xl:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Selected goals"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:Te.length===0?e.jsx(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:"No target goals yet"}):Te.map(i=>e.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-full bg-[var(--ui-accent-soft)] px-3 py-1.5 text-sm text-[var(--ui-ink-strong)] transition hover:bg-[var(--ui-accent-soft-hover)]",onClick:()=>r({targetGoalIds:ee(t.targetGoalIds,i.id)}),children:[e.jsx(R,{kind:"goal",label:i.title,compact:!0,gradient:!1}),e.jsx("span",{children:"Remove"})]},i.id))})]}),e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Selected projects"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:Pe.length===0?e.jsx(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:"No target projects yet"}):Pe.map(i=>e.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-full bg-[var(--ui-accent-soft)] px-3 py-1.5 text-sm text-[var(--ui-ink-strong)] transition hover:bg-[var(--ui-accent-soft-hover)]",onClick:()=>r({targetProjectIds:ee(t.targetProjectIds,i.id)}),children:[e.jsx(R,{kind:"project",label:i.title,compact:!0,gradient:!1}),e.jsx("span",{children:"Remove"})]},i.id))})]})]})]}),e.jsxs("div",{className:"grid gap-5 xl:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Goal matches"}),D?e.jsxs(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[he.length," found"]}):null]}),e.jsx("div",{className:"mt-3 grid gap-3",children:D?$e.length===0?e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"No goals match this search yet."}):$e.map(i=>{const f=t.targetGoalIds.includes(i.id);return e.jsxs("button",{type:"button",className:ce("rounded-[22px] border px-4 py-4 text-left transition",f?"border-[color-mix(in_srgb,var(--primary)_30%,transparent)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)]"),onClick:()=>r({targetGoalIds:ee(t.targetGoalIds,i.id)}),children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center justify-between gap-2",children:[e.jsx(Re,{kind:"goal",label:i.title,className:"max-w-full min-w-0"}),e.jsx(H,{user:i.user,compact:!0})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:i.description||"No strategic note attached yet."})]},i.id)}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Search for the goal this strategy is meant to land."})})]}),e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Project matches"}),D?e.jsxs(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[xe.length," found"]}):null]}),e.jsx("div",{className:"mt-3 grid gap-3",children:D?qe.length===0?e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"No projects match this search yet."}):qe.map(i=>{const f=t.targetProjectIds.includes(i.id);return e.jsxs("button",{type:"button",className:ce("rounded-[22px] border px-4 py-4 text-left transition",f?"border-[color-mix(in_srgb,var(--primary)_30%,transparent)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)]"),onClick:()=>r({targetProjectIds:ee(t.targetProjectIds,i.id)}),children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center justify-between gap-2",children:[e.jsx(Re,{kind:"project",label:i.title,className:"max-w-full min-w-0",showIcon:!1}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:i.goalTitle}),e.jsx(H,{user:i.user,compact:!0})]})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:i.description||"No project summary attached yet."})]},i.id)}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Search for the concrete project this strategy should land or organize."})})]})]})]})},{id:"context",eyebrow:"Context",title:"Keep the right supporting entities in view",description:"Linked entities stay visible in the strategy context without becoming part of the main execution sequence.",render:(t,r)=>e.jsxs(e.Fragment,{children:[e.jsx(T,{label:"Search supporting context",description:"Search across goals, projects, tasks, habits, and other strategies.",children:e.jsxs("div",{className:"flex items-center gap-3 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx(ye,{className:"size-4 text-[var(--ui-ink-faint)]"}),e.jsx(X,{className:"border-none bg-transparent px-0 py-0",value:_,onChange:i=>w(i.target.value),placeholder:"Search by title, owner, @handle, human, or bot"})]})}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.linkedEntities.length===0?e.jsx(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:"No extra linked context yet"}):t.linkedEntities.map(i=>{const f=fe.find(I=>I.entityType===i.entityType&&I.entityId===i.entityId);return e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 rounded-full bg-[var(--ui-accent-soft)] px-3 py-1.5 text-sm text-[var(--ui-ink-medium)] transition hover:bg-[var(--ui-accent-soft-hover)]",onClick:()=>r({linkedEntities:t.linkedEntities.filter(I=>!(I.entityType===i.entityType&&I.entityId===i.entityId))}),children:[e.jsx(xt,{className:"mr-1 size-3.5"}),(f==null?void 0:f.label)??`${i.entityType}:${i.entityId}`,e.jsx("span",{children:"Remove"})]},`${i.entityType}:${i.entityId}`)})}),e.jsx("div",{className:"grid gap-3",children:E?De.length===0?e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"No supporting entities match this search yet."}):De.map(i=>{const f=t.linkedEntities.some(I=>I.entityType===i.entityType&&I.entityId===i.entityId);return e.jsxs("label",{className:ce("flex items-start justify-between gap-3 rounded-[20px] border px-4 py-4",f?"border-[color-mix(in_srgb,var(--primary)_28%,transparent)] bg-[var(--ui-accent-soft)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]"),children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(R,{kind:i.entityType,label:i.label,compact:!0,gradient:!1}),i.user?e.jsx(H,{user:i.user,compact:!0}):null]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:i.description})]}),e.jsx("input",{type:"checkbox",checked:f,onChange:()=>r({linkedEntities:Ye(t.linkedEntities,{entityType:i.entityType,entityId:i.entityId})})})]},i.key)}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Search when you want to pull another entity into the background context. This keeps the page focused instead of dumping every record into one long list."})})]})},{id:"sequence",eyebrow:"Sequence",title:"Build the execution sequence",description:"Search, add steps, and create missing tasks.",render:()=>e.jsx(zt,{draft:a,setDraft:h,sequenceSearchQuery:$,setSequenceSearchQuery:F,openInlineTaskComposer:ct,showInlineTaskComposer:Y,setShowInlineTaskComposer:K,inlineTaskDraft:k,setInlineTaskDraft:L,inlineTaskError:J,setInlineTaskError:q,inlineTaskPending:Z,submitInlineTask:()=>void ut(),defaultUserId:j,goals:m,projects:c,inlineTaskProjects:at,projectsById:C,tasksById:se,usersById:je,goalsById:v,sequenceEntityKeys:tt,hasSequenceQuery:it,hasSequenceResults:nt,limitedSequenceGoals:_e,limitedSequenceProjects:Le,limitedSequenceTasks:Ae,limitedSuggestedProjects:st,limitedSuggestedTasks:rt,appendSequenceNode:Be,updateNode:lt,removeNode:dt,reorderNodes:ot,contractChecks:Ze,alignmentBreakdown:Ve})}];return e.jsx(Ct,{open:s,onOpenChange:b,eyebrow:"Strategy",title:n?"Edit strategy":"Create strategy",description:"Strategies connect goals, projects, and tasks into a guided multi-step plan with a focused sequence builder at the end.",value:a,onChange:h,draftPersistenceKey:n?`strategy.${n.id}`:"strategy.new",steps:mt,initialStepId:S,contentClassName:"lg:h-[min(56rem,calc(100vh-1rem))] lg:w-[min(78rem,calc(100vw-1.5rem))]",submitLabel:n?ve?"Save strategy":"Save draft":ve?"Create strategy":"Create draft",pending:d,pendingLabel:"Saving strategy",resolveError:et,onSubmit:pt})}export{Zt as S,Xe as a,qt as b,$t as i};
1
+ import{j as e,bz as gt,c7 as ht,b8 as ye,bY as We,r as p,c1 as xt}from"./vendor-B7FKSwHK.js";import{b as ft,C as vt,u as bt,a as yt,P as jt,D as It,c as Nt,S as wt,v as kt,d as St}from"./board-DprRipIG.js";import{F as T,a as Ye,Q as Ct}from"./question-flow-dialog-yMYVk998.js";import{j as G,b as R,B as Q,I as U,T as ue,c as ce,_ as Mt,E as Re,ag as Tt}from"./index-gmPaoLN-.js";import{U as H}from"./user-badge-C4eZu1e_.js";import{U as Pt}from"./user-select-field-CmKwcbZt.js";import{d as ae,b as Et,a as Gt}from"./user-ownership-DJGl4rAj.js";function Ue(s){return[{id:"title",label:"Strategy title is set",satisfied:s.title.trim().length>0},{id:"graph",label:"Graph contains at least one linked project or task",satisfied:s.graph.nodes.length>0},{id:"targets",label:"At least one target goal or project is selected",satisfied:s.targetGoalIds.length>0||s.targetProjectIds.length>0},{id:"narrative",label:"The plan already names an overview or end state",satisfied:s.overview.trim().length>0||s.endStateDescription.trim().length>0}]}function $t(s){return Ue(s).every(d=>d.satisfied)}function qt(s){return[{id:"coverage",label:"Agreed work moving",value:s.planCoverageScore,detail:`${s.startedNodeCount}/${s.totalNodeCount} agreed steps have started or finished.`},{id:"order",label:"Order respected",value:s.sequencingScore,detail:`${s.outOfOrderNodeIds.length} step${s.outOfOrderNodeIds.length===1?"":"s"} started before prerequisites were complete.`},{id:"scope",label:"Scope held",value:s.scopeDisciplineScore,detail:`${s.offPlanEntityCount} unagreed item${s.offPlanEntityCount===1?"":"s"} are inside the strategy scope, ${s.offPlanActiveEntityCount} still active.`},{id:"satisfaction",label:"End-state satisfaction",value:s.qualityScore,detail:`${s.targetProgressScore}% target progress with ${s.blockedNodeIds.length} blocked step${s.blockedNodeIds.length===1?"":"s"}.`}]}function Dt(s){return s.trim().toLowerCase()}function ee(s,d){return s.includes(d)?s.filter(n=>n!==d):[...s,d]}function Je(s,d){return s.some(n=>n.entityType===d.entityType&&n.entityId===d.entityId)?s.filter(n=>!(n.entityType===d.entityType&&n.entityId===d.entityId)):[...s,d]}function Oe(s,d){if(s.length!==d.length)return!1;const n=new Set(d);return s.every(m=>n.has(m))}function pe(s="project",d){return{id:`strategy_node_${Math.random().toString(36).slice(2,10)}`,entityType:s,entityId:"",branchLabel:"",notes:"",dependencyMode:"after_previous",customPredecessorIds:[],...d}}function _t(s){const d=new Map(s.graph.nodes.map(g=>[g.id,g])),n=new Map(s.graph.nodes.map(g=>[g.id,0])),m=new Map,c=new Map(s.graph.nodes.map((g,y)=>[g.id,y]));for(const g of s.graph.nodes)m.set(g.id,[]);for(const g of s.graph.edges)n.set(g.to,(n.get(g.to)??0)+1),m.set(g.from,[...m.get(g.from)??[],g.to]);const o=s.graph.nodes.filter(g=>(n.get(g.id)??0)===0).sort((g,y)=>(c.get(g.id)??0)-(c.get(y.id)??0)).map(g=>g.id),x=[];for(;o.length>0;){o.sort((j,S)=>(c.get(j)??0)-(c.get(S)??0));const g=o.shift();if(!g)continue;const y=d.get(g);if(y){x.push(y);for(const j of m.get(g)??[]){const S=(n.get(j)??0)-1;n.set(j,S),S===0&&o.push(j)}}}return x.length===s.graph.nodes.length?x:s.graph.nodes}function Lt(s){const d=new Map;for(const m of s.graph.nodes)d.set(m.id,[]);for(const m of s.graph.edges)d.set(m.to,[...d.get(m.to)??[],m.from]);const n=_t(s);return{title:s.title,overview:s.overview,endStateDescription:s.endStateDescription,status:s.status,userId:s.userId??null,targetGoalIds:s.targetGoalIds,targetProjectIds:s.targetProjectIds,linkedEntities:s.linkedEntities,nodes:n.map((m,c)=>{const o=d.get(m.id)??[],x=n[c-1],g=x?d.get(x.id)??[]:[];let y="custom";return o.length===0?y="start":x&&Oe(o,[x.id])?y="after_previous":x&&o.length>0&&Oe(o,g)&&(y="parallel_with_previous"),pe(m.entityType,{id:m.id,entityId:m.entityId,branchLabel:m.branchLabel,notes:m.notes,dependencyMode:y,customPredecessorIds:o})})}}function Xe(s){const d=new Map,n=new Set;for(const[m,c]of s.entries()){const o=s[m-1];let x;switch(c.dependencyMode){case"after_previous":x=o?[o.id]:[];break;case"parallel_with_previous":x=o?[...d.get(o.id)??[]]:[];break;case"custom":x=c.customPredecessorIds.filter(g=>n.has(g));break;case"start":default:x=[];break}d.set(c.id,x),n.add(c.id)}return d}function ze(s){const d=Xe(s),n=new Set,m=new Set;function c(o){if(m.has(o))return!0;if(n.has(o))return!1;n.add(o),m.add(o);for(const x of d.get(o)??[])if(c(x))return!0;return m.delete(o),!1}return s.some(o=>c(o.id))}const Qe={title:"",overview:"",endStateDescription:"",status:"active",userId:null,targetGoalIds:[],targetProjectIds:[],linkedEntities:[],nodes:[pe("project",{dependencyMode:"start"})]};function V(s,d){const n=d[0];return{title:"",description:"",goalId:(n==null?void 0:n.goalId)??"",projectId:(n==null?void 0:n.id)??"",userId:(n==null?void 0:n.userId)??s,priority:"medium",effort:"deep",energy:"steady",points:60}}function At(s,d,n){const m=Xe(s.nodes),c=new Set(s.nodes.filter(o=>o.entityId).map(o=>o.id));return{nodes:s.nodes.filter(o=>o.entityId).map(o=>{var x,g;return{id:o.id,entityType:o.entityType,entityId:o.entityId,title:o.entityType==="project"?((x=d.get(o.entityId))==null?void 0:x.title)??o.entityId:((g=n.get(o.entityId))==null?void 0:g.title)??o.entityId,branchLabel:o.branchLabel.trim(),notes:o.notes.trim()}}),edges:s.nodes.flatMap(o=>c.has(o.id)?(m.get(o.id)??[]).filter(x=>c.has(x)).map(x=>({from:x,to:o.id,label:"",condition:""})):[])}}function Fe(s){return((s==null?void 0:s.progress)??0)/100}function Bt(s){switch(s==null?void 0:s.status){case"done":return 1;case"in_progress":return .66;case"focus":return .5;case"blocked":return .25;default:return 0}}function Rt(s){const{draft:d,graph:n,goals:m,projects:c,projectsById:o,tasks:x,tasksById:g}=s,y=new Map(n.nodes.map(l=>[l.id,l.entityType==="project"?Fe(o.get(l.entityId)):Bt(g.get(l.entityId))])),j=new Map;for(const l of n.nodes)j.set(l.id,[]);for(const l of n.edges)j.set(l.to,[...j.get(l.to)??[],l.from]);const S=n.nodes.filter(l=>(y.get(l.id)??0)>=1).map(l=>l.id),b=n.nodes.filter(l=>(y.get(l.id)??0)>0).map(l=>l.id),P=n.nodes.filter(l=>{var u,v;return l.entityType==="project"?((u=o.get(l.entityId))==null?void 0:u.status)==="paused":((v=g.get(l.entityId))==null?void 0:v.status)==="blocked"}).map(l=>l.id),a=n.nodes.filter(l=>(y.get(l.id)??0)<=0?!1:(j.get(l.id)??[]).some(v=>(y.get(v)??0)<1)).map(l=>l.id),h=n.nodes.filter(l=>(y.get(l.id)??0)>=1?!1:(j.get(l.id)??[]).every(v=>(y.get(v)??0)>=1)).map(l=>l.id),N=new Map(m.map(l=>[l.id,l])),M=d.targetGoalIds.map(l=>{var v;const u=x.filter(C=>C.goalId===l);return u.length===0?((v=N.get(l))==null?void 0:v.status)==="completed"?1:0:u.filter(C=>C.status==="done").length/u.length}),_=d.targetProjectIds.map(l=>Fe(o.get(l))),w=[...M,..._],$=n.nodes.length===0?0:n.nodes.reduce((l,u)=>l+(y.get(u.id)??0),0)/n.nodes.length,F=w.length===0?$:w.reduce((l,u)=>l+u,0)/w.length,te=new Set(n.nodes.filter(l=>l.entityType==="project").map(l=>l.entityId)),O=new Set(n.nodes.filter(l=>l.entityType==="task").map(l=>l.entityId)),A=new Set,z=new Set,k=new Set;for(const l of d.targetProjectIds){const u=c.find(v=>v.id===l);if(u&&!te.has(u.id)&&u.status!=="completed"){const v=`project:${u.id}`;A.add(v),z.add(v)}for(const v of x.filter(C=>C.projectId===l))if(!O.has(v.id)&&["focus","in_progress","done","blocked"].includes(v.status)){const C=`task:${v.id}`;A.add(C),v.status==="done"?k.add(C):z.add(C)}}for(const l of d.targetGoalIds)for(const u of x.filter(v=>v.goalId===l))if(!O.has(u.id)&&["focus","in_progress","done","blocked"].includes(u.status)){const v=`task:${u.id}`;A.add(v),u.status==="done"?k.add(v):z.add(v)}const L=Math.max(1,n.nodes.length),J=A.size,K=P.length/L,X=Math.max(0,Math.min(100,Math.round($*100))),q=Math.max(0,Math.min(100,Math.round(100-a.length/L*100))),Z=Math.max(0,Math.min(100,Math.round(100-J/L*100))),W=Math.max(0,Math.min(100,Math.round(Math.max(0,Math.min(1,F*.8+(1-K)*.2))*100))),D=Math.max(0,Math.min(100,Math.round(F*100)));return{alignmentScore:Math.max(0,Math.min(100,Math.round(X*.35+q*.3+Z*.2+W*.15))),planCoverageScore:X,sequencingScore:q,scopeDisciplineScore:Z,qualityScore:W,targetProgressScore:D,completedNodeCount:S.length,startedNodeCount:b.length,readyNodeCount:h.length,totalNodeCount:L,completedTargetCount:w.filter(l=>l>=1).length,totalTargetCount:w.length,offPlanEntityCount:J,offPlanActiveEntityCount:z.size,offPlanCompletedEntityCount:k.size,activeNodeIds:h.slice(0,8),nextNodeIds:h.slice(0,5),blockedNodeIds:P,outOfOrderNodeIds:a}}function Ot({node:s,index:d,total:n,projectsById:m,tasksById:c,usersById:o,allNodes:x,onUpdate:g,onRemove:y}){const{attributes:j,listeners:S,setNodeRef:b,transform:P,transition:a,isDragging:h}=ft({id:s.id}),N=s.entityType==="project"?m.get(s.entityId):c.get(s.entityId),M=N&&"userId"in N&&N.userId?o.get(N.userId)??N.user??null:null,_=x.slice(0,d);return e.jsxs("div",{ref:b,style:{transform:vt.Transform.toString(P),transition:a},className:ce("min-w-0 overflow-hidden rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4 shadow-[var(--ui-shadow-soft)]",h&&"opacity-70"),children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx("button",{type:"button",className:"mt-1 rounded-full bg-[var(--ui-surface-2)] p-2 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",...j,...S,children:e.jsx(gt,{className:"size-4"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:["Step ",d+1]}),e.jsx(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:s.entityType}),N?e.jsx(R,{kind:s.entityType,label:N.title,compact:!0,gradient:!1}):null]}),e.jsx("div",{className:"mt-3 text-base font-medium text-[var(--ui-ink-strong)]",children:(N==null?void 0:N.title)||"Select an entity for this step"}),e.jsx("div",{className:"mt-2 break-words text-sm leading-6 text-[var(--ui-ink-soft)]",children:s.notes||(N&&"description"in N?N.description:"")||"Add an optional note if this phase needs intent or setup context."}),M?e.jsx("div",{className:"mt-3",children:e.jsx(H,{user:M,compact:!0})}):null]})]}),e.jsxs(Q,{type:"button",variant:"secondary",size:"sm",className:"w-full sm:w-auto",disabled:n===1,onClick:()=>y(s.id),children:[e.jsx(ht,{className:"size-4"}),"Remove"]})]}),e.jsxs("div",{className:"mt-4 grid gap-4 xl:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[e.jsx(T,{label:"Relationship to the flow",labelHelp:"Keep the sequence mostly linear in the form. Use parallel when this step should open beside the previous one, or custom only when the dependency is special.",children:e.jsx(Ye,{value:s.dependencyMode,columns:2,onChange:w=>g(s.id,{dependencyMode:w}),options:[{value:"start",label:"Start here",description:"This step opens immediately."},{value:"after_previous",label:"After previous",description:"Use the prior step as the gate."},{value:"parallel_with_previous",label:"Parallel with previous",description:"Open beside the prior branch."},{value:"custom",label:"Custom dependency",description:"Pick earlier steps manually."}]})}),e.jsxs("div",{className:"grid gap-4",children:[e.jsx(T,{label:"Branch label",children:e.jsx(U,{value:s.branchLabel,onChange:w=>g(s.id,{branchLabel:w.target.value}),placeholder:"Core path, fallback lane, support branch"})}),e.jsx(T,{label:"Step note",children:e.jsx(ue,{value:s.notes,onChange:w=>g(s.id,{notes:w.target.value}),placeholder:"Explain what has to be true before or after this step."})})]})]}),s.dependencyMode==="custom"?e.jsxs("div",{className:"mt-4 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:"Depends on"}),e.jsx("div",{className:"mt-3 grid gap-2",children:_.length===0?e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"No earlier steps available yet."}):_.map(w=>{const $=w.entityType==="project"?m.get(w.entityId):c.get(w.entityId);return e.jsxs("label",{className:"flex items-start justify-between gap-3 rounded-[16px] bg-[var(--ui-surface-2)] px-4 py-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:($==null?void 0:$.title)||`Step ${x.indexOf(w)+1}`}),e.jsx("div",{className:"mt-1 text-xs leading-5 text-[var(--ui-ink-soft)]",children:w.branchLabel||w.entityType})]}),e.jsx("input",{type:"checkbox",checked:s.customPredecessorIds.includes(w.id),onChange:()=>g(s.id,{customPredecessorIds:ee(s.customPredecessorIds,w.id)})})]},w.id)})})]}):null]})}const ie="min-h-10 rounded-[var(--radius-control)] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-2 text-sm text-[var(--ui-ink-strong)] outline-none transition focus:border-[color-mix(in_srgb,var(--primary)_34%,transparent)]";function zt({draft:s,setDraft:d,sequenceSearchQuery:n,setSequenceSearchQuery:m,openInlineTaskComposer:c,showInlineTaskComposer:o,setShowInlineTaskComposer:x,inlineTaskDraft:g,setInlineTaskDraft:y,inlineTaskError:j,setInlineTaskError:S,inlineTaskPending:b,submitInlineTask:P,defaultUserId:a,goals:h,projects:N,inlineTaskProjects:M,projectsById:_,tasksById:w,usersById:$,goalsById:F,sequenceEntityKeys:te,hasSequenceQuery:O,hasSequenceResults:A,limitedSequenceGoals:z,limitedSequenceProjects:k,limitedSequenceTasks:L,limitedSuggestedProjects:J,limitedSuggestedTasks:K,appendSequenceNode:X,updateNode:q,removeNode:Z,reorderNodes:W,contractChecks:D,alignmentBreakdown:E}){const l=bt(yt(jt,{activationConstraint:{distance:6}}));return e.jsxs("div",{className:"grid min-w-0 gap-5",children:[e.jsxs("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] px-5 py-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Search and add"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Search goals, projects, tasks, humans, and bots."})]}),e.jsxs(G,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:[s.nodes.length," planned steps"]})]}),e.jsxs("div",{className:"mt-4 flex items-center gap-3 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx(ye,{className:"size-4 text-[var(--ui-ink-faint)]"}),e.jsx(U,{className:"border-none bg-transparent px-0 py-0",value:n,onChange:u=>m(u.target.value),placeholder:"Search goals, projects, tasks, owners, humans, or bots"})]}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsxs(Q,{type:"button",className:"w-full justify-start",variant:"secondary",onClick:c,children:[e.jsx(We,{className:"size-4"}),"Create new task"]}),o?e.jsx(Qt,{inlineTaskDraft:g,setInlineTaskDraft:y,inlineTaskError:j,setInlineTaskError:S,inlineTaskPending:b,setShowInlineTaskComposer:x,submitInlineTask:P,goals:h,projects:N,inlineTaskProjects:M,projectsById:_,defaultUserId:a}):null,e.jsx(Ft,{draft:s,setDraft:d,hasSequenceQuery:O,hasSequenceResults:A,sequenceEntityKeys:te,limitedSequenceGoals:z,limitedSequenceProjects:k,limitedSequenceTasks:L,limitedSuggestedProjects:J,limitedSuggestedTasks:K,appendSequenceNode:X})]})]}),e.jsxs("div",{className:"grid min-w-0 gap-4",children:[e.jsxs("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-5 py-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Sequence"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Keep the flow mostly linear here. When a step should open beside the previous one, switch it to parallel. Use custom only for special joins."})]}),e.jsxs(G,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:[s.nodes.length," planned steps"]})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[s.targetGoalIds.map(u=>{const v=F.get(u);return v?e.jsx(R,{kind:"goal",label:v.title,compact:!0,gradient:!1},u):null}),s.targetProjectIds.map(u=>{const v=_.get(u);return v?e.jsx(R,{kind:"project",label:v.title,compact:!0,gradient:!1},u):null})]})]}),e.jsx(It,{sensors:l,collisionDetection:Nt,onDragEnd:u=>{!u.over||u.active.id===u.over.id||W(String(u.active.id),String(u.over.id))},children:e.jsx(wt,{items:s.nodes.map(u=>u.id),strategy:kt,children:e.jsx("div",{className:"grid gap-3",children:s.nodes.map((u,v)=>e.jsx(Ot,{node:u,index:v,total:s.nodes.length,projectsById:_,tasksById:w,usersById:$,allNodes:s.nodes,onUpdate:q,onRemove:Z},u.id))})})})]}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Contract readiness"}),e.jsx("div",{className:"mt-3 grid gap-2",children:D.map(u=>e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[14px] bg-[var(--ui-surface-1)] px-3 py-2",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:u.label}),e.jsx(G,{className:u.satisfied?"bg-[var(--ui-success-soft)] text-[var(--success)]":"bg-[var(--ui-warning-soft)] text-[var(--warning)]",children:u.satisfied?"Ready":"Missing"})]},u.id))})]}),e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Alignment preview"}),e.jsx("div",{className:"mt-3 grid gap-3",children:E.map(u=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm text-[var(--ui-ink-muted)]",children:[e.jsx("span",{children:u.label}),e.jsxs("span",{children:[u.value,"%"]})]}),e.jsx(Mt,{value:u.value,className:"mt-2"})]},u.id))})]})]})]})}function Qt({inlineTaskDraft:s,setInlineTaskDraft:d,inlineTaskError:n,setInlineTaskError:m,inlineTaskPending:c,setShowInlineTaskComposer:o,submitInlineTask:x,goals:g,projects:y,inlineTaskProjects:j,projectsById:S,defaultUserId:b}){const P=()=>{o(!1),m(null)};return e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:"New task"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Add the task and place it in the sequence."})]}),e.jsx(Q,{type:"button",variant:"secondary",className:"w-full sm:w-auto",onClick:P,children:"Close"})]}),e.jsxs("div",{className:"mt-4 grid gap-4",children:[e.jsx(T,{label:"Task title",children:e.jsx(U,{value:s.title,onChange:a=>d(h=>({...h,title:a.target.value})),placeholder:"Draft the shared strategy hierarchy view"})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(T,{label:"Goal",children:e.jsxs("select",{value:s.goalId,onChange:a=>{const h=a.target.value,N=y.find(M=>M.goalId===h)??null;d(M=>({...M,goalId:h,projectId:(N==null?void 0:N.id)??"",userId:(N==null?void 0:N.userId)??M.userId??b}))},className:ie,children:[e.jsx("option",{value:"",children:"Select goal"}),g.map(a=>e.jsx("option",{value:a.id,children:a.title},a.id))]})}),e.jsx(T,{label:"Project",children:e.jsxs("select",{value:s.projectId,onChange:a=>d(h=>{var N,M;return{...h,projectId:a.target.value,goalId:((N=S.get(a.target.value))==null?void 0:N.goalId)??h.goalId,userId:((M=S.get(a.target.value))==null?void 0:M.userId)??h.userId}}),className:ie,children:[e.jsx("option",{value:"",children:"Select project"}),j.map(a=>e.jsx("option",{value:a.id,children:a.title},a.id))]})})]}),e.jsx(T,{label:"Notes",children:e.jsx(ue,{value:s.description,onChange:a=>d(h=>({...h,description:a.target.value})),placeholder:"Optional detail or acceptance note."})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(T,{label:"Priority",children:e.jsxs("select",{value:s.priority,onChange:a=>d(h=>({...h,priority:a.target.value})),className:ie,children:[e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"high",children:"High"}),e.jsx("option",{value:"critical",children:"Critical"})]})}),e.jsx(T,{label:"Points",children:e.jsx(U,{type:"number",value:s.points,onChange:a=>d(h=>({...h,points:Number(a.target.value)||0}))})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(T,{label:"Effort",children:e.jsxs("select",{value:s.effort,onChange:a=>d(h=>({...h,effort:a.target.value})),className:ie,children:[e.jsx("option",{value:"light",children:"Light"}),e.jsx("option",{value:"deep",children:"Deep"}),e.jsx("option",{value:"extended",children:"Extended"})]})}),e.jsx(T,{label:"Energy",children:e.jsxs("select",{value:s.energy,onChange:a=>d(h=>({...h,energy:a.target.value})),className:ie,children:[e.jsx("option",{value:"calm",children:"Calm"}),e.jsx("option",{value:"steady",children:"Steady"}),e.jsx("option",{value:"intense",children:"Intense"})]})})]}),n?e.jsx("div",{className:"rounded-[18px] border border-[color-mix(in_srgb,var(--danger)_28%,transparent)] bg-[var(--ui-danger-soft)] px-4 py-3 text-sm text-[var(--danger)]",children:n}):null,e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsx(Q,{type:"button",variant:"secondary",className:"w-full sm:w-auto",onClick:P,children:"Cancel"}),e.jsxs(Q,{type:"button",className:"w-full sm:w-auto",pending:c,pendingLabel:"Creating task",onClick:x,children:[e.jsx(We,{className:"size-4"}),"Create task"]})]})]})]})}function Ft({draft:s,setDraft:d,hasSequenceQuery:n,hasSequenceResults:m,sequenceEntityKeys:c,limitedSequenceGoals:o,limitedSequenceProjects:x,limitedSequenceTasks:g,limitedSuggestedProjects:y,limitedSuggestedTasks:j,appendSequenceNode:S}){return n?m?e.jsxs("div",{className:"grid gap-3",children:[o.length>0?e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Goals"}):null,o.map(b=>{const P=s.targetGoalIds.includes(b.id),a=s.linkedEntities.some(h=>h.entityType==="goal"&&h.entityId===b.id);return e.jsx("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(R,{kind:"goal",label:b.title,compact:!0,gradient:!1}),e.jsx(H,{user:b.user,compact:!0})]}),b.description?e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:b.description}):null]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(Q,{type:"button",className:"w-full sm:w-auto",variant:P?"secondary":"primary",onClick:()=>d(h=>({...h,targetGoalIds:ee(h.targetGoalIds,b.id)})),children:P?"Targeted":"Add target"}),e.jsx(Q,{type:"button",className:"w-full sm:w-auto",variant:"secondary",onClick:()=>d(h=>({...h,linkedEntities:Je(h.linkedEntities,{entityType:"goal",entityId:b.id})})),children:a?"Unlink":"Link"})]})]})},b.id)}),x.length>0?e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Projects"}):null,x.map(b=>e.jsx(Ke,{project:b,inSequence:c.has(`project:${b.id}`),appendSequenceNode:S},`sequence-project:${b.id}`)),g.length>0?e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Tasks"}):null,g.map(b=>e.jsx(He,{task:b,inSequence:c.has(`task:${b.id}`),appendSequenceNode:S},`sequence-task:${b.id}`))]}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"No goals, projects, or tasks match this search."}):y.length>0||j.length>0?e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Suggested from targets"}),y.map(b=>e.jsx(Ke,{project:b,inSequence:c.has(`project:${b.id}`),appendSequenceNode:S},`suggested-project:${b.id}`)),j.map(b=>e.jsx(He,{task:b,inSequence:c.has(`task:${b.id}`),appendSequenceNode:S},`suggested-task:${b.id}`))]}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Type to search."})}function Ke({project:s,inSequence:d,appendSequenceNode:n}){return e.jsx("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(R,{kind:"project",label:s.title,compact:!0,gradient:!1}),e.jsx(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:s.goalTitle}),e.jsx(H,{user:s.user,compact:!0})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:s.description||s.goalTitle})]}),e.jsx(Q,{type:"button",className:"w-full sm:w-auto",variant:d?"secondary":"primary",disabled:d,onClick:()=>n("project",s.id),children:d?"In sequence":"Add step"})]})})}function He({task:s,inSequence:d,appendSequenceNode:n}){return e.jsx("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(R,{kind:"task",label:s.title,compact:!0,gradient:!1}),e.jsx(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:s.status}),e.jsx(H,{user:s.user,compact:!0})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:s.description||`${s.owner} · ${s.status}`})]}),e.jsx(Q,{type:"button",className:"w-full sm:w-auto",variant:d?"secondary":"primary",disabled:d,onClick:()=>n("task",s.id),children:d?"In sequence":"Add step"})]})})}function Zt({open:s,pending:d=!1,editingStrategy:n,goals:m,projects:c,tasks:o,habits:x,strategies:g,users:y,defaultUserId:j=null,initialStepId:S,onOpenChange:b,onSubmit:P}){const[a,h]=p.useState(Qe),[N,M]=p.useState(""),[_,w]=p.useState(""),[$,F]=p.useState(""),[te,O]=p.useState(null),[A,z]=p.useState([]),[k,L]=p.useState(V(j,c)),[J,K]=p.useState(!1),[X,q]=p.useState(null),[Z,W]=p.useState(!1);p.useEffect(()=>{var r,i,f;if(!s)return;const t=n?Lt(n):{...Qe,userId:j,nodes:[pe("project",{dependencyMode:"start"})]};h(t),M(""),w(""),F(""),z([]),K(!1),L(V(j,c).projectId&&t.targetProjectIds[0]?{...V(j,c),goalId:((r=c.find(I=>I.id===t.targetProjectIds[0]))==null?void 0:r.goalId)??"",projectId:t.targetProjectIds[0]??((i=c[0])==null?void 0:i.id)??"",userId:((f=c.find(I=>I.id===t.targetProjectIds[0]))==null?void 0:f.userId)??j}:V(j,c)),q(null),O(null)},[j,n,s,c]);const D=p.useDeferredValue(N),E=p.useDeferredValue(_),l=p.useDeferredValue($),u=p.useMemo(()=>{const t=new Set(A.map(r=>r.id));return[...A,...o.filter(r=>!t.has(r.id))]},[A,o]),v=p.useMemo(()=>new Map(m.map(t=>[t.id,t])),[m]),C=p.useMemo(()=>new Map(c.map(t=>[t.id,t])),[c]),se=p.useMemo(()=>new Map(u.map(t=>[t.id,t])),[u]),je=p.useMemo(()=>new Map(y.map(t=>[t.id,t])),[y]),me=y.find(t=>t.id===j)??null,ge=y.find(t=>t.id===a.userId)??me,B=(t,r,i)=>{const f=Dt(t);return f.length===0||Et(r,i).includes(f)},Ie=p.useMemo(()=>m.filter(t=>B(E,[t.title,t.description],t.user)),[E,m]),he=p.useMemo(()=>m.filter(t=>B(D,[t.title,t.description],t.user)),[m,D]),xe=p.useMemo(()=>c.filter(t=>B(D,[t.title,t.description,t.goalTitle,t.status],t.user)),[D,c]),Ne=p.useMemo(()=>c.filter(t=>B(E,[t.title,t.description,t.goalTitle,t.status],t.user)),[E,c]),we=p.useMemo(()=>u.filter(t=>B(E,[t.title,t.description,t.owner,t.status],t.user)),[u,E]),ke=p.useMemo(()=>x.filter(t=>B(E,[t.title,t.description,t.frequency,t.status],t.user)),[E,x]),Se=p.useMemo(()=>g.filter(t=>t.id!==(n==null?void 0:n.id)&&B(E,[t.title,t.overview,t.endStateDescription,t.status],t.user)),[E,n==null?void 0:n.id,g]),fe=p.useMemo(()=>[...Ie.map(r=>({key:`goal:${r.id}`,entityType:"goal",entityId:r.id,label:r.title,description:ae(r.description,r.user,"Goal"),user:r.user??null})),...Ne.map(r=>({key:`project:${r.id}`,entityType:"project",entityId:r.id,label:r.title,description:ae(`${r.goalTitle}${r.goalTitle?" · ":""}${r.status}`,r.user,`Project · ${r.goalTitle}`),user:r.user??null})),...we.map(r=>({key:`task:${r.id}`,entityType:"task",entityId:r.id,label:r.title,description:ae(`${r.status} · ${r.owner}`,r.user,`Task · ${r.owner}`),user:r.user??null})),...ke.map(r=>({key:`habit:${r.id}`,entityType:"habit",entityId:r.id,label:r.title,description:ae(r.description,r.user,"Habit"),user:r.user??null})),...Se.map(r=>({key:`strategy:${r.id}`,entityType:"strategy",entityId:r.id,label:r.title,description:ae(r.overview,r.user,"Strategy"),user:r.user??null}))].sort((r,i)=>r.label.localeCompare(i.label)),[Ie,ke,Ne,Se,we]),Y=p.useMemo(()=>At(a,C,se),[a,C,se]),Ce=p.useMemo(()=>Rt({draft:a,graph:Y,goals:m,projects:c,projectsById:C,tasks:u,tasksById:se}),[u,a,Y,m,c,C,se]),Ze=p.useMemo(()=>[...Ue({title:a.title,overview:a.overview,endStateDescription:a.endStateDescription,targetGoalIds:a.targetGoalIds,targetProjectIds:a.targetProjectIds,graph:Y}),{id:"acyclic",label:"Graph stays directed and non-looping",satisfied:!ze(a.nodes)}],[a.endStateDescription,a.nodes,a.overview,a.targetGoalIds,a.targetProjectIds,a.title,Y]),ve=p.useMemo(()=>$t({title:a.title,overview:a.overview,endStateDescription:a.endStateDescription,targetGoalIds:a.targetGoalIds,targetProjectIds:a.targetProjectIds,graph:Y}),[a.endStateDescription,a.overview,a.targetGoalIds,a.targetProjectIds,a.title,Y]),Ve=p.useMemo(()=>qt(Ce),[Ce]),be=p.useMemo(()=>{if(!a.title.trim())return"Strategy title is required.";if(a.nodes.length===0)return"Add at least one project or task step.";const t=new Set;for(const r of a.nodes){if(!r.entityId)return"Every step needs a linked project or task.";const i=`${r.entityType}:${r.entityId}`;if(t.has(i))return"Each project or task should appear only once in the sequence.";t.add(i)}return ze(a.nodes)?"Strategy graph must stay directed and non-loopy.":null},[a.nodes,a.title]),et=t=>t==="sequence"?te??be??(ve?null:"This can still be saved as a draft. Add the target plus the overview or end state later, then lock it as the contract from the strategy detail page."):null,Me=p.useMemo(()=>m.filter(t=>B(l,[t.title,t.description],t.user)),[m,l]),ne=p.useMemo(()=>c.filter(t=>B(l,[t.title,t.description,t.goalTitle,t.status],t.user)),[c,l]),le=p.useMemo(()=>u.filter(t=>B(l,[t.title,t.description,t.owner,t.status],t.user)),[u,l]),de=p.useMemo(()=>new Set(a.targetGoalIds),[a.targetGoalIds]),oe=p.useMemo(()=>new Set(a.targetProjectIds),[a.targetProjectIds]),tt=p.useMemo(()=>new Set(a.nodes.map(t=>`${t.entityType}:${t.entityId}`)),[a.nodes]),Te=p.useMemo(()=>a.targetGoalIds.map(t=>v.get(t)).filter(t=>!!t),[a.targetGoalIds,v]),Pe=p.useMemo(()=>a.targetProjectIds.map(t=>C.get(t)).filter(t=>!!t),[a.targetProjectIds,C]),Ee=p.useMemo(()=>ne.filter(t=>oe.has(t.id)||de.has(t.goalId)),[ne,de,oe]),Ge=p.useMemo(()=>le.filter(t=>oe.has(t.projectId??"")||de.has(t.goalId??"")),[le,de,oe]),$e=p.useMemo(()=>he.slice(0,8),[he]),qe=p.useMemo(()=>xe.slice(0,8),[xe]),De=p.useMemo(()=>fe.slice(0,12),[fe]),_e=p.useMemo(()=>Me.slice(0,6),[Me]),Le=p.useMemo(()=>ne.slice(0,8),[ne]),Ae=p.useMemo(()=>le.slice(0,10),[le]),st=p.useMemo(()=>Ee.slice(0,4),[Ee]),rt=p.useMemo(()=>Ge.slice(0,6),[Ge]),at=p.useMemo(()=>{if(!k.goalId)return c;const t=c.filter(r=>r.goalId===k.goalId);return t.length>0?t:c},[k.goalId,c]),it=l.length>0,nt=_e.length>0||Le.length>0||Ae.length>0,lt=(t,r)=>{h(i=>({...i,nodes:i.nodes.map(f=>f.id===t?{...f,...r}:f)}))},Be=(t,r)=>{a.nodes.some(i=>i.entityType===t&&i.entityId===r)||h(i=>({...i,nodes:[...i.nodes,pe(t,{entityId:r,dependencyMode:i.nodes.length===0?"start":"after_previous"})]}))},dt=t=>{h(r=>{const i=r.nodes.filter(f=>f.id!==t);return{...r,nodes:i.map((f,I)=>({...f,dependencyMode:I===0&&f.dependencyMode==="after_previous"?"start":f.dependencyMode,customPredecessorIds:f.customPredecessorIds.filter(re=>re!==t)}))}})},ot=(t,r)=>{h(i=>{const f=i.nodes.findIndex(re=>re.id===t),I=i.nodes.findIndex(re=>re.id===r);return f<0||I<0?i:{...i,nodes:St(i.nodes,f,I)}})},ct=()=>{const t=$.trim(),r=a.targetProjectIds.map(I=>C.get(I)).find(I=>!!I)??C.get(k.projectId)??c[0]??null,i=(r==null?void 0:r.goalId)??a.targetGoalIds[0]??"",f=c.find(I=>I.goalId===i&&(r?I.id===r.id:!0))??c.find(I=>I.goalId===i)??r;L(I=>({...V(j,c),title:t||I.title,description:I.description,goalId:i,projectId:(f==null?void 0:f.id)??I.projectId,userId:(f==null?void 0:f.userId)??I.userId??j})),q(null),K(!0)},ut=async()=>{const t=C.get(k.projectId);if(!k.title.trim()){q("Task title is required.");return}if(!t){q("Pick a project for the new task.");return}W(!0),q(null);try{const r=je.get(k.userId??t.userId??"")??t.user??ge??me,i=(await Tt({title:k.title.trim(),description:k.description.trim(),level:"task",owner:(r==null?void 0:r.displayName)??"Albert",userId:k.userId??t.userId??a.userId,assigneeUserIds:[],goalId:t.goalId,projectId:t.id,parentWorkItemId:null,priority:k.priority,status:"focus",effort:k.effort,energy:k.energy,dueDate:"",points:k.points,plannedDurationSeconds:86400,aiInstructions:"",executionMode:null,acceptanceCriteria:[],blockerLinks:[],completionReport:null,gitRefs:[],tagIds:[],notes:[]})).task;z(f=>[i,...f]),Be("task",i.id),L({...V(j,c),goalId:t.goalId,projectId:t.id,userId:i.userId??t.userId??a.userId}),F(""),K(!1)}catch(r){q(r instanceof Error?r.message:"Task creation failed.")}finally{W(!1)}},pt=async()=>{if(be){O(be);return}try{await P({title:a.title.trim(),overview:a.overview.trim(),endStateDescription:a.endStateDescription.trim(),status:a.status,userId:a.userId,targetGoalIds:a.targetGoalIds,targetProjectIds:a.targetProjectIds,linkedEntities:a.linkedEntities,graph:Y},n==null?void 0:n.id),O(null),b(!1)}catch(t){O(t instanceof Error?t.message:"Strategy save failed.")}},mt=[{id:"foundation",eyebrow:"Foundation",title:"Set the owner and the strategic frame",description:"Start with who owns the strategy, what the plan is called, and whether this should open as active, paused, or already landed.",render:(t,r)=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_minmax(16rem,0.8fr)]",children:[e.jsx(T,{label:"Strategy title",children:e.jsx(U,{value:t.title,onChange:i=>r({title:i.target.value}),placeholder:"Land the multi-user planning system"})}),e.jsx(T,{label:"Status",children:e.jsx(Ye,{value:t.status,onChange:i=>r({status:i}),options:[{value:"active",label:"Active",description:"Use this when the plan should drive work now."},{value:"paused",label:"Paused",description:"Keep the strategy visible without active pressure."},{value:"completed",label:"Completed",description:"The end state is already landed."}]})})]}),e.jsx(Pt,{value:t.userId,users:y,onChange:i=>r({userId:i}),label:"Owner user",defaultLabel:Gt(me),help:"Strategies can belong to a human or a bot even when the sequence spans multiple owners."}),e.jsxs("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-accent-soft)] px-5 py-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Live posture"}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx(R,{kind:"strategy",label:t.title.trim()||"Untitled strategy",compact:!0,gradient:!1}),e.jsx(G,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-strong)]",children:t.status}),ge?e.jsx(H,{user:ge,compact:!0}):null]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"This flow is built to keep strategy creation as guided as the other major entities in Forge: clear questions first, then a focused sequence stage at the end."})]})]})},{id:"objective",eyebrow:"Objective",title:"Define the objective and the end targets",description:"Capture what this strategy is coordinating, what done looks like, and which goals or projects are the real targets.",render:(t,r)=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsx(T,{label:"Overview",children:e.jsx(ue,{value:t.overview,onChange:i=>r({overview:i.target.value}),placeholder:"Explain what this strategy is coordinating and why it matters right now."})}),e.jsx(T,{label:"End state",children:e.jsx(ue,{value:t.endStateDescription,onChange:i=>r({endStateDescription:i.target.value}),placeholder:"Describe what reality should look like when this strategy lands."})})]}),e.jsxs("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] px-5 py-5",children:[e.jsx(T,{label:"Search goals or projects",description:"Keep this page search-first. Add only the targets that truly define what this strategy is trying to land.",children:e.jsxs("div",{className:"flex items-center gap-3 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx(ye,{className:"size-4 text-[var(--ui-ink-faint)]"}),e.jsx(U,{className:"border-none bg-transparent px-0 py-0",value:N,onChange:i=>M(i.target.value),placeholder:"Search goals, projects, owners, humans, or bots"})]})}),e.jsxs("div",{className:"mt-5 grid gap-4 xl:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Selected goals"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:Te.length===0?e.jsx(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:"No target goals yet"}):Te.map(i=>e.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-full bg-[var(--ui-accent-soft)] px-3 py-1.5 text-sm text-[var(--ui-ink-strong)] transition hover:bg-[var(--ui-accent-soft-hover)]",onClick:()=>r({targetGoalIds:ee(t.targetGoalIds,i.id)}),children:[e.jsx(R,{kind:"goal",label:i.title,compact:!0,gradient:!1}),e.jsx("span",{children:"Remove"})]},i.id))})]}),e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Selected projects"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:Pe.length===0?e.jsx(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:"No target projects yet"}):Pe.map(i=>e.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-full bg-[var(--ui-accent-soft)] px-3 py-1.5 text-sm text-[var(--ui-ink-strong)] transition hover:bg-[var(--ui-accent-soft-hover)]",onClick:()=>r({targetProjectIds:ee(t.targetProjectIds,i.id)}),children:[e.jsx(R,{kind:"project",label:i.title,compact:!0,gradient:!1}),e.jsx("span",{children:"Remove"})]},i.id))})]})]})]}),e.jsxs("div",{className:"grid gap-5 xl:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Goal matches"}),D?e.jsxs(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[he.length," found"]}):null]}),e.jsx("div",{className:"mt-3 grid gap-3",children:D?$e.length===0?e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"No goals match this search yet."}):$e.map(i=>{const f=t.targetGoalIds.includes(i.id);return e.jsxs("button",{type:"button",className:ce("rounded-[22px] border px-4 py-4 text-left transition",f?"border-[color-mix(in_srgb,var(--primary)_30%,transparent)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)]"),onClick:()=>r({targetGoalIds:ee(t.targetGoalIds,i.id)}),children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center justify-between gap-2",children:[e.jsx(Re,{kind:"goal",label:i.title,className:"max-w-full min-w-0"}),e.jsx(H,{user:i.user,compact:!0})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:i.description||"No strategic note attached yet."})]},i.id)}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Search for the goal this strategy is meant to land."})})]}),e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Project matches"}),D?e.jsxs(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[xe.length," found"]}):null]}),e.jsx("div",{className:"mt-3 grid gap-3",children:D?qe.length===0?e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"No projects match this search yet."}):qe.map(i=>{const f=t.targetProjectIds.includes(i.id);return e.jsxs("button",{type:"button",className:ce("rounded-[22px] border px-4 py-4 text-left transition",f?"border-[color-mix(in_srgb,var(--primary)_30%,transparent)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)]"),onClick:()=>r({targetProjectIds:ee(t.targetProjectIds,i.id)}),children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center justify-between gap-2",children:[e.jsx(Re,{kind:"project",label:i.title,className:"max-w-full min-w-0",showIcon:!1}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:i.goalTitle}),e.jsx(H,{user:i.user,compact:!0})]})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:i.description||"No project summary attached yet."})]},i.id)}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Search for the concrete project this strategy should land or organize."})})]})]})]})},{id:"context",eyebrow:"Context",title:"Keep the right supporting entities in view",description:"Linked entities stay visible in the strategy context without becoming part of the main execution sequence.",render:(t,r)=>e.jsxs(e.Fragment,{children:[e.jsx(T,{label:"Search supporting context",description:"Search across goals, projects, tasks, habits, and other strategies.",children:e.jsxs("div",{className:"flex items-center gap-3 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx(ye,{className:"size-4 text-[var(--ui-ink-faint)]"}),e.jsx(U,{className:"border-none bg-transparent px-0 py-0",value:_,onChange:i=>w(i.target.value),placeholder:"Search by title, owner, @handle, human, or bot"})]})}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.linkedEntities.length===0?e.jsx(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:"No extra linked context yet"}):t.linkedEntities.map(i=>{const f=fe.find(I=>I.entityType===i.entityType&&I.entityId===i.entityId);return e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 rounded-full bg-[var(--ui-accent-soft)] px-3 py-1.5 text-sm text-[var(--ui-ink-medium)] transition hover:bg-[var(--ui-accent-soft-hover)]",onClick:()=>r({linkedEntities:t.linkedEntities.filter(I=>!(I.entityType===i.entityType&&I.entityId===i.entityId))}),children:[e.jsx(xt,{className:"mr-1 size-3.5"}),(f==null?void 0:f.label)??`${i.entityType}:${i.entityId}`,e.jsx("span",{children:"Remove"})]},`${i.entityType}:${i.entityId}`)})}),e.jsx("div",{className:"grid gap-3",children:E?De.length===0?e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"No supporting entities match this search yet."}):De.map(i=>{const f=t.linkedEntities.some(I=>I.entityType===i.entityType&&I.entityId===i.entityId);return e.jsxs("label",{className:ce("flex items-start justify-between gap-3 rounded-[20px] border px-4 py-4",f?"border-[color-mix(in_srgb,var(--primary)_28%,transparent)] bg-[var(--ui-accent-soft)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]"),children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(R,{kind:i.entityType,label:i.label,compact:!0,gradient:!1}),i.user?e.jsx(H,{user:i.user,compact:!0}):null]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:i.description})]}),e.jsx("input",{type:"checkbox",checked:f,onChange:()=>r({linkedEntities:Je(t.linkedEntities,{entityType:i.entityType,entityId:i.entityId})})})]},i.key)}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Search when you want to pull another entity into the background context. This keeps the page focused instead of dumping every record into one long list."})})]})},{id:"sequence",eyebrow:"Sequence",title:"Build the execution sequence",description:"Search, add steps, and create missing tasks.",render:()=>e.jsx(zt,{draft:a,setDraft:h,sequenceSearchQuery:$,setSequenceSearchQuery:F,openInlineTaskComposer:ct,showInlineTaskComposer:J,setShowInlineTaskComposer:K,inlineTaskDraft:k,setInlineTaskDraft:L,inlineTaskError:X,setInlineTaskError:q,inlineTaskPending:Z,submitInlineTask:()=>void ut(),defaultUserId:j,goals:m,projects:c,inlineTaskProjects:at,projectsById:C,tasksById:se,usersById:je,goalsById:v,sequenceEntityKeys:tt,hasSequenceQuery:it,hasSequenceResults:nt,limitedSequenceGoals:_e,limitedSequenceProjects:Le,limitedSequenceTasks:Ae,limitedSuggestedProjects:st,limitedSuggestedTasks:rt,appendSequenceNode:Be,updateNode:lt,removeNode:dt,reorderNodes:ot,contractChecks:Ze,alignmentBreakdown:Ve})}];return e.jsx(Ct,{open:s,onOpenChange:b,eyebrow:"Strategy",title:n?"Edit strategy":"Create strategy",description:"Strategies connect goals, projects, and tasks into a guided multi-step plan with a focused sequence builder at the end.",value:a,onChange:h,draftPersistenceKey:n?`strategy.${n.id}`:"strategy.new",steps:mt,initialStepId:S,contentClassName:"lg:h-[min(56rem,calc(100vh-1rem))] lg:w-[min(78rem,calc(100vw-1.5rem))]",submitLabel:n?ve?"Save strategy":"Save draft":ve?"Create strategy":"Create draft",pending:d,pendingLabel:"Saving strategy",resolveError:et,onSubmit:pt})}export{Zt as S,Ue as a,qt as b,$t as i};
@@ -1 +1 @@
1
- import{j as r}from"./vendor-BwL6m4SE.js";import{c as i}from"./index-izRKx6JK.js";function s({className:e,interactive:a=!1,muted:t=!1,...n}){return r.jsx("div",{className:i("min-w-0 max-w-full rounded-[22px] border border-[var(--ui-border-subtle)] p-4",t?"bg-[var(--ui-surface-2)]":"bg-[var(--ui-surface-1)]",a&&"transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]",e),...n})}function c({label:e,value:a,className:t}){return r.jsxs(s,{className:i("min-w-0 overflow-hidden rounded-[18px] p-3",t),children:[r.jsx("div",{className:"min-w-0 text-wrap text-[10px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)] [overflow-wrap:anywhere]",children:e}),r.jsx("div",{className:"mt-1 min-w-0 text-wrap text-lg font-semibold text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:a})]})}export{s as S,c as a};
1
+ import{j as r}from"./vendor-B7FKSwHK.js";import{c as i}from"./index-gmPaoLN-.js";function s({className:e,interactive:a=!1,muted:t=!1,...n}){return r.jsx("div",{className:i("min-w-0 max-w-full rounded-[22px] border border-[var(--ui-border-subtle)] p-4",t?"bg-[var(--ui-surface-2)]":"bg-[var(--ui-surface-1)]",a&&"transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]",e),...n})}function c({label:e,value:a,className:t}){return r.jsxs(s,{className:i("min-w-0 overflow-hidden rounded-[18px] p-3",t),children:[r.jsx("div",{className:"min-w-0 text-wrap text-[10px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)] [overflow-wrap:anywhere]",children:e}),r.jsx("div",{className:"mt-1 min-w-0 text-wrap text-lg font-semibold text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:a})]})}export{s as S,c as a};
@@ -1,4 +1,4 @@
1
- import{r as j}from"./vendor-BwL6m4SE.js";/**
1
+ import{r as j}from"./vendor-B7FKSwHK.js";/**
2
2
  * table-core
3
3
  *
4
4
  * Copyright (c) TanStack
@@ -0,0 +1 @@
1
+ import{bv as xe,aL as ze,ba as Ke,cb as is,bG as rs,j as e,aC as A,b3 as Pe,b_ as ns,b7 as ls,r as y,cc as cs,aV as ue,aG as ds,bp as os,cx as us,aP as Ee,b4 as ms,bE as xs}from"./vendor-B7FKSwHK.js";import{j as ps,i as J,k as w}from"./state-BFyKSULP.js";import{c as q,ad as Ue,b as X,j as i,u as gs,d as hs,S as vs,e as Me,a2 as fs,E as Re,C as ks,B as k,z as T,y as me,K as Fe,aJ as bs,i as js,ee as Ns,ef as ys,X as ws,an as Ss,ao as Ts,R as As,r as Cs,ap as Is,W as $s,eg as _s,Y as Oe,Z as Ds}from"./index-gmPaoLN-.js";import{a as Ps,T as Es}from"./timebox-planning-dialog-C6h0Hp71.js";import{O as Ms}from"./open-in-graph-button-DFQ4r6SN.js";import{N as Y}from"./note-markdown-CG8u2d6p.js";import{E as Rs}from"./entity-notes-surface-DPsJwqQa.js";import{P as Fs}from"./preference-entity-handoff-button-cPrTpHsV.js";import{TaskDialog as Os}from"./task-dialog-2wy0xI7f.js";import{g as Ls,e as Bs,W as qs}from"./calendar-rules-BGIBuEDk.js";import{P as zs}from"./page-hero-U603l9rQ.js";import{U as Le}from"./user-badge-C4eZu1e_.js";import{g as Ks,a as Us}from"./activity-copy-Bj4h9OcF.js";import{g as Be,a as qe}from"./entity-links-DwpxhW2H.js";import{g as Ws}from"./user-ownership-DJGl4rAj.js";import"./motion-BibSzp57.js";import"./ui-uo_bNP7c.js";import"./board-DprRipIG.js";import"./forms-ByKjodjN.js";import"./scheduling-rules-editor-De72IUax.js";import"./question-flow-dialog-yMYVk998.js";import"./calendar-ui-Cy1XRwzV.js";import"./note-tags-input-D_conqDO.js";import"./entity-link-multiselect-BfDAROHB.js";import"./use-anchored-overlay-position-BSxFX6Hi.js";import"./goal-dialog-nkdME5Uy.js";import"./inline-note-fields-BvQwmMAv.js";import"./user-select-field-CmKwcbZt.js";import"./schemas-BlFy-uPR.js";import"./project-dialog-B2_PcXAf.js";const Z=[{status:"backlog",label:"Backlog",description:"Not started yet.",icon:xe},{status:"focus",label:"Focus",description:"Ready to start soon.",icon:ze},{status:"in_progress",label:"In progress",description:"Work is active now.",icon:Ke},{status:"blocked",label:"Blocked",description:"Something is stopping progress.",icon:is},{status:"done",label:"Done",description:"The task is completed.",icon:rs}],Qs={issue:{label:"Issue",noun:"issue",descriptor:"Vertical slice issue",heroDescription:"Track the vertical slice, keep the acceptance bar explicit, and surface the execution context without losing the product-level story."},task:{label:"Task",noun:"task",descriptor:"AI session task",heroDescription:"Drive one focused AI execution session, keep the work contract crisp, and show the concrete evidence of what changed."},subtask:{label:"Subtask",noun:"subtask",descriptor:"Granular child step",heroDescription:"Keep the child step sharply scoped, trace its parent chain, and make the work evidence visible without opening the editor."}},Gs={commit:{label:"Commit",className:"bg-emerald-500/12 text-emerald-100"},branch:{label:"Branch",className:"bg-sky-500/12 text-sky-100"},pull_request:{label:"Pull request",className:"bg-fuchsia-500/12 text-fuchsia-100"}};function pe(a){return a==="issue"?"issue":"task"}function Hs(a,o){switch(a){case"goal":return`/goals/${o}`;case"project":return`/projects/${o}`;case"task":return`/tasks/${o}`;case"strategy":return`/strategies/${o}`;case"habit":return"/habits";default:return null}}function D(a){if(!a||a<=0)return"0 min";if(a<3600)return`${Math.max(1,Math.round(a/60))} min`;const o=Math.floor(a/3600),u=Math.round(a%3600/60);return u===0?`${o} h`:`${o} h ${u} min`}function x({label:a,help:o}){return e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx("span",{children:a}),o?e.jsx(Ue,{content:o,label:`Explain ${a}`}):null]})}function P({eyebrow:a,title:o,description:u,children:c,className:p}){return e.jsxs("div",{className:q("min-w-0 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4 sm:p-5",p),children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:a}),e.jsx("div",{className:"mt-2 text-lg font-medium text-[var(--ui-ink-strong)]",children:o}),u?e.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:u}):null,e.jsx("div",{className:"mt-4",children:c})]})}function h({label:a,value:o,hint:u,className:c}){return e.jsxs("div",{className:q("min-w-0 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3",c),children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:a}),e.jsx("div",{className:"mt-2 text-base font-medium text-[var(--ui-ink-strong)]",children:o}),u?e.jsx("div",{className:"mt-1 text-sm leading-5 text-[var(--ui-ink-faint)]",children:u}):null]})}function Vs({payload:a,relatedWorkItems:o,availableTags:u,workItemMeta:c,taskLevel:p,hasAiBrief:v,botOwner:ee,formatDate:b,formatDateTime:C}){const E=a.task.parentWorkItemId?o.find(l=>l.id===a.task.parentWorkItemId)??null:null,M=o.filter(l=>l.parentWorkItemId===a.task.id).sort((l,j)=>l.sortOrder-j.sortOrder),z=(a.task.tagIds??[]).map(l=>u.find(j=>j.id===l)??null).filter(l=>!!l),R=a.task.blockerLinks??[];return e.jsxs("div",{className:"mt-5 grid gap-4 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,1fr)_minmax(0,1fr)]",children:[e.jsx(P,{eyebrow:"Hierarchy",title:"Context map",description:`See where this ${c.noun} sits in the larger planning ladder without opening the board.`,children:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{children:[e.jsx(x,{label:"Project",help:`The project is the main work stream this ${c.noun} belongs to.`}),e.jsx("div",{className:"mt-2",children:a.project?e.jsx(A,{to:`/projects/${a.project.id}`,className:"inline-flex max-w-full",children:e.jsx(X,{kind:"project",label:a.project.title,compact:!0,gradient:!1,wrap:!0,className:"max-w-full"})}):e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-soft)]",children:"No project linked"})})]}),e.jsxs("div",{children:[e.jsx(x,{label:"Goal",help:"The goal shows the longer-term result this work supports."}),e.jsx("div",{className:"mt-2",children:a.goal?e.jsx(A,{to:`/goals/${a.goal.id}`,className:"inline-flex max-w-full",children:e.jsx(X,{kind:"goal",label:a.goal.title,compact:!0,gradient:!1,wrap:!0,className:"max-w-full"})}):e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-soft)]",children:"No goal linked"})})]}),e.jsxs("div",{children:[e.jsx(x,{label:"Parent item",help:"Issues parent tasks, tasks parent subtasks, and split child items stay legible here."}),e.jsx("div",{className:"mt-2",children:E?e.jsx(A,{to:`/tasks/${E.id}`,className:"inline-flex max-w-full",children:e.jsx(X,{kind:pe(E.level),label:E.title,compact:!0,gradient:!1,wrap:!0,className:"max-w-full"})}):e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-soft)]",children:"No parent work item"})})]}),e.jsxs("div",{children:[e.jsx(x,{label:"Child items",help:"Child work items let you scan the next layer down without leaving the detail view."}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:M.length>0?M.map(l=>e.jsx(A,{to:`/tasks/${l.id}`,className:"inline-flex max-w-full",children:e.jsx(X,{kind:pe(l.level),label:l.title,compact:!0,gradient:!1,wrap:!0,className:"max-w-full"})},l.id)):e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-soft)]",children:"No child work items"})})]})]})}),e.jsx(P,{eyebrow:"Execution",title:"Execution profile",description:"Surface the operating mode, AI posture, tags, and blockers as a single readable brief.",children:e.jsxs("div",{className:"grid gap-3",children:[e.jsx(h,{label:"Work-item type",value:c.descriptor,hint:p==="task"?"Tasks are meant to fit one focused AI session.":p==="issue"?"Issues hold the vertical slice and its delivery contract.":"Subtasks stay intentionally small and concrete."}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(h,{label:"Execution mode",value:a.task.executionMode?a.task.executionMode.toUpperCase():"Not set"}),e.jsx(h,{label:"AI posture",value:v?"AI brief ready":p==="issue"?"Issue narrative only":"Needs AI brief"})]}),e.jsxs("div",{children:[e.jsx(x,{label:"Tags",help:"Tags shape filtering and fast scanning across the board and hierarchy views."}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:z.length>0?z.map(l=>e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:l.name},l.id)):e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-soft)]",children:"No tags"})})]}),e.jsxs("div",{children:[e.jsx(x,{label:"Blockers",help:"Blockers tie this work item to the entities that currently constrain it."}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:R.length>0?R.map(l=>{const j=Hs(l.entityType,l.entityId),K=e.jsx(i,{wrap:!0,className:"bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]",children:l.label??`${l.entityType} · ${l.entityId}`},`${l.entityType}:${l.entityId}`);return j?e.jsx(A,{to:j,className:"inline-flex max-w-full",children:K},`${l.entityType}:${l.entityId}`):K}):e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-soft)]",children:"No blockers linked"})})]})]})}),e.jsx(P,{eyebrow:"People and timing",title:"Accountability surface",description:"Show who owns the work, who is helping, and when the record moved.",children:e.jsxs("div",{className:"grid gap-3",children:[e.jsx(h,{label:"Owner",value:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.task.user?e.jsx(Le,{user:a.task.user,compact:!0}):null,e.jsx("span",{children:a.task.owner}),ee?e.jsxs(i,{className:"bg-[var(--ui-accent-soft)] text-[var(--tertiary)]",children:[e.jsx(Pe,{className:"mr-1 size-3.5"}),"Bot owner"]}):null]})}),e.jsxs("div",{children:[e.jsx(x,{label:"Assignees"}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:a.task.assignees&&a.task.assignees.length>0?a.task.assignees.map(l=>e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-1.5 text-sm text-[var(--ui-ink-medium)]",children:[e.jsx(Le,{user:l,compact:!0}),e.jsx("span",{children:l.displayName}),l.kind==="bot"?e.jsx(Pe,{className:"size-3.5 text-[var(--tertiary)]"}):null]},l.id)):e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-soft)]",children:"No assignees"})})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(h,{label:"Due date",value:b(a.task.dueDate),hint:`Use due dates only when timing materially matters for this ${c.noun}.`}),e.jsx(h,{label:"Completed",value:a.task.completedAt?C(a.task.completedAt):"Not completed"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(h,{label:"Created",value:C(a.task.createdAt)}),e.jsx(h,{label:"Updated",value:C(a.task.updatedAt)})]})]})})]})}function Tt(){var Se,Te,Ae,Ce,Ie,$e,_e;const{t:a,formatDate:o,formatDateTime:u}=gs(),c=hs(),p=Array.isArray(c.selectedUserIds)?c.selectedUserIds:[],v=ns(),ee=ls(),b=ps(),C=Ws(p),[E,M]=y.useState(!1),[z,R]=y.useState(!1),[l,j]=y.useState(!1),[K,ge]=y.useState(!1),[We,se]=y.useState(!1),[Qe,U]=y.useState(null),[W,Ge]=y.useState(()=>typeof window<"u"?window.matchMedia("(max-width: 1023px)").matches:!1),[te]=y.useState(()=>{const s=new Date,r=new Date(s);r.setHours(0,0,0,0);const n=new Date(s);return n.setHours(23,59,59,999),{from:r.toISOString(),to:n.toISOString()}}),[F]=y.useState(()=>{const s=new Date,r=new Date(s);r.setHours(0,0,0,0);const n=new Date(r);return n.setDate(n.getDate()+7),n.setHours(23,59,59,999),{from:r.toISOString(),to:n.toISOString()}});y.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const s=window.matchMedia("(max-width: 1023px)"),r=n=>Ge(n?n.matches:s.matches);return r(),typeof s.addEventListener=="function"?(s.addEventListener("change",r),()=>s.removeEventListener("change",r)):(s.addListener(r),()=>s.removeListener(r))},[]);const $=J({queryKey:["task-context",v.taskId],queryFn:()=>_s(v.taskId),enabled:!!v.taskId}),He=J({queryKey:["task-calendar-overview",v.taskId,te.from,te.to,...p],queryFn:()=>Oe({...te,userIds:p}),enabled:!!v.taskId}),I=J({queryKey:["forge-life-force",...p],queryFn:async()=>(await Ds(p)).lifeForce}),Ve=J({queryKey:["task-calendar-overview",v.taskId,F.from,F.to,...p],queryFn:()=>Oe({...F,userIds:p}),enabled:!!v.taskId}),N=async()=>{await Promise.all([js(b),b.invalidateQueries({queryKey:["task-context",v.taskId]}),b.invalidateQueries({queryKey:["activity-archive"]}),b.invalidateQueries({queryKey:["project-board"]}),b.invalidateQueries({queryKey:["forge-xp-metrics"]}),b.invalidateQueries({queryKey:["forge-reward-ledger"]}),b.invalidateQueries({queryKey:["forge-operator-context"]}),b.invalidateQueries({queryKey:["task-calendar-overview",v.taskId]}),b.invalidateQueries({queryKey:["forge-calendar-overview"]})])},Q=w({mutationFn:({taskId:s,patch:r})=>c.patchTask(s,r),onSuccess:N}),Je=w({mutationFn:s=>Ss(s),onSuccess:N}),Xe=w({mutationFn:s=>Cs(s),onSuccess:N}),he=w({mutationFn:({runId:s,actor:r,note:n})=>Ns(s,{actor:r,note:n??""}),onSuccess:N}),ve=w({mutationFn:({runId:s,actor:r,note:n})=>ys(s,{actor:r,note:n??""}),onSuccess:N}),ae=w({mutationFn:Is,onSuccess:N}),fe=w({mutationFn:s=>Ts(s),onSuccess:N}),ie=w({mutationFn:ws,onSuccess:N}),ke=w({mutationFn:({timeboxId:s,patch:r})=>As(s,r),onSuccess:N}),Ye=w({mutationFn:$s,onSuccess:N}),t=$.data;if($.isLoading)return e.jsx(vs,{});if($.isError)return e.jsx(Me,{eyebrow:a("common.taskDetail.errorEyebrow"),error:$.error,onRetry:()=>void $.refetch()});if(!t)return e.jsx(Me,{eyebrow:a("common.taskDetail.errorEyebrow"),error:new Error(a("common.taskDetail.emptyPayload")),onRetry:()=>void $.refetch()});const f=t.activeTaskRun??null,m=t.task.actionPointSummary??null,be=Z.find(s=>s.status===t.task.status)??Z[0],re=t.task.level??"task",je=t.task.aiInstructions??"",Ze=Ls(t.task,(Se=t.project)==null?void 0:Se.schedulingRules),_=Bs({rules:Ze,overview:(Te=He.data)==null?void 0:Te.calendar}),G=(((Ae=Ve.data)==null?void 0:Ae.calendar.timeboxes)??[]).filter(s=>s.taskId===t.task.id).sort((s,r)=>Date.parse(s.startsAt)-Date.parse(r.startsAt)),ne=G[0]??null,g=Qs[re],le=pe(re),es=c.snapshot.workItems??c.snapshot.tasks??[],ss=c.snapshot.tags??[],ce=t.task.acceptanceCriteria??[],H=t.task.gitRefs??[],d=t.task.completionReport,Ne=new Set((d==null?void 0:d.linkedGitRefIds)??[]),de=H.filter(s=>Ne.has(s.id)),ye=H.filter(s=>!Ne.has(s.id)),oe=((Ce=t.task.user)==null?void 0:Ce.kind)==="bot"||((Ie=t.task.ownerUser)==null?void 0:Ie.kind)==="bot",O=(t.task.assignees??[]).filter(s=>s.kind==="bot"),V=je.trim().length>0,S=W?"w-full justify-start":"",ts=s=>{switch(s){case"active":return"Active";case"completed":return"Completed";case"released":return"Paused";case"timed_out":return"Timed out";default:return s}},we=async s=>{await c.patchTaskStatus(t.task.id,s),await N(),se(!1)},as=async()=>{window.confirm(`Delete ${g.noun} "${t.task.title}"?`)&&(await fe.mutateAsync(t.task.id),ee(t.project?`/projects/${t.project.id}`:t.goal?`/goals/${t.goal.id}`:"/kanban"))};return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(zs,{entityKind:le,title:e.jsx(Re,{kind:le,label:t.task.title,variant:"heading",size:"lg",lines:3,className:"max-w-full",labelClassName:"[overflow-wrap:anywhere]"}),titleText:t.task.title,description:t.task.description?e.jsx(Y,{markdown:t.task.description,className:"[&>p]:text-[13px] [&>p]:leading-6 [&>blockquote]:text-[13px] [&>ul]:text-[13px] [&>ol]:text-[13px]"}):g.heroDescription,badge:m?`${t.task.points} xp · ${Math.round(m.totalCostAp)} AP`:`${t.task.points} xp`,actions:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(fs,{metrics:c.snapshot.metrics}),e.jsx(Fs,{userId:C,domain:"tasks",entityType:"task",entityId:t.task.id,label:t.task.title,description:t.task.description}),e.jsx(Ms,{entityType:"task",entityId:t.task.id})]})}),e.jsxs(ks,{className:"min-w-0 overflow-hidden",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:g.label}),e.jsx("div",{className:"mt-2",children:e.jsx(Re,{kind:le,label:t.task.title,variant:"heading",size:"xl",lines:3,className:"max-w-full",labelClassName:"[overflow-wrap:anywhere]"})}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:t.task.description?e.jsx(Y,{markdown:t.task.description,className:"[&>p]:text-sm [&>p]:leading-6 [&>blockquote]:text-sm [&>ul]:text-sm [&>ol]:text-sm"}):`This page shows the ${g.noun}, where it belongs, what is driving it, and the concrete evidence of what has happened on it so far.`})]}),e.jsx("div",{className:q("shrink-0",W?"w-full":""),children:e.jsxs("div",{className:q("flex flex-wrap items-center gap-2",W&&"grid w-full grid-cols-1"),children:[e.jsxs(k,{className:S,pending:$.isFetching,pendingLabel:f?"Opening":"Starting",onClick:async()=>{await c.startTaskNow(t.task.id),await N()},children:[e.jsx(Ke,{className:"size-4 fill-current"}),f?"Focus work":"Start work"]}),f?e.jsxs(e.Fragment,{children:[e.jsx(k,{className:S,variant:"secondary",pending:he.isPending,pendingLabel:"Pausing",onClick:async()=>{await he.mutateAsync({runId:f.id,actor:f.actor,note:f.note})},children:"Pause"}),e.jsx(k,{className:S,variant:"secondary",pending:ve.isPending,pendingLabel:"Completing",onClick:async()=>{await ve.mutateAsync({runId:f.id,actor:f.actor,note:f.note})},children:"Complete"})]}):null,e.jsxs(k,{className:S,variant:"secondary",onClick:()=>se(!0),children:[e.jsx(be.icon,{className:"size-4"}),"Change status"]}),e.jsxs(k,{className:S,variant:"secondary",onClick:()=>M(!0),children:[e.jsx(cs,{className:"size-4"}),"Edit ",g.noun]}),e.jsxs(k,{className:S,variant:"secondary",onClick:()=>R(!0),children:[e.jsx(xe,{className:"size-4"}),"Adjust work"]}),e.jsxs(k,{className:S,variant:"secondary",pending:ie.isPending,pendingLabel:"Planning",onClick:()=>j(!0),children:[e.jsx(ue,{className:"size-4"}),"Time Box"]}),t.task.status==="done"?e.jsx(k,{className:S,variant:"secondary",onClick:async()=>{await Je.mutateAsync(t.task.id)},children:"Mark as not done"}):null,e.jsxs(k,{className:q(S,"text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)] hover:bg-[var(--ui-danger-soft)]"),variant:"ghost",pending:fe.isPending,pendingLabel:a("common.taskDetail.deleting"),onClick:()=>void as(),children:["Delete ",g.noun]})]})})]}),e.jsxs("div",{className:"mt-5 flex flex-wrap gap-2",children:[e.jsx(i,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:g.label}),e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:g.descriptor}),e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:be.label}),e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:a(`common.enums.priority.${t.task.priority}`)}),e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:a(`common.enums.effort.${t.task.effort}`)}),e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:a(`common.enums.energy.${t.task.energy}`)}),e.jsxs(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:[t.task.points," xp"]}),t.task.time.totalCreditedSeconds>0?e.jsxs(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:[Math.floor(t.task.time.totalCreditedSeconds/60)," min tracked"]}):null,f?e.jsx(i,{className:"bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]",children:"Timer active"}):null,t.task.executionMode?e.jsx(i,{className:t.task.executionMode==="afk"?"bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]":"bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]",children:t.task.executionMode.toUpperCase()}):null,V?e.jsx(i,{className:"bg-[var(--ui-accent-soft)] text-[var(--primary)]",children:"AI brief ready"}):null,oe||O.length>0?e.jsx(i,{className:"bg-[var(--ui-accent-soft)] text-[var(--tertiary)]",children:"Bot collaboration live"}):null,ne?e.jsx(A,{to:`/calendar?timeboxId=${encodeURIComponent(ne.id)}`,className:"inline-flex",children:e.jsxs(i,{className:"cursor-pointer bg-[var(--primary)]/16 text-[var(--primary)] transition hover:bg-[var(--primary)]/24",children:["Timeboxed · ",u(ne.startsAt)]})}):null]}),W?null:e.jsxs("div",{className:"mt-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Status"}),e.jsx("div",{className:"mt-3 grid gap-2 md:grid-cols-2 xl:grid-cols-5",children:Z.map(s=>{const r=s.icon,n=s.status===t.task.status;return e.jsxs("button",{type:"button",disabled:n||Q.isPending,className:`rounded-[18px] border px-3.5 py-3 text-left transition ${n?"border-[color-mix(in_srgb,var(--primary)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-3)]"}`,onClick:()=>void we(s.status),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(r,{className:"size-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"font-medium",children:s.label})]}),e.jsx("div",{className:"mt-2 text-xs leading-5 text-[var(--ui-ink-faint)]",children:s.description})]},s.status)})})]}),e.jsx(Vs,{payload:t,relatedWorkItems:es,availableTags:ss,workItemMeta:g,taskLevel:re,hasAiBrief:V,botOwner:oe,formatDate:o,formatDateTime:u}),V||ce.length>0||d||H.length>0?e.jsxs("div",{className:"mt-5 grid gap-4 xl:grid-cols-[minmax(0,1.05fr)_minmax(0,1fr)]",children:[e.jsx(P,{eyebrow:"Execution brief",title:"AI and delivery instructions",description:"The narrative, criteria, and execution intent live together so the detail view can stand on its own.",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx(ds,{className:"size-4 text-[var(--primary)]"}),e.jsx("span",{children:"AI instructions"})]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-medium)]",children:V?e.jsx(Y,{markdown:je,className:"[&>p]:text-sm [&>p]:leading-6 [&>blockquote]:text-sm [&>ul]:text-sm [&>ol]:text-sm"}):`No AI instructions have been written for this ${g.noun} yet.`})]}),e.jsxs("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx(ze,{className:"size-4 text-[var(--success)]"}),e.jsx("span",{children:"Acceptance criteria"})]}),ce.length>0?e.jsx("div",{className:"mt-3 grid gap-2",children:ce.map((s,r)=>e.jsx("div",{className:"rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-medium)]",children:s},`${t.task.id}-criterion-${r}`))}):e.jsx("div",{className:"mt-3 rounded-[16px] border border-dashed border-[var(--ui-border-subtle)] px-4 py-3 text-sm text-[var(--ui-ink-faint)]",children:"No acceptance criteria captured yet."})]})]})}),e.jsx(P,{eyebrow:"Evidence",title:"Work done, changed files, and git traceability",description:"Show the work summary, file footprint, and linked refs directly in the detail view.",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx(os,{className:"size-4 text-[var(--primary)]"}),e.jsx("span",{children:"Work summary"})]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-medium)]",children:d!=null&&d.workSummary?e.jsx(Y,{markdown:d.workSummary,className:"[&>p]:text-sm [&>p]:leading-6 [&>blockquote]:text-sm [&>ul]:text-sm [&>ol]:text-sm"}):"No work summary yet."})]}),e.jsxs("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx(us,{className:"size-4 text-[var(--warning)]"}),e.jsx("span",{children:"Changed files"})]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:d!=null&&d.modifiedFiles&&d.modifiedFiles.length>0?d.modifiedFiles.map(s=>e.jsx(i,{wrap:!0,className:"bg-[var(--ui-surface-3)] font-mono text-[11px] text-[var(--ui-ink-medium)]",children:s},s)):e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-soft)]",children:"No changed files listed"})})]}),e.jsxs("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx(Ee,{className:"size-4 text-[var(--tertiary)]"}),e.jsx("span",{children:"Git refs"})]}),e.jsxs("div",{className:"mt-3 grid gap-3",children:[[de,ye].filter(s=>s.length>0).map((s,r)=>e.jsxs("div",{className:"grid gap-2",children:[de.length>0&&ye.length>0?e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:r===0?"Linked in completion report":"Other recorded refs"}):null,s.map(n=>{const L=Gs[n.refType],B=e.jsxs("div",{className:"rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(i,{className:L.className,children:L.label}),e.jsx("div",{className:"font-mono text-sm text-[var(--ui-ink-strong)]",children:n.refValue})]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:n.displayTitle||n.repository||n.provider})]});return n.url?e.jsxs("a",{href:n.url,target:"_blank",rel:"noreferrer",className:"group block",children:[B,e.jsxs("div",{className:"mt-2 inline-flex items-center gap-1 text-[11px] uppercase tracking-[0.16em] text-[var(--primary)]",children:["Open ref",e.jsx(ms,{className:"size-3.5 transition group-hover:translate-x-0.5 group-hover:-translate-y-0.5"})]})]},n.id):e.jsx("div",{children:B},n.id)})]},`git-group-${r}`)),H.length===0?e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-soft)]",children:"No git refs recorded"}):null]})]})]})})]}):null,e.jsxs("div",{className:"mt-5 grid gap-4 xl:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",children:[e.jsxs(P,{eyebrow:"Work done",title:"Execution ledger",description:"Surface tracked work, credited work, and manual adjustments without opening the timer history.",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsx(h,{label:"Tracked total",value:D(t.task.time.totalTrackedSeconds)}),e.jsx(h,{label:"Credited total",value:D(t.task.time.totalCreditedSeconds)}),e.jsx(h,{label:"Live work",value:D(t.task.time.liveCreditedSeconds)}),e.jsx(h,{label:"Manual adjustments",value:D(t.task.time.manualAdjustedSeconds)})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:["Today credited"," ",D(t.task.time.todayCreditedSeconds??0)]}),e.jsxs(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:["Live tracked"," ",D(t.task.time.liveTrackedSeconds)]}),e.jsxs(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:["Active runs ",t.task.time.activeRunCount]})]})]}),e.jsxs(P,{eyebrow:"Workflow health",title:"Signal scan",description:"A fast read on how ready this work item is for execution and closeout.",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(h,{label:"Closeout readiness",value:d!=null&&d.workSummary||de.length>0?"Evidence present":"Needs closeout evidence",hint:($e=d==null?void 0:d.modifiedFiles)!=null&&$e.length?`${d.modifiedFiles.length} changed file${d.modifiedFiles.length===1?"":"s"} listed`:"No changed-file evidence captured yet."}),e.jsx(h,{label:"Collaboration model",value:oe||O.length>0?"Human + bot":t.task.assignees&&t.task.assignees.length>0?"Shared human work":"Single owner",hint:O.length>0?`${O.length} bot assignee${O.length===1?"":"s"} attached`:"No bot assignee attached."})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:["Priority ",a(`common.enums.priority.${t.task.priority}`)]}),e.jsxs(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:["Effort ",a(`common.enums.effort.${t.task.effort}`)]}),e.jsxs(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:["Energy ",a(`common.enums.energy.${t.task.energy}`)]}),e.jsxs(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:["Duration"," ",D(t.task.plannedDurationSeconds)]})]})]})]}),e.jsxs("div",{className:"mt-5 rounded-[20px] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Action Point load"}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsxs("div",{className:"rounded-[16px] bg-[var(--ui-surface-1)] px-3.5 py-3",children:[e.jsx(x,{label:"Total cost"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:m?T(m.totalCostAp):"Not calibrated"})]}),e.jsxs("div",{className:"rounded-[16px] bg-[var(--ui-surface-1)] px-3.5 py-3",children:[e.jsx(x,{label:"Today debit"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:m?T(m.spentTodayAp):"0 AP"})]}),e.jsxs("div",{className:"rounded-[16px] bg-[var(--ui-surface-1)] px-3.5 py-3",children:[e.jsx(x,{label:"Sustain rate"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:m?me(m.sustainRateApPerHour):"0 AP/h"})]}),e.jsxs("div",{className:"rounded-[16px] bg-[var(--ui-surface-1)] px-3.5 py-3",children:[e.jsx(x,{label:"Expected duration"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:m?`${Math.round(m.expectedDurationSeconds/3600)} h`:"No target"})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[(_e=t.task.splitSuggestion)!=null&&_e.shouldSplit?e.jsx(i,{className:"bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]",children:"Split it"}):null,m?e.jsxs(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:["Remaining ",T(m.remainingAp)]}):null,m?e.jsxs(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:["Spent total ",T(m.spentTotalAp)]}):null,m?e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:m.costBand}):null]}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"This task only debits the Action Points you actually worked today. Marking it done does not consume the full estimate by itself."})]}),e.jsxs("div",{className:"mt-5 rounded-[20px] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Today's Life Force context"}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[16px] bg-[var(--ui-surface-1)] px-3.5 py-3",children:[e.jsx(x,{label:"Daily AP"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:I.data?`${T(I.data.spentTodayAp)} / ${T(I.data.dailyBudgetAp)}`:"Loading..."})]}),e.jsxs("div",{className:"rounded-[16px] bg-[var(--ui-surface-1)] px-3.5 py-3",children:[e.jsx(x,{label:"Instant headroom"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:I.data?me(I.data.instantFreeApPerHour):"Loading..."})]}),e.jsxs("div",{className:"rounded-[16px] bg-[var(--ui-surface-1)] px-3.5 py-3",children:[e.jsx(x,{label:"Forecast"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:I.data?`${T(I.data.forecastAp)} / ${T(I.data.dailyBudgetAp)}`:"Loading..."})]})]})]}),e.jsxs("div",{className:"mt-5 rounded-[20px] bg-[var(--ui-surface-2)] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx("span",{children:"Current timer"}),e.jsx(Ue,{content:"This shows whether work is running on the task right now and how much time has been credited.",label:"Explain current timer"})]}),e.jsx("div",{className:"mt-3 text-[var(--ui-ink-strong)]",children:f?`${f.timerMode==="planned"?"Planned":"Unlimited"} timer active with ${Math.floor(f.creditedSeconds/60)} credited minutes.`:"No timer is running on this task right now."})]}),e.jsxs("div",{className:"mt-5 grid gap-4 xl:grid-cols-[minmax(0,1fr)_20rem]",children:[e.jsxs("div",{className:"rounded-[20px] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Task scheduling"}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[16px] bg-[var(--ui-surface-1)] px-3.5 py-3",children:[e.jsx(x,{label:"Rule source"}),e.jsx("div",{className:"mt-2 text-[var(--ui-ink-strong)]",children:t.task.schedulingRules?"Task-specific override":"Uses project defaults"})]}),e.jsxs("div",{className:"rounded-[16px] bg-[var(--ui-surface-1)] px-3.5 py-3",children:[e.jsx(x,{label:"Planned duration"}),e.jsx("div",{className:"mt-2 text-[var(--ui-ink-strong)]",children:t.task.plannedDurationSeconds?`${Math.round(t.task.plannedDurationSeconds/60)} min`:"No duration target"})]})]}),e.jsx("p",{className:"mt-4 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Scheduling rules now live behind the guided modal flow instead of an inline editor. Use it to change eligible blocks, blocked contexts, and the planning duration without overcrowding the task page."}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsxs(k,{onClick:()=>ge(!0),children:[e.jsx(ue,{className:"size-4"}),"Edit task scheduling"]}),e.jsx(A,{to:"/calendar",children:e.jsx(k,{variant:"secondary",children:"Open calendar workspace"})})]})]}),e.jsxs("div",{className:"rounded-[20px] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Calendar status"}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(i,{className:_.tone==="blocked"?"bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]":_.tone==="waiting"?"bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]":"bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]",children:_.label}),e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:t.task.schedulingRules?"Task override":"Using project defaults"}),t.task.plannedDurationSeconds?e.jsxs(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:[Math.round(t.task.plannedDurationSeconds/60)," min target"]}):null]}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Forge checks these rules before a live run starts. If the current calendar context is blocked, you can still override with an explicit reason."}),_.context.length>0?e.jsxs("div",{className:"mt-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Current context"}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:_.context.map(s=>e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:s},s))})]}):null,_.conflicts.length>0?e.jsx("div",{className:"mt-4 grid gap-2",children:_.conflicts.map(s=>e.jsx("div",{className:"rounded-[16px] bg-[var(--ui-danger-soft)] px-3 py-2 text-sm text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",children:s},s))}):null,e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:e.jsxs(k,{pending:ie.isPending||ke.isPending,pendingLabel:"Planning",onClick:()=>{U(null),j(!0)},children:[e.jsx(ue,{className:"size-4"}),"Time Box"]})})]})]}),e.jsxs("div",{className:"mt-5 rounded-[20px] bg-[var(--ui-surface-2)] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Scheduled blocks"}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Open a scheduled block to edit the day, the hour range, or the AP profile tied to this task."})]}),e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:G.length})]}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[G.length===0?e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-4 text-sm text-[var(--ui-ink-faint)]",children:"No future timeboxes are attached to this task yet."}):null,G.map(s=>e.jsxs("div",{role:"button",tabIndex:0,onClick:()=>{U(s),j(!0)},onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),U(s),j(!0))},className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4 text-left transition hover:bg-[var(--ui-surface-hover)]",children:[e.jsx("div",{className:"flex flex-wrap items-start justify-between gap-3",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"line-clamp-2 font-medium leading-6 text-[var(--ui-ink-strong)]",children:s.title}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx(xe,{className:"size-3.5 shrink-0"}),u(s.startsAt)," to"," ",u(s.endsAt)]})]})}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:s.source}),e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:s.status}),e.jsx(i,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:me(Fe(s).rateApPerHour)}),e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:T(Fe(s).totalAp)}),s.overrideReason?e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:s.overrideReason}):null]}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx("span",{className:"rounded-[999px] bg-[var(--ui-surface-3)] px-3 py-1 text-xs text-[var(--ui-ink-medium)]",children:"Edit in guide"}),e.jsx(A,{to:`/calendar?timeboxId=${encodeURIComponent(s.id)}`,onClick:r=>r.stopPropagation(),className:"rounded-[999px] bg-[var(--ui-surface-3)] px-3 py-1 text-xs text-[var(--ui-ink-medium)] transition hover:bg-[var(--ui-surface-hover)]",children:"Open in calendar"})]})]},s.id))]})]}),e.jsx("div",{className:"mt-5",children:e.jsx(Rs,{entityType:"task",entityId:t.task.id,title:`${g.label} notes`,description:`Capture real progress, blockers, and context in Markdown so the ${g.noun} keeps a durable work log.`,invalidateQueryKeys:[["task-context",v.taskId],...t.task.projectId?[["project-board",t.task.projectId]]:[]]})}),e.jsxs("div",{className:"mt-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Activity"}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[t.activity.length===0?e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] p-4 text-sm text-[var(--ui-ink-faint)]",children:"No activity has been recorded for this task yet."}):null,t.activity.map(s=>e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:Ks(s)}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:Us(s)}),e.jsx("div",{className:"mt-3 text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:u(s.createdAt)})]}),e.jsx(k,{variant:"ghost",className:"shrink-0",onClick:async()=>{await Xe.mutateAsync(s.id)},children:"Remove"})]}),Be(s)&&qe(s)?e.jsx(A,{to:Be(s),className:"mt-3 inline-flex text-[11px] uppercase tracking-[0.16em] text-[var(--primary)]",children:qe(s)}):null]},s.id))]})]}),e.jsxs("div",{className:"mt-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Timer sessions"}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[t.taskRuns.length===0?e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] p-4 text-sm text-[var(--ui-ink-faint)]",children:"No timer sessions have been recorded for this task yet."}):null,t.taskRuns.map(s=>{var r,n,L,B,De;return e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:s.actor}),e.jsx(i,{children:ts(s.status)})]}),(r=s.gitContext)!=null&&r.branch||(n=s.gitContext)!=null&&n.pullRequestNumber?e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[(L=s.gitContext)!=null&&L.branch?e.jsxs(i,{className:"bg-[var(--ui-accent-soft)] text-[var(--primary)]",children:[e.jsx(Ee,{className:"mr-1 size-3"}),s.gitContext.branch]}):null,(B=s.gitContext)!=null&&B.pullRequestNumber?e.jsxs(i,{className:"bg-[var(--ui-accent-soft)] text-[var(--tertiary)]",children:[e.jsx(xs,{className:"mr-1 size-3"}),"PR #",s.gitContext.pullRequestNumber]}):null,(De=s.gitContext)!=null&&De.repository?e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-soft)]",children:s.gitContext.repository}):null]}):null,e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:s.note||a("common.labels.noRunNote")}),e.jsx("div",{className:"mt-3 text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:u(s.updatedAt)})]},s.id)})]})]})]}),e.jsx(Os,{open:E,goals:c.snapshot.goals,projects:c.snapshot.dashboard.projects,workItems:c.snapshot.workItems,tags:c.snapshot.tags,users:c.snapshot.users,editingTask:t.task,defaultUserId:t.task.userId??C,onRefreshEntities:c.refresh,currentCreditedSeconds:t.task.time.totalCreditedSeconds,onOpenChange:M,onAdjustTrackedTime:async s=>{await ae.mutateAsync(s)},onSubmit:async(s,r)=>{r&&await Q.mutateAsync({taskId:r,patch:s})}}),e.jsx(qs,{open:z,onOpenChange:R,entityType:"task",entityId:t.task.id,targetLabel:t.task.title,currentCreditedSeconds:t.task.time.totalCreditedSeconds,pending:ae.isPending,onSubmit:async s=>{await ae.mutateAsync(s)}}),e.jsx(Ps,{open:l,onOpenChange:s=>{j(s),s||U(null)},tasks:[t.task],initialTaskId:t.task.id,lockedTaskId:t.task.id,editingTimebox:Qe,from:F.from,to:F.to,userIds:p,onCreateTimebox:async s=>{await ie.mutateAsync({...s,userId:C??void 0})},onUpdateTimebox:async(s,r)=>{await ke.mutateAsync({timeboxId:s,patch:{...r,userId:C??void 0}})},onDeleteTimebox:async s=>{await Ye.mutateAsync(s)}}),e.jsx(Es,{open:K,onOpenChange:ge,tasks:[t.task],onSave:async({taskId:s,schedulingRules:r,plannedDurationSeconds:n})=>{await Q.mutateAsync({taskId:s,patch:{schedulingRules:r,plannedDurationSeconds:n}}),await b.invalidateQueries({queryKey:["task-calendar-overview",v.taskId]})}}),e.jsx(bs,{open:We,onOpenChange:se,eyebrow:`${g.label} status`,title:"Change status",description:`Pick the state that best matches where this ${g.noun} is right now.`,children:e.jsx("div",{className:"grid gap-3",children:Z.map(s=>{const r=s.icon,n=s.status===t.task.status;return e.jsx("button",{type:"button",disabled:n||Q.isPending,className:`rounded-[22px] border px-4 py-4 text-left transition ${n?"border-[color-mix(in_srgb,var(--primary)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-3)]"}`,onClick:()=>void we(s.status),children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(r,{className:"size-4 shrink-0 text-[var(--primary)]"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:s.label}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-faint)]",children:s.description})]})]})},s.status)})})})]})}export{Tt as TaskDetailPage};
@@ -1,6 +1,6 @@
1
- import{r as p,j as e,aP as be,b7 as Ie,cN as he,aK as je,bV as Se,bD as Ce,cO as $e,bX as Ae}from"./vendor-BwL6m4SE.js";import{Q as Me,F as g,a as H}from"./question-flow-dialog-D-_EvoAt.js";import{cd as Te,ce as Fe,B as ge,I as F,k as ye,u as We,b as xe,c as De,T as Q,a9 as Re,a8 as Pe,cf as Ge}from"./index-izRKx6JK.js";import{defaultGoalValues as Ee}from"./goal-dialog-DH50D0tP.js";import{I as He}from"./inline-note-fields-D4mCM1gO.js";import{defaultProjectValues as ze}from"./project-dialog-B_J1ESMk.js";import{U as Oe}from"./user-select-field-fx129Uh6.js";import{q as Be}from"./schemas-B0Pa-V-A.js";import{a as Le}from"./user-ownership-DJGl4rAj.js";import"./ui-B9TWEtCx.js";import"./motion-DcgUnXhY.js";import"./state-Bpe5dF3T.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";import"./user-badge-MEZuJiir.js";function le(t){return typeof t=="string"?t.trim():""}function Ue(t,d){const c=d.find(b=>b.refType===t.refType&&b.refValue===t.refValue&&b.repository===t.repository)??null;return{id:(c==null?void 0:c.id)??`draft-${t.refType}-${t.refValue.replace(/[^a-zA-Z0-9]+/g,"-")}`,workItemId:(c==null?void 0:c.workItemId)??"",refType:t.refType,provider:t.provider,repository:t.repository,refValue:t.refValue,url:t.url,displayTitle:t.displayTitle}}function Ke(t){return t==="branch"?be:t==="pull_request"?Ce:$e}function qe({selectedRefs:t,onChange:d}){const[c,b]=p.useState(null),[I,j]=p.useState(null),[s,i]=p.useState(!1),[C,z]=p.useState("branch"),[f,k]=p.useState(""),[w,v]=p.useState(""),[N,U]=p.useState([]),[V,Z]=p.useState([]),[u,D]=p.useState(!1),[S,A]=p.useState(null);p.useEffect(()=>{let o=!1;return i(!0),Te().then(h=>{o||(b(h.git),v(y=>y.trim().length>0?y:h.git.repository||y),j(null))}).catch(h=>{o||j(h instanceof Error?h.message:"Forge could not load git helper context.")}).finally(()=>{o||i(!1)}),()=>{o=!0}},[]),p.useEffect(()=>{let o=!1;return D(!0),Fe({kind:C,query:f,repository:w}).then(h=>{o||(U(h.git.refs),Z(h.git.warnings),A(null))}).catch(h=>{o||(A(h instanceof Error?h.message:"Forge could not search git refs right now."),U([]))}).finally(()=>{o||D(!1)}),()=>{o=!0}},[C,f,w]);const Y=p.useMemo(()=>{const o=le(c==null?void 0:c.currentBranch),h=le(w)||le(c==null?void 0:c.repository);return o?{key:`branch:${o}`,refType:"branch",provider:h?"github":"git",repository:h,refValue:o,url:h&&o?`https://github.com/${h}/tree/${encodeURIComponent(o)}`:null,displayTitle:o,subtitle:"Current local branch"}:null},[c==null?void 0:c.currentBranch,c==null?void 0:c.repository,w]),W=o=>{const h=Ue(o,t);t.some(y=>y.refType===h.refType&&y.refValue===h.refValue&&y.repository===h.repository)||d([...t,h])},m=o=>{d(t.filter(h=>h.id!==o.id))};return e.jsxs("div",{className:"grid gap-3 rounded-[20px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"type-label text-white/45",children:"Git links"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:"Pick the live branch, commits, or pull requests from the local repo instead of typing raw hashes."})]}),Y?e.jsxs(ge,{type:"button",variant:"secondary",size:"sm",onClick:()=>W(Y),children:[e.jsx(be,{className:"size-4"}),"Use current branch"]}):null]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[10rem_minmax(0,1fr)]",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"type-label text-white/45",children:"Type"}),e.jsxs("select",{value:C,onChange:o=>z(o.target.value),className:"min-h-10 rounded-[var(--radius-control)] border border-white/10 bg-white/[0.04] px-3 py-2 text-sm text-white outline-none transition focus:border-[rgba(192,193,255,0.3)]",children:[e.jsx("option",{value:"branch",children:"Branch"}),e.jsx("option",{value:"commit",children:"Commit"}),e.jsx("option",{value:"pull_request",children:"Pull request"})]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"type-label text-white/45",children:"Repository"}),e.jsx(F,{value:w,onChange:o=>v(o.target.value),placeholder:(c==null?void 0:c.repository)||"owner/repo"})]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"type-label text-white/45",children:"Search"}),e.jsxs("div",{className:"relative",children:[e.jsx(Ie,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-white/32"}),e.jsx(F,{value:f,onChange:o=>k(o.target.value),placeholder:C==="branch"?"Search branches":C==="pull_request"?"Search pull requests":"Search commits",className:"pl-10"})]})]}),t.length>0?e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"type-label text-white/45",children:"Selected links"}),e.jsx("div",{className:"grid gap-2",children:t.map(o=>e.jsxs("div",{className:"flex items-start justify-between gap-3 rounded-[16px] border border-white/8 bg-white/[0.04] px-3 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(ye,{className:"bg-white/[0.08] text-white/72",children:o.refType.replaceAll("_"," ")}),e.jsx("div",{className:"truncate text-sm text-white/84",children:o.displayTitle||o.refValue})]}),e.jsx("div",{className:"mt-1 text-xs text-white/46",children:[o.repository,o.refValue].filter(Boolean).join(" · ")})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[o.url?e.jsx("a",{href:o.url,target:"_blank",rel:"noreferrer",className:"inline-flex size-8 items-center justify-center rounded-full text-white/55 transition hover:bg-white/[0.08] hover:text-white",children:e.jsx(he,{className:"size-4"})}):null,e.jsx("button",{type:"button",className:"inline-flex size-8 items-center justify-center rounded-full text-white/55 transition hover:bg-white/[0.08] hover:text-white",onClick:()=>m(o),children:e.jsx(je,{className:"size-4"})})]})]},o.id))})]}):null,e.jsxs("div",{className:"grid gap-2 rounded-[16px] border border-white/8 bg-white/[0.02] p-2",children:[s||u?e.jsxs("div",{className:"flex items-center gap-2 px-2 py-4 text-sm text-white/52",children:[e.jsx(Se,{className:"size-4 animate-spin"}),"Loading git suggestions…"]}):null,I?e.jsx("div",{className:"rounded-[14px] bg-rose-500/10 px-3 py-2 text-sm text-rose-200",children:I}):null,S?e.jsx("div",{className:"rounded-[14px] bg-rose-500/10 px-3 py-2 text-sm text-rose-200",children:S}):null,[...(c==null?void 0:c.warnings)??[],...V].filter(Boolean).slice(0,2).map(o=>e.jsx("div",{className:"rounded-[14px] bg-amber-400/10 px-3 py-2 text-sm text-amber-100",children:o},o)),!u&&!S&&N.length===0?e.jsx("div",{className:"px-2 py-4 text-sm text-white/45",children:"No matching git refs found."}):null,N.map(o=>{const h=Ke(C),y=t.some(M=>M.refType===o.refType&&M.refValue===o.refValue&&M.repository===o.repository);return e.jsxs("div",{className:"flex items-start justify-between gap-3 rounded-[14px] px-2 py-2 transition hover:bg-white/[0.04]",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-white/82",children:[e.jsx(h,{className:"size-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate",children:o.displayTitle||o.refValue})]}),e.jsx("div",{className:"mt-1 text-xs text-white/46",children:[o.repository,o.subtitle].filter(Boolean).join(" · ")})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[o.url?e.jsx("a",{href:o.url,target:"_blank",rel:"noreferrer",className:"inline-flex size-8 items-center justify-center rounded-full text-white/55 transition hover:bg-white/[0.08] hover:text-white",children:e.jsx(he,{className:"size-4"})}):null,e.jsx(ge,{type:"button",size:"sm",variant:"secondary",disabled:y,onClick:()=>W(o),children:y?"Added":"Add"})]})]},o.key)})]})]})}const X={title:"",description:"",level:"task",owner:"Albert",userId:null,assigneeUserIds:[],goalId:"",projectId:"",parentWorkItemId:null,priority:"medium",status:"focus",effort:"deep",energy:"steady",dueDate:"",points:60,plannedDurationSeconds:86400,actionCostBand:"standard",aiInstructions:"",executionMode:null,acceptanceCriteria:[],blockerLinks:[],completionReport:null,gitRefs:[],tagIds:[],notes:[]},_e=[];function Qe(t){return t.split(`
2
- `).map(d=>d.trim()).filter(d=>d.length>0)}function ie(t){return t.modifiedFiles.length===0&&t.workSummary.trim().length===0&&t.linkedGitRefIds.length===0?null:{modifiedFiles:t.modifiedFiles,workSummary:t.workSummary,linkedGitRefIds:t.linkedGitRefIds}}function Xe(t,d){return ie({modifiedFiles:(d==null?void 0:d.modifiedFiles)??[],workSummary:(d==null?void 0:d.workSummary)??"",linkedGitRefIds:t.map(c=>c.id).filter(c=>typeof c=="string")})}function $(t){return t.trim().toLowerCase()}function Ve(t){return t==="issue"?["goal","project"]:t==="task"?["goal","project","issue"]:["goal","project","task"]}function Ye(t){return t==="issue"?["goal","project"]:t==="task"?["goal","project","issue"]:["goal","project"]}function fe(t){return t==="task"?"task":t}function Ze(t){var v;const{editingTask:d,initialGoalId:c,initialLevel:b,initialParentWorkItemId:I,initialProjectId:j,defaultUserId:s,projects:i,users:C,workItems:z}=t;if(d)return at(d);const f=I?z.find(N=>N.id===I)??null:null,k=i.find(N=>N.id===((f==null?void 0:f.projectId)??j))??null,w=(k==null?void 0:k.userId)??s??null;return{...X,level:b??((f==null?void 0:f.level)==="issue"?"task":(f==null?void 0:f.level)==="task"?"subtask":X.level),owner:((v=C.find(N=>N.id===w))==null?void 0:v.displayName)??X.owner,userId:w,goalId:(f==null?void 0:f.goalId)??(k==null?void 0:k.goalId)??c??"",projectId:(k==null?void 0:k.id)??"",parentWorkItemId:(f==null?void 0:f.id)??null}}function Je(t){const{draft:d,goals:c,projects:b,workItems:I}=t,j=[];if(d.goalId){const s=c.find(i=>i.id===d.goalId);s&&j.push({id:`goal:${s.id}`,kind:"goal",mode:"existing",entityId:s.id,label:s.title,description:"Goal",searchText:$(`${s.title} ${s.description}`),goalId:s.id,projectId:null,parentWorkItemId:null})}if(d.projectId){const s=b.find(i=>i.id===d.projectId);s&&j.push({id:`project:${s.id}`,kind:"project",mode:"existing",entityId:s.id,label:s.title,description:"Project",searchText:$(`${s.title} ${s.description} ${s.goalTitle}`),goalId:s.goalId,projectId:s.id,parentWorkItemId:null})}if(d.parentWorkItemId){const s=I.find(i=>i.id===d.parentWorkItemId);s&&j.push({id:`${s.level}:${s.id}`,kind:s.level==="issue"?"issue":"task",mode:"existing",entityId:s.id,label:s.title,description:s.level==="issue"?"Issue":"Task",searchText:$(`${s.title} ${s.description} ${s.aiInstructions}`),goalId:s.goalId,projectId:s.projectId,parentWorkItemId:s.parentWorkItemId})}return j}function et(t){const{goals:d,projects:c,workItems:b,allowedKinds:I,editingTaskId:j}=t,s=[];return I.includes("goal")&&s.push(...d.map(i=>({id:`goal:${i.id}`,kind:"goal",mode:"existing",entityId:i.id,label:i.title,description:"Goal",searchText:$(`${i.title} ${i.description}`),goalId:i.id,projectId:null,parentWorkItemId:null}))),I.includes("project")&&s.push(...c.map(i=>({id:`project:${i.id}`,kind:"project",mode:"existing",entityId:i.id,label:i.title,description:`Project · ${i.goalTitle}`,searchText:$(`${i.title} ${i.description} ${i.goalTitle} ${i.productRequirementsDocument}`),goalId:i.goalId,projectId:i.id,parentWorkItemId:null}))),I.includes("issue")&&s.push(...b.filter(i=>i.level==="issue"&&i.id!==j).map(i=>({id:`issue:${i.id}`,kind:"issue",mode:"existing",entityId:i.id,label:i.title,description:"Issue",searchText:$(`${i.title} ${i.description} ${i.aiInstructions} ${i.executionMode??""}`),goalId:i.goalId,projectId:i.projectId,parentWorkItemId:null}))),I.includes("task")&&s.push(...b.filter(i=>i.level==="task"&&i.id!==j).map(i=>({id:`task:${i.id}`,kind:"task",mode:"existing",entityId:i.id,label:i.title,description:"Task",searchText:$(`${i.title} ${i.description} ${i.aiInstructions} ${i.executionMode??""}`),goalId:i.goalId,projectId:i.projectId,parentWorkItemId:i.parentWorkItemId}))),s}function tt(t,d,c){if(d.kind==="goal"){const b=t.projectId?c.find(j=>j.projectId===t.projectId)??null:null,I=!t.projectId||(b==null?void 0:b.goalId)===d.entityId||d.goalId===t.goalId;return{goalId:d.entityId,projectId:I?t.projectId:"",parentWorkItemId:I?t.parentWorkItemId:null}}if(d.kind==="project"){const b=t.parentWorkItemId?c.find(I=>I.id===t.parentWorkItemId)??null:null;return{goalId:d.goalId??t.goalId,projectId:d.entityId,parentWorkItemId:!b||b.projectId===d.entityId?t.parentWorkItemId:null}}return{goalId:d.goalId??t.goalId,projectId:d.projectId??t.projectId,parentWorkItemId:d.entityId}}function rt(t){return t==="goal"?{goalId:"",projectId:"",parentWorkItemId:null}:t==="project"?{projectId:"",parentWorkItemId:null}:{parentWorkItemId:null}}function at(t){var d;return{title:t.title,description:t.description,level:t.level,owner:t.owner,userId:t.userId??null,assigneeUserIds:t.assigneeUserIds??[],goalId:t.goalId??"",projectId:t.projectId??"",parentWorkItemId:t.parentWorkItemId??null,priority:t.priority,status:t.status,effort:t.effort,energy:t.energy,dueDate:t.dueDate??"",points:t.points,plannedDurationSeconds:t.plannedDurationSeconds??86400,actionCostBand:((d=t.actionPointSummary)==null?void 0:d.costBand)??"standard",aiInstructions:t.aiInstructions,executionMode:t.executionMode,acceptanceCriteria:t.acceptanceCriteria,blockerLinks:t.blockerLinks,completionReport:t.completionReport,gitRefs:t.gitRefs,tagIds:t.tagIds,notes:[]}}function jt({open:t,goals:d,projects:c,workItems:b,tags:I,users:j,editingTask:s,initialProjectId:i,initialGoalId:C,initialParentWorkItemId:z,initialLevel:f,initialStepId:k,defaultUserId:w=null,onRefreshEntities:v,currentCreditedSeconds:N,onOpenChange:U,onAdjustTrackedTime:V,onSubmit:Z}){const{t:u}=We(),D=d??[],S=c??[],A=b??_e,Y=I??[],W=j??[],[m,o]=p.useState(X),[h,y]=p.useState(null),[M,J]=p.useState({}),[R,ee]=p.useState(""),[ve,P]=p.useState(!1),[te,O]=p.useState(0),[oe,G]=p.useState(null),[st,re]=p.useState(null),[ae,ne]=p.useState(0),ke=a=>{J(Object.fromEntries(Object.entries(a).map(([n,r])=>[n,r==null?void 0:r[0]])))};p.useEffect(()=>{t&&(y(null),J({}),ee(""),P(!1),O(0),G(null),re(null),ne(s?Math.max(0,Math.floor((N??s.time.totalCreditedSeconds)/60)):0),o(Ze({editingTask:s,initialGoalId:C,initialLevel:f,initialParentWorkItemId:z,initialProjectId:i,defaultUserId:w,projects:S,users:W,workItems:A})))},[w,s,C,f,z,i,t,S,W,A,N]);const de=s?Math.max(0,Math.floor((N??s.time.totalCreditedSeconds)/60)):0,B=s?ae-de:0,T=p.useMemo(()=>S.find(a=>a.id===m.projectId)??null,[m.projectId,S]),ce=p.useMemo(()=>Ve(m.level),[m.level]),ue=p.useMemo(()=>Ye(m.level),[m.level]),K=p.useMemo(()=>Je({draft:m,goals:D,projects:S,workItems:A}),[m,D,S,A]),se=p.useMemo(()=>et({goals:D,projects:S,workItems:A,allowedKinds:ce,editingTaskId:s==null?void 0:s.id}),[ce,s==null?void 0:s.id,D,S,A]),L=p.useMemo(()=>{const a=$(R),n=a.length===0?se.slice(0,8):se.filter(l=>l.searchText.includes(a)).slice(0,8);if(a.length===0)return n;const r=ue.map(l=>l==="project"&&!m.goalId?{id:`create:${l}:${a}`,kind:l,mode:"create",label:R.trim(),description:"Pick or create a goal first, then create a project here.",disabled:!0,disabledReason:"Pick or create a goal first."}:l==="issue"&&!m.projectId?{id:`create:${l}:${a}`,kind:l,mode:"create",label:R.trim(),description:"Pick or create a project first, then create an issue here.",disabled:!0,disabledReason:"Pick or create a project first."}:{id:`create:${l}:${a}`,kind:l,mode:"create",label:R.trim(),description:`Create a new ${l} from "${R.trim()}".`});return[...n,...r]},[R,se,ue,m.goalId,m.projectId]),we=W.find(a=>a.id===((T==null?void 0:T.userId)??w))??null;p.useEffect(()=>{T&&m.goalId!==T.goalId&&o(a=>({...a,goalId:T.goalId}))},[m.goalId,T]);const q=a=>{o(n=>({...n,...tt(n,a,A)})),ee(""),G(null),O(0),P(!1)},pe=a=>{o(n=>({...n,...rt(a)})),G(null)},me=async a=>{if(a.disabled){G(a.disabledReason??a.description);return}const n=a.label.trim();if(n){re(a.id),G(null);try{if(a.kind==="goal"){const r=await Re({...Ee,title:n,userId:m.userId??null});await(v==null?void 0:v()),q({id:`goal:${r.goal.id}`,kind:"goal",mode:"existing",entityId:r.goal.id,label:r.goal.title,description:"Goal",searchText:$(`${r.goal.title} ${r.goal.description}`),goalId:r.goal.id,projectId:null,parentWorkItemId:null});return}if(a.kind==="project"){if(!m.goalId)throw new Error("Pick or create a goal first.");const r=await Pe({...ze,goalId:m.goalId,title:n,userId:m.userId??null,assigneeUserIds:m.assigneeUserIds});await(v==null?void 0:v()),q({id:`project:${r.project.id}`,kind:"project",mode:"existing",entityId:r.project.id,label:r.project.title,description:"Project",searchText:$(`${r.project.title} ${r.project.description}`),goalId:r.project.goalId,projectId:r.project.id,parentWorkItemId:null});return}if(a.kind==="issue"){if(!m.projectId)throw new Error("Pick or create a project first.");const r=await Ge({...X,level:"issue",title:n,owner:m.owner,userId:m.userId??null,assigneeUserIds:m.assigneeUserIds,goalId:m.goalId,projectId:m.projectId,executionMode:"afk"});await(v==null?void 0:v()),q({id:`issue:${r.workItem.id}`,kind:"issue",mode:"existing",entityId:r.workItem.id,label:r.workItem.title,description:"Issue",searchText:$(`${r.workItem.title} ${r.workItem.description}`),goalId:r.workItem.goalId,projectId:r.workItem.projectId,parentWorkItemId:null})}}catch(r){G(r instanceof Error?r.message:"Unable to create that linked entity right now.")}finally{re(null)}}},Ne=[{id:"anchor",eyebrow:"Placement",title:"Choose where this work belongs",description:"Anchor the work through the hierarchy. Tasks can carry a goal, project, and issue parent together so the chain of meaning stays explicit.",render:(a,n)=>{var r;return e.jsxs(e.Fragment,{children:[e.jsx(g,{label:"Hierarchy anchors",labelHelp:"Pick the goal and project anchors, then choose the real parent where needed. Tasks can live under issues, subtasks under tasks.",error:M.projectId??null,children:e.jsx("div",{className:"grid gap-3",children:e.jsxs("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[K.length>0?e.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:K.map(l=>e.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-2.5 py-1.5",children:[e.jsx(xe,{kind:fe(l.kind),label:l.label,compact:!0,gradient:!1,className:"max-w-[16rem]"}),e.jsx("button",{type:"button",className:"rounded-full text-[var(--ui-ink-soft)] transition hover:text-[var(--ui-ink-strong)]",onClick:()=>pe(l.kind),"aria-label":`Remove ${l.label}`,children:e.jsx(je,{className:"size-3.5"})})]},l.id))}):null,e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex items-center gap-3 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx(Ie,{className:"size-4 text-[var(--ui-ink-faint)]"}),e.jsx("input",{value:R,onChange:l=>{ee(l.target.value),P(!0),O(0),G(null)},onFocus:()=>P(!0),onBlur:()=>{window.setTimeout(()=>P(!1),120)},onKeyDown:l=>{if(l.key==="Backspace"&&!R&&K.length>0){pe(K[K.length-1].kind);return}if(l.key==="ArrowDown"){l.preventDefault(),P(!0),O(x=>L.length===0?0:Math.min(L.length-1,x+1));return}if(l.key==="ArrowUp"){l.preventDefault(),O(x=>Math.max(0,x-1));return}if(l.key==="Escape"){P(!1);return}if(l.key==="Enter"&&L[te]){l.preventDefault();const x=L[te];x.mode==="existing"?q(x):me(x)}},placeholder:'Search or create Goal, Project, or parent Issue like Goal + "Creative system"',className:"min-w-0 flex-1 bg-transparent text-sm text-[var(--ui-ink-strong)] placeholder:text-[var(--ui-ink-faint)] focus:outline-none"})]}),ve?e.jsx("div",{className:"absolute top-full z-20 mt-2 w-full rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-popover)] p-2 shadow-[var(--ui-shadow-floating)] backdrop-blur-xl",children:L.length>0?L.map((l,x)=>e.jsxs("button",{type:"button",disabled:l.mode==="create"&&l.disabled,className:De("flex w-full items-start justify-between gap-3 rounded-[18px] px-3 py-2.5 text-left transition",x===te?"bg-[var(--ui-surface-active)] text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]",l.mode==="create"&&l.disabled&&"cursor-not-allowed opacity-45"),onMouseEnter:()=>O(x),onMouseDown:E=>E.preventDefault(),onClick:()=>{if(l.mode==="existing"){q(l);return}me(l)},children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(xe,{kind:fe(l.kind),label:l.mode==="create"?`Create ${l.kind}`:l.label,compact:!0,gradient:!1}),l.mode==="create"?e.jsxs(ye,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:['"',l.label,'"']}):null]}),e.jsx("div",{className:"mt-1 text-xs leading-5 text-[var(--ui-ink-faint)]",children:l.description})]}),l.mode==="create"?e.jsx("span",{className:"rounded-full bg-[var(--primary)]/12 p-2 text-[var(--primary)]",children:e.jsx(Ae,{className:"size-3.5"})}):null]},l.id)):e.jsx("div",{className:"px-3 py-2.5 text-sm text-[var(--ui-ink-faint)]",children:"Type to find an existing anchor or create a new one."})}):null]}),oe?e.jsx("div",{className:"mt-3 rounded-[16px] border border-[color-mix(in_srgb,var(--danger)_22%,transparent)] bg-[var(--ui-danger-soft)] px-3 py-2 text-sm text-[var(--danger)]",children:oe}):null]})})}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(g,{label:"Resolved project",children:e.jsx(F,{readOnly:!0,value:(T==null?void 0:T.title)??"",placeholder:"Select or create a project anchor"})}),e.jsx(g,{label:"Resolved goal",children:e.jsx(F,{readOnly:!0,value:((r=D.find(l=>l.id===a.goalId))==null?void 0:r.title)??"",placeholder:"Select or create a goal anchor"})})]})]})}},{id:"shape",eyebrow:"Shape",title:"Define the next concrete move",description:"Keep the task small enough to be actionable and strong enough to clearly move the project forward.",render:(a,n)=>e.jsxs(e.Fragment,{children:[e.jsx(g,{label:"Hierarchy level",error:M.level??null,children:e.jsx(H,{value:a.level,onChange:r=>n({level:r}),options:[{value:"issue",label:"Issue",description:"Vertical slice with AFK or HITL execution mode."},{value:"task",label:"Task",description:"One focused AI session with direct instructions."},{value:"subtask",label:"Subtask",description:"A lightweight child step under a task."}]})}),e.jsx(g,{label:u("common.dialogs.task.title"),error:M.title??null,children:e.jsx(F,{value:a.title,onChange:r=>n({title:r.target.value}),placeholder:"Draft the first mode atlas sketch"})}),e.jsx(g,{label:u("common.dialogs.task.descriptionLabel"),children:e.jsx(Q,{value:a.description,onChange:r=>n({description:r.target.value}),placeholder:"Write the task description in Markdown. Keep it short or turn it into a full acceptance doc."})}),a.level==="issue"||a.level==="task"?e.jsxs(e.Fragment,{children:[e.jsx(g,{label:"Execution mode",children:e.jsx(H,{value:a.executionMode??"afk",onChange:r=>n({executionMode:r}),options:[{value:"afk",label:"AFK",description:"AI can complete the issue flow without waiting on a human decision."},{value:"hitl",label:"HITL",description:"A human decision is required somewhere in the slice."}]})}),e.jsx(g,{label:"Acceptance criteria",children:e.jsx(Q,{value:a.acceptanceCriteria.join(`
1
+ import{r as p,j as e,aP as be,b8 as Ie,cQ as he,aK as je,bW as Se,bE as Ce,cR as $e,bY as Ae}from"./vendor-B7FKSwHK.js";import{Q as Me,F as g,a as H}from"./question-flow-dialog-yMYVk998.js";import{cm as Te,cn as We,B as ge,I as W,j as ye,u as Fe,b as xe,c as De,T as Q,ai as Re,ah as Pe,co as Ee}from"./index-gmPaoLN-.js";import{defaultGoalValues as Ge}from"./goal-dialog-nkdME5Uy.js";import{I as He}from"./inline-note-fields-BvQwmMAv.js";import{defaultProjectValues as ze}from"./project-dialog-B2_PcXAf.js";import{U as Be}from"./user-select-field-CmKwcbZt.js";import{q as Oe}from"./schemas-BlFy-uPR.js";import{a as Le}from"./user-ownership-DJGl4rAj.js";import"./ui-uo_bNP7c.js";import"./motion-BibSzp57.js";import"./state-BFyKSULP.js";import"./board-DprRipIG.js";import"./forms-ByKjodjN.js";import"./user-badge-C4eZu1e_.js";function le(t){return typeof t=="string"?t.trim():""}function Ue(t,d){const c=d.find(b=>b.refType===t.refType&&b.refValue===t.refValue&&b.repository===t.repository)??null;return{id:(c==null?void 0:c.id)??`draft-${t.refType}-${t.refValue.replace(/[^a-zA-Z0-9]+/g,"-")}`,workItemId:(c==null?void 0:c.workItemId)??"",refType:t.refType,provider:t.provider,repository:t.repository,refValue:t.refValue,url:t.url,displayTitle:t.displayTitle}}function Ke(t){return t==="branch"?be:t==="pull_request"?Ce:$e}function qe({selectedRefs:t,onChange:d}){const[c,b]=p.useState(null),[I,j]=p.useState(null),[s,i]=p.useState(!1),[C,z]=p.useState("branch"),[f,k]=p.useState(""),[w,v]=p.useState(""),[N,U]=p.useState([]),[V,Z]=p.useState([]),[u,D]=p.useState(!1),[S,A]=p.useState(null);p.useEffect(()=>{let o=!1;return i(!0),Te().then(h=>{o||(b(h.git),v(y=>y.trim().length>0?y:h.git.repository||y),j(null))}).catch(h=>{o||j(h instanceof Error?h.message:"Forge could not load git helper context.")}).finally(()=>{o||i(!1)}),()=>{o=!0}},[]),p.useEffect(()=>{let o=!1;return D(!0),We({kind:C,query:f,repository:w}).then(h=>{o||(U(h.git.refs),Z(h.git.warnings),A(null))}).catch(h=>{o||(A(h instanceof Error?h.message:"Forge could not search git refs right now."),U([]))}).finally(()=>{o||D(!1)}),()=>{o=!0}},[C,f,w]);const Y=p.useMemo(()=>{const o=le(c==null?void 0:c.currentBranch),h=le(w)||le(c==null?void 0:c.repository);return o?{key:`branch:${o}`,refType:"branch",provider:h?"github":"git",repository:h,refValue:o,url:h&&o?`https://github.com/${h}/tree/${encodeURIComponent(o)}`:null,displayTitle:o,subtitle:"Current local branch"}:null},[c==null?void 0:c.currentBranch,c==null?void 0:c.repository,w]),F=o=>{const h=Ue(o,t);t.some(y=>y.refType===h.refType&&y.refValue===h.refValue&&y.repository===h.repository)||d([...t,h])},m=o=>{d(t.filter(h=>h.id!==o.id))};return e.jsxs("div",{className:"grid gap-3 rounded-[20px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"type-label text-white/45",children:"Git links"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:"Pick the live branch, commits, or pull requests from the local repo instead of typing raw hashes."})]}),Y?e.jsxs(ge,{type:"button",variant:"secondary",size:"sm",onClick:()=>F(Y),children:[e.jsx(be,{className:"size-4"}),"Use current branch"]}):null]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[10rem_minmax(0,1fr)]",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"type-label text-white/45",children:"Type"}),e.jsxs("select",{value:C,onChange:o=>z(o.target.value),className:"min-h-10 rounded-[var(--radius-control)] border border-white/10 bg-white/[0.04] px-3 py-2 text-sm text-white outline-none transition focus:border-[rgba(192,193,255,0.3)]",children:[e.jsx("option",{value:"branch",children:"Branch"}),e.jsx("option",{value:"commit",children:"Commit"}),e.jsx("option",{value:"pull_request",children:"Pull request"})]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"type-label text-white/45",children:"Repository"}),e.jsx(W,{value:w,onChange:o=>v(o.target.value),placeholder:(c==null?void 0:c.repository)||"owner/repo"})]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"type-label text-white/45",children:"Search"}),e.jsxs("div",{className:"relative",children:[e.jsx(Ie,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-white/32"}),e.jsx(W,{value:f,onChange:o=>k(o.target.value),placeholder:C==="branch"?"Search branches":C==="pull_request"?"Search pull requests":"Search commits",className:"pl-10"})]})]}),t.length>0?e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"type-label text-white/45",children:"Selected links"}),e.jsx("div",{className:"grid gap-2",children:t.map(o=>e.jsxs("div",{className:"flex items-start justify-between gap-3 rounded-[16px] border border-white/8 bg-white/[0.04] px-3 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(ye,{className:"bg-white/[0.08] text-white/72",children:o.refType.replaceAll("_"," ")}),e.jsx("div",{className:"truncate text-sm text-white/84",children:o.displayTitle||o.refValue})]}),e.jsx("div",{className:"mt-1 text-xs text-white/46",children:[o.repository,o.refValue].filter(Boolean).join(" · ")})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[o.url?e.jsx("a",{href:o.url,target:"_blank",rel:"noreferrer",className:"inline-flex size-8 items-center justify-center rounded-full text-white/55 transition hover:bg-white/[0.08] hover:text-white",children:e.jsx(he,{className:"size-4"})}):null,e.jsx("button",{type:"button",className:"inline-flex size-8 items-center justify-center rounded-full text-white/55 transition hover:bg-white/[0.08] hover:text-white",onClick:()=>m(o),children:e.jsx(je,{className:"size-4"})})]})]},o.id))})]}):null,e.jsxs("div",{className:"grid gap-2 rounded-[16px] border border-white/8 bg-white/[0.02] p-2",children:[s||u?e.jsxs("div",{className:"flex items-center gap-2 px-2 py-4 text-sm text-white/52",children:[e.jsx(Se,{className:"size-4 animate-spin"}),"Loading git suggestions…"]}):null,I?e.jsx("div",{className:"rounded-[14px] bg-rose-500/10 px-3 py-2 text-sm text-rose-200",children:I}):null,S?e.jsx("div",{className:"rounded-[14px] bg-rose-500/10 px-3 py-2 text-sm text-rose-200",children:S}):null,[...(c==null?void 0:c.warnings)??[],...V].filter(Boolean).slice(0,2).map(o=>e.jsx("div",{className:"rounded-[14px] bg-amber-400/10 px-3 py-2 text-sm text-amber-100",children:o},o)),!u&&!S&&N.length===0?e.jsx("div",{className:"px-2 py-4 text-sm text-white/45",children:"No matching git refs found."}):null,N.map(o=>{const h=Ke(C),y=t.some(M=>M.refType===o.refType&&M.refValue===o.refValue&&M.repository===o.repository);return e.jsxs("div",{className:"flex items-start justify-between gap-3 rounded-[14px] px-2 py-2 transition hover:bg-white/[0.04]",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-white/82",children:[e.jsx(h,{className:"size-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate",children:o.displayTitle||o.refValue})]}),e.jsx("div",{className:"mt-1 text-xs text-white/46",children:[o.repository,o.subtitle].filter(Boolean).join(" · ")})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[o.url?e.jsx("a",{href:o.url,target:"_blank",rel:"noreferrer",className:"inline-flex size-8 items-center justify-center rounded-full text-white/55 transition hover:bg-white/[0.08] hover:text-white",children:e.jsx(he,{className:"size-4"})}):null,e.jsx(ge,{type:"button",size:"sm",variant:"secondary",disabled:y,onClick:()=>F(o),children:y?"Added":"Add"})]})]},o.key)})]})]})}const X={title:"",description:"",level:"task",owner:"Albert",userId:null,assigneeUserIds:[],goalId:"",projectId:"",parentWorkItemId:null,priority:"medium",status:"focus",effort:"deep",energy:"steady",dueDate:"",points:60,plannedDurationSeconds:86400,actionCostBand:"standard",aiInstructions:"",executionMode:null,acceptanceCriteria:[],blockerLinks:[],completionReport:null,gitRefs:[],tagIds:[],notes:[]},_e=[];function Qe(t){return t.split(`
2
+ `).map(d=>d.trim()).filter(d=>d.length>0)}function ie(t){return t.modifiedFiles.length===0&&t.workSummary.trim().length===0&&t.linkedGitRefIds.length===0?null:{modifiedFiles:t.modifiedFiles,workSummary:t.workSummary,linkedGitRefIds:t.linkedGitRefIds}}function Xe(t,d){return ie({modifiedFiles:(d==null?void 0:d.modifiedFiles)??[],workSummary:(d==null?void 0:d.workSummary)??"",linkedGitRefIds:t.map(c=>c.id).filter(c=>typeof c=="string")})}function $(t){return t.trim().toLowerCase()}function Ve(t){return t==="issue"?["goal","project"]:t==="task"?["goal","project","issue"]:["goal","project","task"]}function Ye(t){return t==="issue"?["goal","project"]:t==="task"?["goal","project","issue"]:["goal","project"]}function fe(t){return t==="task"?"task":t}function Ze(t){var v;const{editingTask:d,initialGoalId:c,initialLevel:b,initialParentWorkItemId:I,initialProjectId:j,defaultUserId:s,projects:i,users:C,workItems:z}=t;if(d)return at(d);const f=I?z.find(N=>N.id===I)??null:null,k=i.find(N=>N.id===((f==null?void 0:f.projectId)??j))??null,w=(k==null?void 0:k.userId)??s??null;return{...X,level:b??((f==null?void 0:f.level)==="issue"?"task":(f==null?void 0:f.level)==="task"?"subtask":X.level),owner:((v=C.find(N=>N.id===w))==null?void 0:v.displayName)??X.owner,userId:w,goalId:(f==null?void 0:f.goalId)??(k==null?void 0:k.goalId)??c??"",projectId:(k==null?void 0:k.id)??"",parentWorkItemId:(f==null?void 0:f.id)??null}}function Je(t){const{draft:d,goals:c,projects:b,workItems:I}=t,j=[];if(d.goalId){const s=c.find(i=>i.id===d.goalId);s&&j.push({id:`goal:${s.id}`,kind:"goal",mode:"existing",entityId:s.id,label:s.title,description:"Goal",searchText:$(`${s.title} ${s.description}`),goalId:s.id,projectId:null,parentWorkItemId:null})}if(d.projectId){const s=b.find(i=>i.id===d.projectId);s&&j.push({id:`project:${s.id}`,kind:"project",mode:"existing",entityId:s.id,label:s.title,description:"Project",searchText:$(`${s.title} ${s.description} ${s.goalTitle}`),goalId:s.goalId,projectId:s.id,parentWorkItemId:null})}if(d.parentWorkItemId){const s=I.find(i=>i.id===d.parentWorkItemId);s&&j.push({id:`${s.level}:${s.id}`,kind:s.level==="issue"?"issue":"task",mode:"existing",entityId:s.id,label:s.title,description:s.level==="issue"?"Issue":"Task",searchText:$(`${s.title} ${s.description} ${s.aiInstructions}`),goalId:s.goalId,projectId:s.projectId,parentWorkItemId:s.parentWorkItemId})}return j}function et(t){const{goals:d,projects:c,workItems:b,allowedKinds:I,editingTaskId:j}=t,s=[];return I.includes("goal")&&s.push(...d.map(i=>({id:`goal:${i.id}`,kind:"goal",mode:"existing",entityId:i.id,label:i.title,description:"Goal",searchText:$(`${i.title} ${i.description}`),goalId:i.id,projectId:null,parentWorkItemId:null}))),I.includes("project")&&s.push(...c.map(i=>({id:`project:${i.id}`,kind:"project",mode:"existing",entityId:i.id,label:i.title,description:`Project · ${i.goalTitle}`,searchText:$(`${i.title} ${i.description} ${i.goalTitle} ${i.productRequirementsDocument}`),goalId:i.goalId,projectId:i.id,parentWorkItemId:null}))),I.includes("issue")&&s.push(...b.filter(i=>i.level==="issue"&&i.id!==j).map(i=>({id:`issue:${i.id}`,kind:"issue",mode:"existing",entityId:i.id,label:i.title,description:"Issue",searchText:$(`${i.title} ${i.description} ${i.aiInstructions} ${i.executionMode??""}`),goalId:i.goalId,projectId:i.projectId,parentWorkItemId:null}))),I.includes("task")&&s.push(...b.filter(i=>i.level==="task"&&i.id!==j).map(i=>({id:`task:${i.id}`,kind:"task",mode:"existing",entityId:i.id,label:i.title,description:"Task",searchText:$(`${i.title} ${i.description} ${i.aiInstructions} ${i.executionMode??""}`),goalId:i.goalId,projectId:i.projectId,parentWorkItemId:i.parentWorkItemId}))),s}function tt(t,d,c){if(d.kind==="goal"){const b=t.projectId?c.find(j=>j.projectId===t.projectId)??null:null,I=!t.projectId||(b==null?void 0:b.goalId)===d.entityId||d.goalId===t.goalId;return{goalId:d.entityId,projectId:I?t.projectId:"",parentWorkItemId:I?t.parentWorkItemId:null}}if(d.kind==="project"){const b=t.parentWorkItemId?c.find(I=>I.id===t.parentWorkItemId)??null:null;return{goalId:d.goalId??t.goalId,projectId:d.entityId,parentWorkItemId:!b||b.projectId===d.entityId?t.parentWorkItemId:null}}return{goalId:d.goalId??t.goalId,projectId:d.projectId??t.projectId,parentWorkItemId:d.entityId}}function rt(t){return t==="goal"?{goalId:"",projectId:"",parentWorkItemId:null}:t==="project"?{projectId:"",parentWorkItemId:null}:{parentWorkItemId:null}}function at(t){var d;return{title:t.title,description:t.description,level:t.level,owner:t.owner,userId:t.userId??null,assigneeUserIds:t.assigneeUserIds??[],goalId:t.goalId??"",projectId:t.projectId??"",parentWorkItemId:t.parentWorkItemId??null,priority:t.priority,status:t.status,effort:t.effort,energy:t.energy,dueDate:t.dueDate??"",points:t.points,plannedDurationSeconds:t.plannedDurationSeconds??86400,actionCostBand:((d=t.actionPointSummary)==null?void 0:d.costBand)??"standard",aiInstructions:t.aiInstructions,executionMode:t.executionMode,acceptanceCriteria:t.acceptanceCriteria,blockerLinks:t.blockerLinks,completionReport:t.completionReport,gitRefs:t.gitRefs,tagIds:t.tagIds,notes:[]}}function jt({open:t,goals:d,projects:c,workItems:b,tags:I,users:j,editingTask:s,initialProjectId:i,initialGoalId:C,initialParentWorkItemId:z,initialLevel:f,initialStepId:k,defaultUserId:w=null,onRefreshEntities:v,currentCreditedSeconds:N,onOpenChange:U,onAdjustTrackedTime:V,onSubmit:Z}){const{t:u}=Fe(),D=d??[],S=c??[],A=b??_e,Y=I??[],F=j??[],[m,o]=p.useState(X),[h,y]=p.useState(null),[M,J]=p.useState({}),[R,ee]=p.useState(""),[ve,P]=p.useState(!1),[te,B]=p.useState(0),[oe,E]=p.useState(null),[st,re]=p.useState(null),[ae,ne]=p.useState(0),ke=a=>{J(Object.fromEntries(Object.entries(a).map(([n,r])=>[n,r==null?void 0:r[0]])))};p.useEffect(()=>{t&&(y(null),J({}),ee(""),P(!1),B(0),E(null),re(null),ne(s?Math.max(0,Math.floor((N??s.time.totalCreditedSeconds)/60)):0),o(Ze({editingTask:s,initialGoalId:C,initialLevel:f,initialParentWorkItemId:z,initialProjectId:i,defaultUserId:w,projects:S,users:F,workItems:A})))},[w,s,C,f,z,i,t,S,F,A,N]);const de=s?Math.max(0,Math.floor((N??s.time.totalCreditedSeconds)/60)):0,O=s?ae-de:0,T=p.useMemo(()=>S.find(a=>a.id===m.projectId)??null,[m.projectId,S]),ce=p.useMemo(()=>Ve(m.level),[m.level]),ue=p.useMemo(()=>Ye(m.level),[m.level]),K=p.useMemo(()=>Je({draft:m,goals:D,projects:S,workItems:A}),[m,D,S,A]),se=p.useMemo(()=>et({goals:D,projects:S,workItems:A,allowedKinds:ce,editingTaskId:s==null?void 0:s.id}),[ce,s==null?void 0:s.id,D,S,A]),L=p.useMemo(()=>{const a=$(R),n=a.length===0?se.slice(0,8):se.filter(l=>l.searchText.includes(a)).slice(0,8);if(a.length===0)return n;const r=ue.map(l=>l==="project"&&!m.goalId?{id:`create:${l}:${a}`,kind:l,mode:"create",label:R.trim(),description:"Pick or create a goal first, then create a project here.",disabled:!0,disabledReason:"Pick or create a goal first."}:l==="issue"&&!m.projectId?{id:`create:${l}:${a}`,kind:l,mode:"create",label:R.trim(),description:"Pick or create a project first, then create an issue here.",disabled:!0,disabledReason:"Pick or create a project first."}:{id:`create:${l}:${a}`,kind:l,mode:"create",label:R.trim(),description:`Create a new ${l} from "${R.trim()}".`});return[...n,...r]},[R,se,ue,m.goalId,m.projectId]),we=F.find(a=>a.id===((T==null?void 0:T.userId)??w))??null;p.useEffect(()=>{T&&m.goalId!==T.goalId&&o(a=>({...a,goalId:T.goalId}))},[m.goalId,T]);const q=a=>{o(n=>({...n,...tt(n,a,A)})),ee(""),E(null),B(0),P(!1)},pe=a=>{o(n=>({...n,...rt(a)})),E(null)},me=async a=>{if(a.disabled){E(a.disabledReason??a.description);return}const n=a.label.trim();if(n){re(a.id),E(null);try{if(a.kind==="goal"){const r=await Re({...Ge,title:n,userId:m.userId??null});await(v==null?void 0:v()),q({id:`goal:${r.goal.id}`,kind:"goal",mode:"existing",entityId:r.goal.id,label:r.goal.title,description:"Goal",searchText:$(`${r.goal.title} ${r.goal.description}`),goalId:r.goal.id,projectId:null,parentWorkItemId:null});return}if(a.kind==="project"){if(!m.goalId)throw new Error("Pick or create a goal first.");const r=await Pe({...ze,goalId:m.goalId,title:n,userId:m.userId??null,assigneeUserIds:m.assigneeUserIds});await(v==null?void 0:v()),q({id:`project:${r.project.id}`,kind:"project",mode:"existing",entityId:r.project.id,label:r.project.title,description:"Project",searchText:$(`${r.project.title} ${r.project.description}`),goalId:r.project.goalId,projectId:r.project.id,parentWorkItemId:null});return}if(a.kind==="issue"){if(!m.projectId)throw new Error("Pick or create a project first.");const r=await Ee({...X,level:"issue",title:n,owner:m.owner,userId:m.userId??null,assigneeUserIds:m.assigneeUserIds,goalId:m.goalId,projectId:m.projectId,executionMode:"afk"});await(v==null?void 0:v()),q({id:`issue:${r.workItem.id}`,kind:"issue",mode:"existing",entityId:r.workItem.id,label:r.workItem.title,description:"Issue",searchText:$(`${r.workItem.title} ${r.workItem.description}`),goalId:r.workItem.goalId,projectId:r.workItem.projectId,parentWorkItemId:null})}}catch(r){E(r instanceof Error?r.message:"Unable to create that linked entity right now.")}finally{re(null)}}},Ne=[{id:"anchor",eyebrow:"Placement",title:"Choose where this work belongs",description:"Anchor the work through the hierarchy. Tasks can carry a goal, project, and issue parent together so the chain of meaning stays explicit.",render:(a,n)=>{var r;return e.jsxs(e.Fragment,{children:[e.jsx(g,{label:"Hierarchy anchors",labelHelp:"Pick the goal and project anchors, then choose the real parent where needed. Tasks can live under issues, subtasks under tasks.",error:M.projectId??null,children:e.jsx("div",{className:"grid gap-3",children:e.jsxs("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[K.length>0?e.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:K.map(l=>e.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-2.5 py-1.5",children:[e.jsx(xe,{kind:fe(l.kind),label:l.label,compact:!0,gradient:!1,className:"max-w-[16rem]"}),e.jsx("button",{type:"button",className:"rounded-full text-[var(--ui-ink-soft)] transition hover:text-[var(--ui-ink-strong)]",onClick:()=>pe(l.kind),"aria-label":`Remove ${l.label}`,children:e.jsx(je,{className:"size-3.5"})})]},l.id))}):null,e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex items-center gap-3 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx(Ie,{className:"size-4 text-[var(--ui-ink-faint)]"}),e.jsx("input",{value:R,onChange:l=>{ee(l.target.value),P(!0),B(0),E(null)},onFocus:()=>P(!0),onBlur:()=>{window.setTimeout(()=>P(!1),120)},onKeyDown:l=>{if(l.key==="Backspace"&&!R&&K.length>0){pe(K[K.length-1].kind);return}if(l.key==="ArrowDown"){l.preventDefault(),P(!0),B(x=>L.length===0?0:Math.min(L.length-1,x+1));return}if(l.key==="ArrowUp"){l.preventDefault(),B(x=>Math.max(0,x-1));return}if(l.key==="Escape"){P(!1);return}if(l.key==="Enter"&&L[te]){l.preventDefault();const x=L[te];x.mode==="existing"?q(x):me(x)}},placeholder:'Search or create Goal, Project, or parent Issue like Goal + "Creative system"',className:"min-w-0 flex-1 bg-transparent text-sm text-[var(--ui-ink-strong)] placeholder:text-[var(--ui-ink-faint)] focus:outline-none"})]}),ve?e.jsx("div",{className:"absolute top-full z-20 mt-2 w-full rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-popover)] p-2 shadow-[var(--ui-shadow-floating)] backdrop-blur-xl",children:L.length>0?L.map((l,x)=>e.jsxs("button",{type:"button",disabled:l.mode==="create"&&l.disabled,className:De("flex w-full items-start justify-between gap-3 rounded-[18px] px-3 py-2.5 text-left transition",x===te?"bg-[var(--ui-surface-active)] text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]",l.mode==="create"&&l.disabled&&"cursor-not-allowed opacity-45"),onMouseEnter:()=>B(x),onMouseDown:G=>G.preventDefault(),onClick:()=>{if(l.mode==="existing"){q(l);return}me(l)},children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(xe,{kind:fe(l.kind),label:l.mode==="create"?`Create ${l.kind}`:l.label,compact:!0,gradient:!1}),l.mode==="create"?e.jsxs(ye,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:['"',l.label,'"']}):null]}),e.jsx("div",{className:"mt-1 text-xs leading-5 text-[var(--ui-ink-faint)]",children:l.description})]}),l.mode==="create"?e.jsx("span",{className:"rounded-full bg-[var(--primary)]/12 p-2 text-[var(--primary)]",children:e.jsx(Ae,{className:"size-3.5"})}):null]},l.id)):e.jsx("div",{className:"px-3 py-2.5 text-sm text-[var(--ui-ink-faint)]",children:"Type to find an existing anchor or create a new one."})}):null]}),oe?e.jsx("div",{className:"mt-3 rounded-[16px] border border-[color-mix(in_srgb,var(--danger)_22%,transparent)] bg-[var(--ui-danger-soft)] px-3 py-2 text-sm text-[var(--danger)]",children:oe}):null]})})}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(g,{label:"Resolved project",children:e.jsx(W,{readOnly:!0,value:(T==null?void 0:T.title)??"",placeholder:"Select or create a project anchor"})}),e.jsx(g,{label:"Resolved goal",children:e.jsx(W,{readOnly:!0,value:((r=D.find(l=>l.id===a.goalId))==null?void 0:r.title)??"",placeholder:"Select or create a goal anchor"})})]})]})}},{id:"shape",eyebrow:"Shape",title:"Define the next concrete move",description:"Keep the task small enough to be actionable and strong enough to clearly move the project forward.",render:(a,n)=>e.jsxs(e.Fragment,{children:[e.jsx(g,{label:"Hierarchy level",error:M.level??null,children:e.jsx(H,{value:a.level,onChange:r=>n({level:r}),options:[{value:"issue",label:"Issue",description:"Vertical slice with AFK or HITL execution mode."},{value:"task",label:"Task",description:"One focused AI session with direct instructions."},{value:"subtask",label:"Subtask",description:"A lightweight child step under a task."}]})}),e.jsx(g,{label:u("common.dialogs.task.title"),error:M.title??null,children:e.jsx(W,{value:a.title,onChange:r=>n({title:r.target.value}),placeholder:"Draft the first mode atlas sketch"})}),e.jsx(g,{label:u("common.dialogs.task.descriptionLabel"),children:e.jsx(Q,{value:a.description,onChange:r=>n({description:r.target.value}),placeholder:"Write the task description in Markdown. Keep it short or turn it into a full acceptance doc."})}),a.level==="issue"||a.level==="task"?e.jsxs(e.Fragment,{children:[e.jsx(g,{label:"Execution mode",children:e.jsx(H,{value:a.executionMode??"afk",onChange:r=>n({executionMode:r}),options:[{value:"afk",label:"AFK",description:"AI can complete the issue flow without waiting on a human decision."},{value:"hitl",label:"HITL",description:"A human decision is required somewhere in the slice."}]})}),e.jsx(g,{label:"Acceptance criteria",children:e.jsx(Q,{value:a.acceptanceCriteria.join(`
3
3
  `),onChange:r=>n({acceptanceCriteria:r.target.value.split(`
4
- `).map(l=>l.trim()).filter(l=>l.length>0)}),placeholder:"Given ... / When ... / Then ..."})})]}):null,a.level!=="issue"?e.jsx(g,{label:"AI instructions",children:e.jsx(Q,{value:a.aiInstructions,onChange:r=>n({aiInstructions:r.target.value}),placeholder:"Tell the executing agent which files and patterns matter, and what finished work looks like."})}):null,e.jsx(g,{label:u("common.dialogs.task.owner"),labelHelp:"The owner is the person or role expected to carry this task.",error:M.owner??null,children:e.jsx(F,{value:a.owner,onChange:r=>n({owner:r.target.value}),placeholder:"Albert"})}),e.jsx(Oe,{value:a.userId,users:W,onChange:r=>{var l;return n({userId:r,owner:((l=W.find(x=>x.id===r))==null?void 0:l.displayName)??a.owner})},label:"Owner user",defaultLabel:Le(we),help:"Tasks can belong to a human or bot user. The linked project owner is suggested first so cross-user task routing stays explicit."}),e.jsx(g,{label:"Assignees",children:e.jsx("select",{multiple:!0,value:a.assigneeUserIds,onChange:r=>n({assigneeUserIds:Array.from(r.target.selectedOptions,l=>l.value)}),className:"min-h-28 rounded-[var(--radius-control)] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-2 text-sm text-[var(--ui-ink-strong)] outline-none transition focus:border-[var(--primary)]",children:W.map(r=>e.jsxs("option",{value:r.id,children:[r.displayName," · ",r.kind]},r.id))})})]})},{id:"execution",eyebrow:"Execution",title:"Set priority, status, effort, and energy",description:"This is the minimum the execution engine needs in order to place the task well and show the right next move.",render:(a,n)=>e.jsxs(e.Fragment,{children:[e.jsx(g,{label:u("common.dialogs.task.priority"),labelHelp:"Priority controls how strongly Forge should surface this task in the board and daily views.",children:e.jsx(H,{value:a.priority,onChange:r=>n({priority:r}),options:[{value:"low",label:u("common.enums.priority.low")},{value:"medium",label:u("common.enums.priority.medium")},{value:"high",label:u("common.enums.priority.high")},{value:"critical",label:u("common.enums.priority.critical")}]})}),e.jsx(g,{label:u("common.dialogs.task.status"),labelHelp:"Status tells Forge whether the task is waiting, ready for focus, active, blocked, or done.",children:e.jsx(H,{value:a.status,onChange:r=>n({status:r}),options:[{value:"backlog",label:u("common.enums.taskStatus.backlog")},{value:"focus",label:u("common.enums.taskStatus.focus")},{value:"in_progress",label:u("common.enums.taskStatus.in_progress")},{value:"blocked",label:u("common.enums.taskStatus.blocked")}]})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(g,{label:u("common.dialogs.task.effort"),labelHelp:"Effort describes how much concentration and time this task usually needs.",children:e.jsx(H,{value:a.effort,onChange:r=>n({effort:r}),options:[{value:"light",label:u("common.enums.effort.light")},{value:"deep",label:u("common.enums.effort.deep")},{value:"marathon",label:u("common.enums.effort.marathon")}]})}),e.jsx(g,{label:u("common.dialogs.task.energy"),labelHelp:"Energy helps you match this task to a low-energy, steady, or high-energy moment.",children:e.jsx(H,{value:a.energy,onChange:r=>n({energy:r}),options:[{value:"low",label:u("common.enums.energy.low")},{value:"steady",label:u("common.enums.energy.steady")},{value:"high",label:u("common.enums.energy.high")}]})})]})]})},{id:"signal",eyebrow:"Reward and timing",title:"Set the reward and timing details",description:"This keeps the daily surfaces honest without forcing you through a bloated last-mile form.",render:(a,n)=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(g,{label:u("common.dialogs.task.xp"),labelHelp:"XP is the reward weight for finishing this task. Higher XP should mean more meaningful work.",error:M.points??null,children:e.jsx(F,{type:"number",value:a.points,onChange:r=>n({points:Number(r.target.value)||0}),placeholder:"60"})}),e.jsx(g,{label:u("common.dialogs.task.dueDate"),labelHelp:"Only add a due date when timing really matters for this task.",children:e.jsx(F,{type:"date",value:a.dueDate,onChange:r=>n({dueDate:r.target.value})})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(g,{label:"Expected duration",labelHelp:"Life Force uses this as the expected shape of the task. The default is one day.",error:M.plannedDurationSeconds??null,children:e.jsx(F,{type:"number",min:15,max:10080,step:15,value:Math.max(15,Math.round((a.plannedDurationSeconds??86400)/60)),onChange:r=>n({plannedDurationSeconds:Math.max(60,(Number(r.target.value)||1440)*60)})})}),s?e.jsx(g,{label:"Tracked minutes",labelHelp:"Change the current credited work total without starting a live run. Forge records the difference as a work adjustment when you save.",children:e.jsx(F,{type:"number",min:0,step:1,value:ae,onChange:r=>ne(Math.max(0,Math.trunc(Number(r.target.value)||0)))})}):null,e.jsx(g,{label:"Action cost",labelHelp:"Choose a simple AP band now. Advanced AP editing can happen later inside the task.",children:e.jsx(H,{value:a.actionCostBand??"standard",onChange:r=>n({actionCostBand:r}),options:[{value:"tiny",label:"Tiny"},{value:"light",label:"Light"},{value:"standard",label:"Standard"},{value:"heavy",label:"Heavy"},{value:"brutal",label:"Brutal"}]})})]}),s?e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:["Currently recorded: ",de," min."," ",B===0?"Saving this edit keeps the tracked total unchanged.":`Saving this edit will ${B>0?"add":"remove"} ${Math.abs(B)} minute${Math.abs(B)===1?"":"s"} from the task history.`]}):null,e.jsx(g,{label:u("common.dialogs.task.tags"),children:e.jsx("div",{className:"flex flex-wrap gap-2",children:Y.map(r=>{const l=a.tagIds.includes(r.id);return e.jsx("button",{type:"button",className:`rounded-full px-3 py-2 text-sm transition ${l?"bg-[var(--ui-surface-active)] text-[var(--ui-ink-strong)]":"bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"}`,onClick:()=>n({tagIds:l?a.tagIds.filter(x=>x!==r.id):[...a.tagIds,r.id]}),children:r.name},r.id)})})})]})},{id:"notes",eyebrow:"Closeout",title:"Capture what changed when the work is done",description:"Completion stays truthful when the closeout records modified files, a concise work summary, and the associated commit refs.",render:(a,n)=>{var r,l;return e.jsxs(e.Fragment,{children:[a.level!=="issue"?e.jsxs(e.Fragment,{children:[e.jsx(g,{label:"Work summary",children:e.jsx(Q,{value:((r=a.completionReport)==null?void 0:r.workSummary)??"",onChange:x=>{var E,_;return n({completionReport:ie({modifiedFiles:((E=a.completionReport)==null?void 0:E.modifiedFiles)??[],workSummary:x.target.value,linkedGitRefIds:((_=a.completionReport)==null?void 0:_.linkedGitRefIds)??[]})})},placeholder:"Summarize what changed in this session and what is now true."})}),e.jsx(g,{label:"Modified files",children:e.jsx(Q,{value:(((l=a.completionReport)==null?void 0:l.modifiedFiles)??[]).join(`
5
- `),onChange:x=>{var E,_;return n({completionReport:ie({modifiedFiles:Qe(x.target.value),workSummary:((E=a.completionReport)==null?void 0:E.workSummary)??"",linkedGitRefIds:((_=a.completionReport)==null?void 0:_.linkedGitRefIds)??[]})})},placeholder:`apps/web/src/pages/kanban-page.tsx
6
- apps/api/src/repositories/tasks.ts`})}),e.jsx(g,{label:"Git links",children:e.jsx(qe,{selectedRefs:a.gitRefs,onChange:x=>n({gitRefs:x,completionReport:Xe(x,a.completionReport)})})})]}):null,e.jsx(g,{label:"Creation notes",children:e.jsx(He,{notes:a.notes,onChange:x=>n({notes:x}),entityLabel:"task"})})]})}},{id:"notes-evidence",eyebrow:"Evidence",title:"Capture launch context if this task needs a durable work note",description:"These notes become linked Markdown evidence on the task immediately, which helps preserve setup context, blockers, or handoff detail.",render:(a,n)=>e.jsx("div",{className:"text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Use the previous step for completion closeout. Use linked notes here only when you want durable extra context, setup detail, or handoff evidence beyond the structured completion report."})}];return e.jsx(Me,{open:t,onOpenChange:U,eyebrow:u("common.dialogs.task.eyebrow"),title:u(s?"common.dialogs.task.editTitle":"common.dialogs.task.createTitle"),description:u("common.dialogs.task.description"),value:m,onChange:o,draftPersistenceKey:s?`task.${s.id}`:"task.new",steps:Ne,initialStepId:k,submitLabel:u(s?"common.dialogs.task.save":"common.dialogs.task.create"),error:h,onSubmit:async()=>{if(y(null),s&&ae<0){y("Tracked minutes cannot be negative.");return}const a=Be.safeParse(m);if(!a.success){ke(a.error.flatten().fieldErrors),y("A few task details still need attention before this move can be saved.");return}J({});try{await Z(a.data,s==null?void 0:s.id),s&&V&&B!==0&&await V({entityType:"task",entityId:s.id,deltaMinutes:B,note:"Adjusted from task editor."}),U(!1)}catch(n){y(n instanceof Error?n.message:"Unable to save this task right now.")}}})}export{jt as TaskDialog,X as defaultTaskValues};
4
+ `).map(l=>l.trim()).filter(l=>l.length>0)}),placeholder:"Given ... / When ... / Then ..."})})]}):null,a.level!=="issue"?e.jsx(g,{label:"AI instructions",children:e.jsx(Q,{value:a.aiInstructions,onChange:r=>n({aiInstructions:r.target.value}),placeholder:"Tell the executing agent which files and patterns matter, and what finished work looks like."})}):null,e.jsx(g,{label:u("common.dialogs.task.owner"),labelHelp:"The owner is the person or role expected to carry this task.",error:M.owner??null,children:e.jsx(W,{value:a.owner,onChange:r=>n({owner:r.target.value}),placeholder:"Albert"})}),e.jsx(Be,{value:a.userId,users:F,onChange:r=>{var l;return n({userId:r,owner:((l=F.find(x=>x.id===r))==null?void 0:l.displayName)??a.owner})},label:"Owner user",defaultLabel:Le(we),help:"Tasks can belong to a human or bot user. The linked project owner is suggested first so cross-user task routing stays explicit."}),e.jsx(g,{label:"Assignees",children:e.jsx("select",{multiple:!0,value:a.assigneeUserIds,onChange:r=>n({assigneeUserIds:Array.from(r.target.selectedOptions,l=>l.value)}),className:"min-h-28 rounded-[var(--radius-control)] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-2 text-sm text-[var(--ui-ink-strong)] outline-none transition focus:border-[var(--primary)]",children:F.map(r=>e.jsxs("option",{value:r.id,children:[r.displayName," · ",r.kind]},r.id))})})]})},{id:"execution",eyebrow:"Execution",title:"Set priority, status, effort, and energy",description:"This is the minimum the execution engine needs in order to place the task well and show the right next move.",render:(a,n)=>e.jsxs(e.Fragment,{children:[e.jsx(g,{label:u("common.dialogs.task.priority"),labelHelp:"Priority controls how strongly Forge should surface this task in the board and daily views.",children:e.jsx(H,{value:a.priority,onChange:r=>n({priority:r}),options:[{value:"low",label:u("common.enums.priority.low")},{value:"medium",label:u("common.enums.priority.medium")},{value:"high",label:u("common.enums.priority.high")},{value:"critical",label:u("common.enums.priority.critical")}]})}),e.jsx(g,{label:u("common.dialogs.task.status"),labelHelp:"Status tells Forge whether the task is waiting, ready for focus, active, blocked, or done.",children:e.jsx(H,{value:a.status,onChange:r=>n({status:r}),options:[{value:"backlog",label:u("common.enums.taskStatus.backlog")},{value:"focus",label:u("common.enums.taskStatus.focus")},{value:"in_progress",label:u("common.enums.taskStatus.in_progress")},{value:"blocked",label:u("common.enums.taskStatus.blocked")}]})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(g,{label:u("common.dialogs.task.effort"),labelHelp:"Effort describes how much concentration and time this task usually needs.",children:e.jsx(H,{value:a.effort,onChange:r=>n({effort:r}),options:[{value:"light",label:u("common.enums.effort.light")},{value:"deep",label:u("common.enums.effort.deep")},{value:"marathon",label:u("common.enums.effort.marathon")}]})}),e.jsx(g,{label:u("common.dialogs.task.energy"),labelHelp:"Energy helps you match this task to a low-energy, steady, or high-energy moment.",children:e.jsx(H,{value:a.energy,onChange:r=>n({energy:r}),options:[{value:"low",label:u("common.enums.energy.low")},{value:"steady",label:u("common.enums.energy.steady")},{value:"high",label:u("common.enums.energy.high")}]})})]})]})},{id:"signal",eyebrow:"Reward and timing",title:"Set the reward and timing details",description:"This keeps the daily surfaces honest without forcing you through a bloated last-mile form.",render:(a,n)=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(g,{label:u("common.dialogs.task.xp"),labelHelp:"XP is the reward weight for finishing this task. Higher XP should mean more meaningful work.",error:M.points??null,children:e.jsx(W,{type:"number",value:a.points,onChange:r=>n({points:Number(r.target.value)||0}),placeholder:"60"})}),e.jsx(g,{label:u("common.dialogs.task.dueDate"),labelHelp:"Only add a due date when timing really matters for this task.",children:e.jsx(W,{type:"date",value:a.dueDate,onChange:r=>n({dueDate:r.target.value})})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(g,{label:"Expected duration",labelHelp:"Life Force uses this as the expected shape of the task. The default is one day.",error:M.plannedDurationSeconds??null,children:e.jsx(W,{type:"number",min:15,max:10080,step:15,value:Math.max(15,Math.round((a.plannedDurationSeconds??86400)/60)),onChange:r=>n({plannedDurationSeconds:Math.max(60,(Number(r.target.value)||1440)*60)})})}),s?e.jsx(g,{label:"Tracked minutes",labelHelp:"Change the current credited work total without starting a live run. Forge records the difference as a work adjustment when you save.",children:e.jsx(W,{type:"number",min:0,step:1,value:ae,onChange:r=>ne(Math.max(0,Math.trunc(Number(r.target.value)||0)))})}):null,e.jsx(g,{label:"Action cost",labelHelp:"Choose a simple AP band now. Advanced AP editing can happen later inside the task.",children:e.jsx(H,{value:a.actionCostBand??"standard",onChange:r=>n({actionCostBand:r}),options:[{value:"tiny",label:"Tiny"},{value:"light",label:"Light"},{value:"standard",label:"Standard"},{value:"heavy",label:"Heavy"},{value:"brutal",label:"Brutal"}]})})]}),s?e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:["Currently recorded: ",de," min."," ",O===0?"Saving this edit keeps the tracked total unchanged.":`Saving this edit will ${O>0?"add":"remove"} ${Math.abs(O)} minute${Math.abs(O)===1?"":"s"} from the task history.`]}):null,e.jsx(g,{label:u("common.dialogs.task.tags"),children:e.jsx("div",{className:"flex flex-wrap gap-2",children:Y.map(r=>{const l=a.tagIds.includes(r.id);return e.jsx("button",{type:"button",className:`rounded-full px-3 py-2 text-sm transition ${l?"bg-[var(--ui-surface-active)] text-[var(--ui-ink-strong)]":"bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"}`,onClick:()=>n({tagIds:l?a.tagIds.filter(x=>x!==r.id):[...a.tagIds,r.id]}),children:r.name},r.id)})})})]})},{id:"notes",eyebrow:"Closeout",title:"Capture what changed when the work is done",description:"Completion stays truthful when the closeout records modified files, a concise work summary, and the associated commit refs.",render:(a,n)=>{var r,l;return e.jsxs(e.Fragment,{children:[a.level!=="issue"?e.jsxs(e.Fragment,{children:[e.jsx(g,{label:"Work summary",children:e.jsx(Q,{value:((r=a.completionReport)==null?void 0:r.workSummary)??"",onChange:x=>{var G,_;return n({completionReport:ie({modifiedFiles:((G=a.completionReport)==null?void 0:G.modifiedFiles)??[],workSummary:x.target.value,linkedGitRefIds:((_=a.completionReport)==null?void 0:_.linkedGitRefIds)??[]})})},placeholder:"Summarize what changed in this session and what is now true."})}),e.jsx(g,{label:"Modified files",children:e.jsx(Q,{value:(((l=a.completionReport)==null?void 0:l.modifiedFiles)??[]).join(`
5
+ `),onChange:x=>{var G,_;return n({completionReport:ie({modifiedFiles:Qe(x.target.value),workSummary:((G=a.completionReport)==null?void 0:G.workSummary)??"",linkedGitRefIds:((_=a.completionReport)==null?void 0:_.linkedGitRefIds)??[]})})},placeholder:`apps/web/src/pages/kanban-page.tsx
6
+ apps/api/src/repositories/tasks.ts`})}),e.jsx(g,{label:"Git links",children:e.jsx(qe,{selectedRefs:a.gitRefs,onChange:x=>n({gitRefs:x,completionReport:Xe(x,a.completionReport)})})})]}):null,e.jsx(g,{label:"Creation notes",children:e.jsx(He,{notes:a.notes,onChange:x=>n({notes:x}),entityLabel:"task"})})]})}},{id:"notes-evidence",eyebrow:"Evidence",title:"Capture launch context if this task needs a durable work note",description:"These notes become linked Markdown evidence on the task immediately, which helps preserve setup context, blockers, or handoff detail.",render:(a,n)=>e.jsx("div",{className:"text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Use the previous step for completion closeout. Use linked notes here only when you want durable extra context, setup detail, or handoff evidence beyond the structured completion report."})}];return e.jsx(Me,{open:t,onOpenChange:U,eyebrow:u("common.dialogs.task.eyebrow"),title:u(s?"common.dialogs.task.editTitle":"common.dialogs.task.createTitle"),description:u("common.dialogs.task.description"),value:m,onChange:o,draftPersistenceKey:s?`task.${s.id}`:"task.new",steps:Ne,initialStepId:k,submitLabel:u(s?"common.dialogs.task.save":"common.dialogs.task.create"),error:h,onSubmit:async()=>{if(y(null),s&&ae<0){y("Tracked minutes cannot be negative.");return}const a=Oe.safeParse(m);if(!a.success){ke(a.error.flatten().fieldErrors),y("A few task details still need attention before this move can be saved.");return}J({});try{await Z(a.data,s==null?void 0:s.id),s&&V&&O!==0&&await V({entityType:"task",entityId:s.id,deltaMinutes:O,note:"Adjusted from task editor."}),U(!1)}catch(n){y(n instanceof Error?n.message:"Unable to save this task right now.")}}})}export{jt as TaskDialog,X as defaultTaskValues};