forge-openclaw-plugin 0.2.111 → 0.2.113
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-BdeoV3N4.js → activity-page-DPPiiyLO.js} +1 -1
- package/dist/assets/{ai-surface-workspace-BCbQUekv.js → ai-surface-workspace-B_fV9C4s.js} +1 -1
- package/dist/assets/{atlas-panel-DTnRBOZx.js → atlas-panel-BPTJyMcI.js} +1 -1
- package/dist/assets/{calendar-page-YDexXy_e.js → calendar-page-D4DcRQv7.js} +1 -1
- package/dist/assets/{calendar-rules-B_aOcMi3.js → calendar-rules-Cl_xMrBn.js} +1 -1
- package/dist/assets/{calendar-week-toolbar-BTbIzq3e.js → calendar-week-toolbar-BARSOEO9.js} +1 -1
- package/dist/assets/{companion-sync-lab-page-DKouMut9.js → companion-sync-lab-page-COFYDI3w.js} +1 -1
- package/dist/assets/{daily-metrics-dashboard-B3UCGG1t.js → daily-metrics-dashboard-BNGQlJkQ.js} +1 -1
- package/dist/assets/{entity-note-count-link-DUxobQUt.js → entity-note-count-link-BX93WYgh.js} +1 -1
- package/dist/assets/{entity-notes-surface-BdHBn8rx.js → entity-notes-surface-CBlKc-x-.js} +1 -1
- package/dist/assets/{execution-board-R5-oyf-Z.js → execution-board-Dh41UeKR.js} +1 -1
- package/dist/assets/{faceted-token-search-DtO6OUwQ.js → faceted-token-search-BgxYH_gW.js} +1 -1
- package/dist/assets/{flagship-signal-deck-B9k46sWA.js → flagship-signal-deck-bolzzK8q.js} +1 -1
- package/dist/assets/{floating-action-menu-DBzfnJOx.js → floating-action-menu-C5H-Wr2B.js} +1 -1
- package/dist/assets/{goal-detail-page-Mr_gnZ2l.js → goal-detail-page-CQeFnGDJ.js} +1 -1
- package/dist/assets/{goals-page-BG7FuqK1.js → goals-page-BTg9crEK.js} +1 -1
- package/dist/assets/{habits-page-CGdaOqL3.js → habits-page-C4vqk346.js} +1 -1
- package/dist/assets/{index-BP9__l6C.js → index-By3tQxiE.js} +2 -2
- package/dist/assets/{insight-flow-dialog-BUv06Vn-.js → insight-flow-dialog-JPYCsTKI.js} +1 -1
- package/dist/assets/{insights-page-BgD1_1we.js → insights-page-CFhVMlVL.js} +1 -1
- package/dist/assets/{kanban-page-DvZSN-Bi.js → kanban-page-DC3IDsnh.js} +1 -1
- package/dist/assets/{knowledge-graph-page-BXWXtPvo.js → knowledge-graph-page-DucyRYTZ.js} +1 -1
- package/dist/assets/{life-force-page-CwjHvpzu.js → life-force-page-UrXfxaSO.js} +1 -1
- package/dist/assets/{life-force-workspace-Ct70SsNQ.js → life-force-workspace-BhPNH7ad.js} +1 -1
- package/dist/assets/{metric-tile-DCxLxNli.js → metric-tile-DtRPjN4V.js} +1 -1
- package/dist/assets/{movement-page-C06ebiYk.js → movement-page-DCIdTQEN.js} +1 -1
- package/dist/assets/{note-markdown-3wB52NOn.js → note-markdown-CepDxj3v.js} +1 -1
- package/dist/assets/{note-tags-input-Blg5Gqz_.js → note-tags-input-BXYaDkOr.js} +1 -1
- package/dist/assets/{notes-page-CSkjizyK.js → notes-page-Bl1LlCLo.js} +1 -1
- package/dist/assets/{open-in-graph-button-CDHxzS8B.js → open-in-graph-button-C263zl5l.js} +1 -1
- package/dist/assets/{orbit-map-OV-GcUZl.js → orbit-map-Cb_AJyIj.js} +1 -1
- package/dist/assets/{overview-page-Cw3pI34n.js → overview-page-C2yLity7.js} +1 -1
- package/dist/assets/{page-hero-DgnhI5es.js → page-hero-5RTqAI88.js} +1 -1
- package/dist/assets/{pill-cluster-DIGkIvKN.js → pill-cluster-CBrrtZBm.js} +1 -1
- package/dist/assets/{preference-entity-handoff-button-LT_GBuqB.js → preference-entity-handoff-button-BQzg2J4k.js} +1 -1
- package/dist/assets/{preferences-page-Dkvz7nkU.js → preferences-page-DekYF-Yz.js} +1 -1
- package/dist/assets/{project-collections-BsAT8WYE.js → project-collections-BVXB8PPF.js} +1 -1
- package/dist/assets/{project-detail-page-DsJUWg8k.js → project-detail-page-CQlrLEn9.js} +1 -1
- package/dist/assets/{project-management-hierarchy-page-CIy0wAp8.js → project-management-hierarchy-page--mzM_zRE.js} +1 -1
- package/dist/assets/{project-management-section-nav-ClB2S1FW.js → project-management-section-nav-DQl0qRWy.js} +1 -1
- package/dist/assets/{projects-page-Da1bZLSH.js → projects-page-Dr_0NdVP.js} +1 -1
- package/dist/assets/{psyche-behaviors-page-D0uwf78o.js → psyche-behaviors-page-DOUaCWON.js} +1 -1
- package/dist/assets/{psyche-flashcards-page-e_qwwsOf.js → psyche-flashcards-page-BA84fO_X.js} +1 -1
- package/dist/assets/{psyche-goal-map-page-BIY028Wx.js → psyche-goal-map-page-DpXAg1Vf.js} +1 -1
- package/dist/assets/{psyche-graph-Y1UKALEm.js → psyche-graph-BxcbAbXt.js} +1 -1
- package/dist/assets/{psyche-metrics-page-DDkGJzo_.js → psyche-metrics-page-D8JQEoOl.js} +1 -1
- package/dist/assets/{psyche-mode-guide-page-C7mD9uiv.js → psyche-mode-guide-page-CBlIS5N_.js} +1 -1
- package/dist/assets/{psyche-modes-page-RUdaOQWr.js → psyche-modes-page-DE6KDK_1.js} +1 -1
- package/dist/assets/{psyche-page-D3FZy__c.js → psyche-page-Dkh7R2Dc.js} +1 -1
- package/dist/assets/{psyche-patterns-page-BSD35F41.js → psyche-patterns-page-DbCNRuww.js} +1 -1
- package/dist/assets/{psyche-questionnaire-builder-page-BpgUTMgj.js → psyche-questionnaire-builder-page-DnraDj1H.js} +1 -1
- package/dist/assets/{psyche-questionnaire-detail-page-DwjyjNhg.js → psyche-questionnaire-detail-page-DQ6zNQkk.js} +1 -1
- package/dist/assets/{psyche-questionnaire-run-detail-page-mJ-DgeB-.js → psyche-questionnaire-run-detail-page-BGrOIX0B.js} +1 -1
- package/dist/assets/{psyche-questionnaire-run-page-YuMBkH1G.js → psyche-questionnaire-run-page-Bg3BhBHb.js} +1 -1
- package/dist/assets/{psyche-questionnaires-page-CNglToKh.js → psyche-questionnaires-page-BEreTNjG.js} +1 -1
- package/dist/assets/{psyche-report-detail-page-CV6tbLxz.js → psyche-report-detail-page-Br9KlJBG.js} +1 -1
- package/dist/assets/{psyche-reports-page-BEOe8OPA.js → psyche-reports-page-Bk6QpAEF.js} +1 -1
- package/dist/assets/{psyche-schemas-beliefs-page-KIRqmO8C.js → psyche-schemas-beliefs-page-Db8d2ga7.js} +1 -1
- package/dist/assets/{psyche-screen-time-page-DvXuwgU1.js → psyche-screen-time-page-NazHUAkT.js} +1 -1
- package/dist/assets/{psyche-self-observation-page-E6yDPBm1.js → psyche-self-observation-page-H6FToucM.js} +1 -1
- package/dist/assets/{psyche-values-page-CSLG7C6a.js → psyche-values-page-DqM382-6.js} +1 -1
- package/dist/assets/{report-chain-fields-BYEp3tRr.js → report-chain-fields-nW4zndrM.js} +1 -1
- package/dist/assets/{rewards-page-pAa_MIte.js → rewards-page-C-tZVnIK.js} +1 -1
- package/dist/assets/{scheduling-rules-editor-BmGrjC9q.js → scheduling-rules-editor-DGF-044c.js} +1 -1
- package/dist/assets/{schema-badge-IVJ4SoeC.js → schema-badge-57AJ3FY-.js} +1 -1
- package/dist/assets/{select-menu-BE5AIdgO.js → select-menu-mfaklv7r.js} +1 -1
- package/dist/assets/{settings-agents-page-hqI0IaNx.js → settings-agents-page-CPJeeYg0.js} +1 -1
- package/dist/assets/{settings-bin-page-2bPjFtZ3.js → settings-bin-page-D3eX5aNf.js} +1 -1
- package/dist/assets/{settings-calendar-page-u_TfZJEh.js → settings-calendar-page-Bgx8NIsP.js} +1 -1
- package/dist/assets/{settings-data-page-DSQ14F2i.js → settings-data-page-BuMSUjpp.js} +1 -1
- package/dist/assets/{settings-logs-page-BU0CJhDM.js → settings-logs-page-CHb2GNUM.js} +1 -1
- package/dist/assets/{settings-mobile-page-B1fQ61BB.js → settings-mobile-page-ClUvXhJg.js} +1 -1
- package/dist/assets/{settings-models-page-B0Dis_c_.js → settings-models-page-njK6D7zc.js} +1 -1
- package/dist/assets/{settings-page-V4ibXIp9.js → settings-page-Dm--cx6B.js} +1 -1
- package/dist/assets/{settings-rewards-page-DeCGBNn5.js → settings-rewards-page-3aShLM3A.js} +1 -1
- package/dist/assets/{settings-section-nav-DV5umEkp.js → settings-section-nav-BWox23Qv.js} +1 -1
- package/dist/assets/{settings-users-page-BB8Dzd_P.js → settings-users-page-D-hEPpgQ.js} +1 -1
- package/dist/assets/{settings-wiki-page-B0k0KRsU.js → settings-wiki-page-CC-rOtDm.js} +1 -1
- package/dist/assets/{sleep-page-CPwUb-em.js → sleep-page-Cm_Ei2w1.js} +1 -1
- package/dist/assets/{sports-page-Cl4vZVwh.js → sports-page-CqSI-j-H.js} +1 -1
- package/dist/assets/{strategies-page-DhFXf-g3.js → strategies-page-BuJ4zLLv.js} +1 -1
- package/dist/assets/{strategy-detail-page-B2gotRKI.js → strategy-detail-page-CLmy0jbW.js} +1 -1
- package/dist/assets/{strategy-dialog-DD1bbrRB.js → strategy-dialog-DnJix1ys.js} +1 -1
- package/dist/assets/{surface-98myBzix.js → surface-DRNu5Fpz.js} +1 -1
- package/dist/assets/{task-detail-page-nx4eQbMW.js → task-detail-page-DTnNjW33.js} +1 -1
- package/dist/assets/{timebox-planning-dialog-DoZ9zUra.js → timebox-planning-dialog-DckIr1K4.js} +1 -1
- package/dist/assets/{today-page-7BH7Yne1.js → today-page-Cgk4HBPK.js} +1 -1
- package/dist/assets/{training-load-page-E82pNn1-.js → training-load-page-C-7iINaB.js} +1 -1
- package/dist/assets/{vitals-page-D64WlwVv.js → vitals-page-CqE4bYMf.js} +1 -1
- package/dist/assets/{weekly-review-page-BkRxxm7Q.js → weekly-review-page-DFmuzzig.js} +1 -1
- package/dist/assets/{weight-loss-page-DPbg7rTC.js → weight-loss-page-CWtgeuti.js} +3 -3
- package/dist/assets/{wiki-article-markdown-B0Q6082A.js → wiki-article-markdown-BkQg8Hne.js} +1 -1
- package/dist/assets/{wiki-editor-page-Tkb50wEA.js → wiki-editor-page-BYKcdX5I.js} +1 -1
- package/dist/assets/{wiki-ingest-history-page-CcQzkZRr.js → wiki-ingest-history-page-D_p4myw1.js} +1 -1
- package/dist/assets/{wiki-ingest-modal-D6yft0Qb.js → wiki-ingest-modal-C-CidueO.js} +1 -1
- package/dist/assets/{wiki-page-DEND1jmD.js → wiki-page-DYpg9ZEO.js} +1 -1
- package/dist/assets/{workbench-flow-page-CkNI03j_.js → workbench-flow-page-Q3r2IJty.js} +1 -1
- package/dist/assets/{workbench-page-W3zQpeWr.js → workbench-page-BFfWMGm6.js} +1 -1
- package/dist/assets/{workout-detail-page-BVSZv53z.js → workout-detail-page-DeDyz1Kk.js} +1 -1
- package/dist/companion-iroh/win32-x64/forge-companion-iroh.exe +0 -0
- package/dist/index.html +1 -1
- package/dist/server/server/src/health-weight-loss.js +30 -11
- package/dist/server/server/src/services/companion-iroh.js +19 -12
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/dist/assets/{timebox-planning-dialog-DoZ9zUra.js → timebox-planning-dialog-DckIr1K4.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as j,j as e,aG as Ie}from"./vendor-Dnkkx2co.js";import{S as Re}from"./scheduling-rules-editor-BmGrjC9q.js";import{aT as _e,C as ye,B as Y,K as ae,k as q,F as y,c as h,h as z,I as C,j as Ee,d as se,Q as Le,cJ as Me,N as Fe}from"./index-BP9__l6C.js";import{i as je}from"./state-vCcAT5Hq.js";import{f as $e}from"./calendar-ui-Cy1XRwzV.js";function ze({open:s,onOpenChange:o,tasks:m,onSave:v}){const c=j.useMemo(()=>m.filter(f=>f.status!=="done"),[m]),[I,k]=j.useState("");j.useEffect(()=>{if(s){if(c.length===0){k("");return}k(f=>f&&c.some(g=>g.id===f)?f:c[0].id)}},[c,s]);const N=c.find(f=>f.id===I)??null;return e.jsx(_e,{open:s,onOpenChange:o,eyebrow:"Calendar",title:"Adjust task scheduling rules",description:"Choose a task, then tell Forge which work blocks, calendar conditions, or keywords should allow or block that work.",children:e.jsxs("div",{className:"grid min-w-0 gap-4",children:[e.jsx(ye,{className:"min-w-0 overflow-hidden rounded-[28px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-1)]",children:e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx("div",{className:"rounded-[18px] bg-[var(--primary)]/14 p-3 text-[var(--primary)]",children:e.jsx(Ie,{className:"size-4"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:"Guided rule editing"}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Use this when a task should only run in certain blocks such as Secondary Activity, or should stay blocked during clinic, rest, or other provider events."})]})]})}),c.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"grid min-w-0 gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Task"}),e.jsx("select",{value:I,onChange:f=>k(f.target.value),className:"w-full min-w-0 max-w-full rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3 text-[15px] text-[var(--ui-ink-strong)] outline-none transition focus:border-[var(--ui-border-strong)] focus:ring-2 focus:ring-[var(--primary)]/20",children:c.map(f=>e.jsx("option",{value:f.id,children:f.title},f.id))})]}),N?e.jsx(Re,{title:"Task rules",subtitle:"These rules are saved directly on the task. They drive blocked-now checks and future timebox recommendations.",initialRules:N.schedulingRules,initialPlannedDurationSeconds:N.plannedDurationSeconds,allowPlannedDuration:!0,saveLabel:"Save task rules",onSave:async({schedulingRules:f,plannedDurationSeconds:g})=>{await v({taskId:N.id,schedulingRules:f,plannedDurationSeconds:g===void 0?N.plannedDurationSeconds:g??null}),o(!1)}}):null]}):e.jsxs(ye,{className:"min-w-0 overflow-hidden rounded-[28px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-1)]",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:"No schedulable tasks yet"}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Create or reopen a task first, then come back here to define work-block and calendar eligibility."}),e.jsx("div",{className:"mt-4",children:e.jsx(Y,{variant:"secondary",onClick:()=>o(!1),children:"Close"})})]})]})})}function E(s){return s.slice(0,10)}function Ke(s){return new Date(`${s}T00:00:00`).toISOString()}function He(s){return new Date(`${s}T23:59:59.999`).toISOString()}function re(s,o,m){return s<o?o:s>m?m:s}function we(s,o){const m=E(s),v=E(o),c=new Date(`${m}T12:00:00`);return c.setDate(c.getDate()+1),re(E(c.toISOString()),m,v)}function be(s){return String(s).padStart(2,"0")}function G(s){return`${be(s.getHours())}:${be(s.getMinutes())}`}function ke(s,o){if(!s||!o)return null;const m=new Date(`${s}T${o}:00`);return Number.isNaN(m.getTime())?null:m}function U(s,o,m){if(m){const k=new Date(m.startsAt),N=new Date(m.endsAt);return{startTime:G(k),endTime:G(N)}}const v=new Date(`${s}T09:00:00`),c=Math.max(1800,Math.min(o??3600,360*60)),I=new Date(v.getTime()+c*1e3);return{startTime:G(v),endTime:G(I)}}function Ne(s,o){return`${new Date(s).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})} - ${new Date(o).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`}function J(s,o){return`${$e(new Date(s))} · ${Ne(s,o)}`}const Se="rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]",ne="rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]",p="bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)]",ee="rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3 text-[15px] text-[var(--ui-ink-strong)] outline-none transition focus:border-[var(--ui-border-strong)] focus:ring-2 focus:ring-[var(--primary)]/20";function te({title:s,subtitle:o,emptyLabel:m,children:v}){const c=Array.isArray(v)?v:v?[v]:[];return e.jsxs("div",{className:`${Se} p-4`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:s}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:o})]}),e.jsx(h,{className:p,children:c.length})]}),e.jsx("div",{className:"mt-3 grid gap-2",children:c.length>0?c:e.jsx("div",{className:"rounded-[18px] border border-dashed border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-3 text-sm text-[var(--ui-ink-muted)]",children:m})})]})}function Be({event:s}){return e.jsxs("div",{className:`${ne} px-3 py-3`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:s.title}),e.jsx(h,{className:p,children:s.availability})]}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:J(s.startAt,s.endAt)})]})}function Oe({block:s}){return e.jsxs("div",{className:`${ne} px-3 py-3`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:s.title}),e.jsx(h,{className:p,children:s.blockingState})]}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:J(s.startAt,s.endAt)})]})}function We({timebox:s}){const o=ae(s);return e.jsxs("div",{className:`${ne} px-3 py-3`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:s.title}),e.jsx(h,{className:p,children:s.source})]}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:J(s.startsAt,s.endsAt)}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-2",children:[e.jsx(h,{className:p,children:se(o.rateApPerHour)}),e.jsx(h,{className:p,children:z(o.totalAp)})]})]})}function Je({open:s,onOpenChange:o,tasks:m,from:v,to:c,onCreateTimebox:I,onUpdateTimebox:k,onDeleteTimebox:N,initialTaskId:f,lockedTaskId:g,editingTimebox:t,userIds:le}){var he,pe,fe,ve,ge,xe;const L=!!t,w=j.useMemo(()=>{const a=g??(t==null?void 0:t.taskId)??null,d=m.filter(u=>u.status!=="done"||u.id===a);if(!a)return d;const r=d.find(u=>u.id===a);return r?[r]:[]},[t==null?void 0:t.taskId,g,m]),M=E(v),F=E(c),ie=t?re(E(t.startsAt),M,F):we(v,c),oe=g??(t==null?void 0:t.taskId)??f??((he=w[0])==null?void 0:he.id)??"",$=w.find(a=>a.id===oe)??w[0]??null,de=U(ie,$==null?void 0:$.plannedDurationSeconds,t?{startsAt:t.startsAt,endsAt:t.endsAt}:null),[i,O]=j.useState({taskId:oe,preferredDate:ie,plannerMode:t?"manual":"suggested",selectedTimeboxId:"",activityPresetKey:((pe=t==null?void 0:t.actionProfile)==null?void 0:pe.profileKey)??"task_inherited",customSustainRateApPerHour:((fe=t==null?void 0:t.actionProfile)==null?void 0:fe.sourceMethod)==="manual"?t.actionProfile.sustainRateApPerHour:null,manualStartTime:de.startTime,manualEndTime:de.endTime,manualTitle:(t==null?void 0:t.title)??($==null?void 0:$.title)??"",overrideReason:(t==null?void 0:t.overrideReason)??""}),[Ae,b]=j.useState(null),[Pe,W]=j.useState(!1),[De,ce]=j.useState(!1);j.useEffect(()=>{var _,H,B;if(!s)return;const a=g??f??((_=w[0])==null?void 0:_.id)??"",d=(t==null?void 0:t.taskId)??a,r=w.find(x=>x.id===d)??w[0]??null,u=t?re(E(t.startsAt),M,F):we(v,c),n=U(u,r==null?void 0:r.plannedDurationSeconds,t?{startsAt:t.startsAt,endsAt:t.endsAt}:null);b(null),O({taskId:d,preferredDate:u,plannerMode:t?"manual":"suggested",selectedTimeboxId:"",activityPresetKey:((H=t==null?void 0:t.actionProfile)==null?void 0:H.profileKey)??"task_inherited",customSustainRateApPerHour:((B=t==null?void 0:t.actionProfile)==null?void 0:B.sourceMethod)==="manual"?t.actionProfile.sustainRateApPerHour:null,manualStartTime:n.startTime,manualEndTime:n.endTime,manualTitle:(t==null?void 0:t.title)??(r==null?void 0:r.title)??"",overrideReason:(t==null?void 0:t.overrideReason)??""})},[w,t,v,f,g,F,M,s,c]);const l=w.find(a=>a.id===i.taskId)??null,P=j.useMemo(()=>({from:Ke(i.preferredDate),to:He(i.preferredDate)}),[i.preferredDate]),D=je({queryKey:["forge-calendar-suggestions-dialog",i.taskId,P.from,P.to],queryFn:()=>Me({taskId:i.taskId,from:P.from,to:P.to,limit:8}),enabled:s&&i.taskId.length>0}),X=je({queryKey:["forge-calendar-timebox-dialog-day",P.from,P.to,...le??[]],queryFn:()=>Fe({from:P.from,to:P.to,userIds:le}),enabled:s});j.useEffect(()=>{var d;if(!s)return;const a=((d=D.data)==null?void 0:d.timeboxes)??[];if(!a.length){O(r=>r.selectedTimeboxId?{...r,selectedTimeboxId:""}:r);return}O(r=>r.selectedTimeboxId&&a.some(u=>u.id===r.selectedTimeboxId)?r:{...r,selectedTimeboxId:a[0].id})},[s,D.data]);const A=(ve=X.data)==null?void 0:ve.calendar,Z=(A==null?void 0:A.events)??[],V=(A==null?void 0:A.workBlockInstances)??[],T=(A==null?void 0:A.timeboxes)??[],K=(((ge=D.data)==null?void 0:ge.timeboxes)??[]).find(a=>a.id===i.selectedTimeboxId),S=ke(i.preferredDate,i.manualStartTime),R=ke(i.preferredDate,i.manualEndTime),Q=S&&R?ae({startsAt:S.toISOString(),endsAt:R.toISOString(),actionProfile:i.customSustainRateApPerHour!==null||i.activityPresetKey!=="task_inherited"?{id:"manual-preview",profileKey:"manual-preview",title:i.manualTitle||(l==null?void 0:l.title)||"Manual timebox",entityType:"task_timebox",mode:"container",startupAp:0,totalCostAp:0,expectedDurationSeconds:null,sustainRateApPerHour:i.customSustainRateApPerHour??((xe=q().find(a=>a.key===i.activityPresetKey))==null?void 0:xe.defaultRateApPerHour)??100/24,demandWeights:{activation:.1,focus:.3,vigor:.1,composure:.1,flow:.4},doubleCountPolicy:"container_only",sourceMethod:"manual",costBand:"light",recoveryEffect:0,metadata:{},createdAt:S.toISOString(),updatedAt:S.toISOString()}:null}):null,ue=L?"Review the task tied to this scheduled block":g?"Review the task you are planning":"Choose the task you want to place into the calendar",me=L?"The timebox stays linked to this task. Update the day, hours, title, or AP profile without leaving the planning flow.":g?"Forge will use this task's current duration target and scheduling rules while it looks for viable slots.":"Forge will use the task's current planned duration and scheduling rules when it searches for valid slots.",Ce=j.useMemo(()=>[{id:"task",eyebrow:"Planning",title:ue,description:me,render:(a,d)=>e.jsxs("div",{className:"grid min-w-0 max-w-full gap-4 overflow-hidden",children:[g?null:e.jsx(y,{label:"Task",children:e.jsx("select",{value:a.taskId,onChange:r=>(()=>{const u=w.find(_=>_.id===r.target.value),n=U(a.preferredDate,u==null?void 0:u.plannedDurationSeconds);d({taskId:r.target.value,selectedTimeboxId:"",activityPresetKey:"task_inherited",customSustainRateApPerHour:null,manualStartTime:n.startTime,manualEndTime:n.endTime,manualTitle:(u==null?void 0:u.title)??a.manualTitle})})(),className:ee,children:w.map(r=>e.jsx("option",{value:r.id,children:r.title},r.id))})}),l?e.jsxs("div",{className:"min-w-0 max-w-full overflow-hidden rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5 shadow-[var(--ui-shadow-soft)]",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Time Box"}),e.jsx("div",{className:"mt-2 break-words font-display text-[1.4rem] leading-tight text-[var(--ui-ink-strong)]",children:l.title})]}),e.jsx(h,{className:p,children:l.status})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(h,{className:p,children:l.plannedDurationSeconds?`${Math.round(l.plannedDurationSeconds/60)} min target`:"No duration yet"}),e.jsx(h,{className:p,children:l.schedulingRules?"Task-specific rules":"Uses project rules"}),e.jsxs(h,{className:p,children:[l.points," xp"]}),l.plannedDurationSeconds?e.jsxs(h,{className:p,children:[z(l.plannedDurationSeconds/3600/24*100)," ","target load"]}):null]}),e.jsx("p",{className:"mt-4 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Pick a day first, then either accept one of Forge's suggested slots or set the block manually."}),L&&t&&N?e.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-3 rounded-[20px] border border-[color-mix(in_srgb,var(--danger)_24%,var(--ui-border-subtle)_76%)] bg-[var(--ui-danger-soft)] px-4 py-3",children:[e.jsx("div",{className:"text-sm leading-6 text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",children:"Remove this planned timebox if you no longer want it in the calendar."}),e.jsx(Y,{type:"button",variant:"ghost",className:"text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)] hover:bg-[var(--ui-danger-soft)]",pending:De,pendingLabel:"Deleting",onClick:()=>void(async()=>{b(null),ce(!0);try{await N(t.id),o(!1)}catch(r){b(r instanceof Error?r.message:"Forge could not delete this timebox.")}finally{ce(!1)}})(),children:"Delete timebox"})]}):null]}):null]})},{id:"day",eyebrow:"Calendar",title:"Choose the day and review what is already there",description:"Forge reads the real day first so the timebox stays grounded in your provider events, work blocks, and already-planned work.",render:(a,d)=>e.jsx("div",{className:"grid gap-5",children:e.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,16rem)_minmax(0,1fr)]",children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsx(y,{label:"Date",description:"Choose the day you want to protect for this task.",children:e.jsx(C,{type:"date",min:M,max:F,value:a.preferredDate,onChange:r=>{const u=U(r.target.value,l==null?void 0:l.plannedDurationSeconds,t?{startsAt:`${r.target.value}T${a.manualStartTime}:00`,endsAt:`${r.target.value}T${a.manualEndTime}:00`}:null);d({preferredDate:r.target.value,selectedTimeboxId:"",manualStartTime:u.startTime,manualEndTime:u.endTime})}})}),e.jsx(y,{label:"Planning style",description:"Take Forge's slot recommendation when it fits, or set the block yourself.",children:e.jsx(Ee,{value:a.plannerMode,onChange:r=>d({plannerMode:r}),options:[{value:"suggested",label:"Use suggestions",description:"Forge proposes slots that fit the task rules and the selected day."},{value:"manual",label:"Set it manually",description:"You choose the exact start and end time yourself."}]})})]}),e.jsxs("div",{className:"rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Selected day"}),e.jsx("div",{className:"mt-2 font-display text-[1.3rem] leading-tight text-[var(--ui-ink-strong)]",children:a.preferredDate?new Date(`${a.preferredDate}T12:00:00`).toLocaleDateString([],{weekday:"long",month:"long",day:"numeric"}):"Choose a day"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(h,{className:p,children:[Z.length," events"]}),e.jsxs(h,{className:p,children:[V.length," work blocks"]}),e.jsxs(h,{className:p,children:[T.length," timeboxes"]})]})]}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"This is the context Forge will use while recommending a slot. You can still place the block manually if you want something more exact."}),X.isLoading?e.jsx("div",{className:"mt-4 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-4 text-sm text-[var(--ui-ink-soft)]",children:"Loading the selected day…"}):e.jsxs("div",{className:"mt-4 grid gap-4 xl:grid-cols-3",children:[e.jsx(te,{title:"Provider events",subtitle:"Busy or free events already on the day.",emptyLabel:"No mirrored events on this day.",children:Z.slice(0,4).map(r=>e.jsx(Be,{event:r},r.id))}),e.jsx(te,{title:"Work blocks",subtitle:"Recurring allowed or blocked containers.",emptyLabel:"No work blocks land on this day.",children:V.slice(0,4).map(r=>e.jsx(Oe,{block:r},r.id))}),e.jsx(te,{title:"Planned timeboxes",subtitle:"Existing owned work already placed there.",emptyLabel:"No other planned timeboxes yet.",children:T.slice(0,4).map(r=>e.jsx(We,{timebox:r},r.id))})]})]})]})})},{id:"slot",eyebrow:i.plannerMode==="suggested"?"Suggestion":"Manual",title:i.plannerMode==="suggested"?"Choose one of Forge's suggested slots":"Set the exact timebox yourself",description:i.plannerMode==="suggested"?"Forge proposes slots that fit the selected day, the task rules, and the current calendar picture.":"Use manual mode when the right block is obvious to you or when you want to place the timebox despite imperfect recommendations.",render:(a,d)=>{var u;if(a.plannerMode==="manual")return e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(y,{label:"Day",description:"Pick the day for the block. Forge defaults to a future day, but you can move it.",children:e.jsx(C,{type:"date",min:M,max:F,value:a.preferredDate,onChange:n=>d({preferredDate:n.target.value})})}),e.jsx(y,{label:"Start time",description:"Choose when the protected work block should begin.",children:e.jsx(C,{type:"time",step:300,value:a.manualStartTime,onChange:n=>d({manualStartTime:n.target.value})})}),e.jsx(y,{label:"End time",description:"Choose when the work block should end.",children:e.jsx(C,{type:"time",step:300,value:a.manualEndTime,onChange:n=>d({manualEndTime:n.target.value})})})]}),e.jsx(y,{label:"Title",description:"By default Forge uses the task title. Tighten it only if a shorter calendar label would help.",children:e.jsx(C,{value:a.manualTitle,onChange:n=>d({manualTitle:n.target.value}),placeholder:(l==null?void 0:l.title)??"Task timebox"})}),e.jsx(y,{label:"Override reason",description:"Optional. Add a short reason only if you are intentionally placing the block despite the normal rules or calendar shape.",children:e.jsx(C,{value:a.overrideReason,onChange:n=>d({overrideReason:n.target.value}),placeholder:"Protected writing block before clinic."})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(y,{label:"Activity profile",children:e.jsx("select",{value:a.activityPresetKey??"task_inherited",onChange:n=>d({activityPresetKey:n.target.value}),className:ee,children:q().map(n=>e.jsx("option",{value:n.key,children:n.label},n.key))})}),e.jsx(y,{label:"Custom AP per hour",children:e.jsx(C,{type:"number",min:0,step:.5,value:a.customSustainRateApPerHour??"",onChange:n=>d({customSustainRateApPerHour:n.target.value.trim()===""?null:Number(n.target.value)}),placeholder:"Leave empty to use the activity profile"})})]}),e.jsxs("div",{className:`${Se} p-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-medium text-[var(--ui-ink-strong)]",children:a.manualTitle||(l==null?void 0:l.title)||"Manual timebox"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:S&&R?`${S.toLocaleDateString([],{weekday:"long",month:"short",day:"numeric"})} · ${Ne(S.toISOString(),R.toISOString())}`:"Choose a start and end time."})]}),e.jsx(h,{className:p,children:"manual"})]}),Q?e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(h,{className:p,children:se(Q.rateApPerHour)}),e.jsx(h,{className:p,children:z(Q.totalAp)})]}):null]})]});const r=((u=D.data)==null?void 0:u.timeboxes)??[];return D.isLoading?e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Looking for valid slots on the selected day…"}):r.length?e.jsx("div",{className:"grid gap-3",children:r.map(n=>{var B;const _=a.selectedTimeboxId===n.id,H=ae({...n,actionProfile:a.customSustainRateApPerHour!==null||a.activityPresetKey!=="task_inherited"?{id:"suggested-preview",profileKey:"suggested-preview",title:n.title,entityType:"task_timebox",mode:"container",startupAp:0,totalCostAp:0,expectedDurationSeconds:null,sustainRateApPerHour:a.customSustainRateApPerHour??((B=q().find(x=>x.key===a.activityPresetKey))==null?void 0:B.defaultRateApPerHour)??100/24,demandWeights:{activation:.1,focus:.3,vigor:.1,composure:.1,flow:.4},doubleCountPolicy:"container_only",sourceMethod:"manual",costBand:"light",recoveryEffect:0,metadata:{},createdAt:n.startsAt,updatedAt:n.startsAt}:null});return e.jsxs("button",{type:"button",onClick:()=>d({selectedTimeboxId:n.id}),className:`rounded-[24px] border px-4 py-4 text-left transition ${_?"border-[color-mix(in_srgb,var(--primary)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)] shadow-[var(--ui-shadow-soft)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)] hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]"}`,children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium",children:n.title}),e.jsx(h,{className:p,children:n.source})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:J(n.startsAt,n.endsAt)}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(h,{className:p,children:se(H.rateApPerHour)}),e.jsx(h,{className:p,children:z(H.totalAp)})]}),_?e.jsxs("div",{className:"mt-4 grid gap-4 md:grid-cols-2",children:[e.jsx(y,{label:"Activity profile",children:e.jsx("select",{value:a.activityPresetKey??"task_inherited",onChange:x=>d({activityPresetKey:x.target.value}),className:ee,children:q().map(x=>e.jsx("option",{value:x.key,children:x.label},x.key))})}),e.jsx(y,{label:"Custom AP per hour",children:e.jsx(C,{type:"number",min:0,step:.5,value:a.customSustainRateApPerHour??"",onChange:x=>d({customSustainRateApPerHour:x.target.value.trim()===""?null:Number(x.target.value)}),placeholder:"Leave empty to use the activity profile"})})]}):null]},n.id)})}):e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"rounded-[24px] border border-[color-mix(in_srgb,var(--warning)_24%,var(--ui-border-subtle)_76%)] bg-[var(--ui-warning-soft)] px-4 py-4 text-sm leading-6 text-[color-mix(in_srgb,var(--warning)_72%,var(--ui-ink-strong)_28%)]",children:"Forge could not find a valid slot on this day. Try another day, adjust the task rules, or switch to manual placement if you already know the right block."}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(Y,{variant:"secondary",onClick:()=>void D.refetch(),children:"Refresh suggestions"}),e.jsx(Y,{variant:"secondary",onClick:()=>d({plannerMode:"manual"}),children:"Switch to manual"})]})]})}}],[w,X.isLoading,V,Z,T,i.plannerMode,t,v,g,F,Q,M,l,D.data,D.isLoading,me,ue,c]);return e.jsx(Le,{open:s,onOpenChange:o,eyebrow:"Calendar",title:L?"Edit timebox":"Plan work",description:L?"Update the day, hour range, title, and AP profile for this scheduled block without leaving the task or calendar view.":"Review the day, let Forge recommend valid slots, and place a real timebox on the task without leaving the detail view.",value:i,onChange:O,draftPersistenceKey:t?`calendar.timebox.${t.id}`:`calendar.timebox.new.${(l==null?void 0:l.id)??"unscoped"}`,steps:Ce,submitLabel:L?"Save timebox":"Schedule timebox",pending:Pe,pendingLabel:"Scheduling",error:Ae,contentClassName:"md:w-[min(70rem,calc(100vw-1.5rem))]",onSubmit:async()=>{if(!l){b("Choose a task before scheduling a timebox.");return}if(i.plannerMode==="manual"){if(!S||!R){b("Choose a valid manual start and end time.");return}if(R<=S){b("The manual timebox needs an end time after the start time.");return}b(null),W(!0);try{const a={title:i.manualTitle.trim()||l.title,startsAt:S.toISOString(),endsAt:R.toISOString(),overrideReason:i.overrideReason.trim()||null,activityPresetKey:i.activityPresetKey,customSustainRateApPerHour:i.customSustainRateApPerHour};t&&k?await k(t.id,a):await I({taskId:l.id,projectId:l.projectId,...a,source:"manual"}),o(!1)}catch(a){b(a instanceof Error?a.message:"Forge could not create the manual timebox.")}finally{W(!1)}return}if(!K){b("Pick one suggested slot before scheduling the timebox.");return}b(null),W(!0);try{const a={title:K.title,startsAt:K.startsAt,endsAt:K.endsAt,activityPresetKey:i.activityPresetKey,customSustainRateApPerHour:i.customSustainRateApPerHour};t&&k?await k(t.id,a):await I({taskId:l.id,projectId:l.projectId,...a,source:K.source}),o(!1)}catch(a){b(a instanceof Error?a.message:"Forge could not create the selected timebox.")}finally{W(!1)}}})}export{ze as T,Je as a};
|
|
1
|
+
import{r as j,j as e,aG as Ie}from"./vendor-Dnkkx2co.js";import{S as Re}from"./scheduling-rules-editor-DGF-044c.js";import{aT as _e,C as ye,B as Y,K as ae,k as q,F as y,c as h,h as z,I as C,j as Ee,d as se,Q as Le,cJ as Me,N as Fe}from"./index-By3tQxiE.js";import{i as je}from"./state-vCcAT5Hq.js";import{f as $e}from"./calendar-ui-Cy1XRwzV.js";function ze({open:s,onOpenChange:o,tasks:m,onSave:v}){const c=j.useMemo(()=>m.filter(f=>f.status!=="done"),[m]),[I,k]=j.useState("");j.useEffect(()=>{if(s){if(c.length===0){k("");return}k(f=>f&&c.some(g=>g.id===f)?f:c[0].id)}},[c,s]);const N=c.find(f=>f.id===I)??null;return e.jsx(_e,{open:s,onOpenChange:o,eyebrow:"Calendar",title:"Adjust task scheduling rules",description:"Choose a task, then tell Forge which work blocks, calendar conditions, or keywords should allow or block that work.",children:e.jsxs("div",{className:"grid min-w-0 gap-4",children:[e.jsx(ye,{className:"min-w-0 overflow-hidden rounded-[28px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-1)]",children:e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx("div",{className:"rounded-[18px] bg-[var(--primary)]/14 p-3 text-[var(--primary)]",children:e.jsx(Ie,{className:"size-4"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:"Guided rule editing"}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Use this when a task should only run in certain blocks such as Secondary Activity, or should stay blocked during clinic, rest, or other provider events."})]})]})}),c.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"grid min-w-0 gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Task"}),e.jsx("select",{value:I,onChange:f=>k(f.target.value),className:"w-full min-w-0 max-w-full rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3 text-[15px] text-[var(--ui-ink-strong)] outline-none transition focus:border-[var(--ui-border-strong)] focus:ring-2 focus:ring-[var(--primary)]/20",children:c.map(f=>e.jsx("option",{value:f.id,children:f.title},f.id))})]}),N?e.jsx(Re,{title:"Task rules",subtitle:"These rules are saved directly on the task. They drive blocked-now checks and future timebox recommendations.",initialRules:N.schedulingRules,initialPlannedDurationSeconds:N.plannedDurationSeconds,allowPlannedDuration:!0,saveLabel:"Save task rules",onSave:async({schedulingRules:f,plannedDurationSeconds:g})=>{await v({taskId:N.id,schedulingRules:f,plannedDurationSeconds:g===void 0?N.plannedDurationSeconds:g??null}),o(!1)}}):null]}):e.jsxs(ye,{className:"min-w-0 overflow-hidden rounded-[28px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-1)]",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:"No schedulable tasks yet"}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Create or reopen a task first, then come back here to define work-block and calendar eligibility."}),e.jsx("div",{className:"mt-4",children:e.jsx(Y,{variant:"secondary",onClick:()=>o(!1),children:"Close"})})]})]})})}function E(s){return s.slice(0,10)}function Ke(s){return new Date(`${s}T00:00:00`).toISOString()}function He(s){return new Date(`${s}T23:59:59.999`).toISOString()}function re(s,o,m){return s<o?o:s>m?m:s}function we(s,o){const m=E(s),v=E(o),c=new Date(`${m}T12:00:00`);return c.setDate(c.getDate()+1),re(E(c.toISOString()),m,v)}function be(s){return String(s).padStart(2,"0")}function G(s){return`${be(s.getHours())}:${be(s.getMinutes())}`}function ke(s,o){if(!s||!o)return null;const m=new Date(`${s}T${o}:00`);return Number.isNaN(m.getTime())?null:m}function U(s,o,m){if(m){const k=new Date(m.startsAt),N=new Date(m.endsAt);return{startTime:G(k),endTime:G(N)}}const v=new Date(`${s}T09:00:00`),c=Math.max(1800,Math.min(o??3600,360*60)),I=new Date(v.getTime()+c*1e3);return{startTime:G(v),endTime:G(I)}}function Ne(s,o){return`${new Date(s).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})} - ${new Date(o).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`}function J(s,o){return`${$e(new Date(s))} · ${Ne(s,o)}`}const Se="rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]",ne="rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]",p="bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)]",ee="rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3 text-[15px] text-[var(--ui-ink-strong)] outline-none transition focus:border-[var(--ui-border-strong)] focus:ring-2 focus:ring-[var(--primary)]/20";function te({title:s,subtitle:o,emptyLabel:m,children:v}){const c=Array.isArray(v)?v:v?[v]:[];return e.jsxs("div",{className:`${Se} p-4`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:s}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:o})]}),e.jsx(h,{className:p,children:c.length})]}),e.jsx("div",{className:"mt-3 grid gap-2",children:c.length>0?c:e.jsx("div",{className:"rounded-[18px] border border-dashed border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-3 text-sm text-[var(--ui-ink-muted)]",children:m})})]})}function Be({event:s}){return e.jsxs("div",{className:`${ne} px-3 py-3`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:s.title}),e.jsx(h,{className:p,children:s.availability})]}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:J(s.startAt,s.endAt)})]})}function Oe({block:s}){return e.jsxs("div",{className:`${ne} px-3 py-3`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:s.title}),e.jsx(h,{className:p,children:s.blockingState})]}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:J(s.startAt,s.endAt)})]})}function We({timebox:s}){const o=ae(s);return e.jsxs("div",{className:`${ne} px-3 py-3`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:s.title}),e.jsx(h,{className:p,children:s.source})]}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:J(s.startsAt,s.endsAt)}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-2",children:[e.jsx(h,{className:p,children:se(o.rateApPerHour)}),e.jsx(h,{className:p,children:z(o.totalAp)})]})]})}function Je({open:s,onOpenChange:o,tasks:m,from:v,to:c,onCreateTimebox:I,onUpdateTimebox:k,onDeleteTimebox:N,initialTaskId:f,lockedTaskId:g,editingTimebox:t,userIds:le}){var he,pe,fe,ve,ge,xe;const L=!!t,w=j.useMemo(()=>{const a=g??(t==null?void 0:t.taskId)??null,d=m.filter(u=>u.status!=="done"||u.id===a);if(!a)return d;const r=d.find(u=>u.id===a);return r?[r]:[]},[t==null?void 0:t.taskId,g,m]),M=E(v),F=E(c),ie=t?re(E(t.startsAt),M,F):we(v,c),oe=g??(t==null?void 0:t.taskId)??f??((he=w[0])==null?void 0:he.id)??"",$=w.find(a=>a.id===oe)??w[0]??null,de=U(ie,$==null?void 0:$.plannedDurationSeconds,t?{startsAt:t.startsAt,endsAt:t.endsAt}:null),[i,O]=j.useState({taskId:oe,preferredDate:ie,plannerMode:t?"manual":"suggested",selectedTimeboxId:"",activityPresetKey:((pe=t==null?void 0:t.actionProfile)==null?void 0:pe.profileKey)??"task_inherited",customSustainRateApPerHour:((fe=t==null?void 0:t.actionProfile)==null?void 0:fe.sourceMethod)==="manual"?t.actionProfile.sustainRateApPerHour:null,manualStartTime:de.startTime,manualEndTime:de.endTime,manualTitle:(t==null?void 0:t.title)??($==null?void 0:$.title)??"",overrideReason:(t==null?void 0:t.overrideReason)??""}),[Ae,b]=j.useState(null),[Pe,W]=j.useState(!1),[De,ce]=j.useState(!1);j.useEffect(()=>{var _,H,B;if(!s)return;const a=g??f??((_=w[0])==null?void 0:_.id)??"",d=(t==null?void 0:t.taskId)??a,r=w.find(x=>x.id===d)??w[0]??null,u=t?re(E(t.startsAt),M,F):we(v,c),n=U(u,r==null?void 0:r.plannedDurationSeconds,t?{startsAt:t.startsAt,endsAt:t.endsAt}:null);b(null),O({taskId:d,preferredDate:u,plannerMode:t?"manual":"suggested",selectedTimeboxId:"",activityPresetKey:((H=t==null?void 0:t.actionProfile)==null?void 0:H.profileKey)??"task_inherited",customSustainRateApPerHour:((B=t==null?void 0:t.actionProfile)==null?void 0:B.sourceMethod)==="manual"?t.actionProfile.sustainRateApPerHour:null,manualStartTime:n.startTime,manualEndTime:n.endTime,manualTitle:(t==null?void 0:t.title)??(r==null?void 0:r.title)??"",overrideReason:(t==null?void 0:t.overrideReason)??""})},[w,t,v,f,g,F,M,s,c]);const l=w.find(a=>a.id===i.taskId)??null,P=j.useMemo(()=>({from:Ke(i.preferredDate),to:He(i.preferredDate)}),[i.preferredDate]),D=je({queryKey:["forge-calendar-suggestions-dialog",i.taskId,P.from,P.to],queryFn:()=>Me({taskId:i.taskId,from:P.from,to:P.to,limit:8}),enabled:s&&i.taskId.length>0}),X=je({queryKey:["forge-calendar-timebox-dialog-day",P.from,P.to,...le??[]],queryFn:()=>Fe({from:P.from,to:P.to,userIds:le}),enabled:s});j.useEffect(()=>{var d;if(!s)return;const a=((d=D.data)==null?void 0:d.timeboxes)??[];if(!a.length){O(r=>r.selectedTimeboxId?{...r,selectedTimeboxId:""}:r);return}O(r=>r.selectedTimeboxId&&a.some(u=>u.id===r.selectedTimeboxId)?r:{...r,selectedTimeboxId:a[0].id})},[s,D.data]);const A=(ve=X.data)==null?void 0:ve.calendar,Z=(A==null?void 0:A.events)??[],V=(A==null?void 0:A.workBlockInstances)??[],T=(A==null?void 0:A.timeboxes)??[],K=(((ge=D.data)==null?void 0:ge.timeboxes)??[]).find(a=>a.id===i.selectedTimeboxId),S=ke(i.preferredDate,i.manualStartTime),R=ke(i.preferredDate,i.manualEndTime),Q=S&&R?ae({startsAt:S.toISOString(),endsAt:R.toISOString(),actionProfile:i.customSustainRateApPerHour!==null||i.activityPresetKey!=="task_inherited"?{id:"manual-preview",profileKey:"manual-preview",title:i.manualTitle||(l==null?void 0:l.title)||"Manual timebox",entityType:"task_timebox",mode:"container",startupAp:0,totalCostAp:0,expectedDurationSeconds:null,sustainRateApPerHour:i.customSustainRateApPerHour??((xe=q().find(a=>a.key===i.activityPresetKey))==null?void 0:xe.defaultRateApPerHour)??100/24,demandWeights:{activation:.1,focus:.3,vigor:.1,composure:.1,flow:.4},doubleCountPolicy:"container_only",sourceMethod:"manual",costBand:"light",recoveryEffect:0,metadata:{},createdAt:S.toISOString(),updatedAt:S.toISOString()}:null}):null,ue=L?"Review the task tied to this scheduled block":g?"Review the task you are planning":"Choose the task you want to place into the calendar",me=L?"The timebox stays linked to this task. Update the day, hours, title, or AP profile without leaving the planning flow.":g?"Forge will use this task's current duration target and scheduling rules while it looks for viable slots.":"Forge will use the task's current planned duration and scheduling rules when it searches for valid slots.",Ce=j.useMemo(()=>[{id:"task",eyebrow:"Planning",title:ue,description:me,render:(a,d)=>e.jsxs("div",{className:"grid min-w-0 max-w-full gap-4 overflow-hidden",children:[g?null:e.jsx(y,{label:"Task",children:e.jsx("select",{value:a.taskId,onChange:r=>(()=>{const u=w.find(_=>_.id===r.target.value),n=U(a.preferredDate,u==null?void 0:u.plannedDurationSeconds);d({taskId:r.target.value,selectedTimeboxId:"",activityPresetKey:"task_inherited",customSustainRateApPerHour:null,manualStartTime:n.startTime,manualEndTime:n.endTime,manualTitle:(u==null?void 0:u.title)??a.manualTitle})})(),className:ee,children:w.map(r=>e.jsx("option",{value:r.id,children:r.title},r.id))})}),l?e.jsxs("div",{className:"min-w-0 max-w-full overflow-hidden rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5 shadow-[var(--ui-shadow-soft)]",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Time Box"}),e.jsx("div",{className:"mt-2 break-words font-display text-[1.4rem] leading-tight text-[var(--ui-ink-strong)]",children:l.title})]}),e.jsx(h,{className:p,children:l.status})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(h,{className:p,children:l.plannedDurationSeconds?`${Math.round(l.plannedDurationSeconds/60)} min target`:"No duration yet"}),e.jsx(h,{className:p,children:l.schedulingRules?"Task-specific rules":"Uses project rules"}),e.jsxs(h,{className:p,children:[l.points," xp"]}),l.plannedDurationSeconds?e.jsxs(h,{className:p,children:[z(l.plannedDurationSeconds/3600/24*100)," ","target load"]}):null]}),e.jsx("p",{className:"mt-4 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Pick a day first, then either accept one of Forge's suggested slots or set the block manually."}),L&&t&&N?e.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-3 rounded-[20px] border border-[color-mix(in_srgb,var(--danger)_24%,var(--ui-border-subtle)_76%)] bg-[var(--ui-danger-soft)] px-4 py-3",children:[e.jsx("div",{className:"text-sm leading-6 text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",children:"Remove this planned timebox if you no longer want it in the calendar."}),e.jsx(Y,{type:"button",variant:"ghost",className:"text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)] hover:bg-[var(--ui-danger-soft)]",pending:De,pendingLabel:"Deleting",onClick:()=>void(async()=>{b(null),ce(!0);try{await N(t.id),o(!1)}catch(r){b(r instanceof Error?r.message:"Forge could not delete this timebox.")}finally{ce(!1)}})(),children:"Delete timebox"})]}):null]}):null]})},{id:"day",eyebrow:"Calendar",title:"Choose the day and review what is already there",description:"Forge reads the real day first so the timebox stays grounded in your provider events, work blocks, and already-planned work.",render:(a,d)=>e.jsx("div",{className:"grid gap-5",children:e.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,16rem)_minmax(0,1fr)]",children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsx(y,{label:"Date",description:"Choose the day you want to protect for this task.",children:e.jsx(C,{type:"date",min:M,max:F,value:a.preferredDate,onChange:r=>{const u=U(r.target.value,l==null?void 0:l.plannedDurationSeconds,t?{startsAt:`${r.target.value}T${a.manualStartTime}:00`,endsAt:`${r.target.value}T${a.manualEndTime}:00`}:null);d({preferredDate:r.target.value,selectedTimeboxId:"",manualStartTime:u.startTime,manualEndTime:u.endTime})}})}),e.jsx(y,{label:"Planning style",description:"Take Forge's slot recommendation when it fits, or set the block yourself.",children:e.jsx(Ee,{value:a.plannerMode,onChange:r=>d({plannerMode:r}),options:[{value:"suggested",label:"Use suggestions",description:"Forge proposes slots that fit the task rules and the selected day."},{value:"manual",label:"Set it manually",description:"You choose the exact start and end time yourself."}]})})]}),e.jsxs("div",{className:"rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Selected day"}),e.jsx("div",{className:"mt-2 font-display text-[1.3rem] leading-tight text-[var(--ui-ink-strong)]",children:a.preferredDate?new Date(`${a.preferredDate}T12:00:00`).toLocaleDateString([],{weekday:"long",month:"long",day:"numeric"}):"Choose a day"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(h,{className:p,children:[Z.length," events"]}),e.jsxs(h,{className:p,children:[V.length," work blocks"]}),e.jsxs(h,{className:p,children:[T.length," timeboxes"]})]})]}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"This is the context Forge will use while recommending a slot. You can still place the block manually if you want something more exact."}),X.isLoading?e.jsx("div",{className:"mt-4 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-4 text-sm text-[var(--ui-ink-soft)]",children:"Loading the selected day…"}):e.jsxs("div",{className:"mt-4 grid gap-4 xl:grid-cols-3",children:[e.jsx(te,{title:"Provider events",subtitle:"Busy or free events already on the day.",emptyLabel:"No mirrored events on this day.",children:Z.slice(0,4).map(r=>e.jsx(Be,{event:r},r.id))}),e.jsx(te,{title:"Work blocks",subtitle:"Recurring allowed or blocked containers.",emptyLabel:"No work blocks land on this day.",children:V.slice(0,4).map(r=>e.jsx(Oe,{block:r},r.id))}),e.jsx(te,{title:"Planned timeboxes",subtitle:"Existing owned work already placed there.",emptyLabel:"No other planned timeboxes yet.",children:T.slice(0,4).map(r=>e.jsx(We,{timebox:r},r.id))})]})]})]})})},{id:"slot",eyebrow:i.plannerMode==="suggested"?"Suggestion":"Manual",title:i.plannerMode==="suggested"?"Choose one of Forge's suggested slots":"Set the exact timebox yourself",description:i.plannerMode==="suggested"?"Forge proposes slots that fit the selected day, the task rules, and the current calendar picture.":"Use manual mode when the right block is obvious to you or when you want to place the timebox despite imperfect recommendations.",render:(a,d)=>{var u;if(a.plannerMode==="manual")return e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(y,{label:"Day",description:"Pick the day for the block. Forge defaults to a future day, but you can move it.",children:e.jsx(C,{type:"date",min:M,max:F,value:a.preferredDate,onChange:n=>d({preferredDate:n.target.value})})}),e.jsx(y,{label:"Start time",description:"Choose when the protected work block should begin.",children:e.jsx(C,{type:"time",step:300,value:a.manualStartTime,onChange:n=>d({manualStartTime:n.target.value})})}),e.jsx(y,{label:"End time",description:"Choose when the work block should end.",children:e.jsx(C,{type:"time",step:300,value:a.manualEndTime,onChange:n=>d({manualEndTime:n.target.value})})})]}),e.jsx(y,{label:"Title",description:"By default Forge uses the task title. Tighten it only if a shorter calendar label would help.",children:e.jsx(C,{value:a.manualTitle,onChange:n=>d({manualTitle:n.target.value}),placeholder:(l==null?void 0:l.title)??"Task timebox"})}),e.jsx(y,{label:"Override reason",description:"Optional. Add a short reason only if you are intentionally placing the block despite the normal rules or calendar shape.",children:e.jsx(C,{value:a.overrideReason,onChange:n=>d({overrideReason:n.target.value}),placeholder:"Protected writing block before clinic."})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(y,{label:"Activity profile",children:e.jsx("select",{value:a.activityPresetKey??"task_inherited",onChange:n=>d({activityPresetKey:n.target.value}),className:ee,children:q().map(n=>e.jsx("option",{value:n.key,children:n.label},n.key))})}),e.jsx(y,{label:"Custom AP per hour",children:e.jsx(C,{type:"number",min:0,step:.5,value:a.customSustainRateApPerHour??"",onChange:n=>d({customSustainRateApPerHour:n.target.value.trim()===""?null:Number(n.target.value)}),placeholder:"Leave empty to use the activity profile"})})]}),e.jsxs("div",{className:`${Se} p-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-medium text-[var(--ui-ink-strong)]",children:a.manualTitle||(l==null?void 0:l.title)||"Manual timebox"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:S&&R?`${S.toLocaleDateString([],{weekday:"long",month:"short",day:"numeric"})} · ${Ne(S.toISOString(),R.toISOString())}`:"Choose a start and end time."})]}),e.jsx(h,{className:p,children:"manual"})]}),Q?e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(h,{className:p,children:se(Q.rateApPerHour)}),e.jsx(h,{className:p,children:z(Q.totalAp)})]}):null]})]});const r=((u=D.data)==null?void 0:u.timeboxes)??[];return D.isLoading?e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Looking for valid slots on the selected day…"}):r.length?e.jsx("div",{className:"grid gap-3",children:r.map(n=>{var B;const _=a.selectedTimeboxId===n.id,H=ae({...n,actionProfile:a.customSustainRateApPerHour!==null||a.activityPresetKey!=="task_inherited"?{id:"suggested-preview",profileKey:"suggested-preview",title:n.title,entityType:"task_timebox",mode:"container",startupAp:0,totalCostAp:0,expectedDurationSeconds:null,sustainRateApPerHour:a.customSustainRateApPerHour??((B=q().find(x=>x.key===a.activityPresetKey))==null?void 0:B.defaultRateApPerHour)??100/24,demandWeights:{activation:.1,focus:.3,vigor:.1,composure:.1,flow:.4},doubleCountPolicy:"container_only",sourceMethod:"manual",costBand:"light",recoveryEffect:0,metadata:{},createdAt:n.startsAt,updatedAt:n.startsAt}:null});return e.jsxs("button",{type:"button",onClick:()=>d({selectedTimeboxId:n.id}),className:`rounded-[24px] border px-4 py-4 text-left transition ${_?"border-[color-mix(in_srgb,var(--primary)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)] shadow-[var(--ui-shadow-soft)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)] hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]"}`,children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium",children:n.title}),e.jsx(h,{className:p,children:n.source})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:J(n.startsAt,n.endsAt)}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(h,{className:p,children:se(H.rateApPerHour)}),e.jsx(h,{className:p,children:z(H.totalAp)})]}),_?e.jsxs("div",{className:"mt-4 grid gap-4 md:grid-cols-2",children:[e.jsx(y,{label:"Activity profile",children:e.jsx("select",{value:a.activityPresetKey??"task_inherited",onChange:x=>d({activityPresetKey:x.target.value}),className:ee,children:q().map(x=>e.jsx("option",{value:x.key,children:x.label},x.key))})}),e.jsx(y,{label:"Custom AP per hour",children:e.jsx(C,{type:"number",min:0,step:.5,value:a.customSustainRateApPerHour??"",onChange:x=>d({customSustainRateApPerHour:x.target.value.trim()===""?null:Number(x.target.value)}),placeholder:"Leave empty to use the activity profile"})})]}):null]},n.id)})}):e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"rounded-[24px] border border-[color-mix(in_srgb,var(--warning)_24%,var(--ui-border-subtle)_76%)] bg-[var(--ui-warning-soft)] px-4 py-4 text-sm leading-6 text-[color-mix(in_srgb,var(--warning)_72%,var(--ui-ink-strong)_28%)]",children:"Forge could not find a valid slot on this day. Try another day, adjust the task rules, or switch to manual placement if you already know the right block."}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(Y,{variant:"secondary",onClick:()=>void D.refetch(),children:"Refresh suggestions"}),e.jsx(Y,{variant:"secondary",onClick:()=>d({plannerMode:"manual"}),children:"Switch to manual"})]})]})}}],[w,X.isLoading,V,Z,T,i.plannerMode,t,v,g,F,Q,M,l,D.data,D.isLoading,me,ue,c]);return e.jsx(Le,{open:s,onOpenChange:o,eyebrow:"Calendar",title:L?"Edit timebox":"Plan work",description:L?"Update the day, hour range, title, and AP profile for this scheduled block without leaving the task or calendar view.":"Review the day, let Forge recommend valid slots, and place a real timebox on the task without leaving the detail view.",value:i,onChange:O,draftPersistenceKey:t?`calendar.timebox.${t.id}`:`calendar.timebox.new.${(l==null?void 0:l.id)??"unscoped"}`,steps:Ce,submitLabel:L?"Save timebox":"Schedule timebox",pending:Pe,pendingLabel:"Scheduling",error:Ae,contentClassName:"md:w-[min(70rem,calc(100vw-1.5rem))]",onSubmit:async()=>{if(!l){b("Choose a task before scheduling a timebox.");return}if(i.plannerMode==="manual"){if(!S||!R){b("Choose a valid manual start and end time.");return}if(R<=S){b("The manual timebox needs an end time after the start time.");return}b(null),W(!0);try{const a={title:i.manualTitle.trim()||l.title,startsAt:S.toISOString(),endsAt:R.toISOString(),overrideReason:i.overrideReason.trim()||null,activityPresetKey:i.activityPresetKey,customSustainRateApPerHour:i.customSustainRateApPerHour};t&&k?await k(t.id,a):await I({taskId:l.id,projectId:l.projectId,...a,source:"manual"}),o(!1)}catch(a){b(a instanceof Error?a.message:"Forge could not create the manual timebox.")}finally{W(!1)}return}if(!K){b("Pick one suggested slot before scheduling the timebox.");return}b(null),W(!0);try{const a={title:K.title,startsAt:K.startsAt,endsAt:K.endsAt,activityPresetKey:i.activityPresetKey,customSustainRateApPerHour:i.customSustainRateApPerHour};t&&k?await k(t.id,a):await I({taskId:l.id,projectId:l.projectId,...a,source:K.source}),o(!1)}catch(a){b(a instanceof Error?a.message:"Forge could not create the selected timebox.")}finally{W(!1)}}})}export{ze as T,Je as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,aC as b,b8 as L,br as C,bO as X,b5 as O,r as D,aV as F,cA as U}from"./vendor-Dnkkx2co.js";import{i as M}from"./state-vCcAT5Hq.js";import{A as V}from"./ai-surface-workspace-BCbQUekv.js";import{P as H,aq as W,c as x,_ as z,b as S,V as P,B as q,Z as K,u as Q,a as G,eR as J,eS as Y,C as k,W as Z,eT as ee,eU as te,eV as se,bG as ae,bH as ie,bI as ne,bJ as re,bK as le,N as oe}from"./index-BP9__l6C.js";import{E as _}from"./entity-note-count-link-DUxobQUt.js";import{S as $}from"./surface-98myBzix.js";import{a as de}from"./life-force-workspace-Ct70SsNQ.js";import{P as A}from"./page-hero-DgnhI5es.js";import"./board-dIX6etHh.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./graph-DDUZNRsO.js";import"./floating-action-menu-DBzfnJOx.js";import"./charts-DFnEuIMB.js";function E(s,t){return t.find(c=>c.id===s.goalId)??null}function ce(s,t){return s.tagIds.map(c=>t.find(d=>d.id===c)).filter(Boolean)}function me(s,t){(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),t())}function ue(s,t){switch(s.status){case"backlog":return{label:t.backlog,action:"start",icon:C};case"focus":return{label:t.focus,action:"start",icon:C};case"in_progress":return{label:t.in_progress,nextStatus:"done",action:"move",icon:X};case"blocked":return{label:t.blocked,action:"start",icon:C};default:return null}}function xe({tasks:s,timeline:t,goals:c,tags:d,notesSummaryByEntity:N,selectedTaskId:j,onSelectTask:r,onMove:p,onStartTask:f}){const{t:l,formatDate:w}=H(),T={backlog:l("common.dailyRunway.actionBacklog"),focus:l("common.dailyRunway.actionFocus"),in_progress:l("common.dailyRunway.actionProgress"),blocked:l("common.dailyRunway.actionBlocked")};return e.jsxs("div",{className:"grid min-w-0 gap-4 2xl:grid-cols-[minmax(0,1.3fr)_minmax(17rem,0.9fr)]",children:[e.jsxs($,{className:"min-w-0 rounded-[24px]",children:[e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:l("common.dailyRunway.runwayEyebrow")}),e.jsx(W,{content:"These are the tasks that matter most for today. Click a card to open the task details. Use Start to begin work immediately."})]}),e.jsx("h4",{className:"mt-2 font-display text-2xl text-[var(--ui-ink-strong)]",children:l("common.dailyRunway.runwayTitle")})]}),e.jsx(x,{className:"shrink-0 text-[var(--primary)]",children:l(s.length===1?"common.dailyRunway.prioritiesOne":"common.dailyRunway.prioritiesOther",{count:s.length})})]}),e.jsx("div",{className:"mt-4 grid min-w-0 gap-3",children:s.map((a,y)=>{const o=ue(a,T),i=ce(a,d).slice(0,2),n=E(a,c),h=j===a.id,B=z(N,"task",a.id).count;return e.jsxs("article",{role:"button",tabIndex:0,"aria-pressed":h,className:K("grid w-full gap-3 rounded-[22px] border px-4 py-4 text-left transition",h?"border-[var(--primary)]/28 bg-[var(--ui-accent-soft)] shadow-[var(--ui-shadow-soft)]":"border-transparent bg-[var(--ui-surface-1)] hover:border-[var(--ui-border-subtle)] hover:bg-[var(--ui-surface-hover)]"),onClick:()=>r(a.id),onKeyDown:m=>me(m,()=>r(a.id)),children:[e.jsxs("div",{className:"flex min-w-0 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-[var(--ui-ink-faint)]",children:l("common.dailyRunway.runwayItem",{index:y+1})}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[n?e.jsx(b,{to:`/goals/${n.id}`,className:"min-w-0 max-w-full transition hover:opacity-85",onClick:m=>m.stopPropagation(),children:e.jsx(S,{kind:"goal",label:n.title,compact:!0,gradient:!1})}):e.jsx(S,{kind:"goal",label:l("common.dailyRunway.unassigned"),compact:!0,gradient:!1}),a.time.activeRunCount>0?e.jsx(x,{className:"border-[color-mix(in_srgb,#10b981_24%,transparent)] bg-[color-mix(in_srgb,#10b981_16%,var(--ui-surface-1))] text-[color-mix(in_srgb,#10b981_80%,var(--ui-ink-strong)_20%)]",children:"Live"}):null]}),e.jsx("div",{className:"mt-2",children:e.jsx(b,{to:`/tasks/${a.id}`,className:"block min-w-0 max-w-full transition hover:opacity-85",onClick:m=>m.stopPropagation(),children:e.jsx(P,{kind:"task",label:a.title,variant:"heading",size:"md"})})}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:a.description||l("common.dailyRunway.noNote")})]}),e.jsx(x,{className:"shrink-0 self-start",children:a.status.replaceAll("_"," ")})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(x,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:[a.points," xp"]}),e.jsx(_,{entityType:"task",entityId:a.id,count:B}),a.time.totalCreditedSeconds>0?e.jsxs(x,{tone:"meta",children:[Math.floor(a.time.totalCreditedSeconds/60)," min tracked"]}):null,e.jsx(x,{tone:"meta",children:a.effort}),e.jsx(x,{tone:"meta",children:w(a.dueDate)}),i.map(m=>e.jsx(x,{className:"bg-[var(--ui-surface-2)]",style:{color:m.color},children:m.name},m.id))]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:a.owner}),o?e.jsxs(q,{variant:o.action==="start"?"primary":"secondary",className:"px-3 py-2 text-[11px] uppercase tracking-[0.16em]",onClick:async m=>{if(m.stopPropagation(),o.action==="start"){await f(a.id);return}o.nextStatus&&await p(a.id,o.nextStatus)},children:[e.jsx(o.icon,{className:"mr-2 size-3.5"}),o.label]}):null]})]},a.id)})})]}),e.jsxs($,{className:"min-w-0 rounded-[24px]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:l("common.dailyRunway.timelineEyebrow")}),e.jsx(W,{content:"This groups today's tasks by status, so you can see what is already moving, what is ready to start, what is blocked, and what is done."})]}),e.jsx("h4",{className:"mt-2 font-display text-2xl text-[var(--ui-ink-strong)]",children:l("common.dailyRunway.timelineTitle")}),e.jsx("div",{className:"mt-4 grid min-w-0 gap-3",children:t.map(a=>e.jsxs($,{muted:!0,className:"min-w-0 overflow-hidden rounded-[20px]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:a.label}),e.jsx(x,{tone:"meta",children:a.tasks.length})]}),e.jsxs("div",{className:"mt-3 grid gap-2",children:[a.tasks.slice(0,3).map(y=>{const o=E(y,c);return e.jsxs(b,{to:`/tasks/${y.id}`,className:"flex min-w-0 items-center justify-between gap-3 overflow-hidden rounded-[16px] bg-[var(--ui-surface-1)] px-3 py-3 text-left transition hover:bg-[var(--ui-surface-hover)]",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(P,{kind:"task",label:y.title,className:"max-w-full",labelClassName:"[overflow-wrap:anywhere]"}),e.jsx("div",{className:"mt-2",children:e.jsx(S,{kind:"goal",label:(o==null?void 0:o.title)??l("common.dailyRunway.unassigned"),compact:!0,gradient:!1})})]}),e.jsx(L,{className:"size-4 shrink-0 text-[var(--ui-ink-faint)]"})]},y.id)}),a.tasks.length===0?e.jsx("div",{className:"text-sm text-[var(--ui-ink-faint)]",children:l("common.dailyRunway.emptyBucket")}):null]})]},a.id))})]})]})}const he=5,g="text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",u="text-[var(--ui-ink-soft)]",v="text-[var(--ui-ink-strong)]",R="min-w-0 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] shadow-[var(--ui-shadow-soft)]",I="min-w-0 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]",pe="inline-flex min-h-10 max-w-full shrink-0 items-center justify-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-2 text-xs font-medium text-[var(--ui-ink-medium)] shadow-[var(--ui-shadow-soft)] transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]";function fe(){const s=new Date;s.setHours(0,0,0,0);const t=new Date(s);return t.setDate(t.getDate()+1),{start:s,end:t,from:s.toISOString(),to:t.toISOString()}}function ye(s,t){const c=new Date(s.startAt),d=new Date(s.endAt);return c<t.end&&d>t.start}function ge(s){if(s.isAllDay)return"All day";const t=new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"});return`${t.format(new Date(s.startAt))} - ${t.format(new Date(s.endAt))}`}function Ae(){var o;const{t:s}=H(),t=Q(),c=O(),d=D.useMemo(()=>fe(),[]),N=Array.isArray(t.selectedUserIds)?t.selectedUserIds:[],j=M({queryKey:["forge-calendar-overview",d.from,d.to,...N],queryFn:()=>oe({from:d.from,to:d.to,userIds:N})}),r=t.snapshot.today.directive.task,p=t.snapshot.today.milestoneRewards.find(i=>!i.completed)??t.snapshot.today.milestoneRewards[0]??null,f=t.snapshot.risk.blockedTasks[0]??t.snapshot.risk.overdueTasks[0]??null,l=Math.max(0,t.snapshot.metrics.nextLevelXp-t.snapshot.metrics.currentLevelXp),w=D.useMemo(()=>{var i;return(((i=j.data)==null?void 0:i.calendar.events)??[]).filter(n=>!n.deletedAt&&n.status!=="cancelled"&&ye(n,d)).sort((n,h)=>new Date(n.startAt).getTime()-new Date(h.startAt).getTime())},[(o=j.data)==null?void 0:o.calendar.events,d]),T=w.slice(0,he);if(!(t.snapshot.lifeForce!==void 0||r!==null||t.snapshot.overview.topTasks.length>0||t.snapshot.today.dueHabits.length>0||t.snapshot.today.dailyQuests.length>0||t.snapshot.today.milestoneRewards.length>0||w.length>0)&&!j.isLoading)return e.jsxs("div",{className:"grid gap-4",children:[e.jsx(A,{title:"Today",titleText:"Today",description:"Start a task, earn XP, and keep today's work clear.",badge:`${t.snapshot.metrics.weeklyXp} weekly xp`}),e.jsx(G,{eyebrow:s("common.todayPage.heroEyebrow"),title:s("common.todayPage.emptyTitle"),description:s("common.todayPage.emptyDescription"),action:e.jsx(b,{to:"/goals",className:"inline-flex min-h-10 min-w-max shrink-0 items-center justify-center rounded-full bg-[var(--primary)] px-4 py-2 text-sm font-medium whitespace-nowrap text-[var(--ui-ink-on-accent)] transition hover:opacity-90",children:s("common.todayPage.emptyAction")})})]});const y=[{id:"hero",title:"Today",description:"Compact page header.",defaultWidth:12,defaultHeight:2,removable:!1,surfaceChrome:"none",defaultTitleVisible:!1,defaultDescriptionVisible:!1,render:()=>e.jsx(J,{children:e.jsx(A,{title:"Today",titleText:"Today",description:(r==null?void 0:r.description)??"Start one real task, collect XP, and keep today's work moving.",badge:`${t.snapshot.metrics.weeklyXp} weekly xp`})})},{id:"life-force",title:"Life Force",description:"Instant headroom, AP use today, and tiredness signals.",defaultWidth:12,defaultHeight:3,minWidth:5,render:()=>e.jsx(de,{selectedUserIds:t.selectedUserIds,fallbackLifeForce:t.snapshot.lifeForce,onRefresh:t.refresh})},{id:"metrics",title:"Live metrics",description:"XP, level, and momentum stay visible but lighter than before.",defaultWidth:5,defaultHeight:4,minWidth:4,render:({compact:i})=>e.jsx(Y,{children:e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs(k,{className:"min-w-0 p-4",children:[e.jsx("div",{className:g,children:"Weekly XP"}),e.jsx("div",{className:"mt-2 break-words font-display text-4xl text-[var(--primary)]",children:t.snapshot.metrics.weeklyXp}),e.jsxs("div",{className:`mt-1 text-sm ${u}`,children:[t.snapshot.metrics.totalXp," total XP"]})]}),e.jsxs(k,{className:"min-w-0 p-4",children:[e.jsx("div",{className:g,children:"Level"}),e.jsx("div",{className:`mt-2 font-display text-4xl ${v}`,children:t.snapshot.metrics.level}),e.jsxs("div",{className:`mt-1 text-sm ${u}`,children:[l," xp to the next level"]}),i?null:e.jsx("div",{className:"mt-3",children:e.jsx(Z,{value:t.snapshot.metrics.currentLevelXp/t.snapshot.metrics.nextLevelXp*100,tone:"tertiary"})})]}),e.jsxs(k,{className:"min-w-0 p-4",children:[e.jsx("div",{className:g,children:"Momentum"}),e.jsxs("div",{className:`mt-2 font-display text-4xl ${v}`,children:[t.snapshot.metrics.momentumScore,"%"]}),e.jsxs("div",{className:`mt-1 text-sm ${u}`,children:[t.snapshot.metrics.streakDays," day streak"]})]}),e.jsxs(k,{className:"min-w-0 p-4",children:[e.jsx("div",{className:g,children:"Next reward"}),e.jsx("div",{className:`mt-2 break-words text-base font-semibold ${v}`,children:(p==null?void 0:p.title)??"Keep showing up"}),e.jsx("div",{className:`mt-1 text-sm ${u}`,children:(p==null?void 0:p.progressLabel)??"The next visible win comes from a task completion or aligned habit check-in."})]})]})})},{id:"runway",title:"Runway",description:"The execution lane itself can be widened or narrowed.",defaultWidth:7,defaultHeight:6,minWidth:5,render:()=>e.jsx(ee,{children:e.jsx(xe,{tasks:t.snapshot.overview.topTasks,timeline:t.snapshot.today.timeline,goals:t.snapshot.goals,tags:t.snapshot.tags,notesSummaryByEntity:t.snapshot.dashboard.notesSummaryByEntity,selectedTaskId:(r==null?void 0:r.id)??null,onSelectTask:i=>c(`/tasks/${i}`),onStartTask:async i=>{await t.startTaskNow(i)},onMove:async(i,n)=>{await t.patchTaskStatus(i,n)}})})},{id:"calendar",title:"Calendar",description:"Today's events stay grouped with their results instead of splitting search from outcome.",defaultWidth:5,defaultHeight:5,minWidth:4,render:({compact:i})=>e.jsx(te,{children:e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("div",{className:"inline-flex size-10 shrink-0 items-center justify-center rounded-2xl bg-[var(--primary)]/14 text-[var(--primary)]",children:e.jsx(F,{className:"size-4"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:g,children:"Today's calendar"}),e.jsx("div",{className:`text-sm font-semibold ${v}`,children:new Intl.DateTimeFormat(void 0,{weekday:"short",month:"short",day:"numeric"}).format(d.start)}),e.jsxs("div",{className:`text-sm ${u}`,children:[w.length," event",w.length===1?"":"s"]})]})]}),e.jsxs(b,{to:"/calendar",className:pe,children:["Open calendar",e.jsx(U,{className:"size-3.5"})]})]}),w.length===0?e.jsx("div",{className:`${I} px-4 py-4 text-sm ${u}`,children:"Nothing is scheduled yet for today."}):T.map(n=>e.jsxs("button",{type:"button",className:`${I} grid gap-2 px-3 py-3 text-left transition hover:bg-[var(--ui-surface-hover)]`,onClick:()=>c("/calendar"),children:[e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:`truncate text-sm font-medium ${v}`,children:n.title}),e.jsx("div",{className:`mt-1 text-sm ${u}`,children:ge(n)})]}),e.jsx(x,{className:"shrink-0 bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:n.originType==="native"?"Forge":n.originType})]}),!i&&n.description?e.jsx("div",{className:`line-clamp-2 text-sm leading-6 ${u}`,children:n.description}):null]},n.id))]})})},{id:"focus",title:"Current focus",description:"Current task, comeback task, and due habits stay in one movable stack.",defaultWidth:12,defaultHeight:4,minWidth:6,render:({compact:i})=>{var n;return e.jsx(se,{children:e.jsxs("div",{className:"grid min-w-0 gap-4 xl:grid-cols-[minmax(0,1.2fr)_minmax(0,0.8fr)]",children:[e.jsxs("div",{className:`${R} p-4`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:g,children:"Current task"}),r?e.jsx(_,{entityType:"task",entityId:r.id,count:((n=t.snapshot.dashboard.notesSummaryByEntity[`task:${r.id}`])==null?void 0:n.count)??0}):null]}),e.jsx("div",{className:`mt-3 break-words text-base font-semibold ${v}`,children:(r==null?void 0:r.title)??"Pick a task from the runway"}),e.jsx("div",{className:`mt-2 text-sm leading-6 ${u}`,children:(r==null?void 0:r.description)??"Once a task is active, the timer rail and this panel stay aligned."}),r?e.jsx("button",{type:"button",className:"mt-4 inline-flex min-h-10 max-w-full items-center justify-center rounded-2xl border border-[color-mix(in_srgb,var(--primary)_24%,transparent)] bg-[var(--ui-accent-soft)] px-3.5 py-2 text-sm font-medium text-[var(--primary)] shadow-[var(--ui-shadow-soft)] transition hover:bg-[var(--ui-accent-soft-hover)]",onClick:async()=>{await t.startTaskNow(r.id)},children:"Start work"}):null]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:`${R} p-4`,children:[e.jsx("div",{className:g,children:"Recovery task"}),e.jsx("div",{className:`mt-3 break-words text-sm font-semibold ${v}`,children:(f==null?void 0:f.title)??"No blocked or overdue task is dominating today"}),i?null:e.jsx("div",{className:`mt-2 text-sm leading-6 ${u}`,children:(f==null?void 0:f.description)??"If something slips, it will surface here as the clean comeback move."})]}),e.jsxs("div",{className:`${R} p-4`,children:[e.jsx("div",{className:g,children:"Due habits"}),e.jsx("div",{className:"mt-3 grid gap-2",children:t.snapshot.today.dueHabits.slice(0,i?2:3).map(h=>e.jsxs("div",{className:`${I} flex items-center justify-between gap-3 px-3 py-2.5`,children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:`truncate text-sm font-medium ${v}`,children:h.title}),i?null:e.jsx("div",{className:`text-sm ${u}`,children:h.frequency})]}),e.jsxs(x,{className:"shrink-0 bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_78%,var(--ui-ink-strong)_22%)]",children:[h.rewardXp," xp"]})]},h.id))})]})]})]})})}},{id:"time",title:"Clock",description:"Optional utility widget.",defaultWidth:3,defaultHeight:2,defaultHidden:!0,render:({compact:i})=>e.jsx(ae,{compact:i})},{id:"weather",title:"Weather",description:"Optional utility widget.",defaultWidth:3,defaultHeight:2,defaultHidden:!0,render:({compact:i})=>e.jsx(ie,{compact:i})},{id:"mini-calendar",title:"Mini calendar",description:"Optional utility widget.",defaultWidth:4,defaultHeight:3,defaultHidden:!0,render:({compact:i})=>e.jsx(ne,{compact:i})},{id:"spotify",title:"Spotify",description:"Optional utility widget.",defaultWidth:4,defaultHeight:2,defaultHidden:!0,render:()=>e.jsx(re,{surfaceId:"today"})},{id:"quick-capture",title:"Quick capture",description:"Save a note or wiki draft without leaving Today.",defaultWidth:5,defaultHeight:3,defaultHidden:!0,render:({compact:i})=>{var n;return e.jsx(le,{compact:i,defaultUserId:t.selectedUserIds[0]??((n=t.snapshot.users[0])==null?void 0:n.id)??null})}}];return e.jsx(V,{surfaceId:"today",baseWidgets:y})}export{Ae as TodayPage};
|
|
1
|
+
import{j as e,aC as b,b8 as L,br as C,bO as X,b5 as O,r as D,aV as F,cA as U}from"./vendor-Dnkkx2co.js";import{i as M}from"./state-vCcAT5Hq.js";import{A as V}from"./ai-surface-workspace-B_fV9C4s.js";import{P as H,aq as W,c as x,_ as z,b as S,V as P,B as q,Z as K,u as Q,a as G,eR as J,eS as Y,C as k,W as Z,eT as ee,eU as te,eV as se,bG as ae,bH as ie,bI as ne,bJ as re,bK as le,N as oe}from"./index-By3tQxiE.js";import{E as _}from"./entity-note-count-link-BX93WYgh.js";import{S as $}from"./surface-DRNu5Fpz.js";import{a as de}from"./life-force-workspace-BhPNH7ad.js";import{P as A}from"./page-hero-5RTqAI88.js";import"./board-dIX6etHh.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./graph-DDUZNRsO.js";import"./floating-action-menu-C5H-Wr2B.js";import"./charts-DFnEuIMB.js";function E(s,t){return t.find(c=>c.id===s.goalId)??null}function ce(s,t){return s.tagIds.map(c=>t.find(d=>d.id===c)).filter(Boolean)}function me(s,t){(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),t())}function ue(s,t){switch(s.status){case"backlog":return{label:t.backlog,action:"start",icon:C};case"focus":return{label:t.focus,action:"start",icon:C};case"in_progress":return{label:t.in_progress,nextStatus:"done",action:"move",icon:X};case"blocked":return{label:t.blocked,action:"start",icon:C};default:return null}}function xe({tasks:s,timeline:t,goals:c,tags:d,notesSummaryByEntity:N,selectedTaskId:j,onSelectTask:r,onMove:p,onStartTask:f}){const{t:l,formatDate:w}=H(),T={backlog:l("common.dailyRunway.actionBacklog"),focus:l("common.dailyRunway.actionFocus"),in_progress:l("common.dailyRunway.actionProgress"),blocked:l("common.dailyRunway.actionBlocked")};return e.jsxs("div",{className:"grid min-w-0 gap-4 2xl:grid-cols-[minmax(0,1.3fr)_minmax(17rem,0.9fr)]",children:[e.jsxs($,{className:"min-w-0 rounded-[24px]",children:[e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:l("common.dailyRunway.runwayEyebrow")}),e.jsx(W,{content:"These are the tasks that matter most for today. Click a card to open the task details. Use Start to begin work immediately."})]}),e.jsx("h4",{className:"mt-2 font-display text-2xl text-[var(--ui-ink-strong)]",children:l("common.dailyRunway.runwayTitle")})]}),e.jsx(x,{className:"shrink-0 text-[var(--primary)]",children:l(s.length===1?"common.dailyRunway.prioritiesOne":"common.dailyRunway.prioritiesOther",{count:s.length})})]}),e.jsx("div",{className:"mt-4 grid min-w-0 gap-3",children:s.map((a,y)=>{const o=ue(a,T),i=ce(a,d).slice(0,2),n=E(a,c),h=j===a.id,B=z(N,"task",a.id).count;return e.jsxs("article",{role:"button",tabIndex:0,"aria-pressed":h,className:K("grid w-full gap-3 rounded-[22px] border px-4 py-4 text-left transition",h?"border-[var(--primary)]/28 bg-[var(--ui-accent-soft)] shadow-[var(--ui-shadow-soft)]":"border-transparent bg-[var(--ui-surface-1)] hover:border-[var(--ui-border-subtle)] hover:bg-[var(--ui-surface-hover)]"),onClick:()=>r(a.id),onKeyDown:m=>me(m,()=>r(a.id)),children:[e.jsxs("div",{className:"flex min-w-0 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-[var(--ui-ink-faint)]",children:l("common.dailyRunway.runwayItem",{index:y+1})}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[n?e.jsx(b,{to:`/goals/${n.id}`,className:"min-w-0 max-w-full transition hover:opacity-85",onClick:m=>m.stopPropagation(),children:e.jsx(S,{kind:"goal",label:n.title,compact:!0,gradient:!1})}):e.jsx(S,{kind:"goal",label:l("common.dailyRunway.unassigned"),compact:!0,gradient:!1}),a.time.activeRunCount>0?e.jsx(x,{className:"border-[color-mix(in_srgb,#10b981_24%,transparent)] bg-[color-mix(in_srgb,#10b981_16%,var(--ui-surface-1))] text-[color-mix(in_srgb,#10b981_80%,var(--ui-ink-strong)_20%)]",children:"Live"}):null]}),e.jsx("div",{className:"mt-2",children:e.jsx(b,{to:`/tasks/${a.id}`,className:"block min-w-0 max-w-full transition hover:opacity-85",onClick:m=>m.stopPropagation(),children:e.jsx(P,{kind:"task",label:a.title,variant:"heading",size:"md"})})}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:a.description||l("common.dailyRunway.noNote")})]}),e.jsx(x,{className:"shrink-0 self-start",children:a.status.replaceAll("_"," ")})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(x,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:[a.points," xp"]}),e.jsx(_,{entityType:"task",entityId:a.id,count:B}),a.time.totalCreditedSeconds>0?e.jsxs(x,{tone:"meta",children:[Math.floor(a.time.totalCreditedSeconds/60)," min tracked"]}):null,e.jsx(x,{tone:"meta",children:a.effort}),e.jsx(x,{tone:"meta",children:w(a.dueDate)}),i.map(m=>e.jsx(x,{className:"bg-[var(--ui-surface-2)]",style:{color:m.color},children:m.name},m.id))]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:a.owner}),o?e.jsxs(q,{variant:o.action==="start"?"primary":"secondary",className:"px-3 py-2 text-[11px] uppercase tracking-[0.16em]",onClick:async m=>{if(m.stopPropagation(),o.action==="start"){await f(a.id);return}o.nextStatus&&await p(a.id,o.nextStatus)},children:[e.jsx(o.icon,{className:"mr-2 size-3.5"}),o.label]}):null]})]},a.id)})})]}),e.jsxs($,{className:"min-w-0 rounded-[24px]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:l("common.dailyRunway.timelineEyebrow")}),e.jsx(W,{content:"This groups today's tasks by status, so you can see what is already moving, what is ready to start, what is blocked, and what is done."})]}),e.jsx("h4",{className:"mt-2 font-display text-2xl text-[var(--ui-ink-strong)]",children:l("common.dailyRunway.timelineTitle")}),e.jsx("div",{className:"mt-4 grid min-w-0 gap-3",children:t.map(a=>e.jsxs($,{muted:!0,className:"min-w-0 overflow-hidden rounded-[20px]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:a.label}),e.jsx(x,{tone:"meta",children:a.tasks.length})]}),e.jsxs("div",{className:"mt-3 grid gap-2",children:[a.tasks.slice(0,3).map(y=>{const o=E(y,c);return e.jsxs(b,{to:`/tasks/${y.id}`,className:"flex min-w-0 items-center justify-between gap-3 overflow-hidden rounded-[16px] bg-[var(--ui-surface-1)] px-3 py-3 text-left transition hover:bg-[var(--ui-surface-hover)]",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(P,{kind:"task",label:y.title,className:"max-w-full",labelClassName:"[overflow-wrap:anywhere]"}),e.jsx("div",{className:"mt-2",children:e.jsx(S,{kind:"goal",label:(o==null?void 0:o.title)??l("common.dailyRunway.unassigned"),compact:!0,gradient:!1})})]}),e.jsx(L,{className:"size-4 shrink-0 text-[var(--ui-ink-faint)]"})]},y.id)}),a.tasks.length===0?e.jsx("div",{className:"text-sm text-[var(--ui-ink-faint)]",children:l("common.dailyRunway.emptyBucket")}):null]})]},a.id))})]})]})}const he=5,g="text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",u="text-[var(--ui-ink-soft)]",v="text-[var(--ui-ink-strong)]",R="min-w-0 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] shadow-[var(--ui-shadow-soft)]",I="min-w-0 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]",pe="inline-flex min-h-10 max-w-full shrink-0 items-center justify-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-2 text-xs font-medium text-[var(--ui-ink-medium)] shadow-[var(--ui-shadow-soft)] transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]";function fe(){const s=new Date;s.setHours(0,0,0,0);const t=new Date(s);return t.setDate(t.getDate()+1),{start:s,end:t,from:s.toISOString(),to:t.toISOString()}}function ye(s,t){const c=new Date(s.startAt),d=new Date(s.endAt);return c<t.end&&d>t.start}function ge(s){if(s.isAllDay)return"All day";const t=new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"});return`${t.format(new Date(s.startAt))} - ${t.format(new Date(s.endAt))}`}function Ae(){var o;const{t:s}=H(),t=Q(),c=O(),d=D.useMemo(()=>fe(),[]),N=Array.isArray(t.selectedUserIds)?t.selectedUserIds:[],j=M({queryKey:["forge-calendar-overview",d.from,d.to,...N],queryFn:()=>oe({from:d.from,to:d.to,userIds:N})}),r=t.snapshot.today.directive.task,p=t.snapshot.today.milestoneRewards.find(i=>!i.completed)??t.snapshot.today.milestoneRewards[0]??null,f=t.snapshot.risk.blockedTasks[0]??t.snapshot.risk.overdueTasks[0]??null,l=Math.max(0,t.snapshot.metrics.nextLevelXp-t.snapshot.metrics.currentLevelXp),w=D.useMemo(()=>{var i;return(((i=j.data)==null?void 0:i.calendar.events)??[]).filter(n=>!n.deletedAt&&n.status!=="cancelled"&&ye(n,d)).sort((n,h)=>new Date(n.startAt).getTime()-new Date(h.startAt).getTime())},[(o=j.data)==null?void 0:o.calendar.events,d]),T=w.slice(0,he);if(!(t.snapshot.lifeForce!==void 0||r!==null||t.snapshot.overview.topTasks.length>0||t.snapshot.today.dueHabits.length>0||t.snapshot.today.dailyQuests.length>0||t.snapshot.today.milestoneRewards.length>0||w.length>0)&&!j.isLoading)return e.jsxs("div",{className:"grid gap-4",children:[e.jsx(A,{title:"Today",titleText:"Today",description:"Start a task, earn XP, and keep today's work clear.",badge:`${t.snapshot.metrics.weeklyXp} weekly xp`}),e.jsx(G,{eyebrow:s("common.todayPage.heroEyebrow"),title:s("common.todayPage.emptyTitle"),description:s("common.todayPage.emptyDescription"),action:e.jsx(b,{to:"/goals",className:"inline-flex min-h-10 min-w-max shrink-0 items-center justify-center rounded-full bg-[var(--primary)] px-4 py-2 text-sm font-medium whitespace-nowrap text-[var(--ui-ink-on-accent)] transition hover:opacity-90",children:s("common.todayPage.emptyAction")})})]});const y=[{id:"hero",title:"Today",description:"Compact page header.",defaultWidth:12,defaultHeight:2,removable:!1,surfaceChrome:"none",defaultTitleVisible:!1,defaultDescriptionVisible:!1,render:()=>e.jsx(J,{children:e.jsx(A,{title:"Today",titleText:"Today",description:(r==null?void 0:r.description)??"Start one real task, collect XP, and keep today's work moving.",badge:`${t.snapshot.metrics.weeklyXp} weekly xp`})})},{id:"life-force",title:"Life Force",description:"Instant headroom, AP use today, and tiredness signals.",defaultWidth:12,defaultHeight:3,minWidth:5,render:()=>e.jsx(de,{selectedUserIds:t.selectedUserIds,fallbackLifeForce:t.snapshot.lifeForce,onRefresh:t.refresh})},{id:"metrics",title:"Live metrics",description:"XP, level, and momentum stay visible but lighter than before.",defaultWidth:5,defaultHeight:4,minWidth:4,render:({compact:i})=>e.jsx(Y,{children:e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs(k,{className:"min-w-0 p-4",children:[e.jsx("div",{className:g,children:"Weekly XP"}),e.jsx("div",{className:"mt-2 break-words font-display text-4xl text-[var(--primary)]",children:t.snapshot.metrics.weeklyXp}),e.jsxs("div",{className:`mt-1 text-sm ${u}`,children:[t.snapshot.metrics.totalXp," total XP"]})]}),e.jsxs(k,{className:"min-w-0 p-4",children:[e.jsx("div",{className:g,children:"Level"}),e.jsx("div",{className:`mt-2 font-display text-4xl ${v}`,children:t.snapshot.metrics.level}),e.jsxs("div",{className:`mt-1 text-sm ${u}`,children:[l," xp to the next level"]}),i?null:e.jsx("div",{className:"mt-3",children:e.jsx(Z,{value:t.snapshot.metrics.currentLevelXp/t.snapshot.metrics.nextLevelXp*100,tone:"tertiary"})})]}),e.jsxs(k,{className:"min-w-0 p-4",children:[e.jsx("div",{className:g,children:"Momentum"}),e.jsxs("div",{className:`mt-2 font-display text-4xl ${v}`,children:[t.snapshot.metrics.momentumScore,"%"]}),e.jsxs("div",{className:`mt-1 text-sm ${u}`,children:[t.snapshot.metrics.streakDays," day streak"]})]}),e.jsxs(k,{className:"min-w-0 p-4",children:[e.jsx("div",{className:g,children:"Next reward"}),e.jsx("div",{className:`mt-2 break-words text-base font-semibold ${v}`,children:(p==null?void 0:p.title)??"Keep showing up"}),e.jsx("div",{className:`mt-1 text-sm ${u}`,children:(p==null?void 0:p.progressLabel)??"The next visible win comes from a task completion or aligned habit check-in."})]})]})})},{id:"runway",title:"Runway",description:"The execution lane itself can be widened or narrowed.",defaultWidth:7,defaultHeight:6,minWidth:5,render:()=>e.jsx(ee,{children:e.jsx(xe,{tasks:t.snapshot.overview.topTasks,timeline:t.snapshot.today.timeline,goals:t.snapshot.goals,tags:t.snapshot.tags,notesSummaryByEntity:t.snapshot.dashboard.notesSummaryByEntity,selectedTaskId:(r==null?void 0:r.id)??null,onSelectTask:i=>c(`/tasks/${i}`),onStartTask:async i=>{await t.startTaskNow(i)},onMove:async(i,n)=>{await t.patchTaskStatus(i,n)}})})},{id:"calendar",title:"Calendar",description:"Today's events stay grouped with their results instead of splitting search from outcome.",defaultWidth:5,defaultHeight:5,minWidth:4,render:({compact:i})=>e.jsx(te,{children:e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("div",{className:"inline-flex size-10 shrink-0 items-center justify-center rounded-2xl bg-[var(--primary)]/14 text-[var(--primary)]",children:e.jsx(F,{className:"size-4"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:g,children:"Today's calendar"}),e.jsx("div",{className:`text-sm font-semibold ${v}`,children:new Intl.DateTimeFormat(void 0,{weekday:"short",month:"short",day:"numeric"}).format(d.start)}),e.jsxs("div",{className:`text-sm ${u}`,children:[w.length," event",w.length===1?"":"s"]})]})]}),e.jsxs(b,{to:"/calendar",className:pe,children:["Open calendar",e.jsx(U,{className:"size-3.5"})]})]}),w.length===0?e.jsx("div",{className:`${I} px-4 py-4 text-sm ${u}`,children:"Nothing is scheduled yet for today."}):T.map(n=>e.jsxs("button",{type:"button",className:`${I} grid gap-2 px-3 py-3 text-left transition hover:bg-[var(--ui-surface-hover)]`,onClick:()=>c("/calendar"),children:[e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:`truncate text-sm font-medium ${v}`,children:n.title}),e.jsx("div",{className:`mt-1 text-sm ${u}`,children:ge(n)})]}),e.jsx(x,{className:"shrink-0 bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:n.originType==="native"?"Forge":n.originType})]}),!i&&n.description?e.jsx("div",{className:`line-clamp-2 text-sm leading-6 ${u}`,children:n.description}):null]},n.id))]})})},{id:"focus",title:"Current focus",description:"Current task, comeback task, and due habits stay in one movable stack.",defaultWidth:12,defaultHeight:4,minWidth:6,render:({compact:i})=>{var n;return e.jsx(se,{children:e.jsxs("div",{className:"grid min-w-0 gap-4 xl:grid-cols-[minmax(0,1.2fr)_minmax(0,0.8fr)]",children:[e.jsxs("div",{className:`${R} p-4`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:g,children:"Current task"}),r?e.jsx(_,{entityType:"task",entityId:r.id,count:((n=t.snapshot.dashboard.notesSummaryByEntity[`task:${r.id}`])==null?void 0:n.count)??0}):null]}),e.jsx("div",{className:`mt-3 break-words text-base font-semibold ${v}`,children:(r==null?void 0:r.title)??"Pick a task from the runway"}),e.jsx("div",{className:`mt-2 text-sm leading-6 ${u}`,children:(r==null?void 0:r.description)??"Once a task is active, the timer rail and this panel stay aligned."}),r?e.jsx("button",{type:"button",className:"mt-4 inline-flex min-h-10 max-w-full items-center justify-center rounded-2xl border border-[color-mix(in_srgb,var(--primary)_24%,transparent)] bg-[var(--ui-accent-soft)] px-3.5 py-2 text-sm font-medium text-[var(--primary)] shadow-[var(--ui-shadow-soft)] transition hover:bg-[var(--ui-accent-soft-hover)]",onClick:async()=>{await t.startTaskNow(r.id)},children:"Start work"}):null]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:`${R} p-4`,children:[e.jsx("div",{className:g,children:"Recovery task"}),e.jsx("div",{className:`mt-3 break-words text-sm font-semibold ${v}`,children:(f==null?void 0:f.title)??"No blocked or overdue task is dominating today"}),i?null:e.jsx("div",{className:`mt-2 text-sm leading-6 ${u}`,children:(f==null?void 0:f.description)??"If something slips, it will surface here as the clean comeback move."})]}),e.jsxs("div",{className:`${R} p-4`,children:[e.jsx("div",{className:g,children:"Due habits"}),e.jsx("div",{className:"mt-3 grid gap-2",children:t.snapshot.today.dueHabits.slice(0,i?2:3).map(h=>e.jsxs("div",{className:`${I} flex items-center justify-between gap-3 px-3 py-2.5`,children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:`truncate text-sm font-medium ${v}`,children:h.title}),i?null:e.jsx("div",{className:`text-sm ${u}`,children:h.frequency})]}),e.jsxs(x,{className:"shrink-0 bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_78%,var(--ui-ink-strong)_22%)]",children:[h.rewardXp," xp"]})]},h.id))})]})]})]})})}},{id:"time",title:"Clock",description:"Optional utility widget.",defaultWidth:3,defaultHeight:2,defaultHidden:!0,render:({compact:i})=>e.jsx(ae,{compact:i})},{id:"weather",title:"Weather",description:"Optional utility widget.",defaultWidth:3,defaultHeight:2,defaultHidden:!0,render:({compact:i})=>e.jsx(ie,{compact:i})},{id:"mini-calendar",title:"Mini calendar",description:"Optional utility widget.",defaultWidth:4,defaultHeight:3,defaultHidden:!0,render:({compact:i})=>e.jsx(ne,{compact:i})},{id:"spotify",title:"Spotify",description:"Optional utility widget.",defaultWidth:4,defaultHeight:2,defaultHidden:!0,render:()=>e.jsx(re,{surfaceId:"today"})},{id:"quick-capture",title:"Quick capture",description:"Save a note or wiki draft without leaving Today.",defaultWidth:5,defaultHeight:3,defaultHidden:!0,render:({compact:i})=>{var n;return e.jsx(le,{compact:i,defaultUserId:t.selectedUserIds[0]??((n=t.snapshot.users[0])==null?void 0:n.id)??null})}}];return e.jsx(V,{surfaceId:"today",baseWidgets:y})}export{Ae as TodayPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as m,j as e,du as O,aL as K,bL as W,aH as B,cg as P,bF as F,dv as $,bG as V}from"./vendor-Dnkkx2co.js";import{i as G}from"./state-vCcAT5Hq.js";import{C as h,aq as p,c as N,u as q,S as U,E as Q,eL as Y}from"./index-BP9__l6C.js";import{e as Z,C as I,X as C,Y as k,T as _,B as y,d as H,a as X,c as D,i as J,P as ee,j as ae,k as ie,f as te}from"./charts-DFnEuIMB.js";import{P as re}from"./page-hero-DgnhI5es.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";function M({height:i,children:a}){const d=m.useRef(null),[n,o]=m.useState(0);return m.useEffect(()=>{const t=d.current;if(!t)return;const u=()=>{o(Math.max(0,Math.floor(t.getBoundingClientRect().width)))};if(u(),typeof ResizeObserver>"u")return window.addEventListener("resize",u),()=>window.removeEventListener("resize",u);const f=new ResizeObserver(u);return f.observe(t),()=>f.disconnect()},[]),e.jsx("div",{ref:d,style:{height:i},className:"min-w-0",children:n>24?a({width:n,height:i}):null})}const T=["below_z1","zone_1","zone_2","zone_3","zone_4","zone_5"],S={below_z1:"Below Z1",zone_1:"Z1",zone_2:"Z2",zone_3:"Z3",zone_4:"Z4",zone_5:"Z5"},se={below_z1:"var(--ui-ink-muted)",zone_1:"var(--info)",zone_2:"var(--success)",zone_3:"var(--warning)",zone_4:"var(--tertiary)",zone_5:"var(--danger)"},w={timeInZone:"Each block totals the minutes Forge can place into adaptive HRR zones from stored heart-rate samples. Weekly is the default planning view because it matches common training microcycles; monthly and daily views help detect longer trends or recent spikes.",smartMode:"Smart modes do not change the underlying data. They change the coaching lens: combat readiness prioritizes hard-day spacing and controlled high intensity, aerobic base prioritizes low-zone development, and endurance pro compares the distribution with pyramidal or polarized endurance planning patterns.",interpretation:"This paragraph explains what the selected mode concludes from the latest load balance, zone distribution, hard-day count, and data confidence. It is a planning summary, not a medical clearance.",drivers:"Drivers are the signals helping the selected mode: examples include enough easy/base work, controlled high-zone share, stable acute/chronic load, or improving data quality.",limiters:"Limiters are the signals that should constrain the next block. If Forge lists a limiter, the next target should usually solve that before adding more hard work.",targets:"Next targets translate the selected mode into a practical week and next workout. The range is intentionally bounded so training can progress without turning every good week into a maximal week."};function ne(i){return i.key==="combat_readiness"?"Combat":i.key==="aerobic_base"?"Base":"Endurance"}function de(i){return i>=82?"signal":i>=65?"default":"meta"}function oe(i){switch(i){case"vo2max_4x4":return"4x4 VO2max";case"zone_2_base":return"Zone 2 / base";case"technical_kickboxing":return"Technical kickboxing";case"easy_aerobic":return"Easy aerobic";case"recovery":return"Recovery";default:return i.replaceAll("_"," ")}}function le(i,a){return a==="daily"?i.bucketKey.slice(5):a==="monthly"?i.bucketKey.slice(2):i.bucketKey.replace(/^20/,"'")}function ce(i,a){const d=a==="daily"?30:12;return i.slice(-d).map(n=>({bucket:le(n,a),total:Math.round(n.durationMinutes),load:n.trainingLoad,confidence:n.confidence,...Object.fromEntries(T.map(o=>[o,n.zoneMinutes[o]??0]))}))}function ue(i,a){return i.zoneTimeSeries[a]}function xe({mode:i}){return e.jsxs("div",{className:"grid gap-3 lg:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-muted)]",children:[e.jsx(W,{className:"size-3.5"}),"Drivers",e.jsx(p,{label:"Explain training drivers",title:"Drivers",content:w.drivers})]}),e.jsx("div",{className:"mt-3 grid gap-2 text-[12px] leading-5 text-[var(--ui-ink-medium)]",children:(i.drivers.length>0?i.drivers:["No positive driver is strong enough yet."]).map(a=>e.jsx("div",{children:a},a))})]}),e.jsxs("div",{className:"rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-muted)]",children:[e.jsx(B,{className:"size-3.5"}),"Limiters",e.jsx(p,{label:"Explain training limiters",title:"Limiters",content:w.limiters})]}),e.jsx("div",{className:"mt-3 grid gap-2 text-[12px] leading-5 text-[var(--ui-ink-medium)]",children:(i.limitingFactors.length>0?i.limitingFactors:["No major limiter in this mode right now."]).map(a=>e.jsx("div",{children:a},a))})]})]})}function me({trainingLoad:i}){const[a,d]=m.useState(i.trainingIntelligence.defaultMode),[n,o]=m.useState("weekly"),t=i.trainingIntelligence.modes.find(r=>r.key===a)??i.trainingIntelligence.modes[0],u=ue(i,n),f=m.useMemo(()=>ce(u,n),[u,n]),L=u.slice(-8).reverse();return t?e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.25fr)_minmax(340px,0.75fr)]",children:[e.jsxs(h,{className:"overflow-hidden",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-1.5",children:[e.jsx("div",{className:"font-label text-[10px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Zone intelligence"}),e.jsx(p,{label:"Explain zone intelligence",title:"Time in zone",content:w.timeInZone})]}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:"Time in zone by training block"}),e.jsx("div",{className:"mt-1 max-w-2xl text-[12px] leading-5 text-[var(--ui-ink-muted)]",children:"Weekly by default because most training plans are adjusted week by week. The stacked bars preserve the full zone split, while the table adds load rate, hard days, and data confidence."})]}),e.jsx("div",{className:"grid grid-cols-3 gap-1 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-1",children:[["weekly","Week"],["monthly","Month"],["daily","90d"]].map(([r,c])=>e.jsx("button",{type:"button",className:`rounded-[6px] px-3 py-1.5 text-[12px] ${n===r?"bg-[var(--ui-surface-2)] text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-muted)]"}`,onClick:()=>o(r),children:c},r))})]}),e.jsx("div",{className:"mt-5",children:e.jsx(M,{height:320,children:({width:r,height:c})=>e.jsxs(Z,{data:f,width:r,height:c,children:[e.jsx(I,{stroke:"var(--ui-border-subtle)",vertical:!1}),e.jsx(C,{dataKey:"bucket",tick:{fill:"var(--ui-ink-muted)",fontSize:10}}),e.jsx(k,{tick:{fill:"var(--ui-ink-muted)",fontSize:10},width:42}),e.jsx(_,{formatter:(v,l)=>[`${Number(v).toFixed(0)} min`,S[l]??String(l)],contentStyle:{background:"var(--ui-surface-modal)",border:"1px solid var(--ui-border-subtle)",borderRadius:8,color:"var(--ui-ink-strong)"}}),T.map(v=>e.jsx(y,{dataKey:v,stackId:"zones",fill:se[v],name:v},v))]})})}),e.jsx("div",{className:"mt-4 grid gap-3 md:hidden",children:L.map(r=>e.jsxs("div",{className:"rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold text-[var(--ui-ink-strong)]",children:r.bucketKey}),e.jsxs("div",{className:"mt-1 text-xs leading-5 text-[var(--ui-ink-muted)]",children:["Load ",r.trainingLoad," · ",r.loadPerMinute," ","TRIMP/min"]})]}),e.jsx(N,{tone:"meta",children:r.confidence})]}),e.jsx("div",{className:"mt-3 grid grid-cols-2 gap-2 text-[12px] min-[360px]:grid-cols-3",children:T.map(c=>e.jsxs("div",{className:"rounded-[8px] bg-[var(--ui-surface-2)] px-2 py-1.5",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-[0.12em] text-[var(--ui-ink-muted)]",children:S[c]}),e.jsxs("div",{className:"mt-0.5 text-[var(--ui-ink-medium)]",children:[r.zoneMinutes[c]," min"]})]},c))}),e.jsxs("div",{className:"mt-3 text-xs leading-5 text-[var(--ui-ink-muted)]",children:[r.hardDayCount," hard day",r.hardDayCount===1?"":"s"," in this block."]})]},r.bucketKey))}),e.jsxs("div",{className:"mt-4 hidden overflow-x-auto rounded-[8px] border border-[var(--ui-border-subtle)] md:block",children:[e.jsxs("div",{className:"grid min-w-[760px] grid-cols-[96px_72px_72px_repeat(6,64px)_72px_80px] bg-[var(--ui-surface-2)] px-3 py-2 text-[10px] uppercase tracking-[0.14em] text-[var(--ui-ink-muted)]",children:[e.jsx("div",{children:"Block"}),e.jsx("div",{children:"Load"}),e.jsx("div",{children:"TRIMP/min"}),T.map(r=>e.jsx("div",{children:S[r]},r)),e.jsx("div",{children:"Hard"}),e.jsx("div",{children:"Quality"})]}),L.map(r=>e.jsxs("div",{className:"grid min-w-[760px] grid-cols-[96px_72px_72px_repeat(6,64px)_72px_80px] border-t border-[var(--ui-border-subtle)] px-3 py-2 text-[12px] text-[var(--ui-ink-medium)]",children:[e.jsx("div",{className:"text-[var(--ui-ink-strong)]",children:r.bucketKey}),e.jsx("div",{children:r.trainingLoad}),e.jsx("div",{children:r.loadPerMinute}),T.map(c=>e.jsx("div",{children:r.zoneMinutes[c]},c)),e.jsx("div",{children:r.hardDayCount}),e.jsx("div",{children:r.confidence})]},r.bucketKey))]})]}),e.jsxs(h,{className:"overflow-hidden",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-1.5",children:[e.jsx("div",{className:"font-label text-[10px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Smart training mode"}),e.jsx(p,{label:"Explain smart training modes",title:"Training mode",content:w.smartMode})]}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:t.label})]}),e.jsxs(N,{tone:de(t.score),children:[t.score,"/100"]})]}),e.jsx("div",{className:"mt-4 grid grid-cols-3 gap-1 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-1",children:i.trainingIntelligence.modes.map(r=>e.jsx("button",{type:"button",className:`rounded-[6px] px-2 py-2 text-[12px] ${r.key===t.key?"bg-[var(--ui-surface-2)] text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-muted)]"}`,onClick:()=>d(r.key),children:ne(r)},r.key))}),e.jsxs("div",{className:"mt-4 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-muted)]",children:[e.jsx(O,{className:"size-3.5"}),"Interpretation",e.jsx(p,{label:"Explain this interpretation",title:"Interpretation",content:w.interpretation})]}),e.jsx("div",{className:"mt-3 text-[13px] leading-5 text-[var(--ui-ink-medium)]",children:t.summary}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-[11px] text-[var(--ui-ink-muted)]",children:[e.jsxs("div",{children:["Balance: ",t.loadBalance.status]}),e.jsxs("div",{children:["Confidence: ",t.confidence]}),e.jsxs("div",{children:["ACWR: ",t.loadBalance.acuteChronicRatio??"n/a"]}),e.jsxs("div",{children:["Baseline:"," ",t.loadBalance.latestWeekBaselineLoadRatio??"n/a","x"]})]})]}),e.jsx("div",{className:"mt-4",children:e.jsx(xe,{mode:t})}),e.jsxs("div",{className:"mt-4 grid gap-3 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-muted)]",children:[e.jsx(K,{className:"size-3.5"}),"Next targets",e.jsx(p,{label:"Explain next training targets",title:"Next targets",content:w.targets})]}),e.jsxs("div",{className:"grid gap-2 text-[12px] leading-5 text-[var(--ui-ink-medium)]",children:[e.jsxs("div",{children:["Next week: ",t.nextWeekTargets.totalMinutesRange[0],"-",t.nextWeekTargets.totalMinutesRange[1]," min · max"," ",t.nextWeekTargets.maxHardSessions," hard sessions · at least ",t.nextWeekTargets.minimumEasyMinutes," easy/base min."]}),e.jsxs("div",{children:["Next workout:"," ",e.jsx("span",{className:"text-[var(--ui-ink-strong)]",children:oe(t.nextWorkout.recommendedType)})," ","for ",t.nextWorkout.durationMinutesRange[0],"-",t.nextWorkout.durationMinutesRange[1]," min, ceiling"," ",t.nextWorkout.intensityCeiling,"."]}),e.jsx("div",{className:"text-[var(--ui-ink-muted)]",children:t.nextWorkout.reason}),t.nextWeekTargets.warning?e.jsx("div",{className:"rounded-[6px] bg-[var(--ui-warning-soft)] px-2 py-1 text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]",children:t.nextWeekTargets.warning}):null]})]})]})]}):null}const he={low:"var(--success)",moderate:"var(--warning)",high:"var(--danger)"},ge={below_z1:"var(--ui-ink-muted)",zone_1:"var(--info)",zone_2:"var(--success)",zone_3:"var(--warning)",zone_4:"var(--tertiary)",zone_5:"var(--danger)"},x={hero:"Forge estimates cardiovascular training stress from stored workouts, heart-rate samples, adaptive heart-rate-reserve zones, and recent vitals. Use this page to decide whether the next training block should build aerobic base, hold load steady, sharpen intensity, or recover. The numbers support coaching decisions; they are not medical diagnosis.",acuteLoad:"Acute load is the last seven days of Forge's TRIMP-like internal load. It rises when workouts are longer, harder, or spend more time in high heart-rate zones. Compare it with chronic load before adding hard sessions.",chronicBase:"Chronic base is the average weekly load over the last 28 days. It is Forge's estimate of the current load you have recently proven you can absorb.",acwr:"ACWR is acute load divided by chronic weekly load. Values near 1.0 usually mean the current week resembles the recent base. High values ask for recovery checks; low values suggest underloading. Treat it as a flag, not a verdict.",vo2max:"VO2max is the latest available wearable estimate in ml/kg/min. Forge shows the recent change when enough points exist, but wearable VO2max can move with device model, terrain, heat, and workout type.",weeklyMap:"This chart combines weekly internal load, training hours, and the share of time in zones 4 and 5. It helps reveal whether fatigue comes from total volume, hard intensity, or both.",adaptationRadar:"The radar compresses six signals into one coach view: current load, base capacity, acute/chronic balance, heart-rate data quality, high-intensity pressure, and VO2max movement.",intensityTarget:"This compares your recent or all-time low, moderate, and high intensity distribution with broad target bands used in endurance and combat-sport conditioning. The target is a planning reference, not a rule.",hrZones:"These bars show minutes in each adaptive HRR zone. Zone 2 is commonly used for aerobic base, zones 4 and 5 for threshold and VO2max work, and below-zone time often reflects warm-up, recovery, or missing cardiovascular load.",dailyTexture:"Daily texture shows whether load spikes are coming from easy volume, threshold work, or high-intensity minutes. It is useful for spacing hard days and avoiding accidental clusters.",sessionSignals:"Recent workout rows expose the session evidence behind the summary: date, activity, training load, high-zone share, heart-rate response, and data confidence.",sportContribution:"Sport contribution groups load by workout type. In kickboxing and other combat sports, wrist heart rate can undercount short striking spikes, so compare this with how the session actually felt."};function A(i,a=0){return i==null||Number.isNaN(i)?"n/a":`${(i*100).toFixed(a)}%`}function b(i,a=0){return i==null||Number.isNaN(i)?"n/a":i.toFixed(a)}function ve(i){switch(i){case"productive":return{label:"Productive",tone:"signal",text:"Acute load is close to the current chronic base."};case"underloaded":return{label:"Underloaded",tone:"meta",text:"The recent week is below the four-week baseline."};case"overload_watch":return{label:"Watch load",tone:"default",text:"Acute load or strain is elevated enough to deserve recovery checks."};default:return{label:"Building signal",tone:"meta",text:"Forge needs more recent training evidence for a cleaner read."}}}function R({label:i,value:a,detail:d,help:n,icon:o}){return e.jsxs(h,{className:"relative min-h-[136px] overflow-hidden",children:[e.jsx("div",{className:"absolute right-3 top-3 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-2 text-[var(--ui-ink-muted)]",children:e.jsx(o,{className:"size-4"})}),e.jsxs("div",{className:"flex max-w-[80%] items-center gap-1.5",children:[e.jsx("div",{className:"font-label text-[10px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:i}),e.jsx(p,{label:`Explain ${i}`,title:i,content:n})]}),e.jsx("div",{className:"mt-4 font-display text-4xl leading-none text-[var(--ui-ink-strong)]",children:a}),e.jsx("div",{className:"mt-3 max-w-[24rem] text-[12px] leading-5 text-[var(--ui-ink-muted)]",children:d})]})}function j({eyebrow:i,title:a,description:d,help:n,action:o}){return 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 items-center gap-1.5",children:[e.jsx("div",{className:"font-label text-[10px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:i}),e.jsx(p,{label:`Explain ${i}`,title:a,content:n})]}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:a}),d?e.jsx("div",{className:"mt-1 max-w-2xl text-[12px] leading-5 text-[var(--ui-ink-muted)]",children:d}):null]}),o?e.jsx("div",{className:"shrink-0",children:o}):null]})}function pe(i){return i.weeklyLoad.map(a=>({week:a.weekKey.replace(/^20/,"'"),load:a.trainingLoad,hours:a.durationHours,loadPerHour:a.loadPerHour,high:Math.round(a.highPercentage*100),moderate:Math.round(a.moderatePercentage*100),low:Math.round(a.lowPercentage*100)}))}function be(i){return i.dailyLoad.map(a=>({date:a.dateKey.slice(5),load:a.trainingLoad,high:a.highIntensityMinutes,moderate:a.moderateIntensityMinutes,low:a.lowIntensityMinutes}))}function je(i,a){return(a==="recent"?i.recentIntensityDistribution:i.intensityDistribution).map(n=>({...n,percent:Math.round(n.percentage*100),targetLow:Math.round(n.targetRange[0]*100),targetHigh:Math.round(n.targetRange[1]*100),fill:he[n.key]??"var(--ui-ink-medium)"}))}function fe(i,a){return(a==="recent"?i.recentZoneTotals:i.zoneTotals).map(n=>({...n,minutes:Math.round(n.seconds/60),percent:Math.round(n.percentage*100),fill:ge[n.key]??"var(--ui-ink-medium)"}))}function ke(i){const a=i.summary,d=a.acuteChronicRatio==null?45:Math.max(0,Math.min(100,100-Math.abs(a.acuteChronicRatio-1)*80));return[{axis:"Load",value:Math.min(100,a.acuteLoad7d/3)},{axis:"Base",value:Math.min(100,a.chronicWeeklyLoad28d/3)},{axis:"Balance",value:d},{axis:"Quality",value:Math.min(100,a.averageHeartRateCoverage*100)},{axis:"High",value:Math.min(100,a.highIntensityMinutes7d*1.8)},{axis:"VO2",value:a.vo2MaxDelta==null?50:Math.max(0,Math.min(100,50+a.vo2MaxDelta*10))}]}function ye({sessions:i}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid gap-3 md:hidden",children:i.slice(0,20).map(a=>e.jsxs("div",{className:"rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3",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:"truncate text-sm font-medium text-[var(--ui-ink-medium)]",children:a.workoutTypeLabel}),e.jsxs("div",{className:"mt-1 text-[11px] text-[var(--ui-ink-muted)]",children:[a.dateKey.slice(5)," ·"," ",b(a.durationMinutes,0),"m ·"," ",a.confidence]})]}),e.jsxs(N,{tone:"meta",children:[b(a.trainingLoad,0)," load"]})]}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-[12px] text-[var(--ui-ink-medium)]",children:[e.jsxs("div",{className:"rounded-[8px] bg-[var(--ui-surface-2)] px-2 py-1.5",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-[0.14em] text-[var(--ui-ink-muted)]",children:"Z4+Z5"}),e.jsx("div",{className:"mt-0.5 text-[var(--ui-ink-strong)]",children:A(a.highIntensityPercentage)})]}),e.jsxs("div",{className:"rounded-[8px] bg-[var(--ui-surface-2)] px-2 py-1.5",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-[0.14em] text-[var(--ui-ink-muted)]",children:"HR"}),e.jsxs("div",{className:"mt-0.5 text-[var(--ui-ink-strong)]",children:[a.averageHr?Math.round(a.averageHr):"n/a",a.maxHr?`/${Math.round(a.maxHr)}`:""]})]})]})]},a.id))}),e.jsxs("div",{className:"hidden overflow-hidden rounded-[8px] border border-[var(--ui-border-subtle)] md:block",children:[e.jsxs("div",{className:"grid grid-cols-[88px_minmax(118px,1fr)_64px_72px_72px] bg-[var(--ui-surface-2)] px-3 py-2 text-[10px] uppercase tracking-[0.16em] text-[var(--ui-ink-muted)]",children:[e.jsx("div",{children:"Date"}),e.jsx("div",{children:"Session"}),e.jsx("div",{children:"Load"}),e.jsx("div",{children:"Z4+Z5"}),e.jsx("div",{children:"HR"})]}),e.jsx("div",{className:"max-h-[370px] overflow-auto",children:i.slice(0,20).map(a=>e.jsxs("div",{className:"grid grid-cols-[88px_minmax(118px,1fr)_64px_72px_72px] border-t border-[var(--ui-border-subtle)] px-3 py-2 text-[12px] text-[var(--ui-ink-medium)]",children:[e.jsx("div",{className:"text-[var(--ui-ink-strong)]/52",children:a.dateKey.slice(5)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-[var(--ui-ink-medium)]",children:a.workoutTypeLabel}),e.jsxs("div",{className:"mt-0.5 text-[10px] text-[var(--ui-ink-muted)]",children:[b(a.durationMinutes,0),"m ·"," ",a.confidence]})]}),e.jsx("div",{className:"text-[var(--ui-ink-strong)]",children:b(a.trainingLoad,0)}),e.jsx("div",{children:A(a.highIntensityPercentage)}),e.jsxs("div",{children:[a.averageHr?Math.round(a.averageHr):"n/a",a.maxHr?`/${Math.round(a.maxHr)}`:""]})]},a.id))})]})]})}function Se(){const i=q(),a=Array.isArray(i.selectedUserIds)?i.selectedUserIds:[],[d,n]=m.useState("recent"),o=G({queryKey:["forge-training-load",...a],queryFn:async()=>(await Y(a)).trainingLoad}),t=o.data,u=ve((t==null?void 0:t.summary.readiness)??"insufficient_data"),f=m.useMemo(()=>t?pe(t):[],[t]),L=m.useMemo(()=>t?be(t):[],[t]),r=m.useMemo(()=>t?je(t,d):[],[d,t]),c=m.useMemo(()=>t?fe(t,d):[],[d,t]),v=m.useMemo(()=>t?ke(t):[],[t]);if(o.isLoading)return e.jsx(U,{eyebrow:"Training Load",title:"Loading cardiovascular model",description:"Computing acute load, zone distribution, and target bands from workout evidence.",columns:3,blocks:8});if(o.isError||!t)return e.jsx(Q,{eyebrow:"Training Load",error:o.error??new Error("Training load data unavailable"),onRetry:()=>void o.refetch()});const{summary:l}=t;return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(re,{eyebrow:"Health",entityKind:"habit",title:"Training Load",titleText:"Training Load",description:"Forge estimates cardiovascular training stress from workout duration, heart-rate response, adaptive HRR zones, and recent vitals so you can plan the next training block with clearer load and recovery context.",helpContent:x.hero,badge:`${l.sessionCount} sessions · ${l.reliableSessionCount} high-resolution`,actions:e.jsx(N,{tone:u.tone,children:u.label})}),e.jsxs("section",{className:"grid gap-4 lg:grid-cols-4",children:[R({label:"Acute load",value:b(l.acuteLoad7d,0),detail:`Last 7 days of internal load. ${u.text}`,help:x.acuteLoad,icon:F}),R({label:"Chronic base",value:b(l.chronicWeeklyLoad28d,0),detail:"Average weekly load across the last 28 days.",help:x.chronicBase,icon:$}),R({label:"ACWR",value:b(l.acuteChronicRatio,2),detail:"Acute load divided by chronic weekly load. Useful as a flag, not a verdict.",help:x.acwr,icon:W}),R({label:"VO2 max",value:l.vo2MaxLatest?b(l.vo2MaxLatest,1):"n/a",detail:l.vo2MaxDelta==null?"No delta available yet.":`${l.vo2MaxDelta>=0?"+":""}${l.vo2MaxDelta} since the first recent point.`,help:x.vo2max,icon:V})]}),e.jsx(me,{trainingLoad:t}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.35fr)_minmax(320px,0.65fr)]",children:[e.jsxs(h,{className:"overflow-hidden",children:[e.jsx(j,{eyebrow:"Weekly load map",title:"Load, hours, and high-intensity share over the last 26 weeks.",description:"Load estimates internal stress; hours show volume; the red line shows how much of each week landed in zones 4 and 5.",help:x.weeklyMap,action:e.jsx(N,{tone:"meta",children:"TRIMP · HRR zones"})}),e.jsx("div",{className:"mt-5",children:e.jsx(M,{height:340,children:({width:s,height:g})=>e.jsxs(H,{data:f,width:s,height:g,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"trainingLoadFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--info)",stopOpacity:.38}),e.jsx("stop",{offset:"100%",stopColor:"var(--info)",stopOpacity:.04})]})}),e.jsx(I,{stroke:"var(--ui-border-subtle)",vertical:!1}),e.jsx(C,{dataKey:"week",tick:{fill:"var(--ui-ink-muted)",fontSize:10}}),e.jsx(k,{yAxisId:"load",tick:{fill:"var(--ui-ink-muted)",fontSize:10},width:42}),e.jsx(k,{yAxisId:"pct",orientation:"right",domain:[0,100],tick:{fill:"var(--ui-ink-muted)",fontSize:10},width:38}),e.jsx(_,{contentStyle:{background:"var(--ui-surface-modal)",border:"1px solid var(--ui-border-subtle)",borderRadius:8,color:"var(--ui-ink-strong)"}}),e.jsx(X,{yAxisId:"load",type:"monotone",dataKey:"load",name:"Training load",stroke:"var(--info)",fill:"url(#trainingLoadFill)",strokeWidth:2}),e.jsx(y,{yAxisId:"load",dataKey:"hours",name:"Hours",fill:"var(--primary)",radius:[3,3,0,0]}),e.jsx(D,{yAxisId:"pct",type:"monotone",dataKey:"high",name:"Z4+Z5 %",stroke:"var(--danger)",strokeWidth:2.4,dot:{r:2}})]})})})]}),e.jsxs(h,{className:"overflow-hidden",children:[e.jsx(j,{eyebrow:"Adaptation radar",title:"Current signal balance",description:"A compact coach view of load, base, balance, data quality, high-intensity pressure, and VO2max movement.",help:x.adaptationRadar}),e.jsx("div",{className:"mt-4",children:e.jsx(M,{height:300,children:({width:s,height:g})=>e.jsxs(J,{data:v,width:s,height:g,children:[e.jsx(ee,{stroke:"var(--ui-border-subtle)"}),e.jsx(ae,{dataKey:"axis",tick:{fill:"var(--ui-ink-muted)",fontSize:10}}),e.jsx(ie,{dataKey:"value",stroke:"var(--success)",fill:"var(--success)",fillOpacity:.24}),e.jsx(_,{contentStyle:{background:"var(--ui-surface-modal)",border:"1px solid var(--ui-border-subtle)",borderRadius:8,color:"var(--ui-ink-strong)"}})]})})})]})]}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,0.8fr)_minmax(0,1.2fr)]",children:[e.jsxs(h,{children:[e.jsx(j,{eyebrow:"Intensity target",title:"Distribution vs target bands",description:"Compare the selected time window with broad low, moderate, and high intensity bands.",help:x.intensityTarget,action:e.jsx("div",{className:"grid grid-cols-2 gap-1 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-1",children:[["recent","28d"],["all","All"]].map(([s,g])=>e.jsx("button",{type:"button",className:`rounded-[6px] px-3 py-1.5 text-[12px] ${d===s?"bg-[var(--ui-surface-2)] text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-muted)]"}`,onClick:()=>n(s),children:g},s))})}),e.jsx("div",{className:"mt-4 grid gap-3",children:r.map(s=>e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-[12px]",children:[e.jsx("span",{className:"text-[var(--ui-ink-medium)]",children:s.label}),e.jsxs("span",{className:"text-[var(--ui-ink-strong)]",children:[s.percent,"% · target ",s.targetLow,"-",s.targetHigh,"%"]})]}),e.jsxs("div",{className:"relative h-3 overflow-hidden rounded-full bg-[var(--ui-surface-2)]",children:[e.jsx("div",{className:"absolute inset-y-0 rounded-full bg-[var(--ui-surface-2)]",style:{left:`${s.targetLow}%`,width:`${Math.max(2,s.targetHigh-s.targetLow)}%`}}),e.jsx("div",{className:"relative h-full rounded-full",style:{width:`${Math.max(1,s.percent)}%`,background:s.fill}})]})]},s.key))}),e.jsx("div",{className:"mt-5 grid gap-2 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3 text-[12px] leading-5 text-[var(--ui-ink-muted)]",children:t.targetModel.monitoringNotes.map(s=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{className:"mt-0.5 size-3.5 shrink-0 text-[var(--primary)]"}),e.jsx("span",{children:s})]},s))})]}),e.jsxs(h,{children:[e.jsx(j,{eyebrow:"HR zones",title:`Detailed zone distribution for ${d==="recent"?"the last 28 days":"all available sessions"}.`,help:x.hrZones}),e.jsx("div",{className:"mt-4",children:e.jsx(M,{height:290,children:({width:s,height:g})=>e.jsxs(Z,{data:c,width:s,height:g,children:[e.jsx(I,{stroke:"var(--ui-border-subtle)",vertical:!1}),e.jsx(C,{dataKey:"label",interval:0,tick:{fill:"var(--ui-ink-muted)",fontSize:10}}),e.jsx(k,{tick:{fill:"var(--ui-ink-muted)",fontSize:10},width:38}),e.jsx(_,{formatter:(z,E)=>[E==="minutes"?`${z} min`:`${z}%`,E],contentStyle:{background:"var(--ui-surface-modal)",border:"1px solid var(--ui-border-subtle)",borderRadius:8,color:"var(--ui-ink-strong)"}}),e.jsx(y,{dataKey:"minutes",name:"minutes",radius:[4,4,0,0],children:c.map(z=>e.jsx(te,{fill:z.fill},z.key))})]})})})]})]}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1fr)_420px]",children:[e.jsxs(h,{children:[e.jsx(j,{eyebrow:"Daily load texture",title:"Easy, threshold, and high-intensity minutes against daily load.",help:x.dailyTexture}),e.jsx("div",{className:"mt-4",children:e.jsx(M,{height:310,children:({width:s,height:g})=>e.jsxs(H,{data:L,width:s,height:g,children:[e.jsx(I,{stroke:"var(--ui-border-subtle)",vertical:!1}),e.jsx(C,{dataKey:"date",tick:{fill:"var(--ui-ink-muted)",fontSize:10}}),e.jsx(k,{yAxisId:"minutes",tick:{fill:"var(--ui-ink-muted)",fontSize:10},width:38}),e.jsx(k,{yAxisId:"load",orientation:"right",tick:{fill:"var(--ui-ink-muted)",fontSize:10},width:38}),e.jsx(_,{contentStyle:{background:"var(--ui-surface-modal)",border:"1px solid var(--ui-border-subtle)",borderRadius:8,color:"var(--ui-ink-strong)"}}),e.jsx(y,{yAxisId:"minutes",dataKey:"low",stackId:"zones",fill:"var(--success)",name:"low min"}),e.jsx(y,{yAxisId:"minutes",dataKey:"moderate",stackId:"zones",fill:"var(--warning)",name:"threshold min"}),e.jsx(y,{yAxisId:"minutes",dataKey:"high",stackId:"zones",fill:"var(--danger)",name:"high min"}),e.jsx(D,{yAxisId:"load",type:"monotone",dataKey:"load",stroke:"var(--info)",strokeWidth:2.2,dot:!1})]})})})]}),e.jsxs(h,{children:[e.jsx(j,{eyebrow:"Session signals",title:"Recent workouts",help:x.sessionSignals,action:e.jsxs(N,{tone:"meta",children:[l.hardDayCount7d," hard days / 7d"]})}),e.jsx("div",{className:"mt-4",children:e.jsx(ye,{sessions:t.sessionSignals})})]})]}),e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",children:[e.jsxs(h,{children:[e.jsx(j,{eyebrow:"Sport contribution",title:"Load by workout type",help:x.sportContribution}),e.jsx("div",{className:"mt-3 grid gap-3",children:t.activityBreakdown.slice(0,8).map(s=>e.jsxs("div",{className:"grid gap-2 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3 sm:grid-cols-[minmax(0,1fr)_76px_76px_76px]",children:[e.jsxs("div",{children:[e.jsx("div",{className:"truncate text-sm text-[var(--ui-ink-strong)]",children:s.workoutTypeLabel}),e.jsxs("div",{className:"mt-1 text-[11px] text-[var(--ui-ink-muted)]",children:[s.sessionCount," sessions ·"," ",s.activityFamilyLabel]})]}),e.jsxs("div",{className:"text-[12px] text-[var(--ui-ink-medium)]",children:[e.jsxs("span",{className:"block text-[var(--ui-ink-strong)]",children:[s.durationHours,"h"]}),"volume"]}),e.jsxs("div",{className:"text-[12px] text-[var(--ui-ink-medium)]",children:[e.jsx("span",{className:"block text-[var(--ui-ink-strong)]",children:s.trainingLoad}),"load"]}),e.jsxs("div",{className:"text-[12px] text-[var(--ui-ink-medium)]",children:[e.jsx("span",{className:"block text-[var(--ui-ink-strong)]",children:A(s.highPercentage)}),"high"]})]},s.workoutType))})]}),e.jsxs(h,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(P,{className:"size-4 text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]"}),e.jsx("div",{className:"font-label text-[10px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Interpretation guardrails"})]}),e.jsxs("div",{className:"mt-4 grid gap-3 text-[12px] leading-5 text-[var(--ui-ink-muted)]",children:[e.jsx("p",{children:"Forge is estimating training stress from heart-rate reserve zones and a TRIMP-like load. This is good for trend decisions, but it is not a substitute for lactate testing, gas exchange thresholds, or coach-led periodization."}),e.jsx("p",{children:"Combat sports add sensor noise: wrist HR can miss short spikes during punching and clinch work. Treat high-intensity minutes as minimum evidence when the session had a lot of arm motion."}),e.jsx("p",{children:"The practical target is not maximum Z5. Keep hard combat sessions meaningful, then add easy aerobic base when the high-intensity share is already high."})]})]})]})]})}export{Se as TrainingLoadPage};
|
|
1
|
+
import{r as m,j as e,du as O,aL as K,bL as W,aH as B,cg as P,bF as F,dv as $,bG as V}from"./vendor-Dnkkx2co.js";import{i as G}from"./state-vCcAT5Hq.js";import{C as h,aq as p,c as N,u as q,S as U,E as Q,eL as Y}from"./index-By3tQxiE.js";import{e as Z,C as I,X as C,Y as k,T as _,B as y,d as H,a as X,c as D,i as J,P as ee,j as ae,k as ie,f as te}from"./charts-DFnEuIMB.js";import{P as re}from"./page-hero-5RTqAI88.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";function M({height:i,children:a}){const d=m.useRef(null),[n,o]=m.useState(0);return m.useEffect(()=>{const t=d.current;if(!t)return;const u=()=>{o(Math.max(0,Math.floor(t.getBoundingClientRect().width)))};if(u(),typeof ResizeObserver>"u")return window.addEventListener("resize",u),()=>window.removeEventListener("resize",u);const f=new ResizeObserver(u);return f.observe(t),()=>f.disconnect()},[]),e.jsx("div",{ref:d,style:{height:i},className:"min-w-0",children:n>24?a({width:n,height:i}):null})}const T=["below_z1","zone_1","zone_2","zone_3","zone_4","zone_5"],S={below_z1:"Below Z1",zone_1:"Z1",zone_2:"Z2",zone_3:"Z3",zone_4:"Z4",zone_5:"Z5"},se={below_z1:"var(--ui-ink-muted)",zone_1:"var(--info)",zone_2:"var(--success)",zone_3:"var(--warning)",zone_4:"var(--tertiary)",zone_5:"var(--danger)"},w={timeInZone:"Each block totals the minutes Forge can place into adaptive HRR zones from stored heart-rate samples. Weekly is the default planning view because it matches common training microcycles; monthly and daily views help detect longer trends or recent spikes.",smartMode:"Smart modes do not change the underlying data. They change the coaching lens: combat readiness prioritizes hard-day spacing and controlled high intensity, aerobic base prioritizes low-zone development, and endurance pro compares the distribution with pyramidal or polarized endurance planning patterns.",interpretation:"This paragraph explains what the selected mode concludes from the latest load balance, zone distribution, hard-day count, and data confidence. It is a planning summary, not a medical clearance.",drivers:"Drivers are the signals helping the selected mode: examples include enough easy/base work, controlled high-zone share, stable acute/chronic load, or improving data quality.",limiters:"Limiters are the signals that should constrain the next block. If Forge lists a limiter, the next target should usually solve that before adding more hard work.",targets:"Next targets translate the selected mode into a practical week and next workout. The range is intentionally bounded so training can progress without turning every good week into a maximal week."};function ne(i){return i.key==="combat_readiness"?"Combat":i.key==="aerobic_base"?"Base":"Endurance"}function de(i){return i>=82?"signal":i>=65?"default":"meta"}function oe(i){switch(i){case"vo2max_4x4":return"4x4 VO2max";case"zone_2_base":return"Zone 2 / base";case"technical_kickboxing":return"Technical kickboxing";case"easy_aerobic":return"Easy aerobic";case"recovery":return"Recovery";default:return i.replaceAll("_"," ")}}function le(i,a){return a==="daily"?i.bucketKey.slice(5):a==="monthly"?i.bucketKey.slice(2):i.bucketKey.replace(/^20/,"'")}function ce(i,a){const d=a==="daily"?30:12;return i.slice(-d).map(n=>({bucket:le(n,a),total:Math.round(n.durationMinutes),load:n.trainingLoad,confidence:n.confidence,...Object.fromEntries(T.map(o=>[o,n.zoneMinutes[o]??0]))}))}function ue(i,a){return i.zoneTimeSeries[a]}function xe({mode:i}){return e.jsxs("div",{className:"grid gap-3 lg:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-muted)]",children:[e.jsx(W,{className:"size-3.5"}),"Drivers",e.jsx(p,{label:"Explain training drivers",title:"Drivers",content:w.drivers})]}),e.jsx("div",{className:"mt-3 grid gap-2 text-[12px] leading-5 text-[var(--ui-ink-medium)]",children:(i.drivers.length>0?i.drivers:["No positive driver is strong enough yet."]).map(a=>e.jsx("div",{children:a},a))})]}),e.jsxs("div",{className:"rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-muted)]",children:[e.jsx(B,{className:"size-3.5"}),"Limiters",e.jsx(p,{label:"Explain training limiters",title:"Limiters",content:w.limiters})]}),e.jsx("div",{className:"mt-3 grid gap-2 text-[12px] leading-5 text-[var(--ui-ink-medium)]",children:(i.limitingFactors.length>0?i.limitingFactors:["No major limiter in this mode right now."]).map(a=>e.jsx("div",{children:a},a))})]})]})}function me({trainingLoad:i}){const[a,d]=m.useState(i.trainingIntelligence.defaultMode),[n,o]=m.useState("weekly"),t=i.trainingIntelligence.modes.find(r=>r.key===a)??i.trainingIntelligence.modes[0],u=ue(i,n),f=m.useMemo(()=>ce(u,n),[u,n]),L=u.slice(-8).reverse();return t?e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.25fr)_minmax(340px,0.75fr)]",children:[e.jsxs(h,{className:"overflow-hidden",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-1.5",children:[e.jsx("div",{className:"font-label text-[10px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Zone intelligence"}),e.jsx(p,{label:"Explain zone intelligence",title:"Time in zone",content:w.timeInZone})]}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:"Time in zone by training block"}),e.jsx("div",{className:"mt-1 max-w-2xl text-[12px] leading-5 text-[var(--ui-ink-muted)]",children:"Weekly by default because most training plans are adjusted week by week. The stacked bars preserve the full zone split, while the table adds load rate, hard days, and data confidence."})]}),e.jsx("div",{className:"grid grid-cols-3 gap-1 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-1",children:[["weekly","Week"],["monthly","Month"],["daily","90d"]].map(([r,c])=>e.jsx("button",{type:"button",className:`rounded-[6px] px-3 py-1.5 text-[12px] ${n===r?"bg-[var(--ui-surface-2)] text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-muted)]"}`,onClick:()=>o(r),children:c},r))})]}),e.jsx("div",{className:"mt-5",children:e.jsx(M,{height:320,children:({width:r,height:c})=>e.jsxs(Z,{data:f,width:r,height:c,children:[e.jsx(I,{stroke:"var(--ui-border-subtle)",vertical:!1}),e.jsx(C,{dataKey:"bucket",tick:{fill:"var(--ui-ink-muted)",fontSize:10}}),e.jsx(k,{tick:{fill:"var(--ui-ink-muted)",fontSize:10},width:42}),e.jsx(_,{formatter:(v,l)=>[`${Number(v).toFixed(0)} min`,S[l]??String(l)],contentStyle:{background:"var(--ui-surface-modal)",border:"1px solid var(--ui-border-subtle)",borderRadius:8,color:"var(--ui-ink-strong)"}}),T.map(v=>e.jsx(y,{dataKey:v,stackId:"zones",fill:se[v],name:v},v))]})})}),e.jsx("div",{className:"mt-4 grid gap-3 md:hidden",children:L.map(r=>e.jsxs("div",{className:"rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold text-[var(--ui-ink-strong)]",children:r.bucketKey}),e.jsxs("div",{className:"mt-1 text-xs leading-5 text-[var(--ui-ink-muted)]",children:["Load ",r.trainingLoad," · ",r.loadPerMinute," ","TRIMP/min"]})]}),e.jsx(N,{tone:"meta",children:r.confidence})]}),e.jsx("div",{className:"mt-3 grid grid-cols-2 gap-2 text-[12px] min-[360px]:grid-cols-3",children:T.map(c=>e.jsxs("div",{className:"rounded-[8px] bg-[var(--ui-surface-2)] px-2 py-1.5",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-[0.12em] text-[var(--ui-ink-muted)]",children:S[c]}),e.jsxs("div",{className:"mt-0.5 text-[var(--ui-ink-medium)]",children:[r.zoneMinutes[c]," min"]})]},c))}),e.jsxs("div",{className:"mt-3 text-xs leading-5 text-[var(--ui-ink-muted)]",children:[r.hardDayCount," hard day",r.hardDayCount===1?"":"s"," in this block."]})]},r.bucketKey))}),e.jsxs("div",{className:"mt-4 hidden overflow-x-auto rounded-[8px] border border-[var(--ui-border-subtle)] md:block",children:[e.jsxs("div",{className:"grid min-w-[760px] grid-cols-[96px_72px_72px_repeat(6,64px)_72px_80px] bg-[var(--ui-surface-2)] px-3 py-2 text-[10px] uppercase tracking-[0.14em] text-[var(--ui-ink-muted)]",children:[e.jsx("div",{children:"Block"}),e.jsx("div",{children:"Load"}),e.jsx("div",{children:"TRIMP/min"}),T.map(r=>e.jsx("div",{children:S[r]},r)),e.jsx("div",{children:"Hard"}),e.jsx("div",{children:"Quality"})]}),L.map(r=>e.jsxs("div",{className:"grid min-w-[760px] grid-cols-[96px_72px_72px_repeat(6,64px)_72px_80px] border-t border-[var(--ui-border-subtle)] px-3 py-2 text-[12px] text-[var(--ui-ink-medium)]",children:[e.jsx("div",{className:"text-[var(--ui-ink-strong)]",children:r.bucketKey}),e.jsx("div",{children:r.trainingLoad}),e.jsx("div",{children:r.loadPerMinute}),T.map(c=>e.jsx("div",{children:r.zoneMinutes[c]},c)),e.jsx("div",{children:r.hardDayCount}),e.jsx("div",{children:r.confidence})]},r.bucketKey))]})]}),e.jsxs(h,{className:"overflow-hidden",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-1.5",children:[e.jsx("div",{className:"font-label text-[10px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Smart training mode"}),e.jsx(p,{label:"Explain smart training modes",title:"Training mode",content:w.smartMode})]}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:t.label})]}),e.jsxs(N,{tone:de(t.score),children:[t.score,"/100"]})]}),e.jsx("div",{className:"mt-4 grid grid-cols-3 gap-1 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-1",children:i.trainingIntelligence.modes.map(r=>e.jsx("button",{type:"button",className:`rounded-[6px] px-2 py-2 text-[12px] ${r.key===t.key?"bg-[var(--ui-surface-2)] text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-muted)]"}`,onClick:()=>d(r.key),children:ne(r)},r.key))}),e.jsxs("div",{className:"mt-4 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-muted)]",children:[e.jsx(O,{className:"size-3.5"}),"Interpretation",e.jsx(p,{label:"Explain this interpretation",title:"Interpretation",content:w.interpretation})]}),e.jsx("div",{className:"mt-3 text-[13px] leading-5 text-[var(--ui-ink-medium)]",children:t.summary}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-[11px] text-[var(--ui-ink-muted)]",children:[e.jsxs("div",{children:["Balance: ",t.loadBalance.status]}),e.jsxs("div",{children:["Confidence: ",t.confidence]}),e.jsxs("div",{children:["ACWR: ",t.loadBalance.acuteChronicRatio??"n/a"]}),e.jsxs("div",{children:["Baseline:"," ",t.loadBalance.latestWeekBaselineLoadRatio??"n/a","x"]})]})]}),e.jsx("div",{className:"mt-4",children:e.jsx(xe,{mode:t})}),e.jsxs("div",{className:"mt-4 grid gap-3 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-muted)]",children:[e.jsx(K,{className:"size-3.5"}),"Next targets",e.jsx(p,{label:"Explain next training targets",title:"Next targets",content:w.targets})]}),e.jsxs("div",{className:"grid gap-2 text-[12px] leading-5 text-[var(--ui-ink-medium)]",children:[e.jsxs("div",{children:["Next week: ",t.nextWeekTargets.totalMinutesRange[0],"-",t.nextWeekTargets.totalMinutesRange[1]," min · max"," ",t.nextWeekTargets.maxHardSessions," hard sessions · at least ",t.nextWeekTargets.minimumEasyMinutes," easy/base min."]}),e.jsxs("div",{children:["Next workout:"," ",e.jsx("span",{className:"text-[var(--ui-ink-strong)]",children:oe(t.nextWorkout.recommendedType)})," ","for ",t.nextWorkout.durationMinutesRange[0],"-",t.nextWorkout.durationMinutesRange[1]," min, ceiling"," ",t.nextWorkout.intensityCeiling,"."]}),e.jsx("div",{className:"text-[var(--ui-ink-muted)]",children:t.nextWorkout.reason}),t.nextWeekTargets.warning?e.jsx("div",{className:"rounded-[6px] bg-[var(--ui-warning-soft)] px-2 py-1 text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]",children:t.nextWeekTargets.warning}):null]})]})]})]}):null}const he={low:"var(--success)",moderate:"var(--warning)",high:"var(--danger)"},ge={below_z1:"var(--ui-ink-muted)",zone_1:"var(--info)",zone_2:"var(--success)",zone_3:"var(--warning)",zone_4:"var(--tertiary)",zone_5:"var(--danger)"},x={hero:"Forge estimates cardiovascular training stress from stored workouts, heart-rate samples, adaptive heart-rate-reserve zones, and recent vitals. Use this page to decide whether the next training block should build aerobic base, hold load steady, sharpen intensity, or recover. The numbers support coaching decisions; they are not medical diagnosis.",acuteLoad:"Acute load is the last seven days of Forge's TRIMP-like internal load. It rises when workouts are longer, harder, or spend more time in high heart-rate zones. Compare it with chronic load before adding hard sessions.",chronicBase:"Chronic base is the average weekly load over the last 28 days. It is Forge's estimate of the current load you have recently proven you can absorb.",acwr:"ACWR is acute load divided by chronic weekly load. Values near 1.0 usually mean the current week resembles the recent base. High values ask for recovery checks; low values suggest underloading. Treat it as a flag, not a verdict.",vo2max:"VO2max is the latest available wearable estimate in ml/kg/min. Forge shows the recent change when enough points exist, but wearable VO2max can move with device model, terrain, heat, and workout type.",weeklyMap:"This chart combines weekly internal load, training hours, and the share of time in zones 4 and 5. It helps reveal whether fatigue comes from total volume, hard intensity, or both.",adaptationRadar:"The radar compresses six signals into one coach view: current load, base capacity, acute/chronic balance, heart-rate data quality, high-intensity pressure, and VO2max movement.",intensityTarget:"This compares your recent or all-time low, moderate, and high intensity distribution with broad target bands used in endurance and combat-sport conditioning. The target is a planning reference, not a rule.",hrZones:"These bars show minutes in each adaptive HRR zone. Zone 2 is commonly used for aerobic base, zones 4 and 5 for threshold and VO2max work, and below-zone time often reflects warm-up, recovery, or missing cardiovascular load.",dailyTexture:"Daily texture shows whether load spikes are coming from easy volume, threshold work, or high-intensity minutes. It is useful for spacing hard days and avoiding accidental clusters.",sessionSignals:"Recent workout rows expose the session evidence behind the summary: date, activity, training load, high-zone share, heart-rate response, and data confidence.",sportContribution:"Sport contribution groups load by workout type. In kickboxing and other combat sports, wrist heart rate can undercount short striking spikes, so compare this with how the session actually felt."};function A(i,a=0){return i==null||Number.isNaN(i)?"n/a":`${(i*100).toFixed(a)}%`}function b(i,a=0){return i==null||Number.isNaN(i)?"n/a":i.toFixed(a)}function ve(i){switch(i){case"productive":return{label:"Productive",tone:"signal",text:"Acute load is close to the current chronic base."};case"underloaded":return{label:"Underloaded",tone:"meta",text:"The recent week is below the four-week baseline."};case"overload_watch":return{label:"Watch load",tone:"default",text:"Acute load or strain is elevated enough to deserve recovery checks."};default:return{label:"Building signal",tone:"meta",text:"Forge needs more recent training evidence for a cleaner read."}}}function R({label:i,value:a,detail:d,help:n,icon:o}){return e.jsxs(h,{className:"relative min-h-[136px] overflow-hidden",children:[e.jsx("div",{className:"absolute right-3 top-3 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-2 text-[var(--ui-ink-muted)]",children:e.jsx(o,{className:"size-4"})}),e.jsxs("div",{className:"flex max-w-[80%] items-center gap-1.5",children:[e.jsx("div",{className:"font-label text-[10px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:i}),e.jsx(p,{label:`Explain ${i}`,title:i,content:n})]}),e.jsx("div",{className:"mt-4 font-display text-4xl leading-none text-[var(--ui-ink-strong)]",children:a}),e.jsx("div",{className:"mt-3 max-w-[24rem] text-[12px] leading-5 text-[var(--ui-ink-muted)]",children:d})]})}function j({eyebrow:i,title:a,description:d,help:n,action:o}){return 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 items-center gap-1.5",children:[e.jsx("div",{className:"font-label text-[10px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:i}),e.jsx(p,{label:`Explain ${i}`,title:a,content:n})]}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:a}),d?e.jsx("div",{className:"mt-1 max-w-2xl text-[12px] leading-5 text-[var(--ui-ink-muted)]",children:d}):null]}),o?e.jsx("div",{className:"shrink-0",children:o}):null]})}function pe(i){return i.weeklyLoad.map(a=>({week:a.weekKey.replace(/^20/,"'"),load:a.trainingLoad,hours:a.durationHours,loadPerHour:a.loadPerHour,high:Math.round(a.highPercentage*100),moderate:Math.round(a.moderatePercentage*100),low:Math.round(a.lowPercentage*100)}))}function be(i){return i.dailyLoad.map(a=>({date:a.dateKey.slice(5),load:a.trainingLoad,high:a.highIntensityMinutes,moderate:a.moderateIntensityMinutes,low:a.lowIntensityMinutes}))}function je(i,a){return(a==="recent"?i.recentIntensityDistribution:i.intensityDistribution).map(n=>({...n,percent:Math.round(n.percentage*100),targetLow:Math.round(n.targetRange[0]*100),targetHigh:Math.round(n.targetRange[1]*100),fill:he[n.key]??"var(--ui-ink-medium)"}))}function fe(i,a){return(a==="recent"?i.recentZoneTotals:i.zoneTotals).map(n=>({...n,minutes:Math.round(n.seconds/60),percent:Math.round(n.percentage*100),fill:ge[n.key]??"var(--ui-ink-medium)"}))}function ke(i){const a=i.summary,d=a.acuteChronicRatio==null?45:Math.max(0,Math.min(100,100-Math.abs(a.acuteChronicRatio-1)*80));return[{axis:"Load",value:Math.min(100,a.acuteLoad7d/3)},{axis:"Base",value:Math.min(100,a.chronicWeeklyLoad28d/3)},{axis:"Balance",value:d},{axis:"Quality",value:Math.min(100,a.averageHeartRateCoverage*100)},{axis:"High",value:Math.min(100,a.highIntensityMinutes7d*1.8)},{axis:"VO2",value:a.vo2MaxDelta==null?50:Math.max(0,Math.min(100,50+a.vo2MaxDelta*10))}]}function ye({sessions:i}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid gap-3 md:hidden",children:i.slice(0,20).map(a=>e.jsxs("div",{className:"rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3",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:"truncate text-sm font-medium text-[var(--ui-ink-medium)]",children:a.workoutTypeLabel}),e.jsxs("div",{className:"mt-1 text-[11px] text-[var(--ui-ink-muted)]",children:[a.dateKey.slice(5)," ·"," ",b(a.durationMinutes,0),"m ·"," ",a.confidence]})]}),e.jsxs(N,{tone:"meta",children:[b(a.trainingLoad,0)," load"]})]}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-[12px] text-[var(--ui-ink-medium)]",children:[e.jsxs("div",{className:"rounded-[8px] bg-[var(--ui-surface-2)] px-2 py-1.5",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-[0.14em] text-[var(--ui-ink-muted)]",children:"Z4+Z5"}),e.jsx("div",{className:"mt-0.5 text-[var(--ui-ink-strong)]",children:A(a.highIntensityPercentage)})]}),e.jsxs("div",{className:"rounded-[8px] bg-[var(--ui-surface-2)] px-2 py-1.5",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-[0.14em] text-[var(--ui-ink-muted)]",children:"HR"}),e.jsxs("div",{className:"mt-0.5 text-[var(--ui-ink-strong)]",children:[a.averageHr?Math.round(a.averageHr):"n/a",a.maxHr?`/${Math.round(a.maxHr)}`:""]})]})]})]},a.id))}),e.jsxs("div",{className:"hidden overflow-hidden rounded-[8px] border border-[var(--ui-border-subtle)] md:block",children:[e.jsxs("div",{className:"grid grid-cols-[88px_minmax(118px,1fr)_64px_72px_72px] bg-[var(--ui-surface-2)] px-3 py-2 text-[10px] uppercase tracking-[0.16em] text-[var(--ui-ink-muted)]",children:[e.jsx("div",{children:"Date"}),e.jsx("div",{children:"Session"}),e.jsx("div",{children:"Load"}),e.jsx("div",{children:"Z4+Z5"}),e.jsx("div",{children:"HR"})]}),e.jsx("div",{className:"max-h-[370px] overflow-auto",children:i.slice(0,20).map(a=>e.jsxs("div",{className:"grid grid-cols-[88px_minmax(118px,1fr)_64px_72px_72px] border-t border-[var(--ui-border-subtle)] px-3 py-2 text-[12px] text-[var(--ui-ink-medium)]",children:[e.jsx("div",{className:"text-[var(--ui-ink-strong)]/52",children:a.dateKey.slice(5)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-[var(--ui-ink-medium)]",children:a.workoutTypeLabel}),e.jsxs("div",{className:"mt-0.5 text-[10px] text-[var(--ui-ink-muted)]",children:[b(a.durationMinutes,0),"m ·"," ",a.confidence]})]}),e.jsx("div",{className:"text-[var(--ui-ink-strong)]",children:b(a.trainingLoad,0)}),e.jsx("div",{children:A(a.highIntensityPercentage)}),e.jsxs("div",{children:[a.averageHr?Math.round(a.averageHr):"n/a",a.maxHr?`/${Math.round(a.maxHr)}`:""]})]},a.id))})]})]})}function Se(){const i=q(),a=Array.isArray(i.selectedUserIds)?i.selectedUserIds:[],[d,n]=m.useState("recent"),o=G({queryKey:["forge-training-load",...a],queryFn:async()=>(await Y(a)).trainingLoad}),t=o.data,u=ve((t==null?void 0:t.summary.readiness)??"insufficient_data"),f=m.useMemo(()=>t?pe(t):[],[t]),L=m.useMemo(()=>t?be(t):[],[t]),r=m.useMemo(()=>t?je(t,d):[],[d,t]),c=m.useMemo(()=>t?fe(t,d):[],[d,t]),v=m.useMemo(()=>t?ke(t):[],[t]);if(o.isLoading)return e.jsx(U,{eyebrow:"Training Load",title:"Loading cardiovascular model",description:"Computing acute load, zone distribution, and target bands from workout evidence.",columns:3,blocks:8});if(o.isError||!t)return e.jsx(Q,{eyebrow:"Training Load",error:o.error??new Error("Training load data unavailable"),onRetry:()=>void o.refetch()});const{summary:l}=t;return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(re,{eyebrow:"Health",entityKind:"habit",title:"Training Load",titleText:"Training Load",description:"Forge estimates cardiovascular training stress from workout duration, heart-rate response, adaptive HRR zones, and recent vitals so you can plan the next training block with clearer load and recovery context.",helpContent:x.hero,badge:`${l.sessionCount} sessions · ${l.reliableSessionCount} high-resolution`,actions:e.jsx(N,{tone:u.tone,children:u.label})}),e.jsxs("section",{className:"grid gap-4 lg:grid-cols-4",children:[R({label:"Acute load",value:b(l.acuteLoad7d,0),detail:`Last 7 days of internal load. ${u.text}`,help:x.acuteLoad,icon:F}),R({label:"Chronic base",value:b(l.chronicWeeklyLoad28d,0),detail:"Average weekly load across the last 28 days.",help:x.chronicBase,icon:$}),R({label:"ACWR",value:b(l.acuteChronicRatio,2),detail:"Acute load divided by chronic weekly load. Useful as a flag, not a verdict.",help:x.acwr,icon:W}),R({label:"VO2 max",value:l.vo2MaxLatest?b(l.vo2MaxLatest,1):"n/a",detail:l.vo2MaxDelta==null?"No delta available yet.":`${l.vo2MaxDelta>=0?"+":""}${l.vo2MaxDelta} since the first recent point.`,help:x.vo2max,icon:V})]}),e.jsx(me,{trainingLoad:t}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.35fr)_minmax(320px,0.65fr)]",children:[e.jsxs(h,{className:"overflow-hidden",children:[e.jsx(j,{eyebrow:"Weekly load map",title:"Load, hours, and high-intensity share over the last 26 weeks.",description:"Load estimates internal stress; hours show volume; the red line shows how much of each week landed in zones 4 and 5.",help:x.weeklyMap,action:e.jsx(N,{tone:"meta",children:"TRIMP · HRR zones"})}),e.jsx("div",{className:"mt-5",children:e.jsx(M,{height:340,children:({width:s,height:g})=>e.jsxs(H,{data:f,width:s,height:g,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"trainingLoadFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--info)",stopOpacity:.38}),e.jsx("stop",{offset:"100%",stopColor:"var(--info)",stopOpacity:.04})]})}),e.jsx(I,{stroke:"var(--ui-border-subtle)",vertical:!1}),e.jsx(C,{dataKey:"week",tick:{fill:"var(--ui-ink-muted)",fontSize:10}}),e.jsx(k,{yAxisId:"load",tick:{fill:"var(--ui-ink-muted)",fontSize:10},width:42}),e.jsx(k,{yAxisId:"pct",orientation:"right",domain:[0,100],tick:{fill:"var(--ui-ink-muted)",fontSize:10},width:38}),e.jsx(_,{contentStyle:{background:"var(--ui-surface-modal)",border:"1px solid var(--ui-border-subtle)",borderRadius:8,color:"var(--ui-ink-strong)"}}),e.jsx(X,{yAxisId:"load",type:"monotone",dataKey:"load",name:"Training load",stroke:"var(--info)",fill:"url(#trainingLoadFill)",strokeWidth:2}),e.jsx(y,{yAxisId:"load",dataKey:"hours",name:"Hours",fill:"var(--primary)",radius:[3,3,0,0]}),e.jsx(D,{yAxisId:"pct",type:"monotone",dataKey:"high",name:"Z4+Z5 %",stroke:"var(--danger)",strokeWidth:2.4,dot:{r:2}})]})})})]}),e.jsxs(h,{className:"overflow-hidden",children:[e.jsx(j,{eyebrow:"Adaptation radar",title:"Current signal balance",description:"A compact coach view of load, base, balance, data quality, high-intensity pressure, and VO2max movement.",help:x.adaptationRadar}),e.jsx("div",{className:"mt-4",children:e.jsx(M,{height:300,children:({width:s,height:g})=>e.jsxs(J,{data:v,width:s,height:g,children:[e.jsx(ee,{stroke:"var(--ui-border-subtle)"}),e.jsx(ae,{dataKey:"axis",tick:{fill:"var(--ui-ink-muted)",fontSize:10}}),e.jsx(ie,{dataKey:"value",stroke:"var(--success)",fill:"var(--success)",fillOpacity:.24}),e.jsx(_,{contentStyle:{background:"var(--ui-surface-modal)",border:"1px solid var(--ui-border-subtle)",borderRadius:8,color:"var(--ui-ink-strong)"}})]})})})]})]}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,0.8fr)_minmax(0,1.2fr)]",children:[e.jsxs(h,{children:[e.jsx(j,{eyebrow:"Intensity target",title:"Distribution vs target bands",description:"Compare the selected time window with broad low, moderate, and high intensity bands.",help:x.intensityTarget,action:e.jsx("div",{className:"grid grid-cols-2 gap-1 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-1",children:[["recent","28d"],["all","All"]].map(([s,g])=>e.jsx("button",{type:"button",className:`rounded-[6px] px-3 py-1.5 text-[12px] ${d===s?"bg-[var(--ui-surface-2)] text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-muted)]"}`,onClick:()=>n(s),children:g},s))})}),e.jsx("div",{className:"mt-4 grid gap-3",children:r.map(s=>e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-[12px]",children:[e.jsx("span",{className:"text-[var(--ui-ink-medium)]",children:s.label}),e.jsxs("span",{className:"text-[var(--ui-ink-strong)]",children:[s.percent,"% · target ",s.targetLow,"-",s.targetHigh,"%"]})]}),e.jsxs("div",{className:"relative h-3 overflow-hidden rounded-full bg-[var(--ui-surface-2)]",children:[e.jsx("div",{className:"absolute inset-y-0 rounded-full bg-[var(--ui-surface-2)]",style:{left:`${s.targetLow}%`,width:`${Math.max(2,s.targetHigh-s.targetLow)}%`}}),e.jsx("div",{className:"relative h-full rounded-full",style:{width:`${Math.max(1,s.percent)}%`,background:s.fill}})]})]},s.key))}),e.jsx("div",{className:"mt-5 grid gap-2 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3 text-[12px] leading-5 text-[var(--ui-ink-muted)]",children:t.targetModel.monitoringNotes.map(s=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{className:"mt-0.5 size-3.5 shrink-0 text-[var(--primary)]"}),e.jsx("span",{children:s})]},s))})]}),e.jsxs(h,{children:[e.jsx(j,{eyebrow:"HR zones",title:`Detailed zone distribution for ${d==="recent"?"the last 28 days":"all available sessions"}.`,help:x.hrZones}),e.jsx("div",{className:"mt-4",children:e.jsx(M,{height:290,children:({width:s,height:g})=>e.jsxs(Z,{data:c,width:s,height:g,children:[e.jsx(I,{stroke:"var(--ui-border-subtle)",vertical:!1}),e.jsx(C,{dataKey:"label",interval:0,tick:{fill:"var(--ui-ink-muted)",fontSize:10}}),e.jsx(k,{tick:{fill:"var(--ui-ink-muted)",fontSize:10},width:38}),e.jsx(_,{formatter:(z,E)=>[E==="minutes"?`${z} min`:`${z}%`,E],contentStyle:{background:"var(--ui-surface-modal)",border:"1px solid var(--ui-border-subtle)",borderRadius:8,color:"var(--ui-ink-strong)"}}),e.jsx(y,{dataKey:"minutes",name:"minutes",radius:[4,4,0,0],children:c.map(z=>e.jsx(te,{fill:z.fill},z.key))})]})})})]})]}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1fr)_420px]",children:[e.jsxs(h,{children:[e.jsx(j,{eyebrow:"Daily load texture",title:"Easy, threshold, and high-intensity minutes against daily load.",help:x.dailyTexture}),e.jsx("div",{className:"mt-4",children:e.jsx(M,{height:310,children:({width:s,height:g})=>e.jsxs(H,{data:L,width:s,height:g,children:[e.jsx(I,{stroke:"var(--ui-border-subtle)",vertical:!1}),e.jsx(C,{dataKey:"date",tick:{fill:"var(--ui-ink-muted)",fontSize:10}}),e.jsx(k,{yAxisId:"minutes",tick:{fill:"var(--ui-ink-muted)",fontSize:10},width:38}),e.jsx(k,{yAxisId:"load",orientation:"right",tick:{fill:"var(--ui-ink-muted)",fontSize:10},width:38}),e.jsx(_,{contentStyle:{background:"var(--ui-surface-modal)",border:"1px solid var(--ui-border-subtle)",borderRadius:8,color:"var(--ui-ink-strong)"}}),e.jsx(y,{yAxisId:"minutes",dataKey:"low",stackId:"zones",fill:"var(--success)",name:"low min"}),e.jsx(y,{yAxisId:"minutes",dataKey:"moderate",stackId:"zones",fill:"var(--warning)",name:"threshold min"}),e.jsx(y,{yAxisId:"minutes",dataKey:"high",stackId:"zones",fill:"var(--danger)",name:"high min"}),e.jsx(D,{yAxisId:"load",type:"monotone",dataKey:"load",stroke:"var(--info)",strokeWidth:2.2,dot:!1})]})})})]}),e.jsxs(h,{children:[e.jsx(j,{eyebrow:"Session signals",title:"Recent workouts",help:x.sessionSignals,action:e.jsxs(N,{tone:"meta",children:[l.hardDayCount7d," hard days / 7d"]})}),e.jsx("div",{className:"mt-4",children:e.jsx(ye,{sessions:t.sessionSignals})})]})]}),e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",children:[e.jsxs(h,{children:[e.jsx(j,{eyebrow:"Sport contribution",title:"Load by workout type",help:x.sportContribution}),e.jsx("div",{className:"mt-3 grid gap-3",children:t.activityBreakdown.slice(0,8).map(s=>e.jsxs("div",{className:"grid gap-2 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3 sm:grid-cols-[minmax(0,1fr)_76px_76px_76px]",children:[e.jsxs("div",{children:[e.jsx("div",{className:"truncate text-sm text-[var(--ui-ink-strong)]",children:s.workoutTypeLabel}),e.jsxs("div",{className:"mt-1 text-[11px] text-[var(--ui-ink-muted)]",children:[s.sessionCount," sessions ·"," ",s.activityFamilyLabel]})]}),e.jsxs("div",{className:"text-[12px] text-[var(--ui-ink-medium)]",children:[e.jsxs("span",{className:"block text-[var(--ui-ink-strong)]",children:[s.durationHours,"h"]}),"volume"]}),e.jsxs("div",{className:"text-[12px] text-[var(--ui-ink-medium)]",children:[e.jsx("span",{className:"block text-[var(--ui-ink-strong)]",children:s.trainingLoad}),"load"]}),e.jsxs("div",{className:"text-[12px] text-[var(--ui-ink-medium)]",children:[e.jsx("span",{className:"block text-[var(--ui-ink-strong)]",children:A(s.highPercentage)}),"high"]})]},s.workoutType))})]}),e.jsxs(h,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(P,{className:"size-4 text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]"}),e.jsx("div",{className:"font-label text-[10px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Interpretation guardrails"})]}),e.jsxs("div",{className:"mt-4 grid gap-3 text-[12px] leading-5 text-[var(--ui-ink-muted)]",children:[e.jsx("p",{children:"Forge is estimating training stress from heart-rate reserve zones and a TRIMP-like load. This is good for trend decisions, but it is not a substitute for lactate testing, gas exchange thresholds, or coach-led periodization."}),e.jsx("p",{children:"Combat sports add sensor noise: wrist HR can miss short spikes during punching and clinch work. Treat high-intensity minutes as minimum evidence when the session had a lot of arm motion."}),e.jsx("p",{children:"The practical target is not maximum Z5. Keep hard combat sessions meaningful, then add easy aerobic base when the high-intensity share is already high."})]})]})]})]})}export{Se as TrainingLoadPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./vendor-Dnkkx2co.js";import{i as x}from"./state-vCcAT5Hq.js";import{P as v}from"./page-hero-
|
|
1
|
+
import{j as e}from"./vendor-Dnkkx2co.js";import{i as x}from"./state-vCcAT5Hq.js";import{P as v}from"./page-hero-5RTqAI88.js";import{u as f,L as j,E as b,C as y,c as l,Z as N,bN as M,cv as k}from"./index-By3tQxiE.js";import{S as o,f as C,m as D,M as u}from"./daily-metrics-dashboard-BNGQlJkQ.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";import"./charts-DFnEuIMB.js";const R=["restingHeartRate","heartRateVariabilitySDNN","vo2Max","oxygenSaturation","bodyMass","stepCount"];function p(t,a){return a.map(r=>({...r,metrics:t.filter(s=>s.category===r.category)}))}function S(t){return t}function V({metrics:t}){if(!t.summary.hasData||t.metrics.length===0)return null;const a=p(t.metrics,t.summary.categoryBreakdown),r=t.metrics.find(n=>n.metric==="devrageSwearCount")??null,s=t.metrics.find(n=>n.metric==="swearingMessagePercent")??null;return e.jsxs("section",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/38",children:"Psyche metrics"}),e.jsx("div",{className:"mt-1 text-2xl font-semibold text-white",children:"Conversation tone alongside body signals"})]}),e.jsxs(l,{className:"bg-amber-200/10 text-amber-50",children:[t.summary.trackedDays," tracked days"]})]}),e.jsxs("div",{className:"grid gap-4 xl:grid-cols-2",children:[e.jsx(o,{title:"Devrage count",description:"Daily user-message swear count from stored conversation history.",metric:r}),e.jsx(o,{title:"Swearing rate",description:"Share of scanned user messages that contained at least one tracked swear.",metric:s})]}),e.jsx(u,{groups:a})]})}function I(){var h;const t=f(),a=x({queryKey:["forge-vitals-view",...t.selectedUserIds],queryFn:async()=>(await M(t.selectedUserIds)).vitals}),r=x({queryKey:["forge-psyche-metrics-vitals-view"],queryFn:async()=>(await k()).metrics});if(a.isLoading)return e.jsx(j,{title:"Loading body signals",description:"Reading recent HealthKit body metrics, recovery signals, and daily aggregates."});if(a.isError||!a.data)return e.jsx(b,{error:a.error??new Error("Vitals data unavailable"),onRetry:()=>void a.refetch()});const s=a.data,n=s.metrics.map(S),c=R.map(i=>n.find(d=>d.metric===i)??null),m=s.summary.categoryBreakdown,w=p(n,m),g=!r.isError&&((h=r.data)!=null&&h.summary.hasData)?r.data:null;return e.jsxs("div",{className:"mx-auto grid w-full max-w-[1380px] gap-5",children:[e.jsx(v,{title:"Vitals",description:"Forge now keeps a daily body-signals layer across recovery, cardio fitness, breathing, composition, temperature, and activity. Use this surface to spot drift early, not just admire numbers late.",badge:`${s.summary.metricCount} live metrics`}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-4",children:[e.jsx(o,{title:"Recovery pulse",description:"Resting heart rate and HRV are the fastest read on load, stress, and whether today needs a gentler edge.",metric:c[0]??c[1]}),e.jsx(o,{title:"Cardio engine",description:"VO2 max and walking heart rate show whether baseline fitness is improving or whether your effort is costing more than usual.",metric:c[2]}),e.jsx(o,{title:"Breath and oxygen",description:"Respiratory rate and oxygen saturation help catch nights or stretches where recovery quality starts to slip.",metric:c[3]}),e.jsx(o,{title:"Body composition",description:"Mass and composition stay close to the daily story so progress is visible without flattening everything into weight alone.",metric:c[4]})]}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.1fr)_minmax(340px,0.9fr)]",children:[e.jsxs(y,{className:"overflow-hidden rounded-[30px] border-white/8 bg-[radial-gradient(circle_at_top_left,rgba(108,99,255,0.16),transparent_36%),linear-gradient(180deg,rgba(15,19,38,0.98),rgba(9,13,28,0.98))] p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Coverage"}),e.jsxs("div",{className:"text-2xl font-semibold text-white",children:[s.summary.trackedDays," tracked days across ",s.summary.metricCount," metrics"]}),e.jsx("div",{className:"max-w-3xl text-sm leading-6 text-white/58",children:"The companion is compressing HealthKit into daily signal bands, so what you see here is designed for decisions: how your recovery is trending, where your physiology is changing, and which body systems are actually being observed consistently."})]}),e.jsxs(l,{className:"bg-white/[0.08] text-white/72",children:["Latest snapshot ",C(s.summary.latestDateKey)]})]}),e.jsx("div",{className:"mt-5 grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:m.map(i=>{const d=D(i.category);return e.jsxs("div",{className:N("rounded-[22px] border bg-white/[0.03] p-4",d.ring),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(l,{className:d.badge,children:i.category}),e.jsxs("div",{className:"text-xs text-white/44",children:[i.coverageDays," days"]})]}),e.jsx("div",{className:"mt-3 text-2xl font-semibold text-white",children:i.metricCount}),e.jsxs("div",{className:"mt-1 text-sm text-white/58",children:["active metric",i.metricCount===1?"":"s"]})]},i.category)})})]}),e.jsx(y,{className:"rounded-[30px] border-white/8 bg-[linear-gradient(180deg,rgba(13,19,37,0.96),rgba(10,14,30,0.96))] p-6",children:e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Daily interpretation"}),e.jsx("div",{className:"text-lg font-semibold text-white",children:"Body signals should feel operational, not medical-chart dead."}),e.jsxs("div",{className:"grid gap-3 text-sm leading-6 text-white/58",children:[e.jsx("div",{children:"Lower resting heart rate paired with stable or rising HRV usually means recovery is holding."}),e.jsx("div",{children:"Rising walking heart rate, falling HRV, or a jump in respiratory rate usually means you are carrying more load than the calendar admits."}),e.jsx("div",{children:"Composition and temperature metrics move slower, but they make the fast signals easier to trust because you can see the surrounding body context."})]}),e.jsxs("div",{className:"mt-2 rounded-[22px] border border-white/8 bg-white/[0.035] p-4 text-sm text-white/70",children:[s.summary.latestMetricCount," metrics updated on the latest tracked day."]})]})})]}),e.jsx(u,{groups:w}),g?e.jsx(V,{metrics:g}):null]})}export{I as VitalsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./vendor-Dnkkx2co.js";import{j as y,i as f,k as g}from"./state-vCcAT5Hq.js";import{F as j}from"./flagship-signal-deck-
|
|
1
|
+
import{j as e}from"./vendor-Dnkkx2co.js";import{j as y,i as f,k as g}from"./state-vCcAT5Hq.js";import{F as j}from"./flagship-signal-deck-bolzzK8q.js";import{P as k,fp as b,i as N,S as R,E as v,C as w,c as h,B as $,fq as S}from"./index-By3tQxiE.js";import{P as z}from"./page-hero-5RTqAI88.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";const o="font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",d="overflow-hidden rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]",x="text-sm leading-6 text-[var(--ui-ink-soft)]";function P({data:s}){const m=Math.max(1,...s.map(i=>i.xp)),t=s.length>0?Math.max(4,Math.min(18,280/s.length-4)):8,c=s.length>1?Math.max(1,(300-s.length*t)/(s.length-1)):0;return e.jsx("div",{className:"mt-4 aspect-[16/9] min-h-56 w-full min-w-0 overflow-hidden rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3",children:e.jsxs("svg",{viewBox:"0 0 340 200",role:"img","aria-label":"Weekly review XP chart",className:"h-full w-full",children:[e.jsx("g",{stroke:"var(--ui-border-subtle)",strokeWidth:"1",children:[45,85,125,165].map(i=>e.jsx("line",{x1:"20",x2:"320",y1:i,y2:i},i))}),s.map((i,r)=>{const l=20+r*(t+c),n=Math.max(2,i.xp/m*128);return e.jsxs("g",{children:[e.jsx("rect",{x:l,y:168-n,width:t,height:n,rx:"5",fill:"var(--primary)"}),r===0||r===s.length-1||r%3===0?e.jsx("text",{x:l+t/2,y:"192",fill:"var(--ui-ink-faint)",fontSize:"10",textAnchor:"middle",children:i.label}):null]},`${i.label}-${r}`)})]})})}function L(){var u;const{t:s}=k(),m=y(),t=f({queryKey:["forge-weekly-review"],queryFn:S}),c=g({mutationFn:b,onSuccess:async()=>{await Promise.all([m.invalidateQueries({queryKey:["forge-weekly-review"]}),m.invalidateQueries({queryKey:["forge-xp-metrics"]}),m.invalidateQueries({queryKey:["forge-reward-ledger"]}),N(m),m.invalidateQueries({queryKey:["activity-archive"]})])}}),i=(u=t.data)==null?void 0:u.review;if(t.isLoading)return e.jsx(R,{});if(t.isError)return e.jsx(v,{eyebrow:s("common.weeklyReview.heroEyebrow"),error:t.error,onRetry:()=>void t.refetch()});if(!i)return e.jsx(v,{eyebrow:s("common.weeklyReview.heroEyebrow"),error:new Error("Forge returned an empty weekly review payload."),onRetry:()=>void t.refetch()});const r=i.wins[0]??null,l=i.calibration.find(a=>a.mode==="recover")??i.calibration[0]??null,n=i.calibration.find(a=>a.mode==="accelerate")??i.calibration[0]??null,p=[{id:"week",label:"This week",title:`${i.momentumSummary.totalXp} XP with ${i.momentumSummary.focusHours} focus hours`,detail:`Peak window: ${i.momentumSummary.peakWindow}. Efficiency score is holding at ${i.momentumSummary.efficiencyScore}.`,badge:i.windowLabel},{id:"wins",label:"Wins",title:(r==null?void 0:r.title)??s("common.weeklyReview.noWin"),detail:(r==null?void 0:r.summary)??s("common.weeklyReview.noWinDetail"),badge:r?`+${r.rewardXp} xp`:`${i.wins.length} wins`},{id:"recovery",label:"Recovery",title:(l==null?void 0:l.title)??s("common.weeklyReview.noRecovery"),detail:(l==null?void 0:l.note)??s("common.weeklyReview.noRecoveryDetail"),badge:(l==null?void 0:l.mode)??"maintain"},{id:"next-intent",label:"Next intent",title:(n==null?void 0:n.title)??i.reward.title,detail:(n==null?void 0:n.note)??i.reward.summary,badge:`+${i.reward.rewardXp} xp`}];return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(z,{title:"Weekly Review",description:`${i.windowLabel}. ${s("common.weeklyReview.heroDescription")}`,badge:`${i.momentumSummary.totalXp} xp`}),e.jsxs("section",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.2fr)_minmax(0,0.8fr)]",children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(w,{children:[e.jsx("div",{className:o,children:s("common.weeklyReview.sectionMomentum")}),e.jsx(P,{data:i.chart}),e.jsxs("div",{className:"mt-4 grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:`${d} p-4`,children:[e.jsx("div",{className:o,children:"XP"}),e.jsx("div",{className:"mt-2 text-2xl text-[var(--ui-ink-strong)]",children:i.momentumSummary.totalXp})]}),e.jsxs("div",{className:`${d} p-4`,children:[e.jsx("div",{className:o,children:"Focus hours"}),e.jsx("div",{className:"mt-2 text-2xl text-[var(--ui-ink-strong)]",children:i.momentumSummary.focusHours})]}),e.jsxs("div",{className:`${d} p-4`,children:[e.jsx("div",{className:o,children:"Peak window"}),e.jsx("div",{className:"mt-2 break-words text-2xl text-[var(--ui-ink-strong)]",children:i.momentumSummary.peakWindow})]})]})]}),e.jsxs(w,{children:[e.jsx("div",{className:o,children:s("common.weeklyReview.sectionGoals")}),e.jsx("div",{className:"mt-4 grid gap-3",children:i.calibration.map(a=>e.jsxs("div",{className:`${d} p-4`,children:[e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[e.jsx("div",{className:"min-w-0 flex-1 break-words font-medium text-[var(--ui-ink-strong)]",children:a.title}),e.jsx(h,{className:"max-w-[9rem] shrink-0 self-start",children:a.mode})]}),e.jsx("div",{className:`mt-3 break-words ${x}`,children:a.note})]},a.id))})]})]}),e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(w,{children:[e.jsx("div",{className:o,children:s("common.weeklyReview.sectionWins")}),e.jsx("div",{className:"mt-4 grid gap-3",children:i.wins.map(a=>e.jsxs("div",{className:`${d} p-4`,children:[e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[e.jsx("div",{className:"min-w-0 flex-1 break-words font-medium text-[var(--ui-ink-strong)]",children:a.title}),e.jsxs(h,{tone:"signal",className:"max-w-[8rem] shrink-0 self-start",children:["+",a.rewardXp," xp"]})]}),e.jsx("div",{className:`mt-2 break-words ${x}`,children:a.summary})]},a.id))})]}),e.jsxs(w,{children:[e.jsx("h2",{className:"break-words font-display text-3xl text-[var(--ui-ink-strong)]",children:i.reward.title}),e.jsx("p",{className:`mt-3 leading-7 ${x}`,children:i.reward.summary}),e.jsxs("div",{className:`mt-4 ${d} p-4`,children:[e.jsx("div",{className:o,children:s("common.weeklyReview.completionBonus")}),e.jsxs("div",{className:"mt-2 text-3xl text-[var(--primary)]",children:["+",i.reward.rewardXp," XP"]})]}),e.jsx($,{className:"mt-4 w-full",disabled:i.completion.finalized,pending:c.isPending,pendingLabel:s("common.weeklyReview.finalizePending"),onClick:async()=>{await c.mutateAsync()},children:i.completion.finalized?s("common.weeklyReview.finalized"):s("common.weeklyReview.finalize")}),e.jsx("div",{className:`mt-3 ${x}`,children:i.completion.finalized?`${s("common.weeklyReview.finalizedDetail")} ${i.completion.finalizedBy?`By ${i.completion.finalizedBy}. `:""}${i.completion.finalizedAt?new Date(i.completion.finalizedAt).toLocaleString():""}`.trim():i.reward.summary})]})]})]}),e.jsx(j,{eyebrow:s("common.weeklyReview.summaryEyebrow"),title:s("common.weeklyReview.summaryTitle"),description:s("common.weeklyReview.summaryDescription"),items:p})]})}export{L as WeeklyReviewPage};
|