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
@@ -0,0 +1 @@
1
+ import{b0 as ht,bD as vt,cF as ft,cG as bt,bf as jt,aG as yt,j as e,aK as Nt,b3 as de,c2 as kt,r as x,aC as ve,c7 as Ct,b4 as It}from"./vendor-Dnkkx2co.js";import{j as St,i as Ke,k as N}from"./state-vCcAT5Hq.js";import{bk as Z,Z as U,c as I,I as v,L as Je,a as et,B as u,C as j,U as tt,H as wt,u as Pt,s as Ft,c1 as Ye,c2 as Lt,c3 as Tt,c4 as Mt,c5 as Dt,c6 as At,c7 as Et,c8 as zt,c9 as _t,ca as Gt,cb as Ot,cc as $t,cd as Bt,ce as qt,cf as Qt,cg as Rt,E as Ut,ch as Wt,T as E,ci as Xe}from"./index-EqQsXoat.js";import{P as Ht}from"./page-hero-ffKzgyW3.js";import{R as Kt,P as Yt,O as Xt,C as Zt,T as Vt,D as Jt,a as es}from"./ui-C1iwpj2-.js";import"./motion-Lt5B1XuE.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";const st=[{id:"overview",label:"Overview",icon:ht},{id:"map",label:"Map",icon:vt},{id:"table",label:"Table",icon:ft},{id:"history",label:"History",icon:bt},{id:"contexts",label:"Contexts",icon:jt},{id:"concepts",label:"Concepts",icon:yt}],ts=new Set(["projects","tasks","strategies","habits"]),oe=[{value:"projects",label:"Projects",description:"Goals and projects already living in Forge.",mode:"forge"},{value:"tasks",label:"Tasks",description:"Execution-level work choices inside Forge.",mode:"forge"},{value:"strategies",label:"Strategies",description:"Plan shapes and sequencing choices in Forge.",mode:"forge"},{value:"habits",label:"Habits",description:"Recurring behaviors and routines from Forge.",mode:"forge"},{value:"activities",label:"Activities",description:"Movement, leisure, and social setting concepts.",mode:"concept"},{value:"food",label:"Food",description:"Cuisine, meal mood, and drink preferences.",mode:"concept"},{value:"places",label:"Places",description:"Living environments, venues, and trip shapes.",mode:"concept"},{value:"countries",label:"Countries",description:"Country-level attraction and lifestyle fit.",mode:"concept"},{value:"fashion",label:"Fashion",description:"Silhouette, material, and palette preferences.",mode:"concept"},{value:"people",label:"People",description:"Presence, body-type, and conversation preferences.",mode:"concept"},{value:"media",label:"Media",description:"Film, reading, and music taste.",mode:"concept"},{value:"tools",label:"Tools",description:"Workflow and capture preferences.",mode:"concept"},{value:"custom",label:"Custom",description:"General-purpose concept libraries you control.",mode:"concept"}],fe={novelty:"Novelty",simplicity:"Simplicity",rigor:"Rigor",aesthetics:"Aesthetics",depth:"Depth",structure:"Structure",familiarity:"Familiarity",surprise:"Surprise"},ne={novelty:0,simplicity:0,rigor:0,aesthetics:0,depth:0,structure:0,familiarity:0,surprise:0},Ze={liked:"bg-[var(--ui-success-soft)] text-[var(--success)]",disliked:"bg-[var(--ui-danger-soft)] text-[var(--danger)]",uncertain:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",vetoed:"bg-[var(--ui-danger-soft)] text-[var(--danger)]",bookmarked:"bg-[var(--ui-info-soft)] text-[var(--info)]",favorite:"bg-[var(--ui-warning-soft)] text-[var(--warning)]",must_have:"bg-[var(--ui-accent-soft)] text-[var(--primary)]",neutral:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]"},ss=[{signalType:"favorite",label:"Favorite"},{signalType:"must_have",label:"Must-have"},{signalType:"bookmark",label:"Bookmark"},{signalType:"compare_later",label:"Later"},{signalType:"neutral",label:"Neutral"},{signalType:"veto",label:"Veto"}];function le(i){return i.trim().toLowerCase()}function R(i){return`${Math.round(i*100)}%`}function as(i){return[...i.goals.map(a=>({entityType:"goal",entityId:a.id,domain:"projects",label:a.title,description:a.description,user:a.user,href:`/goals/${a.id}`,searchText:Z([a.title,a.description,a.status,a.horizon],a)})),...i.dashboard.projects.map(a=>({entityType:"project",entityId:a.id,domain:"projects",label:a.title,description:a.description,user:a.user,href:`/projects/${a.id}`,searchText:Z([a.title,a.description,a.status,a.goalTitle],a)})),...i.tasks.map(a=>({entityType:"task",entityId:a.id,domain:"tasks",label:a.title,description:a.description,user:a.user,href:`/tasks/${a.id}`,searchText:Z([a.title,a.description,a.status,a.priority,a.owner],a)})),...i.strategies.map(a=>({entityType:"strategy",entityId:a.id,domain:"strategies",label:a.title,description:a.overview||a.endStateDescription,user:a.user,href:`/strategies/${a.id}`,searchText:Z([a.title,a.overview,a.endStateDescription,a.status],a)})),...i.habits.map(a=>({entityType:"habit",entityId:a.id,domain:"habits",label:a.title,description:a.description,user:a.user,href:null,searchText:Z([a.title,a.description,a.status,a.frequency],a)}))]}function is(i,a){return!i||!a?null:i==="goal"?`/goals/${a}`:i==="project"?`/projects/${a}`:i==="task"?`/tasks/${a}`:i==="strategy"?`/strategies/${a}`:null}function ce(i){return i.manualStatus??i.status}function rs(i){return i&&st.some(a=>a.id===i)?i:"overview"}function ns(i){return i.summary.totalItems<2?{title:"Forge does not know enough yet.",description:"Start the game so Forge can ask a few clean comparisons and build a real preference model."}:i.summary.averageConfidence<.28?{title:"Forge has a rough sketch, not a stable read.",description:"There is some signal, but the model still needs more rounds before its preferences are trustworthy."}:{title:"This is what Forge currently thinks.",description:"The summary below is the current best model for this user, this domain, and the active context."}}function ls({summary:i}){const a=Math.max(-1,Math.min(1,i.leaning)),o=(a+1)/2*100;return e.jsxs("div",{className:"grid gap-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs text-[var(--ui-ink-soft)]",children:[e.jsx("span",{children:fe[i.dimensionId]}),e.jsxs("span",{children:[i.movement>.08?"Rising":i.movement<-.08?"Falling":"Stable"," ","· ",R(i.confidence)]})]}),e.jsxs("div",{className:"relative h-2 rounded-full bg-[var(--ui-surface-2)]",children:[e.jsx("div",{className:"absolute inset-y-0 left-1/2 w-px bg-[var(--ui-border-strong)]"}),e.jsx("div",{className:U("absolute top-1/2 size-3 -translate-x-1/2 -translate-y-1/2 rounded-full border border-[var(--ui-border-strong)]",a>=0?"bg-[var(--success)]":"bg-[var(--danger)]"),style:{left:`${o}%`}})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 text-[11px] uppercase tracking-[0.12em] text-[var(--ui-ink-faint)]",children:[e.jsxs("span",{children:[a>=0?"Leans toward":"Leans away from"," ",fe[i.dimensionId].toLowerCase()]}),e.jsxs("span",{children:["Context ",R(i.contextSensitivity)]})]})]})}function Ve({title:i,description:a,sideLabel:o,onClick:g}){return e.jsxs("button",{type:"button",className:"grid min-h-[220px] gap-4 rounded-[28px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] p-5 text-left transition hover:border-[color-mix(in_srgb,var(--primary)_40%,transparent)] hover:bg-[var(--ui-surface-hover)]",onClick:g,children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:o}),e.jsx("div",{className:"font-display text-3xl text-[var(--ui-ink-strong)]",children:i}),e.jsx("div",{className:"max-w-[36ch] text-sm leading-6 text-[var(--ui-ink-soft)]",children:a||"Choose the one that feels more right."}),e.jsx("div",{className:"mt-auto text-sm text-[var(--primary)]",children:"Click this card"})]})}function cs({state:i,onOpenChange:a,error:o,loading:g,workspaceLoading:k,activeWorkspace:h,conceptSearchQuery:w,onConceptSearchQueryChange:p,filteredCatalogs:S,onSelectDomain:V,onStartCatalogGame:G,onJudge:J,onSignal:O}){return e.jsx(Kt,{open:i.open,onOpenChange:a,children:e.jsxs(Yt,{children:[e.jsx(Xt,{className:"fixed inset-0 z-40 bg-[var(--ui-overlay-backdrop)] backdrop-blur-xl"}),e.jsxs(Zt,{className:"fixed inset-x-4 bottom-4 top-4 z-50 overflow-y-auto rounded-[32px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-modal)] shadow-[var(--ui-shadow-floating)] md:inset-x-10 lg:left-1/2 lg:right-auto lg:w-[min(72rem,calc(100vw-3rem))] lg:-translate-x-1/2",children:[e.jsx(Vt,{className:"sr-only",children:"Preference game"}),e.jsx(Jt,{className:"sr-only",children:"Start comparison rounds from a Forge domain or concept list."}),e.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between gap-4 border-b border-[var(--ui-border-subtle)] bg-[color-mix(in_srgb,var(--surface-glass)_94%,transparent)] px-5 py-4 backdrop-blur-xl",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Preference game"}),e.jsx("div",{className:"mt-1 font-display text-2xl text-[var(--ui-ink-strong)]",children:i.phase==="domain"?"Choose a domain":i.phase==="catalog"?"Choose a concept list":"Pick the better fit"})]}),e.jsx(es,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":"Close preference game",className:"rounded-full bg-[var(--ui-surface-2)] p-2 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",children:e.jsx(Nt,{className:"size-4"})})})]}),e.jsxs("div",{className:"grid gap-5 px-5 py-5",children:[o?e.jsx("div",{className:"rounded-[18px] border border-[color-mix(in_srgb,var(--danger)_28%,transparent)] bg-[var(--ui-danger-soft)] px-4 py-3 text-sm text-[var(--danger)]",children:o}):null,i.phase==="domain"?e.jsx(ds,{onSelectDomain:V}):null,i.phase==="catalog"?e.jsx(os,{domain:i.domain,query:w,onQueryChange:p,catalogs:S,onStartCatalogGame:G}):null,i.phase==="play"?e.jsx(us,{domain:i.domain,loading:g||k,activeWorkspace:h,onJudge:J,onSignal:O}):null]})]})]})})}function ds({onSelectDomain:i}){return e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:oe.map(a=>e.jsxs("button",{type:"button",className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-5 py-5 text-left transition hover:border-[color-mix(in_srgb,var(--primary)_30%,transparent)] hover:bg-[var(--ui-accent-soft)]",onClick:()=>i(a.value),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:a.label}),e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:a.mode==="forge"?"Forge":"Concept"})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:a.description})]},a.value))})}function os({domain:i,query:a,onQueryChange:o,catalogs:g,onStartCatalogGame:k}){return e.jsxs("div",{className:"grid gap-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Pick the concept list Forge should draw from. You do not need to assemble the items yourself."}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"size-4 text-[var(--ui-ink-faint)]"}),e.jsx(v,{value:a,onChange:h=>o(h.target.value),placeholder:"Search concept lists"})]}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:g.length>0?g.map(h=>e.jsxs("button",{type:"button",className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-5 py-5 text-left transition hover:border-[color-mix(in_srgb,var(--primary)_30%,transparent)] hover:bg-[var(--ui-accent-soft)]",onClick:()=>k(i,h.id),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:h.title}),e.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[h.items.length," items"]})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:h.description||"No description yet."})]},h.id)):e.jsx("div",{className:"rounded-[24px] bg-[var(--ui-surface-1)] px-5 py-6 text-sm text-[var(--ui-ink-soft)]",children:"No concept list matches that search yet."})})]})}function us({domain:i,loading:a,activeWorkspace:o,onJudge:g,onSignal:k}){var w;const h=(o==null?void 0:o.compare.nextPair)??null;return a?e.jsx(Je,{eyebrow:"Preference game",title:"Preparing the next round",description:"Forge is lining up comparison candidates."}):h?e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:((w=oe.find(p=>p.value===i))==null?void 0:w.label)??i}),e.jsx("span",{children:o==null?void 0:o.selectedContext.name}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[(o==null?void 0:o.compare.pendingCount)??0," queued comparisons"]})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(Ve,{title:h.left.label,description:h.left.description,sideLabel:"Left",onClick:()=>g("left",1)}),e.jsx(Ve,{title:h.right.label,description:h.right.description,sideLabel:"Right",onClick:()=>g("right",1)})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{onClick:()=>g("left",1),children:"Left"}),e.jsx(u,{onClick:()=>g("right",1),children:"Right"}),e.jsx(u,{variant:"secondary",onClick:()=>g("left",1.75),children:"Strong left"}),e.jsx(u,{variant:"secondary",onClick:()=>g("right",1.75),children:"Strong right"}),e.jsx(u,{variant:"secondary",onClick:()=>g("tie",1),children:"Tie"}),e.jsx(u,{variant:"secondary",onClick:()=>g("skip",1),children:"Skip"})]}),e.jsx("div",{className:"grid gap-4 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4 lg:grid-cols-2",children:[h.left,h.right].map(p=>e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:p.label}),e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Quick signals"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ss.map(S=>e.jsx(u,{variant:"secondary",size:"sm",onClick:()=>k(p.id,S.signalType),children:S.label},`${p.id}-${S.signalType}`))})]},p.id))})]}):e.jsx(et,{eyebrow:"Preference game",title:"No pair is ready yet",description:"Forge needs more items in this domain before it can keep asking comparisons."})}function ms({users:i,user:a,selectedUserId:o,selectedDomain:g,workspace:k,onPatchSearch:h}){var w;return e.jsxs(j,{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-3 xl:grid-cols-[minmax(0,1.2fr)_minmax(0,1fr)]",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Active user"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("select",{value:o,onChange:p=>h({userId:p.target.value,contextId:null,focusItem:null}),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none transition focus:border-[var(--primary)]",children:i.map(p=>e.jsxs("option",{value:p.id,children:[p.displayName," · ",p.kind]},p.id))}),e.jsx(tt,{user:a}),e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:wt(a)})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Domain"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:oe.map(p=>e.jsx("button",{type:"button",className:U("rounded-full border px-3 py-2 text-sm transition",p.value===g?"border-[var(--primary)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>h({domain:p.value,contextId:null,focusItem:null}),children:p.label},p.value))}),e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:(w=oe.find(p=>p.value===g))==null?void 0:w.description})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:k.selectedContext.name}),e.jsx("span",{children:k.selectedContext.shareMode}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[k.compare.pendingCount," queued comparisons"]}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[k.libraries.totalCatalogItems," concept items ready"]})]})]})}function xs({selectedTab:i,onSelectTab:a}){return e.jsx("div",{className:"flex flex-wrap gap-2",children:st.map(o=>e.jsxs("button",{type:"button",className:U("inline-flex items-center gap-2 rounded-full border px-3 py-2 text-sm transition",o.id===i?"border-[var(--primary)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>a(o.id),children:[e.jsx(o.icon,{className:"size-4"}),o.label]},o.id))})}function ks(){var qe,Qe,Re;const i=Pt(),a=St(),[o,g]=kt(),[k,h]=x.useState(""),[w,p]=x.useState(""),[S,V]=x.useState(""),[G,J]=x.useState(""),[O,be]=x.useState(""),[z,M]=x.useState({open:!1,phase:"domain",domain:o.get("domain")??"projects"}),[at,D]=x.useState(null),[it,ue]=x.useState(!1),[je,$]=x.useState(null),[f,F]=x.useState({label:"",description:"",tags:"",manualStatus:"",manualScore:"",confidenceLock:"",bookmarked:!1,compareLater:!1,frozen:!1,featureWeights:{novelty:"0",simplicity:"0",rigor:"0",aesthetics:"0",depth:"0",structure:"0",familiarity:"0",surprise:"0"}}),[_,ee]=x.useState({label:"",description:"",tags:""}),[L,W]=x.useState({name:"",description:"",shareMode:"blended",decayDays:"90"}),[H,me]=x.useState({title:"",description:""}),[rt,te]=x.useState({}),[ye,xe]=x.useState(null),[se,pe]=x.useState({title:"",description:""}),[nt,ge]=x.useState(null),[B,ae]=x.useState({label:"",description:"",tags:""}),m=o.get("userId")??Ft(i.selectedUserIds)??((qe=i.snapshot.users[0])==null?void 0:qe.id)??null,C=o.get("domain")??"projects",T=rs(o.get("tab")),K=o.get("contextId"),ie=o.get("focusItem"),lt=x.useMemo(()=>i.snapshot.users.find(t=>t.id===m)??null,[m,i.snapshot.users]),re=x.useMemo(()=>as(i.snapshot),[i.snapshot]),Y=Ke({queryKey:["forge-preferences",m,C,K],queryFn:async()=>(await Xe({userId:m??void 0,domain:C,contextId:K??void 0})).workspace,enabled:!!m}),Ne=Ke({queryKey:["forge-preferences-game",m,z.domain,K],queryFn:async()=>(await Xe({userId:m??void 0,domain:z.domain,contextId:K??void 0})).workspace,enabled:!!m&&z.open}),r=Y.data??null,P=z.domain===C?r:Ne.data??null;x.useEffect(()=>{var s;if(!r)return;const t=ie&&r.scores.some(c=>c.itemId===ie)?ie:((s=r.scores[0])==null?void 0:s.itemId)??null;$(c=>c&&r.scores.some(n=>n.itemId===c)?c:t)},[ie,r]);const he=x.useMemo(()=>{if(!r)return[];const t=le(k);return t?r.scores.filter(s=>{var c,n,l;return[((c=s.item)==null?void 0:c.label)??"",((n=s.item)==null?void 0:n.description)??"",((l=s.item)==null?void 0:l.tags.join(" "))??"",s.status,s.manualStatus??"",s.dominantDimensions.join(" "),s.explanation.join(" ")].join(" ").toLowerCase().includes(t)}):r.scores},[k,r]),d=he.find(t=>t.itemId===je)??(r==null?void 0:r.scores.find(t=>t.itemId===je))??he[0]??(r==null?void 0:r.scores[0])??null;x.useEffect(()=>{var t,s,c,n,l,y,X,Q,Ue,We,He;d&&F({label:((t=d.item)==null?void 0:t.label)??"",description:((s=d.item)==null?void 0:s.description)??"",tags:((c=d.item)==null?void 0:c.tags.join(", "))??"",manualStatus:d.manualStatus??"",manualScore:typeof d.manualScore=="number"?String(d.manualScore):"",confidenceLock:typeof d.confidenceLock=="number"?String(d.confidenceLock):"",bookmarked:d.bookmarked,compareLater:d.compareLater,frozen:d.frozen,featureWeights:{novelty:String(((n=d.item)==null?void 0:n.featureWeights.novelty)??0),simplicity:String(((l=d.item)==null?void 0:l.featureWeights.simplicity)??0),rigor:String(((y=d.item)==null?void 0:y.featureWeights.rigor)??0),aesthetics:String(((X=d.item)==null?void 0:X.featureWeights.aesthetics)??0),depth:String(((Q=d.item)==null?void 0:Q.featureWeights.depth)??0),structure:String(((Ue=d.item)==null?void 0:Ue.featureWeights.structure)??0),familiarity:String(((We=d.item)==null?void 0:We.featureWeights.familiarity)??0),surprise:String(((He=d.item)==null?void 0:He.featureWeights.surprise)??0)}})},[d]);const ke=x.useMemo(()=>{const t=le(w);return re.filter(s=>s.domain===C).filter(s=>t?s.searchText.includes(t):!0).slice(0,12)},[re,w,C]),Ce=x.useMemo(()=>{const t=T==="concepts"?r:P??r,s=(t==null?void 0:t.catalogs)??[],c=le(S);return c?s.filter(n=>[n.title,n.description,n.source,...n.items.flatMap(l=>[l.label,l.description,l.tags.join(" ")])].join(" ").toLowerCase().includes(c)):s},[P,S,T,r]),b=async()=>{await a.invalidateQueries({queryKey:["forge-preferences"]}),await a.invalidateQueries({queryKey:["forge-preferences-game"]})},Ie=N({mutationFn:Ye,onSuccess:b}),Se=N({mutationFn:Lt,onSuccess:async({item:t})=>{await b(),ee({label:"",description:"",tags:""}),$(t.id)}}),we=N({mutationFn:Tt,onSuccess:async()=>{await b(),me({title:"",description:""}),g(t=>{const s=new URLSearchParams(t);return s.set("tab","concepts"),s})}}),Pe=N({mutationFn:({catalogId:t,patch:s})=>Mt(t,s),onSuccess:async()=>{await b(),xe(null)}}),Fe=N({mutationFn:Dt,onSuccess:b}),Le=N({mutationFn:At,onSuccess:async()=>{await b()}}),Te=N({mutationFn:({catalogItemId:t,patch:s})=>Et(t,s),onSuccess:async()=>{await b(),ge(null)}}),Me=N({mutationFn:zt,onSuccess:b}),ct=N({mutationFn:_t,onSuccess:async()=>{await b(),M(t=>({...t,phase:"play"}))}}),dt=N({mutationFn:Gt,onSuccess:b}),ot=N({mutationFn:Ot,onSuccess:b}),De=N({mutationFn:async()=>{!(d!=null&&d.item)||!m||!r||(await $t(d.item.id,{label:f.label,description:f.description,tags:f.tags.split(",").map(t=>t.trim()).filter(Boolean),featureWeights:Object.fromEntries(Object.keys(ne).map(t=>[t,Number(f.featureWeights[t]||0)]))}),await Bt(d.item.id,{userId:m,domain:C,contextId:r.selectedContext.id,manualStatus:f.manualStatus||null,manualScore:f.manualScore.trim().length>0?Number(f.manualScore):null,confidenceLock:f.confidenceLock.trim().length>0?Number(f.confidenceLock):null,bookmarked:f.bookmarked,compareLater:f.compareLater,frozen:f.frozen}))},onSuccess:b}),Ae=N({mutationFn:qt,onSuccess:async({context:t})=>{await b(),W({name:"",description:"",shareMode:"blended",decayDays:"90"}),g(s=>{const c=new URLSearchParams(s);return c.set("contextId",t.id),c.set("tab","contexts"),c})}}),Ee=N({mutationFn:Qt,onSuccess:async()=>{await b(),J(""),be("")}}),q=N({mutationFn:({contextId:t,patch:s})=>Rt(t,s),onSuccess:b}),A=t=>{g(s=>{const c=new URLSearchParams(s);for(const[n,l]of Object.entries(t))l?c.set(n,l):c.delete(n);return c})},ze=(t=C)=>{D(null),M({open:!0,phase:"domain",domain:t})},ut=async t=>{if(!m)return;D(null),ue(!0);const s=re.filter(l=>{var y;return l.domain===t&&((y=l.user)==null?void 0:y.id)===m}),c=re.filter(l=>l.domain===t),n=(s.length>0?s:c).slice(0,12);if(n.length<2){D("Forge needs at least two matching records in this domain before it can start the game."),ue(!1),M(l=>({...l,phase:"domain"}));return}try{A({domain:t,tab:"overview",contextId:null,focusItem:null}),await Promise.all(n.map(l=>Ye({userId:m,domain:t,entityType:l.entityType,entityId:l.entityId,label:l.label,description:l.description,tags:[]}))),await b(),M({open:!0,phase:"play",domain:t})}catch(l){D(l instanceof Error?l.message:"Forge could not start the game."),M(y=>({...y,phase:"domain"}))}finally{ue(!1)}},_e=async(t,s)=>{if(m){D(null),A({domain:t,tab:"overview",contextId:null,focusItem:null});try{await ct.mutateAsync({userId:m,domain:t,contextId:K??void 0,catalogId:s}),M({open:!0,phase:"play",domain:t})}catch(c){D(c instanceof Error?c.message:"Forge could not start the game.")}}},mt=async t=>{if(ts.has(t)){await ut(t);return}D(null),M({open:!0,phase:"catalog",domain:t})},xt=async(t,s=1)=>{if(!m||!(P!=null&&P.compare.nextPair))return;const c=P.compare.nextPair;await dt.mutateAsync({userId:m,domain:z.domain,contextId:P.selectedContext.id,leftItemId:c.left.id,rightItemId:c.right.id,outcome:t,strength:s})},pt=async(t,s)=>{!m||!P||await ot.mutateAsync({userId:m,domain:z.domain,contextId:P.selectedContext.id,itemId:t,signalType:s,strength:1})};if(!m)return e.jsx(et,{eyebrow:"Preferences",title:"No Forge user available",description:"Forge needs at least one human or bot user before it can learn preferences."});if(Y.isLoading&&!r)return e.jsx(Je,{eyebrow:"Preferences",title:"Loading preference model",description:"Reconstructing current scores, uncertainty, and concept libraries."});if(Y.isError)return e.jsx(Ut,{eyebrow:"Preferences",error:Y.error,onRetry:()=>void Y.refetch()});if(!r)return null;const gt=[...r.dimensions].sort((t,s)=>s.confidence-t.confidence).slice(0,6),Ge=r.scores.filter(t=>ce(t)==="liked"||ce(t)==="favorite").slice(0,4),Oe=r.scores.filter(t=>t.uncertainty>=.5).slice(0,4),$e=ns(r),Be=is(((Qe=d==null?void 0:d.item)==null?void 0:Qe.sourceEntityType)??null,((Re=d==null?void 0:d.item)==null?void 0:Re.sourceEntityId)??null);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsx(Ht,{title:"Preferences",titleText:"Preferences",description:"Forge keeps an explicit, editable model of what one user prefers in one domain. The first job of this page is to show what Forge currently knows.",badge:`${r.summary.totalItems} items · ${R(r.summary.averageConfidence)} confidence`,actions:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{className:"min-w-[10rem]",onClick:()=>ze(),children:"Start the game"}),e.jsx(u,{variant:"secondary",onClick:()=>void b(),children:"Refresh model"})]})}),e.jsx(Wt,{}),e.jsx(ms,{users:i.snapshot.users,user:lt,selectedUserId:m,selectedDomain:C,workspace:r,onPatchSearch:A}),e.jsx(xs,{selectedTab:T,onSelectTab:t=>A({tab:t})}),T==="overview"?e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.3fr)_360px]",children:[e.jsxs(j,{className:"grid gap-5",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"What Forge knows"}),e.jsx("div",{className:"font-display text-3xl text-[var(--ui-ink-strong)]",children:$e.title}),e.jsx("div",{className:"max-w-[70ch] text-sm leading-6 text-[var(--ui-ink-soft)]",children:$e.description})]}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[{label:"Known items",value:r.summary.totalItems,detail:"Items inside this domain"},{label:"Confidence",value:R(r.summary.averageConfidence),detail:"Average certainty"},{label:"Unknowns",value:r.summary.uncertainCount,detail:"Need more rounds"},{label:"Libraries",value:r.libraries.totalCatalogItems,detail:"Seeded concepts ready"}].map(t=>e.jsxs("div",{className:"rounded-[22px] bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:t.label}),e.jsx("div",{className:"mt-2 font-display text-3xl text-[var(--ui-ink-strong)]",children:t.value}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:t.detail})]},t.label))}),e.jsx("div",{className:"grid gap-4 lg:grid-cols-2",children:gt.map(t=>e.jsx(ls,{summary:t},t.dimensionId))})]}),e.jsxs(j,{className:"grid gap-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Next move"}),e.jsx("div",{className:"font-display text-2xl text-[var(--ui-ink-strong)]",children:"Start the game"}),e.jsx("div",{className:"text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Forge will ask a small number of pairwise questions. You choose a domain, Forge supplies the candidates, and the model tightens from there."}),e.jsx(u,{className:"w-full",onClick:()=>ze(),children:"Start the game"}),e.jsxs("div",{className:"grid gap-3 rounded-[22px] bg-[var(--ui-surface-2)] px-4 py-4 text-sm text-[var(--ui-ink-soft)]",children:[e.jsxs("div",{children:["Current queue: ",r.compare.pendingCount," comparison",r.compare.pendingCount===1?"":"s"]}),e.jsxs("div",{children:["Active context: ",r.selectedContext.name]}),e.jsxs("div",{children:["Library coverage: ",r.libraries.seededCatalogCount," ","seeded lists and ",r.libraries.customCatalogCount," ","custom lists"]})]})]})]}),e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.3fr)_360px]",children:[e.jsxs(j,{className:"grid gap-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.16em] text-[var(--ui-ink-faint)]",children:"Preference map"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Green drifts positive, red drifts negative, and low opacity still means uncertainty."})]}),e.jsx(ve,{to:"?tab=map",className:"text-sm text-[var(--primary)]",children:"Open full map"})]}),e.jsxs("div",{className:"relative min-h-[340px] overflow-hidden rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)]",children:[e.jsx("div",{className:"absolute inset-x-0 top-1/2 h-px bg-[var(--ui-border-subtle)]"}),e.jsx("div",{className:"absolute inset-y-0 left-1/2 w-px bg-[var(--ui-border-subtle)]"}),r.map.map(t=>e.jsx("button",{type:"button",className:U("absolute -translate-x-1/2 -translate-y-1/2 rounded-full border px-2 py-1 text-[11px] shadow-[var(--ui-shadow-soft)] transition hover:scale-[1.04]",t.itemId===(d==null?void 0:d.itemId)?"border-[var(--ui-border-strong)] bg-[var(--ui-surface-active)] text-[var(--ui-ink-strong)]":t.score>=0?"border-[color-mix(in_srgb,var(--success)_34%,transparent)] bg-[var(--ui-success-soft)] text-[var(--ui-ink-strong)]":"border-[color-mix(in_srgb,var(--danger)_34%,transparent)] bg-[var(--ui-danger-soft)] text-[var(--ui-ink-strong)]"),style:{left:`${50+t.x*30}%`,top:`${50-t.y*30}%`,opacity:.55+t.confidence*.45},onClick:()=>$(t.itemId),children:t.label},t.itemId))]})]}),e.jsxs(j,{className:"grid gap-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Best read so far"}),e.jsx("div",{className:"grid gap-2",children:Ge.length>0?Ge.map(t=>{var s;return e.jsxs("button",{type:"button",className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-3 text-left transition hover:bg-[var(--ui-surface-hover)]",onClick:()=>{$(t.itemId),A({focusItem:t.itemId})},children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:((s=t.item)==null?void 0:s.label)??t.itemId}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:t.explanation[0]||"Forge has positive evidence here."})]},t.itemId)}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-3 text-sm text-[var(--ui-ink-soft)]",children:"No clear positives yet. A few comparison rounds will change that."})}),e.jsxs("div",{className:"border-t border-[var(--ui-border-subtle)] pt-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Biggest unknowns"}),e.jsx("div",{className:"mt-3 grid gap-2",children:Oe.length>0?Oe.map(t=>{var s;return e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-3 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:((s=t.item)==null?void 0:s.label)??t.itemId}),e.jsxs("div",{className:"mt-1",children:["Uncertainty ",R(t.uncertainty)]})]},t.itemId)}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-3 text-sm text-[var(--ui-ink-soft)]",children:"The current unknown list is short."})})]})]})]}),e.jsxs(j,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Bring in Forge records"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Search goals, projects, tasks, strategies, or habits across human and bot users, then send them straight into this model."})]}),e.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[ke.length," visible"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"size-4 text-[var(--ui-ink-muted)]"}),e.jsx(v,{value:w,onChange:t=>p(t.target.value),placeholder:"Search across owners, handles, user kind, title, and description"})]}),e.jsx("div",{className:"grid gap-2",children:ke.map(t=>e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-medium text-[var(--ui-ink-strong)]",children:t.label}),e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:t.entityType}),t.user?e.jsx(tt,{user:t.user,compact:!0}):null]}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:t.description||"No description yet."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.href?e.jsx(ve,{to:t.href,children:e.jsx(u,{variant:"ghost",size:"sm",children:"Open"})}):null,e.jsx(u,{variant:"secondary",size:"sm",pending:Ie.isPending,pendingLabel:"Adding",onClick:()=>void Ie.mutateAsync({userId:m,domain:C,entityType:t.entityType,entityId:t.entityId,label:t.label,description:t.description,tags:[]}),children:"Add to model"})]})]},`${t.entityType}-${t.entityId}`))})]})]}):null,T==="map"?e.jsxs(j,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Full map"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Click a point to inspect why Forge believes it belongs there."})]}),e.jsxs("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:[r.map.length," plotted items"]})]}),e.jsxs("div",{className:"relative min-h-[520px] overflow-hidden rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)]",children:[e.jsx("div",{className:"absolute inset-x-0 top-1/2 h-px bg-[var(--ui-border-subtle)]"}),e.jsx("div",{className:"absolute inset-y-0 left-1/2 w-px bg-[var(--ui-border-subtle)]"}),r.map.map(t=>e.jsx("button",{type:"button",className:U("absolute -translate-x-1/2 -translate-y-1/2 rounded-full border px-3 py-1 text-xs transition hover:scale-[1.04]",t.itemId===(d==null?void 0:d.itemId)?"border-[var(--ui-border-strong)] bg-[var(--ui-surface-active)] text-[var(--ui-ink-strong)]":t.score>=0?"border-[color-mix(in_srgb,var(--success)_34%,transparent)] bg-[var(--ui-success-soft)] text-[var(--ui-ink-strong)]":"border-[color-mix(in_srgb,var(--danger)_34%,transparent)] bg-[var(--ui-danger-soft)] text-[var(--ui-ink-strong)]"),style:{left:`${50+t.x*34}%`,top:`${50-t.y*34}%`,opacity:.45+t.confidence*.55},onClick:()=>{$(t.itemId),A({focusItem:t.itemId})},children:t.label},t.itemId))]})]}):null,T==="table"?e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.2fr)_380px]",children:[e.jsxs(j,{className:"grid gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"size-4 text-[var(--ui-ink-muted)]"}),e.jsx(v,{value:k,onChange:t=>h(t.target.value),placeholder:"Search learned items, explanations, tags, or dominant dimensions"})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full text-left text-sm",children:[e.jsx("thead",{className:"text-[11px] uppercase tracking-[0.14em] text-[var(--ui-ink-muted)]",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2",children:"Item"}),e.jsx("th",{className:"px-3 py-2",children:"Score"}),e.jsx("th",{className:"px-3 py-2",children:"Confidence"}),e.jsx("th",{className:"px-3 py-2",children:"Status"}),e.jsx("th",{className:"px-3 py-2",children:"Evidence"})]})}),e.jsx("tbody",{children:he.map(t=>{var s,c;return e.jsxs("tr",{className:U("cursor-pointer border-t border-[var(--ui-border-subtle)] transition hover:bg-[var(--ui-surface-2)]",t.itemId===(d==null?void 0:d.itemId)?"bg-[var(--ui-surface-2)]":""),onClick:()=>{$(t.itemId),A({focusItem:t.itemId})},children:[e.jsxs("td",{className:"px-3 py-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:((s=t.item)==null?void 0:s.label)??t.itemId}),e.jsx("div",{className:"text-xs text-[var(--ui-ink-muted)]",children:(((c=t.item)==null?void 0:c.tags)??[]).join(" · ")})]}),e.jsx("td",{className:"px-3 py-3 text-[var(--ui-ink-medium)]",children:t.latentScore.toFixed(2)}),e.jsx("td",{className:"px-3 py-3 text-[var(--ui-ink-medium)]",children:R(t.confidence)}),e.jsx("td",{className:"px-3 py-3",children:e.jsx(I,{className:Ze[ce(t)],children:ce(t)})}),e.jsx("td",{className:"px-3 py-3 text-[var(--ui-ink-medium)]",children:t.evidenceCount})]},t.itemId)})})]})})]}),e.jsxs(j,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Item editor"}),d!=null&&d.item?e.jsxs(e.Fragment,{children:[e.jsx(v,{value:f.label,onChange:t=>F(s=>({...s,label:t.target.value})),placeholder:"Item label"}),e.jsx(E,{value:f.description,onChange:t=>F(s=>({...s,description:t.target.value})),className:"min-h-24",placeholder:"Item description"}),e.jsx(v,{value:f.tags,onChange:t=>F(s=>({...s,tags:t.target.value})),placeholder:"comma, separated, tags"}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("select",{value:f.manualStatus,onChange:t=>F(s=>({...s,manualStatus:t.target.value})),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none",children:[e.jsx("option",{value:"",children:"Inferred status"}),Object.keys(Ze).map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsx(v,{value:f.manualScore,onChange:t=>F(s=>({...s,manualScore:t.target.value})),placeholder:"Manual score"}),e.jsx(v,{value:f.confidenceLock,onChange:t=>F(s=>({...s,confidenceLock:t.target.value})),placeholder:"Confidence lock 0-1"})]}),e.jsx("div",{className:"grid gap-2",children:Object.keys(ne).map(t=>e.jsxs("div",{className:"grid grid-cols-[110px_minmax(0,1fr)] items-center gap-3",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:fe[t]}),e.jsx(v,{value:f.featureWeights[t],onChange:s=>F(c=>({...c,featureWeights:{...c.featureWeights,[t]:s.target.value}}))})]},t))}),e.jsx("div",{className:"grid gap-2 text-sm text-[var(--ui-ink-soft)]",children:[["bookmarked","Bookmarked"],["compareLater","Compare later"],["frozen","Frozen"]].map(([t,s])=>e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:f[t],onChange:c=>F(n=>({...n,[t]:c.target.checked}))}),e.jsx("span",{children:s})]},t))}),e.jsx(u,{pending:De.isPending,pendingLabel:"Saving item",onClick:()=>void De.mutateAsync(),children:"Save item model"}),Be?e.jsx(ve,{className:"text-sm text-[var(--primary)]",to:Be,children:"Open linked entity"}):null]}):e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Select a row to inspect or edit it."}),e.jsxs("div",{className:"mt-3 border-t border-[var(--ui-border-subtle)] pt-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Add custom item"}),e.jsxs("div",{className:"mt-3 grid gap-3",children:[e.jsx(v,{value:_.label,onChange:t=>ee(s=>({...s,label:t.target.value})),placeholder:"Custom item label"}),e.jsx(E,{value:_.description,onChange:t=>ee(s=>({...s,description:t.target.value})),className:"min-h-24",placeholder:"What is this preference item?"}),e.jsx(v,{value:_.tags,onChange:t=>ee(s=>({...s,tags:t.target.value})),placeholder:"comma, separated, tags"}),e.jsx(u,{disabled:!_.label.trim(),pending:Se.isPending,pendingLabel:"Creating item",onClick:()=>void Se.mutateAsync({userId:m,domain:C,label:_.label,description:_.description,tags:_.tags.split(",").map(t=>t.trim()).filter(Boolean),featureWeights:ne,queueForCompare:!0}),children:"Create custom item"})]})]})]})]}):null,T==="history"?e.jsxs("div",{className:"grid gap-5 xl:grid-cols-3",children:[e.jsxs(j,{className:"grid gap-3 xl:col-span-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Recent pairwise judgments"}),e.jsx("div",{className:"grid gap-2",children:r.history.judgments.slice(0,12).map(t=>{var n,l,y,X;const s=((l=(n=r.scores.find(Q=>Q.itemId===t.leftItemId))==null?void 0:n.item)==null?void 0:l.label)??t.leftItemId,c=((X=(y=r.scores.find(Q=>Q.itemId===t.rightItemId))==null?void 0:y.item)==null?void 0:X.label)??t.rightItemId;return e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-3 text-sm text-[var(--ui-ink-soft)]",children:[e.jsxs("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:[s," vs ",c]}),e.jsxs("div",{className:"mt-1",children:["Outcome ",t.outcome," · strength"," ",t.strength," ·"," ",new Date(t.createdAt).toLocaleString()]})]},t.id)})})]}),e.jsxs(j,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Signals and snapshots"}),e.jsx("div",{className:"grid gap-2",children:r.history.signals.slice(0,8).map(t=>{var c,n;const s=((n=(c=r.scores.find(l=>l.itemId===t.itemId))==null?void 0:c.item)==null?void 0:n.label)??t.itemId;return e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-2 text-sm text-[var(--ui-ink-soft)]",children:[s," · ",t.signalType," ·"," ",new Date(t.createdAt).toLocaleString()]},t.id)})}),e.jsx("div",{className:"grid gap-2",children:r.history.snapshots.slice(0,5).map(t=>e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-2 text-sm text-[var(--ui-ink-soft)]",children:["Snapshot ",new Date(t.createdAt).toLocaleString()]},t.id))}),e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-3 text-sm text-[var(--ui-ink-soft)]",children:["Stale items: ",r.history.staleItemIds.length," · Flipped items: ",r.history.flippedItemIds.length]})]})]}):null,T==="contexts"?e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.1fr)_360px]",children:[e.jsx("div",{className:"grid gap-4",children:r.contexts.map(t=>e.jsxs(j,{className:"grid gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-display text-2xl text-[var(--ui-ink-strong)]",children:t.name}),e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:t.description||"No description yet."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.isDefault?e.jsx(I,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:"Default"}):null,e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:t.shareMode}),t.active?null:e.jsx(I,{className:"bg-[var(--ui-warning-soft)] text-[var(--warning)]",children:"Inactive"})]})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-4",children:[e.jsx(v,{value:t.name,onChange:s=>void q.mutateAsync({contextId:t.id,patch:{name:s.target.value}}),placeholder:"Context name"}),e.jsxs("select",{value:t.shareMode,onChange:s=>void q.mutateAsync({contextId:t.id,patch:{shareMode:s.target.value}}),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none",children:[e.jsx("option",{value:"shared",children:"shared"}),e.jsx("option",{value:"blended",children:"blended"}),e.jsx("option",{value:"isolated",children:"isolated"})]}),e.jsx(v,{value:String(t.decayDays),onChange:s=>void q.mutateAsync({contextId:t.id,patch:{decayDays:Number(s.target.value||90)}}),placeholder:"Decay days"}),e.jsx(u,{variant:"secondary",onClick:()=>A({contextId:t.id,tab:"overview"}),children:"Open context"})]}),e.jsx(E,{value:t.description,onChange:s=>void q.mutateAsync({contextId:t.id,patch:{description:s.target.value}}),className:"min-h-20"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{variant:"secondary",onClick:()=>void q.mutateAsync({contextId:t.id,patch:{active:!t.active}}),children:t.active?"Deactivate":"Activate"}),t.isDefault?null:e.jsx(u,{variant:"secondary",onClick:()=>void q.mutateAsync({contextId:t.id,patch:{isDefault:!0}}),children:"Make default"})]})]},t.id))}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs(j,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Create context"}),e.jsx(v,{value:L.name,onChange:t=>W(s=>({...s,name:t.target.value})),placeholder:"Context name"}),e.jsx(E,{value:L.description,onChange:t=>W(s=>({...s,description:t.target.value})),className:"min-h-24",placeholder:"What changes in this context?"}),e.jsxs("select",{value:L.shareMode,onChange:t=>W(s=>({...s,shareMode:t.target.value})),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none",children:[e.jsx("option",{value:"blended",children:"blended"}),e.jsx("option",{value:"shared",children:"shared"}),e.jsx("option",{value:"isolated",children:"isolated"})]}),e.jsx(v,{value:L.decayDays,onChange:t=>W(s=>({...s,decayDays:t.target.value})),placeholder:"Decay days"}),e.jsx(u,{disabled:!L.name.trim(),pending:Ae.isPending,pendingLabel:"Creating context",onClick:()=>void Ae.mutateAsync({userId:m,domain:C,name:L.name,description:L.description,shareMode:L.shareMode,decayDays:Number(L.decayDays||90),active:!0,isDefault:!1}),children:"Create context"})]}),e.jsxs(j,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Merge contexts"}),e.jsxs("select",{value:G,onChange:t=>J(t.target.value),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none",children:[e.jsx("option",{value:"",children:"Source context"}),r.contexts.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]}),e.jsxs("select",{value:O,onChange:t=>be(t.target.value),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none",children:[e.jsx("option",{value:"",children:"Target context"}),r.contexts.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]}),e.jsx(u,{pending:Ee.isPending,pendingLabel:"Merging",disabled:!G||!O||G===O,onClick:()=>void Ee.mutateAsync({sourceContextId:G,targetContextId:O}),children:"Merge into target"})]})]})]}):null,T==="concepts"?e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.1fr)_380px]",children:[e.jsxs(j,{className:"grid gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Concept libraries"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"These are the lists Forge can use when you start the game in a concept domain. Seeded lists are editable, and custom lists are fully yours."})]}),e.jsx("div",{className:"grid gap-3 md:grid-cols-4",children:[["Lists",r.libraries.totalCatalogs],["Concepts",r.libraries.totalCatalogItems],["Seeded",r.libraries.seededCatalogCount],["Custom",r.libraries.customCatalogCount]].map(([t,s])=>e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:t}),e.jsx("div",{className:"mt-2 font-display text-3xl text-[var(--ui-ink-strong)]",children:s})]},t))}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"size-4 text-[var(--ui-ink-muted)]"}),e.jsx(v,{value:S,onChange:t=>V(t.target.value),placeholder:"Search lists, concepts, tags, and seeded domains"})]})]}),e.jsxs(j,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Create concept list"}),e.jsx(v,{value:H.title,onChange:t=>me(s=>({...s,title:t.target.value})),placeholder:"List title"}),e.jsx(E,{value:H.description,onChange:t=>me(s=>({...s,description:t.target.value})),className:"min-h-24",placeholder:"What should this list help compare?"}),e.jsx(u,{disabled:!H.title.trim(),pending:we.isPending,pendingLabel:"Creating list",onClick:()=>void we.mutateAsync({userId:m,domain:C,title:H.title,description:H.description}),children:"Create list"})]})]}),e.jsx("div",{className:"grid gap-4",children:Ce.map(t=>{const s=rt[t.id]??{label:"",description:"",tags:""},c=t.items.filter(n=>S.trim()?[n.label,n.description,n.tags.join(" ")].join(" ").toLowerCase().includes(le(S)):!0);return e.jsxs(j,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsx("div",{className:"min-w-0",children:ye===t.id?e.jsxs("div",{className:"grid gap-3",children:[e.jsx(v,{value:se.title,onChange:n=>pe(l=>({...l,title:n.target.value}))}),e.jsx(E,{value:se.description,onChange:n=>pe(l=>({...l,description:n.target.value})),className:"min-h-24"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"font-display text-2xl text-[var(--ui-ink-strong)]",children:t.title}),e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:t.source}),e.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[t.items.length," items"]})]}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:t.description||"No description yet."})]})}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{variant:"secondary",size:"sm",onClick:()=>void _e(C,t.id),children:"Start from this list"}),ye===t.id?e.jsxs(e.Fragment,{children:[e.jsx(u,{size:"sm",pending:Pe.isPending,pendingLabel:"Saving",onClick:()=>void Pe.mutateAsync({catalogId:t.id,patch:{title:se.title,description:se.description}}),children:"Save"}),e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>xe(null),children:"Cancel"})]}):e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>{xe(t.id),pe({title:t.title,description:t.description})},children:"Edit list"}),e.jsx(u,{variant:"ghost",size:"sm",pending:Fe.isPending,pendingLabel:"Deleting",onClick:()=>void Fe.mutateAsync(t.id),children:"Delete list"})]})]}),e.jsx("div",{className:"grid gap-2",children:c.map(n=>e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-3",children:nt===n.id?e.jsxs("div",{className:"grid gap-3",children:[e.jsx(v,{value:B.label,onChange:l=>ae(y=>({...y,label:l.target.value}))}),e.jsx(E,{value:B.description,onChange:l=>ae(y=>({...y,description:l.target.value})),className:"min-h-20"}),e.jsx(v,{value:B.tags,onChange:l=>ae(y=>({...y,tags:l.target.value})),placeholder:"comma, separated, tags"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{size:"sm",pending:Te.isPending,pendingLabel:"Saving",onClick:()=>void Te.mutateAsync({catalogItemId:n.id,patch:{label:B.label,description:B.description,tags:B.tags.split(",").map(l=>l.trim()).filter(Boolean)}}),children:"Save concept"}),e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>ge(null),children:"Cancel"})]})]}):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:"font-medium text-[var(--ui-ink-strong)]",children:n.label}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:n.description||"No description yet."}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:n.tags.map(l=>e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:l},`${n.id}-${l}`))})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>{ge(n.id),ae({label:n.label,description:n.description,tags:n.tags.join(", ")})},children:"Edit"}),e.jsxs(u,{variant:"ghost",size:"sm",pending:Me.isPending,pendingLabel:"Deleting",onClick:()=>void Me.mutateAsync(n.id),children:[e.jsx(Ct,{className:"mr-1 size-4"}),"Delete"]})]})]})},n.id))}),e.jsxs("div",{className:"grid gap-3 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--ui-ink-medium)]",children:[e.jsx(It,{className:"size-4"}),"Add concept to ",t.title]}),e.jsx(v,{value:s.label,onChange:n=>te(l=>({...l,[t.id]:{...s,label:n.target.value}})),placeholder:"Concept label"}),e.jsx(E,{value:s.description,onChange:n=>te(l=>({...l,[t.id]:{...s,description:n.target.value}})),className:"min-h-20",placeholder:"Short description"}),e.jsx(v,{value:s.tags,onChange:n=>te(l=>({...l,[t.id]:{...s,tags:n.target.value}})),placeholder:"comma, separated, tags"}),e.jsx(u,{disabled:!s.label.trim(),pending:Le.isPending,pendingLabel:"Adding",onClick:()=>void Le.mutateAsync({catalogId:t.id,label:s.label,description:s.description,tags:s.tags.split(",").map(n=>n.trim()).filter(Boolean),featureWeights:ne}).then(()=>te(n=>({...n,[t.id]:{label:"",description:"",tags:""}}))),children:"Add concept"})]})]},t.id)})})]}):null]}),e.jsx(cs,{state:z,onOpenChange:t=>{t||D(null),M(s=>({...s,open:t}))},error:at,loading:it,workspaceLoading:Ne.isLoading,activeWorkspace:P,conceptSearchQuery:S,onConceptSearchQueryChange:V,filteredCatalogs:Ce,onSelectDomain:t=>void mt(t),onStartCatalogGame:(t,s)=>void _e(t,s),onJudge:(t,s)=>void xt(t,s),onSignal:(t,s)=>void pt(t,s)})]})}export{ks as PreferencesPage};
@@ -0,0 +1 @@
1
+ import{j as a}from"./vendor-Dnkkx2co.js";import{Z as n}from"./index-EqQsXoat.js";const u={active:"Active",paused:"Suspended",completed:"Finished",all:"All"};function d({value:e,counts:t,onChange:s,className:o}){return a.jsx("div",{className:n("flex flex-wrap gap-2",o),children:Object.keys(u).map(r=>{const i=r===e;return a.jsxs("button",{type:"button",onClick:()=>s(r),className:n("inline-flex min-h-10 items-center gap-2 rounded-full border px-4 py-2 text-sm transition",i?"border-[var(--ui-border-strong)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)] shadow-[var(--ui-shadow-soft)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"),children:[a.jsx("span",{children:u[r]}),a.jsx("span",{className:n("rounded-full px-2 py-0.5 text-[11px]",i?"bg-[var(--ui-surface-active)] text-[var(--ui-ink-strong)]":"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]"),children:t[r]})]},r)})})}function v(e){return{active:e.filter(t=>t.status==="active").length,paused:e.filter(t=>t.status==="paused").length,completed:e.filter(t=>t.status==="completed").length,all:e.length}}function f(e,t){return t==="all"?e:e.filter(s=>s.status===t)}export{d as P,v as b,f};
@@ -1 +1 @@
1
- import{cc as ee,b5 as te,r as k,j as e,aC as j}from"./vendor-DHkYh85p.js";import{j as se,i as F,k as w}from"./state-B-4sS1xO.js";import{S as ae}from"./scheduling-rules-editor-D02s70hr.js";import{P as ie,u as re,s as oe,i as y,ay as ne,at as ce,bO as le,bP as de,as as pe,E as me,S as xe,a8 as je,b as v,V as ue,U,C as u,B as m,c as h,Y as he,az as ge,bQ as we,N as ye}from"./index-CF4J4R9L.js";import{O as ve}from"./open-in-graph-button-IXe9SGth.js";import{P as fe}from"./project-management-section-nav-P3ixzPa-.js";import{e as be,W as ke}from"./calendar-rules-DNJFNsxi.js";import{E as Ne}from"./execution-board-D07gOocB.js";import{N as H}from"./note-markdown-N-uxD3Xt.js";import{E as Ie}from"./entity-notes-surface-CkcRsKJQ.js";import{P as De}from"./preference-entity-handoff-button-5PzUn42S.js";import{P as Se}from"./page-hero-DRy5b2MU.js";import{g as Pe,a as qe}from"./activity-copy-Bj4h9OcF.js";import{g as Qe}from"./entity-links-DwpxhW2H.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";import"./note-tags-input-Cdu7wiw6.js";function Te(a){return!!(a&&a.startsWith("campaign:"))}function et(){var M;const{t:a}=ie(),i=re(),N=Array.isArray(i.selectedUserIds)?i.selectedUserIds:[],o=ee(),K=te(),r=se(),[W,C]=k.useState(!1),[G,E]=k.useState(!1),[_,R]=k.useState(!1),[I]=k.useState(()=>{const t=new Date,l=new Date(t);l.setHours(0,0,0,0);const $=new Date(t);return $.setHours(23,59,59,999),{from:l.toISOString(),to:$.toISOString()}}),D=oe(N),c=i.snapshot.dashboard.projects.find(t=>t.id===o.projectId)??null,A=c?i.snapshot.goals.find(t=>t.id===c.goalId)??null:null,O=c?i.snapshot.tasks.filter(t=>t.projectId===c.id||!t.projectId&&t.goalId===c.goalId):[],B=new Set(O.map(t=>t.id)),z=c?i.snapshot.activity.filter(t=>t.entityId===c.goalId||t.entityId===c.id||B.has(t.entityId)||t.entityType==="task_run"&&typeof t.metadata.taskId=="string"&&B.has(t.metadata.taskId)):[],n=Te(o.projectId),f=F({queryKey:["project-board",o.projectId],queryFn:()=>we(o.projectId),enabled:!!o.projectId&&!n}),V=F({queryKey:["project-calendar-overview",o.projectId,I.from,I.to,...N],queryFn:()=>ye({...I,userIds:N}),enabled:!!o.projectId&&!n}),Y=w({mutationFn:t=>ne(t),onSuccess:async()=>{await Promise.all([y(r),r.invalidateQueries({queryKey:["project-board",o.projectId]})])}}),L=w({mutationFn:ce,onSuccess:async()=>{await Promise.all([y(r),r.invalidateQueries({queryKey:["project-board",o.projectId]}),r.invalidateQueries({queryKey:["forge-xp-metrics"]}),r.invalidateQueries({queryKey:["forge-reward-ledger"]}),r.invalidateQueries({queryKey:["forge-operator-context"]})])}}),g=w({mutationFn:t=>le(o.projectId,{status:t}),onSuccess:async()=>{await Promise.all([y(r),r.invalidateQueries({queryKey:["project-board",o.projectId]}),r.invalidateQueries({queryKey:["forge-xp-metrics"]}),r.invalidateQueries({queryKey:["forge-reward-ledger"]}),r.invalidateQueries({queryKey:["forge-operator-context"]})])}}),S=w({mutationFn:()=>de(o.projectId),onSuccess:async()=>{await Promise.all([y(r),r.invalidateQueries({queryKey:["project-board",o.projectId]})]),K("/projects")}}),J=w({mutationFn:t=>pe(t),onSuccess:async()=>{await Promise.all([y(r),r.invalidateQueries({queryKey:["project-board",o.projectId]}),r.invalidateQueries({queryKey:["task-context"]})])}}),s=f.data??(c&&A?{project:c,goal:A,tasks:O,activity:z}:void 0),b=i.snapshot.dashboard.projects.find(t=>t.id===o.projectId)??null;if(f.isError&&!n)return e.jsx(me,{eyebrow:a("common.projectDetail.errorEyebrow"),error:f.error,onRetry:()=>void f.refetch()});if(!s)return e.jsx(xe,{});const d=s.tasks.find(t=>t.status==="focus"||t.status==="in_progress")??s.tasks[0]??null,p=s.tasks.find(t=>t.status==="blocked")??s.tasks.find(t=>t.status==="backlog")??null;s.activity[0];const X="notesSummaryByEntity"in s?s.notesSummaryByEntity:i.snapshot.dashboard.notesSummaryByEntity,P=g.isPending||S.isPending,x=be({rules:s.project.schedulingRules,overview:(M=V.data)==null?void 0:M.calendar}),q=i.snapshot.strategies.filter(t=>t.targetGoalIds.includes(s.goal.id)),Q=i.snapshot.strategies.filter(t=>t.targetProjectIds.includes(s.project.id)),T=async t=>{await g.mutateAsync(t)},Z=async()=>{window.confirm(a("common.projectDetail.deleteProjectConfirm",{title:s.project.title}))&&await S.mutateAsync()};return e.jsxs("div",{className:"grid min-w-0 gap-5",children:[e.jsx(fe,{}),e.jsx(Se,{entityKind:"project",title:e.jsx(ue,{kind:"project",label:s.project.title,variant:"heading",size:"lg"}),titleText:s.project.title,description:s.project.description?e.jsx(H,{markdown:s.project.description,className:"[&>p]:text-[13px] [&>p]:leading-6 [&>blockquote]:text-[13px] [&>ul]:text-[13px] [&>ol]:text-[13px]"}):"No project description yet.",badge:e.jsx(v,{kind:"goal",label:s.goal.title,compact:!0,gradient:!1}),actions:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(je,{metrics:i.snapshot.metrics}),e.jsx(De,{userId:D,domain:"projects",entityType:"project",entityId:s.project.id,label:s.project.title,description:s.project.description}),e.jsx(ve,{entityType:"project",entityId:s.project.id})]})}),s.project.user?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-white/62",children:[e.jsx("span",{className:"text-white/42",children:"Owned by"}),e.jsx(U,{user:s.project.user}),s.project.assignees&&s.project.assignees.length>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-white/35",children:"Assigned with"}),e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:s.project.assignees.map(t=>e.jsx(U,{user:t,compact:!0},t.id))})]}):null]}):null,s.project.productRequirementsDocument?e.jsxs(u,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Product requirements document"}),e.jsx("div",{className:"mt-3",children:e.jsx(H,{markdown:s.project.productRequirementsDocument,className:"[&>p]:text-[13px] [&>p]:leading-6 [&>blockquote]:text-[13px] [&>ul]:text-[13px] [&>ol]:text-[13px]"})})]}):null,q.length>0||Q.length>0?e.jsxs(u,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Strategy stack"}),e.jsxs("div",{className:"mt-3 grid gap-3 lg:grid-cols-2",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-white/42",children:"Goal-level strategies"}),q.length===0?e.jsx("div",{className:"text-sm text-white/48",children:"No goal-level strategies linked yet."}):q.map(t=>e.jsxs(j,{to:`/strategies/${t.id}`,className:"rounded-[18px] border border-white/8 bg-white/[0.04] px-4 py-3 transition hover:bg-white/[0.07]",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:t.title}),e.jsx("div",{className:"mt-1 text-xs text-white/48",children:t.overview||t.endStateDescription})]},t.id))]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-white/42",children:"Project-level strategies"}),Q.length===0?e.jsx("div",{className:"text-sm text-white/48",children:"No lower-level strategies linked yet."}):Q.map(t=>e.jsxs(j,{to:`/strategies/${t.id}`,className:"rounded-[18px] border border-white/8 bg-white/[0.04] px-4 py-3 transition hover:bg-white/[0.07]",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:t.title}),e.jsx("div",{className:"mt-1 text-xs text-white/48",children:t.overview||t.endStateDescription})]},t.id))]})]})]}):null,n?e.jsxs(u,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:a("common.projectDetail.compatibility")}),e.jsx("p",{className:"mt-3 text-sm leading-7 text-white/60",children:a("common.projectDetail.compatibilityDescription")})]}):null,e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx(m,{onClick:()=>E(!0),children:a("common.projectDetail.addTask")}),n?null:e.jsx(m,{variant:"secondary",onClick:()=>R(!0),children:"Adjust work"}),n?null:e.jsx(m,{variant:"secondary",onClick:()=>C(!0),children:a("common.projectDetail.editProject")}),!n&&s.project.status==="active"?e.jsx(m,{variant:"secondary",pending:P&&g.variables==="paused",pendingLabel:a("common.projectDetail.suspending"),onClick:()=>void T("paused"),children:a("common.projectDetail.suspendProject")}):null,!n&&s.project.status!=="completed"?e.jsx(m,{pending:P&&g.variables==="completed",pendingLabel:a("common.projectDetail.finishing"),onClick:()=>void T("completed"),children:a("common.projectDetail.finishProject")}):null,!n&&s.project.status!=="active"?e.jsx(m,{variant:"secondary",pending:P&&g.variables==="active",pendingLabel:a("common.projectDetail.restarting"),onClick:()=>void T("active"),children:a("common.projectDetail.restartProject")}):null,n?null:e.jsx(m,{variant:"ghost",pending:S.isPending,pendingLabel:a("common.projectDetail.deleting"),onClick:()=>void Z(),children:a("common.projectDetail.deleteProject")}),e.jsx(j,{to:`/goals/${s.goal.id}`,children:e.jsx(m,{variant:"ghost",children:a("common.projectDetail.openGoal")})})]}),e.jsxs("section",{className:"grid min-w-0 gap-5 xl:grid-cols-[minmax(0,1fr)_22rem]",children:[e.jsxs(u,{children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:a("common.projectDetail.commandEyebrow")}),e.jsx("h2",{className:"mt-2 font-display text-[clamp(1.35rem,2vw,1.9rem)] text-white",children:a("common.projectDetail.commandTitle")}),e.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-6 text-white/60",children:a("common.projectDetail.commandDescription")})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(v,{kind:"project",compact:!0,gradient:!1}),e.jsx(v,{kind:"goal",label:s.goal.title,compact:!0,gradient:!1})]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 lg:grid-cols-2",children:[e.jsxs(j,{to:d?`/tasks/${d.id}`:`/projects/${s.project.id}`,className:"rounded-[20px] bg-white/[0.04] p-4 transition hover:bg-white/[0.08]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:a("common.projectDetail.signalNext")}),d?e.jsx(v,{kind:"task",compact:!0,gradient:!1}):null]}),e.jsx("div",{className:"mt-2 font-medium text-white",children:(d==null?void 0:d.title)??a("common.projectDetail.noNextTask")}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:(d==null?void 0:d.description)||a("common.projectDetail.noNextTaskDetail")})]}),e.jsxs(j,{to:p?`/tasks/${p.id}`:`/projects/${s.project.id}`,className:"rounded-[20px] bg-white/[0.04] p-4 transition hover:bg-white/[0.08]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:a("common.projectDetail.signalRisk")}),p?e.jsx(v,{kind:"task",compact:!0,gradient:!1}):null]}),e.jsx("div",{className:"mt-2 font-medium text-white",children:(p==null?void 0:p.title)??a("common.projectDetail.noRisk")}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:(p==null?void 0:p.description)||a("common.projectDetail.noRiskDetail")})]})]})]}),e.jsxs(u,{className:"h-fit min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:a("common.projectDetail.sectionHealth")}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(h,{className:"bg-white/[0.08] text-white/72",children:a(`common.enums.projectStatus.${s.project.status}`)}),e.jsx(h,{className:"bg-white/[0.08] text-white/72",children:s.project.momentumLabel}),e.jsxs(h,{className:"bg-white/[0.08] text-white/72",children:[Math.floor(s.project.time.totalCreditedSeconds/60)," min tracked"]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:a("common.projectDetail.fieldProgress")}),e.jsxs("div",{className:"mt-2 font-display text-xl text-white",children:[s.project.progress,"%"]})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:a("common.projectDetail.fieldMomentum")}),e.jsx("div",{className:"mt-2 font-display text-xl text-white",children:s.project.momentumLabel})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:a("common.projectDetail.fieldStatus")}),e.jsx("div",{className:"mt-2 font-display text-xl text-white",children:a(`common.enums.projectStatus.${s.project.status}`)})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Live tasks"}),e.jsx("div",{className:"mt-2 font-display text-xl text-white",children:s.tasks.filter(t=>t.status==="focus"||t.status==="in_progress").length})]})]})]})]}),n?null:e.jsxs("section",{className:"grid gap-5 xl:grid-cols-[minmax(0,1fr)_22rem]",children:[e.jsx(ae,{title:"Project scheduling defaults",subtitle:"Define the calendar contexts where work from this project is allowed or blocked. Tasks can inherit these defaults or override them.",initialRules:s.project.schedulingRules,saveLabel:"Save project scheduling",onSave:async({schedulingRules:t})=>{await i.patchProject(s.project.id,{schedulingRules:t}),await r.invalidateQueries({queryKey:["project-board",o.projectId]}),await r.invalidateQueries({queryKey:["project-calendar-overview",o.projectId]})}}),e.jsxs(u,{className:"h-fit min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Calendar status"}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(h,{className:x.tone==="blocked"?"bg-rose-500/14 text-rose-100":x.tone==="waiting"?"bg-amber-500/14 text-amber-100":"bg-emerald-500/14 text-emerald-100",children:x.label}),e.jsx(h,{className:"bg-white/[0.08] text-white/72",children:"Project defaults"})]}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-white/58",children:"These rules act as the default calendar gate for every task in the project unless a task sets its own override."}),x.context.length>0?e.jsxs("div",{className:"mt-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Current context"}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:x.context.map(t=>e.jsx(h,{className:"bg-white/[0.08] text-white/72",children:t},t))})]}):null,x.conflicts.length>0?e.jsx("div",{className:"mt-4 grid gap-2",children:x.conflicts.map(t=>e.jsx("div",{className:"rounded-[16px] bg-rose-500/10 px-3 py-2 text-sm text-rose-100",children:t},t))}):null,e.jsx("div",{className:"mt-4",children:e.jsx(j,{to:"/calendar",children:e.jsx(m,{variant:"secondary",children:"Open calendar workspace"})})})]})]}),e.jsx(Ne,{tasks:s.tasks,activeRuns:i.snapshot.activeTaskRuns,goals:i.snapshot.goals,tags:i.snapshot.tags,notesSummaryByEntity:X,selectedTaskId:null,onMove:async(t,l)=>{await i.patchTaskStatus(t,l),await r.invalidateQueries({queryKey:["project-board",o.projectId]})},onSelectTask:t=>K(`/tasks/${t}`),onStopTask:async t=>{await i.stopTaskRun(t),await r.invalidateQueries({queryKey:["project-board",o.projectId]}),await r.invalidateQueries({queryKey:["task-context",t.taskId]})},onQuickReopenTask:async t=>{await Y.mutateAsync(t)},onDeleteTask:async t=>{await J.mutateAsync(t)}}),n?null:e.jsx(Ie,{entityType:"project",entityId:s.project.id,title:"Project notes",description:"Keep rollout notes, checkpoints, and cross-task context attached to the project itself.",invalidateQueryKeys:[["project-board",o.projectId]]}),e.jsxs(u,{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:a("common.projectDetail.sectionEvidence")}),e.jsx("div",{className:"mt-4 grid gap-3 lg:grid-cols-2",children:s.activity.slice(0,6).map(t=>e.jsxs(j,{to:Qe(t)??`/activity?eventId=${t.id}`,className:"rounded-[18px] bg-white/[0.04] p-4 transition hover:bg-white/[0.08]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-white",children:Pe(t)}),e.jsx(h,{children:t.source})]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:qe(t)})]},t.id))})]}),e.jsx(he,{open:W,goals:i.snapshot.goals,users:i.snapshot.users,editingProject:b,defaultUserId:(b==null?void 0:b.userId)??D,onOpenChange:C,onSubmit:async(t,l)=>{l&&(await i.patchProject(l,t),await r.invalidateQueries({queryKey:["project-board",o.projectId]}))}}),e.jsx(ge,{open:G,goals:i.snapshot.goals,projects:i.snapshot.dashboard.projects,workItems:i.snapshot.workItems,tags:i.snapshot.tags,users:i.snapshot.users,editingTask:null,initialProjectId:n?null:s.project.id,defaultUserId:s.project.userId??D,onRefreshEntities:i.refresh,onOpenChange:E,onSubmit:async(t,l)=>{l?await i.patchTask(l,t):await i.createTask(t),await r.invalidateQueries({queryKey:["project-board",o.projectId]})}}),n?null:e.jsx(ke,{open:_,onOpenChange:R,entityType:"project",entityId:s.project.id,targetLabel:s.project.title,currentCreditedSeconds:s.project.time.totalCreditedSeconds,pending:L.isPending,onSubmit:async t=>{await L.mutateAsync(t)}})]})}export{et as ProjectDetailPage};
1
+ import{cc as ee,b5 as te,r as k,j as e,aC as j}from"./vendor-Dnkkx2co.js";import{j as se,i as F,k as w}from"./state-vCcAT5Hq.js";import{S as ae}from"./scheduling-rules-editor-D40AC2jR.js";import{P as ie,u as re,s as oe,i as v,ay as ne,at as ce,bO as le,bP as de,as as pe,E as me,S as xe,a8 as je,b as y,V as ue,U,C as u,B as m,c as h,Y as he,az as ge,bQ as we,N as ve}from"./index-EqQsXoat.js";import{O as ye}from"./open-in-graph-button-BFPKfyK3.js";import{P as fe}from"./project-management-section-nav-BImLCVvf.js";import{e as be,W as ke}from"./calendar-rules-DPFsfiRl.js";import{E as Ne}from"./execution-board-CtPhI-58.js";import{N as H}from"./note-markdown-BzK2Qlgr.js";import{E as Ie}from"./entity-notes-surface-Djz50HvD.js";import{P as De}from"./preference-entity-handoff-button-Dj3V6VxL.js";import{P as Se}from"./page-hero-ffKzgyW3.js";import{g as Pe,a as qe}from"./activity-copy-Bj4h9OcF.js";import{g as Qe}from"./entity-links-DwpxhW2H.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";import"./entity-note-count-link-RzBB6ujx.js";import"./floating-action-menu-CKQRhff9.js";import"./note-tags-input-CZzqJMLc.js";function Te(a){return!!(a&&a.startsWith("campaign:"))}function et(){var M;const{t:a}=ie(),i=re(),N=Array.isArray(i.selectedUserIds)?i.selectedUserIds:[],o=ee(),K=te(),r=se(),[W,C]=k.useState(!1),[G,E]=k.useState(!1),[_,R]=k.useState(!1),[I]=k.useState(()=>{const t=new Date,l=new Date(t);l.setHours(0,0,0,0);const $=new Date(t);return $.setHours(23,59,59,999),{from:l.toISOString(),to:$.toISOString()}}),D=oe(N),c=i.snapshot.dashboard.projects.find(t=>t.id===o.projectId)??null,A=c?i.snapshot.goals.find(t=>t.id===c.goalId)??null:null,O=c?i.snapshot.tasks.filter(t=>t.projectId===c.id||!t.projectId&&t.goalId===c.goalId):[],B=new Set(O.map(t=>t.id)),z=c?i.snapshot.activity.filter(t=>t.entityId===c.goalId||t.entityId===c.id||B.has(t.entityId)||t.entityType==="task_run"&&typeof t.metadata.taskId=="string"&&B.has(t.metadata.taskId)):[],n=Te(o.projectId),f=F({queryKey:["project-board",o.projectId],queryFn:()=>we(o.projectId),enabled:!!o.projectId&&!n}),V=F({queryKey:["project-calendar-overview",o.projectId,I.from,I.to,...N],queryFn:()=>ve({...I,userIds:N}),enabled:!!o.projectId&&!n}),Y=w({mutationFn:t=>ne(t),onSuccess:async()=>{await Promise.all([v(r),r.invalidateQueries({queryKey:["project-board",o.projectId]})])}}),L=w({mutationFn:ce,onSuccess:async()=>{await Promise.all([v(r),r.invalidateQueries({queryKey:["project-board",o.projectId]}),r.invalidateQueries({queryKey:["forge-xp-metrics"]}),r.invalidateQueries({queryKey:["forge-reward-ledger"]}),r.invalidateQueries({queryKey:["forge-operator-context"]})])}}),g=w({mutationFn:t=>le(o.projectId,{status:t}),onSuccess:async()=>{await Promise.all([v(r),r.invalidateQueries({queryKey:["project-board",o.projectId]}),r.invalidateQueries({queryKey:["forge-xp-metrics"]}),r.invalidateQueries({queryKey:["forge-reward-ledger"]}),r.invalidateQueries({queryKey:["forge-operator-context"]})])}}),S=w({mutationFn:()=>de(o.projectId),onSuccess:async()=>{await Promise.all([v(r),r.invalidateQueries({queryKey:["project-board",o.projectId]})]),K("/projects")}}),J=w({mutationFn:t=>pe(t),onSuccess:async()=>{await Promise.all([v(r),r.invalidateQueries({queryKey:["project-board",o.projectId]}),r.invalidateQueries({queryKey:["task-context"]})])}}),s=f.data??(c&&A?{project:c,goal:A,tasks:O,activity:z}:void 0),b=i.snapshot.dashboard.projects.find(t=>t.id===o.projectId)??null;if(f.isError&&!n)return e.jsx(me,{eyebrow:a("common.projectDetail.errorEyebrow"),error:f.error,onRetry:()=>void f.refetch()});if(!s)return e.jsx(xe,{});const d=s.tasks.find(t=>t.status==="focus"||t.status==="in_progress")??s.tasks[0]??null,p=s.tasks.find(t=>t.status==="blocked")??s.tasks.find(t=>t.status==="backlog")??null;s.activity[0];const X="notesSummaryByEntity"in s?s.notesSummaryByEntity:i.snapshot.dashboard.notesSummaryByEntity,P=g.isPending||S.isPending,x=be({rules:s.project.schedulingRules,overview:(M=V.data)==null?void 0:M.calendar}),q=i.snapshot.strategies.filter(t=>t.targetGoalIds.includes(s.goal.id)),Q=i.snapshot.strategies.filter(t=>t.targetProjectIds.includes(s.project.id)),T=async t=>{await g.mutateAsync(t)},Z=async()=>{window.confirm(a("common.projectDetail.deleteProjectConfirm",{title:s.project.title}))&&await S.mutateAsync()};return e.jsxs("div",{className:"grid min-w-0 gap-5",children:[e.jsx(fe,{}),e.jsx(Se,{entityKind:"project",title:e.jsx(ue,{kind:"project",label:s.project.title,variant:"heading",size:"lg"}),titleText:s.project.title,description:s.project.description?e.jsx(H,{markdown:s.project.description,className:"[&>p]:text-[13px] [&>p]:leading-6 [&>blockquote]:text-[13px] [&>ul]:text-[13px] [&>ol]:text-[13px]"}):"No project description yet.",badge:e.jsx(y,{kind:"goal",label:s.goal.title,compact:!0,gradient:!1}),actions:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(je,{metrics:i.snapshot.metrics}),e.jsx(De,{userId:D,domain:"projects",entityType:"project",entityId:s.project.id,label:s.project.title,description:s.project.description}),e.jsx(ye,{entityType:"project",entityId:s.project.id})]})}),s.project.user?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-white/62",children:[e.jsx("span",{className:"text-white/42",children:"Owned by"}),e.jsx(U,{user:s.project.user}),s.project.assignees&&s.project.assignees.length>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-white/35",children:"Assigned with"}),e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:s.project.assignees.map(t=>e.jsx(U,{user:t,compact:!0},t.id))})]}):null]}):null,s.project.productRequirementsDocument?e.jsxs(u,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Product requirements document"}),e.jsx("div",{className:"mt-3",children:e.jsx(H,{markdown:s.project.productRequirementsDocument,className:"[&>p]:text-[13px] [&>p]:leading-6 [&>blockquote]:text-[13px] [&>ul]:text-[13px] [&>ol]:text-[13px]"})})]}):null,q.length>0||Q.length>0?e.jsxs(u,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Strategy stack"}),e.jsxs("div",{className:"mt-3 grid gap-3 lg:grid-cols-2",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-white/42",children:"Goal-level strategies"}),q.length===0?e.jsx("div",{className:"text-sm text-white/48",children:"No goal-level strategies linked yet."}):q.map(t=>e.jsxs(j,{to:`/strategies/${t.id}`,className:"rounded-[18px] border border-white/8 bg-white/[0.04] px-4 py-3 transition hover:bg-white/[0.07]",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:t.title}),e.jsx("div",{className:"mt-1 text-xs text-white/48",children:t.overview||t.endStateDescription})]},t.id))]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-white/42",children:"Project-level strategies"}),Q.length===0?e.jsx("div",{className:"text-sm text-white/48",children:"No lower-level strategies linked yet."}):Q.map(t=>e.jsxs(j,{to:`/strategies/${t.id}`,className:"rounded-[18px] border border-white/8 bg-white/[0.04] px-4 py-3 transition hover:bg-white/[0.07]",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:t.title}),e.jsx("div",{className:"mt-1 text-xs text-white/48",children:t.overview||t.endStateDescription})]},t.id))]})]})]}):null,n?e.jsxs(u,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:a("common.projectDetail.compatibility")}),e.jsx("p",{className:"mt-3 text-sm leading-7 text-white/60",children:a("common.projectDetail.compatibilityDescription")})]}):null,e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx(m,{onClick:()=>E(!0),children:a("common.projectDetail.addTask")}),n?null:e.jsx(m,{variant:"secondary",onClick:()=>R(!0),children:"Adjust work"}),n?null:e.jsx(m,{variant:"secondary",onClick:()=>C(!0),children:a("common.projectDetail.editProject")}),!n&&s.project.status==="active"?e.jsx(m,{variant:"secondary",pending:P&&g.variables==="paused",pendingLabel:a("common.projectDetail.suspending"),onClick:()=>void T("paused"),children:a("common.projectDetail.suspendProject")}):null,!n&&s.project.status!=="completed"?e.jsx(m,{pending:P&&g.variables==="completed",pendingLabel:a("common.projectDetail.finishing"),onClick:()=>void T("completed"),children:a("common.projectDetail.finishProject")}):null,!n&&s.project.status!=="active"?e.jsx(m,{variant:"secondary",pending:P&&g.variables==="active",pendingLabel:a("common.projectDetail.restarting"),onClick:()=>void T("active"),children:a("common.projectDetail.restartProject")}):null,n?null:e.jsx(m,{variant:"ghost",pending:S.isPending,pendingLabel:a("common.projectDetail.deleting"),onClick:()=>void Z(),children:a("common.projectDetail.deleteProject")}),e.jsx(j,{to:`/goals/${s.goal.id}`,children:e.jsx(m,{variant:"ghost",children:a("common.projectDetail.openGoal")})})]}),e.jsxs("section",{className:"grid min-w-0 gap-5 xl:grid-cols-[minmax(0,1fr)_22rem]",children:[e.jsxs(u,{children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:a("common.projectDetail.commandEyebrow")}),e.jsx("h2",{className:"mt-2 font-display text-[clamp(1.35rem,2vw,1.9rem)] text-white",children:a("common.projectDetail.commandTitle")}),e.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-6 text-white/60",children:a("common.projectDetail.commandDescription")})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(y,{kind:"project",compact:!0,gradient:!1}),e.jsx(y,{kind:"goal",label:s.goal.title,compact:!0,gradient:!1})]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 lg:grid-cols-2",children:[e.jsxs(j,{to:d?`/tasks/${d.id}`:`/projects/${s.project.id}`,className:"rounded-[20px] bg-white/[0.04] p-4 transition hover:bg-white/[0.08]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:a("common.projectDetail.signalNext")}),d?e.jsx(y,{kind:"task",compact:!0,gradient:!1}):null]}),e.jsx("div",{className:"mt-2 font-medium text-white",children:(d==null?void 0:d.title)??a("common.projectDetail.noNextTask")}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:(d==null?void 0:d.description)||a("common.projectDetail.noNextTaskDetail")})]}),e.jsxs(j,{to:p?`/tasks/${p.id}`:`/projects/${s.project.id}`,className:"rounded-[20px] bg-white/[0.04] p-4 transition hover:bg-white/[0.08]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:a("common.projectDetail.signalRisk")}),p?e.jsx(y,{kind:"task",compact:!0,gradient:!1}):null]}),e.jsx("div",{className:"mt-2 font-medium text-white",children:(p==null?void 0:p.title)??a("common.projectDetail.noRisk")}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:(p==null?void 0:p.description)||a("common.projectDetail.noRiskDetail")})]})]})]}),e.jsxs(u,{className:"h-fit min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:a("common.projectDetail.sectionHealth")}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(h,{className:"bg-white/[0.08] text-white/72",children:a(`common.enums.projectStatus.${s.project.status}`)}),e.jsx(h,{className:"bg-white/[0.08] text-white/72",children:s.project.momentumLabel}),e.jsxs(h,{className:"bg-white/[0.08] text-white/72",children:[Math.floor(s.project.time.totalCreditedSeconds/60)," min tracked"]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:a("common.projectDetail.fieldProgress")}),e.jsxs("div",{className:"mt-2 font-display text-xl text-white",children:[s.project.progress,"%"]})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:a("common.projectDetail.fieldMomentum")}),e.jsx("div",{className:"mt-2 font-display text-xl text-white",children:s.project.momentumLabel})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:a("common.projectDetail.fieldStatus")}),e.jsx("div",{className:"mt-2 font-display text-xl text-white",children:a(`common.enums.projectStatus.${s.project.status}`)})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Live tasks"}),e.jsx("div",{className:"mt-2 font-display text-xl text-white",children:s.tasks.filter(t=>t.status==="focus"||t.status==="in_progress").length})]})]})]})]}),n?null:e.jsxs("section",{className:"grid gap-5 xl:grid-cols-[minmax(0,1fr)_22rem]",children:[e.jsx(ae,{title:"Project scheduling defaults",subtitle:"Define the calendar contexts where work from this project is allowed or blocked. Tasks can inherit these defaults or override them.",initialRules:s.project.schedulingRules,saveLabel:"Save project scheduling",onSave:async({schedulingRules:t})=>{await i.patchProject(s.project.id,{schedulingRules:t}),await r.invalidateQueries({queryKey:["project-board",o.projectId]}),await r.invalidateQueries({queryKey:["project-calendar-overview",o.projectId]})}}),e.jsxs(u,{className:"h-fit min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Calendar status"}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(h,{className:x.tone==="blocked"?"bg-rose-500/14 text-rose-100":x.tone==="waiting"?"bg-amber-500/14 text-amber-100":"bg-emerald-500/14 text-emerald-100",children:x.label}),e.jsx(h,{className:"bg-white/[0.08] text-white/72",children:"Project defaults"})]}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-white/58",children:"These rules act as the default calendar gate for every task in the project unless a task sets its own override."}),x.context.length>0?e.jsxs("div",{className:"mt-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Current context"}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:x.context.map(t=>e.jsx(h,{className:"bg-white/[0.08] text-white/72",children:t},t))})]}):null,x.conflicts.length>0?e.jsx("div",{className:"mt-4 grid gap-2",children:x.conflicts.map(t=>e.jsx("div",{className:"rounded-[16px] bg-rose-500/10 px-3 py-2 text-sm text-rose-100",children:t},t))}):null,e.jsx("div",{className:"mt-4",children:e.jsx(j,{to:"/calendar",children:e.jsx(m,{variant:"secondary",children:"Open calendar workspace"})})})]})]}),e.jsx(Ne,{tasks:s.tasks,activeRuns:i.snapshot.activeTaskRuns,goals:i.snapshot.goals,tags:i.snapshot.tags,notesSummaryByEntity:X,selectedTaskId:null,onMove:async(t,l)=>{await i.patchTaskStatus(t,l),await r.invalidateQueries({queryKey:["project-board",o.projectId]})},onSelectTask:t=>K(`/tasks/${t}`),onStopTask:async t=>{await i.stopTaskRun(t),await r.invalidateQueries({queryKey:["project-board",o.projectId]}),await r.invalidateQueries({queryKey:["task-context",t.taskId]})},onQuickReopenTask:async t=>{await Y.mutateAsync(t)},onDeleteTask:async t=>{await J.mutateAsync(t)}}),n?null:e.jsx(Ie,{entityType:"project",entityId:s.project.id,title:"Project notes",description:"Keep rollout notes, checkpoints, and cross-task context attached to the project itself.",invalidateQueryKeys:[["project-board",o.projectId]]}),e.jsxs(u,{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:a("common.projectDetail.sectionEvidence")}),e.jsx("div",{className:"mt-4 grid min-w-0 gap-3 lg:grid-cols-2",children:s.activity.slice(0,6).map(t=>e.jsxs(j,{to:Qe(t)??`/activity?eventId=${t.id}`,className:"min-w-0 max-w-full rounded-[18px] bg-[var(--ui-surface-1)] p-4 transition hover:bg-[var(--ui-surface-hover)]",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"min-w-0 break-words font-medium text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:Pe(t)}),e.jsx(h,{children:t.source})]}),e.jsx("div",{className:"mt-2 min-w-0 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:qe(t)})]},t.id))})]}),e.jsx(he,{open:W,goals:i.snapshot.goals,users:i.snapshot.users,editingProject:b,defaultUserId:(b==null?void 0:b.userId)??D,onOpenChange:C,onSubmit:async(t,l)=>{l&&(await i.patchProject(l,t),await r.invalidateQueries({queryKey:["project-board",o.projectId]}))}}),e.jsx(ge,{open:G,goals:i.snapshot.goals,projects:i.snapshot.dashboard.projects,workItems:i.snapshot.workItems,tags:i.snapshot.tags,users:i.snapshot.users,editingTask:null,initialProjectId:n?null:s.project.id,defaultUserId:s.project.userId??D,onRefreshEntities:i.refresh,onOpenChange:E,onSubmit:async(t,l)=>{l?await i.patchTask(l,t):await i.createTask(t),await r.invalidateQueries({queryKey:["project-board",o.projectId]})}}),n?null:e.jsx(ke,{open:_,onOpenChange:R,entityType:"project",entityId:s.project.id,targetLabel:s.project.title,currentCreditedSeconds:s.project.time.totalCreditedSeconds,pending:L.isPending,onSubmit:async t=>{await L.mutateAsync(t)}})]})}export{et as ProjectDetailPage};
@@ -0,0 +1 @@
1
+ import{r as x,j as s,cz as X,cx as Y,cA as Z,aC as J,aK as ee,b3 as se}from"./vendor-Dnkkx2co.js";import{i as re}from"./state-vCcAT5Hq.js";import{u as te,c as j,U as R,b as D,L as ae,E as ie,C as O,B as C,m as A,a as ne,aS as le,Z as F,bR as oe}from"./index-EqQsXoat.js";import{P as ce}from"./project-management-section-nav-BImLCVvf.js";import{P as de}from"./page-hero-ffKzgyW3.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";const _={user:"user:",kind:"kind:"},q=["goal","strategy","project","issue","task","subtask"],T=[...q],L=["active","paused","completed","backlog","focus","in_progress","blocked","done"];function I(r){return r.trim().toLowerCase()}function ue(r){return r.reduce((i,n)=>{if(n.startsWith(_.user))i.userIds.push(n.slice(_.user.length));else if(n.startsWith(_.kind)){const d=n.slice(_.kind.length);(d==="human"||d==="bot")&&i.kinds.push(d)}return i},{userIds:[],kinds:[]})}function he(r,i){return`${i}:${I(r)}`}function ge(r){const i=r.trim();return i.length===0?[]:["any",...q].map(n=>({id:he(i,n),query:i,kind:n}))}function me(r){switch(r){case"done":case"completed":return 1;case"in_progress":case"active":return .66;case"focus":return .45;case"blocked":return .5;case"paused":return .28;default:return .08}}function P(r,i){const n=r.replace(/\s+/g," ").trim();return n.length===0?i:n}function S(r){const i=(r.children??[]).map(S);if(r.kind==="project")return{...r,children:i,progressPercent:r.progressPercent,progressLabel:r.progressLabel??(typeof r.progressPercent=="number"?`${r.progressPercent}% complete`:null)};if(i.length>0){const d=i.map(g=>g.progressPercent).filter(g=>typeof g=="number");if(d.length>0){const g=Math.round(d.reduce((y,h)=>y+h,0)/d.length);return{...r,children:i,progressPercent:g,progressLabel:`${i.length} child item${i.length===1?"":"s"}`}}}const n=Math.round(me(r.statusLabel)*100);return{...r,children:i,progressPercent:n,progressLabel:r.statusLabel?r.statusLabel.replaceAll("_"," "):null}}function V(r){const{goals:i,strategies:n,projects:d,workItems:g,tagNameById:y}=r,h=new Map,v=new Map,m=new Map;for(const e of g)if(e.parentWorkItemId){const a=h.get(e.parentWorkItemId)??[];a.push(e),h.set(e.parentWorkItemId,a)}else if(e.level==="issue"&&e.projectId){const a=v.get(e.projectId)??[];a.push(e),v.set(e.projectId,a)}else if(e.projectId){const a=m.get(e.projectId)??[];a.push(e),m.set(e.projectId,a)}const b=e=>{var a;return S({id:`${e.level}:${e.id}`,entityId:e.id,kind:e.level,label:e.title,description:P(e.description,e.level==="issue"?"Vertical slice issue":e.level==="subtask"?"Granular child step":"Focused AI session task"),searchText:I([e.title,e.description,e.aiInstructions,e.executionMode??"",e.status,((a=e.user)==null?void 0:a.displayName)??"",...(e.assignees??[]).map(c=>c.displayName),...e.tagIds.map(c=>y.get(c)??"")].join(" ")),href:`/tasks/${e.id}`,statusLabel:e.status,executionMode:e.executionMode,goalId:e.goalId,projectId:e.projectId,tagIds:e.tagIds,user:e.user,assignees:e.assignees??[],linkedUserIds:[...e.user?[e.user.id]:[],...e.assigneeUserIds??[]],progressPercent:null,progressLabel:null,children:(h.get(e.id)??[]).map(b)})},f=e=>{var c;const a=n.filter(o=>o.targetProjectIds.includes(e.id));return S({id:`project:${e.id}`,entityId:e.id,kind:"project",label:e.title,description:P(e.description||e.productRequirementsDocument,"PRD-backed initiative"),searchText:I([e.title,e.description,e.productRequirementsDocument,e.goalTitle,e.workflowStatus,e.status,((c=e.user)==null?void 0:c.displayName)??"",...(e.assignees??[]).map(o=>o.displayName)].join(" ")),href:`/projects/${e.id}`,statusLabel:e.workflowStatus,executionMode:null,goalId:e.goalId,projectId:e.id,tagIds:[],user:e.user,assignees:e.assignees??[],linkedUserIds:[...e.user?[e.user.id]:[],...e.assigneeUserIds??[]],progressPercent:e.progress,progressLabel:`${e.completedTaskCount}/${e.totalTasks} done`,children:[...a.map(o=>{var p;return S({id:`strategy:${o.id}`,entityId:o.id,kind:"strategy",label:o.title,description:P(o.overview||o.endStateDescription,"Execution strategy"),searchText:I([o.title,o.overview,o.endStateDescription,o.status,((p=o.user)==null?void 0:p.displayName)??""].join(" ")),href:`/strategies/${o.id}`,statusLabel:o.status,executionMode:null,goalId:e.goalId,projectId:e.id,tagIds:[],user:o.user,assignees:[],linkedUserIds:o.user?[o.user.id]:[],progressPercent:null,progressLabel:null,children:[]})}),...(v.get(e.id)??[]).map(b),...(m.get(e.id)??[]).map(b)]})};return i.map(e=>{var B,w;const a=d.filter(l=>l.goalId===e.id),c=n.filter(l=>l.targetGoalIds.includes(e.id)),o=new Map(c.map(l=>[l.id,[]])),p=new Set;for(const l of a){const N=c.find(U=>U.targetProjectIds.includes(l.id));N&&((B=o.get(N.id))==null||B.push(l),p.add(l.id))}const M=c.map(l=>{var N;return S({id:`strategy:${l.id}`,entityId:l.id,kind:"strategy",label:l.title,description:P(l.overview||l.endStateDescription,"High-level strategy"),searchText:I([l.title,l.overview,l.endStateDescription,l.status,((N=l.user)==null?void 0:N.displayName)??""].join(" ")),href:`/strategies/${l.id}`,statusLabel:l.status,executionMode:null,goalId:e.id,projectId:null,tagIds:[],user:l.user,assignees:[],linkedUserIds:l.user?[l.user.id]:[],progressPercent:null,progressLabel:null,children:(o.get(l.id)??[]).map(f)})}),$=a.filter(l=>!p.has(l.id)).map(f);return S({id:`goal:${e.id}`,entityId:e.id,kind:"goal",label:e.title,description:P(e.description,"Strategic goal"),searchText:I([e.title,e.description,e.status,((w=e.user)==null?void 0:w.displayName)??""].join(" ")),href:`/goals/${e.id}`,statusLabel:e.status,executionMode:null,goalId:e.id,projectId:null,tagIds:e.tagIds,user:e.user,assignees:[],linkedUserIds:e.user?[e.user.id]:[],progressPercent:null,progressLabel:null,children:[...M,...$]})})}function K(r){return r.reduce((i,n)=>i+1+K(n.children??[]),0)}function pe(r,i){return r.searchText.includes(I(i.query))&&(i.kind==="any"||i.kind===r.kind)}function G(r,i,n=!1){const{clauses:d,statusFilters:g,ownerUserIds:y,ownerKinds:h,selectedUserIds:v}=i,m=d.length===0||d.some(p=>pe(r,p)),b=g.length===0||r.statusLabel!==null&&g.includes(r.statusLabel),f=y.length===0&&v.length===0?!0:[...y,...v].some(p=>r.linkedUserIds.includes(p)),e=h.length===0||[r.user,...r.assignees].some(p=>p&&h.includes(p.kind)),a=b&&f&&e,c=d.length===0||n||m,o=(r.children??[]).map(p=>G(p,i,n||a&&m)).filter(p=>p!==null);return a&&c||o.length>0?{...r,children:o}:null}function Q(r,i){return r.flatMap(n=>{const d=Q(n.children??[],i);return i.includes(n.kind)?[{...n,children:d}]:d})}function xe(r){switch(r){case"goal":return"bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_76%,var(--ui-ink-strong)_24%)]";case"strategy":return"bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]";case"project":return"bg-[var(--ui-accent-soft)] text-[var(--primary)]";case"issue":return"bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_72%,var(--ui-ink-strong)_28%)]";case"subtask":return"border-[color-mix(in_srgb,var(--tertiary)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-tertiary-soft)] text-[var(--tertiary)]";default:return"bg-[var(--ui-tertiary-soft)] text-[var(--tertiary)]"}}function z(r){switch(r){case"done":case"completed":return"bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]";case"blocked":return"bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]";case"in_progress":case"active":return"bg-[var(--ui-accent-soft)] text-[var(--primary)]";case"focus":return"bg-[var(--ui-tertiary-soft)] text-[var(--tertiary)]";default:return"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]"}}function W(r){return r==="any"?s.jsx(j,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:"Any"}):r==="subtask"?s.jsx(D,{kind:"task",label:"Subtask",compact:!0,gradient:!1,className:"border-[color-mix(in_srgb,var(--tertiary)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-tertiary-soft)] text-[var(--tertiary)]"}):s.jsx(D,{kind:r==="issue"?"issue":r,label:r,compact:!0,gradient:!1})}function be({query:r,onQueryChange:i,clauses:n,onClausesChange:d,resultSummary:g}){const[y,h]=x.useState(!1),[v,m]=x.useState(0),b=x.useMemo(()=>ge(r).filter(a=>!n.some(c=>c.id===a.id)),[n,r]),f=a=>{d([...n,a]),i(""),m(0),h(!1)},e=a=>{d(n.filter(c=>c.id!==a))};return s.jsx("div",{className:"grid gap-3",children:s.jsxs("div",{className:"rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4 shadow-[var(--ui-shadow-soft)] sm:p-5",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--ui-ink-faint)]",children:"Hierarchy search"}),s.jsxs("div",{className:"mt-2 max-w-3xl text-sm leading-6 text-[var(--ui-ink-soft)]",children:["Build OR clauses like"," ",s.jsx("span",{className:"text-[var(--ui-ink-strong)]",children:'Goal + "MD"'})," ","or"," ",s.jsx("span",{className:"text-[var(--ui-ink-strong)]",children:'Any + "Happy"'}),". Matching ancestors keep their branches visible so you can explore the hierarchy, not lose it."]})]}),n.length>0||r.trim().length>0?s.jsx(C,{variant:"secondary",size:"sm",onClick:()=>{i(""),d([]),m(0),h(!1)},children:"Clear search"}):null]}),s.jsxs("div",{className:"mt-4 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3",children:[n.length>0?s.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:n.map(a=>s.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-2.5 py-1.5",children:[W(a.kind),s.jsxs("span",{className:"max-w-[14rem] truncate text-sm text-[var(--ui-ink-medium)]",children:['"',a.query,'"']}),s.jsx("button",{type:"button",className:"rounded-full text-[var(--ui-ink-soft)] transition hover:text-[var(--ui-ink-strong)]",onClick:()=>e(a.id),"aria-label":`Remove ${a.kind} ${a.query}`,children:s.jsx(ee,{className:"size-3.5"})})]},a.id))}):null,s.jsxs("div",{className:"relative",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(se,{className:"size-4 text-[var(--ui-ink-muted)]"}),s.jsx("input",{value:r,onChange:a=>{i(a.target.value),h(!0),m(0)},onFocus:()=>h(!0),onBlur:()=>{window.setTimeout(()=>h(!1),120)},onKeyDown:a=>{if(a.key==="Backspace"&&!r&&n.length>0){e(n[n.length-1].id);return}if(a.key==="ArrowDown"){a.preventDefault(),h(!0),m(c=>b.length===0?0:Math.min(b.length-1,c+1));return}if(a.key==="ArrowUp"){a.preventDefault(),m(c=>Math.max(0,c-1));return}if(a.key==="Escape"){h(!1);return}a.key==="Enter"&&b[v]&&(a.preventDefault(),f(b[v]))},placeholder:'Type text, then pick a clause like Goal + "MD" or Any + "Happy"',className:"min-w-0 flex-1 bg-transparent text-sm text-[var(--ui-ink-strong)] placeholder:text-[var(--ui-ink-muted)] focus:outline-none"})]}),y?s.jsx("div",{className:"absolute top-full z-20 mt-2 w-full rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-popover)] p-2 shadow-[var(--ui-shadow-strong)] backdrop-blur-xl",children:b.length>0?b.map((a,c)=>s.jsx("button",{type:"button",className:F("flex w-full items-start justify-between gap-3 rounded-[18px] px-3 py-2.5 text-left transition",c===v?"bg-[var(--ui-surface-active)] text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"),onMouseEnter:()=>m(c),onMouseDown:o=>o.preventDefault(),onClick:()=>f(a),children:s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[W(a.kind),s.jsxs("span",{className:"truncate text-sm font-medium text-[var(--ui-ink-strong)]",children:['"',a.query,'"']})]}),s.jsxs("div",{className:"mt-1 text-xs leading-5 text-[var(--ui-ink-soft)]",children:["Match ",a.kind==="any"?"any visible hierarchy node":`${a.kind} nodes`," that mention this text."]})]})},a.id)):s.jsx("div",{className:"px-3 py-2.5 text-sm text-[var(--ui-ink-muted)]",children:"Type a word or phrase to create a new OR clause."})}):null]})]}),s.jsx("div",{className:"mt-3 text-sm text-[var(--ui-ink-soft)]",children:g})]})})}function Se(){const r=te(),i=x.useRef(null),[n,d]=x.useState(""),[g,y]=x.useState([]),[h,v]=x.useState([]),[m,b]=x.useState([...L]),[f,e]=x.useState(T),a=re({queryKey:["work-items-hierarchy",...r.selectedUserIds],queryFn:()=>oe({userIds:r.selectedUserIds})}),c=x.useMemo(()=>{const t=r.snapshot.users.filter(u=>u.kind==="bot"),k=r.snapshot.users.filter(u=>u.kind==="human");return[{value:`${_.kind}bot`,label:"Bots",description:`${t.length} bot collaborators`,searchText:`bots bot ai agents assistants ${t.map(u=>`${u.displayName} ${u.handle}`).join(" ")}`,badge:s.jsx(j,{className:"border-[color-mix(in_srgb,var(--info)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]",children:"Bots"}),menuBadge:s.jsx(j,{className:"border-[color-mix(in_srgb,var(--info)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]",children:"Bots"})},{value:`${_.kind}human`,label:"Humans",description:`${k.length} human collaborators`,searchText:`humans human people operators ${k.map(u=>`${u.displayName} ${u.handle}`).join(" ")}`,badge:s.jsx(j,{className:"border-[color-mix(in_srgb,var(--warning)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_76%,var(--ui-ink-strong)_24%)]",children:"Humans"}),menuBadge:s.jsx(j,{className:"border-[color-mix(in_srgb,var(--warning)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_76%,var(--ui-ink-strong)_24%)]",children:"Humans"})},...r.snapshot.users.map(u=>({value:`${_.user}${u.id}`,label:u.displayName,description:`${u.kind}${u.handle?` · @${u.handle}`:""}`,searchText:`${u.displayName} ${u.handle} ${u.kind} ${u.description}`,badge:s.jsx(R,{user:u,compact:!0}),menuBadge:s.jsx(R,{user:u,compact:!0})}))]},[r.snapshot.users]),o=x.useMemo(()=>[{value:"goal",label:"Goal",searchText:"goal direction objective",kind:"goal"},{value:"strategy",label:"Strategy",searchText:"strategy plan sequencing",kind:"strategy"},{value:"project",label:"Project",searchText:"project initiative prd",kind:"project"},{value:"issue",label:"Issue",searchText:"issue vertical slice tracer bullet",kind:"issue"},{value:"task",label:"Task",searchText:"task execution ai session",kind:"task"},{value:"subtask",label:"Subtask",searchText:"subtask child step",badge:s.jsx(D,{kind:"task",label:"Subtask",compact:!0,gradient:!1,className:"border-[color-mix(in_srgb,var(--tertiary)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-tertiary-soft)] text-[var(--tertiary)]"}),menuBadge:s.jsx(D,{kind:"task",label:"Subtask",compact:!0,gradient:!1,className:"border-[color-mix(in_srgb,var(--tertiary)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-tertiary-soft)] text-[var(--tertiary)]"})}],[]),p=x.useMemo(()=>[{value:"active",label:"Active",searchText:"active in progress live"},{value:"paused",label:"Paused",searchText:"paused suspended"},{value:"completed",label:"Completed",searchText:"completed finished"},{value:"backlog",label:"Backlog",searchText:"backlog queued"},{value:"focus",label:"Focus",searchText:"focus ready"},{value:"in_progress",label:"In progress",searchText:"in progress active doing"},{value:"blocked",label:"Blocked",searchText:"blocked stuck"},{value:"done",label:"Done",searchText:"done complete finished"}].map(t=>({...t,badge:s.jsx(j,{className:z(t.value),children:t.label}),menuBadge:s.jsx(j,{className:z(t.value),children:t.label})})),[]),M=x.useMemo(()=>new Map(r.snapshot.tags.map(t=>[t.id,t.name])),[r.snapshot.tags]),$=x.useMemo(()=>a.data?V({...a.data,tagNameById:M}):V({goals:r.snapshot.goals,strategies:r.snapshot.strategies,projects:r.snapshot.dashboard.projects,tagNameById:M,workItems:r.snapshot.workItems&&r.snapshot.workItems.length>0?r.snapshot.workItems:r.snapshot.tasks}),[a.data,r.snapshot,M]),B=n.trim().length>0||g.length>0||h.length>0||m.length!==L.length||L.some(t=>!m.includes(t))||f.length!==T.length||T.some(t=>!f.includes(t)),w=x.useMemo(()=>ue(h),[h]),l=x.useMemo(()=>{const t=$.map(k=>G(k,{clauses:g,statusFilters:m,ownerUserIds:w.userIds,ownerKinds:w.kinds,selectedUserIds:r.selectedUserIds})).filter(k=>k!==null);return Q(t,f)},[$,w.kinds,w.userIds,g,m,r.selectedUserIds,f]),N=x.useMemo(()=>K(l),[l]),U=`${g.length>0?`${g.length} OR clause${g.length===1?"":"s"} active`:"Search across the full hierarchy"} · ${N} visible node${N===1?"":"s"}.`;return a.isLoading&&$.length===0?s.jsx(ae,{eyebrow:"Hierarchy",title:"Building Forge hierarchy",description:"Loading goals, strategies, projects, issues, tasks, and subtasks into the compact hierarchy view."}):a.isError&&$.length===0?s.jsx(ie,{eyebrow:"Hierarchy",error:a.error,onRetry:()=>void a.refetch()}):s.jsxs("div",{className:"grid min-w-0 gap-5",children:[s.jsx(ce,{}),s.jsx(de,{title:"Hierarchy",description:"Explore the full Forge stack from goal to subtask in one compact operational tree, with both strategy layers visible and the same control surfaces as the board.",badge:`${N} visible nodes`}),s.jsxs(O,{className:"min-w-0 overflow-hidden border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3 border-b border-[var(--ui-border-subtle)] px-5 py-4",children:[s.jsxs("div",{children:[s.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Hierarchy controls"}),s.jsx("div",{className:"mt-2 max-w-3xl text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Filter across goals, projects, tags, humans, bots, and work-item types, then expand or collapse the full tree without losing the hierarchy context."})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsx(C,{variant:"secondary",size:"sm",onClick:()=>{var t,k;return(k=(t=i.current)==null?void 0:t.openAll)==null?void 0:k.call(t)},children:"Expand all"}),s.jsx(C,{variant:"secondary",size:"sm",onClick:()=>{var t,k;return(k=(t=i.current)==null?void 0:t.closeAll)==null?void 0:k.call(t)},children:"Collapse all"}),B?s.jsx(C,{variant:"secondary",size:"sm",onClick:()=>{d(""),y([]),v([]),b([...L]),e(T)},children:"Reset"}):null]})]}),s.jsxs("div",{className:"grid gap-4 px-5 py-5",children:[s.jsx(be,{query:n,onQueryChange:d,clauses:g,onClausesChange:y,resultSummary:U}),s.jsxs("div",{className:"grid gap-3 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,1fr)_minmax(0,1fr)]",children:[s.jsx(A,{options:p,selectedValues:m,onChange:t=>b(t),placeholder:"Visible states",emptyMessage:"No states available.",variant:"action-bar"}),s.jsx(A,{options:o,selectedValues:f,onChange:t=>e(t),placeholder:"Visible levels",emptyMessage:"No hierarchy levels.",className:"min-w-0",variant:"action-bar"}),s.jsx(A,{options:c,selectedValues:h,onChange:v,placeholder:"Filter by human, bot, or collaborator",emptyMessage:"No matching collaborators."})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs(j,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[l.length," top-level nodes"]}),s.jsxs(j,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[N," visible nodes"]}),s.jsx(j,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:f.join(" + ")})]})]})]}),l.length===0?s.jsx(ne,{eyebrow:"Hierarchy",title:"No hierarchy nodes match the current filters",description:"Clear some filters or broaden the search to bring the full planning ladder back into view.",action:s.jsx(C,{variant:"secondary",onClick:()=>{d(""),y([]),v([]),b([...L]),e(T)},children:"Reset hierarchy filters"})}):s.jsxs(O,{className:"min-w-0 overflow-hidden border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-0",children:[s.jsxs("div",{className:"grid grid-cols-[minmax(0,1.8fr)_auto_auto_auto] gap-3 border-b border-[var(--ui-border-subtle)] px-5 py-3 text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:[s.jsx("div",{children:"Name"}),s.jsx("div",{className:"hidden lg:block",children:"State"}),s.jsx("div",{className:"hidden xl:block",children:"People"}),s.jsx("div",{className:"hidden lg:block",children:"Progress"})]}),s.jsx("div",{className:"p-2",children:s.jsx(X,{ref:i,data:l,width:"100%",height:760,rowHeight:64,overscanCount:10,childrenAccessor:t=>t.children??null,openByDefault:!0,paddingTop:8,paddingBottom:8,disableDrag:!0,className:"text-sm",children:({node:t,style:k})=>{const u=t.data.kind==="subtask"?"task":t.data.kind,E=le(u),H=E.colorToken.rgb.join(", ");return s.jsx("div",{style:k,className:"px-2 py-1.5",children:s.jsxs("div",{className:F("grid min-w-0 items-center gap-3 rounded-[16px] border border-[var(--ui-border-subtle)] px-3 py-2 transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]","grid-cols-[minmax(0,1.8fr)_auto] lg:grid-cols-[minmax(0,1.8fr)_auto_auto] xl:grid-cols-[minmax(0,1.8fr)_auto_auto_auto]"),style:{marginLeft:`${t.level*14}px`,background:`color-mix(in srgb, rgb(${H}) 7%, var(--ui-surface-1))`},children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[s.jsx("button",{type:"button",className:"inline-flex size-7 shrink-0 items-center justify-center rounded-full bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",onClick:()=>t.toggle(),disabled:t.isLeaf,"aria-label":t.isOpen?`Collapse ${t.data.label}`:`Expand ${t.data.label}`,children:t.isLeaf?s.jsx("span",{className:"size-2 rounded-full bg-[var(--ui-ink-muted)]"}):t.isOpen?s.jsx(Y,{className:"size-4"}):s.jsx(Z,{className:"size-4"})}),s.jsx("span",{className:F("inline-flex size-9 shrink-0 items-center justify-center rounded-[12px] border",E.subtleBadgeClassName),children:s.jsx(E.icon,{className:F("size-4",E.iconClassName)})}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(j,{className:xe(t.data.kind),children:t.data.kind}),t.data.executionMode?s.jsx(j,{className:t.data.executionMode==="afk"?"bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]":"bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_76%,var(--ui-ink-strong)_24%)]",children:t.data.executionMode.toUpperCase()}):null,s.jsx("div",{className:"truncate text-[13px] font-medium text-[var(--ui-ink-strong)]",children:t.data.label})]}),s.jsx("div",{className:"mt-0.5 truncate text-[11px] leading-5 text-[var(--ui-ink-soft)]",children:t.data.description})]})]}),s.jsx("div",{className:"hidden lg:flex justify-end",children:s.jsx(j,{className:z(t.data.statusLabel),children:t.data.statusLabel?t.data.statusLabel.replaceAll("_"," "):"linked"})}),s.jsxs("div",{className:"hidden xl:flex items-center justify-end gap-2",children:[t.data.user?s.jsx(R,{user:t.data.user,compact:!0}):null,t.data.assignees.length>0?s.jsxs(j,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:["+",t.data.assignees.length]}):null]}),s.jsxs("div",{className:"hidden lg:flex min-w-[11rem] items-center justify-end gap-3",children:[s.jsxs("div",{className:"min-w-[7.5rem]",children:[s.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-[var(--ui-surface-2)]",children:s.jsx("div",{className:"h-full rounded-full",style:{width:`${t.data.progressPercent??0}%`,background:`linear-gradient(90deg, rgb(${H}), color-mix(in srgb, rgb(${H}) 72%, var(--ui-surface-1)))`}})}),s.jsx("div",{className:"mt-1 text-[11px] text-[var(--ui-ink-faint)]",children:t.data.progressLabel??`${t.data.progressPercent??0}% complete`})]}),t.data.href?s.jsx(J,{to:t.data.href,className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-1.5 text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-medium)] transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",children:"Open"}):s.jsx("span",{className:"w-[3.75rem]"})]})]})})}})})]})]})}export{Se as ProjectManagementHierarchyPage};
@@ -0,0 +1 @@
1
+ import{aJ as v,r as l,cB as b,cC as f,aU as p,j as e,bB as m,F as h,aK as g}from"./vendor-Dnkkx2co.js";import{C as j,Z as c}from"./index-EqQsXoat.js";const i=[{to:"/projects",label:"Projects",icon:b},{to:"/kanban",label:"Board",icon:f},{to:"/projects/hierarchy",label:"Hierarchy",icon:p}];function d(t,s){return s==="/projects"?t==="/projects"||/^\/projects\/[^/]+$/.test(t):t===s||t.startsWith(`${s}/`)}function y({className:t}){const s=v(),[o,n]=l.useState(!1),u=l.useMemo(()=>[...i].sort((r,a)=>a.to.length-r.to.length).find(r=>d(s.pathname,r.to))??i[0],[s.pathname]);return l.useEffect(()=>{if(!o)return;const r=document.body.style.overflow,a=x=>{x.key==="Escape"&&n(!1)};return document.body.style.overflow="hidden",window.addEventListener("keydown",a),()=>{document.body.style.overflow=r,window.removeEventListener("keydown",a)}},[o]),e.jsxs(e.Fragment,{children:[e.jsxs(j,{className:c("overflow-hidden bg-[var(--card-gradient)] p-2",t),children:[e.jsx("div",{className:"hidden items-center gap-3 lg:flex",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:i.map(r=>e.jsxs(m,{to:r.to,end:r.to==="/projects",className:({isActive:a})=>c("inline-flex items-center gap-2 whitespace-nowrap rounded-full px-3 py-1.5 text-[11px] font-semibold uppercase tracking-[0.14em] transition",a||d(s.pathname,r.to)?"border border-[color-mix(in_srgb,var(--info)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]":"border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"),children:[e.jsx(r.icon,{className:"size-3.5"}),e.jsx("span",{children:r.label})]},r.to))})}),e.jsx("div",{className:"flex items-center justify-between gap-3 lg:hidden",children:e.jsx("button",{type:"button",className:"inline-flex min-w-0 flex-1 items-center gap-3 rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3.5 py-2.5 text-left shadow-[var(--ui-shadow-soft)] transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]",onClick:()=>n(!0),children:e.jsxs("span",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-2xl border border-[color-mix(in_srgb,var(--info)_24%,var(--ui-border-subtle)_76%)] bg-[var(--ui-info-soft)]",children:e.jsx(u.icon,{className:"size-4 text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]"})}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-[10px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Project management"}),e.jsx("span",{className:"mt-0.5 block truncate text-sm font-medium text-[var(--ui-ink-strong)]",children:u.label})]})]})})})]}),o&&typeof document<"u"?h.createPortal(e.jsxs("div",{className:"lg:hidden",children:[e.jsx("div",{className:"surface-overlay fixed inset-0 z-50 backdrop-blur-xl"}),e.jsx("button",{type:"button","aria-label":"Close project management sections",className:"fixed inset-0 z-[51]",onClick:()=>n(!1)}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-[52] flex items-end justify-center px-3 pt-3 sm:px-4 sm:pt-4",style:{paddingBottom:"calc(var(--forge-mobile-nav-clearance) - 0.25rem)"},children:e.jsxs("div",{className:"surface-modal-panel pointer-events-auto flex max-h-[min(34rem,calc(100dvh-var(--forge-mobile-nav-clearance)-1rem))] w-full max-w-xl min-h-0 flex-col overflow-hidden rounded-[30px] border shadow-[var(--ui-shadow-strong)]",children:[e.jsx("div",{className:"shrink-0 border-b border-[var(--ui-border-subtle)] px-4 pb-2.5 pt-3 sm:px-5",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[10px] uppercase tracking-[0.22em] text-[var(--ui-ink-muted)]",children:"Forge PM"}),e.jsx("div",{className:"mt-1.5 flex min-w-0 flex-wrap items-center gap-2",children:e.jsx("div",{className:"truncate text-[1.05rem] font-semibold text-[var(--ui-ink-strong)]",children:"Browse the hierarchy"})})]}),e.jsx("button",{type:"button","aria-label":"Close project management sections",className:"inline-flex size-10 shrink-0 items-center justify-center rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",onClick:()=>n(!1),children:e.jsx(g,{className:"size-4"})})]})}),e.jsx("div",{className:"min-h-0 overflow-y-auto p-3 overscroll-contain sm:p-4",children:e.jsx("div",{className:"grid gap-2",children:i.map(r=>{const a=d(s.pathname,r.to);return e.jsx(m,{to:r.to,end:r.to==="/projects",onClick:()=>n(!1),className:c("group flex items-center justify-between gap-3 rounded-[22px] border px-3.5 py-3 transition hover:-translate-y-[1px] hover:text-[var(--ui-ink-strong)]",a?"border-[color-mix(in_srgb,var(--info)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]"),children:e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"flex size-10 items-center justify-center rounded-2xl border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]",children:e.jsx(r.icon,{className:"size-4"})}),e.jsx("span",{className:"text-sm font-medium",children:r.label})]})},r.to)})})})]})})]}),document.body):null]})}export{y as P};
@@ -0,0 +1 @@
1
+ import{j as e,r as g,aK as X,b3 as J,aC as A}from"./vendor-Dnkkx2co.js";import{A as Y}from"./ai-surface-workspace-CutiG6uS.js";import{P as Z}from"./pill-cluster-C2D0h3lx.js";import{Z as Q,c as T,b as D,u as U,bk as F,bl as R,_ as q,C as M,U as ee,V as W,W as H,B as O,a as se,bS as te,bT as ae,bU as ie}from"./index-EqQsXoat.js";import{P as re}from"./page-hero-ffKzgyW3.js";import{E as ne}from"./entity-note-count-link-RzBB6ujx.js";import{b as le,f as oe,P as ce}from"./project-collections-qSqp90HN.js";import{P as de}from"./project-management-section-nav-BImLCVvf.js";import"./board-dIX6etHh.js";import"./state-vCcAT5Hq.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./graph-DDUZNRsO.js";function ue({children:t,columns:d="single",className:w}){return e.jsx("section",{className:Q("grid gap-4",d==="two"&&"lg:grid-cols-2",d==="sidebar"&&"xl:grid-cols-[minmax(0,25rem)_minmax(0,1fr)]",w),children:t})}function me(t){return t.trim().toLowerCase()}function V(t,d=!1){switch(t.kind){case"goal":return e.jsx(D,{kind:"goal",label:t.label,compact:!0,gradient:!1});case"task":return e.jsx(D,{kind:"task",label:t.label,compact:!0,gradient:!1});case"tag":return e.jsx(T,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:t.label});case"status":return e.jsx(T,{className:"bg-[var(--ui-accent-soft)] text-[color-mix(in_srgb,var(--primary)_72%,var(--ui-ink-strong)_28%)]",children:t.label});case"type":return e.jsx(T,{className:"bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]",children:t.label});case"user":return e.jsx(T,{className:"bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]",children:t.label});default:return t.label}}function he({query:t,onQueryChange:d,options:w,selectedOptionIds:m,onSelectedOptionIdsChange:I,resultSummary:C}){const[L,j]=g.useState(!1),[P,p]=g.useState(0),N=g.useMemo(()=>m.map(n=>w.find(o=>o.id===n)).filter(Boolean),[w,m]),S=me(t),b=g.useMemo(()=>{const n=w.filter(o=>!m.includes(o.id));return S?n.filter(o=>`${o.label} ${o.description??""} ${o.searchText??""}`.toLowerCase().includes(S)).slice(0,10):n.slice(0,10)},[S,w,m]),k=n=>{m.includes(n)||(I([...m,n]),d(""),p(0),j(!1))},B=n=>{I(m.filter(o=>o!==n))},K=()=>{d(""),I([]),p(0),j(!1)};return e.jsx("div",{className:"grid gap-3",children:e.jsxs("div",{className:"rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4 shadow-[var(--ui-shadow-soft)] sm:p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--ui-ink-muted)]",children:"Project search"}),e.jsx("div",{className:"mt-2 max-w-2xl text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Search with free text, then pin matching goals, tasks, tags, human users, bot users, statuses, or project-type chips as you narrow the list."})]}),t.trim().length>0||m.length>0?e.jsx("button",{type:"button",onClick:K,className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-2 text-sm text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",children:"Clear search"}):null]}),e.jsxs("div",{className:"mt-4 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3",children:[N.length>0?e.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:N.map(n=>e.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-2.5 py-1.5",children:[V(n,!0),e.jsx("button",{type:"button",className:"rounded-full text-[var(--ui-ink-soft)] transition hover:text-[var(--ui-ink-strong)]",onClick:()=>B(n.id),"aria-label":`Remove ${n.label}`,children:e.jsx(X,{className:"size-3.5"})})]},n.id))}):null,e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(J,{className:"size-4 text-[var(--ui-ink-muted)]"}),e.jsx("input",{value:t,onChange:n=>{d(n.target.value),j(!0),p(0)},onFocus:()=>j(!0),onBlur:()=>{window.setTimeout(()=>j(!1),120)},onKeyDown:n=>{if(n.key==="Backspace"&&!t&&m.length>0){B(m[m.length-1]);return}if(n.key==="ArrowDown"){n.preventDefault(),j(!0),p(o=>b.length===0?0:Math.min(b.length-1,o+1));return}if(n.key==="ArrowUp"){n.preventDefault(),p(o=>Math.max(0,o-1));return}if(n.key==="Escape"){j(!1);return}n.key==="Enter"&&b[P]&&(n.preventDefault(),k(b[P].id))},placeholder:"Type a project, goal, task, human, bot, user, or tag",className:"min-w-0 flex-1 bg-transparent text-sm text-[var(--ui-ink-strong)] placeholder:text-[var(--ui-ink-muted)] focus:outline-none"})]}),L?e.jsx("div",{className:"absolute top-full z-20 mt-2 w-full rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-popover)] p-2 shadow-[var(--ui-shadow-strong)] backdrop-blur-xl",children:b.length>0?b.map((n,o)=>e.jsx("button",{type:"button",className:Q("flex w-full items-start justify-between gap-3 rounded-[18px] px-3 py-2.5 text-left transition",o===P?"bg-[var(--ui-surface-active)] text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"),onMouseEnter:()=>p(o),onMouseDown:_=>_.preventDefault(),onClick:()=>k(n.id),children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:V(n)}),n.description?e.jsx("div",{className:"mt-1 text-xs leading-5 text-[var(--ui-ink-soft)]",children:n.description}):null]})},n.id)):e.jsx("div",{className:"px-3 py-2.5 text-sm text-[var(--ui-ink-muted)]",children:"Keep typing to search by free text, or select a suggested goal, task, human or bot owner, tag, status, or type chip when it appears."})}):null]})]}),e.jsx("div",{className:"mt-3 text-sm text-[var(--ui-ink-soft)]",children:C})]})})}const pe={execution:"Execution",value:"Value",category:"Category"};function xe(t){return t.trim().toLowerCase()}function Ie(){const t=U(),[d,w]=g.useState("active"),[m,I]=g.useState(""),[C,L]=g.useState([]),[j,P]=g.useState(null),p=g.useMemo(()=>le(t.snapshot.dashboard.projects),[t.snapshot.dashboard.projects]),N=g.useMemo(()=>{const a=new Map(t.snapshot.dashboard.goals.map(r=>[r.id,r])),l=new Map(t.snapshot.tags.map(r=>[r.id,r])),u=new Map(t.snapshot.users.map(r=>[r.id,r])),f=new Map;for(const r of t.snapshot.tasks){if(!r.projectId)continue;const x=f.get(r.projectId)??[];x.push(r),f.set(r.projectId,x)}return new Map(t.snapshot.dashboard.projects.map(r=>{const x=a.get(r.goalId)??null,$=f.get(r.id)??[],v=r.userId?u.get(r.userId)??null:null,y=new Map;for(const c of(x==null?void 0:x.tags)??[])y.set(c.id,{id:c.id,name:c.name,kind:c.kind});for(const c of $)for(const s of c.tagIds){const i=l.get(s);i&&y.set(i.id,{id:i.id,name:i.name,kind:i.kind})}const E=Array.from(new Set(Array.from(y.values()).map(c=>c.kind))),z=[r.title,r.description,r.goalTitle,(v==null?void 0:v.displayName)??"",(v==null?void 0:v.handle)??"",(v==null?void 0:v.kind)??"",(x==null?void 0:x.description)??"",r.nextTaskTitle??"",r.momentumLabel,r.status,$.map(c=>c.title).join(" "),Array.from(y.values()).map(c=>`${c.name} ${c.kind}`).join(" ")].join(" ").toLowerCase();return[r.id,{tagIds:Array.from(y.keys()),tags:Array.from(y.values()),taskIds:$.map(c=>c.id),typeKeys:E,userId:r.userId,searchText:z}]}))},[t.snapshot.dashboard.goals,t.snapshot.dashboard.projects,t.snapshot.tags,t.snapshot.tasks,t.snapshot.users]),S=g.useMemo(()=>{var v,y,E,z,c;const a=new Map,l=new Map,u=new Map,f=new Map,r=new Map,x=new Map,$=new Map;for(const s of t.snapshot.dashboard.projects){const i=N.get(s.id);if(i){l.has(s.goalId)||l.set(s.goalId,new Set),l.get(s.goalId).add(s.id),r.has(s.status)||r.set(s.status,new Set),r.get(s.status).add(s.id);for(const h of i.taskIds)u.has(h)||u.set(h,new Set),u.get(h).add(s.id);for(const h of i.tags)f.has(h.id)||f.set(h.id,new Set),f.get(h.id).add(s.id);for(const h of i.typeKeys)x.has(h)||x.set(h,new Set),x.get(h).add(s.id);i.userId&&($.has(i.userId)||$.set(i.userId,new Set),$.get(i.userId).add(s.id))}}for(const s of t.snapshot.dashboard.goals){const i=((v=l.get(s.id))==null?void 0:v.size)??0;i!==0&&a.set(`goal:${s.id}`,{id:`goal:${s.id}`,kind:"goal",value:s.id,label:s.title,description:R(`${i} project${i===1?"":"s"} linked to this goal`,s.user,`${i} project${i===1?"":"s"} linked to this goal`),searchText:F([s.title,s.description],s)})}for(const s of t.snapshot.tasks){const i=((y=u.get(s.id))==null?void 0:y.size)??0;i!==0&&a.set(`task:${s.id}`,{id:`task:${s.id}`,kind:"task",value:s.id,label:s.title,description:R(`${i} project${i===1?"":"s"} linked to this task`,s.user,`${i} project${i===1?"":"s"} linked to this task`),searchText:F([s.title,s.description],s)})}for(const s of t.snapshot.tags){const i=((E=f.get(s.id))==null?void 0:E.size)??0;i!==0&&a.set(`tag:${s.id}`,{id:`tag:${s.id}`,kind:"tag",value:s.id,label:s.name,description:R(`${i} project${i===1?"":"s"} touching this tag`,s.user,`${i} project${i===1?"":"s"} touching this tag`),searchText:F([s.name,s.kind,s.description],s)})}for(const[s,i]of Object.entries(p))s==="all"||i===0||a.set(`status:${s}`,{id:`status:${s}`,kind:"status",value:s,label:s==="paused"?"Suspended":s==="completed"?"Finished":"Active",description:`${i} project${i===1?"":"s"} currently ${s==="paused"?"suspended":s==="completed"?"finished":"active"}`,searchText:`${s} ${s==="paused"?"suspended":""} ${s==="completed"?"finished":""}`});for(const[s,i]of Object.entries(pe)){const h=((z=x.get(s))==null?void 0:z.size)??0;h!==0&&a.set(`type:${s}`,{id:`type:${s}`,kind:"type",value:s,label:i,description:`${h} project${h===1?"":"s"} linked to ${i.toLowerCase()} tags`,searchText:`${i} ${s} project type`})}for(const s of t.snapshot.users){const i=((c=$.get(s.id))==null?void 0:c.size)??0;i!==0&&a.set(`user:${s.id}`,{id:`user:${s.id}`,kind:"user",value:s.id,label:s.displayName,description:`${i} project${i===1?"":"s"} owned by this ${s.kind}`,searchText:`${s.displayName} ${s.handle} ${s.kind} ${s.description}`})}return Array.from(a.values()).sort((s,i)=>s.label.localeCompare(i.label))},[p,N,t.snapshot.dashboard.goals,t.snapshot.dashboard.projects,t.snapshot.tags,t.snapshot.tasks,t.snapshot.users]),b=g.useMemo(()=>C.map(a=>S.find(l=>l.id===a)).filter(Boolean),[S,C]),k=g.useMemo(()=>{const a=xe(m);return oe(t.snapshot.dashboard.projects,d).filter(l=>{const u=N.get(l.id);return!u||!b.every(r=>{switch(r.kind){case"goal":return l.goalId===r.value;case"task":return u.taskIds.includes(r.value);case"tag":return u.tagIds.includes(r.value);case"status":return l.status===r.value;case"type":return u.typeKeys.includes(r.value);case"user":return u.userId===r.value;default:return!0}})?!1:a?u.searchText.includes(a):!0})},[d,N,m,b,t.snapshot.dashboard.projects]),B=d==="all"?p.all:p[d],n=m.trim().length>0||C.length>0?`${k.length} matching project${k.length===1?"":"s"} in the current collection view`:`${B} project${B===1?"":"s"} in ${d==="all"?"all project states":d==="paused"?"the suspended view":d==="completed"?"the finished view":"the active view"}`,o=async a=>{P(a);try{await t.patchProject(a,{status:"active"})}finally{P(null)}},_=e.jsx(ue,{columns:"two",className:"2xl:grid-cols-3",children:k.map(a=>{const l=q(t.snapshot.dashboard.notesSummaryByEntity,"project",a.id),u=N.get(a.id),f=(u==null?void 0:u.tags.slice(0,3))??[];return e.jsxs(M,{className:"flex h-full flex-col transition hover:bg-[var(--ui-surface-hover)]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[e.jsx(D,{kind:"goal",label:a.goalTitle,compact:!0}),e.jsx(ee,{user:a.user,compact:!0})]}),e.jsx(T,{className:a.status==="completed"?"bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]":a.status==="paused"?"bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_76%,var(--ui-ink-strong)_24%)]":"bg-[var(--ui-accent-soft)] text-[var(--primary)]",children:a.status==="paused"?"Suspended":a.status==="completed"?"Finished":"Active"})]}),e.jsx("div",{className:"mt-4",children:e.jsx(A,{to:`/projects/${a.id}`,className:"transition hover:opacity-90",children:e.jsx(W,{kind:"project",label:a.title,variant:"heading",size:"xl",lines:2})})}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:a.description}),f.length>0?e.jsx(Z,{className:"mt-4",children:f.map(r=>e.jsx(T,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:r.name},r.id))}):null,e.jsx("div",{className:"mt-4",children:e.jsx(H,{value:a.progress,tone:a.status==="completed"?"secondary":"primary"})}),e.jsxs("div",{className:"mt-4 grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Active"}),e.jsx("div",{className:"mt-2 text-[var(--ui-ink-strong)]",children:a.activeTaskCount})]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Completed"}),e.jsx("div",{className:"mt-2 text-[var(--ui-ink-strong)]",children:a.completedTaskCount})]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"XP"}),e.jsx("div",{className:"mt-2 text-[var(--ui-ink-strong)]",children:a.earnedPoints})]})]}),e.jsx("div",{className:"mt-5 break-words text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)] [overflow-wrap:anywhere]",children:a.nextTaskTitle?`Next move: ${a.nextTaskTitle}`:"Ready for the next task"}),e.jsx("div",{className:"mt-4",children:e.jsx(ne,{entityType:"project",entityId:a.id,count:l.count})}),e.jsxs("div",{className:"mt-5 flex flex-wrap items-center justify-between gap-3 pt-1",children:[e.jsx(A,{to:`/projects/${a.id}`,children:e.jsx(O,{variant:"ghost",children:"Open project"})}),d!=="active"&&a.status!=="active"?e.jsx(O,{variant:"secondary",pending:j===a.id,pendingLabel:"Restarting…",onClick:()=>void o(a.id),children:"Restart"}):null]})]},a.id)})}),G=[{id:"hero",title:"Projects",description:"Route header",defaultWidth:12,defaultHeight:2,removable:!1,surfaceChrome:"none",defaultTitleVisible:!1,defaultDescriptionVisible:!1,render:()=>e.jsx(te,{children:e.jsx(re,{entityKind:"project",title:e.jsx(W,{kind:"project",label:"Projects",variant:"heading",size:"lg"}),titleText:"Projects",description:"Projects are the concrete paths that move a life goal forward.",badge:`${t.snapshot.dashboard.projects.length} total projects`})})},{id:"search-results",title:"Search and results",description:"Search stays grouped with its live result set.",defaultWidth:8,defaultHeight:6,minWidth:6,render:({compact:a})=>e.jsx(ae,{children:e.jsxs("div",{className:"grid min-w-0 gap-4",children:[e.jsx(he,{query:m,onQueryChange:I,options:S,selectedOptionIds:C,onSelectedOptionIdsChange:L,resultSummary:n}),e.jsx(ce,{value:d,counts:p,onChange:w}),k.length===0?e.jsxs(M,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"No matching projects"}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Nothing in this project collection matches the current search and chips."})]}):a?e.jsx("div",{className:"grid min-w-0 gap-3",children:k.slice(0,5).map(l=>e.jsx(A,{to:`/projects/${l.id}`,className:"block min-w-0 max-w-full rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-3 transition hover:bg-[var(--ui-surface-hover)]",children:e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-semibold text-[var(--ui-ink-strong)]",children:l.title}),e.jsx("div",{className:"truncate text-sm text-[var(--ui-ink-soft)]",children:l.goalTitle})]}),e.jsxs(T,{wrap:!0,className:"max-w-[7rem] shrink-0 bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)]",children:[l.earnedPoints," xp"]})]})},l.id))}):_]})})},{id:"summary",title:"Collection summary",description:"Counts and spotlight cards.",defaultWidth:4,defaultHeight:5,minWidth:4,render:()=>{const a=k[0]??t.snapshot.dashboard.projects[0]??null;return e.jsx(ie,{children:e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-1",children:[e.jsxs(M,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Active"}),e.jsx("div",{className:"mt-2 font-display text-4xl text-[var(--ui-ink-strong)]",children:p.active})]}),e.jsxs(M,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Finished"}),e.jsx("div",{className:"mt-2 font-display text-4xl text-[var(--ui-ink-strong)]",children:p.completed})]})]}),a?e.jsxs(M,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Spotlight"}),e.jsx("div",{className:"mt-3 text-base font-semibold text-[var(--ui-ink-strong)]",children:a.title}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:a.description}),e.jsx("div",{className:"mt-3",children:e.jsx(H,{value:a.progress})})]}):null]})})}}];return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(de,{}),t.snapshot.dashboard.projects.length===0?e.jsx(se,{eyebrow:"Projects",title:"No projects in flight",description:"Create the first practical path under a life goal so execution, kanban, and evidence all have a concrete home.",action:e.jsx(A,{to:"/goals",className:"inline-flex min-h-10 min-w-max shrink-0 items-center justify-center rounded-full bg-[var(--ui-surface-2)] px-4 py-3 text-sm whitespace-nowrap text-[var(--ui-ink-strong)] transition hover:bg-[var(--ui-surface-hover)]",children:"Open goals"})}):e.jsx(Y,{surfaceId:"projects",baseWidgets:G})]})}export{Ie as ProjectsPage};
@@ -0,0 +1,5 @@
1
+ import{j as t,aC as pe,b8 as ye,c2 as ve,r as v}from"./vendor-Dnkkx2co.js";import{j as ge,i as g,k as fe}from"./state-vCcAT5Hq.js";import{u as be,s as xe,cl as we,cm as je,bk as P,bl as N,cn as T,L as ke,E as Ce,B,V as Ie,ch as Se,c as Pe,U as Ne,_ as Te,Z as V,Q as Be,a0 as Le,a1 as Me,F as i,I as Ee,T as d,m as S,co as Fe,cp as qe,cq as Oe,by as Ae,bx as Qe,bw as De,cr as Ke,bA as Re}from"./index-EqQsXoat.js";import{E as Ue}from"./entity-note-count-link-RzBB6ujx.js";import{A as G}from"./atlas-panel-jgMRyaHn.js";import{S as H}from"./schema-badge-FY7818qB.js";import{u as We,p as _e}from"./use-psyche-focus-target-Ct-acS9G.js";import{P as $e}from"./page-hero-ffKzgyW3.js";import{p as L}from"./query-cache-IQ8W-LNC.js";import{b as J}from"./psyche-schemas-Dxj554nU.js";import{g as ze}from"./schema-visuals-CvC9a3i6.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";function Ve({entries:s}){const n={away:"border-rose-400/20 bg-[rgba(251,113,133,0.08)]",committed:"border-emerald-400/20 bg-[rgba(110,231,183,0.08)]",recovery:"border-amber-400/20 bg-[rgba(251,191,36,0.08)]"};return t.jsx("div",{className:"grid gap-3 lg:grid-cols-3",children:s.map(o=>t.jsxs(pe,{to:o.href,className:`rounded-[22px] border px-4 py-4 transition hover:-translate-y-0.5 ${n[o.tone]}`,children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:o.tone}),t.jsx("div",{className:"mt-2 font-medium text-white",children:o.title}),t.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:o.summary}),t.jsxs("div",{className:"mt-4 inline-flex items-center gap-2 text-sm text-white/54",children:["Open",t.jsx(ye,{className:"size-3.5"})]})]},o.id))})}const f={kind:"away",title:"",description:"",commonCues:[],urgeStory:"",shortTermPayoff:"",longTermCost:"",replacementMove:"",repairPlan:"",linkedPatternIds:[],linkedValueIds:[],linkedSchemaIds:[],linkedModeIds:[],userId:null};function Ge(s){return{kind:s.kind,title:s.title,description:s.description,commonCues:s.commonCues,urgeStory:s.urgeStory,shortTermPayoff:s.shortTermPayoff,longTermCost:s.longTermCost,replacementMove:s.replacementMove,repairPlan:s.repairPlan,linkedPatternIds:s.linkedPatternIds,linkedValueIds:s.linkedValueIds,linkedSchemaIds:s.linkedSchemaIds,linkedModeIds:s.linkedModeIds,userId:s.userId??null}}const Z={away:"Away moves",committed:"Committed actions",recovery:"Recovery moves"};function ht(){var O,A,Q,D,K,R,U,W,_,$,z;const s=be(),n=ge(),[o,M]=ve(),[X,c]=v.useState(!1),[h,p]=v.useState(null),[y,m]=v.useState(f),[Y,b]=v.useState(null),x=g({queryKey:["forge-psyche-behaviors"],queryFn:Ae}),w=g({queryKey:["forge-psyche-patterns"],queryFn:Qe}),j=g({queryKey:["forge-psyche-values"],queryFn:De}),k=g({queryKey:["forge-psyche-schema-catalog"],queryFn:Ke}),C=g({queryKey:["forge-psyche-modes"],queryFn:Re}),I=((O=x.data)==null?void 0:O.behaviors)??[],ee=((A=w.data)==null?void 0:A.patterns)??[],te=((Q=j.data)==null?void 0:Q.values)??[],ae=((D=k.data)==null?void 0:D.schemas)??[],re=((K=C.data)==null?void 0:K.modes)??[],u=xe(s.selectedUserIds),E=o.get("focus"),se=s.snapshot.dashboard.notesSummaryByEntity;We(E),v.useEffect(()=>{if(o.get("create")==="1"){c(!0),p(null),m({...f,userId:u});const e=new URLSearchParams(o);e.delete("create"),M(e,{replace:!0})}},[u,o,M]);const F=fe({mutationFn:async e=>{const a=J.parse(e);return h?we(h.id,a):je(a)},onSuccess:async()=>{c(!1),p(null),m({...f,userId:u}),b(null),await Promise.all([n.invalidateQueries({queryKey:["forge-psyche-behaviors"]}),n.invalidateQueries({queryKey:["forge-psyche-overview"]})])}}),ie=ee.map(e=>({value:e.id,label:T(e.title,e.user),description:N(e.preferredResponse||e.targetBehavior,e.user),searchText:P([e.title,e.preferredResponse,e.targetBehavior,e.description],e),kind:"pattern"})),oe=te.map(e=>({value:e.id,label:T(e.title,e.user),description:N(e.valuedDirection,e.user),searchText:P([e.title,e.valuedDirection,e.description],e),kind:"value"})),ne=ae.map(e=>({value:e.id,label:e.title,description:`${e.description} ${ze(e.family)}`,searchText:`${e.slug} ${e.family} ${e.schemaType}`,badge:t.jsx(H,{label:e.title,schemaType:e.schemaType,compact:!0}),menuBadge:t.jsx(H,{label:e.title,schemaType:e.schemaType,compact:!0})})),le=re.map(e=>({value:e.id,label:T(e.title,e.user),description:N(e.archetype||e.family,e.user),searchText:P([e.title,e.archetype,e.family,e.persona],e),kind:"mode"})),de=async e=>{const{pattern:a}=await Fe({title:e,description:"",targetBehavior:e,cueContexts:[],shortTermPayoff:"",longTermCost:"",preferredResponse:"",linkedValueIds:[],linkedSchemaLabels:[],linkedModeIds:[],linkedBeliefIds:[],userId:y.userId});return L(n,["forge-psyche-patterns"],"patterns",a),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:a.id,label:a.title,description:a.preferredResponse||a.targetBehavior,kind:"pattern"}},ce=async e=>{const{value:a}=await qe({title:e,description:"",valuedDirection:e,whyItMatters:"",linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],committedActions:[],userId:y.userId});return L(n,["forge-psyche-values"],"values",a),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:a.id,label:a.title,description:a.valuedDirection,kind:"value"}},he=async e=>{const{mode:a}=await Oe({family:"coping",archetype:"",title:e,persona:"",imagery:"",symbolicForm:"",facialExpression:"",fear:"",burden:"",protectiveJob:"",originContext:"",firstAppearanceAt:null,linkedPatternIds:[],linkedBehaviorIds:[],linkedValueIds:[],userId:y.userId});return L(n,["forge-psyche-modes"],"modes",a),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:a.id,label:a.title,description:a.archetype||a.family,kind:"mode"}},me=[{id:"behavior",eyebrow:"Behavior",title:"Describe the move or urge in plain language",description:"Start with the behavior itself so the map reads like something you can instantly recognize in real life.",render:(e,a)=>t.jsxs(t.Fragment,{children:[t.jsx(Le,{value:e.userId??null,users:s.snapshot.users,onChange:r=>a({userId:r}),defaultLabel:Me(s.snapshot.users.find(r=>r.id===u)??null,"Choose behavior owner"),help:"Behaviors can belong to a human or bot user while still linking across shared patterns, schemas, and modes."}),t.jsx(i,{label:"Behavior title",children:t.jsx(Ee,{value:e.title,onChange:r=>a({title:r.target.value}),placeholder:"Scroll to numb the impact"})}),t.jsx(i,{label:"What does the move look like?",children:t.jsx(d,{value:e.description,onChange:r=>a({description:r.target.value}),placeholder:"Describe the move the way you would recognize it in the moment, not in therapist shorthand."})})]})},{id:"context",eyebrow:"Context",title:"Capture the cue, the pull, and the immediate payoff",description:"Make the move readable as a real pattern instead of a label.",render:(e,a)=>t.jsxs(t.Fragment,{children:[t.jsx(i,{label:"Common cues",children:t.jsx(d,{value:e.commonCues.join(`
2
+ `),onChange:r=>a({commonCues:r.target.value.split(`
3
+ `).map(ue=>ue.trim()).filter(Boolean)}),placeholder:`One line per cue
4
+ Late-night ambiguity
5
+ Feedback after a hard week`})}),t.jsx(i,{label:"What inner push or story shows up?",children:t.jsx(d,{value:e.urgeStory,onChange:r=>a({urgeStory:r.target.value}),placeholder:"What inner push or justification tends to appear?"})}),t.jsx(i,{label:"What do you get right away from this move?",children:t.jsx(d,{value:e.shortTermPayoff,onChange:r=>a({shortTermPayoff:r.target.value}),placeholder:"What relief, certainty, distance, or control does it give in the short term?"})})]})},{id:"classification",eyebrow:"Classification",title:"Now classify the move and define the return path",description:"Once the move is clear, decide whether it is an away move, a committed action, or a recovery path.",render:(e,a)=>t.jsxs(t.Fragment,{children:[t.jsx(i,{label:"Move type",children:t.jsx("div",{className:"grid gap-3 md:grid-cols-3",children:["away","committed","recovery"].map(r=>t.jsx("button",{type:"button",className:V("rounded-[8px] border px-4 py-4 text-left transition",e.kind===r?"border-[color-mix(in_srgb,var(--primary)_40%,var(--ui-border-subtle)_60%)] bg-[color-mix(in_srgb,var(--primary)_12%,var(--ui-surface-1)_88%)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>a({kind:r}),children:Z[r]},r))})}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(i,{label:"What does it cost over time?",children:t.jsx(d,{value:e.longTermCost,onChange:r=>a({longTermCost:r.target.value}),placeholder:"What does this move cost over time?"})}),t.jsx(i,{label:"What move should replace or steady it?",children:t.jsx(d,{value:e.replacementMove,onChange:r=>a({replacementMove:r.target.value}),placeholder:"What move should replace this one when possible?"})})]}),t.jsx(i,{label:"If the slip happens, how do you repair and return?",children:t.jsx(d,{value:e.repairPlan,onChange:r=>a({repairPlan:r.target.value}),placeholder:"Describe the repair path without shame or collapse."})})]})},{id:"links",eyebrow:"Links",title:"Attach the move to patterns, values, schemas, and modes",description:"This turns the move into part of the full graphical psyche system.",render:(e,a)=>t.jsxs(t.Fragment,{children:[t.jsx(i,{label:"Linked patterns",children:t.jsx(S,{options:ie,selectedValues:e.linkedPatternIds,onChange:r=>a({linkedPatternIds:r}),placeholder:"Search or create a pattern…",emptyMessage:"No patterns match yet.",createLabel:"Create pattern",onCreate:de})}),t.jsx(i,{label:"Linked values",children:t.jsx(S,{options:oe,selectedValues:e.linkedValueIds,onChange:r=>a({linkedValueIds:r}),placeholder:"Search or create a value…",emptyMessage:"No values match yet.",createLabel:"Create value",onCreate:ce})}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(i,{label:"Linked schemas",children:t.jsx(S,{options:ne,selectedValues:e.linkedSchemaIds,onChange:r=>a({linkedSchemaIds:r}),placeholder:"Search schema themes…",emptyMessage:"No schema themes match."})}),t.jsx(i,{label:"Linked modes",children:t.jsx(S,{options:le,selectedValues:e.linkedModeIds,onChange:r=>a({linkedModeIds:r}),placeholder:"Search or create a mode…",emptyMessage:"No modes match yet.",createLabel:"Create mode",onCreate:he})})]})]})}];if(x.isLoading||w.isLoading||j.isLoading||k.isLoading||C.isLoading)return t.jsx(ke,{eyebrow:"Behaviors",title:"Loading behaviors",description:"Getting behaviors, patterns, values, schemas, and modes ready."});const q=x.error??w.error??j.error??k.error??C.error;if(q)return t.jsx(Ce,{eyebrow:"Psyche behaviors",error:q,onRetry:()=>void Promise.all([x.refetch(),w.refetch(),j.refetch(),k.refetch(),C.refetch()])});const l={away:I.filter(e=>e.kind==="away"),committed:I.filter(e=>e.kind==="committed"),recovery:I.filter(e=>e.kind==="recovery")};return t.jsxs("div",{className:"grid gap-5",children:[t.jsx($e,{entityKind:"behavior",title:t.jsx(Ie,{kind:"behavior",label:"Behaviors",variant:"heading",size:"lg"}),description:"Group behaviors by what pulls you away, what moves you toward your values, and what helps you recover after a slip.",badge:`${I.length} mapped`,actions:t.jsx(B,{onClick:()=>{p(null),m({...f,userId:u}),c(!0)},children:"Add behavior"})}),t.jsx(Se,{}),t.jsx(G,{eyebrow:"Overview",title:"Behavior summary",description:"This summary keeps the three behavior types visible together: away, committed, and recovery.",tone:"amber",children:t.jsx(Ve,{entries:[{id:"away",title:((R=l.away[0])==null?void 0:R.title)??"No away move mapped yet",summary:((U=l.away[0])==null?void 0:U.replacementMove)||"Map the move that tends to pull you away first.",href:"#behavior-columns",tone:"away"},{id:"committed",title:((W=l.committed[0])==null?void 0:W.title)??"No committed action mapped yet",summary:((_=l.committed[0])==null?void 0:_.replacementMove)||"Map the move you want to practice instead.",href:"#behavior-columns",tone:"committed"},{id:"recovery",title:(($=l.recovery[0])==null?void 0:$.title)??"No recovery move mapped yet",summary:((z=l.recovery[0])==null?void 0:z.repairPlan)||"Map how you return after a slip without turning it into collapse.",href:"#behavior-columns",tone:"recovery"}]})}),t.jsx(G,{eyebrow:"Behaviors",title:"Behaviors by type",description:"Use these columns to separate what pulls you off course, what helps you move toward your values, and what helps you recover.",tone:"default",children:t.jsx("div",{id:"behavior-columns",className:"grid gap-4 xl:grid-cols-3",children:["away","committed","recovery"].map(e=>t.jsxs("div",{className:"grid min-w-0 gap-3 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:Z[e]}),t.jsx(Pe,{children:l[e].length})]}),l[e].length===0?t.jsx("div",{className:"flex",children:t.jsxs(B,{variant:"secondary",onClick:()=>{p(null),m({...f,userId:u}),c(!0)},children:["Add"," ",e==="away"?"away move":e==="committed"?"committed action":"recovery move"]})}):l[e].map(a=>t.jsxs("div",{"data-psyche-focus-id":a.id,className:V("min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4 text-left transition hover:bg-[var(--ui-surface-hover)]",_e(E===a.id)),children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:a.title}),a.user?t.jsx(Ne,{user:a.user,compact:!0}):null]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(Ue,{entityType:"behavior",entityId:a.id,count:Te(se,"behavior",a.id).count}),t.jsx(B,{variant:"secondary",size:"sm",onClick:()=>{p(a),m(Ge(a)),c(!0)},children:"Edit"})]})]}),t.jsx("div",{className:"mt-2 break-words text-sm leading-6 text-[var(--ui-ink-soft)]",children:a.description}),t.jsx("div",{className:"mt-3 break-words text-sm text-[var(--ui-ink-faint)]",children:a.replacementMove||a.repairPlan||"No recovery step recorded yet."})]},a.id))]},e))})}),t.jsx(Be,{open:X,onOpenChange:c,eyebrow:"Behavior",title:h?"Refine behavior path":"Create behavior",description:"Use this guided flow to describe the behavior, when it shows up, what it gives you, and what kind of move it is.",value:y,onChange:m,draftPersistenceKey:h?`psyche.behavior.${h.id}`:"psyche.behavior.new",steps:me,submitLabel:h?"Save behavior":"Create behavior",pending:F.isPending,error:Y,onSubmit:async()=>{b(null);const e=J.safeParse(y);if(!e.success){b("This behavior still needs a kind and a title before it can be saved.");return}try{await F.mutateAsync(e.data)}catch(a){b(a instanceof Error?a.message:"Unable to save this behavior right now.")}}})]})}export{ht as PsycheBehaviorsPage};
@@ -0,0 +1 @@
1
+ import{c2 as T,r as x,j as e,b4 as B,b3 as z,cH as M,aG as R,aK as q}from"./vendor-Dnkkx2co.js";import{j as Q,i as K,k as F}from"./state-vCcAT5Hq.js";import{u as O,s as H,cs as Y,ct as V,cu as W,L as G,E as X,B as S,ch as Z,I as h,c as N,U as D,Z as y,T as J,a0 as $,a1 as ee,bB as se}from"./index-EqQsXoat.js";import{u as ae,p as te}from"./use-psyche-focus-target-Ct-acS9G.js";import{P as re}from"./page-hero-ffKzgyW3.js";import{f as ie}from"./psyche-schemas-Dxj554nU.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";const k={title:"",message:"",triggerSentence:"",triggerSituation:"",tags:[],backgroundColor:"#f8fafc",textColor:"#111827",accentColor:"#6ee7b7",typography:"serif",imageUrl:"",imageAlt:"",layout:"centered",visualStyle:"calm",linkedValueIds:[],linkedBehaviorIds:[],linkedPatternIds:[],linkedBeliefIds:[],linkedModeIds:[],linkedReportIds:[],userId:null},le={serif:"font-serif",sans:"font-sans",mono:"font-mono",display:"font-display"},ne={calm:"Calm",urgent:"Urgent",warm:"Warm",clinical:"Clinical",playful:"Playful"};function oe(s){return s.split(",").map(l=>l.trim()).filter(Boolean)}function L(s){return{title:s.title,message:s.message,triggerSentence:s.triggerSentence,triggerSituation:s.triggerSituation,tags:s.tags,backgroundColor:s.backgroundColor,textColor:s.textColor,accentColor:s.accentColor,typography:s.typography,imageUrl:s.imageUrl,imageAlt:s.imageAlt,layout:s.layout,visualStyle:s.visualStyle,linkedValueIds:s.linkedValueIds,linkedBehaviorIds:s.linkedBehaviorIds,linkedPatternIds:s.linkedPatternIds,linkedBeliefIds:s.linkedBeliefIds,linkedModeIds:s.linkedModeIds,linkedReportIds:s.linkedReportIds,userId:s.userId??null}}function A({card:s,compact:l=!1,focused:a=!1,onClick:p}){const c=s.imageUrl.trim().length>0,n=s.layout,d=s.title.trim(),v=s.triggerSentence.trim()||s.triggerSituation.trim();return e.jsxs("button",{type:"button",className:y("group min-w-0 rounded-[26px] border p-2 text-left shadow-[var(--card-shadow)] transition hover:-translate-y-0.5 hover:border-[var(--ui-border-strong)]",a?"border-[color-mix(in_srgb,var(--tertiary)_72%,var(--ui-border-subtle)_28%)]":"border-[var(--ui-border-subtle)]"),onClick:p,children:[e.jsxs("div",{className:y("relative grid min-h-[18rem] overflow-hidden rounded-[20px] border",l?"min-h-[15rem]":"sm:min-h-[21rem]",n==="image_split"&&c?"md:grid-cols-[0.9fr_1.1fr]":""),style:{background:s.backgroundColor,color:s.textColor,borderColor:s.accentColor},children:[c&&n!=="image_split"?e.jsx("img",{src:s.imageUrl,alt:s.imageAlt||d||"Flashcard image",className:"absolute inset-0 size-full object-cover opacity-30"}):null,c&&n==="image_split"?e.jsx("div",{className:"relative min-h-[10rem] overflow-hidden",children:e.jsx("img",{src:s.imageUrl,alt:s.imageAlt||d||"Flashcard image",className:"absolute inset-0 size-full object-cover"})}):null,e.jsxs("div",{className:y("relative z-10 flex min-w-0 flex-col p-6",n==="top_left"?"items-start justify-start":"items-center justify-center text-center",n==="poster"?"min-h-[22rem] p-8":"",le[s.typography]),children:[e.jsx("div",{className:"mb-5 h-1.5 w-16 rounded-full",style:{backgroundColor:s.accentColor}}),e.jsx("div",{className:y("max-w-[24rem] text-balance leading-[1.12]",l?"text-2xl":"text-[clamp(1.9rem,4vw,3.45rem)]"),children:s.message||"Write the sentence that should meet you in the hard moment."}),v?e.jsx("div",{className:"mt-6 max-w-md rounded-full border px-3 py-1.5 text-xs font-medium opacity-75",style:{borderColor:s.accentColor},children:v}):null]})]}),e.jsxs("div",{className:"px-2 pt-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[d?e.jsx("div",{className:"truncate text-sm font-semibold text-[var(--ui-ink-strong)]",children:d}):null,e.jsx(N,{className:"bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)]",children:ne[s.visualStyle]})]}),s.tags.length>0?e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:s.tags.slice(0,5).map(o=>e.jsx("span",{className:"rounded-full bg-[var(--ui-surface-1)] px-2 py-1 text-[11px] text-[var(--ui-ink-soft)]",children:o},o))}):null]})]})}function ce({open:s,editingCard:l,draft:a,users:p,suggestedOwner:c,submitError:n,saving:d,onClose:v,onDelete:o,onDraftChange:i,onSubmit:u}){return s?e.jsx("div",{className:"fixed inset-0 z-50 flex items-end justify-center bg-[var(--overlay)] px-3 py-4 backdrop-blur-xl sm:items-center sm:p-6",children:e.jsxs("div",{className:"max-h-[min(92dvh,58rem)] w-full max-w-6xl overflow-hidden rounded-[30px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)] shadow-[var(--ui-shadow-floating)]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-[var(--ui-border-subtle)] px-5 py-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--tertiary)]",children:l?"Edit flashcard":"New flashcard"}),e.jsx("div",{className:"mt-1 text-lg font-semibold text-[var(--ui-ink-strong)]",children:"Message first, retrieval second, styling last."})]}),e.jsx("button",{type:"button","aria-label":"Close flashcard editor",className:"inline-flex size-10 shrink-0 items-center justify-center rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",onClick:v,children:e.jsx(q,{className:"size-4"})})]}),e.jsxs("div",{className:"grid max-h-[calc(min(92dvh,58rem)-5rem)] min-h-0 overflow-y-auto p-4 md:grid-cols-[1fr_0.9fr] md:p-5",children:[e.jsxs("div",{className:"grid content-start gap-4 pr-0 md:pr-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Main message"}),e.jsx(J,{className:"mt-2 min-h-28",value:a.message,placeholder:"This urge is a wave. You do not have to obey it.",onChange:r=>i({...a,message:r.target.value})})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Trigger sentence"}),e.jsx(h,{className:"mt-2",value:a.triggerSentence,placeholder:"I feel the urge to…",onChange:r=>i({...a,triggerSentence:r.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Optional title"}),e.jsx(h,{className:"mt-2",value:a.title,placeholder:"Late-night urge card",onChange:r=>i({...a,title:r.target.value})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Trigger situation"}),e.jsx(h,{className:"mt-2",value:a.triggerSituation,placeholder:"Late evening shame, loneliness, conflict, or boredom",onChange:r=>i({...a,triggerSituation:r.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Tags"}),e.jsx(h,{className:"mt-2",value:a.tags.join(", "),placeholder:"urge, sobriety, grounding",onChange:r=>i({...a,tags:oe(r.target.value)})})]}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-3",children:[["backgroundColor","Background"],["textColor","Text"],["accentColor","Accent"]].map(([r,m])=>e.jsxs("label",{className:"grid gap-2 text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:[m,e.jsx("input",{type:"color",value:String(a[r]),className:"h-11 w-full rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-1",onChange:w=>i({...a,[r]:w.target.value})})]},r))}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[e.jsxs("label",{className:"grid gap-2 text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:["Typography",e.jsxs("select",{className:"h-11 rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 text-sm normal-case tracking-normal text-[var(--ui-ink-strong)]",value:a.typography,onChange:r=>i({...a,typography:r.target.value}),children:[e.jsx("option",{value:"serif",children:"Serif"}),e.jsx("option",{value:"sans",children:"Sans"}),e.jsx("option",{value:"mono",children:"Mono"}),e.jsx("option",{value:"display",children:"Display"})]})]}),e.jsxs("label",{className:"grid gap-2 text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:["Layout",e.jsxs("select",{className:"h-11 rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 text-sm normal-case tracking-normal text-[var(--ui-ink-strong)]",value:a.layout,onChange:r=>i({...a,layout:r.target.value}),children:[e.jsx("option",{value:"centered",children:"Centered"}),e.jsx("option",{value:"top_left",children:"Top left"}),e.jsx("option",{value:"image_split",children:"Image split"}),e.jsx("option",{value:"poster",children:"Poster"})]})]}),e.jsxs("label",{className:"grid gap-2 text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:["Tone",e.jsxs("select",{className:"h-11 rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 text-sm normal-case tracking-normal text-[var(--ui-ink-strong)]",value:a.visualStyle,onChange:r=>i({...a,visualStyle:r.target.value}),children:[e.jsx("option",{value:"calm",children:"Calm"}),e.jsx("option",{value:"urgent",children:"Urgent"}),e.jsx("option",{value:"warm",children:"Warm"}),e.jsx("option",{value:"clinical",children:"Clinical"}),e.jsx("option",{value:"playful",children:"Playful"})]})]})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Image URL"}),e.jsx(h,{className:"mt-2",value:a.imageUrl,placeholder:"https://…",onChange:r=>i({...a,imageUrl:r.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Image alt"}),e.jsx(h,{className:"mt-2",value:a.imageAlt,placeholder:"Describe the image",onChange:r=>i({...a,imageAlt:r.target.value})})]})]}),e.jsx($,{users:p,value:a.userId??null,defaultLabel:ee(c,"Choose flashcard owner"),onChange:r=>i({...a,userId:r}),help:"Flashcards can belong to a human or bot owner while still being searchable by trigger, tags, and linked Psyche records."}),n?e.jsx("div",{className:"rounded-[18px] border border-[var(--danger)]/20 bg-[var(--ui-danger-soft)] px-4 py-3 text-sm text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",children:n}):null,e.jsxs("div",{className:"flex flex-wrap justify-between gap-3",children:[l?e.jsx(S,{type:"button",variant:"ghost",onClick:o,children:"Delete"}):e.jsx("span",{}),e.jsx(S,{type:"button",disabled:d,onClick:u,children:d?"Saving...":"Save flashcard"})]})]}),e.jsx("div",{className:"mt-5 min-w-0 md:mt-0",children:e.jsx(A,{card:a,compact:!0})})]})]})}):null}function ye(){var U;const s=O(),l=Q(),[a,p]=T(),c=a.get("focus"),[n,d]=x.useState(""),[v,o]=x.useState(!1),[i,u]=x.useState(null),[r,m]=x.useState(k),[w,C]=x.useState(null),f=H(s.selectedUserIds),E=s.snapshot.users.find(t=>t.id===f)??null;ae(c);const b=K({queryKey:["forge-psyche-flashcards",s.selectedUserIds],queryFn:()=>se(s.selectedUserIds)});x.useEffect(()=>{if(a.get("create")==="1"){u(null),m({...k,userId:f}),o(!0);const t=new URLSearchParams(a);t.delete("create"),p(t,{replace:!0})}},[f,a,p]);const P=F({mutationFn:async t=>{const g=ie.parse(t);return i?Y(i.id,g):V(g)},onSuccess:async()=>{o(!1),u(null),m({...k,userId:f}),C(null),await Promise.all([l.invalidateQueries({queryKey:["forge-psyche-flashcards"]}),l.invalidateQueries({queryKey:["forge-psyche-overview"]})])},onError:t=>{C(t instanceof Error?t.message:String(t))}}),_=F({mutationFn:async t=>W(t.id),onSuccess:async()=>{o(!1),u(null),await Promise.all([l.invalidateQueries({queryKey:["forge-psyche-flashcards"]}),l.invalidateQueries({queryKey:["forge-psyche-overview"]})])}}),j=((U=b.data)==null?void 0:U.flashcards)??[],I=x.useMemo(()=>{const t=n.trim().toLowerCase();return t?j.filter(g=>[g.title,g.message,g.triggerSentence,g.triggerSituation,...g.tags].join(" ").toLowerCase().includes(t)):j},[j,n]);return b.isLoading?e.jsx(G,{title:"Loading Psyche flashcards"}):b.isError?e.jsx(X,{eyebrow:"Psyche",error:b.error,onRetry:()=>void b.refetch()}):e.jsxs("div",{className:"grid gap-6",children:[e.jsx(re,{title:"Flashcards",titleText:"Flashcards",description:"Small therapeutic reminder cards for urges, trigger moments, mode shifts, and values-based pivots.",actions:e.jsxs(S,{type:"button",onClick:()=>{u(null),m({...k,userId:f}),o(!0)},children:[e.jsx(B,{className:"mr-2 size-4"}),"New flashcard"]})}),e.jsx(Z,{}),e.jsxs("div",{className:"grid gap-4 rounded-[26px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)] p-4 md:grid-cols-[1fr_auto] md:items-center",children:[e.jsxs("div",{className:"relative min-w-0",children:[e.jsx(z,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-[var(--ui-ink-faint)]"}),e.jsx(h,{value:n,placeholder:"Search message, tags, trigger sentence, or situation",className:"pl-10",onChange:t=>d(t.target.value)})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsxs(N,{className:"bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)]",children:[j.length," saved"]}),e.jsxs(N,{className:"bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)]",children:[I.length," visible"]})]})]}),I.length>0?e.jsx("div",{className:"grid gap-5 lg:grid-cols-2 2xl:grid-cols-3",children:I.map(t=>e.jsxs("div",{className:te(c===t.id),children:[e.jsx(A,{card:t,focused:c===t.id,onClick:()=>{u(t),m(L(t)),o(!0)}}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-2 px-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.user?e.jsx(D,{user:t.user,compact:!0}):null,t.imageUrl?e.jsxs(N,{className:"bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)]",children:[e.jsx(M,{className:"mr-1 size-3"}),"image"]}):null]}),e.jsx(S,{type:"button",variant:"ghost",onClick:()=>{u(t),m(L(t)),o(!0)},children:"Edit"})]})]},t.id))}):e.jsxs("div",{className:"rounded-[30px] border border-[var(--ui-border-subtle)] bg-[radial-gradient(circle_at_top_left,color-mix(in_srgb,var(--tertiary)_12%,transparent),transparent_46%),var(--ui-surface-section)] p-8 text-center",children:[e.jsx(R,{className:"mx-auto size-8 text-[var(--tertiary)]"}),e.jsx("div",{className:"mt-4 text-xl font-semibold text-[var(--ui-ink-strong)]",children:"No flashcards match this view."}),e.jsx("div",{className:"mx-auto mt-2 max-w-xl text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Create cards for the sentences you want available during urges, shame spirals, critic attacks, and values-based pivots."})]}),e.jsx(ce,{open:v,editingCard:i,draft:r,users:s.snapshot.users,suggestedOwner:E,submitError:w,saving:P.isPending||_.isPending,onClose:()=>{o(!1),u(null),C(null)},onDelete:()=>{i&&_.mutateAsync(i)},onDraftChange:m,onSubmit:()=>void P.mutateAsync(r)})]})}export{ye as PsycheFlashcardsPage};
@@ -0,0 +1 @@
1
+ import{r as h,j as e,aC as m}from"./vendor-Dnkkx2co.js";import{i as j}from"./state-vCcAT5Hq.js";import{b as N,P as I}from"./psyche-graph-EP5GL612.js";import{u as S,L as G,E as P,ch as E,C as K,b as L,V as B,c as v,Z as V,cj as _,ad as C}from"./index-EqQsXoat.js";import{P as H}from"./page-hero-ffKzgyW3.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";function T(){var x;const n=S(),[p,f]=h.useState(null),o=j({queryKey:["forge-psyche-overview"],queryFn:C}),r=(x=o.data)==null?void 0:x.overview,l=h.useMemo(()=>r?n.snapshot.goals.map(i=>{const u=r.values.filter(t=>t.linkedGoalIds.includes(i.id)),g=n.snapshot.dashboard.projects.filter(t=>t.goalId===i.id),b=n.snapshot.habits.filter(t=>t.linkedGoalIds.includes(i.id)||t.linkedValueIds.some(d=>u.some(c=>c.id===d))),w=r.reports.filter(t=>t.linkedGoalIds.includes(i.id)),y=r.behaviors.filter(t=>t.linkedValueIds.some(d=>u.some(c=>c.id===d))),k=r.beliefs.filter(t=>t.linkedValueIds.some(d=>u.some(c=>c.id===d)));return{goal:i,linkedValues:u,linkedProjects:g,linkedHabits:b,linkedReports:w,linkedBehaviors:y,linkedBeliefs:k}}):[],[r,n.snapshot.dashboard.projects,n.snapshot.goals,n.snapshot.habits]),a=h.useMemo(()=>N(l),[l]);if(h.useEffect(()=>{f(a.defaultSelectedId)},[a.defaultSelectedId]),o.isLoading)return e.jsx(G,{eyebrow:"Goal map",title:"Loading the gravity well",description:"Linking goals, values, reports, beliefs, behaviors, and projects back into execution."});if(o.isError||!r)return e.jsx(P,{eyebrow:"Goal map",error:o.error??new Error("Forge returned an empty Psyche overview payload."),onRetry:()=>void o.refetch()});const s=a.inspectors[p??a.defaultSelectedId]??a.inspectors[a.defaultSelectedId];return e.jsxs("div",{className:"grid min-w-0 gap-4",children:[e.jsx(H,{title:"Goal Map",titleText:"Goal Map",description:"Values orbit each goal. Habits, reports, beliefs, behaviors, and projects reveal where the orbit gets disrupted and how execution reconnects.",badge:`${l.length} goal${l.length===1?"":"s"}`,actions:e.jsxs(e.Fragment,{children:[e.jsx(m,{to:"/goals",className:"inline-flex min-h-10 min-w-max shrink-0 items-center justify-center rounded-full bg-[var(--ui-surface-2)] px-4 py-2 text-sm whitespace-nowrap text-[var(--ui-ink-strong)] transition hover:bg-[var(--ui-surface-hover)]",children:"Open goals"}),e.jsx(m,{to:"/psyche/reports?create=1",className:"inline-flex min-h-10 min-w-max shrink-0 items-center justify-center rounded-full bg-[var(--ui-info-soft)] px-4 py-2 text-sm whitespace-nowrap text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)] transition hover:bg-[color-mix(in_srgb,var(--info)_18%,var(--ui-surface-hover)_82%)]",children:"Reflect"})]})}),e.jsx(E,{}),e.jsxs("section",{className:"grid min-w-0 gap-4 xl:grid-cols-[minmax(0,1fr)_20rem]",children:[e.jsx(I,{testId:"goal-gravity-graph",title:"Life direction, value orbit, and execution field",hint:"Drag to inspect the whole field. Select any goal, value, belief, behavior, project, or report to see what it means and where to act next.",nodes:a.nodes,edges:a.edges,fields:a.fields,selectedNodeId:p,onSelectNode:f,minHeightClassName:"min-h-[25rem] sm:min-h-[34rem] lg:min-h-[56rem]",legend:[{label:"Goals",kind:"goal"},{label:"Values",kind:"value"},{label:"Beliefs",kind:"belief"},{label:"Behaviors",kind:"behavior"},{label:"Habits",kind:"habit"},{label:"Projects",kind:"project"},{label:"Reports",kind:"report"}],action:l.length===0?e.jsx(m,{to:"/goals",className:"inline-flex min-h-10 min-w-max shrink-0 items-center justify-center rounded-[var(--radius-control)] bg-[var(--ui-accent-soft)] px-4 py-2 text-sm font-medium whitespace-nowrap text-[var(--ui-ink-strong)]",children:"Add first goal"}):e.jsx(m,{to:"/goals",className:"inline-flex min-h-10 min-w-max shrink-0 items-center justify-center rounded-[var(--radius-control)] bg-[var(--ui-surface-2)] px-4 py-2 text-sm font-medium whitespace-nowrap text-[var(--ui-ink-strong)] transition hover:bg-[var(--ui-surface-hover)]",children:"Open goals"})}),e.jsxs(K,{className:"min-w-0 h-fit xl:sticky xl:top-24",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:s.entityKind?e.jsx(L,{kind:s.entityKind,compact:!0,gradient:!1,iconOnly:!0}):e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:s.eyebrow})}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[s.entityKind?e.jsx(B,{kind:s.entityKind,label:s.title,variant:"heading",size:"lg",showKind:!1}):e.jsx("h2",{className:"break-words font-display text-[clamp(1.35rem,2.2vw,2rem)] leading-none text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:s.title}),s.entityKind?null:e.jsx(v,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:s.tone})]}),e.jsx("p",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:s.summary}),s.stats.length>0?e.jsx("div",{className:"mt-4 grid gap-2",children:s.stats.map(i=>e.jsx("div",{className:"break-words rounded-[18px] bg-[var(--ui-surface-1)] px-3 py-3 text-sm text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:i},i))}):null,s.chips.length>0?e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:s.chips.map(i=>e.jsx(v,{className:"max-w-full bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:i},i))}):null,e.jsx("div",{className:"mt-5",children:e.jsx(m,{to:s.href,className:V("inline-flex min-h-11 w-full items-center justify-center rounded-[var(--radius-control)] px-4 py-2.5 text-sm font-medium whitespace-nowrap shadow-[var(--ui-shadow-soft)]",s.entityKind?_(s.entityKind,!0):"bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]"),children:s.ctaLabel})})]})]})]})}export{T as PsycheGoalMapPage};
@@ -0,0 +1 @@
1
+ import{r as $,b5 as Xt,j as c,cI as Rt,b4 as zt,cn as Ct,cJ as Pt,cK as Nt}from"./vendor-Dnkkx2co.js";import{Z as dt,B as ot,aS as gt}from"./index-EqQsXoat.js";function U(n,i,s){return`${i}:${n}:${s}`}function ft(n,i,s){return Math.min(Math.max(n,i),s)}function mt(n,i,s){return Math.min(s,Math.max(1,Math.ceil(n.trim().length/i)))}function _t(n,{compact:i}){const s=mt(n,i?13:14,4),p=(i?114:156)+(s-1)*(i?12:18)+Math.min(24,Math.max(0,n.trim().length-18))*(i?.7:1);return ft(p,i?118:164,i?154:210)}function Tt(n,{compact:i}){const s=mt(n,i?11:13,3),p=(i?40:48)+(s-1)*(i?6:8)+Math.min(i?18:26,Math.max(0,n.trim().length-(i?12:16)))*(i?.45:.55);return ft(p,i?42:50,i?56:68)}function tt(n,{compact:i,emphasis:s=!1}){const p=mt(n,i?16:s?22:20,s?3:2);return{width:ft((i?s?184:152:s?224:176)+Math.min(n.length,48)*(i?1.8:2.15),i?s?188:156:s?228:184,i?s?248:208:s?300:244),height:p===1?i?64:70:p===2?i?82:92:i?98:110}}function kt(n){if(n.kind==="goal"||n.kind==="value"||n.kind==="ghost"){const i=n.radius??(n.kind==="goal"?76:34);return{halfWidth:i,halfHeight:i}}return{halfWidth:(n.width??146)/2,halfHeight:(n.height??58)/2}}function Et(n,{compact:i}){const s=n.map(u=>({...u,homeX:u.x,homeY:u.y,locked:u.kind==="goal"||u.kind==="ghost"})),x=i?28:40,p=i?.08:.06;for(let u=0;u<180;u+=1){for(const r of s)r.locked||(r.x+=(r.homeX-r.x)*p,r.y+=(r.homeY-r.y)*p);for(let r=0;r<s.length;r+=1)for(let v=r+1;v<s.length;v+=1){const g=s[r],w=s[v],h=kt(g),L=kt(w),j=w.x-g.x,z=w.y-g.y,y=h.halfWidth+L.halfWidth+x-Math.abs(j),b=h.halfHeight+L.halfHeight+x-Math.abs(z);if(y<=0||b<=0)continue;const I=y<b?"x":"y",P=Math.sign(I==="x"?j||v-r||1:z||v-r||1),E=(I==="x"?y:b)/(g.locked||w.locked?1:2);g.locked||(I==="x"?g.x-=P*E:g.y-=P*E),w.locked||(I==="x"?w.x+=P*E:w.y+=P*E)}}return s.map(({homeX:u,homeY:r,locked:v,...g})=>g)}function St(){return{nodes:[{id:"ghost_goal_north",kind:"ghost",x:-250,y:-20,radius:68,label:"First goal",meta:"Goal",href:"/goals"},{id:"ghost_goal_center",kind:"ghost",x:0,y:34,radius:74,label:"Life goals",meta:"Goal",href:"/goals"},{id:"ghost_goal_south",kind:"ghost",x:250,y:-10,radius:68,label:"Direction",meta:"Goal",href:"/goals"}],edges:[],fields:[],inspectors:{ghost_goal_center:{id:"ghost_goal_center",eyebrow:"Goals",title:"Add the first life goal",summary:"The graph is already laid out. Once a goal exists, values, reports, beliefs, and behaviors will start orbiting it instead of staying fragmented.",href:"/goals",ctaLabel:"Open life goals",tone:"sky",entityKind:"goal",chips:["Goals","Values","Reports"],stats:["0 goals mapped yet"]}},defaultSelectedId:"ghost_goal_center"}}function Wt(n,{compact:i=!1}={}){var w;if(n.length===0)return St();const s=[],x=[],p=[],u={},r=i?560:840,v=-((n.length-1)*r)/2;n.forEach((h,L)=>{const j=v+L*r,z=L%2===0?92:146,y=h.linkedBehaviors.length+h.linkedBeliefs.length+h.linkedReports.length+h.linkedHabits.length,b=`goal:${h.goal.id}`;s.push({id:b,kind:"goal",x:j,y:z,radius:_t(h.goal.title,{compact:i}),tone:"amber",label:h.goal.title,href:`/goals/${h.goal.id}`}),u[b]={id:b,eyebrow:"Goal",title:h.goal.title,summary:h.goal.description,href:`/goals/${h.goal.id}`,ctaLabel:"Open goal",tone:"amber",entityKind:"goal",chips:h.linkedValues.slice(0,4).map(e=>e.title),stats:[`${h.linkedValues.length} linked value${h.linkedValues.length===1?"":"s"}`,`${h.linkedProjects.length} live project${h.linkedProjects.length===1?"":"s"}`,`${h.linkedHabits.length} linked habit${h.linkedHabits.length===1?"":"s"}`,`${y} friction signal${y===1?"":"s"}`]},y>0&&p.push({id:`field:${h.goal.id}`,x:j+18,y:z+20,radiusX:i?144:176,radiusY:i?104:132,tone:"rose",opacity:Math.min(.42,.14+y*.04)});const I=i?208:282;h.linkedValues.slice(0,i?4:5).forEach((e,d)=>{const m=(-95+d*(i?78:64))*(Math.PI/180),k=Tt(e.title,{compact:i}),G=j+Math.cos(m)*I,W=z+Math.sin(m)*I,K=U(h.goal.id,"value",e.id);s.push({id:K,kind:"value",x:G,y:W,radius:k,tone:"mint",label:e.title,meta:`${e.linkedGoalIds.length} goal${e.linkedGoalIds.length===1?"":"s"}`,href:`/psyche/values?focus=${e.id}#values-atlas`}),x.push({id:`${b}->${K}`,from:b,to:K,tone:"mint",strength:"medium"}),u[K]={id:K,eyebrow:"Value",title:e.title,summary:e.valuedDirection||e.whyItMatters||e.description,href:`/psyche/values?focus=${e.id}#values-atlas`,ctaLabel:"Open values",tone:"mint",entityKind:"value",chips:e.committedActions.slice(0,3),stats:[`${e.linkedProjectIds.length} linked project${e.linkedProjectIds.length===1?"":"s"}`,`${e.linkedTaskIds.length} linked task${e.linkedTaskIds.length===1?"":"s"}`]}});const P=h.linkedProjects.slice(0,i?2:3).map(e=>({project:e,size:tt(e.title,{compact:i,emphasis:!0})})),E=i?24:30;let N=-(P.reduce((e,d)=>e+d.size.width,0)+Math.max(0,P.length-1)*E)/2;P.forEach(({project:e,size:d},m)=>{const k=U(h.goal.id,"project",e.id),G=j+N+d.width/2,W=z-(i?330:434)-m*(i?16:20);N+=d.width+E,s.push({id:k,kind:"project",x:G,y:W,width:d.width,height:d.height,tone:"sky",label:e.title,meta:"Project",href:`/projects/${e.id}`}),x.push({id:`${b}->${k}`,from:b,to:k,tone:"sky",strength:"medium"}),u[k]={id:k,eyebrow:"Project",title:e.title,summary:e.description,href:`/projects/${e.id}`,ctaLabel:"Open project",tone:"sky",entityKind:"project",chips:[e.status,e.goalTitle],stats:[`${e.progress}% progress`,`${e.activeTaskCount} active task${e.activeTaskCount===1?"":"s"}`]}}),h.linkedHabits.slice(0,i?2:3).forEach((e,d)=>{const m=U(h.goal.id,"habit",e.id),k=tt(e.title,{compact:i}),G=j-(i?44:58),W=z+(i?228:294)+d*(i?92:104);s.push({id:m,kind:"habit",x:G,y:W,width:k.width,height:k.height,tone:"mint",label:e.title,meta:e.polarity,href:"/habits"}),x.push({id:`${b}->${m}`,from:b,to:m,tone:"mint",strength:e.dueToday?"high":"medium"}),u[m]={id:m,eyebrow:"Habit",title:e.title,summary:e.description||"Recurring operating record connected directly to this goal field.",href:"/habits",ctaLabel:"Open habits",tone:"mint",entityKind:"habit",chips:[e.polarity,e.frequency,e.dueToday?"due today":"checked in"],stats:[`${e.streakCount} streak`,`${e.rewardXp}/${e.penaltyXp} xp flow`]}});let O=z+(i?132:156);h.linkedBehaviors.slice(0,i?2:3).forEach(e=>{const d=U(h.goal.id,"behavior",e.id),m=tt(e.title,{compact:i}),k=j-(i?272:352);s.push({id:d,kind:"behavior",x:k,y:O,width:m.width,height:m.height,tone:"orange",label:e.title,meta:e.kind,href:`/psyche/behaviors?focus=${e.id}#behavior-columns`}),x.push({id:`${b}->${d}`,from:b,to:d,tone:"orange",dashed:e.kind!=="committed",strength:e.kind==="committed"?"medium":"low"}),u[d]={id:d,eyebrow:"Behavior",title:e.title,summary:e.replacementMove||e.description||e.urgeStory,href:`/psyche/behaviors?focus=${e.id}#behavior-columns`,ctaLabel:"Open behaviors",tone:"orange",entityKind:"behavior",chips:[e.kind,...e.commonCues.slice(0,2)],stats:[e.shortTermPayoff?"Short-term payoff mapped":"Payoff still to map",e.longTermCost?"Long-term cost mapped":"Cost still to map"]},O+=m.height+(i?18:22)});let X=z+(i?8:10);h.linkedBeliefs.slice(0,i?2:3).forEach(e=>{const d=U(h.goal.id,"belief",e.id),m=tt(e.statement,{compact:i,emphasis:!0}),k=j+(i?278:362);s.push({id:d,kind:"belief",x:k,y:X,width:m.width,height:m.height,tone:"violet",label:e.statement,meta:"belief",href:`/psyche/schemas-beliefs?focus=${e.id}`}),x.push({id:`${b}->${d}`,from:b,to:d,tone:"violet",dashed:!0,strength:"low"}),u[d]={id:d,eyebrow:"Belief",title:e.statement,summary:e.flexibleAlternative||e.originNote||"Belief script attached to this part of the map.",href:`/psyche/schemas-beliefs?focus=${e.id}`,ctaLabel:"Open beliefs",tone:"violet",entityKind:"belief",chips:[e.beliefType,`${e.confidence}% grip`],stats:[`${e.linkedBehaviorIds.length} linked behavior${e.linkedBehaviorIds.length===1?"":"s"}`,`${e.linkedReportIds.length} linked report${e.linkedReportIds.length===1?"":"s"}`]},X+=m.height+(i?18:22)});const S=h.linkedReports.slice(0,i?2:3).map(e=>({report:e,size:tt(e.title,{compact:i})})),H=i?20:26;let J=-(S.reduce((e,d)=>e+d.size.width,0)+Math.max(0,S.length-1)*H)/2;S.forEach(({report:e,size:d})=>{const m=U(h.goal.id,"report",e.id),k=j+J+d.width/2,G=z+(i?332:430);J+=d.width+H,s.push({id:m,kind:"report",x:k,y:G,width:d.width,height:d.height,tone:"blue",label:e.title,meta:e.status,href:`/psyche/reports/${e.id}`}),x.push({id:`${b}->${m}`,from:b,to:m,tone:"sky",strength:"medium"}),u[m]={id:m,eyebrow:"Report",title:e.title,summary:e.eventSituation||e.customEventType||"Reflective chain linked into this goal.",href:`/psyche/reports/${e.id}`,ctaLabel:"Open report",tone:"blue",entityKind:"report",chips:[e.status,...e.nextMoves.slice(0,2)],stats:[`${e.emotions.length} emotion${e.emotions.length===1?"":"s"}`,`${e.behaviors.length} move${e.behaviors.length===1?"":"s"}`]}})});const g=((w=s[0])==null?void 0:w.id)??"ghost_goal_center";return{nodes:Et(s,{compact:i}),edges:x,fields:p,inspectors:u,defaultSelectedId:g}}const et={mint:"color-mix(in srgb, var(--success) 64%, transparent)",sky:"color-mix(in srgb, var(--info) 66%, transparent)",violet:"color-mix(in srgb, var(--primary) 72%, transparent)",rose:"color-mix(in srgb, var(--danger) 68%, transparent)",amber:"color-mix(in srgb, var(--warning) 68%, transparent)",orange:"color-mix(in srgb, var(--tertiary) 72%, transparent)",blue:"color-mix(in srgb, var(--info) 72%, transparent)",slate:"color-mix(in srgb, var(--ui-ink-soft) 52%, transparent)"},it={mint:"color-mix(in srgb, var(--success) 18%, transparent)",sky:"color-mix(in srgb, var(--info) 18%, transparent)",violet:"color-mix(in srgb, var(--primary) 18%, transparent)",rose:"color-mix(in srgb, var(--danger) 18%, transparent)",amber:"color-mix(in srgb, var(--warning) 18%, transparent)",orange:"color-mix(in srgb, var(--tertiary) 18%, transparent)",blue:"color-mix(in srgb, var(--info) 18%, transparent)",slate:"color-mix(in srgb, var(--ui-ink-soft) 12%, transparent)"},A={mint:"color-mix(in srgb, var(--success) 56%, var(--ui-ink-strong) 44%)",sky:"color-mix(in srgb, var(--info) 56%, var(--ui-ink-strong) 44%)",violet:"color-mix(in srgb, var(--primary) 60%, var(--ui-ink-strong) 40%)",rose:"color-mix(in srgb, var(--danger) 58%, var(--ui-ink-strong) 42%)",amber:"color-mix(in srgb, var(--warning) 60%, var(--ui-ink-strong) 40%)",orange:"color-mix(in srgb, var(--tertiary) 60%, var(--ui-ink-strong) 40%)",blue:"color-mix(in srgb, var(--info) 58%, var(--ui-ink-strong) 42%)",slate:"var(--ui-ink-medium)"};function wt(n){switch(n){case"goal":case"value":case"behavior":case"belief":case"report":case"project":case"habit":return n;default:return null}}function Dt(n){if(n.tone)return n.tone;switch(n.kind){case"goal":return"amber";case"value":return"mint";case"belief":return"violet";case"behavior":return"orange";case"project":return"sky";case"habit":return"mint";case"report":return"blue";default:return"slate"}}function Gt(n){if(n.kind==="ghost")return n.meta??null;const i=wt(n.kind);return i?gt(i).label:n.meta??null}function ut(n,i,s){return Math.min(Math.max(n,i),s)}function lt(n,i,s=3){const x=n.trim().split(/\s+/),p=[];let u="";for(let g=0;g<x.length;g+=1){const w=x[g],h=u?`${u} ${w}`:w;if(h.length>i&&u){if(p.push(u),p.length>=s-1){u=[w,...x.slice(g+1)].join(" ");break}u=w}else u=h}u&&p.push(u);const r=p.slice(0,s),v=r.length-1;return v>=0&&r[v].length>i&&(r[v]=`${r[v].slice(0,Math.max(1,i-1)).trimEnd()}…`),r}function Vt(n,i){if(n.length===0&&i.length===0)return{minX:-360,maxX:360,minY:-240,maxY:240};let s=Number.POSITIVE_INFINITY,x=Number.NEGATIVE_INFINITY,p=Number.POSITIVE_INFINITY,u=Number.NEGATIVE_INFINITY;for(const r of n){const v=r.kind==="goal"||r.kind==="value"||r.kind==="ghost"?r.radius??32:(r.width??124)/2,g=r.kind==="goal"||r.kind==="value"||r.kind==="ghost"?r.radius??32:(r.height??56)/2,w=r.meta&&(r.kind==="goal"||r.kind==="ghost")?48:0;s=Math.min(s,r.x-v),x=Math.max(x,r.x+v),p=Math.min(p,r.y-g-w),u=Math.max(u,r.y+g)}for(const r of i)s=Math.min(s,r.x-r.radiusX),x=Math.max(x,r.x+r.radiusX),p=Math.min(p,r.y-r.radiusY),u=Math.max(u,r.y+r.radiusY);return{minX:s,maxX:x,minY:p,maxY:u}}function vt(n){return{x:n.x,y:n.y}}function Bt(n){if(n.kind==="goal"){const i=n.radius??112;return lt(n.label,Math.max(14,Math.floor(i/7.2)),4)}if(n.kind==="value"||n.kind==="ghost"){const i=n.radius??40;return lt(n.label,Math.max(12,Math.floor(i/3)),3)}return n.kind==="project"?lt(n.label,Math.max(18,Math.floor((n.width??220)/10)),3):lt(n.label,Math.max(16,Math.floor((n.width??180)/10.5)),2)}function Ft(n){switch(n){case"goal":return"amber";case"project":return"sky";case"value":return"mint";case"behavior":return"orange";case"belief":return"violet";case"report":return"blue";default:return"slate"}}function Kt({nodes:n,edges:i,fields:s=[],title:x,hint:p,action:u,legend:r,selectedNodeId:v,onSelectNode:g,minHeightClassName:w="min-h-[34rem] lg:min-h-[44rem]",compact:h=!1,testId:L}){const j=$.useRef(null),z=Xt(),[y,b]=$.useState({width:0,height:0}),[I,P]=$.useState({scale:1,x:0,y:0}),[E,q]=$.useState(null),N=$.useRef(null),O=$.useRef({scale:1,x:0,y:0}),X=$.useRef(new Map),S=$.useRef(null),H=$.useRef(0),D=$.useRef(!1),J=$.useMemo(()=>new Map(n.map(t=>[t.id,t])),[n]),e=$.useMemo(()=>Vt(n,s),[s,n]),d=y.width>0&&y.width<640;$.useEffect(()=>{if(!j.current||typeof ResizeObserver>"u")return;const t=new ResizeObserver(a=>{const l=a[0];b({width:l.contentRect.width,height:l.contentRect.height})});return t.observe(j.current),()=>t.disconnect()},[]);const m=$.useCallback(()=>{if(!y.width||!y.height)return;const t=d?260:h?140:190,a=Math.max(e.maxX-e.minX,1),l=Math.max(e.maxY-e.minY,1),o=ut(Math.min(y.width/(a+t),y.height/(l+t)),d?.16:h?.4:.46,d?.76:h?1.04:1.18),f=(e.minX+e.maxX)/2,Y=(e.minY+e.maxY)/2;P({scale:o,x:y.width/2-f*o,y:y.height/2-Y*o})},[e.maxX,e.maxY,e.minX,e.minY,h,y.height,y.width,d]);$.useEffect(()=>{O.current=I},[I]),$.useEffect(()=>{D.current||m()},[m]);const k=$.useCallback((t,a,l)=>{const o=ut(t,.28,1.9);P(f=>{if(a==null||l==null)return{...f,scale:o};const Y=(a-f.x)/f.scale,V=(l-f.y)/f.scale;return{scale:o,x:a-Y*o,y:l-V*o}})},[]),G=$.useCallback(()=>{const t=[...X.current.values()];if(t.length<2){S.current=null;return}const[a,l]=t,o=Math.hypot(l.x-a.x,l.y-a.y);if(!Number.isFinite(o)||o<=0){S.current=null;return}const f=O.current;S.current={startDistance:o,startScale:f.scale,startViewportX:f.x,startViewportY:f.y,startMidpointX:(a.x+l.x)/2,startMidpointY:(a.y+l.y)/2}},[]),W=t=>{var o;t.preventDefault();const a=(o=j.current)==null?void 0:o.getBoundingClientRect();if(!a)return;D.current=!0;const l=t.deltaY<0?1.1:.9;k(I.scale*l,t.clientX-a.left,t.clientY-a.top)},K=t=>{var f;const a=(f=j.current)==null?void 0:f.getBoundingClientRect(),l=t.clientX-((a==null?void 0:a.left)??0),o=t.clientY-((a==null?void 0:a.top)??0);if(X.current.set(t.pointerId,{x:l,y:o}),X.current.size===1){const Y=O.current;N.current={pointerId:t.pointerId,originX:Y.x,originY:Y.y,startX:l,startY:o}}else N.current=null,G();t.currentTarget.setPointerCapture(t.pointerId)},$t=t=>{var V;const a=(V=j.current)==null?void 0:V.getBoundingClientRect(),l=t.clientX-((a==null?void 0:a.left)??0),o=t.clientY-((a==null?void 0:a.top)??0);if(X.current.has(t.pointerId)&&X.current.set(t.pointerId,{x:l,y:o}),S.current&&X.current.size>=2){const[R,_]=[...X.current.values()],C=Math.hypot(_.x-R.x,_.y-R.y);if(Number.isFinite(C)&&C>0){D.current=!0,H.current=Date.now()+240;const Q=(R.x+_.x)/2,F=(R.y+_.y)/2,T=S.current,Z=ut(T.startScale*C/T.startDistance,.24,1.42),ct=(T.startMidpointX-T.startViewportX)/T.startScale,ht=(T.startMidpointY-T.startViewportY)/T.startScale;P({scale:Z,x:Q-ct*Z,y:F-ht*Z})}return}if(!N.current||N.current.pointerId!==t.pointerId||X.current.size!==1)return;D.current=!0;const f=l-N.current.startX,Y=o-N.current.startY;(Math.abs(f)>3||Math.abs(Y)>3)&&(H.current=Date.now()+240),P(R=>{var _,C;return{...R,x:(((_=N.current)==null?void 0:_.originX)??R.x)+f,y:(((C=N.current)==null?void 0:C.originY)??R.y)+Y}})},xt=t=>{if(X.current.delete(t.pointerId),X.current.size<2&&(S.current=null),X.current.size===1){const[a,l]=[...X.current.entries()][0]??[];if(a!=null&&l){const o=O.current;N.current={pointerId:a,originX:o.x,originY:o.y,startX:l.x,startY:l.y}}}else N.current=null;t.currentTarget.hasPointerCapture(t.pointerId)&&t.currentTarget.releasePointerCapture(t.pointerId)},nt=E??v??null,rt=$.useCallback(t=>{Date.now()<H.current||(g==null||g(t.id),t.href&&z(t.href))},[z,g]);return c.jsxs("section",{"data-testid":L,className:dt("overflow-hidden rounded-[32px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)] shadow-[var(--card-shadow)]","px-3 py-3 sm:px-4 sm:py-4 lg:px-5 lg:py-5"),children:[c.jsxs("div",{className:"mb-3 flex min-w-0 flex-wrap items-start justify-between gap-3",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--info)]",children:"Gravity well"}),c.jsx("h2",{className:dt("mt-2 break-words font-display leading-none text-[var(--ui-ink-strong)]",h?"text-[clamp(1.25rem,2vw,1.7rem)]":"text-[clamp(1.45rem,2.8vw,2.3rem)]"),children:x}),p?c.jsx("p",{className:"mt-1.5 max-w-3xl break-words text-sm leading-6 text-[var(--ui-ink-soft)]",children:d?"Select a node, pan the field, and open the full map when you need the wider structure.":p}):null]}),c.jsx("div",{className:"flex min-w-0 flex-wrap items-center justify-end gap-2",children:u})]}),c.jsxs("div",{ref:j,className:dt("group relative overflow-hidden rounded-[30px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] touch-none",w),style:{touchAction:"none"},onWheel:W,onPointerDown:K,onPointerMove:$t,onPointerUp:xt,onPointerCancel:xt,children:[c.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_center,color-mix(in_srgb,var(--success)_8%,transparent),transparent_28%),radial-gradient(circle_at_20%_20%,color-mix(in_srgb,var(--primary)_10%,transparent),transparent_24%),var(--ui-surface-section)]"}),c.jsxs("div",{className:"absolute left-3 top-3 z-10 inline-flex max-w-[calc(100%-7rem)] items-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--surface-glass)] px-2.5 py-1.5 text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)] backdrop-blur-xl sm:left-4 sm:top-4 sm:max-w-none sm:px-3",onPointerDown:t=>t.stopPropagation(),children:[c.jsx(Rt,{className:"size-3.5"}),d?"Drag or pinch":"Drag to pan, scroll to zoom"]}),c.jsxs("div",{className:"absolute right-3 top-3 z-10 flex max-w-[calc(100%-1.5rem)] flex-wrap items-center justify-end gap-1.5 sm:right-4 sm:top-4 sm:max-w-none sm:gap-2",onPointerDown:t=>t.stopPropagation(),children:[c.jsx(ot,{type:"button",variant:"secondary",size:"sm",className:"px-2.5 sm:px-3","aria-label":"Zoom in",onClick:()=>{D.current=!0,k(I.scale*1.12,y.width-96,72)},children:c.jsx(zt,{className:"size-4"})}),c.jsx(ot,{type:"button",variant:"secondary",size:"sm",className:"px-2.5 sm:px-3","aria-label":"Zoom out",onClick:()=>{D.current=!0,k(I.scale*.88,y.width-96,72)},children:c.jsx(Ct,{className:"size-4"})}),c.jsxs(ot,{type:"button",variant:"secondary",size:"sm",className:"px-2.5 sm:min-w-[4.75rem] sm:px-3","aria-label":"Fit graph",onClick:()=>{D.current=!0,m()},children:[c.jsx(Pt,{className:"size-4"}),d?null:"Fit"]}),c.jsxs(ot,{type:"button",variant:"secondary",size:"sm",className:"px-2.5 sm:min-w-[5.5rem] sm:px-3","aria-label":"Reset graph",onClick:()=>{D.current=!1,m()},children:[c.jsx(Nt,{className:"size-4"}),d?null:"Reset"]})]}),r&&r.length>0&&!d?c.jsx("div",{className:"absolute bottom-4 left-4 z-10 flex flex-wrap items-center gap-2 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--surface-glass)] px-3 py-2 text-xs text-[var(--ui-ink-soft)] backdrop-blur-xl",children:r.map(t=>{const a=t.kind?Ft(t.kind):t.tone??"slate",l=t.kind?gt(t.kind).icon:null;return c.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap rounded-full bg-[var(--ui-surface-1)] px-2.5 py-1.5",children:[l?c.jsx(l,{className:"size-3.5",color:A[a],strokeWidth:2.1}):c.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:et[a]}}),t.label]},t.label)})}):null,c.jsxs("svg",{className:"relative z-[1] h-full w-full overflow-hidden",viewBox:`0 0 ${y.width||1200} ${y.height||760}`,role:"img","aria-label":x,style:{overflow:"hidden"},children:[c.jsx("defs",{children:c.jsx("filter",{id:"forge-graph-blur",children:c.jsx("feGaussianBlur",{stdDeviation:"34"})})}),c.jsxs("g",{transform:`translate(${I.x} ${I.y}) scale(${I.scale})`,children:[s.map(t=>c.jsx("ellipse",{cx:t.x,cy:t.y,rx:t.radiusX,ry:t.radiusY,fill:it[t.tone??"rose"],opacity:t.opacity??.42,filter:"url(#forge-graph-blur)"},t.id)),n.filter(t=>t.kind==="goal"||t.kind==="ghost").map(t=>{const a=t.radius??76;return c.jsx("g",{opacity:t.kind==="ghost"?.28:.55,children:[a+74,a+124].map((l,o)=>c.jsx("circle",{cx:t.x,cy:t.y,r:l,fill:"none",stroke:o===0?"var(--ui-border-subtle)":"var(--ui-border-strong)",strokeDasharray:o===0?"0":"10 10"},`${t.id}-ring-${l}`))},`${t.id}-orbital-lanes`)}),i.map(t=>{const a=J.get(t.from),l=J.get(t.to);if(!a||!l)return null;const o=vt(a),f=vt(l),Y=(o.x+f.x)/2,V=(o.y+f.y)/2,R=Math.max(24,Math.abs(o.x-f.x)*.08),_=Y,C=V-R;return c.jsx("path",{d:`M ${o.x} ${o.y} Q ${_} ${C} ${f.x} ${f.y}`,fill:"none",stroke:et[t.tone??"slate"],strokeWidth:t.strength==="high"?3:t.strength==="medium"?2.2:1.6,strokeDasharray:t.dashed?"8 8":void 0,opacity:nt&&t.from!==nt&&t.to!==nt?.18:.62},t.id)}),n.map(t=>{t.id;const a=E===t.id,l=nt===t.id,o=Dt(t),f=Gt(t),Y=Bt(t),V=wt(t.kind),R=V?gt(V).icon:null;if(t.kind==="goal"||t.kind==="value"||t.kind==="ghost"){const M=t.radius??(t.kind==="goal"?76:34),st=f?t.y-M-(t.kind==="goal"?18:10):null,yt=t.kind==="goal"?20:14.5,at=t.kind==="goal"?28:16,It=t.kind==="goal"?t.y-M*.34:t.kind==="value"?t.y-M*.3:t.y-M*.2,Yt=t.kind==="goal"?t.y+M*.2:t.y+10;return c.jsxs("g",{tabIndex:0,role:"button",onPointerEnter:()=>{q(t.id),g==null||g(t.id)},onPointerLeave:()=>q(B=>B===t.id?null:B),onFocus:()=>g==null?void 0:g(t.id),onClick:()=>rt(t),onKeyDown:B=>{(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),rt(t))},className:"cursor-pointer outline-none",children:[c.jsx("circle",{cx:t.x,cy:t.y,r:M+(l?14:0),fill:l?it[o]:"transparent",stroke:l?et[o]:"transparent",opacity:a?.98:.9}),c.jsx("circle",{cx:t.x,cy:t.y,r:M+(a?2:0),fill:t.kind==="ghost"?"var(--ui-surface-1)":it[o],stroke:t.kind==="ghost"?"var(--ui-border-strong)":et[o],strokeDasharray:t.kind==="ghost"?"8 8":void 0,strokeWidth:l?2.8:1.6}),f?c.jsx("text",{x:t.x,y:st??t.y-12,textAnchor:"middle",fontSize:t.kind==="goal"?"11.5":"10.5",fill:t.kind==="ghost"?"var(--ui-ink-soft)":A[o],style:{letterSpacing:"0.18em",textTransform:"uppercase"},children:f}):null,R?c.jsx(R,{x:t.x-at/2,y:It-at/2,width:at,height:at,color:A[o],strokeWidth:2.1}):null,Y.map((B,bt)=>c.jsx("text",{x:t.x,y:Yt+bt*yt-(Y.length-1)*yt/2,textAnchor:"middle",fontSize:t.kind==="goal"?21:12.8,fontWeight:t.kind==="goal"?600:500,fill:t.kind==="ghost"?"var(--ui-ink-strong)":A[o],children:B},`${t.id}-${B}-${bt}`))]},t.id)}const _=t.width??146,C=t.height??58,Q=t.x-_/2,F=t.y-C/2,T=t.kind==="project"?14:13,Z=Q+14,ct=F+13,ht=F+22,jt=f?F+C*.65:F+C*.56,pt=t.kind==="project"?16:15,Mt=t.kind==="project"?14.2:13.2;return c.jsxs("g",{tabIndex:0,role:"button",onPointerEnter:()=>{q(t.id),g==null||g(t.id)},onPointerLeave:()=>q(M=>M===t.id?null:M),onFocus:()=>g==null?void 0:g(t.id),onClick:()=>rt(t),onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),rt(t))},className:"cursor-pointer outline-none",children:[c.jsx("rect",{x:Q-(l?6:0),y:F-(l?6:0),rx:"28",ry:"28",width:_+(l?12:0),height:C+(l?12:0),fill:l?it[o]:"transparent"}),c.jsx("rect",{x:Q-(a?2:0),y:F-(a?2:0),rx:"22",ry:"22",width:_+(a?4:0),height:C+(a?4:0),fill:it[o],stroke:et[o],strokeWidth:l?2.3:1.3}),R?c.jsx(R,{x:Z,y:ct,width:T,height:T,color:A[o],strokeWidth:2.1}):null,f?c.jsx("text",{x:Z+T+8,y:ht,textAnchor:"start",fontSize:"9.5",fill:A[o],style:{letterSpacing:"0.16em",textTransform:"uppercase",opacity:.82},children:f}):null,Y.map((M,st)=>c.jsx("text",{x:t.x,y:jt+st*pt-(Y.length-1)*pt/2,textAnchor:"middle",fontSize:Mt,fontWeight:600,fill:A[o],children:M},`${t.id}-${M}-${st}`))]},t.id)})]})]})]})]})}export{Kt as P,Wt as b};