forge-openclaw-plugin 0.3.6 → 0.3.9

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 (126) hide show
  1. package/dist/assets/{action-bar-CsDQF9d4.js → action-bar-BFjWjRIM.js} +1 -1
  2. package/dist/assets/{activity-page-CACf1Sd5.js → activity-page-D-6yBWuZ.js} +1 -1
  3. package/dist/assets/{ai-surface-workspace-Vn5fqCAT.js → ai-surface-workspace-BEfo9bRO.js} +1 -1
  4. package/dist/assets/{atlas-panel-GdK1oyxo.js → atlas-panel-BfMyJXxQ.js} +1 -1
  5. package/dist/assets/{calendar-page-CcVGbvfY.js → calendar-page-D4tQNJ2V.js} +1 -1
  6. package/dist/assets/{calendar-rules-Dlq0KT93.js → calendar-rules-C-6O_uGU.js} +1 -1
  7. package/dist/assets/{calendar-week-toolbar-BVFb1_2G.js → calendar-week-toolbar-_NzeKsYx.js} +1 -1
  8. package/dist/assets/{companion-sync-lab-page-Dgvtdc4i.js → companion-sync-lab-page-D1Oqsf6M.js} +1 -1
  9. package/dist/assets/{daily-metrics-dashboard-ChQVbNJI.js → daily-metrics-dashboard-DtE3pVOl.js} +1 -1
  10. package/dist/assets/{define-workbench-box-DWAqqjvH.js → define-workbench-box-D-32C8nM.js} +1 -1
  11. package/dist/assets/{entity-link-multiselect-Do5DTju7.js → entity-link-multiselect-DcCvkesQ.js} +1 -1
  12. package/dist/assets/{entity-note-count-link-CV3eOv66.js → entity-note-count-link-Cjsk5oT2.js} +1 -1
  13. package/dist/assets/{entity-notes-surface-CiUgAVl7.js → entity-notes-surface-DQQPLjxd.js} +1 -1
  14. package/dist/assets/{execution-board-ClaXVQ0H.js → execution-board-agWQbN-y.js} +1 -1
  15. package/dist/assets/{faceted-token-search-DoSsb7qT.js → faceted-token-search-DldM3-ru.js} +1 -1
  16. package/dist/assets/{flagship-signal-deck-B2s7TrIN.js → flagship-signal-deck-BlLYW9Kz.js} +1 -1
  17. package/dist/assets/{floating-action-menu-DGkHCmvI.js → floating-action-menu-D9-psbha.js} +1 -1
  18. package/dist/assets/{generic-node-view-CgLkbts-.js → generic-node-view-CcepUVhP.js} +1 -1
  19. package/dist/assets/{goal-detail-page-JRcEYpeA.js → goal-detail-page-DP1n5-Hk.js} +1 -1
  20. package/dist/assets/{goal-dialog-6R2uYWPQ.js → goal-dialog-Oxx8WqbZ.js} +1 -1
  21. package/dist/assets/{goals-page-CYestXkp.js → goals-page-CUt1a4Y2.js} +1 -1
  22. package/dist/assets/{habits-page-B27lnyKu.js → habits-page-5REbWAlo.js} +1 -1
  23. package/dist/assets/{health-boxes-CeqSGyZ3.js → health-boxes-sHNML3tm.js} +1 -1
  24. package/dist/assets/{index-DGYIFHgo.js → index-CQ5r7ZUz.js} +2 -2
  25. package/dist/assets/index-FxgNSuZX.css +1 -0
  26. package/dist/assets/{inline-note-fields-CJ9ukqFp.js → inline-note-fields-Bql_KfR9.js} +1 -1
  27. package/dist/assets/{insight-flow-dialog-BgaJRYGX.js → insight-flow-dialog-CN-CMSB7.js} +1 -1
  28. package/dist/assets/{insights-page-Dc5bilGE.js → insights-page-B1u6ONtQ.js} +1 -1
  29. package/dist/assets/{kanban-boxes-qIwmQlRq.js → kanban-boxes-DB1kuUlY.js} +1 -1
  30. package/dist/assets/{kanban-page-BGnVLHeN.js → kanban-page-BBW9_vMu.js} +1 -1
  31. package/dist/assets/{knowledge-graph-page-B7IsVVO_.js → knowledge-graph-page-CoJaydZb.js} +1 -1
  32. package/dist/assets/{life-force-page-B5N4DknK.js → life-force-page-DBYbA1GF.js} +1 -1
  33. package/dist/assets/{life-force-workspace-Da-dmoRX.js → life-force-workspace-BiD9xOEt.js} +1 -1
  34. package/dist/assets/{metric-tile-BVuj7mc3.js → metric-tile-CuP9DOYm.js} +1 -1
  35. package/dist/assets/{movement-boxes-BZrdIh8b.js → movement-boxes-DZg_qPPg.js} +1 -1
  36. package/dist/assets/{movement-page-CY2XLgp_.js → movement-page-CmwsQGR_.js} +1 -1
  37. package/dist/assets/{note-markdown-BZHBOkEd.js → note-markdown-B82ncnFt.js} +1 -1
  38. package/dist/assets/{note-tags-input-DucocvNH.js → note-tags-input-C_x5WdK5.js} +1 -1
  39. package/dist/assets/{notes-boxes-DAQ6KBkJ.js → notes-boxes-BEFlp9yd.js} +1 -1
  40. package/dist/assets/{notes-page-CSCfdDJl.js → notes-page-B6Vl-GPf.js} +1 -1
  41. package/dist/assets/{open-in-graph-button-ObO3m8yd.js → open-in-graph-button-C-bJekoH.js} +1 -1
  42. package/dist/assets/{orbit-map-Bteg-ola.js → orbit-map-DHeTM15g.js} +1 -1
  43. package/dist/assets/{overview-page-ckfN_sLZ.js → overview-page-BRWje1F9.js} +1 -1
  44. package/dist/assets/{page-hero-BkrRTu-t.js → page-hero-8bITsx_x.js} +1 -1
  45. package/dist/assets/{pill-cluster-COzv8VgR.js → pill-cluster-XQjm-wPc.js} +1 -1
  46. package/dist/assets/{preference-entity-handoff-button-BpVAeFmY.js → preference-entity-handoff-button-DwYF_5i3.js} +1 -1
  47. package/dist/assets/{preferences-page-DseOh9AP.js → preferences-page-C7DBPpNb.js} +1 -1
  48. package/dist/assets/{project-collections-C7yU5PSi.js → project-collections-mtxanSMf.js} +1 -1
  49. package/dist/assets/{project-detail-page-Crt46y_7.js → project-detail-page-BT87Goqc.js} +1 -1
  50. package/dist/assets/{project-dialog-YYxtlqg8.js → project-dialog-DnZe757y.js} +1 -1
  51. package/dist/assets/{project-management-hierarchy-page-DnojKHzy.js → project-management-hierarchy-page-B3R2lNFI.js} +1 -1
  52. package/dist/assets/{project-management-section-nav-Ctjd348W.js → project-management-section-nav-DyBWxHbe.js} +1 -1
  53. package/dist/assets/{projects-boxes-D8lLFGBC.js → projects-boxes-CxZj3P29.js} +1 -1
  54. package/dist/assets/{projects-page-CV_2em8d.js → projects-page-Bec11c0x.js} +1 -1
  55. package/dist/assets/{psyche-behaviors-page-CYCNk0rz.js → psyche-behaviors-page-DWRpYvl1.js} +1 -1
  56. package/dist/assets/{psyche-flashcards-page-DwmjBixN.js → psyche-flashcards-page-CX4rcsXZ.js} +1 -1
  57. package/dist/assets/{psyche-goal-map-page-CdMhyBKh.js → psyche-goal-map-page-Y6b3lCvV.js} +1 -1
  58. package/dist/assets/{psyche-graph-BcrZcJrq.js → psyche-graph-CQuCWKIp.js} +1 -1
  59. package/dist/assets/{psyche-metrics-page-D5bX1mNX.js → psyche-metrics-page-DadDJOnm.js} +1 -1
  60. package/dist/assets/{psyche-mode-guide-page-BmX9EOOB.js → psyche-mode-guide-page-B1nz0uCg.js} +1 -1
  61. package/dist/assets/{psyche-modes-page-CTHFDyLE.js → psyche-modes-page-i3uSuhKA.js} +1 -1
  62. package/dist/assets/{psyche-page-DRR3Fjv-.js → psyche-page-Y_s-BE2m.js} +1 -1
  63. package/dist/assets/{psyche-patterns-page-BAS38xYf.js → psyche-patterns-page-DaaOLIlN.js} +1 -1
  64. package/dist/assets/{psyche-questionnaire-builder-page-DpSi-zg3.js → psyche-questionnaire-builder-page-CuF7rXOv.js} +1 -1
  65. package/dist/assets/{psyche-questionnaire-detail-page-BcXIiV4E.js → psyche-questionnaire-detail-page-BfFEMkRY.js} +1 -1
  66. package/dist/assets/{psyche-questionnaire-run-detail-page-DvccwzWO.js → psyche-questionnaire-run-detail-page-BoQTvd7Q.js} +1 -1
  67. package/dist/assets/{psyche-questionnaire-run-page-vcyon8IZ.js → psyche-questionnaire-run-page-C0qKiNZN.js} +1 -1
  68. package/dist/assets/{psyche-questionnaires-page-B0DDTner.js → psyche-questionnaires-page-B6hfD448.js} +1 -1
  69. package/dist/assets/{psyche-report-detail-page-BgBA3xIO.js → psyche-report-detail-page-BlFL8moM.js} +1 -1
  70. package/dist/assets/{psyche-reports-page-Ce1vEEqW.js → psyche-reports-page-DAAcYENp.js} +1 -1
  71. package/dist/assets/{psyche-schemas-beliefs-page-D-IHHohY.js → psyche-schemas-beliefs-page-CsxKSrKM.js} +1 -1
  72. package/dist/assets/{psyche-screen-time-page-DOKW3m8B.js → psyche-screen-time-page-n4b0e58x.js} +1 -1
  73. package/dist/assets/{psyche-self-observation-page-j7Sk6Ns1.js → psyche-self-observation-page-BaxEQ2-3.js} +1 -1
  74. package/dist/assets/{psyche-values-page-NfzdWUyb.js → psyche-values-page-DTv5NMSU.js} +1 -1
  75. package/dist/assets/{question-flow-dialog-CLHVmFON.js → question-flow-dialog-CskCt5NZ.js} +1 -1
  76. package/dist/assets/{report-chain-fields-C9MuyBha.js → report-chain-fields-D132-EMh.js} +1 -1
  77. package/dist/assets/{rewards-page-CVxOBP6m.js → rewards-page-C533lVP-.js} +1 -1
  78. package/dist/assets/{scheduling-rules-editor-BmbOHH_R.js → scheduling-rules-editor-CDpontGp.js} +1 -1
  79. package/dist/assets/{schema-badge-BAiS_OAp.js → schema-badge-B3DiMnjB.js} +1 -1
  80. package/dist/assets/{schemas-B0AXfuOr.js → schemas-CH1_ngUX.js} +1 -1
  81. package/dist/assets/{select-menu-Bl5MILOj.js → select-menu-BOF-k4Ln.js} +1 -1
  82. package/dist/assets/{settings-agents-page-BIRP02mt.js → settings-agents-page-B5OQtlZX.js} +1 -1
  83. package/dist/assets/{settings-bin-page-DxJKeM28.js → settings-bin-page-D_bk3Kcu.js} +1 -1
  84. package/dist/assets/{settings-calendar-page-aMBtwvO_.js → settings-calendar-page-PuSj9_kM.js} +1 -1
  85. package/dist/assets/{settings-data-page-nHNergsh.js → settings-data-page-EwFMaeq6.js} +1 -1
  86. package/dist/assets/{settings-logs-page-CFotPoFy.js → settings-logs-page-BKkse0DX.js} +1 -1
  87. package/dist/assets/{settings-mobile-page-Bf_1D-bN.js → settings-mobile-page-BrIVmdeB.js} +1 -1
  88. package/dist/assets/{settings-models-page-BbFNmnik.js → settings-models-page-Mg84D_0K.js} +1 -1
  89. package/dist/assets/{settings-page-CalbNbcg.js → settings-page-D-kul92f.js} +1 -1
  90. package/dist/assets/{settings-rewards-page-ByDfCzP5.js → settings-rewards-page-waNyCcX_.js} +1 -1
  91. package/dist/assets/{settings-section-nav-x_JXfzL9.js → settings-section-nav-BmJWnrYk.js} +1 -1
  92. package/dist/assets/{settings-users-page-N1jl9hWV.js → settings-users-page-DBgC6y56.js} +1 -1
  93. package/dist/assets/{settings-wiki-page-Bn2Qr94L.js → settings-wiki-page-CM0te9dI.js} +1 -1
  94. package/dist/assets/sleep-page-C_krRE59.js +1 -0
  95. package/dist/assets/{sports-page-DbK4yGrR.js → sports-page-eg5Rfc_E.js} +1 -1
  96. package/dist/assets/{strategies-page-AUBlFCZ9.js → strategies-page-D4AqvFNW.js} +1 -1
  97. package/dist/assets/{strategy-detail-page-DCF8mVaL.js → strategy-detail-page-BlYVkXaW.js} +1 -1
  98. package/dist/assets/{strategy-dialog-50xKlqcz.js → strategy-dialog-FO9Oa0dB.js} +1 -1
  99. package/dist/assets/{surface-BjT1dIAF.js → surface-MVeeZGKB.js} +1 -1
  100. package/dist/assets/{task-detail-page-Dsll2LCX.js → task-detail-page-Dy-aRyY6.js} +1 -1
  101. package/dist/assets/{task-dialog-BfPkbIPE.js → task-dialog-DrA9pba7.js} +1 -1
  102. package/dist/assets/{timebox-planning-dialog-BTKUS6Jj.js → timebox-planning-dialog-C_gnfxFx.js} +1 -1
  103. package/dist/assets/{today-boxes-BPi9bDHM.js → today-boxes-BFOws_iC.js} +1 -1
  104. package/dist/assets/{today-page-BSXSA-Ts.js → today-page-BoPj6a6q.js} +1 -1
  105. package/dist/assets/{training-load-page-BD0s8-Zm.js → training-load-page-DGU40Zfl.js} +1 -1
  106. package/dist/assets/{user-badge-ap1PvOxd.js → user-badge-CZWtYeMw.js} +1 -1
  107. package/dist/assets/{utility-widgets-Cq508sqJ.js → utility-widgets-B3wWGxQc.js} +1 -1
  108. package/dist/assets/{vitals-page-BnXk8OzN.js → vitals-page-BXRZEP_8.js} +1 -1
  109. package/dist/assets/{weekly-review-page-CnmSGnEC.js → weekly-review-page-D5cebA5x.js} +1 -1
  110. package/dist/assets/{weight-loss-page-Bn6lAXNf.js → weight-loss-page-BuUdFh9z.js} +1 -1
  111. package/dist/assets/{wiki-article-markdown-BDnkdNDC.js → wiki-article-markdown-CvaCjg_t.js} +1 -1
  112. package/dist/assets/{wiki-editor-page-CHEETB0G.js → wiki-editor-page-Dco79SLY.js} +1 -1
  113. package/dist/assets/{wiki-ingest-history-page-CisvtAzm.js → wiki-ingest-history-page-uvKRkRDF.js} +1 -1
  114. package/dist/assets/{wiki-ingest-modal-C2faIjzj.js → wiki-ingest-modal-BW6AJPea.js} +1 -1
  115. package/dist/assets/{wiki-page-CELe_6qL.js → wiki-page-BIL5zMqv.js} +1 -1
  116. package/dist/assets/{workbench-flow-page-JBVim3L0.js → workbench-flow-page-Dx_nq8R_.js} +1 -1
  117. package/dist/assets/{workbench-page-q7Z3sQtz.js → workbench-page-BJnt_Zzf.js} +1 -1
  118. package/dist/assets/{workout-detail-page-9I_3DPYU.js → workout-detail-page-CKgqyB-y.js} +1 -1
  119. package/dist/index.html +2 -2
  120. package/dist/server/server/src/app.js +4 -0
  121. package/dist/server/server/src/health.js +44 -3
  122. package/dist/server/server/src/openapi.js +31 -0
  123. package/openclaw.plugin.json +1 -1
  124. package/package.json +1 -1
  125. package/dist/assets/index-UzsVTD1W.css +0 -1
  126. package/dist/assets/sleep-page-DyU635jb.js +0 -1
