forge-openclaw-plugin 0.2.100 → 0.2.102

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 (189) hide show
  1. package/dist/assets/{activity-page-5oyCFOns.js → activity-page-CgF7K2ww.js} +1 -1
  2. package/dist/assets/ai-surface-workspace-xtB5RFQu.js +1 -0
  3. package/dist/assets/atlas-panel-B3dPHCmZ.js +1 -0
  4. package/dist/assets/{board-BkDRaMp6.js → board-DqHzdCPQ.js} +1 -1
  5. package/dist/assets/{calendar-page-Bo2iua-a.js → calendar-page-C1Wfd2Fy.js} +1 -1
  6. package/dist/assets/{calendar-rules-DA1g3QUk.js → calendar-rules-CaZXtlxt.js} +1 -1
  7. package/dist/assets/calendar-week-toolbar-BZ_-X3Wb.js +1 -0
  8. package/dist/assets/{charts-P7EVhIog.js → charts-FcU0F3XV.js} +8 -8
  9. package/dist/assets/{companion-sync-lab-page-CosNknOK.js → companion-sync-lab-page-NgeK-O-P.js} +1 -1
  10. package/dist/assets/daily-metrics-dashboard-BMyL0Qr4.js +1 -0
  11. package/dist/assets/{entity-note-count-link-BmGDB572.js → entity-note-count-link-BrS1-O0o.js} +1 -1
  12. package/dist/assets/entity-notes-surface-CBylYDwy.js +1 -0
  13. package/dist/assets/{execution-board-CDRXQB85.js → execution-board-CpO2ch6v.js} +1 -1
  14. package/dist/assets/faceted-token-search-D7xPWfOl.js +1 -0
  15. package/dist/assets/flagship-signal-deck-BEFKOhvx.js +1 -0
  16. package/dist/assets/{floating-action-menu-CJkI2iFy.js → floating-action-menu-zzC2r0Ob.js} +1 -1
  17. package/dist/assets/{forms-BFlTgZ3W.js → forms-CmLAyGqz.js} +1 -1
  18. package/dist/assets/{goal-detail-page-cJvHaLMQ.js → goal-detail-page-JK_Nva8e.js} +1 -1
  19. package/dist/assets/goals-page-yeoJ06Vw.js +1 -0
  20. package/dist/assets/{graph-D6JLqDbD.js → graph-BTa79qum.js} +14 -14
  21. package/dist/assets/{habits-page-DKb96_mj.js → habits-page-Dx5EhkJi.js} +1 -1
  22. package/dist/assets/index-BHIKoiZ6.js +19 -0
  23. package/dist/assets/index-H8R-ABM3.css +1 -0
  24. package/dist/assets/insight-flow-dialog-BtIQXXsS.js +1 -0
  25. package/dist/assets/{insights-page-Dc9oFltJ.js → insights-page-CujrosD_.js} +1 -1
  26. package/dist/assets/{kanban-page-JAxerYh6.js → kanban-page-Q9NuIz5w.js} +1 -1
  27. package/dist/assets/knowledge-graph-page-DaJmlvvM.js +1 -0
  28. package/dist/assets/{life-force-page-BGDbQuVh.js → life-force-page-BGDkKfbJ.js} +1 -1
  29. package/dist/assets/{life-force-workspace-B1fYSXRC.js → life-force-workspace-CLVexVnb.js} +1 -1
  30. package/dist/assets/{maps-ClgJoCjz.js → maps-CF1RagUX.js} +1 -1
  31. package/dist/assets/metric-tile-4iMd_WnJ.js +1 -0
  32. package/dist/assets/{motion-BeD44FeG.js → motion-CfdU2F35.js} +1 -1
  33. package/dist/assets/movement-page-ClaoTNuX.js +1 -0
  34. package/dist/assets/note-markdown-CsGQhQXF.js +3 -0
  35. package/dist/assets/note-tags-input-DdZi93tj.js +1 -0
  36. package/dist/assets/notes-page-DYI8s3NN.js +1 -0
  37. package/dist/assets/{open-in-graph-button-Cg5VrKsC.js → open-in-graph-button-C0TGev7c.js} +1 -1
  38. package/dist/assets/orbit-map-DVXkfQdd.js +1 -0
  39. package/dist/assets/overview-page-BwMlFQKX.js +1 -0
  40. package/dist/assets/page-hero-oFHaAjtL.js +1 -0
  41. package/dist/assets/pill-cluster-7UZd_lHp.js +1 -0
  42. package/dist/assets/{preference-entity-handoff-button-D4WAs9pC.js → preference-entity-handoff-button-DOKV9bZc.js} +1 -1
  43. package/dist/assets/preferences-page-BrKEkmfD.js +1 -0
  44. package/dist/assets/{project-collections-DvaX20q_.js → project-collections-CZagCmeH.js} +1 -1
  45. package/dist/assets/{project-detail-page-drPIFZGb.js → project-detail-page-DogvVNEn.js} +1 -1
  46. package/dist/assets/{project-management-hierarchy-page-BUbRXvny.js → project-management-hierarchy-page-Dr7hW9PW.js} +1 -1
  47. package/dist/assets/{project-management-section-nav-C2Ud8Zdd.js → project-management-section-nav-BLdAgTge.js} +1 -1
  48. package/dist/assets/{projects-page-BGzEZUtg.js → projects-page-UKrby_5-.js} +1 -1
  49. package/dist/assets/psyche-behaviors-page-BeVlXvbj.js +5 -0
  50. package/dist/assets/psyche-flashcards-page-CqAWCO4E.js +1 -0
  51. package/dist/assets/psyche-goal-map-page-IyNnbk_W.js +1 -0
  52. package/dist/assets/psyche-graph-IkUQRaDK.js +1 -0
  53. package/dist/assets/{psyche-metrics-page-zYTJDbyZ.js → psyche-metrics-page-uai0a7Lx.js} +1 -1
  54. package/dist/assets/psyche-mode-guide-page-C7p-ABiF.js +1 -0
  55. package/dist/assets/psyche-modes-page-CLQ5V3w0.js +1 -0
  56. package/dist/assets/psyche-page-NQBHkkpU.js +1 -0
  57. package/dist/assets/psyche-patterns-page-BkRiNpI_.js +5 -0
  58. package/dist/assets/psyche-questionnaire-builder-page-Du-7HwPC.js +1 -0
  59. package/dist/assets/psyche-questionnaire-detail-page-C5-yf8MF.js +1 -0
  60. package/dist/assets/psyche-questionnaire-run-detail-page-CoSH5O6R.js +1 -0
  61. package/dist/assets/psyche-questionnaire-run-page-ChI7c1wy.js +1 -0
  62. package/dist/assets/psyche-questionnaires-page-xUcJJzbI.js +1 -0
  63. package/dist/assets/psyche-report-detail-page-BPrZCFZS.js +3 -0
  64. package/dist/assets/psyche-reports-page-D2EXJmm6.js +1 -0
  65. package/dist/assets/{psyche-schemas-HFmg37Wj.js → psyche-schemas-RcZYaokx.js} +1 -1
  66. package/dist/assets/psyche-schemas-beliefs-page-h0ooZ1lp.js +9 -0
  67. package/dist/assets/psyche-screen-time-page-_3-4LikV.js +1 -0
  68. package/dist/assets/psyche-self-observation-page-BdbCsgR5.js +1 -0
  69. package/dist/assets/psyche-values-page-DuUVki5e.js +5 -0
  70. package/dist/assets/report-chain-fields-BBMz0sGI.js +1 -0
  71. package/dist/assets/{rewards-page-C2HQjIAf.js → rewards-page-PZFPa6rR.js} +1 -1
  72. package/dist/assets/{scheduling-rules-editor-BHOpHOrV.js → scheduling-rules-editor-B9KNKsQz.js} +1 -1
  73. package/dist/assets/schema-badge-D93RcG36.js +1 -0
  74. package/dist/assets/schema-visuals-CvC9a3i6.js +1 -0
  75. package/dist/assets/select-menu-Cdq7foRu.js +1 -0
  76. package/dist/assets/{settings-agents-page-VuYXTiyc.js → settings-agents-page-DPx2F6wf.js} +3 -3
  77. package/dist/assets/{settings-bin-page-BNzvYaOk.js → settings-bin-page-COwP3gjo.js} +1 -1
  78. package/dist/assets/settings-calendar-page-C-ghE0YT.js +5 -0
  79. package/dist/assets/{settings-data-page-CGSlryuI.js → settings-data-page-CBubzKBw.js} +1 -1
  80. package/dist/assets/{settings-logs-page-BTK5fine.js → settings-logs-page-uOuXMeBm.js} +1 -1
  81. package/dist/assets/{settings-mobile-page-CRaObOGo.js → settings-mobile-page-C5rfj8_r.js} +1 -1
  82. package/dist/assets/settings-models-page-DijmUWdU.js +1 -0
  83. package/dist/assets/{settings-page-BP81Mb5R.js → settings-page-B4u5TR5g.js} +1 -1
  84. package/dist/assets/{settings-rewards-page-CDJ1PH2G.js → settings-rewards-page-COiTwkMH.js} +1 -1
  85. package/dist/assets/{settings-section-nav-CCFm27r2.js → settings-section-nav-Dc4IeVBt.js} +1 -1
  86. package/dist/assets/{settings-users-page-TdUocFPa.js → settings-users-page-DEGa5DNn.js} +1 -1
  87. package/dist/assets/settings-wiki-page-Cvsiz5_e.js +1 -0
  88. package/dist/assets/{sleep-page-cI1GMVzk.js → sleep-page-BnSOwkEU.js} +1 -1
  89. package/dist/assets/{sports-page-06LTqp0V.js → sports-page-l1RqXzA_.js} +1 -1
  90. package/dist/assets/{state-B-4sS1xO.js → state-VYvD1QVP.js} +1 -1
  91. package/dist/assets/{strategies-page-DXP9Kx8s.js → strategies-page-DEnPlpAs.js} +1 -1
  92. package/dist/assets/{strategy-detail-page-D6mx_Mik.js → strategy-detail-page-Ls8bxKeH.js} +1 -1
  93. package/dist/assets/strategy-dialog-DMyRKrWf.js +1 -0
  94. package/dist/assets/surface-Bfz_sLX6.js +1 -0
  95. package/dist/assets/{table-WfAPUppN.js → table-C0VTeqw0.js} +1 -1
  96. package/dist/assets/task-detail-page-CgrYgQLD.js +1 -0
  97. package/dist/assets/{timebox-planning-dialog-CaCnoslG.js → timebox-planning-dialog-Ww0NGLLo.js} +1 -1
  98. package/dist/assets/today-page-CIuFHMi1.js +1 -0
  99. package/dist/assets/training-load-page-BIwc648i.js +1 -0
  100. package/dist/assets/{ui-C13Nbgas.js → ui-CsEkP2V8.js} +4 -4
  101. package/dist/assets/use-psyche-focus-target-qxT5Oy_z.js +1 -0
  102. package/dist/assets/{vendor-DHkYh85p.js → vendor-kIz9EZnX.js} +237 -222
  103. package/dist/assets/{vitals-page-BQvEjTc6.js → vitals-page-Dz1Jt5H8.js} +1 -1
  104. package/dist/assets/{weekly-review-page-Tp6Q9CRj.js → weekly-review-page-BFpBe1kI.js} +1 -1
  105. package/dist/assets/weight-loss-page-BgMoBpBt.js +5 -0
  106. package/dist/assets/{wiki-article-markdown-DQYohmW2.js → wiki-article-markdown-gsPTXTg1.js} +1 -1
  107. package/dist/assets/{wiki-editor-page-Dem_3eZv.js → wiki-editor-page-BpAZHooY.js} +7 -7
  108. package/dist/assets/{wiki-ingest-history-page-BxoOcCoJ.js → wiki-ingest-history-page-C-ig8O22.js} +1 -1
  109. package/dist/assets/{wiki-ingest-modal-DhguKk3J.js → wiki-ingest-modal-BK4eQgqs.js} +1 -1
  110. package/dist/assets/{wiki-page-BLRxVXkl.js → wiki-page-CMTZ60Zt.js} +1 -1
  111. package/dist/assets/workbench-flow-page-BIpWUcLJ.js +5 -0
  112. package/dist/assets/workbench-page-CtCjYSRe.js +1 -0
  113. package/dist/assets/workout-detail-page-DD9IGN6l.js +2 -0
  114. package/dist/index.html +9 -9
  115. package/dist/openclaw/local-runtime.js +41 -14
  116. package/dist/server/server/migrations/067_weight_loss_daily_active_overrides.sql +13 -0
  117. package/dist/server/server/src/app.js +103 -30
  118. package/dist/server/server/src/health-weight-loss.js +457 -55
  119. package/dist/server/server/src/health.js +12 -4
  120. package/dist/server/server/src/movement.js +84 -1
  121. package/dist/server/server/src/openapi.js +123 -18
  122. package/dist/server/server/src/repositories/model-settings.js +12 -9
  123. package/dist/server/server/src/repositories/settings.js +19 -5
  124. package/dist/server/server/src/watch-mobile.js +22 -10
  125. package/dist/server/src/components/ui/info-tooltip.js +6 -6
  126. package/dist/server/src/lib/api.js +14 -4
  127. package/dist/server/src/lib/theme-system.js +8 -0
  128. package/openclaw.plugin.json +1 -1
  129. package/package.json +3 -3
  130. package/server/migrations/067_weight_loss_daily_active_overrides.sql +13 -0
  131. package/skills/forge-openclaw/SKILL.md +13 -0
  132. package/skills/forge-openclaw/entity_conversation_playbooks.md +7 -1
  133. package/dist/assets/ai-surface-workspace-qgk_B57-.js +0 -1
  134. package/dist/assets/atlas-panel-rfH2qOez.js +0 -1
  135. package/dist/assets/calendar-week-toolbar-DU1Q4RYj.js +0 -1
  136. package/dist/assets/daily-metrics-dashboard-LjuGAB3f.js +0 -1
  137. package/dist/assets/entity-notes-surface-DgEgicaE.js +0 -1
  138. package/dist/assets/faceted-token-search-CE1YauRd.js +0 -1
  139. package/dist/assets/flagship-signal-deck-DDds90Gl.js +0 -1
  140. package/dist/assets/goals-page-f_39hvUV.js +0 -1
  141. package/dist/assets/index-BHTUu_4M.js +0 -19
  142. package/dist/assets/index-CZbuZQjw.css +0 -1
  143. package/dist/assets/insight-flow-dialog-pzAzyayN.js +0 -1
  144. package/dist/assets/knowledge-graph-page-UQ3skqEi.js +0 -1
  145. package/dist/assets/metric-tile-DX6TclqM.js +0 -1
  146. package/dist/assets/movement-page-6HP6nGJx.js +0 -1
  147. package/dist/assets/note-markdown-DiW2-5d3.js +0 -3
  148. package/dist/assets/note-tags-input-DDLXf54U.js +0 -1
  149. package/dist/assets/notes-page-BuguDjhz.js +0 -1
  150. package/dist/assets/orbit-map-GD05-0oS.js +0 -1
  151. package/dist/assets/overview-page-DuOs2OCB.js +0 -1
  152. package/dist/assets/page-hero-CQWo1Mm_.js +0 -1
  153. package/dist/assets/pill-cluster-BJogDRDJ.js +0 -1
  154. package/dist/assets/preferences-page-BaJTMU1I.js +0 -1
  155. package/dist/assets/psyche-behaviors-page-Dmm_Io9D.js +0 -5
  156. package/dist/assets/psyche-flashcards-page-BgNKJ6QJ.js +0 -1
  157. package/dist/assets/psyche-goal-map-page-DXJs98Vr.js +0 -1
  158. package/dist/assets/psyche-graph-CFgs_Bqc.js +0 -1
  159. package/dist/assets/psyche-mode-guide-page-XPgRfCOf.js +0 -1
  160. package/dist/assets/psyche-modes-page-B-GA8oRF.js +0 -1
  161. package/dist/assets/psyche-page--r6a3e1t.js +0 -1
  162. package/dist/assets/psyche-patterns-page-BM5-3bMm.js +0 -5
  163. package/dist/assets/psyche-questionnaire-builder-page-CJshQ-mg.js +0 -1
  164. package/dist/assets/psyche-questionnaire-detail-page-USmR5G5A.js +0 -1
  165. package/dist/assets/psyche-questionnaire-run-detail-page-D7iBCmTi.js +0 -1
  166. package/dist/assets/psyche-questionnaire-run-page-Cpil-kDh.js +0 -1
  167. package/dist/assets/psyche-questionnaires-page-C-_y3VwS.js +0 -1
  168. package/dist/assets/psyche-report-detail-page--dkSPRaj.js +0 -3
  169. package/dist/assets/psyche-reports-page-CUaOXmIN.js +0 -1
  170. package/dist/assets/psyche-schemas-beliefs-page-BX6xaap3.js +0 -9
  171. package/dist/assets/psyche-screen-time-page-CAAI4mD7.js +0 -1
  172. package/dist/assets/psyche-self-observation-page-BZ6FLuwa.js +0 -1
  173. package/dist/assets/psyche-values-page-yEV6MGt8.js +0 -5
  174. package/dist/assets/report-chain-fields-fZ8Xd4H6.js +0 -1
  175. package/dist/assets/schema-badge-DyKbxb51.js +0 -1
  176. package/dist/assets/schema-visuals-D6nxjbYC.js +0 -1
  177. package/dist/assets/select-menu-BX-pZNqL.js +0 -1
  178. package/dist/assets/settings-calendar-page-CjSFB53S.js +0 -5
  179. package/dist/assets/settings-models-page-DFshpYF8.js +0 -1
  180. package/dist/assets/settings-wiki-page-B2zX0QQG.js +0 -1
  181. package/dist/assets/strategy-dialog-BvzomTaF.js +0 -1
  182. package/dist/assets/task-detail-page-BIWIggdp.js +0 -1
  183. package/dist/assets/today-page-DO2mRPT2.js +0 -1
  184. package/dist/assets/training-load-page-CyZ0mlEr.js +0 -1
  185. package/dist/assets/use-psyche-focus-target-C1C_XjYG.js +0 -1
  186. package/dist/assets/weight-loss-page-BBzlhLVV.js +0 -1
  187. package/dist/assets/workbench-flow-page-DqMkCCTy.js +0 -5
  188. package/dist/assets/workbench-page-BWd02wPw.js +0 -1
  189. package/dist/assets/workout-detail-page-BD8u7GyL.js +0 -2
