forge-openclaw-plugin 0.3.17 → 0.3.19

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.
Files changed (163) hide show
  1. package/dist/assets/{action-bar-D3CEYlj4.js → action-bar-B3ttL3XF.js} +1 -1
  2. package/dist/assets/{activity-page-Ce1pHIu5.js → activity-page-CoNcd0PX.js} +1 -1
  3. package/dist/assets/{ai-surface-workspace-DEliwOjF.js → ai-surface-workspace-Db34puL5.js} +1 -1
  4. package/dist/assets/artifacts-page-C09tfJTW.js +2 -0
  5. package/dist/assets/{atlas-panel-VZOnJa1c.js → atlas-panel-DRMA3RbG.js} +1 -1
  6. package/dist/assets/{board-DprRipIG.js → board-Dl7As76Q.js} +1 -1
  7. package/dist/assets/{calendar-page-Zstsn4uG.js → calendar-page-CagtpmrB.js} +1 -1
  8. package/dist/assets/{calendar-rules-BGIBuEDk.js → calendar-rules-jys-Ya5M.js} +1 -1
  9. package/dist/assets/{calendar-week-toolbar-DXFkMkbq.js → calendar-week-toolbar-DWTObcj1.js} +1 -1
  10. package/dist/assets/{charts-C5S0-BL7.js → charts-YpkKrjkZ.js} +1 -1
  11. package/dist/assets/{companion-sync-lab-page-DIPPLFKt.js → companion-sync-lab-page-COYI00E2.js} +1 -1
  12. package/dist/assets/{daily-metrics-dashboard-CG-OOCJz.js → daily-metrics-dashboard-CLoHakVX.js} +1 -1
  13. package/dist/assets/{define-workbench-box-BEEdtBkQ.js → define-workbench-box-DkTWtzNA.js} +1 -1
  14. package/dist/assets/{entity-link-multiselect-BfDAROHB.js → entity-link-multiselect-HmmmJO5A.js} +1 -1
  15. package/dist/assets/{entity-note-count-link-BGOiaash.js → entity-note-count-link-BDLj5ezr.js} +1 -1
  16. package/dist/assets/{entity-notes-surface-DPsJwqQa.js → entity-notes-surface-Csbm1myW.js} +1 -1
  17. package/dist/assets/{execution-board-Dg-2GSKv.js → execution-board-C7wYWJE4.js} +1 -1
  18. package/dist/assets/{faceted-token-search-DV7MSVYb.js → faceted-token-search-B2XWEl8j.js} +1 -1
  19. package/dist/assets/{flagship-signal-deck-D3wVL3bC.js → flagship-signal-deck-DnNN_VE1.js} +1 -1
  20. package/dist/assets/{floating-action-menu-BUs382px.js → floating-action-menu-D2Lk9TOc.js} +1 -1
  21. package/dist/assets/{forms-ByKjodjN.js → forms-DznAv9hZ.js} +1 -1
  22. package/dist/assets/{generic-node-view-BY5dbPXJ.js → generic-node-view-C_WhZXoj.js} +1 -1
  23. package/dist/assets/goal-detail-page-B395rAnv.js +1 -0
  24. package/dist/assets/{goal-dialog-nkdME5Uy.js → goal-dialog-DiEV3MyU.js} +1 -1
  25. package/dist/assets/goals-page-BNwaz0yD.js +1 -0
  26. package/dist/assets/{graph-CHVj0Z7n.js → graph-BUSFLDnl.js} +1 -1
  27. package/dist/assets/{habits-page-wO461EVU.js → habits-page-BkfbiwMJ.js} +1 -1
  28. package/dist/assets/{health-boxes-BphMeSJj.js → health-boxes-BlA33CqS.js} +1 -1
  29. package/dist/assets/index-C0CztQTU.js +2 -0
  30. package/dist/assets/index-CKnJCN1y.css +1 -0
  31. package/dist/assets/{inline-note-fields-BvQwmMAv.js → inline-note-fields-CbA0QOnc.js} +1 -1
  32. package/dist/assets/{insight-flow-dialog-H_eaOmst.js → insight-flow-dialog-DdxIE6oo.js} +1 -1
  33. package/dist/assets/{insights-page-DINYe3cB.js → insights-page-C0q_J9Hz.js} +1 -1
  34. package/dist/assets/{kanban-boxes-oACOTDYG.js → kanban-boxes-BynqbGHC.js} +1 -1
  35. package/dist/assets/{kanban-page-BGLXH91f.js → kanban-page-DyiaHH0e.js} +1 -1
  36. package/dist/assets/{knowledge-graph-page-VfMvw5jL.js → knowledge-graph-page-Cn9VkUur.js} +1 -1
  37. package/dist/assets/{life-force-page-DQPb6UL-.js → life-force-page-DQPEIj23.js} +1 -1
  38. package/dist/assets/{life-force-workspace-BJ1aI3JE.js → life-force-workspace-Db7XThH2.js} +1 -1
  39. package/dist/assets/{maps-CvEHVkBk.js → maps-CpdpZmGM.js} +1 -1
  40. package/dist/assets/{metric-tile-CbEe19Gd.js → metric-tile-sDt_l_O7.js} +1 -1
  41. package/dist/assets/{motion-BibSzp57.js → motion-eRlWWQT8.js} +1 -1
  42. package/dist/assets/{movement-boxes-dtDYhw5c.js → movement-boxes-birc_cd8.js} +1 -1
  43. package/dist/assets/{movement-page-BhmwCHjs.js → movement-page-BQllmJBm.js} +1 -1
  44. package/dist/assets/{note-markdown-CG8u2d6p.js → note-markdown-Dpve4W0R.js} +1 -1
  45. package/dist/assets/{note-tags-input-D_conqDO.js → note-tags-input-Hvi_ifLe.js} +1 -1
  46. package/dist/assets/{notes-boxes-BLKucFqW.js → notes-boxes-J-MuDr8u.js} +1 -1
  47. package/dist/assets/{notes-page-CafVxWjb.js → notes-page-uR_LafDv.js} +1 -1
  48. package/dist/assets/{open-in-graph-button-DFQ4r6SN.js → open-in-graph-button-JgYTH-IQ.js} +1 -1
  49. package/dist/assets/{orbit-map-DsEl3ori.js → orbit-map-BpNCTagm.js} +1 -1
  50. package/dist/assets/overview-page-DQB4q_vg.js +1 -0
  51. package/dist/assets/{page-hero-U603l9rQ.js → page-hero-ED69y6m0.js} +1 -1
  52. package/dist/assets/pill-cluster-DbPrs1Y4.js +1 -0
  53. package/dist/assets/{preference-entity-handoff-button-cPrTpHsV.js → preference-entity-handoff-button-NkwkWqGv.js} +1 -1
  54. package/dist/assets/{preferences-page-DQjFIOmt.js → preferences-page-BFUVjsHA.js} +1 -1
  55. package/dist/assets/{project-collections-B9OGHGqm.js → project-collections-DHXN2w-P.js} +1 -1
  56. package/dist/assets/{project-detail-page-r1Sw2kcO.js → project-detail-page-nE0M0UmN.js} +1 -1
  57. package/dist/assets/{project-dialog-B2_PcXAf.js → project-dialog-CDkUuAgl.js} +1 -1
  58. package/dist/assets/{project-management-hierarchy-page-qLNG8hsh.js → project-management-hierarchy-page-CID81NpW.js} +1 -1
  59. package/dist/assets/{project-management-section-nav-DFUlmMEB.js → project-management-section-nav-BjFavt6d.js} +1 -1
  60. package/dist/assets/{projects-boxes-BA7_XaqX.js → projects-boxes-DzGqWlhE.js} +1 -1
  61. package/dist/assets/projects-page-DpFKm_CM.js +1 -0
  62. package/dist/assets/{psyche-behaviors-page-ByWpXlLq.js → psyche-behaviors-page-CEQ2EByW.js} +1 -1
  63. package/dist/assets/{psyche-flashcards-page-B9nSc0mk.js → psyche-flashcards-page-D-g1DOS7.js} +1 -1
  64. package/dist/assets/{psyche-goal-map-page-BQU7qI88.js → psyche-goal-map-page-DbWVOpVH.js} +1 -1
  65. package/dist/assets/{psyche-graph-DCeP7r2b.js → psyche-graph-1FHrdH3f.js} +1 -1
  66. package/dist/assets/{psyche-metrics-page-DD2lOP-J.js → psyche-metrics-page-B3736p8_.js} +1 -1
  67. package/dist/assets/{psyche-mode-guide-page-DbtZgnjr.js → psyche-mode-guide-page-CjsMqDsi.js} +1 -1
  68. package/dist/assets/{psyche-modes-page-3zFJWFQf.js → psyche-modes-page-B2qzppBs.js} +1 -1
  69. package/dist/assets/{psyche-page-D5vXYkfB.js → psyche-page-BEPP2B13.js} +1 -1
  70. package/dist/assets/{psyche-patterns-page-BneAAeKS.js → psyche-patterns-page-CWeNeX2P.js} +2 -2
  71. package/dist/assets/{psyche-questionnaire-builder-page-BH1la5C9.js → psyche-questionnaire-builder-page-QFg9LkM0.js} +1 -1
  72. package/dist/assets/{psyche-questionnaire-detail-page-DYav634P.js → psyche-questionnaire-detail-page-D67EJ1D5.js} +1 -1
  73. package/dist/assets/psyche-questionnaire-run-detail-page-C1KsEy8T.js +1 -0
  74. package/dist/assets/{psyche-questionnaire-run-page-e1T6k_dS.js → psyche-questionnaire-run-page-CB3rSTAX.js} +1 -1
  75. package/dist/assets/{psyche-questionnaires-page-Dyv367z9.js → psyche-questionnaires-page-wU3bZws7.js} +1 -1
  76. package/dist/assets/{psyche-report-detail-page-hqxHIXw2.js → psyche-report-detail-page-DI3jE820.js} +3 -3
  77. package/dist/assets/{psyche-reports-page-DhIfcGbt.js → psyche-reports-page-aUbgZ_12.js} +1 -1
  78. package/dist/assets/{psyche-schemas-Cg51Ztxz.js → psyche-schemas-B00gm5HO.js} +1 -1
  79. package/dist/assets/{psyche-schemas-beliefs-page-Dgb5o9vx.js → psyche-schemas-beliefs-page-C_PMXwjL.js} +2 -2
  80. package/dist/assets/{psyche-screen-time-page-D6MnJGNa.js → psyche-screen-time-page-CMIgDG-3.js} +1 -1
  81. package/dist/assets/{psyche-self-observation-page-C1Vyezbv.js → psyche-self-observation-page-DC3orZgf.js} +1 -1
  82. package/dist/assets/{psyche-values-page-B_JWVw1Q.js → psyche-values-page-CPdKfTdl.js} +2 -2
  83. package/dist/assets/{question-flow-dialog-yMYVk998.js → question-flow-dialog-B4B3BI8e.js} +2 -2
  84. package/dist/assets/{report-chain-fields-D4NM9a6I.js → report-chain-fields-D-XNut8V.js} +1 -1
  85. package/dist/assets/rewards-page-D8w07BIZ.js +1 -0
  86. package/dist/assets/{scheduling-rules-editor-De72IUax.js → scheduling-rules-editor-Cn6t-RRn.js} +1 -1
  87. package/dist/assets/{schema-badge-jX28kUa6.js → schema-badge-Dsk9AoYd.js} +1 -1
  88. package/dist/assets/{schemas-BlFy-uPR.js → schemas-3GS34K1i.js} +1 -1
  89. package/dist/assets/{select-menu-BXv1rsVc.js → select-menu-BDeaaa4m.js} +1 -1
  90. package/dist/assets/{settings-agents-page-DN_np10S.js → settings-agents-page-CkS4s4kN.js} +2 -2
  91. package/dist/assets/settings-bin-page-BHlW0n-a.js +1 -0
  92. package/dist/assets/{settings-calendar-page-Cg0gSSFs.js → settings-calendar-page-BAmKOPeT.js} +1 -1
  93. package/dist/assets/{settings-data-page-Dwmp2rLy.js → settings-data-page-C-VrzHGq.js} +1 -1
  94. package/dist/assets/{settings-logs-page-DQNM21Re.js → settings-logs-page-CnVuzJ7d.js} +1 -1
  95. package/dist/assets/{settings-mobile-page-DQdiRa-a.js → settings-mobile-page-0SWGg6CE.js} +1 -1
  96. package/dist/assets/settings-models-page-BjVixsws.js +1 -0
  97. package/dist/assets/{settings-page-Cl2KiCFg.js → settings-page-DVZ58c3R.js} +1 -1
  98. package/dist/assets/settings-rewards-page-Df0ONVFq.js +1 -0
  99. package/dist/assets/{settings-section-nav-D_N87IG0.js → settings-section-nav-Btjx5m2u.js} +1 -1
  100. package/dist/assets/settings-users-page-Cl0YuOOI.js +1 -0
  101. package/dist/assets/{settings-wiki-page-BxMQM5Vi.js → settings-wiki-page-K8KBzeYx.js} +1 -1
  102. package/dist/assets/{sleep-page-DUYmQKrg.js → sleep-page-BFj8hcTf.js} +1 -1
  103. package/dist/assets/{sports-page-Bzi5TF9T.js → sports-page-7yta1r8s.js} +1 -1
  104. package/dist/assets/{state-BFyKSULP.js → state-CkEUXgqt.js} +1 -1
  105. package/dist/assets/{strategies-page-C-T2MZx4.js → strategies-page-BQoWnPtN.js} +1 -1
  106. package/dist/assets/strategy-detail-page-D9DTQoyy.js +1 -0
  107. package/dist/assets/strategy-dialog-z9w2UB3s.js +1 -0
  108. package/dist/assets/{surface-BJObZeRw.js → surface-BL_bDiZ5.js} +1 -1
  109. package/dist/assets/{table-CTLroJKN.js → table--SK_dk4S.js} +1 -1
  110. package/dist/assets/{task-detail-page-ZZOXSpSF.js → task-detail-page-RcbvVzXn.js} +1 -1
  111. package/dist/assets/{task-dialog-2wy0xI7f.js → task-dialog-ri1qEzPp.js} +4 -4
  112. package/dist/assets/timebox-planning-dialog-DoeeGwCm.js +1 -0
  113. package/dist/assets/{today-boxes-B_TdgSDz.js → today-boxes-CTw0D5JP.js} +1 -1
  114. package/dist/assets/today-page-5-qRLbBt.js +1 -0
  115. package/dist/assets/{training-load-page-B78e1-o-.js → training-load-page-DrGnOtnH.js} +1 -1
  116. package/dist/assets/{ui-uo_bNP7c.js → ui-CDt36qNz.js} +1 -1
  117. package/dist/assets/{use-anchored-overlay-position-BSxFX6Hi.js → use-anchored-overlay-position-C2kg0Ay0.js} +1 -1
  118. package/dist/assets/{use-psyche-focus-target-1GLkhYiv.js → use-psyche-focus-target-p2l8W-Af.js} +1 -1
  119. package/dist/assets/{user-badge-C4eZu1e_.js → user-badge-BWoSrGA-.js} +1 -1
  120. package/dist/assets/{user-select-field-CmKwcbZt.js → user-select-field-DbB9v7Lf.js} +1 -1
  121. package/dist/assets/{utility-widgets-B06wQFrd.js → utility-widgets-fodvUR7I.js} +2 -2
  122. package/dist/assets/{vendor-B7FKSwHK.js → vendor-Dgw7UY7q.js} +1 -1
  123. package/dist/assets/{vitals-page-BC7QFsm2.js → vitals-page-f8QdPdpp.js} +1 -1
  124. package/dist/assets/{weekly-review-page-BjNsNoWj.js → weekly-review-page-D0wPiQgO.js} +1 -1
  125. package/dist/assets/{weight-loss-page-BOahGY9r.js → weight-loss-page-BT9dPxYi.js} +1 -1
  126. package/dist/assets/{wiki-article-markdown-DO47HnZf.js → wiki-article-markdown-Hyu5JwrY.js} +1 -1
  127. package/dist/assets/{wiki-editor-page-OWRUHl4O.js → wiki-editor-page-ujqNw8ua.js} +3 -3
  128. package/dist/assets/{wiki-ingest-history-page-CuHpg2lZ.js → wiki-ingest-history-page-BwoDT00-.js} +1 -1
  129. package/dist/assets/{wiki-ingest-modal-EZ3kX-vA.js → wiki-ingest-modal-cvnNma0M.js} +1 -1
  130. package/dist/assets/{wiki-page-BPV3HIgu.js → wiki-page-jHyJ7EgO.js} +1 -1
  131. package/dist/assets/{workbench-flow-page-C53KueEz.js → workbench-flow-page-DJD5sXMF.js} +1 -1
  132. package/dist/assets/{workbench-page-DJ7nT2JQ.js → workbench-page-Ci0xh6rG.js} +1 -1
  133. package/dist/assets/{workout-detail-page-Dhyu0q7o.js → workout-detail-page-DA30ubtE.js} +2 -2
  134. package/dist/index.html +8 -8
  135. package/dist/openclaw/tools.js +1 -1
  136. package/dist/server/apps/api/migrations/073_artifact_entity_links_repair.sql +24 -0
  137. package/dist/server/apps/api/src/app.js +26 -8
  138. package/dist/server/apps/api/src/openapi.js +103 -24
  139. package/dist/server/apps/api/src/services/artifacts.js +138 -68
  140. package/dist/server/apps/web/src/lib/api.js +3 -0
  141. package/openclaw.plugin.json +1 -1
  142. package/package.json +1 -1
  143. package/server/migrations/073_artifact_entity_links_repair.sql +24 -0
  144. package/skills/forge-openclaw/SKILL.md +7 -5
  145. package/skills/forge-openclaw/entity_conversation_playbooks.md +14 -9
  146. package/dist/assets/artifacts-page-BgyFVIVM.js +0 -2
  147. package/dist/assets/goal-detail-page-MYr6j2B4.js +0 -1
  148. package/dist/assets/goals-page-BsFeBzU1.js +0 -1
  149. package/dist/assets/index-CSd8ylsy.css +0 -1
  150. package/dist/assets/index-gmPaoLN-.js +0 -2
  151. package/dist/assets/overview-page-BffcX-pM.js +0 -1
  152. package/dist/assets/pill-cluster-BYVFNppV.js +0 -1
  153. package/dist/assets/projects-page-B6ggXWFw.js +0 -1
  154. package/dist/assets/psyche-questionnaire-run-detail-page-9VaijhJm.js +0 -1
  155. package/dist/assets/rewards-page-B5-bcL4R.js +0 -1
  156. package/dist/assets/settings-bin-page-BM5BpK_i.js +0 -1
  157. package/dist/assets/settings-models-page-CAEPpuHF.js +0 -1
  158. package/dist/assets/settings-rewards-page-DoIUumhe.js +0 -1
  159. package/dist/assets/settings-users-page-CPesR62N.js +0 -1
  160. package/dist/assets/strategy-detail-page-3tYuSZu-.js +0 -1
  161. package/dist/assets/strategy-dialog-BWm4slo4.js +0 -1
  162. package/dist/assets/timebox-planning-dialog-C6h0Hp71.js +0 -1
  163. package/dist/assets/today-page-Dipns9tl.js +0 -1