@@ -1 +1 @@
1
- import{j as e}from"./vendor-BwL6m4SE.js";import{B as d,I as c,T as u}from"./index-DGYIFHgo.js";const m={contentMarkdown:"",author:""};function h(){return{...m}}function v({notes:t,onChange:s,entityLabel:o}){return e.jsxs("div",{className:"grid gap-3",children:[t.length===0?e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-4 text-sm leading-6 text-[var(--ui-ink-muted)]",children:["Add an optional Markdown note if this ",o," should start with context, evidence, or a clear handoff summary."]}):null,t.map((l,r)=>e.jsxs("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:["Creation note ",r+1]}),e.jsx(d,{type:"button",variant:"ghost",size:"sm",onClick:()=>s(t.filter((n,a)=>a!==r)),children:"Remove"})]}),e.jsxs("div",{className:"mt-4 grid gap-4",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-muted)]",children:"Author"}),e.jsx(c,{value:l.author,placeholder:"Albert",onChange:n=>s(t.map((a,i)=>i===r?{...a,author:n.target.value}:a))})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-muted)]",children:"Markdown note"}),e.jsx(u,{className:"min-h-28",value:l.contentMarkdown,placeholder:"Capture why this was created now, what changed, or what the next person should know.",onChange:n=>s(t.map((a,i)=>i===r?{...a,contentMarkdown:n.target.value}:a))})]})]})]},r)),e.jsx("div",{children:e.jsx(d,{type:"button",variant:"secondary",onClick:()=>s([...t,h()]),children:"Add creation note"})})]})}export{v as I};
1
+ import{j as e}from"./vendor-BwL6m4SE.js";import{B as d,I as c,T as u}from"./index-CQ5r7ZUz.js";const m={contentMarkdown:"",author:""};function h(){return{...m}}function v({notes:t,onChange:s,entityLabel:o}){return e.jsxs("div",{className:"grid gap-3",children:[t.length===0?e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-4 text-sm leading-6 text-[var(--ui-ink-muted)]",children:["Add an optional Markdown note if this ",o," should start with context, evidence, or a clear handoff summary."]}):null,t.map((l,r)=>e.jsxs("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:["Creation note ",r+1]}),e.jsx(d,{type:"button",variant:"ghost",size:"sm",onClick:()=>s(t.filter((n,a)=>a!==r)),children:"Remove"})]}),e.jsxs("div",{className:"mt-4 grid gap-4",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-muted)]",children:"Author"}),e.jsx(c,{value:l.author,placeholder:"Albert",onChange:n=>s(t.map((a,i)=>i===r?{...a,author:n.target.value}:a))})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-muted)]",children:"Markdown note"}),e.jsx(u,{className:"min-h-28",value:l.contentMarkdown,placeholder:"Capture why this was created now, what changed, or what the next person should know.",onChange:n=>s(t.map((a,i)=>i===r?{...a,contentMarkdown:n.target.value}:a))})]})]})]},r)),e.jsx("div",{children:e.jsx(d,{type:"button",variant:"secondary",onClick:()=>s([...t,h()]),children:"Add creation note"})})]})}export{v as I};
@@ -1 +1 @@
1
- import{r as c,j as t}from"./vendor-BwL6m4SE.js";import{Q as N,F as m,a as u}from"./question-flow-dialog-CLHVmFON.js";import{I as v,b as f,a3 as x,T as p}from"./index-DGYIFHgo.js";import{c as W}from"./schemas-B0AXfuOr.js";function w(e,a){return{originType:(e==null?void 0:e.originType)??"user",originAgentId:(e==null?void 0:e.originAgentId)??"",originLabel:(e==null?void 0:e.originLabel)??"",entityType:(a==null?void 0:a.entityType)??(e==null?void 0:e.entityType)??"",entityId:(a==null?void 0:a.entityId)??(e==null?void 0:e.entityId)??"",timeframeLabel:(e==null?void 0:e.timeframeLabel)??"This week",title:(e==null?void 0:e.title)??"",summary:(e==null?void 0:e.summary)??"",recommendation:(e==null?void 0:e.recommendation)??"",rationale:(e==null?void 0:e.rationale)??"",confidence:(e==null?void 0:e.confidence)??.72,ctaLabel:(e==null?void 0:e.ctaLabel)??"Review insight",targetKind:(a==null?void 0:a.entityType)??(e==null?void 0:e.entityType)??"general"}}function U({open:e,onOpenChange:a,title:j="Store insight",description:T="Capture a clear observation, its recommendation, and where it belongs without dropping into a raw admin form.",eyebrow:I="Insight",pending:L=!1,submitLabel:C="Store insight",initialValue:g,lockedEntity:h,entityCandidates:d=[],onSubmit:F}){const[s,l]=c.useState(()=>w(g,h)),[S,i]=c.useState(null);c.useEffect(()=>{e&&(l(w(g,h)),i(null))},[g,h,e]);const b=c.useMemo(()=>{const o=new Set(["general"]);return d.forEach(n=>o.add(n.entityType)),h&&o.add(h.entityType),Array.from(o)},[d,h]),y=d.filter(o=>o.entityType===s.targetKind),K=[{id:"focus",eyebrow:"Focus",title:"Name the insight and place it in the right context",description:"Start with the main observation, then decide whether this belongs to a specific entity or should stay general.",render:(o,n)=>t.jsxs(t.Fragment,{children:[t.jsx(m,{label:"Insight title",description:"Write the main idea as a clear headline.",labelHelp:"The title should sound like the recommendation or realization you want to remember, not like an internal database field.",children:t.jsx(v,{value:o.title,onChange:r=>n({title:r.target.value}),placeholder:"Weekly review needs a tighter end ritual"})}),t.jsx(m,{label:"Timeframe",description:"Keep the horizon short and readable.",children:t.jsx(v,{value:o.timeframeLabel,onChange:r=>n({timeframeLabel:r.target.value}),placeholder:"This week"})}),t.jsx(m,{label:"Where should this insight live?",description:"Use a specific entity when the insight is about one goal, project, task, or report. Keep it general when it applies to the wider system.",children:h?t.jsxs("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[t.jsx(f,{kind:h.kind,label:h.label}),h.description?t.jsx(x,{className:"mt-2",children:h.description}):null]}):t.jsxs(t.Fragment,{children:[t.jsx(u,{value:o.targetKind,onChange:r=>n({targetKind:r,entityType:r==="general"?"":r,entityId:""}),options:b.map(r=>({value:r,label:r==="general"?"General insight":r==="trigger_report"?"Report":r.charAt(0).toUpperCase()+r.slice(1),description:r==="general"?"Store it in the broader insight feed.":`Attach it to a specific ${r==="trigger_report"?"report":r}.`})),columns:b.length>=3?3:2}),o.targetKind!=="general"?y.length>0?t.jsx("div",{className:"mt-4 grid gap-3 md:grid-cols-2",children:y.map(r=>{const A=o.entityType===r.entityType&&o.entityId===r.entityId;return t.jsxs("button",{type:"button",className:`rounded-[22px] border px-4 py-4 text-left transition ${A?"border-[color-mix(in_srgb,var(--primary)_34%,var(--ui-border-subtle)_66%)] 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)]"}`,onClick:()=>n({entityType:r.entityType,entityId:r.entityId}),children:[t.jsx(f,{kind:r.kind,label:r.label,compact:!0}),r.description?t.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-faint)]",children:r.description}):null]},`${r.entityType}:${r.entityId}`)})}):t.jsxs(x,{className:"mt-4",children:["No"," ",o.targetKind==="trigger_report"?"reports":`${o.targetKind}s`," ","are ready to attach here yet."]}):null]})})]})},{id:"observation",eyebrow:"Observation",title:"Capture what you are seeing clearly",description:"Keep the summary plain and useful. Add the why only if it helps the next action make sense.",render:(o,n)=>t.jsxs(t.Fragment,{children:[t.jsx(m,{label:"Summary",description:"Describe the pattern, problem, or opportunity in plain language.",labelHelp:"Write what is actually happening, not a slogan and not a long essay.",children:t.jsx(p,{value:o.summary,onChange:r=>n({summary:r.target.value}),placeholder:"The weekly review loses energy because the close-out is vague, so finished work never turns into clear next moves."})}),t.jsx(m,{label:"Why this matters",description:"Optional context that helps explain the recommendation.",children:t.jsx(p,{value:o.rationale,onChange:r=>n({rationale:r.target.value}),placeholder:"When the close-out is loose, important wins disappear from memory and the next week starts without momentum."})})]})},{id:"move",eyebrow:"Next move",title:"Turn the insight into a recommendation",description:"Finish with the recommendation you want the user or agent to actually act on.",render:(o,n)=>t.jsxs(t.Fragment,{children:[t.jsx(m,{label:"Recommendation",description:"Write the concrete move this insight points toward.",labelHelp:"A recommendation should be actionable. If the user read only this line, they should know what to do next.",children:t.jsx(p,{value:o.recommendation,onChange:r=>n({recommendation:r.target.value}),placeholder:"Add a fixed five-minute close-out block that turns finished tasks into one sentence of evidence and one next move."})}),t.jsx(m,{label:"Confidence",description:"Choose how strongly this recommendation holds up right now.",children:t.jsx(u,{value:String(o.confidence),onChange:r=>n({confidence:Number(r)}),options:[{value:"0.55",label:"Low",description:"Useful hunch, still early."},{value:"0.72",label:"Medium",description:"Solid pattern, worth acting on."},{value:"0.88",label:"High",description:"Clear enough to trust strongly."}],columns:3})})]})}];return t.jsx(N,{open:e,onOpenChange:a,eyebrow:I,title:j,description:T,value:s,onChange:l,draftPersistenceKey:"insights.flow",steps:K,submitLabel:C,pending:L,error:S,onSubmit:async()=>{i(null);const o=W.safeParse({originType:s.originType,originAgentId:s.originAgentId,originLabel:s.originLabel,entityType:s.targetKind==="general"?"":s.entityType,entityId:s.targetKind==="general"?"":s.entityId,timeframeLabel:s.timeframeLabel,title:s.title,summary:s.summary,recommendation:s.recommendation,rationale:s.rationale,confidence:s.confidence,ctaLabel:s.ctaLabel});if(!o.success){i("This insight still needs a title, a summary, and a recommendation before it can be stored.");return}try{await F(o.data),a(!1)}catch(n){i(n instanceof Error?n.message:"Unable to store this insight right now.")}}})}export{U as I};
1
+ import{r as c,j as t}from"./vendor-BwL6m4SE.js";import{Q as N,F as m,a as u}from"./question-flow-dialog-CskCt5NZ.js";import{I as v,b as f,a3 as x,T as p}from"./index-CQ5r7ZUz.js";import{c as W}from"./schemas-CH1_ngUX.js";function w(e,a){return{originType:(e==null?void 0:e.originType)??"user",originAgentId:(e==null?void 0:e.originAgentId)??"",originLabel:(e==null?void 0:e.originLabel)??"",entityType:(a==null?void 0:a.entityType)??(e==null?void 0:e.entityType)??"",entityId:(a==null?void 0:a.entityId)??(e==null?void 0:e.entityId)??"",timeframeLabel:(e==null?void 0:e.timeframeLabel)??"This week",title:(e==null?void 0:e.title)??"",summary:(e==null?void 0:e.summary)??"",recommendation:(e==null?void 0:e.recommendation)??"",rationale:(e==null?void 0:e.rationale)??"",confidence:(e==null?void 0:e.confidence)??.72,ctaLabel:(e==null?void 0:e.ctaLabel)??"Review insight",targetKind:(a==null?void 0:a.entityType)??(e==null?void 0:e.entityType)??"general"}}function U({open:e,onOpenChange:a,title:j="Store insight",description:T="Capture a clear observation, its recommendation, and where it belongs without dropping into a raw admin form.",eyebrow:I="Insight",pending:L=!1,submitLabel:C="Store insight",initialValue:g,lockedEntity:h,entityCandidates:d=[],onSubmit:F}){const[s,l]=c.useState(()=>w(g,h)),[S,i]=c.useState(null);c.useEffect(()=>{e&&(l(w(g,h)),i(null))},[g,h,e]);const b=c.useMemo(()=>{const o=new Set(["general"]);return d.forEach(n=>o.add(n.entityType)),h&&o.add(h.entityType),Array.from(o)},[d,h]),y=d.filter(o=>o.entityType===s.targetKind),K=[{id:"focus",eyebrow:"Focus",title:"Name the insight and place it in the right context",description:"Start with the main observation, then decide whether this belongs to a specific entity or should stay general.",render:(o,n)=>t.jsxs(t.Fragment,{children:[t.jsx(m,{label:"Insight title",description:"Write the main idea as a clear headline.",labelHelp:"The title should sound like the recommendation or realization you want to remember, not like an internal database field.",children:t.jsx(v,{value:o.title,onChange:r=>n({title:r.target.value}),placeholder:"Weekly review needs a tighter end ritual"})}),t.jsx(m,{label:"Timeframe",description:"Keep the horizon short and readable.",children:t.jsx(v,{value:o.timeframeLabel,onChange:r=>n({timeframeLabel:r.target.value}),placeholder:"This week"})}),t.jsx(m,{label:"Where should this insight live?",description:"Use a specific entity when the insight is about one goal, project, task, or report. Keep it general when it applies to the wider system.",children:h?t.jsxs("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[t.jsx(f,{kind:h.kind,label:h.label}),h.description?t.jsx(x,{className:"mt-2",children:h.description}):null]}):t.jsxs(t.Fragment,{children:[t.jsx(u,{value:o.targetKind,onChange:r=>n({targetKind:r,entityType:r==="general"?"":r,entityId:""}),options:b.map(r=>({value:r,label:r==="general"?"General insight":r==="trigger_report"?"Report":r.charAt(0).toUpperCase()+r.slice(1),description:r==="general"?"Store it in the broader insight feed.":`Attach it to a specific ${r==="trigger_report"?"report":r}.`})),columns:b.length>=3?3:2}),o.targetKind!=="general"?y.length>0?t.jsx("div",{className:"mt-4 grid gap-3 md:grid-cols-2",children:y.map(r=>{const A=o.entityType===r.entityType&&o.entityId===r.entityId;return t.jsxs("button",{type:"button",className:`rounded-[22px] border px-4 py-4 text-left transition ${A?"border-[color-mix(in_srgb,var(--primary)_34%,var(--ui-border-subtle)_66%)] 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)]"}`,onClick:()=>n({entityType:r.entityType,entityId:r.entityId}),children:[t.jsx(f,{kind:r.kind,label:r.label,compact:!0}),r.description?t.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-faint)]",children:r.description}):null]},`${r.entityType}:${r.entityId}`)})}):t.jsxs(x,{className:"mt-4",children:["No"," ",o.targetKind==="trigger_report"?"reports":`${o.targetKind}s`," ","are ready to attach here yet."]}):null]})})]})},{id:"observation",eyebrow:"Observation",title:"Capture what you are seeing clearly",description:"Keep the summary plain and useful. Add the why only if it helps the next action make sense.",render:(o,n)=>t.jsxs(t.Fragment,{children:[t.jsx(m,{label:"Summary",description:"Describe the pattern, problem, or opportunity in plain language.",labelHelp:"Write what is actually happening, not a slogan and not a long essay.",children:t.jsx(p,{value:o.summary,onChange:r=>n({summary:r.target.value}),placeholder:"The weekly review loses energy because the close-out is vague, so finished work never turns into clear next moves."})}),t.jsx(m,{label:"Why this matters",description:"Optional context that helps explain the recommendation.",children:t.jsx(p,{value:o.rationale,onChange:r=>n({rationale:r.target.value}),placeholder:"When the close-out is loose, important wins disappear from memory and the next week starts without momentum."})})]})},{id:"move",eyebrow:"Next move",title:"Turn the insight into a recommendation",description:"Finish with the recommendation you want the user or agent to actually act on.",render:(o,n)=>t.jsxs(t.Fragment,{children:[t.jsx(m,{label:"Recommendation",description:"Write the concrete move this insight points toward.",labelHelp:"A recommendation should be actionable. If the user read only this line, they should know what to do next.",children:t.jsx(p,{value:o.recommendation,onChange:r=>n({recommendation:r.target.value}),placeholder:"Add a fixed five-minute close-out block that turns finished tasks into one sentence of evidence and one next move."})}),t.jsx(m,{label:"Confidence",description:"Choose how strongly this recommendation holds up right now.",children:t.jsx(u,{value:String(o.confidence),onChange:r=>n({confidence:Number(r)}),options:[{value:"0.55",label:"Low",description:"Useful hunch, still early."},{value:"0.72",label:"Medium",description:"Solid pattern, worth acting on."},{value:"0.88",label:"High",description:"Clear enough to trust strongly."}],columns:3})})]})}];return t.jsx(N,{open:e,onOpenChange:a,eyebrow:I,title:j,description:T,value:s,onChange:l,draftPersistenceKey:"insights.flow",steps:K,submitLabel:C,pending:L,error:S,onSubmit:async()=>{i(null);const o=W.safeParse({originType:s.originType,originAgentId:s.originAgentId,originLabel:s.originLabel,entityType:s.targetKind==="general"?"":s.entityType,entityId:s.targetKind==="general"?"":s.entityId,timeframeLabel:s.timeframeLabel,title:s.title,summary:s.summary,recommendation:s.recommendation,rationale:s.rationale,confidence:s.confidence,ctaLabel:s.ctaLabel});if(!o.success){i("This insight still needs a title, a summary, and a recommendation before it can be stored.");return}try{await F(o.data),a(!1)}catch(n){i(n instanceof Error?n.message:"Unable to store this insight right now.")}}})}export{U as I};
@@ -1,4 +1,4 @@
1
- import{r as k,j as e,b6 as re}from"./vendor-BwL6m4SE.js";import{j as ie,i as ne,k as $}from"./state-Bpe5dF3T.js";import{Q as se,F as y,a as ae}from"./question-flow-dialog-CLHVmFON.js";import{I as D,T as L,b as oe,c as U,a3 as le,d as de,L as ce,e as ue,B as E,C as A,a4 as G,k as B,a5 as W,a6 as pe,i as me,a7 as ge,a8 as he,a9 as fe,aa as xe,ab as ye,ac as ke,ad as je}from"./index-DGYIFHgo.js";import{q as be,p as ve,g as we}from"./schemas-B0AXfuOr.js";import{I as Ie}from"./insight-flow-dialog-BgaJRYGX.js";import{P as Ne}from"./page-hero-BkrRTu-t.js";import{U as Te}from"./user-badge-ap1PvOxd.js";import"./ui-B9TWEtCx.js";import"./motion-DcgUnXhY.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";const Ce={title:"",description:"",level:"task",owner:"Albert",userId:null,assigneeUserIds:[],goalId:"",projectId:"",parentWorkItemId:null,priority:"medium",status:"focus",effort:"deep",energy:"steady",dueDate:"",points:60,plannedDurationSeconds:86400,actionCostBand:"standard",aiInstructions:"",executionMode:null,acceptanceCriteria:[],blockerLinks:[],completionReport:null,gitRefs:[],tagIds:[],notes:[]},Se={goalId:"",title:"",description:"",status:"active",workflowStatus:"backlog",userId:null,assigneeUserIds:[],targetPoints:240,themeColor:"#c0c1ff",productRequirementsDocument:"",notes:[]},Pe={title:"",description:"",horizon:"year",status:"active",userId:null,targetPoints:400,themeColor:"#c8a46b",tagIds:[],notes:[]},Ee=["goal","project","task","tag","note","insight","psyche_value","behavior_pattern","behavior","belief_entry","mode_profile","mode_guide_session","flashcard","event_type","emotion_definition","trigger_report"];function Ae(t){return t!==null&&Ee.includes(t)}function R(t,a,o=96){const s=t.trim()||a.trim();return s.length<=o?s:`${s.slice(0,o-1).trimEnd()}…`}function Fe(t){return[t.summary.trim(),t.rationale.trim()?`Why it matters: ${t.rationale.trim()}`:""].filter(Boolean).join(`
1
+ import{r as k,j as e,b6 as re}from"./vendor-BwL6m4SE.js";import{j as ie,i as ne,k as $}from"./state-Bpe5dF3T.js";import{Q as se,F as y,a as ae}from"./question-flow-dialog-CskCt5NZ.js";import{I as D,T as L,b as oe,c as U,a3 as le,d as de,L as ce,e as ue,B as E,C as A,a4 as G,k as B,a5 as W,a6 as pe,i as me,a7 as ge,a8 as he,a9 as fe,aa as xe,ab as ye,ac as ke,ad as je}from"./index-CQ5r7ZUz.js";import{q as be,p as ve,g as we}from"./schemas-CH1_ngUX.js";import{I as Ie}from"./insight-flow-dialog-CN-CMSB7.js";import{P as Ne}from"./page-hero-8bITsx_x.js";import{U as Te}from"./user-badge-CZWtYeMw.js";import"./ui-B9TWEtCx.js";import"./motion-DcgUnXhY.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";const Ce={title:"",description:"",level:"task",owner:"Albert",userId:null,assigneeUserIds:[],goalId:"",projectId:"",parentWorkItemId:null,priority:"medium",status:"focus",effort:"deep",energy:"steady",dueDate:"",points:60,plannedDurationSeconds:86400,actionCostBand:"standard",aiInstructions:"",executionMode:null,acceptanceCriteria:[],blockerLinks:[],completionReport:null,gitRefs:[],tagIds:[],notes:[]},Se={goalId:"",title:"",description:"",status:"active",workflowStatus:"backlog",userId:null,assigneeUserIds:[],targetPoints:240,themeColor:"#c0c1ff",productRequirementsDocument:"",notes:[]},Pe={title:"",description:"",horizon:"year",status:"active",userId:null,targetPoints:400,themeColor:"#c8a46b",tagIds:[],notes:[]},Ee=["goal","project","task","tag","note","insight","psyche_value","behavior_pattern","behavior","belief_entry","mode_profile","mode_guide_session","flashcard","event_type","emotion_definition","trigger_report"];function Ae(t){return t!==null&&Ee.includes(t)}function R(t,a,o=96){const s=t.trim()||a.trim();return s.length<=o?s:`${s.slice(0,o-1).trimEnd()}…`}function Fe(t){return[t.summary.trim(),t.rationale.trim()?`Why it matters: ${t.rationale.trim()}`:""].filter(Boolean).join(`
2
2
 
3
3
  `)}function O(t){return!Ae(t.entityType)||!t.entityId?null:{entityType:t.entityType,entityId:t.entityId,anchorKey:null}}function ee(t,a,o){var s,l;return t.entityType==="goal"&&t.entityId?t.entityId:t.entityType==="project"&&t.entityId?((s=a.find(d=>d.id===t.entityId))==null?void 0:s.goalId)??"":t.entityType==="task"&&t.entityId?((l=o.find(d=>d.id===t.entityId))==null?void 0:l.goalId)??"":""}function _e(t,a){var o;return t.entityType==="project"&&t.entityId?t.entityId:t.entityType==="task"&&t.entityId?((o=a.find(s=>s.id===t.entityId))==null?void 0:o.projectId)??"":""}function te(t,a,o){const s=[];return o.length>0&&s.push("task"),a.length>0&&s.push("project"),s.push("goal"),O(t)&&s.push("note"),s}function Me(t,a,o){const s=te(t,a,o);return s.includes("task")&&(t.entityType==="task"||t.entityType==="project")?"task":s.includes("project")&&t.entityType==="goal"?"project":s[0]??"goal"}function $e(t,a,o){var j,b,v;const s=ee(t,a,o),d=_e(t,o)||(s?((j=a.find(h=>h.goalId===s))==null?void 0:j.id)??"":"")||((b=a[0])==null?void 0:b.id)||"",p=d?((v=a.find(h=>h.id===d))==null?void 0:v.goalId)??s:s;return{...Ce,title:R(t.recommendation,t.title),description:Fe(t),goalId:p,projectId:d}}function De(t,a,o,s){var p;const d=ee(t,o,s)||((p=a[0])==null?void 0:p.id)||"";return{...Se,goalId:d,title:R(t.title,t.recommendation),description:`${t.summary.trim()}
4
4
 
@@ -1 +1 @@
1
- import{j as c}from"./vendor-BwL6m4SE.js";import{c as s,a as n,b as d,d as m,e as p,f as i,g as r,h as b}from"./generic-node-view-CgLkbts-.js";import{d as o}from"./define-workbench-box-DWAqqjvH.js";function u({children:a}){return c.jsx(c.Fragment,{children:a})}const e=m({itemKind:"task",itemLabel:"Task",defaultEntityTypes:["task"],defaultLimit:24}),t=p(),f=o(u,{id:"surface:kanban-index:summary",surfaceId:"kanban-index",routePath:"/kanban",title:"Kanban summary",icon:"kanban",description:"Board summary and execution posture.",category:"Execution",tags:["kanban","summary"],inputs:e,params:t,output:[n({label:"Kanban summary",description:"Summary of board posture and execution pressure."})],tools:[],NodeView:s({title:"Kanban summary",description:"Board summary and execution posture.",inputs:e,params:t,output:[n({label:"Kanban summary",description:"Summary of board posture and execution pressure."})],tools:[]}),execute:a=>i(a,{query:"",entityTypes:["task"],limit:24})}),x=o(u,{id:"surface:kanban-index:filters",surfaceId:"kanban-index",routePath:"/kanban",title:"Kanban filters",icon:"filter",description:"Goal, owner, and tag filters for board scope.",category:"Execution",tags:["kanban","filters"],inputs:e,params:t,output:[n({label:"Filter summary",description:"Summary of the current Kanban filters and scope."})],tools:[r("Search Forge entities by query and entity types.")],NodeView:s({title:"Kanban filters",description:"Goal, owner, and tag filters for board scope.",inputs:e,params:t,output:[n({label:"Filter summary",description:"Summary of the current Kanban filters and scope."})],tools:[r("Search Forge entities by query and entity types.")]}),execute:a=>i(a,{query:"",entityTypes:["task"],limit:24})}),h=o(u,{id:"surface:kanban-index:board",surfaceId:"kanban-index",routePath:"/kanban",title:"Kanban board",icon:"board",description:"Task board with move and execution actions.",category:"Execution",tags:["kanban","board","tasks"],inputs:e,params:t,output:d({itemKind:"kanban_task",itemLabel:"Kanban task"}),tools:[r("Search Forge entities by query and entity types."),b("Update a task status.")],NodeView:s({title:"Kanban board",description:"Task board with move and execution actions.",inputs:e,params:t,output:d({itemKind:"kanban_task",itemLabel:"Kanban task"}),tools:[r("Search Forge entities by query and entity types."),b("Update a task status.")]}),execute:a=>i(a,{query:"",entityTypes:["task"],limit:24})});export{f as K,x as a,h as b};
1
+ import{j as c}from"./vendor-BwL6m4SE.js";import{c as s,a as n,b as d,d as m,e as p,f as i,g as r,h as b}from"./generic-node-view-CcepUVhP.js";import{d as o}from"./define-workbench-box-D-32C8nM.js";function u({children:a}){return c.jsx(c.Fragment,{children:a})}const e=m({itemKind:"task",itemLabel:"Task",defaultEntityTypes:["task"],defaultLimit:24}),t=p(),f=o(u,{id:"surface:kanban-index:summary",surfaceId:"kanban-index",routePath:"/kanban",title:"Kanban summary",icon:"kanban",description:"Board summary and execution posture.",category:"Execution",tags:["kanban","summary"],inputs:e,params:t,output:[n({label:"Kanban summary",description:"Summary of board posture and execution pressure."})],tools:[],NodeView:s({title:"Kanban summary",description:"Board summary and execution posture.",inputs:e,params:t,output:[n({label:"Kanban summary",description:"Summary of board posture and execution pressure."})],tools:[]}),execute:a=>i(a,{query:"",entityTypes:["task"],limit:24})}),x=o(u,{id:"surface:kanban-index:filters",surfaceId:"kanban-index",routePath:"/kanban",title:"Kanban filters",icon:"filter",description:"Goal, owner, and tag filters for board scope.",category:"Execution",tags:["kanban","filters"],inputs:e,params:t,output:[n({label:"Filter summary",description:"Summary of the current Kanban filters and scope."})],tools:[r("Search Forge entities by query and entity types.")],NodeView:s({title:"Kanban filters",description:"Goal, owner, and tag filters for board scope.",inputs:e,params:t,output:[n({label:"Filter summary",description:"Summary of the current Kanban filters and scope."})],tools:[r("Search Forge entities by query and entity types.")]}),execute:a=>i(a,{query:"",entityTypes:["task"],limit:24})}),h=o(u,{id:"surface:kanban-index:board",surfaceId:"kanban-index",routePath:"/kanban",title:"Kanban board",icon:"board",description:"Task board with move and execution actions.",category:"Execution",tags:["kanban","board","tasks"],inputs:e,params:t,output:d({itemKind:"kanban_task",itemLabel:"Kanban task"}),tools:[r("Search Forge entities by query and entity types."),b("Update a task status.")],NodeView:s({title:"Kanban board",description:"Task board with move and execution actions.",inputs:e,params:t,output:d({itemKind:"kanban_task",itemLabel:"Kanban task"}),tools:[r("Search Forge entities by query and entity types."),b("Update a task status.")]}),execute:a=>i(a,{query:"",entityTypes:["task"],limit:24})});export{f as K,x as a,h as b};
@@ -1 +1 @@
1
- import{b6 as Re,r as n,j as s,aC as Ce,b7 as Be,aK as _e,c3 as Oe}from"./vendor-BwL6m4SE.js";import{j as Ae,k as O}from"./state-Bpe5dF3T.js";import{K as Le,a as Ke,b as We}from"./kanban-boxes-qIwmQlRq.js";import{E as Ue}from"./execution-board-ClaXVQ0H.js";import{ProjectDialog as ze}from"./project-dialog-YYxtlqg8.js";import{P as qe}from"./project-management-section-nav-Ctjd348W.js";import{E as G}from"./entity-link-multiselect-Do5DTju7.js";import{TaskDialog as Qe}from"./task-dialog-BfPkbIPE.js";import{u as De,d as Ve,k as m,b as A,B as y,h as pe,C as H,ae as Ge,I as he,af as He,i as Xe,ag as Ye,ah as Je}from"./index-DGYIFHgo.js";import{P as ge}from"./page-hero-BkrRTu-t.js";import{U as fe}from"./user-badge-ap1PvOxd.js";import{g as Ze}from"./user-ownership-DJGl4rAj.js";import"./generic-node-view-CgLkbts-.js";import"./graph-BF4IsheG.js";import"./define-workbench-box-DWAqqjvH.js";import"./board-CuxQRKPJ.js";import"./entity-note-count-link-CV3eOv66.js";import"./floating-action-menu-DGkHCmvI.js";import"./question-flow-dialog-CLHVmFON.js";import"./ui-B9TWEtCx.js";import"./motion-DcgUnXhY.js";import"./inline-note-fields-CJ9ukqFp.js";import"./user-select-field-fx129Uh6.js";import"./schemas-B0AXfuOr.js";import"./forms-D1qJ3oOP.js";import"./use-anchored-overlay-position-BY4kNzPj.js";import"./goal-dialog-6R2uYWPQ.js";const f={goal:"goal:",project:"project:",tag:"tag:"},b={user:"user:",kind:"kind:"},es=[{value:"project",label:"Project",searchText:"project initiative prd"},{value:"issue",label:"Issue",searchText:"issue vertical slice tracer bullet"},{value:"task",label:"Task",searchText:"task focused ai session"},{value:"subtask",label:"Subtask",searchText:"subtask child step"}];function X(r){return r.trim().toLowerCase()}function ss(r){return r.reduce((t,l)=>(l.startsWith(f.goal)?t.goalIds.push(l.slice(f.goal.length)):l.startsWith(f.project)?t.projectIds.push(l.slice(f.project.length)):l.startsWith(f.tag)&&t.tagIds.push(l.slice(f.tag.length)),t),{goalIds:[],projectIds:[],tagIds:[]})}function ts(r){return r.reduce((t,l)=>{if(l.startsWith(b.user))t.userIds.push(l.slice(b.user.length));else if(l.startsWith(b.kind)){const u=l.slice(b.kind.length);(u==="human"||u==="bot")&&t.kinds.push(u)}return t},{userIds:[],kinds:[]})}function xe(r,t,l,u){r([]),t([]),l(""),u(["task","subtask"])}function as(r){const t=r.trim();return t.length===0?{firstTitle:"Split task part 1",secondTitle:"Split task part 2"}:{firstTitle:`${t} - part 1`,secondTitle:`${t} - part 2`}}function Fs(){var re,le,oe,de,ce,ue,me;const{t:r}=De(),t=Ve(),l=Re(),u=Ae(),[$,L]=n.useState([]),[E,K]=n.useState([]),[I,F]=n.useState(""),[j,W]=n.useState(["task","subtask"]),[U,M]=n.useState(((le=(re=t.snapshot.workItems)==null?void 0:re[0])==null?void 0:le.id)??((oe=t.snapshot.tasks[0])==null?void 0:oe.id)??null),[Y,z]=n.useState(null),[ke,q]=n.useState(void 0),[J,T]=n.useState(null),[ve,R]=n.useState(void 0),[o,C]=n.useState(null),[Z,Q]=n.useState(null),[d,B]=n.useState({firstTitle:"",secondTitle:"",remainingRatio:.5}),be=n.useMemo(()=>[...t.snapshot.goals.map(e=>({value:`${f.goal}${e.id}`,label:e.title,description:"Goal",searchText:`goal ${e.title} ${e.description??""}`,kind:"goal"})),...t.snapshot.dashboard.projects.map(e=>({value:`${f.project}${e.id}`,label:e.title,description:"Project",searchText:`project ${e.title} ${e.description??""} ${e.goalTitle??""}`,kind:"project"})),...t.snapshot.tags.map(e=>({value:`${f.tag}${e.id}`,label:e.name,description:"Tag",searchText:`tag ${e.name} ${e.color??""}`,kind:"tag"}))],[t.snapshot.dashboard.projects,t.snapshot.goals,t.snapshot.tags]),je=n.useMemo(()=>{const e=t.snapshot.users.filter(i=>i.kind==="bot"),a=t.snapshot.users.filter(i=>i.kind==="human");return[{value:`${b.kind}bot`,label:"Bots",description:`${e.length} bot owner${e.length===1?"":"s"}`,searchText:`bots bot ai agents assistants ${e.map(i=>`${i.displayName} ${i.handle}`).join(" ")}`,badge:s.jsx(m,{className:"border-[color-mix(in_srgb,var(--info)_28%,transparent)] bg-[var(--ui-info-soft)] text-[var(--ui-ink-strong)]",children:"Bots"}),menuBadge:s.jsx(m,{className:"border-[color-mix(in_srgb,var(--info)_28%,transparent)] bg-[var(--ui-info-soft)] text-[var(--ui-ink-strong)]",children:"Bots"})},{value:`${b.kind}human`,label:"Humans",description:`${a.length} human owner${a.length===1?"":"s"}`,searchText:`humans human people operators ${a.map(i=>`${i.displayName} ${i.handle}`).join(" ")}`,badge:s.jsx(m,{className:"border-[color-mix(in_srgb,var(--warning)_28%,transparent)] bg-[var(--ui-warning-soft)] text-[var(--ui-ink-strong)]",children:"Humans"}),menuBadge:s.jsx(m,{className:"border-[color-mix(in_srgb,var(--warning)_28%,transparent)] bg-[var(--ui-warning-soft)] text-[var(--ui-ink-strong)]",children:"Humans"})},...t.snapshot.users.map(i=>({value:`${b.user}${i.id}`,label:i.displayName,description:`${i.kind}${i.handle?` · @${i.handle}`:""}`,searchText:`${i.displayName} ${i.handle} ${i.kind} ${i.description}`,badge:s.jsx(fe,{user:i,compact:!0}),menuBadge:s.jsx(fe,{user:i,compact:!0})}))]},[t.snapshot.users]),ye=n.useMemo(()=>es.map(e=>({value:e.value,label:e.label,searchText:e.searchText,badge:e.value==="subtask"?s.jsx(A,{kind:"task",label:"Subtask",compact:!0,gradient:!1,className:"border-[color-mix(in_srgb,var(--primary)_28%,transparent)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]"}):s.jsx(A,{kind:e.kind??e.value,label:e.label,compact:!0,gradient:!1}),menuBadge:e.value==="subtask"?s.jsx(A,{kind:"task",label:"Subtask",compact:!0,gradient:!1,className:"border-[color-mix(in_srgb,var(--primary)_28%,transparent)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]"}):s.jsx(A,{kind:e.kind??e.value,label:e.label,compact:!0,gradient:!1})})),[]),p=n.useMemo(()=>ss($),[$]),x=n.useMemo(()=>ts(E),[E]),_=n.useMemo(()=>X(I),[I]),h=n.useMemo(()=>t.snapshot.workItems&&t.snapshot.workItems.length>0?t.snapshot.workItems:t.snapshot.tasks,[t.snapshot.tasks,t.snapshot.workItems]),Ie=n.useMemo(()=>new Map(t.snapshot.dashboard.projects.map(e=>[e.id,e])),[t.snapshot.dashboard.projects]),k=h.filter(e=>{var a;if(!j.includes(e.level))return!1;if(_.length>0){const i=e.projectId?Ie.get(e.projectId)??null:null;if(!X([e.title,e.description,e.level,e.aiInstructions??"",e.executionMode??"",(i==null?void 0:i.title)??"",(i==null?void 0:i.goalTitle)??"",((a=e.user)==null?void 0:a.displayName)??"",...(e.assignees??[]).map(P=>P.displayName)].join(" ")).includes(_))return!1}if(p.goalIds.length>0&&(e.goalId===null||!p.goalIds.includes(e.goalId))||p.projectIds.length>0&&(e.projectId===null||!p.projectIds.includes(e.projectId))||p.tagIds.length>0&&!p.tagIds.every(i=>e.tagIds.includes(i)))return!1;if(x.userIds.length>0||x.kinds.length>0){const i=[...e.user?[e.user]:[],...e.assignees??[]],c=i.some(v=>x.userIds.includes(v.id)),P=i.some(v=>x.kinds.includes(v.kind));if(!c&&!P)return!1}return!0}),D=t.snapshot.dashboard.projects.filter(e=>{var a;if(!j.includes("project")||_.length>0&&!X([e.title,e.description,e.goalTitle,e.productRequirementsDocument,((a=e.user)==null?void 0:a.displayName)??"",...(e.assignees??[]).map(c=>c.displayName)].join(" ")).includes(_)||p.goalIds.length>0&&!p.goalIds.includes(e.goalId)||p.projectIds.length>0&&!p.projectIds.includes(e.id))return!1;if(x.userIds.length>0||x.kinds.length>0){const i=[...e.user?[e.user]:[],...e.assignees??[]],c=i.some(v=>x.userIds.includes(v.id)),P=i.some(v=>x.kinds.includes(v.kind));if(!c&&!P)return!1}return!0}),Te=k.length+D.length,we=D.length>0||k.length>0,Ne=I.trim().length>0||$.length>0||E.length>0||j.length!==2||!j.includes("task")||!j.includes("subtask"),ee=k.find(e=>e.id===U)??h.find(e=>e.id===U)??null,w=Y?t.snapshot.dashboard.projects.find(e=>e.id===Y)??null:null,g=J?h.find(e=>e.id===J)??null:null,Se=k.filter(e=>e.status==="blocked").length,Pe=k.filter(e=>e.status==="done").length,$e=k.filter(e=>e.status==="focus"||e.status==="in_progress").length,se=t.snapshot.activeTaskRuns.length,te=Ze(t.selectedUserIds),N=Z?h.find(e=>e.id===Z)??null:null,S=async()=>{await Promise.all([t.refresh(),Xe(u),u.invalidateQueries({queryKey:["project-board"]}),u.invalidateQueries({queryKey:["task-context"]})])},Ee=O({mutationFn:({taskId:e,patch:a})=>t.patchTask(e,a),onSuccess:S}),Fe=O({mutationFn:e=>He(e),onSuccess:S}),Me=O({mutationFn:Ye,onSuccess:S}),ae=O({mutationFn:({taskId:e,firstTitle:a,secondTitle:i,remainingRatio:c})=>Je(e,{firstTitle:a,secondTitle:i,remainingRatio:c}),onSuccess:async()=>{await S(),Q(null)}}),ie=(e,a)=>{z(e),q(a)},ne=(e,a)=>{T(e),C(null),R(a)},V=e=>{T(null),R(void 0),C(e)};return h.length===0&&t.snapshot.dashboard.projects.length===0?s.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-5",children:[s.jsx(ge,{title:"Kanban",description:"Move tasks across the board, start work quickly, and keep your next step visible.",badge:"0 visible tasks",actions:s.jsx(y,{size:"lg",onClick:()=>t.openStartWork(),children:"Start work"})}),s.jsx(pe,{eyebrow:r("common.kanban.heroEyebrow"),title:r("common.kanban.emptyTitle"),description:r("common.kanban.emptyDescription"),action:s.jsx(Ce,{to:"/goals",className:"inline-flex whitespace-nowrap rounded-full bg-[var(--primary)] px-4 py-2 text-sm font-medium text-[var(--ui-ink-on-accent)] transition hover:opacity-90",children:r("common.kanban.emptyAction")})})]}):s.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-5",children:[s.jsx(qe,{}),s.jsx(ge,{title:"Kanban",description:"Move projects, issues, tasks, and subtasks through one shared execution board, then open the right layer when you need to inspect or edit it.",badge:`${Te} visible work items`,actions:s.jsx(y,{size:"lg",onClick:()=>t.openStartWork(ee?{taskId:ee.id}:void 0),children:"Start work"})}),s.jsx(Le,{children:s.jsx(H,{className:"min-w-0 overflow-hidden",children:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Board"}),s.jsx("div",{className:"mt-2 text-base text-[var(--ui-ink-strong)]",children:"See projects, issues, tasks, and subtasks in the same workflow lanes, with one card language and one shared board state."})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs(m,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:[$e," ready or active"]}),s.jsxs(m,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:[Se," blocked"]}),s.jsxs(m,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:[Pe," done"]}),s.jsxs(m,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:[se," live timer",se===1?"":"s"]}),s.jsxs(m,{className:"bg-[var(--ui-accent-soft)] text-[var(--primary)]",children:[Math.round(((de=t.snapshot.lifeForce)==null?void 0:de.spentTodayAp)??0)," /"," ",Math.round(((ce=t.snapshot.lifeForce)==null?void 0:ce.dailyBudgetAp)??0)," AP"]})]})]})})}),s.jsx(Ke,{children:s.jsxs(H,{className:"min-w-0 overflow-hidden",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("div",{className:"type-label text-[var(--ui-ink-faint)]",children:"Filters"}),s.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Use compact entity chips for goals, projects, tags, and owner scopes instead of the wide pill rows."})]}),Ne?s.jsx(y,{variant:"secondary",size:"sm",onClick:()=>xe(L,K,F,W),children:"Reset"}):null]}),s.jsxs("div",{className:"mt-4 grid gap-3 xl:grid-cols-[minmax(0,1fr)_minmax(18rem,24rem)]",children:[s.jsx("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Be,{className:"size-4 text-[var(--ui-ink-faint)]"}),s.jsx("input",{value:I,onChange:e=>F(e.target.value),placeholder:"Search projects, issues, tasks, subtasks, PRDs, owners, and assignees",className:"min-w-0 flex-1 bg-transparent text-sm text-[var(--ui-ink-strong)] placeholder:text-[var(--ui-ink-faint)] focus:outline-none"}),I.trim().length>0?s.jsx("button",{type:"button",className:"rounded-full text-[var(--ui-ink-faint)] transition hover:text-[var(--ui-ink-strong)]",onClick:()=>F(""),"aria-label":"Clear board search",children:s.jsx(_e,{className:"size-4"})}):null]})}),s.jsx(G,{options:ye,selectedValues:j,onChange:e=>W(e),placeholder:"Work item types",emptyMessage:"No work-item levels.",variant:"action-bar"})]}),s.jsxs("div",{className:"mt-3 grid gap-3 xl:grid-cols-[minmax(0,1.55fr)_minmax(18rem,1fr)]",children:[s.jsxs("div",{className:"grid gap-2",children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Entity filters"}),s.jsx(G,{options:be,selectedValues:$,onChange:L,placeholder:"Filter by goal, project, or tag",emptyMessage:"No matching goals, projects, or tags."})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Owner filters"}),s.jsx(G,{options:je,selectedValues:E,onChange:K,placeholder:"Type Bo for bots, Hu for humans, or a teammate name",emptyMessage:"No matching owners."})]})]})]})}),we?s.jsx(We,{children:s.jsx(Ue,{tasks:k,projects:D,activeRuns:t.snapshot.activeTaskRuns,goals:t.snapshot.goals,tags:t.snapshot.tags,notesSummaryByEntity:t.snapshot.dashboard.notesSummaryByEntity,selectedTaskId:U,onMove:async(e,a)=>{await t.patchTaskStatus(e,a)},onMoveProject:async(e,a)=>{await t.patchProject(e,{workflowStatus:a})},onQuickReopenTask:async e=>{await Ge(e),await S()},onDeleteTask:async e=>{await Fe.mutateAsync(e),M(a=>{var i;return a!==e?a:((i=k.find(c=>c.id!==e))==null?void 0:i.id)??null}),T(a=>a===e?null:a)},onStartTask:async e=>{await t.startTaskNow(e),M(e),await u.invalidateQueries({queryKey:["task-context",e]})},onStopTask:async e=>{await t.stopTaskRun(e),M(e.taskId),await u.invalidateQueries({queryKey:["task-context",e.taskId]})},onSelectTask:e=>{M(e)},onOpenProject:e=>{l(`/projects/${e}`)},onOpenTask:e=>{l(`/tasks/${e}`)},onEditProject:e=>{ie(e)},onEditTask:e=>{ne(e)},onLinkProject:e=>{ie(e,"anchor")},onLinkTask:e=>{ne(e,"anchor")},onCreateIssueForProject:e=>{const a=t.snapshot.dashboard.projects.find(i=>i.id===e)??null;a&&V({initialLevel:"issue",initialGoalId:a.goalId,initialProjectId:a.id})},onCreateTaskForIssue:e=>{const a=h.find(i=>i.id===e)??null;a&&V({initialLevel:"task",initialGoalId:a.goalId,initialProjectId:a.projectId,initialParentWorkItemId:a.id})},onCreateSubtaskForTask:e=>{const a=h.find(i=>i.id===e)??null;a&&V({initialLevel:"subtask",initialGoalId:a.goalId,initialProjectId:a.projectId,initialParentWorkItemId:a.id})},onSplitTask:e=>{const a=h.find(c=>c.id===e)??null;if(!a)return;const i=as(a.title);Q(e),B({firstTitle:i.firstTitle,secondTitle:i.secondTitle,remainingRatio:.5})}})}):s.jsx(pe,{eyebrow:r("common.kanban.heroEyebrow"),title:r("common.kanban.noTasksMatch"),description:"No tasks match the current filters. Reset the filters to bring the full board back.",action:s.jsx(y,{variant:"secondary",onClick:()=>xe(L,K,F,W),children:"Reset"})}),s.jsx(ze,{open:w!==null,goals:t.snapshot.goals,users:t.snapshot.users,editingProject:w,defaultUserId:(w==null?void 0:w.userId)??te,initialStepId:ke,onOpenChange:e=>{e||(z(null),q(void 0))},onSubmit:async(e,a)=>{a&&(await t.patchProject(a,e),z(null),q(void 0))}}),s.jsx(Qe,{open:g!==null||o!==null,goals:t.snapshot.goals,projects:t.snapshot.dashboard.projects,workItems:h,tags:t.snapshot.tags,users:t.snapshot.users,editingTask:g,initialGoalId:o==null?void 0:o.initialGoalId,initialProjectId:o==null?void 0:o.initialProjectId,initialParentWorkItemId:o==null?void 0:o.initialParentWorkItemId,initialLevel:o==null?void 0:o.initialLevel,initialStepId:ve,defaultUserId:(g==null?void 0:g.userId)??te,onRefreshEntities:t.refresh,currentCreditedSeconds:g==null?void 0:g.time.totalCreditedSeconds,onOpenChange:e=>{e||(T(null),C(null),R(void 0))},onAdjustTrackedTime:g?async e=>{await Me.mutateAsync(e)}:void 0,onSubmit:async(e,a)=>{a?await Ee.mutateAsync({taskId:a,patch:e}):await t.createTask(e),T(null),C(null),R(void 0)}}),N?s.jsx("div",{className:"surface-overlay fixed inset-0 z-[60] flex items-center justify-center p-4 backdrop-blur-xl",children:s.jsxs(H,{className:"surface-modal-panel w-full max-w-xl",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"mt-1 flex size-11 shrink-0 items-center justify-center rounded-full bg-[var(--ui-warning-soft)] text-[var(--warning)]",children:s.jsx(Oe,{className:"size-5"})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"font-display text-[1.35rem] leading-tight text-[var(--ui-ink-strong)]",children:"Split this task"}),s.jsxs("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:[N.title," has grown beyond its expected shape. Split the remaining work into two child tasks while keeping the original history intact."]})]})]}),s.jsxs("div",{className:"mt-5 grid gap-4",children:[s.jsxs("div",{className:"grid gap-2",children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"First task name"}),s.jsx(he,{value:d.firstTitle,onChange:e=>B(a=>({...a,firstTitle:e.target.value}))})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Second task name"}),s.jsx(he,{value:d.secondTitle,onChange:e=>B(a=>({...a,secondTitle:e.target.value}))})]}),s.jsxs("div",{className:"grid gap-3 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm text-[var(--ui-ink-soft)]",children:[s.jsx("span",{children:"Remaining work ratio"}),s.jsxs("span",{children:[Math.round(d.remainingRatio*100),"% /"," ",100-Math.round(d.remainingRatio*100),"%"]})]}),s.jsx("input",{type:"range",min:25,max:75,step:5,value:Math.round(d.remainingRatio*100),onChange:e=>B(a=>({...a,remainingRatio:Number(e.target.value)/100}))}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs(m,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:[Math.round((((ue=N.actionPointSummary)==null?void 0:ue.totalCostAp)??0)*d.remainingRatio)," ","AP first child"]}),s.jsxs(m,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:[Math.round((((me=N.actionPointSummary)==null?void 0:me.totalCostAp)??0)*(1-d.remainingRatio))," ","AP second child"]})]})]})]}),s.jsxs("div",{className:"mt-5 flex flex-wrap justify-end gap-3",children:[s.jsx(y,{variant:"secondary",onClick:()=>{Q(null)},children:"Cancel"}),s.jsx(y,{pending:ae.isPending,disabled:d.firstTitle.trim().length===0||d.secondTitle.trim().length===0,onClick:()=>{ae.mutateAsync({taskId:N.id,firstTitle:d.firstTitle.trim(),secondTitle:d.secondTitle.trim(),remainingRatio:d.remainingRatio})},children:"Create split tasks"})]})]})}):null]})}export{Fs as KanbanPage};
1
+ import{b6 as Re,r as n,j as s,aC as Ce,b7 as Be,aK as _e,c3 as Oe}from"./vendor-BwL6m4SE.js";import{j as Ae,k as O}from"./state-Bpe5dF3T.js";import{K as Le,a as Ke,b as We}from"./kanban-boxes-DB1kuUlY.js";import{E as Ue}from"./execution-board-agWQbN-y.js";import{ProjectDialog as ze}from"./project-dialog-DnZe757y.js";import{P as qe}from"./project-management-section-nav-DyBWxHbe.js";import{E as G}from"./entity-link-multiselect-DcCvkesQ.js";import{TaskDialog as Qe}from"./task-dialog-DrA9pba7.js";import{u as De,d as Ve,k as m,b as A,B as y,h as pe,C as H,ae as Ge,I as he,af as He,i as Xe,ag as Ye,ah as Je}from"./index-CQ5r7ZUz.js";import{P as ge}from"./page-hero-8bITsx_x.js";import{U as fe}from"./user-badge-CZWtYeMw.js";import{g as Ze}from"./user-ownership-DJGl4rAj.js";import"./generic-node-view-CcepUVhP.js";import"./graph-BF4IsheG.js";import"./define-workbench-box-D-32C8nM.js";import"./board-CuxQRKPJ.js";import"./entity-note-count-link-Cjsk5oT2.js";import"./floating-action-menu-D9-psbha.js";import"./question-flow-dialog-CskCt5NZ.js";import"./ui-B9TWEtCx.js";import"./motion-DcgUnXhY.js";import"./inline-note-fields-Bql_KfR9.js";import"./user-select-field-fx129Uh6.js";import"./schemas-CH1_ngUX.js";import"./forms-D1qJ3oOP.js";import"./use-anchored-overlay-position-BY4kNzPj.js";import"./goal-dialog-Oxx8WqbZ.js";const f={goal:"goal:",project:"project:",tag:"tag:"},b={user:"user:",kind:"kind:"},es=[{value:"project",label:"Project",searchText:"project initiative prd"},{value:"issue",label:"Issue",searchText:"issue vertical slice tracer bullet"},{value:"task",label:"Task",searchText:"task focused ai session"},{value:"subtask",label:"Subtask",searchText:"subtask child step"}];function X(r){return r.trim().toLowerCase()}function ss(r){return r.reduce((t,l)=>(l.startsWith(f.goal)?t.goalIds.push(l.slice(f.goal.length)):l.startsWith(f.project)?t.projectIds.push(l.slice(f.project.length)):l.startsWith(f.tag)&&t.tagIds.push(l.slice(f.tag.length)),t),{goalIds:[],projectIds:[],tagIds:[]})}function ts(r){return r.reduce((t,l)=>{if(l.startsWith(b.user))t.userIds.push(l.slice(b.user.length));else if(l.startsWith(b.kind)){const u=l.slice(b.kind.length);(u==="human"||u==="bot")&&t.kinds.push(u)}return t},{userIds:[],kinds:[]})}function xe(r,t,l,u){r([]),t([]),l(""),u(["task","subtask"])}function as(r){const t=r.trim();return t.length===0?{firstTitle:"Split task part 1",secondTitle:"Split task part 2"}:{firstTitle:`${t} - part 1`,secondTitle:`${t} - part 2`}}function Fs(){var re,le,oe,de,ce,ue,me;const{t:r}=De(),t=Ve(),l=Re(),u=Ae(),[$,L]=n.useState([]),[E,K]=n.useState([]),[I,F]=n.useState(""),[j,W]=n.useState(["task","subtask"]),[U,M]=n.useState(((le=(re=t.snapshot.workItems)==null?void 0:re[0])==null?void 0:le.id)??((oe=t.snapshot.tasks[0])==null?void 0:oe.id)??null),[Y,z]=n.useState(null),[ke,q]=n.useState(void 0),[J,T]=n.useState(null),[ve,R]=n.useState(void 0),[o,C]=n.useState(null),[Z,Q]=n.useState(null),[d,B]=n.useState({firstTitle:"",secondTitle:"",remainingRatio:.5}),be=n.useMemo(()=>[...t.snapshot.goals.map(e=>({value:`${f.goal}${e.id}`,label:e.title,description:"Goal",searchText:`goal ${e.title} ${e.description??""}`,kind:"goal"})),...t.snapshot.dashboard.projects.map(e=>({value:`${f.project}${e.id}`,label:e.title,description:"Project",searchText:`project ${e.title} ${e.description??""} ${e.goalTitle??""}`,kind:"project"})),...t.snapshot.tags.map(e=>({value:`${f.tag}${e.id}`,label:e.name,description:"Tag",searchText:`tag ${e.name} ${e.color??""}`,kind:"tag"}))],[t.snapshot.dashboard.projects,t.snapshot.goals,t.snapshot.tags]),je=n.useMemo(()=>{const e=t.snapshot.users.filter(i=>i.kind==="bot"),a=t.snapshot.users.filter(i=>i.kind==="human");return[{value:`${b.kind}bot`,label:"Bots",description:`${e.length} bot owner${e.length===1?"":"s"}`,searchText:`bots bot ai agents assistants ${e.map(i=>`${i.displayName} ${i.handle}`).join(" ")}`,badge:s.jsx(m,{className:"border-[color-mix(in_srgb,var(--info)_28%,transparent)] bg-[var(--ui-info-soft)] text-[var(--ui-ink-strong)]",children:"Bots"}),menuBadge:s.jsx(m,{className:"border-[color-mix(in_srgb,var(--info)_28%,transparent)] bg-[var(--ui-info-soft)] text-[var(--ui-ink-strong)]",children:"Bots"})},{value:`${b.kind}human`,label:"Humans",description:`${a.length} human owner${a.length===1?"":"s"}`,searchText:`humans human people operators ${a.map(i=>`${i.displayName} ${i.handle}`).join(" ")}`,badge:s.jsx(m,{className:"border-[color-mix(in_srgb,var(--warning)_28%,transparent)] bg-[var(--ui-warning-soft)] text-[var(--ui-ink-strong)]",children:"Humans"}),menuBadge:s.jsx(m,{className:"border-[color-mix(in_srgb,var(--warning)_28%,transparent)] bg-[var(--ui-warning-soft)] text-[var(--ui-ink-strong)]",children:"Humans"})},...t.snapshot.users.map(i=>({value:`${b.user}${i.id}`,label:i.displayName,description:`${i.kind}${i.handle?` · @${i.handle}`:""}`,searchText:`${i.displayName} ${i.handle} ${i.kind} ${i.description}`,badge:s.jsx(fe,{user:i,compact:!0}),menuBadge:s.jsx(fe,{user:i,compact:!0})}))]},[t.snapshot.users]),ye=n.useMemo(()=>es.map(e=>({value:e.value,label:e.label,searchText:e.searchText,badge:e.value==="subtask"?s.jsx(A,{kind:"task",label:"Subtask",compact:!0,gradient:!1,className:"border-[color-mix(in_srgb,var(--primary)_28%,transparent)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]"}):s.jsx(A,{kind:e.kind??e.value,label:e.label,compact:!0,gradient:!1}),menuBadge:e.value==="subtask"?s.jsx(A,{kind:"task",label:"Subtask",compact:!0,gradient:!1,className:"border-[color-mix(in_srgb,var(--primary)_28%,transparent)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]"}):s.jsx(A,{kind:e.kind??e.value,label:e.label,compact:!0,gradient:!1})})),[]),p=n.useMemo(()=>ss($),[$]),x=n.useMemo(()=>ts(E),[E]),_=n.useMemo(()=>X(I),[I]),h=n.useMemo(()=>t.snapshot.workItems&&t.snapshot.workItems.length>0?t.snapshot.workItems:t.snapshot.tasks,[t.snapshot.tasks,t.snapshot.workItems]),Ie=n.useMemo(()=>new Map(t.snapshot.dashboard.projects.map(e=>[e.id,e])),[t.snapshot.dashboard.projects]),k=h.filter(e=>{var a;if(!j.includes(e.level))return!1;if(_.length>0){const i=e.projectId?Ie.get(e.projectId)??null:null;if(!X([e.title,e.description,e.level,e.aiInstructions??"",e.executionMode??"",(i==null?void 0:i.title)??"",(i==null?void 0:i.goalTitle)??"",((a=e.user)==null?void 0:a.displayName)??"",...(e.assignees??[]).map(P=>P.displayName)].join(" ")).includes(_))return!1}if(p.goalIds.length>0&&(e.goalId===null||!p.goalIds.includes(e.goalId))||p.projectIds.length>0&&(e.projectId===null||!p.projectIds.includes(e.projectId))||p.tagIds.length>0&&!p.tagIds.every(i=>e.tagIds.includes(i)))return!1;if(x.userIds.length>0||x.kinds.length>0){const i=[...e.user?[e.user]:[],...e.assignees??[]],c=i.some(v=>x.userIds.includes(v.id)),P=i.some(v=>x.kinds.includes(v.kind));if(!c&&!P)return!1}return!0}),D=t.snapshot.dashboard.projects.filter(e=>{var a;if(!j.includes("project")||_.length>0&&!X([e.title,e.description,e.goalTitle,e.productRequirementsDocument,((a=e.user)==null?void 0:a.displayName)??"",...(e.assignees??[]).map(c=>c.displayName)].join(" ")).includes(_)||p.goalIds.length>0&&!p.goalIds.includes(e.goalId)||p.projectIds.length>0&&!p.projectIds.includes(e.id))return!1;if(x.userIds.length>0||x.kinds.length>0){const i=[...e.user?[e.user]:[],...e.assignees??[]],c=i.some(v=>x.userIds.includes(v.id)),P=i.some(v=>x.kinds.includes(v.kind));if(!c&&!P)return!1}return!0}),Te=k.length+D.length,we=D.length>0||k.length>0,Ne=I.trim().length>0||$.length>0||E.length>0||j.length!==2||!j.includes("task")||!j.includes("subtask"),ee=k.find(e=>e.id===U)??h.find(e=>e.id===U)??null,w=Y?t.snapshot.dashboard.projects.find(e=>e.id===Y)??null:null,g=J?h.find(e=>e.id===J)??null:null,Se=k.filter(e=>e.status==="blocked").length,Pe=k.filter(e=>e.status==="done").length,$e=k.filter(e=>e.status==="focus"||e.status==="in_progress").length,se=t.snapshot.activeTaskRuns.length,te=Ze(t.selectedUserIds),N=Z?h.find(e=>e.id===Z)??null:null,S=async()=>{await Promise.all([t.refresh(),Xe(u),u.invalidateQueries({queryKey:["project-board"]}),u.invalidateQueries({queryKey:["task-context"]})])},Ee=O({mutationFn:({taskId:e,patch:a})=>t.patchTask(e,a),onSuccess:S}),Fe=O({mutationFn:e=>He(e),onSuccess:S}),Me=O({mutationFn:Ye,onSuccess:S}),ae=O({mutationFn:({taskId:e,firstTitle:a,secondTitle:i,remainingRatio:c})=>Je(e,{firstTitle:a,secondTitle:i,remainingRatio:c}),onSuccess:async()=>{await S(),Q(null)}}),ie=(e,a)=>{z(e),q(a)},ne=(e,a)=>{T(e),C(null),R(a)},V=e=>{T(null),R(void 0),C(e)};return h.length===0&&t.snapshot.dashboard.projects.length===0?s.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-5",children:[s.jsx(ge,{title:"Kanban",description:"Move tasks across the board, start work quickly, and keep your next step visible.",badge:"0 visible tasks",actions:s.jsx(y,{size:"lg",onClick:()=>t.openStartWork(),children:"Start work"})}),s.jsx(pe,{eyebrow:r("common.kanban.heroEyebrow"),title:r("common.kanban.emptyTitle"),description:r("common.kanban.emptyDescription"),action:s.jsx(Ce,{to:"/goals",className:"inline-flex whitespace-nowrap rounded-full bg-[var(--primary)] px-4 py-2 text-sm font-medium text-[var(--ui-ink-on-accent)] transition hover:opacity-90",children:r("common.kanban.emptyAction")})})]}):s.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-5",children:[s.jsx(qe,{}),s.jsx(ge,{title:"Kanban",description:"Move projects, issues, tasks, and subtasks through one shared execution board, then open the right layer when you need to inspect or edit it.",badge:`${Te} visible work items`,actions:s.jsx(y,{size:"lg",onClick:()=>t.openStartWork(ee?{taskId:ee.id}:void 0),children:"Start work"})}),s.jsx(Le,{children:s.jsx(H,{className:"min-w-0 overflow-hidden",children:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Board"}),s.jsx("div",{className:"mt-2 text-base text-[var(--ui-ink-strong)]",children:"See projects, issues, tasks, and subtasks in the same workflow lanes, with one card language and one shared board state."})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs(m,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:[$e," ready or active"]}),s.jsxs(m,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:[Se," blocked"]}),s.jsxs(m,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:[Pe," done"]}),s.jsxs(m,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:[se," live timer",se===1?"":"s"]}),s.jsxs(m,{className:"bg-[var(--ui-accent-soft)] text-[var(--primary)]",children:[Math.round(((de=t.snapshot.lifeForce)==null?void 0:de.spentTodayAp)??0)," /"," ",Math.round(((ce=t.snapshot.lifeForce)==null?void 0:ce.dailyBudgetAp)??0)," AP"]})]})]})})}),s.jsx(Ke,{children:s.jsxs(H,{className:"min-w-0 overflow-hidden",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("div",{className:"type-label text-[var(--ui-ink-faint)]",children:"Filters"}),s.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Use compact entity chips for goals, projects, tags, and owner scopes instead of the wide pill rows."})]}),Ne?s.jsx(y,{variant:"secondary",size:"sm",onClick:()=>xe(L,K,F,W),children:"Reset"}):null]}),s.jsxs("div",{className:"mt-4 grid gap-3 xl:grid-cols-[minmax(0,1fr)_minmax(18rem,24rem)]",children:[s.jsx("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Be,{className:"size-4 text-[var(--ui-ink-faint)]"}),s.jsx("input",{value:I,onChange:e=>F(e.target.value),placeholder:"Search projects, issues, tasks, subtasks, PRDs, owners, and assignees",className:"min-w-0 flex-1 bg-transparent text-sm text-[var(--ui-ink-strong)] placeholder:text-[var(--ui-ink-faint)] focus:outline-none"}),I.trim().length>0?s.jsx("button",{type:"button",className:"rounded-full text-[var(--ui-ink-faint)] transition hover:text-[var(--ui-ink-strong)]",onClick:()=>F(""),"aria-label":"Clear board search",children:s.jsx(_e,{className:"size-4"})}):null]})}),s.jsx(G,{options:ye,selectedValues:j,onChange:e=>W(e),placeholder:"Work item types",emptyMessage:"No work-item levels.",variant:"action-bar"})]}),s.jsxs("div",{className:"mt-3 grid gap-3 xl:grid-cols-[minmax(0,1.55fr)_minmax(18rem,1fr)]",children:[s.jsxs("div",{className:"grid gap-2",children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Entity filters"}),s.jsx(G,{options:be,selectedValues:$,onChange:L,placeholder:"Filter by goal, project, or tag",emptyMessage:"No matching goals, projects, or tags."})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Owner filters"}),s.jsx(G,{options:je,selectedValues:E,onChange:K,placeholder:"Type Bo for bots, Hu for humans, or a teammate name",emptyMessage:"No matching owners."})]})]})]})}),we?s.jsx(We,{children:s.jsx(Ue,{tasks:k,projects:D,activeRuns:t.snapshot.activeTaskRuns,goals:t.snapshot.goals,tags:t.snapshot.tags,notesSummaryByEntity:t.snapshot.dashboard.notesSummaryByEntity,selectedTaskId:U,onMove:async(e,a)=>{await t.patchTaskStatus(e,a)},onMoveProject:async(e,a)=>{await t.patchProject(e,{workflowStatus:a})},onQuickReopenTask:async e=>{await Ge(e),await S()},onDeleteTask:async e=>{await Fe.mutateAsync(e),M(a=>{var i;return a!==e?a:((i=k.find(c=>c.id!==e))==null?void 0:i.id)??null}),T(a=>a===e?null:a)},onStartTask:async e=>{await t.startTaskNow(e),M(e),await u.invalidateQueries({queryKey:["task-context",e]})},onStopTask:async e=>{await t.stopTaskRun(e),M(e.taskId),await u.invalidateQueries({queryKey:["task-context",e.taskId]})},onSelectTask:e=>{M(e)},onOpenProject:e=>{l(`/projects/${e}`)},onOpenTask:e=>{l(`/tasks/${e}`)},onEditProject:e=>{ie(e)},onEditTask:e=>{ne(e)},onLinkProject:e=>{ie(e,"anchor")},onLinkTask:e=>{ne(e,"anchor")},onCreateIssueForProject:e=>{const a=t.snapshot.dashboard.projects.find(i=>i.id===e)??null;a&&V({initialLevel:"issue",initialGoalId:a.goalId,initialProjectId:a.id})},onCreateTaskForIssue:e=>{const a=h.find(i=>i.id===e)??null;a&&V({initialLevel:"task",initialGoalId:a.goalId,initialProjectId:a.projectId,initialParentWorkItemId:a.id})},onCreateSubtaskForTask:e=>{const a=h.find(i=>i.id===e)??null;a&&V({initialLevel:"subtask",initialGoalId:a.goalId,initialProjectId:a.projectId,initialParentWorkItemId:a.id})},onSplitTask:e=>{const a=h.find(c=>c.id===e)??null;if(!a)return;const i=as(a.title);Q(e),B({firstTitle:i.firstTitle,secondTitle:i.secondTitle,remainingRatio:.5})}})}):s.jsx(pe,{eyebrow:r("common.kanban.heroEyebrow"),title:r("common.kanban.noTasksMatch"),description:"No tasks match the current filters. Reset the filters to bring the full board back.",action:s.jsx(y,{variant:"secondary",onClick:()=>xe(L,K,F,W),children:"Reset"})}),s.jsx(ze,{open:w!==null,goals:t.snapshot.goals,users:t.snapshot.users,editingProject:w,defaultUserId:(w==null?void 0:w.userId)??te,initialStepId:ke,onOpenChange:e=>{e||(z(null),q(void 0))},onSubmit:async(e,a)=>{a&&(await t.patchProject(a,e),z(null),q(void 0))}}),s.jsx(Qe,{open:g!==null||o!==null,goals:t.snapshot.goals,projects:t.snapshot.dashboard.projects,workItems:h,tags:t.snapshot.tags,users:t.snapshot.users,editingTask:g,initialGoalId:o==null?void 0:o.initialGoalId,initialProjectId:o==null?void 0:o.initialProjectId,initialParentWorkItemId:o==null?void 0:o.initialParentWorkItemId,initialLevel:o==null?void 0:o.initialLevel,initialStepId:ve,defaultUserId:(g==null?void 0:g.userId)??te,onRefreshEntities:t.refresh,currentCreditedSeconds:g==null?void 0:g.time.totalCreditedSeconds,onOpenChange:e=>{e||(T(null),C(null),R(void 0))},onAdjustTrackedTime:g?async e=>{await Me.mutateAsync(e)}:void 0,onSubmit:async(e,a)=>{a?await Ee.mutateAsync({taskId:a,patch:e}):await t.createTask(e),T(null),C(null),R(void 0)}}),N?s.jsx("div",{className:"surface-overlay fixed inset-0 z-[60] flex items-center justify-center p-4 backdrop-blur-xl",children:s.jsxs(H,{className:"surface-modal-panel w-full max-w-xl",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"mt-1 flex size-11 shrink-0 items-center justify-center rounded-full bg-[var(--ui-warning-soft)] text-[var(--warning)]",children:s.jsx(Oe,{className:"size-5"})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"font-display text-[1.35rem] leading-tight text-[var(--ui-ink-strong)]",children:"Split this task"}),s.jsxs("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:[N.title," has grown beyond its expected shape. Split the remaining work into two child tasks while keeping the original history intact."]})]})]}),s.jsxs("div",{className:"mt-5 grid gap-4",children:[s.jsxs("div",{className:"grid gap-2",children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"First task name"}),s.jsx(he,{value:d.firstTitle,onChange:e=>B(a=>({...a,firstTitle:e.target.value}))})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Second task name"}),s.jsx(he,{value:d.secondTitle,onChange:e=>B(a=>({...a,secondTitle:e.target.value}))})]}),s.jsxs("div",{className:"grid gap-3 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm text-[var(--ui-ink-soft)]",children:[s.jsx("span",{children:"Remaining work ratio"}),s.jsxs("span",{children:[Math.round(d.remainingRatio*100),"% /"," ",100-Math.round(d.remainingRatio*100),"%"]})]}),s.jsx("input",{type:"range",min:25,max:75,step:5,value:Math.round(d.remainingRatio*100),onChange:e=>B(a=>({...a,remainingRatio:Number(e.target.value)/100}))}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs(m,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:[Math.round((((ue=N.actionPointSummary)==null?void 0:ue.totalCostAp)??0)*d.remainingRatio)," ","AP first child"]}),s.jsxs(m,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:[Math.round((((me=N.actionPointSummary)==null?void 0:me.totalCostAp)??0)*(1-d.remainingRatio))," ","AP second child"]})]})]})]}),s.jsxs("div",{className:"mt-5 flex flex-wrap justify-end gap-3",children:[s.jsx(y,{variant:"secondary",onClick:()=>{Q(null)},children:"Cancel"}),s.jsx(y,{pending:ae.isPending,disabled:d.firstTitle.trim().length===0||d.secondTitle.trim().length===0,onClick:()=>{ae.mutateAsync({taskId:N.id,firstTitle:d.firstTitle.trim(),secondTitle:d.secondTitle.trim(),remainingRatio:d.remainingRatio})},children:"Create split tasks"})]})]})}):null]})}export{Fs as KanbanPage};
@@ -1 +1 @@
1
- import{r as h,j as r,b6 as nr,bY as sr,ca as ir,cf as or,cg as gt,bj as ft,bX as cr,ch as lr,ci as ur,cj as dr}from"./vendor-BwL6m4SE.js";import{R as pr,P as hr,O as gr,C as fr,T as mr,D as xr,a as mt}from"./ui-B9TWEtCx.js";import{i as yr}from"./state-Bpe5dF3T.js";import{ai as br,aj as dt,ak as Ot,al as vr,am as wr,an as Nr,ao as ot,ap as Be,aq as Pt,ar as ct,as as Tt,at as Dt,au as Sr,av as Cr,b as at,E as Er,aw as jr,ax as _r,ab as Rr,d as Gr,ay as xt,az as Mr,L as kr,e as Fr,a as Kr,V as Ir,B as W,I as Ze,aA as yt,aB as Ar,aC as Or,aD as Pr}from"./index-DGYIFHgo.js";import{G as Tr,S as Dr,i as zr,C as Lr,B as $r,M as Yr}from"./graph-BF4IsheG.js";import{E as ve}from"./entity-link-multiselect-Do5DTju7.js";import{F as bt}from"./faceted-token-search-DoSsb7qT.js";import{U as vt}from"./user-badge-ap1PvOxd.js";import{A as Hr,m as Vr}from"./motion-DcgUnXhY.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";import"./use-anchored-overlay-position-BY4kNzPj.js";const Br=Math.PI*(3-Math.sqrt(5)),Xr=.48;function Xe(e,t,n){return Math.min(n,Math.max(t,e))}function Wr({positions:e,point:t}){const n=[...e.values()];if(n.length===0)return{x:.5,y:.5};let s=Number.POSITIVE_INFINITY,u=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY;for(const N of n)s=Math.min(s,N.x),u=Math.max(u,N.x),o=Math.min(o,N.y),c=Math.max(c,N.y);const l=Math.max(u-s,0),i=Math.max(c-o,0),m=Math.max(l,i,1),g=(1-l/m)/2,b=(1-i/m)/2,G=l||1,f=i||1;return{x:Xe((t.x-s)/G*(l/m)+g,0,1),y:Xe((t.y-o)/f*(i/m)+b,0,1)}}function Ur(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function qr({nodes:e,cache:t}){const n=new Map,s=[...e].sort((l,i)=>i.importance-l.importance||l.title.localeCompare(i.title)||l.id.localeCompare(i.id));let u=0,o=0,c=0;if(s.forEach((l,i)=>{const m=t.get(l.id);if(m){n.set(l.id,m),u+=m.x,o+=m.y,c+=1;return}const g=(Ur(l.id)%1e3/1e3-.5)*.22,b=i*Br+g,G=Xr*Math.sqrt(i+1),f={x:Math.cos(b)*G,y:Math.sin(b)*G};n.set(l.id,f),u+=f.x,o+=f.y,c+=1}),c>0){const l=u/c,i=o/c;n.forEach((m,g)=>{n.set(g,{x:m.x-l,y:m.y-i})})}return n}function Qr(e,t){if(e.startsWith("rgb(")&&e.endsWith(")"))return e.replace("rgb(","rgba(").replace(")",`, ${t})`);if(e.startsWith("#")){const n=e.slice(1),s=n.length===3?n.split("").map(l=>`${l}${l}`).join(""):n,u=parseInt(s.slice(0,2),16),o=parseInt(s.slice(2,4),16),c=parseInt(s.slice(4,6),16);return`rgba(${u}, ${o}, ${c}, ${t})`}return e}function Ie(e,t){return`rgba(${e==="structural"?"125, 211, 252":e==="contextual"?"45, 212, 191":e==="taxonomy"?"192, 132, 252":e==="workspace"?"251, 191, 36":"148, 163, 184"}, ${t})`}function wt(e,t){return!t.focusNodeId||e===t.focusNodeId?0:t.detailNodeIds.has(e)?1:t.relatedNodeIds.has(e)?2:3}function Zr({nodeId:e,attributes:t,node:n,focusNodeId:s,relatedNodeIds:u,detailNodeIds:o,hoveredNodeId:c,draggedNodeId:l}){const i=s===e,m=u.has(e),g=o.has(e),b=c===e,G=l===e,f=!s||m,N=t.color;return{...t,label:i||b||G||g?n.title:"",forceLabel:i||b||G||g,highlighted:i||b||G||g,color:f?N:Qr(N,.34),size:G?t.size*2:i?t.size*1.8:b?t.size*1.35:g?t.size*1.16:m?t.size*1.06:t.size,zIndex:G?4:i?3:g||b?2:1}}function Jr({attributes:e,edge:t,focusNodeId:n,detailNodeIds:s,relatedNodeIds:u,hoveredNodeId:o}){const c=!!n&&(t.source===n||t.target===n),l=!!o&&(t.source===o||t.target===o),i={focusNodeId:n,detailNodeIds:s,relatedNodeIds:u},m=n?Math.max(wt(t.source,i),wt(t.target,i)):0,g=c?Ie(t.family,.24):l?Ie(t.family,.14):n?m<=1?Ie(t.family,.09):m===2?Ie(t.family,.05):Ie(t.family,.016):Ie(t.family,.055);return{...e,color:g,size:c?e.size*1.18:l?e.size*1.08:e.size,zIndex:c?2:l?1:0}}function Nt(e,t){const n=new Set,s=new Set;for(const u of e)u.source===t?n.add(u.target):u.target===t&&n.add(u.source);for(const u of e)u.source!==t&&n.has(u.source)&&s.add(u.target),u.target!==t&&n.has(u.target)&&s.add(u.source);return s.delete(t),n.forEach(u=>s.delete(u)),{firstRing:[...n].sort(),secondRing:[...s].sort()}}function St(e,t,n){if(!n)return e.map(()=>-1);const s=new Set(e);if(!s.has(n))return e.map(()=>-1);const u=new Map;for(const l of t){if(!s.has(l.source)||!s.has(l.target))continue;const i=u.get(l.source)??new Set;i.add(l.target),u.set(l.source,i);const m=u.get(l.target)??new Set;m.add(l.source),u.set(l.target,m)}const o=new Map([[n,0]]);let c=[n];for(;c.length>0;){const l=[];for(const i of c){const m=o.get(i);for(const g of u.get(i)??[])o.has(g)||(o.set(g,m+1),l.push(g))}c=l}return e.map(l=>o.get(l)??-1)}function ea({positions:e,focusNodeId:t,firstRingNodeIds:n,secondRingNodeIds:s,currentRatio:u}){const o=e.get(t);if(!o)return null;const c=[t,...n,...s].filter((L,me,k)=>k.indexOf(L)===me),l=c.map(L=>e.get(L)).filter(Boolean);if(l.length===0)return null;let i=Number.POSITIVE_INFINITY,m=Number.NEGATIVE_INFINITY,g=Number.POSITIVE_INFINITY,b=Number.NEGATIVE_INFINITY,G=Number.POSITIVE_INFINITY,f=Number.NEGATIVE_INFINITY,N=Number.POSITIVE_INFINITY,F=Number.NEGATIVE_INFINITY;for(const L of e.values())G=Math.min(G,L.x),f=Math.max(f,L.x),N=Math.min(N,L.y),F=Math.max(F,L.y);for(const L of l)i=Math.min(i,L.x),m=Math.max(m,L.x),g=Math.min(g,L.y),b=Math.max(b,L.y);const j=Math.max(m-i,b-g,.75),z=Math.max(f-G,F-N,j),M=l.length<=1?Xe(Math.max(u,.48),.38,.6):Xe(j/z*3.2,.42,Math.max(u,1.12));return{x:o.x,y:o.y,ratio:M,nodeIds:c}}function zt({positions:e,currentRatio:t=1}){const n=[...e.values()];if(n.length===0)return{x:0,y:0,ratio:t};let s=Number.POSITIVE_INFINITY,u=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY;for(const m of n)s=Math.min(s,m.x),u=Math.max(u,m.x),o=Math.min(o,m.y),c=Math.max(c,m.y);const l=Math.max(u-s,c-o,1),i=Xe(l/6.4,.72,2.8);return{x:0,y:0,ratio:Math.max(t,i)}}let He=null;function ta(){if(He!==null)return He;if(typeof document>"u")return He=!1,!1;const e=document.createElement("canvas");return He=!!(e.getContext("webgl2")||e.getContext("webgl")||e.getContext("experimental-webgl")),He}function ra(e){if(!e||typeof window>"u")return"#c0c1ff";const t=document.body?getComputedStyle(document.body).getPropertyValue(e).trim():"",n=getComputedStyle(document.documentElement).getPropertyValue(e).trim(),s=t||n;return s?`rgb(${s})`:"#c0c1ff"}function aa(e,t){if(e.startsWith("rgb(")&&e.endsWith(")"))return e.replace("rgb(","rgba(").replace(")",`, ${t})`);if(e.startsWith("#")){const n=e.slice(1),s=n.length===3?n.split("").map(l=>`${l}${l}`).join(""):n,u=parseInt(s.slice(0,2),16),o=parseInt(s.slice(2,4),16),c=parseInt(s.slice(4,6),16);return`rgba(${u}, ${o}, ${c}, ${t})`}return e}function Ve(e,t){e.forEachNode(n=>{const s=e.getNodeAttributes(n);Number.isFinite(s.x)&&Number.isFinite(s.y)&&t.set(n,{x:s.x,y:s.y})})}function na(e,t,n){const s=new Tr,u=[...e].sort((c,l)=>l.importance-c.importance||c.title.localeCompare(l.title)||c.id.localeCompare(l.id)),o=qr({nodes:u,cache:n});return u.forEach(c=>{const l=o.get(c.id);s.addNode(c.id,{x:(l==null?void 0:l.x)??0,y:(l==null?void 0:l.y)??0,size:Math.max(2.5,c.size/14),color:ra(c.accentToken),label:c.title,hidden:!1,forceLabel:!1,highlighted:!1,zIndex:0,data:c})}),t.forEach(c=>{!s.hasNode(c.source)||!s.hasNode(c.target)||s.addEdgeWithKey(c.id,c.source,c.target,{size:Math.max(.8,c.strength*1.6),color:c.family==="structural"?"rgba(125, 211, 252, 0.055)":c.family==="contextual"?"rgba(45, 212, 191, 0.055)":c.family==="taxonomy"?"rgba(192, 132, 252, 0.055)":c.family==="workspace"?"rgba(251, 191, 36, 0.055)":"rgba(148, 163, 184, 0.055)",label:c.label,hidden:!1,forceLabel:!1,zIndex:0,data:c})}),s}function Ct(e){if(e.order===0)return;let t=0,n=0,s=0;if(e.forEachNode(c=>{const l=e.getNodeAttributes(c);t+=l.x,n+=l.y,s+=1}),s===0)return;const u=t/s,o=n/s;Math.abs(u)<1e-4&&Math.abs(o)<1e-4||e.updateEachNodeAttributes((c,l)=>({...l,x:l.x-u,y:l.y-o}),{attributes:["x","y"]})}function Et(e){const t=new Map;return e.forEachNode(n=>{const s=e.getNodeAttributes(n);t.set(n,{x:s.x,y:s.y})}),t}function Ae(e,t){return{nodes:e.nodes().map(n=>({id:n,...e.getNodeAttributes(n)})),edges:t}}function sa(e){if(e.nodes.length===0)return{minX:-1,maxX:1,minY:-1,maxY:1};let t=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,s=Number.POSITIVE_INFINITY,u=Number.NEGATIVE_INFINITY;for(const o of e.nodes)t=Math.min(t,o.x),n=Math.max(n,o.x),s=Math.min(s,o.y),u=Math.max(u,o.y);return{minX:t,maxX:n,minY:s,maxY:u}}function ia(e){const t=zt({positions:new Map(e.nodes.map(n=>[n.id,{x:n.x,y:n.y}])),currentRatio:1});return{x:t.x,y:t.y,angle:0,ratio:t.ratio}}function oa({x:e,y:t}){const n=Array.from({length:e.length},(u,o)=>({x:e[o]??0,y:t[o]??0})),s=br(n);return s.changed?{changed:!0,offsetX:s.offset.x,offsetY:s.offset.y,x:new Float32Array(s.positions.map(u=>u.x)),y:new Float32Array(s.positions.map(u=>u.y))}:{changed:!1,offsetX:0,offsetY:0,x:new Float32Array(e),y:new Float32Array(t)}}function Lt({node:e,snapshot:t,camera:n,width:s,height:u}){const o=sa(t),c=Math.max(1,o.maxX-o.minX),l=Math.max(1,o.maxY-o.minY),i=28,g=Math.min(Math.max(1,s-i*2)/c,Math.max(1,u-i*2)/l)/Math.max(n.ratio,.08);return{x:s/2+(e.x-n.x)*g,y:u/2-(e.y-n.y)*g,size:Math.max(4,e.size*g*.12)}}function jt(e,t){if(!e)return!1;const n=e.clientWidth,s=e.clientHeight,u=e.getBoundingClientRect();return e.isConnected&&t.width>0&&t.height>0&&n>0&&s>0&&u.width>0&&u.height>0&&e.getClientRects().length>0}function ca({sigma:e,graph:t,viewportX:n,viewportY:s}){let u=null,o=Number.POSITIVE_INFINITY;return t.forEachNode(c=>{const l=t.getNodeAttributes(c),i=e.getNodeDisplayData(c);if(!i||l.hidden)return;const m=e.graphToViewport({x:l.x,y:l.y}),g=m.x-n,b=m.y-s,G=Math.hypot(g,b),f=Math.max(i.size*1.8,18);G<=f&&G<o&&(u=c,o=G)}),u}function Oe(e,t){return`rgba(${e.family==="structural"?"125, 211, 252":e.family==="contextual"?"45, 212, 191":e.family==="taxonomy"?"192, 132, 252":e.family==="workspace"?"251, 191, 36":"148, 163, 184"}, ${t})`}function $t({input:e,rendererMode:t,visibleNodeIds:n,focusPressureByNodeId:s,boundsCenter:u,focusedNodePosition:o,camera:c,nodeScreenPositions:l}){const i=Ot({centroid:e.centroid,boundsCenter:u,camera:c});window.__FORGE_KNOWLEDGE_GRAPH_DIAGNOSTICS__={datasetSignature:e.datasetSignature,visibleNodeIds:n,visibleNodeCount:n.length,focusedNodeId:e.focusNodeId,primaryFocusedNodeId:e.primaryFocusedNodeId,draggedNodeId:e.draggedNodeId,layoutGeneration:e.layoutGeneration,rendererMode:t,startupPhase:e.startupPhase,startupInvariantSatisfied:e.startupInvariantSatisfied,simulationPhase:e.simulationPhase,focusSources:e.focusSources,focusPressureByNodeId:s,graphCentroid:e.centroid,boundsCenter:u,focusedNodePosition:o,cameraTarget:e.cameraTarget,cameraFollowError:e.cameraTarget?{x:Number((c.x-e.cameraTarget.x).toFixed(4)),y:Number((c.y-e.cameraTarget.y).toFixed(4)),ratio:Number((c.ratio-e.cameraTarget.ratio).toFixed(4))}:null,camera:c,nodeScreenPositions:l,centroidDistanceFromOrigin:i.centroidDistanceFromOrigin,boundsCenterDistanceFromOrigin:i.boundsCenterDistanceFromOrigin,cameraDistanceFromOrigin:i.cameraDistanceFromOrigin,cameraToCentroidDistance:i.cameraToCentroidDistance,latestSnapshotAt:e.latestSnapshotAt,latestSnapshotNodeCount:e.latestSnapshotNodeCount}}function la(){if(typeof window>"u")return!1;if(window.__FORGE_ENABLE_GRAPH_DIAGNOSTICS__)return!0;try{return new URLSearchParams(window.location.search).get("graphDiagnostics")==="1"}catch{return!1}}function _t(){typeof window>"u"||(delete window.__FORGE_KNOWLEDGE_GRAPH_DIAGNOSTICS__,delete window.__FORGE_KNOWLEDGE_GRAPH_TEST_API__)}function ua(e){const t=[],n={},s={};let u=null;e.graph.forEachNode(c=>{t.push(c);const l=e.sigma.getNodeDisplayData(c),i=e.graph.getNodeAttributes(c),m=e.sigma.graphToViewport({x:i.x,y:i.y});n[c]={x:m.x,y:m.y,size:(l==null?void 0:l.size)??i.size},s[c]=Number((e.focusPressure[t.length-1]??0).toFixed(4)),c===e.primaryFocusedNodeId&&(u={x:i.x,y:i.y})});const o=dt(t.map(c=>{const l=e.graph.getNodeAttributes(c);return{x:l.x,y:l.y}}));$t({input:e,rendererMode:"sigma",visibleNodeIds:t,focusPressureByNodeId:s,boundsCenter:o,focusedNodePosition:u,camera:e.sigma.getCamera().getState(),nodeScreenPositions:n})}function Rt(e){const t=e.snapshot.nodes.map(o=>o.id),n={},s={};let u=null;e.snapshot.nodes.forEach((o,c)=>{n[o.id]=Lt({node:o,snapshot:e.snapshot,camera:e.camera,width:e.width,height:e.height}),s[o.id]=Number((e.focusPressure[c]??0).toFixed(4)),o.id===e.primaryFocusedNodeId&&(u={x:o.x,y:o.y})}),$t({input:e,rendererMode:"fallback",visibleNodeIds:t,focusPressureByNodeId:s,boundsCenter:dt(e.snapshot.nodes.map(o=>({x:o.x,y:o.y}))),focusedNodePosition:u,camera:e.camera,nodeScreenPositions:n})}function Gt(e){const t=ot.indexOf(e);return t>=0?t:ot.length-1}function da(e){const t=Be.find(n=>n.kinds.some(s=>s===e))??Be[Be.length-1];return{laneId:t.id,laneLabel:t.label,laneIndex:Be.findIndex(n=>n.id===t.id)}}function Je(){return{structural:0,contextual:0,taxonomy:0,workspace:0}}function pa(e){const t=new Map;for(const n of e){const s=t.get(n.source)??new Set;s.add(n.target),t.set(n.source,s);const u=t.get(n.target)??new Set;u.add(n.source),t.set(n.target,u)}return t}function ha(e,t){return t.strength-e.strength||e.relationKind.localeCompare(t.relationKind)||e.label.localeCompare(t.label)||e.id.localeCompare(t.id)}function Yt(e){const t=new Map;for(const n of e){const s=`${n.source}→${n.target}`,u=t.get(s)??[];u.push(n),t.set(s,u)}return Array.from(t.entries()).map(([n,s])=>{const u=[...s].sort(ha),o=u[0],c=u.length,l=Math.max(...u.map(i=>i.strength))*Math.min(1.45,1+(c-1)*.12);return{id:`${n}#${o.id}`,source:o.source,target:o.target,relationKind:o.relationKind,family:o.family,label:c>1?`${o.label} +${c-1}`:o.label,strength:l,directional:o.directional,structural:o.structural,parallelCount:c,data:u}}).sort((n,s)=>n.source.localeCompare(s.source)||n.target.localeCompare(s.target)||n.id.localeCompare(s.id))}function ga(e,t){const n=Yt(t),s=[...e].sort((o,c)=>{var l;return o.id.localeCompare(c.id)||((l=o.updatedAt)==null?void 0:l.localeCompare(c.updatedAt??""))||0}).map(o=>`${o.id}:${o.title}:${o.size}:${o.importance}:${o.updatedAt??""}`).join("|"),u=n.map(o=>`${o.source}:${o.target}:${o.parallelCount}:${o.label}:${o.strength.toFixed(3)}`).join("|");return`${e.length}/${n.length}/${s}::${u}`}function Ht(e,t){const n=[...e].sort((l,i)=>{const m=Gt(l.entityKind)-Gt(i.entityKind);return m!==0?m:i.importance-l.importance||l.title.localeCompare(i.title)}),s=new Map,u=n.map(l=>{const{laneId:i,laneIndex:m,laneLabel:g}=da(l.entityKind),b=s.get(m)??0;return s.set(m,b+1),{...l,layer:m,laneId:i,laneLabel:g,row:b}}),o=new Map(u.map(l=>[l.id,l])),c=t.map(l=>{const i=o.get(l.source),m=o.get(l.target),g=(i==null?void 0:i.layer)??0,b=(m==null?void 0:m.layer)??0;return{...l,secondary:b<=g||l.family!=="structural"&&l.family!=="taxonomy"}});return{nodes:u,edges:c}}function Mt(e,t,n){const s=new Map(e.map(f=>[f.id,f])),u=n?s.get(n)??null:null;if(!u)return{generatedAt:new Date().toISOString(),focusNode:null,firstRingNodes:[],neighborhoodEdges:[],familyGroups:[],relationCounts:Je(),secondRingCounts:Je()};const o=t.filter(f=>f.source===u.id||f.target===u.id),c=Array.from(new Set(o.flatMap(f=>f.source===u.id?[f.target]:[f.source]))),l=c.map(f=>s.get(f)??null).filter(f=>!!f),i=new Map,m=Je(),g=Je(),b=pa(t);for(const f of c){const N=b.get(f)??new Set;for(const F of N){if(F===u.id||c.includes(F))continue;const j=t.filter(z=>z.source===f&&z.target===F||z.target===f&&z.source===F);for(const z of j)g[z.family]+=1}}for(const f of o){const N=f.source===u.id?f.target:f.source,F=s.get(N);if(!F)continue;m[f.family]+=1;const j=i.get(f.relationKind);if(j){j.items.some(z=>z.id===F.id)||j.items.push(F);continue}i.set(f.relationKind,{relationKind:f.relationKind,family:f.family,label:vr[f.relationKind],items:[F]})}const G=new Map;for(const f of i.values()){const N=G.get(f.family);if(N){N.relations.push({...f,items:[...f.items].sort((F,j)=>F.title.localeCompare(j.title))}),N.itemCount+=f.items.length,N.relationCount+=1;continue}G.set(f.family,{family:f.family,label:wr[f.family],relationCount:1,itemCount:f.items.length,relations:[{...f,items:[...f.items].sort((F,j)=>F.title.localeCompare(j.title))}]})}return{generatedAt:new Date().toISOString(),focusNode:u,firstRingNodes:l.sort((f,N)=>f.title.localeCompare(N.title)),neighborhoodEdges:o,familyGroups:[...G.values()].map(f=>({...f,relations:f.relations.sort((N,F)=>N.label.localeCompare(F.label))})).sort((f,N)=>f.label.localeCompare(N.label)),relationCounts:m,secondRingCounts:g}}function fa(e,t){return Nr(e,t)}function ma(e,t){if(!e)return new Set;const n=new Set([e]);for(const s of t)s.source===e?n.add(s.target):s.target===e&&n.add(s.source);return n}const xa=h.forwardRef(function({nodes:t,edges:n,focusNodeId:s,physicsSettings:u,onSelectNode:o},c){Pt(),ct(d=>d.knowledgeGraphDiagnostics.panelOpen);const l=h.useRef(null),i=h.useRef(null),m=h.useRef(null),g=h.useRef(null),b=h.useRef(new Map),G=h.useRef(new Map),f=h.useRef(new Map),N=h.useRef(o),F=h.useRef(s),j=h.useRef(null),z=h.useRef(0),M=h.useRef(null),L=h.useRef(0),me=h.useRef(!0),k=h.useRef(null),ce=h.useRef(0),A=h.useRef("global"),xe=h.useRef(null),Pe=h.useRef([]),Me=h.useRef(new Float32Array(0)),we=h.useRef({x:0,y:0}),$=h.useRef("boot"),Ne=h.useRef(!1),Y=h.useRef(!1),P=h.useRef(!1),te=h.useRef(null),le=h.useRef(null),ke=h.useRef(0),Se=h.useRef(0);h.useRef(0),h.useRef(Tt("/knowledge-graph"));const[Q,ue]=h.useState(null),[ye,de]=h.useState(null),[pe,H]=h.useState(null),[he,V]=h.useState({x:0,y:0,angle:0,ratio:1}),[y,B]=h.useState(null),[w,We]=h.useState({width:0,height:0}),Fe=Dt(),re=(d=g.current)=>zt({positions:d?Et(d):new Map,currentRatio:1}).ratio,Te=(d=g.current)=>({x:.5,y:.5,angle:0,ratio:re(d)}),De=(d=g.current)=>({x:0,y:0,angle:0,ratio:re(d)}),ze=()=>i.current?"sigma":"fallback",T=h.useMemo(()=>Yt(n),[n]),ge=h.useMemo(()=>ga(t,n),[n,t]),q=h.useMemo(()=>s?Nt(T,s):null,[s,T]),ae=h.useMemo(()=>s?new Set([s,...(q==null?void 0:q.firstRing)??[]]):new Set,[s,q]),ne=h.useMemo(()=>s?new Set([s,...(q==null?void 0:q.firstRing)??[],...(q==null?void 0:q.secondRing)??[]]):new Set,[s,q]),Ue=()=>jt(l.current,w),se=({resize:d=!1}={})=>{if(!i.current||!Ue())return!1;try{return d&&i.current.resize(),i.current.refresh(),!0}catch(x){if(x instanceof Error&&x.message.includes("Container has no width"))return!1;throw x}},Le=()=>Date.now()<L.current,D=({level:d,eventKey:x,message:v,details:E,publishBackend:C=!1})=>{},st=()=>i.current?{...i.current.getCamera().getState()}:{...he},be=({rendererMode:d})=>{if(!g.current||!j.current)return null;const x=g.current,v=x.nodes().map(S=>{const I=x.getNodeAttributes(S);return{id:S,x:I.x,y:I.y}}),E=Sr(v),C=dt(v),K=st(),O=d==="sigma"?{...K,x:Number((K.x-.5).toFixed(4)),y:Number((K.y-.5).toFixed(4))}:K,R=Ot({centroid:E,boundsCenter:C,camera:O});return{datasetSignature:j.current,route:"/knowledge-graph",rendererMode:d,startupPhase:$.current,startupInvariantSatisfied:Cr(R),visibleNodeCount:v.length,focusedNodeId:F.current,primaryFocusedNodeId:xe.current,graphCentroid:E,boundsCenter:C,camera:K,cameraTarget:k.current?{x:k.current.x,y:k.current.y,ratio:k.current.ratio}:null,driftMetrics:R,latestSnapshotAt:te.current,lastVerifiedAt:new Date().toISOString()}},qe=(d,{mirrorToConsole:x=!1}={})=>{},Qe=({rendererMode:d,publishAnomaly:x})=>{},$e=()=>{const d=i.current?Te():De();if(i.current){i.current.getCamera().setState(d);return}V(d)},a=d=>{var C;if(!g.current)return!1;const x=be({rendererMode:ze()});if(!x)return!1;const v=x.graphCentroid.x,E=x.graphCentroid.y;return Math.abs(v)<1e-4&&Math.abs(E)<1e-4?!1:(Ct(g.current),Ve(g.current,b.current),(C=m.current)==null||C.postMessage({type:"recenter-graph",offsetX:v,offsetY:E}),B(Ae(g.current,T)),$e(),$.current="startup_corrected",D({level:"warning",eventKey:"startup_corrected",message:"Corrected the knowledge graph startup bias back to graph-space origin.",publishBackend:!0,details:{datasetSignature:j.current}}),!0)},p=({phase:d,allowCorrection:x,publishBackendOnFailure:v=!1})=>{if(!g.current||!j.current)return;$.current=d;const E=i.current?"sigma":"fallback",C=be({rendererMode:E});if(!C)return;if(C.startupInvariantSatisfied){$.current="startup_verified",qe({...C},{mirrorToConsole:!0}),D({level:"info",eventKey:"startup_verified",message:"Knowledge graph startup invariant passed.",details:{datasetSignature:C.datasetSignature,driftMetrics:C.driftMetrics}});return}if(D({level:"warning",eventKey:"startup_invariant_failed",message:"Knowledge graph startup invariant failed before correction.",publishBackend:v,details:{datasetSignature:C.datasetSignature,driftMetrics:C.driftMetrics,centroid:C.graphCentroid,boundsCenter:C.boundsCenter,camera:C.camera}}),Ne.current||(Ne.current=!0,!a()))return;se();const O=be({rendererMode:E});if(O){if(O.startupInvariantSatisfied){$.current="startup_verified",qe({...O},{mirrorToConsole:!0}),D({level:"info",eventKey:"startup_verified_after_correction",message:"Knowledge graph startup invariant passed after correction.",details:{datasetSignature:O.datasetSignature,driftMetrics:O.driftMetrics}});return}D({level:"error",eventKey:"startup_correction_failed",message:"Knowledge graph startup correction did not restore the origin invariant.",publishBackend:!0,details:{datasetSignature:O.datasetSignature,driftMetrics:O.driftMetrics,centroid:O.graphCentroid,boundsCenter:O.boundsCenter,camera:O.camera}})}},_=()=>{var x,v,E,C;if(!j.current||!g.current)return;const d=Date.now();if(!(d-Se.current<1500)){if(Se.current=d,i.current){ua({datasetSignature:j.current,focusNodeId:F.current,primaryFocusedNodeId:xe.current,draggedNodeId:((x=M.current)==null?void 0:x.nodeId)??null,graph:g.current,layoutGeneration:z.current,sigma:i.current,startupPhase:$.current,startupInvariantSatisfied:((v=be({rendererMode:"sigma"}))==null?void 0:v.startupInvariantSatisfied)??!1,simulationPhase:A.current,focusSources:Pe.current,focusPressure:Me.current,centroid:we.current,cameraTarget:k.current?{x:k.current.x,y:k.current.y,ratio:k.current.ratio}:null,latestSnapshotAt:te.current,latestSnapshotNodeCount:le.current});return}y&&Rt({datasetSignature:j.current,focusNodeId:F.current,primaryFocusedNodeId:xe.current,draggedNodeId:((E=M.current)==null?void 0:E.nodeId)??null,layoutGeneration:z.current,camera:he,snapshot:y,width:w.width,height:w.height,startupPhase:$.current,startupInvariantSatisfied:((C=be({rendererMode:"fallback"}))==null?void 0:C.startupInvariantSatisfied)??!1,simulationPhase:A.current,focusSources:Pe.current,focusPressure:Me.current,centroid:we.current,cameraTarget:k.current?{x:k.current.x,y:k.current.y,ratio:k.current.ratio}:null,latestSnapshotAt:te.current,latestSnapshotNodeCount:le.current})}},Ye=()=>{if(!g.current||!F.current){k.current=null;return}const d=g.current;if(!d.hasNode(F.current)){k.current=null;return}const x=Et(d),v=Nt(T,F.current),E=i.current?i.current.getCamera().getState().ratio:he.ratio,C=ea({positions:x,focusNodeId:F.current,firstRingNodeIds:v.firstRing,secondRingNodeIds:v.secondRing,currentRatio:E}),K=i.current&&C?Wr({positions:x,point:{x:C.x,y:C.y}}):null;k.current=C?{x:(K==null?void 0:K.x)??C.x,y:(K==null?void 0:K.y)??C.y,angle:0,ratio:C.ratio,nodeIds:C.nodeIds}:null},pt=(d=220)=>{if(!k.current)return;const x=k.current;if(i.current){const v=i.current.getCamera(),E=v.getState(),C=Date.now()<ce.current;v.animate({x:x.x,y:x.y,ratio:C?E.ratio:x.ratio,angle:0},{duration:d});return}V(v=>({...v,x:x.x,y:x.y,ratio:Date.now()<ce.current?v.ratio:x.ratio}))};h.useEffect(()=>{N.current=o},[o]),h.useEffect(()=>{F.current=s,k.current=null},[s]),h.useEffect(()=>{_t()},[Fe]),h.useEffect(()=>{if(!(!la()||typeof window>"u"))return window.__FORGE_KNOWLEDGE_GRAPH_TEST_API__={selectNode:d=>{var v;const x=d?f.current.get(d)??((v=g.current)!=null&&v.hasNode(d)?g.current.getNodeAttribute(d,"data")??null:null):null;N.current(x)},moveNodeBy:(d,x,v)=>{var O,R;if(!((O=g.current)!=null&&O.hasNode(d)))return;const E=g.current.getNodeAttributes(d),C=E.x+x,K=E.y+v;g.current.mergeNodeAttributes(d,{x:C,y:K}),b.current.set(d,{x:C,y:K}),(R=m.current)==null||R.postMessage({type:"nudge-node",nodeId:d,x:C,y:K}),se(),!i.current&&g.current&&B(Ae(g.current,T))},nudgeCameraBy:(d,x)=>{if(i.current){const v=i.current.getCamera(),E=v.getState();v.animate({x:E.x+d,y:E.y+x,ratio:E.ratio,angle:E.angle},{duration:140});return}V(v=>({...v,x:v.x+d,y:v.y+x}))}},()=>{delete window.__FORGE_KNOWLEDGE_GRAPH_TEST_API__}},[T]),h.useEffect(()=>{if(!l.current||typeof ResizeObserver>"u")return;const d=()=>{l.current&&We({width:l.current.clientWidth,height:l.current.clientHeight})};d();const x=new ResizeObserver(()=>{d()});return x.observe(l.current),()=>x.disconnect()},[]),h.useImperativeHandle(c,()=>({zoomIn:()=>{if(ce.current=Date.now()+1200,i.current){i.current.getCamera().animatedZoom({factor:1.25,duration:160});return}V(d=>({...d,ratio:Math.max(.08,d.ratio*.82)}))},zoomOut:()=>{if(ce.current=Date.now()+1200,i.current){i.current.getCamera().animatedUnzoom({factor:1.25,duration:160});return}V(d=>({...d,ratio:Math.min(4,d.ratio*1.22)}))},fit:()=>{if(k.current=null,i.current){i.current.getCamera().animate(Te(),{duration:220});return}y&&V(ia(y))},recenterOnFocus:()=>{Ye(),k.current&&pt(220)}}),[y,T]),h.useEffect(()=>()=>{var d,x,v;g.current&&Ve(g.current,b.current),i.current&&j.current&&G.current.set(j.current,i.current.getCamera().getState()),(d=m.current)==null||d.postMessage({type:"dispose"}),(x=m.current)==null||x.terminate(),m.current=null,(v=i.current)==null||v.kill(),i.current=null,_t()},[Fe]),h.useEffect(()=>{var K,O;if(!l.current||!jt(l.current,w))return;if(j.current===ge&&g.current!==null){se({resize:!0}),_();return}$.current="boot",Ne.current=!1,Y.current=!1,P.current=!1,te.current=null,le.current=null,ke.current=0,k.current=null,D({level:"info",eventKey:"graph_boot",message:"Bootstrapping a fresh knowledge graph dataset.",details:{nodeCount:t.length,edgeCount:T.length}}),g.current&&Ve(g.current,b.current),i.current&&j.current&&G.current.set(j.current,i.current.getCamera().getState());const x=na(t,T,b.current);if(Ct(x),Ve(x,b.current),g.current=x,f.current=new Map(t.map(R=>[R.id,R])),j.current=ge,z.current+=1,B(Ae(x,T)),$.current="graph_built",D({level:"info",eventKey:"graph_built",message:"Built and centered the knowledge graph structure.",details:{layoutGeneration:z.current}}),!ta())(K=i.current)==null||K.kill(),i.current=null,H("WebGL is unavailable in this browser context."),V(De(x)),p({phase:"graph_built",allowCorrection:!0,publishBackendOnFailure:!0});else try{if(i.current)i.current.setGraph(x),se();else{i.current=new Dr(x,l.current,{renderEdgeLabels:!1,hideEdgesOnMove:!0,hideLabelsOnMove:!0,labelRenderedSizeThreshold:20,labelDensity:.04,labelGridCellSize:120,defaultNodeColor:"#c0c1ff",defaultEdgeColor:"rgba(125, 211, 252, 0.1)",minCameraRatio:.08,maxCameraRatio:4,autoRescale:!1,autoCenter:!1,enableEdgeEvents:!1,enableCameraPanning:!0,zIndex:!0}),D({level:"info",eventKey:"sigma_initialized",message:"Initialized Sigma for the knowledge graph.",details:{datasetSignature:ge}}),i.current.on("clickNode",({node:S})=>{if(Le())return;const I=f.current.get(S)??null;N.current(I)}),i.current.on("clickStage",({event:S})=>{if(Le())return;if(!i.current||!g.current){N.current(null);return}const I=ca({sigma:i.current,graph:g.current,viewportX:S.x,viewportY:S.y});if(I){N.current(f.current.get(I)??null);return}N.current(null)}),i.current.on("downNode",({node:S,event:I,preventSigmaDefault:ie})=>{var oe,X;if(!i.current||!((oe=g.current)!=null&&oe.hasNode(S)))return;ie();const Ke=i.current.viewportToGraph({x:I.x,y:I.y}),Z=g.current.getNodeAttributes(S);M.current={nodeId:S,offsetX:Z.x-Ke.x,offsetY:Z.y-Ke.y,startViewportX:I.x,startViewportY:I.y,currentX:Z.x,currentY:Z.y,moved:!1},me.current=i.current.getSetting("enableCameraPanning")??!0,i.current.setSetting("enableCameraPanning",!1),de(S),ue(S),D({level:"debug",eventKey:"drag_start",message:"Started dragging a knowledge graph node.",details:{nodeId:S}}),(X=m.current)==null||X.postMessage({type:"drag-start",nodeId:S})}),i.current.on("moveBody",({event:S,preventSigmaDefault:I})=>{var X;if(!i.current||!g.current||!M.current)return;I();const ie=i.current.viewportToGraph({x:S.x,y:S.y});Math.hypot(S.x-M.current.startViewportX,S.y-M.current.startViewportY)>3&&(M.current={...M.current,moved:!0});const Z=ie.x+M.current.offsetX,oe=ie.y+M.current.offsetY;M.current={...M.current,currentX:Z,currentY:oe},g.current.mergeNodeAttributes(M.current.nodeId,{x:Z,y:oe}),b.current.set(M.current.nodeId,{x:Z,y:oe}),(X=m.current)==null||X.postMessage({type:"drag-move",nodeId:M.current.nodeId,x:Z,y:oe}),se()});const R=()=>{var ie;if(!i.current||!M.current){M.current=null,de(null);return}const S=M.current.nodeId,I=M.current.moved;i.current.setSetting("enableCameraPanning",me.current),(ie=m.current)==null||ie.postMessage({type:"drag-end",nodeId:S}),D({level:"debug",eventKey:"drag_end",message:"Released a dragged knowledge graph node.",details:{nodeId:S,moved:I}}),M.current=null,de(null),I&&(L.current=Date.now()+220,N.current(f.current.get(S)??null))};i.current.on("upNode",R),i.current.on("upStage",R),i.current.on("leaveStage",R),i.current.on("enterNode",({node:S})=>{ue(S)}),i.current.on("leaveNode",()=>{ue(null)}),i.current.on("afterRender",()=>{Y.current||(Y.current=!0,$.current="first_frame",D({level:"info",eventKey:"first_frame",message:"Knowledge graph rendered its first frame.",details:{datasetSignature:j.current}}),p({phase:"first_frame",allowCorrection:!0,publishBackendOnFailure:!0}),Qe({rendererMode:"sigma",publishAnomaly:!0})),_()})}H(null),B(Ae(x,T)),i.current.getCamera().setState(Te(x))}catch(R){(O=i.current)==null||O.kill(),i.current=null,H(R instanceof Error?R.message:"Graph renderer unavailable."),B(Ae(x,T)),V(De(x)),D({level:"error",eventKey:"sigma_fallback",message:"Fell back from Sigma to the SVG renderer.",publishBackend:!0,details:{reason:R instanceof Error?R.message:"unknown"}}),p({phase:"graph_built",allowCorrection:!0,publishBackendOnFailure:!0})}m.current||(m.current=new Worker(new URL("/forge/assets/knowledge-graph-layout.worker-DRvzPxhP.js",import.meta.url),{type:"module"}),m.current.onmessage=R=>{var oe;if(!g.current)return;const S=R.data;if(S.type==="stats"){A.current=S.phase,xe.current=S.primaryFocusedNodeId,Pe.current=S.focusSources,Me.current=S.focusPressure,we.current=S.centroid,P.current||(P.current=!0,$.current="worker_started",D({level:"info",eventKey:"worker_started",message:"Knowledge graph worker reported its first simulation stats.",details:{datasetSignature:j.current,phase:S.phase}}),p({phase:"worker_started",allowCorrection:!0,publishBackendOnFailure:!0}));return}const I=g.current;let ie=S.x,Ke=S.y;if($.current!=="startup_verified"){const X=oa({x:S.x,y:S.y});X.changed&&(ie=X.x,Ke=X.y,(oe=m.current)==null||oe.postMessage({type:"recenter-graph",offsetX:X.offsetX,offsetY:X.offsetY}),$e(),D({level:"warning",eventKey:"worker_startup_recenter",message:"Recentering worker positions during startup because the graph drifted away from origin.",details:{datasetSignature:j.current,startupPhase:$.current,offsetX:X.offsetX,offsetY:X.offsetY}}))}let Z=0;if(I.updateEachNodeAttributes((X,ar)=>({...ar,x:ie[Z],y:Ke[Z++]}),{attributes:["x","y"]}),M.current&&I.hasNode(M.current.nodeId)){const X=M.current.nodeId;I.mergeNodeAttributes(X,{x:M.current.currentX,y:M.current.currentY})}Ve(I,b.current),i.current?se():B(Ae(I,T))});const v=x.nodes(),E=new Map(v.map((R,S)=>[R,S])),C=St(v,T,s);m.current.postMessage({type:"init-graph",nodes:v.map(R=>{const S=x.getNodeAttributes(R);return{id:R,x:S.x,y:S.y,size:S.size,mass:Math.max(1,S.data.importance/42),importance:S.data.importance}}),edges:T.filter(R=>E.has(R.source)&&E.has(R.target)).map(R=>({source:E.get(R.source),target:E.get(R.target),weight:Math.max(.6,R.strength)})),focusNodeId:s,hopLevels:C,physics:u}),D({level:"debug",eventKey:"worker_init",message:"Posted the graph payload to the layout worker.",details:{nodeCount:v.length,edgeCount:T.length}})},[w.height,w.width,ge,s,t,u,T]),h.useEffect(()=>{if(!m.current||!g.current)return;const d=St(g.current.nodes(),T,s);m.current.postMessage({type:"set-focus",focusNodeId:s,hopLevels:d}),s||(k.current=null)},[s,T]),h.useEffect(()=>{m.current&&m.current.postMessage({type:"update-physics",physics:u})},[u]),h.useEffect(()=>{},[ge,Fe]),h.useEffect(()=>{!i.current||!g.current||(i.current.setSetting("nodeReducer",(d,x)=>{var E;const v=(E=g.current)==null?void 0:E.getNodeAttribute(d,"data");return Zr({nodeId:d,attributes:x,node:v,focusNodeId:s,relatedNodeIds:ne,detailNodeIds:ae,hoveredNodeId:Q,draggedNodeId:ye})}),i.current.setSetting("edgeReducer",(d,x)=>{var E;const v=(E=g.current)==null?void 0:E.getEdgeAttribute(d,"data");return Jr({attributes:x,edge:v,focusNodeId:s,detailNodeIds:ae,relatedNodeIds:ne,hoveredNodeId:Q})}),se())},[ae,ye,s,Q,ne]),h.useEffect(()=>{var d,x;!y||!j.current||w.width<=0||w.height<=0||!pe&&i.current||(Y.current||(Y.current=!0,$.current="first_frame",D({level:"info",eventKey:"fallback_first_frame",message:"Knowledge graph rendered its first fallback frame.",details:{datasetSignature:j.current}}),p({phase:"first_frame",allowCorrection:!0,publishBackendOnFailure:!0})),Rt({datasetSignature:j.current,focusNodeId:s,primaryFocusedNodeId:xe.current,draggedNodeId:((d=M.current)==null?void 0:d.nodeId)??null,layoutGeneration:z.current,camera:he,snapshot:y,width:w.width,height:w.height,startupPhase:$.current,startupInvariantSatisfied:((x=be({rendererMode:"fallback"}))==null?void 0:x.startupInvariantSatisfied)??!1,simulationPhase:A.current,focusSources:Pe.current,focusPressure:Me.current,centroid:we.current,cameraTarget:k.current?{x:k.current.x,y:k.current.y,ratio:k.current.ratio}:null,latestSnapshotAt:te.current,latestSnapshotNodeCount:le.current}))},[w.height,w.width,he,pe,y,s]);const it=h.useMemo(()=>!y||w.width<=0||w.height<=0?[]:y.nodes.map(d=>{const x=Lt({node:d,snapshot:y,camera:he,width:w.width,height:w.height});return{...d,viewportX:x.x,viewportY:x.y,viewportSize:x.size}}),[w.height,w.width,he,y]),ht=h.useMemo(()=>new Map(it.map(d=>[d.id,d])),[it]);return r.jsx("div",{className:"relative h-full w-full overflow-hidden bg-[var(--ui-surface-0)]",children:r.jsx("div",{ref:l,className:"h-full w-full touch-none","aria-label":"Knowledge graph canvas",children:pe&&y?r.jsxs("svg",{className:"h-full w-full",viewBox:`0 0 ${Math.max(w.width,1)} ${Math.max(w.height,1)}`,"aria-hidden":"true",children:[r.jsx("title",{children:"Knowledge graph fallback canvas"}),r.jsx("rect",{x:"0",y:"0",width:Math.max(w.width,1),height:Math.max(w.height,1),fill:"transparent",onClick:()=>N.current(null)}),y.edges.map(d=>{const x=ht.get(d.source),v=ht.get(d.target);if(!x||!v)return null;const E=!!s&&(d.source===s||d.target===s),C=!!Q&&(d.source===Q||d.target===Q),K=s?d.source===s?0:ae.has(d.source)?1:ne.has(d.source)?2:3:0,O=s?d.target===s?0:ae.has(d.target)?1:ne.has(d.target)?2:3:0,R=s?Math.max(K,O):0;return r.jsx("line",{x1:x.viewportX,y1:x.viewportY,x2:v.viewportX,y2:v.viewportY,stroke:E?Oe(d,.24):C?Oe(d,.14):s?R<=1?Oe(d,.09):R===2?Oe(d,.05):Oe(d,.016):Oe(d,.055),strokeWidth:E?1.7:C?1.3:.95},d.id)}),it.map(d=>{const x=s===d.id,v=ne.has(d.id),E=ae.has(d.id),C=Q===d.id,K=!s||v;return r.jsxs("g",{transform:`translate(${d.viewportX}, ${d.viewportY})`,onMouseEnter:()=>ue(d.id),onMouseLeave:()=>ue(null),onClick:O=>{O.stopPropagation();const R=f.current.get(d.id)??null;N.current(R)},style:{cursor:"pointer"},children:[r.jsx("circle",{r:x?d.viewportSize*1.9:C?d.viewportSize*1.3:E?d.viewportSize*1.15:v?d.viewportSize*1.05:d.viewportSize,fill:K?d.color:aa(d.color,.3),stroke:x?"var(--ui-border-strong)":"var(--ui-border-subtle)",strokeWidth:x?2:1}),(x||C||E)&&r.jsx("text",{x:d.viewportSize*1.5,y:4,fill:"var(--ui-ink-strong)",fontSize:"12",children:d.data.title})]},d.id)})]}):null})})}),ya=300,ba=152;function Vt(e,t){return e?ma(e,t):new Set}function va(e,t,n){const s=Ht(e,t),u=Vt(n,t);return s.nodes.map(o=>{const c=o.id===n,l=!n||u.has(o.id);return{id:o.id,draggable:!1,selectable:!1,position:{x:72+o.layer*ya,y:88+o.row*ba},data:{label:r.jsxs("div",{className:"w-[min(17rem,calc(100vw-5rem))] min-w-0 max-w-[17rem] rounded-[22px] border px-4 py-4 shadow-[var(--ui-shadow-soft)] transition",style:{borderColor:c?"var(--ui-border-strong)":"var(--ui-border-subtle)",background:c?"var(--ui-surface-active)":"var(--ui-surface-1)",opacity:l?1:.28},children:[r.jsx("div",{className:"flex flex-wrap items-center gap-2",children:r.jsx(at,{kind:o.entityKind,label:o.entityKind.replaceAll("_"," "),compact:!0,gradient:c})}),r.jsx("div",{className:"mt-3",children:r.jsx(Er,{kind:o.entityKind,label:o.title,className:"max-w-full",lines:2})}),o.subtitle?r.jsx("div",{className:"mt-2 break-words text-sm leading-5 text-[var(--ui-ink-soft)]",children:o.subtitle}):null]})},style:{background:"transparent",border:"none",padding:0}}})}function wa(e,t,n,s){const u=Ht(e,t),o=Vt(n,t);return u.edges.filter(c=>s||!c.secondary).map(c=>{const l=!n||o.has(c.source)||o.has(c.target);return{id:c.id,source:c.source,target:c.target,animated:!c.secondary&&c.family==="structural"&&l,markerEnd:{type:Yr.ArrowClosed,color:c.secondary?"var(--ui-border-subtle)":"var(--ui-border-strong)"},style:{opacity:l?1:.18,stroke:c.secondary?"var(--ui-border-subtle)":c.family==="taxonomy"?"var(--success)":c.family==="structural"?"var(--ui-border-strong)":"var(--primary)",strokeDasharray:c.secondary?"8 6":void 0,strokeWidth:c.secondary?1:c.family==="structural"?1.7:1.2}}})}function Na({nodes:e,edges:t,focusNodeId:n,showSecondaryEdges:s,onSelectNode:u,onOpenNode:o,onNavigateNode:c,isMobile:l}){const i=h.useMemo(()=>va(e,t,n),[t,n,e]),m=h.useMemo(()=>wa(e,t,n,s),[t,n,e,s]),g=h.useMemo(()=>new Map(e.map(b=>[b.id,b])),[e]);return r.jsxs("div",{className:"knowledge-graph-canvas relative h-[44rem] rounded-[28px]",children:[r.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-10 flex gap-4 overflow-x-auto px-6 py-4",children:Be.map(b=>r.jsx("div",{className:"min-w-[min(17rem,calc(100vw-5rem))] rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-2 text-center text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)] shadow-[var(--ui-shadow-soft)] backdrop-blur",children:b.label},b.id))}),r.jsxs(zr,{fitView:!0,fitViewOptions:n?{padding:.24,nodes:[{id:n}]}:{padding:.2},nodes:i,edges:m,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,attributionPosition:"bottom-left",onNodeClick:(b,G)=>{const f=g.get(G.id);f&&u(f)},onNodeDoubleClick:(b,G)=>{const f=g.get(G.id);if(f){if(l){o(f);return}c(f)}},children:[r.jsx(Lr,{showInteractive:!1}),r.jsx($r,{gap:28,size:1,color:"var(--ui-border-subtle)"})]},`${n??"all"}-${s?"all":"primary"}`)]})}const Bt=6,Xt=5,Wt=.92,Ut=5,qt=.15,Qt=2.4,Zt=2,Jt=.8,er=3,ee={focusRepulsion:2.25,focusDiffusion:1.95,focusSpringReductionMax:.34,focusSpringReductionDiffusion:1.85,edgeSpringStrength:1,gravityStrength:1,focusShellSpacing:1};function Ee(e,t,n){return Math.min(Math.max(e,t),n)}function tr(e){return{focusRepulsion:Ee((e==null?void 0:e.focusRepulsion)??ee.focusRepulsion,.6,Bt),focusDiffusion:Ee((e==null?void 0:e.focusDiffusion)??ee.focusDiffusion,.6,Xt),focusSpringReductionMax:Ee((e==null?void 0:e.focusSpringReductionMax)??ee.focusSpringReductionMax,0,Wt),focusSpringReductionDiffusion:Ee((e==null?void 0:e.focusSpringReductionDiffusion)??ee.focusSpringReductionDiffusion,.6,Ut),edgeSpringStrength:Ee((e==null?void 0:e.edgeSpringStrength)??ee.edgeSpringStrength,qt,Qt),gravityStrength:Ee((e==null?void 0:e.gravityStrength)??ee.gravityStrength,0,Zt),focusShellSpacing:Ee((e==null?void 0:e.focusShellSpacing)??ee.focusShellSpacing,Jt,er)}}const nt=2e3,lt=40,ut=2e3,rr="forge.knowledge-graph.physics";function Sa(){if(typeof window>"u")return!1;if(window.__FORGE_ENABLE_GRAPH_DIAGNOSTICS__)return!0;try{return new URLSearchParams(window.location.search).get("graphDiagnostics")==="1"}catch{return!1}}function et(e,t){return Array.from(new Set(e.getAll(t).flatMap(n=>n.split(",")).map(n=>n.trim()).filter(Boolean)))}function U(e,t,n){e.delete(t),n.forEach(s=>e.append(t,s))}function Ca(e){switch(e.entityType){case"workbench_flow":case"workbench_surface":case"wiki_space":return null;default:return Rr(e.entityType,e.entityId)}}function J(e){return e?e.slice(0,10):""}function Ea(){if(typeof window>"u")return ee;try{const e=window.localStorage.getItem(rr);return e?tr(JSON.parse(e)):ee}catch{return ee}}function ja(e){typeof window>"u"||window.localStorage.setItem(rr,JSON.stringify(e))}function _a(e,t,n,s,u){const o=e.find(c=>c.id===t);return o||(!t||!n?null:{id:t,displayName:n,kind:s??"human",accentColor:u??"",handle:n.toLowerCase().replace(/\s+/g,"-"),description:"",createdAt:"",updatedAt:""})}function Ra({entityKinds:e,relationKinds:t,tags:n,owners:s}){return[...e.map(u=>`entity:${u}`),...t.map(u=>`relation:${u}`),...n.map(u=>`tag:${u}`),...s.map(u=>`owner:${u}`)]}function kt(e){const t=[],n=[],s=[],u=[];for(const o of e){const[c,...l]=o.split(":"),i=l.join(":").trim();i&&(c==="entity"?t.push(i):c==="relation"?n.push(i):c==="tag"?s.push(i):c==="owner"&&u.push(i))}return{entityKinds:t,relationKinds:n,tags:s,owners:u}}function Ga(e){const t=new URLSearchParams(e),n=t.get("view")==="hierarchy"?"hierarchy":"graph",s=jr(t.get("focus")),u=s?fa(s.entityType,s.entityId):null,o=et(t,"entityKind"),c=et(t,"relationKind"),l=et(t,"tag"),i=et(t,"owner"),m=t.get("q")??"",g=t.get("updatedFrom"),b=t.get("updatedTo"),G=Number(t.get("limit")??nt),f=Number.isFinite(G)?Math.max(lt,Math.min(ut,G)):nt;return{selectedView:n,focusNodeId:u,selectedKinds:o,selectedRelations:c,selectedTags:l,selectedOwners:i,showHierarchyCrossLinks:t.get("cross")==="1",queryText:m,updatedFrom:g,updatedTo:b,maxNodes:f}}function Ma(e){return{q:e.queryText.trim()||null,entityKinds:[...e.selectedKinds].sort(),relationKinds:[...e.selectedRelations].sort(),tags:[...e.selectedTags].sort(),owners:[...e.selectedOwners].sort(),updatedFrom:e.updatedFrom,updatedTo:e.updatedTo,limit:e.maxNodes,focusNodeId:null}}function Ft(e,t){if(!t){e.delete("focus");return}e.set("focus",_r(t.entityType,t.entityId))}function ka({isMobile:e,currentFocusNodeId:t,nextNodeId:n}){return n?e?t===n?{nextFocusNodeId:n,nextMobileSheetOpen:!0,shouldUpdateFocus:!1}:{nextFocusNodeId:n,nextMobileSheetOpen:!1,shouldUpdateFocus:!0}:{nextFocusNodeId:n,nextMobileSheetOpen:!1,shouldUpdateFocus:t!==n}:{nextFocusNodeId:null,nextMobileSheetOpen:!1,shouldUpdateFocus:t!==null}}const Kt="__clear__";function Fa({isMobile:e,focusNodeId:t,shellOverlayFocusNodeId:n,lastRequestedKey:s}){const u=e?null:t,o=u??Kt;return o===(n??Kt)?{action:"none",nextRequestedKey:o}:s===o?{action:"none",nextRequestedKey:o}:{action:u?"set":"clear",nextRequestedKey:o}}const It="shrink-0 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-2 py-0.5 text-[9px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)] shadow-[var(--ui-shadow-soft)] backdrop-blur",At="flex shrink-0 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-0.5 shadow-[var(--ui-shadow-soft)] backdrop-blur",tt="bg-[var(--ui-accent-soft)] text-[var(--primary)] shadow-[var(--ui-shadow-soft)]",rt="text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",fe="rounded-full border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] shadow-[var(--ui-shadow-soft)] backdrop-blur hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",Ka="fixed inset-0 z-40 bg-[color-mix(in_srgb,var(--ui-scrim)_72%,transparent)] backdrop-blur-xl",Ia="fixed inset-x-4 top-[max(1rem,env(safe-area-inset-top))] z-50 max-h-[calc(100dvh-2rem)] overflow-y-auto rounded-[30px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] shadow-[var(--ui-shadow-floating)] md:left-1/2 md:right-auto md:-translate-x-1/2",Aa="sticky top-0 z-10 flex items-start justify-between gap-4 border-b border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-5 py-4 backdrop-blur-xl",Oa="text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",Pa="font-display text-2xl text-[var(--ui-ink-strong)]",Ta="text-sm leading-6 text-[var(--ui-ink-soft)]",je="grid min-w-0 gap-3 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",_e="text-sm font-medium text-[var(--ui-ink-strong)]",Re="text-xs leading-5 text-[var(--ui-ink-faint)]",Ge="rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-2.5 py-1 text-xs text-[var(--ui-ink-soft)]",Da="rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-info-soft)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]";class za extends h.Component{constructor(t){super(t),this.state={error:null}}static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t){t.resetKey!==this.props.resetKey&&this.state.error!==null&&this.setState({error:null})}render(){return this.state.error?this.props.fallback(this.state.error):this.props.children}}function Ja(){var Qe,$e;const e=Gr(),t=Pt();ct(a=>a.knowledgeGraphDiagnostics);const n=ct(a=>{var p,_;return((_=(p=a.shell.knowledgeGraphOverlayFocus)==null?void 0:p.focusNode)==null?void 0:_.id)??null}),s=nr(),[u,o]=sr(),c=h.useRef(null),l=h.useRef(null),i=h.useRef(null),m=h.useRef(null),g=h.useRef(null);h.useRef(Tt("/knowledge-graph"));const[b,G]=h.useState(()=>typeof window<"u"?window.matchMedia("(max-width: 1023px)").matches:!1),[f,N]=h.useState(!1),[F,j]=h.useState(!1),[z,M]=h.useState(!1),[L,me]=h.useState(!1),[k,ce]=h.useState(""),[A,xe]=h.useState(()=>Ea()),Me=Dt(),we=({level:a,eventKey:p,message:_,details:Ye,publishBackend:pt=!1})=>{};h.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const a=window.matchMedia("(max-width: 1023px)"),p=_=>G(_?_.matches:a.matches);return p(),typeof a.addEventListener=="function"?(a.addEventListener("change",p),()=>a.removeEventListener("change",p)):(a.addListener(p),()=>a.removeListener(p))},[]),h.useEffect(()=>{b||(N(!1),j(!1),l.current=null)},[b]),h.useEffect(()=>{ja(A)},[A]);const $=u.toString(),Ne=h.useMemo(()=>Ga($),[$]),{selectedView:Y,focusNodeId:P,selectedKinds:te,selectedRelations:le,selectedTags:ke,selectedOwners:Se,showHierarchyCrossLinks:Q,queryText:ue,updatedFrom:ye,updatedTo:de,maxNodes:pe}=Ne;h.useEffect(()=>{ce(ue)},[ue]);const H=h.useMemo(()=>Ma(Ne),[Ne]),he=h.useMemo(()=>["forge-knowledge-graph",...e.selectedUserIds,JSON.stringify(H)],[H,e.selectedUserIds]),V=yr({queryKey:he,queryFn:()=>Pr(e.selectedUserIds,H),placeholderData:a=>a,staleTime:6e4,refetchOnWindowFocus:!1}),y=V.data;h.useEffect(()=>{we({level:"info",eventKey:"route_arrival",message:"Arrived on the Knowledge Graph page.",details:{search:u.toString()}})},[]),h.useEffect(()=>{if(!V.isSuccess||!y)return;const a=JSON.stringify({q:H.q,entityKinds:H.entityKinds,relationKinds:H.relationKinds,tags:H.tags,owners:H.owners,updatedFrom:H.updatedFrom,updatedTo:H.updatedTo,limit:H.limit,nodeCount:y.counts.nodeCount,edgeCount:y.counts.edgeCount,filteredNodeCount:y.counts.filteredNodeCount,limited:y.counts.limited});g.current!==a&&(g.current=a,we({level:"info",eventKey:"graph_query_resolved",message:"Knowledge graph query resolved.",details:{nodeCount:y.counts.nodeCount,edgeCount:y.counts.edgeCount,filteredNodeCount:y.counts.filteredNodeCount,limited:y.counts.limited}}))},[y,V.isSuccess,H]),h.useEffect(()=>{!y||!P||y.nodes.some(a=>a.id===P)||(o(a=>{const p=new URLSearchParams(a);return p.delete("focus"),p},{replace:!0}),N(!1),l.current=null)},[P,y,o]),h.useEffect(()=>{if(b){if(!P){l.current=null,N(!1);return}l.current===P&&!f&&(N(!0),l.current=null)}},[P,b,f]);const B=h.useMemo(()=>!y||!P?Mt([],[],null):Mt(y.nodes,y.edges,P),[P,y]);h.useEffect(()=>{var p;const a=Fa({isMobile:b,focusNodeId:((p=B.focusNode)==null?void 0:p.id)??null,shellOverlayFocusNodeId:n,lastRequestedKey:m.current});if(m.current=a.nextRequestedKey,a.action!=="none"){if(a.action==="clear"){t(xt());return}t(Mr(B))}},[t,B,b,n]),h.useEffect(()=>{{i.current=null;return}},[Me,P,B,b]),h.useEffect(()=>()=>{t(xt())},[t]),h.useEffect(()=>{if(!(typeof window>"u")){if(!Sa()){delete window.__FORGE_KNOWLEDGE_GRAPH_PAGE_TEST__;return}return window.__FORGE_KNOWLEDGE_GRAPH_PAGE_TEST__={isMobile:b,mobileSheetOpen:f,focusNodeId:P,selectedView:Y,selectNodeById:a=>{if(!y)return;const p=a?y.nodes.find(_=>_.id===a)??null:null;Ce(p)},activateFocusedNode:()=>{if(!P||!y)return;const a=y.nodes.find(p=>p.id===P)??null;a&&Ce(a)}},()=>{delete window.__FORGE_KNOWLEDGE_GRAPH_PAGE_TEST__}}},[P,b,f,Y]);const w=a=>{o(p=>{const _=new URLSearchParams(p);return a(_),_},{replace:!0})},We=a=>{const p=a.trim();ce(a),w(_=>{p.length>0?_.set("q",p):_.delete("q")})},Ce=a=>{const p=ka({isMobile:b,currentFocusNodeId:P,nextNodeId:(a==null?void 0:a.id)??null});l.current=b&&p.nextMobileSheetOpen?(a==null?void 0:a.id)??null:null,N(p.nextMobileSheetOpen),p.shouldUpdateFocus&&(w(_=>{Ft(_,a)}),b&&j(!1))},Fe=a=>{a.href&&s(a.href)},re=(a,p)=>{xe(_=>tr({..._,[a]:p}))},Te=a=>{const p=Ca(a);p&&s(p)},De=a=>{w(p=>{p.set("view","hierarchy"),Ft(p,a)})},ze=()=>{w(a=>{["q","entityKind","relationKind","tag","owner","updatedFrom","updatedTo","focus"].forEach(p=>a.delete(p)),a.set("limit",String(nt))}),M(!1)};if(V.isLoading&&!y)return r.jsx(kr,{eyebrow:"Knowledge Graph",title:"Loading the Forge world model",description:"Gathering goals, projects, KarpaWiki pages, psyche entities, calendar context, and Workbench flows into one graph."});if(V.isError)return r.jsx(Fr,{eyebrow:"Knowledge Graph",error:V.error,onRetry:()=>void V.refetch()});if(!y)return null;const T=new Map(y.facets.entityKinds.map(a=>[a.value,a])),ge=ot.map(a=>{const p=Kr(a),_=T.get(a),Ye=(_==null?void 0:_.count)??0;return{value:a,label:(_==null?void 0:_.label)??p.label,description:Ye===1?"1 node":`${Ye} nodes`,kind:a}}),q=y.facets.relationKinds.map(a=>({value:a.value,label:a.label,description:`${a.count} links`})),ae=y.facets.tags.map(a=>({value:a.id,label:a.label,description:`${a.count} linked nodes`,badge:r.jsx(at,{kind:"tag",label:a.label,compact:!0,gradient:!1}),menuBadge:r.jsx(at,{kind:"tag",label:a.label,compact:!0,gradient:!1})})),ne=y.facets.owners.map(a=>{const p=_a(e.snapshot.users,a.userId,a.displayName,a.kind,a.accentColor);return{value:a.userId,label:a.displayName,description:`${a.count} nodes`,badge:r.jsx(vt,{user:p,compact:!0}),menuBadge:r.jsx(vt,{user:p,compact:!0})}}),Ue=[...ge.map(a=>({id:`entity:${a.value}`,label:a.label,description:a.description,searchText:`entity kind ${a.label}`,badge:r.jsx(at,{kind:a.kind??"note",label:a.label,compact:!0,gradient:!1})})),...q.map(a=>({id:`relation:${a.value}`,label:a.label,description:a.description,searchText:`relation kind ${a.label}`})),...ae.map(a=>({id:`tag:${a.value}`,label:a.label,description:a.description,searchText:`tag ${a.label}`,badge:a.menuBadge??a.badge})),...ne.map(a=>({id:`owner:${a.value}`,label:a.label,description:a.description,searchText:`owner ${a.label}`,badge:a.menuBadge??a.badge}))],se=Ra({entityKinds:te,relationKinds:le,tags:ke,owners:Se}),Le=y.counts.limited?`${y.counts.nodeCount}/${y.counts.filteredNodeCount} nodes`:`${y.counts.nodeCount}n · ${y.counts.edgeCount}e`,D=y.counts.limited?`${y.counts.nodeCount} visible nodes from ${y.counts.filteredNodeCount} filtered matches`:`${y.counts.nodeCount} nodes and ${y.counts.edgeCount} edges`,st=ue.trim().length>0||te.length>0||le.length>0||ke.length>0||Se.length>0||!!ye||!!de||pe!==nt,be=!b,qe=`${Y}:${y.nodes.map(a=>a.id).join("|")}::${y.edges.map(a=>a.id).join("|")}`;return r.jsxs("div",{className:"h-[calc(100dvh-var(--forge-mobile-nav-clearance)-5.25rem)] overflow-hidden lg:-mt-3 lg:h-[calc(100dvh-10rem)]",children:[r.jsxs("div",{className:"relative h-full bg-[var(--ui-surface-0)]",children:[r.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-30 hidden md:block",children:r.jsx(Ir,{metrics:e.snapshot.metrics})}),r.jsx(za,{resetKey:qe,fallback:a=>r.jsx("div",{className:"grid h-full place-items-center p-6 text-center",children:r.jsxs("div",{className:"grid max-w-lg gap-4 rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-6 shadow-[var(--ui-shadow-floating)]",children:[r.jsx("div",{className:"mx-auto flex size-12 items-center justify-center rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-warning-soft)] text-[var(--warning)]",children:r.jsx(ir,{className:"size-5"})}),r.jsxs("div",{className:"grid gap-2",children:[r.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Graph renderer fallback"}),r.jsx("h2",{className:"text-lg font-semibold text-[var(--ui-ink-strong)]",children:"The graph renderer hit a display error."}),r.jsx("p",{className:"text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Switch to the hierarchy view or reset the current graph filters. The graph will recover automatically when the dataset changes."}),r.jsx("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3 text-left text-xs text-[var(--ui-ink-faint)]",children:a.message})]}),r.jsxs("div",{className:"flex flex-wrap justify-center gap-2",children:[r.jsxs(W,{variant:"primary",size:"sm",onClick:()=>w(p=>{p.set("view","hierarchy")}),children:[r.jsx(or,{className:"size-4"}),"Open hierarchy"]}),r.jsx(W,{variant:"secondary",size:"sm",onClick:ze,children:"Reset graph filters"})]})]})}),children:Y==="graph"?r.jsx(xa,{ref:c,nodes:y.nodes,edges:y.edges,focusNodeId:P,physicsSettings:A,onSelectNode:Ce}):r.jsx("div",{className:"h-full overflow-y-auto px-4 py-4 lg:px-6",children:r.jsx(Na,{nodes:y.nodes,edges:y.edges,focusNodeId:P,showSecondaryEdges:Q,isMobile:b,onSelectNode:Ce,onOpenNode:Ce,onNavigateNode:Fe})})}),b?r.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-20 px-3 pt-2 lg:hidden",children:r.jsxs("div",{className:"pointer-events-auto flex items-center gap-1.5",children:[r.jsx("div",{title:D,className:It,children:Le}),r.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[r.jsxs("div",{className:At,children:[r.jsx("button",{type:"button",className:`rounded-full px-2 py-1 text-[10px] transition ${Y==="graph"?tt:rt}`,onClick:()=>w(a=>{a.set("view","graph")}),children:"Graph"}),r.jsx("button",{type:"button",className:`rounded-full px-2 py-1 text-[10px] transition ${Y==="hierarchy"?tt:rt}`,onClick:()=>w(a=>{a.set("view","hierarchy")}),children:"Hierarchy"})]}),r.jsx(W,{variant:"secondary",size:"sm",className:`h-7 px-2 text-[10px] ${fe}`,onClick:()=>me(!0),"aria-label":"Open graph appearance settings",title:"Graph appearance settings",children:r.jsx(gt,{className:"size-3"})}),r.jsxs(W,{variant:"secondary",size:"sm",className:`h-7 px-2 text-[10px] ${fe}`,onClick:()=>{N(!1),j(!0)},"aria-label":"Open graph filters",children:[r.jsx(ft,{className:"size-3"}),"Search"]})]})]})}):null,be?r.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-20 px-4 pt-3 lg:px-6",children:[r.jsxs("div",{"data-testid":"knowledge-graph-desktop-toolbar",className:"pointer-events-auto flex items-center gap-1.5",children:[r.jsx("div",{"data-testid":"knowledge-graph-count-pill",title:D,className:It,children:Le}),r.jsx("div",{className:"min-w-0 flex-1",children:r.jsx(bt,{title:"",description:"",compact:!0,minimal:!0,hideSummary:!0,query:k,onQueryChange:ce,onQuerySubmit:We,submitLabel:"Search graph",options:Ue,selectedOptionIds:se,onSelectedOptionIdsChange:a=>{const p=kt(a);w(_=>{U(_,"entityKind",p.entityKinds),U(_,"relationKind",p.relationKinds),U(_,"tag",p.tags),U(_,"owner",p.owners)})},resultSummary:"",placeholder:"Type a graph search, then press Enter or the search button"})}),r.jsxs(W,{variant:"secondary",size:"sm",className:`h-7 px-2 text-[10px] ${fe}`,onClick:()=>M(a=>!a),children:[r.jsx(ft,{className:"size-3"}),"Advanced"]}),st?r.jsx(W,{variant:"secondary",size:"sm",className:`h-7 px-2 text-[10px] ${fe}`,onClick:ze,children:"Reset"}):null]}),r.jsx(Hr,{initial:!1,children:z?r.jsx(Vr.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.18,ease:"easeOut"},className:"pointer-events-auto mt-2 ml-auto max-w-[min(54rem,calc(100%-3.5rem))] rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-3 shadow-[var(--ui-shadow-floating)] backdrop-blur",children:r.jsxs("div",{className:"grid gap-3 xl:grid-cols-[minmax(0,1.4fr)_minmax(17rem,1fr)]",children:[r.jsxs("div",{className:"grid gap-3",children:[r.jsx(ve,{options:ge,selectedValues:te,onChange:a=>w(p=>{U(p,"entityKind",a)}),placeholder:"Filter by entity type",emptyMessage:"No entity kinds match the current graph."}),r.jsx(ve,{options:q,selectedValues:le,onChange:a=>w(p=>{U(p,"relationKind",a)}),placeholder:"Filter by relation type",emptyMessage:"No relation kinds match the current graph."}),r.jsx(ve,{options:ae,selectedValues:ke,onChange:a=>w(p=>{U(p,"tag",a)}),placeholder:"Filter by tag",emptyMessage:"No tags are available in the current filtered graph."}),r.jsx(ve,{options:ne,selectedValues:Se,onChange:a=>w(p=>{U(p,"owner",a)}),placeholder:"Filter by owner",emptyMessage:"No owners match the current graph."})]}),r.jsxs("div",{className:"grid gap-3 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3",children:[r.jsxs("div",{className:"grid gap-2",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3 text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:[r.jsx("span",{children:"Max nodes shown"}),r.jsx("span",{children:pe})]}),r.jsx("input",{type:"range",min:lt,max:ut,step:20,value:pe,onChange:a=>w(p=>{p.set("limit",a.target.value)}),className:"w-full accent-[var(--secondary)]"}),r.jsx("div",{className:"text-xs text-[var(--ui-ink-faint)]",children:"The graph stays deterministic under the cap and focus mode redistributes the visible neighborhood around the selected node."})]}),r.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[r.jsxs("div",{className:"grid gap-2",children:[r.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Updated from"}),r.jsx(Ze,{type:"date",value:J(ye),min:J(y.facets.updatedAt.min),max:J(de??y.facets.updatedAt.max),onChange:a=>w(p=>{a.target.value?p.set("updatedFrom",a.target.value):p.delete("updatedFrom")})})]}),r.jsxs("div",{className:"grid gap-2",children:[r.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Updated to"}),r.jsx(Ze,{type:"date",value:J(de),min:J(ye??y.facets.updatedAt.min),max:J(y.facets.updatedAt.max),onChange:a=>w(p=>{a.target.value?p.set("updatedTo",a.target.value):p.delete("updatedTo")})})]})]}),Y==="hierarchy"?r.jsx(W,{variant:Q?"primary":"secondary",size:"sm",className:"h-8 rounded-full px-3 text-xs",onClick:()=>w(a=>{Q?a.delete("cross"):a.set("cross","1")}),children:Q?"Hide cross-links":"Show cross-links"}):null]})]})}):null})]}):null,b?null:r.jsx("div",{className:"pointer-events-none absolute bottom-5 left-4 z-20 lg:left-6",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("div",{className:`pointer-events-auto ${At}`,children:[r.jsx("button",{type:"button",className:`rounded-full px-2.5 py-1.5 text-[10px] transition ${Y==="graph"?tt:rt}`,onClick:()=>w(a=>{a.set("view","graph")}),children:"Graph"}),r.jsx("button",{type:"button",className:`rounded-full px-2.5 py-1.5 text-[10px] transition ${Y==="hierarchy"?tt:rt}`,onClick:()=>w(a=>{a.set("view","hierarchy")}),children:"Hierarchy"})]}),Y==="graph"?r.jsxs(r.Fragment,{children:[r.jsx(W,{variant:"secondary",size:"sm",className:`pointer-events-auto size-8 p-0 ${fe}`,onClick:()=>me(!0),title:"Graph appearance settings","aria-label":"Open graph appearance settings",children:r.jsx(gt,{className:"size-3.5"})}),r.jsx(W,{variant:"secondary",size:"sm",className:`pointer-events-auto size-8 p-0 ${fe}`,onClick:()=>{var a;return(a=c.current)==null?void 0:a.zoomIn()},title:"Zoom in","aria-label":"Zoom in",children:r.jsx(cr,{className:"size-3.5"})}),r.jsx(W,{variant:"secondary",size:"sm",className:`pointer-events-auto size-8 p-0 ${fe}`,onClick:()=>{var a;return(a=c.current)==null?void 0:a.zoomOut()},title:"Zoom out","aria-label":"Zoom out",children:r.jsx(lr,{className:"size-3.5"})}),r.jsx(W,{variant:"secondary",size:"sm",className:`pointer-events-auto size-8 p-0 ${fe}`,onClick:()=>{var a;return(a=c.current)==null?void 0:a.recenterOnFocus()},disabled:!B.focusNode,title:"Recenter","aria-label":"Recenter",children:r.jsx(ur,{className:"size-3.5"})}),r.jsx(W,{variant:"secondary",size:"sm",className:`pointer-events-auto size-8 p-0 ${fe}`,onClick:()=>{var a;return(a=c.current)==null?void 0:a.fit()},title:"Reset camera","aria-label":"Reset camera",children:r.jsx(dr,{className:"size-3.5"})}),null]}):null]})})]}),r.jsx(yt,{open:f&&!!B.focusNode,onOpenChange:N,eyebrow:"Knowledge Graph",title:((Qe=B.focusNode)==null?void 0:Qe.title)??"Focus node",description:(($e=B.focusNode)==null?void 0:$e.subtitle)??"Inspect the selected node and move deeper into the graph.",children:r.jsx(Ar,{focus:B,onOpenPage:a=>{N(!1),Fe(a)},onOpenNotes:a=>{N(!1),Te(a)},onOpenHierarchy:a=>{N(!1),De(a)},onSelectNode:Ce,className:"border-0 bg-transparent p-0 shadow-none"})}),r.jsx(yt,{open:F,onOpenChange:j,eyebrow:"Knowledge Graph",title:"Filter graph",description:"Search the visible graph and adjust the focus cap without covering the canvas all the time.",children:r.jsxs("div",{className:"grid gap-4 pb-2",children:[r.jsx("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-3",children:r.jsx(bt,{title:"",description:"",compact:!0,query:k,onQueryChange:ce,onQuerySubmit:We,submitLabel:"Search graph",options:Ue,selectedOptionIds:se,onSelectedOptionIdsChange:a=>{const p=kt(a);w(_=>{U(_,"entityKind",p.entityKinds),U(_,"relationKind",p.relationKinds),U(_,"tag",p.tags),U(_,"owner",p.owners)})},resultSummary:D,placeholder:"Type a graph search, then press Enter or the search button"})}),r.jsxs("div",{className:"grid gap-3",children:[r.jsx(ve,{options:ge,selectedValues:te,onChange:a=>w(p=>{U(p,"entityKind",a)}),placeholder:"Filter by entity type",emptyMessage:"No entity kinds match the current graph."}),r.jsx(ve,{options:q,selectedValues:le,onChange:a=>w(p=>{U(p,"relationKind",a)}),placeholder:"Filter by relation type",emptyMessage:"No relation kinds match the current graph."}),r.jsx(ve,{options:ae,selectedValues:ke,onChange:a=>w(p=>{U(p,"tag",a)}),placeholder:"Filter by tag",emptyMessage:"No tags are available in the current filtered graph."}),r.jsx(ve,{options:ne,selectedValues:Se,onChange:a=>w(p=>{U(p,"owner",a)}),placeholder:"Filter by owner",emptyMessage:"No owners match the current graph."})]}),r.jsxs("div",{className:"grid gap-3 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-3",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3 text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:[r.jsx("span",{children:"Max nodes shown"}),r.jsx("span",{children:pe})]}),r.jsx("input",{type:"range",min:lt,max:ut,step:20,value:pe,onChange:a=>w(p=>{p.set("limit",a.target.value)}),className:"w-full accent-[var(--secondary)]"}),r.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[r.jsxs("div",{className:"grid gap-2",children:[r.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Updated from"}),r.jsx(Ze,{type:"date",value:J(ye),min:J(y.facets.updatedAt.min),max:J(de??y.facets.updatedAt.max),onChange:a=>w(p=>{a.target.value?p.set("updatedFrom",a.target.value):p.delete("updatedFrom")})})]}),r.jsxs("div",{className:"grid gap-2",children:[r.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Updated to"}),r.jsx(Ze,{type:"date",value:J(de),min:J(ye??y.facets.updatedAt.min),max:J(y.facets.updatedAt.max),onChange:a=>w(p=>{a.target.value?p.set("updatedTo",a.target.value):p.delete("updatedTo")})})]})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(W,{variant:"secondary",size:"sm",onClick:ze,children:"Reset"}),r.jsx(W,{variant:"primary",size:"sm",onClick:()=>j(!1),children:"Done"})]})]})]})}),r.jsx(pr,{open:L,onOpenChange:me,children:r.jsxs(hr,{children:[r.jsx(gr,{className:Ka}),r.jsxs(fr,{className:`${Ia} md:w-[min(40rem,calc(100vw-3rem))]`,children:[r.jsx(mr,{className:"sr-only",children:"Knowledge Graph appearance settings"}),r.jsx(xr,{className:"sr-only",children:"Tune the graph focus physics and appearance response."}),r.jsxs("div",{className:Aa,children:[r.jsxs("div",{className:"grid gap-1",children:[r.jsx("div",{className:Oa,children:"Graph appearance"}),r.jsx("div",{className:Pa,children:"Tune the focus field"}),r.jsx("p",{className:`max-w-xl ${Ta}`,children:"Shape how strongly a focused node opens its neighborhood and how far that pressure diffuses through connected hops."})]}),r.jsx(mt,{asChild:!0,children:r.jsx(Or,{"aria-label":"Close graph appearance settings"})})]}),r.jsxs("div",{className:"grid gap-4 px-5 py-5",children:[r.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[r.jsxs("div",{className:je,children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:_e,children:"Focused repulsion"}),r.jsx("div",{className:Re,children:"Push nearby nodes apart more aggressively while the focused node stays anchored."})]}),r.jsx("div",{className:Ge,children:A.focusRepulsion.toFixed(2)})]}),r.jsx("input",{"aria-label":"Focused repulsion",type:"range",min:"0.6",max:String(Bt),step:"0.05",value:A.focusRepulsion,onChange:a=>re("focusRepulsion",Number(a.target.value)),className:"w-full accent-[var(--secondary)]"})]}),r.jsxs("div",{className:je,children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:_e,children:"Focus diffusion"}),r.jsx("div",{className:Re,children:"Extend the focus field further through multi-hop neighbors and lengthen the reversible transition."})]}),r.jsx("div",{className:Ge,children:A.focusDiffusion.toFixed(2)})]}),r.jsx("input",{"aria-label":"Focus diffusion",type:"range",min:"0.6",max:String(Xt),step:"0.05",value:A.focusDiffusion,onChange:a=>re("focusDiffusion",Number(a.target.value)),className:"w-full accent-[var(--secondary)]"})]}),r.jsxs("div",{className:je,children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:_e,children:"Spring reduction max"}),r.jsx("div",{className:Re,children:"Reduce edge spring constants most strongly around the focused node so its local neighborhood can open more freely."})]}),r.jsx("div",{className:Ge,children:A.focusSpringReductionMax.toFixed(2)})]}),r.jsx("input",{"aria-label":"Spring reduction max",type:"range",min:"0",max:String(Wt),step:"0.02",value:A.focusSpringReductionMax,onChange:a=>re("focusSpringReductionMax",Number(a.target.value)),className:"w-full accent-[var(--secondary)]"})]}),r.jsxs("div",{className:je,children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:_e,children:"Spring reduction diffusion"}),r.jsx("div",{className:Re,children:"Spread that spring softening progressively through first-hop, second-hop, and more distant neighborhoods."})]}),r.jsx("div",{className:Ge,children:A.focusSpringReductionDiffusion.toFixed(2)})]}),r.jsx("input",{"aria-label":"Spring reduction diffusion",type:"range",min:"0.6",max:String(Ut),step:"0.05",value:A.focusSpringReductionDiffusion,onChange:a=>re("focusSpringReductionDiffusion",Number(a.target.value)),className:"w-full accent-[var(--secondary)]"})]}),r.jsxs("div",{className:je,children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:_e,children:"Edge spring strength"}),r.jsx("div",{className:Re,children:"Lower this to loosen graph edges globally and let neighborhoods spread instead of snapping tightly inward."})]}),r.jsx("div",{className:Ge,children:A.edgeSpringStrength.toFixed(2)})]}),r.jsx("input",{"aria-label":"Edge spring strength",type:"range",min:String(qt),max:String(Qt),step:"0.05",value:A.edgeSpringStrength,onChange:a=>re("edgeSpringStrength",Number(a.target.value)),className:"w-full accent-[var(--secondary)]"})]}),r.jsxs("div",{className:je,children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:_e,children:"Gravity strength"}),r.jsx("div",{className:Re,children:"Reduce this to weaken the global inward pull that compacts the whole graph toward the middle."})]}),r.jsx("div",{className:Ge,children:A.gravityStrength.toFixed(2)})]}),r.jsx("input",{"aria-label":"Gravity strength",type:"range",min:"0",max:String(Zt),step:"0.05",value:A.gravityStrength,onChange:a=>re("gravityStrength",Number(a.target.value)),className:"w-full accent-[var(--secondary)]"})]}),r.jsxs("div",{className:je,children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:_e,children:"Focus shell spacing"}),r.jsx("div",{className:Re,children:"Increase this to push focused rings farther outward and visibly open the local structure."})]}),r.jsx("div",{className:Ge,children:A.focusShellSpacing.toFixed(2)})]}),r.jsx("input",{"aria-label":"Focus shell spacing",type:"range",min:String(Jt),max:String(er),step:"0.05",value:A.focusShellSpacing,onChange:a=>re("focusShellSpacing",Number(a.target.value)),className:"w-full accent-[var(--secondary)]"})]})]}),r.jsx("div",{className:Da,children:"The main cramming forces are the edge springs and the inward gravity pull. Lower edge spring strength or gravity strength to let the whole graph breathe more, then raise focus shell spacing and spring-reduction controls when you want a selected neighborhood to open dramatically."}),r.jsxs("div",{className:"flex flex-wrap justify-between gap-3",children:[r.jsx(W,{variant:"secondary",onClick:()=>xe(ee),children:"Reset defaults"}),r.jsx(mt,{asChild:!0,children:r.jsx(W,{variant:"primary",children:"Done"})})]})]})]})]})}),null]})}export{Ja as KnowledgeGraphPage};
1
+ import{r as h,j as r,b6 as nr,bY as sr,ca as ir,cf as or,cg as gt,bj as ft,bX as cr,ch as lr,ci as ur,cj as dr}from"./vendor-BwL6m4SE.js";import{R as pr,P as hr,O as gr,C as fr,T as mr,D as xr,a as mt}from"./ui-B9TWEtCx.js";import{i as yr}from"./state-Bpe5dF3T.js";import{ai as br,aj as dt,ak as Ot,al as vr,am as wr,an as Nr,ao as ot,ap as Be,aq as Pt,ar as ct,as as Tt,at as Dt,au as Sr,av as Cr,b as at,E as Er,aw as jr,ax as _r,ab as Rr,d as Gr,ay as xt,az as Mr,L as kr,e as Fr,a as Kr,V as Ir,B as W,I as Ze,aA as yt,aB as Ar,aC as Or,aD as Pr}from"./index-CQ5r7ZUz.js";import{G as Tr,S as Dr,i as zr,C as Lr,B as $r,M as Yr}from"./graph-BF4IsheG.js";import{E as ve}from"./entity-link-multiselect-DcCvkesQ.js";import{F as bt}from"./faceted-token-search-DldM3-ru.js";import{U as vt}from"./user-badge-CZWtYeMw.js";import{A as Hr,m as Vr}from"./motion-DcgUnXhY.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";import"./use-anchored-overlay-position-BY4kNzPj.js";const Br=Math.PI*(3-Math.sqrt(5)),Xr=.48;function Xe(e,t,n){return Math.min(n,Math.max(t,e))}function Wr({positions:e,point:t}){const n=[...e.values()];if(n.length===0)return{x:.5,y:.5};let s=Number.POSITIVE_INFINITY,u=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY;for(const N of n)s=Math.min(s,N.x),u=Math.max(u,N.x),o=Math.min(o,N.y),c=Math.max(c,N.y);const l=Math.max(u-s,0),i=Math.max(c-o,0),m=Math.max(l,i,1),g=(1-l/m)/2,b=(1-i/m)/2,G=l||1,f=i||1;return{x:Xe((t.x-s)/G*(l/m)+g,0,1),y:Xe((t.y-o)/f*(i/m)+b,0,1)}}function Ur(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function qr({nodes:e,cache:t}){const n=new Map,s=[...e].sort((l,i)=>i.importance-l.importance||l.title.localeCompare(i.title)||l.id.localeCompare(i.id));let u=0,o=0,c=0;if(s.forEach((l,i)=>{const m=t.get(l.id);if(m){n.set(l.id,m),u+=m.x,o+=m.y,c+=1;return}const g=(Ur(l.id)%1e3/1e3-.5)*.22,b=i*Br+g,G=Xr*Math.sqrt(i+1),f={x:Math.cos(b)*G,y:Math.sin(b)*G};n.set(l.id,f),u+=f.x,o+=f.y,c+=1}),c>0){const l=u/c,i=o/c;n.forEach((m,g)=>{n.set(g,{x:m.x-l,y:m.y-i})})}return n}function Qr(e,t){if(e.startsWith("rgb(")&&e.endsWith(")"))return e.replace("rgb(","rgba(").replace(")",`, ${t})`);if(e.startsWith("#")){const n=e.slice(1),s=n.length===3?n.split("").map(l=>`${l}${l}`).join(""):n,u=parseInt(s.slice(0,2),16),o=parseInt(s.slice(2,4),16),c=parseInt(s.slice(4,6),16);return`rgba(${u}, ${o}, ${c}, ${t})`}return e}function Ie(e,t){return`rgba(${e==="structural"?"125, 211, 252":e==="contextual"?"45, 212, 191":e==="taxonomy"?"192, 132, 252":e==="workspace"?"251, 191, 36":"148, 163, 184"}, ${t})`}function wt(e,t){return!t.focusNodeId||e===t.focusNodeId?0:t.detailNodeIds.has(e)?1:t.relatedNodeIds.has(e)?2:3}function Zr({nodeId:e,attributes:t,node:n,focusNodeId:s,relatedNodeIds:u,detailNodeIds:o,hoveredNodeId:c,draggedNodeId:l}){const i=s===e,m=u.has(e),g=o.has(e),b=c===e,G=l===e,f=!s||m,N=t.color;return{...t,label:i||b||G||g?n.title:"",forceLabel:i||b||G||g,highlighted:i||b||G||g,color:f?N:Qr(N,.34),size:G?t.size*2:i?t.size*1.8:b?t.size*1.35:g?t.size*1.16:m?t.size*1.06:t.size,zIndex:G?4:i?3:g||b?2:1}}function Jr({attributes:e,edge:t,focusNodeId:n,detailNodeIds:s,relatedNodeIds:u,hoveredNodeId:o}){const c=!!n&&(t.source===n||t.target===n),l=!!o&&(t.source===o||t.target===o),i={focusNodeId:n,detailNodeIds:s,relatedNodeIds:u},m=n?Math.max(wt(t.source,i),wt(t.target,i)):0,g=c?Ie(t.family,.24):l?Ie(t.family,.14):n?m<=1?Ie(t.family,.09):m===2?Ie(t.family,.05):Ie(t.family,.016):Ie(t.family,.055);return{...e,color:g,size:c?e.size*1.18:l?e.size*1.08:e.size,zIndex:c?2:l?1:0}}function Nt(e,t){const n=new Set,s=new Set;for(const u of e)u.source===t?n.add(u.target):u.target===t&&n.add(u.source);for(const u of e)u.source!==t&&n.has(u.source)&&s.add(u.target),u.target!==t&&n.has(u.target)&&s.add(u.source);return s.delete(t),n.forEach(u=>s.delete(u)),{firstRing:[...n].sort(),secondRing:[...s].sort()}}function St(e,t,n){if(!n)return e.map(()=>-1);const s=new Set(e);if(!s.has(n))return e.map(()=>-1);const u=new Map;for(const l of t){if(!s.has(l.source)||!s.has(l.target))continue;const i=u.get(l.source)??new Set;i.add(l.target),u.set(l.source,i);const m=u.get(l.target)??new Set;m.add(l.source),u.set(l.target,m)}const o=new Map([[n,0]]);let c=[n];for(;c.length>0;){const l=[];for(const i of c){const m=o.get(i);for(const g of u.get(i)??[])o.has(g)||(o.set(g,m+1),l.push(g))}c=l}return e.map(l=>o.get(l)??-1)}function ea({positions:e,focusNodeId:t,firstRingNodeIds:n,secondRingNodeIds:s,currentRatio:u}){const o=e.get(t);if(!o)return null;const c=[t,...n,...s].filter((L,me,k)=>k.indexOf(L)===me),l=c.map(L=>e.get(L)).filter(Boolean);if(l.length===0)return null;let i=Number.POSITIVE_INFINITY,m=Number.NEGATIVE_INFINITY,g=Number.POSITIVE_INFINITY,b=Number.NEGATIVE_INFINITY,G=Number.POSITIVE_INFINITY,f=Number.NEGATIVE_INFINITY,N=Number.POSITIVE_INFINITY,F=Number.NEGATIVE_INFINITY;for(const L of e.values())G=Math.min(G,L.x),f=Math.max(f,L.x),N=Math.min(N,L.y),F=Math.max(F,L.y);for(const L of l)i=Math.min(i,L.x),m=Math.max(m,L.x),g=Math.min(g,L.y),b=Math.max(b,L.y);const j=Math.max(m-i,b-g,.75),z=Math.max(f-G,F-N,j),M=l.length<=1?Xe(Math.max(u,.48),.38,.6):Xe(j/z*3.2,.42,Math.max(u,1.12));return{x:o.x,y:o.y,ratio:M,nodeIds:c}}function zt({positions:e,currentRatio:t=1}){const n=[...e.values()];if(n.length===0)return{x:0,y:0,ratio:t};let s=Number.POSITIVE_INFINITY,u=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY;for(const m of n)s=Math.min(s,m.x),u=Math.max(u,m.x),o=Math.min(o,m.y),c=Math.max(c,m.y);const l=Math.max(u-s,c-o,1),i=Xe(l/6.4,.72,2.8);return{x:0,y:0,ratio:Math.max(t,i)}}let He=null;function ta(){if(He!==null)return He;if(typeof document>"u")return He=!1,!1;const e=document.createElement("canvas");return He=!!(e.getContext("webgl2")||e.getContext("webgl")||e.getContext("experimental-webgl")),He}function ra(e){if(!e||typeof window>"u")return"#c0c1ff";const t=document.body?getComputedStyle(document.body).getPropertyValue(e).trim():"",n=getComputedStyle(document.documentElement).getPropertyValue(e).trim(),s=t||n;return s?`rgb(${s})`:"#c0c1ff"}function aa(e,t){if(e.startsWith("rgb(")&&e.endsWith(")"))return e.replace("rgb(","rgba(").replace(")",`, ${t})`);if(e.startsWith("#")){const n=e.slice(1),s=n.length===3?n.split("").map(l=>`${l}${l}`).join(""):n,u=parseInt(s.slice(0,2),16),o=parseInt(s.slice(2,4),16),c=parseInt(s.slice(4,6),16);return`rgba(${u}, ${o}, ${c}, ${t})`}return e}function Ve(e,t){e.forEachNode(n=>{const s=e.getNodeAttributes(n);Number.isFinite(s.x)&&Number.isFinite(s.y)&&t.set(n,{x:s.x,y:s.y})})}function na(e,t,n){const s=new Tr,u=[...e].sort((c,l)=>l.importance-c.importance||c.title.localeCompare(l.title)||c.id.localeCompare(l.id)),o=qr({nodes:u,cache:n});return u.forEach(c=>{const l=o.get(c.id);s.addNode(c.id,{x:(l==null?void 0:l.x)??0,y:(l==null?void 0:l.y)??0,size:Math.max(2.5,c.size/14),color:ra(c.accentToken),label:c.title,hidden:!1,forceLabel:!1,highlighted:!1,zIndex:0,data:c})}),t.forEach(c=>{!s.hasNode(c.source)||!s.hasNode(c.target)||s.addEdgeWithKey(c.id,c.source,c.target,{size:Math.max(.8,c.strength*1.6),color:c.family==="structural"?"rgba(125, 211, 252, 0.055)":c.family==="contextual"?"rgba(45, 212, 191, 0.055)":c.family==="taxonomy"?"rgba(192, 132, 252, 0.055)":c.family==="workspace"?"rgba(251, 191, 36, 0.055)":"rgba(148, 163, 184, 0.055)",label:c.label,hidden:!1,forceLabel:!1,zIndex:0,data:c})}),s}function Ct(e){if(e.order===0)return;let t=0,n=0,s=0;if(e.forEachNode(c=>{const l=e.getNodeAttributes(c);t+=l.x,n+=l.y,s+=1}),s===0)return;const u=t/s,o=n/s;Math.abs(u)<1e-4&&Math.abs(o)<1e-4||e.updateEachNodeAttributes((c,l)=>({...l,x:l.x-u,y:l.y-o}),{attributes:["x","y"]})}function Et(e){const t=new Map;return e.forEachNode(n=>{const s=e.getNodeAttributes(n);t.set(n,{x:s.x,y:s.y})}),t}function Ae(e,t){return{nodes:e.nodes().map(n=>({id:n,...e.getNodeAttributes(n)})),edges:t}}function sa(e){if(e.nodes.length===0)return{minX:-1,maxX:1,minY:-1,maxY:1};let t=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,s=Number.POSITIVE_INFINITY,u=Number.NEGATIVE_INFINITY;for(const o of e.nodes)t=Math.min(t,o.x),n=Math.max(n,o.x),s=Math.min(s,o.y),u=Math.max(u,o.y);return{minX:t,maxX:n,minY:s,maxY:u}}function ia(e){const t=zt({positions:new Map(e.nodes.map(n=>[n.id,{x:n.x,y:n.y}])),currentRatio:1});return{x:t.x,y:t.y,angle:0,ratio:t.ratio}}function oa({x:e,y:t}){const n=Array.from({length:e.length},(u,o)=>({x:e[o]??0,y:t[o]??0})),s=br(n);return s.changed?{changed:!0,offsetX:s.offset.x,offsetY:s.offset.y,x:new Float32Array(s.positions.map(u=>u.x)),y:new Float32Array(s.positions.map(u=>u.y))}:{changed:!1,offsetX:0,offsetY:0,x:new Float32Array(e),y:new Float32Array(t)}}function Lt({node:e,snapshot:t,camera:n,width:s,height:u}){const o=sa(t),c=Math.max(1,o.maxX-o.minX),l=Math.max(1,o.maxY-o.minY),i=28,g=Math.min(Math.max(1,s-i*2)/c,Math.max(1,u-i*2)/l)/Math.max(n.ratio,.08);return{x:s/2+(e.x-n.x)*g,y:u/2-(e.y-n.y)*g,size:Math.max(4,e.size*g*.12)}}function jt(e,t){if(!e)return!1;const n=e.clientWidth,s=e.clientHeight,u=e.getBoundingClientRect();return e.isConnected&&t.width>0&&t.height>0&&n>0&&s>0&&u.width>0&&u.height>0&&e.getClientRects().length>0}function ca({sigma:e,graph:t,viewportX:n,viewportY:s}){let u=null,o=Number.POSITIVE_INFINITY;return t.forEachNode(c=>{const l=t.getNodeAttributes(c),i=e.getNodeDisplayData(c);if(!i||l.hidden)return;const m=e.graphToViewport({x:l.x,y:l.y}),g=m.x-n,b=m.y-s,G=Math.hypot(g,b),f=Math.max(i.size*1.8,18);G<=f&&G<o&&(u=c,o=G)}),u}function Oe(e,t){return`rgba(${e.family==="structural"?"125, 211, 252":e.family==="contextual"?"45, 212, 191":e.family==="taxonomy"?"192, 132, 252":e.family==="workspace"?"251, 191, 36":"148, 163, 184"}, ${t})`}function $t({input:e,rendererMode:t,visibleNodeIds:n,focusPressureByNodeId:s,boundsCenter:u,focusedNodePosition:o,camera:c,nodeScreenPositions:l}){const i=Ot({centroid:e.centroid,boundsCenter:u,camera:c});window.__FORGE_KNOWLEDGE_GRAPH_DIAGNOSTICS__={datasetSignature:e.datasetSignature,visibleNodeIds:n,visibleNodeCount:n.length,focusedNodeId:e.focusNodeId,primaryFocusedNodeId:e.primaryFocusedNodeId,draggedNodeId:e.draggedNodeId,layoutGeneration:e.layoutGeneration,rendererMode:t,startupPhase:e.startupPhase,startupInvariantSatisfied:e.startupInvariantSatisfied,simulationPhase:e.simulationPhase,focusSources:e.focusSources,focusPressureByNodeId:s,graphCentroid:e.centroid,boundsCenter:u,focusedNodePosition:o,cameraTarget:e.cameraTarget,cameraFollowError:e.cameraTarget?{x:Number((c.x-e.cameraTarget.x).toFixed(4)),y:Number((c.y-e.cameraTarget.y).toFixed(4)),ratio:Number((c.ratio-e.cameraTarget.ratio).toFixed(4))}:null,camera:c,nodeScreenPositions:l,centroidDistanceFromOrigin:i.centroidDistanceFromOrigin,boundsCenterDistanceFromOrigin:i.boundsCenterDistanceFromOrigin,cameraDistanceFromOrigin:i.cameraDistanceFromOrigin,cameraToCentroidDistance:i.cameraToCentroidDistance,latestSnapshotAt:e.latestSnapshotAt,latestSnapshotNodeCount:e.latestSnapshotNodeCount}}function la(){if(typeof window>"u")return!1;if(window.__FORGE_ENABLE_GRAPH_DIAGNOSTICS__)return!0;try{return new URLSearchParams(window.location.search).get("graphDiagnostics")==="1"}catch{return!1}}function _t(){typeof window>"u"||(delete window.__FORGE_KNOWLEDGE_GRAPH_DIAGNOSTICS__,delete window.__FORGE_KNOWLEDGE_GRAPH_TEST_API__)}function ua(e){const t=[],n={},s={};let u=null;e.graph.forEachNode(c=>{t.push(c);const l=e.sigma.getNodeDisplayData(c),i=e.graph.getNodeAttributes(c),m=e.sigma.graphToViewport({x:i.x,y:i.y});n[c]={x:m.x,y:m.y,size:(l==null?void 0:l.size)??i.size},s[c]=Number((e.focusPressure[t.length-1]??0).toFixed(4)),c===e.primaryFocusedNodeId&&(u={x:i.x,y:i.y})});const o=dt(t.map(c=>{const l=e.graph.getNodeAttributes(c);return{x:l.x,y:l.y}}));$t({input:e,rendererMode:"sigma",visibleNodeIds:t,focusPressureByNodeId:s,boundsCenter:o,focusedNodePosition:u,camera:e.sigma.getCamera().getState(),nodeScreenPositions:n})}function Rt(e){const t=e.snapshot.nodes.map(o=>o.id),n={},s={};let u=null;e.snapshot.nodes.forEach((o,c)=>{n[o.id]=Lt({node:o,snapshot:e.snapshot,camera:e.camera,width:e.width,height:e.height}),s[o.id]=Number((e.focusPressure[c]??0).toFixed(4)),o.id===e.primaryFocusedNodeId&&(u={x:o.x,y:o.y})}),$t({input:e,rendererMode:"fallback",visibleNodeIds:t,focusPressureByNodeId:s,boundsCenter:dt(e.snapshot.nodes.map(o=>({x:o.x,y:o.y}))),focusedNodePosition:u,camera:e.camera,nodeScreenPositions:n})}function Gt(e){const t=ot.indexOf(e);return t>=0?t:ot.length-1}function da(e){const t=Be.find(n=>n.kinds.some(s=>s===e))??Be[Be.length-1];return{laneId:t.id,laneLabel:t.label,laneIndex:Be.findIndex(n=>n.id===t.id)}}function Je(){return{structural:0,contextual:0,taxonomy:0,workspace:0}}function pa(e){const t=new Map;for(const n of e){const s=t.get(n.source)??new Set;s.add(n.target),t.set(n.source,s);const u=t.get(n.target)??new Set;u.add(n.source),t.set(n.target,u)}return t}function ha(e,t){return t.strength-e.strength||e.relationKind.localeCompare(t.relationKind)||e.label.localeCompare(t.label)||e.id.localeCompare(t.id)}function Yt(e){const t=new Map;for(const n of e){const s=`${n.source}→${n.target}`,u=t.get(s)??[];u.push(n),t.set(s,u)}return Array.from(t.entries()).map(([n,s])=>{const u=[...s].sort(ha),o=u[0],c=u.length,l=Math.max(...u.map(i=>i.strength))*Math.min(1.45,1+(c-1)*.12);return{id:`${n}#${o.id}`,source:o.source,target:o.target,relationKind:o.relationKind,family:o.family,label:c>1?`${o.label} +${c-1}`:o.label,strength:l,directional:o.directional,structural:o.structural,parallelCount:c,data:u}}).sort((n,s)=>n.source.localeCompare(s.source)||n.target.localeCompare(s.target)||n.id.localeCompare(s.id))}function ga(e,t){const n=Yt(t),s=[...e].sort((o,c)=>{var l;return o.id.localeCompare(c.id)||((l=o.updatedAt)==null?void 0:l.localeCompare(c.updatedAt??""))||0}).map(o=>`${o.id}:${o.title}:${o.size}:${o.importance}:${o.updatedAt??""}`).join("|"),u=n.map(o=>`${o.source}:${o.target}:${o.parallelCount}:${o.label}:${o.strength.toFixed(3)}`).join("|");return`${e.length}/${n.length}/${s}::${u}`}function Ht(e,t){const n=[...e].sort((l,i)=>{const m=Gt(l.entityKind)-Gt(i.entityKind);return m!==0?m:i.importance-l.importance||l.title.localeCompare(i.title)}),s=new Map,u=n.map(l=>{const{laneId:i,laneIndex:m,laneLabel:g}=da(l.entityKind),b=s.get(m)??0;return s.set(m,b+1),{...l,layer:m,laneId:i,laneLabel:g,row:b}}),o=new Map(u.map(l=>[l.id,l])),c=t.map(l=>{const i=o.get(l.source),m=o.get(l.target),g=(i==null?void 0:i.layer)??0,b=(m==null?void 0:m.layer)??0;return{...l,secondary:b<=g||l.family!=="structural"&&l.family!=="taxonomy"}});return{nodes:u,edges:c}}function Mt(e,t,n){const s=new Map(e.map(f=>[f.id,f])),u=n?s.get(n)??null:null;if(!u)return{generatedAt:new Date().toISOString(),focusNode:null,firstRingNodes:[],neighborhoodEdges:[],familyGroups:[],relationCounts:Je(),secondRingCounts:Je()};const o=t.filter(f=>f.source===u.id||f.target===u.id),c=Array.from(new Set(o.flatMap(f=>f.source===u.id?[f.target]:[f.source]))),l=c.map(f=>s.get(f)??null).filter(f=>!!f),i=new Map,m=Je(),g=Je(),b=pa(t);for(const f of c){const N=b.get(f)??new Set;for(const F of N){if(F===u.id||c.includes(F))continue;const j=t.filter(z=>z.source===f&&z.target===F||z.target===f&&z.source===F);for(const z of j)g[z.family]+=1}}for(const f of o){const N=f.source===u.id?f.target:f.source,F=s.get(N);if(!F)continue;m[f.family]+=1;const j=i.get(f.relationKind);if(j){j.items.some(z=>z.id===F.id)||j.items.push(F);continue}i.set(f.relationKind,{relationKind:f.relationKind,family:f.family,label:vr[f.relationKind],items:[F]})}const G=new Map;for(const f of i.values()){const N=G.get(f.family);if(N){N.relations.push({...f,items:[...f.items].sort((F,j)=>F.title.localeCompare(j.title))}),N.itemCount+=f.items.length,N.relationCount+=1;continue}G.set(f.family,{family:f.family,label:wr[f.family],relationCount:1,itemCount:f.items.length,relations:[{...f,items:[...f.items].sort((F,j)=>F.title.localeCompare(j.title))}]})}return{generatedAt:new Date().toISOString(),focusNode:u,firstRingNodes:l.sort((f,N)=>f.title.localeCompare(N.title)),neighborhoodEdges:o,familyGroups:[...G.values()].map(f=>({...f,relations:f.relations.sort((N,F)=>N.label.localeCompare(F.label))})).sort((f,N)=>f.label.localeCompare(N.label)),relationCounts:m,secondRingCounts:g}}function fa(e,t){return Nr(e,t)}function ma(e,t){if(!e)return new Set;const n=new Set([e]);for(const s of t)s.source===e?n.add(s.target):s.target===e&&n.add(s.source);return n}const xa=h.forwardRef(function({nodes:t,edges:n,focusNodeId:s,physicsSettings:u,onSelectNode:o},c){Pt(),ct(d=>d.knowledgeGraphDiagnostics.panelOpen);const l=h.useRef(null),i=h.useRef(null),m=h.useRef(null),g=h.useRef(null),b=h.useRef(new Map),G=h.useRef(new Map),f=h.useRef(new Map),N=h.useRef(o),F=h.useRef(s),j=h.useRef(null),z=h.useRef(0),M=h.useRef(null),L=h.useRef(0),me=h.useRef(!0),k=h.useRef(null),ce=h.useRef(0),A=h.useRef("global"),xe=h.useRef(null),Pe=h.useRef([]),Me=h.useRef(new Float32Array(0)),we=h.useRef({x:0,y:0}),$=h.useRef("boot"),Ne=h.useRef(!1),Y=h.useRef(!1),P=h.useRef(!1),te=h.useRef(null),le=h.useRef(null),ke=h.useRef(0),Se=h.useRef(0);h.useRef(0),h.useRef(Tt("/knowledge-graph"));const[Q,ue]=h.useState(null),[ye,de]=h.useState(null),[pe,H]=h.useState(null),[he,V]=h.useState({x:0,y:0,angle:0,ratio:1}),[y,B]=h.useState(null),[w,We]=h.useState({width:0,height:0}),Fe=Dt(),re=(d=g.current)=>zt({positions:d?Et(d):new Map,currentRatio:1}).ratio,Te=(d=g.current)=>({x:.5,y:.5,angle:0,ratio:re(d)}),De=(d=g.current)=>({x:0,y:0,angle:0,ratio:re(d)}),ze=()=>i.current?"sigma":"fallback",T=h.useMemo(()=>Yt(n),[n]),ge=h.useMemo(()=>ga(t,n),[n,t]),q=h.useMemo(()=>s?Nt(T,s):null,[s,T]),ae=h.useMemo(()=>s?new Set([s,...(q==null?void 0:q.firstRing)??[]]):new Set,[s,q]),ne=h.useMemo(()=>s?new Set([s,...(q==null?void 0:q.firstRing)??[],...(q==null?void 0:q.secondRing)??[]]):new Set,[s,q]),Ue=()=>jt(l.current,w),se=({resize:d=!1}={})=>{if(!i.current||!Ue())return!1;try{return d&&i.current.resize(),i.current.refresh(),!0}catch(x){if(x instanceof Error&&x.message.includes("Container has no width"))return!1;throw x}},Le=()=>Date.now()<L.current,D=({level:d,eventKey:x,message:v,details:E,publishBackend:C=!1})=>{},st=()=>i.current?{...i.current.getCamera().getState()}:{...he},be=({rendererMode:d})=>{if(!g.current||!j.current)return null;const x=g.current,v=x.nodes().map(S=>{const I=x.getNodeAttributes(S);return{id:S,x:I.x,y:I.y}}),E=Sr(v),C=dt(v),K=st(),O=d==="sigma"?{...K,x:Number((K.x-.5).toFixed(4)),y:Number((K.y-.5).toFixed(4))}:K,R=Ot({centroid:E,boundsCenter:C,camera:O});return{datasetSignature:j.current,route:"/knowledge-graph",rendererMode:d,startupPhase:$.current,startupInvariantSatisfied:Cr(R),visibleNodeCount:v.length,focusedNodeId:F.current,primaryFocusedNodeId:xe.current,graphCentroid:E,boundsCenter:C,camera:K,cameraTarget:k.current?{x:k.current.x,y:k.current.y,ratio:k.current.ratio}:null,driftMetrics:R,latestSnapshotAt:te.current,lastVerifiedAt:new Date().toISOString()}},qe=(d,{mirrorToConsole:x=!1}={})=>{},Qe=({rendererMode:d,publishAnomaly:x})=>{},$e=()=>{const d=i.current?Te():De();if(i.current){i.current.getCamera().setState(d);return}V(d)},a=d=>{var C;if(!g.current)return!1;const x=be({rendererMode:ze()});if(!x)return!1;const v=x.graphCentroid.x,E=x.graphCentroid.y;return Math.abs(v)<1e-4&&Math.abs(E)<1e-4?!1:(Ct(g.current),Ve(g.current,b.current),(C=m.current)==null||C.postMessage({type:"recenter-graph",offsetX:v,offsetY:E}),B(Ae(g.current,T)),$e(),$.current="startup_corrected",D({level:"warning",eventKey:"startup_corrected",message:"Corrected the knowledge graph startup bias back to graph-space origin.",publishBackend:!0,details:{datasetSignature:j.current}}),!0)},p=({phase:d,allowCorrection:x,publishBackendOnFailure:v=!1})=>{if(!g.current||!j.current)return;$.current=d;const E=i.current?"sigma":"fallback",C=be({rendererMode:E});if(!C)return;if(C.startupInvariantSatisfied){$.current="startup_verified",qe({...C},{mirrorToConsole:!0}),D({level:"info",eventKey:"startup_verified",message:"Knowledge graph startup invariant passed.",details:{datasetSignature:C.datasetSignature,driftMetrics:C.driftMetrics}});return}if(D({level:"warning",eventKey:"startup_invariant_failed",message:"Knowledge graph startup invariant failed before correction.",publishBackend:v,details:{datasetSignature:C.datasetSignature,driftMetrics:C.driftMetrics,centroid:C.graphCentroid,boundsCenter:C.boundsCenter,camera:C.camera}}),Ne.current||(Ne.current=!0,!a()))return;se();const O=be({rendererMode:E});if(O){if(O.startupInvariantSatisfied){$.current="startup_verified",qe({...O},{mirrorToConsole:!0}),D({level:"info",eventKey:"startup_verified_after_correction",message:"Knowledge graph startup invariant passed after correction.",details:{datasetSignature:O.datasetSignature,driftMetrics:O.driftMetrics}});return}D({level:"error",eventKey:"startup_correction_failed",message:"Knowledge graph startup correction did not restore the origin invariant.",publishBackend:!0,details:{datasetSignature:O.datasetSignature,driftMetrics:O.driftMetrics,centroid:O.graphCentroid,boundsCenter:O.boundsCenter,camera:O.camera}})}},_=()=>{var x,v,E,C;if(!j.current||!g.current)return;const d=Date.now();if(!(d-Se.current<1500)){if(Se.current=d,i.current){ua({datasetSignature:j.current,focusNodeId:F.current,primaryFocusedNodeId:xe.current,draggedNodeId:((x=M.current)==null?void 0:x.nodeId)??null,graph:g.current,layoutGeneration:z.current,sigma:i.current,startupPhase:$.current,startupInvariantSatisfied:((v=be({rendererMode:"sigma"}))==null?void 0:v.startupInvariantSatisfied)??!1,simulationPhase:A.current,focusSources:Pe.current,focusPressure:Me.current,centroid:we.current,cameraTarget:k.current?{x:k.current.x,y:k.current.y,ratio:k.current.ratio}:null,latestSnapshotAt:te.current,latestSnapshotNodeCount:le.current});return}y&&Rt({datasetSignature:j.current,focusNodeId:F.current,primaryFocusedNodeId:xe.current,draggedNodeId:((E=M.current)==null?void 0:E.nodeId)??null,layoutGeneration:z.current,camera:he,snapshot:y,width:w.width,height:w.height,startupPhase:$.current,startupInvariantSatisfied:((C=be({rendererMode:"fallback"}))==null?void 0:C.startupInvariantSatisfied)??!1,simulationPhase:A.current,focusSources:Pe.current,focusPressure:Me.current,centroid:we.current,cameraTarget:k.current?{x:k.current.x,y:k.current.y,ratio:k.current.ratio}:null,latestSnapshotAt:te.current,latestSnapshotNodeCount:le.current})}},Ye=()=>{if(!g.current||!F.current){k.current=null;return}const d=g.current;if(!d.hasNode(F.current)){k.current=null;return}const x=Et(d),v=Nt(T,F.current),E=i.current?i.current.getCamera().getState().ratio:he.ratio,C=ea({positions:x,focusNodeId:F.current,firstRingNodeIds:v.firstRing,secondRingNodeIds:v.secondRing,currentRatio:E}),K=i.current&&C?Wr({positions:x,point:{x:C.x,y:C.y}}):null;k.current=C?{x:(K==null?void 0:K.x)??C.x,y:(K==null?void 0:K.y)??C.y,angle:0,ratio:C.ratio,nodeIds:C.nodeIds}:null},pt=(d=220)=>{if(!k.current)return;const x=k.current;if(i.current){const v=i.current.getCamera(),E=v.getState(),C=Date.now()<ce.current;v.animate({x:x.x,y:x.y,ratio:C?E.ratio:x.ratio,angle:0},{duration:d});return}V(v=>({...v,x:x.x,y:x.y,ratio:Date.now()<ce.current?v.ratio:x.ratio}))};h.useEffect(()=>{N.current=o},[o]),h.useEffect(()=>{F.current=s,k.current=null},[s]),h.useEffect(()=>{_t()},[Fe]),h.useEffect(()=>{if(!(!la()||typeof window>"u"))return window.__FORGE_KNOWLEDGE_GRAPH_TEST_API__={selectNode:d=>{var v;const x=d?f.current.get(d)??((v=g.current)!=null&&v.hasNode(d)?g.current.getNodeAttribute(d,"data")??null:null):null;N.current(x)},moveNodeBy:(d,x,v)=>{var O,R;if(!((O=g.current)!=null&&O.hasNode(d)))return;const E=g.current.getNodeAttributes(d),C=E.x+x,K=E.y+v;g.current.mergeNodeAttributes(d,{x:C,y:K}),b.current.set(d,{x:C,y:K}),(R=m.current)==null||R.postMessage({type:"nudge-node",nodeId:d,x:C,y:K}),se(),!i.current&&g.current&&B(Ae(g.current,T))},nudgeCameraBy:(d,x)=>{if(i.current){const v=i.current.getCamera(),E=v.getState();v.animate({x:E.x+d,y:E.y+x,ratio:E.ratio,angle:E.angle},{duration:140});return}V(v=>({...v,x:v.x+d,y:v.y+x}))}},()=>{delete window.__FORGE_KNOWLEDGE_GRAPH_TEST_API__}},[T]),h.useEffect(()=>{if(!l.current||typeof ResizeObserver>"u")return;const d=()=>{l.current&&We({width:l.current.clientWidth,height:l.current.clientHeight})};d();const x=new ResizeObserver(()=>{d()});return x.observe(l.current),()=>x.disconnect()},[]),h.useImperativeHandle(c,()=>({zoomIn:()=>{if(ce.current=Date.now()+1200,i.current){i.current.getCamera().animatedZoom({factor:1.25,duration:160});return}V(d=>({...d,ratio:Math.max(.08,d.ratio*.82)}))},zoomOut:()=>{if(ce.current=Date.now()+1200,i.current){i.current.getCamera().animatedUnzoom({factor:1.25,duration:160});return}V(d=>({...d,ratio:Math.min(4,d.ratio*1.22)}))},fit:()=>{if(k.current=null,i.current){i.current.getCamera().animate(Te(),{duration:220});return}y&&V(ia(y))},recenterOnFocus:()=>{Ye(),k.current&&pt(220)}}),[y,T]),h.useEffect(()=>()=>{var d,x,v;g.current&&Ve(g.current,b.current),i.current&&j.current&&G.current.set(j.current,i.current.getCamera().getState()),(d=m.current)==null||d.postMessage({type:"dispose"}),(x=m.current)==null||x.terminate(),m.current=null,(v=i.current)==null||v.kill(),i.current=null,_t()},[Fe]),h.useEffect(()=>{var K,O;if(!l.current||!jt(l.current,w))return;if(j.current===ge&&g.current!==null){se({resize:!0}),_();return}$.current="boot",Ne.current=!1,Y.current=!1,P.current=!1,te.current=null,le.current=null,ke.current=0,k.current=null,D({level:"info",eventKey:"graph_boot",message:"Bootstrapping a fresh knowledge graph dataset.",details:{nodeCount:t.length,edgeCount:T.length}}),g.current&&Ve(g.current,b.current),i.current&&j.current&&G.current.set(j.current,i.current.getCamera().getState());const x=na(t,T,b.current);if(Ct(x),Ve(x,b.current),g.current=x,f.current=new Map(t.map(R=>[R.id,R])),j.current=ge,z.current+=1,B(Ae(x,T)),$.current="graph_built",D({level:"info",eventKey:"graph_built",message:"Built and centered the knowledge graph structure.",details:{layoutGeneration:z.current}}),!ta())(K=i.current)==null||K.kill(),i.current=null,H("WebGL is unavailable in this browser context."),V(De(x)),p({phase:"graph_built",allowCorrection:!0,publishBackendOnFailure:!0});else try{if(i.current)i.current.setGraph(x),se();else{i.current=new Dr(x,l.current,{renderEdgeLabels:!1,hideEdgesOnMove:!0,hideLabelsOnMove:!0,labelRenderedSizeThreshold:20,labelDensity:.04,labelGridCellSize:120,defaultNodeColor:"#c0c1ff",defaultEdgeColor:"rgba(125, 211, 252, 0.1)",minCameraRatio:.08,maxCameraRatio:4,autoRescale:!1,autoCenter:!1,enableEdgeEvents:!1,enableCameraPanning:!0,zIndex:!0}),D({level:"info",eventKey:"sigma_initialized",message:"Initialized Sigma for the knowledge graph.",details:{datasetSignature:ge}}),i.current.on("clickNode",({node:S})=>{if(Le())return;const I=f.current.get(S)??null;N.current(I)}),i.current.on("clickStage",({event:S})=>{if(Le())return;if(!i.current||!g.current){N.current(null);return}const I=ca({sigma:i.current,graph:g.current,viewportX:S.x,viewportY:S.y});if(I){N.current(f.current.get(I)??null);return}N.current(null)}),i.current.on("downNode",({node:S,event:I,preventSigmaDefault:ie})=>{var oe,X;if(!i.current||!((oe=g.current)!=null&&oe.hasNode(S)))return;ie();const Ke=i.current.viewportToGraph({x:I.x,y:I.y}),Z=g.current.getNodeAttributes(S);M.current={nodeId:S,offsetX:Z.x-Ke.x,offsetY:Z.y-Ke.y,startViewportX:I.x,startViewportY:I.y,currentX:Z.x,currentY:Z.y,moved:!1},me.current=i.current.getSetting("enableCameraPanning")??!0,i.current.setSetting("enableCameraPanning",!1),de(S),ue(S),D({level:"debug",eventKey:"drag_start",message:"Started dragging a knowledge graph node.",details:{nodeId:S}}),(X=m.current)==null||X.postMessage({type:"drag-start",nodeId:S})}),i.current.on("moveBody",({event:S,preventSigmaDefault:I})=>{var X;if(!i.current||!g.current||!M.current)return;I();const ie=i.current.viewportToGraph({x:S.x,y:S.y});Math.hypot(S.x-M.current.startViewportX,S.y-M.current.startViewportY)>3&&(M.current={...M.current,moved:!0});const Z=ie.x+M.current.offsetX,oe=ie.y+M.current.offsetY;M.current={...M.current,currentX:Z,currentY:oe},g.current.mergeNodeAttributes(M.current.nodeId,{x:Z,y:oe}),b.current.set(M.current.nodeId,{x:Z,y:oe}),(X=m.current)==null||X.postMessage({type:"drag-move",nodeId:M.current.nodeId,x:Z,y:oe}),se()});const R=()=>{var ie;if(!i.current||!M.current){M.current=null,de(null);return}const S=M.current.nodeId,I=M.current.moved;i.current.setSetting("enableCameraPanning",me.current),(ie=m.current)==null||ie.postMessage({type:"drag-end",nodeId:S}),D({level:"debug",eventKey:"drag_end",message:"Released a dragged knowledge graph node.",details:{nodeId:S,moved:I}}),M.current=null,de(null),I&&(L.current=Date.now()+220,N.current(f.current.get(S)??null))};i.current.on("upNode",R),i.current.on("upStage",R),i.current.on("leaveStage",R),i.current.on("enterNode",({node:S})=>{ue(S)}),i.current.on("leaveNode",()=>{ue(null)}),i.current.on("afterRender",()=>{Y.current||(Y.current=!0,$.current="first_frame",D({level:"info",eventKey:"first_frame",message:"Knowledge graph rendered its first frame.",details:{datasetSignature:j.current}}),p({phase:"first_frame",allowCorrection:!0,publishBackendOnFailure:!0}),Qe({rendererMode:"sigma",publishAnomaly:!0})),_()})}H(null),B(Ae(x,T)),i.current.getCamera().setState(Te(x))}catch(R){(O=i.current)==null||O.kill(),i.current=null,H(R instanceof Error?R.message:"Graph renderer unavailable."),B(Ae(x,T)),V(De(x)),D({level:"error",eventKey:"sigma_fallback",message:"Fell back from Sigma to the SVG renderer.",publishBackend:!0,details:{reason:R instanceof Error?R.message:"unknown"}}),p({phase:"graph_built",allowCorrection:!0,publishBackendOnFailure:!0})}m.current||(m.current=new Worker(new URL("/forge/assets/knowledge-graph-layout.worker-DRvzPxhP.js",import.meta.url),{type:"module"}),m.current.onmessage=R=>{var oe;if(!g.current)return;const S=R.data;if(S.type==="stats"){A.current=S.phase,xe.current=S.primaryFocusedNodeId,Pe.current=S.focusSources,Me.current=S.focusPressure,we.current=S.centroid,P.current||(P.current=!0,$.current="worker_started",D({level:"info",eventKey:"worker_started",message:"Knowledge graph worker reported its first simulation stats.",details:{datasetSignature:j.current,phase:S.phase}}),p({phase:"worker_started",allowCorrection:!0,publishBackendOnFailure:!0}));return}const I=g.current;let ie=S.x,Ke=S.y;if($.current!=="startup_verified"){const X=oa({x:S.x,y:S.y});X.changed&&(ie=X.x,Ke=X.y,(oe=m.current)==null||oe.postMessage({type:"recenter-graph",offsetX:X.offsetX,offsetY:X.offsetY}),$e(),D({level:"warning",eventKey:"worker_startup_recenter",message:"Recentering worker positions during startup because the graph drifted away from origin.",details:{datasetSignature:j.current,startupPhase:$.current,offsetX:X.offsetX,offsetY:X.offsetY}}))}let Z=0;if(I.updateEachNodeAttributes((X,ar)=>({...ar,x:ie[Z],y:Ke[Z++]}),{attributes:["x","y"]}),M.current&&I.hasNode(M.current.nodeId)){const X=M.current.nodeId;I.mergeNodeAttributes(X,{x:M.current.currentX,y:M.current.currentY})}Ve(I,b.current),i.current?se():B(Ae(I,T))});const v=x.nodes(),E=new Map(v.map((R,S)=>[R,S])),C=St(v,T,s);m.current.postMessage({type:"init-graph",nodes:v.map(R=>{const S=x.getNodeAttributes(R);return{id:R,x:S.x,y:S.y,size:S.size,mass:Math.max(1,S.data.importance/42),importance:S.data.importance}}),edges:T.filter(R=>E.has(R.source)&&E.has(R.target)).map(R=>({source:E.get(R.source),target:E.get(R.target),weight:Math.max(.6,R.strength)})),focusNodeId:s,hopLevels:C,physics:u}),D({level:"debug",eventKey:"worker_init",message:"Posted the graph payload to the layout worker.",details:{nodeCount:v.length,edgeCount:T.length}})},[w.height,w.width,ge,s,t,u,T]),h.useEffect(()=>{if(!m.current||!g.current)return;const d=St(g.current.nodes(),T,s);m.current.postMessage({type:"set-focus",focusNodeId:s,hopLevels:d}),s||(k.current=null)},[s,T]),h.useEffect(()=>{m.current&&m.current.postMessage({type:"update-physics",physics:u})},[u]),h.useEffect(()=>{},[ge,Fe]),h.useEffect(()=>{!i.current||!g.current||(i.current.setSetting("nodeReducer",(d,x)=>{var E;const v=(E=g.current)==null?void 0:E.getNodeAttribute(d,"data");return Zr({nodeId:d,attributes:x,node:v,focusNodeId:s,relatedNodeIds:ne,detailNodeIds:ae,hoveredNodeId:Q,draggedNodeId:ye})}),i.current.setSetting("edgeReducer",(d,x)=>{var E;const v=(E=g.current)==null?void 0:E.getEdgeAttribute(d,"data");return Jr({attributes:x,edge:v,focusNodeId:s,detailNodeIds:ae,relatedNodeIds:ne,hoveredNodeId:Q})}),se())},[ae,ye,s,Q,ne]),h.useEffect(()=>{var d,x;!y||!j.current||w.width<=0||w.height<=0||!pe&&i.current||(Y.current||(Y.current=!0,$.current="first_frame",D({level:"info",eventKey:"fallback_first_frame",message:"Knowledge graph rendered its first fallback frame.",details:{datasetSignature:j.current}}),p({phase:"first_frame",allowCorrection:!0,publishBackendOnFailure:!0})),Rt({datasetSignature:j.current,focusNodeId:s,primaryFocusedNodeId:xe.current,draggedNodeId:((d=M.current)==null?void 0:d.nodeId)??null,layoutGeneration:z.current,camera:he,snapshot:y,width:w.width,height:w.height,startupPhase:$.current,startupInvariantSatisfied:((x=be({rendererMode:"fallback"}))==null?void 0:x.startupInvariantSatisfied)??!1,simulationPhase:A.current,focusSources:Pe.current,focusPressure:Me.current,centroid:we.current,cameraTarget:k.current?{x:k.current.x,y:k.current.y,ratio:k.current.ratio}:null,latestSnapshotAt:te.current,latestSnapshotNodeCount:le.current}))},[w.height,w.width,he,pe,y,s]);const it=h.useMemo(()=>!y||w.width<=0||w.height<=0?[]:y.nodes.map(d=>{const x=Lt({node:d,snapshot:y,camera:he,width:w.width,height:w.height});return{...d,viewportX:x.x,viewportY:x.y,viewportSize:x.size}}),[w.height,w.width,he,y]),ht=h.useMemo(()=>new Map(it.map(d=>[d.id,d])),[it]);return r.jsx("div",{className:"relative h-full w-full overflow-hidden bg-[var(--ui-surface-0)]",children:r.jsx("div",{ref:l,className:"h-full w-full touch-none","aria-label":"Knowledge graph canvas",children:pe&&y?r.jsxs("svg",{className:"h-full w-full",viewBox:`0 0 ${Math.max(w.width,1)} ${Math.max(w.height,1)}`,"aria-hidden":"true",children:[r.jsx("title",{children:"Knowledge graph fallback canvas"}),r.jsx("rect",{x:"0",y:"0",width:Math.max(w.width,1),height:Math.max(w.height,1),fill:"transparent",onClick:()=>N.current(null)}),y.edges.map(d=>{const x=ht.get(d.source),v=ht.get(d.target);if(!x||!v)return null;const E=!!s&&(d.source===s||d.target===s),C=!!Q&&(d.source===Q||d.target===Q),K=s?d.source===s?0:ae.has(d.source)?1:ne.has(d.source)?2:3:0,O=s?d.target===s?0:ae.has(d.target)?1:ne.has(d.target)?2:3:0,R=s?Math.max(K,O):0;return r.jsx("line",{x1:x.viewportX,y1:x.viewportY,x2:v.viewportX,y2:v.viewportY,stroke:E?Oe(d,.24):C?Oe(d,.14):s?R<=1?Oe(d,.09):R===2?Oe(d,.05):Oe(d,.016):Oe(d,.055),strokeWidth:E?1.7:C?1.3:.95},d.id)}),it.map(d=>{const x=s===d.id,v=ne.has(d.id),E=ae.has(d.id),C=Q===d.id,K=!s||v;return r.jsxs("g",{transform:`translate(${d.viewportX}, ${d.viewportY})`,onMouseEnter:()=>ue(d.id),onMouseLeave:()=>ue(null),onClick:O=>{O.stopPropagation();const R=f.current.get(d.id)??null;N.current(R)},style:{cursor:"pointer"},children:[r.jsx("circle",{r:x?d.viewportSize*1.9:C?d.viewportSize*1.3:E?d.viewportSize*1.15:v?d.viewportSize*1.05:d.viewportSize,fill:K?d.color:aa(d.color,.3),stroke:x?"var(--ui-border-strong)":"var(--ui-border-subtle)",strokeWidth:x?2:1}),(x||C||E)&&r.jsx("text",{x:d.viewportSize*1.5,y:4,fill:"var(--ui-ink-strong)",fontSize:"12",children:d.data.title})]},d.id)})]}):null})})}),ya=300,ba=152;function Vt(e,t){return e?ma(e,t):new Set}function va(e,t,n){const s=Ht(e,t),u=Vt(n,t);return s.nodes.map(o=>{const c=o.id===n,l=!n||u.has(o.id);return{id:o.id,draggable:!1,selectable:!1,position:{x:72+o.layer*ya,y:88+o.row*ba},data:{label:r.jsxs("div",{className:"w-[min(17rem,calc(100vw-5rem))] min-w-0 max-w-[17rem] rounded-[22px] border px-4 py-4 shadow-[var(--ui-shadow-soft)] transition",style:{borderColor:c?"var(--ui-border-strong)":"var(--ui-border-subtle)",background:c?"var(--ui-surface-active)":"var(--ui-surface-1)",opacity:l?1:.28},children:[r.jsx("div",{className:"flex flex-wrap items-center gap-2",children:r.jsx(at,{kind:o.entityKind,label:o.entityKind.replaceAll("_"," "),compact:!0,gradient:c})}),r.jsx("div",{className:"mt-3",children:r.jsx(Er,{kind:o.entityKind,label:o.title,className:"max-w-full",lines:2})}),o.subtitle?r.jsx("div",{className:"mt-2 break-words text-sm leading-5 text-[var(--ui-ink-soft)]",children:o.subtitle}):null]})},style:{background:"transparent",border:"none",padding:0}}})}function wa(e,t,n,s){const u=Ht(e,t),o=Vt(n,t);return u.edges.filter(c=>s||!c.secondary).map(c=>{const l=!n||o.has(c.source)||o.has(c.target);return{id:c.id,source:c.source,target:c.target,animated:!c.secondary&&c.family==="structural"&&l,markerEnd:{type:Yr.ArrowClosed,color:c.secondary?"var(--ui-border-subtle)":"var(--ui-border-strong)"},style:{opacity:l?1:.18,stroke:c.secondary?"var(--ui-border-subtle)":c.family==="taxonomy"?"var(--success)":c.family==="structural"?"var(--ui-border-strong)":"var(--primary)",strokeDasharray:c.secondary?"8 6":void 0,strokeWidth:c.secondary?1:c.family==="structural"?1.7:1.2}}})}function Na({nodes:e,edges:t,focusNodeId:n,showSecondaryEdges:s,onSelectNode:u,onOpenNode:o,onNavigateNode:c,isMobile:l}){const i=h.useMemo(()=>va(e,t,n),[t,n,e]),m=h.useMemo(()=>wa(e,t,n,s),[t,n,e,s]),g=h.useMemo(()=>new Map(e.map(b=>[b.id,b])),[e]);return r.jsxs("div",{className:"knowledge-graph-canvas relative h-[44rem] rounded-[28px]",children:[r.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-10 flex gap-4 overflow-x-auto px-6 py-4",children:Be.map(b=>r.jsx("div",{className:"min-w-[min(17rem,calc(100vw-5rem))] rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-2 text-center text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)] shadow-[var(--ui-shadow-soft)] backdrop-blur",children:b.label},b.id))}),r.jsxs(zr,{fitView:!0,fitViewOptions:n?{padding:.24,nodes:[{id:n}]}:{padding:.2},nodes:i,edges:m,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,attributionPosition:"bottom-left",onNodeClick:(b,G)=>{const f=g.get(G.id);f&&u(f)},onNodeDoubleClick:(b,G)=>{const f=g.get(G.id);if(f){if(l){o(f);return}c(f)}},children:[r.jsx(Lr,{showInteractive:!1}),r.jsx($r,{gap:28,size:1,color:"var(--ui-border-subtle)"})]},`${n??"all"}-${s?"all":"primary"}`)]})}const Bt=6,Xt=5,Wt=.92,Ut=5,qt=.15,Qt=2.4,Zt=2,Jt=.8,er=3,ee={focusRepulsion:2.25,focusDiffusion:1.95,focusSpringReductionMax:.34,focusSpringReductionDiffusion:1.85,edgeSpringStrength:1,gravityStrength:1,focusShellSpacing:1};function Ee(e,t,n){return Math.min(Math.max(e,t),n)}function tr(e){return{focusRepulsion:Ee((e==null?void 0:e.focusRepulsion)??ee.focusRepulsion,.6,Bt),focusDiffusion:Ee((e==null?void 0:e.focusDiffusion)??ee.focusDiffusion,.6,Xt),focusSpringReductionMax:Ee((e==null?void 0:e.focusSpringReductionMax)??ee.focusSpringReductionMax,0,Wt),focusSpringReductionDiffusion:Ee((e==null?void 0:e.focusSpringReductionDiffusion)??ee.focusSpringReductionDiffusion,.6,Ut),edgeSpringStrength:Ee((e==null?void 0:e.edgeSpringStrength)??ee.edgeSpringStrength,qt,Qt),gravityStrength:Ee((e==null?void 0:e.gravityStrength)??ee.gravityStrength,0,Zt),focusShellSpacing:Ee((e==null?void 0:e.focusShellSpacing)??ee.focusShellSpacing,Jt,er)}}const nt=2e3,lt=40,ut=2e3,rr="forge.knowledge-graph.physics";function Sa(){if(typeof window>"u")return!1;if(window.__FORGE_ENABLE_GRAPH_DIAGNOSTICS__)return!0;try{return new URLSearchParams(window.location.search).get("graphDiagnostics")==="1"}catch{return!1}}function et(e,t){return Array.from(new Set(e.getAll(t).flatMap(n=>n.split(",")).map(n=>n.trim()).filter(Boolean)))}function U(e,t,n){e.delete(t),n.forEach(s=>e.append(t,s))}function Ca(e){switch(e.entityType){case"workbench_flow":case"workbench_surface":case"wiki_space":return null;default:return Rr(e.entityType,e.entityId)}}function J(e){return e?e.slice(0,10):""}function Ea(){if(typeof window>"u")return ee;try{const e=window.localStorage.getItem(rr);return e?tr(JSON.parse(e)):ee}catch{return ee}}function ja(e){typeof window>"u"||window.localStorage.setItem(rr,JSON.stringify(e))}function _a(e,t,n,s,u){const o=e.find(c=>c.id===t);return o||(!t||!n?null:{id:t,displayName:n,kind:s??"human",accentColor:u??"",handle:n.toLowerCase().replace(/\s+/g,"-"),description:"",createdAt:"",updatedAt:""})}function Ra({entityKinds:e,relationKinds:t,tags:n,owners:s}){return[...e.map(u=>`entity:${u}`),...t.map(u=>`relation:${u}`),...n.map(u=>`tag:${u}`),...s.map(u=>`owner:${u}`)]}function kt(e){const t=[],n=[],s=[],u=[];for(const o of e){const[c,...l]=o.split(":"),i=l.join(":").trim();i&&(c==="entity"?t.push(i):c==="relation"?n.push(i):c==="tag"?s.push(i):c==="owner"&&u.push(i))}return{entityKinds:t,relationKinds:n,tags:s,owners:u}}function Ga(e){const t=new URLSearchParams(e),n=t.get("view")==="hierarchy"?"hierarchy":"graph",s=jr(t.get("focus")),u=s?fa(s.entityType,s.entityId):null,o=et(t,"entityKind"),c=et(t,"relationKind"),l=et(t,"tag"),i=et(t,"owner"),m=t.get("q")??"",g=t.get("updatedFrom"),b=t.get("updatedTo"),G=Number(t.get("limit")??nt),f=Number.isFinite(G)?Math.max(lt,Math.min(ut,G)):nt;return{selectedView:n,focusNodeId:u,selectedKinds:o,selectedRelations:c,selectedTags:l,selectedOwners:i,showHierarchyCrossLinks:t.get("cross")==="1",queryText:m,updatedFrom:g,updatedTo:b,maxNodes:f}}function Ma(e){return{q:e.queryText.trim()||null,entityKinds:[...e.selectedKinds].sort(),relationKinds:[...e.selectedRelations].sort(),tags:[...e.selectedTags].sort(),owners:[...e.selectedOwners].sort(),updatedFrom:e.updatedFrom,updatedTo:e.updatedTo,limit:e.maxNodes,focusNodeId:null}}function Ft(e,t){if(!t){e.delete("focus");return}e.set("focus",_r(t.entityType,t.entityId))}function ka({isMobile:e,currentFocusNodeId:t,nextNodeId:n}){return n?e?t===n?{nextFocusNodeId:n,nextMobileSheetOpen:!0,shouldUpdateFocus:!1}:{nextFocusNodeId:n,nextMobileSheetOpen:!1,shouldUpdateFocus:!0}:{nextFocusNodeId:n,nextMobileSheetOpen:!1,shouldUpdateFocus:t!==n}:{nextFocusNodeId:null,nextMobileSheetOpen:!1,shouldUpdateFocus:t!==null}}const Kt="__clear__";function Fa({isMobile:e,focusNodeId:t,shellOverlayFocusNodeId:n,lastRequestedKey:s}){const u=e?null:t,o=u??Kt;return o===(n??Kt)?{action:"none",nextRequestedKey:o}:s===o?{action:"none",nextRequestedKey:o}:{action:u?"set":"clear",nextRequestedKey:o}}const It="shrink-0 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-2 py-0.5 text-[9px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)] shadow-[var(--ui-shadow-soft)] backdrop-blur",At="flex shrink-0 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-0.5 shadow-[var(--ui-shadow-soft)] backdrop-blur",tt="bg-[var(--ui-accent-soft)] text-[var(--primary)] shadow-[var(--ui-shadow-soft)]",rt="text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",fe="rounded-full border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] shadow-[var(--ui-shadow-soft)] backdrop-blur hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",Ka="fixed inset-0 z-40 bg-[color-mix(in_srgb,var(--ui-scrim)_72%,transparent)] backdrop-blur-xl",Ia="fixed inset-x-4 top-[max(1rem,env(safe-area-inset-top))] z-50 max-h-[calc(100dvh-2rem)] overflow-y-auto rounded-[30px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] shadow-[var(--ui-shadow-floating)] md:left-1/2 md:right-auto md:-translate-x-1/2",Aa="sticky top-0 z-10 flex items-start justify-between gap-4 border-b border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-5 py-4 backdrop-blur-xl",Oa="text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",Pa="font-display text-2xl text-[var(--ui-ink-strong)]",Ta="text-sm leading-6 text-[var(--ui-ink-soft)]",je="grid min-w-0 gap-3 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",_e="text-sm font-medium text-[var(--ui-ink-strong)]",Re="text-xs leading-5 text-[var(--ui-ink-faint)]",Ge="rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-2.5 py-1 text-xs text-[var(--ui-ink-soft)]",Da="rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-info-soft)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]";class za extends h.Component{constructor(t){super(t),this.state={error:null}}static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t){t.resetKey!==this.props.resetKey&&this.state.error!==null&&this.setState({error:null})}render(){return this.state.error?this.props.fallback(this.state.error):this.props.children}}function Ja(){var Qe,$e;const e=Gr(),t=Pt();ct(a=>a.knowledgeGraphDiagnostics);const n=ct(a=>{var p,_;return((_=(p=a.shell.knowledgeGraphOverlayFocus)==null?void 0:p.focusNode)==null?void 0:_.id)??null}),s=nr(),[u,o]=sr(),c=h.useRef(null),l=h.useRef(null),i=h.useRef(null),m=h.useRef(null),g=h.useRef(null);h.useRef(Tt("/knowledge-graph"));const[b,G]=h.useState(()=>typeof window<"u"?window.matchMedia("(max-width: 1023px)").matches:!1),[f,N]=h.useState(!1),[F,j]=h.useState(!1),[z,M]=h.useState(!1),[L,me]=h.useState(!1),[k,ce]=h.useState(""),[A,xe]=h.useState(()=>Ea()),Me=Dt(),we=({level:a,eventKey:p,message:_,details:Ye,publishBackend:pt=!1})=>{};h.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const a=window.matchMedia("(max-width: 1023px)"),p=_=>G(_?_.matches:a.matches);return p(),typeof a.addEventListener=="function"?(a.addEventListener("change",p),()=>a.removeEventListener("change",p)):(a.addListener(p),()=>a.removeListener(p))},[]),h.useEffect(()=>{b||(N(!1),j(!1),l.current=null)},[b]),h.useEffect(()=>{ja(A)},[A]);const $=u.toString(),Ne=h.useMemo(()=>Ga($),[$]),{selectedView:Y,focusNodeId:P,selectedKinds:te,selectedRelations:le,selectedTags:ke,selectedOwners:Se,showHierarchyCrossLinks:Q,queryText:ue,updatedFrom:ye,updatedTo:de,maxNodes:pe}=Ne;h.useEffect(()=>{ce(ue)},[ue]);const H=h.useMemo(()=>Ma(Ne),[Ne]),he=h.useMemo(()=>["forge-knowledge-graph",...e.selectedUserIds,JSON.stringify(H)],[H,e.selectedUserIds]),V=yr({queryKey:he,queryFn:()=>Pr(e.selectedUserIds,H),placeholderData:a=>a,staleTime:6e4,refetchOnWindowFocus:!1}),y=V.data;h.useEffect(()=>{we({level:"info",eventKey:"route_arrival",message:"Arrived on the Knowledge Graph page.",details:{search:u.toString()}})},[]),h.useEffect(()=>{if(!V.isSuccess||!y)return;const a=JSON.stringify({q:H.q,entityKinds:H.entityKinds,relationKinds:H.relationKinds,tags:H.tags,owners:H.owners,updatedFrom:H.updatedFrom,updatedTo:H.updatedTo,limit:H.limit,nodeCount:y.counts.nodeCount,edgeCount:y.counts.edgeCount,filteredNodeCount:y.counts.filteredNodeCount,limited:y.counts.limited});g.current!==a&&(g.current=a,we({level:"info",eventKey:"graph_query_resolved",message:"Knowledge graph query resolved.",details:{nodeCount:y.counts.nodeCount,edgeCount:y.counts.edgeCount,filteredNodeCount:y.counts.filteredNodeCount,limited:y.counts.limited}}))},[y,V.isSuccess,H]),h.useEffect(()=>{!y||!P||y.nodes.some(a=>a.id===P)||(o(a=>{const p=new URLSearchParams(a);return p.delete("focus"),p},{replace:!0}),N(!1),l.current=null)},[P,y,o]),h.useEffect(()=>{if(b){if(!P){l.current=null,N(!1);return}l.current===P&&!f&&(N(!0),l.current=null)}},[P,b,f]);const B=h.useMemo(()=>!y||!P?Mt([],[],null):Mt(y.nodes,y.edges,P),[P,y]);h.useEffect(()=>{var p;const a=Fa({isMobile:b,focusNodeId:((p=B.focusNode)==null?void 0:p.id)??null,shellOverlayFocusNodeId:n,lastRequestedKey:m.current});if(m.current=a.nextRequestedKey,a.action!=="none"){if(a.action==="clear"){t(xt());return}t(Mr(B))}},[t,B,b,n]),h.useEffect(()=>{{i.current=null;return}},[Me,P,B,b]),h.useEffect(()=>()=>{t(xt())},[t]),h.useEffect(()=>{if(!(typeof window>"u")){if(!Sa()){delete window.__FORGE_KNOWLEDGE_GRAPH_PAGE_TEST__;return}return window.__FORGE_KNOWLEDGE_GRAPH_PAGE_TEST__={isMobile:b,mobileSheetOpen:f,focusNodeId:P,selectedView:Y,selectNodeById:a=>{if(!y)return;const p=a?y.nodes.find(_=>_.id===a)??null:null;Ce(p)},activateFocusedNode:()=>{if(!P||!y)return;const a=y.nodes.find(p=>p.id===P)??null;a&&Ce(a)}},()=>{delete window.__FORGE_KNOWLEDGE_GRAPH_PAGE_TEST__}}},[P,b,f,Y]);const w=a=>{o(p=>{const _=new URLSearchParams(p);return a(_),_},{replace:!0})},We=a=>{const p=a.trim();ce(a),w(_=>{p.length>0?_.set("q",p):_.delete("q")})},Ce=a=>{const p=ka({isMobile:b,currentFocusNodeId:P,nextNodeId:(a==null?void 0:a.id)??null});l.current=b&&p.nextMobileSheetOpen?(a==null?void 0:a.id)??null:null,N(p.nextMobileSheetOpen),p.shouldUpdateFocus&&(w(_=>{Ft(_,a)}),b&&j(!1))},Fe=a=>{a.href&&s(a.href)},re=(a,p)=>{xe(_=>tr({..._,[a]:p}))},Te=a=>{const p=Ca(a);p&&s(p)},De=a=>{w(p=>{p.set("view","hierarchy"),Ft(p,a)})},ze=()=>{w(a=>{["q","entityKind","relationKind","tag","owner","updatedFrom","updatedTo","focus"].forEach(p=>a.delete(p)),a.set("limit",String(nt))}),M(!1)};if(V.isLoading&&!y)return r.jsx(kr,{eyebrow:"Knowledge Graph",title:"Loading the Forge world model",description:"Gathering goals, projects, KarpaWiki pages, psyche entities, calendar context, and Workbench flows into one graph."});if(V.isError)return r.jsx(Fr,{eyebrow:"Knowledge Graph",error:V.error,onRetry:()=>void V.refetch()});if(!y)return null;const T=new Map(y.facets.entityKinds.map(a=>[a.value,a])),ge=ot.map(a=>{const p=Kr(a),_=T.get(a),Ye=(_==null?void 0:_.count)??0;return{value:a,label:(_==null?void 0:_.label)??p.label,description:Ye===1?"1 node":`${Ye} nodes`,kind:a}}),q=y.facets.relationKinds.map(a=>({value:a.value,label:a.label,description:`${a.count} links`})),ae=y.facets.tags.map(a=>({value:a.id,label:a.label,description:`${a.count} linked nodes`,badge:r.jsx(at,{kind:"tag",label:a.label,compact:!0,gradient:!1}),menuBadge:r.jsx(at,{kind:"tag",label:a.label,compact:!0,gradient:!1})})),ne=y.facets.owners.map(a=>{const p=_a(e.snapshot.users,a.userId,a.displayName,a.kind,a.accentColor);return{value:a.userId,label:a.displayName,description:`${a.count} nodes`,badge:r.jsx(vt,{user:p,compact:!0}),menuBadge:r.jsx(vt,{user:p,compact:!0})}}),Ue=[...ge.map(a=>({id:`entity:${a.value}`,label:a.label,description:a.description,searchText:`entity kind ${a.label}`,badge:r.jsx(at,{kind:a.kind??"note",label:a.label,compact:!0,gradient:!1})})),...q.map(a=>({id:`relation:${a.value}`,label:a.label,description:a.description,searchText:`relation kind ${a.label}`})),...ae.map(a=>({id:`tag:${a.value}`,label:a.label,description:a.description,searchText:`tag ${a.label}`,badge:a.menuBadge??a.badge})),...ne.map(a=>({id:`owner:${a.value}`,label:a.label,description:a.description,searchText:`owner ${a.label}`,badge:a.menuBadge??a.badge}))],se=Ra({entityKinds:te,relationKinds:le,tags:ke,owners:Se}),Le=y.counts.limited?`${y.counts.nodeCount}/${y.counts.filteredNodeCount} nodes`:`${y.counts.nodeCount}n · ${y.counts.edgeCount}e`,D=y.counts.limited?`${y.counts.nodeCount} visible nodes from ${y.counts.filteredNodeCount} filtered matches`:`${y.counts.nodeCount} nodes and ${y.counts.edgeCount} edges`,st=ue.trim().length>0||te.length>0||le.length>0||ke.length>0||Se.length>0||!!ye||!!de||pe!==nt,be=!b,qe=`${Y}:${y.nodes.map(a=>a.id).join("|")}::${y.edges.map(a=>a.id).join("|")}`;return r.jsxs("div",{className:"h-[calc(100dvh-var(--forge-mobile-nav-clearance)-5.25rem)] overflow-hidden lg:-mt-3 lg:h-[calc(100dvh-10rem)]",children:[r.jsxs("div",{className:"relative h-full bg-[var(--ui-surface-0)]",children:[r.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-30 hidden md:block",children:r.jsx(Ir,{metrics:e.snapshot.metrics})}),r.jsx(za,{resetKey:qe,fallback:a=>r.jsx("div",{className:"grid h-full place-items-center p-6 text-center",children:r.jsxs("div",{className:"grid max-w-lg gap-4 rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-6 shadow-[var(--ui-shadow-floating)]",children:[r.jsx("div",{className:"mx-auto flex size-12 items-center justify-center rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-warning-soft)] text-[var(--warning)]",children:r.jsx(ir,{className:"size-5"})}),r.jsxs("div",{className:"grid gap-2",children:[r.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Graph renderer fallback"}),r.jsx("h2",{className:"text-lg font-semibold text-[var(--ui-ink-strong)]",children:"The graph renderer hit a display error."}),r.jsx("p",{className:"text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Switch to the hierarchy view or reset the current graph filters. The graph will recover automatically when the dataset changes."}),r.jsx("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3 text-left text-xs text-[var(--ui-ink-faint)]",children:a.message})]}),r.jsxs("div",{className:"flex flex-wrap justify-center gap-2",children:[r.jsxs(W,{variant:"primary",size:"sm",onClick:()=>w(p=>{p.set("view","hierarchy")}),children:[r.jsx(or,{className:"size-4"}),"Open hierarchy"]}),r.jsx(W,{variant:"secondary",size:"sm",onClick:ze,children:"Reset graph filters"})]})]})}),children:Y==="graph"?r.jsx(xa,{ref:c,nodes:y.nodes,edges:y.edges,focusNodeId:P,physicsSettings:A,onSelectNode:Ce}):r.jsx("div",{className:"h-full overflow-y-auto px-4 py-4 lg:px-6",children:r.jsx(Na,{nodes:y.nodes,edges:y.edges,focusNodeId:P,showSecondaryEdges:Q,isMobile:b,onSelectNode:Ce,onOpenNode:Ce,onNavigateNode:Fe})})}),b?r.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-20 px-3 pt-2 lg:hidden",children:r.jsxs("div",{className:"pointer-events-auto flex items-center gap-1.5",children:[r.jsx("div",{title:D,className:It,children:Le}),r.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[r.jsxs("div",{className:At,children:[r.jsx("button",{type:"button",className:`rounded-full px-2 py-1 text-[10px] transition ${Y==="graph"?tt:rt}`,onClick:()=>w(a=>{a.set("view","graph")}),children:"Graph"}),r.jsx("button",{type:"button",className:`rounded-full px-2 py-1 text-[10px] transition ${Y==="hierarchy"?tt:rt}`,onClick:()=>w(a=>{a.set("view","hierarchy")}),children:"Hierarchy"})]}),r.jsx(W,{variant:"secondary",size:"sm",className:`h-7 px-2 text-[10px] ${fe}`,onClick:()=>me(!0),"aria-label":"Open graph appearance settings",title:"Graph appearance settings",children:r.jsx(gt,{className:"size-3"})}),r.jsxs(W,{variant:"secondary",size:"sm",className:`h-7 px-2 text-[10px] ${fe}`,onClick:()=>{N(!1),j(!0)},"aria-label":"Open graph filters",children:[r.jsx(ft,{className:"size-3"}),"Search"]})]})]})}):null,be?r.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-20 px-4 pt-3 lg:px-6",children:[r.jsxs("div",{"data-testid":"knowledge-graph-desktop-toolbar",className:"pointer-events-auto flex items-center gap-1.5",children:[r.jsx("div",{"data-testid":"knowledge-graph-count-pill",title:D,className:It,children:Le}),r.jsx("div",{className:"min-w-0 flex-1",children:r.jsx(bt,{title:"",description:"",compact:!0,minimal:!0,hideSummary:!0,query:k,onQueryChange:ce,onQuerySubmit:We,submitLabel:"Search graph",options:Ue,selectedOptionIds:se,onSelectedOptionIdsChange:a=>{const p=kt(a);w(_=>{U(_,"entityKind",p.entityKinds),U(_,"relationKind",p.relationKinds),U(_,"tag",p.tags),U(_,"owner",p.owners)})},resultSummary:"",placeholder:"Type a graph search, then press Enter or the search button"})}),r.jsxs(W,{variant:"secondary",size:"sm",className:`h-7 px-2 text-[10px] ${fe}`,onClick:()=>M(a=>!a),children:[r.jsx(ft,{className:"size-3"}),"Advanced"]}),st?r.jsx(W,{variant:"secondary",size:"sm",className:`h-7 px-2 text-[10px] ${fe}`,onClick:ze,children:"Reset"}):null]}),r.jsx(Hr,{initial:!1,children:z?r.jsx(Vr.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.18,ease:"easeOut"},className:"pointer-events-auto mt-2 ml-auto max-w-[min(54rem,calc(100%-3.5rem))] rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-3 shadow-[var(--ui-shadow-floating)] backdrop-blur",children:r.jsxs("div",{className:"grid gap-3 xl:grid-cols-[minmax(0,1.4fr)_minmax(17rem,1fr)]",children:[r.jsxs("div",{className:"grid gap-3",children:[r.jsx(ve,{options:ge,selectedValues:te,onChange:a=>w(p=>{U(p,"entityKind",a)}),placeholder:"Filter by entity type",emptyMessage:"No entity kinds match the current graph."}),r.jsx(ve,{options:q,selectedValues:le,onChange:a=>w(p=>{U(p,"relationKind",a)}),placeholder:"Filter by relation type",emptyMessage:"No relation kinds match the current graph."}),r.jsx(ve,{options:ae,selectedValues:ke,onChange:a=>w(p=>{U(p,"tag",a)}),placeholder:"Filter by tag",emptyMessage:"No tags are available in the current filtered graph."}),r.jsx(ve,{options:ne,selectedValues:Se,onChange:a=>w(p=>{U(p,"owner",a)}),placeholder:"Filter by owner",emptyMessage:"No owners match the current graph."})]}),r.jsxs("div",{className:"grid gap-3 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3",children:[r.jsxs("div",{className:"grid gap-2",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3 text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:[r.jsx("span",{children:"Max nodes shown"}),r.jsx("span",{children:pe})]}),r.jsx("input",{type:"range",min:lt,max:ut,step:20,value:pe,onChange:a=>w(p=>{p.set("limit",a.target.value)}),className:"w-full accent-[var(--secondary)]"}),r.jsx("div",{className:"text-xs text-[var(--ui-ink-faint)]",children:"The graph stays deterministic under the cap and focus mode redistributes the visible neighborhood around the selected node."})]}),r.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[r.jsxs("div",{className:"grid gap-2",children:[r.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Updated from"}),r.jsx(Ze,{type:"date",value:J(ye),min:J(y.facets.updatedAt.min),max:J(de??y.facets.updatedAt.max),onChange:a=>w(p=>{a.target.value?p.set("updatedFrom",a.target.value):p.delete("updatedFrom")})})]}),r.jsxs("div",{className:"grid gap-2",children:[r.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Updated to"}),r.jsx(Ze,{type:"date",value:J(de),min:J(ye??y.facets.updatedAt.min),max:J(y.facets.updatedAt.max),onChange:a=>w(p=>{a.target.value?p.set("updatedTo",a.target.value):p.delete("updatedTo")})})]})]}),Y==="hierarchy"?r.jsx(W,{variant:Q?"primary":"secondary",size:"sm",className:"h-8 rounded-full px-3 text-xs",onClick:()=>w(a=>{Q?a.delete("cross"):a.set("cross","1")}),children:Q?"Hide cross-links":"Show cross-links"}):null]})]})}):null})]}):null,b?null:r.jsx("div",{className:"pointer-events-none absolute bottom-5 left-4 z-20 lg:left-6",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("div",{className:`pointer-events-auto ${At}`,children:[r.jsx("button",{type:"button",className:`rounded-full px-2.5 py-1.5 text-[10px] transition ${Y==="graph"?tt:rt}`,onClick:()=>w(a=>{a.set("view","graph")}),children:"Graph"}),r.jsx("button",{type:"button",className:`rounded-full px-2.5 py-1.5 text-[10px] transition ${Y==="hierarchy"?tt:rt}`,onClick:()=>w(a=>{a.set("view","hierarchy")}),children:"Hierarchy"})]}),Y==="graph"?r.jsxs(r.Fragment,{children:[r.jsx(W,{variant:"secondary",size:"sm",className:`pointer-events-auto size-8 p-0 ${fe}`,onClick:()=>me(!0),title:"Graph appearance settings","aria-label":"Open graph appearance settings",children:r.jsx(gt,{className:"size-3.5"})}),r.jsx(W,{variant:"secondary",size:"sm",className:`pointer-events-auto size-8 p-0 ${fe}`,onClick:()=>{var a;return(a=c.current)==null?void 0:a.zoomIn()},title:"Zoom in","aria-label":"Zoom in",children:r.jsx(cr,{className:"size-3.5"})}),r.jsx(W,{variant:"secondary",size:"sm",className:`pointer-events-auto size-8 p-0 ${fe}`,onClick:()=>{var a;return(a=c.current)==null?void 0:a.zoomOut()},title:"Zoom out","aria-label":"Zoom out",children:r.jsx(lr,{className:"size-3.5"})}),r.jsx(W,{variant:"secondary",size:"sm",className:`pointer-events-auto size-8 p-0 ${fe}`,onClick:()=>{var a;return(a=c.current)==null?void 0:a.recenterOnFocus()},disabled:!B.focusNode,title:"Recenter","aria-label":"Recenter",children:r.jsx(ur,{className:"size-3.5"})}),r.jsx(W,{variant:"secondary",size:"sm",className:`pointer-events-auto size-8 p-0 ${fe}`,onClick:()=>{var a;return(a=c.current)==null?void 0:a.fit()},title:"Reset camera","aria-label":"Reset camera",children:r.jsx(dr,{className:"size-3.5"})}),null]}):null]})})]}),r.jsx(yt,{open:f&&!!B.focusNode,onOpenChange:N,eyebrow:"Knowledge Graph",title:((Qe=B.focusNode)==null?void 0:Qe.title)??"Focus node",description:(($e=B.focusNode)==null?void 0:$e.subtitle)??"Inspect the selected node and move deeper into the graph.",children:r.jsx(Ar,{focus:B,onOpenPage:a=>{N(!1),Fe(a)},onOpenNotes:a=>{N(!1),Te(a)},onOpenHierarchy:a=>{N(!1),De(a)},onSelectNode:Ce,className:"border-0 bg-transparent p-0 shadow-none"})}),r.jsx(yt,{open:F,onOpenChange:j,eyebrow:"Knowledge Graph",title:"Filter graph",description:"Search the visible graph and adjust the focus cap without covering the canvas all the time.",children:r.jsxs("div",{className:"grid gap-4 pb-2",children:[r.jsx("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-3",children:r.jsx(bt,{title:"",description:"",compact:!0,query:k,onQueryChange:ce,onQuerySubmit:We,submitLabel:"Search graph",options:Ue,selectedOptionIds:se,onSelectedOptionIdsChange:a=>{const p=kt(a);w(_=>{U(_,"entityKind",p.entityKinds),U(_,"relationKind",p.relationKinds),U(_,"tag",p.tags),U(_,"owner",p.owners)})},resultSummary:D,placeholder:"Type a graph search, then press Enter or the search button"})}),r.jsxs("div",{className:"grid gap-3",children:[r.jsx(ve,{options:ge,selectedValues:te,onChange:a=>w(p=>{U(p,"entityKind",a)}),placeholder:"Filter by entity type",emptyMessage:"No entity kinds match the current graph."}),r.jsx(ve,{options:q,selectedValues:le,onChange:a=>w(p=>{U(p,"relationKind",a)}),placeholder:"Filter by relation type",emptyMessage:"No relation kinds match the current graph."}),r.jsx(ve,{options:ae,selectedValues:ke,onChange:a=>w(p=>{U(p,"tag",a)}),placeholder:"Filter by tag",emptyMessage:"No tags are available in the current filtered graph."}),r.jsx(ve,{options:ne,selectedValues:Se,onChange:a=>w(p=>{U(p,"owner",a)}),placeholder:"Filter by owner",emptyMessage:"No owners match the current graph."})]}),r.jsxs("div",{className:"grid gap-3 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-3",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3 text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:[r.jsx("span",{children:"Max nodes shown"}),r.jsx("span",{children:pe})]}),r.jsx("input",{type:"range",min:lt,max:ut,step:20,value:pe,onChange:a=>w(p=>{p.set("limit",a.target.value)}),className:"w-full accent-[var(--secondary)]"}),r.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[r.jsxs("div",{className:"grid gap-2",children:[r.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Updated from"}),r.jsx(Ze,{type:"date",value:J(ye),min:J(y.facets.updatedAt.min),max:J(de??y.facets.updatedAt.max),onChange:a=>w(p=>{a.target.value?p.set("updatedFrom",a.target.value):p.delete("updatedFrom")})})]}),r.jsxs("div",{className:"grid gap-2",children:[r.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Updated to"}),r.jsx(Ze,{type:"date",value:J(de),min:J(ye??y.facets.updatedAt.min),max:J(y.facets.updatedAt.max),onChange:a=>w(p=>{a.target.value?p.set("updatedTo",a.target.value):p.delete("updatedTo")})})]})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(W,{variant:"secondary",size:"sm",onClick:ze,children:"Reset"}),r.jsx(W,{variant:"primary",size:"sm",onClick:()=>j(!1),children:"Done"})]})]})]})}),r.jsx(pr,{open:L,onOpenChange:me,children:r.jsxs(hr,{children:[r.jsx(gr,{className:Ka}),r.jsxs(fr,{className:`${Ia} md:w-[min(40rem,calc(100vw-3rem))]`,children:[r.jsx(mr,{className:"sr-only",children:"Knowledge Graph appearance settings"}),r.jsx(xr,{className:"sr-only",children:"Tune the graph focus physics and appearance response."}),r.jsxs("div",{className:Aa,children:[r.jsxs("div",{className:"grid gap-1",children:[r.jsx("div",{className:Oa,children:"Graph appearance"}),r.jsx("div",{className:Pa,children:"Tune the focus field"}),r.jsx("p",{className:`max-w-xl ${Ta}`,children:"Shape how strongly a focused node opens its neighborhood and how far that pressure diffuses through connected hops."})]}),r.jsx(mt,{asChild:!0,children:r.jsx(Or,{"aria-label":"Close graph appearance settings"})})]}),r.jsxs("div",{className:"grid gap-4 px-5 py-5",children:[r.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[r.jsxs("div",{className:je,children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:_e,children:"Focused repulsion"}),r.jsx("div",{className:Re,children:"Push nearby nodes apart more aggressively while the focused node stays anchored."})]}),r.jsx("div",{className:Ge,children:A.focusRepulsion.toFixed(2)})]}),r.jsx("input",{"aria-label":"Focused repulsion",type:"range",min:"0.6",max:String(Bt),step:"0.05",value:A.focusRepulsion,onChange:a=>re("focusRepulsion",Number(a.target.value)),className:"w-full accent-[var(--secondary)]"})]}),r.jsxs("div",{className:je,children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:_e,children:"Focus diffusion"}),r.jsx("div",{className:Re,children:"Extend the focus field further through multi-hop neighbors and lengthen the reversible transition."})]}),r.jsx("div",{className:Ge,children:A.focusDiffusion.toFixed(2)})]}),r.jsx("input",{"aria-label":"Focus diffusion",type:"range",min:"0.6",max:String(Xt),step:"0.05",value:A.focusDiffusion,onChange:a=>re("focusDiffusion",Number(a.target.value)),className:"w-full accent-[var(--secondary)]"})]}),r.jsxs("div",{className:je,children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:_e,children:"Spring reduction max"}),r.jsx("div",{className:Re,children:"Reduce edge spring constants most strongly around the focused node so its local neighborhood can open more freely."})]}),r.jsx("div",{className:Ge,children:A.focusSpringReductionMax.toFixed(2)})]}),r.jsx("input",{"aria-label":"Spring reduction max",type:"range",min:"0",max:String(Wt),step:"0.02",value:A.focusSpringReductionMax,onChange:a=>re("focusSpringReductionMax",Number(a.target.value)),className:"w-full accent-[var(--secondary)]"})]}),r.jsxs("div",{className:je,children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:_e,children:"Spring reduction diffusion"}),r.jsx("div",{className:Re,children:"Spread that spring softening progressively through first-hop, second-hop, and more distant neighborhoods."})]}),r.jsx("div",{className:Ge,children:A.focusSpringReductionDiffusion.toFixed(2)})]}),r.jsx("input",{"aria-label":"Spring reduction diffusion",type:"range",min:"0.6",max:String(Ut),step:"0.05",value:A.focusSpringReductionDiffusion,onChange:a=>re("focusSpringReductionDiffusion",Number(a.target.value)),className:"w-full accent-[var(--secondary)]"})]}),r.jsxs("div",{className:je,children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:_e,children:"Edge spring strength"}),r.jsx("div",{className:Re,children:"Lower this to loosen graph edges globally and let neighborhoods spread instead of snapping tightly inward."})]}),r.jsx("div",{className:Ge,children:A.edgeSpringStrength.toFixed(2)})]}),r.jsx("input",{"aria-label":"Edge spring strength",type:"range",min:String(qt),max:String(Qt),step:"0.05",value:A.edgeSpringStrength,onChange:a=>re("edgeSpringStrength",Number(a.target.value)),className:"w-full accent-[var(--secondary)]"})]}),r.jsxs("div",{className:je,children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:_e,children:"Gravity strength"}),r.jsx("div",{className:Re,children:"Reduce this to weaken the global inward pull that compacts the whole graph toward the middle."})]}),r.jsx("div",{className:Ge,children:A.gravityStrength.toFixed(2)})]}),r.jsx("input",{"aria-label":"Gravity strength",type:"range",min:"0",max:String(Zt),step:"0.05",value:A.gravityStrength,onChange:a=>re("gravityStrength",Number(a.target.value)),className:"w-full accent-[var(--secondary)]"})]}),r.jsxs("div",{className:je,children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:_e,children:"Focus shell spacing"}),r.jsx("div",{className:Re,children:"Increase this to push focused rings farther outward and visibly open the local structure."})]}),r.jsx("div",{className:Ge,children:A.focusShellSpacing.toFixed(2)})]}),r.jsx("input",{"aria-label":"Focus shell spacing",type:"range",min:String(Jt),max:String(er),step:"0.05",value:A.focusShellSpacing,onChange:a=>re("focusShellSpacing",Number(a.target.value)),className:"w-full accent-[var(--secondary)]"})]})]}),r.jsx("div",{className:Da,children:"The main cramming forces are the edge springs and the inward gravity pull. Lower edge spring strength or gravity strength to let the whole graph breathe more, then raise focus shell spacing and spring-reduction controls when you want a selected neighborhood to open dramatically."}),r.jsxs("div",{className:"flex flex-wrap justify-between gap-3",children:[r.jsx(W,{variant:"secondary",onClick:()=>xe(ee),children:"Reset defaults"}),r.jsx(mt,{asChild:!0,children:r.jsx(W,{variant:"primary",children:"Done"})})]})]})]})]})}),null]})}export{Ja as KnowledgeGraphPage};
@@ -1 +1 @@
1
- import{j as t}from"./vendor-BwL6m4SE.js";import{L as i}from"./life-force-workspace-Da-dmoRX.js";import{d as o,aE as a}from"./index-DGYIFHgo.js";import{P as s}from"./page-hero-BkrRTu-t.js";import"./state-Bpe5dF3T.js";import"./floating-action-menu-DGkHCmvI.js";import"./charts-BzT4pUPg.js";import"./motion-DcgUnXhY.js";import"./ui-B9TWEtCx.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";function F(){const e=o(),r=e.snapshot.lifeForce;return r?t.jsxs("div",{className:"grid gap-4",children:[t.jsx(s,{title:"Life Force",titleText:"Life Force",description:"Edit weekday Action Point curves, inspect drains, and tune the capacity model without crowding the Overview surface.",badge:`${Math.round(r.spentTodayAp)} / ${Math.round(r.dailyBudgetAp)} AP`,actions:t.jsx(a,{users:e.snapshot.users,selectedUserIds:e.selectedUserIds,onChange:e.setSelectedUserIds})}),t.jsx(i,{selectedUserIds:e.selectedUserIds,fallbackLifeForce:r,onRefresh:e.refresh,showEditor:!0})]}):t.jsx("div",{className:"grid gap-4",children:t.jsx(s,{title:"Life Force",titleText:"Life Force",description:"Action Point capacity, weekday curves, and instant headroom editing live here.",badge:"Not calibrated yet"})})}export{F as LifeForcePage};
1
+ import{j as t}from"./vendor-BwL6m4SE.js";import{L as i}from"./life-force-workspace-BiD9xOEt.js";import{d as o,aE as a}from"./index-CQ5r7ZUz.js";import{P as s}from"./page-hero-8bITsx_x.js";import"./state-Bpe5dF3T.js";import"./floating-action-menu-D9-psbha.js";import"./charts-BzT4pUPg.js";import"./motion-DcgUnXhY.js";import"./ui-B9TWEtCx.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";function F(){const e=o(),r=e.snapshot.lifeForce;return r?t.jsxs("div",{className:"grid gap-4",children:[t.jsx(s,{title:"Life Force",titleText:"Life Force",description:"Edit weekday Action Point curves, inspect drains, and tune the capacity model without crowding the Overview surface.",badge:`${Math.round(r.spentTodayAp)} / ${Math.round(r.dailyBudgetAp)} AP`,actions:t.jsx(a,{users:e.snapshot.users,selectedUserIds:e.selectedUserIds,onChange:e.setSelectedUserIds})}),t.jsx(i,{selectedUserIds:e.selectedUserIds,fallbackLifeForce:r,onRefresh:e.refresh,showEditor:!0})]}):t.jsx("div",{className:"grid gap-4",children:t.jsx(s,{title:"Life Force",titleText:"Life Force",description:"Action Point capacity, weekday curves, and instant headroom editing live here.",badge:"Not calibrated yet"})})}export{F as LifeForcePage};