forge-openclaw-plugin 0.2.98 → 0.2.100
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-copy-Bj4h9OcF.js +1 -0
- package/dist/assets/activity-page-5oyCFOns.js +1 -0
- package/dist/assets/ai-surface-workspace-qgk_B57-.js +1 -0
- package/dist/assets/atlas-panel-rfH2qOez.js +1 -0
- package/dist/assets/{board-Ju0h0SeG.js → board-BkDRaMp6.js} +1 -1
- package/dist/assets/calendar-display-preferences-Cid-2RnL.js +1 -0
- package/dist/assets/calendar-page-Bo2iua-a.js +1 -0
- package/dist/assets/calendar-rules-DA1g3QUk.js +1 -0
- package/dist/assets/calendar-ui-Cy1XRwzV.js +1 -0
- package/dist/assets/calendar-week-toolbar-DU1Q4RYj.js +1 -0
- package/dist/assets/charts-P7EVhIog.js +36 -0
- package/dist/assets/companion-sync-lab-page-CosNknOK.js +1 -0
- package/dist/assets/daily-metrics-dashboard-LjuGAB3f.js +1 -0
- package/dist/assets/date-keys-Cj1G3TOn.js +1 -0
- package/dist/assets/entity-links-DwpxhW2H.js +1 -0
- package/dist/assets/entity-note-count-link-BmGDB572.js +1 -0
- package/dist/assets/entity-notes-surface-DgEgicaE.js +1 -0
- package/dist/assets/execution-board-CDRXQB85.js +1 -0
- package/dist/assets/faceted-token-search-CE1YauRd.js +1 -0
- package/dist/assets/flagship-signal-deck-DDds90Gl.js +1 -0
- package/dist/assets/floating-action-menu-CJkI2iFy.js +1 -0
- package/dist/assets/forms-BFlTgZ3W.js +1 -0
- package/dist/assets/goal-detail-page-cJvHaLMQ.js +1 -0
- package/dist/assets/goals-page-f_39hvUV.js +1 -0
- package/dist/assets/graph-BZV40eAE.css +1 -0
- package/dist/assets/graph-D6JLqDbD.js +318 -0
- package/dist/assets/habits-page-DKb96_mj.js +1 -0
- package/dist/assets/health-link-options-Cpx8w7uM.js +1 -0
- package/dist/assets/index-BHTUu_4M.js +19 -0
- package/dist/assets/index-CZbuZQjw.css +1 -0
- package/dist/assets/insight-flow-dialog-pzAzyayN.js +1 -0
- package/dist/assets/insights-page-Dc9oFltJ.js +8 -0
- package/dist/assets/kanban-page-JAxerYh6.js +1 -0
- package/dist/assets/knowledge-graph-page-UQ3skqEi.js +1 -0
- package/dist/assets/life-force-page-BGDbQuVh.js +1 -0
- package/dist/assets/life-force-workspace-B1fYSXRC.js +1 -0
- package/dist/assets/maps-B-YMMjus.css +1 -0
- package/dist/assets/maps-ClgJoCjz.js +803 -0
- package/dist/assets/metric-tile-DX6TclqM.js +1 -0
- package/dist/assets/{motion-DRPJkN3a.js → motion-BeD44FeG.js} +1 -1
- package/dist/assets/movement-page-6HP6nGJx.js +1 -0
- package/dist/assets/note-markdown-DiW2-5d3.js +3 -0
- package/dist/assets/note-tags-input-DDLXf54U.js +1 -0
- package/dist/assets/notes-page-BuguDjhz.js +1 -0
- package/dist/assets/open-in-graph-button-Cg5VrKsC.js +1 -0
- package/dist/assets/orbit-map-GD05-0oS.js +1 -0
- package/dist/assets/overview-page-DuOs2OCB.js +1 -0
- package/dist/assets/page-hero-CQWo1Mm_.js +1 -0
- package/dist/assets/pill-cluster-BJogDRDJ.js +1 -0
- package/dist/assets/preference-entity-handoff-button-D4WAs9pC.js +1 -0
- package/dist/assets/preferences-page-BaJTMU1I.js +1 -0
- package/dist/assets/project-collections-DvaX20q_.js +1 -0
- package/dist/assets/project-detail-page-drPIFZGb.js +1 -0
- package/dist/assets/project-management-hierarchy-page-BUbRXvny.js +1 -0
- package/dist/assets/project-management-section-nav-C2Ud8Zdd.js +1 -0
- package/dist/assets/projects-page-BGzEZUtg.js +1 -0
- package/dist/assets/psyche-behaviors-page-Dmm_Io9D.js +5 -0
- package/dist/assets/psyche-flashcards-page-BgNKJ6QJ.js +1 -0
- package/dist/assets/psyche-goal-map-page-DXJs98Vr.js +1 -0
- package/dist/assets/psyche-graph-CFgs_Bqc.js +1 -0
- package/dist/assets/psyche-metrics-page-zYTJDbyZ.js +1 -0
- package/dist/assets/psyche-mode-guide-page-XPgRfCOf.js +1 -0
- package/dist/assets/psyche-modes-page-B-GA8oRF.js +1 -0
- package/dist/assets/psyche-page--r6a3e1t.js +1 -0
- package/dist/assets/psyche-patterns-page-BM5-3bMm.js +5 -0
- package/dist/assets/psyche-questionnaire-builder-page-CJshQ-mg.js +1 -0
- package/dist/assets/psyche-questionnaire-detail-page-USmR5G5A.js +1 -0
- package/dist/assets/psyche-questionnaire-run-detail-page-D7iBCmTi.js +1 -0
- package/dist/assets/psyche-questionnaire-run-page-Cpil-kDh.js +1 -0
- package/dist/assets/psyche-questionnaires-page-C-_y3VwS.js +1 -0
- package/dist/assets/psyche-report-detail-page--dkSPRaj.js +3 -0
- package/dist/assets/psyche-reports-page-CUaOXmIN.js +1 -0
- package/dist/assets/psyche-schemas-HFmg37Wj.js +1 -0
- package/dist/assets/psyche-schemas-beliefs-page-BX6xaap3.js +9 -0
- package/dist/assets/psyche-screen-time-page-CAAI4mD7.js +1 -0
- package/dist/assets/psyche-self-observation-page-BZ6FLuwa.js +1 -0
- package/dist/assets/psyche-values-page-yEV6MGt8.js +5 -0
- package/dist/assets/query-cache-IQ8W-LNC.js +1 -0
- package/dist/assets/report-chain-fields-fZ8Xd4H6.js +1 -0
- package/dist/assets/rewards-page-C2HQjIAf.js +1 -0
- package/dist/assets/scheduling-rules-editor-BHOpHOrV.js +1 -0
- package/dist/assets/schema-badge-DyKbxb51.js +1 -0
- package/dist/assets/schema-visuals-D6nxjbYC.js +1 -0
- package/dist/assets/select-menu-BX-pZNqL.js +1 -0
- package/dist/assets/settings-agents-page-VuYXTiyc.js +6 -0
- package/dist/assets/settings-bin-page-BNzvYaOk.js +1 -0
- package/dist/assets/settings-calendar-page-CjSFB53S.js +5 -0
- package/dist/assets/settings-data-page-CGSlryuI.js +1 -0
- package/dist/assets/settings-logs-page-BTK5fine.js +1 -0
- package/dist/assets/settings-mobile-page-CRaObOGo.js +1 -0
- package/dist/assets/settings-models-page-DFshpYF8.js +1 -0
- package/dist/assets/settings-page-BP81Mb5R.js +1 -0
- package/dist/assets/settings-rewards-page-CDJ1PH2G.js +1 -0
- package/dist/assets/settings-section-nav-CCFm27r2.js +1 -0
- package/dist/assets/settings-users-page-TdUocFPa.js +1 -0
- package/dist/assets/settings-wiki-page-B2zX0QQG.js +1 -0
- package/dist/assets/sleep-page-cI1GMVzk.js +1 -0
- package/dist/assets/sports-page-06LTqp0V.js +1 -0
- package/dist/assets/state-B-4sS1xO.js +1 -0
- package/dist/assets/strategies-page-DXP9Kx8s.js +1 -0
- package/dist/assets/strategy-detail-page-D6mx_Mik.js +1 -0
- package/dist/assets/strategy-dialog-BvzomTaF.js +1 -0
- package/dist/assets/{table-DewbFlTh.js → table-WfAPUppN.js} +1 -1
- package/dist/assets/task-detail-page-BIWIggdp.js +1 -0
- package/dist/assets/timebox-planning-dialog-CaCnoslG.js +1 -0
- package/dist/assets/today-page-DO2mRPT2.js +1 -0
- package/dist/assets/training-load-page-CyZ0mlEr.js +1 -0
- package/dist/assets/{ui-C2IvSrAz.js → ui-C13Nbgas.js} +4 -4
- package/dist/assets/use-psyche-focus-target-C1C_XjYG.js +1 -0
- package/dist/assets/vendor-CRS-psbw.css +1 -0
- package/dist/assets/vendor-DHkYh85p.js +1052 -0
- package/dist/assets/vitals-page-BQvEjTc6.js +1 -0
- package/dist/assets/weekly-review-page-Tp6Q9CRj.js +1 -0
- package/dist/assets/weight-loss-page-BBzlhLVV.js +1 -0
- package/dist/assets/wiki-article-markdown-DQYohmW2.js +4 -0
- package/dist/assets/wiki-editor-page-Dem_3eZv.js +26 -0
- package/dist/assets/wiki-ingest-history-page-BxoOcCoJ.js +1 -0
- package/dist/assets/wiki-ingest-modal-DhguKk3J.js +1 -0
- package/dist/assets/wiki-page-BLRxVXkl.js +1 -0
- package/dist/assets/workbench-flow-page-DqMkCCTy.js +5 -0
- package/dist/assets/workbench-page-BWd02wPw.js +1 -0
- package/dist/assets/workout-detail-page-BD8u7GyL.js +2 -0
- package/dist/index.html +148 -9
- package/dist/openclaw/tools.js +340 -0
- package/dist/server/server/migrations/065_weight_loss_nutrition_insights.sql +236 -0
- package/dist/server/server/migrations/066_watch_action_receipts.sql +20 -0
- package/dist/server/server/src/app.js +266 -13
- package/dist/server/server/src/health-weight-loss.js +1378 -0
- package/dist/server/server/src/health.js +188 -35
- package/dist/server/server/src/openapi.js +449 -0
- package/dist/server/server/src/services/context.js +6 -7
- package/dist/server/server/src/services/doctor.js +39 -4
- package/dist/server/server/src/services/gamification.js +146 -34
- package/dist/server/server/src/watch-mobile.js +564 -4
- package/dist/server/server/src/web.js +18 -5
- package/dist/server/src/components/ui/info-tooltip.js +48 -3
- package/dist/server/src/lib/api.js +131 -0
- package/dist/server/src/lib/weight-loss-types.js +1 -0
- package/openclaw.plugin.json +14 -1
- package/package.json +1 -1
- package/server/migrations/065_weight_loss_nutrition_insights.sql +236 -0
- package/server/migrations/066_watch_action_receipts.sql +20 -0
- package/skills/forge-openclaw/SKILL.md +26 -5
- package/skills/forge-openclaw/entity_conversation_playbooks.md +134 -5
- package/skills/forge-openclaw/psyche_entity_playbooks.md +45 -0
- package/dist/assets/index-Cn5Wpwau.css +0 -1
- package/dist/assets/index-CwvGs8n4.js +0 -91
- package/dist/assets/vendor-B-Lq_OG3.css +0 -1
- package/dist/assets/vendor-DL2K5ayT.js +0 -2186
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c2 as ft,r as h,j as e,b0 as jt,bH as wt,cG as yt,cH as Nt,bf as Ct,aG as It,aC as ue,b3 as se,c7 as St,b4 as kt,aK as Ft}from"./vendor-DHkYh85p.js";import{R as Pt,P as Lt,O as Tt,C as Mt,T as At,D as Dt,a as Et}from"./ui-C13Nbgas.js";import{j as _t,i as Ze,k as j}from"./state-B-4sS1xO.js";import{u as zt,s as Ot,c4 as Ve,c5 as $t,c6 as Bt,c7 as Wt,c8 as qt,c9 as Rt,ca as Qt,cb as Ut,cc as Gt,cd as Ht,ce as Kt,cf as Jt,cg as Yt,ch as Xt,ci as Zt,cj as Vt,a as et,L as tt,E as es,B as o,ck as ts,C as v,U as st,H as ss,Z as $,c as y,I as x,T,bk as H,cl as at}from"./index-BHTUu_4M.js";import{P as as}from"./page-hero-CQWo1Mm_.js";import"./board-BkDRaMp6.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";const rt=[{id:"overview",label:"Overview",icon:jt},{id:"map",label:"Map",icon:wt},{id:"table",label:"Table",icon:yt},{id:"history",label:"History",icon:Nt},{id:"contexts",label:"Contexts",icon:Ct},{id:"concepts",label:"Concepts",icon:It}],is=new Set(["projects","tasks","strategies","habits"]),ae=[{value:"projects",label:"Projects",description:"Goals and projects already living in Forge.",mode:"forge"},{value:"tasks",label:"Tasks",description:"Execution-level work choices inside Forge.",mode:"forge"},{value:"strategies",label:"Strategies",description:"Plan shapes and sequencing choices in Forge.",mode:"forge"},{value:"habits",label:"Habits",description:"Recurring behaviors and routines from Forge.",mode:"forge"},{value:"activities",label:"Activities",description:"Movement, leisure, and social setting concepts.",mode:"concept"},{value:"food",label:"Food",description:"Cuisine, meal mood, and drink preferences.",mode:"concept"},{value:"places",label:"Places",description:"Living environments, venues, and trip shapes.",mode:"concept"},{value:"countries",label:"Countries",description:"Country-level attraction and lifestyle fit.",mode:"concept"},{value:"fashion",label:"Fashion",description:"Silhouette, material, and palette preferences.",mode:"concept"},{value:"people",label:"People",description:"Presence, body-type, and conversation preferences.",mode:"concept"},{value:"media",label:"Media",description:"Film, reading, and music taste.",mode:"concept"},{value:"tools",label:"Tools",description:"Workflow and capture preferences.",mode:"concept"},{value:"custom",label:"Custom",description:"General-purpose concept libraries you control.",mode:"concept"}],ve={novelty:"Novelty",simplicity:"Simplicity",rigor:"Rigor",aesthetics:"Aesthetics",depth:"Depth",structure:"Structure",familiarity:"Familiarity",surprise:"Surprise"},ie={novelty:0,simplicity:0,rigor:0,aesthetics:0,depth:0,structure:0,familiarity:0,surprise:0},it={liked:"bg-emerald-500/12 text-emerald-200",disliked:"bg-rose-500/12 text-rose-200",uncertain:"bg-white/[0.08] text-white/70",vetoed:"bg-rose-500/15 text-rose-100",bookmarked:"bg-sky-500/12 text-sky-200",favorite:"bg-amber-500/12 text-amber-200",must_have:"bg-indigo-500/15 text-indigo-100",neutral:"bg-white/[0.08] text-white/70"},ns=[{signalType:"favorite",label:"Favorite"},{signalType:"must_have",label:"Must-have"},{signalType:"bookmark",label:"Bookmark"},{signalType:"compare_later",label:"Later"},{signalType:"neutral",label:"Neutral"},{signalType:"veto",label:"Veto"}];function ne(c){return c.trim().toLowerCase()}function B(c){return`${Math.round(c*100)}%`}function rs(c){return[...c.goals.map(a=>({entityType:"goal",entityId:a.id,domain:"projects",label:a.title,description:a.description,user:a.user,href:`/goals/${a.id}`,searchText:H([a.title,a.description,a.status,a.horizon],a)})),...c.dashboard.projects.map(a=>({entityType:"project",entityId:a.id,domain:"projects",label:a.title,description:a.description,user:a.user,href:`/projects/${a.id}`,searchText:H([a.title,a.description,a.status,a.goalTitle],a)})),...c.tasks.map(a=>({entityType:"task",entityId:a.id,domain:"tasks",label:a.title,description:a.description,user:a.user,href:`/tasks/${a.id}`,searchText:H([a.title,a.description,a.status,a.priority,a.owner],a)})),...c.strategies.map(a=>({entityType:"strategy",entityId:a.id,domain:"strategies",label:a.title,description:a.overview||a.endStateDescription,user:a.user,href:`/strategies/${a.id}`,searchText:H([a.title,a.overview,a.endStateDescription,a.status],a)})),...c.habits.map(a=>({entityType:"habit",entityId:a.id,domain:"habits",label:a.title,description:a.description,user:a.user,href:null,searchText:H([a.title,a.description,a.status,a.frequency],a)}))]}function ls(c,a){return!c||!a?null:c==="goal"?`/goals/${a}`:c==="project"?`/projects/${a}`:c==="task"?`/tasks/${a}`:c==="strategy"?`/strategies/${a}`:null}function re(c){return c.manualStatus??c.status}function ds(c){return c&&rt.some(a=>a.id===c)?c:"overview"}function cs(c){return c.summary.totalItems<2?{title:"Forge does not know enough yet.",description:"Start the game so Forge can ask a few clean comparisons and build a real preference model."}:c.summary.averageConfidence<.28?{title:"Forge has a rough sketch, not a stable read.",description:"There is some signal, but the model still needs more rounds before its preferences are trustworthy."}:{title:"This is what Forge currently thinks.",description:"The summary below is the current best model for this user, this domain, and the active context."}}function os({summary:c}){const a=Math.max(-1,Math.min(1,c.leaning)),N=(a+1)/2*100;return e.jsxs("div",{className:"grid gap-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs text-white/56",children:[e.jsx("span",{children:ve[c.dimensionId]}),e.jsxs("span",{children:[c.movement>.08?"Rising":c.movement<-.08?"Falling":"Stable"," ","· ",B(c.confidence)]})]}),e.jsxs("div",{className:"relative h-2 rounded-full bg-white/[0.08]",children:[e.jsx("div",{className:"absolute inset-y-0 left-1/2 w-px bg-white/10"}),e.jsx("div",{className:$("absolute top-1/2 size-3 -translate-x-1/2 -translate-y-1/2 rounded-full border border-white/12",a>=0?"bg-emerald-300":"bg-rose-300"),style:{left:`${N}%`}})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 text-[11px] uppercase tracking-[0.12em] text-white/38",children:[e.jsxs("span",{children:[a>=0?"Leans toward":"Leans away from"," ",ve[c.dimensionId].toLowerCase()]}),e.jsxs("span",{children:["Context ",B(c.contextSensitivity)]})]})]})}function nt({title:c,description:a,sideLabel:N,onClick:W}){return e.jsxs("button",{type:"button",className:"grid min-h-[220px] gap-4 rounded-[28px] border border-white/10 bg-[linear-gradient(180deg,rgba(255,255,255,0.07),rgba(255,255,255,0.03))] p-5 text-left transition hover:border-[var(--primary)]/40 hover:bg-[linear-gradient(180deg,rgba(192,193,255,0.14),rgba(255,255,255,0.05))]",onClick:W,children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:N}),e.jsx("div",{className:"font-display text-3xl text-white",children:c}),e.jsx("div",{className:"max-w-[36ch] text-sm leading-6 text-white/56",children:a||"Choose the one that feels more right."}),e.jsx("div",{className:"mt-auto text-sm text-[var(--primary)]",children:"Click this card"})]})}function js(){var Qe,Ue,Ge,He,Ke;const c=zt(),a=_t(),[N,W]=ft(),[le,lt]=h.useState(""),[de,dt]=h.useState(""),[D,be]=h.useState(""),[K,fe]=h.useState(""),[J,je]=h.useState(""),[f,F]=h.useState({open:!1,phase:"domain",domain:N.get("domain")??"projects"}),[we,P]=h.useState(null),[ct,ce]=h.useState(!1),[ye,E]=h.useState(null),[p,C]=h.useState({label:"",description:"",tags:"",manualStatus:"",manualScore:"",confidenceLock:"",bookmarked:!1,compareLater:!1,frozen:!1,featureWeights:{novelty:"0",simplicity:"0",rigor:"0",aesthetics:"0",depth:"0",structure:"0",familiarity:"0",surprise:"0"}}),[M,Y]=h.useState({label:"",description:"",tags:""}),[I,q]=h.useState({name:"",description:"",shareMode:"blended",decayDays:"90"}),[R,oe]=h.useState({title:"",description:""}),[ot,X]=h.useState({}),[Ne,me]=h.useState(null),[Z,he]=h.useState({title:"",description:""}),[mt,xe]=h.useState(null),[_,V]=h.useState({label:"",description:"",tags:""}),m=N.get("userId")??Ot(c.selectedUserIds)??((Qe=c.snapshot.users[0])==null?void 0:Qe.id)??null,w=N.get("domain")??"projects",S=ds(N.get("tab")),Q=N.get("contextId"),ee=N.get("focusItem"),Ce=h.useMemo(()=>c.snapshot.users.find(t=>t.id===m)??null,[m,c.snapshot.users]),te=h.useMemo(()=>rs(c.snapshot),[c.snapshot]),U=Ze({queryKey:["forge-preferences",m,w,Q],queryFn:async()=>(await at({userId:m??void 0,domain:w,contextId:Q??void 0})).workspace,enabled:!!m}),Ie=Ze({queryKey:["forge-preferences-game",m,f.domain,Q],queryFn:async()=>(await at({userId:m??void 0,domain:f.domain,contextId:Q??void 0})).workspace,enabled:!!m&&f.open}),i=U.data??null,g=f.domain===w?i:Ie.data??null;h.useEffect(()=>{var s;if(!i)return;const t=ee&&i.scores.some(l=>l.itemId===ee)?ee:((s=i.scores[0])==null?void 0:s.itemId)??null;E(l=>l&&i.scores.some(n=>n.itemId===l)?l:t)},[ee,i]);const pe=h.useMemo(()=>{if(!i)return[];const t=ne(le);return t?i.scores.filter(s=>{var l,n,r;return[((l=s.item)==null?void 0:l.label)??"",((n=s.item)==null?void 0:n.description)??"",((r=s.item)==null?void 0:r.tags.join(" "))??"",s.status,s.manualStatus??"",s.dominantDimensions.join(" "),s.explanation.join(" ")].join(" ").toLowerCase().includes(t)}):i.scores},[le,i]),d=pe.find(t=>t.itemId===ye)??(i==null?void 0:i.scores.find(t=>t.itemId===ye))??pe[0]??(i==null?void 0:i.scores[0])??null;h.useEffect(()=>{var t,s,l,n,r,b,G,O,Je,Ye,Xe;d&&C({label:((t=d.item)==null?void 0:t.label)??"",description:((s=d.item)==null?void 0:s.description)??"",tags:((l=d.item)==null?void 0:l.tags.join(", "))??"",manualStatus:d.manualStatus??"",manualScore:typeof d.manualScore=="number"?String(d.manualScore):"",confidenceLock:typeof d.confidenceLock=="number"?String(d.confidenceLock):"",bookmarked:d.bookmarked,compareLater:d.compareLater,frozen:d.frozen,featureWeights:{novelty:String(((n=d.item)==null?void 0:n.featureWeights.novelty)??0),simplicity:String(((r=d.item)==null?void 0:r.featureWeights.simplicity)??0),rigor:String(((b=d.item)==null?void 0:b.featureWeights.rigor)??0),aesthetics:String(((G=d.item)==null?void 0:G.featureWeights.aesthetics)??0),depth:String(((O=d.item)==null?void 0:O.featureWeights.depth)??0),structure:String(((Je=d.item)==null?void 0:Je.featureWeights.structure)??0),familiarity:String(((Ye=d.item)==null?void 0:Ye.featureWeights.familiarity)??0),surprise:String(((Xe=d.item)==null?void 0:Xe.featureWeights.surprise)??0)}})},[d]);const Se=h.useMemo(()=>{const t=ne(de);return te.filter(s=>s.domain===w).filter(s=>t?s.searchText.includes(t):!0).slice(0,12)},[te,de,w]),ge=h.useMemo(()=>{const t=S==="concepts"?i:g??i,s=(t==null?void 0:t.catalogs)??[],l=ne(D);return l?s.filter(n=>[n.title,n.description,n.source,...n.items.flatMap(r=>[r.label,r.description,r.tags.join(" ")])].join(" ").toLowerCase().includes(l)):s},[g,D,S,i]),u=async()=>{await a.invalidateQueries({queryKey:["forge-preferences"]}),await a.invalidateQueries({queryKey:["forge-preferences-game"]})},ke=j({mutationFn:Ve,onSuccess:u}),Fe=j({mutationFn:$t,onSuccess:async({item:t})=>{await u(),Y({label:"",description:"",tags:""}),E(t.id)}}),Pe=j({mutationFn:Bt,onSuccess:async()=>{await u(),oe({title:"",description:""}),W(t=>{const s=new URLSearchParams(t);return s.set("tab","concepts"),s})}}),Le=j({mutationFn:({catalogId:t,patch:s})=>Wt(t,s),onSuccess:async()=>{await u(),me(null)}}),Te=j({mutationFn:qt,onSuccess:u}),Me=j({mutationFn:Rt,onSuccess:async()=>{await u()}}),Ae=j({mutationFn:({catalogItemId:t,patch:s})=>Qt(t,s),onSuccess:async()=>{await u(),xe(null)}}),De=j({mutationFn:Ut,onSuccess:u}),ht=j({mutationFn:Gt,onSuccess:async()=>{await u(),F(t=>({...t,phase:"play"}))}}),xt=j({mutationFn:Ht,onSuccess:u}),pt=j({mutationFn:Kt,onSuccess:u}),Ee=j({mutationFn:async()=>{!(d!=null&&d.item)||!m||!i||(await Jt(d.item.id,{label:p.label,description:p.description,tags:p.tags.split(",").map(t=>t.trim()).filter(Boolean),featureWeights:Object.fromEntries(Object.keys(ie).map(t=>[t,Number(p.featureWeights[t]||0)]))}),await Yt(d.item.id,{userId:m,domain:w,contextId:i.selectedContext.id,manualStatus:p.manualStatus||null,manualScore:p.manualScore.trim().length>0?Number(p.manualScore):null,confidenceLock:p.confidenceLock.trim().length>0?Number(p.confidenceLock):null,bookmarked:p.bookmarked,compareLater:p.compareLater,frozen:p.frozen}))},onSuccess:u}),_e=j({mutationFn:Xt,onSuccess:async({context:t})=>{await u(),q({name:"",description:"",shareMode:"blended",decayDays:"90"}),W(s=>{const l=new URLSearchParams(s);return l.set("contextId",t.id),l.set("tab","contexts"),l})}}),ze=j({mutationFn:Zt,onSuccess:async()=>{await u(),fe(""),je("")}}),z=j({mutationFn:({contextId:t,patch:s})=>Vt(t,s),onSuccess:u}),k=t=>{W(s=>{const l=new URLSearchParams(s);for(const[n,r]of Object.entries(t))r?l.set(n,r):l.delete(n);return l})},Oe=(t=w)=>{P(null),F({open:!0,phase:"domain",domain:t})},gt=async t=>{if(!m)return;P(null),ce(!0);const s=te.filter(r=>{var b;return r.domain===t&&((b=r.user)==null?void 0:b.id)===m}),l=te.filter(r=>r.domain===t),n=(s.length>0?s:l).slice(0,12);if(n.length<2){P("Forge needs at least two matching records in this domain before it can start the game."),ce(!1),F(r=>({...r,phase:"domain"}));return}try{k({domain:t,tab:"overview",contextId:null,focusItem:null}),await Promise.all(n.map(r=>Ve({userId:m,domain:t,entityType:r.entityType,entityId:r.entityId,label:r.label,description:r.description,tags:[]}))),await u(),F({open:!0,phase:"play",domain:t})}catch(r){P(r instanceof Error?r.message:"Forge could not start the game."),F(b=>({...b,phase:"domain"}))}finally{ce(!1)}},$e=async(t,s)=>{if(m){P(null),k({domain:t,tab:"overview",contextId:null,focusItem:null});try{await ht.mutateAsync({userId:m,domain:t,contextId:Q??void 0,catalogId:s}),F({open:!0,phase:"play",domain:t})}catch(l){P(l instanceof Error?l.message:"Forge could not start the game.")}}},ut=async t=>{if(is.has(t)){await gt(t);return}P(null),F({open:!0,phase:"catalog",domain:t})},L=async(t,s=1)=>{if(!m||!(g!=null&&g.compare.nextPair))return;const l=g.compare.nextPair;await xt.mutateAsync({userId:m,domain:f.domain,contextId:g.selectedContext.id,leftItemId:l.left.id,rightItemId:l.right.id,outcome:t,strength:s})},vt=async(t,s)=>{!m||!g||await pt.mutateAsync({userId:m,domain:f.domain,contextId:g.selectedContext.id,itemId:t,signalType:s,strength:1})};if(!m)return e.jsx(et,{eyebrow:"Preferences",title:"No Forge user available",description:"Forge needs at least one human or bot user before it can learn preferences."});if(U.isLoading&&!i)return e.jsx(tt,{eyebrow:"Preferences",title:"Loading preference model",description:"Reconstructing current scores, uncertainty, and concept libraries."});if(U.isError)return e.jsx(es,{eyebrow:"Preferences",error:U.error,onRetry:()=>void U.refetch()});if(!i)return null;const bt=[...i.dimensions].sort((t,s)=>s.confidence-t.confidence).slice(0,6),Be=i.scores.filter(t=>re(t)==="liked"||re(t)==="favorite").slice(0,4),We=i.scores.filter(t=>t.uncertainty>=.5).slice(0,4),qe=cs(i),Re=ls(((Ue=d==null?void 0:d.item)==null?void 0:Ue.sourceEntityType)??null,((Ge=d==null?void 0:d.item)==null?void 0:Ge.sourceEntityId)??null),A=(g==null?void 0:g.compare.nextPair)??null;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsx(as,{title:"Preferences",titleText:"Preferences",description:"Forge keeps an explicit, editable model of what one user prefers in one domain. The first job of this page is to show what Forge currently knows.",badge:`${i.summary.totalItems} items · ${B(i.summary.averageConfidence)} confidence`,actions:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(o,{className:"min-w-[10rem]",onClick:()=>Oe(),children:"Start the game"}),e.jsx(o,{variant:"secondary",onClick:()=>void u(),children:"Refresh model"})]})}),e.jsx(ts,{}),e.jsxs(v,{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-3 xl:grid-cols-[minmax(0,1.2fr)_minmax(0,1fr)]",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Active user"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("select",{value:m,onChange:t=>k({userId:t.target.value,contextId:null,focusItem:null}),className:"min-h-10 rounded-[18px] border border-white/8 bg-white/[0.05] px-3 text-sm text-white outline-none",children:c.snapshot.users.map(t=>e.jsxs("option",{value:t.id,children:[t.displayName," · ",t.kind]},t.id))}),e.jsx(st,{user:Ce}),e.jsx("div",{className:"text-sm text-white/54",children:ss(Ce)})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Domain"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ae.map(t=>e.jsx("button",{type:"button",className:$("rounded-full border px-3 py-2 text-sm transition",t.value===w?"border-[var(--primary)] bg-[var(--primary)]/14 text-white":"border-white/8 bg-white/[0.04] text-white/62 hover:bg-white/[0.08]"),onClick:()=>k({domain:t.value,contextId:null,focusItem:null}),children:t.label},t.value))}),e.jsx("div",{className:"text-sm text-white/48",children:(He=ae.find(t=>t.value===w))==null?void 0:He.description})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-white/50",children:[e.jsx(y,{className:"bg-white/[0.08] text-white/70",children:i.selectedContext.name}),e.jsx("span",{children:i.selectedContext.shareMode}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[i.compare.pendingCount," queued comparisons"]}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[i.libraries.totalCatalogItems," concept items ready"]})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:rt.map(t=>e.jsxs("button",{type:"button",className:$("inline-flex items-center gap-2 rounded-full border px-3 py-2 text-sm transition",t.id===S?"border-[var(--primary)] bg-[var(--primary)]/14 text-white":"border-white/8 bg-white/[0.04] text-white/62 hover:bg-white/[0.08]"),onClick:()=>k({tab:t.id}),children:[e.jsx(t.icon,{className:"size-4"}),t.label]},t.id))}),S==="overview"?e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.3fr)_360px]",children:[e.jsxs(v,{className:"grid gap-5",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"What Forge knows"}),e.jsx("div",{className:"font-display text-3xl text-white",children:qe.title}),e.jsx("div",{className:"max-w-[70ch] text-sm leading-6 text-white/58",children:qe.description})]}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[{label:"Known items",value:i.summary.totalItems,detail:"Items inside this domain"},{label:"Confidence",value:B(i.summary.averageConfidence),detail:"Average certainty"},{label:"Unknowns",value:i.summary.uncertainCount,detail:"Need more rounds"},{label:"Libraries",value:i.libraries.totalCatalogItems,detail:"Seeded concepts ready"}].map(t=>e.jsxs("div",{className:"rounded-[22px] bg-white/[0.04] px-4 py-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:t.label}),e.jsx("div",{className:"mt-2 font-display text-3xl text-white",children:t.value}),e.jsx("div",{className:"mt-1 text-sm text-white/52",children:t.detail})]},t.label))}),e.jsx("div",{className:"grid gap-4 lg:grid-cols-2",children:bt.map(t=>e.jsx(os,{summary:t},t.dimensionId))})]}),e.jsxs(v,{className:"grid gap-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Next move"}),e.jsx("div",{className:"font-display text-2xl text-white",children:"Start the game"}),e.jsx("div",{className:"text-sm leading-6 text-white/58",children:"Forge will ask a small number of pairwise questions. You choose a domain, Forge supplies the candidates, and the model tightens from there."}),e.jsx(o,{className:"w-full",onClick:()=>Oe(),children:"Start the game"}),e.jsxs("div",{className:"grid gap-3 rounded-[22px] bg-white/[0.04] px-4 py-4 text-sm text-white/58",children:[e.jsxs("div",{children:["Current queue: ",i.compare.pendingCount," comparison",i.compare.pendingCount===1?"":"s"]}),e.jsxs("div",{children:["Active context: ",i.selectedContext.name]}),e.jsxs("div",{children:["Library coverage: ",i.libraries.seededCatalogCount," ","seeded lists and ",i.libraries.customCatalogCount," ","custom lists"]})]})]})]}),e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.3fr)_360px]",children:[e.jsxs(v,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Preference map"}),e.jsx("div",{className:"mt-1 text-sm text-white/54",children:"Green drifts positive, red drifts negative, and low opacity still means uncertainty."})]}),e.jsx(ue,{to:"?tab=map",className:"text-sm text-[var(--primary)]",children:"Open full map"})]}),e.jsxs("div",{className:"relative min-h-[340px] overflow-hidden rounded-[24px] border border-white/8 bg-[radial-gradient(circle_at_top,rgba(87,196,138,0.18),transparent_35%),radial-gradient(circle_at_bottom_right,rgba(255,104,130,0.14),transparent_30%),linear-gradient(180deg,rgba(255,255,255,0.03),rgba(255,255,255,0.01))]",children:[e.jsx("div",{className:"absolute inset-x-0 top-1/2 h-px bg-white/8"}),e.jsx("div",{className:"absolute inset-y-0 left-1/2 w-px bg-white/8"}),i.map.map(t=>e.jsx("button",{type:"button",className:$("absolute -translate-x-1/2 -translate-y-1/2 rounded-full border px-2 py-1 text-[11px] shadow-[0_10px_25px_rgba(5,8,16,0.32)] transition hover:scale-[1.04]",t.itemId===(d==null?void 0:d.itemId)?"border-white/30 bg-white/16 text-white":t.score>=0?"border-emerald-300/30 bg-emerald-500/14 text-emerald-100":"border-rose-300/30 bg-rose-500/14 text-rose-100"),style:{left:`${50+t.x*30}%`,top:`${50-t.y*30}%`,opacity:.55+t.confidence*.45},onClick:()=>E(t.itemId),children:t.label},t.itemId))]})]}),e.jsxs(v,{className:"grid gap-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Best read so far"}),e.jsx("div",{className:"grid gap-2",children:Be.length>0?Be.map(t=>{var s;return e.jsxs("button",{type:"button",className:"rounded-[18px] bg-white/[0.04] px-3 py-3 text-left transition hover:bg-white/[0.07]",onClick:()=>{E(t.itemId),k({focusItem:t.itemId})},children:[e.jsx("div",{className:"font-medium text-white",children:((s=t.item)==null?void 0:s.label)??t.itemId}),e.jsx("div",{className:"mt-1 text-sm text-white/54",children:t.explanation[0]||"Forge has positive evidence here."})]},t.itemId)}):e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] px-3 py-3 text-sm text-white/58",children:"No clear positives yet. A few comparison rounds will change that."})}),e.jsxs("div",{className:"border-t border-white/8 pt-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Biggest unknowns"}),e.jsx("div",{className:"mt-3 grid gap-2",children:We.length>0?We.map(t=>{var s;return e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-3 py-3 text-sm text-white/58",children:[e.jsx("div",{className:"font-medium text-white",children:((s=t.item)==null?void 0:s.label)??t.itemId}),e.jsxs("div",{className:"mt-1",children:["Uncertainty ",B(t.uncertainty)]})]},t.itemId)}):e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] px-3 py-3 text-sm text-white/58",children:"The current unknown list is short."})})]})]})]}),e.jsxs(v,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Bring in Forge records"}),e.jsx("div",{className:"mt-1 text-sm text-white/54",children:"Search goals, projects, tasks, strategies, or habits across human and bot users, then send them straight into this model."})]}),e.jsxs(y,{className:"bg-white/[0.08] text-white/70",children:[Se.length," visible"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(se,{className:"size-4 text-white/38"}),e.jsx(x,{value:de,onChange:t=>dt(t.target.value),placeholder:"Search across owners, handles, user kind, title, and description"})]}),e.jsx("div",{className:"grid gap-2",children:Se.map(t=>e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-medium text-white",children:t.label}),e.jsx(y,{className:"bg-white/[0.08] text-white/70",children:t.entityType}),t.user?e.jsx(st,{user:t.user,compact:!0}):null]}),e.jsx("div",{className:"mt-1 text-sm text-white/52",children:t.description||"No description yet."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.href?e.jsx(ue,{to:t.href,children:e.jsx(o,{variant:"ghost",size:"sm",children:"Open"})}):null,e.jsx(o,{variant:"secondary",size:"sm",pending:ke.isPending,pendingLabel:"Adding",onClick:()=>void ke.mutateAsync({userId:m,domain:w,entityType:t.entityType,entityId:t.entityId,label:t.label,description:t.description,tags:[]}),children:"Add to model"})]})]},`${t.entityType}-${t.entityId}`))})]})]}):null,S==="map"?e.jsxs(v,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Full map"}),e.jsx("div",{className:"mt-1 text-sm text-white/54",children:"Click a point to inspect why Forge believes it belongs there."})]}),e.jsxs("div",{className:"text-sm text-white/52",children:[i.map.length," plotted items"]})]}),e.jsxs("div",{className:"relative min-h-[520px] overflow-hidden rounded-[24px] border border-white/8 bg-[radial-gradient(circle_at_20%_20%,rgba(87,196,138,0.2),transparent_25%),radial-gradient(circle_at_80%_80%,rgba(255,104,130,0.2),transparent_26%),linear-gradient(180deg,rgba(255,255,255,0.03),rgba(255,255,255,0.01))]",children:[e.jsx("div",{className:"absolute inset-x-0 top-1/2 h-px bg-white/8"}),e.jsx("div",{className:"absolute inset-y-0 left-1/2 w-px bg-white/8"}),i.map.map(t=>e.jsx("button",{type:"button",className:$("absolute -translate-x-1/2 -translate-y-1/2 rounded-full border px-3 py-1 text-xs transition hover:scale-[1.04]",t.itemId===(d==null?void 0:d.itemId)?"border-white/30 bg-white/16 text-white":t.score>=0?"border-emerald-300/30 bg-emerald-500/14 text-emerald-100":"border-rose-300/30 bg-rose-500/14 text-rose-100"),style:{left:`${50+t.x*34}%`,top:`${50-t.y*34}%`,opacity:.45+t.confidence*.55},onClick:()=>{E(t.itemId),k({focusItem:t.itemId})},children:t.label},t.itemId))]})]}):null,S==="table"?e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.2fr)_380px]",children:[e.jsxs(v,{className:"grid gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(se,{className:"size-4 text-white/38"}),e.jsx(x,{value:le,onChange:t=>lt(t.target.value),placeholder:"Search learned items, explanations, tags, or dominant dimensions"})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full text-left text-sm",children:[e.jsx("thead",{className:"text-[11px] uppercase tracking-[0.14em] text-white/38",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2",children:"Item"}),e.jsx("th",{className:"px-3 py-2",children:"Score"}),e.jsx("th",{className:"px-3 py-2",children:"Confidence"}),e.jsx("th",{className:"px-3 py-2",children:"Status"}),e.jsx("th",{className:"px-3 py-2",children:"Evidence"})]})}),e.jsx("tbody",{children:pe.map(t=>{var s,l;return e.jsxs("tr",{className:$("cursor-pointer border-t border-white/6 transition hover:bg-white/[0.04]",t.itemId===(d==null?void 0:d.itemId)?"bg-white/[0.05]":""),onClick:()=>{E(t.itemId),k({focusItem:t.itemId})},children:[e.jsxs("td",{className:"px-3 py-3",children:[e.jsx("div",{className:"font-medium text-white",children:((s=t.item)==null?void 0:s.label)??t.itemId}),e.jsx("div",{className:"text-xs text-white/48",children:(((l=t.item)==null?void 0:l.tags)??[]).join(" · ")})]}),e.jsx("td",{className:"px-3 py-3 text-white/68",children:t.latentScore.toFixed(2)}),e.jsx("td",{className:"px-3 py-3 text-white/68",children:B(t.confidence)}),e.jsx("td",{className:"px-3 py-3",children:e.jsx(y,{className:it[re(t)],children:re(t)})}),e.jsx("td",{className:"px-3 py-3 text-white/68",children:t.evidenceCount})]},t.itemId)})})]})})]}),e.jsxs(v,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Item editor"}),d!=null&&d.item?e.jsxs(e.Fragment,{children:[e.jsx(x,{value:p.label,onChange:t=>C(s=>({...s,label:t.target.value})),placeholder:"Item label"}),e.jsx(T,{value:p.description,onChange:t=>C(s=>({...s,description:t.target.value})),className:"min-h-24",placeholder:"Item description"}),e.jsx(x,{value:p.tags,onChange:t=>C(s=>({...s,tags:t.target.value})),placeholder:"comma, separated, tags"}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("select",{value:p.manualStatus,onChange:t=>C(s=>({...s,manualStatus:t.target.value})),className:"min-h-10 rounded-[18px] border border-white/8 bg-white/[0.05] px-3 text-sm text-white outline-none",children:[e.jsx("option",{value:"",children:"Inferred status"}),Object.keys(it).map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsx(x,{value:p.manualScore,onChange:t=>C(s=>({...s,manualScore:t.target.value})),placeholder:"Manual score"}),e.jsx(x,{value:p.confidenceLock,onChange:t=>C(s=>({...s,confidenceLock:t.target.value})),placeholder:"Confidence lock 0-1"})]}),e.jsx("div",{className:"grid gap-2",children:Object.keys(ie).map(t=>e.jsxs("div",{className:"grid grid-cols-[110px_minmax(0,1fr)] items-center gap-3",children:[e.jsx("div",{className:"text-sm text-white/56",children:ve[t]}),e.jsx(x,{value:p.featureWeights[t],onChange:s=>C(l=>({...l,featureWeights:{...l.featureWeights,[t]:s.target.value}}))})]},t))}),e.jsx("div",{className:"grid gap-2 text-sm text-white/58",children:[["bookmarked","Bookmarked"],["compareLater","Compare later"],["frozen","Frozen"]].map(([t,s])=>e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:p[t],onChange:l=>C(n=>({...n,[t]:l.target.checked}))}),e.jsx("span",{children:s})]},t))}),e.jsx(o,{pending:Ee.isPending,pendingLabel:"Saving item",onClick:()=>void Ee.mutateAsync(),children:"Save item model"}),Re?e.jsx(ue,{className:"text-sm text-[var(--primary)]",to:Re,children:"Open linked entity"}):null]}):e.jsx("div",{className:"text-sm text-white/52",children:"Select a row to inspect or edit it."}),e.jsxs("div",{className:"mt-3 border-t border-white/8 pt-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Add custom item"}),e.jsxs("div",{className:"mt-3 grid gap-3",children:[e.jsx(x,{value:M.label,onChange:t=>Y(s=>({...s,label:t.target.value})),placeholder:"Custom item label"}),e.jsx(T,{value:M.description,onChange:t=>Y(s=>({...s,description:t.target.value})),className:"min-h-24",placeholder:"What is this preference item?"}),e.jsx(x,{value:M.tags,onChange:t=>Y(s=>({...s,tags:t.target.value})),placeholder:"comma, separated, tags"}),e.jsx(o,{disabled:!M.label.trim(),pending:Fe.isPending,pendingLabel:"Creating item",onClick:()=>void Fe.mutateAsync({userId:m,domain:w,label:M.label,description:M.description,tags:M.tags.split(",").map(t=>t.trim()).filter(Boolean),featureWeights:ie,queueForCompare:!0}),children:"Create custom item"})]})]})]})]}):null,S==="history"?e.jsxs("div",{className:"grid gap-5 xl:grid-cols-3",children:[e.jsxs(v,{className:"grid gap-3 xl:col-span-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Recent pairwise judgments"}),e.jsx("div",{className:"grid gap-2",children:i.history.judgments.slice(0,12).map(t=>{var n,r,b,G;const s=((r=(n=i.scores.find(O=>O.itemId===t.leftItemId))==null?void 0:n.item)==null?void 0:r.label)??t.leftItemId,l=((G=(b=i.scores.find(O=>O.itemId===t.rightItemId))==null?void 0:b.item)==null?void 0:G.label)??t.rightItemId;return e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3 text-sm text-white/58",children:[e.jsxs("div",{className:"font-medium text-white",children:[s," vs ",l]}),e.jsxs("div",{className:"mt-1",children:["Outcome ",t.outcome," · strength"," ",t.strength," ·"," ",new Date(t.createdAt).toLocaleString()]})]},t.id)})})]}),e.jsxs(v,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Signals and snapshots"}),e.jsx("div",{className:"grid gap-2",children:i.history.signals.slice(0,8).map(t=>{var l,n;const s=((n=(l=i.scores.find(r=>r.itemId===t.itemId))==null?void 0:l.item)==null?void 0:n.label)??t.itemId;return e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-3 py-2 text-sm text-white/58",children:[s," · ",t.signalType," ·"," ",new Date(t.createdAt).toLocaleString()]},t.id)})}),e.jsx("div",{className:"grid gap-2",children:i.history.snapshots.slice(0,5).map(t=>e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-3 py-2 text-sm text-white/58",children:["Snapshot ",new Date(t.createdAt).toLocaleString()]},t.id))}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-3 py-3 text-sm text-white/58",children:["Stale items: ",i.history.staleItemIds.length," · Flipped items: ",i.history.flippedItemIds.length]})]})]}):null,S==="contexts"?e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.1fr)_360px]",children:[e.jsx("div",{className:"grid gap-4",children:i.contexts.map(t=>e.jsxs(v,{className:"grid gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-display text-2xl text-white",children:t.name}),e.jsx("div",{className:"text-sm text-white/54",children:t.description||"No description yet."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.isDefault?e.jsx(y,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:"Default"}):null,e.jsx(y,{className:"bg-white/[0.08] text-white/70",children:t.shareMode}),t.active?null:e.jsx(y,{className:"bg-amber-500/12 text-amber-200",children:"Inactive"})]})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-4",children:[e.jsx(x,{value:t.name,onChange:s=>void z.mutateAsync({contextId:t.id,patch:{name:s.target.value}}),placeholder:"Context name"}),e.jsxs("select",{value:t.shareMode,onChange:s=>void z.mutateAsync({contextId:t.id,patch:{shareMode:s.target.value}}),className:"min-h-10 rounded-[18px] border border-white/8 bg-white/[0.05] px-3 text-sm text-white outline-none",children:[e.jsx("option",{value:"shared",children:"shared"}),e.jsx("option",{value:"blended",children:"blended"}),e.jsx("option",{value:"isolated",children:"isolated"})]}),e.jsx(x,{value:String(t.decayDays),onChange:s=>void z.mutateAsync({contextId:t.id,patch:{decayDays:Number(s.target.value||90)}}),placeholder:"Decay days"}),e.jsx(o,{variant:"secondary",onClick:()=>k({contextId:t.id,tab:"overview"}),children:"Open context"})]}),e.jsx(T,{value:t.description,onChange:s=>void z.mutateAsync({contextId:t.id,patch:{description:s.target.value}}),className:"min-h-20"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(o,{variant:"secondary",onClick:()=>void z.mutateAsync({contextId:t.id,patch:{active:!t.active}}),children:t.active?"Deactivate":"Activate"}),t.isDefault?null:e.jsx(o,{variant:"secondary",onClick:()=>void z.mutateAsync({contextId:t.id,patch:{isDefault:!0}}),children:"Make default"})]})]},t.id))}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs(v,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Create context"}),e.jsx(x,{value:I.name,onChange:t=>q(s=>({...s,name:t.target.value})),placeholder:"Context name"}),e.jsx(T,{value:I.description,onChange:t=>q(s=>({...s,description:t.target.value})),className:"min-h-24",placeholder:"What changes in this context?"}),e.jsxs("select",{value:I.shareMode,onChange:t=>q(s=>({...s,shareMode:t.target.value})),className:"min-h-10 rounded-[18px] border border-white/8 bg-white/[0.05] px-3 text-sm text-white outline-none",children:[e.jsx("option",{value:"blended",children:"blended"}),e.jsx("option",{value:"shared",children:"shared"}),e.jsx("option",{value:"isolated",children:"isolated"})]}),e.jsx(x,{value:I.decayDays,onChange:t=>q(s=>({...s,decayDays:t.target.value})),placeholder:"Decay days"}),e.jsx(o,{disabled:!I.name.trim(),pending:_e.isPending,pendingLabel:"Creating context",onClick:()=>void _e.mutateAsync({userId:m,domain:w,name:I.name,description:I.description,shareMode:I.shareMode,decayDays:Number(I.decayDays||90),active:!0,isDefault:!1}),children:"Create context"})]}),e.jsxs(v,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Merge contexts"}),e.jsxs("select",{value:K,onChange:t=>fe(t.target.value),className:"min-h-10 rounded-[18px] border border-white/8 bg-white/[0.05] px-3 text-sm text-white outline-none",children:[e.jsx("option",{value:"",children:"Source context"}),i.contexts.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]}),e.jsxs("select",{value:J,onChange:t=>je(t.target.value),className:"min-h-10 rounded-[18px] border border-white/8 bg-white/[0.05] px-3 text-sm text-white outline-none",children:[e.jsx("option",{value:"",children:"Target context"}),i.contexts.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]}),e.jsx(o,{pending:ze.isPending,pendingLabel:"Merging",disabled:!K||!J||K===J,onClick:()=>void ze.mutateAsync({sourceContextId:K,targetContextId:J}),children:"Merge into target"})]})]})]}):null,S==="concepts"?e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.1fr)_380px]",children:[e.jsxs(v,{className:"grid gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Concept libraries"}),e.jsx("div",{className:"mt-1 text-sm text-white/54",children:"These are the lists Forge can use when you start the game in a concept domain. Seeded lists are editable, and custom lists are fully yours."})]}),e.jsx("div",{className:"grid gap-3 md:grid-cols-4",children:[["Lists",i.libraries.totalCatalogs],["Concepts",i.libraries.totalCatalogItems],["Seeded",i.libraries.seededCatalogCount],["Custom",i.libraries.customCatalogCount]].map(([t,s])=>e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:t}),e.jsx("div",{className:"mt-2 font-display text-3xl text-white",children:s})]},t))}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(se,{className:"size-4 text-white/38"}),e.jsx(x,{value:D,onChange:t=>be(t.target.value),placeholder:"Search lists, concepts, tags, and seeded domains"})]})]}),e.jsxs(v,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Create concept list"}),e.jsx(x,{value:R.title,onChange:t=>oe(s=>({...s,title:t.target.value})),placeholder:"List title"}),e.jsx(T,{value:R.description,onChange:t=>oe(s=>({...s,description:t.target.value})),className:"min-h-24",placeholder:"What should this list help compare?"}),e.jsx(o,{disabled:!R.title.trim(),pending:Pe.isPending,pendingLabel:"Creating list",onClick:()=>void Pe.mutateAsync({userId:m,domain:w,title:R.title,description:R.description}),children:"Create list"})]})]}),e.jsx("div",{className:"grid gap-4",children:ge.map(t=>{const s=ot[t.id]??{label:"",description:"",tags:""},l=t.items.filter(n=>D.trim()?[n.label,n.description,n.tags.join(" ")].join(" ").toLowerCase().includes(ne(D)):!0);return e.jsxs(v,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsx("div",{className:"min-w-0",children:Ne===t.id?e.jsxs("div",{className:"grid gap-3",children:[e.jsx(x,{value:Z.title,onChange:n=>he(r=>({...r,title:n.target.value}))}),e.jsx(T,{value:Z.description,onChange:n=>he(r=>({...r,description:n.target.value})),className:"min-h-24"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"font-display text-2xl text-white",children:t.title}),e.jsx(y,{className:"bg-white/[0.08] text-white/70",children:t.source}),e.jsxs(y,{className:"bg-white/[0.08] text-white/70",children:[t.items.length," items"]})]}),e.jsx("div",{className:"mt-1 text-sm text-white/54",children:t.description||"No description yet."})]})}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(o,{variant:"secondary",size:"sm",onClick:()=>void $e(w,t.id),children:"Start from this list"}),Ne===t.id?e.jsxs(e.Fragment,{children:[e.jsx(o,{size:"sm",pending:Le.isPending,pendingLabel:"Saving",onClick:()=>void Le.mutateAsync({catalogId:t.id,patch:{title:Z.title,description:Z.description}}),children:"Save"}),e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>me(null),children:"Cancel"})]}):e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>{me(t.id),he({title:t.title,description:t.description})},children:"Edit list"}),e.jsx(o,{variant:"ghost",size:"sm",pending:Te.isPending,pendingLabel:"Deleting",onClick:()=>void Te.mutateAsync(t.id),children:"Delete list"})]})]}),e.jsx("div",{className:"grid gap-2",children:l.map(n=>e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:mt===n.id?e.jsxs("div",{className:"grid gap-3",children:[e.jsx(x,{value:_.label,onChange:r=>V(b=>({...b,label:r.target.value}))}),e.jsx(T,{value:_.description,onChange:r=>V(b=>({...b,description:r.target.value})),className:"min-h-20"}),e.jsx(x,{value:_.tags,onChange:r=>V(b=>({...b,tags:r.target.value})),placeholder:"comma, separated, tags"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(o,{size:"sm",pending:Ae.isPending,pendingLabel:"Saving",onClick:()=>void Ae.mutateAsync({catalogItemId:n.id,patch:{label:_.label,description:_.description,tags:_.tags.split(",").map(r=>r.trim()).filter(Boolean)}}),children:"Save concept"}),e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>xe(null),children:"Cancel"})]})]}):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-medium text-white",children:n.label}),e.jsx("div",{className:"mt-1 text-sm text-white/54",children:n.description||"No description yet."}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:n.tags.map(r=>e.jsx(y,{className:"bg-white/[0.08] text-white/70",children:r},`${n.id}-${r}`))})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>{xe(n.id),V({label:n.label,description:n.description,tags:n.tags.join(", ")})},children:"Edit"}),e.jsxs(o,{variant:"ghost",size:"sm",pending:De.isPending,pendingLabel:"Deleting",onClick:()=>void De.mutateAsync(n.id),children:[e.jsx(St,{className:"mr-1 size-4"}),"Delete"]})]})]})},n.id))}),e.jsxs("div",{className:"grid gap-3 rounded-[18px] border border-white/8 bg-white/[0.02] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-white/68",children:[e.jsx(kt,{className:"size-4"}),"Add concept to ",t.title]}),e.jsx(x,{value:s.label,onChange:n=>X(r=>({...r,[t.id]:{...s,label:n.target.value}})),placeholder:"Concept label"}),e.jsx(T,{value:s.description,onChange:n=>X(r=>({...r,[t.id]:{...s,description:n.target.value}})),className:"min-h-20",placeholder:"Short description"}),e.jsx(x,{value:s.tags,onChange:n=>X(r=>({...r,[t.id]:{...s,tags:n.target.value}})),placeholder:"comma, separated, tags"}),e.jsx(o,{disabled:!s.label.trim(),pending:Me.isPending,pendingLabel:"Adding",onClick:()=>void Me.mutateAsync({catalogId:t.id,label:s.label,description:s.description,tags:s.tags.split(",").map(n=>n.trim()).filter(Boolean),featureWeights:ie}).then(()=>X(n=>({...n,[t.id]:{label:"",description:"",tags:""}}))),children:"Add concept"})]})]},t.id)})})]}):null]}),e.jsx(Pt,{open:f.open,onOpenChange:t=>{t||P(null),F(s=>({...s,open:t}))},children:e.jsxs(Lt,{children:[e.jsx(Tt,{className:"fixed inset-0 z-40 bg-[rgba(4,8,18,0.74)] backdrop-blur-xl"}),e.jsxs(Mt,{className:"fixed inset-x-4 bottom-4 top-4 z-50 overflow-y-auto rounded-[32px] border border-white/10 bg-[linear-gradient(180deg,rgba(17,24,39,0.98),rgba(10,14,24,0.98))] shadow-[0_30px_90px_rgba(3,8,18,0.45)] md:inset-x-10 lg:left-1/2 lg:right-auto lg:w-[min(72rem,calc(100vw-3rem))] lg:-translate-x-1/2",children:[e.jsx(At,{className:"sr-only",children:"Preference game"}),e.jsx(Dt,{className:"sr-only",children:"Start comparison rounds from a Forge domain or concept list."}),e.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between gap-4 border-b border-white/8 bg-[rgba(10,14,24,0.92)] px-5 py-4 backdrop-blur-xl",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Preference game"}),e.jsx("div",{className:"mt-1 font-display text-2xl text-white",children:f.phase==="domain"?"Choose a domain":f.phase==="catalog"?"Choose a concept list":"Pick the better fit"})]}),e.jsx(Et,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":"Close preference game",className:"rounded-full bg-white/6 p-2 text-white/65 transition hover:bg-white/10 hover:text-white",children:e.jsx(Ft,{className:"size-4"})})})]}),e.jsxs("div",{className:"grid gap-5 px-5 py-5",children:[we?e.jsx("div",{className:"rounded-[18px] border border-rose-400/25 bg-rose-500/10 px-4 py-3 text-sm text-rose-100",children:we}):null,f.phase==="domain"?e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:ae.map(t=>e.jsxs("button",{type:"button",className:"rounded-[24px] border border-white/8 bg-white/[0.04] px-5 py-5 text-left transition hover:border-[var(--primary)]/30 hover:bg-[var(--primary)]/10",onClick:()=>void ut(t.value),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-white",children:t.label}),e.jsx(y,{className:"bg-white/[0.08] text-white/70",children:t.mode==="forge"?"Forge":"Concept"})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/56",children:t.description})]},t.value))}):null,f.phase==="catalog"?e.jsxs("div",{className:"grid gap-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Pick the concept list Forge should draw from. You do not need to assemble the items yourself."}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(se,{className:"size-4 text-white/38"}),e.jsx(x,{value:D,onChange:t=>be(t.target.value),placeholder:"Search concept lists"})]}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:ge.length>0?ge.map(t=>e.jsxs("button",{type:"button",className:"rounded-[24px] border border-white/8 bg-white/[0.04] px-5 py-5 text-left transition hover:border-[var(--primary)]/30 hover:bg-[var(--primary)]/10",onClick:()=>void $e(f.domain,t.id),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-white",children:t.title}),e.jsxs(y,{className:"bg-white/[0.08] text-white/70",children:[t.items.length," items"]})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/56",children:t.description||"No description yet."})]},t.id)):e.jsx("div",{className:"rounded-[24px] bg-white/[0.04] px-5 py-6 text-sm text-white/58",children:"No concept list matches that search yet."})})]}):null,f.phase==="play"?e.jsx("div",{className:"grid gap-5",children:ct||Ie.isLoading?e.jsx(tt,{eyebrow:"Preference game",title:"Preparing the next round",description:"Forge is lining up comparison candidates."}):A?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-white/52",children:[e.jsx(y,{className:"bg-white/[0.08] text-white/70",children:((Ke=ae.find(t=>t.value===f.domain))==null?void 0:Ke.label)??f.domain}),e.jsx("span",{children:g==null?void 0:g.selectedContext.name}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[(g==null?void 0:g.compare.pendingCount)??0," ","queued comparisons"]})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(nt,{title:A.left.label,description:A.left.description,sideLabel:"Left",onClick:()=>void L("left",1)}),e.jsx(nt,{title:A.right.label,description:A.right.description,sideLabel:"Right",onClick:()=>void L("right",1)})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(o,{onClick:()=>void L("left",1),children:"Left"}),e.jsx(o,{onClick:()=>void L("right",1),children:"Right"}),e.jsx(o,{variant:"secondary",onClick:()=>void L("left",1.75),children:"Strong left"}),e.jsx(o,{variant:"secondary",onClick:()=>void L("right",1.75),children:"Strong right"}),e.jsx(o,{variant:"secondary",onClick:()=>void L("tie",1),children:"Tie"}),e.jsx(o,{variant:"secondary",onClick:()=>void L("skip",1),children:"Skip"})]}),e.jsx("div",{className:"grid gap-4 rounded-[24px] border border-white/8 bg-white/[0.03] px-4 py-4 lg:grid-cols-2",children:[A.left,A.right].map(t=>e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"font-medium text-white",children:t.label}),e.jsx("div",{className:"text-sm text-white/56",children:"Quick signals"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ns.map(s=>e.jsx(o,{variant:"secondary",size:"sm",onClick:()=>void vt(t.id,s.signalType),children:s.label},`${t.id}-${s.signalType}`))})]},t.id))})]}):e.jsx(et,{eyebrow:"Preference game",title:"No pair is ready yet",description:"Forge needs more items in this domain before it can keep asking comparisons."})}):null]})]})]})})]})}export{js as PreferencesPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as i}from"./vendor-DHkYh85p.js";import{Z as l}from"./index-BHTUu_4M.js";const r={active:"Active",paused:"Suspended",completed:"Finished",all:"All"};function d({value:e,counts:t,onChange:s,className:o}){return i.jsx("div",{className:l("flex flex-wrap gap-2",o),children:Object.keys(r).map(n=>{const a=n===e;return i.jsxs("button",{type:"button",onClick:()=>s(n),className:l("inline-flex min-h-10 items-center gap-2 rounded-full border px-4 py-2 text-sm transition",a?"border-[rgba(192,193,255,0.28)] bg-[rgba(192,193,255,0.16)] text-white shadow-[0_16px_36px_rgba(8,12,24,0.18)]":"border-white/8 bg-white/[0.04] text-white/62 hover:bg-white/[0.08] hover:text-white"),children:[i.jsx("span",{children:r[n]}),i.jsx("span",{className:l("rounded-full px-2 py-0.5 text-[11px]",a?"bg-white/12 text-white/88":"bg-white/8 text-white/54"),children:t[n]})]},n)})})}function h(e){return{active:e.filter(t=>t.status==="active").length,paused:e.filter(t=>t.status==="paused").length,completed:e.filter(t=>t.status==="completed").length,all:e.length}}function x(e,t){return t==="all"?e:e.filter(s=>s.status===t)}export{d as P,h as b,x as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{cc as ee,b5 as te,r as k,j as e,aC as j}from"./vendor-DHkYh85p.js";import{j as se,i as F,k as w}from"./state-B-4sS1xO.js";import{S as ae}from"./scheduling-rules-editor-BHOpHOrV.js";import{P as ie,u as re,s as oe,i as y,ay as ne,at as ce,bO as le,bP as de,as as pe,E as me,S as xe,a8 as je,b as v,V as ue,U,C as u,B as m,c as h,Y as he,az as ge,bQ as we,N as ye}from"./index-BHTUu_4M.js";import{O as ve}from"./open-in-graph-button-Cg5VrKsC.js";import{P as fe}from"./project-management-section-nav-C2Ud8Zdd.js";import{e as be,W as ke}from"./calendar-rules-DA1g3QUk.js";import{E as Ne}from"./execution-board-CDRXQB85.js";import{N as H}from"./note-markdown-DiW2-5d3.js";import{E as Ie}from"./entity-notes-surface-DgEgicaE.js";import{P as De}from"./preference-entity-handoff-button-D4WAs9pC.js";import{P as Se}from"./page-hero-CQWo1Mm_.js";import{g as Pe,a as qe}from"./activity-copy-Bj4h9OcF.js";import{g as Qe}from"./entity-links-DwpxhW2H.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";import"./entity-note-count-link-BmGDB572.js";import"./floating-action-menu-CJkI2iFy.js";import"./note-tags-input-DDLXf54U.js";function Te(a){return!!(a&&a.startsWith("campaign:"))}function et(){var M;const{t:a}=ie(),i=re(),N=Array.isArray(i.selectedUserIds)?i.selectedUserIds:[],o=ee(),K=te(),r=se(),[W,C]=k.useState(!1),[G,E]=k.useState(!1),[_,R]=k.useState(!1),[I]=k.useState(()=>{const t=new Date,l=new Date(t);l.setHours(0,0,0,0);const $=new Date(t);return $.setHours(23,59,59,999),{from:l.toISOString(),to:$.toISOString()}}),D=oe(N),c=i.snapshot.dashboard.projects.find(t=>t.id===o.projectId)??null,A=c?i.snapshot.goals.find(t=>t.id===c.goalId)??null:null,O=c?i.snapshot.tasks.filter(t=>t.projectId===c.id||!t.projectId&&t.goalId===c.goalId):[],B=new Set(O.map(t=>t.id)),z=c?i.snapshot.activity.filter(t=>t.entityId===c.goalId||t.entityId===c.id||B.has(t.entityId)||t.entityType==="task_run"&&typeof t.metadata.taskId=="string"&&B.has(t.metadata.taskId)):[],n=Te(o.projectId),f=F({queryKey:["project-board",o.projectId],queryFn:()=>we(o.projectId),enabled:!!o.projectId&&!n}),V=F({queryKey:["project-calendar-overview",o.projectId,I.from,I.to,...N],queryFn:()=>ye({...I,userIds:N}),enabled:!!o.projectId&&!n}),Y=w({mutationFn:t=>ne(t),onSuccess:async()=>{await Promise.all([y(r),r.invalidateQueries({queryKey:["project-board",o.projectId]})])}}),L=w({mutationFn:ce,onSuccess:async()=>{await Promise.all([y(r),r.invalidateQueries({queryKey:["project-board",o.projectId]}),r.invalidateQueries({queryKey:["forge-xp-metrics"]}),r.invalidateQueries({queryKey:["forge-reward-ledger"]}),r.invalidateQueries({queryKey:["forge-operator-context"]})])}}),g=w({mutationFn:t=>le(o.projectId,{status:t}),onSuccess:async()=>{await Promise.all([y(r),r.invalidateQueries({queryKey:["project-board",o.projectId]}),r.invalidateQueries({queryKey:["forge-xp-metrics"]}),r.invalidateQueries({queryKey:["forge-reward-ledger"]}),r.invalidateQueries({queryKey:["forge-operator-context"]})])}}),S=w({mutationFn:()=>de(o.projectId),onSuccess:async()=>{await Promise.all([y(r),r.invalidateQueries({queryKey:["project-board",o.projectId]})]),K("/projects")}}),J=w({mutationFn:t=>pe(t),onSuccess:async()=>{await Promise.all([y(r),r.invalidateQueries({queryKey:["project-board",o.projectId]}),r.invalidateQueries({queryKey:["task-context"]})])}}),s=f.data??(c&&A?{project:c,goal:A,tasks:O,activity:z}:void 0),b=i.snapshot.dashboard.projects.find(t=>t.id===o.projectId)??null;if(f.isError&&!n)return e.jsx(me,{eyebrow:a("common.projectDetail.errorEyebrow"),error:f.error,onRetry:()=>void f.refetch()});if(!s)return e.jsx(xe,{});const d=s.tasks.find(t=>t.status==="focus"||t.status==="in_progress")??s.tasks[0]??null,p=s.tasks.find(t=>t.status==="blocked")??s.tasks.find(t=>t.status==="backlog")??null;s.activity[0];const X="notesSummaryByEntity"in s?s.notesSummaryByEntity:i.snapshot.dashboard.notesSummaryByEntity,P=g.isPending||S.isPending,x=be({rules:s.project.schedulingRules,overview:(M=V.data)==null?void 0:M.calendar}),q=i.snapshot.strategies.filter(t=>t.targetGoalIds.includes(s.goal.id)),Q=i.snapshot.strategies.filter(t=>t.targetProjectIds.includes(s.project.id)),T=async t=>{await g.mutateAsync(t)},Z=async()=>{window.confirm(a("common.projectDetail.deleteProjectConfirm",{title:s.project.title}))&&await S.mutateAsync()};return e.jsxs("div",{className:"grid min-w-0 gap-5",children:[e.jsx(fe,{}),e.jsx(Se,{entityKind:"project",title:e.jsx(ue,{kind:"project",label:s.project.title,variant:"heading",size:"lg"}),titleText:s.project.title,description:s.project.description?e.jsx(H,{markdown:s.project.description,className:"[&>p]:text-[13px] [&>p]:leading-6 [&>blockquote]:text-[13px] [&>ul]:text-[13px] [&>ol]:text-[13px]"}):"No project description yet.",badge:e.jsx(v,{kind:"goal",label:s.goal.title,compact:!0,gradient:!1}),actions:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(je,{metrics:i.snapshot.metrics}),e.jsx(De,{userId:D,domain:"projects",entityType:"project",entityId:s.project.id,label:s.project.title,description:s.project.description}),e.jsx(ve,{entityType:"project",entityId:s.project.id})]})}),s.project.user?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-white/62",children:[e.jsx("span",{className:"text-white/42",children:"Owned by"}),e.jsx(U,{user:s.project.user}),s.project.assignees&&s.project.assignees.length>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-white/35",children:"Assigned with"}),e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:s.project.assignees.map(t=>e.jsx(U,{user:t,compact:!0},t.id))})]}):null]}):null,s.project.productRequirementsDocument?e.jsxs(u,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Product requirements document"}),e.jsx("div",{className:"mt-3",children:e.jsx(H,{markdown:s.project.productRequirementsDocument,className:"[&>p]:text-[13px] [&>p]:leading-6 [&>blockquote]:text-[13px] [&>ul]:text-[13px] [&>ol]:text-[13px]"})})]}):null,q.length>0||Q.length>0?e.jsxs(u,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Strategy stack"}),e.jsxs("div",{className:"mt-3 grid gap-3 lg:grid-cols-2",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-white/42",children:"Goal-level strategies"}),q.length===0?e.jsx("div",{className:"text-sm text-white/48",children:"No goal-level strategies linked yet."}):q.map(t=>e.jsxs(j,{to:`/strategies/${t.id}`,className:"rounded-[18px] border border-white/8 bg-white/[0.04] px-4 py-3 transition hover:bg-white/[0.07]",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:t.title}),e.jsx("div",{className:"mt-1 text-xs text-white/48",children:t.overview||t.endStateDescription})]},t.id))]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-white/42",children:"Project-level strategies"}),Q.length===0?e.jsx("div",{className:"text-sm text-white/48",children:"No lower-level strategies linked yet."}):Q.map(t=>e.jsxs(j,{to:`/strategies/${t.id}`,className:"rounded-[18px] border border-white/8 bg-white/[0.04] px-4 py-3 transition hover:bg-white/[0.07]",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:t.title}),e.jsx("div",{className:"mt-1 text-xs text-white/48",children:t.overview||t.endStateDescription})]},t.id))]})]})]}):null,n?e.jsxs(u,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:a("common.projectDetail.compatibility")}),e.jsx("p",{className:"mt-3 text-sm leading-7 text-white/60",children:a("common.projectDetail.compatibilityDescription")})]}):null,e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx(m,{onClick:()=>E(!0),children:a("common.projectDetail.addTask")}),n?null:e.jsx(m,{variant:"secondary",onClick:()=>R(!0),children:"Adjust work"}),n?null:e.jsx(m,{variant:"secondary",onClick:()=>C(!0),children:a("common.projectDetail.editProject")}),!n&&s.project.status==="active"?e.jsx(m,{variant:"secondary",pending:P&&g.variables==="paused",pendingLabel:a("common.projectDetail.suspending"),onClick:()=>void T("paused"),children:a("common.projectDetail.suspendProject")}):null,!n&&s.project.status!=="completed"?e.jsx(m,{pending:P&&g.variables==="completed",pendingLabel:a("common.projectDetail.finishing"),onClick:()=>void T("completed"),children:a("common.projectDetail.finishProject")}):null,!n&&s.project.status!=="active"?e.jsx(m,{variant:"secondary",pending:P&&g.variables==="active",pendingLabel:a("common.projectDetail.restarting"),onClick:()=>void T("active"),children:a("common.projectDetail.restartProject")}):null,n?null:e.jsx(m,{variant:"ghost",pending:S.isPending,pendingLabel:a("common.projectDetail.deleting"),onClick:()=>void Z(),children:a("common.projectDetail.deleteProject")}),e.jsx(j,{to:`/goals/${s.goal.id}`,children:e.jsx(m,{variant:"ghost",children:a("common.projectDetail.openGoal")})})]}),e.jsxs("section",{className:"grid min-w-0 gap-5 xl:grid-cols-[minmax(0,1fr)_22rem]",children:[e.jsxs(u,{children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:a("common.projectDetail.commandEyebrow")}),e.jsx("h2",{className:"mt-2 font-display text-[clamp(1.35rem,2vw,1.9rem)] text-white",children:a("common.projectDetail.commandTitle")}),e.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-6 text-white/60",children:a("common.projectDetail.commandDescription")})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(v,{kind:"project",compact:!0,gradient:!1}),e.jsx(v,{kind:"goal",label:s.goal.title,compact:!0,gradient:!1})]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 lg:grid-cols-2",children:[e.jsxs(j,{to:d?`/tasks/${d.id}`:`/projects/${s.project.id}`,className:"rounded-[20px] bg-white/[0.04] p-4 transition hover:bg-white/[0.08]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:a("common.projectDetail.signalNext")}),d?e.jsx(v,{kind:"task",compact:!0,gradient:!1}):null]}),e.jsx("div",{className:"mt-2 font-medium text-white",children:(d==null?void 0:d.title)??a("common.projectDetail.noNextTask")}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:(d==null?void 0:d.description)||a("common.projectDetail.noNextTaskDetail")})]}),e.jsxs(j,{to:p?`/tasks/${p.id}`:`/projects/${s.project.id}`,className:"rounded-[20px] bg-white/[0.04] p-4 transition hover:bg-white/[0.08]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:a("common.projectDetail.signalRisk")}),p?e.jsx(v,{kind:"task",compact:!0,gradient:!1}):null]}),e.jsx("div",{className:"mt-2 font-medium text-white",children:(p==null?void 0:p.title)??a("common.projectDetail.noRisk")}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:(p==null?void 0:p.description)||a("common.projectDetail.noRiskDetail")})]})]})]}),e.jsxs(u,{className:"h-fit min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:a("common.projectDetail.sectionHealth")}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(h,{className:"bg-white/[0.08] text-white/72",children:a(`common.enums.projectStatus.${s.project.status}`)}),e.jsx(h,{className:"bg-white/[0.08] text-white/72",children:s.project.momentumLabel}),e.jsxs(h,{className:"bg-white/[0.08] text-white/72",children:[Math.floor(s.project.time.totalCreditedSeconds/60)," min tracked"]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:a("common.projectDetail.fieldProgress")}),e.jsxs("div",{className:"mt-2 font-display text-xl text-white",children:[s.project.progress,"%"]})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:a("common.projectDetail.fieldMomentum")}),e.jsx("div",{className:"mt-2 font-display text-xl text-white",children:s.project.momentumLabel})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:a("common.projectDetail.fieldStatus")}),e.jsx("div",{className:"mt-2 font-display text-xl text-white",children:a(`common.enums.projectStatus.${s.project.status}`)})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Live tasks"}),e.jsx("div",{className:"mt-2 font-display text-xl text-white",children:s.tasks.filter(t=>t.status==="focus"||t.status==="in_progress").length})]})]})]})]}),n?null:e.jsxs("section",{className:"grid gap-5 xl:grid-cols-[minmax(0,1fr)_22rem]",children:[e.jsx(ae,{title:"Project scheduling defaults",subtitle:"Define the calendar contexts where work from this project is allowed or blocked. Tasks can inherit these defaults or override them.",initialRules:s.project.schedulingRules,saveLabel:"Save project scheduling",onSave:async({schedulingRules:t})=>{await i.patchProject(s.project.id,{schedulingRules:t}),await r.invalidateQueries({queryKey:["project-board",o.projectId]}),await r.invalidateQueries({queryKey:["project-calendar-overview",o.projectId]})}}),e.jsxs(u,{className:"h-fit min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Calendar status"}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(h,{className:x.tone==="blocked"?"bg-rose-500/14 text-rose-100":x.tone==="waiting"?"bg-amber-500/14 text-amber-100":"bg-emerald-500/14 text-emerald-100",children:x.label}),e.jsx(h,{className:"bg-white/[0.08] text-white/72",children:"Project defaults"})]}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-white/58",children:"These rules act as the default calendar gate for every task in the project unless a task sets its own override."}),x.context.length>0?e.jsxs("div",{className:"mt-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Current context"}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:x.context.map(t=>e.jsx(h,{className:"bg-white/[0.08] text-white/72",children:t},t))})]}):null,x.conflicts.length>0?e.jsx("div",{className:"mt-4 grid gap-2",children:x.conflicts.map(t=>e.jsx("div",{className:"rounded-[16px] bg-rose-500/10 px-3 py-2 text-sm text-rose-100",children:t},t))}):null,e.jsx("div",{className:"mt-4",children:e.jsx(j,{to:"/calendar",children:e.jsx(m,{variant:"secondary",children:"Open calendar workspace"})})})]})]}),e.jsx(Ne,{tasks:s.tasks,activeRuns:i.snapshot.activeTaskRuns,goals:i.snapshot.goals,tags:i.snapshot.tags,notesSummaryByEntity:X,selectedTaskId:null,onMove:async(t,l)=>{await i.patchTaskStatus(t,l),await r.invalidateQueries({queryKey:["project-board",o.projectId]})},onSelectTask:t=>K(`/tasks/${t}`),onStopTask:async t=>{await i.stopTaskRun(t),await r.invalidateQueries({queryKey:["project-board",o.projectId]}),await r.invalidateQueries({queryKey:["task-context",t.taskId]})},onQuickReopenTask:async t=>{await Y.mutateAsync(t)},onDeleteTask:async t=>{await J.mutateAsync(t)}}),n?null:e.jsx(Ie,{entityType:"project",entityId:s.project.id,title:"Project notes",description:"Keep rollout notes, checkpoints, and cross-task context attached to the project itself.",invalidateQueryKeys:[["project-board",o.projectId]]}),e.jsxs(u,{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:a("common.projectDetail.sectionEvidence")}),e.jsx("div",{className:"mt-4 grid gap-3 lg:grid-cols-2",children:s.activity.slice(0,6).map(t=>e.jsxs(j,{to:Qe(t)??`/activity?eventId=${t.id}`,className:"rounded-[18px] bg-white/[0.04] p-4 transition hover:bg-white/[0.08]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-white",children:Pe(t)}),e.jsx(h,{children:t.source})]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:qe(t)})]},t.id))})]}),e.jsx(he,{open:W,goals:i.snapshot.goals,users:i.snapshot.users,editingProject:b,defaultUserId:(b==null?void 0:b.userId)??D,onOpenChange:C,onSubmit:async(t,l)=>{l&&(await i.patchProject(l,t),await r.invalidateQueries({queryKey:["project-board",o.projectId]}))}}),e.jsx(ge,{open:G,goals:i.snapshot.goals,projects:i.snapshot.dashboard.projects,workItems:i.snapshot.workItems,tags:i.snapshot.tags,users:i.snapshot.users,editingTask:null,initialProjectId:n?null:s.project.id,defaultUserId:s.project.userId??D,onRefreshEntities:i.refresh,onOpenChange:E,onSubmit:async(t,l)=>{l?await i.patchTask(l,t):await i.createTask(t),await r.invalidateQueries({queryKey:["project-board",o.projectId]})}}),n?null:e.jsx(ke,{open:_,onOpenChange:R,entityType:"project",entityId:s.project.id,targetLabel:s.project.title,currentCreditedSeconds:s.project.time.totalCreditedSeconds,pending:L.isPending,onSubmit:async t=>{await L.mutateAsync(t)}})]})}export{et as ProjectDetailPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as x,j as s,cz as X,cx as Y,cA as Z,aC as J,aK as ee,b3 as se}from"./vendor-DHkYh85p.js";import{i as te}from"./state-B-4sS1xO.js";import{u as ae,c as v,U as R,b as D,L as re,E as ie,C as O,B,m as A,a as ne,aR as le,Z as F,bR as de}from"./index-BHTUu_4M.js";import{P as ce}from"./project-management-section-nav-C2Ud8Zdd.js";import{P as oe}from"./page-hero-CQWo1Mm_.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";const $={user:"user:",kind:"kind:"},q=["goal","strategy","project","issue","task","subtask"],L=[...q],P=["active","paused","completed","backlog","focus","in_progress","blocked","done"];function I(t){return t.trim().toLowerCase()}function ue(t){return t.reduce((i,n)=>{if(n.startsWith($.user))i.userIds.push(n.slice($.user.length));else if(n.startsWith($.kind)){const o=n.slice($.kind.length);(o==="human"||o==="bot")&&i.kinds.push(o)}return i},{userIds:[],kinds:[]})}function he(t,i){return`${i}:${I(t)}`}function pe(t){const i=t.trim();return i.length===0?[]:["any",...q].map(n=>({id:he(i,n),query:i,kind:n}))}function ge(t){switch(t){case"done":case"completed":return 1;case"in_progress":case"active":return .66;case"focus":return .45;case"blocked":return .5;case"paused":return .28;default:return .08}}function C(t,i){const n=t.replace(/\s+/g," ").trim();return n.length===0?i:n}function M(t){const i=(t.children??[]).map(M);if(t.kind==="project")return{...t,children:i,progressPercent:t.progressPercent,progressLabel:t.progressLabel??(typeof t.progressPercent=="number"?`${t.progressPercent}% complete`:null)};if(i.length>0){const o=i.map(p=>p.progressPercent).filter(p=>typeof p=="number");if(o.length>0){const p=Math.round(o.reduce((j,h)=>j+h,0)/o.length);return{...t,children:i,progressPercent:p,progressLabel:`${i.length} child item${i.length===1?"":"s"}`}}}const n=Math.round(ge(t.statusLabel)*100);return{...t,children:i,progressPercent:n,progressLabel:t.statusLabel?t.statusLabel.replaceAll("_"," "):null}}function V(t){const{goals:i,strategies:n,projects:o,workItems:p,tagNameById:j}=t,h=new Map,f=new Map,g=new Map;for(const e of p)if(e.parentWorkItemId){const r=h.get(e.parentWorkItemId)??[];r.push(e),h.set(e.parentWorkItemId,r)}else if(e.level==="issue"&&e.projectId){const r=f.get(e.projectId)??[];r.push(e),f.set(e.projectId,r)}else if(e.projectId){const r=g.get(e.projectId)??[];r.push(e),g.set(e.projectId,r)}const b=e=>{var r;return M({id:`${e.level}:${e.id}`,entityId:e.id,kind:e.level,label:e.title,description:C(e.description,e.level==="issue"?"Vertical slice issue":e.level==="subtask"?"Granular child step":"Focused AI session task"),searchText:I([e.title,e.description,e.aiInstructions,e.executionMode??"",e.status,((r=e.user)==null?void 0:r.displayName)??"",...(e.assignees??[]).map(c=>c.displayName),...e.tagIds.map(c=>j.get(c)??"")].join(" ")),href:`/tasks/${e.id}`,statusLabel:e.status,executionMode:e.executionMode,goalId:e.goalId,projectId:e.projectId,tagIds:e.tagIds,user:e.user,assignees:e.assignees??[],linkedUserIds:[...e.user?[e.user.id]:[],...e.assigneeUserIds??[]],progressPercent:null,progressLabel:null,children:(h.get(e.id)??[]).map(b)})},w=e=>{var c;const r=n.filter(d=>d.targetProjectIds.includes(e.id));return M({id:`project:${e.id}`,entityId:e.id,kind:"project",label:e.title,description:C(e.description||e.productRequirementsDocument,"PRD-backed initiative"),searchText:I([e.title,e.description,e.productRequirementsDocument,e.goalTitle,e.workflowStatus,e.status,((c=e.user)==null?void 0:c.displayName)??"",...(e.assignees??[]).map(d=>d.displayName)].join(" ")),href:`/projects/${e.id}`,statusLabel:e.workflowStatus,executionMode:null,goalId:e.goalId,projectId:e.id,tagIds:[],user:e.user,assignees:e.assignees??[],linkedUserIds:[...e.user?[e.user.id]:[],...e.assigneeUserIds??[]],progressPercent:e.progress,progressLabel:`${e.completedTaskCount}/${e.totalTasks} done`,children:[...r.map(d=>{var m;return M({id:`strategy:${d.id}`,entityId:d.id,kind:"strategy",label:d.title,description:C(d.overview||d.endStateDescription,"Execution strategy"),searchText:I([d.title,d.overview,d.endStateDescription,d.status,((m=d.user)==null?void 0:m.displayName)??""].join(" ")),href:`/strategies/${d.id}`,statusLabel:d.status,executionMode:null,goalId:e.goalId,projectId:e.id,tagIds:[],user:d.user,assignees:[],linkedUserIds:d.user?[d.user.id]:[],progressPercent:null,progressLabel:null,children:[]})}),...(f.get(e.id)??[]).map(b),...(g.get(e.id)??[]).map(b)]})};return i.map(e=>{var _,N;const r=o.filter(l=>l.goalId===e.id),c=n.filter(l=>l.targetGoalIds.includes(e.id)),d=new Map(c.map(l=>[l.id,[]])),m=new Set;for(const l of r){const y=c.find(U=>U.targetProjectIds.includes(l.id));y&&((_=d.get(y.id))==null||_.push(l),m.add(l.id))}const T=c.map(l=>{var y;return M({id:`strategy:${l.id}`,entityId:l.id,kind:"strategy",label:l.title,description:C(l.overview||l.endStateDescription,"High-level strategy"),searchText:I([l.title,l.overview,l.endStateDescription,l.status,((y=l.user)==null?void 0:y.displayName)??""].join(" ")),href:`/strategies/${l.id}`,statusLabel:l.status,executionMode:null,goalId:e.id,projectId:null,tagIds:[],user:l.user,assignees:[],linkedUserIds:l.user?[l.user.id]:[],progressPercent:null,progressLabel:null,children:(d.get(l.id)??[]).map(w)})}),S=r.filter(l=>!m.has(l.id)).map(w);return M({id:`goal:${e.id}`,entityId:e.id,kind:"goal",label:e.title,description:C(e.description,"Strategic goal"),searchText:I([e.title,e.description,e.status,((N=e.user)==null?void 0:N.displayName)??""].join(" ")),href:`/goals/${e.id}`,statusLabel:e.status,executionMode:null,goalId:e.id,projectId:null,tagIds:e.tagIds,user:e.user,assignees:[],linkedUserIds:e.user?[e.user.id]:[],progressPercent:null,progressLabel:null,children:[...T,...S]})})}function K(t){return t.reduce((i,n)=>i+1+K(n.children??[]),0)}function me(t,i){return t.searchText.includes(I(i.query))&&(i.kind==="any"||i.kind===t.kind)}function G(t,i,n=!1){const{clauses:o,statusFilters:p,ownerUserIds:j,ownerKinds:h,selectedUserIds:f}=i,g=o.length===0||o.some(m=>me(t,m)),b=p.length===0||t.statusLabel!==null&&p.includes(t.statusLabel),w=j.length===0&&f.length===0?!0:[...j,...f].some(m=>t.linkedUserIds.includes(m)),e=h.length===0||[t.user,...t.assignees].some(m=>m&&h.includes(m.kind)),r=b&&w&&e,c=o.length===0||n||g,d=(t.children??[]).map(m=>G(m,i,n||r&&g)).filter(m=>m!==null);return r&&c||d.length>0?{...t,children:d}:null}function Q(t,i){return t.flatMap(n=>{const o=Q(n.children??[],i);return i.includes(n.kind)?[{...n,children:o}]:o})}function xe(t){switch(t){case"goal":return"bg-amber-400/12 text-amber-100";case"strategy":return"bg-cyan-400/12 text-cyan-100";case"project":return"bg-sky-400/12 text-sky-100";case"issue":return"bg-orange-400/12 text-orange-100";case"subtask":return"border-indigo-300/18 bg-indigo-400/12 text-indigo-100";default:return"bg-indigo-400/12 text-indigo-100"}}function z(t){switch(t){case"done":case"completed":return"bg-emerald-400/12 text-emerald-100";case"blocked":return"bg-rose-400/12 text-rose-100";case"in_progress":case"active":return"bg-sky-400/12 text-sky-100";case"focus":return"bg-violet-400/12 text-violet-100";default:return"bg-white/[0.08] text-white/70"}}function W(t){return t==="any"?s.jsx(v,{className:"bg-white/[0.08] text-white/76",children:"Any"}):t==="subtask"?s.jsx(D,{kind:"task",label:"Subtask",compact:!0,gradient:!1,className:"border-indigo-300/18 bg-indigo-400/12 text-indigo-100"}):s.jsx(D,{kind:t==="issue"?"issue":t,label:t,compact:!0,gradient:!1})}function be({query:t,onQueryChange:i,clauses:n,onClausesChange:o,resultSummary:p}){const[j,h]=x.useState(!1),[f,g]=x.useState(0),b=x.useMemo(()=>pe(t).filter(r=>!n.some(c=>c.id===r.id)),[n,t]),w=r=>{o([...n,r]),i(""),g(0),h(!1)},e=r=>{o(n.filter(c=>c.id!==r))};return s.jsx("div",{className:"grid gap-3",children:s.jsxs("div",{className:"rounded-[28px] border border-white/8 bg-[linear-gradient(135deg,rgba(19,28,48,0.9),rgba(10,14,26,0.98))] p-4 shadow-[0_30px_80px_rgba(3,8,18,0.28)] sm:p-5",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/42",children:"Hierarchy search"}),s.jsxs("div",{className:"mt-2 max-w-3xl text-sm leading-6 text-white/62",children:["Build OR clauses like ",s.jsx("span",{className:"text-white",children:'Goal + "MD"'})," or ",s.jsx("span",{className:"text-white",children:'Any + "Happy"'}),". Matching ancestors keep their branches visible so you can explore the hierarchy, not lose it."]})]}),n.length>0||t.trim().length>0?s.jsx(B,{variant:"secondary",size:"sm",onClick:()=>{i(""),o([]),g(0),h(!1)},children:"Clear search"}):null]}),s.jsxs("div",{className:"mt-4 rounded-[24px] border border-white/8 bg-white/[0.04] px-4 py-3",children:[n.length>0?s.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:n.map(r=>s.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full border border-white/8 bg-white/[0.06] px-2.5 py-1.5",children:[W(r.kind),s.jsxs("span",{className:"max-w-[14rem] truncate text-sm text-white/78",children:['"',r.query,'"']}),s.jsx("button",{type:"button",className:"rounded-full text-white/52 transition hover:text-white",onClick:()=>e(r.id),"aria-label":`Remove ${r.kind} ${r.query}`,children:s.jsx(ee,{className:"size-3.5"})})]},r.id))}):null,s.jsxs("div",{className:"relative",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(se,{className:"size-4 text-white/36"}),s.jsx("input",{value:t,onChange:r=>{i(r.target.value),h(!0),g(0)},onFocus:()=>h(!0),onBlur:()=>{window.setTimeout(()=>h(!1),120)},onKeyDown:r=>{if(r.key==="Backspace"&&!t&&n.length>0){e(n[n.length-1].id);return}if(r.key==="ArrowDown"){r.preventDefault(),h(!0),g(c=>b.length===0?0:Math.min(b.length-1,c+1));return}if(r.key==="ArrowUp"){r.preventDefault(),g(c=>Math.max(0,c-1));return}if(r.key==="Escape"){h(!1);return}r.key==="Enter"&&b[f]&&(r.preventDefault(),w(b[f]))},placeholder:'Type text, then pick a clause like Goal + "MD" or Any + "Happy"',className:"min-w-0 flex-1 bg-transparent text-sm text-white placeholder:text-white/34 focus:outline-none"})]}),j?s.jsx("div",{className:"absolute top-full z-20 mt-2 w-full rounded-[22px] border border-white/8 bg-[rgba(8,13,24,0.96)] p-2 shadow-[0_26px_60px_rgba(4,8,18,0.32)] backdrop-blur-xl",children:b.length>0?b.map((r,c)=>s.jsx("button",{type:"button",className:F("flex w-full items-start justify-between gap-3 rounded-[18px] px-3 py-2.5 text-left transition",c===f?"bg-white/[0.1] text-white":"text-white/70 hover:bg-white/[0.06] hover:text-white"),onMouseEnter:()=>g(c),onMouseDown:d=>d.preventDefault(),onClick:()=>w(r),children:s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[W(r.kind),s.jsxs("span",{className:"truncate text-sm font-medium text-white",children:['"',r.query,'"']})]}),s.jsxs("div",{className:"mt-1 text-xs leading-5 text-white/46",children:["Match ",r.kind==="any"?"any visible hierarchy node":`${r.kind} nodes`," that mention this text."]})]})},r.id)):s.jsx("div",{className:"px-3 py-2.5 text-sm text-white/42",children:"Type a word or phrase to create a new OR clause."})}):null]})]}),s.jsx("div",{className:"mt-3 text-sm text-white/52",children:p})]})})}function Me(){const t=ae(),i=x.useRef(null),[n,o]=x.useState(""),[p,j]=x.useState([]),[h,f]=x.useState([]),[g,b]=x.useState([...P]),[w,e]=x.useState(L),r=te({queryKey:["work-items-hierarchy",...t.selectedUserIds],queryFn:()=>de({userIds:t.selectedUserIds})}),c=x.useMemo(()=>{const a=t.snapshot.users.filter(u=>u.kind==="bot"),k=t.snapshot.users.filter(u=>u.kind==="human");return[{value:`${$.kind}bot`,label:"Bots",description:`${a.length} bot collaborators`,searchText:`bots bot ai agents assistants ${a.map(u=>`${u.displayName} ${u.handle}`).join(" ")}`,badge:s.jsx(v,{className:"border-cyan-300/18 bg-cyan-400/12 text-cyan-50",children:"Bots"}),menuBadge:s.jsx(v,{className:"border-cyan-300/18 bg-cyan-400/12 text-cyan-50",children:"Bots"})},{value:`${$.kind}human`,label:"Humans",description:`${k.length} human collaborators`,searchText:`humans human people operators ${k.map(u=>`${u.displayName} ${u.handle}`).join(" ")}`,badge:s.jsx(v,{className:"border-amber-300/18 bg-amber-400/12 text-amber-50",children:"Humans"}),menuBadge:s.jsx(v,{className:"border-amber-300/18 bg-amber-400/12 text-amber-50",children:"Humans"})},...t.snapshot.users.map(u=>({value:`${$.user}${u.id}`,label:u.displayName,description:`${u.kind}${u.handle?` · @${u.handle}`:""}`,searchText:`${u.displayName} ${u.handle} ${u.kind} ${u.description}`,badge:s.jsx(R,{user:u,compact:!0}),menuBadge:s.jsx(R,{user:u,compact:!0})}))]},[t.snapshot.users]),d=x.useMemo(()=>[{value:"goal",label:"Goal",searchText:"goal direction objective",kind:"goal"},{value:"strategy",label:"Strategy",searchText:"strategy plan sequencing",kind:"strategy"},{value:"project",label:"Project",searchText:"project initiative prd",kind:"project"},{value:"issue",label:"Issue",searchText:"issue vertical slice tracer bullet",kind:"issue"},{value:"task",label:"Task",searchText:"task execution ai session",kind:"task"},{value:"subtask",label:"Subtask",searchText:"subtask child step",badge:s.jsx(D,{kind:"task",label:"Subtask",compact:!0,gradient:!1,className:"border-indigo-300/18 bg-indigo-400/12 text-indigo-100"}),menuBadge:s.jsx(D,{kind:"task",label:"Subtask",compact:!0,gradient:!1,className:"border-indigo-300/18 bg-indigo-400/12 text-indigo-100"})}],[]),m=x.useMemo(()=>[{value:"active",label:"Active",searchText:"active in progress live"},{value:"paused",label:"Paused",searchText:"paused suspended"},{value:"completed",label:"Completed",searchText:"completed finished"},{value:"backlog",label:"Backlog",searchText:"backlog queued"},{value:"focus",label:"Focus",searchText:"focus ready"},{value:"in_progress",label:"In progress",searchText:"in progress active doing"},{value:"blocked",label:"Blocked",searchText:"blocked stuck"},{value:"done",label:"Done",searchText:"done complete finished"}].map(a=>({...a,badge:s.jsx(v,{className:z(a.value),children:a.label}),menuBadge:s.jsx(v,{className:z(a.value),children:a.label})})),[]),T=x.useMemo(()=>new Map(t.snapshot.tags.map(a=>[a.id,a.name])),[t.snapshot.tags]),S=x.useMemo(()=>r.data?V({...r.data,tagNameById:T}):V({goals:t.snapshot.goals,strategies:t.snapshot.strategies,projects:t.snapshot.dashboard.projects,tagNameById:T,workItems:t.snapshot.workItems&&t.snapshot.workItems.length>0?t.snapshot.workItems:t.snapshot.tasks}),[r.data,t.snapshot,T]),_=n.trim().length>0||p.length>0||h.length>0||g.length!==P.length||P.some(a=>!g.includes(a))||w.length!==L.length||L.some(a=>!w.includes(a)),N=x.useMemo(()=>ue(h),[h]),l=x.useMemo(()=>{const a=S.map(k=>G(k,{clauses:p,statusFilters:g,ownerUserIds:N.userIds,ownerKinds:N.kinds,selectedUserIds:t.selectedUserIds})).filter(k=>k!==null);return Q(a,w)},[S,N.kinds,N.userIds,p,g,t.selectedUserIds,w]),y=x.useMemo(()=>K(l),[l]),U=`${p.length>0?`${p.length} OR clause${p.length===1?"":"s"} active`:"Search across the full hierarchy"} · ${y} visible node${y===1?"":"s"}.`;return r.isLoading&&S.length===0?s.jsx(re,{eyebrow:"Hierarchy",title:"Building Forge hierarchy",description:"Loading goals, strategies, projects, issues, tasks, and subtasks into the compact hierarchy view."}):r.isError&&S.length===0?s.jsx(ie,{eyebrow:"Hierarchy",error:r.error,onRetry:()=>void r.refetch()}):s.jsxs("div",{className:"grid min-w-0 gap-5",children:[s.jsx(ce,{}),s.jsx(oe,{title:"Hierarchy",description:"Explore the full Forge stack from goal to subtask in one compact operational tree, with both strategy layers visible and the same control surfaces as the board.",badge:`${y} visible nodes`}),s.jsxs(O,{className:"min-w-0 overflow-hidden border-white/8 bg-[linear-gradient(180deg,rgba(16,23,38,0.92),rgba(9,14,24,0.98))]",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3 border-b border-white/8 px-5 py-4",children:[s.jsxs("div",{children:[s.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Hierarchy controls"}),s.jsx("div",{className:"mt-2 max-w-3xl text-sm leading-6 text-white/60",children:"Filter across goals, projects, tags, humans, bots, and work-item types, then expand or collapse the full tree without losing the hierarchy context."})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsx(B,{variant:"secondary",size:"sm",onClick:()=>{var a,k;return(k=(a=i.current)==null?void 0:a.openAll)==null?void 0:k.call(a)},children:"Expand all"}),s.jsx(B,{variant:"secondary",size:"sm",onClick:()=>{var a,k;return(k=(a=i.current)==null?void 0:a.closeAll)==null?void 0:k.call(a)},children:"Collapse all"}),_?s.jsx(B,{variant:"secondary",size:"sm",onClick:()=>{o(""),j([]),f([]),b([...P]),e(L)},children:"Reset"}):null]})]}),s.jsxs("div",{className:"grid gap-4 px-5 py-5",children:[s.jsx(be,{query:n,onQueryChange:o,clauses:p,onClausesChange:j,resultSummary:U}),s.jsxs("div",{className:"grid gap-3 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,1fr)_minmax(0,1fr)]",children:[s.jsx(A,{options:m,selectedValues:g,onChange:a=>b(a),placeholder:"Visible states",emptyMessage:"No states available.",variant:"action-bar"}),s.jsx(A,{options:d,selectedValues:w,onChange:a=>e(a),placeholder:"Visible levels",emptyMessage:"No hierarchy levels.",className:"min-w-0",variant:"action-bar"}),s.jsx(A,{options:c,selectedValues:h,onChange:f,placeholder:"Filter by human, bot, or collaborator",emptyMessage:"No matching collaborators."})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs(v,{className:"bg-white/[0.08] text-white/72",children:[l.length," top-level nodes"]}),s.jsxs(v,{className:"bg-white/[0.08] text-white/72",children:[y," visible nodes"]}),s.jsx(v,{className:"bg-white/[0.08] text-white/72",children:w.join(" + ")})]})]})]}),l.length===0?s.jsx(ne,{eyebrow:"Hierarchy",title:"No hierarchy nodes match the current filters",description:"Clear some filters or broaden the search to bring the full planning ladder back into view.",action:s.jsx(B,{variant:"secondary",onClick:()=>{o(""),j([]),f([]),b([...P]),e(L)},children:"Reset hierarchy filters"})}):s.jsxs(O,{className:"min-w-0 overflow-hidden border-white/8 bg-[linear-gradient(180deg,rgba(13,20,31,0.96),rgba(9,15,24,0.98))] p-0",children:[s.jsxs("div",{className:"grid grid-cols-[minmax(0,1.8fr)_auto_auto_auto] gap-3 border-b border-white/8 px-5 py-3 text-[11px] uppercase tracking-[0.18em] text-white/38",children:[s.jsx("div",{children:"Name"}),s.jsx("div",{className:"hidden lg:block",children:"State"}),s.jsx("div",{className:"hidden xl:block",children:"People"}),s.jsx("div",{className:"hidden lg:block",children:"Progress"})]}),s.jsx("div",{className:"p-2",children:s.jsx(X,{ref:i,data:l,width:"100%",height:760,rowHeight:64,overscanCount:10,childrenAccessor:a=>a.children??null,openByDefault:!0,paddingTop:8,paddingBottom:8,disableDrag:!0,className:"text-sm",children:({node:a,style:k})=>{const u=a.data.kind==="subtask"?"task":a.data.kind,E=le(u),H=E.colorToken.rgb.join(", ");return s.jsx("div",{style:k,className:"px-2 py-1.5",children:s.jsxs("div",{className:F("grid min-w-0 items-center gap-3 rounded-[16px] border border-white/8 px-3 py-2 transition hover:border-white/14 hover:bg-white/[0.05]","grid-cols-[minmax(0,1.8fr)_auto] lg:grid-cols-[minmax(0,1.8fr)_auto_auto] xl:grid-cols-[minmax(0,1.8fr)_auto_auto_auto]"),style:{marginLeft:`${a.level*14}px`,background:`linear-gradient(180deg, rgba(${H}, 0.07), rgba(255,255,255,0.02))`},children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[s.jsx("button",{type:"button",className:"inline-flex size-7 shrink-0 items-center justify-center rounded-full bg-white/[0.06] text-white/62 transition hover:bg-white/[0.1] hover:text-white",onClick:()=>a.toggle(),disabled:a.isLeaf,"aria-label":a.isOpen?`Collapse ${a.data.label}`:`Expand ${a.data.label}`,children:a.isLeaf?s.jsx("span",{className:"size-2 rounded-full bg-white/22"}):a.isOpen?s.jsx(Y,{className:"size-4"}):s.jsx(Z,{className:"size-4"})}),s.jsx("span",{className:F("inline-flex size-9 shrink-0 items-center justify-center rounded-[12px] border",E.subtleBadgeClassName),children:s.jsx(E.icon,{className:F("size-4",E.iconClassName)})}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(v,{className:xe(a.data.kind),children:a.data.kind}),a.data.executionMode?s.jsx(v,{className:a.data.executionMode==="afk"?"bg-emerald-400/12 text-emerald-100":"bg-amber-400/12 text-amber-100",children:a.data.executionMode.toUpperCase()}):null,s.jsx("div",{className:"truncate text-[13px] font-medium text-white",children:a.data.label})]}),s.jsx("div",{className:"mt-0.5 truncate text-[11px] leading-5 text-white/46",children:a.data.description})]})]}),s.jsx("div",{className:"hidden lg:flex justify-end",children:s.jsx(v,{className:z(a.data.statusLabel),children:a.data.statusLabel?a.data.statusLabel.replaceAll("_"," "):"linked"})}),s.jsxs("div",{className:"hidden xl:flex items-center justify-end gap-2",children:[a.data.user?s.jsx(R,{user:a.data.user,compact:!0}):null,a.data.assignees.length>0?s.jsxs(v,{className:"bg-white/[0.08] text-white/72",children:["+",a.data.assignees.length]}):null]}),s.jsxs("div",{className:"hidden lg:flex min-w-[11rem] items-center justify-end gap-3",children:[s.jsxs("div",{className:"min-w-[7.5rem]",children:[s.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-white/[0.08]",children:s.jsx("div",{className:"h-full rounded-full",style:{width:`${a.data.progressPercent??0}%`,background:`linear-gradient(90deg, rgba(${H}, 0.96), rgba(${H}, 0.72))`}})}),s.jsx("div",{className:"mt-1 text-[11px] text-white/44",children:a.data.progressLabel??`${a.data.progressPercent??0}% complete`})]}),a.data.href?s.jsx(J,{to:a.data.href,className:"rounded-full border border-white/10 bg-white/[0.04] px-3 py-1.5 text-[11px] uppercase tracking-[0.16em] text-white/72 transition hover:border-white/18 hover:bg-white/[0.08] hover:text-white",children:"Open"}):s.jsx("span",{className:"w-[3.75rem]"})]})]})})}})})]})]})}export{Me as ProjectManagementHierarchyPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{aJ as p,r as l,cB as b,cC as f,aU as g,j as e,bz as m,o as w,aK as u}from"./vendor-DHkYh85p.js";import{C as j,Z as c}from"./index-BHTUu_4M.js";const i=[{to:"/projects",label:"Projects",icon:b},{to:"/kanban",label:"Board",icon:f},{to:"/projects/hierarchy",label:"Hierarchy",icon:g}];function d(a,s){return s==="/projects"?a==="/projects"||/^\/projects\/[^/]+$/.test(a):a===s||a.startsWith(`${s}/`)}function y({className:a}){const s=p(),[o,n]=l.useState(!1),x=l.useMemo(()=>[...i].sort((t,r)=>r.to.length-t.to.length).find(t=>d(s.pathname,t.to))??i[0],[s.pathname]);return l.useEffect(()=>{if(!o)return;const t=document.body.style.overflow,r=h=>{h.key==="Escape"&&n(!1)};return document.body.style.overflow="hidden",window.addEventListener("keydown",r),()=>{document.body.style.overflow=t,window.removeEventListener("keydown",r)}},[o]),e.jsxs(e.Fragment,{children:[e.jsxs(j,{className:c("overflow-hidden bg-[linear-gradient(180deg,rgba(15,24,31,0.94),rgba(10,18,25,0.92))] p-2",a),children:[e.jsx("div",{className:"hidden items-center gap-3 lg:flex",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:i.map(t=>e.jsxs(m,{to:t.to,end:t.to==="/projects",className:({isActive:r})=>c("inline-flex items-center gap-2 whitespace-nowrap rounded-full px-3 py-1.5 text-[11px] font-semibold uppercase tracking-[0.14em] transition",r||d(s.pathname,t.to)?"bg-[rgba(125,211,252,0.16)] text-[#c7f0ff]":"bg-white/[0.04] text-white/58 hover:bg-white/[0.08] hover:text-white"),children:[e.jsx(t.icon,{className:"size-3.5"}),e.jsx("span",{children:t.label})]},t.to))})}),e.jsx("div",{className:"flex items-center justify-between gap-3 lg:hidden",children:e.jsx("button",{type:"button",className:"inline-flex min-w-0 flex-1 items-center gap-3 rounded-[22px] border border-white/8 bg-[linear-gradient(180deg,rgba(19,28,42,0.96),rgba(11,17,30,0.94))] px-3.5 py-2.5 text-left shadow-[0_18px_38px_rgba(3,8,18,0.2)] transition hover:border-white/12",onClick:()=>n(!0),children:e.jsxs("span",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-2xl border border-[rgba(125,211,252,0.2)] bg-[rgba(125,211,252,0.12)]",children:e.jsx(x.icon,{className:"size-4 text-[#c7f0ff]"})}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-[10px] uppercase tracking-[0.18em] text-white/40",children:"Project management"}),e.jsx("span",{className:"mt-0.5 block truncate text-sm font-medium text-white",children:x.label})]})]})})})]}),o&&typeof document<"u"?w.createPortal(e.jsxs("div",{className:"lg:hidden",children:[e.jsx("div",{className:"fixed inset-0 z-50 bg-[rgba(5,10,18,0.78)] backdrop-blur-xl"}),e.jsx("button",{type:"button","aria-label":"Close project management sections",className:"fixed inset-0 z-[51]",onClick:()=>n(!1)}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-[52] flex items-end justify-center px-3 pt-3 sm:px-4 sm:pt-4",style:{paddingBottom:"calc(var(--forge-mobile-nav-clearance) - 0.25rem)"},children:e.jsxs("div",{className:"pointer-events-auto flex max-h-[min(34rem,calc(100dvh-var(--forge-mobile-nav-clearance)-1rem))] w-full max-w-xl min-h-0 flex-col overflow-hidden rounded-[30px] border border-white/10 bg-[radial-gradient(circle_at_top,rgba(125,211,252,0.12),transparent_40%),linear-gradient(180deg,rgba(18,27,42,0.98),rgba(10,15,28,0.98))] shadow-[0_36px_110px_rgba(3,8,18,0.5)]",children:[e.jsx("div",{className:"shrink-0 border-b border-white/8 px-4 pb-2.5 pt-3 sm:px-5",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[10px] uppercase tracking-[0.22em] text-white/38",children:"Forge PM"}),e.jsx("div",{className:"mt-1.5 flex min-w-0 flex-wrap items-center gap-2",children:e.jsx("div",{className:"truncate text-[1.05rem] font-semibold text-white",children:"Browse the hierarchy"})})]}),e.jsx("button",{type:"button","aria-label":"Close project management sections",className:"inline-flex size-10 shrink-0 items-center justify-center rounded-full border border-white/8 bg-white/[0.05] text-white/65 transition hover:border-white/12 hover:bg-white/[0.09] hover:text-white",onClick:()=>n(!1),children:e.jsx(u,{className:"size-4"})})]})}),e.jsx("div",{className:"min-h-0 overflow-y-auto p-3 overscroll-contain sm:p-4",children:e.jsx("div",{className:"grid gap-2",children:i.map(t=>{const r=d(s.pathname,t.to);return e.jsx(m,{to:t.to,end:t.to==="/projects",onClick:()=>n(!1),className:c("group flex items-center justify-between gap-3 rounded-[22px] border px-3.5 py-3 transition hover:-translate-y-[1px] hover:text-white",r?"border-[rgba(125,211,252,0.18)] bg-[rgba(125,211,252,0.12)] text-white":"border-white/8 bg-white/[0.04] text-white/72 hover:border-white/12 hover:bg-white/[0.06]"),children:e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"flex size-10 items-center justify-center rounded-2xl border border-white/8 bg-white/[0.04]",children:e.jsx(t.icon,{className:"size-4"})}),e.jsx("span",{className:"text-sm font-medium",children:t.label})]})},t.to)})})})]})})]}),document.body):null]})}export{y as P};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,r as g,aK as X,b3 as J,aC as L}from"./vendor-DHkYh85p.js";import{A as Y}from"./ai-surface-workspace-qgk_B57-.js";import{P as Z}from"./pill-cluster-BJogDRDJ.js";import{Z as Q,c as T,b as D,u as U,bk as R,bl as _,_ as q,C as M,U as ee,V as W,W as H,B as O,a as te,bS as se,bT as ae,bU as ie}from"./index-BHTUu_4M.js";import{P as re}from"./page-hero-CQWo1Mm_.js";import{E as ne}from"./entity-note-count-link-BmGDB572.js";import{b as le,f as ce,P as de}from"./project-collections-DvaX20q_.js";import{P as oe}from"./project-management-section-nav-C2Ud8Zdd.js";import"./board-BkDRaMp6.js";import"./state-B-4sS1xO.js";import"./ui-C13Nbgas.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";function he({children:s,columns:c="single",className:k}){return e.jsx("section",{className:Q("grid gap-4",c==="two"&&"lg:grid-cols-2",c==="sidebar"&&"xl:grid-cols-[minmax(0,25rem)_minmax(0,1fr)]",k),children:s})}function ue(s){return s.trim().toLowerCase()}function V(s,c=!1){switch(s.kind){case"goal":return e.jsx(D,{kind:"goal",label:s.label,compact:!0,gradient:!1});case"task":return e.jsx(D,{kind:"task",label:s.label,compact:!0,gradient:!1});case"tag":return e.jsx(T,{className:"bg-white/[0.08] text-white/78",children:s.label});case"status":return e.jsx(T,{className:"bg-[rgba(192,193,255,0.12)] text-white/84",children:s.label});case"type":return e.jsx(T,{className:"bg-[rgba(86,170,255,0.12)] text-white/84",children:s.label});case"user":return e.jsx(T,{className:"bg-[rgba(110,231,183,0.12)] text-white/84",children:s.label});default:return s.label}}function me({query:s,onQueryChange:c,options:k,selectedOptionIds:u,onSelectedOptionIdsChange:I,resultSummary:C}){const[F,w]=g.useState(!1),[P,p]=g.useState(0),N=g.useMemo(()=>u.map(n=>k.find(d=>d.id===n)).filter(Boolean),[k,u]),S=ue(s),b=g.useMemo(()=>{const n=k.filter(d=>!u.includes(d.id));return S?n.filter(d=>`${d.label} ${d.description??""} ${d.searchText??""}`.toLowerCase().includes(S)).slice(0,10):n.slice(0,10)},[S,k,u]),v=n=>{u.includes(n)||(I([...u,n]),c(""),p(0),w(!1))},B=n=>{I(u.filter(d=>d!==n))},K=()=>{c(""),I([]),p(0),w(!1)};return e.jsx("div",{className:"grid gap-3",children:e.jsxs("div",{className:"rounded-[28px] border border-white/8 bg-[linear-gradient(135deg,rgba(19,28,48,0.9),rgba(10,14,26,0.98))] p-4 shadow-[0_30px_80px_rgba(3,8,18,0.28)] sm:p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/42",children:"Project search"}),e.jsx("div",{className:"mt-2 max-w-2xl text-sm leading-6 text-white/62",children:"Search with free text, then pin matching goals, tasks, tags, human users, bot users, statuses, or project-type chips as you narrow the list."})]}),s.trim().length>0||u.length>0?e.jsx("button",{type:"button",onClick:K,className:"rounded-full border border-white/8 bg-white/[0.04] px-3 py-2 text-sm text-white/62 transition hover:bg-white/[0.08] hover:text-white",children:"Clear search"}):null]}),e.jsxs("div",{className:"mt-4 rounded-[24px] border border-white/8 bg-white/[0.04] px-4 py-3",children:[N.length>0?e.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:N.map(n=>e.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full border border-white/8 bg-white/[0.06] px-2.5 py-1.5",children:[V(n,!0),e.jsx("button",{type:"button",className:"rounded-full text-white/52 transition hover:text-white",onClick:()=>B(n.id),"aria-label":`Remove ${n.label}`,children:e.jsx(X,{className:"size-3.5"})})]},n.id))}):null,e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(J,{className:"size-4 text-white/36"}),e.jsx("input",{value:s,onChange:n=>{c(n.target.value),w(!0),p(0)},onFocus:()=>w(!0),onBlur:()=>{window.setTimeout(()=>w(!1),120)},onKeyDown:n=>{if(n.key==="Backspace"&&!s&&u.length>0){B(u[u.length-1]);return}if(n.key==="ArrowDown"){n.preventDefault(),w(!0),p(d=>b.length===0?0:Math.min(b.length-1,d+1));return}if(n.key==="ArrowUp"){n.preventDefault(),p(d=>Math.max(0,d-1));return}if(n.key==="Escape"){w(!1);return}n.key==="Enter"&&b[P]&&(n.preventDefault(),v(b[P].id))},placeholder:"Type a project, goal, task, human, bot, user, or tag",className:"min-w-0 flex-1 bg-transparent text-sm text-white placeholder:text-white/34 focus:outline-none"})]}),F?e.jsx("div",{className:"absolute top-full z-20 mt-2 w-full rounded-[22px] border border-white/8 bg-[rgba(8,13,24,0.96)] p-2 shadow-[0_26px_60px_rgba(4,8,18,0.32)] backdrop-blur-xl",children:b.length>0?b.map((n,d)=>e.jsx("button",{type:"button",className:Q("flex w-full items-start justify-between gap-3 rounded-[18px] px-3 py-2.5 text-left transition",d===P?"bg-white/[0.1] text-white":"text-white/70 hover:bg-white/[0.06] hover:text-white"),onMouseEnter:()=>p(d),onMouseDown:E=>E.preventDefault(),onClick:()=>v(n.id),children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:V(n)}),n.description?e.jsx("div",{className:"mt-1 text-xs leading-5 text-white/46",children:n.description}):null]})},n.id)):e.jsx("div",{className:"px-3 py-2.5 text-sm text-white/42",children:"Keep typing to search by free text, or select a suggested goal, task, human or bot owner, tag, status, or type chip when it appears."})}):null]})]}),e.jsx("div",{className:"mt-3 text-sm text-white/52",children:C})]})})}const pe={execution:"Execution",value:"Value",category:"Category"};function xe(s){return s.trim().toLowerCase()}function Ie(){const s=U(),[c,k]=g.useState("active"),[u,I]=g.useState(""),[C,F]=g.useState([]),[w,P]=g.useState(null),p=g.useMemo(()=>le(s.snapshot.dashboard.projects),[s.snapshot.dashboard.projects]),N=g.useMemo(()=>{const a=new Map(s.snapshot.dashboard.goals.map(r=>[r.id,r])),l=new Map(s.snapshot.tags.map(r=>[r.id,r])),h=new Map(s.snapshot.users.map(r=>[r.id,r])),f=new Map;for(const r of s.snapshot.tasks){if(!r.projectId)continue;const x=f.get(r.projectId)??[];x.push(r),f.set(r.projectId,x)}return new Map(s.snapshot.dashboard.projects.map(r=>{const x=a.get(r.goalId)??null,$=f.get(r.id)??[],j=r.userId?h.get(r.userId)??null:null,y=new Map;for(const o of(x==null?void 0:x.tags)??[])y.set(o.id,{id:o.id,name:o.name,kind:o.kind});for(const o of $)for(const t of o.tagIds){const i=l.get(t);i&&y.set(i.id,{id:i.id,name:i.name,kind:i.kind})}const z=Array.from(new Set(Array.from(y.values()).map(o=>o.kind))),A=[r.title,r.description,r.goalTitle,(j==null?void 0:j.displayName)??"",(j==null?void 0:j.handle)??"",(j==null?void 0:j.kind)??"",(x==null?void 0:x.description)??"",r.nextTaskTitle??"",r.momentumLabel,r.status,$.map(o=>o.title).join(" "),Array.from(y.values()).map(o=>`${o.name} ${o.kind}`).join(" ")].join(" ").toLowerCase();return[r.id,{tagIds:Array.from(y.keys()),tags:Array.from(y.values()),taskIds:$.map(o=>o.id),typeKeys:z,userId:r.userId,searchText:A}]}))},[s.snapshot.dashboard.goals,s.snapshot.dashboard.projects,s.snapshot.tags,s.snapshot.tasks,s.snapshot.users]),S=g.useMemo(()=>{var j,y,z,A,o;const a=new Map,l=new Map,h=new Map,f=new Map,r=new Map,x=new Map,$=new Map;for(const t of s.snapshot.dashboard.projects){const i=N.get(t.id);if(i){l.has(t.goalId)||l.set(t.goalId,new Set),l.get(t.goalId).add(t.id),r.has(t.status)||r.set(t.status,new Set),r.get(t.status).add(t.id);for(const m of i.taskIds)h.has(m)||h.set(m,new Set),h.get(m).add(t.id);for(const m of i.tags)f.has(m.id)||f.set(m.id,new Set),f.get(m.id).add(t.id);for(const m of i.typeKeys)x.has(m)||x.set(m,new Set),x.get(m).add(t.id);i.userId&&($.has(i.userId)||$.set(i.userId,new Set),$.get(i.userId).add(t.id))}}for(const t of s.snapshot.dashboard.goals){const i=((j=l.get(t.id))==null?void 0:j.size)??0;i!==0&&a.set(`goal:${t.id}`,{id:`goal:${t.id}`,kind:"goal",value:t.id,label:t.title,description:_(`${i} project${i===1?"":"s"} linked to this goal`,t.user,`${i} project${i===1?"":"s"} linked to this goal`),searchText:R([t.title,t.description],t)})}for(const t of s.snapshot.tasks){const i=((y=h.get(t.id))==null?void 0:y.size)??0;i!==0&&a.set(`task:${t.id}`,{id:`task:${t.id}`,kind:"task",value:t.id,label:t.title,description:_(`${i} project${i===1?"":"s"} linked to this task`,t.user,`${i} project${i===1?"":"s"} linked to this task`),searchText:R([t.title,t.description],t)})}for(const t of s.snapshot.tags){const i=((z=f.get(t.id))==null?void 0:z.size)??0;i!==0&&a.set(`tag:${t.id}`,{id:`tag:${t.id}`,kind:"tag",value:t.id,label:t.name,description:_(`${i} project${i===1?"":"s"} touching this tag`,t.user,`${i} project${i===1?"":"s"} touching this tag`),searchText:R([t.name,t.kind,t.description],t)})}for(const[t,i]of Object.entries(p))t==="all"||i===0||a.set(`status:${t}`,{id:`status:${t}`,kind:"status",value:t,label:t==="paused"?"Suspended":t==="completed"?"Finished":"Active",description:`${i} project${i===1?"":"s"} currently ${t==="paused"?"suspended":t==="completed"?"finished":"active"}`,searchText:`${t} ${t==="paused"?"suspended":""} ${t==="completed"?"finished":""}`});for(const[t,i]of Object.entries(pe)){const m=((A=x.get(t))==null?void 0:A.size)??0;m!==0&&a.set(`type:${t}`,{id:`type:${t}`,kind:"type",value:t,label:i,description:`${m} project${m===1?"":"s"} linked to ${i.toLowerCase()} tags`,searchText:`${i} ${t} project type`})}for(const t of s.snapshot.users){const i=((o=$.get(t.id))==null?void 0:o.size)??0;i!==0&&a.set(`user:${t.id}`,{id:`user:${t.id}`,kind:"user",value:t.id,label:t.displayName,description:`${i} project${i===1?"":"s"} owned by this ${t.kind}`,searchText:`${t.displayName} ${t.handle} ${t.kind} ${t.description}`})}return Array.from(a.values()).sort((t,i)=>t.label.localeCompare(i.label))},[p,N,s.snapshot.dashboard.goals,s.snapshot.dashboard.projects,s.snapshot.tags,s.snapshot.tasks,s.snapshot.users]),b=g.useMemo(()=>C.map(a=>S.find(l=>l.id===a)).filter(Boolean),[S,C]),v=g.useMemo(()=>{const a=xe(u);return ce(s.snapshot.dashboard.projects,c).filter(l=>{const h=N.get(l.id);return!h||!b.every(r=>{switch(r.kind){case"goal":return l.goalId===r.value;case"task":return h.taskIds.includes(r.value);case"tag":return h.tagIds.includes(r.value);case"status":return l.status===r.value;case"type":return h.typeKeys.includes(r.value);case"user":return h.userId===r.value;default:return!0}})?!1:a?h.searchText.includes(a):!0})},[c,N,u,b,s.snapshot.dashboard.projects]),B=c==="all"?p.all:p[c],n=u.trim().length>0||C.length>0?`${v.length} matching project${v.length===1?"":"s"} in the current collection view`:`${B} project${B===1?"":"s"} in ${c==="all"?"all project states":c==="paused"?"the suspended view":c==="completed"?"the finished view":"the active view"}`,d=async a=>{P(a);try{await s.patchProject(a,{status:"active"})}finally{P(null)}},E=e.jsx(he,{columns:"two",className:"2xl:grid-cols-3",children:v.map(a=>{const l=q(s.snapshot.dashboard.notesSummaryByEntity,"project",a.id),h=N.get(a.id),f=(h==null?void 0:h.tags.slice(0,3))??[];return e.jsxs(M,{className:"flex h-full flex-col transition hover:bg-white/[0.06]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[e.jsx(D,{kind:"goal",label:a.goalTitle,compact:!0}),e.jsx(ee,{user:a.user,compact:!0})]}),e.jsx(T,{className:a.status==="completed"?"text-emerald-300":a.status==="paused"?"text-amber-300":"text-[var(--primary)]",children:a.status==="paused"?"Suspended":a.status==="completed"?"Finished":"Active"})]}),e.jsx("div",{className:"mt-4",children:e.jsx(L,{to:`/projects/${a.id}`,className:"transition hover:opacity-90",children:e.jsx(W,{kind:"project",label:a.title,variant:"heading",size:"xl",lines:2})})}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-white/58",children:a.description}),f.length>0?e.jsx(Z,{className:"mt-4",children:f.map(r=>e.jsx(T,{className:"bg-white/[0.08] text-white/72",children:r.name},r.id))}):null,e.jsx("div",{className:"mt-4",children:e.jsx(H,{value:a.progress,tone:a.status==="completed"?"secondary":"primary"})}),e.jsxs("div",{className:"mt-4 grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Active"}),e.jsx("div",{className:"mt-2 text-white",children:a.activeTaskCount})]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Completed"}),e.jsx("div",{className:"mt-2 text-white",children:a.completedTaskCount})]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"XP"}),e.jsx("div",{className:"mt-2 text-white",children:a.earnedPoints})]})]}),e.jsx("div",{className:"mt-5 text-[11px] uppercase tracking-[0.16em] text-white/40",children:a.nextTaskTitle?`Next move: ${a.nextTaskTitle}`:"Ready for the next task"}),e.jsx("div",{className:"mt-4",children:e.jsx(ne,{entityType:"project",entityId:a.id,count:l.count})}),e.jsxs("div",{className:"mt-5 flex flex-wrap items-center justify-between gap-3 pt-1",children:[e.jsx(L,{to:`/projects/${a.id}`,children:e.jsx(O,{variant:"ghost",children:"Open project"})}),c!=="active"&&a.status!=="active"?e.jsx(O,{variant:"secondary",pending:w===a.id,pendingLabel:"Restarting…",onClick:()=>void d(a.id),children:"Restart"}):null]})]},a.id)})}),G=[{id:"hero",title:"Projects",description:"Route header",defaultWidth:12,defaultHeight:2,removable:!1,surfaceChrome:"none",defaultTitleVisible:!1,defaultDescriptionVisible:!1,render:()=>e.jsx(se,{children:e.jsx(re,{entityKind:"project",title:e.jsx(W,{kind:"project",label:"Projects",variant:"heading",size:"lg"}),titleText:"Projects",description:"Projects are the concrete paths that move a life goal forward.",badge:`${s.snapshot.dashboard.projects.length} total projects`})})},{id:"search-results",title:"Search and results",description:"Search stays grouped with its live result set.",defaultWidth:8,defaultHeight:6,minWidth:6,render:({compact:a})=>e.jsx(ae,{children:e.jsxs("div",{className:"grid gap-4",children:[e.jsx(me,{query:u,onQueryChange:I,options:S,selectedOptionIds:C,onSelectedOptionIdsChange:F,resultSummary:n}),e.jsx(de,{value:c,counts:p,onChange:k}),v.length===0?e.jsxs(M,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/42",children:"No matching projects"}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/58",children:"Nothing in this project collection matches the current search and chips."})]}):a?e.jsx("div",{className:"grid gap-3",children:v.slice(0,5).map(l=>e.jsx(L,{to:`/projects/${l.id}`,className:"rounded-[18px] bg-white/[0.04] px-4 py-3 transition hover:bg-white/[0.06]",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-semibold text-white",children:l.title}),e.jsx("div",{className:"text-sm text-white/54",children:l.goalTitle})]}),e.jsxs(T,{className:"shrink-0 bg-white/[0.08] text-white/72",children:[l.earnedPoints," xp"]})]})},l.id))}):E]})})},{id:"summary",title:"Collection summary",description:"Counts and spotlight cards.",defaultWidth:4,defaultHeight:5,minWidth:4,render:()=>{const a=v[0]??s.snapshot.dashboard.projects[0]??null;return e.jsx(ie,{children:e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-1",children:[e.jsxs(M,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/38",children:"Active"}),e.jsx("div",{className:"mt-2 font-display text-4xl text-white",children:p.active})]}),e.jsxs(M,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/38",children:"Finished"}),e.jsx("div",{className:"mt-2 font-display text-4xl text-white",children:p.completed})]})]}),a?e.jsxs(M,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/38",children:"Spotlight"}),e.jsx("div",{className:"mt-3 text-base font-semibold text-white",children:a.title}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/56",children:a.description}),e.jsx("div",{className:"mt-3",children:e.jsx(H,{value:a.progress})})]}):null]})})}}];return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(oe,{}),s.snapshot.dashboard.projects.length===0?e.jsx(te,{eyebrow:"Projects",title:"No projects in flight",description:"Create the first practical path under a life goal so execution, kanban, and evidence all have a concrete home.",action:e.jsx(L,{to:"/goals",className:"inline-flex min-h-10 min-w-max shrink-0 items-center justify-center rounded-full bg-white/[0.08] px-4 py-3 text-sm whitespace-nowrap text-white transition hover:bg-white/[0.12]",children:"Open goals"})}):e.jsx(Y,{surfaceId:"projects",baseWidgets:G})]})}export{Ie as ProjectsPage};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{j as t,aC as ue,b8 as pe,c2 as ye,r as v}from"./vendor-DHkYh85p.js";import{j as ve,i as g,k as ge}from"./state-B-4sS1xO.js";import{u as fe,s as xe,co as be,cp as we,bk as P,bl as N,cq as T,L as je,E as ke,B,V as Ce,ck as Ie,c as Se,U as Pe,_ as Ne,Q as Te,a0 as Be,a1 as Le,F as i,I as Me,T as d,m as S,cr as Ee,cs as Fe,ct as qe,by as Oe,bx as Ae,bw as Qe,cu as De,bA as Ke}from"./index-BHTUu_4M.js";import{E as Re}from"./entity-note-count-link-BmGDB572.js";import{A as G}from"./atlas-panel-rfH2qOez.js";import{S as _}from"./schema-badge-DyKbxb51.js";import{u as Ue,p as $e}from"./use-psyche-focus-target-C1C_XjYG.js";import{P as We}from"./page-hero-CQWo1Mm_.js";import{p as L}from"./query-cache-IQ8W-LNC.js";import{b as H}from"./psyche-schemas-HFmg37Wj.js";import{g as ze}from"./schema-visuals-D6nxjbYC.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";function Ve({entries:r}){const n={away:"border-rose-400/20 bg-[rgba(251,113,133,0.08)]",committed:"border-emerald-400/20 bg-[rgba(110,231,183,0.08)]",recovery:"border-amber-400/20 bg-[rgba(251,191,36,0.08)]"};return t.jsx("div",{className:"grid gap-3 lg:grid-cols-3",children:r.map(o=>t.jsxs(ue,{to:o.href,className:`rounded-[22px] border px-4 py-4 transition hover:-translate-y-0.5 ${n[o.tone]}`,children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:o.tone}),t.jsx("div",{className:"mt-2 font-medium text-white",children:o.title}),t.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:o.summary}),t.jsxs("div",{className:"mt-4 inline-flex items-center gap-2 text-sm text-white/54",children:["Open",t.jsx(pe,{className:"size-3.5"})]})]},o.id))})}const f={kind:"away",title:"",description:"",commonCues:[],urgeStory:"",shortTermPayoff:"",longTermCost:"",replacementMove:"",repairPlan:"",linkedPatternIds:[],linkedValueIds:[],linkedSchemaIds:[],linkedModeIds:[],userId:null};function Ge(r){return{kind:r.kind,title:r.title,description:r.description,commonCues:r.commonCues,urgeStory:r.urgeStory,shortTermPayoff:r.shortTermPayoff,longTermCost:r.longTermCost,replacementMove:r.replacementMove,repairPlan:r.repairPlan,linkedPatternIds:r.linkedPatternIds,linkedValueIds:r.linkedValueIds,linkedSchemaIds:r.linkedSchemaIds,linkedModeIds:r.linkedModeIds,userId:r.userId??null}}const J={away:"Away moves",committed:"Committed actions",recovery:"Recovery moves"};function ct(){var O,A,Q,D,K,R,U,$,W,z,V;const r=fe(),n=ve(),[o,M]=ye(),[X,c]=v.useState(!1),[h,p]=v.useState(null),[y,m]=v.useState(f),[Y,x]=v.useState(null),b=g({queryKey:["forge-psyche-behaviors"],queryFn:Oe}),w=g({queryKey:["forge-psyche-patterns"],queryFn:Ae}),j=g({queryKey:["forge-psyche-values"],queryFn:Qe}),k=g({queryKey:["forge-psyche-schema-catalog"],queryFn:De}),C=g({queryKey:["forge-psyche-modes"],queryFn:Ke}),I=((O=b.data)==null?void 0:O.behaviors)??[],Z=((A=w.data)==null?void 0:A.patterns)??[],ee=((Q=j.data)==null?void 0:Q.values)??[],te=((D=k.data)==null?void 0:D.schemas)??[],ae=((K=C.data)==null?void 0:K.modes)??[],u=xe(r.selectedUserIds),E=o.get("focus"),se=r.snapshot.dashboard.notesSummaryByEntity;Ue(E),v.useEffect(()=>{if(o.get("create")==="1"){c(!0),p(null),m({...f,userId:u});const e=new URLSearchParams(o);e.delete("create"),M(e,{replace:!0})}},[u,o,M]);const F=ge({mutationFn:async e=>{const a=H.parse(e);return h?be(h.id,a):we(a)},onSuccess:async()=>{c(!1),p(null),m({...f,userId:u}),x(null),await Promise.all([n.invalidateQueries({queryKey:["forge-psyche-behaviors"]}),n.invalidateQueries({queryKey:["forge-psyche-overview"]})])}}),re=Z.map(e=>({value:e.id,label:T(e.title,e.user),description:N(e.preferredResponse||e.targetBehavior,e.user),searchText:P([e.title,e.preferredResponse,e.targetBehavior,e.description],e),kind:"pattern"})),ie=ee.map(e=>({value:e.id,label:T(e.title,e.user),description:N(e.valuedDirection,e.user),searchText:P([e.title,e.valuedDirection,e.description],e),kind:"value"})),oe=te.map(e=>({value:e.id,label:e.title,description:`${e.description} ${ze(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})})),ne=ae.map(e=>({value:e.id,label:T(e.title,e.user),description:N(e.archetype||e.family,e.user),searchText:P([e.title,e.archetype,e.family,e.persona],e),kind:"mode"})),le=async e=>{const{pattern:a}=await Ee({title:e,description:"",targetBehavior:e,cueContexts:[],shortTermPayoff:"",longTermCost:"",preferredResponse:"",linkedValueIds:[],linkedSchemaLabels:[],linkedModeIds:[],linkedBeliefIds:[],userId:y.userId});return L(n,["forge-psyche-patterns"],"patterns",a),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:a.id,label:a.title,description:a.preferredResponse||a.targetBehavior,kind:"pattern"}},de=async e=>{const{value:a}=await Fe({title:e,description:"",valuedDirection:e,whyItMatters:"",linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],committedActions:[],userId:y.userId});return L(n,["forge-psyche-values"],"values",a),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:a.id,label:a.title,description:a.valuedDirection,kind:"value"}},ce=async e=>{const{mode:a}=await qe({family:"coping",archetype:"",title:e,persona:"",imagery:"",symbolicForm:"",facialExpression:"",fear:"",burden:"",protectiveJob:"",originContext:"",firstAppearanceAt:null,linkedPatternIds:[],linkedBehaviorIds:[],linkedValueIds:[],userId:y.userId});return L(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"}},he=[{id:"behavior",eyebrow:"Behavior",title:"Describe the move or urge in plain language",description:"Start with the behavior itself so the map reads like something you can instantly recognize in real life.",render:(e,a)=>t.jsxs(t.Fragment,{children:[t.jsx(Be,{value:e.userId??null,users:r.snapshot.users,onChange:s=>a({userId:s}),defaultLabel:Le(r.snapshot.users.find(s=>s.id===u)??null,"Choose behavior owner"),help:"Behaviors can belong to a human or bot user while still linking across shared patterns, schemas, and modes."}),t.jsx(i,{label:"Behavior title",children:t.jsx(Me,{value:e.title,onChange:s=>a({title:s.target.value}),placeholder:"Scroll to numb the impact"})}),t.jsx(i,{label:"What does the move look like?",children:t.jsx(d,{value:e.description,onChange:s=>a({description:s.target.value}),placeholder:"Describe the move the way you would recognize it in the moment, not in therapist shorthand."})})]})},{id:"context",eyebrow:"Context",title:"Capture the cue, the pull, and the immediate payoff",description:"Make the move readable as a real pattern instead of a label.",render:(e,a)=>t.jsxs(t.Fragment,{children:[t.jsx(i,{label:"Common cues",children:t.jsx(d,{value:e.commonCues.join(`
|
|
2
|
+
`),onChange:s=>a({commonCues:s.target.value.split(`
|
|
3
|
+
`).map(me=>me.trim()).filter(Boolean)}),placeholder:`One line per cue
|
|
4
|
+
Late-night ambiguity
|
|
5
|
+
Feedback after a hard week`})}),t.jsx(i,{label:"What inner push or story shows up?",children:t.jsx(d,{value:e.urgeStory,onChange:s=>a({urgeStory:s.target.value}),placeholder:"What inner push or justification tends to appear?"})}),t.jsx(i,{label:"What do you get right away from this move?",children:t.jsx(d,{value:e.shortTermPayoff,onChange:s=>a({shortTermPayoff:s.target.value}),placeholder:"What relief, certainty, distance, or control does it give in the short term?"})})]})},{id:"classification",eyebrow:"Classification",title:"Now classify the move and define the return path",description:"Once the move is clear, decide whether it is an away move, a committed action, or a recovery path.",render:(e,a)=>t.jsxs(t.Fragment,{children:[t.jsx(i,{label:"Move type",children:t.jsx("div",{className:"grid gap-3 md:grid-cols-3",children:["away","committed","recovery"].map(s=>t.jsx("button",{type:"button",className:`rounded-[22px] border px-4 py-4 text-left transition ${e.kind===s?"border-white/20 bg-white/[0.12] text-white":"border-white/8 bg-white/[0.04] text-white/62 hover:bg-white/[0.07]"}`,onClick:()=>a({kind:s}),children:J[s]},s))})}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(i,{label:"What does it cost over time?",children:t.jsx(d,{value:e.longTermCost,onChange:s=>a({longTermCost:s.target.value}),placeholder:"What does this move cost over time?"})}),t.jsx(i,{label:"What move should replace or steady it?",children:t.jsx(d,{value:e.replacementMove,onChange:s=>a({replacementMove:s.target.value}),placeholder:"What move should replace this one when possible?"})})]}),t.jsx(i,{label:"If the slip happens, how do you repair and return?",children:t.jsx(d,{value:e.repairPlan,onChange:s=>a({repairPlan:s.target.value}),placeholder:"Describe the repair path without shame or collapse."})})]})},{id:"links",eyebrow:"Links",title:"Attach the move to patterns, values, schemas, and modes",description:"This turns the move into part of the full graphical psyche system.",render:(e,a)=>t.jsxs(t.Fragment,{children:[t.jsx(i,{label:"Linked patterns",children:t.jsx(S,{options:re,selectedValues:e.linkedPatternIds,onChange:s=>a({linkedPatternIds:s}),placeholder:"Search or create a pattern…",emptyMessage:"No patterns match yet.",createLabel:"Create pattern",onCreate:le})}),t.jsx(i,{label:"Linked values",children:t.jsx(S,{options:ie,selectedValues:e.linkedValueIds,onChange:s=>a({linkedValueIds:s}),placeholder:"Search or create a value…",emptyMessage:"No values match yet.",createLabel:"Create value",onCreate:de})}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(i,{label:"Linked schemas",children:t.jsx(S,{options:oe,selectedValues:e.linkedSchemaIds,onChange:s=>a({linkedSchemaIds:s}),placeholder:"Search schema themes…",emptyMessage:"No schema themes match."})}),t.jsx(i,{label:"Linked modes",children:t.jsx(S,{options:ne,selectedValues:e.linkedModeIds,onChange:s=>a({linkedModeIds:s}),placeholder:"Search or create a mode…",emptyMessage:"No modes match yet.",createLabel:"Create mode",onCreate:ce})})]})]})}];if(b.isLoading||w.isLoading||j.isLoading||k.isLoading||C.isLoading)return t.jsx(je,{eyebrow:"Behaviors",title:"Loading behaviors",description:"Getting behaviors, patterns, values, schemas, and modes ready."});const q=b.error??w.error??j.error??k.error??C.error;if(q)return t.jsx(ke,{eyebrow:"Psyche behaviors",error:q,onRetry:()=>void Promise.all([b.refetch(),w.refetch(),j.refetch(),k.refetch(),C.refetch()])});const l={away:I.filter(e=>e.kind==="away"),committed:I.filter(e=>e.kind==="committed"),recovery:I.filter(e=>e.kind==="recovery")};return t.jsxs("div",{className:"grid gap-5",children:[t.jsx(We,{entityKind:"behavior",title:t.jsx(Ce,{kind:"behavior",label:"Behaviors",variant:"heading",size:"lg"}),description:"Group behaviors by what pulls you away, what moves you toward your values, and what helps you recover after a slip.",badge:`${I.length} mapped`,actions:t.jsx(B,{onClick:()=>{p(null),m({...f,userId:u}),c(!0)},children:"Add behavior"})}),t.jsx(Ie,{}),t.jsx(G,{eyebrow:"Overview",title:"Behavior summary",description:"This summary keeps the three behavior types visible together: away, committed, and recovery.",tone:"amber",children:t.jsx(Ve,{entries:[{id:"away",title:((R=l.away[0])==null?void 0:R.title)??"No away move mapped yet",summary:((U=l.away[0])==null?void 0:U.replacementMove)||"Map the move that tends to pull you away first.",href:"#behavior-columns",tone:"away"},{id:"committed",title:(($=l.committed[0])==null?void 0:$.title)??"No committed action mapped yet",summary:((W=l.committed[0])==null?void 0:W.replacementMove)||"Map the move you want to practice instead.",href:"#behavior-columns",tone:"committed"},{id:"recovery",title:((z=l.recovery[0])==null?void 0:z.title)??"No recovery move mapped yet",summary:((V=l.recovery[0])==null?void 0:V.repairPlan)||"Map how you return after a slip without turning it into collapse.",href:"#behavior-columns",tone:"recovery"}]})}),t.jsx(G,{eyebrow:"Behaviors",title:"Behaviors by type",description:"Use these columns to separate what pulls you off course, what helps you move toward your values, and what helps you recover.",tone:"default",children:t.jsx("div",{id:"behavior-columns",className:"grid gap-4 xl:grid-cols-3",children:["away","committed","recovery"].map(e=>t.jsxs("div",{className:"grid gap-3 rounded-[24px] bg-white/[0.04] p-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("div",{className:"font-medium text-white",children:J[e]}),t.jsx(Se,{children:l[e].length})]}),l[e].length===0?t.jsx("div",{className:"flex",children:t.jsxs(B,{variant:"secondary",onClick:()=>{p(null),m({...f,userId:u}),c(!0)},children:["Add"," ",e==="away"?"away move":e==="committed"?"committed action":"recovery move"]})}):l[e].map(a=>t.jsxs("div",{"data-psyche-focus-id":a.id,className:`rounded-[22px] border border-white/8 bg-white/[0.04] p-4 text-left transition hover:bg-white/[0.08] ${$e(E===a.id)}`,children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("div",{className:"font-medium text-white",children:a.title}),a.user?t.jsx(Pe,{user:a.user,compact:!0}):null]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(Re,{entityType:"behavior",entityId:a.id,count:Ne(se,"behavior",a.id).count}),t.jsx(B,{variant:"secondary",size:"sm",onClick:()=>{p(a),m(Ge(a)),c(!0)},children:"Edit"})]})]}),t.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:a.description}),t.jsx("div",{className:"mt-3 text-sm text-white/46",children:a.replacementMove||a.repairPlan||"No recovery step recorded yet."})]},a.id))]},e))})}),t.jsx(Te,{open:X,onOpenChange:c,eyebrow:"Behavior",title:h?"Refine behavior path":"Create behavior",description:"Use this guided flow to describe the behavior, when it shows up, what it gives you, and what kind of move it is.",value:y,onChange:m,draftPersistenceKey:h?`psyche.behavior.${h.id}`:"psyche.behavior.new",steps:he,submitLabel:h?"Save behavior":"Create behavior",pending:F.isPending,error:Y,onSubmit:async()=>{x(null);const e=H.safeParse(y);if(!e.success){x("This behavior still needs a kind and a title before it can be saved.");return}try{await F.mutateAsync(e.data)}catch(a){x(a instanceof Error?a.message:"Unable to save this behavior right now.")}}})]})}export{ct as PsycheBehaviorsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c2 as T,r as h,j as e,b4 as B,b3 as z,cI as M,aG as R,aK as q}from"./vendor-DHkYh85p.js";import{j as Q,i as K,k as L}from"./state-B-4sS1xO.js";import{u as O,s as Y,cv as H,cw as V,cx as W,L as G,E as X,B as S,ck as Z,I as x,c as N,U as D,Z as y,T as J,a0 as $,a1 as ee,bB as se}from"./index-BHTUu_4M.js";import{u as te,p as ae}from"./use-psyche-focus-target-C1C_XjYG.js";import{P as le}from"./page-hero-CQWo1Mm_.js";import{f as ie}from"./psyche-schemas-HFmg37Wj.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";const w={title:"",message:"",triggerSentence:"",triggerSituation:"",tags:[],backgroundColor:"#f8fafc",textColor:"#111827",accentColor:"#6ee7b7",typography:"serif",imageUrl:"",imageAlt:"",layout:"centered",visualStyle:"calm",linkedValueIds:[],linkedBehaviorIds:[],linkedPatternIds:[],linkedBeliefIds:[],linkedModeIds:[],linkedReportIds:[],userId:null},re={serif:"font-serif",sans:"font-sans",mono:"font-mono",display:"font-display"},ne={calm:"Calm",urgent:"Urgent",warm:"Warm",clinical:"Clinical",playful:"Playful"};function oe(s){return s.split(",").map(r=>r.trim()).filter(Boolean)}function _(s){return{title:s.title,message:s.message,triggerSentence:s.triggerSentence,triggerSituation:s.triggerSituation,tags:s.tags,backgroundColor:s.backgroundColor,textColor:s.textColor,accentColor:s.accentColor,typography:s.typography,imageUrl:s.imageUrl,imageAlt:s.imageAlt,layout:s.layout,visualStyle:s.visualStyle,linkedValueIds:s.linkedValueIds,linkedBehaviorIds:s.linkedBehaviorIds,linkedPatternIds:s.linkedPatternIds,linkedBeliefIds:s.linkedBeliefIds,linkedModeIds:s.linkedModeIds,linkedReportIds:s.linkedReportIds,userId:s.userId??null}}function A({card:s,compact:r=!1,focused:t=!1,onClick:p}){const c=s.imageUrl.trim().length>0,n=s.layout,d=s.title.trim(),v=s.triggerSentence.trim()||s.triggerSituation.trim();return e.jsxs("button",{type:"button",className:y("group min-w-0 rounded-[26px] border p-2 text-left shadow-[0_26px_80px_rgba(3,8,18,0.28)] transition hover:-translate-y-0.5 hover:border-white/20",t?"border-[rgba(110,231,183,0.8)]":"border-white/10"),onClick:p,children:[e.jsxs("div",{className:y("relative grid min-h-[18rem] overflow-hidden rounded-[20px] border",r?"min-h-[15rem]":"sm:min-h-[21rem]",n==="image_split"&&c?"md:grid-cols-[0.9fr_1.1fr]":""),style:{background:s.backgroundColor,color:s.textColor,borderColor:s.accentColor},children:[c&&n!=="image_split"?e.jsx("img",{src:s.imageUrl,alt:s.imageAlt||d||"Flashcard image",className:"absolute inset-0 size-full object-cover opacity-30"}):null,c&&n==="image_split"?e.jsx("div",{className:"relative min-h-[10rem] overflow-hidden",children:e.jsx("img",{src:s.imageUrl,alt:s.imageAlt||d||"Flashcard image",className:"absolute inset-0 size-full object-cover"})}):null,e.jsxs("div",{className:y("relative z-10 flex min-w-0 flex-col p-6",n==="top_left"?"items-start justify-start":"items-center justify-center text-center",n==="poster"?"min-h-[22rem] p-8":"",re[s.typography]),children:[e.jsx("div",{className:"mb-5 h-1.5 w-16 rounded-full",style:{backgroundColor:s.accentColor}}),e.jsx("div",{className:y("max-w-[24rem] text-balance leading-[1.12]",r?"text-2xl":"text-[clamp(1.9rem,4vw,3.45rem)]"),children:s.message||"Write the sentence that should meet you in the hard moment."}),v?e.jsx("div",{className:"mt-6 max-w-md rounded-full border px-3 py-1.5 text-xs font-medium opacity-75",style:{borderColor:s.accentColor},children:v}):null]})]}),e.jsxs("div",{className:"px-2 pt-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[d?e.jsx("div",{className:"truncate text-sm font-semibold text-white",children:d}):null,e.jsx(N,{className:"bg-white/[0.06] text-white/70",children:ne[s.visualStyle]})]}),s.tags.length>0?e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:s.tags.slice(0,5).map(o=>e.jsx("span",{className:"rounded-full bg-white/[0.06] px-2 py-1 text-[11px] text-white/55",children:o},o))}):null]})]})}function ce({open:s,editingCard:r,draft:t,users:p,suggestedOwner:c,submitError:n,saving:d,onClose:v,onDelete:o,onDraftChange:i,onSubmit:m}){return s?e.jsx("div",{className:"fixed inset-0 z-50 flex items-end justify-center bg-[rgba(3,8,18,0.76)] px-3 py-4 backdrop-blur-xl sm:items-center sm:p-6",children:e.jsxs("div",{className:"max-h-[min(92dvh,58rem)] w-full max-w-6xl overflow-hidden rounded-[30px] border border-white/10 bg-[linear-gradient(180deg,rgba(17,24,39,0.98),rgba(7,12,22,0.98))] shadow-[0_42px_120px_rgba(0,0,0,0.5)]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-white/8 px-5 py-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--tertiary)]",children:r?"Edit flashcard":"New flashcard"}),e.jsx("div",{className:"mt-1 text-lg font-semibold text-white",children:"Message first, retrieval second, styling last."})]}),e.jsx("button",{type:"button","aria-label":"Close flashcard editor",className:"inline-flex size-10 shrink-0 items-center justify-center rounded-full border border-white/10 bg-white/[0.06] text-white/65 hover:bg-white/[0.1]",onClick:v,children:e.jsx(q,{className:"size-4"})})]}),e.jsxs("div",{className:"grid max-h-[calc(min(92dvh,58rem)-5rem)] min-h-0 overflow-y-auto p-4 md:grid-cols-[1fr_0.9fr] md:p-5",children:[e.jsxs("div",{className:"grid content-start gap-4 pr-0 md:pr-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-white/48",children:"Main message"}),e.jsx(J,{className:"mt-2 min-h-28",value:t.message,placeholder:"This urge is a wave. You do not have to obey it.",onChange:l=>i({...t,message:l.target.value})})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-white/48",children:"Trigger sentence"}),e.jsx(x,{className:"mt-2",value:t.triggerSentence,placeholder:"I feel the urge to…",onChange:l=>i({...t,triggerSentence:l.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-white/48",children:"Optional title"}),e.jsx(x,{className:"mt-2",value:t.title,placeholder:"Late-night urge card",onChange:l=>i({...t,title:l.target.value})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-white/48",children:"Trigger situation"}),e.jsx(x,{className:"mt-2",value:t.triggerSituation,placeholder:"Late evening shame, loneliness, conflict, or boredom",onChange:l=>i({...t,triggerSituation:l.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-white/48",children:"Tags"}),e.jsx(x,{className:"mt-2",value:t.tags.join(", "),placeholder:"urge, sobriety, grounding",onChange:l=>i({...t,tags:oe(l.target.value)})})]}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-3",children:[["backgroundColor","Background"],["textColor","Text"],["accentColor","Accent"]].map(([l,u])=>e.jsxs("label",{className:"grid gap-2 text-xs font-semibold uppercase tracking-[0.16em] text-white/48",children:[u,e.jsx("input",{type:"color",value:String(t[l]),className:"h-11 w-full rounded-[16px] border border-white/10 bg-white/[0.05] p-1",onChange:k=>i({...t,[l]:k.target.value})})]},l))}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[e.jsxs("label",{className:"grid gap-2 text-xs font-semibold uppercase tracking-[0.16em] text-white/48",children:["Typography",e.jsxs("select",{className:"h-11 rounded-[16px] border border-white/10 bg-[rgba(15,23,42,0.95)] px-3 text-sm normal-case tracking-normal text-white",value:t.typography,onChange:l=>i({...t,typography:l.target.value}),children:[e.jsx("option",{value:"serif",children:"Serif"}),e.jsx("option",{value:"sans",children:"Sans"}),e.jsx("option",{value:"mono",children:"Mono"}),e.jsx("option",{value:"display",children:"Display"})]})]}),e.jsxs("label",{className:"grid gap-2 text-xs font-semibold uppercase tracking-[0.16em] text-white/48",children:["Layout",e.jsxs("select",{className:"h-11 rounded-[16px] border border-white/10 bg-[rgba(15,23,42,0.95)] px-3 text-sm normal-case tracking-normal text-white",value:t.layout,onChange:l=>i({...t,layout:l.target.value}),children:[e.jsx("option",{value:"centered",children:"Centered"}),e.jsx("option",{value:"top_left",children:"Top left"}),e.jsx("option",{value:"image_split",children:"Image split"}),e.jsx("option",{value:"poster",children:"Poster"})]})]}),e.jsxs("label",{className:"grid gap-2 text-xs font-semibold uppercase tracking-[0.16em] text-white/48",children:["Tone",e.jsxs("select",{className:"h-11 rounded-[16px] border border-white/10 bg-[rgba(15,23,42,0.95)] px-3 text-sm normal-case tracking-normal text-white",value:t.visualStyle,onChange:l=>i({...t,visualStyle:l.target.value}),children:[e.jsx("option",{value:"calm",children:"Calm"}),e.jsx("option",{value:"urgent",children:"Urgent"}),e.jsx("option",{value:"warm",children:"Warm"}),e.jsx("option",{value:"clinical",children:"Clinical"}),e.jsx("option",{value:"playful",children:"Playful"})]})]})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-white/48",children:"Image URL"}),e.jsx(x,{className:"mt-2",value:t.imageUrl,placeholder:"https://…",onChange:l=>i({...t,imageUrl:l.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-white/48",children:"Image alt"}),e.jsx(x,{className:"mt-2",value:t.imageAlt,placeholder:"Describe the image",onChange:l=>i({...t,imageAlt:l.target.value})})]})]}),e.jsx($,{users:p,value:t.userId??null,defaultLabel:ee(c,"Choose flashcard owner"),onChange:l=>i({...t,userId:l}),help:"Flashcards can belong to a human or bot owner while still being searchable by trigger, tags, and linked Psyche records."}),n?e.jsx("div",{className:"rounded-[18px] border border-red-300/20 bg-red-400/10 px-4 py-3 text-sm text-red-100",children:n}):null,e.jsxs("div",{className:"flex flex-wrap justify-between gap-3",children:[r?e.jsx(S,{type:"button",variant:"ghost",onClick:o,children:"Delete"}):e.jsx("span",{}),e.jsx(S,{type:"button",disabled:d,onClick:m,children:d?"Saving...":"Save flashcard"})]})]}),e.jsx("div",{className:"mt-5 min-w-0 md:mt-0",children:e.jsx(A,{card:t,compact:!0})})]})]})}):null}function ye(){var F;const s=O(),r=Q(),[t,p]=T(),c=t.get("focus"),[n,d]=h.useState(""),[v,o]=h.useState(!1),[i,m]=h.useState(null),[l,u]=h.useState(w),[k,C]=h.useState(null),b=Y(s.selectedUserIds),E=s.snapshot.users.find(a=>a.id===b)??null;te(c);const j=K({queryKey:["forge-psyche-flashcards",s.selectedUserIds],queryFn:()=>se(s.selectedUserIds)});h.useEffect(()=>{if(t.get("create")==="1"){m(null),u({...w,userId:b}),o(!0);const a=new URLSearchParams(t);a.delete("create"),p(a,{replace:!0})}},[b,t,p]);const P=L({mutationFn:async a=>{const g=ie.parse(a);return i?H(i.id,g):V(g)},onSuccess:async()=>{o(!1),m(null),u({...w,userId:b}),C(null),await Promise.all([r.invalidateQueries({queryKey:["forge-psyche-flashcards"]}),r.invalidateQueries({queryKey:["forge-psyche-overview"]})])},onError:a=>{C(a instanceof Error?a.message:String(a))}}),U=L({mutationFn:async a=>W(a.id),onSuccess:async()=>{o(!1),m(null),await Promise.all([r.invalidateQueries({queryKey:["forge-psyche-flashcards"]}),r.invalidateQueries({queryKey:["forge-psyche-overview"]})])}}),f=((F=j.data)==null?void 0:F.flashcards)??[],I=h.useMemo(()=>{const a=n.trim().toLowerCase();return a?f.filter(g=>[g.title,g.message,g.triggerSentence,g.triggerSituation,...g.tags].join(" ").toLowerCase().includes(a)):f},[f,n]);return j.isLoading?e.jsx(G,{title:"Loading Psyche flashcards"}):j.isError?e.jsx(X,{eyebrow:"Psyche",error:j.error,onRetry:()=>void j.refetch()}):e.jsxs("div",{className:"grid gap-6",children:[e.jsx(le,{title:"Flashcards",titleText:"Flashcards",description:"Small therapeutic reminder cards for urges, trigger moments, mode shifts, and values-based pivots.",actions:e.jsxs(S,{type:"button",onClick:()=>{m(null),u({...w,userId:b}),o(!0)},children:[e.jsx(B,{className:"mr-2 size-4"}),"New flashcard"]})}),e.jsx(Z,{}),e.jsxs("div",{className:"grid gap-4 rounded-[26px] border border-white/10 bg-white/[0.04] p-4 md:grid-cols-[1fr_auto] md:items-center",children:[e.jsxs("div",{className:"relative min-w-0",children:[e.jsx(z,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-white/38"}),e.jsx(x,{value:n,placeholder:"Search message, tags, trigger sentence, or situation",className:"pl-10",onChange:a=>d(a.target.value)})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-sm text-white/52",children:[e.jsxs(N,{className:"bg-white/[0.06] text-white/70",children:[f.length," saved"]}),e.jsxs(N,{className:"bg-white/[0.06] text-white/70",children:[I.length," visible"]})]})]}),I.length>0?e.jsx("div",{className:"grid gap-5 lg:grid-cols-2 2xl:grid-cols-3",children:I.map(a=>e.jsxs("div",{className:ae(c===a.id),children:[e.jsx(A,{card:a,focused:c===a.id,onClick:()=>{m(a),u(_(a)),o(!0)}}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-2 px-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[a.user?e.jsx(D,{user:a.user,compact:!0}):null,a.imageUrl?e.jsxs(N,{className:"bg-white/[0.06] text-white/60",children:[e.jsx(M,{className:"mr-1 size-3"}),"image"]}):null]}),e.jsx(S,{type:"button",variant:"ghost",onClick:()=>{m(a),u(_(a)),o(!0)},children:"Edit"})]})]},a.id))}):e.jsxs("div",{className:"rounded-[30px] border border-white/10 bg-[linear-gradient(135deg,rgba(110,231,183,0.08),rgba(96,165,250,0.08))] p-8 text-center",children:[e.jsx(R,{className:"mx-auto size-8 text-[var(--tertiary)]"}),e.jsx("div",{className:"mt-4 text-xl font-semibold text-white",children:"No flashcards match this view."}),e.jsx("div",{className:"mx-auto mt-2 max-w-xl text-sm leading-6 text-white/58",children:"Create cards for the sentences you want available during urges, shame spirals, critic attacks, and values-based pivots."})]}),e.jsx(ce,{open:v,editingCard:i,draft:l,users:s.snapshot.users,suggestedOwner:E,submitError:k,saving:P.isPending||U.isPending,onClose:()=>{o(!1),m(null),C(null)},onDelete:()=>{i&&U.mutateAsync(i)},onDraftChange:u,onSubmit:()=>void P.mutateAsync(l)})]})}export{ye as PsycheFlashcardsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as p,j as e,aC as m}from"./vendor-DHkYh85p.js";import{i as k}from"./state-B-4sS1xO.js";import{b as N,P as I}from"./psyche-graph-CFgs_Bqc.js";import{u as S,L as G,E as P,ck as E,C as K,b as L,V as B,c as f,Z as V,cm as C,ad as H}from"./index-BHTUu_4M.js";import{P as M}from"./page-hero-CQWo1Mm_.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";function T(){var u;const r=S(),[x,g]=p.useState(null),l=k({queryKey:["forge-psyche-overview"],queryFn:H}),n=(u=l.data)==null?void 0:u.overview,o=p.useMemo(()=>n?r.snapshot.goals.map(i=>{const h=n.values.filter(s=>s.linkedGoalIds.includes(i.id)),w=r.snapshot.dashboard.projects.filter(s=>s.goalId===i.id),b=r.snapshot.habits.filter(s=>s.linkedGoalIds.includes(i.id)||s.linkedValueIds.some(d=>h.some(c=>c.id===d))),y=n.reports.filter(s=>s.linkedGoalIds.includes(i.id)),v=n.behaviors.filter(s=>s.linkedValueIds.some(d=>h.some(c=>c.id===d))),j=n.beliefs.filter(s=>s.linkedValueIds.some(d=>h.some(c=>c.id===d)));return{goal:i,linkedValues:h,linkedProjects:w,linkedHabits:b,linkedReports:y,linkedBehaviors:v,linkedBeliefs:j}}):[],[n,r.snapshot.dashboard.projects,r.snapshot.goals,r.snapshot.habits]),a=p.useMemo(()=>N(o),[o]);if(p.useEffect(()=>{g(a.defaultSelectedId)},[a.defaultSelectedId]),l.isLoading)return e.jsx(G,{eyebrow:"Goal map",title:"Loading the gravity well",description:"Linking goals, values, reports, beliefs, behaviors, and projects back into execution."});if(l.isError||!n)return e.jsx(P,{eyebrow:"Goal map",error:l.error??new Error("Forge returned an empty Psyche overview payload."),onRetry:()=>void l.refetch()});const t=a.inspectors[x??a.defaultSelectedId]??a.inspectors[a.defaultSelectedId];return e.jsxs("div",{className:"grid min-w-0 gap-4",children:[e.jsx(M,{title:"Goal Map",titleText:"Goal Map",description:"Values orbit each goal. Habits, reports, beliefs, behaviors, and projects reveal where the orbit gets disrupted and how execution reconnects.",badge:`${o.length} goal${o.length===1?"":"s"}`,actions:e.jsxs(e.Fragment,{children:[e.jsx(m,{to:"/goals",className:"inline-flex min-h-10 min-w-max shrink-0 items-center justify-center rounded-full bg-white/[0.08] px-4 py-2 text-sm whitespace-nowrap text-white transition hover:bg-white/[0.12]",children:"Open goals"}),e.jsx(m,{to:"/psyche/reports?create=1",className:"inline-flex min-h-10 min-w-max shrink-0 items-center justify-center rounded-full bg-[rgba(125,211,252,0.16)] px-4 py-2 text-sm whitespace-nowrap text-white transition hover:bg-[rgba(125,211,252,0.22)]",children:"Reflect"})]})}),e.jsx(E,{}),e.jsxs("section",{className:"grid min-w-0 gap-4 xl:grid-cols-[minmax(0,1fr)_20rem]",children:[e.jsx(I,{testId:"goal-gravity-graph",title:"Life direction, value orbit, and execution field",hint:"Drag to inspect the whole field. Select any goal, value, belief, behavior, project, or report to see what it means and where to act next.",nodes:a.nodes,edges:a.edges,fields:a.fields,selectedNodeId:x,onSelectNode:g,minHeightClassName:"min-h-[25rem] sm:min-h-[34rem] lg:min-h-[56rem]",legend:[{label:"Goals",kind:"goal"},{label:"Values",kind:"value"},{label:"Beliefs",kind:"belief"},{label:"Behaviors",kind:"behavior"},{label:"Habits",kind:"habit"},{label:"Projects",kind:"project"},{label:"Reports",kind:"report"}],action:o.length===0?e.jsx(m,{to:"/goals",className:"inline-flex min-h-10 min-w-max shrink-0 items-center justify-center rounded-[var(--radius-control)] bg-[linear-gradient(135deg,rgba(192,193,255,0.36),rgba(192,193,255,0.22))] px-4 py-2 text-sm font-medium whitespace-nowrap text-white",children:"Add first goal"}):e.jsx(m,{to:"/goals",className:"inline-flex min-h-10 min-w-max shrink-0 items-center justify-center rounded-[var(--radius-control)] bg-white/8 px-4 py-2 text-sm font-medium whitespace-nowrap text-white transition hover:bg-white/12",children:"Open goals"})}),e.jsxs(K,{className:"min-w-0 h-fit xl:sticky xl:top-24",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:t.entityKind?e.jsx(L,{kind:t.entityKind,compact:!0,gradient:!1,iconOnly:!0}):e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:t.eyebrow})}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[t.entityKind?e.jsx(B,{kind:t.entityKind,label:t.title,variant:"heading",size:"lg",showKind:!1}):e.jsx("h2",{className:"font-display text-[clamp(1.35rem,2.2vw,2rem)] leading-none text-white",children:t.title}),t.entityKind?null:e.jsx(f,{className:"bg-white/[0.08]",style:{color:"white"},children:t.tone})]}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-white/60",children:t.summary}),t.stats.length>0?e.jsx("div",{className:"mt-4 grid gap-2",children:t.stats.map(i=>e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] px-3 py-3 text-sm text-white/68",children:i},i))}):null,t.chips.length>0?e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:t.chips.map(i=>e.jsx(f,{className:"bg-white/[0.08] text-white/74",children:i},i))}):null,e.jsx("div",{className:"mt-5",children:e.jsx(m,{to:t.href,className:V("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-[0_12px_30px_rgba(192,193,255,0.08)]",t.entityKind?C(t.entityKind,!0):"bg-[linear-gradient(135deg,rgba(192,193,255,0.36),rgba(192,193,255,0.22))] text-white"),children:t.ctaLabel})})]})]})]})}export{T as PsycheGoalMapPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as v,b5 as Xt,j as c,cJ as Rt,b4 as zt,cn as Ct,cK as Pt,cL as _t}from"./vendor-DHkYh85p.js";import{Z as ht,B as at,aR as gt}from"./index-BHTUu_4M.js";function q(n,i,r){return`${i}:${n}:${r}`}function ft(n,i,r){return Math.min(Math.max(n,i),r)}function mt(n,i,r){return Math.min(r,Math.max(1,Math.ceil(n.trim().length/i)))}function Nt(n,{compact:i}){const r=mt(n,i?13:14,4),p=(i?114:156)+(r-1)*(i?12:18)+Math.min(24,Math.max(0,n.trim().length-18))*(i?.7:1);return ft(p,i?118:164,i?154:210)}function Tt(n,{compact:i}){const r=mt(n,i?11:13,3),p=(i?40:48)+(r-1)*(i?6:8)+Math.min(i?18:26,Math.max(0,n.trim().length-(i?12:16)))*(i?.45:.55);return ft(p,i?42:50,i?56:68)}function et(n,{compact:i,emphasis:r=!1}){const p=mt(n,i?16:r?22:20,r?3:2);return{width:ft((i?r?184:152:r?224:176)+Math.min(n.length,48)*(i?1.8:2.15),i?r?188:156:r?228:184,i?r?248:208:r?300:244),height:p===1?i?64:70:p===2?i?82:92:i?98:110}}function kt(n){if(n.kind==="goal"||n.kind==="value"||n.kind==="ghost"){const i=n.radius??(n.kind==="goal"?76:34);return{halfWidth:i,halfHeight:i}}return{halfWidth:(n.width??146)/2,halfHeight:(n.height??58)/2}}function Et(n,{compact:i}){const r=n.map(u=>({...u,homeX:u.x,homeY:u.y,locked:u.kind==="goal"||u.kind==="ghost"})),x=i?28:40,p=i?.08:.06;for(let u=0;u<180;u+=1){for(const s of r)s.locked||(s.x+=(s.homeX-s.x)*p,s.y+=(s.homeY-s.y)*p);for(let s=0;s<r.length;s+=1)for(let w=s+1;w<r.length;w+=1){const g=r[s],$=r[w],h=kt(g),F=kt($),j=$.x-g.x,z=$.y-g.y,y=h.halfWidth+F.halfWidth+x-Math.abs(j),b=h.halfHeight+F.halfHeight+x-Math.abs(z);if(y<=0||b<=0)continue;const I=y<b?"x":"y",P=Math.sign(I==="x"?j||w-s||1:z||w-s||1),E=(I==="x"?y:b)/(g.locked||$.locked?1:2);g.locked||(I==="x"?g.x-=P*E:g.y-=P*E),$.locked||(I==="x"?$.x+=P*E:$.y+=P*E)}}return r.map(({homeX:u,homeY:s,locked:w,...g})=>g)}function Dt(){return{nodes:[{id:"ghost_goal_north",kind:"ghost",x:-250,y:-20,radius:68,label:"First goal",meta:"Goal",href:"/goals"},{id:"ghost_goal_center",kind:"ghost",x:0,y:34,radius:74,label:"Life goals",meta:"Goal",href:"/goals"},{id:"ghost_goal_south",kind:"ghost",x:250,y:-10,radius:68,label:"Direction",meta:"Goal",href:"/goals"}],edges:[],fields:[],inspectors:{ghost_goal_center:{id:"ghost_goal_center",eyebrow:"Goals",title:"Add the first life goal",summary:"The graph is already laid out. Once a goal exists, values, reports, beliefs, and behaviors will start orbiting it instead of staying fragmented.",href:"/goals",ctaLabel:"Open life goals",tone:"sky",entityKind:"goal",chips:["Goals","Values","Reports"],stats:["0 goals mapped yet"]}},defaultSelectedId:"ghost_goal_center"}}function Wt(n,{compact:i=!1}={}){var $;if(n.length===0)return Dt();const r=[],x=[],p=[],u={},s=i?560:840,w=-((n.length-1)*s)/2;n.forEach((h,F)=>{const j=w+F*s,z=F%2===0?92:146,y=h.linkedBehaviors.length+h.linkedBeliefs.length+h.linkedReports.length+h.linkedHabits.length,b=`goal:${h.goal.id}`;r.push({id:b,kind:"goal",x:j,y:z,radius:Nt(h.goal.title,{compact:i}),tone:"amber",label:h.goal.title,href:`/goals/${h.goal.id}`}),u[b]={id:b,eyebrow:"Goal",title:h.goal.title,summary:h.goal.description,href:`/goals/${h.goal.id}`,ctaLabel:"Open goal",tone:"amber",entityKind:"goal",chips:h.linkedValues.slice(0,4).map(e=>e.title),stats:[`${h.linkedValues.length} linked value${h.linkedValues.length===1?"":"s"}`,`${h.linkedProjects.length} live project${h.linkedProjects.length===1?"":"s"}`,`${h.linkedHabits.length} linked habit${h.linkedHabits.length===1?"":"s"}`,`${y} friction signal${y===1?"":"s"}`]},y>0&&p.push({id:`field:${h.goal.id}`,x:j+18,y:z+20,radiusX:i?144:176,radiusY:i?104:132,tone:"rose",opacity:Math.min(.42,.14+y*.04)});const I=i?208:282;h.linkedValues.slice(0,i?4:5).forEach((e,d)=>{const m=(-95+d*(i?78:64))*(Math.PI/180),k=Tt(e.title,{compact:i}),G=j+Math.cos(m)*I,W=z+Math.sin(m)*I,K=q(h.goal.id,"value",e.id);r.push({id:K,kind:"value",x:G,y:W,radius:k,tone:"mint",label:e.title,meta:`${e.linkedGoalIds.length} goal${e.linkedGoalIds.length===1?"":"s"}`,href:`/psyche/values?focus=${e.id}#values-atlas`}),x.push({id:`${b}->${K}`,from:b,to:K,tone:"mint",strength:"medium"}),u[K]={id:K,eyebrow:"Value",title:e.title,summary:e.valuedDirection||e.whyItMatters||e.description,href:`/psyche/values?focus=${e.id}#values-atlas`,ctaLabel:"Open values",tone:"mint",entityKind:"value",chips:e.committedActions.slice(0,3),stats:[`${e.linkedProjectIds.length} linked project${e.linkedProjectIds.length===1?"":"s"}`,`${e.linkedTaskIds.length} linked task${e.linkedTaskIds.length===1?"":"s"}`]}});const P=h.linkedProjects.slice(0,i?2:3).map(e=>({project:e,size:et(e.title,{compact:i,emphasis:!0})})),E=i?24:30;let _=-(P.reduce((e,d)=>e+d.size.width,0)+Math.max(0,P.length-1)*E)/2;P.forEach(({project:e,size:d},m)=>{const k=q(h.goal.id,"project",e.id),G=j+_+d.width/2,W=z-(i?330:434)-m*(i?16:20);_+=d.width+E,r.push({id:k,kind:"project",x:G,y:W,width:d.width,height:d.height,tone:"sky",label:e.title,meta:"Project",href:`/projects/${e.id}`}),x.push({id:`${b}->${k}`,from:b,to:k,tone:"sky",strength:"medium"}),u[k]={id:k,eyebrow:"Project",title:e.title,summary:e.description,href:`/projects/${e.id}`,ctaLabel:"Open project",tone:"sky",entityKind:"project",chips:[e.status,e.goalTitle],stats:[`${e.progress}% progress`,`${e.activeTaskCount} active task${e.activeTaskCount===1?"":"s"}`]}}),h.linkedHabits.slice(0,i?2:3).forEach((e,d)=>{const m=q(h.goal.id,"habit",e.id),k=et(e.title,{compact:i}),G=j-(i?44:58),W=z+(i?228:294)+d*(i?92:104);r.push({id:m,kind:"habit",x:G,y:W,width:k.width,height:k.height,tone:"mint",label:e.title,meta:e.polarity,href:"/habits"}),x.push({id:`${b}->${m}`,from:b,to:m,tone:"mint",strength:e.dueToday?"high":"medium"}),u[m]={id:m,eyebrow:"Habit",title:e.title,summary:e.description||"Recurring operating record connected directly to this goal field.",href:"/habits",ctaLabel:"Open habits",tone:"mint",entityKind:"habit",chips:[e.polarity,e.frequency,e.dueToday?"due today":"checked in"],stats:[`${e.streakCount} streak`,`${e.rewardXp}/${e.penaltyXp} xp flow`]}});let O=z+(i?132:156);h.linkedBehaviors.slice(0,i?2:3).forEach(e=>{const d=q(h.goal.id,"behavior",e.id),m=et(e.title,{compact:i}),k=j-(i?272:352);r.push({id:d,kind:"behavior",x:k,y:O,width:m.width,height:m.height,tone:"orange",label:e.title,meta:e.kind,href:`/psyche/behaviors?focus=${e.id}#behavior-columns`}),x.push({id:`${b}->${d}`,from:b,to:d,tone:"orange",dashed:e.kind!=="committed",strength:e.kind==="committed"?"medium":"low"}),u[d]={id:d,eyebrow:"Behavior",title:e.title,summary:e.replacementMove||e.description||e.urgeStory,href:`/psyche/behaviors?focus=${e.id}#behavior-columns`,ctaLabel:"Open behaviors",tone:"orange",entityKind:"behavior",chips:[e.kind,...e.commonCues.slice(0,2)],stats:[e.shortTermPayoff?"Short-term payoff mapped":"Payoff still to map",e.longTermCost?"Long-term cost mapped":"Cost still to map"]},O+=m.height+(i?18:22)});let X=z+(i?8:10);h.linkedBeliefs.slice(0,i?2:3).forEach(e=>{const d=q(h.goal.id,"belief",e.id),m=et(e.statement,{compact:i,emphasis:!0}),k=j+(i?278:362);r.push({id:d,kind:"belief",x:k,y:X,width:m.width,height:m.height,tone:"violet",label:e.statement,meta:"belief",href:`/psyche/schemas-beliefs?focus=${e.id}`}),x.push({id:`${b}->${d}`,from:b,to:d,tone:"violet",dashed:!0,strength:"low"}),u[d]={id:d,eyebrow:"Belief",title:e.statement,summary:e.flexibleAlternative||e.originNote||"Belief script attached to this part of the map.",href:`/psyche/schemas-beliefs?focus=${e.id}`,ctaLabel:"Open beliefs",tone:"violet",entityKind:"belief",chips:[e.beliefType,`${e.confidence}% grip`],stats:[`${e.linkedBehaviorIds.length} linked behavior${e.linkedBehaviorIds.length===1?"":"s"}`,`${e.linkedReportIds.length} linked report${e.linkedReportIds.length===1?"":"s"}`]},X+=m.height+(i?18:22)});const D=h.linkedReports.slice(0,i?2:3).map(e=>({report:e,size:et(e.title,{compact:i})})),Z=i?20:26;let Q=-(D.reduce((e,d)=>e+d.size.width,0)+Math.max(0,D.length-1)*Z)/2;D.forEach(({report:e,size:d})=>{const m=q(h.goal.id,"report",e.id),k=j+Q+d.width/2,G=z+(i?332:430);Q+=d.width+Z,r.push({id:m,kind:"report",x:k,y:G,width:d.width,height:d.height,tone:"blue",label:e.title,meta:e.status,href:`/psyche/reports/${e.id}`}),x.push({id:`${b}->${m}`,from:b,to:m,tone:"sky",strength:"medium"}),u[m]={id:m,eyebrow:"Report",title:e.title,summary:e.eventSituation||e.customEventType||"Reflective chain linked into this goal.",href:`/psyche/reports/${e.id}`,ctaLabel:"Open report",tone:"blue",entityKind:"report",chips:[e.status,...e.nextMoves.slice(0,2)],stats:[`${e.emotions.length} emotion${e.emotions.length===1?"":"s"}`,`${e.behaviors.length} move${e.behaviors.length===1?"":"s"}`]}})});const g=(($=r[0])==null?void 0:$.id)??"ghost_goal_center";return{nodes:Et(r,{compact:i}),edges:x,fields:p,inspectors:u,defaultSelectedId:g}}const A={mint:"rgba(110,231,183,0.64)",sky:"rgba(125,211,252,0.66)",violet:"rgba(196,181,253,0.72)",rose:"rgba(251,113,133,0.68)",amber:"rgba(251,191,36,0.68)",orange:"rgba(251,146,60,0.72)",blue:"rgba(96,165,250,0.72)",slate:"rgba(148,163,184,0.52)"},dt={mint:"rgba(16,185,129,0.18)",sky:"rgba(56,189,248,0.18)",violet:"rgba(167,139,250,0.18)",rose:"rgba(251,113,133,0.18)",amber:"rgba(251,191,36,0.18)",orange:"rgba(251,146,60,0.18)",blue:"rgba(96,165,250,0.18)",slate:"rgba(148,163,184,0.12)"},H={mint:"rgba(209,250,229,0.98)",sky:"rgba(224,242,254,0.98)",violet:"rgba(237,233,254,0.98)",rose:"rgba(255,228,230,0.98)",amber:"rgba(254,243,199,0.98)",orange:"rgba(255,237,213,0.98)",blue:"rgba(219,234,254,0.98)",slate:"rgba(241,245,249,0.9)"};function $t(n){switch(n){case"goal":case"value":case"behavior":case"belief":case"report":case"project":case"habit":return n;default:return null}}function St(n){if(n.tone)return n.tone;switch(n.kind){case"goal":return"amber";case"value":return"mint";case"belief":return"violet";case"behavior":return"orange";case"project":return"sky";case"habit":return"mint";case"report":return"blue";default:return"slate"}}function Gt(n){if(n.kind==="ghost")return n.meta??null;const i=$t(n.kind);return i?gt(i).label:n.meta??null}function ut(n,i,r){return Math.min(Math.max(n,i),r)}function lt(n,i,r=3){const x=n.trim().split(/\s+/),p=[];let u="";for(let g=0;g<x.length;g+=1){const $=x[g],h=u?`${u} ${$}`:$;if(h.length>i&&u){if(p.push(u),p.length>=r-1){u=[$,...x.slice(g+1)].join(" ");break}u=$}else u=h}u&&p.push(u);const s=p.slice(0,r),w=s.length-1;return w>=0&&s[w].length>i&&(s[w]=`${s[w].slice(0,Math.max(1,i-1)).trimEnd()}…`),s}function Vt(n,i){if(n.length===0&&i.length===0)return{minX:-360,maxX:360,minY:-240,maxY:240};let r=Number.POSITIVE_INFINITY,x=Number.NEGATIVE_INFINITY,p=Number.POSITIVE_INFINITY,u=Number.NEGATIVE_INFINITY;for(const s of n){const w=s.kind==="goal"||s.kind==="value"||s.kind==="ghost"?s.radius??32:(s.width??124)/2,g=s.kind==="goal"||s.kind==="value"||s.kind==="ghost"?s.radius??32:(s.height??56)/2,$=s.meta&&(s.kind==="goal"||s.kind==="ghost")?48:0;r=Math.min(r,s.x-w),x=Math.max(x,s.x+w),p=Math.min(p,s.y-g-$),u=Math.max(u,s.y+g)}for(const s of i)r=Math.min(r,s.x-s.radiusX),x=Math.max(x,s.x+s.radiusX),p=Math.min(p,s.y-s.radiusY),u=Math.max(u,s.y+s.radiusY);return{minX:r,maxX:x,minY:p,maxY:u}}function wt(n){return{x:n.x,y:n.y}}function Lt(n){if(n.kind==="goal"){const i=n.radius??112;return lt(n.label,Math.max(14,Math.floor(i/7.2)),4)}if(n.kind==="value"||n.kind==="ghost"){const i=n.radius??40;return lt(n.label,Math.max(12,Math.floor(i/3)),3)}return n.kind==="project"?lt(n.label,Math.max(18,Math.floor((n.width??220)/10)),3):lt(n.label,Math.max(16,Math.floor((n.width??180)/10.5)),2)}function Bt(n){switch(n){case"goal":return"amber";case"project":return"sky";case"value":return"mint";case"behavior":return"orange";case"belief":return"violet";case"report":return"blue";default:return"slate"}}function Kt({nodes:n,edges:i,fields:r=[],title:x,hint:p,action:u,legend:s,selectedNodeId:w,onSelectNode:g,minHeightClassName:$="min-h-[34rem] lg:min-h-[44rem]",compact:h=!1,testId:F}){const j=v.useRef(null),z=Xt(),[y,b]=v.useState({width:0,height:0}),[I,P]=v.useState({scale:1,x:0,y:0}),[E,J]=v.useState(null),_=v.useRef(null),O=v.useRef({scale:1,x:0,y:0}),X=v.useRef(new Map),D=v.useRef(null),Z=v.useRef(0),S=v.useRef(!1),Q=v.useMemo(()=>new Map(n.map(t=>[t.id,t])),[n]),e=v.useMemo(()=>Vt(n,r),[r,n]),d=y.width>0&&y.width<640;v.useEffect(()=>{if(!j.current||typeof ResizeObserver>"u")return;const t=new ResizeObserver(a=>{const o=a[0];b({width:o.contentRect.width,height:o.contentRect.height})});return t.observe(j.current),()=>t.disconnect()},[]);const m=v.useCallback(()=>{if(!y.width||!y.height)return;const t=d?132:h?140:190,a=Math.max(e.maxX-e.minX,1),o=Math.max(e.maxY-e.minY,1),l=ut(Math.min(y.width/(a+t),y.height/(o+t)),d?.24:h?.4:.46,d?.76:h?1.04:1.18),f=(e.minX+e.maxX)/2,Y=(e.minY+e.maxY)/2;P({scale:l,x:y.width/2-f*l,y:y.height/2-Y*l})},[e.maxX,e.maxY,e.minX,e.minY,h,y.height,y.width,d]);v.useEffect(()=>{O.current=I},[I]),v.useEffect(()=>{S.current||m()},[m]);const k=v.useCallback((t,a,o)=>{const l=ut(t,.28,1.9);P(f=>{if(a==null||o==null)return{...f,scale:l};const Y=(a-f.x)/f.scale,V=(o-f.y)/f.scale;return{scale:l,x:a-Y*l,y:o-V*l}})},[]),G=v.useCallback(()=>{const t=[...X.current.values()];if(t.length<2){D.current=null;return}const[a,o]=t,l=Math.hypot(o.x-a.x,o.y-a.y);if(!Number.isFinite(l)||l<=0){D.current=null;return}const f=O.current;D.current={startDistance:l,startScale:f.scale,startViewportX:f.x,startViewportY:f.y,startMidpointX:(a.x+o.x)/2,startMidpointY:(a.y+o.y)/2}},[]),W=t=>{var l;t.preventDefault();const a=(l=j.current)==null?void 0:l.getBoundingClientRect();if(!a)return;S.current=!0;const o=t.deltaY<0?1.1:.9;k(I.scale*o,t.clientX-a.left,t.clientY-a.top)},K=t=>{var f;const a=(f=j.current)==null?void 0:f.getBoundingClientRect(),o=t.clientX-((a==null?void 0:a.left)??0),l=t.clientY-((a==null?void 0:a.top)??0);if(X.current.set(t.pointerId,{x:o,y:l}),X.current.size===1){const Y=O.current;_.current={pointerId:t.pointerId,originX:Y.x,originY:Y.y,startX:o,startY:l}}else _.current=null,G();t.currentTarget.setPointerCapture(t.pointerId)},vt=t=>{var V;const a=(V=j.current)==null?void 0:V.getBoundingClientRect(),o=t.clientX-((a==null?void 0:a.left)??0),l=t.clientY-((a==null?void 0:a.top)??0);if(X.current.has(t.pointerId)&&X.current.set(t.pointerId,{x:o,y:l}),D.current&&X.current.size>=2){const[R,N]=[...X.current.values()],C=Math.hypot(N.x-R.x,N.y-R.y);if(Number.isFinite(C)&&C>0){S.current=!0,Z.current=Date.now()+240;const tt=(R.x+N.x)/2,B=(R.y+N.y)/2,T=D.current,U=ut(T.startScale*C/T.startDistance,.24,1.42),ot=(T.startMidpointX-T.startViewportX)/T.startScale,ct=(T.startMidpointY-T.startViewportY)/T.startScale;P({scale:U,x:tt-ot*U,y:B-ct*U})}return}if(!_.current||_.current.pointerId!==t.pointerId||X.current.size!==1)return;S.current=!0;const f=o-_.current.startX,Y=l-_.current.startY;(Math.abs(f)>3||Math.abs(Y)>3)&&(Z.current=Date.now()+240),P(R=>{var N,C;return{...R,x:(((N=_.current)==null?void 0:N.originX)??R.x)+f,y:(((C=_.current)==null?void 0:C.originY)??R.y)+Y}})},xt=t=>{if(X.current.delete(t.pointerId),X.current.size<2&&(D.current=null),X.current.size===1){const[a,o]=[...X.current.entries()][0]??[];if(a!=null&&o){const l=O.current;_.current={pointerId:a,originX:l.x,originY:l.y,startX:o.x,startY:o.y}}}else _.current=null;t.currentTarget.hasPointerCapture(t.pointerId)&&t.currentTarget.releasePointerCapture(t.pointerId)},it=E??w??null,nt=v.useCallback(t=>{Date.now()<Z.current||(g==null||g(t.id),t.href&&z(t.href))},[z,g]);return c.jsxs("section",{"data-testid":F,className:ht("overflow-hidden rounded-[32px] border border-white/8 bg-[radial-gradient(circle_at_top,rgba(125,211,252,0.12),transparent_32%),linear-gradient(180deg,rgba(11,18,31,0.985),rgba(7,12,23,0.98))] shadow-[0_26px_90px_rgba(2,6,16,0.38)]","px-3 py-3 sm:px-4 sm:py-4 lg:px-5 lg:py-5"),children:[c.jsxs("div",{className:"mb-3 flex min-w-0 flex-wrap items-start justify-between gap-3",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[rgba(125,211,252,0.82)]",children:"Gravity well"}),c.jsx("h2",{className:ht("mt-2 font-display leading-none text-white",h?"text-[clamp(1.25rem,2vw,1.7rem)]":"text-[clamp(1.45rem,2.8vw,2.3rem)]"),children:x}),p?c.jsx("p",{className:"mt-1.5 max-w-3xl text-sm leading-6 text-white/54",children:d?"Select a node, pan the field, and open the full map when you need the wider structure.":p}):null]}),c.jsx("div",{className:"flex min-w-0 flex-wrap items-center justify-end gap-2",children:u})]}),c.jsxs("div",{ref:j,className:ht("group relative overflow-hidden rounded-[30px] border border-white/6 bg-[radial-gradient(circle_at_center,rgba(255,255,255,0.04),transparent_46%)] touch-none",$),style:{touchAction:"none"},onWheel:W,onPointerDown:K,onPointerMove:vt,onPointerUp:xt,onPointerCancel:xt,children:[c.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_center,rgba(110,231,183,0.06),transparent_28%),radial-gradient(circle_at_20%_20%,rgba(196,181,253,0.08),transparent_24%),linear-gradient(180deg,rgba(255,255,255,0.015),rgba(4,8,18,0.24))]"}),c.jsxs("div",{className:"absolute left-3 top-3 z-10 inline-flex max-w-[calc(100%-7rem)] items-center gap-2 rounded-full border border-white/8 bg-[rgba(8,14,25,0.78)] px-2.5 py-1.5 text-[11px] uppercase tracking-[0.18em] text-white/42 backdrop-blur-xl sm:left-4 sm:top-4 sm:max-w-none sm:px-3",onPointerDown:t=>t.stopPropagation(),children:[c.jsx(Rt,{className:"size-3.5"}),d?"Drag or pinch":"Drag to pan, scroll to zoom"]}),c.jsxs("div",{className:"absolute right-3 top-3 z-10 flex max-w-[calc(100%-1.5rem)] flex-wrap items-center justify-end gap-1.5 sm:right-4 sm:top-4 sm:max-w-none sm:gap-2",onPointerDown:t=>t.stopPropagation(),children:[c.jsx(at,{type:"button",variant:"secondary",size:"sm",className:"px-2.5 sm:px-3","aria-label":"Zoom in",onClick:()=>{S.current=!0,k(I.scale*1.12,y.width-96,72)},children:c.jsx(zt,{className:"size-4"})}),c.jsx(at,{type:"button",variant:"secondary",size:"sm",className:"px-2.5 sm:px-3","aria-label":"Zoom out",onClick:()=>{S.current=!0,k(I.scale*.88,y.width-96,72)},children:c.jsx(Ct,{className:"size-4"})}),c.jsxs(at,{type:"button",variant:"secondary",size:"sm",className:"px-2.5 sm:min-w-[4.75rem] sm:px-3","aria-label":"Fit graph",onClick:()=>{S.current=!0,m()},children:[c.jsx(Pt,{className:"size-4"}),d?null:"Fit"]}),c.jsxs(at,{type:"button",variant:"secondary",size:"sm",className:"px-2.5 sm:min-w-[5.5rem] sm:px-3","aria-label":"Reset graph",onClick:()=>{S.current=!1,m()},children:[c.jsx(_t,{className:"size-4"}),d?null:"Reset"]})]}),s&&s.length>0&&!d?c.jsx("div",{className:"absolute bottom-4 left-4 z-10 flex flex-wrap items-center gap-2 rounded-[24px] border border-white/8 bg-[rgba(8,14,25,0.76)] px-3 py-2 text-xs text-white/58 backdrop-blur-xl",children:s.map(t=>{const a=t.kind?Bt(t.kind):t.tone??"slate",o=t.kind?gt(t.kind).icon:null;return c.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap rounded-full bg-white/[0.04] px-2.5 py-1.5",children:[o?c.jsx(o,{className:"size-3.5",color:H[a],strokeWidth:2.1}):c.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:A[a]}}),t.label]},t.label)})}):null,c.jsxs("svg",{className:"relative z-[1] h-full w-full",viewBox:`0 0 ${y.width||1200} ${y.height||760}`,role:"img","aria-label":x,children:[c.jsx("defs",{children:c.jsx("filter",{id:"forge-graph-blur",children:c.jsx("feGaussianBlur",{stdDeviation:"34"})})}),c.jsxs("g",{transform:`translate(${I.x} ${I.y}) scale(${I.scale})`,children:[r.map(t=>c.jsx("ellipse",{cx:t.x,cy:t.y,rx:t.radiusX,ry:t.radiusY,fill:dt[t.tone??"rose"],opacity:t.opacity??.42,filter:"url(#forge-graph-blur)"},t.id)),n.filter(t=>t.kind==="goal"||t.kind==="ghost").map(t=>{const a=t.radius??76;return c.jsx("g",{opacity:t.kind==="ghost"?.28:.55,children:[a+74,a+124].map((o,l)=>c.jsx("circle",{cx:t.x,cy:t.y,r:o,fill:"none",stroke:l===0?"rgba(255,255,255,0.08)":"rgba(255,255,255,0.045)",strokeDasharray:l===0?"0":"10 10"},`${t.id}-ring-${o}`))},`${t.id}-orbital-lanes`)}),i.map(t=>{const a=Q.get(t.from),o=Q.get(t.to);if(!a||!o)return null;const l=wt(a),f=wt(o),Y=(l.x+f.x)/2,V=(l.y+f.y)/2,R=Math.max(24,Math.abs(l.x-f.x)*.08),N=Y,C=V-R;return c.jsx("path",{d:`M ${l.x} ${l.y} Q ${N} ${C} ${f.x} ${f.y}`,fill:"none",stroke:A[t.tone??"slate"],strokeWidth:t.strength==="high"?3:t.strength==="medium"?2.2:1.6,strokeDasharray:t.dashed?"8 8":void 0,opacity:it&&t.from!==it&&t.to!==it?.18:.62},t.id)}),n.map(t=>{t.id;const a=E===t.id,o=it===t.id,l=St(t),f=Gt(t),Y=Lt(t),V=$t(t.kind),R=V?gt(V).icon:null;if(t.kind==="goal"||t.kind==="value"||t.kind==="ghost"){const M=t.radius??(t.kind==="goal"?76:34),st=f?t.y-M-(t.kind==="goal"?18:10):null,yt=t.kind==="goal"?20:14.5,rt=t.kind==="goal"?28:16,It=t.kind==="goal"?t.y-M*.34:t.kind==="value"?t.y-M*.3:t.y-M*.2,Yt=t.kind==="goal"?t.y+M*.2:t.y+10;return c.jsxs("g",{tabIndex:0,role:"button",onPointerEnter:()=>{J(t.id),g==null||g(t.id)},onPointerLeave:()=>J(L=>L===t.id?null:L),onFocus:()=>g==null?void 0:g(t.id),onClick:()=>nt(t),onKeyDown:L=>{(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),nt(t))},className:"cursor-pointer outline-none",children:[c.jsx("circle",{cx:t.x,cy:t.y,r:M+(o?14:0),fill:o?`${A[l]}22`:"transparent",stroke:o?A[l]:"transparent",opacity:a?.98:.9}),c.jsx("circle",{cx:t.x,cy:t.y,r:M+(a?2:0),fill:t.kind==="ghost"?"rgba(255,255,255,0.03)":dt[l],stroke:t.kind==="ghost"?"rgba(255,255,255,0.18)":A[l],strokeDasharray:t.kind==="ghost"?"8 8":void 0,strokeWidth:o?2.8:1.6}),f?c.jsx("text",{x:t.x,y:st??t.y-12,textAnchor:"middle",fontSize:t.kind==="goal"?"11.5":"10.5",fill:t.kind==="ghost"?"rgba(255,255,255,0.62)":H[l],style:{letterSpacing:"0.18em",textTransform:"uppercase"},children:f}):null,R?c.jsx(R,{x:t.x-rt/2,y:It-rt/2,width:rt,height:rt,color:H[l],strokeWidth:2.1}):null,Y.map((L,bt)=>c.jsx("text",{x:t.x,y:Yt+bt*yt-(Y.length-1)*yt/2,textAnchor:"middle",fontSize:t.kind==="goal"?21:12.8,fontWeight:t.kind==="goal"?600:500,fill:t.kind==="ghost"?"rgba(255,255,255,0.92)":H[l],children:L},`${t.id}-${L}-${bt}`))]},t.id)}const N=t.width??146,C=t.height??58,tt=t.x-N/2,B=t.y-C/2,T=t.kind==="project"?14:13,U=tt+14,ot=B+13,ct=B+22,jt=f?B+C*.65:B+C*.56,pt=t.kind==="project"?16:15,Mt=t.kind==="project"?14.2:13.2;return c.jsxs("g",{tabIndex:0,role:"button",onPointerEnter:()=>{J(t.id),g==null||g(t.id)},onPointerLeave:()=>J(M=>M===t.id?null:M),onFocus:()=>g==null?void 0:g(t.id),onClick:()=>nt(t),onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),nt(t))},className:"cursor-pointer outline-none",children:[c.jsx("rect",{x:tt-(o?6:0),y:B-(o?6:0),rx:"28",ry:"28",width:N+(o?12:0),height:C+(o?12:0),fill:o?`${A[l]}22`:"transparent"}),c.jsx("rect",{x:tt-(a?2:0),y:B-(a?2:0),rx:"22",ry:"22",width:N+(a?4:0),height:C+(a?4:0),fill:dt[l],stroke:A[l],strokeWidth:o?2.3:1.3}),R?c.jsx(R,{x:U,y:ot,width:T,height:T,color:H[l],strokeWidth:2.1}):null,f?c.jsx("text",{x:U+T+8,y:ct,textAnchor:"start",fontSize:"9.5",fill:H[l],style:{letterSpacing:"0.16em",textTransform:"uppercase",opacity:.82},children:f}):null,Y.map((M,st)=>c.jsx("text",{x:t.x,y:jt+st*pt-(Y.length-1)*pt/2,textAnchor:"middle",fontSize:Mt,fontWeight:600,fill:H[l],children:M},`${t.id}-${M}-${st}`))]},t.id)})]})]})]})]})}export{Kt as P,Wt as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./vendor-DHkYh85p.js";import{i as g}from"./state-B-4sS1xO.js";import{L as h,E as p,ck as w,C as i,c as m,Z as u,cy as y}from"./index-BHTUu_4M.js";import{P as j}from"./page-hero-CQWo1Mm_.js";import{S as o,f as v,m as f,M as b}from"./daily-metrics-dashboard-LjuGAB3f.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";import"./charts-P7EVhIog.js";function a(t){return new Intl.NumberFormat().format(Math.round(t))}function c(t){return`${t.toFixed(t>=10?1:2)}%`}function N(t){return t.summary.categoryBreakdown.map(s=>({...s,metrics:t.metrics.filter(n=>n.category===s.category)}))}function P(){return e.jsxs(i,{className:"rounded-[30px] border-white/8 bg-[linear-gradient(180deg,rgba(14,20,32,0.96),rgba(9,13,24,0.98))] p-6",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"No daily metrics yet"}),e.jsx("div",{className:"mt-2 text-2xl font-semibold text-white",children:"Psyche metrics will appear after the first local backfill finds conversations."}),e.jsx("p",{className:"mt-3 max-w-3xl text-sm leading-6 text-white/58",children:"This surface stays quiet until Forge has stored daily metric rows. It does not run the scanner while rendering the page."})]})}function q(){const t=g({queryKey:["forge-psyche-metrics-view"],queryFn:async()=>(await y()).metrics});if(t.isLoading)return e.jsx(h,{title:"Loading Psyche metrics",description:"Reading stored daily metric rows and summary statistics."});if(t.isError||!t.data)return e.jsx(p,{eyebrow:"Psyche metrics",error:t.error??new Error("Psyche metrics unavailable"),onRetry:()=>void t.refetch()});const s=t.data,n=N(s),l=s.metrics.find(r=>r.metric==="devrageSwearCount")??null,x=s.metrics.find(r=>r.metric==="swearingMessagePercent")??null;return e.jsxs("div",{className:"mx-auto grid w-full max-w-[1380px] gap-5",children:[e.jsx(j,{title:"Psyche Metrics",titleText:"Psyche Metrics",description:"Daily Psyche measurements from stored history, presented with the same operational shape as Vitals.",badge:s.summary.hasData?`${s.summary.metricCount} daily metrics`:"No daily metrics yet"}),e.jsx(w,{}),s.summary.hasData?e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"grid gap-4 xl:grid-cols-4",children:[e.jsx(o,{title:"Devrage count",description:"Raw daily swear count across scanned user messages.",metric:l}),e.jsx(o,{title:"Swearing rate",description:"Percentage of user messages that contained at least one tracked swear.",metric:x}),e.jsxs(i,{className:"rounded-[28px] border border-amber-200/12 bg-[linear-gradient(180deg,rgba(39,31,17,0.96),rgba(19,21,17,0.95))] p-5",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-amber-100/72",children:"Seven-day averages"}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[18px] bg-white/[0.045] px-4 py-3",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Swears"}),e.jsx("span",{className:"text-xl font-semibold text-white",children:a(s.context.weeklyAverage.rawSwearCount)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[18px] bg-white/[0.045] px-4 py-3",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Swearing messages"}),e.jsx("span",{className:"text-xl font-semibold text-white",children:c(s.context.weeklyAverage.swearingMessagePercent)})]})]})]}),e.jsxs(i,{className:"rounded-[28px] border border-white/8 bg-[linear-gradient(180deg,rgba(13,19,37,0.96),rgba(10,14,30,0.96))] p-5",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Stored coverage"}),e.jsxs("div",{className:"mt-3 text-2xl font-semibold text-white",children:[s.summary.trackedDays," days"]}),e.jsxs("div",{className:"mt-3 grid gap-2 text-sm text-white/62",children:[e.jsxs("div",{children:[a(s.context.conversationsScanned)," conversations"]}),e.jsxs("div",{children:[a(s.context.messagesScanned)," user messages"]}),e.jsxs("div",{children:[s.context.sourceCount," source families"]})]})]})]}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.1fr)_minmax(340px,0.9fr)]",children:[e.jsxs(i,{className:"overflow-hidden rounded-[30px] border-white/8 bg-[radial-gradient(circle_at_top_left,rgba(251,191,36,0.14),transparent_36%),linear-gradient(180deg,rgba(20,18,31,0.98),rgba(10,13,26,0.98))] p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Coverage"}),e.jsxs("div",{className:"text-2xl font-semibold text-white",children:[s.summary.trackedDays," tracked days across ",s.summary.metricCount," metrics"]}),e.jsx("div",{className:"max-w-3xl text-sm leading-6 text-white/58",children:"Devrage is stored as daily Psyche measurements, so this view reads history from SQLite instead of rescanning conversations during page load."})]}),e.jsxs(m,{className:"bg-white/[0.08] text-white/72",children:["Latest snapshot ",v(s.summary.latestDateKey)]})]}),e.jsx("div",{className:"mt-5 grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:s.summary.categoryBreakdown.map(r=>{const d=f(r.category);return e.jsxs("div",{className:u("rounded-[22px] border bg-white/[0.03] p-4",d.ring),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(m,{className:d.badge,children:r.category}),e.jsxs("div",{className:"text-xs text-white/44",children:[r.coverageDays," days"]})]}),e.jsx("div",{className:"mt-3 text-2xl font-semibold text-white",children:r.metricCount}),e.jsxs("div",{className:"mt-1 text-sm text-white/58",children:["active metric",r.metricCount===1?"":"s"]})]},r.category)})})]}),e.jsx(i,{className:"rounded-[30px] border-white/8 bg-[linear-gradient(180deg,rgba(13,19,37,0.96),rgba(10,14,30,0.96))] p-6",children:e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Summary statistics"}),e.jsxs("div",{className:"text-lg font-semibold text-white",children:[a(s.context.totalSwears)," total swears across stored history."]}),e.jsxs("div",{className:"grid gap-3 text-sm leading-6 text-white/58",children:[e.jsxs("div",{children:["Daily average: ",a(s.context.dailyAverage.rawSwearCount)," swears and ",c(s.context.dailyAverage.swearingMessagePercent)," swearing messages."]}),e.jsxs("div",{children:["Weekly average: ",a(s.context.weeklyAverage.rawSwearCount)," swears and ",c(s.context.weeklyAverage.swearingMessagePercent)," swearing messages."]}),e.jsxs("div",{children:[a(s.context.messagesWithSwears)," user messages contained at least one tracked swear."]})]}),e.jsxs("div",{className:"mt-2 rounded-[22px] border border-white/8 bg-white/[0.035] p-4 text-sm text-white/70",children:[s.summary.latestMetricCount," metrics updated on the latest tracked day."]})]})})]}),e.jsx(b,{groups:n})]}):e.jsx(P,{})]})}export{q as PsycheMetricsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,aC as v}from"./vendor-DHkYh85p.js";import{j as N,i as w,k as S}from"./state-B-4sS1xO.js";import{u as C}from"./forms-BFlTgZ3W.js";import{cz as k,L as M,E as P,B as d,ck as q,C as l,a as j,c as f,cA as E}from"./index-BHTUu_4M.js";import{P as L}from"./page-hero-CQWo1Mm_.js";import{m as Q}from"./psyche-schemas-HFmg37Wj.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./motion-BeD44FeG.js";import"./graph-D6JLqDbD.js";function R(a){return a instanceof Error?a:typeof a=="string"&&a.trim().length>0?new Error(a):new Error("Forge could not complete the requested query collection.")}function _(a){const i=a.find(t=>t.isError);return{isLoading:a.some(t=>t.isPending||t.isLoading),error:i?R(i.error):null}}async function F(a){await Promise.all(a.map(i=>i.refetch()))}const n={copingResponse:[{value:"fight",label:"Fight"},{value:"flight",label:"Flight"},{value:"freeze",label:"Freeze"},{value:"detach",label:"Detach"},{value:"comply",label:"Comply"},{value:"overcompensate",label:"Overcompensate"},{value:"none",label:"Mixed / unsure"}],childState:[{value:"vulnerable",label:"Vulnerable"},{value:"angry",label:"Angry"},{value:"impulsive",label:"Impulsive"},{value:"lonely",label:"Lonely"},{value:"ashamed",label:"Ashamed"},{value:"none",label:"Mixed / unsure"}],criticStyle:[{value:"demanding",label:"Demanding"},{value:"punitive",label:"Punitive"},{value:"none",label:"Neither / unclear"}],healthyContact:[{value:"healthy_adult",label:"Healthy adult"},{value:"happy_child",label:"Happy child"},{value:"none",label:"Hard to access right now"}]};function D(){var u,p,x,g,y,b;const a=N(),i=w({queryKey:["forge-psyche-mode-guide-sessions"],queryFn:E}),t=C({defaultValues:{summary:"What mode was most present in this moment?",copingResponse:"none",childState:"none",criticStyle:"none",healthyContact:"none"}}),o=S({mutationFn:async s=>{const r=Q.parse({summary:s.summary,answers:[{questionKey:"coping_response",value:s.copingResponse},{questionKey:"child_state",value:s.childState},{questionKey:"critic_style",value:s.criticStyle},{questionKey:"healthy_contact",value:s.healthyContact}]});return k(r)},onSuccess:async()=>{await a.invalidateQueries({queryKey:["forge-psyche-mode-guide-sessions"]})}}),m=[i],c=_(m),h=((u=o.data)==null?void 0:u.session)??((x=(p=i.data)==null?void 0:p.sessions)==null?void 0:x[0]);return c.isLoading?e.jsx(M,{eyebrow:"Mode guide",title:"Loading guided sessions",description:"Hydrating previous mode-guide runs and the latest stored readings."}):c.error?e.jsx(P,{eyebrow:"Mode guide",error:c.error,onRetry:()=>void F(m)}):e.jsxs("div",{className:"grid gap-5",children:[e.jsx(L,{eyebrow:"Mode guide",title:"Guided Mode Identification",description:"A short guided pass can help separate coping responses, child states, critic pressure, and whatever healthy contact is still available.",badge:`${((g=i.data)==null?void 0:g.sessions.length)??0} sessions`,actions:e.jsx(v,{to:"/psyche/modes",children:e.jsx(d,{variant:"secondary",children:"Back to mode map"})})}),e.jsx(q,{}),e.jsxs("section",{className:"grid gap-5 xl:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[e.jsxs(l,{className:"bg-[linear-gradient(180deg,rgba(16,20,30,0.96),rgba(11,15,24,0.94))]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Guided questionnaire"}),e.jsxs("form",{className:"mt-4 grid gap-5",onSubmit:t.handleSubmit(async s=>o.mutateAsync(s)),children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Prompt"}),e.jsx("input",{className:"w-full rounded-2xl border border-white/8 bg-white/6 px-4 py-3 text-sm text-white outline-none placeholder:text-white/35",...t.register("summary")})]}),e.jsxs(l,{className:"rounded-[24px] bg-[rgba(248,113,113,0.08)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-rose-100/80",children:"When the pressure rose, what coping move dominated?"}),e.jsx("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:n.copingResponse.map(s=>e.jsxs("label",{className:"flex items-center gap-3 rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("input",{type:"radio",value:s.value,...t.register("copingResponse")}),e.jsx("span",{className:"text-white/74",children:s.label})]},s.value))})]}),e.jsxs(l,{className:"rounded-[24px] bg-[rgba(196,181,253,0.08)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-violet-100/80",children:"Which child state felt closest?"}),e.jsx("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:n.childState.map(s=>e.jsxs("label",{className:"flex items-center gap-3 rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("input",{type:"radio",value:s.value,...t.register("childState")}),e.jsx("span",{className:"text-white/74",children:s.label})]},s.value))})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(l,{className:"rounded-[24px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/48",children:"What was the critic like?"}),e.jsx("div",{className:"mt-3 grid gap-2",children:n.criticStyle.map(s=>e.jsxs("label",{className:"flex items-center gap-3 rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("input",{type:"radio",value:s.value,...t.register("criticStyle")}),e.jsx("span",{className:"text-white/74",children:s.label})]},s.value))})]}),e.jsxs(l,{className:"rounded-[24px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/48",children:"What healthy contact was still reachable?"}),e.jsx("div",{className:"mt-3 grid gap-2",children:n.healthyContact.map(s=>e.jsxs("label",{className:"flex items-center gap-3 rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("input",{type:"radio",value:s.value,...t.register("healthyContact")}),e.jsx("span",{className:"text-white/74",children:s.label})]},s.value))})]})]}),e.jsx(d,{type:"submit",children:"Run guide"})]})]}),e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(l,{className:"bg-[linear-gradient(180deg,rgba(15,21,34,0.96),rgba(10,15,23,0.94))]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Latest reading"}),h?e.jsxs("div",{className:"mt-4 grid gap-3",children:[h.results.map(s=>e.jsxs("div",{className:"rounded-[22px] bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-white",children:s.label}),e.jsxs(f,{className:"text-white/70",children:[Math.round(s.confidence*100),"%"]})]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:s.family.replaceAll("_"," ")}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/66",children:s.reasoning})]},`${s.family}:${s.label}`)),e.jsx(v,{to:"/psyche/modes",children:e.jsx(d,{variant:"secondary",children:"Use this in the mode map"})})]}):e.jsx("div",{className:"mt-4",children:e.jsx(j,{eyebrow:"Guided reading",title:"No guided sessions yet",description:"Run the guide once to separate coping response, child state, critic pressure, and reachable healthy contact."})})]}),e.jsxs(l,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Session history"}),e.jsx("div",{className:"mt-4 grid gap-3",children:(((y=i.data)==null?void 0:y.sessions)??[]).length===0?e.jsx(j,{eyebrow:"Session history",title:"No stored guide history",description:"Completed guide sessions will accumulate here so later mode-map work can build from real prior readings."}):(((b=i.data)==null?void 0:b.sessions)??[]).map(s=>e.jsxs("div",{className:"rounded-[20px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-medium text-white",children:s.summary}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:s.results.map(r=>e.jsx(f,{className:"text-white/72",children:r.label},`${s.id}:${r.label}`))})]},s.id))})]})]})]})]})}export{D as PsycheModeGuidePage};
|