@@ -0,0 +1 @@
1
+ import{r as c,j as t}from"./vendor-kIz9EZnX.js";import{Q as N,cO as W,F as i,I as u,b as v,ah as f,j as x,T as p}from"./index-BHIKoiZ6.js";function w(e,a){return{originType:(e==null?void 0:e.originType)??"user",originAgentId:(e==null?void 0:e.originAgentId)??"",originLabel:(e==null?void 0:e.originLabel)??"",entityType:(a==null?void 0:a.entityType)??(e==null?void 0:e.entityType)??"",entityId:(a==null?void 0:a.entityId)??(e==null?void 0:e.entityId)??"",timeframeLabel:(e==null?void 0:e.timeframeLabel)??"This week",title:(e==null?void 0:e.title)??"",summary:(e==null?void 0:e.summary)??"",recommendation:(e==null?void 0:e.recommendation)??"",rationale:(e==null?void 0:e.rationale)??"",confidence:(e==null?void 0:e.confidence)??.72,ctaLabel:(e==null?void 0:e.ctaLabel)??"Review insight",targetKind:(a==null?void 0:a.entityType)??(e==null?void 0:e.entityType)??"general"}}function $({open:e,onOpenChange:a,title:j="Store insight",description:T="Capture a clear observation, its recommendation, and where it belongs without dropping into a raw admin form.",eyebrow:I="Insight",pending:L=!1,submitLabel:C="Store insight",initialValue:g,lockedEntity:h,entityCandidates:d=[],onSubmit:F}){const[s,l]=c.useState(()=>w(g,h)),[S,m]=c.useState(null);c.useEffect(()=>{e&&(l(w(g,h)),m(null))},[g,h,e]);const b=c.useMemo(()=>{const o=new Set(["general"]);return d.forEach(n=>o.add(n.entityType)),h&&o.add(h.entityType),Array.from(o)},[d,h]),y=d.filter(o=>o.entityType===s.targetKind),K=[{id:"focus",eyebrow:"Focus",title:"Name the insight and place it in the right context",description:"Start with the main observation, then decide whether this belongs to a specific entity or should stay general.",render:(o,n)=>t.jsxs(t.Fragment,{children:[t.jsx(i,{label:"Insight title",description:"Write the main idea as a clear headline.",labelHelp:"The title should sound like the recommendation or realization you want to remember, not like an internal database field.",children:t.jsx(u,{value:o.title,onChange:r=>n({title:r.target.value}),placeholder:"Weekly review needs a tighter end ritual"})}),t.jsx(i,{label:"Timeframe",description:"Keep the horizon short and readable.",children:t.jsx(u,{value:o.timeframeLabel,onChange:r=>n({timeframeLabel:r.target.value}),placeholder:"This week"})}),t.jsx(i,{label:"Where should this insight live?",description:"Use a specific entity when the insight is about one goal, project, task, or report. Keep it general when it applies to the wider system.",children:h?t.jsxs("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[t.jsx(v,{kind:h.kind,label:h.label}),h.description?t.jsx(f,{className:"mt-2",children:h.description}):null]}):t.jsxs(t.Fragment,{children:[t.jsx(x,{value:o.targetKind,onChange:r=>n({targetKind:r,entityType:r==="general"?"":r,entityId:""}),options:b.map(r=>({value:r,label:r==="general"?"General insight":r==="trigger_report"?"Report":r.charAt(0).toUpperCase()+r.slice(1),description:r==="general"?"Store it in the broader insight feed.":`Attach it to a specific ${r==="trigger_report"?"report":r}.`})),columns:b.length>=3?3:2}),o.targetKind!=="general"?y.length>0?t.jsx("div",{className:"mt-4 grid gap-3 md:grid-cols-2",children:y.map(r=>{const A=o.entityType===r.entityType&&o.entityId===r.entityId;return t.jsxs("button",{type:"button",className:`rounded-[22px] border px-4 py-4 text-left transition ${A?"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-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)]"}`,onClick:()=>n({entityType:r.entityType,entityId:r.entityId}),children:[t.jsx(v,{kind:r.kind,label:r.label,compact:!0}),r.description?t.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-faint)]",children:r.description}):null]},`${r.entityType}:${r.entityId}`)})}):t.jsxs(f,{className:"mt-4",children:["No"," ",o.targetKind==="trigger_report"?"reports":`${o.targetKind}s`," ","are ready to attach here yet."]}):null]})})]})},{id:"observation",eyebrow:"Observation",title:"Capture what you are seeing clearly",description:"Keep the summary plain and useful. Add the why only if it helps the next action make sense.",render:(o,n)=>t.jsxs(t.Fragment,{children:[t.jsx(i,{label:"Summary",description:"Describe the pattern, problem, or opportunity in plain language.",labelHelp:"Write what is actually happening, not a slogan and not a long essay.",children:t.jsx(p,{value:o.summary,onChange:r=>n({summary:r.target.value}),placeholder:"The weekly review loses energy because the close-out is vague, so finished work never turns into clear next moves."})}),t.jsx(i,{label:"Why this matters",description:"Optional context that helps explain the recommendation.",children:t.jsx(p,{value:o.rationale,onChange:r=>n({rationale:r.target.value}),placeholder:"When the close-out is loose, important wins disappear from memory and the next week starts without momentum."})})]})},{id:"move",eyebrow:"Next move",title:"Turn the insight into a recommendation",description:"Finish with the recommendation you want the user or agent to actually act on.",render:(o,n)=>t.jsxs(t.Fragment,{children:[t.jsx(i,{label:"Recommendation",description:"Write the concrete move this insight points toward.",labelHelp:"A recommendation should be actionable. If the user read only this line, they should know what to do next.",children:t.jsx(p,{value:o.recommendation,onChange:r=>n({recommendation:r.target.value}),placeholder:"Add a fixed five-minute close-out block that turns finished tasks into one sentence of evidence and one next move."})}),t.jsx(i,{label:"Confidence",description:"Choose how strongly this recommendation holds up right now.",children:t.jsx(x,{value:String(o.confidence),onChange:r=>n({confidence:Number(r)}),options:[{value:"0.55",label:"Low",description:"Useful hunch, still early."},{value:"0.72",label:"Medium",description:"Solid pattern, worth acting on."},{value:"0.88",label:"High",description:"Clear enough to trust strongly."}],columns:3})})]})}];return t.jsx(N,{open:e,onOpenChange:a,eyebrow:I,title:j,description:T,value:s,onChange:l,draftPersistenceKey:"insights.flow",steps:K,submitLabel:C,pending:L,error:S,onSubmit:async()=>{m(null);const o=W.safeParse({originType:s.originType,originAgentId:s.originAgentId,originLabel:s.originLabel,entityType:s.targetKind==="general"?"":s.entityType,entityId:s.targetKind==="general"?"":s.entityId,timeframeLabel:s.timeframeLabel,title:s.title,summary:s.summary,recommendation:s.recommendation,rationale:s.rationale,confidence:s.confidence,ctaLabel:s.ctaLabel});if(!o.success){m("This insight still needs a title, a summary, and a recommendation before it can be stored.");return}try{await F(o.data),a(!1)}catch(n){m(n instanceof Error?n.message:"Unable to store this insight right now.")}}})}export{$ as I};
@@ -1,4 +1,4 @@
1
- import{r as w,j as e,b5 as W}from"./vendor-DHkYh85p.js";import{j as z,i as X,k as M}from"./state-B-4sS1xO.js";import{Q as H,ae as Y,af as V,ag as J,F as f,j as Z,I as _,T as L,b as ee,ah as te,u as ie,ai as ne,aj as U,ak as se,i as re,al as ae,am as oe,an as de,ao as le,ap as ce,L as pe,E as ue,B as E,C as F,aq as $,c as Q,U as he,ar as me}from"./index-BHTUu_4M.js";import{I as ge}from"./insight-flow-dialog-pzAzyayN.js";import{P as xe}from"./page-hero-CQWo1Mm_.js";import{R as fe,A as ye,X as je,Y as we,a as R}from"./charts-P7EVhIog.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";const ke={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:[]},be={goalId:"",title:"",description:"",status:"active",workflowStatus:"backlog",userId:null,assigneeUserIds:[],targetPoints:240,themeColor:"#c0c1ff",productRequirementsDocument:"",notes:[]},Ie={title:"",description:"",horizon:"year",status:"active",userId:null,targetPoints:400,themeColor:"#c8a46b",tagIds:[],notes:[]},ve=["goal","project","task","tag","note","insight","psyche_value","behavior_pattern","behavior","belief_entry","mode_profile","mode_guide_session","flashcard","event_type","emotion_definition","trigger_report"];function Ne(t){return t!==null&&ve.includes(t)}function K(t,o,a=96){const r=t.trim()||o.trim();return r.length<=a?r:`${r.slice(0,a-1).trimEnd()}…`}function Te(t){return[t.summary.trim(),t.rationale.trim()?`Why it matters: ${t.rationale.trim()}`:""].filter(Boolean).join(`
1
+ import{r as w,j as e,b5 as W}from"./vendor-kIz9EZnX.js";import{j as z,i as X,k as M}from"./state-VYvD1QVP.js";import{Q as H,ae as Y,af as V,ag as J,F as f,j as Z,I as _,T as L,b as ee,ah as te,u as ie,ai as ne,aj as U,ak as se,i as re,al as ae,am as oe,an as de,ao as le,ap as ce,L as pe,E as ue,B as E,C as F,aq as $,c as Q,U as he,ar as me}from"./index-BHIKoiZ6.js";import{I as ge}from"./insight-flow-dialog-BtIQXXsS.js";import{P as xe}from"./page-hero-oFHaAjtL.js";import{R as fe,A as ye,X as je,Y as we,a as R}from"./charts-FcU0F3XV.js";import"./motion-CfdU2F35.js";import"./ui-CsEkP2V8.js";import"./forms-CmLAyGqz.js";import"./board-DqHzdCPQ.js";import"./graph-BTa79qum.js";const ke={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:[]},be={goalId:"",title:"",description:"",status:"active",workflowStatus:"backlog",userId:null,assigneeUserIds:[],targetPoints:240,themeColor:"#c0c1ff",productRequirementsDocument:"",notes:[]},Ie={title:"",description:"",horizon:"year",status:"active",userId:null,targetPoints:400,themeColor:"#c8a46b",tagIds:[],notes:[]},ve=["goal","project","task","tag","note","insight","psyche_value","behavior_pattern","behavior","belief_entry","mode_profile","mode_guide_session","flashcard","event_type","emotion_definition","trigger_report"];function Ne(t){return t!==null&&ve.includes(t)}function K(t,o,a=96){const r=t.trim()||o.trim();return r.length<=a?r:`${r.slice(0,a-1).trimEnd()}…`}function Te(t){return[t.summary.trim(),t.rationale.trim()?`Why it matters: ${t.rationale.trim()}`:""].filter(Boolean).join(`
2
2
 
3
3
  `)}function G(t){return!Ne(t.entityType)||!t.entityId?null:{entityType:t.entityType,entityId:t.entityId,anchorKey:null}}function O(t,o,a){var r,d;return t.entityType==="goal"&&t.entityId?t.entityId:t.entityType==="project"&&t.entityId?((r=o.find(h=>h.id===t.entityId))==null?void 0:r.goalId)??"":t.entityType==="task"&&t.entityId?((d=a.find(h=>h.id===t.entityId))==null?void 0:d.goalId)??"":""}function Ce(t,o){var a;return t.entityType==="project"&&t.entityId?t.entityId:t.entityType==="task"&&t.entityId?((a=o.find(r=>r.id===t.entityId))==null?void 0:a.projectId)??"":""}function B(t,o,a){const r=[];return a.length>0&&r.push("task"),o.length>0&&r.push("project"),r.push("goal"),G(t)&&r.push("note"),r}function Ae(t,o,a){const r=B(t,o,a);return r.includes("task")&&(t.entityType==="task"||t.entityType==="project")?"task":r.includes("project")&&t.entityType==="goal"?"project":r[0]??"goal"}function Se(t,o,a){var b,j,k;const r=O(t,o,a),h=Ce(t,a)||(r?((b=o.find(m=>m.goalId===r))==null?void 0:b.id)??"":"")||((j=o[0])==null?void 0:j.id)||"",y=h?((k=o.find(m=>m.id===h))==null?void 0:k.goalId)??r:r;return{...ke,title:K(t.recommendation,t.title),description:Te(t),goalId:y,projectId:h}}function Ee(t,o,a,r){var y;const h=O(t,a,r)||((y=o[0])==null?void 0:y.id)||"";return{...be,goalId:h,title:K(t.title,t.recommendation),description:`${t.summary.trim()}
4
4
 
@@ -1 +1 @@
1
- import{b5 as Re,r as n,j as s,aC as Ce,b3 as Be,aK as Oe,c9 as Ae}from"./vendor-DHkYh85p.js";import{j as Le,k as A}from"./state-B-4sS1xO.js";import{P as We,u as Ke,c as h,U as me,b as L,s as Ue,as as ze,at as _e,au as qe,B as v,a as pe,av as Qe,C as G,aw as De,m as H,ax as Ve,ay as Ge,Y as He,az as Xe,I as ge,i as Ye}from"./index-BHTUu_4M.js";import{E as Je}from"./execution-board-CDRXQB85.js";import{P as Ze}from"./project-management-section-nav-C2Ud8Zdd.js";import{P as xe}from"./page-hero-CQWo1Mm_.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";import"./entity-note-count-link-BmGDB572.js";import"./floating-action-menu-CJkI2iFy.js";const x={goal:"goal:",project:"project:",tag:"tag:"},k={user:"user:",kind:"kind:"},es=[{value:"project",label:"Project",searchText:"project initiative prd"},{value:"issue",label:"Issue",searchText:"issue vertical slice tracer bullet"},{value:"task",label:"Task",searchText:"task focused ai session"},{value:"subtask",label:"Subtask",searchText:"subtask child step"}];function X(l){return l.trim().toLowerCase()}function ss(l){return l.reduce((t,r)=>(r.startsWith(x.goal)?t.goalIds.push(r.slice(x.goal.length)):r.startsWith(x.project)?t.projectIds.push(r.slice(x.project.length)):r.startsWith(x.tag)&&t.tagIds.push(r.slice(x.tag.length)),t),{goalIds:[],projectIds:[],tagIds:[]})}function ts(l){return l.reduce((t,r)=>{if(r.startsWith(k.user))t.userIds.push(r.slice(k.user.length));else if(r.startsWith(k.kind)){const u=r.slice(k.kind.length);(u==="human"||u==="bot")&&t.kinds.push(u)}return t},{userIds:[],kinds:[]})}function be(l,t,r,u){l([]),t([]),r(""),u(["task","subtask"])}function as(l){const t=l.trim();return t.length===0?{firstTitle:"Split task part 1",secondTitle:"Split task part 2"}:{firstTitle:`${t} - part 1`,secondTitle:`${t} - part 2`}}function bs(){var le,re,oe,de,ce,ue,he;const{t:l}=We(),t=Ke(),r=Re(),u=Le(),[$,W]=n.useState([]),[E,K]=n.useState([]),[y,F]=n.useState(""),[w,U]=n.useState(["task","subtask"]),[z,M]=n.useState(((re=(le=t.snapshot.workItems)==null?void 0:le[0])==null?void 0:re.id)??((oe=t.snapshot.tasks[0])==null?void 0:oe.id)??null),[Y,_]=n.useState(null),[fe,q]=n.useState(void 0),[J,I]=n.useState(null),[je,R]=n.useState(void 0),[o,C]=n.useState(null),[Z,Q]=n.useState(null),[d,B]=n.useState({firstTitle:"",secondTitle:"",remainingRatio:.5}),ke=n.useMemo(()=>[...t.snapshot.goals.map(e=>({value:`${x.goal}${e.id}`,label:e.title,description:"Goal",searchText:`goal ${e.title} ${e.description??""}`,kind:"goal"})),...t.snapshot.dashboard.projects.map(e=>({value:`${x.project}${e.id}`,label:e.title,description:"Project",searchText:`project ${e.title} ${e.description??""} ${e.goalTitle??""}`,kind:"project"})),...t.snapshot.tags.map(e=>({value:`${x.tag}${e.id}`,label:e.name,description:"Tag",searchText:`tag ${e.name} ${e.color??""}`,kind:"tag"}))],[t.snapshot.dashboard.projects,t.snapshot.goals,t.snapshot.tags]),we=n.useMemo(()=>{const e=t.snapshot.users.filter(i=>i.kind==="bot"),a=t.snapshot.users.filter(i=>i.kind==="human");return[{value:`${k.kind}bot`,label:"Bots",description:`${e.length} bot owner${e.length===1?"":"s"}`,searchText:`bots bot ai agents assistants ${e.map(i=>`${i.displayName} ${i.handle}`).join(" ")}`,badge:s.jsx(h,{className:"border-cyan-300/18 bg-cyan-400/12 text-cyan-50",children:"Bots"}),menuBadge:s.jsx(h,{className:"border-cyan-300/18 bg-cyan-400/12 text-cyan-50",children:"Bots"})},{value:`${k.kind}human`,label:"Humans",description:`${a.length} human owner${a.length===1?"":"s"}`,searchText:`humans human people operators ${a.map(i=>`${i.displayName} ${i.handle}`).join(" ")}`,badge:s.jsx(h,{className:"border-amber-300/18 bg-amber-400/12 text-amber-50",children:"Humans"}),menuBadge:s.jsx(h,{className:"border-amber-300/18 bg-amber-400/12 text-amber-50",children:"Humans"})},...t.snapshot.users.map(i=>({value:`${k.user}${i.id}`,label:i.displayName,description:`${i.kind}${i.handle?` · @${i.handle}`:""}`,searchText:`${i.displayName} ${i.handle} ${i.kind} ${i.description}`,badge:s.jsx(me,{user:i,compact:!0}),menuBadge:s.jsx(me,{user:i,compact:!0})}))]},[t.snapshot.users]),ve=n.useMemo(()=>es.map(e=>({value:e.value,label:e.label,searchText:e.searchText,badge:e.value==="subtask"?s.jsx(L,{kind:"task",label:"Subtask",compact:!0,gradient:!1,className:"border-indigo-300/18 bg-indigo-400/12 text-indigo-100"}):s.jsx(L,{kind:e.kind??e.value,label:e.label,compact:!0,gradient:!1}),menuBadge:e.value==="subtask"?s.jsx(L,{kind:"task",label:"Subtask",compact:!0,gradient:!1,className:"border-indigo-300/18 bg-indigo-400/12 text-indigo-100"}):s.jsx(L,{kind:e.kind??e.value,label:e.label,compact:!0,gradient:!1})})),[]),m=n.useMemo(()=>ss($),[$]),b=n.useMemo(()=>ts(E),[E]),O=n.useMemo(()=>X(y),[y]),p=n.useMemo(()=>t.snapshot.workItems&&t.snapshot.workItems.length>0?t.snapshot.workItems:t.snapshot.tasks,[t.snapshot.tasks,t.snapshot.workItems]),ye=n.useMemo(()=>new Map(t.snapshot.dashboard.projects.map(e=>[e.id,e])),[t.snapshot.dashboard.projects]),f=p.filter(e=>{var a;if(!w.includes(e.level))return!1;if(O.length>0){const i=e.projectId?ye.get(e.projectId)??null:null;if(!X([e.title,e.description,e.level,e.aiInstructions??"",e.executionMode??"",(i==null?void 0:i.title)??"",(i==null?void 0:i.goalTitle)??"",((a=e.user)==null?void 0:a.displayName)??"",...(e.assignees??[]).map(P=>P.displayName)].join(" ")).includes(O))return!1}if(m.goalIds.length>0&&(e.goalId===null||!m.goalIds.includes(e.goalId))||m.projectIds.length>0&&(e.projectId===null||!m.projectIds.includes(e.projectId))||m.tagIds.length>0&&!m.tagIds.every(i=>e.tagIds.includes(i)))return!1;if(b.userIds.length>0||b.kinds.length>0){const i=[...e.user?[e.user]:[],...e.assignees??[]],c=i.some(j=>b.userIds.includes(j.id)),P=i.some(j=>b.kinds.includes(j.kind));if(!c&&!P)return!1}return!0}),D=t.snapshot.dashboard.projects.filter(e=>{var a;if(!w.includes("project")||O.length>0&&!X([e.title,e.description,e.goalTitle,e.productRequirementsDocument,((a=e.user)==null?void 0:a.displayName)??"",...(e.assignees??[]).map(c=>c.displayName)].join(" ")).includes(O)||m.goalIds.length>0&&!m.goalIds.includes(e.goalId)||m.projectIds.length>0&&!m.projectIds.includes(e.id))return!1;if(b.userIds.length>0||b.kinds.length>0){const i=[...e.user?[e.user]:[],...e.assignees??[]],c=i.some(j=>b.userIds.includes(j.id)),P=i.some(j=>b.kinds.includes(j.kind));if(!c&&!P)return!1}return!0}),Ie=f.length+D.length,Te=D.length>0||f.length>0,Ne=y.trim().length>0||$.length>0||E.length>0||w.length!==2||!w.includes("task")||!w.includes("subtask"),ee=f.find(e=>e.id===z)??p.find(e=>e.id===z)??null,T=Y?t.snapshot.dashboard.projects.find(e=>e.id===Y)??null:null,g=J?p.find(e=>e.id===J)??null:null,Se=f.filter(e=>e.status==="blocked").length,Pe=f.filter(e=>e.status==="done").length,$e=f.filter(e=>e.status==="focus"||e.status==="in_progress").length,se=t.snapshot.activeTaskRuns.length,te=Ue(t.selectedUserIds),N=Z?p.find(e=>e.id===Z)??null:null,S=async()=>{await Promise.all([t.refresh(),Ye(u),u.invalidateQueries({queryKey:["project-board"]}),u.invalidateQueries({queryKey:["task-context"]})])},Ee=A({mutationFn:({taskId:e,patch:a})=>t.patchTask(e,a),onSuccess:S}),Fe=A({mutationFn:e=>ze(e),onSuccess:S}),Me=A({mutationFn:_e,onSuccess:S}),ae=A({mutationFn:({taskId:e,firstTitle:a,secondTitle:i,remainingRatio:c})=>qe(e,{firstTitle:a,secondTitle:i,remainingRatio:c}),onSuccess:async()=>{await S(),Q(null)}}),ie=(e,a)=>{_(e),q(a)},ne=(e,a)=>{I(e),C(null),R(a)},V=e=>{I(null),R(void 0),C(e)};return p.length===0&&t.snapshot.dashboard.projects.length===0?s.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-5",children:[s.jsx(xe,{title:"Kanban",description:"Move tasks across the board, start work quickly, and keep your next step visible.",badge:"0 visible tasks",actions:s.jsx(v,{size:"lg",onClick:()=>t.openStartWork(),children:"Start work"})}),s.jsx(pe,{eyebrow:l("common.kanban.heroEyebrow"),title:l("common.kanban.emptyTitle"),description:l("common.kanban.emptyDescription"),action:s.jsx(Ce,{to:"/goals",className:"inline-flex whitespace-nowrap rounded-full bg-[var(--primary)] px-4 py-2 text-sm font-medium text-slate-950 transition hover:opacity-90",children:l("common.kanban.emptyAction")})})]}):s.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-5",children:[s.jsx(Ze,{}),s.jsx(xe,{title:"Kanban",description:"Move projects, issues, tasks, and subtasks through one shared execution board, then open the right layer when you need to inspect or edit it.",badge:`${Ie} visible work items`,actions:s.jsx(v,{size:"lg",onClick:()=>t.openStartWork(ee?{taskId:ee.id}:void 0),children:"Start work"})}),s.jsx(Qe,{children:s.jsx(G,{className:"min-w-0 overflow-hidden",children:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Board"}),s.jsx("div",{className:"mt-2 text-base text-white",children:"See projects, issues, tasks, and subtasks in the same workflow lanes, with one card language and one shared board state."})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs(h,{className:"bg-white/[0.08] text-white/72",children:[$e," ready or active"]}),s.jsxs(h,{className:"bg-white/[0.08] text-white/72",children:[Se," blocked"]}),s.jsxs(h,{className:"bg-white/[0.08] text-white/72",children:[Pe," done"]}),s.jsxs(h,{className:"bg-white/[0.08] text-white/72",children:[se," live timer",se===1?"":"s"]}),s.jsxs(h,{className:"bg-[var(--primary)]/12 text-[var(--primary)]",children:[Math.round(((de=t.snapshot.lifeForce)==null?void 0:de.spentTodayAp)??0)," /"," ",Math.round(((ce=t.snapshot.lifeForce)==null?void 0:ce.dailyBudgetAp)??0)," AP"]})]})]})})}),s.jsx(De,{children:s.jsxs(G,{className:"min-w-0 overflow-hidden",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("div",{className:"type-label text-white/40",children:"Filters"}),s.jsx("div",{className:"mt-2 text-sm text-white/56",children:"Use compact entity chips for goals, projects, tags, and owner scopes instead of the wide pill rows."})]}),Ne?s.jsx(v,{variant:"secondary",size:"sm",onClick:()=>be(W,K,F,U),children:"Reset"}):null]}),s.jsxs("div",{className:"mt-4 grid gap-3 xl:grid-cols-[minmax(0,1fr)_minmax(18rem,24rem)]",children:[s.jsx("div",{className:"rounded-[22px] border border-white/10 bg-black/20 px-4 py-3",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Be,{className:"size-4 text-white/36"}),s.jsx("input",{value:y,onChange:e=>F(e.target.value),placeholder:"Search projects, issues, tasks, subtasks, PRDs, owners, and assignees",className:"min-w-0 flex-1 bg-transparent text-sm text-white placeholder:text-white/34 focus:outline-none"}),y.trim().length>0?s.jsx("button",{type:"button",className:"rounded-full text-white/46 transition hover:text-white",onClick:()=>F(""),"aria-label":"Clear board search",children:s.jsx(Oe,{className:"size-4"})}):null]})}),s.jsx(H,{options:ve,selectedValues:w,onChange:e=>U(e),placeholder:"Work item types",emptyMessage:"No work-item levels.",variant:"action-bar"})]}),s.jsxs("div",{className:"mt-3 grid gap-3 xl:grid-cols-[minmax(0,1.55fr)_minmax(18rem,1fr)]",children:[s.jsxs("div",{className:"grid gap-2",children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Entity filters"}),s.jsx(H,{options:ke,selectedValues:$,onChange:W,placeholder:"Filter by goal, project, or tag",emptyMessage:"No matching goals, projects, or tags."})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Owner filters"}),s.jsx(H,{options:we,selectedValues:E,onChange:K,placeholder:"Type Bo for bots, Hu for humans, or a teammate name",emptyMessage:"No matching owners."})]})]})]})}),Te?s.jsx(Ve,{children:s.jsx(Je,{tasks:f,projects:D,activeRuns:t.snapshot.activeTaskRuns,goals:t.snapshot.goals,tags:t.snapshot.tags,notesSummaryByEntity:t.snapshot.dashboard.notesSummaryByEntity,selectedTaskId:z,onMove:async(e,a)=>{await t.patchTaskStatus(e,a)},onMoveProject:async(e,a)=>{await t.patchProject(e,{workflowStatus:a})},onQuickReopenTask:async e=>{await Ge(e),await S()},onDeleteTask:async e=>{await Fe.mutateAsync(e),M(a=>{var i;return a!==e?a:((i=f.find(c=>c.id!==e))==null?void 0:i.id)??null}),I(a=>a===e?null:a)},onStartTask:async e=>{await t.startTaskNow(e),M(e),await u.invalidateQueries({queryKey:["task-context",e]})},onStopTask:async e=>{await t.stopTaskRun(e),M(e.taskId),await u.invalidateQueries({queryKey:["task-context",e.taskId]})},onSelectTask:e=>{M(e)},onOpenProject:e=>{r(`/projects/${e}`)},onOpenTask:e=>{r(`/tasks/${e}`)},onEditProject:e=>{ie(e)},onEditTask:e=>{ne(e)},onLinkProject:e=>{ie(e,"anchor")},onLinkTask:e=>{ne(e,"anchor")},onCreateIssueForProject:e=>{const a=t.snapshot.dashboard.projects.find(i=>i.id===e)??null;a&&V({initialLevel:"issue",initialGoalId:a.goalId,initialProjectId:a.id})},onCreateTaskForIssue:e=>{const a=p.find(i=>i.id===e)??null;a&&V({initialLevel:"task",initialGoalId:a.goalId,initialProjectId:a.projectId,initialParentWorkItemId:a.id})},onCreateSubtaskForTask:e=>{const a=p.find(i=>i.id===e)??null;a&&V({initialLevel:"subtask",initialGoalId:a.goalId,initialProjectId:a.projectId,initialParentWorkItemId:a.id})},onSplitTask:e=>{const a=p.find(c=>c.id===e)??null;if(!a)return;const i=as(a.title);Q(e),B({firstTitle:i.firstTitle,secondTitle:i.secondTitle,remainingRatio:.5})}})}):s.jsx(pe,{eyebrow:l("common.kanban.heroEyebrow"),title:l("common.kanban.noTasksMatch"),description:"No tasks match the current filters. Reset the filters to bring the full board back.",action:s.jsx(v,{variant:"secondary",onClick:()=>be(W,K,F,U),children:"Reset"})}),s.jsx(He,{open:T!==null,goals:t.snapshot.goals,users:t.snapshot.users,editingProject:T,defaultUserId:(T==null?void 0:T.userId)??te,initialStepId:fe,onOpenChange:e=>{e||(_(null),q(void 0))},onSubmit:async(e,a)=>{a&&(await t.patchProject(a,e),_(null),q(void 0))}}),s.jsx(Xe,{open:g!==null||o!==null,goals:t.snapshot.goals,projects:t.snapshot.dashboard.projects,workItems:p,tags:t.snapshot.tags,users:t.snapshot.users,editingTask:g,initialGoalId:o==null?void 0:o.initialGoalId,initialProjectId:o==null?void 0:o.initialProjectId,initialParentWorkItemId:o==null?void 0:o.initialParentWorkItemId,initialLevel:o==null?void 0:o.initialLevel,initialStepId:je,defaultUserId:(g==null?void 0:g.userId)??te,onRefreshEntities:t.refresh,currentCreditedSeconds:g==null?void 0:g.time.totalCreditedSeconds,onOpenChange:e=>{e||(I(null),C(null),R(void 0))},onAdjustTrackedTime:g?async e=>{await Me.mutateAsync(e)}:void 0,onSubmit:async(e,a)=>{a?await Ee.mutateAsync({taskId:a,patch:e}):await t.createTask(e),I(null),C(null),R(void 0)}}),N?s.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-[rgba(5,8,18,0.74)] p-4 backdrop-blur-xl",children:s.jsxs(G,{className:"w-full max-w-xl border border-white/10 bg-[linear-gradient(180deg,rgba(16,22,36,0.96),rgba(9,13,22,0.98))] shadow-[0_32px_90px_rgba(5,8,18,0.58)]",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"mt-1 flex size-11 shrink-0 items-center justify-center rounded-full bg-amber-400/14 text-amber-100",children:s.jsx(Ae,{className:"size-5"})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"font-display text-[1.35rem] leading-tight text-white",children:"Split this task"}),s.jsxs("div",{className:"mt-2 text-sm leading-6 text-white/64",children:[N.title," has grown beyond its expected shape. Split the remaining work into two child tasks while keeping the original history intact."]})]})]}),s.jsxs("div",{className:"mt-5 grid gap-4",children:[s.jsxs("div",{className:"grid gap-2",children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:"First task name"}),s.jsx(ge,{value:d.firstTitle,onChange:e=>B(a=>({...a,firstTitle:e.target.value}))})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Second task name"}),s.jsx(ge,{value:d.secondTitle,onChange:e=>B(a=>({...a,secondTitle:e.target.value}))})]}),s.jsxs("div",{className:"grid gap-3 rounded-[18px] bg-white/[0.04] px-4 py-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm text-white/70",children:[s.jsx("span",{children:"Remaining work ratio"}),s.jsxs("span",{children:[Math.round(d.remainingRatio*100),"% / ",100-Math.round(d.remainingRatio*100),"%"]})]}),s.jsx("input",{type:"range",min:25,max:75,step:5,value:Math.round(d.remainingRatio*100),onChange:e=>B(a=>({...a,remainingRatio:Number(e.target.value)/100}))}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs(h,{className:"bg-white/[0.08] text-white/72",children:[Math.round((((ue=N.actionPointSummary)==null?void 0:ue.totalCostAp)??0)*d.remainingRatio)," ","AP first child"]}),s.jsxs(h,{className:"bg-white/[0.08] text-white/72",children:[Math.round((((he=N.actionPointSummary)==null?void 0:he.totalCostAp)??0)*(1-d.remainingRatio))," ","AP second child"]})]})]})]}),s.jsxs("div",{className:"mt-5 flex flex-wrap justify-end gap-3",children:[s.jsx(v,{variant:"secondary",onClick:()=>{Q(null)},children:"Cancel"}),s.jsx(v,{pending:ae.isPending,disabled:d.firstTitle.trim().length===0||d.secondTitle.trim().length===0,onClick:()=>{ae.mutateAsync({taskId:N.id,firstTitle:d.firstTitle.trim(),secondTitle:d.secondTitle.trim(),remainingRatio:d.remainingRatio})},children:"Create split tasks"})]})]})}):null]})}export{bs as KanbanPage};
1
+ import{b5 as Re,r as n,j as s,aC as Ce,b3 as Be,aK as Oe,c9 as Ae}from"./vendor-kIz9EZnX.js";import{j as Le,k as A}from"./state-VYvD1QVP.js";import{P as We,u as Ke,c as h,U as me,b as L,s as Ue,as as ze,at as _e,au as qe,B as v,a as pe,av as Qe,C as G,aw as De,m as H,ax as Ve,ay as Ge,Y as He,az as Xe,I as ge,i as Ye}from"./index-BHIKoiZ6.js";import{E as Je}from"./execution-board-CpO2ch6v.js";import{P as Ze}from"./project-management-section-nav-BLdAgTge.js";import{P as xe}from"./page-hero-oFHaAjtL.js";import"./motion-CfdU2F35.js";import"./ui-CsEkP2V8.js";import"./forms-CmLAyGqz.js";import"./board-DqHzdCPQ.js";import"./graph-BTa79qum.js";import"./entity-note-count-link-BrS1-O0o.js";import"./floating-action-menu-zzC2r0Ob.js";const x={goal:"goal:",project:"project:",tag:"tag:"},k={user:"user:",kind:"kind:"},es=[{value:"project",label:"Project",searchText:"project initiative prd"},{value:"issue",label:"Issue",searchText:"issue vertical slice tracer bullet"},{value:"task",label:"Task",searchText:"task focused ai session"},{value:"subtask",label:"Subtask",searchText:"subtask child step"}];function X(l){return l.trim().toLowerCase()}function ss(l){return l.reduce((t,r)=>(r.startsWith(x.goal)?t.goalIds.push(r.slice(x.goal.length)):r.startsWith(x.project)?t.projectIds.push(r.slice(x.project.length)):r.startsWith(x.tag)&&t.tagIds.push(r.slice(x.tag.length)),t),{goalIds:[],projectIds:[],tagIds:[]})}function ts(l){return l.reduce((t,r)=>{if(r.startsWith(k.user))t.userIds.push(r.slice(k.user.length));else if(r.startsWith(k.kind)){const u=r.slice(k.kind.length);(u==="human"||u==="bot")&&t.kinds.push(u)}return t},{userIds:[],kinds:[]})}function be(l,t,r,u){l([]),t([]),r(""),u(["task","subtask"])}function as(l){const t=l.trim();return t.length===0?{firstTitle:"Split task part 1",secondTitle:"Split task part 2"}:{firstTitle:`${t} - part 1`,secondTitle:`${t} - part 2`}}function bs(){var le,re,oe,de,ce,ue,he;const{t:l}=We(),t=Ke(),r=Re(),u=Le(),[$,W]=n.useState([]),[E,K]=n.useState([]),[y,F]=n.useState(""),[w,U]=n.useState(["task","subtask"]),[z,M]=n.useState(((re=(le=t.snapshot.workItems)==null?void 0:le[0])==null?void 0:re.id)??((oe=t.snapshot.tasks[0])==null?void 0:oe.id)??null),[Y,_]=n.useState(null),[fe,q]=n.useState(void 0),[J,I]=n.useState(null),[je,R]=n.useState(void 0),[o,C]=n.useState(null),[Z,Q]=n.useState(null),[d,B]=n.useState({firstTitle:"",secondTitle:"",remainingRatio:.5}),ke=n.useMemo(()=>[...t.snapshot.goals.map(e=>({value:`${x.goal}${e.id}`,label:e.title,description:"Goal",searchText:`goal ${e.title} ${e.description??""}`,kind:"goal"})),...t.snapshot.dashboard.projects.map(e=>({value:`${x.project}${e.id}`,label:e.title,description:"Project",searchText:`project ${e.title} ${e.description??""} ${e.goalTitle??""}`,kind:"project"})),...t.snapshot.tags.map(e=>({value:`${x.tag}${e.id}`,label:e.name,description:"Tag",searchText:`tag ${e.name} ${e.color??""}`,kind:"tag"}))],[t.snapshot.dashboard.projects,t.snapshot.goals,t.snapshot.tags]),we=n.useMemo(()=>{const e=t.snapshot.users.filter(i=>i.kind==="bot"),a=t.snapshot.users.filter(i=>i.kind==="human");return[{value:`${k.kind}bot`,label:"Bots",description:`${e.length} bot owner${e.length===1?"":"s"}`,searchText:`bots bot ai agents assistants ${e.map(i=>`${i.displayName} ${i.handle}`).join(" ")}`,badge:s.jsx(h,{className:"border-cyan-300/18 bg-cyan-400/12 text-cyan-50",children:"Bots"}),menuBadge:s.jsx(h,{className:"border-cyan-300/18 bg-cyan-400/12 text-cyan-50",children:"Bots"})},{value:`${k.kind}human`,label:"Humans",description:`${a.length} human owner${a.length===1?"":"s"}`,searchText:`humans human people operators ${a.map(i=>`${i.displayName} ${i.handle}`).join(" ")}`,badge:s.jsx(h,{className:"border-amber-300/18 bg-amber-400/12 text-amber-50",children:"Humans"}),menuBadge:s.jsx(h,{className:"border-amber-300/18 bg-amber-400/12 text-amber-50",children:"Humans"})},...t.snapshot.users.map(i=>({value:`${k.user}${i.id}`,label:i.displayName,description:`${i.kind}${i.handle?` · @${i.handle}`:""}`,searchText:`${i.displayName} ${i.handle} ${i.kind} ${i.description}`,badge:s.jsx(me,{user:i,compact:!0}),menuBadge:s.jsx(me,{user:i,compact:!0})}))]},[t.snapshot.users]),ve=n.useMemo(()=>es.map(e=>({value:e.value,label:e.label,searchText:e.searchText,badge:e.value==="subtask"?s.jsx(L,{kind:"task",label:"Subtask",compact:!0,gradient:!1,className:"border-indigo-300/18 bg-indigo-400/12 text-indigo-100"}):s.jsx(L,{kind:e.kind??e.value,label:e.label,compact:!0,gradient:!1}),menuBadge:e.value==="subtask"?s.jsx(L,{kind:"task",label:"Subtask",compact:!0,gradient:!1,className:"border-indigo-300/18 bg-indigo-400/12 text-indigo-100"}):s.jsx(L,{kind:e.kind??e.value,label:e.label,compact:!0,gradient:!1})})),[]),m=n.useMemo(()=>ss($),[$]),b=n.useMemo(()=>ts(E),[E]),O=n.useMemo(()=>X(y),[y]),p=n.useMemo(()=>t.snapshot.workItems&&t.snapshot.workItems.length>0?t.snapshot.workItems:t.snapshot.tasks,[t.snapshot.tasks,t.snapshot.workItems]),ye=n.useMemo(()=>new Map(t.snapshot.dashboard.projects.map(e=>[e.id,e])),[t.snapshot.dashboard.projects]),f=p.filter(e=>{var a;if(!w.includes(e.level))return!1;if(O.length>0){const i=e.projectId?ye.get(e.projectId)??null:null;if(!X([e.title,e.description,e.level,e.aiInstructions??"",e.executionMode??"",(i==null?void 0:i.title)??"",(i==null?void 0:i.goalTitle)??"",((a=e.user)==null?void 0:a.displayName)??"",...(e.assignees??[]).map(P=>P.displayName)].join(" ")).includes(O))return!1}if(m.goalIds.length>0&&(e.goalId===null||!m.goalIds.includes(e.goalId))||m.projectIds.length>0&&(e.projectId===null||!m.projectIds.includes(e.projectId))||m.tagIds.length>0&&!m.tagIds.every(i=>e.tagIds.includes(i)))return!1;if(b.userIds.length>0||b.kinds.length>0){const i=[...e.user?[e.user]:[],...e.assignees??[]],c=i.some(j=>b.userIds.includes(j.id)),P=i.some(j=>b.kinds.includes(j.kind));if(!c&&!P)return!1}return!0}),D=t.snapshot.dashboard.projects.filter(e=>{var a;if(!w.includes("project")||O.length>0&&!X([e.title,e.description,e.goalTitle,e.productRequirementsDocument,((a=e.user)==null?void 0:a.displayName)??"",...(e.assignees??[]).map(c=>c.displayName)].join(" ")).includes(O)||m.goalIds.length>0&&!m.goalIds.includes(e.goalId)||m.projectIds.length>0&&!m.projectIds.includes(e.id))return!1;if(b.userIds.length>0||b.kinds.length>0){const i=[...e.user?[e.user]:[],...e.assignees??[]],c=i.some(j=>b.userIds.includes(j.id)),P=i.some(j=>b.kinds.includes(j.kind));if(!c&&!P)return!1}return!0}),Ie=f.length+D.length,Te=D.length>0||f.length>0,Ne=y.trim().length>0||$.length>0||E.length>0||w.length!==2||!w.includes("task")||!w.includes("subtask"),ee=f.find(e=>e.id===z)??p.find(e=>e.id===z)??null,T=Y?t.snapshot.dashboard.projects.find(e=>e.id===Y)??null:null,g=J?p.find(e=>e.id===J)??null:null,Se=f.filter(e=>e.status==="blocked").length,Pe=f.filter(e=>e.status==="done").length,$e=f.filter(e=>e.status==="focus"||e.status==="in_progress").length,se=t.snapshot.activeTaskRuns.length,te=Ue(t.selectedUserIds),N=Z?p.find(e=>e.id===Z)??null:null,S=async()=>{await Promise.all([t.refresh(),Ye(u),u.invalidateQueries({queryKey:["project-board"]}),u.invalidateQueries({queryKey:["task-context"]})])},Ee=A({mutationFn:({taskId:e,patch:a})=>t.patchTask(e,a),onSuccess:S}),Fe=A({mutationFn:e=>ze(e),onSuccess:S}),Me=A({mutationFn:_e,onSuccess:S}),ae=A({mutationFn:({taskId:e,firstTitle:a,secondTitle:i,remainingRatio:c})=>qe(e,{firstTitle:a,secondTitle:i,remainingRatio:c}),onSuccess:async()=>{await S(),Q(null)}}),ie=(e,a)=>{_(e),q(a)},ne=(e,a)=>{I(e),C(null),R(a)},V=e=>{I(null),R(void 0),C(e)};return p.length===0&&t.snapshot.dashboard.projects.length===0?s.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-5",children:[s.jsx(xe,{title:"Kanban",description:"Move tasks across the board, start work quickly, and keep your next step visible.",badge:"0 visible tasks",actions:s.jsx(v,{size:"lg",onClick:()=>t.openStartWork(),children:"Start work"})}),s.jsx(pe,{eyebrow:l("common.kanban.heroEyebrow"),title:l("common.kanban.emptyTitle"),description:l("common.kanban.emptyDescription"),action:s.jsx(Ce,{to:"/goals",className:"inline-flex whitespace-nowrap rounded-full bg-[var(--primary)] px-4 py-2 text-sm font-medium text-slate-950 transition hover:opacity-90",children:l("common.kanban.emptyAction")})})]}):s.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-5",children:[s.jsx(Ze,{}),s.jsx(xe,{title:"Kanban",description:"Move projects, issues, tasks, and subtasks through one shared execution board, then open the right layer when you need to inspect or edit it.",badge:`${Ie} visible work items`,actions:s.jsx(v,{size:"lg",onClick:()=>t.openStartWork(ee?{taskId:ee.id}:void 0),children:"Start work"})}),s.jsx(Qe,{children:s.jsx(G,{className:"min-w-0 overflow-hidden",children:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Board"}),s.jsx("div",{className:"mt-2 text-base text-white",children:"See projects, issues, tasks, and subtasks in the same workflow lanes, with one card language and one shared board state."})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs(h,{className:"bg-white/[0.08] text-white/72",children:[$e," ready or active"]}),s.jsxs(h,{className:"bg-white/[0.08] text-white/72",children:[Se," blocked"]}),s.jsxs(h,{className:"bg-white/[0.08] text-white/72",children:[Pe," done"]}),s.jsxs(h,{className:"bg-white/[0.08] text-white/72",children:[se," live timer",se===1?"":"s"]}),s.jsxs(h,{className:"bg-[var(--primary)]/12 text-[var(--primary)]",children:[Math.round(((de=t.snapshot.lifeForce)==null?void 0:de.spentTodayAp)??0)," /"," ",Math.round(((ce=t.snapshot.lifeForce)==null?void 0:ce.dailyBudgetAp)??0)," AP"]})]})]})})}),s.jsx(De,{children:s.jsxs(G,{className:"min-w-0 overflow-hidden",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("div",{className:"type-label text-white/40",children:"Filters"}),s.jsx("div",{className:"mt-2 text-sm text-white/56",children:"Use compact entity chips for goals, projects, tags, and owner scopes instead of the wide pill rows."})]}),Ne?s.jsx(v,{variant:"secondary",size:"sm",onClick:()=>be(W,K,F,U),children:"Reset"}):null]}),s.jsxs("div",{className:"mt-4 grid gap-3 xl:grid-cols-[minmax(0,1fr)_minmax(18rem,24rem)]",children:[s.jsx("div",{className:"rounded-[22px] border border-white/10 bg-black/20 px-4 py-3",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Be,{className:"size-4 text-white/36"}),s.jsx("input",{value:y,onChange:e=>F(e.target.value),placeholder:"Search projects, issues, tasks, subtasks, PRDs, owners, and assignees",className:"min-w-0 flex-1 bg-transparent text-sm text-white placeholder:text-white/34 focus:outline-none"}),y.trim().length>0?s.jsx("button",{type:"button",className:"rounded-full text-white/46 transition hover:text-white",onClick:()=>F(""),"aria-label":"Clear board search",children:s.jsx(Oe,{className:"size-4"})}):null]})}),s.jsx(H,{options:ve,selectedValues:w,onChange:e=>U(e),placeholder:"Work item types",emptyMessage:"No work-item levels.",variant:"action-bar"})]}),s.jsxs("div",{className:"mt-3 grid gap-3 xl:grid-cols-[minmax(0,1.55fr)_minmax(18rem,1fr)]",children:[s.jsxs("div",{className:"grid gap-2",children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Entity filters"}),s.jsx(H,{options:ke,selectedValues:$,onChange:W,placeholder:"Filter by goal, project, or tag",emptyMessage:"No matching goals, projects, or tags."})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Owner filters"}),s.jsx(H,{options:we,selectedValues:E,onChange:K,placeholder:"Type Bo for bots, Hu for humans, or a teammate name",emptyMessage:"No matching owners."})]})]})]})}),Te?s.jsx(Ve,{children:s.jsx(Je,{tasks:f,projects:D,activeRuns:t.snapshot.activeTaskRuns,goals:t.snapshot.goals,tags:t.snapshot.tags,notesSummaryByEntity:t.snapshot.dashboard.notesSummaryByEntity,selectedTaskId:z,onMove:async(e,a)=>{await t.patchTaskStatus(e,a)},onMoveProject:async(e,a)=>{await t.patchProject(e,{workflowStatus:a})},onQuickReopenTask:async e=>{await Ge(e),await S()},onDeleteTask:async e=>{await Fe.mutateAsync(e),M(a=>{var i;return a!==e?a:((i=f.find(c=>c.id!==e))==null?void 0:i.id)??null}),I(a=>a===e?null:a)},onStartTask:async e=>{await t.startTaskNow(e),M(e),await u.invalidateQueries({queryKey:["task-context",e]})},onStopTask:async e=>{await t.stopTaskRun(e),M(e.taskId),await u.invalidateQueries({queryKey:["task-context",e.taskId]})},onSelectTask:e=>{M(e)},onOpenProject:e=>{r(`/projects/${e}`)},onOpenTask:e=>{r(`/tasks/${e}`)},onEditProject:e=>{ie(e)},onEditTask:e=>{ne(e)},onLinkProject:e=>{ie(e,"anchor")},onLinkTask:e=>{ne(e,"anchor")},onCreateIssueForProject:e=>{const a=t.snapshot.dashboard.projects.find(i=>i.id===e)??null;a&&V({initialLevel:"issue",initialGoalId:a.goalId,initialProjectId:a.id})},onCreateTaskForIssue:e=>{const a=p.find(i=>i.id===e)??null;a&&V({initialLevel:"task",initialGoalId:a.goalId,initialProjectId:a.projectId,initialParentWorkItemId:a.id})},onCreateSubtaskForTask:e=>{const a=p.find(i=>i.id===e)??null;a&&V({initialLevel:"subtask",initialGoalId:a.goalId,initialProjectId:a.projectId,initialParentWorkItemId:a.id})},onSplitTask:e=>{const a=p.find(c=>c.id===e)??null;if(!a)return;const i=as(a.title);Q(e),B({firstTitle:i.firstTitle,secondTitle:i.secondTitle,remainingRatio:.5})}})}):s.jsx(pe,{eyebrow:l("common.kanban.heroEyebrow"),title:l("common.kanban.noTasksMatch"),description:"No tasks match the current filters. Reset the filters to bring the full board back.",action:s.jsx(v,{variant:"secondary",onClick:()=>be(W,K,F,U),children:"Reset"})}),s.jsx(He,{open:T!==null,goals:t.snapshot.goals,users:t.snapshot.users,editingProject:T,defaultUserId:(T==null?void 0:T.userId)??te,initialStepId:fe,onOpenChange:e=>{e||(_(null),q(void 0))},onSubmit:async(e,a)=>{a&&(await t.patchProject(a,e),_(null),q(void 0))}}),s.jsx(Xe,{open:g!==null||o!==null,goals:t.snapshot.goals,projects:t.snapshot.dashboard.projects,workItems:p,tags:t.snapshot.tags,users:t.snapshot.users,editingTask:g,initialGoalId:o==null?void 0:o.initialGoalId,initialProjectId:o==null?void 0:o.initialProjectId,initialParentWorkItemId:o==null?void 0:o.initialParentWorkItemId,initialLevel:o==null?void 0:o.initialLevel,initialStepId:je,defaultUserId:(g==null?void 0:g.userId)??te,onRefreshEntities:t.refresh,currentCreditedSeconds:g==null?void 0:g.time.totalCreditedSeconds,onOpenChange:e=>{e||(I(null),C(null),R(void 0))},onAdjustTrackedTime:g?async e=>{await Me.mutateAsync(e)}:void 0,onSubmit:async(e,a)=>{a?await Ee.mutateAsync({taskId:a,patch:e}):await t.createTask(e),I(null),C(null),R(void 0)}}),N?s.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-[rgba(5,8,18,0.74)] p-4 backdrop-blur-xl",children:s.jsxs(G,{className:"w-full max-w-xl border border-white/10 bg-[linear-gradient(180deg,rgba(16,22,36,0.96),rgba(9,13,22,0.98))] shadow-[0_32px_90px_rgba(5,8,18,0.58)]",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"mt-1 flex size-11 shrink-0 items-center justify-center rounded-full bg-amber-400/14 text-amber-100",children:s.jsx(Ae,{className:"size-5"})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"font-display text-[1.35rem] leading-tight text-white",children:"Split this task"}),s.jsxs("div",{className:"mt-2 text-sm leading-6 text-white/64",children:[N.title," has grown beyond its expected shape. Split the remaining work into two child tasks while keeping the original history intact."]})]})]}),s.jsxs("div",{className:"mt-5 grid gap-4",children:[s.jsxs("div",{className:"grid gap-2",children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:"First task name"}),s.jsx(ge,{value:d.firstTitle,onChange:e=>B(a=>({...a,firstTitle:e.target.value}))})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Second task name"}),s.jsx(ge,{value:d.secondTitle,onChange:e=>B(a=>({...a,secondTitle:e.target.value}))})]}),s.jsxs("div",{className:"grid gap-3 rounded-[18px] bg-white/[0.04] px-4 py-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm text-white/70",children:[s.jsx("span",{children:"Remaining work ratio"}),s.jsxs("span",{children:[Math.round(d.remainingRatio*100),"% / ",100-Math.round(d.remainingRatio*100),"%"]})]}),s.jsx("input",{type:"range",min:25,max:75,step:5,value:Math.round(d.remainingRatio*100),onChange:e=>B(a=>({...a,remainingRatio:Number(e.target.value)/100}))}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs(h,{className:"bg-white/[0.08] text-white/72",children:[Math.round((((ue=N.actionPointSummary)==null?void 0:ue.totalCostAp)??0)*d.remainingRatio)," ","AP first child"]}),s.jsxs(h,{className:"bg-white/[0.08] text-white/72",children:[Math.round((((he=N.actionPointSummary)==null?void 0:he.totalCostAp)??0)*(1-d.remainingRatio))," ","AP second child"]})]})]})]}),s.jsxs("div",{className:"mt-5 flex flex-wrap justify-end gap-3",children:[s.jsx(v,{variant:"secondary",onClick:()=>{Q(null)},children:"Cancel"}),s.jsx(v,{pending:ae.isPending,disabled:d.firstTitle.trim().length===0||d.secondTitle.trim().length===0,onClick:()=>{ae.mutateAsync({taskId:N.id,firstTitle:d.firstTitle.trim(),secondTitle:d.secondTitle.trim(),remainingRatio:d.remainingRatio})},children:"Create split tasks"})]})]})}):null]})}export{bs as KanbanPage};
@@ -0,0 +1 @@
1
+ import{r as p,j as r,b5 as Ut,c2 as qt,cg as Qt,cl as Jt,cm as ot,bf as ct,b4 as Zt,cn as er,co as tr,cp as rr}from"./vendor-kIz9EZnX.js";import{R as nr,P as ar,O as sr,C as ir,T as or,D as cr,a as lt}from"./ui-CsEkP2V8.js";import{i as lr}from"./state-VYvD1QVP.js";import{aA as ur,aB as at,aC as Rt,aD as dr,aE as hr,aF as pr,aG as et,aH as Le,aI as jt,aJ as tt,aK as Gt,aL as Mt,aM as gr,aN as fr,b as qe,V as mr,aO as xr,aP as br,ap as wr,u as yr,aQ as ut,aR as vr,L as Nr,E as Sr,aS as _r,U as dt,a8 as Cr,B as W,m as we,I as Xe,aT as ht,aU as Er,aV as Rr,aW as jr}from"./index-BHIKoiZ6.js";import{G as Gr,S as Mr,i as Fr,C as Kr,B as Ir,M as kr}from"./graph-BTa79qum.js";import{F as pt}from"./faceted-token-search-D7xPWfOl.js";import{A as Ar,m as Or}from"./motion-CfdU2F35.js";import"./forms-CmLAyGqz.js";import"./board-DqHzdCPQ.js";const Pr=Math.PI*(3-Math.sqrt(5)),Tr=.48;function $e(e,t,a){return Math.min(a,Math.max(t,e))}function Dr({positions:e,point:t}){const a=[...e.values()];if(a.length===0)return{x:.5,y:.5};let s=Number.POSITIVE_INFINITY,u=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY;for(const N of a)s=Math.min(s,N.x),u=Math.max(u,N.x),o=Math.min(o,N.y),c=Math.max(c,N.y);const l=Math.max(u-s,0),i=Math.max(c-o,0),m=Math.max(l,i,1),g=(1-l/m)/2,w=(1-i/m)/2,G=l||1,f=i||1;return{x:$e((t.x-s)/G*(l/m)+g,0,1),y:$e((t.y-o)/f*(i/m)+w,0,1)}}function zr(e){let t=2166136261;for(let a=0;a<e.length;a+=1)t^=e.charCodeAt(a),t=Math.imul(t,16777619);return t>>>0}function Lr({nodes:e,cache:t}){const a=new Map,s=[...e].sort((l,i)=>i.importance-l.importance||l.title.localeCompare(i.title)||l.id.localeCompare(i.id));let u=0,o=0,c=0;if(s.forEach((l,i)=>{const m=t.get(l.id);if(m){a.set(l.id,m),u+=m.x,o+=m.y,c+=1;return}const g=(zr(l.id)%1e3/1e3-.5)*.22,w=i*Pr+g,G=Tr*Math.sqrt(i+1),f={x:Math.cos(w)*G,y:Math.sin(w)*G};a.set(l.id,f),u+=f.x,o+=f.y,c+=1}),c>0){const l=u/c,i=o/c;a.forEach((m,g)=>{a.set(g,{x:m.x-l,y:m.y-i})})}return a}function $r(e,t){if(e.startsWith("rgb(")&&e.endsWith(")"))return e.replace("rgb(","rgba(").replace(")",`, ${t})`);if(e.startsWith("#")){const a=e.slice(1),s=a.length===3?a.split("").map(l=>`${l}${l}`).join(""):a,u=parseInt(s.slice(0,2),16),o=parseInt(s.slice(2,4),16),c=parseInt(s.slice(4,6),16);return`rgba(${u}, ${o}, ${c}, ${t})`}return e}function Ge(e,t){return`rgba(${e==="structural"?"125, 211, 252":e==="contextual"?"45, 212, 191":e==="taxonomy"?"192, 132, 252":e==="workspace"?"251, 191, 36":"148, 163, 184"}, ${t})`}function gt(e,t){return!t.focusNodeId||e===t.focusNodeId?0:t.detailNodeIds.has(e)?1:t.relatedNodeIds.has(e)?2:3}function Yr({nodeId:e,attributes:t,node:a,focusNodeId:s,relatedNodeIds:u,detailNodeIds:o,hoveredNodeId:c,draggedNodeId:l}){const i=s===e,m=u.has(e),g=o.has(e),w=c===e,G=l===e,f=!s||m,N=t.color;return{...t,label:i||w||G||g?a.title:"",forceLabel:i||w||G||g,highlighted:i||w||G||g,color:f?N:$r(N,.34),size:G?t.size*2:i?t.size*1.8:w?t.size*1.35:g?t.size*1.16:m?t.size*1.06:t.size,zIndex:G?4:i?3:g||w?2:1}}function Hr({attributes:e,edge:t,focusNodeId:a,detailNodeIds:s,relatedNodeIds:u,hoveredNodeId:o}){const c=!!a&&(t.source===a||t.target===a),l=!!o&&(t.source===o||t.target===o),i={focusNodeId:a,detailNodeIds:s,relatedNodeIds:u},m=a?Math.max(gt(t.source,i),gt(t.target,i)):0,g=c?Ge(t.family,.24):l?Ge(t.family,.14):a?m<=1?Ge(t.family,.09):m===2?Ge(t.family,.05):Ge(t.family,.016):Ge(t.family,.055);return{...e,color:g,size:c?e.size*1.18:l?e.size*1.08:e.size,zIndex:c?2:l?1:0}}function ft(e,t){const a=new Set,s=new Set;for(const u of e)u.source===t?a.add(u.target):u.target===t&&a.add(u.source);for(const u of e)u.source!==t&&a.has(u.source)&&s.add(u.target),u.target!==t&&a.has(u.target)&&s.add(u.source);return s.delete(t),a.forEach(u=>s.delete(u)),{firstRing:[...a].sort(),secondRing:[...s].sort()}}function mt(e,t,a){if(!a)return e.map(()=>-1);const s=new Set(e);if(!s.has(a))return e.map(()=>-1);const u=new Map;for(const l of t){if(!s.has(l.source)||!s.has(l.target))continue;const i=u.get(l.source)??new Set;i.add(l.target),u.set(l.source,i);const m=u.get(l.target)??new Set;m.add(l.source),u.set(l.target,m)}const o=new Map([[a,0]]);let c=[a];for(;c.length>0;){const l=[];for(const i of c){const m=o.get(i);for(const g of u.get(i)??[])o.has(g)||(o.set(g,m+1),l.push(g))}c=l}return e.map(l=>o.get(l)??-1)}function Vr({positions:e,focusNodeId:t,firstRingNodeIds:a,secondRingNodeIds:s,currentRatio:u}){const o=e.get(t);if(!o)return null;const c=[t,...a,...s].filter((L,fe,F)=>F.indexOf(L)===fe),l=c.map(L=>e.get(L)).filter(Boolean);if(l.length===0)return null;let i=Number.POSITIVE_INFINITY,m=Number.NEGATIVE_INFINITY,g=Number.POSITIVE_INFINITY,w=Number.NEGATIVE_INFINITY,G=Number.POSITIVE_INFINITY,f=Number.NEGATIVE_INFINITY,N=Number.POSITIVE_INFINITY,K=Number.NEGATIVE_INFINITY;for(const L of e.values())G=Math.min(G,L.x),f=Math.max(f,L.x),N=Math.min(N,L.y),K=Math.max(K,L.y);for(const L of l)i=Math.min(i,L.x),m=Math.max(m,L.x),g=Math.min(g,L.y),w=Math.max(w,L.y);const E=Math.max(m-i,w-g,.75),z=Math.max(f-G,K-N,E),M=l.length<=1?$e(Math.max(u,.48),.38,.6):$e(E/z*3.2,.42,Math.max(u,1.12));return{x:o.x,y:o.y,ratio:M,nodeIds:c}}function Ft({positions:e,currentRatio:t=1}){const a=[...e.values()];if(a.length===0)return{x:0,y:0,ratio:t};let s=Number.POSITIVE_INFINITY,u=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY;for(const m of a)s=Math.min(s,m.x),u=Math.max(u,m.x),o=Math.min(o,m.y),c=Math.max(c,m.y);const l=Math.max(u-s,c-o,1),i=$e(l/6.4,.72,2.8);return{x:0,y:0,ratio:Math.max(t,i)}}let De=null;function Br(){if(De!==null)return De;if(typeof document>"u")return De=!1,!1;const e=document.createElement("canvas");return De=!!(e.getContext("webgl2")||e.getContext("webgl")||e.getContext("experimental-webgl")),De}function Xr(e){if(!e||typeof window>"u")return"#c0c1ff";const t=document.body?getComputedStyle(document.body).getPropertyValue(e).trim():"",a=getComputedStyle(document.documentElement).getPropertyValue(e).trim(),s=t||a;return s?`rgb(${s})`:"#c0c1ff"}function Wr(e,t){if(e.startsWith("rgb(")&&e.endsWith(")"))return e.replace("rgb(","rgba(").replace(")",`, ${t})`);if(e.startsWith("#")){const a=e.slice(1),s=a.length===3?a.split("").map(l=>`${l}${l}`).join(""):a,u=parseInt(s.slice(0,2),16),o=parseInt(s.slice(2,4),16),c=parseInt(s.slice(4,6),16);return`rgba(${u}, ${o}, ${c}, ${t})`}return e}function ze(e,t){e.forEachNode(a=>{const s=e.getNodeAttributes(a);Number.isFinite(s.x)&&Number.isFinite(s.y)&&t.set(a,{x:s.x,y:s.y})})}function Ur(e,t,a){const s=new Gr,u=[...e].sort((c,l)=>l.importance-c.importance||c.title.localeCompare(l.title)||c.id.localeCompare(l.id)),o=Lr({nodes:u,cache:a});return u.forEach(c=>{const l=o.get(c.id);s.addNode(c.id,{x:(l==null?void 0:l.x)??0,y:(l==null?void 0:l.y)??0,size:Math.max(2.5,c.size/14),color:Xr(c.accentToken),label:c.title,hidden:!1,forceLabel:!1,highlighted:!1,zIndex:0,data:c})}),t.forEach(c=>{!s.hasNode(c.source)||!s.hasNode(c.target)||s.addEdgeWithKey(c.id,c.source,c.target,{size:Math.max(.8,c.strength*1.6),color:c.family==="structural"?"rgba(125, 211, 252, 0.055)":c.family==="contextual"?"rgba(45, 212, 191, 0.055)":c.family==="taxonomy"?"rgba(192, 132, 252, 0.055)":c.family==="workspace"?"rgba(251, 191, 36, 0.055)":"rgba(148, 163, 184, 0.055)",label:c.label,hidden:!1,forceLabel:!1,zIndex:0,data:c})}),s}function xt(e){if(e.order===0)return;let t=0,a=0,s=0;if(e.forEachNode(c=>{const l=e.getNodeAttributes(c);t+=l.x,a+=l.y,s+=1}),s===0)return;const u=t/s,o=a/s;Math.abs(u)<1e-4&&Math.abs(o)<1e-4||e.updateEachNodeAttributes((c,l)=>({...l,x:l.x-u,y:l.y-o}),{attributes:["x","y"]})}function bt(e){const t=new Map;return e.forEachNode(a=>{const s=e.getNodeAttributes(a);t.set(a,{x:s.x,y:s.y})}),t}function Me(e,t){return{nodes:e.nodes().map(a=>({id:a,...e.getNodeAttributes(a)})),edges:t}}function qr(e){if(e.nodes.length===0)return{minX:-1,maxX:1,minY:-1,maxY:1};let t=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,s=Number.POSITIVE_INFINITY,u=Number.NEGATIVE_INFINITY;for(const o of e.nodes)t=Math.min(t,o.x),a=Math.max(a,o.x),s=Math.min(s,o.y),u=Math.max(u,o.y);return{minX:t,maxX:a,minY:s,maxY:u}}function Qr(e){const t=Ft({positions:new Map(e.nodes.map(a=>[a.id,{x:a.x,y:a.y}])),currentRatio:1});return{x:t.x,y:t.y,angle:0,ratio:t.ratio}}function Jr({x:e,y:t}){const a=Array.from({length:e.length},(u,o)=>({x:e[o]??0,y:t[o]??0})),s=ur(a);return s.changed?{changed:!0,offsetX:s.offset.x,offsetY:s.offset.y,x:new Float32Array(s.positions.map(u=>u.x)),y:new Float32Array(s.positions.map(u=>u.y))}:{changed:!1,offsetX:0,offsetY:0,x:new Float32Array(e),y:new Float32Array(t)}}function Kt({node:e,snapshot:t,camera:a,width:s,height:u}){const o=qr(t),c=Math.max(1,o.maxX-o.minX),l=Math.max(1,o.maxY-o.minY),i=28,g=Math.min(Math.max(1,s-i*2)/c,Math.max(1,u-i*2)/l)/Math.max(a.ratio,.08);return{x:s/2+(e.x-a.x)*g,y:u/2-(e.y-a.y)*g,size:Math.max(4,e.size*g*.12)}}function wt(e,t){if(!e)return!1;const a=e.clientWidth,s=e.clientHeight,u=e.getBoundingClientRect();return e.isConnected&&t.width>0&&t.height>0&&a>0&&s>0&&u.width>0&&u.height>0&&e.getClientRects().length>0}function Zr({sigma:e,graph:t,viewportX:a,viewportY:s}){let u=null,o=Number.POSITIVE_INFINITY;return t.forEachNode(c=>{const l=t.getNodeAttributes(c),i=e.getNodeDisplayData(c);if(!i||l.hidden)return;const m=e.graphToViewport({x:l.x,y:l.y}),g=m.x-a,w=m.y-s,G=Math.hypot(g,w),f=Math.max(i.size*1.8,18);G<=f&&G<o&&(u=c,o=G)}),u}function Fe(e,t){return`rgba(${e.family==="structural"?"125, 211, 252":e.family==="contextual"?"45, 212, 191":e.family==="taxonomy"?"192, 132, 252":e.family==="workspace"?"251, 191, 36":"148, 163, 184"}, ${t})`}function It({input:e,rendererMode:t,visibleNodeIds:a,focusPressureByNodeId:s,boundsCenter:u,focusedNodePosition:o,camera:c,nodeScreenPositions:l}){const i=Rt({centroid:e.centroid,boundsCenter:u,camera:c});window.__FORGE_KNOWLEDGE_GRAPH_DIAGNOSTICS__={datasetSignature:e.datasetSignature,visibleNodeIds:a,visibleNodeCount:a.length,focusedNodeId:e.focusNodeId,primaryFocusedNodeId:e.primaryFocusedNodeId,draggedNodeId:e.draggedNodeId,layoutGeneration:e.layoutGeneration,rendererMode:t,startupPhase:e.startupPhase,startupInvariantSatisfied:e.startupInvariantSatisfied,simulationPhase:e.simulationPhase,focusSources:e.focusSources,focusPressureByNodeId:s,graphCentroid:e.centroid,boundsCenter:u,focusedNodePosition:o,cameraTarget:e.cameraTarget,cameraFollowError:e.cameraTarget?{x:Number((c.x-e.cameraTarget.x).toFixed(4)),y:Number((c.y-e.cameraTarget.y).toFixed(4)),ratio:Number((c.ratio-e.cameraTarget.ratio).toFixed(4))}:null,camera:c,nodeScreenPositions:l,centroidDistanceFromOrigin:i.centroidDistanceFromOrigin,boundsCenterDistanceFromOrigin:i.boundsCenterDistanceFromOrigin,cameraDistanceFromOrigin:i.cameraDistanceFromOrigin,cameraToCentroidDistance:i.cameraToCentroidDistance,latestSnapshotAt:e.latestSnapshotAt,latestSnapshotNodeCount:e.latestSnapshotNodeCount}}function en(){if(typeof window>"u")return!1;if(window.__FORGE_ENABLE_GRAPH_DIAGNOSTICS__)return!0;try{return new URLSearchParams(window.location.search).get("graphDiagnostics")==="1"}catch{return!1}}function yt(){typeof window>"u"||(delete window.__FORGE_KNOWLEDGE_GRAPH_DIAGNOSTICS__,delete window.__FORGE_KNOWLEDGE_GRAPH_TEST_API__)}function tn(e){const t=[],a={},s={};let u=null;e.graph.forEachNode(c=>{t.push(c);const l=e.sigma.getNodeDisplayData(c),i=e.graph.getNodeAttributes(c),m=e.sigma.graphToViewport({x:i.x,y:i.y});a[c]={x:m.x,y:m.y,size:(l==null?void 0:l.size)??i.size},s[c]=Number((e.focusPressure[t.length-1]??0).toFixed(4)),c===e.primaryFocusedNodeId&&(u={x:i.x,y:i.y})});const o=at(t.map(c=>{const l=e.graph.getNodeAttributes(c);return{x:l.x,y:l.y}}));It({input:e,rendererMode:"sigma",visibleNodeIds:t,focusPressureByNodeId:s,boundsCenter:o,focusedNodePosition:u,camera:e.sigma.getCamera().getState(),nodeScreenPositions:a})}function vt(e){const t=e.snapshot.nodes.map(o=>o.id),a={},s={};let u=null;e.snapshot.nodes.forEach((o,c)=>{a[o.id]=Kt({node:o,snapshot:e.snapshot,camera:e.camera,width:e.width,height:e.height}),s[o.id]=Number((e.focusPressure[c]??0).toFixed(4)),o.id===e.primaryFocusedNodeId&&(u={x:o.x,y:o.y})}),It({input:e,rendererMode:"fallback",visibleNodeIds:t,focusPressureByNodeId:s,boundsCenter:at(e.snapshot.nodes.map(o=>({x:o.x,y:o.y}))),focusedNodePosition:u,camera:e.camera,nodeScreenPositions:a})}function Nt(e){const t=et.indexOf(e);return t>=0?t:et.length-1}function rn(e){const t=Le.find(a=>a.kinds.some(s=>s===e))??Le[Le.length-1];return{laneId:t.id,laneLabel:t.label,laneIndex:Le.findIndex(a=>a.id===t.id)}}function We(){return{structural:0,contextual:0,taxonomy:0,workspace:0}}function nn(e){const t=new Map;for(const a of e){const s=t.get(a.source)??new Set;s.add(a.target),t.set(a.source,s);const u=t.get(a.target)??new Set;u.add(a.source),t.set(a.target,u)}return t}function an(e,t){return t.strength-e.strength||e.relationKind.localeCompare(t.relationKind)||e.label.localeCompare(t.label)||e.id.localeCompare(t.id)}function kt(e){const t=new Map;for(const a of e){const s=`${a.source}→${a.target}`,u=t.get(s)??[];u.push(a),t.set(s,u)}return Array.from(t.entries()).map(([a,s])=>{const u=[...s].sort(an),o=u[0],c=u.length,l=Math.max(...u.map(i=>i.strength))*Math.min(1.45,1+(c-1)*.12);return{id:`${a}#${o.id}`,source:o.source,target:o.target,relationKind:o.relationKind,family:o.family,label:c>1?`${o.label} +${c-1}`:o.label,strength:l,directional:o.directional,structural:o.structural,parallelCount:c,data:u}}).sort((a,s)=>a.source.localeCompare(s.source)||a.target.localeCompare(s.target)||a.id.localeCompare(s.id))}function sn(e,t){const a=kt(t),s=[...e].sort((o,c)=>{var l;return o.id.localeCompare(c.id)||((l=o.updatedAt)==null?void 0:l.localeCompare(c.updatedAt??""))||0}).map(o=>`${o.id}:${o.title}:${o.size}:${o.importance}:${o.updatedAt??""}`).join("|"),u=a.map(o=>`${o.source}:${o.target}:${o.parallelCount}:${o.label}:${o.strength.toFixed(3)}`).join("|");return`${e.length}/${a.length}/${s}::${u}`}function At(e,t){const a=[...e].sort((l,i)=>{const m=Nt(l.entityKind)-Nt(i.entityKind);return m!==0?m:i.importance-l.importance||l.title.localeCompare(i.title)}),s=new Map,u=a.map(l=>{const{laneId:i,laneIndex:m,laneLabel:g}=rn(l.entityKind),w=s.get(m)??0;return s.set(m,w+1),{...l,layer:m,laneId:i,laneLabel:g,row:w}}),o=new Map(u.map(l=>[l.id,l])),c=t.map(l=>{const i=o.get(l.source),m=o.get(l.target),g=(i==null?void 0:i.layer)??0,w=(m==null?void 0:m.layer)??0;return{...l,secondary:w<=g||l.family!=="structural"&&l.family!=="taxonomy"}});return{nodes:u,edges:c}}function St(e,t,a){const s=new Map(e.map(f=>[f.id,f])),u=a?s.get(a)??null:null;if(!u)return{generatedAt:new Date().toISOString(),focusNode:null,firstRingNodes:[],neighborhoodEdges:[],familyGroups:[],relationCounts:We(),secondRingCounts:We()};const o=t.filter(f=>f.source===u.id||f.target===u.id),c=Array.from(new Set(o.flatMap(f=>f.source===u.id?[f.target]:[f.source]))),l=c.map(f=>s.get(f)??null).filter(f=>!!f),i=new Map,m=We(),g=We(),w=nn(t);for(const f of c){const N=w.get(f)??new Set;for(const K of N){if(K===u.id||c.includes(K))continue;const E=t.filter(z=>z.source===f&&z.target===K||z.target===f&&z.source===K);for(const z of E)g[z.family]+=1}}for(const f of o){const N=f.source===u.id?f.target:f.source,K=s.get(N);if(!K)continue;m[f.family]+=1;const E=i.get(f.relationKind);if(E){E.items.some(z=>z.id===K.id)||E.items.push(K);continue}i.set(f.relationKind,{relationKind:f.relationKind,family:f.family,label:dr[f.relationKind],items:[K]})}const G=new Map;for(const f of i.values()){const N=G.get(f.family);if(N){N.relations.push({...f,items:[...f.items].sort((K,E)=>K.title.localeCompare(E.title))}),N.itemCount+=f.items.length,N.relationCount+=1;continue}G.set(f.family,{family:f.family,label:hr[f.family],relationCount:1,itemCount:f.items.length,relations:[{...f,items:[...f.items].sort((K,E)=>K.title.localeCompare(E.title))}]})}return{generatedAt:new Date().toISOString(),focusNode:u,firstRingNodes:l.sort((f,N)=>f.title.localeCompare(N.title)),neighborhoodEdges:o,familyGroups:[...G.values()].map(f=>({...f,relations:f.relations.sort((N,K)=>N.label.localeCompare(K.label))})).sort((f,N)=>f.label.localeCompare(N.label)),relationCounts:m,secondRingCounts:g}}function on(e,t){return pr(e,t)}function cn(e,t){if(!e)return new Set;const a=new Set([e]);for(const s of t)s.source===e?a.add(s.target):s.target===e&&a.add(s.source);return a}const ln=p.forwardRef(function({nodes:t,edges:a,focusNodeId:s,physicsSettings:u,onSelectNode:o},c){jt(),tt(d=>d.knowledgeGraphDiagnostics.panelOpen);const l=p.useRef(null),i=p.useRef(null),m=p.useRef(null),g=p.useRef(null),w=p.useRef(new Map),G=p.useRef(new Map),f=p.useRef(new Map),N=p.useRef(o),K=p.useRef(s),E=p.useRef(null),z=p.useRef(0),M=p.useRef(null),L=p.useRef(0),fe=p.useRef(!0),F=p.useRef(null),ce=p.useRef(0),A=p.useRef("global"),me=p.useRef(null),Ke=p.useRef([]),Ce=p.useRef(new Float32Array(0)),ye=p.useRef({x:0,y:0}),$=p.useRef("boot"),ve=p.useRef(!1),Y=p.useRef(!1),P=p.useRef(!1),te=p.useRef(null),le=p.useRef(null),Ee=p.useRef(0),Ne=p.useRef(0);p.useRef(0),p.useRef(Gt("/knowledge-graph"));const[Q,ue]=p.useState(null),[xe,de]=p.useState(null),[he,H]=p.useState(null),[pe,V]=p.useState({x:0,y:0,angle:0,ratio:1}),[b,B]=p.useState(null),[v,Ye]=p.useState({width:0,height:0}),Re=Mt(),re=(d=g.current)=>Ft({positions:d?bt(d):new Map,currentRatio:1}).ratio,Ie=(d=g.current)=>({x:.5,y:.5,angle:0,ratio:re(d)}),ke=(d=g.current)=>({x:0,y:0,angle:0,ratio:re(d)}),Ae=()=>i.current?"sigma":"fallback",T=p.useMemo(()=>kt(a),[a]),ge=p.useMemo(()=>sn(t,a),[a,t]),q=p.useMemo(()=>s?ft(T,s):null,[s,T]),ne=p.useMemo(()=>s?new Set([s,...(q==null?void 0:q.firstRing)??[]]):new Set,[s,q]),ae=p.useMemo(()=>s?new Set([s,...(q==null?void 0:q.firstRing)??[],...(q==null?void 0:q.secondRing)??[]]):new Set,[s,q]),He=()=>wt(l.current,v),se=({resize:d=!1}={})=>{if(!i.current||!He())return!1;try{return d&&i.current.resize(),i.current.refresh(),!0}catch(x){if(x instanceof Error&&x.message.includes("Container has no width"))return!1;throw x}},Oe=()=>Date.now()<L.current,D=({level:d,eventKey:x,message:y,details:C,publishBackend:_=!1})=>{},Je=()=>i.current?{...i.current.getCamera().getState()}:{...pe},be=({rendererMode:d})=>{if(!g.current||!E.current)return null;const x=g.current,y=x.nodes().map(S=>{const k=x.getNodeAttributes(S);return{id:S,x:k.x,y:k.y}}),C=gr(y),_=at(y),I=Je(),O=d==="sigma"?{...I,x:Number((I.x-.5).toFixed(4)),y:Number((I.y-.5).toFixed(4))}:I,j=Rt({centroid:C,boundsCenter:_,camera:O});return{datasetSignature:E.current,route:"/knowledge-graph",rendererMode:d,startupPhase:$.current,startupInvariantSatisfied:fr(j),visibleNodeCount:y.length,focusedNodeId:K.current,primaryFocusedNodeId:me.current,graphCentroid:C,boundsCenter:_,camera:I,cameraTarget:F.current?{x:F.current.x,y:F.current.y,ratio:F.current.ratio}:null,driftMetrics:j,latestSnapshotAt:te.current,lastVerifiedAt:new Date().toISOString()}},Ve=(d,{mirrorToConsole:x=!1}={})=>{},Be=({rendererMode:d,publishAnomaly:x})=>{},Pe=()=>{const d=i.current?Ie():ke();if(i.current){i.current.getCamera().setState(d);return}V(d)},n=d=>{var _;if(!g.current)return!1;const x=be({rendererMode:Ae()});if(!x)return!1;const y=x.graphCentroid.x,C=x.graphCentroid.y;return Math.abs(y)<1e-4&&Math.abs(C)<1e-4?!1:(xt(g.current),ze(g.current,w.current),(_=m.current)==null||_.postMessage({type:"recenter-graph",offsetX:y,offsetY:C}),B(Me(g.current,T)),Pe(),$.current="startup_corrected",D({level:"warning",eventKey:"startup_corrected",message:"Corrected the knowledge graph startup bias back to graph-space origin.",publishBackend:!0,details:{datasetSignature:E.current}}),!0)},h=({phase:d,allowCorrection:x,publishBackendOnFailure:y=!1})=>{if(!g.current||!E.current)return;$.current=d;const C=i.current?"sigma":"fallback",_=be({rendererMode:C});if(!_)return;if(_.startupInvariantSatisfied){$.current="startup_verified",Ve({..._},{mirrorToConsole:!0}),D({level:"info",eventKey:"startup_verified",message:"Knowledge graph startup invariant passed.",details:{datasetSignature:_.datasetSignature,driftMetrics:_.driftMetrics}});return}if(D({level:"warning",eventKey:"startup_invariant_failed",message:"Knowledge graph startup invariant failed before correction.",publishBackend:y,details:{datasetSignature:_.datasetSignature,driftMetrics:_.driftMetrics,centroid:_.graphCentroid,boundsCenter:_.boundsCenter,camera:_.camera}}),ve.current||(ve.current=!0,!n()))return;se();const O=be({rendererMode:C});if(O){if(O.startupInvariantSatisfied){$.current="startup_verified",Ve({...O},{mirrorToConsole:!0}),D({level:"info",eventKey:"startup_verified_after_correction",message:"Knowledge graph startup invariant passed after correction.",details:{datasetSignature:O.datasetSignature,driftMetrics:O.driftMetrics}});return}D({level:"error",eventKey:"startup_correction_failed",message:"Knowledge graph startup correction did not restore the origin invariant.",publishBackend:!0,details:{datasetSignature:O.datasetSignature,driftMetrics:O.driftMetrics,centroid:O.graphCentroid,boundsCenter:O.boundsCenter,camera:O.camera}})}},R=()=>{var x,y,C,_;if(!E.current||!g.current)return;const d=Date.now();if(!(d-Ne.current<1500)){if(Ne.current=d,i.current){tn({datasetSignature:E.current,focusNodeId:K.current,primaryFocusedNodeId:me.current,draggedNodeId:((x=M.current)==null?void 0:x.nodeId)??null,graph:g.current,layoutGeneration:z.current,sigma:i.current,startupPhase:$.current,startupInvariantSatisfied:((y=be({rendererMode:"sigma"}))==null?void 0:y.startupInvariantSatisfied)??!1,simulationPhase:A.current,focusSources:Ke.current,focusPressure:Ce.current,centroid:ye.current,cameraTarget:F.current?{x:F.current.x,y:F.current.y,ratio:F.current.ratio}:null,latestSnapshotAt:te.current,latestSnapshotNodeCount:le.current});return}b&&vt({datasetSignature:E.current,focusNodeId:K.current,primaryFocusedNodeId:me.current,draggedNodeId:((C=M.current)==null?void 0:C.nodeId)??null,layoutGeneration:z.current,camera:pe,snapshot:b,width:v.width,height:v.height,startupPhase:$.current,startupInvariantSatisfied:((_=be({rendererMode:"fallback"}))==null?void 0:_.startupInvariantSatisfied)??!1,simulationPhase:A.current,focusSources:Ke.current,focusPressure:Ce.current,centroid:ye.current,cameraTarget:F.current?{x:F.current.x,y:F.current.y,ratio:F.current.ratio}:null,latestSnapshotAt:te.current,latestSnapshotNodeCount:le.current})}},Te=()=>{if(!g.current||!K.current){F.current=null;return}const d=g.current;if(!d.hasNode(K.current)){F.current=null;return}const x=bt(d),y=ft(T,K.current),C=i.current?i.current.getCamera().getState().ratio:pe.ratio,_=Vr({positions:x,focusNodeId:K.current,firstRingNodeIds:y.firstRing,secondRingNodeIds:y.secondRing,currentRatio:C}),I=i.current&&_?Dr({positions:x,point:{x:_.x,y:_.y}}):null;F.current=_?{x:(I==null?void 0:I.x)??_.x,y:(I==null?void 0:I.y)??_.y,angle:0,ratio:_.ratio,nodeIds:_.nodeIds}:null},st=(d=220)=>{if(!F.current)return;const x=F.current;if(i.current){const y=i.current.getCamera(),C=y.getState(),_=Date.now()<ce.current;y.animate({x:x.x,y:x.y,ratio:_?C.ratio:x.ratio,angle:0},{duration:d});return}V(y=>({...y,x:x.x,y:x.y,ratio:Date.now()<ce.current?y.ratio:x.ratio}))};p.useEffect(()=>{N.current=o},[o]),p.useEffect(()=>{K.current=s,F.current=null},[s]),p.useEffect(()=>{yt()},[Re]),p.useEffect(()=>{if(!(!en()||typeof window>"u"))return window.__FORGE_KNOWLEDGE_GRAPH_TEST_API__={selectNode:d=>{var y;const x=d?f.current.get(d)??((y=g.current)!=null&&y.hasNode(d)?g.current.getNodeAttribute(d,"data")??null:null):null;N.current(x)},moveNodeBy:(d,x,y)=>{var O,j;if(!((O=g.current)!=null&&O.hasNode(d)))return;const C=g.current.getNodeAttributes(d),_=C.x+x,I=C.y+y;g.current.mergeNodeAttributes(d,{x:_,y:I}),w.current.set(d,{x:_,y:I}),(j=m.current)==null||j.postMessage({type:"nudge-node",nodeId:d,x:_,y:I}),se(),!i.current&&g.current&&B(Me(g.current,T))},nudgeCameraBy:(d,x)=>{if(i.current){const y=i.current.getCamera(),C=y.getState();y.animate({x:C.x+d,y:C.y+x,ratio:C.ratio,angle:C.angle},{duration:140});return}V(y=>({...y,x:y.x+d,y:y.y+x}))}},()=>{delete window.__FORGE_KNOWLEDGE_GRAPH_TEST_API__}},[T]),p.useEffect(()=>{if(!l.current||typeof ResizeObserver>"u")return;const d=()=>{l.current&&Ye({width:l.current.clientWidth,height:l.current.clientHeight})};d();const x=new ResizeObserver(()=>{d()});return x.observe(l.current),()=>x.disconnect()},[]),p.useImperativeHandle(c,()=>({zoomIn:()=>{if(ce.current=Date.now()+1200,i.current){i.current.getCamera().animatedZoom({factor:1.25,duration:160});return}V(d=>({...d,ratio:Math.max(.08,d.ratio*.82)}))},zoomOut:()=>{if(ce.current=Date.now()+1200,i.current){i.current.getCamera().animatedUnzoom({factor:1.25,duration:160});return}V(d=>({...d,ratio:Math.min(4,d.ratio*1.22)}))},fit:()=>{if(F.current=null,i.current){i.current.getCamera().animate(Ie(),{duration:220});return}b&&V(Qr(b))},recenterOnFocus:()=>{Te(),F.current&&st(220)}}),[b,T]),p.useEffect(()=>()=>{var d,x,y;g.current&&ze(g.current,w.current),i.current&&E.current&&G.current.set(E.current,i.current.getCamera().getState()),(d=m.current)==null||d.postMessage({type:"dispose"}),(x=m.current)==null||x.terminate(),m.current=null,(y=i.current)==null||y.kill(),i.current=null,yt()},[Re]),p.useEffect(()=>{var I,O;if(!l.current||!wt(l.current,v))return;if(E.current===ge&&g.current!==null){se({resize:!0}),R();return}$.current="boot",ve.current=!1,Y.current=!1,P.current=!1,te.current=null,le.current=null,Ee.current=0,F.current=null,D({level:"info",eventKey:"graph_boot",message:"Bootstrapping a fresh knowledge graph dataset.",details:{nodeCount:t.length,edgeCount:T.length}}),g.current&&ze(g.current,w.current),i.current&&E.current&&G.current.set(E.current,i.current.getCamera().getState());const x=Ur(t,T,w.current);if(xt(x),ze(x,w.current),g.current=x,f.current=new Map(t.map(j=>[j.id,j])),E.current=ge,z.current+=1,B(Me(x,T)),$.current="graph_built",D({level:"info",eventKey:"graph_built",message:"Built and centered the knowledge graph structure.",details:{layoutGeneration:z.current}}),!Br())(I=i.current)==null||I.kill(),i.current=null,H("WebGL is unavailable in this browser context."),V(ke(x)),h({phase:"graph_built",allowCorrection:!0,publishBackendOnFailure:!0});else try{if(i.current)i.current.setGraph(x),se();else{i.current=new Mr(x,l.current,{renderEdgeLabels:!1,hideEdgesOnMove:!0,hideLabelsOnMove:!0,labelRenderedSizeThreshold:20,labelDensity:.04,labelGridCellSize:120,defaultNodeColor:"#c0c1ff",defaultEdgeColor:"rgba(125, 211, 252, 0.1)",minCameraRatio:.08,maxCameraRatio:4,autoRescale:!1,autoCenter:!1,enableEdgeEvents:!1,enableCameraPanning:!0,zIndex:!0}),D({level:"info",eventKey:"sigma_initialized",message:"Initialized Sigma for the knowledge graph.",details:{datasetSignature:ge}}),i.current.on("clickNode",({node:S})=>{if(Oe())return;const k=f.current.get(S)??null;N.current(k)}),i.current.on("clickStage",({event:S})=>{if(Oe())return;if(!i.current||!g.current){N.current(null);return}const k=Zr({sigma:i.current,graph:g.current,viewportX:S.x,viewportY:S.y});if(k){N.current(f.current.get(k)??null);return}N.current(null)}),i.current.on("downNode",({node:S,event:k,preventSigmaDefault:ie})=>{var oe,X;if(!i.current||!((oe=g.current)!=null&&oe.hasNode(S)))return;ie();const je=i.current.viewportToGraph({x:k.x,y:k.y}),J=g.current.getNodeAttributes(S);M.current={nodeId:S,offsetX:J.x-je.x,offsetY:J.y-je.y,startViewportX:k.x,startViewportY:k.y,currentX:J.x,currentY:J.y,moved:!1},fe.current=i.current.getSetting("enableCameraPanning")??!0,i.current.setSetting("enableCameraPanning",!1),de(S),ue(S),D({level:"debug",eventKey:"drag_start",message:"Started dragging a knowledge graph node.",details:{nodeId:S}}),(X=m.current)==null||X.postMessage({type:"drag-start",nodeId:S})}),i.current.on("moveBody",({event:S,preventSigmaDefault:k})=>{var X;if(!i.current||!g.current||!M.current)return;k();const ie=i.current.viewportToGraph({x:S.x,y:S.y});Math.hypot(S.x-M.current.startViewportX,S.y-M.current.startViewportY)>3&&(M.current={...M.current,moved:!0});const J=ie.x+M.current.offsetX,oe=ie.y+M.current.offsetY;M.current={...M.current,currentX:J,currentY:oe},g.current.mergeNodeAttributes(M.current.nodeId,{x:J,y:oe}),w.current.set(M.current.nodeId,{x:J,y:oe}),(X=m.current)==null||X.postMessage({type:"drag-move",nodeId:M.current.nodeId,x:J,y:oe}),se()});const j=()=>{var ie;if(!i.current||!M.current){M.current=null,de(null);return}const S=M.current.nodeId,k=M.current.moved;i.current.setSetting("enableCameraPanning",fe.current),(ie=m.current)==null||ie.postMessage({type:"drag-end",nodeId:S}),D({level:"debug",eventKey:"drag_end",message:"Released a dragged knowledge graph node.",details:{nodeId:S,moved:k}}),M.current=null,de(null),k&&(L.current=Date.now()+220,N.current(f.current.get(S)??null))};i.current.on("upNode",j),i.current.on("upStage",j),i.current.on("leaveStage",j),i.current.on("enterNode",({node:S})=>{ue(S)}),i.current.on("leaveNode",()=>{ue(null)}),i.current.on("afterRender",()=>{Y.current||(Y.current=!0,$.current="first_frame",D({level:"info",eventKey:"first_frame",message:"Knowledge graph rendered its first frame.",details:{datasetSignature:E.current}}),h({phase:"first_frame",allowCorrection:!0,publishBackendOnFailure:!0}),Be({rendererMode:"sigma",publishAnomaly:!0})),R()})}H(null),B(Me(x,T)),i.current.getCamera().setState(Ie(x))}catch(j){(O=i.current)==null||O.kill(),i.current=null,H(j instanceof Error?j.message:"Graph renderer unavailable."),B(Me(x,T)),V(ke(x)),D({level:"error",eventKey:"sigma_fallback",message:"Fell back from Sigma to the SVG renderer.",publishBackend:!0,details:{reason:j instanceof Error?j.message:"unknown"}}),h({phase:"graph_built",allowCorrection:!0,publishBackendOnFailure:!0})}m.current||(m.current=new Worker(new URL("/forge/assets/knowledge-graph-layout.worker-DRvzPxhP.js",import.meta.url),{type:"module"}),m.current.onmessage=j=>{var oe;if(!g.current)return;const S=j.data;if(S.type==="stats"){A.current=S.phase,me.current=S.primaryFocusedNodeId,Ke.current=S.focusSources,Ce.current=S.focusPressure,ye.current=S.centroid,P.current||(P.current=!0,$.current="worker_started",D({level:"info",eventKey:"worker_started",message:"Knowledge graph worker reported its first simulation stats.",details:{datasetSignature:E.current,phase:S.phase}}),h({phase:"worker_started",allowCorrection:!0,publishBackendOnFailure:!0}));return}const k=g.current;let ie=S.x,je=S.y;if($.current!=="startup_verified"){const X=Jr({x:S.x,y:S.y});X.changed&&(ie=X.x,je=X.y,(oe=m.current)==null||oe.postMessage({type:"recenter-graph",offsetX:X.offsetX,offsetY:X.offsetY}),Pe(),D({level:"warning",eventKey:"worker_startup_recenter",message:"Recentering worker positions during startup because the graph drifted away from origin.",details:{datasetSignature:E.current,startupPhase:$.current,offsetX:X.offsetX,offsetY:X.offsetY}}))}let J=0;if(k.updateEachNodeAttributes((X,Wt)=>({...Wt,x:ie[J],y:je[J++]}),{attributes:["x","y"]}),M.current&&k.hasNode(M.current.nodeId)){const X=M.current.nodeId;k.mergeNodeAttributes(X,{x:M.current.currentX,y:M.current.currentY})}ze(k,w.current),i.current?se():B(Me(k,T))});const y=x.nodes(),C=new Map(y.map((j,S)=>[j,S])),_=mt(y,T,s);m.current.postMessage({type:"init-graph",nodes:y.map(j=>{const S=x.getNodeAttributes(j);return{id:j,x:S.x,y:S.y,size:S.size,mass:Math.max(1,S.data.importance/42),importance:S.data.importance}}),edges:T.filter(j=>C.has(j.source)&&C.has(j.target)).map(j=>({source:C.get(j.source),target:C.get(j.target),weight:Math.max(.6,j.strength)})),focusNodeId:s,hopLevels:_,physics:u}),D({level:"debug",eventKey:"worker_init",message:"Posted the graph payload to the layout worker.",details:{nodeCount:y.length,edgeCount:T.length}})},[v.height,v.width,ge,s,t,u,T]),p.useEffect(()=>{if(!m.current||!g.current)return;const d=mt(g.current.nodes(),T,s);m.current.postMessage({type:"set-focus",focusNodeId:s,hopLevels:d}),s||(F.current=null)},[s,T]),p.useEffect(()=>{m.current&&m.current.postMessage({type:"update-physics",physics:u})},[u]),p.useEffect(()=>{},[ge,Re]),p.useEffect(()=>{!i.current||!g.current||(i.current.setSetting("nodeReducer",(d,x)=>{var C;const y=(C=g.current)==null?void 0:C.getNodeAttribute(d,"data");return Yr({nodeId:d,attributes:x,node:y,focusNodeId:s,relatedNodeIds:ae,detailNodeIds:ne,hoveredNodeId:Q,draggedNodeId:xe})}),i.current.setSetting("edgeReducer",(d,x)=>{var C;const y=(C=g.current)==null?void 0:C.getEdgeAttribute(d,"data");return Hr({attributes:x,edge:y,focusNodeId:s,detailNodeIds:ne,relatedNodeIds:ae,hoveredNodeId:Q})}),se())},[ne,xe,s,Q,ae]),p.useEffect(()=>{var d,x;!b||!E.current||v.width<=0||v.height<=0||!he&&i.current||(Y.current||(Y.current=!0,$.current="first_frame",D({level:"info",eventKey:"fallback_first_frame",message:"Knowledge graph rendered its first fallback frame.",details:{datasetSignature:E.current}}),h({phase:"first_frame",allowCorrection:!0,publishBackendOnFailure:!0})),vt({datasetSignature:E.current,focusNodeId:s,primaryFocusedNodeId:me.current,draggedNodeId:((d=M.current)==null?void 0:d.nodeId)??null,layoutGeneration:z.current,camera:pe,snapshot:b,width:v.width,height:v.height,startupPhase:$.current,startupInvariantSatisfied:((x=be({rendererMode:"fallback"}))==null?void 0:x.startupInvariantSatisfied)??!1,simulationPhase:A.current,focusSources:Ke.current,focusPressure:Ce.current,centroid:ye.current,cameraTarget:F.current?{x:F.current.x,y:F.current.y,ratio:F.current.ratio}:null,latestSnapshotAt:te.current,latestSnapshotNodeCount:le.current}))},[v.height,v.width,pe,he,b,s]);const Ze=p.useMemo(()=>!b||v.width<=0||v.height<=0?[]:b.nodes.map(d=>{const x=Kt({node:d,snapshot:b,camera:pe,width:v.width,height:v.height});return{...d,viewportX:x.x,viewportY:x.y,viewportSize:x.size}}),[v.height,v.width,pe,b]),it=p.useMemo(()=>new Map(Ze.map(d=>[d.id,d])),[Ze]);return r.jsx("div",{className:"relative h-full w-full overflow-hidden bg-[radial-gradient(circle_at_top,rgba(125,211,252,0.1),transparent_34%),linear-gradient(180deg,rgba(7,12,23,0.98),rgba(6,11,20,0.98))]",children:r.jsx("div",{ref:l,className:"h-full w-full touch-none","aria-label":"Knowledge graph canvas",children:he&&b?r.jsxs("svg",{className:"h-full w-full",viewBox:`0 0 ${Math.max(v.width,1)} ${Math.max(v.height,1)}`,"aria-hidden":"true",children:[r.jsx("title",{children:"Knowledge graph fallback canvas"}),r.jsx("rect",{x:"0",y:"0",width:Math.max(v.width,1),height:Math.max(v.height,1),fill:"transparent",onClick:()=>N.current(null)}),b.edges.map(d=>{const x=it.get(d.source),y=it.get(d.target);if(!x||!y)return null;const C=!!s&&(d.source===s||d.target===s),_=!!Q&&(d.source===Q||d.target===Q),I=s?d.source===s?0:ne.has(d.source)?1:ae.has(d.source)?2:3:0,O=s?d.target===s?0:ne.has(d.target)?1:ae.has(d.target)?2:3:0,j=s?Math.max(I,O):0;return r.jsx("line",{x1:x.viewportX,y1:x.viewportY,x2:y.viewportX,y2:y.viewportY,stroke:C?Fe(d,.24):_?Fe(d,.14):s?j<=1?Fe(d,.09):j===2?Fe(d,.05):Fe(d,.016):Fe(d,.055),strokeWidth:C?1.7:_?1.3:.95},d.id)}),Ze.map(d=>{const x=s===d.id,y=ae.has(d.id),C=ne.has(d.id),_=Q===d.id,I=!s||y;return r.jsxs("g",{transform:`translate(${d.viewportX}, ${d.viewportY})`,onMouseEnter:()=>ue(d.id),onMouseLeave:()=>ue(null),onClick:O=>{O.stopPropagation();const j=f.current.get(d.id)??null;N.current(j)},style:{cursor:"pointer"},children:[r.jsx("circle",{r:x?d.viewportSize*1.9:_?d.viewportSize*1.3:C?d.viewportSize*1.15:y?d.viewportSize*1.05:d.viewportSize,fill:I?d.color:Wr(d.color,.3),stroke:x?"rgba(255,255,255,0.78)":"rgba(255,255,255,0.12)",strokeWidth:x?2:1}),(x||_||C)&&r.jsx("text",{x:d.viewportSize*1.5,y:4,fill:"rgba(244,247,255,0.92)",fontSize:"12",children:d.data.title})]},d.id)})]}):null})})}),un=300,dn=152;function Ot(e,t){return e?cn(e,t):new Set}function hn(e,t,a){const s=At(e,t),u=Ot(a,t);return s.nodes.map(o=>{const c=o.id===a,l=!a||u.has(o.id);return{id:o.id,draggable:!1,selectable:!1,position:{x:72+o.layer*un,y:88+o.row*dn},data:{label:r.jsxs("div",{className:"min-w-[232px] rounded-[22px] border px-4 py-4 shadow-[0_24px_70px_rgba(0,0,0,0.24)] transition",style:{borderColor:c?"rgba(255,255,255,0.32)":"rgba(255,255,255,0.1)",background:c?"rgba(11,17,30,0.98)":"rgba(8,14,26,0.92)",opacity:l?1:.28},children:[r.jsx("div",{className:"flex flex-wrap items-center gap-2",children:r.jsx(qe,{kind:o.entityKind,label:o.entityKind.replaceAll("_"," "),compact:!0,gradient:c})}),r.jsx("div",{className:"mt-3",children:r.jsx(mr,{kind:o.entityKind,label:o.title,className:"max-w-full",lines:2})}),o.subtitle?r.jsx("div",{className:"mt-2 text-sm leading-5 text-white/58",children:o.subtitle}):null]})},style:{background:"transparent",border:"none",padding:0}}})}function pn(e,t,a,s){const u=At(e,t),o=Ot(a,t);return u.edges.filter(c=>s||!c.secondary).map(c=>{const l=!a||o.has(c.source)||o.has(c.target);return{id:c.id,source:c.source,target:c.target,animated:!c.secondary&&c.family==="structural"&&l,markerEnd:{type:kr.ArrowClosed,color:c.secondary?"rgba(255,255,255,0.16)":"rgba(232,242,255,0.42)"},style:{opacity:l?1:.18,stroke:c.secondary?"rgba(255,255,255,0.16)":c.family==="taxonomy"?"rgba(162,245,189,0.34)":c.family==="structural"?"rgba(232,242,255,0.4)":"rgba(192,193,255,0.24)",strokeDasharray:c.secondary?"8 6":void 0,strokeWidth:c.secondary?1:c.family==="structural"?1.7:1.2}}})}function gn({nodes:e,edges:t,focusNodeId:a,showSecondaryEdges:s,onSelectNode:u,onOpenNode:o,onNavigateNode:c,isMobile:l}){const i=p.useMemo(()=>hn(e,t,a),[t,a,e]),m=p.useMemo(()=>pn(e,t,a,s),[t,a,e,s]),g=p.useMemo(()=>new Map(e.map(w=>[w.id,w])),[e]);return r.jsxs("div",{className:"knowledge-graph-canvas relative h-[44rem] rounded-[28px]",children:[r.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-10 flex gap-4 overflow-x-auto px-6 py-4",children:Le.map(w=>r.jsx("div",{className:"min-w-[17rem] rounded-full border border-white/10 bg-[rgba(11,17,28,0.78)] px-4 py-2 text-center text-[11px] uppercase tracking-[0.16em] text-white/52 backdrop-blur",children:w.label},w.id))}),r.jsxs(Fr,{fitView:!0,fitViewOptions:a?{padding:.24,nodes:[{id:a}]}:{padding:.2},nodes:i,edges:m,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,attributionPosition:"bottom-left",onNodeClick:(w,G)=>{const f=g.get(G.id);f&&u(f)},onNodeDoubleClick:(w,G)=>{const f=g.get(G.id);if(f){if(l){o(f);return}c(f)}},children:[r.jsx(Kr,{showInteractive:!1}),r.jsx(Ir,{gap:28,size:1,color:"rgba(255,255,255,0.05)"})]},`${a??"all"}-${s?"all":"primary"}`)]})}const Pt=6,Tt=5,Dt=.92,zt=5,Lt=.15,$t=2.4,Yt=2,Ht=.8,Vt=3,ee={focusRepulsion:2.25,focusDiffusion:1.95,focusSpringReductionMax:.34,focusSpringReductionDiffusion:1.85,edgeSpringStrength:1,gravityStrength:1,focusShellSpacing:1};function _e(e,t,a){return Math.min(Math.max(e,t),a)}function Bt(e){return{focusRepulsion:_e((e==null?void 0:e.focusRepulsion)??ee.focusRepulsion,.6,Pt),focusDiffusion:_e((e==null?void 0:e.focusDiffusion)??ee.focusDiffusion,.6,Tt),focusSpringReductionMax:_e((e==null?void 0:e.focusSpringReductionMax)??ee.focusSpringReductionMax,0,Dt),focusSpringReductionDiffusion:_e((e==null?void 0:e.focusSpringReductionDiffusion)??ee.focusSpringReductionDiffusion,.6,zt),edgeSpringStrength:_e((e==null?void 0:e.edgeSpringStrength)??ee.edgeSpringStrength,Lt,$t),gravityStrength:_e((e==null?void 0:e.gravityStrength)??ee.gravityStrength,0,Yt),focusShellSpacing:_e((e==null?void 0:e.focusShellSpacing)??ee.focusShellSpacing,Ht,Vt)}}const Qe=2e3,rt=40,nt=2e3,Xt="forge.knowledge-graph.physics";function fn(){if(typeof window>"u")return!1;if(window.__FORGE_ENABLE_GRAPH_DIAGNOSTICS__)return!0;try{return new URLSearchParams(window.location.search).get("graphDiagnostics")==="1"}catch{return!1}}function Ue(e,t){return Array.from(new Set(e.getAll(t).flatMap(a=>a.split(",")).map(a=>a.trim()).filter(Boolean)))}function U(e,t,a){e.delete(t),a.forEach(s=>e.append(t,s))}function mn(e){switch(e.entityType){case"workbench_flow":case"workbench_surface":case"wiki_space":return null;default:return wr(e.entityType,e.entityId)}}function Z(e){return e?e.slice(0,10):""}function xn(){if(typeof window>"u")return ee;try{const e=window.localStorage.getItem(Xt);return e?Bt(JSON.parse(e)):ee}catch{return ee}}function bn(e){typeof window>"u"||window.localStorage.setItem(Xt,JSON.stringify(e))}function wn(e,t,a,s,u){const o=e.find(c=>c.id===t);return o||(!t||!a?null:{id:t,displayName:a,kind:s??"human",accentColor:u??"",handle:a.toLowerCase().replace(/\s+/g,"-"),description:"",createdAt:"",updatedAt:""})}function yn({entityKinds:e,relationKinds:t,tags:a,owners:s}){return[...e.map(u=>`entity:${u}`),...t.map(u=>`relation:${u}`),...a.map(u=>`tag:${u}`),...s.map(u=>`owner:${u}`)]}function _t(e){const t=[],a=[],s=[],u=[];for(const o of e){const[c,...l]=o.split(":"),i=l.join(":").trim();i&&(c==="entity"?t.push(i):c==="relation"?a.push(i):c==="tag"?s.push(i):c==="owner"&&u.push(i))}return{entityKinds:t,relationKinds:a,tags:s,owners:u}}function vn(e){const t=new URLSearchParams(e),a=t.get("view")==="hierarchy"?"hierarchy":"graph",s=xr(t.get("focus")),u=s?on(s.entityType,s.entityId):null,o=Ue(t,"entityKind"),c=Ue(t,"relationKind"),l=Ue(t,"tag"),i=Ue(t,"owner"),m=t.get("q")??"",g=t.get("updatedFrom"),w=t.get("updatedTo"),G=Number(t.get("limit")??Qe),f=Number.isFinite(G)?Math.max(rt,Math.min(nt,G)):Qe;return{selectedView:a,focusNodeId:u,selectedKinds:o,selectedRelations:c,selectedTags:l,selectedOwners:i,showHierarchyCrossLinks:t.get("cross")==="1",queryText:m,updatedFrom:g,updatedTo:w,maxNodes:f}}function Nn(e){return{q:e.queryText.trim()||null,entityKinds:[...e.selectedKinds].sort(),relationKinds:[...e.selectedRelations].sort(),tags:[...e.selectedTags].sort(),owners:[...e.selectedOwners].sort(),updatedFrom:e.updatedFrom,updatedTo:e.updatedTo,limit:e.maxNodes,focusNodeId:null}}function Ct(e,t){if(!t){e.delete("focus");return}e.set("focus",br(t.entityType,t.entityId))}function Sn({isMobile:e,currentFocusNodeId:t,nextNodeId:a}){return a?e?t===a?{nextFocusNodeId:a,nextMobileSheetOpen:!0,shouldUpdateFocus:!1}:{nextFocusNodeId:a,nextMobileSheetOpen:!1,shouldUpdateFocus:!0}:{nextFocusNodeId:a,nextMobileSheetOpen:!1,shouldUpdateFocus:t!==a}:{nextFocusNodeId:null,nextMobileSheetOpen:!1,shouldUpdateFocus:t!==null}}const Et="__clear__";function _n({isMobile:e,focusNodeId:t,shellOverlayFocusNodeId:a,lastRequestedKey:s}){const u=e?null:t,o=u??Et;return o===(a??Et)?{action:"none",nextRequestedKey:o}:s===o?{action:"none",nextRequestedKey:o}:{action:u?"set":"clear",nextRequestedKey:o}}class Cn extends p.Component{constructor(t){super(t),this.state={error:null}}static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t){t.resetKey!==this.props.resetKey&&this.state.error!==null&&this.setState({error:null})}render(){return this.state.error?this.props.fallback(this.state.error):this.props.children}}function An(){var Be,Pe;const e=yr(),t=jt();tt(n=>n.knowledgeGraphDiagnostics);const a=tt(n=>{var h,R;return((R=(h=n.shell.knowledgeGraphOverlayFocus)==null?void 0:h.focusNode)==null?void 0:R.id)??null}),s=Ut(),[u,o]=qt(),c=p.useRef(null),l=p.useRef(null),i=p.useRef(null),m=p.useRef(null),g=p.useRef(null);p.useRef(Gt("/knowledge-graph"));const[w,G]=p.useState(()=>typeof window<"u"?window.matchMedia("(max-width: 1023px)").matches:!1),[f,N]=p.useState(!1),[K,E]=p.useState(!1),[z,M]=p.useState(!1),[L,fe]=p.useState(!1),[F,ce]=p.useState(""),[A,me]=p.useState(()=>xn()),Ce=Mt(),ye=({level:n,eventKey:h,message:R,details:Te,publishBackend:st=!1})=>{};p.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const n=window.matchMedia("(max-width: 1023px)"),h=R=>G(R?R.matches:n.matches);return h(),typeof n.addEventListener=="function"?(n.addEventListener("change",h),()=>n.removeEventListener("change",h)):(n.addListener(h),()=>n.removeListener(h))},[]),p.useEffect(()=>{w||(N(!1),E(!1),l.current=null)},[w]),p.useEffect(()=>{bn(A)},[A]);const $=u.toString(),ve=p.useMemo(()=>vn($),[$]),{selectedView:Y,focusNodeId:P,selectedKinds:te,selectedRelations:le,selectedTags:Ee,selectedOwners:Ne,showHierarchyCrossLinks:Q,queryText:ue,updatedFrom:xe,updatedTo:de,maxNodes:he}=ve;p.useEffect(()=>{ce(ue)},[ue]);const H=p.useMemo(()=>Nn(ve),[ve]),pe=p.useMemo(()=>["forge-knowledge-graph",...e.selectedUserIds,JSON.stringify(H)],[H,e.selectedUserIds]),V=lr({queryKey:pe,queryFn:()=>jr(e.selectedUserIds,H),placeholderData:n=>n,staleTime:6e4,refetchOnWindowFocus:!1}),b=V.data;p.useEffect(()=>{ye({level:"info",eventKey:"route_arrival",message:"Arrived on the Knowledge Graph page.",details:{search:u.toString()}})},[]),p.useEffect(()=>{if(!V.isSuccess||!b)return;const n=JSON.stringify({q:H.q,entityKinds:H.entityKinds,relationKinds:H.relationKinds,tags:H.tags,owners:H.owners,updatedFrom:H.updatedFrom,updatedTo:H.updatedTo,limit:H.limit,nodeCount:b.counts.nodeCount,edgeCount:b.counts.edgeCount,filteredNodeCount:b.counts.filteredNodeCount,limited:b.counts.limited});g.current!==n&&(g.current=n,ye({level:"info",eventKey:"graph_query_resolved",message:"Knowledge graph query resolved.",details:{nodeCount:b.counts.nodeCount,edgeCount:b.counts.edgeCount,filteredNodeCount:b.counts.filteredNodeCount,limited:b.counts.limited}}))},[b,V.isSuccess,H]),p.useEffect(()=>{!b||!P||b.nodes.some(n=>n.id===P)||(o(n=>{const h=new URLSearchParams(n);return h.delete("focus"),h},{replace:!0}),N(!1),l.current=null)},[P,b,o]),p.useEffect(()=>{if(w){if(!P){l.current=null,N(!1);return}l.current===P&&!f&&(N(!0),l.current=null)}},[P,w,f]);const B=p.useMemo(()=>!b||!P?St([],[],null):St(b.nodes,b.edges,P),[P,b]);p.useEffect(()=>{var h;const n=_n({isMobile:w,focusNodeId:((h=B.focusNode)==null?void 0:h.id)??null,shellOverlayFocusNodeId:a,lastRequestedKey:m.current});if(m.current=n.nextRequestedKey,n.action!=="none"){if(n.action==="clear"){t(ut());return}t(vr(B))}},[t,B,w,a]),p.useEffect(()=>{{i.current=null;return}},[Ce,P,B,w]),p.useEffect(()=>()=>{t(ut())},[t]),p.useEffect(()=>{if(!(typeof window>"u")){if(!fn()){delete window.__FORGE_KNOWLEDGE_GRAPH_PAGE_TEST__;return}return window.__FORGE_KNOWLEDGE_GRAPH_PAGE_TEST__={isMobile:w,mobileSheetOpen:f,focusNodeId:P,selectedView:Y,selectNodeById:n=>{if(!b)return;const h=n?b.nodes.find(R=>R.id===n)??null:null;Se(h)},activateFocusedNode:()=>{if(!P||!b)return;const n=b.nodes.find(h=>h.id===P)??null;n&&Se(n)}},()=>{delete window.__FORGE_KNOWLEDGE_GRAPH_PAGE_TEST__}}},[P,w,f,Y]);const v=n=>{o(h=>{const R=new URLSearchParams(h);return n(R),R},{replace:!0})},Ye=n=>{const h=n.trim();ce(n),v(R=>{h.length>0?R.set("q",h):R.delete("q")})},Se=n=>{const h=Sn({isMobile:w,currentFocusNodeId:P,nextNodeId:(n==null?void 0:n.id)??null});l.current=w&&h.nextMobileSheetOpen?(n==null?void 0:n.id)??null:null,N(h.nextMobileSheetOpen),h.shouldUpdateFocus&&(v(R=>{Ct(R,n)}),w&&E(!1))},Re=n=>{n.href&&s(n.href)},re=(n,h)=>{me(R=>Bt({...R,[n]:h}))},Ie=n=>{const h=mn(n);h&&s(h)},ke=n=>{v(h=>{h.set("view","hierarchy"),Ct(h,n)})},Ae=()=>{v(n=>{["q","entityKind","relationKind","tag","owner","updatedFrom","updatedTo","focus"].forEach(h=>n.delete(h)),n.set("limit",String(Qe))}),M(!1)};if(V.isLoading&&!b)return r.jsx(Nr,{eyebrow:"Knowledge Graph",title:"Loading the Forge world model",description:"Gathering goals, projects, KarpaWiki pages, psyche entities, calendar context, and Workbench flows into one graph."});if(V.isError)return r.jsx(Sr,{eyebrow:"Knowledge Graph",error:V.error,onRetry:()=>void V.refetch()});if(!b)return null;const T=new Map(b.facets.entityKinds.map(n=>[n.value,n])),ge=et.map(n=>{const h=_r(n),R=T.get(n),Te=(R==null?void 0:R.count)??0;return{value:n,label:(R==null?void 0:R.label)??h.label,description:Te===1?"1 node":`${Te} nodes`,kind:n}}),q=b.facets.relationKinds.map(n=>({value:n.value,label:n.label,description:`${n.count} links`})),ne=b.facets.tags.map(n=>({value:n.id,label:n.label,description:`${n.count} linked nodes`,badge:r.jsx(qe,{kind:"tag",label:n.label,compact:!0,gradient:!1}),menuBadge:r.jsx(qe,{kind:"tag",label:n.label,compact:!0,gradient:!1})})),ae=b.facets.owners.map(n=>{const h=wn(e.snapshot.users,n.userId,n.displayName,n.kind,n.accentColor);return{value:n.userId,label:n.displayName,description:`${n.count} nodes`,badge:r.jsx(dt,{user:h,compact:!0}),menuBadge:r.jsx(dt,{user:h,compact:!0})}}),He=[...ge.map(n=>({id:`entity:${n.value}`,label:n.label,description:n.description,searchText:`entity kind ${n.label}`,badge:r.jsx(qe,{kind:n.kind??"note",label:n.label,compact:!0,gradient:!1})})),...q.map(n=>({id:`relation:${n.value}`,label:n.label,description:n.description,searchText:`relation kind ${n.label}`})),...ne.map(n=>({id:`tag:${n.value}`,label:n.label,description:n.description,searchText:`tag ${n.label}`,badge:n.menuBadge??n.badge})),...ae.map(n=>({id:`owner:${n.value}`,label:n.label,description:n.description,searchText:`owner ${n.label}`,badge:n.menuBadge??n.badge}))],se=yn({entityKinds:te,relationKinds:le,tags:Ee,owners:Ne}),Oe=b.counts.limited?`${b.counts.nodeCount}/${b.counts.filteredNodeCount} nodes`:`${b.counts.nodeCount}n · ${b.counts.edgeCount}e`,D=b.counts.limited?`${b.counts.nodeCount} visible nodes from ${b.counts.filteredNodeCount} filtered matches`:`${b.counts.nodeCount} nodes and ${b.counts.edgeCount} edges`,Je=ue.trim().length>0||te.length>0||le.length>0||Ee.length>0||Ne.length>0||!!xe||!!de||he!==Qe,be=!w,Ve=`${Y}:${b.nodes.map(n=>n.id).join("|")}::${b.edges.map(n=>n.id).join("|")}`;return r.jsxs("div",{className:"h-[calc(100dvh-var(--forge-mobile-nav-clearance)-5.25rem)] overflow-hidden lg:-mt-3 lg:h-[calc(100dvh-10rem)]",children:[r.jsxs("div",{className:"relative h-full bg-[radial-gradient(circle_at_top,rgba(125,211,252,0.08),transparent_26%),linear-gradient(180deg,rgba(7,12,23,0.98),rgba(5,10,19,1))]",children:[r.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-30 hidden md:block",children:r.jsx(Cr,{metrics:e.snapshot.metrics})}),r.jsx(Cn,{resetKey:Ve,fallback:n=>r.jsx("div",{className:"grid h-full place-items-center p-6 text-center",children:r.jsxs("div",{className:"grid max-w-lg gap-4 rounded-[28px] border border-[rgba(255,255,255,0.08)] bg-[rgba(8,12,22,0.92)] p-6 shadow-[0_30px_80px_rgba(0,0,0,0.36)]",children:[r.jsx("div",{className:"mx-auto flex size-12 items-center justify-center rounded-full border border-[rgba(255,255,255,0.12)] bg-[rgba(255,255,255,0.04)] text-[var(--warning)]",children:r.jsx(Qt,{className:"size-5"})}),r.jsxs("div",{className:"grid gap-2",children:[r.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Graph renderer fallback"}),r.jsx("h2",{className:"text-lg font-semibold text-[var(--ui-ink-strong)]",children:"The graph renderer hit a display error."}),r.jsx("p",{className:"text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Switch to the hierarchy view or reset the current graph filters. The graph will recover automatically when the dataset changes."}),r.jsx("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[rgba(255,255,255,0.04)] px-4 py-3 text-left text-xs text-[var(--ui-ink-faint)]",children:n.message})]}),r.jsxs("div",{className:"flex flex-wrap justify-center gap-2",children:[r.jsxs(W,{variant:"primary",size:"sm",onClick:()=>v(h=>{h.set("view","hierarchy")}),children:[r.jsx(Jt,{className:"size-4"}),"Open hierarchy"]}),r.jsx(W,{variant:"secondary",size:"sm",onClick:Ae,children:"Reset graph filters"})]})]})}),children:Y==="graph"?r.jsx(ln,{ref:c,nodes:b.nodes,edges:b.edges,focusNodeId:P,physicsSettings:A,onSelectNode:Se}):r.jsx("div",{className:"h-full overflow-y-auto px-4 py-4 lg:px-6",children:r.jsx(gn,{nodes:b.nodes,edges:b.edges,focusNodeId:P,showSecondaryEdges:Q,isMobile:w,onSelectNode:Se,onOpenNode:Se,onNavigateNode:Re})})}),w?r.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-20 px-3 pt-2 lg:hidden",children:r.jsxs("div",{className:"pointer-events-auto flex items-center gap-1.5",children:[r.jsx("div",{title:D,className:"shrink-0 rounded-full border border-white/10 bg-[rgba(8,12,20,0.78)] px-2 py-0.5 text-[9px] uppercase tracking-[0.18em] text-white/48 backdrop-blur",children:Oe}),r.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[r.jsxs("div",{className:"flex shrink-0 rounded-full border border-white/10 bg-[rgba(8,12,20,0.78)] p-0.5 shadow-[0_14px_42px_rgba(0,0,0,0.24)] backdrop-blur",children:[r.jsx("button",{type:"button",className:`rounded-full px-2 py-1 text-[10px] transition ${Y==="graph"?"bg-white/[0.14] text-white":"text-white/52 hover:text-white"}`,onClick:()=>v(n=>{n.set("view","graph")}),children:"Graph"}),r.jsx("button",{type:"button",className:`rounded-full px-2 py-1 text-[10px] transition ${Y==="hierarchy"?"bg-white/[0.14] text-white":"text-white/52 hover:text-white"}`,onClick:()=>v(n=>{n.set("view","hierarchy")}),children:"Hierarchy"})]}),r.jsx(W,{variant:"secondary",size:"sm",className:"h-7 rounded-full border-white/10 bg-[rgba(8,12,20,0.78)] px-2 text-[10px] text-white/68 backdrop-blur hover:text-white",onClick:()=>fe(!0),"aria-label":"Open graph appearance settings",title:"Graph appearance settings",children:r.jsx(ot,{className:"size-3"})}),r.jsxs(W,{variant:"secondary",size:"sm",className:"h-7 rounded-full border-white/10 bg-[rgba(8,12,20,0.78)] px-2 text-[10px] text-white/68 backdrop-blur hover:text-white",onClick:()=>{N(!1),E(!0)},"aria-label":"Open graph filters",children:[r.jsx(ct,{className:"size-3"}),"Search"]})]})]})}):null,be?r.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-20 px-4 pt-3 lg:px-6",children:[r.jsxs("div",{"data-testid":"knowledge-graph-desktop-toolbar",className:"pointer-events-auto flex items-center gap-1.5",children:[r.jsx("div",{"data-testid":"knowledge-graph-count-pill",title:D,className:"shrink-0 rounded-full border border-white/10 bg-[rgba(8,12,20,0.78)] px-2 py-0.5 text-[9px] uppercase tracking-[0.18em] text-white/48 backdrop-blur",children:Oe}),r.jsx("div",{className:"min-w-0 flex-1",children:r.jsx(pt,{title:"",description:"",compact:!0,minimal:!0,hideSummary:!0,query:F,onQueryChange:ce,onQuerySubmit:Ye,submitLabel:"Search graph",options:He,selectedOptionIds:se,onSelectedOptionIdsChange:n=>{const h=_t(n);v(R=>{U(R,"entityKind",h.entityKinds),U(R,"relationKind",h.relationKinds),U(R,"tag",h.tags),U(R,"owner",h.owners)})},resultSummary:"",placeholder:"Type a graph search, then press Enter or the search button"})}),r.jsxs(W,{variant:"secondary",size:"sm",className:"h-7 rounded-full border-white/10 bg-[rgba(8,12,20,0.78)] px-2 text-[10px] text-white/68 backdrop-blur hover:text-white",onClick:()=>M(n=>!n),children:[r.jsx(ct,{className:"size-3"}),"Advanced"]}),Je?r.jsx(W,{variant:"secondary",size:"sm",className:"h-7 rounded-full border-white/10 bg-[rgba(8,12,20,0.78)] px-2 text-[10px] text-white/68 backdrop-blur hover:text-white",onClick:Ae,children:"Reset"}):null]}),r.jsx(Ar,{initial:!1,children:z?r.jsx(Or.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.18,ease:"easeOut"},className:"pointer-events-auto mt-2 ml-auto max-w-[min(54rem,calc(100%-3.5rem))] rounded-[20px] border border-white/10 bg-[rgba(8,12,20,0.88)] p-3 shadow-[0_20px_60px_rgba(0,0,0,0.32)] backdrop-blur",children:r.jsxs("div",{className:"grid gap-3 xl:grid-cols-[minmax(0,1.4fr)_minmax(17rem,1fr)]",children:[r.jsxs("div",{className:"grid gap-3",children:[r.jsx(we,{options:ge,selectedValues:te,onChange:n=>v(h=>{U(h,"entityKind",n)}),placeholder:"Filter by entity type",emptyMessage:"No entity kinds match the current graph."}),r.jsx(we,{options:q,selectedValues:le,onChange:n=>v(h=>{U(h,"relationKind",n)}),placeholder:"Filter by relation type",emptyMessage:"No relation kinds match the current graph."}),r.jsx(we,{options:ne,selectedValues:Ee,onChange:n=>v(h=>{U(h,"tag",n)}),placeholder:"Filter by tag",emptyMessage:"No tags are available in the current filtered graph."}),r.jsx(we,{options:ae,selectedValues:Ne,onChange:n=>v(h=>{U(h,"owner",n)}),placeholder:"Filter by owner",emptyMessage:"No owners match the current graph."})]}),r.jsxs("div",{className:"grid gap-3 rounded-[20px] border border-white/10 bg-white/[0.03] p-3",children:[r.jsxs("div",{className:"grid gap-2",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3 text-[11px] uppercase tracking-[0.18em] text-white/46",children:[r.jsx("span",{children:"Max nodes shown"}),r.jsx("span",{children:he})]}),r.jsx("input",{type:"range",min:rt,max:nt,step:20,value:he,onChange:n=>v(h=>{h.set("limit",n.target.value)}),className:"w-full accent-[var(--secondary)]"}),r.jsx("div",{className:"text-xs text-white/42",children:"The graph stays deterministic under the cap and focus mode redistributes the visible neighborhood around the selected node."})]}),r.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[r.jsxs("div",{className:"grid gap-2",children:[r.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/46",children:"Updated from"}),r.jsx(Xe,{type:"date",value:Z(xe),min:Z(b.facets.updatedAt.min),max:Z(de??b.facets.updatedAt.max),onChange:n=>v(h=>{n.target.value?h.set("updatedFrom",n.target.value):h.delete("updatedFrom")})})]}),r.jsxs("div",{className:"grid gap-2",children:[r.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/46",children:"Updated to"}),r.jsx(Xe,{type:"date",value:Z(de),min:Z(xe??b.facets.updatedAt.min),max:Z(b.facets.updatedAt.max),onChange:n=>v(h=>{n.target.value?h.set("updatedTo",n.target.value):h.delete("updatedTo")})})]})]}),Y==="hierarchy"?r.jsx(W,{variant:Q?"primary":"secondary",size:"sm",className:"h-8 rounded-full px-3 text-xs",onClick:()=>v(n=>{Q?n.delete("cross"):n.set("cross","1")}),children:Q?"Hide cross-links":"Show cross-links"}):null]})]})}):null})]}):null,w?null:r.jsx("div",{className:"pointer-events-none absolute bottom-5 left-4 z-20 lg:left-6",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("div",{className:"pointer-events-auto flex shrink-0 rounded-full border border-white/10 bg-[rgba(8,12,20,0.82)] p-0.5 shadow-[0_14px_42px_rgba(0,0,0,0.24)] backdrop-blur",children:[r.jsx("button",{type:"button",className:`rounded-full px-2.5 py-1.5 text-[10px] transition ${Y==="graph"?"bg-white/[0.14] text-white":"text-white/52 hover:text-white"}`,onClick:()=>v(n=>{n.set("view","graph")}),children:"Graph"}),r.jsx("button",{type:"button",className:`rounded-full px-2.5 py-1.5 text-[10px] transition ${Y==="hierarchy"?"bg-white/[0.14] text-white":"text-white/52 hover:text-white"}`,onClick:()=>v(n=>{n.set("view","hierarchy")}),children:"Hierarchy"})]}),Y==="graph"?r.jsxs(r.Fragment,{children:[r.jsx(W,{variant:"secondary",size:"sm",className:"pointer-events-auto size-8 rounded-full border-white/10 bg-[rgba(8,12,20,0.82)] p-0 text-white/72 backdrop-blur hover:text-white",onClick:()=>fe(!0),title:"Graph appearance settings","aria-label":"Open graph appearance settings",children:r.jsx(ot,{className:"size-3.5"})}),r.jsx(W,{variant:"secondary",size:"sm",className:"pointer-events-auto size-8 rounded-full border-white/10 bg-[rgba(8,12,20,0.82)] p-0 text-white/72 backdrop-blur hover:text-white",onClick:()=>{var n;return(n=c.current)==null?void 0:n.zoomIn()},title:"Zoom in","aria-label":"Zoom in",children:r.jsx(Zt,{className:"size-3.5"})}),r.jsx(W,{variant:"secondary",size:"sm",className:"pointer-events-auto size-8 rounded-full border-white/10 bg-[rgba(8,12,20,0.82)] p-0 text-white/72 backdrop-blur hover:text-white",onClick:()=>{var n;return(n=c.current)==null?void 0:n.zoomOut()},title:"Zoom out","aria-label":"Zoom out",children:r.jsx(er,{className:"size-3.5"})}),r.jsx(W,{variant:"secondary",size:"sm",className:"pointer-events-auto size-8 rounded-full border-white/10 bg-[rgba(8,12,20,0.82)] p-0 text-white/72 backdrop-blur hover:text-white",onClick:()=>{var n;return(n=c.current)==null?void 0:n.recenterOnFocus()},disabled:!B.focusNode,title:"Recenter","aria-label":"Recenter",children:r.jsx(tr,{className:"size-3.5"})}),r.jsx(W,{variant:"secondary",size:"sm",className:"pointer-events-auto size-8 rounded-full border-white/10 bg-[rgba(8,12,20,0.82)] p-0 text-white/72 backdrop-blur hover:text-white",onClick:()=>{var n;return(n=c.current)==null?void 0:n.fit()},title:"Reset camera","aria-label":"Reset camera",children:r.jsx(rr,{className:"size-3.5"})}),null]}):null]})})]}),r.jsx(ht,{open:f&&!!B.focusNode,onOpenChange:N,eyebrow:"Knowledge Graph",title:((Be=B.focusNode)==null?void 0:Be.title)??"Focus node",description:((Pe=B.focusNode)==null?void 0:Pe.subtitle)??"Inspect the selected node and move deeper into the graph.",children:r.jsx(Er,{focus:B,onOpenPage:n=>{N(!1),Re(n)},onOpenNotes:n=>{N(!1),Ie(n)},onOpenHierarchy:n=>{N(!1),ke(n)},onSelectNode:Se,className:"border-0 bg-transparent p-0 shadow-none"})}),r.jsx(ht,{open:K,onOpenChange:E,eyebrow:"Knowledge Graph",title:"Filter graph",description:"Search the visible graph and adjust the focus cap without covering the canvas all the time.",children:r.jsxs("div",{className:"grid gap-4 pb-2",children:[r.jsx("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[rgba(255,255,255,0.03)] p-3",children:r.jsx(pt,{title:"",description:"",compact:!0,query:F,onQueryChange:ce,onQuerySubmit:Ye,submitLabel:"Search graph",options:He,selectedOptionIds:se,onSelectedOptionIdsChange:n=>{const h=_t(n);v(R=>{U(R,"entityKind",h.entityKinds),U(R,"relationKind",h.relationKinds),U(R,"tag",h.tags),U(R,"owner",h.owners)})},resultSummary:D,placeholder:"Type a graph search, then press Enter or the search button"})}),r.jsxs("div",{className:"grid gap-3",children:[r.jsx(we,{options:ge,selectedValues:te,onChange:n=>v(h=>{U(h,"entityKind",n)}),placeholder:"Filter by entity type",emptyMessage:"No entity kinds match the current graph."}),r.jsx(we,{options:q,selectedValues:le,onChange:n=>v(h=>{U(h,"relationKind",n)}),placeholder:"Filter by relation type",emptyMessage:"No relation kinds match the current graph."}),r.jsx(we,{options:ne,selectedValues:Ee,onChange:n=>v(h=>{U(h,"tag",n)}),placeholder:"Filter by tag",emptyMessage:"No tags are available in the current filtered graph."}),r.jsx(we,{options:ae,selectedValues:Ne,onChange:n=>v(h=>{U(h,"owner",n)}),placeholder:"Filter by owner",emptyMessage:"No owners match the current graph."})]}),r.jsxs("div",{className:"grid gap-3 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[rgba(255,255,255,0.03)] p-3",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3 text-[11px] uppercase tracking-[0.18em] text-white/46",children:[r.jsx("span",{children:"Max nodes shown"}),r.jsx("span",{children:he})]}),r.jsx("input",{type:"range",min:rt,max:nt,step:20,value:he,onChange:n=>v(h=>{h.set("limit",n.target.value)}),className:"w-full accent-[var(--secondary)]"}),r.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[r.jsxs("div",{className:"grid gap-2",children:[r.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/46",children:"Updated from"}),r.jsx(Xe,{type:"date",value:Z(xe),min:Z(b.facets.updatedAt.min),max:Z(de??b.facets.updatedAt.max),onChange:n=>v(h=>{n.target.value?h.set("updatedFrom",n.target.value):h.delete("updatedFrom")})})]}),r.jsxs("div",{className:"grid gap-2",children:[r.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/46",children:"Updated to"}),r.jsx(Xe,{type:"date",value:Z(de),min:Z(xe??b.facets.updatedAt.min),max:Z(b.facets.updatedAt.max),onChange:n=>v(h=>{n.target.value?h.set("updatedTo",n.target.value):h.delete("updatedTo")})})]})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(W,{variant:"secondary",size:"sm",onClick:Ae,children:"Reset"}),r.jsx(W,{variant:"primary",size:"sm",onClick:()=>E(!1),children:"Done"})]})]})]})}),r.jsx(nr,{open:L,onOpenChange:fe,children:r.jsxs(ar,{children:[r.jsx(sr,{className:"fixed inset-0 z-40 bg-[rgba(4,8,18,0.72)] backdrop-blur-xl"}),r.jsxs(ir,{className:"fixed inset-x-4 top-[max(1rem,env(safe-area-inset-top))] z-50 max-h-[calc(100dvh-2rem)] overflow-y-auto rounded-[30px] border border-white/10 bg-[linear-gradient(180deg,rgba(16,23,36,0.98),rgba(8,12,22,0.98))] shadow-[0_32px_90px_rgba(3,8,18,0.48)] md:left-1/2 md:right-auto md:w-[min(40rem,calc(100vw-3rem))] md:-translate-x-1/2",children:[r.jsx(or,{className:"sr-only",children:"Knowledge Graph appearance settings"}),r.jsx(cr,{className:"sr-only",children:"Tune the graph focus physics and appearance response."}),r.jsxs("div",{className:"sticky top-0 z-10 flex items-start justify-between gap-4 border-b border-white/8 bg-[rgba(8,12,22,0.9)] px-5 py-4 backdrop-blur-xl",children:[r.jsxs("div",{className:"grid gap-1",children:[r.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Graph appearance"}),r.jsx("div",{className:"font-display text-2xl text-white",children:"Tune the focus field"}),r.jsx("p",{className:"max-w-xl text-sm leading-6 text-white/55",children:"Shape how strongly a focused node opens its neighborhood and how far that pressure diffuses through connected hops."})]}),r.jsx(lt,{asChild:!0,children:r.jsx(Rr,{"aria-label":"Close graph appearance settings"})})]}),r.jsxs("div",{className:"grid gap-4 px-5 py-5",children:[r.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[r.jsxs("div",{className:"grid gap-3 rounded-[24px] border border-white/10 bg-white/[0.04] p-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-medium text-white",children:"Focused repulsion"}),r.jsx("div",{className:"text-xs leading-5 text-white/46",children:"Push nearby nodes apart more aggressively while the focused node stays anchored."})]}),r.jsx("div",{className:"rounded-full border border-white/10 bg-white/[0.06] px-2.5 py-1 text-xs text-white/72",children:A.focusRepulsion.toFixed(2)})]}),r.jsx("input",{"aria-label":"Focused repulsion",type:"range",min:"0.6",max:String(Pt),step:"0.05",value:A.focusRepulsion,onChange:n=>re("focusRepulsion",Number(n.target.value)),className:"w-full accent-[var(--secondary)]"})]}),r.jsxs("div",{className:"grid gap-3 rounded-[24px] border border-white/10 bg-white/[0.04] p-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-medium text-white",children:"Focus diffusion"}),r.jsx("div",{className:"text-xs leading-5 text-white/46",children:"Extend the focus field further through multi-hop neighbors and lengthen the reversible transition."})]}),r.jsx("div",{className:"rounded-full border border-white/10 bg-white/[0.06] px-2.5 py-1 text-xs text-white/72",children:A.focusDiffusion.toFixed(2)})]}),r.jsx("input",{"aria-label":"Focus diffusion",type:"range",min:"0.6",max:String(Tt),step:"0.05",value:A.focusDiffusion,onChange:n=>re("focusDiffusion",Number(n.target.value)),className:"w-full accent-[var(--secondary)]"})]}),r.jsxs("div",{className:"grid gap-3 rounded-[24px] border border-white/10 bg-white/[0.04] p-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-medium text-white",children:"Spring reduction max"}),r.jsx("div",{className:"text-xs leading-5 text-white/46",children:"Reduce edge spring constants most strongly around the focused node so its local neighborhood can open more freely."})]}),r.jsx("div",{className:"rounded-full border border-white/10 bg-white/[0.06] px-2.5 py-1 text-xs text-white/72",children:A.focusSpringReductionMax.toFixed(2)})]}),r.jsx("input",{"aria-label":"Spring reduction max",type:"range",min:"0",max:String(Dt),step:"0.02",value:A.focusSpringReductionMax,onChange:n=>re("focusSpringReductionMax",Number(n.target.value)),className:"w-full accent-[var(--secondary)]"})]}),r.jsxs("div",{className:"grid gap-3 rounded-[24px] border border-white/10 bg-white/[0.04] p-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-medium text-white",children:"Spring reduction diffusion"}),r.jsx("div",{className:"text-xs leading-5 text-white/46",children:"Spread that spring softening progressively through first-hop, second-hop, and more distant neighborhoods."})]}),r.jsx("div",{className:"rounded-full border border-white/10 bg-white/[0.06] px-2.5 py-1 text-xs text-white/72",children:A.focusSpringReductionDiffusion.toFixed(2)})]}),r.jsx("input",{"aria-label":"Spring reduction diffusion",type:"range",min:"0.6",max:String(zt),step:"0.05",value:A.focusSpringReductionDiffusion,onChange:n=>re("focusSpringReductionDiffusion",Number(n.target.value)),className:"w-full accent-[var(--secondary)]"})]}),r.jsxs("div",{className:"grid gap-3 rounded-[24px] border border-white/10 bg-white/[0.04] p-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-medium text-white",children:"Edge spring strength"}),r.jsx("div",{className:"text-xs leading-5 text-white/46",children:"Lower this to loosen graph edges globally and let neighborhoods spread instead of snapping tightly inward."})]}),r.jsx("div",{className:"rounded-full border border-white/10 bg-white/[0.06] px-2.5 py-1 text-xs text-white/72",children:A.edgeSpringStrength.toFixed(2)})]}),r.jsx("input",{"aria-label":"Edge spring strength",type:"range",min:String(Lt),max:String($t),step:"0.05",value:A.edgeSpringStrength,onChange:n=>re("edgeSpringStrength",Number(n.target.value)),className:"w-full accent-[var(--secondary)]"})]}),r.jsxs("div",{className:"grid gap-3 rounded-[24px] border border-white/10 bg-white/[0.04] p-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-medium text-white",children:"Gravity strength"}),r.jsx("div",{className:"text-xs leading-5 text-white/46",children:"Reduce this to weaken the global inward pull that compacts the whole graph toward the middle."})]}),r.jsx("div",{className:"rounded-full border border-white/10 bg-white/[0.06] px-2.5 py-1 text-xs text-white/72",children:A.gravityStrength.toFixed(2)})]}),r.jsx("input",{"aria-label":"Gravity strength",type:"range",min:"0",max:String(Yt),step:"0.05",value:A.gravityStrength,onChange:n=>re("gravityStrength",Number(n.target.value)),className:"w-full accent-[var(--secondary)]"})]}),r.jsxs("div",{className:"grid gap-3 rounded-[24px] border border-white/10 bg-white/[0.04] p-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-medium text-white",children:"Focus shell spacing"}),r.jsx("div",{className:"text-xs leading-5 text-white/46",children:"Increase this to push focused rings farther outward and visibly open the local structure."})]}),r.jsx("div",{className:"rounded-full border border-white/10 bg-white/[0.06] px-2.5 py-1 text-xs text-white/72",children:A.focusShellSpacing.toFixed(2)})]}),r.jsx("input",{"aria-label":"Focus shell spacing",type:"range",min:String(Ht),max:String(Vt),step:"0.05",value:A.focusShellSpacing,onChange:n=>re("focusShellSpacing",Number(n.target.value)),className:"w-full accent-[var(--secondary)]"})]})]}),r.jsx("div",{className:"rounded-[24px] border border-white/8 bg-[rgba(125,211,252,0.07)] px-4 py-3 text-sm leading-6 text-white/62",children:"The main cramming forces are the edge springs and the inward gravity pull. Lower edge spring strength or gravity strength to let the whole graph breathe more, then raise focus shell spacing and spring-reduction controls when you want a selected neighborhood to open dramatically."}),r.jsxs("div",{className:"flex flex-wrap justify-between gap-3",children:[r.jsx(W,{variant:"secondary",onClick:()=>me(ee),children:"Reset defaults"}),r.jsx(lt,{asChild:!0,children:r.jsx(W,{variant:"primary",children:"Done"})})]})]})]})]})}),null]})}export{An as KnowledgeGraphPage};
@@ -1 +1 @@
1
- import{j as t}from"./vendor-DHkYh85p.js";import{L as i}from"./life-force-workspace-B1fYSXRC.js";import{u as o,aX as a}from"./index-BHTUu_4M.js";import{P as s}from"./page-hero-CQWo1Mm_.js";import"./state-B-4sS1xO.js";import"./floating-action-menu-CJkI2iFy.js";import"./charts-P7EVhIog.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";function v(){const e=o(),r=e.snapshot.lifeForce;return r?t.jsxs("div",{className:"grid gap-4",children:[t.jsx(s,{title:"Life Force",titleText:"Life Force",description:"Edit weekday Action Point curves, inspect drains, and tune the capacity model without crowding the Overview surface.",badge:`${Math.round(r.spentTodayAp)} / ${Math.round(r.dailyBudgetAp)} AP`,actions:t.jsx(a,{users:e.snapshot.users,selectedUserIds:e.selectedUserIds,onChange:e.setSelectedUserIds})}),t.jsx(i,{selectedUserIds:e.selectedUserIds,fallbackLifeForce:r,onRefresh:e.refresh,showEditor:!0})]}):t.jsx("div",{className:"grid gap-4",children:t.jsx(s,{title:"Life Force",titleText:"Life Force",description:"Action Point capacity, weekday curves, and instant headroom editing live here.",badge:"Not calibrated yet"})})}export{v as LifeForcePage};
1
+ import{j as t}from"./vendor-kIz9EZnX.js";import{L as i}from"./life-force-workspace-CLVexVnb.js";import{u as o,aX as a}from"./index-BHIKoiZ6.js";import{P as s}from"./page-hero-oFHaAjtL.js";import"./state-VYvD1QVP.js";import"./floating-action-menu-zzC2r0Ob.js";import"./charts-FcU0F3XV.js";import"./motion-CfdU2F35.js";import"./ui-CsEkP2V8.js";import"./forms-CmLAyGqz.js";import"./board-DqHzdCPQ.js";import"./graph-BTa79qum.js";function v(){const e=o(),r=e.snapshot.lifeForce;return r?t.jsxs("div",{className:"grid gap-4",children:[t.jsx(s,{title:"Life Force",titleText:"Life Force",description:"Edit weekday Action Point curves, inspect drains, and tune the capacity model without crowding the Overview surface.",badge:`${Math.round(r.spentTodayAp)} / ${Math.round(r.dailyBudgetAp)} AP`,actions:t.jsx(a,{users:e.snapshot.users,selectedUserIds:e.selectedUserIds,onChange:e.setSelectedUserIds})}),t.jsx(i,{selectedUserIds:e.selectedUserIds,fallbackLifeForce:r,onRefresh:e.refresh,showEditor:!0})]}):t.jsx("div",{className:"grid gap-4",children:t.jsx(s,{title:"Life Force",titleText:"Life Force",description:"Action Point capacity, weekday curves, and instant headroom editing live here.",badge:"Not calibrated yet"})})}export{v as LifeForcePage};
@@ -1 +1 @@
1
- import{r as u,j as e,c9 as Ae,by as ke,bG as Pe,aH as me,bU as De,cS as Me,c7 as He,bF as Te,bX as Ce,aC as Oe}from"./vendor-DHkYh85p.js";import{j as ue,i as xe,k as q}from"./state-B-4sS1xO.js";import{i as K,cS as Se,cT as U,C as w,c as J,B as ee,Z as $,O as pe}from"./index-BHTUu_4M.js";import{F as Le}from"./floating-action-menu-CJkI2iFy.js";import{A as Fe,C as _e,X as Ee,c as le,Y as Ie,T as Xe,d as ze,a as Ye,b as Be}from"./charts-P7EVhIog.js";const Y=20,ce=288,M={top:16,right:18,bottom:28,left:42},te=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function Re(t,a){return te.map((r,o)=>({weekday:o,baselineDailyAp:t.baselineDailyAp,points:t.currentCurve.map(i=>({...i,locked:o===a?i.locked:!1}))}))}function re(t){return`${Number(t.toFixed(1))} AP`}function O(t){return`${Number(t.toFixed(1))} AP/h`}function se(t){const a=new Date(2026,0,1,0,t,0,0);return new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"}).format(a)}function We(t){const a=new Date(2026,0,1,0,t,0,0);return new Intl.DateTimeFormat(void 0,{hour:"numeric"}).format(a)}function C(t,a,r){return Math.min(r,Math.max(a,t))}function $e(t){if(t.length<2)return 0;let a=0;for(let r=0;r<t.length-1;r+=1){const o=t[r],i=t[r+1];a+=(o.rateApPerHour+i.rateApPerHour)/2*((i.minuteOfDay-o.minuteOfDay)/60)}return a}function de(t,a){if(t.length===0)return 0;if(a<=t[0].minuteOfDay)return t[0].rateApPerHour;for(let r=0;r<t.length-1;r+=1){const o=t[r],i=t[r+1];if(a<=i.minuteOfDay){const v=Math.max(1,i.minuteOfDay-o.minuteOfDay),y=(a-o.minuteOfDay)/v;return o.rateApPerHour+(i.rateApPerHour-o.rateApPerHour)*y}}return t[t.length-1].rateApPerHour}function qe(t,a){const r=$e(t);if(r<=0||a<=0)return t.map(i=>({...i,rateApPerHour:0}));const o=a/r;return t.map(i=>({...i,rateApPerHour:Number((i.rateApPerHour*o).toFixed(4))}))}function Ke(t,a,r){var x;if(a<=0||a>=t.length-1)return((x=t[a])==null?void 0:x.rateApPerHour)??0;const o=t[a-1],i=t[a],v=t[a+1];let y=0;for(let f=0;f<t.length-1;f+=1){if(f===a-1||f===a)continue;const n=t[f],H=t[f+1];y+=(n.rateApPerHour+H.rateApPerHour)/2*((H.minuteOfDay-n.minuteOfDay)/60)}const S=Math.max(Y/60,(i.minuteOfDay-o.minuteOfDay)/60),P=Math.max(Y/60,(v.minuteOfDay-i.minuteOfDay)/60);return Math.max(0,(2*(r-y)-o.rateApPerHour*S-v.rateApPerHour*P)/(S+P))}function Qe(t){switch(t){case"danger":return"bg-rose-400/12 text-rose-100";case"warning":return"bg-amber-400/12 text-amber-100";case"success":return"bg-emerald-400/12 text-emerald-100";case"info":default:return"bg-sky-400/12 text-sky-100"}}function Ge(t){switch(t){case"primary":return"Primary";case"secondary":return"Secondary";case"recovery":return"Recovery";case"background":default:return"Ambient"}}function he(t){return t.spentTodayAp>t.dailyBudgetAp?"Over budget":t.spentTodayAp<t.targetBandMinAp?"Below target band":"Inside target band"}function Ve(t){return t.overloadApPerHour>0||t.instantFreeApPerHour<=0?"Recovery":t.instantCapacityApPerHour>=t.currentDrainApPerHour+4?"Deep work":"Low-friction admin"}function Ze({lifeForce:t}){return e.jsxs("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[e.jsxs(w,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Daily AP"}),e.jsxs("div",{className:"mt-2 font-display text-4xl text-[var(--primary)]",children:[Math.round(t.spentTodayAp),e.jsxs("span",{className:"ml-2 text-lg text-white/44",children:["/ ",Math.round(t.dailyBudgetAp)]})]}),e.jsxs("div",{className:"mt-2 text-sm text-white/58",children:["Target band ",Math.round(t.targetBandMinAp),"-",Math.round(t.targetBandMaxAp)," AP"]}),e.jsx("div",{className:"mt-2 text-xs uppercase tracking-[0.14em] text-white/38",children:he(t)})]}),e.jsxs(w,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Instant headroom"}),e.jsx("div",{className:"mt-2 font-display text-4xl text-white",children:t.instantFreeApPerHour.toFixed(1)}),e.jsxs("div",{className:"mt-2 text-sm text-white/58",children:[O(t.instantCapacityApPerHour)," capacity minus"," ",O(t.currentDrainApPerHour)," load"]}),e.jsx("div",{className:"mt-2 text-xs uppercase tracking-[0.14em] text-white/38",children:t.overloadApPerHour>0?`${O(t.overloadApPerHour)} overloaded`:"No overload right now"})]}),e.jsxs(w,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Fatigue buffer"}),e.jsx("div",{className:"mt-2 font-display text-4xl text-white",children:t.fatigueBufferApPerHour.toFixed(1)}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:"Short-term strain rises with overlap and falls with recovery."})]}),e.jsxs(w,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Forecast"}),e.jsx("div",{className:"mt-2 font-display text-4xl text-white",children:Math.round(t.forecastAp)}),e.jsxs("div",{className:"mt-2 text-sm text-white/58",children:["Planned remaining ",re(t.plannedRemainingAp)]}),e.jsxs("div",{className:"mt-2 text-xs uppercase tracking-[0.14em] text-white/38",children:["Remaining ",re(t.remainingAp)]})]})]})}function Ue({lifeForce:t}){return e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-6",children:t.stats.map(a=>e.jsxs(w,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/38",children:a.label}),e.jsxs(J,{className:"bg-white/[0.08] text-white/70",children:["L",a.level]})]}),e.jsxs("div",{className:"mt-3 text-2xl font-semibold text-white",children:[Math.round(a.xp)," XP"]}),e.jsx("div",{className:"mt-1 text-sm text-white/54",children:a.key==="life_force"?`+${Math.round((a.costModifier-1)*100)}% daily resilience`:`${Math.round((1-a.costModifier)*100)}% cost relief`})]},a.key))})}function Je({lifeForce:t,weekday:a,points:r,baselineDailyAp:o,isDirty:i,isSaving:v,onChange:y,onReset:S,onSave:P,onWeekdayChange:x}){var ne,oe;const f=u.useRef(null),[n,H]=u.useState(null),[E,ae]=u.useState(720),[p,Q]=u.useState(null),L=u.useMemo(()=>new Date().getDay(),[]),F=u.useMemo(()=>{const s=new Date;return s.getHours()*60+s.getMinutes()},[]),B=u.useMemo(()=>[...r].sort((s,l)=>s.minuteOfDay-l.minuteOfDay),[r]),c=u.useMemo(()=>B.map(s=>({...s,locked:a===L?s.minuteOfDay<=F:!1})),[F,B,L,a]),b=u.useMemo(()=>{const s=Math.max(t.instantCapacityApPerHour,...c.map(l=>l.rateApPerHour),8);return Math.max(12,Math.ceil(s*1.25))},[t.instantCapacityApPerHour,c]),G=u.useMemo(()=>c.map(s=>({...s,label:se(s.minuteOfDay)})),[c]),j=u.useMemo(()=>[0,240,480,720,960,1200,1440],[]),V=u.useMemo(()=>Array.from(new Set([0,Math.max(2,Math.round(b/3)),Math.max(4,Math.round(2*b/3)),b])).sort((s,l)=>s-l),[b]),R=Math.max(E,1),_=Math.max(160,R-M.left-M.right),I=ce-M.top-M.bottom;u.useEffect(()=>{const s=()=>{var m;const l=((m=f.current)==null?void 0:m.clientWidth)??0;ae(l>0?l:720)};return s(),window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[]),u.useEffect(()=>{if(n===null||!f.current)return;const s=f.current,l=d=>{if(d.pointerId!==n.pointerId)return;d.preventDefault();const g=s.getBoundingClientRect(),A=Number.isFinite(d.clientX)?d.clientX:g.left+n.pointerX,h=Number.isFinite(d.clientY)?d.clientY:g.top+n.pointerY,D=C(A-g.left,0,g.width),X=C(h-g.top,0,g.height),W=C(A-g.left-M.left,0,_),ye=C(h-g.top-M.top,0,I);y(c.map((N,k)=>{if(k!==n.index)return{minuteOfDay:N.minuteOfDay,rateApPerHour:N.rateApPerHour,locked:N.locked};if(N.locked||k===0||k===c.length-1)return{minuteOfDay:N.minuteOfDay,rateApPerHour:N.rateApPerHour,locked:N.locked};const ve=c[k-1].minuteOfDay+Y,we=c[k+1].minuteOfDay-Y,je=Math.round(C(W/_*1440,ve,we)),z=c.map(ie=>({minuteOfDay:ie.minuteOfDay,rateApPerHour:ie.rateApPerHour,locked:ie.locked}));z[k]={...z[k],minuteOfDay:je};const be=Ke(z,k,o),Ne=C((I-ye)/I*b,0,Math.max(0,be));return z[k]={...z[k],rateApPerHour:Number(Ne.toFixed(3))},z[k]})),H(N=>N===null||N.pointerId!==d.pointerId?N:{...N,pointerX:D,pointerY:X})},m=d=>{(!d||d.pointerId===n.pointerId)&&H(null)};return window.addEventListener("pointermove",l,{passive:!1}),window.addEventListener("pointerup",m),window.addEventListener("pointercancel",m),()=>{window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",m),window.removeEventListener("pointercancel",m)}},[o,n,y,I,_,c,b]);const ge=u.useMemo(()=>{if(!p)return[];const s=c[p.index]??null;return[{id:"remove-point",label:"Remove point",description:s===null?"No turn point is selected.":`Delete the turn point at ${se(s.minuteOfDay)}.`,icon:He,tone:"danger",disabled:s===null||p.index===0||p.index===c.length-1,onSelect:()=>{y(c.filter((l,m)=>m!==p.index))}},{id:"flatten-point",label:"Flatten point",description:s===null?"No turn point is selected.":"Place the handle back on the interpolated segment between its neighbors.",icon:Te,disabled:s===null||p.index===0||p.index===c.length-1,onSelect:()=>{const l=c[p.index-1],m=c[p.index+1],d=de([l,m],s.minuteOfDay);y(c.map((g,A)=>A===p.index?{...g,rateApPerHour:Number(d.toFixed(3))}:g))}}]},[p,y,c]),Z=u.useMemo(()=>c.map(s=>({...s,x:M.left+s.minuteOfDay/1440*_,y:M.top+(1-s.rateApPerHour/Math.max(1,b))*I})),[I,_,c,b]),T=n===null?null:{pointerX:n.pointerX,pointerY:n.pointerY,constrainedX:((ne=Z[n.index])==null?void 0:ne.x)??n.pointerX,constrainedY:((oe=Z[n.index])==null?void 0:oe.y)??n.pointerY};return e.jsxs(e.Fragment,{children:[e.jsxs(w,{className:"overflow-hidden 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:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Life Force view"}),e.jsx("div",{className:"mt-2 text-xl font-semibold text-white",children:"Instant Life Force editor"}),e.jsx("div",{className:"mt-2 max-w-3xl text-sm leading-6 text-white/56",children:"One click adds a turn point. Drag future handles. Right click a handle to remove or flatten it. The ghost handle follows your finger or cursor while the real turn point stays constrained on the curve and normalized to the baseline daily AP budget."})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-1 rounded-full bg-white/[0.04] p-1",children:te.map((s,l)=>e.jsx("button",{type:"button",className:$("rounded-full px-3 py-1.5 text-[11px] font-medium transition",a===l?"bg-[var(--primary)] text-slate-950":"text-white/60 hover:bg-white/[0.05] hover:text-white"),onClick:()=>x(l),children:s},s))}),e.jsx(ee,{variant:"secondary",onClick:S,children:"Reset"}),e.jsxs(ee,{onClick:P,pending:v,disabled:!i,children:[e.jsx(Ce,{className:"mr-2 size-4"}),"Save curve"]})]})]}),e.jsxs("div",{className:"mt-4 rounded-[24px] bg-[linear-gradient(180deg,rgba(192,193,255,0.08),rgba(192,193,255,0.02))] p-3",children:[e.jsxs("div",{ref:f,className:$("relative h-72 w-full overflow-hidden rounded-[20px] bg-[rgba(255,255,255,0.02)]",n!==null?"select-none touch-none":""),style:{touchAction:n===null?"pan-y":"none"},role:"img","aria-label":"Life Force capacity curve editor",onClick:s=>{if(n!==null||!f.current||s.target!==s.currentTarget)return;const l=f.current.getBoundingClientRect(),m=C(s.clientX-l.left-M.left,0,_),d=Math.round(m/_*1440),g=c.findIndex(W=>W.minuteOfDay>d);if(g<=0)return;const A=c[g-1],h=c[g];if(d-A.minuteOfDay<Y||h.minuteOfDay-d<Y)return;const D=de(c,d),X=[...c];X.splice(g,0,{minuteOfDay:d,rateApPerHour:Number(D.toFixed(3)),locked:a===L&&d<=F}),y(X)},children:[e.jsxs(Fe,{width:R,height:ce,data:G,margin:M,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"life-force-chart-fill",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"rgba(192,193,255,0.24)"}),e.jsx("stop",{offset:"100%",stopColor:"rgba(192,193,255,0.02)"})]})}),e.jsx(_e,{vertical:!1,stroke:"rgba(255,255,255,0.08)",strokeDasharray:"3 4"}),e.jsx(Ee,{dataKey:"minuteOfDay",type:"number",domain:[0,1440],ticks:j,tickFormatter:We,tick:{fill:"rgba(255,255,255,0.48)",fontSize:10},tickLine:!1,axisLine:{stroke:"rgba(255,255,255,0.12)"},children:e.jsx(le,{value:"Time",position:"insideBottom",offset:-10,fill:"rgba(255,255,255,0.38)",fontSize:10})}),e.jsx(Ie,{type:"number",domain:[0,b],ticks:V,tick:{fill:"rgba(255,255,255,0.48)",fontSize:10},tickLine:!1,axisLine:{stroke:"rgba(255,255,255,0.12)"},width:34,children:e.jsx(le,{value:"AP/h",angle:-90,position:"insideLeft",fill:"rgba(255,255,255,0.38)",fontSize:10,style:{textAnchor:"middle"}})}),e.jsx(Xe,{cursor:{stroke:"rgba(255,255,255,0.18)",strokeDasharray:"3 4"},content:({active:s,payload:l})=>{var d;const m=s?(d=l==null?void 0:l[0])==null?void 0:d.payload:null;return m?e.jsxs("div",{className:"rounded-[16px] border border-white/10 bg-[rgba(10,15,27,0.95)] px-3 py-2 text-xs text-white shadow-[0_18px_50px_rgba(4,8,18,0.3)] backdrop-blur-xl",children:[e.jsx("div",{className:"font-medium text-white",children:m.label}),e.jsx("div",{className:"mt-1 text-white/60",children:O(m.rateApPerHour)})]}):null}}),a===L?e.jsx(ze,{x:F,stroke:"rgba(255,255,255,0.22)",strokeDasharray:"3 4"}):null,e.jsx(Ye,{type:"linear",dataKey:"rateApPerHour",stroke:"none",fill:"url(#life-force-chart-fill)",isAnimationActive:!1}),e.jsx(Be,{type:"linear",dataKey:"rateApPerHour",stroke:"rgba(214,215,255,0.95)",strokeWidth:1.5,dot:!1,activeDot:!1,isAnimationActive:!1})]}),T?e.jsxs("svg",{className:"pointer-events-none absolute inset-0 z-[15] h-full w-full","aria-hidden":"true",children:[e.jsx("line",{x1:T.constrainedX,y1:T.constrainedY,x2:T.pointerX,y2:T.pointerY,stroke:"rgba(214,215,255,0.38)",strokeDasharray:"4 5",strokeWidth:"1.5"}),e.jsx("circle",{cx:T.pointerX,cy:T.pointerY,r:"11",fill:"rgba(214,215,255,0.12)",stroke:"rgba(214,215,255,0.34)",strokeWidth:"1.5","data-testid":"life-force-ghost-handle"}),e.jsx("circle",{cx:T.pointerX,cy:T.pointerY,r:"3.5",fill:"rgba(255,255,255,0.44)"})]}):null,Z.map((s,l)=>{const m=l===0||l===Z.length-1,d=(n==null?void 0:n.index)===l,g=m?14:16,A=m?22:28;return e.jsx("button",{type:"button","aria-label":`Turn point at ${se(s.minuteOfDay)}`,className:$("absolute z-20 flex items-center justify-center rounded-full transition-transform duration-75",s.locked||m?"cursor-not-allowed":"cursor-grab active:cursor-grabbing",d?"scale-110":""),style:{left:s.x-A/2,top:s.y-A/2,width:A,height:A,touchAction:"none"},onPointerDown:h=>{if(h.preventDefault(),h.stopPropagation(),s.locked||m||!f.current)return;"setPointerCapture"in h.currentTarget&&h.currentTarget.setPointerCapture(h.pointerId);const D=f.current.getBoundingClientRect(),X=Number.isFinite(h.clientX)?h.clientX:D.left+s.x,W=Number.isFinite(h.clientY)?h.clientY:D.top+s.y;H({index:l,pointerId:h.pointerId,pointerX:C(X-D.left,0,D.width),pointerY:C(W-D.top,0,D.height)})},onContextMenu:h=>{h.preventDefault(),h.stopPropagation(),Q({index:l,position:{x:h.clientX+6,y:h.clientY+6}})},children:e.jsx("span",{className:$("pointer-events-none inline-flex rounded-full border border-[rgba(10,15,27,0.92)] shadow-[0_0_0_1px_rgba(255,255,255,0.08),0_10px_24px_rgba(4,8,18,0.28)]",s.locked||m?"bg-white/55":"bg-white"),style:{width:g,height:g,opacity:d?.96:1}})},`${s.minuteOfDay}-${l}`)})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-2 px-1 text-[11px] text-white/42",children:[e.jsxs("div",{children:["Editing ",te[a]," curve"]}),e.jsxs("div",{children:[Math.round(o)," AP/day baseline"]})]})]})]}),e.jsx(Le,{open:p!==null,title:"Turn point actions",subtitle:"Delete the turn point or flatten it back onto the surrounding segment.",items:ge,position:(p==null?void 0:p.position)??null,onClose:()=>Q(null)})]})}function et(){return e.jsx(w,{className:"overflow-hidden 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:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Life Force studio"}),e.jsx("div",{className:"mt-2 text-xl font-semibold text-white",children:"Edit weekday curves in the dedicated view"}),e.jsx("div",{className:"mt-2 max-w-3xl text-sm leading-6 text-white/56",children:"The full weekday editor, turn-point menu, and curve calibration now live in their own page so Overview can stay fast and readable."})]}),e.jsxs(Oe,{to:"/life-force",className:"inline-flex min-h-10 min-w-0 max-w-full items-center justify-center gap-2 overflow-hidden whitespace-nowrap rounded-[var(--radius-control)] border border-[var(--primary)]/14 bg-[var(--ui-accent-soft)] px-3 py-2 text-[13px] font-medium text-[var(--ui-ink-on-accent)] shadow-[var(--ui-shadow-soft)] transition hover:bg-[var(--ui-accent-soft-hover)]",children:[e.jsx(me,{className:"size-4"}),"Open Life Force studio"]})]})})}function tt({drains:t,plannedDrains:a,warnings:r,recommendations:o}){return e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)]",children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsxs(w,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Current drains"}),e.jsx("div",{className:"mt-2 text-xl font-semibold text-white",children:"What is consuming Life Force now"})]}),e.jsxs(J,{className:"bg-white/[0.08] text-white/70",children:[t.length," active"]})]}),e.jsx("div",{className:"mt-4 grid gap-3",children:t.length===0?e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-4 text-sm text-white/58",children:"No current drainers are active. This is a good moment to choose your next intentional action."}):t.map(i=>e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-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:"text-base font-semibold text-white",children:i.title}),e.jsx("div",{className:"mt-1 text-sm text-white/54",children:i.why})]}),e.jsxs("div",{className:"shrink-0 text-right",children:[e.jsx("div",{className:"text-base font-semibold text-[var(--primary)]",children:O(i.apPerHour)}),e.jsx("div",{className:"mt-1 text-xs uppercase tracking-[0.14em] text-white/38",children:Ge(i.role)})]})]})},i.id))})]}),e.jsxs(w,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Planned drains"}),e.jsx("div",{className:"mt-2 text-xl font-semibold text-white",children:"What the rest of today is already asking from you"})]}),e.jsxs(J,{className:"bg-white/[0.08] text-white/70",children:[a.length," planned"]})]}),e.jsx("div",{className:"mt-4 grid gap-3",children:a.length===0?e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-4 text-sm text-white/58",children:"No future AP load has been forecast yet. The day is still open."}):a.slice(0,6).map(i=>e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-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:"text-base font-semibold text-white",children:i.title}),e.jsx("div",{className:"mt-1 text-sm text-white/54",children:i.why})]}),e.jsxs("div",{className:"shrink-0 text-right",children:[e.jsx("div",{className:"text-base font-semibold text-[var(--primary)]",children:re(i.instantAp)}),e.jsx("div",{className:"mt-1 text-xs uppercase tracking-[0.14em] text-white/38",children:O(i.apPerHour)})]})]})},i.id))})]})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs(w,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Warnings"}),e.jsx("div",{className:"mt-4 grid gap-3",children:r.map(i=>e.jsxs("div",{className:$("rounded-[18px] px-4 py-4",Qe(i.tone)),children:[e.jsx("div",{className:"text-sm font-semibold",children:i.title}),e.jsx("div",{className:"mt-1 text-sm leading-6 text-current/80",children:i.detail})]},i.id))})]}),e.jsxs(w,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Recommendations"}),e.jsx("div",{className:"mt-4 grid gap-2",children:o.map((i,v)=>e.jsx("div",{className:"rounded-[16px] bg-white/[0.04] px-4 py-3 text-sm leading-6 text-white/66",children:i},`${i}-${v}`))})]})]})]})}function fe({lifeForce:t,onTired:a,onOkayAgain:r,tiredPending:o,okayPending:i,feedback:v}){return e.jsxs(w,{className:"overflow-hidden p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Life Force now"}),e.jsxs("div",{className:"mt-2 text-2xl font-semibold text-white",children:[t.instantFreeApPerHour.toFixed(1)," AP/h free"]}),e.jsxs("div",{className:"mt-2 text-sm text-white/58",children:[Math.round(t.spentTodayAp)," / ",Math.round(t.dailyBudgetAp)," AP used today"]}),e.jsx("div",{className:"mt-2 text-xs uppercase tracking-[0.14em] text-white/38",children:he(t)})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(ee,{variant:"secondary",onClick:a,pending:o,children:[e.jsx(ke,{className:"mr-2 size-4"}),"I'm getting tired"]}),e.jsxs(ee,{variant:"secondary",onClick:r,pending:i,children:[e.jsx(Pe,{className:"mr-2 size-4"}),"I'm okay again"]})]})]}),v?e.jsx("div",{className:"mt-4 rounded-[18px] bg-[var(--primary)]/10 px-4 py-3 text-sm text-white/74",children:v}):null,e.jsxs("div",{className:"mt-4 grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-white",children:[e.jsx(me,{className:"size-4 text-[var(--primary)]"}),"Instant capacity"]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:O(t.instantCapacityApPerHour)})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-white",children:[e.jsx(De,{className:"size-4 text-[var(--primary)]"}),"Current load"]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:O(t.currentDrainApPerHour)}),e.jsx("div",{className:"mt-2 text-xs uppercase tracking-[0.14em] text-white/38",children:t.overloadApPerHour>0?`${O(t.overloadApPerHour)} overload`:"Inside instant limit"})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-white",children:[e.jsx(Me,{className:"size-4 text-[var(--primary)]"}),"Next move"]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:t.recommendations[0]??"Favor the next clean, manageable action."}),e.jsx("div",{className:"mt-2 text-xs uppercase tracking-[0.14em] text-white/38",children:Ve(t)})]})]})]})}function ot({selectedUserIds:t,fallbackLifeForce:a,onRefresh:r,showEditor:o=!0}){var b,G;const i=ue(),v=new Date().getDay(),[y,S]=u.useState(v),P=xe({queryKey:["forge-life-force",...t],queryFn:()=>pe(t),initialData:a===void 0?void 0:{lifeForce:a,templates:te.map((j,V)=>({weekday:V,baselineDailyAp:a.baselineDailyAp,points:a.currentCurve.map(R=>({...R,locked:V===v?R.locked:!1}))}))}}),x=((b=P.data)==null?void 0:b.lifeForce)??a,n=(((G=P.data)==null?void 0:G.templates)??Re(x,v)).find(j=>j.weekday===y)??{weekday:y,baselineDailyAp:x.baselineDailyAp,points:x.currentCurve},[H,E]=u.useState(n.points),[ae,p]=u.useState(!1),[Q,L]=u.useState(null);u.useEffect(()=>{E(n.points),p(!1)},[n.points,n.weekday]);const F=q({mutationFn:j=>Se(n.weekday,{points:qe(j,n.baselineDailyAp)},t),onSuccess:async j=>{await i.invalidateQueries({queryKey:["forge-life-force"]}),await K(i),r&&await r(),E(j.points),p(!1)}}),B=q({mutationFn:()=>U({signalType:"tired"},t),onSuccess:async()=>{await i.invalidateQueries({queryKey:["forge-life-force"]}),await K(i),r&&await r(),L("Tiredness signal applied. Today’s Life Force now reflects the extra strain.")}}),c=q({mutationFn:()=>U({signalType:"okay_again"},t),onSuccess:async()=>{await i.invalidateQueries({queryKey:["forge-life-force"]}),await K(i),r&&await r(),L("Recovery signal applied. Instant strain has been eased for the rest of today.")}});return e.jsxs("div",{className:"grid gap-4",children:[e.jsx(Ze,{lifeForce:x}),e.jsx(Ue,{lifeForce:x}),e.jsx(fe,{lifeForce:x,onTired:()=>{B.mutateAsync()},onOkayAgain:()=>{c.mutateAsync()},tiredPending:B.isPending,okayPending:c.isPending,feedback:Q}),o?e.jsx(Je,{lifeForce:x,weekday:y,points:H,baselineDailyAp:n.baselineDailyAp,isDirty:ae,isSaving:F.isPending,onWeekdayChange:S,onChange:j=>{E(j),p(!0)},onReset:()=>{E(n.points),p(!1)},onSave:()=>{F.mutateAsync(H)}}):e.jsx(et,{}),e.jsx(tt,{drains:x.activeDrains,plannedDrains:x.plannedDrains,warnings:x.warnings,recommendations:x.recommendations}),x.topTaskIdsNeedingSplit.length>0?e.jsxs(w,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-white",children:[e.jsx(Ae,{className:"size-4 text-[var(--primary)]"}),"Tasks asking to be split"]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:x.topTaskIdsNeedingSplit.map(j=>e.jsx(J,{className:"bg-white/[0.08] text-white/74",children:j},j))})]}):null]})}function lt({selectedUserIds:t,fallbackLifeForce:a,onRefresh:r}){var n;const o=Array.isArray(t)?t:[],i=ue(),y=((n=xe({queryKey:["forge-life-force",...o],queryFn:()=>pe(o),initialData:a===void 0?void 0:{lifeForce:a,templates:[]}}).data)==null?void 0:n.lifeForce)??a;if(!y)return e.jsxs(w,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Life Force"}),e.jsx("div",{className:"mt-2 text-lg font-semibold text-white",children:"Not calibrated yet"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:"Today can still load without a Life Force snapshot, but the AP and instant headroom model is not available for this state yet."})]});const[S,P]=u.useState(null),x=q({mutationFn:()=>U({signalType:"tired"},o),onSuccess:async()=>{await i.invalidateQueries({queryKey:["forge-life-force"]}),await K(i),r&&await r(),P("Tiredness signal applied. Today’s headroom has been reduced.")}}),f=q({mutationFn:()=>U({signalType:"okay_again"},o),onSuccess:async()=>{await i.invalidateQueries({queryKey:["forge-life-force"]}),await K(i),r&&await r(),P("Recovery signal applied. Today’s headroom has been eased.")}});return e.jsx(fe,{lifeForce:y,onTired:()=>{x.mutateAsync()},onOkayAgain:()=>{f.mutateAsync()},tiredPending:x.isPending,okayPending:f.isPending,feedback:S})}export{ot as L,lt as a};
1
+ import{r as u,j as e,c9 as Ae,bA as ke,bC as Pe,aH as me,bL as De,cR as Me,c7 as He,bK as Te,bX as Ce,aC as Oe}from"./vendor-kIz9EZnX.js";import{j as ue,i as xe,k as $}from"./state-VYvD1QVP.js";import{i as q,cP as Le,cQ as J,C as w,c as U,B as ee,Z as K,O as pe}from"./index-BHIKoiZ6.js";import{F as Se}from"./floating-action-menu-zzC2r0Ob.js";import{A as Fe,C as _e,X as Ee,L as le,Y as Ie,T as Xe,b as ze,a as Re,c as Ye}from"./charts-FcU0F3XV.js";const R=20,ce=288,M={top:16,right:18,bottom:28,left:42},te=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function Be(t,a){return te.map((r,o)=>({weekday:o,baselineDailyAp:t.baselineDailyAp,points:t.currentCurve.map(i=>({...i,locked:o===a?i.locked:!1}))}))}function re(t){return`${Number(t.toFixed(1))} AP`}function O(t){return`${Number(t.toFixed(1))} AP/h`}function se(t){const a=new Date(2026,0,1,0,t,0,0);return new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"}).format(a)}function We(t){const a=new Date(2026,0,1,0,t,0,0);return new Intl.DateTimeFormat(void 0,{hour:"numeric"}).format(a)}function C(t,a,r){return Math.min(r,Math.max(a,t))}function Ke(t){if(t.length<2)return 0;let a=0;for(let r=0;r<t.length-1;r+=1){const o=t[r],i=t[r+1];a+=(o.rateApPerHour+i.rateApPerHour)/2*((i.minuteOfDay-o.minuteOfDay)/60)}return a}function de(t,a){if(t.length===0)return 0;if(a<=t[0].minuteOfDay)return t[0].rateApPerHour;for(let r=0;r<t.length-1;r+=1){const o=t[r],i=t[r+1];if(a<=i.minuteOfDay){const v=Math.max(1,i.minuteOfDay-o.minuteOfDay),y=(a-o.minuteOfDay)/v;return o.rateApPerHour+(i.rateApPerHour-o.rateApPerHour)*y}}return t[t.length-1].rateApPerHour}function $e(t,a){const r=Ke(t);if(r<=0||a<=0)return t.map(i=>({...i,rateApPerHour:0}));const o=a/r;return t.map(i=>({...i,rateApPerHour:Number((i.rateApPerHour*o).toFixed(4))}))}function qe(t,a,r){var x;if(a<=0||a>=t.length-1)return((x=t[a])==null?void 0:x.rateApPerHour)??0;const o=t[a-1],i=t[a],v=t[a+1];let y=0;for(let f=0;f<t.length-1;f+=1){if(f===a-1||f===a)continue;const n=t[f],H=t[f+1];y+=(n.rateApPerHour+H.rateApPerHour)/2*((H.minuteOfDay-n.minuteOfDay)/60)}const L=Math.max(R/60,(i.minuteOfDay-o.minuteOfDay)/60),P=Math.max(R/60,(v.minuteOfDay-i.minuteOfDay)/60);return Math.max(0,(2*(r-y)-o.rateApPerHour*L-v.rateApPerHour*P)/(L+P))}function Qe(t){switch(t){case"danger":return"bg-rose-400/12 text-rose-100";case"warning":return"bg-amber-400/12 text-amber-100";case"success":return"bg-emerald-400/12 text-emerald-100";case"info":default:return"bg-sky-400/12 text-sky-100"}}function Ge(t){switch(t){case"primary":return"Primary";case"secondary":return"Secondary";case"recovery":return"Recovery";case"background":default:return"Ambient"}}function he(t){return t.spentTodayAp>t.dailyBudgetAp?"Over budget":t.spentTodayAp<t.targetBandMinAp?"Below target band":"Inside target band"}function Ve(t){return t.overloadApPerHour>0||t.instantFreeApPerHour<=0?"Recovery":t.instantCapacityApPerHour>=t.currentDrainApPerHour+4?"Deep work":"Low-friction admin"}function Ze({lifeForce:t}){return e.jsxs("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[e.jsxs(w,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Daily AP"}),e.jsxs("div",{className:"mt-2 font-display text-4xl text-[var(--primary)]",children:[Math.round(t.spentTodayAp),e.jsxs("span",{className:"ml-2 text-lg text-white/44",children:["/ ",Math.round(t.dailyBudgetAp)]})]}),e.jsxs("div",{className:"mt-2 text-sm text-white/58",children:["Target band ",Math.round(t.targetBandMinAp),"-",Math.round(t.targetBandMaxAp)," AP"]}),e.jsx("div",{className:"mt-2 text-xs uppercase tracking-[0.14em] text-white/38",children:he(t)})]}),e.jsxs(w,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Instant headroom"}),e.jsx("div",{className:"mt-2 font-display text-4xl text-white",children:t.instantFreeApPerHour.toFixed(1)}),e.jsxs("div",{className:"mt-2 text-sm text-white/58",children:[O(t.instantCapacityApPerHour)," capacity minus"," ",O(t.currentDrainApPerHour)," load"]}),e.jsx("div",{className:"mt-2 text-xs uppercase tracking-[0.14em] text-white/38",children:t.overloadApPerHour>0?`${O(t.overloadApPerHour)} overloaded`:"No overload right now"})]}),e.jsxs(w,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Fatigue buffer"}),e.jsx("div",{className:"mt-2 font-display text-4xl text-white",children:t.fatigueBufferApPerHour.toFixed(1)}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:"Short-term strain rises with overlap and falls with recovery."})]}),e.jsxs(w,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Forecast"}),e.jsx("div",{className:"mt-2 font-display text-4xl text-white",children:Math.round(t.forecastAp)}),e.jsxs("div",{className:"mt-2 text-sm text-white/58",children:["Planned remaining ",re(t.plannedRemainingAp)]}),e.jsxs("div",{className:"mt-2 text-xs uppercase tracking-[0.14em] text-white/38",children:["Remaining ",re(t.remainingAp)]})]})]})}function Je({lifeForce:t}){return e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-6",children:t.stats.map(a=>e.jsxs(w,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/38",children:a.label}),e.jsxs(U,{className:"bg-white/[0.08] text-white/70",children:["L",a.level]})]}),e.jsxs("div",{className:"mt-3 text-2xl font-semibold text-white",children:[Math.round(a.xp)," XP"]}),e.jsx("div",{className:"mt-1 text-sm text-white/54",children:a.key==="life_force"?`+${Math.round((a.costModifier-1)*100)}% daily resilience`:`${Math.round((1-a.costModifier)*100)}% cost relief`})]},a.key))})}function Ue({lifeForce:t,weekday:a,points:r,baselineDailyAp:o,isDirty:i,isSaving:v,onChange:y,onReset:L,onSave:P,onWeekdayChange:x}){var ne,oe;const f=u.useRef(null),[n,H]=u.useState(null),[E,ae]=u.useState(720),[p,Q]=u.useState(null),S=u.useMemo(()=>new Date().getDay(),[]),F=u.useMemo(()=>{const s=new Date;return s.getHours()*60+s.getMinutes()},[]),Y=u.useMemo(()=>[...r].sort((s,l)=>s.minuteOfDay-l.minuteOfDay),[r]),c=u.useMemo(()=>Y.map(s=>({...s,locked:a===S?s.minuteOfDay<=F:!1})),[F,Y,S,a]),b=u.useMemo(()=>{const s=Math.max(t.instantCapacityApPerHour,...c.map(l=>l.rateApPerHour),8);return Math.max(12,Math.ceil(s*1.25))},[t.instantCapacityApPerHour,c]),G=u.useMemo(()=>c.map(s=>({...s,label:se(s.minuteOfDay)})),[c]),j=u.useMemo(()=>[0,240,480,720,960,1200,1440],[]),V=u.useMemo(()=>Array.from(new Set([0,Math.max(2,Math.round(b/3)),Math.max(4,Math.round(2*b/3)),b])).sort((s,l)=>s-l),[b]),B=Math.max(E,1),_=Math.max(160,B-M.left-M.right),I=ce-M.top-M.bottom;u.useEffect(()=>{const s=()=>{var m;const l=((m=f.current)==null?void 0:m.clientWidth)??0;ae(l>0?l:720)};return s(),window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[]),u.useEffect(()=>{if(n===null||!f.current)return;const s=f.current,l=d=>{if(d.pointerId!==n.pointerId)return;d.preventDefault();const g=s.getBoundingClientRect(),A=Number.isFinite(d.clientX)?d.clientX:g.left+n.pointerX,h=Number.isFinite(d.clientY)?d.clientY:g.top+n.pointerY,D=C(A-g.left,0,g.width),X=C(h-g.top,0,g.height),W=C(A-g.left-M.left,0,_),ye=C(h-g.top-M.top,0,I);y(c.map((N,k)=>{if(k!==n.index)return{minuteOfDay:N.minuteOfDay,rateApPerHour:N.rateApPerHour,locked:N.locked};if(N.locked||k===0||k===c.length-1)return{minuteOfDay:N.minuteOfDay,rateApPerHour:N.rateApPerHour,locked:N.locked};const ve=c[k-1].minuteOfDay+R,we=c[k+1].minuteOfDay-R,je=Math.round(C(W/_*1440,ve,we)),z=c.map(ie=>({minuteOfDay:ie.minuteOfDay,rateApPerHour:ie.rateApPerHour,locked:ie.locked}));z[k]={...z[k],minuteOfDay:je};const be=qe(z,k,o),Ne=C((I-ye)/I*b,0,Math.max(0,be));return z[k]={...z[k],rateApPerHour:Number(Ne.toFixed(3))},z[k]})),H(N=>N===null||N.pointerId!==d.pointerId?N:{...N,pointerX:D,pointerY:X})},m=d=>{(!d||d.pointerId===n.pointerId)&&H(null)};return window.addEventListener("pointermove",l,{passive:!1}),window.addEventListener("pointerup",m),window.addEventListener("pointercancel",m),()=>{window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",m),window.removeEventListener("pointercancel",m)}},[o,n,y,I,_,c,b]);const ge=u.useMemo(()=>{if(!p)return[];const s=c[p.index]??null;return[{id:"remove-point",label:"Remove point",description:s===null?"No turn point is selected.":`Delete the turn point at ${se(s.minuteOfDay)}.`,icon:He,tone:"danger",disabled:s===null||p.index===0||p.index===c.length-1,onSelect:()=>{y(c.filter((l,m)=>m!==p.index))}},{id:"flatten-point",label:"Flatten point",description:s===null?"No turn point is selected.":"Place the handle back on the interpolated segment between its neighbors.",icon:Te,disabled:s===null||p.index===0||p.index===c.length-1,onSelect:()=>{const l=c[p.index-1],m=c[p.index+1],d=de([l,m],s.minuteOfDay);y(c.map((g,A)=>A===p.index?{...g,rateApPerHour:Number(d.toFixed(3))}:g))}}]},[p,y,c]),Z=u.useMemo(()=>c.map(s=>({...s,x:M.left+s.minuteOfDay/1440*_,y:M.top+(1-s.rateApPerHour/Math.max(1,b))*I})),[I,_,c,b]),T=n===null?null:{pointerX:n.pointerX,pointerY:n.pointerY,constrainedX:((ne=Z[n.index])==null?void 0:ne.x)??n.pointerX,constrainedY:((oe=Z[n.index])==null?void 0:oe.y)??n.pointerY};return e.jsxs(e.Fragment,{children:[e.jsxs(w,{className:"overflow-hidden 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:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Life Force view"}),e.jsx("div",{className:"mt-2 text-xl font-semibold text-white",children:"Instant Life Force editor"}),e.jsx("div",{className:"mt-2 max-w-3xl text-sm leading-6 text-white/56",children:"One click adds a turn point. Drag future handles. Right click a handle to remove or flatten it. The ghost handle follows your finger or cursor while the real turn point stays constrained on the curve and normalized to the baseline daily AP budget."})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-1 rounded-full bg-white/[0.04] p-1",children:te.map((s,l)=>e.jsx("button",{type:"button",className:K("rounded-full px-3 py-1.5 text-[11px] font-medium transition",a===l?"bg-[var(--primary)] text-slate-950":"text-white/60 hover:bg-white/[0.05] hover:text-white"),onClick:()=>x(l),children:s},s))}),e.jsx(ee,{variant:"secondary",onClick:L,children:"Reset"}),e.jsxs(ee,{onClick:P,pending:v,disabled:!i,children:[e.jsx(Ce,{className:"mr-2 size-4"}),"Save curve"]})]})]}),e.jsxs("div",{className:"mt-4 rounded-[24px] bg-[linear-gradient(180deg,rgba(192,193,255,0.08),rgba(192,193,255,0.02))] p-3",children:[e.jsxs("div",{ref:f,className:K("relative h-72 w-full overflow-hidden rounded-[20px] bg-[rgba(255,255,255,0.02)]",n!==null?"select-none touch-none":""),style:{touchAction:n===null?"pan-y":"none"},role:"img","aria-label":"Life Force capacity curve editor",onClick:s=>{if(n!==null||!f.current||s.target!==s.currentTarget)return;const l=f.current.getBoundingClientRect(),m=C(s.clientX-l.left-M.left,0,_),d=Math.round(m/_*1440),g=c.findIndex(W=>W.minuteOfDay>d);if(g<=0)return;const A=c[g-1],h=c[g];if(d-A.minuteOfDay<R||h.minuteOfDay-d<R)return;const D=de(c,d),X=[...c];X.splice(g,0,{minuteOfDay:d,rateApPerHour:Number(D.toFixed(3)),locked:a===S&&d<=F}),y(X)},children:[e.jsxs(Fe,{width:B,height:ce,data:G,margin:M,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"life-force-chart-fill",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"rgba(192,193,255,0.24)"}),e.jsx("stop",{offset:"100%",stopColor:"rgba(192,193,255,0.02)"})]})}),e.jsx(_e,{vertical:!1,stroke:"rgba(255,255,255,0.08)",strokeDasharray:"3 4"}),e.jsx(Ee,{dataKey:"minuteOfDay",type:"number",domain:[0,1440],ticks:j,tickFormatter:We,tick:{fill:"rgba(255,255,255,0.48)",fontSize:10},tickLine:!1,axisLine:{stroke:"rgba(255,255,255,0.12)"},children:e.jsx(le,{value:"Time",position:"insideBottom",offset:-10,fill:"rgba(255,255,255,0.38)",fontSize:10})}),e.jsx(Ie,{type:"number",domain:[0,b],ticks:V,tick:{fill:"rgba(255,255,255,0.48)",fontSize:10},tickLine:!1,axisLine:{stroke:"rgba(255,255,255,0.12)"},width:34,children:e.jsx(le,{value:"AP/h",angle:-90,position:"insideLeft",fill:"rgba(255,255,255,0.38)",fontSize:10,style:{textAnchor:"middle"}})}),e.jsx(Xe,{cursor:{stroke:"rgba(255,255,255,0.18)",strokeDasharray:"3 4"},content:({active:s,payload:l})=>{var d;const m=s?(d=l==null?void 0:l[0])==null?void 0:d.payload:null;return m?e.jsxs("div",{className:"rounded-[16px] border border-white/10 bg-[rgba(10,15,27,0.95)] px-3 py-2 text-xs text-white shadow-[0_18px_50px_rgba(4,8,18,0.3)] backdrop-blur-xl",children:[e.jsx("div",{className:"font-medium text-white",children:m.label}),e.jsx("div",{className:"mt-1 text-white/60",children:O(m.rateApPerHour)})]}):null}}),a===S?e.jsx(ze,{x:F,stroke:"rgba(255,255,255,0.22)",strokeDasharray:"3 4"}):null,e.jsx(Re,{type:"linear",dataKey:"rateApPerHour",stroke:"none",fill:"url(#life-force-chart-fill)",isAnimationActive:!1}),e.jsx(Ye,{type:"linear",dataKey:"rateApPerHour",stroke:"rgba(214,215,255,0.95)",strokeWidth:1.5,dot:!1,activeDot:!1,isAnimationActive:!1})]}),T?e.jsxs("svg",{className:"pointer-events-none absolute inset-0 z-[15] h-full w-full","aria-hidden":"true",children:[e.jsx("line",{x1:T.constrainedX,y1:T.constrainedY,x2:T.pointerX,y2:T.pointerY,stroke:"rgba(214,215,255,0.38)",strokeDasharray:"4 5",strokeWidth:"1.5"}),e.jsx("circle",{cx:T.pointerX,cy:T.pointerY,r:"11",fill:"rgba(214,215,255,0.12)",stroke:"rgba(214,215,255,0.34)",strokeWidth:"1.5","data-testid":"life-force-ghost-handle"}),e.jsx("circle",{cx:T.pointerX,cy:T.pointerY,r:"3.5",fill:"rgba(255,255,255,0.44)"})]}):null,Z.map((s,l)=>{const m=l===0||l===Z.length-1,d=(n==null?void 0:n.index)===l,g=m?14:16,A=m?22:28;return e.jsx("button",{type:"button","aria-label":`Turn point at ${se(s.minuteOfDay)}`,className:K("absolute z-20 flex items-center justify-center rounded-full transition-transform duration-75",s.locked||m?"cursor-not-allowed":"cursor-grab active:cursor-grabbing",d?"scale-110":""),style:{left:s.x-A/2,top:s.y-A/2,width:A,height:A,touchAction:"none"},onPointerDown:h=>{if(h.preventDefault(),h.stopPropagation(),s.locked||m||!f.current)return;"setPointerCapture"in h.currentTarget&&h.currentTarget.setPointerCapture(h.pointerId);const D=f.current.getBoundingClientRect(),X=Number.isFinite(h.clientX)?h.clientX:D.left+s.x,W=Number.isFinite(h.clientY)?h.clientY:D.top+s.y;H({index:l,pointerId:h.pointerId,pointerX:C(X-D.left,0,D.width),pointerY:C(W-D.top,0,D.height)})},onContextMenu:h=>{h.preventDefault(),h.stopPropagation(),Q({index:l,position:{x:h.clientX+6,y:h.clientY+6}})},children:e.jsx("span",{className:K("pointer-events-none inline-flex rounded-full border border-[rgba(10,15,27,0.92)] shadow-[0_0_0_1px_rgba(255,255,255,0.08),0_10px_24px_rgba(4,8,18,0.28)]",s.locked||m?"bg-white/55":"bg-white"),style:{width:g,height:g,opacity:d?.96:1}})},`${s.minuteOfDay}-${l}`)})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-2 px-1 text-[11px] text-white/42",children:[e.jsxs("div",{children:["Editing ",te[a]," curve"]}),e.jsxs("div",{children:[Math.round(o)," AP/day baseline"]})]})]})]}),e.jsx(Se,{open:p!==null,title:"Turn point actions",subtitle:"Delete the turn point or flatten it back onto the surrounding segment.",items:ge,position:(p==null?void 0:p.position)??null,onClose:()=>Q(null)})]})}function et(){return e.jsx(w,{className:"overflow-hidden 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:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Life Force studio"}),e.jsx("div",{className:"mt-2 text-xl font-semibold text-white",children:"Edit weekday curves in the dedicated view"}),e.jsx("div",{className:"mt-2 max-w-3xl text-sm leading-6 text-white/56",children:"The full weekday editor, turn-point menu, and curve calibration now live in their own page so Overview can stay fast and readable."})]}),e.jsxs(Oe,{to:"/life-force",className:"inline-flex min-h-10 min-w-0 max-w-full items-center justify-center gap-2 overflow-hidden whitespace-nowrap rounded-[var(--radius-control)] border border-[var(--primary)]/14 bg-[var(--ui-accent-soft)] px-3 py-2 text-[13px] font-medium text-[var(--ui-ink-on-accent)] shadow-[var(--ui-shadow-soft)] transition hover:bg-[var(--ui-accent-soft-hover)]",children:[e.jsx(me,{className:"size-4"}),"Open Life Force studio"]})]})})}function tt({drains:t,plannedDrains:a,warnings:r,recommendations:o}){return e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)]",children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsxs(w,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Current drains"}),e.jsx("div",{className:"mt-2 text-xl font-semibold text-white",children:"What is consuming Life Force now"})]}),e.jsxs(U,{className:"bg-white/[0.08] text-white/70",children:[t.length," active"]})]}),e.jsx("div",{className:"mt-4 grid gap-3",children:t.length===0?e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-4 text-sm text-white/58",children:"No current drainers are active. This is a good moment to choose your next intentional action."}):t.map(i=>e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-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:"text-base font-semibold text-white",children:i.title}),e.jsx("div",{className:"mt-1 text-sm text-white/54",children:i.why})]}),e.jsxs("div",{className:"shrink-0 text-right",children:[e.jsx("div",{className:"text-base font-semibold text-[var(--primary)]",children:O(i.apPerHour)}),e.jsx("div",{className:"mt-1 text-xs uppercase tracking-[0.14em] text-white/38",children:Ge(i.role)})]})]})},i.id))})]}),e.jsxs(w,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Planned drains"}),e.jsx("div",{className:"mt-2 text-xl font-semibold text-white",children:"What the rest of today is already asking from you"})]}),e.jsxs(U,{className:"bg-white/[0.08] text-white/70",children:[a.length," planned"]})]}),e.jsx("div",{className:"mt-4 grid gap-3",children:a.length===0?e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-4 text-sm text-white/58",children:"No future AP load has been forecast yet. The day is still open."}):a.slice(0,6).map(i=>e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-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:"text-base font-semibold text-white",children:i.title}),e.jsx("div",{className:"mt-1 text-sm text-white/54",children:i.why})]}),e.jsxs("div",{className:"shrink-0 text-right",children:[e.jsx("div",{className:"text-base font-semibold text-[var(--primary)]",children:re(i.instantAp)}),e.jsx("div",{className:"mt-1 text-xs uppercase tracking-[0.14em] text-white/38",children:O(i.apPerHour)})]})]})},i.id))})]})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs(w,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Warnings"}),e.jsx("div",{className:"mt-4 grid gap-3",children:r.map(i=>e.jsxs("div",{className:K("rounded-[18px] px-4 py-4",Qe(i.tone)),children:[e.jsx("div",{className:"text-sm font-semibold",children:i.title}),e.jsx("div",{className:"mt-1 text-sm leading-6 text-current/80",children:i.detail})]},i.id))})]}),e.jsxs(w,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Recommendations"}),e.jsx("div",{className:"mt-4 grid gap-2",children:o.map((i,v)=>e.jsx("div",{className:"rounded-[16px] bg-white/[0.04] px-4 py-3 text-sm leading-6 text-white/66",children:i},`${i}-${v}`))})]})]})]})}function fe({lifeForce:t,onTired:a,onOkayAgain:r,tiredPending:o,okayPending:i,feedback:v}){return e.jsxs(w,{className:"overflow-hidden p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Life Force now"}),e.jsxs("div",{className:"mt-2 text-2xl font-semibold text-white",children:[t.instantFreeApPerHour.toFixed(1)," AP/h free"]}),e.jsxs("div",{className:"mt-2 text-sm text-white/58",children:[Math.round(t.spentTodayAp)," / ",Math.round(t.dailyBudgetAp)," AP used today"]}),e.jsx("div",{className:"mt-2 text-xs uppercase tracking-[0.14em] text-white/38",children:he(t)})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(ee,{variant:"secondary",onClick:a,pending:o,children:[e.jsx(ke,{className:"mr-2 size-4"}),"I'm getting tired"]}),e.jsxs(ee,{variant:"secondary",onClick:r,pending:i,children:[e.jsx(Pe,{className:"mr-2 size-4"}),"I'm okay again"]})]})]}),v?e.jsx("div",{className:"mt-4 rounded-[18px] bg-[var(--primary)]/10 px-4 py-3 text-sm text-white/74",children:v}):null,e.jsxs("div",{className:"mt-4 grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-white",children:[e.jsx(me,{className:"size-4 text-[var(--primary)]"}),"Instant capacity"]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:O(t.instantCapacityApPerHour)})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-white",children:[e.jsx(De,{className:"size-4 text-[var(--primary)]"}),"Current load"]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:O(t.currentDrainApPerHour)}),e.jsx("div",{className:"mt-2 text-xs uppercase tracking-[0.14em] text-white/38",children:t.overloadApPerHour>0?`${O(t.overloadApPerHour)} overload`:"Inside instant limit"})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-white",children:[e.jsx(Me,{className:"size-4 text-[var(--primary)]"}),"Next move"]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:t.recommendations[0]??"Favor the next clean, manageable action."}),e.jsx("div",{className:"mt-2 text-xs uppercase tracking-[0.14em] text-white/38",children:Ve(t)})]})]})]})}function ot({selectedUserIds:t,fallbackLifeForce:a,onRefresh:r,showEditor:o=!0}){var b,G;const i=ue(),v=new Date().getDay(),[y,L]=u.useState(v),P=xe({queryKey:["forge-life-force",...t],queryFn:()=>pe(t),initialData:a===void 0?void 0:{lifeForce:a,templates:te.map((j,V)=>({weekday:V,baselineDailyAp:a.baselineDailyAp,points:a.currentCurve.map(B=>({...B,locked:V===v?B.locked:!1}))}))}}),x=((b=P.data)==null?void 0:b.lifeForce)??a,n=(((G=P.data)==null?void 0:G.templates)??Be(x,v)).find(j=>j.weekday===y)??{weekday:y,baselineDailyAp:x.baselineDailyAp,points:x.currentCurve},[H,E]=u.useState(n.points),[ae,p]=u.useState(!1),[Q,S]=u.useState(null);u.useEffect(()=>{E(n.points),p(!1)},[n.points,n.weekday]);const F=$({mutationFn:j=>Le(n.weekday,{points:$e(j,n.baselineDailyAp)},t),onSuccess:async j=>{await i.invalidateQueries({queryKey:["forge-life-force"]}),await q(i),r&&await r(),E(j.points),p(!1)}}),Y=$({mutationFn:()=>J({signalType:"tired"},t),onSuccess:async()=>{await i.invalidateQueries({queryKey:["forge-life-force"]}),await q(i),r&&await r(),S("Tiredness signal applied. Today’s Life Force now reflects the extra strain.")}}),c=$({mutationFn:()=>J({signalType:"okay_again"},t),onSuccess:async()=>{await i.invalidateQueries({queryKey:["forge-life-force"]}),await q(i),r&&await r(),S("Recovery signal applied. Instant strain has been eased for the rest of today.")}});return e.jsxs("div",{className:"grid gap-4",children:[e.jsx(Ze,{lifeForce:x}),e.jsx(Je,{lifeForce:x}),e.jsx(fe,{lifeForce:x,onTired:()=>{Y.mutateAsync()},onOkayAgain:()=>{c.mutateAsync()},tiredPending:Y.isPending,okayPending:c.isPending,feedback:Q}),o?e.jsx(Ue,{lifeForce:x,weekday:y,points:H,baselineDailyAp:n.baselineDailyAp,isDirty:ae,isSaving:F.isPending,onWeekdayChange:L,onChange:j=>{E(j),p(!0)},onReset:()=>{E(n.points),p(!1)},onSave:()=>{F.mutateAsync(H)}}):e.jsx(et,{}),e.jsx(tt,{drains:x.activeDrains,plannedDrains:x.plannedDrains,warnings:x.warnings,recommendations:x.recommendations}),x.topTaskIdsNeedingSplit.length>0?e.jsxs(w,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-white",children:[e.jsx(Ae,{className:"size-4 text-[var(--primary)]"}),"Tasks asking to be split"]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:x.topTaskIdsNeedingSplit.map(j=>e.jsx(U,{className:"bg-white/[0.08] text-white/74",children:j},j))})]}):null]})}function lt({selectedUserIds:t,fallbackLifeForce:a,onRefresh:r}){var n;const o=Array.isArray(t)?t:[],i=ue(),y=((n=xe({queryKey:["forge-life-force",...o],queryFn:()=>pe(o),initialData:a===void 0?void 0:{lifeForce:a,templates:[]}}).data)==null?void 0:n.lifeForce)??a;if(!y)return e.jsxs(w,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Life Force"}),e.jsx("div",{className:"mt-2 text-lg font-semibold text-white",children:"Not calibrated yet"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:"Today can still load without a Life Force snapshot, but the AP and instant headroom model is not available for this state yet."})]});const[L,P]=u.useState(null),x=$({mutationFn:()=>J({signalType:"tired"},o),onSuccess:async()=>{await i.invalidateQueries({queryKey:["forge-life-force"]}),await q(i),r&&await r(),P("Tiredness signal applied. Today’s headroom has been reduced.")}}),f=$({mutationFn:()=>J({signalType:"okay_again"},o),onSuccess:async()=>{await i.invalidateQueries({queryKey:["forge-life-force"]}),await q(i),r&&await r(),P("Recovery signal applied. Today’s headroom has been eased.")}});return e.jsx(fe,{lifeForce:y,onTired:()=>{x.mutateAsync()},onOkayAgain:()=>{f.mutateAsync()},tiredPending:x.isPending,okayPending:f.isPending,feedback:L})}export{ot as L,lt as a};