@@ -1 +1 @@
1
- import{r as u,j as e,aC as m,da as v,bk as b}from"./vendor-B7FKSwHK.js";import{i as w}from"./state-BFyKSULP.js";import{F as g}from"./faceted-token-search-DV7MSVYb.js";import{L as j,e as N,B as p,bB as k,h as S,C as f,j as d,c as _,bU as C}from"./index-gmPaoLN-.js";import{P as $}from"./page-hero-U603l9rQ.js";import"./motion-BibSzp57.js";import"./ui-uo_bNP7c.js";import"./board-DprRipIG.js";import"./forms-ByKjodjN.js";function c(l,a){return`${l}: ${a}`}function q(l){const a=new Map;for(const r of l){const t=(s,n,x)=>{a.has(s)||a.set(s,{id:s,label:n,description:x})};for(const s of r.aliases)t(`alias:${s}`,c("Alias",s),"Filter by questionnaire alias.");for(const s of r.symptomDomains)t(`domain:${s}`,c("Domain",s),"Filter by symptom domain.");t(`source:${r.sourceClass}`,c("Source",r.sourceClass.replaceAll("_"," ")),"Filter by source and licence class."),t(`presentation:${r.presentationMode}`,c("Flow",r.presentationMode.replaceAll("_"," ")),"Filter by runner presentation mode."),t(`response:${r.responseStyle}`,c("Response",r.responseStyle.replaceAll("_"," ")),"Filter by response style."),t(`availability:${r.availability}`,c("Availability",r.availability.replaceAll("_"," ")),"Filter by availability."),t(`size:${r.itemCount>=50?"long":r.itemCount>=15?"medium":"short"}`,c("Length",r.itemCount>=50?"long":r.itemCount>=15?"medium":"short"),"Filter by approximate questionnaire length."),t(`self:${r.isSelfReport?"self_report":"other"}`,c("Type",r.isSelfReport?"self report":"other"),"Filter by self-report availability.")}return Array.from(a.values()).sort((r,t)=>r.label.localeCompare(t.label))}function Q(l,a){return l.every(r=>{const[t,s]=r.split(":",2);if(!t||!s)return!0;switch(t){case"alias":return a.aliases.includes(s);case"domain":return a.symptomDomains.includes(s);case"source":return a.sourceClass===s;case"presentation":return a.presentationMode===s;case"response":return a.responseStyle===s;case"availability":return a.availability===s;case"size":return s==="long"?a.itemCount>=50:s==="medium"?a.itemCount>=15&&a.itemCount<50:a.itemCount<15;case"self":return s==="self_report"?a.isSelfReport:!a.isSelfReport;default:return!0}})}function E(){var y;const[l,a]=u.useState(""),[r,t]=u.useState([]),s=w({queryKey:["forge-psyche-questionnaires"],queryFn:()=>C()}),n=((y=s.data)==null?void 0:y.instruments)??[],x=u.useMemo(()=>q(n),[n]),h=u.useMemo(()=>{const i=l.trim().toLowerCase();return n.filter(o=>(i.length===0||`${o.title} ${o.subtitle} ${o.description} ${o.aliases.join(" ")} ${o.symptomDomains.join(" ")} ${o.tags.join(" ")}`.toLowerCase().includes(i))&&Q(r,o))},[n,l,r]);return s.isLoading?e.jsx(j,{eyebrow:"Questionnaires",title:"Loading the questionnaire library",description:"Hydrating the seeded assessment catalog, versions, and latest run history."}):s.isError?e.jsx(N,{eyebrow:"Questionnaires",error:s.error,onRetry:()=>void s.refetch()}):e.jsxs("div",{className:"grid gap-5",children:[e.jsx($,{eyebrow:"Psyche",title:"Questionnaires",description:"Browse the seeded mental health questionnaire library, narrow it with facet chips, launch guided runs, and build your own versioned instruments.",badge:`${n.length} instruments`,actions:e.jsx(m,{to:"/psyche/questionnaires/new",children:e.jsx(p,{children:"Build questionnaire"})})}),e.jsx(k,{}),e.jsx(g,{title:"Questionnaire filters",description:"Search by title or alias, then pin chips for symptom domain, source class, item count, response style, flow mode, self-report status, or availability.",query:l,onQueryChange:a,options:x,selectedOptionIds:r,onSelectedOptionIdsChange:t,resultSummary:`${h.length} of ${n.length} questionnaires visible`}),h.length===0?e.jsx(S,{eyebrow:"Questionnaire library",title:"No questionnaires match the current filters",description:"Clear one or two chips and the seeded catalog will come back into view."}):e.jsx("section",{className:"grid gap-4 xl:grid-cols-2",children:h.map(i=>e.jsxs(f,{className:"min-w-0 overflow-hidden border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"break-words font-label text-[11px] uppercase tracking-[0.18em] text-[var(--tertiary)] [overflow-wrap:anywhere]",children:i.subtitle||"Questionnaire"}),e.jsx("h2",{className:"mt-3 break-words font-display text-[clamp(1.35rem,2vw,1.9rem)] leading-tight text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:i.title}),e.jsx("p",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:i.description})]}),e.jsxs("div",{className:"min-w-[8.5rem] rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-3 text-left sm:text-right",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Latest"}),e.jsx("div",{className:"mt-2 break-words text-sm text-[var(--ui-ink-medium)]",children:i.latestRunAt?new Date(i.latestRunAt).toLocaleDateString():"Not taken yet"})]})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsxs(d,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[i.itemCount," items"]}),e.jsx(d,{className:"bg-[color-mix(in_srgb,var(--success)_12%,var(--ui-surface-1)_88%)] text-[color-mix(in_srgb,var(--success)_68%,var(--ui-ink-strong)_32%)]",children:i.presentationMode.replaceAll("_"," ")}),e.jsx(d,{className:"bg-[color-mix(in_srgb,var(--info)_12%,var(--ui-surface-1)_88%)] text-[color-mix(in_srgb,var(--info)_68%,var(--ui-ink-strong)_32%)]",children:i.responseStyle.replaceAll("_"," ")}),e.jsx(d,{className:"bg-[color-mix(in_srgb,var(--primary)_12%,var(--ui-surface-1)_88%)] text-[color-mix(in_srgb,var(--primary)_68%,var(--ui-ink-strong)_32%)]",children:i.sourceClass.replaceAll("_"," ")})]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:i.symptomDomains.map(o=>e.jsx(d,{className:"max-w-full whitespace-normal break-words bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:o},`${i.id}-${o}`))}),e.jsxs("div",{className:"mt-5 grid gap-3 sm:grid-cols-[minmax(0,1fr)_auto_auto]",children:[e.jsx("div",{className:"min-w-0 break-words rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3 text-sm text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:i.completedRunCount>0?`${i.completedRunCount} completed runs saved in history`:"No saved history yet"}),e.jsx(m,{to:`/psyche/questionnaires/${i.id}`,children:e.jsx(p,{variant:"secondary",className:"w-full sm:w-auto",children:"Open detail"})}),e.jsx(m,{to:`/psyche/questionnaires/${i.id}/take`,children:e.jsx(p,{className:"w-full sm:w-auto",children:"Start guided run"})})]})]},i.id))}),e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)]",children:[e.jsxs(f,{className:"min-w-0 border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(v,{className:"size-5 text-[var(--tertiary)]"}),e.jsx("div",{className:"break-words font-display text-2xl text-[var(--ui-ink-strong)]",children:"Seeded first wave"})]}),e.jsx("p",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:"The current library ships a verified first wave: PHQ-9, GAD-7, WHO-5, PCL-5, AUDIT, SRQ-20, and YSQ-R, each stored in SQLite as a versioned definition with scoring and provenance."})]}),e.jsxs(f,{className:"min-w-0 border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(b,{className:"size-5 text-[var(--secondary)]"}),e.jsx("div",{className:"break-words font-display text-2xl text-[var(--ui-ink-strong)]",children:"Builder ready"})]}),e.jsx("p",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:"System questionnaires stay read-only. Custom drafts can branch from any seed, edit structure and scoring JSON safely, and publish new immutable versions without rewriting past runs."}),e.jsx("div",{className:"mt-4",children:e.jsx(m,{to:"/psyche/questionnaires/new",children:e.jsx(p,{variant:"secondary",className:_("w-full sm:w-auto"),children:"Open builder"})})})]})]})]})}export{E as PsycheQuestionnairesPage};
1
+ import{r as u,j as e,aC as m,db as v,bk as b}from"./vendor-Dgw7UY7q.js";import{i as w}from"./state-CkEUXgqt.js";import{F as g}from"./faceted-token-search-B2XWEl8j.js";import{L as j,e as N,B as p,bD as k,h as S,C as f,j as d,c as _,bW as C}from"./index-C0CztQTU.js";import{P as $}from"./page-hero-ED69y6m0.js";import"./motion-eRlWWQT8.js";import"./ui-CDt36qNz.js";import"./board-Dl7As76Q.js";import"./forms-DznAv9hZ.js";function c(l,a){return`${l}: ${a}`}function q(l){const a=new Map;for(const r of l){const t=(s,n,x)=>{a.has(s)||a.set(s,{id:s,label:n,description:x})};for(const s of r.aliases)t(`alias:${s}`,c("Alias",s),"Filter by questionnaire alias.");for(const s of r.symptomDomains)t(`domain:${s}`,c("Domain",s),"Filter by symptom domain.");t(`source:${r.sourceClass}`,c("Source",r.sourceClass.replaceAll("_"," ")),"Filter by source and licence class."),t(`presentation:${r.presentationMode}`,c("Flow",r.presentationMode.replaceAll("_"," ")),"Filter by runner presentation mode."),t(`response:${r.responseStyle}`,c("Response",r.responseStyle.replaceAll("_"," ")),"Filter by response style."),t(`availability:${r.availability}`,c("Availability",r.availability.replaceAll("_"," ")),"Filter by availability."),t(`size:${r.itemCount>=50?"long":r.itemCount>=15?"medium":"short"}`,c("Length",r.itemCount>=50?"long":r.itemCount>=15?"medium":"short"),"Filter by approximate questionnaire length."),t(`self:${r.isSelfReport?"self_report":"other"}`,c("Type",r.isSelfReport?"self report":"other"),"Filter by self-report availability.")}return Array.from(a.values()).sort((r,t)=>r.label.localeCompare(t.label))}function Q(l,a){return l.every(r=>{const[t,s]=r.split(":",2);if(!t||!s)return!0;switch(t){case"alias":return a.aliases.includes(s);case"domain":return a.symptomDomains.includes(s);case"source":return a.sourceClass===s;case"presentation":return a.presentationMode===s;case"response":return a.responseStyle===s;case"availability":return a.availability===s;case"size":return s==="long"?a.itemCount>=50:s==="medium"?a.itemCount>=15&&a.itemCount<50:a.itemCount<15;case"self":return s==="self_report"?a.isSelfReport:!a.isSelfReport;default:return!0}})}function E(){var y;const[l,a]=u.useState(""),[r,t]=u.useState([]),s=w({queryKey:["forge-psyche-questionnaires"],queryFn:()=>C()}),n=((y=s.data)==null?void 0:y.instruments)??[],x=u.useMemo(()=>q(n),[n]),h=u.useMemo(()=>{const i=l.trim().toLowerCase();return n.filter(o=>(i.length===0||`${o.title} ${o.subtitle} ${o.description} ${o.aliases.join(" ")} ${o.symptomDomains.join(" ")} ${o.tags.join(" ")}`.toLowerCase().includes(i))&&Q(r,o))},[n,l,r]);return s.isLoading?e.jsx(j,{eyebrow:"Questionnaires",title:"Loading the questionnaire library",description:"Hydrating the seeded assessment catalog, versions, and latest run history."}):s.isError?e.jsx(N,{eyebrow:"Questionnaires",error:s.error,onRetry:()=>void s.refetch()}):e.jsxs("div",{className:"grid gap-5",children:[e.jsx($,{eyebrow:"Psyche",title:"Questionnaires",description:"Browse the seeded mental health questionnaire library, narrow it with facet chips, launch guided runs, and build your own versioned instruments.",badge:`${n.length} instruments`,actions:e.jsx(m,{to:"/psyche/questionnaires/new",children:e.jsx(p,{children:"Build questionnaire"})})}),e.jsx(k,{}),e.jsx(g,{title:"Questionnaire filters",description:"Search by title or alias, then pin chips for symptom domain, source class, item count, response style, flow mode, self-report status, or availability.",query:l,onQueryChange:a,options:x,selectedOptionIds:r,onSelectedOptionIdsChange:t,resultSummary:`${h.length} of ${n.length} questionnaires visible`}),h.length===0?e.jsx(S,{eyebrow:"Questionnaire library",title:"No questionnaires match the current filters",description:"Clear one or two chips and the seeded catalog will come back into view."}):e.jsx("section",{className:"grid gap-4 xl:grid-cols-2",children:h.map(i=>e.jsxs(f,{className:"min-w-0 overflow-hidden border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"break-words font-label text-[11px] uppercase tracking-[0.18em] text-[var(--tertiary)] [overflow-wrap:anywhere]",children:i.subtitle||"Questionnaire"}),e.jsx("h2",{className:"mt-3 break-words font-display text-[clamp(1.35rem,2vw,1.9rem)] leading-tight text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:i.title}),e.jsx("p",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:i.description})]}),e.jsxs("div",{className:"min-w-[8.5rem] rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-3 text-left sm:text-right",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Latest"}),e.jsx("div",{className:"mt-2 break-words text-sm text-[var(--ui-ink-medium)]",children:i.latestRunAt?new Date(i.latestRunAt).toLocaleDateString():"Not taken yet"})]})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsxs(d,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[i.itemCount," items"]}),e.jsx(d,{className:"bg-[color-mix(in_srgb,var(--success)_12%,var(--ui-surface-1)_88%)] text-[color-mix(in_srgb,var(--success)_68%,var(--ui-ink-strong)_32%)]",children:i.presentationMode.replaceAll("_"," ")}),e.jsx(d,{className:"bg-[color-mix(in_srgb,var(--info)_12%,var(--ui-surface-1)_88%)] text-[color-mix(in_srgb,var(--info)_68%,var(--ui-ink-strong)_32%)]",children:i.responseStyle.replaceAll("_"," ")}),e.jsx(d,{className:"bg-[color-mix(in_srgb,var(--primary)_12%,var(--ui-surface-1)_88%)] text-[color-mix(in_srgb,var(--primary)_68%,var(--ui-ink-strong)_32%)]",children:i.sourceClass.replaceAll("_"," ")})]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:i.symptomDomains.map(o=>e.jsx(d,{className:"max-w-full whitespace-normal break-words bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:o},`${i.id}-${o}`))}),e.jsxs("div",{className:"mt-5 grid gap-3 sm:grid-cols-[minmax(0,1fr)_auto_auto]",children:[e.jsx("div",{className:"min-w-0 break-words rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3 text-sm text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:i.completedRunCount>0?`${i.completedRunCount} completed runs saved in history`:"No saved history yet"}),e.jsx(m,{to:`/psyche/questionnaires/${i.id}`,children:e.jsx(p,{variant:"secondary",className:"w-full sm:w-auto",children:"Open detail"})}),e.jsx(m,{to:`/psyche/questionnaires/${i.id}/take`,children:e.jsx(p,{className:"w-full sm:w-auto",children:"Start guided run"})})]})]},i.id))}),e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)]",children:[e.jsxs(f,{className:"min-w-0 border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(v,{className:"size-5 text-[var(--tertiary)]"}),e.jsx("div",{className:"break-words font-display text-2xl text-[var(--ui-ink-strong)]",children:"Seeded first wave"})]}),e.jsx("p",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:"The current library ships a verified first wave: PHQ-9, GAD-7, WHO-5, PCL-5, AUDIT, SRQ-20, and YSQ-R, each stored in SQLite as a versioned definition with scoring and provenance."})]}),e.jsxs(f,{className:"min-w-0 border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(b,{className:"size-5 text-[var(--secondary)]"}),e.jsx("div",{className:"break-words font-display text-2xl text-[var(--ui-ink-strong)]",children:"Builder ready"})]}),e.jsx("p",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:"System questionnaires stay read-only. Custom drafts can branch from any seed, edit structure and scoring JSON safely, and publish new immutable versions without rewriting past runs."}),e.jsx("div",{className:"mt-4",children:e.jsx(m,{to:"/psyche/questionnaires/new",children:e.jsx(p,{variant:"secondary",className:_("w-full sm:w-auto"),children:"Open builder"})})})]})]})]})}export{E as PsycheQuestionnairesPage};
@@ -1,3 +1,3 @@
1
- import{r as h,j as e,db as ie,b6 as ae,b_ as re}from"./vendor-B7FKSwHK.js";import{j as ne,i as p,k as R}from"./state-BFyKSULP.js";import{B as b,c as oe,S as de,e as D,T as H,ad as U,ac as V,I as C,b as G,bB as le,cA as ce,al as me,cB as he,be as ue,bf as pe,bg as xe,b_ as ge,cC as ve,cD as fe}from"./index-gmPaoLN-.js";import{A as Y,m as J}from"./motion-BibSzp57.js";import{I as ye}from"./insight-flow-dialog-H_eaOmst.js";import{O as be}from"./open-in-graph-button-DFQ4r6SN.js";import{E as je}from"./entity-notes-surface-DPsJwqQa.js";import{S as y,B as ke,M as we,T as Te,E as Ne}from"./report-chain-fields-D4NM9a6I.js";import{P as Ie}from"./page-hero-U603l9rQ.js";import{t as Se}from"./psyche-schemas-Cg51Ztxz.js";import{b as Le,a as Ce,c as Ee,f as Me,t as Be}from"./schema-visuals-CvC9a3i6.js";import"./ui-uo_bNP7c.js";import"./board-DprRipIG.js";import"./forms-ByKjodjN.js";import"./question-flow-dialog-yMYVk998.js";import"./schemas-BlFy-uPR.js";import"./note-markdown-CG8u2d6p.js";import"./note-tags-input-D_conqDO.js";import"./entity-link-multiselect-BfDAROHB.js";import"./use-anchored-overlay-position-BSxFX6Hi.js";import"./user-ownership-DJGl4rAj.js";const X="(max-width: 1023px)";function qe(){const[i,o]=h.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(X).matches);return h.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const d=window.matchMedia(X),m=s=>o(s.matches);return o(d.matches),typeof d.addEventListener=="function"?(d.addEventListener("change",m),()=>d.removeEventListener("change",m)):(d.addListener(m),()=>d.removeListener(m))},[]),i}function Ae({stages:i,activeStageId:o,onStageChange:d,stageContent:m,inspector:s}){const a=qe(),[j,g]=h.useState(!1),n=i.find(l=>l.id===o);return h.useEffect(()=>{g(!a)},[a]),e.jsxs("section",{className:"grid min-w-0 gap-4 xl:grid-cols-[minmax(0,1fr)_18rem]",children:[e.jsxs("div",{className:"min-w-0 rounded-[30px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)] p-4",children:[e.jsxs("div",{className:"mb-4 flex items-start justify-between gap-3",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:"Tracing the chain"}),e.jsx("div",{className:"mt-1 break-words text-sm text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:n==null?void 0:n.summary})]}),s?e.jsxs(b,{variant:"secondary",size:"sm",onClick:()=>g(l=>!l),children:[j?e.jsx(ie,{className:"size-4"}):e.jsx(ae,{className:"size-4"}),"Inspector"]}):null]}),e.jsx("div",{className:"mb-4 pb-1",children:e.jsx("div",{className:"flex min-w-0 flex-wrap items-center gap-3",children:i.map((l,v)=>e.jsxs("button",{type:"button",className:oe("min-w-0 max-w-full rounded-[22px] px-4 py-3 text-left transition",a?"flex-1 basis-[5.5rem]":"basis-[13rem]",l.id===o?"bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)] shadow-[var(--ui-shadow-soft)]":"bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>d(l.id),children:[e.jsxs("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:[v+1,". ",l.label]}),a?null:e.jsx("div",{className:"mt-1.5 text-sm leading-5",children:l.summary})]},l.id))})}),e.jsxs("div",{className:"min-w-0 rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4 md:p-5",children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"rounded-full bg-[var(--ui-surface-2)] px-3 py-1.5 text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:n==null?void 0:n.label}),e.jsx("span",{className:"min-w-0 break-words text-sm text-[var(--ui-ink-faint)] [overflow-wrap:anywhere]",children:n==null?void 0:n.summary})]}),e.jsx(Y,{mode:"wait",children:e.jsx(J.div,{initial:{opacity:0,y:14},animate:{opacity:1,y:0},exit:{opacity:0,y:-14},transition:{duration:.26,ease:"easeOut"},children:m},o)})]})]}),s?e.jsx(Y,{initial:!1,children:j?e.jsxs(J.div,{initial:{opacity:0,x:16},animate:{opacity:1,x:0},exit:{opacity:0,x:16},transition:{duration:.22,ease:"easeOut"},className:"min-w-0 rounded-[26px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)] p-3.5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Linked inspectors"}),e.jsx("div",{className:"mt-3 grid gap-3",children:s})]}):null}):null]})}function Pe(i){return i.join(`
2
- `)}function E(i,o){return i.includes(o)?i.filter(d=>d!==o):[...i,o]}function Oe(i){return{title:i.title,status:i.status,eventTypeId:i.eventTypeId??"",customEventType:i.customEventType,eventSituation:i.eventSituation,occurredAt:i.occurredAt?i.occurredAt.slice(0,16):"",emotions:i.emotions,thoughts:i.thoughts,behaviors:i.behaviors,selfShortTerm:i.consequences.selfShortTerm,selfLongTerm:i.consequences.selfLongTerm,othersShortTerm:i.consequences.othersShortTerm,othersLongTerm:i.consequences.othersLongTerm,modeOverlaysText:Pe(i.modeOverlays),schemaLinks:i.schemaLinks,modeTimeline:i.modeTimeline,nextMoves:i.nextMoves,linkedBehaviorIds:i.linkedBehaviorIds,linkedBeliefIds:i.linkedBeliefIds,linkedModeIds:i.linkedModeIds}}function at(){var _,F,Q,K,W,$;const{reportId:i}=re(),o=ne(),[d,m]=h.useState("spark"),[s,a]=h.useState(null),[j,g]=h.useState(!1),n=p({queryKey:["forge-psyche-report",i],queryFn:()=>he(i),enabled:!!i}),l=p({queryKey:["forge-psyche-behaviors"],queryFn:ue}),v=p({queryKey:["forge-psyche-beliefs"],queryFn:pe}),w=p({queryKey:["forge-psyche-modes"],queryFn:xe}),T=p({queryKey:["forge-psyche-schema-catalog"],queryFn:ge}),N=p({queryKey:["forge-psyche-event-types"],queryFn:ve}),I=p({queryKey:["forge-psyche-emotions"],queryFn:fe});h.useEffect(()=>{var t;(t=n.data)!=null&&t.report&&a(Oe(n.data.report))},[n.data]);const M=R({mutationFn:async t=>{var k;const r=(k=n.data)==null?void 0:k.report,u=Se.parse({title:t.title,status:t.status,eventTypeId:t.eventTypeId||null,customEventType:t.customEventType,eventSituation:t.eventSituation,occurredAt:t.occurredAt?new Date(t.occurredAt).toISOString():null,emotions:t.emotions.filter(c=>c.label.trim().length>0),thoughts:t.thoughts.filter(c=>c.text.trim().length>0),behaviors:t.behaviors.filter(c=>c.text.trim().length>0),consequences:{selfShortTerm:t.selfShortTerm,selfLongTerm:t.selfLongTerm,othersShortTerm:t.othersShortTerm,othersLongTerm:t.othersLongTerm},linkedPatternIds:(r==null?void 0:r.linkedPatternIds)??[],linkedValueIds:(r==null?void 0:r.linkedValueIds)??[],linkedGoalIds:(r==null?void 0:r.linkedGoalIds)??[],linkedProjectIds:(r==null?void 0:r.linkedProjectIds)??[],linkedTaskIds:(r==null?void 0:r.linkedTaskIds)??[],linkedBehaviorIds:t.linkedBehaviorIds,linkedBeliefIds:t.linkedBeliefIds,linkedModeIds:t.linkedModeIds,modeOverlays:t.modeOverlaysText.split(`
3
- `).map(c=>c.trim()).filter(Boolean),schemaLinks:t.schemaLinks.filter(Boolean),modeTimeline:t.modeTimeline.filter(c=>c.stage.trim().length>0&&c.label.trim().length>0),nextMoves:t.nextMoves.filter(Boolean)});return ce(i,u)},onSuccess:async()=>{await Promise.all([o.invalidateQueries({queryKey:["forge-psyche-report",i]}),o.invalidateQueries({queryKey:["forge-psyche-reports"]}),o.invalidateQueries({queryKey:["forge-psyche-overview"]}),o.invalidateQueries({queryKey:["forge-reward-ledger"]})])}}),S=R({mutationFn:me,onSuccess:async()=>{await o.invalidateQueries({queryKey:["forge-psyche-report",i]}),await o.invalidateQueries({queryKey:["forge-insights"]})}}),B=n.error??l.error??v.error??w.error??T.error??N.error??I.error??null;if(n.isLoading||!s)return e.jsx(de,{});if(B)return e.jsx(D,{eyebrow:"Trigger report",error:B,onRetry:()=>void Promise.all([n.refetch(),l.refetch(),v.refetch(),w.refetch(),T.refetch(),N.refetch(),I.refetch()])});if(!n.data)return e.jsx(D,{eyebrow:"Trigger report",error:new Error("Forge returned an empty trigger report payload."),onRetry:()=>void n.refetch()});const q=n.data,x=q.report,A=((_=l.data)==null?void 0:_.behaviors)??[],L=((F=v.data)==null?void 0:F.beliefs)??[],f=((Q=w.data)==null?void 0:Q.modes)??[],P=((K=T.data)==null?void 0:K.schemas)??[],Z=((W=N.data)==null?void 0:W.eventTypes)??[],ee=(($=I.data)==null?void 0:$.emotions)??[],O=[{id:"spark",label:"Spark",summary:"What happened concretely?"},{id:"wave",label:"Wave",summary:"What emotional wave moved through you?"},{id:"script",label:"Script",summary:"What did the mind start saying?"},{id:"lens",label:"Lens",summary:"Which schemas and beliefs got activated?"},{id:"state",label:"State",summary:"Which modes took the wheel?"},{id:"move",label:"Move",summary:"What did you do or want to do?"},{id:"horizon",label:"Horizon",summary:"What were the consequences?"},{id:"pivot",label:"Pivot",summary:"What is the next move now?"}],te={spark:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-[minmax(0,1fr)_13rem]",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Title"}),e.jsx(C,{value:s.title,onChange:t=>a({...s,title:t.target.value})})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Status"}),e.jsxs("select",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3 text-sm text-[var(--ui-ink-strong)]",value:s.status,onChange:t=>a({...s,status:t.target.value}),children:[e.jsx("option",{value:"draft",children:"draft"}),e.jsx("option",{value:"reviewed",children:"reviewed"}),e.jsx("option",{value:"integrated",children:"integrated"})]})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Event type"}),e.jsxs("select",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3 text-sm text-[var(--ui-ink-strong)]",value:s.eventTypeId,onChange:t=>a({...s,eventTypeId:t.target.value}),children:[e.jsx("option",{value:"",children:"Custom or uncategorized"}),Z.map(t=>e.jsx("option",{value:t.id,children:t.label},t.id))]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Occurred at"}),e.jsx(C,{type:"datetime-local",value:s.occurredAt,onChange:t=>a({...s,occurredAt:t.target.value})})]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Custom event label"}),e.jsx(C,{value:s.customEventType,onChange:t=>a({...s,customEventType:t.target.value})})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Situation"}),e.jsx(H,{value:s.eventSituation,onChange:t=>a({...s,eventSituation:t.target.value})})]})]}),wave:e.jsx(Ne,{items:s.emotions,onChange:t=>a({...s,emotions:t}),definitions:ee}),script:e.jsx(Te,{items:s.thoughts,onChange:t=>a({...s,thoughts:t}),beliefs:L,modes:f}),lens:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-4 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:"Schema links"}),e.jsx(U,{content:"Use maladaptive schemas for recurring old patterns that were active here. Use adaptive schemas for healthier patterns you want this response to build on.",label:"Explain schema links"})]}),e.jsx(V,{children:"Choose the schemas that were active here or that you want the repair move to strengthen."}),[{title:"Maladaptive schemas",schemas:P.filter(t=>t.schemaType==="maladaptive"),schemaType:"maladaptive",description:"Recurring old patterns that felt active in this moment."},{title:"Adaptive schemas",schemas:P.filter(t=>t.schemaType==="adaptive"),schemaType:"adaptive",description:"Healthier stable themes you want this chain to strengthen."}].map(t=>{const r=Le(t.schemaType);return e.jsxs("div",{className:`rounded-[22px] border p-4 ${r.cardTone}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:t.title}),e.jsx(U,{content:Ee(t.schemaType),label:`Explain ${Ce(t.schemaType)}`})]}),e.jsx(V,{className:"mt-2",children:t.description}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:t.schemas.map(u=>{const k=s.schemaLinks.some(c=>{var z;return((z=Me(c,[u]))==null?void 0:z.id)===u.id});return e.jsx("button",{type:"button",className:`rounded-full border px-3 py-2 text-sm transition ${k?`${r.badgeTone} ring-1 ring-[color-mix(in_srgb,var(--primary)_28%,transparent)]`:"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:()=>a({...s,schemaLinks:Be(s.schemaLinks,u)}),children:u.title},u.id)})})]},t.schemaType)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Linked beliefs"}),e.jsx("div",{className:"mt-3 flex max-h-56 flex-wrap gap-2 overflow-y-auto",children:L.map(t=>{const r=s.linkedBeliefIds.includes(t.id);return e.jsx("button",{type:"button",className:`rounded-full px-3 py-2 text-sm transition ${r?"bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]":"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"}`,onClick:()=>a({...s,linkedBeliefIds:E(s.linkedBeliefIds,t.id)}),children:t.statement},t.id)})})]})]}),state:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Mode overlays"}),e.jsx(H,{value:s.modeOverlaysText,onChange:t=>a({...s,modeOverlaysText:t.target.value})})]}),e.jsx(we,{items:s.modeTimeline,onChange:t=>a({...s,modeTimeline:t}),modes:f,stages:O.map(t=>t.label)}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Linked modes"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:f.map(t=>{const r=s.linkedModeIds.includes(t.id);return e.jsx("button",{type:"button",className:`rounded-full px-3 py-2 text-sm transition ${r?"bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]":"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"}`,onClick:()=>a({...s,linkedModeIds:E(s.linkedModeIds,t.id)}),children:t.title},t.id)})})]})]}),move:e.jsxs("div",{className:"grid gap-4",children:[e.jsx(ke,{items:s.behaviors,onChange:t=>a({...s,behaviors:t}),behaviors:A,modes:f}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Linked behaviors"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:A.map(t=>{const r=s.linkedBehaviorIds.includes(t.id);return e.jsx("button",{type:"button",className:`rounded-full px-3 py-2 text-sm transition ${r?"bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]":"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"}`,onClick:()=>a({...s,linkedBehaviorIds:E(s.linkedBehaviorIds,t.id)}),children:t.title},t.id)})})]})]}),horizon:e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(y,{title:"Short-term impact on you",description:"What happened to you right away?",addLabel:"Add self effect",items:s.selfShortTerm,onChange:t=>a({...s,selfShortTerm:t}),placeholder:"I shut down and lost the evening."}),e.jsx(y,{title:"Long-term impact on you",description:"What does this cost if it keeps repeating?",addLabel:"Add self cost",items:s.selfLongTerm,onChange:t=>a({...s,selfLongTerm:t}),placeholder:"It keeps training the same abandonment script."}),e.jsx(y,{title:"Short-term impact on others",description:"What happened to other people right away?",addLabel:"Add other effect",items:s.othersShortTerm,onChange:t=>a({...s,othersShortTerm:t}),placeholder:"They felt shut out."}),e.jsx(y,{title:"Long-term impact on others",description:"What pattern does this create over time?",addLabel:"Add other cost",items:s.othersLongTerm,onChange:t=>a({...s,othersLongTerm:t}),placeholder:"Trust gets thinner each time."})]}),pivot:e.jsxs("div",{className:"grid gap-4",children:[e.jsx(y,{title:"What is the next move now?",description:"Finish with concrete repairs, boundaries, or committed actions.",addLabel:"Add next move",items:s.nextMoves,onChange:t=>a({...s,nextMoves:t}),placeholder:"Send one honest repair message tomorrow morning."}),e.jsx("div",{className:"flex justify-end",children:e.jsx(b,{pending:M.isPending,onClick:()=>void M.mutateAsync(s),children:"Save chain"})})]})},se=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rounded-[22px] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Linked modes"}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[f.filter(t=>s.linkedModeIds.includes(t.id)).map(t=>e.jsx(G,{kind:"mode",label:t.title,compact:!0},t.id)),s.linkedModeIds.length===0?e.jsx(b,{variant:"secondary",size:"sm",onClick:()=>m("state"),children:"Link mode"}):null]})]}),e.jsxs("div",{className:"rounded-[22px] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Linked beliefs"}),e.jsxs("div",{className:"mt-3 grid gap-2",children:[L.filter(t=>s.linkedBeliefIds.includes(t.id)).map(t=>e.jsx("div",{className:"rounded-[16px] bg-[var(--ui-surface-1)] px-3 py-3",children:e.jsx(G,{kind:"belief",label:t.statement,compact:!0})},t.id)),s.linkedBeliefIds.length===0?e.jsx(b,{variant:"secondary",size:"sm",onClick:()=>m("lens"),children:"Link belief"}):null]})]}),e.jsx(je,{entityType:"trigger_report",entityId:x.id,anchorKey:d,includeAnchorlessWhenAnchored:!0,compact:!0,title:`Stage notes on ${d}`,description:"Use anchored Markdown notes to capture what became clear at this stage of the chain.",invalidateQueryKeys:[["forge-psyche-report",i],["forge-psyche-reports"],["forge-psyche-overview"]]}),e.jsxs("div",{className:"rounded-[22px] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Insights"}),e.jsxs("div",{className:"mt-3 grid gap-2",children:[q.insights.map(t=>e.jsxs("div",{className:"rounded-[16px] bg-[var(--ui-surface-1)] px-3 py-3 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:t.title}),e.jsx("div",{className:"mt-2 text-[var(--ui-ink-soft)]",children:t.summary})]},t.id)),e.jsx(b,{variant:"secondary",pending:S.isPending,onClick:()=>g(!0),children:"Store insight"})]})]})]});return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(Ie,{eyebrow:"Trigger report",title:x.title,description:"Move through Spark to Pivot in one chain canvas.",badge:x.status,actions:e.jsx(be,{entityType:"trigger_report",entityId:x.id})}),e.jsx(le,{}),e.jsx(Ae,{stages:O,activeStageId:d,onStageChange:m,stageContent:te[d],inspector:se}),e.jsx(ye,{open:j,onOpenChange:g,eyebrow:"Report insight",title:"Store report insight",description:"Capture the insight from this report as a guided recommendation instead of a raw side-panel form.",submitLabel:"Store insight",pending:S.isPending,lockedEntity:{entityType:"trigger_report",entityId:x.id,kind:"report",label:x.title,description:`Anchored to the ${d} stage of this reflective chain.`},initialValue:{originType:"user",originLabel:"Forge Psyche",timeframeLabel:"Current trigger report",rationale:`Captured from the ${d} stage of the Psyche chain canvas.`},onSubmit:async t=>{await S.mutateAsync(t)}})]})}export{at as PsycheReportDetailPage};
1
+ import{r as h,j as e,dc as ie,b6 as ae,b_ as re}from"./vendor-Dgw7UY7q.js";import{j as ne,i as p,k as D}from"./state-CkEUXgqt.js";import{B as b,c as oe,S as de,e as R,T as H,af as U,ae as V,I as C,b as G,bD as le,cC as ce,an as me,cD as he,bg as ue,bh as pe,bi as xe,c0 as ge,cE as ve,cF as fe}from"./index-C0CztQTU.js";import{A as Y,m as J}from"./motion-eRlWWQT8.js";import{I as ye}from"./insight-flow-dialog-DdxIE6oo.js";import{O as be}from"./open-in-graph-button-JgYTH-IQ.js";import{E as je}from"./entity-notes-surface-Csbm1myW.js";import{S as y,B as ke,M as we,T as Te,E as Ne}from"./report-chain-fields-D-XNut8V.js";import{P as Ie}from"./page-hero-ED69y6m0.js";import{t as Se}from"./psyche-schemas-B00gm5HO.js";import{b as Le,a as Ce,c as Ee,f as Me,t as Be}from"./schema-visuals-CvC9a3i6.js";import"./ui-CDt36qNz.js";import"./board-Dl7As76Q.js";import"./forms-DznAv9hZ.js";import"./question-flow-dialog-B4B3BI8e.js";import"./schemas-3GS34K1i.js";import"./note-markdown-Dpve4W0R.js";import"./note-tags-input-Hvi_ifLe.js";import"./entity-link-multiselect-HmmmJO5A.js";import"./use-anchored-overlay-position-C2kg0Ay0.js";import"./user-ownership-DJGl4rAj.js";const X="(max-width: 1023px)";function qe(){const[i,o]=h.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(X).matches);return h.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const d=window.matchMedia(X),m=s=>o(s.matches);return o(d.matches),typeof d.addEventListener=="function"?(d.addEventListener("change",m),()=>d.removeEventListener("change",m)):(d.addListener(m),()=>d.removeListener(m))},[]),i}function Ae({stages:i,activeStageId:o,onStageChange:d,stageContent:m,inspector:s}){const a=qe(),[j,g]=h.useState(!1),n=i.find(l=>l.id===o);return h.useEffect(()=>{g(!a)},[a]),e.jsxs("section",{className:"grid min-w-0 gap-4 xl:grid-cols-[minmax(0,1fr)_18rem]",children:[e.jsxs("div",{className:"min-w-0 rounded-[30px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)] p-4",children:[e.jsxs("div",{className:"mb-4 flex items-start justify-between gap-3",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:"Tracing the chain"}),e.jsx("div",{className:"mt-1 break-words text-sm text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:n==null?void 0:n.summary})]}),s?e.jsxs(b,{variant:"secondary",size:"sm",onClick:()=>g(l=>!l),children:[j?e.jsx(ie,{className:"size-4"}):e.jsx(ae,{className:"size-4"}),"Inspector"]}):null]}),e.jsx("div",{className:"mb-4 pb-1",children:e.jsx("div",{className:"flex min-w-0 flex-wrap items-center gap-3",children:i.map((l,v)=>e.jsxs("button",{type:"button",className:oe("min-w-0 max-w-full rounded-[22px] px-4 py-3 text-left transition",a?"flex-1 basis-[5.5rem]":"basis-[13rem]",l.id===o?"bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)] shadow-[var(--ui-shadow-soft)]":"bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>d(l.id),children:[e.jsxs("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:[v+1,". ",l.label]}),a?null:e.jsx("div",{className:"mt-1.5 text-sm leading-5",children:l.summary})]},l.id))})}),e.jsxs("div",{className:"min-w-0 rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4 md:p-5",children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"rounded-full bg-[var(--ui-surface-2)] px-3 py-1.5 text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:n==null?void 0:n.label}),e.jsx("span",{className:"min-w-0 break-words text-sm text-[var(--ui-ink-faint)] [overflow-wrap:anywhere]",children:n==null?void 0:n.summary})]}),e.jsx(Y,{mode:"wait",children:e.jsx(J.div,{initial:{opacity:0,y:14},animate:{opacity:1,y:0},exit:{opacity:0,y:-14},transition:{duration:.26,ease:"easeOut"},children:m},o)})]})]}),s?e.jsx(Y,{initial:!1,children:j?e.jsxs(J.div,{initial:{opacity:0,x:16},animate:{opacity:1,x:0},exit:{opacity:0,x:16},transition:{duration:.22,ease:"easeOut"},className:"min-w-0 rounded-[26px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)] p-3.5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Linked inspectors"}),e.jsx("div",{className:"mt-3 grid gap-3",children:s})]}):null}):null]})}function Pe(i){return i.join(`
2
+ `)}function E(i,o){return i.includes(o)?i.filter(d=>d!==o):[...i,o]}function Oe(i){return{title:i.title,status:i.status,eventTypeId:i.eventTypeId??"",customEventType:i.customEventType,eventSituation:i.eventSituation,occurredAt:i.occurredAt?i.occurredAt.slice(0,16):"",emotions:i.emotions,thoughts:i.thoughts,behaviors:i.behaviors,selfShortTerm:i.consequences.selfShortTerm,selfLongTerm:i.consequences.selfLongTerm,othersShortTerm:i.consequences.othersShortTerm,othersLongTerm:i.consequences.othersLongTerm,modeOverlaysText:Pe(i.modeOverlays),schemaLinks:i.schemaLinks,modeTimeline:i.modeTimeline,nextMoves:i.nextMoves,linkedBehaviorIds:i.linkedBehaviorIds,linkedBeliefIds:i.linkedBeliefIds,linkedModeIds:i.linkedModeIds}}function at(){var F,_,Q,K,W,$;const{reportId:i}=re(),o=ne(),[d,m]=h.useState("spark"),[s,a]=h.useState(null),[j,g]=h.useState(!1),n=p({queryKey:["forge-psyche-report",i],queryFn:()=>he(i),enabled:!!i}),l=p({queryKey:["forge-psyche-behaviors"],queryFn:ue}),v=p({queryKey:["forge-psyche-beliefs"],queryFn:pe}),w=p({queryKey:["forge-psyche-modes"],queryFn:xe}),T=p({queryKey:["forge-psyche-schema-catalog"],queryFn:ge}),N=p({queryKey:["forge-psyche-event-types"],queryFn:ve}),I=p({queryKey:["forge-psyche-emotions"],queryFn:fe});h.useEffect(()=>{var t;(t=n.data)!=null&&t.report&&a(Oe(n.data.report))},[n.data]);const M=D({mutationFn:async t=>{var k;const r=(k=n.data)==null?void 0:k.report,u=Se.parse({title:t.title,status:t.status,eventTypeId:t.eventTypeId||null,customEventType:t.customEventType,eventSituation:t.eventSituation,occurredAt:t.occurredAt?new Date(t.occurredAt).toISOString():null,emotions:t.emotions.filter(c=>c.label.trim().length>0),thoughts:t.thoughts.filter(c=>c.text.trim().length>0),behaviors:t.behaviors.filter(c=>c.text.trim().length>0),consequences:{selfShortTerm:t.selfShortTerm,selfLongTerm:t.selfLongTerm,othersShortTerm:t.othersShortTerm,othersLongTerm:t.othersLongTerm},linkedPatternIds:(r==null?void 0:r.linkedPatternIds)??[],linkedValueIds:(r==null?void 0:r.linkedValueIds)??[],linkedGoalIds:(r==null?void 0:r.linkedGoalIds)??[],linkedProjectIds:(r==null?void 0:r.linkedProjectIds)??[],linkedTaskIds:(r==null?void 0:r.linkedTaskIds)??[],linkedBehaviorIds:t.linkedBehaviorIds,linkedBeliefIds:t.linkedBeliefIds,linkedModeIds:t.linkedModeIds,modeOverlays:t.modeOverlaysText.split(`
3
+ `).map(c=>c.trim()).filter(Boolean),schemaLinks:t.schemaLinks.filter(Boolean),modeTimeline:t.modeTimeline.filter(c=>c.stage.trim().length>0&&c.label.trim().length>0),nextMoves:t.nextMoves.filter(Boolean)});return ce(i,u)},onSuccess:async()=>{await Promise.all([o.invalidateQueries({queryKey:["forge-psyche-report",i]}),o.invalidateQueries({queryKey:["forge-psyche-reports"]}),o.invalidateQueries({queryKey:["forge-psyche-overview"]}),o.invalidateQueries({queryKey:["forge-reward-ledger"]})])}}),S=D({mutationFn:me,onSuccess:async()=>{await o.invalidateQueries({queryKey:["forge-psyche-report",i]}),await o.invalidateQueries({queryKey:["forge-insights"]})}}),B=n.error??l.error??v.error??w.error??T.error??N.error??I.error??null;if(n.isLoading||!s)return e.jsx(de,{});if(B)return e.jsx(R,{eyebrow:"Trigger report",error:B,onRetry:()=>void Promise.all([n.refetch(),l.refetch(),v.refetch(),w.refetch(),T.refetch(),N.refetch(),I.refetch()])});if(!n.data)return e.jsx(R,{eyebrow:"Trigger report",error:new Error("Forge returned an empty trigger report payload."),onRetry:()=>void n.refetch()});const q=n.data,x=q.report,A=((F=l.data)==null?void 0:F.behaviors)??[],L=((_=v.data)==null?void 0:_.beliefs)??[],f=((Q=w.data)==null?void 0:Q.modes)??[],P=((K=T.data)==null?void 0:K.schemas)??[],Z=((W=N.data)==null?void 0:W.eventTypes)??[],ee=(($=I.data)==null?void 0:$.emotions)??[],O=[{id:"spark",label:"Spark",summary:"What happened concretely?"},{id:"wave",label:"Wave",summary:"What emotional wave moved through you?"},{id:"script",label:"Script",summary:"What did the mind start saying?"},{id:"lens",label:"Lens",summary:"Which schemas and beliefs got activated?"},{id:"state",label:"State",summary:"Which modes took the wheel?"},{id:"move",label:"Move",summary:"What did you do or want to do?"},{id:"horizon",label:"Horizon",summary:"What were the consequences?"},{id:"pivot",label:"Pivot",summary:"What is the next move now?"}],te={spark:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-[minmax(0,1fr)_13rem]",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Title"}),e.jsx(C,{value:s.title,onChange:t=>a({...s,title:t.target.value})})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Status"}),e.jsxs("select",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3 text-sm text-[var(--ui-ink-strong)]",value:s.status,onChange:t=>a({...s,status:t.target.value}),children:[e.jsx("option",{value:"draft",children:"draft"}),e.jsx("option",{value:"reviewed",children:"reviewed"}),e.jsx("option",{value:"integrated",children:"integrated"})]})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Event type"}),e.jsxs("select",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3 text-sm text-[var(--ui-ink-strong)]",value:s.eventTypeId,onChange:t=>a({...s,eventTypeId:t.target.value}),children:[e.jsx("option",{value:"",children:"Custom or uncategorized"}),Z.map(t=>e.jsx("option",{value:t.id,children:t.label},t.id))]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Occurred at"}),e.jsx(C,{type:"datetime-local",value:s.occurredAt,onChange:t=>a({...s,occurredAt:t.target.value})})]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Custom event label"}),e.jsx(C,{value:s.customEventType,onChange:t=>a({...s,customEventType:t.target.value})})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Situation"}),e.jsx(H,{value:s.eventSituation,onChange:t=>a({...s,eventSituation:t.target.value})})]})]}),wave:e.jsx(Ne,{items:s.emotions,onChange:t=>a({...s,emotions:t}),definitions:ee}),script:e.jsx(Te,{items:s.thoughts,onChange:t=>a({...s,thoughts:t}),beliefs:L,modes:f}),lens:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-4 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:"Schema links"}),e.jsx(U,{content:"Use maladaptive schemas for recurring old patterns that were active here. Use adaptive schemas for healthier patterns you want this response to build on.",label:"Explain schema links"})]}),e.jsx(V,{children:"Choose the schemas that were active here or that you want the repair move to strengthen."}),[{title:"Maladaptive schemas",schemas:P.filter(t=>t.schemaType==="maladaptive"),schemaType:"maladaptive",description:"Recurring old patterns that felt active in this moment."},{title:"Adaptive schemas",schemas:P.filter(t=>t.schemaType==="adaptive"),schemaType:"adaptive",description:"Healthier stable themes you want this chain to strengthen."}].map(t=>{const r=Le(t.schemaType);return e.jsxs("div",{className:`rounded-[22px] border p-4 ${r.cardTone}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:t.title}),e.jsx(U,{content:Ee(t.schemaType),label:`Explain ${Ce(t.schemaType)}`})]}),e.jsx(V,{className:"mt-2",children:t.description}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:t.schemas.map(u=>{const k=s.schemaLinks.some(c=>{var z;return((z=Me(c,[u]))==null?void 0:z.id)===u.id});return e.jsx("button",{type:"button",className:`rounded-full border px-3 py-2 text-sm transition ${k?`${r.badgeTone} ring-1 ring-[color-mix(in_srgb,var(--primary)_28%,transparent)]`:"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:()=>a({...s,schemaLinks:Be(s.schemaLinks,u)}),children:u.title},u.id)})})]},t.schemaType)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Linked beliefs"}),e.jsx("div",{className:"mt-3 flex max-h-56 flex-wrap gap-2 overflow-y-auto",children:L.map(t=>{const r=s.linkedBeliefIds.includes(t.id);return e.jsx("button",{type:"button",className:`rounded-full px-3 py-2 text-sm transition ${r?"bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]":"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"}`,onClick:()=>a({...s,linkedBeliefIds:E(s.linkedBeliefIds,t.id)}),children:t.statement},t.id)})})]})]}),state:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Mode overlays"}),e.jsx(H,{value:s.modeOverlaysText,onChange:t=>a({...s,modeOverlaysText:t.target.value})})]}),e.jsx(we,{items:s.modeTimeline,onChange:t=>a({...s,modeTimeline:t}),modes:f,stages:O.map(t=>t.label)}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Linked modes"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:f.map(t=>{const r=s.linkedModeIds.includes(t.id);return e.jsx("button",{type:"button",className:`rounded-full px-3 py-2 text-sm transition ${r?"bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]":"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"}`,onClick:()=>a({...s,linkedModeIds:E(s.linkedModeIds,t.id)}),children:t.title},t.id)})})]})]}),move:e.jsxs("div",{className:"grid gap-4",children:[e.jsx(ke,{items:s.behaviors,onChange:t=>a({...s,behaviors:t}),behaviors:A,modes:f}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Linked behaviors"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:A.map(t=>{const r=s.linkedBehaviorIds.includes(t.id);return e.jsx("button",{type:"button",className:`rounded-full px-3 py-2 text-sm transition ${r?"bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]":"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"}`,onClick:()=>a({...s,linkedBehaviorIds:E(s.linkedBehaviorIds,t.id)}),children:t.title},t.id)})})]})]}),horizon:e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(y,{title:"Short-term impact on you",description:"What happened to you right away?",addLabel:"Add self effect",items:s.selfShortTerm,onChange:t=>a({...s,selfShortTerm:t}),placeholder:"I shut down and lost the evening."}),e.jsx(y,{title:"Long-term impact on you",description:"What does this cost if it keeps repeating?",addLabel:"Add self cost",items:s.selfLongTerm,onChange:t=>a({...s,selfLongTerm:t}),placeholder:"It keeps training the same abandonment script."}),e.jsx(y,{title:"Short-term impact on others",description:"What happened to other people right away?",addLabel:"Add other effect",items:s.othersShortTerm,onChange:t=>a({...s,othersShortTerm:t}),placeholder:"They felt shut out."}),e.jsx(y,{title:"Long-term impact on others",description:"What pattern does this create over time?",addLabel:"Add other cost",items:s.othersLongTerm,onChange:t=>a({...s,othersLongTerm:t}),placeholder:"Trust gets thinner each time."})]}),pivot:e.jsxs("div",{className:"grid gap-4",children:[e.jsx(y,{title:"What is the next move now?",description:"Finish with concrete repairs, boundaries, or committed actions.",addLabel:"Add next move",items:s.nextMoves,onChange:t=>a({...s,nextMoves:t}),placeholder:"Send one honest repair message tomorrow morning."}),e.jsx("div",{className:"flex justify-end",children:e.jsx(b,{pending:M.isPending,onClick:()=>void M.mutateAsync(s),children:"Save chain"})})]})},se=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rounded-[22px] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Linked modes"}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[f.filter(t=>s.linkedModeIds.includes(t.id)).map(t=>e.jsx(G,{kind:"mode",label:t.title,compact:!0},t.id)),s.linkedModeIds.length===0?e.jsx(b,{variant:"secondary",size:"sm",onClick:()=>m("state"),children:"Link mode"}):null]})]}),e.jsxs("div",{className:"rounded-[22px] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Linked beliefs"}),e.jsxs("div",{className:"mt-3 grid gap-2",children:[L.filter(t=>s.linkedBeliefIds.includes(t.id)).map(t=>e.jsx("div",{className:"rounded-[16px] bg-[var(--ui-surface-1)] px-3 py-3",children:e.jsx(G,{kind:"belief",label:t.statement,compact:!0})},t.id)),s.linkedBeliefIds.length===0?e.jsx(b,{variant:"secondary",size:"sm",onClick:()=>m("lens"),children:"Link belief"}):null]})]}),e.jsx(je,{entityType:"trigger_report",entityId:x.id,anchorKey:d,includeAnchorlessWhenAnchored:!0,compact:!0,title:`Stage notes on ${d}`,description:"Use anchored Markdown notes to capture what became clear at this stage of the chain.",invalidateQueryKeys:[["forge-psyche-report",i],["forge-psyche-reports"],["forge-psyche-overview"]]}),e.jsxs("div",{className:"rounded-[22px] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Insights"}),e.jsxs("div",{className:"mt-3 grid gap-2",children:[q.insights.map(t=>e.jsxs("div",{className:"rounded-[16px] bg-[var(--ui-surface-1)] px-3 py-3 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:t.title}),e.jsx("div",{className:"mt-2 text-[var(--ui-ink-soft)]",children:t.summary})]},t.id)),e.jsx(b,{variant:"secondary",pending:S.isPending,onClick:()=>g(!0),children:"Store insight"})]})]})]});return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(Ie,{eyebrow:"Trigger report",title:x.title,description:"Move through Spark to Pivot in one chain canvas.",badge:x.status,actions:e.jsx(be,{entityType:"trigger_report",entityId:x.id})}),e.jsx(le,{}),e.jsx(Ae,{stages:O,activeStageId:d,onStageChange:m,stageContent:te[d],inspector:se}),e.jsx(ye,{open:j,onOpenChange:g,eyebrow:"Report insight",title:"Store report insight",description:"Capture the insight from this report as a guided recommendation instead of a raw side-panel form.",submitLabel:"Store insight",pending:S.isPending,lockedEntity:{entityType:"trigger_report",entityId:x.id,kind:"report",label:x.title,description:`Anchored to the ${d} stage of this reflective chain.`},initialValue:{originType:"user",originLabel:"Forge Psyche",timeframeLabel:"Current trigger report",rationale:`Captured from the ${d} stage of the Psyche chain canvas.`},onSubmit:async t=>{await S.mutateAsync(t)}})]})}export{at as PsycheReportDetailPage};
@@ -1 +1 @@
1
- import{bZ as ve,r as S,j as t,aC as fe}from"./vendor-B7FKSwHK.js";import{j as ye,i as d,k as xe}from"./state-BFyKSULP.js";import{Q as ke,F as o}from"./question-flow-dialog-yMYVk998.js";import{E as be}from"./entity-note-count-link-BGOiaash.js";import{A as we}from"./atlas-panel-VZOnJa1c.js";import{E as L}from"./entity-link-multiselect-BfDAROHB.js";import{S as Ie}from"./schema-badge-jX28kUa6.js";import{E as Te,T as je,B as Se,S as m,M as Le}from"./report-chain-fields-D4NM9a6I.js";import{d as Ne,L as Ce,e as Ee,B as Be,E as Z,bB as Pe,h as Me,a0 as Ae,j as Fe,cE as qe,I as q,T as Re,ad as Oe,ac as De,bY as Qe,bW as Ke,c8 as Ue,bZ as $e,bi as Ge,bc as _e,be as He,bf as ze,bg as We,b_ as Ve,cC as Ye,cD as Ze}from"./index-gmPaoLN-.js";import{P as Je}from"./page-hero-U603l9rQ.js";import{U as Xe}from"./user-badge-C4eZu1e_.js";import{U as et}from"./user-select-field-CmKwcbZt.js";import{p as N}from"./query-cache-IQ8W-LNC.js";import{t as J}from"./psyche-schemas-Cg51Ztxz.js";import{f as X,b as tt,a as st,c as rt,t as it}from"./schema-visuals-CvC9a3i6.js";import{g as at,b as C,d as E,e as B,a as nt}from"./user-ownership-DJGl4rAj.js";import"./ui-uo_bNP7c.js";import"./motion-BibSzp57.js";import"./use-anchored-overlay-position-BSxFX6Hi.js";import"./board-DprRipIG.js";import"./forms-ByKjodjN.js";const P={title:"",status:"draft",eventTypeId:"",customEventType:"",eventSituation:"",occurredAt:"",emotions:[],thoughts:[],behaviors:[],selfShortTerm:[],selfLongTerm:[],othersShortTerm:[],othersLongTerm:[],linkedValueIds:[],linkedBehaviorIds:[],linkedBeliefIds:[],linkedModeIds:[],linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],schemaLinks:[],modeTimeline:[],nextMoves:[],userId:null};function ot(l){const n=new Date(l);if(Number.isNaN(n.getTime()))return"";const a=n.getFullYear(),p=String(n.getMonth()+1).padStart(2,"0"),M=String(n.getDate()).padStart(2,"0"),c=String(n.getHours()).padStart(2,"0"),i=String(n.getMinutes()).padStart(2,"0");return`${a}-${p}-${M}T${c}:${i}`}function Ct(){var K,U,$,G,_,H,z,W;const l=Ne(),n=ye(),[a,p]=ve(),[M,c]=S.useState(!1),[i,u]=S.useState(P),[ee,g]=S.useState(null),v=d({queryKey:["forge-psyche-reports"],queryFn:Ge}),f=d({queryKey:["forge-psyche-values"],queryFn:_e}),y=d({queryKey:["forge-psyche-behaviors"],queryFn:He}),x=d({queryKey:["forge-psyche-beliefs"],queryFn:ze}),k=d({queryKey:["forge-psyche-modes"],queryFn:We}),b=d({queryKey:["forge-psyche-schema-catalog"],queryFn:Ve}),w=d({queryKey:["forge-psyche-event-types"],queryFn:Ye}),I=d({queryKey:["forge-psyche-emotions"],queryFn:Ze}),A=((K=v.data)==null?void 0:K.reports)??[],te=((U=f.data)==null?void 0:U.values)??[],R=(($=y.data)==null?void 0:$.behaviors)??[],O=((G=x.data)==null?void 0:G.beliefs)??[],T=((_=k.data)==null?void 0:_.modes)??[],F=((H=b.data)==null?void 0:H.schemas)??[],se=((z=w.data)==null?void 0:z.eventTypes)??[],re=((W=I.data)==null?void 0:W.emotions)??[],j=at(l.selectedUserIds),ie=l.snapshot.dashboard.notesSummaryByEntity;S.useEffect(()=>{if(a.get("create")==="1"){c(!0),u({...P,userId:a.get("userId")??j,occurredAt:a.get("occurredAt")?ot(a.get("occurredAt")):"",customEventType:a.get("intent")==="execution_tension"?"Execution tension":a.get("intent")==="belief"?"Belief script activation":a.get("intent")==="behavior"?"Behavior spike":a.get("intent")==="pattern"?"Recurring pattern":a.get("intent")==="value"?"Blocked value":"",linkedValueIds:a.get("valueId")?[a.get("valueId")]:[],linkedBehaviorIds:a.get("behaviorId")?[a.get("behaviorId")]:[],linkedBeliefIds:a.get("beliefId")?[a.get("beliefId")]:[],linkedGoalIds:a.get("goalId")?[a.get("goalId")]:[],linkedProjectIds:a.get("projectId")?[a.get("projectId")]:[],linkedTaskIds:a.get("taskId")?[a.get("taskId")]:[]});const e=new URLSearchParams(a);e.delete("create"),e.delete("intent"),e.delete("occurredAt"),e.delete("userId"),e.delete("valueId"),e.delete("behaviorId"),e.delete("beliefId"),e.delete("goalId"),e.delete("projectId"),e.delete("taskId"),p(e,{replace:!0})}},[a,p]);const D=xe({mutationFn:async e=>{const r=J.parse({title:e.title,status:e.status,eventTypeId:e.eventTypeId||null,customEventType:e.customEventType,eventSituation:e.eventSituation,occurredAt:e.occurredAt?new Date(e.occurredAt).toISOString():null,emotions:e.emotions.filter(s=>s.label.trim().length>0),thoughts:e.thoughts.filter(s=>s.text.trim().length>0),behaviors:e.behaviors.filter(s=>s.text.trim().length>0),consequences:{selfShortTerm:e.selfShortTerm,selfLongTerm:e.selfLongTerm,othersShortTerm:e.othersShortTerm,othersLongTerm:e.othersLongTerm},linkedPatternIds:[],linkedValueIds:e.linkedValueIds,linkedGoalIds:e.linkedGoalIds,linkedProjectIds:e.linkedProjectIds,linkedTaskIds:e.linkedTaskIds,linkedBehaviorIds:e.linkedBehaviorIds,linkedBeliefIds:e.linkedBeliefIds,linkedModeIds:e.linkedModeIds,modeOverlays:[],schemaLinks:e.schemaLinks.filter(Boolean),modeTimeline:e.modeTimeline.filter(s=>s.stage.trim().length>0&&s.label.trim().length>0),nextMoves:e.nextMoves.filter(Boolean),userId:e.userId});return qe(r)},onSuccess:async()=>{c(!1),u({...P,userId:j}),g(null),await Promise.all([n.invalidateQueries({queryKey:["forge-psyche-reports"]}),n.invalidateQueries({queryKey:["forge-psyche-overview"]}),n.invalidateQueries({queryKey:["forge-xp-metrics"]})])}}),ae=te.map(e=>({value:e.id,label:B(e.title,e.user),description:E(e.valuedDirection,e.user),searchText:C([e.title,e.valuedDirection,e.description],e),kind:"value"})),ne=R.map(e=>({value:e.id,label:B(e.title,e.user),description:E(e.kind,e.user),searchText:C([e.title,e.kind,e.description],e),kind:"behavior"})),oe=O.map(e=>({value:e.id,label:B(e.statement,e.user),description:E(e.flexibleAlternative||e.originNote,e.user),searchText:C([e.statement,e.flexibleAlternative,e.originNote,e.beliefType],e),kind:"belief"})),de=T.map(e=>({value:e.id,label:B(e.title,e.user),description:E(e.archetype||e.family,e.user),searchText:C([e.title,e.archetype,e.family,e.persona],e),kind:"mode"})),le=async e=>{const{value:r}=await Qe({title:e,description:"",valuedDirection:e,whyItMatters:"",linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],committedActions:[],userId:i.userId});return N(n,["forge-psyche-values"],"values",r),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:r.id,label:r.title,description:r.valuedDirection,kind:"value"}},ce=async e=>{const{behavior:r}=await Ke({kind:"away",title:e,description:"",commonCues:[],urgeStory:"",shortTermPayoff:"",longTermCost:"",replacementMove:"",repairPlan:"",linkedPatternIds:[],linkedValueIds:[],linkedSchemaIds:[],linkedModeIds:[],userId:i.userId});return N(n,["forge-psyche-behaviors"],"behaviors",r),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:r.id,label:r.title,description:r.kind,kind:"behavior"}},he=async e=>{const{belief:r}=await Ue({schemaId:null,statement:e,beliefType:"absolute",originNote:"",confidence:60,evidenceFor:[],evidenceAgainst:[],flexibleAlternative:"",linkedValueIds:[],linkedBehaviorIds:[],linkedModeIds:[],linkedReportIds:[],userId:i.userId});return N(n,["forge-psyche-beliefs"],"beliefs",r),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:r.id,label:r.statement,description:r.flexibleAlternative||r.originNote,kind:"belief"}},me=async e=>{const{mode:r}=await $e({family:"coping",archetype:"",title:e,persona:"",imagery:"",symbolicForm:"",facialExpression:"",fear:"",burden:"",protectiveJob:"",originContext:"",firstAppearanceAt:null,linkedPatternIds:[],linkedBehaviorIds:[],linkedValueIds:[],userId:i.userId});return N(n,["forge-psyche-modes"],"modes",r),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:r.id,label:r.title,description:r.archetype||r.family,kind:"mode"}},pe=[{id:"spark",eyebrow:"Spark",title:"Capture the trigger and the situation",description:"Start with what happened concretely before interpretation takes over.",render:(e,r)=>t.jsxs(t.Fragment,{children:[t.jsx(et,{value:e.userId,users:l.snapshot.users,onChange:s=>r({userId:s}),defaultLabel:nt(l.snapshot.users.find(s=>s.id===j)??null,"Choose report owner"),help:"Trigger reports can belong to a human or bot user while still linking to shared values, behaviors, beliefs, and modes."}),t.jsx(o,{label:"Report title",children:t.jsx(q,{value:e.title,onChange:s=>r({title:s.target.value}),placeholder:"Friday silence spiral"})}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(o,{label:"Event type",children:t.jsxs("select",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3 text-sm text-[var(--ui-ink-strong)]",value:e.eventTypeId,onChange:s=>r({eventTypeId:s.target.value}),children:[t.jsx("option",{value:"",children:"Custom or uncategorized"}),se.map(s=>t.jsx("option",{value:s.id,children:s.label},s.id))]})}),t.jsx(o,{label:"Occurred at",children:t.jsx(q,{type:"datetime-local",value:e.occurredAt,onChange:s=>r({occurredAt:s.target.value})})})]}),t.jsx(o,{label:"Custom event label",children:t.jsx(q,{value:e.customEventType,onChange:s=>r({customEventType:s.target.value}),placeholder:"Unexpected distance after vulnerability"})}),t.jsx(o,{label:"Situation",children:t.jsx(Re,{value:e.eventSituation,onChange:s=>r({eventSituation:s.target.value}),placeholder:"Describe what happened concretely, without explaining it away yet."})})]})},{id:"wave-script-move",eyebrow:"Wave, script, move",title:"Capture the emotional wave, thought script, and behavior",description:"These stay structured, but the flow keeps them staged instead of dumping everything into one giant form.",render:(e,r)=>t.jsxs(t.Fragment,{children:[t.jsx(Te,{items:e.emotions,onChange:s=>r({emotions:s}),definitions:re}),t.jsx(je,{items:e.thoughts,onChange:s=>r({thoughts:s}),beliefs:O,modes:T}),t.jsx(Se,{items:e.behaviors,onChange:s=>r({behaviors:s}),behaviors:R,modes:T})]})},{id:"lens-state",eyebrow:"Lens and state",title:"Link the report to beliefs, modes, values, and behavior history",description:"This is where the report becomes part of the larger graphical psyche system.",render:(e,r)=>t.jsxs(t.Fragment,{children:[t.jsx(o,{label:"Linked values",children:t.jsx(L,{options:ae,selectedValues:e.linkedValueIds,onChange:s=>r({linkedValueIds:s}),placeholder:"Search or create a value…",emptyMessage:"No values match yet.",createLabel:"Create value",onCreate:le})}),t.jsx(o,{label:"Linked behaviors",children:t.jsx(L,{options:ne,selectedValues:e.linkedBehaviorIds,onChange:s=>r({linkedBehaviorIds:s}),placeholder:"Search or create a behavior…",emptyMessage:"No behaviors match yet.",createLabel:"Create behavior",onCreate:ce})}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(o,{label:"Linked beliefs",children:t.jsx(L,{options:oe,selectedValues:e.linkedBeliefIds,onChange:s=>r({linkedBeliefIds:s}),placeholder:"Search or create a belief…",emptyMessage:"No beliefs match yet.",createLabel:"Create belief",onCreate:he})}),t.jsx(o,{label:"Linked modes",children:t.jsx(L,{options:de,selectedValues:e.linkedModeIds,onChange:s=>r({linkedModeIds:s}),placeholder:"Search or create a mode…",emptyMessage:"No modes match yet.",createLabel:"Create mode",onCreate:me})})]}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.linkedGoalIds.length>0?t.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm text-[var(--ui-ink-soft)]",children:["Linked to ",e.linkedGoalIds.length," goal tension"]}):null,e.linkedProjectIds.length>0?t.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm text-[var(--ui-ink-soft)]",children:["Linked to ",e.linkedProjectIds.length," project tension"]}):null,e.linkedTaskIds.length>0?t.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm text-[var(--ui-ink-soft)]",children:["Linked to ",e.linkedTaskIds.length," task tension"]}):null]})]})},{id:"horizon-pivot",eyebrow:"Horizon and pivot",title:"Record consequences, schema pressure, and the next move",description:"Use this step to record what happened next, which schemas were involved, and what you want to do after this moment.",render:(e,r)=>t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(m,{title:"Short-term impact on you",description:"Add the immediate effects on your body, mood, or direction.",addLabel:"Add self effect",items:e.selfShortTerm,onChange:s=>r({selfShortTerm:s}),placeholder:"I shut down and lost the rest of the evening."}),t.jsx(m,{title:"Long-term impact on you",description:"Capture what this pattern costs when it keeps repeating.",addLabel:"Add self cost",items:e.selfLongTerm,onChange:s=>r({selfLongTerm:s}),placeholder:"It keeps reinforcing the same abandonment story."}),t.jsx(m,{title:"Short-term impact on others",description:"Note what happened to the people around you right away.",addLabel:"Add other effect",items:e.othersShortTerm,onChange:s=>r({othersShortTerm:s}),placeholder:"They felt pushed away and confused."}),t.jsx(m,{title:"Long-term impact on others",description:"Capture the longer pattern this creates in relationships.",addLabel:"Add other cost",items:e.othersLongTerm,onChange:s=>r({othersLongTerm:s}),placeholder:"Trust gets thinner every time this loop takes over."})]}),t.jsxs("div",{className:"grid gap-4",children:[t.jsx(o,{label:"Schema links",description:"Choose the schemas that were active or that you want to strengthen in this moment.",labelHelp:"Use maladaptive schemas for recurring old patterns that felt active here. Use adaptive schemas for healthier patterns you want to rely on more.",children:t.jsx("div",{className:"grid gap-4",children:[{title:"Maladaptive schemas",schemas:F.filter(s=>s.schemaType==="maladaptive"),schemaType:"maladaptive",description:"Recurring old patterns that felt active in this moment."},{title:"Adaptive schemas",schemas:F.filter(s=>s.schemaType==="adaptive"),schemaType:"adaptive",description:"Healthier stable themes you want this repair move to strengthen."}].map(s=>{const V=tt(s.schemaType);return t.jsxs("div",{className:`rounded-[24px] border p-4 ${V.cardTone}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:s.title}),t.jsx(Oe,{content:rt(s.schemaType),label:`Explain ${st(s.schemaType)}`})]}),t.jsx(De,{className:"mt-2",children:s.description}),t.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:s.schemas.map(h=>{const ue=e.schemaLinks.some(ge=>{var Y;return((Y=X(ge,[h]))==null?void 0:Y.id)===h.id});return t.jsx("button",{type:"button",className:`rounded-full border px-3 py-2 text-sm transition ${ue?`${V.badgeTone} ring-1 ring-[color-mix(in_srgb,var(--primary)_28%,transparent)]`:"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"}`,onClick:()=>r({schemaLinks:it(e.schemaLinks,h)}),children:h.title},h.id)})})]},s.schemaType)})})}),t.jsx(Le,{items:e.modeTimeline,onChange:s=>r({modeTimeline:s}),modes:T,stages:["Spark","Wave","Script","Lens","State","Move","Horizon","Pivot"]}),t.jsx(m,{title:"Next moves",description:"Finish with concrete next moves that protect the value or repair the situation.",addLabel:"Add next move",items:e.nextMoves,onChange:s=>r({nextMoves:s}),placeholder:"Send one honest repair message tomorrow morning."})]})]})}];if(v.isLoading||f.isLoading||y.isLoading||x.isLoading||k.isLoading||b.isLoading||w.isLoading||I.isLoading)return t.jsx(Ce,{eyebrow:"Reports",title:"Loading reports",description:"Getting reports, values, behaviors, beliefs, modes, event labels, and emotions ready."});const Q=v.error??f.error??y.error??x.error??k.error??b.error??w.error??I.error;return Q?t.jsx(Ee,{eyebrow:"Trigger reports",error:Q,onRetry:()=>void Promise.all([v.refetch(),f.refetch(),y.refetch(),x.refetch(),k.refetch(),b.refetch(),w.refetch(),I.refetch()])}):t.jsxs("div",{className:"grid gap-5",children:[t.jsx(Je,{entityKind:"report",title:t.jsx(Z,{kind:"report",label:"Reports",variant:"heading",size:"lg"}),description:"Capture the trigger, emotional wave, script, state, and next pivot in one guided reflective chain instead of a single massive worksheet.",badge:`${A.length} reports`,actions:t.jsx(Be,{onClick:()=>{u({...P,userId:j}),c(!0)},children:"Reflect"})}),t.jsx(Pe,{}),t.jsx(we,{eyebrow:"Reports",title:"Recent reports",description:"Open any report to review what happened, which beliefs and schemas were involved, and what you want to do next.",tone:"violet",children:t.jsx("div",{className:"grid gap-4",children:A.length===0?t.jsx(Me,{eyebrow:"Trigger reports",title:"No reports yet",description:"Start a first Spark-to-Pivot chain so Forge can track the full reflective arc instead of isolated notes."}):A.map(e=>{var r;return t.jsxs("div",{className:"min-w-0 max-w-full rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5 transition hover:bg-[var(--ui-surface-hover)]",children:[t.jsxs("div",{className:"grid min-w-0 gap-4 md:grid-cols-[minmax(0,1fr)_auto] md:items-start",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx(Z,{kind:"report",label:e.title,variant:"heading",size:"xl",lines:2,className:"w-full"}),t.jsx("div",{className:"mt-2 min-w-0 break-words text-sm text-[var(--ui-ink-faint)] [overflow-wrap:anywhere]",children:e.customEventType||e.eventSituation})]}),t.jsxs("div",{className:"flex min-w-0 max-w-full flex-wrap items-center gap-2 md:justify-end",children:[e.user?t.jsx(Xe,{user:e.user,compact:!0}):null,t.jsx(be,{entityType:"trigger_report",entityId:e.id,count:Ae(ie,"trigger_report",e.id).count}),t.jsx(Fe,{children:e.status}),t.jsx(fe,{to:`/psyche/reports/${e.id}`,className:"inline-flex min-h-10 max-w-full items-center rounded-full bg-[var(--ui-surface-2)] px-3 py-2 text-sm text-[var(--ui-ink-strong)] transition hover:bg-[var(--ui-surface-hover)]",children:"Open report"})]})]}),t.jsxs("div",{className:"mt-5 grid min-w-0 gap-3 xl:grid-cols-4",children:[t.jsxs("div",{className:"min-w-0 rounded-[20px] bg-[var(--ui-surface-1)] p-4",children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Spark"}),t.jsx("div",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:e.eventSituation})]}),t.jsxs("div",{className:"min-w-0 rounded-[20px] bg-[var(--ui-success-soft)] p-4",children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Wave"}),t.jsx("div",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:((r=e.emotions[0])==null?void 0:r.label)??"No emotion captured yet"})]}),t.jsxs("div",{className:"min-w-0 rounded-[20px] bg-[var(--ui-info-soft)] p-4",children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Lens"}),t.jsx("div",{className:"mt-3 min-w-0",children:e.schemaLinks[0]?(()=>{const s=X(e.schemaLinks[0],F);return s?t.jsx(Ie,{label:s.title,schemaType:s.schemaType,compact:!0}):t.jsx("div",{className:"break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:e.schemaLinks[0]})})():t.jsx("div",{className:"break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:"No schema link yet"})})]}),t.jsxs("div",{className:"min-w-0 rounded-[20px] bg-[var(--ui-warning-soft)] p-4",children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Pivot"}),t.jsx("div",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:e.nextMoves[0]??"No next move yet"})]})]})]},e.id)})})}),t.jsx(ke,{open:M,onOpenChange:c,eyebrow:"Trigger report",title:"Build a reflective chain",description:"This guided flow replaces the old open worksheet with a staged Spark-to-Pivot capture.",value:i,onChange:u,draftPersistenceKey:"psyche.report.new",steps:pe,submitLabel:"Create report",pending:D.isPending,error:ee,onSubmit:async()=>{if(g(null),!J.safeParse({title:i.title,status:i.status,eventTypeId:i.eventTypeId||null,customEventType:i.customEventType,eventSituation:i.eventSituation,occurredAt:i.occurredAt?new Date(i.occurredAt).toISOString():null,emotions:i.emotions.filter(r=>r.label.trim().length>0),thoughts:i.thoughts.filter(r=>r.text.trim().length>0),behaviors:i.behaviors.filter(r=>r.text.trim().length>0),consequences:{selfShortTerm:i.selfShortTerm,selfLongTerm:i.selfLongTerm,othersShortTerm:i.othersShortTerm,othersLongTerm:i.othersLongTerm},linkedPatternIds:[],linkedValueIds:i.linkedValueIds,linkedGoalIds:i.linkedGoalIds,linkedProjectIds:i.linkedProjectIds,linkedTaskIds:i.linkedTaskIds,linkedBehaviorIds:i.linkedBehaviorIds,linkedBeliefIds:i.linkedBeliefIds,linkedModeIds:i.linkedModeIds,modeOverlays:[],schemaLinks:i.schemaLinks.filter(Boolean),modeTimeline:i.modeTimeline.filter(r=>r.stage.trim().length>0&&r.label.trim().length>0),nextMoves:i.nextMoves.filter(Boolean)}).success){g("This report still needs a title and concrete triggering situation.");return}try{await D.mutateAsync(i)}catch(r){g(r instanceof Error?r.message:"Unable to create this report right now.")}}})]})}export{Ct as PsycheReportsPage};
1
+ import{bZ as ve,r as S,j as t,aC as fe}from"./vendor-Dgw7UY7q.js";import{j as ye,i as d,k as xe}from"./state-CkEUXgqt.js";import{Q as ke,F as o}from"./question-flow-dialog-B4B3BI8e.js";import{E as be}from"./entity-note-count-link-BDLj5ezr.js";import{A as we}from"./atlas-panel-DRMA3RbG.js";import{E as L}from"./entity-link-multiselect-HmmmJO5A.js";import{S as Ie}from"./schema-badge-Dsk9AoYd.js";import{E as Te,T as je,B as Se,S as m,M as Le}from"./report-chain-fields-D-XNut8V.js";import{d as Ne,L as Ce,e as Ee,B as Be,E as J,bD as Pe,h as Me,a2 as Ae,j as Fe,cG as qe,I as q,T as Re,af as Oe,ae as De,b_ as Qe,bY as Ke,ca as Ue,b$ as $e,bk as Ge,be as _e,bg as He,bh as ze,bi as We,c0 as Ve,cE as Ye,cF as Je}from"./index-C0CztQTU.js";import{P as Ze}from"./page-hero-ED69y6m0.js";import{U as Xe}from"./user-badge-BWoSrGA-.js";import{U as et}from"./user-select-field-DbB9v7Lf.js";import{p as N}from"./query-cache-IQ8W-LNC.js";import{t as Z}from"./psyche-schemas-B00gm5HO.js";import{f as X,b as tt,a as st,c as rt,t as it}from"./schema-visuals-CvC9a3i6.js";import{g as at,b as C,d as E,e as B,a as nt}from"./user-ownership-DJGl4rAj.js";import"./ui-CDt36qNz.js";import"./motion-eRlWWQT8.js";import"./use-anchored-overlay-position-C2kg0Ay0.js";import"./board-Dl7As76Q.js";import"./forms-DznAv9hZ.js";const P={title:"",status:"draft",eventTypeId:"",customEventType:"",eventSituation:"",occurredAt:"",emotions:[],thoughts:[],behaviors:[],selfShortTerm:[],selfLongTerm:[],othersShortTerm:[],othersLongTerm:[],linkedValueIds:[],linkedBehaviorIds:[],linkedBeliefIds:[],linkedModeIds:[],linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],schemaLinks:[],modeTimeline:[],nextMoves:[],userId:null};function ot(l){const n=new Date(l);if(Number.isNaN(n.getTime()))return"";const a=n.getFullYear(),p=String(n.getMonth()+1).padStart(2,"0"),M=String(n.getDate()).padStart(2,"0"),c=String(n.getHours()).padStart(2,"0"),i=String(n.getMinutes()).padStart(2,"0");return`${a}-${p}-${M}T${c}:${i}`}function Ct(){var K,U,$,G,_,H,z,W;const l=Ne(),n=ye(),[a,p]=ve(),[M,c]=S.useState(!1),[i,u]=S.useState(P),[ee,g]=S.useState(null),v=d({queryKey:["forge-psyche-reports"],queryFn:Ge}),f=d({queryKey:["forge-psyche-values"],queryFn:_e}),y=d({queryKey:["forge-psyche-behaviors"],queryFn:He}),x=d({queryKey:["forge-psyche-beliefs"],queryFn:ze}),k=d({queryKey:["forge-psyche-modes"],queryFn:We}),b=d({queryKey:["forge-psyche-schema-catalog"],queryFn:Ve}),w=d({queryKey:["forge-psyche-event-types"],queryFn:Ye}),I=d({queryKey:["forge-psyche-emotions"],queryFn:Je}),A=((K=v.data)==null?void 0:K.reports)??[],te=((U=f.data)==null?void 0:U.values)??[],R=(($=y.data)==null?void 0:$.behaviors)??[],O=((G=x.data)==null?void 0:G.beliefs)??[],T=((_=k.data)==null?void 0:_.modes)??[],F=((H=b.data)==null?void 0:H.schemas)??[],se=((z=w.data)==null?void 0:z.eventTypes)??[],re=((W=I.data)==null?void 0:W.emotions)??[],j=at(l.selectedUserIds),ie=l.snapshot.dashboard.notesSummaryByEntity;S.useEffect(()=>{if(a.get("create")==="1"){c(!0),u({...P,userId:a.get("userId")??j,occurredAt:a.get("occurredAt")?ot(a.get("occurredAt")):"",customEventType:a.get("intent")==="execution_tension"?"Execution tension":a.get("intent")==="belief"?"Belief script activation":a.get("intent")==="behavior"?"Behavior spike":a.get("intent")==="pattern"?"Recurring pattern":a.get("intent")==="value"?"Blocked value":"",linkedValueIds:a.get("valueId")?[a.get("valueId")]:[],linkedBehaviorIds:a.get("behaviorId")?[a.get("behaviorId")]:[],linkedBeliefIds:a.get("beliefId")?[a.get("beliefId")]:[],linkedGoalIds:a.get("goalId")?[a.get("goalId")]:[],linkedProjectIds:a.get("projectId")?[a.get("projectId")]:[],linkedTaskIds:a.get("taskId")?[a.get("taskId")]:[]});const e=new URLSearchParams(a);e.delete("create"),e.delete("intent"),e.delete("occurredAt"),e.delete("userId"),e.delete("valueId"),e.delete("behaviorId"),e.delete("beliefId"),e.delete("goalId"),e.delete("projectId"),e.delete("taskId"),p(e,{replace:!0})}},[a,p]);const D=xe({mutationFn:async e=>{const r=Z.parse({title:e.title,status:e.status,eventTypeId:e.eventTypeId||null,customEventType:e.customEventType,eventSituation:e.eventSituation,occurredAt:e.occurredAt?new Date(e.occurredAt).toISOString():null,emotions:e.emotions.filter(s=>s.label.trim().length>0),thoughts:e.thoughts.filter(s=>s.text.trim().length>0),behaviors:e.behaviors.filter(s=>s.text.trim().length>0),consequences:{selfShortTerm:e.selfShortTerm,selfLongTerm:e.selfLongTerm,othersShortTerm:e.othersShortTerm,othersLongTerm:e.othersLongTerm},linkedPatternIds:[],linkedValueIds:e.linkedValueIds,linkedGoalIds:e.linkedGoalIds,linkedProjectIds:e.linkedProjectIds,linkedTaskIds:e.linkedTaskIds,linkedBehaviorIds:e.linkedBehaviorIds,linkedBeliefIds:e.linkedBeliefIds,linkedModeIds:e.linkedModeIds,modeOverlays:[],schemaLinks:e.schemaLinks.filter(Boolean),modeTimeline:e.modeTimeline.filter(s=>s.stage.trim().length>0&&s.label.trim().length>0),nextMoves:e.nextMoves.filter(Boolean),userId:e.userId});return qe(r)},onSuccess:async()=>{c(!1),u({...P,userId:j}),g(null),await Promise.all([n.invalidateQueries({queryKey:["forge-psyche-reports"]}),n.invalidateQueries({queryKey:["forge-psyche-overview"]}),n.invalidateQueries({queryKey:["forge-xp-metrics"]})])}}),ae=te.map(e=>({value:e.id,label:B(e.title,e.user),description:E(e.valuedDirection,e.user),searchText:C([e.title,e.valuedDirection,e.description],e),kind:"value"})),ne=R.map(e=>({value:e.id,label:B(e.title,e.user),description:E(e.kind,e.user),searchText:C([e.title,e.kind,e.description],e),kind:"behavior"})),oe=O.map(e=>({value:e.id,label:B(e.statement,e.user),description:E(e.flexibleAlternative||e.originNote,e.user),searchText:C([e.statement,e.flexibleAlternative,e.originNote,e.beliefType],e),kind:"belief"})),de=T.map(e=>({value:e.id,label:B(e.title,e.user),description:E(e.archetype||e.family,e.user),searchText:C([e.title,e.archetype,e.family,e.persona],e),kind:"mode"})),le=async e=>{const{value:r}=await Qe({title:e,description:"",valuedDirection:e,whyItMatters:"",linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],committedActions:[],userId:i.userId});return N(n,["forge-psyche-values"],"values",r),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:r.id,label:r.title,description:r.valuedDirection,kind:"value"}},ce=async e=>{const{behavior:r}=await Ke({kind:"away",title:e,description:"",commonCues:[],urgeStory:"",shortTermPayoff:"",longTermCost:"",replacementMove:"",repairPlan:"",linkedPatternIds:[],linkedValueIds:[],linkedSchemaIds:[],linkedModeIds:[],userId:i.userId});return N(n,["forge-psyche-behaviors"],"behaviors",r),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:r.id,label:r.title,description:r.kind,kind:"behavior"}},he=async e=>{const{belief:r}=await Ue({schemaId:null,statement:e,beliefType:"absolute",originNote:"",confidence:60,evidenceFor:[],evidenceAgainst:[],flexibleAlternative:"",linkedValueIds:[],linkedBehaviorIds:[],linkedModeIds:[],linkedReportIds:[],userId:i.userId});return N(n,["forge-psyche-beliefs"],"beliefs",r),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:r.id,label:r.statement,description:r.flexibleAlternative||r.originNote,kind:"belief"}},me=async e=>{const{mode:r}=await $e({family:"coping",archetype:"",title:e,persona:"",imagery:"",symbolicForm:"",facialExpression:"",fear:"",burden:"",protectiveJob:"",originContext:"",firstAppearanceAt:null,linkedPatternIds:[],linkedBehaviorIds:[],linkedValueIds:[],userId:i.userId});return N(n,["forge-psyche-modes"],"modes",r),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:r.id,label:r.title,description:r.archetype||r.family,kind:"mode"}},pe=[{id:"spark",eyebrow:"Spark",title:"Capture the trigger and the situation",description:"Start with what happened concretely before interpretation takes over.",render:(e,r)=>t.jsxs(t.Fragment,{children:[t.jsx(et,{value:e.userId,users:l.snapshot.users,onChange:s=>r({userId:s}),defaultLabel:nt(l.snapshot.users.find(s=>s.id===j)??null,"Choose report owner"),help:"Trigger reports can belong to a human or bot user while still linking to shared values, behaviors, beliefs, and modes."}),t.jsx(o,{label:"Report title",children:t.jsx(q,{value:e.title,onChange:s=>r({title:s.target.value}),placeholder:"Friday silence spiral"})}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(o,{label:"Event type",children:t.jsxs("select",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3 text-sm text-[var(--ui-ink-strong)]",value:e.eventTypeId,onChange:s=>r({eventTypeId:s.target.value}),children:[t.jsx("option",{value:"",children:"Custom or uncategorized"}),se.map(s=>t.jsx("option",{value:s.id,children:s.label},s.id))]})}),t.jsx(o,{label:"Occurred at",children:t.jsx(q,{type:"datetime-local",value:e.occurredAt,onChange:s=>r({occurredAt:s.target.value})})})]}),t.jsx(o,{label:"Custom event label",children:t.jsx(q,{value:e.customEventType,onChange:s=>r({customEventType:s.target.value}),placeholder:"Unexpected distance after vulnerability"})}),t.jsx(o,{label:"Situation",children:t.jsx(Re,{value:e.eventSituation,onChange:s=>r({eventSituation:s.target.value}),placeholder:"Describe what happened concretely, without explaining it away yet."})})]})},{id:"wave-script-move",eyebrow:"Wave, script, move",title:"Capture the emotional wave, thought script, and behavior",description:"These stay structured, but the flow keeps them staged instead of dumping everything into one giant form.",render:(e,r)=>t.jsxs(t.Fragment,{children:[t.jsx(Te,{items:e.emotions,onChange:s=>r({emotions:s}),definitions:re}),t.jsx(je,{items:e.thoughts,onChange:s=>r({thoughts:s}),beliefs:O,modes:T}),t.jsx(Se,{items:e.behaviors,onChange:s=>r({behaviors:s}),behaviors:R,modes:T})]})},{id:"lens-state",eyebrow:"Lens and state",title:"Link the report to beliefs, modes, values, and behavior history",description:"This is where the report becomes part of the larger graphical psyche system.",render:(e,r)=>t.jsxs(t.Fragment,{children:[t.jsx(o,{label:"Linked values",children:t.jsx(L,{options:ae,selectedValues:e.linkedValueIds,onChange:s=>r({linkedValueIds:s}),placeholder:"Search or create a value…",emptyMessage:"No values match yet.",createLabel:"Create value",onCreate:le})}),t.jsx(o,{label:"Linked behaviors",children:t.jsx(L,{options:ne,selectedValues:e.linkedBehaviorIds,onChange:s=>r({linkedBehaviorIds:s}),placeholder:"Search or create a behavior…",emptyMessage:"No behaviors match yet.",createLabel:"Create behavior",onCreate:ce})}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(o,{label:"Linked beliefs",children:t.jsx(L,{options:oe,selectedValues:e.linkedBeliefIds,onChange:s=>r({linkedBeliefIds:s}),placeholder:"Search or create a belief…",emptyMessage:"No beliefs match yet.",createLabel:"Create belief",onCreate:he})}),t.jsx(o,{label:"Linked modes",children:t.jsx(L,{options:de,selectedValues:e.linkedModeIds,onChange:s=>r({linkedModeIds:s}),placeholder:"Search or create a mode…",emptyMessage:"No modes match yet.",createLabel:"Create mode",onCreate:me})})]}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.linkedGoalIds.length>0?t.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm text-[var(--ui-ink-soft)]",children:["Linked to ",e.linkedGoalIds.length," goal tension"]}):null,e.linkedProjectIds.length>0?t.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm text-[var(--ui-ink-soft)]",children:["Linked to ",e.linkedProjectIds.length," project tension"]}):null,e.linkedTaskIds.length>0?t.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm text-[var(--ui-ink-soft)]",children:["Linked to ",e.linkedTaskIds.length," task tension"]}):null]})]})},{id:"horizon-pivot",eyebrow:"Horizon and pivot",title:"Record consequences, schema pressure, and the next move",description:"Use this step to record what happened next, which schemas were involved, and what you want to do after this moment.",render:(e,r)=>t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(m,{title:"Short-term impact on you",description:"Add the immediate effects on your body, mood, or direction.",addLabel:"Add self effect",items:e.selfShortTerm,onChange:s=>r({selfShortTerm:s}),placeholder:"I shut down and lost the rest of the evening."}),t.jsx(m,{title:"Long-term impact on you",description:"Capture what this pattern costs when it keeps repeating.",addLabel:"Add self cost",items:e.selfLongTerm,onChange:s=>r({selfLongTerm:s}),placeholder:"It keeps reinforcing the same abandonment story."}),t.jsx(m,{title:"Short-term impact on others",description:"Note what happened to the people around you right away.",addLabel:"Add other effect",items:e.othersShortTerm,onChange:s=>r({othersShortTerm:s}),placeholder:"They felt pushed away and confused."}),t.jsx(m,{title:"Long-term impact on others",description:"Capture the longer pattern this creates in relationships.",addLabel:"Add other cost",items:e.othersLongTerm,onChange:s=>r({othersLongTerm:s}),placeholder:"Trust gets thinner every time this loop takes over."})]}),t.jsxs("div",{className:"grid gap-4",children:[t.jsx(o,{label:"Schema links",description:"Choose the schemas that were active or that you want to strengthen in this moment.",labelHelp:"Use maladaptive schemas for recurring old patterns that felt active here. Use adaptive schemas for healthier patterns you want to rely on more.",children:t.jsx("div",{className:"grid gap-4",children:[{title:"Maladaptive schemas",schemas:F.filter(s=>s.schemaType==="maladaptive"),schemaType:"maladaptive",description:"Recurring old patterns that felt active in this moment."},{title:"Adaptive schemas",schemas:F.filter(s=>s.schemaType==="adaptive"),schemaType:"adaptive",description:"Healthier stable themes you want this repair move to strengthen."}].map(s=>{const V=tt(s.schemaType);return t.jsxs("div",{className:`rounded-[24px] border p-4 ${V.cardTone}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:s.title}),t.jsx(Oe,{content:rt(s.schemaType),label:`Explain ${st(s.schemaType)}`})]}),t.jsx(De,{className:"mt-2",children:s.description}),t.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:s.schemas.map(h=>{const ue=e.schemaLinks.some(ge=>{var Y;return((Y=X(ge,[h]))==null?void 0:Y.id)===h.id});return t.jsx("button",{type:"button",className:`rounded-full border px-3 py-2 text-sm transition ${ue?`${V.badgeTone} ring-1 ring-[color-mix(in_srgb,var(--primary)_28%,transparent)]`:"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"}`,onClick:()=>r({schemaLinks:it(e.schemaLinks,h)}),children:h.title},h.id)})})]},s.schemaType)})})}),t.jsx(Le,{items:e.modeTimeline,onChange:s=>r({modeTimeline:s}),modes:T,stages:["Spark","Wave","Script","Lens","State","Move","Horizon","Pivot"]}),t.jsx(m,{title:"Next moves",description:"Finish with concrete next moves that protect the value or repair the situation.",addLabel:"Add next move",items:e.nextMoves,onChange:s=>r({nextMoves:s}),placeholder:"Send one honest repair message tomorrow morning."})]})]})}];if(v.isLoading||f.isLoading||y.isLoading||x.isLoading||k.isLoading||b.isLoading||w.isLoading||I.isLoading)return t.jsx(Ce,{eyebrow:"Reports",title:"Loading reports",description:"Getting reports, values, behaviors, beliefs, modes, event labels, and emotions ready."});const Q=v.error??f.error??y.error??x.error??k.error??b.error??w.error??I.error;return Q?t.jsx(Ee,{eyebrow:"Trigger reports",error:Q,onRetry:()=>void Promise.all([v.refetch(),f.refetch(),y.refetch(),x.refetch(),k.refetch(),b.refetch(),w.refetch(),I.refetch()])}):t.jsxs("div",{className:"grid gap-5",children:[t.jsx(Ze,{entityKind:"report",title:t.jsx(J,{kind:"report",label:"Reports",variant:"heading",size:"lg"}),description:"Capture the trigger, emotional wave, script, state, and next pivot in one guided reflective chain instead of a single massive worksheet.",badge:`${A.length} reports`,actions:t.jsx(Be,{onClick:()=>{u({...P,userId:j}),c(!0)},children:"Reflect"})}),t.jsx(Pe,{}),t.jsx(we,{eyebrow:"Reports",title:"Recent reports",description:"Open any report to review what happened, which beliefs and schemas were involved, and what you want to do next.",tone:"violet",children:t.jsx("div",{className:"grid gap-4",children:A.length===0?t.jsx(Me,{eyebrow:"Trigger reports",title:"No reports yet",description:"Start a first Spark-to-Pivot chain so Forge can track the full reflective arc instead of isolated notes."}):A.map(e=>{var r;return t.jsxs("div",{className:"min-w-0 max-w-full rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5 transition hover:bg-[var(--ui-surface-hover)]",children:[t.jsxs("div",{className:"grid min-w-0 gap-4 md:grid-cols-[minmax(0,1fr)_auto] md:items-start",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx(J,{kind:"report",label:e.title,variant:"heading",size:"xl",lines:2,className:"w-full"}),t.jsx("div",{className:"mt-2 min-w-0 break-words text-sm text-[var(--ui-ink-faint)] [overflow-wrap:anywhere]",children:e.customEventType||e.eventSituation})]}),t.jsxs("div",{className:"flex min-w-0 max-w-full flex-wrap items-center gap-2 md:justify-end",children:[e.user?t.jsx(Xe,{user:e.user,compact:!0}):null,t.jsx(be,{entityType:"trigger_report",entityId:e.id,count:Ae(ie,"trigger_report",e.id).count}),t.jsx(Fe,{children:e.status}),t.jsx(fe,{to:`/psyche/reports/${e.id}`,className:"inline-flex min-h-10 max-w-full items-center rounded-full bg-[var(--ui-surface-2)] px-3 py-2 text-sm text-[var(--ui-ink-strong)] transition hover:bg-[var(--ui-surface-hover)]",children:"Open report"})]})]}),t.jsxs("div",{className:"mt-5 grid min-w-0 gap-3 xl:grid-cols-4",children:[t.jsxs("div",{className:"min-w-0 rounded-[20px] bg-[var(--ui-surface-1)] p-4",children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Spark"}),t.jsx("div",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:e.eventSituation})]}),t.jsxs("div",{className:"min-w-0 rounded-[20px] bg-[var(--ui-success-soft)] p-4",children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Wave"}),t.jsx("div",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:((r=e.emotions[0])==null?void 0:r.label)??"No emotion captured yet"})]}),t.jsxs("div",{className:"min-w-0 rounded-[20px] bg-[var(--ui-info-soft)] p-4",children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Lens"}),t.jsx("div",{className:"mt-3 min-w-0",children:e.schemaLinks[0]?(()=>{const s=X(e.schemaLinks[0],F);return s?t.jsx(Ie,{label:s.title,schemaType:s.schemaType,compact:!0}):t.jsx("div",{className:"break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:e.schemaLinks[0]})})():t.jsx("div",{className:"break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:"No schema link yet"})})]}),t.jsxs("div",{className:"min-w-0 rounded-[20px] bg-[var(--ui-warning-soft)] p-4",children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Pivot"}),t.jsx("div",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:e.nextMoves[0]??"No next move yet"})]})]})]},e.id)})})}),t.jsx(ke,{open:M,onOpenChange:c,eyebrow:"Trigger report",title:"Build a reflective chain",description:"This guided flow replaces the old open worksheet with a staged Spark-to-Pivot capture.",value:i,onChange:u,draftPersistenceKey:"psyche.report.new",steps:pe,submitLabel:"Create report",pending:D.isPending,error:ee,onSubmit:async()=>{if(g(null),!Z.safeParse({title:i.title,status:i.status,eventTypeId:i.eventTypeId||null,customEventType:i.customEventType,eventSituation:i.eventSituation,occurredAt:i.occurredAt?new Date(i.occurredAt).toISOString():null,emotions:i.emotions.filter(r=>r.label.trim().length>0),thoughts:i.thoughts.filter(r=>r.text.trim().length>0),behaviors:i.behaviors.filter(r=>r.text.trim().length>0),consequences:{selfShortTerm:i.selfShortTerm,selfLongTerm:i.selfLongTerm,othersShortTerm:i.othersShortTerm,othersLongTerm:i.othersLongTerm},linkedPatternIds:[],linkedValueIds:i.linkedValueIds,linkedGoalIds:i.linkedGoalIds,linkedProjectIds:i.linkedProjectIds,linkedTaskIds:i.linkedTaskIds,linkedBehaviorIds:i.linkedBehaviorIds,linkedBeliefIds:i.linkedBeliefIds,linkedModeIds:i.linkedModeIds,modeOverlays:[],schemaLinks:i.schemaLinks.filter(Boolean),modeTimeline:i.modeTimeline.filter(r=>r.stage.trim().length>0&&r.label.trim().length>0),nextMoves:i.nextMoves.filter(Boolean)}).success){g("This report still needs a title and concrete triggering situation.");return}try{await D.mutateAsync(i)}catch(r){g(r instanceof Error?r.message:"Unable to create this report right now.")}}})]})}export{Ct as PsycheReportsPage};
@@ -1 +1 @@
1
- import{o as d,a as t,s as a,e as n,n as s}from"./forms-ByKjodjN.js";const e=a().trim(),l=e.min(1),r=t(l).transform(o=>Array.from(new Set(o))),i=a().trim().min(1).nullable().optional(),h=d({title:l,description:e,valuedDirection:l,whyItMatters:e,linkedGoalIds:t(a()).default([]),linkedProjectIds:t(a()).default([]),linkedTaskIds:t(a()).default([]),committedActions:t(e).default([]),userId:i}),p=d({title:l,description:e,targetBehavior:l,cueContexts:t(e).default([]),shortTermPayoff:e,longTermCost:e,preferredResponse:l,linkedValueIds:t(a()).default([]),linkedSchemaLabels:r.default([]),linkedModeIds:t(a()).default([]),linkedBeliefIds:t(a()).default([]),userId:i}),g=d({kind:n(["away","committed","recovery"]),title:l,description:e,commonCues:t(e).default([]),urgeStory:e,shortTermPayoff:e,longTermCost:e,replacementMove:e,repairPlan:e,linkedPatternIds:t(a()).default([]),linkedValueIds:t(a()).default([]),linkedSchemaIds:t(a()).default([]),linkedModeIds:t(a()).default([]),userId:i}),k=d({schemaId:a().nullable(),statement:l,beliefType:n(["absolute","conditional"]),originNote:e,confidence:s().int().min(0).max(100),evidenceFor:t(e).default([]),evidenceAgainst:t(e).default([]),flexibleAlternative:e,linkedValueIds:t(a()).default([]),linkedBehaviorIds:t(a()).default([]),linkedModeIds:t(a()).default([]),linkedReportIds:t(a()).default([]),userId:i}),y=d({family:n(["coping","child","critic_parent","healthy_adult","happy_child"]),archetype:e,title:l,persona:e,imagery:e,symbolicForm:e,facialExpression:e,fear:e,burden:e,protectiveJob:e,originContext:e,firstAppearanceAt:a().trim().nullable(),linkedPatternIds:t(a()).default([]),linkedBehaviorIds:t(a()).default([]),linkedValueIds:t(a()).default([]),userId:i}),b=d({summary:l,answers:t(d({questionKey:l,value:l})).min(1),userId:i}),v=d({title:e.default(""),message:l,triggerSentence:e.default(""),triggerSituation:e.default(""),tags:t(e).default([]),backgroundColor:e.default("#f8fafc"),textColor:e.default("#111827"),accentColor:e.default("#6ee7b7"),typography:n(["serif","sans","mono","display"]).default("serif"),imageUrl:e.default(""),imageAlt:e.default(""),layout:n(["centered","top_left","image_split","poster"]).default("centered"),visualStyle:n(["calm","urgent","warm","clinical","playful"]).default("calm"),linkedValueIds:t(a()).default([]),linkedBehaviorIds:t(a()).default([]),linkedPatternIds:t(a()).default([]),linkedBeliefIds:t(a()).default([]),linkedModeIds:t(a()).default([]),linkedReportIds:t(a()).default([]),userId:i});d({label:l,description:e,userId:i});d({label:l,description:e,category:e,userId:i});const u=d({id:l,emotionDefinitionId:a().nullable(),label:l,intensity:s().int().min(0).max(100),note:e}),f=d({id:l,text:l,parentMode:e,criticMode:e,beliefId:a().nullable()}),c=d({id:l,text:l,mode:e,behaviorId:a().nullable()}),m=d({id:l,stage:l,modeId:a().nullable(),label:l,note:e}),S=d({title:l,status:n(["draft","reviewed","integrated"]).default("draft"),eventTypeId:a().nullable(),customEventType:e,eventSituation:l,occurredAt:a().trim().nullable(),emotions:t(u).default([]),thoughts:t(f).default([]),behaviors:t(c).default([]),consequences:d({selfShortTerm:t(e).default([]),selfLongTerm:t(e).default([]),othersShortTerm:t(e).default([]),othersLongTerm:t(e).default([])}),linkedPatternIds:t(a()).default([]),linkedValueIds:t(a()).default([]),linkedGoalIds:t(a()).default([]),linkedProjectIds:t(a()).default([]),linkedTaskIds:t(a()).default([]),linkedBehaviorIds:t(a()).default([]),linkedBeliefIds:t(a()).default([]),linkedModeIds:t(a()).default([]),modeOverlays:t(e).default([]),schemaLinks:t(e).default([]),modeTimeline:t(m).default([]),nextMoves:t(e).default([]),userId:i});export{y as a,g as b,p as c,k as d,v as f,b as m,h as p,S as t};
1
+ import{o as d,a as t,s as a,e as n,n as s}from"./forms-DznAv9hZ.js";const e=a().trim(),l=e.min(1),r=t(l).transform(o=>Array.from(new Set(o))),i=a().trim().min(1).nullable().optional(),h=d({title:l,description:e,valuedDirection:l,whyItMatters:e,linkedGoalIds:t(a()).default([]),linkedProjectIds:t(a()).default([]),linkedTaskIds:t(a()).default([]),committedActions:t(e).default([]),userId:i}),p=d({title:l,description:e,targetBehavior:l,cueContexts:t(e).default([]),shortTermPayoff:e,longTermCost:e,preferredResponse:l,linkedValueIds:t(a()).default([]),linkedSchemaLabels:r.default([]),linkedModeIds:t(a()).default([]),linkedBeliefIds:t(a()).default([]),userId:i}),g=d({kind:n(["away","committed","recovery"]),title:l,description:e,commonCues:t(e).default([]),urgeStory:e,shortTermPayoff:e,longTermCost:e,replacementMove:e,repairPlan:e,linkedPatternIds:t(a()).default([]),linkedValueIds:t(a()).default([]),linkedSchemaIds:t(a()).default([]),linkedModeIds:t(a()).default([]),userId:i}),k=d({schemaId:a().nullable(),statement:l,beliefType:n(["absolute","conditional"]),originNote:e,confidence:s().int().min(0).max(100),evidenceFor:t(e).default([]),evidenceAgainst:t(e).default([]),flexibleAlternative:e,linkedValueIds:t(a()).default([]),linkedBehaviorIds:t(a()).default([]),linkedModeIds:t(a()).default([]),linkedReportIds:t(a()).default([]),userId:i}),y=d({family:n(["coping","child","critic_parent","healthy_adult","happy_child"]),archetype:e,title:l,persona:e,imagery:e,symbolicForm:e,facialExpression:e,fear:e,burden:e,protectiveJob:e,originContext:e,firstAppearanceAt:a().trim().nullable(),linkedPatternIds:t(a()).default([]),linkedBehaviorIds:t(a()).default([]),linkedValueIds:t(a()).default([]),userId:i}),b=d({summary:l,answers:t(d({questionKey:l,value:l})).min(1),userId:i}),v=d({title:e.default(""),message:l,triggerSentence:e.default(""),triggerSituation:e.default(""),tags:t(e).default([]),backgroundColor:e.default("#f8fafc"),textColor:e.default("#111827"),accentColor:e.default("#6ee7b7"),typography:n(["serif","sans","mono","display"]).default("serif"),imageUrl:e.default(""),imageAlt:e.default(""),layout:n(["centered","top_left","image_split","poster"]).default("centered"),visualStyle:n(["calm","urgent","warm","clinical","playful"]).default("calm"),linkedValueIds:t(a()).default([]),linkedBehaviorIds:t(a()).default([]),linkedPatternIds:t(a()).default([]),linkedBeliefIds:t(a()).default([]),linkedModeIds:t(a()).default([]),linkedReportIds:t(a()).default([]),userId:i});d({label:l,description:e,userId:i});d({label:l,description:e,category:e,userId:i});const u=d({id:l,emotionDefinitionId:a().nullable(),label:l,intensity:s().int().min(0).max(100),note:e}),f=d({id:l,text:l,parentMode:e,criticMode:e,beliefId:a().nullable()}),c=d({id:l,text:l,mode:e,behaviorId:a().nullable()}),m=d({id:l,stage:l,modeId:a().nullable(),label:l,note:e}),S=d({title:l,status:n(["draft","reviewed","integrated"]).default("draft"),eventTypeId:a().nullable(),customEventType:e,eventSituation:l,occurredAt:a().trim().nullable(),emotions:t(u).default([]),thoughts:t(f).default([]),behaviors:t(c).default([]),consequences:d({selfShortTerm:t(e).default([]),selfLongTerm:t(e).default([]),othersShortTerm:t(e).default([]),othersLongTerm:t(e).default([])}),linkedPatternIds:t(a()).default([]),linkedValueIds:t(a()).default([]),linkedGoalIds:t(a()).default([]),linkedProjectIds:t(a()).default([]),linkedTaskIds:t(a()).default([]),linkedBehaviorIds:t(a()).default([]),linkedBeliefIds:t(a()).default([]),linkedModeIds:t(a()).default([]),modeOverlays:t(e).default([]),schemaLinks:t(e).default([]),modeTimeline:t(m).default([]),nextMoves:t(e).default([]),userId:i});export{y as a,g as b,p as c,k as d,v as f,b as m,h as p,S as t};
@@ -1,4 +1,4 @@
1
- import{bZ as be,r as x,j as t}from"./vendor-B7FKSwHK.js";import{j as je,i as k,k as we}from"./state-BFyKSULP.js";import{S as re}from"./schema-badge-jX28kUa6.js";import{Q as ke,F as d}from"./question-flow-dialog-yMYVk998.js";import{E as Ie}from"./entity-note-count-link-BGOiaash.js";import{A as se}from"./atlas-panel-VZOnJa1c.js";import{E as F}from"./entity-link-multiselect-BfDAROHB.js";import{d as Te,L as Se,e as Ne,B as $,bB as Ce,a0 as Le,j as I,b as Be,ad as ne,cL as Ee,c8 as Fe,ac as Ae,I as Me,T as A,bY as Pe,bW as qe,bZ as Oe,cE as Qe,b_ as Ue,bf as $e,be as Re,bg as He,bc as Ke,bi as De}from"./index-gmPaoLN-.js";import{u as Ve,p as _e}from"./use-psyche-focus-target-1GLkhYiv.js";import{P as Ge}from"./page-hero-U603l9rQ.js";import{U as We}from"./user-badge-C4eZu1e_.js";import{U as ze}from"./user-select-field-CmKwcbZt.js";import{p as M}from"./query-cache-IQ8W-LNC.js";import{d as ie}from"./psyche-schemas-Cg51Ztxz.js";import{c as R,b as K,g as Ye,a as Ze,f as Je}from"./schema-visuals-CvC9a3i6.js";import{g as Xe,b as P,d as q,e as O,a as et}from"./user-ownership-DJGl4rAj.js";import"./ui-uo_bNP7c.js";import"./motion-BibSzp57.js";import"./use-anchored-overlay-position-BSxFX6Hi.js";import"./board-DprRipIG.js";import"./forms-ByKjodjN.js";const S={schemaId:null,statement:"",beliefType:"absolute",originNote:"",confidence:60,evidenceFor:[],evidenceAgainst:[],flexibleAlternative:"",linkedValueIds:[],linkedBehaviorIds:[],linkedModeIds:[],linkedReportIds:[],userId:null};function H(a){return{schemaId:a.schemaId,statement:a.statement,beliefType:a.beliefType,originNote:a.originNote,confidence:a.confidence,evidenceFor:a.evidenceFor,evidenceAgainst:a.evidenceAgainst,flexibleAlternative:a.flexibleAlternative,linkedValueIds:a.linkedValueIds,linkedBehaviorIds:a.linkedBehaviorIds,linkedModeIds:a.linkedModeIds,linkedReportIds:a.linkedReportIds,userId:a.userId??null}}function tt({schema:a,beliefs:o,behaviors:f,reports:v}){const g=o.filter(n=>n.schemaId===a.id).length,l=f.filter(n=>n.linkedSchemaIds.includes(a.id)).length,c=v.filter(n=>n.schemaLinks.some(h=>{const r=Je(h,[a]);return(r==null?void 0:r.id)===a.id})).length;return{beliefCount:g,behaviorCount:l,reportCount:c,total:g+l+c}}function ae({title:a,description:o,titleHelp:f,schemas:v,beliefs:g,behaviors:l,reports:c,onOpenBelief:n}){if(v.length===0)return null;const h=K(v[0].schemaType);return t.jsxs("section",{className:`min-w-0 grid gap-4 rounded-[30px] border p-4 md:p-5 ${h.sectionTone}`,children:[t.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-3 sm:flex-row sm:flex-wrap sm:items-start sm:justify-between",children:[t.jsxs("div",{className:"grid min-w-0 gap-2",children:[t.jsxs("div",{className:`flex items-center gap-2 text-[11px] uppercase tracking-[0.18em] ${h.sectionEyebrow}`,children:[t.jsx("span",{children:a}),f?t.jsx(ne,{content:f,label:`Explain ${a.toLowerCase()}`}):null]}),t.jsx("div",{className:"max-w-3xl text-sm leading-6 text-[var(--ui-ink-soft)]",children:o})]}),t.jsxs(I,{children:[v.length," schemas"]})]}),t.jsx("div",{className:"grid gap-4 xl:grid-cols-2",children:v.map(r=>{const j=tt({schema:r,beliefs:g,behaviors:l,reports:c}),p=g.filter(u=>u.schemaId===r.id),y=K(r.schemaType);return t.jsxs("div",{className:`min-w-0 rounded-[26px] border p-5 ${y.cardTone}`,children:[t.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-3 sm:flex-row sm:justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx(re,{label:r.title,schemaType:r.schemaType}),t.jsx("div",{className:"mt-3 text-sm text-[var(--ui-ink-faint)]",children:Ye(r.family)}),t.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:r.description})]}),t.jsxs(I,{children:[j.total," ",y.countLabel]})]}),t.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[t.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[j.beliefCount," beliefs"]}),t.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[j.behaviorCount," behaviors"]}),t.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[j.reportCount," reports"]})]}),t.jsxs("div",{className:"mt-4 grid gap-3",children:[p.length>0?t.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] p-4 text-sm text-[var(--ui-ink-soft)]",children:`${p.length} ${y.linkSummary}${p.length===1?"":"s"} live here.`}):t.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] p-4 text-sm leading-6 text-[var(--ui-ink-faint)]",children:y.emptyCopy}),p.slice(0,2).map(u=>t.jsxs("button",{type:"button",className:"rounded-[20px] bg-[var(--ui-surface-1)] p-4 text-left transition hover:bg-[var(--ui-surface-2)]",onClick:()=>n(u),children:[t.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:u.statement}),t.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:u.flexibleAlternative||"No flexible alternative recorded yet."})]},u.id))]})]},r.id)})})]})}function kt(){var Y,Z,J,X,ee,te;const a=Te(),o=je(),[f,v]=be(),[g,l]=x.useState(!1),[c,n]=x.useState(null),[h,r]=x.useState(S),[j,p]=x.useState(null),y=k({queryKey:["forge-psyche-schema-catalog"],queryFn:Ue}),u=k({queryKey:["forge-psyche-beliefs"],queryFn:$e}),N=k({queryKey:["forge-psyche-behaviors"],queryFn:Re}),C=k({queryKey:["forge-psyche-modes"],queryFn:He}),L=k({queryKey:["forge-psyche-values"],queryFn:Ke}),B=k({queryKey:["forge-psyche-reports"],queryFn:De}),b=((Y=y.data)==null?void 0:Y.schemas)??[],T=((Z=u.data)==null?void 0:Z.beliefs)??[],Q=((J=N.data)==null?void 0:J.behaviors)??[],D=((X=C.data)==null?void 0:X.modes)??[],oe=((ee=L.data)==null?void 0:ee.values)??[],U=((te=B.data)==null?void 0:te.reports)??[],w=Xe(a.selectedUserIds),V=f.get("focus"),le=a.snapshot.dashboard.notesSummaryByEntity;Ve(V),x.useEffect(()=>{if(f.get("create")==="1"){l(!0),n(null),r({...S,userId:w});const e=new URLSearchParams(f);e.delete("create"),v(e,{replace:!0})}},[w,f,v]);const _=we({mutationFn:async e=>{const s=ie.parse(e);return c?Ee(c.id,s):Fe(s)},onSuccess:async()=>{l(!1),n(null),r({...S,userId:w}),p(null),await Promise.all([o.invalidateQueries({queryKey:["forge-psyche-beliefs"]}),o.invalidateQueries({queryKey:["forge-psyche-overview"]})])}}),de=oe.map(e=>({value:e.id,label:O(e.title,e.user),description:q(e.valuedDirection,e.user),searchText:P([e.title,e.valuedDirection,e.description],e),kind:"value"})),ce=Q.map(e=>({value:e.id,label:O(e.title,e.user),description:q(e.kind,e.user),searchText:P([e.title,e.kind,e.description],e),kind:"behavior"})),he=D.map(e=>({value:e.id,label:O(e.title,e.user),description:q(e.archetype||e.family,e.user),searchText:P([e.title,e.archetype,e.family,e.persona],e),kind:"mode"})),ue=U.map(e=>({value:e.id,label:O(e.title,e.user),description:q(e.customEventType||e.eventSituation,e.user),searchText:P([e.title,e.customEventType,e.eventSituation],e),kind:"report"})),me=x.useMemo(()=>new Map(b.map(e=>[e.id,e])),[b]),G=x.useMemo(()=>b.filter(e=>e.schemaType==="maladaptive"),[b]),W=x.useMemo(()=>b.filter(e=>e.schemaType==="adaptive"),[b]),pe=async e=>{const{value:s}=await Pe({title:e,description:"",valuedDirection:e,whyItMatters:"",linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],committedActions:[],userId:h.userId});return M(o,["forge-psyche-values"],"values",s),await o.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:s.id,label:s.title,description:s.valuedDirection,kind:"value"}},fe=async e=>{const{behavior:s}=await qe({kind:"away",title:e,description:"",commonCues:[],urgeStory:"",shortTermPayoff:"",longTermCost:"",replacementMove:"",repairPlan:"",linkedPatternIds:[],linkedValueIds:[],linkedSchemaIds:[],linkedModeIds:[],userId:h.userId});return M(o,["forge-psyche-behaviors"],"behaviors",s),await o.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:s.id,label:s.title,description:s.kind,kind:"behavior"}},ve=async e=>{const{mode:s}=await Oe({family:"coping",archetype:"",title:e,persona:"",imagery:"",symbolicForm:"",facialExpression:"",fear:"",burden:"",protectiveJob:"",originContext:"",firstAppearanceAt:null,linkedPatternIds:[],linkedBehaviorIds:[],linkedValueIds:[],userId:h.userId});return M(o,["forge-psyche-modes"],"modes",s),await o.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:s.id,label:s.title,description:s.archetype||s.family,kind:"mode"}},ge=async e=>{const{report:s}=await Qe({title:e,status:"draft",eventTypeId:null,customEventType:"",eventSituation:e,occurredAt:null,emotions:[],thoughts:[],behaviors:[],consequences:{selfShortTerm:[],selfLongTerm:[],othersShortTerm:[],othersLongTerm:[]},linkedPatternIds:[],linkedValueIds:[],linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],linkedBehaviorIds:[],linkedBeliefIds:[],linkedModeIds:[],modeOverlays:[],schemaLinks:[],modeTimeline:[],nextMoves:[],userId:h.userId});return M(o,["forge-psyche-reports"],"reports",s),await o.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:s.id,label:s.title,description:s.customEventType||s.eventSituation,kind:"report"}};x.useEffect(()=>{g&&p(null)},[g]);const ye=[{id:"lens",eyebrow:"Lens",title:"Choose the schema and belief script",description:"Place the belief inside the right schema system, then write the actual inner line that tends to fire there.",render:(e,s)=>t.jsxs(t.Fragment,{children:[t.jsx(ze,{value:e.userId??null,users:a.snapshot.users,onChange:i=>s({userId:i}),defaultLabel:et(a.snapshot.users.find(i=>i.id===w)??null,"Choose belief owner"),help:"Beliefs can belong to a human or bot user even when they connect to shared behaviors, modes, and reports."}),t.jsx(d,{label:"Schema",description:"Choose the schema this belief belongs to, whether it is a recurring old pattern or a healthier pattern you want to strengthen.",labelHelp:"Schemas are the broader repeating themes. Beliefs are the personal scripts that fire inside those themes.",children:t.jsx("div",{className:"grid gap-4",children:[{title:"Maladaptive schemas",schemas:G,description:"Recurring old patterns that tend to get activated and distort how the situation feels.",schemaType:"maladaptive"},{title:"Adaptive schemas",schemas:W,description:"Healthier stable themes you want to strengthen, trust, and live from more often.",schemaType:"adaptive"}].map(i=>{const m=K(i.schemaType);return t.jsxs("div",{className:`rounded-[24px] border p-4 ${m.cardTone}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:i.title}),t.jsx(ne,{content:R(i.schemaType),label:`Explain ${Ze(i.schemaType)}`})]}),t.jsx(Ae,{className:"mt-2",children:i.description}),t.jsx("div",{className:"mt-4 grid gap-2 sm:flex sm:flex-wrap",children:i.schemas.map(E=>{const xe=e.schemaId===E.id;return t.jsx("button",{type:"button",className:`w-full rounded-[18px] border px-3 py-2 text-left text-sm leading-5 transition sm:w-auto sm:rounded-full ${xe?`${m.badgeTone} ring-1 ring-[var(--ui-ring)]`:"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"}`,onClick:()=>s({schemaId:E.id}),children:E.title},E.id)})})]},i.schemaType)})})}),t.jsx(d,{label:"Belief statement",description:"Write the sentence the mind tends to say in the moment.",labelHelp:"A belief script should sound like the actual inner line that shows up under pressure, not a formal summary.",children:t.jsx(Me,{value:e.statement,onChange:i=>s({statement:i.target.value}),placeholder:"If they go quiet, I am already being left."})}),t.jsx(d,{label:"Belief type",description:"Choose whether the script sounds absolute or conditional.",labelHelp:"Absolute beliefs sound fixed and global. Conditional beliefs sound more like if-then rules about safety, worth, or closeness.",children:t.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:["absolute","conditional"].map(i=>t.jsx("button",{type:"button",className:`rounded-[22px] border px-4 py-4 text-left transition ${e.beliefType===i?"border-[var(--ui-border-strong)] bg-[var(--ui-surface-2)] 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)]"}`,onClick:()=>s({beliefType:i}),children:i==="absolute"?"Absolute: this is simply true":"Conditional: if this happens, then..."},i))})})]})},{id:"origin",eyebrow:"Origin",title:"Capture the origin and confidence of the script",description:"This keeps the belief from turning into a generic note divorced from actual history.",render:(e,s)=>t.jsxs(t.Fragment,{children:[t.jsx(d,{label:"Origin context",description:"Capture where this script learned its force or usefulness.",children:t.jsx(A,{value:e.originNote,onChange:i=>s({originNote:i.target.value}),placeholder:"It got stronger in periods where silence usually meant anger, distance, or punishment."})}),t.jsxs(d,{label:"Grip right now",description:"How strongly does this belief feel true when it gets activated?",labelHelp:"Grip is the felt strength of the script in the moment, not whether it is objectively true.",children:[t.jsx("input",{type:"range",min:0,max:100,value:e.confidence,onChange:i=>s({confidence:Number(i.target.value)})}),t.jsxs("div",{className:"text-sm text-[var(--ui-ink-faint)]",children:[e.confidence,"% grip"]})]}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(d,{label:"Evidence for",description:"Add one supporting memory, sign, or interpretation per line.",children:t.jsx(A,{value:e.evidenceFor.join(`
1
+ import{bZ as be,r as x,j as t}from"./vendor-Dgw7UY7q.js";import{j as je,i as w,k as ke}from"./state-CkEUXgqt.js";import{S as re}from"./schema-badge-Dsk9AoYd.js";import{Q as we,F as d}from"./question-flow-dialog-B4B3BI8e.js";import{E as Ie}from"./entity-note-count-link-BDLj5ezr.js";import{A as se}from"./atlas-panel-DRMA3RbG.js";import{E as F}from"./entity-link-multiselect-HmmmJO5A.js";import{d as Te,L as Se,e as Ne,B as U,bD as Ce,a2 as Le,j as I,b as Be,af as ne,cN as Ee,ca as Fe,ae as Ae,I as Me,T as A,b_ as Pe,bY as qe,b$ as Oe,cG as Qe,c0 as $e,bh as Ue,bg as Re,bi as He,be as Ke,bk as De}from"./index-C0CztQTU.js";import{u as Ge,p as Ve}from"./use-psyche-focus-target-p2l8W-Af.js";import{P as _e}from"./page-hero-ED69y6m0.js";import{U as ze}from"./user-badge-BWoSrGA-.js";import{U as We}from"./user-select-field-DbB9v7Lf.js";import{p as M}from"./query-cache-IQ8W-LNC.js";import{d as ie}from"./psyche-schemas-B00gm5HO.js";import{c as R,b as K,g as Ye,a as Je,f as Ze}from"./schema-visuals-CvC9a3i6.js";import{g as Xe,b as P,d as q,e as O,a as et}from"./user-ownership-DJGl4rAj.js";import"./ui-CDt36qNz.js";import"./motion-eRlWWQT8.js";import"./use-anchored-overlay-position-C2kg0Ay0.js";import"./board-Dl7As76Q.js";import"./forms-DznAv9hZ.js";const S={schemaId:null,statement:"",beliefType:"absolute",originNote:"",confidence:60,evidenceFor:[],evidenceAgainst:[],flexibleAlternative:"",linkedValueIds:[],linkedBehaviorIds:[],linkedModeIds:[],linkedReportIds:[],userId:null};function H(a){return{schemaId:a.schemaId,statement:a.statement,beliefType:a.beliefType,originNote:a.originNote,confidence:a.confidence,evidenceFor:a.evidenceFor,evidenceAgainst:a.evidenceAgainst,flexibleAlternative:a.flexibleAlternative,linkedValueIds:a.linkedValueIds,linkedBehaviorIds:a.linkedBehaviorIds,linkedModeIds:a.linkedModeIds,linkedReportIds:a.linkedReportIds,userId:a.userId??null}}function tt({schema:a,beliefs:o,behaviors:f,reports:v}){const g=o.filter(n=>n.schemaId===a.id).length,l=f.filter(n=>n.linkedSchemaIds.includes(a.id)).length,c=v.filter(n=>n.schemaLinks.some(h=>{const r=Ze(h,[a]);return(r==null?void 0:r.id)===a.id})).length;return{beliefCount:g,behaviorCount:l,reportCount:c,total:g+l+c}}function ae({title:a,description:o,titleHelp:f,schemas:v,beliefs:g,behaviors:l,reports:c,onOpenBelief:n}){if(v.length===0)return null;const h=K(v[0].schemaType);return t.jsxs("section",{className:`min-w-0 grid gap-4 rounded-[30px] border p-4 md:p-5 ${h.sectionTone}`,children:[t.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-3 sm:flex-row sm:flex-wrap sm:items-start sm:justify-between",children:[t.jsxs("div",{className:"grid min-w-0 gap-2",children:[t.jsxs("div",{className:`flex items-center gap-2 text-[11px] uppercase tracking-[0.18em] ${h.sectionEyebrow}`,children:[t.jsx("span",{children:a}),f?t.jsx(ne,{content:f,label:`Explain ${a.toLowerCase()}`}):null]}),t.jsx("div",{className:"max-w-3xl text-sm leading-6 text-[var(--ui-ink-soft)]",children:o})]}),t.jsxs(I,{children:[v.length," schemas"]})]}),t.jsx("div",{className:"grid gap-4 xl:grid-cols-2",children:v.map(r=>{const j=tt({schema:r,beliefs:g,behaviors:l,reports:c}),p=g.filter(u=>u.schemaId===r.id),y=K(r.schemaType);return t.jsxs("div",{className:`min-w-0 rounded-[26px] border p-5 ${y.cardTone}`,children:[t.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-3 sm:flex-row sm:justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx(re,{label:r.title,schemaType:r.schemaType}),t.jsx("div",{className:"mt-3 text-sm text-[var(--ui-ink-faint)]",children:Ye(r.family)}),t.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:r.description})]}),t.jsxs(I,{children:[j.total," ",y.countLabel]})]}),t.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[t.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[j.beliefCount," beliefs"]}),t.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[j.behaviorCount," behaviors"]}),t.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[j.reportCount," reports"]})]}),t.jsxs("div",{className:"mt-4 grid gap-3",children:[p.length>0?t.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] p-4 text-sm text-[var(--ui-ink-soft)]",children:`${p.length} ${y.linkSummary}${p.length===1?"":"s"} live here.`}):t.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] p-4 text-sm leading-6 text-[var(--ui-ink-faint)]",children:y.emptyCopy}),p.slice(0,2).map(u=>t.jsxs("button",{type:"button",className:"rounded-[20px] bg-[var(--ui-surface-1)] p-4 text-left transition hover:bg-[var(--ui-surface-2)]",onClick:()=>n(u),children:[t.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:u.statement}),t.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:u.flexibleAlternative||"No flexible alternative recorded yet."})]},u.id))]})]},r.id)})})]})}function wt(){var Y,J,Z,X,ee,te;const a=Te(),o=je(),[f,v]=be(),[g,l]=x.useState(!1),[c,n]=x.useState(null),[h,r]=x.useState(S),[j,p]=x.useState(null),y=w({queryKey:["forge-psyche-schema-catalog"],queryFn:$e}),u=w({queryKey:["forge-psyche-beliefs"],queryFn:Ue}),N=w({queryKey:["forge-psyche-behaviors"],queryFn:Re}),C=w({queryKey:["forge-psyche-modes"],queryFn:He}),L=w({queryKey:["forge-psyche-values"],queryFn:Ke}),B=w({queryKey:["forge-psyche-reports"],queryFn:De}),b=((Y=y.data)==null?void 0:Y.schemas)??[],T=((J=u.data)==null?void 0:J.beliefs)??[],Q=((Z=N.data)==null?void 0:Z.behaviors)??[],D=((X=C.data)==null?void 0:X.modes)??[],oe=((ee=L.data)==null?void 0:ee.values)??[],$=((te=B.data)==null?void 0:te.reports)??[],k=Xe(a.selectedUserIds),G=f.get("focus"),le=a.snapshot.dashboard.notesSummaryByEntity;Ge(G),x.useEffect(()=>{if(f.get("create")==="1"){l(!0),n(null),r({...S,userId:k});const e=new URLSearchParams(f);e.delete("create"),v(e,{replace:!0})}},[k,f,v]);const V=ke({mutationFn:async e=>{const s=ie.parse(e);return c?Ee(c.id,s):Fe(s)},onSuccess:async()=>{l(!1),n(null),r({...S,userId:k}),p(null),await Promise.all([o.invalidateQueries({queryKey:["forge-psyche-beliefs"]}),o.invalidateQueries({queryKey:["forge-psyche-overview"]})])}}),de=oe.map(e=>({value:e.id,label:O(e.title,e.user),description:q(e.valuedDirection,e.user),searchText:P([e.title,e.valuedDirection,e.description],e),kind:"value"})),ce=Q.map(e=>({value:e.id,label:O(e.title,e.user),description:q(e.kind,e.user),searchText:P([e.title,e.kind,e.description],e),kind:"behavior"})),he=D.map(e=>({value:e.id,label:O(e.title,e.user),description:q(e.archetype||e.family,e.user),searchText:P([e.title,e.archetype,e.family,e.persona],e),kind:"mode"})),ue=$.map(e=>({value:e.id,label:O(e.title,e.user),description:q(e.customEventType||e.eventSituation,e.user),searchText:P([e.title,e.customEventType,e.eventSituation],e),kind:"report"})),me=x.useMemo(()=>new Map(b.map(e=>[e.id,e])),[b]),_=x.useMemo(()=>b.filter(e=>e.schemaType==="maladaptive"),[b]),z=x.useMemo(()=>b.filter(e=>e.schemaType==="adaptive"),[b]),pe=async e=>{const{value:s}=await Pe({title:e,description:"",valuedDirection:e,whyItMatters:"",linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],committedActions:[],userId:h.userId});return M(o,["forge-psyche-values"],"values",s),await o.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:s.id,label:s.title,description:s.valuedDirection,kind:"value"}},fe=async e=>{const{behavior:s}=await qe({kind:"away",title:e,description:"",commonCues:[],urgeStory:"",shortTermPayoff:"",longTermCost:"",replacementMove:"",repairPlan:"",linkedPatternIds:[],linkedValueIds:[],linkedSchemaIds:[],linkedModeIds:[],userId:h.userId});return M(o,["forge-psyche-behaviors"],"behaviors",s),await o.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:s.id,label:s.title,description:s.kind,kind:"behavior"}},ve=async e=>{const{mode:s}=await Oe({family:"coping",archetype:"",title:e,persona:"",imagery:"",symbolicForm:"",facialExpression:"",fear:"",burden:"",protectiveJob:"",originContext:"",firstAppearanceAt:null,linkedPatternIds:[],linkedBehaviorIds:[],linkedValueIds:[],userId:h.userId});return M(o,["forge-psyche-modes"],"modes",s),await o.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:s.id,label:s.title,description:s.archetype||s.family,kind:"mode"}},ge=async e=>{const{report:s}=await Qe({title:e,status:"draft",eventTypeId:null,customEventType:"",eventSituation:e,occurredAt:null,emotions:[],thoughts:[],behaviors:[],consequences:{selfShortTerm:[],selfLongTerm:[],othersShortTerm:[],othersLongTerm:[]},linkedPatternIds:[],linkedValueIds:[],linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],linkedBehaviorIds:[],linkedBeliefIds:[],linkedModeIds:[],modeOverlays:[],schemaLinks:[],modeTimeline:[],nextMoves:[],userId:h.userId});return M(o,["forge-psyche-reports"],"reports",s),await o.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:s.id,label:s.title,description:s.customEventType||s.eventSituation,kind:"report"}};x.useEffect(()=>{g&&p(null)},[g]);const ye=[{id:"lens",eyebrow:"Lens",title:"Choose the schema and belief script",description:"Place the belief inside the right schema system, then write the actual inner line that tends to fire there.",render:(e,s)=>t.jsxs(t.Fragment,{children:[t.jsx(We,{value:e.userId??null,users:a.snapshot.users,onChange:i=>s({userId:i}),defaultLabel:et(a.snapshot.users.find(i=>i.id===k)??null,"Choose belief owner"),help:"Beliefs can belong to a human or bot user even when they connect to shared behaviors, modes, and reports."}),t.jsx(d,{label:"Schema",description:"Choose the schema this belief belongs to, whether it is a recurring old pattern or a healthier pattern you want to strengthen.",labelHelp:"Schemas are the broader repeating themes. Beliefs are the personal scripts that fire inside those themes.",children:t.jsx("div",{className:"grid gap-4",children:[{title:"Maladaptive schemas",schemas:_,description:"Recurring old patterns that tend to get activated and distort how the situation feels.",schemaType:"maladaptive"},{title:"Adaptive schemas",schemas:z,description:"Healthier stable themes you want to strengthen, trust, and live from more often.",schemaType:"adaptive"}].map(i=>{const m=K(i.schemaType);return t.jsxs("div",{className:`rounded-[24px] border p-4 ${m.cardTone}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:i.title}),t.jsx(ne,{content:R(i.schemaType),label:`Explain ${Je(i.schemaType)}`})]}),t.jsx(Ae,{className:"mt-2",children:i.description}),t.jsx("div",{className:"mt-4 grid gap-2 sm:flex sm:flex-wrap",children:i.schemas.map(E=>{const xe=e.schemaId===E.id;return t.jsx("button",{type:"button",className:`w-full rounded-[18px] border px-3 py-2 text-left text-sm leading-5 transition sm:w-auto sm:rounded-full ${xe?`${m.badgeTone} ring-1 ring-[var(--ui-ring)]`:"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"}`,onClick:()=>s({schemaId:E.id}),children:E.title},E.id)})})]},i.schemaType)})})}),t.jsx(d,{label:"Belief statement",description:"Write the sentence the mind tends to say in the moment.",labelHelp:"A belief script should sound like the actual inner line that shows up under pressure, not a formal summary.",children:t.jsx(Me,{value:e.statement,onChange:i=>s({statement:i.target.value}),placeholder:"If they go quiet, I am already being left."})}),t.jsx(d,{label:"Belief type",description:"Choose whether the script sounds absolute or conditional.",labelHelp:"Absolute beliefs sound fixed and global. Conditional beliefs sound more like if-then rules about safety, worth, or closeness.",children:t.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:["absolute","conditional"].map(i=>t.jsx("button",{type:"button",className:`rounded-[22px] border px-4 py-4 text-left transition ${e.beliefType===i?"border-[var(--ui-border-strong)] bg-[var(--ui-surface-2)] 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)]"}`,onClick:()=>s({beliefType:i}),children:i==="absolute"?"Absolute: this is simply true":"Conditional: if this happens, then..."},i))})})]})},{id:"origin",eyebrow:"Origin",title:"Capture the origin and confidence of the script",description:"This keeps the belief from turning into a generic note divorced from actual history.",render:(e,s)=>t.jsxs(t.Fragment,{children:[t.jsx(d,{label:"Origin context",description:"Capture where this script learned its force or usefulness.",children:t.jsx(A,{value:e.originNote,onChange:i=>s({originNote:i.target.value}),placeholder:"It got stronger in periods where silence usually meant anger, distance, or punishment."})}),t.jsxs(d,{label:"Grip right now",description:"How strongly does this belief feel true when it gets activated?",labelHelp:"Grip is the felt strength of the script in the moment, not whether it is objectively true.",children:[t.jsx("input",{type:"range",min:0,max:100,value:e.confidence,onChange:i=>s({confidence:Number(i.target.value)})}),t.jsxs("div",{className:"text-sm text-[var(--ui-ink-faint)]",children:[e.confidence,"% grip"]})]}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(d,{label:"Evidence for",description:"Add one supporting memory, sign, or interpretation per line.",children:t.jsx(A,{value:e.evidenceFor.join(`
2
2
  `),onChange:i=>s({evidenceFor:i.target.value.split(`
