forge-openclaw-plugin 0.2.109 → 0.2.110
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{activity-page-DWHZ8_sJ.js → activity-page-BdeoV3N4.js} +1 -1
- package/dist/assets/{ai-surface-workspace-DPygfyhc.js → ai-surface-workspace-BCbQUekv.js} +1 -1
- package/dist/assets/{atlas-panel-D261RUQF.js → atlas-panel-DTnRBOZx.js} +1 -1
- package/dist/assets/{calendar-page-BQbJkdPF.js → calendar-page-YDexXy_e.js} +1 -1
- package/dist/assets/{calendar-rules-BoFsuvZ8.js → calendar-rules-B_aOcMi3.js} +1 -1
- package/dist/assets/{calendar-week-toolbar-LetevPI7.js → calendar-week-toolbar-BTbIzq3e.js} +1 -1
- package/dist/assets/{companion-sync-lab-page-Bid-4B8W.js → companion-sync-lab-page-DKouMut9.js} +1 -1
- package/dist/assets/{daily-metrics-dashboard-CqnGJNeI.js → daily-metrics-dashboard-B3UCGG1t.js} +1 -1
- package/dist/assets/{entity-note-count-link-VMURwBMi.js → entity-note-count-link-DUxobQUt.js} +1 -1
- package/dist/assets/{entity-notes-surface-DGXcyNzo.js → entity-notes-surface-BdHBn8rx.js} +1 -1
- package/dist/assets/{execution-board-BGf6zZqJ.js → execution-board-R5-oyf-Z.js} +1 -1
- package/dist/assets/{faceted-token-search-CAsZrhZ4.js → faceted-token-search-DtO6OUwQ.js} +1 -1
- package/dist/assets/{flagship-signal-deck-DJsq3jn2.js → flagship-signal-deck-B9k46sWA.js} +1 -1
- package/dist/assets/{floating-action-menu-B3tQStUN.js → floating-action-menu-DBzfnJOx.js} +1 -1
- package/dist/assets/{goal-detail-page-DBs-9wpk.js → goal-detail-page-Mr_gnZ2l.js} +1 -1
- package/dist/assets/{goals-page-CPmhjsG-.js → goals-page-BG7FuqK1.js} +1 -1
- package/dist/assets/{habits-page-DkW8zT6_.js → habits-page-CGdaOqL3.js} +1 -1
- package/dist/assets/{index-BhkubYaC.js → index-BP9__l6C.js} +2 -2
- package/dist/assets/{insight-flow-dialog-BvgRjkPi.js → insight-flow-dialog-BUv06Vn-.js} +1 -1
- package/dist/assets/{insights-page-Dtij6pm5.js → insights-page-BgD1_1we.js} +1 -1
- package/dist/assets/{kanban-page-R1x5hUU-.js → kanban-page-DvZSN-Bi.js} +1 -1
- package/dist/assets/{knowledge-graph-page-BRBB5Vvz.js → knowledge-graph-page-BXWXtPvo.js} +1 -1
- package/dist/assets/{life-force-page-DGPWKM9I.js → life-force-page-CwjHvpzu.js} +1 -1
- package/dist/assets/{life-force-workspace-DoRIQoU_.js → life-force-workspace-Ct70SsNQ.js} +1 -1
- package/dist/assets/{metric-tile-NJiFcFxW.js → metric-tile-DCxLxNli.js} +1 -1
- package/dist/assets/{movement-page-Dk8aV737.js → movement-page-C06ebiYk.js} +1 -1
- package/dist/assets/{note-markdown-CZHjJDve.js → note-markdown-3wB52NOn.js} +1 -1
- package/dist/assets/{note-tags-input-DFpxZHPg.js → note-tags-input-Blg5Gqz_.js} +1 -1
- package/dist/assets/{notes-page-r3kymlqg.js → notes-page-CSkjizyK.js} +1 -1
- package/dist/assets/{open-in-graph-button-B_XHtHZD.js → open-in-graph-button-CDHxzS8B.js} +1 -1
- package/dist/assets/{orbit-map-C_xy4kYC.js → orbit-map-OV-GcUZl.js} +1 -1
- package/dist/assets/{overview-page-Dwg4uYe9.js → overview-page-Cw3pI34n.js} +1 -1
- package/dist/assets/{page-hero-DzEsy8i5.js → page-hero-DgnhI5es.js} +1 -1
- package/dist/assets/{pill-cluster-DcBUeEMT.js → pill-cluster-DIGkIvKN.js} +1 -1
- package/dist/assets/{preference-entity-handoff-button-BX2n07ob.js → preference-entity-handoff-button-LT_GBuqB.js} +1 -1
- package/dist/assets/{preferences-page-BSnwiWBt.js → preferences-page-Dkvz7nkU.js} +1 -1
- package/dist/assets/{project-collections-BR6YdlCZ.js → project-collections-BsAT8WYE.js} +1 -1
- package/dist/assets/{project-detail-page-DeYshcCb.js → project-detail-page-DsJUWg8k.js} +1 -1
- package/dist/assets/{project-management-hierarchy-page-Bhdt79Ea.js → project-management-hierarchy-page-CIy0wAp8.js} +1 -1
- package/dist/assets/{project-management-section-nav-DnXuWUfe.js → project-management-section-nav-ClB2S1FW.js} +1 -1
- package/dist/assets/{projects-page-BA9W0ZPk.js → projects-page-Da1bZLSH.js} +1 -1
- package/dist/assets/{psyche-behaviors-page-DpTj53GI.js → psyche-behaviors-page-D0uwf78o.js} +1 -1
- package/dist/assets/{psyche-flashcards-page-CV58hAJA.js → psyche-flashcards-page-e_qwwsOf.js} +1 -1
- package/dist/assets/{psyche-goal-map-page-C07CALFg.js → psyche-goal-map-page-BIY028Wx.js} +1 -1
- package/dist/assets/{psyche-graph-CP7mxfMP.js → psyche-graph-Y1UKALEm.js} +1 -1
- package/dist/assets/{psyche-metrics-page-CY8e9R0D.js → psyche-metrics-page-DDkGJzo_.js} +1 -1
- package/dist/assets/{psyche-mode-guide-page-DYt6AmHl.js → psyche-mode-guide-page-C7mD9uiv.js} +1 -1
- package/dist/assets/{psyche-modes-page-Dd77kTtJ.js → psyche-modes-page-RUdaOQWr.js} +1 -1
- package/dist/assets/{psyche-page-DNXZjIKp.js → psyche-page-D3FZy__c.js} +1 -1
- package/dist/assets/{psyche-patterns-page-DxGzpeT5.js → psyche-patterns-page-BSD35F41.js} +1 -1
- package/dist/assets/{psyche-questionnaire-builder-page-5EQctRHO.js → psyche-questionnaire-builder-page-BpgUTMgj.js} +1 -1
- package/dist/assets/{psyche-questionnaire-detail-page-W8nhUGAc.js → psyche-questionnaire-detail-page-DwjyjNhg.js} +1 -1
- package/dist/assets/{psyche-questionnaire-run-detail-page-DVwzSuqg.js → psyche-questionnaire-run-detail-page-mJ-DgeB-.js} +1 -1
- package/dist/assets/{psyche-questionnaire-run-page-BHResQgL.js → psyche-questionnaire-run-page-YuMBkH1G.js} +1 -1
- package/dist/assets/{psyche-questionnaires-page-DFTOXpyp.js → psyche-questionnaires-page-CNglToKh.js} +1 -1
- package/dist/assets/{psyche-report-detail-page-BqDE_tf7.js → psyche-report-detail-page-CV6tbLxz.js} +1 -1
- package/dist/assets/{psyche-reports-page-B75pDz0l.js → psyche-reports-page-BEOe8OPA.js} +1 -1
- package/dist/assets/{psyche-schemas-beliefs-page-BjSO4tYL.js → psyche-schemas-beliefs-page-KIRqmO8C.js} +1 -1
- package/dist/assets/{psyche-screen-time-page-B7lKf1g7.js → psyche-screen-time-page-DvXuwgU1.js} +1 -1
- package/dist/assets/{psyche-self-observation-page-C6RMThwc.js → psyche-self-observation-page-E6yDPBm1.js} +1 -1
- package/dist/assets/{psyche-values-page-1O158mIJ.js → psyche-values-page-CSLG7C6a.js} +1 -1
- package/dist/assets/{report-chain-fields-CyJ_VFY5.js → report-chain-fields-BYEp3tRr.js} +1 -1
- package/dist/assets/{rewards-page-sPlDYuVo.js → rewards-page-pAa_MIte.js} +1 -1
- package/dist/assets/{scheduling-rules-editor-DGgcBs1W.js → scheduling-rules-editor-BmGrjC9q.js} +1 -1
- package/dist/assets/{schema-badge-Do-YvNHm.js → schema-badge-IVJ4SoeC.js} +1 -1
- package/dist/assets/{select-menu-CAM7rMdO.js → select-menu-BE5AIdgO.js} +1 -1
- package/dist/assets/{settings-agents-page-BsZY71kz.js → settings-agents-page-hqI0IaNx.js} +1 -1
- package/dist/assets/{settings-bin-page-kB3jtHo_.js → settings-bin-page-2bPjFtZ3.js} +1 -1
- package/dist/assets/{settings-calendar-page-C-IGNk3_.js → settings-calendar-page-u_TfZJEh.js} +1 -1
- package/dist/assets/{settings-data-page-CFGSL9g3.js → settings-data-page-DSQ14F2i.js} +1 -1
- package/dist/assets/{settings-logs-page-C7e9FIN_.js → settings-logs-page-BU0CJhDM.js} +1 -1
- package/dist/assets/{settings-mobile-page-DzKeZQDM.js → settings-mobile-page-B1fQ61BB.js} +1 -1
- package/dist/assets/{settings-models-page-dFhaOV3E.js → settings-models-page-B0Dis_c_.js} +1 -1
- package/dist/assets/{settings-page-C0fSyYUx.js → settings-page-V4ibXIp9.js} +1 -1
- package/dist/assets/{settings-rewards-page-D-LuZHhv.js → settings-rewards-page-DeCGBNn5.js} +1 -1
- package/dist/assets/{settings-section-nav-kFFQSJEe.js → settings-section-nav-DV5umEkp.js} +1 -1
- package/dist/assets/{settings-users-page-CX797HPB.js → settings-users-page-BB8Dzd_P.js} +1 -1
- package/dist/assets/{settings-wiki-page-CWLAvcsf.js → settings-wiki-page-B0k0KRsU.js} +1 -1
- package/dist/assets/{sleep-page-QgBkKyk_.js → sleep-page-CPwUb-em.js} +1 -1
- package/dist/assets/{sports-page-C8tLMl7V.js → sports-page-Cl4vZVwh.js} +1 -1
- package/dist/assets/{strategies-page-CGgh-KXu.js → strategies-page-DhFXf-g3.js} +1 -1
- package/dist/assets/{strategy-detail-page-CnzqjjoD.js → strategy-detail-page-B2gotRKI.js} +1 -1
- package/dist/assets/{strategy-dialog-C6AThZ9L.js → strategy-dialog-DD1bbrRB.js} +1 -1
- package/dist/assets/{surface-CIDhCEsF.js → surface-98myBzix.js} +1 -1
- package/dist/assets/{task-detail-page-Dp0r_qZP.js → task-detail-page-nx4eQbMW.js} +1 -1
- package/dist/assets/{timebox-planning-dialog-B3uaSsWI.js → timebox-planning-dialog-DoZ9zUra.js} +1 -1
- package/dist/assets/{today-page-CTnMYrPi.js → today-page-7BH7Yne1.js} +1 -1
- package/dist/assets/{training-load-page-D0WB5_Tq.js → training-load-page-E82pNn1-.js} +1 -1
- package/dist/assets/{vitals-page-0vg8nqwj.js → vitals-page-D64WlwVv.js} +1 -1
- package/dist/assets/{weekly-review-page-CSSKlkbH.js → weekly-review-page-BkRxxm7Q.js} +1 -1
- package/dist/assets/weight-loss-page-DPbg7rTC.js +5 -0
- package/dist/assets/{wiki-article-markdown-CBFvfJx_.js → wiki-article-markdown-B0Q6082A.js} +1 -1
- package/dist/assets/{wiki-editor-page-CL1uxpih.js → wiki-editor-page-Tkb50wEA.js} +1 -1
- package/dist/assets/{wiki-ingest-history-page-XX8DeNCC.js → wiki-ingest-history-page-CcQzkZRr.js} +1 -1
- package/dist/assets/{wiki-ingest-modal-j-ftDmzp.js → wiki-ingest-modal-D6yft0Qb.js} +1 -1
- package/dist/assets/{wiki-page-B46TQYpy.js → wiki-page-DEND1jmD.js} +1 -1
- package/dist/assets/{workbench-flow-page-CicEuBKq.js → workbench-flow-page-CkNI03j_.js} +1 -1
- package/dist/assets/{workbench-page-tXezYLh_.js → workbench-page-W3zQpeWr.js} +1 -1
- package/dist/assets/{workout-detail-page-BTO5X0Of.js → workout-detail-page-BVSZv53z.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/server/server/src/app.js +2 -0
- package/dist/server/server/src/health-weight-loss.js +160 -10
- package/dist/server/src/lib/weight-loss-energy-model.js +64 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/skills/forge-openclaw/SKILL.md +10 -0
- package/skills/forge-openclaw/entity_conversation_playbooks.md +33 -0
- package/skills/forge-openclaw/psyche_entity_playbooks.md +31 -0
- package/dist/assets/weight-loss-page-Dcr4wjjy.js +0 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b5 as Q,r as g,j as e,aC as y,c2 as U}from"./vendor-Dnkkx2co.js";import{i as G}from"./state-vCcAT5Hq.js";import{A as z}from"./ai-surface-workspace-DPygfyhc.js";import{b as Z,P as J}from"./psyche-graph-CP7mxfMP.js";import{u as H,Q as X,j as Y,F as ee,b as N,C as P,Z as K,S as te,E as se,a8 as re,ch as ae,B as ie,V as ne,c as I,cj as oe,ad as le,ck as de}from"./index-BhkubYaC.js";import{P as ce}from"./page-hero-DzEsy8i5.js";import"./board-dIX6etHh.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./graph-DDUZNRsO.js";const D={intent:"trigger_report",linkedGoalId:"",linkedProjectId:"",linkedTaskId:""};function ue({open:t,onOpenChange:o}){const d=Q(),l=H(),[c,b]=g.useState(D),k=[{id:"intent",eyebrow:"Reflect",title:"What do you want to reflect on?",description:"Choose the entrypoint first. Forge will route you into the right guided flow instead of dropping you into a generic form.",render:(i,r)=>e.jsx(Y,{columns:3,value:i.intent,onChange:s=>r({intent:s}),options:[{value:"trigger_report",label:"A situation",description:"Start a Spark-to-Pivot report about something that happened."},{value:"behavior",label:"A behavior",description:"Trace an away move, committed action, or recovery path."},{value:"belief",label:"A belief script",description:"Capture or refine the belief beneath the reaction."},{value:"pattern",label:"A recurring pattern",description:"Map the loop, payoff, cost, and better response."},{value:"value",label:"A blocked value",description:"Clarify which value is being challenged or needs support."},{value:"execution_tension",label:"A goal tension",description:"Reflect on a goal, project, or task that carries friction."}]})},{id:"placement",eyebrow:"Placement",title:"Attach the reflection to the wider system",description:"This keeps the reflection connected to values, behaviors, and live work instead of becoming an isolated note.",render:(i,r)=>e.jsx("div",{className:"grid gap-4",children:e.jsx(ee,{label:"Goal / project / task tension",children:e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(N,{kind:"goal",label:"Goal",compact:!0,gradient:!1}),e.jsx(N,{kind:"project",label:"Project",compact:!0,gradient:!1}),e.jsx(N,{kind:"task",label:"Task",compact:!0,gradient:!1})]}),e.jsxs("select",{className:"rounded-[18px] border border-white/8 bg-white/6 px-4 py-3 text-sm text-white",value:i.linkedGoalId,onChange:s=>r({linkedGoalId:s.target.value}),children:[e.jsx("option",{value:"",children:"No goal selected"}),l.snapshot.goals.map(s=>e.jsxs("option",{value:s.id,children:["Goal · ",s.title]},s.id))]}),e.jsxs("select",{className:"rounded-[18px] border border-white/8 bg-white/6 px-4 py-3 text-sm text-white",value:i.linkedProjectId,onChange:s=>r({linkedProjectId:s.target.value}),children:[e.jsx("option",{value:"",children:"No project selected"}),l.snapshot.dashboard.projects.map(s=>e.jsxs("option",{value:s.id,children:["Project · ",s.title]},s.id))]}),e.jsxs("select",{className:"rounded-[18px] border border-white/8 bg-white/6 px-4 py-3 text-sm text-white",value:i.linkedTaskId,onChange:s=>r({linkedTaskId:s.target.value}),children:[e.jsx("option",{value:"",children:"No task selected"}),l.snapshot.tasks.slice(0,40).map(s=>e.jsxs("option",{value:s.id,children:["Task · ",s.title]},s.id))]})]})})})}],h=async()=>{const i=new URLSearchParams({create:"1",intent:c.intent});switch(c.linkedGoalId&&i.set("goalId",c.linkedGoalId),c.linkedProjectId&&i.set("projectId",c.linkedProjectId),c.linkedTaskId&&i.set("taskId",c.linkedTaskId),c.intent){case"behavior":d(`/psyche/behaviors?${i.toString()}`);break;case"belief":d(`/psyche/schemas-beliefs?${i.toString()}`);break;case"pattern":d(`/psyche/patterns?${i.toString()}`);break;case"value":d(`/psyche/values?${i.toString()}`);break;case"execution_tension":case"trigger_report":default:d(`/psyche/reports?${i.toString()}`);break}o(!1),b(D)};return e.jsx(X,{open:t,onOpenChange:o,eyebrow:"Reflect",title:"Start from the right reflective doorway",description:"Choose what you want to reflect on first. Forge will take you into the right guided flow instead of leaving you in a generic form.",value:c,onChange:b,draftPersistenceKey:"psyche.reflect.launcher",steps:k,submitLabel:"Open guided reflection",onSubmit:h})}function _({to:t,children:o,className:d}){return e.jsx(y,{to:t,className:"group block transition-transform duration-[var(--motion-medium)] ease-[var(--ease-standard)] hover:-translate-y-0.5 focus-visible:outline-none",children:e.jsx(P,{className:K("transition-[transform,box-shadow,background,border-color] duration-[var(--motion-medium)] ease-[var(--ease-standard)] group-hover:border-[var(--ui-border-strong)] group-hover:bg-[var(--ui-surface-hover)] group-hover:shadow-[var(--card-shadow-hover)] group-focus-visible:shadow-[var(--card-shadow-hover)]",d),children:o})})}function C(t){return`${t.toFixed(t>=10?0:1)}%`}function f(t){return new Intl.NumberFormat().format(Math.round(t))}const W="inline-flex min-h-10 min-w-0 max-w-full items-center justify-center rounded-[var(--radius-control)] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-2 text-sm font-medium whitespace-nowrap text-[var(--ui-ink-medium)] transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",me="bg-[linear-gradient(135deg,color-mix(in_srgb,var(--primary)_34%,var(--ui-surface-2)_66%),color-mix(in_srgb,var(--primary)_18%,var(--ui-surface-1)_82%))] text-[var(--ui-ink-strong)]";function M(t,o){return o==="percent"?C(t):f(t)}function pe({metric:t}){const o=t.history.slice(0,7).reverse(),d=Math.max(1,...o.map(l=>l.rawSwearCount));return e.jsxs(P,{className:"min-w-0 border border-[color-mix(in_srgb,var(--warning)_24%,var(--ui-border-subtle)_76%)] bg-[color-mix(in_srgb,var(--ui-warning-soft)_48%,var(--ui-surface-1)_52%)] p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--warning)]",children:"Devrage metric"}),e.jsxs("div",{className:"mt-2 break-words font-display text-[clamp(1.4rem,2.5vw,2.15rem)] leading-none text-[var(--ui-ink-strong)]",children:[f(t.rawSwearCount)," swears"]})]}),e.jsx(I,{className:"bg-[var(--ui-warning-soft)] text-[var(--warning)]",children:t.latestDateKey??"No history"})]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"min-w-0 rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("div",{className:"text-xs text-[var(--ui-ink-faint)]",children:"Swearing messages"}),e.jsx("div",{className:"mt-1 break-words text-2xl font-semibold text-[var(--ui-ink-strong)]",children:C(t.swearingMessagePercent)})]}),e.jsxs("div",{className:"min-w-0 rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("div",{className:"text-xs text-[var(--ui-ink-faint)]",children:"Daily average"}),e.jsx("div",{className:"mt-1 break-words text-2xl font-semibold text-[var(--ui-ink-strong)]",children:M(t.dailyAverage.rawSwearCount,"count")})]}),e.jsxs("div",{className:"min-w-0 rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("div",{className:"text-xs text-[var(--ui-ink-faint)]",children:"Weekly average"}),e.jsx("div",{className:"mt-1 break-words text-2xl font-semibold text-[var(--ui-ink-strong)]",children:M(t.weeklyAverage.rawSwearCount,"count")})]})]}),e.jsx("div",{className:"mt-4 flex h-16 items-end gap-1.5",children:o.length>0?o.map(l=>e.jsx("div",{className:"min-w-0 flex-1 rounded-t-[6px] bg-[var(--warning)]/50",style:{height:`${Math.max(8,l.rawSwearCount/d*64)}px`},title:`${l.dateKey}: ${f(l.rawSwearCount)} swears, ${C(l.swearingMessagePercent)} swearing messages`},l.dateKey)):e.jsx("div",{className:"self-center text-sm text-[var(--ui-ink-faint)]",children:"History will appear after the first local backfill."})}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2 text-xs text-[var(--ui-ink-soft)]",children:[e.jsxs("span",{children:[f(t.conversationsScanned)," conversations"]}),e.jsxs("span",{children:[f(t.messagesScanned)," messages"]}),e.jsxs("span",{children:[f(t.messagesWithSwears)," flagged"]})]}),e.jsx(y,{to:"/psyche/metrics",className:"mt-4 inline-flex min-h-10 items-center justify-center rounded-[var(--radius-control)] border border-[color-mix(in_srgb,var(--warning)_24%,transparent)] bg-[var(--ui-warning-soft)] px-4 py-2 text-sm font-medium text-[var(--warning)] transition hover:bg-[color-mix(in_srgb,var(--warning)_20%,transparent)]",children:"Open metrics"})]})}function Se(){var A,T;const t=H(),[o,d]=U(),[l,c]=g.useState(o.get("reflect")==="1"),[b,k]=g.useState(null),h=G({queryKey:["forge-psyche-overview"],queryFn:le}),i=G({queryKey:["forge-psyche-questionnaires-hub"],queryFn:()=>de()}),r=(A=h.data)==null?void 0:A.overview,s=g.useMemo(()=>r?t.snapshot.goals.slice(0,3).map(a=>{const m=r.values.filter(u=>u.linkedGoalIds.includes(a.id)),S=t.snapshot.dashboard.projects.filter(u=>u.goalId===a.id),F=t.snapshot.habits.filter(u=>u.linkedGoalIds.includes(a.id)||u.linkedValueIds.some(w=>m.some(j=>j.id===w))),O=r.reports.filter(u=>u.linkedGoalIds.includes(a.id)),L=r.behaviors.filter(u=>u.linkedValueIds.some(w=>m.some(j=>j.id===w))),V=r.beliefs.filter(u=>u.linkedValueIds.some(w=>m.some(j=>j.id===w)));return{goal:a,linkedValues:m,linkedProjects:S,linkedHabits:F,linkedReports:O,linkedBehaviors:L,linkedBeliefs:V}}):[],[r,t.snapshot.dashboard.projects,t.snapshot.goals,t.snapshot.habits]),p=g.useMemo(()=>Z(s,{compact:!0}),[s]);if(g.useEffect(()=>{k(p.defaultSelectedId)},[p.defaultSelectedId]),h.isLoading)return e.jsx(te,{});if(h.isError||!r)return e.jsx(se,{eyebrow:"Psyche",error:h.error,onRetry:()=>void h.refetch()});const n=p.inspectors[b??p.defaultSelectedId]??p.inspectors[p.defaultSelectedId],v=r.patterns[0]??null,R=r.reports[0]??null,x=[...((T=i.data)==null?void 0:T.instruments)??[]].sort((a,m)=>{const S=a.latestRunAt?new Date(a.latestRunAt).getTime():0;return(m.latestRunAt?new Date(m.latestRunAt).getTime():0)-S})[0]??null,E="Values, patterns, behaviors, beliefs, habits, and reports in one live field.",$=r.devrageMetric.hasData||r.devrageMetric.conversationsScanned>0||r.devrageMetric.history.length>0,q=e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e.jsx(re,{metrics:t.snapshot.metrics}),e.jsx(y,{to:"/psyche/goal-map",className:W,children:"Open goal map"})]}),B=[{id:"hero",title:"Psyche",description:"Top route composition",defaultWidth:12,defaultHeight:1,removable:!1,surfaceChrome:"none",defaultTitleVisible:!1,defaultDescriptionVisible:!1,render:()=>e.jsx(ce,{title:"Psyche",titleText:"Psyche",description:E,actions:q})},{id:"sections",title:"Psyche sections",description:"Section switcher",defaultWidth:12,defaultHeight:1,surfaceChrome:"none",defaultTitleVisible:!1,defaultDescriptionVisible:!1,render:()=>e.jsx(ae,{})},{id:"field",title:"Live field",description:"Graph and inspector stay as movable widgets.",defaultWidth:8,defaultHeight:5,minWidth:6,render:()=>e.jsx(J,{testId:"psyche-hub-graph",compact:!0,title:"Reflective pulse and live entity field",hint:"Select any goal, value, habit, belief, behavior, project, or report.",nodes:p.nodes,edges:p.edges,fields:p.fields,selectedNodeId:b,onSelectNode:k,minHeightClassName:"min-h-[20rem] sm:min-h-[24rem] lg:min-h-[34rem]",legend:[{label:"Goals",kind:"goal"},{label:"Values",kind:"value"},{label:"Habits",kind:"habit"},{label:"Behaviors",kind:"behavior"}],action:e.jsxs(e.Fragment,{children:[e.jsx(y,{to:"/psyche/goal-map",className:W,children:"Open goal map"}),e.jsx(ie,{size:"sm",className:"min-w-0 sm:min-w-[6.5rem]",onClick:()=>c(!0),children:"Reflect"})]})})},{id:"inspector",title:"Inspector",description:"Selected-node inspector widget.",defaultWidth:4,defaultHeight:5,minWidth:4,render:()=>e.jsxs(P,{className:"h-full min-w-0",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:n.entityKind?e.jsx(N,{kind:n.entityKind,compact:!0,gradient:!1,iconOnly:!0}):e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:n.eyebrow})}),e.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:n.entityKind?e.jsx(ne,{kind:n.entityKind,label:n.title,variant:"heading",size:"lg",showKind:!1}):e.jsx("h2",{className:"break-words font-display text-[clamp(1.25rem,2.2vw,1.8rem)] leading-none text-[var(--ui-ink-strong)]",children:n.title})}),e.jsx("p",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)]",children:n.summary}),n.chips.length>0?e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:n.chips.map(a=>e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:a},a))}):null,n.stats.length>0?e.jsx("div",{className:"mt-4 grid gap-2",children:n.stats.map(a=>e.jsx("div",{className:"min-w-0 rounded-[18px] bg-[var(--ui-surface-1)] px-3 py-3 text-sm text-[var(--ui-ink-medium)] break-words",children:a},a))}):null,e.jsx("div",{className:"mt-5",children:e.jsx(y,{to:n.href,className:K("inline-flex min-h-11 w-full items-center justify-center rounded-[var(--radius-control)] px-4 py-2.5 text-sm font-medium whitespace-nowrap shadow-[var(--ui-shadow-soft)]",n.entityKind?oe(n.entityKind,!0):me),children:n.ctaLabel})})]})},...$?[{id:"devrage",title:"Devrage metric",description:"Daily user-message frustration metric.",defaultWidth:4,defaultHeight:3,minWidth:4,render:()=>e.jsx(pe,{metric:r.devrageMetric})}]:[],{id:"actions",title:"Open threads",description:"Action and pulse cards.",defaultWidth:8,defaultHeight:3,render:()=>e.jsxs("div",{className:"grid min-w-0 gap-4 lg:grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)]",children:[e.jsxs(_,{to:"/psyche/behaviors",className:"rounded-[28px] border border-[color-mix(in_srgb,var(--success)_22%,var(--ui-border-subtle)_78%)] bg-[color-mix(in_srgb,var(--ui-success-soft)_44%,var(--ui-surface-1)_56%)] p-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--success)]",children:"Best next reflective move"}),e.jsx("div",{className:"mt-3 break-words font-display text-[clamp(1.45rem,2.2vw,2rem)] leading-none text-[var(--ui-ink-strong)]",children:(v==null?void 0:v.preferredResponse)||"Map the active loop, then name the committed move that brings you back."}),e.jsx("p",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)]",children:(v==null?void 0:v.targetBehavior)||"When the loop is explicit, the return path stops feeling abstract."})]}),e.jsxs(_,{to:R?`/psyche/reports/${R.id}`:"/psyche/reports",className:"rounded-[28px] border border-[color-mix(in_srgb,var(--primary)_22%,var(--ui-border-subtle)_78%)] bg-[color-mix(in_srgb,var(--ui-accent-soft)_46%,var(--ui-surface-1)_54%)] p-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--primary)]",children:"Open threads"}),e.jsxs("div",{className:"mt-3 grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"min-w-0 rounded-[22px] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Insights"}),e.jsx("div",{className:"mt-2 break-words font-display text-4xl text-[var(--ui-ink-strong)]",children:r.openInsights})]}),e.jsxs("div",{className:"min-w-0 rounded-[22px] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Notes"}),e.jsx("div",{className:"mt-2 break-words font-display text-4xl text-[var(--ui-ink-strong)]",children:r.openNotes})]})]})]})]})},{id:"questionnaires",title:"Questionnaire pulse",description:"Recent questionnaire state.",defaultWidth:12,defaultHeight:2,render:()=>{var a;return e.jsxs(_,{to:x!=null&&x.latestRunId?`/psyche/questionnaire-runs/${x.latestRunId}`:"/psyche/questionnaires",className:"rounded-[28px] border border-[color-mix(in_srgb,var(--info)_22%,var(--ui-border-subtle)_78%)] bg-[color-mix(in_srgb,var(--ui-info-soft)_42%,var(--ui-surface-1)_58%)] p-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--info)]",children:"Questionnaire pulse"}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"min-w-0 break-words font-display text-[clamp(1.4rem,2.2vw,2rem)] leading-none text-[var(--ui-ink-strong)]",children:(x==null?void 0:x.title)??"Questionnaire library ready"}),e.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[(((a=i.data)==null?void 0:a.instruments)??[]).length," available"]})]})]})}}];return e.jsxs("div",{className:"grid min-w-0 gap-4 overflow-x-clip",children:[e.jsx(z,{surfaceId:"psyche",baseWidgets:B}),e.jsx(ue,{open:l,onOpenChange:a=>{c(a);const m=new URLSearchParams(o);m.delete("reflect"),d(m,{replace:!0})}})]})}export{Se as PsychePage};
|
|
1
|
+
import{b5 as Q,r as g,j as e,aC as y,c2 as U}from"./vendor-Dnkkx2co.js";import{i as G}from"./state-vCcAT5Hq.js";import{A as z}from"./ai-surface-workspace-BCbQUekv.js";import{b as Z,P as J}from"./psyche-graph-Y1UKALEm.js";import{u as H,Q as X,j as Y,F as ee,b as N,C as P,Z as K,S as te,E as se,a8 as re,ch as ae,B as ie,V as ne,c as I,cj as oe,ad as le,ck as de}from"./index-BP9__l6C.js";import{P as ce}from"./page-hero-DgnhI5es.js";import"./board-dIX6etHh.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./graph-DDUZNRsO.js";const D={intent:"trigger_report",linkedGoalId:"",linkedProjectId:"",linkedTaskId:""};function ue({open:t,onOpenChange:o}){const d=Q(),l=H(),[c,b]=g.useState(D),k=[{id:"intent",eyebrow:"Reflect",title:"What do you want to reflect on?",description:"Choose the entrypoint first. Forge will route you into the right guided flow instead of dropping you into a generic form.",render:(i,r)=>e.jsx(Y,{columns:3,value:i.intent,onChange:s=>r({intent:s}),options:[{value:"trigger_report",label:"A situation",description:"Start a Spark-to-Pivot report about something that happened."},{value:"behavior",label:"A behavior",description:"Trace an away move, committed action, or recovery path."},{value:"belief",label:"A belief script",description:"Capture or refine the belief beneath the reaction."},{value:"pattern",label:"A recurring pattern",description:"Map the loop, payoff, cost, and better response."},{value:"value",label:"A blocked value",description:"Clarify which value is being challenged or needs support."},{value:"execution_tension",label:"A goal tension",description:"Reflect on a goal, project, or task that carries friction."}]})},{id:"placement",eyebrow:"Placement",title:"Attach the reflection to the wider system",description:"This keeps the reflection connected to values, behaviors, and live work instead of becoming an isolated note.",render:(i,r)=>e.jsx("div",{className:"grid gap-4",children:e.jsx(ee,{label:"Goal / project / task tension",children:e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(N,{kind:"goal",label:"Goal",compact:!0,gradient:!1}),e.jsx(N,{kind:"project",label:"Project",compact:!0,gradient:!1}),e.jsx(N,{kind:"task",label:"Task",compact:!0,gradient:!1})]}),e.jsxs("select",{className:"rounded-[18px] border border-white/8 bg-white/6 px-4 py-3 text-sm text-white",value:i.linkedGoalId,onChange:s=>r({linkedGoalId:s.target.value}),children:[e.jsx("option",{value:"",children:"No goal selected"}),l.snapshot.goals.map(s=>e.jsxs("option",{value:s.id,children:["Goal · ",s.title]},s.id))]}),e.jsxs("select",{className:"rounded-[18px] border border-white/8 bg-white/6 px-4 py-3 text-sm text-white",value:i.linkedProjectId,onChange:s=>r({linkedProjectId:s.target.value}),children:[e.jsx("option",{value:"",children:"No project selected"}),l.snapshot.dashboard.projects.map(s=>e.jsxs("option",{value:s.id,children:["Project · ",s.title]},s.id))]}),e.jsxs("select",{className:"rounded-[18px] border border-white/8 bg-white/6 px-4 py-3 text-sm text-white",value:i.linkedTaskId,onChange:s=>r({linkedTaskId:s.target.value}),children:[e.jsx("option",{value:"",children:"No task selected"}),l.snapshot.tasks.slice(0,40).map(s=>e.jsxs("option",{value:s.id,children:["Task · ",s.title]},s.id))]})]})})})}],h=async()=>{const i=new URLSearchParams({create:"1",intent:c.intent});switch(c.linkedGoalId&&i.set("goalId",c.linkedGoalId),c.linkedProjectId&&i.set("projectId",c.linkedProjectId),c.linkedTaskId&&i.set("taskId",c.linkedTaskId),c.intent){case"behavior":d(`/psyche/behaviors?${i.toString()}`);break;case"belief":d(`/psyche/schemas-beliefs?${i.toString()}`);break;case"pattern":d(`/psyche/patterns?${i.toString()}`);break;case"value":d(`/psyche/values?${i.toString()}`);break;case"execution_tension":case"trigger_report":default:d(`/psyche/reports?${i.toString()}`);break}o(!1),b(D)};return e.jsx(X,{open:t,onOpenChange:o,eyebrow:"Reflect",title:"Start from the right reflective doorway",description:"Choose what you want to reflect on first. Forge will take you into the right guided flow instead of leaving you in a generic form.",value:c,onChange:b,draftPersistenceKey:"psyche.reflect.launcher",steps:k,submitLabel:"Open guided reflection",onSubmit:h})}function _({to:t,children:o,className:d}){return e.jsx(y,{to:t,className:"group block transition-transform duration-[var(--motion-medium)] ease-[var(--ease-standard)] hover:-translate-y-0.5 focus-visible:outline-none",children:e.jsx(P,{className:K("transition-[transform,box-shadow,background,border-color] duration-[var(--motion-medium)] ease-[var(--ease-standard)] group-hover:border-[var(--ui-border-strong)] group-hover:bg-[var(--ui-surface-hover)] group-hover:shadow-[var(--card-shadow-hover)] group-focus-visible:shadow-[var(--card-shadow-hover)]",d),children:o})})}function C(t){return`${t.toFixed(t>=10?0:1)}%`}function f(t){return new Intl.NumberFormat().format(Math.round(t))}const W="inline-flex min-h-10 min-w-0 max-w-full items-center justify-center rounded-[var(--radius-control)] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-2 text-sm font-medium whitespace-nowrap text-[var(--ui-ink-medium)] transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",me="bg-[linear-gradient(135deg,color-mix(in_srgb,var(--primary)_34%,var(--ui-surface-2)_66%),color-mix(in_srgb,var(--primary)_18%,var(--ui-surface-1)_82%))] text-[var(--ui-ink-strong)]";function M(t,o){return o==="percent"?C(t):f(t)}function pe({metric:t}){const o=t.history.slice(0,7).reverse(),d=Math.max(1,...o.map(l=>l.rawSwearCount));return e.jsxs(P,{className:"min-w-0 border border-[color-mix(in_srgb,var(--warning)_24%,var(--ui-border-subtle)_76%)] bg-[color-mix(in_srgb,var(--ui-warning-soft)_48%,var(--ui-surface-1)_52%)] p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--warning)]",children:"Devrage metric"}),e.jsxs("div",{className:"mt-2 break-words font-display text-[clamp(1.4rem,2.5vw,2.15rem)] leading-none text-[var(--ui-ink-strong)]",children:[f(t.rawSwearCount)," swears"]})]}),e.jsx(I,{className:"bg-[var(--ui-warning-soft)] text-[var(--warning)]",children:t.latestDateKey??"No history"})]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"min-w-0 rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("div",{className:"text-xs text-[var(--ui-ink-faint)]",children:"Swearing messages"}),e.jsx("div",{className:"mt-1 break-words text-2xl font-semibold text-[var(--ui-ink-strong)]",children:C(t.swearingMessagePercent)})]}),e.jsxs("div",{className:"min-w-0 rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("div",{className:"text-xs text-[var(--ui-ink-faint)]",children:"Daily average"}),e.jsx("div",{className:"mt-1 break-words text-2xl font-semibold text-[var(--ui-ink-strong)]",children:M(t.dailyAverage.rawSwearCount,"count")})]}),e.jsxs("div",{className:"min-w-0 rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("div",{className:"text-xs text-[var(--ui-ink-faint)]",children:"Weekly average"}),e.jsx("div",{className:"mt-1 break-words text-2xl font-semibold text-[var(--ui-ink-strong)]",children:M(t.weeklyAverage.rawSwearCount,"count")})]})]}),e.jsx("div",{className:"mt-4 flex h-16 items-end gap-1.5",children:o.length>0?o.map(l=>e.jsx("div",{className:"min-w-0 flex-1 rounded-t-[6px] bg-[var(--warning)]/50",style:{height:`${Math.max(8,l.rawSwearCount/d*64)}px`},title:`${l.dateKey}: ${f(l.rawSwearCount)} swears, ${C(l.swearingMessagePercent)} swearing messages`},l.dateKey)):e.jsx("div",{className:"self-center text-sm text-[var(--ui-ink-faint)]",children:"History will appear after the first local backfill."})}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2 text-xs text-[var(--ui-ink-soft)]",children:[e.jsxs("span",{children:[f(t.conversationsScanned)," conversations"]}),e.jsxs("span",{children:[f(t.messagesScanned)," messages"]}),e.jsxs("span",{children:[f(t.messagesWithSwears)," flagged"]})]}),e.jsx(y,{to:"/psyche/metrics",className:"mt-4 inline-flex min-h-10 items-center justify-center rounded-[var(--radius-control)] border border-[color-mix(in_srgb,var(--warning)_24%,transparent)] bg-[var(--ui-warning-soft)] px-4 py-2 text-sm font-medium text-[var(--warning)] transition hover:bg-[color-mix(in_srgb,var(--warning)_20%,transparent)]",children:"Open metrics"})]})}function Se(){var A,T;const t=H(),[o,d]=U(),[l,c]=g.useState(o.get("reflect")==="1"),[b,k]=g.useState(null),h=G({queryKey:["forge-psyche-overview"],queryFn:le}),i=G({queryKey:["forge-psyche-questionnaires-hub"],queryFn:()=>de()}),r=(A=h.data)==null?void 0:A.overview,s=g.useMemo(()=>r?t.snapshot.goals.slice(0,3).map(a=>{const m=r.values.filter(u=>u.linkedGoalIds.includes(a.id)),S=t.snapshot.dashboard.projects.filter(u=>u.goalId===a.id),F=t.snapshot.habits.filter(u=>u.linkedGoalIds.includes(a.id)||u.linkedValueIds.some(w=>m.some(j=>j.id===w))),O=r.reports.filter(u=>u.linkedGoalIds.includes(a.id)),L=r.behaviors.filter(u=>u.linkedValueIds.some(w=>m.some(j=>j.id===w))),V=r.beliefs.filter(u=>u.linkedValueIds.some(w=>m.some(j=>j.id===w)));return{goal:a,linkedValues:m,linkedProjects:S,linkedHabits:F,linkedReports:O,linkedBehaviors:L,linkedBeliefs:V}}):[],[r,t.snapshot.dashboard.projects,t.snapshot.goals,t.snapshot.habits]),p=g.useMemo(()=>Z(s,{compact:!0}),[s]);if(g.useEffect(()=>{k(p.defaultSelectedId)},[p.defaultSelectedId]),h.isLoading)return e.jsx(te,{});if(h.isError||!r)return e.jsx(se,{eyebrow:"Psyche",error:h.error,onRetry:()=>void h.refetch()});const n=p.inspectors[b??p.defaultSelectedId]??p.inspectors[p.defaultSelectedId],v=r.patterns[0]??null,R=r.reports[0]??null,x=[...((T=i.data)==null?void 0:T.instruments)??[]].sort((a,m)=>{const S=a.latestRunAt?new Date(a.latestRunAt).getTime():0;return(m.latestRunAt?new Date(m.latestRunAt).getTime():0)-S})[0]??null,E="Values, patterns, behaviors, beliefs, habits, and reports in one live field.",$=r.devrageMetric.hasData||r.devrageMetric.conversationsScanned>0||r.devrageMetric.history.length>0,q=e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e.jsx(re,{metrics:t.snapshot.metrics}),e.jsx(y,{to:"/psyche/goal-map",className:W,children:"Open goal map"})]}),B=[{id:"hero",title:"Psyche",description:"Top route composition",defaultWidth:12,defaultHeight:1,removable:!1,surfaceChrome:"none",defaultTitleVisible:!1,defaultDescriptionVisible:!1,render:()=>e.jsx(ce,{title:"Psyche",titleText:"Psyche",description:E,actions:q})},{id:"sections",title:"Psyche sections",description:"Section switcher",defaultWidth:12,defaultHeight:1,surfaceChrome:"none",defaultTitleVisible:!1,defaultDescriptionVisible:!1,render:()=>e.jsx(ae,{})},{id:"field",title:"Live field",description:"Graph and inspector stay as movable widgets.",defaultWidth:8,defaultHeight:5,minWidth:6,render:()=>e.jsx(J,{testId:"psyche-hub-graph",compact:!0,title:"Reflective pulse and live entity field",hint:"Select any goal, value, habit, belief, behavior, project, or report.",nodes:p.nodes,edges:p.edges,fields:p.fields,selectedNodeId:b,onSelectNode:k,minHeightClassName:"min-h-[20rem] sm:min-h-[24rem] lg:min-h-[34rem]",legend:[{label:"Goals",kind:"goal"},{label:"Values",kind:"value"},{label:"Habits",kind:"habit"},{label:"Behaviors",kind:"behavior"}],action:e.jsxs(e.Fragment,{children:[e.jsx(y,{to:"/psyche/goal-map",className:W,children:"Open goal map"}),e.jsx(ie,{size:"sm",className:"min-w-0 sm:min-w-[6.5rem]",onClick:()=>c(!0),children:"Reflect"})]})})},{id:"inspector",title:"Inspector",description:"Selected-node inspector widget.",defaultWidth:4,defaultHeight:5,minWidth:4,render:()=>e.jsxs(P,{className:"h-full min-w-0",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:n.entityKind?e.jsx(N,{kind:n.entityKind,compact:!0,gradient:!1,iconOnly:!0}):e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:n.eyebrow})}),e.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:n.entityKind?e.jsx(ne,{kind:n.entityKind,label:n.title,variant:"heading",size:"lg",showKind:!1}):e.jsx("h2",{className:"break-words font-display text-[clamp(1.25rem,2.2vw,1.8rem)] leading-none text-[var(--ui-ink-strong)]",children:n.title})}),e.jsx("p",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)]",children:n.summary}),n.chips.length>0?e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:n.chips.map(a=>e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:a},a))}):null,n.stats.length>0?e.jsx("div",{className:"mt-4 grid gap-2",children:n.stats.map(a=>e.jsx("div",{className:"min-w-0 rounded-[18px] bg-[var(--ui-surface-1)] px-3 py-3 text-sm text-[var(--ui-ink-medium)] break-words",children:a},a))}):null,e.jsx("div",{className:"mt-5",children:e.jsx(y,{to:n.href,className:K("inline-flex min-h-11 w-full items-center justify-center rounded-[var(--radius-control)] px-4 py-2.5 text-sm font-medium whitespace-nowrap shadow-[var(--ui-shadow-soft)]",n.entityKind?oe(n.entityKind,!0):me),children:n.ctaLabel})})]})},...$?[{id:"devrage",title:"Devrage metric",description:"Daily user-message frustration metric.",defaultWidth:4,defaultHeight:3,minWidth:4,render:()=>e.jsx(pe,{metric:r.devrageMetric})}]:[],{id:"actions",title:"Open threads",description:"Action and pulse cards.",defaultWidth:8,defaultHeight:3,render:()=>e.jsxs("div",{className:"grid min-w-0 gap-4 lg:grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)]",children:[e.jsxs(_,{to:"/psyche/behaviors",className:"rounded-[28px] border border-[color-mix(in_srgb,var(--success)_22%,var(--ui-border-subtle)_78%)] bg-[color-mix(in_srgb,var(--ui-success-soft)_44%,var(--ui-surface-1)_56%)] p-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--success)]",children:"Best next reflective move"}),e.jsx("div",{className:"mt-3 break-words font-display text-[clamp(1.45rem,2.2vw,2rem)] leading-none text-[var(--ui-ink-strong)]",children:(v==null?void 0:v.preferredResponse)||"Map the active loop, then name the committed move that brings you back."}),e.jsx("p",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)]",children:(v==null?void 0:v.targetBehavior)||"When the loop is explicit, the return path stops feeling abstract."})]}),e.jsxs(_,{to:R?`/psyche/reports/${R.id}`:"/psyche/reports",className:"rounded-[28px] border border-[color-mix(in_srgb,var(--primary)_22%,var(--ui-border-subtle)_78%)] bg-[color-mix(in_srgb,var(--ui-accent-soft)_46%,var(--ui-surface-1)_54%)] p-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--primary)]",children:"Open threads"}),e.jsxs("div",{className:"mt-3 grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"min-w-0 rounded-[22px] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Insights"}),e.jsx("div",{className:"mt-2 break-words font-display text-4xl text-[var(--ui-ink-strong)]",children:r.openInsights})]}),e.jsxs("div",{className:"min-w-0 rounded-[22px] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Notes"}),e.jsx("div",{className:"mt-2 break-words font-display text-4xl text-[var(--ui-ink-strong)]",children:r.openNotes})]})]})]})]})},{id:"questionnaires",title:"Questionnaire pulse",description:"Recent questionnaire state.",defaultWidth:12,defaultHeight:2,render:()=>{var a;return e.jsxs(_,{to:x!=null&&x.latestRunId?`/psyche/questionnaire-runs/${x.latestRunId}`:"/psyche/questionnaires",className:"rounded-[28px] border border-[color-mix(in_srgb,var(--info)_22%,var(--ui-border-subtle)_78%)] bg-[color-mix(in_srgb,var(--ui-info-soft)_42%,var(--ui-surface-1)_58%)] p-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--info)]",children:"Questionnaire pulse"}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"min-w-0 break-words font-display text-[clamp(1.4rem,2.2vw,2rem)] leading-none text-[var(--ui-ink-strong)]",children:(x==null?void 0:x.title)??"Questionnaire library ready"}),e.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[(((a=i.data)==null?void 0:a.instruments)??[]).length," available"]})]})]})}}];return e.jsxs("div",{className:"grid min-w-0 gap-4 overflow-x-clip",children:[e.jsx(z,{surfaceId:"psyche",baseWidgets:B}),e.jsx(ue,{open:l,onOpenChange:a=>{c(a);const m=new URLSearchParams(o);m.delete("reflect"),d(m,{replace:!0})}})]})}export{Se as PsychePage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c2 as ke,r as y,j as t}from"./vendor-Dnkkx2co.js";import{j as je,i as f,k as Ie}from"./state-vCcAT5Hq.js";import{u as Ne,s as Se,i as Ce,cz as Pe,co as Te,cA as ie,bm as Le,bk as O,bl as K,cn as Q,L as Be,E as Ee,B as F,V as ne,ch as Fe,b as q,_ as qe,U as _e,c as Ae,Q as Me,a0 as Oe,a1 as Ke,F as l,I as Qe,T as w,m as _,cp as $e,cq as Re,cB as De,bx as Ue,bw as Ve,cr as ze,bA as We,bz as Ge,by as He}from"./index-
|
|
1
|
+
import{c2 as ke,r as y,j as t}from"./vendor-Dnkkx2co.js";import{j as je,i as f,k as Ie}from"./state-vCcAT5Hq.js";import{u as Ne,s as Se,i as Ce,cz as Pe,co as Te,cA as ie,bm as Le,bk as O,bl as K,cn as Q,L as Be,E as Ee,B as F,V as ne,ch as Fe,b as q,_ as qe,U as _e,c as Ae,Q as Me,a0 as Oe,a1 as Ke,F as l,I as Qe,T as w,m as _,cp as $e,cq as Re,cB as De,bx as Ue,bw as Ve,cr as ze,bA as We,bz as Ge,by as He}from"./index-BP9__l6C.js";import{E as Je}from"./entity-note-count-link-DUxobQUt.js";import{A as oe}from"./atlas-panel-DTnRBOZx.js";import{O as Xe}from"./orbit-map-OV-GcUZl.js";import{S as $}from"./schema-badge-IVJ4SoeC.js";import{u as Ye,p as Ze}from"./use-psyche-focus-target-Ct-acS9G.js";import{P as et}from"./page-hero-DgnhI5es.js";import{p as R}from"./query-cache-IQ8W-LNC.js";import{c as le}from"./psyche-schemas-Dxj554nU.js";import{g as tt,f as de}from"./schema-visuals-CvC9a3i6.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";const k={title:"",description:"",targetBehavior:"",cueContexts:[],shortTermPayoff:"",longTermCost:"",preferredResponse:"",linkedValueIds:[],linkedSchemaLabels:[],linkedModeIds:[],linkedBeliefIds:[],userId:null};function at(i){return{title:i.title,description:i.description,targetBehavior:i.targetBehavior,cueContexts:i.cueContexts,shortTermPayoff:i.shortTermPayoff,longTermCost:i.longTermCost,preferredResponse:i.preferredResponse,linkedValueIds:i.linkedValueIds,linkedSchemaLabels:i.linkedSchemaLabels,linkedModeIds:i.linkedModeIds,linkedBeliefIds:i.linkedBeliefIds,userId:i.userId??null}}function st(i){const n=new Set;return i.filter(d=>{const j=`${d.entityType}:${d.entityId}:${d.anchorKey??""}`;return n.has(j)?!1:(n.add(j),!0)})}function rt(i){const n=i.replace(/\s+/g," ").trim();return n.length<=180?n:`${n.slice(0,177).trimEnd()}...`}function kt(){var X,Y,Z,ee,te,ae;const i=Ne(),n=je(),[d,j]=ke(),[ce,p]=y.useState(!1),[u,v]=y.useState(null),[c,x]=y.useState(null),[I,h]=y.useState(k),[ue,N]=y.useState(null),S=f({queryKey:["forge-psyche-patterns"],queryFn:Ue}),C=f({queryKey:["forge-psyche-values"],queryFn:Ve}),P=f({queryKey:["forge-psyche-schema-catalog"],queryFn:ze}),T=f({queryKey:["forge-psyche-modes"],queryFn:We}),L=f({queryKey:["forge-psyche-beliefs"],queryFn:Ge}),B=f({queryKey:["forge-psyche-behaviors"],queryFn:He}),m=((X=S.data)==null?void 0:X.patterns)??[],D=((Y=C.data)==null?void 0:Y.values)??[],A=((Z=P.data)==null?void 0:Z.schemas)??[],U=((ee=T.data)==null?void 0:ee.modes)??[],V=((te=L.data)==null?void 0:te.beliefs)??[],z=((ae=B.data)==null?void 0:ae.behaviors)??[],g=Se(i.selectedUserIds),W=d.get("focus"),pe=i.snapshot.dashboard.notesSummaryByEntity,b=f({enabled:c!==null,queryKey:["forge-note",c],queryFn:()=>ie(c)});Ye(W),y.useEffect(()=>{if(d.get("create")==="1"){p(!0),v(null),h({...k,userId:d.get("userId")??g}),x(d.get("sourceObservationNoteId"));const e=new URLSearchParams(d);e.delete("create"),e.delete("sourceObservationNoteId"),e.delete("userId"),j(e,{replace:!0})}},[g,d,j]);const G=Ie({mutationFn:async e=>{var o,E;const a=le.parse(e);if(u)return Pe(u.id,a);const s=await Te(a);if(c){const M=((E=(o=b.data)==null?void 0:o.note)==null?void 0:E.id)===c?b.data.note:(await ie(c)).note;await Le(c,{links:st([...M.links,{entityType:"behavior_pattern",entityId:s.pattern.id,anchorKey:null}])})}return s},onSuccess:async()=>{p(!1),v(null),x(null),h({...k,userId:g}),N(null),await Promise.all([n.invalidateQueries({queryKey:["forge-psyche-patterns"]}),n.invalidateQueries({queryKey:["forge-psyche-overview"]}),n.invalidateQueries({queryKey:["forge-psyche-self-observation-calendar"]}),Ce(n),n.invalidateQueries({queryKey:["notes-index"]})])}}),he=D.map(e=>({value:e.id,label:Q(e.title,e.user),description:K(e.valuedDirection,e.user),searchText:O([e.title,e.valuedDirection,e.description],e),kind:"value"})),me=A.map(e=>({value:e.title,label:e.title,description:`${e.description} ${tt(e.family)}`,searchText:`${e.slug} ${e.family} ${e.schemaType}`,badge:t.jsx($,{label:e.title,schemaType:e.schemaType,compact:!0}),menuBadge:t.jsx($,{label:e.title,schemaType:e.schemaType,compact:!0})})),ge=U.map(e=>({value:e.id,label:Q(e.title,e.user),description:K(e.archetype||e.family,e.user),searchText:O([e.title,e.archetype,e.family,e.persona],e),kind:"mode"})),ye=V.map(e=>({value:e.id,label:Q(e.statement,e.user),description:K(e.flexibleAlternative||e.originNote,e.user),searchText:O([e.statement,e.flexibleAlternative,e.originNote,e.beliefType],e),kind:"belief"})),fe=async e=>{const{mode:a}=await Re({family:"coping",archetype:"",title:e,persona:"",imagery:"",symbolicForm:"",facialExpression:"",fear:"",burden:"",protectiveJob:"",originContext:"",firstAppearanceAt:null,linkedPatternIds:[],linkedBehaviorIds:[],linkedValueIds:[],userId:I.userId});return R(n,["forge-psyche-modes"],"modes",a),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:a.id,label:a.title,description:a.archetype||a.family,kind:"mode"}},ve=async e=>{const{value:a}=await $e({title:e,description:"",valuedDirection:e,whyItMatters:"",linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],committedActions:[],userId:I.userId});return R(n,["forge-psyche-values"],"values",a),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:a.id,label:a.title,description:a.valuedDirection,kind:"value"}},xe=async e=>{const{belief:a}=await De({schemaId:null,statement:e,beliefType:"absolute",originNote:"",confidence:60,evidenceFor:[],evidenceAgainst:[],flexibleAlternative:"",linkedValueIds:[],linkedBehaviorIds:[],linkedModeIds:[],linkedReportIds:[],userId:I.userId});return R(n,["forge-psyche-beliefs"],"beliefs",a),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:a.id,label:a.statement,description:a.flexibleAlternative||a.originNote,kind:"belief"}},H=y.useMemo(()=>m.filter(e=>!z.some(a=>a.kind==="away"&&a.linkedPatternIds.includes(e.id))),[m,z]),be=m.slice(0,5).map((e,a)=>({id:e.id,label:`${e.linkedValueIds.length} values`,title:e.title,detail:e.preferredResponse,href:`/psyche/patterns?focus=${e.id}#pattern-lanes`,angle:-92+a*70,radius:150+a%2*14,tone:["rose","sky","violet","mint"][a%4]})),we=[{id:"loop",eyebrow:"Loop",title:"Name the pattern and the behavior it keeps producing",description:"This should feel like a recognizable loop, not a diagnostic label.",render:(e,a)=>{var s;return t.jsxs(t.Fragment,{children:[c?t.jsxs("div",{className:"rounded-[22px] border border-[color-mix(in_srgb,var(--tertiary)_24%,var(--ui-border-subtle)_76%)] bg-[color-mix(in_srgb,var(--tertiary)_10%,var(--ui-surface-1)_90%)] p-4",children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--tertiary)]",children:"Source observation"}),t.jsx("div",{className:"mt-2 break-words text-sm leading-6 text-[var(--ui-ink-medium)] [overflow-wrap:anywhere]",children:b.isLoading?"Loading the saved observation note...":(s=b.data)!=null&&s.note?rt(b.data.note.contentPlain||b.data.note.contentMarkdown):"Forge will link this pattern back to the saved observation when you submit it."})]}):null,t.jsx(Oe,{value:e.userId??null,users:i.snapshot.users,onChange:o=>a({userId:o}),defaultLabel:Ke(i.snapshot.users.find(o=>o.id===g)??null,"Choose pattern owner"),help:"Patterns can belong to a human or bot user even when linked values, modes, or beliefs cross owners."}),t.jsx(l,{label:"Pattern name",description:"Give the loop a name you will recognize quickly later.",children:t.jsx(Qe,{value:e.title,onChange:o=>a({title:o.target.value}),placeholder:"Anxious reassurance loop"})}),t.jsx(l,{label:"What happens in the loop",description:"Describe the actual sequence of behavior, not the diagnosis.",children:t.jsx(w,{value:e.targetBehavior,onChange:o=>a({targetBehavior:o.target.value}),placeholder:"What do you actually do when the trigger hits?"})}),t.jsx(l,{label:"Description",description:"Write the loop in plain language so it stays usable in the future.",children:t.jsx(w,{value:e.description,onChange:o=>a({description:o.target.value}),placeholder:"Describe the loop in plain human language so it stays recognizable later."})})]})}},{id:"dynamics",eyebrow:"Dynamics",title:"Capture cues, payoff, cost, and the desired response",description:"The goal is to make the action map obvious at a glance.",render:(e,a)=>t.jsxs(t.Fragment,{children:[t.jsx(l,{label:"Common cues",description:"Add one cue per line so the trigger pattern stays easy to scan.",children:t.jsx(w,{value:e.cueContexts.join(`
|
|
2
2
|
`),onChange:s=>a({cueContexts:s.target.value.split(`
|
|
3
3
|
`).map(o=>o.trim()).filter(Boolean)}),placeholder:`One line per cue
|
|
4
4
|
Silence after vulnerability
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cc as B,b5 as Q,r as p,j as e,aC as R,cL as A,cM as F,cN as V,cO as z}from"./vendor-Dnkkx2co.js";import{i as $,k as h}from"./state-vCcAT5Hq.js";import{cC as Y,cD as G,cE as H,cF as K,cG as U,L as Z,E as W,B as j,ch as X,C as v,Z as d,a as ee,c as se,cH as ae}from"./index-BhkubYaC.js";import{P as ie}from"./page-hero-DzEsy8i5.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";const re={locale:"en",instructions:"Add questionnaire instructions here.",completionNote:"",presentationMode:"single_question",responseStyle:"four_point_frequency",itemIds:["item_1"],items:[{id:"item_1",prompt:"Sample question",shortLabel:"",description:"",helperText:"",required:!0,visibility:null,tags:[],options:[{key:"0",label:"Not at all",value:0,description:""},{key:"1",label:"Several days",value:1,description:""},{key:"2",label:"More than half the days",value:2,description:""},{key:"3",label:"Nearly every day",value:3,description:""}]}],sections:[{id:"section_1",title:"Section 1",description:"",visibility:null,itemIds:["item_1"]}],pageSize:null},ne={scores:[{key:"total",label:"Total score",description:"",valueType:"number",expression:{kind:"sum",itemIds:["item_1"]},dependsOnItemIds:["item_1"],missingPolicy:{mode:"require_all"},bands:[],roundTo:null,unitLabel:""}]},te={retrievalDate:"2026-04-06",sourceClass:"secondary_verified",scoringNotes:"Describe the scoring method and provenance here.",sources:[{label:"Primary source",url:"https://example.com",citation:"Replace with a real citation.",notes:""}]};function f(s){const n=(s==null?void 0:s.draftVersion)??(s==null?void 0:s.currentVersion);return{title:(s==null?void 0:s.title)??"",subtitle:(s==null?void 0:s.subtitle)??"",description:(s==null?void 0:s.description)??"",aliases:(s==null?void 0:s.aliases.join(", "))??"",symptomDomains:(s==null?void 0:s.symptomDomains.join(", "))??"",tags:(s==null?void 0:s.tags.join(", "))??"",sourceClass:(s==null?void 0:s.sourceClass)??"secondary_verified",availability:(s==null?void 0:s.availability)??"custom",isSelfReport:(s==null?void 0:s.isSelfReport)??!0,label:(n==null?void 0:n.label)??"Draft 1",definitionJson:JSON.stringify((n==null?void 0:n.definition)??re,null,2),scoringJson:JSON.stringify((n==null?void 0:n.scoring)??ne,null,2),provenanceJson:JSON.stringify((n==null?void 0:n.provenance)??te,null,2)}}function y(s){return s.split(",").map(n=>n.trim()).filter(Boolean)}function M(s){return{title:s.title.trim(),subtitle:s.subtitle.trim(),description:s.description.trim(),aliases:y(s.aliases),symptomDomains:y(s.symptomDomains),tags:y(s.tags),sourceClass:s.sourceClass,availability:s.availability,isSelfReport:s.isSelfReport,versionLabel:s.label.trim()||"Draft 1",definition:JSON.parse(s.definitionJson),scoring:JSON.parse(s.scoringJson),provenance:JSON.parse(s.provenanceJson),userId:"user_operator"}}const oe=[{id:"metadata",label:"Metadata",icon:A},{id:"structure",label:"Structure",icon:F},{id:"scoring",label:"Scoring",icon:V},{id:"publish",label:"Publish",icon:z}],o="text-sm font-medium text-[var(--ui-ink-medium)]",c="min-w-0 max-w-full rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3 text-sm text-[var(--ui-ink-strong)] outline-none transition placeholder:text-[var(--ui-ink-faint)] focus:border-[color-mix(in_srgb,var(--primary)_45%,var(--ui-border-strong)_55%)] focus:bg-[var(--ui-surface-2)]",S=d(c,"resize-y whitespace-pre-wrap break-words font-mono leading-6 [overflow-wrap:anywhere]"),g="font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",w="min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",_="mx-1 rounded-[6px] bg-[var(--ui-surface-2)] px-1.5 py-0.5 text-xs text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]";function he(){var D,O;const{instrumentId:s}=B(),n=Q(),[m,T]=p.useState("metadata"),[r,t]=p.useState(()=>f(null)),[N,C]=p.useState(null),u=$({queryKey:["forge-psyche-questionnaire-builder",s],queryFn:()=>ae(s),enabled:!!s}),b=h({mutationFn:async()=>{var i;if(!s)throw new Error("Missing questionnaire id");const a=(i=u.data)==null?void 0:i.instrument;return a!=null&&a.isSystem?Y(s,{userId:"user_operator"}):G(s)},onSuccess:a=>{t(f(a.instrument)),a.instrument.id!==s&&n(`/psyche/questionnaires/${a.instrument.id}/edit`,{replace:!0})}}),k=h({mutationFn:async()=>H(M(r)),onSuccess:a=>{n(`/psyche/questionnaires/${a.instrument.id}/edit`,{replace:!0})}}),J=h({mutationFn:async()=>{if(!s)throw new Error("Missing questionnaire id");const a=M(r);return K(s,{...a,label:a.versionLabel})}}),P=h({mutationFn:async()=>{if(!s)throw new Error("Missing questionnaire id");return U(s,{label:r.label})},onSuccess:a=>{n(`/psyche/questionnaires/${a.instrument.id}`)}}),q=(D=u.data)==null?void 0:D.instrument;p.useEffect(()=>{if(!s){t(f(null));return}const a=q;if(a){if(!a.draftVersion&&!b.isPending){b.mutate();return}t(f(a))}},[s,b.isPending,q]);const I=s?"Edit questionnaire":"Build questionnaire",l=((O=u.data)==null?void 0:O.instrument)??null,E=u.isLoading||b.isPending||k.isPending||J.isPending||P.isPending,x=p.useMemo(()=>{try{return{definition:JSON.parse(r.definitionJson),scoring:JSON.parse(r.scoringJson)}}catch{return null}},[r.definitionJson,r.scoringJson]);if(s&&u.isLoading&&!l)return e.jsx(Z,{eyebrow:"Questionnaire builder",title:"Loading editable draft",description:"Preparing the current questionnaire draft so the builder can open on real versioned data."});if(u.isError)return e.jsx(W,{eyebrow:"Questionnaire builder",error:u.error,onRetry:()=>void u.refetch()});const L=async()=>{try{C(null),s?await J.mutateAsync():await k.mutateAsync()}catch(a){C(a instanceof Error?a.message:"Unable to save questionnaire draft.")}};return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(ie,{eyebrow:"Psyche",title:I,description:"Edit versioned questionnaire metadata, structure, scoring, and publication state directly in the app. Seeded instruments branch into editable drafts before any change is made.",badge:s?(l==null?void 0:l.title)??"Draft":"New draft",actions:s?e.jsx(R,{to:`/psyche/questionnaires/${s}`,children:e.jsx(j,{variant:"secondary",children:"Back to detail"})}):null}),e.jsx(X,{}),e.jsx(v,{className:"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)]",children:e.jsx("div",{className:"grid gap-3 md:grid-cols-4",children:oe.map(a=>e.jsxs("button",{type:"button",className:d("min-w-0 rounded-[8px] border px-4 py-4 text-left transition",m===a.id?"border-[color-mix(in_srgb,var(--success)_42%,var(--ui-border-subtle)_58%)] bg-[var(--ui-success-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-2)]"),onClick:()=>T(a.id),children:[e.jsx(a.icon,{className:"size-4 shrink-0"}),e.jsx("div",{className:"mt-3 min-w-0 break-words text-sm font-medium",children:a.label})]},a.id))})}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.1fr)_minmax(18rem,0.9fr)]",children:[e.jsxs(v,{className:"min-w-0 border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)]",children:[m==="metadata"?e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:o,children:"Title"}),e.jsx("input",{value:r.title,onChange:a=>t(i=>({...i,title:a.target.value})),className:c})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:o,children:"Subtitle"}),e.jsx("input",{value:r.subtitle,onChange:a=>t(i=>({...i,subtitle:a.target.value})),className:c})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:o,children:"Description"}),e.jsx("textarea",{value:r.description,onChange:a=>t(i=>({...i,description:a.target.value})),className:d(c,"min-h-28 resize-y")})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:o,children:"Aliases"}),e.jsx("input",{value:r.aliases,onChange:a=>t(i=>({...i,aliases:a.target.value})),className:c})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:o,children:"Symptom domains"}),e.jsx("input",{value:r.symptomDomains,onChange:a=>t(i=>({...i,symptomDomains:a.target.value})),className:c})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:o,children:"Tags"}),e.jsx("input",{value:r.tags,onChange:a=>t(i=>({...i,tags:a.target.value})),className:c})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:o,children:"Source class"}),e.jsx("select",{value:r.sourceClass,onChange:a=>t(i=>({...i,sourceClass:a.target.value})),className:c,children:["public_domain","free_use","open_access","open_noncommercial","free_clinician","secondary_verified"].map(a=>e.jsx("option",{value:a,children:a.replaceAll("_"," ")},a))})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:o,children:"Availability"}),e.jsx("select",{value:r.availability,onChange:a=>t(i=>({...i,availability:a.target.value})),className:c,children:["open","free_clinician","custom"].map(a=>e.jsx("option",{value:a,children:a.replaceAll("_"," ")},a))})]})]})]}):null,m==="structure"?e.jsxs("div",{className:"grid min-w-0 gap-2",children:[e.jsx("span",{className:o,children:"Definition JSON"}),e.jsxs("div",{className:"min-w-0 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:["Items and sections can declare",e.jsx("code",{className:_,children:"visibility.script"}),"rules such as",e.jsx("code",{className:_,children:"audit_1 > 0"}),"or",e.jsx("code",{className:_,children:'answered(question_12) and option(question_12) == "yes"'}),"."]}),e.jsx("textarea",{value:r.definitionJson,onChange:a=>t(i=>({...i,definitionJson:a.target.value})),className:d(S,"min-h-[32rem]")})]}):null,m==="scoring"?e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:o,children:"Scoring JSON"}),e.jsx("textarea",{value:r.scoringJson,onChange:a=>t(i=>({...i,scoringJson:a.target.value})),className:d(S,"min-h-[24rem]")})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:o,children:"Provenance JSON"}),e.jsx("textarea",{value:r.provenanceJson,onChange:a=>t(i=>({...i,provenanceJson:a.target.value})),className:d(S,"min-h-[16rem]")})]})]}):null,m==="publish"?e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:o,children:"Version label"}),e.jsx("input",{value:r.label,onChange:a=>t(i=>({...i,label:a.target.value})),className:c})]}),x?e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:w,children:[e.jsx("div",{className:g,children:"Items"}),e.jsx("div",{className:"mt-2 text-2xl font-semibold text-[var(--ui-ink-strong)]",children:x.definition.items.length})]}),e.jsxs("div",{className:w,children:[e.jsx("div",{className:g,children:"Sections"}),e.jsx("div",{className:"mt-2 text-2xl font-semibold text-[var(--ui-ink-strong)]",children:x.definition.sections.length})]}),e.jsxs("div",{className:w,children:[e.jsx("div",{className:g,children:"Scores"}),e.jsx("div",{className:"mt-2 text-2xl font-semibold text-[var(--ui-ink-strong)]",children:x.scoring.scores.length})]})]}):null,e.jsx("p",{className:"text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Publishing freezes the current draft into an immutable version for future runs. Past run history will always keep the version it was scored against."})]}):null]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs(v,{className:"min-w-0 border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)]",children:[e.jsx("div",{className:g,children:"Draft posture"}),l!=null&&l.isSystem?e.jsx("div",{className:"mt-4",children:e.jsx(ee,{eyebrow:"System seed",title:"This started as a read-only seed",description:"The builder branched it into a user-owned draft before exposing any editable state."})}):e.jsxs("div",{className:"mt-4 grid gap-2",children:[e.jsx(se,{className:"w-fit border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:l!=null&&l.draftVersion?"Draft available":"New draft"}),e.jsx("div",{className:"break-words text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Save updates whenever the metadata or JSON changes, then publish once the definition is ready for scoring and longitudinal history."})]})]}),e.jsxs(v,{className:"min-w-0 border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)]",children:[e.jsx("div",{className:g,children:"Actions"}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsx(j,{onClick:()=>void L(),disabled:E,children:"Save draft"}),s?e.jsx(j,{variant:"secondary",onClick:()=>P.mutate(),disabled:E||!!N,children:"Publish version"}):null,N?e.jsx("div",{className:"break-words rounded-[8px] border border-[var(--danger)]/20 bg-[var(--ui-danger-soft)] px-4 py-3 text-sm text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",children:N}):null]})]})]})]})]})}export{he as PsycheQuestionnaireBuilderPage};
|
|
1
|
+
import{cc as B,b5 as Q,r as p,j as e,aC as R,cL as A,cM as F,cN as V,cO as z}from"./vendor-Dnkkx2co.js";import{i as $,k as h}from"./state-vCcAT5Hq.js";import{cC as Y,cD as G,cE as H,cF as K,cG as U,L as Z,E as W,B as j,ch as X,C as v,Z as d,a as ee,c as se,cH as ae}from"./index-BP9__l6C.js";import{P as ie}from"./page-hero-DgnhI5es.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";const re={locale:"en",instructions:"Add questionnaire instructions here.",completionNote:"",presentationMode:"single_question",responseStyle:"four_point_frequency",itemIds:["item_1"],items:[{id:"item_1",prompt:"Sample question",shortLabel:"",description:"",helperText:"",required:!0,visibility:null,tags:[],options:[{key:"0",label:"Not at all",value:0,description:""},{key:"1",label:"Several days",value:1,description:""},{key:"2",label:"More than half the days",value:2,description:""},{key:"3",label:"Nearly every day",value:3,description:""}]}],sections:[{id:"section_1",title:"Section 1",description:"",visibility:null,itemIds:["item_1"]}],pageSize:null},ne={scores:[{key:"total",label:"Total score",description:"",valueType:"number",expression:{kind:"sum",itemIds:["item_1"]},dependsOnItemIds:["item_1"],missingPolicy:{mode:"require_all"},bands:[],roundTo:null,unitLabel:""}]},te={retrievalDate:"2026-04-06",sourceClass:"secondary_verified",scoringNotes:"Describe the scoring method and provenance here.",sources:[{label:"Primary source",url:"https://example.com",citation:"Replace with a real citation.",notes:""}]};function f(s){const n=(s==null?void 0:s.draftVersion)??(s==null?void 0:s.currentVersion);return{title:(s==null?void 0:s.title)??"",subtitle:(s==null?void 0:s.subtitle)??"",description:(s==null?void 0:s.description)??"",aliases:(s==null?void 0:s.aliases.join(", "))??"",symptomDomains:(s==null?void 0:s.symptomDomains.join(", "))??"",tags:(s==null?void 0:s.tags.join(", "))??"",sourceClass:(s==null?void 0:s.sourceClass)??"secondary_verified",availability:(s==null?void 0:s.availability)??"custom",isSelfReport:(s==null?void 0:s.isSelfReport)??!0,label:(n==null?void 0:n.label)??"Draft 1",definitionJson:JSON.stringify((n==null?void 0:n.definition)??re,null,2),scoringJson:JSON.stringify((n==null?void 0:n.scoring)??ne,null,2),provenanceJson:JSON.stringify((n==null?void 0:n.provenance)??te,null,2)}}function y(s){return s.split(",").map(n=>n.trim()).filter(Boolean)}function M(s){return{title:s.title.trim(),subtitle:s.subtitle.trim(),description:s.description.trim(),aliases:y(s.aliases),symptomDomains:y(s.symptomDomains),tags:y(s.tags),sourceClass:s.sourceClass,availability:s.availability,isSelfReport:s.isSelfReport,versionLabel:s.label.trim()||"Draft 1",definition:JSON.parse(s.definitionJson),scoring:JSON.parse(s.scoringJson),provenance:JSON.parse(s.provenanceJson),userId:"user_operator"}}const oe=[{id:"metadata",label:"Metadata",icon:A},{id:"structure",label:"Structure",icon:F},{id:"scoring",label:"Scoring",icon:V},{id:"publish",label:"Publish",icon:z}],o="text-sm font-medium text-[var(--ui-ink-medium)]",c="min-w-0 max-w-full rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3 text-sm text-[var(--ui-ink-strong)] outline-none transition placeholder:text-[var(--ui-ink-faint)] focus:border-[color-mix(in_srgb,var(--primary)_45%,var(--ui-border-strong)_55%)] focus:bg-[var(--ui-surface-2)]",S=d(c,"resize-y whitespace-pre-wrap break-words font-mono leading-6 [overflow-wrap:anywhere]"),g="font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",w="min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",_="mx-1 rounded-[6px] bg-[var(--ui-surface-2)] px-1.5 py-0.5 text-xs text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]";function he(){var D,O;const{instrumentId:s}=B(),n=Q(),[m,T]=p.useState("metadata"),[r,t]=p.useState(()=>f(null)),[N,C]=p.useState(null),u=$({queryKey:["forge-psyche-questionnaire-builder",s],queryFn:()=>ae(s),enabled:!!s}),b=h({mutationFn:async()=>{var i;if(!s)throw new Error("Missing questionnaire id");const a=(i=u.data)==null?void 0:i.instrument;return a!=null&&a.isSystem?Y(s,{userId:"user_operator"}):G(s)},onSuccess:a=>{t(f(a.instrument)),a.instrument.id!==s&&n(`/psyche/questionnaires/${a.instrument.id}/edit`,{replace:!0})}}),k=h({mutationFn:async()=>H(M(r)),onSuccess:a=>{n(`/psyche/questionnaires/${a.instrument.id}/edit`,{replace:!0})}}),J=h({mutationFn:async()=>{if(!s)throw new Error("Missing questionnaire id");const a=M(r);return K(s,{...a,label:a.versionLabel})}}),P=h({mutationFn:async()=>{if(!s)throw new Error("Missing questionnaire id");return U(s,{label:r.label})},onSuccess:a=>{n(`/psyche/questionnaires/${a.instrument.id}`)}}),q=(D=u.data)==null?void 0:D.instrument;p.useEffect(()=>{if(!s){t(f(null));return}const a=q;if(a){if(!a.draftVersion&&!b.isPending){b.mutate();return}t(f(a))}},[s,b.isPending,q]);const I=s?"Edit questionnaire":"Build questionnaire",l=((O=u.data)==null?void 0:O.instrument)??null,E=u.isLoading||b.isPending||k.isPending||J.isPending||P.isPending,x=p.useMemo(()=>{try{return{definition:JSON.parse(r.definitionJson),scoring:JSON.parse(r.scoringJson)}}catch{return null}},[r.definitionJson,r.scoringJson]);if(s&&u.isLoading&&!l)return e.jsx(Z,{eyebrow:"Questionnaire builder",title:"Loading editable draft",description:"Preparing the current questionnaire draft so the builder can open on real versioned data."});if(u.isError)return e.jsx(W,{eyebrow:"Questionnaire builder",error:u.error,onRetry:()=>void u.refetch()});const L=async()=>{try{C(null),s?await J.mutateAsync():await k.mutateAsync()}catch(a){C(a instanceof Error?a.message:"Unable to save questionnaire draft.")}};return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(ie,{eyebrow:"Psyche",title:I,description:"Edit versioned questionnaire metadata, structure, scoring, and publication state directly in the app. Seeded instruments branch into editable drafts before any change is made.",badge:s?(l==null?void 0:l.title)??"Draft":"New draft",actions:s?e.jsx(R,{to:`/psyche/questionnaires/${s}`,children:e.jsx(j,{variant:"secondary",children:"Back to detail"})}):null}),e.jsx(X,{}),e.jsx(v,{className:"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)]",children:e.jsx("div",{className:"grid gap-3 md:grid-cols-4",children:oe.map(a=>e.jsxs("button",{type:"button",className:d("min-w-0 rounded-[8px] border px-4 py-4 text-left transition",m===a.id?"border-[color-mix(in_srgb,var(--success)_42%,var(--ui-border-subtle)_58%)] bg-[var(--ui-success-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-2)]"),onClick:()=>T(a.id),children:[e.jsx(a.icon,{className:"size-4 shrink-0"}),e.jsx("div",{className:"mt-3 min-w-0 break-words text-sm font-medium",children:a.label})]},a.id))})}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.1fr)_minmax(18rem,0.9fr)]",children:[e.jsxs(v,{className:"min-w-0 border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)]",children:[m==="metadata"?e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:o,children:"Title"}),e.jsx("input",{value:r.title,onChange:a=>t(i=>({...i,title:a.target.value})),className:c})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:o,children:"Subtitle"}),e.jsx("input",{value:r.subtitle,onChange:a=>t(i=>({...i,subtitle:a.target.value})),className:c})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:o,children:"Description"}),e.jsx("textarea",{value:r.description,onChange:a=>t(i=>({...i,description:a.target.value})),className:d(c,"min-h-28 resize-y")})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:o,children:"Aliases"}),e.jsx("input",{value:r.aliases,onChange:a=>t(i=>({...i,aliases:a.target.value})),className:c})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:o,children:"Symptom domains"}),e.jsx("input",{value:r.symptomDomains,onChange:a=>t(i=>({...i,symptomDomains:a.target.value})),className:c})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:o,children:"Tags"}),e.jsx("input",{value:r.tags,onChange:a=>t(i=>({...i,tags:a.target.value})),className:c})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:o,children:"Source class"}),e.jsx("select",{value:r.sourceClass,onChange:a=>t(i=>({...i,sourceClass:a.target.value})),className:c,children:["public_domain","free_use","open_access","open_noncommercial","free_clinician","secondary_verified"].map(a=>e.jsx("option",{value:a,children:a.replaceAll("_"," ")},a))})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:o,children:"Availability"}),e.jsx("select",{value:r.availability,onChange:a=>t(i=>({...i,availability:a.target.value})),className:c,children:["open","free_clinician","custom"].map(a=>e.jsx("option",{value:a,children:a.replaceAll("_"," ")},a))})]})]})]}):null,m==="structure"?e.jsxs("div",{className:"grid min-w-0 gap-2",children:[e.jsx("span",{className:o,children:"Definition JSON"}),e.jsxs("div",{className:"min-w-0 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:["Items and sections can declare",e.jsx("code",{className:_,children:"visibility.script"}),"rules such as",e.jsx("code",{className:_,children:"audit_1 > 0"}),"or",e.jsx("code",{className:_,children:'answered(question_12) and option(question_12) == "yes"'}),"."]}),e.jsx("textarea",{value:r.definitionJson,onChange:a=>t(i=>({...i,definitionJson:a.target.value})),className:d(S,"min-h-[32rem]")})]}):null,m==="scoring"?e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:o,children:"Scoring JSON"}),e.jsx("textarea",{value:r.scoringJson,onChange:a=>t(i=>({...i,scoringJson:a.target.value})),className:d(S,"min-h-[24rem]")})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:o,children:"Provenance JSON"}),e.jsx("textarea",{value:r.provenanceJson,onChange:a=>t(i=>({...i,provenanceJson:a.target.value})),className:d(S,"min-h-[16rem]")})]})]}):null,m==="publish"?e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:o,children:"Version label"}),e.jsx("input",{value:r.label,onChange:a=>t(i=>({...i,label:a.target.value})),className:c})]}),x?e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:w,children:[e.jsx("div",{className:g,children:"Items"}),e.jsx("div",{className:"mt-2 text-2xl font-semibold text-[var(--ui-ink-strong)]",children:x.definition.items.length})]}),e.jsxs("div",{className:w,children:[e.jsx("div",{className:g,children:"Sections"}),e.jsx("div",{className:"mt-2 text-2xl font-semibold text-[var(--ui-ink-strong)]",children:x.definition.sections.length})]}),e.jsxs("div",{className:w,children:[e.jsx("div",{className:g,children:"Scores"}),e.jsx("div",{className:"mt-2 text-2xl font-semibold text-[var(--ui-ink-strong)]",children:x.scoring.scores.length})]})]}):null,e.jsx("p",{className:"text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Publishing freezes the current draft into an immutable version for future runs. Past run history will always keep the version it was scored against."})]}):null]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs(v,{className:"min-w-0 border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)]",children:[e.jsx("div",{className:g,children:"Draft posture"}),l!=null&&l.isSystem?e.jsx("div",{className:"mt-4",children:e.jsx(ee,{eyebrow:"System seed",title:"This started as a read-only seed",description:"The builder branched it into a user-owned draft before exposing any editable state."})}):e.jsxs("div",{className:"mt-4 grid gap-2",children:[e.jsx(se,{className:"w-fit border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:l!=null&&l.draftVersion?"Draft available":"New draft"}),e.jsx("div",{className:"break-words text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Save updates whenever the metadata or JSON changes, then publish once the definition is ready for scoring and longitudinal history."})]})]}),e.jsxs(v,{className:"min-w-0 border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)]",children:[e.jsx("div",{className:g,children:"Actions"}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsx(j,{onClick:()=>void L(),disabled:E,children:"Save draft"}),s?e.jsx(j,{variant:"secondary",onClick:()=>P.mutate(),disabled:E||!!N,children:"Publish version"}):null,N?e.jsx("div",{className:"break-words rounded-[8px] border border-[var(--danger)]/20 bg-[var(--ui-danger-soft)] px-4 py-3 text-sm text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",children:N}):null]})]})]})]})]})}export{he as PsycheQuestionnaireBuilderPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cc as k,j as e,aC as o,br as L,cL as S,cP as C}from"./vendor-Dnkkx2co.js";import{i as P}from"./state-vCcAT5Hq.js";import{L as $,E as _,B as m,ch as E,C as u,c,a as q,cH as A}from"./index-
|
|
1
|
+
import{cc as k,j as e,aC as o,br as L,cL as S,cP as C}from"./vendor-Dnkkx2co.js";import{i as P}from"./state-vCcAT5Hq.js";import{L as $,E as _,B as m,ch as E,C as u,c,a as q,cH as A}from"./index-BP9__l6C.js";import{P as Q}from"./page-hero-DgnhI5es.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";const x="font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",v="min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",h="text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",p="mt-2 break-words text-sm font-medium text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",j="block min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4 transition hover:bg-[var(--ui-surface-2)]";function D({history:n}){var b,f;const a=[...n].reverse().filter(i=>typeof i.primaryScore=="number");if(a.length===0)return null;const s=a.map(i=>Number(i.primaryScore)),t=Math.min(...s),d=Math.max(...s),l=Math.max(1,d-t),r=a.map((i,w)=>{const y=a.length===1?50:8+w/(a.length-1)*84,N=84-(Number(i.primaryScore)-t)/l*68;return{x:y,y:N,label:new Date(i.completedAt).toLocaleDateString(void 0,{month:"short",day:"numeric"}),score:Number(i.primaryScore)}}),g=r.map(i=>`${i.x},${i.y}`).join(" ");return e.jsxs("div",{className:"mt-4 min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-3",children:[e.jsxs("svg",{viewBox:"0 0 100 100",role:"img","aria-label":"Questionnaire score history",className:"h-56 w-full overflow-visible",preserveAspectRatio:"none",children:[[16,50,84].map(i=>e.jsx("line",{x1:"6",x2:"94",y1:i,y2:i,stroke:"var(--ui-border-subtle)",strokeWidth:"0.6",vectorEffect:"non-scaling-stroke"},i)),e.jsx("polyline",{fill:"none",points:g,stroke:"var(--success)",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2.5",vectorEffect:"non-scaling-stroke"}),r.map(i=>e.jsxs("g",{children:[e.jsx("circle",{cx:i.x,cy:i.y,r:"2.8",fill:"var(--ui-surface-section)",stroke:"var(--success)",strokeWidth:"1.4",vectorEffect:"non-scaling-stroke"}),e.jsx("title",{children:`${i.label}: ${i.score}`})]},`${i.label}-${i.score}-${i.x}`))]}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap justify-between gap-2 text-xs text-[var(--ui-ink-faint)]",children:[e.jsxs("span",{children:["Oldest ",(b=r[0])==null?void 0:b.label]}),e.jsxs("span",{children:["Latest ",(f=r.at(-1))==null?void 0:f.label]})]})]})}function G(){var l;const{instrumentId:n=""}=k(),a=P({queryKey:["forge-psyche-questionnaire",n],queryFn:()=>A(n),enabled:n.length>0});if(a.isLoading)return e.jsx($,{eyebrow:"Questionnaire",title:"Loading questionnaire detail",description:"Hydrating the versioned definition, source provenance, and run history."});if(a.isError||!((l=a.data)!=null&&l.instrument))return e.jsx(_,{eyebrow:"Questionnaire",error:a.error,onRetry:()=>void a.refetch()});const s=a.data.instrument,t=s.currentVersion??s.draftVersion,d=!s.isSystem;return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(Q,{eyebrow:"Psyche",title:s.title,description:s.description,badge:`${s.itemCount} items`,actions:e.jsxs(e.Fragment,{children:[e.jsx(o,{to:`/psyche/questionnaires/${s.id}/take`,children:e.jsxs(m,{children:[e.jsx(L,{className:"mr-2 size-4"}),"Start run"]})}),d?e.jsx(o,{to:`/psyche/questionnaires/${s.id}/edit`,children:e.jsxs(m,{variant:"secondary",children:[e.jsx(S,{className:"mr-2 size-4"}),"Edit draft"]})}):e.jsx(o,{to:`/psyche/questionnaires/${s.id}/edit`,children:e.jsxs(m,{variant:"secondary",children:[e.jsx(C,{className:"mr-2 size-4"}),"Clone to draft"]})})]})}),e.jsx(E,{}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.05fr)_minmax(18rem,0.95fr)]",children:[e.jsxs(u,{className:"min-w-0 border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)]",children:[e.jsx("div",{className:x,children:"Guided definition"}),e.jsxs("div",{className:"mt-4 grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:v,children:[e.jsx("div",{className:h,children:"Flow"}),e.jsx("div",{className:p,children:s.presentationMode.replaceAll("_"," ")})]}),e.jsxs("div",{className:v,children:[e.jsx("div",{className:h,children:"Response style"}),e.jsx("div",{className:p,children:s.responseStyle.replaceAll("_"," ")})]}),e.jsxs("div",{className:v,children:[e.jsx("div",{className:h,children:"Version"}),e.jsx("div",{className:p,children:s.currentVersionNumber?`v${s.currentVersionNumber}`:"Draft"})]})]}),t?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mt-5 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:t.definition.instructions}),e.jsx("div",{className:"mt-5 grid gap-3",children:t.definition.sections.map(r=>e.jsx("div",{className:"min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"break-words text-sm font-medium text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:r.title}),r.description?e.jsx("div",{className:"mt-1 break-words text-sm text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:r.description}):null]}),e.jsxs(c,{className:"shrink-0 border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[r.itemIds.length," items"]})]})},r.id))})]}):null]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs(u,{className:"min-w-0 border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)]",children:[e.jsx("div",{className:x,children:"Provenance"}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(c,{className:"border border-[var(--ui-border-subtle)] bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]",children:s.sourceClass.replaceAll("_"," ")}),e.jsx(c,{className:"border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:s.availability.replaceAll("_"," ")}),s.symptomDomains.map(r=>e.jsx(c,{className:"max-w-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:r},r))]}),t?e.jsx("div",{className:"mt-4 grid gap-3",children:t.provenance.sources.map(r=>e.jsxs("a",{href:r.url,target:"_blank",rel:"noreferrer",className:j,children:[e.jsx("div",{className:"break-words text-sm font-medium text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:r.label}),e.jsx("div",{className:"mt-2 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:r.citation})]},r.url))}):null]}),e.jsxs(u,{className:"min-w-0 border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)]",children:[e.jsx("div",{className:x,children:"History over time"}),s.history.length===0?e.jsx("div",{className:"mt-4",children:e.jsx(q,{eyebrow:"Run history",title:"No completed runs yet",description:"Complete the first guided run and the longitudinal score trace will appear here."})}):e.jsxs(e.Fragment,{children:[e.jsx(D,{history:s.history}),e.jsx("div",{className:"mt-4 grid gap-3",children:s.history.slice(0,5).map(r=>e.jsx(o,{to:`/psyche/questionnaire-runs/${r.runId}`,className:j,children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"break-words text-sm font-medium text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:r.primaryScoreLabel||"Primary score"}),e.jsx("div",{className:"mt-1 break-words text-sm text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:new Date(r.completedAt).toLocaleString()})]}),e.jsxs("div",{className:"shrink-0 text-right",children:[e.jsx("div",{className:"text-lg font-semibold text-[var(--ui-ink-strong)]",children:r.primaryScore??"—"}),r.bandLabel?e.jsx("div",{className:"max-w-[10rem] break-words text-xs uppercase tracking-[0.16em] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)] [overflow-wrap:anywhere]",children:r.bandLabel}):null]})]})},r.runId))})]})]})]})]})]})}export{G as PsycheQuestionnaireDetailPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cc as g,j as e,aC as o}from"./vendor-Dnkkx2co.js";import{i as h}from"./state-vCcAT5Hq.js";import{P as v}from"./page-hero-
|
|
1
|
+
import{cc as g,j as e,aC as o}from"./vendor-Dnkkx2co.js";import{i as h}from"./state-vCcAT5Hq.js";import{P as v}from"./page-hero-DgnhI5es.js";import{L as b,E as w,B as d,C as c,a as f,c as y,Z as j,cI as N}from"./index-BP9__l6C.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";const l="font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",u="min-w-0 overflow-hidden border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)]",m="min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",k="border border-[color-mix(in_srgb,var(--success)_36%,var(--ui-border-subtle)_64%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_70%,var(--ui-ink-strong)_30%)]",C="border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]";function R(){const{runId:t=""}=g(),a=h({queryKey:["forge-psyche-questionnaire-run",t],queryFn:()=>N(t),enabled:t.length>0});if(a.isLoading)return e.jsx(b,{eyebrow:"Questionnaire result",title:"Loading scored run",description:"Hydrating the recorded answers, stored scores, and longitudinal context."});if(a.isError||!a.data)return e.jsx(w,{eyebrow:"Questionnaire result",error:a.error,onRetry:()=>void a.refetch()});const s=a.data,x=new Map(s.answers.map(r=>[r.itemId,r]));return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(v,{eyebrow:"Questionnaire result",title:s.instrument.title,description:"Stored raw answers, computed scores, and score history all remain attached to the exact version used for this run.",badge:s.run.completedAt?"Completed":"Draft",actions:e.jsxs(e.Fragment,{children:[e.jsx(o,{to:`/psyche/questionnaires/${s.instrument.id}`,children:e.jsx(d,{variant:"secondary",children:"Back to questionnaire"})}),e.jsx(o,{to:`/psyche/questionnaires/${s.instrument.id}/take`,children:e.jsx(d,{children:"Take again"})})]})}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,0.9fr)_minmax(18rem,1.1fr)]",children:[e.jsxs(c,{className:u,children:[e.jsx("div",{className:l,children:"Stored scores"}),s.scores.length===0?e.jsx("div",{className:"mt-4",children:e.jsx(f,{eyebrow:"Scores",title:"No scores stored yet",description:"This run has not been completed, so there are no persisted score rows yet."})}):e.jsx("div",{className:"mt-4 grid gap-3",children:s.scores.map(r=>e.jsx("div",{className:m,children:e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"break-words text-sm font-medium text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:r.label}),r.bandLabel?e.jsx("div",{className:"mt-2 break-words text-xs uppercase tracking-[0.16em] text-[color-mix(in_srgb,var(--success)_74%,var(--ui-ink-strong)_26%)] [overflow-wrap:anywhere]",children:r.bandLabel}):null]}),e.jsx("div",{className:"min-w-0 break-words text-right text-lg font-semibold text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:r.valueText??r.valueNumeric??"—"})]})},r.scoreKey))})]}),e.jsxs(c,{className:u,children:[e.jsx("div",{className:l,children:"Answer ledger"}),e.jsx("div",{className:"mt-4 grid gap-3",children:s.version.definition.items.map(r=>{const i=x.get(r.id);return e.jsxs("div",{className:m,children:[e.jsx("div",{className:"break-words text-sm font-medium leading-6 text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:r.prompt}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:r.options.map(n=>{const p=(i==null?void 0:i.optionKey)===n.key;return e.jsx(y,{className:j("max-w-full break-words [overflow-wrap:anywhere]",p?k:C),children:n.label},`${r.id}-${n.key}`)})})]},r.id)})})]})]})]})}export{R as PsycheQuestionnaireRunDetailPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cc as T,b5 as Z,r as S,j as i,aC as H,b7 as G,d5 as X,bk as B,b8 as K}from"./vendor-Dnkkx2co.js";import{k as V}from"./state-vCcAT5Hq.js";import{P as Y}from"./page-hero-DzEsy8i5.js";import{cX as J,cY as W,cZ as D,E as ee,L as ne,B as k,C as te,Z as q,c as ie}from"./index-BhkubYaC.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";const z=new Map;function j(n){return new Error(n)}function re(n){const r=[];let e=0;for(;e<n.length;){const a=n[e];if(/\s/.test(a)){e+=1;continue}const s=n.slice(e,e+2);if(s==="=="||s==="!="||s===">="||s==="<="||s==="&&"||s==="||"){r.push({type:s}),e+=2;continue}if("(),><+-*/!".includes(a)){r.push({type:a}),e+=1;continue}if(a==="'"||a==='"'){const d=a;e+=1;let u="";for(;e<n.length&&n[e]!==d;){const t=n[e];if(t==="\\"&&e+1<n.length){u+=n[e+1],e+=2;continue}u+=t,e+=1}if(n[e]!==d)throw j(`Unterminated string in flow rule: ${n}`);e+=1,r.push({type:"string",value:u});continue}if(/\d/.test(a)){let d=a;for(e+=1;e<n.length&&/[\d.]/.test(n[e]);)d+=n[e],e+=1;r.push({type:"number",value:Number(d)});continue}if(/[A-Za-z_]/.test(a)){let d=a;for(e+=1;e<n.length&&/[A-Za-z0-9_]/.test(n[e]);)d+=n[e],e+=1;const u=d.toLowerCase();u==="and"?r.push({type:"&&"}):u==="or"?r.push({type:"||"}):u==="not"?r.push({type:"!"}):u==="true"?r.push({type:"boolean",value:!0}):u==="false"?r.push({type:"boolean",value:!1}):u==="null"?r.push({type:"null"}):r.push({type:"identifier",value:d});continue}throw j(`Unexpected token '${a}' in flow rule: ${n}`)}return r}function se(n,r){let e=0;function a(){return n[e]}function s(l){const o=n[e];return!o||l&&o.type!==l?null:(e+=1,o)}function d(l){const o=s(l);if(!o)throw j(`Expected '${l}' in flow rule: ${r}`);return o}function u(){const l=a();if(!l)throw j(`Unexpected end of flow rule: ${r}`);if(s("(")){const o=g();return d(")"),o}if(l.type==="number")return s("number"),{kind:"literal",value:l.value};if(l.type==="string")return s("string"),{kind:"literal",value:l.value};if(l.type==="boolean")return s("boolean"),{kind:"literal",value:l.value};if(l.type==="null")return s("null"),{kind:"literal",value:null};if(l.type==="identifier"){const o=s("identifier").value;if(s("(")){const m=[];if(!s(")")){do m.push(g());while(s(","));d(")")}if(o!=="answered"&&o!=="option"&&o!=="label"&&o!=="value")throw j(`Unknown flow function '${o}' in rule: ${r}`);return{kind:"call",name:o,args:m}}return{kind:"reference",itemId:o}}throw j(`Unexpected token '${l.type}' in flow rule: ${r}`)}function t(){return s("!")?{kind:"unary",operator:"!",operand:t()}:s("-")?{kind:"unary",operator:"-",operand:t()}:u()}function v(){let l=t();for(;;){if(s("*")){l={kind:"binary",operator:"*",left:l,right:t()};continue}if(s("/")){l={kind:"binary",operator:"/",left:l,right:t()};continue}return l}}function y(){let l=v();for(;;){if(s("+")){l={kind:"binary",operator:"+",left:l,right:v()};continue}if(s("-")){l={kind:"binary",operator:"-",left:l,right:v()};continue}return l}}function b(){let l=y();for(;;){const o=a(),m=o&&(o.type==="=="||o.type==="!="||o.type===">="||o.type==="<="||o.type===">"||o.type==="<")?o.type:null;if(!m)return l;e+=1,l={kind:"binary",operator:m,left:l,right:y()}}}function p(){let l=b();for(;s("&&");)l={kind:"binary",operator:"&&",left:l,right:b()};return l}function g(){let l=p();for(;s("||");)l={kind:"binary",operator:"||",left:l,right:p()};return l}const N=g();if(e<n.length)throw j(`Unexpected trailing tokens in flow rule: ${r}`);return N}function ae(n){const r=z.get(n);if(r)return r;const e=se(re(n),n);return z.set(n,e),e}function le(n){return n.kind==="reference"?n.itemId:n.kind==="literal"&&typeof n.value=="string"&&n.value.trim().length>0?n.value.trim():null}function M(n){return typeof n=="boolean"?n:typeof n=="number"?n!==0:typeof n=="string"?n.length>0:!1}function h(n){if(typeof n=="number"&&Number.isFinite(n))return n;if(typeof n=="boolean")return n?1:0;if(typeof n=="string"){const r=Number(n);return Number.isFinite(r)?r:null}return null}function oe(n,r,e){const a=h(n),s=h(e);if(a!==null&&s!==null)switch(r){case"==":return a===s;case"!=":return a!==s;case">":return a>s;case">=":return a>=s;case"<":return a<s;case"<=":return a<=s}return r==="=="||r==="!="?r==="=="?n===e:n!==e:!1}function P(n,r){switch(n.kind){case"literal":return n.value;case"reference":return r.getAnswerValue(n.itemId);case"unary":{const e=P(n.operand,r);if(n.operator==="!")return!M(e);const a=h(e);return a===null?null:-a}case"binary":{const e=P(n.left,r),a=P(n.right,r);switch(n.operator){case"&&":return M(e)&&M(a);case"||":return M(e)||M(a);case"+":return e===null||a===null?null:(h(e)??0)+(h(a)??0);case"-":return e===null||a===null?null:(h(e)??0)-(h(a)??0);case"*":return e===null||a===null?null:(h(e)??0)*(h(a)??0);case"/":{const s=h(a);return e===null||s===null||s===0?null:(h(e)??0)/s}default:return oe(e,n.operator,a)}}case"call":{const e=n.args[0]?le(n.args[0]):null;if(!e)return null;switch(n.name){case"answered":return r.isAnswered(e);case"option":return r.getOptionKey(e);case"label":return r.getLabel(e);case"value":return r.getAnswerValue(e)}}}}function ue(n){return new Map(n.map(r=>[r.itemId,{optionKey:r.optionKey??null,numericValue:r.numericValue??null,valueText:r.valueText??null}]))}function F(n,r,e){const a=ae(n),s=ue(r),d=P(a,{getAnswerValue:u=>{if(!e.has(u))return null;const t=s.get(u);return(t==null?void 0:t.numericValue)??(t==null?void 0:t.optionKey)??(t==null?void 0:t.valueText)??null},getOptionKey:u=>{var t;return e.has(u)?((t=s.get(u))==null?void 0:t.optionKey)??null:null},getLabel:u=>{var t;return e.has(u)?((t=s.get(u))==null?void 0:t.valueText)??null:null},isAnswered:u=>{if(!e.has(u))return!1;const t=s.get(u);return!!(t&&(t.optionKey!==null||t.numericValue!==null||(t.valueText??"").trim().length>0))}});return M(d)}function ce(n,r){const e=new Set,a=new Set,s=new Map(n.items.map(u=>[u.id,u])),d=new Map;for(const u of n.sections){if(!(!u.visibility||F(u.visibility.script,r,e)))continue;const v=u.itemIds.filter(y=>{const b=s.get(y);if(!b)return!1;const p=!b.visibility||F(b.visibility.script,r,e);return p&&e.add(b.id),p});v.length>0&&(a.add(u.id),d.set(u.id,v))}return{visibleItemIds:e,visibleSectionIds:a,visibleItemIdsBySection:d}}const O="font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",de="min-w-0 rounded-[8px] border px-5 py-5 text-left transition",fe="min-w-0 rounded-[8px] border px-3 py-3 text-sm transition",_="border-[color-mix(in_srgb,var(--success)_42%,var(--ui-border-subtle)_58%)] bg-[var(--ui-success-soft)] text-[var(--ui-ink-strong)]",L="border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-2)]";function me(n,r){const e=n.options.find(a=>a.key===r);return e?{itemId:n.id,optionKey:e.key,valueText:e.label,numericValue:e.value,answer:{label:e.label,value:e.value}}:null}function je(){const{instrumentId:n=""}=T(),r=Z(),[e,a]=S.useState(null),s=V({mutationFn:()=>J(n,{userId:"user_operator"}),onSuccess:c=>a(c)}),d=V({mutationFn:c=>W(e.run.id,c),onSuccess:c=>a(c)}),u=V({mutationFn:()=>D(e.run.id),onSuccess:c=>{a(c),r(`/psyche/questionnaire-runs/${c.run.id}`)}});S.useEffect(()=>{n&&s.mutate()},[n]);const t=e,v=S.useMemo(()=>new Map(((t==null?void 0:t.answers)??[]).map(c=>[c.itemId,c.optionKey??""])),[t]),y=(t==null?void 0:t.version.definition.sections)??[],b=(t==null?void 0:t.version.definition.items)??[],p=S.useMemo(()=>t?ce(t.version.definition,t.answers):{visibleItemIds:new Set,visibleSectionIds:new Set,visibleItemIdsBySection:new Map},[t]),g=S.useMemo(()=>b.filter(c=>p.visibleItemIds.has(c.id)),[b,p]),N=S.useMemo(()=>y.filter(c=>p.visibleSectionIds.has(c.id)).map(c=>({...c,itemIds:p.visibleItemIdsBySection.get(c.id)??[]})),[y,p]),l=(t==null?void 0:t.version.definition.presentationMode)==="single_question"?g.length:N.length,o=l>0?Math.min((t==null?void 0:t.run.progressIndex)??0,l-1):0,m=N[o]??null,I=(t==null?void 0:t.version.definition.presentationMode)==="single_question"?g[o]??null:null,$=g.every(c=>!c.required||v.has(c.id)),A=async c=>{t&&(a(f=>f&&{...f,run:{...f.run,progressIndex:c}}),await d.mutateAsync({answers:[],progressIndex:c}))},E=async(c,f,x)=>{const w=me(c,f);!w||!t||(a(C=>{if(!C)return C;const Q=C.answers.filter(U=>U.itemId!==c.id);return{...C,run:{...C.run,progressIndex:x},answers:[...Q,{...w,optionKey:w.optionKey??null,numericValue:w.numericValue??null,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}]}}),await d.mutateAsync({answers:[w],progressIndex:x}))};if(s.isError)return i.jsx(ee,{eyebrow:"Questionnaire run",error:s.error,onRetry:()=>s.mutate()});if(s.isPending||!t)return i.jsx(ne,{eyebrow:"Questionnaire run",title:"Preparing guided run",description:"Opening the current questionnaire version, loading any draft answers, and restoring your place."});const R=l>0?(o+1)/l*100:0;return i.jsxs("div",{className:"grid gap-5",children:[i.jsx(Y,{eyebrow:"Guided questionnaire",title:t.instrument.title,description:t.version.definition.instructions,badge:`v${t.version.versionNumber}`,actions:i.jsx(H,{to:`/psyche/questionnaires/${t.instrument.id}`,children:i.jsx(k,{variant:"secondary",children:"Back to detail"})})}),i.jsxs(te,{className:"min-w-0 overflow-hidden border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)] p-0",children:[i.jsxs("div",{className:"border-b border-[var(--ui-border-subtle)] px-5 py-4",children:[i.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("div",{className:O,children:"Progress"}),i.jsxs("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:["Step ",o+1," of ",l]})]}),i.jsx("div",{className:"flex items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:d.isPending?i.jsxs(i.Fragment,{children:[i.jsx(G,{className:"size-4 animate-spin"}),"Autosaving"]}):i.jsxs(i.Fragment,{children:[i.jsx(X,{className:"size-4 text-[var(--tertiary)]"}),"Saved"]})})]}),i.jsx("div",{className:"mt-3 h-1.5 rounded-full bg-[var(--ui-surface-2)]",children:i.jsx("div",{className:"h-full rounded-full bg-[linear-gradient(90deg,var(--success),var(--info))] transition-[width] duration-300",style:{width:`${R}%`}})})]}),t.version.definition.presentationMode==="single_question"&&I?i.jsx("div",{className:"px-5 py-6 sm:px-6",children:i.jsxs("div",{className:"mx-auto grid max-w-3xl gap-6",children:[i.jsx("div",{className:"min-w-0 break-words font-display text-[clamp(1.7rem,3vw,2.4rem)] leading-tight text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:I.prompt}),i.jsx("div",{className:"grid gap-3",children:I.options.map(c=>{const f=v.get(I.id)===c.key;return i.jsxs("button",{type:"button",className:q(de,f?_:L),onClick:()=>void E(I,c.key,o),children:[i.jsx("div",{className:"break-words text-base font-medium [overflow-wrap:anywhere]",children:c.label}),c.description?i.jsx("div",{className:"mt-2 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:c.description}):null]},c.key)})}),i.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[i.jsxs(k,{variant:"secondary",disabled:o===0,onClick:()=>void A(Math.max(0,o-1)),children:[i.jsx(B,{className:"mr-2 size-4"}),"Previous"]}),o<g.length-1?i.jsxs(k,{onClick:()=>void A(Math.min(g.length-1,o+1)),children:["Next",i.jsx(K,{className:"ml-2 size-4"})]}):i.jsx(k,{disabled:!$||u.isPending,onClick:()=>u.mutate(),children:"Finish and score"})]})]})}):m?i.jsx("div",{className:"px-5 py-6 sm:px-6",children:i.jsxs("div",{className:"mx-auto max-w-5xl",children:[i.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("div",{className:O,children:m.title}),m.description?i.jsx("div",{className:"mt-2 break-words text-sm text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:m.description}):null]}),i.jsxs(ie,{className:"shrink-0 border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[m.itemIds.length," items"]})]}),i.jsx("div",{className:"mt-6 grid gap-4",children:m.itemIds.map(c=>{const f=g.find(x=>x.id===c);return f?i.jsxs("div",{className:"min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[i.jsx("div",{className:"break-words text-sm leading-6 text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:f.prompt}),i.jsx("div",{className:"mt-4 grid gap-2 md:grid-cols-3 xl:grid-cols-6",children:f.options.map(x=>{const w=v.get(f.id)===x.key;return i.jsx("button",{type:"button",className:q(fe,w?_:L),onClick:()=>void E(f,x.key,o),children:i.jsx("span",{className:"break-words [overflow-wrap:anywhere]",children:x.label})},x.key)})})]},f.id):null})}),i.jsxs("div",{className:"mt-6 flex flex-wrap items-center justify-between gap-3",children:[i.jsxs(k,{variant:"secondary",disabled:o===0,onClick:()=>void A(Math.max(0,o-1)),children:[i.jsx(B,{className:"mr-2 size-4"}),"Previous section"]}),o<N.length-1?i.jsxs(k,{onClick:()=>void A(Math.min(N.length-1,o+1)),children:["Next section",i.jsx(K,{className:"ml-2 size-4"})]}):i.jsx(k,{disabled:!$||u.isPending,onClick:()=>u.mutate(),children:"Finish and score"})]})]})}):null]})]})}export{je as PsycheQuestionnaireRunPage};
|
|
1
|
+
import{cc as T,b5 as Z,r as S,j as i,aC as H,b7 as G,d5 as X,bk as B,b8 as K}from"./vendor-Dnkkx2co.js";import{k as V}from"./state-vCcAT5Hq.js";import{P as Y}from"./page-hero-DgnhI5es.js";import{cX as J,cY as W,cZ as D,E as ee,L as ne,B as k,C as te,Z as q,c as ie}from"./index-BP9__l6C.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";const z=new Map;function j(n){return new Error(n)}function re(n){const r=[];let e=0;for(;e<n.length;){const a=n[e];if(/\s/.test(a)){e+=1;continue}const s=n.slice(e,e+2);if(s==="=="||s==="!="||s===">="||s==="<="||s==="&&"||s==="||"){r.push({type:s}),e+=2;continue}if("(),><+-*/!".includes(a)){r.push({type:a}),e+=1;continue}if(a==="'"||a==='"'){const d=a;e+=1;let u="";for(;e<n.length&&n[e]!==d;){const t=n[e];if(t==="\\"&&e+1<n.length){u+=n[e+1],e+=2;continue}u+=t,e+=1}if(n[e]!==d)throw j(`Unterminated string in flow rule: ${n}`);e+=1,r.push({type:"string",value:u});continue}if(/\d/.test(a)){let d=a;for(e+=1;e<n.length&&/[\d.]/.test(n[e]);)d+=n[e],e+=1;r.push({type:"number",value:Number(d)});continue}if(/[A-Za-z_]/.test(a)){let d=a;for(e+=1;e<n.length&&/[A-Za-z0-9_]/.test(n[e]);)d+=n[e],e+=1;const u=d.toLowerCase();u==="and"?r.push({type:"&&"}):u==="or"?r.push({type:"||"}):u==="not"?r.push({type:"!"}):u==="true"?r.push({type:"boolean",value:!0}):u==="false"?r.push({type:"boolean",value:!1}):u==="null"?r.push({type:"null"}):r.push({type:"identifier",value:d});continue}throw j(`Unexpected token '${a}' in flow rule: ${n}`)}return r}function se(n,r){let e=0;function a(){return n[e]}function s(l){const o=n[e];return!o||l&&o.type!==l?null:(e+=1,o)}function d(l){const o=s(l);if(!o)throw j(`Expected '${l}' in flow rule: ${r}`);return o}function u(){const l=a();if(!l)throw j(`Unexpected end of flow rule: ${r}`);if(s("(")){const o=g();return d(")"),o}if(l.type==="number")return s("number"),{kind:"literal",value:l.value};if(l.type==="string")return s("string"),{kind:"literal",value:l.value};if(l.type==="boolean")return s("boolean"),{kind:"literal",value:l.value};if(l.type==="null")return s("null"),{kind:"literal",value:null};if(l.type==="identifier"){const o=s("identifier").value;if(s("(")){const m=[];if(!s(")")){do m.push(g());while(s(","));d(")")}if(o!=="answered"&&o!=="option"&&o!=="label"&&o!=="value")throw j(`Unknown flow function '${o}' in rule: ${r}`);return{kind:"call",name:o,args:m}}return{kind:"reference",itemId:o}}throw j(`Unexpected token '${l.type}' in flow rule: ${r}`)}function t(){return s("!")?{kind:"unary",operator:"!",operand:t()}:s("-")?{kind:"unary",operator:"-",operand:t()}:u()}function v(){let l=t();for(;;){if(s("*")){l={kind:"binary",operator:"*",left:l,right:t()};continue}if(s("/")){l={kind:"binary",operator:"/",left:l,right:t()};continue}return l}}function y(){let l=v();for(;;){if(s("+")){l={kind:"binary",operator:"+",left:l,right:v()};continue}if(s("-")){l={kind:"binary",operator:"-",left:l,right:v()};continue}return l}}function b(){let l=y();for(;;){const o=a(),m=o&&(o.type==="=="||o.type==="!="||o.type===">="||o.type==="<="||o.type===">"||o.type==="<")?o.type:null;if(!m)return l;e+=1,l={kind:"binary",operator:m,left:l,right:y()}}}function p(){let l=b();for(;s("&&");)l={kind:"binary",operator:"&&",left:l,right:b()};return l}function g(){let l=p();for(;s("||");)l={kind:"binary",operator:"||",left:l,right:p()};return l}const N=g();if(e<n.length)throw j(`Unexpected trailing tokens in flow rule: ${r}`);return N}function ae(n){const r=z.get(n);if(r)return r;const e=se(re(n),n);return z.set(n,e),e}function le(n){return n.kind==="reference"?n.itemId:n.kind==="literal"&&typeof n.value=="string"&&n.value.trim().length>0?n.value.trim():null}function M(n){return typeof n=="boolean"?n:typeof n=="number"?n!==0:typeof n=="string"?n.length>0:!1}function h(n){if(typeof n=="number"&&Number.isFinite(n))return n;if(typeof n=="boolean")return n?1:0;if(typeof n=="string"){const r=Number(n);return Number.isFinite(r)?r:null}return null}function oe(n,r,e){const a=h(n),s=h(e);if(a!==null&&s!==null)switch(r){case"==":return a===s;case"!=":return a!==s;case">":return a>s;case">=":return a>=s;case"<":return a<s;case"<=":return a<=s}return r==="=="||r==="!="?r==="=="?n===e:n!==e:!1}function P(n,r){switch(n.kind){case"literal":return n.value;case"reference":return r.getAnswerValue(n.itemId);case"unary":{const e=P(n.operand,r);if(n.operator==="!")return!M(e);const a=h(e);return a===null?null:-a}case"binary":{const e=P(n.left,r),a=P(n.right,r);switch(n.operator){case"&&":return M(e)&&M(a);case"||":return M(e)||M(a);case"+":return e===null||a===null?null:(h(e)??0)+(h(a)??0);case"-":return e===null||a===null?null:(h(e)??0)-(h(a)??0);case"*":return e===null||a===null?null:(h(e)??0)*(h(a)??0);case"/":{const s=h(a);return e===null||s===null||s===0?null:(h(e)??0)/s}default:return oe(e,n.operator,a)}}case"call":{const e=n.args[0]?le(n.args[0]):null;if(!e)return null;switch(n.name){case"answered":return r.isAnswered(e);case"option":return r.getOptionKey(e);case"label":return r.getLabel(e);case"value":return r.getAnswerValue(e)}}}}function ue(n){return new Map(n.map(r=>[r.itemId,{optionKey:r.optionKey??null,numericValue:r.numericValue??null,valueText:r.valueText??null}]))}function F(n,r,e){const a=ae(n),s=ue(r),d=P(a,{getAnswerValue:u=>{if(!e.has(u))return null;const t=s.get(u);return(t==null?void 0:t.numericValue)??(t==null?void 0:t.optionKey)??(t==null?void 0:t.valueText)??null},getOptionKey:u=>{var t;return e.has(u)?((t=s.get(u))==null?void 0:t.optionKey)??null:null},getLabel:u=>{var t;return e.has(u)?((t=s.get(u))==null?void 0:t.valueText)??null:null},isAnswered:u=>{if(!e.has(u))return!1;const t=s.get(u);return!!(t&&(t.optionKey!==null||t.numericValue!==null||(t.valueText??"").trim().length>0))}});return M(d)}function ce(n,r){const e=new Set,a=new Set,s=new Map(n.items.map(u=>[u.id,u])),d=new Map;for(const u of n.sections){if(!(!u.visibility||F(u.visibility.script,r,e)))continue;const v=u.itemIds.filter(y=>{const b=s.get(y);if(!b)return!1;const p=!b.visibility||F(b.visibility.script,r,e);return p&&e.add(b.id),p});v.length>0&&(a.add(u.id),d.set(u.id,v))}return{visibleItemIds:e,visibleSectionIds:a,visibleItemIdsBySection:d}}const O="font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",de="min-w-0 rounded-[8px] border px-5 py-5 text-left transition",fe="min-w-0 rounded-[8px] border px-3 py-3 text-sm transition",_="border-[color-mix(in_srgb,var(--success)_42%,var(--ui-border-subtle)_58%)] bg-[var(--ui-success-soft)] text-[var(--ui-ink-strong)]",L="border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-2)]";function me(n,r){const e=n.options.find(a=>a.key===r);return e?{itemId:n.id,optionKey:e.key,valueText:e.label,numericValue:e.value,answer:{label:e.label,value:e.value}}:null}function je(){const{instrumentId:n=""}=T(),r=Z(),[e,a]=S.useState(null),s=V({mutationFn:()=>J(n,{userId:"user_operator"}),onSuccess:c=>a(c)}),d=V({mutationFn:c=>W(e.run.id,c),onSuccess:c=>a(c)}),u=V({mutationFn:()=>D(e.run.id),onSuccess:c=>{a(c),r(`/psyche/questionnaire-runs/${c.run.id}`)}});S.useEffect(()=>{n&&s.mutate()},[n]);const t=e,v=S.useMemo(()=>new Map(((t==null?void 0:t.answers)??[]).map(c=>[c.itemId,c.optionKey??""])),[t]),y=(t==null?void 0:t.version.definition.sections)??[],b=(t==null?void 0:t.version.definition.items)??[],p=S.useMemo(()=>t?ce(t.version.definition,t.answers):{visibleItemIds:new Set,visibleSectionIds:new Set,visibleItemIdsBySection:new Map},[t]),g=S.useMemo(()=>b.filter(c=>p.visibleItemIds.has(c.id)),[b,p]),N=S.useMemo(()=>y.filter(c=>p.visibleSectionIds.has(c.id)).map(c=>({...c,itemIds:p.visibleItemIdsBySection.get(c.id)??[]})),[y,p]),l=(t==null?void 0:t.version.definition.presentationMode)==="single_question"?g.length:N.length,o=l>0?Math.min((t==null?void 0:t.run.progressIndex)??0,l-1):0,m=N[o]??null,I=(t==null?void 0:t.version.definition.presentationMode)==="single_question"?g[o]??null:null,$=g.every(c=>!c.required||v.has(c.id)),A=async c=>{t&&(a(f=>f&&{...f,run:{...f.run,progressIndex:c}}),await d.mutateAsync({answers:[],progressIndex:c}))},E=async(c,f,x)=>{const w=me(c,f);!w||!t||(a(C=>{if(!C)return C;const Q=C.answers.filter(U=>U.itemId!==c.id);return{...C,run:{...C.run,progressIndex:x},answers:[...Q,{...w,optionKey:w.optionKey??null,numericValue:w.numericValue??null,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}]}}),await d.mutateAsync({answers:[w],progressIndex:x}))};if(s.isError)return i.jsx(ee,{eyebrow:"Questionnaire run",error:s.error,onRetry:()=>s.mutate()});if(s.isPending||!t)return i.jsx(ne,{eyebrow:"Questionnaire run",title:"Preparing guided run",description:"Opening the current questionnaire version, loading any draft answers, and restoring your place."});const R=l>0?(o+1)/l*100:0;return i.jsxs("div",{className:"grid gap-5",children:[i.jsx(Y,{eyebrow:"Guided questionnaire",title:t.instrument.title,description:t.version.definition.instructions,badge:`v${t.version.versionNumber}`,actions:i.jsx(H,{to:`/psyche/questionnaires/${t.instrument.id}`,children:i.jsx(k,{variant:"secondary",children:"Back to detail"})})}),i.jsxs(te,{className:"min-w-0 overflow-hidden border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)] p-0",children:[i.jsxs("div",{className:"border-b border-[var(--ui-border-subtle)] px-5 py-4",children:[i.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("div",{className:O,children:"Progress"}),i.jsxs("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:["Step ",o+1," of ",l]})]}),i.jsx("div",{className:"flex items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:d.isPending?i.jsxs(i.Fragment,{children:[i.jsx(G,{className:"size-4 animate-spin"}),"Autosaving"]}):i.jsxs(i.Fragment,{children:[i.jsx(X,{className:"size-4 text-[var(--tertiary)]"}),"Saved"]})})]}),i.jsx("div",{className:"mt-3 h-1.5 rounded-full bg-[var(--ui-surface-2)]",children:i.jsx("div",{className:"h-full rounded-full bg-[linear-gradient(90deg,var(--success),var(--info))] transition-[width] duration-300",style:{width:`${R}%`}})})]}),t.version.definition.presentationMode==="single_question"&&I?i.jsx("div",{className:"px-5 py-6 sm:px-6",children:i.jsxs("div",{className:"mx-auto grid max-w-3xl gap-6",children:[i.jsx("div",{className:"min-w-0 break-words font-display text-[clamp(1.7rem,3vw,2.4rem)] leading-tight text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:I.prompt}),i.jsx("div",{className:"grid gap-3",children:I.options.map(c=>{const f=v.get(I.id)===c.key;return i.jsxs("button",{type:"button",className:q(de,f?_:L),onClick:()=>void E(I,c.key,o),children:[i.jsx("div",{className:"break-words text-base font-medium [overflow-wrap:anywhere]",children:c.label}),c.description?i.jsx("div",{className:"mt-2 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:c.description}):null]},c.key)})}),i.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[i.jsxs(k,{variant:"secondary",disabled:o===0,onClick:()=>void A(Math.max(0,o-1)),children:[i.jsx(B,{className:"mr-2 size-4"}),"Previous"]}),o<g.length-1?i.jsxs(k,{onClick:()=>void A(Math.min(g.length-1,o+1)),children:["Next",i.jsx(K,{className:"ml-2 size-4"})]}):i.jsx(k,{disabled:!$||u.isPending,onClick:()=>u.mutate(),children:"Finish and score"})]})]})}):m?i.jsx("div",{className:"px-5 py-6 sm:px-6",children:i.jsxs("div",{className:"mx-auto max-w-5xl",children:[i.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("div",{className:O,children:m.title}),m.description?i.jsx("div",{className:"mt-2 break-words text-sm text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:m.description}):null]}),i.jsxs(ie,{className:"shrink-0 border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[m.itemIds.length," items"]})]}),i.jsx("div",{className:"mt-6 grid gap-4",children:m.itemIds.map(c=>{const f=g.find(x=>x.id===c);return f?i.jsxs("div",{className:"min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[i.jsx("div",{className:"break-words text-sm leading-6 text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:f.prompt}),i.jsx("div",{className:"mt-4 grid gap-2 md:grid-cols-3 xl:grid-cols-6",children:f.options.map(x=>{const w=v.get(f.id)===x.key;return i.jsx("button",{type:"button",className:q(fe,w?_:L),onClick:()=>void E(f,x.key,o),children:i.jsx("span",{className:"break-words [overflow-wrap:anywhere]",children:x.label})},x.key)})})]},f.id):null})}),i.jsxs("div",{className:"mt-6 flex flex-wrap items-center justify-between gap-3",children:[i.jsxs(k,{variant:"secondary",disabled:o===0,onClick:()=>void A(Math.max(0,o-1)),children:[i.jsx(B,{className:"mr-2 size-4"}),"Previous section"]}),o<N.length-1?i.jsxs(k,{onClick:()=>void A(Math.min(N.length-1,o+1)),children:["Next section",i.jsx(K,{className:"ml-2 size-4"})]}):i.jsx(k,{disabled:!$||u.isPending,onClick:()=>u.mutate(),children:"Finish and score"})]})]})}):null]})]})}export{je as PsycheQuestionnaireRunPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as u,j as e,aC as m,d6 as v,bf as b}from"./vendor-Dnkkx2co.js";import{i as w}from"./state-vCcAT5Hq.js";import{F as g}from"./faceted-token-search-
|
|
1
|
+
import{r as u,j as e,aC as m,d6 as v,bf as b}from"./vendor-Dnkkx2co.js";import{i as w}from"./state-vCcAT5Hq.js";import{F as g}from"./faceted-token-search-DtO6OUwQ.js";import{L as j,E as N,B as p,ch as k,a as S,C as f,c as d,Z as _,ck as C}from"./index-BP9__l6C.js";import{P as $}from"./page-hero-DgnhI5es.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";function 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 H(){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{H as PsycheQuestionnairesPage};
|
package/dist/assets/{psyche-report-detail-page-BqDE_tf7.js → psyche-report-detail-page-CV6tbLxz.js}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as h,j as e,d7 as ie,bi as ae,cc as re}from"./vendor-Dnkkx2co.js";import{j as ne,i as p,k as R}from"./state-vCcAT5Hq.js";import{B as b,Z as oe,c_ as de,ai as le,S as ce,E as D,T as H,aq as U,ah as V,I as C,b as G,ch as me,c$ as he,by as ue,bz as pe,bA as xe,cr as ge,d0 as ve,d1 as fe}from"./index-
|
|
1
|
+
import{r as h,j as e,d7 as ie,bi as ae,cc as re}from"./vendor-Dnkkx2co.js";import{j as ne,i as p,k as R}from"./state-vCcAT5Hq.js";import{B as b,Z as oe,c_ as de,ai as le,S as ce,E as D,T as H,aq as U,ah as V,I as C,b as G,ch as me,c$ as he,by as ue,bz as pe,bA as xe,cr as ge,d0 as ve,d1 as fe}from"./index-BP9__l6C.js";import{A as Y,m as Z}from"./motion-Lt5B1XuE.js";import{I as ye}from"./insight-flow-dialog-BUv06Vn-.js";import{O as be}from"./open-in-graph-button-CDHxzS8B.js";import{E as je}from"./entity-notes-surface-BdHBn8rx.js";import{S as y,B as ke,M as we,T as Te,E as Ne}from"./report-chain-fields-BYEp3tRr.js";import{P as Ie}from"./page-hero-DgnhI5es.js";import{t as Se}from"./psyche-schemas-Dxj554nU.js";import{b as Le,a as Ce,c as Ee,f as Me,t as Be}from"./schema-visuals-CvC9a3i6.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";import"./note-markdown-3wB52NOn.js";import"./note-tags-input-Blg5Gqz_.js";const J="(max-width: 1023px)";function qe(){const[i,o]=h.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(J).matches);return h.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const d=window.matchMedia(J),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(Z.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(Z.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
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 et(){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
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 de(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:le,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(ce,{});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)??[],X=((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"}),X.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(me,{}),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{et as PsycheReportDetailPage};
|