forge-openclaw-plugin 0.2.101 → 0.2.103

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 (227) hide show
  1. package/dist/assets/activity-page-Dv6X5ZCV.js +1 -0
  2. package/dist/assets/ai-surface-workspace-CutiG6uS.js +1 -0
  3. package/dist/assets/atlas-panel-jgMRyaHn.js +1 -0
  4. package/dist/assets/{board-BkDRaMp6.js → board-dIX6etHh.js} +1 -1
  5. package/dist/assets/calendar-page-q7Nm5E2U.js +1 -0
  6. package/dist/assets/calendar-rules-DPFsfiRl.js +1 -0
  7. package/dist/assets/calendar-week-toolbar-nVhgB-0s.js +1 -0
  8. package/dist/assets/{charts-P7EVhIog.js → charts-DFnEuIMB.js} +8 -8
  9. package/dist/assets/companion-sync-lab-page-CJ8UTij8.js +1 -0
  10. package/dist/assets/daily-metrics-dashboard-CiJkkkd1.js +1 -0
  11. package/dist/assets/entity-note-count-link-RzBB6ujx.js +1 -0
  12. package/dist/assets/entity-notes-surface-Djz50HvD.js +1 -0
  13. package/dist/assets/execution-board-CtPhI-58.js +1 -0
  14. package/dist/assets/faceted-token-search-DEC6ANa9.js +1 -0
  15. package/dist/assets/flagship-signal-deck-CtHC3mql.js +1 -0
  16. package/dist/assets/floating-action-menu-CKQRhff9.js +1 -0
  17. package/dist/assets/{forms-BFlTgZ3W.js → forms-hB0SqEh-.js} +1 -1
  18. package/dist/assets/goal-detail-page-CF5fNQeR.js +1 -0
  19. package/dist/assets/goals-page-fsY8NzGB.js +1 -0
  20. package/dist/assets/{graph-D6JLqDbD.js → graph-DDUZNRsO.js} +14 -14
  21. package/dist/assets/habits-page-COoGz4kj.js +1 -0
  22. package/dist/assets/index-BAXYM89v.css +1 -0
  23. package/dist/assets/index-EqQsXoat.js +19 -0
  24. package/dist/assets/insight-flow-dialog-DtX_5W7g.js +1 -0
  25. package/dist/assets/insights-page-cBd74ObU.js +8 -0
  26. package/dist/assets/kanban-page-CYav9THw.js +1 -0
  27. package/dist/assets/knowledge-graph-page-D2A-W1jE.js +1 -0
  28. package/dist/assets/{life-force-page-Dy0JTS2G.js → life-force-page-CACGlNhq.js} +1 -1
  29. package/dist/assets/life-force-workspace-BJ4N1I78.js +1 -0
  30. package/dist/assets/{maps-ClgJoCjz.js → maps-C-yOWiDN.js} +1 -1
  31. package/dist/assets/metric-tile-CMadwnGz.js +1 -0
  32. package/dist/assets/{motion-BeD44FeG.js → motion-Lt5B1XuE.js} +1 -1
  33. package/dist/assets/movement-page-D5VqFd2q.js +1 -0
  34. package/dist/assets/note-markdown-BzK2Qlgr.js +3 -0
  35. package/dist/assets/note-tags-input-CZzqJMLc.js +1 -0
  36. package/dist/assets/notes-page-D3Hsh90C.js +1 -0
  37. package/dist/assets/{open-in-graph-button-IXe9SGth.js → open-in-graph-button-BFPKfyK3.js} +1 -1
  38. package/dist/assets/orbit-map-CnyfSmOG.js +1 -0
  39. package/dist/assets/overview-page-CXdWrOV1.js +1 -0
  40. package/dist/assets/page-hero-ffKzgyW3.js +1 -0
  41. package/dist/assets/pill-cluster-C2D0h3lx.js +1 -0
  42. package/dist/assets/{preference-entity-handoff-button-5PzUn42S.js → preference-entity-handoff-button-Dj3V6VxL.js} +1 -1
  43. package/dist/assets/preferences-page-Jo8Gw386.js +1 -0
  44. package/dist/assets/project-collections-qSqp90HN.js +1 -0
  45. package/dist/assets/{project-detail-page-BXK5-4xW.js → project-detail-page-BifhiLQX.js} +1 -1
  46. package/dist/assets/project-management-hierarchy-page-DZ_9klIc.js +1 -0
  47. package/dist/assets/project-management-section-nav-BImLCVvf.js +1 -0
  48. package/dist/assets/projects-page-ptcx6H38.js +1 -0
  49. package/dist/assets/psyche-behaviors-page-BDwXyDta.js +5 -0
  50. package/dist/assets/psyche-flashcards-page-DL1BP1jX.js +1 -0
  51. package/dist/assets/psyche-goal-map-page-ovcpisx1.js +1 -0
  52. package/dist/assets/psyche-graph-EP5GL612.js +1 -0
  53. package/dist/assets/{psyche-metrics-page-CuR9oqEy.js → psyche-metrics-page-Bcu813Rg.js} +1 -1
  54. package/dist/assets/psyche-mode-guide-page-C0g27Xpt.js +1 -0
  55. package/dist/assets/psyche-modes-page-BjKjX5MR.js +1 -0
  56. package/dist/assets/psyche-page-F4tF2W70.js +1 -0
  57. package/dist/assets/psyche-patterns-page-B-14hukK.js +5 -0
  58. package/dist/assets/psyche-questionnaire-builder-page-BdXmoHvK.js +1 -0
  59. package/dist/assets/psyche-questionnaire-detail-page-Cu5uwlJu.js +1 -0
  60. package/dist/assets/psyche-questionnaire-run-detail-page-C3R4PClg.js +1 -0
  61. package/dist/assets/psyche-questionnaire-run-page-Div3iDdt.js +1 -0
  62. package/dist/assets/psyche-questionnaires-page-DpqAPQCp.js +1 -0
  63. package/dist/assets/psyche-report-detail-page-BvWVDKP3.js +3 -0
  64. package/dist/assets/psyche-reports-page-BrbWUlAq.js +1 -0
  65. package/dist/assets/{psyche-schemas-HFmg37Wj.js → psyche-schemas-Dxj554nU.js} +1 -1
  66. package/dist/assets/psyche-schemas-beliefs-page-DYKvAtSD.js +9 -0
  67. package/dist/assets/psyche-screen-time-page-CAOKCyQw.js +1 -0
  68. package/dist/assets/psyche-self-observation-page-F0MVA0UH.js +1 -0
  69. package/dist/assets/psyche-values-page-DyvX-d0o.js +5 -0
  70. package/dist/assets/report-chain-fields-CeC1cJFS.js +1 -0
  71. package/dist/assets/rewards-page-C2loyODo.js +1 -0
  72. package/dist/assets/scheduling-rules-editor-D40AC2jR.js +1 -0
  73. package/dist/assets/schema-badge-FY7818qB.js +1 -0
  74. package/dist/assets/schema-visuals-CvC9a3i6.js +1 -0
  75. package/dist/assets/select-menu-DJsCG6rM.js +1 -0
  76. package/dist/assets/settings-agents-page-BFkJ5AAD.js +6 -0
  77. package/dist/assets/settings-bin-page-D3-Ab-iA.js +1 -0
  78. package/dist/assets/settings-calendar-page-ly_mSTAD.js +5 -0
  79. package/dist/assets/settings-data-page-D7QOqNf-.js +1 -0
  80. package/dist/assets/settings-logs-page-Ca87HEUx.js +1 -0
  81. package/dist/assets/settings-mobile-page-D0jejZot.js +1 -0
  82. package/dist/assets/settings-models-page-DPDsZjSc.js +1 -0
  83. package/dist/assets/settings-page-1cArlSPM.js +1 -0
  84. package/dist/assets/settings-rewards-page-Db4BV1DC.js +1 -0
  85. package/dist/assets/{settings-section-nav-DSOuht_F.js → settings-section-nav-DP9o4peU.js} +1 -1
  86. package/dist/assets/settings-users-page-BHFyDSsd.js +1 -0
  87. package/dist/assets/settings-wiki-page-BNaiupBm.js +1 -0
  88. package/dist/assets/sleep-page-BmOPF0yD.js +1 -0
  89. package/dist/assets/sports-page-BldIiclr.js +1 -0
  90. package/dist/assets/{state-B-4sS1xO.js → state-vCcAT5Hq.js} +1 -1
  91. package/dist/assets/strategies-page-CaTN99qj.js +1 -0
  92. package/dist/assets/strategy-detail-page-DsgFTd-U.js +1 -0
  93. package/dist/assets/strategy-dialog-7X7peRzu.js +1 -0
  94. package/dist/assets/surface-CJI17F3n.js +1 -0
  95. package/dist/assets/{table-WfAPUppN.js → table-BNqMG3_S.js} +1 -1
  96. package/dist/assets/task-detail-page-M1sIIPA8.js +1 -0
  97. package/dist/assets/timebox-planning-dialog-ByojN0AN.js +1 -0
  98. package/dist/assets/today-page-BjDijtn8.js +1 -0
  99. package/dist/assets/training-load-page-BPRmaWmF.js +1 -0
  100. package/dist/assets/{ui-C13Nbgas.js → ui-C1iwpj2-.js} +4 -4
  101. package/dist/assets/use-psyche-focus-target-Ct-acS9G.js +1 -0
  102. package/dist/assets/vendor-Dnkkx2co.js +1067 -0
  103. package/dist/assets/{vitals-page-qre17Nw8.js → vitals-page-CE9zdGLF.js} +1 -1
  104. package/dist/assets/weekly-review-page-CzhTv90n.js +1 -0
  105. package/dist/assets/weight-loss-page-Bp_cIk78.js +5 -0
  106. package/dist/assets/wiki-article-markdown-Dok2uy2p.js +4 -0
  107. package/dist/assets/wiki-editor-page-BuW32Y3f.js +26 -0
  108. package/dist/assets/wiki-ingest-history-page-DZKSBNHV.js +1 -0
  109. package/dist/assets/wiki-ingest-modal-DyqBEZcC.js +1 -0
  110. package/dist/assets/wiki-page-DqxlbLKG.js +1 -0
  111. package/dist/assets/workbench-flow-page-C4nc9jUg.js +5 -0
  112. package/dist/assets/workbench-page-BnyR7SL0.js +1 -0
  113. package/dist/assets/workout-detail-page-DT-c5cHL.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 +125 -33
  118. package/dist/server/server/src/health-weight-loss.js +554 -77
  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 +21 -12
  123. package/dist/server/server/src/repositories/settings.js +19 -5
  124. package/dist/server/src/components/ui/info-tooltip.js +6 -6
  125. package/dist/server/src/components/workbench-boxes/shared/generic-node-view.js +13 -5
  126. package/dist/server/src/lib/api.js +24 -5
  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/activity-page-CpjuNSHw.js +0 -1
  134. package/dist/assets/ai-surface-workspace-DEAFZruS.js +0 -1
  135. package/dist/assets/atlas-panel-CdVNPotj.js +0 -1
  136. package/dist/assets/calendar-page-DNNt6lfz.js +0 -1
  137. package/dist/assets/calendar-rules-DNJFNsxi.js +0 -1
  138. package/dist/assets/calendar-week-toolbar-BbPwYeN0.js +0 -1
  139. package/dist/assets/companion-sync-lab-page-KxEDigM6.js +0 -1
  140. package/dist/assets/daily-metrics-dashboard-B3cqJgDt.js +0 -1
  141. package/dist/assets/entity-note-count-link-DrhjJZ4i.js +0 -1
  142. package/dist/assets/entity-notes-surface-CkcRsKJQ.js +0 -1
  143. package/dist/assets/execution-board-D07gOocB.js +0 -1
  144. package/dist/assets/faceted-token-search-BxRRcM3q.js +0 -1
  145. package/dist/assets/flagship-signal-deck-cmy82b8_.js +0 -1
  146. package/dist/assets/floating-action-menu-Fs_ZiUMo.js +0 -1
  147. package/dist/assets/goal-detail-page-CqLiNz4f.js +0 -1
  148. package/dist/assets/goals-page-BTk7mg_T.js +0 -1
  149. package/dist/assets/habits-page-BJxagdzx.js +0 -1
  150. package/dist/assets/index-CF4J4R9L.js +0 -19
  151. package/dist/assets/index-CZbuZQjw.css +0 -1
  152. package/dist/assets/insight-flow-dialog-8f3D0GuC.js +0 -1
  153. package/dist/assets/insights-page-D6rOa7uk.js +0 -8
  154. package/dist/assets/kanban-page-XQ7Se6dH.js +0 -1
  155. package/dist/assets/knowledge-graph-page-BtAg8iv3.js +0 -1
  156. package/dist/assets/life-force-workspace-OfyB9HJM.js +0 -1
  157. package/dist/assets/metric-tile-DKpo-8xw.js +0 -1
  158. package/dist/assets/movement-page-Bg_T_Stx.js +0 -1
  159. package/dist/assets/note-markdown-N-uxD3Xt.js +0 -3
  160. package/dist/assets/note-tags-input-Cdu7wiw6.js +0 -1
  161. package/dist/assets/notes-page-CKXnF_KU.js +0 -1
  162. package/dist/assets/orbit-map-Dzi6KliQ.js +0 -1
  163. package/dist/assets/overview-page-1miYqaVS.js +0 -1
  164. package/dist/assets/page-hero-DRy5b2MU.js +0 -1
  165. package/dist/assets/pill-cluster-C9QczVJ2.js +0 -1
  166. package/dist/assets/preferences-page-DtNaF5Q3.js +0 -1
  167. package/dist/assets/project-collections-xPz2mlRr.js +0 -1
  168. package/dist/assets/project-management-hierarchy-page-DtRpMABw.js +0 -1
  169. package/dist/assets/project-management-section-nav-P3ixzPa-.js +0 -1
  170. package/dist/assets/projects-page-C5ViRuf4.js +0 -1
  171. package/dist/assets/psyche-behaviors-page-Dco46sC4.js +0 -5
  172. package/dist/assets/psyche-flashcards-page-ZcoEB8gV.js +0 -1
  173. package/dist/assets/psyche-goal-map-page-CLBAQOI0.js +0 -1
  174. package/dist/assets/psyche-graph-k4tX2tdp.js +0 -1
  175. package/dist/assets/psyche-mode-guide-page-hIVXcCnE.js +0 -1
  176. package/dist/assets/psyche-modes-page-0lYtBlhO.js +0 -1
  177. package/dist/assets/psyche-page-VZ9k9ISp.js +0 -1
  178. package/dist/assets/psyche-patterns-page-gx5nmdGq.js +0 -5
  179. package/dist/assets/psyche-questionnaire-builder-page-Bn0TOISd.js +0 -1
  180. package/dist/assets/psyche-questionnaire-detail-page-CmVzSd_s.js +0 -1
  181. package/dist/assets/psyche-questionnaire-run-detail-page-BsMbmXCG.js +0 -1
  182. package/dist/assets/psyche-questionnaire-run-page-CgkRL2vi.js +0 -1
  183. package/dist/assets/psyche-questionnaires-page-D7V8uLXM.js +0 -1
  184. package/dist/assets/psyche-report-detail-page-OlFq57eL.js +0 -3
  185. package/dist/assets/psyche-reports-page-dVUZjna1.js +0 -1
  186. package/dist/assets/psyche-schemas-beliefs-page-BCgc8FUd.js +0 -9
  187. package/dist/assets/psyche-screen-time-page-B_6BT_WN.js +0 -1
  188. package/dist/assets/psyche-self-observation-page-CEG5mluK.js +0 -1
  189. package/dist/assets/psyche-values-page-DRbRfEd6.js +0 -5
  190. package/dist/assets/report-chain-fields-CALCV3V5.js +0 -1
  191. package/dist/assets/rewards-page-DmC4R_Ps.js +0 -1
  192. package/dist/assets/scheduling-rules-editor-D02s70hr.js +0 -1
  193. package/dist/assets/schema-badge-BZO-qNhO.js +0 -1
  194. package/dist/assets/schema-visuals-D6nxjbYC.js +0 -1
  195. package/dist/assets/select-menu-fYyreSdQ.js +0 -1
  196. package/dist/assets/settings-agents-page-C_v_hMJF.js +0 -6
  197. package/dist/assets/settings-bin-page-DY5bg81n.js +0 -1
  198. package/dist/assets/settings-calendar-page-D1CzE6cg.js +0 -5
  199. package/dist/assets/settings-data-page-CHRQFU9H.js +0 -1
  200. package/dist/assets/settings-logs-page-B04pUwEv.js +0 -1
  201. package/dist/assets/settings-mobile-page-D9kTlYDS.js +0 -1
  202. package/dist/assets/settings-models-page-D26270R2.js +0 -1
  203. package/dist/assets/settings-page-DYDTFlnv.js +0 -1
  204. package/dist/assets/settings-rewards-page-cl4vqqO_.js +0 -1
  205. package/dist/assets/settings-users-page-BU79JB_T.js +0 -1
  206. package/dist/assets/settings-wiki-page-DwAUlyA3.js +0 -1
  207. package/dist/assets/sleep-page-D8NbdhyS.js +0 -1
  208. package/dist/assets/sports-page-CV4Cnzwn.js +0 -1
  209. package/dist/assets/strategies-page-C4qvXnql.js +0 -1
  210. package/dist/assets/strategy-detail-page-DJLo5rfy.js +0 -1
  211. package/dist/assets/strategy-dialog-D3AuUlVz.js +0 -1
  212. package/dist/assets/task-detail-page-z-9u9rF0.js +0 -1
  213. package/dist/assets/timebox-planning-dialog-DB6FLqmI.js +0 -1
  214. package/dist/assets/today-page-BKlu6gx5.js +0 -1
  215. package/dist/assets/training-load-page-CyJQqo_3.js +0 -1
  216. package/dist/assets/use-psyche-focus-target-C1C_XjYG.js +0 -1
  217. package/dist/assets/vendor-DHkYh85p.js +0 -1052
  218. package/dist/assets/weekly-review-page-Cz4vkRcx.js +0 -1
  219. package/dist/assets/weight-loss-page-BQrnOI0y.js +0 -1
  220. package/dist/assets/wiki-article-markdown-DdiR2TJE.js +0 -4
  221. package/dist/assets/wiki-editor-page-DqwoqVFb.js +0 -26
  222. package/dist/assets/wiki-ingest-history-page--evBLbOw.js +0 -1
  223. package/dist/assets/wiki-ingest-modal--ohzFnj2.js +0 -1
  224. package/dist/assets/wiki-page-B_VJFBPA.js +0 -1
  225. package/dist/assets/workbench-flow-page-Du62mtJU.js +0 -5
  226. package/dist/assets/workbench-page-4MKr3iRm.js +0 -1
  227. package/dist/assets/workout-detail-page-DfUbYYw1.js +0 -2
