forge-openclaw-plugin 0.2.118 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/dist/assets/{activity-page-DPPiiyLO.js → activity-page-DRRbpVK-.js} +1 -1
  2. package/dist/assets/{ai-surface-workspace-B_fV9C4s.js → ai-surface-workspace-DJPt-OaW.js} +1 -1
  3. package/dist/assets/{atlas-panel-BPTJyMcI.js → atlas-panel-G3wGxjYf.js} +1 -1
  4. package/dist/assets/{calendar-page-D4DcRQv7.js → calendar-page-y8G1ige8.js} +1 -1
  5. package/dist/assets/{calendar-rules-Cl_xMrBn.js → calendar-rules-CRhXqGQu.js} +1 -1
  6. package/dist/assets/{calendar-week-toolbar-BARSOEO9.js → calendar-week-toolbar-CWSK5hJl.js} +1 -1
  7. package/dist/assets/{companion-sync-lab-page-COFYDI3w.js → companion-sync-lab-page-kEgOF3c6.js} +1 -1
  8. package/dist/assets/daily-metrics-dashboard-BJjUIZVA.js +1 -0
  9. package/dist/assets/{entity-note-count-link-BX93WYgh.js → entity-note-count-link-ef3ZOpKM.js} +1 -1
  10. package/dist/assets/{entity-notes-surface-CBlKc-x-.js → entity-notes-surface-CaCjjUaq.js} +1 -1
  11. package/dist/assets/{execution-board-Dh41UeKR.js → execution-board-RRWm2srb.js} +1 -1
  12. package/dist/assets/{faceted-token-search-BgxYH_gW.js → faceted-token-search-CZmtyJTT.js} +1 -1
  13. package/dist/assets/{flagship-signal-deck-bolzzK8q.js → flagship-signal-deck-DxRfmfpN.js} +1 -1
  14. package/dist/assets/{floating-action-menu-C5H-Wr2B.js → floating-action-menu-cKjNsPYD.js} +1 -1
  15. package/dist/assets/{goal-detail-page-CQeFnGDJ.js → goal-detail-page-BgQlK7yT.js} +1 -1
  16. package/dist/assets/{goals-page-BTg9crEK.js → goals-page-Cz2i3pVy.js} +1 -1
  17. package/dist/assets/{habits-page-C4vqk346.js → habits-page-BmEmWCGv.js} +1 -1
  18. package/dist/assets/index-Bcem7l5u.css +1 -0
  19. package/dist/assets/{index-By3tQxiE.js → index-QJkjKYzZ.js} +2 -2
  20. package/dist/assets/{insight-flow-dialog-JPYCsTKI.js → insight-flow-dialog-CdYMHwMP.js} +1 -1
  21. package/dist/assets/{insights-page-CFhVMlVL.js → insights-page-DHG-o9P_.js} +1 -1
  22. package/dist/assets/{kanban-page-DC3IDsnh.js → kanban-page-C6S_fJRc.js} +1 -1
  23. package/dist/assets/{knowledge-graph-page-DucyRYTZ.js → knowledge-graph-page-juA9QCy0.js} +1 -1
  24. package/dist/assets/{life-force-page-UrXfxaSO.js → life-force-page-ChTIA4mV.js} +1 -1
  25. package/dist/assets/{life-force-workspace-BhPNH7ad.js → life-force-workspace-sszLD-Yn.js} +1 -1
  26. package/dist/assets/{metric-tile-DtRPjN4V.js → metric-tile-B-tDTcBt.js} +1 -1
  27. package/dist/assets/{movement-page-DCIdTQEN.js → movement-page-Dx3T3HrG.js} +1 -1
  28. package/dist/assets/{note-markdown-CepDxj3v.js → note-markdown-CCyyE85h.js} +1 -1
  29. package/dist/assets/{note-tags-input-BXYaDkOr.js → note-tags-input-BS14YXHn.js} +1 -1
  30. package/dist/assets/{notes-page-Bl1LlCLo.js → notes-page-D3yGl8TN.js} +1 -1
  31. package/dist/assets/{open-in-graph-button-C263zl5l.js → open-in-graph-button-CMjJZX7G.js} +1 -1
  32. package/dist/assets/{orbit-map-Cb_AJyIj.js → orbit-map-v2Pv9RU_.js} +1 -1
  33. package/dist/assets/{overview-page-C2yLity7.js → overview-page-DSOpBpHf.js} +1 -1
  34. package/dist/assets/{page-hero-5RTqAI88.js → page-hero-CONuJu5J.js} +1 -1
  35. package/dist/assets/{pill-cluster-CBrrtZBm.js → pill-cluster-W2fY48OM.js} +1 -1
  36. package/dist/assets/{preference-entity-handoff-button-BQzg2J4k.js → preference-entity-handoff-button-CKDxCnbl.js} +1 -1
  37. package/dist/assets/{preferences-page-DekYF-Yz.js → preferences-page-Br3zrLlH.js} +1 -1
  38. package/dist/assets/{project-collections-BVXB8PPF.js → project-collections-NBwk6yV-.js} +1 -1
  39. package/dist/assets/{project-detail-page-CQlrLEn9.js → project-detail-page-BIU9_TRN.js} +1 -1
  40. package/dist/assets/{project-management-hierarchy-page--mzM_zRE.js → project-management-hierarchy-page-C2H620xD.js} +1 -1
  41. package/dist/assets/{project-management-section-nav-DQl0qRWy.js → project-management-section-nav-DRPVS1Eh.js} +1 -1
  42. package/dist/assets/{projects-page-Dr_0NdVP.js → projects-page-w7a_L2-z.js} +1 -1
  43. package/dist/assets/{psyche-behaviors-page-DOUaCWON.js → psyche-behaviors-page-Dt4CMC-q.js} +1 -1
  44. package/dist/assets/{psyche-flashcards-page-BA84fO_X.js → psyche-flashcards-page-rXz06dqO.js} +1 -1
  45. package/dist/assets/{psyche-goal-map-page-DpXAg1Vf.js → psyche-goal-map-page-BCcD6Jkl.js} +1 -1
  46. package/dist/assets/{psyche-graph-BxcbAbXt.js → psyche-graph-CXlAj4ED.js} +1 -1
  47. package/dist/assets/psyche-metrics-page-B1otiir6.js +1 -0
  48. package/dist/assets/{psyche-mode-guide-page-CBlIS5N_.js → psyche-mode-guide-page-C6AdVIAv.js} +1 -1
  49. package/dist/assets/{psyche-modes-page-DE6KDK_1.js → psyche-modes-page-DoUqz2mR.js} +1 -1
  50. package/dist/assets/psyche-page-BJNLQn8W.js +1 -0
  51. package/dist/assets/{psyche-patterns-page-DbCNRuww.js → psyche-patterns-page-CzpMSAPu.js} +1 -1
  52. package/dist/assets/{psyche-questionnaire-builder-page-DnraDj1H.js → psyche-questionnaire-builder-page-DjzatGVZ.js} +1 -1
  53. package/dist/assets/{psyche-questionnaire-detail-page-DQ6zNQkk.js → psyche-questionnaire-detail-page-B0Qfowfg.js} +1 -1
  54. package/dist/assets/{psyche-questionnaire-run-detail-page-BGrOIX0B.js → psyche-questionnaire-run-detail-page-B2dNj4jJ.js} +1 -1
  55. package/dist/assets/{psyche-questionnaire-run-page-Bg3BhBHb.js → psyche-questionnaire-run-page-DyD9Ui-g.js} +1 -1
  56. package/dist/assets/{psyche-questionnaires-page-BEreTNjG.js → psyche-questionnaires-page-BxfKcoi3.js} +1 -1
  57. package/dist/assets/{psyche-report-detail-page-Br9KlJBG.js → psyche-report-detail-page-Ci14mNUK.js} +1 -1
  58. package/dist/assets/{psyche-reports-page-Bk6QpAEF.js → psyche-reports-page-ALhNueiV.js} +1 -1
  59. package/dist/assets/{psyche-schemas-beliefs-page-Db8d2ga7.js → psyche-schemas-beliefs-page-C0P2Vw6-.js} +1 -1
  60. package/dist/assets/{psyche-screen-time-page-NazHUAkT.js → psyche-screen-time-page-BYnaT3cb.js} +1 -1
  61. package/dist/assets/{psyche-self-observation-page-H6FToucM.js → psyche-self-observation-page-eM9vpwIB.js} +1 -1
  62. package/dist/assets/{psyche-values-page-DqM382-6.js → psyche-values-page-BqrGIDok.js} +1 -1
  63. package/dist/assets/{report-chain-fields-nW4zndrM.js → report-chain-fields-CbkT7WOO.js} +1 -1
  64. package/dist/assets/{rewards-page-C-tZVnIK.js → rewards-page-DpAJ8IxE.js} +1 -1
  65. package/dist/assets/{scheduling-rules-editor-DGF-044c.js → scheduling-rules-editor-BUGnZJ0g.js} +1 -1
  66. package/dist/assets/{schema-badge-57AJ3FY-.js → schema-badge-CLAA4p-b.js} +1 -1
  67. package/dist/assets/{select-menu-mfaklv7r.js → select-menu-Cqs5t3ng.js} +1 -1
  68. package/dist/assets/{settings-agents-page-CPJeeYg0.js → settings-agents-page-pmkVrOO8.js} +1 -1
  69. package/dist/assets/{settings-bin-page-D3eX5aNf.js → settings-bin-page-BwtLrweW.js} +1 -1
  70. package/dist/assets/{settings-calendar-page-Bgx8NIsP.js → settings-calendar-page-BBjAMOCf.js} +1 -1
  71. package/dist/assets/{settings-data-page-BuMSUjpp.js → settings-data-page-Bqy5SukM.js} +1 -1
  72. package/dist/assets/{settings-logs-page-CHb2GNUM.js → settings-logs-page-8khtrf4T.js} +1 -1
  73. package/dist/assets/{settings-mobile-page-ClUvXhJg.js → settings-mobile-page-BcyRjEU_.js} +1 -1
  74. package/dist/assets/{settings-models-page-njK6D7zc.js → settings-models-page-DlSnO9WX.js} +1 -1
  75. package/dist/assets/{settings-page-Dm--cx6B.js → settings-page-CyBQ2qcB.js} +1 -1
  76. package/dist/assets/{settings-rewards-page-3aShLM3A.js → settings-rewards-page-BBX2WtVM.js} +1 -1
  77. package/dist/assets/{settings-section-nav-BWox23Qv.js → settings-section-nav-Co0AaDG-.js} +1 -1
  78. package/dist/assets/{settings-users-page-D-hEPpgQ.js → settings-users-page-JSnfFFPu.js} +1 -1
  79. package/dist/assets/{settings-wiki-page-CC-rOtDm.js → settings-wiki-page--nT23Fdy.js} +1 -1
  80. package/dist/assets/{sleep-page-Cm_Ei2w1.js → sleep-page-CGMi3MtV.js} +1 -1
  81. package/dist/assets/{sports-page-CqSI-j-H.js → sports-page-Kv5bBoLr.js} +1 -1
  82. package/dist/assets/{strategies-page-BuJ4zLLv.js → strategies-page-Br7RdUJO.js} +1 -1
  83. package/dist/assets/{strategy-detail-page-CLmy0jbW.js → strategy-detail-page-CBWXjUhC.js} +1 -1
  84. package/dist/assets/{strategy-dialog-DnJix1ys.js → strategy-dialog-BTwkaSxI.js} +1 -1
  85. package/dist/assets/{surface-DRNu5Fpz.js → surface-CyWI7e1R.js} +1 -1
  86. package/dist/assets/{task-detail-page-DTnNjW33.js → task-detail-page-Qis9354n.js} +1 -1
  87. package/dist/assets/{timebox-planning-dialog-DckIr1K4.js → timebox-planning-dialog-DB8snOBD.js} +1 -1
  88. package/dist/assets/{today-page-Cgk4HBPK.js → today-page-D9A5PU0S.js} +1 -1
  89. package/dist/assets/{training-load-page-C-7iINaB.js → training-load-page-Bpd4DQAh.js} +1 -1
  90. package/dist/assets/vitals-page-CVYC-4RG.js +1 -0
  91. package/dist/assets/{weekly-review-page-DFmuzzig.js → weekly-review-page-BP7N3fNB.js} +1 -1
  92. package/dist/assets/{weight-loss-page-CWtgeuti.js → weight-loss-page-_fX3N1UK.js} +1 -1
  93. package/dist/assets/{wiki-article-markdown-BkQg8Hne.js → wiki-article-markdown-Bi02AsVt.js} +1 -1
  94. package/dist/assets/{wiki-editor-page-BYKcdX5I.js → wiki-editor-page-OZf9l4Tg.js} +1 -1
  95. package/dist/assets/{wiki-ingest-history-page-D_p4myw1.js → wiki-ingest-history-page-CzeNSL7N.js} +1 -1
  96. package/dist/assets/{wiki-ingest-modal-C-CidueO.js → wiki-ingest-modal-Ig_xnyc6.js} +1 -1
  97. package/dist/assets/wiki-page-B4xuNgY4.js +1 -0
  98. package/dist/assets/{workbench-flow-page-Q3r2IJty.js → workbench-flow-page-BhRJCALC.js} +1 -1
  99. package/dist/assets/{workbench-page-BFfWMGm6.js → workbench-page-DxVs2AOY.js} +1 -1
  100. package/dist/assets/{workout-detail-page-DeDyz1Kk.js → workout-detail-page-D4wfkE98.js} +1 -1
  101. package/dist/index.html +2 -2
  102. package/dist/server/server/migrations/069_psyche_devrage_cumulative_rage.sql +5 -0
  103. package/dist/server/server/src/app.js +3 -2
  104. package/dist/server/server/src/openapi.js +48 -8
  105. package/dist/server/server/src/psyche-types.js +18 -4
  106. package/dist/server/server/src/services/devrage-scanner.js +115 -10
  107. package/dist/server/server/src/services/devrage.js +61 -11
  108. package/openclaw.plugin.json +1 -1
  109. package/package.json +1 -1
  110. package/server/migrations/069_psyche_devrage_cumulative_rage.sql +5 -0
  111. package/skills/forge-openclaw/SKILL.md +7 -0
  112. package/skills/forge-openclaw/entity_conversation_playbooks.md +23 -0
  113. package/skills/forge-openclaw/psyche_entity_playbooks.md +32 -0
  114. package/dist/assets/daily-metrics-dashboard-BNGQlJkQ.js +0 -1
  115. package/dist/assets/index-BAXYM89v.css +0 -1
  116. package/dist/assets/psyche-metrics-page-D8JQEoOl.js +0 -1
  117. package/dist/assets/psyche-page-Dkh7R2Dc.js +0 -1
  118. package/dist/assets/vitals-page-CqE4bYMf.js +0 -1
  119. package/dist/assets/wiki-page-DYpg9ZEO.js +0 -1
