forge-openclaw-plugin 0.2.102 → 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-xtB5RFQu.js → ai-surface-workspace-CutiG6uS.js} +1 -1
- package/dist/assets/{atlas-panel-B3dPHCmZ.js → atlas-panel-jgMRyaHn.js} +1 -1
- package/dist/assets/{board-DqHzdCPQ.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-BZ_-X3Wb.js → calendar-week-toolbar-nVhgB-0s.js} +1 -1
- package/dist/assets/{charts-FcU0F3XV.js → charts-DFnEuIMB.js} +1 -1
- package/dist/assets/companion-sync-lab-page-CJ8UTij8.js +1 -0
- package/dist/assets/{daily-metrics-dashboard-BMyL0Qr4.js → daily-metrics-dashboard-CiJkkkd1.js} +1 -1
- package/dist/assets/entity-note-count-link-RzBB6ujx.js +1 -0
- package/dist/assets/{entity-notes-surface-CBylYDwy.js → entity-notes-surface-Djz50HvD.js} +1 -1
- package/dist/assets/execution-board-CtPhI-58.js +1 -0
- package/dist/assets/{faceted-token-search-D7xPWfOl.js → faceted-token-search-DEC6ANa9.js} +1 -1
- package/dist/assets/{flagship-signal-deck-BEFKOhvx.js → flagship-signal-deck-CtHC3mql.js} +1 -1
- package/dist/assets/floating-action-menu-CKQRhff9.js +1 -0
- package/dist/assets/{forms-CmLAyGqz.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-BTa79qum.js → graph-DDUZNRsO.js} +1 -1
- 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-BtIQXXsS.js → insight-flow-dialog-DtX_5W7g.js} +1 -1
- 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-BGDkKfbJ.js → life-force-page-CACGlNhq.js} +1 -1
- package/dist/assets/life-force-workspace-BJ4N1I78.js +1 -0
- package/dist/assets/{maps-CF1RagUX.js → maps-C-yOWiDN.js} +1 -1
- package/dist/assets/{metric-tile-4iMd_WnJ.js → metric-tile-CMadwnGz.js} +1 -1
- package/dist/assets/{motion-CfdU2F35.js → motion-Lt5B1XuE.js} +1 -1
- package/dist/assets/movement-page-D5VqFd2q.js +1 -0
- package/dist/assets/{note-markdown-CsGQhQXF.js → note-markdown-BzK2Qlgr.js} +1 -1
- package/dist/assets/{note-tags-input-DdZi93tj.js → note-tags-input-CZzqJMLc.js} +1 -1
- package/dist/assets/notes-page-D3Hsh90C.js +1 -0
- package/dist/assets/{open-in-graph-button-C0TGev7c.js → open-in-graph-button-BFPKfyK3.js} +1 -1
- package/dist/assets/{orbit-map-DVXkfQdd.js → orbit-map-CnyfSmOG.js} +1 -1
- package/dist/assets/{overview-page-BwMlFQKX.js → overview-page-CXdWrOV1.js} +1 -1
- package/dist/assets/{page-hero-oFHaAjtL.js → page-hero-ffKzgyW3.js} +1 -1
- package/dist/assets/pill-cluster-C2D0h3lx.js +1 -0
- package/dist/assets/{preference-entity-handoff-button-DOKV9bZc.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-DogvVNEn.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-BeVlXvbj.js → psyche-behaviors-page-BDwXyDta.js} +1 -1
- package/dist/assets/{psyche-flashcards-page-CqAWCO4E.js → psyche-flashcards-page-DL1BP1jX.js} +1 -1
- package/dist/assets/{psyche-goal-map-page-IyNnbk_W.js → psyche-goal-map-page-ovcpisx1.js} +1 -1
- package/dist/assets/{psyche-graph-IkUQRaDK.js → psyche-graph-EP5GL612.js} +1 -1
- package/dist/assets/{psyche-metrics-page-uai0a7Lx.js → psyche-metrics-page-Bcu813Rg.js} +1 -1
- package/dist/assets/{psyche-mode-guide-page-C7p-ABiF.js → psyche-mode-guide-page-C0g27Xpt.js} +1 -1
- package/dist/assets/{psyche-modes-page-CLQ5V3w0.js → psyche-modes-page-BjKjX5MR.js} +1 -1
- package/dist/assets/{psyche-page-NQBHkkpU.js → psyche-page-F4tF2W70.js} +1 -1
- package/dist/assets/{psyche-patterns-page-BkRiNpI_.js → psyche-patterns-page-B-14hukK.js} +1 -1
- package/dist/assets/{psyche-questionnaire-builder-page-Du-7HwPC.js → psyche-questionnaire-builder-page-BdXmoHvK.js} +1 -1
- package/dist/assets/{psyche-questionnaire-detail-page-C5-yf8MF.js → psyche-questionnaire-detail-page-Cu5uwlJu.js} +1 -1
- package/dist/assets/{psyche-questionnaire-run-detail-page-CoSH5O6R.js → psyche-questionnaire-run-detail-page-C3R4PClg.js} +1 -1
- package/dist/assets/{psyche-questionnaire-run-page-ChI7c1wy.js → psyche-questionnaire-run-page-Div3iDdt.js} +1 -1
- package/dist/assets/{psyche-questionnaires-page-xUcJJzbI.js → psyche-questionnaires-page-DpqAPQCp.js} +1 -1
- package/dist/assets/{psyche-report-detail-page-BPrZCFZS.js → psyche-report-detail-page-BvWVDKP3.js} +1 -1
- package/dist/assets/{psyche-reports-page-D2EXJmm6.js → psyche-reports-page-BrbWUlAq.js} +1 -1
- package/dist/assets/{psyche-schemas-RcZYaokx.js → psyche-schemas-Dxj554nU.js} +1 -1
- package/dist/assets/{psyche-schemas-beliefs-page-h0ooZ1lp.js → psyche-schemas-beliefs-page-DYKvAtSD.js} +1 -1
- package/dist/assets/{psyche-screen-time-page-_3-4LikV.js → psyche-screen-time-page-CAOKCyQw.js} +1 -1
- package/dist/assets/{psyche-self-observation-page-BdbCsgR5.js → psyche-self-observation-page-F0MVA0UH.js} +1 -1
- package/dist/assets/{psyche-values-page-DuUVki5e.js → psyche-values-page-DyvX-d0o.js} +1 -1
- package/dist/assets/{report-chain-fields-BBMz0sGI.js → report-chain-fields-CeC1cJFS.js} +1 -1
- package/dist/assets/rewards-page-C2loyODo.js +1 -0
- package/dist/assets/scheduling-rules-editor-D40AC2jR.js +1 -0
- package/dist/assets/{schema-badge-D93RcG36.js → schema-badge-FY7818qB.js} +1 -1
- package/dist/assets/{select-menu-Cdq7foRu.js → select-menu-DJsCG6rM.js} +1 -1
- 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-Dc4IeVBt.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-VYvD1QVP.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-DMyRKrWf.js → strategy-dialog-7X7peRzu.js} +1 -1
- package/dist/assets/{surface-Bfz_sLX6.js → surface-CJI17F3n.js} +1 -1
- package/dist/assets/{table-C0VTeqw0.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-CsEkP2V8.js → ui-C1iwpj2-.js} +1 -1
- package/dist/assets/{use-psyche-focus-target-qxT5Oy_z.js → use-psyche-focus-target-Ct-acS9G.js} +1 -1
- package/dist/assets/{vendor-kIz9EZnX.js → vendor-Dnkkx2co.js} +3 -3
- package/dist/assets/{vitals-page-Dz1Jt5H8.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-DD9IGN6l.js → workout-detail-page-DT-c5cHL.js} +2 -2
- package/dist/index.html +9 -9
- package/dist/server/server/src/app.js +22 -3
- package/dist/server/server/src/health-weight-loss.js +114 -39
- package/dist/server/server/src/repositories/model-settings.js +9 -3
- package/dist/server/src/components/workbench-boxes/shared/generic-node-view.js +13 -5
- package/dist/server/src/lib/api.js +10 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/dist/assets/activity-page-CgF7K2ww.js +0 -1
- package/dist/assets/calendar-page-C1Wfd2Fy.js +0 -1
- package/dist/assets/calendar-rules-CaZXtlxt.js +0 -1
- package/dist/assets/companion-sync-lab-page-NgeK-O-P.js +0 -1
- package/dist/assets/entity-note-count-link-BrS1-O0o.js +0 -1
- package/dist/assets/execution-board-CpO2ch6v.js +0 -1
- package/dist/assets/floating-action-menu-zzC2r0Ob.js +0 -1
- package/dist/assets/goal-detail-page-JK_Nva8e.js +0 -1
- package/dist/assets/goals-page-yeoJ06Vw.js +0 -1
- package/dist/assets/habits-page-Dx5EhkJi.js +0 -1
- package/dist/assets/index-BHIKoiZ6.js +0 -19
- package/dist/assets/index-H8R-ABM3.css +0 -1
- package/dist/assets/insights-page-CujrosD_.js +0 -8
- package/dist/assets/kanban-page-Q9NuIz5w.js +0 -1
- package/dist/assets/knowledge-graph-page-DaJmlvvM.js +0 -1
- package/dist/assets/life-force-workspace-CLVexVnb.js +0 -1
- package/dist/assets/movement-page-ClaoTNuX.js +0 -1
- package/dist/assets/notes-page-DYI8s3NN.js +0 -1
- package/dist/assets/pill-cluster-7UZd_lHp.js +0 -1
- package/dist/assets/preferences-page-BrKEkmfD.js +0 -1
- package/dist/assets/project-collections-CZagCmeH.js +0 -1
- package/dist/assets/project-management-hierarchy-page-Dr7hW9PW.js +0 -1
- package/dist/assets/project-management-section-nav-BLdAgTge.js +0 -1
- package/dist/assets/projects-page-UKrby_5-.js +0 -1
- package/dist/assets/rewards-page-PZFPa6rR.js +0 -1
- package/dist/assets/scheduling-rules-editor-B9KNKsQz.js +0 -1
- package/dist/assets/settings-agents-page-DPx2F6wf.js +0 -6
- package/dist/assets/settings-bin-page-COwP3gjo.js +0 -1
- package/dist/assets/settings-calendar-page-C-ghE0YT.js +0 -5
- package/dist/assets/settings-data-page-CBubzKBw.js +0 -1
- package/dist/assets/settings-logs-page-uOuXMeBm.js +0 -1
- package/dist/assets/settings-mobile-page-C5rfj8_r.js +0 -1
- package/dist/assets/settings-models-page-DijmUWdU.js +0 -1
- package/dist/assets/settings-page-B4u5TR5g.js +0 -1
- package/dist/assets/settings-rewards-page-COiTwkMH.js +0 -1
- package/dist/assets/settings-users-page-DEGa5DNn.js +0 -1
- package/dist/assets/settings-wiki-page-Cvsiz5_e.js +0 -1
- package/dist/assets/sleep-page-BnSOwkEU.js +0 -1
- package/dist/assets/sports-page-l1RqXzA_.js +0 -1
- package/dist/assets/strategies-page-DEnPlpAs.js +0 -1
- package/dist/assets/strategy-detail-page-Ls8bxKeH.js +0 -1
- package/dist/assets/task-detail-page-CgrYgQLD.js +0 -1
- package/dist/assets/timebox-planning-dialog-Ww0NGLLo.js +0 -1
- package/dist/assets/today-page-CIuFHMi1.js +0 -1
- package/dist/assets/training-load-page-BIwc648i.js +0 -1
- package/dist/assets/weekly-review-page-BFpBe1kI.js +0 -1
- package/dist/assets/weight-loss-page-BgMoBpBt.js +0 -5
- package/dist/assets/wiki-article-markdown-gsPTXTg1.js +0 -4
- package/dist/assets/wiki-editor-page-BpAZHooY.js +0 -26
- package/dist/assets/wiki-ingest-history-page-C-ig8O22.js +0 -1
- package/dist/assets/wiki-ingest-modal-BK4eQgqs.js +0 -1
- package/dist/assets/wiki-page-CMTZ60Zt.js +0 -1
- package/dist/assets/workbench-flow-page-BIpWUcLJ.js +0 -5
- package/dist/assets/workbench-page-CtCjYSRe.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as p,j as e,aC as ee}from"./vendor-kIz9EZnX.js";import{i as te,k as $}from"./state-VYvD1QVP.js";import{S as se}from"./settings-section-nav-Dc4IeVBt.js";import{P as ie}from"./page-hero-oFHaAjtL.js";import{i as ae,C as ne,B as re,M as le}from"./graph-BTa79qum.js";import{C as S,aq as ce,c as f,U as C,Q as K,F as M,j as T,I as R,T as oe,W as de,u as he,eu as xe,ev as ue,ew as pe,B as X,ex as ge}from"./index-BHIKoiZ6.js";import"./motion-CfdU2F35.js";import"./ui-CsEkP2V8.js";import"./forms-CmLAyGqz.js";import"./board-DqHzdCPQ.js";const Q=[{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."}]}],me=[{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}}],I=Q.reduce((t,r)=>t+r.rights.length,0);function F(t){return Object.values(t.config.rights).filter(Boolean).length}function q(t){const r=[];return t.config.rights.canReadEntities&&r.push("See"),t.config.rights.canCoordinate&&r.push("Message"),t.config.rights.canManageStrategies&&r.push("Plan"),t.config.rights.canAffectEntities&&r.push("Affect"),r.join(" · ")||"Hidden"}function be(t){return!t.config.rights.discoverable&&!t.config.rights.canReadEntities?"Hidden":t.config.rights.canAffectEntities&&t.config.rights.canManageStrategies?"Trusted":t.config.rights.canCoordinate||t.config.rights.canLinkEntities?"Coordinated":"Observed"}function Z(t){return[{id:"see",label:"See",enabled:t.config.rights.discoverable&&t.config.rights.canReadEntities&&t.config.rights.canSearchEntities},{id:"message",label:"Message",enabled:t.config.rights.canCoordinate},{id:"share",label:"Share context",enabled:t.config.rights.canLinkEntities},{id:"plan",label:"Plan",enabled:t.config.rights.canManageStrategies},{id:"affect",label:"Affect",enabled:t.config.rights.canAffectEntities||t.config.rights.canCreateOnBehalf}]}function fe(t,r){return Object.entries(r.rights).every(([i,x])=>t.config.rights[i]===x)}function we(t,r){const i=t.filter(a=>a.kind==="human"),x=t.filter(a=>a.kind==="bot"),u={x:560,y:360},g={width:226,height:132},d=i[0]??null,v=[...i.slice(d?1:0).map(a=>({user:a,radius:245,offset:-90})),...x.map(a=>({user:a,radius:390,offset:-90}))],b=v.length,N=[...d?[{user:d,position:{x:u.x-g.width/2,y:u.y-g.height/2}}]:[],...v.map((a,o)=>{const h=(a.offset+360/Math.max(b,1)*o)*Math.PI/180;return{user:a.user,position:{x:u.x+Math.cos(h)*a.radius-g.width/2,y:u.y+Math.sin(h)*a.radius-g.height/2}}})],U=new Set(r.selectedGrant?[r.selectedGrant.subjectUserId,r.selectedGrant.targetUserId]:r.selectedUserId?[r.selectedUserId]:[]);return N.map(({user:a,position:o})=>{const h=U.has(a.id),s=a.id===r.selectedUserId;return{id:a.id,position:o,draggable:!1,selectable:!1,data:{label:e.jsxs("div",{className:`min-w-[206px] rounded-[22px] border px-4 py-4 shadow-[0_24px_60px_rgba(0,0,0,0.28)] transition ${s?"border-[rgba(244,185,122,0.45)] bg-[rgba(27,16,10,0.92)]":h?"border-white/18 bg-[rgba(14,20,34,0.94)]":"border-white/10 bg-[rgba(9,15,28,0.92)]"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(C,{user:a}),e.jsx(f,{className:"bg-white/[0.08] text-white/65",children:a.kind})]}),e.jsxs("div",{className:"mt-3 text-xs text-white/52",children:["@",a.handle]}),e.jsx("div",{className:"mt-2 line-clamp-2 text-xs leading-5 text-white/46",children:a.description||"No user description yet."})]})},style:{background:"transparent",border:"none",padding:0}}})}function je(t,r,i){return t.filter(x=>x.subjectUserId!==x.targetUserId).map(x=>{const u=r===x.id,g=i!==null&&(x.subjectUserId===i||x.targetUserId===i),d=F(x),w=u?"#f4b97a":!x.config.rights.discoverable&&!x.config.rights.canReadEntities?"rgba(248,113,113,0.55)":g?"rgba(192,193,255,0.78)":"rgba(255,255,255,0.32)";return{id:x.id,source:x.subjectUserId,target:x.targetUserId,label:`${q(x)} · ${d}/${I}`,markerEnd:{type:le.ArrowClosed,color:w},labelStyle:{fill:u?"#f4b97a":"rgba(255,255,255,0.68)",fontSize:11,fontWeight:600},labelBgStyle:{fill:u?"rgba(34,23,16,0.96)":"rgba(8,13,24,0.94)",stroke:u?"rgba(244,185,122,0.36)":"rgba(255,255,255,0.14)",strokeWidth:1},labelBgPadding:[7,5],labelBgBorderRadius:8,style:{stroke:w,strokeWidth:u?2.5:g?1.8:1.25},animated:u}})}function ve({users:t,grants:r,selectedGrantId:i=null,selectedUserId:x=null,onOpenGrant:u,onOpenUser:g}){const d=r.find(o=>o.id===i)??null,w=p.useMemo(()=>we(t,{selectedUserId:x,selectedGrant:d}),[d,x,t]),v=p.useMemo(()=>je(r,i,x),[r,i,x]),b=p.useMemo(()=>r.filter(o=>o.subjectUserId!==o.targetUserId),[r]),N=b.filter(o=>F(o)===I).length,U=b.filter(o=>o.config.rights.canCoordinate).length,a=b.filter(o=>o.config.rights.canAffectEntities||o.config.rights.canCreateOnBehalf).length;return e.jsxs(S,{className:"overflow-hidden p-0",children:[e.jsxs("div",{className:"grid gap-4 border-b border-white/8 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-white/45",children:"Directed relationship graph"}),e.jsx(ce,{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-white/58",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(f,{className:"bg-white/[0.08] text-white/70",children:[b.length," edges"]}),e.jsxs(f,{className:"bg-emerald-500/12 text-emerald-200",children:[N," fully open"]})]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Full collaboration"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:N}),e.jsx("div",{className:"text-xs leading-5 text-white/48",children:"Directions still running with the default fully open posture."})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Coordination lanes"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:U}),e.jsx("div",{className:"text-xs leading-5 text-white/48",children:"Directions allowed to coordinate directly through Forge."})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Execution control"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:a}),e.jsx("div",{className:"text-xs leading-5 text-white/48",children:"Directions allowed to create or mutate target-owned work."})]})]})]}),e.jsx("div",{className:"h-[min(72vh,54rem)] min-h-[34rem] bg-[radial-gradient(circle_at_top,rgba(244,185,122,0.08),transparent_34%),linear-gradient(180deg,rgba(6,10,20,0.97),rgba(8,14,26,0.94))]",children:e.jsxs(ae,{className:"user-relationship-flow",nodes:w,edges:v,fitView:!0,fitViewOptions:{padding:.18,maxZoom:.95},nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,onNodeClick:(o,h)=>{g(h.id)},onEdgeClick:(o,h)=>{u(h.id)},attributionPosition:"bottom-left",children:[e.jsx(ne,{showInteractive:!1}),e.jsx(re,{gap:28,size:1,color:"rgba(255,255,255,0.06)"})]})})]})}const Ne={kind:"human",handle:"",displayName:"",description:"",accentColor:"#c0c1ff"};function W(t){return t?{kind:t.kind,handle:t.handle,displayName:t.displayName,description:t.description,accentColor:t.accentColor}:Ne}function ye({open:t,onOpenChange:r,user:i,grants:x,ownership:u,xp:g,pending:d=!1,onSubmit:w,onOpenRelationship:v}){const[b,N]=p.useState(()=>W(i)),[U,a]=p.useState(null);p.useEffect(()=>{t&&(N(W(i)),a(null))},[t,i]);const o=p.useMemo(()=>x.filter(c=>c.subjectUserId!==c.targetUserId),[x]),h=p.useMemo(()=>i?o.filter(c=>c.subjectUserId===i.id):[],[o,i]),s=p.useMemo(()=>i?o.filter(c=>c.targetUserId===i.id):[],[o,i]),y=[{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:(c,m)=>e.jsxs(e.Fragment,{children:[e.jsx(M,{label:"Kind",description:"Humans represent real people. Bots represent agents or automations with their own ownership lane.",children:e.jsx(T,{columns:2,value:c.kind,onChange:k=>m({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(M,{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(R,{value:c.handle,onChange:k=>m({handle:k.target.value}),placeholder:"forge-operator"})}),e.jsx(M,{label:"Display name",description:"This is the human-readable label used across the UI.",children:e.jsx(R,{value:c.displayName,onChange:k=>m({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:(c,m)=>e.jsxs(e.Fragment,{children:[e.jsx(M,{label:"Description",description:"Explain what this user is responsible for and what side of the system it represents.",children:e.jsx(oe,{value:c.description,onChange:k=>m({description:k.target.value}),className:"min-h-36",placeholder:"Primary human operator for strategy, execution, and review."})}),e.jsx(M,{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(R,{value:c.accentColor,onChange:k=>m({accentColor:k.target.value}),placeholder:"#c0c1ff"}),e.jsx("div",{className:"size-10 shrink-0 rounded-full border border-white/10",style:{backgroundColor:c.accentColor||"#c0c1ff"}})]})}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[20px] border border-white/8 bg-white/[0.03] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Owned records"}),e.jsx("div",{className:"mt-2 text-white",children:(u==null?void 0:u.totalOwnedEntities)??0})]}),e.jsxs("div",{className:"rounded-[20px] border border-white/8 bg-white/[0.03] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Total XP"}),e.jsx("div",{className:"mt-2 text-white",children:(g==null?void 0:g.totalXp)??0})]}),e.jsxs("div",{className:"rounded-[20px] border border-white/8 bg-white/[0.03] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Weekly XP"}),e.jsx("div",{className:"mt-2 text-white",children:(g==null?void 0:g.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:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx(C,{user:i}),e.jsxs("div",{className:"mt-3 text-sm leading-6 text-white/56",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:"text-sm font-medium text-white",children:"Outbound lanes"}),h.length>0?h.map(c=>e.jsxs("button",{type:"button",className:"rounded-[20px] border border-white/8 bg-white/[0.03] px-4 py-4 text-left transition hover:bg-white/[0.05]",onClick:()=>v(c.id),children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(C,{user:c.subjectUser}),e.jsx("span",{className:"text-white/45",children:"→"}),e.jsx(C,{user:c.targetUser})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(f,{className:"bg-white/[0.08] text-white/74",children:q(c)}),e.jsxs(f,{className:"bg-white/[0.08] text-white/74",children:[F(c),"/",I," rights"]})]})]},c.id)):e.jsx("div",{className:"rounded-[20px] border border-dashed border-white/10 bg-white/[0.02] px-4 py-4 text-sm text-white/52",children:"No outbound relationship lanes yet."})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:"Inbound lanes"}),s.length>0?s.map(c=>e.jsxs("button",{type:"button",className:"rounded-[20px] border border-white/8 bg-white/[0.03] px-4 py-4 text-left transition hover:bg-white/[0.05]",onClick:()=>v(c.id),children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(C,{user:c.subjectUser}),e.jsx("span",{className:"text-white/45",children:"→"}),e.jsx(C,{user:c.targetUser})]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:Z(c).map(m=>e.jsx(f,{className:m.enabled?"bg-white/[0.08] text-white/74":"bg-white/[0.04] text-white/38",children:m.label},`${c.id}-${m.id}`))})]},c.id)):e.jsx("div",{className:"rounded-[20px] border border-dashed border-white/10 bg-white/[0.02] px-4 py-4 text-sm text-white/52",children:"No inbound relationship lanes yet."})]})]})]}):e.jsx("div",{className:"rounded-[20px] border border-dashed border-white/10 bg-white/[0.02] px-4 py-4 text-sm leading-6 text-white/52",children:"Create the user first, then Forge will generate the directional relationship lanes you can tune from here."})}];return e.jsx(K,{open:t,onOpenChange:r,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:b,onChange:N,draftPersistenceKey:i?`users.settings.${i.id}`:"users.settings.new",steps:y,submitLabel:i?"Save user":"Create user",pending:d,pendingLabel:i?"Saving user":"Creating user",error:U,contentClassName:"lg:w-[min(58rem,calc(100vw-1.5rem))]",onSubmit:async()=>{const c=b.handle.trim(),m=b.displayName.trim();if(c.length===0){a("Add a handle before saving this user.");return}if(m.length===0){a("Add a display name before saving this user.");return}await w({userId:i==null?void 0:i.id,input:{kind:b.kind,handle:c,displayName:m,description:b.description.trim(),accentColor:b.accentColor.trim()||"#c0c1ff"}}),r(!1)}})}function z(t,r){return{accessLevel:(t==null?void 0:t.accessLevel)??"manage",applyScope:"this_arrow",rights:{discoverable:(t==null?void 0:t.config.rights.discoverable)??!0,canListUsers:(t==null?void 0:t.config.rights.canListUsers)??!0,canReadProfile:(t==null?void 0:t.config.rights.canReadProfile)??!0,canReadEntities:(t==null?void 0:t.config.rights.canReadEntities)??!0,canSearchEntities:(t==null?void 0:t.config.rights.canSearchEntities)??!0,canLinkEntities:(t==null?void 0:t.config.rights.canLinkEntities)??!0,canCoordinate:(t==null?void 0:t.config.rights.canCoordinate)??!0,canAffectEntities:(t==null?void 0:t.config.rights.canAffectEntities)??!0,canManageStrategies:(t==null?void 0:t.config.rights.canManageStrategies)??!0,canCreateOnBehalf:(t==null?void 0:t.config.rights.canCreateOnBehalf)??!0,canViewMetrics:(t==null?void 0:t.config.rights.canViewMetrics)??!0,canViewActivity:(t==null?void 0:t.config.rights.canViewActivity)??!0}}}function ke({open:t,onOpenChange:r,grant:i,grants:x,pending:u=!1,onSubmit:g}){const d=p.useMemo(()=>i?x.find(a=>a.subjectUserId===i.targetUserId&&a.targetUserId===i.subjectUserId)??null:null,[i,x]),[w,v]=p.useState(()=>z(i,!!d));p.useEffect(()=>{t&&v(z(i,!!d))},[i,t,d]);const b=p.useMemo(()=>Object.values(w.rights).filter(Boolean).length,[w.rights]),N=Math.round(b/I*100),U=[{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,o)=>e.jsxs(e.Fragment,{children:[i?e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(C,{user:i.subjectUser}),e.jsx("span",{className:"text-white/45",children:"→"}),e.jsx(C,{user:i.targetUser})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(f,{className:"bg-white/[0.08] text-white/74",children:be(i)}),e.jsxs(f,{className:"bg-white/[0.08] text-white/74",children:[F(i),"/",I," 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:"text-sm font-medium text-white",children:"Access level"}),e.jsx(T,{columns:2,value:a.accessLevel,onChange:h=>o({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:"text-sm font-medium text-white",children:"Apply scope"}),e.jsx(T,{columns:2,value:a.applyScope,onChange:h=>o({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:"text-sm font-medium text-white",children:"Quick preset"}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:me.map(h=>e.jsxs("button",{type:"button",className:`rounded-[22px] border p-4 text-left transition ${i&&fe(i,h)?"border-[rgba(244,185,122,0.35)] bg-[rgba(244,185,122,0.08)]":"border-white/8 bg-white/[0.03] hover:bg-white/[0.05]"}`,onClick:()=>o({rights:{...a.rights,...h.rights}}),children:[e.jsx("div",{className:"text-sm font-medium text-white",children:h.label}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/56",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,o)=>e.jsx(e.Fragment,{children:Q.map(h=>e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-white",children:h.label}),e.jsx("div",{className:"mt-1 text-sm leading-6 text-white/54",children:h.description})]}),e.jsx("div",{className:"grid gap-2",children:h.rights.map(s=>e.jsxs("label",{className:"flex items-start justify-between gap-3 rounded-[18px] border border-white/8 bg-white/[0.03] px-4 py-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-white",children:s.label}),e.jsx("div",{className:"mt-1 text-xs leading-5 text-white/50",children:s.description})]}),e.jsx("input",{type:"checkbox",checked:a.rights[s.key],onChange:y=>o({rights:{...a.rights,[s.key]:y.target.checked}})})]},s.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 o,h;return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:"Capability coverage"}),e.jsx("div",{className:"mt-4",children:e.jsx(de,{value:N})}),e.jsxs("div",{className:"mt-3 text-sm text-white/62",children:[b,"/",I," rights enabled"]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:Z({...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(s=>e.jsx(f,{className:s.enabled?"bg-white/[0.08] text-white/74":"bg-white/[0.04] text-white/38",children:s.label},s.id))})]}),e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:"Save scope"}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/58",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(f,{className:"bg-white/[0.08] text-white/74",children:["access ",a.accessLevel]}),e.jsxs(f,{className:"bg-white/[0.08] text-white/74",children:["scope"," ",a.applyScope==="both_arrows"&&d?"both arrows":"this arrow"]})]}),d?e.jsxs("div",{className:"mt-4 rounded-[18px] border border-white/8 bg-white/[0.03] px-4 py-3 text-sm text-white/54",children:["Reverse arrow available:"," ",((o=d.subjectUser)==null?void 0:o.displayName)??d.subjectUserId," ","→"," ",((h=d.targetUser)==null?void 0:h.displayName)??d.targetUserId]}):null]})]})})}}];return e.jsx(K,{open:t,onOpenChange:r,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:w,onChange:v,draftPersistenceKey:i?`users.relationship.${i.id}`:"users.relationship.new",steps:U,submitLabel:"Save relationship",pending:u,pendingLabel:"Saving relationship",contentClassName:"lg:w-[min(62rem,calc(100vw-1.5rem))]",onSubmit:async()=>{i&&(await g({grantId:i.id,patch:{accessLevel:w.accessLevel,rights:w.rights},reverseGrantId:(d==null?void 0:d.id)??null,applyToReverse:w.applyScope==="both_arrows"&&d!==null}),r(!1))}})}function Le(){var P;const t=he(),[r,i]=p.useState(null),[x,u]=p.useState(null),[g,d]=p.useState(!1),[w,v]=p.useState(!1),[b,N]=p.useState(""),U=te({queryKey:["forge-user-directory"],queryFn:ge}),a=async()=>{await Promise.all([t.refresh(),U.refetch()])},o=$({mutationFn:async({input:n,userId:l})=>l?(await xe(l,n)).user:(await ue(n)).user,onSuccess:async()=>{i(null),d(!1),await a()}}),h=$({mutationFn:async({grantId:n,patch:l})=>(await pe(n,l)).grant,onSuccess:a}),s=(P=U.data)==null?void 0:P.directory,y=(s==null?void 0:s.grants.find(n=>n.id===x))??null,c=p.useMemo(()=>new Map(((s==null?void 0:s.ownership)??[]).map(n=>[n.userId,n])),[s==null?void 0:s.ownership]),m=p.useMemo(()=>new Map(((s==null?void 0:s.xp)??[]).map(n=>[n.userId,n])),[s==null?void 0:s.xp]),k=p.useMemo(()=>{const n=new Map;for(const l of(s==null?void 0:s.grants)??[]){if(!l.targetUser||l.subjectUserId===l.targetUserId)continue;const j=n.get(l.subjectUserId)??[];j.push(l.targetUser),n.set(l.subjectUserId,j)}return n},[s==null?void 0:s.grants]),O=p.useMemo(()=>{const n=((s==null?void 0:s.grants)??[]).filter(l=>l.subjectUserId!==l.targetUserId);return{totalEdges:n.length,fullyOpenEdges:n.filter(l=>Object.values(l.config.rights).every(Boolean)).length,coordinationEdges:n.filter(l=>l.config.rights.canCoordinate).length,executionEdges:n.filter(l=>l.config.rights.canAffectEntities||l.config.rights.canCreateOnBehalf).length}},[s==null?void 0:s.grants]),A=b.trim().toLowerCase(),B=p.useMemo(()=>{const l=((s==null?void 0:s.users)??t.snapshot.users).filter(j=>A?[j.displayName,j.handle,j.kind,j.description].join(" ").toLowerCase().includes(A):!0);return{humans:l.filter(j=>j.kind==="human"),bots:l.filter(j=>j.kind==="bot")}},[s==null?void 0:s.users,A,t.snapshot.users]),J=(y==null?void 0:y.subjectUserId)??(r==null?void 0:r.id)??null,Y=(y==null?void 0:y.id)??null;return e.jsxs("div",{className:"mx-auto grid w-full max-w-[1440px] gap-5",children:[e.jsx(ie,{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:`${t.snapshot.users.length} users`}),e.jsx(se,{}),e.jsx(ye,{open:g,onOpenChange:d,user:r,grants:(s==null?void 0:s.grants)??[],ownership:r?c.get(r.id)??null:null,xp:r?m.get(r.id)??null:null,pending:o.isPending,onSubmit:async n=>{await o.mutateAsync(n)},onOpenRelationship:n=>{d(!1),u(n),v(!0)}}),e.jsx(ke,{open:w,onOpenChange:v,grant:y,grants:(s==null?void 0:s.grants)??[],pending:h.isPending,onSubmit:async n=>{await h.mutateAsync({grantId:n.grantId,patch:n.patch}),n.applyToReverse&&n.reverseGrantId&&await h.mutateAsync({grantId:n.reverseGrantId,patch:n.patch})}}),e.jsxs(S,{className:"grid gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Multi-user posture"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/60",children:(s==null?void 0:s.posture.summary)??"Forge is preparing modular user access while keeping the current posture permissive."})]}),e.jsx(f,{className:"bg-white/[0.08] text-white/72",children:(s==null?void 0:s.posture.accessModel)??"permissive"})]}),e.jsx("div",{className:"flex items-center gap-3 rounded-[18px] bg-white/[0.04] px-4 py-3",children:e.jsx(R,{value:b,onChange:n=>N(n.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(S,{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-white/45",children:"Multi-agent onboarding"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/60",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(f,{className:"bg-white/[0.08] text-white/72",children:"default open"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Directional edges"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:O.totalEdges})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Fully open"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:O.fullyOpenEdges})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Coordination"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:O.coordinationEdges})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Execution control"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:O.executionEdges})]})]}),e.jsxs("div",{className:"grid gap-2 text-sm leading-6 text-white/56",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(ve,{users:(s==null?void 0:s.users)??t.snapshot.users,grants:(s==null?void 0:s.grants)??[],selectedGrantId:Y,selectedUserId:J,onOpenUser:n=>{const l=((s==null?void 0:s.users)??t.snapshot.users).find(j=>j.id===n)??null;u(null),i(l),d(!0)},onOpenGrant:n=>{i(null),u(n),v(!0)}}),e.jsxs(S,{className:"grid gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Agent onboarding"}),e.jsx("div",{className:"text-sm leading-6 text-white/60",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:"text-sm leading-6 text-white/52",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(ee,{to:"/settings/agents",className:"inline-flex min-h-10 items-center justify-center rounded-[var(--radius-control)] bg-white/8 px-3 py-2 text-[13px] font-medium text-white transition hover:bg-white/12",children:"Open agent onboarding"})})]})]}),e.jsx(S,{children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"User directory"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/60",children:"Open any user to edit its identity and jump into the exact directional relationship lanes from the user settings flow."})]}),e.jsx(X,{onClick:()=>{u(null),i(null),d(!0)},children:"Create user"})]})}),e.jsx("div",{className:"grid gap-5",children:[{title:"Human users",users:B.humans},{title:"Bot users",users:B.bots}].map(n=>e.jsxs(S,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:n.title}),e.jsx(f,{className:"bg-white/[0.08] text-white/72",children:n.users.length})]}),e.jsx("div",{className:"mt-4 grid gap-3",children:n.users.map(l=>{var j,D,G,_,H,V;return e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] 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(C,{user:l}),e.jsxs("div",{className:"mt-3 text-sm text-white/58",children:["@",l.handle]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/60",children:l.description||"No description yet."}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(f,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:[((j=m.get(l.id))==null?void 0:j.totalXp)??0," XP"]}),e.jsxs(f,{className:"bg-white/[0.08] text-white/70",children:[((D=m.get(l.id))==null?void 0:D.weeklyXp)??0," weekly"]}),e.jsxs(f,{className:"bg-white/[0.08] text-white/70",children:[((G=m.get(l.id))==null?void 0:G.rewardEventCount)??0," ","rewards"]}),Object.entries(((_=c.get(l.id))==null?void 0:_.entityCounts)??{}).sort((E,L)=>L[1]-E[1]).slice(0,4).map(([E,L])=>e.jsxs(f,{className:"bg-white/[0.08] text-white/70",children:[L," ",E]},`${l.id}-${E}`)),e.jsxs(f,{className:"bg-white/[0.08] text-white/70",children:[((H=c.get(l.id))==null?void 0:H.totalOwnedEntities)??0," ","owned"]})]}),e.jsxs("div",{className:"mt-3 text-xs leading-5 text-white/50",children:["Can currently read:"," ",(k.get(l.id)??[]).map(E=>`${E.displayName} (${E.kind})`).join(", ")||"no other users"]}),(V=m.get(l.id))!=null&&V.lastRewardAt?e.jsxs("div",{className:"mt-2 text-xs leading-5 text-white/45",children:["Last XP movement:"," ",new Date(m.get(l.id).lastRewardAt).toLocaleString()]}):null]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(X,{variant:"secondary",onClick:()=>{u(null),i(l),d(!0)},children:"Open settings"})})]})},l.id)})})]},n.title))})]})]})}export{Le as SettingsUsersPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as d,j as e,aC as y,bg as j,cD as N}from"./vendor-kIz9EZnX.js";import{j as S,i as W,k as o}from"./state-VYvD1QVP.js";import{S as C}from"./settings-section-nav-Dc4IeVBt.js";import{P as K}from"./page-hero-oFHaAjtL.js";import{bV as L,bW as P,bX as M,L as Q,E as w,B as l,C as f,aq as A,I as k,bY as q}from"./index-BHIKoiZ6.js";import"./motion-CfdU2F35.js";import"./ui-CsEkP2V8.js";import"./forms-CmLAyGqz.js";import"./board-DqHzdCPQ.js";import"./graph-BTa79qum.js";function H(){var b;const a=S(),[n,c]=d.useState(""),[p,g]=d.useState(""),[m,x]=d.useState("personal"),s=W({queryKey:["forge-wiki-settings"],queryFn:q}),r=async()=>{await Promise.all([a.invalidateQueries({queryKey:["forge-wiki-settings"]}),a.invalidateQueries({queryKey:["forge-wiki-pages"]}),a.invalidateQueries({queryKey:["forge-wiki-page"]}),a.invalidateQueries({queryKey:["forge-wiki-search"]})])},h=o({mutationFn:()=>L({label:n.trim(),description:p.trim(),visibility:m}),onSuccess:async()=>{c(""),g(""),x("personal"),await r()}}),u=o({mutationFn:()=>P(),onSuccess:r}),v=o({mutationFn:()=>M(),onSuccess:r});if(s.isLoading)return e.jsx(Q,{eyebrow:"KarpaWiki settings",title:"Loading KarpaWiki controls",description:"Fetching spaces and profile configuration for KarpaWiki."});if(s.isError)return e.jsx(w,{eyebrow:"KarpaWiki settings",error:s.error,onRetry:()=>void s.refetch()});const t=(b=s.data)==null?void 0:b.settings;return t?e.jsxs("div",{className:"mx-auto grid w-full max-w-[1440px] gap-5",children:[e.jsx(K,{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:`${t.spaces.length} spaces · ${t.embeddingProfiles.length} embedding profiles`,actions:e.jsxs(e.Fragment,{children:[e.jsxs(y,{to:"/settings/models",className:"inline-flex min-h-11 items-center rounded-[16px] bg-white/[0.08] px-4 py-3 text-sm text-white transition hover:bg-white/[0.12]",children:["Open model settings",e.jsx(j,{className:"ml-2 size-4"})]}),e.jsx(l,{variant:"secondary",pending:u.isPending,pendingLabel:"Syncing",onClick:()=>void u.mutateAsync(),children:"Refresh indexes"}),e.jsx(l,{pending:v.isPending,pendingLabel:"Reindexing",onClick:()=>void v.mutateAsync(),disabled:t.embeddingProfiles.length===0,children:"Reindex embeddings"})]})}),e.jsx(C,{}),e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(f,{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 text-white",children:"Model configuration moved"}),e.jsx("div",{className:"text-xs leading-5 text-white/50",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:"inline-flex min-h-11 w-fit items-center rounded-[16px] bg-white/[0.08] px-4 py-3 text-sm text-white transition hover:bg-white/[0.12]",children:["Manage KarpaWiki models and embeddings",e.jsx(j,{className:"ml-2 size-4"})]})]}),e.jsx("div",{className:"grid gap-5",children:e.jsxs(f,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(N,{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 text-white",children:"Spaces"}),e.jsx(A,{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 text-white/50",children:"Personal and shared wiki spaces map to explicit SQLite namespaces."})]})]}),e.jsx("div",{className:"grid gap-3",children:t.spaces.map(i=>e.jsxs("div",{className:"grid gap-1 rounded-[18px] bg-white/[0.04] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-white",children:i.label}),e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-white/42",children:i.visibility})]}),e.jsx("div",{className:"text-xs text-white/46",children:i.slug}),e.jsx("div",{className:"text-sm text-white/60",children:i.description||"No description yet."})]},i.id))}),e.jsxs("div",{className:"grid gap-3 rounded-[20px] bg-white/[0.03] p-4",children:[e.jsx(k,{value:n,onChange:i=>c(i.target.value),placeholder:"New space label"}),e.jsx(k,{value:p,onChange:i=>g(i.target.value),placeholder:"Description"}),e.jsxs("select",{className:"rounded-[16px] border border-white/10 bg-white/[0.04] px-3 py-3 text-sm text-white",value:m,onChange:i=>x(i.target.value),children:[e.jsx("option",{value:"personal",children:"Personal"}),e.jsx("option",{value:"shared",children:"Shared"})]}),e.jsx(l,{pending:h.isPending,pendingLabel:"Creating",disabled:!n.trim(),onClick:()=>void h.mutateAsync(),children:"Create space"})]})]})})]})]}):e.jsx(w,{eyebrow:"KarpaWiki settings",error:new Error("Forge returned an empty KarpaWiki settings payload."),onRetry:()=>void s.refetch()})}export{H as SettingsWikiPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as g,j as e,aV as te,cq as se,bX as ae}from"./vendor-kIz9EZnX.js";import{j as re,i as A,k as ie}from"./state-VYvD1QVP.js";import{u as ne,eC as de,S as le,E as ce,ch as oe,eD as xe,eE as me,C as S,c as p,eF as he,Z as v,B as C,I as Q,T as pe,m as ue,bL as ge,eG as we,bw as be,bx as ve,by as fe,bz as je,bC as ye}from"./index-BHIKoiZ6.js";import{P as Ne}from"./page-hero-oFHaAjtL.js";import{p as Se,b as ke}from"./health-link-options-Cpx8w7uM.js";import"./motion-CfdU2F35.js";import"./ui-CsEkP2V8.js";import"./forms-CmLAyGqz.js";import"./board-DqHzdCPQ.js";import"./graph-BTa79qum.js";const Ae=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],W={awake:{label:"Awake",strong:"rgba(251, 191, 36, 0.95)",soft:"rgba(251, 191, 36, 0.16)",text:"text-amber-200"},core:{label:"Core",strong:"rgba(165, 180, 252, 0.96)",soft:"rgba(165, 180, 252, 0.18)",text:"text-indigo-100"},deep:{label:"Deep",strong:"rgba(45, 212, 191, 0.96)",soft:"rgba(45, 212, 191, 0.18)",text:"text-teal-100"},rem:{label:"REM",strong:"rgba(96, 165, 250, 0.96)",soft:"rgba(96, 165, 250, 0.18)",text:"text-sky-100"},in_bed:{label:"In bed",strong:"rgba(255, 255, 255, 0.4)",soft:"rgba(255, 255, 255, 0.1)",text:"text-white/72"},asleep_unspecified:{label:"Asleep",strong:"rgba(196, 181, 253, 0.96)",soft:"rgba(196, 181, 253, 0.16)",text:"text-violet-100"}};function I(t){return W[t]??W.asleep_unspecified}function u(t){if(t<=0)return"0m";const s=Math.floor(t/3600),a=Math.round(t%3600/60);return s===0?`${a}m`:a===0?`${s}h`:`${s}h ${a}m`}function Te(t){const s=Math.round(t/60);return s===0?"on baseline":`${s>0?"+":"-"}${Math.abs(s)}m`}function R(t){return`${Math.round(t*100)}%`}function T(t,s){return t?new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",timeZone:s}).format(new Date(t)):"n/a"}function O(t,s){return new Intl.DateTimeFormat(void 0,{weekday:"long",day:"numeric",month:"long",timeZone:s}).format(new Date(t))}function q(t,s,a){return`${T(t,a)} - ${T(s,a)}`}function Re(t){const[s,a]=t.split("-").map(Number);return new Intl.DateTimeFormat(void 0,{month:"long",year:"numeric"}).format(new Date(s,(a??1)-1,1))}function U(t){const s=new Date(t),a=(t.getDay()+6)%7;return s.setDate(t.getDate()-a),s}function Me(t){const s=U(t);return s.setDate(s.getDate()+6),s}function _e(t){const s=t.getFullYear(),a=`${t.getMonth()+1}`.padStart(2,"0"),r=`${t.getDate()}`.padStart(2,"0");return`${s}-${a}-${r}`}function B(t){return{qualitySummary:typeof t.annotations.qualitySummary=="string"?t.annotations.qualitySummary:"",notes:typeof t.annotations.notes=="string"?t.annotations.notes:"",tagsText:Array.isArray(t.annotations.tags)?t.annotations.tags.join(", "):"",linkValues:Array.isArray(t.links)?t.links.map(s=>`${s.entityType}:${s.entityId}`):[]}}function De(t,s){if(!t)return[];const[a,r]=t.split("-").map(Number),n=new Date(a,(r??1)-1,1),x=new Date(a,r??1,0),d=U(n),h=Me(x),l=new Map(s.map(c=>[c.dateKey,c])),i=[];for(const c=new Date(d);c<=h;c.setDate(c.getDate()+1)){const j=_e(c);i.push({dateKey:j,dayNumber:c.getDate(),outsideMonth:c.getMonth()!==n.getMonth(),sleep:l.get(j)??null})}return i}function Ie(t){return t>0?"text-emerald-200":t<0?"text-rose-200":"text-white/70"}function G(t){return t==="recharged"||t==="recovered"?"bg-emerald-400/16 text-emerald-100":t==="steady"||t==="stable"?"bg-sky-400/16 text-sky-100":t==="fragile"||t==="strained"?"bg-amber-400/16 text-amber-100":t==="depleted"?"bg-rose-400/16 text-rose-100":"bg-white/10 text-white/76"}function Be(t){return t==="provider_raw"?"bg-emerald-400/16 text-emerald-100":t==="historical_raw"?"bg-amber-400/16 text-amber-100":"bg-white/10 text-white/70"}function qe(t){return t==="provider_raw"?"Provider raw data":t==="historical_raw"?"Historical raw data":"Raw data unavailable"}function Ce(t){return t.qualityKind==="provider_native"?"bg-emerald-400/16 text-emerald-100":"bg-amber-400/16 text-amber-100"}function $e(t,s){const a=t.stage;if(typeof a=="string"&&a.trim().length>0)return a;const r=t.sourceType;if(typeof r=="string"&&r.trim().length>0)return r;const n=t.stageBreakdown;if(Array.isArray(n)&&n.length>0){const x=n[0];if(x&&typeof x=="object"&&typeof x.stage=="string")return(x.stage||"asleep_unspecified").trim()}return s.includes("awake")?"awake":"asleep_unspecified"}function Ee(t){const s=t,a=(s==null?void 0:s.segments)??(s==null?void 0:s.rawSegments)??[],r=(s==null?void 0:s.auditLogs)??(s==null?void 0:s.rawLogs)??[],n=s!=null&&s.sourceRecords&&s.sourceRecords.length>0?s.sourceRecords:r.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})),x=(s==null?void 0:s.rawDataStatus)??(n.length>0?"historical_raw":"raw_unavailable");return{sourceRecords:n,segments:a,auditLogs:r,rawDataStatus:x}}function J({stages:t}){const s=t.reduce((a,r)=>a+r.seconds,0);return t.length===0||s===0?e.jsx("div",{className:"rounded-[18px] border border-dashed border-white/10 bg-black/10 px-4 py-4 text-sm text-white/52",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-white/[0.08]",children:t.map(a=>{const r=I(a.stage);return e.jsx("div",{className:"h-full",style:{width:`${Math.max(4,a.seconds/s*100)}%`,background:r.strong},title:`${r.label} · ${u(a.seconds)}`},a.stage)})}),e.jsx("div",{className:"grid gap-2 sm:grid-cols-2 xl:grid-cols-4",children:t.map(a=>{const r=I(a.stage),n="percentage"in a&&typeof a.percentage=="number"?a.percentage:s>0?a.seconds/s:0;return e.jsxs("div",{className:"rounded-[16px] border border-white/8 px-3 py-3",style:{background:r.soft},children:[e.jsx("div",{className:v("text-sm font-medium",r.text),children:r.label}),e.jsx("div",{className:"mt-1 text-lg text-white",children:u(a.seconds)}),e.jsx("div",{className:"text-xs text-white/54",children:R(n)})]},a.stage)})})]})}function H({blocks:t,selectedBlockId:s,onSelect:a}){return e.jsxs("div",{className:"relative h-12 overflow-hidden rounded-[18px] border border-white/8 bg-black/20",children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[linear-gradient(90deg,rgba(255,255,255,0.06)_1px,transparent_1px)] bg-[length:25%_100%]"}),t.map(r=>{const n=I(r.stage),x=s===r.id;return e.jsx("button",{type:"button",onClick:()=>a(r.id),className:v("absolute inset-y-[5px] rounded-[12px] border transition",x?"border-white/60 shadow-[0_0_0_1px_rgba(255,255,255,0.18)]":"border-white/10"),style:{left:`${r.offsetRatio*100}%`,width:`${Math.max(r.widthRatio*100,1.8)}%`,background:n.strong},title:`${r.label} · ${u(r.durationSeconds)} · ${r.startedAt} - ${r.endedAt}`,children:r.widthRatio>.13?e.jsx("span",{className:"truncate px-2 text-[10px] font-medium text-slate-950/85",children:r.label}):null},r.id)})]})}function Ke({timeline:t,timeZone:s}){var l,i;const a=t.blocks.filter(c=>c.lane==="in_bed"),r=t.blocks.filter(c=>c.lane==="sleep"),n=((l=r[0])==null?void 0:l.id)??((i=a[0])==null?void 0:i.id)??null,[x,d]=g.useState(n);g.useEffect(()=>{d(n)},[n,t.startedAt,t.endedAt,t.totalSeconds]);const h=t.blocks.find(c=>c.id===x)??null;return t.hasRawSegments?e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-3",children:[a.length>0?e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"In bed window"}),e.jsx(H,{blocks:a,selectedBlockId:x,onSelect:d})]}):null,e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:t.hasSleepStageData?"Sleep phases":"Recorded sleep coverage"}),e.jsx(H,{blocks:r.length>0?r:a,selectedBlockId:x,onSelect:d})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs text-white/48",children:[e.jsx("span",{children:T(t.startedAt,s)}),e.jsx("span",{children:u(t.totalSeconds)}),e.jsx("span",{children:T(t.endedAt,s)})]}),h?e.jsx("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.03] 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:v("text-sm font-medium",I(h.stage).text),children:h.label}),e.jsxs("div",{className:"mt-1 text-sm text-white/58",children:[T(h.startedAt,s)," -"," ",T(h.endedAt,s)]})]}),e.jsx(p,{tone:"meta",children:u(h.durationSeconds)})]})}):null]}):e.jsx("div",{className:"rounded-[18px] border border-dashed border-white/10 bg-black/10 px-4 py-5 text-sm text-white/56",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:t}){return t?e.jsx(S,{className:"overflow-hidden border-white/8 bg-[linear-gradient(135deg,rgba(7,17,40,0.96),rgba(16,24,54,0.94))] 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-[radial-gradient(circle_at_top_right,rgba(96,165,250,0.22),transparent_36%),radial-gradient(circle_at_bottom_left,rgba(45,212,191,0.14),transparent_34%)]"}),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(p,{className:v("border-white/0",G(t.recoveryState)),children:t.qualitativeState}),e.jsx(p,{tone:"meta",children:t.sourceTimezone}),t.hasReflection?e.jsx(p,{tone:"meta",children:"Has reflection"}):null,t.hasRawSegments?e.jsxs(p,{tone:"meta",children:[t.rawSegmentCount," raw segments"]}):null]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.2em] text-white/42",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-white",children:u(t.asleepSeconds)}),e.jsxs("div",{className:"pb-2 text-sm text-white/58",children:["asleep across ",q(t.startedAt,t.endedAt,t.sourceTimezone)]})]}),e.jsx("div",{className:"mt-3 text-sm text-white/64",children:O(t.endedAt,t.sourceTimezone)}),t.qualitySummary?e.jsx("div",{className:"mt-4 max-w-2xl text-sm leading-6 text-white/72",children:t.qualitySummary}):e.jsx("div",{className:"mt-4 max-w-2xl text-sm leading-6 text-white/56",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-white/8 bg-black/20 px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"In bed"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:u(t.timeInBedSeconds)})]}),e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-black/20 px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"Score"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:t.score??"n/a"})]}),e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-black/20 px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"Regularity"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:t.regularity??"n/a"})]}),e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-black/20 px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"Efficiency"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:R(t.efficiency)})]})]})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-black/20 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-white/40",children:"Baseline"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:"Compared with recent nights"})]}),e.jsx(se,{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-white/[0.04] px-4 py-3",children:[e.jsx("span",{className:"text-sm text-white/60",children:"7-night average"}),e.jsx("span",{className:"text-sm text-white",children:u(t.weeklyAverageSleepSeconds)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[16px] bg-white/[0.04] px-4 py-3",children:[e.jsx("span",{className:"text-sm text-white/60",children:"Versus baseline"}),e.jsx("span",{className:v("text-sm",Ie(t.deltaFromWeeklyAverageSeconds)),children:Te(t.deltaFromWeeklyAverageSeconds)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[16px] bg-white/[0.04] px-4 py-3",children:[e.jsx("span",{className:"text-sm text-white/60",children:"Bedtime drift"}),e.jsxs("span",{className:"text-sm text-white",children:[t.bedtimeDriftMinutes??0,"m"]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[16px] bg-white/[0.04] px-4 py-3",children:[e.jsx("span",{className:"text-sm text-white/60",children:"Wake drift"}),e.jsxs("span",{className:"text-sm text-white",children:[t.wakeDriftMinutes??0,"m"]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[16px] bg-white/[0.04] px-4 py-3",children:[e.jsx("span",{className:"text-sm text-white/60",children:"Restorative share"}),e.jsx("span",{className:"text-sm text-white",children:R(t.restorativeShare)})]})]})]}),e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-black/20 px-5 py-5",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"Stage composition"}),e.jsx("div",{className:"mt-4",children:e.jsx(J,{stages:t.stageBreakdown})})]})]})]})]})}):e.jsxs(S,{className:"overflow-hidden p-6",children:[e.jsx("div",{className:"text-sm uppercase tracking-[0.18em] text-white/42",children:"Sleep"}),e.jsx("div",{className:"mt-4 text-2xl text-white",children:"No overnight sleep yet"}),e.jsx("div",{className:"mt-3 max-w-2xl text-sm leading-6 text-white/58",children:"The sleep page will switch to a night-first summary once the companion syncs a canonical overnight session."})]})}function F({title:t,value:s,description:a}){return e.jsxs(S,{className:"h-full border-white/8 bg-white/[0.03]",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:t}),e.jsx("div",{className:"mt-3 text-3xl text-white",children:s}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/56",children:a})]})}function ze({days:t,selectedSleepId:s,onSelect:a}){const r=g.useMemo(()=>Array.from(new Set(t.map(l=>l.dateKey.slice(0,7)))).sort((l,i)=>l.localeCompare(i)),[t]),[n,x]=g.useState(r[r.length-1]??"");g.useEffect(()=>{if(r.length===0){x("");return}r.includes(n)||x(r[r.length-1]??"")},[n,r]);const d=r.indexOf(n),h=g.useMemo(()=>De(n,t),[t,n]);return n?e.jsx(S,{className:"overflow-hidden border-white/8 bg-[linear-gradient(180deg,rgba(10,17,33,0.98),rgba(12,20,40,0.96))] 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-white/42",children:"Sleep calendar"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:Re(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:()=>x(r[Math.max(0,d-1)]??n),children:"Previous"}),e.jsx(C,{type:"button",variant:"secondary",className:"h-9 rounded-full",disabled:d===-1||d>=r.length-1,onClick:()=>x(r[Math.min(r.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-white/38",children:Ae.map(l=>e.jsx("div",{children:l},l))}),e.jsx("div",{className:"grid grid-cols-7 gap-2",children:h.map(l=>{const i=l.sleep,c=(i==null?void 0:i.sleepId)===s,j=i&&typeof i.score=="number"?i.score>=80?"rgba(45,212,191,0.22)":i.score>=65?"rgba(96,165,250,0.22)":"rgba(251,191,36,0.18)":"rgba(255,255,255,0.04)";return e.jsxs("button",{type:"button",disabled:!i,"aria-pressed":c,"aria-label":`Select sleep for ${l.dateKey}`,onClick:()=>{i&&(x(i.dateKey.slice(0,7)),a(i.sleepId,i.dateKey.slice(0,7)))},className:v("min-h-[90px] rounded-[18px] border px-2 py-2 text-left transition",i?"border-white/10 hover:border-white/22 hover:bg-white/[0.05]":"border-white/6 bg-white/[0.02]",c&&"border-[var(--primary)] bg-[var(--primary)]/12",l.outsideMonth&&!i&&"opacity-35"),style:i?{background:`linear-gradient(180deg, ${j}, rgba(255,255,255,0.03))`}:void 0,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("span",{className:v("text-sm",l.outsideMonth?"text-white/40":"text-white/82"),children:l.dayNumber}),i!=null&&i.hasReflection?e.jsx("span",{className:"size-2 rounded-full bg-emerald-300"}):null]}),i?e.jsxs("div",{className:"mt-4 grid gap-1",children:[e.jsxs("div",{className:"text-lg text-white",children:[i.sleepHours.toFixed(1),"h"]}),e.jsxs("div",{className:"text-xs text-white/52",children:[i.score??"n/a"," score"]}),e.jsx("div",{className:"text-xs text-white/40",children:i.hasRawSegments?"phases available":"summary only"})]}):null]},l.dateKey)})})]})}):e.jsx(S,{className:"border-white/8 bg-white/[0.03] px-5 py-8 text-sm leading-6 text-white/56",children:"No canonical nights are available for the calendar yet."})}function z({active:t,children:s,onClick:a}){return e.jsx("button",{type:"button",onClick:a,className:v("rounded-full border px-4 py-2 text-sm transition",t?"border-[var(--primary)] bg-[var(--primary)]/12 text-white":"border-white/8 bg-white/[0.03] text-white/60 hover:text-white"),children:s})}function Le({session:t,draft:s,rawDetail:a,rawDetailLoading:r,pending:n,tab:x,linkOptions:d,onTabChange:h,onDraftChange:l,onSave:i}){const[c,j]=g.useState(null),y=g.useMemo(()=>Ee(a),[a]),$=typeof t.derived.efficiency=="number"?t.derived.efficiency:t.timeInBedSeconds>0?t.asleepSeconds/t.timeInBedSeconds:0,E=typeof t.derived.restorativeShare=="number"?t.derived.restorativeShare:0,M=typeof t.derived.recoveryState=="string"?t.derived.recoveryState:null;return e.jsx(S,{className:"overflow-hidden border-white/8 bg-[linear-gradient(180deg,rgba(10,17,33,0.98),rgba(13,20,38,0.96))] 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(p,{className:v("border-white/0",G(M)),children:M?M.replaceAll("_"," "):"Canonical night"}),e.jsxs(p,{tone:"meta",children:[t.rawSegmentCount," raw segments"]}),e.jsx(p,{tone:"meta",children:t.sourceTimezone})]}),e.jsx("div",{className:"mt-3 text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Selected night"}),e.jsx("div",{className:"mt-2 text-2xl text-white",children:O(t.endedAt,t.sourceTimezone)}),e.jsx("div",{className:"mt-2 text-sm text-white/56",children:q(t.startedAt,t.endedAt,t.sourceTimezone)})]}),e.jsxs("div",{className:"grid gap-2 text-right",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Summary"}),e.jsx("div",{className:"text-3xl text-white",children:u(t.asleepSeconds)}),e.jsx("div",{className:"text-sm text-white/54",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-white/8 bg-white/[0.03] px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"In bed"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:u(t.timeInBedSeconds)})]}),e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.03] px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"Awake"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:u(t.awakeSeconds)})]}),e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.03] px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"Efficiency"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:R($)})]}),e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.03] px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"Restorative"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:R(E)})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(z,{active:x==="summary",onClick:()=>h("summary"),children:"Summary"}),e.jsx(z,{active:x==="reflection",onClick:()=>h("reflection"),children:"Reflection"}),e.jsx(z,{active:x==="raw",onClick:()=>h("raw"),children:"Show raw data"})]}),x==="summary"?e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-black/18 px-4 py-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Phase timeline"}),e.jsx("div",{className:"mt-4",children:r?e.jsx("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.03] px-4 py-6 text-sm text-white/56",children:"Loading phase timing from raw sleep segments…"}):e.jsx(Ke,{timeline:(a==null?void 0:a.phaseTimeline)??{startedAt:t.startedAt,endedAt:t.endedAt,totalSeconds:Math.max(0,Math.round((new Date(t.endedAt).getTime()-new Date(t.startedAt).getTime())/1e3)),hasRawSegments:!1,hasSleepStageData:!1,blocks:[]},timeZone:t.sourceTimezone})})]}),e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-black/18 px-4 py-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Stage composition"}),e.jsx("div",{className:"mt-4",children:e.jsx(J,{stages:t.stageBreakdown})})]})]}):null,x==="reflection"?e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Quality summary"}),e.jsx(Q,{value:s.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-white/58",children:"Night notes"}),e.jsx(pe,{className:"min-h-[200px]",value:s.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-white/58",children:"Tags"}),e.jsx(Q,{value:s.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-white/58",children:"Linked context"}),e.jsx(ue,{options:d,selectedValues:s.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(ae,{className:"size-4"}),"Save reflection"]})})]}):null,x==="raw"?e.jsxs("div",{className:"grid gap-5",children:[e.jsx("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.03] px-4 py-4 text-sm leading-6 text-white/56",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."}),r?e.jsx("div",{className:"text-sm text-white/56",children:"Loading raw sleep evidence…"}):null,r?null:e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(p,{className:v("border-white/0",Be(y.rawDataStatus)),children:qe(y.rawDataStatus)}),y.rawDataStatus==="historical_raw"?e.jsx(p,{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-white/42",children:"Raw data"}),y.sourceRecords.length?y.sourceRecords.map(o=>e.jsxs("div",{className:"rounded-[16px] border border-white/8 bg-black/18 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(p,{className:v("border-white/0",Ce(o)),children:o.qualityKind==="provider_native"?"Provider raw":"Historical raw"}),e.jsx(p,{tone:"meta",className:"capitalize",children:o.rawStage.replaceAll("_"," ")}),e.jsx("span",{className:"text-sm text-white/64",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-white/42",children:o.providerRecordType.replaceAll("_"," ")}),e.jsx(C,{type:"button",variant:"secondary",className:"h-8 rounded-full px-3",onClick:()=>j(_=>_===o.id?null:o.id),children:c===o.id?"Hide JSON":"See JSON"})]})]}),e.jsx("div",{className:"mt-3 text-sm text-white/50",children:u(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-white/8 bg-slate-950/70 p-3 text-xs leading-6 text-white/72",children:JSON.stringify({payload:o.payload,metadata:o.metadata},null,2)}):null]},o.id)):e.jsx("div",{className:"rounded-[16px] border border-dashed border-white/10 bg-black/10 px-4 py-4 text-sm text-white/52",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-white/42",children:"Sleep segments"}),y.segments.length?y.segments.map(o=>e.jsx("div",{className:"rounded-[16px] border border-white/8 bg-black/18 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(p,{tone:"meta",className:"capitalize",children:o.stage.replaceAll("_"," ")}),e.jsx(p,{tone:"meta",children:o.qualityKind==="provider_native"?"provider-backed":"historical"}),e.jsx("span",{className:"text-sm text-white/64",children:q(o.startedAt,o.endedAt,o.sourceTimezone)})]}),e.jsx("span",{className:"text-sm text-white/50",children:u(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-white/10 bg-black/10 px-4 py-4 text-sm text-white/52",children:"No normalized sleep segments were stored for this night."})]})]})]}):null]})})}function Xe(){var V;const t=ne(),s=re(),[a,r]=g.useState({}),[n,x]=g.useState(null),[d,h]=g.useState("summary"),l=Array.isArray(t==null?void 0:t.selectedUserIds)?t.selectedUserIds:[],i=t==null?void 0:t.snapshot,c=A({queryKey:["forge-sleep",...l],queryFn:async()=>(await ge(l)).sleep}),j=A({queryKey:["forge-sleep-raw",n],enabled:!!n,queryFn:async()=>we(n)}),y=A({queryKey:["forge-sleep-values",...l],queryFn:async()=>(await be(l)).values}),$=A({queryKey:["forge-sleep-patterns",...l],queryFn:async()=>(await ve(l)).patterns}),E=A({queryKey:["forge-sleep-behaviors",...l],queryFn:async()=>(await fe(l)).behaviors}),M=A({queryKey:["forge-sleep-beliefs",...l],queryFn:async()=>(await je(l)).beliefs}),o=A({queryKey:["forge-sleep-reports",...l],queryFn:async()=>(await ye(l)).reports});g.useEffect(()=>{c.data&&r(Object.fromEntries(c.data.sessions.map(m=>[m.id,B(m)])))},[c.data]),g.useEffect(()=>{var N,f,k;if(!((N=c.data)!=null&&N.sessions.length)){x(null);return}c.data.sessions.some(K=>K.id===n)||x(((f=c.data.latestNight)==null?void 0:f.sleepId)??((k=c.data.sessions[0])==null?void 0:k.id)??null)},[n,c.data]),g.useEffect(()=>{h("summary")},[n]);const _=ie({mutationFn:async m=>de(m.sleepId,{qualitySummary:m.qualitySummary,notes:m.notes,tags:m.tagsText.split(",").map(N=>N.trim()).filter(Boolean),links:Se(m.linkValues)}),onSuccess:async()=>{await s.invalidateQueries({queryKey:["forge-sleep"]}),await s.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 w=c.data,D=w.sessions,L=new Map(D.map(m=>[m.id,m])),b=(n?L.get(n):null)??(w.latestNight?L.get(w.latestNight.sleepId):null)??D[0]??null,P=b?a[b.id]??B(b):null,Y=ke({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:y.data??[],patterns:$.data??[],behaviors:E.data??[],beliefs:M.data??[],reports:o.data??[]});function X(m,N){r(f=>{const k=D.find(ee=>ee.id===m),K=f[m]??(k?B(k):{qualitySummary:"",notes:"",tagsText:"",linkValues:[]});return{...f,[m]:{...K,...N}}})}async function Z(m){const N=D.find(k=>k.id===m);if(!N)return;const f=a[m]??B(N);await _.mutateAsync({sleepId:m,qualitySummary:f.qualitySummary,notes:f.notes,tagsText:f.tagsText,linkValues:f.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(xe,{children:e.jsx(Fe,{latestNight:w.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:u(w.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:`${w.summary.averageRegularityScore}`,description:`Average bedtime drift ${w.summary.averageBedtimeConsistencyMinutes}m and wake drift ${w.summary.averageWakeConsistencyMinutes}m.`}),e.jsx(F,{title:"Restorative share",value:R(w.summary.averageRestorativeShare),description:`Deep + REM share across recent nights, with ${w.summary.reflectiveNightCount} nights already carrying context.`}),e.jsxs(S,{className:"border-white/8 bg-white/[0.03]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Recent stage mix"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:"Average nightly phases"})]}),e.jsx(te,{className:"size-5 text-[var(--primary)]"})]}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:w.stageAverages.length>0?w.stageAverages.slice(0,5).map(m=>e.jsxs(p,{tone:"meta",children:[I(m.stage).label," ",u(m.averageSeconds)]},m.stage)):e.jsx("div",{className:"text-sm text-white/52",children:"Stage averages will appear once nights include phase data."})})]})]})}),e.jsx(he,{children:e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,25rem)_minmax(0,1fr)]",children:[e.jsx(ze,{days:w.calendarDays,selectedSleepId:(b==null?void 0:b.id)??null,onSelect:m=>x(m)}),b&&P?e.jsx(Le,{session:b,draft:P,rawDetail:j.data??null,rawDetailLoading:j.isLoading,pending:_.isPending&&((V=_.variables)==null?void 0:V.sleepId)===b.id,tab:d,linkOptions:Y,onTabChange:h,onDraftChange:m=>X(b.id,m),onSave:()=>void Z(b.id)}):e.jsx(S,{className:"border-white/8 bg-white/[0.03] px-6 py-8 text-sm leading-6 text-white/58",children:"Pick a night from the calendar to inspect its phase timing, stage summary, and reflection context."})]})})]})}export{Xe as SleepPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as u,j as e,aC as Ie,bE as Ne,aV as Pe,b8 as ke,bG as qe,bX as Qe}from"./vendor-kIz9EZnX.js";import{j as Ze,i as O,k as Ue}from"./state-VYvD1QVP.js";import{u as Ge,eH as Xe,S as Ye,E as Je,eI as et,C as g,eJ as Y,c as o,I as $,eK as tt,aT as at,T as st,m as it,B as ie,bM as rt,bw as nt,bx as lt,by as ct,bz as dt,bC as ot}from"./index-BHIKoiZ6.js";import{F as ve}from"./faceted-token-search-D7xPWfOl.js";import{P as xt}from"./page-hero-oFHaAjtL.js";import{f as ht}from"./date-keys-Cj1G3TOn.js";import{p as mt,b as pt}from"./health-link-options-Cpx8w7uM.js";import{R as P,A as ut,C as J,X as q,Y as B,T as Q,a as ye,e as we,B as re,f as gt,d as jt,g as ft,c as ne,S as vt,h as yt}from"./charts-FcU0F3XV.js";import"./motion-CfdU2F35.js";import"./ui-CsEkP2V8.js";import"./forms-CmLAyGqz.js";import"./board-DqHzdCPQ.js";import"./graph-BTa79qum.js";const U={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,i=>i.toUpperCase()):"Unknown"}function W(t){return`${Math.round(t/60)}m`}function ce(t){return t?`${(t/1e3).toFixed(1)} km`:"n/a"}function G(t,i){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(i))}`}function te(t){return ht(new Date(t))}function Z(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(i=>`${i.entityType}:${i.entityId}`):[]}}function Se(t){return t.trim().toLowerCase()}function j(t){var i;return((i=t.workoutTypeLabel)==null?void 0:i.trim())||z(t.workoutType)}function H(t){var i;return((i=t.activityFamilyLabel)==null?void 0:i.trim())||z(t.activityFamily)}function Ae(t){return z(t.sourceSystem??t.source)}function wt(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 bt(t){const i=wt(t.value);return!t.unit||t.unit==="count"?i:`${i} ${t.unit}`}function Nt(t,i){return Se([t.workoutType,j(t),t.activityFamily,H(t),t.sourceSystem,Ae(t),t.sourceType,t.sourceDevice,t.reconciliationStatus,t.moodBefore,t.moodAfter,t.meaningText,t.plannedContext,t.socialContext,t.tags.join(" "),i.moodBefore,i.moodAfter,i.meaningText,i.plannedContext,i.socialContext,i.tagsText,G(t.startedAt,t.endedAt)].join(" "))}function kt(t){const i=new Map;for(const s of t)i.set(`workout:${s.workoutType}`,{id:`workout:${s.workoutType}`,label:j(s),description:"Workout type",searchText:`${j(s)} workout`,badge:e.jsx(o,{tone:"meta",children:j(s)})}),i.set(`source:${s.sourceType}`,{id:`source:${s.sourceType}`,label:s.sourceType.replaceAll("_"," "),description:"Source type",searchText:`${s.sourceType} source`,badge:e.jsx(o,{tone:"meta",className:"capitalize",children:s.sourceType.replaceAll("_"," ")})}),i.set(`status:${s.reconciliationStatus}`,{id:`status:${s.reconciliationStatus}`,label:s.reconciliationStatus.replaceAll("_"," "),description:"Reconciliation status",searchText:`${s.reconciliationStatus} status`,badge:e.jsx(o,{tone:"meta",className:"capitalize",children:s.reconciliationStatus.replaceAll("_"," ")})});return i.set("linked:yes",{id:"linked:yes",label:"Linked",description:"Already tied to Forge or Psyche context",badge:e.jsx(o,{tone:"meta",children:"Linked"})}),i.set("linked:no",{id:"linked:no",label:"Needs links",description:"No Forge or Psyche links yet",badge:e.jsx(o,{tone:"meta",children:"Needs links"})}),i.set("habit:yes",{id:"habit:yes",label:"Habit-generated",description:"Created from a habit completion",badge:e.jsx(o,{tone:"meta",children:"Habit-generated"})}),i.set("effort:rated",{id:"effort:rated",label:"Effort rated",description:"Already has a subjective effort score",badge:e.jsx(o,{tone:"meta",children:"Effort rated"})}),Array.from(i.values())}function St(t,i){return i.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 ee(t,i,s){if(!t||t.length===0)return null;const l=[...t].filter(c=>c.dateKey<=i&&c[s]!=null).sort((c,f)=>f.dateKey.localeCompare(c.dateKey))[0];return(l==null?void 0:l[s])??null}function At(t){return[t.workoutType,t.workoutTypeLabel,t.activityFamily,t.activityFamilyLabel].filter(Boolean).join(" ").toLowerCase().includes("kickboxing")}function Tt(t){const i=new Map;for(const s of t){const l=`type:${s.workoutType}`;i.set(l,{id:l,label:j(s),description:H(s),searchText:`${j(s)} ${H(s)} ${s.workoutType}`,badge:e.jsx(o,{tone:"meta",children:j(s)})})}return[...i.values()].sort((s,l)=>s.label.localeCompare(l.label))}function Ct(t,i,s,l,c){const f=i.filter(x=>x.startsWith("type:")).map(x=>x.slice(5)),v=new Set(f),C=te(new Date().toISOString()),w=new Date(`${C}T12:00:00.000Z`);w.setUTCDate(w.getUTCDate()-90);const n=w.toISOString().slice(0,10);return t.filter(x=>{if(v.size>0&&!v.has(x.workoutType))return!1;const h=te(x.startedAt);return s==="recent_90"?h>=n:!(s==="custom"&&(l&&h<l||c&&h>c))}).sort((x,h)=>Date.parse(x.startedAt)-Date.parse(h.startedAt))}function le(t){var s;const i=Object.fromEntries(V.map(l=>[l,0]));for(const l of t)for(const c of((s=l.analytics)==null?void 0:s.zoneDurations)??[])V.includes(c.key)&&(i[c.key]+=c.seconds);return i}function be(t){const i=Object.values(t).reduce((s,l)=>s+l,0);return Object.fromEntries(V.map(s=>[s,i>0?Number((t[s]/i*100).toFixed(1)):0]))}function Mt(t,i,s){const l=typeof(s==null?void 0:s.dataKey)=="string"?s.dataKey:typeof i=="string"?i:"",c=typeof t=="number"?Number(t.toFixed(1)):String(t??"n/a");return l==="restingHeartRate"||i==="Resting HR"?[`${c} bpm`,"Resting HR"]:l==="vo2Max"||i==="VO2max"?[`${c} ml/kg/min`,"VO2max"]:[`${c}%`,z(l)]}function Rt(t,i){const s=t.map((n,x)=>{var y,M,D;const h=te(n.startedAt),N=t.slice(Math.max(0,x-2),x+1),b=le(N),T=be(b);return{id:n.id,dateKey:h,date:h.slice(5),session:j(n),durationMinutes:Math.round(n.durationSeconds/60),confidence:((y=n.analytics)==null?void 0:y.confidence)??"unavailable",restingHeartRate:((D=(M=n.analytics)==null?void 0:M.hrSummary)==null?void 0:D.restingHr)??ee(i,h,"restingHeartRate"),vo2Max:ee(i,h,"vo2Max"),...T}}),l=t.map((n,x)=>{var T,y,M;const h=te(n.startedAt),N=le(t.slice(0,x+1)),b=be(N);return{id:n.id,dateKey:h,date:h.slice(5),session:j(n),durationMinutes:Math.round(n.durationSeconds/60),confidence:((T=n.analytics)==null?void 0:T.confidence)??"unavailable",restingHeartRate:((M=(y=n.analytics)==null?void 0:y.hrSummary)==null?void 0:M.restingHr)??ee(i,h,"restingHeartRate"),vo2Max:ee(i,h,"vo2Max"),...b}}),c=le(t),f=Object.values(c).reduce((n,x)=>n+x,0),v=V.map(n=>{var h;const x=((h=t.flatMap(N=>{var b;return((b=N.analytics)==null?void 0:b.zoneDurations)??[]}).find(N=>N.key===n))==null?void 0:h.label)??z(n);return{key:n,zone:x,percentage:f>0?Number((c[n]/f*100).toFixed(1)):0,fill:U[n]??"#f8fafc"}}),C=t.filter(n=>{var x,h;return(((h=(x=n.analytics)==null?void 0:x.dataQuality)==null?void 0:h.heartRateSampleCount)??0)>0}).length,w=[...new Set(t.map(n=>j(n)))];return{sessions:t,lineData:s,expandingLineData:l,averageZoneData:v,rawHrCount:C,exerciseLabels:w}}function Et({session:t,draft:i,linkOptions:s,pending:l,step:c,onStepChange:f,onDraftChange:v,onSave:C}){var n,x,h,N,b,T,y,M,D;const w=[{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] bg-white/[0.04] 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-white",children:[e.jsx(Ne,{className:"size-4 text-[var(--primary)]"}),e.jsx("span",{children:j(t)})]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:G(t.startedAt,t.endedAt)})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(o,{children:W(t.durationSeconds)}),t.totalEnergyKcal?e.jsxs(o,{tone:"meta",children:[Math.round(t.totalEnergyKcal)," kcal"]}):null,t.distanceMeters?e.jsx(o,{tone:"meta",children:ce(t.distanceMeters)}):null,e.jsx(o,{tone:"meta",children:H(t)}),e.jsx(o,{tone:"meta",className:"capitalize",children:t.reconciliationStatus.replaceAll("_"," ")})]})]})}),e.jsx("div",{className:"grid gap-2 sm:grid-cols-3",children:w.map((r,L)=>e.jsxs("button",{type:"button",onClick:()=>f(L),className:`rounded-[20px] border px-4 py-3 text-left transition ${c===L?"border-[var(--primary)] bg-[var(--primary)]/10 text-white":"border-white/8 bg-white/[0.04] text-white/62 hover:bg-white/[0.06] hover:text-white"}`,children:[e.jsxs("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:["Step ",L+1]}),e.jsx("div",{className:"mt-2 text-sm font-medium",children:r.title})]},r.id))}),e.jsxs("div",{className:"rounded-[24px] bg-white/[0.03] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:w[c].title}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:w[c].description}),c===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] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Activity family"}),e.jsx("div",{className:"mt-2 text-lg text-white capitalize",children:H(t)})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Source system"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:Ae(t)})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Source device"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:t.sourceDevice||"n/a"})]})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Steps"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:t.stepCount??"n/a"})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Avg HR"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:t.averageHeartRate?Math.round(t.averageHeartRate):"n/a"})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Max HR"}),e.jsx("div",{className:"mt-2 text-lg text-white",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-white/58",children:"Effort"}),e.jsx($,{type:"number",min:1,max:10,value:i.subjectiveEffort,onChange:r=>v({subjectiveEffort:r.target.value})})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Planned vs spontaneous"}),e.jsx($,{value:i.plannedContext,onChange:r=>v({plannedContext:r.target.value}),placeholder:"Planned recovery block"})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Social context"}),e.jsx($,{value:i.socialContext,onChange:r=>v({socialContext:r.target.value}),placeholder:"Solo, coach, group class, partner"})]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Tags"}),e.jsx($,{value:i.tagsText,onChange:r=>v({tagsText:r.target.value}),placeholder:"recovery, interval-block, stress-release"})]})]}):null,c===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-white/58",children:"Mood before"}),e.jsx($,{value:i.moodBefore,onChange:r=>v({moodBefore:r.target.value})})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Mood after"}),e.jsx($,{value:i.moodAfter,onChange:r=>v({moodAfter:r.target.value})})]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Meaning, impact, and why this session mattered"}),e.jsx(st,{className:"min-h-[160px]",value:i.meaningText,onChange:r=>v({meaningText:r.target.value}),placeholder:"This session was planned as active recovery after a heavy work block and helped reset stress before sleep."})]})]}):null,c===2?e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Search goals, projects, habits, values, beliefs, patterns, or reports and attach the ones that explain this session."}),e.jsx(it,{options:s,selectedValues:i.linkValues,onChange:r=>v({linkValues:r}),placeholder:"Search Forge and Psyche records…"})]}):null,e.jsxs("div",{className:"mt-5 grid gap-4 border-t border-white/8 pt-5",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Captured data"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",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(r=>e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:r.label}),e.jsx("div",{className:"mt-2 text-lg text-white",children:bt(r)}),e.jsxs("div",{className:"mt-1 text-xs uppercase tracking-[0.14em] text-white/38",children:[z(r.category)," · ",z(r.statistic)]})]},`${r.category}:${r.key}:${r.statistic}`)),(((h=(x=t.details)==null?void 0:x.metrics)==null?void 0:h.length)??0)===0?e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] p-4 text-sm text-white/50",children:"No provider metrics were captured for this session yet."}):null]}),(((b=(N=t.details)==null?void 0:N.events)==null?void 0:b.length)??0)>0?e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Workout events"}),e.jsx("div",{className:"grid gap-2",children:(T=t.details)==null?void 0:T.events.map(r=>e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("div",{className:"text-white",children:r.label}),e.jsx(o,{tone:"meta",children:W(r.durationSeconds)})]}),e.jsx("div",{className:"mt-1 text-sm text-white/56",children:G(r.startedAt,r.endedAt??r.startedAt)})]},`${r.type}:${r.startedAt}`))})]}):null,(((M=(y=t.details)==null?void 0:y.components)==null?void 0:M.length)??0)>0?e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Workout phases"}),e.jsx("div",{className:"grid gap-2",children:(D=t.details)==null?void 0:D.components.map(r=>e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("div",{className:"text-white",children:r.activity.canonicalLabel}),e.jsx(o,{tone:"meta",children:W(r.durationSeconds)})]}),e.jsx("div",{className:"mt-1 text-sm text-white/56",children:G(r.startedAt,r.endedAt??r.startedAt)})]},r.externalUid))})]}):null]})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"text-sm text-white/48",children:c<w.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:()=>f(Math.max(0,c-1)),disabled:c===0,children:"Back"}),c<w.length-1?e.jsxs(ie,{type:"button",onClick:()=>f(c+1),children:["Next",e.jsx(ke,{className:"size-4"})]}):null,e.jsxs(ie,{type:"button",pending:l,pendingLabel:"Saving",onClick:C,children:[e.jsx(Qe,{className:"size-4"}),"Save session"]})]})]})]})}function Pt(){var je,fe;const t=Ge(),i=Ze(),s=Array.isArray(t.selectedUserIds)?t.selectedUserIds:[],[l,c]=u.useState({}),[f,v]=u.useState(""),[C,w]=u.useState([]),[n,x]=u.useState([]),[h,N]=u.useState(""),[b,T]=u.useState("all"),[y,M]=u.useState("rolling_stack"),[D,r]=u.useState(""),[L,Te]=u.useState(""),[de,Ce]=u.useState(!1),[oe,ae]=u.useState(null),[Me,X]=u.useState(0),k=O({queryKey:["forge-fitness",...s],queryFn:async()=>(await rt(s)).fitness}),Re=O({queryKey:["forge-health-values",...s],queryFn:async()=>(await nt(s)).values}),Ee=O({queryKey:["forge-health-patterns",...s],queryFn:async()=>(await lt(s)).patterns}),ze=O({queryKey:["forge-health-behaviors",...s],queryFn:async()=>(await ct(s)).behaviors}),De=O({queryKey:["forge-health-beliefs",...s],queryFn:async()=>(await dt(s)).beliefs}),Fe=O({queryKey:["forge-health-reports",...s],queryFn:async()=>(await ot(s)).reports});u.useEffect(()=>{k.data&&c(Object.fromEntries(k.data.sessions.map(a=>[a.id,Z(a)])))},[k.data]),u.useEffect(()=>{if(de||!k.data)return;const d=(k.data.analysisSessions??k.data.sessions).find(At);d&&x([`type:${d.workoutType}`]),Ce(!0)},[de,k.data]);const se=Ue({mutationFn:async a=>Xe(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:mt(a.linkValues)}),onSuccess:async()=>{await i.invalidateQueries({queryKey:["forge-fitness"]})}}),F=k.data,S=(F==null?void 0:F.sessions)??[],K=(F==null?void 0:F.analysisSessions)??S,$e=pt({goals:t.snapshot.dashboard.goals,projects:t.snapshot.dashboard.projects,tasks:t.snapshot.dashboard.tasks,habits:t.snapshot.dashboard.habits,values:Re.data??[],patterns:Ee.data??[],behaviors:ze.data??[],beliefs:De.data??[],reports:Fe.data??[]}),Le=u.useMemo(()=>kt(S),[S]),_e=u.useMemo(()=>Tt(K),[K]),I=u.useMemo(()=>{const a=Se(f);return[...S].sort((d,m)=>new Date(m.startedAt).getTime()-new Date(d.startedAt).getTime()).filter(d=>{const m=l[d.id]??Z(d);return(a.length===0||Nt(d,m).includes(a))&&St(d,C)})},[l,f,C,S]),xe=u.useMemo(()=>Ct(K,n,b,D,L),[b,L,K,D,n]),he=I.length===S.length&&f.trim().length===0&&C.length===0?`${S.length} workout sessions visible`:`${I.length} of ${S.length} workout sessions visible`,R=I.find(a=>a.id===oe)??S.find(a=>a.id===oe)??null,me=R?l[R.id]??Z(R):null;if(k.isLoading)return e.jsx(Ye,{eyebrow:"Sports",title:"Loading sports view",description:"Reading synced workouts and local reflection metadata.",columns:2,blocks:6});if(k.isError||!F)return e.jsx(Je,{eyebrow:"Sports",error:k.error??new Error("Sports data unavailable"),onRetry:()=>void k.refetch()});const{summary:p,weeklyTrend:pe,typeBreakdown:He}=F,ue=p.zoneMix??[],A=Rt(xe,F.vitalsTrend),ge=n.length===0?"All exercise types":A.exerciseLabels.length>0?A.exerciseLabels.join(", "):`${n.length} selected types`,Ke=ue.map(a=>({zone:a.label,minutes:Math.round(a.seconds/60),percentage:Math.round(a.percentage*100),fill:U[a.key]??"#f8fafc"})),Oe=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:j(a),name:j(a)}});function We(a,d){c(m=>{const E=m[a]??Z(S.find(_=>_.id===a));return{...m,[a]:{...E,...d}}})}async function Ve(a){const d=S.find(E=>E.id===a);if(!d)return;const m=l[a]??Z(d);await se.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}),ae(null),X(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:`${S.length} sessions`}),e.jsx(et,{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-white/45",children:"Weekly volume"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--primary)]",children:W(p.weeklyVolumeSeconds)}),e.jsx("div",{className:"mt-2 text-sm text-white/58",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-white/45",children:"Exercise minutes"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:p.exerciseMinutes}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:"Aggregate exercise minutes from synced sessions."})]}),e.jsxs(g,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Energy burned"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:p.energyBurnedKcal}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:"Recent weekly kcal."})]}),e.jsxs(g,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Training streak"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:p.streakDays}),e.jsx("div",{className:"mt-2 text-sm text-white/58",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-white/45",children:"Average session"}),e.jsxs("div",{className:"mt-3 font-display text-4xl text-white",children:[p.averageSessionMinutes,"m"]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:"Mean duration across recent sessions."})]}),e.jsxs(g,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Training load"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:p.totalTrainingLoad??"n/a"}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:"Forge TRIMP across recent sessions."})]}),e.jsxs(g,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Linked sessions"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:p.linkedSessionCount}),e.jsx("div",{className:"mt-2 text-sm text-white/58",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-white/45",children:"HR coverage"}),e.jsxs("div",{className:"mt-3 font-display text-4xl text-white",children:[Math.round((p.averageHeartRateCoverage??0)*100),"%"]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:"Average raw HR sample coverage."})]})]})}),e.jsx(Y,{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-white/45",children:"Load and volume trend"}),e.jsx("div",{className:"mt-4 h-[260px]",children:e.jsx(P,{width:"100%",height:"100%",children:e.jsxs(ut,{data:Oe,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(J,{stroke:"rgba(255,255,255,0.08)",vertical:!1}),e.jsx(q,{dataKey:"date",tick:{fill:"rgba(255,255,255,0.55)",fontSize:11}}),e.jsx(B,{tick:{fill:"rgba(255,255,255,0.55)",fontSize:11},width:34}),e.jsx(Q,{contentStyle:{background:"rgba(8,12,22,0.94)",border:"1px solid rgba(255,255,255,0.12)",borderRadius:8,color:"white"}}),e.jsx(ye,{type:"monotone",dataKey:"load",stroke:"#f97316",fill:"url(#sportsLoad)",strokeWidth:2}),e.jsx(ye,{type:"monotone",dataKey:"duration",stroke:"#38bdf8",fill:"rgba(56,189,248,0.10)",strokeWidth:2})]})})})]}),e.jsxs(g,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Zone distribution"}),e.jsx("div",{className:"mt-4 grid gap-3",children:ue.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-white/72",children:a.label}),e.jsxs("span",{className:"text-white",children:[Math.round(a.percentage*100),"% · ",W(a.seconds)]})]}),e.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-white/[0.08]",children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${Math.max(1,a.percentage*100)}%`,background:U[a.key]??"#f8fafc"}})})]},a.key))}),e.jsx("div",{className:"mt-5 h-[180px]",children:e.jsx(P,{width:"100%",height:"100%",children:e.jsxs(we,{data:Ke,children:[e.jsx(q,{dataKey:"zone",tick:{fill:"rgba(255,255,255,0.55)",fontSize:10}}),e.jsx(B,{tick:{fill:"rgba(255,255,255,0.55)",fontSize:10},width:34}),e.jsx(Q,{contentStyle:{background:"rgba(8,12,22,0.94)",border:"1px solid rgba(255,255,255,0.12)",borderRadius:8,color:"white"}}),e.jsx(re,{dataKey:"minutes",fill:"#f97316",radius:[4,4,0,0]})]})})})]})]})}),e.jsx(Y,{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-white/45",children:"HR zone analysis"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:"Filter all-time workout evidence by exercise type and date."})]}),e.jsxs(o,{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(ve,{title:"Exercise types",description:"Select one, many, or none for all exercise types.",query:h,onQueryChange:N,options:_e,selectedOptionIds:n,onSelectedOptionIdsChange:x,resultSummary:ge,placeholder:"Search exercise types",emptyStateMessage:"No exercise type matches."}),e.jsxs("div",{className:"grid gap-3 rounded-[8px] border border-white/8 bg-white/[0.035] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",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 ${b===a?"border-[var(--primary)] bg-[var(--primary)]/12 text-white":"border-white/8 bg-white/[0.04] text-white/62 hover:bg-white/[0.07] hover:text-white"}`,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-white/58",children:"Start"}),e.jsx($,{type:"date",value:D,onChange:a=>{r(a.target.value),T("custom")}})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"End"}),e.jsx($,{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-white/45",children:"Average zones"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:"Duration-weighted proportion of time in each HR zone."})]}),e.jsx(o,{tone:"meta",children:ge})]}),e.jsx("div",{className:"mt-4 h-[235px]",children:A.sessions.length>0?e.jsx(P,{width:"100%",height:"100%",children:e.jsxs(we,{data:A.averageZoneData,children:[e.jsx(J,{stroke:"rgba(255,255,255,0.08)",vertical:!1}),e.jsx(q,{dataKey:"zone",interval:0,tick:{fill:"rgba(255,255,255,0.55)",fontSize:10}}),e.jsx(B,{unit:"%",domain:[0,100],ticks:[0,25,50,75,100],tick:{fill:"rgba(255,255,255,0.55)",fontSize:10},width:38}),e.jsx(Q,{formatter:a=>[`${a}%`,"Average time"],contentStyle:{background:"rgba(8,12,22,0.94)",border:"1px solid rgba(255,255,255,0.12)",borderRadius:8,color:"white"}}),e.jsx(re,{dataKey:"percentage",radius:[4,4,0,0],children:A.averageZoneData.map(a=>e.jsx(gt,{fill:a.fill},a.key))})]})}):e.jsx("div",{className:"grid h-full place-items-center rounded-[8px] bg-white/[0.035] p-6 text-center text-sm leading-6 text-white/54",children:"No selected sessions with zone analytics are available yet."})}),A.sessions.length>0?e.jsxs("div",{className:"mt-3 grid gap-2 text-sm text-white/58 sm:grid-cols-3",children:[e.jsxs("div",{children:[A.rawHrCount," sessions have raw HR timelines"]}),e.jsxs("div",{children:["Latest:"," ",((je=A.lineData.at(-1))==null?void 0:je.dateKey)??"n/a"]}),e.jsxs("div",{children:["VO2max points:"," ",A.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-white/45",children:y==="expanding_lines"?"Expanding zone lines":"Zone drift"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:y==="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-white/8 bg-white/[0.035] 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 ${y===a?"bg-[var(--primary)]/18 text-white":"text-white/58 hover:bg-white/[0.06] hover:text-white"}`,onClick:()=>M(a),children:d},a))}),e.jsx(o,{tone:"meta",children:"HRR zones"})]})]}),e.jsx("div",{className:"mt-4 h-[255px]",children:A.lineData.length>0?e.jsx(P,{width:"100%",height:"100%",children:e.jsxs(jt,{data:y==="expanding_lines"?A.expandingLineData:A.lineData,children:[e.jsx(J,{stroke:"rgba(255,255,255,0.08)",vertical:!1}),e.jsx(q,{dataKey:"date",tick:{fill:"rgba(255,255,255,0.55)",fontSize:10}}),e.jsx(B,{yAxisId:"zones",domain:[0,100],ticks:[0,25,50,75,100],unit:"%",tick:{fill:"rgba(255,255,255,0.55)",fontSize:10},width:38}),e.jsx(B,{yAxisId:"vitals",orientation:"right",tick:{fill:"rgba(255,255,255,0.55)",fontSize:10},width:42}),e.jsx(Q,{formatter:(a,d,m)=>Mt(a,d,m),contentStyle:{background:"rgba(8,12,22,0.94)",border:"1px solid rgba(255,255,255,0.12)",borderRadius:8,color:"white"}}),e.jsx(ft,{wrapperStyle:{color:"rgba(255,255,255,0.7)",fontSize:11}}),y==="expanding_lines"?V.map(a=>e.jsx(ne,{yAxisId:"zones",type:"monotone",dataKey:a,name:z(a),stroke:U[a],strokeWidth:2,dot:{r:2.5},activeDot:{r:4},connectNulls:!0},a)):V.map(a=>e.jsx(re,{yAxisId:"zones",dataKey:a,stackId:"zones",fill:U[a],isAnimationActive:!1},a)),e.jsx(ne,{yAxisId:"vitals",type:"monotone",dataKey:"restingHeartRate",name:"Resting HR",stroke:"#e2e8f0",strokeWidth:2,dot:{r:3},connectNulls:!0}),e.jsx(ne,{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] bg-white/[0.035] p-6 text-center text-sm leading-6 text-white/54",children:"Select workouts with HR evidence to unlock the time-series plot."})})]})]})]})}),e.jsx(Y,{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-white/45",children:"Duration vs intensity"}),e.jsx("div",{className:"mt-4 h-[250px]",children:e.jsx(P,{width:"100%",height:"100%",children:e.jsxs(vt,{data:Be,children:[e.jsx(J,{stroke:"rgba(255,255,255,0.08)"}),e.jsx(q,{type:"number",dataKey:"duration",name:"minutes",tick:{fill:"rgba(255,255,255,0.55)",fontSize:11}}),e.jsx(B,{type:"number",dataKey:"intensity",name:"intensity",tick:{fill:"rgba(255,255,255,0.55)",fontSize:11},width:38}),e.jsx(Q,{cursor:{strokeDasharray:"3 3"},contentStyle:{background:"rgba(8,12,22,0.94)",border:"1px solid rgba(255,255,255,0.12)",borderRadius:8,color:"white"}}),e.jsx(yt,{dataKey:"load",fill:"#f97316"})]})})})]}),e.jsxs(g,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Evidence quality"}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsxs("div",{className:"rounded-[8px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Raw HR coverage"}),e.jsxs("div",{className:"mt-2 text-2xl text-white",children:[Math.round((p.averageHeartRateCoverage??0)*100),"%"]})]}),e.jsxs("div",{className:"rounded-[8px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Route-backed workouts"}),e.jsx("div",{className:"mt-2 text-2xl text-white",children:p.routeWorkoutCount??0})]}),e.jsxs("div",{className:"rounded-[8px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Top sport"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:p.topWorkoutTypeLabel??p.topWorkoutType??"n/a"})]})]})]})]})}),e.jsx(Y,{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-white/45",children:"Recent volume"}),e.jsx("div",{className:"grid gap-3",children:pe.map(a=>e.jsxs("div",{className:"grid gap-2 rounded-[18px] bg-white/[0.04] px-4 py-3 md:grid-cols-[110px_150px_minmax(0,1fr)_90px]",children:[e.jsx("div",{className:"text-sm text-white/62",children:a.dateKey}),e.jsx("div",{className:"text-sm text-white",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-white/[0.08]",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-white",children:[a.durationMinutes,"m"]})]}),e.jsxs("div",{className:"text-sm text-white/62",children:[a.energyKcal," kcal"]})]},a.id))}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Distance"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:ce(p.distanceMeters)})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Planned sessions"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:p.plannedSessionCount})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Imported / merged"}),e.jsxs("div",{className:"mt-2 text-lg text-white",children:[p.importedSessionCount," / ",p.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-white/45",children:"Training composition"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:"Workout type and provenance mix"})]}),e.jsx("div",{className:"grid gap-3",children:He.slice(0,6).map(a=>e.jsxs("div",{className:"grid gap-2 rounded-[18px] bg-white/[0.04] px-4 py-3 md:grid-cols-[minmax(0,1fr)_90px_90px]",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-white",children:a.workoutTypeLabel??z(a.workoutType)}),e.jsxs("div",{className:"mt-1 text-sm text-white/58",children:[a.sessionCount," sessions · ",a.activityFamilyLabel??"Other"]})]}),e.jsxs("div",{className:"text-sm text-white/72",children:[a.totalMinutes,"m"]}),e.jsxs("div",{className:"text-sm text-white/72",children:[a.energyKcal," kcal"]})]},a.workoutType))}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Habit-generated"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:p.habitGeneratedSessionCount})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Forge-linked"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:p.linkedSessionCount})]})]})]})]})}),e.jsx(tt,{children:e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,25rem)_minmax(0,1fr)]",children:[e.jsx(ve,{title:"Session browser",description:"Search past activities by workout type, source, reconciliation state, or whether they still need context.",query:f,onQueryChange:v,options:Le,selectedOptionIds:C,onSelectedOptionIdsChange:w,resultSummary:he,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-white/45",children:"Activity history"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:"Open a workout to add reflection and links in a guided modal."})]}),e.jsx(o,{tone:"meta",children:he})]}),e.jsx("div",{className:"max-h-[34rem] overflow-y-auto rounded-[8px] border border-white/8 bg-white/[0.03] 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-white/50",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-white/8 bg-white/[0.04] px-4 py-3 text-left transition hover:bg-white/[0.07]",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(Ie,{to:`/sports/workouts/${a.id}`,className:"flex min-w-0 items-center gap-2 text-white transition hover:text-[var(--primary)]",children:[e.jsx(Ne,{className:"size-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate text-base font-medium",children:j(a)})]}),e.jsxs("div",{className:"mt-2 flex min-w-0 items-center gap-2 text-sm text-white/56",children:[e.jsx(Pe,{className:"size-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate",children:G(a.startedAt,a.endedAt)})]}),e.jsxs("div",{className:"mt-2 text-sm text-white/46",children:[H(a)," · ",a.sourceDevice]})]}),e.jsxs("button",{type:"button","aria-label":`Edit ${j(a)} reflection`,className:"inline-flex w-fit max-w-full items-center gap-2 rounded-full bg-white/[0.05] px-3 py-1.5 text-xs text-white/70 transition hover:bg-white/[0.08] hover:text-white",onClick:()=>{ae(a.id),X(0)},children:[e.jsx("span",{className:"truncate",children:d?"Reflected":"Needs reflection"}),e.jsx(ke,{className:"size-3.5 shrink-0"})]})]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap gap-2",children:[e.jsx(o,{children:W(a.durationSeconds)}),a.totalEnergyKcal?e.jsxs(o,{tone:"meta",children:[Math.round(a.totalEnergyKcal)," kcal"]}):null,a.distanceMeters?e.jsx(o,{tone:"meta",children:ce(a.distanceMeters)}):null,a.averageHeartRate?e.jsxs(o,{tone:"meta",children:[e.jsx(qe,{className:"mr-1 size-3.5"}),Math.round(a.averageHeartRate)," bpm"]}):null,e.jsx(o,{tone:"meta",children:H(a)}),e.jsx(o,{tone:"meta",className:"capitalize",children:a.sourceType.replaceAll("_"," ")}),e.jsx(o,{tone:"meta",className:"capitalize",children:a.reconciliationStatus.replaceAll("_"," ")}),(m=a.analytics)!=null&&m.confidence?e.jsxs(o,{tone:"meta",children:[a.analytics.confidence," zones"]}):null,(_=(E=a.analytics)==null?void 0:E.routeSummary)!=null&&_.hasRoute?e.jsx(o,{tone:"meta",children:"Route"}):null]})]},a.id)})})})]})]})}),R&&me?e.jsx(at,{open:!!R,onOpenChange:a=>{a||(ae(null),X(0))},eyebrow:"Sports session",title:j(R),description:"Add contextual meaning without crowding the main training surface.",children:e.jsx(Et,{session:R,draft:me,linkOptions:$e,pending:se.isPending&&((fe=se.variables)==null?void 0:fe.workoutId)===R.id,step:Me,onStepChange:X,onDraftChange:a=>We(R.id,a),onSave:()=>void Ve(R.id)})}):null]})}export{Pt as SportsPage,Mt as formatZoneTrendTooltipValue};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b5 as U,c2 as z,r,j as e,b4 as A,b3 as $,ce as O,c7 as Q}from"./vendor-kIz9EZnX.js";import{j as F,k as I}from"./state-VYvD1QVP.js";import{b as G,S as R}from"./strategy-dialog-DMyRKrWf.js";import{P as _}from"./page-hero-oFHaAjtL.js";import{u as H,s as K,bZ as Z,b_ as J,b$ as V,B as d,C as M,I as W,a as X,U as Y,c as x}from"./index-BHIKoiZ6.js";import"./board-DqHzdCPQ.js";import"./motion-CfdU2F35.js";import"./ui-CsEkP2V8.js";import"./forms-CmLAyGqz.js";import"./graph-BTa79qum.js";function ee(a){return a.trim().toLowerCase()}function xe(){const a=H(),u=U(),B=F(),[j,w]=z(),[E,c]=r.useState(!1),[T,o]=r.useState(null),[m,D]=r.useState(""),L=K(a.selectedUserIds);r.useEffect(()=>{j.get("create")==="1"&&(o(null),c(!0),w(s=>{const t=new URLSearchParams(s);return t.delete("create"),t},{replace:!0}))},[j,w]);const v=async()=>{await B.invalidateQueries({queryKey:["strategy-detail"]}),await a.refresh()},N=I({mutationFn:async({input:s,strategyId:t})=>t?(await Z(t,s)).strategy:(await J(s)).strategy,onSuccess:async()=>{await v()}}),p=I({mutationFn:async s=>V(s),onSuccess:async()=>{await v()}}),b=r.useMemo(()=>new Map(a.snapshot.goals.map(s=>[s.id,s])),[a.snapshot.goals]),h=r.useMemo(()=>new Map(a.snapshot.dashboard.projects.map(s=>[s.id,s])),[a.snapshot.dashboard.projects]),f=r.useMemo(()=>new Map(a.snapshot.tasks.map(s=>[s.id,s])),[a.snapshot.tasks]),S=r.useMemo(()=>{const s=ee(m);return s?a.snapshot.strategies.filter(t=>{var k,y,C;const g=t.targetGoalIds.map(l=>{var n;return((n=b.get(l))==null?void 0:n.title)??""}).join(" "),i=t.targetProjectIds.map(l=>{var n;return((n=h.get(l))==null?void 0:n.title)??""}).join(" "),q=t.graph.nodes.map(l=>{var n,P;return l.entityType==="project"?((n=h.get(l.entityId))==null?void 0:n.title)??"":((P=f.get(l.entityId))==null?void 0:P.title)??""}).join(" ");return[t.title,t.overview,t.endStateDescription,t.status,((k=t.user)==null?void 0:k.displayName)??"",((y=t.user)==null?void 0:y.handle)??"",((C=t.user)==null?void 0:C.kind)??"",g,i,q].join(" ").toLowerCase().includes(s)}):a.snapshot.strategies},[b,h,m,a.snapshot.strategies,f]);return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(_,{title:"Strategies",titleText:"Strategies",description:"Strategies connect human and bot work into a directed plan, with explicit end goals, ownership, and live alignment metrics.",badge:`${a.snapshot.strategies.length} strategies`,actions:e.jsxs(d,{onClick:()=>{o(null),c(!0)},children:[e.jsx(A,{className:"size-4"}),"New strategy"]})}),e.jsxs(M,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($,{className:"size-4 text-white/38"}),e.jsx(W,{value:m,onChange:s=>D(s.target.value),placeholder:"Search strategy title, target, graph node, human, or bot"})]}),e.jsx("div",{className:"text-sm text-white/56",children:"Search includes owners, target goals/projects, and graph nodes so cross-user plans stay discoverable."})]}),S.length===0?e.jsx(X,{eyebrow:"Strategies",title:"No strategies in this scope",description:"Create a strategy to connect projects and tasks into a non-looping execution plan across human and bot actors.",action:e.jsx(d,{onClick:()=>{o(null),c(!0)},children:"Create strategy"})}):e.jsx("div",{className:"grid gap-4",children:S.map(s=>{const t=s.graph.nodes.filter(i=>s.metrics.activeNodeIds.includes(i.id)),g=G(s.metrics);return e.jsxs(M,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsx("div",{className:"min-w-0",children:e.jsxs("button",{type:"button",className:"text-left",onClick:()=>u(`/strategies/${s.id}`),children:[e.jsx("div",{className:"font-display text-2xl text-white",children:s.title}),e.jsx("div",{className:"mt-2 max-w-3xl text-sm leading-6 text-white/58",children:s.overview||s.endStateDescription})]})}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(Y,{user:s.user}),e.jsx(x,{className:s.isLocked?"bg-amber-500/12 text-amber-200":"bg-emerald-500/12 text-emerald-200",children:s.isLocked?"Contract locked":"Editable draft"}),e.jsx(x,{className:"bg-white/[0.08] text-white/78",children:s.status}),e.jsxs(x,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:[s.metrics.alignmentScore,"% aligned"]})]})]}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-4",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Graph progress"}),e.jsxs("div",{className:"mt-2 text-xl text-white",children:[s.metrics.startedNodeCount,"/",s.metrics.totalNodeCount]}),e.jsxs("div",{className:"text-xs leading-5 text-white/46",children:[s.metrics.completedNodeCount," completed"]})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Ready branches"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:s.metrics.readyNodeCount}),e.jsx("div",{className:"text-xs leading-5 text-white/46",children:"Nodes whose prerequisites are already satisfied."})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"End targets"}),e.jsxs("div",{className:"mt-2 text-xl text-white",children:[s.metrics.completedTargetCount,"/",s.metrics.totalTargetCount||0]}),e.jsxs("div",{className:"text-xs leading-5 text-white/46",children:[s.metrics.targetProgressScore,"% target progress"]})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Sequencing"}),e.jsxs("div",{className:"mt-2 text-xl text-white",children:[s.metrics.sequencingScore,"%"]})]})]}),e.jsxs("div",{className:"grid gap-3 xl:grid-cols-[minmax(0,1.2fr)_minmax(16rem,0.8fr)]",children:[e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-4",children:e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Active next nodes"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:t.length===0?e.jsx("div",{className:"text-sm text-white/52",children:"No currently open branch."}):t.map(i=>e.jsx(x,{className:"bg-white/[0.08] text-white/80",children:i.title},i.id))})]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Alignment breakdown"}),e.jsx("div",{className:"mt-3 grid gap-2 text-sm text-white/58",children:g.map(i=>e.jsxs("div",{children:[i.label," ",i.value,"%"]},i.id))})]})]})}),e.jsxs("div",{className:"flex flex-wrap items-end justify-end gap-2",children:[s.isLocked?null:e.jsxs(d,{variant:"secondary",onClick:()=>{o(s),c(!0)},children:[e.jsx(O,{className:"size-4"}),"Edit"]}),e.jsxs(d,{variant:"secondary",pending:p.isPending&&p.variables===s.id,pendingLabel:"Deleting strategy",onClick:()=>{window.confirm(`Delete strategy "${s.title}"?`)&&p.mutateAsync(s.id)},children:[e.jsx(Q,{className:"size-4"}),"Delete"]}),e.jsx(d,{onClick:()=>u(`/strategies/${s.id}`),children:"Open strategy"})]})]})]},s.id)})}),e.jsx(R,{open:E,pending:N.isPending,editingStrategy:T,goals:a.snapshot.dashboard.goals,projects:a.snapshot.dashboard.projects,tasks:a.snapshot.tasks,habits:a.snapshot.habits,strategies:a.snapshot.strategies,users:a.snapshot.users,defaultUserId:L,onOpenChange:c,onSubmit:async(s,t)=>{await N.mutateAsync({input:s,strategyId:t})}})]})}export{xe as StrategiesPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as h,j as e,cA as W,cx as K,cE as V,cC as Z,aC as A,cc as J,b5 as X}from"./vendor-kIz9EZnX.js";import{j as Y,i as ee,k as D}from"./state-VYvD1QVP.js";import{O as te}from"./open-in-graph-button-C0TGev7c.js";import{P as se}from"./preference-entity-handoff-button-DOKV9bZc.js";import{a as ae,i as ie,b as re,S as ne}from"./strategy-dialog-DMyRKrWf.js";import{i as le,C as de,B as oe,M as ce}from"./graph-BTa79qum.js";import{c as m,U as M,u as xe,s as pe,bZ as F,b$ as me,L as ge,E as G,B as L,C as k,W as he,bq as ue,c0 as be}from"./index-BHIKoiZ6.js";import{P as fe}from"./page-hero-oFHaAjtL.js";import"./board-DqHzdCPQ.js";import"./motion-CfdU2F35.js";import"./ui-CsEkP2V8.js";import"./forms-CmLAyGqz.js";function Q(a){const r=new Map;for(const i of a.nodes)r.set(i.id,[]);for(const i of a.edges)r.set(i.to,[...r.get(i.to)??[],i.from]);const l=new Map,o=i=>{const c=l.get(i);if(c!==void 0)return c;const y=r.get(i)??[],u=y.length===0?0:Math.max(...y.map(n=>o(n)))+1;return l.set(i,u),u};for(const i of a.nodes)o(i.id);return l}function je(a){const r=Q(a),l=new Map;for(const o of a.nodes){const i=r.get(o.id)??0;l.set(i,[...l.get(i)??[],o.id])}return Array.from(l.entries()).sort((o,i)=>o[0]-i[0]).map(([o,i])=>({level:o,nodeIds:i}))}function ye(a,r){const l=Q(a.graph),o=new Map;for(const i of a.graph.nodes){const c=l.get(i.id)??0;o.set(c,[...o.get(c)??[],i.id])}return a.graph.nodes.map(i=>{const c=l.get(i.id)??0,y=(o.get(c)??[]).indexOf(i.id),u=a.metrics.activeNodeIds.includes(i.id),n=a.metrics.blockedNodeIds.includes(i.id),p=a.metrics.outOfOrderNodeIds.includes(i.id),f=!u&&!n&&!p,t=(r==null?void 0:r.get(i.id))??null;let g="border-white/10 bg-[rgba(8,14,26,0.92)]";return u?g="border-emerald-400/30 bg-emerald-500/[0.08]":n?g="border-rose-400/28 bg-rose-500/[0.08]":p?g="border-amber-400/28 bg-amber-500/[0.08]":a.metrics.completedNodeCount>0&&(g="border-sky-400/20 bg-sky-500/[0.05]"),{id:i.id,position:{x:72+c*308,y:56+y*168},draggable:!1,selectable:!1,data:{label:e.jsxs("div",{className:`min-w-[220px] rounded-[22px] border px-4 py-4 shadow-[0_24px_70px_rgba(0,0,0,0.24)] ${g}`,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(m,{className:"bg-white/[0.08] text-white/74",children:i.entityType}),u?e.jsx(m,{className:"bg-emerald-500/12 text-emerald-200",children:"Active"}):null,n?e.jsx(m,{className:"bg-rose-500/12 text-rose-200",children:"Blocked"}):null,p?e.jsx(m,{className:"bg-amber-500/12 text-amber-200",children:"Out of order"}):null,f&&!n&&!p?e.jsx(m,{className:"bg-sky-500/12 text-sky-200",children:"In plan"}):null]}),e.jsx("div",{className:"mt-3 text-base font-medium leading-6 text-white",children:i.title}),i.branchLabel?e.jsx("div",{className:"mt-2 text-xs uppercase tracking-[0.16em] text-white/45",children:i.branchLabel}):null,i.notes?e.jsx("div",{className:"mt-2 text-sm leading-5 text-white/56",children:i.notes}):null,t?e.jsxs("div",{className:"mt-3 flex items-center gap-2 text-xs text-white/52",children:[e.jsx("span",{className:"inline-block size-2.5 rounded-full",style:{backgroundColor:t.color}}),e.jsx("span",{children:t.label})]}):null]})},style:{background:"transparent",border:"none",padding:0}}})}function we(a){return a.graph.edges.map(r=>{const l=a.metrics.activeNodeIds.includes(r.to),o=a.metrics.blockedNodeIds.includes(r.to),i=a.metrics.outOfOrderNodeIds.includes(r.to);let c="rgba(255,255,255,0.3)";return l?c="#4ade80":o?c="#fb7185":i&&(c="#f59e0b"),{id:`${r.from}->${r.to}`,source:r.from,target:r.to,label:r.label||void 0,animated:l,markerEnd:{type:ce.ArrowClosed,color:c},style:{stroke:c,strokeWidth:l?2.4:1.5},labelStyle:{fill:"rgba(255,255,255,0.56)",fontSize:11,fontWeight:600}}})}function ve({strategy:a,ownerByNodeId:r,heightClassName:l="h-[540px]"}){const o=h.useMemo(()=>ye(a,r),[r,a]),i=h.useMemo(()=>we(a),[a]);return e.jsx("div",{className:`${l} rounded-[24px] bg-[radial-gradient(circle_at_top,rgba(125,211,252,0.08),transparent_32%),radial-gradient(circle_at_bottom_right,rgba(244,185,122,0.10),transparent_38%),linear-gradient(180deg,rgba(6,10,20,0.97),rgba(8,14,26,0.94))]`,children:e.jsxs(le,{fitView:!0,nodes:o,edges:i,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,attributionPosition:"bottom-left",children:[e.jsx(de,{showInteractive:!1}),e.jsx(oe,{gap:28,size:1,color:"rgba(255,255,255,0.06)"})]})})}function Ne(a,r){const l=a.metrics.activeNodeIds.includes(r),o=a.metrics.blockedNodeIds.includes(r),i=a.metrics.outOfOrderNodeIds.includes(r);return o?{label:"Blocked",className:"bg-rose-500/12 text-rose-200"}:i?{label:"Out of order",className:"bg-amber-500/12 text-amber-200"}:l?{label:"Ready now",className:"bg-emerald-500/12 text-emerald-200"}:{label:"In plan",className:"bg-sky-500/12 text-sky-200"}}function ke({strategy:a,projectsById:r,tasksById:l,className:o}){const i=h.useMemo(()=>je(a.graph),[a.graph]),c=h.useMemo(()=>{const n=new Map;for(const p of a.graph.nodes)n.set(p.id,[]);for(const p of a.graph.edges)n.set(p.to,[...n.get(p.to)??[],p.from]);return n},[a.graph]),[y,u]=h.useState([]);return e.jsxs("div",{className:o??"grid gap-3",children:[i.map(n=>{const p=y.includes(n.level),f=n.level===0?"Launch phase":`Phase ${n.level+1}`,t=n.nodeIds.length>1;return e.jsxs("div",{className:"rounded-[24px] border border-white/8 bg-white/[0.03]",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 px-4 py-4",children:[e.jsxs("button",{type:"button",className:"flex min-w-0 items-center gap-3 text-left",onClick:()=>u(g=>p?g.filter(d=>d!==n.level):[...g,n.level]),children:[e.jsx("span",{className:"rounded-full bg-white/[0.06] p-2 text-white/72",children:p?e.jsx(W,{className:"size-4"}):e.jsx(K,{className:"size-4"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:f}),e.jsx("div",{className:"mt-1 text-sm text-white/60",children:t?"These branches can progress in parallel once the previous phase is complete.":"This phase advances as one focused step in the strategy."})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(m,{className:"bg-white/[0.08] text-white/76",children:[n.nodeIds.length," node",n.nodeIds.length===1?"":"s"]}),e.jsx(m,{className:"bg-white/[0.08] text-white/76",children:t?e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"mr-1 size-3.5"}),"Parallel"]}):e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"mr-1 size-3.5"}),"Sequential"]})})]})]}),p?null:e.jsx("div",{className:"grid gap-3 border-t border-white/8 px-4 py-4 lg:grid-cols-2",children:n.nodeIds.map(g=>{var O,N,P;const d=a.graph.nodes.find(b=>b.id===g);if(!d)return null;const v=d.entityType==="project"?r.get(d.entityId):l.get(d.entityId),T=d.entityType==="project"?`/projects/${d.entityId}`:`/tasks/${d.entityId}`,I=d.entityType==="project"?(O=r.get(d.entityId))==null?void 0:O.user:(N=l.get(d.entityId))==null?void 0:N.user,j=((P=c.get(d.id))==null?void 0:P.map(b=>{var $;return(($=a.graph.nodes.find(B=>B.id===b))==null?void 0:$.title)??b}))??[],w=Ne(a,d.id);return e.jsxs("div",{className:"rounded-[20px] border border-white/8 bg-[rgba(8,14,26,0.76)] p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(m,{className:"bg-white/[0.08] text-white/76",children:d.entityType}),e.jsx(m,{className:w.className,children:w.label})]}),e.jsx(A,{to:T,className:"mt-3 block text-lg font-medium text-white transition hover:text-[var(--primary)]",children:d.title}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/54",children:d.notes||("description"in(v??{})?v==null?void 0:v.description:"")||"No extra step note attached yet."})]}),e.jsx(M,{user:I,compact:!0})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[d.branchLabel?e.jsx(m,{className:"bg-[rgba(192,193,255,0.12)] text-white/82",children:d.branchLabel}):null,j.length===0?e.jsx(m,{className:"bg-emerald-500/10 text-emerald-200",children:"Start node"}):j.map(b=>e.jsxs(m,{className:"bg-white/[0.08] text-white/70",children:["Depends on ",b]},`${d.id}:${b}`))]})]},d.id)})})]},n.level)}),i.length===0?e.jsx("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.03] px-4 py-4 text-sm text-white/56",children:"No phases mapped yet."}):null]})}function Ee(){var B;const a=xe(),{strategyId:r}=J(),l=X(),o=Y(),[i,c]=h.useState(!1),[y,u]=h.useState(),n=pe(a.selectedUserIds),p=a.snapshot.strategies.find(s=>s.id===r)??null,f=ee({queryKey:["strategy-detail",r],queryFn:async()=>(await be(r)).strategy,enabled:!!(r&&!p)}),t=p??f.data??null,g=async()=>{await Promise.all([o.invalidateQueries({queryKey:["strategy-detail",r]}),a.refresh()])},d=D({mutationFn:async({input:s,currentStrategyId:x})=>(await F(x,s)).strategy,onSuccess:g}),v=D({mutationFn:async s=>me(s),onSuccess:async()=>{await g(),l("/strategies")}}),T=D({mutationFn:async s=>(await F(r,{isLocked:s,lockedByUserId:s?n??(t==null?void 0:t.userId)??"user_operator":null})).strategy,onSuccess:g}),I=h.useMemo(()=>new Map(a.snapshot.goals.map(s=>[s.id,s])),[a.snapshot.goals]),j=h.useMemo(()=>new Map(a.snapshot.dashboard.projects.map(s=>[s.id,s])),[a.snapshot.dashboard.projects]),w=h.useMemo(()=>new Map(a.snapshot.tasks.map(s=>[s.id,s])),[a.snapshot.tasks]),O=h.useMemo(()=>t?new Map(t.graph.nodes.map(s=>{var S,C;const x=s.entityType==="project"?(S=j.get(s.entityId))==null?void 0:S.user:(C=w.get(s.entityId))==null?void 0:C.user;return[s.id,x?{label:`${x.displayName} (${x.kind})`,color:x.accentColor}:null]})):new Map,[j,t,w]),N=t??{title:"",overview:"",endStateDescription:"",targetGoalIds:[],targetProjectIds:[],graph:{nodes:[],edges:[]}},P=h.useMemo(()=>ae(N),[N]),b=h.useMemo(()=>ie(N),[N]),$=h.useMemo(()=>re((t==null?void 0:t.metrics)??{planCoverageScore:0,sequencingScore:0,scopeDisciplineScore:0,qualityScore:0,targetProgressScore:0,startedNodeCount:0,totalNodeCount:1,offPlanEntityCount:0,offPlanActiveEntityCount:0,blockedNodeIds:[],outOfOrderNodeIds:[]}),[t==null?void 0:t.metrics]);return f.isLoading&&!t?e.jsx(ge,{eyebrow:"Strategy",title:"Loading strategy",description:"Resolving the directed plan, targets, and current alignment."}):f.isError?e.jsx(G,{eyebrow:"Strategy",error:f.error,onRetry:()=>void f.refetch()}):t?e.jsxs("div",{className:"grid gap-5",children:[e.jsx(fe,{title:t.title,titleText:t.title,description:t.overview||t.endStateDescription,badge:`${t.metrics.alignmentScore}% aligned`,actions:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(se,{userId:n,domain:"strategies",entityType:"strategy",entityId:t.id,label:t.title,description:t.overview||t.endStateDescription}),e.jsx(te,{entityType:"strategy",entityId:t.id}),t.isLocked?null:e.jsx(L,{variant:"secondary",onClick:()=>{u(void 0),c(!0)},children:"Edit strategy"}),e.jsx(L,{variant:"secondary",disabled:!t.isLocked&&!b,pending:T.isPending,pendingLabel:t.isLocked?"Unlocking contract":"Locking contract",onClick:()=>{T.mutateAsync(!t.isLocked)},children:t.isLocked?"Unlock contract":"Lock as contract"}),e.jsx(L,{variant:"secondary",pending:v.isPending,pendingLabel:"Deleting strategy",onClick:()=>{window.confirm(`Delete strategy "${t.title}"?`)&&v.mutateAsync(t.id)},children:"Delete"})]})}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(M,{user:t.user}),e.jsx(m,{className:t.isLocked?"bg-amber-500/12 text-amber-200":"bg-emerald-500/12 text-emerald-200",children:t.isLocked?"Contract locked":"Editable draft"}),e.jsx(m,{className:"bg-white/[0.08] text-white/76",children:t.status}),e.jsxs(m,{className:"bg-white/[0.08] text-white/76",children:[t.graph.nodes.length," nodes"]}),e.jsxs(m,{className:"bg-white/[0.08] text-white/76",children:[t.graph.edges.length," edges"]})]}),e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.15fr)_minmax(18rem,0.85fr)]",children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(k,{className:"grid gap-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"End state"}),e.jsx("div",{className:"text-sm leading-7 text-white/64",children:t.endStateDescription||"No end-state description yet."})]}),e.jsxs(k,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Directed execution graph"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:"The graph is the contract surface for this strategy. It shows which branches are available now, where work is blocked, and whether any node is moving out of sequence."})]}),t.isLocked?null:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(L,{variant:"secondary",onClick:()=>{u("sequence"),c(!0)},children:"Refine sequence"}),e.jsx(L,{onClick:()=>{u("sequence"),c(!0)},children:"Add parallel work"})]})]}),e.jsx(ve,{strategy:t,ownerByNodeId:O}),e.jsx(ke,{strategy:t,projectsById:j,tasksById:w})]})]}),e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(k,{className:"grid gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Contract state"}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:t.isLocked?"This strategy is currently locked as a contract. The graph, targets, and descriptive plan stay frozen until you explicitly unlock it.":"This strategy is still a draft. Agents and users can keep refining the plan until you lock it."}),t.isLocked?e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2 text-sm text-white/60",children:[e.jsxs("span",{children:["Locked by"," ",((B=t.lockedByUser)==null?void 0:B.displayName)??"Unknown user"]}),t.lockedAt?e.jsxs("span",{children:["· ",new Date(t.lockedAt).toLocaleString()]}):null]}):null,t.isLocked?null:e.jsx("div",{className:"mt-4 grid gap-2",children:P.map(s=>e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[14px] bg-white/[0.03] px-3 py-2",children:[e.jsx("div",{className:"text-sm text-white/64",children:s.label}),e.jsx(m,{className:s.satisfied?"bg-emerald-500/12 text-emerald-200":"bg-amber-500/12 text-amber-200",children:s.satisfied?"Ready":"Missing"})]},s.id))})]}),!t.isLocked&&!b?e.jsx("div",{className:"rounded-[18px] border border-amber-400/18 bg-amber-500/[0.08] px-4 py-3 text-sm leading-6 text-amber-100/86",children:"Add a target goal or project plus an overview or end state before locking this draft as the execution contract."}):null,t.isLocked?null:e.jsx("div",{className:"mt-4 text-xs leading-5 text-white/46",children:"Drafts may stay incomplete while humans and agents negotiate the plan. Only the lock action requires the contract checks to pass."})]}),e.jsxs(k,{className:"grid gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Alignment metrics"}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-4",children:[e.jsx("div",{className:"text-sm text-white/56",children:"Alignment score"}),e.jsxs("div",{className:"mt-2 font-display text-3xl text-[var(--primary)]",children:[t.metrics.alignmentScore,"%"]}),e.jsxs("div",{className:"mt-3 text-xs leading-5 text-white/48",children:[t.metrics.startedNodeCount,"/",t.metrics.totalNodeCount," planned nodes started,"," ",t.metrics.completedNodeCount," completed,"," ",t.metrics.readyNodeCount," ready now."]})]}),$.map(s=>e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-sm text-white/56",children:s.label}),e.jsxs("div",{className:"text-sm font-medium text-white",children:[s.value,"%"]})]}),e.jsx(he,{value:s.value,className:"mt-3"}),e.jsx("div",{className:"mt-3 text-xs leading-5 text-white/48",children:s.detail})]},s.id))]}),e.jsxs(k,{className:"grid gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"End targets"}),t.targetGoalIds.map(s=>{const x=I.get(s);return x?e.jsx(A,{to:`/goals/${x.id}`,className:"rounded-[16px] bg-white/[0.04] px-4 py-3 text-sm text-white/78 transition hover:bg-white/[0.08]",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("span",{children:["Goal: ",x.title]}),e.jsx(M,{user:x.user,compact:!0})]})},x.id):null}),t.targetProjectIds.map(s=>{const x=j.get(s);return x?e.jsx(A,{to:`/projects/${x.id}`,className:"rounded-[16px] bg-white/[0.04] px-4 py-3 text-sm text-white/78 transition hover:bg-white/[0.08]",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("span",{children:["Project: ",x.title]}),e.jsx(M,{user:x.user,compact:!0})]})},x.id):null}),t.targetGoalIds.length===0&&t.targetProjectIds.length===0?e.jsx("div",{className:"rounded-[16px] bg-white/[0.04] px-4 py-3 text-sm text-white/52",children:"No end targets linked yet."}):null]}),e.jsxs(k,{className:"grid gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Linked entities"}),t.linkedEntities.length===0?e.jsx("div",{className:"rounded-[16px] bg-white/[0.04] px-4 py-3 text-sm text-white/52",children:"No additional linked entities."}):t.linkedEntities.map(s=>{var C,E,q,_,R,U,z;const x=ue(s.entityType,s.entityId),S=s.entityType==="goal"?(C=I.get(s.entityId))==null?void 0:C.title:s.entityType==="project"?(E=j.get(s.entityId))==null?void 0:E.title:s.entityType==="task"?(q=w.get(s.entityId))==null?void 0:q.title:`${s.entityType}:${s.entityId}`;return x?e.jsx(A,{to:x,className:"rounded-[16px] bg-white/[0.04] px-4 py-3 text-sm text-white/78 transition hover:bg-white/[0.08]",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("span",{children:S}),e.jsx(M,{user:s.entityType==="goal"?(_=I.get(s.entityId))==null?void 0:_.user:s.entityType==="project"?(R=j.get(s.entityId))==null?void 0:R.user:s.entityType==="task"?(U=w.get(s.entityId))==null?void 0:U.user:s.entityType==="strategy"?(z=a.snapshot.strategies.find(H=>H.id===s.entityId))==null?void 0:z.user:null,compact:!0})]})},`${s.entityType}:${s.entityId}`):e.jsx("div",{className:"rounded-[16px] bg-white/[0.04] px-4 py-3 text-sm text-white/52",children:S},`${s.entityType}:${s.entityId}`)})]})]})]}),e.jsx(ne,{open:i,pending:d.isPending,editingStrategy:t,goals:a.snapshot.dashboard.goals,projects:a.snapshot.dashboard.projects,tasks:a.snapshot.tasks,habits:a.snapshot.habits,strategies:a.snapshot.strategies,users:a.snapshot.users,defaultUserId:n,initialStepId:y,onOpenChange:s=>{c(s),s||u(void 0)},onSubmit:async s=>{await d.mutateAsync({input:s,currentStrategyId:t.id})}})]}):e.jsx(G,{eyebrow:"Strategy",error:new Error("Strategy not found."),onRetry:()=>l("/strategies")})}export{Ee as StrategyDetailPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{bc as he,aL as Ke,br as Ue,cd as it,bO as nt,j as e,aC as A,b2 as Ee,cc as rt,b5 as lt,r as N,ce as ct,aV as xe,aG as dt,be as ot,cy as xt,aP as Me,bg as mt,bo as ht}from"./vendor-kIz9EZnX.js";import{j as ut,i as Z,k as y}from"./state-VYvD1QVP.js";import{Z as z,aq as We,b as J,c as i,U as Re,P as pt,u as gt,s as wt,ay as jt,r as bt,eO as kt,eP as ft,at as vt,as as Nt,x as yt,y as St,z as Tt,S as At,E as Oe,a8 as Ct,V as Fe,C as It,B as b,h as T,d as me,K as Le,az as $t,aT as Pt,i as Dt,eQ as Et,N as Be,O as Mt}from"./index-BHIKoiZ6.js";import{a as Rt,T as Ot}from"./timebox-planning-dialog-Ww0NGLLo.js";import{O as Ft}from"./open-in-graph-button-C0TGev7c.js";import{N as X}from"./note-markdown-CsGQhQXF.js";import{E as Lt}from"./entity-notes-surface-CBylYDwy.js";import{P as Bt}from"./preference-entity-handoff-button-DOKV9bZc.js";import{g as qt,e as zt,W as Kt}from"./calendar-rules-CaZXtlxt.js";import{P as Ut}from"./page-hero-oFHaAjtL.js";import{g as Wt,a as Qt}from"./activity-copy-Bj4h9OcF.js";import{g as qe,a as ze}from"./entity-links-DwpxhW2H.js";import"./motion-CfdU2F35.js";import"./ui-CsEkP2V8.js";import"./forms-CmLAyGqz.js";import"./board-DqHzdCPQ.js";import"./graph-BTa79qum.js";import"./scheduling-rules-editor-B9KNKsQz.js";import"./calendar-ui-Cy1XRwzV.js";import"./note-tags-input-DdZi93tj.js";const Y=[{status:"backlog",label:"Backlog",description:"Not started yet.",icon:he},{status:"focus",label:"Focus",description:"Ready to start soon.",icon:Ke},{status:"in_progress",label:"In progress",description:"Work is active now.",icon:Ue},{status:"blocked",label:"Blocked",description:"Something is stopping progress.",icon:it},{status:"done",label:"Done",description:"The task is completed.",icon:nt}],_t={issue:{label:"Issue",noun:"issue",descriptor:"Vertical slice issue",heroDescription:"Track the vertical slice, keep the acceptance bar explicit, and surface the execution context without losing the product-level story."},task:{label:"Task",noun:"task",descriptor:"AI session task",heroDescription:"Drive one focused AI execution session, keep the work contract crisp, and show the concrete evidence of what changed."},subtask:{label:"Subtask",noun:"subtask",descriptor:"Granular child step",heroDescription:"Keep the child step sharply scoped, trace its parent chain, and make the work evidence visible without opening the editor."}},Gt={commit:{label:"Commit",className:"bg-emerald-500/12 text-emerald-100"},branch:{label:"Branch",className:"bg-sky-500/12 text-sky-100"},pull_request:{label:"Pull request",className:"bg-fuchsia-500/12 text-fuchsia-100"}};function ue(a){return a==="issue"?"issue":"task"}function Ht(a,o){switch(a){case"goal":return`/goals/${o}`;case"project":return`/projects/${o}`;case"task":return`/tasks/${o}`;case"strategy":return`/strategies/${o}`;case"habit":return"/habits";default:return null}}function D(a){if(!a||a<=0)return"0 min";if(a<3600)return`${Math.max(1,Math.round(a/60))} min`;const o=Math.floor(a/3600),x=Math.round(a%3600/60);return x===0?`${o} h`:`${o} h ${x} min`}function h({label:a,help:o}){return e.jsxs("div",{className:"flex items-center gap-2 text-sm text-white/58",children:[e.jsx("span",{children:a}),o?e.jsx(We,{content:o,label:`Explain ${a}`}):null]})}function E({eyebrow:a,title:o,description:x,children:c,className:u}){return e.jsxs("div",{className:z("rounded-[24px] border border-white/8 bg-[linear-gradient(180deg,rgba(255,255,255,0.05),rgba(255,255,255,0.025))] p-4 sm:p-5",u),children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:a}),e.jsx("div",{className:"mt-2 text-lg font-medium text-white",children:o}),x?e.jsx("p",{className:"mt-2 text-sm leading-6 text-white/56",children:x}):null,e.jsx("div",{className:"mt-4",children:c})]})}function g({label:a,value:o,hint:x,className:c}){return e.jsxs("div",{className:z("rounded-[18px] border border-white/8 bg-white/[0.035] px-4 py-3",c),children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:a}),e.jsx("div",{className:"mt-2 text-base font-medium text-white",children:o}),x?e.jsx("div",{className:"mt-1 text-sm leading-5 text-white/52",children:x}):null]})}function Vt({payload:a,relatedWorkItems:o,availableTags:x,workItemMeta:c,taskLevel:u,hasAiBrief:w,botOwner:ee,formatDate:k,formatDateTime:C}){const M=a.task.parentWorkItemId?o.find(l=>l.id===a.task.parentWorkItemId)??null:null,R=o.filter(l=>l.parentWorkItemId===a.task.id).sort((l,f)=>l.sortOrder-f.sortOrder),K=(a.task.tagIds??[]).map(l=>x.find(f=>f.id===l)??null).filter(l=>!!l),O=a.task.blockerLinks??[];return e.jsxs("div",{className:"mt-5 grid gap-4 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,1fr)_minmax(0,1fr)]",children:[e.jsx(E,{eyebrow:"Hierarchy",title:"Context map",description:`See where this ${c.noun} sits in the larger planning ladder without opening the board.`,children:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{label:"Project",help:`The project is the main work stream this ${c.noun} belongs to.`}),e.jsx("div",{className:"mt-2",children:a.project?e.jsx(A,{to:`/projects/${a.project.id}`,className:"inline-flex max-w-full",children:e.jsx(J,{kind:"project",label:a.project.title,compact:!0,gradient:!1,wrap:!0,className:"max-w-full"})}):e.jsx(i,{className:"bg-white/[0.08] text-white/65",children:"No project linked"})})]}),e.jsxs("div",{children:[e.jsx(h,{label:"Goal",help:"The goal shows the longer-term result this work supports."}),e.jsx("div",{className:"mt-2",children:a.goal?e.jsx(A,{to:`/goals/${a.goal.id}`,className:"inline-flex max-w-full",children:e.jsx(J,{kind:"goal",label:a.goal.title,compact:!0,gradient:!1,wrap:!0,className:"max-w-full"})}):e.jsx(i,{className:"bg-white/[0.08] text-white/65",children:"No goal linked"})})]}),e.jsxs("div",{children:[e.jsx(h,{label:"Parent item",help:"Issues parent tasks, tasks parent subtasks, and split child items stay legible here."}),e.jsx("div",{className:"mt-2",children:M?e.jsx(A,{to:`/tasks/${M.id}`,className:"inline-flex max-w-full",children:e.jsx(J,{kind:ue(M.level),label:M.title,compact:!0,gradient:!1,wrap:!0,className:"max-w-full"})}):e.jsx(i,{className:"bg-white/[0.08] text-white/65",children:"No parent work item"})})]}),e.jsxs("div",{children:[e.jsx(h,{label:"Child items",help:"Child work items let you scan the next layer down without leaving the detail view."}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:R.length>0?R.map(l=>e.jsx(A,{to:`/tasks/${l.id}`,className:"inline-flex max-w-full",children:e.jsx(J,{kind:ue(l.level),label:l.title,compact:!0,gradient:!1,wrap:!0,className:"max-w-full"})},l.id)):e.jsx(i,{className:"bg-white/[0.08] text-white/65",children:"No child work items"})})]})]})}),e.jsx(E,{eyebrow:"Execution",title:"Execution profile",description:"Surface the operating mode, AI posture, tags, and blockers as a single readable brief.",children:e.jsxs("div",{className:"grid gap-3",children:[e.jsx(g,{label:"Work-item type",value:c.descriptor,hint:u==="task"?"Tasks are meant to fit one focused AI session.":u==="issue"?"Issues hold the vertical slice and its delivery contract.":"Subtasks stay intentionally small and concrete."}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(g,{label:"Execution mode",value:a.task.executionMode?a.task.executionMode.toUpperCase():"Not set"}),e.jsx(g,{label:"AI posture",value:w?"AI brief ready":u==="issue"?"Issue narrative only":"Needs AI brief"})]}),e.jsxs("div",{children:[e.jsx(h,{label:"Tags",help:"Tags shape filtering and fast scanning across the board and hierarchy views."}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:K.length>0?K.map(l=>e.jsx(i,{className:"bg-white/[0.08] text-white/72",children:l.name},l.id)):e.jsx(i,{className:"bg-white/[0.08] text-white/65",children:"No tags"})})]}),e.jsxs("div",{children:[e.jsx(h,{label:"Blockers",help:"Blockers tie this work item to the entities that currently constrain it."}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:O.length>0?O.map(l=>{const f=Ht(l.entityType,l.entityId),U=e.jsx(i,{wrap:!0,className:"bg-amber-500/12 text-amber-100",children:l.label??`${l.entityType} · ${l.entityId}`},`${l.entityType}:${l.entityId}`);return f?e.jsx(A,{to:f,className:"inline-flex max-w-full",children:U},`${l.entityType}:${l.entityId}`):U}):e.jsx(i,{className:"bg-white/[0.08] text-white/65",children:"No blockers linked"})})]})]})}),e.jsx(E,{eyebrow:"People and timing",title:"Accountability surface",description:"Show who owns the work, who is helping, and when the record moved.",children:e.jsxs("div",{className:"grid gap-3",children:[e.jsx(g,{label:"Owner",value:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.task.user?e.jsx(Re,{user:a.task.user,compact:!0}):null,e.jsx("span",{children:a.task.owner}),ee?e.jsxs(i,{className:"bg-fuchsia-500/12 text-fuchsia-100",children:[e.jsx(Ee,{className:"mr-1 size-3.5"}),"Bot owner"]}):null]})}),e.jsxs("div",{children:[e.jsx(h,{label:"Assignees"}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:a.task.assignees&&a.task.assignees.length>0?a.task.assignees.map(l=>e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-white/8 bg-white/[0.05] px-3 py-1.5 text-sm text-white/72",children:[e.jsx(Re,{user:l,compact:!0}),e.jsx("span",{children:l.displayName}),l.kind==="bot"?e.jsx(Ee,{className:"size-3.5 text-fuchsia-200"}):null]},l.id)):e.jsx(i,{className:"bg-white/[0.08] text-white/65",children:"No assignees"})})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(g,{label:"Due date",value:k(a.task.dueDate),hint:`Use due dates only when timing materially matters for this ${c.noun}.`}),e.jsx(g,{label:"Completed",value:a.task.completedAt?C(a.task.completedAt):"Not completed"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(g,{label:"Created",value:C(a.task.createdAt)}),e.jsx(g,{label:"Updated",value:C(a.task.updatedAt)})]})]})})]})}function gs(){var Se,Te,Ae,Ce,Ie,$e,Pe;const{t:a,formatDate:o,formatDateTime:x}=pt(),c=gt(),u=Array.isArray(c.selectedUserIds)?c.selectedUserIds:[],w=rt(),ee=lt(),k=ut(),C=wt(u),[M,R]=N.useState(!1),[K,O]=N.useState(!1),[l,f]=N.useState(!1),[U,pe]=N.useState(!1),[Qe,te]=N.useState(!1),[_e,W]=N.useState(null),[Q,Ge]=N.useState(()=>typeof window<"u"?window.matchMedia("(max-width: 1023px)").matches:!1),[se]=N.useState(()=>{const t=new Date,n=new Date(t);n.setHours(0,0,0,0);const r=new Date(t);return r.setHours(23,59,59,999),{from:n.toISOString(),to:r.toISOString()}}),[F]=N.useState(()=>{const t=new Date,n=new Date(t);n.setHours(0,0,0,0);const r=new Date(n);return r.setDate(r.getDate()+7),r.setHours(23,59,59,999),{from:n.toISOString(),to:r.toISOString()}});N.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const t=window.matchMedia("(max-width: 1023px)"),n=r=>Ge(r?r.matches:t.matches);return n(),typeof t.addEventListener=="function"?(t.addEventListener("change",n),()=>t.removeEventListener("change",n)):(t.addListener(n),()=>t.removeListener(n))},[]);const $=Z({queryKey:["task-context",w.taskId],queryFn:()=>Et(w.taskId),enabled:!!w.taskId}),He=Z({queryKey:["task-calendar-overview",w.taskId,se.from,se.to,...u],queryFn:()=>Be({...se,userIds:u}),enabled:!!w.taskId}),I=Z({queryKey:["forge-life-force",...u],queryFn:async()=>(await Mt(u)).lifeForce}),Ve=Z({queryKey:["task-calendar-overview",w.taskId,F.from,F.to,...u],queryFn:()=>Be({...F,userIds:u}),enabled:!!w.taskId}),v=async()=>{await Promise.all([Dt(k),k.invalidateQueries({queryKey:["task-context",w.taskId]}),k.invalidateQueries({queryKey:["activity-archive"]}),k.invalidateQueries({queryKey:["project-board"]}),k.invalidateQueries({queryKey:["forge-xp-metrics"]}),k.invalidateQueries({queryKey:["forge-reward-ledger"]}),k.invalidateQueries({queryKey:["forge-operator-context"]}),k.invalidateQueries({queryKey:["task-calendar-overview",w.taskId]}),k.invalidateQueries({queryKey:["forge-calendar-overview"]})])},_=y({mutationFn:({taskId:t,patch:n})=>c.patchTask(t,n),onSuccess:v}),Ze=y({mutationFn:t=>jt(t),onSuccess:v}),Je=y({mutationFn:t=>bt(t),onSuccess:v}),ge=y({mutationFn:({runId:t,actor:n,note:r})=>kt(t,{actor:n,note:r??""}),onSuccess:v}),we=y({mutationFn:({runId:t,actor:n,note:r})=>ft(t,{actor:n,note:r??""}),onSuccess:v}),ae=y({mutationFn:vt,onSuccess:v}),je=y({mutationFn:t=>Nt(t),onSuccess:v}),ie=y({mutationFn:yt,onSuccess:v}),be=y({mutationFn:({timeboxId:t,patch:n})=>St(t,n),onSuccess:v}),Xe=y({mutationFn:Tt,onSuccess:v}),s=$.data;if($.isLoading)return e.jsx(At,{});if($.isError)return e.jsx(Oe,{eyebrow:a("common.taskDetail.errorEyebrow"),error:$.error,onRetry:()=>void $.refetch()});if(!s)return e.jsx(Oe,{eyebrow:a("common.taskDetail.errorEyebrow"),error:new Error(a("common.taskDetail.emptyPayload")),onRetry:()=>void $.refetch()});const j=s.activeTaskRun??null,m=s.task.actionPointSummary??null,ke=Y.find(t=>t.status===s.task.status)??Y[0],ne=s.task.level??"task",fe=s.task.aiInstructions??"",Ye=qt(s.task,(Se=s.project)==null?void 0:Se.schedulingRules),P=zt({rules:Ye,overview:(Te=He.data)==null?void 0:Te.calendar}),G=(((Ae=Ve.data)==null?void 0:Ae.calendar.timeboxes)??[]).filter(t=>t.taskId===s.task.id).sort((t,n)=>Date.parse(t.startsAt)-Date.parse(n.startsAt)),re=G[0]??null,p=_t[ne],le=ue(ne),et=c.snapshot.workItems??c.snapshot.tasks??[],tt=c.snapshot.tags??[],ce=s.task.acceptanceCriteria??[],H=s.task.gitRefs??[],d=s.task.completionReport,ve=new Set((d==null?void 0:d.linkedGitRefIds)??[]),de=H.filter(t=>ve.has(t.id)),Ne=H.filter(t=>!ve.has(t.id)),oe=((Ce=s.task.user)==null?void 0:Ce.kind)==="bot"||((Ie=s.task.ownerUser)==null?void 0:Ie.kind)==="bot",L=(s.task.assignees??[]).filter(t=>t.kind==="bot"),V=fe.trim().length>0,S=Q?"w-full justify-start":"",st=t=>{switch(t){case"active":return"Active";case"completed":return"Completed";case"released":return"Paused";case"timed_out":return"Timed out";default:return t}},ye=async t=>{await c.patchTaskStatus(s.task.id,t),await v(),te(!1)},at=async()=>{window.confirm(`Delete ${p.noun} "${s.task.title}"?`)&&(await je.mutateAsync(s.task.id),ee(s.project?`/projects/${s.project.id}`:s.goal?`/goals/${s.goal.id}`:"/kanban"))};return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(Ut,{entityKind:le,title:e.jsx(Fe,{kind:le,label:s.task.title,variant:"heading",size:"lg",lines:3,className:"max-w-full",labelClassName:"[overflow-wrap:anywhere]"}),titleText:s.task.title,description:s.task.description?e.jsx(X,{markdown:s.task.description,className:"[&>p]:text-[13px] [&>p]:leading-6 [&>blockquote]:text-[13px] [&>ul]:text-[13px] [&>ol]:text-[13px]"}):p.heroDescription,badge:m?`${s.task.points} xp · ${Math.round(m.totalCostAp)} AP`:`${s.task.points} xp`,actions:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(Ct,{metrics:c.snapshot.metrics}),e.jsx(Bt,{userId:C,domain:"tasks",entityType:"task",entityId:s.task.id,label:s.task.title,description:s.task.description}),e.jsx(Ft,{entityType:"task",entityId:s.task.id})]})}),e.jsxs(It,{className:"min-w-0 overflow-hidden",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:p.label}),e.jsx("div",{className:"mt-2",children:e.jsx(Fe,{kind:le,label:s.task.title,variant:"heading",size:"xl",lines:3,className:"max-w-full",labelClassName:"[overflow-wrap:anywhere]"})}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/60",children:s.task.description?e.jsx(X,{markdown:s.task.description,className:"[&>p]:text-sm [&>p]:leading-6 [&>blockquote]:text-sm [&>ul]:text-sm [&>ol]:text-sm"}):`This page shows the ${p.noun}, where it belongs, what is driving it, and the concrete evidence of what has happened on it so far.`})]}),e.jsx("div",{className:z("shrink-0",Q?"w-full":""),children:e.jsxs("div",{className:z("flex flex-wrap items-center gap-2",Q&&"grid w-full grid-cols-1"),children:[e.jsxs(b,{className:S,pending:$.isFetching,pendingLabel:j?"Opening":"Starting",onClick:async()=>{await c.startTaskNow(s.task.id),await v()},children:[e.jsx(Ue,{className:"size-4 fill-current"}),j?"Focus work":"Start work"]}),j?e.jsxs(e.Fragment,{children:[e.jsx(b,{className:S,variant:"secondary",pending:ge.isPending,pendingLabel:"Pausing",onClick:async()=>{await ge.mutateAsync({runId:j.id,actor:j.actor,note:j.note})},children:"Pause"}),e.jsx(b,{className:S,variant:"secondary",pending:we.isPending,pendingLabel:"Completing",onClick:async()=>{await we.mutateAsync({runId:j.id,actor:j.actor,note:j.note})},children:"Complete"})]}):null,e.jsxs(b,{className:S,variant:"secondary",onClick:()=>te(!0),children:[e.jsx(ke.icon,{className:"size-4"}),"Change status"]}),e.jsxs(b,{className:S,variant:"secondary",onClick:()=>R(!0),children:[e.jsx(ct,{className:"size-4"}),"Edit ",p.noun]}),e.jsxs(b,{className:S,variant:"secondary",onClick:()=>O(!0),children:[e.jsx(he,{className:"size-4"}),"Adjust work"]}),e.jsxs(b,{className:S,variant:"secondary",pending:ie.isPending,pendingLabel:"Planning",onClick:()=>f(!0),children:[e.jsx(xe,{className:"size-4"}),"Time Box"]}),s.task.status==="done"?e.jsx(b,{className:S,variant:"secondary",onClick:async()=>{await Ze.mutateAsync(s.task.id)},children:"Mark as not done"}):null,e.jsxs(b,{className:z(S,"text-rose-200 hover:bg-rose-500/10"),variant:"ghost",pending:je.isPending,pendingLabel:a("common.taskDetail.deleting"),onClick:()=>void at(),children:["Delete ",p.noun]})]})})]}),e.jsxs("div",{className:"mt-5 flex flex-wrap gap-2",children:[e.jsx(i,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:p.label}),e.jsx(i,{className:"bg-white/[0.08] text-white/72",children:p.descriptor}),e.jsx(i,{className:"bg-white/[0.08] text-white/72",children:ke.label}),e.jsx(i,{className:"bg-white/[0.08] text-white/72",children:a(`common.enums.priority.${s.task.priority}`)}),e.jsx(i,{className:"bg-white/[0.08] text-white/72",children:a(`common.enums.effort.${s.task.effort}`)}),e.jsx(i,{className:"bg-white/[0.08] text-white/72",children:a(`common.enums.energy.${s.task.energy}`)}),e.jsxs(i,{className:"bg-white/[0.08] text-white/72",children:[s.task.points," xp"]}),s.task.time.totalCreditedSeconds>0?e.jsxs(i,{className:"bg-white/[0.08] text-white/72",children:[Math.floor(s.task.time.totalCreditedSeconds/60)," min tracked"]}):null,j?e.jsx(i,{className:"bg-emerald-500/12 text-emerald-200",children:"Timer active"}):null,s.task.executionMode?e.jsx(i,{className:s.task.executionMode==="afk"?"bg-emerald-500/12 text-emerald-100":"bg-amber-500/12 text-amber-100",children:s.task.executionMode.toUpperCase()}):null,V?e.jsx(i,{className:"bg-sky-500/12 text-sky-100",children:"AI brief ready"}):null,oe||L.length>0?e.jsx(i,{className:"bg-fuchsia-500/12 text-fuchsia-100",children:"Bot collaboration live"}):null,re?e.jsx(A,{to:`/calendar?timeboxId=${encodeURIComponent(re.id)}`,className:"inline-flex",children:e.jsxs(i,{className:"cursor-pointer bg-[var(--primary)]/16 text-[var(--primary)] transition hover:bg-[var(--primary)]/24",children:["Timeboxed · ",x(re.startsAt)]})}):null]}),Q?null:e.jsxs("div",{className:"mt-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Status"}),e.jsx("div",{className:"mt-3 grid gap-2 md:grid-cols-2 xl:grid-cols-5",children:Y.map(t=>{const n=t.icon,r=t.status===s.task.status;return e.jsxs("button",{type:"button",disabled:r||_.isPending,className:`rounded-[18px] border px-3.5 py-3 text-left transition ${r?"border-[rgba(192,193,255,0.28)] bg-[rgba(192,193,255,0.14)] text-white":"border-white/8 bg-white/[0.04] text-white/72 hover:bg-white/[0.08]"}`,onClick:()=>void ye(t.status),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(n,{className:"size-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"font-medium",children:t.label})]}),e.jsx("div",{className:"mt-2 text-xs leading-5 text-white/54",children:t.description})]},t.status)})})]}),e.jsx(Vt,{payload:s,relatedWorkItems:et,availableTags:tt,workItemMeta:p,taskLevel:ne,hasAiBrief:V,botOwner:oe,formatDate:o,formatDateTime:x}),V||ce.length>0||d||H.length>0?e.jsxs("div",{className:"mt-5 grid gap-4 xl:grid-cols-[minmax(0,1.05fr)_minmax(0,1fr)]",children:[e.jsx(E,{eyebrow:"Execution brief",title:"AI and delivery instructions",description:"The narrative, criteria, and execution intent live together so the detail view can stand on its own.",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"rounded-[20px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-white/62",children:[e.jsx(dt,{className:"size-4 text-[var(--primary)]"}),e.jsx("span",{children:"AI instructions"})]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/72",children:V?e.jsx(X,{markdown:fe,className:"[&>p]:text-sm [&>p]:leading-6 [&>blockquote]:text-sm [&>ul]:text-sm [&>ol]:text-sm"}):`No AI instructions have been written for this ${p.noun} yet.`})]}),e.jsxs("div",{className:"rounded-[20px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-white/62",children:[e.jsx(Ke,{className:"size-4 text-emerald-200"}),e.jsx("span",{children:"Acceptance criteria"})]}),ce.length>0?e.jsx("div",{className:"mt-3 grid gap-2",children:ce.map((t,n)=>e.jsx("div",{className:"rounded-[16px] border border-white/8 bg-white/[0.04] px-4 py-3 text-sm leading-6 text-white/72",children:t},`${s.task.id}-criterion-${n}`))}):e.jsx("div",{className:"mt-3 rounded-[16px] border border-dashed border-white/10 px-4 py-3 text-sm text-white/52",children:"No acceptance criteria captured yet."})]})]})}),e.jsx(E,{eyebrow:"Evidence",title:"Work done, changed files, and git traceability",description:"Show the work summary, file footprint, and linked refs directly in the detail view.",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"rounded-[20px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-white/62",children:[e.jsx(ot,{className:"size-4 text-sky-200"}),e.jsx("span",{children:"Work summary"})]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/72",children:d!=null&&d.workSummary?e.jsx(X,{markdown:d.workSummary,className:"[&>p]:text-sm [&>p]:leading-6 [&>blockquote]:text-sm [&>ul]:text-sm [&>ol]:text-sm"}):"No work summary yet."})]}),e.jsxs("div",{className:"rounded-[20px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-white/62",children:[e.jsx(xt,{className:"size-4 text-amber-200"}),e.jsx("span",{children:"Changed files"})]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:d!=null&&d.modifiedFiles&&d.modifiedFiles.length>0?d.modifiedFiles.map(t=>e.jsx(i,{wrap:!0,className:"bg-white/[0.08] font-mono text-[11px] text-white/74",children:t},t)):e.jsx(i,{className:"bg-white/[0.08] text-white/65",children:"No changed files listed"})})]}),e.jsxs("div",{className:"rounded-[20px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-white/62",children:[e.jsx(Me,{className:"size-4 text-fuchsia-200"}),e.jsx("span",{children:"Git refs"})]}),e.jsxs("div",{className:"mt-3 grid gap-3",children:[[de,Ne].filter(t=>t.length>0).map((t,n)=>e.jsxs("div",{className:"grid gap-2",children:[de.length>0&&Ne.length>0?e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/38",children:n===0?"Linked in completion report":"Other recorded refs"}):null,t.map(r=>{const B=Gt[r.refType],q=e.jsxs("div",{className:"rounded-[16px] border border-white/8 bg-white/[0.04] px-4 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(i,{className:B.className,children:B.label}),e.jsx("div",{className:"font-mono text-sm text-white/84",children:r.refValue})]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:r.displayTitle||r.repository||r.provider})]});return r.url?e.jsxs("a",{href:r.url,target:"_blank",rel:"noreferrer",className:"group block",children:[q,e.jsxs("div",{className:"mt-2 inline-flex items-center gap-1 text-[11px] uppercase tracking-[0.16em] text-[var(--primary)]",children:["Open ref",e.jsx(mt,{className:"size-3.5 transition group-hover:translate-x-0.5 group-hover:-translate-y-0.5"})]})]},r.id):e.jsx("div",{children:q},r.id)})]},`git-group-${n}`)),H.length===0?e.jsx(i,{className:"bg-white/[0.08] text-white/65",children:"No git refs recorded"}):null]})]})]})})]}):null,e.jsxs("div",{className:"mt-5 grid gap-4 xl:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",children:[e.jsxs(E,{eyebrow:"Work done",title:"Execution ledger",description:"Surface tracked work, credited work, and manual adjustments without opening the timer history.",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsx(g,{label:"Tracked total",value:D(s.task.time.totalTrackedSeconds)}),e.jsx(g,{label:"Credited total",value:D(s.task.time.totalCreditedSeconds)}),e.jsx(g,{label:"Live work",value:D(s.task.time.liveCreditedSeconds)}),e.jsx(g,{label:"Manual adjustments",value:D(s.task.time.manualAdjustedSeconds)})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(i,{className:"bg-white/[0.08] text-white/72",children:["Today credited"," ",D(s.task.time.todayCreditedSeconds??0)]}),e.jsxs(i,{className:"bg-white/[0.08] text-white/72",children:["Live tracked"," ",D(s.task.time.liveTrackedSeconds)]}),e.jsxs(i,{className:"bg-white/[0.08] text-white/72",children:["Active runs ",s.task.time.activeRunCount]})]})]}),e.jsxs(E,{eyebrow:"Workflow health",title:"Signal scan",description:"A fast read on how ready this work item is for execution and closeout.",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(g,{label:"Closeout readiness",value:d!=null&&d.workSummary||de.length>0?"Evidence present":"Needs closeout evidence",hint:($e=d==null?void 0:d.modifiedFiles)!=null&&$e.length?`${d.modifiedFiles.length} changed file${d.modifiedFiles.length===1?"":"s"} listed`:"No changed-file evidence captured yet."}),e.jsx(g,{label:"Collaboration model",value:oe||L.length>0?"Human + bot":s.task.assignees&&s.task.assignees.length>0?"Shared human work":"Single owner",hint:L.length>0?`${L.length} bot assignee${L.length===1?"":"s"} attached`:"No bot assignee attached."})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(i,{className:"bg-white/[0.08] text-white/72",children:["Priority ",a(`common.enums.priority.${s.task.priority}`)]}),e.jsxs(i,{className:"bg-white/[0.08] text-white/72",children:["Effort ",a(`common.enums.effort.${s.task.effort}`)]}),e.jsxs(i,{className:"bg-white/[0.08] text-white/72",children:["Energy ",a(`common.enums.energy.${s.task.energy}`)]}),e.jsxs(i,{className:"bg-white/[0.08] text-white/72",children:["Duration"," ",D(s.task.plannedDurationSeconds)]})]})]})]}),e.jsxs("div",{className:"mt-5 rounded-[20px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Action Point load"}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsxs("div",{className:"rounded-[16px] bg-white/[0.03] px-3.5 py-3",children:[e.jsx(h,{label:"Total cost"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:m?T(m.totalCostAp):"Not calibrated"})]}),e.jsxs("div",{className:"rounded-[16px] bg-white/[0.03] px-3.5 py-3",children:[e.jsx(h,{label:"Today debit"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:m?T(m.spentTodayAp):"0 AP"})]}),e.jsxs("div",{className:"rounded-[16px] bg-white/[0.03] px-3.5 py-3",children:[e.jsx(h,{label:"Sustain rate"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:m?me(m.sustainRateApPerHour):"0 AP/h"})]}),e.jsxs("div",{className:"rounded-[16px] bg-white/[0.03] px-3.5 py-3",children:[e.jsx(h,{label:"Expected duration"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:m?`${Math.round(m.expectedDurationSeconds/3600)} h`:"No target"})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[(Pe=s.task.splitSuggestion)!=null&&Pe.shouldSplit?e.jsx(i,{className:"bg-amber-400/12 text-amber-100",children:"Split it"}):null,m?e.jsxs(i,{className:"bg-white/[0.08] text-white/72",children:["Remaining ",T(m.remainingAp)]}):null,m?e.jsxs(i,{className:"bg-white/[0.08] text-white/72",children:["Spent total ",T(m.spentTotalAp)]}):null,m?e.jsx(i,{className:"bg-white/[0.08] text-white/72",children:m.costBand}):null]}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-white/58",children:"This task only debits the Action Points you actually worked today. Marking it done does not consume the full estimate by itself."})]}),e.jsxs("div",{className:"mt-5 rounded-[20px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Today's Life Force context"}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[16px] bg-white/[0.03] px-3.5 py-3",children:[e.jsx(h,{label:"Daily AP"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:I.data?`${T(I.data.spentTodayAp)} / ${T(I.data.dailyBudgetAp)}`:"Loading..."})]}),e.jsxs("div",{className:"rounded-[16px] bg-white/[0.03] px-3.5 py-3",children:[e.jsx(h,{label:"Instant headroom"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:I.data?me(I.data.instantFreeApPerHour):"Loading..."})]}),e.jsxs("div",{className:"rounded-[16px] bg-white/[0.03] px-3.5 py-3",children:[e.jsx(h,{label:"Forecast"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:I.data?`${T(I.data.forecastAp)} / ${T(I.data.dailyBudgetAp)}`:"Loading..."})]})]})]}),e.jsxs("div",{className:"mt-5 rounded-[20px] bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-white/58",children:[e.jsx("span",{children:"Current timer"}),e.jsx(We,{content:"This shows whether work is running on the task right now and how much time has been credited.",label:"Explain current timer"})]}),e.jsx("div",{className:"mt-3 text-white",children:j?`${j.timerMode==="planned"?"Planned":"Unlimited"} timer active with ${Math.floor(j.creditedSeconds/60)} credited minutes.`:"No timer is running on this task right now."})]}),e.jsxs("div",{className:"mt-5 grid gap-4 xl:grid-cols-[minmax(0,1fr)_20rem]",children:[e.jsxs("div",{className:"rounded-[20px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Task scheduling"}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[16px] bg-white/[0.03] px-3.5 py-3",children:[e.jsx(h,{label:"Rule source"}),e.jsx("div",{className:"mt-2 text-white",children:s.task.schedulingRules?"Task-specific override":"Uses project defaults"})]}),e.jsxs("div",{className:"rounded-[16px] bg-white/[0.03] px-3.5 py-3",children:[e.jsx(h,{label:"Planned duration"}),e.jsx("div",{className:"mt-2 text-white",children:s.task.plannedDurationSeconds?`${Math.round(s.task.plannedDurationSeconds/60)} min`:"No duration target"})]})]}),e.jsx("p",{className:"mt-4 text-sm leading-6 text-white/58",children:"Scheduling rules now live behind the guided modal flow instead of an inline editor. Use it to change eligible blocks, blocked contexts, and the planning duration without overcrowding the task page."}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsxs(b,{onClick:()=>pe(!0),children:[e.jsx(xe,{className:"size-4"}),"Edit task scheduling"]}),e.jsx(A,{to:"/calendar",children:e.jsx(b,{variant:"secondary",children:"Open calendar workspace"})})]})]}),e.jsxs("div",{className:"rounded-[20px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Calendar status"}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(i,{className:P.tone==="blocked"?"bg-rose-500/14 text-rose-100":P.tone==="waiting"?"bg-amber-500/14 text-amber-100":"bg-emerald-500/14 text-emerald-100",children:P.label}),e.jsx(i,{className:"bg-white/[0.08] text-white/72",children:s.task.schedulingRules?"Task override":"Using project defaults"}),s.task.plannedDurationSeconds?e.jsxs(i,{className:"bg-white/[0.08] text-white/72",children:[Math.round(s.task.plannedDurationSeconds/60)," min target"]}):null]}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-white/58",children:"Forge checks these rules before a live run starts. If the current calendar context is blocked, you can still override with an explicit reason."}),P.context.length>0?e.jsxs("div",{className:"mt-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Current context"}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:P.context.map(t=>e.jsx(i,{className:"bg-white/[0.08] text-white/72",children:t},t))})]}):null,P.conflicts.length>0?e.jsx("div",{className:"mt-4 grid gap-2",children:P.conflicts.map(t=>e.jsx("div",{className:"rounded-[16px] bg-rose-500/10 px-3 py-2 text-sm text-rose-100",children:t},t))}):null,e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:e.jsxs(b,{pending:ie.isPending||be.isPending,pendingLabel:"Planning",onClick:()=>{W(null),f(!0)},children:[e.jsx(xe,{className:"size-4"}),"Time Box"]})})]})]}),e.jsxs("div",{className:"mt-5 rounded-[20px] bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Scheduled blocks"}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-white/58",children:"Open a scheduled block to edit the day, the hour range, or the AP profile tied to this task."})]}),e.jsx(i,{className:"bg-white/[0.08] text-white/72",children:G.length})]}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[G.length===0?e.jsx("div",{className:"rounded-[18px] bg-white/[0.03] px-4 py-4 text-sm text-white/55",children:"No future timeboxes are attached to this task yet."}):null,G.map(t=>e.jsxs("div",{role:"button",tabIndex:0,onClick:()=>{W(t),f(!0)},onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),W(t),f(!0))},className:"rounded-[18px] border border-white/8 bg-[linear-gradient(180deg,rgba(26,32,49,0.86),rgba(16,21,34,0.86))] p-4 text-left transition hover:bg-[linear-gradient(180deg,rgba(30,36,54,0.92),rgba(18,23,37,0.92))]",children:[e.jsx("div",{className:"flex flex-wrap items-start justify-between gap-3",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"line-clamp-2 font-medium leading-6 text-white",children:t.title}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-sm text-white/58",children:[e.jsx(he,{className:"size-3.5 shrink-0"}),x(t.startsAt)," to"," ",x(t.endsAt)]})]})}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(i,{className:"bg-white/[0.08] text-white/72",children:t.source}),e.jsx(i,{className:"bg-white/[0.08] text-white/72",children:t.status}),e.jsx(i,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:me(Le(t).rateApPerHour)}),e.jsx(i,{className:"bg-white/[0.08] text-white/72",children:T(Le(t).totalAp)}),t.overrideReason?e.jsx(i,{className:"bg-white/[0.08] text-white/72",children:t.overrideReason}):null]}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx("span",{className:"rounded-[999px] bg-white/[0.08] px-3 py-1 text-xs text-white/72",children:"Edit in guide"}),e.jsx(A,{to:`/calendar?timeboxId=${encodeURIComponent(t.id)}`,onClick:n=>n.stopPropagation(),className:"rounded-[999px] bg-white/[0.08] px-3 py-1 text-xs text-white/72 transition hover:bg-white/[0.12]",children:"Open in calendar"})]})]},t.id))]})]}),e.jsx("div",{className:"mt-5",children:e.jsx(Lt,{entityType:"task",entityId:s.task.id,title:`${p.label} notes`,description:`Capture real progress, blockers, and context in Markdown so the ${p.noun} keeps a durable work log.`,invalidateQueryKeys:[["task-context",w.taskId],...s.task.projectId?[["project-board",s.task.projectId]]:[]]})}),e.jsxs("div",{className:"mt-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Activity"}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[s.activity.length===0?e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] p-4 text-sm text-white/55",children:"No activity has been recorded for this task yet."}):null,s.activity.map(t=>e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-white",children:Wt(t)}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:Qt(t)}),e.jsx("div",{className:"mt-3 text-[11px] uppercase tracking-[0.16em] text-white/35",children:x(t.createdAt)})]}),e.jsx(b,{variant:"ghost",className:"shrink-0",onClick:async()=>{await Je.mutateAsync(t.id)},children:"Remove"})]}),qe(t)&&ze(t)?e.jsx(A,{to:qe(t),className:"mt-3 inline-flex text-[11px] uppercase tracking-[0.16em] text-[var(--primary)]",children:ze(t)}):null]},t.id))]})]}),e.jsxs("div",{className:"mt-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Timer sessions"}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[s.taskRuns.length===0?e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] p-4 text-sm text-white/55",children:"No timer sessions have been recorded for this task yet."}):null,s.taskRuns.map(t=>{var n,r,B,q,De;return e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-white",children:t.actor}),e.jsx(i,{children:st(t.status)})]}),(n=t.gitContext)!=null&&n.branch||(r=t.gitContext)!=null&&r.pullRequestNumber?e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[(B=t.gitContext)!=null&&B.branch?e.jsxs(i,{className:"bg-sky-500/12 text-sky-100",children:[e.jsx(Me,{className:"mr-1 size-3"}),t.gitContext.branch]}):null,(q=t.gitContext)!=null&&q.pullRequestNumber?e.jsxs(i,{className:"bg-fuchsia-500/12 text-fuchsia-100",children:[e.jsx(ht,{className:"mr-1 size-3"}),"PR #",t.gitContext.pullRequestNumber]}):null,(De=t.gitContext)!=null&&De.repository?e.jsx(i,{className:"bg-white/[0.08] text-white/68",children:t.gitContext.repository}):null]}):null,e.jsx("div",{className:"mt-2 text-sm text-white/58",children:t.note||a("common.labels.noRunNote")}),e.jsx("div",{className:"mt-3 text-[11px] uppercase tracking-[0.16em] text-white/35",children:x(t.updatedAt)})]},t.id)})]})]})]}),e.jsx($t,{open:M,goals:c.snapshot.goals,projects:c.snapshot.dashboard.projects,workItems:c.snapshot.workItems,tags:c.snapshot.tags,users:c.snapshot.users,editingTask:s.task,defaultUserId:s.task.userId??C,onRefreshEntities:c.refresh,currentCreditedSeconds:s.task.time.totalCreditedSeconds,onOpenChange:R,onAdjustTrackedTime:async t=>{await ae.mutateAsync(t)},onSubmit:async(t,n)=>{n&&await _.mutateAsync({taskId:n,patch:t})}}),e.jsx(Kt,{open:K,onOpenChange:O,entityType:"task",entityId:s.task.id,targetLabel:s.task.title,currentCreditedSeconds:s.task.time.totalCreditedSeconds,pending:ae.isPending,onSubmit:async t=>{await ae.mutateAsync(t)}}),e.jsx(Rt,{open:l,onOpenChange:t=>{f(t),t||W(null)},tasks:[s.task],initialTaskId:s.task.id,lockedTaskId:s.task.id,editingTimebox:_e,from:F.from,to:F.to,userIds:u,onCreateTimebox:async t=>{await ie.mutateAsync({...t,userId:C??void 0})},onUpdateTimebox:async(t,n)=>{await be.mutateAsync({timeboxId:t,patch:{...n,userId:C??void 0}})},onDeleteTimebox:async t=>{await Xe.mutateAsync(t)}}),e.jsx(Ot,{open:U,onOpenChange:pe,tasks:[s.task],onSave:async({taskId:t,schedulingRules:n,plannedDurationSeconds:r})=>{await _.mutateAsync({taskId:t,patch:{schedulingRules:n,plannedDurationSeconds:r}}),await k.invalidateQueries({queryKey:["task-calendar-overview",w.taskId]})}}),e.jsx(Pt,{open:Qe,onOpenChange:te,eyebrow:`${p.label} status`,title:"Change status",description:`Pick the state that best matches where this ${p.noun} is right now.`,children:e.jsx("div",{className:"grid gap-3",children:Y.map(t=>{const n=t.icon,r=t.status===s.task.status;return e.jsx("button",{type:"button",disabled:r||_.isPending,className:`rounded-[22px] border px-4 py-4 text-left transition ${r?"border-[rgba(192,193,255,0.28)] bg-[rgba(192,193,255,0.14)] text-white":"border-white/8 bg-white/[0.04] text-white/72 hover:bg-white/[0.08]"}`,onClick:()=>void ye(t.status),children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(n,{className:"size-4 shrink-0 text-[var(--primary)]"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:t.label}),e.jsx("div",{className:"mt-1 text-sm text-white/54",children:t.description})]})]})},t.status)})})})]})}export{gs as TaskDetailPage};
|