3
3
  `).map(m=>m.trim()).filter(Boolean)}),placeholder:`One line per sign
4
4
  They stopped replying for days
@@ -6,4 +6,4 @@ I was ignored when I asked directly`})}),t.jsx(d,{label:"Evidence against",descr
6
6
  `),onChange:i=>s({evidenceAgainst:i.target.value.split(`
7
7
  `).map(m=>m.trim()).filter(Boolean)}),placeholder:`One line per counterpoint
8
8
  They later explained they were overwhelmed
9
- Other people stay close without constant contact`})})]})]})},{id:"repair",eyebrow:"Repair",title:"Define the flexible alternative and attach the wider system",description:"The flexible alternative is the repair move; the links keep it attached to behaviors, values, modes, and reports.",render:(e,s)=>t.jsxs(t.Fragment,{children:[t.jsx(d,{label:"Flexible alternative",description:"Write the steadier line you want available when the old script activates.",labelHelp:"A flexible alternative is not fake positivity. It is a truer, more workable belief that leaves room for uncertainty.",children:t.jsx(A,{value:e.flexibleAlternative,onChange:i=>s({flexibleAlternative:i.target.value}),placeholder:"Silence can mean many things. I can check the facts before deciding I am being left."})}),t.jsx(d,{label:"Linked values",description:"Choose the valued directions this belief interferes with most.",children:t.jsx(F,{options:de,selectedValues:e.linkedValueIds,onChange:i=>s({linkedValueIds:i}),placeholder:"Search or create a value…",emptyMessage:"No values match yet.",createLabel:"Create value",onCreate:pe})}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[t.jsx(d,{label:"Linked behaviors",description:"Choose the moves this belief tends to trigger or justify.",children:t.jsx(F,{options:ce,selectedValues:e.linkedBehaviorIds,onChange:i=>s({linkedBehaviorIds:i}),placeholder:"Search or create a behavior…",emptyMessage:"No behaviors match yet.",createLabel:"Create behavior",onCreate:fe})}),t.jsx(d,{label:"Linked modes",description:"Choose the inner states that most often carry this script.",children:t.jsx(F,{options:he,selectedValues:e.linkedModeIds,onChange:i=>s({linkedModeIds:i}),placeholder:"Search or create a mode…",emptyMessage:"No modes match yet.",createLabel:"Create mode",onCreate:ve})}),t.jsx(d,{label:"Linked reports",description:"Choose the reflective chains where this script has already shown up.",children:t.jsx(F,{options:ue,selectedValues:e.linkedReportIds,onChange:i=>s({linkedReportIds:i}),placeholder:"Search or create a report…",emptyMessage:"No reports match yet.",createLabel:"Create report",onCreate:ge})})]})]})}];if(y.isLoading||u.isLoading||N.isLoading||C.isLoading||L.isLoading||B.isLoading)return t.jsx(Se,{eyebrow:"Schemas & beliefs",title:"Loading schemas and beliefs",description:"Getting schemas, beliefs, behaviors, modes, values, and linked reports ready."});const z=y.error??u.error??N.error??C.error??L.error??B.error;return z?t.jsx(Ne,{eyebrow:"Schemas & beliefs",error:z,onRetry:()=>void Promise.all([y.refetch(),u.refetch(),N.refetch(),C.refetch(),L.refetch(),B.refetch()])}):t.jsxs("div",{className:"grid min-w-0 gap-5",children:[t.jsx(Ge,{title:"Schemas & Beliefs",description:"Review your schemas and beliefs together. See which beliefs are tied to each schema, then open any belief to edit it in context.",badge:`${T.length} beliefs`,actions:t.jsx($,{onClick:()=>{n(null),r({...S,userId:w}),l(!0)},children:"Add belief"})}),t.jsx(Ce,{}),t.jsxs("section",{className:"grid min-w-0 gap-5 xl:grid-cols-[minmax(0,1.2fr)_minmax(0,0.8fr)]",children:[t.jsx(se,{eyebrow:"Schemas",title:"Schemas",description:"Use these groups to notice recurring old patterns and to reinforce healthier patterns you want to rely on more often.",titleHelp:"Schemas are broad recurring patterns that shape how situations feel and how you respond. Use them to organize beliefs, behaviors, and reports around patterns that repeat.",tone:"violet",children:b.length===0?t.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Schema data is unavailable right now."}):t.jsxs("div",{className:"grid gap-5",children:[t.jsx(ae,{title:"Maladaptive schemas",titleHelp:R("maladaptive"),description:"These schemas describe recurring old patterns that can change how you read situations and react.",schemas:G,beliefs:T,behaviors:Q,reports:U,onOpenBelief:e=>{n(e),r(H(e)),l(!0)}}),t.jsx(ae,{title:"Adaptive schemas",titleHelp:R("adaptive"),description:"These schemas describe healthier patterns you want to trust, practice, and strengthen over time.",schemas:W,beliefs:T,behaviors:Q,reports:U,onOpenBelief:e=>{n(e),r(H(e)),l(!0)}})]})}),t.jsx(se,{eyebrow:"Beliefs",title:"Beliefs",description:"Use this list to review and edit the stories you tell yourself. Open any belief to update the wording, evidence, or a more flexible alternative.",titleHelp:"Beliefs are the specific scripts or rules that show up in your mind, such as what you expect from yourself, from other people, or from a situation.",tone:"sky",children:t.jsxs("div",{className:"grid gap-3",children:[t.jsx($,{onClick:()=>{n(null),r({...S,userId:w}),l(!0)},children:"Add belief"}),T.length===0?t.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Your beliefs will appear here after you add the first one."}):T.map(e=>{const s=e.schemaId?me.get(e.schemaId)??null:null,i=V===e.id;return t.jsxs("div",{"data-psyche-focus-id":e.id,className:`rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4 text-left transition hover:bg-[var(--ui-surface-2)] ${_e(i)}`,children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:e.statement}),t.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e.user?t.jsx(We,{user:e.user,compact:!0}):null,t.jsx(Ie,{entityType:"belief_entry",entityId:e.id,count:Le(le,"belief_entry",e.id).count}),t.jsxs(I,{children:[e.confidence,"% grip"]}),t.jsx($,{variant:"secondary",size:"sm",onClick:()=>{n(e),r(H(e)),l(!0)},children:"Edit"})]})]}),t.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:e.flexibleAlternative||"No flexible alternative recorded yet."}),t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[s?t.jsx(re,{label:s.title,schemaType:s.schemaType,compact:!0,showType:!0}):null,D.filter(m=>e.linkedModeIds.includes(m.id)).slice(0,2).map(m=>t.jsx(Be,{kind:"mode",label:m.title,compact:!0},m.id))]})]},e.id)})]})})]}),t.jsx(ke,{open:g,onOpenChange:l,eyebrow:"Belief",title:c?"Refine belief":"Create belief",description:"Use this guided flow to capture the belief, what seems to support it, and a more flexible alternative.",value:h,onChange:r,draftPersistenceKey:c?`psyche.belief.${c.id}`:"psyche.belief.new",steps:ye,submitLabel:c?"Save belief":"Create belief",pending:_.isPending,error:j,onSubmit:async()=>{p(null);const e=ie.safeParse(h);if(!e.success){p("This belief still needs a statement before it can be saved.");return}try{await _.mutateAsync(e.data)}catch(s){p(s instanceof Error?s.message:"Unable to save this belief right now.")}}})]})}export{kt as PsycheSchemasBeliefsPage};
9
+ Other people stay close without constant contact`})})]})]})},{id:"repair",eyebrow:"Repair",title:"Define the flexible alternative and attach the wider system",description:"The flexible alternative is the repair move; the links keep it attached to behaviors, values, modes, and reports.",render:(e,s)=>t.jsxs(t.Fragment,{children:[t.jsx(d,{label:"Flexible alternative",description:"Write the steadier line you want available when the old script activates.",labelHelp:"A flexible alternative is not fake positivity. It is a truer, more workable belief that leaves room for uncertainty.",children:t.jsx(A,{value:e.flexibleAlternative,onChange:i=>s({flexibleAlternative:i.target.value}),placeholder:"Silence can mean many things. I can check the facts before deciding I am being left."})}),t.jsx(d,{label:"Linked values",description:"Choose the valued directions this belief interferes with most.",children:t.jsx(F,{options:de,selectedValues:e.linkedValueIds,onChange:i=>s({linkedValueIds:i}),placeholder:"Search or create a value…",emptyMessage:"No values match yet.",createLabel:"Create value",onCreate:pe})}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[t.jsx(d,{label:"Linked behaviors",description:"Choose the moves this belief tends to trigger or justify.",children:t.jsx(F,{options:ce,selectedValues:e.linkedBehaviorIds,onChange:i=>s({linkedBehaviorIds:i}),placeholder:"Search or create a behavior…",emptyMessage:"No behaviors match yet.",createLabel:"Create behavior",onCreate:fe})}),t.jsx(d,{label:"Linked modes",description:"Choose the inner states that most often carry this script.",children:t.jsx(F,{options:he,selectedValues:e.linkedModeIds,onChange:i=>s({linkedModeIds:i}),placeholder:"Search or create a mode…",emptyMessage:"No modes match yet.",createLabel:"Create mode",onCreate:ve})}),t.jsx(d,{label:"Linked reports",description:"Choose the reflective chains where this script has already shown up.",children:t.jsx(F,{options:ue,selectedValues:e.linkedReportIds,onChange:i=>s({linkedReportIds:i}),placeholder:"Search or create a report…",emptyMessage:"No reports match yet.",createLabel:"Create report",onCreate:ge})})]})]})}];if(y.isLoading||u.isLoading||N.isLoading||C.isLoading||L.isLoading||B.isLoading)return t.jsx(Se,{eyebrow:"Schemas & beliefs",title:"Loading schemas and beliefs",description:"Getting schemas, beliefs, behaviors, modes, values, and linked reports ready."});const W=y.error??u.error??N.error??C.error??L.error??B.error;return W?t.jsx(Ne,{eyebrow:"Schemas & beliefs",error:W,onRetry:()=>void Promise.all([y.refetch(),u.refetch(),N.refetch(),C.refetch(),L.refetch(),B.refetch()])}):t.jsxs("div",{className:"grid min-w-0 gap-5",children:[t.jsx(_e,{title:"Schemas & Beliefs",description:"Review your schemas and beliefs together. See which beliefs are tied to each schema, then open any belief to edit it in context.",badge:`${T.length} beliefs`,actions:t.jsx(U,{onClick:()=>{n(null),r({...S,userId:k}),l(!0)},children:"Add belief"})}),t.jsx(Ce,{}),t.jsxs("section",{className:"grid min-w-0 gap-5 xl:grid-cols-[minmax(0,1.2fr)_minmax(0,0.8fr)]",children:[t.jsx(se,{eyebrow:"Schemas",title:"Schemas",description:"Use these groups to notice recurring old patterns and to reinforce healthier patterns you want to rely on more often.",titleHelp:"Schemas are broad recurring patterns that shape how situations feel and how you respond. Use them to organize beliefs, behaviors, and reports around patterns that repeat.",tone:"violet",children:b.length===0?t.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Schema data is unavailable right now."}):t.jsxs("div",{className:"grid gap-5",children:[t.jsx(ae,{title:"Maladaptive schemas",titleHelp:R("maladaptive"),description:"These schemas describe recurring old patterns that can change how you read situations and react.",schemas:_,beliefs:T,behaviors:Q,reports:$,onOpenBelief:e=>{n(e),r(H(e)),l(!0)}}),t.jsx(ae,{title:"Adaptive schemas",titleHelp:R("adaptive"),description:"These schemas describe healthier patterns you want to trust, practice, and strengthen over time.",schemas:z,beliefs:T,behaviors:Q,reports:$,onOpenBelief:e=>{n(e),r(H(e)),l(!0)}})]})}),t.jsx(se,{eyebrow:"Beliefs",title:"Beliefs",description:"Use this list to review and edit the stories you tell yourself. Open any belief to update the wording, evidence, or a more flexible alternative.",titleHelp:"Beliefs are the specific scripts or rules that show up in your mind, such as what you expect from yourself, from other people, or from a situation.",tone:"sky",children:t.jsxs("div",{className:"grid gap-3",children:[t.jsx(U,{onClick:()=>{n(null),r({...S,userId:k}),l(!0)},children:"Add belief"}),T.length===0?t.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Your beliefs will appear here after you add the first one."}):T.map(e=>{const s=e.schemaId?me.get(e.schemaId)??null:null,i=G===e.id;return t.jsxs("div",{"data-psyche-focus-id":e.id,className:`rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4 text-left transition hover:bg-[var(--ui-surface-2)] ${Ve(i)}`,children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:e.statement}),t.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e.user?t.jsx(ze,{user:e.user,compact:!0}):null,t.jsx(Ie,{entityType:"belief_entry",entityId:e.id,count:Le(le,"belief_entry",e.id).count}),t.jsxs(I,{children:[e.confidence,"% grip"]}),t.jsx(U,{variant:"secondary",size:"sm",onClick:()=>{n(e),r(H(e)),l(!0)},children:"Edit"})]})]}),t.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:e.flexibleAlternative||"No flexible alternative recorded yet."}),t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[s?t.jsx(re,{label:s.title,schemaType:s.schemaType,compact:!0,showType:!0}):null,D.filter(m=>e.linkedModeIds.includes(m.id)).slice(0,2).map(m=>t.jsx(Be,{kind:"mode",label:m.title,compact:!0},m.id))]})]},e.id)})]})})]}),t.jsx(we,{open:g,onOpenChange:l,eyebrow:"Belief",title:c?"Refine belief":"Create belief",description:"Use this guided flow to capture the belief, what seems to support it, and a more flexible alternative.",value:h,onChange:r,draftPersistenceKey:c?`psyche.belief.${c.id}`:"psyche.belief.new",steps:ye,submitLabel:c?"Save belief":"Create belief",pending:V.isPending,error:j,onSubmit:async()=>{p(null);const e=ie.safeParse(h);if(!e.success){p("This belief still needs a statement before it can be saved.");return}try{await V.mutateAsync(e.data)}catch(s){p(s instanceof Error?s.message:"Unable to save this belief right now.")}}})]})}export{wt as PsycheSchemasBeliefsPage};
@@ -1 +1 @@
1
- import{r as E,j as e}from"./vendor-B7FKSwHK.js";import{i as N}from"./state-BFyKSULP.js";import{S as Q,e as G,j as l,bB as U,C as i,c as x,B as V,cH as X,cI as Y,cJ as z,cK as J}from"./index-gmPaoLN-.js";import{P as O}from"./page-hero-U603l9rQ.js";import{R as w,A,C,X as L,Y as F,T,a as k}from"./charts-C5S0-BL7.js";import"./motion-BibSzp57.js";import"./ui-uo_bNP7c.js";import"./board-DprRipIG.js";import"./forms-ByKjodjN.js";const S="min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)] p-5 shadow-[var(--card-shadow)]",_="min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",j="min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5",d="font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",P="font-label text-[10px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",b="text-[var(--ui-ink-soft)]",m="border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",Z="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)_74%,var(--ui-ink-strong)_26%)]",K="var(--ui-border-subtle)",h="var(--ui-ink-faint)",ee="color-mix(in_srgb,var(--success)_82%,var(--primary)_18%)",se="color-mix(in_srgb,var(--success)_18%,transparent)",M="color-mix(in_srgb,var(--info)_86%,var(--primary)_14%)",W="color-mix(in_srgb,var(--info)_16%,transparent)",te="var(--ui-ink-strong)",ae="color-mix(in_srgb,var(--ui-ink-strong)_12%,transparent)",D={background:"var(--ui-surface-modal)",border:"1px solid var(--ui-border-subtle)",borderRadius:"8px",color:"var(--ui-ink-strong)"};function re(t){switch(t){case"fresh":return"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)_74%,var(--ui-ink-strong)_26%)]";case"stale":return"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)_74%,var(--ui-ink-strong)_26%)]";case"unavailable":return"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)_74%,var(--ui-ink-strong)_26%)]";default:return m}}function n(t){return t>=3600?`${(t/3600).toFixed(1)}h`:`${Math.round(t/60)}m`}function I(t){return`${String(t).padStart(2,"0")}:00`}function R(t){return["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][t]??"Day"}function ie(t,r,c){return!t||!r?c:`${new Date(t).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})} → ${new Date(r).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}`}function H(t,r){const c=typeof t=="number"?t:typeof t=="string"?Number(t):0;return[r==="totalActivitySeconds"||r==="averageActivitySeconds"?n(c):String(Math.round(c)),r==="totalActivitySeconds"?"Activity":r==="averageActivitySeconds"?"Avg activity":r==="pickupCount"||r==="averagePickups"?r==="averagePickups"?"Avg pickups":"Pickups":r==="averageNotifications"?"Avg notifications":"Notifications"]}function pe(){const[t,r]=E.useState("day"),c=N({queryKey:["forge-screen-time-settings"],queryFn:()=>X().then(s=>s.settings)}),v=N({queryKey:["forge-screen-time-day"],queryFn:()=>Y().then(s=>s.screenTime)}),p=N({queryKey:["forge-screen-time-month"],queryFn:()=>z().then(s=>s.screenTime)}),f=N({queryKey:["forge-screen-time-all-time"],queryFn:()=>J().then(s=>s.screenTime)});if(c.isLoading||v.isLoading||p.isLoading||f.isLoading)return e.jsx(Q,{});const q=c.error??v.error??p.error??f.error;if(q||!c.data||!v.data||!p.data||!f.data)return e.jsx(G,{eyebrow:"Psyche",error:q,onRetry:()=>{c.refetch(),v.refetch(),p.refetch(),f.refetch()}});const a=c.data,o=v.data,g=p.data,u=f.data,$=o.topApps.slice(0,3).map(s=>s.displayName||s.bundleIdentifier),B=typeof a.metadata.snapshot_source=="string"?a.metadata.snapshot_source.replaceAll("_"," "):"device activity report";return e.jsxs("div",{className:"space-y-5",children:[e.jsx(O,{title:"Screen Time",titleText:"Screen Time",description:"Apple-compliant device activity, hourly usage, and reflective phone context woven into Psyche.",actions:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(l,{tone:"default",className:m,children:a.authorizationStatus.replaceAll("_"," ")}),e.jsx(l,{tone:"default",className:m,children:a.captureState.replaceAll("_"," ")}),e.jsx(l,{tone:"default",className:re(a.captureFreshness),children:a.captureFreshness}),e.jsx(l,{tone:"default",className:m,children:a.syncEnabled?"Sync on":"Sync paused"})]})}),e.jsx(U,{}),e.jsxs(i,{className:S,children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:d,children:"Reflective device activity"}),e.jsx("div",{className:x("mt-2 max-w-3xl text-sm",b),children:"Forge treats Screen Time as reflective evidence, not as fake exact foreground traces. Movement overlap is estimated from hourly bins and stays truthful about that."})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:["day","month","all_time"].map(s=>e.jsx(V,{variant:"ghost",className:t===s?"h-9 rounded-full border border-[color-mix(in_srgb,var(--success)_35%,var(--ui-border-subtle)_65%)] bg-[var(--ui-success-soft)] px-4 text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]":"h-9 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 text-[var(--ui-ink-soft)]",onClick:()=>r(s),children:s==="all_time"?"All time":s},s))})]}),e.jsxs("div",{className:"mt-5 grid gap-3 md:grid-cols-3",children:[e.jsxs(i,{className:_,children:[e.jsx("div",{className:P,children:"Today on screen"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:n(o.summary.totalActivitySeconds)}),e.jsxs("div",{className:x("mt-2 text-sm",b),children:["Across ",o.summary.activeHourCount," active hours."]})]}),e.jsxs(i,{className:_,children:[e.jsx("div",{className:P,children:"Pickups today"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:o.summary.pickupCount}),e.jsxs("div",{className:x("mt-2 text-sm",b),children:["First pickup"," ",o.summary.firstPickupAt?new Date(o.summary.firstPickupAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"not captured","."]})]}),e.jsxs(i,{className:_,children:[e.jsx("div",{className:P,children:"Capture health"}),e.jsx("div",{className:"mt-3 text-lg text-[var(--ui-ink-strong)]",children:a.captureFreshness==="fresh"?a.captureAgeHours!==null?`Updated ${a.captureAgeHours.toFixed(1)}h ago`:"Fresh capture":a.captureFreshness==="stale"?a.captureAgeHours!==null?`Last refresh ${a.captureAgeHours.toFixed(1)}h ago`:"Capture is stale":a.captureFreshness==="unavailable"?"Unavailable":"Waiting for capture"}),e.jsxs("div",{className:x("mt-2 text-sm",b),children:[a.capturedDayCount," days, ",a.capturedHourCount," ","hourly slices, ",a.captureWindowDays," day window."]})]})]}),e.jsx(i,{className:x("mt-3",_),children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(l,{tone:"default",className:m,children:B}),e.jsx(l,{tone:"default",className:m,children:"Hourly model"}),e.jsx(l,{tone:"default",className:m,children:ie(a.lastCaptureStartedAt,a.lastCaptureEndedAt,"No captured range yet")}),$.map(s=>e.jsx(l,{tone:"default",className:Z,children:s},s))]})})]}),t==="day"?e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[minmax(0,2fr)_minmax(18rem,1fr)]",children:[e.jsxs(i,{className:S,children:[e.jsx("div",{className:d,children:"Hourly rhythm"}),e.jsx("div",{className:x("mt-2 text-sm",b),children:"Activity, pickups, and notification pressure across the day."}),e.jsx("div",{className:"mt-5 h-72",children:e.jsx(w,{width:"100%",height:"100%",children:e.jsxs(A,{data:o.hourlySegments,children:[e.jsx(C,{stroke:K,vertical:!1}),e.jsx(L,{dataKey:"hourIndex",tickFormatter:I,stroke:h,tickLine:!1,axisLine:!1}),e.jsx(F,{stroke:h,tickLine:!1,axisLine:!1,tickFormatter:s=>n(Number(s))}),e.jsx(T,{contentStyle:D,formatter:(s,y)=>H(s,String(y)),labelFormatter:s=>I(Number(s))}),e.jsx(k,{type:"monotone",dataKey:"totalActivitySeconds",stroke:ee,fill:se,strokeWidth:2}),e.jsx(k,{type:"monotone",dataKey:"pickupCount",stroke:M,fill:W,strokeWidth:1.6})]})})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(i,{className:j,children:[e.jsx("div",{className:d,children:"Top apps"}),e.jsx("div",{className:"mt-4 space-y-3",children:o.topApps.slice(0,6).map(s=>e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium text-[var(--ui-ink-strong)]",children:s.displayName||s.bundleIdentifier}),e.jsx("div",{className:"truncate text-xs text-[var(--ui-ink-faint)]",children:s.categoryLabel||s.bundleIdentifier})]}),e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:n(s.totalActivitySeconds)})]},s.id))})]}),e.jsxs(i,{className:j,children:[e.jsx("div",{className:d,children:"Top categories"}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:o.topCategories.slice(0,8).map(s=>e.jsxs(l,{tone:"default",className:m,children:[s.categoryLabel," ·"," ",n(s.totalActivitySeconds)]},s.id))})]})]})]}):null,t==="month"?e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[minmax(0,2fr)_minmax(18rem,1fr)]",children:[e.jsxs(i,{className:S,children:[e.jsx("div",{className:d,children:"Monthly drift"}),e.jsx("div",{className:"mt-5 h-72",children:e.jsx(w,{width:"100%",height:"100%",children:e.jsxs(A,{data:g.days,children:[e.jsx(C,{stroke:K,vertical:!1}),e.jsx(L,{dataKey:"dateKey",stroke:h,tickLine:!1,axisLine:!1}),e.jsx(F,{stroke:h,tickLine:!1,axisLine:!1,tickFormatter:s=>n(Number(s))}),e.jsx(T,{contentStyle:D,formatter:(s,y)=>H(s,String(y))}),e.jsx(k,{type:"monotone",dataKey:"totalActivitySeconds",stroke:te,fill:ae,strokeWidth:2})]})})})]}),e.jsxs(i,{className:j,children:[e.jsx("div",{className:d,children:"Month summary"}),e.jsxs("div",{className:"mt-4 space-y-3 text-sm text-[var(--ui-ink-soft)]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Total activity"}),e.jsx("span",{children:n(g.totals.totalActivitySeconds)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Pickups"}),e.jsx("span",{children:g.totals.pickupCount})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Notifications"}),e.jsx("span",{children:g.totals.notificationCount})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Active days"}),e.jsx("span",{children:g.totals.activeDays})]})]})]})]}):null,t==="all_time"?e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[minmax(0,2fr)_minmax(18rem,1fr)]",children:[e.jsxs(i,{className:S,children:[e.jsx("div",{className:d,children:"Weekday pattern"}),e.jsx("div",{className:"mt-5 h-72",children:e.jsx(w,{width:"100%",height:"100%",children:e.jsxs(A,{data:u.weekdayPattern,children:[e.jsx(C,{stroke:K,vertical:!1}),e.jsx(L,{dataKey:"weekday",tickFormatter:R,stroke:h,tickLine:!1,axisLine:!1}),e.jsx(F,{stroke:h,tickLine:!1,axisLine:!1,tickFormatter:s=>n(Number(s))}),e.jsx(T,{contentStyle:D,formatter:(s,y)=>H(s,String(y)),labelFormatter:s=>R(Number(s))}),e.jsx(k,{type:"monotone",dataKey:"averageActivitySeconds",stroke:M,fill:W,strokeWidth:2})]})})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(i,{className:j,children:[e.jsx("div",{className:d,children:"Lifetime summary"}),e.jsxs("div",{className:"mt-4 space-y-3 text-sm text-[var(--ui-ink-soft)]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Days captured"}),e.jsx("span",{children:u.summary.dayCount})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Total activity"}),e.jsx("span",{children:n(u.summary.totalActivitySeconds)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Average per day"}),e.jsx("span",{children:n(u.summary.averageDailyActivitySeconds)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Total pickups"}),e.jsx("span",{children:u.summary.totalPickups})]})]})]}),e.jsxs(i,{className:j,children:[e.jsx("div",{className:d,children:"Dominant categories"}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:u.topCategories.slice(0,10).map(s=>e.jsxs(l,{tone:"default",className:m,children:[s.categoryLabel," ·"," ",n(s.totalActivitySeconds)]},s.id))})]})]})]}):null]})}export{pe as PsycheScreenTimePage};
1
+ import{r as Q,j as e}from"./vendor-Dgw7UY7q.js";import{i as N}from"./state-CkEUXgqt.js";import{S as B,e as G,j as l,bD as U,C as i,c as x,B as V,cJ as X,cK as Y,cL as z,cM as J}from"./index-C0CztQTU.js";import{P as O}from"./page-hero-ED69y6m0.js";import{R as w,A,C,X as L,Y as F,T,a as k}from"./charts-YpkKrjkZ.js";import"./motion-eRlWWQT8.js";import"./ui-CDt36qNz.js";import"./board-Dl7As76Q.js";import"./forms-DznAv9hZ.js";const S="min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)] p-5 shadow-[var(--card-shadow)]",_="min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",j="min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5",d="font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",P="font-label text-[10px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",b="text-[var(--ui-ink-soft)]",m="border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",Z="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)_74%,var(--ui-ink-strong)_26%)]",K="var(--ui-border-subtle)",h="var(--ui-ink-faint)",ee="color-mix(in_srgb,var(--success)_82%,var(--primary)_18%)",se="color-mix(in_srgb,var(--success)_18%,transparent)",q="color-mix(in_srgb,var(--info)_86%,var(--primary)_14%)",W="color-mix(in_srgb,var(--info)_16%,transparent)",te="var(--ui-ink-strong)",ae="color-mix(in_srgb,var(--ui-ink-strong)_12%,transparent)",D={background:"var(--ui-surface-modal)",border:"1px solid var(--ui-border-subtle)",borderRadius:"8px",color:"var(--ui-ink-strong)"};function re(t){switch(t){case"fresh":return"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)_74%,var(--ui-ink-strong)_26%)]";case"stale":return"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)_74%,var(--ui-ink-strong)_26%)]";case"unavailable":return"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)_74%,var(--ui-ink-strong)_26%)]";default:return m}}function n(t){return t>=3600?`${(t/3600).toFixed(1)}h`:`${Math.round(t/60)}m`}function R(t){return`${String(t).padStart(2,"0")}:00`}function $(t){return["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][t]??"Day"}function ie(t,r,c){return!t||!r?c:`${new Date(t).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})} → ${new Date(r).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}`}function H(t,r){const c=typeof t=="number"?t:typeof t=="string"?Number(t):0;return[r==="totalActivitySeconds"||r==="averageActivitySeconds"?n(c):String(Math.round(c)),r==="totalActivitySeconds"?"Activity":r==="averageActivitySeconds"?"Avg activity":r==="pickupCount"||r==="averagePickups"?r==="averagePickups"?"Avg pickups":"Pickups":r==="averageNotifications"?"Avg notifications":"Notifications"]}function pe(){const[t,r]=Q.useState("day"),c=N({queryKey:["forge-screen-time-settings"],queryFn:()=>X().then(s=>s.settings)}),v=N({queryKey:["forge-screen-time-day"],queryFn:()=>Y().then(s=>s.screenTime)}),p=N({queryKey:["forge-screen-time-month"],queryFn:()=>z().then(s=>s.screenTime)}),f=N({queryKey:["forge-screen-time-all-time"],queryFn:()=>J().then(s=>s.screenTime)});if(c.isLoading||v.isLoading||p.isLoading||f.isLoading)return e.jsx(B,{});const M=c.error??v.error??p.error??f.error;if(M||!c.data||!v.data||!p.data||!f.data)return e.jsx(G,{eyebrow:"Psyche",error:M,onRetry:()=>{c.refetch(),v.refetch(),p.refetch(),f.refetch()}});const a=c.data,o=v.data,g=p.data,u=f.data,I=o.topApps.slice(0,3).map(s=>s.displayName||s.bundleIdentifier),E=typeof a.metadata.snapshot_source=="string"?a.metadata.snapshot_source.replaceAll("_"," "):"device activity report";return e.jsxs("div",{className:"space-y-5",children:[e.jsx(O,{title:"Screen Time",titleText:"Screen Time",description:"Apple-compliant device activity, hourly usage, and reflective phone context woven into Psyche.",actions:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(l,{tone:"default",className:m,children:a.authorizationStatus.replaceAll("_"," ")}),e.jsx(l,{tone:"default",className:m,children:a.captureState.replaceAll("_"," ")}),e.jsx(l,{tone:"default",className:re(a.captureFreshness),children:a.captureFreshness}),e.jsx(l,{tone:"default",className:m,children:a.syncEnabled?"Sync on":"Sync paused"})]})}),e.jsx(U,{}),e.jsxs(i,{className:S,children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:d,children:"Reflective device activity"}),e.jsx("div",{className:x("mt-2 max-w-3xl text-sm",b),children:"Forge treats Screen Time as reflective evidence, not as fake exact foreground traces. Movement overlap is estimated from hourly bins and stays truthful about that."})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:["day","month","all_time"].map(s=>e.jsx(V,{variant:"ghost",className:t===s?"h-9 rounded-full border border-[color-mix(in_srgb,var(--success)_35%,var(--ui-border-subtle)_65%)] bg-[var(--ui-success-soft)] px-4 text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]":"h-9 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 text-[var(--ui-ink-soft)]",onClick:()=>r(s),children:s==="all_time"?"All time":s},s))})]}),e.jsxs("div",{className:"mt-5 grid gap-3 md:grid-cols-3",children:[e.jsxs(i,{className:_,children:[e.jsx("div",{className:P,children:"Today on screen"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:n(o.summary.totalActivitySeconds)}),e.jsxs("div",{className:x("mt-2 text-sm",b),children:["Across ",o.summary.activeHourCount," active hours."]})]}),e.jsxs(i,{className:_,children:[e.jsx("div",{className:P,children:"Pickups today"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:o.summary.pickupCount}),e.jsxs("div",{className:x("mt-2 text-sm",b),children:["First pickup"," ",o.summary.firstPickupAt?new Date(o.summary.firstPickupAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"not captured","."]})]}),e.jsxs(i,{className:_,children:[e.jsx("div",{className:P,children:"Capture health"}),e.jsx("div",{className:"mt-3 text-lg text-[var(--ui-ink-strong)]",children:a.captureFreshness==="fresh"?a.captureAgeHours!==null?`Updated ${a.captureAgeHours.toFixed(1)}h ago`:"Fresh capture":a.captureFreshness==="stale"?a.captureAgeHours!==null?`Last refresh ${a.captureAgeHours.toFixed(1)}h ago`:"Capture is stale":a.captureFreshness==="unavailable"?"Unavailable":"Waiting for capture"}),e.jsxs("div",{className:x("mt-2 text-sm",b),children:[a.capturedDayCount," days, ",a.capturedHourCount," ","hourly slices, ",a.captureWindowDays," day window."]})]})]}),e.jsx(i,{className:x("mt-3",_),children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(l,{tone:"default",className:m,children:E}),e.jsx(l,{tone:"default",className:m,children:"Hourly model"}),e.jsx(l,{tone:"default",className:m,children:ie(a.lastCaptureStartedAt,a.lastCaptureEndedAt,"No captured range yet")}),I.map(s=>e.jsx(l,{tone:"default",className:Z,children:s},s))]})})]}),t==="day"?e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[minmax(0,2fr)_minmax(18rem,1fr)]",children:[e.jsxs(i,{className:S,children:[e.jsx("div",{className:d,children:"Hourly rhythm"}),e.jsx("div",{className:x("mt-2 text-sm",b),children:"Activity, pickups, and notification pressure across the day."}),e.jsx("div",{className:"mt-5 h-72",children:e.jsx(w,{width:"100%",height:"100%",children:e.jsxs(A,{data:o.hourlySegments,children:[e.jsx(C,{stroke:K,vertical:!1}),e.jsx(L,{dataKey:"hourIndex",tickFormatter:R,stroke:h,tickLine:!1,axisLine:!1}),e.jsx(F,{stroke:h,tickLine:!1,axisLine:!1,tickFormatter:s=>n(Number(s))}),e.jsx(T,{contentStyle:D,formatter:(s,y)=>H(s,String(y)),labelFormatter:s=>R(Number(s))}),e.jsx(k,{type:"monotone",dataKey:"totalActivitySeconds",stroke:ee,fill:se,strokeWidth:2}),e.jsx(k,{type:"monotone",dataKey:"pickupCount",stroke:q,fill:W,strokeWidth:1.6})]})})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(i,{className:j,children:[e.jsx("div",{className:d,children:"Top apps"}),e.jsx("div",{className:"mt-4 space-y-3",children:o.topApps.slice(0,6).map(s=>e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium text-[var(--ui-ink-strong)]",children:s.displayName||s.bundleIdentifier}),e.jsx("div",{className:"truncate text-xs text-[var(--ui-ink-faint)]",children:s.categoryLabel||s.bundleIdentifier})]}),e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:n(s.totalActivitySeconds)})]},s.id))})]}),e.jsxs(i,{className:j,children:[e.jsx("div",{className:d,children:"Top categories"}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:o.topCategories.slice(0,8).map(s=>e.jsxs(l,{tone:"default",className:m,children:[s.categoryLabel," ·"," ",n(s.totalActivitySeconds)]},s.id))})]})]})]}):null,t==="month"?e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[minmax(0,2fr)_minmax(18rem,1fr)]",children:[e.jsxs(i,{className:S,children:[e.jsx("div",{className:d,children:"Monthly drift"}),e.jsx("div",{className:"mt-5 h-72",children:e.jsx(w,{width:"100%",height:"100%",children:e.jsxs(A,{data:g.days,children:[e.jsx(C,{stroke:K,vertical:!1}),e.jsx(L,{dataKey:"dateKey",stroke:h,tickLine:!1,axisLine:!1}),e.jsx(F,{stroke:h,tickLine:!1,axisLine:!1,tickFormatter:s=>n(Number(s))}),e.jsx(T,{contentStyle:D,formatter:(s,y)=>H(s,String(y))}),e.jsx(k,{type:"monotone",dataKey:"totalActivitySeconds",stroke:te,fill:ae,strokeWidth:2})]})})})]}),e.jsxs(i,{className:j,children:[e.jsx("div",{className:d,children:"Month summary"}),e.jsxs("div",{className:"mt-4 space-y-3 text-sm text-[var(--ui-ink-soft)]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Total activity"}),e.jsx("span",{children:n(g.totals.totalActivitySeconds)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Pickups"}),e.jsx("span",{children:g.totals.pickupCount})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Notifications"}),e.jsx("span",{children:g.totals.notificationCount})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Active days"}),e.jsx("span",{children:g.totals.activeDays})]})]})]})]}):null,t==="all_time"?e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[minmax(0,2fr)_minmax(18rem,1fr)]",children:[e.jsxs(i,{className:S,children:[e.jsx("div",{className:d,children:"Weekday pattern"}),e.jsx("div",{className:"mt-5 h-72",children:e.jsx(w,{width:"100%",height:"100%",children:e.jsxs(A,{data:u.weekdayPattern,children:[e.jsx(C,{stroke:K,vertical:!1}),e.jsx(L,{dataKey:"weekday",tickFormatter:$,stroke:h,tickLine:!1,axisLine:!1}),e.jsx(F,{stroke:h,tickLine:!1,axisLine:!1,tickFormatter:s=>n(Number(s))}),e.jsx(T,{contentStyle:D,formatter:(s,y)=>H(s,String(y)),labelFormatter:s=>$(Number(s))}),e.jsx(k,{type:"monotone",dataKey:"averageActivitySeconds",stroke:q,fill:W,strokeWidth:2})]})})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(i,{className:j,children:[e.jsx("div",{className:d,children:"Lifetime summary"}),e.jsxs("div",{className:"mt-4 space-y-3 text-sm text-[var(--ui-ink-soft)]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Days captured"}),e.jsx("span",{children:u.summary.dayCount})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Total activity"}),e.jsx("span",{children:n(u.summary.totalActivitySeconds)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Average per day"}),e.jsx("span",{children:n(u.summary.averageDailyActivitySeconds)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Total pickups"}),e.jsx("span",{children:u.summary.totalPickups})]})]})]}),e.jsxs(i,{className:j,children:[e.jsx("div",{className:d,children:"Dominant categories"}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:u.topCategories.slice(0,10).map(s=>e.jsxs(l,{tone:"default",className:m,children:[s.categoryLabel," ·"," ",n(s.totalActivitySeconds)]},s.id))})]})]})]}):null]})}export{pe as PsycheScreenTimePage};