forge-openclaw-plugin 0.3.13 → 0.3.15
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/README.md +2 -2
- package/dist/assets/{action-bar-BFjWjRIM.js → action-bar-B9MYlps2.js} +1 -1
- package/dist/assets/{activity-page-D-6yBWuZ.js → activity-page-DbzbChcE.js} +1 -1
- package/dist/assets/{ai-surface-workspace-BEfo9bRO.js → ai-surface-workspace-CF0257Hs.js} +1 -1
- package/dist/assets/{atlas-panel-BfMyJXxQ.js → atlas-panel-CO3RYAKn.js} +1 -1
- package/dist/assets/{calendar-page-D4tQNJ2V.js → calendar-page-BuuHKEHC.js} +1 -1
- package/dist/assets/{calendar-rules-C-6O_uGU.js → calendar-rules-DKftgNx5.js} +1 -1
- package/dist/assets/{calendar-week-toolbar-_NzeKsYx.js → calendar-week-toolbar-ChIpkT-G.js} +1 -1
- package/dist/assets/{companion-sync-lab-page-D1Oqsf6M.js → companion-sync-lab-page-BZRX4Btw.js} +1 -1
- package/dist/assets/{daily-metrics-dashboard-DtE3pVOl.js → daily-metrics-dashboard-CXDsaAQd.js} +1 -1
- package/dist/assets/{define-workbench-box-D-32C8nM.js → define-workbench-box-CpG0Zb1L.js} +1 -1
- package/dist/assets/{entity-link-multiselect-DcCvkesQ.js → entity-link-multiselect-Dl4rZqdg.js} +1 -1
- package/dist/assets/{entity-note-count-link-Cjsk5oT2.js → entity-note-count-link-Bs1aKYyD.js} +1 -1
- package/dist/assets/{entity-notes-surface-DQQPLjxd.js → entity-notes-surface-B56XSw7M.js} +1 -1
- package/dist/assets/{execution-board-agWQbN-y.js → execution-board-D66C_ikW.js} +1 -1
- package/dist/assets/{faceted-token-search-DldM3-ru.js → faceted-token-search-Dg2rjknH.js} +1 -1
- package/dist/assets/{flagship-signal-deck-BlLYW9Kz.js → flagship-signal-deck-C6KVPhmM.js} +1 -1
- package/dist/assets/{floating-action-menu-D9-psbha.js → floating-action-menu-DAFAEBcA.js} +1 -1
- package/dist/assets/{generic-node-view-CcepUVhP.js → generic-node-view-C6DK5hJ6.js} +1 -1
- package/dist/assets/{goal-detail-page-DP1n5-Hk.js → goal-detail-page-CC4VXud6.js} +1 -1
- package/dist/assets/{goal-dialog-Oxx8WqbZ.js → goal-dialog-15hD8EBp.js} +1 -1
- package/dist/assets/{goals-page-CUt1a4Y2.js → goals-page-CQ2lJMzI.js} +1 -1
- package/dist/assets/{habits-page-5REbWAlo.js → habits-page-a7KVPaQp.js} +1 -1
- package/dist/assets/{health-boxes-sHNML3tm.js → health-boxes-DqgvIYoL.js} +1 -1
- package/dist/assets/index-ClJbJhca.css +1 -0
- package/dist/assets/index-FpGANF9S.js +2 -0
- package/dist/assets/{inline-note-fields-Bql_KfR9.js → inline-note-fields-COgzxr_7.js} +1 -1
- package/dist/assets/{insight-flow-dialog-CN-CMSB7.js → insight-flow-dialog-Dmb6NSGp.js} +1 -1
- package/dist/assets/{insights-page-B1u6ONtQ.js → insights-page-OnqR4cYI.js} +1 -1
- package/dist/assets/{kanban-boxes-DB1kuUlY.js → kanban-boxes-BWUzntCV.js} +1 -1
- package/dist/assets/{kanban-page-BBW9_vMu.js → kanban-page-BI16Gzp_.js} +1 -1
- package/dist/assets/{knowledge-graph-page-CoJaydZb.js → knowledge-graph-page-DxEBaEke.js} +1 -1
- package/dist/assets/{life-force-page-DBYbA1GF.js → life-force-page-CDEXEQai.js} +1 -1
- package/dist/assets/{life-force-workspace-BiD9xOEt.js → life-force-workspace-C7UOnJEf.js} +1 -1
- package/dist/assets/{metric-tile-CuP9DOYm.js → metric-tile-boeHB1R1.js} +1 -1
- package/dist/assets/{movement-boxes-DZg_qPPg.js → movement-boxes-BUSqaTL2.js} +1 -1
- package/dist/assets/{movement-page-CmwsQGR_.js → movement-page-DcbO0497.js} +1 -1
- package/dist/assets/note-markdown-DXXI3W3V.js +3 -0
- package/dist/assets/{note-tags-input-C_x5WdK5.js → note-tags-input-CYh3TVW2.js} +1 -1
- package/dist/assets/{notes-boxes-BEFlp9yd.js → notes-boxes-CMJXX2K0.js} +1 -1
- package/dist/assets/{notes-page-B6Vl-GPf.js → notes-page-DvHMcQey.js} +1 -1
- package/dist/assets/{open-in-graph-button-C-bJekoH.js → open-in-graph-button-4UYrp1XP.js} +1 -1
- package/dist/assets/{orbit-map-DHeTM15g.js → orbit-map-BwK7sDaC.js} +1 -1
- package/dist/assets/{overview-page-BRWje1F9.js → overview-page-Z5vaUTm3.js} +1 -1
- package/dist/assets/{page-hero-8bITsx_x.js → page-hero-DvrM83_C.js} +1 -1
- package/dist/assets/{pill-cluster-XQjm-wPc.js → pill-cluster-DYI3Ibj8.js} +1 -1
- package/dist/assets/{preference-entity-handoff-button-DwYF_5i3.js → preference-entity-handoff-button-C2ATjvws.js} +1 -1
- package/dist/assets/{preferences-page-C7DBPpNb.js → preferences-page-BAexXHye.js} +1 -1
- package/dist/assets/{project-collections-mtxanSMf.js → project-collections-B9nr-Ts-.js} +1 -1
- package/dist/assets/{project-detail-page-BT87Goqc.js → project-detail-page-B9PqyPu9.js} +1 -1
- package/dist/assets/{project-dialog-DnZe757y.js → project-dialog-CBA-D65n.js} +1 -1
- package/dist/assets/{project-management-hierarchy-page-B3R2lNFI.js → project-management-hierarchy-page-DXK14jn0.js} +1 -1
- package/dist/assets/{project-management-section-nav-DyBWxHbe.js → project-management-section-nav-DJ3QKCtr.js} +1 -1
- package/dist/assets/{projects-boxes-CxZj3P29.js → projects-boxes-iBu_PRqe.js} +1 -1
- package/dist/assets/{projects-page-Bec11c0x.js → projects-page-CdAk-ByT.js} +1 -1
- package/dist/assets/{psyche-behaviors-page-DWRpYvl1.js → psyche-behaviors-page-CbhhTfU2.js} +1 -1
- package/dist/assets/{psyche-flashcards-page-CX4rcsXZ.js → psyche-flashcards-page-DQaw_vUQ.js} +1 -1
- package/dist/assets/{psyche-goal-map-page-Y6b3lCvV.js → psyche-goal-map-page-C-ZTVOEP.js} +1 -1
- package/dist/assets/{psyche-graph-CQuCWKIp.js → psyche-graph-DYzeClxn.js} +1 -1
- package/dist/assets/{psyche-metrics-page-DadDJOnm.js → psyche-metrics-page-C9hKn10A.js} +1 -1
- package/dist/assets/{psyche-mode-guide-page-B1nz0uCg.js → psyche-mode-guide-page-CR8e984W.js} +1 -1
- package/dist/assets/{psyche-modes-page-i3uSuhKA.js → psyche-modes-page-lQdpAcY3.js} +1 -1
- package/dist/assets/{psyche-page-Y_s-BE2m.js → psyche-page-CTdIDkw9.js} +1 -1
- package/dist/assets/{psyche-patterns-page-DaaOLIlN.js → psyche-patterns-page-Drgm-f7I.js} +1 -1
- package/dist/assets/{psyche-questionnaire-builder-page-CuF7rXOv.js → psyche-questionnaire-builder-page-gRwdGXde.js} +1 -1
- package/dist/assets/{psyche-questionnaire-detail-page-BfFEMkRY.js → psyche-questionnaire-detail-page-CIP9b2UI.js} +1 -1
- package/dist/assets/{psyche-questionnaire-run-detail-page-BoQTvd7Q.js → psyche-questionnaire-run-detail-page-SYndwtF3.js} +1 -1
- package/dist/assets/{psyche-questionnaire-run-page-C0qKiNZN.js → psyche-questionnaire-run-page-CXiJyd5i.js} +1 -1
- package/dist/assets/{psyche-questionnaires-page-B6hfD448.js → psyche-questionnaires-page-CFPKwA3O.js} +1 -1
- package/dist/assets/{psyche-report-detail-page-BlFL8moM.js → psyche-report-detail-page-dU30a2WE.js} +1 -1
- package/dist/assets/{psyche-reports-page-DAAcYENp.js → psyche-reports-page-Cn0EBndy.js} +1 -1
- package/dist/assets/{psyche-schemas-beliefs-page-CsxKSrKM.js → psyche-schemas-beliefs-page-Bab4xSWv.js} +1 -1
- package/dist/assets/{psyche-screen-time-page-n4b0e58x.js → psyche-screen-time-page-lIe6GQxJ.js} +1 -1
- package/dist/assets/{psyche-self-observation-page-BaxEQ2-3.js → psyche-self-observation-page-BTE3KfIl.js} +1 -1
- package/dist/assets/{psyche-values-page-DTv5NMSU.js → psyche-values-page-DclBZ9xw.js} +1 -1
- package/dist/assets/question-flow-dialog-Ded2E85L.js +2 -0
- package/dist/assets/{report-chain-fields-D132-EMh.js → report-chain-fields-DY640iqL.js} +1 -1
- package/dist/assets/{rewards-page-C533lVP-.js → rewards-page-FxUXB76B.js} +1 -1
- package/dist/assets/{scheduling-rules-editor-CDpontGp.js → scheduling-rules-editor-jakFfxqF.js} +1 -1
- package/dist/assets/{schema-badge-B3DiMnjB.js → schema-badge-30B5syHA.js} +1 -1
- package/dist/assets/{schemas-CH1_ngUX.js → schemas-Db29G8NU.js} +1 -1
- package/dist/assets/{select-menu-BOF-k4Ln.js → select-menu-BF2zI3RW.js} +1 -1
- package/dist/assets/{settings-agents-page-B5OQtlZX.js → settings-agents-page-Bh-Bv6FQ.js} +1 -1
- package/dist/assets/{settings-bin-page-D_bk3Kcu.js → settings-bin-page-DT8JJero.js} +1 -1
- package/dist/assets/{settings-calendar-page-PuSj9_kM.js → settings-calendar-page-BA4_Qqiu.js} +3 -3
- package/dist/assets/{settings-data-page-EwFMaeq6.js → settings-data-page-K4kpmQJY.js} +1 -1
- package/dist/assets/{settings-logs-page-BKkse0DX.js → settings-logs-page-DkuNPAZo.js} +1 -1
- package/dist/assets/{settings-mobile-page-BrIVmdeB.js → settings-mobile-page-4pCNwD91.js} +1 -1
- package/dist/assets/{settings-models-page-Mg84D_0K.js → settings-models-page-CZHG3t7W.js} +1 -1
- package/dist/assets/{settings-page-D-kul92f.js → settings-page-B_Be0vOY.js} +1 -1
- package/dist/assets/{settings-rewards-page-waNyCcX_.js → settings-rewards-page-C6nFTWJu.js} +1 -1
- package/dist/assets/{settings-section-nav-BmJWnrYk.js → settings-section-nav-Lo-VKCfZ.js} +1 -1
- package/dist/assets/{settings-users-page-DBgC6y56.js → settings-users-page-CVzNp4-m.js} +1 -1
- package/dist/assets/{settings-wiki-page-CM0te9dI.js → settings-wiki-page-DXM--7BB.js} +1 -1
- package/dist/assets/sleep-page-DvPdZMKx.js +1 -0
- package/dist/assets/{sports-page-eg5Rfc_E.js → sports-page-DjuZlOur.js} +1 -1
- package/dist/assets/{strategies-page-D4AqvFNW.js → strategies-page-PE1IlatS.js} +1 -1
- package/dist/assets/{strategy-detail-page-BlYVkXaW.js → strategy-detail-page-C4KiEGCI.js} +1 -1
- package/dist/assets/{strategy-dialog-FO9Oa0dB.js → strategy-dialog-Cwf7Y3P5.js} +1 -1
- package/dist/assets/surface-ubuOfukq.js +1 -0
- package/dist/assets/{task-detail-page-Dy-aRyY6.js → task-detail-page-B3SMFZQ3.js} +1 -1
- package/dist/assets/{task-dialog-DrA9pba7.js → task-dialog-CI_Fy_FW.js} +1 -1
- package/dist/assets/{timebox-planning-dialog-C_gnfxFx.js → timebox-planning-dialog-BtFuVoA1.js} +1 -1
- package/dist/assets/{today-boxes-BFOws_iC.js → today-boxes-CYuxSkZf.js} +1 -1
- package/dist/assets/{today-page-BoPj6a6q.js → today-page-CHGpLEZ3.js} +1 -1
- package/dist/assets/{training-load-page-DGU40Zfl.js → training-load-page-GZJF-Yy5.js} +1 -1
- package/dist/assets/{user-badge-CZWtYeMw.js → user-badge-ByhC6bMU.js} +1 -1
- package/dist/assets/{utility-widgets-B3wWGxQc.js → utility-widgets-ilORjDmg.js} +1 -1
- package/dist/assets/{vitals-page-BXRZEP_8.js → vitals-page-mdEqIm_9.js} +1 -1
- package/dist/assets/{weekly-review-page-D5cebA5x.js → weekly-review-page-C8W-yg5r.js} +1 -1
- package/dist/assets/weight-loss-page-BApTknCn.js +5 -0
- package/dist/assets/{wiki-article-markdown-CvaCjg_t.js → wiki-article-markdown-DBccllQg.js} +1 -1
- package/dist/assets/{wiki-editor-page-Dco79SLY.js → wiki-editor-page-BfRfH1O3.js} +2 -2
- package/dist/assets/{wiki-ingest-history-page-uvKRkRDF.js → wiki-ingest-history-page-C-6H3MU6.js} +1 -1
- package/dist/assets/{wiki-ingest-modal-BW6AJPea.js → wiki-ingest-modal-DnlhByD_.js} +1 -1
- package/dist/assets/{wiki-page-BIL5zMqv.js → wiki-page-DPZ55e3x.js} +1 -1
- package/dist/assets/{workbench-flow-page-Dx_nq8R_.js → workbench-flow-page-_-NKIx5R.js} +1 -1
- package/dist/assets/{workbench-page-BJnt_Zzf.js → workbench-page-NIAzggwX.js} +1 -1
- package/dist/assets/{workout-detail-page-CKgqyB-y.js → workout-detail-page-3fxr6HL4.js} +1 -1
- package/dist/index.html +6 -6
- package/dist/openclaw/index.d.ts +2 -7
- package/dist/server/server/src/app.js +16 -7
- package/dist/server/server/src/health-weight-loss.js +321 -14
- package/dist/server/server/src/managers/platform/openai-responses-provider.js +2 -2
- package/dist/server/server/src/openapi.js +30 -3
- package/dist/server/server/src/repositories/ai-connectors.js +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +6 -4
- package/server/index.js +6 -1
- package/skills/forge-openclaw/SKILL.md +76 -8
- package/skills/forge-openclaw/entity_conversation_playbooks.md +167 -5
- package/skills/forge-openclaw/psyche_entity_playbooks.md +84 -0
- package/dist/assets/favicon-B6oXI6k4.ico +0 -0
- package/dist/assets/favicon-Bai4rhyS.png +0 -0
- package/dist/assets/favicon-ERg17ZCd.svg +0 -3
- package/dist/assets/index-CQ5r7ZUz.js +0 -2
- package/dist/assets/index-FxgNSuZX.css +0 -1
- package/dist/assets/note-markdown-B82ncnFt.js +0 -3
- package/dist/assets/question-flow-dialog-CskCt5NZ.js +0 -2
- package/dist/assets/sleep-page-C_krRE59.js +0 -1
- package/dist/assets/surface-MVeeZGKB.js +0 -1
- package/dist/assets/weight-loss-page-BuUdFh9z.js +0 -5
- package/skills/forge-openclaw/SKILL.md.bak-20260415 +0 -552
- package/skills/forge-openclaw/entity_conversation_playbooks.md.bak-20260415 +0 -1303
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as W,j as l}from"./vendor-BwL6m4SE.js";import{H as P,P as w}from"./graph-BF4IsheG.js";import{a4 as j,c as S}from"./index-
|
|
1
|
+
import{r as W,j as l}from"./vendor-BwL6m4SE.js";import{H as P,P as w}from"./graph-BF4IsheG.js";import{a4 as j,c as S}from"./index-FpGANF9S.js";function u(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function E(...e){for(const r of e)if(typeof r=="string")return r;return""}function O(...e){for(const r of e){if(typeof r=="number"&&Number.isFinite(r))return r;if(typeof r=="string"){const t=Number(r);if(Number.isFinite(t))return t}}return null}function A(...e){for(const r of e){if(Array.isArray(r)){const t=r.filter(a=>typeof a=="string"&&a.trim().length>0);if(t.length>0)return t;continue}if(typeof r=="string"){const t=r.trim();if(!t)continue;try{const a=JSON.parse(t);if(Array.isArray(a)){const i=a.filter(s=>typeof s=="string"&&s.trim().length>0);if(i.length>0)return i}}catch{const a=t.split(",").map(i=>i.trim()).filter(i=>i.length>0);if(a.length>0)return a}}}return[]}function _(e,r,t){const a={};return(t.length>0?t:[{key:"summary"}]).forEach((s,o)=>{const n=r&&s.key in r?r[s.key]:o===0||s.key==="summary"?e:null;a[s.key]={text:typeof n=="string"?n:Array.isArray(n)||u(n)?JSON.stringify(n,null,2):String(n??""),json:u(n)}}),a}function $(e,r,t){var s;const a=e.output??[];if(!r&&a.length===0)return null;const i=r?{...r}:{};if(a.length>0){const o=(s=a[0])==null?void 0:s.key;o&&!(o in i)&&(i[o]=t),a.some(n=>n.key==="summary")&&!("summary"in i)&&(i.summary=t)}return i}function d(e,r){const t=$(e.definition,r.output,r.primaryText);return{primaryText:r.primaryText,payload:t,logs:r.logs??[],outputMap:_(r.primaryText,t,e.definition.output)}}function G(e,r,t,a){return d(e,{primaryText:t??`${e.definition.title}
|
|
2
2
|
${e.definition.description}
|
|
3
3
|
Route: ${e.definition.routePath??"n/a"}`,output:r,logs:a})}function C(e,r,t){const a=Math.max(1,Math.min(50,Math.round(t.limit??12))),i=e.services.entities.search({searches:[{query:t.query,entityTypes:t.entityTypes,limit:a}]}).results[0],s=i!=null&&i.ok?i.matches??[]:[],o=s.slice(0,a).map(n=>{const c=typeof n.title=="string"?n.title:typeof n.name=="string"?n.name:typeof n.id=="string"?n.id:"Untitled";return`${typeof n.entityType=="string"?n.entityType:"entity"}: ${c}`});return{title:r.title,matches:s,summaryText:o.length>0?o.join(`
|
|
4
4
|
`):`No ${r.title.toLowerCase()} matches found.`,limit:a,query:t.query}}function J(e,r){const t=E(e.inputs.query,e.params.query,r.query).trim(),a=A(e.inputs.entityTypes,e.params.entityTypes,r.entityTypes),i=O(e.inputs.limit,e.params.limit,r.limit)??r.limit??12,s=C(e.context,e.definition,{query:t,entityTypes:a,limit:i});return d(e,{primaryText:s.summaryText,output:{summary:s.summaryText,matches:s.matches,matchCount:s.matches.length}})}function X(e){var t,a;const r=((a=(t=e.context.services.movement).listPlaces)==null?void 0:a.call(t))??[];return d(e,{primaryText:r.length>0?r.slice(0,24).map(i=>typeof i.label=="string"?i.label:typeof i.name=="string"?i.name:typeof i.id=="string"?i.id:"Place").join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c6 as F,b6 as q,r as l,j as e,aC as p}from"./vendor-BwL6m4SE.js";import{j as A,k as H}from"./state-Bpe5dF3T.js";import{GoalDialog as L}from"./goal-dialog-Oxx8WqbZ.js";import{O as Q}from"./open-in-graph-button-C-bJekoH.js";import{N as z}from"./note-markdown-B82ncnFt.js";import{ProjectDialog as K}from"./project-dialog-DnZe757y.js";import{E as $}from"./entity-notes-surface-DQQPLjxd.js";import{P as _}from"./preference-entity-handoff-button-DwYF_5i3.js";import{b as X,f as J,P as V}from"./project-collections-mtxanSMf.js";import{P as W}from"./page-hero-8bITsx_x.js";import{u as Y,d as Z,h as ee,E as T,B as x,C as j,b as k,k as u,P as te,i as ae,Q as se}from"./index-CQ5r7ZUz.js";import{U as C}from"./user-badge-CZWtYeMw.js";import{g as ie,a as ne}from"./activity-copy-Bj4h9OcF.js";import{g as oe}from"./entity-links-DwpxhW2H.js";import{g as le}from"./user-ownership-DJGl4rAj.js";import"./question-flow-dialog-CskCt5NZ.js";import"./ui-B9TWEtCx.js";import"./motion-DcgUnXhY.js";import"./inline-note-fields-Bql_KfR9.js";import"./user-select-field-fx129Uh6.js";import"./schemas-CH1_ngUX.js";import"./forms-D1qJ3oOP.js";import"./note-tags-input-C_x5WdK5.js";import"./entity-link-multiselect-DcCvkesQ.js";import"./use-anchored-overlay-position-BY4kNzPj.js";import"./board-CuxQRKPJ.js";function Ee(){const{t:a}=Y(),i=Z(),d=F(),G=q(),f=A(),[O,N]=l.useState(!1),[S,y]=l.useState(!1),[m,B]=l.useState("active"),v=le(i.selectedUserIds),[E,b]=l.useState(null),D=H({mutationFn:()=>se(d.goalId),onSuccess:async()=>{await Promise.all([ae(f),f.invalidateQueries({queryKey:["project-board"]}),f.invalidateQueries({queryKey:["task-context"]})]),G("/goals")}}),s=i.snapshot.dashboard.goals.find(t=>t.id===d.goalId)??null,g=l.useMemo(()=>i.snapshot.dashboard.projects.filter(t=>t.goalId===d.goalId),[d.goalId,i.snapshot.dashboard.projects]),R=l.useMemo(()=>X(g),[g]),o=l.useMemo(()=>J(g,m),[g,m]),w=new Set(g.map(t=>t.id)),I=new Set(i.snapshot.tasks.filter(t=>w.has(t.projectId??"")).map(t=>t.id)),h=i.snapshot.activity.filter(t=>t.entityId===d.goalId||w.has(t.entityId)||I.has(t.entityId)||t.entityType==="task_run"&&typeof t.metadata.taskId=="string"&&I.has(t.metadata.taskId));if(!s)return e.jsx(ee,{eyebrow:a("common.goalDetail.eyebrow"),title:a("common.goalDetail.missingTitle"),description:a("common.goalDetail.missingDescription"),action:e.jsx(p,{to:"/goals",className:"inline-flex min-h-10 min-w-0 max-w-full items-center justify-center whitespace-nowrap rounded-full bg-[var(--primary)] px-4 py-2 text-sm font-medium text-[var(--ui-ink-on-accent)] transition hover:opacity-90",children:a("common.goalDetail.backToGoals")})});const n=o.find(t=>t.nextTaskTitle)??o[0]??null,r=i.snapshot.overview.neglectedGoals.find(t=>t.goalId===s.id)??null,c=h[0]??null,M=async t=>{b(t);try{await i.patchProject(t,{status:"active"})}finally{b(null)}},U=async()=>{window.confirm(a("common.goalDetail.deleteGoalConfirm",{title:s.title}))&&await D.mutateAsync()};return e.jsxs("div",{className:"grid min-w-0 gap-5",children:[e.jsx(W,{entityKind:"goal",title:e.jsx(T,{kind:"goal",label:s.title,variant:"heading",size:"lg"}),titleText:s.title,description:s.description?e.jsx(z,{markdown:s.description,className:"[&>p]:text-[13px] [&>p]:leading-6 [&>blockquote]:text-[13px] [&>ul]:text-[13px] [&>ol]:text-[13px]"}):"No strategic description yet.",badge:a(o.length===1?"common.goalDetail.heroBadgeOne":"common.goalDetail.heroBadgeOther",{count:o.length}),actions:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(_,{userId:v,domain:"projects",entityType:"goal",entityId:s.id,label:s.title,description:s.description}),e.jsx(Q,{entityType:"goal",entityId:s.id})]})}),s.user?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx("span",{className:"text-[var(--ui-ink-faint)]",children:"Owned by"}),e.jsx(C,{user:s.user})]}):null,e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx(x,{onClick:()=>N(!0),children:a("common.goalDetail.edit")}),e.jsx(x,{variant:"secondary",onClick:()=>y(!0),children:a("common.goalDetail.addProject")}),e.jsx(x,{variant:"ghost",className:"text-[var(--danger)] hover:bg-[var(--ui-danger-soft)]",pending:D.isPending,pendingLabel:a("common.goalDetail.deleting"),onClick:()=>void U(),children:a("common.goalDetail.deleteGoal")})]}),e.jsxs("section",{className:"grid min-w-0 gap-5 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)]",children:[e.jsxs(j,{children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:a("common.goalDetail.sectionProjects")}),e.jsx(V,{value:m,counts:R,onChange:B,className:"justify-end"})]}),o.length===0?e.jsx("div",{className:"mt-4 rounded-[20px] bg-[var(--ui-surface-2)] p-4 text-sm text-[var(--ui-ink-soft)]",children:m==="active"?a("common.goalDetail.noProjects"):"No projects match this lifecycle filter yet. Switch filters or restart one to make it active again."}):e.jsx("div",{className:"mt-4 grid gap-4 lg:grid-cols-2",children:o.map(t=>e.jsxs("div",{className:"rounded-[22px] bg-[var(--ui-surface-2)] p-5 transition hover:bg-[var(--ui-surface-2)]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(k,{kind:"project",compact:!0,gradient:!1}),t.user?e.jsx(C,{user:t.user,compact:!0}):null]}),e.jsx(u,{children:t.status})]}),e.jsx("div",{className:"mt-4",children:e.jsx(p,{to:`/projects/${t.id}`,className:"transition hover:opacity-90",children:e.jsx(T,{kind:"project",label:t.title,variant:"heading",size:"lg"})})}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:t.description}),e.jsx("div",{className:"mt-4",children:e.jsx(te,{value:t.progress})}),e.jsx("div",{className:"mt-4 text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:t.nextTaskTitle?a("common.goalDetail.nextMove",{value:t.nextTaskTitle}):a("common.goalDetail.addNextTask")}),e.jsxs("div",{className:"mt-4 flex flex-wrap justify-between gap-3",children:[e.jsx(p,{to:`/projects/${t.id}`,children:e.jsx(x,{variant:"ghost",children:"Open project"})}),m!=="active"&&t.status!=="active"?e.jsx(x,{variant:"secondary",size:"sm",pending:E===t.id,pendingLabel:"Restarting…",onClick:()=>void M(t.id),children:"Restart"}):null]})]},t.id))})]}),e.jsx("div",{className:"grid min-w-0 gap-5",children:e.jsxs(j,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:a("common.goalDetail.sectionHealth")}),e.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:[e.jsx(k,{kind:"goal",compact:!0,gradient:!1}),e.jsx(u,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:a("common.goalDetail.progressTitle",{progress:s.progress,count:s.completedTasks})}),e.jsx(u,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:a("common.goalDetail.progressDetail",{xp:s.earnedPoints})}),e.jsx(u,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:a(o.length===1?"common.goalDetail.heroBadgeOne":"common.goalDetail.heroBadgeOther",{count:o.length})})]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:a("common.goalDetail.fieldProgress")}),e.jsxs("div",{className:"mt-2 font-display text-xl text-[var(--ui-ink-strong)]",children:[s.progress,"%"]})]}),e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:a("common.goalDetail.fieldCompletedTasks")}),e.jsx("div",{className:"mt-2 font-display text-xl text-[var(--ui-ink-strong)]",children:s.completedTasks})]}),e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:a("common.goalDetail.fieldXpBanked")}),e.jsx("div",{className:"mt-2 font-display text-xl text-[var(--ui-ink-strong)]",children:s.earnedPoints})]})]}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:a("common.goalDetail.signalNext")}),n?e.jsx(k,{kind:"project",compact:!0,gradient:!1}):null]}),e.jsx("div",{className:"mt-2 font-medium text-[var(--ui-ink-strong)]",children:(n==null?void 0:n.title)??a("common.goalDetail.noProject")}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:n!=null&&n.nextTaskTitle?a("common.goalDetail.nextMove",{value:n.nextTaskTitle}):(n==null?void 0:n.description)||a("common.goalDetail.noProjectDetail")})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:a("common.goalDetail.signalRisk")}),e.jsx("div",{className:"mt-2 font-medium text-[var(--ui-ink-strong)]",children:(r==null?void 0:r.title)??a("common.goalDetail.noRisk")}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:(r==null?void 0:r.summary)||a("common.goalDetail.noRiskDetail")})]}),e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:a("common.goalDetail.signalEvidence")}),e.jsx("div",{className:"mt-2 font-medium text-[var(--ui-ink-strong)]",children:(c==null?void 0:c.title)??a("common.goalDetail.noEvidence")}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:(c==null?void 0:c.description)||a("common.goalDetail.noEvidenceDetail")})]})]})]})]})})]}),e.jsx($,{entityType:"goal",entityId:s.id,title:"Goal notes",description:"Use notes to capture strategy changes, meaning shifts, and progress context that belongs at the goal level."}),e.jsxs(j,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:a("common.goalDetail.sectionEvidence")}),h.length===0?e.jsx("div",{className:"mt-4 rounded-[20px] bg-[var(--ui-surface-2)] p-4 text-sm text-[var(--ui-ink-soft)]",children:a("common.goalDetail.noEvidenceLogged")}):e.jsx("div",{className:"mt-4 grid gap-3 lg:grid-cols-2",children:h.slice(0,6).map(t=>e.jsxs(p,{to:oe(t)??`/activity?eventId=${t.id}`,className:"rounded-[18px] bg-[var(--ui-surface-2)] p-4 transition hover:bg-[var(--ui-surface-2)]",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:ie(t)}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:ne(t)})]},t.id))})]}),e.jsx(L,{open:O,editingGoal:s,tags:i.snapshot.tags,users:i.snapshot.users,defaultUserId:s.userId??v,onOpenChange:N,onSubmit:async(t,P)=>{P&&await i.patchGoal(P,t)}}),e.jsx(K,{open:S,goals:i.snapshot.goals,users:i.snapshot.users,editingProject:null,initialGoalId:s.id,defaultUserId:s.userId??v,onOpenChange:y,onSubmit:async t=>{await i.createProject(t)}})]})}export{Ee as GoalDetailPage};
|
|
1
|
+
import{c6 as F,b6 as q,r as l,j as e,aC as p}from"./vendor-BwL6m4SE.js";import{j as A,k as H}from"./state-Bpe5dF3T.js";import{GoalDialog as L}from"./goal-dialog-15hD8EBp.js";import{O as Q}from"./open-in-graph-button-4UYrp1XP.js";import{N as z}from"./note-markdown-DXXI3W3V.js";import{ProjectDialog as K}from"./project-dialog-CBA-D65n.js";import{E as $}from"./entity-notes-surface-B56XSw7M.js";import{P as _}from"./preference-entity-handoff-button-C2ATjvws.js";import{b as X,f as J,P as V}from"./project-collections-B9nr-Ts-.js";import{P as W}from"./page-hero-DvrM83_C.js";import{u as Y,d as Z,h as ee,E as T,B as x,C as j,b as k,k as u,P as te,i as ae,Q as se}from"./index-FpGANF9S.js";import{U as C}from"./user-badge-ByhC6bMU.js";import{g as ie,a as ne}from"./activity-copy-Bj4h9OcF.js";import{g as oe}from"./entity-links-DwpxhW2H.js";import{g as le}from"./user-ownership-DJGl4rAj.js";import"./question-flow-dialog-Ded2E85L.js";import"./ui-B9TWEtCx.js";import"./motion-DcgUnXhY.js";import"./inline-note-fields-COgzxr_7.js";import"./user-select-field-fx129Uh6.js";import"./schemas-Db29G8NU.js";import"./forms-D1qJ3oOP.js";import"./note-tags-input-CYh3TVW2.js";import"./entity-link-multiselect-Dl4rZqdg.js";import"./use-anchored-overlay-position-BY4kNzPj.js";import"./board-CuxQRKPJ.js";function Ee(){const{t:a}=Y(),i=Z(),d=F(),G=q(),f=A(),[O,N]=l.useState(!1),[S,y]=l.useState(!1),[m,B]=l.useState("active"),v=le(i.selectedUserIds),[E,b]=l.useState(null),D=H({mutationFn:()=>se(d.goalId),onSuccess:async()=>{await Promise.all([ae(f),f.invalidateQueries({queryKey:["project-board"]}),f.invalidateQueries({queryKey:["task-context"]})]),G("/goals")}}),s=i.snapshot.dashboard.goals.find(t=>t.id===d.goalId)??null,g=l.useMemo(()=>i.snapshot.dashboard.projects.filter(t=>t.goalId===d.goalId),[d.goalId,i.snapshot.dashboard.projects]),R=l.useMemo(()=>X(g),[g]),o=l.useMemo(()=>J(g,m),[g,m]),w=new Set(g.map(t=>t.id)),I=new Set(i.snapshot.tasks.filter(t=>w.has(t.projectId??"")).map(t=>t.id)),h=i.snapshot.activity.filter(t=>t.entityId===d.goalId||w.has(t.entityId)||I.has(t.entityId)||t.entityType==="task_run"&&typeof t.metadata.taskId=="string"&&I.has(t.metadata.taskId));if(!s)return e.jsx(ee,{eyebrow:a("common.goalDetail.eyebrow"),title:a("common.goalDetail.missingTitle"),description:a("common.goalDetail.missingDescription"),action:e.jsx(p,{to:"/goals",className:"inline-flex min-h-10 min-w-0 max-w-full items-center justify-center whitespace-nowrap rounded-full bg-[var(--primary)] px-4 py-2 text-sm font-medium text-[var(--ui-ink-on-accent)] transition hover:opacity-90",children:a("common.goalDetail.backToGoals")})});const n=o.find(t=>t.nextTaskTitle)??o[0]??null,r=i.snapshot.overview.neglectedGoals.find(t=>t.goalId===s.id)??null,c=h[0]??null,M=async t=>{b(t);try{await i.patchProject(t,{status:"active"})}finally{b(null)}},U=async()=>{window.confirm(a("common.goalDetail.deleteGoalConfirm",{title:s.title}))&&await D.mutateAsync()};return e.jsxs("div",{className:"grid min-w-0 gap-5",children:[e.jsx(W,{entityKind:"goal",title:e.jsx(T,{kind:"goal",label:s.title,variant:"heading",size:"lg"}),titleText:s.title,description:s.description?e.jsx(z,{markdown:s.description,className:"[&>p]:text-[13px] [&>p]:leading-6 [&>blockquote]:text-[13px] [&>ul]:text-[13px] [&>ol]:text-[13px]"}):"No strategic description yet.",badge:a(o.length===1?"common.goalDetail.heroBadgeOne":"common.goalDetail.heroBadgeOther",{count:o.length}),actions:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(_,{userId:v,domain:"projects",entityType:"goal",entityId:s.id,label:s.title,description:s.description}),e.jsx(Q,{entityType:"goal",entityId:s.id})]})}),s.user?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx("span",{className:"text-[var(--ui-ink-faint)]",children:"Owned by"}),e.jsx(C,{user:s.user})]}):null,e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx(x,{onClick:()=>N(!0),children:a("common.goalDetail.edit")}),e.jsx(x,{variant:"secondary",onClick:()=>y(!0),children:a("common.goalDetail.addProject")}),e.jsx(x,{variant:"ghost",className:"text-[var(--danger)] hover:bg-[var(--ui-danger-soft)]",pending:D.isPending,pendingLabel:a("common.goalDetail.deleting"),onClick:()=>void U(),children:a("common.goalDetail.deleteGoal")})]}),e.jsxs("section",{className:"grid min-w-0 gap-5 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)]",children:[e.jsxs(j,{children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:a("common.goalDetail.sectionProjects")}),e.jsx(V,{value:m,counts:R,onChange:B,className:"justify-end"})]}),o.length===0?e.jsx("div",{className:"mt-4 rounded-[20px] bg-[var(--ui-surface-2)] p-4 text-sm text-[var(--ui-ink-soft)]",children:m==="active"?a("common.goalDetail.noProjects"):"No projects match this lifecycle filter yet. Switch filters or restart one to make it active again."}):e.jsx("div",{className:"mt-4 grid gap-4 lg:grid-cols-2",children:o.map(t=>e.jsxs("div",{className:"rounded-[22px] bg-[var(--ui-surface-2)] p-5 transition hover:bg-[var(--ui-surface-2)]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(k,{kind:"project",compact:!0,gradient:!1}),t.user?e.jsx(C,{user:t.user,compact:!0}):null]}),e.jsx(u,{children:t.status})]}),e.jsx("div",{className:"mt-4",children:e.jsx(p,{to:`/projects/${t.id}`,className:"transition hover:opacity-90",children:e.jsx(T,{kind:"project",label:t.title,variant:"heading",size:"lg"})})}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:t.description}),e.jsx("div",{className:"mt-4",children:e.jsx(te,{value:t.progress})}),e.jsx("div",{className:"mt-4 text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:t.nextTaskTitle?a("common.goalDetail.nextMove",{value:t.nextTaskTitle}):a("common.goalDetail.addNextTask")}),e.jsxs("div",{className:"mt-4 flex flex-wrap justify-between gap-3",children:[e.jsx(p,{to:`/projects/${t.id}`,children:e.jsx(x,{variant:"ghost",children:"Open project"})}),m!=="active"&&t.status!=="active"?e.jsx(x,{variant:"secondary",size:"sm",pending:E===t.id,pendingLabel:"Restarting…",onClick:()=>void M(t.id),children:"Restart"}):null]})]},t.id))})]}),e.jsx("div",{className:"grid min-w-0 gap-5",children:e.jsxs(j,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:a("common.goalDetail.sectionHealth")}),e.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:[e.jsx(k,{kind:"goal",compact:!0,gradient:!1}),e.jsx(u,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:a("common.goalDetail.progressTitle",{progress:s.progress,count:s.completedTasks})}),e.jsx(u,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:a("common.goalDetail.progressDetail",{xp:s.earnedPoints})}),e.jsx(u,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:a(o.length===1?"common.goalDetail.heroBadgeOne":"common.goalDetail.heroBadgeOther",{count:o.length})})]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:a("common.goalDetail.fieldProgress")}),e.jsxs("div",{className:"mt-2 font-display text-xl text-[var(--ui-ink-strong)]",children:[s.progress,"%"]})]}),e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:a("common.goalDetail.fieldCompletedTasks")}),e.jsx("div",{className:"mt-2 font-display text-xl text-[var(--ui-ink-strong)]",children:s.completedTasks})]}),e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:a("common.goalDetail.fieldXpBanked")}),e.jsx("div",{className:"mt-2 font-display text-xl text-[var(--ui-ink-strong)]",children:s.earnedPoints})]})]}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:a("common.goalDetail.signalNext")}),n?e.jsx(k,{kind:"project",compact:!0,gradient:!1}):null]}),e.jsx("div",{className:"mt-2 font-medium text-[var(--ui-ink-strong)]",children:(n==null?void 0:n.title)??a("common.goalDetail.noProject")}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:n!=null&&n.nextTaskTitle?a("common.goalDetail.nextMove",{value:n.nextTaskTitle}):(n==null?void 0:n.description)||a("common.goalDetail.noProjectDetail")})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:a("common.goalDetail.signalRisk")}),e.jsx("div",{className:"mt-2 font-medium text-[var(--ui-ink-strong)]",children:(r==null?void 0:r.title)??a("common.goalDetail.noRisk")}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:(r==null?void 0:r.summary)||a("common.goalDetail.noRiskDetail")})]}),e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:a("common.goalDetail.signalEvidence")}),e.jsx("div",{className:"mt-2 font-medium text-[var(--ui-ink-strong)]",children:(c==null?void 0:c.title)??a("common.goalDetail.noEvidence")}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:(c==null?void 0:c.description)||a("common.goalDetail.noEvidenceDetail")})]})]})]})]})})]}),e.jsx($,{entityType:"goal",entityId:s.id,title:"Goal notes",description:"Use notes to capture strategy changes, meaning shifts, and progress context that belongs at the goal level."}),e.jsxs(j,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:a("common.goalDetail.sectionEvidence")}),h.length===0?e.jsx("div",{className:"mt-4 rounded-[20px] bg-[var(--ui-surface-2)] p-4 text-sm text-[var(--ui-ink-soft)]",children:a("common.goalDetail.noEvidenceLogged")}):e.jsx("div",{className:"mt-4 grid gap-3 lg:grid-cols-2",children:h.slice(0,6).map(t=>e.jsxs(p,{to:oe(t)??`/activity?eventId=${t.id}`,className:"rounded-[18px] bg-[var(--ui-surface-2)] p-4 transition hover:bg-[var(--ui-surface-2)]",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:ie(t)}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:ne(t)})]},t.id))})]}),e.jsx(L,{open:O,editingGoal:s,tags:i.snapshot.tags,users:i.snapshot.users,defaultUserId:s.userId??v,onOpenChange:N,onSubmit:async(t,P)=>{P&&await i.patchGoal(P,t)}}),e.jsx(K,{open:S,goals:i.snapshot.goals,users:i.snapshot.users,editingProject:null,initialGoalId:s.id,defaultUserId:s.userId??v,onOpenChange:y,onSubmit:async t=>{await i.createProject(t)}})]})}export{Ee as GoalDetailPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,j as t}from"./vendor-BwL6m4SE.js";import{Q as T,F as i,a as j}from"./question-flow-dialog-
|
|
1
|
+
import{r as c,j as t}from"./vendor-BwL6m4SE.js";import{Q as T,F as i,a as j}from"./question-flow-dialog-Ded2E85L.js";import{I as N}from"./inline-note-fields-COgzxr_7.js";import{u as P,I as h,T as L}from"./index-FpGANF9S.js";import{U as D}from"./user-select-field-fx129Uh6.js";import{g as A}from"./schemas-Db29G8NU.js";import{a as H}from"./user-ownership-DJGl4rAj.js";import"./ui-B9TWEtCx.js";import"./motion-DcgUnXhY.js";import"./state-Bpe5dF3T.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";const p={title:"",description:"",horizon:"year",status:"active",userId:null,targetPoints:400,themeColor:"#c8a46b",tagIds:[],notes:[]};function K(a){return{title:a.title,description:a.description,horizon:a.horizon,status:a.status,userId:a.userId??null,targetPoints:a.targetPoints,themeColor:a.themeColor,tagIds:a.tagIds,notes:[]}}function Z({open:a,pending:y=!1,editingGoal:n,tags:w,users:C,defaultUserId:d=null,onOpenChange:b,onSubmit:I}){const{t:r}=P(),f=C??[],S=f.find(o=>o.id===d)??null,[x,m]=c.useState(p),[F,l]=c.useState(null),[u,g]=c.useState({}),E=o=>{g(Object.fromEntries(Object.entries(o).map(([s,e])=>[s,e==null?void 0:e[0]])))};c.useEffect(()=>{a&&(l(null),g({}),m(n?K(n):{...p,userId:d}))},[d,n,a]);const z=[{id:"intent",eyebrow:"Direction",title:"Name the arc and why it matters",description:"Start with the long-horizon direction itself. We can refine cadence, tags, and visual tone after the intent is clear.",render:(o,s)=>t.jsxs(t.Fragment,{children:[t.jsx(i,{label:r("common.dialogs.goal.title"),error:u.title??null,children:t.jsx(h,{value:o.title,onChange:e=>s({title:e.target.value}),placeholder:"Build a durable body and calm energy"})}),t.jsx(i,{label:r("common.dialogs.goal.descriptionLabel"),children:t.jsx(L,{value:o.description,onChange:e=>s({description:e.target.value}),placeholder:"Write the goal description in Markdown. This can stay short or grow into a long strategic page."})}),t.jsx(D,{value:o.userId,users:f,onChange:e=>s({userId:e}),label:"Owner user",defaultLabel:H(S),help:"Goals can belong to a human or bot user. The current single-user scope becomes the default when one user is selected."})]})},{id:"cadence",eyebrow:"Cadence",title:"Choose the horizon and current posture",description:"Keep this simple: how long does this arc run, and is it currently active, paused, or already complete?",render:(o,s)=>t.jsxs(t.Fragment,{children:[t.jsx(i,{label:r("common.dialogs.goal.horizon"),children:t.jsx(j,{value:o.horizon,onChange:e=>s({horizon:e}),options:[{value:"quarter",label:r("common.enums.goalHorizon.quarter"),description:"Tight strategic push for the coming months."},{value:"year",label:r("common.enums.goalHorizon.year"),description:"A full-cycle objective for this year."},{value:"lifetime",label:r("common.enums.goalHorizon.lifetime"),description:"A long-running life arc that projects can keep serving."}],columns:3})}),t.jsx(i,{label:r("common.dialogs.goal.status"),children:t.jsx(j,{value:o.status,onChange:e=>s({status:e}),options:[{value:"active",label:r("common.enums.projectStatus.active"),description:"This is live right now."},{value:"paused",label:r("common.enums.projectStatus.paused"),description:"Keep it visible, but do not push it right now."},{value:"completed",label:r("common.enums.projectStatus.completed"),description:"You have already fulfilled this arc."}]})})]})},{id:"signal",eyebrow:"Signal",title:"Set the target and visual signature",description:"Give Forge enough signal to show progress and make this arc recognizable throughout the app.",render:(o,s)=>t.jsxs(t.Fragment,{children:[t.jsx(i,{label:r("common.dialogs.goal.targetXp"),error:u.targetPoints??null,children:t.jsx(h,{type:"number",value:o.targetPoints,onChange:e=>s({targetPoints:Number(e.target.value)||0})})}),t.jsx(i,{label:r("common.dialogs.goal.themeColor"),error:u.themeColor??null,children:t.jsxs("div",{className:"flex items-center gap-3 rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3",children:[t.jsx("input",{className:"h-10 w-12 rounded-lg border border-[var(--ui-border-subtle)] bg-transparent",type:"color",value:o.themeColor,onChange:e=>s({themeColor:e.target.value})}),t.jsx(h,{className:"border-none bg-transparent px-0 py-0",value:o.themeColor,onChange:e=>s({themeColor:e.target.value})})]})}),t.jsx(i,{label:r("common.dialogs.goal.tags"),children:t.jsx("div",{className:"flex flex-wrap gap-2",children:w.map(e=>{const v=o.tagIds.includes(e.id);return t.jsx("button",{type:"button",className:`rounded-full px-3 py-2 text-sm transition ${v?"bg-[var(--ui-surface-active)] text-[var(--ui-ink-strong)]":"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"}`,onClick:()=>s({tagIds:v?o.tagIds.filter(k=>k!==e.id):[...o.tagIds,e.id]}),children:e.name},e.id)})})})]})},{id:"notes",eyebrow:"Evidence",title:"Attach any creation context that should live with this goal",description:"Creation notes become real linked Markdown notes, so strategic context does not vanish into the form flow.",render:(o,s)=>t.jsx(i,{label:"Creation notes",children:t.jsx(N,{notes:o.notes,onChange:e=>s({notes:e}),entityLabel:"goal"})})}];return t.jsx(T,{open:a,onOpenChange:b,eyebrow:r("common.dialogs.goal.eyebrow"),title:r(n?"common.dialogs.goal.editTitle":"common.dialogs.goal.createTitle"),description:r("common.dialogs.goal.description"),value:x,onChange:m,draftPersistenceKey:n?`goal.${n.id}`:"goal.new",steps:z,pending:y,pendingLabel:r(n?"common.dialogs.goal.save":"common.dialogs.goal.create"),submitLabel:r(n?"common.dialogs.goal.save":"common.dialogs.goal.create"),error:F,onSubmit:async()=>{l(null);const o=A.safeParse(x);if(!o.success){E(o.error.flatten().fieldErrors),l("Some answers still need attention before this goal arc can be saved.");return}g({});try{await I(o.data,n==null?void 0:n.id),m(p),b(!1)}catch(s){l(s instanceof Error?s.message:r("common.dialogs.goal.submitError"))}}})}export{Z as GoalDialog,p as defaultGoalValues,K as goalToFormValues};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as p,j as e,aC as b,b_ as P,bW as C}from"./vendor-BwL6m4SE.js";import{P as S}from"./page-hero-8bITsx_x.js";import{E as G}from"./entity-note-count-link-Cjsk5oT2.js";import{C as k,B as y,b as w,E as h,k as l,c as N,d as E,h as z,R as L,P as T}from"./index-CQ5r7ZUz.js";import{GoalDialog as B}from"./goal-dialog-Oxx8WqbZ.js";import{P as I}from"./pill-cluster-XQjm-wPc.js";import{b as R,f as D,P as F}from"./project-collections-mtxanSMf.js";import{U}from"./user-badge-CZWtYeMw.js";import{g as M}from"./user-ownership-DJGl4rAj.js";import"./state-Bpe5dF3T.js";import"./motion-DcgUnXhY.js";import"./ui-B9TWEtCx.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";import"./question-flow-dialog-CskCt5NZ.js";import"./inline-note-fields-Bql_KfR9.js";import"./user-select-field-fx129Uh6.js";import"./schemas-CH1_ngUX.js";function O({goals:t,tags:r,users:o,defaultUserId:d=null,pending:c=!1,onCreate:n,onUpdate:v}){const[f,m]=p.useState(!1),[g,u]=p.useState(null),a=t.find(s=>s.id===g)??null;return e.jsxs(e.Fragment,{children:[e.jsxs(k,{children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Goal arcs"}),e.jsx("h3",{className:"mt-2 font-display text-3xl text-[var(--ui-ink-strong)]",children:"Strategic arcs before tickets"}),e.jsx("p",{className:"mt-3 max-w-3xl text-sm leading-7 text-[var(--ui-ink-soft)]",children:"This is the long-horizon map. Each arc shows why it matters, how much ground has been covered, and which project should move next."})]}),e.jsx(y,{onClick:()=>{u(null),m(!0)},children:"Create goal"})]}),e.jsxs("div",{className:"mt-5 grid gap-3 xl:grid-cols-2",children:[t.length===0?e.jsx("div",{className:"rounded-[24px] bg-[var(--ui-surface-2)] p-5 text-sm leading-7 text-[var(--ui-ink-soft)] xl:col-span-2",children:"Start with a life goal. Once the destination is clear, you can attach projects and then fill those projects with tasks."}):null,t.map(s=>{const x=`${Math.max(6,Math.min(100,s.progress))}%`;return e.jsxs(b,{to:`/goals/${s.id}`,className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4 transition hover:bg-[var(--ui-surface-hover)]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(w,{kind:"goal",compact:!0,gradient:!1}),e.jsx("div",{className:"mt-2",children:e.jsx(h,{kind:"goal",label:s.title,variant:"heading",size:"lg",showKind:!1,lines:2})}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:s.description||"No strategic note attached yet."})]}),e.jsx("button",{className:"rounded-full bg-[var(--ui-surface-2)] p-2 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",type:"button",onClick:i=>{i.preventDefault(),i.stopPropagation(),u(s.id),m(!0)},children:e.jsx(P,{className:"size-4"})})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(l,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:s.horizon}),e.jsx(l,{className:s.status==="active"?"text-[var(--success)]":s.status==="paused"?"text-[var(--warning)]":"text-[var(--tertiary)]",children:s.status}),e.jsxs(l,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:[s.earnedPoints," / ",s.targetPoints," xp"]}),e.jsxs(l,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:[s.totalTasks," tasks"]})]}),e.jsx("div",{className:"mt-4 h-1.5 rounded-full bg-[var(--ui-surface-2)]",children:e.jsx("div",{className:"h-full rounded-full bg-[var(--primary)]",style:{width:x}})}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:s.tags.map(i=>e.jsx(l,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:i.name},i.id))}),e.jsxs("div",{className:"mt-3 flex items-center justify-between gap-3 text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:s.momentumLabel}),e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-2",style:{color:s.themeColor},children:["Open arc",e.jsx(C,{className:"size-3.5"})]})]})]},s.id)})]})]}),e.jsx(B,{open:f,pending:c,editingGoal:a,tags:r,users:o,defaultUserId:d,onOpenChange:s=>{m(s),s||u(null)},onSubmit:async(s,x)=>{if(x){await v(x,s);return}await n(s)}})]})}function $({eyebrow:t,title:r,description:o,meta:d,actions:c,className:n}){return e.jsxs("div",{className:N("flex flex-wrap items-start justify-between gap-3",n),children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[t?e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:t}):null,e.jsxs("div",{className:N("min-w-0",t&&"mt-2"),children:[e.jsx("div",{className:"min-w-0 text-lg text-[var(--ui-ink-strong)]",children:r}),o?e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:o}):null]})]}),d||c?e.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-2",children:[d,c]}):null]})}function ne(){const t=E(),[r,o]=p.useState("active"),[d,c]=p.useState(null),n=t.snapshot.dashboard.goals.length>0,v=R(t.snapshot.dashboard.projects),f=D(t.snapshot.dashboard.projects,r),m=M(t.selectedUserIds),g=new Map(t.snapshot.dashboard.goals.map(a=>[a.id,f.filter(s=>s.goalId===a.id)])),u=async a=>{c(a);try{await t.patchProject(a,{status:"active"})}finally{c(null)}};return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(S,{entityKind:"goal",title:e.jsx(h,{kind:"goal",label:"Life Goals",variant:"heading",size:"lg"}),titleText:"Life Goals",description:"Life goals are the destinations you care about over the long run. Each one can hold several projects, and those projects turn direction into real work.",badge:`${t.snapshot.dashboard.goals.length} active goals`,actions:n?e.jsxs("div",{className:"inline-flex min-h-10 items-center rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-2 text-sm whitespace-nowrap text-[var(--ui-ink-soft)]",children:[t.snapshot.dashboard.projects.length," live project",t.snapshot.dashboard.projects.length===1?"":"s"," ","attached"]}):null}),e.jsx(O,{goals:t.snapshot.dashboard.goals,tags:t.snapshot.tags,users:t.snapshot.users,defaultUserId:m,onCreate:t.createGoal,onUpdate:t.patchGoal}),n?e.jsx(F,{value:r,counts:v,onChange:o}):null,n?null:e.jsx(z,{eyebrow:"Life goals",title:"No life goals yet",description:"Define the first long-horizon direction above so Forge can attach projects, tasks, momentum, and evidence to something meaningful."}),n?e.jsx("div",{className:"grid gap-4",children:t.snapshot.dashboard.goals.map(a=>{const s=g.get(a.id)??[],x=L(t.snapshot.dashboard.notesSummaryByEntity,"goal",a.id);return e.jsx(b,{to:`/goals/${a.id}`,className:"min-w-0 overflow-hidden rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4 transition hover:bg-[var(--ui-surface-hover)] sm:p-5",children:e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)] xl:gap-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs(I,{children:[a.tags.slice(0,3).map(i=>e.jsx(l,{className:"bg-[var(--ui-surface-2)]",style:{color:i.color},children:i.name},i.id)),e.jsx(l,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:a.horizon}),e.jsx(U,{user:a.user,compact:!0})]}),e.jsx("div",{className:"mt-4",children:e.jsx(h,{kind:"goal",label:a.title,variant:"heading",size:"xl",lines:2})}),e.jsx("p",{className:"mt-3 max-w-2xl text-sm leading-7 text-[var(--ui-ink-soft)]",children:a.description}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3.5 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Progress"}),e.jsxs("div",{className:"mt-2 text-xl text-[var(--ui-ink-strong)]",children:[a.progress,"%"]})]}),e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3.5 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Tasks done"}),e.jsxs("div",{className:"mt-2 text-xl text-[var(--ui-ink-strong)]",children:[a.completedTasks,"/",Math.max(a.totalTasks,1)]})]}),e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3.5 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"XP banked"}),e.jsx("div",{className:"mt-2 text-xl text-[var(--ui-ink-strong)]",children:a.earnedPoints})]})]}),e.jsx("div",{className:"mt-4",children:e.jsx(T,{value:a.progress})}),e.jsx("div",{className:"mt-4",children:e.jsx(G,{entityType:"goal",entityId:a.id,count:x.count})})]}),e.jsxs("div",{className:"min-w-0 rounded-[24px] bg-[var(--ui-surface-2)] p-4",children:[e.jsx($,{title:"Projects carrying this direction",meta:e.jsx("div",{className:"shrink-0 text-sm text-[var(--ui-ink-faint)]",children:s.length}),className:"gap-2"}),s.length===0?e.jsx("div",{className:"mt-4 text-sm leading-6 text-[var(--ui-ink-soft)]",children:r==="active"?"No active project is attached yet. Create one so this direction starts producing visible work.":"No projects in this lifecycle view are attached yet. Switch filters or restart one to bring it back into active motion."}):e.jsx("div",{className:"mt-4 grid gap-3",children:s.slice(0,3).map(i=>e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-hover)] px-4 py-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx(w,{kind:"project",compact:!0,gradient:!1}),e.jsx(h,{kind:"project",label:i.title,className:"min-w-0",showIcon:!1,lines:2})]}),e.jsx(l,{className:"shrink-0",children:i.status})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:i.description}),e.jsxs("div",{className:"mt-3 text-sm text-[var(--ui-ink-faint)]",children:["Next move:"," ",i.nextTaskTitle??"Define the first attached task"]}),r!=="active"&&i.status!=="active"?e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsx(y,{variant:"secondary",size:"sm",pending:d===i.id,pendingLabel:"Restarting…",onClick:j=>{j.preventDefault(),j.stopPropagation(),u(i.id)},children:"Restart"})}):null]},i.id))})]})]})},a.id)})}):e.jsx(k,{children:e.jsx("div",{className:"rounded-[20px] bg-[var(--ui-surface-2)] p-4 text-sm text-[var(--ui-ink-soft)]",children:"Goal cards will appear here once the first long-horizon direction is created."})})]})}export{ne as GoalsPage};
|
|
1
|
+
import{r as p,j as e,aC as b,b_ as P,bW as C}from"./vendor-BwL6m4SE.js";import{P as S}from"./page-hero-DvrM83_C.js";import{E as G}from"./entity-note-count-link-Bs1aKYyD.js";import{C as k,B as y,b as w,E as h,k as l,c as N,d as E,h as z,R as L,P as T}from"./index-FpGANF9S.js";import{GoalDialog as B}from"./goal-dialog-15hD8EBp.js";import{P as I}from"./pill-cluster-DYI3Ibj8.js";import{b as R,f as D,P as F}from"./project-collections-B9nr-Ts-.js";import{U}from"./user-badge-ByhC6bMU.js";import{g as M}from"./user-ownership-DJGl4rAj.js";import"./state-Bpe5dF3T.js";import"./motion-DcgUnXhY.js";import"./ui-B9TWEtCx.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";import"./question-flow-dialog-Ded2E85L.js";import"./inline-note-fields-COgzxr_7.js";import"./user-select-field-fx129Uh6.js";import"./schemas-Db29G8NU.js";function O({goals:t,tags:r,users:o,defaultUserId:d=null,pending:c=!1,onCreate:n,onUpdate:v}){const[f,m]=p.useState(!1),[g,u]=p.useState(null),a=t.find(s=>s.id===g)??null;return e.jsxs(e.Fragment,{children:[e.jsxs(k,{children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Goal arcs"}),e.jsx("h3",{className:"mt-2 font-display text-3xl text-[var(--ui-ink-strong)]",children:"Strategic arcs before tickets"}),e.jsx("p",{className:"mt-3 max-w-3xl text-sm leading-7 text-[var(--ui-ink-soft)]",children:"This is the long-horizon map. Each arc shows why it matters, how much ground has been covered, and which project should move next."})]}),e.jsx(y,{onClick:()=>{u(null),m(!0)},children:"Create goal"})]}),e.jsxs("div",{className:"mt-5 grid gap-3 xl:grid-cols-2",children:[t.length===0?e.jsx("div",{className:"rounded-[24px] bg-[var(--ui-surface-2)] p-5 text-sm leading-7 text-[var(--ui-ink-soft)] xl:col-span-2",children:"Start with a life goal. Once the destination is clear, you can attach projects and then fill those projects with tasks."}):null,t.map(s=>{const x=`${Math.max(6,Math.min(100,s.progress))}%`;return e.jsxs(b,{to:`/goals/${s.id}`,className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4 transition hover:bg-[var(--ui-surface-hover)]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(w,{kind:"goal",compact:!0,gradient:!1}),e.jsx("div",{className:"mt-2",children:e.jsx(h,{kind:"goal",label:s.title,variant:"heading",size:"lg",showKind:!1,lines:2})}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:s.description||"No strategic note attached yet."})]}),e.jsx("button",{className:"rounded-full bg-[var(--ui-surface-2)] p-2 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",type:"button",onClick:i=>{i.preventDefault(),i.stopPropagation(),u(s.id),m(!0)},children:e.jsx(P,{className:"size-4"})})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(l,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:s.horizon}),e.jsx(l,{className:s.status==="active"?"text-[var(--success)]":s.status==="paused"?"text-[var(--warning)]":"text-[var(--tertiary)]",children:s.status}),e.jsxs(l,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:[s.earnedPoints," / ",s.targetPoints," xp"]}),e.jsxs(l,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:[s.totalTasks," tasks"]})]}),e.jsx("div",{className:"mt-4 h-1.5 rounded-full bg-[var(--ui-surface-2)]",children:e.jsx("div",{className:"h-full rounded-full bg-[var(--primary)]",style:{width:x}})}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:s.tags.map(i=>e.jsx(l,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:i.name},i.id))}),e.jsxs("div",{className:"mt-3 flex items-center justify-between gap-3 text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:s.momentumLabel}),e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-2",style:{color:s.themeColor},children:["Open arc",e.jsx(C,{className:"size-3.5"})]})]})]},s.id)})]})]}),e.jsx(B,{open:f,pending:c,editingGoal:a,tags:r,users:o,defaultUserId:d,onOpenChange:s=>{m(s),s||u(null)},onSubmit:async(s,x)=>{if(x){await v(x,s);return}await n(s)}})]})}function $({eyebrow:t,title:r,description:o,meta:d,actions:c,className:n}){return e.jsxs("div",{className:N("flex flex-wrap items-start justify-between gap-3",n),children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[t?e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:t}):null,e.jsxs("div",{className:N("min-w-0",t&&"mt-2"),children:[e.jsx("div",{className:"min-w-0 text-lg text-[var(--ui-ink-strong)]",children:r}),o?e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:o}):null]})]}),d||c?e.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-2",children:[d,c]}):null]})}function ne(){const t=E(),[r,o]=p.useState("active"),[d,c]=p.useState(null),n=t.snapshot.dashboard.goals.length>0,v=R(t.snapshot.dashboard.projects),f=D(t.snapshot.dashboard.projects,r),m=M(t.selectedUserIds),g=new Map(t.snapshot.dashboard.goals.map(a=>[a.id,f.filter(s=>s.goalId===a.id)])),u=async a=>{c(a);try{await t.patchProject(a,{status:"active"})}finally{c(null)}};return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(S,{entityKind:"goal",title:e.jsx(h,{kind:"goal",label:"Life Goals",variant:"heading",size:"lg"}),titleText:"Life Goals",description:"Life goals are the destinations you care about over the long run. Each one can hold several projects, and those projects turn direction into real work.",badge:`${t.snapshot.dashboard.goals.length} active goals`,actions:n?e.jsxs("div",{className:"inline-flex min-h-10 items-center rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-2 text-sm whitespace-nowrap text-[var(--ui-ink-soft)]",children:[t.snapshot.dashboard.projects.length," live project",t.snapshot.dashboard.projects.length===1?"":"s"," ","attached"]}):null}),e.jsx(O,{goals:t.snapshot.dashboard.goals,tags:t.snapshot.tags,users:t.snapshot.users,defaultUserId:m,onCreate:t.createGoal,onUpdate:t.patchGoal}),n?e.jsx(F,{value:r,counts:v,onChange:o}):null,n?null:e.jsx(z,{eyebrow:"Life goals",title:"No life goals yet",description:"Define the first long-horizon direction above so Forge can attach projects, tasks, momentum, and evidence to something meaningful."}),n?e.jsx("div",{className:"grid gap-4",children:t.snapshot.dashboard.goals.map(a=>{const s=g.get(a.id)??[],x=L(t.snapshot.dashboard.notesSummaryByEntity,"goal",a.id);return e.jsx(b,{to:`/goals/${a.id}`,className:"min-w-0 overflow-hidden rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4 transition hover:bg-[var(--ui-surface-hover)] sm:p-5",children:e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)] xl:gap-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs(I,{children:[a.tags.slice(0,3).map(i=>e.jsx(l,{className:"bg-[var(--ui-surface-2)]",style:{color:i.color},children:i.name},i.id)),e.jsx(l,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:a.horizon}),e.jsx(U,{user:a.user,compact:!0})]}),e.jsx("div",{className:"mt-4",children:e.jsx(h,{kind:"goal",label:a.title,variant:"heading",size:"xl",lines:2})}),e.jsx("p",{className:"mt-3 max-w-2xl text-sm leading-7 text-[var(--ui-ink-soft)]",children:a.description}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3.5 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Progress"}),e.jsxs("div",{className:"mt-2 text-xl text-[var(--ui-ink-strong)]",children:[a.progress,"%"]})]}),e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3.5 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Tasks done"}),e.jsxs("div",{className:"mt-2 text-xl text-[var(--ui-ink-strong)]",children:[a.completedTasks,"/",Math.max(a.totalTasks,1)]})]}),e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3.5 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"XP banked"}),e.jsx("div",{className:"mt-2 text-xl text-[var(--ui-ink-strong)]",children:a.earnedPoints})]})]}),e.jsx("div",{className:"mt-4",children:e.jsx(T,{value:a.progress})}),e.jsx("div",{className:"mt-4",children:e.jsx(G,{entityType:"goal",entityId:a.id,count:x.count})})]}),e.jsxs("div",{className:"min-w-0 rounded-[24px] bg-[var(--ui-surface-2)] p-4",children:[e.jsx($,{title:"Projects carrying this direction",meta:e.jsx("div",{className:"shrink-0 text-sm text-[var(--ui-ink-faint)]",children:s.length}),className:"gap-2"}),s.length===0?e.jsx("div",{className:"mt-4 text-sm leading-6 text-[var(--ui-ink-soft)]",children:r==="active"?"No active project is attached yet. Create one so this direction starts producing visible work.":"No projects in this lifecycle view are attached yet. Switch filters or restart one to bring it back into active motion."}):e.jsx("div",{className:"mt-4 grid gap-3",children:s.slice(0,3).map(i=>e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-hover)] px-4 py-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx(w,{kind:"project",compact:!0,gradient:!1}),e.jsx(h,{kind:"project",label:i.title,className:"min-w-0",showIcon:!1,lines:2})]}),e.jsx(l,{className:"shrink-0",children:i.status})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:i.description}),e.jsxs("div",{className:"mt-3 text-sm text-[var(--ui-ink-faint)]",children:["Next move:"," ",i.nextTaskTitle??"Define the first attached task"]}),r!=="active"&&i.status!=="active"?e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsx(y,{variant:"secondary",size:"sm",pending:d===i.id,pendingLabel:"Restarting…",onClick:j=>{j.preventDefault(),j.stopPropagation(),u(i.id)},children:"Restart"})}):null]},i.id))})]})]})},a.id)})}):e.jsx(k,{children:e.jsx("div",{className:"rounded-[20px] bg-[var(--ui-surface-2)] p-4 text-sm text-[var(--ui-ink-soft)]",children:"Goal cards will appear here once the first long-horizon direction is created."})})]})}export{ne as GoalsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as p,j as e,bY as Ye,aG as Ze,c7 as Je,aV as Ve,c8 as es,c1 as ss,b$ as Ce,bF as Ie,c9 as Pe,ca as as,aK as De,cb as ts,cc as rs,cd as is,ce as ns}from"./vendor-BwL6m4SE.js";import{R as Le,P as Se,O as Te,C as He,T as Ee,D as Ae,a as Be}from"./ui-B9TWEtCx.js";import{j as ls,i as me,k as ge}from"./state-Bpe5dF3T.js";import{E as os}from"./entity-note-count-link-Cjsk5oT2.js";import{N as ds}from"./note-markdown-B82ncnFt.js";import{I as q,T as ve,b as F,d as cs,U as xe,V as us,B as L,E as Fe,C as A,n as U,m as Me,h as ms,R as gs,c as P,k as v,W as xs,X as hs,Y as Ke,Z as bs,_ as vs,$ as ps,a0 as fs,a1 as ks,a2 as ys,O as js}from"./index-CQ5r7ZUz.js";import{u as ws,p as _s}from"./use-psyche-focus-target-BhNedCZB.js";import{P as Ns}from"./page-hero-8bITsx_x.js";import{Q as Cs,F as b,a as oe}from"./question-flow-dialog-CskCt5NZ.js";import{U as Is}from"./user-select-field-fx129Uh6.js";import{a as Ps,c as Ds,g as Ls}from"./user-ownership-DJGl4rAj.js";import{h as Ss}from"./schemas-CH1_ngUX.js";import{S as Ts}from"./select-menu-BOF-k4Ln.js";import{U as Hs}from"./user-badge-CZWtYeMw.js";import{f as Es}from"./date-keys-BnZV4PNO.js";import"./motion-DcgUnXhY.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";const he={title:"",description:"",status:"active",userId:null,polarity:"positive",frequency:"daily",targetCount:1,weekDays:[],linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],linkedValueIds:[],linkedPatternIds:[],linkedBehaviorIds:[],linkedBeliefIds:[],linkedModeIds:[],linkedReportIds:[],linkedBehaviorId:"",rewardXp:12,penaltyXp:8,generatedHealthEventTemplate:{enabled:!1,workoutType:"workout",title:"",durationMinutes:45,xpReward:0,tags:[],links:[],notesTemplate:""}},As=[{value:1,label:"Mon"},{value:2,label:"Tue"},{value:3,label:"Wed"},{value:4,label:"Thu"},{value:5,label:"Fri"},{value:6,label:"Sat"},{value:0,label:"Sun"}];function Bs(s){return{title:s.title,description:s.description,status:s.status,userId:s.userId??null,polarity:s.polarity,frequency:s.frequency,targetCount:s.targetCount,weekDays:s.weekDays,linkedGoalIds:s.linkedGoalIds,linkedProjectIds:s.linkedProjectIds,linkedTaskIds:s.linkedTaskIds,linkedValueIds:s.linkedValueIds,linkedPatternIds:s.linkedPatternIds,linkedBehaviorIds:s.linkedBehaviorIds,linkedBeliefIds:s.linkedBeliefIds,linkedModeIds:s.linkedModeIds,linkedReportIds:s.linkedReportIds,linkedBehaviorId:s.linkedBehaviorId??"",rewardXp:s.rewardXp,penaltyXp:s.penaltyXp,generatedHealthEventTemplate:s.generatedHealthEventTemplate}}function Fs({open:s,pending:o=!1,editingHabit:d,values:f,patterns:k,behaviors:T,beliefs:c,modes:y,reports:m,goals:j,projects:H,tasks:D,users:M,defaultUserId:w=null,onOpenChange:N,onSubmit:E}){const[R,S]=p.useState(he),[te,K]=p.useState(null),[C,Z]=p.useState({});p.useEffect(()=>{s&&(S(d?Bs(d):{...he,userId:w}),K(null),Z({}))},[w,d,s]);const O=M.find(r=>r.id===w)??null,$=p.useMemo(()=>T.slice().sort((r,i)=>r.title.localeCompare(i.title)),[T]),I=r=>({linkedBehaviorIds:r,linkedBehaviorId:r[0]??""}),_=(r,i)=>r.includes(i)?r.filter(t=>t!==i):[...r,i],G=[{id:"intent",eyebrow:"Habit",title:"Name the recurring move",description:"Use habits for recurring commitments and recurring slips. Keep the title concrete so the daily check-in never needs interpretation.",render:(r,i)=>e.jsxs(e.Fragment,{children:[e.jsx(b,{label:"Title",error:C.title??null,children:e.jsx(q,{value:r.title,onChange:t=>i({title:t.target.value}),placeholder:"Train lower body"})}),e.jsx(b,{label:"Description",children:e.jsx(ve,{value:r.description,onChange:t=>i({description:t.target.value}),placeholder:"Write the habit description in Markdown. Define what counts, edge cases, and examples."})}),e.jsx(Is,{value:r.userId,users:M,onChange:t=>i({userId:t}),label:"Owner user",defaultLabel:Ps(O),help:"Habits can be owned by humans or bots. When one scoped user is active, Forge uses that as the default."})]})},{id:"shape",eyebrow:"Shape",title:"Set direction and cadence",description:"Forge uses polarity to decide whether doing the habit is good or bad, and cadence to know when it should show up.",render:(r,i)=>e.jsxs(e.Fragment,{children:[e.jsx(b,{label:"Polarity",children:e.jsx(oe,{value:r.polarity,onChange:t=>i({polarity:t}),options:[{value:"positive",label:"Positive",description:"Doing it is aligned and should award XP."},{value:"negative",label:"Negative",description:"Doing it is a slip and should cost XP."}],columns:2})}),e.jsx(b,{label:"Frequency",children:e.jsx(oe,{value:r.frequency,onChange:t=>i({frequency:t}),options:[{value:"daily",label:"Daily",description:"Track against each day."},{value:"weekly",label:"Weekly",description:"Track only on the selected weekdays."}],columns:2})}),r.frequency==="weekly"?e.jsx(b,{label:"Weekdays",error:C.weekDays??null,children:e.jsx("div",{className:"flex flex-wrap gap-2",children:As.map(t=>{const n=r.weekDays.includes(t.value);return e.jsx("button",{type:"button",className:`rounded-full border px-3 py-2 text-sm transition ${n?"border-[color-mix(in_srgb,var(--primary)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"}`,onClick:()=>i({weekDays:n?r.weekDays.filter(J=>J!==t.value):[...r.weekDays,t.value].sort()}),children:t.label},t.value)})})}):null,e.jsx(b,{label:"Status",children:e.jsx(oe,{value:r.status,onChange:t=>i({status:t}),options:[{value:"active",label:"Active",description:"Show it in the daily operating flow."},{value:"paused",label:"Paused",description:"Keep it visible but not currently due."},{value:"archived",label:"Archived",description:"Keep the record but retire it from active work."}]})})]})},{id:"generation",eyebrow:"Generation",title:"Decide whether this habit should create a workout record",description:"Use this when a completed habit should generate a structured sports or recovery session in Forge, then reconcile with HealthKit later if the same session gets imported.",render:(r,i)=>e.jsxs(e.Fragment,{children:[e.jsx(b,{label:"Generate workout record",children:e.jsx(oe,{value:r.generatedHealthEventTemplate.enabled?"enabled":"disabled",onChange:t=>i({generatedHealthEventTemplate:{...r.generatedHealthEventTemplate,enabled:t==="enabled"}}),options:[{value:"disabled",label:"Disabled",description:"This habit only affects the habit ledger."},{value:"enabled",label:"Enabled",description:"A completed check-in creates a workout or recovery session."}],columns:2})}),r.generatedHealthEventTemplate.enabled?e.jsxs(e.Fragment,{children:[e.jsx(b,{label:"Workout type",children:e.jsx(q,{value:r.generatedHealthEventTemplate.workoutType,onChange:t=>i({generatedHealthEventTemplate:{...r.generatedHealthEventTemplate,workoutType:t.target.value}}),placeholder:"mobility, walk, strength, recovery"})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(b,{label:"Duration (minutes)",children:e.jsx(q,{type:"number",min:1,max:1440,value:r.generatedHealthEventTemplate.durationMinutes,onChange:t=>i({generatedHealthEventTemplate:{...r.generatedHealthEventTemplate,durationMinutes:Number(t.target.value)||45}})})}),e.jsx(b,{label:"Workout XP",children:e.jsx(q,{type:"number",min:0,max:500,value:r.generatedHealthEventTemplate.xpReward,onChange:t=>i({generatedHealthEventTemplate:{...r.generatedHealthEventTemplate,xpReward:Number(t.target.value)||0}})})})]}),e.jsx(b,{label:"Generated session note",children:e.jsx(ve,{value:r.generatedHealthEventTemplate.notesTemplate,onChange:t=>i({generatedHealthEventTemplate:{...r.generatedHealthEventTemplate,notesTemplate:t.target.value}}),placeholder:"Morning routine session generated from habit completion."})})]}):null]})},{id:"links",eyebrow:"Links",title:"Connect the habit to real Forge work",description:"Link habits to the goals, projects, and tasks they support so they stay anchored in the same operating graph as everything else.",render:(r,i)=>e.jsxs(e.Fragment,{children:[e.jsx(b,{label:"Goals",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:j.map(t=>{const n=r.linkedGoalIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedGoalIds:_(r.linkedGoalIds,t.id)}),children:e.jsx(F,{kind:"goal",label:t.title,gradient:n,className:n?"":"opacity-75"})},t.id)})})}),e.jsx(b,{label:"Projects",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:H.map(t=>{const n=r.linkedProjectIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedProjectIds:_(r.linkedProjectIds,t.id)}),children:e.jsx(F,{kind:"project",label:t.title,gradient:n,className:n?"":"opacity-75"})},t.id)})})}),e.jsx(b,{label:"Tasks",children:e.jsx("div",{className:"flex max-h-48 flex-wrap gap-2 overflow-y-auto",children:D.map(t=>{const n=r.linkedTaskIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedTaskIds:_(r.linkedTaskIds,t.id)}),children:e.jsx(F,{kind:"task",label:t.title,gradient:n,className:n?"":"opacity-75",wrap:!0})},t.id)})})}),e.jsx(b,{label:"Values",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:f.map(t=>{const n=r.linkedValueIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedValueIds:_(r.linkedValueIds,t.id)}),children:e.jsx(F,{kind:"value",label:t.title,gradient:n,className:n?"":"opacity-75"})},t.id)})})}),e.jsx(b,{label:"Patterns",children:e.jsx("div",{className:"flex max-h-44 flex-wrap gap-2 overflow-y-auto",children:k.map(t=>{const n=r.linkedPatternIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedPatternIds:_(r.linkedPatternIds,t.id)}),children:e.jsx(F,{kind:"pattern",label:t.title,gradient:n,className:n?"":"opacity-75",wrap:!0})},t.id)})})})]})},{id:"reward",eyebrow:"Reward",title:"Link the behavior and XP logic",description:"Habits can point back to a Psyche behavior. Reward XP is granted for aligned outcomes; penalty XP is applied for misaligned ones.",render:(r,i)=>e.jsxs(e.Fragment,{children:[e.jsx(b,{label:"Linked behavior",children:e.jsx("div",{className:"flex max-h-44 flex-wrap gap-2 overflow-y-auto",children:$.map(t=>{const n=r.linkedBehaviorIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i(I(_(r.linkedBehaviorIds,t.id))),children:e.jsx(F,{kind:"behavior",label:t.title,gradient:n,className:n?"":"opacity-75",wrap:!0})},t.id)})})}),e.jsx(b,{label:"Beliefs",children:e.jsx("div",{className:"flex max-h-44 flex-wrap gap-2 overflow-y-auto",children:c.map(t=>{const n=r.linkedBeliefIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedBeliefIds:_(r.linkedBeliefIds,t.id)}),children:e.jsx(F,{kind:"belief",label:t.statement,gradient:n,className:n?"":"opacity-75",wrap:!0})},t.id)})})}),e.jsx(b,{label:"Modes",children:e.jsx("div",{className:"flex max-h-44 flex-wrap gap-2 overflow-y-auto",children:y.map(t=>{const n=r.linkedModeIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedModeIds:_(r.linkedModeIds,t.id)}),children:e.jsx(F,{kind:"mode",label:t.title,gradient:n,className:n?"":"opacity-75",wrap:!0})},t.id)})})}),e.jsx(b,{label:"Reports",children:e.jsx("div",{className:"flex max-h-44 flex-wrap gap-2 overflow-y-auto",children:m.map(t=>{const n=r.linkedReportIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedReportIds:_(r.linkedReportIds,t.id)}),children:e.jsx(F,{kind:"report",label:t.title,gradient:n,className:n?"":"opacity-75",wrap:!0})},t.id)})})}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[e.jsx(b,{label:"Target count",error:C.targetCount??null,children:e.jsx(q,{type:"number",value:r.targetCount,onChange:t=>i({targetCount:Number(t.target.value)||1})})}),e.jsx(b,{label:"Reward XP",error:C.rewardXp??null,children:e.jsx(q,{type:"number",value:r.rewardXp,onChange:t=>i({rewardXp:Number(t.target.value)||1})})}),e.jsx(b,{label:"Penalty XP",error:C.penaltyXp??null,children:e.jsx(q,{type:"number",value:r.penaltyXp,onChange:t=>i({penaltyXp:Number(t.target.value)||1})})})]})]})}];return e.jsx(Cs,{open:s,onOpenChange:N,eyebrow:"Habit",title:d?"Edit habit":"Create habit",description:"Habits are recurring commitments or recurring slips with explicit XP consequences.",value:R,onChange:S,draftPersistenceKey:d?`habit.${d.id}`:"habit.new",steps:G,pending:o,pendingLabel:d?"Save habit":"Create habit",submitLabel:d?"Save habit":"Create habit",error:te,onSubmit:async()=>{K(null);const r=Ss.safeParse(R);if(!r.success){Z(Object.fromEntries(Object.entries(r.error.flatten().fieldErrors).map(([i,t])=>[i,t==null?void 0:t[0]]))),K("Some habit fields still need attention.");return}Z({});try{await E(r.data,d==null?void 0:d.id),S(he),N(!1)}catch(i){K(i instanceof Error?i.message:"Habit update failed.")}}})}const Ms=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Ks=["S","M","T","W","T","F","S"],Xs=[{value:"name",label:"Name A-Z",description:"Keep the list stable alphabetically."},{value:"needs_attention",label:"Needs attention",description:"Bubble up habits still waiting on today."},{value:"streak",label:"Longest streak",description:"Put the strongest current streaks first."},{value:"created_at",label:"Newest created",description:"Show the most recently created habits first."},{value:"updated_at",label:"Recently updated",description:"Sort by the most recently changed habits."}];function Rs(s){return s.frequency==="daily"?`${s.targetCount}x daily`:`${s.targetCount}x weekly · ${s.weekDays.map(o=>Ms[o]).join(", ")}`}function W(s){return Es(s)}function $e(s){const[o,d,f]=s.split("-").map(Number);return new Date(o,d-1,f)}function ze(s){return new Date(s.getFullYear(),s.getMonth(),s.getDate())}function de(s,o){const d=new Date(s);return d.setDate(d.getDate()+o),d}function Xe(s){const o=ze(s),d=(o.getDay()+6)%7;return o.setDate(o.getDate()-d),o}function ee(s){const o=typeof s=="string"?$e(s):s;return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(o)}function ue(s,o){return s.polarity==="positive"&&o==="done"||s.polarity==="negative"&&o==="missed"}function pe(s,o){return s.polarity==="positive"?o==="done"?"Done":"Missed":o==="done"?"Performed":"Resisted"}function qe(s){const o=W(new Date),d=s.checkIns.find(f=>f.dateKey===o)??null;return s.dueToday?{tone:"pending",label:s.frequency==="daily"?"Waiting for today":"Awaiting this week's check-in",cardClass:"border-[color-mix(in_srgb,var(--warning)_28%,var(--ui-border-subtle)_72%)] shadow-[var(--ui-shadow-soft)]",overlayClass:"bg-[radial-gradient(circle_at_top_right,color-mix(in_srgb,var(--warning)_18%,transparent),transparent_44%)]",pillClass:"border border-[color-mix(in_srgb,var(--warning)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]"}:d?ue(s,d.status)?{tone:"aligned",label:`${pe(s,d.status)} today`,cardClass:"border-[color-mix(in_srgb,var(--success)_24%,var(--ui-border-subtle)_76%)] shadow-[var(--ui-shadow-soft)]",overlayClass:"bg-[radial-gradient(circle_at_top_right,color-mix(in_srgb,var(--success)_16%,transparent),transparent_44%)]",pillClass:"border border-[color-mix(in_srgb,var(--success)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]"}:{tone:"unaligned",label:`${pe(s,d.status)} today`,cardClass:"border-[color-mix(in_srgb,var(--danger)_24%,var(--ui-border-subtle)_76%)] shadow-[var(--ui-shadow-soft)]",overlayClass:"bg-[radial-gradient(circle_at_top_right,color-mix(in_srgb,var(--danger)_16%,transparent),transparent_44%)]",pillClass:"border border-[color-mix(in_srgb,var(--danger)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]"}:s.polarity==="positive"?{tone:"neutral",label:"No update due right now",cardClass:"",overlayClass:"bg-[radial-gradient(circle_at_top_right,color-mix(in_srgb,var(--success)_9%,transparent),transparent_40%)]",pillClass:"border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]"}:{tone:"neutral",label:"No update due right now",cardClass:"",overlayClass:"bg-[radial-gradient(circle_at_top_right,color-mix(in_srgb,var(--danger)_9%,transparent),transparent_40%)]",pillClass:"border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]"}}function Os(s){return s>=10?{Icon:ts,className:"border border-[color-mix(in_srgb,var(--warning)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)] shadow-[var(--ui-shadow-soft)]",iconClass:"text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]",valueClass:"text-[var(--ui-ink-strong)]",label:"Celebration pace"}:s>=5?{Icon:rs,className:"border border-[color-mix(in_srgb,var(--success)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)]",iconClass:"text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]",valueClass:"text-[var(--ui-ink-strong)]",label:"Locked in"}:s>=1?{Icon:is,className:"border border-[color-mix(in_srgb,var(--info)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)]",iconClass:"text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]",valueClass:"text-[var(--ui-ink-strong)]",label:"Building rhythm"}:{Icon:ns,className:"border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] shadow-[var(--ui-shadow-soft)]",iconClass:"text-[var(--ui-ink-soft)]",valueClass:"text-[var(--ui-ink-strong)]",label:"Cold start"}}function $s(s){return s>=80?"border-[color-mix(in_srgb,var(--success)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]":s>=50?"border-[color-mix(in_srgb,var(--warning)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]":"border-[color-mix(in_srgb,var(--danger)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]"}const se="border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",Re="border-[color-mix(in_srgb,var(--success)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]",Oe="border-[color-mix(in_srgb,var(--danger)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",ce="border-[color-mix(in_srgb,var(--warning)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]",be="border-[color-mix(in_srgb,var(--info)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]",ae="border-[color-mix(in_srgb,var(--primary)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-accent-soft)] text-[color-mix(in_srgb,var(--primary)_72%,var(--ui-ink-strong)_28%)]";function zs(s){var T;const o=new Date;if(s.frequency==="daily"){const c=ze(o),y=[];for(let m=-6;m<=0;m+=1){const j=de(c,m),H=W(j),D=s.checkIns.find(N=>N.dateKey===H)??null,M=Ks[j.getDay()],w=m===0;y.push({id:H,label:M,current:w,actionDateKey:H,actionLabel:ee(j),state:D?ue(s,D.status)?"aligned":"unaligned":"unknown",title:`${ee(j)} · ${D?pe(s,D.status):"Not informed"}`})}return{caption:"7-day rhythm",rangeLabel:"Past 7 days",showLabels:!0,startLabel:"",endLabel:"",cells:y}}const d=Xe(o),f=new Map;for(const c of s.checkIns){const y=W(Xe($e(c.dateKey))),m=f.get(y)??[];m.push(c),f.set(y,m)}const k=[];for(let c=-6;c<=0;c+=1){const y=de(d,c*7),m=W(y),j=f.get(m)??[],H=s.weekDays.length>0?[...s.weekDays].sort((E,R)=>R-E)[0]:0,D=W(de(y,H)),M=((T=j[0])==null?void 0:T.dateKey)??D,w=j.filter(E=>ue(s,E.status)).length,N=j.length-w;k.push({id:m,label:"",current:c===0,actionDateKey:M,actionLabel:`Week of ${ee(y)}`,state:j.length===0?"unknown":w>=N?"aligned":"unaligned",title:`${ee(y)} week · ${j.length===0?"Not informed":w>=N?"Mostly aligned":"Mostly off track"}`})}return{caption:"7-week rhythm",rangeLabel:"Past 7 weeks",showLabels:!1,startLabel:ee(de(d,-42)),endLabel:"This week",cells:k}}function qs(s,o){return P("h-8 w-full rounded-[10px] border transition",s==="aligned"&&"border-[color-mix(in_srgb,var(--success)_30%,var(--ui-border-subtle)_70%)] bg-[color-mix(in_srgb,var(--success)_58%,var(--ui-surface-1)_42%)] shadow-[var(--ui-shadow-soft)]",s==="unaligned"&&"border-[color-mix(in_srgb,var(--danger)_30%,var(--ui-border-subtle)_70%)] bg-[color-mix(in_srgb,var(--danger)_54%,var(--ui-surface-1)_46%)] shadow-[var(--ui-shadow-soft)]",s==="unknown"&&"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]",o&&"ring-1 ring-[color-mix(in_srgb,var(--primary)_34%,transparent)]")}function Ws({habit:s,onSelectCell:o}){const d=zs(s),f=qe(s);return e.jsxs("div",{className:"w-full rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-2.5 shadow-[var(--ui-shadow-soft)]",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"shrink-0",children:[e.jsx("div",{className:"font-label text-[10px] uppercase tracking-[0.16em] text-[var(--ui-ink-muted)]",children:d.caption}),e.jsx("div",{className:"text-[11px] text-[var(--ui-ink-soft)]",children:d.rangeLabel})]}),e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:d.cells.map(k=>e.jsxs("button",{type:"button",className:"group flex min-w-0 flex-1 items-center gap-1 rounded-[10px] transition hover:bg-[var(--ui-surface-hover)]",onClick:()=>o(s,k),title:`Log check-in for ${k.actionLabel}`,"aria-label":`Log check-in for ${k.actionLabel}`,children:[e.jsx("div",{className:P(qs(k.state,k.current),"h-6 min-w-0 flex-1 rounded-[8px] transition duration-150 group-hover:-translate-y-0.5 group-hover:shadow-[var(--ui-shadow-soft)]")}),d.showLabels?e.jsx("span",{className:"hidden text-[9px] uppercase tracking-[0.14em] text-[var(--ui-ink-muted)] transition group-hover:text-[var(--ui-ink-medium)] sm:inline",children:k.label}):null]},k.id))}),e.jsx("div",{className:P("shrink-0 rounded-full px-2.5 py-1 text-[10px] font-medium",f.pillClass),children:f.label})]}),d.showLabels?null:e.jsxs("div",{className:"mt-1 text-right text-[10px] uppercase tracking-[0.14em] text-[var(--ui-ink-muted)]",children:[d.startLabel," - ",d.endLabel]})]})}function Gs(s){return s.polarity==="positive"?{alignedLabel:"Done",alignedDescription:"Log that the intended habit happened.",unalignedLabel:"Missed",unalignedDescription:"Log that the habit did not happen."}:{alignedLabel:"Resisted",alignedDescription:"Log that the unwanted behavior was resisted.",unalignedLabel:"Performed",unalignedDescription:"Log that the unwanted behavior happened."}}function Q(s,o){return s.polarity==="positive"?o==="aligned"?"done":"missed":o==="aligned"?"missed":"done"}function Y(s,o){return ue(s,o)?"aligned":"unaligned"}function ma(){var ke,ye,je,we,_e,Ne;const s=cs(),o=ls(),[d,f]=Ye(),[k,T]=p.useState(null),[c,y]=p.useState(null),[m,j]=p.useState(null),[H,D]=p.useState(""),[M,w]=p.useState(!1),[N,E]=p.useState(null),[R,S]=p.useState(null),te=d.get("focus"),K=d.get("orderBy")??"name",C=Ds(s.selectedUserIds),Z=Ls(C),O=["forge-habits",K,...C];ws(te);const $=me({queryKey:O,queryFn:async()=>(await ks({userIds:C,orderBy:K})).habits}),I=me({queryKey:["forge-psyche-overview",...C],queryFn:async()=>(await ys(C)).overview}),_=me({queryKey:["forge-life-force",...C],queryFn:async()=>(await js(C)).lifeForce});p.useEffect(()=>{d.get("create")==="1"&&(T(null),w(!0),f(a=>{const h=new URLSearchParams(a);return h.delete("create"),h},{replace:!0}))},[d,f]);const G=async()=>{await o.invalidateQueries({queryKey:["forge-habits"]}),await s.refresh()},r=ge({mutationFn:async({input:a,habitId:h})=>h?(await bs(h,a)).habit:(await vs(a)).habit,onSuccess:async()=>{S(null),await G()},onError:a=>{S(a instanceof Error?a.message:"Habit save failed.")}}),i=ge({mutationFn:async({habitId:a,status:h,dateKey:u,note:z})=>fs(a,{status:h,dateKey:u,note:z}),onSuccess:async()=>{S(null),await G()},onError:a=>{S(a instanceof Error?a.message:"Habit check-in failed.")}}),t=ge({mutationFn:async a=>ps(a),onMutate:async a=>{await o.cancelQueries({queryKey:O});const h=o.getQueryData(O);return o.setQueryData(O,u=>(u==null?void 0:u.filter(z=>z.id!==a))??[]),{previousHabits:h}},onSuccess:async()=>{S(null),E(null),await G()},onError:(a,h,u)=>{u!=null&&u.previousHabits&&o.setQueryData(O,u.previousHabits),S(a instanceof Error?a.message:"Habit delete failed.")}}),n=p.useMemo(()=>($.data??[]).filter(a=>a.status!=="archived"),[$.data]),J=p.useMemo(()=>n.filter(a=>a.dueToday),[n]),We=p.useMemo(()=>J.reduce((a,h)=>{var re;const u=Ke().totalAp,z=((re=xe(h))==null?void 0:re.totalAp)??0;return a+u+z},0),[J]),Ge=p.useMemo(()=>n.reduce((a,h)=>{var u;return a+(((u=xe(h))==null?void 0:u.totalAp)??0)},0),[n]),X=p.useMemo(()=>c?c.habit.checkIns.find(a=>a.dateKey===c.cell.actionDateKey)??null:null,[c]);if(p.useEffect(()=>{if(!c){j(null),D("");return}j((X==null?void 0:X.status)??null),D((X==null?void 0:X.note)??"")},[c,X]),$.error)throw $.error;const Ue=a=>{f(h=>{const u=new URLSearchParams(h);return a==="name"?u.delete("orderBy"):u.set("orderBy",a),u},{replace:!0})},V=c?Gs(c.habit):null,fe=m==="done"||m==="missed"||X!==null;return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(Ns,{entityKind:"habit",title:e.jsx(Fe,{kind:"habit",label:"Habits",variant:"heading",size:"lg"}),titleText:"Habits",description:"Habits track recurring commitments and recurring slips with explicit daily consequences, linked behaviors, and real XP movement.",badge:`${n.length} habits`,actions:e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e.jsx(us,{metrics:s.snapshot.metrics}),e.jsxs(L,{onClick:()=>{T(null),w(!0)},children:[e.jsx(Ze,{className:"size-4"}),"New habit"]})]})}),R?e.jsx(A,{className:"border-[color-mix(in_srgb,var(--danger)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Je,{className:"mt-0.5 size-4 shrink-0"}),e.jsx("div",{children:R})]})}):null,e.jsxs("section",{className:"grid gap-4 lg:grid-cols-4",children:[e.jsxs(A,{className:"border-[color-mix(in_srgb,var(--warning)_22%,var(--ui-border-subtle)_78%)] shadow-[var(--ui-shadow-soft)]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Due today"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--primary)]",children:J.length}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Habits that still need a check-in today."})]}),e.jsxs(A,{className:"border-[color-mix(in_srgb,var(--primary)_22%,var(--ui-border-subtle)_78%)] shadow-[var(--ui-shadow-soft)]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Habit AP due"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--primary)]",children:U(We)}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Default Action Point load if every due habit is logged today."})]}),e.jsxs(A,{className:"border-[color-mix(in_srgb,var(--success)_22%,var(--ui-border-subtle)_78%)] shadow-[var(--ui-shadow-soft)]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Best streak"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]",children:Math.max(0,...n.map(a=>a.streakCount))}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Longest current aligned streak across active habits."})]}),e.jsxs(A,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Average alignment"}),e.jsxs("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:[n.length>0?Math.round(n.reduce((a,h)=>a+h.completionRate,0)/n.length):0,"%"]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Share of recent habit check-ins that matched the intended direction."})]})]}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)]",children:[e.jsxs(A,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Life Force sync"}),e.jsx("div",{className:"mt-3 text-2xl font-display text-[var(--ui-ink-strong)]",children:_.data?`${U(_.data.spentTodayAp)} / ${U(_.data.dailyBudgetAp)}`:"Loading..."}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Habit check-ins debit the same Action Point ledger as work, notes, movement, and workouts."})]}),e.jsxs(A,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Instant headroom"}),e.jsx("div",{className:"mt-3 text-2xl font-display text-[var(--ui-ink-strong)]",children:_.data?Me(_.data.instantFreeApPerHour):"Loading..."}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Use this to tell whether now is a good moment for heavier habits or just a light check-in."})]}),e.jsxs(A,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Workout-linked load"}),e.jsx("div",{className:"mt-3 text-2xl font-display text-[var(--ui-ink-strong)]",children:U(Ge)}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Habit-generated workout templates stay visible as Action Point cost instead of hiding behind the XP reward."})]})]}),$.isLoading?e.jsx(A,{children:"Loading habits..."}):n.length===0?e.jsx(ms,{eyebrow:"Habits",title:"No recurring habits yet",description:"Create the recurring commitments or recurring slips you want Forge to track explicitly. Positive habits pay out when completed. Negative habits invert that logic.",action:e.jsx(L,{onClick:()=>{T(null),w(!0)},children:"Create habit"})}):e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4 shadow-[var(--ui-shadow-soft)] sm:flex-row sm:items-end sm:justify-between",children:[e.jsxs("div",{className:"max-w-xl",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:"Habit list order"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Choose a stable ordering so the list does not reshuffle while you are logging check-ins."})]}),e.jsx(Ts,{label:"Order by",value:K,options:Xs,onChange:Ue,className:"w-full sm:w-[19rem]"})]}),e.jsx("div",{className:"grid gap-4 xl:grid-cols-2",children:n.map(a=>{const h=qe(a),u=Os(a.streakCount),z=u.Icon,re=Ke(),ie=xe(a),Qe=gs(s.snapshot.dashboard.notesSummaryByEntity,"habit",a.id).count,ne=a.polarity==="positive"?{label:"Done",status:Q(a,"aligned"),Icon:Ie,className:"border-[color-mix(in_srgb,var(--success)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)] hover:bg-[color-mix(in_srgb,var(--success)_24%,var(--ui-surface-hover)_76%)]"}:{label:"Resisted",status:Q(a,"aligned"),Icon:Ce,className:"border-[color-mix(in_srgb,var(--success)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)] hover:bg-[color-mix(in_srgb,var(--success)_24%,var(--ui-surface-hover)_76%)]"},le=a.polarity==="positive"?{label:"Missed",status:Q(a,"unaligned"),Icon:Pe,className:"border-[color-mix(in_srgb,var(--danger)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)] hover:bg-[color-mix(in_srgb,var(--danger)_22%,var(--ui-surface-hover)_78%)]"}:{label:"Performed",status:Q(a,"unaligned"),Icon:as,className:"border-[color-mix(in_srgb,var(--danger)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)] hover:bg-[color-mix(in_srgb,var(--danger)_22%,var(--ui-surface-hover)_78%)]"};return e.jsxs(A,{className:P("relative flex h-full flex-col overflow-hidden",h.cardClass,_s(te===a.id)),"data-psyche-focus-id":a.id,children:[e.jsx("div",{className:P("pointer-events-none absolute inset-0 opacity-100",h.overlayClass)}),e.jsxs("div",{className:"relative z-10 flex h-full flex-col",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Fe,{kind:"habit",label:a.title,variant:"heading",size:"sm"}),e.jsx(Hs,{user:a.user,compact:!0}),e.jsx(v,{className:se,children:a.status}),e.jsxs(v,{className:se,children:[e.jsx(Ve,{className:"mr-1 size-3.5"}),Rs(a)]}),e.jsx(v,{className:a.polarity==="positive"?Re:Oe,children:a.polarity==="positive"?"Positive":"Negative"}),a.dueToday?e.jsx(v,{className:ce,children:"Needs check-in"}):null,a.linkedGoalIds.slice(0,1).map(g=>{const l=s.snapshot.goals.find(x=>x.id===g);return l?e.jsxs(v,{className:ce,children:["Goal · ",l.title]},l.id):null}),a.linkedProjectIds.slice(0,1).map(g=>{const l=s.snapshot.dashboard.projects.find(x=>x.id===g);return l?e.jsxs(v,{className:be,children:["Project · ",l.title]},l.id):null}),a.linkedTaskIds.slice(0,1).map(g=>{const l=s.snapshot.tasks.find(x=>x.id===g);return l?e.jsxs(v,{className:ae,children:["Task · ",l.title]},l.id):null})]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-medium)]",children:a.description?e.jsx(ds,{markdown:a.description,className:"[&>p]:text-sm [&>p]:leading-6 [&>blockquote]:text-sm [&>ul]:text-sm [&>ol]:text-sm"}):"No extra notes yet."})]}),e.jsxs("div",{className:"ml-auto inline-flex shrink-0 flex-col items-end gap-2 self-start text-right",children:[e.jsxs("div",{className:P("inline-flex flex-col self-end rounded-[20px] px-3 py-2.5 text-right",u.className),children:[e.jsxs("div",{className:"flex items-center justify-end gap-1.5 text-[10px] uppercase tracking-[0.16em]",children:[e.jsx("span",{children:"Streak"}),e.jsx(z,{className:P("size-3.5 shrink-0",u.iconClass)})]}),e.jsx("div",{className:P("mt-1.5 font-display text-[2.75rem] leading-none",u.valueClass),children:a.streakCount}),e.jsx("div",{className:"mt-1 text-[11px] leading-tight text-[var(--ui-ink-soft)]",children:u.label})]}),e.jsxs("div",{className:"ml-auto grid grid-cols-2 gap-1.5",children:[e.jsx(L,{variant:"ghost",size:"sm",className:"h-7 min-w-0 rounded-[11px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",disabled:r.isPending,onClick:()=>{T(a),w(!0)},"aria-label":`Edit ${a.title}`,title:"Edit habit",children:e.jsx(es,{className:"size-4"})}),e.jsx(L,{variant:"ghost",size:"sm",className:"h-7 min-w-0 rounded-[11px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",disabled:t.isPending,onClick:()=>E(a),"aria-label":`Delete ${a.title}`,title:"Delete habit",children:e.jsx(ss,{className:"size-4"})})]})]})]}),e.jsxs("div",{className:"mt-auto grid gap-4 pt-5",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(v,{className:P("",$s(a.completionRate)),children:["Alignment ",a.completionRate,"%"]}),e.jsx(v,{className:se,children:a.polarity==="positive"?`+${a.rewardXp} XP done`:`+${a.rewardXp} XP resisted`}),e.jsx(v,{className:se,children:a.polarity==="positive"?`-${a.penaltyXp} XP missed`:`-${a.penaltyXp} XP performed`}),e.jsxs(v,{className:ae,children:[U(re.totalAp)," check-in"]}),ie?e.jsxs(v,{className:ce,children:[U(ie.totalAp)," ","workout"]}):null,ie?e.jsx(v,{className:se,children:Me(ie.rateApPerHour)}):null,e.jsx(os,{entityType:"habit",entityId:a.id,count:Qe,className:"min-h-8 rounded-full border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-1.5 text-[12px] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)]"}),a.linkedBehaviorTitles.slice(0,2).map(g=>e.jsxs(v,{className:ce,children:[e.jsx(Ce,{className:"mr-1 size-3.5"}),g]},g)),a.linkedProjectIds.slice(1,2).map(g=>{const l=s.snapshot.dashboard.projects.find(x=>x.id===g);return l?e.jsxs(v,{className:be,children:["Project · ",l.title]},l.id):null}),a.linkedTaskIds.slice(1,2).map(g=>{const l=s.snapshot.tasks.find(x=>x.id===g);return l?e.jsxs(v,{className:ae,children:["Task · ",l.title]},l.id):null}),a.linkedValueIds.slice(0,2).map(g=>{var x;const l=(x=I.data)==null?void 0:x.values.find(B=>B.id===g);return l?e.jsxs(v,{className:Re,children:["Value · ",l.title]},l.id):null}),a.linkedPatternIds.slice(0,2).map(g=>{var x;const l=(x=I.data)==null?void 0:x.patterns.find(B=>B.id===g);return l?e.jsxs(v,{className:be,children:["Pattern · ",l.title]},l.id):null}),a.linkedBeliefIds.slice(0,2).map(g=>{var x;const l=(x=I.data)==null?void 0:x.beliefs.find(B=>B.id===g);return l?e.jsxs(v,{className:Oe,children:["Belief · ",l.statement]},l.id):null}),a.linkedModeIds.slice(0,2).map(g=>{var x;const l=(x=I.data)==null?void 0:x.modes.find(B=>B.id===g);return l?e.jsxs(v,{className:ae,children:["Mode · ",l.title]},l.id):null}),a.linkedReportIds.slice(0,2).map(g=>{var x;const l=(x=I.data)==null?void 0:x.reports.find(B=>B.id===g);return l?e.jsxs(v,{className:ae,children:["Report · ",l.title]},l.id):null})]}),e.jsx("div",{className:"grid gap-4",children:e.jsx(Ws,{habit:a,onSelectCell:(g,l)=>{y({habit:g,cell:l}),S(null)}})}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs(L,{variant:"secondary",className:P("h-11 rounded-[16px] border",ne.className),disabled:i.isPending,onClick:()=>void i.mutateAsync({habitId:a.id,status:ne.status,dateKey:W(new Date)}),children:[e.jsx(ne.Icon,{className:"size-4"}),ne.label]}),e.jsxs(L,{variant:"secondary",className:P("h-11 rounded-[16px] border",le.className),disabled:i.isPending,onClick:()=>void i.mutateAsync({habitId:a.id,status:le.status,dateKey:W(new Date)}),children:[e.jsx(le.Icon,{className:"size-4"}),le.label]})]})]})]})]},a.id)})})]}),e.jsx(Fs,{open:M,pending:r.isPending,editingHabit:k,values:((ke=I.data)==null?void 0:ke.values)??[],patterns:((ye=I.data)==null?void 0:ye.patterns)??[],behaviors:((je=I.data)==null?void 0:je.behaviors)??[],beliefs:((we=I.data)==null?void 0:we.beliefs)??[],modes:((_e=I.data)==null?void 0:_e.modes)??[],reports:((Ne=I.data)==null?void 0:Ne.reports)??[],goals:s.snapshot.dashboard.goals,projects:s.snapshot.dashboard.projects,tasks:s.snapshot.tasks,users:s.snapshot.users,defaultUserId:(k==null?void 0:k.userId)??Z,onOpenChange:w,onSubmit:async(a,h)=>{try{await r.mutateAsync({input:a,habitId:h})}catch(u){throw u instanceof xs,u}}}),e.jsx(Le,{open:N!==null,onOpenChange:a=>{!a&&!t.isPending&&E(null)},children:e.jsxs(Se,{children:[e.jsx(Te,{className:"surface-overlay fixed inset-0 z-40 backdrop-blur-xl"}),e.jsxs(He,{className:"surface-modal-panel fixed inset-x-4 top-1/2 z-50 mx-auto w-[min(30rem,calc(100vw-2rem))] max-w-[30rem] -translate-y-1/2 overflow-hidden rounded-[30px] border",children:[e.jsx("div",{className:"border-b border-[var(--ui-border-subtle)] px-5 py-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Delete habit"}),e.jsx(Ee,{className:"mt-2 text-lg font-semibold text-[var(--ui-ink-strong)]",children:(N==null?void 0:N.title)??"Delete this habit?"}),e.jsx(Ae,{className:"mt-3 text-sm text-[var(--ui-ink-soft)]",children:"Remove this habit from Forge. The habit card disappears immediately after delete succeeds."})]}),e.jsx(Be,{asChild:!0,children:e.jsx(L,{variant:"ghost",size:"sm",className:"h-10 w-10 rounded-[14px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-0 text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]","aria-label":"Close delete habit modal",title:"Close",disabled:t.isPending,children:e.jsx(De,{className:"size-4"})})})]})}),e.jsxs("div",{className:"grid gap-4 p-5",children:[e.jsx("div",{className:"rounded-[20px] border border-[color-mix(in_srgb,var(--danger)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-danger-soft)] px-4 py-3 text-sm leading-6 text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",children:"This removes the habit and its check-in history from the habits page."}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-3",children:[e.jsx(L,{variant:"secondary",onClick:()=>E(null),disabled:t.isPending,children:"Cancel"}),e.jsx(L,{className:"border border-[color-mix(in_srgb,var(--danger)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)] hover:bg-[color-mix(in_srgb,var(--danger)_22%,var(--ui-surface-hover)_78%)]",pending:t.isPending,pendingLabel:"Deleting",onClick:()=>{N&&t.mutateAsync(N.id)},children:"Delete habit"})]})]})]})]})}),e.jsx(Le,{open:c!==null,onOpenChange:a=>{a||y(null)},children:e.jsxs(Se,{children:[e.jsx(Te,{className:"surface-overlay fixed inset-0 z-40 backdrop-blur-xl"}),e.jsxs(He,{className:"surface-modal-panel fixed inset-x-4 top-1/2 z-50 mx-auto w-[min(42rem,calc(100vw-2rem))] max-w-[42rem] -translate-y-1/2 overflow-hidden rounded-[30px] border",children:[e.jsx(Ee,{className:"sr-only",children:"Habit history"}),e.jsx(Ae,{className:"sr-only",children:"Log or revise a habit check-in for a selected history point."}),c&&V?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-b border-[var(--ui-border-subtle)] px-5 py-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Habit history"}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"text-lg font-semibold text-[var(--ui-ink-strong)]",children:c.habit.title}),e.jsx(v,{children:c.cell.actionLabel})]}),e.jsx("div",{className:"mt-3 text-sm text-[var(--ui-ink-soft)]",children:c.habit.frequency==="daily"?"Log or revise the check-in for this specific day.":"Log or revise the representative check-in for this week."})]}),e.jsx(Be,{asChild:!0,children:e.jsx(L,{variant:"ghost",size:"sm",className:"h-10 w-10 rounded-[14px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-0 text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]","aria-label":"Close history modal",title:"Close",children:e.jsx(De,{className:"size-4"})})})]})}),e.jsxs("div",{className:"grid gap-4 p-5",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("button",{type:"button","aria-pressed":m!==null&&Y(c.habit,m)==="aligned",className:P("rounded-[22px] border px-4 py-4 text-left transition",m!==null&&Y(c.habit,m)==="aligned"?"border-[color-mix(in_srgb,var(--success)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)]"),onClick:()=>j(a=>a!==null&&Y(c.habit,a)==="aligned"?null:Q(c.habit,"aligned")),children:[e.jsxs("div",{className:"flex items-center gap-2 text-base font-medium",children:[e.jsx(Ie,{className:"size-4"}),V.alignedLabel]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:V.alignedDescription})]}),e.jsxs("button",{type:"button","aria-pressed":m!==null&&Y(c.habit,m)==="unaligned",className:P("rounded-[22px] border px-4 py-4 text-left transition",m!==null&&Y(c.habit,m)==="unaligned"?"border-[color-mix(in_srgb,var(--danger)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)]"),onClick:()=>j(a=>a!==null&&Y(c.habit,a)==="unaligned"?null:Q(c.habit,"unaligned")),children:[e.jsxs("div",{className:"flex items-center gap-2 text-base font-medium",children:[e.jsx(Pe,{className:"size-4"}),V.unalignedLabel]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:V.unalignedDescription})]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:"Optional note"}),e.jsx(ve,{value:H,onChange:a=>D(a.target.value),placeholder:"Add context for what happened on this day or week.",className:"min-h-24"})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-3",children:[e.jsx(L,{variant:"secondary",onClick:()=>y(null),disabled:i.isPending,children:"Cancel"}),e.jsx(L,{disabled:i.isPending||!fe,pending:i.isPending,pendingLabel:"Saving",onClick:async()=>{fe&&(m===null?(await hs(c.habit.id,c.cell.actionDateKey),await G()):await i.mutateAsync({habitId:c.habit.id,status:m,dateKey:c.cell.actionDateKey,note:H.trim()||void 0}),y(null))},children:"Save check-in"})]})]})]}):null]})]})})]})}export{ma as HabitsPage};
|
|
1
|
+
import{r as p,j as e,bY as Ye,aG as Ze,c7 as Je,aV as Ve,c8 as es,c1 as ss,b$ as Ce,bF as Ie,c9 as Pe,ca as as,aK as De,cb as ts,cc as rs,cd as is,ce as ns}from"./vendor-BwL6m4SE.js";import{R as Le,P as Se,O as Te,C as He,T as Ee,D as Ae,a as Be}from"./ui-B9TWEtCx.js";import{j as ls,i as me,k as ge}from"./state-Bpe5dF3T.js";import{E as os}from"./entity-note-count-link-Bs1aKYyD.js";import{N as ds}from"./note-markdown-DXXI3W3V.js";import{I as q,T as ve,b as F,d as cs,U as xe,V as us,B as L,E as Fe,C as A,n as U,m as Me,h as ms,R as gs,c as P,k as v,W as xs,X as hs,Y as Ke,Z as bs,_ as vs,$ as ps,a0 as fs,a1 as ks,a2 as ys,O as js}from"./index-FpGANF9S.js";import{u as ws,p as _s}from"./use-psyche-focus-target-BhNedCZB.js";import{P as Ns}from"./page-hero-DvrM83_C.js";import{Q as Cs,F as b,a as oe}from"./question-flow-dialog-Ded2E85L.js";import{U as Is}from"./user-select-field-fx129Uh6.js";import{a as Ps,c as Ds,g as Ls}from"./user-ownership-DJGl4rAj.js";import{h as Ss}from"./schemas-Db29G8NU.js";import{S as Ts}from"./select-menu-BF2zI3RW.js";import{U as Hs}from"./user-badge-ByhC6bMU.js";import{f as Es}from"./date-keys-BnZV4PNO.js";import"./motion-DcgUnXhY.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";const he={title:"",description:"",status:"active",userId:null,polarity:"positive",frequency:"daily",targetCount:1,weekDays:[],linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],linkedValueIds:[],linkedPatternIds:[],linkedBehaviorIds:[],linkedBeliefIds:[],linkedModeIds:[],linkedReportIds:[],linkedBehaviorId:"",rewardXp:12,penaltyXp:8,generatedHealthEventTemplate:{enabled:!1,workoutType:"workout",title:"",durationMinutes:45,xpReward:0,tags:[],links:[],notesTemplate:""}},As=[{value:1,label:"Mon"},{value:2,label:"Tue"},{value:3,label:"Wed"},{value:4,label:"Thu"},{value:5,label:"Fri"},{value:6,label:"Sat"},{value:0,label:"Sun"}];function Bs(s){return{title:s.title,description:s.description,status:s.status,userId:s.userId??null,polarity:s.polarity,frequency:s.frequency,targetCount:s.targetCount,weekDays:s.weekDays,linkedGoalIds:s.linkedGoalIds,linkedProjectIds:s.linkedProjectIds,linkedTaskIds:s.linkedTaskIds,linkedValueIds:s.linkedValueIds,linkedPatternIds:s.linkedPatternIds,linkedBehaviorIds:s.linkedBehaviorIds,linkedBeliefIds:s.linkedBeliefIds,linkedModeIds:s.linkedModeIds,linkedReportIds:s.linkedReportIds,linkedBehaviorId:s.linkedBehaviorId??"",rewardXp:s.rewardXp,penaltyXp:s.penaltyXp,generatedHealthEventTemplate:s.generatedHealthEventTemplate}}function Fs({open:s,pending:o=!1,editingHabit:d,values:f,patterns:k,behaviors:T,beliefs:c,modes:y,reports:m,goals:j,projects:H,tasks:D,users:M,defaultUserId:w=null,onOpenChange:N,onSubmit:E}){const[R,S]=p.useState(he),[te,K]=p.useState(null),[C,Z]=p.useState({});p.useEffect(()=>{s&&(S(d?Bs(d):{...he,userId:w}),K(null),Z({}))},[w,d,s]);const O=M.find(r=>r.id===w)??null,$=p.useMemo(()=>T.slice().sort((r,i)=>r.title.localeCompare(i.title)),[T]),I=r=>({linkedBehaviorIds:r,linkedBehaviorId:r[0]??""}),_=(r,i)=>r.includes(i)?r.filter(t=>t!==i):[...r,i],G=[{id:"intent",eyebrow:"Habit",title:"Name the recurring move",description:"Use habits for recurring commitments and recurring slips. Keep the title concrete so the daily check-in never needs interpretation.",render:(r,i)=>e.jsxs(e.Fragment,{children:[e.jsx(b,{label:"Title",error:C.title??null,children:e.jsx(q,{value:r.title,onChange:t=>i({title:t.target.value}),placeholder:"Train lower body"})}),e.jsx(b,{label:"Description",children:e.jsx(ve,{value:r.description,onChange:t=>i({description:t.target.value}),placeholder:"Write the habit description in Markdown. Define what counts, edge cases, and examples."})}),e.jsx(Is,{value:r.userId,users:M,onChange:t=>i({userId:t}),label:"Owner user",defaultLabel:Ps(O),help:"Habits can be owned by humans or bots. When one scoped user is active, Forge uses that as the default."})]})},{id:"shape",eyebrow:"Shape",title:"Set direction and cadence",description:"Forge uses polarity to decide whether doing the habit is good or bad, and cadence to know when it should show up.",render:(r,i)=>e.jsxs(e.Fragment,{children:[e.jsx(b,{label:"Polarity",children:e.jsx(oe,{value:r.polarity,onChange:t=>i({polarity:t}),options:[{value:"positive",label:"Positive",description:"Doing it is aligned and should award XP."},{value:"negative",label:"Negative",description:"Doing it is a slip and should cost XP."}],columns:2})}),e.jsx(b,{label:"Frequency",children:e.jsx(oe,{value:r.frequency,onChange:t=>i({frequency:t}),options:[{value:"daily",label:"Daily",description:"Track against each day."},{value:"weekly",label:"Weekly",description:"Track only on the selected weekdays."}],columns:2})}),r.frequency==="weekly"?e.jsx(b,{label:"Weekdays",error:C.weekDays??null,children:e.jsx("div",{className:"flex flex-wrap gap-2",children:As.map(t=>{const n=r.weekDays.includes(t.value);return e.jsx("button",{type:"button",className:`rounded-full border px-3 py-2 text-sm transition ${n?"border-[color-mix(in_srgb,var(--primary)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"}`,onClick:()=>i({weekDays:n?r.weekDays.filter(J=>J!==t.value):[...r.weekDays,t.value].sort()}),children:t.label},t.value)})})}):null,e.jsx(b,{label:"Status",children:e.jsx(oe,{value:r.status,onChange:t=>i({status:t}),options:[{value:"active",label:"Active",description:"Show it in the daily operating flow."},{value:"paused",label:"Paused",description:"Keep it visible but not currently due."},{value:"archived",label:"Archived",description:"Keep the record but retire it from active work."}]})})]})},{id:"generation",eyebrow:"Generation",title:"Decide whether this habit should create a workout record",description:"Use this when a completed habit should generate a structured sports or recovery session in Forge, then reconcile with HealthKit later if the same session gets imported.",render:(r,i)=>e.jsxs(e.Fragment,{children:[e.jsx(b,{label:"Generate workout record",children:e.jsx(oe,{value:r.generatedHealthEventTemplate.enabled?"enabled":"disabled",onChange:t=>i({generatedHealthEventTemplate:{...r.generatedHealthEventTemplate,enabled:t==="enabled"}}),options:[{value:"disabled",label:"Disabled",description:"This habit only affects the habit ledger."},{value:"enabled",label:"Enabled",description:"A completed check-in creates a workout or recovery session."}],columns:2})}),r.generatedHealthEventTemplate.enabled?e.jsxs(e.Fragment,{children:[e.jsx(b,{label:"Workout type",children:e.jsx(q,{value:r.generatedHealthEventTemplate.workoutType,onChange:t=>i({generatedHealthEventTemplate:{...r.generatedHealthEventTemplate,workoutType:t.target.value}}),placeholder:"mobility, walk, strength, recovery"})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(b,{label:"Duration (minutes)",children:e.jsx(q,{type:"number",min:1,max:1440,value:r.generatedHealthEventTemplate.durationMinutes,onChange:t=>i({generatedHealthEventTemplate:{...r.generatedHealthEventTemplate,durationMinutes:Number(t.target.value)||45}})})}),e.jsx(b,{label:"Workout XP",children:e.jsx(q,{type:"number",min:0,max:500,value:r.generatedHealthEventTemplate.xpReward,onChange:t=>i({generatedHealthEventTemplate:{...r.generatedHealthEventTemplate,xpReward:Number(t.target.value)||0}})})})]}),e.jsx(b,{label:"Generated session note",children:e.jsx(ve,{value:r.generatedHealthEventTemplate.notesTemplate,onChange:t=>i({generatedHealthEventTemplate:{...r.generatedHealthEventTemplate,notesTemplate:t.target.value}}),placeholder:"Morning routine session generated from habit completion."})})]}):null]})},{id:"links",eyebrow:"Links",title:"Connect the habit to real Forge work",description:"Link habits to the goals, projects, and tasks they support so they stay anchored in the same operating graph as everything else.",render:(r,i)=>e.jsxs(e.Fragment,{children:[e.jsx(b,{label:"Goals",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:j.map(t=>{const n=r.linkedGoalIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedGoalIds:_(r.linkedGoalIds,t.id)}),children:e.jsx(F,{kind:"goal",label:t.title,gradient:n,className:n?"":"opacity-75"})},t.id)})})}),e.jsx(b,{label:"Projects",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:H.map(t=>{const n=r.linkedProjectIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedProjectIds:_(r.linkedProjectIds,t.id)}),children:e.jsx(F,{kind:"project",label:t.title,gradient:n,className:n?"":"opacity-75"})},t.id)})})}),e.jsx(b,{label:"Tasks",children:e.jsx("div",{className:"flex max-h-48 flex-wrap gap-2 overflow-y-auto",children:D.map(t=>{const n=r.linkedTaskIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedTaskIds:_(r.linkedTaskIds,t.id)}),children:e.jsx(F,{kind:"task",label:t.title,gradient:n,className:n?"":"opacity-75",wrap:!0})},t.id)})})}),e.jsx(b,{label:"Values",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:f.map(t=>{const n=r.linkedValueIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedValueIds:_(r.linkedValueIds,t.id)}),children:e.jsx(F,{kind:"value",label:t.title,gradient:n,className:n?"":"opacity-75"})},t.id)})})}),e.jsx(b,{label:"Patterns",children:e.jsx("div",{className:"flex max-h-44 flex-wrap gap-2 overflow-y-auto",children:k.map(t=>{const n=r.linkedPatternIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedPatternIds:_(r.linkedPatternIds,t.id)}),children:e.jsx(F,{kind:"pattern",label:t.title,gradient:n,className:n?"":"opacity-75",wrap:!0})},t.id)})})})]})},{id:"reward",eyebrow:"Reward",title:"Link the behavior and XP logic",description:"Habits can point back to a Psyche behavior. Reward XP is granted for aligned outcomes; penalty XP is applied for misaligned ones.",render:(r,i)=>e.jsxs(e.Fragment,{children:[e.jsx(b,{label:"Linked behavior",children:e.jsx("div",{className:"flex max-h-44 flex-wrap gap-2 overflow-y-auto",children:$.map(t=>{const n=r.linkedBehaviorIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i(I(_(r.linkedBehaviorIds,t.id))),children:e.jsx(F,{kind:"behavior",label:t.title,gradient:n,className:n?"":"opacity-75",wrap:!0})},t.id)})})}),e.jsx(b,{label:"Beliefs",children:e.jsx("div",{className:"flex max-h-44 flex-wrap gap-2 overflow-y-auto",children:c.map(t=>{const n=r.linkedBeliefIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedBeliefIds:_(r.linkedBeliefIds,t.id)}),children:e.jsx(F,{kind:"belief",label:t.statement,gradient:n,className:n?"":"opacity-75",wrap:!0})},t.id)})})}),e.jsx(b,{label:"Modes",children:e.jsx("div",{className:"flex max-h-44 flex-wrap gap-2 overflow-y-auto",children:y.map(t=>{const n=r.linkedModeIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedModeIds:_(r.linkedModeIds,t.id)}),children:e.jsx(F,{kind:"mode",label:t.title,gradient:n,className:n?"":"opacity-75",wrap:!0})},t.id)})})}),e.jsx(b,{label:"Reports",children:e.jsx("div",{className:"flex max-h-44 flex-wrap gap-2 overflow-y-auto",children:m.map(t=>{const n=r.linkedReportIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedReportIds:_(r.linkedReportIds,t.id)}),children:e.jsx(F,{kind:"report",label:t.title,gradient:n,className:n?"":"opacity-75",wrap:!0})},t.id)})})}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[e.jsx(b,{label:"Target count",error:C.targetCount??null,children:e.jsx(q,{type:"number",value:r.targetCount,onChange:t=>i({targetCount:Number(t.target.value)||1})})}),e.jsx(b,{label:"Reward XP",error:C.rewardXp??null,children:e.jsx(q,{type:"number",value:r.rewardXp,onChange:t=>i({rewardXp:Number(t.target.value)||1})})}),e.jsx(b,{label:"Penalty XP",error:C.penaltyXp??null,children:e.jsx(q,{type:"number",value:r.penaltyXp,onChange:t=>i({penaltyXp:Number(t.target.value)||1})})})]})]})}];return e.jsx(Cs,{open:s,onOpenChange:N,eyebrow:"Habit",title:d?"Edit habit":"Create habit",description:"Habits are recurring commitments or recurring slips with explicit XP consequences.",value:R,onChange:S,draftPersistenceKey:d?`habit.${d.id}`:"habit.new",steps:G,pending:o,pendingLabel:d?"Save habit":"Create habit",submitLabel:d?"Save habit":"Create habit",error:te,onSubmit:async()=>{K(null);const r=Ss.safeParse(R);if(!r.success){Z(Object.fromEntries(Object.entries(r.error.flatten().fieldErrors).map(([i,t])=>[i,t==null?void 0:t[0]]))),K("Some habit fields still need attention.");return}Z({});try{await E(r.data,d==null?void 0:d.id),S(he),N(!1)}catch(i){K(i instanceof Error?i.message:"Habit update failed.")}}})}const Ms=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Ks=["S","M","T","W","T","F","S"],Xs=[{value:"name",label:"Name A-Z",description:"Keep the list stable alphabetically."},{value:"needs_attention",label:"Needs attention",description:"Bubble up habits still waiting on today."},{value:"streak",label:"Longest streak",description:"Put the strongest current streaks first."},{value:"created_at",label:"Newest created",description:"Show the most recently created habits first."},{value:"updated_at",label:"Recently updated",description:"Sort by the most recently changed habits."}];function Rs(s){return s.frequency==="daily"?`${s.targetCount}x daily`:`${s.targetCount}x weekly · ${s.weekDays.map(o=>Ms[o]).join(", ")}`}function W(s){return Es(s)}function $e(s){const[o,d,f]=s.split("-").map(Number);return new Date(o,d-1,f)}function ze(s){return new Date(s.getFullYear(),s.getMonth(),s.getDate())}function de(s,o){const d=new Date(s);return d.setDate(d.getDate()+o),d}function Xe(s){const o=ze(s),d=(o.getDay()+6)%7;return o.setDate(o.getDate()-d),o}function ee(s){const o=typeof s=="string"?$e(s):s;return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(o)}function ue(s,o){return s.polarity==="positive"&&o==="done"||s.polarity==="negative"&&o==="missed"}function pe(s,o){return s.polarity==="positive"?o==="done"?"Done":"Missed":o==="done"?"Performed":"Resisted"}function qe(s){const o=W(new Date),d=s.checkIns.find(f=>f.dateKey===o)??null;return s.dueToday?{tone:"pending",label:s.frequency==="daily"?"Waiting for today":"Awaiting this week's check-in",cardClass:"border-[color-mix(in_srgb,var(--warning)_28%,var(--ui-border-subtle)_72%)] shadow-[var(--ui-shadow-soft)]",overlayClass:"bg-[radial-gradient(circle_at_top_right,color-mix(in_srgb,var(--warning)_18%,transparent),transparent_44%)]",pillClass:"border border-[color-mix(in_srgb,var(--warning)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]"}:d?ue(s,d.status)?{tone:"aligned",label:`${pe(s,d.status)} today`,cardClass:"border-[color-mix(in_srgb,var(--success)_24%,var(--ui-border-subtle)_76%)] shadow-[var(--ui-shadow-soft)]",overlayClass:"bg-[radial-gradient(circle_at_top_right,color-mix(in_srgb,var(--success)_16%,transparent),transparent_44%)]",pillClass:"border border-[color-mix(in_srgb,var(--success)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]"}:{tone:"unaligned",label:`${pe(s,d.status)} today`,cardClass:"border-[color-mix(in_srgb,var(--danger)_24%,var(--ui-border-subtle)_76%)] shadow-[var(--ui-shadow-soft)]",overlayClass:"bg-[radial-gradient(circle_at_top_right,color-mix(in_srgb,var(--danger)_16%,transparent),transparent_44%)]",pillClass:"border border-[color-mix(in_srgb,var(--danger)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]"}:s.polarity==="positive"?{tone:"neutral",label:"No update due right now",cardClass:"",overlayClass:"bg-[radial-gradient(circle_at_top_right,color-mix(in_srgb,var(--success)_9%,transparent),transparent_40%)]",pillClass:"border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]"}:{tone:"neutral",label:"No update due right now",cardClass:"",overlayClass:"bg-[radial-gradient(circle_at_top_right,color-mix(in_srgb,var(--danger)_9%,transparent),transparent_40%)]",pillClass:"border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]"}}function Os(s){return s>=10?{Icon:ts,className:"border border-[color-mix(in_srgb,var(--warning)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)] shadow-[var(--ui-shadow-soft)]",iconClass:"text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]",valueClass:"text-[var(--ui-ink-strong)]",label:"Celebration pace"}:s>=5?{Icon:rs,className:"border border-[color-mix(in_srgb,var(--success)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)]",iconClass:"text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]",valueClass:"text-[var(--ui-ink-strong)]",label:"Locked in"}:s>=1?{Icon:is,className:"border border-[color-mix(in_srgb,var(--info)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)]",iconClass:"text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]",valueClass:"text-[var(--ui-ink-strong)]",label:"Building rhythm"}:{Icon:ns,className:"border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] shadow-[var(--ui-shadow-soft)]",iconClass:"text-[var(--ui-ink-soft)]",valueClass:"text-[var(--ui-ink-strong)]",label:"Cold start"}}function $s(s){return s>=80?"border-[color-mix(in_srgb,var(--success)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]":s>=50?"border-[color-mix(in_srgb,var(--warning)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]":"border-[color-mix(in_srgb,var(--danger)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]"}const se="border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",Re="border-[color-mix(in_srgb,var(--success)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]",Oe="border-[color-mix(in_srgb,var(--danger)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",ce="border-[color-mix(in_srgb,var(--warning)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]",be="border-[color-mix(in_srgb,var(--info)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]",ae="border-[color-mix(in_srgb,var(--primary)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-accent-soft)] text-[color-mix(in_srgb,var(--primary)_72%,var(--ui-ink-strong)_28%)]";function zs(s){var T;const o=new Date;if(s.frequency==="daily"){const c=ze(o),y=[];for(let m=-6;m<=0;m+=1){const j=de(c,m),H=W(j),D=s.checkIns.find(N=>N.dateKey===H)??null,M=Ks[j.getDay()],w=m===0;y.push({id:H,label:M,current:w,actionDateKey:H,actionLabel:ee(j),state:D?ue(s,D.status)?"aligned":"unaligned":"unknown",title:`${ee(j)} · ${D?pe(s,D.status):"Not informed"}`})}return{caption:"7-day rhythm",rangeLabel:"Past 7 days",showLabels:!0,startLabel:"",endLabel:"",cells:y}}const d=Xe(o),f=new Map;for(const c of s.checkIns){const y=W(Xe($e(c.dateKey))),m=f.get(y)??[];m.push(c),f.set(y,m)}const k=[];for(let c=-6;c<=0;c+=1){const y=de(d,c*7),m=W(y),j=f.get(m)??[],H=s.weekDays.length>0?[...s.weekDays].sort((E,R)=>R-E)[0]:0,D=W(de(y,H)),M=((T=j[0])==null?void 0:T.dateKey)??D,w=j.filter(E=>ue(s,E.status)).length,N=j.length-w;k.push({id:m,label:"",current:c===0,actionDateKey:M,actionLabel:`Week of ${ee(y)}`,state:j.length===0?"unknown":w>=N?"aligned":"unaligned",title:`${ee(y)} week · ${j.length===0?"Not informed":w>=N?"Mostly aligned":"Mostly off track"}`})}return{caption:"7-week rhythm",rangeLabel:"Past 7 weeks",showLabels:!1,startLabel:ee(de(d,-42)),endLabel:"This week",cells:k}}function qs(s,o){return P("h-8 w-full rounded-[10px] border transition",s==="aligned"&&"border-[color-mix(in_srgb,var(--success)_30%,var(--ui-border-subtle)_70%)] bg-[color-mix(in_srgb,var(--success)_58%,var(--ui-surface-1)_42%)] shadow-[var(--ui-shadow-soft)]",s==="unaligned"&&"border-[color-mix(in_srgb,var(--danger)_30%,var(--ui-border-subtle)_70%)] bg-[color-mix(in_srgb,var(--danger)_54%,var(--ui-surface-1)_46%)] shadow-[var(--ui-shadow-soft)]",s==="unknown"&&"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]",o&&"ring-1 ring-[color-mix(in_srgb,var(--primary)_34%,transparent)]")}function Ws({habit:s,onSelectCell:o}){const d=zs(s),f=qe(s);return e.jsxs("div",{className:"w-full rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-2.5 shadow-[var(--ui-shadow-soft)]",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"shrink-0",children:[e.jsx("div",{className:"font-label text-[10px] uppercase tracking-[0.16em] text-[var(--ui-ink-muted)]",children:d.caption}),e.jsx("div",{className:"text-[11px] text-[var(--ui-ink-soft)]",children:d.rangeLabel})]}),e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:d.cells.map(k=>e.jsxs("button",{type:"button",className:"group flex min-w-0 flex-1 items-center gap-1 rounded-[10px] transition hover:bg-[var(--ui-surface-hover)]",onClick:()=>o(s,k),title:`Log check-in for ${k.actionLabel}`,"aria-label":`Log check-in for ${k.actionLabel}`,children:[e.jsx("div",{className:P(qs(k.state,k.current),"h-6 min-w-0 flex-1 rounded-[8px] transition duration-150 group-hover:-translate-y-0.5 group-hover:shadow-[var(--ui-shadow-soft)]")}),d.showLabels?e.jsx("span",{className:"hidden text-[9px] uppercase tracking-[0.14em] text-[var(--ui-ink-muted)] transition group-hover:text-[var(--ui-ink-medium)] sm:inline",children:k.label}):null]},k.id))}),e.jsx("div",{className:P("shrink-0 rounded-full px-2.5 py-1 text-[10px] font-medium",f.pillClass),children:f.label})]}),d.showLabels?null:e.jsxs("div",{className:"mt-1 text-right text-[10px] uppercase tracking-[0.14em] text-[var(--ui-ink-muted)]",children:[d.startLabel," - ",d.endLabel]})]})}function Gs(s){return s.polarity==="positive"?{alignedLabel:"Done",alignedDescription:"Log that the intended habit happened.",unalignedLabel:"Missed",unalignedDescription:"Log that the habit did not happen."}:{alignedLabel:"Resisted",alignedDescription:"Log that the unwanted behavior was resisted.",unalignedLabel:"Performed",unalignedDescription:"Log that the unwanted behavior happened."}}function Q(s,o){return s.polarity==="positive"?o==="aligned"?"done":"missed":o==="aligned"?"missed":"done"}function Y(s,o){return ue(s,o)?"aligned":"unaligned"}function ma(){var ke,ye,je,we,_e,Ne;const s=cs(),o=ls(),[d,f]=Ye(),[k,T]=p.useState(null),[c,y]=p.useState(null),[m,j]=p.useState(null),[H,D]=p.useState(""),[M,w]=p.useState(!1),[N,E]=p.useState(null),[R,S]=p.useState(null),te=d.get("focus"),K=d.get("orderBy")??"name",C=Ds(s.selectedUserIds),Z=Ls(C),O=["forge-habits",K,...C];ws(te);const $=me({queryKey:O,queryFn:async()=>(await ks({userIds:C,orderBy:K})).habits}),I=me({queryKey:["forge-psyche-overview",...C],queryFn:async()=>(await ys(C)).overview}),_=me({queryKey:["forge-life-force",...C],queryFn:async()=>(await js(C)).lifeForce});p.useEffect(()=>{d.get("create")==="1"&&(T(null),w(!0),f(a=>{const h=new URLSearchParams(a);return h.delete("create"),h},{replace:!0}))},[d,f]);const G=async()=>{await o.invalidateQueries({queryKey:["forge-habits"]}),await s.refresh()},r=ge({mutationFn:async({input:a,habitId:h})=>h?(await bs(h,a)).habit:(await vs(a)).habit,onSuccess:async()=>{S(null),await G()},onError:a=>{S(a instanceof Error?a.message:"Habit save failed.")}}),i=ge({mutationFn:async({habitId:a,status:h,dateKey:u,note:z})=>fs(a,{status:h,dateKey:u,note:z}),onSuccess:async()=>{S(null),await G()},onError:a=>{S(a instanceof Error?a.message:"Habit check-in failed.")}}),t=ge({mutationFn:async a=>ps(a),onMutate:async a=>{await o.cancelQueries({queryKey:O});const h=o.getQueryData(O);return o.setQueryData(O,u=>(u==null?void 0:u.filter(z=>z.id!==a))??[]),{previousHabits:h}},onSuccess:async()=>{S(null),E(null),await G()},onError:(a,h,u)=>{u!=null&&u.previousHabits&&o.setQueryData(O,u.previousHabits),S(a instanceof Error?a.message:"Habit delete failed.")}}),n=p.useMemo(()=>($.data??[]).filter(a=>a.status!=="archived"),[$.data]),J=p.useMemo(()=>n.filter(a=>a.dueToday),[n]),We=p.useMemo(()=>J.reduce((a,h)=>{var re;const u=Ke().totalAp,z=((re=xe(h))==null?void 0:re.totalAp)??0;return a+u+z},0),[J]),Ge=p.useMemo(()=>n.reduce((a,h)=>{var u;return a+(((u=xe(h))==null?void 0:u.totalAp)??0)},0),[n]),X=p.useMemo(()=>c?c.habit.checkIns.find(a=>a.dateKey===c.cell.actionDateKey)??null:null,[c]);if(p.useEffect(()=>{if(!c){j(null),D("");return}j((X==null?void 0:X.status)??null),D((X==null?void 0:X.note)??"")},[c,X]),$.error)throw $.error;const Ue=a=>{f(h=>{const u=new URLSearchParams(h);return a==="name"?u.delete("orderBy"):u.set("orderBy",a),u},{replace:!0})},V=c?Gs(c.habit):null,fe=m==="done"||m==="missed"||X!==null;return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(Ns,{entityKind:"habit",title:e.jsx(Fe,{kind:"habit",label:"Habits",variant:"heading",size:"lg"}),titleText:"Habits",description:"Habits track recurring commitments and recurring slips with explicit daily consequences, linked behaviors, and real XP movement.",badge:`${n.length} habits`,actions:e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e.jsx(us,{metrics:s.snapshot.metrics}),e.jsxs(L,{onClick:()=>{T(null),w(!0)},children:[e.jsx(Ze,{className:"size-4"}),"New habit"]})]})}),R?e.jsx(A,{className:"border-[color-mix(in_srgb,var(--danger)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Je,{className:"mt-0.5 size-4 shrink-0"}),e.jsx("div",{children:R})]})}):null,e.jsxs("section",{className:"grid gap-4 lg:grid-cols-4",children:[e.jsxs(A,{className:"border-[color-mix(in_srgb,var(--warning)_22%,var(--ui-border-subtle)_78%)] shadow-[var(--ui-shadow-soft)]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Due today"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--primary)]",children:J.length}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Habits that still need a check-in today."})]}),e.jsxs(A,{className:"border-[color-mix(in_srgb,var(--primary)_22%,var(--ui-border-subtle)_78%)] shadow-[var(--ui-shadow-soft)]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Habit AP due"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--primary)]",children:U(We)}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Default Action Point load if every due habit is logged today."})]}),e.jsxs(A,{className:"border-[color-mix(in_srgb,var(--success)_22%,var(--ui-border-subtle)_78%)] shadow-[var(--ui-shadow-soft)]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Best streak"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]",children:Math.max(0,...n.map(a=>a.streakCount))}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Longest current aligned streak across active habits."})]}),e.jsxs(A,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Average alignment"}),e.jsxs("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:[n.length>0?Math.round(n.reduce((a,h)=>a+h.completionRate,0)/n.length):0,"%"]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Share of recent habit check-ins that matched the intended direction."})]})]}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)]",children:[e.jsxs(A,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Life Force sync"}),e.jsx("div",{className:"mt-3 text-2xl font-display text-[var(--ui-ink-strong)]",children:_.data?`${U(_.data.spentTodayAp)} / ${U(_.data.dailyBudgetAp)}`:"Loading..."}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Habit check-ins debit the same Action Point ledger as work, notes, movement, and workouts."})]}),e.jsxs(A,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Instant headroom"}),e.jsx("div",{className:"mt-3 text-2xl font-display text-[var(--ui-ink-strong)]",children:_.data?Me(_.data.instantFreeApPerHour):"Loading..."}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Use this to tell whether now is a good moment for heavier habits or just a light check-in."})]}),e.jsxs(A,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Workout-linked load"}),e.jsx("div",{className:"mt-3 text-2xl font-display text-[var(--ui-ink-strong)]",children:U(Ge)}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Habit-generated workout templates stay visible as Action Point cost instead of hiding behind the XP reward."})]})]}),$.isLoading?e.jsx(A,{children:"Loading habits..."}):n.length===0?e.jsx(ms,{eyebrow:"Habits",title:"No recurring habits yet",description:"Create the recurring commitments or recurring slips you want Forge to track explicitly. Positive habits pay out when completed. Negative habits invert that logic.",action:e.jsx(L,{onClick:()=>{T(null),w(!0)},children:"Create habit"})}):e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4 shadow-[var(--ui-shadow-soft)] sm:flex-row sm:items-end sm:justify-between",children:[e.jsxs("div",{className:"max-w-xl",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:"Habit list order"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Choose a stable ordering so the list does not reshuffle while you are logging check-ins."})]}),e.jsx(Ts,{label:"Order by",value:K,options:Xs,onChange:Ue,className:"w-full sm:w-[19rem]"})]}),e.jsx("div",{className:"grid gap-4 xl:grid-cols-2",children:n.map(a=>{const h=qe(a),u=Os(a.streakCount),z=u.Icon,re=Ke(),ie=xe(a),Qe=gs(s.snapshot.dashboard.notesSummaryByEntity,"habit",a.id).count,ne=a.polarity==="positive"?{label:"Done",status:Q(a,"aligned"),Icon:Ie,className:"border-[color-mix(in_srgb,var(--success)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)] hover:bg-[color-mix(in_srgb,var(--success)_24%,var(--ui-surface-hover)_76%)]"}:{label:"Resisted",status:Q(a,"aligned"),Icon:Ce,className:"border-[color-mix(in_srgb,var(--success)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)] hover:bg-[color-mix(in_srgb,var(--success)_24%,var(--ui-surface-hover)_76%)]"},le=a.polarity==="positive"?{label:"Missed",status:Q(a,"unaligned"),Icon:Pe,className:"border-[color-mix(in_srgb,var(--danger)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)] hover:bg-[color-mix(in_srgb,var(--danger)_22%,var(--ui-surface-hover)_78%)]"}:{label:"Performed",status:Q(a,"unaligned"),Icon:as,className:"border-[color-mix(in_srgb,var(--danger)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)] hover:bg-[color-mix(in_srgb,var(--danger)_22%,var(--ui-surface-hover)_78%)]"};return e.jsxs(A,{className:P("relative flex h-full flex-col overflow-hidden",h.cardClass,_s(te===a.id)),"data-psyche-focus-id":a.id,children:[e.jsx("div",{className:P("pointer-events-none absolute inset-0 opacity-100",h.overlayClass)}),e.jsxs("div",{className:"relative z-10 flex h-full flex-col",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Fe,{kind:"habit",label:a.title,variant:"heading",size:"sm"}),e.jsx(Hs,{user:a.user,compact:!0}),e.jsx(v,{className:se,children:a.status}),e.jsxs(v,{className:se,children:[e.jsx(Ve,{className:"mr-1 size-3.5"}),Rs(a)]}),e.jsx(v,{className:a.polarity==="positive"?Re:Oe,children:a.polarity==="positive"?"Positive":"Negative"}),a.dueToday?e.jsx(v,{className:ce,children:"Needs check-in"}):null,a.linkedGoalIds.slice(0,1).map(g=>{const l=s.snapshot.goals.find(x=>x.id===g);return l?e.jsxs(v,{className:ce,children:["Goal · ",l.title]},l.id):null}),a.linkedProjectIds.slice(0,1).map(g=>{const l=s.snapshot.dashboard.projects.find(x=>x.id===g);return l?e.jsxs(v,{className:be,children:["Project · ",l.title]},l.id):null}),a.linkedTaskIds.slice(0,1).map(g=>{const l=s.snapshot.tasks.find(x=>x.id===g);return l?e.jsxs(v,{className:ae,children:["Task · ",l.title]},l.id):null})]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-medium)]",children:a.description?e.jsx(ds,{markdown:a.description,className:"[&>p]:text-sm [&>p]:leading-6 [&>blockquote]:text-sm [&>ul]:text-sm [&>ol]:text-sm"}):"No extra notes yet."})]}),e.jsxs("div",{className:"ml-auto inline-flex shrink-0 flex-col items-end gap-2 self-start text-right",children:[e.jsxs("div",{className:P("inline-flex flex-col self-end rounded-[20px] px-3 py-2.5 text-right",u.className),children:[e.jsxs("div",{className:"flex items-center justify-end gap-1.5 text-[10px] uppercase tracking-[0.16em]",children:[e.jsx("span",{children:"Streak"}),e.jsx(z,{className:P("size-3.5 shrink-0",u.iconClass)})]}),e.jsx("div",{className:P("mt-1.5 font-display text-[2.75rem] leading-none",u.valueClass),children:a.streakCount}),e.jsx("div",{className:"mt-1 text-[11px] leading-tight text-[var(--ui-ink-soft)]",children:u.label})]}),e.jsxs("div",{className:"ml-auto grid grid-cols-2 gap-1.5",children:[e.jsx(L,{variant:"ghost",size:"sm",className:"h-7 min-w-0 rounded-[11px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",disabled:r.isPending,onClick:()=>{T(a),w(!0)},"aria-label":`Edit ${a.title}`,title:"Edit habit",children:e.jsx(es,{className:"size-4"})}),e.jsx(L,{variant:"ghost",size:"sm",className:"h-7 min-w-0 rounded-[11px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",disabled:t.isPending,onClick:()=>E(a),"aria-label":`Delete ${a.title}`,title:"Delete habit",children:e.jsx(ss,{className:"size-4"})})]})]})]}),e.jsxs("div",{className:"mt-auto grid gap-4 pt-5",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(v,{className:P("",$s(a.completionRate)),children:["Alignment ",a.completionRate,"%"]}),e.jsx(v,{className:se,children:a.polarity==="positive"?`+${a.rewardXp} XP done`:`+${a.rewardXp} XP resisted`}),e.jsx(v,{className:se,children:a.polarity==="positive"?`-${a.penaltyXp} XP missed`:`-${a.penaltyXp} XP performed`}),e.jsxs(v,{className:ae,children:[U(re.totalAp)," check-in"]}),ie?e.jsxs(v,{className:ce,children:[U(ie.totalAp)," ","workout"]}):null,ie?e.jsx(v,{className:se,children:Me(ie.rateApPerHour)}):null,e.jsx(os,{entityType:"habit",entityId:a.id,count:Qe,className:"min-h-8 rounded-full border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-1.5 text-[12px] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)]"}),a.linkedBehaviorTitles.slice(0,2).map(g=>e.jsxs(v,{className:ce,children:[e.jsx(Ce,{className:"mr-1 size-3.5"}),g]},g)),a.linkedProjectIds.slice(1,2).map(g=>{const l=s.snapshot.dashboard.projects.find(x=>x.id===g);return l?e.jsxs(v,{className:be,children:["Project · ",l.title]},l.id):null}),a.linkedTaskIds.slice(1,2).map(g=>{const l=s.snapshot.tasks.find(x=>x.id===g);return l?e.jsxs(v,{className:ae,children:["Task · ",l.title]},l.id):null}),a.linkedValueIds.slice(0,2).map(g=>{var x;const l=(x=I.data)==null?void 0:x.values.find(B=>B.id===g);return l?e.jsxs(v,{className:Re,children:["Value · ",l.title]},l.id):null}),a.linkedPatternIds.slice(0,2).map(g=>{var x;const l=(x=I.data)==null?void 0:x.patterns.find(B=>B.id===g);return l?e.jsxs(v,{className:be,children:["Pattern · ",l.title]},l.id):null}),a.linkedBeliefIds.slice(0,2).map(g=>{var x;const l=(x=I.data)==null?void 0:x.beliefs.find(B=>B.id===g);return l?e.jsxs(v,{className:Oe,children:["Belief · ",l.statement]},l.id):null}),a.linkedModeIds.slice(0,2).map(g=>{var x;const l=(x=I.data)==null?void 0:x.modes.find(B=>B.id===g);return l?e.jsxs(v,{className:ae,children:["Mode · ",l.title]},l.id):null}),a.linkedReportIds.slice(0,2).map(g=>{var x;const l=(x=I.data)==null?void 0:x.reports.find(B=>B.id===g);return l?e.jsxs(v,{className:ae,children:["Report · ",l.title]},l.id):null})]}),e.jsx("div",{className:"grid gap-4",children:e.jsx(Ws,{habit:a,onSelectCell:(g,l)=>{y({habit:g,cell:l}),S(null)}})}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs(L,{variant:"secondary",className:P("h-11 rounded-[16px] border",ne.className),disabled:i.isPending,onClick:()=>void i.mutateAsync({habitId:a.id,status:ne.status,dateKey:W(new Date)}),children:[e.jsx(ne.Icon,{className:"size-4"}),ne.label]}),e.jsxs(L,{variant:"secondary",className:P("h-11 rounded-[16px] border",le.className),disabled:i.isPending,onClick:()=>void i.mutateAsync({habitId:a.id,status:le.status,dateKey:W(new Date)}),children:[e.jsx(le.Icon,{className:"size-4"}),le.label]})]})]})]})]},a.id)})})]}),e.jsx(Fs,{open:M,pending:r.isPending,editingHabit:k,values:((ke=I.data)==null?void 0:ke.values)??[],patterns:((ye=I.data)==null?void 0:ye.patterns)??[],behaviors:((je=I.data)==null?void 0:je.behaviors)??[],beliefs:((we=I.data)==null?void 0:we.beliefs)??[],modes:((_e=I.data)==null?void 0:_e.modes)??[],reports:((Ne=I.data)==null?void 0:Ne.reports)??[],goals:s.snapshot.dashboard.goals,projects:s.snapshot.dashboard.projects,tasks:s.snapshot.tasks,users:s.snapshot.users,defaultUserId:(k==null?void 0:k.userId)??Z,onOpenChange:w,onSubmit:async(a,h)=>{try{await r.mutateAsync({input:a,habitId:h})}catch(u){throw u instanceof xs,u}}}),e.jsx(Le,{open:N!==null,onOpenChange:a=>{!a&&!t.isPending&&E(null)},children:e.jsxs(Se,{children:[e.jsx(Te,{className:"surface-overlay fixed inset-0 z-40 backdrop-blur-xl"}),e.jsxs(He,{className:"surface-modal-panel fixed inset-x-4 top-1/2 z-50 mx-auto w-[min(30rem,calc(100vw-2rem))] max-w-[30rem] -translate-y-1/2 overflow-hidden rounded-[30px] border",children:[e.jsx("div",{className:"border-b border-[var(--ui-border-subtle)] px-5 py-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Delete habit"}),e.jsx(Ee,{className:"mt-2 text-lg font-semibold text-[var(--ui-ink-strong)]",children:(N==null?void 0:N.title)??"Delete this habit?"}),e.jsx(Ae,{className:"mt-3 text-sm text-[var(--ui-ink-soft)]",children:"Remove this habit from Forge. The habit card disappears immediately after delete succeeds."})]}),e.jsx(Be,{asChild:!0,children:e.jsx(L,{variant:"ghost",size:"sm",className:"h-10 w-10 rounded-[14px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-0 text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]","aria-label":"Close delete habit modal",title:"Close",disabled:t.isPending,children:e.jsx(De,{className:"size-4"})})})]})}),e.jsxs("div",{className:"grid gap-4 p-5",children:[e.jsx("div",{className:"rounded-[20px] border border-[color-mix(in_srgb,var(--danger)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-danger-soft)] px-4 py-3 text-sm leading-6 text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",children:"This removes the habit and its check-in history from the habits page."}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-3",children:[e.jsx(L,{variant:"secondary",onClick:()=>E(null),disabled:t.isPending,children:"Cancel"}),e.jsx(L,{className:"border border-[color-mix(in_srgb,var(--danger)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)] hover:bg-[color-mix(in_srgb,var(--danger)_22%,var(--ui-surface-hover)_78%)]",pending:t.isPending,pendingLabel:"Deleting",onClick:()=>{N&&t.mutateAsync(N.id)},children:"Delete habit"})]})]})]})]})}),e.jsx(Le,{open:c!==null,onOpenChange:a=>{a||y(null)},children:e.jsxs(Se,{children:[e.jsx(Te,{className:"surface-overlay fixed inset-0 z-40 backdrop-blur-xl"}),e.jsxs(He,{className:"surface-modal-panel fixed inset-x-4 top-1/2 z-50 mx-auto w-[min(42rem,calc(100vw-2rem))] max-w-[42rem] -translate-y-1/2 overflow-hidden rounded-[30px] border",children:[e.jsx(Ee,{className:"sr-only",children:"Habit history"}),e.jsx(Ae,{className:"sr-only",children:"Log or revise a habit check-in for a selected history point."}),c&&V?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-b border-[var(--ui-border-subtle)] px-5 py-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Habit history"}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"text-lg font-semibold text-[var(--ui-ink-strong)]",children:c.habit.title}),e.jsx(v,{children:c.cell.actionLabel})]}),e.jsx("div",{className:"mt-3 text-sm text-[var(--ui-ink-soft)]",children:c.habit.frequency==="daily"?"Log or revise the check-in for this specific day.":"Log or revise the representative check-in for this week."})]}),e.jsx(Be,{asChild:!0,children:e.jsx(L,{variant:"ghost",size:"sm",className:"h-10 w-10 rounded-[14px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-0 text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]","aria-label":"Close history modal",title:"Close",children:e.jsx(De,{className:"size-4"})})})]})}),e.jsxs("div",{className:"grid gap-4 p-5",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("button",{type:"button","aria-pressed":m!==null&&Y(c.habit,m)==="aligned",className:P("rounded-[22px] border px-4 py-4 text-left transition",m!==null&&Y(c.habit,m)==="aligned"?"border-[color-mix(in_srgb,var(--success)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)]"),onClick:()=>j(a=>a!==null&&Y(c.habit,a)==="aligned"?null:Q(c.habit,"aligned")),children:[e.jsxs("div",{className:"flex items-center gap-2 text-base font-medium",children:[e.jsx(Ie,{className:"size-4"}),V.alignedLabel]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:V.alignedDescription})]}),e.jsxs("button",{type:"button","aria-pressed":m!==null&&Y(c.habit,m)==="unaligned",className:P("rounded-[22px] border px-4 py-4 text-left transition",m!==null&&Y(c.habit,m)==="unaligned"?"border-[color-mix(in_srgb,var(--danger)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)]"),onClick:()=>j(a=>a!==null&&Y(c.habit,a)==="unaligned"?null:Q(c.habit,"unaligned")),children:[e.jsxs("div",{className:"flex items-center gap-2 text-base font-medium",children:[e.jsx(Pe,{className:"size-4"}),V.unalignedLabel]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:V.unalignedDescription})]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:"Optional note"}),e.jsx(ve,{value:H,onChange:a=>D(a.target.value),placeholder:"Add context for what happened on this day or week.",className:"min-h-24"})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-3",children:[e.jsx(L,{variant:"secondary",onClick:()=>y(null),disabled:i.isPending,children:"Cancel"}),e.jsx(L,{disabled:i.isPending||!fe,pending:i.isPending,pendingLabel:"Saving",onClick:async()=>{fe&&(m===null?(await hs(c.habit.id,c.cell.actionDateKey),await G()):await i.mutateAsync({habitId:c.habit.id,status:m,dateKey:c.cell.actionDateKey,note:H.trim()||void 0}),y(null))},children:"Save check-in"})]})]})]}):null]})]})})]})}export{ma as HabitsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as i}from"./vendor-BwL6m4SE.js";import{a as t,n as s,c as n,o,p as a}from"./generic-node-view-
|
|
1
|
+
import{j as i}from"./vendor-BwL6m4SE.js";import{a as t,n as s,c as n,o,p as a}from"./generic-node-view-C6DK5hJ6.js";import{d as p}from"./define-workbench-box-CpG0Zb1L.js";function c({children:e}){return i.jsx(i.Fragment,{children:e})}function r(e){return p(c,{id:e.id,surfaceId:e.surfaceId,routePath:e.routePath,title:e.title,icon:e.surfaceId,description:e.description,category:e.category,tags:e.tags,inputs:[],params:[],output:e.output,tools:[],NodeView:n({title:e.title,description:e.description,inputs:[],params:[],output:e.output,tools:[]}),execute:e.execute})}const m=r({id:"surface:sleep-index:summary",surfaceId:"sleep-index",routePath:"/sleep",title:"Sleep summary",description:"Recent nightly sleep metrics and recovery posture.",category:"Sleep",tags:["sleep","summary"],execute:e=>o(e),output:[t({label:"Sleep summary",description:"Summary of recent sleep and recovery posture."}),s({key:"sleepView",label:"Sleep view",description:"Structured sleep history and derived sleep patterns.",modelName:"ForgeSleepView"})]}),S=r({id:"surface:sleep-index:patterns",surfaceId:"sleep-index",routePath:"/sleep",title:"Sleep patterns",description:"Weekly baseline, stage mix, and timing patterns around canonical nights.",category:"Sleep",tags:["sleep","patterns"],execute:e=>o(e),output:[t({label:"Sleep pattern summary",description:"Summary of trend, stage averages, and recovery state."}),s({key:"sleepView",label:"Sleep view",description:"Structured sleep trend, stage averages, and recovery signals.",modelName:"ForgeSleepView"})]}),y=r({id:"surface:sleep-index:browser",surfaceId:"sleep-index",routePath:"/sleep",title:"Night detail",description:"Interactive sleep calendar, selected-night detail, and optional raw evidence.",category:"Sleep",tags:["sleep","browser","history"],execute:e=>o(e),output:[t({label:"Night detail summary",description:"Summary of the sleep calendar and selected-night detail."}),s({key:"sleepView",label:"Sleep view",description:"Structured canonical nights, calendar summaries, and phase detail.",modelName:"ForgeSleepView"})]}),x=r({id:"surface:sports-index:summary",surfaceId:"sports-index",routePath:"/sports",title:"Sports summary",description:"Recent workout metrics, streaks, and linked-session totals.",category:"Sports",tags:["sports","summary"],execute:e=>a(e),output:[t({label:"Sports summary",description:"Summary of recent workout metrics and streaks."}),s({key:"sportsView",label:"Sports view",description:"Structured workout metrics, streaks, and linked session totals.",modelName:"ForgeSportsView"})]}),g=r({id:"surface:sports-index:composition",surfaceId:"sports-index",routePath:"/sports",title:"Training composition",description:"Workout mix, trend, and session composition context.",category:"Sports",tags:["sports","composition","trend"],execute:e=>a(e),output:[t({label:"Composition summary",description:"Summary of workout mix, trend, and session composition."}),s({key:"sportsView",label:"Sports view",description:"Structured workout mix, trend, and session composition data.",modelName:"ForgeSportsView"})]}),w=r({id:"surface:sports-index:browser",surfaceId:"sports-index",routePath:"/sports",title:"Session browser",description:"Searchable and virtualized workout history browser.",category:"Sports",tags:["sports","browser","history"],execute:e=>a(e),output:[t({label:"Session browser summary",description:"Summary of searchable workout history."}),s({key:"sportsView",label:"Sports view",description:"Structured workout history for browsing and analysis.",modelName:"ForgeSportsView"})]});export{m as S,S as a,y as b,x as c,g as d,w as e};
|