forge-openclaw-plugin 0.3.4 → 0.3.5
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/{action-bar-CMGr_Uv_.js → action-bar-DBZ38L_6.js} +1 -1
- package/dist/assets/{activity-page-DwGKkJtr.js → activity-page-BJxUR9bD.js} +1 -1
- package/dist/assets/{ai-surface-workspace-UtnoNmjq.js → ai-surface-workspace-ehzBjTsW.js} +1 -1
- package/dist/assets/{atlas-panel-f1kc-LkD.js → atlas-panel-BFUeVT69.js} +1 -1
- package/dist/assets/{calendar-page-C4YqeVrC.js → calendar-page-Bg8W-YQ-.js} +1 -1
- package/dist/assets/{calendar-rules-BQppCPiN.js → calendar-rules-9XQLoI96.js} +1 -1
- package/dist/assets/{calendar-week-toolbar-DdPuHUwd.js → calendar-week-toolbar-BeYnx1pE.js} +1 -1
- package/dist/assets/{companion-sync-lab-page-N3cR33GS.js → companion-sync-lab-page-BRKYkIrs.js} +1 -1
- package/dist/assets/{daily-metrics-dashboard-CXnAtN2T.js → daily-metrics-dashboard-Jt0nAHU5.js} +1 -1
- package/dist/assets/{define-workbench-box-DkffygDU.js → define-workbench-box-5h-dyvJY.js} +1 -1
- package/dist/assets/{entity-link-multiselect-wuyJ8BbW.js → entity-link-multiselect-Bb4De_e3.js} +1 -1
- package/dist/assets/{entity-note-count-link-CEtKyMAl.js → entity-note-count-link-BzWnsOmI.js} +1 -1
- package/dist/assets/{entity-notes-surface-iKNiierJ.js → entity-notes-surface-CagOwdng.js} +1 -1
- package/dist/assets/{execution-board-DesFZ1f5.js → execution-board-DTmAtmqZ.js} +1 -1
- package/dist/assets/{faceted-token-search-D4Okr-Kr.js → faceted-token-search-DJPRm9AY.js} +1 -1
- package/dist/assets/{flagship-signal-deck-CW91n6u9.js → flagship-signal-deck-CJbGZF7I.js} +1 -1
- package/dist/assets/{floating-action-menu-GCeuOdYZ.js → floating-action-menu-K77jh8XZ.js} +1 -1
- package/dist/assets/{generic-node-view-COhU_Wm3.js → generic-node-view-p5ePSFuG.js} +1 -1
- package/dist/assets/{goal-detail-page-Bd8JU3IK.js → goal-detail-page-DGu_khEK.js} +1 -1
- package/dist/assets/{goal-dialog-CLz5fYhO.js → goal-dialog-BWD7cOv9.js} +1 -1
- package/dist/assets/{goals-page-CZHNVyY-.js → goals-page-Bgj3sj0f.js} +1 -1
- package/dist/assets/{habits-page-CXiBB7_N.js → habits-page-Ctut1tuX.js} +1 -1
- package/dist/assets/{health-boxes-BUcsxDLh.js → health-boxes-Ie3horXx.js} +1 -1
- package/dist/assets/index-BaiwtAgo.js +2 -0
- package/dist/assets/{inline-note-fields-CcRDO3pd.js → inline-note-fields-DE6WM9uM.js} +1 -1
- package/dist/assets/{insight-flow-dialog-DUBk2MR8.js → insight-flow-dialog-XL8I74eJ.js} +1 -1
- package/dist/assets/{insights-page-8fLhCYsM.js → insights-page-Bz1FLbp5.js} +1 -1
- package/dist/assets/{kanban-boxes-CH7plRk1.js → kanban-boxes-BBziel7P.js} +1 -1
- package/dist/assets/{kanban-page-Bq-aYwUL.js → kanban-page-DdQP73I3.js} +1 -1
- package/dist/assets/{knowledge-graph-page-DYFfWh4Y.js → knowledge-graph-page-DdHWj4Dj.js} +1 -1
- package/dist/assets/{life-force-page-D80rgBBR.js → life-force-page-BRN-93cI.js} +1 -1
- package/dist/assets/{life-force-workspace-CcmZRRfU.js → life-force-workspace-BowvP5R4.js} +1 -1
- package/dist/assets/{metric-tile-DysHMgM3.js → metric-tile-B6aJueRo.js} +1 -1
- package/dist/assets/{movement-boxes-BH3botKt.js → movement-boxes-5cjWjIdR.js} +1 -1
- package/dist/assets/{movement-page-D5KLMKS9.js → movement-page-Dy53RWtB.js} +1 -1
- package/dist/assets/{note-markdown-Byd_vNkS.js → note-markdown-CvEQCfoi.js} +1 -1
- package/dist/assets/{note-tags-input-DYAFDq8Q.js → note-tags-input-Cg5zBXos.js} +1 -1
- package/dist/assets/{notes-boxes-CPiPps1e.js → notes-boxes-CgZyf7mV.js} +1 -1
- package/dist/assets/{notes-page-DehVrOOb.js → notes-page-Cbdcv0Ej.js} +1 -1
- package/dist/assets/{open-in-graph-button-L21MKsb5.js → open-in-graph-button-D31ZOEhA.js} +1 -1
- package/dist/assets/{orbit-map-ChJOQ8CN.js → orbit-map-8eNDWek8.js} +1 -1
- package/dist/assets/overview-page-CZ6q52Qj.js +1 -0
- package/dist/assets/{page-hero-DlHEJ0Yt.js → page-hero-C0MpI3MM.js} +1 -1
- package/dist/assets/{pill-cluster-DhOR4m7X.js → pill-cluster-DGwKZQKF.js} +1 -1
- package/dist/assets/{preference-entity-handoff-button-ugHU2us9.js → preference-entity-handoff-button-CJhr5AXl.js} +1 -1
- package/dist/assets/{preferences-page-BTTXeSDR.js → preferences-page-8vszDNFX.js} +1 -1
- package/dist/assets/{project-collections-USb6PUe0.js → project-collections-sC7eAAhS.js} +1 -1
- package/dist/assets/{project-detail-page-1tD6tUsB.js → project-detail-page-BKdnMjJy.js} +1 -1
- package/dist/assets/{project-dialog-BaHhJqP6.js → project-dialog-BiHZpOo1.js} +1 -1
- package/dist/assets/{project-management-hierarchy-page-D4HV8QXs.js → project-management-hierarchy-page-VW-hykAI.js} +1 -1
- package/dist/assets/{project-management-section-nav-9OV6_ifH.js → project-management-section-nav-BEZ5zihs.js} +1 -1
- package/dist/assets/{projects-boxes-AyudWls3.js → projects-boxes-Ca6rpYeE.js} +1 -1
- package/dist/assets/{projects-page-DizVVzbt.js → projects-page-D86pjpTf.js} +1 -1
- package/dist/assets/{psyche-behaviors-page-CX5MJjWj.js → psyche-behaviors-page-YLJB6CRU.js} +1 -1
- package/dist/assets/{psyche-flashcards-page-DzCGy-FV.js → psyche-flashcards-page-D3gdHLUw.js} +1 -1
- package/dist/assets/{psyche-goal-map-page-BcKR792E.js → psyche-goal-map-page-DJiqSiCx.js} +1 -1
- package/dist/assets/{psyche-graph-BNllZR67.js → psyche-graph-Tke0qFdt.js} +1 -1
- package/dist/assets/{psyche-metrics-page-CpEKlZLO.js → psyche-metrics-page-DoLnvmC2.js} +1 -1
- package/dist/assets/{psyche-mode-guide-page-DXKSE2o7.js → psyche-mode-guide-page-_Zbvg_HL.js} +1 -1
- package/dist/assets/{psyche-modes-page-Bh6eeNm1.js → psyche-modes-page-eAkaAzJc.js} +1 -1
- package/dist/assets/{psyche-page-B44RJrrC.js → psyche-page-CwmuBVjA.js} +1 -1
- package/dist/assets/{psyche-patterns-page-Bm7T5FMJ.js → psyche-patterns-page-D7B4Ykjq.js} +1 -1
- package/dist/assets/{psyche-questionnaire-builder-page-BNtMNjY8.js → psyche-questionnaire-builder-page-CHJlvCzX.js} +1 -1
- package/dist/assets/{psyche-questionnaire-detail-page-BnMXErRK.js → psyche-questionnaire-detail-page-Bg3ll-D4.js} +1 -1
- package/dist/assets/{psyche-questionnaire-run-detail-page-CWKxbdwZ.js → psyche-questionnaire-run-detail-page-CIEerczF.js} +1 -1
- package/dist/assets/{psyche-questionnaire-run-page-DwH7Sk52.js → psyche-questionnaire-run-page-DyxIk6Qx.js} +1 -1
- package/dist/assets/{psyche-questionnaires-page-B1t_a8QU.js → psyche-questionnaires-page-ZlqUxuIl.js} +1 -1
- package/dist/assets/{psyche-report-detail-page-x2AtC99e.js → psyche-report-detail-page-B2jgYnQ5.js} +1 -1
- package/dist/assets/{psyche-reports-page-KiwCgWPa.js → psyche-reports-page-DlXr52yr.js} +1 -1
- package/dist/assets/{psyche-schemas-beliefs-page-CIEoAJAp.js → psyche-schemas-beliefs-page-BhrTZN9B.js} +1 -1
- package/dist/assets/{psyche-screen-time-page-DO6UycL9.js → psyche-screen-time-page-WNGcdusx.js} +1 -1
- package/dist/assets/{psyche-self-observation-page-CPcpUSdm.js → psyche-self-observation-page-XsCOglo4.js} +1 -1
- package/dist/assets/{psyche-values-page-BAgNeo4L.js → psyche-values-page-NvHI6zWK.js} +1 -1
- package/dist/assets/{question-flow-dialog-BByFV8Yw.js → question-flow-dialog-Bj4PxpjS.js} +1 -1
- package/dist/assets/{report-chain-fields-BpRWMp7h.js → report-chain-fields-mWFikZzT.js} +1 -1
- package/dist/assets/{rewards-page-kIiX8SHn.js → rewards-page-DyjwXsQN.js} +1 -1
- package/dist/assets/{scheduling-rules-editor-oQXGcL5l.js → scheduling-rules-editor-C6FEYOxd.js} +1 -1
- package/dist/assets/{schema-badge-BoNjw3h4.js → schema-badge-CCe4zkSN.js} +1 -1
- package/dist/assets/{schemas-IBbtdPzn.js → schemas-Cjwn6ooR.js} +1 -1
- package/dist/assets/{select-menu-U-YryCwP.js → select-menu-DeJhCsd8.js} +1 -1
- package/dist/assets/{settings-agents-page-CbHeMq3e.js → settings-agents-page-DYDxyKu-.js} +1 -1
- package/dist/assets/{settings-bin-page-LxS2YPsA.js → settings-bin-page-BWLfKVW1.js} +1 -1
- package/dist/assets/{settings-calendar-page-CZc-I-HK.js → settings-calendar-page-Ci-wXhCv.js} +1 -1
- package/dist/assets/{settings-data-page-m-aBRMR9.js → settings-data-page-DxIw-fWn.js} +1 -1
- package/dist/assets/{settings-logs-page-BUEGWlQu.js → settings-logs-page-inpyIdu6.js} +1 -1
- package/dist/assets/{settings-mobile-page-C_5CHjHl.js → settings-mobile-page-BcJGLax8.js} +1 -1
- package/dist/assets/{settings-models-page-B4HQu8kL.js → settings-models-page-OWTRhfkj.js} +1 -1
- package/dist/assets/{settings-page-CY8N-fNV.js → settings-page-DXxF3qK2.js} +1 -1
- package/dist/assets/{settings-rewards-page-C0XQoWjb.js → settings-rewards-page-CCXin1n_.js} +1 -1
- package/dist/assets/{settings-section-nav-CkqqtM0F.js → settings-section-nav-CwSDNC3W.js} +1 -1
- package/dist/assets/{settings-users-page-COCBOq7d.js → settings-users-page-B4NEACwR.js} +1 -1
- package/dist/assets/{settings-wiki-page-Dy1d7-z-.js → settings-wiki-page-BNRK1SYc.js} +1 -1
- package/dist/assets/{sleep-page-1kKicdFq.js → sleep-page-Bara54nB.js} +1 -1
- package/dist/assets/{sports-page-DJErRii_.js → sports-page-BawekFKD.js} +1 -1
- package/dist/assets/{strategies-page-CWNFb9vv.js → strategies-page-BEl3NGAU.js} +1 -1
- package/dist/assets/{strategy-detail-page-D9rFVXRS.js → strategy-detail-page-DPPI_8Ub.js} +1 -1
- package/dist/assets/{strategy-dialog-BIVHfUR6.js → strategy-dialog-DU6wbBkQ.js} +1 -1
- package/dist/assets/{surface-B3oXO1No.js → surface-BVYp-Wq9.js} +1 -1
- package/dist/assets/{task-detail-page-r8ipOpAF.js → task-detail-page-BsMVAsbb.js} +1 -1
- package/dist/assets/{task-dialog-C3kkWtcT.js → task-dialog-BGzPc6TW.js} +1 -1
- package/dist/assets/{timebox-planning-dialog-BadS5tEr.js → timebox-planning-dialog-4_XWuqkw.js} +1 -1
- package/dist/assets/{today-boxes-CiccN0Gw.js → today-boxes-5pCvh5zS.js} +1 -1
- package/dist/assets/{today-page-DvQredbl.js → today-page-BGurICpl.js} +1 -1
- package/dist/assets/{training-load-page-CkX-nSoe.js → training-load-page-BkoYKZ9_.js} +1 -1
- package/dist/assets/{user-badge-BKzwGZDd.js → user-badge-DfDv87j7.js} +1 -1
- package/dist/assets/{utility-widgets-DvxKA6dI.js → utility-widgets-CbYj32he.js} +1 -1
- package/dist/assets/{vitals-page-CRIsr_C7.js → vitals-page-DlxMk-L7.js} +1 -1
- package/dist/assets/{weekly-review-page-CNqxLRCd.js → weekly-review-page-VrEvAl1T.js} +1 -1
- package/dist/assets/{weight-loss-page-SSsCp1Yw.js → weight-loss-page-DJDnjxKF.js} +1 -1
- package/dist/assets/{wiki-article-markdown-C9VKineE.js → wiki-article-markdown-DxTkiQRy.js} +1 -1
- package/dist/assets/{wiki-editor-page-DxGsKvF7.js → wiki-editor-page-Beu92YnZ.js} +1 -1
- package/dist/assets/{wiki-ingest-history-page-CFmP7K1F.js → wiki-ingest-history-page-Cq_soygm.js} +1 -1
- package/dist/assets/{wiki-ingest-modal-BLw2PSWP.js → wiki-ingest-modal-D6xs2sEn.js} +1 -1
- package/dist/assets/{wiki-page-BiQ-jAuz.js → wiki-page-yF3Flgtg.js} +1 -1
- package/dist/assets/{workbench-flow-page-D960hXu_.js → workbench-flow-page-CZZGg3a8.js} +1 -1
- package/dist/assets/{workbench-page-BWlY-FiL.js → workbench-page-DKENZ5Nz.js} +1 -1
- package/dist/assets/{workout-detail-page-G32yJoE9.js → workout-detail-page-CeN4QiYQ.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/server/server/src/app.js +4 -1
- package/dist/server/server/src/health.js +47 -19
- package/dist/server/src/lib/api.js +4 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/dist/assets/index-BejvcRGb.js +0 -2
- package/dist/assets/overview-page-D_ewyeWF.js +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as c,j as e,b8 as P,cW as T,aV as L,cX as Q,cN as U,aS as v,cm as $}from"./vendor-Cpmju3nw.js";import{j as E,k as N}from"./state-BtwEvpO6.js";import{c as w,aa as z,cl as O}from"./index-
|
|
1
|
+
import{r as c,j as e,b8 as P,cW as T,aV as L,cX as Q,cN as U,aS as v,cm as $}from"./vendor-Cpmju3nw.js";import{j as E,k as N}from"./state-BtwEvpO6.js";import{c as w,aa as z,cl as O}from"./index-BaiwtAgo.js";import{c as f,a as u,n as m,m as j,j as g}from"./generic-node-view-p5ePSFuG.js";function R(t){const i=new Date(t.getFullYear(),t.getMonth(),1),r=(i.getDay()+6)%7,n=new Date(i);return n.setDate(n.getDate()-r),Array.from({length:35},(a,s)=>{const l=new Date(n);return l.setDate(n.getDate()+s),l})}function _(t,i){return typeof window>"u"?i:window.localStorage.getItem(t)??i}function A(t,i){typeof window>"u"||window.localStorage.setItem(t,i)}function C({compact:t}){const[i,r]=c.useState(()=>new Date);return c.useEffect(()=>{const n=window.setInterval(()=>r(new Date),3e4);return()=>window.clearInterval(n)},[]),e.jsxs("div",{className:"flex h-full flex-col justify-between gap-4 rounded-[20px] bg-white/[0.03] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white/45",children:[e.jsx(P,{className:"size-4"}),e.jsx("span",{className:"text-[12px] uppercase tracking-[0.16em]",children:"Local time"})]}),e.jsx("div",{className:w("font-display text-white",t?"text-3xl":"text-5xl"),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(i)}),e.jsx("div",{className:"text-sm text-white/58",children:new Intl.DateTimeFormat(void 0,{weekday:"long",month:"long",day:"numeric"}).format(i)})]})}function W({compact:t}){const i=new Date,r=c.useMemo(()=>R(i),[i]),n=t?["M","T","W","T","F","S","S"]:["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];return e.jsxs("div",{className:"grid gap-3 rounded-[20px] bg-white/[0.03] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-white",children:[e.jsx(L,{className:"size-4 text-[var(--primary)]"}),new Intl.DateTimeFormat(void 0,{month:"long",year:"numeric"}).format(i)]}),e.jsx("div",{className:"text-[12px] text-white/45",children:t?"Mini":"Month view"})]}),e.jsxs("div",{className:"grid grid-cols-7 gap-1.5",children:[n.map(a=>e.jsx("div",{className:"text-center text-[11px] uppercase tracking-[0.14em] text-white/35",children:a},a)),r.map(a=>{const s=a.getMonth()===i.getMonth(),l=a.toDateString()===i.toDateString();return e.jsx("div",{className:w("flex min-h-9 items-center justify-center rounded-xl text-sm",l?"bg-[var(--primary)] text-slate-950":s?"bg-white/[0.04] text-white/78":"bg-transparent text-white/24"),children:a.getDate()},a.toISOString())})]})]})}function D({surfaceId:t}){const i=`forge.utility.spotify.${t}`,[r,n]=c.useState(()=>_(i,"https://open.spotify.com/"));return c.useEffect(()=>{A(i,r)},[i,r]),e.jsxs("div",{className:"grid h-full gap-3 rounded-[20px] bg-white/[0.03] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white",children:[e.jsx(Q,{className:"size-4 text-[var(--secondary)]"}),e.jsx("span",{className:"text-sm font-semibold",children:"Spotify link"})]}),e.jsx("input",{value:r,onChange:a=>n(a.target.value),className:"w-full rounded-2xl border border-white/10 bg-white/[0.04] px-3 py-2.5 text-sm text-white outline-none transition focus:border-[rgba(192,193,255,0.35)]",placeholder:"Paste a playlist, album, or artist URL"}),e.jsxs("a",{href:r,target:"_blank",rel:"noreferrer",className:"inline-flex min-h-10 items-center justify-center gap-2 rounded-2xl bg-[rgba(78,222,163,0.14)] px-3 py-2 text-sm font-medium text-[var(--secondary)] transition hover:bg-[rgba(78,222,163,0.22)]",children:["Open Spotify",e.jsx(U,{className:"size-4"})]})]})}function F({compact:t}){const[i,r]=c.useState(null),[n,a]=c.useState("Locating…");return c.useEffect(()=>{if(typeof navigator>"u"||!navigator.geolocation){a("Location unavailable");return}let s=!1;return navigator.geolocation.getCurrentPosition(async l=>{try{const p=await(await fetch(`https://api.open-meteo.com/v1/forecast?latitude=${l.coords.latitude}&longitude=${l.coords.longitude}¤t=temperature_2m,weather_code`)).json();if(s||!p.current)return;r({temperature:Number(p.current.temperature_2m??0),weatherCode:Number(p.current.weather_code??0)}),a("Live")}catch{s||a("Weather unavailable")}},()=>{s||a("Permission denied")},{maximumAge:3e5,timeout:6e3}),()=>{s=!0}},[]),e.jsxs("div",{className:"flex h-full flex-col justify-between gap-4 rounded-[20px] bg-white/[0.03] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white",children:[e.jsx(T,{className:"size-4 text-[var(--tertiary)]"}),e.jsx("span",{className:"text-sm font-semibold",children:"Weather"})]}),i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:w("font-display text-white",t?"text-3xl":"text-5xl"),children:[Math.round(i.temperature),"°"]}),e.jsxs("div",{className:"text-sm text-white/58",children:["Code ",i.weatherCode," · ",n]})]}):e.jsx("div",{className:"text-sm text-white/58",children:n})]})}function I({compact:t,defaultUserId:i}){const r=E(),n=c.useRef(null),a=c.useRef(null),[s,l]=c.useState(""),[d,p]=c.useState(""),k=N({mutationFn:async()=>z({contentMarkdown:`# ${s.trim()||"Quick note"}
|
|
2
2
|
|
|
3
3
|
${d.trim()}`,author:"Forge quick capture",userId:i??null,links:[]}),onSuccess:async()=>{l(""),p(""),await r.invalidateQueries({queryKey:["notes-index"]})}}),S=N({mutationFn:async()=>O({title:s.trim()||"Quick capture",contentMarkdown:d.trim(),summary:d.trim().slice(0,180),author:"Forge quick capture"}),onSuccess:async()=>{l(""),p(""),await r.invalidateQueries({queryKey:["wiki-pages"]})}});function x(o,M=o){const h=a.current;if(!h)return;const y=h.selectionStart??0,b=h.selectionEnd??0,V=d.slice(y,b),q=`${d.slice(0,y)}${o}${V}${M}${d.slice(b)}`;p(q),requestAnimationFrame(()=>{h.focus(),h.selectionStart=y+o.length,h.selectionEnd=b+o.length})}return e.jsxs("div",{className:"grid h-full min-h-0 gap-3 rounded-[20px] bg-white/[0.03] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white",children:[e.jsx(v,{className:"size-4 text-[var(--primary)]"}),e.jsx("span",{className:"text-sm font-semibold",children:"Quick capture"})]}),e.jsx("input",{ref:n,value:s,onChange:o=>l(o.target.value),className:"w-full rounded-2xl border border-white/10 bg-white/[0.04] px-3 py-2.5 text-sm text-white outline-none transition focus:border-[rgba(192,193,255,0.35)]",placeholder:"Title"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:[{label:"B",action:()=>x("**")},{label:"I",action:()=>x("_")},{label:"H1",action:()=>x("# ","")},{label:"[]",action:()=>x("- [ ] ","")}].map(o=>e.jsx("button",{type:"button",className:"inline-flex min-h-8 items-center justify-center rounded-xl bg-white/[0.05] px-2.5 text-[12px] font-semibold text-white/72 transition hover:bg-white/[0.08] hover:text-white",onClick:o.action,children:o.label},o.label))}),e.jsx("textarea",{ref:a,value:d,onChange:o=>p(o.target.value),className:w("min-h-0 w-full rounded-[20px] border border-white/10 bg-white/[0.04] px-3 py-3 text-sm text-white outline-none transition focus:border-[rgba(192,193,255,0.35)]",t?"h-28":"h-40"),placeholder:"Write a quick note or rough wiki draft"}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center justify-center gap-2 rounded-2xl bg-[rgba(192,193,255,0.16)] px-3 py-2 text-sm font-medium text-[var(--primary)] transition hover:bg-[rgba(192,193,255,0.24)] disabled:opacity-50",disabled:!d.trim()||k.isPending,onClick:()=>k.mutate(),children:[e.jsx($,{className:"size-4"}),"Save as note"]}),e.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center justify-center gap-2 rounded-2xl bg-[rgba(255,185,95,0.16)] px-3 py-2 text-sm font-medium text-[var(--tertiary)] transition hover:bg-[rgba(255,185,95,0.24)] disabled:opacity-50",disabled:!d.trim()||S.isPending,onClick:()=>S.mutate(),children:[e.jsx(v,{className:"size-4"}),"Save as wiki"]})]})]})}const K={id:"surface:utility:time",surfaceId:"utility",routePath:null,title:"Clock",icon:"timer",description:"Live local time widget.",category:"Utilities",tags:["utility","clock"],inputs:[],params:[],output:[u({label:"Current time",description:"Formatted local time string published by the clock widget."}),m({key:"clock",label:"Clock state",description:"Structured clock state including the current ISO timestamp.",modelName:"ForgeClockState"})],tools:[],NodeView:f({title:"Clock",description:"Live local time widget.",inputs:[],params:[],output:[u({label:"Current time",description:"Formatted local time string published by the clock widget."}),m({key:"clock",label:"Clock state",description:"Structured clock state including the current ISO timestamp.",modelName:"ForgeClockState"})],tools:[]}),WebView:C,execute:t=>g(t,{clock:{now:t.context.now}},new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.context.now)))};C.workbench=K;const G={id:"surface:utility:mini-calendar",surfaceId:"utility",routePath:null,title:"Mini calendar",icon:"calendar",description:"Compact month calendar widget.",category:"Utilities",tags:["utility","calendar"],inputs:[],params:[],output:[u({label:"Month view",description:"Summary of the compact month calendar widget."}),m({key:"calendarView",label:"Calendar view",description:"Structured mini-calendar state including the current month anchor.",modelName:"ForgeMiniCalendarView"})],tools:[],NodeView:f({title:"Mini calendar",description:"Compact month calendar widget.",inputs:[],params:[],output:[u({label:"Month view",description:"Summary of the compact month calendar widget."}),m({key:"calendarView",label:"Calendar view",description:"Structured mini-calendar state including the current month anchor.",modelName:"ForgeMiniCalendarView"})],tools:[]}),WebView:W,execute:t=>g(t,{calendarView:{now:t.context.now}},"Compact month calendar")};W.workbench=G;const B={id:"surface:utility:spotify",surfaceId:"utility",routePath:null,title:"Spotify",icon:"music",description:"Pinned music link widget.",category:"Utilities",tags:["utility","spotify"],inputs:[{key:"surfaceId",label:"Surface id",kind:"text",required:!1}],params:[],output:[u({label:"Spotify link",description:"Summary of the pinned music link widget."}),m({key:"spotifyLink",label:"Spotify state",description:"Structured Spotify widget state and pinned surface context.",modelName:"ForgeSpotifyWidgetState"})],tools:[],NodeView:f({title:"Spotify",description:"Pinned music link widget.",inputs:[{key:"surfaceId",label:"Surface id",kind:"text"}],params:[],output:[u({label:"Spotify link",description:"Summary of the pinned music link widget."}),m({key:"spotifyLink",label:"Spotify state",description:"Structured Spotify widget state and pinned surface context.",modelName:"ForgeSpotifyWidgetState"})],tools:[]}),WebView:D,execute:t=>g(t,{spotifyLink:{surfaceId:t.inputs.surfaceId??null}},"Pinned Spotify link")};D.workbench=B;const H={id:"surface:utility:weather",surfaceId:"utility",routePath:null,title:"Weather",icon:"weather",description:"Location-aware weather widget.",category:"Utilities",tags:["utility","weather"],inputs:[],params:[],output:[u({label:"Weather summary",description:"Summary of the weather widget state."}),m({key:"weather",label:"Weather payload",description:"Structured weather widget payload.",modelName:"ForgeWeatherWidgetState"})],tools:[],NodeView:f({title:"Weather",description:"Location-aware weather widget.",inputs:[],params:[],output:[u({label:"Weather summary",description:"Summary of the weather widget state."}),m({key:"weather",label:"Weather payload",description:"Structured weather widget payload.",modelName:"ForgeWeatherWidgetState"})],tools:[]}),WebView:F,execute:t=>g(t,{weather:null},"Weather widget")};F.workbench=H;const X={id:"surface:utility:quick-capture",surfaceId:"utility",routePath:null,title:"Quick capture",icon:"capture",description:"Draft a quick note or wiki page.",category:"Capture",tags:["capture","notes"],inputs:[{key:"defaultUserId",label:"Default user id",kind:"text",required:!1}],params:[],output:[u({label:"Draft summary",description:"Summary of the quick-capture draft state."}),m({key:"draft",label:"Draft context",description:"Structured quick-capture draft context.",modelName:"ForgeQuickCaptureDraft"})],tools:[j("Create a Forge evidence note from captured markdown.")],NodeView:f({title:"Quick capture",description:"Draft a quick note or wiki page.",inputs:[{key:"defaultUserId",label:"Default user id",kind:"text"}],params:[],output:[u({label:"Draft summary",description:"Summary of the quick-capture draft state."}),m({key:"draft",label:"Draft context",description:"Structured quick-capture draft context.",modelName:"ForgeQuickCaptureDraft"})],tools:[j("Create a Forge evidence note from captured markdown.")]}),WebView:I,execute:t=>g(t,{draft:{defaultUserId:t.inputs.defaultUserId??null}},"Quick capture can draft notes and wiki pages.")};I.workbench=X;export{W as M,I as Q,D as S,C as T,F as W};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./vendor-Cpmju3nw.js";import{i as x}from"./state-BtwEvpO6.js";import{P as w}from"./page-hero-
|
|
1
|
+
import{j as e}from"./vendor-Cpmju3nw.js";import{i as x}from"./state-BtwEvpO6.js";import{P as w}from"./page-hero-C0MpI3MM.js";import{d as f,L as j,e as b,C as u,k as m,c as N,bf as M,bV as k}from"./index-BaiwtAgo.js";import{S as c,f as C,m as R,M as p,D}from"./daily-metrics-dashboard-Jt0nAHU5.js";import"./motion-DwjmC9aq.js";import"./ui-B9O-eUim.js";import"./board-CLOHbg6t.js";import"./forms-C5d5hTf2.js";import"./charts-DwTguE_x.js";const V=["restingHeartRate","heartRateVariabilitySDNN","vo2Max","oxygenSaturation","bodyMass","stepCount"];function y(t,a){return a.map(i=>({...i,metrics:t.filter(s=>s.category===i.category)}))}function S(t){return t}function B({metrics:t}){if(!t.summary.hasData||t.metrics.length===0)return null;const a=y(t.metrics,t.summary.categoryBreakdown),i=t.metrics.find(r=>r.metric==="devrageSwearCount")??null,s=t.metrics.find(r=>r.metric==="swearingMessagePercent")??null,d=t.metrics.find(r=>r.metric==="devrageAverageMaxCumulativeRage")??null,n=t.metrics.find(r=>r.metric==="devrageMaxCumulativeRage")??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(m,{className:"bg-amber-200/10 text-amber-50",children:[t.summary.trackedDays," tracked days"]})]}),e.jsx(D,{swearMetric:i,percentMetric:s,averageRageMetric:d,maxRageMetric:n,compact:!0}),e.jsxs("div",{className:"grid gap-4 xl:grid-cols-4",children:[e.jsx(c,{title:"Devrage count",description:"Daily user-message swear count from stored conversation history.",metric:i}),e.jsx(c,{title:"Swearing rate",description:"Share of scanned user messages that contained at least one tracked swear.",metric:s}),e.jsx(c,{title:"Average rage peak",description:"Average per-thread peak after swears add and clean messages cool the score down.",metric:d}),e.jsx(c,{title:"Max rage peak",description:"Highest cumulative thread score reached on the latest tracked day.",metric:n})]}),e.jsx(p,{groups:a})]})}function U(){var h;const t=f(),a=x({queryKey:["forge-vitals-view",...t.selectedUserIds],queryFn:async()=>(await M(t.selectedUserIds)).vitals}),i=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,d=s.metrics.map(S),n=V.map(o=>d.find(l=>l.metric===o)??null),r=s.summary.categoryBreakdown,v=y(d,r),g=!i.isError&&((h=i.data)!=null&&h.summary.hasData)?i.data:null;return e.jsxs("div",{className:"mx-auto grid w-full max-w-[1380px] gap-5",children:[e.jsx(w,{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(c,{title:"Recovery pulse",description:"Resting heart rate and HRV are the fastest read on load, stress, and whether today needs a gentler edge.",metric:n[0]??n[1]}),e.jsx(c,{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:n[2]}),e.jsx(c,{title:"Breath and oxygen",description:"Respiratory rate and oxygen saturation help catch nights or stretches where recovery quality starts to slip.",metric:n[3]}),e.jsx(c,{title:"Body composition",description:"Mass and composition stay close to the daily story so progress is visible without flattening everything into weight alone.",metric:n[4]})]}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.1fr)_minmax(340px,0.9fr)]",children:[e.jsxs(u,{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(m,{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:r.map(o=>{const l=R(o.category);return e.jsxs("div",{className:N("rounded-[22px] border bg-white/[0.03] p-4",l.ring),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(m,{className:l.badge,children:o.category}),e.jsxs("div",{className:"text-xs text-white/44",children:[o.coverageDays," days"]})]}),e.jsx("div",{className:"mt-3 text-2xl font-semibold text-white",children:o.metricCount}),e.jsxs("div",{className:"mt-1 text-sm text-white/58",children:["active metric",o.metricCount===1?"":"s"]})]},o.category)})})]}),e.jsx(u,{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(p,{groups:v}),g?e.jsx(B,{metrics:g}):null]})}export{U as VitalsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./vendor-Cpmju3nw.js";import{j as p,i as f,k as g}from"./state-BtwEvpO6.js";import{F as j}from"./flagship-signal-deck-
|
|
1
|
+
import{j as e}from"./vendor-Cpmju3nw.js";import{j as p,i as f,k as g}from"./state-BtwEvpO6.js";import{F as j}from"./flagship-signal-deck-CJbGZF7I.js";import{u as k,S as b,e as v,C as w,k as h,B as N,eB as R,i as $,eC as S}from"./index-BaiwtAgo.js";import{P as z}from"./page-hero-C0MpI3MM.js";import"./motion-DwjmC9aq.js";import"./ui-B9O-eUim.js";import"./board-CLOHbg6t.js";import"./forms-C5d5hTf2.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 K(){var u;const{t:s}=k(),m=p(),t=f({queryKey:["forge-weekly-review"],queryFn:S}),c=g({mutationFn:R,onSuccess:async()=>{await Promise.all([m.invalidateQueries({queryKey:["forge-weekly-review"]}),m.invalidateQueries({queryKey:["forge-xp-metrics"]}),m.invalidateQueries({queryKey:["forge-reward-ledger"]}),$(m),m.invalidateQueries({queryKey:["activity-archive"]})])}}),i=(u=t.data)==null?void 0:u.review;if(t.isLoading)return e.jsx(b,{});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,y=[{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(N,{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:y})]})}export{K as WeeklyReviewPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as a,bX as Be,aG as ua,b7 as ga,cg as Ba,dx as Ha,cB as za,bB as Ie,cm as qa,cF as ma,c8 as Oa,c1 as ha,dy as Ua,dz as Qa,bq as pa,dA as Va,dB as Ya,r as K,d8 as Ja,bt as ea,dC as Za,br as Xa,bd as et}from"./vendor-Cpmju3nw.js";import{j as at,i as tt,k as U}from"./state-BtwEvpO6.js";import{P as nt}from"./page-hero-DlHEJ0Yt.js";import{C as V,a4 as le,B as D,I as w,c as Pe,k as E,T as ke,d as rt,L as st,e as it,e8 as aa,e9 as ot,ea as lt,eb as ct,ec as ta,ed as dt,ee as ut,ef as gt,eg as mt,eh as ht,ei as pt,ej as bt}from"./index-BejvcRGb.js";import{S as I,a as M}from"./surface-B3oXO1No.js";import{Q as Ce,F as j,a as na}from"./question-flow-dialog-BByFV8Yw.js";import{f as We}from"./date-keys-Cj1G3TOn.js";import"./motion-DwjmC9aq.js";import"./ui-B9O-eUim.js";import"./board-CLOHbg6t.js";import"./forms-C5d5hTf2.js";function xt({view:e,onOpenPlan:t,onOpenFoodSearch:n,onOpenCustomFood:r,onOpenChatGptFood:s,onOpenCheckin:d,onOpenHistory:g}){const l=[{label:"Plan target",value:`${e.target.calorieTarget.toFixed(0)} kcal`},{label:"Protein",value:`${e.target.proteinGramsTarget.toFixed(0)}g`},{label:"Fiber",value:`${e.target.fiberGramsTarget.toFixed(0)}g`}];return a.jsxs(V,{className:"grid gap-4 border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)] p-5",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:[a.jsx("span",{children:"Control center"}),a.jsx(le,{label:"Explain weight-loss controls",content:"Use these actions to change the nutrition plan, log food, or record body signals. The day budget cards above use today's active-calorie source; the plan target here is the baseline target before today's active adjustment."})]}),a.jsx("h2",{className:"mt-1 text-xl font-semibold leading-tight text-[var(--ui-ink-strong)]",children:e.target.bodyGoal?`Goal: ${e.target.bodyGoal}`:"Set the body objective"}),a.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Adjust the baseline plan, log food with exact quantities, or record body signals from guided flows."})]}),a.jsx("div",{className:"grid gap-2 sm:grid-cols-3 xl:grid-cols-1 min-[1360px]:grid-cols-3",children:l.map(o=>a.jsxs("div",{className:"min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-2",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:o.label}),a.jsx("div",{className:"mt-1 truncate text-sm font-semibold text-[var(--ui-ink-strong)]",children:o.value})]},o.label))}),a.jsxs("div",{className:"grid min-w-0 grid-cols-2 gap-2",children:[a.jsxs(D,{type:"button",onClick:r,children:[a.jsx(Be,{className:"size-4"}),"Custom food"]}),a.jsxs(D,{type:"button",variant:"secondary",onClick:s,children:[a.jsx(ua,{className:"size-4"}),"Ask ChatGPT"]}),a.jsxs(D,{type:"button",variant:"secondary",onClick:n,children:[a.jsx(ga,{className:"size-4"}),"Search food"]}),a.jsxs(D,{type:"button",variant:"secondary",onClick:t,children:[a.jsx(Ba,{className:"size-4"}),"Plan settings"]}),a.jsxs(D,{type:"button",variant:"secondary",onClick:d,children:[a.jsx(Ha,{className:"size-4"}),"Add measure"]}),a.jsxs(D,{type:"button",variant:"secondary",onClick:g,children:[a.jsx(za,{className:"size-4"}),"Food history"]})]})]})}function _(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function oe(e){return typeof e=="string"&&e.trim()?e:null}function i(e,t=0){const n=_(e);return n===null?"n/a":n.toFixed(t)}function H(e,t=0){const n=_(e);return n===null?"n/a":`${n>0?"+":""}${n.toFixed(t)}`}function ye(e){const t=_(e);return t===null?"n/a":`${t.toFixed(1)}/10`}function ft(e){return Array.isArray(e)?e.filter(t=>!!t&&typeof t=="object"&&!Array.isArray(t)):[]}function vt(e){switch(e){case"user_override":return"Manual override for today";case"today_healthkit_active_energy":return"HealthKit active energy today";case"today_workout_movement_energy":return"Workout + movement today";case"today_workout_movement_step_energy":return"Workout + movement + steps today";case"today_workout_step_energy":return"Workout + steps today";case"today_movement_step_energy":return"Movement + steps today";case"today_workout_energy":return"Workout energy today";case"today_movement_trip_calories":return"Movement trips today";case"today_step_estimate":return"Step estimate today";default:return"Past-week active baseline"}}function yt(e){switch(e){case"user_override":return"Using your manual value for today.";case"today_healthkit_active_energy":return"Using same-day HealthKit active energy instead of the baseline.";case"today_workout_movement_energy":return"Using today's workout and movement calories instead of the baseline.";case"today_workout_movement_step_energy":return"Using today's workouts, movement, and steps instead of the baseline.";case"today_workout_step_energy":return"Using today's workouts and steps instead of the baseline.";case"today_movement_step_energy":return"Using today's movement and steps instead of the baseline.";case"today_workout_energy":return"Using today's workout calories instead of the baseline.";case"today_movement_trip_calories":return"Using today's movement calories instead of the baseline.";case"today_step_estimate":return"Using today's step estimate because it is above the baseline.";default:return"No meaningful same-day active evidence yet, so the past-week active baseline is used."}}function jt(e){return`${e>=0?"+":""}${e.toFixed(0)} kcal`}function kt(e){return e.trim()===""?"0":e}function Nt({view:e,draftValue:t,pending:n,error:r,onDraftChange:s,onSave:d,onReset:g}){const l=e.energyModel,o=e.todayLedger,u=l.todayActiveOverride,C=l.todayActiveCaloriesSource,A=`${o.plannedTargetCalories.toFixed(0)} ${jt(l.todayTargetAdjustmentKcal)} = ${o.targetCalories.toFixed(0)} kcal`;return a.jsxs(V,{className:"grid min-w-0 gap-3 border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[a.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-1 text-[11px] uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:["Active kcal",a.jsx(le,{label:"Explain active calories",content:`Today target = baseline food target plus the day-specific active adjustment. ${A}. Automatic same-day activity can only add ${Math.round(l.activityEatBackFraction*100)}% of the positive surplus above the baseline day. A manual edit overrides today only and can raise or lower the target.`})]}),a.jsxs("div",{className:"mt-1 text-2xl font-semibold leading-tight text-[var(--ui-ink-strong)]",children:[l.todayActiveCaloriesKcal.toFixed(0)," kcal"]})]}),a.jsx("div",{className:"rounded-[8px] bg-[var(--ui-info-soft)] p-2 text-[color-mix(in_srgb,var(--info)_78%,var(--ui-ink-strong)_22%)]",children:a.jsx(Ie,{className:"size-4"})})]}),a.jsxs("div",{className:"grid gap-1 text-xs leading-5 text-[var(--ui-ink-soft)]",children:[a.jsx("div",{className:"break-words font-medium text-[var(--ui-ink-medium)]",children:yt(C)}),a.jsxs("div",{children:["Baseline ",l.baselineActiveCaloriesKcal.toFixed(0)," kcal"," · ","observed"," ",l.todayObservedActiveCaloriesKcal!=null?`${l.todayObservedActiveCaloriesKcal.toFixed(0)} kcal`:"n/a"]}),a.jsxs("div",{className:"break-words",children:["Source: ",vt(C)]})]}),a.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(0,1fr)_auto] gap-2",children:[a.jsx(w,{inputMode:"decimal",value:t,onChange:f=>s(kt(f.target.value)),"aria-label":"Today active calories",className:"py-2.5"}),a.jsxs(D,{type:"button",onClick:d,pending:n,pendingLabel:"Applying",children:[a.jsx(qa,{className:"size-4"}),"Apply"]})]}),a.jsxs(D,{type:"button",variant:"secondary",onClick:g,disabled:!u||n,children:[a.jsx(ma,{className:"size-4"}),"Use evidence"]}),r?a.jsx("div",{className:"rounded-[8px] border border-[var(--danger)]/20 bg-[var(--ui-danger-soft)] px-3 py-2 text-xs leading-5 text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",children:r}):null]})}const wt={default:"bg-[color-mix(in_srgb,var(--primary)_14%,transparent)] text-[var(--primary)]",green:"bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_78%,var(--ui-ink-strong)_22%)]",amber:"bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_76%,var(--ui-ink-strong)_24%)]",rose:"bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",cyan:"bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_78%,var(--ui-ink-strong)_22%)]"};function Z({label:e,value:t,detail:n,icon:r,tone:s="default",help:d,helpMaxWidthPx:g}){return a.jsxs(V,{className:"grid gap-4 border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5",children:[a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsx("div",{className:Pe("rounded-2xl p-2.5",wt[s]),children:a.jsx(r,{className:"size-5"})}),a.jsxs("div",{className:"flex items-center justify-end gap-1 text-right text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:[a.jsx("span",{children:e}),d?a.jsx(le,{content:d,label:`Explain ${e}`,maxWidthPx:g}):null]})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-3xl font-semibold text-[var(--ui-ink-strong)]",children:t}),a.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:n})]})]})}function Ct({meal:e,onLogAgain:t,onEdit:n,onDelete:r,pending:s=!1}){const d=e.items[0]??null,g=Math.max(0,e.items.length-1),l=d?`${d.name}${g>0?` + ${g} more`:""}`:e.mealLabel??"Meal",o=e.items.slice(0,3).map(u=>{const C=Number.isFinite(u.quantity)&&u.quantity>0?Number.isInteger(u.quantity)?String(u.quantity):u.quantity.toFixed(2).replace(/\.?0+$/,""):null,A=u.unit??"serving",f=u.grams!=null?`${u.grams.toFixed(0)}g`:null;return[C,A,f?`(${f})`:null].filter(Boolean).join(" ")}).filter(Boolean).join(" · ");return a.jsxs(I,{className:"grid min-w-0 gap-3",children:[a.jsxs("div",{className:"flex min-w-0 flex-wrap items-start justify-between gap-3",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"break-words text-base font-semibold leading-6 text-[var(--ui-ink-strong)]",children:l}),a.jsx("div",{className:"mt-1 text-xs leading-5 text-[var(--ui-ink-faint)]",children:o||e.notes||"No quantity recorded"})]}),a.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.mealLabel?a.jsx(E,{tone:"meta",children:e.mealLabel}):null,a.jsxs(E,{tone:"meta",children:[e.totals.calories.toFixed(0)," kcal"]})]})]}),a.jsxs("div",{className:"grid gap-2 text-xs text-[var(--ui-ink-soft)] sm:grid-cols-3 xl:grid-cols-6",children:[a.jsxs("span",{children:[e.totals.proteinGrams.toFixed(0),"g protein"]}),a.jsxs("span",{children:[e.totals.carbohydrateGrams.toFixed(0),"g carbs"]}),a.jsxs("span",{children:[e.totals.fatGrams.toFixed(0),"g fat"]}),a.jsxs("span",{children:[e.totals.fiberGrams.toFixed(0),"g fiber"]}),a.jsxs("span",{children:[e.totals.sodiumMg.toFixed(0),"mg sodium"]}),a.jsx("span",{children:e.confirmationState})]}),a.jsxs("div",{className:"flex flex-wrap gap-2",children:[n?a.jsxs(D,{type:"button",size:"sm",variant:"secondary",onClick:()=>n(e),children:[a.jsx(Oa,{className:"size-4"}),"Edit"]}):null,r?a.jsxs(D,{type:"button",size:"sm",variant:"ghost",pending:s,onClick:()=>r(e),children:[a.jsx(ha,{className:"size-4"}),"Delete"]}):null,t?a.jsxs(D,{type:"button",size:"sm",variant:"ghost",pending:s,onClick:()=>t(e),children:[a.jsx(ma,{className:"size-4"}),"Log again"]}):null]})]})}function He({children:e}){return a.jsx(I,{className:"border-dashed border-[var(--ui-border-strong)] p-5 text-sm text-[var(--ui-ink-soft)]",children:e})}function Ne(e){return`${e.toFixed(0)} kcal`}function Mt(e){return e>=0?"Kcal left":"Over target"}function Ft(e){return e>=0?Ne(e):Ne(Math.abs(e))}function Kt({ledger:e,remainingCalories:t,intakePercent:n,logSavedPending:r,onLogAgain:s,onEditMeal:d,onDeleteMeal:g}){const l=e.totals;return a.jsxs(V,{className:"grid gap-5 border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5",children:[a.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Food log"}),a.jsxs("h2",{className:"mt-1 flex items-center gap-2 text-xl font-semibold text-[var(--ui-ink-strong)]",children:[a.jsx("span",{children:"Calories, macros, and meal evidence"}),a.jsx(le,{label:"Explain food log",content:"The food log is today's editable record of what was eaten. Edit a meal to change quantities, remove items, correct food parameters, or delete the meal entirely."})]})]}),a.jsxs(E,{tone:"meta",children:[e.meals.length," meals"]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"mb-4 grid gap-3 sm:grid-cols-3",children:[a.jsxs("div",{className:"min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3",children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:"Eaten today"}),a.jsx("div",{className:"mt-1 text-2xl font-semibold text-[var(--ui-ink-strong)]",children:Ne(l.calories)})]}),a.jsxs("div",{className:"min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3",children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:"Target today"}),a.jsx("div",{className:"mt-1 text-2xl font-semibold text-[var(--ui-ink-strong)]",children:Ne(e.targetCalories)})]}),a.jsxs("div",{className:Pe("min-w-0 rounded-[8px] border p-3",t>=0?"border-[color-mix(in_srgb,var(--success)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-success-soft)]":"border-[color-mix(in_srgb,var(--danger)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-danger-soft)]"),children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:Mt(t)}),a.jsx("div",{className:"mt-1 text-2xl font-semibold text-[var(--ui-ink-strong)]",children:Ft(t)})]})]}),a.jsx("div",{className:"h-3 overflow-hidden rounded-full bg-[var(--ui-surface-2)]",children:a.jsx("div",{className:Pe("h-full rounded-full",t>=0?"bg-[color-mix(in_srgb,var(--success)_82%,var(--secondary)_18%)]":"bg-[color-mix(in_srgb,var(--danger)_82%,var(--tertiary)_18%)]"),style:{width:`${Math.min(100,n)}%`}})}),a.jsxs("div",{className:"mt-3 grid gap-2 text-sm text-[var(--ui-ink-soft)] sm:grid-cols-4",children:[a.jsxs("span",{children:[l.carbohydrateGrams.toFixed(0),"g carbs"]}),a.jsxs("span",{children:[l.fatGrams.toFixed(0),"g fat"]}),a.jsxs("span",{children:[l.fiberGrams.toFixed(0),"g fiber"]}),a.jsxs("span",{children:[e.unconfirmedCount," unconfirmed"]})]})]}),a.jsx("div",{className:"grid gap-3",children:e.meals.length>0?e.meals.map(o=>a.jsx(Ct,{meal:o,pending:r,onLogAgain:s,onEdit:d,onDelete:g},o.id)):a.jsx(He,{children:"No meals logged today yet."})})]})}function At({hypotheses:e}){return a.jsxs(V,{className:"grid gap-4 border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Hypotheses"}),a.jsx("h2",{className:"mt-1 text-xl font-semibold text-[var(--ui-ink-strong)]",children:"Food and body pattern candidates"})]}),a.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:e.length>0?e.slice(0,6).map((t,n)=>a.jsxs(I,{children:[a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsx(E,{tone:"signal",children:oe(t.metric)??"pattern"}),a.jsx("span",{className:"text-xs text-[var(--ui-ink-faint)]",children:i(t.confidence,2)})]}),a.jsx("div",{className:"mt-3 text-sm font-medium text-[var(--ui-ink-strong)]",children:oe(t.label)??"Candidate pattern"}),a.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:oe(t.description)??"Forge needs more paired meals and check-ins to harden this signal."})]},String(t.key??n))):a.jsx("div",{className:"md:col-span-2",children:a.jsx(He,{children:"Log meals plus energy, gut, and look check-ins for a few days to generate pattern candidates."})})})]})}function Gt({experiments:e}){return a.jsxs(V,{className:"grid content-start gap-4 border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"rounded-2xl bg-[var(--ui-info-soft)] p-2.5 text-[color-mix(in_srgb,var(--info)_78%,var(--ui-ink-strong)_22%)]",children:a.jsx(Ua,{className:"size-5"})}),a.jsxs("div",{children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Experiments"}),a.jsx("h2",{className:"text-xl font-semibold text-[var(--ui-ink-strong)]",children:"N-of-1 lab"})]})]}),a.jsxs("div",{className:"grid gap-3",children:[e.slice(0,4).map((t,n)=>a.jsxs(I,{children:[a.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:oe(t.title)??"Nutrition experiment"}),a.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:oe(t.hypothesis)??oe(t.intervention)??"No hypothesis recorded."})]},String(t.id??n))),e.length===0?a.jsx(He,{children:"Start experiments from OpenClaw or the API: caffeine timing, fiber ramp, low-FODMAP trial, carb timing, sodium/puffiness, or pre-training fueling."}):null]})]})}function St({view:e}){const t=e.dataQuality,n=e.todayLedger;return a.jsxs(V,{className:"grid gap-4 border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5",children:[a.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Data quality"}),a.jsx("h2",{className:"mt-1 text-xl font-semibold text-[var(--ui-ink-strong)]",children:"Confidence, coverage, and next evidence"})]}),a.jsxs(E,{tone:"meta",children:[e.summary.dataQualityScore.toFixed(0),"% coverage"]})]}),a.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[a.jsx(Dt,{label:"Source confidence",value:t.sourceConfidence,children:"Food parsing stays candidate-based until accepted; wearable burn is treated as a trend input."}),a.jsxs(I,{children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Missing check-ins"}),a.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:t.missingHighValueCheckins.length>0?t.missingHighValueCheckins.map(r=>a.jsx(E,{tone:"signal",children:r},r)):a.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Core evidence loop is covered."})})]}),a.jsxs(I,{children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Next best cue"}),a.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:t.notes}),a.jsxs("div",{className:"mt-3 text-xs text-[var(--ui-ink-faint)]",children:[n.unconfirmedCount," unconfirmed candidate",n.unconfirmedCount===1?"":"s"]})]})]})]})}function Dt({label:e,value:t,children:n}){return a.jsxs(I,{children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:e}),a.jsx("div",{className:"mt-2 text-lg font-semibold text-[var(--ui-ink-strong)]",children:t}),a.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:n})]})}const Q={id:"hall_niddk_linearized_adult_12w",label:"Hall/NIDDK linearized adult model",defaultPlanningHorizonDays:84,steadyStateKcalPerKgPerDay:10/.45359237,timeConstantDays:365,staticEnergyDensityKcalPerKg:7700};function $e(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function ba(e={}){const t=$e(e.planningHorizonDays)??Q.defaultPlanningHorizonDays,n=$e(e.timeConstantDays)??Q.timeConstantDays,r=$e(e.steadyStateKcalPerKgPerDay)??Q.steadyStateKcalPerKgPerDay,s=1-Math.exp(-t/n);return{planningHorizonDays:t,timeConstantDays:n,steadyStateKcalPerKgPerDay:r,responseFraction:s}}function xa(e,t={}){if(typeof e!="number"||!Number.isFinite(e))return null;if(e===0)return 0;const n=ba(t);return n.responseFraction<=0?null:e*(n.planningHorizonDays/7)*n.steadyStateKcalPerKgPerDay/n.responseFraction}function _t(e,t={}){if(typeof e!="number"||!Number.isFinite(e))return null;if(e===0)return 0;const n=ba(t);return e/n.steadyStateKcalPerKgPerDay*n.responseFraction/(n.planningHorizonDays/7)}function Et(e){return typeof e!="number"||!Number.isFinite(e)?null:e*Q.staticEnergyDensityKcalPerKg/7}function B(e,t,n){return a.jsxs("li",{className:"grid gap-0.5",children:[a.jsx("span",{className:"font-medium text-[var(--ui-ink)]",children:e}),a.jsx("code",{className:"rounded-[6px] bg-[var(--ui-surface-2)] px-1.5 py-0.5 font-mono text-[11px] text-[var(--ui-ink-soft)]",children:t}),n?a.jsx("span",{className:"text-xs text-[var(--ui-ink-faint)]",children:n}):null]})}function fa({values:e,label:t="Show calorie and macro formulas"}){const r=((e==null?void 0:e.sex)??"male")==="male"?"+ 5":"- 161",s=(e==null?void 0:e.proteinFactor)!=null?`${e.proteinFactor.toFixed(1)}g/kg`:"1.6-2.0g/kg";return a.jsx(le,{label:t,title:"Weight Loss Formulas",maxWidthPx:520,panelClassName:"text-xs leading-5",content:a.jsxs("div",{className:"grid gap-3",children:[a.jsx("p",{children:"Forge keeps activity independent from the goal. The goal only adds a deficit, surplus, or zero adjustment to the formula resting baseline plus active calories. Complete HealthKit basal energy is calibration evidence, not the silent baseline."}),a.jsxs("ol",{className:"grid gap-2",children:[B("Mifflin-St Jeor resting baseline",`10 x weight kg + 6.25 x height cm - 5 x age ${r}`,`Current formula value: ${i(e==null?void 0:e.bmrKcal)} kcal/day.`),B("Resting calories","Mifflin-St Jeor formula baseline; HealthKit basal is complete-day evidence only",`Using: ${i(e==null?void 0:e.restingKcal)} kcal/day${e!=null&&e.restingSource?` (${e.restingSource})`:""}.`),B("Maintenance calories","resting calories + active calories",`${i(e==null?void 0:e.restingKcal)} + ${i(e==null?void 0:e.activeKcal)} = ${i(e==null?void 0:e.maintenanceKcal)} kcal/day.`),B("Objective adjustment","Hall/NIDDK linearized adult model, inverted over the planning horizon",`Weekly rate ${H(e==null?void 0:e.weeklyRateKg,2)} kg/week gives ${H(e==null?void 0:e.dailyAdjustmentKcal)} kcal/day${e!=null&&e.rateModel?` with ${e.rateModel}`:""}${e!=null&&e.rateModelHorizonDays?` over ${e.rateModelHorizonDays} days`:""}.`),B("Daily calorie target","max(sex floor, maintenance + objective adjustment)",`Floor ${i(e==null?void 0:e.calorieFloor)} kcal; target ${i(e==null?void 0:e.calorieTarget)} kcal/day.`),B("Protein target",`min(reference weight x ${s}, 45% of kcal / 4)`,`Reference ${i(e==null?void 0:e.proteinReferenceWeightKg,1)} kg; target ${i(e==null?void 0:e.proteinGrams)} g/day.`),B("Fat target","saved plan fat when present; otherwise min(remaining kcal after protein, 35% kcal / 9, max(0.6g/kg reference, 25% kcal / 9))",`Target ${i(e==null?void 0:e.fatGrams)} g/day.`),B("Carbohydrate target","(calorie target - protein g x 4 - fat g x 9) / 4",`Target ${i(e==null?void 0:e.carbohydrateGrams)} g/day. The 130g DRI is shown as reference, not forced if it breaks calories.`),B("Fiber target","14g per 1000 kcal; adult sex/age AI shown as reference",`Target ${i(e==null?void 0:e.fiberGrams)} g/day; energy-adjusted ${i(e==null?void 0:e.fiberEnergyAdjustedGrams)} g/day; adult AI reference ${i(e==null?void 0:e.fiberDriGrams)} g/day.`),B("Sport-loss estimate","training hours ~= active kcal / 500; sweat ~= 0.4-0.8 L/h; sodium ~= 500-1000 mg/L","Shown as expected loss ranges, not rigid supplement instructions.")]})]})})}function va(e,t){var r;if(!e)return null;const n=e.match(new RegExp(`${t}=([^;]+)`));return((r=n==null?void 0:n[1])==null?void 0:r.trim())??null}function me(e,t){const n=typeof e=="string"?Number(e):_(e);return typeof n=="number"&&Number.isFinite(n)?n:t}function $t(e){return va(e.target.notes,"sex")==="female"?"female":"male"}function Tt(e){return me(va(e.target.notes,"age_years"),35)}function h(e,t,n,r,s,d){return{id:e,label:t,target:typeof n=="number"?Re(n):n,unit:r,note:s,source:d}}function Re(e){return Number.isFinite(e)?Math.abs(e)>=100?e.toFixed(0):e.toFixed(1).replace(/\.0$/,""):"n/a"}function se(e,t){return`${Re(e)}-${Re(t)}`}function Lt(e,t,n,r){const s=Math.round(n/1e3*14);return r>0?r:s}function It({calorieTarget:e,currentWeightKg:t,protein:n,savedFat:r}){const s=Math.max(0,(e-n*4)/9),d=Math.max(0,Math.min(s,e*.35/9,Math.max(t*.6,e*.25/9))),g=r??d;return{carbs:Math.max(0,(e-n*4-g*9)/4),fat:g}}function Pt(e,t){return e==="male"?t>=51?14:17:t>=51?11:12}function Wt(e,t){const n=t>70,r=t>=51;return[h("vitamin_a","Vitamin A",e==="male"?900:700,"ug RAE","Retinol activity equivalent target.","NASEM DRI"),h("vitamin_c","Vitamin C",e==="male"?90:75,"mg","Adult RDA.","NASEM DRI"),h("vitamin_d","Vitamin D",n?20:15,"ug","Assumes limited sun exposure; older adults need more.","NASEM DRI"),h("vitamin_e","Vitamin E",15,"mg alpha-tocopherol","Adult RDA.","NASEM DRI"),h("vitamin_k","Vitamin K",e==="male"?120:90,"ug","Adult AI.","NASEM DRI"),h("thiamin_b1","Thiamin B1",e==="male"?1.2:1.1,"mg","Adult RDA.","NASEM DRI"),h("riboflavin_b2","Riboflavin B2",e==="male"?1.3:1.1,"mg","Adult RDA.","NASEM DRI"),h("niacin_b3","Niacin B3",e==="male"?16:14,"mg NE","Adult RDA.","NASEM DRI"),h("vitamin_b6","Vitamin B6",r?e==="male"?1.7:1.5:1.3,"mg","RDA rises after 50.","NASEM DRI"),h("folate","Folate",400,"ug DFE","Adult RDA.","NASEM DRI"),h("vitamin_b12","Vitamin B12",2.4,"ug","Adult RDA.","NASEM DRI"),h("pantothenic_acid","Pantothenic acid",5,"mg","Adult AI.","NASEM DRI"),h("biotin","Biotin",30,"ug","Adult AI.","NASEM DRI"),h("choline","Choline",e==="male"?550:425,"mg","Adult AI.","NASEM DRI")]}function Rt(e,t){const n=t>70||e==="female"&&t>=51?1200:1e3,r=e==="male"?t>=31?420:400:t>=31?320:310,s=e==="male"?t>=51?30:35:t>=51?20:25,d=t>=71?1800:t>=51?2e3:2300;return[h("calcium","Calcium",n,"mg","Bone and muscle target; higher for older adults and women 51+.","NASEM DRI"),h("iron","Iron",e==="female"&&t<=50?18:8,"mg","Menstruating-age female target is higher.","NASEM DRI"),h("magnesium","Magnesium",r,"mg","Adult RDA.","NASEM DRI"),h("phosphorus","Phosphorus",700,"mg","Adult RDA.","NASEM DRI"),h("zinc","Zinc",e==="male"?11:8,"mg","Adult RDA.","NASEM DRI"),h("iodine","Iodine",150,"ug","Adult RDA.","NASEM DRI"),h("selenium","Selenium",55,"ug","Adult RDA.","NASEM DRI"),h("copper","Copper",.9,"mg","Adult RDA.","NASEM DRI"),h("manganese","Manganese",e==="male"?2.3:1.8,"mg","Adult AI.","NASEM DRI"),h("chromium","Chromium",s,"ug","Adult AI.","NASEM DRI"),h("molybdenum","Molybdenum",45,"ug","Adult RDA.","NASEM DRI"),h("fluoride","Fluoride",e==="male"?4:3,"mg","Adult AI.","NASEM DRI"),h("chloride","Chloride",d,"mg","Adult AI.","NASEM DRI"),h("potassium","Potassium",e==="male"?3400:2600,"mg","Current adult AI for non-pregnant adults.","NASEM DRI"),h("sodium_limit","Sodium ceiling",2300,"mg max","Default daily ceiling unless medically individualized.","U.S. Dietary Guidelines")]}function Bt(e){const t=$t(e),n=Tt(e),r=me(e.weightTrend.latestWeightKg,80),s=Math.max(1,me(e.target.calorieTarget,2200)),d=me(e.target.proteinGramsTarget,r*1.8),{carbs:g,fat:l}=It({calorieTarget:s,currentWeightKg:r,protein:d,savedFat:_(e.target.fatGramsTarget)}),o=Lt(t,n,s,me(e.target.fiberGramsTarget,0)),u=_(e.energyModel.activeBurnKcal)??_(e.energyModel.activeEnergyCalories)??null,C=_(e.energyModel.movementCaloriesKcal),A=_(e.energyModel.restingEnergyCalories);return ya({sex:t,ageYears:n,currentWeightKg:r,calorieTarget:s,proteinGramsTarget:d,carbohydrateGramsTarget:g,fatGramsTarget:l,fiberGramsTarget:o,activeBurnKcal:u,movementCaloriesKcal:C,restingEnergyKcal:A})}function ya(e){const{sex:t,ageYears:n,currentWeightKg:r,calorieTarget:s,proteinGramsTarget:d,carbohydrateGramsTarget:g,fatGramsTarget:l,fiberGramsTarget:o,activeBurnKcal:u,movementCaloriesKcal:C,restingEnergyKcal:A}=e,f=u!=null?Math.min(4,Math.max(.1,u/500)):null,b=f!=null?f*.4:null,p=f!=null?f*.8:null,y=b!=null?b*500:null,k=p!=null?p*1e3:null,$=b!=null?b*78:null,T=p!=null?p*312:null,P=u!=null?_t(u):null;return{profile:{sex:t,ageYears:n,currentWeightKg:r,calorieTarget:s,activeBurnKcal:u,movementCaloriesKcal:C,restingEnergyKcal:A},macros:[h("calories","Calories",s,"kcal","Plan target from BMR, active burn, and chosen weekly rate.","Forge plan"),h("protein","Protein",d,"g","Higher than the population RDA to preserve lean mass during weight change.","ISSN + Forge plan"),h("carbohydrate","Carbohydrate",g,"g","Remaining fuel after protein and fat. It may sit below the 130g/day adult DRI reference when needed to preserve the calorie target.","NASEM DRI + Forge plan"),h("fat","Total fat",l,"g","Uses the saved plan fat target when present; generated defaults aim for a practical floor around 0.6g/kg or 20-35% of calories when possible.","NASEM AMDR + Forge plan"),h("fiber","Fiber",o,"g","Uses 14g per 1000 kcal as the plan target; the sex/age adult AI remains a reference or stretch value when calories are low.","NASEM DRI"),h("saturated_fat","Saturated fat",s*.1/9,"g max","Keep below 10% of energy.","U.S. Dietary Guidelines"),h("added_sugar","Added sugar",s*.1/4,"g max","Keep below 10% of energy; lower is better when feasible.","U.S. Dietary Guidelines"),h("linoleic_acid","Linoleic acid",Pt(t,n),"g","Essential n-6 fatty acid AI.","NASEM DRI"),h("ala","ALA omega-3",t==="male"?1.6:1.1,"g","Essential n-3 fatty acid AI.","NASEM DRI"),h("water","Total water",t==="male"?3.7:2.7,"L","All beverages and food water before extra training replacement.","NASEM DRI")],vitamins:Wt(t,n),minerals:Rt(t,n),sportLosses:[h("training_time","Estimated training time",f??"n/a","h/day","Derived from active burn at roughly 500 kcal/h.","Forge sport-loss model"),h("sweat_fluid","Expected sweat fluid",b!=null&&p!=null?se(b,p):"n/a","L/day","Planning range uses 0.4-0.8 L/h; measure body mass change to calibrate.","ACSM"),h("sweat_sodium","Expected sweat sodium",y!=null&&k!=null?se(y,k):"n/a","mg/day","Sodium varies widely; this uses a conservative range around common sweat sodium values.","ACSM + Sports Medicine review"),h("sweat_potassium","Expected sweat potassium",$!=null&&T!=null?se($,T):"n/a","mg/day","Potassium is usually much smaller than sodium but useful for long/hot sessions.","Sports Medicine review"),h("gross_sport_equivalent","Gross sport burn equivalent",P??"n/a","kg/week","Energy equivalent if the active burn were not eaten back; the plan may already include it.","Hall/NIDDK dynamic model")],sportSummary:{trainingHours:f,fluidLossLiters:b!=null&&p!=null?se(b,p):"n/a",sodiumLossMg:y!=null&&k!=null?se(y,k):"n/a",potassiumLossMg:$!=null&&T!=null?se($,T):"n/a",grossSportWeightEquivalentKgPerWeek:P}}}function Te({rows:e,compact:t=!1}){return a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"grid gap-2 md:hidden",children:e.map(n=>a.jsxs("div",{className:"grid min-w-0 gap-2 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-3",children:[a.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[a.jsx("div",{className:"min-w-0 break-words text-sm font-semibold text-[var(--ui-ink)]",children:n.label}),a.jsxs("div",{className:"shrink-0 text-right text-sm font-semibold text-[var(--ui-ink)]",children:[n.target,a.jsx("div",{className:"text-xs font-normal text-[var(--ui-ink-faint)]",children:n.unit})]})]}),a.jsx("p",{className:"min-w-0 break-words text-xs leading-5 text-[var(--ui-ink-muted)]",children:n.note}),t?null:a.jsx(E,{tone:"meta",wrap:!0,className:"justify-self-start",children:n.source})]},n.id))}),a.jsx("div",{className:"hidden overflow-hidden rounded-[20px] border border-[var(--ui-border-subtle)] md:block",children:a.jsx("div",{className:"max-h-[460px] overflow-auto",children:a.jsxs("table",{className:"w-full min-w-[620px] border-collapse text-left text-sm",children:[a.jsx("thead",{className:"sticky top-0 bg-[var(--ui-surface-2)] text-xs uppercase text-[var(--ui-ink-faint)]",children:a.jsxs("tr",{children:[a.jsx("th",{className:"px-4 py-3 font-semibold",children:"Target"}),a.jsx("th",{className:"px-4 py-3 font-semibold",children:"Amount"}),a.jsx("th",{className:"px-4 py-3 font-semibold",children:"Rationale"}),t?null:a.jsx("th",{className:"px-4 py-3 font-semibold",children:"Source"})]})}),a.jsx("tbody",{className:"divide-y divide-[var(--ui-border-subtle)]",children:e.map(n=>a.jsxs("tr",{className:"bg-[var(--ui-surface-1)]",children:[a.jsx("td",{className:"px-4 py-3 font-medium text-[var(--ui-ink)]",children:n.label}),a.jsxs("td",{className:"px-4 py-3 text-[var(--ui-ink)]",children:[a.jsx("span",{className:"font-semibold",children:n.target})," ",a.jsx("span",{className:"text-[var(--ui-ink-faint)]",children:n.unit})]}),a.jsx("td",{className:"px-4 py-3 text-[var(--ui-ink-muted)]",children:n.note}),t?null:a.jsx("td",{className:"px-4 py-3",children:a.jsx(E,{tone:"meta",children:n.source})})]},n.id))})]})})})]})}function ge({title:e,description:t,children:n}){return a.jsxs(I,{children:[a.jsxs("div",{className:"mb-4",children:[a.jsx("h3",{className:"text-sm font-semibold text-[var(--ui-ink)]",children:e}),a.jsx("p",{className:"mt-1 text-sm text-[var(--ui-ink-muted)]",children:t})]}),n]})}function Ht({view:e}){const t=Bt(e),n=e.target.weeklyRateGoalKg??null,r=n!=null&&Number.isFinite(n)?xa(n):null,s=t.profile.restingEnergyKcal,d=t.profile.activeBurnKcal,g=s!=null&&d!=null?s+d:null,l=e.target.bodyGoal??"maintain",o=l.includes("lose")?2:l.includes("gain")?1.8:1.6,u=b=>{var k;const p=(k=t.macros.find($=>$.id===b))==null?void 0:k.target,y=Number(p);return Number.isFinite(y)?y:null},C=t.profile.sex==="male"?t.profile.ageYears>=51?30:38:t.profile.ageYears>=51?21:25,A=Math.round(t.profile.calorieTarget/1e3*14),f=t.sportSummary.grossSportWeightEquivalentKgPerWeek!=null?`${t.sportSummary.grossSportWeightEquivalentKgPerWeek.toFixed(2)} kg/week`:"n/a";return a.jsx("section",{className:"grid gap-4",children:a.jsxs(V,{className:"p-5",children:[a.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-[var(--ui-ink)]",children:[a.jsx(Qa,{className:"size-4 text-[var(--ui-accent)]"}),"Macro And Micronutrient Targets",a.jsx(fa,{values:{sex:t.profile.sex,ageYears:t.profile.ageYears,currentWeightKg:t.profile.currentWeightKg,bmrKcal:null,restingKcal:s,restingSource:s!=null?"formula baseline; HealthKit complete-day evidence is calibration":null,activeKcal:d,maintenanceKcal:g,weeklyRateKg:n,dailyAdjustmentKcal:r,rateModel:Q.label,rateModelHorizonDays:Q.defaultPlanningHorizonDays,calorieTarget:t.profile.calorieTarget,calorieFloor:t.profile.sex==="male"?1500:1200,proteinReferenceWeightKg:null,proteinFactor:o,proteinGrams:u("protein"),fatGrams:u("fat"),carbohydrateGrams:u("carbohydrate"),fiberGrams:u("fiber"),fiberEnergyAdjustedGrams:A,fiberDriGrams:C}})]}),a.jsx("p",{className:"mt-1 max-w-3xl text-sm text-[var(--ui-ink-muted)]",children:"Daily targets use Forge plan values first, then adult DRI/Dietary Guidelines defaults for nutrients the food log can score as catalog detail improves."})]}),a.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.jsxs(E,{tone:"signal",children:[t.profile.calorieTarget.toFixed(0)," kcal"]}),a.jsxs(E,{tone:"meta",children:[t.profile.sex,", ",t.profile.ageYears.toFixed(0),"y"]})]})]}),a.jsxs("div",{className:"mt-5 grid gap-4 2xl:grid-cols-[minmax(0,1fr)_minmax(320px,0.58fr)]",children:[a.jsxs("div",{className:"grid gap-4",children:[a.jsx(ge,{title:"All macro targets",description:"Calories, protein, carbs, fat, fiber, sugar ceiling, saturated fat ceiling, essential fats, and water.",children:a.jsx(Te,{rows:t.macros,compact:!0})}),a.jsx(ge,{title:"Vitamins",description:"Adult daily vitamin targets from DRI values, adjusted for sex and age where the reference differs.",children:a.jsx(Te,{rows:t.vitamins})})]}),a.jsxs("div",{className:"grid content-start gap-4",children:[a.jsxs(ge,{title:"Expected sport losses",description:"Planning range from active burn. Calibrate with pre/post workout weight when possible.",children:[a.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[a.jsx(M,{label:"Active burn",value:t.profile.activeBurnKcal!=null?`${t.profile.activeBurnKcal.toFixed(0)} kcal`:"n/a"}),a.jsx(M,{label:"Sport equivalent",value:f}),a.jsx(M,{label:"Sweat fluid",value:`${t.sportSummary.fluidLossLiters} L`}),a.jsx(M,{label:"Sodium loss",value:`${t.sportSummary.sodiumLossMg} mg`})]}),a.jsxs("div",{className:"mt-4 flex items-start gap-3 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-3 text-sm text-[var(--ui-ink-muted)]",children:[a.jsx(pa,{className:"mt-0.5 size-4 shrink-0 text-[var(--ui-accent)]"}),a.jsx("span",{children:"Sport burn is shown as gross energy equivalent, not a promise of scale loss. The calorie plan may already include active burn, and replacement depends on appetite, heat, sodium loss, and actual intake."})]})]}),a.jsx(ge,{title:"Minerals & oligoelements",description:"Daily mineral and trace-element targets including sodium ceiling and potassium AI.",children:a.jsx(Te,{rows:t.minerals,compact:!0})}),a.jsx(ge,{title:"Sport electrolyte model",description:"Use these as expected losses, not rigid supplement prescriptions.",children:a.jsx("div",{className:"grid gap-3",children:t.sportLosses.map(b=>a.jsxs("div",{className:"flex items-start justify-between gap-3 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-3",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-[var(--ui-ink)]",children:[b.id==="sweat_fluid"?a.jsx(Va,{className:"size-4 text-[var(--ui-accent)]"}):a.jsx(Ya,{className:"size-4 text-[var(--ui-accent)]"}),b.label]}),a.jsx("p",{className:"mt-1 text-xs text-[var(--ui-ink-faint)]",children:b.note})]}),a.jsxs("div",{className:"shrink-0 text-right text-sm font-semibold text-[var(--ui-ink)]",children:[b.target,a.jsx("div",{className:"text-xs font-normal text-[var(--ui-ink-faint)]",children:b.unit})]})]},b.id))})})]})]})]})})}function ie(e,t){var r;if(!e)return null;const n=e.match(new RegExp(`${t}=([^;]+)`));return((r=n==null?void 0:n[1])==null?void 0:r.trim())??null}function z(e){const t=typeof e=="number"?e:Number(e);return Number.isFinite(t)&&t>0?t:null}function ja(e,t){if(t==="maintain")return 0;const n=t==="gain"?.0025:.005,r=t==="gain"?.1:.2,s=t==="gain"?.35:Math.max(.5,e*.01);return Math.min(s,Math.max(r,e*n))}function ka(e,t){return t==="gain"?e*1.03:t==="maintain"?e:e*.95}function Na(e){return e.toFixed(1)}function zt(e,t){return e==="male"?t>=51?30:38:t>=51?21:25}function qt(e){if(e.ageYears==null||e.ageYears<=0||e.heightCm==null||e.heightCm<=0||e.weightKg==null||e.weightKg<=0)return null;const t=e.sex==="male"?5:-161;return 10*e.weightKg+6.25*e.heightCm-5*e.ageYears+t}function ra(e,t){const n=e/100;return n>0?t*n*n:null}function Ot(e){const t=e.goalMode==="lose"&&e.goalWeightKg!=null?Math.min(e.currentWeightKg,e.goalWeightKg):e.currentWeightKg,n=ra(e.heightCm,30),r=ra(e.heightCm,25);if(n!=null&&r!=null&&e.currentWeightKg>n){const s=r+(e.currentWeightKg-r)*.25;return Math.min(t,s)}return t}function Ut(e,t){const n=z(e.currentWeightKg)??80;return{...e,goalMode:t,goalWeightKg:Na(ka(n,t)),weeklyRateKg:ja(n,t).toFixed(2)}}function Le(e){const t=_(e.weightTrend.latestWeightKg),n=e.target,r=ie(n.notes,"sex"),s=ie(n.notes,"age_years"),d=ie(n.notes,"height_cm"),g=_(e.energyModel.activeBurnKcal)??_(e.energyModel.activeEnergyCalories)??_(e.energyModel.movementCaloriesKcal)??z(ie(n.notes,"activity_kcal"))??0,l=n.bodyGoal??"",o=l.includes("gain")?"gain":l.includes("maintain")?"maintain":"lose",u=n.weightGoalKg??n.goalBodyWeightKg??null,C=t??80;return{goalMode:o,sex:r==="female"?"female":"male",ageYears:z(s)?String(s):"",heightCm:z(d)?String(d):"",currentWeightKg:t?t.toFixed(1):"",goalWeightKg:u?String(u):Na(ka(C,o)),weeklyRateKg:n.weeklyRateGoalKg!==null&&n.weeklyRateGoalKg!==void 0?String(Math.abs(n.weeklyRateGoalKg)):ja(C,o).toFixed(2),activeCaloriesKcal:g.toFixed(0),restingCaloriesKcal:_(e.energyModel.formulaRestingKcal)!=null?String(_(e.energyModel.formulaRestingKcal)):"",dietStyle:n.dietStyle??""}}function Qt(e){const t=z(ie(e.target.notes,"age_years"))!=null,n=z(ie(e.target.notes,"height_cm"))!=null,r=_(e.weightTrend.latestWeightKg)!=null,s=typeof e.target.bodyGoal=="string"&&e.target.bodyGoal.trim().length>0&&e.target.calorieTarget>0&&e.target.proteinGramsTarget>0;return t&&n&&r&&s}function Vt(e){const t=e.energyModel,n=t.activeBaselineEvidenceDays>0?`Forge is averaging ${t.activeBaselineEvidenceDays} measured prior day${t.activeBaselineEvidenceDays===1?"":"s"} inside the past ${t.activeBaselineWindowDays} days, excluding today and ignoring missing sync days instead of counting them as zero.`:`Forge has no measured prior-day active evidence in the past ${t.activeBaselineWindowDays} days, so it is falling back to the saved plan estimate.`,r=t.energySourceConfidence==="healthkit_daily_active_energy"?"HealthKit daily active energy is the active-burn source; workout and movement values are only visible evidence and are not added again.":t.energySourceConfidence==="workout_movement_fallback"?"HealthKit daily active energy is missing, so active burn already equals workout average plus movement-trip average.":"No measured active-burn stream is available, so Forge is using the saved plan estimate.";return`This is the baseline active allowance used when today has no same-day workout, movement, step, or active-energy evidence. ${n} ${r} Current evidence: active burn ${i(t.activeBurnKcal)} kcal/day, workout average ${i(t.workoutEnergyKcal)} kcal/day, movement average ${i(t.movementCaloriesKcal)} kcal/day, today's workout ${i(t.todayWorkoutEnergyKcal)} kcal, today's movement ${i(t.todayMovementCaloriesKcal)} kcal.`}function wa(e){const t=Number(e.currentWeightKg)||80,n=Number(e.heightCm)||178,r=Number(e.ageYears)||35,s=z(e.goalWeightKg),d=Math.max(0,Number(e.activeCaloriesKcal)||0),g=qt({sex:e.sex,ageYears:r,heightCm:n,weightKg:t})??10*t+6.25*n-5*r+5,l=g,o=l+d,u=Math.abs(Number(e.weeklyRateKg)||0),C=e.goalMode==="lose"?-u:e.goalMode==="gain"?u:0,A=xa(C)??0,f=Et(C)??0,b=e.sex==="male"?1500:1200,p=Math.round(o+A),y=Math.max(b,p),k=Ot({currentWeightKg:t,goalWeightKg:s,heightCm:n,goalMode:e.goalMode}),$=e.goalMode==="lose"?2:e.goalMode==="gain"?1.8:1.6,T=Math.round(k*$),P=Math.floor(y*.45/4),W=Math.max(1,Math.min(T,P)),q=k*.6,R=y*.25/9,te=Math.max(0,(y-W*4)/9),Y=Math.max(0,Math.floor(Math.min(te,y*.35/9,Math.max(q,R)))),X=Math.max(0,Math.floor((y-W*4-Y*9)/4)),O=Math.round(y/1e3*14),ce=zt(e.sex,r),ne=O,de=Math.round(y*.1/9),ee=Math.round(y*.1/4);return{bmr:Math.round(g),restingCalories:Math.round(l),restingSource:"Mifflin-St Jeor baseline",activeCalories:Math.round(d),maintenanceCalories:Math.round(o),plannedCalorieTarget:p,minimumCalorieFloor:b,weeklyRateGoalKg:C,dailyEnergyAdjustment:Math.round(A),staticDailyEnergyAdjustment:Math.round(f),rateModel:Q.id,rateModelLabel:Q.label,rateModelPlanningHorizonDays:Q.defaultPlanningHorizonDays,calorieTarget:y,proteinReferenceWeight:Math.round(k*10)/10,proteinGramsTarget:W,carbohydrateGramsTarget:X,fatGramsTarget:Y,fiberGramsTarget:ne,fiberEnergyAdjustedGrams:O,fiberDriGrams:ce,saturatedFatLimitGrams:de,addedSugarLimitGrams:ee}}function Yt(e){const t=[],n=Number(e.ageYears),r=Number(e.heightCm),s=Number(e.currentWeightKg),d=Number(e.goalWeightKg),g=Number(e.weeklyRateKg),l=e.activeCaloriesKcal.trim()?Number(e.activeCaloriesKcal):Number.NaN,o=e.restingCaloriesKcal.trim()?Number(e.restingCaloriesKcal):null;return(!Number.isFinite(n)||n<13||n>100)&&t.push("- Enter the user's real age. Forge uses it in Mifflin-St Jeor resting metabolism."),(!Number.isFinite(r)||r<120||r>230)&&t.push("- Enter height in cm. Height changes BMR and protein reference weight."),(!Number.isFinite(s)||s<30||s>300)&&t.push("- Enter current weight in kg. Use the latest known body measure as the starting state."),e.goalMode!=="maintain"&&(!Number.isFinite(d)||d<30||d>300)&&t.push("- Enter a target weight for the selected loss or gain objective."),(!Number.isFinite(g)||g<0)&&t.push("- Enter a non-negative weekly change rate in kg/week."),Number.isFinite(g)&&g>Math.max(1.5,s*.02)&&t.push("- The weekly rate is very aggressive. Choose a slower default unless this is a supervised plan."),(!Number.isFinite(l)||l<0||l>3e3)&&t.push("- Enter average active calories per day. Zero is valid only when Forge has no activity evidence."),o!=null&&(!Number.isFinite(o)||o<900||o>3500)&&t.push("- Formula resting baseline should stay in a plausible daily range."),t.length>0?t.join(`
|
|
1
|
+
import{j as a,bX as Be,aG as ua,b7 as ga,cg as Ba,dx as Ha,cB as za,bB as Ie,cm as qa,cF as ma,c8 as Oa,c1 as ha,dy as Ua,dz as Qa,bq as pa,dA as Va,dB as Ya,r as K,d8 as Ja,bt as ea,dC as Za,br as Xa,bd as et}from"./vendor-Cpmju3nw.js";import{j as at,i as tt,k as U}from"./state-BtwEvpO6.js";import{P as nt}from"./page-hero-C0MpI3MM.js";import{C as V,a4 as le,B as D,I as w,c as Pe,k as E,T as ke,d as rt,L as st,e as it,e8 as aa,e9 as ot,ea as lt,eb as ct,ec as ta,ed as dt,ee as ut,ef as gt,eg as mt,eh as ht,ei as pt,ej as bt}from"./index-BaiwtAgo.js";import{S as I,a as M}from"./surface-BVYp-Wq9.js";import{Q as Ce,F as j,a as na}from"./question-flow-dialog-Bj4PxpjS.js";import{f as We}from"./date-keys-Cj1G3TOn.js";import"./motion-DwjmC9aq.js";import"./ui-B9O-eUim.js";import"./board-CLOHbg6t.js";import"./forms-C5d5hTf2.js";function xt({view:e,onOpenPlan:t,onOpenFoodSearch:n,onOpenCustomFood:r,onOpenChatGptFood:s,onOpenCheckin:d,onOpenHistory:g}){const l=[{label:"Plan target",value:`${e.target.calorieTarget.toFixed(0)} kcal`},{label:"Protein",value:`${e.target.proteinGramsTarget.toFixed(0)}g`},{label:"Fiber",value:`${e.target.fiberGramsTarget.toFixed(0)}g`}];return a.jsxs(V,{className:"grid gap-4 border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)] p-5",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:[a.jsx("span",{children:"Control center"}),a.jsx(le,{label:"Explain weight-loss controls",content:"Use these actions to change the nutrition plan, log food, or record body signals. The day budget cards above use today's active-calorie source; the plan target here is the baseline target before today's active adjustment."})]}),a.jsx("h2",{className:"mt-1 text-xl font-semibold leading-tight text-[var(--ui-ink-strong)]",children:e.target.bodyGoal?`Goal: ${e.target.bodyGoal}`:"Set the body objective"}),a.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Adjust the baseline plan, log food with exact quantities, or record body signals from guided flows."})]}),a.jsx("div",{className:"grid gap-2 sm:grid-cols-3 xl:grid-cols-1 min-[1360px]:grid-cols-3",children:l.map(o=>a.jsxs("div",{className:"min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-2",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:o.label}),a.jsx("div",{className:"mt-1 truncate text-sm font-semibold text-[var(--ui-ink-strong)]",children:o.value})]},o.label))}),a.jsxs("div",{className:"grid min-w-0 grid-cols-2 gap-2",children:[a.jsxs(D,{type:"button",onClick:r,children:[a.jsx(Be,{className:"size-4"}),"Custom food"]}),a.jsxs(D,{type:"button",variant:"secondary",onClick:s,children:[a.jsx(ua,{className:"size-4"}),"Ask ChatGPT"]}),a.jsxs(D,{type:"button",variant:"secondary",onClick:n,children:[a.jsx(ga,{className:"size-4"}),"Search food"]}),a.jsxs(D,{type:"button",variant:"secondary",onClick:t,children:[a.jsx(Ba,{className:"size-4"}),"Plan settings"]}),a.jsxs(D,{type:"button",variant:"secondary",onClick:d,children:[a.jsx(Ha,{className:"size-4"}),"Add measure"]}),a.jsxs(D,{type:"button",variant:"secondary",onClick:g,children:[a.jsx(za,{className:"size-4"}),"Food history"]})]})]})}function _(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function oe(e){return typeof e=="string"&&e.trim()?e:null}function i(e,t=0){const n=_(e);return n===null?"n/a":n.toFixed(t)}function H(e,t=0){const n=_(e);return n===null?"n/a":`${n>0?"+":""}${n.toFixed(t)}`}function ye(e){const t=_(e);return t===null?"n/a":`${t.toFixed(1)}/10`}function ft(e){return Array.isArray(e)?e.filter(t=>!!t&&typeof t=="object"&&!Array.isArray(t)):[]}function vt(e){switch(e){case"user_override":return"Manual override for today";case"today_healthkit_active_energy":return"HealthKit active energy today";case"today_workout_movement_energy":return"Workout + movement today";case"today_workout_movement_step_energy":return"Workout + movement + steps today";case"today_workout_step_energy":return"Workout + steps today";case"today_movement_step_energy":return"Movement + steps today";case"today_workout_energy":return"Workout energy today";case"today_movement_trip_calories":return"Movement trips today";case"today_step_estimate":return"Step estimate today";default:return"Past-week active baseline"}}function yt(e){switch(e){case"user_override":return"Using your manual value for today.";case"today_healthkit_active_energy":return"Using same-day HealthKit active energy instead of the baseline.";case"today_workout_movement_energy":return"Using today's workout and movement calories instead of the baseline.";case"today_workout_movement_step_energy":return"Using today's workouts, movement, and steps instead of the baseline.";case"today_workout_step_energy":return"Using today's workouts and steps instead of the baseline.";case"today_movement_step_energy":return"Using today's movement and steps instead of the baseline.";case"today_workout_energy":return"Using today's workout calories instead of the baseline.";case"today_movement_trip_calories":return"Using today's movement calories instead of the baseline.";case"today_step_estimate":return"Using today's step estimate because it is above the baseline.";default:return"No meaningful same-day active evidence yet, so the past-week active baseline is used."}}function jt(e){return`${e>=0?"+":""}${e.toFixed(0)} kcal`}function kt(e){return e.trim()===""?"0":e}function Nt({view:e,draftValue:t,pending:n,error:r,onDraftChange:s,onSave:d,onReset:g}){const l=e.energyModel,o=e.todayLedger,u=l.todayActiveOverride,C=l.todayActiveCaloriesSource,A=`${o.plannedTargetCalories.toFixed(0)} ${jt(l.todayTargetAdjustmentKcal)} = ${o.targetCalories.toFixed(0)} kcal`;return a.jsxs(V,{className:"grid min-w-0 gap-3 border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[a.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-1 text-[11px] uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:["Active kcal",a.jsx(le,{label:"Explain active calories",content:`Today target = baseline food target plus the day-specific active adjustment. ${A}. Automatic same-day activity can only add ${Math.round(l.activityEatBackFraction*100)}% of the positive surplus above the baseline day. A manual edit overrides today only and can raise or lower the target.`})]}),a.jsxs("div",{className:"mt-1 text-2xl font-semibold leading-tight text-[var(--ui-ink-strong)]",children:[l.todayActiveCaloriesKcal.toFixed(0)," kcal"]})]}),a.jsx("div",{className:"rounded-[8px] bg-[var(--ui-info-soft)] p-2 text-[color-mix(in_srgb,var(--info)_78%,var(--ui-ink-strong)_22%)]",children:a.jsx(Ie,{className:"size-4"})})]}),a.jsxs("div",{className:"grid gap-1 text-xs leading-5 text-[var(--ui-ink-soft)]",children:[a.jsx("div",{className:"break-words font-medium text-[var(--ui-ink-medium)]",children:yt(C)}),a.jsxs("div",{children:["Baseline ",l.baselineActiveCaloriesKcal.toFixed(0)," kcal"," · ","observed"," ",l.todayObservedActiveCaloriesKcal!=null?`${l.todayObservedActiveCaloriesKcal.toFixed(0)} kcal`:"n/a"]}),a.jsxs("div",{className:"break-words",children:["Source: ",vt(C)]})]}),a.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(0,1fr)_auto] gap-2",children:[a.jsx(w,{inputMode:"decimal",value:t,onChange:f=>s(kt(f.target.value)),"aria-label":"Today active calories",className:"py-2.5"}),a.jsxs(D,{type:"button",onClick:d,pending:n,pendingLabel:"Applying",children:[a.jsx(qa,{className:"size-4"}),"Apply"]})]}),a.jsxs(D,{type:"button",variant:"secondary",onClick:g,disabled:!u||n,children:[a.jsx(ma,{className:"size-4"}),"Use evidence"]}),r?a.jsx("div",{className:"rounded-[8px] border border-[var(--danger)]/20 bg-[var(--ui-danger-soft)] px-3 py-2 text-xs leading-5 text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",children:r}):null]})}const wt={default:"bg-[color-mix(in_srgb,var(--primary)_14%,transparent)] text-[var(--primary)]",green:"bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_78%,var(--ui-ink-strong)_22%)]",amber:"bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_76%,var(--ui-ink-strong)_24%)]",rose:"bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",cyan:"bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_78%,var(--ui-ink-strong)_22%)]"};function Z({label:e,value:t,detail:n,icon:r,tone:s="default",help:d,helpMaxWidthPx:g}){return a.jsxs(V,{className:"grid gap-4 border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5",children:[a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsx("div",{className:Pe("rounded-2xl p-2.5",wt[s]),children:a.jsx(r,{className:"size-5"})}),a.jsxs("div",{className:"flex items-center justify-end gap-1 text-right text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:[a.jsx("span",{children:e}),d?a.jsx(le,{content:d,label:`Explain ${e}`,maxWidthPx:g}):null]})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-3xl font-semibold text-[var(--ui-ink-strong)]",children:t}),a.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:n})]})]})}function Ct({meal:e,onLogAgain:t,onEdit:n,onDelete:r,pending:s=!1}){const d=e.items[0]??null,g=Math.max(0,e.items.length-1),l=d?`${d.name}${g>0?` + ${g} more`:""}`:e.mealLabel??"Meal",o=e.items.slice(0,3).map(u=>{const C=Number.isFinite(u.quantity)&&u.quantity>0?Number.isInteger(u.quantity)?String(u.quantity):u.quantity.toFixed(2).replace(/\.?0+$/,""):null,A=u.unit??"serving",f=u.grams!=null?`${u.grams.toFixed(0)}g`:null;return[C,A,f?`(${f})`:null].filter(Boolean).join(" ")}).filter(Boolean).join(" · ");return a.jsxs(I,{className:"grid min-w-0 gap-3",children:[a.jsxs("div",{className:"flex min-w-0 flex-wrap items-start justify-between gap-3",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"break-words text-base font-semibold leading-6 text-[var(--ui-ink-strong)]",children:l}),a.jsx("div",{className:"mt-1 text-xs leading-5 text-[var(--ui-ink-faint)]",children:o||e.notes||"No quantity recorded"})]}),a.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.mealLabel?a.jsx(E,{tone:"meta",children:e.mealLabel}):null,a.jsxs(E,{tone:"meta",children:[e.totals.calories.toFixed(0)," kcal"]})]})]}),a.jsxs("div",{className:"grid gap-2 text-xs text-[var(--ui-ink-soft)] sm:grid-cols-3 xl:grid-cols-6",children:[a.jsxs("span",{children:[e.totals.proteinGrams.toFixed(0),"g protein"]}),a.jsxs("span",{children:[e.totals.carbohydrateGrams.toFixed(0),"g carbs"]}),a.jsxs("span",{children:[e.totals.fatGrams.toFixed(0),"g fat"]}),a.jsxs("span",{children:[e.totals.fiberGrams.toFixed(0),"g fiber"]}),a.jsxs("span",{children:[e.totals.sodiumMg.toFixed(0),"mg sodium"]}),a.jsx("span",{children:e.confirmationState})]}),a.jsxs("div",{className:"flex flex-wrap gap-2",children:[n?a.jsxs(D,{type:"button",size:"sm",variant:"secondary",onClick:()=>n(e),children:[a.jsx(Oa,{className:"size-4"}),"Edit"]}):null,r?a.jsxs(D,{type:"button",size:"sm",variant:"ghost",pending:s,onClick:()=>r(e),children:[a.jsx(ha,{className:"size-4"}),"Delete"]}):null,t?a.jsxs(D,{type:"button",size:"sm",variant:"ghost",pending:s,onClick:()=>t(e),children:[a.jsx(ma,{className:"size-4"}),"Log again"]}):null]})]})}function He({children:e}){return a.jsx(I,{className:"border-dashed border-[var(--ui-border-strong)] p-5 text-sm text-[var(--ui-ink-soft)]",children:e})}function Ne(e){return`${e.toFixed(0)} kcal`}function Mt(e){return e>=0?"Kcal left":"Over target"}function Ft(e){return e>=0?Ne(e):Ne(Math.abs(e))}function Kt({ledger:e,remainingCalories:t,intakePercent:n,logSavedPending:r,onLogAgain:s,onEditMeal:d,onDeleteMeal:g}){const l=e.totals;return a.jsxs(V,{className:"grid gap-5 border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5",children:[a.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Food log"}),a.jsxs("h2",{className:"mt-1 flex items-center gap-2 text-xl font-semibold text-[var(--ui-ink-strong)]",children:[a.jsx("span",{children:"Calories, macros, and meal evidence"}),a.jsx(le,{label:"Explain food log",content:"The food log is today's editable record of what was eaten. Edit a meal to change quantities, remove items, correct food parameters, or delete the meal entirely."})]})]}),a.jsxs(E,{tone:"meta",children:[e.meals.length," meals"]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"mb-4 grid gap-3 sm:grid-cols-3",children:[a.jsxs("div",{className:"min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3",children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:"Eaten today"}),a.jsx("div",{className:"mt-1 text-2xl font-semibold text-[var(--ui-ink-strong)]",children:Ne(l.calories)})]}),a.jsxs("div",{className:"min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3",children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:"Target today"}),a.jsx("div",{className:"mt-1 text-2xl font-semibold text-[var(--ui-ink-strong)]",children:Ne(e.targetCalories)})]}),a.jsxs("div",{className:Pe("min-w-0 rounded-[8px] border p-3",t>=0?"border-[color-mix(in_srgb,var(--success)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-success-soft)]":"border-[color-mix(in_srgb,var(--danger)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-danger-soft)]"),children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:Mt(t)}),a.jsx("div",{className:"mt-1 text-2xl font-semibold text-[var(--ui-ink-strong)]",children:Ft(t)})]})]}),a.jsx("div",{className:"h-3 overflow-hidden rounded-full bg-[var(--ui-surface-2)]",children:a.jsx("div",{className:Pe("h-full rounded-full",t>=0?"bg-[color-mix(in_srgb,var(--success)_82%,var(--secondary)_18%)]":"bg-[color-mix(in_srgb,var(--danger)_82%,var(--tertiary)_18%)]"),style:{width:`${Math.min(100,n)}%`}})}),a.jsxs("div",{className:"mt-3 grid gap-2 text-sm text-[var(--ui-ink-soft)] sm:grid-cols-4",children:[a.jsxs("span",{children:[l.carbohydrateGrams.toFixed(0),"g carbs"]}),a.jsxs("span",{children:[l.fatGrams.toFixed(0),"g fat"]}),a.jsxs("span",{children:[l.fiberGrams.toFixed(0),"g fiber"]}),a.jsxs("span",{children:[e.unconfirmedCount," unconfirmed"]})]})]}),a.jsx("div",{className:"grid gap-3",children:e.meals.length>0?e.meals.map(o=>a.jsx(Ct,{meal:o,pending:r,onLogAgain:s,onEdit:d,onDelete:g},o.id)):a.jsx(He,{children:"No meals logged today yet."})})]})}function At({hypotheses:e}){return a.jsxs(V,{className:"grid gap-4 border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Hypotheses"}),a.jsx("h2",{className:"mt-1 text-xl font-semibold text-[var(--ui-ink-strong)]",children:"Food and body pattern candidates"})]}),a.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:e.length>0?e.slice(0,6).map((t,n)=>a.jsxs(I,{children:[a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsx(E,{tone:"signal",children:oe(t.metric)??"pattern"}),a.jsx("span",{className:"text-xs text-[var(--ui-ink-faint)]",children:i(t.confidence,2)})]}),a.jsx("div",{className:"mt-3 text-sm font-medium text-[var(--ui-ink-strong)]",children:oe(t.label)??"Candidate pattern"}),a.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:oe(t.description)??"Forge needs more paired meals and check-ins to harden this signal."})]},String(t.key??n))):a.jsx("div",{className:"md:col-span-2",children:a.jsx(He,{children:"Log meals plus energy, gut, and look check-ins for a few days to generate pattern candidates."})})})]})}function Gt({experiments:e}){return a.jsxs(V,{className:"grid content-start gap-4 border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"rounded-2xl bg-[var(--ui-info-soft)] p-2.5 text-[color-mix(in_srgb,var(--info)_78%,var(--ui-ink-strong)_22%)]",children:a.jsx(Ua,{className:"size-5"})}),a.jsxs("div",{children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Experiments"}),a.jsx("h2",{className:"text-xl font-semibold text-[var(--ui-ink-strong)]",children:"N-of-1 lab"})]})]}),a.jsxs("div",{className:"grid gap-3",children:[e.slice(0,4).map((t,n)=>a.jsxs(I,{children:[a.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:oe(t.title)??"Nutrition experiment"}),a.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:oe(t.hypothesis)??oe(t.intervention)??"No hypothesis recorded."})]},String(t.id??n))),e.length===0?a.jsx(He,{children:"Start experiments from OpenClaw or the API: caffeine timing, fiber ramp, low-FODMAP trial, carb timing, sodium/puffiness, or pre-training fueling."}):null]})]})}function St({view:e}){const t=e.dataQuality,n=e.todayLedger;return a.jsxs(V,{className:"grid gap-4 border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5",children:[a.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Data quality"}),a.jsx("h2",{className:"mt-1 text-xl font-semibold text-[var(--ui-ink-strong)]",children:"Confidence, coverage, and next evidence"})]}),a.jsxs(E,{tone:"meta",children:[e.summary.dataQualityScore.toFixed(0),"% coverage"]})]}),a.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[a.jsx(Dt,{label:"Source confidence",value:t.sourceConfidence,children:"Food parsing stays candidate-based until accepted; wearable burn is treated as a trend input."}),a.jsxs(I,{children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Missing check-ins"}),a.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:t.missingHighValueCheckins.length>0?t.missingHighValueCheckins.map(r=>a.jsx(E,{tone:"signal",children:r},r)):a.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Core evidence loop is covered."})})]}),a.jsxs(I,{children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Next best cue"}),a.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:t.notes}),a.jsxs("div",{className:"mt-3 text-xs text-[var(--ui-ink-faint)]",children:[n.unconfirmedCount," unconfirmed candidate",n.unconfirmedCount===1?"":"s"]})]})]})]})}function Dt({label:e,value:t,children:n}){return a.jsxs(I,{children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:e}),a.jsx("div",{className:"mt-2 text-lg font-semibold text-[var(--ui-ink-strong)]",children:t}),a.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:n})]})}const Q={id:"hall_niddk_linearized_adult_12w",label:"Hall/NIDDK linearized adult model",defaultPlanningHorizonDays:84,steadyStateKcalPerKgPerDay:10/.45359237,timeConstantDays:365,staticEnergyDensityKcalPerKg:7700};function $e(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function ba(e={}){const t=$e(e.planningHorizonDays)??Q.defaultPlanningHorizonDays,n=$e(e.timeConstantDays)??Q.timeConstantDays,r=$e(e.steadyStateKcalPerKgPerDay)??Q.steadyStateKcalPerKgPerDay,s=1-Math.exp(-t/n);return{planningHorizonDays:t,timeConstantDays:n,steadyStateKcalPerKgPerDay:r,responseFraction:s}}function xa(e,t={}){if(typeof e!="number"||!Number.isFinite(e))return null;if(e===0)return 0;const n=ba(t);return n.responseFraction<=0?null:e*(n.planningHorizonDays/7)*n.steadyStateKcalPerKgPerDay/n.responseFraction}function _t(e,t={}){if(typeof e!="number"||!Number.isFinite(e))return null;if(e===0)return 0;const n=ba(t);return e/n.steadyStateKcalPerKgPerDay*n.responseFraction/(n.planningHorizonDays/7)}function Et(e){return typeof e!="number"||!Number.isFinite(e)?null:e*Q.staticEnergyDensityKcalPerKg/7}function B(e,t,n){return a.jsxs("li",{className:"grid gap-0.5",children:[a.jsx("span",{className:"font-medium text-[var(--ui-ink)]",children:e}),a.jsx("code",{className:"rounded-[6px] bg-[var(--ui-surface-2)] px-1.5 py-0.5 font-mono text-[11px] text-[var(--ui-ink-soft)]",children:t}),n?a.jsx("span",{className:"text-xs text-[var(--ui-ink-faint)]",children:n}):null]})}function fa({values:e,label:t="Show calorie and macro formulas"}){const r=((e==null?void 0:e.sex)??"male")==="male"?"+ 5":"- 161",s=(e==null?void 0:e.proteinFactor)!=null?`${e.proteinFactor.toFixed(1)}g/kg`:"1.6-2.0g/kg";return a.jsx(le,{label:t,title:"Weight Loss Formulas",maxWidthPx:520,panelClassName:"text-xs leading-5",content:a.jsxs("div",{className:"grid gap-3",children:[a.jsx("p",{children:"Forge keeps activity independent from the goal. The goal only adds a deficit, surplus, or zero adjustment to the formula resting baseline plus active calories. Complete HealthKit basal energy is calibration evidence, not the silent baseline."}),a.jsxs("ol",{className:"grid gap-2",children:[B("Mifflin-St Jeor resting baseline",`10 x weight kg + 6.25 x height cm - 5 x age ${r}`,`Current formula value: ${i(e==null?void 0:e.bmrKcal)} kcal/day.`),B("Resting calories","Mifflin-St Jeor formula baseline; HealthKit basal is complete-day evidence only",`Using: ${i(e==null?void 0:e.restingKcal)} kcal/day${e!=null&&e.restingSource?` (${e.restingSource})`:""}.`),B("Maintenance calories","resting calories + active calories",`${i(e==null?void 0:e.restingKcal)} + ${i(e==null?void 0:e.activeKcal)} = ${i(e==null?void 0:e.maintenanceKcal)} kcal/day.`),B("Objective adjustment","Hall/NIDDK linearized adult model, inverted over the planning horizon",`Weekly rate ${H(e==null?void 0:e.weeklyRateKg,2)} kg/week gives ${H(e==null?void 0:e.dailyAdjustmentKcal)} kcal/day${e!=null&&e.rateModel?` with ${e.rateModel}`:""}${e!=null&&e.rateModelHorizonDays?` over ${e.rateModelHorizonDays} days`:""}.`),B("Daily calorie target","max(sex floor, maintenance + objective adjustment)",`Floor ${i(e==null?void 0:e.calorieFloor)} kcal; target ${i(e==null?void 0:e.calorieTarget)} kcal/day.`),B("Protein target",`min(reference weight x ${s}, 45% of kcal / 4)`,`Reference ${i(e==null?void 0:e.proteinReferenceWeightKg,1)} kg; target ${i(e==null?void 0:e.proteinGrams)} g/day.`),B("Fat target","saved plan fat when present; otherwise min(remaining kcal after protein, 35% kcal / 9, max(0.6g/kg reference, 25% kcal / 9))",`Target ${i(e==null?void 0:e.fatGrams)} g/day.`),B("Carbohydrate target","(calorie target - protein g x 4 - fat g x 9) / 4",`Target ${i(e==null?void 0:e.carbohydrateGrams)} g/day. The 130g DRI is shown as reference, not forced if it breaks calories.`),B("Fiber target","14g per 1000 kcal; adult sex/age AI shown as reference",`Target ${i(e==null?void 0:e.fiberGrams)} g/day; energy-adjusted ${i(e==null?void 0:e.fiberEnergyAdjustedGrams)} g/day; adult AI reference ${i(e==null?void 0:e.fiberDriGrams)} g/day.`),B("Sport-loss estimate","training hours ~= active kcal / 500; sweat ~= 0.4-0.8 L/h; sodium ~= 500-1000 mg/L","Shown as expected loss ranges, not rigid supplement instructions.")]})]})})}function va(e,t){var r;if(!e)return null;const n=e.match(new RegExp(`${t}=([^;]+)`));return((r=n==null?void 0:n[1])==null?void 0:r.trim())??null}function me(e,t){const n=typeof e=="string"?Number(e):_(e);return typeof n=="number"&&Number.isFinite(n)?n:t}function $t(e){return va(e.target.notes,"sex")==="female"?"female":"male"}function Tt(e){return me(va(e.target.notes,"age_years"),35)}function h(e,t,n,r,s,d){return{id:e,label:t,target:typeof n=="number"?Re(n):n,unit:r,note:s,source:d}}function Re(e){return Number.isFinite(e)?Math.abs(e)>=100?e.toFixed(0):e.toFixed(1).replace(/\.0$/,""):"n/a"}function se(e,t){return`${Re(e)}-${Re(t)}`}function Lt(e,t,n,r){const s=Math.round(n/1e3*14);return r>0?r:s}function It({calorieTarget:e,currentWeightKg:t,protein:n,savedFat:r}){const s=Math.max(0,(e-n*4)/9),d=Math.max(0,Math.min(s,e*.35/9,Math.max(t*.6,e*.25/9))),g=r??d;return{carbs:Math.max(0,(e-n*4-g*9)/4),fat:g}}function Pt(e,t){return e==="male"?t>=51?14:17:t>=51?11:12}function Wt(e,t){const n=t>70,r=t>=51;return[h("vitamin_a","Vitamin A",e==="male"?900:700,"ug RAE","Retinol activity equivalent target.","NASEM DRI"),h("vitamin_c","Vitamin C",e==="male"?90:75,"mg","Adult RDA.","NASEM DRI"),h("vitamin_d","Vitamin D",n?20:15,"ug","Assumes limited sun exposure; older adults need more.","NASEM DRI"),h("vitamin_e","Vitamin E",15,"mg alpha-tocopherol","Adult RDA.","NASEM DRI"),h("vitamin_k","Vitamin K",e==="male"?120:90,"ug","Adult AI.","NASEM DRI"),h("thiamin_b1","Thiamin B1",e==="male"?1.2:1.1,"mg","Adult RDA.","NASEM DRI"),h("riboflavin_b2","Riboflavin B2",e==="male"?1.3:1.1,"mg","Adult RDA.","NASEM DRI"),h("niacin_b3","Niacin B3",e==="male"?16:14,"mg NE","Adult RDA.","NASEM DRI"),h("vitamin_b6","Vitamin B6",r?e==="male"?1.7:1.5:1.3,"mg","RDA rises after 50.","NASEM DRI"),h("folate","Folate",400,"ug DFE","Adult RDA.","NASEM DRI"),h("vitamin_b12","Vitamin B12",2.4,"ug","Adult RDA.","NASEM DRI"),h("pantothenic_acid","Pantothenic acid",5,"mg","Adult AI.","NASEM DRI"),h("biotin","Biotin",30,"ug","Adult AI.","NASEM DRI"),h("choline","Choline",e==="male"?550:425,"mg","Adult AI.","NASEM DRI")]}function Rt(e,t){const n=t>70||e==="female"&&t>=51?1200:1e3,r=e==="male"?t>=31?420:400:t>=31?320:310,s=e==="male"?t>=51?30:35:t>=51?20:25,d=t>=71?1800:t>=51?2e3:2300;return[h("calcium","Calcium",n,"mg","Bone and muscle target; higher for older adults and women 51+.","NASEM DRI"),h("iron","Iron",e==="female"&&t<=50?18:8,"mg","Menstruating-age female target is higher.","NASEM DRI"),h("magnesium","Magnesium",r,"mg","Adult RDA.","NASEM DRI"),h("phosphorus","Phosphorus",700,"mg","Adult RDA.","NASEM DRI"),h("zinc","Zinc",e==="male"?11:8,"mg","Adult RDA.","NASEM DRI"),h("iodine","Iodine",150,"ug","Adult RDA.","NASEM DRI"),h("selenium","Selenium",55,"ug","Adult RDA.","NASEM DRI"),h("copper","Copper",.9,"mg","Adult RDA.","NASEM DRI"),h("manganese","Manganese",e==="male"?2.3:1.8,"mg","Adult AI.","NASEM DRI"),h("chromium","Chromium",s,"ug","Adult AI.","NASEM DRI"),h("molybdenum","Molybdenum",45,"ug","Adult RDA.","NASEM DRI"),h("fluoride","Fluoride",e==="male"?4:3,"mg","Adult AI.","NASEM DRI"),h("chloride","Chloride",d,"mg","Adult AI.","NASEM DRI"),h("potassium","Potassium",e==="male"?3400:2600,"mg","Current adult AI for non-pregnant adults.","NASEM DRI"),h("sodium_limit","Sodium ceiling",2300,"mg max","Default daily ceiling unless medically individualized.","U.S. Dietary Guidelines")]}function Bt(e){const t=$t(e),n=Tt(e),r=me(e.weightTrend.latestWeightKg,80),s=Math.max(1,me(e.target.calorieTarget,2200)),d=me(e.target.proteinGramsTarget,r*1.8),{carbs:g,fat:l}=It({calorieTarget:s,currentWeightKg:r,protein:d,savedFat:_(e.target.fatGramsTarget)}),o=Lt(t,n,s,me(e.target.fiberGramsTarget,0)),u=_(e.energyModel.activeBurnKcal)??_(e.energyModel.activeEnergyCalories)??null,C=_(e.energyModel.movementCaloriesKcal),A=_(e.energyModel.restingEnergyCalories);return ya({sex:t,ageYears:n,currentWeightKg:r,calorieTarget:s,proteinGramsTarget:d,carbohydrateGramsTarget:g,fatGramsTarget:l,fiberGramsTarget:o,activeBurnKcal:u,movementCaloriesKcal:C,restingEnergyKcal:A})}function ya(e){const{sex:t,ageYears:n,currentWeightKg:r,calorieTarget:s,proteinGramsTarget:d,carbohydrateGramsTarget:g,fatGramsTarget:l,fiberGramsTarget:o,activeBurnKcal:u,movementCaloriesKcal:C,restingEnergyKcal:A}=e,f=u!=null?Math.min(4,Math.max(.1,u/500)):null,b=f!=null?f*.4:null,p=f!=null?f*.8:null,y=b!=null?b*500:null,k=p!=null?p*1e3:null,$=b!=null?b*78:null,T=p!=null?p*312:null,P=u!=null?_t(u):null;return{profile:{sex:t,ageYears:n,currentWeightKg:r,calorieTarget:s,activeBurnKcal:u,movementCaloriesKcal:C,restingEnergyKcal:A},macros:[h("calories","Calories",s,"kcal","Plan target from BMR, active burn, and chosen weekly rate.","Forge plan"),h("protein","Protein",d,"g","Higher than the population RDA to preserve lean mass during weight change.","ISSN + Forge plan"),h("carbohydrate","Carbohydrate",g,"g","Remaining fuel after protein and fat. It may sit below the 130g/day adult DRI reference when needed to preserve the calorie target.","NASEM DRI + Forge plan"),h("fat","Total fat",l,"g","Uses the saved plan fat target when present; generated defaults aim for a practical floor around 0.6g/kg or 20-35% of calories when possible.","NASEM AMDR + Forge plan"),h("fiber","Fiber",o,"g","Uses 14g per 1000 kcal as the plan target; the sex/age adult AI remains a reference or stretch value when calories are low.","NASEM DRI"),h("saturated_fat","Saturated fat",s*.1/9,"g max","Keep below 10% of energy.","U.S. Dietary Guidelines"),h("added_sugar","Added sugar",s*.1/4,"g max","Keep below 10% of energy; lower is better when feasible.","U.S. Dietary Guidelines"),h("linoleic_acid","Linoleic acid",Pt(t,n),"g","Essential n-6 fatty acid AI.","NASEM DRI"),h("ala","ALA omega-3",t==="male"?1.6:1.1,"g","Essential n-3 fatty acid AI.","NASEM DRI"),h("water","Total water",t==="male"?3.7:2.7,"L","All beverages and food water before extra training replacement.","NASEM DRI")],vitamins:Wt(t,n),minerals:Rt(t,n),sportLosses:[h("training_time","Estimated training time",f??"n/a","h/day","Derived from active burn at roughly 500 kcal/h.","Forge sport-loss model"),h("sweat_fluid","Expected sweat fluid",b!=null&&p!=null?se(b,p):"n/a","L/day","Planning range uses 0.4-0.8 L/h; measure body mass change to calibrate.","ACSM"),h("sweat_sodium","Expected sweat sodium",y!=null&&k!=null?se(y,k):"n/a","mg/day","Sodium varies widely; this uses a conservative range around common sweat sodium values.","ACSM + Sports Medicine review"),h("sweat_potassium","Expected sweat potassium",$!=null&&T!=null?se($,T):"n/a","mg/day","Potassium is usually much smaller than sodium but useful for long/hot sessions.","Sports Medicine review"),h("gross_sport_equivalent","Gross sport burn equivalent",P??"n/a","kg/week","Energy equivalent if the active burn were not eaten back; the plan may already include it.","Hall/NIDDK dynamic model")],sportSummary:{trainingHours:f,fluidLossLiters:b!=null&&p!=null?se(b,p):"n/a",sodiumLossMg:y!=null&&k!=null?se(y,k):"n/a",potassiumLossMg:$!=null&&T!=null?se($,T):"n/a",grossSportWeightEquivalentKgPerWeek:P}}}function Te({rows:e,compact:t=!1}){return a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"grid gap-2 md:hidden",children:e.map(n=>a.jsxs("div",{className:"grid min-w-0 gap-2 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-3",children:[a.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[a.jsx("div",{className:"min-w-0 break-words text-sm font-semibold text-[var(--ui-ink)]",children:n.label}),a.jsxs("div",{className:"shrink-0 text-right text-sm font-semibold text-[var(--ui-ink)]",children:[n.target,a.jsx("div",{className:"text-xs font-normal text-[var(--ui-ink-faint)]",children:n.unit})]})]}),a.jsx("p",{className:"min-w-0 break-words text-xs leading-5 text-[var(--ui-ink-muted)]",children:n.note}),t?null:a.jsx(E,{tone:"meta",wrap:!0,className:"justify-self-start",children:n.source})]},n.id))}),a.jsx("div",{className:"hidden overflow-hidden rounded-[20px] border border-[var(--ui-border-subtle)] md:block",children:a.jsx("div",{className:"max-h-[460px] overflow-auto",children:a.jsxs("table",{className:"w-full min-w-[620px] border-collapse text-left text-sm",children:[a.jsx("thead",{className:"sticky top-0 bg-[var(--ui-surface-2)] text-xs uppercase text-[var(--ui-ink-faint)]",children:a.jsxs("tr",{children:[a.jsx("th",{className:"px-4 py-3 font-semibold",children:"Target"}),a.jsx("th",{className:"px-4 py-3 font-semibold",children:"Amount"}),a.jsx("th",{className:"px-4 py-3 font-semibold",children:"Rationale"}),t?null:a.jsx("th",{className:"px-4 py-3 font-semibold",children:"Source"})]})}),a.jsx("tbody",{className:"divide-y divide-[var(--ui-border-subtle)]",children:e.map(n=>a.jsxs("tr",{className:"bg-[var(--ui-surface-1)]",children:[a.jsx("td",{className:"px-4 py-3 font-medium text-[var(--ui-ink)]",children:n.label}),a.jsxs("td",{className:"px-4 py-3 text-[var(--ui-ink)]",children:[a.jsx("span",{className:"font-semibold",children:n.target})," ",a.jsx("span",{className:"text-[var(--ui-ink-faint)]",children:n.unit})]}),a.jsx("td",{className:"px-4 py-3 text-[var(--ui-ink-muted)]",children:n.note}),t?null:a.jsx("td",{className:"px-4 py-3",children:a.jsx(E,{tone:"meta",children:n.source})})]},n.id))})]})})})]})}function ge({title:e,description:t,children:n}){return a.jsxs(I,{children:[a.jsxs("div",{className:"mb-4",children:[a.jsx("h3",{className:"text-sm font-semibold text-[var(--ui-ink)]",children:e}),a.jsx("p",{className:"mt-1 text-sm text-[var(--ui-ink-muted)]",children:t})]}),n]})}function Ht({view:e}){const t=Bt(e),n=e.target.weeklyRateGoalKg??null,r=n!=null&&Number.isFinite(n)?xa(n):null,s=t.profile.restingEnergyKcal,d=t.profile.activeBurnKcal,g=s!=null&&d!=null?s+d:null,l=e.target.bodyGoal??"maintain",o=l.includes("lose")?2:l.includes("gain")?1.8:1.6,u=b=>{var k;const p=(k=t.macros.find($=>$.id===b))==null?void 0:k.target,y=Number(p);return Number.isFinite(y)?y:null},C=t.profile.sex==="male"?t.profile.ageYears>=51?30:38:t.profile.ageYears>=51?21:25,A=Math.round(t.profile.calorieTarget/1e3*14),f=t.sportSummary.grossSportWeightEquivalentKgPerWeek!=null?`${t.sportSummary.grossSportWeightEquivalentKgPerWeek.toFixed(2)} kg/week`:"n/a";return a.jsx("section",{className:"grid gap-4",children:a.jsxs(V,{className:"p-5",children:[a.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-[var(--ui-ink)]",children:[a.jsx(Qa,{className:"size-4 text-[var(--ui-accent)]"}),"Macro And Micronutrient Targets",a.jsx(fa,{values:{sex:t.profile.sex,ageYears:t.profile.ageYears,currentWeightKg:t.profile.currentWeightKg,bmrKcal:null,restingKcal:s,restingSource:s!=null?"formula baseline; HealthKit complete-day evidence is calibration":null,activeKcal:d,maintenanceKcal:g,weeklyRateKg:n,dailyAdjustmentKcal:r,rateModel:Q.label,rateModelHorizonDays:Q.defaultPlanningHorizonDays,calorieTarget:t.profile.calorieTarget,calorieFloor:t.profile.sex==="male"?1500:1200,proteinReferenceWeightKg:null,proteinFactor:o,proteinGrams:u("protein"),fatGrams:u("fat"),carbohydrateGrams:u("carbohydrate"),fiberGrams:u("fiber"),fiberEnergyAdjustedGrams:A,fiberDriGrams:C}})]}),a.jsx("p",{className:"mt-1 max-w-3xl text-sm text-[var(--ui-ink-muted)]",children:"Daily targets use Forge plan values first, then adult DRI/Dietary Guidelines defaults for nutrients the food log can score as catalog detail improves."})]}),a.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.jsxs(E,{tone:"signal",children:[t.profile.calorieTarget.toFixed(0)," kcal"]}),a.jsxs(E,{tone:"meta",children:[t.profile.sex,", ",t.profile.ageYears.toFixed(0),"y"]})]})]}),a.jsxs("div",{className:"mt-5 grid gap-4 2xl:grid-cols-[minmax(0,1fr)_minmax(320px,0.58fr)]",children:[a.jsxs("div",{className:"grid gap-4",children:[a.jsx(ge,{title:"All macro targets",description:"Calories, protein, carbs, fat, fiber, sugar ceiling, saturated fat ceiling, essential fats, and water.",children:a.jsx(Te,{rows:t.macros,compact:!0})}),a.jsx(ge,{title:"Vitamins",description:"Adult daily vitamin targets from DRI values, adjusted for sex and age where the reference differs.",children:a.jsx(Te,{rows:t.vitamins})})]}),a.jsxs("div",{className:"grid content-start gap-4",children:[a.jsxs(ge,{title:"Expected sport losses",description:"Planning range from active burn. Calibrate with pre/post workout weight when possible.",children:[a.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[a.jsx(M,{label:"Active burn",value:t.profile.activeBurnKcal!=null?`${t.profile.activeBurnKcal.toFixed(0)} kcal`:"n/a"}),a.jsx(M,{label:"Sport equivalent",value:f}),a.jsx(M,{label:"Sweat fluid",value:`${t.sportSummary.fluidLossLiters} L`}),a.jsx(M,{label:"Sodium loss",value:`${t.sportSummary.sodiumLossMg} mg`})]}),a.jsxs("div",{className:"mt-4 flex items-start gap-3 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-3 text-sm text-[var(--ui-ink-muted)]",children:[a.jsx(pa,{className:"mt-0.5 size-4 shrink-0 text-[var(--ui-accent)]"}),a.jsx("span",{children:"Sport burn is shown as gross energy equivalent, not a promise of scale loss. The calorie plan may already include active burn, and replacement depends on appetite, heat, sodium loss, and actual intake."})]})]}),a.jsx(ge,{title:"Minerals & oligoelements",description:"Daily mineral and trace-element targets including sodium ceiling and potassium AI.",children:a.jsx(Te,{rows:t.minerals,compact:!0})}),a.jsx(ge,{title:"Sport electrolyte model",description:"Use these as expected losses, not rigid supplement prescriptions.",children:a.jsx("div",{className:"grid gap-3",children:t.sportLosses.map(b=>a.jsxs("div",{className:"flex items-start justify-between gap-3 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-3",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-[var(--ui-ink)]",children:[b.id==="sweat_fluid"?a.jsx(Va,{className:"size-4 text-[var(--ui-accent)]"}):a.jsx(Ya,{className:"size-4 text-[var(--ui-accent)]"}),b.label]}),a.jsx("p",{className:"mt-1 text-xs text-[var(--ui-ink-faint)]",children:b.note})]}),a.jsxs("div",{className:"shrink-0 text-right text-sm font-semibold text-[var(--ui-ink)]",children:[b.target,a.jsx("div",{className:"text-xs font-normal text-[var(--ui-ink-faint)]",children:b.unit})]})]},b.id))})})]})]})]})})}function ie(e,t){var r;if(!e)return null;const n=e.match(new RegExp(`${t}=([^;]+)`));return((r=n==null?void 0:n[1])==null?void 0:r.trim())??null}function z(e){const t=typeof e=="number"?e:Number(e);return Number.isFinite(t)&&t>0?t:null}function ja(e,t){if(t==="maintain")return 0;const n=t==="gain"?.0025:.005,r=t==="gain"?.1:.2,s=t==="gain"?.35:Math.max(.5,e*.01);return Math.min(s,Math.max(r,e*n))}function ka(e,t){return t==="gain"?e*1.03:t==="maintain"?e:e*.95}function Na(e){return e.toFixed(1)}function zt(e,t){return e==="male"?t>=51?30:38:t>=51?21:25}function qt(e){if(e.ageYears==null||e.ageYears<=0||e.heightCm==null||e.heightCm<=0||e.weightKg==null||e.weightKg<=0)return null;const t=e.sex==="male"?5:-161;return 10*e.weightKg+6.25*e.heightCm-5*e.ageYears+t}function ra(e,t){const n=e/100;return n>0?t*n*n:null}function Ot(e){const t=e.goalMode==="lose"&&e.goalWeightKg!=null?Math.min(e.currentWeightKg,e.goalWeightKg):e.currentWeightKg,n=ra(e.heightCm,30),r=ra(e.heightCm,25);if(n!=null&&r!=null&&e.currentWeightKg>n){const s=r+(e.currentWeightKg-r)*.25;return Math.min(t,s)}return t}function Ut(e,t){const n=z(e.currentWeightKg)??80;return{...e,goalMode:t,goalWeightKg:Na(ka(n,t)),weeklyRateKg:ja(n,t).toFixed(2)}}function Le(e){const t=_(e.weightTrend.latestWeightKg),n=e.target,r=ie(n.notes,"sex"),s=ie(n.notes,"age_years"),d=ie(n.notes,"height_cm"),g=_(e.energyModel.activeBurnKcal)??_(e.energyModel.activeEnergyCalories)??_(e.energyModel.movementCaloriesKcal)??z(ie(n.notes,"activity_kcal"))??0,l=n.bodyGoal??"",o=l.includes("gain")?"gain":l.includes("maintain")?"maintain":"lose",u=n.weightGoalKg??n.goalBodyWeightKg??null,C=t??80;return{goalMode:o,sex:r==="female"?"female":"male",ageYears:z(s)?String(s):"",heightCm:z(d)?String(d):"",currentWeightKg:t?t.toFixed(1):"",goalWeightKg:u?String(u):Na(ka(C,o)),weeklyRateKg:n.weeklyRateGoalKg!==null&&n.weeklyRateGoalKg!==void 0?String(Math.abs(n.weeklyRateGoalKg)):ja(C,o).toFixed(2),activeCaloriesKcal:g.toFixed(0),restingCaloriesKcal:_(e.energyModel.formulaRestingKcal)!=null?String(_(e.energyModel.formulaRestingKcal)):"",dietStyle:n.dietStyle??""}}function Qt(e){const t=z(ie(e.target.notes,"age_years"))!=null,n=z(ie(e.target.notes,"height_cm"))!=null,r=_(e.weightTrend.latestWeightKg)!=null,s=typeof e.target.bodyGoal=="string"&&e.target.bodyGoal.trim().length>0&&e.target.calorieTarget>0&&e.target.proteinGramsTarget>0;return t&&n&&r&&s}function Vt(e){const t=e.energyModel,n=t.activeBaselineEvidenceDays>0?`Forge is averaging ${t.activeBaselineEvidenceDays} measured prior day${t.activeBaselineEvidenceDays===1?"":"s"} inside the past ${t.activeBaselineWindowDays} days, excluding today and ignoring missing sync days instead of counting them as zero.`:`Forge has no measured prior-day active evidence in the past ${t.activeBaselineWindowDays} days, so it is falling back to the saved plan estimate.`,r=t.energySourceConfidence==="healthkit_daily_active_energy"?"HealthKit daily active energy is the active-burn source; workout and movement values are only visible evidence and are not added again.":t.energySourceConfidence==="workout_movement_fallback"?"HealthKit daily active energy is missing, so active burn already equals workout average plus movement-trip average.":"No measured active-burn stream is available, so Forge is using the saved plan estimate.";return`This is the baseline active allowance used when today has no same-day workout, movement, step, or active-energy evidence. ${n} ${r} Current evidence: active burn ${i(t.activeBurnKcal)} kcal/day, workout average ${i(t.workoutEnergyKcal)} kcal/day, movement average ${i(t.movementCaloriesKcal)} kcal/day, today's workout ${i(t.todayWorkoutEnergyKcal)} kcal, today's movement ${i(t.todayMovementCaloriesKcal)} kcal.`}function wa(e){const t=Number(e.currentWeightKg)||80,n=Number(e.heightCm)||178,r=Number(e.ageYears)||35,s=z(e.goalWeightKg),d=Math.max(0,Number(e.activeCaloriesKcal)||0),g=qt({sex:e.sex,ageYears:r,heightCm:n,weightKg:t})??10*t+6.25*n-5*r+5,l=g,o=l+d,u=Math.abs(Number(e.weeklyRateKg)||0),C=e.goalMode==="lose"?-u:e.goalMode==="gain"?u:0,A=xa(C)??0,f=Et(C)??0,b=e.sex==="male"?1500:1200,p=Math.round(o+A),y=Math.max(b,p),k=Ot({currentWeightKg:t,goalWeightKg:s,heightCm:n,goalMode:e.goalMode}),$=e.goalMode==="lose"?2:e.goalMode==="gain"?1.8:1.6,T=Math.round(k*$),P=Math.floor(y*.45/4),W=Math.max(1,Math.min(T,P)),q=k*.6,R=y*.25/9,te=Math.max(0,(y-W*4)/9),Y=Math.max(0,Math.floor(Math.min(te,y*.35/9,Math.max(q,R)))),X=Math.max(0,Math.floor((y-W*4-Y*9)/4)),O=Math.round(y/1e3*14),ce=zt(e.sex,r),ne=O,de=Math.round(y*.1/9),ee=Math.round(y*.1/4);return{bmr:Math.round(g),restingCalories:Math.round(l),restingSource:"Mifflin-St Jeor baseline",activeCalories:Math.round(d),maintenanceCalories:Math.round(o),plannedCalorieTarget:p,minimumCalorieFloor:b,weeklyRateGoalKg:C,dailyEnergyAdjustment:Math.round(A),staticDailyEnergyAdjustment:Math.round(f),rateModel:Q.id,rateModelLabel:Q.label,rateModelPlanningHorizonDays:Q.defaultPlanningHorizonDays,calorieTarget:y,proteinReferenceWeight:Math.round(k*10)/10,proteinGramsTarget:W,carbohydrateGramsTarget:X,fatGramsTarget:Y,fiberGramsTarget:ne,fiberEnergyAdjustedGrams:O,fiberDriGrams:ce,saturatedFatLimitGrams:de,addedSugarLimitGrams:ee}}function Yt(e){const t=[],n=Number(e.ageYears),r=Number(e.heightCm),s=Number(e.currentWeightKg),d=Number(e.goalWeightKg),g=Number(e.weeklyRateKg),l=e.activeCaloriesKcal.trim()?Number(e.activeCaloriesKcal):Number.NaN,o=e.restingCaloriesKcal.trim()?Number(e.restingCaloriesKcal):null;return(!Number.isFinite(n)||n<13||n>100)&&t.push("- Enter the user's real age. Forge uses it in Mifflin-St Jeor resting metabolism."),(!Number.isFinite(r)||r<120||r>230)&&t.push("- Enter height in cm. Height changes BMR and protein reference weight."),(!Number.isFinite(s)||s<30||s>300)&&t.push("- Enter current weight in kg. Use the latest known body measure as the starting state."),e.goalMode!=="maintain"&&(!Number.isFinite(d)||d<30||d>300)&&t.push("- Enter a target weight for the selected loss or gain objective."),(!Number.isFinite(g)||g<0)&&t.push("- Enter a non-negative weekly change rate in kg/week."),Number.isFinite(g)&&g>Math.max(1.5,s*.02)&&t.push("- The weekly rate is very aggressive. Choose a slower default unless this is a supervised plan."),(!Number.isFinite(l)||l<0||l>3e3)&&t.push("- Enter average active calories per day. Zero is valid only when Forge has no activity evidence."),o!=null&&(!Number.isFinite(o)||o<900||o>3500)&&t.push("- Formula resting baseline should stay in a plausible daily range."),t.length>0?t.join(`
|
|
2
2
|
`):null}function Jt(e){const t=wa(e),n=Number(e.goalWeightKg);return{calorieTarget:t.calorieTarget,proteinGramsTarget:t.proteinGramsTarget,fiberGramsTarget:t.fiberGramsTarget,carbohydrateGramsTarget:t.carbohydrateGramsTarget,fatGramsTarget:t.fatGramsTarget,weightGoalKg:Number.isFinite(n)?n:null,weeklyRateGoalKg:t.weeklyRateGoalKg,dietStyle:e.dietStyle,bodyGoal:e.goalMode,notes:["Forge science plan",`height_cm=${Number(e.heightCm)||"unknown"}`,`age_years=${Number(e.ageYears)||"unknown"}`,`sex=${e.sex}`,"bmr_formula=Mifflin-St Jeor",`resting_kcal=${t.restingCalories}`,`activity_kcal=${t.activeCalories}`,"eat_back_fraction=0.5",`maintenance_kcal=${t.maintenanceCalories}`,`rate_model=${t.rateModel}`,`rate_model_horizon_days=${t.rateModelPlanningHorizonDays}`,`static_7700_adjustment_kcal=${t.staticDailyEnergyAdjustment}`].join("; ")}}function Zt({open:e,onOpenChange:t,view:n,value:r,onChange:s,onSubmit:d,pending:g,error:l}){const o=K.useMemo(()=>wa(r),[r]),u=z(r.ageYears)!=null&&z(r.heightCm)!=null&&z(r.currentWeightKg)!=null,C=u?String(o.bmr):"",A=u?`Forge uses Mifflin-St Jeor as the stable target baseline. Complete HealthKit basal energy stays evidence/calibration, not the silent default. Current formula value: ${o.bmr} kcal.`:"Forge will calculate this from real age, height, sex, and current weight. Complete HealthKit basal energy stays evidence/calibration, not the silent default.",f=K.useMemo(()=>ya({sex:r.sex,ageYears:Number(r.ageYears)||35,currentWeightKg:Number(r.currentWeightKg)||80,calorieTarget:o.calorieTarget,proteinGramsTarget:o.proteinGramsTarget,carbohydrateGramsTarget:o.carbohydrateGramsTarget,fatGramsTarget:o.fatGramsTarget,fiberGramsTarget:o.fiberGramsTarget,activeBurnKcal:o.activeCalories,movementCaloriesKcal:_(n.energyModel.movementCaloriesKcal),restingEnergyKcal:o.restingCalories}),[o,r,n.energyModel.movementCaloriesKcal]),b=[{id:"profile",eyebrow:"Current state",title:"Confirm the body data Forge knows",description:"These fields drive resting metabolism. Saved values are reused when Forge has them.",render:(p,y)=>a.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[a.jsx(j,{label:"Sex",children:a.jsx(na,{value:p.sex,onChange:k=>y({sex:k}),options:[{value:"male",label:"Male"},{value:"female",label:"Female"}]})}),a.jsx(j,{label:"Age",children:a.jsx(w,{inputMode:"numeric",value:p.ageYears,onChange:k=>y({ageYears:k.target.value}),placeholder:"35"})}),a.jsx(j,{label:"Height cm",children:a.jsx(w,{inputMode:"decimal",value:p.heightCm,onChange:k=>y({heightCm:k.target.value}),placeholder:"178"})}),a.jsx(j,{label:"Current weight kg",children:a.jsx(w,{inputMode:"decimal",value:p.currentWeightKg,onChange:k=>y({currentWeightKg:k.target.value}),placeholder:"80.0"})})]})},{id:"objective",eyebrow:"Goal",title:"Choose what should happen next",description:"Forge proposes a default target and weekly rate from current weight; you can change both.",render:(p,y)=>a.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[a.jsx("div",{className:"md:col-span-2",children:a.jsx(na,{columns:3,value:p.goalMode,onChange:k=>y(Ut(p,k)),options:[{value:"lose",label:"Lose fat",description:"Default: about 0.5% body weight per week."},{value:"gain",label:"Gain mass",description:"Default: small surplus around 0.25% per week."},{value:"maintain",label:"Maintain",description:"Hold weight while optimizing signals."}]})}),a.jsx(j,{label:"Target weight kg",hint:"Filled from the objective; change it anytime.",children:a.jsx(w,{inputMode:"decimal",value:p.goalWeightKg,onChange:k=>y({goalWeightKg:k.target.value}),placeholder:"75.0"})}),a.jsx(j,{label:"Weekly change kg",hint:"Loss/gain rate is converted to kcal/day with the Hall/NIDDK adult dynamic model over Forge's 12-week planning horizon.",children:a.jsx(w,{inputMode:"decimal",value:p.weeklyRateKg,onChange:k=>y({weeklyRateKg:k.target.value}),placeholder:"0.35"})})]})},{id:"activity",eyebrow:"Activity",title:"Add active burn to resting burn",description:"Active calories are independent evidence from HealthKit, workouts, and movement. The objective only changes the deficit or surplus.",render:(p,y)=>a.jsxs("div",{className:"grid gap-4",children:[a.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[a.jsx(j,{label:"Formula resting baseline/day",hint:A,children:a.jsx(w,{inputMode:"decimal",value:C,readOnly:!0,placeholder:"Calculated from profile"})}),a.jsx(j,{label:"Average active calories/day",hint:Vt(n),children:a.jsx(w,{inputMode:"decimal",value:p.activeCaloriesKcal,onChange:k=>y({activeCaloriesKcal:k.target.value}),placeholder:"350"})})]}),a.jsxs("div",{className:"grid gap-3 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4 md:grid-cols-3",children:[a.jsx(M,{label:o.restingSource,value:`${o.restingCalories} kcal`}),a.jsx(M,{label:"Maintenance",value:`${o.maintenanceCalories} kcal`}),a.jsx(M,{label:"Daily adjustment",value:`${o.dailyEnergyAdjustment>0?"+":""}${o.dailyEnergyAdjustment} kcal`})]})]})},{id:"macros",eyebrow:"Macros",title:"Validate calories, macros, and limits",description:"Target intake equals resting burn plus active burn plus the objective adjustment. Macros are generated from protein-per-kg, a practical fat floor, remaining carbohydrates, fiber density, and dietary limits.",render:(p,y)=>a.jsxs("div",{className:"grid gap-4",children:[a.jsxs("div",{className:"flex items-start justify-between gap-3 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3",children:[a.jsx("div",{className:"min-w-0 text-sm leading-6 text-[var(--ui-ink-muted)]",children:"Inspect the exact math behind the current calories, macro targets, and sport-loss preview."}),a.jsx(fa,{values:{sex:p.sex,ageYears:Number(p.ageYears)||null,currentWeightKg:Number(p.currentWeightKg)||null,heightCm:Number(p.heightCm)||null,bmrKcal:o.bmr,restingKcal:o.restingCalories,restingSource:o.restingSource,activeKcal:o.activeCalories,maintenanceKcal:o.maintenanceCalories,weeklyRateKg:o.weeklyRateGoalKg,dailyAdjustmentKcal:o.dailyEnergyAdjustment,rateModel:o.rateModelLabel,rateModelHorizonDays:o.rateModelPlanningHorizonDays,calorieTarget:o.calorieTarget,calorieFloor:o.minimumCalorieFloor,proteinReferenceWeightKg:o.proteinReferenceWeight,proteinFactor:p.goalMode==="lose"?2:p.goalMode==="gain"?1.8:1.6,proteinGrams:o.proteinGramsTarget,fatGrams:o.fatGramsTarget,carbohydrateGrams:o.carbohydrateGramsTarget,fiberGrams:o.fiberGramsTarget,fiberEnergyAdjustedGrams:o.fiberEnergyAdjustedGrams,fiberDriGrams:o.fiberDriGrams}})]}),a.jsxs("div",{className:"grid gap-3 md:grid-cols-4 xl:grid-cols-7",children:[a.jsx(M,{label:"Calories",value:`${o.calorieTarget}`}),a.jsx(M,{label:"Protein",value:`${o.proteinGramsTarget}g`}),a.jsx(M,{label:"Carbs",value:`${o.carbohydrateGramsTarget}g`}),a.jsx(M,{label:"Fat",value:`${o.fatGramsTarget}g`}),a.jsx(M,{label:"Fiber",value:`${o.fiberGramsTarget}g`}),a.jsx(M,{label:"Sat fat max",value:`${o.saturatedFatLimitGrams}g`}),a.jsx(M,{label:"Added sugar max",value:`${o.addedSugarLimitGrams}g`})]}),a.jsxs("div",{className:"grid gap-4 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[a.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-sm font-semibold text-[var(--ui-ink)]",children:"Micronutrient and sport-loss preview"}),a.jsx("div",{className:"mt-1 text-sm leading-6 text-[var(--ui-ink-muted)]",children:"The dashboard will track vitamin, mineral, trace-element, water, sodium-ceiling, essential-fat, and sport-loss targets from this plan."})]}),a.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.jsxs(E,{tone:"meta",children:[f.vitamins.length," vitamins"]}),a.jsxs(E,{tone:"meta",children:[f.minerals.length," minerals"]}),a.jsxs(E,{tone:"signal",children:[f.sportSummary.fluidLossLiters," L sweat"]})]})]}),a.jsxs("div",{className:"grid gap-3 md:grid-cols-4",children:[a.jsx(M,{label:"Sport sodium loss",value:`${f.sportSummary.sodiumLossMg} mg`}),a.jsx(M,{label:"Sport potassium loss",value:`${f.sportSummary.potassiumLossMg} mg`}),a.jsx(M,{label:"Water baseline",value:r.sex==="male"?"3.7 L":"2.7 L"}),a.jsx(M,{label:"Essential fats",value:r.sex==="male"?"17g LA / 1.6g ALA":"12g LA / 1.1g ALA"})]})]}),a.jsx(j,{label:"Diet style or constraints",children:a.jsx(ke,{value:p.dietStyle,onChange:k=>y({dietStyle:k.target.value}),placeholder:"Mediterranean, high protein, no lactose, low FODMAP trial..."})})]})}];return a.jsx(Ce,{open:e,onOpenChange:t,eyebrow:"Weight plan",title:"Set weight objective",description:"Build an editable calorie and macro plan.",value:r,onChange:s,steps:b,onSubmit:d,submitLabel:"Save plan",pending:g,pendingLabel:"Saving plan",error:l,draftPersistenceKey:"weight-loss-plan"})}const Xt={tsp:5,tbsp:15,cup:240};function je(){return{mealLabel:"Meal",notes:"",source:"search",selectedItems:[]}}function G(e,t,n){return typeof e!="number"||!Number.isFinite(e)?null:Ma(n)==="grams"?e:t>0?Math.round(e/t*10)/10:e}function en(e){const t=Number.isFinite(e.quantity)&&e.quantity>0?e.quantity:1,n=e.unit??"serving",r=n==="grams"?e.grams??t:e.grams!=null&&t>0?e.grams/t:e.grams;return{id:e.foodId??e.id,source:"saved_meal",sourceId:e.foodId??e.id,name:e.name,brand:e.brand??null,barcode:null,servingLabel:n,servingGrams:r??null,calories:G(e.calories,t,n),proteinGrams:G(e.proteinGrams,t,n),carbohydrateGrams:G(e.carbohydrateGrams,t,n),fatGrams:G(e.fatGrams,t,n),fiberGrams:G(e.fiberGrams,t,n),sugarGrams:G(e.sugarGrams,t,n),sodiumMg:G(e.sodiumMg,t,n),potassiumMg:G(e.potassiumMg,t,n),caffeineMg:G(e.caffeineMg,t,n),alcoholGrams:G(e.alcoholGrams,t,n),glycemicIndex:e.glycemicIndex??null,novaGroup:e.novaGroup??null,tags:e.tags??[],confidence:e.confidence??null}}function an(e,t,n){const r=Number.isFinite(e.quantity)&&e.quantity>0?e.quantity:1,s=e.unit??"serving",d=s==="grams"||s==="g"?e.grams??r:e.grams!=null&&r>0?e.grams/r:e.grams;return{id:e.foodId??`${n}_${t}_${Date.now()}`,source:n,sourceId:e.foodId??null,name:e.name,brand:e.brand??null,barcode:null,servingLabel:s,servingGrams:d??null,calories:G(e.calories,r,s),proteinGrams:G(e.proteinGrams,r,s),carbohydrateGrams:G(e.carbohydrateGrams,r,s),fatGrams:G(e.fatGrams,r,s),fiberGrams:G(e.fiberGrams,r,s),sugarGrams:G(e.sugarGrams,r,s),sodiumMg:G(e.sodiumMg,r,s),potassiumMg:G(e.potassiumMg,r,s),caffeineMg:G(e.caffeineMg,r,s),alcoholGrams:G(e.alcoholGrams,r,s),glycemicIndex:e.glycemicIndex??null,novaGroup:e.novaGroup??null,tags:e.tags??[],confidence:e.confidence??null}}function tn(e){if(!e)return null;const n=e.toLowerCase().replace(",",".").match(/(\d+(?:\.\d+)?)\s*(kg|g|gram|grams|ml|l)\b/);if(!n)return null;const r=Number(n[1]);if(!Number.isFinite(r)||r<=0)return null;const s=n[2];return s==="kg"||s==="l"?r*1e3:r}function he(e){return typeof e.servingGrams=="number"&&Number.isFinite(e.servingGrams)&&e.servingGrams>0?e.servingGrams:tn(e.servingLabel)}function nn(e){const t=he(e);return t!=null?`${i(t)} g`:e.servingLabel??"serving"}function Ca(e){const t=Number(e.amount)||0;if(t<=0)return null;const n=he(e.food);return e.unit==="grams"?t:e.unit==="tsp"||e.unit==="tbsp"||e.unit==="cup"?t*Xt[e.unit]:n!=null?t*n:null}function sa(e){return!(e.unit==="grams"||e.unit==="tsp"||e.unit==="tbsp"||e.unit==="cup")||he(e.food)!=null?null:"Add base grams before using grams or household measures. Without a denominator, Forge will not guess a ratio."}function Ma(e){const t=e==null?void 0:e.trim().toLowerCase();return t==="g"||t==="gram"||t==="grams"?"grams":t==="tsp"||t==="teaspoon"?"tsp":t==="tbsp"||t==="tablespoon"?"tbsp":t==="cup"?"cup":t==="serving"||t==="servings"?"serving":"unit"}function rn(e){switch(e){case"manual":case"search":case"barcode":case"chatgpt":case"photo":case"saved_meal":return e;default:return"manual"}}function sn(e){return{mealLabel:e.mealLabel??"Meal",notes:e.notes??"",loggedAt:e.loggedAt,dayKey:e.dayKey,source:rn(e.source),selectedItems:e.items.map(t=>({localId:t.id,food:en(t),amount:String(t.quantity||1),unit:t.unit??"serving"}))}}function on(e,t=e.source??"manual"){return{mealLabel:e.mealLabel??"Meal",notes:e.notes??"",loggedAt:e.loggedAt,dayKey:e.dayKey,source:e.source??"manual",selectedItems:e.items.map((n,r)=>({localId:`${t}-${r}-${Date.now()}`,food:an(n,r,t),amount:String(n.quantity||1),unit:Ma(n.unit)}))}}function Fa(){return{id:`custom_food_${Date.now()}`,source:"manual",sourceId:null,name:"Custom food",brand:null,barcode:null,servingLabel:"100 g",servingGrams:100,calories:null,proteinGrams:null,carbohydrateGrams:null,fatGrams:null,fiberGrams:null,sugarGrams:null,sodiumMg:null,potassiumMg:null,caffeineMg:null,alcoholGrams:null,glycemicIndex:null,novaGroup:null,tags:["custom"],confidence:1}}function ln(){return{mealLabel:"Meal",notes:"",source:"manual",selectedItems:[{localId:`custom-${Date.now()}`,food:Fa(),amount:"100",unit:"grams"}]}}function cn({open:e,onOpenChange:t,value:n,onChange:r,foodResults:s,searchPending:d,chatGptPending:g=!1,chatGptError:l=null,logPending:o,onSearch:u,onParseWithChatGpt:C,onSubmit:A,mode:f="create",intent:b="search",initialStepId:p}){const[y,k]=K.useState(""),[$,T]=K.useState(""),[P,W]=K.useState(null),q=K.useMemo(()=>pn(n.selectedItems),[n.selectedItems]),R=x=>r({...n,...x}),te=x=>{R({selectedItems:[...n.selectedItems,{localId:`${x.id}-${Date.now()}`,food:x,amount:"1",unit:"serving"}]}),W(null)},Y=()=>{te(Fa())},X=async()=>{const x=$.trim();!x||!C||(await C(x),T(""))},O=(x,v)=>{R({selectedItems:n.selectedItems.map(N=>N.localId===x?{...N,...v}:N)})},ce=(x,v)=>{R({selectedItems:n.selectedItems.map(N=>N.localId===x?{...N,food:{...N.food,...v}}:N)})},ne=x=>{R({selectedItems:n.selectedItems.filter(v=>v.localId!==x)})},de=async()=>{n.selectedItems.length!==0&&await A()},ee=a.jsxs(I,{className:"grid gap-3",children:[a.jsx(j,{label:"Ask ChatGPT",labelHelp:"Uses the connected OpenAI Codex OAuth / ChatGPT subscription model to create a reviewable candidate meal draft. It does not use the metered OpenAI Platform API.",children:a.jsx(ke,{value:$,onChange:x=>T(x.target.value),placeholder:"Example: 2 eggs, 150g Greek yogurt, one banana, and a cappuccino..."})}),l?a.jsx("div",{className:"rounded-[18px] border border-[var(--ui-danger-soft)] bg-[var(--ui-danger-soft)] px-3 py-2 text-xs leading-5 text-[var(--ui-ink)]",children:l}):null,a.jsxs(D,{type:"button",variant:b==="chatgpt"?"primary":"secondary",pending:g,pendingLabel:"Parsing",disabled:!$.trim()||!C,onClick:()=>void X(),children:[a.jsx(ua,{className:"size-4"}),"Parse with ChatGPT"]})]}),re=a.jsx(I,{className:"grid gap-3",children:a.jsxs("div",{className:"flex items-start justify-between gap-3",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"text-sm font-semibold text-[var(--ui-ink-strong)]",children:"Create custom food"}),a.jsx("div",{className:"mt-1 text-xs leading-5 text-[var(--ui-ink-soft)]",children:"Start from a blank food, then define base grams, calories, macros, sodium, and exact quantity in the next step."})]}),a.jsxs(D,{type:"button",size:"sm",onClick:Y,children:[a.jsx(Be,{className:"size-4"}),"Add custom"]})]})}),J=b==="chatgpt"?[ee,re]:[re,ee],pe=[{id:"search",eyebrow:b==="chatgpt"?"ChatGPT food parser":"Food",title:b==="chatgpt"?"Describe the meal, then review every item":"Search, create, or ask ChatGPT",description:b==="chatgpt"?"ChatGPT creates a candidate meal through the subscription-backed connection; you still review quantities and nutrients before saving.":"Search the catalog, create a custom food, or use ChatGPT to turn rough meal text into editable items.",render:()=>a.jsxs("div",{className:"grid gap-4",children:[a.jsxs("div",{className:"grid gap-3 md:grid-cols-[minmax(0,1fr)_auto]",children:[a.jsx(j,{label:"Food search",labelHelp:"Search returns food candidates with per-serving nutrition. Click a result to inspect macros before adding it to the meal draft.",children:a.jsx(w,{value:y,onChange:x=>k(x.target.value),placeholder:"Search eggs, yogurt, sourdough..."})}),a.jsxs(D,{type:"button",variant:"secondary",pending:d,disabled:!y.trim(),onClick:()=>u(y),children:[a.jsx(ga,{className:"size-4"}),"Search"]})]}),a.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:J.map((x,v)=>a.jsx("div",{children:x},`${b}-assistant-panel-${v}`))}),P?a.jsx(hn,{food:P,onAdd:()=>te(P)}):null,a.jsx("div",{className:"grid gap-3",children:s.map(x=>a.jsx(I,{interactive:!0,className:"p-0",children:a.jsx("button",{type:"button",className:"block w-full rounded-[22px] p-4 text-left",onClick:()=>W(x),children:a.jsxs("div",{className:"flex items-start justify-between gap-3",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"truncate text-sm font-semibold text-[var(--ui-ink-strong)]",children:x.name}),a.jsx("div",{className:"mt-1 truncate text-xs text-[var(--ui-ink-faint)]",children:[x.brand,x.servingLabel,x.source].filter(Boolean).join(" · ")})]}),a.jsxs(E,{tone:"meta",children:[i(x.calories)," kcal"]})]})})},x.id))})]})},{id:"amounts",eyebrow:b==="custom"?"Custom food":"Quantity",title:b==="custom"?"Define the food and exact dose":"Set exactly how much you ate",description:"Scale by grams, servings, household measures, or units before saving the meal.",render:x=>a.jsxs("div",{className:"grid gap-4",children:[x.selectedItems.length===0?a.jsx("div",{className:"rounded-[22px] border border-dashed border-[var(--ui-border-strong)] bg-[var(--ui-surface-1)] p-5 text-sm text-[var(--ui-ink-soft)]",children:"Add at least one food from the search step."}):null,x.selectedItems.map(v=>a.jsxs(I,{className:"grid gap-3",children:[a.jsxs("div",{className:"flex items-start justify-between gap-3",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-sm font-semibold text-[var(--ui-ink-strong)]",children:v.food.name}),a.jsxs("div",{className:"text-xs text-[var(--ui-ink-faint)]",children:["Base: ",i(v.food.calories)," kcal per"," ",nn(v.food)]})]}),a.jsxs(D,{type:"button",size:"sm",variant:"ghost",onClick:()=>ne(v.localId),children:[a.jsx(ha,{className:"size-4"}),"Remove"]})]}),a.jsxs("div",{className:"grid gap-3 md:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto]",children:[a.jsx(j,{label:"Quantity",labelHelp:"This is the amount actually eaten. Forge converts the selected unit to an eaten gram equivalent when base grams are known, then scales every nutrient by eaten grams divided by base grams.",children:a.jsx(w,{inputMode:"decimal",value:v.amount,onChange:N=>O(v.localId,{amount:N.target.value}),placeholder:"1"})}),a.jsx(j,{label:"Unit",labelHelp:"Servings multiply the base serving. Grams, teaspoons, tablespoons, and cups use a gram conversion table and require base grams.",children:a.jsxs("select",{className:"interactive-tap w-full rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3 text-[15px] text-[var(--ui-ink-strong)] outline-none",value:v.unit,onChange:N=>O(v.localId,{unit:N.target.value}),children:[a.jsx("option",{value:"serving",children:"serving"}),a.jsx("option",{value:"grams",children:"grams"}),a.jsx("option",{value:"unit",children:"unit"}),a.jsx("option",{value:"tsp",children:"teaspoon"}),a.jsx("option",{value:"tbsp",children:"tablespoon"}),a.jsx("option",{value:"cup",children:"cup"})]})}),a.jsxs(E,{tone:"signal",children:[i(we(v).calories)," kcal"]})]}),sa(v)?a.jsx("div",{className:"rounded-[18px] border border-[var(--ui-warning-soft)] bg-[var(--ui-warning-soft)] px-3 py-2 text-xs leading-5 text-[var(--ui-ink)]",children:sa(v)}):a.jsxs("div",{className:"text-xs text-[var(--ui-ink-faint)]",children:[i(Number(v.amount)||0)," ",v.unit," ="," ",i(Ca(v))," g eaten; ratio ="," ",i(we(v).scale),"x the base nutrition."]}),a.jsx(mn,{item:v,onChange:N=>ce(v.localId,N)})]},v.localId)),a.jsxs("div",{className:"grid gap-3 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4 md:grid-cols-4",children:[a.jsx(M,{label:"Calories",value:i(q.calories)}),a.jsx(M,{label:"Protein",value:`${i(q.proteinGrams)}g`}),a.jsx(M,{label:"Carbs",value:`${i(q.carbohydrateGrams)}g`}),a.jsx(M,{label:"Fat",value:`${i(q.fatGrams)}g`})]})]})},{id:"context",eyebrow:"Context",title:"Meal label and notes",description:"Add how it felt, where it happened, or anything relevant to future pattern detection.",render:(x,v)=>a.jsxs("div",{className:"grid gap-4",children:[a.jsx(j,{label:"Meal label",labelHelp:"The label groups the edited items as breakfast, lunch, snack, dinner, or any personal meal name.",children:a.jsx(w,{value:x.mealLabel,onChange:N=>v({mealLabel:N.target.value}),placeholder:"Breakfast"})}),a.jsx(j,{label:"Notes",labelHelp:"Use notes for context the numbers do not capture: hunger, cravings, gut comfort, energy, timing, place, or workout relationship.",children:a.jsx(ke,{value:x.notes,onChange:N=>v({notes:N.target.value}),placeholder:"Energy, cravings, gut comfort, training effect..."})})]})}];return a.jsx(Ce,{open:e,onOpenChange:t,eyebrow:"Food log",title:f==="edit"?"Edit food":"Add food",description:"Search, inspect, scale, edit nutrition parameters, and save meal items.",value:n,onChange:r,steps:pe,initialStepId:p,onSubmit:de,submitLabel:f==="edit"?"Update meal":"Save meal",pending:o,pendingLabel:"Saving meal",resolveError:x=>x!=="search"&&n.selectedItems.length===0?"Select at least one food before saving.":null,draftPersistenceKey:`weight-loss-food-log.${f}.${b}`})}function Ka(e){return{loggedAt:e.loggedAt,dayKey:e.dayKey??We(),mealLabel:ia(e.mealLabel,"Meal"),source:e.source??"search",confirmationState:"confirmed",notes:ia(e.notes),items:e.selectedItems.map(t=>{const n=we(t);return{foodId:dn(t),name:t.food.name,brand:t.food.brand,quantity:Number(t.amount)||1,unit:t.unit,grams:n.grams,calories:n.calories,proteinGrams:n.proteinGrams,carbohydrateGrams:n.carbohydrateGrams,fatGrams:n.fatGrams,fiberGrams:n.fiberGrams,sugarGrams:n.sugarGrams,sodiumMg:n.sodiumMg,potassiumMg:n.potassiumMg,caffeineMg:n.caffeineMg,alcoholGrams:n.alcoholGrams,novaGroup:t.food.novaGroup,tags:t.food.tags,confidence:.9}})}}function ia(e,t=""){return typeof e=="string"?e:t}function dn(e){return e.food.source==="manual"||e.food.source==="chatgpt"||e.food.id.startsWith("custom_food_")||e.food.id.startsWith("chatgpt_")?null:e.food.id}function un(e){return Ka(e)}function gn(e){const t=Number(e);return Number.isFinite(t)?t:null}function mn({item:e,onChange:t}){const n=e.food,r=(s,d)=>t({[s]:gn(d)});return a.jsxs("div",{className:"grid gap-3 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-[var(--ui-ink-strong)]",children:["Food parameters",a.jsx(le,{label:`Explain editable food parameters for ${n.name}`,content:"These are the nutrient values for the base serving shown above. Changing them recalculates the eaten quantity and stores the corrected values in Forge."})]}),a.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[a.jsx(j,{label:"Base label",labelHelp:"Human-readable denominator shown for the nutrition values, such as 100 g, 220 g, one burger, or one scoop.",children:a.jsx(w,{value:n.servingLabel??"",onChange:s=>t({servingLabel:s.target.value||null}),placeholder:"100 g"})}),a.jsx(j,{label:"Base grams",labelHelp:"Gram denominator for the base nutrition values. If kcal is per 220 g, enter 220. If kcal is per 100 g, enter 100.",children:a.jsx(w,{inputMode:"decimal",value:n.servingGrams??"",onChange:s=>r("servingGrams",s.target.value),placeholder:"100"})}),a.jsx(j,{label:"Food name",labelHelp:"Rename the item when the database result is too generic or wrong.",children:a.jsx(w,{value:n.name,onChange:s=>t({name:s.target.value})})}),a.jsx(j,{label:"Brand",labelHelp:"Optional brand or preparation source, useful when the same food has different nutrition.",children:a.jsx(w,{value:n.brand??"",onChange:s=>t({brand:s.target.value||null})})})]}),a.jsxs("div",{className:"grid gap-3 md:grid-cols-4",children:[a.jsx(j,{label:"kcal",labelHelp:"Kilocalories for the base amount above. Forge multiplies this by eaten grams divided by base grams, so 2 g of a 220 g base is not treated as 2 servings.",children:a.jsx(w,{inputMode:"decimal",value:n.calories??"",onChange:s=>r("calories",s.target.value)})}),a.jsx(j,{label:"Protein g",labelHelp:"Protein grams for the base amount above. This is scaled by the same gram ratio as calories.",children:a.jsx(w,{inputMode:"decimal",value:n.proteinGrams??"",onChange:s=>r("proteinGrams",s.target.value)})}),a.jsx(j,{label:"Carbs g",labelHelp:"Carbohydrate grams for the base amount above. Carbs are training fuel after protein and fat are allocated.",children:a.jsx(w,{inputMode:"decimal",value:n.carbohydrateGrams??"",onChange:s=>r("carbohydrateGrams",s.target.value)})}),a.jsx(j,{label:"Fat g",labelHelp:"Fat grams for the base amount above. Fat supports the practical floor and AMDR context in the plan.",children:a.jsx(w,{inputMode:"decimal",value:n.fatGrams??"",onChange:s=>r("fatGrams",s.target.value)})}),a.jsx(j,{label:"Fiber g",labelHelp:"Fiber grams for the base amount above. Forge compares this to the 14g per 1000 kcal planning target.",children:a.jsx(w,{inputMode:"decimal",value:n.fiberGrams??"",onChange:s=>r("fiberGrams",s.target.value)})}),a.jsx(j,{label:"Sugar g",labelHelp:"Sugar grams for the base amount above. Added sugar is tracked as a ceiling, not a goal.",children:a.jsx(w,{inputMode:"decimal",value:n.sugarGrams??"",onChange:s=>r("sugarGrams",s.target.value)})}),a.jsx(j,{label:"Sodium mg",labelHelp:"Sodium milligrams for the base amount above. Sodium affects daily ceiling, sport loss replacement, and water retention hypotheses.",children:a.jsx(w,{inputMode:"decimal",value:n.sodiumMg??"",onChange:s=>r("sodiumMg",s.target.value)})})]})]})}function hn({food:e,onAdd:t}){return a.jsxs(V,{className:"grid gap-4 border-[var(--primary)]/20 bg-[var(--ui-accent-soft)] p-4",children:[a.jsxs("div",{className:"flex items-start justify-between gap-3",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-lg font-semibold text-[var(--ui-ink-strong)]",children:e.name}),a.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:[e.brand,e.servingLabel,e.source].filter(Boolean).join(" · ")})]}),a.jsxs(D,{type:"button",onClick:t,children:[a.jsx(Be,{className:"size-4"}),"Add"]})]}),a.jsxs("div",{className:"grid gap-3 md:grid-cols-4",children:[a.jsx(M,{label:"Calories",value:i(e.calories)}),a.jsx(M,{label:"Protein",value:`${i(e.proteinGrams)}g`}),a.jsx(M,{label:"Carbs",value:`${i(e.carbohydrateGrams)}g`}),a.jsx(M,{label:"Fat",value:`${i(e.fatGrams)}g`}),a.jsx(M,{label:"Fiber",value:`${i(e.fiberGrams)}g`}),a.jsx(M,{label:"Sugar",value:`${i(e.sugarGrams)}g`}),a.jsx(M,{label:"Sodium",value:`${i(e.sodiumMg)}mg`}),a.jsx(M,{label:"NOVA",value:e.novaGroup?String(e.novaGroup):"n/a"})]}),a.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--ui-ink-soft)]",children:[a.jsx(Ja,{className:"size-4"}),"Base grams: ",i(he(e)),". Adjust exact intake in the next step."]})]})}function we(e){const t=Number(e.amount)||0,n=he(e.food),r=Ca(e),s=e.unit==="serving"||e.unit==="unit",d=t<=0?0:n!=null&&r!=null?r/n:s?t:null,g=l=>d!=null&&typeof l=="number"&&Number.isFinite(l)?Math.round(l*d*10)/10:null;return{grams:r,scale:d,calories:g(e.food.calories),proteinGrams:g(e.food.proteinGrams),carbohydrateGrams:g(e.food.carbohydrateGrams),fatGrams:g(e.food.fatGrams),fiberGrams:g(e.food.fiberGrams),sugarGrams:g(e.food.sugarGrams),sodiumMg:g(e.food.sodiumMg),potassiumMg:g(e.food.potassiumMg),caffeineMg:g(e.food.caffeineMg),alcoholGrams:g(e.food.alcoholGrams)}}function pn(e){return e.reduce((t,n)=>{const r=we(n);return{calories:t.calories+(r.calories??0),proteinGrams:t.proteinGrams+(r.proteinGrams??0),carbohydrateGrams:t.carbohydrateGrams+(r.carbohydrateGrams??0),fatGrams:t.fatGrams+(r.fatGrams??0)}},{calories:0,proteinGrams:0,carbohydrateGrams:0,fatGrams:0})}function oa(){return{weightKg:"",waistCm:"",bodyFatPercent:"",energy:"",hunger:"",cravings:"",bloating:"",facePuffiness:"",leanness:"",notes:""}}function bn({open:e,onOpenChange:t,value:n,onChange:r,onSubmit:s,pending:d}){const g=[{id:"body",eyebrow:"Body",title:"Measurements",description:"Add weight and body measures when you have them. Empty fields are ignored.",render:(l,o)=>a.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[a.jsx(j,{label:"Weight kg",children:a.jsx(w,{inputMode:"decimal",value:l.weightKg,onChange:u=>o({weightKg:u.target.value})})}),a.jsx(j,{label:"Waist cm",children:a.jsx(w,{inputMode:"decimal",value:l.waistCm,onChange:u=>o({waistCm:u.target.value})})}),a.jsx(j,{label:"Body fat %",children:a.jsx(w,{inputMode:"decimal",value:l.bodyFatPercent,onChange:u=>o({bodyFatPercent:u.target.value})})})]})},{id:"state",eyebrow:"State",title:"Energy, appetite, and gut",description:"These subjective signals are what make the view more useful than a calorie ledger.",render:(l,o)=>a.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[a.jsx(j,{label:"Energy 0-10",children:a.jsx(w,{inputMode:"decimal",value:l.energy,onChange:u=>o({energy:u.target.value})})}),a.jsx(j,{label:"Hunger 0-10",children:a.jsx(w,{inputMode:"decimal",value:l.hunger,onChange:u=>o({hunger:u.target.value})})}),a.jsx(j,{label:"Cravings 0-10",children:a.jsx(w,{inputMode:"decimal",value:l.cravings,onChange:u=>o({cravings:u.target.value})})}),a.jsx(j,{label:"Bloating 0-10",children:a.jsx(w,{inputMode:"decimal",value:l.bloating,onChange:u=>o({bloating:u.target.value})})}),a.jsx(j,{label:"Face puffiness 0-10",children:a.jsx(w,{inputMode:"decimal",value:l.facePuffiness,onChange:u=>o({facePuffiness:u.target.value})})}),a.jsx(j,{label:"Leanness 0-10",children:a.jsx(w,{inputMode:"decimal",value:l.leanness,onChange:u=>o({leanness:u.target.value})})})]})},{id:"notes",eyebrow:"Context",title:"Notes",description:"Capture anything that explains the signal.",render:(l,o)=>a.jsx(j,{label:"Notes",children:a.jsx(ke,{value:l.notes,onChange:u=>o({notes:u.target.value}),placeholder:"Sleep, sodium, workout soreness, stressful day..."})})}];return a.jsx(Ce,{open:e,onOpenChange:t,eyebrow:"Check-in",title:"Add body signal",description:"Add measurements, energy, gut, and appearance signals.",value:n,onChange:r,steps:g,onSubmit:s,submitLabel:"Save check-in",pending:d,pendingLabel:"Saving check-in",draftPersistenceKey:"weight-loss-checkin"})}function xn(e){const t=n=>{const r=Number(n);return Number.isFinite(r)?r:null};return{body:{weightKg:t(e.weightKg),waistCm:t(e.waistCm),bodyFatPercent:t(e.bodyFatPercent),notes:e.notes},subjective:{energy:t(e.energy),hunger:t(e.hunger),cravings:t(e.cravings),timeRelation:"unspecified",notes:e.notes},gut:{bloating:t(e.bloating),notes:e.notes},appearance:{facePuffiness:t(e.facePuffiness),leanness:t(e.leanness),notes:e.notes}}}function fn(e){const t=e.items[0]??null,n=Math.max(0,e.items.length-1);return t?`${t.name}${n>0?` + ${n} more`:""}`:e.mealLabel??"Meal"}function vn(e){return e.items.slice(0,3).map(t=>{const n=Number.isFinite(t.quantity)&&t.quantity>0?Number.isInteger(t.quantity)?String(t.quantity):t.quantity.toFixed(2).replace(/\.?0+$/,""):null,r=t.unit??"serving",s=t.grams!=null?`${t.grams.toFixed(0)}g`:null;return[n,r,s?`(${s})`:null].filter(Boolean).join(" ")}).filter(Boolean).join(" · ")}function yn({open:e,onOpenChange:t,meals:n,onLogAgain:r,onEdit:s,onDelete:d,pending:g}){return a.jsx(Ce,{open:e,onOpenChange:t,eyebrow:"History",title:"Food history",description:"Review recent foods and quickly log a previous meal again.",value:{},onChange:()=>{},steps:[{id:"history",title:"Recent meal history",render:()=>a.jsx("div",{className:"grid gap-3",children:n.map(l=>a.jsxs(I,{className:"grid gap-3",children:[a.jsxs("div",{className:"flex items-start justify-between gap-3",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-sm font-semibold text-[var(--ui-ink-strong)]",children:fn(l)}),a.jsxs("div",{className:"mt-1 text-xs text-[var(--ui-ink-faint)]",children:[l.loggedAt.slice(0,10)," ·"," ",vn(l)||l.mealLabel||"No quantity recorded"]})]}),a.jsxs(E,{tone:"meta",children:[l.totals.calories.toFixed(0)," kcal"]})]}),a.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.jsx(D,{type:"button",size:"sm",variant:"secondary",onClick:()=>s(l),children:"Edit"}),a.jsx(D,{type:"button",size:"sm",variant:"ghost",pending:g,onClick:()=>d(l),children:"Delete"}),a.jsx(D,{type:"button",size:"sm",variant:"secondary",pending:g,onClick:()=>r(l),children:"Log again"})]})]},l.id))})}],onSubmit:async()=>t(!1),submitLabel:"Done"})}function jn(e){switch(e){case"healthkit_daily_active_energy":return"HealthKit daily active energy";case"workout_movement_fallback":return"workout + movement fallback";case"target_inference_only":return"plan target inference";default:return e||"unknown source"}}function kn(e){const t=e.energyModel,n=t.sourceAvailability,r=[n.healthKitDailyEnergy?"HealthKit active energy":null,t.formulaRestingKcal!=null?"formula resting baseline":null,t.wearableRestingKcal!=null?"complete-day HealthKit resting evidence":null,n.workoutEnergy?"workout energy":null,n.movementTripCalories?"movement-trip calories":null].filter(Boolean);return r.length>0?r.join(", "):"no measured expenditure streams"}function Nn(e){const t=e.energyModel,n=t.recentFoodLogDayCount>0?`${t.recentFoodLogCount} recent food log${t.recentFoodLogCount===1?"":"s"} across ${t.recentFoodLogDayCount} logged day${t.recentFoodLogDayCount===1?"":"s"}`:"no recent logged food days";if(t.estimatedTdeeKcal==null)return`No TDEE estimate yet. Average logged intake is ${i(t.averageCalorieIntake)} kcal/day from ${n}.`;const r=`Recent average balance: intake ${i(t.averageCalorieIntake)} - TDEE ${i(t.estimatedTdeeKcal)} = ${H(t.estimatedDailyEnergyBalanceKcal)} kcal/day.`,s=t.restingEnergyCalories!=null&&t.activeBurnKcal!=null?`TDEE = formula resting baseline ${i(t.restingEnergyCalories)} + active burn ${i(t.activeBurnKcal)}.`:`TDEE is falling back to the configured plan estimate ${i(t.inferredTdee)}.`,d=t.energySourceConfidence==="healthkit_daily_active_energy"?`Active burn uses HealthKit daily active energy ${i(t.activeBurnKcal)}; workout and movement are evidence only.`:t.energySourceConfidence==="workout_movement_fallback"?`Active burn fallback = workout ${i(t.workoutEnergyKcal)} + movement ${i(t.movementCaloriesKcal)} = ${i(t.activeBurnKcal)}, so movement is not added again.`:"Active burn is not measured yet.";return`${r} ${s} ${d} Food window: ${n}. Negative means estimated deficit; this is not today's remaining calories.`}function wn(e){const t=e.energyModel,n=t.restingEnergyCalories!=null&&t.activeBurnKcal!=null,r=e.todayLedger.dateKey,s=t.recentFoodLogDayCount>0?`${t.recentFoodLogCount} recent food log${t.recentFoodLogCount===1?"":"s"} across ${t.recentFoodLogDayCount} distinct logged day${t.recentFoodLogDayCount===1?"":"s"}`:"no recent logged food days",d=t.energySourceConfidence==="healthkit_daily_active_energy"?`active burn = HealthKit daily active energy average = ${i(t.activeBurnKcal)} kcal/day`:t.energySourceConfidence==="workout_movement_fallback"?`active burn = workout average ${i(t.workoutEnergyKcal)} + movement-trip average ${i(t.movementCaloriesKcal)} = ${i(t.activeBurnKcal)} kcal/day`:"active burn is not measured; Forge falls back to plan inference",g=t.restingEnergyCalories!=null&&t.activeBurnKcal!=null?`TDEE = formula resting baseline ${i(t.restingEnergyCalories)} + active burn average ${i(t.activeBurnKcal)} = ${i(t.estimatedTdeeKcal)} kcal/day.`:`TDEE = ${i(t.estimatedTdeeKcal)} kcal/day from the configured plan because complete resting + active energy is not available.`,l=t.estimatedTdeeKcal!=null?`Energy gap = average logged intake - TDEE = ${i(t.averageCalorieIntake)} - ${i(t.estimatedTdeeKcal)} = ${H(t.estimatedDailyEnergyBalanceKcal)} kcal/day.`:"Energy gap cannot be computed until Forge has either measured expenditure or an inferred TDEE.",o=t.energySourceConfidence==="healthkit_daily_active_energy"?`selected active burn = HealthKit daily active energy average = ${i(t.activeBurnKcal)} kcal/day. Workout and movement are visible as evidence but are not added.`:t.energySourceConfidence==="workout_movement_fallback"?`selected active burn = workout average ${i(t.workoutEnergyKcal)} + movement-trip average ${i(t.movementCaloriesKcal)} = ${i(t.activeBurnKcal)} kcal/day. This is why movement can appear next to active burn: it is a component of active burn here, not a separate add-on.`:"selected active burn is unavailable, so TDEE falls back to the configured plan estimate.",u=t.restingEnergyCalories!=null&&t.activeBurnKcal!=null&&t.estimatedTdeeKcal!=null?t.energySourceConfidence==="healthkit_daily_active_energy"?`Arithmetic shown here: active burn ${i(t.activeBurnKcal)} = HealthKit daily active energy average; TDEE ${i(t.estimatedTdeeKcal)} = formula resting baseline ${i(t.restingEnergyCalories)} + active burn ${i(t.activeBurnKcal)}; energy gap ${H(t.estimatedDailyEnergyBalanceKcal)} = intake ${i(t.averageCalorieIntake)} - TDEE ${i(t.estimatedTdeeKcal)}.`:t.energySourceConfidence==="workout_movement_fallback"?`Arithmetic shown here: active burn ${i(t.activeBurnKcal)} = workout ${i(t.workoutEnergyKcal)} + movement ${i(t.movementCaloriesKcal)}; TDEE ${i(t.estimatedTdeeKcal)} = formula resting baseline ${i(t.restingEnergyCalories)} + active burn ${i(t.activeBurnKcal)}; energy gap ${H(t.estimatedDailyEnergyBalanceKcal)} = intake ${i(t.averageCalorieIntake)} - TDEE ${i(t.estimatedTdeeKcal)}.`:`Arithmetic shown here: TDEE ${i(t.estimatedTdeeKcal)} = formula resting baseline ${i(t.restingEnergyCalories)} + active burn ${i(t.activeBurnKcal)}; energy gap ${H(t.estimatedDailyEnergyBalanceKcal)} = intake ${i(t.averageCalorieIntake)} - TDEE ${i(t.estimatedTdeeKcal)}.`:"Arithmetic shown here uses the available expenditure branch; some terms are unavailable because Forge does not yet have both resting and active energy evidence.",C=t.recentFoodLogDayCount>0?`Average intake = total calories in the latest ${t.recentFoodLogCount} non-discarded food log${t.recentFoodLogCount===1?"":"s"} / ${t.recentFoodLogDayCount} logged day${t.recentFoodLogDayCount===1?"":"s"}. It does not divide by silent calendar days.`:"Average logged intake is 0 because there are no recent food logs in the current window.",A=t.energySourceConfidence==="healthkit_daily_active_energy"?"Active burn is using HealthKit daily active energy first. Workout and movement values remain visible as evidence, but movement is not added again on top of HealthKit active energy.":t.energySourceConfidence==="workout_movement_fallback"?"HealthKit daily active energy is missing, so active burn falls back to workout energy plus movement-trip calories.":"No measured active-burn stream is available, so this is driven by the plan target and should be treated as low-confidence.",f=`Today is separate: today's target = baseline plan target plus the day-specific active adjustment. Today active evidence currently uses ${Aa(t.todayActiveCaloriesSource)}: ${i(t.todayActiveCaloriesKcal)} kcal. Default active calories: ${i(t.baselineActiveCaloriesKcal)} kcal. Eat-back fraction ${i(t.activityEatBackFraction*100,0)}%; target adjustment ${H(t.todayTargetAdjustmentKcal)} kcal. Automatic low or early same-day activity cannot reduce the target; a manual override can raise or lower it for this date.`,b=t.energySourceConfidence==="healthkit_daily_active_energy"?"Data path: recent food logs provide intake; HealthKit daily active-energy rows provide active burn; Mifflin-St Jeor provides the stable resting baseline. Complete HealthKit basal rows are shown as calibration evidence.":t.energySourceConfidence==="workout_movement_fallback"?"Data path: recent food logs provide intake; Mifflin-St Jeor provides the stable resting baseline; workout-session energy plus movement-trip calories provide fallback active burn.":"Data path: recent food logs provide intake; expenditure is using the configured plan inference because measured expenditure streams are incomplete.";return a.jsxs("span",{className:"grid gap-2",children:[a.jsxs("span",{children:[a.jsx("span",{className:"font-semibold text-[var(--ui-ink-strong)]",children:"What this card means:"})," ","this is a historical energy-balance estimate, not the remaining food budget for today. Negative means estimated deficit; positive means estimated surplus."]}),a.jsxs("span",{children:[a.jsx("span",{className:"font-semibold text-[var(--ui-ink-strong)]",children:"Formula:"})," ",l]}),a.jsxs("span",{children:[a.jsx("span",{className:"font-semibold text-[var(--ui-ink-strong)]",children:"TDEE:"})," ","TDEE means total daily energy expenditure: the estimated calories burned per day. Forge uses"," ",n?"the formula resting baseline plus the selected active-burn branch":"the configured/inferred plan estimate because formula resting plus active expenditure is incomplete",". Objective deficit or surplus is not subtracted here; that belongs to the intake target."]}),a.jsxs("span",{children:[a.jsx("span",{className:"font-semibold text-[var(--ui-ink-strong)]",children:"Selected branch:"})," ",t.energySourceConfidence==="healthkit_daily_active_energy"?"HealthKit daily active energy exists, so active burn uses that value. Workout, movement, and step values are shown only as evidence.":t.energySourceConfidence==="workout_movement_fallback"?"HealthKit daily active energy is missing, so active burn uses workout calories plus movement-trip calories.":"Measured expenditure is incomplete, so TDEE falls back to the configured plan estimate."]}),a.jsxs("span",{children:[a.jsx("span",{className:"font-semibold text-[var(--ui-ink-strong)]",children:"Active-burn branch:"})," ",o]}),a.jsxs("span",{children:[a.jsx("span",{className:"font-semibold text-[var(--ui-ink-strong)]",children:"Arithmetic:"})," ",u]}),a.jsxs("span",{children:[a.jsx("span",{className:"font-semibold text-[var(--ui-ink-strong)]",children:"Why these numbers:"})," ","The displayed movement value is therefore"," ",t.energySourceConfidence==="workout_movement_fallback"?"part of the active-burn calculation":"supporting evidence only",", and it is not the same thing as today's editable active-calorie budget."]}),a.jsxs("span",{children:[a.jsx("span",{className:"font-semibold text-[var(--ui-ink-strong)]",children:"Current data:"})," ","intake ",i(t.averageCalorieIntake)," kcal/day; TDEE"," ",i(t.estimatedTdeeKcal)," kcal/day; formula resting"," ",i(t.restingEnergyCalories)," kcal/day; active burn"," ",i(t.activeBurnKcal)," kcal/day; workout"," ",i(t.workoutEnergyKcal)," kcal/day; movement"," ",i(t.movementCaloriesKcal)," kcal/day."," ",t.energySourceConfidence==="workout_movement_fallback"?"On this branch, active burn already equals workout plus movement, so movement is not an extra add-on after active burn.":"On this branch, movement is shown as evidence and is not added on top of active burn."]}),a.jsxs("span",{children:[a.jsx("span",{className:"font-semibold text-[var(--ui-ink-strong)]",children:"Data lineage:"})," ",b]}),a.jsxs("span",{children:[a.jsx("span",{className:"font-semibold text-[var(--ui-ink-strong)]",children:"Food window:"})," ",C," Current denominator: ",s,"."]}),a.jsxs("span",{children:[a.jsx("span",{className:"font-semibold text-[var(--ui-ink-strong)]",children:"Expenditure:"})," ",g," ",d,". TDEE means total daily energy expenditure, the estimated calories burned per day before applying the weight-loss or weight-gain objective."]}),a.jsxs("span",{children:[a.jsx("span",{className:"font-semibold text-[var(--ui-ink-strong)]",children:"TDEE source:"})," ",n?"formula resting baseline plus selected active-burn branch":"plan-inference branch because Forge does not yet have both resting and active expenditure streams",". TDEE is an expenditure estimate; the goal deficit or surplus is applied when planning intake targets, not when calculating historical TDEE."]}),a.jsxs("span",{children:[a.jsx("span",{className:"font-semibold text-[var(--ui-ink-strong)]",children:"Calculation path:"})," ","Forge first tries HealthKit daily active energy for active burn. If that is missing, it uses workout energy plus movement-trip calories. TDEE is resting energy plus whichever active-burn branch was selected. The objective deficit or surplus is not part of this historical TDEE."]}),a.jsxs("span",{children:[a.jsx("span",{className:"font-semibold text-[var(--ui-ink-strong)]",children:"Source:"})," ",jn(t.energySourceConfidence)," across"," ",t.evidenceDays," expenditure evidence day",t.evidenceDays===1?"":"s"," ending the selected day (",r,"). Available streams: ",kn(e),"."," ",A]}),a.jsxs("span",{children:[a.jsx("span",{className:"font-semibold text-[var(--ui-ink-strong)]",children:"Movement:"})," ","movement kcal is a component of fallback active burn. If HealthKit daily active energy exists, Forge shows movement as supporting evidence but does not add it again. If HealthKit active energy is missing, fallback active burn is workout average + movement average; the displayed active burn number already includes that movement component."]}),a.jsxs("span",{children:[a.jsx("span",{className:"font-semibold text-[var(--ui-ink-strong)]",children:"Today:"})," ",f]})]})}function Cn(e){const t=H(e);return t==="n/a"?t:`${t} kcal/d`}function Aa(e){switch(e){case"today_workout_energy":return"today's workout energy";case"today_healthkit_active_energy":return"today's HealthKit active energy";case"today_workout_movement_energy":return"today's workout and movement energy";case"today_workout_movement_step_energy":return"today's workout, movement, and step energy";case"today_workout_step_energy":return"today's workout and step energy";case"today_movement_step_energy":return"today's movement and step energy";case"today_movement_trip_calories":return"today's movement trip calories";case"today_step_estimate":return"today's estimated step calories";case"user_override":return"your manual active-calorie override";default:return"the default daily active calories"}}function la(e){return`${e>=0?"+":""}${e.toFixed(0)} kcal`}function Mn(e){return e>=0?`${e.toFixed(0)} kcal left`:`${Math.abs(e).toFixed(0)} kcal over`}function ca(e){return e.trim()===""?"0":e}function da(e,t,n){const r=e.energyModel.baselineActiveCaloriesKcal??e.energyModel.todayActiveCaloriesKcal??0,s=e.energyModel.activityEatBackFraction??0,d=t-r,g=Math.round(d*s),l=e.energyModel.todayTargetAdjustmentKcal??0,o=e.todayLedger.plannedTargetCalories??e.todayLedger.targetCalories-l,u=Math.max(0,Math.round(o+g)),C=Math.round(e.todayLedger.totals.calories-u),A=Math.round(u-e.todayLedger.totals.calories),f=Math.max(0,d),b=Math.round(f*s);return{...e,summary:{...e.summary,targetCalories:u,todayCalorieDelta:C,remainingCalories:A},todayLedger:{...e.todayLedger,plannedTargetCalories:o,targetCalories:u,activeAdjustmentCalories:g,activeCaloriesSource:"user_override",calorieDelta:C,remainingCalories:A},energyModel:{...e.energyModel,todayActiveCaloriesKcal:t,todayActiveCaloriesSource:"user_override",todayTargetAdjustmentKcal:g,todayActiveDeltaKcal:Math.round(d),todayActiveSurplusKcal:Math.round(f),todayActivityBufferKcal:b,todayActiveOverride:n}}}function Fn(e){const[t,n,r]=e.split("-").map(Number),s=new Date(t,n-1,r),d=new Date(t,n-1,r+1);return{dayStartAt:s.toISOString(),dayEndAt:d.toISOString()}}function Kn(){const e=new Date,t=new Date(e);return t.setHours(24,0,2,0),Math.max(1e3,t.getTime()-e.getTime())}function Wn(){const e=rt(),t=at(),n=e.selectedUserIds,[r,s]=K.useState(()=>We()),d=K.useMemo(()=>Fn(r),[r]),g=K.useMemo(()=>["forge-weight-loss-view",r,...n],[r,n]),[l,o]=K.useState(!1),[u,C]=K.useState(!1),[A,f]=K.useState(!1),[b,p]=K.useState(!1),[y,k]=K.useState(!1),[$,T]=K.useState(null),[P,W]=K.useState(null),[q,R]=K.useState(""),[te,Y]=K.useState(null),[X,O]=K.useState(null),[ce,ne]=K.useState("search"),[de,ee]=K.useState(void 0),[re,J]=K.useState(()=>je()),[pe,x]=K.useState(()=>oa()),v=tt({queryKey:g,queryFn:async()=>(await bt(n,{dateKey:r,...d})).weightLoss}),N=v.data;K.useEffect(()=>{const c=()=>{s(S=>{const ue=We();return ue===S?S:ue})},m=window.setTimeout(c,Kn());return window.addEventListener("focus",c),document.addEventListener("visibilitychange",c),()=>{window.clearTimeout(m),window.removeEventListener("focus",c),document.removeEventListener("visibilitychange",c)}},[r]),K.useEffect(()=>{!N||u||l||Qt(N)||(C(!0),Y(Le(N)),T(`Forge needs the missing profile fields before the calorie and macro plan can be trusted.
|
|
3
3
|
|
|
4
4
|
- Confirm age, height, current weight, objective, weekly rate, and active calories.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as a,aC as j,r as w}from"./vendor-Cpmju3nw.js";import{c as u,a_ as N,c8 as $}from"./index-
|
|
1
|
+
import{j as a,aC as j,r as w}from"./vendor-Cpmju3nw.js";import{c as u,a_ as N,c8 as $}from"./index-BaiwtAgo.js";function k(i){const e=[];let n,r;for(const s of i){const t=s.trim();if(!t)continue;const o=t.indexOf(":");if(o<=0){e.push({label:"Note",value:t});continue}const c=t.slice(0,o).trim(),p=t.slice(o+1).trim();if(!p)continue;const m=c.toLowerCase();if(m==="title"){n=p;continue}if(m==="summary"){r=p;continue}e.push({label:c,value:p})}return{title:n,summary:r,rows:e}}function C(i){const e=[],n=/(!?\[\[([^\]]+)\]\]|\[([^\]]+)\]\(([^)]+)\)|`([^`]+)`|\*\*([^*]+)\*\*|\*([^*]+)\*)/g;let r=0,s=null;for(;(s=n.exec(i))!==null;){if(s.index>r&&e.push({type:"text",value:i.slice(r,s.index)}),s[1]&&s[2]){const t=s[2].trim(),o=s[1].startsWith("!"),c=t.indexOf("|"),p=c>=0?t.slice(0,c).trim():t,m=c>=0?t.slice(c+1).trim():p;if(p.toLowerCase().startsWith("forge:")){const[,g,...l]=p.split(":");e.push({type:"forge-link",entityType:g??"",entityId:l.join(":").trim(),label:m})}else e.push({type:"wiki-link",target:p,label:m,embed:o})}else s[3]&&s[4]?e.push({type:"link",label:s[3],href:s[4].trim()}):s[5]?e.push({type:"code",value:s[5]}):s[6]?e.push({type:"strong",value:s[6]}):s[7]&&e.push({type:"em",value:s[7]});r=n.lastIndex}return r<i.length&&e.push({type:"text",value:i.slice(r)}),e}function L(i){const e=i.replace(/\r/g,"").split(`
|
|
2
2
|
`),n=[],r=[];let s=null,t=0;for(;t<e.length;){const o=e[t]??"",c=o.trim();if(!c){t+=1;continue}if(c.startsWith("```")){const l=[];for(t+=1;t<e.length&&!(e[t]??"").trim().startsWith("```");)l.push(e[t]??""),t+=1;t+=1,n.push({type:"code",code:l.join(`
|
|
3
3
|
`)});continue}const p=c.match(/^:::([a-z0-9-]+)\s*$/i);if(p){const l=p[1].toLowerCase(),d=[];for(t+=1;t<e.length&&(e[t]??"").trim()!==":::";)d.push(e[t]??""),t+=1;t<e.length&&(t+=1);const y=[`:::${l}`,...d,":::"].join(`
|
|
4
4
|
`);r.push({kind:l,lines:d,raw:y}),l==="forge-infobox"?s=k(d):l==="note"||l==="tip"||l==="warning"||l==="danger"?n.push({type:"admonition",kind:l,lines:d}):(l==="forge-links"||l==="forge-media"||l==="forge-related")&&n.push({type:l,lines:d});continue}const m=o.match(/^(#{1,6})\s+(.*)$/);if(m){n.push({type:"heading",level:m[1].length,text:m[2].trim()}),t+=1;continue}if(/^>\s?/.test(o)){const l=[];for(;t<e.length&&/^>\s?/.test(e[t]??"");)l.push((e[t]??"").replace(/^>\s?/,"")),t+=1;n.push({type:"quote",text:l.join(" ").trim()});continue}if(/^[-*+]\s+/.test(o)||/^\d+\.\s+/.test(o)){const l=/^\d+\.\s+/.test(o),d=[];for(;t<e.length&&(/^[-*+]\s+/.test(e[t]??"")||/^\d+\.\s+/.test(e[t]??""));)d.push((e[t]??"").replace(/^[-*+]\s+/,"").replace(/^\d+\.\s+/,"").trim()),t+=1;n.push({type:"list",ordered:l,items:d});continue}const g=[];for(;t<e.length;){const l=e[t]??"",d=l.trim();if(!d||d.startsWith("```")||d.startsWith(":::")||/^#{1,6}\s+/.test(l)||/^>\s?/.test(l)||/^[-*+]\s+/.test(l)||/^\d+\.\s+/.test(l))break;g.push(d),t+=1}if(g.length>0){n.push({type:"paragraph",text:g.join(" ")});continue}t+=1}return{blocks:n,infobox:s,directives:r}}const x="text-[var(--ui-ink-medium)]",W="text-[var(--ui-ink-soft)]",f="text-[var(--ui-ink-faint)]",I="text-[var(--ui-ink-strong)]",b="border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]",T="border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]",q="rounded-sm bg-[var(--ui-surface-2)] px-1.5 py-0.5 text-[var(--ui-ink-strong)] no-underline ring-1 ring-[var(--ui-border-subtle)] transition hover:bg-[var(--ui-surface-hover)]";function M(i,e,n){return i.map((r,s)=>{const t=`${e}-${s}`;switch(r.type){case"text":return a.jsx(w.Fragment,{children:r.value},t);case"code":return a.jsx("code",{className:"rounded bg-[var(--ui-surface-2)] px-1.5 py-0.5 font-mono text-[0.92em] text-[var(--ui-ink-strong)] ring-1 ring-[var(--ui-border-subtle)]",children:r.value},t);case"strong":return a.jsx("strong",{className:"font-semibold text-[var(--ui-ink-strong)]",children:r.value},t);case"em":return a.jsx("em",{className:"italic text-[var(--ui-ink-medium)]",children:r.value},t);case"link":{const o=/^https?:\/\//i.test(r.href);return a.jsx("a",{href:r.href,target:o?"_blank":void 0,rel:o?"noreferrer":void 0,className:"text-[var(--secondary)] underline decoration-current/30 underline-offset-2 transition hover:text-[var(--ui-ink-strong)]",children:r.label},t)}case"forge-link":{const o=N(r.entityType,r.entityId),c=o?$(o):null;return c?a.jsx("a",{href:c,className:q,children:r.label},t):a.jsx("span",{className:"rounded-sm bg-[var(--ui-surface-2)] px-1.5 py-0.5 text-[var(--ui-ink-soft)] ring-1 ring-[var(--ui-border-subtle)]",children:r.label},t)}case"wiki-link":return a.jsx(j,{to:{pathname:`/wiki/page/${encodeURIComponent(r.target)}`,search:n?`?spaceId=${encodeURIComponent(n)}`:""},className:u("underline decoration-current/30 underline-offset-2 transition hover:text-[var(--ui-ink-strong)]",r.embed?"text-[var(--primary)]":"text-[var(--secondary)]"),children:r.label},t)}})}function h(i,e,n){return M(C(i),e,n)}function _(i,e){const n=i.map(r=>r.trim()).filter(Boolean);return n.length===0?null:a.jsx("ul",{className:u("space-y-1.5 pl-4 text-[13px] leading-6",x),children:n.map((r,s)=>a.jsx("li",{children:h(r,`directive-${s}`,e)},`${r}-${s}`))})}function v(i,e,n){switch(i.type){case"heading":{const r=i.level===1?"text-[1.9rem] leading-[1.08]":i.level===2?"text-[1.25rem] leading-[1.2]":i.level===3?"text-[1.05rem] leading-[1.3]":"text-[0.92rem] leading-[1.35]";return a.jsx("h2",{className:u("font-semibold tracking-[-0.02em]",I,e>0&&"mt-6",r),children:h(i.text,`heading-${e}`,n)},`heading-${e}`)}case"paragraph":return a.jsx("p",{className:u("text-[14px] leading-7",x),children:h(i.text,`paragraph-${e}`,n)},`paragraph-${e}`);case"quote":return a.jsx("blockquote",{className:u("border-l-[3px] border-[var(--ui-border-strong)] pl-4 text-[14px] leading-7",W),children:h(i.text,`quote-${e}`,n)},`quote-${e}`);case"list":{const r=i.ordered?"ol":"ul";return a.jsx(r,{className:u("space-y-1.5 pl-5 text-[14px] leading-7",x,i.ordered?"list-decimal":"list-disc"),children:i.items.map((s,t)=>a.jsx("li",{children:h(s,`list-${e}-${t}`,n)},`item-${e}-${t}`))},`list-${e}`)}case"code":return a.jsx("pre",{className:"max-w-full overflow-x-auto rounded-xl border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-code)] px-4 py-3 text-[12px] leading-6 text-[var(--ui-ink-strong)]",children:a.jsx("code",{children:i.code})},`code-${e}`);case"admonition":return a.jsxs("aside",{className:u("rounded-xl border px-4 py-3",i.kind==="warning"||i.kind==="danger"?"border-[color-mix(in_srgb,var(--warning)_32%,transparent)] bg-[var(--ui-warning-soft)]":T),children:[a.jsx("div",{className:u("mb-2 text-[11px] font-semibold uppercase tracking-[0.16em]",f),children:i.kind}),a.jsx("div",{className:u("grid gap-2 text-[13px] leading-6",x),children:i.lines.map((r,s)=>a.jsx("p",{children:h(r,`admonition-${e}-${s}`,n)},`admonition-line-${s}`))})]},`admonition-${e}`);case"forge-links":case"forge-media":case"forge-related":return a.jsxs("section",{className:u("rounded-xl border px-4 py-3",b),children:[a.jsx("div",{className:u("mb-2 text-[11px] font-semibold uppercase tracking-[0.16em]",f),children:i.type.replace("forge-","")}),_(i.lines,n)]},`${i.type}-${e}`)}}function P(i,e,n){return a.jsx("div",{className:u("text-[13px] leading-6",x),children:h(i,e,n)})}function R({infobox:i,spaceId:e,className:n}){return a.jsxs("aside",{className:u("wiki-infobox rounded-2xl border p-4",b,n),children:[i.title?a.jsx("div",{className:"text-[1rem] font-semibold leading-tight text-[var(--ui-ink-strong)]",children:i.title}):null,i.summary?a.jsx("p",{className:"mt-2 text-[13px] leading-6 text-[var(--ui-ink-soft)]",children:h(i.summary,"infobox-summary",e)}):null,a.jsx("dl",{className:"mt-3 grid gap-2",children:i.rows.map((r,s)=>a.jsxs("div",{className:"grid gap-1 border-t border-[var(--ui-border-subtle)] pt-2 first:border-t-0 first:pt-0",children:[a.jsx("dt",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:r.label}),a.jsx("dd",{children:P(r.value,`infobox-row-${s}`,e)})]},`${r.label}-${s}`))})]})}function z(i){const e=[],n=[];let r=!1;for(const s of i)!r&&s.type==="heading"&&s.level<=2&&e.length>0&&(r=!0),r?n.push(s):e.push(s);return{intro:e.length>0?e:i.slice(0,1),rest:e.length>0?n:i.slice(1)}}function A({markdown:i,spaceId:e,className:n}){const r=L(i),{intro:s,rest:t}=z(r.blocks);return a.jsxs("div",{className:u("grid gap-4",n),children:[a.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1fr)_19rem] xl:items-start",children:[a.jsx("div",{className:"grid gap-4",children:s.map((o,c)=>v(o,c,e))}),r.infobox?a.jsx(R,{infobox:r.infobox,spaceId:e,className:"order-2 xl:order-none"}):null]}),t.length>0?a.jsx("div",{className:"grid gap-4",children:t.map((o,c)=>v(o,c+s.length,e))}):null]})}export{A as W};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{aJ as Be,b6 as Qe,c6 as De,bY as Ke,r as d,j as e,cr as Ve,cs as qe,cL as He,cm as Ue,c5 as Je,aU as Ye,aR as Ge,ca as Xe,dH as Ze,dI as ea,aK as we,bG as aa}from"./vendor-Cpmju3nw.js";import{R as ye,P as Ne,O as Ce,C as Se,T as Ie,D as Te,a as $e}from"./ui-B9O-eUim.js";import{j as sa,i as Y,k as ta}from"./state-BtwEvpO6.js";import{E as F}from"./entity-link-multiselect-
|
|
1
|
+
import{aJ as Be,b6 as Qe,c6 as De,bY as Ke,r as d,j as e,cr as Ve,cs as qe,cL as He,cm as Ue,c5 as Je,aU as Ye,aR as Ge,ca as Xe,dH as Ze,dI as ea,aK as we,bG as aa}from"./vendor-Cpmju3nw.js";import{R as ye,P as Ne,O as Ce,C as Se,T as Ie,D as Te,a as $e}from"./ui-B9O-eUim.js";import{j as sa,i as Y,k as ta}from"./state-BtwEvpO6.js";import{E as F}from"./entity-link-multiselect-Bb4De_e3.js";import{d as ra,k as g,g as P,L as ia,e as na,h as la,B as C,c as j,I as T,T as E,a4 as ve,ey as oa,cl as da,bn as ca,ez as ua,eA as pa}from"./index-BaiwtAgo.js";import{W as xa}from"./wiki-article-markdown-DxTkiQRy.js";import"./use-anchored-overlay-position-BrQ4cqKn.js";import"./motion-DwjmC9aq.js";import"./board-CLOHbg6t.js";import"./forms-C5d5hTf2.js";const _="rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] shadow-[var(--ui-shadow-card)]",x="text-[11px] font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",ma="w-full rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3.5 py-3 text-[13px] text-[var(--ui-ink-strong)] outline-none transition focus:border-[color-mix(in_srgb,var(--primary)_40%,transparent)]",b="border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",fe="min-w-0 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3 text-left transition hover:bg-[var(--ui-surface-hover)]";function M(t,r){return`${t}:${r}`}function ha(t){const r=t.indexOf(":");return r<=0||r>=t.length-1?null:{entityType:t.slice(0,r),entityId:t.slice(r+1)}}function Le(t){return t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function $(t){return Array.from(new Set(t.split(",").map(r=>r.trim()).filter(Boolean)))}function ga(t){if(!t.trim())return{};try{const r=JSON.parse(t);return r&&typeof r=="object"&&!Array.isArray(r)?r:{}}catch{return{}}}function Me(){return{pageId:null,kind:"wiki",title:"",slug:"",parentSlug:"index",indexOrder:0,showInIndex:!0,summary:"",aliasesText:"",contentMarkdown:`# Untitled
|
|
2
2
|
|
|
3
3
|
`,author:"",tagsText:"",frontmatterText:`{
|
|
4
4
|
"status": "draft"
|