forge-openclaw-plugin 0.2.101 → 0.2.103

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (227) hide show
  1. package/dist/assets/activity-page-Dv6X5ZCV.js +1 -0
  2. package/dist/assets/ai-surface-workspace-CutiG6uS.js +1 -0
  3. package/dist/assets/atlas-panel-jgMRyaHn.js +1 -0
  4. package/dist/assets/{board-BkDRaMp6.js → board-dIX6etHh.js} +1 -1
  5. package/dist/assets/calendar-page-q7Nm5E2U.js +1 -0
  6. package/dist/assets/calendar-rules-DPFsfiRl.js +1 -0
  7. package/dist/assets/calendar-week-toolbar-nVhgB-0s.js +1 -0
  8. package/dist/assets/{charts-P7EVhIog.js → charts-DFnEuIMB.js} +8 -8
  9. package/dist/assets/companion-sync-lab-page-CJ8UTij8.js +1 -0
  10. package/dist/assets/daily-metrics-dashboard-CiJkkkd1.js +1 -0
  11. package/dist/assets/entity-note-count-link-RzBB6ujx.js +1 -0
  12. package/dist/assets/entity-notes-surface-Djz50HvD.js +1 -0
  13. package/dist/assets/execution-board-CtPhI-58.js +1 -0
  14. package/dist/assets/faceted-token-search-DEC6ANa9.js +1 -0
  15. package/dist/assets/flagship-signal-deck-CtHC3mql.js +1 -0
  16. package/dist/assets/floating-action-menu-CKQRhff9.js +1 -0
  17. package/dist/assets/{forms-BFlTgZ3W.js → forms-hB0SqEh-.js} +1 -1
  18. package/dist/assets/goal-detail-page-CF5fNQeR.js +1 -0
  19. package/dist/assets/goals-page-fsY8NzGB.js +1 -0
  20. package/dist/assets/{graph-D6JLqDbD.js → graph-DDUZNRsO.js} +14 -14
  21. package/dist/assets/habits-page-COoGz4kj.js +1 -0
  22. package/dist/assets/index-BAXYM89v.css +1 -0
  23. package/dist/assets/index-EqQsXoat.js +19 -0
  24. package/dist/assets/insight-flow-dialog-DtX_5W7g.js +1 -0
  25. package/dist/assets/insights-page-cBd74ObU.js +8 -0
  26. package/dist/assets/kanban-page-CYav9THw.js +1 -0
  27. package/dist/assets/knowledge-graph-page-D2A-W1jE.js +1 -0
  28. package/dist/assets/{life-force-page-Dy0JTS2G.js → life-force-page-CACGlNhq.js} +1 -1
  29. package/dist/assets/life-force-workspace-BJ4N1I78.js +1 -0
  30. package/dist/assets/{maps-ClgJoCjz.js → maps-C-yOWiDN.js} +1 -1
  31. package/dist/assets/metric-tile-CMadwnGz.js +1 -0
  32. package/dist/assets/{motion-BeD44FeG.js → motion-Lt5B1XuE.js} +1 -1
  33. package/dist/assets/movement-page-D5VqFd2q.js +1 -0
  34. package/dist/assets/note-markdown-BzK2Qlgr.js +3 -0
  35. package/dist/assets/note-tags-input-CZzqJMLc.js +1 -0
  36. package/dist/assets/notes-page-D3Hsh90C.js +1 -0
  37. package/dist/assets/{open-in-graph-button-IXe9SGth.js → open-in-graph-button-BFPKfyK3.js} +1 -1
  38. package/dist/assets/orbit-map-CnyfSmOG.js +1 -0
  39. package/dist/assets/overview-page-CXdWrOV1.js +1 -0
  40. package/dist/assets/page-hero-ffKzgyW3.js +1 -0
  41. package/dist/assets/pill-cluster-C2D0h3lx.js +1 -0
  42. package/dist/assets/{preference-entity-handoff-button-5PzUn42S.js → preference-entity-handoff-button-Dj3V6VxL.js} +1 -1
  43. package/dist/assets/preferences-page-Jo8Gw386.js +1 -0
  44. package/dist/assets/project-collections-qSqp90HN.js +1 -0
  45. package/dist/assets/{project-detail-page-BXK5-4xW.js → project-detail-page-BifhiLQX.js} +1 -1
  46. package/dist/assets/project-management-hierarchy-page-DZ_9klIc.js +1 -0
  47. package/dist/assets/project-management-section-nav-BImLCVvf.js +1 -0
  48. package/dist/assets/projects-page-ptcx6H38.js +1 -0
  49. package/dist/assets/psyche-behaviors-page-BDwXyDta.js +5 -0
  50. package/dist/assets/psyche-flashcards-page-DL1BP1jX.js +1 -0
  51. package/dist/assets/psyche-goal-map-page-ovcpisx1.js +1 -0
  52. package/dist/assets/psyche-graph-EP5GL612.js +1 -0
  53. package/dist/assets/{psyche-metrics-page-CuR9oqEy.js → psyche-metrics-page-Bcu813Rg.js} +1 -1
  54. package/dist/assets/psyche-mode-guide-page-C0g27Xpt.js +1 -0
  55. package/dist/assets/psyche-modes-page-BjKjX5MR.js +1 -0
  56. package/dist/assets/psyche-page-F4tF2W70.js +1 -0
  57. package/dist/assets/psyche-patterns-page-B-14hukK.js +5 -0
  58. package/dist/assets/psyche-questionnaire-builder-page-BdXmoHvK.js +1 -0
  59. package/dist/assets/psyche-questionnaire-detail-page-Cu5uwlJu.js +1 -0
  60. package/dist/assets/psyche-questionnaire-run-detail-page-C3R4PClg.js +1 -0
  61. package/dist/assets/psyche-questionnaire-run-page-Div3iDdt.js +1 -0
  62. package/dist/assets/psyche-questionnaires-page-DpqAPQCp.js +1 -0
  63. package/dist/assets/psyche-report-detail-page-BvWVDKP3.js +3 -0
  64. package/dist/assets/psyche-reports-page-BrbWUlAq.js +1 -0
  65. package/dist/assets/{psyche-schemas-HFmg37Wj.js → psyche-schemas-Dxj554nU.js} +1 -1
  66. package/dist/assets/psyche-schemas-beliefs-page-DYKvAtSD.js +9 -0
  67. package/dist/assets/psyche-screen-time-page-CAOKCyQw.js +1 -0
  68. package/dist/assets/psyche-self-observation-page-F0MVA0UH.js +1 -0
  69. package/dist/assets/psyche-values-page-DyvX-d0o.js +5 -0
  70. package/dist/assets/report-chain-fields-CeC1cJFS.js +1 -0
  71. package/dist/assets/rewards-page-C2loyODo.js +1 -0
  72. package/dist/assets/scheduling-rules-editor-D40AC2jR.js +1 -0
  73. package/dist/assets/schema-badge-FY7818qB.js +1 -0
  74. package/dist/assets/schema-visuals-CvC9a3i6.js +1 -0
  75. package/dist/assets/select-menu-DJsCG6rM.js +1 -0
  76. package/dist/assets/settings-agents-page-BFkJ5AAD.js +6 -0
  77. package/dist/assets/settings-bin-page-D3-Ab-iA.js +1 -0
  78. package/dist/assets/settings-calendar-page-ly_mSTAD.js +5 -0
  79. package/dist/assets/settings-data-page-D7QOqNf-.js +1 -0
  80. package/dist/assets/settings-logs-page-Ca87HEUx.js +1 -0
  81. package/dist/assets/settings-mobile-page-D0jejZot.js +1 -0
  82. package/dist/assets/settings-models-page-DPDsZjSc.js +1 -0
  83. package/dist/assets/settings-page-1cArlSPM.js +1 -0
  84. package/dist/assets/settings-rewards-page-Db4BV1DC.js +1 -0
  85. package/dist/assets/{settings-section-nav-DSOuht_F.js → settings-section-nav-DP9o4peU.js} +1 -1
  86. package/dist/assets/settings-users-page-BHFyDSsd.js +1 -0
  87. package/dist/assets/settings-wiki-page-BNaiupBm.js +1 -0
  88. package/dist/assets/sleep-page-BmOPF0yD.js +1 -0
  89. package/dist/assets/sports-page-BldIiclr.js +1 -0
  90. package/dist/assets/{state-B-4sS1xO.js → state-vCcAT5Hq.js} +1 -1
  91. package/dist/assets/strategies-page-CaTN99qj.js +1 -0
  92. package/dist/assets/strategy-detail-page-DsgFTd-U.js +1 -0
  93. package/dist/assets/strategy-dialog-7X7peRzu.js +1 -0
  94. package/dist/assets/surface-CJI17F3n.js +1 -0
  95. package/dist/assets/{table-WfAPUppN.js → table-BNqMG3_S.js} +1 -1
  96. package/dist/assets/task-detail-page-M1sIIPA8.js +1 -0
  97. package/dist/assets/timebox-planning-dialog-ByojN0AN.js +1 -0
  98. package/dist/assets/today-page-BjDijtn8.js +1 -0
  99. package/dist/assets/training-load-page-BPRmaWmF.js +1 -0
  100. package/dist/assets/{ui-C13Nbgas.js → ui-C1iwpj2-.js} +4 -4
  101. package/dist/assets/use-psyche-focus-target-Ct-acS9G.js +1 -0
  102. package/dist/assets/vendor-Dnkkx2co.js +1067 -0
  103. package/dist/assets/{vitals-page-qre17Nw8.js → vitals-page-CE9zdGLF.js} +1 -1
  104. package/dist/assets/weekly-review-page-CzhTv90n.js +1 -0
  105. package/dist/assets/weight-loss-page-Bp_cIk78.js +5 -0
  106. package/dist/assets/wiki-article-markdown-Dok2uy2p.js +4 -0
  107. package/dist/assets/wiki-editor-page-BuW32Y3f.js +26 -0
  108. package/dist/assets/wiki-ingest-history-page-DZKSBNHV.js +1 -0
  109. package/dist/assets/wiki-ingest-modal-DyqBEZcC.js +1 -0
  110. package/dist/assets/wiki-page-DqxlbLKG.js +1 -0
  111. package/dist/assets/workbench-flow-page-C4nc9jUg.js +5 -0
  112. package/dist/assets/workbench-page-BnyR7SL0.js +1 -0
  113. package/dist/assets/workout-detail-page-DT-c5cHL.js +2 -0
  114. package/dist/index.html +9 -9
  115. package/dist/openclaw/local-runtime.js +41 -14
  116. package/dist/server/server/migrations/067_weight_loss_daily_active_overrides.sql +13 -0
  117. package/dist/server/server/src/app.js +125 -33
  118. package/dist/server/server/src/health-weight-loss.js +554 -77
  119. package/dist/server/server/src/health.js +12 -4
  120. package/dist/server/server/src/movement.js +84 -1
  121. package/dist/server/server/src/openapi.js +123 -18
  122. package/dist/server/server/src/repositories/model-settings.js +21 -12
  123. package/dist/server/server/src/repositories/settings.js +19 -5
  124. package/dist/server/src/components/ui/info-tooltip.js +6 -6
  125. package/dist/server/src/components/workbench-boxes/shared/generic-node-view.js +13 -5
  126. package/dist/server/src/lib/api.js +24 -5
  127. package/dist/server/src/lib/theme-system.js +8 -0
  128. package/openclaw.plugin.json +1 -1
  129. package/package.json +3 -3
  130. package/server/migrations/067_weight_loss_daily_active_overrides.sql +13 -0
  131. package/skills/forge-openclaw/SKILL.md +13 -0
  132. package/skills/forge-openclaw/entity_conversation_playbooks.md +7 -1
  133. package/dist/assets/activity-page-CpjuNSHw.js +0 -1
  134. package/dist/assets/ai-surface-workspace-DEAFZruS.js +0 -1
  135. package/dist/assets/atlas-panel-CdVNPotj.js +0 -1
  136. package/dist/assets/calendar-page-DNNt6lfz.js +0 -1
  137. package/dist/assets/calendar-rules-DNJFNsxi.js +0 -1
  138. package/dist/assets/calendar-week-toolbar-BbPwYeN0.js +0 -1
  139. package/dist/assets/companion-sync-lab-page-KxEDigM6.js +0 -1
  140. package/dist/assets/daily-metrics-dashboard-B3cqJgDt.js +0 -1
  141. package/dist/assets/entity-note-count-link-DrhjJZ4i.js +0 -1
  142. package/dist/assets/entity-notes-surface-CkcRsKJQ.js +0 -1
  143. package/dist/assets/execution-board-D07gOocB.js +0 -1
  144. package/dist/assets/faceted-token-search-BxRRcM3q.js +0 -1
  145. package/dist/assets/flagship-signal-deck-cmy82b8_.js +0 -1
  146. package/dist/assets/floating-action-menu-Fs_ZiUMo.js +0 -1
  147. package/dist/assets/goal-detail-page-CqLiNz4f.js +0 -1
  148. package/dist/assets/goals-page-BTk7mg_T.js +0 -1
  149. package/dist/assets/habits-page-BJxagdzx.js +0 -1
  150. package/dist/assets/index-CF4J4R9L.js +0 -19
  151. package/dist/assets/index-CZbuZQjw.css +0 -1
  152. package/dist/assets/insight-flow-dialog-8f3D0GuC.js +0 -1
  153. package/dist/assets/insights-page-D6rOa7uk.js +0 -8
  154. package/dist/assets/kanban-page-XQ7Se6dH.js +0 -1
  155. package/dist/assets/knowledge-graph-page-BtAg8iv3.js +0 -1
  156. package/dist/assets/life-force-workspace-OfyB9HJM.js +0 -1
  157. package/dist/assets/metric-tile-DKpo-8xw.js +0 -1
  158. package/dist/assets/movement-page-Bg_T_Stx.js +0 -1
  159. package/dist/assets/note-markdown-N-uxD3Xt.js +0 -3
  160. package/dist/assets/note-tags-input-Cdu7wiw6.js +0 -1
  161. package/dist/assets/notes-page-CKXnF_KU.js +0 -1
  162. package/dist/assets/orbit-map-Dzi6KliQ.js +0 -1
  163. package/dist/assets/overview-page-1miYqaVS.js +0 -1
  164. package/dist/assets/page-hero-DRy5b2MU.js +0 -1
  165. package/dist/assets/pill-cluster-C9QczVJ2.js +0 -1
  166. package/dist/assets/preferences-page-DtNaF5Q3.js +0 -1
  167. package/dist/assets/project-collections-xPz2mlRr.js +0 -1
  168. package/dist/assets/project-management-hierarchy-page-DtRpMABw.js +0 -1
  169. package/dist/assets/project-management-section-nav-P3ixzPa-.js +0 -1
  170. package/dist/assets/projects-page-C5ViRuf4.js +0 -1
  171. package/dist/assets/psyche-behaviors-page-Dco46sC4.js +0 -5
  172. package/dist/assets/psyche-flashcards-page-ZcoEB8gV.js +0 -1
  173. package/dist/assets/psyche-goal-map-page-CLBAQOI0.js +0 -1
  174. package/dist/assets/psyche-graph-k4tX2tdp.js +0 -1
  175. package/dist/assets/psyche-mode-guide-page-hIVXcCnE.js +0 -1
  176. package/dist/assets/psyche-modes-page-0lYtBlhO.js +0 -1
  177. package/dist/assets/psyche-page-VZ9k9ISp.js +0 -1
  178. package/dist/assets/psyche-patterns-page-gx5nmdGq.js +0 -5
  179. package/dist/assets/psyche-questionnaire-builder-page-Bn0TOISd.js +0 -1
  180. package/dist/assets/psyche-questionnaire-detail-page-CmVzSd_s.js +0 -1
  181. package/dist/assets/psyche-questionnaire-run-detail-page-BsMbmXCG.js +0 -1
  182. package/dist/assets/psyche-questionnaire-run-page-CgkRL2vi.js +0 -1
  183. package/dist/assets/psyche-questionnaires-page-D7V8uLXM.js +0 -1
  184. package/dist/assets/psyche-report-detail-page-OlFq57eL.js +0 -3
  185. package/dist/assets/psyche-reports-page-dVUZjna1.js +0 -1
  186. package/dist/assets/psyche-schemas-beliefs-page-BCgc8FUd.js +0 -9
  187. package/dist/assets/psyche-screen-time-page-B_6BT_WN.js +0 -1
  188. package/dist/assets/psyche-self-observation-page-CEG5mluK.js +0 -1
  189. package/dist/assets/psyche-values-page-DRbRfEd6.js +0 -5
  190. package/dist/assets/report-chain-fields-CALCV3V5.js +0 -1
  191. package/dist/assets/rewards-page-DmC4R_Ps.js +0 -1
  192. package/dist/assets/scheduling-rules-editor-D02s70hr.js +0 -1
  193. package/dist/assets/schema-badge-BZO-qNhO.js +0 -1
  194. package/dist/assets/schema-visuals-D6nxjbYC.js +0 -1
  195. package/dist/assets/select-menu-fYyreSdQ.js +0 -1
  196. package/dist/assets/settings-agents-page-C_v_hMJF.js +0 -6
  197. package/dist/assets/settings-bin-page-DY5bg81n.js +0 -1
  198. package/dist/assets/settings-calendar-page-D1CzE6cg.js +0 -5
  199. package/dist/assets/settings-data-page-CHRQFU9H.js +0 -1
  200. package/dist/assets/settings-logs-page-B04pUwEv.js +0 -1
  201. package/dist/assets/settings-mobile-page-D9kTlYDS.js +0 -1
  202. package/dist/assets/settings-models-page-D26270R2.js +0 -1
  203. package/dist/assets/settings-page-DYDTFlnv.js +0 -1
  204. package/dist/assets/settings-rewards-page-cl4vqqO_.js +0 -1
  205. package/dist/assets/settings-users-page-BU79JB_T.js +0 -1
  206. package/dist/assets/settings-wiki-page-DwAUlyA3.js +0 -1
  207. package/dist/assets/sleep-page-D8NbdhyS.js +0 -1
  208. package/dist/assets/sports-page-CV4Cnzwn.js +0 -1
  209. package/dist/assets/strategies-page-C4qvXnql.js +0 -1
  210. package/dist/assets/strategy-detail-page-DJLo5rfy.js +0 -1
  211. package/dist/assets/strategy-dialog-D3AuUlVz.js +0 -1
  212. package/dist/assets/task-detail-page-z-9u9rF0.js +0 -1
  213. package/dist/assets/timebox-planning-dialog-DB6FLqmI.js +0 -1
  214. package/dist/assets/today-page-BKlu6gx5.js +0 -1
  215. package/dist/assets/training-load-page-CyJQqo_3.js +0 -1
  216. package/dist/assets/use-psyche-focus-target-C1C_XjYG.js +0 -1
  217. package/dist/assets/vendor-DHkYh85p.js +0 -1052
  218. package/dist/assets/weekly-review-page-Cz4vkRcx.js +0 -1
  219. package/dist/assets/weight-loss-page-BQrnOI0y.js +0 -1
  220. package/dist/assets/wiki-article-markdown-DdiR2TJE.js +0 -4
  221. package/dist/assets/wiki-editor-page-DqwoqVFb.js +0 -26
  222. package/dist/assets/wiki-ingest-history-page--evBLbOw.js +0 -1
  223. package/dist/assets/wiki-ingest-modal--ohzFnj2.js +0 -1
  224. package/dist/assets/wiki-page-B_VJFBPA.js +0 -1
  225. package/dist/assets/workbench-flow-page-Du62mtJU.js +0 -5
  226. package/dist/assets/workbench-page-4MKr3iRm.js +0 -1
  227. package/dist/assets/workout-detail-page-DfUbYYw1.js +0 -2