@@ -1 +0,0 @@
1
- import{r as i,j as r}from"./vendor-DHkYh85p.js";import{Q as N,cR as W,F as m,I as w,b as x,ah as f,j as v,T as p}from"./index-CF4J4R9L.js";function u(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:c,lockedEntity:h,entityCandidates:d=[],onSubmit:F}){const[s,l]=i.useState(()=>u(c,h)),[S,g]=i.useState(null);i.useEffect(()=>{e&&(l(u(c,h)),g(null))},[c,h,e]);const b=i.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)=>r.jsxs(r.Fragment,{children:[r.jsx(m,{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:r.jsx(w,{value:o.title,onChange:t=>n({title:t.target.value}),placeholder:"Weekly review needs a tighter end ritual"})}),r.jsx(m,{label:"Timeframe",description:"Keep the horizon short and readable.",children:r.jsx(w,{value:o.timeframeLabel,onChange:t=>n({timeframeLabel:t.target.value}),placeholder:"This week"})}),r.jsx(m,{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?r.jsxs("div",{className:"rounded-[24px] border border-white/8 bg-white/[0.04] p-4",children:[r.jsx(x,{kind:h.kind,label:h.label}),h.description?r.jsx(f,{className:"mt-2",children:h.description}):null]}):r.jsxs(r.Fragment,{children:[r.jsx(v,{value:o.targetKind,onChange:t=>n({targetKind:t,entityType:t==="general"?"":t,entityId:""}),options:b.map(t=>({value:t,label:t==="general"?"General insight":t==="trigger_report"?"Report":t.charAt(0).toUpperCase()+t.slice(1),description:t==="general"?"Store it in the broader insight feed.":`Attach it to a specific ${t==="trigger_report"?"report":t}.`})),columns:b.length>=3?3:2}),o.targetKind!=="general"?y.length>0?r.jsx("div",{className:"mt-4 grid gap-3 md:grid-cols-2",children:y.map(t=>{const A=o.entityType===t.entityType&&o.entityId===t.entityId;return r.jsxs("button",{type:"button",className:`rounded-[22px] border px-4 py-4 text-left transition ${A?"border-[rgba(192,193,255,0.28)] bg-[rgba(192,193,255,0.14)] text-white":"border-white/8 bg-white/[0.04] text-white/72 hover:bg-white/[0.07]"}`,onClick:()=>n({entityType:t.entityType,entityId:t.entityId}),children:[r.jsx(x,{kind:t.kind,label:t.label,compact:!0}),t.description?r.jsx("div",{className:"mt-2 text-sm leading-6 text-white/54",children:t.description}):null]},`${t.entityType}:${t.entityId}`)})}):r.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)=>r.jsxs(r.Fragment,{children:[r.jsx(m,{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:r.jsx(p,{value:o.summary,onChange:t=>n({summary:t.target.value}),placeholder:"The weekly review loses energy because the close-out is vague, so finished work never turns into clear next moves."})}),r.jsx(m,{label:"Why this matters",description:"Optional context that helps explain the recommendation.",children:r.jsx(p,{value:o.rationale,onChange:t=>n({rationale:t.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)=>r.jsxs(r.Fragment,{children:[r.jsx(m,{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:r.jsx(p,{value:o.recommendation,onChange:t=>n({recommendation:t.target.value}),placeholder:"Add a fixed five-minute close-out block that turns finished tasks into one sentence of evidence and one next move."})}),r.jsx(m,{label:"Confidence",description:"Choose how strongly this recommendation holds up right now.",children:r.jsx(v,{value:String(o.confidence),onChange:t=>n({confidence:Number(t)}),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 r.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()=>{g(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){g("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){g(n instanceof Error?n.message:"Unable to store this insight right now.")}}})}export{$ as I};
@@ -1,8 +0,0 @@
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-CF4J4R9L.js";import{I as ge}from"./insight-flow-dialog-8f3D0GuC.js";import{P as xe}from"./page-hero-DRy5b2MU.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(`
2
-
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
-
5
- Recommendation: ${t.recommendation.trim()}`.trim()}}function Fe(t){return{...Ie,title:K(t.title,t.recommendation),description:`${t.summary.trim()}
6
-
7
- Recommendation: ${t.recommendation.trim()}`.trim()}}function Pe(t){return[`## ${t.title.trim()}`,"",t.summary.trim(),"","### Recommendation","",t.recommendation.trim(),t.rationale.trim()?"":null,t.rationale.trim()?"### Why this matters":null,t.rationale.trim()||null].filter(o=>!!o).join(`
8
- `)}function q(t,o,a,r){return{kind:Ae(t,o,a),task:Se(t,a,r),project:Ee(t,o,a,r),goal:Fe(t),noteMarkdown:Pe(t)}}function De(t){switch(t){case"task":return{label:"Task",description:"Turn the recommendation into one concrete next move."};case"project":return{label:"Project",description:"Start a larger initiative when the insight needs a stream of work."};case"goal":return{label:"Goal",description:"Capture a new long-term direction when this changes strategy."};case"note":return{label:"Linked note",description:"Attach the recommendation as durable evidence without creating new work."}}}function Me({open:t,onOpenChange:o,insight:a,goals:r,projects:d,tasks:h,tags:y,pending:b=!1,onSubmit:j}){const k=w.useMemo(()=>B(a,r,d),[r,a,d]),m=w.useMemo(()=>G(a),[a]),[p,T]=w.useState(()=>q(a,r,d,h)),[A,u]=w.useState(null),[v,C]=w.useState({});w.useEffect(()=>{t&&(T(q(a,r,d,h)),u(null),C({}))},[r,a,t,d,h]);const S=p.task.projectId?d.find(s=>s.id===p.task.projectId)??null:null;w.useEffect(()=>{S&&p.task.goalId!==S.goalId&&T(s=>({...s,task:{...s.task,goalId:S.goalId}}))},[p.task.goalId,S]);const P=p.project.goalId?r.find(s=>s.id===p.project.goalId)??null:null,N=w.useMemo(()=>{var s,l,n;if(!m)return null;switch(m.entityType){case"goal":return((s=r.find(i=>i.id===m.entityId))==null?void 0:s.title)??"Linked goal";case"project":return((l=d.find(i=>i.id===m.entityId))==null?void 0:l.title)??"Linked project";case"task":return((n=h.find(i=>i.id===m.entityId))==null?void 0:n.title)??"Linked task";default:return`${m.entityType.replaceAll("_"," ")}`}},[r,d,m,h]),D=[{id:"kind",eyebrow:"Apply",title:"Choose what this insight should become",description:"Accept means you agree with the recommendation. Apply means you turn it into a real record right now.",render:(s,l)=>e.jsx(f,{label:"Apply as",description:"Pick the kind of record Forge should create from this recommendation.",hint:"Task is the best default when the insight points to a concrete next move.",children:e.jsx(Z,{value:s.kind,onChange:n=>l({kind:n}),options:k.map(n=>({value:n,...De(n)})),columns:k.length>=3?3:2})})},{id:"details",eyebrow:"Details",title:"Review the record Forge will create",description:"The fields are prefilled from the insight, but you can tighten them before saving.",render:(s,l)=>s.kind==="task"?e.jsxs(e.Fragment,{children:[e.jsx(f,{label:"Task title",error:v.title??null,children:e.jsx(_,{value:s.task.title,onChange:n=>l({task:{...s.task,title:n.target.value}}),placeholder:"Turn the recommendation into a task"})}),e.jsx(f,{label:"Description",children:e.jsx(L,{value:s.task.description,onChange:n=>l({task:{...s.task,description:n.target.value}}),placeholder:"Add the operational context for this task."})}),e.jsx(f,{label:"Project",error:v.projectId??null,children:e.jsx("div",{className:"grid gap-3",children:d.map(n=>{const i=n.id===s.task.projectId;return e.jsxs("button",{type:"button",className:`rounded-[22px] border px-4 py-4 text-left transition ${i?"border-[rgba(192,193,255,0.28)] bg-[rgba(192,193,255,0.14)] text-white":"border-white/8 bg-white/[0.04] text-white/72 hover:bg-white/[0.07]"}`,onClick:()=>l({task:{...s.task,projectId:n.id,goalId:n.goalId}}),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"font-medium",children:n.title}),e.jsx(ee,{kind:"goal",label:n.goalTitle,compact:!0,gradient:!1})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/54",children:n.description||"No project note attached yet."})]},n.id)})})}),e.jsx(f,{label:"Owner",error:v.owner??null,children:e.jsx(_,{value:s.task.owner,onChange:n=>l({task:{...s.task,owner:n.target.value}}),placeholder:"Albert"})}),e.jsx(f,{label:"Tags",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:y.map(n=>{const i=s.task.tagIds.includes(n.id);return e.jsx("button",{type:"button",className:`rounded-full px-3 py-2 text-sm transition ${i?"bg-white/16 text-white":"bg-white/6 text-white/58 hover:bg-white/10 hover:text-white"}`,onClick:()=>l({task:{...s.task,tagIds:i?s.task.tagIds.filter(c=>c!==n.id):[...s.task.tagIds,n.id]}}),children:n.name},n.id)})})})]}):s.kind==="project"?e.jsxs(e.Fragment,{children:[e.jsx(f,{label:"Project title",error:v.title??null,children:e.jsx(_,{value:s.project.title,onChange:n=>l({project:{...s.project,title:n.target.value}}),placeholder:"Turn the insight into a project"})}),e.jsx(f,{label:"Description",children:e.jsx(L,{value:s.project.description,onChange:n=>l({project:{...s.project,description:n.target.value}}),placeholder:"Describe the initiative this insight points to."})}),e.jsx(f,{label:"Goal",error:v.goalId??null,children:e.jsx("div",{className:"grid gap-3",children:r.map(n=>{const i=n.id===s.project.goalId;return e.jsxs("button",{type:"button",className:`rounded-[22px] border px-4 py-4 text-left transition ${i?"border-[rgba(192,193,255,0.28)] bg-[rgba(192,193,255,0.14)] text-white":"border-white/8 bg-white/[0.04] text-white/72 hover:bg-white/[0.07]"}`,onClick:()=>l({project:{...s.project,goalId:n.id}}),children:[e.jsx("div",{className:"font-medium",children:n.title}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/54",children:n.description||"No strategic note attached yet."})]},n.id)})})}),P?e.jsxs(te,{children:["This project will sit under the “",P.title,"” goal."]}):null]}):s.kind==="goal"?e.jsxs(e.Fragment,{children:[e.jsx(f,{label:"Goal title",error:v.title??null,children:e.jsx(_,{value:s.goal.title,onChange:n=>l({goal:{...s.goal,title:n.target.value}}),placeholder:"Turn the insight into a life goal"})}),e.jsx(f,{label:"Description",children:e.jsx(L,{value:s.goal.description,onChange:n=>l({goal:{...s.goal,description:n.target.value}}),placeholder:"Describe the strategic direction this insight suggests."})}),e.jsx(f,{label:"Tags",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:y.map(n=>{const i=s.goal.tagIds.includes(n.id);return e.jsx("button",{type:"button",className:`rounded-full px-3 py-2 text-sm transition ${i?"bg-white/16 text-white":"bg-white/6 text-white/58 hover:bg-white/10 hover:text-white"}`,onClick:()=>l({goal:{...s.goal,tagIds:i?s.goal.tagIds.filter(c=>c!==n.id):[...s.goal.tagIds,n.id]}}),children:n.name},n.id)})})})]}):e.jsxs(e.Fragment,{children:[e.jsx(f,{label:"Linked note",description:"This stores the insight as durable Markdown evidence on the linked entity instead of creating a new work item.",hint:N?`This note will attach to ${N}.`:void 0,children:e.jsx(L,{value:s.noteMarkdown,onChange:n=>l({noteMarkdown:n.target.value}),placeholder:"Write the applied note content in Markdown",className:"min-h-64"})}),N?e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.04] px-4 py-3 text-sm text-white/70",children:["Linked target:"," ",e.jsx("span",{className:"font-medium text-white",children:N})]}):null]})}];return e.jsx(H,{open:t,onOpenChange:o,eyebrow:"Apply insight",title:"Turn this insight into a real record",description:"Apply should create something concrete inside Forge, not just change the status label.",value:p,onChange:T,draftPersistenceKey:"insights.apply",steps:D,submitLabel:"Apply insight",pending:b,error:A,onSubmit:async()=>{u(null),C({});try{if(p.kind==="task"){const s=Y.safeParse(p.task);if(!s.success){C(Object.fromEntries(Object.entries(s.error.flatten().fieldErrors).map(([l,n])=>[l,n==null?void 0:n[0]]))),u("This applied task still needs a valid title, project, and owner.");return}await j({kind:"task",input:s.data}),o(!1);return}if(p.kind==="project"){const s=V.safeParse(p.project);if(!s.success){C(Object.fromEntries(Object.entries(s.error.flatten().fieldErrors).map(([l,n])=>[l,n==null?void 0:n[0]]))),u("This applied project still needs a valid title and goal.");return}await j({kind:"project",input:s.data}),o(!1);return}if(p.kind==="goal"){const s=J.safeParse(p.goal);if(!s.success){C(Object.fromEntries(Object.entries(s.error.flatten().fieldErrors).map(([l,n])=>[l,n==null?void 0:n[0]]))),u("This applied goal still needs a valid title and target.");return}await j({kind:"goal",input:s.data}),o(!1);return}if(!p.noteMarkdown.trim()){u("The linked note needs Markdown content before it can be saved.");return}if(!m){u("This insight is not attached to a specific entity yet, so Forge cannot place a linked note for it.");return}await j({kind:"note",input:{contentMarkdown:p.noteMarkdown.trim()}}),o(!1)}catch(s){u(s instanceof Error?s.message:"Unable to apply this insight right now.")}}})}function We(){var D,s,l,n;const t=z(),o=W(),a=ie(),r=Array.isArray(a.selectedUserIds)?a.selectedUserIds:[],{snapshot:d}=a,[h,y]=w.useState(!1),[b,j]=w.useState(null),k=X({queryKey:["forge-insights",...r],queryFn:()=>me(r)}),m=M({mutationFn:ne,onSuccess:async()=>{await t.invalidateQueries({queryKey:["forge-insights"]})}}),p=M({mutationFn:({insightId:i,feedbackType:c})=>U(i,c),onSuccess:async()=>{await t.invalidateQueries({queryKey:["forge-insights"]})}}),T=M({mutationFn:({insightId:i})=>se(i),onMutate:async({insightId:i})=>{await t.cancelQueries({queryKey:["forge-insights"]});const c=t.getQueryData(["forge-insights"]);if(c){const g=c.insights.feed.find(I=>I.id===i);t.setQueryData(["forge-insights"],{insights:{...c.insights,feed:c.insights.feed.filter(I=>I.id!==i),openCount:(g==null?void 0:g.status)==="open"?Math.max(0,c.insights.openCount-1):c.insights.openCount}})}return{previous:c}},onError:(i,c,g)=>{g!=null&&g.previous&&t.setQueryData(["forge-insights"],g.previous)},onSettled:async()=>{await t.invalidateQueries({queryKey:["forge-insights"]})}}),A=M({mutationFn:async({insight:i,submission:c})=>{let g=null,I="Applied the insight.";if(c.kind==="task"){const x=await ae(c.input);g=`/tasks/${x.task.id}`,I=`Created task: ${x.task.title}`}else if(c.kind==="project"){const x=await oe(c.input);g=`/projects/${x.project.id}`,I=`Created project: ${x.project.title}`}else if(c.kind==="goal"){const x=await de(c.input);g=`/goals/${x.goal.id}`,I=`Created goal: ${x.goal.title}`}else{const x=G(i);if(!x)throw new Error("This insight is not linked to a concrete entity yet, so Forge cannot attach a linked note to it.");await le({contentMarkdown:c.input.contentMarkdown,links:[x]}),g=ce(x.entityType,x.entityId),I="Created a linked note from the insight."}return await U(i.id,"applied",I),{href:g}},onSuccess:async({href:i})=>{await Promise.all([t.invalidateQueries({queryKey:["forge-insights"]}),re(t),t.invalidateQueries({queryKey:["forge-xp-metrics"]}),t.invalidateQueries({queryKey:["forge-reward-ledger"]}),t.invalidateQueries({queryKey:["notes-index"]})]),j(null),i&&o(i)}}),u=(D=k.data)==null?void 0:D.insights,v=w.useMemo(()=>[...d.goals.slice(0,8).map(i=>({entityType:"goal",entityId:i.id,kind:"goal",label:i.title,description:i.description})),...d.projects.slice(0,8).map(i=>({entityType:"project",entityId:i.id,kind:"project",label:i.title,description:i.goalTitle})),...d.tasks.slice(0,10).map(i=>({entityType:"task",entityId:i.id,kind:"task",label:i.title,description:i.status.replaceAll("_"," ")}))],[d.goals,d.projects,d.tasks]),C=p.isPending?((s=p.variables)==null?void 0:s.insightId)??null:null,S=T.isPending?((l=T.variables)==null?void 0:l.insightId)??null:null,P=A.isPending?((n=A.variables)==null?void 0:n.insight.id)??null:null,N=d.metrics.topGoalId?d.goals.find(i=>i.id===d.metrics.topGoalId)??null:null;return k.isLoading?e.jsx(pe,{eyebrow:"Insights",title:"Loading the insight feed",description:"Pulling coaching, momentum analysis, and stored recommendations."}):k.isError||!u?e.jsx(ue,{eyebrow:"Insights",error:k.error,onRetry:()=>void t.invalidateQueries({queryKey:["forge-insights"]})}):e.jsxs("div",{className:"grid gap-5",children:[e.jsx(xe,{title:"Insights",description:"Save useful advice from you or your agent, review what seems worth acting on, and turn the good ones into real work when the timing is right.",badge:`${u.openCount} open`,actions:e.jsx(E,{onClick:()=>y(!0),children:"Store insight"})}),e.jsxs("section",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.1fr)_minmax(0,0.9fr)]",children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(F,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Momentum analysis"}),e.jsx("div",{className:"mt-4 grid grid-cols-5 gap-2 sm:grid-cols-10",children:u.momentumHeatmap.map(i=>e.jsxs("div",{className:"rounded-[16px] bg-white/[0.04] p-3",children:[e.jsx("div",{className:"h-12 rounded-[12px]",style:{background:i.intensity>=4?"rgba(192,193,255,0.95)":i.intensity===3?"rgba(192,193,255,0.7)":i.intensity===2?"rgba(192,193,255,0.45)":i.intensity===1?"rgba(192,193,255,0.2)":"rgba(255,255,255,0.05)"}}),e.jsx("div",{className:"mt-2 text-[10px] uppercase tracking-[0.16em] text-white/40",children:i.label})]},i.id))})]}),e.jsxs(F,{children:[e.jsxs("div",{className:"flex items-center gap-2 font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:[e.jsx("span",{children:"Execution trends"}),e.jsx($,{content:"The lavender series tracks completed XP by time window. The green series tracks execution pressure from focused and completed work. Read them together to see whether visible output and active work are moving in sync.",label:"Explain execution trends"})]}),e.jsx("div",{className:"mt-4 h-72 min-w-0",children:e.jsx(fe,{width:"100%",height:"100%",minWidth:280,minHeight:288,children:e.jsxs(ye,{data:u.executionTrends,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"insight-xp",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#c0c1ff",stopOpacity:"0.8"}),e.jsx("stop",{offset:"100%",stopColor:"#c0c1ff",stopOpacity:"0.08"})]})}),e.jsx(je,{dataKey:"label",tick:{fill:"rgba(255,255,255,0.42)",fontSize:11}}),e.jsx(we,{hide:!0}),e.jsx(R,{dataKey:"xp",stroke:"#c0c1ff",fill:"url(#insight-xp)",strokeWidth:2}),e.jsx(R,{dataKey:"focusScore",stroke:"#4edea3",fill:"rgba(78,222,163,0.06)",strokeWidth:2})]})})}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-3",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-white/[0.04] px-3 py-2 text-sm text-white/64",children:[e.jsx("span",{className:"size-2.5 rounded-full bg-[#c0c1ff]"}),e.jsx("span",{children:"Completed XP"}),e.jsx($,{content:"Completed XP is the reward Forge logged for finished work in each time window. It helps you see whether things are actually getting finished, not just started.",label:"Explain completed XP"})]}),e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-white/[0.04] px-3 py-2 text-sm text-white/64",children:[e.jsx("span",{className:"size-2.5 rounded-full bg-[#4edea3]"}),e.jsx("span",{children:"Focus score"}),e.jsx($,{content:"Focus score is Forge's rough read of how much active execution pressure was present in each window, based on focused and completed work.",label:"Explain focus score"})]})]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/54",children:"Use this chart to spot whether finished output and active deep-work pressure are rising together or starting to drift apart."})]}),e.jsxs(F,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"bg-white/[0.08] text-white/60",children:"Deterministic coaching"}),e.jsx($,{content:"This is Forge's built-in coaching read. It looks at your overdue work, blocked work, current goal pressure, and recent evidence to produce one grounded recommendation from the actual operating record.",label:"Explain deterministic coaching"})]}),e.jsx("h2",{className:"mt-4 font-display text-4xl text-white",children:u.coaching.title}),e.jsx("p",{className:"mt-4 text-sm leading-7 text-white/60",children:"Forge turns the current state of your goals, projects, tasks, and recent evidence into one focused operating read instead of a vague motivational hint."}),e.jsxs("div",{className:"mt-4 rounded-[18px] border border-white/8 bg-white/[0.04] px-4 py-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Current read"}),e.jsx("div",{className:"mt-2 text-sm leading-7 text-white/72",children:u.coaching.summary})]}),e.jsxs("div",{className:"mt-4 rounded-[22px] bg-[radial-gradient(circle_at_top_left,rgba(192,193,255,0.14),transparent_45%),rgba(255,255,255,0.03)] p-5",children:[e.jsx("div",{className:"font-medium text-white",children:"Recommendation"}),e.jsx("div",{className:"mt-2 text-sm leading-7 text-white/60",children:u.coaching.recommendation}),N?e.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"rounded-full bg-white/[0.06] px-3 py-2 text-sm text-white/64",children:["Connected goal: ",e.jsx("span",{className:"font-medium text-white",children:N.title})]}),e.jsx(E,{variant:"secondary",size:"sm",onClick:()=>o(`/goals/${N.id}`),children:"Open goal"})]}):null]})]})]}),e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(F,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Store insight"}),e.jsxs("div",{className:"mt-4 rounded-[22px] bg-white/[0.04] p-5",children:[e.jsx("div",{className:"font-medium text-white",children:"Capture advice without forcing it into a task too early"}),e.jsx("div",{className:"mt-2 text-sm leading-7 text-white/60",children:"Insights are saved suggestions from you or your agent. Use them when something feels worth remembering, but it is not ready to become a goal, project, or task yet."}),e.jsx("div",{className:"mt-4",children:e.jsx(E,{onClick:()=>y(!0),children:"Store insight"})})]})]}),e.jsxs(F,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Stored insights"}),e.jsx("div",{className:"mt-4 grid gap-3",children:u.feed.length===0?e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] p-4 text-sm text-white/55",children:"No stored insights yet."}):u.feed.map(i=>e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-white",children:i.title}),e.jsx("div",{className:"mt-1 text-sm text-white/56",children:i.summary}),i.user?e.jsx("div",{className:"mt-3",children:e.jsx(he,{user:i.user,compact:!0})}):null]}),e.jsx(Q,{className:"text-white/70",children:i.status})]}),e.jsx("div",{className:"mt-3 text-sm text-white/58",children:i.recommendation}),e.jsxs("div",{className:"mt-3 text-xs uppercase tracking-[0.16em] text-white/38",children:[i.originLabel??i.originType," · confidence ",Math.round(i.confidence*100),"%"]}),i.status==="applied"?e.jsx("div",{className:"mt-4 rounded-[16px] border border-emerald-400/18 bg-emerald-400/8 px-4 py-3 text-sm text-emerald-100/88",children:"This insight has already been turned into a real Forge record, so it stays here as a trace of what happened."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-4 text-sm text-white/52",children:i.status==="accepted"?"Accepted means this feels useful and worth keeping in view. Apply turns it into a real goal, project, task, or note when you are ready.":"Accept keeps this advice on the board. Apply turns it into a real Forge record now. Dismiss deletes it from the list."}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[i.status!=="accepted"?e.jsx(E,{variant:"secondary",pending:C===i.id,onClick:()=>void p.mutateAsync({insightId:i.id,feedbackType:"accepted"}),children:"Accept"}):null,e.jsx(E,{pending:P===i.id,onClick:()=>j(i),children:"Apply"}),e.jsx(E,{variant:"ghost",pending:S===i.id,onClick:()=>void T.mutateAsync({insightId:i.id}),children:"Dismiss"})]})]})]},i.id))})]})]})]}),e.jsx(ge,{open:h,onOpenChange:y,entityCandidates:v,pending:m.isPending,onSubmit:async i=>{await m.mutateAsync(i)}}),b?e.jsx(Me,{open:!!b,onOpenChange:i=>{i||j(null)},insight:b,goals:d.goals,projects:d.projects,tasks:d.tasks,tags:d.tags,pending:A.isPending,onSubmit:async i=>{await A.mutateAsync({insight:b,submission:i})}}):null]})}export{We as InsightsPage};
@@ -1 +0,0 @@
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-CF4J4R9L.js";import{E as Je}from"./execution-board-D07gOocB.js";import{P as Ze}from"./project-management-section-nav-P3ixzPa-.js";import{P as xe}from"./page-hero-DRy5b2MU.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-DrhjJZ4i.js";import"./floating-action-menu-Fs_ZiUMo.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 +0,0 @@
1
- import{r as p,j as r,b5 as Wt,c2 as Ut,cg as qt,cl as Qt,cm as ct,bf as lt,b4 as Jt,cn as Zt,co as er,cp as tr}from"./vendor-DHkYh85p.js";import{R as rr,P as nr,O as ar,C as sr,T as ir,D as or,a as ut}from"./ui-C13Nbgas.js";import{i as cr}from"./state-B-4sS1xO.js";import{aA as lr,aB as ur,aC as dr,aD as at,aE as $e,aF as jt,aG as st,aH as Mt,aI as Gt,aJ as hr,aK as it,aL as ot,aM as pr,aN as gr,b as et,V as fr,u as mr,aO as xr,aP as dt,aQ as br,L as wr,E as yr,aR as vr,U as ht,a8 as Nr,B as q,m as Se,I as qe,aS as pt,aT as Sr,aU as _r,aV as gt,ap as Cr,aW as Er}from"./index-CF4J4R9L.js";import{S as Rr,G as jr,i as Mr,C as Gr,B as Fr,M as kr}from"./graph-D6JLqDbD.js";import{F as ft}from"./faceted-token-search-BxRRcM3q.js";import{A as Ir,m as Kr}from"./motion-BeD44FeG.js";import"./board-BkDRaMp6.js";import"./forms-BFlTgZ3W.js";const Or=Math.PI*(3-Math.sqrt(5)),Ar=.48;function Ye(t,n,a){return Math.min(a,Math.max(n,t))}function Pr({positions:t,point:n}){const a=[...t.values()];if(a.length===0)return{x:.5,y:.5};let s=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY;for(const v of a)s=Math.min(s,v.x),c=Math.max(c,v.x),o=Math.min(o,v.y),l=Math.max(l,v.y);const u=Math.max(c-s,0),i=Math.max(l-o,0),m=Math.max(u,i,1),f=(1-u/m)/2,w=(1-i/m)/2,F=u||1,g=i||1;return{x:Ye((n.x-s)/F*(u/m)+f,0,1),y:Ye((n.y-o)/g*(i/m)+w,0,1)}}function Dr(t){let n=2166136261;for(let a=0;a<t.length;a+=1)n^=t.charCodeAt(a),n=Math.imul(n,16777619);return n>>>0}function Tr({nodes:t,cache:n}){const a=new Map,s=[...t].sort((u,i)=>i.importance-u.importance||u.title.localeCompare(i.title)||u.id.localeCompare(i.id));let c=0,o=0,l=0;if(s.forEach((u,i)=>{const m=n.get(u.id);if(m){a.set(u.id,m),c+=m.x,o+=m.y,l+=1;return}const f=(Dr(u.id)%1e3/1e3-.5)*.22,w=i*Or+f,F=Ar*Math.sqrt(i+1),g={x:Math.cos(w)*F,y:Math.sin(w)*F};a.set(u.id,g),c+=g.x,o+=g.y,l+=1}),l>0){const u=c/l,i=o/l;a.forEach((m,f)=>{a.set(f,{x:m.x-u,y:m.y-i})})}return a}function zr(t,n){if(t.startsWith("rgb(")&&t.endsWith(")"))return t.replace("rgb(","rgba(").replace(")",`, ${n})`);if(t.startsWith("#")){const a=t.slice(1),s=a.length===3?a.split("").map(u=>`${u}${u}`).join(""):a,c=parseInt(s.slice(0,2),16),o=parseInt(s.slice(2,4),16),l=parseInt(s.slice(4,6),16);return`rgba(${c}, ${o}, ${l}, ${n})`}return t}function Ge(t,n){return`rgba(${t==="structural"?"125, 211, 252":t==="contextual"?"45, 212, 191":t==="taxonomy"?"192, 132, 252":t==="workspace"?"251, 191, 36":"148, 163, 184"}, ${n})`}function mt(t,n){return!n.focusNodeId||t===n.focusNodeId?0:n.detailNodeIds.has(t)?1:n.relatedNodeIds.has(t)?2:3}function Lr({nodeId:t,attributes:n,node:a,focusNodeId:s,relatedNodeIds:c,detailNodeIds:o,hoveredNodeId:l,draggedNodeId:u}){const i=s===t,m=c.has(t),f=o.has(t),w=l===t,F=u===t,g=!s||m,v=n.color;return{...n,label:i||w||F||f?a.title:"",forceLabel:i||w||F||f,highlighted:i||w||F||f,color:g?v:zr(v,.34),size:F?n.size*2:i?n.size*1.8:w?n.size*1.35:f?n.size*1.16:m?n.size*1.06:n.size,zIndex:F?4:i?3:f||w?2:1}}function $r({attributes:t,edge:n,focusNodeId:a,detailNodeIds:s,relatedNodeIds:c,hoveredNodeId:o}){const l=!!a&&(n.source===a||n.target===a),u=!!o&&(n.source===o||n.target===o),i={focusNodeId:a,detailNodeIds:s,relatedNodeIds:c},m=a?Math.max(mt(n.source,i),mt(n.target,i)):0,f=l?Ge(n.family,.24):u?Ge(n.family,.14):a?m<=1?Ge(n.family,.09):m===2?Ge(n.family,.05):Ge(n.family,.016):Ge(n.family,.055);return{...t,color:f,size:l?t.size*1.18:u?t.size*1.08:t.size,zIndex:l?2:u?1:0}}function xt(t,n){const a=new Set,s=new Set;for(const c of t)c.source===n?a.add(c.target):c.target===n&&a.add(c.source);for(const c of t)c.source!==n&&a.has(c.source)&&s.add(c.target),c.target!==n&&a.has(c.target)&&s.add(c.source);return s.delete(n),a.forEach(c=>s.delete(c)),{firstRing:[...a].sort(),secondRing:[...s].sort()}}function bt(t,n,a){if(!a)return t.map(()=>-1);const s=new Set(t);if(!s.has(a))return t.map(()=>-1);const c=new Map;for(const u of n){if(!s.has(u.source)||!s.has(u.target))continue;const i=c.get(u.source)??new Set;i.add(u.target),c.set(u.source,i);const m=c.get(u.target)??new Set;m.add(u.source),c.set(u.target,m)}const o=new Map([[a,0]]);let l=[a];for(;l.length>0;){const u=[];for(const i of l){const m=o.get(i);for(const f of c.get(i)??[])o.has(f)||(o.set(f,m+1),u.push(f))}l=u}return t.map(u=>o.get(u)??-1)}function Yr({positions:t,focusNodeId:n,firstRingNodeIds:a,secondRingNodeIds:s,currentRatio:c}){const o=t.get(n);if(!o)return null;const l=[n,...a,...s].filter((A,Z,j)=>j.indexOf(A)===Z),u=l.map(A=>t.get(A)).filter(Boolean);if(u.length===0)return null;let i=Number.POSITIVE_INFINITY,m=Number.NEGATIVE_INFINITY,f=Number.POSITIVE_INFINITY,w=Number.NEGATIVE_INFINITY,F=Number.POSITIVE_INFINITY,g=Number.NEGATIVE_INFINITY,v=Number.POSITIVE_INFINITY,M=Number.NEGATIVE_INFINITY;for(const A of t.values())F=Math.min(F,A.x),g=Math.max(g,A.x),v=Math.min(v,A.y),M=Math.max(M,A.y);for(const A of u)i=Math.min(i,A.x),m=Math.max(m,A.x),f=Math.min(f,A.y),w=Math.max(w,A.y);const S=Math.max(m-i,w-f,.75),P=Math.max(g-F,M-v,S),G=u.length<=1?Ye(Math.max(c,.48),.38,.6):Ye(S/P*3.2,.42,Math.max(c,1.12));return{x:o.x,y:o.y,ratio:G,nodeIds:l}}function Ft({positions:t,currentRatio:n=1}){const a=[...t.values()];if(a.length===0)return{x:0,y:0,ratio:n};let s=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY;for(const m of a)s=Math.min(s,m.x),c=Math.max(c,m.x),o=Math.min(o,m.y),l=Math.max(l,m.y);const u=Math.max(c-s,l-o,1),i=Ye(u/6.4,.72,2.8);return{x:0,y:0,ratio:Math.max(n,i)}}function wt(t){const n=at.indexOf(t);return n>=0?n:at.length-1}function Hr(t){const n=$e.find(a=>a.kinds.some(s=>s===t))??$e[$e.length-1];return{laneId:n.id,laneLabel:n.label,laneIndex:$e.findIndex(a=>a.id===n.id)}}function Qe(){return{structural:0,contextual:0,taxonomy:0,workspace:0}}function Vr(t){const n=new Map;for(const a of t){const s=n.get(a.source)??new Set;s.add(a.target),n.set(a.source,s);const c=n.get(a.target)??new Set;c.add(a.source),n.set(a.target,c)}return n}function Br(t,n){return n.strength-t.strength||t.relationKind.localeCompare(n.relationKind)||t.label.localeCompare(n.label)||t.id.localeCompare(n.id)}function kt(t){const n=new Map;for(const a of t){const s=`${a.source}→${a.target}`,c=n.get(s)??[];c.push(a),n.set(s,c)}return Array.from(n.entries()).map(([a,s])=>{const c=[...s].sort(Br),o=c[0],l=c.length,u=Math.max(...c.map(i=>i.strength))*Math.min(1.45,1+(l-1)*.12);return{id:`${a}#${o.id}`,source:o.source,target:o.target,relationKind:o.relationKind,family:o.family,label:l>1?`${o.label} +${l-1}`:o.label,strength:u,directional:o.directional,structural:o.structural,parallelCount:l,data:c}}).sort((a,s)=>a.source.localeCompare(s.source)||a.target.localeCompare(s.target)||a.id.localeCompare(s.id))}function Xr(t,n){const a=kt(n),s=[...t].sort((o,l)=>{var u;return o.id.localeCompare(l.id)||((u=o.updatedAt)==null?void 0:u.localeCompare(l.updatedAt??""))||0}).map(o=>`${o.id}:${o.title}:${o.size}:${o.importance}:${o.updatedAt??""}`).join("|"),c=a.map(o=>`${o.source}:${o.target}:${o.parallelCount}:${o.label}:${o.strength.toFixed(3)}`).join("|");return`${t.length}/${a.length}/${s}::${c}`}function It(t,n){const a=[...t].sort((u,i)=>{const m=wt(u.entityKind)-wt(i.entityKind);return m!==0?m:i.importance-u.importance||u.title.localeCompare(i.title)}),s=new Map,c=a.map(u=>{const{laneId:i,laneIndex:m,laneLabel:f}=Hr(u.entityKind),w=s.get(m)??0;return s.set(m,w+1),{...u,layer:m,laneId:i,laneLabel:f,row:w}}),o=new Map(c.map(u=>[u.id,u])),l=n.map(u=>{const i=o.get(u.source),m=o.get(u.target),f=(i==null?void 0:i.layer)??0,w=(m==null?void 0:m.layer)??0;return{...u,secondary:w<=f||u.family!=="structural"&&u.family!=="taxonomy"}});return{nodes:c,edges:l}}function yt(t,n,a){const s=new Map(t.map(g=>[g.id,g])),c=a?s.get(a)??null:null;if(!c)return{generatedAt:new Date().toISOString(),focusNode:null,firstRingNodes:[],neighborhoodEdges:[],familyGroups:[],relationCounts:Qe(),secondRingCounts:Qe()};const o=n.filter(g=>g.source===c.id||g.target===c.id),l=Array.from(new Set(o.flatMap(g=>g.source===c.id?[g.target]:[g.source]))),u=l.map(g=>s.get(g)??null).filter(g=>!!g),i=new Map,m=Qe(),f=Qe(),w=Vr(n);for(const g of l){const v=w.get(g)??new Set;for(const M of v){if(M===c.id||l.includes(M))continue;const S=n.filter(P=>P.source===g&&P.target===M||P.target===g&&P.source===M);for(const P of S)f[P.family]+=1}}for(const g of o){const v=g.source===c.id?g.target:g.source,M=s.get(v);if(!M)continue;m[g.family]+=1;const S=i.get(g.relationKind);if(S){S.items.some(P=>P.id===M.id)||S.items.push(M);continue}i.set(g.relationKind,{relationKind:g.relationKind,family:g.family,label:ur[g.relationKind],items:[M]})}const F=new Map;for(const g of i.values()){const v=F.get(g.family);if(v){v.relations.push({...g,items:[...g.items].sort((M,S)=>M.title.localeCompare(S.title))}),v.itemCount+=g.items.length,v.relationCount+=1;continue}F.set(g.family,{family:g.family,label:dr[g.family],relationCount:1,itemCount:g.items.length,relations:[{...g,items:[...g.items].sort((M,S)=>M.title.localeCompare(S.title))}]})}return{generatedAt:new Date().toISOString(),focusNode:c,firstRingNodes:u.sort((g,v)=>g.title.localeCompare(v.title)),neighborhoodEdges:o,familyGroups:[...F.values()].map(g=>({...g,relations:g.relations.sort((v,M)=>v.label.localeCompare(M.label))})).sort((g,v)=>g.label.localeCompare(v.label)),relationCounts:m,secondRingCounts:f}}function Wr(t,n){return lr(t,n)}function Ur(t,n){if(!t)return new Set;const a=new Set([t]);for(const s of n)s.source===t?a.add(s.target):s.target===t&&a.add(s.source);return a}let ze=null;function qr(){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 vt(){typeof window>"u"||(delete window.__FORGE_KNOWLEDGE_GRAPH_DIAGNOSTICS__,delete window.__FORGE_KNOWLEDGE_GRAPH_TEST_API__)}function Qr(){if(ze!==null)return ze;if(typeof document>"u")return ze=!1,!1;const t=document.createElement("canvas");return ze=!!(t.getContext("webgl2")||t.getContext("webgl")||t.getContext("experimental-webgl")),ze}function Jr(t){if(!t||typeof window>"u")return"#c0c1ff";const n=getComputedStyle(document.documentElement).getPropertyValue(t).trim();return n?`rgb(${n})`:"#c0c1ff"}function Zr(t,n){if(t.startsWith("rgb(")&&t.endsWith(")"))return t.replace("rgb(","rgba(").replace(")",`, ${n})`);if(t.startsWith("#")){const a=t.slice(1),s=a.length===3?a.split("").map(u=>`${u}${u}`).join(""):a,c=parseInt(s.slice(0,2),16),o=parseInt(s.slice(2,4),16),l=parseInt(s.slice(4,6),16);return`rgba(${c}, ${o}, ${l}, ${n})`}return t}function Le(t,n){t.forEachNode(a=>{const s=t.getNodeAttributes(a);Number.isFinite(s.x)&&Number.isFinite(s.y)&&n.set(a,{x:s.x,y:s.y})})}function en(t,n,a){const s=new jr,c=[...t].sort((l,u)=>u.importance-l.importance||l.title.localeCompare(u.title)||l.id.localeCompare(u.id)),o=Tr({nodes:c,cache:a});return c.forEach(l=>{const u=o.get(l.id);s.addNode(l.id,{x:(u==null?void 0:u.x)??0,y:(u==null?void 0:u.y)??0,size:Math.max(2.5,l.size/14),color:Jr(l.accentToken),label:l.title,hidden:!1,forceLabel:!1,highlighted:!1,zIndex:0,data:l})}),n.forEach(l=>{!s.hasNode(l.source)||!s.hasNode(l.target)||s.addEdgeWithKey(l.id,l.source,l.target,{size:Math.max(.8,l.strength*1.6),color:l.family==="structural"?"rgba(125, 211, 252, 0.055)":l.family==="contextual"?"rgba(45, 212, 191, 0.055)":l.family==="taxonomy"?"rgba(192, 132, 252, 0.055)":l.family==="workspace"?"rgba(251, 191, 36, 0.055)":"rgba(148, 163, 184, 0.055)",label:l.label,hidden:!1,forceLabel:!1,zIndex:0,data:l})}),s}function Nt(t){if(t.order===0)return;let n=0,a=0,s=0;if(t.forEachNode(l=>{const u=t.getNodeAttributes(l);n+=u.x,a+=u.y,s+=1}),s===0)return;const c=n/s,o=a/s;Math.abs(c)<1e-4&&Math.abs(o)<1e-4||t.updateEachNodeAttributes((l,u)=>({...u,x:u.x-c,y:u.y-o}),{attributes:["x","y"]})}function St(t){const n=new Map;return t.forEachNode(a=>{const s=t.getNodeAttributes(a);n.set(a,{x:s.x,y:s.y})}),n}function Fe(t,n){return{nodes:t.nodes().map(a=>({id:a,...t.getNodeAttributes(a)})),edges:n}}function tn(t){if(t.nodes.length===0)return{minX:-1,maxX:1,minY:-1,maxY:1};let n=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,s=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY;for(const o of t.nodes)n=Math.min(n,o.x),a=Math.max(a,o.x),s=Math.min(s,o.y),c=Math.max(c,o.y);return{minX:n,maxX:a,minY:s,maxY:c}}function rn(t){const n=Ft({positions:new Map(t.nodes.map(a=>[a.id,{x:a.x,y:a.y}])),currentRatio:1});return{x:n.x,y:n.y,angle:0,ratio:n.ratio}}function nn({x:t,y:n}){const a=Array.from({length:t.length},(c,o)=>({x:t[o]??0,y:n[o]??0})),s=hr(a);return s.changed?{changed:!0,offsetX:s.offset.x,offsetY:s.offset.y,x:new Float32Array(s.positions.map(c=>c.x)),y:new Float32Array(s.positions.map(c=>c.y))}:{changed:!1,offsetX:0,offsetY:0,x:new Float32Array(t),y:new Float32Array(n)}}function Kt({node:t,snapshot:n,camera:a,width:s,height:c}){const o=tn(n),l=Math.max(1,o.maxX-o.minX),u=Math.max(1,o.maxY-o.minY),i=28,f=Math.min(Math.max(1,s-i*2)/l,Math.max(1,c-i*2)/u)/Math.max(a.ratio,.08);return{x:s/2+(t.x-a.x)*f,y:c/2-(t.y-a.y)*f,size:Math.max(4,t.size*f*.12)}}function an({datasetSignature:t,focusNodeId:n,primaryFocusedNodeId:a,draggedNodeId:s,graph:c,layoutGeneration:o,sigma:l,startupPhase:u,startupInvariantSatisfied:i,simulationPhase:m,focusSources:f,focusPressure:w,centroid:F,cameraTarget:g,latestSnapshotAt:v,latestSnapshotNodeCount:M}){const S=[],P={},G={};let A=null;c.forEachNode(k=>{S.push(k);const K=l.getNodeDisplayData(k),ee=c.getNodeAttributes(k),xe=l.graphToViewport({x:ee.x,y:ee.y});P[k]={x:xe.x,y:xe.y,size:(K==null?void 0:K.size)??ee.size},G[k]=Number((w[S.length-1]??0).toFixed(4)),k===a&&(A={x:ee.x,y:ee.y})});const Z=it(S.map(k=>{const K=c.getNodeAttributes(k);return{x:K.x,y:K.y}})),j=l.getCamera().getState(),H=ot({centroid:F,boundsCenter:Z,camera:j});window.__FORGE_KNOWLEDGE_GRAPH_DIAGNOSTICS__={datasetSignature:t,visibleNodeIds:S,visibleNodeCount:S.length,focusedNodeId:n,primaryFocusedNodeId:a,draggedNodeId:s,layoutGeneration:o,rendererMode:"sigma",startupPhase:u,startupInvariantSatisfied:i,simulationPhase:m,focusSources:f,focusPressureByNodeId:G,graphCentroid:F,boundsCenter:Z,focusedNodePosition:A,cameraTarget:g,cameraFollowError:g?{x:Number((j.x-g.x).toFixed(4)),y:Number((j.y-g.y).toFixed(4)),ratio:Number((j.ratio-g.ratio).toFixed(4))}:null,camera:j,nodeScreenPositions:P,centroidDistanceFromOrigin:H.centroidDistanceFromOrigin,boundsCenterDistanceFromOrigin:H.boundsCenterDistanceFromOrigin,cameraDistanceFromOrigin:H.cameraDistanceFromOrigin,cameraToCentroidDistance:H.cameraToCentroidDistance,latestSnapshotAt:v,latestSnapshotNodeCount:M}}function _t({datasetSignature:t,focusNodeId:n,primaryFocusedNodeId:a,draggedNodeId:s,layoutGeneration:c,camera:o,snapshot:l,width:u,height:i,startupPhase:m,startupInvariantSatisfied:f,simulationPhase:w,focusSources:F,focusPressure:g,centroid:v,cameraTarget:M,latestSnapshotAt:S,latestSnapshotNodeCount:P}){const G=l.nodes.map(K=>K.id),A={},Z={};let j=null;l.nodes.forEach((K,ee)=>{A[K.id]=Kt({node:K,snapshot:l,camera:o,width:u,height:i}),Z[K.id]=Number((g[ee]??0).toFixed(4)),K.id===a&&(j={x:K.x,y:K.y})});const H=it(l.nodes.map(K=>({x:K.x,y:K.y}))),k=ot({centroid:v,boundsCenter:H,camera:o});window.__FORGE_KNOWLEDGE_GRAPH_DIAGNOSTICS__={datasetSignature:t,visibleNodeIds:G,visibleNodeCount:G.length,focusedNodeId:n,primaryFocusedNodeId:a,draggedNodeId:s,layoutGeneration:c,rendererMode:"fallback",startupPhase:m,startupInvariantSatisfied:f,simulationPhase:w,focusSources:F,focusPressureByNodeId:Z,graphCentroid:v,boundsCenter:H,focusedNodePosition:j,cameraTarget:M,cameraFollowError:M?{x:Number((o.x-M.x).toFixed(4)),y:Number((o.y-M.y).toFixed(4)),ratio:Number((o.ratio-M.ratio).toFixed(4))}:null,camera:o,nodeScreenPositions:A,centroidDistanceFromOrigin:k.centroidDistanceFromOrigin,boundsCenterDistanceFromOrigin:k.boundsCenterDistanceFromOrigin,cameraDistanceFromOrigin:k.cameraDistanceFromOrigin,cameraToCentroidDistance:k.cameraToCentroidDistance,latestSnapshotAt:S,latestSnapshotNodeCount:P}}function Ct(t,n){if(!t)return!1;const a=t.clientWidth,s=t.clientHeight,c=t.getBoundingClientRect();return t.isConnected&&n.width>0&&n.height>0&&a>0&&s>0&&c.width>0&&c.height>0&&t.getClientRects().length>0}function sn({sigma:t,graph:n,viewportX:a,viewportY:s}){let c=null,o=Number.POSITIVE_INFINITY;return n.forEachNode(l=>{const u=n.getNodeAttributes(l),i=t.getNodeDisplayData(l);if(!i||u.hidden)return;const m=t.graphToViewport({x:u.x,y:u.y}),f=m.x-a,w=m.y-s,F=Math.hypot(f,w),g=Math.max(i.size*1.8,18);F<=g&&F<o&&(c=l,o=F)}),c}function ke(t,n){return`rgba(${t.family==="structural"?"125, 211, 252":t.family==="contextual"?"45, 212, 191":t.family==="taxonomy"?"192, 132, 252":t.family==="workspace"?"251, 191, 36":"148, 163, 184"}, ${n})`}const on=p.forwardRef(function({nodes:n,edges:a,focusNodeId:s,physicsSettings:c,onSelectNode:o},l){jt(),st(d=>d.knowledgeGraphDiagnostics.panelOpen);const u=p.useRef(null),i=p.useRef(null),m=p.useRef(null),f=p.useRef(null),w=p.useRef(new Map),F=p.useRef(new Map),g=p.useRef(new Map),v=p.useRef(o),M=p.useRef(s),S=p.useRef(null),P=p.useRef(0),G=p.useRef(null),A=p.useRef(0),Z=p.useRef(!0),j=p.useRef(null),H=p.useRef(0),k=p.useRef("global"),K=p.useRef(null),ee=p.useRef([]),xe=p.useRef(new Float32Array(0)),_e=p.useRef({x:0,y:0}),Y=p.useRef("boot"),Ie=p.useRef(!1),V=p.useRef(!1),z=p.useRef(!1),te=p.useRef(null),se=p.useRef(null),ve=p.useRef(0),be=p.useRef(0);p.useRef(0),p.useRef(Mt("/knowledge-graph"));const[re,ie]=p.useState(null),[ue,oe]=p.useState(null),[ce,B]=p.useState(null),[we,X]=p.useState({x:0,y:0,angle:0,ratio:1}),[b,W]=p.useState(null),[N,He]=p.useState({width:0,height:0}),je=Gt(),de=(d=f.current)=>Ft({positions:d?St(d):new Map,currentRatio:1}).ratio,Ke=(d=f.current)=>({x:.5,y:.5,angle:0,ratio:de(d)}),Oe=(d=f.current)=>({x:0,y:0,angle:0,ratio:de(d)}),Ae=()=>i.current?"sigma":"fallback",L=p.useMemo(()=>kt(a),[a]),ye=p.useMemo(()=>Xr(n,a),[a,n]),J=p.useMemo(()=>s?xt(L,s):null,[s,L]),he=p.useMemo(()=>s?new Set([s,...(J==null?void 0:J.firstRing)??[]]):new Set,[s,J]),pe=p.useMemo(()=>s?new Set([s,...(J==null?void 0:J.firstRing)??[],...(J==null?void 0:J.secondRing)??[]]):new Set,[s,J]),Ve=()=>Ct(u.current,N),ge=({resize:d=!1}={})=>{if(!i.current||!Ve())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}},Pe=()=>Date.now()<A.current,$=({level:d,eventKey:x,message:y,details:R,publishBackend:_=!1})=>{},tt=()=>i.current?{...i.current.getCamera().getState()}:{...we},Ne=({rendererMode:d})=>{if(!f.current||!S.current)return null;const x=f.current,y=x.nodes().map(C=>{const D=x.getNodeAttributes(C);return{id:C,x:D.x,y:D.y}}),R=pr(y),_=it(y),O=tt(),T=d==="sigma"?{...O,x:Number((O.x-.5).toFixed(4)),y:Number((O.y-.5).toFixed(4))}:O,I=ot({centroid:R,boundsCenter:_,camera:T});return{datasetSignature:S.current,route:"/knowledge-graph",rendererMode:d,startupPhase:Y.current,startupInvariantSatisfied:gr(I),visibleNodeCount:y.length,focusedNodeId:M.current,primaryFocusedNodeId:K.current,graphCentroid:R,boundsCenter:_,camera:O,cameraTarget:j.current?{x:j.current.x,y:j.current.y,ratio:j.current.ratio}:null,driftMetrics:I,latestSnapshotAt:te.current,lastVerifiedAt:new Date().toISOString()}},Be=(d,{mirrorToConsole:x=!1}={})=>{},Xe=({rendererMode:d,publishAnomaly:x})=>{},De=()=>{const d=i.current?Ke():Oe();if(i.current){i.current.getCamera().setState(d);return}X(d)},e=d=>{var _;if(!f.current)return!1;const x=Ne({rendererMode:Ae()});if(!x)return!1;const y=x.graphCentroid.x,R=x.graphCentroid.y;return Math.abs(y)<1e-4&&Math.abs(R)<1e-4?!1:(Nt(f.current),Le(f.current,w.current),(_=m.current)==null||_.postMessage({type:"recenter-graph",offsetX:y,offsetY:R}),W(Fe(f.current,L)),De(),Y.current="startup_corrected",$({level:"warning",eventKey:"startup_corrected",message:"Corrected the knowledge graph startup bias back to graph-space origin.",publishBackend:!0,details:{datasetSignature:S.current}}),!0)},h=({phase:d,allowCorrection:x,publishBackendOnFailure:y=!1})=>{if(!f.current||!S.current)return;Y.current=d;const R=i.current?"sigma":"fallback",_=Ne({rendererMode:R});if(!_)return;if(_.startupInvariantSatisfied){Y.current="startup_verified",Be({..._},{mirrorToConsole:!0}),$({level:"info",eventKey:"startup_verified",message:"Knowledge graph startup invariant passed.",details:{datasetSignature:_.datasetSignature,driftMetrics:_.driftMetrics}});return}if($({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}}),Ie.current||(Ie.current=!0,!e()))return;ge();const T=Ne({rendererMode:R});if(T){if(T.startupInvariantSatisfied){Y.current="startup_verified",Be({...T},{mirrorToConsole:!0}),$({level:"info",eventKey:"startup_verified_after_correction",message:"Knowledge graph startup invariant passed after correction.",details:{datasetSignature:T.datasetSignature,driftMetrics:T.driftMetrics}});return}$({level:"error",eventKey:"startup_correction_failed",message:"Knowledge graph startup correction did not restore the origin invariant.",publishBackend:!0,details:{datasetSignature:T.datasetSignature,driftMetrics:T.driftMetrics,centroid:T.graphCentroid,boundsCenter:T.boundsCenter,camera:T.camera}})}},E=()=>{var x,y,R,_;if(!S.current||!f.current)return;const d=Date.now();if(!(d-be.current<1500)){if(be.current=d,i.current){an({datasetSignature:S.current,focusNodeId:M.current,primaryFocusedNodeId:K.current,draggedNodeId:((x=G.current)==null?void 0:x.nodeId)??null,graph:f.current,layoutGeneration:P.current,sigma:i.current,startupPhase:Y.current,startupInvariantSatisfied:((y=Ne({rendererMode:"sigma"}))==null?void 0:y.startupInvariantSatisfied)??!1,simulationPhase:k.current,focusSources:ee.current,focusPressure:xe.current,centroid:_e.current,cameraTarget:j.current?{x:j.current.x,y:j.current.y,ratio:j.current.ratio}:null,latestSnapshotAt:te.current,latestSnapshotNodeCount:se.current});return}b&&_t({datasetSignature:S.current,focusNodeId:M.current,primaryFocusedNodeId:K.current,draggedNodeId:((R=G.current)==null?void 0:R.nodeId)??null,layoutGeneration:P.current,camera:we,snapshot:b,width:N.width,height:N.height,startupPhase:Y.current,startupInvariantSatisfied:((_=Ne({rendererMode:"fallback"}))==null?void 0:_.startupInvariantSatisfied)??!1,simulationPhase:k.current,focusSources:ee.current,focusPressure:xe.current,centroid:_e.current,cameraTarget:j.current?{x:j.current.x,y:j.current.y,ratio:j.current.ratio}:null,latestSnapshotAt:te.current,latestSnapshotNodeCount:se.current})}},Ee=()=>{if(!f.current||!M.current){j.current=null;return}const d=f.current;if(!d.hasNode(M.current)){j.current=null;return}const x=St(d),y=xt(L,M.current),R=i.current?i.current.getCamera().getState().ratio:we.ratio,_=Yr({positions:x,focusNodeId:M.current,firstRingNodeIds:y.firstRing,secondRingNodeIds:y.secondRing,currentRatio:R}),O=i.current&&_?Pr({positions:x,point:{x:_.x,y:_.y}}):null;j.current=_?{x:(O==null?void 0:O.x)??_.x,y:(O==null?void 0:O.y)??_.y,angle:0,ratio:_.ratio,nodeIds:_.nodeIds}:null},We=(d=220)=>{if(!j.current)return;const x=j.current;if(i.current){const y=i.current.getCamera(),R=y.getState(),_=Date.now()<H.current;y.animate({x:x.x,y:x.y,ratio:_?R.ratio:x.ratio,angle:0},{duration:d});return}X(y=>({...y,x:x.x,y:x.y,ratio:Date.now()<H.current?y.ratio:x.ratio}))};p.useEffect(()=>{v.current=o},[o]),p.useEffect(()=>{M.current=s,j.current=null},[s]),p.useEffect(()=>{vt()},[je]),p.useEffect(()=>{if(!(!qr()||typeof window>"u"))return window.__FORGE_KNOWLEDGE_GRAPH_TEST_API__={selectNode:d=>{var y;const x=d?g.current.get(d)??((y=f.current)!=null&&y.hasNode(d)?f.current.getNodeAttribute(d,"data")??null:null):null;v.current(x)},moveNodeBy:(d,x,y)=>{var T,I;if(!((T=f.current)!=null&&T.hasNode(d)))return;const R=f.current.getNodeAttributes(d),_=R.x+x,O=R.y+y;f.current.mergeNodeAttributes(d,{x:_,y:O}),w.current.set(d,{x:_,y:O}),(I=m.current)==null||I.postMessage({type:"nudge-node",nodeId:d,x:_,y:O}),ge(),!i.current&&f.current&&W(Fe(f.current,L))},nudgeCameraBy:(d,x)=>{if(i.current){const y=i.current.getCamera(),R=y.getState();y.animate({x:R.x+d,y:R.y+x,ratio:R.ratio,angle:R.angle},{duration:140});return}X(y=>({...y,x:y.x+d,y:y.y+x}))}},()=>{delete window.__FORGE_KNOWLEDGE_GRAPH_TEST_API__}},[L]),p.useEffect(()=>{if(!u.current||typeof ResizeObserver>"u")return;const d=()=>{u.current&&He({width:u.current.clientWidth,height:u.current.clientHeight})};d();const x=new ResizeObserver(()=>{d()});return x.observe(u.current),()=>x.disconnect()},[]),p.useImperativeHandle(l,()=>({zoomIn:()=>{if(H.current=Date.now()+1200,i.current){i.current.getCamera().animatedZoom({factor:1.25,duration:160});return}X(d=>({...d,ratio:Math.max(.08,d.ratio*.82)}))},zoomOut:()=>{if(H.current=Date.now()+1200,i.current){i.current.getCamera().animatedUnzoom({factor:1.25,duration:160});return}X(d=>({...d,ratio:Math.min(4,d.ratio*1.22)}))},fit:()=>{if(j.current=null,i.current){i.current.getCamera().animate(Ke(),{duration:220});return}b&&X(rn(b))},recenterOnFocus:()=>{Ee(),j.current&&We(220)}}),[b,L]),p.useEffect(()=>()=>{var d,x,y;f.current&&Le(f.current,w.current),i.current&&S.current&&F.current.set(S.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,vt()},[je]),p.useEffect(()=>{var O,T;if(!u.current||!Ct(u.current,N))return;if(S.current===ye&&f.current!==null){ge({resize:!0}),E();return}Y.current="boot",Ie.current=!1,V.current=!1,z.current=!1,te.current=null,se.current=null,ve.current=0,j.current=null,$({level:"info",eventKey:"graph_boot",message:"Bootstrapping a fresh knowledge graph dataset.",details:{nodeCount:n.length,edgeCount:L.length}}),f.current&&Le(f.current,w.current),i.current&&S.current&&F.current.set(S.current,i.current.getCamera().getState());const x=en(n,L,w.current);if(Nt(x),Le(x,w.current),f.current=x,g.current=new Map(n.map(I=>[I.id,I])),S.current=ye,P.current+=1,W(Fe(x,L)),Y.current="graph_built",$({level:"info",eventKey:"graph_built",message:"Built and centered the knowledge graph structure.",details:{layoutGeneration:P.current}}),!Qr())(O=i.current)==null||O.kill(),i.current=null,B("WebGL is unavailable in this browser context."),X(Oe(x)),h({phase:"graph_built",allowCorrection:!0,publishBackendOnFailure:!0});else try{if(i.current)i.current.setGraph(x),ge();else{i.current=new Rr(x,u.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}),$({level:"info",eventKey:"sigma_initialized",message:"Initialized Sigma for the knowledge graph.",details:{datasetSignature:ye}}),i.current.on("clickNode",({node:C})=>{if(Pe())return;const D=g.current.get(C)??null;v.current(D)}),i.current.on("clickStage",({event:C})=>{if(Pe())return;if(!i.current||!f.current){v.current(null);return}const D=sn({sigma:i.current,graph:f.current,viewportX:C.x,viewportY:C.y});if(D){v.current(g.current.get(D)??null);return}v.current(null)}),i.current.on("downNode",({node:C,event:D,preventSigmaDefault:fe})=>{var me,U;if(!i.current||!((me=f.current)!=null&&me.hasNode(C)))return;fe();const Me=i.current.viewportToGraph({x:D.x,y:D.y}),ne=f.current.getNodeAttributes(C);G.current={nodeId:C,offsetX:ne.x-Me.x,offsetY:ne.y-Me.y,startViewportX:D.x,startViewportY:D.y,currentX:ne.x,currentY:ne.y,moved:!1},Z.current=i.current.getSetting("enableCameraPanning")??!0,i.current.setSetting("enableCameraPanning",!1),oe(C),ie(C),$({level:"debug",eventKey:"drag_start",message:"Started dragging a knowledge graph node.",details:{nodeId:C}}),(U=m.current)==null||U.postMessage({type:"drag-start",nodeId:C})}),i.current.on("moveBody",({event:C,preventSigmaDefault:D})=>{var U;if(!i.current||!f.current||!G.current)return;D();const fe=i.current.viewportToGraph({x:C.x,y:C.y});Math.hypot(C.x-G.current.startViewportX,C.y-G.current.startViewportY)>3&&(G.current={...G.current,moved:!0});const ne=fe.x+G.current.offsetX,me=fe.y+G.current.offsetY;G.current={...G.current,currentX:ne,currentY:me},f.current.mergeNodeAttributes(G.current.nodeId,{x:ne,y:me}),w.current.set(G.current.nodeId,{x:ne,y:me}),(U=m.current)==null||U.postMessage({type:"drag-move",nodeId:G.current.nodeId,x:ne,y:me}),ge()});const I=()=>{var fe;if(!i.current||!G.current){G.current=null,oe(null);return}const C=G.current.nodeId,D=G.current.moved;i.current.setSetting("enableCameraPanning",Z.current),(fe=m.current)==null||fe.postMessage({type:"drag-end",nodeId:C}),$({level:"debug",eventKey:"drag_end",message:"Released a dragged knowledge graph node.",details:{nodeId:C,moved:D}}),G.current=null,oe(null),D&&(A.current=Date.now()+220,v.current(g.current.get(C)??null))};i.current.on("upNode",I),i.current.on("upStage",I),i.current.on("leaveStage",I),i.current.on("enterNode",({node:C})=>{ie(C)}),i.current.on("leaveNode",()=>{ie(null)}),i.current.on("afterRender",()=>{V.current||(V.current=!0,Y.current="first_frame",$({level:"info",eventKey:"first_frame",message:"Knowledge graph rendered its first frame.",details:{datasetSignature:S.current}}),h({phase:"first_frame",allowCorrection:!0,publishBackendOnFailure:!0}),Xe({rendererMode:"sigma",publishAnomaly:!0})),E()})}B(null),W(Fe(x,L)),i.current.getCamera().setState(Ke(x))}catch(I){(T=i.current)==null||T.kill(),i.current=null,B(I instanceof Error?I.message:"Graph renderer unavailable."),W(Fe(x,L)),X(Oe(x)),$({level:"error",eventKey:"sigma_fallback",message:"Fell back from Sigma to the SVG renderer.",publishBackend:!0,details:{reason:I instanceof Error?I.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=I=>{var me;if(!f.current)return;const C=I.data;if(C.type==="stats"){k.current=C.phase,K.current=C.primaryFocusedNodeId,ee.current=C.focusSources,xe.current=C.focusPressure,_e.current=C.centroid,z.current||(z.current=!0,Y.current="worker_started",$({level:"info",eventKey:"worker_started",message:"Knowledge graph worker reported its first simulation stats.",details:{datasetSignature:S.current,phase:C.phase}}),h({phase:"worker_started",allowCorrection:!0,publishBackendOnFailure:!0}));return}const D=f.current;let fe=C.x,Me=C.y;if(Y.current!=="startup_verified"){const U=nn({x:C.x,y:C.y});U.changed&&(fe=U.x,Me=U.y,(me=m.current)==null||me.postMessage({type:"recenter-graph",offsetX:U.offsetX,offsetY:U.offsetY}),De(),$({level:"warning",eventKey:"worker_startup_recenter",message:"Recentering worker positions during startup because the graph drifted away from origin.",details:{datasetSignature:S.current,startupPhase:Y.current,offsetX:U.offsetX,offsetY:U.offsetY}}))}let ne=0;if(D.updateEachNodeAttributes((U,Xt)=>({...Xt,x:fe[ne],y:Me[ne++]}),{attributes:["x","y"]}),G.current&&D.hasNode(G.current.nodeId)){const U=G.current.nodeId;D.mergeNodeAttributes(U,{x:G.current.currentX,y:G.current.currentY})}Le(D,w.current),i.current?ge():W(Fe(D,L))});const y=x.nodes(),R=new Map(y.map((I,C)=>[I,C])),_=bt(y,L,s);m.current.postMessage({type:"init-graph",nodes:y.map(I=>{const C=x.getNodeAttributes(I);return{id:I,x:C.x,y:C.y,size:C.size,mass:Math.max(1,C.data.importance/42),importance:C.data.importance}}),edges:L.filter(I=>R.has(I.source)&&R.has(I.target)).map(I=>({source:R.get(I.source),target:R.get(I.target),weight:Math.max(.6,I.strength)})),focusNodeId:s,hopLevels:_,physics:c}),$({level:"debug",eventKey:"worker_init",message:"Posted the graph payload to the layout worker.",details:{nodeCount:y.length,edgeCount:L.length}})},[N.height,N.width,ye,s,n,c,L]),p.useEffect(()=>{if(!m.current||!f.current)return;const d=bt(f.current.nodes(),L,s);m.current.postMessage({type:"set-focus",focusNodeId:s,hopLevels:d}),s||(j.current=null)},[s,L]),p.useEffect(()=>{m.current&&m.current.postMessage({type:"update-physics",physics:c})},[c]),p.useEffect(()=>{},[ye,je]),p.useEffect(()=>{!i.current||!f.current||(i.current.setSetting("nodeReducer",(d,x)=>{var R;const y=(R=f.current)==null?void 0:R.getNodeAttribute(d,"data");return Lr({nodeId:d,attributes:x,node:y,focusNodeId:s,relatedNodeIds:pe,detailNodeIds:he,hoveredNodeId:re,draggedNodeId:ue})}),i.current.setSetting("edgeReducer",(d,x)=>{var R;const y=(R=f.current)==null?void 0:R.getEdgeAttribute(d,"data");return $r({attributes:x,edge:y,focusNodeId:s,detailNodeIds:he,relatedNodeIds:pe,hoveredNodeId:re})}),ge())},[he,ue,s,re,pe]),p.useEffect(()=>{var d,x;!b||!S.current||N.width<=0||N.height<=0||!ce&&i.current||(V.current||(V.current=!0,Y.current="first_frame",$({level:"info",eventKey:"fallback_first_frame",message:"Knowledge graph rendered its first fallback frame.",details:{datasetSignature:S.current}}),h({phase:"first_frame",allowCorrection:!0,publishBackendOnFailure:!0})),_t({datasetSignature:S.current,focusNodeId:s,primaryFocusedNodeId:K.current,draggedNodeId:((d=G.current)==null?void 0:d.nodeId)??null,layoutGeneration:P.current,camera:we,snapshot:b,width:N.width,height:N.height,startupPhase:Y.current,startupInvariantSatisfied:((x=Ne({rendererMode:"fallback"}))==null?void 0:x.startupInvariantSatisfied)??!1,simulationPhase:k.current,focusSources:ee.current,focusPressure:xe.current,centroid:_e.current,cameraTarget:j.current?{x:j.current.x,y:j.current.y,ratio:j.current.ratio}:null,latestSnapshotAt:te.current,latestSnapshotNodeCount:se.current}))},[N.height,N.width,we,ce,b,s]);const Te=p.useMemo(()=>!b||N.width<=0||N.height<=0?[]:b.nodes.map(d=>{const x=Kt({node:d,snapshot:b,camera:we,width:N.width,height:N.height});return{...d,viewportX:x.x,viewportY:x.y,viewportSize:x.size}}),[N.height,N.width,we,b]),Ue=p.useMemo(()=>new Map(Te.map(d=>[d.id,d])),[Te]);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:u,className:"h-full w-full touch-none","aria-label":"Knowledge graph canvas",children:ce&&b?r.jsxs("svg",{className:"h-full w-full",viewBox:`0 0 ${Math.max(N.width,1)} ${Math.max(N.height,1)}`,"aria-hidden":"true",children:[r.jsx("title",{children:"Knowledge graph fallback canvas"}),r.jsx("rect",{x:"0",y:"0",width:Math.max(N.width,1),height:Math.max(N.height,1),fill:"transparent",onClick:()=>v.current(null)}),b.edges.map(d=>{const x=Ue.get(d.source),y=Ue.get(d.target);if(!x||!y)return null;const R=!!s&&(d.source===s||d.target===s),_=!!re&&(d.source===re||d.target===re),O=s?d.source===s?0:he.has(d.source)?1:pe.has(d.source)?2:3:0,T=s?d.target===s?0:he.has(d.target)?1:pe.has(d.target)?2:3:0,I=s?Math.max(O,T):0;return r.jsx("line",{x1:x.viewportX,y1:x.viewportY,x2:y.viewportX,y2:y.viewportY,stroke:R?ke(d,.24):_?ke(d,.14):s?I<=1?ke(d,.09):I===2?ke(d,.05):ke(d,.016):ke(d,.055),strokeWidth:R?1.7:_?1.3:.95},d.id)}),Te.map(d=>{const x=s===d.id,y=pe.has(d.id),R=he.has(d.id),_=re===d.id,O=!s||y;return r.jsxs("g",{transform:`translate(${d.viewportX}, ${d.viewportY})`,onMouseEnter:()=>ie(d.id),onMouseLeave:()=>ie(null),onClick:T=>{T.stopPropagation();const I=g.current.get(d.id)??null;v.current(I)},style:{cursor:"pointer"},children:[r.jsx("circle",{r:x?d.viewportSize*1.9:_?d.viewportSize*1.3:R?d.viewportSize*1.15:y?d.viewportSize*1.05:d.viewportSize,fill:O?d.color:Zr(d.color,.3),stroke:x?"rgba(255,255,255,0.78)":"rgba(255,255,255,0.12)",strokeWidth:x?2:1}),(x||_||R)&&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})})}),cn=300,ln=152;function Ot(t,n){return t?Ur(t,n):new Set}function un(t,n,a){const s=It(t,n),c=Ot(a,n);return s.nodes.map(o=>{const l=o.id===a,u=!a||c.has(o.id);return{id:o.id,draggable:!1,selectable:!1,position:{x:72+o.layer*cn,y:88+o.row*ln},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:l?"rgba(255,255,255,0.32)":"rgba(255,255,255,0.1)",background:l?"rgba(11,17,30,0.98)":"rgba(8,14,26,0.92)",opacity:u?1:.28},children:[r.jsx("div",{className:"flex flex-wrap items-center gap-2",children:r.jsx(et,{kind:o.entityKind,label:o.entityKind.replaceAll("_"," "),compact:!0,gradient:l})}),r.jsx("div",{className:"mt-3",children:r.jsx(fr,{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 dn(t,n,a,s){const c=It(t,n),o=Ot(a,n);return c.edges.filter(l=>s||!l.secondary).map(l=>{const u=!a||o.has(l.source)||o.has(l.target);return{id:l.id,source:l.source,target:l.target,animated:!l.secondary&&l.family==="structural"&&u,markerEnd:{type:kr.ArrowClosed,color:l.secondary?"rgba(255,255,255,0.16)":"rgba(232,242,255,0.42)"},style:{opacity:u?1:.18,stroke:l.secondary?"rgba(255,255,255,0.16)":l.family==="taxonomy"?"rgba(162,245,189,0.34)":l.family==="structural"?"rgba(232,242,255,0.4)":"rgba(192,193,255,0.24)",strokeDasharray:l.secondary?"8 6":void 0,strokeWidth:l.secondary?1:l.family==="structural"?1.7:1.2}}})}function hn({nodes:t,edges:n,focusNodeId:a,showSecondaryEdges:s,onSelectNode:c,onOpenNode:o,onNavigateNode:l,isMobile:u}){const i=p.useMemo(()=>un(t,n,a),[n,a,t]),m=p.useMemo(()=>dn(t,n,a,s),[n,a,t,s]),f=p.useMemo(()=>new Map(t.map(w=>[w.id,w])),[t]);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:$e.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(Mr,{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,F)=>{const g=f.get(F.id);g&&c(g)},onNodeDoubleClick:(w,F)=>{const g=f.get(F.id);if(g){if(u){o(g);return}l(g)}},children:[r.jsx(Gr,{showInteractive:!1}),r.jsx(Fr,{gap:28,size:1,color:"rgba(255,255,255,0.05)"})]},`${a??"all"}-${s?"all":"primary"}`)]})}const At=6,Pt=5,Dt=.92,Tt=5,zt=.15,Lt=2.4,$t=2,Yt=.8,Ht=3,le={focusRepulsion:2.25,focusDiffusion:1.95,focusSpringReductionMax:.34,focusSpringReductionDiffusion:1.85,edgeSpringStrength:1,gravityStrength:1,focusShellSpacing:1};function Re(t,n,a){return Math.min(Math.max(t,n),a)}function Vt(t){return{focusRepulsion:Re((t==null?void 0:t.focusRepulsion)??le.focusRepulsion,.6,At),focusDiffusion:Re((t==null?void 0:t.focusDiffusion)??le.focusDiffusion,.6,Pt),focusSpringReductionMax:Re((t==null?void 0:t.focusSpringReductionMax)??le.focusSpringReductionMax,0,Dt),focusSpringReductionDiffusion:Re((t==null?void 0:t.focusSpringReductionDiffusion)??le.focusSpringReductionDiffusion,.6,Tt),edgeSpringStrength:Re((t==null?void 0:t.edgeSpringStrength)??le.edgeSpringStrength,zt,Lt),gravityStrength:Re((t==null?void 0:t.gravityStrength)??le.gravityStrength,0,$t),focusShellSpacing:Re((t==null?void 0:t.focusShellSpacing)??le.focusShellSpacing,Yt,Ht)}}function pn({isMobile:t,currentFocusNodeId:n,nextNodeId:a}){return a?t?n===a?{nextFocusNodeId:a,nextMobileSheetOpen:!0,shouldUpdateFocus:!1}:{nextFocusNodeId:a,nextMobileSheetOpen:!1,shouldUpdateFocus:!0}:{nextFocusNodeId:a,nextMobileSheetOpen:!1,shouldUpdateFocus:n!==a}:{nextFocusNodeId:null,nextMobileSheetOpen:!1,shouldUpdateFocus:n!==null}}const Et="__clear__";function gn({isMobile:t,focusNodeId:n,shellOverlayFocusNodeId:a,lastRequestedKey:s}){const c=t?null:n,o=c??Et;return o===(a??Et)?{action:"none",nextRequestedKey:o}:s===o?{action:"none",nextRequestedKey:o}:{action:c?"set":"clear",nextRequestedKey:o}}const Je=2e3,rt=40,nt=2e3,Bt="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 Ze(t,n){return Array.from(new Set(t.getAll(n).flatMap(a=>a.split(",")).map(a=>a.trim()).filter(Boolean)))}function Q(t,n,a){t.delete(n),a.forEach(s=>t.append(n,s))}function mn(t){switch(t.entityType){case"workbench_flow":case"workbench_surface":case"wiki_space":return null;default:return Cr(t.entityType,t.entityId)}}function ae(t){return t?t.slice(0,10):""}function xn(){if(typeof window>"u")return le;try{const t=window.localStorage.getItem(Bt);return t?Vt(JSON.parse(t)):le}catch{return le}}function bn(t,n,a,s,c){const o=t.find(l=>l.id===n);return o||(!n||!a?null:{id:n,displayName:a,kind:s??"human",accentColor:c??"",handle:a.toLowerCase().replace(/\s+/g,"-"),description:"",createdAt:"",updatedAt:""})}function wn({entityKinds:t,relationKinds:n,tags:a,owners:s}){return[...t.map(c=>`entity:${c}`),...n.map(c=>`relation:${c}`),...a.map(c=>`tag:${c}`),...s.map(c=>`owner:${c}`)]}function Rt(t){const n=[],a=[],s=[],c=[];for(const o of t){const[l,...u]=o.split(":"),i=u.join(":").trim();i&&(l==="entity"?n.push(i):l==="relation"?a.push(i):l==="tag"?s.push(i):l==="owner"&&c.push(i))}return{entityKinds:n,relationKinds:a,tags:s,owners:c}}class yn extends p.Component{constructor(n){super(n),this.state={error:null}}static getDerivedStateFromError(n){return{error:n}}componentDidUpdate(n){n.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 Gn(){var Xe,De;const t=mr(),n=jt();st(e=>e.knowledgeGraphDiagnostics);const a=st(e=>{var h,E;return((E=(h=e.shell.knowledgeGraphOverlayFocus)==null?void 0:h.focusNode)==null?void 0:E.id)??null}),s=Wt(),[c,o]=Ut(),l=p.useRef(null),u=p.useRef(null),i=p.useRef(null),m=p.useRef(null),f=p.useRef(null);p.useRef(Mt("/knowledge-graph"));const[w,F]=p.useState(()=>typeof window<"u"?window.matchMedia("(max-width: 1023px)").matches:!1),[g,v]=p.useState(!1),[M,S]=p.useState(!1),[P,G]=p.useState(!1),[A,Z]=p.useState(!1),[j,H]=p.useState(""),[k,K]=p.useState(()=>xn()),xe=Gt(),_e=({level:e,eventKey:h,message:E,details:Ee,publishBackend:We=!1})=>{};p.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const e=window.matchMedia("(max-width: 1023px)"),h=E=>F(E?E.matches:e.matches);return h(),typeof e.addEventListener=="function"?(e.addEventListener("change",h),()=>e.removeEventListener("change",h)):(e.addListener(h),()=>e.removeListener(h))},[]),p.useEffect(()=>{w||(v(!1),S(!1),u.current=null)},[w]),p.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(Bt,JSON.stringify(k))},[k]);const Y=c.toString(),Ie=p.useMemo(()=>{const e=new URLSearchParams(Y),h=e.get("view")==="hierarchy"?"hierarchy":"graph",E=xr(e.get("focus")),Ee=E?Wr(E.entityType,E.entityId):null,We=Ze(e,"entityKind"),Te=Ze(e,"relationKind"),Ue=Ze(e,"tag"),d=Ze(e,"owner"),x=e.get("q")??"",y=e.get("updatedFrom"),R=e.get("updatedTo"),_=Number(e.get("limit")??Je),O=Number.isFinite(_)?Math.max(rt,Math.min(nt,_)):Je;return{selectedView:h,focusNodeId:Ee,selectedKinds:We,selectedRelations:Te,selectedTags:Ue,selectedOwners:d,showHierarchyCrossLinks:e.get("cross")==="1",queryText:x,updatedFrom:y,updatedTo:R,maxNodes:O}},[Y]),{selectedView:V,focusNodeId:z,selectedKinds:te,selectedRelations:se,selectedTags:ve,selectedOwners:be,showHierarchyCrossLinks:re,queryText:ie,updatedFrom:ue,updatedTo:oe,maxNodes:ce}=Ie;p.useEffect(()=>{H(ie)},[ie]);const B=p.useMemo(()=>({q:ie.trim()||null,entityKinds:[...te].sort(),relationKinds:[...se].sort(),tags:[...ve].sort(),owners:[...be].sort(),updatedFrom:ue,updatedTo:oe,limit:ce,focusNodeId:null}),[ce,ie,te,be,se,ve,ue,oe]),we=p.useMemo(()=>["forge-knowledge-graph",...t.selectedUserIds,JSON.stringify(B)],[B,t.selectedUserIds]),X=cr({queryKey:we,queryFn:()=>Er(t.selectedUserIds,B),placeholderData:e=>e,staleTime:6e4,refetchOnWindowFocus:!1}),b=X.data;p.useEffect(()=>{_e({level:"info",eventKey:"route_arrival",message:"Arrived on the Knowledge Graph page.",details:{search:c.toString()}})},[]),p.useEffect(()=>{if(!X.isSuccess||!b)return;const e=JSON.stringify({q:B.q,entityKinds:B.entityKinds,relationKinds:B.relationKinds,tags:B.tags,owners:B.owners,updatedFrom:B.updatedFrom,updatedTo:B.updatedTo,limit:B.limit,nodeCount:b.counts.nodeCount,edgeCount:b.counts.edgeCount,filteredNodeCount:b.counts.filteredNodeCount,limited:b.counts.limited});f.current!==e&&(f.current=e,_e({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,X.isSuccess,B]),p.useEffect(()=>{!b||!z||b.nodes.some(e=>e.id===z)||(o(e=>{const h=new URLSearchParams(e);return h.delete("focus"),h},{replace:!0}),v(!1),u.current=null)},[z,b,o]),p.useEffect(()=>{if(w){if(!z){u.current=null,v(!1);return}u.current===z&&!g&&(v(!0),u.current=null)}},[z,w,g]);const W=p.useMemo(()=>!b||!z?yt([],[],null):yt(b.nodes,b.edges,z),[z,b]);p.useEffect(()=>{var h;const e=gn({isMobile:w,focusNodeId:((h=W.focusNode)==null?void 0:h.id)??null,shellOverlayFocusNodeId:a,lastRequestedKey:m.current});if(m.current=e.nextRequestedKey,e.action!=="none"){if(e.action==="clear"){n(dt());return}n(br(W))}},[n,W,w,a]),p.useEffect(()=>{{i.current=null;return}},[xe,z,W,w]),p.useEffect(()=>()=>{n(dt())},[n]),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:g,focusNodeId:z,selectedView:V,selectNodeById:e=>{if(!b)return;const h=e?b.nodes.find(E=>E.id===e)??null:null;Ce(h)},activateFocusedNode:()=>{if(!z||!b)return;const e=b.nodes.find(h=>h.id===z)??null;e&&Ce(e)}},()=>{delete window.__FORGE_KNOWLEDGE_GRAPH_PAGE_TEST__}}},[z,w,g,V]);const N=e=>{o(h=>{const E=new URLSearchParams(h);return e(E),E},{replace:!0})},He=e=>{const h=e.trim();H(e),N(E=>{h.length>0?E.set("q",h):E.delete("q")})},Ce=e=>{const h=pn({isMobile:w,currentFocusNodeId:z,nextNodeId:(e==null?void 0:e.id)??null});u.current=w&&h.nextMobileSheetOpen?(e==null?void 0:e.id)??null:null,v(h.nextMobileSheetOpen),h.shouldUpdateFocus&&(N(E=>{if(!e){E.delete("focus");return}E.set("focus",gt(e.entityType,e.entityId))}),w&&S(!1))},je=e=>{e.href&&s(e.href)},de=(e,h)=>{K(E=>Vt({...E,[e]:h}))},Ke=e=>{const h=mn(e);h&&s(h)},Oe=e=>{N(h=>{h.set("view","hierarchy"),h.set("focus",gt(e.entityType,e.entityId))})},Ae=()=>{N(e=>{["q","entityKind","relationKind","tag","owner","updatedFrom","updatedTo","focus"].forEach(h=>e.delete(h)),e.set("limit",String(Je))}),G(!1)};if(X.isLoading&&!b)return r.jsx(wr,{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(X.isError)return r.jsx(yr,{eyebrow:"Knowledge Graph",error:X.error,onRetry:()=>void X.refetch()});if(!b)return null;const L=new Map(b.facets.entityKinds.map(e=>[e.value,e])),ye=at.map(e=>{const h=vr(e),E=L.get(e),Ee=(E==null?void 0:E.count)??0;return{value:e,label:(E==null?void 0:E.label)??h.label,description:Ee===1?"1 node":`${Ee} nodes`,kind:e}}),J=b.facets.relationKinds.map(e=>({value:e.value,label:e.label,description:`${e.count} links`})),he=b.facets.tags.map(e=>({value:e.id,label:e.label,description:`${e.count} linked nodes`,badge:r.jsx(et,{kind:"tag",label:e.label,compact:!0,gradient:!1}),menuBadge:r.jsx(et,{kind:"tag",label:e.label,compact:!0,gradient:!1})})),pe=b.facets.owners.map(e=>{const h=bn(t.snapshot.users,e.userId,e.displayName,e.kind,e.accentColor);return{value:e.userId,label:e.displayName,description:`${e.count} nodes`,badge:r.jsx(ht,{user:h,compact:!0}),menuBadge:r.jsx(ht,{user:h,compact:!0})}}),Ve=[...ye.map(e=>({id:`entity:${e.value}`,label:e.label,description:e.description,searchText:`entity kind ${e.label}`,badge:r.jsx(et,{kind:e.kind??"note",label:e.label,compact:!0,gradient:!1})})),...J.map(e=>({id:`relation:${e.value}`,label:e.label,description:e.description,searchText:`relation kind ${e.label}`})),...he.map(e=>({id:`tag:${e.value}`,label:e.label,description:e.description,searchText:`tag ${e.label}`,badge:e.menuBadge??e.badge})),...pe.map(e=>({id:`owner:${e.value}`,label:e.label,description:e.description,searchText:`owner ${e.label}`,badge:e.menuBadge??e.badge}))],ge=wn({entityKinds:te,relationKinds:se,tags:ve,owners:be}),Pe=b.counts.limited?`${b.counts.nodeCount}/${b.counts.filteredNodeCount} nodes`:`${b.counts.nodeCount}n · ${b.counts.edgeCount}e`,$=b.counts.limited?`${b.counts.nodeCount} visible nodes from ${b.counts.filteredNodeCount} filtered matches`:`${b.counts.nodeCount} nodes and ${b.counts.edgeCount} edges`,tt=ie.trim().length>0||te.length>0||se.length>0||ve.length>0||be.length>0||!!ue||!!oe||ce!==Je,Ne=!w,Be=`${V}:${b.nodes.map(e=>e.id).join("|")}::${b.edges.map(e=>e.id).join("|")}`;return r.jsxs("div",{className:"-mx-4 -mb-2.5 h-[calc(100dvh-var(--forge-mobile-nav-clearance)-5.25rem)] overflow-hidden lg:-mx-6 lg:-mb-3 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(Nr,{metrics:t.snapshot.metrics})}),r.jsx(yn,{resetKey:Be,fallback:e=>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:e.message})]}),r.jsxs("div",{className:"flex flex-wrap justify-center gap-2",children:[r.jsxs(q,{variant:"primary",size:"sm",onClick:()=>N(h=>{h.set("view","hierarchy")}),children:[r.jsx(Qt,{className:"size-4"}),"Open hierarchy"]}),r.jsx(q,{variant:"secondary",size:"sm",onClick:Ae,children:"Reset graph filters"})]})]})}),children:V==="graph"?r.jsx(on,{ref:l,nodes:b.nodes,edges:b.edges,focusNodeId:z,physicsSettings:k,onSelectNode:Ce}):r.jsx("div",{className:"h-full overflow-y-auto px-4 py-4 lg:px-6",children:r.jsx(hn,{nodes:b.nodes,edges:b.edges,focusNodeId:z,showSecondaryEdges:re,isMobile:w,onSelectNode:Ce,onOpenNode:Ce,onNavigateNode:je})})}),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:$,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:Pe}),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 ${V==="graph"?"bg-white/[0.14] text-white":"text-white/52 hover:text-white"}`,onClick:()=>N(e=>{e.set("view","graph")}),children:"Graph"}),r.jsx("button",{type:"button",className:`rounded-full px-2 py-1 text-[10px] transition ${V==="hierarchy"?"bg-white/[0.14] text-white":"text-white/52 hover:text-white"}`,onClick:()=>N(e=>{e.set("view","hierarchy")}),children:"Hierarchy"})]}),r.jsx(q,{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:()=>Z(!0),"aria-label":"Open graph appearance settings",title:"Graph appearance settings",children:r.jsx(ct,{className:"size-3"})}),r.jsxs(q,{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:()=>{v(!1),S(!0)},"aria-label":"Open graph filters",children:[r.jsx(lt,{className:"size-3"}),"Search"]})]})]})}):null,Ne?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:$,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:Pe}),r.jsx("div",{className:"min-w-0 flex-1",children:r.jsx(ft,{title:"",description:"",compact:!0,minimal:!0,hideSummary:!0,query:j,onQueryChange:H,onQuerySubmit:He,submitLabel:"Search graph",options:Ve,selectedOptionIds:ge,onSelectedOptionIdsChange:e=>{const h=Rt(e);N(E=>{Q(E,"entityKind",h.entityKinds),Q(E,"relationKind",h.relationKinds),Q(E,"tag",h.tags),Q(E,"owner",h.owners)})},resultSummary:"",placeholder:"Type a graph search, then press Enter or the search button"})}),r.jsxs(q,{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:()=>G(e=>!e),children:[r.jsx(lt,{className:"size-3"}),"Advanced"]}),tt?r.jsx(q,{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(Ir,{initial:!1,children:P?r.jsx(Kr.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(Se,{options:ye,selectedValues:te,onChange:e=>N(h=>{Q(h,"entityKind",e)}),placeholder:"Filter by entity type",emptyMessage:"No entity kinds match the current graph."}),r.jsx(Se,{options:J,selectedValues:se,onChange:e=>N(h=>{Q(h,"relationKind",e)}),placeholder:"Filter by relation type",emptyMessage:"No relation kinds match the current graph."}),r.jsx(Se,{options:he,selectedValues:ve,onChange:e=>N(h=>{Q(h,"tag",e)}),placeholder:"Filter by tag",emptyMessage:"No tags are available in the current filtered graph."}),r.jsx(Se,{options:pe,selectedValues:be,onChange:e=>N(h=>{Q(h,"owner",e)}),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:ce})]}),r.jsx("input",{type:"range",min:rt,max:nt,step:20,value:ce,onChange:e=>N(h=>{h.set("limit",e.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(qe,{type:"date",value:ae(ue),min:ae(b.facets.updatedAt.min),max:ae(oe??b.facets.updatedAt.max),onChange:e=>N(h=>{e.target.value?h.set("updatedFrom",e.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(qe,{type:"date",value:ae(oe),min:ae(ue??b.facets.updatedAt.min),max:ae(b.facets.updatedAt.max),onChange:e=>N(h=>{e.target.value?h.set("updatedTo",e.target.value):h.delete("updatedTo")})})]})]}),V==="hierarchy"?r.jsx(q,{variant:re?"primary":"secondary",size:"sm",className:"h-8 rounded-full px-3 text-xs",onClick:()=>N(e=>{re?e.delete("cross"):e.set("cross","1")}),children:re?"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 ${V==="graph"?"bg-white/[0.14] text-white":"text-white/52 hover:text-white"}`,onClick:()=>N(e=>{e.set("view","graph")}),children:"Graph"}),r.jsx("button",{type:"button",className:`rounded-full px-2.5 py-1.5 text-[10px] transition ${V==="hierarchy"?"bg-white/[0.14] text-white":"text-white/52 hover:text-white"}`,onClick:()=>N(e=>{e.set("view","hierarchy")}),children:"Hierarchy"})]}),V==="graph"?r.jsxs(r.Fragment,{children:[r.jsx(q,{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:()=>Z(!0),title:"Graph appearance settings","aria-label":"Open graph appearance settings",children:r.jsx(ct,{className:"size-3.5"})}),r.jsx(q,{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 e;return(e=l.current)==null?void 0:e.zoomIn()},title:"Zoom in","aria-label":"Zoom in",children:r.jsx(Jt,{className:"size-3.5"})}),r.jsx(q,{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 e;return(e=l.current)==null?void 0:e.zoomOut()},title:"Zoom out","aria-label":"Zoom out",children:r.jsx(Zt,{className:"size-3.5"})}),r.jsx(q,{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 e;return(e=l.current)==null?void 0:e.recenterOnFocus()},disabled:!W.focusNode,title:"Recenter","aria-label":"Recenter",children:r.jsx(er,{className:"size-3.5"})}),r.jsx(q,{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 e;return(e=l.current)==null?void 0:e.fit()},title:"Reset camera","aria-label":"Reset camera",children:r.jsx(tr,{className:"size-3.5"})}),null]}):null]})})]}),r.jsx(pt,{open:g&&!!W.focusNode,onOpenChange:v,eyebrow:"Knowledge Graph",title:((Xe=W.focusNode)==null?void 0:Xe.title)??"Focus node",description:((De=W.focusNode)==null?void 0:De.subtitle)??"Inspect the selected node and move deeper into the graph.",children:r.jsx(Sr,{focus:W,onOpenPage:e=>{v(!1),je(e)},onOpenNotes:e=>{v(!1),Ke(e)},onOpenHierarchy:e=>{v(!1),Oe(e)},onSelectNode:Ce,className:"border-0 bg-transparent p-0 shadow-none"})}),r.jsx(pt,{open:M,onOpenChange:S,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(ft,{title:"",description:"",compact:!0,query:j,onQueryChange:H,onQuerySubmit:He,submitLabel:"Search graph",options:Ve,selectedOptionIds:ge,onSelectedOptionIdsChange:e=>{const h=Rt(e);N(E=>{Q(E,"entityKind",h.entityKinds),Q(E,"relationKind",h.relationKinds),Q(E,"tag",h.tags),Q(E,"owner",h.owners)})},resultSummary:$,placeholder:"Type a graph search, then press Enter or the search button"})}),r.jsxs("div",{className:"grid gap-3",children:[r.jsx(Se,{options:ye,selectedValues:te,onChange:e=>N(h=>{Q(h,"entityKind",e)}),placeholder:"Filter by entity type",emptyMessage:"No entity kinds match the current graph."}),r.jsx(Se,{options:J,selectedValues:se,onChange:e=>N(h=>{Q(h,"relationKind",e)}),placeholder:"Filter by relation type",emptyMessage:"No relation kinds match the current graph."}),r.jsx(Se,{options:he,selectedValues:ve,onChange:e=>N(h=>{Q(h,"tag",e)}),placeholder:"Filter by tag",emptyMessage:"No tags are available in the current filtered graph."}),r.jsx(Se,{options:pe,selectedValues:be,onChange:e=>N(h=>{Q(h,"owner",e)}),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:ce})]}),r.jsx("input",{type:"range",min:rt,max:nt,step:20,value:ce,onChange:e=>N(h=>{h.set("limit",e.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(qe,{type:"date",value:ae(ue),min:ae(b.facets.updatedAt.min),max:ae(oe??b.facets.updatedAt.max),onChange:e=>N(h=>{e.target.value?h.set("updatedFrom",e.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(qe,{type:"date",value:ae(oe),min:ae(ue??b.facets.updatedAt.min),max:ae(b.facets.updatedAt.max),onChange:e=>N(h=>{e.target.value?h.set("updatedTo",e.target.value):h.delete("updatedTo")})})]})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(q,{variant:"secondary",size:"sm",onClick:Ae,children:"Reset"}),r.jsx(q,{variant:"primary",size:"sm",onClick:()=>S(!1),children:"Done"})]})]})]})}),r.jsx(rr,{open:A,onOpenChange:Z,children:r.jsxs(nr,{children:[r.jsx(ar,{className:"fixed inset-0 z-40 bg-[rgba(4,8,18,0.72)] backdrop-blur-xl"}),r.jsxs(sr,{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(ir,{className:"sr-only",children:"Knowledge Graph appearance settings"}),r.jsx(or,{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(ut,{asChild:!0,children:r.jsx(_r,{"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:k.focusRepulsion.toFixed(2)})]}),r.jsx("input",{"aria-label":"Focused repulsion",type:"range",min:"0.6",max:String(At),step:"0.05",value:k.focusRepulsion,onChange:e=>de("focusRepulsion",Number(e.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:k.focusDiffusion.toFixed(2)})]}),r.jsx("input",{"aria-label":"Focus diffusion",type:"range",min:"0.6",max:String(Pt),step:"0.05",value:k.focusDiffusion,onChange:e=>de("focusDiffusion",Number(e.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:k.focusSpringReductionMax.toFixed(2)})]}),r.jsx("input",{"aria-label":"Spring reduction max",type:"range",min:"0",max:String(Dt),step:"0.02",value:k.focusSpringReductionMax,onChange:e=>de("focusSpringReductionMax",Number(e.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:k.focusSpringReductionDiffusion.toFixed(2)})]}),r.jsx("input",{"aria-label":"Spring reduction diffusion",type:"range",min:"0.6",max:String(Tt),step:"0.05",value:k.focusSpringReductionDiffusion,onChange:e=>de("focusSpringReductionDiffusion",Number(e.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:k.edgeSpringStrength.toFixed(2)})]}),r.jsx("input",{"aria-label":"Edge spring strength",type:"range",min:String(zt),max:String(Lt),step:"0.05",value:k.edgeSpringStrength,onChange:e=>de("edgeSpringStrength",Number(e.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:k.gravityStrength.toFixed(2)})]}),r.jsx("input",{"aria-label":"Gravity strength",type:"range",min:"0",max:String($t),step:"0.05",value:k.gravityStrength,onChange:e=>de("gravityStrength",Number(e.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:k.focusShellSpacing.toFixed(2)})]}),r.jsx("input",{"aria-label":"Focus shell spacing",type:"range",min:String(Yt),max:String(Ht),step:"0.05",value:k.focusShellSpacing,onChange:e=>de("focusShellSpacing",Number(e.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(q,{variant:"secondary",onClick:()=>K(le),children:"Reset defaults"}),r.jsx(ut,{asChild:!0,children:r.jsx(q,{variant:"primary",children:"Done"})})]})]})]})]})}),null]})}export{Gn as KnowledgeGraphPage};
@@ -1 +0,0 @@
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-CF4J4R9L.js";import{F as Le}from"./floating-action-menu-Fs_ZiUMo.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 +0,0 @@
1
- import{j as e}from"./vendor-DHkYh85p.js";import{C as l,aq as c,Z as x}from"./index-CF4J4R9L.js";function o({label:t,value:n,tone:a="default",detail:s,help:r,className:i}){return e.jsxs(l,{className:x("rounded-[22px] p-4",a==="core"&&"bg-[linear-gradient(180deg,rgba(29,24,48,0.95),rgba(17,17,31,0.92))]",a==="psyche"&&"bg-[linear-gradient(180deg,rgba(18,31,34,0.96),rgba(13,24,27,0.94))]",i),children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:[e.jsx("span",{children:t}),r?e.jsx(c,{label:`Explain ${t}`,title:t,content:r,panelClassName:"normal-case tracking-normal"}):null]}),e.jsx("div",{className:"mt-3 font-display text-3xl text-white",children:n}),s?e.jsx("div",{className:"mt-2 text-sm text-white/56",children:s}):null]})}export{o as M};