@@ -1 +1 @@
1
- import{b0 as ht,bD as vt,cF as ft,cG as bt,bf as jt,aG as yt,j as e,aK as Nt,b3 as de,c2 as kt,r as x,aC as ve,c7 as Ct,b4 as It}from"./vendor-Dnkkx2co.js";import{j as St,i as Ke,k as N}from"./state-vCcAT5Hq.js";import{bk as Z,Z as U,c as I,I as v,L as Je,a as et,B as u,C as j,U as tt,H as wt,u as Pt,s as Ft,c1 as Ye,c2 as Lt,c3 as Tt,c4 as Mt,c5 as Dt,c6 as At,c7 as Et,c8 as zt,c9 as _t,ca as Gt,cb as Ot,cc as $t,cd as Bt,ce as qt,cf as Qt,cg as Rt,E as Ut,ch as Wt,T as E,ci as Xe}from"./index-By3tQxiE.js";import{P as Ht}from"./page-hero-5RTqAI88.js";import{R as Kt,P as Yt,O as Xt,C as Zt,T as Vt,D as Jt,a as es}from"./ui-C1iwpj2-.js";import"./motion-Lt5B1XuE.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";const st=[{id:"overview",label:"Overview",icon:ht},{id:"map",label:"Map",icon:vt},{id:"table",label:"Table",icon:ft},{id:"history",label:"History",icon:bt},{id:"contexts",label:"Contexts",icon:jt},{id:"concepts",label:"Concepts",icon:yt}],ts=new Set(["projects","tasks","strategies","habits"]),oe=[{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"}],fe={novelty:"Novelty",simplicity:"Simplicity",rigor:"Rigor",aesthetics:"Aesthetics",depth:"Depth",structure:"Structure",familiarity:"Familiarity",surprise:"Surprise"},ne={novelty:0,simplicity:0,rigor:0,aesthetics:0,depth:0,structure:0,familiarity:0,surprise:0},Ze={liked:"bg-[var(--ui-success-soft)] text-[var(--success)]",disliked:"bg-[var(--ui-danger-soft)] text-[var(--danger)]",uncertain:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",vetoed:"bg-[var(--ui-danger-soft)] text-[var(--danger)]",bookmarked:"bg-[var(--ui-info-soft)] text-[var(--info)]",favorite:"bg-[var(--ui-warning-soft)] text-[var(--warning)]",must_have:"bg-[var(--ui-accent-soft)] text-[var(--primary)]",neutral:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]"},ss=[{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 le(i){return i.trim().toLowerCase()}function R(i){return`${Math.round(i*100)}%`}function as(i){return[...i.goals.map(a=>({entityType:"goal",entityId:a.id,domain:"projects",label:a.title,description:a.description,user:a.user,href:`/goals/${a.id}`,searchText:Z([a.title,a.description,a.status,a.horizon],a)})),...i.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:Z([a.title,a.description,a.status,a.goalTitle],a)})),...i.tasks.map(a=>({entityType:"task",entityId:a.id,domain:"tasks",label:a.title,description:a.description,user:a.user,href:`/tasks/${a.id}`,searchText:Z([a.title,a.description,a.status,a.priority,a.owner],a)})),...i.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:Z([a.title,a.overview,a.endStateDescription,a.status],a)})),...i.habits.map(a=>({entityType:"habit",entityId:a.id,domain:"habits",label:a.title,description:a.description,user:a.user,href:null,searchText:Z([a.title,a.description,a.status,a.frequency],a)}))]}function is(i,a){return!i||!a?null:i==="goal"?`/goals/${a}`:i==="project"?`/projects/${a}`:i==="task"?`/tasks/${a}`:i==="strategy"?`/strategies/${a}`:null}function ce(i){return i.manualStatus??i.status}function rs(i){return i&&st.some(a=>a.id===i)?i:"overview"}function ns(i){return i.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."}:i.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 ls({summary:i}){const a=Math.max(-1,Math.min(1,i.leaning)),o=(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-[var(--ui-ink-soft)]",children:[e.jsx("span",{children:fe[i.dimensionId]}),e.jsxs("span",{children:[i.movement>.08?"Rising":i.movement<-.08?"Falling":"Stable"," ","· ",R(i.confidence)]})]}),e.jsxs("div",{className:"relative h-2 rounded-full bg-[var(--ui-surface-2)]",children:[e.jsx("div",{className:"absolute inset-y-0 left-1/2 w-px bg-[var(--ui-border-strong)]"}),e.jsx("div",{className:U("absolute top-1/2 size-3 -translate-x-1/2 -translate-y-1/2 rounded-full border border-[var(--ui-border-strong)]",a>=0?"bg-[var(--success)]":"bg-[var(--danger)]"),style:{left:`${o}%`}})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 text-[11px] uppercase tracking-[0.12em] text-[var(--ui-ink-faint)]",children:[e.jsxs("span",{children:[a>=0?"Leans toward":"Leans away from"," ",fe[i.dimensionId].toLowerCase()]}),e.jsxs("span",{children:["Context ",R(i.contextSensitivity)]})]})]})}function Ve({title:i,description:a,sideLabel:o,onClick:g}){return e.jsxs("button",{type:"button",className:"grid min-h-[220px] gap-4 rounded-[28px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] p-5 text-left transition hover:border-[color-mix(in_srgb,var(--primary)_40%,transparent)] hover:bg-[var(--ui-surface-hover)]",onClick:g,children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:o}),e.jsx("div",{className:"font-display text-3xl text-[var(--ui-ink-strong)]",children:i}),e.jsx("div",{className:"max-w-[36ch] text-sm leading-6 text-[var(--ui-ink-soft)]",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 cs({state:i,onOpenChange:a,error:o,loading:g,workspaceLoading:k,activeWorkspace:h,conceptSearchQuery:w,onConceptSearchQueryChange:p,filteredCatalogs:S,onSelectDomain:V,onStartCatalogGame:G,onJudge:J,onSignal:O}){return e.jsx(Kt,{open:i.open,onOpenChange:a,children:e.jsxs(Yt,{children:[e.jsx(Xt,{className:"fixed inset-0 z-40 bg-[var(--ui-overlay-backdrop)] backdrop-blur-xl"}),e.jsxs(Zt,{className:"fixed inset-x-4 bottom-4 top-4 z-50 overflow-y-auto rounded-[32px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-modal)] shadow-[var(--ui-shadow-floating)] 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(Vt,{className:"sr-only",children:"Preference game"}),e.jsx(Jt,{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-[var(--ui-border-subtle)] bg-[color-mix(in_srgb,var(--surface-glass)_94%,transparent)] px-5 py-4 backdrop-blur-xl",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Preference game"}),e.jsx("div",{className:"mt-1 font-display text-2xl text-[var(--ui-ink-strong)]",children:i.phase==="domain"?"Choose a domain":i.phase==="catalog"?"Choose a concept list":"Pick the better fit"})]}),e.jsx(es,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":"Close preference game",className:"rounded-full bg-[var(--ui-surface-2)] p-2 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",children:e.jsx(Nt,{className:"size-4"})})})]}),e.jsxs("div",{className:"grid gap-5 px-5 py-5",children:[o?e.jsx("div",{className:"rounded-[18px] border border-[color-mix(in_srgb,var(--danger)_28%,transparent)] bg-[var(--ui-danger-soft)] px-4 py-3 text-sm text-[var(--danger)]",children:o}):null,i.phase==="domain"?e.jsx(ds,{onSelectDomain:V}):null,i.phase==="catalog"?e.jsx(os,{domain:i.domain,query:w,onQueryChange:p,catalogs:S,onStartCatalogGame:G}):null,i.phase==="play"?e.jsx(us,{domain:i.domain,loading:g||k,activeWorkspace:h,onJudge:J,onSignal:O}):null]})]})]})})}function ds({onSelectDomain:i}){return e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:oe.map(a=>e.jsxs("button",{type:"button",className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-5 py-5 text-left transition hover:border-[color-mix(in_srgb,var(--primary)_30%,transparent)] hover:bg-[var(--ui-accent-soft)]",onClick:()=>i(a.value),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:a.label}),e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:a.mode==="forge"?"Forge":"Concept"})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:a.description})]},a.value))})}function os({domain:i,query:a,onQueryChange:o,catalogs:g,onStartCatalogGame:k}){return e.jsxs("div",{className:"grid gap-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",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(de,{className:"size-4 text-[var(--ui-ink-faint)]"}),e.jsx(v,{value:a,onChange:h=>o(h.target.value),placeholder:"Search concept lists"})]}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:g.length>0?g.map(h=>e.jsxs("button",{type:"button",className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-5 py-5 text-left transition hover:border-[color-mix(in_srgb,var(--primary)_30%,transparent)] hover:bg-[var(--ui-accent-soft)]",onClick:()=>k(i,h.id),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:h.title}),e.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[h.items.length," items"]})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:h.description||"No description yet."})]},h.id)):e.jsx("div",{className:"rounded-[24px] bg-[var(--ui-surface-1)] px-5 py-6 text-sm text-[var(--ui-ink-soft)]",children:"No concept list matches that search yet."})})]})}function us({domain:i,loading:a,activeWorkspace:o,onJudge:g,onSignal:k}){var w;const h=(o==null?void 0:o.compare.nextPair)??null;return a?e.jsx(Je,{eyebrow:"Preference game",title:"Preparing the next round",description:"Forge is lining up comparison candidates."}):h?e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:((w=oe.find(p=>p.value===i))==null?void 0:w.label)??i}),e.jsx("span",{children:o==null?void 0:o.selectedContext.name}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[(o==null?void 0:o.compare.pendingCount)??0," queued comparisons"]})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(Ve,{title:h.left.label,description:h.left.description,sideLabel:"Left",onClick:()=>g("left",1)}),e.jsx(Ve,{title:h.right.label,description:h.right.description,sideLabel:"Right",onClick:()=>g("right",1)})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{onClick:()=>g("left",1),children:"Left"}),e.jsx(u,{onClick:()=>g("right",1),children:"Right"}),e.jsx(u,{variant:"secondary",onClick:()=>g("left",1.75),children:"Strong left"}),e.jsx(u,{variant:"secondary",onClick:()=>g("right",1.75),children:"Strong right"}),e.jsx(u,{variant:"secondary",onClick:()=>g("tie",1),children:"Tie"}),e.jsx(u,{variant:"secondary",onClick:()=>g("skip",1),children:"Skip"})]}),e.jsx("div",{className:"grid gap-4 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4 lg:grid-cols-2",children:[h.left,h.right].map(p=>e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:p.label}),e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Quick signals"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ss.map(S=>e.jsx(u,{variant:"secondary",size:"sm",onClick:()=>k(p.id,S.signalType),children:S.label},`${p.id}-${S.signalType}`))})]},p.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."})}function ms({users:i,user:a,selectedUserId:o,selectedDomain:g,workspace:k,onPatchSearch:h}){var w;return e.jsxs(j,{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-[var(--ui-ink-faint)]",children:"Active user"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("select",{value:o,onChange:p=>h({userId:p.target.value,contextId:null,focusItem:null}),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none transition focus:border-[var(--primary)]",children:i.map(p=>e.jsxs("option",{value:p.id,children:[p.displayName," · ",p.kind]},p.id))}),e.jsx(tt,{user:a}),e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:wt(a)})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Domain"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:oe.map(p=>e.jsx("button",{type:"button",className:U("rounded-full border px-3 py-2 text-sm transition",p.value===g?"border-[var(--primary)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>h({domain:p.value,contextId:null,focusItem:null}),children:p.label},p.value))}),e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:(w=oe.find(p=>p.value===g))==null?void 0:w.description})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:k.selectedContext.name}),e.jsx("span",{children:k.selectedContext.shareMode}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[k.compare.pendingCount," queued comparisons"]}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[k.libraries.totalCatalogItems," concept items ready"]})]})]})}function xs({selectedTab:i,onSelectTab:a}){return e.jsx("div",{className:"flex flex-wrap gap-2",children:st.map(o=>e.jsxs("button",{type:"button",className:U("inline-flex items-center gap-2 rounded-full border px-3 py-2 text-sm transition",o.id===i?"border-[var(--primary)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>a(o.id),children:[e.jsx(o.icon,{className:"size-4"}),o.label]},o.id))})}function ks(){var qe,Qe,Re;const i=Pt(),a=St(),[o,g]=kt(),[k,h]=x.useState(""),[w,p]=x.useState(""),[S,V]=x.useState(""),[G,J]=x.useState(""),[O,be]=x.useState(""),[z,M]=x.useState({open:!1,phase:"domain",domain:o.get("domain")??"projects"}),[at,D]=x.useState(null),[it,ue]=x.useState(!1),[je,$]=x.useState(null),[f,F]=x.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"}}),[_,ee]=x.useState({label:"",description:"",tags:""}),[L,W]=x.useState({name:"",description:"",shareMode:"blended",decayDays:"90"}),[H,me]=x.useState({title:"",description:""}),[rt,te]=x.useState({}),[ye,xe]=x.useState(null),[se,pe]=x.useState({title:"",description:""}),[nt,ge]=x.useState(null),[B,ae]=x.useState({label:"",description:"",tags:""}),m=o.get("userId")??Ft(i.selectedUserIds)??((qe=i.snapshot.users[0])==null?void 0:qe.id)??null,C=o.get("domain")??"projects",T=rs(o.get("tab")),K=o.get("contextId"),ie=o.get("focusItem"),lt=x.useMemo(()=>i.snapshot.users.find(t=>t.id===m)??null,[m,i.snapshot.users]),re=x.useMemo(()=>as(i.snapshot),[i.snapshot]),Y=Ke({queryKey:["forge-preferences",m,C,K],queryFn:async()=>(await Xe({userId:m??void 0,domain:C,contextId:K??void 0})).workspace,enabled:!!m}),Ne=Ke({queryKey:["forge-preferences-game",m,z.domain,K],queryFn:async()=>(await Xe({userId:m??void 0,domain:z.domain,contextId:K??void 0})).workspace,enabled:!!m&&z.open}),r=Y.data??null,P=z.domain===C?r:Ne.data??null;x.useEffect(()=>{var s;if(!r)return;const t=ie&&r.scores.some(c=>c.itemId===ie)?ie:((s=r.scores[0])==null?void 0:s.itemId)??null;$(c=>c&&r.scores.some(n=>n.itemId===c)?c:t)},[ie,r]);const he=x.useMemo(()=>{if(!r)return[];const t=le(k);return t?r.scores.filter(s=>{var c,n,l;return[((c=s.item)==null?void 0:c.label)??"",((n=s.item)==null?void 0:n.description)??"",((l=s.item)==null?void 0:l.tags.join(" "))??"",s.status,s.manualStatus??"",s.dominantDimensions.join(" "),s.explanation.join(" ")].join(" ").toLowerCase().includes(t)}):r.scores},[k,r]),d=he.find(t=>t.itemId===je)??(r==null?void 0:r.scores.find(t=>t.itemId===je))??he[0]??(r==null?void 0:r.scores[0])??null;x.useEffect(()=>{var t,s,c,n,l,y,X,Q,Ue,We,He;d&&F({label:((t=d.item)==null?void 0:t.label)??"",description:((s=d.item)==null?void 0:s.description)??"",tags:((c=d.item)==null?void 0:c.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(((l=d.item)==null?void 0:l.featureWeights.simplicity)??0),rigor:String(((y=d.item)==null?void 0:y.featureWeights.rigor)??0),aesthetics:String(((X=d.item)==null?void 0:X.featureWeights.aesthetics)??0),depth:String(((Q=d.item)==null?void 0:Q.featureWeights.depth)??0),structure:String(((Ue=d.item)==null?void 0:Ue.featureWeights.structure)??0),familiarity:String(((We=d.item)==null?void 0:We.featureWeights.familiarity)??0),surprise:String(((He=d.item)==null?void 0:He.featureWeights.surprise)??0)}})},[d]);const ke=x.useMemo(()=>{const t=le(w);return re.filter(s=>s.domain===C).filter(s=>t?s.searchText.includes(t):!0).slice(0,12)},[re,w,C]),Ce=x.useMemo(()=>{const t=T==="concepts"?r:P??r,s=(t==null?void 0:t.catalogs)??[],c=le(S);return c?s.filter(n=>[n.title,n.description,n.source,...n.items.flatMap(l=>[l.label,l.description,l.tags.join(" ")])].join(" ").toLowerCase().includes(c)):s},[P,S,T,r]),b=async()=>{await a.invalidateQueries({queryKey:["forge-preferences"]}),await a.invalidateQueries({queryKey:["forge-preferences-game"]})},Ie=N({mutationFn:Ye,onSuccess:b}),Se=N({mutationFn:Lt,onSuccess:async({item:t})=>{await b(),ee({label:"",description:"",tags:""}),$(t.id)}}),we=N({mutationFn:Tt,onSuccess:async()=>{await b(),me({title:"",description:""}),g(t=>{const s=new URLSearchParams(t);return s.set("tab","concepts"),s})}}),Pe=N({mutationFn:({catalogId:t,patch:s})=>Mt(t,s),onSuccess:async()=>{await b(),xe(null)}}),Fe=N({mutationFn:Dt,onSuccess:b}),Le=N({mutationFn:At,onSuccess:async()=>{await b()}}),Te=N({mutationFn:({catalogItemId:t,patch:s})=>Et(t,s),onSuccess:async()=>{await b(),ge(null)}}),Me=N({mutationFn:zt,onSuccess:b}),ct=N({mutationFn:_t,onSuccess:async()=>{await b(),M(t=>({...t,phase:"play"}))}}),dt=N({mutationFn:Gt,onSuccess:b}),ot=N({mutationFn:Ot,onSuccess:b}),De=N({mutationFn:async()=>{!(d!=null&&d.item)||!m||!r||(await $t(d.item.id,{label:f.label,description:f.description,tags:f.tags.split(",").map(t=>t.trim()).filter(Boolean),featureWeights:Object.fromEntries(Object.keys(ne).map(t=>[t,Number(f.featureWeights[t]||0)]))}),await Bt(d.item.id,{userId:m,domain:C,contextId:r.selectedContext.id,manualStatus:f.manualStatus||null,manualScore:f.manualScore.trim().length>0?Number(f.manualScore):null,confidenceLock:f.confidenceLock.trim().length>0?Number(f.confidenceLock):null,bookmarked:f.bookmarked,compareLater:f.compareLater,frozen:f.frozen}))},onSuccess:b}),Ae=N({mutationFn:qt,onSuccess:async({context:t})=>{await b(),W({name:"",description:"",shareMode:"blended",decayDays:"90"}),g(s=>{const c=new URLSearchParams(s);return c.set("contextId",t.id),c.set("tab","contexts"),c})}}),Ee=N({mutationFn:Qt,onSuccess:async()=>{await b(),J(""),be("")}}),q=N({mutationFn:({contextId:t,patch:s})=>Rt(t,s),onSuccess:b}),A=t=>{g(s=>{const c=new URLSearchParams(s);for(const[n,l]of Object.entries(t))l?c.set(n,l):c.delete(n);return c})},ze=(t=C)=>{D(null),M({open:!0,phase:"domain",domain:t})},ut=async t=>{if(!m)return;D(null),ue(!0);const s=re.filter(l=>{var y;return l.domain===t&&((y=l.user)==null?void 0:y.id)===m}),c=re.filter(l=>l.domain===t),n=(s.length>0?s:c).slice(0,12);if(n.length<2){D("Forge needs at least two matching records in this domain before it can start the game."),ue(!1),M(l=>({...l,phase:"domain"}));return}try{A({domain:t,tab:"overview",contextId:null,focusItem:null}),await Promise.all(n.map(l=>Ye({userId:m,domain:t,entityType:l.entityType,entityId:l.entityId,label:l.label,description:l.description,tags:[]}))),await b(),M({open:!0,phase:"play",domain:t})}catch(l){D(l instanceof Error?l.message:"Forge could not start the game."),M(y=>({...y,phase:"domain"}))}finally{ue(!1)}},_e=async(t,s)=>{if(m){D(null),A({domain:t,tab:"overview",contextId:null,focusItem:null});try{await ct.mutateAsync({userId:m,domain:t,contextId:K??void 0,catalogId:s}),M({open:!0,phase:"play",domain:t})}catch(c){D(c instanceof Error?c.message:"Forge could not start the game.")}}},mt=async t=>{if(ts.has(t)){await ut(t);return}D(null),M({open:!0,phase:"catalog",domain:t})},xt=async(t,s=1)=>{if(!m||!(P!=null&&P.compare.nextPair))return;const c=P.compare.nextPair;await dt.mutateAsync({userId:m,domain:z.domain,contextId:P.selectedContext.id,leftItemId:c.left.id,rightItemId:c.right.id,outcome:t,strength:s})},pt=async(t,s)=>{!m||!P||await ot.mutateAsync({userId:m,domain:z.domain,contextId:P.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(Y.isLoading&&!r)return e.jsx(Je,{eyebrow:"Preferences",title:"Loading preference model",description:"Reconstructing current scores, uncertainty, and concept libraries."});if(Y.isError)return e.jsx(Ut,{eyebrow:"Preferences",error:Y.error,onRetry:()=>void Y.refetch()});if(!r)return null;const gt=[...r.dimensions].sort((t,s)=>s.confidence-t.confidence).slice(0,6),Ge=r.scores.filter(t=>ce(t)==="liked"||ce(t)==="favorite").slice(0,4),Oe=r.scores.filter(t=>t.uncertainty>=.5).slice(0,4),$e=ns(r),Be=is(((Qe=d==null?void 0:d.item)==null?void 0:Qe.sourceEntityType)??null,((Re=d==null?void 0:d.item)==null?void 0:Re.sourceEntityId)??null);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsx(Ht,{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:`${r.summary.totalItems} items · ${R(r.summary.averageConfidence)} confidence`,actions:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{className:"min-w-[10rem]",onClick:()=>ze(),children:"Start the game"}),e.jsx(u,{variant:"secondary",onClick:()=>void b(),children:"Refresh model"})]})}),e.jsx(Wt,{}),e.jsx(ms,{users:i.snapshot.users,user:lt,selectedUserId:m,selectedDomain:C,workspace:r,onPatchSearch:A}),e.jsx(xs,{selectedTab:T,onSelectTab:t=>A({tab:t})}),T==="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(j,{className:"grid gap-5",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"What Forge knows"}),e.jsx("div",{className:"font-display text-3xl text-[var(--ui-ink-strong)]",children:$e.title}),e.jsx("div",{className:"max-w-[70ch] text-sm leading-6 text-[var(--ui-ink-soft)]",children:$e.description})]}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[{label:"Known items",value:r.summary.totalItems,detail:"Items inside this domain"},{label:"Confidence",value:R(r.summary.averageConfidence),detail:"Average certainty"},{label:"Unknowns",value:r.summary.uncertainCount,detail:"Need more rounds"},{label:"Libraries",value:r.libraries.totalCatalogItems,detail:"Seeded concepts ready"}].map(t=>e.jsxs("div",{className:"rounded-[22px] bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:t.label}),e.jsx("div",{className:"mt-2 font-display text-3xl text-[var(--ui-ink-strong)]",children:t.value}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:t.detail})]},t.label))}),e.jsx("div",{className:"grid gap-4 lg:grid-cols-2",children:gt.map(t=>e.jsx(ls,{summary:t},t.dimensionId))})]}),e.jsxs(j,{className:"grid gap-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Next move"}),e.jsx("div",{className:"font-display text-2xl text-[var(--ui-ink-strong)]",children:"Start the game"}),e.jsx("div",{className:"text-sm leading-6 text-[var(--ui-ink-soft)]",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(u,{className:"w-full",onClick:()=>ze(),children:"Start the game"}),e.jsxs("div",{className:"grid gap-3 rounded-[22px] bg-[var(--ui-surface-2)] px-4 py-4 text-sm text-[var(--ui-ink-soft)]",children:[e.jsxs("div",{children:["Current queue: ",r.compare.pendingCount," comparison",r.compare.pendingCount===1?"":"s"]}),e.jsxs("div",{children:["Active context: ",r.selectedContext.name]}),e.jsxs("div",{children:["Library coverage: ",r.libraries.seededCatalogCount," ","seeded lists and ",r.libraries.customCatalogCount," ","custom lists"]})]})]})]}),e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.3fr)_360px]",children:[e.jsxs(j,{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-[var(--ui-ink-faint)]",children:"Preference map"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Green drifts positive, red drifts negative, and low opacity still means uncertainty."})]}),e.jsx(ve,{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-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)]",children:[e.jsx("div",{className:"absolute inset-x-0 top-1/2 h-px bg-[var(--ui-border-subtle)]"}),e.jsx("div",{className:"absolute inset-y-0 left-1/2 w-px bg-[var(--ui-border-subtle)]"}),r.map.map(t=>e.jsx("button",{type:"button",className:U("absolute -translate-x-1/2 -translate-y-1/2 rounded-full border px-2 py-1 text-[11px] shadow-[var(--ui-shadow-soft)] transition hover:scale-[1.04]",t.itemId===(d==null?void 0:d.itemId)?"border-[var(--ui-border-strong)] bg-[var(--ui-surface-active)] text-[var(--ui-ink-strong)]":t.score>=0?"border-[color-mix(in_srgb,var(--success)_34%,transparent)] bg-[var(--ui-success-soft)] text-[var(--ui-ink-strong)]":"border-[color-mix(in_srgb,var(--danger)_34%,transparent)] bg-[var(--ui-danger-soft)] text-[var(--ui-ink-strong)]"),style:{left:`${50+t.x*30}%`,top:`${50-t.y*30}%`,opacity:.55+t.confidence*.45},onClick:()=>$(t.itemId),children:t.label},t.itemId))]})]}),e.jsxs(j,{className:"grid gap-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Best read so far"}),e.jsx("div",{className:"grid gap-2",children:Ge.length>0?Ge.map(t=>{var s;return e.jsxs("button",{type:"button",className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-3 text-left transition hover:bg-[var(--ui-surface-hover)]",onClick:()=>{$(t.itemId),A({focusItem:t.itemId})},children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:((s=t.item)==null?void 0:s.label)??t.itemId}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:t.explanation[0]||"Forge has positive evidence here."})]},t.itemId)}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-3 text-sm text-[var(--ui-ink-soft)]",children:"No clear positives yet. A few comparison rounds will change that."})}),e.jsxs("div",{className:"border-t border-[var(--ui-border-subtle)] pt-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Biggest unknowns"}),e.jsx("div",{className:"mt-3 grid gap-2",children:Oe.length>0?Oe.map(t=>{var s;return e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-3 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:((s=t.item)==null?void 0:s.label)??t.itemId}),e.jsxs("div",{className:"mt-1",children:["Uncertainty ",R(t.uncertainty)]})]},t.itemId)}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-3 text-sm text-[var(--ui-ink-soft)]",children:"The current unknown list is short."})})]})]})]}),e.jsxs(j,{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-[var(--ui-ink-faint)]",children:"Bring in Forge records"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Search goals, projects, tasks, strategies, or habits across human and bot users, then send them straight into this model."})]}),e.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[ke.length," visible"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"size-4 text-[var(--ui-ink-muted)]"}),e.jsx(v,{value:w,onChange:t=>p(t.target.value),placeholder:"Search across owners, handles, user kind, title, and description"})]}),e.jsx("div",{className:"grid gap-2",children:ke.map(t=>e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-[18px] bg-[var(--ui-surface-2)] 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-[var(--ui-ink-strong)]",children:t.label}),e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:t.entityType}),t.user?e.jsx(tt,{user:t.user,compact:!0}):null]}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:t.description||"No description yet."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.href?e.jsx(ve,{to:t.href,children:e.jsx(u,{variant:"ghost",size:"sm",children:"Open"})}):null,e.jsx(u,{variant:"secondary",size:"sm",pending:Ie.isPending,pendingLabel:"Adding",onClick:()=>void Ie.mutateAsync({userId:m,domain:C,entityType:t.entityType,entityId:t.entityId,label:t.label,description:t.description,tags:[]}),children:"Add to model"})]})]},`${t.entityType}-${t.entityId}`))})]})]}):null,T==="map"?e.jsxs(j,{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-[var(--ui-ink-faint)]",children:"Full map"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Click a point to inspect why Forge believes it belongs there."})]}),e.jsxs("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:[r.map.length," plotted items"]})]}),e.jsxs("div",{className:"relative min-h-[520px] overflow-hidden rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)]",children:[e.jsx("div",{className:"absolute inset-x-0 top-1/2 h-px bg-[var(--ui-border-subtle)]"}),e.jsx("div",{className:"absolute inset-y-0 left-1/2 w-px bg-[var(--ui-border-subtle)]"}),r.map.map(t=>e.jsx("button",{type:"button",className:U("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-[var(--ui-border-strong)] bg-[var(--ui-surface-active)] text-[var(--ui-ink-strong)]":t.score>=0?"border-[color-mix(in_srgb,var(--success)_34%,transparent)] bg-[var(--ui-success-soft)] text-[var(--ui-ink-strong)]":"border-[color-mix(in_srgb,var(--danger)_34%,transparent)] bg-[var(--ui-danger-soft)] text-[var(--ui-ink-strong)]"),style:{left:`${50+t.x*34}%`,top:`${50-t.y*34}%`,opacity:.45+t.confidence*.55},onClick:()=>{$(t.itemId),A({focusItem:t.itemId})},children:t.label},t.itemId))]})]}):null,T==="table"?e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.2fr)_380px]",children:[e.jsxs(j,{className:"grid gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"size-4 text-[var(--ui-ink-muted)]"}),e.jsx(v,{value:k,onChange:t=>h(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-[var(--ui-ink-muted)]",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:he.map(t=>{var s,c;return e.jsxs("tr",{className:U("cursor-pointer border-t border-[var(--ui-border-subtle)] transition hover:bg-[var(--ui-surface-2)]",t.itemId===(d==null?void 0:d.itemId)?"bg-[var(--ui-surface-2)]":""),onClick:()=>{$(t.itemId),A({focusItem:t.itemId})},children:[e.jsxs("td",{className:"px-3 py-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:((s=t.item)==null?void 0:s.label)??t.itemId}),e.jsx("div",{className:"text-xs text-[var(--ui-ink-muted)]",children:(((c=t.item)==null?void 0:c.tags)??[]).join(" · ")})]}),e.jsx("td",{className:"px-3 py-3 text-[var(--ui-ink-medium)]",children:t.latentScore.toFixed(2)}),e.jsx("td",{className:"px-3 py-3 text-[var(--ui-ink-medium)]",children:R(t.confidence)}),e.jsx("td",{className:"px-3 py-3",children:e.jsx(I,{className:Ze[ce(t)],children:ce(t)})}),e.jsx("td",{className:"px-3 py-3 text-[var(--ui-ink-medium)]",children:t.evidenceCount})]},t.itemId)})})]})})]}),e.jsxs(j,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Item editor"}),d!=null&&d.item?e.jsxs(e.Fragment,{children:[e.jsx(v,{value:f.label,onChange:t=>F(s=>({...s,label:t.target.value})),placeholder:"Item label"}),e.jsx(E,{value:f.description,onChange:t=>F(s=>({...s,description:t.target.value})),className:"min-h-24",placeholder:"Item description"}),e.jsx(v,{value:f.tags,onChange:t=>F(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:f.manualStatus,onChange:t=>F(s=>({...s,manualStatus:t.target.value})),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none",children:[e.jsx("option",{value:"",children:"Inferred status"}),Object.keys(Ze).map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsx(v,{value:f.manualScore,onChange:t=>F(s=>({...s,manualScore:t.target.value})),placeholder:"Manual score"}),e.jsx(v,{value:f.confidenceLock,onChange:t=>F(s=>({...s,confidenceLock:t.target.value})),placeholder:"Confidence lock 0-1"})]}),e.jsx("div",{className:"grid gap-2",children:Object.keys(ne).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-[var(--ui-ink-soft)]",children:fe[t]}),e.jsx(v,{value:f.featureWeights[t],onChange:s=>F(c=>({...c,featureWeights:{...c.featureWeights,[t]:s.target.value}}))})]},t))}),e.jsx("div",{className:"grid gap-2 text-sm text-[var(--ui-ink-soft)]",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:f[t],onChange:c=>F(n=>({...n,[t]:c.target.checked}))}),e.jsx("span",{children:s})]},t))}),e.jsx(u,{pending:De.isPending,pendingLabel:"Saving item",onClick:()=>void De.mutateAsync(),children:"Save item model"}),Be?e.jsx(ve,{className:"text-sm text-[var(--primary)]",to:Be,children:"Open linked entity"}):null]}):e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Select a row to inspect or edit it."}),e.jsxs("div",{className:"mt-3 border-t border-[var(--ui-border-subtle)] pt-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Add custom item"}),e.jsxs("div",{className:"mt-3 grid gap-3",children:[e.jsx(v,{value:_.label,onChange:t=>ee(s=>({...s,label:t.target.value})),placeholder:"Custom item label"}),e.jsx(E,{value:_.description,onChange:t=>ee(s=>({...s,description:t.target.value})),className:"min-h-24",placeholder:"What is this preference item?"}),e.jsx(v,{value:_.tags,onChange:t=>ee(s=>({...s,tags:t.target.value})),placeholder:"comma, separated, tags"}),e.jsx(u,{disabled:!_.label.trim(),pending:Se.isPending,pendingLabel:"Creating item",onClick:()=>void Se.mutateAsync({userId:m,domain:C,label:_.label,description:_.description,tags:_.tags.split(",").map(t=>t.trim()).filter(Boolean),featureWeights:ne,queueForCompare:!0}),children:"Create custom item"})]})]})]})]}):null,T==="history"?e.jsxs("div",{className:"grid gap-5 xl:grid-cols-3",children:[e.jsxs(j,{className:"grid gap-3 xl:col-span-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Recent pairwise judgments"}),e.jsx("div",{className:"grid gap-2",children:r.history.judgments.slice(0,12).map(t=>{var n,l,y,X;const s=((l=(n=r.scores.find(Q=>Q.itemId===t.leftItemId))==null?void 0:n.item)==null?void 0:l.label)??t.leftItemId,c=((X=(y=r.scores.find(Q=>Q.itemId===t.rightItemId))==null?void 0:y.item)==null?void 0:X.label)??t.rightItemId;return e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-3 text-sm text-[var(--ui-ink-soft)]",children:[e.jsxs("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:[s," vs ",c]}),e.jsxs("div",{className:"mt-1",children:["Outcome ",t.outcome," · strength"," ",t.strength," ·"," ",new Date(t.createdAt).toLocaleString()]})]},t.id)})})]}),e.jsxs(j,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Signals and snapshots"}),e.jsx("div",{className:"grid gap-2",children:r.history.signals.slice(0,8).map(t=>{var c,n;const s=((n=(c=r.scores.find(l=>l.itemId===t.itemId))==null?void 0:c.item)==null?void 0:n.label)??t.itemId;return e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-2 text-sm text-[var(--ui-ink-soft)]",children:[s," · ",t.signalType," ·"," ",new Date(t.createdAt).toLocaleString()]},t.id)})}),e.jsx("div",{className:"grid gap-2",children:r.history.snapshots.slice(0,5).map(t=>e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-2 text-sm text-[var(--ui-ink-soft)]",children:["Snapshot ",new Date(t.createdAt).toLocaleString()]},t.id))}),e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-3 text-sm text-[var(--ui-ink-soft)]",children:["Stale items: ",r.history.staleItemIds.length," · Flipped items: ",r.history.flippedItemIds.length]})]})]}):null,T==="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:r.contexts.map(t=>e.jsxs(j,{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-[var(--ui-ink-strong)]",children:t.name}),e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:t.description||"No description yet."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.isDefault?e.jsx(I,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:"Default"}):null,e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:t.shareMode}),t.active?null:e.jsx(I,{className:"bg-[var(--ui-warning-soft)] text-[var(--warning)]",children:"Inactive"})]})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-4",children:[e.jsx(v,{value:t.name,onChange:s=>void q.mutateAsync({contextId:t.id,patch:{name:s.target.value}}),placeholder:"Context name"}),e.jsxs("select",{value:t.shareMode,onChange:s=>void q.mutateAsync({contextId:t.id,patch:{shareMode:s.target.value}}),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] 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(v,{value:String(t.decayDays),onChange:s=>void q.mutateAsync({contextId:t.id,patch:{decayDays:Number(s.target.value||90)}}),placeholder:"Decay days"}),e.jsx(u,{variant:"secondary",onClick:()=>A({contextId:t.id,tab:"overview"}),children:"Open context"})]}),e.jsx(E,{value:t.description,onChange:s=>void q.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(u,{variant:"secondary",onClick:()=>void q.mutateAsync({contextId:t.id,patch:{active:!t.active}}),children:t.active?"Deactivate":"Activate"}),t.isDefault?null:e.jsx(u,{variant:"secondary",onClick:()=>void q.mutateAsync({contextId:t.id,patch:{isDefault:!0}}),children:"Make default"})]})]},t.id))}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs(j,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Create context"}),e.jsx(v,{value:L.name,onChange:t=>W(s=>({...s,name:t.target.value})),placeholder:"Context name"}),e.jsx(E,{value:L.description,onChange:t=>W(s=>({...s,description:t.target.value})),className:"min-h-24",placeholder:"What changes in this context?"}),e.jsxs("select",{value:L.shareMode,onChange:t=>W(s=>({...s,shareMode:t.target.value})),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] 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(v,{value:L.decayDays,onChange:t=>W(s=>({...s,decayDays:t.target.value})),placeholder:"Decay days"}),e.jsx(u,{disabled:!L.name.trim(),pending:Ae.isPending,pendingLabel:"Creating context",onClick:()=>void Ae.mutateAsync({userId:m,domain:C,name:L.name,description:L.description,shareMode:L.shareMode,decayDays:Number(L.decayDays||90),active:!0,isDefault:!1}),children:"Create context"})]}),e.jsxs(j,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Merge contexts"}),e.jsxs("select",{value:G,onChange:t=>J(t.target.value),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none",children:[e.jsx("option",{value:"",children:"Source context"}),r.contexts.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]}),e.jsxs("select",{value:O,onChange:t=>be(t.target.value),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none",children:[e.jsx("option",{value:"",children:"Target context"}),r.contexts.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]}),e.jsx(u,{pending:Ee.isPending,pendingLabel:"Merging",disabled:!G||!O||G===O,onClick:()=>void Ee.mutateAsync({sourceContextId:G,targetContextId:O}),children:"Merge into target"})]})]})]}):null,T==="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(j,{className:"grid gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Concept libraries"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",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",r.libraries.totalCatalogs],["Concepts",r.libraries.totalCatalogItems],["Seeded",r.libraries.seededCatalogCount],["Custom",r.libraries.customCatalogCount]].map(([t,s])=>e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:t}),e.jsx("div",{className:"mt-2 font-display text-3xl text-[var(--ui-ink-strong)]",children:s})]},t))}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"size-4 text-[var(--ui-ink-muted)]"}),e.jsx(v,{value:S,onChange:t=>V(t.target.value),placeholder:"Search lists, concepts, tags, and seeded domains"})]})]}),e.jsxs(j,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Create concept list"}),e.jsx(v,{value:H.title,onChange:t=>me(s=>({...s,title:t.target.value})),placeholder:"List title"}),e.jsx(E,{value:H.description,onChange:t=>me(s=>({...s,description:t.target.value})),className:"min-h-24",placeholder:"What should this list help compare?"}),e.jsx(u,{disabled:!H.title.trim(),pending:we.isPending,pendingLabel:"Creating list",onClick:()=>void we.mutateAsync({userId:m,domain:C,title:H.title,description:H.description}),children:"Create list"})]})]}),e.jsx("div",{className:"grid gap-4",children:Ce.map(t=>{const s=rt[t.id]??{label:"",description:"",tags:""},c=t.items.filter(n=>S.trim()?[n.label,n.description,n.tags.join(" ")].join(" ").toLowerCase().includes(le(S)):!0);return e.jsxs(j,{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:ye===t.id?e.jsxs("div",{className:"grid gap-3",children:[e.jsx(v,{value:se.title,onChange:n=>pe(l=>({...l,title:n.target.value}))}),e.jsx(E,{value:se.description,onChange:n=>pe(l=>({...l,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-[var(--ui-ink-strong)]",children:t.title}),e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:t.source}),e.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[t.items.length," items"]})]}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:t.description||"No description yet."})]})}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{variant:"secondary",size:"sm",onClick:()=>void _e(C,t.id),children:"Start from this list"}),ye===t.id?e.jsxs(e.Fragment,{children:[e.jsx(u,{size:"sm",pending:Pe.isPending,pendingLabel:"Saving",onClick:()=>void Pe.mutateAsync({catalogId:t.id,patch:{title:se.title,description:se.description}}),children:"Save"}),e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>xe(null),children:"Cancel"})]}):e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>{xe(t.id),pe({title:t.title,description:t.description})},children:"Edit list"}),e.jsx(u,{variant:"ghost",size:"sm",pending:Fe.isPending,pendingLabel:"Deleting",onClick:()=>void Fe.mutateAsync(t.id),children:"Delete list"})]})]}),e.jsx("div",{className:"grid gap-2",children:c.map(n=>e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-3",children:nt===n.id?e.jsxs("div",{className:"grid gap-3",children:[e.jsx(v,{value:B.label,onChange:l=>ae(y=>({...y,label:l.target.value}))}),e.jsx(E,{value:B.description,onChange:l=>ae(y=>({...y,description:l.target.value})),className:"min-h-20"}),e.jsx(v,{value:B.tags,onChange:l=>ae(y=>({...y,tags:l.target.value})),placeholder:"comma, separated, tags"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{size:"sm",pending:Te.isPending,pendingLabel:"Saving",onClick:()=>void Te.mutateAsync({catalogItemId:n.id,patch:{label:B.label,description:B.description,tags:B.tags.split(",").map(l=>l.trim()).filter(Boolean)}}),children:"Save concept"}),e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>ge(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-[var(--ui-ink-strong)]",children:n.label}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:n.description||"No description yet."}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:n.tags.map(l=>e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:l},`${n.id}-${l}`))})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>{ge(n.id),ae({label:n.label,description:n.description,tags:n.tags.join(", ")})},children:"Edit"}),e.jsxs(u,{variant:"ghost",size:"sm",pending:Me.isPending,pendingLabel:"Deleting",onClick:()=>void Me.mutateAsync(n.id),children:[e.jsx(Ct,{className:"mr-1 size-4"}),"Delete"]})]})]})},n.id))}),e.jsxs("div",{className:"grid gap-3 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--ui-ink-medium)]",children:[e.jsx(It,{className:"size-4"}),"Add concept to ",t.title]}),e.jsx(v,{value:s.label,onChange:n=>te(l=>({...l,[t.id]:{...s,label:n.target.value}})),placeholder:"Concept label"}),e.jsx(E,{value:s.description,onChange:n=>te(l=>({...l,[t.id]:{...s,description:n.target.value}})),className:"min-h-20",placeholder:"Short description"}),e.jsx(v,{value:s.tags,onChange:n=>te(l=>({...l,[t.id]:{...s,tags:n.target.value}})),placeholder:"comma, separated, tags"}),e.jsx(u,{disabled:!s.label.trim(),pending:Le.isPending,pendingLabel:"Adding",onClick:()=>void Le.mutateAsync({catalogId:t.id,label:s.label,description:s.description,tags:s.tags.split(",").map(n=>n.trim()).filter(Boolean),featureWeights:ne}).then(()=>te(n=>({...n,[t.id]:{label:"",description:"",tags:""}}))),children:"Add concept"})]})]},t.id)})})]}):null]}),e.jsx(cs,{state:z,onOpenChange:t=>{t||D(null),M(s=>({...s,open:t}))},error:at,loading:it,workspaceLoading:Ne.isLoading,activeWorkspace:P,conceptSearchQuery:S,onConceptSearchQueryChange:V,filteredCatalogs:Ce,onSelectDomain:t=>void mt(t),onStartCatalogGame:(t,s)=>void _e(t,s),onJudge:(t,s)=>void xt(t,s),onSignal:(t,s)=>void pt(t,s)})]})}export{ks as PreferencesPage};
1
+ import{b0 as ht,bD as vt,cF as ft,cG as bt,bf as jt,aG as yt,j as e,aK as Nt,b3 as de,c2 as kt,r as x,aC as ve,c7 as Ct,b4 as It}from"./vendor-Dnkkx2co.js";import{j as St,i as Ke,k as N}from"./state-vCcAT5Hq.js";import{bk as Z,Z as U,c as I,I as v,L as Je,a as et,B as u,C as j,U as tt,H as wt,u as Pt,s as Ft,c1 as Ye,c2 as Lt,c3 as Tt,c4 as Mt,c5 as Dt,c6 as At,c7 as Et,c8 as zt,c9 as _t,ca as Gt,cb as Ot,cc as $t,cd as Bt,ce as qt,cf as Qt,cg as Rt,E as Ut,ch as Wt,T as E,ci as Xe}from"./index-QJkjKYzZ.js";import{P as Ht}from"./page-hero-CONuJu5J.js";import{R as Kt,P as Yt,O as Xt,C as Zt,T as Vt,D as Jt,a as es}from"./ui-C1iwpj2-.js";import"./motion-Lt5B1XuE.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";const st=[{id:"overview",label:"Overview",icon:ht},{id:"map",label:"Map",icon:vt},{id:"table",label:"Table",icon:ft},{id:"history",label:"History",icon:bt},{id:"contexts",label:"Contexts",icon:jt},{id:"concepts",label:"Concepts",icon:yt}],ts=new Set(["projects","tasks","strategies","habits"]),oe=[{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"}],fe={novelty:"Novelty",simplicity:"Simplicity",rigor:"Rigor",aesthetics:"Aesthetics",depth:"Depth",structure:"Structure",familiarity:"Familiarity",surprise:"Surprise"},ne={novelty:0,simplicity:0,rigor:0,aesthetics:0,depth:0,structure:0,familiarity:0,surprise:0},Ze={liked:"bg-[var(--ui-success-soft)] text-[var(--success)]",disliked:"bg-[var(--ui-danger-soft)] text-[var(--danger)]",uncertain:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",vetoed:"bg-[var(--ui-danger-soft)] text-[var(--danger)]",bookmarked:"bg-[var(--ui-info-soft)] text-[var(--info)]",favorite:"bg-[var(--ui-warning-soft)] text-[var(--warning)]",must_have:"bg-[var(--ui-accent-soft)] text-[var(--primary)]",neutral:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]"},ss=[{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 le(i){return i.trim().toLowerCase()}function R(i){return`${Math.round(i*100)}%`}function as(i){return[...i.goals.map(a=>({entityType:"goal",entityId:a.id,domain:"projects",label:a.title,description:a.description,user:a.user,href:`/goals/${a.id}`,searchText:Z([a.title,a.description,a.status,a.horizon],a)})),...i.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:Z([a.title,a.description,a.status,a.goalTitle],a)})),...i.tasks.map(a=>({entityType:"task",entityId:a.id,domain:"tasks",label:a.title,description:a.description,user:a.user,href:`/tasks/${a.id}`,searchText:Z([a.title,a.description,a.status,a.priority,a.owner],a)})),...i.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:Z([a.title,a.overview,a.endStateDescription,a.status],a)})),...i.habits.map(a=>({entityType:"habit",entityId:a.id,domain:"habits",label:a.title,description:a.description,user:a.user,href:null,searchText:Z([a.title,a.description,a.status,a.frequency],a)}))]}function is(i,a){return!i||!a?null:i==="goal"?`/goals/${a}`:i==="project"?`/projects/${a}`:i==="task"?`/tasks/${a}`:i==="strategy"?`/strategies/${a}`:null}function ce(i){return i.manualStatus??i.status}function rs(i){return i&&st.some(a=>a.id===i)?i:"overview"}function ns(i){return i.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."}:i.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 ls({summary:i}){const a=Math.max(-1,Math.min(1,i.leaning)),o=(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-[var(--ui-ink-soft)]",children:[e.jsx("span",{children:fe[i.dimensionId]}),e.jsxs("span",{children:[i.movement>.08?"Rising":i.movement<-.08?"Falling":"Stable"," ","· ",R(i.confidence)]})]}),e.jsxs("div",{className:"relative h-2 rounded-full bg-[var(--ui-surface-2)]",children:[e.jsx("div",{className:"absolute inset-y-0 left-1/2 w-px bg-[var(--ui-border-strong)]"}),e.jsx("div",{className:U("absolute top-1/2 size-3 -translate-x-1/2 -translate-y-1/2 rounded-full border border-[var(--ui-border-strong)]",a>=0?"bg-[var(--success)]":"bg-[var(--danger)]"),style:{left:`${o}%`}})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 text-[11px] uppercase tracking-[0.12em] text-[var(--ui-ink-faint)]",children:[e.jsxs("span",{children:[a>=0?"Leans toward":"Leans away from"," ",fe[i.dimensionId].toLowerCase()]}),e.jsxs("span",{children:["Context ",R(i.contextSensitivity)]})]})]})}function Ve({title:i,description:a,sideLabel:o,onClick:g}){return e.jsxs("button",{type:"button",className:"grid min-h-[220px] gap-4 rounded-[28px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] p-5 text-left transition hover:border-[color-mix(in_srgb,var(--primary)_40%,transparent)] hover:bg-[var(--ui-surface-hover)]",onClick:g,children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:o}),e.jsx("div",{className:"font-display text-3xl text-[var(--ui-ink-strong)]",children:i}),e.jsx("div",{className:"max-w-[36ch] text-sm leading-6 text-[var(--ui-ink-soft)]",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 cs({state:i,onOpenChange:a,error:o,loading:g,workspaceLoading:k,activeWorkspace:h,conceptSearchQuery:w,onConceptSearchQueryChange:p,filteredCatalogs:S,onSelectDomain:V,onStartCatalogGame:G,onJudge:J,onSignal:O}){return e.jsx(Kt,{open:i.open,onOpenChange:a,children:e.jsxs(Yt,{children:[e.jsx(Xt,{className:"fixed inset-0 z-40 bg-[var(--ui-overlay-backdrop)] backdrop-blur-xl"}),e.jsxs(Zt,{className:"fixed inset-x-4 bottom-4 top-4 z-50 overflow-y-auto rounded-[32px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-modal)] shadow-[var(--ui-shadow-floating)] 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(Vt,{className:"sr-only",children:"Preference game"}),e.jsx(Jt,{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-[var(--ui-border-subtle)] bg-[color-mix(in_srgb,var(--surface-glass)_94%,transparent)] px-5 py-4 backdrop-blur-xl",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Preference game"}),e.jsx("div",{className:"mt-1 font-display text-2xl text-[var(--ui-ink-strong)]",children:i.phase==="domain"?"Choose a domain":i.phase==="catalog"?"Choose a concept list":"Pick the better fit"})]}),e.jsx(es,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":"Close preference game",className:"rounded-full bg-[var(--ui-surface-2)] p-2 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",children:e.jsx(Nt,{className:"size-4"})})})]}),e.jsxs("div",{className:"grid gap-5 px-5 py-5",children:[o?e.jsx("div",{className:"rounded-[18px] border border-[color-mix(in_srgb,var(--danger)_28%,transparent)] bg-[var(--ui-danger-soft)] px-4 py-3 text-sm text-[var(--danger)]",children:o}):null,i.phase==="domain"?e.jsx(ds,{onSelectDomain:V}):null,i.phase==="catalog"?e.jsx(os,{domain:i.domain,query:w,onQueryChange:p,catalogs:S,onStartCatalogGame:G}):null,i.phase==="play"?e.jsx(us,{domain:i.domain,loading:g||k,activeWorkspace:h,onJudge:J,onSignal:O}):null]})]})]})})}function ds({onSelectDomain:i}){return e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:oe.map(a=>e.jsxs("button",{type:"button",className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-5 py-5 text-left transition hover:border-[color-mix(in_srgb,var(--primary)_30%,transparent)] hover:bg-[var(--ui-accent-soft)]",onClick:()=>i(a.value),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:a.label}),e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:a.mode==="forge"?"Forge":"Concept"})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:a.description})]},a.value))})}function os({domain:i,query:a,onQueryChange:o,catalogs:g,onStartCatalogGame:k}){return e.jsxs("div",{className:"grid gap-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",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(de,{className:"size-4 text-[var(--ui-ink-faint)]"}),e.jsx(v,{value:a,onChange:h=>o(h.target.value),placeholder:"Search concept lists"})]}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:g.length>0?g.map(h=>e.jsxs("button",{type:"button",className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-5 py-5 text-left transition hover:border-[color-mix(in_srgb,var(--primary)_30%,transparent)] hover:bg-[var(--ui-accent-soft)]",onClick:()=>k(i,h.id),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:h.title}),e.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[h.items.length," items"]})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:h.description||"No description yet."})]},h.id)):e.jsx("div",{className:"rounded-[24px] bg-[var(--ui-surface-1)] px-5 py-6 text-sm text-[var(--ui-ink-soft)]",children:"No concept list matches that search yet."})})]})}function us({domain:i,loading:a,activeWorkspace:o,onJudge:g,onSignal:k}){var w;const h=(o==null?void 0:o.compare.nextPair)??null;return a?e.jsx(Je,{eyebrow:"Preference game",title:"Preparing the next round",description:"Forge is lining up comparison candidates."}):h?e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:((w=oe.find(p=>p.value===i))==null?void 0:w.label)??i}),e.jsx("span",{children:o==null?void 0:o.selectedContext.name}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[(o==null?void 0:o.compare.pendingCount)??0," queued comparisons"]})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(Ve,{title:h.left.label,description:h.left.description,sideLabel:"Left",onClick:()=>g("left",1)}),e.jsx(Ve,{title:h.right.label,description:h.right.description,sideLabel:"Right",onClick:()=>g("right",1)})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{onClick:()=>g("left",1),children:"Left"}),e.jsx(u,{onClick:()=>g("right",1),children:"Right"}),e.jsx(u,{variant:"secondary",onClick:()=>g("left",1.75),children:"Strong left"}),e.jsx(u,{variant:"secondary",onClick:()=>g("right",1.75),children:"Strong right"}),e.jsx(u,{variant:"secondary",onClick:()=>g("tie",1),children:"Tie"}),e.jsx(u,{variant:"secondary",onClick:()=>g("skip",1),children:"Skip"})]}),e.jsx("div",{className:"grid gap-4 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4 lg:grid-cols-2",children:[h.left,h.right].map(p=>e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:p.label}),e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Quick signals"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ss.map(S=>e.jsx(u,{variant:"secondary",size:"sm",onClick:()=>k(p.id,S.signalType),children:S.label},`${p.id}-${S.signalType}`))})]},p.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."})}function ms({users:i,user:a,selectedUserId:o,selectedDomain:g,workspace:k,onPatchSearch:h}){var w;return e.jsxs(j,{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-[var(--ui-ink-faint)]",children:"Active user"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("select",{value:o,onChange:p=>h({userId:p.target.value,contextId:null,focusItem:null}),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none transition focus:border-[var(--primary)]",children:i.map(p=>e.jsxs("option",{value:p.id,children:[p.displayName," · ",p.kind]},p.id))}),e.jsx(tt,{user:a}),e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:wt(a)})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Domain"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:oe.map(p=>e.jsx("button",{type:"button",className:U("rounded-full border px-3 py-2 text-sm transition",p.value===g?"border-[var(--primary)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>h({domain:p.value,contextId:null,focusItem:null}),children:p.label},p.value))}),e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:(w=oe.find(p=>p.value===g))==null?void 0:w.description})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:k.selectedContext.name}),e.jsx("span",{children:k.selectedContext.shareMode}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[k.compare.pendingCount," queued comparisons"]}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[k.libraries.totalCatalogItems," concept items ready"]})]})]})}function xs({selectedTab:i,onSelectTab:a}){return e.jsx("div",{className:"flex flex-wrap gap-2",children:st.map(o=>e.jsxs("button",{type:"button",className:U("inline-flex items-center gap-2 rounded-full border px-3 py-2 text-sm transition",o.id===i?"border-[var(--primary)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>a(o.id),children:[e.jsx(o.icon,{className:"size-4"}),o.label]},o.id))})}function ks(){var qe,Qe,Re;const i=Pt(),a=St(),[o,g]=kt(),[k,h]=x.useState(""),[w,p]=x.useState(""),[S,V]=x.useState(""),[G,J]=x.useState(""),[O,be]=x.useState(""),[z,M]=x.useState({open:!1,phase:"domain",domain:o.get("domain")??"projects"}),[at,D]=x.useState(null),[it,ue]=x.useState(!1),[je,$]=x.useState(null),[f,F]=x.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"}}),[_,ee]=x.useState({label:"",description:"",tags:""}),[L,W]=x.useState({name:"",description:"",shareMode:"blended",decayDays:"90"}),[H,me]=x.useState({title:"",description:""}),[rt,te]=x.useState({}),[ye,xe]=x.useState(null),[se,pe]=x.useState({title:"",description:""}),[nt,ge]=x.useState(null),[B,ae]=x.useState({label:"",description:"",tags:""}),m=o.get("userId")??Ft(i.selectedUserIds)??((qe=i.snapshot.users[0])==null?void 0:qe.id)??null,C=o.get("domain")??"projects",T=rs(o.get("tab")),K=o.get("contextId"),ie=o.get("focusItem"),lt=x.useMemo(()=>i.snapshot.users.find(t=>t.id===m)??null,[m,i.snapshot.users]),re=x.useMemo(()=>as(i.snapshot),[i.snapshot]),Y=Ke({queryKey:["forge-preferences",m,C,K],queryFn:async()=>(await Xe({userId:m??void 0,domain:C,contextId:K??void 0})).workspace,enabled:!!m}),Ne=Ke({queryKey:["forge-preferences-game",m,z.domain,K],queryFn:async()=>(await Xe({userId:m??void 0,domain:z.domain,contextId:K??void 0})).workspace,enabled:!!m&&z.open}),r=Y.data??null,P=z.domain===C?r:Ne.data??null;x.useEffect(()=>{var s;if(!r)return;const t=ie&&r.scores.some(c=>c.itemId===ie)?ie:((s=r.scores[0])==null?void 0:s.itemId)??null;$(c=>c&&r.scores.some(n=>n.itemId===c)?c:t)},[ie,r]);const he=x.useMemo(()=>{if(!r)return[];const t=le(k);return t?r.scores.filter(s=>{var c,n,l;return[((c=s.item)==null?void 0:c.label)??"",((n=s.item)==null?void 0:n.description)??"",((l=s.item)==null?void 0:l.tags.join(" "))??"",s.status,s.manualStatus??"",s.dominantDimensions.join(" "),s.explanation.join(" ")].join(" ").toLowerCase().includes(t)}):r.scores},[k,r]),d=he.find(t=>t.itemId===je)??(r==null?void 0:r.scores.find(t=>t.itemId===je))??he[0]??(r==null?void 0:r.scores[0])??null;x.useEffect(()=>{var t,s,c,n,l,y,X,Q,Ue,We,He;d&&F({label:((t=d.item)==null?void 0:t.label)??"",description:((s=d.item)==null?void 0:s.description)??"",tags:((c=d.item)==null?void 0:c.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(((l=d.item)==null?void 0:l.featureWeights.simplicity)??0),rigor:String(((y=d.item)==null?void 0:y.featureWeights.rigor)??0),aesthetics:String(((X=d.item)==null?void 0:X.featureWeights.aesthetics)??0),depth:String(((Q=d.item)==null?void 0:Q.featureWeights.depth)??0),structure:String(((Ue=d.item)==null?void 0:Ue.featureWeights.structure)??0),familiarity:String(((We=d.item)==null?void 0:We.featureWeights.familiarity)??0),surprise:String(((He=d.item)==null?void 0:He.featureWeights.surprise)??0)}})},[d]);const ke=x.useMemo(()=>{const t=le(w);return re.filter(s=>s.domain===C).filter(s=>t?s.searchText.includes(t):!0).slice(0,12)},[re,w,C]),Ce=x.useMemo(()=>{const t=T==="concepts"?r:P??r,s=(t==null?void 0:t.catalogs)??[],c=le(S);return c?s.filter(n=>[n.title,n.description,n.source,...n.items.flatMap(l=>[l.label,l.description,l.tags.join(" ")])].join(" ").toLowerCase().includes(c)):s},[P,S,T,r]),b=async()=>{await a.invalidateQueries({queryKey:["forge-preferences"]}),await a.invalidateQueries({queryKey:["forge-preferences-game"]})},Ie=N({mutationFn:Ye,onSuccess:b}),Se=N({mutationFn:Lt,onSuccess:async({item:t})=>{await b(),ee({label:"",description:"",tags:""}),$(t.id)}}),we=N({mutationFn:Tt,onSuccess:async()=>{await b(),me({title:"",description:""}),g(t=>{const s=new URLSearchParams(t);return s.set("tab","concepts"),s})}}),Pe=N({mutationFn:({catalogId:t,patch:s})=>Mt(t,s),onSuccess:async()=>{await b(),xe(null)}}),Fe=N({mutationFn:Dt,onSuccess:b}),Le=N({mutationFn:At,onSuccess:async()=>{await b()}}),Te=N({mutationFn:({catalogItemId:t,patch:s})=>Et(t,s),onSuccess:async()=>{await b(),ge(null)}}),Me=N({mutationFn:zt,onSuccess:b}),ct=N({mutationFn:_t,onSuccess:async()=>{await b(),M(t=>({...t,phase:"play"}))}}),dt=N({mutationFn:Gt,onSuccess:b}),ot=N({mutationFn:Ot,onSuccess:b}),De=N({mutationFn:async()=>{!(d!=null&&d.item)||!m||!r||(await $t(d.item.id,{label:f.label,description:f.description,tags:f.tags.split(",").map(t=>t.trim()).filter(Boolean),featureWeights:Object.fromEntries(Object.keys(ne).map(t=>[t,Number(f.featureWeights[t]||0)]))}),await Bt(d.item.id,{userId:m,domain:C,contextId:r.selectedContext.id,manualStatus:f.manualStatus||null,manualScore:f.manualScore.trim().length>0?Number(f.manualScore):null,confidenceLock:f.confidenceLock.trim().length>0?Number(f.confidenceLock):null,bookmarked:f.bookmarked,compareLater:f.compareLater,frozen:f.frozen}))},onSuccess:b}),Ae=N({mutationFn:qt,onSuccess:async({context:t})=>{await b(),W({name:"",description:"",shareMode:"blended",decayDays:"90"}),g(s=>{const c=new URLSearchParams(s);return c.set("contextId",t.id),c.set("tab","contexts"),c})}}),Ee=N({mutationFn:Qt,onSuccess:async()=>{await b(),J(""),be("")}}),q=N({mutationFn:({contextId:t,patch:s})=>Rt(t,s),onSuccess:b}),A=t=>{g(s=>{const c=new URLSearchParams(s);for(const[n,l]of Object.entries(t))l?c.set(n,l):c.delete(n);return c})},ze=(t=C)=>{D(null),M({open:!0,phase:"domain",domain:t})},ut=async t=>{if(!m)return;D(null),ue(!0);const s=re.filter(l=>{var y;return l.domain===t&&((y=l.user)==null?void 0:y.id)===m}),c=re.filter(l=>l.domain===t),n=(s.length>0?s:c).slice(0,12);if(n.length<2){D("Forge needs at least two matching records in this domain before it can start the game."),ue(!1),M(l=>({...l,phase:"domain"}));return}try{A({domain:t,tab:"overview",contextId:null,focusItem:null}),await Promise.all(n.map(l=>Ye({userId:m,domain:t,entityType:l.entityType,entityId:l.entityId,label:l.label,description:l.description,tags:[]}))),await b(),M({open:!0,phase:"play",domain:t})}catch(l){D(l instanceof Error?l.message:"Forge could not start the game."),M(y=>({...y,phase:"domain"}))}finally{ue(!1)}},_e=async(t,s)=>{if(m){D(null),A({domain:t,tab:"overview",contextId:null,focusItem:null});try{await ct.mutateAsync({userId:m,domain:t,contextId:K??void 0,catalogId:s}),M({open:!0,phase:"play",domain:t})}catch(c){D(c instanceof Error?c.message:"Forge could not start the game.")}}},mt=async t=>{if(ts.has(t)){await ut(t);return}D(null),M({open:!0,phase:"catalog",domain:t})},xt=async(t,s=1)=>{if(!m||!(P!=null&&P.compare.nextPair))return;const c=P.compare.nextPair;await dt.mutateAsync({userId:m,domain:z.domain,contextId:P.selectedContext.id,leftItemId:c.left.id,rightItemId:c.right.id,outcome:t,strength:s})},pt=async(t,s)=>{!m||!P||await ot.mutateAsync({userId:m,domain:z.domain,contextId:P.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(Y.isLoading&&!r)return e.jsx(Je,{eyebrow:"Preferences",title:"Loading preference model",description:"Reconstructing current scores, uncertainty, and concept libraries."});if(Y.isError)return e.jsx(Ut,{eyebrow:"Preferences",error:Y.error,onRetry:()=>void Y.refetch()});if(!r)return null;const gt=[...r.dimensions].sort((t,s)=>s.confidence-t.confidence).slice(0,6),Ge=r.scores.filter(t=>ce(t)==="liked"||ce(t)==="favorite").slice(0,4),Oe=r.scores.filter(t=>t.uncertainty>=.5).slice(0,4),$e=ns(r),Be=is(((Qe=d==null?void 0:d.item)==null?void 0:Qe.sourceEntityType)??null,((Re=d==null?void 0:d.item)==null?void 0:Re.sourceEntityId)??null);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsx(Ht,{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:`${r.summary.totalItems} items · ${R(r.summary.averageConfidence)} confidence`,actions:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{className:"min-w-[10rem]",onClick:()=>ze(),children:"Start the game"}),e.jsx(u,{variant:"secondary",onClick:()=>void b(),children:"Refresh model"})]})}),e.jsx(Wt,{}),e.jsx(ms,{users:i.snapshot.users,user:lt,selectedUserId:m,selectedDomain:C,workspace:r,onPatchSearch:A}),e.jsx(xs,{selectedTab:T,onSelectTab:t=>A({tab:t})}),T==="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(j,{className:"grid gap-5",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"What Forge knows"}),e.jsx("div",{className:"font-display text-3xl text-[var(--ui-ink-strong)]",children:$e.title}),e.jsx("div",{className:"max-w-[70ch] text-sm leading-6 text-[var(--ui-ink-soft)]",children:$e.description})]}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[{label:"Known items",value:r.summary.totalItems,detail:"Items inside this domain"},{label:"Confidence",value:R(r.summary.averageConfidence),detail:"Average certainty"},{label:"Unknowns",value:r.summary.uncertainCount,detail:"Need more rounds"},{label:"Libraries",value:r.libraries.totalCatalogItems,detail:"Seeded concepts ready"}].map(t=>e.jsxs("div",{className:"rounded-[22px] bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:t.label}),e.jsx("div",{className:"mt-2 font-display text-3xl text-[var(--ui-ink-strong)]",children:t.value}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:t.detail})]},t.label))}),e.jsx("div",{className:"grid gap-4 lg:grid-cols-2",children:gt.map(t=>e.jsx(ls,{summary:t},t.dimensionId))})]}),e.jsxs(j,{className:"grid gap-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Next move"}),e.jsx("div",{className:"font-display text-2xl text-[var(--ui-ink-strong)]",children:"Start the game"}),e.jsx("div",{className:"text-sm leading-6 text-[var(--ui-ink-soft)]",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(u,{className:"w-full",onClick:()=>ze(),children:"Start the game"}),e.jsxs("div",{className:"grid gap-3 rounded-[22px] bg-[var(--ui-surface-2)] px-4 py-4 text-sm text-[var(--ui-ink-soft)]",children:[e.jsxs("div",{children:["Current queue: ",r.compare.pendingCount," comparison",r.compare.pendingCount===1?"":"s"]}),e.jsxs("div",{children:["Active context: ",r.selectedContext.name]}),e.jsxs("div",{children:["Library coverage: ",r.libraries.seededCatalogCount," ","seeded lists and ",r.libraries.customCatalogCount," ","custom lists"]})]})]})]}),e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.3fr)_360px]",children:[e.jsxs(j,{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-[var(--ui-ink-faint)]",children:"Preference map"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Green drifts positive, red drifts negative, and low opacity still means uncertainty."})]}),e.jsx(ve,{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-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)]",children:[e.jsx("div",{className:"absolute inset-x-0 top-1/2 h-px bg-[var(--ui-border-subtle)]"}),e.jsx("div",{className:"absolute inset-y-0 left-1/2 w-px bg-[var(--ui-border-subtle)]"}),r.map.map(t=>e.jsx("button",{type:"button",className:U("absolute -translate-x-1/2 -translate-y-1/2 rounded-full border px-2 py-1 text-[11px] shadow-[var(--ui-shadow-soft)] transition hover:scale-[1.04]",t.itemId===(d==null?void 0:d.itemId)?"border-[var(--ui-border-strong)] bg-[var(--ui-surface-active)] text-[var(--ui-ink-strong)]":t.score>=0?"border-[color-mix(in_srgb,var(--success)_34%,transparent)] bg-[var(--ui-success-soft)] text-[var(--ui-ink-strong)]":"border-[color-mix(in_srgb,var(--danger)_34%,transparent)] bg-[var(--ui-danger-soft)] text-[var(--ui-ink-strong)]"),style:{left:`${50+t.x*30}%`,top:`${50-t.y*30}%`,opacity:.55+t.confidence*.45},onClick:()=>$(t.itemId),children:t.label},t.itemId))]})]}),e.jsxs(j,{className:"grid gap-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Best read so far"}),e.jsx("div",{className:"grid gap-2",children:Ge.length>0?Ge.map(t=>{var s;return e.jsxs("button",{type:"button",className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-3 text-left transition hover:bg-[var(--ui-surface-hover)]",onClick:()=>{$(t.itemId),A({focusItem:t.itemId})},children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:((s=t.item)==null?void 0:s.label)??t.itemId}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:t.explanation[0]||"Forge has positive evidence here."})]},t.itemId)}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-3 text-sm text-[var(--ui-ink-soft)]",children:"No clear positives yet. A few comparison rounds will change that."})}),e.jsxs("div",{className:"border-t border-[var(--ui-border-subtle)] pt-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Biggest unknowns"}),e.jsx("div",{className:"mt-3 grid gap-2",children:Oe.length>0?Oe.map(t=>{var s;return e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-3 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:((s=t.item)==null?void 0:s.label)??t.itemId}),e.jsxs("div",{className:"mt-1",children:["Uncertainty ",R(t.uncertainty)]})]},t.itemId)}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-3 text-sm text-[var(--ui-ink-soft)]",children:"The current unknown list is short."})})]})]})]}),e.jsxs(j,{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-[var(--ui-ink-faint)]",children:"Bring in Forge records"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Search goals, projects, tasks, strategies, or habits across human and bot users, then send them straight into this model."})]}),e.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[ke.length," visible"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"size-4 text-[var(--ui-ink-muted)]"}),e.jsx(v,{value:w,onChange:t=>p(t.target.value),placeholder:"Search across owners, handles, user kind, title, and description"})]}),e.jsx("div",{className:"grid gap-2",children:ke.map(t=>e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-[18px] bg-[var(--ui-surface-2)] 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-[var(--ui-ink-strong)]",children:t.label}),e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:t.entityType}),t.user?e.jsx(tt,{user:t.user,compact:!0}):null]}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:t.description||"No description yet."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.href?e.jsx(ve,{to:t.href,children:e.jsx(u,{variant:"ghost",size:"sm",children:"Open"})}):null,e.jsx(u,{variant:"secondary",size:"sm",pending:Ie.isPending,pendingLabel:"Adding",onClick:()=>void Ie.mutateAsync({userId:m,domain:C,entityType:t.entityType,entityId:t.entityId,label:t.label,description:t.description,tags:[]}),children:"Add to model"})]})]},`${t.entityType}-${t.entityId}`))})]})]}):null,T==="map"?e.jsxs(j,{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-[var(--ui-ink-faint)]",children:"Full map"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Click a point to inspect why Forge believes it belongs there."})]}),e.jsxs("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:[r.map.length," plotted items"]})]}),e.jsxs("div",{className:"relative min-h-[520px] overflow-hidden rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)]",children:[e.jsx("div",{className:"absolute inset-x-0 top-1/2 h-px bg-[var(--ui-border-subtle)]"}),e.jsx("div",{className:"absolute inset-y-0 left-1/2 w-px bg-[var(--ui-border-subtle)]"}),r.map.map(t=>e.jsx("button",{type:"button",className:U("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-[var(--ui-border-strong)] bg-[var(--ui-surface-active)] text-[var(--ui-ink-strong)]":t.score>=0?"border-[color-mix(in_srgb,var(--success)_34%,transparent)] bg-[var(--ui-success-soft)] text-[var(--ui-ink-strong)]":"border-[color-mix(in_srgb,var(--danger)_34%,transparent)] bg-[var(--ui-danger-soft)] text-[var(--ui-ink-strong)]"),style:{left:`${50+t.x*34}%`,top:`${50-t.y*34}%`,opacity:.45+t.confidence*.55},onClick:()=>{$(t.itemId),A({focusItem:t.itemId})},children:t.label},t.itemId))]})]}):null,T==="table"?e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.2fr)_380px]",children:[e.jsxs(j,{className:"grid gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"size-4 text-[var(--ui-ink-muted)]"}),e.jsx(v,{value:k,onChange:t=>h(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-[var(--ui-ink-muted)]",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:he.map(t=>{var s,c;return e.jsxs("tr",{className:U("cursor-pointer border-t border-[var(--ui-border-subtle)] transition hover:bg-[var(--ui-surface-2)]",t.itemId===(d==null?void 0:d.itemId)?"bg-[var(--ui-surface-2)]":""),onClick:()=>{$(t.itemId),A({focusItem:t.itemId})},children:[e.jsxs("td",{className:"px-3 py-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:((s=t.item)==null?void 0:s.label)??t.itemId}),e.jsx("div",{className:"text-xs text-[var(--ui-ink-muted)]",children:(((c=t.item)==null?void 0:c.tags)??[]).join(" · ")})]}),e.jsx("td",{className:"px-3 py-3 text-[var(--ui-ink-medium)]",children:t.latentScore.toFixed(2)}),e.jsx("td",{className:"px-3 py-3 text-[var(--ui-ink-medium)]",children:R(t.confidence)}),e.jsx("td",{className:"px-3 py-3",children:e.jsx(I,{className:Ze[ce(t)],children:ce(t)})}),e.jsx("td",{className:"px-3 py-3 text-[var(--ui-ink-medium)]",children:t.evidenceCount})]},t.itemId)})})]})})]}),e.jsxs(j,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Item editor"}),d!=null&&d.item?e.jsxs(e.Fragment,{children:[e.jsx(v,{value:f.label,onChange:t=>F(s=>({...s,label:t.target.value})),placeholder:"Item label"}),e.jsx(E,{value:f.description,onChange:t=>F(s=>({...s,description:t.target.value})),className:"min-h-24",placeholder:"Item description"}),e.jsx(v,{value:f.tags,onChange:t=>F(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:f.manualStatus,onChange:t=>F(s=>({...s,manualStatus:t.target.value})),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none",children:[e.jsx("option",{value:"",children:"Inferred status"}),Object.keys(Ze).map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsx(v,{value:f.manualScore,onChange:t=>F(s=>({...s,manualScore:t.target.value})),placeholder:"Manual score"}),e.jsx(v,{value:f.confidenceLock,onChange:t=>F(s=>({...s,confidenceLock:t.target.value})),placeholder:"Confidence lock 0-1"})]}),e.jsx("div",{className:"grid gap-2",children:Object.keys(ne).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-[var(--ui-ink-soft)]",children:fe[t]}),e.jsx(v,{value:f.featureWeights[t],onChange:s=>F(c=>({...c,featureWeights:{...c.featureWeights,[t]:s.target.value}}))})]},t))}),e.jsx("div",{className:"grid gap-2 text-sm text-[var(--ui-ink-soft)]",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:f[t],onChange:c=>F(n=>({...n,[t]:c.target.checked}))}),e.jsx("span",{children:s})]},t))}),e.jsx(u,{pending:De.isPending,pendingLabel:"Saving item",onClick:()=>void De.mutateAsync(),children:"Save item model"}),Be?e.jsx(ve,{className:"text-sm text-[var(--primary)]",to:Be,children:"Open linked entity"}):null]}):e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Select a row to inspect or edit it."}),e.jsxs("div",{className:"mt-3 border-t border-[var(--ui-border-subtle)] pt-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Add custom item"}),e.jsxs("div",{className:"mt-3 grid gap-3",children:[e.jsx(v,{value:_.label,onChange:t=>ee(s=>({...s,label:t.target.value})),placeholder:"Custom item label"}),e.jsx(E,{value:_.description,onChange:t=>ee(s=>({...s,description:t.target.value})),className:"min-h-24",placeholder:"What is this preference item?"}),e.jsx(v,{value:_.tags,onChange:t=>ee(s=>({...s,tags:t.target.value})),placeholder:"comma, separated, tags"}),e.jsx(u,{disabled:!_.label.trim(),pending:Se.isPending,pendingLabel:"Creating item",onClick:()=>void Se.mutateAsync({userId:m,domain:C,label:_.label,description:_.description,tags:_.tags.split(",").map(t=>t.trim()).filter(Boolean),featureWeights:ne,queueForCompare:!0}),children:"Create custom item"})]})]})]})]}):null,T==="history"?e.jsxs("div",{className:"grid gap-5 xl:grid-cols-3",children:[e.jsxs(j,{className:"grid gap-3 xl:col-span-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Recent pairwise judgments"}),e.jsx("div",{className:"grid gap-2",children:r.history.judgments.slice(0,12).map(t=>{var n,l,y,X;const s=((l=(n=r.scores.find(Q=>Q.itemId===t.leftItemId))==null?void 0:n.item)==null?void 0:l.label)??t.leftItemId,c=((X=(y=r.scores.find(Q=>Q.itemId===t.rightItemId))==null?void 0:y.item)==null?void 0:X.label)??t.rightItemId;return e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-3 text-sm text-[var(--ui-ink-soft)]",children:[e.jsxs("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:[s," vs ",c]}),e.jsxs("div",{className:"mt-1",children:["Outcome ",t.outcome," · strength"," ",t.strength," ·"," ",new Date(t.createdAt).toLocaleString()]})]},t.id)})})]}),e.jsxs(j,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Signals and snapshots"}),e.jsx("div",{className:"grid gap-2",children:r.history.signals.slice(0,8).map(t=>{var c,n;const s=((n=(c=r.scores.find(l=>l.itemId===t.itemId))==null?void 0:c.item)==null?void 0:n.label)??t.itemId;return e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-2 text-sm text-[var(--ui-ink-soft)]",children:[s," · ",t.signalType," ·"," ",new Date(t.createdAt).toLocaleString()]},t.id)})}),e.jsx("div",{className:"grid gap-2",children:r.history.snapshots.slice(0,5).map(t=>e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-2 text-sm text-[var(--ui-ink-soft)]",children:["Snapshot ",new Date(t.createdAt).toLocaleString()]},t.id))}),e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-3 text-sm text-[var(--ui-ink-soft)]",children:["Stale items: ",r.history.staleItemIds.length," · Flipped items: ",r.history.flippedItemIds.length]})]})]}):null,T==="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:r.contexts.map(t=>e.jsxs(j,{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-[var(--ui-ink-strong)]",children:t.name}),e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:t.description||"No description yet."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.isDefault?e.jsx(I,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:"Default"}):null,e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:t.shareMode}),t.active?null:e.jsx(I,{className:"bg-[var(--ui-warning-soft)] text-[var(--warning)]",children:"Inactive"})]})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-4",children:[e.jsx(v,{value:t.name,onChange:s=>void q.mutateAsync({contextId:t.id,patch:{name:s.target.value}}),placeholder:"Context name"}),e.jsxs("select",{value:t.shareMode,onChange:s=>void q.mutateAsync({contextId:t.id,patch:{shareMode:s.target.value}}),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] 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(v,{value:String(t.decayDays),onChange:s=>void q.mutateAsync({contextId:t.id,patch:{decayDays:Number(s.target.value||90)}}),placeholder:"Decay days"}),e.jsx(u,{variant:"secondary",onClick:()=>A({contextId:t.id,tab:"overview"}),children:"Open context"})]}),e.jsx(E,{value:t.description,onChange:s=>void q.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(u,{variant:"secondary",onClick:()=>void q.mutateAsync({contextId:t.id,patch:{active:!t.active}}),children:t.active?"Deactivate":"Activate"}),t.isDefault?null:e.jsx(u,{variant:"secondary",onClick:()=>void q.mutateAsync({contextId:t.id,patch:{isDefault:!0}}),children:"Make default"})]})]},t.id))}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs(j,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Create context"}),e.jsx(v,{value:L.name,onChange:t=>W(s=>({...s,name:t.target.value})),placeholder:"Context name"}),e.jsx(E,{value:L.description,onChange:t=>W(s=>({...s,description:t.target.value})),className:"min-h-24",placeholder:"What changes in this context?"}),e.jsxs("select",{value:L.shareMode,onChange:t=>W(s=>({...s,shareMode:t.target.value})),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] 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(v,{value:L.decayDays,onChange:t=>W(s=>({...s,decayDays:t.target.value})),placeholder:"Decay days"}),e.jsx(u,{disabled:!L.name.trim(),pending:Ae.isPending,pendingLabel:"Creating context",onClick:()=>void Ae.mutateAsync({userId:m,domain:C,name:L.name,description:L.description,shareMode:L.shareMode,decayDays:Number(L.decayDays||90),active:!0,isDefault:!1}),children:"Create context"})]}),e.jsxs(j,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Merge contexts"}),e.jsxs("select",{value:G,onChange:t=>J(t.target.value),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none",children:[e.jsx("option",{value:"",children:"Source context"}),r.contexts.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]}),e.jsxs("select",{value:O,onChange:t=>be(t.target.value),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none",children:[e.jsx("option",{value:"",children:"Target context"}),r.contexts.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]}),e.jsx(u,{pending:Ee.isPending,pendingLabel:"Merging",disabled:!G||!O||G===O,onClick:()=>void Ee.mutateAsync({sourceContextId:G,targetContextId:O}),children:"Merge into target"})]})]})]}):null,T==="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(j,{className:"grid gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Concept libraries"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",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",r.libraries.totalCatalogs],["Concepts",r.libraries.totalCatalogItems],["Seeded",r.libraries.seededCatalogCount],["Custom",r.libraries.customCatalogCount]].map(([t,s])=>e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:t}),e.jsx("div",{className:"mt-2 font-display text-3xl text-[var(--ui-ink-strong)]",children:s})]},t))}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"size-4 text-[var(--ui-ink-muted)]"}),e.jsx(v,{value:S,onChange:t=>V(t.target.value),placeholder:"Search lists, concepts, tags, and seeded domains"})]})]}),e.jsxs(j,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Create concept list"}),e.jsx(v,{value:H.title,onChange:t=>me(s=>({...s,title:t.target.value})),placeholder:"List title"}),e.jsx(E,{value:H.description,onChange:t=>me(s=>({...s,description:t.target.value})),className:"min-h-24",placeholder:"What should this list help compare?"}),e.jsx(u,{disabled:!H.title.trim(),pending:we.isPending,pendingLabel:"Creating list",onClick:()=>void we.mutateAsync({userId:m,domain:C,title:H.title,description:H.description}),children:"Create list"})]})]}),e.jsx("div",{className:"grid gap-4",children:Ce.map(t=>{const s=rt[t.id]??{label:"",description:"",tags:""},c=t.items.filter(n=>S.trim()?[n.label,n.description,n.tags.join(" ")].join(" ").toLowerCase().includes(le(S)):!0);return e.jsxs(j,{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:ye===t.id?e.jsxs("div",{className:"grid gap-3",children:[e.jsx(v,{value:se.title,onChange:n=>pe(l=>({...l,title:n.target.value}))}),e.jsx(E,{value:se.description,onChange:n=>pe(l=>({...l,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-[var(--ui-ink-strong)]",children:t.title}),e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:t.source}),e.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[t.items.length," items"]})]}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:t.description||"No description yet."})]})}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{variant:"secondary",size:"sm",onClick:()=>void _e(C,t.id),children:"Start from this list"}),ye===t.id?e.jsxs(e.Fragment,{children:[e.jsx(u,{size:"sm",pending:Pe.isPending,pendingLabel:"Saving",onClick:()=>void Pe.mutateAsync({catalogId:t.id,patch:{title:se.title,description:se.description}}),children:"Save"}),e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>xe(null),children:"Cancel"})]}):e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>{xe(t.id),pe({title:t.title,description:t.description})},children:"Edit list"}),e.jsx(u,{variant:"ghost",size:"sm",pending:Fe.isPending,pendingLabel:"Deleting",onClick:()=>void Fe.mutateAsync(t.id),children:"Delete list"})]})]}),e.jsx("div",{className:"grid gap-2",children:c.map(n=>e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-3",children:nt===n.id?e.jsxs("div",{className:"grid gap-3",children:[e.jsx(v,{value:B.label,onChange:l=>ae(y=>({...y,label:l.target.value}))}),e.jsx(E,{value:B.description,onChange:l=>ae(y=>({...y,description:l.target.value})),className:"min-h-20"}),e.jsx(v,{value:B.tags,onChange:l=>ae(y=>({...y,tags:l.target.value})),placeholder:"comma, separated, tags"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{size:"sm",pending:Te.isPending,pendingLabel:"Saving",onClick:()=>void Te.mutateAsync({catalogItemId:n.id,patch:{label:B.label,description:B.description,tags:B.tags.split(",").map(l=>l.trim()).filter(Boolean)}}),children:"Save concept"}),e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>ge(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-[var(--ui-ink-strong)]",children:n.label}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:n.description||"No description yet."}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:n.tags.map(l=>e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:l},`${n.id}-${l}`))})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>{ge(n.id),ae({label:n.label,description:n.description,tags:n.tags.join(", ")})},children:"Edit"}),e.jsxs(u,{variant:"ghost",size:"sm",pending:Me.isPending,pendingLabel:"Deleting",onClick:()=>void Me.mutateAsync(n.id),children:[e.jsx(Ct,{className:"mr-1 size-4"}),"Delete"]})]})]})},n.id))}),e.jsxs("div",{className:"grid gap-3 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--ui-ink-medium)]",children:[e.jsx(It,{className:"size-4"}),"Add concept to ",t.title]}),e.jsx(v,{value:s.label,onChange:n=>te(l=>({...l,[t.id]:{...s,label:n.target.value}})),placeholder:"Concept label"}),e.jsx(E,{value:s.description,onChange:n=>te(l=>({...l,[t.id]:{...s,description:n.target.value}})),className:"min-h-20",placeholder:"Short description"}),e.jsx(v,{value:s.tags,onChange:n=>te(l=>({...l,[t.id]:{...s,tags:n.target.value}})),placeholder:"comma, separated, tags"}),e.jsx(u,{disabled:!s.label.trim(),pending:Le.isPending,pendingLabel:"Adding",onClick:()=>void Le.mutateAsync({catalogId:t.id,label:s.label,description:s.description,tags:s.tags.split(",").map(n=>n.trim()).filter(Boolean),featureWeights:ne}).then(()=>te(n=>({...n,[t.id]:{label:"",description:"",tags:""}}))),children:"Add concept"})]})]},t.id)})})]}):null]}),e.jsx(cs,{state:z,onOpenChange:t=>{t||D(null),M(s=>({...s,open:t}))},error:at,loading:it,workspaceLoading:Ne.isLoading,activeWorkspace:P,conceptSearchQuery:S,onConceptSearchQueryChange:V,filteredCatalogs:Ce,onSelectDomain:t=>void mt(t),onStartCatalogGame:(t,s)=>void _e(t,s),onJudge:(t,s)=>void xt(t,s),onSignal:(t,s)=>void pt(t,s)})]})}export{ks as PreferencesPage};
@@ -1 +1 @@
1
- import{j as a}from"./vendor-Dnkkx2co.js";import{Z as n}from"./index-By3tQxiE.js";const u={active:"Active",paused:"Suspended",completed:"Finished",all:"All"};function d({value:e,counts:t,onChange:s,className:o}){return a.jsx("div",{className:n("flex flex-wrap gap-2",o),children:Object.keys(u).map(r=>{const i=r===e;return a.jsxs("button",{type:"button",onClick:()=>s(r),className:n("inline-flex min-h-10 items-center gap-2 rounded-full border px-4 py-2 text-sm transition",i?"border-[var(--ui-border-strong)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)] shadow-[var(--ui-shadow-soft)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"),children:[a.jsx("span",{children:u[r]}),a.jsx("span",{className:n("rounded-full px-2 py-0.5 text-[11px]",i?"bg-[var(--ui-surface-active)] text-[var(--ui-ink-strong)]":"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]"),children:t[r]})]},r)})})}function v(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 f(e,t){return t==="all"?e:e.filter(s=>s.status===t)}export{d as P,v as b,f};
1
+ import{j as a}from"./vendor-Dnkkx2co.js";import{Z as n}from"./index-QJkjKYzZ.js";const u={active:"Active",paused:"Suspended",completed:"Finished",all:"All"};function d({value:e,counts:t,onChange:s,className:o}){return a.jsx("div",{className:n("flex flex-wrap gap-2",o),children:Object.keys(u).map(r=>{const i=r===e;return a.jsxs("button",{type:"button",onClick:()=>s(r),className:n("inline-flex min-h-10 items-center gap-2 rounded-full border px-4 py-2 text-sm transition",i?"border-[var(--ui-border-strong)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)] shadow-[var(--ui-shadow-soft)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"),children:[a.jsx("span",{children:u[r]}),a.jsx("span",{className:n("rounded-full px-2 py-0.5 text-[11px]",i?"bg-[var(--ui-surface-active)] text-[var(--ui-ink-strong)]":"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]"),children:t[r]})]},r)})})}function v(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 f(e,t){return t==="all"?e:e.filter(s=>s.status===t)}export{d as P,v as b,f};
@@ -1 +1 @@
1
- import{cc as ee,b5 as te,r as k,j as e,aC as j}from"./vendor-Dnkkx2co.js";import{j as se,i as F,k as w}from"./state-vCcAT5Hq.js";import{S as ae}from"./scheduling-rules-editor-DGF-044c.js";import{P as ie,u as re,s as oe,i as v,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 y,V as ue,U,C as u,B as m,c as h,Y as he,az as ge,bQ as we,N as ve}from"./index-By3tQxiE.js";import{O as ye}from"./open-in-graph-button-C263zl5l.js";import{P as fe}from"./project-management-section-nav-DQl0qRWy.js";import{e as be,W as ke}from"./calendar-rules-Cl_xMrBn.js";import{E as Ne}from"./execution-board-Dh41UeKR.js";import{N as H}from"./note-markdown-CepDxj3v.js";import{E as Ie}from"./entity-notes-surface-CBlKc-x-.js";import{P as De}from"./preference-entity-handoff-button-BQzg2J4k.js";import{P as Se}from"./page-hero-5RTqAI88.js";import{g as Pe,a as qe}from"./activity-copy-Bj4h9OcF.js";import{g as Qe}from"./entity-links-DwpxhW2H.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";import"./entity-note-count-link-BX93WYgh.js";import"./floating-action-menu-C5H-Wr2B.js";import"./note-tags-input-BXYaDkOr.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:()=>ve({...I,userIds:N}),enabled:!!o.projectId&&!n}),Y=w({mutationFn:t=>ne(t),onSuccess:async()=>{await Promise.all([v(r),r.invalidateQueries({queryKey:["project-board",o.projectId]})])}}),L=w({mutationFn:ce,onSuccess:async()=>{await Promise.all([v(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([v(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([v(r),r.invalidateQueries({queryKey:["project-board",o.projectId]})]),K("/projects")}}),J=w({mutationFn:t=>pe(t),onSuccess:async()=>{await Promise.all([v(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(y,{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(ye,{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(y,{kind:"project",compact:!0,gradient:!1}),e.jsx(y,{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(y,{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(y,{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-[var(--ui-ink-faint)]",children:a("common.projectDetail.sectionEvidence")}),e.jsx("div",{className:"mt-4 grid min-w-0 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:"min-w-0 max-w-full rounded-[18px] bg-[var(--ui-surface-1)] p-4 transition hover:bg-[var(--ui-surface-hover)]",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"min-w-0 break-words font-medium text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:Pe(t)}),e.jsx(h,{children:t.source})]}),e.jsx("div",{className:"mt-2 min-w-0 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",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};
1
+ import{cc as ee,b5 as te,r as k,j as e,aC as j}from"./vendor-Dnkkx2co.js";import{j as se,i as F,k as w}from"./state-vCcAT5Hq.js";import{S as ae}from"./scheduling-rules-editor-BUGnZJ0g.js";import{P as ie,u as re,s as oe,i as v,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 y,V as ue,U,C as u,B as m,c as h,Y as he,az as ge,bQ as we,N as ve}from"./index-QJkjKYzZ.js";import{O as ye}from"./open-in-graph-button-CMjJZX7G.js";import{P as fe}from"./project-management-section-nav-DRPVS1Eh.js";import{e as be,W as ke}from"./calendar-rules-CRhXqGQu.js";import{E as Ne}from"./execution-board-RRWm2srb.js";import{N as H}from"./note-markdown-CCyyE85h.js";import{E as Ie}from"./entity-notes-surface-CaCjjUaq.js";import{P as De}from"./preference-entity-handoff-button-CKDxCnbl.js";import{P as Se}from"./page-hero-CONuJu5J.js";import{g as Pe,a as qe}from"./activity-copy-Bj4h9OcF.js";import{g as Qe}from"./entity-links-DwpxhW2H.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";import"./entity-note-count-link-ef3ZOpKM.js";import"./floating-action-menu-cKjNsPYD.js";import"./note-tags-input-BS14YXHn.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:()=>ve({...I,userIds:N}),enabled:!!o.projectId&&!n}),Y=w({mutationFn:t=>ne(t),onSuccess:async()=>{await Promise.all([v(r),r.invalidateQueries({queryKey:["project-board",o.projectId]})])}}),L=w({mutationFn:ce,onSuccess:async()=>{await Promise.all([v(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([v(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([v(r),r.invalidateQueries({queryKey:["project-board",o.projectId]})]),K("/projects")}}),J=w({mutationFn:t=>pe(t),onSuccess:async()=>{await Promise.all([v(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(y,{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(ye,{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(y,{kind:"project",compact:!0,gradient:!1}),e.jsx(y,{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(y,{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(y,{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-[var(--ui-ink-faint)]",children:a("common.projectDetail.sectionEvidence")}),e.jsx("div",{className:"mt-4 grid min-w-0 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:"min-w-0 max-w-full rounded-[18px] bg-[var(--ui-surface-1)] p-4 transition hover:bg-[var(--ui-surface-hover)]",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"min-w-0 break-words font-medium text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:Pe(t)}),e.jsx(h,{children:t.source})]}),e.jsx("div",{className:"mt-2 min-w-0 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",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};
@@ -1 +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-Dnkkx2co.js";import{i as re}from"./state-vCcAT5Hq.js";import{u as te,c as j,U as R,b as D,L as ae,E as ie,C as O,B as C,m as A,a as ne,aS as le,Z as F,bR as oe}from"./index-By3tQxiE.js";import{P as ce}from"./project-management-section-nav-DQl0qRWy.js";import{P as de}from"./page-hero-5RTqAI88.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";const _={user:"user:",kind:"kind:"},q=["goal","strategy","project","issue","task","subtask"],T=[...q],L=["active","paused","completed","backlog","focus","in_progress","blocked","done"];function I(r){return r.trim().toLowerCase()}function ue(r){return r.reduce((i,n)=>{if(n.startsWith(_.user))i.userIds.push(n.slice(_.user.length));else if(n.startsWith(_.kind)){const d=n.slice(_.kind.length);(d==="human"||d==="bot")&&i.kinds.push(d)}return i},{userIds:[],kinds:[]})}function he(r,i){return`${i}:${I(r)}`}function ge(r){const i=r.trim();return i.length===0?[]:["any",...q].map(n=>({id:he(i,n),query:i,kind:n}))}function me(r){switch(r){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 P(r,i){const n=r.replace(/\s+/g," ").trim();return n.length===0?i:n}function S(r){const i=(r.children??[]).map(S);if(r.kind==="project")return{...r,children:i,progressPercent:r.progressPercent,progressLabel:r.progressLabel??(typeof r.progressPercent=="number"?`${r.progressPercent}% complete`:null)};if(i.length>0){const d=i.map(g=>g.progressPercent).filter(g=>typeof g=="number");if(d.length>0){const g=Math.round(d.reduce((y,h)=>y+h,0)/d.length);return{...r,children:i,progressPercent:g,progressLabel:`${i.length} child item${i.length===1?"":"s"}`}}}const n=Math.round(me(r.statusLabel)*100);return{...r,children:i,progressPercent:n,progressLabel:r.statusLabel?r.statusLabel.replaceAll("_"," "):null}}function V(r){const{goals:i,strategies:n,projects:d,workItems:g,tagNameById:y}=r,h=new Map,v=new Map,m=new Map;for(const e of g)if(e.parentWorkItemId){const a=h.get(e.parentWorkItemId)??[];a.push(e),h.set(e.parentWorkItemId,a)}else if(e.level==="issue"&&e.projectId){const a=v.get(e.projectId)??[];a.push(e),v.set(e.projectId,a)}else if(e.projectId){const a=m.get(e.projectId)??[];a.push(e),m.set(e.projectId,a)}const b=e=>{var a;return S({id:`${e.level}:${e.id}`,entityId:e.id,kind:e.level,label:e.title,description:P(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,((a=e.user)==null?void 0:a.displayName)??"",...(e.assignees??[]).map(c=>c.displayName),...e.tagIds.map(c=>y.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)})},f=e=>{var c;const a=n.filter(o=>o.targetProjectIds.includes(e.id));return S({id:`project:${e.id}`,entityId:e.id,kind:"project",label:e.title,description:P(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(o=>o.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:[...a.map(o=>{var p;return S({id:`strategy:${o.id}`,entityId:o.id,kind:"strategy",label:o.title,description:P(o.overview||o.endStateDescription,"Execution strategy"),searchText:I([o.title,o.overview,o.endStateDescription,o.status,((p=o.user)==null?void 0:p.displayName)??""].join(" ")),href:`/strategies/${o.id}`,statusLabel:o.status,executionMode:null,goalId:e.goalId,projectId:e.id,tagIds:[],user:o.user,assignees:[],linkedUserIds:o.user?[o.user.id]:[],progressPercent:null,progressLabel:null,children:[]})}),...(v.get(e.id)??[]).map(b),...(m.get(e.id)??[]).map(b)]})};return i.map(e=>{var B,w;const a=d.filter(l=>l.goalId===e.id),c=n.filter(l=>l.targetGoalIds.includes(e.id)),o=new Map(c.map(l=>[l.id,[]])),p=new Set;for(const l of a){const N=c.find(U=>U.targetProjectIds.includes(l.id));N&&((B=o.get(N.id))==null||B.push(l),p.add(l.id))}const M=c.map(l=>{var N;return S({id:`strategy:${l.id}`,entityId:l.id,kind:"strategy",label:l.title,description:P(l.overview||l.endStateDescription,"High-level strategy"),searchText:I([l.title,l.overview,l.endStateDescription,l.status,((N=l.user)==null?void 0:N.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:(o.get(l.id)??[]).map(f)})}),$=a.filter(l=>!p.has(l.id)).map(f);return S({id:`goal:${e.id}`,entityId:e.id,kind:"goal",label:e.title,description:P(e.description,"Strategic goal"),searchText:I([e.title,e.description,e.status,((w=e.user)==null?void 0:w.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:[...M,...$]})})}function K(r){return r.reduce((i,n)=>i+1+K(n.children??[]),0)}function pe(r,i){return r.searchText.includes(I(i.query))&&(i.kind==="any"||i.kind===r.kind)}function G(r,i,n=!1){const{clauses:d,statusFilters:g,ownerUserIds:y,ownerKinds:h,selectedUserIds:v}=i,m=d.length===0||d.some(p=>pe(r,p)),b=g.length===0||r.statusLabel!==null&&g.includes(r.statusLabel),f=y.length===0&&v.length===0?!0:[...y,...v].some(p=>r.linkedUserIds.includes(p)),e=h.length===0||[r.user,...r.assignees].some(p=>p&&h.includes(p.kind)),a=b&&f&&e,c=d.length===0||n||m,o=(r.children??[]).map(p=>G(p,i,n||a&&m)).filter(p=>p!==null);return a&&c||o.length>0?{...r,children:o}:null}function Q(r,i){return r.flatMap(n=>{const d=Q(n.children??[],i);return i.includes(n.kind)?[{...n,children:d}]:d})}function xe(r){switch(r){case"goal":return"bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_76%,var(--ui-ink-strong)_24%)]";case"strategy":return"bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]";case"project":return"bg-[var(--ui-accent-soft)] text-[var(--primary)]";case"issue":return"bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_72%,var(--ui-ink-strong)_28%)]";case"subtask":return"border-[color-mix(in_srgb,var(--tertiary)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-tertiary-soft)] text-[var(--tertiary)]";default:return"bg-[var(--ui-tertiary-soft)] text-[var(--tertiary)]"}}function z(r){switch(r){case"done":case"completed":return"bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]";case"blocked":return"bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]";case"in_progress":case"active":return"bg-[var(--ui-accent-soft)] text-[var(--primary)]";case"focus":return"bg-[var(--ui-tertiary-soft)] text-[var(--tertiary)]";default:return"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]"}}function W(r){return r==="any"?s.jsx(j,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:"Any"}):r==="subtask"?s.jsx(D,{kind:"task",label:"Subtask",compact:!0,gradient:!1,className:"border-[color-mix(in_srgb,var(--tertiary)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-tertiary-soft)] text-[var(--tertiary)]"}):s.jsx(D,{kind:r==="issue"?"issue":r,label:r,compact:!0,gradient:!1})}function be({query:r,onQueryChange:i,clauses:n,onClausesChange:d,resultSummary:g}){const[y,h]=x.useState(!1),[v,m]=x.useState(0),b=x.useMemo(()=>ge(r).filter(a=>!n.some(c=>c.id===a.id)),[n,r]),f=a=>{d([...n,a]),i(""),m(0),h(!1)},e=a=>{d(n.filter(c=>c.id!==a))};return s.jsx("div",{className:"grid gap-3",children:s.jsxs("div",{className:"rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4 shadow-[var(--ui-shadow-soft)] 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-[var(--ui-ink-faint)]",children:"Hierarchy search"}),s.jsxs("div",{className:"mt-2 max-w-3xl text-sm leading-6 text-[var(--ui-ink-soft)]",children:["Build OR clauses like"," ",s.jsx("span",{className:"text-[var(--ui-ink-strong)]",children:'Goal + "MD"'})," ","or"," ",s.jsx("span",{className:"text-[var(--ui-ink-strong)]",children:'Any + "Happy"'}),". Matching ancestors keep their branches visible so you can explore the hierarchy, not lose it."]})]}),n.length>0||r.trim().length>0?s.jsx(C,{variant:"secondary",size:"sm",onClick:()=>{i(""),d([]),m(0),h(!1)},children:"Clear search"}):null]}),s.jsxs("div",{className:"mt-4 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3",children:[n.length>0?s.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:n.map(a=>s.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-2.5 py-1.5",children:[W(a.kind),s.jsxs("span",{className:"max-w-[14rem] truncate text-sm text-[var(--ui-ink-medium)]",children:['"',a.query,'"']}),s.jsx("button",{type:"button",className:"rounded-full text-[var(--ui-ink-soft)] transition hover:text-[var(--ui-ink-strong)]",onClick:()=>e(a.id),"aria-label":`Remove ${a.kind} ${a.query}`,children:s.jsx(ee,{className:"size-3.5"})})]},a.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-[var(--ui-ink-muted)]"}),s.jsx("input",{value:r,onChange:a=>{i(a.target.value),h(!0),m(0)},onFocus:()=>h(!0),onBlur:()=>{window.setTimeout(()=>h(!1),120)},onKeyDown:a=>{if(a.key==="Backspace"&&!r&&n.length>0){e(n[n.length-1].id);return}if(a.key==="ArrowDown"){a.preventDefault(),h(!0),m(c=>b.length===0?0:Math.min(b.length-1,c+1));return}if(a.key==="ArrowUp"){a.preventDefault(),m(c=>Math.max(0,c-1));return}if(a.key==="Escape"){h(!1);return}a.key==="Enter"&&b[v]&&(a.preventDefault(),f(b[v]))},placeholder:'Type text, then pick a clause like Goal + "MD" or Any + "Happy"',className:"min-w-0 flex-1 bg-transparent text-sm text-[var(--ui-ink-strong)] placeholder:text-[var(--ui-ink-muted)] focus:outline-none"})]}),y?s.jsx("div",{className:"absolute top-full z-20 mt-2 w-full rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-popover)] p-2 shadow-[var(--ui-shadow-strong)] backdrop-blur-xl",children:b.length>0?b.map((a,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===v?"bg-[var(--ui-surface-active)] text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"),onMouseEnter:()=>m(c),onMouseDown:o=>o.preventDefault(),onClick:()=>f(a),children:s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[W(a.kind),s.jsxs("span",{className:"truncate text-sm font-medium text-[var(--ui-ink-strong)]",children:['"',a.query,'"']})]}),s.jsxs("div",{className:"mt-1 text-xs leading-5 text-[var(--ui-ink-soft)]",children:["Match ",a.kind==="any"?"any visible hierarchy node":`${a.kind} nodes`," that mention this text."]})]})},a.id)):s.jsx("div",{className:"px-3 py-2.5 text-sm text-[var(--ui-ink-muted)]",children:"Type a word or phrase to create a new OR clause."})}):null]})]}),s.jsx("div",{className:"mt-3 text-sm text-[var(--ui-ink-soft)]",children:g})]})})}function Se(){const r=te(),i=x.useRef(null),[n,d]=x.useState(""),[g,y]=x.useState([]),[h,v]=x.useState([]),[m,b]=x.useState([...L]),[f,e]=x.useState(T),a=re({queryKey:["work-items-hierarchy",...r.selectedUserIds],queryFn:()=>oe({userIds:r.selectedUserIds})}),c=x.useMemo(()=>{const t=r.snapshot.users.filter(u=>u.kind==="bot"),k=r.snapshot.users.filter(u=>u.kind==="human");return[{value:`${_.kind}bot`,label:"Bots",description:`${t.length} bot collaborators`,searchText:`bots bot ai agents assistants ${t.map(u=>`${u.displayName} ${u.handle}`).join(" ")}`,badge:s.jsx(j,{className:"border-[color-mix(in_srgb,var(--info)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]",children:"Bots"}),menuBadge:s.jsx(j,{className:"border-[color-mix(in_srgb,var(--info)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]",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(j,{className:"border-[color-mix(in_srgb,var(--warning)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_76%,var(--ui-ink-strong)_24%)]",children:"Humans"}),menuBadge:s.jsx(j,{className:"border-[color-mix(in_srgb,var(--warning)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_76%,var(--ui-ink-strong)_24%)]",children:"Humans"})},...r.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})}))]},[r.snapshot.users]),o=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-[color-mix(in_srgb,var(--tertiary)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-tertiary-soft)] text-[var(--tertiary)]"}),menuBadge:s.jsx(D,{kind:"task",label:"Subtask",compact:!0,gradient:!1,className:"border-[color-mix(in_srgb,var(--tertiary)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-tertiary-soft)] text-[var(--tertiary)]"})}],[]),p=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(t=>({...t,badge:s.jsx(j,{className:z(t.value),children:t.label}),menuBadge:s.jsx(j,{className:z(t.value),children:t.label})})),[]),M=x.useMemo(()=>new Map(r.snapshot.tags.map(t=>[t.id,t.name])),[r.snapshot.tags]),$=x.useMemo(()=>a.data?V({...a.data,tagNameById:M}):V({goals:r.snapshot.goals,strategies:r.snapshot.strategies,projects:r.snapshot.dashboard.projects,tagNameById:M,workItems:r.snapshot.workItems&&r.snapshot.workItems.length>0?r.snapshot.workItems:r.snapshot.tasks}),[a.data,r.snapshot,M]),B=n.trim().length>0||g.length>0||h.length>0||m.length!==L.length||L.some(t=>!m.includes(t))||f.length!==T.length||T.some(t=>!f.includes(t)),w=x.useMemo(()=>ue(h),[h]),l=x.useMemo(()=>{const t=$.map(k=>G(k,{clauses:g,statusFilters:m,ownerUserIds:w.userIds,ownerKinds:w.kinds,selectedUserIds:r.selectedUserIds})).filter(k=>k!==null);return Q(t,f)},[$,w.kinds,w.userIds,g,m,r.selectedUserIds,f]),N=x.useMemo(()=>K(l),[l]),U=`${g.length>0?`${g.length} OR clause${g.length===1?"":"s"} active`:"Search across the full hierarchy"} · ${N} visible node${N===1?"":"s"}.`;return a.isLoading&&$.length===0?s.jsx(ae,{eyebrow:"Hierarchy",title:"Building Forge hierarchy",description:"Loading goals, strategies, projects, issues, tasks, and subtasks into the compact hierarchy view."}):a.isError&&$.length===0?s.jsx(ie,{eyebrow:"Hierarchy",error:a.error,onRetry:()=>void a.refetch()}):s.jsxs("div",{className:"grid min-w-0 gap-5",children:[s.jsx(ce,{}),s.jsx(de,{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:`${N} visible nodes`}),s.jsxs(O,{className:"min-w-0 overflow-hidden border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3 border-b border-[var(--ui-border-subtle)] px-5 py-4",children:[s.jsxs("div",{children:[s.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Hierarchy controls"}),s.jsx("div",{className:"mt-2 max-w-3xl text-sm leading-6 text-[var(--ui-ink-soft)]",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(C,{variant:"secondary",size:"sm",onClick:()=>{var t,k;return(k=(t=i.current)==null?void 0:t.openAll)==null?void 0:k.call(t)},children:"Expand all"}),s.jsx(C,{variant:"secondary",size:"sm",onClick:()=>{var t,k;return(k=(t=i.current)==null?void 0:t.closeAll)==null?void 0:k.call(t)},children:"Collapse all"}),B?s.jsx(C,{variant:"secondary",size:"sm",onClick:()=>{d(""),y([]),v([]),b([...L]),e(T)},children:"Reset"}):null]})]}),s.jsxs("div",{className:"grid gap-4 px-5 py-5",children:[s.jsx(be,{query:n,onQueryChange:d,clauses:g,onClausesChange:y,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:p,selectedValues:m,onChange:t=>b(t),placeholder:"Visible states",emptyMessage:"No states available.",variant:"action-bar"}),s.jsx(A,{options:o,selectedValues:f,onChange:t=>e(t),placeholder:"Visible levels",emptyMessage:"No hierarchy levels.",className:"min-w-0",variant:"action-bar"}),s.jsx(A,{options:c,selectedValues:h,onChange:v,placeholder:"Filter by human, bot, or collaborator",emptyMessage:"No matching collaborators."})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs(j,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[l.length," top-level nodes"]}),s.jsxs(j,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[N," visible nodes"]}),s.jsx(j,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:f.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(C,{variant:"secondary",onClick:()=>{d(""),y([]),v([]),b([...L]),e(T)},children:"Reset hierarchy filters"})}):s.jsxs(O,{className:"min-w-0 overflow-hidden border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-0",children:[s.jsxs("div",{className:"grid grid-cols-[minmax(0,1.8fr)_auto_auto_auto] gap-3 border-b border-[var(--ui-border-subtle)] px-5 py-3 text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",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:t=>t.children??null,openByDefault:!0,paddingTop:8,paddingBottom:8,disableDrag:!0,className:"text-sm",children:({node:t,style:k})=>{const u=t.data.kind==="subtask"?"task":t.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-[var(--ui-border-subtle)] px-3 py-2 transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]","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:`${t.level*14}px`,background:`color-mix(in srgb, rgb(${H}) 7%, var(--ui-surface-1))`},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-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",onClick:()=>t.toggle(),disabled:t.isLeaf,"aria-label":t.isOpen?`Collapse ${t.data.label}`:`Expand ${t.data.label}`,children:t.isLeaf?s.jsx("span",{className:"size-2 rounded-full bg-[var(--ui-ink-muted)]"}):t.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(j,{className:xe(t.data.kind),children:t.data.kind}),t.data.executionMode?s.jsx(j,{className:t.data.executionMode==="afk"?"bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]":"bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_76%,var(--ui-ink-strong)_24%)]",children:t.data.executionMode.toUpperCase()}):null,s.jsx("div",{className:"truncate text-[13px] font-medium text-[var(--ui-ink-strong)]",children:t.data.label})]}),s.jsx("div",{className:"mt-0.5 truncate text-[11px] leading-5 text-[var(--ui-ink-soft)]",children:t.data.description})]})]}),s.jsx("div",{className:"hidden lg:flex justify-end",children:s.jsx(j,{className:z(t.data.statusLabel),children:t.data.statusLabel?t.data.statusLabel.replaceAll("_"," "):"linked"})}),s.jsxs("div",{className:"hidden xl:flex items-center justify-end gap-2",children:[t.data.user?s.jsx(R,{user:t.data.user,compact:!0}):null,t.data.assignees.length>0?s.jsxs(j,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:["+",t.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-[var(--ui-surface-2)]",children:s.jsx("div",{className:"h-full rounded-full",style:{width:`${t.data.progressPercent??0}%`,background:`linear-gradient(90deg, rgb(${H}), color-mix(in srgb, rgb(${H}) 72%, var(--ui-surface-1)))`}})}),s.jsx("div",{className:"mt-1 text-[11px] text-[var(--ui-ink-faint)]",children:t.data.progressLabel??`${t.data.progressPercent??0}% complete`})]}),t.data.href?s.jsx(J,{to:t.data.href,className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-1.5 text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-medium)] transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",children:"Open"}):s.jsx("span",{className:"w-[3.75rem]"})]})]})})}})})]})]})}export{Se as ProjectManagementHierarchyPage};
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-Dnkkx2co.js";import{i as re}from"./state-vCcAT5Hq.js";import{u as te,c as j,U as R,b as D,L as ae,E as ie,C as O,B as C,m as A,a as ne,aS as le,Z as F,bR as oe}from"./index-QJkjKYzZ.js";import{P as ce}from"./project-management-section-nav-DRPVS1Eh.js";import{P as de}from"./page-hero-CONuJu5J.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";const _={user:"user:",kind:"kind:"},q=["goal","strategy","project","issue","task","subtask"],T=[...q],L=["active","paused","completed","backlog","focus","in_progress","blocked","done"];function I(r){return r.trim().toLowerCase()}function ue(r){return r.reduce((i,n)=>{if(n.startsWith(_.user))i.userIds.push(n.slice(_.user.length));else if(n.startsWith(_.kind)){const d=n.slice(_.kind.length);(d==="human"||d==="bot")&&i.kinds.push(d)}return i},{userIds:[],kinds:[]})}function he(r,i){return`${i}:${I(r)}`}function ge(r){const i=r.trim();return i.length===0?[]:["any",...q].map(n=>({id:he(i,n),query:i,kind:n}))}function me(r){switch(r){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 P(r,i){const n=r.replace(/\s+/g," ").trim();return n.length===0?i:n}function S(r){const i=(r.children??[]).map(S);if(r.kind==="project")return{...r,children:i,progressPercent:r.progressPercent,progressLabel:r.progressLabel??(typeof r.progressPercent=="number"?`${r.progressPercent}% complete`:null)};if(i.length>0){const d=i.map(g=>g.progressPercent).filter(g=>typeof g=="number");if(d.length>0){const g=Math.round(d.reduce((y,h)=>y+h,0)/d.length);return{...r,children:i,progressPercent:g,progressLabel:`${i.length} child item${i.length===1?"":"s"}`}}}const n=Math.round(me(r.statusLabel)*100);return{...r,children:i,progressPercent:n,progressLabel:r.statusLabel?r.statusLabel.replaceAll("_"," "):null}}function V(r){const{goals:i,strategies:n,projects:d,workItems:g,tagNameById:y}=r,h=new Map,v=new Map,m=new Map;for(const e of g)if(e.parentWorkItemId){const a=h.get(e.parentWorkItemId)??[];a.push(e),h.set(e.parentWorkItemId,a)}else if(e.level==="issue"&&e.projectId){const a=v.get(e.projectId)??[];a.push(e),v.set(e.projectId,a)}else if(e.projectId){const a=m.get(e.projectId)??[];a.push(e),m.set(e.projectId,a)}const b=e=>{var a;return S({id:`${e.level}:${e.id}`,entityId:e.id,kind:e.level,label:e.title,description:P(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,((a=e.user)==null?void 0:a.displayName)??"",...(e.assignees??[]).map(c=>c.displayName),...e.tagIds.map(c=>y.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)})},f=e=>{var c;const a=n.filter(o=>o.targetProjectIds.includes(e.id));return S({id:`project:${e.id}`,entityId:e.id,kind:"project",label:e.title,description:P(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(o=>o.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:[...a.map(o=>{var p;return S({id:`strategy:${o.id}`,entityId:o.id,kind:"strategy",label:o.title,description:P(o.overview||o.endStateDescription,"Execution strategy"),searchText:I([o.title,o.overview,o.endStateDescription,o.status,((p=o.user)==null?void 0:p.displayName)??""].join(" ")),href:`/strategies/${o.id}`,statusLabel:o.status,executionMode:null,goalId:e.goalId,projectId:e.id,tagIds:[],user:o.user,assignees:[],linkedUserIds:o.user?[o.user.id]:[],progressPercent:null,progressLabel:null,children:[]})}),...(v.get(e.id)??[]).map(b),...(m.get(e.id)??[]).map(b)]})};return i.map(e=>{var B,w;const a=d.filter(l=>l.goalId===e.id),c=n.filter(l=>l.targetGoalIds.includes(e.id)),o=new Map(c.map(l=>[l.id,[]])),p=new Set;for(const l of a){const N=c.find(U=>U.targetProjectIds.includes(l.id));N&&((B=o.get(N.id))==null||B.push(l),p.add(l.id))}const M=c.map(l=>{var N;return S({id:`strategy:${l.id}`,entityId:l.id,kind:"strategy",label:l.title,description:P(l.overview||l.endStateDescription,"High-level strategy"),searchText:I([l.title,l.overview,l.endStateDescription,l.status,((N=l.user)==null?void 0:N.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:(o.get(l.id)??[]).map(f)})}),$=a.filter(l=>!p.has(l.id)).map(f);return S({id:`goal:${e.id}`,entityId:e.id,kind:"goal",label:e.title,description:P(e.description,"Strategic goal"),searchText:I([e.title,e.description,e.status,((w=e.user)==null?void 0:w.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:[...M,...$]})})}function K(r){return r.reduce((i,n)=>i+1+K(n.children??[]),0)}function pe(r,i){return r.searchText.includes(I(i.query))&&(i.kind==="any"||i.kind===r.kind)}function G(r,i,n=!1){const{clauses:d,statusFilters:g,ownerUserIds:y,ownerKinds:h,selectedUserIds:v}=i,m=d.length===0||d.some(p=>pe(r,p)),b=g.length===0||r.statusLabel!==null&&g.includes(r.statusLabel),f=y.length===0&&v.length===0?!0:[...y,...v].some(p=>r.linkedUserIds.includes(p)),e=h.length===0||[r.user,...r.assignees].some(p=>p&&h.includes(p.kind)),a=b&&f&&e,c=d.length===0||n||m,o=(r.children??[]).map(p=>G(p,i,n||a&&m)).filter(p=>p!==null);return a&&c||o.length>0?{...r,children:o}:null}function Q(r,i){return r.flatMap(n=>{const d=Q(n.children??[],i);return i.includes(n.kind)?[{...n,children:d}]:d})}function xe(r){switch(r){case"goal":return"bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_76%,var(--ui-ink-strong)_24%)]";case"strategy":return"bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]";case"project":return"bg-[var(--ui-accent-soft)] text-[var(--primary)]";case"issue":return"bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_72%,var(--ui-ink-strong)_28%)]";case"subtask":return"border-[color-mix(in_srgb,var(--tertiary)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-tertiary-soft)] text-[var(--tertiary)]";default:return"bg-[var(--ui-tertiary-soft)] text-[var(--tertiary)]"}}function z(r){switch(r){case"done":case"completed":return"bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]";case"blocked":return"bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]";case"in_progress":case"active":return"bg-[var(--ui-accent-soft)] text-[var(--primary)]";case"focus":return"bg-[var(--ui-tertiary-soft)] text-[var(--tertiary)]";default:return"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]"}}function W(r){return r==="any"?s.jsx(j,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:"Any"}):r==="subtask"?s.jsx(D,{kind:"task",label:"Subtask",compact:!0,gradient:!1,className:"border-[color-mix(in_srgb,var(--tertiary)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-tertiary-soft)] text-[var(--tertiary)]"}):s.jsx(D,{kind:r==="issue"?"issue":r,label:r,compact:!0,gradient:!1})}function be({query:r,onQueryChange:i,clauses:n,onClausesChange:d,resultSummary:g}){const[y,h]=x.useState(!1),[v,m]=x.useState(0),b=x.useMemo(()=>ge(r).filter(a=>!n.some(c=>c.id===a.id)),[n,r]),f=a=>{d([...n,a]),i(""),m(0),h(!1)},e=a=>{d(n.filter(c=>c.id!==a))};return s.jsx("div",{className:"grid gap-3",children:s.jsxs("div",{className:"rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4 shadow-[var(--ui-shadow-soft)] 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-[var(--ui-ink-faint)]",children:"Hierarchy search"}),s.jsxs("div",{className:"mt-2 max-w-3xl text-sm leading-6 text-[var(--ui-ink-soft)]",children:["Build OR clauses like"," ",s.jsx("span",{className:"text-[var(--ui-ink-strong)]",children:'Goal + "MD"'})," ","or"," ",s.jsx("span",{className:"text-[var(--ui-ink-strong)]",children:'Any + "Happy"'}),". Matching ancestors keep their branches visible so you can explore the hierarchy, not lose it."]})]}),n.length>0||r.trim().length>0?s.jsx(C,{variant:"secondary",size:"sm",onClick:()=>{i(""),d([]),m(0),h(!1)},children:"Clear search"}):null]}),s.jsxs("div",{className:"mt-4 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3",children:[n.length>0?s.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:n.map(a=>s.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-2.5 py-1.5",children:[W(a.kind),s.jsxs("span",{className:"max-w-[14rem] truncate text-sm text-[var(--ui-ink-medium)]",children:['"',a.query,'"']}),s.jsx("button",{type:"button",className:"rounded-full text-[var(--ui-ink-soft)] transition hover:text-[var(--ui-ink-strong)]",onClick:()=>e(a.id),"aria-label":`Remove ${a.kind} ${a.query}`,children:s.jsx(ee,{className:"size-3.5"})})]},a.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-[var(--ui-ink-muted)]"}),s.jsx("input",{value:r,onChange:a=>{i(a.target.value),h(!0),m(0)},onFocus:()=>h(!0),onBlur:()=>{window.setTimeout(()=>h(!1),120)},onKeyDown:a=>{if(a.key==="Backspace"&&!r&&n.length>0){e(n[n.length-1].id);return}if(a.key==="ArrowDown"){a.preventDefault(),h(!0),m(c=>b.length===0?0:Math.min(b.length-1,c+1));return}if(a.key==="ArrowUp"){a.preventDefault(),m(c=>Math.max(0,c-1));return}if(a.key==="Escape"){h(!1);return}a.key==="Enter"&&b[v]&&(a.preventDefault(),f(b[v]))},placeholder:'Type text, then pick a clause like Goal + "MD" or Any + "Happy"',className:"min-w-0 flex-1 bg-transparent text-sm text-[var(--ui-ink-strong)] placeholder:text-[var(--ui-ink-muted)] focus:outline-none"})]}),y?s.jsx("div",{className:"absolute top-full z-20 mt-2 w-full rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-popover)] p-2 shadow-[var(--ui-shadow-strong)] backdrop-blur-xl",children:b.length>0?b.map((a,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===v?"bg-[var(--ui-surface-active)] text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"),onMouseEnter:()=>m(c),onMouseDown:o=>o.preventDefault(),onClick:()=>f(a),children:s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[W(a.kind),s.jsxs("span",{className:"truncate text-sm font-medium text-[var(--ui-ink-strong)]",children:['"',a.query,'"']})]}),s.jsxs("div",{className:"mt-1 text-xs leading-5 text-[var(--ui-ink-soft)]",children:["Match ",a.kind==="any"?"any visible hierarchy node":`${a.kind} nodes`," that mention this text."]})]})},a.id)):s.jsx("div",{className:"px-3 py-2.5 text-sm text-[var(--ui-ink-muted)]",children:"Type a word or phrase to create a new OR clause."})}):null]})]}),s.jsx("div",{className:"mt-3 text-sm text-[var(--ui-ink-soft)]",children:g})]})})}function Se(){const r=te(),i=x.useRef(null),[n,d]=x.useState(""),[g,y]=x.useState([]),[h,v]=x.useState([]),[m,b]=x.useState([...L]),[f,e]=x.useState(T),a=re({queryKey:["work-items-hierarchy",...r.selectedUserIds],queryFn:()=>oe({userIds:r.selectedUserIds})}),c=x.useMemo(()=>{const t=r.snapshot.users.filter(u=>u.kind==="bot"),k=r.snapshot.users.filter(u=>u.kind==="human");return[{value:`${_.kind}bot`,label:"Bots",description:`${t.length} bot collaborators`,searchText:`bots bot ai agents assistants ${t.map(u=>`${u.displayName} ${u.handle}`).join(" ")}`,badge:s.jsx(j,{className:"border-[color-mix(in_srgb,var(--info)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]",children:"Bots"}),menuBadge:s.jsx(j,{className:"border-[color-mix(in_srgb,var(--info)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]",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(j,{className:"border-[color-mix(in_srgb,var(--warning)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_76%,var(--ui-ink-strong)_24%)]",children:"Humans"}),menuBadge:s.jsx(j,{className:"border-[color-mix(in_srgb,var(--warning)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_76%,var(--ui-ink-strong)_24%)]",children:"Humans"})},...r.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})}))]},[r.snapshot.users]),o=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-[color-mix(in_srgb,var(--tertiary)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-tertiary-soft)] text-[var(--tertiary)]"}),menuBadge:s.jsx(D,{kind:"task",label:"Subtask",compact:!0,gradient:!1,className:"border-[color-mix(in_srgb,var(--tertiary)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-tertiary-soft)] text-[var(--tertiary)]"})}],[]),p=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(t=>({...t,badge:s.jsx(j,{className:z(t.value),children:t.label}),menuBadge:s.jsx(j,{className:z(t.value),children:t.label})})),[]),M=x.useMemo(()=>new Map(r.snapshot.tags.map(t=>[t.id,t.name])),[r.snapshot.tags]),$=x.useMemo(()=>a.data?V({...a.data,tagNameById:M}):V({goals:r.snapshot.goals,strategies:r.snapshot.strategies,projects:r.snapshot.dashboard.projects,tagNameById:M,workItems:r.snapshot.workItems&&r.snapshot.workItems.length>0?r.snapshot.workItems:r.snapshot.tasks}),[a.data,r.snapshot,M]),B=n.trim().length>0||g.length>0||h.length>0||m.length!==L.length||L.some(t=>!m.includes(t))||f.length!==T.length||T.some(t=>!f.includes(t)),w=x.useMemo(()=>ue(h),[h]),l=x.useMemo(()=>{const t=$.map(k=>G(k,{clauses:g,statusFilters:m,ownerUserIds:w.userIds,ownerKinds:w.kinds,selectedUserIds:r.selectedUserIds})).filter(k=>k!==null);return Q(t,f)},[$,w.kinds,w.userIds,g,m,r.selectedUserIds,f]),N=x.useMemo(()=>K(l),[l]),U=`${g.length>0?`${g.length} OR clause${g.length===1?"":"s"} active`:"Search across the full hierarchy"} · ${N} visible node${N===1?"":"s"}.`;return a.isLoading&&$.length===0?s.jsx(ae,{eyebrow:"Hierarchy",title:"Building Forge hierarchy",description:"Loading goals, strategies, projects, issues, tasks, and subtasks into the compact hierarchy view."}):a.isError&&$.length===0?s.jsx(ie,{eyebrow:"Hierarchy",error:a.error,onRetry:()=>void a.refetch()}):s.jsxs("div",{className:"grid min-w-0 gap-5",children:[s.jsx(ce,{}),s.jsx(de,{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:`${N} visible nodes`}),s.jsxs(O,{className:"min-w-0 overflow-hidden border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3 border-b border-[var(--ui-border-subtle)] px-5 py-4",children:[s.jsxs("div",{children:[s.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Hierarchy controls"}),s.jsx("div",{className:"mt-2 max-w-3xl text-sm leading-6 text-[var(--ui-ink-soft)]",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(C,{variant:"secondary",size:"sm",onClick:()=>{var t,k;return(k=(t=i.current)==null?void 0:t.openAll)==null?void 0:k.call(t)},children:"Expand all"}),s.jsx(C,{variant:"secondary",size:"sm",onClick:()=>{var t,k;return(k=(t=i.current)==null?void 0:t.closeAll)==null?void 0:k.call(t)},children:"Collapse all"}),B?s.jsx(C,{variant:"secondary",size:"sm",onClick:()=>{d(""),y([]),v([]),b([...L]),e(T)},children:"Reset"}):null]})]}),s.jsxs("div",{className:"grid gap-4 px-5 py-5",children:[s.jsx(be,{query:n,onQueryChange:d,clauses:g,onClausesChange:y,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:p,selectedValues:m,onChange:t=>b(t),placeholder:"Visible states",emptyMessage:"No states available.",variant:"action-bar"}),s.jsx(A,{options:o,selectedValues:f,onChange:t=>e(t),placeholder:"Visible levels",emptyMessage:"No hierarchy levels.",className:"min-w-0",variant:"action-bar"}),s.jsx(A,{options:c,selectedValues:h,onChange:v,placeholder:"Filter by human, bot, or collaborator",emptyMessage:"No matching collaborators."})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs(j,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[l.length," top-level nodes"]}),s.jsxs(j,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[N," visible nodes"]}),s.jsx(j,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:f.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(C,{variant:"secondary",onClick:()=>{d(""),y([]),v([]),b([...L]),e(T)},children:"Reset hierarchy filters"})}):s.jsxs(O,{className:"min-w-0 overflow-hidden border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-0",children:[s.jsxs("div",{className:"grid grid-cols-[minmax(0,1.8fr)_auto_auto_auto] gap-3 border-b border-[var(--ui-border-subtle)] px-5 py-3 text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",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:t=>t.children??null,openByDefault:!0,paddingTop:8,paddingBottom:8,disableDrag:!0,className:"text-sm",children:({node:t,style:k})=>{const u=t.data.kind==="subtask"?"task":t.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-[var(--ui-border-subtle)] px-3 py-2 transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]","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:`${t.level*14}px`,background:`color-mix(in srgb, rgb(${H}) 7%, var(--ui-surface-1))`},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-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",onClick:()=>t.toggle(),disabled:t.isLeaf,"aria-label":t.isOpen?`Collapse ${t.data.label}`:`Expand ${t.data.label}`,children:t.isLeaf?s.jsx("span",{className:"size-2 rounded-full bg-[var(--ui-ink-muted)]"}):t.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(j,{className:xe(t.data.kind),children:t.data.kind}),t.data.executionMode?s.jsx(j,{className:t.data.executionMode==="afk"?"bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]":"bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_76%,var(--ui-ink-strong)_24%)]",children:t.data.executionMode.toUpperCase()}):null,s.jsx("div",{className:"truncate text-[13px] font-medium text-[var(--ui-ink-strong)]",children:t.data.label})]}),s.jsx("div",{className:"mt-0.5 truncate text-[11px] leading-5 text-[var(--ui-ink-soft)]",children:t.data.description})]})]}),s.jsx("div",{className:"hidden lg:flex justify-end",children:s.jsx(j,{className:z(t.data.statusLabel),children:t.data.statusLabel?t.data.statusLabel.replaceAll("_"," "):"linked"})}),s.jsxs("div",{className:"hidden xl:flex items-center justify-end gap-2",children:[t.data.user?s.jsx(R,{user:t.data.user,compact:!0}):null,t.data.assignees.length>0?s.jsxs(j,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:["+",t.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-[var(--ui-surface-2)]",children:s.jsx("div",{className:"h-full rounded-full",style:{width:`${t.data.progressPercent??0}%`,background:`linear-gradient(90deg, rgb(${H}), color-mix(in srgb, rgb(${H}) 72%, var(--ui-surface-1)))`}})}),s.jsx("div",{className:"mt-1 text-[11px] text-[var(--ui-ink-faint)]",children:t.data.progressLabel??`${t.data.progressPercent??0}% complete`})]}),t.data.href?s.jsx(J,{to:t.data.href,className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-1.5 text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-medium)] transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",children:"Open"}):s.jsx("span",{className:"w-[3.75rem]"})]})]})})}})})]})]})}export{Se as ProjectManagementHierarchyPage};
@@ -1 +1 @@
1
- import{aJ as v,r as l,cB as b,cC as f,aU as p,j as e,bB as m,F as h,aK as g}from"./vendor-Dnkkx2co.js";import{C as j,Z as c}from"./index-By3tQxiE.js";const i=[{to:"/projects",label:"Projects",icon:b},{to:"/kanban",label:"Board",icon:f},{to:"/projects/hierarchy",label:"Hierarchy",icon:p}];function d(t,s){return s==="/projects"?t==="/projects"||/^\/projects\/[^/]+$/.test(t):t===s||t.startsWith(`${s}/`)}function y({className:t}){const s=v(),[o,n]=l.useState(!1),u=l.useMemo(()=>[...i].sort((r,a)=>a.to.length-r.to.length).find(r=>d(s.pathname,r.to))??i[0],[s.pathname]);return l.useEffect(()=>{if(!o)return;const r=document.body.style.overflow,a=x=>{x.key==="Escape"&&n(!1)};return document.body.style.overflow="hidden",window.addEventListener("keydown",a),()=>{document.body.style.overflow=r,window.removeEventListener("keydown",a)}},[o]),e.jsxs(e.Fragment,{children:[e.jsxs(j,{className:c("overflow-hidden bg-[var(--card-gradient)] p-2",t),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(r=>e.jsxs(m,{to:r.to,end:r.to==="/projects",className:({isActive:a})=>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",a||d(s.pathname,r.to)?"border border-[color-mix(in_srgb,var(--info)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]":"border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"),children:[e.jsx(r.icon,{className:"size-3.5"}),e.jsx("span",{children:r.label})]},r.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-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3.5 py-2.5 text-left shadow-[var(--ui-shadow-soft)] transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]",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-[color-mix(in_srgb,var(--info)_24%,var(--ui-border-subtle)_76%)] bg-[var(--ui-info-soft)]",children:e.jsx(u.icon,{className:"size-4 text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]"})}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-[10px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Project management"}),e.jsx("span",{className:"mt-0.5 block truncate text-sm font-medium text-[var(--ui-ink-strong)]",children:u.label})]})]})})})]}),o&&typeof document<"u"?h.createPortal(e.jsxs("div",{className:"lg:hidden",children:[e.jsx("div",{className:"surface-overlay fixed inset-0 z-50 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:"surface-modal-panel 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 shadow-[var(--ui-shadow-strong)]",children:[e.jsx("div",{className:"shrink-0 border-b border-[var(--ui-border-subtle)] 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-[var(--ui-ink-muted)]",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-[var(--ui-ink-strong)]",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-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",onClick:()=>n(!1),children:e.jsx(g,{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(r=>{const a=d(s.pathname,r.to);return e.jsx(m,{to:r.to,end:r.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-[var(--ui-ink-strong)]",a?"border-[color-mix(in_srgb,var(--info)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]"),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-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]",children:e.jsx(r.icon,{className:"size-4"})}),e.jsx("span",{className:"text-sm font-medium",children:r.label})]})},r.to)})})})]})})]}),document.body):null]})}export{y as P};
1
+ import{aJ as v,r as l,cB as b,cC as f,aU as p,j as e,bB as m,F as h,aK as g}from"./vendor-Dnkkx2co.js";import{C as j,Z as c}from"./index-QJkjKYzZ.js";const i=[{to:"/projects",label:"Projects",icon:b},{to:"/kanban",label:"Board",icon:f},{to:"/projects/hierarchy",label:"Hierarchy",icon:p}];function d(t,s){return s==="/projects"?t==="/projects"||/^\/projects\/[^/]+$/.test(t):t===s||t.startsWith(`${s}/`)}function y({className:t}){const s=v(),[o,n]=l.useState(!1),u=l.useMemo(()=>[...i].sort((r,a)=>a.to.length-r.to.length).find(r=>d(s.pathname,r.to))??i[0],[s.pathname]);return l.useEffect(()=>{if(!o)return;const r=document.body.style.overflow,a=x=>{x.key==="Escape"&&n(!1)};return document.body.style.overflow="hidden",window.addEventListener("keydown",a),()=>{document.body.style.overflow=r,window.removeEventListener("keydown",a)}},[o]),e.jsxs(e.Fragment,{children:[e.jsxs(j,{className:c("overflow-hidden bg-[var(--card-gradient)] p-2",t),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(r=>e.jsxs(m,{to:r.to,end:r.to==="/projects",className:({isActive:a})=>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",a||d(s.pathname,r.to)?"border border-[color-mix(in_srgb,var(--info)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]":"border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"),children:[e.jsx(r.icon,{className:"size-3.5"}),e.jsx("span",{children:r.label})]},r.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-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3.5 py-2.5 text-left shadow-[var(--ui-shadow-soft)] transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]",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-[color-mix(in_srgb,var(--info)_24%,var(--ui-border-subtle)_76%)] bg-[var(--ui-info-soft)]",children:e.jsx(u.icon,{className:"size-4 text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]"})}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-[10px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Project management"}),e.jsx("span",{className:"mt-0.5 block truncate text-sm font-medium text-[var(--ui-ink-strong)]",children:u.label})]})]})})})]}),o&&typeof document<"u"?h.createPortal(e.jsxs("div",{className:"lg:hidden",children:[e.jsx("div",{className:"surface-overlay fixed inset-0 z-50 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:"surface-modal-panel 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 shadow-[var(--ui-shadow-strong)]",children:[e.jsx("div",{className:"shrink-0 border-b border-[var(--ui-border-subtle)] 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-[var(--ui-ink-muted)]",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-[var(--ui-ink-strong)]",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-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",onClick:()=>n(!1),children:e.jsx(g,{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(r=>{const a=d(s.pathname,r.to);return e.jsx(m,{to:r.to,end:r.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-[var(--ui-ink-strong)]",a?"border-[color-mix(in_srgb,var(--info)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]"),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-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]",children:e.jsx(r.icon,{className:"size-4"})}),e.jsx("span",{className:"text-sm font-medium",children:r.label})]})},r.to)})})})]})})]}),document.body):null]})}export{y as P};