@@ -1 +0,0 @@
1
- import{j as e}from"./vendor-DHkYh85p.js";import{j as h,i as u,k as y}from"./state-B-4sS1xO.js";import{F as v}from"./flagship-signal-deck-cmy82b8_.js";import{P as f,fm as g,i as j,S as k,E as x,C as o,c as w,B as N,fn as b}from"./index-CF4J4R9L.js";import{P as R}from"./page-hero-DRy5b2MU.js";import{R as S,f as z,X as $,Y as P,B as X}from"./charts-P7EVhIog.js";import"./motion-BeD44FeG.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";function M(){var c;const{t}=f(),n=h(),l=u({queryKey:["forge-weekly-review"],queryFn:b}),d=y({mutationFn:g,onSuccess:async()=>{await Promise.all([n.invalidateQueries({queryKey:["forge-weekly-review"]}),n.invalidateQueries({queryKey:["forge-xp-metrics"]}),n.invalidateQueries({queryKey:["forge-reward-ledger"]}),j(n),n.invalidateQueries({queryKey:["activity-archive"]})])}}),i=(c=l.data)==null?void 0:c.review;if(l.isLoading)return e.jsx(k,{});if(l.isError)return e.jsx(x,{eyebrow:t("common.weeklyReview.heroEyebrow"),error:l.error,onRetry:()=>void l.refetch()});if(!i)return e.jsx(x,{eyebrow:t("common.weeklyReview.heroEyebrow"),error:new Error("Forge returned an empty weekly review payload."),onRetry:()=>void l.refetch()});const r=i.wins[0]??null,a=i.calibration.find(s=>s.mode==="recover")??i.calibration[0]??null,m=i.calibration.find(s=>s.mode==="accelerate")??i.calibration[0]??null,p=[{id:"week",label:"This week",title:`${i.momentumSummary.totalXp} XP with ${i.momentumSummary.focusHours} focus hours`,detail:`Peak window: ${i.momentumSummary.peakWindow}. Efficiency score is holding at ${i.momentumSummary.efficiencyScore}.`,badge:i.windowLabel},{id:"wins",label:"Wins",title:(r==null?void 0:r.title)??t("common.weeklyReview.noWin"),detail:(r==null?void 0:r.summary)??t("common.weeklyReview.noWinDetail"),badge:r?`+${r.rewardXp} xp`:`${i.wins.length} wins`},{id:"recovery",label:"Recovery",title:(a==null?void 0:a.title)??t("common.weeklyReview.noRecovery"),detail:(a==null?void 0:a.note)??t("common.weeklyReview.noRecoveryDetail"),badge:(a==null?void 0:a.mode)??"maintain"},{id:"next-intent",label:"Next intent",title:(m==null?void 0:m.title)??i.reward.title,detail:(m==null?void 0:m.note)??i.reward.summary,badge:`+${i.reward.rewardXp} xp`}];return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(R,{title:"Weekly Review",description:`${i.windowLabel}. ${t("common.weeklyReview.heroDescription")}`,badge:`${i.momentumSummary.totalXp} xp`}),e.jsxs("section",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.2fr)_minmax(0,0.8fr)]",children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(o,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:t("common.weeklyReview.sectionMomentum")}),e.jsx("div",{className:"mt-4 h-64",children:e.jsx(S,{width:"100%",height:"100%",children:e.jsxs(z,{data:i.chart,children:[e.jsx($,{dataKey:"label",tick:{fill:"rgba(255,255,255,0.42)",fontSize:11}}),e.jsx(P,{hide:!0}),e.jsx(X,{dataKey:"xp",fill:"#c0c1ff",radius:[8,8,0,0]})]})})}),e.jsxs("div",{className:"mt-4 grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/40",children:"XP"}),e.jsx("div",{className:"mt-2 text-2xl text-white",children:i.momentumSummary.totalXp})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Focus hours"}),e.jsx("div",{className:"mt-2 text-2xl text-white",children:i.momentumSummary.focusHours})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Peak window"}),e.jsx("div",{className:"mt-2 text-2xl text-white",children:i.momentumSummary.peakWindow})]})]})]}),e.jsxs(o,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:t("common.weeklyReview.sectionGoals")}),e.jsx("div",{className:"mt-4 grid gap-3",children:i.calibration.map(s=>e.jsxs("div",{className:"overflow-hidden rounded-[20px] bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[e.jsx("div",{className:"min-w-0 flex-1 font-medium text-white",children:s.title}),e.jsx(w,{className:"max-w-[9rem] shrink-0 self-start",children:s.mode})]}),e.jsx("div",{className:"mt-3 text-sm text-white/58",children:s.note})]},s.id))})]})]}),e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(o,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:t("common.weeklyReview.sectionWins")}),e.jsx("div",{className:"mt-4 grid gap-3",children:i.wins.map(s=>e.jsxs("div",{className:"overflow-hidden rounded-[20px] bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[e.jsx("div",{className:"min-w-0 flex-1 font-medium text-white",children:s.title}),e.jsxs(w,{className:"max-w-[8rem] shrink-0 self-start text-emerald-300",children:["+",s.rewardXp," xp"]})]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:s.summary})]},s.id))})]}),e.jsxs(o,{children:[e.jsx("h2",{className:"font-display text-3xl text-white",children:i.reward.title}),e.jsx("p",{className:"mt-3 text-sm leading-7 text-white/60",children:i.reward.summary}),e.jsxs("div",{className:"mt-4 rounded-[20px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/40",children:t("common.weeklyReview.completionBonus")}),e.jsxs("div",{className:"mt-2 text-3xl text-[var(--primary)]",children:["+",i.reward.rewardXp," XP"]})]}),e.jsx(N,{className:"mt-4 w-full",disabled:i.completion.finalized,pending:d.isPending,pendingLabel:t("common.weeklyReview.finalizePending"),onClick:async()=>{await d.mutateAsync()},children:i.completion.finalized?t("common.weeklyReview.finalized"):t("common.weeklyReview.finalize")}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/58",children:i.completion.finalized?`${t("common.weeklyReview.finalizedDetail")} ${i.completion.finalizedBy?`By ${i.completion.finalizedBy}. `:""}${i.completion.finalizedAt?new Date(i.completion.finalizedAt).toLocaleString():""}`.trim():i.reward.summary})]})]})]}),e.jsx(v,{eyebrow:t("common.weeklyReview.summaryEyebrow"),title:t("common.weeklyReview.summaryTitle"),description:t("common.weeklyReview.summaryDescription"),items:p})]})}export{M as WeeklyReviewPage};
@@ -1 +0,0 @@
1
- import{r as d,j as e,bL as B,dx as ue,bJ as pe,bU as be,aG as je,du as ne,dy as ve,bI as fe,bs as we,dz as Ne,cL as ye}from"./vendor-DHkYh85p.js";import{j as ke,i as Ce,k as u}from"./state-B-4sS1xO.js";import{P as Ge}from"./page-hero-DRy5b2MU.js";import{u as Se,eW as D,eX as Fe,eY as Me,eZ as Le,e_ as Pe,e$ as $e,f0 as Be,f1 as Te,L as Ee,E as Ie,C as h,c as f,T as Ae,I as m,B as p,Z as de,f2 as Ke}from"./index-CF4J4R9L.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";function H(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function v(s){return typeof s=="string"&&s.trim()?s:null}function l(s,r=0){const i=H(s);return i===null?"n/a":i.toFixed(r)}function le(s,r=0){const i=H(s);return i===null?"n/a":`${i>0?"+":""}${i.toFixed(r)}`}function g(s){const r=H(s);return r===null?"n/a":`${r.toFixed(1)}/10`}function Qe(s){return Array.isArray(s)?s.filter(r=>!!r&&typeof r=="object"&&!Array.isArray(r)):[]}function x({label:s,value:r,detail:i,icon:b,tone:o="default"}){const w=o==="green"?"bg-emerald-300/10 text-emerald-100":o==="amber"?"bg-amber-300/10 text-amber-100":o==="rose"?"bg-rose-300/10 text-rose-100":"bg-indigo-300/10 text-indigo-100";return e.jsxs(h,{className:"grid gap-4 border-white/8 bg-white/[0.045] p-5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:de("rounded-2xl p-2.5",w),children:e.jsx(b,{className:"size-5"})}),e.jsx("div",{className:"text-right text-[11px] uppercase tracking-[0.16em] text-white/38",children:s})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-3xl font-semibold text-white",children:r}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-white/58",children:i})]})]})}function oe({meal:s,onLogAgain:r,pending:i=!1}){const b=s.items.slice(0,3).map(o=>o.name).join(", ");return e.jsxs("div",{className:"grid gap-2 rounded-[22px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium text-white",children:s.mealLabel??"Meal"}),e.jsx("div",{className:"truncate text-xs text-white/42",children:b||s.notes||"No items"})]}),e.jsxs(f,{className:"bg-white/[0.08] text-white/70",children:[s.totals.calories.toFixed(0)," kcal"]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-xs text-white/56",children:[e.jsxs("span",{children:[s.totals.proteinGrams.toFixed(0),"g protein"]}),e.jsxs("span",{children:[s.totals.fiberGrams.toFixed(0),"g fiber"]}),e.jsx("span",{children:s.confirmationState})]}),r?e.jsxs(p,{type:"button",size:"sm",variant:"ghost",pending:i,onClick:()=>r(s),children:[e.jsx(ye,{className:"size-4"}),"Log again"]}):null]})}function ce({food:s,onLog:r,pending:i}){return e.jsxs("div",{className:"grid gap-3 rounded-[22px] border border-white/8 bg-white/[0.04] p-4 md:grid-cols-[minmax(0,1fr)_auto] md:items-center",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium text-white",children:s.name}),e.jsx("div",{className:"mt-1 truncate text-xs text-white/44",children:[s.brand,s.servingLabel,s.source].filter(Boolean).join(" · ")}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2 text-xs text-white/56",children:[e.jsxs("span",{children:[l(s.calories)," kcal"]}),e.jsxs("span",{children:[l(s.proteinGrams),"g protein"]}),e.jsxs("span",{children:[l(s.fiberGrams),"g fiber"]}),s.novaGroup?e.jsxs("span",{children:["NOVA ",s.novaGroup]}):null]})]}),e.jsxs(p,{type:"button",size:"sm",variant:"secondary",pending:i,onClick:()=>r(s),children:[e.jsx(B,{className:"size-4"}),"Log"]})]})}function Oe(){var re;const s=Se(),r=ke(),i=s.selectedUserIds,b=d.useMemo(()=>["forge-weight-loss-view",...i],[i]),[o,w]=d.useState(""),[T,E]=d.useState(""),[U,I]=d.useState(""),[A,me]=d.useState(""),[K,ge]=d.useState(""),[k,V]=d.useState(""),[C,O]=d.useState(""),[G,Z]=d.useState(""),[S,J]=d.useState(""),j=Ce({queryKey:b,queryFn:async()=>(await Ke(i)).weightLoss}),N=()=>r.invalidateQueries({queryKey:b}),X=u({mutationFn:async()=>D({mealLabel:"Quick log",source:"manual",confirmationState:"confirmed",notes:o.trim()||null,items:[{name:o.trim()||"Manual food entry",quantity:1,unit:"entry",calories:Number(T)||null,proteinGrams:Number(U)||null,confidence:.55,tags:["quick-log"]}]},i),onSuccess:()=>{w(""),E(""),I(""),N()}}),Y=u({mutationFn:async()=>Fe({text:o,mealLabel:"ChatGPT parsed meal",userIds:i}),onSuccess:()=>{w(""),E(""),I(""),N()}}),Q=u({mutationFn:async()=>(await Me({query:A,userIds:i})).foods}),q=u({mutationFn:async()=>(await Le({barcode:K,userIds:i})).food}),F=u({mutationFn:async t=>D({mealLabel:"Catalog food",source:t.barcode?"barcode":"manual",confirmationState:"confirmed",items:[{name:t.name,brand:t.brand,quantity:1,unit:t.servingLabel??"serving",calories:t.calories,proteinGrams:t.proteinGrams,carbohydrateGrams:t.carbohydrateGrams,fatGrams:t.fatGrams,fiberGrams:t.fiberGrams,sugarGrams:t.sugarGrams,sodiumMg:t.sodiumMg,potassiumMg:t.potassiumMg,caffeineMg:t.caffeineMg,alcoholGrams:t.alcoholGrams,glycemicIndex:t.glycemicIndex,novaGroup:t.novaGroup,tags:t.tags,confidence:.82}]},i),onSuccess:()=>{N()}}),M=u({mutationFn:async t=>D({mealLabel:t.mealLabel??"Saved meal",source:"saved_meal",confirmationState:"confirmed",notes:t.notes,items:t.items.map(a=>({name:a.name,brand:a.brand,quantity:a.quantity,unit:a.unit,calories:a.calories,proteinGrams:a.proteinGrams,carbohydrateGrams:a.carbohydrateGrams,fatGrams:a.fatGrams,fiberGrams:a.fiberGrams,sugarGrams:a.sugarGrams,sodiumMg:a.sodiumMg,potassiumMg:a.potassiumMg,caffeineMg:a.caffeineMg,alcoholGrams:a.alcoholGrams,glycemicIndex:a.glycemicIndex,novaGroup:a.novaGroup,fermented:a.fermented,probiotic:a.probiotic,fodmapLevel:a.fodmapLevel,tags:a.tags,confidence:a.confidence??.85}))},i),onSuccess:()=>{N()}}),ee=u({mutationFn:async()=>{await Promise.all([k.trim()?Pe({weightKg:Number(k)},i):Promise.resolve(),C.trim()?$e({energy:Number(C),timeRelation:"current"},i):Promise.resolve(),G.trim()?Be({bloating:Number(G)},i):Promise.resolve(),S.trim()?Te({aestheticScore:Number(S)},i):Promise.resolve()])},onSuccess:()=>{V(""),O(""),Z(""),J(""),N()}});if(j.isLoading)return e.jsx(Ee,{title:"Loading weight-loss signals",description:"Combining food logs, HealthKit, movement, workouts, body check-ins, subjective state, and gut signals."});if(j.isError||!j.data)return e.jsx(Ie,{error:j.error??new Error("Weight-loss view unavailable"),onRetry:()=>void j.refetch()});const n=j.data,c=n.todayLedger,y=c.totals,_=y.calories,z=c.targetCalories-_,xe=c.targetCalories>0?Math.min(140,Math.max(0,_/c.targetCalories*100)):0,L=n.energyModel,te=n.weightTrend,P=n.foodQuality,W=n.trainingFuel,R=n.subjective,se=n.gut,$=n.dataQuality,ae=Qe(n.hypotheses),he=Q.data??[],ie=q.data??null;return e.jsxs("div",{className:"mx-auto grid w-full max-w-[1500px] gap-5",children:[e.jsx(Ge,{title:"Weight Loss",description:"A Forge-native body composition lab: calories and protein, but also sport fuel, visual look, energy, gut comfort, cravings, and testable food hypotheses.",badge:`${n.summary.loggedMealCount} food logs`}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-4",children:[e.jsx(x,{label:"Today",value:`${_.toFixed(0)} kcal`,detail:`${z.toFixed(0)} kcal remaining against a ${c.targetCalories.toFixed(0)} kcal target.`,icon:B,tone:z>=0?"green":"rose"}),e.jsx(x,{label:"Protein",value:`${y.proteinGrams.toFixed(0)}g`,detail:`${n.target.proteinGramsTarget.toFixed(0)}g target. Forge treats protein as the anchor for dieting without looking flat or under-recovered.`,icon:ue}),e.jsx(x,{label:"Energy gap",value:le(L.estimatedDailyEnergyBalanceKcal),detail:`TDEE estimate ${l(L.estimatedTdeeKcal)} kcal, movement ${l(L.movementCaloriesKcal)} kcal, active burn ${l(L.activeBurnKcal)} kcal.`,icon:pe,tone:"amber"}),e.jsx(x,{label:"Weight trend",value:le(te.sevenDayRateKg,2),detail:`Latest ${l(te.latestWeightKg,1)} kg. Trend uses check-ins, not noisy single weigh-ins.`,icon:be,tone:"green"})]}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.08fr)_minmax(360px,0.92fr)]",children:[e.jsxs(h,{className:"grid gap-5 border-white/8 bg-[radial-gradient(circle_at_top_left,rgba(52,211,153,0.14),transparent_34%),linear-gradient(180deg,rgba(14,21,34,0.98),rgba(8,12,24,0.98))] 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:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Quick capture"}),e.jsx("h2",{className:"mt-1 text-2xl font-semibold text-white",children:"Food, photo description, or rough meal"}),e.jsx("p",{className:"mt-2 max-w-3xl text-sm leading-6 text-white/58",children:"Use natural language for ChatGPT parsing through the `openai-codex` subscription connection, or log manually when you only know rough calories."})]}),e.jsx(f,{className:"bg-emerald-300/10 text-emerald-50",children:"subscription parser"})]}),e.jsx(Ae,{value:o,onChange:t=>w(t.target.value),placeholder:"Example: 3 eggs, two slices of sourdough, Greek yogurt with honey, espresso. Felt sharp for training but a bit bloated later."}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(m,{inputMode:"decimal",value:T,onChange:t=>E(t.target.value),placeholder:"Manual kcal"}),e.jsx(m,{inputMode:"decimal",value:U,onChange:t=>I(t.target.value),placeholder:"Manual protein g"})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs(p,{type:"button",pending:Y.isPending,disabled:!o.trim(),onClick:()=>Y.mutate(),children:[e.jsx(je,{className:"size-4"}),"Parse with ChatGPT"]}),e.jsxs(p,{type:"button",variant:"secondary",pending:X.isPending,disabled:!o.trim()&&!T.trim(),onClick:()=>X.mutate(),children:[e.jsx(B,{className:"size-4"}),"Manual log"]})]}),n.recentMeals.length>0?e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Saved and recent meals"}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:n.recentMeals.slice(0,4).map(t=>e.jsx(oe,{meal:t,pending:M.isPending,onLogAgain:a=>M.mutate(a)},`saved-${t.id}`))})]}):null]}),e.jsxs(h,{className:"grid gap-4 border-white/8 bg-white/[0.045] p-5",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Body state"}),e.jsx("h2",{className:"mt-1 text-xl font-semibold text-white",children:"Check-in loop"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(m,{value:k,inputMode:"decimal",onChange:t=>V(t.target.value),placeholder:"Weight kg"}),e.jsx(m,{value:C,inputMode:"decimal",onChange:t=>O(t.target.value),placeholder:"Energy 0-10"}),e.jsx(m,{value:G,inputMode:"decimal",onChange:t=>Z(t.target.value),placeholder:"Bloating 0-10"}),e.jsx(m,{value:S,inputMode:"decimal",onChange:t=>J(t.target.value),placeholder:"Look 0-10"})]}),e.jsxs(p,{type:"button",variant:"secondary",pending:ee.isPending,disabled:!k.trim()&&!C.trim()&&!G.trim()&&!S.trim(),onClick:()=>ee.mutate(),children:[e.jsx(ne,{className:"size-4"}),"Save check-in"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm text-white/58",children:[e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.04] p-3",children:["Energy avg ",e.jsx("span",{className:"text-white",children:g(R.averageEnergy)})]}),e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.04] p-3",children:["Gut comfort ",e.jsx("span",{className:"text-white",children:g(se.gutComfortScore)})]}),e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.04] p-3",children:["Look avg ",e.jsx("span",{className:"text-white",children:g((re=n.appearanceCheckins[0])==null?void 0:re.aestheticScore)})]}),e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.04] p-3",children:["Cravings ",e.jsx("span",{className:"text-white",children:g(R.averageCravings)})]})]})]})]}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(360px,0.9fr)_minmax(0,1.1fr)]",children:[e.jsxs(h,{className:"grid gap-4 border-white/8 bg-white/[0.045] p-5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Catalog"}),e.jsx("h2",{className:"mt-1 text-xl font-semibold text-white",children:"Food search and barcode"})]}),e.jsx(ve,{className:"size-5 text-white/42"})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-[minmax(0,1fr)_auto]",children:[e.jsx(m,{value:A,onChange:t=>me(t.target.value),placeholder:"Search food database"}),e.jsx(p,{type:"button",variant:"secondary",pending:Q.isPending,disabled:!A.trim(),onClick:()=>Q.mutate(),children:"Search"})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-[minmax(0,1fr)_auto]",children:[e.jsx(m,{value:K,onChange:t=>ge(t.target.value),placeholder:"Barcode"}),e.jsx(p,{type:"button",variant:"secondary",pending:q.isPending,disabled:!K.trim(),onClick:()=>q.mutate(),children:"Lookup"})]}),ie?e.jsx(ce,{food:ie,pending:F.isPending,onLog:t=>F.mutate(t)}):null,e.jsx("div",{className:"grid gap-3",children:he.slice(0,6).map(t=>e.jsx(ce,{food:t,pending:F.isPending,onLog:a=>F.mutate(a)},t.id))})]}),e.jsxs(h,{className:"grid gap-5 border-white/8 bg-white/[0.045] 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:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Today ledger"}),e.jsx("h2",{className:"mt-1 text-xl font-semibold text-white",children:"Calories, macros, and meal evidence"})]}),e.jsxs(f,{className:"bg-white/[0.08] text-white/70",children:[c.meals.length," meals"]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"h-3 overflow-hidden rounded-full bg-white/[0.08]",children:e.jsx("div",{className:de("h-full rounded-full",z>=0?"bg-emerald-300":"bg-rose-300"),style:{width:`${Math.min(100,xe)}%`}})}),e.jsxs("div",{className:"mt-3 grid gap-2 text-sm text-white/58 sm:grid-cols-4",children:[e.jsxs("span",{children:[y.carbohydrateGrams.toFixed(0),"g carbs"]}),e.jsxs("span",{children:[y.fatGrams.toFixed(0),"g fat"]}),e.jsxs("span",{children:[y.fiberGrams.toFixed(0),"g fiber"]}),e.jsxs("span",{children:[c.unconfirmedCount," unconfirmed"]})]})]}),e.jsx("div",{className:"grid gap-3",children:c.meals.length>0?c.meals.map(t=>e.jsx(oe,{meal:t,pending:M.isPending,onLogAgain:a=>M.mutate(a)},t.id)):e.jsx("div",{className:"rounded-[22px] border border-dashed border-white/12 p-5 text-sm text-white/50",children:"No meals logged today yet."})})]})]}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-4",children:[e.jsx(x,{label:"Food quality",value:g(P.qualityScore),detail:`Fiber density ${l(P.fiberPer1000Kcal,1)}g/1000 kcal, protein density ${l(P.proteinPer1000Kcal,1)}g/1000 kcal, ultra-processed share ${l(P.ultraProcessedShare,0)}%.`,icon:B,tone:"green"}),e.jsx(x,{label:"Training fuel",value:g(W.fuelingScore),detail:`Recent workout load ${l(W.recentTrainingLoad)} with ${l(W.carbsPerTrainingLoad,1)}g carbs per load unit.`,icon:fe,tone:"amber"}),e.jsx(x,{label:"Subjective",value:g(R.averageFocus),detail:"Focus, energy, hunger, cravings, and performance are tracked as food-effect evidence, not diary fluff.",icon:ne}),e.jsx(x,{label:"Gut",value:g(se.averageBloating),detail:"Bloating, reflux, stool type, and suspected triggers help Forge connect food choices to comfort and look.",icon:we,tone:"rose"})]}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1fr)_minmax(360px,0.8fr)]",children:[e.jsxs(h,{className:"grid gap-4 border-white/8 bg-white/[0.045] p-5",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Hypotheses"}),e.jsx("h2",{className:"mt-1 text-xl font-semibold text-white",children:"Food and body pattern candidates"})]}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:ae.length>0?ae.slice(0,6).map((t,a)=>e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(f,{className:"bg-indigo-300/10 text-indigo-50",children:v(t.metric)??"pattern"}),e.jsx("span",{className:"text-xs text-white/40",children:l(t.confidence,2)})]}),e.jsx("div",{className:"mt-3 text-sm font-medium text-white",children:v(t.label)??"Candidate pattern"}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-white/56",children:v(t.description)??"Forge needs more paired meals and check-ins to harden this signal."})]},String(t.key??a))):e.jsx("div",{className:"rounded-[22px] border border-dashed border-white/12 p-5 text-sm text-white/50 md:col-span-2",children:"Log meals plus energy, gut, and look check-ins for a few days to generate pattern candidates."})})]}),e.jsxs(h,{className:"grid content-start gap-4 border-white/8 bg-white/[0.045] p-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-2xl bg-cyan-300/10 p-2.5 text-cyan-100",children:e.jsx(Ne,{className:"size-5"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Experiments"}),e.jsx("h2",{className:"text-xl font-semibold text-white",children:"N-of-1 lab"})]})]}),e.jsxs("div",{className:"grid gap-3",children:[n.experiments.slice(0,4).map((t,a)=>e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:v(t.title)??"Nutrition experiment"}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-white/56",children:v(t.hypothesis)??v(t.intervention)??"No hypothesis recorded."})]},String(t.id??a))),n.experiments.length===0?e.jsx("div",{className:"rounded-[22px] border border-dashed border-white/12 p-5 text-sm text-white/50",children:"Start experiments from OpenClaw or the API: caffeine timing, fiber ramp, low-FODMAP trial, carb timing, sodium/puffiness, or pre-training fueling."}):null]})]})]}),e.jsxs(h,{className:"grid gap-4 border-white/8 bg-white/[0.045] 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:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Data quality"}),e.jsx("h2",{className:"mt-1 text-xl font-semibold text-white",children:"Confidence, coverage, and next evidence"})]}),e.jsxs(f,{className:"bg-white/[0.08] text-white/70",children:[n.summary.dataQualityScore.toFixed(0),"% coverage"]})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/36",children:"Source confidence"}),e.jsx("div",{className:"mt-2 text-lg font-semibold text-white",children:$.sourceConfidence}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-white/54",children:"Food parsing stays candidate-based until accepted; wearable burn is treated as a trend input."})]}),e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/36",children:"Missing check-ins"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:$.missingHighValueCheckins.length>0?$.missingHighValueCheckins.map(t=>e.jsx(f,{className:"bg-amber-300/10 text-amber-50",children:t},t)):e.jsx("span",{className:"text-sm text-white/58",children:"Core evidence loop is covered."})})]}),e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/36",children:"Next best cue"}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-white/58",children:$.notes}),e.jsxs("div",{className:"mt-3 text-xs text-white/42",children:[c.unconfirmedCount," unconfirmed candidate",c.unconfirmedCount===1?"":"s"]})]})]})]})]})}export{Oe as WeightLossPage};
@@ -1,4 +0,0 @@
1
- import{j as a,aC as w,r as y}from"./vendor-DHkYh85p.js";import{Z as m,bq as b,cO as j}from"./index-CF4J4R9L.js";function v(s){const e=[];let r,i;for(const n of s){const t=n.trim();if(!t)continue;const o=t.indexOf(":");if(o<=0){e.push({label:"Note",value:t});continue}const c=t.slice(0,o).trim(),h=t.slice(o+1).trim();if(!h)continue;const p=c.toLowerCase();if(p==="title"){r=h;continue}if(p==="summary"){i=h;continue}e.push({label:c,value:h})}return{title:r,summary:i,rows:e}}function N(s){const e=[],r=/(!?\[\[([^\]]+)\]\]|\[([^\]]+)\]\(([^)]+)\)|`([^`]+)`|\*\*([^*]+)\*\*|\*([^*]+)\*)/g;let i=0,n=null;for(;(n=r.exec(s))!==null;){if(n.index>i&&e.push({type:"text",value:s.slice(i,n.index)}),n[1]&&n[2]){const t=n[2].trim(),o=n[1].startsWith("!"),c=t.indexOf("|"),h=c>=0?t.slice(0,c).trim():t,p=c>=0?t.slice(c+1).trim():h;if(h.toLowerCase().startsWith("forge:")){const[,x,...l]=h.split(":");e.push({type:"forge-link",entityType:x??"",entityId:l.join(":").trim(),label:p})}else e.push({type:"wiki-link",target:h,label:p,embed:o})}else n[3]&&n[4]?e.push({type:"link",label:n[3],href:n[4].trim()}):n[5]?e.push({type:"code",value:n[5]}):n[6]?e.push({type:"strong",value:n[6]}):n[7]&&e.push({type:"em",value:n[7]});i=r.lastIndex}return i<s.length&&e.push({type:"text",value:s.slice(i)}),e}function $(s){const e=s.replace(/\r/g,"").split(`
2
- `),r=[],i=[];let n=null,t=0;for(;t<e.length;){const o=e[t]??"",c=o.trim();if(!c){t+=1;continue}if(c.startsWith("```")){const l=[];for(t+=1;t<e.length&&!(e[t]??"").trim().startsWith("```");)l.push(e[t]??""),t+=1;t+=1,r.push({type:"code",code:l.join(`
3
- `)});continue}const h=c.match(/^:::([a-z0-9-]+)\s*$/i);if(h){const l=h[1].toLowerCase(),d=[];for(t+=1;t<e.length&&(e[t]??"").trim()!==":::";)d.push(e[t]??""),t+=1;t<e.length&&(t+=1);const f=[`:::${l}`,...d,":::"].join(`
4
- `);i.push({kind:l,lines:d,raw:f}),l==="forge-infobox"?n=v(d):l==="note"||l==="tip"||l==="warning"||l==="danger"?r.push({type:"admonition",kind:l,lines:d}):(l==="forge-links"||l==="forge-media"||l==="forge-related")&&r.push({type:l,lines:d});continue}const p=o.match(/^(#{1,6})\s+(.*)$/);if(p){r.push({type:"heading",level:p[1].length,text:p[2].trim()}),t+=1;continue}if(/^>\s?/.test(o)){const l=[];for(;t<e.length&&/^>\s?/.test(e[t]??"");)l.push((e[t]??"").replace(/^>\s?/,"")),t+=1;r.push({type:"quote",text:l.join(" ").trim()});continue}if(/^[-*+]\s+/.test(o)||/^\d+\.\s+/.test(o)){const l=/^\d+\.\s+/.test(o),d=[];for(;t<e.length&&(/^[-*+]\s+/.test(e[t]??"")||/^\d+\.\s+/.test(e[t]??""));)d.push((e[t]??"").replace(/^[-*+]\s+/,"").replace(/^\d+\.\s+/,"").trim()),t+=1;r.push({type:"list",ordered:l,items:d});continue}const x=[];for(;t<e.length;){const l=e[t]??"",d=l.trim();if(!d||d.startsWith("```")||d.startsWith(":::")||/^#{1,6}\s+/.test(l)||/^>\s?/.test(l)||/^[-*+]\s+/.test(l)||/^\d+\.\s+/.test(l))break;x.push(d),t+=1}if(x.length>0){r.push({type:"paragraph",text:x.join(" ")});continue}t+=1}return{blocks:r,infobox:n,directives:i}}function L(s,e,r){return s.map((i,n)=>{const t=`${e}-${n}`;switch(i.type){case"text":return a.jsx(y.Fragment,{children:i.value},t);case"code":return a.jsx("code",{className:"rounded bg-black/10 px-1.5 py-0.5 font-mono text-[0.92em] text-white",children:i.value},t);case"strong":return a.jsx("strong",{className:"font-semibold text-white",children:i.value},t);case"em":return a.jsx("em",{className:"italic text-white/82",children:i.value},t);case"link":{const o=/^https?:\/\//i.test(i.href);return a.jsx("a",{href:i.href,target:o?"_blank":void 0,rel:o?"noreferrer":void 0,className:"text-[var(--secondary)] underline decoration-current/30 underline-offset-2 transition hover:text-white",children:i.label},t)}case"forge-link":{const o=b(i.entityType,i.entityId),c=o?j(o):null;return c?a.jsx("a",{href:c,className:"rounded-sm bg-white/[0.08] px-1.5 py-0.5 text-white no-underline ring-1 ring-black/5 transition hover:bg-white/[0.12]",children:i.label},t):a.jsx("span",{className:"rounded-sm bg-white/[0.08] px-1.5 py-0.5 text-white/64",children:i.label},t)}case"wiki-link":return a.jsx(w,{to:{pathname:`/wiki/page/${encodeURIComponent(i.target)}`,search:r?`?spaceId=${encodeURIComponent(r)}`:""},className:m("underline decoration-current/30 underline-offset-2 transition hover:text-white",i.embed?"text-[var(--primary)]":"text-[var(--secondary)]"),children:i.label},t)}})}function u(s,e,r){return L(N(s),e,r)}function W(s,e){const r=s.map(i=>i.trim()).filter(Boolean);return r.length===0?null:a.jsx("ul",{className:"space-y-1.5 pl-4 text-[13px] leading-6 text-white/76",children:r.map((i,n)=>a.jsx("li",{children:u(i,`directive-${n}`,e)},`${i}-${n}`))})}function g(s,e,r){switch(s.type){case"heading":{const i=s.level===1?"text-[1.9rem] leading-[1.08]":s.level===2?"text-[1.25rem] leading-[1.2]":s.level===3?"text-[1.05rem] leading-[1.3]":"text-[0.92rem] leading-[1.35]";return a.jsx("h2",{className:m("font-semibold tracking-[-0.02em] text-white",e>0&&"mt-6",i),children:u(s.text,`heading-${e}`,r)},`heading-${e}`)}case"paragraph":return a.jsx("p",{className:"text-[14px] leading-7 text-white/78",children:u(s.text,`paragraph-${e}`,r)},`paragraph-${e}`);case"quote":return a.jsx("blockquote",{className:"border-l-[3px] border-white/16 pl-4 text-[14px] leading-7 text-white/62",children:u(s.text,`quote-${e}`,r)},`quote-${e}`);case"list":{const i=s.ordered?"ol":"ul";return a.jsx(i,{className:m("space-y-1.5 pl-5 text-[14px] leading-7 text-white/78",s.ordered?"list-decimal":"list-disc"),children:s.items.map((n,t)=>a.jsx("li",{children:u(n,`list-${e}-${t}`,r)},`item-${e}-${t}`))},`list-${e}`)}case"code":return a.jsx("pre",{className:"overflow-x-auto rounded-xl bg-[rgba(10,16,30,0.9)] px-4 py-3 text-[12px] leading-6 text-white ring-1 ring-black/5",children:a.jsx("code",{children:s.code})},`code-${e}`);case"admonition":return a.jsxs("aside",{className:m("rounded-xl border px-4 py-3",s.kind==="warning"||s.kind==="danger"?"border-amber-500/25 bg-amber-500/8":"border-white/12 bg-white/[0.04]"),children:[a.jsx("div",{className:"mb-2 text-[11px] font-semibold uppercase tracking-[0.16em] text-white/48",children:s.kind}),a.jsx("div",{className:"grid gap-2 text-[13px] leading-6 text-white/76",children:s.lines.map((i,n)=>a.jsx("p",{children:u(i,`admonition-${e}-${n}`,r)},`admonition-line-${n}`))})]},`admonition-${e}`);case"forge-links":case"forge-media":case"forge-related":return a.jsxs("section",{className:"rounded-xl border border-white/10 bg-white/[0.03] px-4 py-3",children:[a.jsx("div",{className:"mb-2 text-[11px] font-semibold uppercase tracking-[0.16em] text-white/48",children:s.type.replace("forge-","")}),W(s.lines,r)]},`${s.type}-${e}`)}}function k(s,e,r){return a.jsx("div",{className:"text-[13px] leading-6 text-white/76",children:u(s,e,r)})}function q({infobox:s,spaceId:e,className:r}){return a.jsxs("aside",{className:m("wiki-infobox rounded-2xl border border-white/10 bg-white/[0.03] p-4",r),children:[s.title?a.jsx("div",{className:"text-[1rem] font-semibold leading-tight text-white",children:s.title}):null,s.summary?a.jsx("p",{className:"mt-2 text-[13px] leading-6 text-white/60",children:u(s.summary,"infobox-summary",e)}):null,a.jsx("dl",{className:"mt-3 grid gap-2",children:s.rows.map((i,n)=>a.jsxs("div",{className:"grid gap-1 border-t border-white/10 pt-2 first:border-t-0 first:pt-0",children:[a.jsx("dt",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-white/48",children:i.label}),a.jsx("dd",{children:k(i.value,`infobox-row-${n}`,e)})]},`${i.label}-${n}`))})]})}function C(s){const e=[],r=[];let i=!1;for(const n of s)!i&&n.type==="heading"&&n.level<=2&&e.length>0&&(i=!0),i?r.push(n):e.push(n);return{intro:e.length>0?e:s.slice(0,1),rest:e.length>0?r:s.slice(1)}}function M({markdown:s,spaceId:e,className:r}){const i=$(s),{intro:n,rest:t}=C(i.blocks);return a.jsxs("div",{className:m("grid gap-4",r),children:[a.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1fr)_19rem] xl:items-start",children:[a.jsx("div",{className:"grid gap-4",children:n.map((o,c)=>g(o,c,e))}),i.infobox?a.jsx(q,{infobox:i.infobox,spaceId:e,className:"order-2 xl:order-none"}):null]}),t.length>0?a.jsx("div",{className:"grid gap-4",children:t.map((o,c)=>g(o,c+n.length,e))}):null]})}export{M as W};
@@ -1,26 +0,0 @@
1
- import{aJ as Ee,b5 as Ae,cc as Fe,c2 as Re,r as d,j as e,cw as Be,cx as Qe,bk as qe,bX as Ve,cb as De,aU as _e,aR as Ke,cg as Ue,dE as He,dF as Je,aK as be,bl as Xe}from"./vendor-DHkYh85p.js";import{R as we,P as fe,O as je,C as ke,T as ve,D as ye,a as Ne}from"./ui-C13Nbgas.js";import{j as Ze,i as K,k as Ge}from"./state-B-4sS1xO.js";import{u as Ye,c as u,g as M,fi as et,fj as tt,L as at,E as st,a as it,B as v,I as C,T as L,m as E,aq as me,Z as nt,b_ as rt,fk as lt,fl as ot}from"./index-CF4J4R9L.js";import{W as dt}from"./wiki-article-markdown-DdiR2TJE.js";import"./board-BkDRaMp6.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";function I(s,i){return`${s}:${i}`}function ct(s){const i=s.indexOf(":");return i<=0||i>=s.length-1?null:{entityType:s.slice(0,i),entityId:s.slice(i+1)}}function Ce(s){return s.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function S(s){return Array.from(new Set(s.split(",").map(i=>i.trim()).filter(Boolean)))}function xt(s){if(!s.trim())return{};try{const i=JSON.parse(s);return i&&typeof i=="object"&&!Array.isArray(i)?i:{}}catch{return{}}}function Se(){return{pageId:null,kind:"wiki",title:"",slug:"",parentSlug:"index",indexOrder:0,showInIndex:!0,summary:"",aliasesText:"",contentMarkdown:`# Untitled
2
-
3
- `,author:"",tagsText:"",frontmatterText:`{
4
- "status": "draft"
5
- }`,linkedValues:[]}}function pt(s,i){const g=s.trim()||"Untitled";return{...Se(),title:g,slug:(i==null?void 0:i.trim())||Ce(g),contentMarkdown:`# ${g}
6
-
7
- `}}function ue(s){return{pageId:s.id,kind:s.kind,title:s.title,slug:s.slug,parentSlug:s.parentSlug,indexOrder:s.indexOrder,showInIndex:s.showInIndex,summary:s.summary,aliasesText:s.aliases.join(", "),contentMarkdown:s.contentMarkdown,author:s.author??"",tagsText:(s.tags??[]).join(", "),frontmatterText:JSON.stringify(s.frontmatter??{},null,2),linkedValues:s.links.map(i=>I(i.entityType,i.entityId))}}function T({open:s,title:i,description:g,children:O,onOpenChange:h}){return e.jsx(we,{open:s,onOpenChange:h,children:e.jsxs(fe,{children:[e.jsx(je,{className:"fixed inset-0 z-50 bg-[rgba(3,7,18,0.8)] backdrop-blur-sm"}),e.jsxs(ke,{className:"fixed left-1/2 top-[12vh] z-50 w-[min(32rem,calc(100vw-1.5rem))] -translate-x-1/2 rounded-[24px] border border-white/10 bg-[rgba(10,15,28,0.96)] p-4 shadow-[0_24px_80px_rgba(0,0,0,0.45)] sm:p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"text-[1.05rem] font-semibold text-white",children:i}),e.jsx(ye,{className:"mt-1 text-[13px] leading-6 text-white/56",children:g})]}),e.jsx(Ne,{asChild:!0,children:e.jsx("button",{type:"button",className:"rounded-full border border-white/10 bg-white/[0.04] p-2 text-white/64 transition hover:bg-white/[0.08] hover:text-white","aria-label":"Close",children:e.jsx(be,{className:"size-4"})})})]}),e.jsx("div",{className:"mt-4",children:O})]})]})})}const ht="w-full rounded-[18px] border border-white/10 bg-[rgba(10,16,30,0.78)] px-3.5 py-3 text-[13px] text-white outline-none transition focus:border-[rgba(192,193,255,0.35)]";function ge(s){return s.trim().toLowerCase()}function mt(s){const i=s.trim();return i?i.split(/\s+/).length:0}function ut({icon:s,label:i,onClick:g}){return e.jsxs("div",{className:"group relative",children:[e.jsx("button",{type:"button","aria-label":i,className:"inline-flex size-10 items-center justify-center rounded-[14px] border border-white/8 bg-white/[0.04] text-white/62 transition hover:bg-white/[0.08] hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[rgba(192,193,255,0.35)]",onClick:g,children:e.jsx(s,{className:"size-4"})}),e.jsx("div",{className:"pointer-events-none absolute left-1/2 top-[calc(100%+0.55rem)] z-20 -translate-x-1/2 rounded-[12px] border border-white/8 bg-[rgba(10,15,28,0.96)] px-2.5 py-1.5 text-[11px] font-medium text-white/76 opacity-0 shadow-[0_18px_40px_rgba(0,0,0,0.32)] transition group-hover:opacity-100 group-focus-within:opacity-100",children:i})]})}function gt(s){return s.map(i=>({value:i.label,label:i.label,description:i.description,searchText:`${i.label} ${i.description}`,badge:e.jsx(u,{className:"bg-white/[0.08] text-white/80",style:i.color?{color:i.color}:void 0,children:i.label}),menuBadge:e.jsx(u,{className:"bg-white/[0.08] text-white/80",style:i.color?{color:i.color}:void 0,children:i.label})}))}function St(){var te,ae,se,ie,ne,re,le,oe,de,ce,xe,pe;const s=Ye(),i=Ze(),g=Ee(),O=Ae(),{pageId:h}=Fe(),[P,Te]=Re(),[l,c]=d.useState(()=>Se()),[y,p]=d.useState(null),[A,U]=d.useState(""),[b,W]=d.useState(""),[Ie,F]=d.useState(!1),[R,$e]=d.useState(!1),[B,Q]=d.useState(""),[q,V]=d.useState(""),H=d.useRef(null),J=d.useRef(!1),m=((te=g.state)==null?void 0:te.initialPage)??null,D=((ae=P.get("title"))==null?void 0:ae.trim())??"",X=((se=P.get("slug"))==null?void 0:se.trim())??"",f=K({queryKey:["forge-wiki-settings"],queryFn:rt}),w=K({queryKey:["forge-wiki-page",h],queryFn:()=>lt(h??""),enabled:!!h}),j=P.get("spaceId")||((ie=w.data)==null?void 0:ie.page.spaceId)||(m==null?void 0:m.spaceId)||((re=(ne=f.data)==null?void 0:ne.settings.spaces[0])==null?void 0:re.id)||"",Z=((oe=(le=f.data)==null?void 0:le.settings.spaces.find(t=>t.id===j))==null?void 0:oe.label)??"Current space",k=K({queryKey:["forge-wiki-pages",j],queryFn:()=>ot({spaceId:j||void 0,limit:500}),enabled:!!j});d.useEffect(()=>{m&&(!h||m.id===h)&&c(ue(m))},[h,m]),d.useEffect(()=>{h||m||J.current||!D||(J.current=!0,c(pt(D,X)))},[X,D,h,m]),d.useEffect(()=>{var t;(t=w.data)!=null&&t.page&&c(ue(w.data.page))},[w.data]);const $=d.useMemo(()=>{var t;return(((t=k.data)==null?void 0:t.pages)??[]).filter(a=>a.id!==l.pageId).sort((a,r)=>a.title.localeCompare(r.title))},[l.pageId,(de=k.data)==null?void 0:de.pages]),Me=d.useMemo(()=>{var a;const t=new Map;for(const r of((a=k.data)==null?void 0:a.pages)??[])for(const o of r.aliases??[]){const x=o.trim();x&&t.set(x.toLowerCase(),{value:x,label:x,description:`Alias on ${r.title}`,searchText:`${x} ${r.title} ${r.slug}`,badge:e.jsx(u,{className:"bg-white/[0.08] text-white/80",children:x}),menuBadge:e.jsx(u,{className:"bg-white/[0.08] text-white/80",children:x})})}for(const r of S(l.aliasesText))t.set(r.toLowerCase(),{value:r,label:r,description:"Wiki alias",searchText:r,badge:e.jsx(u,{className:"bg-white/[0.08] text-white/80",children:r}),menuBadge:e.jsx(u,{className:"bg-white/[0.08] text-white/80",children:r})});return Array.from(t.values()).sort((r,o)=>r.label.localeCompare(o.label))},[l.aliasesText,(ce=k.data)==null?void 0:ce.pages]),Le=d.useMemo(()=>[{value:"index",label:"Home",description:"Top-level index page",searchText:"home index top level root"},...$.map(t=>({value:t.slug,label:t.title,description:t.summary||t.slug,searchText:`${t.title} ${t.slug} ${t.summary}`}))],[$]),G=d.useMemo(()=>{const t=ge(B);return t?$.filter(a=>`${a.title} ${a.slug} ${a.summary}`.toLowerCase().includes(t)).slice(0,12):$.slice(0,12)},[B,$]),z=d.useMemo(()=>{const t=s.snapshot.goals.map(n=>({value:I("goal",n.id),label:n.title,description:n.description,searchText:`${n.title} ${n.description}`,kind:M("goal")??void 0})),a=s.snapshot.dashboard.projects.map(n=>({value:I("project",n.id),label:n.title,description:[n.goalTitle,n.description].filter(Boolean).join(" · "),searchText:`${n.title} ${n.goalTitle} ${n.description}`,kind:M("project")??void 0})),r=s.snapshot.tasks.map(n=>({value:I("task",n.id),label:n.title,description:n.owner||n.description,searchText:`${n.title} ${n.owner} ${n.description}`,kind:M("task")??void 0})),o=s.snapshot.strategies.map(n=>({value:I("strategy",n.id),label:n.title,description:n.overview,searchText:`${n.title} ${n.overview} ${n.endStateDescription}`,kind:M("strategy")??void 0})),x=s.snapshot.habits.map(n=>({value:I("habit",n.id),label:n.title,description:n.description,searchText:`${n.title} ${n.description}`,kind:M("habit")??void 0}));return[...t,...a,...r,...o,...x].sort((n,_)=>n.label.localeCompare(_.label))},[s.snapshot.dashboard.projects,s.snapshot.goals,s.snapshot.habits,s.snapshot.strategies,s.snapshot.tasks]),Y=d.useMemo(()=>{const t=ge(q);return t?z.filter(a=>`${a.label} ${a.description??""} ${a.searchText??""}`.toLowerCase().includes(t)).slice(0,12):z.slice(0,12)},[z,q]),Oe=d.useMemo(()=>{const t=s.snapshot.tags.map(o=>({label:o.name,description:`Forge ${o.kind} tag`,color:o.color})),a=S(l.tagsText).map(o=>({label:o,description:"Wiki tag"})),r=new Map;return[...t,...a].forEach(o=>{r.set(o.label.toLowerCase(),o)}),gt(Array.from(r.values()).sort((o,x)=>o.label.localeCompare(x.label)))},[l.tagsText,s.snapshot.tags]);function N(t){const a=H.current;c(r=>{const o=r.contentMarkdown;if(!a)return{...r,contentMarkdown:`${o}${o.endsWith(`
8
- `)?"":`
9
- `}${t}`};const x=a.selectionStart??o.length,n=a.selectionEnd??o.length,_=`${o.slice(0,x)}${t}${o.slice(n)}`;return requestAnimationFrame(()=>{a.focus();const he=x+t.length;a.setSelectionRange(he,he)}),{...r,contentMarkdown:_}})}const ee=Ge({mutationFn:async t=>{const a={kind:t.kind,title:t.title.trim(),slug:t.slug.trim()||Ce(t.title),parentSlug:t.parentSlug&&t.parentSlug!=="none"?t.parentSlug:null,indexOrder:t.indexOrder,showInIndex:t.showInIndex,summary:t.summary.trim(),aliases:S(t.aliasesText),contentMarkdown:t.contentMarkdown.trim(),author:t.author.trim()||null,tags:S(t.tagsText),spaceId:j,frontmatter:xt(t.frontmatterText),links:t.linkedValues.map(r=>ct(r)).filter(r=>r!==null)};return t.pageId?et(t.pageId,a):tt(a)},onSuccess:async t=>{await Promise.all([i.invalidateQueries({queryKey:["forge-wiki-pages"]}),i.invalidateQueries({queryKey:["forge-wiki-page"]}),i.invalidateQueries({queryKey:["forge-wiki-home"]}),i.invalidateQueries({queryKey:["forge-wiki-page-by-slug"]}),i.invalidateQueries({queryKey:["forge-wiki-tree"]})]),O({pathname:t.page.slug==="index"?"/wiki":`/wiki/page/${encodeURIComponent(t.page.slug)}`,search:`?spaceId=${encodeURIComponent(t.page.spaceId)}`})}});if(f.isLoading||h&&w.isLoading&&!m)return e.jsx(at,{eyebrow:"Wiki editor",title:"Preparing the editor",description:"Loading the draft, hierarchy, and link helpers."});if(f.isError||w.isError||k.isError)return e.jsx(st,{eyebrow:"Wiki editor",error:f.error??w.error??k.error,onRetry:()=>{f.refetch(),w.refetch(),k.refetch()}});if(h&&!((xe=w.data)!=null&&xe.page))return e.jsx(it,{eyebrow:"Wiki editor",title:"Page not found",description:"This wiki entry does not exist anymore."});const Pe=[{kind:"wiki-link",icon:De,label:"Wiki link"},{kind:"forge-link",icon:_e,label:"Forge link"},{kind:"infobox",icon:Ke,label:"Infobox"},{kind:"admonition",icon:Ue,label:"Admonition"},{kind:"related",icon:He,label:"Related"},{kind:"media",icon:Je,label:"Media"}],We=mt(l.contentMarkdown),ze=l.contentMarkdown.length;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 py-4 sm:px-5 lg:px-6",children:e.jsxs("div",{className:"mx-auto flex w-full max-w-[1720px] flex-col gap-4",children:[e.jsx("section",{className:"wiki-frame px-4 py-3 sm:px-5",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-white/42",children:"Wiki editor"}),e.jsx("h1",{className:"mt-1 text-[1.25rem] font-semibold tracking-[-0.04em] text-white",children:l.pageId?"Edit page":"New page"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(v,{variant:"secondary",size:"sm",className:"xl:hidden",onClick:()=>$e(t=>!t),"aria-expanded":R,children:[R?e.jsx(Be,{className:"size-3.5"}):e.jsx(Qe,{className:"size-3.5"}),"Metadata"]}),e.jsxs(v,{variant:"secondary",size:"sm",onClick:()=>O(-1),children:[e.jsx(qe,{className:"size-3.5"}),"Back"]}),e.jsxs(v,{size:"sm",pending:ee.isPending,pendingLabel:"Saving",disabled:!l.title.trim()||!l.contentMarkdown.trim(),onClick:()=>void ee.mutateAsync(l),children:[e.jsx(Ve,{className:"size-3.5"}),"Save page"]})]})]})}),e.jsxs("section",{className:"grid min-w-0 gap-4 xl:grid-cols-[minmax(19rem,23rem)_minmax(0,1fr)] xl:items-start",children:[e.jsx("aside",{className:nt("order-2 min-w-0 xl:order-1 xl:block",R?"block":"hidden"),children:e.jsxs("section",{className:"wiki-frame px-4 py-4 sm:px-5 xl:sticky xl:top-[5.75rem]",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3 border-b border-white/8 pb-3",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-white/42",children:"Metadata"}),e.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-white/34",children:Z})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("label",{className:"grid gap-1.5",children:[e.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Wiki space"}),e.jsxs("button",{type:"button",className:"flex min-h-[2.9rem] items-center justify-between gap-3 rounded-[18px] border border-white/8 bg-white/[0.04] px-3.5 text-[13px] text-white/82 transition hover:bg-white/[0.06] hover:text-white",onClick:()=>F(!0),children:[e.jsx("span",{className:"truncate",children:Z}),e.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Change"})]})]}),e.jsxs("label",{className:"grid gap-1.5",children:[e.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Title"}),e.jsx(C,{value:l.title,onChange:t=>c(a=>({...a,title:t.target.value})),placeholder:"Page title"})]}),e.jsxs("label",{className:"grid gap-1.5",children:[e.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Slug"}),e.jsx(C,{value:l.slug,onChange:t=>c(a=>({...a,slug:t.target.value})),placeholder:"page-slug"})]}),e.jsxs("label",{className:"grid gap-1.5",children:[e.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Summary"}),e.jsx(L,{value:l.summary,onChange:t=>c(a=>({...a,summary:t.target.value})),rows:4,placeholder:"Short summary"})]}),e.jsxs("label",{className:"grid gap-1.5",children:[e.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Tags"}),e.jsx(E,{options:Oe,selectedValues:S(l.tagsText),onChange:t=>c(a=>({...a,tagsText:t.join(", ")})),placeholder:"Search or add tags",emptyMessage:"No tags yet.",createLabel:"Add tag",onCreate:async t=>{const a=t.trim();return{value:a,label:a,description:"Wiki tag",searchText:a,badge:e.jsx(u,{className:"bg-white/[0.08] text-white/80",children:a}),menuBadge:e.jsx(u,{className:"bg-white/[0.08] text-white/80",children:a})}}})]}),e.jsxs("label",{className:"grid gap-1.5",children:[e.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Forge entities"}),e.jsx(E,{options:z,selectedValues:l.linkedValues,onChange:t=>c(a=>({...a,linkedValues:t})),placeholder:"Search Forge entities"})]}),e.jsxs("label",{className:"grid gap-1.5",children:[e.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Aliases"}),e.jsx(E,{options:Me,selectedValues:S(l.aliasesText),onChange:t=>c(a=>({...a,aliasesText:t.join(", ")})),placeholder:"Search or add aliases",emptyMessage:"No aliases yet.",createLabel:"Add alias",onCreate:async t=>{const a=t.trim();return{value:a,label:a,description:"Wiki alias",searchText:a,badge:e.jsx(u,{className:"bg-white/[0.08] text-white/80",children:a}),menuBadge:e.jsx(u,{className:"bg-white/[0.08] text-white/80",children:a})}}})]}),e.jsxs("label",{className:"grid gap-1.5",children:[e.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Author"}),e.jsx(C,{value:l.author,onChange:t=>c(a=>({...a,author:t.target.value})),placeholder:"Optional author"})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("label",{className:"grid gap-1.5",children:[e.jsxs("span",{className:"flex items-center gap-2 text-[11px] uppercase tracking-[0.16em] text-white/42",children:[e.jsx("span",{children:"Parent"}),e.jsx(me,{content:"Choose the page that should own this page in the wiki tree.",label:"Explain parent page"})]}),e.jsx(E,{options:Le,selectedValues:l.parentSlug?[l.parentSlug]:[],onChange:t=>c(a=>({...a,parentSlug:t[0]??null})),placeholder:"Search parent page",emptyMessage:"No matching pages.",className:"[&_.max-w-\\\\[16rem\\\\]]:max-w-full"})]}),e.jsxs("label",{className:"grid gap-1.5",children:[e.jsxs("span",{className:"flex items-center gap-2 text-[11px] uppercase tracking-[0.16em] text-white/42",children:[e.jsx("span",{children:"Order"}),e.jsx(me,{content:"Lower numbers appear earlier within the same parent page.",label:"Explain page order"})]}),e.jsx(C,{type:"number",value:String(l.indexOrder),onChange:t=>c(a=>({...a,indexOrder:Number(t.target.value||0)}))})]})]}),e.jsxs("label",{className:"flex items-start gap-3 rounded-[18px] border border-white/8 bg-white/[0.03] px-3.5 py-3 text-[13px] text-white/74",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5",checked:l.showInIndex,onChange:t=>c(a=>({...a,showInIndex:t.target.checked}))}),e.jsx("span",{children:"Show in index"})]})]})]})}),e.jsxs("div",{className:"order-1 grid min-w-0 gap-4 xl:order-2",children:[e.jsxs("section",{className:"wiki-frame overflow-hidden",children:[e.jsxs("div",{className:"flex min-h-12 w-full flex-wrap items-center justify-between gap-3 border-b border-white/8 bg-[rgba(10,16,30,0.5)] px-3 py-2 sm:px-4",children:[e.jsx("div",{className:"flex min-w-0 flex-wrap items-center justify-start gap-1.5",children:Pe.map(t=>e.jsx(ut,{icon:t.icon,label:t.label,onClick:()=>{p(t.kind),U(""),W(""),Q(""),V("")}},t.kind))}),e.jsx("div",{className:"ml-auto flex min-w-0 flex-wrap items-center justify-end gap-3 pr-1",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-[11px] uppercase tracking-[0.14em] text-white/36",children:[e.jsxs("span",{children:[We.toLocaleString()," words"]}),e.jsxs("span",{children:[ze.toLocaleString()," chars"]})]})})]}),e.jsx("div",{className:"bg-[linear-gradient(180deg,rgba(8,13,24,0.98),rgba(9,14,26,0.94))]",children:e.jsx(L,{ref:H,value:l.contentMarkdown,onChange:t=>c(a=>({...a,contentMarkdown:t.target.value})),rows:26,className:"min-h-[38rem] resize-y rounded-none border-0 bg-transparent px-5 py-4 font-mono text-[13px] leading-6 text-white shadow-none outline-none focus-visible:ring-0 sm:min-h-[44rem] sm:px-6",placeholder:"Write the page in Markdown"})})]}),e.jsxs("section",{className:"wiki-frame overflow-hidden",children:[e.jsx("div",{className:"border-b border-white/8 px-4 py-3 sm:px-6",children:e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-white/42",children:"Preview"})}),e.jsx("div",{className:"px-4 py-5 sm:px-6",children:e.jsx("div",{className:"wiki-reading-copy wiki-reading-flow mx-auto max-w-[76rem]",children:e.jsx(dt,{markdown:l.contentMarkdown,spaceId:j})})})]})]})]})]})}),e.jsx(T,{open:y==="wiki-link",onOpenChange:t=>!t&&p(null),title:"Insert wiki link",description:"Search pages.",children:e.jsxs("div",{className:"grid gap-3",children:[e.jsx(C,{autoFocus:!0,value:B,onChange:t=>Q(t.target.value),placeholder:"Search wiki pages",className:"h-11 rounded-2xl border-white/10 bg-white/[0.04] text-[14px] text-white placeholder:text-white/28"}),e.jsx("div",{className:"grid max-h-[22rem] gap-2 overflow-y-auto",children:G.length>0?G.map(t=>e.jsxs("button",{type:"button",className:"rounded-[18px] border border-white/8 bg-white/[0.03] px-4 py-3 text-left transition hover:bg-white/[0.06]",onClick:()=>{N(`[[${t.slug}]]`),p(null),Q("")},children:[e.jsx("div",{className:"text-[14px] font-semibold text-white",children:t.title}),e.jsx("div",{className:"mt-1 text-[12px] leading-5 text-white/46",children:t.slug}),t.summary?e.jsx("div",{className:"mt-1 text-[12px] leading-5 text-white/56",children:t.summary}):null]},t.id)):e.jsx("div",{className:"rounded-[18px] border border-dashed border-white/10 px-4 py-8 text-center text-[13px] text-white/42",children:"No pages match this search."})})]})}),e.jsx(T,{open:y==="forge-link",onOpenChange:t=>!t&&p(null),title:"Insert Forge link",description:"Search Forge entities.",children:e.jsxs("div",{className:"grid gap-3",children:[e.jsx(C,{autoFocus:!0,value:q,onChange:t=>V(t.target.value),placeholder:"Search Forge entities",className:"h-11 rounded-2xl border-white/10 bg-white/[0.04] text-[14px] text-white placeholder:text-white/28"}),e.jsx("div",{className:"grid max-h-[22rem] gap-2 overflow-y-auto",children:Y.length>0?Y.map(t=>e.jsxs("button",{type:"button",className:"rounded-[18px] border border-white/8 bg-white/[0.03] px-4 py-3 text-left transition hover:bg-white/[0.06]",onClick:()=>{const[a,r]=t.value.split(":");N(`[[forge:${a}:${r}]]`),p(null),V("")},children:[e.jsx("div",{className:"text-[14px] font-semibold text-white",children:t.label}),t.description?e.jsx("div",{className:"mt-1 text-[12px] leading-5 text-white/56",children:t.description}):null]},t.value)):e.jsx("div",{className:"rounded-[18px] border border-dashed border-white/10 px-4 py-8 text-center text-[13px] text-white/42",children:"No entities match this search."})})]})}),e.jsx(T,{open:y==="infobox",onOpenChange:t=>!t&&p(null),title:"Insert infobox",description:"Create the article metadata box rendered beside the intro.",children:e.jsx("div",{className:"grid gap-3",children:e.jsx(v,{onClick:()=>{N(`:::forge-infobox
10
- Title: ${l.title||"Article title"}
11
- Summary: ${l.summary||"Short summary"}
12
- Tags: ${l.tagsText||"tag-one, tag-two"}
13
- Related: [[index|Home]]
14
- :::
15
- `),p(null)},children:"Insert infobox"})})}),e.jsx(T,{open:y==="admonition",onOpenChange:t=>!t&&p(null),title:"Insert admonition",description:"Add a callout block inside the article.",children:e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("select",{className:ht,value:A,onChange:t=>U(t.target.value),children:[e.jsx("option",{value:"",children:"Select type"}),e.jsx("option",{value:"note",children:"Note"}),e.jsx("option",{value:"tip",children:"Tip"}),e.jsx("option",{value:"warning",children:"Warning"}),e.jsx("option",{value:"danger",children:"Danger"})]}),e.jsx(L,{value:b,onChange:t=>W(t.target.value),rows:4,placeholder:"Admonition text"}),e.jsx(v,{disabled:!A||!b.trim(),onClick:()=>{N(`:::${A}
16
- ${b.trim()}
17
- :::
18
- `),p(null)},children:"Insert admonition"})]})}),e.jsx(T,{open:y==="related",onOpenChange:t=>!t&&p(null),title:"Insert related block",description:"Add an explicit related-pages block.",children:e.jsxs("div",{className:"grid gap-3",children:[e.jsx(L,{value:b,onChange:t=>W(t.target.value),rows:5,placeholder:`[[page-one]]
19
- [[page-two|Readable label]]`}),e.jsx(v,{disabled:!b.trim(),onClick:()=>{N(`:::forge-related
20
- ${b.trim()}
21
- :::
22
- `),p(null)},children:"Insert related block"})]})}),e.jsx(T,{open:y==="media",onOpenChange:t=>!t&&p(null),title:"Insert media block",description:"Reference media or assets in a structured block.",children:e.jsxs("div",{className:"grid gap-3",children:[e.jsx(L,{value:b,onChange:t=>W(t.target.value),rows:5,placeholder:`Image: /path/to/file.png
23
- Caption: Inspiration frame`}),e.jsx(v,{disabled:!b.trim(),onClick:()=>{N(`:::forge-media
24
- ${b.trim()}
25
- :::
26
- `),p(null)},children:"Insert media block"})]})}),e.jsx(we,{open:Ie,onOpenChange:F,children:e.jsxs(fe,{children:[e.jsx(je,{className:"fixed inset-0 z-50 bg-[rgba(3,7,18,0.72)] backdrop-blur-sm"}),e.jsxs(ke,{className:"fixed left-1/2 top-[14vh] z-50 w-[min(28rem,calc(100vw-1.5rem))] -translate-x-1/2 rounded-[28px] border border-white/10 bg-[rgba(10,15,28,0.97)] p-4 shadow-[0_32px_90px_rgba(0,0,0,0.45)] sm:p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(ve,{className:"font-display text-[1.2rem] tracking-[-0.04em] text-white",children:"Choose wiki space"}),e.jsx(ye,{className:"mt-1 text-[13px] leading-6 text-white/56",children:"Save this page into a different wiki space."})]}),e.jsx(Ne,{asChild:!0,children:e.jsx("button",{type:"button",className:"rounded-full border border-white/10 bg-white/[0.04] p-2 text-white/64 transition hover:bg-white/[0.08] hover:text-white","aria-label":"Close space picker",children:e.jsx(be,{className:"size-4"})})})]}),e.jsx("div",{className:"mt-4 grid gap-2",children:(pe=f.data)==null?void 0:pe.settings.spaces.map(t=>{const a=t.id===j;return e.jsxs("button",{type:"button",className:a?"flex items-center justify-between gap-3 rounded-[22px] border border-[rgba(192,193,255,0.22)] bg-[rgba(192,193,255,0.12)] px-4 py-3 text-left text-white transition":"flex items-center justify-between gap-3 rounded-[22px] border border-white/8 bg-white/[0.03] px-4 py-3 text-left text-white/78 transition hover:bg-white/[0.06] hover:text-white",onClick:()=>{const r=new URLSearchParams(P);r.set("spaceId",t.id),Te(r,{replace:!0}),F(!1)},children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-[14px] font-semibold",children:t.label}),e.jsx("span",{className:"mt-1 block text-[12px] leading-5 text-white/52",children:t.description||`/${t.slug}`})]}),a?e.jsx(Xe,{className:"size-4 shrink-0 text-[var(--primary)]"}):null]},t.id)})})]})]})})]})}export{St as WikiEditorPage};
@@ -1 +0,0 @@
1
- import{b5 as F,c2 as J,r as R,j as s,aG as D,c7 as E,b7 as Q}from"./vendor-DHkYh85p.js";import{j as H,i as q,k as z}from"./state-B-4sS1xO.js";import{W as A}from"./wiki-ingest-modal--ohzFnj2.js";import{P as _}from"./page-hero-DRy5b2MU.js";import{fd as U,S as O,E as B,C as W,B as b,I as v,Z as G,a as $,b_ as Y,fh as Z}from"./index-CF4J4R9L.js";import"./ui-C13Nbgas.js";import"./board-BkDRaMp6.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";const V=[{value:"all",label:"All"},{value:"queued",label:"Queued"},{value:"processing",label:"Processing"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"},{value:"review",label:"Review"},{value:"reviewed",label:"Reviewed"}];function X(n){return new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(new Date(n))}function ee(n,o){return o==="all"?!0:n.job.status===o||n.job.phase===o}function me(){var k,y,S,C,I,P;const n=F(),o=H(),[i,m]=J(),c=i.get("spaceId")||"",j=i.get("q")||"",f=i.get("tag")||"all",g=i.get("from")||"",u=i.get("to")||"",K=i.get("ingest")==="1",N=i.get("ingestJobId"),r=q({queryKey:["forge-wiki-settings"],queryFn:Y}),d=q({queryKey:["forge-wiki-ingest-history",c],queryFn:()=>Z({spaceId:c||void 0,limit:200}),enabled:r.isSuccess}),x=z({mutationFn:e=>U(e),onSuccess:async(e,t)=>{if(await o.invalidateQueries({queryKey:["forge-wiki-ingest-history"]}),await o.invalidateQueries({queryKey:["forge-wiki-ingest-jobs"]}),N===t){const a=new URLSearchParams(i);a.delete("ingest"),a.delete("ingestJobId"),m(a,{replace:!0})}}}),p=(e,t)=>{const a=new URLSearchParams(i);t.trim()?a.set(e,t.trim()):a.delete(e),m(a,{replace:!0})},w=R.useMemo(()=>{var a;const e=((a=d.data)==null?void 0:a.jobs)??[],t=j.trim().toLowerCase();return e.filter(l=>{if(!ee(l,f))return!1;const L=l.job.createdAt.slice(0,10);return g&&L<g||u&&L>u?!1:t?[l.job.titleHint,l.job.latestMessage,l.job.sourceLocator,l.job.status,l.job.phase,l.job.mimeType].join(" ").toLowerCase().includes(t):!0})},[g,(k=d.data)==null?void 0:k.jobs,j,f,u]),M=c||((S=(y=r.data)==null?void 0:y.settings.spaces[0])==null?void 0:S.id)||"",h=e=>{const t=new URLSearchParams(i);t.set("ingest","1"),e?t.set("ingestJobId",e):t.delete("ingestJobId"),m(t,{replace:!0})},T=()=>{const e=new URLSearchParams(i);e.delete("ingest"),e.delete("ingestJobId"),m(e,{replace:!0})};return r.isLoading||d.isLoading?s.jsx(O,{eyebrow:"KarpaWiki",title:"Loading ingest history",description:"Gathering prior imports, statuses, and review state.",columns:1,blocks:6}):r.isError||d.isError?s.jsx(B,{eyebrow:"KarpaWiki",error:r.error??d.error,onRetry:()=>{r.refetch(),d.refetch()}}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-3 py-4 sm:px-5 lg:px-6",children:s.jsxs("div",{className:"mx-auto grid w-full max-w-[1480px] gap-5",children:[s.jsx(_,{title:"KarpaWiki Ingest History",description:"Search prior ingests, reopen a review, or clear ingest records without touching pages and entities that were already published.",badge:`${w.length} matching jobs`}),s.jsxs(W,{className:"grid gap-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"History Filters"}),s.jsx("div",{className:"mt-2 text-sm text-white/58",children:"Narrow by free text, date range, space, or status tags."})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsx(b,{variant:"secondary",onClick:()=>n(`/wiki${c?`?spaceId=${encodeURIComponent(c)}`:""}`),children:"Back to KarpaWiki"}),s.jsxs(b,{onClick:()=>h(),children:[s.jsx(D,{className:"size-3.5"}),"New ingest"]})]})]}),s.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1.4fr)_minmax(0,0.8fr)_minmax(0,0.8fr)_minmax(0,0.8fr)]",children:[s.jsxs("label",{className:"grid gap-2",children:[s.jsx("span",{className:"text-sm text-white/58",children:"Free text"}),s.jsx(v,{value:j,onChange:e=>p("q",e.target.value),placeholder:"title, source, status, failure message…"})]}),s.jsxs("label",{className:"grid gap-2",children:[s.jsx("span",{className:"text-sm text-white/58",children:"From"}),s.jsx(v,{type:"date",value:g,onChange:e=>p("from",e.target.value)})]}),s.jsxs("label",{className:"grid gap-2",children:[s.jsx("span",{className:"text-sm text-white/58",children:"To"}),s.jsx(v,{type:"date",value:u,onChange:e=>p("to",e.target.value)})]}),s.jsxs("label",{className:"grid gap-2",children:[s.jsx("span",{className:"text-sm text-white/58",children:"Space"}),s.jsxs("select",{className:"h-11 rounded-[18px] border border-white/10 bg-white/[0.04] px-3 text-sm text-white",value:c,onChange:e=>p("spaceId",e.target.value),children:[s.jsx("option",{value:"",children:"All spaces"}),(((C=r.data)==null?void 0:C.settings.spaces)??[]).map(e=>s.jsx("option",{value:e.id,children:e.label},e.id))]})]})]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:V.map(e=>s.jsx("button",{type:"button",className:G("rounded-full px-3 py-2 text-xs font-semibold uppercase tracking-[0.14em] transition",f===e.value?"bg-[var(--primary)]/[0.18] text-[var(--primary)]":"bg-white/[0.04] text-white/58 hover:bg-white/[0.08] hover:text-white"),onClick:()=>p("tag",e.value==="all"?"":e.value),children:e.label},e.value))})]}),w.length===0?s.jsx($,{eyebrow:"KarpaWiki ingest",title:"No ingest jobs match these filters",description:"Try widening the dates or clearing a status tag."}):s.jsx("div",{className:"grid gap-3",children:w.map(e=>{const t=e.job.titleHint||e.job.latestMessage||e.job.sourceLocator||"KarpaWiki ingest",a=!["queued","processing"].includes(e.job.status);return s.jsxs(W,{className:"grid gap-4",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("button",{type:"button",className:"min-w-0 flex-1 text-left",onClick:()=>h(e.job.id),children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"KarpaWiki ingest"}),s.jsx("span",{className:"rounded-full border border-white/10 bg-white/[0.04] px-2.5 py-1 text-[10px] uppercase tracking-[0.16em] text-white/60",children:e.job.status}),s.jsx("span",{className:"rounded-full border border-white/10 bg-white/[0.04] px-2.5 py-1 text-[10px] uppercase tracking-[0.16em] text-white/44",children:e.job.phase})]}),s.jsx("div",{className:"mt-3 text-lg font-semibold text-white",children:t}),s.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-sm text-white/56",children:[s.jsxs("span",{children:[e.job.progressPercent,"% · ",e.job.createdPageCount," pages ·"," ",e.job.createdEntityCount," entities"]}),s.jsx("span",{children:X(e.job.createdAt)}),e.job.sourceLocator?s.jsx("span",{className:"truncate",children:e.job.sourceLocator}):null]})]}),s.jsxs("div",{className:"flex shrink-0 flex-wrap gap-2",children:[s.jsx(b,{variant:"secondary",size:"sm",onClick:()=>h(e.job.id),children:"Open review"}),s.jsxs(b,{variant:"secondary",size:"sm",disabled:!a||x.isPending,pending:x.isPending&&x.variables===e.job.id,pendingLabel:"Deleting",onClick:()=>{!a||!window.confirm("Delete this ingest history entry? Published pages and entities will stay, but discarded or unreviewed ingest artifacts will be removed.")||x.mutateAsync(e.job.id)},children:[s.jsx(E,{className:"size-3.5"}),"Delete"]})]})]}),e.job.errorMessage?s.jsx("div",{className:"rounded-[18px] border border-rose-400/18 bg-rose-500/[0.08] px-4 py-3 text-sm text-rose-100/86",children:e.job.errorMessage}):null,["queued","processing"].includes(e.job.status)?s.jsxs("div",{className:"inline-flex items-center gap-2 text-sm text-white/50",children:[s.jsx(Q,{className:"size-4 animate-spin"}),"This ingest is still active and cannot be deleted yet."]}):null]},e.job.id)})})]})}),s.jsx(A,{open:K,onOpenChange:e=>{e||T()},spaces:((I=r.data)==null?void 0:I.settings.spaces)??[],llmProfiles:((P=r.data)==null?void 0:P.settings.llmProfiles)??[],initialSpaceId:M,selectedJobId:N,onJobSelected:e=>h(e)})]})}export{me as WikiIngestHistoryPage};
@@ -1 +0,0 @@
1
- import{b5 as Ce,r as p,j as e,aK as ee,dA as Y,dB as Se,aN as _e,dC as Ae,cg as Pe,aG as U,dD as ue,b7 as Ke,b3 as ge}from"./vendor-DHkYh85p.js";import{R as Fe,P as Me,O as Le,C as qe,T as ze,D as $e,a as Qe}from"./ui-C13Nbgas.js";import{j as De,i as te,k as q}from"./state-B-4sS1xO.js";import{f8 as Re,f9 as We,fa as he,fb as Ue,fc as Oe,fd as Be,Z as y,I as be,T as He,B as C,b as X,c as J,g as Ve,fe as Ze,ff as Ge,fg as Ye}from"./index-CF4J4R9L.js";const L=new Set(["queued","processing"]),we=15e3,Xe=["goal","project","task","habit","strategy","psyche_value","flashcard","note"];function fe(s){return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(s))}function S(s,i){const r=s[i];return typeof r=="number"&&Number.isFinite(r)?r:null}function f(s,i){const r=s[i];return typeof r=="string"&&r.trim().length>0?r:null}function Je(s,i){const r=f(s.metadata,"currentFileName")??f(s.metadata,"fileName")??"current source",b=f(s.metadata,"status")??"in_progress",d=S(s.metadata,"chunkIndex"),x=S(s.metadata,"chunkCount"),j=S(s.metadata,"currentFileIndex"),h=S(s.metadata,"currentFileTotal"),v=j!==null&&h!==null?`${r} (${j}/${h})`:r,c=d!==null&&x!==null&&x>1?` · chunk ${d}/${x}`:"";return`Waiting for OpenAI on ${v}${c}. ${i} polls · ${b}.`}function et(s){const i=[];for(const r of s){const b=f(r.metadata,"scope"),x=f(r.metadata,"eventKey")==="llm_compile_background_polled",j=f(r.metadata,"currentFileName")??f(r.metadata,"fileName"),h=S(r.metadata,"chunkIndex"),v=S(r.metadata,"chunkCount"),c=x?["poll",b??"",j??"",h??"",v??""].join(":"):null,m=i[i.length-1],_=m&&f(m.metadata,"eventKey"),N=m&&(f(m.metadata,"currentFileName")??f(m.metadata,"fileName")),k=m&&S(m.metadata,"chunkIndex"),w=m&&S(m.metadata,"chunkCount"),A=m&&_==="llm_compile_background_polled"?["poll",f(m.metadata,"scope")??"",N??"",k??"",w??""].join(":"):null;if(x&&m&&A===c){i[i.length-1]={...r,repetitionCount:m.repetitionCount+1,metadata:{...r.metadata,aggregatedPollCount:m.repetitionCount+1}};continue}i.push({...r,repetitionCount:1})}return i}function O(s){return Ve(s)}function ye(s){return typeof s=="string"&&Xe.includes(s)}function tt(s,i){return typeof i.title=="string"&&i.title.trim().length>0?i.title:typeof i.displayName=="string"&&i.displayName.trim().length>0?i.displayName:typeof i.statement=="string"&&i.statement.trim().length>0?i.statement:`${s}:${String(i.id??"")}`}function it(s,i){const b=[i.description,i.summary,i.overview,i.valuedDirection,i.whyItMatters,i.originNote].find(d=>typeof d=="string"&&d.trim().length>0);return b||(s==="note"&&typeof i.kind=="string"?i.kind:"")}function st({candidate:s,decision:i,onDecisionChange:r,spaceId:b}){const d=ye(s.payload.entityType)?s.payload.entityType:null,[x,j]=p.useState(i.mappedEntityLabel||s.title||""),[h,v]=p.useState(i.targetNoteLabel||s.title||""),c=typeof s.payload.contentMarkdown=="string"?s.payload.contentMarkdown:typeof s.payload.patchSummary=="string"?s.payload.patchSummary:typeof s.payload.rationale=="string"?s.payload.rationale:s.summary,m=te({queryKey:["forge-wiki-ingest-map-search",d,x.trim()],enabled:s.candidateType==="entity"&&i.action==="map_existing"&&d!==null&&x.trim().length>0,queryFn:async()=>{var F;const g=(await Ze({searches:[{entityTypes:d?[d]:void 0,query:x.trim(),limit:8}]})).results[0];return((F=g==null?void 0:g.matches)==null?void 0:F.filter(u=>!!(u&&ye(u.entityType)&&typeof u.id=="string"&&u.entity&&typeof u.entity=="object")).map(u=>({entityType:u.entityType,entityId:u.id,label:tt(u.entityType,u.entity),description:it(u.entityType,u.entity),kind:O(u.entityType)})))??[]}}),_=m.data??[],N=te({queryKey:["forge-wiki-ingest-merge-search",b,h.trim()],enabled:s.candidateType==="page"&&i.action==="merge_existing"&&h.trim().length>0,queryFn:async()=>(await Ge({spaceId:b,kind:"wiki",mode:"text",query:h.trim(),limit:8})).results.map(g=>({noteId:g.page.id,title:g.page.title,slug:g.page.slug,summary:g.page.summary}))}),k=N.data??[],w=i.mappedEntityId&&i.mappedEntityType?_.find(a=>a.entityId===i.mappedEntityId&&a.entityType===i.mappedEntityType)??(i.mappedEntityLabel?{entityId:i.mappedEntityId,entityType:i.mappedEntityType,label:i.mappedEntityLabel,kind:O(i.mappedEntityType)}:null):null,A=i.targetNoteId?k.find(a=>a.noteId===i.targetNoteId)??(i.targetNoteLabel?{noteId:i.targetNoteId,title:i.targetNoteLabel}:null):null;return e.jsxs("div",{className:"rounded-[24px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:s.candidateType.replaceAll("_"," ")}),e.jsx("div",{className:"mt-2 text-base font-semibold text-white",children:s.title||s.targetKey||"Untitled candidate"}),d?e.jsx("div",{className:"mt-2",children:O(d)?e.jsx(X,{kind:O(d),label:d.replaceAll("_"," "),compact:!0,gradient:!1}):e.jsx(J,{className:"bg-white/[0.08] text-white/72",children:d.replaceAll("_"," ")})}):null,s.summary?e.jsx("div",{className:"mt-1 text-sm leading-6 text-white/58",children:s.summary}):null]}),e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-white/10 bg-white/[0.03] p-1",children:[e.jsx("button",{type:"button",className:y("rounded-full px-3 py-1.5 text-xs font-medium transition",i.action==="keep"?"bg-[rgba(192,193,255,0.2)] text-white":"text-white/54 hover:text-white"),onClick:()=>r({...i,action:"keep"}),children:"Keep"}),s.candidateType==="entity"&&d?e.jsx("button",{type:"button",className:y("rounded-full px-3 py-1.5 text-xs font-medium transition",i.action==="map_existing"?"bg-[rgba(133,222,255,0.18)] text-white":"text-white/54 hover:text-white"),onClick:()=>r({...i,action:"map_existing",mappedEntityType:d}),children:"Map existing"}):null,s.candidateType==="page"?e.jsx("button",{type:"button",className:y("rounded-full px-3 py-1.5 text-xs font-medium transition",i.action==="merge_existing"?"bg-[rgba(133,222,255,0.18)] text-white":"text-white/54 hover:text-white"),onClick:()=>r({...i,action:"merge_existing"}),children:"Merge existing"}):null,e.jsx("button",{type:"button",className:y("rounded-full px-3 py-1.5 text-xs font-medium transition",i.action==="discard"?"bg-[rgba(255,255,255,0.12)] text-white":"text-white/54 hover:text-white"),onClick:()=>r({...i,action:"discard"}),children:"Discard"})]})]}),s.candidateType==="entity"&&d&&i.action==="map_existing"?e.jsxs("div",{className:"mt-4 grid gap-3 rounded-[18px] border border-white/8 bg-[rgba(6,10,20,0.55)] p-4",children:[e.jsxs("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:["Map to existing ",d.replaceAll("_"," ")]}),w?e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full border border-white/8 bg-white/[0.06] px-2.5 py-1.5",children:[w.kind?e.jsx(X,{kind:w.kind,label:w.label,compact:!0,gradient:!1,className:"max-w-[20rem]"}):e.jsx(J,{className:"bg-white/[0.08] text-white/78",children:w.label}),e.jsx("button",{type:"button",className:"rounded-full text-white/50 transition hover:text-white",onClick:()=>r({...i,mappedEntityId:void 0,mappedEntityLabel:void 0}),"aria-label":"Clear mapped entity",children:e.jsx(ee,{className:"size-3.5"})})]})}):null,e.jsxs("div",{className:"flex items-center gap-3 rounded-[20px] border border-white/8 bg-white/[0.04] px-4 py-3",children:[e.jsx(ge,{className:"size-4 text-white/34"}),e.jsx("input",{value:x,onChange:a=>{j(a.target.value),i.mappedEntityId&&r({...i,mappedEntityId:void 0,mappedEntityLabel:void 0})},placeholder:`Search existing ${d.replaceAll("_"," ")}`,className:"min-w-0 flex-1 bg-transparent text-sm text-white placeholder:text-white/34 focus:outline-none"})]}),e.jsx("div",{className:"grid gap-2",children:m.isPending?e.jsx("div",{className:"rounded-[16px] border border-white/8 bg-white/[0.03] px-3 py-3 text-sm text-white/48",children:"Searching Forge…"}):_.length===0?e.jsxs("div",{className:"rounded-[16px] border border-dashed border-white/10 px-3 py-3 text-sm text-white/42",children:["No existing ",d.replaceAll("_"," ")," matches yet."]}):_.map(a=>{const g=i.mappedEntityType===a.entityType&&i.mappedEntityId===a.entityId;return e.jsx("button",{type:"button",className:y("flex w-full items-start justify-between gap-3 rounded-[18px] border px-3 py-3 text-left transition",g?"border-[rgba(133,222,255,0.24)] bg-[rgba(133,222,255,0.12)] text-white":"border-white/8 bg-white/[0.03] text-white/72 hover:bg-white/[0.06] hover:text-white"),onClick:()=>r({action:"map_existing",mappedEntityType:a.entityType,mappedEntityId:a.entityId,mappedEntityLabel:a.label}),children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:a.kind?e.jsx(X,{kind:a.kind,label:a.label,compact:!0,gradient:!1}):a.label}),a.description?e.jsx("div",{className:"mt-1 text-xs leading-5 text-white/46",children:a.description}):null]})},`${a.entityType}:${a.entityId}`)})})]}):null,s.candidateType==="page"&&i.action==="merge_existing"?e.jsxs("div",{className:"mt-4 grid gap-3 rounded-[18px] border border-white/8 bg-[rgba(6,10,20,0.55)] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Merge into existing page"}),A?e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full border border-white/8 bg-white/[0.06] px-2.5 py-1.5",children:[e.jsx(J,{className:"bg-white/[0.08] text-white/78",children:A.title}),e.jsx("button",{type:"button",className:"rounded-full text-white/50 transition hover:text-white",onClick:()=>r({...i,targetNoteId:void 0,targetNoteLabel:void 0}),"aria-label":"Clear merge target",children:e.jsx(ee,{className:"size-3.5"})})]})}):null,e.jsxs("div",{className:"flex items-center gap-3 rounded-[20px] border border-white/8 bg-white/[0.04] px-4 py-3",children:[e.jsx(ge,{className:"size-4 text-white/34"}),e.jsx("input",{value:h,onChange:a=>{v(a.target.value),i.targetNoteId&&r({...i,targetNoteId:void 0,targetNoteLabel:void 0})},placeholder:"Search existing wiki pages",className:"min-w-0 flex-1 bg-transparent text-sm text-white placeholder:text-white/34 focus:outline-none"})]}),e.jsx("div",{className:"grid gap-2",children:N.isPending?e.jsx("div",{className:"rounded-[16px] border border-white/8 bg-white/[0.03] px-3 py-3 text-sm text-white/48",children:"Searching Forge…"}):k.length===0?e.jsx("div",{className:"rounded-[16px] border border-dashed border-white/10 px-3 py-3 text-sm text-white/42",children:"No existing wiki pages match yet."}):k.map(a=>{const g=i.targetNoteId===a.noteId;return e.jsx("button",{type:"button",className:y("flex w-full items-start justify-between gap-3 rounded-[18px] border px-3 py-3 text-left transition",g?"border-[rgba(133,222,255,0.24)] bg-[rgba(133,222,255,0.12)] text-white":"border-white/8 bg-white/[0.03] text-white/72 hover:bg-white/[0.06] hover:text-white"),onClick:()=>r({action:"merge_existing",targetNoteId:a.noteId,targetNoteLabel:a.title}),children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:a.title}),e.jsxs("div",{className:"mt-1 text-xs leading-5 text-white/46",children:[a.slug?`${a.slug}`:"",a.summary?`${a.slug?" · ":""}${a.summary}`:""]})]})},a.noteId)})})]}):null,c?e.jsx("div",{className:"mt-4 rounded-[18px] border border-white/8 bg-[rgba(6,10,20,0.65)] px-4 py-3 text-sm leading-6 text-white/72",children:e.jsx("pre",{className:"whitespace-pre-wrap font-sans",children:c})}):null]})}function ot({open:s,onOpenChange:i,spaces:r,llmProfiles:b,initialSpaceId:d,selectedJobId:x,onJobSelected:j,linkedEntityHints:h=[]}){var me;const v=Ce(),c=De(),[m,_]=p.useState("files"),[N,k]=p.useState(d),[w,A]=p.useState(""),[a,g]=p.useState(""),[F,u]=p.useState(""),[z,B]=p.useState([]),[je,$]=p.useState(!1),[ve,Ne]=p.useState(!1),I=p.useMemo(()=>b.filter(t=>t.enabled&&!!t.secretId),[b]),[Q,ie]=p.useState(((me=I[0])==null?void 0:me.id)??""),[D,ke]=p.useState("auto"),[H,se]=p.useState({}),[R,E]=p.useState(null),[W,T]=p.useState(null),ae=p.useRef({});p.useEffect(()=>{d&&k(d)},[d]),p.useEffect(()=>{var t;!Q&&((t=I[0])!=null&&t.id)&&ie(I[0].id)},[Q,I]);const M=I.find(t=>t.id===Q)??I[0]??null,P=te({queryKey:["forge-wiki-ingest-job",x],queryFn:()=>Ye(x),enabled:s&&!!x,refetchInterval:t=>{const o=t.state.data;return o&&L.has(o.job.status)?2e3:!1}});p.useEffect(()=>{const t=P.data;t&&se(o=>{const l={};for(const K of t.candidates)l[K.id]=o[K.id]??(K.status==="rejected"?{action:"discard"}:{action:"keep"});return l})},[P.data]),p.useEffect(()=>{W&&T(null)},[H,W]);const V=q({mutationFn:async t=>Re(t),onSuccess:(t,o)=>{t.job&&c.setQueryData(["forge-wiki-ingest-job",o],t.job),c.invalidateQueries({queryKey:["forge-wiki-ingest-jobs"]}),c.invalidateQueries({queryKey:["forge-wiki-ingest-history"]})}});p.useEffect(()=>{const t=P.data;if(!t||!L.has(t.job.status))return;const o=t.logs.reduce((pe,Te)=>{const xe=Number(new Date(Te.createdAt));return Number.isFinite(xe)?Math.max(pe,xe):pe},0),l=Number(new Date(t.job.updatedAt)),K=Math.max(Number.isFinite(l)?l:0,o);if(!Number.isFinite(K)||K<=0)return;const G=Date.now();if(!(G-K>=we)||V.isPending)return;const Ee=ae.current[t.job.id]??0;G-Ee<we||(ae.current[t.job.id]=G,V.mutate(t.job.id))},[P.data,V]);const re=q({mutationFn:async()=>{if(!M)throw new Error("Set up an OpenAI wiki ingest profile first. Forge now requires an LLM profile before auto-ingest can turn source material into draft pages and entities.");if(m==="files"){if(z.length===0)throw new Error("Select at least one file to ingest.");return We({files:z,spaceId:N||void 0,titleHint:w.trim()||void 0,llmProfileId:M.id,parseStrategy:D,createAsKind:"wiki",linkedEntityHints:h})}if(m==="url"){if(!a.trim())throw new Error("Enter a URL to ingest.");return he({spaceId:N||void 0,titleHint:w.trim()||void 0,sourceKind:"url",sourceUrl:a.trim(),llmProfileId:M.id,parseStrategy:D,createAsKind:"wiki",linkedEntityHints:h})}if(!F.trim())throw new Error("Paste some text to ingest.");return he({spaceId:N||void 0,titleHint:w.trim()||void 0,sourceKind:"raw_text",sourceText:F,mimeType:"text/plain",llmProfileId:M.id,parseStrategy:D,createAsKind:"wiki",linkedEntityHints:h})},onSuccess:async t=>{var l;const o=((l=t.job)==null?void 0:l.job.id)??null;await c.invalidateQueries({queryKey:["forge-wiki-ingest-jobs"]}),await c.invalidateQueries({queryKey:["forge-wiki-ingest-history"]}),o&&j(o),E(null),T(null)},onError:t=>{E(t instanceof Error?t.message:"Unable to start ingest.")}}),ne=q({mutationFn:async()=>{if(!x||!P.data)throw new Error("Choose an ingest job first.");const t=P.data.candidates.map(o=>{const l=H[o.id]??{action:"keep"};if(l.action==="map_existing"&&(!l.mappedEntityType||!l.mappedEntityId))throw new Error(`Choose an existing ${String(o.payload.entityType??"entity").replaceAll("_"," ")} before publishing the review.`);if(l.action==="merge_existing"&&!l.targetNoteId)throw new Error(`Choose an existing wiki page before publishing the review for ${o.title||"this page candidate"}.`);return l.action==="map_existing"?{candidateId:o.id,action:"map_existing",mappedEntityType:l.mappedEntityType,mappedEntityId:l.mappedEntityId}:l.action==="merge_existing"?{candidateId:o.id,action:"merge_existing",targetNoteId:l.targetNoteId}:{candidateId:o.id,action:l.action}});return Ue({jobId:x,decisions:t})},onSuccess:async t=>{T(null),c.setQueryData(["forge-wiki-ingest-job",t.job.job.id],t.job),await Promise.all([c.invalidateQueries({queryKey:["forge-wiki-ingest-jobs"]}),c.invalidateQueries({queryKey:["forge-wiki-ingest-history"]}),c.invalidateQueries({queryKey:["forge-wiki-ingest-job",t.job.job.id]}),c.invalidateQueries({queryKey:["forge-wiki-home"]}),c.invalidateQueries({queryKey:["forge-wiki-page-by-slug"]}),c.invalidateQueries({queryKey:["forge-wiki-tree"]})])},onError:t=>{T(t instanceof Error?t.message:"Unable to publish review.")}}),le=q({mutationFn:async()=>{if(!x)throw new Error("Choose an ingest job first.");return Oe(x)},onSuccess:async t=>{var l;const o=((l=t.job)==null?void 0:l.job.id)??null;await Promise.all([c.invalidateQueries({queryKey:["forge-wiki-ingest-jobs"]}),c.invalidateQueries({queryKey:["forge-wiki-ingest-history"]}),c.invalidateQueries({queryKey:["forge-wiki-ingest-job",x]})]),o&&j(o),E(null),T(null)},onError:t=>{E(t instanceof Error?t.message:"Unable to rerun ingest.")}}),de=q({mutationFn:async()=>{if(!x)throw new Error("Choose an ingest job first.");return Be(x)},onSuccess:async()=>{await Promise.all([c.invalidateQueries({queryKey:["forge-wiki-ingest-jobs"]}),c.invalidateQueries({queryKey:["forge-wiki-ingest-history"]}),c.invalidateQueries({queryKey:["forge-wiki-ingest-job",x]})]),ce(),E(null),T(null)},onError:t=>{E(t instanceof Error?t.message:"Unable to delete ingest.")}}),n=P.data??null,Ie=n&&!L.has(n.job.status),Z=p.useMemo(()=>(n==null?void 0:n.candidates.filter(t=>["suggested","rejected","failed"].includes(t.status)))??[],[n]),oe=p.useMemo(()=>et((n==null?void 0:n.logs)??[]),[n==null?void 0:n.logs]),ce=()=>{j(null),B([]),g(""),u(""),A(""),E(null),T(null)};return e.jsx(Fe,{open:s,onOpenChange:t=>{i(t),t||(E(null),T(null))},children:e.jsxs(Me,{children:[e.jsx(Le,{className:"fixed inset-0 z-50 bg-[rgba(3,7,18,0.78)] backdrop-blur-sm"}),e.jsxs(qe,{className:"fixed inset-x-4 bottom-4 top-4 z-50 mx-auto flex max-w-[min(74rem,calc(100vw-2rem))] flex-col overflow-hidden rounded-[32px] border border-white/8 bg-[linear-gradient(180deg,rgba(18,27,42,0.98),rgba(10,15,28,0.98))] shadow-[0_36px_110px_rgba(3,8,18,0.48)]",children:[e.jsx("div",{className:"border-b border-white/8 px-5 py-5",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"KarpaWiki Ingest"}),e.jsx(ze,{className:"mt-2 font-display text-[1.5rem] tracking-[-0.04em] text-white",children:n?"Ingest review and progress":"Build KarpaWiki memory from source files"}),e.jsx($e,{className:"mt-2 max-w-3xl text-sm leading-6 text-white/58",children:"Upload notes, media, ZIP archives, links, or pasted text. Forge will process them in the background, propose pages and entities, and let you keep only what belongs."})]}),e.jsx(Qe,{asChild:!0,children:e.jsx("button",{type:"button",className:"rounded-full border border-white/10 bg-white/[0.04] p-2 text-white/64 transition hover:bg-white/[0.08] hover:text-white","aria-label":"Close ingest modal",children:e.jsx(ee,{className:"size-4"})})})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto px-5 py-5",children:n?e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"rounded-[28px] border border-white/8 bg-white/[0.04] p-4 sm:p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:["Job ",n.job.id]}),e.jsx("div",{className:"mt-2 text-xl font-semibold text-white",children:n.job.latestMessage||"Ingest job"}),e.jsxs("div",{className:"mt-2 text-sm leading-6 text-white/56",children:[n.job.status," · ",n.job.phase," · started ",fe(n.job.createdAt)]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(C,{variant:"secondary",size:"sm",onClick:ce,children:"New ingest"}),Ie?e.jsxs(e.Fragment,{children:[e.jsxs(C,{variant:"secondary",size:"sm",pending:le.isPending,pendingLabel:"Rerunning",onClick:()=>void le.mutateAsync(),children:[e.jsx(U,{className:"size-3.5"}),"Rerun"]}),e.jsx(C,{variant:"ghost",size:"sm",className:"border border-rose-300/18 bg-rose-400/10 text-rose-100 hover:bg-rose-400/16",pending:de.isPending,pendingLabel:"Deleting",onClick:()=>{window.confirm("Delete this ingest history entry? Published pages or entities will stay, but discarded or unreviewed ingest data will be removed.")&&de.mutateAsync()},children:"Delete"})]}):null]})]}),e.jsx("div",{className:"mt-5 grid gap-3 sm:grid-cols-4",children:[{label:"Progress",value:`${n.job.progressPercent}%`},{label:"Files",value:`${n.job.processedFiles}/${n.job.totalFiles}`},{label:"Pages",value:String(n.job.createdPageCount)},{label:"Entities",value:String(n.job.createdEntityCount)}].map(t=>e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-[rgba(8,12,22,0.68)] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:t.label}),e.jsx("div",{className:"mt-2 text-lg font-semibold text-white",children:t.value})]},t.label))}),e.jsx("div",{className:"mt-5",children:e.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-white/[0.06]",children:e.jsx("div",{className:"h-full rounded-full bg-[linear-gradient(90deg,rgba(192,193,255,0.8),rgba(133,222,255,0.8))] transition-all duration-300",style:{width:`${n.job.progressPercent}%`}})})}),R?e.jsx("div",{className:"mt-4 rounded-[20px] border border-rose-300/22 bg-rose-400/10 px-4 py-3 text-sm text-rose-100",children:R}):null]}),e.jsxs("div",{className:"rounded-[28px] border border-white/8 bg-white/[0.04] p-4 sm:p-5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Rich log"}),e.jsx(C,{variant:"secondary",size:"sm",onClick:()=>v(`/settings/logs?jobId=${encodeURIComponent(n.job.id)}`),children:"Open full logs"})]}),e.jsx("div",{className:"mt-4 grid max-h-[28rem] gap-2 overflow-y-auto",children:oe.length===0?e.jsx("div",{className:"rounded-[18px] border border-dashed border-white/10 px-4 py-4 text-sm text-white/45",children:"Waiting for the backend to emit progress."}):oe.map(t=>e.jsx("div",{className:"rounded-[18px] border border-white/8 bg-[rgba(7,11,21,0.72)] px-4 py-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-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:"rounded-full border border-white/10 bg-white/[0.04] px-2 py-1 text-[10px] font-semibold uppercase tracking-[0.14em] text-white/55",children:t.level}),typeof t.metadata.scope=="string"?e.jsx("span",{className:"rounded-full border border-white/10 bg-white/[0.04] px-2 py-1 text-[10px] font-semibold uppercase tracking-[0.14em] text-white/38",children:t.metadata.scope}):null,typeof t.metadata.eventKey=="string"?e.jsx("span",{className:"rounded-full border border-white/10 bg-white/[0.04] px-2 py-1 text-[10px] font-semibold uppercase tracking-[0.14em] text-white/38",children:t.metadata.eventKey}):null]}),e.jsx("div",{className:"mt-2 text-sm text-white/82",children:f(t.metadata,"eventKey")==="llm_compile_background_polled"?Je(t,t.repetitionCount):t.message}),t.repetitionCount>1?e.jsxs("div",{className:"mt-2 text-xs text-white/44",children:["Combined ",t.repetitionCount," repeated polling updates."]}):null,Object.keys(t.metadata).length>0?e.jsxs("details",{className:"mt-3",children:[e.jsx("summary",{className:"cursor-pointer text-xs text-white/45",children:"View metadata"}),e.jsx("pre",{className:"mt-2 overflow-x-auto whitespace-pre-wrap rounded-[14px] border border-white/8 bg-black/20 px-3 py-3 text-[11px] leading-5 text-white/52",children:JSON.stringify(t.metadata,null,2)})]}):null]}),e.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-white/38",children:fe(t.createdAt)})]})},t.id))})]})]}),e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"rounded-[28px] border border-white/8 bg-white/[0.04] p-4 sm:p-5",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Source files"}),e.jsx("div",{className:"mt-4 grid gap-2",children:n.assets.map(t=>e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[18px] border border-white/8 bg-[rgba(7,11,21,0.72)] px-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium text-white",children:t.fileName||t.sourceLocator||"Source"}),e.jsx("div",{className:"mt-1 text-xs text-white/45",children:t.mimeType||t.sourceKind})]}),e.jsx("div",{className:"shrink-0 text-[11px] uppercase tracking-[0.14em] text-white/40",children:t.status})]},t.id))})]}),e.jsxs("div",{className:"rounded-[28px] border border-white/8 bg-white/[0.04] p-4 sm:p-5",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-white/42",children:"Review"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:"Keep the candidates that belong in Forge and discard the rest."})]}),L.has(n.job.status)?e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-white/10 bg-white/[0.04] px-3 py-2 text-xs text-white/58",children:[e.jsx(Ke,{className:"size-3.5 animate-spin"}),"Processing"]}):null]}),e.jsx("div",{className:"mt-4 grid gap-3",children:Z.length===0?e.jsx("div",{className:"rounded-[18px] border border-dashed border-white/10 px-4 py-4 text-sm text-white/45",children:L.has(n.job.status)?"Candidates will appear here while the job progresses.":"This job has no reviewable candidates left."}):Z.map(t=>e.jsx(st,{candidate:t,spaceId:n.job.spaceId,decision:H[t.id]??{action:"keep"},onDecisionChange:o=>se(l=>({...l,[t.id]:o}))},t.id))}),W?e.jsx("div",{className:"mt-4 rounded-[20px] border border-rose-300/22 bg-rose-400/10 px-4 py-3 text-sm text-rose-100",children:W}):null,Z.length>0&&!L.has(n.job.status)?e.jsx("div",{className:"mt-5",children:e.jsxs(C,{className:"min-h-12",pending:ne.isPending,pendingLabel:"Publishing review",onClick:()=>void ne.mutateAsync(),children:[e.jsx(ue,{className:"size-4"}),"Publish kept candidates"]})}):null]})]})]}):e.jsxs("div",{className:"grid gap-5 lg:grid-cols-[minmax(0,1.15fr)_minmax(18rem,0.85fr)]",children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsx("div",{className:"grid gap-3 sm:grid-cols-3",children:[{id:"files",label:"Files and ZIP",detail:"Drag many files or one archive.",icon:Y},{id:"url",label:"URL",detail:"Pull a webpage or remote file.",icon:Se},{id:"text",label:"Paste text",detail:"Turn notes or transcripts into pages.",icon:_e}].map(t=>{const o=t.icon,l=t.id===m;return e.jsxs("button",{type:"button",className:y("rounded-[24px] border px-4 py-4 text-left transition",l?"border-[rgba(192,193,255,0.24)] bg-[rgba(192,193,255,0.12)] text-white":"border-white/8 bg-white/[0.04] text-white/72 hover:bg-white/[0.07] hover:text-white"),onClick:()=>_(t.id),children:[e.jsx(o,{className:"size-4 text-[var(--secondary)]"}),e.jsx("div",{className:"mt-3 text-sm font-semibold",children:t.label}),e.jsx("div",{className:"mt-1 text-xs leading-5 text-white/48",children:t.detail})]},t.id)})}),e.jsx("div",{className:"rounded-[28px] border border-white/8 bg-[rgba(9,14,26,0.72)] p-4 sm:p-5",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsx(be,{value:w,onChange:t=>A(t.target.value),placeholder:"Optional title hint"}),m==="files"?e.jsxs("div",{className:y("rounded-[28px] border-2 border-dashed px-5 py-8 text-center transition",je?"border-[rgba(192,193,255,0.35)] bg-[rgba(192,193,255,0.08)]":"border-white/10 bg-white/[0.03]"),onDragEnter:t=>{t.preventDefault(),$(!0)},onDragLeave:t=>{t.preventDefault(),$(!1)},onDragOver:t=>{t.preventDefault(),$(!0)},onDrop:t=>{t.preventDefault(),$(!1);const o=Array.from(t.dataTransfer.files);B(l=>[...l,...o])},children:[e.jsx("div",{className:"mx-auto flex size-14 items-center justify-center rounded-full border border-white/10 bg-white/[0.05]",children:e.jsx(Y,{className:"size-5 text-white/72"})}),e.jsx("div",{className:"mt-4 text-base font-semibold text-white",children:"Drop files, media, notes, or ZIP archives here"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/50",children:"Forge accepts many files at once and queues the ingest in the background so the UI stays responsive."}),e.jsxs("label",{className:"mt-5 inline-flex cursor-pointer items-center gap-2 rounded-full border border-white/10 bg-white/[0.05] px-4 py-2 text-sm text-white/78 transition hover:bg-white/[0.08] hover:text-white",children:[e.jsx(Y,{className:"size-4"}),"Choose files",e.jsx("input",{type:"file",multiple:!0,className:"hidden",onChange:t=>B(Array.from(t.target.files??[]))})]}),z.length>0?e.jsx("div",{className:"mt-5 grid gap-2 text-left",children:z.map(t=>e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[18px] border border-white/8 bg-white/[0.04] px-4 py-3 text-sm text-white/72",children:[e.jsx("span",{className:"truncate",children:t.name}),e.jsx("span",{className:"shrink-0 text-xs text-white/42",children:t.name.toLowerCase().endsWith(".zip")?e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Ae,{className:"size-3.5"}),"ZIP"]}):`${Math.max(1,Math.round(t.size/1024))} KB`})]},`${t.name}-${t.size}-${t.lastModified}`))}):null]}):null,m==="url"?e.jsx(be,{value:a,onChange:t=>g(t.target.value),placeholder:"https://example.com/source"}):null,m==="text"?e.jsx(He,{value:F,onChange:t=>u(t.target.value),placeholder:"Paste notes, transcripts, meeting writeups, or source material here…",className:"min-h-[18rem]"}):null]})})]}),e.jsxs("aside",{className:"grid h-fit gap-4",children:[M?null:e.jsxs("div",{className:"rounded-[30px] border border-amber-300/28 bg-[linear-gradient(180deg,rgba(120,74,14,0.28),rgba(37,22,8,0.42))] p-5 shadow-[0_24px_64px_rgba(12,6,0,0.22)]",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 flex size-10 shrink-0 items-center justify-center rounded-full border border-amber-200/20 bg-amber-300/12 text-amber-100",children:e.jsx(Pe,{className:"size-4.5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-amber-100/62",children:"OpenAI setup required for smart ingest"}),e.jsx("div",{className:"mt-2 text-lg font-semibold text-white",children:"Forge can only do a raw import without OpenAI"}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/78",children:"Without an OpenAI ingest profile, Forge cannot extract key insights, split the source into draft wiki pages, or propose Forge entities. The fallback is just a direct text import or media reference with no structured synthesis."}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/62",children:"Set up the API key, model, thinking, and verbosity first, then come back here to build real draft pages and reviewable entity proposals."})]})]}),e.jsxs("div",{className:"mt-5 grid gap-3 sm:grid-cols-2",children:[e.jsxs(C,{className:"w-full",onClick:()=>{i(!1),v("/settings/wiki?setupLlm=1")},children:[e.jsx(U,{className:"size-4"}),"Open OpenAI setup"]}),e.jsx(C,{variant:"secondary",className:"w-full",onClick:()=>{i(!1),v("/settings/wiki")},children:"Open KarpaWiki settings"})]})]}),e.jsxs("div",{className:"rounded-[28px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsxs("button",{type:"button",className:"flex w-full items-center justify-between gap-3 text-left",onClick:()=>Ne(t=>!t),children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Advanced"}),e.jsx("div",{className:"mt-2 text-sm text-white/72",children:"Model, parse, and target controls."})]}),e.jsx(U,{className:"size-4 text-white/58"})]}),ve?e.jsxs("div",{className:"mt-4 grid gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Space"}),e.jsx("div",{className:"grid gap-2",children:r.map(t=>e.jsxs("button",{type:"button",className:y("rounded-[18px] border px-3 py-3 text-left text-sm transition",N===t.id?"border-[rgba(192,193,255,0.24)] bg-[rgba(192,193,255,0.12)] text-white":"border-white/8 bg-white/[0.03] text-white/68 hover:bg-white/[0.06] hover:text-white"),onClick:()=>k(t.id),children:[e.jsx("div",{children:t.label}),e.jsx("div",{className:"mt-1 text-xs text-white/45",children:t.description||`/${t.slug}`})]},t.id))})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-[11px] uppercase tracking-[0.16em] text-white/42",children:"LLM profile"}),e.jsxs("div",{className:"grid gap-2",children:[I.map(t=>e.jsxs("button",{type:"button",className:y("rounded-[18px] border px-3 py-3 text-left text-sm transition",Q===t.id?"border-[rgba(192,193,255,0.24)] bg-[rgba(192,193,255,0.12)] text-white":"border-white/8 bg-white/[0.03] text-white/68 hover:bg-white/[0.06] hover:text-white"),onClick:()=>ie(t.id),children:[e.jsx("div",{children:t.label}),e.jsx("div",{className:"mt-1 text-xs text-white/45",children:t.model})]},t.id)),I.length===0?e.jsx("div",{className:"rounded-[18px] border border-dashed border-white/10 px-4 py-4 text-sm text-white/48",children:"No enabled profile with a saved key yet."}):null]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Parse mode"}),e.jsx("div",{className:"grid gap-2 sm:grid-cols-3",children:[{id:"auto",label:"Auto"},{id:"multimodal",label:"Multimodal"},{id:"text_only",label:"Text only"}].map(t=>e.jsx("button",{type:"button",className:y("rounded-[18px] border px-3 py-3 text-sm transition",D===t.id?"border-[rgba(192,193,255,0.24)] bg-[rgba(192,193,255,0.12)] text-white":"border-white/8 bg-white/[0.03] text-white/68 hover:bg-white/[0.06] hover:text-white"),onClick:()=>ke(t.id),children:t.label},t.id))})]})]}):null]}),e.jsxs("div",{className:"rounded-[28px] border border-white/8 bg-[linear-gradient(180deg,rgba(192,193,255,0.12),rgba(192,193,255,0.05))] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white",children:[e.jsx(ue,{className:"size-4 text-[var(--secondary)]"}),e.jsx("span",{className:"text-sm font-semibold",children:"Publish only what belongs"})]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/62",children:"Forge stages candidate pages, proposed entity records, and page updates first. You review the output before anything is committed to the live memory graph."})]}),R?e.jsx("div",{className:"rounded-[20px] border border-rose-300/22 bg-rose-400/10 px-4 py-3 text-sm text-rose-100",children:R}):null,e.jsxs(C,{className:"min-h-12",pending:re.isPending,pendingLabel:"Starting ingest",disabled:!M,onClick:()=>void re.mutateAsync(),children:[e.jsx(U,{className:"size-4"}),"Start background ingest"]})]})]})})]})]})})}export{ot as W};
@@ -1 +0,0 @@
1
- import{b5 as Ce,cc as Se,c2 as Ee,r as d,j as e,b3 as Pe,cx as ae,aG as re,cH as We,cM as Re,c7 as Ke,b4 as $e,aC as le,aK as de,bl as ze}from"./vendor-DHkYh85p.js";import{R as ce,P as pe,O as me,C as xe,T as he,a as ge,D as Le}from"./ui-C13Nbgas.js";import{j as qe,i as R,k as Ue}from"./state-B-4sS1xO.js";import{u as Fe,a9 as Oe,bq as Te,f3 as De,L as D,E as ne,a as Me,b as oe,a8 as Be,B as U,Z as N,cO as _e,I as Qe,c as Je,b_ as He,f4 as Ae,f5 as Ge,f6 as Ye,f7 as Ve}from"./index-CF4J4R9L.js";import{O as Xe}from"./open-in-graph-button-IXe9SGth.js";import{W as Ze}from"./wiki-article-markdown-DdiR2TJE.js";import{W as et}from"./wiki-ingest-modal--ohzFnj2.js";import"./board-BkDRaMp6.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";function tt(x){return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",year:"numeric"}).format(new Date(x))}function st(x){return x.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function ue({nodes:x,activeSlug:o,spaceId:m,depth:r=0}){return e.jsx("ul",{className:N("grid gap-1",r>0&&"mt-1"),children:x.map(n=>{const u=n.page.slug===o;return e.jsxs("li",{className:"grid gap-1",children:[e.jsx(le,{to:{pathname:n.page.slug==="index"?"/wiki":`/wiki/page/${encodeURIComponent(n.page.slug)}`,search:`?spaceId=${encodeURIComponent(m)}`},className:N("rounded-lg px-2 py-1.5 text-[12px] leading-5 transition",u?"bg-white/[0.08] text-white":"text-white/64 hover:bg-white/[0.04] hover:text-white"),style:{paddingLeft:`${.5+r*.7}rem`},children:n.page.title}),n.children.length>0?e.jsx(ue,{nodes:n.children,activeSlug:o,spaceId:m,depth:r+1}):null]},n.page.id)})})}function it({open:x,onOpenChange:o,spaces:m,activeSpaceId:r,onSelect:n}){var I;const u=((I=m.find(c=>c.visibility==="shared"))==null?void 0:I.id)??"";return e.jsx(ce,{open:x,onOpenChange:o,children:e.jsxs(pe,{children:[e.jsx(me,{className:"fixed inset-0 z-50 bg-[rgba(3,7,18,0.72)] backdrop-blur-sm"}),e.jsxs(xe,{className:"fixed left-1/2 top-[14vh] z-50 w-[min(28rem,calc(100vw-1.5rem))] -translate-x-1/2 rounded-[28px] border border-white/10 bg-[rgba(10,15,28,0.97)] p-4 shadow-[0_32px_90px_rgba(0,0,0,0.45)] sm:p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(he,{className:"font-display text-[1.2rem] tracking-[-0.04em] text-white",children:"Choose KarpaWiki space"}),e.jsx(Le,{className:"mt-1 text-[13px] leading-6 text-white/56",children:"Switch the reading space without leaving the article surface."})]}),e.jsx(ge,{asChild:!0,children:e.jsx("button",{type:"button",className:"rounded-full border border-white/10 bg-white/[0.04] p-2 text-white/64 transition hover:bg-white/[0.08] hover:text-white","aria-label":"Close space picker",children:e.jsx(de,{className:"size-4"})})})]}),e.jsx("div",{className:"mt-4 grid gap-2",children:m.map(c=>{const K=c.id===r,$=c.id===u;return e.jsxs("button",{type:"button",className:N("flex items-center justify-between gap-3 rounded-[22px] border px-4 py-3 text-left transition",K?"border-[rgba(192,193,255,0.22)] bg-[rgba(192,193,255,0.12)] text-white":"border-white/8 bg-white/[0.03] text-white/78 hover:bg-white/[0.06] hover:text-white"),onClick:()=>{n(c.id),o(!1)},children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-[14px] font-semibold text-inherit",children:c.label}),e.jsx("span",{className:"mt-1 block text-[12px] leading-5 text-white/52",children:c.description||`/${c.slug}`}),$?e.jsx("span",{className:"mt-2 inline-flex rounded-full bg-amber-200/90 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-[0.14em] text-stone-950",children:"Recovered pages"}):null]}),K?e.jsx(ze,{className:"size-4 shrink-0 text-[var(--primary)]"}):null]},c.id)})})]})]})})}function gt(){var H,A,G,Y,V,X,Z,ee,te,se;const x=Fe(),o=Ce(),m=qe(),{slug:r}=Se(),[n,u]=Ee(),[I,c]=d.useState(!1),[K,$]=d.useState(!1),[F,C]=d.useState(!1),[b,be]=d.useState("hybrid"),[S,we]=d.useState(""),[E,M]=d.useState(""),B=d.useRef(null),O=n.get("spaceId")??"",fe=n.get("ingest")==="1",_=n.get("ingestJobId"),l=R({queryKey:["forge-wiki-settings"],queryFn:He}),s=O||((A=(H=l.data)==null?void 0:H.settings.spaces[0])==null?void 0:A.id)||"",P=((G=l.data)==null?void 0:G.settings.embeddingProfiles.filter(t=>t.enabled))??[];d.useEffect(()=>{var t;!E&&((t=P[0])!=null&&t.id)&&M(P[0].id)},[P,E]),d.useEffect(()=>{var t,a;if(!O&&((a=(t=l.data)==null?void 0:t.settings.spaces[0])!=null&&a.id)){const h=new URLSearchParams(n);h.set("spaceId",l.data.settings.spaces[0].id),u(h,{replace:!0})}},[n,O,u,l.data]);const j=R({queryKey:["forge-wiki-home",s],queryFn:()=>Ae({spaceId:s||void 0}),enabled:!!s&&!r}),g=R({queryKey:["forge-wiki-page-by-slug",s,r],queryFn:()=>Ge({slug:r??"index",spaceId:s||void 0}),enabled:!!s&&!!r}),W=R({queryKey:["forge-wiki-tree",s],queryFn:()=>Ye({spaceId:s||void 0,kind:"wiki"}),enabled:!!s}),k=R({queryKey:["forge-wiki-modal-search",s,b,S,E],queryFn:()=>Ve({spaceId:s||void 0,mode:b,query:S.trim(),profileId:(b==="semantic"||b==="hybrid")&&E||void 0,limit:30}),enabled:I&&!!s&&S.trim().length>0}),z=r?g.data??null:j.data??null,[ye,je]=d.useState(null);d.useEffect(()=>{z&&je(z)},[z]);const L=!!s&&(r?g.isFetching:j.isFetching),w=z??(L?ye:null),i=(w==null?void 0:w.page)??null,p=((Y=l.data)==null?void 0:Y.settings.spaces.find(t=>t.id===s))??null,f=((V=l.data)==null?void 0:V.settings.spaces.find(t=>t.visibility==="shared"))??null,ke=!!f&&!!p&&(p==null?void 0:p.id)!==(f==null?void 0:f.id)&&(p==null?void 0:p.visibility)==="personal",q=(i==null?void 0:i.slug)!=="index",y=r&&g.error instanceof Oe&&g.error.status===404?r.trim():null;d.useEffect(()=>{if(!s||!y)return;const t=new URLSearchParams;t.set("spaceId",s),t.set("title",y);const a=st(y);a&&t.set("slug",a),o(`/wiki/new?${t.toString()}`,{replace:!0})},[s,y,o]);const Q=d.useMemo(()=>((i==null?void 0:i.links)??[]).map(t=>({id:`${t.entityType}:${t.entityId}`,href:Te(t.entityType,t.entityId),label:`${t.entityType} · ${t.entityId}`})),[i==null?void 0:i.links]),v=Ue({mutationFn:async t=>De(t),onSuccess:async()=>{await Promise.all([m.invalidateQueries({queryKey:["forge-wiki-tree"]}),m.invalidateQueries({queryKey:["forge-wiki-home"]}),m.invalidateQueries({queryKey:["forge-wiki-page-by-slug"]}),m.invalidateQueries({queryKey:["forge-wiki-modal-search"]})]),o(`/wiki${s?`?spaceId=${encodeURIComponent(s)}`:""}`)}}),T=(t,a=!1)=>{const h=new URLSearchParams(n);t(h),u(h,{replace:a})},J=t=>{T(a=>{a.set("ingest","1"),t?a.set("ingestJobId",t):a.delete("ingestJobId"),s&&a.set("spaceId",s)})},ve=()=>{T(t=>{t.delete("ingest"),t.delete("ingestJobId")})},Ne=t=>{T(a=>{a.set("ingest","1"),t?a.set("ingestJobId",t):a.delete("ingestJobId"),s&&a.set("spaceId",s)})},Ie=()=>{!i||!q||v.isPending||!window.confirm(`Delete KarpaWiki page "${i.title}"? You can restore it later from the bin.`)||v.mutateAsync(i.id)};return d.useEffect(()=>{if(!F)return;const t=h=>{var ie;(ie=B.current)!=null&&ie.contains(h.target)||C(!1)},a=h=>{h.key==="Escape"&&C(!1)};return document.addEventListener("pointerdown",t),document.addEventListener("keydown",a),()=>{document.removeEventListener("pointerdown",t),document.removeEventListener("keydown",a)}},[F]),!i&&(l.isLoading||W.isLoading||!r&&j.isLoading||r&&g.isLoading)?e.jsx(D,{eyebrow:"KarpaWiki",title:"Loading the article",description:"Preparing the current space, article, and KarpaWiki index."}):!i&&!y&&(l.isError||j.isError||g.isError||W.isError)?e.jsx(ne,{eyebrow:"KarpaWiki",error:l.error??j.error??g.error??W.error,onRetry:()=>{l.refetch(),j.refetch(),g.refetch(),W.refetch()}}):i?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 py-4 sm:px-5 lg:px-6",children:e.jsxs("div",{className:"mx-auto flex w-full max-w-[1680px] flex-col gap-4",children:[e.jsxs("section",{className:"wiki-frame px-3 py-3 sm:px-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(oe,{kind:"wiki_page",label:"KarpaWiki page",compact:!0,gradient:!1}),p?e.jsx(oe,{kind:"wiki_space",label:p.label,compact:!0,gradient:!1,wrap:!0,className:"max-w-[20rem]"}):null,e.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:tt(i.updatedAt)}),e.jsx(Be,{metrics:x.snapshot.metrics,className:"ml-auto"})]}),e.jsxs("div",{className:"mt-3 flex flex-col gap-2 lg:flex-row lg:items-center",children:[e.jsxs("button",{type:"button",className:"wiki-search-launch flex min-h-[2.9rem] w-full items-center gap-3 rounded-[18px] border border-white/8 bg-white/[0.04] px-4 text-left text-[14px] text-white/56 transition hover:bg-white/[0.06] hover:text-white lg:flex-1",onClick:()=>c(!0),children:[e.jsx(Pe,{className:"size-4 shrink-0 text-white/44"}),e.jsx("span",{children:"Search KarpaWiki"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 lg:shrink-0",children:[e.jsxs("button",{type:"button",className:"wiki-space-trigger inline-flex min-h-[2.9rem] items-center gap-2 rounded-[18px] border border-white/8 bg-white/[0.04] px-4 text-[13px] font-medium text-white/78 transition hover:bg-white/[0.07] hover:text-white",onClick:()=>$(!0),children:[e.jsx("span",{className:"text-[11px] uppercase tracking-[0.14em] text-white/38",children:"Space"}),e.jsx("span",{className:"max-w-[16rem] truncate",children:(p==null?void 0:p.label)??"KarpaWiki space"}),e.jsx(ae,{className:"size-3.5 text-white/44"})]}),e.jsxs("div",{className:"relative",ref:B,children:[e.jsxs(U,{variant:"secondary",size:"sm",className:"min-h-[2.9rem]",onClick:()=>C(t=>!t),children:[e.jsx(re,{className:"size-3.5"}),"Ingest",e.jsx(ae,{className:"size-3.5"})]}),F?e.jsxs("div",{className:"absolute right-0 top-[calc(100%+0.5rem)] z-20 grid min-w-[15rem] gap-2 rounded-[22px] border border-white/10 bg-[rgba(9,14,27,0.98)] p-2 shadow-[0_24px_60px_rgba(0,0,0,0.35)]",children:[e.jsxs("button",{type:"button",className:"flex items-start gap-3 rounded-[18px] px-3 py-3 text-left transition hover:bg-white/[0.06]",onClick:()=>{C(!1),J()},children:[e.jsx(re,{className:"mt-0.5 size-4 shrink-0 text-[var(--primary)]"}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-medium text-white",children:"New ingest"}),e.jsx("span",{className:"mt-1 block text-xs leading-5 text-white/48",children:"Start a fresh import from files, URLs, or pasted text."})]})]}),e.jsxs("button",{type:"button",className:"flex items-start gap-3 rounded-[18px] px-3 py-3 text-left transition hover:bg-white/[0.06]",onClick:()=>{C(!1),o(`/wiki/ingest-history${s?`?spaceId=${encodeURIComponent(s)}`:""}`)},children:[e.jsx(We,{className:"mt-0.5 size-4 shrink-0 text-[var(--secondary)]"}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-medium text-white",children:"History"}),e.jsx("span",{className:"mt-1 block text-xs leading-5 text-white/48",children:"Browse prior ingests, reopen reviews, and delete old ingest records."})]})]})]}):null]}),e.jsxs(U,{variant:"secondary",size:"sm",className:"min-h-[2.9rem]",onClick:()=>o(`/wiki/edit/${encodeURIComponent(i.id)}?spaceId=${encodeURIComponent(s)}`,{state:{initialPage:i}}),children:[e.jsx(Re,{className:"size-3.5"}),"Edit"]}),e.jsx(Xe,{entityType:"note",entityId:i.id,label:"Open in graph",size:"sm"}),e.jsxs(U,{variant:"secondary",size:"sm",className:N("min-h-[2.9rem] border border-rose-400/18 bg-rose-500/10 text-rose-100 hover:bg-rose-500/18",!q&&"opacity-60"),onClick:Ie,pending:v.isPending,pendingLabel:"Deleting",disabled:!q,title:q?"Delete this KarpaWiki page":"The KarpaWiki home page cannot be deleted",children:[e.jsx(Ke,{className:"size-3.5"}),"Delete"]}),e.jsxs(U,{size:"sm",className:"min-h-[2.9rem]",onClick:()=>o(`/wiki/new?spaceId=${encodeURIComponent(s)}`),children:[e.jsx($e,{className:"size-3.5"}),"New page"]})]})]}),ke&&f?e.jsxs("div",{className:"mt-3 flex flex-col gap-3 rounded-[22px] border border-amber-300/20 bg-amber-300/[0.08] px-4 py-3 text-[13px] leading-6 text-amber-50 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("span",{children:["You are viewing the personal starter wiki. The recovered people, story, and conversation pages are in"," ",e.jsx("strong",{children:f.label}),"."]}),e.jsx("button",{type:"button",className:"inline-flex min-h-10 shrink-0 items-center justify-center rounded-2xl bg-amber-200 px-4 text-[12px] font-semibold uppercase tracking-[0.14em] text-stone-950 transition hover:bg-amber-100",onClick:()=>{o({pathname:"/wiki",search:`?spaceId=${encodeURIComponent(f.id)}`})},children:"Open shared memory"})]}):null]}),e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[15rem_minmax(0,1fr)] xl:grid-cols-[16rem_minmax(0,1fr)]",children:[e.jsxs("aside",{className:"wiki-frame h-fit px-2 py-3 sm:px-3 lg:sticky lg:top-[5.75rem]",children:[e.jsx("div",{className:"px-2 pb-2 text-[11px] font-semibold uppercase tracking-[0.16em] text-white/42",children:"Index"}),e.jsx(ue,{nodes:((X=W.data)==null?void 0:X.tree)??[],activeSlug:i.slug,spaceId:s})]}),e.jsxs("article",{"aria-busy":L,className:N("wiki-frame relative overflow-hidden px-4 py-5 transition-[opacity,transform] duration-200 sm:px-6 sm:py-6",L&&"opacity-[0.985]"),children:[L?e.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-px bg-[linear-gradient(90deg,transparent,rgba(192,193,255,0.8),transparent)] opacity-90"}):null,e.jsxs("div",{className:"wiki-reading-copy wiki-reading-flow mx-auto max-w-[76rem]",children:[v.isError?e.jsx("div",{className:"mb-4 rounded-[18px] border border-rose-400/20 bg-rose-500/10 px-4 py-3 text-sm text-rose-100",children:v.error instanceof Error?v.error.message:"Forge could not delete this KarpaWiki page."}):null,e.jsx(Ze,{markdown:i.contentMarkdown,spaceId:s}),i.summary.trim()?e.jsx("p",{className:"mt-5 border-t border-white/8 pt-4 text-[13px] leading-6 text-white/56",children:i.summary}):null,Q.length>0?e.jsxs("section",{className:"mt-8 border-t border-white/8 pt-4",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-white/42",children:"Forge links"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:Q.map(t=>e.jsx("a",{href:t.href?_e(t.href):void 0,className:"rounded-full bg-white/[0.05] px-3 py-1.5 text-[12px] text-white/76 transition hover:bg-white/[0.1] hover:text-white",children:t.label},t.id))})]}):null,w!=null&&w.backlinkSourceNotes.length?e.jsxs("section",{className:"mt-8 border-t border-white/8 pt-4",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-white/42",children:"Linked here"}),e.jsx("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:w.backlinkSourceNotes.map(t=>e.jsxs(le,{to:{pathname:t.slug==="index"?"/wiki":`/wiki/page/${encodeURIComponent(t.slug)}`,search:`?spaceId=${encodeURIComponent(t.spaceId)}`},className:"rounded-xl border border-white/8 bg-white/[0.03] px-4 py-3 transition hover:bg-white/[0.06]",children:[e.jsx("div",{className:"text-[13px] font-semibold text-white",children:t.title}),t.summary?e.jsx("div",{className:"mt-1 text-[12px] leading-5 text-white/56",children:t.summary}):null]},t.id))})]}):null]})]})]})]})}),e.jsx(ce,{open:I,onOpenChange:c,children:e.jsxs(pe,{children:[e.jsx(me,{className:"fixed inset-0 z-50 bg-[rgba(3,7,18,0.8)] backdrop-blur-sm"}),e.jsxs(xe,{className:"fixed left-1/2 top-[8vh] z-50 w-[min(54rem,calc(100vw-1.5rem))] -translate-x-1/2 rounded-[28px] border border-white/10 bg-[rgba(10,15,28,0.96)] p-4 shadow-[0_30px_90px_rgba(0,0,0,0.45)] sm:p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("div",{children:e.jsx(he,{className:"font-display text-[1.35rem] tracking-[-0.04em] text-white",children:"Search the wiki"})}),e.jsx(ge,{asChild:!0,children:e.jsx("button",{type:"button",className:"rounded-full border border-white/10 bg-white/[0.04] p-2 text-white/64 transition hover:bg-white/[0.08] hover:text-white","aria-label":"Close search",children:e.jsx(de,{className:"size-4"})})})]}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsx(Qe,{autoFocus:!0,value:S,onChange:t=>we(t.target.value),placeholder:"Search KarpaWiki pages",className:"h-11 rounded-2xl border-white/10 bg-white/[0.04] text-[14px] text-white placeholder:text-white/28"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[["text","hybrid","semantic","entity"].map(t=>e.jsx("button",{type:"button",className:N("rounded-full px-3 py-1.5 text-[12px] font-medium uppercase tracking-[0.14em] transition",b===t?"bg-white/[0.12] text-white":"bg-white/[0.04] text-white/54 hover:bg-white/[0.08] hover:text-white"),onClick:()=>be(t),children:t},t)),(b==="semantic"||b==="hybrid")&&P.length>0?e.jsx("select",{className:"ml-auto rounded-full border border-white/10 bg-white/[0.04] px-3 py-1.5 text-[12px] text-white",value:E,onChange:t=>M(t.target.value),children:P.map(t=>e.jsx("option",{value:t.id,children:t.label},t.id))}):null]})]}),e.jsx("div",{className:"mt-4 max-h-[60vh] overflow-y-auto",children:S.trim()?k.isLoading?e.jsx(D,{eyebrow:"KarpaWiki search",title:"Searching",description:"Ranking matching pages for this query."}):k.isError?e.jsx(ne,{eyebrow:"KarpaWiki search",error:k.error,onRetry:()=>void k.refetch()}):(Z=k.data)!=null&&Z.results.length?e.jsx("div",{className:"grid gap-2",children:k.data.results.map(t=>e.jsx("button",{type:"button",className:"rounded-2xl border border-white/8 bg-white/[0.03] px-4 py-3 text-left transition hover:bg-white/[0.06]",onClick:()=>{c(!1),o({pathname:t.page.slug==="index"?"/wiki":`/wiki/page/${encodeURIComponent(t.page.slug)}`,search:`?spaceId=${encodeURIComponent(t.page.spaceId)}`})},children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[14px] font-semibold text-white",children:t.page.title}),t.page.summary?e.jsx("div",{className:"mt-1 text-[12px] leading-5 text-white/56",children:t.page.summary}):null]}),e.jsx(Je,{size:"sm",tone:"meta",children:t.score.toFixed(2)})]})},t.page.id))}):e.jsx("div",{className:"rounded-2xl border border-dashed border-white/10 px-4 py-10 text-center text-[13px] leading-6 text-white/42",children:"No pages matched this search."}):e.jsx("div",{className:"rounded-2xl border border-dashed border-white/10 px-4 py-10 text-center text-[13px] leading-6 text-white/42",children:"Start typing to search the current KarpaWiki space."})})]})]})}),e.jsx(it,{open:K,onOpenChange:$,spaces:((ee=l.data)==null?void 0:ee.settings.spaces)??[],activeSpaceId:s,onSelect:t=>{o({pathname:"/wiki",search:`?spaceId=${encodeURIComponent(t)}`},{replace:!0})}}),e.jsx(et,{open:fe,onOpenChange:t=>{if(t){J(_);return}ve()},spaces:((te=l.data)==null?void 0:te.settings.spaces)??[],llmProfiles:((se=l.data)==null?void 0:se.settings.llmProfiles)??[],initialSpaceId:s,selectedJobId:_,onJobSelected:Ne,linkedEntityHints:i.links.map(t=>({entityType:t.entityType,entityId:t.entityId,anchorKey:null}))??[]})]}):y?e.jsx(D,{eyebrow:"KarpaWiki",title:"Opening a new page",description:`Creating a draft for ${y}.`}):e.jsx(Me,{eyebrow:"KarpaWiki",title:"Article not found",description:"This page does not exist in the selected space."})}export{gt as WikiPage};