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.
- package/dist/assets/activity-page-Dv6X5ZCV.js +1 -0
- package/dist/assets/ai-surface-workspace-CutiG6uS.js +1 -0
- package/dist/assets/atlas-panel-jgMRyaHn.js +1 -0
- package/dist/assets/{board-BkDRaMp6.js → board-dIX6etHh.js} +1 -1
- package/dist/assets/calendar-page-q7Nm5E2U.js +1 -0
- package/dist/assets/calendar-rules-DPFsfiRl.js +1 -0
- package/dist/assets/calendar-week-toolbar-nVhgB-0s.js +1 -0
- package/dist/assets/{charts-P7EVhIog.js → charts-DFnEuIMB.js} +8 -8
- package/dist/assets/companion-sync-lab-page-CJ8UTij8.js +1 -0
- package/dist/assets/daily-metrics-dashboard-CiJkkkd1.js +1 -0
- package/dist/assets/entity-note-count-link-RzBB6ujx.js +1 -0
- package/dist/assets/entity-notes-surface-Djz50HvD.js +1 -0
- package/dist/assets/execution-board-CtPhI-58.js +1 -0
- package/dist/assets/faceted-token-search-DEC6ANa9.js +1 -0
- package/dist/assets/flagship-signal-deck-CtHC3mql.js +1 -0
- package/dist/assets/floating-action-menu-CKQRhff9.js +1 -0
- package/dist/assets/{forms-BFlTgZ3W.js → forms-hB0SqEh-.js} +1 -1
- package/dist/assets/goal-detail-page-CF5fNQeR.js +1 -0
- package/dist/assets/goals-page-fsY8NzGB.js +1 -0
- package/dist/assets/{graph-D6JLqDbD.js → graph-DDUZNRsO.js} +14 -14
- package/dist/assets/habits-page-COoGz4kj.js +1 -0
- package/dist/assets/index-BAXYM89v.css +1 -0
- package/dist/assets/index-EqQsXoat.js +19 -0
- package/dist/assets/insight-flow-dialog-DtX_5W7g.js +1 -0
- package/dist/assets/insights-page-cBd74ObU.js +8 -0
- package/dist/assets/kanban-page-CYav9THw.js +1 -0
- package/dist/assets/knowledge-graph-page-D2A-W1jE.js +1 -0
- package/dist/assets/{life-force-page-Dy0JTS2G.js → life-force-page-CACGlNhq.js} +1 -1
- package/dist/assets/life-force-workspace-BJ4N1I78.js +1 -0
- package/dist/assets/{maps-ClgJoCjz.js → maps-C-yOWiDN.js} +1 -1
- package/dist/assets/metric-tile-CMadwnGz.js +1 -0
- package/dist/assets/{motion-BeD44FeG.js → motion-Lt5B1XuE.js} +1 -1
- package/dist/assets/movement-page-D5VqFd2q.js +1 -0
- package/dist/assets/note-markdown-BzK2Qlgr.js +3 -0
- package/dist/assets/note-tags-input-CZzqJMLc.js +1 -0
- package/dist/assets/notes-page-D3Hsh90C.js +1 -0
- package/dist/assets/{open-in-graph-button-IXe9SGth.js → open-in-graph-button-BFPKfyK3.js} +1 -1
- package/dist/assets/orbit-map-CnyfSmOG.js +1 -0
- package/dist/assets/overview-page-CXdWrOV1.js +1 -0
- package/dist/assets/page-hero-ffKzgyW3.js +1 -0
- package/dist/assets/pill-cluster-C2D0h3lx.js +1 -0
- package/dist/assets/{preference-entity-handoff-button-5PzUn42S.js → preference-entity-handoff-button-Dj3V6VxL.js} +1 -1
- package/dist/assets/preferences-page-Jo8Gw386.js +1 -0
- package/dist/assets/project-collections-qSqp90HN.js +1 -0
- package/dist/assets/{project-detail-page-BXK5-4xW.js → project-detail-page-BifhiLQX.js} +1 -1
- package/dist/assets/project-management-hierarchy-page-DZ_9klIc.js +1 -0
- package/dist/assets/project-management-section-nav-BImLCVvf.js +1 -0
- package/dist/assets/projects-page-ptcx6H38.js +1 -0
- package/dist/assets/psyche-behaviors-page-BDwXyDta.js +5 -0
- package/dist/assets/psyche-flashcards-page-DL1BP1jX.js +1 -0
- package/dist/assets/psyche-goal-map-page-ovcpisx1.js +1 -0
- package/dist/assets/psyche-graph-EP5GL612.js +1 -0
- package/dist/assets/{psyche-metrics-page-CuR9oqEy.js → psyche-metrics-page-Bcu813Rg.js} +1 -1
- package/dist/assets/psyche-mode-guide-page-C0g27Xpt.js +1 -0
- package/dist/assets/psyche-modes-page-BjKjX5MR.js +1 -0
- package/dist/assets/psyche-page-F4tF2W70.js +1 -0
- package/dist/assets/psyche-patterns-page-B-14hukK.js +5 -0
- package/dist/assets/psyche-questionnaire-builder-page-BdXmoHvK.js +1 -0
- package/dist/assets/psyche-questionnaire-detail-page-Cu5uwlJu.js +1 -0
- package/dist/assets/psyche-questionnaire-run-detail-page-C3R4PClg.js +1 -0
- package/dist/assets/psyche-questionnaire-run-page-Div3iDdt.js +1 -0
- package/dist/assets/psyche-questionnaires-page-DpqAPQCp.js +1 -0
- package/dist/assets/psyche-report-detail-page-BvWVDKP3.js +3 -0
- package/dist/assets/psyche-reports-page-BrbWUlAq.js +1 -0
- package/dist/assets/{psyche-schemas-HFmg37Wj.js → psyche-schemas-Dxj554nU.js} +1 -1
- package/dist/assets/psyche-schemas-beliefs-page-DYKvAtSD.js +9 -0
- package/dist/assets/psyche-screen-time-page-CAOKCyQw.js +1 -0
- package/dist/assets/psyche-self-observation-page-F0MVA0UH.js +1 -0
- package/dist/assets/psyche-values-page-DyvX-d0o.js +5 -0
- package/dist/assets/report-chain-fields-CeC1cJFS.js +1 -0
- package/dist/assets/rewards-page-C2loyODo.js +1 -0
- package/dist/assets/scheduling-rules-editor-D40AC2jR.js +1 -0
- package/dist/assets/schema-badge-FY7818qB.js +1 -0
- package/dist/assets/schema-visuals-CvC9a3i6.js +1 -0
- package/dist/assets/select-menu-DJsCG6rM.js +1 -0
- package/dist/assets/settings-agents-page-BFkJ5AAD.js +6 -0
- package/dist/assets/settings-bin-page-D3-Ab-iA.js +1 -0
- package/dist/assets/settings-calendar-page-ly_mSTAD.js +5 -0
- package/dist/assets/settings-data-page-D7QOqNf-.js +1 -0
- package/dist/assets/settings-logs-page-Ca87HEUx.js +1 -0
- package/dist/assets/settings-mobile-page-D0jejZot.js +1 -0
- package/dist/assets/settings-models-page-DPDsZjSc.js +1 -0
- package/dist/assets/settings-page-1cArlSPM.js +1 -0
- package/dist/assets/settings-rewards-page-Db4BV1DC.js +1 -0
- package/dist/assets/{settings-section-nav-DSOuht_F.js → settings-section-nav-DP9o4peU.js} +1 -1
- package/dist/assets/settings-users-page-BHFyDSsd.js +1 -0
- package/dist/assets/settings-wiki-page-BNaiupBm.js +1 -0
- package/dist/assets/sleep-page-BmOPF0yD.js +1 -0
- package/dist/assets/sports-page-BldIiclr.js +1 -0
- package/dist/assets/{state-B-4sS1xO.js → state-vCcAT5Hq.js} +1 -1
- package/dist/assets/strategies-page-CaTN99qj.js +1 -0
- package/dist/assets/strategy-detail-page-DsgFTd-U.js +1 -0
- package/dist/assets/strategy-dialog-7X7peRzu.js +1 -0
- package/dist/assets/surface-CJI17F3n.js +1 -0
- package/dist/assets/{table-WfAPUppN.js → table-BNqMG3_S.js} +1 -1
- package/dist/assets/task-detail-page-M1sIIPA8.js +1 -0
- package/dist/assets/timebox-planning-dialog-ByojN0AN.js +1 -0
- package/dist/assets/today-page-BjDijtn8.js +1 -0
- package/dist/assets/training-load-page-BPRmaWmF.js +1 -0
- package/dist/assets/{ui-C13Nbgas.js → ui-C1iwpj2-.js} +4 -4
- package/dist/assets/use-psyche-focus-target-Ct-acS9G.js +1 -0
- package/dist/assets/vendor-Dnkkx2co.js +1067 -0
- package/dist/assets/{vitals-page-qre17Nw8.js → vitals-page-CE9zdGLF.js} +1 -1
- package/dist/assets/weekly-review-page-CzhTv90n.js +1 -0
- package/dist/assets/weight-loss-page-Bp_cIk78.js +5 -0
- package/dist/assets/wiki-article-markdown-Dok2uy2p.js +4 -0
- package/dist/assets/wiki-editor-page-BuW32Y3f.js +26 -0
- package/dist/assets/wiki-ingest-history-page-DZKSBNHV.js +1 -0
- package/dist/assets/wiki-ingest-modal-DyqBEZcC.js +1 -0
- package/dist/assets/wiki-page-DqxlbLKG.js +1 -0
- package/dist/assets/workbench-flow-page-C4nc9jUg.js +5 -0
- package/dist/assets/workbench-page-BnyR7SL0.js +1 -0
- package/dist/assets/workout-detail-page-DT-c5cHL.js +2 -0
- package/dist/index.html +9 -9
- package/dist/openclaw/local-runtime.js +41 -14
- package/dist/server/server/migrations/067_weight_loss_daily_active_overrides.sql +13 -0
- package/dist/server/server/src/app.js +125 -33
- package/dist/server/server/src/health-weight-loss.js +554 -77
- package/dist/server/server/src/health.js +12 -4
- package/dist/server/server/src/movement.js +84 -1
- package/dist/server/server/src/openapi.js +123 -18
- package/dist/server/server/src/repositories/model-settings.js +21 -12
- package/dist/server/server/src/repositories/settings.js +19 -5
- package/dist/server/src/components/ui/info-tooltip.js +6 -6
- package/dist/server/src/components/workbench-boxes/shared/generic-node-view.js +13 -5
- package/dist/server/src/lib/api.js +24 -5
- package/dist/server/src/lib/theme-system.js +8 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +3 -3
- package/server/migrations/067_weight_loss_daily_active_overrides.sql +13 -0
- package/skills/forge-openclaw/SKILL.md +13 -0
- package/skills/forge-openclaw/entity_conversation_playbooks.md +7 -1
- package/dist/assets/activity-page-CpjuNSHw.js +0 -1
- package/dist/assets/ai-surface-workspace-DEAFZruS.js +0 -1
- package/dist/assets/atlas-panel-CdVNPotj.js +0 -1
- package/dist/assets/calendar-page-DNNt6lfz.js +0 -1
- package/dist/assets/calendar-rules-DNJFNsxi.js +0 -1
- package/dist/assets/calendar-week-toolbar-BbPwYeN0.js +0 -1
- package/dist/assets/companion-sync-lab-page-KxEDigM6.js +0 -1
- package/dist/assets/daily-metrics-dashboard-B3cqJgDt.js +0 -1
- package/dist/assets/entity-note-count-link-DrhjJZ4i.js +0 -1
- package/dist/assets/entity-notes-surface-CkcRsKJQ.js +0 -1
- package/dist/assets/execution-board-D07gOocB.js +0 -1
- package/dist/assets/faceted-token-search-BxRRcM3q.js +0 -1
- package/dist/assets/flagship-signal-deck-cmy82b8_.js +0 -1
- package/dist/assets/floating-action-menu-Fs_ZiUMo.js +0 -1
- package/dist/assets/goal-detail-page-CqLiNz4f.js +0 -1
- package/dist/assets/goals-page-BTk7mg_T.js +0 -1
- package/dist/assets/habits-page-BJxagdzx.js +0 -1
- package/dist/assets/index-CF4J4R9L.js +0 -19
- package/dist/assets/index-CZbuZQjw.css +0 -1
- package/dist/assets/insight-flow-dialog-8f3D0GuC.js +0 -1
- package/dist/assets/insights-page-D6rOa7uk.js +0 -8
- package/dist/assets/kanban-page-XQ7Se6dH.js +0 -1
- package/dist/assets/knowledge-graph-page-BtAg8iv3.js +0 -1
- package/dist/assets/life-force-workspace-OfyB9HJM.js +0 -1
- package/dist/assets/metric-tile-DKpo-8xw.js +0 -1
- package/dist/assets/movement-page-Bg_T_Stx.js +0 -1
- package/dist/assets/note-markdown-N-uxD3Xt.js +0 -3
- package/dist/assets/note-tags-input-Cdu7wiw6.js +0 -1
- package/dist/assets/notes-page-CKXnF_KU.js +0 -1
- package/dist/assets/orbit-map-Dzi6KliQ.js +0 -1
- package/dist/assets/overview-page-1miYqaVS.js +0 -1
- package/dist/assets/page-hero-DRy5b2MU.js +0 -1
- package/dist/assets/pill-cluster-C9QczVJ2.js +0 -1
- package/dist/assets/preferences-page-DtNaF5Q3.js +0 -1
- package/dist/assets/project-collections-xPz2mlRr.js +0 -1
- package/dist/assets/project-management-hierarchy-page-DtRpMABw.js +0 -1
- package/dist/assets/project-management-section-nav-P3ixzPa-.js +0 -1
- package/dist/assets/projects-page-C5ViRuf4.js +0 -1
- package/dist/assets/psyche-behaviors-page-Dco46sC4.js +0 -5
- package/dist/assets/psyche-flashcards-page-ZcoEB8gV.js +0 -1
- package/dist/assets/psyche-goal-map-page-CLBAQOI0.js +0 -1
- package/dist/assets/psyche-graph-k4tX2tdp.js +0 -1
- package/dist/assets/psyche-mode-guide-page-hIVXcCnE.js +0 -1
- package/dist/assets/psyche-modes-page-0lYtBlhO.js +0 -1
- package/dist/assets/psyche-page-VZ9k9ISp.js +0 -1
- package/dist/assets/psyche-patterns-page-gx5nmdGq.js +0 -5
- package/dist/assets/psyche-questionnaire-builder-page-Bn0TOISd.js +0 -1
- package/dist/assets/psyche-questionnaire-detail-page-CmVzSd_s.js +0 -1
- package/dist/assets/psyche-questionnaire-run-detail-page-BsMbmXCG.js +0 -1
- package/dist/assets/psyche-questionnaire-run-page-CgkRL2vi.js +0 -1
- package/dist/assets/psyche-questionnaires-page-D7V8uLXM.js +0 -1
- package/dist/assets/psyche-report-detail-page-OlFq57eL.js +0 -3
- package/dist/assets/psyche-reports-page-dVUZjna1.js +0 -1
- package/dist/assets/psyche-schemas-beliefs-page-BCgc8FUd.js +0 -9
- package/dist/assets/psyche-screen-time-page-B_6BT_WN.js +0 -1
- package/dist/assets/psyche-self-observation-page-CEG5mluK.js +0 -1
- package/dist/assets/psyche-values-page-DRbRfEd6.js +0 -5
- package/dist/assets/report-chain-fields-CALCV3V5.js +0 -1
- package/dist/assets/rewards-page-DmC4R_Ps.js +0 -1
- package/dist/assets/scheduling-rules-editor-D02s70hr.js +0 -1
- package/dist/assets/schema-badge-BZO-qNhO.js +0 -1
- package/dist/assets/schema-visuals-D6nxjbYC.js +0 -1
- package/dist/assets/select-menu-fYyreSdQ.js +0 -1
- package/dist/assets/settings-agents-page-C_v_hMJF.js +0 -6
- package/dist/assets/settings-bin-page-DY5bg81n.js +0 -1
- package/dist/assets/settings-calendar-page-D1CzE6cg.js +0 -5
- package/dist/assets/settings-data-page-CHRQFU9H.js +0 -1
- package/dist/assets/settings-logs-page-B04pUwEv.js +0 -1
- package/dist/assets/settings-mobile-page-D9kTlYDS.js +0 -1
- package/dist/assets/settings-models-page-D26270R2.js +0 -1
- package/dist/assets/settings-page-DYDTFlnv.js +0 -1
- package/dist/assets/settings-rewards-page-cl4vqqO_.js +0 -1
- package/dist/assets/settings-users-page-BU79JB_T.js +0 -1
- package/dist/assets/settings-wiki-page-DwAUlyA3.js +0 -1
- package/dist/assets/sleep-page-D8NbdhyS.js +0 -1
- package/dist/assets/sports-page-CV4Cnzwn.js +0 -1
- package/dist/assets/strategies-page-C4qvXnql.js +0 -1
- package/dist/assets/strategy-detail-page-DJLo5rfy.js +0 -1
- package/dist/assets/strategy-dialog-D3AuUlVz.js +0 -1
- package/dist/assets/task-detail-page-z-9u9rF0.js +0 -1
- package/dist/assets/timebox-planning-dialog-DB6FLqmI.js +0 -1
- package/dist/assets/today-page-BKlu6gx5.js +0 -1
- package/dist/assets/training-load-page-CyJQqo_3.js +0 -1
- package/dist/assets/use-psyche-focus-target-C1C_XjYG.js +0 -1
- package/dist/assets/vendor-DHkYh85p.js +0 -1052
- package/dist/assets/weekly-review-page-Cz4vkRcx.js +0 -1
- package/dist/assets/weight-loss-page-BQrnOI0y.js +0 -1
- package/dist/assets/wiki-article-markdown-DdiR2TJE.js +0 -4
- package/dist/assets/wiki-editor-page-DqwoqVFb.js +0 -26
- package/dist/assets/wiki-ingest-history-page--evBLbOw.js +0 -1
- package/dist/assets/wiki-ingest-modal--ohzFnj2.js +0 -1
- package/dist/assets/wiki-page-B_VJFBPA.js +0 -1
- package/dist/assets/workbench-flow-page-Du62mtJU.js +0 -5
- package/dist/assets/workbench-page-4MKr3iRm.js +0 -1
- package/dist/assets/workout-detail-page-DfUbYYw1.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aJ as b,r as d,cm as v,cr as f,
|
|
1
|
+
import{aJ as b,r as d,cm as v,cr as f,bP as g,aV as h,cY as y,cZ as j,b2 as k,ba as N,c_ as w,aF as S,c$ as C,j as e,bB as x,F as z,aK as E}from"./vendor-Dnkkx2co.js";import{C as T,Z as i}from"./index-EqQsXoat.js";const o=[{to:"/settings",label:"General",icon:v},{to:"/settings/data",label:"Data",icon:f},{to:"/settings/users",label:"Users",icon:g},{to:"/settings/calendar",label:"Calendar",icon:h},{to:"/settings/mobile",label:"Mobile",icon:y},{to:"/settings/models",label:"Models",icon:j},{to:"/settings/agents",label:"Agents",icon:k},{to:"/settings/wiki",label:"KarpaWiki",icon:N},{to:"/settings/logs",label:"Logs",icon:w},{to:"/settings/rewards",label:"Rewards",icon:S},{to:"/settings/bin",label:"Bin",icon:C}];function m(t,a){return a==="/settings"?t==="/settings":t===a||t.startsWith(`${a}/`)}function L({className:t}){const a=b(),[l,n]=d.useState(!1),c=d.useMemo(()=>[...o].sort((r,s)=>s.to.length-r.to.length).find(r=>m(a.pathname,r.to))??o[0],[a.pathname]);return d.useEffect(()=>{if(!l)return;const r=document.body.style.overflow,s=document.body.style.touchAction,u=p=>{p.key==="Escape"&&n(!1)};return document.body.style.overflow="hidden",document.body.style.touchAction="none",window.addEventListener("keydown",u),()=>{document.body.style.overflow=r,document.body.style.touchAction=s,window.removeEventListener("keydown",u)}},[l]),e.jsxs(e.Fragment,{children:[e.jsxs(T,{className:i("surface-shell-panel overflow-hidden p-2",t),children:[e.jsx("div",{className:"hidden items-center gap-3 lg:flex",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:o.map(r=>e.jsxs(x,{to:r.to,end:r.to==="/settings",className:({isActive:s})=>i("inline-flex items-center gap-2 whitespace-nowrap rounded-full px-3 py-1.5 text-[11px] font-semibold uppercase tracking-[0.14em] transition",s||m(a.pathname,r.to)?"border border-[var(--primary)]/14 bg-[var(--ui-accent-soft)] text-[var(--primary)]":"border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"),children:[e.jsx(r.icon,{className:"size-3.5"}),e.jsx("span",{children:r.label})]},r.to))})}),e.jsx("div",{className:"flex items-center justify-between gap-3 lg:hidden",children:e.jsxs("button",{type:"button",className:"surface-shell-panel inline-flex min-w-0 flex-1 items-center justify-between gap-3 rounded-[22px] border px-3.5 py-2.5 text-left transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]",onClick:()=>n(!0),children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-2xl border border-[var(--primary)]/20 bg-[var(--primary)]/12",children:e.jsx(c.icon,{className:"size-4 text-[var(--primary)]"})}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-[10px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Settings section"}),e.jsx("span",{className:"mt-0.5 block truncate text-sm font-medium text-[var(--ui-ink-strong)]",children:c.label})]})]}),e.jsx("span",{className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-2.5 py-1 text-[10px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Browse"})]})})]}),l&&typeof document<"u"?z.createPortal(e.jsxs("div",{className:"lg:hidden",children:[e.jsx("div",{className:"surface-overlay fixed inset-0 z-50 backdrop-blur-xl"}),e.jsx("button",{type:"button","aria-label":"Close settings sections",className:"fixed inset-0 z-[51]",onClick:()=>n(!1)}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-[52] flex items-end justify-center px-3 pt-3 sm:px-4 sm:pt-4",style:{paddingLeft:"max(0.75rem, calc(var(--forge-safe-area-left) + 0.75rem))",paddingRight:"max(0.75rem, calc(var(--forge-safe-area-right) + 0.75rem))",paddingTop:"max(0.75rem, calc(env(safe-area-inset-top) + 0.75rem))",paddingBottom:"calc(var(--forge-mobile-nav-clearance) - 0.25rem)"},children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Settings sections",className:"surface-modal-panel pointer-events-auto flex max-h-[min(34rem,calc(100dvh-var(--forge-mobile-nav-clearance)-1rem))] w-full max-w-xl min-h-0 flex-col overflow-hidden rounded-[30px] border",children:[e.jsx("div",{className:"shrink-0 border-b border-[var(--ui-border-subtle)] px-4 pb-3 pt-4 sm:px-5",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[10px] uppercase tracking-[0.22em] text-[var(--ui-ink-faint)]",children:"Settings"}),e.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-2",children:[e.jsx("div",{className:"truncate text-base font-semibold text-[var(--ui-ink-strong)]",children:"Tune Forge"}),e.jsx("span",{className:"rounded-full border border-[var(--primary)]/20 bg-[var(--primary)]/12 px-2.5 py-1 text-[10px] uppercase tracking-[0.16em] text-[var(--primary)]",children:c.label})]}),e.jsx("div",{className:"mt-1 text-xs leading-5 text-[var(--ui-ink-soft)]",children:"Jump between users, calendar, models, rewards, and more."})]}),e.jsx("button",{type:"button","aria-label":"Close settings sections",className:"inline-flex size-10 shrink-0 items-center justify-center rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",onClick:()=>n(!1),children:e.jsx(E,{className:"size-4"})})]})}),e.jsx("div",{className:"min-h-0 overflow-y-auto p-3 overscroll-contain sm:p-4",children:e.jsx("div",{className:"grid gap-2",children:o.map(r=>{const s=m(a.pathname,r.to);return e.jsxs(x,{to:r.to,end:r.to==="/settings",onClick:()=>n(!1),className:i("group flex items-center justify-between gap-3 rounded-[22px] border px-3.5 py-3 transition-[transform,border-color,background-color,color] duration-150 hover:-translate-y-[1px] hover:text-[var(--ui-ink-strong)]",s?"border-[var(--primary)]/18 bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]"),children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("span",{className:i("flex size-10 shrink-0 items-center justify-center rounded-2xl border transition",s?"border-[var(--primary)]/18 bg-[var(--primary)]/14 text-[var(--primary)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] group-hover:border-[var(--ui-border-strong)] group-hover:text-[var(--ui-ink-strong)]"),children:e.jsx(r.icon,{className:"size-4"})}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate text-sm font-semibold text-[var(--ui-ink-strong)]",children:r.label}),e.jsx("span",{className:"mt-0.5 block text-[10px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Forge settings"})]})]}),e.jsx("span",{className:i("rounded-full px-2.5 py-1 text-[10px] uppercase tracking-[0.16em]",s?"bg-[var(--primary)]/16 text-[var(--primary)]":"bg-[var(--ui-surface-1)] text-[var(--ui-ink-faint)]"),children:s?"Current":"Open"})]},r.to)})})})]})})]}),document.body):null]})}export{L as S};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as g,j as e,aC as ce}from"./vendor-Dnkkx2co.js";import{i as de,k as Z}from"./state-vCcAT5Hq.js";import{S as he}from"./settings-section-nav-DP9o4peU.js";import{P as ue}from"./page-hero-ffKzgyW3.js";import{i as pe,C as ge,B as me,M as xe}from"./graph-DDUZNRsO.js";import{C as F,aq as fe,c as b,U as E,Q as ie,F as $,j as H,I as T,T as be,W as ve,u as je,eu as we,ev as ye,ew as Ne,B as J,ex as ke}from"./index-EqQsXoat.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";const ae=[{id:"visibility",label:"Discovery and visibility",description:"What the source user can discover, inspect, and pull into read flows on the target side.",rights:[{key:"discoverable",label:"Discoverable",description:"The target appears as a reachable collaborator in the source user's graph and pickers."},{key:"canListUsers",label:"List users",description:"The source user can include the target in directory, comparison, and routing surfaces."},{key:"canReadProfile",label:"Read profile",description:"The source user can inspect the target's identity card, handle, type, and description."},{key:"canReadEntities",label:"Read entities",description:"The source user can read the target's goals, projects, tasks, notes, strategies, and related records."},{key:"canSearchEntities",label:"Search entities",description:"The source user can find the target's work through Forge search and entity pickers."}]},{id:"coordination",label:"Messaging, context, and handoff",description:"What the source user can message, connect, and coordinate on the target side before changing execution.",rights:[{key:"canLinkEntities",label:"Share context",description:"The source user can attach the target's records into shared notes, strategies, calendar context, and cross-owner plans."},{key:"canCoordinate",label:"Message and coordinate",description:"The source user can communicate with the target through Forge, hand off work, and coordinate execution."},{key:"canViewMetrics",label:"View metrics",description:"The source user can inspect the target's XP, alignment, and progress metrics."},{key:"canViewActivity",label:"View activity",description:"The source user can inspect the target's activity stream, evidence, and execution trail."}]},{id:"execution",label:"Plan and execution control",description:"What the source user can actually change on the target side once collaboration is trusted.",rights:[{key:"canManageStrategies",label:"Manage strategies",description:"The source user can draft and update strategies that belong to the target."},{key:"canCreateOnBehalf",label:"Create on behalf",description:"The source user can intentionally create new target-owned entities."},{key:"canAffectEntities",label:"Affect entities",description:"The source user can mutate work that belongs to the target."}]}],Ce=[{id:"full_collab",label:"Full collaboration",description:"Use when two humans or agents can see, coordinate, plan, and change each other's work.",rights:{discoverable:!0,canListUsers:!0,canReadProfile:!0,canReadEntities:!0,canSearchEntities:!0,canLinkEntities:!0,canCoordinate:!0,canAffectEntities:!0,canManageStrategies:!0,canCreateOnBehalf:!0,canViewMetrics:!0,canViewActivity:!0}},{id:"coordination_only",label:"Coordinate only",description:"Use when the source user may see and coordinate with the target but should not directly mutate target-owned work.",rights:{discoverable:!0,canListUsers:!0,canReadProfile:!0,canReadEntities:!0,canSearchEntities:!0,canLinkEntities:!0,canCoordinate:!0,canAffectEntities:!1,canManageStrategies:!0,canCreateOnBehalf:!1,canViewMetrics:!0,canViewActivity:!0}},{id:"observe_only",label:"Observe only",description:"Use when the source user should keep visibility into the target without planning or execution control.",rights:{discoverable:!0,canListUsers:!0,canReadProfile:!0,canReadEntities:!0,canSearchEntities:!0,canLinkEntities:!1,canCoordinate:!1,canAffectEntities:!1,canManageStrategies:!1,canCreateOnBehalf:!1,canViewMetrics:!0,canViewActivity:!0}},{id:"hidden",label:"Hidden edge",description:"Use when this direction should stop discovering, reading, or acting on the target.",rights:{discoverable:!1,canListUsers:!1,canReadProfile:!1,canReadEntities:!1,canSearchEntities:!1,canLinkEntities:!1,canCoordinate:!1,canAffectEntities:!1,canManageStrategies:!1,canCreateOnBehalf:!1,canViewMetrics:!1,canViewActivity:!1}}],A=ae.reduce((s,n)=>s+n.rights.length,0);function P(s){return Object.values(s.config.rights).filter(Boolean).length}function re(s){const n=[];return s.config.rights.canReadEntities&&n.push("See"),s.config.rights.canCoordinate&&n.push("Message"),s.config.rights.canManageStrategies&&n.push("Plan"),s.config.rights.canAffectEntities&&n.push("Affect"),n.join(" · ")||"Hidden"}function Ue(s){return!s.config.rights.discoverable&&!s.config.rights.canReadEntities?"Hidden":s.config.rights.canAffectEntities&&s.config.rights.canManageStrategies?"Trusted":s.config.rights.canCoordinate||s.config.rights.canLinkEntities?"Coordinated":"Observed"}function ne(s){return[{id:"see",label:"See",enabled:s.config.rights.discoverable&&s.config.rights.canReadEntities&&s.config.rights.canSearchEntities},{id:"message",label:"Message",enabled:s.config.rights.canCoordinate},{id:"share",label:"Share context",enabled:s.config.rights.canLinkEntities},{id:"plan",label:"Plan",enabled:s.config.rights.canManageStrategies},{id:"affect",label:"Affect",enabled:s.config.rights.canAffectEntities||s.config.rights.canCreateOnBehalf}]}function Ee(s,n){return Object.entries(n.rights).every(([i,u])=>s.config.rights[i]===u)}function Se(s,n){const i=s.filter(a=>a.kind==="human"),u=s.filter(a=>a.kind==="bot"),p={x:560,y:360},m={width:226,height:132},d=i[0]??null,w=[...i.slice(d?1:0).map(a=>({user:a,radius:245,offset:-90})),...u.map(a=>({user:a,radius:390,offset:-90}))],f=w.length,y=[...d?[{user:d,position:{x:p.x-m.width/2,y:p.y-m.height/2}}]:[],...w.map((a,c)=>{const h=(a.offset+360/Math.max(f,1)*c)*Math.PI/180;return{user:a.user,position:{x:p.x+Math.cos(h)*a.radius-m.width/2,y:p.y+Math.sin(h)*a.radius-m.height/2}}})],C=new Set(n.selectedGrant?[n.selectedGrant.subjectUserId,n.selectedGrant.targetUserId]:n.selectedUserId?[n.selectedUserId]:[]);return y.map(({user:a,position:c})=>{const h=C.has(a.id),t=a.id===n.selectedUserId;return{id:a.id,position:c,draggable:!1,selectable:!1,data:{label:e.jsxs("div",{className:`min-w-[206px] rounded-[22px] border px-4 py-4 shadow-[var(--ui-shadow-soft)] transition ${t?"border-[color-mix(in_srgb,var(--warning)_45%,var(--ui-border-subtle)_55%)] bg-[var(--ui-warning-soft)]":h?"border-[color-mix(in_srgb,var(--primary)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-accent-soft)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(E,{user:a}),e.jsx(b,{tone:"meta",children:a.kind})]}),e.jsxs("div",{className:"mt-3 text-xs text-[var(--ui-ink-soft)]",children:["@",a.handle]}),e.jsx("div",{className:"mt-2 line-clamp-2 text-xs leading-5 text-[var(--ui-ink-faint)]",children:a.description||"No user description yet."})]})},style:{background:"transparent",border:"none",padding:0}}})}function Ie(s,n,i){return s.filter(u=>u.subjectUserId!==u.targetUserId).map(u=>{const p=n===u.id,m=i!==null&&(u.subjectUserId===i||u.targetUserId===i),d=P(u),v=p?"var(--warning)":!u.config.rights.discoverable&&!u.config.rights.canReadEntities?"var(--danger)":m?"var(--primary)":"var(--ui-border-strong)";return{id:u.id,source:u.subjectUserId,target:u.targetUserId,label:`${re(u)} · ${d}/${A}`,markerEnd:{type:xe.ArrowClosed,color:v},labelStyle:{fill:p?"var(--warning)":"var(--ui-ink-medium)",fontSize:11,fontWeight:600},labelBgStyle:{fill:p?"var(--ui-warning-soft)":"var(--ui-surface-1)",stroke:p?"color-mix(in_srgb,var(--warning)_36%,var(--ui-border-subtle)_64%)":"var(--ui-border-subtle)",strokeWidth:1},labelBgPadding:[7,5],labelBgBorderRadius:8,style:{stroke:v,strokeWidth:p?2.5:m?1.8:1.25},animated:p}})}function Me({users:s,grants:n,selectedGrantId:i=null,selectedUserId:u=null,onOpenGrant:p,onOpenUser:m}){const d=n.find(c=>c.id===i)??null,v=g.useMemo(()=>Se(s,{selectedUserId:u,selectedGrant:d}),[d,u,s]),w=g.useMemo(()=>Ie(n,i,u),[n,i,u]),f=g.useMemo(()=>n.filter(c=>c.subjectUserId!==c.targetUserId),[n]),y=f.filter(c=>P(c)===A).length,C=f.filter(c=>c.config.rights.canCoordinate).length,a=f.filter(c=>c.config.rights.canAffectEntities||c.config.rights.canCreateOnBehalf).length;return e.jsxs(F,{className:"overflow-hidden p-0",children:[e.jsxs("div",{className:"grid gap-4 border-b border-[var(--ui-border-subtle)] px-5 py-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"max-w-3xl",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Directed relationship graph"}),e.jsx(fe,{content:"Keep Forge, OpenClaw, Hermes, and the browser on the same runtime and storage root when these arrows should describe one shared human and bot system.",label:"Explain the shared runtime rule"})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Click a user card to open that user's settings. Click any arrow to open the exact directional relationship flow for that lane."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(b,{tone:"meta",children:[f.length," edges"]}),e.jsxs(b,{className:"bg-[var(--ui-success-soft)] text-[var(--success)]",children:[y," fully open"]})]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Full collaboration"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:y}),e.jsx("div",{className:"text-xs leading-5 text-[var(--ui-ink-faint)]",children:"Directions still running with the default fully open posture."})]}),e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Coordination lanes"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:C}),e.jsx("div",{className:"text-xs leading-5 text-[var(--ui-ink-faint)]",children:"Directions allowed to coordinate directly through Forge."})]}),e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Execution control"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:a}),e.jsx("div",{className:"text-xs leading-5 text-[var(--ui-ink-faint)]",children:"Directions allowed to create or mutate target-owned work."})]})]})]}),e.jsx("div",{className:"h-[clamp(26rem,58vh,42rem)] bg-[linear-gradient(180deg,var(--ui-surface-2),var(--ui-surface-1))] sm:h-[min(72vh,54rem)] sm:min-h-[34rem]",children:e.jsxs(pe,{className:"user-relationship-flow",nodes:v,edges:w,fitView:!0,fitViewOptions:{padding:.1,maxZoom:.95},nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,onNodeClick:(c,h)=>{m(h.id)},onEdgeClick:(c,h)=>{p(h.id)},attributionPosition:"bottom-left",children:[e.jsx(ge,{showInteractive:!1}),e.jsx(me,{gap:28,size:1,color:"var(--ui-border-subtle)"})]})})]})}const O="rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]",Y="text-sm font-medium text-[var(--ui-ink-strong)]",Oe="text-sm leading-6 text-[var(--ui-ink-soft)]",Re={kind:"human",handle:"",displayName:"",description:"",accentColor:"#c0c1ff"};function ee(s){return s?{kind:s.kind,handle:s.handle,displayName:s.displayName,description:s.description,accentColor:s.accentColor}:Re}function Fe({open:s,onOpenChange:n,user:i,grants:u,ownership:p,xp:m,pending:d=!1,onSubmit:v,onOpenRelationship:w}){const[f,y]=g.useState(()=>ee(i)),[C,a]=g.useState(null);g.useEffect(()=>{s&&(y(ee(i)),a(null))},[s,i]);const c=g.useMemo(()=>u.filter(o=>o.subjectUserId!==o.targetUserId),[u]),h=g.useMemo(()=>i?c.filter(o=>o.subjectUserId===i.id):[],[c,i]),t=g.useMemo(()=>i?c.filter(o=>o.targetUserId===i.id):[],[c,i]),N=[{id:"identity",eyebrow:i?"Edit user":"Create user",title:i?"Update the user identity":"Add a human or bot user",description:"Set the owner type and the public identity Forge will use across ownership, routing, and collaboration surfaces.",render:(o,x)=>e.jsxs(e.Fragment,{children:[e.jsx($,{label:"Kind",description:"Humans represent real people. Bots represent agents or automations with their own ownership lane.",children:e.jsx(H,{columns:2,value:o.kind,onChange:k=>x({kind:k}),options:[{value:"human",label:"Human",description:"Use for a real person in the Forge runtime."},{value:"bot",label:"Bot",description:"Use for an agent, assistant, or automation actor."}]})}),e.jsx($,{label:"Handle",description:"This becomes the stable short id shown as @handle.",hint:"Use lowercase and a durable label, for example forge-operator or planner-bot.",children:e.jsx(T,{value:o.handle,onChange:k=>x({handle:k.target.value}),placeholder:"forge-operator"})}),e.jsx($,{label:"Display name",description:"This is the human-readable label used across the UI.",children:e.jsx(T,{value:o.displayName,onChange:k=>x({displayName:k.target.value}),placeholder:"Forge Operator"})})]})},{id:"profile",eyebrow:"Profile",title:"Describe the user lane",description:"Capture what this user represents in the shared Forge runtime and pick the accent color that helps the lane stay recognizable.",render:(o,x)=>e.jsxs(e.Fragment,{children:[e.jsx($,{label:"Description",description:"Explain what this user is responsible for and what side of the system it represents.",children:e.jsx(be,{value:o.description,onChange:k=>x({description:k.target.value}),className:"min-h-36",placeholder:"Primary human operator for strategy, execution, and review."})}),e.jsx($,{label:"Accent color",description:"Forge uses this accent to help the user stand out in ownership and collaboration surfaces.",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(T,{value:o.accentColor,onChange:k=>x({accentColor:k.target.value}),placeholder:"#c0c1ff"}),e.jsx("div",{className:"size-10 shrink-0 rounded-full border border-[var(--ui-border-subtle)]",style:{backgroundColor:o.accentColor||"#c0c1ff"}})]})}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:`${O} px-4 py-3`,children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Owned records"}),e.jsx("div",{className:"mt-2 text-[var(--ui-ink-strong)]",children:(p==null?void 0:p.totalOwnedEntities)??0})]}),e.jsxs("div",{className:`${O} px-4 py-3`,children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Total XP"}),e.jsx("div",{className:"mt-2 text-[var(--ui-ink-strong)]",children:(m==null?void 0:m.totalXp)??0})]}),e.jsxs("div",{className:`${O} px-4 py-3`,children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Weekly XP"}),e.jsx("div",{className:"mt-2 text-[var(--ui-ink-strong)]",children:(m==null?void 0:m.weeklyXp)??0})]})]})]})},{id:"relationships",eyebrow:"Relationships",title:"Open directional relationship settings",description:"Each arrow is a separate contract. Open the exact lane you want to adjust and Forge will take you into the relationship flow.",render:()=>i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`${O} p-4`,children:[e.jsx(E,{user:i}),e.jsxs("div",{className:`mt-3 ${Oe}`,children:["@",i.handle," · ",i.description||"No description yet."]})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:Y,children:"Outbound lanes"}),h.length>0?h.map(o=>e.jsxs("button",{type:"button",className:`${O} px-4 py-4 text-left transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]`,onClick:()=>w(o.id),children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(E,{user:o.subjectUser}),e.jsx("span",{className:"text-[var(--ui-ink-faint)]",children:"→"}),e.jsx(E,{user:o.targetUser})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(b,{tone:"meta",children:re(o)}),e.jsxs(b,{tone:"meta",children:[P(o),"/",A," rights"]})]})]},o.id)):e.jsx("div",{className:"rounded-[20px] border border-dashed border-[var(--ui-border-subtle)] px-4 py-4 text-sm text-[var(--ui-ink-soft)]",children:"No outbound relationship lanes yet."})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:Y,children:"Inbound lanes"}),t.length>0?t.map(o=>e.jsxs("button",{type:"button",className:`${O} px-4 py-4 text-left transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]`,onClick:()=>w(o.id),children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(E,{user:o.subjectUser}),e.jsx("span",{className:"text-[var(--ui-ink-faint)]",children:"→"}),e.jsx(E,{user:o.targetUser})]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:ne(o).map(x=>e.jsx(b,{className:x.enabled?"bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)]":"bg-[var(--ui-surface-1)] text-[var(--ui-ink-faint)] opacity-70",children:x.label},`${o.id}-${x.id}`))})]},o.id)):e.jsx("div",{className:"rounded-[20px] border border-dashed border-[var(--ui-border-subtle)] px-4 py-4 text-sm text-[var(--ui-ink-soft)]",children:"No inbound relationship lanes yet."})]})]})]}):e.jsx("div",{className:"rounded-[20px] border border-dashed border-[var(--ui-border-subtle)] px-4 py-4 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Create the user first, then Forge will generate the directional relationship lanes you can tune from here."})}];return e.jsx(ie,{open:s,onOpenChange:n,eyebrow:i?"User settings":"Create user",title:i?"User settings":"Create user",description:"Edit the user identity, clarify what this lane represents, and jump into relationship settings without crowding the page.",value:f,onChange:y,draftPersistenceKey:i?`users.settings.${i.id}`:"users.settings.new",steps:N,submitLabel:i?"Save user":"Create user",pending:d,pendingLabel:i?"Saving user":"Creating user",error:C,contentClassName:"lg:w-[min(58rem,calc(100vw-1.5rem))]",onSubmit:async()=>{const o=f.handle.trim(),x=f.displayName.trim();if(o.length===0){a("Add a handle before saving this user.");return}if(x.length===0){a("Add a display name before saving this user.");return}await v({userId:i==null?void 0:i.id,input:{kind:f.kind,handle:o,displayName:x,description:f.description.trim(),accentColor:f.accentColor.trim()||"#c0c1ff"}}),n(!1)}})}const _="rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]",S="text-sm font-medium text-[var(--ui-ink-strong)]",G="text-sm leading-6 text-[var(--ui-ink-soft)]",Ae="text-xs leading-5 text-[var(--ui-ink-faint)]";function se(s,n){return{accessLevel:(s==null?void 0:s.accessLevel)??"manage",applyScope:"this_arrow",rights:{discoverable:(s==null?void 0:s.config.rights.discoverable)??!0,canListUsers:(s==null?void 0:s.config.rights.canListUsers)??!0,canReadProfile:(s==null?void 0:s.config.rights.canReadProfile)??!0,canReadEntities:(s==null?void 0:s.config.rights.canReadEntities)??!0,canSearchEntities:(s==null?void 0:s.config.rights.canSearchEntities)??!0,canLinkEntities:(s==null?void 0:s.config.rights.canLinkEntities)??!0,canCoordinate:(s==null?void 0:s.config.rights.canCoordinate)??!0,canAffectEntities:(s==null?void 0:s.config.rights.canAffectEntities)??!0,canManageStrategies:(s==null?void 0:s.config.rights.canManageStrategies)??!0,canCreateOnBehalf:(s==null?void 0:s.config.rights.canCreateOnBehalf)??!0,canViewMetrics:(s==null?void 0:s.config.rights.canViewMetrics)??!0,canViewActivity:(s==null?void 0:s.config.rights.canViewActivity)??!0}}}function $e({open:s,onOpenChange:n,grant:i,grants:u,pending:p=!1,onSubmit:m}){const d=g.useMemo(()=>i?u.find(a=>a.subjectUserId===i.targetUserId&&a.targetUserId===i.subjectUserId)??null:null,[i,u]),[v,w]=g.useState(()=>se(i,!!d));g.useEffect(()=>{s&&w(se(i,!!d))},[i,s,d]);const f=g.useMemo(()=>Object.values(v.rights).filter(Boolean).length,[v.rights]),y=Math.round(f/A*100),C=[{id:"posture",eyebrow:"Relationship posture",title:"Set the trust mode for this arrow",description:"Each arrow is directional. Decide whether you want to tune only this lane or mirror the same contract onto both directions.",render:(a,c)=>e.jsxs(e.Fragment,{children:[i?e.jsxs("div",{className:`${_} p-4`,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(E,{user:i.subjectUser}),e.jsx("span",{className:"text-[var(--ui-ink-faint)]",children:"→"}),e.jsx(E,{user:i.targetUser})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(b,{tone:"meta",children:Ue(i)}),e.jsxs(b,{tone:"meta",children:[P(i),"/",A," rights"]})]})]}):null,e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:S,children:"Access level"}),e.jsx(H,{columns:2,value:a.accessLevel,onChange:h=>c({accessLevel:h}),options:[{value:"view",label:"View",description:"Use when this lane should stay mostly observational."},{value:"manage",label:"Manage",description:"Use when the source side can actively collaborate or act."}]})]}),d?e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:S,children:"Apply scope"}),e.jsx(H,{columns:2,value:a.applyScope,onChange:h=>c({applyScope:h}),options:[{value:"this_arrow",label:"This arrow",description:"Only change the exact direction you opened."},{value:"both_arrows",label:"Both arrows",description:"Mirror the same contract onto the reverse direction too."}]})]}):null]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:S,children:"Quick preset"}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:Ce.map(h=>e.jsxs("button",{type:"button",className:`rounded-[22px] border p-4 text-left transition ${i&&Ee(i,h)?"border-[color-mix(in_srgb,var(--warning)_32%,var(--ui-border-subtle)_68%)] bg-[var(--ui-warning-soft)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]"}`,onClick:()=>c({rights:{...a.rights,...h.rights}}),children:[e.jsx("div",{className:S,children:h.label}),e.jsx("div",{className:`mt-2 ${G}`,children:h.description})]},h.id))})]})]})},{id:"rights",eyebrow:"Rights",title:"Tune the individual permissions",description:"Use the preset as the starting point, then sharpen the exact boundaries only where this relationship needs them.",render:(a,c)=>e.jsx(e.Fragment,{children:ae.map(h=>e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:S,children:h.label}),e.jsx("div",{className:`mt-1 ${G}`,children:h.description})]}),e.jsx("div",{className:"grid gap-2",children:h.rights.map(t=>e.jsxs("label",{className:"flex items-start justify-between gap-3 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:S,children:t.label}),e.jsx("div",{className:`mt-1 ${Ae}`,children:t.description})]}),e.jsx("input",{type:"checkbox",checked:a.rights[t.key],onChange:N=>c({rights:{...a.rights,[t.key]:N.target.checked}})})]},t.key))})]},h.id))})},{id:"review",eyebrow:"Review",title:"Review the final relationship contract",description:"Check the enabled capabilities, confirm whether both directions should match, and then save the relationship.",render:a=>{var c,h;return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:`${_} p-4`,children:[e.jsx("div",{className:S,children:"Capability coverage"}),e.jsx("div",{className:"mt-4",children:e.jsx(ve,{value:y})}),e.jsxs("div",{className:"mt-3 text-sm text-[var(--ui-ink-soft)]",children:[f,"/",A," rights enabled"]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:ne({...i??{id:"draft",subjectUserId:"",targetUserId:"",accessLevel:a.accessLevel,config:{self:!1,mutable:!0,linkedEntities:!0,rights:a.rights},createdAt:"",updatedAt:"",subjectUser:null,targetUser:null},accessLevel:a.accessLevel,config:{...(i==null?void 0:i.config)??{self:!1,mutable:!0,linkedEntities:!0},rights:a.rights}}).map(t=>e.jsx(b,{className:t.enabled?"bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)]":"bg-[var(--ui-surface-1)] text-[var(--ui-ink-faint)] opacity-70",children:t.label},t.id))})]}),e.jsxs("div",{className:`${_} p-4`,children:[e.jsx("div",{className:S,children:"Save scope"}),e.jsx("div",{className:`mt-3 ${G}`,children:a.applyScope==="both_arrows"&&d?"Forge will apply the same access level and rights to both directions of this pair.":"Forge will only update the exact arrow you opened."}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(b,{tone:"meta",children:["access ",a.accessLevel]}),e.jsxs(b,{tone:"meta",children:["scope"," ",a.applyScope==="both_arrows"&&d?"both arrows":"this arrow"]})]}),d?e.jsxs("div",{className:"mt-4 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3 text-sm text-[var(--ui-ink-soft)]",children:["Reverse arrow available:"," ",((c=d.subjectUser)==null?void 0:c.displayName)??d.subjectUserId," ","→"," ",((h=d.targetUser)==null?void 0:h.displayName)??d.targetUserId]}):null]})]})})}}];return e.jsx(ie,{open:s,onOpenChange:n,eyebrow:"Relationship settings",title:"Relationship settings",description:"Edit the exact directional contract between two users without keeping the full rights editor pinned on the page.",value:v,onChange:w,draftPersistenceKey:i?`users.relationship.${i.id}`:"users.relationship.new",steps:C,submitLabel:"Save relationship",pending:p,pendingLabel:"Saving relationship",contentClassName:"lg:w-[min(62rem,calc(100vw-1.5rem))]",onSubmit:async()=>{i&&(await m({grantId:i.id,patch:{accessLevel:v.accessLevel,rights:v.rights},reverseGrantId:(d==null?void 0:d.id)??null,applyToReverse:v.applyScope==="both_arrows"&&d!==null}),n(!1))}})}const U="font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",M="text-sm leading-6 text-[var(--ui-ink-soft)]",te="text-xs leading-5 text-[var(--ui-ink-faint)]",R="rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]";function We(){var X;const s=je(),[n,i]=g.useState(null),[u,p]=g.useState(null),[m,d]=g.useState(!1),[v,w]=g.useState(!1),[f,y]=g.useState(""),C=de({queryKey:["forge-user-directory"],queryFn:ke}),a=async()=>{await Promise.all([s.refresh(),C.refetch()])},c=Z({mutationFn:async({input:r,userId:l})=>l?(await we(l,r)).user:(await ye(r)).user,onSuccess:async()=>{i(null),d(!1),await a()}}),h=Z({mutationFn:async({grantId:r,patch:l})=>(await Ne(r,l)).grant,onSuccess:a}),t=(X=C.data)==null?void 0:X.directory,N=(t==null?void 0:t.grants.find(r=>r.id===u))??null,o=g.useMemo(()=>new Map(((t==null?void 0:t.ownership)??[]).map(r=>[r.userId,r])),[t==null?void 0:t.ownership]),x=g.useMemo(()=>new Map(((t==null?void 0:t.xp)??[]).map(r=>[r.userId,r])),[t==null?void 0:t.xp]),k=g.useMemo(()=>{const r=new Map;for(const l of(t==null?void 0:t.grants)??[]){if(!l.targetUser||l.subjectUserId===l.targetUserId)continue;const j=r.get(l.subjectUserId)??[];j.push(l.targetUser),r.set(l.subjectUserId,j)}return r},[t==null?void 0:t.grants]),L=g.useMemo(()=>{const r=((t==null?void 0:t.grants)??[]).filter(l=>l.subjectUserId!==l.targetUserId);return{totalEdges:r.length,fullyOpenEdges:r.filter(l=>Object.values(l.config.rights).every(Boolean)).length,coordinationEdges:r.filter(l=>l.config.rights.canCoordinate).length,executionEdges:r.filter(l=>l.config.rights.canAffectEntities||l.config.rights.canCreateOnBehalf).length}},[t==null?void 0:t.grants]),B=f.trim().toLowerCase(),V=g.useMemo(()=>{const l=((t==null?void 0:t.users)??s.snapshot.users).filter(j=>B?[j.displayName,j.handle,j.kind,j.description].join(" ").toLowerCase().includes(B):!0);return{humans:l.filter(j=>j.kind==="human"),bots:l.filter(j=>j.kind==="bot")}},[t==null?void 0:t.users,B,s.snapshot.users]),le=(N==null?void 0:N.subjectUserId)??(n==null?void 0:n.id)??null,oe=(N==null?void 0:N.id)??null;return e.jsxs("div",{className:"mx-auto grid w-full max-w-[1440px] gap-5",children:[e.jsx(ue,{title:"Users",description:"Forge users can be human or bot. Ownership, search, and routing are prepared so work can move across both sides of the system.",badge:`${s.snapshot.users.length} users`}),e.jsx(he,{}),e.jsx(Fe,{open:m,onOpenChange:d,user:n,grants:(t==null?void 0:t.grants)??[],ownership:n?o.get(n.id)??null:null,xp:n?x.get(n.id)??null:null,pending:c.isPending,onSubmit:async r=>{await c.mutateAsync(r)},onOpenRelationship:r=>{d(!1),p(r),w(!0)}}),e.jsx($e,{open:v,onOpenChange:w,grant:N,grants:(t==null?void 0:t.grants)??[],pending:h.isPending,onSubmit:async r=>{await h.mutateAsync({grantId:r.grantId,patch:r.patch}),r.applyToReverse&&r.reverseGrantId&&await h.mutateAsync({grantId:r.reverseGrantId,patch:r.patch})}}),e.jsxs(F,{className:"grid gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:U,children:"Multi-user posture"}),e.jsx("div",{className:`mt-2 ${M}`,children:(t==null?void 0:t.posture.summary)??"Forge is preparing modular user access while keeping the current posture permissive."})]}),e.jsx(b,{tone:"meta",children:(t==null?void 0:t.posture.accessModel)??"permissive"})]}),e.jsx("div",{className:`flex items-center gap-3 ${R} px-4 py-3`,children:e.jsx(T,{value:f,onChange:r=>y(r.target.value),placeholder:"Search human, bot, @handle, or description"})})]}),e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(F,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:U,children:"Multi-agent onboarding"}),e.jsx("div",{className:`mt-2 ${M}`,children:"Forge now treats the users graph as the collaboration control plane. Create each human or bot here, keep the runtime shared, then narrow only the specific arrows that should stop seeing, coordinating, planning, or affecting another user."})]}),e.jsx(b,{tone:"meta",children:"default open"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsxs("div",{className:`${R} px-4 py-3`,children:[e.jsx("div",{className:U,children:"Directional edges"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:L.totalEdges})]}),e.jsxs("div",{className:`${R} px-4 py-3`,children:[e.jsx("div",{className:U,children:"Fully open"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:L.fullyOpenEdges})]}),e.jsxs("div",{className:`${R} px-4 py-3`,children:[e.jsx("div",{className:U,children:"Coordination"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:L.coordinationEdges})]}),e.jsxs("div",{className:`${R} px-4 py-3`,children:[e.jsx("div",{className:U,children:"Execution control"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:L.executionEdges})]})]}),e.jsxs("div",{className:`grid gap-2 ${M}`,children:[e.jsx("div",{children:"1. Create the human and bot users that should exist in the shared Forge system."}),e.jsx("div",{children:"2. Point OpenClaw, Hermes, and the browser at the same Forge runtime and storage root."}),e.jsx("div",{children:"3. Use the graph below to decide what each direction can see, message, plan, or change."}),e.jsx("div",{children:"4. Keep strategy drafting open while the plan is negotiated, then lock the strategy once it becomes the contract."})]})]}),e.jsx(Me,{users:(t==null?void 0:t.users)??s.snapshot.users,grants:(t==null?void 0:t.grants)??[],selectedGrantId:oe,selectedUserId:le,onOpenUser:r=>{const l=((t==null?void 0:t.users)??s.snapshot.users).find(j=>j.id===r)??null;p(null),i(l),d(!0)},onOpenGrant:r=>{i(null),p(r),w(!0)}}),e.jsxs(F,{className:"grid gap-3",children:[e.jsx("div",{className:U,children:"Agent onboarding"}),e.jsx("div",{className:M,children:"OpenClaw, Hermes, and the Forge UI all read this same multi-user graph. Keep the defaults open while you are still wiring collaboration, then narrow specific arrows when one user or agent should stop seeing, messaging, planning, or changing another user's work."}),e.jsx("div",{className:M,children:"Forge now treats every owner as either human or bot, keeps search cross-user by default, and allows cross-owner links plus explicit coordination lanes between projects, tasks, notes, and strategies."}),e.jsx("div",{children:e.jsx(ce,{to:"/settings/agents",className:"inline-flex min-h-10 items-center justify-center rounded-[var(--radius-control)] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-2 text-[13px] font-medium text-[var(--ui-ink-strong)] transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]",children:"Open agent onboarding"})})]})]}),e.jsx(F,{children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:U,children:"User directory"}),e.jsx("div",{className:`mt-2 ${M}`,children:"Open any user to edit its identity and jump into the exact directional relationship lanes from the user settings flow."})]}),e.jsx(J,{onClick:()=>{p(null),i(null),d(!0)},children:"Create user"})]})}),e.jsx("div",{className:"grid gap-5",children:[{title:"Human users",users:V.humans},{title:"Bot users",users:V.bots}].map(r=>e.jsxs(F,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:U,children:r.title}),e.jsx(b,{tone:"meta",children:r.users.length})]}),e.jsx("div",{className:"mt-4 grid gap-3",children:r.users.map(l=>{var j,W,z,K,Q,q;return e.jsx("div",{className:`${R} px-4 py-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(E,{user:l}),e.jsxs("div",{className:"mt-3 text-sm text-[var(--ui-ink-soft)]",children:["@",l.handle]}),e.jsx("div",{className:`mt-2 ${M}`,children:l.description||"No description yet."}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(b,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:[((j=x.get(l.id))==null?void 0:j.totalXp)??0," XP"]}),e.jsxs(b,{tone:"meta",children:[((W=x.get(l.id))==null?void 0:W.weeklyXp)??0," weekly"]}),e.jsxs(b,{tone:"meta",children:[((z=x.get(l.id))==null?void 0:z.rewardEventCount)??0," ","rewards"]}),Object.entries(((K=o.get(l.id))==null?void 0:K.entityCounts)??{}).sort((I,D)=>D[1]-I[1]).slice(0,4).map(([I,D])=>e.jsxs(b,{tone:"meta",children:[D," ",I]},`${l.id}-${I}`)),e.jsxs(b,{tone:"meta",children:[((Q=o.get(l.id))==null?void 0:Q.totalOwnedEntities)??0," ","owned"]})]}),e.jsxs("div",{className:`mt-3 ${te}`,children:["Can currently read:"," ",(k.get(l.id)??[]).map(I=>`${I.displayName} (${I.kind})`).join(", ")||"no other users"]}),(q=x.get(l.id))!=null&&q.lastRewardAt?e.jsxs("div",{className:`mt-2 ${te}`,children:["Last XP movement:"," ",new Date(x.get(l.id).lastRewardAt).toLocaleString()]}):null]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(J,{variant:"secondary",onClick:()=>{p(null),i(l),d(!0)},children:"Open settings"})})]})},l.id)})})]},r.title))})]})]})}export{We as SettingsUsersPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as d,j as e,aC as y,bg as k,cD as W}from"./vendor-Dnkkx2co.js";import{j as K,i as L,k as l}from"./state-vCcAT5Hq.js";import{S as P}from"./settings-section-nav-DP9o4peU.js";import{P as M}from"./page-hero-ffKzgyW3.js";import{bV as Q,bW as $,bX as A,L as F,E as j,B as c,C as N,aq as R,I as S,bY as q}from"./index-EqQsXoat.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";const C="inline-flex min-h-11 max-w-full items-center justify-center rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3 text-sm font-medium text-[var(--ui-ink-strong)] shadow-[var(--ui-shadow-soft)] transition hover:bg-[var(--ui-surface-hover)]",E="grid min-w-0 gap-3 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",I="grid min-w-0 gap-1 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",O="min-w-0 rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-3 text-sm text-[var(--ui-ink-strong)] outline-none transition focus:border-[var(--primary)]/35 focus:bg-[var(--ui-surface-3)]",p="text-[var(--ui-ink-strong)]",T="text-[var(--ui-ink-soft)]",n="text-[var(--ui-ink-faint)]";function _(){var w;const t=K(),[r,g]=d.useState(""),[m,u]=d.useState(""),[x,h]=d.useState("personal"),s=L({queryKey:["forge-wiki-settings"],queryFn:q}),o=async()=>{await Promise.all([t.invalidateQueries({queryKey:["forge-wiki-settings"]}),t.invalidateQueries({queryKey:["forge-wiki-pages"]}),t.invalidateQueries({queryKey:["forge-wiki-page"]}),t.invalidateQueries({queryKey:["forge-wiki-search"]})])},v=l({mutationFn:()=>Q({label:r.trim(),description:m.trim(),visibility:x}),onSuccess:async()=>{g(""),u(""),h("personal"),await o()}}),b=l({mutationFn:()=>$(),onSuccess:o}),f=l({mutationFn:()=>A(),onSuccess:o});if(s.isLoading)return e.jsx(F,{eyebrow:"KarpaWiki settings",title:"Loading KarpaWiki controls",description:"Fetching spaces and profile configuration for KarpaWiki."});if(s.isError)return e.jsx(j,{eyebrow:"KarpaWiki settings",error:s.error,onRetry:()=>void s.refetch()});const a=(w=s.data)==null?void 0:w.settings;return a?e.jsxs("div",{className:"mx-auto grid w-full max-w-[1440px] gap-5",children:[e.jsx(M,{eyebrow:"SQLite memory",title:"KarpaWiki Settings",titleText:"KarpaWiki Settings",description:"Manage SQLite-backed spaces and refresh KarpaWiki indexes. Model, OAuth, and embedding profile setup lives in Models.",badge:`${a.spaces.length} spaces · ${a.embeddingProfiles.length} embedding profiles`,actions:e.jsxs(e.Fragment,{children:[e.jsxs(y,{to:"/settings/models",className:C,children:["Open model settings",e.jsx(k,{className:"ml-2 size-4"})]}),e.jsx(c,{variant:"secondary",pending:b.isPending,pendingLabel:"Syncing",onClick:()=>void b.mutateAsync(),children:"Refresh indexes"}),e.jsx(c,{pending:f.isPending,pendingLabel:"Reindexing",onClick:()=>void f.mutateAsync(),disabled:a.embeddingProfiles.length===0,children:"Reindex embeddings"})]})}),e.jsx(P,{}),e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(N,{className:"grid gap-4",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsx("div",{className:`text-sm ${p}`,children:"Model configuration moved"}),e.jsx("div",{className:`text-xs leading-5 ${n}`,children:"KarpaWiki ingest uses the OpenAI Codex OAuth connection selected in Models. OpenAI Platform API keys and embedding profile setup are not configured from this page."})]})}),e.jsxs(y,{to:"/settings/models",className:`${C} w-fit`,children:["Manage KarpaWiki models and embeddings",e.jsx(k,{className:"ml-2 size-4"})]})]}),e.jsx("div",{className:"grid gap-5",children:e.jsxs(N,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(W,{className:"size-4 text-[var(--secondary)]"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`text-sm ${p}`,children:"Spaces"}),e.jsx(R,{content:"Canonical knowledge lives in SQLite notes, with Forge maintaining metadata, links, search, and optional embedding indexes in the database. Text search and entity-linked search work without embeddings, while semantic search stays additive and profile-driven. Ingest jobs can create pages and media assets now, with room for richer OCR, transcription, and multimodal compilation later.",label:"Explain the wiki operating model"})]}),e.jsx("div",{className:`text-xs leading-5 ${n}`,children:"Personal and shared wiki spaces map to explicit SQLite namespaces."})]})]}),e.jsx("div",{className:"grid gap-3",children:a.spaces.map(i=>e.jsxs("div",{className:I,children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:`min-w-0 break-words [overflow-wrap:anywhere] ${p}`,children:i.label}),e.jsx("div",{className:`text-xs uppercase tracking-[0.16em] ${n}`,children:i.visibility})]}),e.jsx("div",{className:`break-words text-xs [overflow-wrap:anywhere] ${n}`,children:i.slug}),e.jsx("div",{className:`text-sm ${T}`,children:i.description||"No description yet."})]},i.id))}),e.jsxs("div",{className:E,children:[e.jsx(S,{value:r,onChange:i=>g(i.target.value),placeholder:"New space label"}),e.jsx(S,{value:m,onChange:i=>u(i.target.value),placeholder:"Description"}),e.jsxs("select",{className:O,value:x,onChange:i=>h(i.target.value),children:[e.jsx("option",{value:"personal",children:"Personal"}),e.jsx("option",{value:"shared",children:"Shared"})]}),e.jsx(c,{pending:v.isPending,pendingLabel:"Creating",disabled:!r.trim(),onClick:()=>void v.mutateAsync(),children:"Create space"})]})]})})]})]}):e.jsx(j,{eyebrow:"KarpaWiki settings",error:new Error("Forge returned an empty KarpaWiki settings payload."),onRetry:()=>void s.refetch()})}export{_ as SettingsWikiPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as g,j as e,aV as re,cq as ae,bX as te}from"./vendor-Dnkkx2co.js";import{j as se,i as _,k as ie}from"./state-vCcAT5Hq.js";import{u as ne,eC as de,S as le,E as ce,ch as oe,eD as ue,eE as me,C as w,c as v,eF as xe,Z as b,B as C,I as Q,T as ve,m as pe,bL as ge,eG as he,bw as fe,bx as be,by as je,bz as ye,bC as ke}from"./index-EqQsXoat.js";import{P as Ne}from"./page-hero-ffKzgyW3.js";import{p as we,b as Se}from"./health-link-options-Cpx8w7uM.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";const _e=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],W={awake:{label:"Awake",strong:"var(--warning)",soft:"var(--ui-warning-soft)",text:"text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]"},core:{label:"Core",strong:"var(--primary)",soft:"var(--ui-accent-soft)",text:"text-[color-mix(in_srgb,var(--primary)_78%,var(--ui-ink-strong)_22%)]"},deep:{label:"Deep",strong:"var(--success)",soft:"var(--ui-success-soft)",text:"text-[color-mix(in_srgb,var(--success)_78%,var(--ui-ink-strong)_22%)]"},rem:{label:"REM",strong:"var(--info)",soft:"var(--ui-info-soft)",text:"text-[color-mix(in_srgb,var(--info)_78%,var(--ui-ink-strong)_22%)]"},in_bed:{label:"In bed",strong:"color-mix(in_srgb,var(--ui-ink-strong)_46%,transparent)",soft:"var(--ui-surface-3)",text:"text-[var(--ui-ink-medium)]"},asleep_unspecified:{label:"Asleep",strong:"var(--primary)",soft:"var(--ui-accent-soft)",text:"text-[color-mix(in_srgb,var(--primary)_78%,var(--ui-ink-strong)_22%)]"}};function I(r){return W[r]??W.asleep_unspecified}function p(r){if(r<=0)return"0m";const a=Math.floor(r/3600),t=Math.round(r%3600/60);return a===0?`${t}m`:t===0?`${a}h`:`${a}h ${t}m`}function Ae(r){const a=Math.round(r/60);return a===0?"on baseline":`${a>0?"+":"-"}${Math.abs(a)}m`}function T(r){return`${Math.round(r*100)}%`}function A(r,a){return r?new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",timeZone:a}).format(new Date(r)):"n/a"}function O(r,a){return new Intl.DateTimeFormat(void 0,{weekday:"long",day:"numeric",month:"long",timeZone:a}).format(new Date(r))}function q(r,a,t){return`${A(r,t)} - ${A(a,t)}`}function Te(r){const[a,t]=r.split("-").map(Number);return new Intl.DateTimeFormat(void 0,{month:"long",year:"numeric"}).format(new Date(a,(t??1)-1,1))}function U(r){const a=new Date(r),t=(r.getDay()+6)%7;return a.setDate(r.getDate()-t),a}function Re(r){const a=U(r);return a.setDate(a.getDate()+6),a}function Me(r){const a=r.getFullYear(),t=`${r.getMonth()+1}`.padStart(2,"0"),s=`${r.getDate()}`.padStart(2,"0");return`${a}-${t}-${s}`}function B(r){return{qualitySummary:typeof r.annotations.qualitySummary=="string"?r.annotations.qualitySummary:"",notes:typeof r.annotations.notes=="string"?r.annotations.notes:"",tagsText:Array.isArray(r.annotations.tags)?r.annotations.tags.join(", "):"",linkValues:Array.isArray(r.links)?r.links.map(a=>`${a.entityType}:${a.entityId}`):[]}}function De(r,a){if(!r)return[];const[t,s]=r.split("-").map(Number),n=new Date(t,(s??1)-1,1),u=new Date(t,s??1,0),d=U(n),x=Re(u),l=new Map(a.map(c=>[c.dateKey,c])),i=[];for(const c=new Date(d);c<=x;c.setDate(c.getDate()+1)){const y=Me(c);i.push({dateKey:y,dayNumber:c.getDate(),outsideMonth:c.getMonth()!==n.getMonth(),sleep:l.get(y)??null})}return i}function Ie(r){return r>0?"text-[color-mix(in_srgb,var(--success)_78%,var(--ui-ink-strong)_22%)]":r<0?"text-[color-mix(in_srgb,var(--danger)_78%,var(--ui-ink-strong)_22%)]":"text-[var(--ui-ink-medium)]"}function G(r){return r==="recharged"||r==="recovered"?"bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_78%,var(--ui-ink-strong)_22%)]":r==="steady"||r==="stable"?"bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_78%,var(--ui-ink-strong)_22%)]":r==="fragile"||r==="strained"?"bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]":r==="depleted"?"bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_78%,var(--ui-ink-strong)_22%)]":"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]"}function Be(r){return r==="provider_raw"?"bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_78%,var(--ui-ink-strong)_22%)]":r==="historical_raw"?"bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]":"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]"}function qe(r){return r==="provider_raw"?"Provider raw data":r==="historical_raw"?"Historical raw data":"Raw data unavailable"}function Ce(r){return r.qualityKind==="provider_native"?"bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_78%,var(--ui-ink-strong)_22%)]":"bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]"}function $e(r,a){const t=r.stage;if(typeof t=="string"&&t.trim().length>0)return t;const s=r.sourceType;if(typeof s=="string"&&s.trim().length>0)return s;const n=r.stageBreakdown;if(Array.isArray(n)&&n.length>0){const u=n[0];if(u&&typeof u=="object"&&typeof u.stage=="string")return(u.stage||"asleep_unspecified").trim()}return a.includes("awake")?"awake":"asleep_unspecified"}function Ee(r){const a=r,t=(a==null?void 0:a.segments)??(a==null?void 0:a.rawSegments)??[],s=(a==null?void 0:a.auditLogs)??(a==null?void 0:a.rawLogs)??[],n=a!=null&&a.sourceRecords&&a.sourceRecords.length>0?a.sourceRecords:s.filter(d=>typeof d.startedAt=="string"&&typeof d.endedAt=="string").map(d=>({id:d.id,importRunId:d.importRunId,pairingSessionId:d.pairingSessionId,sleepSessionId:d.sleepSessionId,userId:d.userId,provider:d.source,providerRecordType:d.logType,providerRecordUid:d.externalUid??d.id,sourceDevice:"",sourceTimezone:d.sourceTimezone,localDateKey:d.localDateKey,startedAt:d.startedAt,endedAt:d.endedAt,rawStage:$e(d.payload,d.logType),rawValue:null,qualityKind:"historical_import",payload:d.payload,metadata:d.metadata,ingestedAt:d.createdAt})),u=(a==null?void 0:a.rawDataStatus)??(n.length>0?"historical_raw":"raw_unavailable");return{sourceRecords:n,segments:t,auditLogs:s,rawDataStatus:u}}function J({stages:r}){const a=r.reduce((t,s)=>t+s.seconds,0);return r.length===0||a===0?e.jsx("div",{className:"rounded-[18px] border border-dashed border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-4 text-sm text-[var(--ui-ink-muted)]",children:"No stage composition was stored for this night yet."}):e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"flex h-3 overflow-hidden rounded-full bg-[var(--ui-surface-2)]",children:r.map(t=>{const s=I(t.stage);return e.jsx("div",{className:"h-full",style:{width:`${Math.max(4,t.seconds/a*100)}%`,background:s.strong},title:`${s.label} · ${p(t.seconds)}`},t.stage)})}),e.jsx("div",{className:"grid gap-2 sm:grid-cols-2 xl:grid-cols-4",children:r.map(t=>{const s=I(t.stage),n="percentage"in t&&typeof t.percentage=="number"?t.percentage:a>0?t.seconds/a:0;return e.jsxs("div",{className:"rounded-[16px] border border-[var(--ui-border-subtle)] px-3 py-3",style:{background:s.soft},children:[e.jsx("div",{className:b("text-sm font-medium",s.text),children:s.label}),e.jsx("div",{className:"mt-1 text-lg text-[var(--ui-ink-strong)]",children:p(t.seconds)}),e.jsx("div",{className:"text-xs text-[var(--ui-ink-muted)]",children:T(n)})]},t.stage)})})]})}function H({blocks:r,selectedBlockId:a,onSelect:t}){return e.jsxs("div",{className:"relative h-12 overflow-hidden rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]",children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[image:var(--ui-surface-section)] bg-[length:25%_100%]"}),r.map(s=>{const n=I(s.stage),u=a===s.id;return e.jsx("button",{type:"button",onClick:()=>t(s.id),className:b("absolute inset-y-[5px] rounded-[12px] border transition",u?"border-[var(--ui-border-strong)] shadow-[var(--ui-shadow-soft)]":"border-[var(--ui-border-subtle)]"),style:{left:`${s.offsetRatio*100}%`,width:`${Math.max(s.widthRatio*100,1.8)}%`,background:n.strong},title:`${s.label} · ${p(s.durationSeconds)} · ${s.startedAt} - ${s.endedAt}`,children:s.widthRatio>.13?e.jsx("span",{className:"truncate px-2 text-[10px] font-medium text-[var(--ui-ink-on-accent)]",children:s.label}):null},s.id)})]})}function Ke({timeline:r,timeZone:a}){var l,i;const t=r.blocks.filter(c=>c.lane==="in_bed"),s=r.blocks.filter(c=>c.lane==="sleep"),n=((l=s[0])==null?void 0:l.id)??((i=t[0])==null?void 0:i.id)??null,[u,d]=g.useState(n);g.useEffect(()=>{d(n)},[n,r.startedAt,r.endedAt,r.totalSeconds]);const x=r.blocks.find(c=>c.id===u)??null;return r.hasRawSegments?e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-3",children:[t.length>0?e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"In bed window"}),e.jsx(H,{blocks:t,selectedBlockId:u,onSelect:d})]}):null,e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:r.hasSleepStageData?"Sleep phases":"Recorded sleep coverage"}),e.jsx(H,{blocks:s.length>0?s:t,selectedBlockId:u,onSelect:d})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs text-[var(--ui-ink-muted)]",children:[e.jsx("span",{children:A(r.startedAt,a)}),e.jsx("span",{children:p(r.totalSeconds)}),e.jsx("span",{children:A(r.endedAt,a)})]}),x?e.jsx("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-4",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:b("text-sm font-medium",I(x.stage).text),children:x.label}),e.jsxs("div",{className:"mt-1 text-sm text-[var(--ui-ink-muted)]",children:[A(x.startedAt,a)," -"," ",A(x.endedAt,a)]})]}),e.jsx(v,{tone:"meta",children:p(x.durationSeconds)})]})}):null]}):e.jsx("div",{className:"rounded-[18px] border border-dashed border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-5 text-sm text-[var(--ui-ink-muted)]",children:"Phase timing is unavailable for this night. Forge still keeps the canonical overnight summary, but the companion did not store segment-level timing."})}function Fe({latestNight:r}){return r?e.jsx(w,{className:"overflow-hidden border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] p-0",children:e.jsxs("div",{className:"relative overflow-hidden px-6 py-6 sm:px-7 sm:py-7",children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[image:var(--ui-surface-section)]"}),e.jsxs("div",{className:"relative grid gap-6 xl:grid-cols-[minmax(0,1.2fr)_minmax(0,0.8fr)]",children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx(v,{className:b("border-transparent",G(r.recoveryState)),children:r.qualitativeState}),e.jsx(v,{tone:"meta",children:r.sourceTimezone}),r.hasReflection?e.jsx(v,{tone:"meta",children:"Has reflection"}):null,r.hasRawSegments?e.jsxs(v,{tone:"meta",children:[r.rawSegmentCount," raw segments"]}):null]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.2em] text-[var(--ui-ink-muted)]",children:"Last night"}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-end gap-x-4 gap-y-2",children:[e.jsx("div",{className:"text-[clamp(2.5rem,6vw,5rem)] font-medium leading-none text-[var(--ui-ink-strong)]",children:p(r.asleepSeconds)}),e.jsxs("div",{className:"pb-2 text-sm text-[var(--ui-ink-muted)]",children:["asleep across ",q(r.startedAt,r.endedAt,r.sourceTimezone)]})]}),e.jsx("div",{className:"mt-3 text-sm text-[var(--ui-ink-medium)]",children:O(r.endedAt,r.sourceTimezone)}),r.qualitySummary?e.jsx("div",{className:"mt-4 max-w-2xl text-sm leading-6 text-[var(--ui-ink-medium)]",children:r.qualitySummary}):e.jsx("div",{className:"mt-4 max-w-2xl text-sm leading-6 text-[var(--ui-ink-muted)]",children:"Canonical overnight summary computed from synced sleep segments, with raw evidence still available underneath."})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"In bed"}),e.jsx("div",{className:"mt-2 text-xl text-[var(--ui-ink-strong)]",children:p(r.timeInBedSeconds)})]}),e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Score"}),e.jsx("div",{className:"mt-2 text-xl text-[var(--ui-ink-strong)]",children:r.score??"n/a"})]}),e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Regularity"}),e.jsx("div",{className:"mt-2 text-xl text-[var(--ui-ink-strong)]",children:r.regularity??"n/a"})]}),e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Efficiency"}),e.jsx("div",{className:"mt-2 text-xl text-[var(--ui-ink-strong)]",children:T(r.efficiency)})]})]})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-5 py-5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Baseline"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:"Compared with recent nights"})]}),e.jsx(ae,{className:"size-5 text-[var(--primary)]"})]}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[16px] bg-[var(--ui-surface-2)] px-4 py-3",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-medium)]",children:"7-night average"}),e.jsx("span",{className:"text-sm text-[var(--ui-ink-strong)]",children:p(r.weeklyAverageSleepSeconds)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[16px] bg-[var(--ui-surface-2)] px-4 py-3",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-medium)]",children:"Versus baseline"}),e.jsx("span",{className:b("text-sm",Ie(r.deltaFromWeeklyAverageSeconds)),children:Ae(r.deltaFromWeeklyAverageSeconds)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[16px] bg-[var(--ui-surface-2)] px-4 py-3",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-medium)]",children:"Bedtime drift"}),e.jsxs("span",{className:"text-sm text-[var(--ui-ink-strong)]",children:[r.bedtimeDriftMinutes??0,"m"]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[16px] bg-[var(--ui-surface-2)] px-4 py-3",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-medium)]",children:"Wake drift"}),e.jsxs("span",{className:"text-sm text-[var(--ui-ink-strong)]",children:[r.wakeDriftMinutes??0,"m"]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[16px] bg-[var(--ui-surface-2)] px-4 py-3",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-medium)]",children:"Restorative share"}),e.jsx("span",{className:"text-sm text-[var(--ui-ink-strong)]",children:T(r.restorativeShare)})]})]})]}),e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-5 py-5",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Stage composition"}),e.jsx("div",{className:"mt-4",children:e.jsx(J,{stages:r.stageBreakdown})})]})]})]})]})}):e.jsxs(w,{className:"overflow-hidden p-6",children:[e.jsx("div",{className:"text-sm uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Sleep"}),e.jsx("div",{className:"mt-4 text-2xl text-[var(--ui-ink-strong)]",children:"No overnight sleep yet"}),e.jsx("div",{className:"mt-3 max-w-2xl text-sm leading-6 text-[var(--ui-ink-muted)]",children:"The sleep page will switch to a night-first summary once the companion syncs a canonical overnight session."})]})}function F({title:r,value:a,description:t}){return e.jsxs(w,{className:"h-full border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:r}),e.jsx("div",{className:"mt-3 text-3xl text-[var(--ui-ink-strong)]",children:a}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-muted)]",children:t})]})}function ze({days:r,selectedSleepId:a,onSelect:t}){const s=g.useMemo(()=>Array.from(new Set(r.map(l=>l.dateKey.slice(0,7)))).sort((l,i)=>l.localeCompare(i)),[r]),[n,u]=g.useState(s[s.length-1]??"");g.useEffect(()=>{if(s.length===0){u("");return}s.includes(n)||u(s[s.length-1]??"")},[n,s]);const d=s.indexOf(n),x=g.useMemo(()=>De(n,r),[r,n]);return n?e.jsx(w,{className:"overflow-hidden border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] p-0",children:e.jsxs("div",{className:"grid gap-5 px-5 py-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Sleep calendar"}),e.jsx("div",{className:"mt-2 text-xl text-[var(--ui-ink-strong)]",children:Te(n)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{type:"button",variant:"secondary",className:"h-9 rounded-full",disabled:d<=0,onClick:()=>u(s[Math.max(0,d-1)]??n),children:"Previous"}),e.jsx(C,{type:"button",variant:"secondary",className:"h-9 rounded-full",disabled:d===-1||d>=s.length-1,onClick:()=>u(s[Math.min(s.length-1,d+1)]??n),children:"Next"})]})]}),e.jsx("div",{className:"grid grid-cols-7 gap-2 text-center text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-muted)]",children:_e.map(l=>e.jsx("div",{children:l},l))}),e.jsx("div",{className:"grid grid-cols-7 gap-2",children:x.map(l=>{const i=l.sleep,c=(i==null?void 0:i.sleepId)===a,y=i&&typeof i.score=="number"?i.score>=80?"var(--ui-success-soft)":i.score>=65?"var(--ui-info-soft)":"var(--ui-warning-soft)":"var(--ui-surface-2)";return e.jsxs("button",{type:"button",disabled:!i,"aria-pressed":c,"aria-label":`Select sleep for ${l.dateKey}`,onClick:()=>{i&&(u(i.dateKey.slice(0,7)),t(i.sleepId,i.dateKey.slice(0,7)))},className:b("min-h-[90px] rounded-[18px] border px-2 py-2 text-left transition",i?"border-[var(--ui-border-subtle)] hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-3)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]",c&&"border-[var(--primary)] bg-[var(--primary)]/12",l.outsideMonth&&!i&&"opacity-35"),style:i?{background:y}:void 0,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("span",{className:b("text-sm",l.outsideMonth?"text-[var(--ui-ink-muted)]":"text-[var(--ui-ink-medium)]"),children:l.dayNumber}),i!=null&&i.hasReflection?e.jsx("span",{className:"size-2 rounded-full bg-[var(--success)]"}):null]}),i?e.jsxs("div",{className:"mt-4 grid gap-1",children:[e.jsxs("div",{className:"text-lg text-[var(--ui-ink-strong)]",children:[i.sleepHours.toFixed(1),"h"]}),e.jsxs("div",{className:"text-xs text-[var(--ui-ink-muted)]",children:[i.score??"n/a"," score"]}),e.jsx("div",{className:"text-xs text-[var(--ui-ink-muted)]",children:i.hasRawSegments?"phases available":"summary only"})]}):null]},l.dateKey)})})]})}):e.jsx(w,{className:"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-5 py-8 text-sm leading-6 text-[var(--ui-ink-muted)]",children:"No canonical nights are available for the calendar yet."})}function z({active:r,children:a,onClick:t}){return e.jsx("button",{type:"button",onClick:t,className:b("rounded-full border px-4 py-2 text-sm transition",r?"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)] hover:text-[var(--ui-ink-strong)]"),children:a})}function Le({session:r,draft:a,rawDetail:t,rawDetailLoading:s,pending:n,tab:u,linkOptions:d,onTabChange:x,onDraftChange:l,onSave:i}){const[c,y]=g.useState(null),k=g.useMemo(()=>Ee(t),[t]),$=typeof r.derived.efficiency=="number"?r.derived.efficiency:r.timeInBedSeconds>0?r.asleepSeconds/r.timeInBedSeconds:0,E=typeof r.derived.restorativeShare=="number"?r.derived.restorativeShare:0,R=typeof r.derived.recoveryState=="string"?r.derived.recoveryState:null;return e.jsx(w,{className:"overflow-hidden border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] p-0",children:e.jsxs("div",{className:"grid gap-5 px-5 py-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(v,{className:b("border-transparent",G(R)),children:R?R.replaceAll("_"," "):"Canonical night"}),e.jsxs(v,{tone:"meta",children:[r.rawSegmentCount," raw segments"]}),e.jsx(v,{tone:"meta",children:r.sourceTimezone})]}),e.jsx("div",{className:"mt-3 text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Selected night"}),e.jsx("div",{className:"mt-2 text-2xl text-[var(--ui-ink-strong)]",children:O(r.endedAt,r.sourceTimezone)}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-muted)]",children:q(r.startedAt,r.endedAt,r.sourceTimezone)})]}),e.jsxs("div",{className:"grid gap-2 text-right",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Summary"}),e.jsx("div",{className:"text-3xl text-[var(--ui-ink-strong)]",children:p(r.asleepSeconds)}),e.jsx("div",{className:"text-sm text-[var(--ui-ink-muted)]",children:"asleep"})]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"In bed"}),e.jsx("div",{className:"mt-2 text-xl text-[var(--ui-ink-strong)]",children:p(r.timeInBedSeconds)})]}),e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Awake"}),e.jsx("div",{className:"mt-2 text-xl text-[var(--ui-ink-strong)]",children:p(r.awakeSeconds)})]}),e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Efficiency"}),e.jsx("div",{className:"mt-2 text-xl text-[var(--ui-ink-strong)]",children:T($)})]}),e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Restorative"}),e.jsx("div",{className:"mt-2 text-xl text-[var(--ui-ink-strong)]",children:T(E)})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(z,{active:u==="summary",onClick:()=>x("summary"),children:"Summary"}),e.jsx(z,{active:u==="reflection",onClick:()=>x("reflection"),children:"Reflection"}),e.jsx(z,{active:u==="raw",onClick:()=>x("raw"),children:"Show raw data"})]}),u==="summary"?e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Phase timeline"}),e.jsx("div",{className:"mt-4",children:s?e.jsx("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-6 text-sm text-[var(--ui-ink-muted)]",children:"Loading phase timing from raw sleep segments…"}):e.jsx(Ke,{timeline:(t==null?void 0:t.phaseTimeline)??{startedAt:r.startedAt,endedAt:r.endedAt,totalSeconds:Math.max(0,Math.round((new Date(r.endedAt).getTime()-new Date(r.startedAt).getTime())/1e3)),hasRawSegments:!1,hasSleepStageData:!1,blocks:[]},timeZone:r.sourceTimezone})})]}),e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Stage composition"}),e.jsx("div",{className:"mt-4",children:e.jsx(J,{stages:r.stageBreakdown})})]})]}):null,u==="reflection"?e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-muted)]",children:"Quality summary"}),e.jsx(Q,{value:a.qualitySummary,onChange:o=>l({qualitySummary:o.target.value}),placeholder:"Recovered after a late evening, but sleep onset drifted."})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-muted)]",children:"Night notes"}),e.jsx(ve,{className:"min-h-[200px]",value:a.notes,onChange:o=>l({notes:o.target.value}),placeholder:"What shaped this night, and what should we remember about it?"})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-muted)]",children:"Tags"}),e.jsx(Q,{value:a.tagsText,onChange:o=>l({tagsText:o.target.value}),placeholder:"travel, stress, good-routine, late-caffeine"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-muted)]",children:"Linked context"}),e.jsx(pe,{options:d,selectedValues:a.linkValues,onChange:o=>l({linkValues:o}),placeholder:"Search goals, tasks, habits, beliefs, reports, or patterns…"})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(C,{type:"button",pending:n,pendingLabel:"Saving",onClick:i,children:[e.jsx(te,{className:"size-4"}),"Save reflection"]})})]}):null,u==="raw"?e.jsxs("div",{className:"grid gap-5",children:[e.jsx("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-4 text-sm leading-6 text-[var(--ui-ink-muted)]",children:"Forge shows the canonical overnight session by default. This view reveals the evidence stack underneath it: raw provider or historical imported records first, then Forge-normalized sleep segments."}),s?e.jsx("div",{className:"text-sm text-[var(--ui-ink-muted)]",children:"Loading raw sleep evidence…"}):null,s?null:e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(v,{className:b("border-transparent",Be(k.rawDataStatus)),children:qe(k.rawDataStatus)}),k.rawDataStatus==="historical_raw"?e.jsx(v,{tone:"meta",children:"Partial evidence"}):null]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Raw data"}),k.sourceRecords.length?k.sourceRecords.map(o=>e.jsxs("div",{className:"rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(v,{className:b("border-transparent",Ce(o)),children:o.qualityKind==="provider_native"?"Provider raw":"Historical raw"}),e.jsx(v,{tone:"meta",className:"capitalize",children:o.rawStage.replaceAll("_"," ")}),e.jsx("span",{className:"text-sm text-[var(--ui-ink-medium)]",children:q(o.startedAt,o.endedAt,o.sourceTimezone)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-[var(--ui-ink-muted)]",children:o.providerRecordType.replaceAll("_"," ")}),e.jsx(C,{type:"button",variant:"secondary",className:"h-8 rounded-full px-3",onClick:()=>y(M=>M===o.id?null:o.id),children:c===o.id?"Hide JSON":"See JSON"})]})]}),e.jsx("div",{className:"mt-3 text-sm text-[var(--ui-ink-muted)]",children:p(Math.max(0,Math.round((new Date(o.endedAt).getTime()-new Date(o.startedAt).getTime())/1e3)))}),c===o.id?e.jsx("pre",{className:"mt-3 overflow-x-auto rounded-[14px] border border-[var(--ui-border-subtle)] bg-[var(--ui-code-bg)] p-3 text-xs leading-6 text-[var(--ui-ink-medium)]",children:JSON.stringify({payload:o.payload,metadata:o.metadata},null,2)}):null]},o.id)):e.jsx("div",{className:"rounded-[16px] border border-dashed border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-4 text-sm text-[var(--ui-ink-muted)]",children:"No raw data was stored for this night."})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Sleep segments"}),k.segments.length?k.segments.map(o=>e.jsx("div",{className:"rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(v,{tone:"meta",className:"capitalize",children:o.stage.replaceAll("_"," ")}),e.jsx(v,{tone:"meta",children:o.qualityKind==="provider_native"?"provider-backed":"historical"}),e.jsx("span",{className:"text-sm text-[var(--ui-ink-medium)]",children:q(o.startedAt,o.endedAt,o.sourceTimezone)})]}),e.jsx("span",{className:"text-sm text-[var(--ui-ink-muted)]",children:p(Math.max(0,Math.round((new Date(o.endedAt).getTime()-new Date(o.startedAt).getTime())/1e3)))})]})},o.id)):e.jsx("div",{className:"rounded-[16px] border border-dashed border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-4 text-sm text-[var(--ui-ink-muted)]",children:"No normalized sleep segments were stored for this night."})]})]})]}):null]})})}function Xe(){var V;const r=ne(),a=se(),[t,s]=g.useState({}),[n,u]=g.useState(null),[d,x]=g.useState("summary"),l=Array.isArray(r==null?void 0:r.selectedUserIds)?r.selectedUserIds:[],i=r==null?void 0:r.snapshot,c=_({queryKey:["forge-sleep",...l],queryFn:async()=>(await ge(l)).sleep}),y=_({queryKey:["forge-sleep-raw",n],enabled:!!n,queryFn:async()=>he(n)}),k=_({queryKey:["forge-sleep-values",...l],queryFn:async()=>(await fe(l)).values}),$=_({queryKey:["forge-sleep-patterns",...l],queryFn:async()=>(await be(l)).patterns}),E=_({queryKey:["forge-sleep-behaviors",...l],queryFn:async()=>(await je(l)).behaviors}),R=_({queryKey:["forge-sleep-beliefs",...l],queryFn:async()=>(await ye(l)).beliefs}),o=_({queryKey:["forge-sleep-reports",...l],queryFn:async()=>(await ke(l)).reports});g.useEffect(()=>{c.data&&s(Object.fromEntries(c.data.sessions.map(m=>[m.id,B(m)])))},[c.data]),g.useEffect(()=>{var N,j,S;if(!((N=c.data)!=null&&N.sessions.length)){u(null);return}c.data.sessions.some(K=>K.id===n)||u(((j=c.data.latestNight)==null?void 0:j.sleepId)??((S=c.data.sessions[0])==null?void 0:S.id)??null)},[n,c.data]),g.useEffect(()=>{x("summary")},[n]);const M=ie({mutationFn:async m=>de(m.sleepId,{qualitySummary:m.qualitySummary,notes:m.notes,tags:m.tagsText.split(",").map(N=>N.trim()).filter(Boolean),links:we(m.linkValues)}),onSuccess:async()=>{await a.invalidateQueries({queryKey:["forge-sleep"]}),await a.invalidateQueries({queryKey:["forge-sleep-raw"]})}});if(c.isLoading)return e.jsx(le,{eyebrow:"Sleep",title:"Loading sleep surface",description:"Reading canonical nights, calendar summaries, and sleep phase detail.",columns:2,blocks:6});if(c.isError||!c.data)return e.jsx(ce,{eyebrow:"Sleep",error:c.error??new Error("Sleep data unavailable"),onRetry:()=>void c.refetch()});const h=c.data,D=h.sessions,L=new Map(D.map(m=>[m.id,m])),f=(n?L.get(n):null)??(h.latestNight?L.get(h.latestNight.sleepId):null)??D[0]??null,P=f?t[f.id]??B(f):null,Y=Se({goals:(i==null?void 0:i.dashboard.goals)??[],projects:(i==null?void 0:i.dashboard.projects)??[],tasks:(i==null?void 0:i.dashboard.tasks)??[],habits:(i==null?void 0:i.dashboard.habits)??[],values:k.data??[],patterns:$.data??[],behaviors:E.data??[],beliefs:R.data??[],reports:o.data??[]});function X(m,N){s(j=>{const S=D.find(ee=>ee.id===m),K=j[m]??(S?B(S):{qualitySummary:"",notes:"",tagsText:"",linkValues:[]});return{...j,[m]:{...K,...N}}})}async function Z(m){const N=D.find(S=>S.id===m);if(!N)return;const j=t[m]??B(N);await M.mutateAsync({sleepId:m,qualitySummary:j.qualitySummary,notes:j.notes,tagsText:j.tagsText,linkValues:j.linkValues})}return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(Ne,{eyebrow:"Health",title:"Sleep",description:"Canonical overnight sessions first, with last-night recovery, a clickable night calendar, and raw segment evidence only when you ask for it.",badge:`${D.length} nights`}),e.jsx(oe,{}),e.jsx(ue,{children:e.jsx(Fe,{latestNight:h.latestNight})}),e.jsx(me,{children:e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,0.95fr)_minmax(0,1.05fr)]",children:[e.jsx(F,{title:"Weekly average",value:p(h.summary.averageSleepSeconds),description:"Average overnight sleep duration across the recent week, used as the baseline for the latest-night comparison."}),e.jsx(F,{title:"Regularity",value:`${h.summary.averageRegularityScore}`,description:`Average bedtime drift ${h.summary.averageBedtimeConsistencyMinutes}m and wake drift ${h.summary.averageWakeConsistencyMinutes}m.`}),e.jsx(F,{title:"Restorative share",value:T(h.summary.averageRestorativeShare),description:`Deep + REM share across recent nights, with ${h.summary.reflectiveNightCount} nights already carrying context.`}),e.jsxs(w,{className:"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]",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-[var(--ui-ink-muted)]",children:"Recent stage mix"}),e.jsx("div",{className:"mt-2 text-xl text-[var(--ui-ink-strong)]",children:"Average nightly phases"})]}),e.jsx(re,{className:"size-5 text-[var(--primary)]"})]}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:h.stageAverages.length>0?h.stageAverages.slice(0,5).map(m=>e.jsxs(v,{tone:"meta",children:[I(m.stage).label," ",p(m.averageSeconds)]},m.stage)):e.jsx("div",{className:"text-sm text-[var(--ui-ink-muted)]",children:"Stage averages will appear once nights include phase data."})})]})]})}),e.jsx(xe,{children:e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,25rem)_minmax(0,1fr)]",children:[e.jsx(ze,{days:h.calendarDays,selectedSleepId:(f==null?void 0:f.id)??null,onSelect:m=>u(m)}),f&&P?e.jsx(Le,{session:f,draft:P,rawDetail:y.data??null,rawDetailLoading:y.isLoading,pending:M.isPending&&((V=M.variables)==null?void 0:V.sleepId)===f.id,tab:d,linkOptions:Y,onTabChange:x,onDraftChange:m=>X(f.id,m),onSave:()=>void Z(f.id)}):e.jsx(w,{className:"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-6 py-8 text-sm leading-6 text-[var(--ui-ink-muted)]",children:"Pick a night from the calendar to inspect its phase timing, stage summary, and reflection context."})]})})]})}export{Xe as SleepPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as h,j as e,aC as Pe,bE as we,aV as qe,b8 as Se,bG as Qe,bX as Ze}from"./vendor-Dnkkx2co.js";import{j as Ue,i as O,k as Ge}from"./state-vCcAT5Hq.js";import{u as Xe,eH as Ye,S as Je,E as et,eI as tt,C as g,eJ as J,c,I as F,eK as at,aT as st,T as rt,m as it,B as ie,bM as nt,bw as lt,bx as ot,by as dt,bz as ct,bC as ut}from"./index-EqQsXoat.js";import{F as je}from"./faceted-token-search-DEC6ANa9.js";import{P as xt}from"./page-hero-ffKzgyW3.js";import{f as mt}from"./date-keys-Cj1G3TOn.js";import{p as ht,b as pt}from"./health-link-options-Cpx8w7uM.js";import{R as P,A as vt,C as ee,X as q,Y as W,T as Q,a as ye,e as ke,B as ne,f as gt,d as ft,g as bt,c as le,S as jt,h as yt}from"./charts-DFnEuIMB.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";function Z({className:t,children:r}){const s=h.useRef(null),[l,o]=h.useState(!1);return h.useEffect(()=>{const p=()=>{const b=s.current;o(!!(b&&b.clientWidth>0&&b.clientHeight>0))},f=window.requestAnimationFrame(p),j=typeof ResizeObserver>"u"?null:new ResizeObserver(p);return s.current&&j&&j.observe(s.current),window.addEventListener("resize",p),()=>{window.cancelAnimationFrame(f),j==null||j.disconnect(),window.removeEventListener("resize",p)}},[]),e.jsx("div",{ref:s,className:t,children:l?r:null})}const G={below_z1:"#94a3b8",zone_1:"#38bdf8",zone_2:"#22c55e",zone_3:"#eab308",zone_4:"#f97316",zone_5:"#ef4444"},V=["below_z1","zone_1","zone_2","zone_3","zone_4","zone_5"];function z(t){return t?t.replace(/^activity_/i,"").replaceAll("_"," ").replace(/\s+/g," ").replace(/\b\w/g,r=>r.toUpperCase()):"Unknown"}function B(t){return`${Math.round(t/60)}m`}function de(t){return t?`${(t/1e3).toFixed(1)} km`:"n/a"}function X(t,r){const s=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"short"}),l=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"});return`${s.format(new Date(t))} · ${l.format(new Date(t))} - ${l.format(new Date(r))}`}function ae(t){return mt(new Date(t))}function U(t){return{subjectiveEffort:t.subjectiveEffort!==null?String(t.subjectiveEffort):"",moodBefore:t.moodBefore??"",moodAfter:t.moodAfter??"",meaningText:t.meaningText??"",plannedContext:t.plannedContext??"",socialContext:t.socialContext??"",tagsText:Array.isArray(t.tags)?t.tags.join(", "):"",linkValues:Array.isArray(t.links)?t.links.map(r=>`${r.entityType}:${r.entityId}`):[]}}function Ae(t){return t.trim().toLowerCase()}function y(t){var r;return((r=t.workoutTypeLabel)==null?void 0:r.trim())||z(t.workoutType)}function _(t){var r;return((r=t.activityFamilyLabel)==null?void 0:r.trim())||z(t.activityFamily)}function Ce(t){return z(t.sourceSystem??t.source)}function kt(t){return t==null?"n/a":typeof t=="boolean"?t?"Yes":"No":typeof t=="number"?Number.isInteger(t)?String(t):t.toFixed(1):t}function Nt(t){const r=kt(t.value);return!t.unit||t.unit==="count"?r:`${r} ${t.unit}`}function wt(t,r){return Ae([t.workoutType,y(t),t.activityFamily,_(t),t.sourceSystem,Ce(t),t.sourceType,t.sourceDevice,t.reconciliationStatus,t.moodBefore,t.moodAfter,t.meaningText,t.plannedContext,t.socialContext,t.tags.join(" "),r.moodBefore,r.moodAfter,r.meaningText,r.plannedContext,r.socialContext,r.tagsText,X(t.startedAt,t.endedAt)].join(" "))}function St(t){const r=new Map;for(const s of t)r.set(`workout:${s.workoutType}`,{id:`workout:${s.workoutType}`,label:y(s),description:"Workout type",searchText:`${y(s)} workout`,badge:e.jsx(c,{tone:"meta",children:y(s)})}),r.set(`source:${s.sourceType}`,{id:`source:${s.sourceType}`,label:s.sourceType.replaceAll("_"," "),description:"Source type",searchText:`${s.sourceType} source`,badge:e.jsx(c,{tone:"meta",className:"capitalize",children:s.sourceType.replaceAll("_"," ")})}),r.set(`status:${s.reconciliationStatus}`,{id:`status:${s.reconciliationStatus}`,label:s.reconciliationStatus.replaceAll("_"," "),description:"Reconciliation status",searchText:`${s.reconciliationStatus} status`,badge:e.jsx(c,{tone:"meta",className:"capitalize",children:s.reconciliationStatus.replaceAll("_"," ")})});return r.set("linked:yes",{id:"linked:yes",label:"Linked",description:"Already tied to Forge or Psyche context",badge:e.jsx(c,{tone:"meta",children:"Linked"})}),r.set("linked:no",{id:"linked:no",label:"Needs links",description:"No Forge or Psyche links yet",badge:e.jsx(c,{tone:"meta",children:"Needs links"})}),r.set("habit:yes",{id:"habit:yes",label:"Habit-generated",description:"Created from a habit completion",badge:e.jsx(c,{tone:"meta",children:"Habit-generated"})}),r.set("effort:rated",{id:"effort:rated",label:"Effort rated",description:"Already has a subjective effort score",badge:e.jsx(c,{tone:"meta",children:"Effort rated"})}),Array.from(r.values())}function At(t,r){return r.every(s=>s.startsWith("workout:")?t.workoutType===s.slice(8):s.startsWith("source:")?t.sourceType===s.slice(7):s.startsWith("status:")?t.reconciliationStatus===s.slice(7):s==="linked:yes"?t.links.length>0:s==="linked:no"?t.links.length===0:s==="habit:yes"?!!t.generatedFromHabitId:s==="effort:rated"?t.subjectiveEffort!==null:!0)}function te(t,r,s){if(!t||t.length===0)return null;const l=[...t].filter(o=>o.dateKey<=r&&o[s]!=null).sort((o,p)=>p.dateKey.localeCompare(o.dateKey))[0];return(l==null?void 0:l[s])??null}function Ct(t){return[t.workoutType,t.workoutTypeLabel,t.activityFamily,t.activityFamilyLabel].filter(Boolean).join(" ").toLowerCase().includes("kickboxing")}function Tt(t){const r=new Map;for(const s of t){const l=`type:${s.workoutType}`;r.set(l,{id:l,label:y(s),description:_(s),searchText:`${y(s)} ${_(s)} ${s.workoutType}`,badge:e.jsx(c,{tone:"meta",children:y(s)})})}return[...r.values()].sort((s,l)=>s.label.localeCompare(l.label))}function Mt(t,r,s,l,o){const p=r.filter(u=>u.startsWith("type:")).map(u=>u.slice(5)),f=new Set(p),j=ae(new Date().toISOString()),b=new Date(`${j}T12:00:00.000Z`);b.setUTCDate(b.getUTCDate()-90);const n=b.toISOString().slice(0,10);return t.filter(u=>{if(f.size>0&&!f.has(u.workoutType))return!1;const x=ae(u.startedAt);return s==="recent_90"?x>=n:!(s==="custom"&&(l&&x<l||o&&x>o))}).sort((u,x)=>Date.parse(u.startedAt)-Date.parse(x.startedAt))}function oe(t){var s;const r=Object.fromEntries(V.map(l=>[l,0]));for(const l of t)for(const o of((s=l.analytics)==null?void 0:s.zoneDurations)??[])V.includes(o.key)&&(r[o.key]+=o.seconds);return r}function Ne(t){const r=Object.values(t).reduce((s,l)=>s+l,0);return Object.fromEntries(V.map(s=>[s,r>0?Number((t[s]/r*100).toFixed(1)):0]))}function Rt(t,r,s){const l=typeof(s==null?void 0:s.dataKey)=="string"?s.dataKey:typeof r=="string"?r:"",o=typeof t=="number"?Number(t.toFixed(1)):String(t??"n/a");return l==="restingHeartRate"||r==="Resting HR"?[`${o} bpm`,"Resting HR"]:l==="vo2Max"||r==="VO2max"?[`${o} ml/kg/min`,"VO2max"]:[`${o}%`,z(l)]}function Et(t,r){const s=t.map((n,u)=>{var k,M,D;const x=ae(n.startedAt),w=t.slice(Math.max(0,u-2),u+1),N=oe(w),T=Ne(N);return{id:n.id,dateKey:x,date:x.slice(5),session:y(n),durationMinutes:Math.round(n.durationSeconds/60),confidence:((k=n.analytics)==null?void 0:k.confidence)??"unavailable",restingHeartRate:((D=(M=n.analytics)==null?void 0:M.hrSummary)==null?void 0:D.restingHr)??te(r,x,"restingHeartRate"),vo2Max:te(r,x,"vo2Max"),...T}}),l=t.map((n,u)=>{var T,k,M;const x=ae(n.startedAt),w=oe(t.slice(0,u+1)),N=Ne(w);return{id:n.id,dateKey:x,date:x.slice(5),session:y(n),durationMinutes:Math.round(n.durationSeconds/60),confidence:((T=n.analytics)==null?void 0:T.confidence)??"unavailable",restingHeartRate:((M=(k=n.analytics)==null?void 0:k.hrSummary)==null?void 0:M.restingHr)??te(r,x,"restingHeartRate"),vo2Max:te(r,x,"vo2Max"),...N}}),o=oe(t),p=Object.values(o).reduce((n,u)=>n+u,0),f=V.map(n=>{var x;const u=((x=t.flatMap(w=>{var N;return((N=w.analytics)==null?void 0:N.zoneDurations)??[]}).find(w=>w.key===n))==null?void 0:x.label)??z(n);return{key:n,zone:u,percentage:p>0?Number((o[n]/p*100).toFixed(1)):0,fill:G[n]??"#f8fafc"}}),j=t.filter(n=>{var u,x;return(((x=(u=n.analytics)==null?void 0:u.dataQuality)==null?void 0:x.heartRateSampleCount)??0)>0}).length,b=[...new Set(t.map(n=>y(n)))];return{sessions:t,lineData:s,expandingLineData:l,averageZoneData:f,rawHrCount:j,exerciseLabels:b}}function zt({session:t,draft:r,linkOptions:s,pending:l,step:o,onStepChange:p,onDraftChange:f,onSave:j}){var n,u,x,w,N,T,k,M,D;const b=[{id:"context",title:"Session context",description:"Quick facts, effort, and how this session happened."},{id:"reflection",title:"Reflection",description:"Mood, meaning, and what the session actually did for you."},{id:"links",title:"Links",description:"Tie the session back to Forge and Psyche context."}];return e.jsxs("div",{className:"grid gap-5",children:[e.jsx("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-lg text-[var(--ui-ink-strong)]",children:[e.jsx(we,{className:"size-4 text-[var(--primary)]"}),e.jsx("span",{children:y(t)})]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:X(t.startedAt,t.endedAt)})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(c,{children:B(t.durationSeconds)}),t.totalEnergyKcal?e.jsxs(c,{tone:"meta",children:[Math.round(t.totalEnergyKcal)," kcal"]}):null,t.distanceMeters?e.jsx(c,{tone:"meta",children:de(t.distanceMeters)}):null,e.jsx(c,{tone:"meta",children:_(t)}),e.jsx(c,{tone:"meta",className:"capitalize",children:t.reconciliationStatus.replaceAll("_"," ")})]})]})}),e.jsx("div",{className:"grid gap-2 sm:grid-cols-3",children:b.map((i,L)=>e.jsxs("button",{type:"button",onClick:()=>p(L),className:`rounded-[20px] border px-4 py-3 text-left transition ${o===L?"border-[var(--primary)] bg-[var(--primary)]/10 text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"}`,children:[e.jsxs("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:["Step ",L+1]}),e.jsx("div",{className:"mt-2 text-sm font-medium",children:i.title})]},i.id))}),e.jsxs("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:b[o].title}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:b[o].description}),o===0?e.jsxs("div",{className:"mt-4 grid gap-4",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Activity family"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)] capitalize",children:_(t)})]}),e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Source system"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:Ce(t)})]}),e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Source device"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:t.sourceDevice||"n/a"})]})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Steps"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:t.stepCount??"n/a"})]}),e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Avg HR"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:t.averageHeartRate?Math.round(t.averageHeartRate):"n/a"})]}),e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Max HR"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:t.maxHeartRate?Math.round(t.maxHeartRate):"n/a"})]})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Effort"}),e.jsx(F,{type:"number",min:1,max:10,value:r.subjectiveEffort,onChange:i=>f({subjectiveEffort:i.target.value})})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Planned vs spontaneous"}),e.jsx(F,{value:r.plannedContext,onChange:i=>f({plannedContext:i.target.value}),placeholder:"Planned recovery block"})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Social context"}),e.jsx(F,{value:r.socialContext,onChange:i=>f({socialContext:i.target.value}),placeholder:"Solo, coach, group class, partner"})]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Tags"}),e.jsx(F,{value:r.tagsText,onChange:i=>f({tagsText:i.target.value}),placeholder:"recovery, interval-block, stress-release"})]})]}):null,o===1?e.jsxs("div",{className:"mt-4 grid gap-4",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Mood before"}),e.jsx(F,{value:r.moodBefore,onChange:i=>f({moodBefore:i.target.value})})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Mood after"}),e.jsx(F,{value:r.moodAfter,onChange:i=>f({moodAfter:i.target.value})})]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Meaning, impact, and why this session mattered"}),e.jsx(rt,{className:"min-h-[160px]",value:r.meaningText,onChange:i=>f({meaningText:i.target.value}),placeholder:"This session was planned as active recovery after a heavy work block and helped reset stress before sleep."})]})]}):null,o===2?e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Search goals, projects, habits, values, beliefs, patterns, or reports and attach the ones that explain this session."}),e.jsx(it,{options:s,selectedValues:r.linkValues,onChange:i=>f({linkValues:i}),placeholder:"Search Forge and Psyche records…"})]}):null,e.jsxs("div",{className:"mt-5 grid gap-4 border-t border-[var(--ui-border-subtle)] pt-5",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Captured data"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Source-native workout metrics, events, and phases exposed through the adapter layer."})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:[(((n=t.details)==null?void 0:n.metrics)??[]).slice(0,12).map(i=>e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:i.label}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:Nt(i)}),e.jsxs("div",{className:"mt-1 text-xs uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:[z(i.category)," ·"," ",z(i.statistic)]})]},`${i.category}:${i.key}:${i.statistic}`)),(((x=(u=t.details)==null?void 0:u.metrics)==null?void 0:x.length)??0)===0?e.jsx("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4 text-sm text-[var(--ui-ink-faint)]",children:"No provider metrics were captured for this session yet."}):null]}),(((N=(w=t.details)==null?void 0:w.events)==null?void 0:N.length)??0)>0?e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Workout events"}),e.jsx("div",{className:"grid gap-2",children:(T=t.details)==null?void 0:T.events.map(i=>e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("div",{className:"text-[var(--ui-ink-strong)]",children:i.label}),e.jsx(c,{tone:"meta",children:B(i.durationSeconds)})]}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:X(i.startedAt,i.endedAt??i.startedAt)})]},`${i.type}:${i.startedAt}`))})]}):null,(((M=(k=t.details)==null?void 0:k.components)==null?void 0:M.length)??0)>0?e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Workout phases"}),e.jsx("div",{className:"grid gap-2",children:(D=t.details)==null?void 0:D.components.map(i=>e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("div",{className:"text-[var(--ui-ink-strong)]",children:i.activity.canonicalLabel}),e.jsx(c,{tone:"meta",children:B(i.durationSeconds)})]}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:X(i.startedAt,i.endedAt??i.startedAt)})]},i.externalUid))})]}):null]})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-faint)]",children:o<b.length-1?"Move through the session one step at a time, then save when the context is clean.":"Everything is in place. Save the session metadata back into Forge."}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(ie,{type:"button",variant:"secondary",onClick:()=>p(Math.max(0,o-1)),disabled:o===0,children:"Back"}),o<b.length-1?e.jsxs(ie,{type:"button",onClick:()=>p(o+1),children:["Next",e.jsx(Se,{className:"size-4"})]}):null,e.jsxs(ie,{type:"button",pending:l,pendingLabel:"Saving",onClick:j,children:[e.jsx(Ze,{className:"size-4"}),"Save session"]})]})]})]})}function qt(){var fe,be;const t=Xe(),r=Ue(),s=Array.isArray(t.selectedUserIds)?t.selectedUserIds:[],[l,o]=h.useState({}),[p,f]=h.useState(""),[j,b]=h.useState([]),[n,u]=h.useState([]),[x,w]=h.useState(""),[N,T]=h.useState("all"),[k,M]=h.useState("rolling_stack"),[D,i]=h.useState(""),[L,Te]=h.useState(""),[ce,Me]=h.useState(!1),[ue,se]=h.useState(null),[Re,Y]=h.useState(0),S=O({queryKey:["forge-fitness",...s],queryFn:async()=>(await nt(s)).fitness}),Ee=O({queryKey:["forge-health-values",...s],queryFn:async()=>(await lt(s)).values}),ze=O({queryKey:["forge-health-patterns",...s],queryFn:async()=>(await ot(s)).patterns}),De=O({queryKey:["forge-health-behaviors",...s],queryFn:async()=>(await dt(s)).behaviors}),He=O({queryKey:["forge-health-beliefs",...s],queryFn:async()=>(await ct(s)).beliefs}),Fe=O({queryKey:["forge-health-reports",...s],queryFn:async()=>(await ut(s)).reports});h.useEffect(()=>{S.data&&o(Object.fromEntries(S.data.sessions.map(a=>[a.id,U(a)])))},[S.data]),h.useEffect(()=>{if(ce||!S.data)return;const d=(S.data.analysisSessions??S.data.sessions).find(Ct);d&&u([`type:${d.workoutType}`]),Me(!0)},[ce,S.data]);const re=Ge({mutationFn:async a=>Ye(a.workoutId,{subjectiveEffort:a.subjectiveEffort.trim().length>0?Number(a.subjectiveEffort):null,moodBefore:a.moodBefore,moodAfter:a.moodAfter,meaningText:a.meaningText,plannedContext:a.plannedContext,socialContext:a.socialContext,tags:a.tagsText.split(",").map(d=>d.trim()).filter(Boolean),links:ht(a.linkValues)}),onSuccess:async()=>{await r.invalidateQueries({queryKey:["forge-fitness"]})}}),H=S.data,A=(H==null?void 0:H.sessions)??[],K=(H==null?void 0:H.analysisSessions)??A,Le=pt({goals:t.snapshot.dashboard.goals,projects:t.snapshot.dashboard.projects,tasks:t.snapshot.dashboard.tasks,habits:t.snapshot.dashboard.habits,values:Ee.data??[],patterns:ze.data??[],behaviors:De.data??[],beliefs:He.data??[],reports:Fe.data??[]}),$e=h.useMemo(()=>St(A),[A]),_e=h.useMemo(()=>Tt(K),[K]),I=h.useMemo(()=>{const a=Ae(p);return[...A].sort((d,m)=>new Date(m.startedAt).getTime()-new Date(d.startedAt).getTime()).filter(d=>{const m=l[d.id]??U(d);return(a.length===0||wt(d,m).includes(a))&&At(d,j)})},[l,p,j,A]),xe=h.useMemo(()=>Mt(K,n,N,D,L),[N,L,K,D,n]),me=I.length===A.length&&p.trim().length===0&&j.length===0?`${A.length} workout sessions visible`:`${I.length} of ${A.length} workout sessions visible`,R=I.find(a=>a.id===ue)??A.find(a=>a.id===ue)??null,he=R?l[R.id]??U(R):null;if(S.isLoading)return e.jsx(Je,{eyebrow:"Sports",title:"Loading sports view",description:"Reading synced workouts and local reflection metadata.",columns:2,blocks:6});if(S.isError||!H)return e.jsx(et,{eyebrow:"Sports",error:S.error??new Error("Sports data unavailable"),onRetry:()=>void S.refetch()});const{summary:v,weeklyTrend:pe,typeBreakdown:Ke}=H,ve=v.zoneMix??[],C=Et(xe,H.vitalsTrend),ge=n.length===0?"All exercise types":C.exerciseLabels.length>0?C.exerciseLabels.join(", "):`${n.length} selected types`,Oe=ve.map(a=>({zone:a.label,minutes:Math.round(a.seconds/60),percentage:Math.round(a.percentage*100),fill:G[a.key]??"#f8fafc"})),We=pe.map(a=>{const d=Object.fromEntries((a.zoneDurations??[]).map(m=>[m.key,Math.round(m.seconds/60)]));return{date:a.dateKey.slice(5),duration:a.durationMinutes,load:a.trainingLoad??0,coverage:Math.round((a.heartRateCoverage??0)*100),...d}}),Be=K.map(a=>{var d,m,E,$;return{duration:Math.round(a.durationSeconds/60),intensity:Math.round((((m=(d=a.analytics)==null?void 0:d.load)==null?void 0:m.intensity)??0)*100),load:(($=(E=a.analytics)==null?void 0:E.load)==null?void 0:$.trimp)??0,type:y(a),name:y(a)}});function Ve(a,d){o(m=>{const E=m[a]??U(A.find($=>$.id===a));return{...m,[a]:{...E,...d}}})}async function Ie(a){const d=A.find(E=>E.id===a);if(!d)return;const m=l[a]??U(d);await re.mutateAsync({workoutId:a,subjectiveEffort:m.subjectiveEffort,moodBefore:m.moodBefore,moodAfter:m.moodAfter,meaningText:m.meaningText,plannedContext:m.plannedContext,socialContext:m.socialContext,tagsText:m.tagsText,linkValues:m.linkValues}),se(null),Y(0)}return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(xt,{entityKind:"project",title:"Sports",description:"A session-first training surface for workout data, subjective meaning, and links back into Forge execution and Psyche.",badge:`${A.length} sessions`}),e.jsx(tt,{children:e.jsxs("section",{className:"grid gap-4 lg:grid-cols-4",children:[e.jsxs(g,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Weekly volume"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--primary)]",children:B(v.weeklyVolumeSeconds)}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Total training time in the recent week."})]}),e.jsxs(g,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Exercise minutes"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:v.exerciseMinutes}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Aggregate exercise minutes from synced sessions."})]}),e.jsxs(g,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Energy burned"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:v.energyBurnedKcal}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Recent weekly kcal."})]}),e.jsxs(g,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Training streak"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:v.streakDays}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Distinct workout days in the recent week."})]}),e.jsxs(g,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Average session"}),e.jsxs("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:[v.averageSessionMinutes,"m"]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Mean duration across recent sessions."})]}),e.jsxs(g,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Training load"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:v.totalTrainingLoad??"n/a"}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Forge TRIMP across recent sessions."})]}),e.jsxs(g,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Linked sessions"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:v.linkedSessionCount}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Sessions already tied to Forge or Psyche entities."})]}),e.jsxs(g,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"HR coverage"}),e.jsxs("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:[Math.round((v.averageHeartRateCoverage??0)*100),"%"]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Average raw HR sample coverage."})]})]})}),e.jsx(J,{children:e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.1fr)_minmax(320px,0.9fr)]",children:[e.jsxs(g,{className:"min-h-[320px]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Load and volume trend"}),e.jsx(Z,{className:"mt-4 h-[260px]",children:e.jsx(P,{width:"100%",height:"100%",minWidth:1,minHeight:1,children:e.jsxs(vt,{data:We,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"sportsLoad",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#f97316",stopOpacity:.36}),e.jsx("stop",{offset:"100%",stopColor:"#f97316",stopOpacity:.04})]})}),e.jsx(ee,{stroke:"var(--ui-border-subtle)",vertical:!1}),e.jsx(q,{dataKey:"date",tick:{fill:"var(--ui-ink-faint)",fontSize:11}}),e.jsx(W,{tick:{fill:"var(--ui-ink-faint)",fontSize:11},width:34}),e.jsx(Q,{contentStyle:{background:"var(--ui-surface-popover)",border:"1px solid var(--ui-border-strong)",borderRadius:8,color:"var(--ui-ink-strong)"}}),e.jsx(ye,{type:"monotone",dataKey:"load",stroke:"#f97316",fill:"url(#sportsLoad)",strokeWidth:2}),e.jsx(ye,{type:"monotone",dataKey:"duration",stroke:"#38bdf8",fill:"var(--ui-info-soft)",strokeWidth:2})]})})})]}),e.jsxs(g,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Zone distribution"}),e.jsx("div",{className:"mt-4 grid gap-3",children:ve.map(a=>e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm",children:[e.jsx("span",{className:"text-[var(--ui-ink)]",children:a.label}),e.jsxs("span",{className:"text-[var(--ui-ink-strong)]",children:[Math.round(a.percentage*100),"% ·"," ",B(a.seconds)]})]}),e.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-[var(--ui-surface-3)]",children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${Math.max(1,a.percentage*100)}%`,background:G[a.key]??"#f8fafc"}})})]},a.key))}),e.jsx(Z,{className:"mt-5 h-[180px]",children:e.jsx(P,{width:"100%",height:"100%",minWidth:1,minHeight:1,children:e.jsxs(ke,{data:Oe,children:[e.jsx(q,{dataKey:"zone",tick:{fill:"var(--ui-ink-faint)",fontSize:10}}),e.jsx(W,{tick:{fill:"var(--ui-ink-faint)",fontSize:10},width:34}),e.jsx(Q,{contentStyle:{background:"var(--ui-surface-popover)",border:"1px solid var(--ui-border-strong)",borderRadius:8,color:"var(--ui-ink-strong)"}}),e.jsx(ne,{dataKey:"minutes",fill:"#f97316",radius:[4,4,0,0]})]})})})]})]})}),e.jsx(J,{children:e.jsxs("section",{className:"grid gap-4",children:[e.jsxs(g,{className:"grid gap-4 overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"HR zone analysis"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:"Filter all-time workout evidence by exercise type and date."})]}),e.jsxs(c,{tone:"meta",children:[xe.length," of ",K.length," ","sessions"]})]}),e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1fr)_minmax(280px,0.8fr)]",children:[e.jsx(je,{title:"Exercise types",description:"Select one, many, or none for all exercise types.",query:x,onQueryChange:w,options:_e,selectedOptionIds:n,onSelectedOptionIdsChange:u,resultSummary:ge,placeholder:"Search exercise types",emptyStateMessage:"No exercise type matches."}),e.jsxs("div",{className:"grid gap-3 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Date range"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:[["all","All time"],["recent_90","90 days"],["custom","Custom"]].map(([a,d])=>e.jsx("button",{type:"button",className:`rounded-[8px] border px-3 py-2 text-sm transition ${N===a?"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"}`,onClick:()=>T(a),children:d},a))}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Start"}),e.jsx(F,{type:"date",value:D,onChange:a=>{i(a.target.value),T("custom")}})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"End"}),e.jsx(F,{type:"date",value:L,onChange:a=>{Te(a.target.value),T("custom")}})]})]})]})]})]}),e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,0.85fr)_minmax(0,1.15fr)]",children:[e.jsxs(g,{className:"min-h-[330px] overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Average zones"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:"Duration-weighted proportion of time in each HR zone."})]}),e.jsx(c,{tone:"meta",children:ge})]}),e.jsx(Z,{className:"mt-4 h-[235px]",children:C.sessions.length>0?e.jsx(P,{width:"100%",height:"100%",minWidth:1,minHeight:1,children:e.jsxs(ke,{data:C.averageZoneData,children:[e.jsx(ee,{stroke:"var(--ui-border-subtle)",vertical:!1}),e.jsx(q,{dataKey:"zone",interval:0,tick:{fill:"var(--ui-ink-faint)",fontSize:10}}),e.jsx(W,{unit:"%",domain:[0,100],ticks:[0,25,50,75,100],tick:{fill:"var(--ui-ink-faint)",fontSize:10},width:38}),e.jsx(Q,{formatter:a=>[`${a}%`,"Average time"],contentStyle:{background:"var(--ui-surface-popover)",border:"1px solid var(--ui-border-strong)",borderRadius:8,color:"var(--ui-ink-strong)"}}),e.jsx(ne,{dataKey:"percentage",radius:[4,4,0,0],children:C.averageZoneData.map(a=>e.jsx(gt,{fill:a.fill},a.key))})]})}):e.jsx("div",{className:"grid h-full place-items-center rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-6 text-center text-sm leading-6 text-[var(--ui-ink-soft)]",children:"No selected sessions with zone analytics are available yet."})}),C.sessions.length>0?e.jsxs("div",{className:"mt-3 grid gap-2 text-sm text-[var(--ui-ink-soft)] sm:grid-cols-3",children:[e.jsxs("div",{children:[C.rawHrCount," sessions have raw HR timelines"]}),e.jsxs("div",{children:["Latest: ",((fe=C.lineData.at(-1))==null?void 0:fe.dateKey)??"n/a"]}),e.jsxs("div",{children:["VO2max points:"," ",C.lineData.filter(a=>a.vo2Max!=null).length]})]}):null]}),e.jsxs(g,{className:"min-h-[330px] overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:k==="expanding_lines"?"Expanding zone lines":"Zone drift"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:k==="expanding_lines"?"Expanding all-session average with resting HR and VO2max overlay.":"Rolling duration-weighted zone mix with resting HR and VO2max overlay."})]}),e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:items-end",children:[e.jsx("div",{className:"grid grid-cols-2 gap-1 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-1","aria-label":"Zone chart display",children:[["rolling_stack","Stacked"],["expanding_lines","Lines"]].map(([a,d])=>e.jsx("button",{type:"button",className:`min-h-9 rounded-[6px] px-3 py-1.5 text-xs font-medium transition ${k===a?"bg-[var(--primary)]/18 text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"}`,onClick:()=>M(a),children:d},a))}),e.jsx(c,{tone:"meta",children:"HRR zones"})]})]}),e.jsx(Z,{className:"mt-4 h-[255px]",children:C.lineData.length>0?e.jsx(P,{width:"100%",height:"100%",minWidth:1,minHeight:1,children:e.jsxs(ft,{data:k==="expanding_lines"?C.expandingLineData:C.lineData,children:[e.jsx(ee,{stroke:"var(--ui-border-subtle)",vertical:!1}),e.jsx(q,{dataKey:"date",tick:{fill:"var(--ui-ink-faint)",fontSize:10}}),e.jsx(W,{yAxisId:"zones",domain:[0,100],ticks:[0,25,50,75,100],unit:"%",tick:{fill:"var(--ui-ink-faint)",fontSize:10},width:38}),e.jsx(W,{yAxisId:"vitals",orientation:"right",tick:{fill:"var(--ui-ink-faint)",fontSize:10},width:42}),e.jsx(Q,{formatter:(a,d,m)=>Rt(a,d,m),contentStyle:{background:"var(--ui-surface-popover)",border:"1px solid var(--ui-border-strong)",borderRadius:8,color:"var(--ui-ink-strong)"}}),e.jsx(bt,{wrapperStyle:{color:"var(--ui-ink)",fontSize:11}}),k==="expanding_lines"?V.map(a=>e.jsx(le,{yAxisId:"zones",type:"monotone",dataKey:a,name:z(a),stroke:G[a],strokeWidth:2,dot:{r:2.5},activeDot:{r:4},connectNulls:!0},a)):V.map(a=>e.jsx(ne,{yAxisId:"zones",dataKey:a,stackId:"zones",fill:G[a],isAnimationActive:!1},a)),e.jsx(le,{yAxisId:"vitals",type:"monotone",dataKey:"restingHeartRate",name:"Resting HR",stroke:"var(--ui-ink-soft)",strokeWidth:2,dot:{r:3},connectNulls:!0}),e.jsx(le,{yAxisId:"vitals",type:"monotone",dataKey:"vo2Max",name:"VO2max",stroke:"#a78bfa",strokeWidth:2,dot:{r:3},connectNulls:!0})]})}):e.jsx("div",{className:"grid h-full place-items-center rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-6 text-center text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Select workouts with HR evidence to unlock the time-series plot."})})]})]})]})}),e.jsx(J,{children:e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_360px]",children:[e.jsxs(g,{className:"min-h-[300px]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Duration vs intensity"}),e.jsx(Z,{className:"mt-4 h-[250px]",children:e.jsx(P,{width:"100%",height:"100%",minWidth:1,minHeight:1,children:e.jsxs(jt,{data:Be,children:[e.jsx(ee,{stroke:"var(--ui-border-subtle)"}),e.jsx(q,{type:"number",dataKey:"duration",name:"minutes",tick:{fill:"var(--ui-ink-faint)",fontSize:11}}),e.jsx(W,{type:"number",dataKey:"intensity",name:"intensity",tick:{fill:"var(--ui-ink-faint)",fontSize:11},width:38}),e.jsx(Q,{cursor:{strokeDasharray:"3 3"},contentStyle:{background:"var(--ui-surface-popover)",border:"1px solid var(--ui-border-strong)",borderRadius:8,color:"var(--ui-ink-strong)"}}),e.jsx(yt,{dataKey:"load",fill:"#f97316"})]})})})]}),e.jsxs(g,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Evidence quality"}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsxs("div",{className:"rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Raw HR coverage"}),e.jsxs("div",{className:"mt-2 text-2xl text-[var(--ui-ink-strong)]",children:[Math.round((v.averageHeartRateCoverage??0)*100),"%"]})]}),e.jsxs("div",{className:"rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Route-backed workouts"}),e.jsx("div",{className:"mt-2 text-2xl text-[var(--ui-ink-strong)]",children:v.routeWorkoutCount??0})]}),e.jsxs("div",{className:"rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Top sport"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:v.topWorkoutTypeLabel??v.topWorkoutType??"n/a"})]})]})]})]})}),e.jsx(J,{children:e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[1.05fr_0.95fr]",children:[e.jsxs(g,{className:"grid gap-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Recent volume"}),e.jsx("div",{className:"grid gap-3",children:pe.map(a=>e.jsxs("div",{className:"grid gap-2 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3 md:grid-cols-[110px_150px_minmax(0,1fr)_90px]",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:a.dateKey}),e.jsx("div",{className:"text-sm text-[var(--ui-ink-strong)]",children:a.workoutTypeLabel??z(a.workoutType)}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-2 flex-1 overflow-hidden rounded-full bg-[var(--ui-surface-3)]",children:e.jsx("div",{className:"h-full rounded-full bg-[var(--primary)]",style:{width:`${Math.min(100,a.durationMinutes/120*100)}%`}})}),e.jsxs("div",{className:"text-sm text-[var(--ui-ink-strong)]",children:[a.durationMinutes,"m"]})]}),e.jsxs("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:[a.energyKcal," kcal"]})]},a.id))}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Distance"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:de(v.distanceMeters)})]}),e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Planned sessions"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:v.plannedSessionCount})]}),e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Imported / merged"}),e.jsxs("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:[v.importedSessionCount," /"," ",v.reconciledSessionCount]})]})]})]}),e.jsxs(g,{className:"grid gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Training composition"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:"Workout type and provenance mix"})]}),e.jsx("div",{className:"grid gap-3",children:Ke.slice(0,6).map(a=>e.jsxs("div",{className:"grid gap-2 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3 md:grid-cols-[minmax(0,1fr)_90px_90px]",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[var(--ui-ink-strong)]",children:a.workoutTypeLabel??z(a.workoutType)}),e.jsxs("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:[a.sessionCount," sessions ·"," ",a.activityFamilyLabel??"Other"]})]}),e.jsxs("div",{className:"text-sm text-[var(--ui-ink)]",children:[a.totalMinutes,"m"]}),e.jsxs("div",{className:"text-sm text-[var(--ui-ink)]",children:[a.energyKcal," kcal"]})]},a.workoutType))}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Habit-generated"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:v.habitGeneratedSessionCount})]}),e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Forge-linked"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:v.linkedSessionCount})]})]})]})]})}),e.jsx(at,{children:e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,25rem)_minmax(0,1fr)]",children:[e.jsx(je,{title:"Session browser",description:"Search past activities by workout type, source, reconciliation state, or whether they still need context.",query:p,onQueryChange:f,options:$e,selectedOptionIds:j,onSelectedOptionIdsChange:b,resultSummary:me,placeholder:"Search workouts, devices, notes, moods, or filter chips",emptyStateMessage:"Keep typing or pick a filter chip to narrow the activity history."}),e.jsxs(g,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Activity history"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:"Open a workout to add reflection and links in a guided modal."})]}),e.jsx(c,{tone:"meta",children:me})]}),e.jsx("div",{className:"max-h-[34rem] overflow-y-auto rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-3",children:I.length===0?e.jsx("div",{className:"flex min-h-[18rem] items-center justify-center p-6 text-center text-sm leading-6 text-[var(--ui-ink-faint)]",children:"No workout matches the current search yet. Clear some filters or search by workout type, device, or reflection text."}):e.jsx("div",{className:"grid gap-3",children:I.map(a=>{var m,E,$;const d=a.meaningText.trim().length>0||a.moodBefore.trim().length>0||a.moodAfter.trim().length>0||a.tags.length>0||a.links.length>0;return e.jsxs("div",{className:"grid w-full min-w-0 gap-3 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3 text-left transition hover:bg-[var(--ui-surface-2)]",children:[e.jsxs("div",{className:"grid min-w-0 gap-3 sm:flex sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs(Pe,{to:`/sports/workouts/${a.id}`,className:"flex min-w-0 items-center gap-2 text-[var(--ui-ink-strong)] transition hover:text-[var(--primary)]",children:[e.jsx(we,{className:"size-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate text-base font-medium",children:y(a)})]}),e.jsxs("div",{className:"mt-2 flex min-w-0 items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx(qe,{className:"size-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate",children:X(a.startedAt,a.endedAt)})]}),e.jsxs("div",{className:"mt-2 text-sm text-[var(--ui-ink-faint)]",children:[_(a)," ·"," ",a.sourceDevice]})]}),e.jsxs("button",{type:"button","aria-label":`Edit ${y(a)} reflection`,className:"inline-flex w-fit max-w-full items-center gap-2 rounded-full bg-[var(--ui-surface-2)] px-3 py-1.5 text-xs text-[var(--ui-ink)] transition hover:bg-[var(--ui-surface-3)] hover:text-[var(--ui-ink-strong)]",onClick:()=>{se(a.id),Y(0)},children:[e.jsx("span",{className:"truncate",children:d?"Reflected":"Needs reflection"}),e.jsx(Se,{className:"size-3.5 shrink-0"})]})]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap gap-2",children:[e.jsx(c,{children:B(a.durationSeconds)}),a.totalEnergyKcal?e.jsxs(c,{tone:"meta",children:[Math.round(a.totalEnergyKcal)," kcal"]}):null,a.distanceMeters?e.jsx(c,{tone:"meta",children:de(a.distanceMeters)}):null,a.averageHeartRate?e.jsxs(c,{tone:"meta",children:[e.jsx(Qe,{className:"mr-1 size-3.5"}),Math.round(a.averageHeartRate)," bpm"]}):null,e.jsx(c,{tone:"meta",children:_(a)}),e.jsx(c,{tone:"meta",className:"capitalize",children:a.sourceType.replaceAll("_"," ")}),e.jsx(c,{tone:"meta",className:"capitalize",children:a.reconciliationStatus.replaceAll("_"," ")}),(m=a.analytics)!=null&&m.confidence?e.jsxs(c,{tone:"meta",children:[a.analytics.confidence," zones"]}):null,($=(E=a.analytics)==null?void 0:E.routeSummary)!=null&&$.hasRoute?e.jsx(c,{tone:"meta",children:"Route"}):null]})]},a.id)})})})]})]})}),R&&he?e.jsx(st,{open:!!R,onOpenChange:a=>{a||(se(null),Y(0))},eyebrow:"Sports session",title:y(R),description:"Add contextual meaning without crowding the main training surface.",children:e.jsx(zt,{session:R,draft:he,linkOptions:Le,pending:re.isPending&&((be=re.variables)==null?void 0:be.workoutId)===R.id,step:Re,onStepChange:Y,onDraftChange:a=>Ve(R.id,a),onSave:()=>void Ie(R.id)})}):null]})}export{qt as SportsPage,Rt as formatZoneTrendTooltipValue};
|