forge-openclaw-plugin 0.2.102 → 0.2.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/activity-page-Dv6X5ZCV.js +1 -0
- package/dist/assets/{ai-surface-workspace-xtB5RFQu.js → ai-surface-workspace-CutiG6uS.js} +1 -1
- package/dist/assets/{atlas-panel-B3dPHCmZ.js → atlas-panel-jgMRyaHn.js} +1 -1
- package/dist/assets/{board-DqHzdCPQ.js → board-dIX6etHh.js} +1 -1
- package/dist/assets/calendar-page-q7Nm5E2U.js +1 -0
- package/dist/assets/calendar-rules-DPFsfiRl.js +1 -0
- package/dist/assets/{calendar-week-toolbar-BZ_-X3Wb.js → calendar-week-toolbar-nVhgB-0s.js} +1 -1
- package/dist/assets/{charts-FcU0F3XV.js → charts-DFnEuIMB.js} +1 -1
- package/dist/assets/companion-sync-lab-page-CJ8UTij8.js +1 -0
- package/dist/assets/{daily-metrics-dashboard-BMyL0Qr4.js → daily-metrics-dashboard-CiJkkkd1.js} +1 -1
- package/dist/assets/entity-note-count-link-RzBB6ujx.js +1 -0
- package/dist/assets/{entity-notes-surface-CBylYDwy.js → entity-notes-surface-Djz50HvD.js} +1 -1
- package/dist/assets/execution-board-CtPhI-58.js +1 -0
- package/dist/assets/{faceted-token-search-D7xPWfOl.js → faceted-token-search-DEC6ANa9.js} +1 -1
- package/dist/assets/{flagship-signal-deck-BEFKOhvx.js → flagship-signal-deck-CtHC3mql.js} +1 -1
- package/dist/assets/floating-action-menu-CKQRhff9.js +1 -0
- package/dist/assets/{forms-CmLAyGqz.js → forms-hB0SqEh-.js} +1 -1
- package/dist/assets/goal-detail-page-CF5fNQeR.js +1 -0
- package/dist/assets/goals-page-fsY8NzGB.js +1 -0
- package/dist/assets/{graph-BTa79qum.js → graph-DDUZNRsO.js} +1 -1
- package/dist/assets/habits-page-COoGz4kj.js +1 -0
- package/dist/assets/index-BAXYM89v.css +1 -0
- package/dist/assets/index-EqQsXoat.js +19 -0
- package/dist/assets/{insight-flow-dialog-BtIQXXsS.js → insight-flow-dialog-DtX_5W7g.js} +1 -1
- package/dist/assets/insights-page-cBd74ObU.js +8 -0
- package/dist/assets/kanban-page-CYav9THw.js +1 -0
- package/dist/assets/knowledge-graph-page-D2A-W1jE.js +1 -0
- package/dist/assets/{life-force-page-BGDkKfbJ.js → life-force-page-CACGlNhq.js} +1 -1
- package/dist/assets/life-force-workspace-BJ4N1I78.js +1 -0
- package/dist/assets/{maps-CF1RagUX.js → maps-C-yOWiDN.js} +1 -1
- package/dist/assets/{metric-tile-4iMd_WnJ.js → metric-tile-CMadwnGz.js} +1 -1
- package/dist/assets/{motion-CfdU2F35.js → motion-Lt5B1XuE.js} +1 -1
- package/dist/assets/movement-page-D5VqFd2q.js +1 -0
- package/dist/assets/{note-markdown-CsGQhQXF.js → note-markdown-BzK2Qlgr.js} +1 -1
- package/dist/assets/{note-tags-input-DdZi93tj.js → note-tags-input-CZzqJMLc.js} +1 -1
- package/dist/assets/notes-page-D3Hsh90C.js +1 -0
- package/dist/assets/{open-in-graph-button-C0TGev7c.js → open-in-graph-button-BFPKfyK3.js} +1 -1
- package/dist/assets/{orbit-map-DVXkfQdd.js → orbit-map-CnyfSmOG.js} +1 -1
- package/dist/assets/{overview-page-BwMlFQKX.js → overview-page-CXdWrOV1.js} +1 -1
- package/dist/assets/{page-hero-oFHaAjtL.js → page-hero-ffKzgyW3.js} +1 -1
- package/dist/assets/pill-cluster-C2D0h3lx.js +1 -0
- package/dist/assets/{preference-entity-handoff-button-DOKV9bZc.js → preference-entity-handoff-button-Dj3V6VxL.js} +1 -1
- package/dist/assets/preferences-page-Jo8Gw386.js +1 -0
- package/dist/assets/project-collections-qSqp90HN.js +1 -0
- package/dist/assets/{project-detail-page-DogvVNEn.js → project-detail-page-BifhiLQX.js} +1 -1
- package/dist/assets/project-management-hierarchy-page-DZ_9klIc.js +1 -0
- package/dist/assets/project-management-section-nav-BImLCVvf.js +1 -0
- package/dist/assets/projects-page-ptcx6H38.js +1 -0
- package/dist/assets/{psyche-behaviors-page-BeVlXvbj.js → psyche-behaviors-page-BDwXyDta.js} +1 -1
- package/dist/assets/{psyche-flashcards-page-CqAWCO4E.js → psyche-flashcards-page-DL1BP1jX.js} +1 -1
- package/dist/assets/{psyche-goal-map-page-IyNnbk_W.js → psyche-goal-map-page-ovcpisx1.js} +1 -1
- package/dist/assets/{psyche-graph-IkUQRaDK.js → psyche-graph-EP5GL612.js} +1 -1
- package/dist/assets/{psyche-metrics-page-uai0a7Lx.js → psyche-metrics-page-Bcu813Rg.js} +1 -1
- package/dist/assets/{psyche-mode-guide-page-C7p-ABiF.js → psyche-mode-guide-page-C0g27Xpt.js} +1 -1
- package/dist/assets/{psyche-modes-page-CLQ5V3w0.js → psyche-modes-page-BjKjX5MR.js} +1 -1
- package/dist/assets/{psyche-page-NQBHkkpU.js → psyche-page-F4tF2W70.js} +1 -1
- package/dist/assets/{psyche-patterns-page-BkRiNpI_.js → psyche-patterns-page-B-14hukK.js} +1 -1
- package/dist/assets/{psyche-questionnaire-builder-page-Du-7HwPC.js → psyche-questionnaire-builder-page-BdXmoHvK.js} +1 -1
- package/dist/assets/{psyche-questionnaire-detail-page-C5-yf8MF.js → psyche-questionnaire-detail-page-Cu5uwlJu.js} +1 -1
- package/dist/assets/{psyche-questionnaire-run-detail-page-CoSH5O6R.js → psyche-questionnaire-run-detail-page-C3R4PClg.js} +1 -1
- package/dist/assets/{psyche-questionnaire-run-page-ChI7c1wy.js → psyche-questionnaire-run-page-Div3iDdt.js} +1 -1
- package/dist/assets/{psyche-questionnaires-page-xUcJJzbI.js → psyche-questionnaires-page-DpqAPQCp.js} +1 -1
- package/dist/assets/{psyche-report-detail-page-BPrZCFZS.js → psyche-report-detail-page-BvWVDKP3.js} +1 -1
- package/dist/assets/{psyche-reports-page-D2EXJmm6.js → psyche-reports-page-BrbWUlAq.js} +1 -1
- package/dist/assets/{psyche-schemas-RcZYaokx.js → psyche-schemas-Dxj554nU.js} +1 -1
- package/dist/assets/{psyche-schemas-beliefs-page-h0ooZ1lp.js → psyche-schemas-beliefs-page-DYKvAtSD.js} +1 -1
- package/dist/assets/{psyche-screen-time-page-_3-4LikV.js → psyche-screen-time-page-CAOKCyQw.js} +1 -1
- package/dist/assets/{psyche-self-observation-page-BdbCsgR5.js → psyche-self-observation-page-F0MVA0UH.js} +1 -1
- package/dist/assets/{psyche-values-page-DuUVki5e.js → psyche-values-page-DyvX-d0o.js} +1 -1
- package/dist/assets/{report-chain-fields-BBMz0sGI.js → report-chain-fields-CeC1cJFS.js} +1 -1
- package/dist/assets/rewards-page-C2loyODo.js +1 -0
- package/dist/assets/scheduling-rules-editor-D40AC2jR.js +1 -0
- package/dist/assets/{schema-badge-D93RcG36.js → schema-badge-FY7818qB.js} +1 -1
- package/dist/assets/{select-menu-Cdq7foRu.js → select-menu-DJsCG6rM.js} +1 -1
- package/dist/assets/settings-agents-page-BFkJ5AAD.js +6 -0
- package/dist/assets/settings-bin-page-D3-Ab-iA.js +1 -0
- package/dist/assets/settings-calendar-page-ly_mSTAD.js +5 -0
- package/dist/assets/settings-data-page-D7QOqNf-.js +1 -0
- package/dist/assets/settings-logs-page-Ca87HEUx.js +1 -0
- package/dist/assets/settings-mobile-page-D0jejZot.js +1 -0
- package/dist/assets/settings-models-page-DPDsZjSc.js +1 -0
- package/dist/assets/settings-page-1cArlSPM.js +1 -0
- package/dist/assets/settings-rewards-page-Db4BV1DC.js +1 -0
- package/dist/assets/{settings-section-nav-Dc4IeVBt.js → settings-section-nav-DP9o4peU.js} +1 -1
- package/dist/assets/settings-users-page-BHFyDSsd.js +1 -0
- package/dist/assets/settings-wiki-page-BNaiupBm.js +1 -0
- package/dist/assets/sleep-page-BmOPF0yD.js +1 -0
- package/dist/assets/sports-page-BldIiclr.js +1 -0
- package/dist/assets/{state-VYvD1QVP.js → state-vCcAT5Hq.js} +1 -1
- package/dist/assets/strategies-page-CaTN99qj.js +1 -0
- package/dist/assets/strategy-detail-page-DsgFTd-U.js +1 -0
- package/dist/assets/{strategy-dialog-DMyRKrWf.js → strategy-dialog-7X7peRzu.js} +1 -1
- package/dist/assets/{surface-Bfz_sLX6.js → surface-CJI17F3n.js} +1 -1
- package/dist/assets/{table-C0VTeqw0.js → table-BNqMG3_S.js} +1 -1
- package/dist/assets/task-detail-page-M1sIIPA8.js +1 -0
- package/dist/assets/timebox-planning-dialog-ByojN0AN.js +1 -0
- package/dist/assets/today-page-BjDijtn8.js +1 -0
- package/dist/assets/training-load-page-BPRmaWmF.js +1 -0
- package/dist/assets/{ui-CsEkP2V8.js → ui-C1iwpj2-.js} +1 -1
- package/dist/assets/{use-psyche-focus-target-qxT5Oy_z.js → use-psyche-focus-target-Ct-acS9G.js} +1 -1
- package/dist/assets/{vendor-kIz9EZnX.js → vendor-Dnkkx2co.js} +3 -3
- package/dist/assets/{vitals-page-Dz1Jt5H8.js → vitals-page-CE9zdGLF.js} +1 -1
- package/dist/assets/weekly-review-page-CzhTv90n.js +1 -0
- package/dist/assets/weight-loss-page-Bp_cIk78.js +5 -0
- package/dist/assets/wiki-article-markdown-Dok2uy2p.js +4 -0
- package/dist/assets/wiki-editor-page-BuW32Y3f.js +26 -0
- package/dist/assets/wiki-ingest-history-page-DZKSBNHV.js +1 -0
- package/dist/assets/wiki-ingest-modal-DyqBEZcC.js +1 -0
- package/dist/assets/wiki-page-DqxlbLKG.js +1 -0
- package/dist/assets/workbench-flow-page-C4nc9jUg.js +5 -0
- package/dist/assets/workbench-page-BnyR7SL0.js +1 -0
- package/dist/assets/{workout-detail-page-DD9IGN6l.js → workout-detail-page-DT-c5cHL.js} +2 -2
- package/dist/index.html +9 -9
- package/dist/server/server/src/app.js +22 -3
- package/dist/server/server/src/health-weight-loss.js +114 -39
- package/dist/server/server/src/repositories/model-settings.js +9 -3
- package/dist/server/server/src/watch-mobile.js +28 -0
- package/dist/server/src/components/workbench-boxes/shared/generic-node-view.js +13 -5
- package/dist/server/src/lib/api.js +10 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/dist/assets/activity-page-CgF7K2ww.js +0 -1
- package/dist/assets/calendar-page-C1Wfd2Fy.js +0 -1
- package/dist/assets/calendar-rules-CaZXtlxt.js +0 -1
- package/dist/assets/companion-sync-lab-page-NgeK-O-P.js +0 -1
- package/dist/assets/entity-note-count-link-BrS1-O0o.js +0 -1
- package/dist/assets/execution-board-CpO2ch6v.js +0 -1
- package/dist/assets/floating-action-menu-zzC2r0Ob.js +0 -1
- package/dist/assets/goal-detail-page-JK_Nva8e.js +0 -1
- package/dist/assets/goals-page-yeoJ06Vw.js +0 -1
- package/dist/assets/habits-page-Dx5EhkJi.js +0 -1
- package/dist/assets/index-BHIKoiZ6.js +0 -19
- package/dist/assets/index-H8R-ABM3.css +0 -1
- package/dist/assets/insights-page-CujrosD_.js +0 -8
- package/dist/assets/kanban-page-Q9NuIz5w.js +0 -1
- package/dist/assets/knowledge-graph-page-DaJmlvvM.js +0 -1
- package/dist/assets/life-force-workspace-CLVexVnb.js +0 -1
- package/dist/assets/movement-page-ClaoTNuX.js +0 -1
- package/dist/assets/notes-page-DYI8s3NN.js +0 -1
- package/dist/assets/pill-cluster-7UZd_lHp.js +0 -1
- package/dist/assets/preferences-page-BrKEkmfD.js +0 -1
- package/dist/assets/project-collections-CZagCmeH.js +0 -1
- package/dist/assets/project-management-hierarchy-page-Dr7hW9PW.js +0 -1
- package/dist/assets/project-management-section-nav-BLdAgTge.js +0 -1
- package/dist/assets/projects-page-UKrby_5-.js +0 -1
- package/dist/assets/rewards-page-PZFPa6rR.js +0 -1
- package/dist/assets/scheduling-rules-editor-B9KNKsQz.js +0 -1
- package/dist/assets/settings-agents-page-DPx2F6wf.js +0 -6
- package/dist/assets/settings-bin-page-COwP3gjo.js +0 -1
- package/dist/assets/settings-calendar-page-C-ghE0YT.js +0 -5
- package/dist/assets/settings-data-page-CBubzKBw.js +0 -1
- package/dist/assets/settings-logs-page-uOuXMeBm.js +0 -1
- package/dist/assets/settings-mobile-page-C5rfj8_r.js +0 -1
- package/dist/assets/settings-models-page-DijmUWdU.js +0 -1
- package/dist/assets/settings-page-B4u5TR5g.js +0 -1
- package/dist/assets/settings-rewards-page-COiTwkMH.js +0 -1
- package/dist/assets/settings-users-page-DEGa5DNn.js +0 -1
- package/dist/assets/settings-wiki-page-Cvsiz5_e.js +0 -1
- package/dist/assets/sleep-page-BnSOwkEU.js +0 -1
- package/dist/assets/sports-page-l1RqXzA_.js +0 -1
- package/dist/assets/strategies-page-DEnPlpAs.js +0 -1
- package/dist/assets/strategy-detail-page-Ls8bxKeH.js +0 -1
- package/dist/assets/task-detail-page-CgrYgQLD.js +0 -1
- package/dist/assets/timebox-planning-dialog-Ww0NGLLo.js +0 -1
- package/dist/assets/today-page-CIuFHMi1.js +0 -1
- package/dist/assets/training-load-page-BIwc648i.js +0 -1
- package/dist/assets/weekly-review-page-BFpBe1kI.js +0 -1
- package/dist/assets/weight-loss-page-BgMoBpBt.js +0 -5
- package/dist/assets/wiki-article-markdown-gsPTXTg1.js +0 -4
- package/dist/assets/wiki-editor-page-BpAZHooY.js +0 -26
- package/dist/assets/wiki-ingest-history-page-C-ig8O22.js +0 -1
- package/dist/assets/wiki-ingest-modal-BK4eQgqs.js +0 -1
- package/dist/assets/wiki-page-CMTZ60Zt.js +0 -1
- package/dist/assets/workbench-flow-page-BIpWUcLJ.js +0 -5
- package/dist/assets/workbench-page-CtCjYSRe.js +0 -1
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{r as w,j as e,b5 as W}from"./vendor-kIz9EZnX.js";import{j as z,i as X,k as M}from"./state-VYvD1QVP.js";import{Q as H,ae as Y,af as V,ag as J,F as f,j as Z,I as _,T as L,b as ee,ah as te,u as ie,ai as ne,aj as U,ak as se,i as re,al as ae,am as oe,an as de,ao as le,ap as ce,L as pe,E as ue,B as E,C as F,aq as $,c as Q,U as he,ar as me}from"./index-BHIKoiZ6.js";import{I as ge}from"./insight-flow-dialog-BtIQXXsS.js";import{P as xe}from"./page-hero-oFHaAjtL.js";import{R as fe,A as ye,X as je,Y as we,a as R}from"./charts-FcU0F3XV.js";import"./motion-CfdU2F35.js";import"./ui-CsEkP2V8.js";import"./forms-CmLAyGqz.js";import"./board-DqHzdCPQ.js";import"./graph-BTa79qum.js";const ke={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:[]},be={goalId:"",title:"",description:"",status:"active",workflowStatus:"backlog",userId:null,assigneeUserIds:[],targetPoints:240,themeColor:"#c0c1ff",productRequirementsDocument:"",notes:[]},Ie={title:"",description:"",horizon:"year",status:"active",userId:null,targetPoints:400,themeColor:"#c8a46b",tagIds:[],notes:[]},ve=["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 Ne(t){return t!==null&&ve.includes(t)}function K(t,o,a=96){const r=t.trim()||o.trim();return r.length<=a?r:`${r.slice(0,a-1).trimEnd()}…`}function Te(t){return[t.summary.trim(),t.rationale.trim()?`Why it matters: ${t.rationale.trim()}`:""].filter(Boolean).join(`
|
|
2
|
-
|
|
3
|
-
`)}function G(t){return!Ne(t.entityType)||!t.entityId?null:{entityType:t.entityType,entityId:t.entityId,anchorKey:null}}function O(t,o,a){var r,d;return t.entityType==="goal"&&t.entityId?t.entityId:t.entityType==="project"&&t.entityId?((r=o.find(h=>h.id===t.entityId))==null?void 0:r.goalId)??"":t.entityType==="task"&&t.entityId?((d=a.find(h=>h.id===t.entityId))==null?void 0:d.goalId)??"":""}function Ce(t,o){var a;return t.entityType==="project"&&t.entityId?t.entityId:t.entityType==="task"&&t.entityId?((a=o.find(r=>r.id===t.entityId))==null?void 0:a.projectId)??"":""}function B(t,o,a){const r=[];return a.length>0&&r.push("task"),o.length>0&&r.push("project"),r.push("goal"),G(t)&&r.push("note"),r}function Ae(t,o,a){const r=B(t,o,a);return r.includes("task")&&(t.entityType==="task"||t.entityType==="project")?"task":r.includes("project")&&t.entityType==="goal"?"project":r[0]??"goal"}function Se(t,o,a){var b,j,k;const r=O(t,o,a),h=Ce(t,a)||(r?((b=o.find(m=>m.goalId===r))==null?void 0:b.id)??"":"")||((j=o[0])==null?void 0:j.id)||"",y=h?((k=o.find(m=>m.id===h))==null?void 0:k.goalId)??r:r;return{...ke,title:K(t.recommendation,t.title),description:Te(t),goalId:y,projectId:h}}function Ee(t,o,a,r){var y;const h=O(t,a,r)||((y=o[0])==null?void 0:y.id)||"";return{...be,goalId:h,title:K(t.title,t.recommendation),description:`${t.summary.trim()}
|
|
4
|
-
|
|
5
|
-
Recommendation: ${t.recommendation.trim()}`.trim()}}function Fe(t){return{...Ie,title:K(t.title,t.recommendation),description:`${t.summary.trim()}
|
|
6
|
-
|
|
7
|
-
Recommendation: ${t.recommendation.trim()}`.trim()}}function Pe(t){return[`## ${t.title.trim()}`,"",t.summary.trim(),"","### Recommendation","",t.recommendation.trim(),t.rationale.trim()?"":null,t.rationale.trim()?"### Why this matters":null,t.rationale.trim()||null].filter(o=>!!o).join(`
|
|
8
|
-
`)}function q(t,o,a,r){return{kind:Ae(t,o,a),task:Se(t,a,r),project:Ee(t,o,a,r),goal:Fe(t),noteMarkdown:Pe(t)}}function De(t){switch(t){case"task":return{label:"Task",description:"Turn the recommendation into one concrete next move."};case"project":return{label:"Project",description:"Start a larger initiative when the insight needs a stream of work."};case"goal":return{label:"Goal",description:"Capture a new long-term direction when this changes strategy."};case"note":return{label:"Linked note",description:"Attach the recommendation as durable evidence without creating new work."}}}function Me({open:t,onOpenChange:o,insight:a,goals:r,projects:d,tasks:h,tags:y,pending:b=!1,onSubmit:j}){const k=w.useMemo(()=>B(a,r,d),[r,a,d]),m=w.useMemo(()=>G(a),[a]),[p,T]=w.useState(()=>q(a,r,d,h)),[A,u]=w.useState(null),[v,C]=w.useState({});w.useEffect(()=>{t&&(T(q(a,r,d,h)),u(null),C({}))},[r,a,t,d,h]);const S=p.task.projectId?d.find(s=>s.id===p.task.projectId)??null:null;w.useEffect(()=>{S&&p.task.goalId!==S.goalId&&T(s=>({...s,task:{...s.task,goalId:S.goalId}}))},[p.task.goalId,S]);const P=p.project.goalId?r.find(s=>s.id===p.project.goalId)??null:null,N=w.useMemo(()=>{var s,l,n;if(!m)return null;switch(m.entityType){case"goal":return((s=r.find(i=>i.id===m.entityId))==null?void 0:s.title)??"Linked goal";case"project":return((l=d.find(i=>i.id===m.entityId))==null?void 0:l.title)??"Linked project";case"task":return((n=h.find(i=>i.id===m.entityId))==null?void 0:n.title)??"Linked task";default:return`${m.entityType.replaceAll("_"," ")}`}},[r,d,m,h]),D=[{id:"kind",eyebrow:"Apply",title:"Choose what this insight should become",description:"Accept means you agree with the recommendation. Apply means you turn it into a real record right now.",render:(s,l)=>e.jsx(f,{label:"Apply as",description:"Pick the kind of record Forge should create from this recommendation.",hint:"Task is the best default when the insight points to a concrete next move.",children:e.jsx(Z,{value:s.kind,onChange:n=>l({kind:n}),options:k.map(n=>({value:n,...De(n)})),columns:k.length>=3?3:2})})},{id:"details",eyebrow:"Details",title:"Review the record Forge will create",description:"The fields are prefilled from the insight, but you can tighten them before saving.",render:(s,l)=>s.kind==="task"?e.jsxs(e.Fragment,{children:[e.jsx(f,{label:"Task title",error:v.title??null,children:e.jsx(_,{value:s.task.title,onChange:n=>l({task:{...s.task,title:n.target.value}}),placeholder:"Turn the recommendation into a task"})}),e.jsx(f,{label:"Description",children:e.jsx(L,{value:s.task.description,onChange:n=>l({task:{...s.task,description:n.target.value}}),placeholder:"Add the operational context for this task."})}),e.jsx(f,{label:"Project",error:v.projectId??null,children:e.jsx("div",{className:"grid gap-3",children:d.map(n=>{const i=n.id===s.task.projectId;return e.jsxs("button",{type:"button",className:`rounded-[22px] border px-4 py-4 text-left transition ${i?"border-[rgba(192,193,255,0.28)] bg-[rgba(192,193,255,0.14)] text-white":"border-white/8 bg-white/[0.04] text-white/72 hover:bg-white/[0.07]"}`,onClick:()=>l({task:{...s.task,projectId:n.id,goalId:n.goalId}}),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"font-medium",children:n.title}),e.jsx(ee,{kind:"goal",label:n.goalTitle,compact:!0,gradient:!1})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/54",children:n.description||"No project note attached yet."})]},n.id)})})}),e.jsx(f,{label:"Owner",error:v.owner??null,children:e.jsx(_,{value:s.task.owner,onChange:n=>l({task:{...s.task,owner:n.target.value}}),placeholder:"Albert"})}),e.jsx(f,{label:"Tags",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:y.map(n=>{const i=s.task.tagIds.includes(n.id);return e.jsx("button",{type:"button",className:`rounded-full px-3 py-2 text-sm transition ${i?"bg-white/16 text-white":"bg-white/6 text-white/58 hover:bg-white/10 hover:text-white"}`,onClick:()=>l({task:{...s.task,tagIds:i?s.task.tagIds.filter(c=>c!==n.id):[...s.task.tagIds,n.id]}}),children:n.name},n.id)})})})]}):s.kind==="project"?e.jsxs(e.Fragment,{children:[e.jsx(f,{label:"Project title",error:v.title??null,children:e.jsx(_,{value:s.project.title,onChange:n=>l({project:{...s.project,title:n.target.value}}),placeholder:"Turn the insight into a project"})}),e.jsx(f,{label:"Description",children:e.jsx(L,{value:s.project.description,onChange:n=>l({project:{...s.project,description:n.target.value}}),placeholder:"Describe the initiative this insight points to."})}),e.jsx(f,{label:"Goal",error:v.goalId??null,children:e.jsx("div",{className:"grid gap-3",children:r.map(n=>{const i=n.id===s.project.goalId;return e.jsxs("button",{type:"button",className:`rounded-[22px] border px-4 py-4 text-left transition ${i?"border-[rgba(192,193,255,0.28)] bg-[rgba(192,193,255,0.14)] text-white":"border-white/8 bg-white/[0.04] text-white/72 hover:bg-white/[0.07]"}`,onClick:()=>l({project:{...s.project,goalId:n.id}}),children:[e.jsx("div",{className:"font-medium",children:n.title}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/54",children:n.description||"No strategic note attached yet."})]},n.id)})})}),P?e.jsxs(te,{children:["This project will sit under the “",P.title,"” goal."]}):null]}):s.kind==="goal"?e.jsxs(e.Fragment,{children:[e.jsx(f,{label:"Goal title",error:v.title??null,children:e.jsx(_,{value:s.goal.title,onChange:n=>l({goal:{...s.goal,title:n.target.value}}),placeholder:"Turn the insight into a life goal"})}),e.jsx(f,{label:"Description",children:e.jsx(L,{value:s.goal.description,onChange:n=>l({goal:{...s.goal,description:n.target.value}}),placeholder:"Describe the strategic direction this insight suggests."})}),e.jsx(f,{label:"Tags",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:y.map(n=>{const i=s.goal.tagIds.includes(n.id);return e.jsx("button",{type:"button",className:`rounded-full px-3 py-2 text-sm transition ${i?"bg-white/16 text-white":"bg-white/6 text-white/58 hover:bg-white/10 hover:text-white"}`,onClick:()=>l({goal:{...s.goal,tagIds:i?s.goal.tagIds.filter(c=>c!==n.id):[...s.goal.tagIds,n.id]}}),children:n.name},n.id)})})})]}):e.jsxs(e.Fragment,{children:[e.jsx(f,{label:"Linked note",description:"This stores the insight as durable Markdown evidence on the linked entity instead of creating a new work item.",hint:N?`This note will attach to ${N}.`:void 0,children:e.jsx(L,{value:s.noteMarkdown,onChange:n=>l({noteMarkdown:n.target.value}),placeholder:"Write the applied note content in Markdown",className:"min-h-64"})}),N?e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.04] px-4 py-3 text-sm text-white/70",children:["Linked target:"," ",e.jsx("span",{className:"font-medium text-white",children:N})]}):null]})}];return e.jsx(H,{open:t,onOpenChange:o,eyebrow:"Apply insight",title:"Turn this insight into a real record",description:"Apply should create something concrete inside Forge, not just change the status label.",value:p,onChange:T,draftPersistenceKey:"insights.apply",steps:D,submitLabel:"Apply insight",pending:b,error:A,onSubmit:async()=>{u(null),C({});try{if(p.kind==="task"){const s=Y.safeParse(p.task);if(!s.success){C(Object.fromEntries(Object.entries(s.error.flatten().fieldErrors).map(([l,n])=>[l,n==null?void 0:n[0]]))),u("This applied task still needs a valid title, project, and owner.");return}await j({kind:"task",input:s.data}),o(!1);return}if(p.kind==="project"){const s=V.safeParse(p.project);if(!s.success){C(Object.fromEntries(Object.entries(s.error.flatten().fieldErrors).map(([l,n])=>[l,n==null?void 0:n[0]]))),u("This applied project still needs a valid title and goal.");return}await j({kind:"project",input:s.data}),o(!1);return}if(p.kind==="goal"){const s=J.safeParse(p.goal);if(!s.success){C(Object.fromEntries(Object.entries(s.error.flatten().fieldErrors).map(([l,n])=>[l,n==null?void 0:n[0]]))),u("This applied goal still needs a valid title and target.");return}await j({kind:"goal",input:s.data}),o(!1);return}if(!p.noteMarkdown.trim()){u("The linked note needs Markdown content before it can be saved.");return}if(!m){u("This insight is not attached to a specific entity yet, so Forge cannot place a linked note for it.");return}await j({kind:"note",input:{contentMarkdown:p.noteMarkdown.trim()}}),o(!1)}catch(s){u(s instanceof Error?s.message:"Unable to apply this insight right now.")}}})}function We(){var D,s,l,n;const t=z(),o=W(),a=ie(),r=Array.isArray(a.selectedUserIds)?a.selectedUserIds:[],{snapshot:d}=a,[h,y]=w.useState(!1),[b,j]=w.useState(null),k=X({queryKey:["forge-insights",...r],queryFn:()=>me(r)}),m=M({mutationFn:ne,onSuccess:async()=>{await t.invalidateQueries({queryKey:["forge-insights"]})}}),p=M({mutationFn:({insightId:i,feedbackType:c})=>U(i,c),onSuccess:async()=>{await t.invalidateQueries({queryKey:["forge-insights"]})}}),T=M({mutationFn:({insightId:i})=>se(i),onMutate:async({insightId:i})=>{await t.cancelQueries({queryKey:["forge-insights"]});const c=t.getQueryData(["forge-insights"]);if(c){const g=c.insights.feed.find(I=>I.id===i);t.setQueryData(["forge-insights"],{insights:{...c.insights,feed:c.insights.feed.filter(I=>I.id!==i),openCount:(g==null?void 0:g.status)==="open"?Math.max(0,c.insights.openCount-1):c.insights.openCount}})}return{previous:c}},onError:(i,c,g)=>{g!=null&&g.previous&&t.setQueryData(["forge-insights"],g.previous)},onSettled:async()=>{await t.invalidateQueries({queryKey:["forge-insights"]})}}),A=M({mutationFn:async({insight:i,submission:c})=>{let g=null,I="Applied the insight.";if(c.kind==="task"){const x=await ae(c.input);g=`/tasks/${x.task.id}`,I=`Created task: ${x.task.title}`}else if(c.kind==="project"){const x=await oe(c.input);g=`/projects/${x.project.id}`,I=`Created project: ${x.project.title}`}else if(c.kind==="goal"){const x=await de(c.input);g=`/goals/${x.goal.id}`,I=`Created goal: ${x.goal.title}`}else{const x=G(i);if(!x)throw new Error("This insight is not linked to a concrete entity yet, so Forge cannot attach a linked note to it.");await le({contentMarkdown:c.input.contentMarkdown,links:[x]}),g=ce(x.entityType,x.entityId),I="Created a linked note from the insight."}return await U(i.id,"applied",I),{href:g}},onSuccess:async({href:i})=>{await Promise.all([t.invalidateQueries({queryKey:["forge-insights"]}),re(t),t.invalidateQueries({queryKey:["forge-xp-metrics"]}),t.invalidateQueries({queryKey:["forge-reward-ledger"]}),t.invalidateQueries({queryKey:["notes-index"]})]),j(null),i&&o(i)}}),u=(D=k.data)==null?void 0:D.insights,v=w.useMemo(()=>[...d.goals.slice(0,8).map(i=>({entityType:"goal",entityId:i.id,kind:"goal",label:i.title,description:i.description})),...d.projects.slice(0,8).map(i=>({entityType:"project",entityId:i.id,kind:"project",label:i.title,description:i.goalTitle})),...d.tasks.slice(0,10).map(i=>({entityType:"task",entityId:i.id,kind:"task",label:i.title,description:i.status.replaceAll("_"," ")}))],[d.goals,d.projects,d.tasks]),C=p.isPending?((s=p.variables)==null?void 0:s.insightId)??null:null,S=T.isPending?((l=T.variables)==null?void 0:l.insightId)??null:null,P=A.isPending?((n=A.variables)==null?void 0:n.insight.id)??null:null,N=d.metrics.topGoalId?d.goals.find(i=>i.id===d.metrics.topGoalId)??null:null;return k.isLoading?e.jsx(pe,{eyebrow:"Insights",title:"Loading the insight feed",description:"Pulling coaching, momentum analysis, and stored recommendations."}):k.isError||!u?e.jsx(ue,{eyebrow:"Insights",error:k.error,onRetry:()=>void t.invalidateQueries({queryKey:["forge-insights"]})}):e.jsxs("div",{className:"grid gap-5",children:[e.jsx(xe,{title:"Insights",description:"Save useful advice from you or your agent, review what seems worth acting on, and turn the good ones into real work when the timing is right.",badge:`${u.openCount} open`,actions:e.jsx(E,{onClick:()=>y(!0),children:"Store insight"})}),e.jsxs("section",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.1fr)_minmax(0,0.9fr)]",children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(F,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Momentum analysis"}),e.jsx("div",{className:"mt-4 grid grid-cols-5 gap-2 sm:grid-cols-10",children:u.momentumHeatmap.map(i=>e.jsxs("div",{className:"rounded-[16px] bg-white/[0.04] p-3",children:[e.jsx("div",{className:"h-12 rounded-[12px]",style:{background:i.intensity>=4?"rgba(192,193,255,0.95)":i.intensity===3?"rgba(192,193,255,0.7)":i.intensity===2?"rgba(192,193,255,0.45)":i.intensity===1?"rgba(192,193,255,0.2)":"rgba(255,255,255,0.05)"}}),e.jsx("div",{className:"mt-2 text-[10px] uppercase tracking-[0.16em] text-white/40",children:i.label})]},i.id))})]}),e.jsxs(F,{children:[e.jsxs("div",{className:"flex items-center gap-2 font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:[e.jsx("span",{children:"Execution trends"}),e.jsx($,{content:"The lavender series tracks completed XP by time window. The green series tracks execution pressure from focused and completed work. Read them together to see whether visible output and active work are moving in sync.",label:"Explain execution trends"})]}),e.jsx("div",{className:"mt-4 h-72 min-w-0",children:e.jsx(fe,{width:"100%",height:"100%",minWidth:280,minHeight:288,children:e.jsxs(ye,{data:u.executionTrends,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"insight-xp",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#c0c1ff",stopOpacity:"0.8"}),e.jsx("stop",{offset:"100%",stopColor:"#c0c1ff",stopOpacity:"0.08"})]})}),e.jsx(je,{dataKey:"label",tick:{fill:"rgba(255,255,255,0.42)",fontSize:11}}),e.jsx(we,{hide:!0}),e.jsx(R,{dataKey:"xp",stroke:"#c0c1ff",fill:"url(#insight-xp)",strokeWidth:2}),e.jsx(R,{dataKey:"focusScore",stroke:"#4edea3",fill:"rgba(78,222,163,0.06)",strokeWidth:2})]})})}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-3",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-white/[0.04] px-3 py-2 text-sm text-white/64",children:[e.jsx("span",{className:"size-2.5 rounded-full bg-[#c0c1ff]"}),e.jsx("span",{children:"Completed XP"}),e.jsx($,{content:"Completed XP is the reward Forge logged for finished work in each time window. It helps you see whether things are actually getting finished, not just started.",label:"Explain completed XP"})]}),e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-white/[0.04] px-3 py-2 text-sm text-white/64",children:[e.jsx("span",{className:"size-2.5 rounded-full bg-[#4edea3]"}),e.jsx("span",{children:"Focus score"}),e.jsx($,{content:"Focus score is Forge's rough read of how much active execution pressure was present in each window, based on focused and completed work.",label:"Explain focus score"})]})]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/54",children:"Use this chart to spot whether finished output and active deep-work pressure are rising together or starting to drift apart."})]}),e.jsxs(F,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"bg-white/[0.08] text-white/60",children:"Deterministic coaching"}),e.jsx($,{content:"This is Forge's built-in coaching read. It looks at your overdue work, blocked work, current goal pressure, and recent evidence to produce one grounded recommendation from the actual operating record.",label:"Explain deterministic coaching"})]}),e.jsx("h2",{className:"mt-4 font-display text-4xl text-white",children:u.coaching.title}),e.jsx("p",{className:"mt-4 text-sm leading-7 text-white/60",children:"Forge turns the current state of your goals, projects, tasks, and recent evidence into one focused operating read instead of a vague motivational hint."}),e.jsxs("div",{className:"mt-4 rounded-[18px] border border-white/8 bg-white/[0.04] px-4 py-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Current read"}),e.jsx("div",{className:"mt-2 text-sm leading-7 text-white/72",children:u.coaching.summary})]}),e.jsxs("div",{className:"mt-4 rounded-[22px] bg-[radial-gradient(circle_at_top_left,rgba(192,193,255,0.14),transparent_45%),rgba(255,255,255,0.03)] p-5",children:[e.jsx("div",{className:"font-medium text-white",children:"Recommendation"}),e.jsx("div",{className:"mt-2 text-sm leading-7 text-white/60",children:u.coaching.recommendation}),N?e.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"rounded-full bg-white/[0.06] px-3 py-2 text-sm text-white/64",children:["Connected goal: ",e.jsx("span",{className:"font-medium text-white",children:N.title})]}),e.jsx(E,{variant:"secondary",size:"sm",onClick:()=>o(`/goals/${N.id}`),children:"Open goal"})]}):null]})]})]}),e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(F,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Store insight"}),e.jsxs("div",{className:"mt-4 rounded-[22px] bg-white/[0.04] p-5",children:[e.jsx("div",{className:"font-medium text-white",children:"Capture advice without forcing it into a task too early"}),e.jsx("div",{className:"mt-2 text-sm leading-7 text-white/60",children:"Insights are saved suggestions from you or your agent. Use them when something feels worth remembering, but it is not ready to become a goal, project, or task yet."}),e.jsx("div",{className:"mt-4",children:e.jsx(E,{onClick:()=>y(!0),children:"Store insight"})})]})]}),e.jsxs(F,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Stored insights"}),e.jsx("div",{className:"mt-4 grid gap-3",children:u.feed.length===0?e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] p-4 text-sm text-white/55",children:"No stored insights yet."}):u.feed.map(i=>e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-white",children:i.title}),e.jsx("div",{className:"mt-1 text-sm text-white/56",children:i.summary}),i.user?e.jsx("div",{className:"mt-3",children:e.jsx(he,{user:i.user,compact:!0})}):null]}),e.jsx(Q,{className:"text-white/70",children:i.status})]}),e.jsx("div",{className:"mt-3 text-sm text-white/58",children:i.recommendation}),e.jsxs("div",{className:"mt-3 text-xs uppercase tracking-[0.16em] text-white/38",children:[i.originLabel??i.originType," · confidence ",Math.round(i.confidence*100),"%"]}),i.status==="applied"?e.jsx("div",{className:"mt-4 rounded-[16px] border border-emerald-400/18 bg-emerald-400/8 px-4 py-3 text-sm text-emerald-100/88",children:"This insight has already been turned into a real Forge record, so it stays here as a trace of what happened."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-4 text-sm text-white/52",children:i.status==="accepted"?"Accepted means this feels useful and worth keeping in view. Apply turns it into a real goal, project, task, or note when you are ready.":"Accept keeps this advice on the board. Apply turns it into a real Forge record now. Dismiss deletes it from the list."}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[i.status!=="accepted"?e.jsx(E,{variant:"secondary",pending:C===i.id,onClick:()=>void p.mutateAsync({insightId:i.id,feedbackType:"accepted"}),children:"Accept"}):null,e.jsx(E,{pending:P===i.id,onClick:()=>j(i),children:"Apply"}),e.jsx(E,{variant:"ghost",pending:S===i.id,onClick:()=>void T.mutateAsync({insightId:i.id}),children:"Dismiss"})]})]})]},i.id))})]})]})]}),e.jsx(ge,{open:h,onOpenChange:y,entityCandidates:v,pending:m.isPending,onSubmit:async i=>{await m.mutateAsync(i)}}),b?e.jsx(Me,{open:!!b,onOpenChange:i=>{i||j(null)},insight:b,goals:d.goals,projects:d.projects,tasks:d.tasks,tags:d.tags,pending:A.isPending,onSubmit:async i=>{await A.mutateAsync({insight:b,submission:i})}}):null]})}export{We as InsightsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b5 as Re,r as n,j as s,aC as Ce,b3 as Be,aK as Oe,c9 as Ae}from"./vendor-kIz9EZnX.js";import{j as Le,k as A}from"./state-VYvD1QVP.js";import{P as We,u as Ke,c as h,U as me,b as L,s as Ue,as as ze,at as _e,au as qe,B as v,a as pe,av as Qe,C as G,aw as De,m as H,ax as Ve,ay as Ge,Y as He,az as Xe,I as ge,i as Ye}from"./index-BHIKoiZ6.js";import{E as Je}from"./execution-board-CpO2ch6v.js";import{P as Ze}from"./project-management-section-nav-BLdAgTge.js";import{P as xe}from"./page-hero-oFHaAjtL.js";import"./motion-CfdU2F35.js";import"./ui-CsEkP2V8.js";import"./forms-CmLAyGqz.js";import"./board-DqHzdCPQ.js";import"./graph-BTa79qum.js";import"./entity-note-count-link-BrS1-O0o.js";import"./floating-action-menu-zzC2r0Ob.js";const x={goal:"goal:",project:"project:",tag:"tag:"},k={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(l){return l.trim().toLowerCase()}function ss(l){return l.reduce((t,r)=>(r.startsWith(x.goal)?t.goalIds.push(r.slice(x.goal.length)):r.startsWith(x.project)?t.projectIds.push(r.slice(x.project.length)):r.startsWith(x.tag)&&t.tagIds.push(r.slice(x.tag.length)),t),{goalIds:[],projectIds:[],tagIds:[]})}function ts(l){return l.reduce((t,r)=>{if(r.startsWith(k.user))t.userIds.push(r.slice(k.user.length));else if(r.startsWith(k.kind)){const u=r.slice(k.kind.length);(u==="human"||u==="bot")&&t.kinds.push(u)}return t},{userIds:[],kinds:[]})}function be(l,t,r,u){l([]),t([]),r(""),u(["task","subtask"])}function as(l){const t=l.trim();return t.length===0?{firstTitle:"Split task part 1",secondTitle:"Split task part 2"}:{firstTitle:`${t} - part 1`,secondTitle:`${t} - part 2`}}function bs(){var le,re,oe,de,ce,ue,he;const{t:l}=We(),t=Ke(),r=Re(),u=Le(),[$,W]=n.useState([]),[E,K]=n.useState([]),[y,F]=n.useState(""),[w,U]=n.useState(["task","subtask"]),[z,M]=n.useState(((re=(le=t.snapshot.workItems)==null?void 0:le[0])==null?void 0:re.id)??((oe=t.snapshot.tasks[0])==null?void 0:oe.id)??null),[Y,_]=n.useState(null),[fe,q]=n.useState(void 0),[J,I]=n.useState(null),[je,R]=n.useState(void 0),[o,C]=n.useState(null),[Z,Q]=n.useState(null),[d,B]=n.useState({firstTitle:"",secondTitle:"",remainingRatio:.5}),ke=n.useMemo(()=>[...t.snapshot.goals.map(e=>({value:`${x.goal}${e.id}`,label:e.title,description:"Goal",searchText:`goal ${e.title} ${e.description??""}`,kind:"goal"})),...t.snapshot.dashboard.projects.map(e=>({value:`${x.project}${e.id}`,label:e.title,description:"Project",searchText:`project ${e.title} ${e.description??""} ${e.goalTitle??""}`,kind:"project"})),...t.snapshot.tags.map(e=>({value:`${x.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]),we=n.useMemo(()=>{const e=t.snapshot.users.filter(i=>i.kind==="bot"),a=t.snapshot.users.filter(i=>i.kind==="human");return[{value:`${k.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(h,{className:"border-cyan-300/18 bg-cyan-400/12 text-cyan-50",children:"Bots"}),menuBadge:s.jsx(h,{className:"border-cyan-300/18 bg-cyan-400/12 text-cyan-50",children:"Bots"})},{value:`${k.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(h,{className:"border-amber-300/18 bg-amber-400/12 text-amber-50",children:"Humans"}),menuBadge:s.jsx(h,{className:"border-amber-300/18 bg-amber-400/12 text-amber-50",children:"Humans"})},...t.snapshot.users.map(i=>({value:`${k.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(me,{user:i,compact:!0}),menuBadge:s.jsx(me,{user:i,compact:!0})}))]},[t.snapshot.users]),ve=n.useMemo(()=>es.map(e=>({value:e.value,label:e.label,searchText:e.searchText,badge:e.value==="subtask"?s.jsx(L,{kind:"task",label:"Subtask",compact:!0,gradient:!1,className:"border-indigo-300/18 bg-indigo-400/12 text-indigo-100"}):s.jsx(L,{kind:e.kind??e.value,label:e.label,compact:!0,gradient:!1}),menuBadge:e.value==="subtask"?s.jsx(L,{kind:"task",label:"Subtask",compact:!0,gradient:!1,className:"border-indigo-300/18 bg-indigo-400/12 text-indigo-100"}):s.jsx(L,{kind:e.kind??e.value,label:e.label,compact:!0,gradient:!1})})),[]),m=n.useMemo(()=>ss($),[$]),b=n.useMemo(()=>ts(E),[E]),O=n.useMemo(()=>X(y),[y]),p=n.useMemo(()=>t.snapshot.workItems&&t.snapshot.workItems.length>0?t.snapshot.workItems:t.snapshot.tasks,[t.snapshot.tasks,t.snapshot.workItems]),ye=n.useMemo(()=>new Map(t.snapshot.dashboard.projects.map(e=>[e.id,e])),[t.snapshot.dashboard.projects]),f=p.filter(e=>{var a;if(!w.includes(e.level))return!1;if(O.length>0){const i=e.projectId?ye.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(O))return!1}if(m.goalIds.length>0&&(e.goalId===null||!m.goalIds.includes(e.goalId))||m.projectIds.length>0&&(e.projectId===null||!m.projectIds.includes(e.projectId))||m.tagIds.length>0&&!m.tagIds.every(i=>e.tagIds.includes(i)))return!1;if(b.userIds.length>0||b.kinds.length>0){const i=[...e.user?[e.user]:[],...e.assignees??[]],c=i.some(j=>b.userIds.includes(j.id)),P=i.some(j=>b.kinds.includes(j.kind));if(!c&&!P)return!1}return!0}),D=t.snapshot.dashboard.projects.filter(e=>{var a;if(!w.includes("project")||O.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(O)||m.goalIds.length>0&&!m.goalIds.includes(e.goalId)||m.projectIds.length>0&&!m.projectIds.includes(e.id))return!1;if(b.userIds.length>0||b.kinds.length>0){const i=[...e.user?[e.user]:[],...e.assignees??[]],c=i.some(j=>b.userIds.includes(j.id)),P=i.some(j=>b.kinds.includes(j.kind));if(!c&&!P)return!1}return!0}),Ie=f.length+D.length,Te=D.length>0||f.length>0,Ne=y.trim().length>0||$.length>0||E.length>0||w.length!==2||!w.includes("task")||!w.includes("subtask"),ee=f.find(e=>e.id===z)??p.find(e=>e.id===z)??null,T=Y?t.snapshot.dashboard.projects.find(e=>e.id===Y)??null:null,g=J?p.find(e=>e.id===J)??null:null,Se=f.filter(e=>e.status==="blocked").length,Pe=f.filter(e=>e.status==="done").length,$e=f.filter(e=>e.status==="focus"||e.status==="in_progress").length,se=t.snapshot.activeTaskRuns.length,te=Ue(t.selectedUserIds),N=Z?p.find(e=>e.id===Z)??null:null,S=async()=>{await Promise.all([t.refresh(),Ye(u),u.invalidateQueries({queryKey:["project-board"]}),u.invalidateQueries({queryKey:["task-context"]})])},Ee=A({mutationFn:({taskId:e,patch:a})=>t.patchTask(e,a),onSuccess:S}),Fe=A({mutationFn:e=>ze(e),onSuccess:S}),Me=A({mutationFn:_e,onSuccess:S}),ae=A({mutationFn:({taskId:e,firstTitle:a,secondTitle:i,remainingRatio:c})=>qe(e,{firstTitle:a,secondTitle:i,remainingRatio:c}),onSuccess:async()=>{await S(),Q(null)}}),ie=(e,a)=>{_(e),q(a)},ne=(e,a)=>{I(e),C(null),R(a)},V=e=>{I(null),R(void 0),C(e)};return p.length===0&&t.snapshot.dashboard.projects.length===0?s.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-5",children:[s.jsx(xe,{title:"Kanban",description:"Move tasks across the board, start work quickly, and keep your next step visible.",badge:"0 visible tasks",actions:s.jsx(v,{size:"lg",onClick:()=>t.openStartWork(),children:"Start work"})}),s.jsx(pe,{eyebrow:l("common.kanban.heroEyebrow"),title:l("common.kanban.emptyTitle"),description:l("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-slate-950 transition hover:opacity-90",children:l("common.kanban.emptyAction")})})]}):s.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-5",children:[s.jsx(Ze,{}),s.jsx(xe,{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:`${Ie} visible work items`,actions:s.jsx(v,{size:"lg",onClick:()=>t.openStartWork(ee?{taskId:ee.id}:void 0),children:"Start work"})}),s.jsx(Qe,{children:s.jsx(G,{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-white/45",children:"Board"}),s.jsx("div",{className:"mt-2 text-base text-white",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(h,{className:"bg-white/[0.08] text-white/72",children:[$e," ready or active"]}),s.jsxs(h,{className:"bg-white/[0.08] text-white/72",children:[Se," blocked"]}),s.jsxs(h,{className:"bg-white/[0.08] text-white/72",children:[Pe," done"]}),s.jsxs(h,{className:"bg-white/[0.08] text-white/72",children:[se," live timer",se===1?"":"s"]}),s.jsxs(h,{className:"bg-[var(--primary)]/12 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(De,{children:s.jsxs(G,{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-white/40",children:"Filters"}),s.jsx("div",{className:"mt-2 text-sm text-white/56",children:"Use compact entity chips for goals, projects, tags, and owner scopes instead of the wide pill rows."})]}),Ne?s.jsx(v,{variant:"secondary",size:"sm",onClick:()=>be(W,K,F,U),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-white/10 bg-black/20 px-4 py-3",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Be,{className:"size-4 text-white/36"}),s.jsx("input",{value:y,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-white placeholder:text-white/34 focus:outline-none"}),y.trim().length>0?s.jsx("button",{type:"button",className:"rounded-full text-white/46 transition hover:text-white",onClick:()=>F(""),"aria-label":"Clear board search",children:s.jsx(Oe,{className:"size-4"})}):null]})}),s.jsx(H,{options:ve,selectedValues:w,onChange:e=>U(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-white/42",children:"Entity filters"}),s.jsx(H,{options:ke,selectedValues:$,onChange:W,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-white/42",children:"Owner filters"}),s.jsx(H,{options:we,selectedValues:E,onChange:K,placeholder:"Type Bo for bots, Hu for humans, or a teammate name",emptyMessage:"No matching owners."})]})]})]})}),Te?s.jsx(Ve,{children:s.jsx(Je,{tasks:f,projects:D,activeRuns:t.snapshot.activeTaskRuns,goals:t.snapshot.goals,tags:t.snapshot.tags,notesSummaryByEntity:t.snapshot.dashboard.notesSummaryByEntity,selectedTaskId:z,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=f.find(c=>c.id!==e))==null?void 0:i.id)??null}),I(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=>{r(`/projects/${e}`)},onOpenTask:e=>{r(`/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=p.find(i=>i.id===e)??null;a&&V({initialLevel:"task",initialGoalId:a.goalId,initialProjectId:a.projectId,initialParentWorkItemId:a.id})},onCreateSubtaskForTask:e=>{const a=p.find(i=>i.id===e)??null;a&&V({initialLevel:"subtask",initialGoalId:a.goalId,initialProjectId:a.projectId,initialParentWorkItemId:a.id})},onSplitTask:e=>{const a=p.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:l("common.kanban.heroEyebrow"),title:l("common.kanban.noTasksMatch"),description:"No tasks match the current filters. Reset the filters to bring the full board back.",action:s.jsx(v,{variant:"secondary",onClick:()=>be(W,K,F,U),children:"Reset"})}),s.jsx(He,{open:T!==null,goals:t.snapshot.goals,users:t.snapshot.users,editingProject:T,defaultUserId:(T==null?void 0:T.userId)??te,initialStepId:fe,onOpenChange:e=>{e||(_(null),q(void 0))},onSubmit:async(e,a)=>{a&&(await t.patchProject(a,e),_(null),q(void 0))}}),s.jsx(Xe,{open:g!==null||o!==null,goals:t.snapshot.goals,projects:t.snapshot.dashboard.projects,workItems:p,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:je,defaultUserId:(g==null?void 0:g.userId)??te,onRefreshEntities:t.refresh,currentCreditedSeconds:g==null?void 0:g.time.totalCreditedSeconds,onOpenChange:e=>{e||(I(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),I(null),C(null),R(void 0)}}),N?s.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-[rgba(5,8,18,0.74)] p-4 backdrop-blur-xl",children:s.jsxs(G,{className:"w-full max-w-xl border border-white/10 bg-[linear-gradient(180deg,rgba(16,22,36,0.96),rgba(9,13,22,0.98))] shadow-[0_32px_90px_rgba(5,8,18,0.58)]",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-amber-400/14 text-amber-100",children:s.jsx(Ae,{className:"size-5"})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"font-display text-[1.35rem] leading-tight text-white",children:"Split this task"}),s.jsxs("div",{className:"mt-2 text-sm leading-6 text-white/64",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-white/40",children:"First task name"}),s.jsx(ge,{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-white/40",children:"Second task name"}),s.jsx(ge,{value:d.secondTitle,onChange:e=>B(a=>({...a,secondTitle:e.target.value}))})]}),s.jsxs("div",{className:"grid gap-3 rounded-[18px] bg-white/[0.04] px-4 py-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm text-white/70",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(h,{className:"bg-white/[0.08] text-white/72",children:[Math.round((((ue=N.actionPointSummary)==null?void 0:ue.totalCostAp)??0)*d.remainingRatio)," ","AP first child"]}),s.jsxs(h,{className:"bg-white/[0.08] text-white/72",children:[Math.round((((he=N.actionPointSummary)==null?void 0:he.totalCostAp)??0)*(1-d.remainingRatio))," ","AP second child"]})]})]})]}),s.jsxs("div",{className:"mt-5 flex flex-wrap justify-end gap-3",children:[s.jsx(v,{variant:"secondary",onClick:()=>{Q(null)},children:"Cancel"}),s.jsx(v,{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{bs as KanbanPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as p,j as r,b5 as Ut,c2 as qt,cg as Qt,cl as Jt,cm as ot,bf as ct,b4 as Zt,cn as er,co as tr,cp as rr}from"./vendor-kIz9EZnX.js";import{R as nr,P as ar,O as sr,C as ir,T as or,D as cr,a as lt}from"./ui-CsEkP2V8.js";import{i as lr}from"./state-VYvD1QVP.js";import{aA as ur,aB as at,aC as Rt,aD as dr,aE as hr,aF as pr,aG as et,aH as Le,aI as jt,aJ as tt,aK as Gt,aL as Mt,aM as gr,aN as fr,b as qe,V as mr,aO as xr,aP as br,ap as wr,u as yr,aQ as ut,aR as vr,L as Nr,E as Sr,aS as _r,U as dt,a8 as Cr,B as W,m as we,I as Xe,aT as ht,aU as Er,aV as Rr,aW as jr}from"./index-BHIKoiZ6.js";import{G as Gr,S as Mr,i as Fr,C as Kr,B as Ir,M as kr}from"./graph-BTa79qum.js";import{F as pt}from"./faceted-token-search-D7xPWfOl.js";import{A as Ar,m as Or}from"./motion-CfdU2F35.js";import"./forms-CmLAyGqz.js";import"./board-DqHzdCPQ.js";const Pr=Math.PI*(3-Math.sqrt(5)),Tr=.48;function $e(e,t,a){return Math.min(a,Math.max(t,e))}function Dr({positions:e,point:t}){const a=[...e.values()];if(a.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 a)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,w=(1-i/m)/2,G=l||1,f=i||1;return{x:$e((t.x-s)/G*(l/m)+g,0,1),y:$e((t.y-o)/f*(i/m)+w,0,1)}}function zr(e){let t=2166136261;for(let a=0;a<e.length;a+=1)t^=e.charCodeAt(a),t=Math.imul(t,16777619);return t>>>0}function Lr({nodes:e,cache:t}){const a=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){a.set(l.id,m),u+=m.x,o+=m.y,c+=1;return}const g=(zr(l.id)%1e3/1e3-.5)*.22,w=i*Pr+g,G=Tr*Math.sqrt(i+1),f={x:Math.cos(w)*G,y:Math.sin(w)*G};a.set(l.id,f),u+=f.x,o+=f.y,c+=1}),c>0){const l=u/c,i=o/c;a.forEach((m,g)=>{a.set(g,{x:m.x-l,y:m.y-i})})}return a}function $r(e,t){if(e.startsWith("rgb(")&&e.endsWith(")"))return e.replace("rgb(","rgba(").replace(")",`, ${t})`);if(e.startsWith("#")){const a=e.slice(1),s=a.length===3?a.split("").map(l=>`${l}${l}`).join(""):a,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 Ge(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 gt(e,t){return!t.focusNodeId||e===t.focusNodeId?0:t.detailNodeIds.has(e)?1:t.relatedNodeIds.has(e)?2:3}function Yr({nodeId:e,attributes:t,node:a,focusNodeId:s,relatedNodeIds:u,detailNodeIds:o,hoveredNodeId:c,draggedNodeId:l}){const i=s===e,m=u.has(e),g=o.has(e),w=c===e,G=l===e,f=!s||m,N=t.color;return{...t,label:i||w||G||g?a.title:"",forceLabel:i||w||G||g,highlighted:i||w||G||g,color:f?N:$r(N,.34),size:G?t.size*2:i?t.size*1.8:w?t.size*1.35:g?t.size*1.16:m?t.size*1.06:t.size,zIndex:G?4:i?3:g||w?2:1}}function Hr({attributes:e,edge:t,focusNodeId:a,detailNodeIds:s,relatedNodeIds:u,hoveredNodeId:o}){const c=!!a&&(t.source===a||t.target===a),l=!!o&&(t.source===o||t.target===o),i={focusNodeId:a,detailNodeIds:s,relatedNodeIds:u},m=a?Math.max(gt(t.source,i),gt(t.target,i)):0,g=c?Ge(t.family,.24):l?Ge(t.family,.14):a?m<=1?Ge(t.family,.09):m===2?Ge(t.family,.05):Ge(t.family,.016):Ge(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 ft(e,t){const a=new Set,s=new Set;for(const u of e)u.source===t?a.add(u.target):u.target===t&&a.add(u.source);for(const u of e)u.source!==t&&a.has(u.source)&&s.add(u.target),u.target!==t&&a.has(u.target)&&s.add(u.source);return s.delete(t),a.forEach(u=>s.delete(u)),{firstRing:[...a].sort(),secondRing:[...s].sort()}}function mt(e,t,a){if(!a)return e.map(()=>-1);const s=new Set(e);if(!s.has(a))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([[a,0]]);let c=[a];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 Vr({positions:e,focusNodeId:t,firstRingNodeIds:a,secondRingNodeIds:s,currentRatio:u}){const o=e.get(t);if(!o)return null;const c=[t,...a,...s].filter((L,fe,F)=>F.indexOf(L)===fe),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,w=Number.NEGATIVE_INFINITY,G=Number.POSITIVE_INFINITY,f=Number.NEGATIVE_INFINITY,N=Number.POSITIVE_INFINITY,K=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),K=Math.max(K,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),w=Math.max(w,L.y);const E=Math.max(m-i,w-g,.75),z=Math.max(f-G,K-N,E),M=l.length<=1?$e(Math.max(u,.48),.38,.6):$e(E/z*3.2,.42,Math.max(u,1.12));return{x:o.x,y:o.y,ratio:M,nodeIds:c}}function Ft({positions:e,currentRatio:t=1}){const a=[...e.values()];if(a.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 a)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=$e(l/6.4,.72,2.8);return{x:0,y:0,ratio:Math.max(t,i)}}let De=null;function Br(){if(De!==null)return De;if(typeof document>"u")return De=!1,!1;const e=document.createElement("canvas");return De=!!(e.getContext("webgl2")||e.getContext("webgl")||e.getContext("experimental-webgl")),De}function Xr(e){if(!e||typeof window>"u")return"#c0c1ff";const t=document.body?getComputedStyle(document.body).getPropertyValue(e).trim():"",a=getComputedStyle(document.documentElement).getPropertyValue(e).trim(),s=t||a;return s?`rgb(${s})`:"#c0c1ff"}function Wr(e,t){if(e.startsWith("rgb(")&&e.endsWith(")"))return e.replace("rgb(","rgba(").replace(")",`, ${t})`);if(e.startsWith("#")){const a=e.slice(1),s=a.length===3?a.split("").map(l=>`${l}${l}`).join(""):a,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 ze(e,t){e.forEachNode(a=>{const s=e.getNodeAttributes(a);Number.isFinite(s.x)&&Number.isFinite(s.y)&&t.set(a,{x:s.x,y:s.y})})}function Ur(e,t,a){const s=new Gr,u=[...e].sort((c,l)=>l.importance-c.importance||c.title.localeCompare(l.title)||c.id.localeCompare(l.id)),o=Lr({nodes:u,cache:a});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:Xr(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 xt(e){if(e.order===0)return;let t=0,a=0,s=0;if(e.forEachNode(c=>{const l=e.getNodeAttributes(c);t+=l.x,a+=l.y,s+=1}),s===0)return;const u=t/s,o=a/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 bt(e){const t=new Map;return e.forEachNode(a=>{const s=e.getNodeAttributes(a);t.set(a,{x:s.x,y:s.y})}),t}function Me(e,t){return{nodes:e.nodes().map(a=>({id:a,...e.getNodeAttributes(a)})),edges:t}}function qr(e){if(e.nodes.length===0)return{minX:-1,maxX:1,minY:-1,maxY:1};let t=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,s=Number.POSITIVE_INFINITY,u=Number.NEGATIVE_INFINITY;for(const o of e.nodes)t=Math.min(t,o.x),a=Math.max(a,o.x),s=Math.min(s,o.y),u=Math.max(u,o.y);return{minX:t,maxX:a,minY:s,maxY:u}}function Qr(e){const t=Ft({positions:new Map(e.nodes.map(a=>[a.id,{x:a.x,y:a.y}])),currentRatio:1});return{x:t.x,y:t.y,angle:0,ratio:t.ratio}}function Jr({x:e,y:t}){const a=Array.from({length:e.length},(u,o)=>({x:e[o]??0,y:t[o]??0})),s=ur(a);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 Kt({node:e,snapshot:t,camera:a,width:s,height:u}){const o=qr(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(a.ratio,.08);return{x:s/2+(e.x-a.x)*g,y:u/2-(e.y-a.y)*g,size:Math.max(4,e.size*g*.12)}}function wt(e,t){if(!e)return!1;const a=e.clientWidth,s=e.clientHeight,u=e.getBoundingClientRect();return e.isConnected&&t.width>0&&t.height>0&&a>0&&s>0&&u.width>0&&u.height>0&&e.getClientRects().length>0}function Zr({sigma:e,graph:t,viewportX:a,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-a,w=m.y-s,G=Math.hypot(g,w),f=Math.max(i.size*1.8,18);G<=f&&G<o&&(u=c,o=G)}),u}function Fe(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 It({input:e,rendererMode:t,visibleNodeIds:a,focusPressureByNodeId:s,boundsCenter:u,focusedNodePosition:o,camera:c,nodeScreenPositions:l}){const i=Rt({centroid:e.centroid,boundsCenter:u,camera:c});window.__FORGE_KNOWLEDGE_GRAPH_DIAGNOSTICS__={datasetSignature:e.datasetSignature,visibleNodeIds:a,visibleNodeCount:a.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 en(){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 yt(){typeof window>"u"||(delete window.__FORGE_KNOWLEDGE_GRAPH_DIAGNOSTICS__,delete window.__FORGE_KNOWLEDGE_GRAPH_TEST_API__)}function tn(e){const t=[],a={},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});a[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=at(t.map(c=>{const l=e.graph.getNodeAttributes(c);return{x:l.x,y:l.y}}));It({input:e,rendererMode:"sigma",visibleNodeIds:t,focusPressureByNodeId:s,boundsCenter:o,focusedNodePosition:u,camera:e.sigma.getCamera().getState(),nodeScreenPositions:a})}function vt(e){const t=e.snapshot.nodes.map(o=>o.id),a={},s={};let u=null;e.snapshot.nodes.forEach((o,c)=>{a[o.id]=Kt({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})}),It({input:e,rendererMode:"fallback",visibleNodeIds:t,focusPressureByNodeId:s,boundsCenter:at(e.snapshot.nodes.map(o=>({x:o.x,y:o.y}))),focusedNodePosition:u,camera:e.camera,nodeScreenPositions:a})}function Nt(e){const t=et.indexOf(e);return t>=0?t:et.length-1}function rn(e){const t=Le.find(a=>a.kinds.some(s=>s===e))??Le[Le.length-1];return{laneId:t.id,laneLabel:t.label,laneIndex:Le.findIndex(a=>a.id===t.id)}}function We(){return{structural:0,contextual:0,taxonomy:0,workspace:0}}function nn(e){const t=new Map;for(const a of e){const s=t.get(a.source)??new Set;s.add(a.target),t.set(a.source,s);const u=t.get(a.target)??new Set;u.add(a.source),t.set(a.target,u)}return t}function an(e,t){return t.strength-e.strength||e.relationKind.localeCompare(t.relationKind)||e.label.localeCompare(t.label)||e.id.localeCompare(t.id)}function kt(e){const t=new Map;for(const a of e){const s=`${a.source}→${a.target}`,u=t.get(s)??[];u.push(a),t.set(s,u)}return Array.from(t.entries()).map(([a,s])=>{const u=[...s].sort(an),o=u[0],c=u.length,l=Math.max(...u.map(i=>i.strength))*Math.min(1.45,1+(c-1)*.12);return{id:`${a}#${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((a,s)=>a.source.localeCompare(s.source)||a.target.localeCompare(s.target)||a.id.localeCompare(s.id))}function sn(e,t){const a=kt(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=a.map(o=>`${o.source}:${o.target}:${o.parallelCount}:${o.label}:${o.strength.toFixed(3)}`).join("|");return`${e.length}/${a.length}/${s}::${u}`}function At(e,t){const a=[...e].sort((l,i)=>{const m=Nt(l.entityKind)-Nt(i.entityKind);return m!==0?m:i.importance-l.importance||l.title.localeCompare(i.title)}),s=new Map,u=a.map(l=>{const{laneId:i,laneIndex:m,laneLabel:g}=rn(l.entityKind),w=s.get(m)??0;return s.set(m,w+1),{...l,layer:m,laneId:i,laneLabel:g,row:w}}),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,w=(m==null?void 0:m.layer)??0;return{...l,secondary:w<=g||l.family!=="structural"&&l.family!=="taxonomy"}});return{nodes:u,edges:c}}function St(e,t,a){const s=new Map(e.map(f=>[f.id,f])),u=a?s.get(a)??null:null;if(!u)return{generatedAt:new Date().toISOString(),focusNode:null,firstRingNodes:[],neighborhoodEdges:[],familyGroups:[],relationCounts:We(),secondRingCounts:We()};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=We(),g=We(),w=nn(t);for(const f of c){const N=w.get(f)??new Set;for(const K of N){if(K===u.id||c.includes(K))continue;const E=t.filter(z=>z.source===f&&z.target===K||z.target===f&&z.source===K);for(const z of E)g[z.family]+=1}}for(const f of o){const N=f.source===u.id?f.target:f.source,K=s.get(N);if(!K)continue;m[f.family]+=1;const E=i.get(f.relationKind);if(E){E.items.some(z=>z.id===K.id)||E.items.push(K);continue}i.set(f.relationKind,{relationKind:f.relationKind,family:f.family,label:dr[f.relationKind],items:[K]})}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((K,E)=>K.title.localeCompare(E.title))}),N.itemCount+=f.items.length,N.relationCount+=1;continue}G.set(f.family,{family:f.family,label:hr[f.family],relationCount:1,itemCount:f.items.length,relations:[{...f,items:[...f.items].sort((K,E)=>K.title.localeCompare(E.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,K)=>N.label.localeCompare(K.label))})).sort((f,N)=>f.label.localeCompare(N.label)),relationCounts:m,secondRingCounts:g}}function on(e,t){return pr(e,t)}function cn(e,t){if(!e)return new Set;const a=new Set([e]);for(const s of t)s.source===e?a.add(s.target):s.target===e&&a.add(s.source);return a}const ln=p.forwardRef(function({nodes:t,edges:a,focusNodeId:s,physicsSettings:u,onSelectNode:o},c){jt(),tt(d=>d.knowledgeGraphDiagnostics.panelOpen);const l=p.useRef(null),i=p.useRef(null),m=p.useRef(null),g=p.useRef(null),w=p.useRef(new Map),G=p.useRef(new Map),f=p.useRef(new Map),N=p.useRef(o),K=p.useRef(s),E=p.useRef(null),z=p.useRef(0),M=p.useRef(null),L=p.useRef(0),fe=p.useRef(!0),F=p.useRef(null),ce=p.useRef(0),A=p.useRef("global"),me=p.useRef(null),Ke=p.useRef([]),Ce=p.useRef(new Float32Array(0)),ye=p.useRef({x:0,y:0}),$=p.useRef("boot"),ve=p.useRef(!1),Y=p.useRef(!1),P=p.useRef(!1),te=p.useRef(null),le=p.useRef(null),Ee=p.useRef(0),Ne=p.useRef(0);p.useRef(0),p.useRef(Gt("/knowledge-graph"));const[Q,ue]=p.useState(null),[xe,de]=p.useState(null),[he,H]=p.useState(null),[pe,V]=p.useState({x:0,y:0,angle:0,ratio:1}),[b,B]=p.useState(null),[v,Ye]=p.useState({width:0,height:0}),Re=Mt(),re=(d=g.current)=>Ft({positions:d?bt(d):new Map,currentRatio:1}).ratio,Ie=(d=g.current)=>({x:.5,y:.5,angle:0,ratio:re(d)}),ke=(d=g.current)=>({x:0,y:0,angle:0,ratio:re(d)}),Ae=()=>i.current?"sigma":"fallback",T=p.useMemo(()=>kt(a),[a]),ge=p.useMemo(()=>sn(t,a),[a,t]),q=p.useMemo(()=>s?ft(T,s):null,[s,T]),ne=p.useMemo(()=>s?new Set([s,...(q==null?void 0:q.firstRing)??[]]):new Set,[s,q]),ae=p.useMemo(()=>s?new Set([s,...(q==null?void 0:q.firstRing)??[],...(q==null?void 0:q.secondRing)??[]]):new Set,[s,q]),He=()=>wt(l.current,v),se=({resize:d=!1}={})=>{if(!i.current||!He())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}},Oe=()=>Date.now()<L.current,D=({level:d,eventKey:x,message:y,details:C,publishBackend:_=!1})=>{},Je=()=>i.current?{...i.current.getCamera().getState()}:{...pe},be=({rendererMode:d})=>{if(!g.current||!E.current)return null;const x=g.current,y=x.nodes().map(S=>{const k=x.getNodeAttributes(S);return{id:S,x:k.x,y:k.y}}),C=gr(y),_=at(y),I=Je(),O=d==="sigma"?{...I,x:Number((I.x-.5).toFixed(4)),y:Number((I.y-.5).toFixed(4))}:I,j=Rt({centroid:C,boundsCenter:_,camera:O});return{datasetSignature:E.current,route:"/knowledge-graph",rendererMode:d,startupPhase:$.current,startupInvariantSatisfied:fr(j),visibleNodeCount:y.length,focusedNodeId:K.current,primaryFocusedNodeId:me.current,graphCentroid:C,boundsCenter:_,camera:I,cameraTarget:F.current?{x:F.current.x,y:F.current.y,ratio:F.current.ratio}:null,driftMetrics:j,latestSnapshotAt:te.current,lastVerifiedAt:new Date().toISOString()}},Ve=(d,{mirrorToConsole:x=!1}={})=>{},Be=({rendererMode:d,publishAnomaly:x})=>{},Pe=()=>{const d=i.current?Ie():ke();if(i.current){i.current.getCamera().setState(d);return}V(d)},n=d=>{var _;if(!g.current)return!1;const x=be({rendererMode:Ae()});if(!x)return!1;const y=x.graphCentroid.x,C=x.graphCentroid.y;return Math.abs(y)<1e-4&&Math.abs(C)<1e-4?!1:(xt(g.current),ze(g.current,w.current),(_=m.current)==null||_.postMessage({type:"recenter-graph",offsetX:y,offsetY:C}),B(Me(g.current,T)),Pe(),$.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:E.current}}),!0)},h=({phase:d,allowCorrection:x,publishBackendOnFailure:y=!1})=>{if(!g.current||!E.current)return;$.current=d;const C=i.current?"sigma":"fallback",_=be({rendererMode:C});if(!_)return;if(_.startupInvariantSatisfied){$.current="startup_verified",Ve({..._},{mirrorToConsole:!0}),D({level:"info",eventKey:"startup_verified",message:"Knowledge graph startup invariant passed.",details:{datasetSignature:_.datasetSignature,driftMetrics:_.driftMetrics}});return}if(D({level:"warning",eventKey:"startup_invariant_failed",message:"Knowledge graph startup invariant failed before correction.",publishBackend:y,details:{datasetSignature:_.datasetSignature,driftMetrics:_.driftMetrics,centroid:_.graphCentroid,boundsCenter:_.boundsCenter,camera:_.camera}}),ve.current||(ve.current=!0,!n()))return;se();const O=be({rendererMode:C});if(O){if(O.startupInvariantSatisfied){$.current="startup_verified",Ve({...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}})}},R=()=>{var x,y,C,_;if(!E.current||!g.current)return;const d=Date.now();if(!(d-Ne.current<1500)){if(Ne.current=d,i.current){tn({datasetSignature:E.current,focusNodeId:K.current,primaryFocusedNodeId:me.current,draggedNodeId:((x=M.current)==null?void 0:x.nodeId)??null,graph:g.current,layoutGeneration:z.current,sigma:i.current,startupPhase:$.current,startupInvariantSatisfied:((y=be({rendererMode:"sigma"}))==null?void 0:y.startupInvariantSatisfied)??!1,simulationPhase:A.current,focusSources:Ke.current,focusPressure:Ce.current,centroid:ye.current,cameraTarget:F.current?{x:F.current.x,y:F.current.y,ratio:F.current.ratio}:null,latestSnapshotAt:te.current,latestSnapshotNodeCount:le.current});return}b&&vt({datasetSignature:E.current,focusNodeId:K.current,primaryFocusedNodeId:me.current,draggedNodeId:((C=M.current)==null?void 0:C.nodeId)??null,layoutGeneration:z.current,camera:pe,snapshot:b,width:v.width,height:v.height,startupPhase:$.current,startupInvariantSatisfied:((_=be({rendererMode:"fallback"}))==null?void 0:_.startupInvariantSatisfied)??!1,simulationPhase:A.current,focusSources:Ke.current,focusPressure:Ce.current,centroid:ye.current,cameraTarget:F.current?{x:F.current.x,y:F.current.y,ratio:F.current.ratio}:null,latestSnapshotAt:te.current,latestSnapshotNodeCount:le.current})}},Te=()=>{if(!g.current||!K.current){F.current=null;return}const d=g.current;if(!d.hasNode(K.current)){F.current=null;return}const x=bt(d),y=ft(T,K.current),C=i.current?i.current.getCamera().getState().ratio:pe.ratio,_=Vr({positions:x,focusNodeId:K.current,firstRingNodeIds:y.firstRing,secondRingNodeIds:y.secondRing,currentRatio:C}),I=i.current&&_?Dr({positions:x,point:{x:_.x,y:_.y}}):null;F.current=_?{x:(I==null?void 0:I.x)??_.x,y:(I==null?void 0:I.y)??_.y,angle:0,ratio:_.ratio,nodeIds:_.nodeIds}:null},st=(d=220)=>{if(!F.current)return;const x=F.current;if(i.current){const y=i.current.getCamera(),C=y.getState(),_=Date.now()<ce.current;y.animate({x:x.x,y:x.y,ratio:_?C.ratio:x.ratio,angle:0},{duration:d});return}V(y=>({...y,x:x.x,y:x.y,ratio:Date.now()<ce.current?y.ratio:x.ratio}))};p.useEffect(()=>{N.current=o},[o]),p.useEffect(()=>{K.current=s,F.current=null},[s]),p.useEffect(()=>{yt()},[Re]),p.useEffect(()=>{if(!(!en()||typeof window>"u"))return window.__FORGE_KNOWLEDGE_GRAPH_TEST_API__={selectNode:d=>{var y;const x=d?f.current.get(d)??((y=g.current)!=null&&y.hasNode(d)?g.current.getNodeAttribute(d,"data")??null:null):null;N.current(x)},moveNodeBy:(d,x,y)=>{var O,j;if(!((O=g.current)!=null&&O.hasNode(d)))return;const C=g.current.getNodeAttributes(d),_=C.x+x,I=C.y+y;g.current.mergeNodeAttributes(d,{x:_,y:I}),w.current.set(d,{x:_,y:I}),(j=m.current)==null||j.postMessage({type:"nudge-node",nodeId:d,x:_,y:I}),se(),!i.current&&g.current&&B(Me(g.current,T))},nudgeCameraBy:(d,x)=>{if(i.current){const y=i.current.getCamera(),C=y.getState();y.animate({x:C.x+d,y:C.y+x,ratio:C.ratio,angle:C.angle},{duration:140});return}V(y=>({...y,x:y.x+d,y:y.y+x}))}},()=>{delete window.__FORGE_KNOWLEDGE_GRAPH_TEST_API__}},[T]),p.useEffect(()=>{if(!l.current||typeof ResizeObserver>"u")return;const d=()=>{l.current&&Ye({width:l.current.clientWidth,height:l.current.clientHeight})};d();const x=new ResizeObserver(()=>{d()});return x.observe(l.current),()=>x.disconnect()},[]),p.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(F.current=null,i.current){i.current.getCamera().animate(Ie(),{duration:220});return}b&&V(Qr(b))},recenterOnFocus:()=>{Te(),F.current&&st(220)}}),[b,T]),p.useEffect(()=>()=>{var d,x,y;g.current&&ze(g.current,w.current),i.current&&E.current&&G.current.set(E.current,i.current.getCamera().getState()),(d=m.current)==null||d.postMessage({type:"dispose"}),(x=m.current)==null||x.terminate(),m.current=null,(y=i.current)==null||y.kill(),i.current=null,yt()},[Re]),p.useEffect(()=>{var I,O;if(!l.current||!wt(l.current,v))return;if(E.current===ge&&g.current!==null){se({resize:!0}),R();return}$.current="boot",ve.current=!1,Y.current=!1,P.current=!1,te.current=null,le.current=null,Ee.current=0,F.current=null,D({level:"info",eventKey:"graph_boot",message:"Bootstrapping a fresh knowledge graph dataset.",details:{nodeCount:t.length,edgeCount:T.length}}),g.current&&ze(g.current,w.current),i.current&&E.current&&G.current.set(E.current,i.current.getCamera().getState());const x=Ur(t,T,w.current);if(xt(x),ze(x,w.current),g.current=x,f.current=new Map(t.map(j=>[j.id,j])),E.current=ge,z.current+=1,B(Me(x,T)),$.current="graph_built",D({level:"info",eventKey:"graph_built",message:"Built and centered the knowledge graph structure.",details:{layoutGeneration:z.current}}),!Br())(I=i.current)==null||I.kill(),i.current=null,H("WebGL is unavailable in this browser context."),V(ke(x)),h({phase:"graph_built",allowCorrection:!0,publishBackendOnFailure:!0});else try{if(i.current)i.current.setGraph(x),se();else{i.current=new Mr(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(Oe())return;const k=f.current.get(S)??null;N.current(k)}),i.current.on("clickStage",({event:S})=>{if(Oe())return;if(!i.current||!g.current){N.current(null);return}const k=Zr({sigma:i.current,graph:g.current,viewportX:S.x,viewportY:S.y});if(k){N.current(f.current.get(k)??null);return}N.current(null)}),i.current.on("downNode",({node:S,event:k,preventSigmaDefault:ie})=>{var oe,X;if(!i.current||!((oe=g.current)!=null&&oe.hasNode(S)))return;ie();const je=i.current.viewportToGraph({x:k.x,y:k.y}),J=g.current.getNodeAttributes(S);M.current={nodeId:S,offsetX:J.x-je.x,offsetY:J.y-je.y,startViewportX:k.x,startViewportY:k.y,currentX:J.x,currentY:J.y,moved:!1},fe.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:k})=>{var X;if(!i.current||!g.current||!M.current)return;k();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 J=ie.x+M.current.offsetX,oe=ie.y+M.current.offsetY;M.current={...M.current,currentX:J,currentY:oe},g.current.mergeNodeAttributes(M.current.nodeId,{x:J,y:oe}),w.current.set(M.current.nodeId,{x:J,y:oe}),(X=m.current)==null||X.postMessage({type:"drag-move",nodeId:M.current.nodeId,x:J,y:oe}),se()});const j=()=>{var ie;if(!i.current||!M.current){M.current=null,de(null);return}const S=M.current.nodeId,k=M.current.moved;i.current.setSetting("enableCameraPanning",fe.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:k}}),M.current=null,de(null),k&&(L.current=Date.now()+220,N.current(f.current.get(S)??null))};i.current.on("upNode",j),i.current.on("upStage",j),i.current.on("leaveStage",j),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:E.current}}),h({phase:"first_frame",allowCorrection:!0,publishBackendOnFailure:!0}),Be({rendererMode:"sigma",publishAnomaly:!0})),R()})}H(null),B(Me(x,T)),i.current.getCamera().setState(Ie(x))}catch(j){(O=i.current)==null||O.kill(),i.current=null,H(j instanceof Error?j.message:"Graph renderer unavailable."),B(Me(x,T)),V(ke(x)),D({level:"error",eventKey:"sigma_fallback",message:"Fell back from Sigma to the SVG renderer.",publishBackend:!0,details:{reason:j instanceof Error?j.message:"unknown"}}),h({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=j=>{var oe;if(!g.current)return;const S=j.data;if(S.type==="stats"){A.current=S.phase,me.current=S.primaryFocusedNodeId,Ke.current=S.focusSources,Ce.current=S.focusPressure,ye.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:E.current,phase:S.phase}}),h({phase:"worker_started",allowCorrection:!0,publishBackendOnFailure:!0}));return}const k=g.current;let ie=S.x,je=S.y;if($.current!=="startup_verified"){const X=Jr({x:S.x,y:S.y});X.changed&&(ie=X.x,je=X.y,(oe=m.current)==null||oe.postMessage({type:"recenter-graph",offsetX:X.offsetX,offsetY:X.offsetY}),Pe(),D({level:"warning",eventKey:"worker_startup_recenter",message:"Recentering worker positions during startup because the graph drifted away from origin.",details:{datasetSignature:E.current,startupPhase:$.current,offsetX:X.offsetX,offsetY:X.offsetY}}))}let J=0;if(k.updateEachNodeAttributes((X,Wt)=>({...Wt,x:ie[J],y:je[J++]}),{attributes:["x","y"]}),M.current&&k.hasNode(M.current.nodeId)){const X=M.current.nodeId;k.mergeNodeAttributes(X,{x:M.current.currentX,y:M.current.currentY})}ze(k,w.current),i.current?se():B(Me(k,T))});const y=x.nodes(),C=new Map(y.map((j,S)=>[j,S])),_=mt(y,T,s);m.current.postMessage({type:"init-graph",nodes:y.map(j=>{const S=x.getNodeAttributes(j);return{id:j,x:S.x,y:S.y,size:S.size,mass:Math.max(1,S.data.importance/42),importance:S.data.importance}}),edges:T.filter(j=>C.has(j.source)&&C.has(j.target)).map(j=>({source:C.get(j.source),target:C.get(j.target),weight:Math.max(.6,j.strength)})),focusNodeId:s,hopLevels:_,physics:u}),D({level:"debug",eventKey:"worker_init",message:"Posted the graph payload to the layout worker.",details:{nodeCount:y.length,edgeCount:T.length}})},[v.height,v.width,ge,s,t,u,T]),p.useEffect(()=>{if(!m.current||!g.current)return;const d=mt(g.current.nodes(),T,s);m.current.postMessage({type:"set-focus",focusNodeId:s,hopLevels:d}),s||(F.current=null)},[s,T]),p.useEffect(()=>{m.current&&m.current.postMessage({type:"update-physics",physics:u})},[u]),p.useEffect(()=>{},[ge,Re]),p.useEffect(()=>{!i.current||!g.current||(i.current.setSetting("nodeReducer",(d,x)=>{var C;const y=(C=g.current)==null?void 0:C.getNodeAttribute(d,"data");return Yr({nodeId:d,attributes:x,node:y,focusNodeId:s,relatedNodeIds:ae,detailNodeIds:ne,hoveredNodeId:Q,draggedNodeId:xe})}),i.current.setSetting("edgeReducer",(d,x)=>{var C;const y=(C=g.current)==null?void 0:C.getEdgeAttribute(d,"data");return Hr({attributes:x,edge:y,focusNodeId:s,detailNodeIds:ne,relatedNodeIds:ae,hoveredNodeId:Q})}),se())},[ne,xe,s,Q,ae]),p.useEffect(()=>{var d,x;!b||!E.current||v.width<=0||v.height<=0||!he&&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:E.current}}),h({phase:"first_frame",allowCorrection:!0,publishBackendOnFailure:!0})),vt({datasetSignature:E.current,focusNodeId:s,primaryFocusedNodeId:me.current,draggedNodeId:((d=M.current)==null?void 0:d.nodeId)??null,layoutGeneration:z.current,camera:pe,snapshot:b,width:v.width,height:v.height,startupPhase:$.current,startupInvariantSatisfied:((x=be({rendererMode:"fallback"}))==null?void 0:x.startupInvariantSatisfied)??!1,simulationPhase:A.current,focusSources:Ke.current,focusPressure:Ce.current,centroid:ye.current,cameraTarget:F.current?{x:F.current.x,y:F.current.y,ratio:F.current.ratio}:null,latestSnapshotAt:te.current,latestSnapshotNodeCount:le.current}))},[v.height,v.width,pe,he,b,s]);const Ze=p.useMemo(()=>!b||v.width<=0||v.height<=0?[]:b.nodes.map(d=>{const x=Kt({node:d,snapshot:b,camera:pe,width:v.width,height:v.height});return{...d,viewportX:x.x,viewportY:x.y,viewportSize:x.size}}),[v.height,v.width,pe,b]),it=p.useMemo(()=>new Map(Ze.map(d=>[d.id,d])),[Ze]);return r.jsx("div",{className:"relative h-full w-full overflow-hidden bg-[radial-gradient(circle_at_top,rgba(125,211,252,0.1),transparent_34%),linear-gradient(180deg,rgba(7,12,23,0.98),rgba(6,11,20,0.98))]",children:r.jsx("div",{ref:l,className:"h-full w-full touch-none","aria-label":"Knowledge graph canvas",children:he&&b?r.jsxs("svg",{className:"h-full w-full",viewBox:`0 0 ${Math.max(v.width,1)} ${Math.max(v.height,1)}`,"aria-hidden":"true",children:[r.jsx("title",{children:"Knowledge graph fallback canvas"}),r.jsx("rect",{x:"0",y:"0",width:Math.max(v.width,1),height:Math.max(v.height,1),fill:"transparent",onClick:()=>N.current(null)}),b.edges.map(d=>{const x=it.get(d.source),y=it.get(d.target);if(!x||!y)return null;const C=!!s&&(d.source===s||d.target===s),_=!!Q&&(d.source===Q||d.target===Q),I=s?d.source===s?0:ne.has(d.source)?1:ae.has(d.source)?2:3:0,O=s?d.target===s?0:ne.has(d.target)?1:ae.has(d.target)?2:3:0,j=s?Math.max(I,O):0;return r.jsx("line",{x1:x.viewportX,y1:x.viewportY,x2:y.viewportX,y2:y.viewportY,stroke:C?Fe(d,.24):_?Fe(d,.14):s?j<=1?Fe(d,.09):j===2?Fe(d,.05):Fe(d,.016):Fe(d,.055),strokeWidth:C?1.7:_?1.3:.95},d.id)}),Ze.map(d=>{const x=s===d.id,y=ae.has(d.id),C=ne.has(d.id),_=Q===d.id,I=!s||y;return r.jsxs("g",{transform:`translate(${d.viewportX}, ${d.viewportY})`,onMouseEnter:()=>ue(d.id),onMouseLeave:()=>ue(null),onClick:O=>{O.stopPropagation();const j=f.current.get(d.id)??null;N.current(j)},style:{cursor:"pointer"},children:[r.jsx("circle",{r:x?d.viewportSize*1.9:_?d.viewportSize*1.3:C?d.viewportSize*1.15:y?d.viewportSize*1.05:d.viewportSize,fill:I?d.color:Wr(d.color,.3),stroke:x?"rgba(255,255,255,0.78)":"rgba(255,255,255,0.12)",strokeWidth:x?2:1}),(x||_||C)&&r.jsx("text",{x:d.viewportSize*1.5,y:4,fill:"rgba(244,247,255,0.92)",fontSize:"12",children:d.data.title})]},d.id)})]}):null})})}),un=300,dn=152;function Ot(e,t){return e?cn(e,t):new Set}function hn(e,t,a){const s=At(e,t),u=Ot(a,t);return s.nodes.map(o=>{const c=o.id===a,l=!a||u.has(o.id);return{id:o.id,draggable:!1,selectable:!1,position:{x:72+o.layer*un,y:88+o.row*dn},data:{label:r.jsxs("div",{className:"min-w-[232px] rounded-[22px] border px-4 py-4 shadow-[0_24px_70px_rgba(0,0,0,0.24)] transition",style:{borderColor:c?"rgba(255,255,255,0.32)":"rgba(255,255,255,0.1)",background:c?"rgba(11,17,30,0.98)":"rgba(8,14,26,0.92)",opacity:l?1:.28},children:[r.jsx("div",{className:"flex flex-wrap items-center gap-2",children:r.jsx(qe,{kind:o.entityKind,label:o.entityKind.replaceAll("_"," "),compact:!0,gradient:c})}),r.jsx("div",{className:"mt-3",children:r.jsx(mr,{kind:o.entityKind,label:o.title,className:"max-w-full",lines:2})}),o.subtitle?r.jsx("div",{className:"mt-2 text-sm leading-5 text-white/58",children:o.subtitle}):null]})},style:{background:"transparent",border:"none",padding:0}}})}function pn(e,t,a,s){const u=At(e,t),o=Ot(a,t);return u.edges.filter(c=>s||!c.secondary).map(c=>{const l=!a||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:kr.ArrowClosed,color:c.secondary?"rgba(255,255,255,0.16)":"rgba(232,242,255,0.42)"},style:{opacity:l?1:.18,stroke:c.secondary?"rgba(255,255,255,0.16)":c.family==="taxonomy"?"rgba(162,245,189,0.34)":c.family==="structural"?"rgba(232,242,255,0.4)":"rgba(192,193,255,0.24)",strokeDasharray:c.secondary?"8 6":void 0,strokeWidth:c.secondary?1:c.family==="structural"?1.7:1.2}}})}function gn({nodes:e,edges:t,focusNodeId:a,showSecondaryEdges:s,onSelectNode:u,onOpenNode:o,onNavigateNode:c,isMobile:l}){const i=p.useMemo(()=>hn(e,t,a),[t,a,e]),m=p.useMemo(()=>pn(e,t,a,s),[t,a,e,s]),g=p.useMemo(()=>new Map(e.map(w=>[w.id,w])),[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:Le.map(w=>r.jsx("div",{className:"min-w-[17rem] rounded-full border border-white/10 bg-[rgba(11,17,28,0.78)] px-4 py-2 text-center text-[11px] uppercase tracking-[0.16em] text-white/52 backdrop-blur",children:w.label},w.id))}),r.jsxs(Fr,{fitView:!0,fitViewOptions:a?{padding:.24,nodes:[{id:a}]}:{padding:.2},nodes:i,edges:m,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,attributionPosition:"bottom-left",onNodeClick:(w,G)=>{const f=g.get(G.id);f&&u(f)},onNodeDoubleClick:(w,G)=>{const f=g.get(G.id);if(f){if(l){o(f);return}c(f)}},children:[r.jsx(Kr,{showInteractive:!1}),r.jsx(Ir,{gap:28,size:1,color:"rgba(255,255,255,0.05)"})]},`${a??"all"}-${s?"all":"primary"}`)]})}const Pt=6,Tt=5,Dt=.92,zt=5,Lt=.15,$t=2.4,Yt=2,Ht=.8,Vt=3,ee={focusRepulsion:2.25,focusDiffusion:1.95,focusSpringReductionMax:.34,focusSpringReductionDiffusion:1.85,edgeSpringStrength:1,gravityStrength:1,focusShellSpacing:1};function _e(e,t,a){return Math.min(Math.max(e,t),a)}function Bt(e){return{focusRepulsion:_e((e==null?void 0:e.focusRepulsion)??ee.focusRepulsion,.6,Pt),focusDiffusion:_e((e==null?void 0:e.focusDiffusion)??ee.focusDiffusion,.6,Tt),focusSpringReductionMax:_e((e==null?void 0:e.focusSpringReductionMax)??ee.focusSpringReductionMax,0,Dt),focusSpringReductionDiffusion:_e((e==null?void 0:e.focusSpringReductionDiffusion)??ee.focusSpringReductionDiffusion,.6,zt),edgeSpringStrength:_e((e==null?void 0:e.edgeSpringStrength)??ee.edgeSpringStrength,Lt,$t),gravityStrength:_e((e==null?void 0:e.gravityStrength)??ee.gravityStrength,0,Yt),focusShellSpacing:_e((e==null?void 0:e.focusShellSpacing)??ee.focusShellSpacing,Ht,Vt)}}const Qe=2e3,rt=40,nt=2e3,Xt="forge.knowledge-graph.physics";function fn(){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 Ue(e,t){return Array.from(new Set(e.getAll(t).flatMap(a=>a.split(",")).map(a=>a.trim()).filter(Boolean)))}function U(e,t,a){e.delete(t),a.forEach(s=>e.append(t,s))}function mn(e){switch(e.entityType){case"workbench_flow":case"workbench_surface":case"wiki_space":return null;default:return wr(e.entityType,e.entityId)}}function Z(e){return e?e.slice(0,10):""}function xn(){if(typeof window>"u")return ee;try{const e=window.localStorage.getItem(Xt);return e?Bt(JSON.parse(e)):ee}catch{return ee}}function bn(e){typeof window>"u"||window.localStorage.setItem(Xt,JSON.stringify(e))}function wn(e,t,a,s,u){const o=e.find(c=>c.id===t);return o||(!t||!a?null:{id:t,displayName:a,kind:s??"human",accentColor:u??"",handle:a.toLowerCase().replace(/\s+/g,"-"),description:"",createdAt:"",updatedAt:""})}function yn({entityKinds:e,relationKinds:t,tags:a,owners:s}){return[...e.map(u=>`entity:${u}`),...t.map(u=>`relation:${u}`),...a.map(u=>`tag:${u}`),...s.map(u=>`owner:${u}`)]}function _t(e){const t=[],a=[],s=[],u=[];for(const o of e){const[c,...l]=o.split(":"),i=l.join(":").trim();i&&(c==="entity"?t.push(i):c==="relation"?a.push(i):c==="tag"?s.push(i):c==="owner"&&u.push(i))}return{entityKinds:t,relationKinds:a,tags:s,owners:u}}function vn(e){const t=new URLSearchParams(e),a=t.get("view")==="hierarchy"?"hierarchy":"graph",s=xr(t.get("focus")),u=s?on(s.entityType,s.entityId):null,o=Ue(t,"entityKind"),c=Ue(t,"relationKind"),l=Ue(t,"tag"),i=Ue(t,"owner"),m=t.get("q")??"",g=t.get("updatedFrom"),w=t.get("updatedTo"),G=Number(t.get("limit")??Qe),f=Number.isFinite(G)?Math.max(rt,Math.min(nt,G)):Qe;return{selectedView:a,focusNodeId:u,selectedKinds:o,selectedRelations:c,selectedTags:l,selectedOwners:i,showHierarchyCrossLinks:t.get("cross")==="1",queryText:m,updatedFrom:g,updatedTo:w,maxNodes:f}}function Nn(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 Ct(e,t){if(!t){e.delete("focus");return}e.set("focus",br(t.entityType,t.entityId))}function Sn({isMobile:e,currentFocusNodeId:t,nextNodeId:a}){return a?e?t===a?{nextFocusNodeId:a,nextMobileSheetOpen:!0,shouldUpdateFocus:!1}:{nextFocusNodeId:a,nextMobileSheetOpen:!1,shouldUpdateFocus:!0}:{nextFocusNodeId:a,nextMobileSheetOpen:!1,shouldUpdateFocus:t!==a}:{nextFocusNodeId:null,nextMobileSheetOpen:!1,shouldUpdateFocus:t!==null}}const Et="__clear__";function _n({isMobile:e,focusNodeId:t,shellOverlayFocusNodeId:a,lastRequestedKey:s}){const u=e?null:t,o=u??Et;return o===(a??Et)?{action:"none",nextRequestedKey:o}:s===o?{action:"none",nextRequestedKey:o}:{action:u?"set":"clear",nextRequestedKey:o}}class Cn extends p.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 An(){var Be,Pe;const e=yr(),t=jt();tt(n=>n.knowledgeGraphDiagnostics);const a=tt(n=>{var h,R;return((R=(h=n.shell.knowledgeGraphOverlayFocus)==null?void 0:h.focusNode)==null?void 0:R.id)??null}),s=Ut(),[u,o]=qt(),c=p.useRef(null),l=p.useRef(null),i=p.useRef(null),m=p.useRef(null),g=p.useRef(null);p.useRef(Gt("/knowledge-graph"));const[w,G]=p.useState(()=>typeof window<"u"?window.matchMedia("(max-width: 1023px)").matches:!1),[f,N]=p.useState(!1),[K,E]=p.useState(!1),[z,M]=p.useState(!1),[L,fe]=p.useState(!1),[F,ce]=p.useState(""),[A,me]=p.useState(()=>xn()),Ce=Mt(),ye=({level:n,eventKey:h,message:R,details:Te,publishBackend:st=!1})=>{};p.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const n=window.matchMedia("(max-width: 1023px)"),h=R=>G(R?R.matches:n.matches);return h(),typeof n.addEventListener=="function"?(n.addEventListener("change",h),()=>n.removeEventListener("change",h)):(n.addListener(h),()=>n.removeListener(h))},[]),p.useEffect(()=>{w||(N(!1),E(!1),l.current=null)},[w]),p.useEffect(()=>{bn(A)},[A]);const $=u.toString(),ve=p.useMemo(()=>vn($),[$]),{selectedView:Y,focusNodeId:P,selectedKinds:te,selectedRelations:le,selectedTags:Ee,selectedOwners:Ne,showHierarchyCrossLinks:Q,queryText:ue,updatedFrom:xe,updatedTo:de,maxNodes:he}=ve;p.useEffect(()=>{ce(ue)},[ue]);const H=p.useMemo(()=>Nn(ve),[ve]),pe=p.useMemo(()=>["forge-knowledge-graph",...e.selectedUserIds,JSON.stringify(H)],[H,e.selectedUserIds]),V=lr({queryKey:pe,queryFn:()=>jr(e.selectedUserIds,H),placeholderData:n=>n,staleTime:6e4,refetchOnWindowFocus:!1}),b=V.data;p.useEffect(()=>{ye({level:"info",eventKey:"route_arrival",message:"Arrived on the Knowledge Graph page.",details:{search:u.toString()}})},[]),p.useEffect(()=>{if(!V.isSuccess||!b)return;const n=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:b.counts.nodeCount,edgeCount:b.counts.edgeCount,filteredNodeCount:b.counts.filteredNodeCount,limited:b.counts.limited});g.current!==n&&(g.current=n,ye({level:"info",eventKey:"graph_query_resolved",message:"Knowledge graph query resolved.",details:{nodeCount:b.counts.nodeCount,edgeCount:b.counts.edgeCount,filteredNodeCount:b.counts.filteredNodeCount,limited:b.counts.limited}}))},[b,V.isSuccess,H]),p.useEffect(()=>{!b||!P||b.nodes.some(n=>n.id===P)||(o(n=>{const h=new URLSearchParams(n);return h.delete("focus"),h},{replace:!0}),N(!1),l.current=null)},[P,b,o]),p.useEffect(()=>{if(w){if(!P){l.current=null,N(!1);return}l.current===P&&!f&&(N(!0),l.current=null)}},[P,w,f]);const B=p.useMemo(()=>!b||!P?St([],[],null):St(b.nodes,b.edges,P),[P,b]);p.useEffect(()=>{var h;const n=_n({isMobile:w,focusNodeId:((h=B.focusNode)==null?void 0:h.id)??null,shellOverlayFocusNodeId:a,lastRequestedKey:m.current});if(m.current=n.nextRequestedKey,n.action!=="none"){if(n.action==="clear"){t(ut());return}t(vr(B))}},[t,B,w,a]),p.useEffect(()=>{{i.current=null;return}},[Ce,P,B,w]),p.useEffect(()=>()=>{t(ut())},[t]),p.useEffect(()=>{if(!(typeof window>"u")){if(!fn()){delete window.__FORGE_KNOWLEDGE_GRAPH_PAGE_TEST__;return}return window.__FORGE_KNOWLEDGE_GRAPH_PAGE_TEST__={isMobile:w,mobileSheetOpen:f,focusNodeId:P,selectedView:Y,selectNodeById:n=>{if(!b)return;const h=n?b.nodes.find(R=>R.id===n)??null:null;Se(h)},activateFocusedNode:()=>{if(!P||!b)return;const n=b.nodes.find(h=>h.id===P)??null;n&&Se(n)}},()=>{delete window.__FORGE_KNOWLEDGE_GRAPH_PAGE_TEST__}}},[P,w,f,Y]);const v=n=>{o(h=>{const R=new URLSearchParams(h);return n(R),R},{replace:!0})},Ye=n=>{const h=n.trim();ce(n),v(R=>{h.length>0?R.set("q",h):R.delete("q")})},Se=n=>{const h=Sn({isMobile:w,currentFocusNodeId:P,nextNodeId:(n==null?void 0:n.id)??null});l.current=w&&h.nextMobileSheetOpen?(n==null?void 0:n.id)??null:null,N(h.nextMobileSheetOpen),h.shouldUpdateFocus&&(v(R=>{Ct(R,n)}),w&&E(!1))},Re=n=>{n.href&&s(n.href)},re=(n,h)=>{me(R=>Bt({...R,[n]:h}))},Ie=n=>{const h=mn(n);h&&s(h)},ke=n=>{v(h=>{h.set("view","hierarchy"),Ct(h,n)})},Ae=()=>{v(n=>{["q","entityKind","relationKind","tag","owner","updatedFrom","updatedTo","focus"].forEach(h=>n.delete(h)),n.set("limit",String(Qe))}),M(!1)};if(V.isLoading&&!b)return r.jsx(Nr,{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(Sr,{eyebrow:"Knowledge Graph",error:V.error,onRetry:()=>void V.refetch()});if(!b)return null;const T=new Map(b.facets.entityKinds.map(n=>[n.value,n])),ge=et.map(n=>{const h=_r(n),R=T.get(n),Te=(R==null?void 0:R.count)??0;return{value:n,label:(R==null?void 0:R.label)??h.label,description:Te===1?"1 node":`${Te} nodes`,kind:n}}),q=b.facets.relationKinds.map(n=>({value:n.value,label:n.label,description:`${n.count} links`})),ne=b.facets.tags.map(n=>({value:n.id,label:n.label,description:`${n.count} linked nodes`,badge:r.jsx(qe,{kind:"tag",label:n.label,compact:!0,gradient:!1}),menuBadge:r.jsx(qe,{kind:"tag",label:n.label,compact:!0,gradient:!1})})),ae=b.facets.owners.map(n=>{const h=wn(e.snapshot.users,n.userId,n.displayName,n.kind,n.accentColor);return{value:n.userId,label:n.displayName,description:`${n.count} nodes`,badge:r.jsx(dt,{user:h,compact:!0}),menuBadge:r.jsx(dt,{user:h,compact:!0})}}),He=[...ge.map(n=>({id:`entity:${n.value}`,label:n.label,description:n.description,searchText:`entity kind ${n.label}`,badge:r.jsx(qe,{kind:n.kind??"note",label:n.label,compact:!0,gradient:!1})})),...q.map(n=>({id:`relation:${n.value}`,label:n.label,description:n.description,searchText:`relation kind ${n.label}`})),...ne.map(n=>({id:`tag:${n.value}`,label:n.label,description:n.description,searchText:`tag ${n.label}`,badge:n.menuBadge??n.badge})),...ae.map(n=>({id:`owner:${n.value}`,label:n.label,description:n.description,searchText:`owner ${n.label}`,badge:n.menuBadge??n.badge}))],se=yn({entityKinds:te,relationKinds:le,tags:Ee,owners:Ne}),Oe=b.counts.limited?`${b.counts.nodeCount}/${b.counts.filteredNodeCount} nodes`:`${b.counts.nodeCount}n · ${b.counts.edgeCount}e`,D=b.counts.limited?`${b.counts.nodeCount} visible nodes from ${b.counts.filteredNodeCount} filtered matches`:`${b.counts.nodeCount} nodes and ${b.counts.edgeCount} edges`,Je=ue.trim().length>0||te.length>0||le.length>0||Ee.length>0||Ne.length>0||!!xe||!!de||he!==Qe,be=!w,Ve=`${Y}:${b.nodes.map(n=>n.id).join("|")}::${b.edges.map(n=>n.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-[radial-gradient(circle_at_top,rgba(125,211,252,0.08),transparent_26%),linear-gradient(180deg,rgba(7,12,23,0.98),rgba(5,10,19,1))]",children:[r.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-30 hidden md:block",children:r.jsx(Cr,{metrics:e.snapshot.metrics})}),r.jsx(Cn,{resetKey:Ve,fallback:n=>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-[rgba(255,255,255,0.08)] bg-[rgba(8,12,22,0.92)] p-6 shadow-[0_30px_80px_rgba(0,0,0,0.36)]",children:[r.jsx("div",{className:"mx-auto flex size-12 items-center justify-center rounded-full border border-[rgba(255,255,255,0.12)] bg-[rgba(255,255,255,0.04)] text-[var(--warning)]",children:r.jsx(Qt,{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-[rgba(255,255,255,0.04)] px-4 py-3 text-left text-xs text-[var(--ui-ink-faint)]",children:n.message})]}),r.jsxs("div",{className:"flex flex-wrap justify-center gap-2",children:[r.jsxs(W,{variant:"primary",size:"sm",onClick:()=>v(h=>{h.set("view","hierarchy")}),children:[r.jsx(Jt,{className:"size-4"}),"Open hierarchy"]}),r.jsx(W,{variant:"secondary",size:"sm",onClick:Ae,children:"Reset graph filters"})]})]})}),children:Y==="graph"?r.jsx(ln,{ref:c,nodes:b.nodes,edges:b.edges,focusNodeId:P,physicsSettings:A,onSelectNode:Se}):r.jsx("div",{className:"h-full overflow-y-auto px-4 py-4 lg:px-6",children:r.jsx(gn,{nodes:b.nodes,edges:b.edges,focusNodeId:P,showSecondaryEdges:Q,isMobile:w,onSelectNode:Se,onOpenNode:Se,onNavigateNode:Re})})}),w?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:"shrink-0 rounded-full border border-white/10 bg-[rgba(8,12,20,0.78)] px-2 py-0.5 text-[9px] uppercase tracking-[0.18em] text-white/48 backdrop-blur",children:Oe}),r.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[r.jsxs("div",{className:"flex shrink-0 rounded-full border border-white/10 bg-[rgba(8,12,20,0.78)] p-0.5 shadow-[0_14px_42px_rgba(0,0,0,0.24)] backdrop-blur",children:[r.jsx("button",{type:"button",className:`rounded-full px-2 py-1 text-[10px] transition ${Y==="graph"?"bg-white/[0.14] text-white":"text-white/52 hover:text-white"}`,onClick:()=>v(n=>{n.set("view","graph")}),children:"Graph"}),r.jsx("button",{type:"button",className:`rounded-full px-2 py-1 text-[10px] transition ${Y==="hierarchy"?"bg-white/[0.14] text-white":"text-white/52 hover:text-white"}`,onClick:()=>v(n=>{n.set("view","hierarchy")}),children:"Hierarchy"})]}),r.jsx(W,{variant:"secondary",size:"sm",className:"h-7 rounded-full border-white/10 bg-[rgba(8,12,20,0.78)] px-2 text-[10px] text-white/68 backdrop-blur hover:text-white",onClick:()=>fe(!0),"aria-label":"Open graph appearance settings",title:"Graph appearance settings",children:r.jsx(ot,{className:"size-3"})}),r.jsxs(W,{variant:"secondary",size:"sm",className:"h-7 rounded-full border-white/10 bg-[rgba(8,12,20,0.78)] px-2 text-[10px] text-white/68 backdrop-blur hover:text-white",onClick:()=>{N(!1),E(!0)},"aria-label":"Open graph filters",children:[r.jsx(ct,{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:"shrink-0 rounded-full border border-white/10 bg-[rgba(8,12,20,0.78)] px-2 py-0.5 text-[9px] uppercase tracking-[0.18em] text-white/48 backdrop-blur",children:Oe}),r.jsx("div",{className:"min-w-0 flex-1",children:r.jsx(pt,{title:"",description:"",compact:!0,minimal:!0,hideSummary:!0,query:F,onQueryChange:ce,onQuerySubmit:Ye,submitLabel:"Search graph",options:He,selectedOptionIds:se,onSelectedOptionIdsChange:n=>{const h=_t(n);v(R=>{U(R,"entityKind",h.entityKinds),U(R,"relationKind",h.relationKinds),U(R,"tag",h.tags),U(R,"owner",h.owners)})},resultSummary:"",placeholder:"Type a graph search, then press Enter or the search button"})}),r.jsxs(W,{variant:"secondary",size:"sm",className:"h-7 rounded-full border-white/10 bg-[rgba(8,12,20,0.78)] px-2 text-[10px] text-white/68 backdrop-blur hover:text-white",onClick:()=>M(n=>!n),children:[r.jsx(ct,{className:"size-3"}),"Advanced"]}),Je?r.jsx(W,{variant:"secondary",size:"sm",className:"h-7 rounded-full border-white/10 bg-[rgba(8,12,20,0.78)] px-2 text-[10px] text-white/68 backdrop-blur hover:text-white",onClick:Ae,children:"Reset"}):null]}),r.jsx(Ar,{initial:!1,children:z?r.jsx(Or.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-white/10 bg-[rgba(8,12,20,0.88)] p-3 shadow-[0_20px_60px_rgba(0,0,0,0.32)] 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(we,{options:ge,selectedValues:te,onChange:n=>v(h=>{U(h,"entityKind",n)}),placeholder:"Filter by entity type",emptyMessage:"No entity kinds match the current graph."}),r.jsx(we,{options:q,selectedValues:le,onChange:n=>v(h=>{U(h,"relationKind",n)}),placeholder:"Filter by relation type",emptyMessage:"No relation kinds match the current graph."}),r.jsx(we,{options:ne,selectedValues:Ee,onChange:n=>v(h=>{U(h,"tag",n)}),placeholder:"Filter by tag",emptyMessage:"No tags are available in the current filtered graph."}),r.jsx(we,{options:ae,selectedValues:Ne,onChange:n=>v(h=>{U(h,"owner",n)}),placeholder:"Filter by owner",emptyMessage:"No owners match the current graph."})]}),r.jsxs("div",{className:"grid gap-3 rounded-[20px] border border-white/10 bg-white/[0.03] 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-white/46",children:[r.jsx("span",{children:"Max nodes shown"}),r.jsx("span",{children:he})]}),r.jsx("input",{type:"range",min:rt,max:nt,step:20,value:he,onChange:n=>v(h=>{h.set("limit",n.target.value)}),className:"w-full accent-[var(--secondary)]"}),r.jsx("div",{className:"text-xs text-white/42",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-white/46",children:"Updated from"}),r.jsx(Xe,{type:"date",value:Z(xe),min:Z(b.facets.updatedAt.min),max:Z(de??b.facets.updatedAt.max),onChange:n=>v(h=>{n.target.value?h.set("updatedFrom",n.target.value):h.delete("updatedFrom")})})]}),r.jsxs("div",{className:"grid gap-2",children:[r.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/46",children:"Updated to"}),r.jsx(Xe,{type:"date",value:Z(de),min:Z(xe??b.facets.updatedAt.min),max:Z(b.facets.updatedAt.max),onChange:n=>v(h=>{n.target.value?h.set("updatedTo",n.target.value):h.delete("updatedTo")})})]})]}),Y==="hierarchy"?r.jsx(W,{variant:Q?"primary":"secondary",size:"sm",className:"h-8 rounded-full px-3 text-xs",onClick:()=>v(n=>{Q?n.delete("cross"):n.set("cross","1")}),children:Q?"Hide cross-links":"Show cross-links"}):null]})]})}):null})]}):null,w?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 flex shrink-0 rounded-full border border-white/10 bg-[rgba(8,12,20,0.82)] p-0.5 shadow-[0_14px_42px_rgba(0,0,0,0.24)] backdrop-blur",children:[r.jsx("button",{type:"button",className:`rounded-full px-2.5 py-1.5 text-[10px] transition ${Y==="graph"?"bg-white/[0.14] text-white":"text-white/52 hover:text-white"}`,onClick:()=>v(n=>{n.set("view","graph")}),children:"Graph"}),r.jsx("button",{type:"button",className:`rounded-full px-2.5 py-1.5 text-[10px] transition ${Y==="hierarchy"?"bg-white/[0.14] text-white":"text-white/52 hover:text-white"}`,onClick:()=>v(n=>{n.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 rounded-full border-white/10 bg-[rgba(8,12,20,0.82)] p-0 text-white/72 backdrop-blur hover:text-white",onClick:()=>fe(!0),title:"Graph appearance settings","aria-label":"Open graph appearance settings",children:r.jsx(ot,{className:"size-3.5"})}),r.jsx(W,{variant:"secondary",size:"sm",className:"pointer-events-auto size-8 rounded-full border-white/10 bg-[rgba(8,12,20,0.82)] p-0 text-white/72 backdrop-blur hover:text-white",onClick:()=>{var n;return(n=c.current)==null?void 0:n.zoomIn()},title:"Zoom in","aria-label":"Zoom in",children:r.jsx(Zt,{className:"size-3.5"})}),r.jsx(W,{variant:"secondary",size:"sm",className:"pointer-events-auto size-8 rounded-full border-white/10 bg-[rgba(8,12,20,0.82)] p-0 text-white/72 backdrop-blur hover:text-white",onClick:()=>{var n;return(n=c.current)==null?void 0:n.zoomOut()},title:"Zoom out","aria-label":"Zoom out",children:r.jsx(er,{className:"size-3.5"})}),r.jsx(W,{variant:"secondary",size:"sm",className:"pointer-events-auto size-8 rounded-full border-white/10 bg-[rgba(8,12,20,0.82)] p-0 text-white/72 backdrop-blur hover:text-white",onClick:()=>{var n;return(n=c.current)==null?void 0:n.recenterOnFocus()},disabled:!B.focusNode,title:"Recenter","aria-label":"Recenter",children:r.jsx(tr,{className:"size-3.5"})}),r.jsx(W,{variant:"secondary",size:"sm",className:"pointer-events-auto size-8 rounded-full border-white/10 bg-[rgba(8,12,20,0.82)] p-0 text-white/72 backdrop-blur hover:text-white",onClick:()=>{var n;return(n=c.current)==null?void 0:n.fit()},title:"Reset camera","aria-label":"Reset camera",children:r.jsx(rr,{className:"size-3.5"})}),null]}):null]})})]}),r.jsx(ht,{open:f&&!!B.focusNode,onOpenChange:N,eyebrow:"Knowledge Graph",title:((Be=B.focusNode)==null?void 0:Be.title)??"Focus node",description:((Pe=B.focusNode)==null?void 0:Pe.subtitle)??"Inspect the selected node and move deeper into the graph.",children:r.jsx(Er,{focus:B,onOpenPage:n=>{N(!1),Re(n)},onOpenNotes:n=>{N(!1),Ie(n)},onOpenHierarchy:n=>{N(!1),ke(n)},onSelectNode:Se,className:"border-0 bg-transparent p-0 shadow-none"})}),r.jsx(ht,{open:K,onOpenChange:E,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-[rgba(255,255,255,0.03)] p-3",children:r.jsx(pt,{title:"",description:"",compact:!0,query:F,onQueryChange:ce,onQuerySubmit:Ye,submitLabel:"Search graph",options:He,selectedOptionIds:se,onSelectedOptionIdsChange:n=>{const h=_t(n);v(R=>{U(R,"entityKind",h.entityKinds),U(R,"relationKind",h.relationKinds),U(R,"tag",h.tags),U(R,"owner",h.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(we,{options:ge,selectedValues:te,onChange:n=>v(h=>{U(h,"entityKind",n)}),placeholder:"Filter by entity type",emptyMessage:"No entity kinds match the current graph."}),r.jsx(we,{options:q,selectedValues:le,onChange:n=>v(h=>{U(h,"relationKind",n)}),placeholder:"Filter by relation type",emptyMessage:"No relation kinds match the current graph."}),r.jsx(we,{options:ne,selectedValues:Ee,onChange:n=>v(h=>{U(h,"tag",n)}),placeholder:"Filter by tag",emptyMessage:"No tags are available in the current filtered graph."}),r.jsx(we,{options:ae,selectedValues:Ne,onChange:n=>v(h=>{U(h,"owner",n)}),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-[rgba(255,255,255,0.03)] p-3",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3 text-[11px] uppercase tracking-[0.18em] text-white/46",children:[r.jsx("span",{children:"Max nodes shown"}),r.jsx("span",{children:he})]}),r.jsx("input",{type:"range",min:rt,max:nt,step:20,value:he,onChange:n=>v(h=>{h.set("limit",n.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-white/46",children:"Updated from"}),r.jsx(Xe,{type:"date",value:Z(xe),min:Z(b.facets.updatedAt.min),max:Z(de??b.facets.updatedAt.max),onChange:n=>v(h=>{n.target.value?h.set("updatedFrom",n.target.value):h.delete("updatedFrom")})})]}),r.jsxs("div",{className:"grid gap-2",children:[r.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/46",children:"Updated to"}),r.jsx(Xe,{type:"date",value:Z(de),min:Z(xe??b.facets.updatedAt.min),max:Z(b.facets.updatedAt.max),onChange:n=>v(h=>{n.target.value?h.set("updatedTo",n.target.value):h.delete("updatedTo")})})]})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(W,{variant:"secondary",size:"sm",onClick:Ae,children:"Reset"}),r.jsx(W,{variant:"primary",size:"sm",onClick:()=>E(!1),children:"Done"})]})]})]})}),r.jsx(nr,{open:L,onOpenChange:fe,children:r.jsxs(ar,{children:[r.jsx(sr,{className:"fixed inset-0 z-40 bg-[rgba(4,8,18,0.72)] backdrop-blur-xl"}),r.jsxs(ir,{className:"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-white/10 bg-[linear-gradient(180deg,rgba(16,23,36,0.98),rgba(8,12,22,0.98))] shadow-[0_32px_90px_rgba(3,8,18,0.48)] md:left-1/2 md:right-auto md:w-[min(40rem,calc(100vw-3rem))] md:-translate-x-1/2",children:[r.jsx(or,{className:"sr-only",children:"Knowledge Graph appearance settings"}),r.jsx(cr,{className:"sr-only",children:"Tune the graph focus physics and appearance response."}),r.jsxs("div",{className:"sticky top-0 z-10 flex items-start justify-between gap-4 border-b border-white/8 bg-[rgba(8,12,22,0.9)] px-5 py-4 backdrop-blur-xl",children:[r.jsxs("div",{className:"grid gap-1",children:[r.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Graph appearance"}),r.jsx("div",{className:"font-display text-2xl text-white",children:"Tune the focus field"}),r.jsx("p",{className:"max-w-xl text-sm leading-6 text-white/55",children:"Shape how strongly a focused node opens its neighborhood and how far that pressure diffuses through connected hops."})]}),r.jsx(lt,{asChild:!0,children:r.jsx(Rr,{"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:"grid gap-3 rounded-[24px] border border-white/10 bg-white/[0.04] p-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-medium text-white",children:"Focused repulsion"}),r.jsx("div",{className:"text-xs leading-5 text-white/46",children:"Push nearby nodes apart more aggressively while the focused node stays anchored."})]}),r.jsx("div",{className:"rounded-full border border-white/10 bg-white/[0.06] px-2.5 py-1 text-xs text-white/72",children:A.focusRepulsion.toFixed(2)})]}),r.jsx("input",{"aria-label":"Focused repulsion",type:"range",min:"0.6",max:String(Pt),step:"0.05",value:A.focusRepulsion,onChange:n=>re("focusRepulsion",Number(n.target.value)),className:"w-full accent-[var(--secondary)]"})]}),r.jsxs("div",{className:"grid gap-3 rounded-[24px] border border-white/10 bg-white/[0.04] p-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-medium text-white",children:"Focus diffusion"}),r.jsx("div",{className:"text-xs leading-5 text-white/46",children:"Extend the focus field further through multi-hop neighbors and lengthen the reversible transition."})]}),r.jsx("div",{className:"rounded-full border border-white/10 bg-white/[0.06] px-2.5 py-1 text-xs text-white/72",children:A.focusDiffusion.toFixed(2)})]}),r.jsx("input",{"aria-label":"Focus diffusion",type:"range",min:"0.6",max:String(Tt),step:"0.05",value:A.focusDiffusion,onChange:n=>re("focusDiffusion",Number(n.target.value)),className:"w-full accent-[var(--secondary)]"})]}),r.jsxs("div",{className:"grid gap-3 rounded-[24px] border border-white/10 bg-white/[0.04] p-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-medium text-white",children:"Spring reduction max"}),r.jsx("div",{className:"text-xs leading-5 text-white/46",children:"Reduce edge spring constants most strongly around the focused node so its local neighborhood can open more freely."})]}),r.jsx("div",{className:"rounded-full border border-white/10 bg-white/[0.06] px-2.5 py-1 text-xs text-white/72",children:A.focusSpringReductionMax.toFixed(2)})]}),r.jsx("input",{"aria-label":"Spring reduction max",type:"range",min:"0",max:String(Dt),step:"0.02",value:A.focusSpringReductionMax,onChange:n=>re("focusSpringReductionMax",Number(n.target.value)),className:"w-full accent-[var(--secondary)]"})]}),r.jsxs("div",{className:"grid gap-3 rounded-[24px] border border-white/10 bg-white/[0.04] p-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-medium text-white",children:"Spring reduction diffusion"}),r.jsx("div",{className:"text-xs leading-5 text-white/46",children:"Spread that spring softening progressively through first-hop, second-hop, and more distant neighborhoods."})]}),r.jsx("div",{className:"rounded-full border border-white/10 bg-white/[0.06] px-2.5 py-1 text-xs text-white/72",children:A.focusSpringReductionDiffusion.toFixed(2)})]}),r.jsx("input",{"aria-label":"Spring reduction diffusion",type:"range",min:"0.6",max:String(zt),step:"0.05",value:A.focusSpringReductionDiffusion,onChange:n=>re("focusSpringReductionDiffusion",Number(n.target.value)),className:"w-full accent-[var(--secondary)]"})]}),r.jsxs("div",{className:"grid gap-3 rounded-[24px] border border-white/10 bg-white/[0.04] p-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-medium text-white",children:"Edge spring strength"}),r.jsx("div",{className:"text-xs leading-5 text-white/46",children:"Lower this to loosen graph edges globally and let neighborhoods spread instead of snapping tightly inward."})]}),r.jsx("div",{className:"rounded-full border border-white/10 bg-white/[0.06] px-2.5 py-1 text-xs text-white/72",children:A.edgeSpringStrength.toFixed(2)})]}),r.jsx("input",{"aria-label":"Edge spring strength",type:"range",min:String(Lt),max:String($t),step:"0.05",value:A.edgeSpringStrength,onChange:n=>re("edgeSpringStrength",Number(n.target.value)),className:"w-full accent-[var(--secondary)]"})]}),r.jsxs("div",{className:"grid gap-3 rounded-[24px] border border-white/10 bg-white/[0.04] p-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-medium text-white",children:"Gravity strength"}),r.jsx("div",{className:"text-xs leading-5 text-white/46",children:"Reduce this to weaken the global inward pull that compacts the whole graph toward the middle."})]}),r.jsx("div",{className:"rounded-full border border-white/10 bg-white/[0.06] px-2.5 py-1 text-xs text-white/72",children:A.gravityStrength.toFixed(2)})]}),r.jsx("input",{"aria-label":"Gravity strength",type:"range",min:"0",max:String(Yt),step:"0.05",value:A.gravityStrength,onChange:n=>re("gravityStrength",Number(n.target.value)),className:"w-full accent-[var(--secondary)]"})]}),r.jsxs("div",{className:"grid gap-3 rounded-[24px] border border-white/10 bg-white/[0.04] p-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-medium text-white",children:"Focus shell spacing"}),r.jsx("div",{className:"text-xs leading-5 text-white/46",children:"Increase this to push focused rings farther outward and visibly open the local structure."})]}),r.jsx("div",{className:"rounded-full border border-white/10 bg-white/[0.06] px-2.5 py-1 text-xs text-white/72",children:A.focusShellSpacing.toFixed(2)})]}),r.jsx("input",{"aria-label":"Focus shell spacing",type:"range",min:String(Ht),max:String(Vt),step:"0.05",value:A.focusShellSpacing,onChange:n=>re("focusShellSpacing",Number(n.target.value)),className:"w-full accent-[var(--secondary)]"})]})]}),r.jsx("div",{className:"rounded-[24px] border border-white/8 bg-[rgba(125,211,252,0.07)] px-4 py-3 text-sm leading-6 text-white/62",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:()=>me(ee),children:"Reset defaults"}),r.jsx(lt,{asChild:!0,children:r.jsx(W,{variant:"primary",children:"Done"})})]})]})]})]})}),null]})}export{An as KnowledgeGraphPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as u,j as e,c9 as Ae,bA as ke,bC as Pe,aH as me,bL as De,cR as Me,c7 as He,bK as Te,bX as Ce,aC as Oe}from"./vendor-kIz9EZnX.js";import{j as ue,i as xe,k as $}from"./state-VYvD1QVP.js";import{i as q,cP as Le,cQ as J,C as w,c as U,B as ee,Z as K,O as pe}from"./index-BHIKoiZ6.js";import{F as Se}from"./floating-action-menu-zzC2r0Ob.js";import{A as Fe,C as _e,X as Ee,L as le,Y as Ie,T as Xe,b as ze,a as Re,c as Ye}from"./charts-FcU0F3XV.js";const R=20,ce=288,M={top:16,right:18,bottom:28,left:42},te=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function Be(t,a){return te.map((r,o)=>({weekday:o,baselineDailyAp:t.baselineDailyAp,points:t.currentCurve.map(i=>({...i,locked:o===a?i.locked:!1}))}))}function re(t){return`${Number(t.toFixed(1))} AP`}function O(t){return`${Number(t.toFixed(1))} AP/h`}function se(t){const a=new Date(2026,0,1,0,t,0,0);return new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"}).format(a)}function We(t){const a=new Date(2026,0,1,0,t,0,0);return new Intl.DateTimeFormat(void 0,{hour:"numeric"}).format(a)}function C(t,a,r){return Math.min(r,Math.max(a,t))}function Ke(t){if(t.length<2)return 0;let a=0;for(let r=0;r<t.length-1;r+=1){const o=t[r],i=t[r+1];a+=(o.rateApPerHour+i.rateApPerHour)/2*((i.minuteOfDay-o.minuteOfDay)/60)}return a}function de(t,a){if(t.length===0)return 0;if(a<=t[0].minuteOfDay)return t[0].rateApPerHour;for(let r=0;r<t.length-1;r+=1){const o=t[r],i=t[r+1];if(a<=i.minuteOfDay){const v=Math.max(1,i.minuteOfDay-o.minuteOfDay),y=(a-o.minuteOfDay)/v;return o.rateApPerHour+(i.rateApPerHour-o.rateApPerHour)*y}}return t[t.length-1].rateApPerHour}function $e(t,a){const r=Ke(t);if(r<=0||a<=0)return t.map(i=>({...i,rateApPerHour:0}));const o=a/r;return t.map(i=>({...i,rateApPerHour:Number((i.rateApPerHour*o).toFixed(4))}))}function qe(t,a,r){var x;if(a<=0||a>=t.length-1)return((x=t[a])==null?void 0:x.rateApPerHour)??0;const o=t[a-1],i=t[a],v=t[a+1];let y=0;for(let f=0;f<t.length-1;f+=1){if(f===a-1||f===a)continue;const n=t[f],H=t[f+1];y+=(n.rateApPerHour+H.rateApPerHour)/2*((H.minuteOfDay-n.minuteOfDay)/60)}const L=Math.max(R/60,(i.minuteOfDay-o.minuteOfDay)/60),P=Math.max(R/60,(v.minuteOfDay-i.minuteOfDay)/60);return Math.max(0,(2*(r-y)-o.rateApPerHour*L-v.rateApPerHour*P)/(L+P))}function Qe(t){switch(t){case"danger":return"bg-rose-400/12 text-rose-100";case"warning":return"bg-amber-400/12 text-amber-100";case"success":return"bg-emerald-400/12 text-emerald-100";case"info":default:return"bg-sky-400/12 text-sky-100"}}function Ge(t){switch(t){case"primary":return"Primary";case"secondary":return"Secondary";case"recovery":return"Recovery";case"background":default:return"Ambient"}}function he(t){return t.spentTodayAp>t.dailyBudgetAp?"Over budget":t.spentTodayAp<t.targetBandMinAp?"Below target band":"Inside target band"}function Ve(t){return t.overloadApPerHour>0||t.instantFreeApPerHour<=0?"Recovery":t.instantCapacityApPerHour>=t.currentDrainApPerHour+4?"Deep work":"Low-friction admin"}function Ze({lifeForce:t}){return e.jsxs("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[e.jsxs(w,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Daily AP"}),e.jsxs("div",{className:"mt-2 font-display text-4xl text-[var(--primary)]",children:[Math.round(t.spentTodayAp),e.jsxs("span",{className:"ml-2 text-lg text-white/44",children:["/ ",Math.round(t.dailyBudgetAp)]})]}),e.jsxs("div",{className:"mt-2 text-sm text-white/58",children:["Target band ",Math.round(t.targetBandMinAp),"-",Math.round(t.targetBandMaxAp)," AP"]}),e.jsx("div",{className:"mt-2 text-xs uppercase tracking-[0.14em] text-white/38",children:he(t)})]}),e.jsxs(w,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Instant headroom"}),e.jsx("div",{className:"mt-2 font-display text-4xl text-white",children:t.instantFreeApPerHour.toFixed(1)}),e.jsxs("div",{className:"mt-2 text-sm text-white/58",children:[O(t.instantCapacityApPerHour)," capacity minus"," ",O(t.currentDrainApPerHour)," load"]}),e.jsx("div",{className:"mt-2 text-xs uppercase tracking-[0.14em] text-white/38",children:t.overloadApPerHour>0?`${O(t.overloadApPerHour)} overloaded`:"No overload right now"})]}),e.jsxs(w,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Fatigue buffer"}),e.jsx("div",{className:"mt-2 font-display text-4xl text-white",children:t.fatigueBufferApPerHour.toFixed(1)}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:"Short-term strain rises with overlap and falls with recovery."})]}),e.jsxs(w,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Forecast"}),e.jsx("div",{className:"mt-2 font-display text-4xl text-white",children:Math.round(t.forecastAp)}),e.jsxs("div",{className:"mt-2 text-sm text-white/58",children:["Planned remaining ",re(t.plannedRemainingAp)]}),e.jsxs("div",{className:"mt-2 text-xs uppercase tracking-[0.14em] text-white/38",children:["Remaining ",re(t.remainingAp)]})]})]})}function Je({lifeForce:t}){return e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-6",children:t.stats.map(a=>e.jsxs(w,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/38",children:a.label}),e.jsxs(U,{className:"bg-white/[0.08] text-white/70",children:["L",a.level]})]}),e.jsxs("div",{className:"mt-3 text-2xl font-semibold text-white",children:[Math.round(a.xp)," XP"]}),e.jsx("div",{className:"mt-1 text-sm text-white/54",children:a.key==="life_force"?`+${Math.round((a.costModifier-1)*100)}% daily resilience`:`${Math.round((1-a.costModifier)*100)}% cost relief`})]},a.key))})}function Ue({lifeForce:t,weekday:a,points:r,baselineDailyAp:o,isDirty:i,isSaving:v,onChange:y,onReset:L,onSave:P,onWeekdayChange:x}){var ne,oe;const f=u.useRef(null),[n,H]=u.useState(null),[E,ae]=u.useState(720),[p,Q]=u.useState(null),S=u.useMemo(()=>new Date().getDay(),[]),F=u.useMemo(()=>{const s=new Date;return s.getHours()*60+s.getMinutes()},[]),Y=u.useMemo(()=>[...r].sort((s,l)=>s.minuteOfDay-l.minuteOfDay),[r]),c=u.useMemo(()=>Y.map(s=>({...s,locked:a===S?s.minuteOfDay<=F:!1})),[F,Y,S,a]),b=u.useMemo(()=>{const s=Math.max(t.instantCapacityApPerHour,...c.map(l=>l.rateApPerHour),8);return Math.max(12,Math.ceil(s*1.25))},[t.instantCapacityApPerHour,c]),G=u.useMemo(()=>c.map(s=>({...s,label:se(s.minuteOfDay)})),[c]),j=u.useMemo(()=>[0,240,480,720,960,1200,1440],[]),V=u.useMemo(()=>Array.from(new Set([0,Math.max(2,Math.round(b/3)),Math.max(4,Math.round(2*b/3)),b])).sort((s,l)=>s-l),[b]),B=Math.max(E,1),_=Math.max(160,B-M.left-M.right),I=ce-M.top-M.bottom;u.useEffect(()=>{const s=()=>{var m;const l=((m=f.current)==null?void 0:m.clientWidth)??0;ae(l>0?l:720)};return s(),window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[]),u.useEffect(()=>{if(n===null||!f.current)return;const s=f.current,l=d=>{if(d.pointerId!==n.pointerId)return;d.preventDefault();const g=s.getBoundingClientRect(),A=Number.isFinite(d.clientX)?d.clientX:g.left+n.pointerX,h=Number.isFinite(d.clientY)?d.clientY:g.top+n.pointerY,D=C(A-g.left,0,g.width),X=C(h-g.top,0,g.height),W=C(A-g.left-M.left,0,_),ye=C(h-g.top-M.top,0,I);y(c.map((N,k)=>{if(k!==n.index)return{minuteOfDay:N.minuteOfDay,rateApPerHour:N.rateApPerHour,locked:N.locked};if(N.locked||k===0||k===c.length-1)return{minuteOfDay:N.minuteOfDay,rateApPerHour:N.rateApPerHour,locked:N.locked};const ve=c[k-1].minuteOfDay+R,we=c[k+1].minuteOfDay-R,je=Math.round(C(W/_*1440,ve,we)),z=c.map(ie=>({minuteOfDay:ie.minuteOfDay,rateApPerHour:ie.rateApPerHour,locked:ie.locked}));z[k]={...z[k],minuteOfDay:je};const be=qe(z,k,o),Ne=C((I-ye)/I*b,0,Math.max(0,be));return z[k]={...z[k],rateApPerHour:Number(Ne.toFixed(3))},z[k]})),H(N=>N===null||N.pointerId!==d.pointerId?N:{...N,pointerX:D,pointerY:X})},m=d=>{(!d||d.pointerId===n.pointerId)&&H(null)};return window.addEventListener("pointermove",l,{passive:!1}),window.addEventListener("pointerup",m),window.addEventListener("pointercancel",m),()=>{window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",m),window.removeEventListener("pointercancel",m)}},[o,n,y,I,_,c,b]);const ge=u.useMemo(()=>{if(!p)return[];const s=c[p.index]??null;return[{id:"remove-point",label:"Remove point",description:s===null?"No turn point is selected.":`Delete the turn point at ${se(s.minuteOfDay)}.`,icon:He,tone:"danger",disabled:s===null||p.index===0||p.index===c.length-1,onSelect:()=>{y(c.filter((l,m)=>m!==p.index))}},{id:"flatten-point",label:"Flatten point",description:s===null?"No turn point is selected.":"Place the handle back on the interpolated segment between its neighbors.",icon:Te,disabled:s===null||p.index===0||p.index===c.length-1,onSelect:()=>{const l=c[p.index-1],m=c[p.index+1],d=de([l,m],s.minuteOfDay);y(c.map((g,A)=>A===p.index?{...g,rateApPerHour:Number(d.toFixed(3))}:g))}}]},[p,y,c]),Z=u.useMemo(()=>c.map(s=>({...s,x:M.left+s.minuteOfDay/1440*_,y:M.top+(1-s.rateApPerHour/Math.max(1,b))*I})),[I,_,c,b]),T=n===null?null:{pointerX:n.pointerX,pointerY:n.pointerY,constrainedX:((ne=Z[n.index])==null?void 0:ne.x)??n.pointerX,constrainedY:((oe=Z[n.index])==null?void 0:oe.y)??n.pointerY};return e.jsxs(e.Fragment,{children:[e.jsxs(w,{className:"overflow-hidden p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Life Force view"}),e.jsx("div",{className:"mt-2 text-xl font-semibold text-white",children:"Instant Life Force editor"}),e.jsx("div",{className:"mt-2 max-w-3xl text-sm leading-6 text-white/56",children:"One click adds a turn point. Drag future handles. Right click a handle to remove or flatten it. The ghost handle follows your finger or cursor while the real turn point stays constrained on the curve and normalized to the baseline daily AP budget."})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-1 rounded-full bg-white/[0.04] p-1",children:te.map((s,l)=>e.jsx("button",{type:"button",className:K("rounded-full px-3 py-1.5 text-[11px] font-medium transition",a===l?"bg-[var(--primary)] text-slate-950":"text-white/60 hover:bg-white/[0.05] hover:text-white"),onClick:()=>x(l),children:s},s))}),e.jsx(ee,{variant:"secondary",onClick:L,children:"Reset"}),e.jsxs(ee,{onClick:P,pending:v,disabled:!i,children:[e.jsx(Ce,{className:"mr-2 size-4"}),"Save curve"]})]})]}),e.jsxs("div",{className:"mt-4 rounded-[24px] bg-[linear-gradient(180deg,rgba(192,193,255,0.08),rgba(192,193,255,0.02))] p-3",children:[e.jsxs("div",{ref:f,className:K("relative h-72 w-full overflow-hidden rounded-[20px] bg-[rgba(255,255,255,0.02)]",n!==null?"select-none touch-none":""),style:{touchAction:n===null?"pan-y":"none"},role:"img","aria-label":"Life Force capacity curve editor",onClick:s=>{if(n!==null||!f.current||s.target!==s.currentTarget)return;const l=f.current.getBoundingClientRect(),m=C(s.clientX-l.left-M.left,0,_),d=Math.round(m/_*1440),g=c.findIndex(W=>W.minuteOfDay>d);if(g<=0)return;const A=c[g-1],h=c[g];if(d-A.minuteOfDay<R||h.minuteOfDay-d<R)return;const D=de(c,d),X=[...c];X.splice(g,0,{minuteOfDay:d,rateApPerHour:Number(D.toFixed(3)),locked:a===S&&d<=F}),y(X)},children:[e.jsxs(Fe,{width:B,height:ce,data:G,margin:M,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"life-force-chart-fill",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"rgba(192,193,255,0.24)"}),e.jsx("stop",{offset:"100%",stopColor:"rgba(192,193,255,0.02)"})]})}),e.jsx(_e,{vertical:!1,stroke:"rgba(255,255,255,0.08)",strokeDasharray:"3 4"}),e.jsx(Ee,{dataKey:"minuteOfDay",type:"number",domain:[0,1440],ticks:j,tickFormatter:We,tick:{fill:"rgba(255,255,255,0.48)",fontSize:10},tickLine:!1,axisLine:{stroke:"rgba(255,255,255,0.12)"},children:e.jsx(le,{value:"Time",position:"insideBottom",offset:-10,fill:"rgba(255,255,255,0.38)",fontSize:10})}),e.jsx(Ie,{type:"number",domain:[0,b],ticks:V,tick:{fill:"rgba(255,255,255,0.48)",fontSize:10},tickLine:!1,axisLine:{stroke:"rgba(255,255,255,0.12)"},width:34,children:e.jsx(le,{value:"AP/h",angle:-90,position:"insideLeft",fill:"rgba(255,255,255,0.38)",fontSize:10,style:{textAnchor:"middle"}})}),e.jsx(Xe,{cursor:{stroke:"rgba(255,255,255,0.18)",strokeDasharray:"3 4"},content:({active:s,payload:l})=>{var d;const m=s?(d=l==null?void 0:l[0])==null?void 0:d.payload:null;return m?e.jsxs("div",{className:"rounded-[16px] border border-white/10 bg-[rgba(10,15,27,0.95)] px-3 py-2 text-xs text-white shadow-[0_18px_50px_rgba(4,8,18,0.3)] backdrop-blur-xl",children:[e.jsx("div",{className:"font-medium text-white",children:m.label}),e.jsx("div",{className:"mt-1 text-white/60",children:O(m.rateApPerHour)})]}):null}}),a===S?e.jsx(ze,{x:F,stroke:"rgba(255,255,255,0.22)",strokeDasharray:"3 4"}):null,e.jsx(Re,{type:"linear",dataKey:"rateApPerHour",stroke:"none",fill:"url(#life-force-chart-fill)",isAnimationActive:!1}),e.jsx(Ye,{type:"linear",dataKey:"rateApPerHour",stroke:"rgba(214,215,255,0.95)",strokeWidth:1.5,dot:!1,activeDot:!1,isAnimationActive:!1})]}),T?e.jsxs("svg",{className:"pointer-events-none absolute inset-0 z-[15] h-full w-full","aria-hidden":"true",children:[e.jsx("line",{x1:T.constrainedX,y1:T.constrainedY,x2:T.pointerX,y2:T.pointerY,stroke:"rgba(214,215,255,0.38)",strokeDasharray:"4 5",strokeWidth:"1.5"}),e.jsx("circle",{cx:T.pointerX,cy:T.pointerY,r:"11",fill:"rgba(214,215,255,0.12)",stroke:"rgba(214,215,255,0.34)",strokeWidth:"1.5","data-testid":"life-force-ghost-handle"}),e.jsx("circle",{cx:T.pointerX,cy:T.pointerY,r:"3.5",fill:"rgba(255,255,255,0.44)"})]}):null,Z.map((s,l)=>{const m=l===0||l===Z.length-1,d=(n==null?void 0:n.index)===l,g=m?14:16,A=m?22:28;return e.jsx("button",{type:"button","aria-label":`Turn point at ${se(s.minuteOfDay)}`,className:K("absolute z-20 flex items-center justify-center rounded-full transition-transform duration-75",s.locked||m?"cursor-not-allowed":"cursor-grab active:cursor-grabbing",d?"scale-110":""),style:{left:s.x-A/2,top:s.y-A/2,width:A,height:A,touchAction:"none"},onPointerDown:h=>{if(h.preventDefault(),h.stopPropagation(),s.locked||m||!f.current)return;"setPointerCapture"in h.currentTarget&&h.currentTarget.setPointerCapture(h.pointerId);const D=f.current.getBoundingClientRect(),X=Number.isFinite(h.clientX)?h.clientX:D.left+s.x,W=Number.isFinite(h.clientY)?h.clientY:D.top+s.y;H({index:l,pointerId:h.pointerId,pointerX:C(X-D.left,0,D.width),pointerY:C(W-D.top,0,D.height)})},onContextMenu:h=>{h.preventDefault(),h.stopPropagation(),Q({index:l,position:{x:h.clientX+6,y:h.clientY+6}})},children:e.jsx("span",{className:K("pointer-events-none inline-flex rounded-full border border-[rgba(10,15,27,0.92)] shadow-[0_0_0_1px_rgba(255,255,255,0.08),0_10px_24px_rgba(4,8,18,0.28)]",s.locked||m?"bg-white/55":"bg-white"),style:{width:g,height:g,opacity:d?.96:1}})},`${s.minuteOfDay}-${l}`)})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-2 px-1 text-[11px] text-white/42",children:[e.jsxs("div",{children:["Editing ",te[a]," curve"]}),e.jsxs("div",{children:[Math.round(o)," AP/day baseline"]})]})]})]}),e.jsx(Se,{open:p!==null,title:"Turn point actions",subtitle:"Delete the turn point or flatten it back onto the surrounding segment.",items:ge,position:(p==null?void 0:p.position)??null,onClose:()=>Q(null)})]})}function et(){return e.jsx(w,{className:"overflow-hidden p-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Life Force studio"}),e.jsx("div",{className:"mt-2 text-xl font-semibold text-white",children:"Edit weekday curves in the dedicated view"}),e.jsx("div",{className:"mt-2 max-w-3xl text-sm leading-6 text-white/56",children:"The full weekday editor, turn-point menu, and curve calibration now live in their own page so Overview can stay fast and readable."})]}),e.jsxs(Oe,{to:"/life-force",className:"inline-flex min-h-10 min-w-0 max-w-full items-center justify-center gap-2 overflow-hidden whitespace-nowrap rounded-[var(--radius-control)] border border-[var(--primary)]/14 bg-[var(--ui-accent-soft)] px-3 py-2 text-[13px] font-medium text-[var(--ui-ink-on-accent)] shadow-[var(--ui-shadow-soft)] transition hover:bg-[var(--ui-accent-soft-hover)]",children:[e.jsx(me,{className:"size-4"}),"Open Life Force studio"]})]})})}function tt({drains:t,plannedDrains:a,warnings:r,recommendations:o}){return e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)]",children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsxs(w,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Current drains"}),e.jsx("div",{className:"mt-2 text-xl font-semibold text-white",children:"What is consuming Life Force now"})]}),e.jsxs(U,{className:"bg-white/[0.08] text-white/70",children:[t.length," active"]})]}),e.jsx("div",{className:"mt-4 grid gap-3",children:t.length===0?e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-4 text-sm text-white/58",children:"No current drainers are active. This is a good moment to choose your next intentional action."}):t.map(i=>e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-base font-semibold text-white",children:i.title}),e.jsx("div",{className:"mt-1 text-sm text-white/54",children:i.why})]}),e.jsxs("div",{className:"shrink-0 text-right",children:[e.jsx("div",{className:"text-base font-semibold text-[var(--primary)]",children:O(i.apPerHour)}),e.jsx("div",{className:"mt-1 text-xs uppercase tracking-[0.14em] text-white/38",children:Ge(i.role)})]})]})},i.id))})]}),e.jsxs(w,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Planned drains"}),e.jsx("div",{className:"mt-2 text-xl font-semibold text-white",children:"What the rest of today is already asking from you"})]}),e.jsxs(U,{className:"bg-white/[0.08] text-white/70",children:[a.length," planned"]})]}),e.jsx("div",{className:"mt-4 grid gap-3",children:a.length===0?e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-4 text-sm text-white/58",children:"No future AP load has been forecast yet. The day is still open."}):a.slice(0,6).map(i=>e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-base font-semibold text-white",children:i.title}),e.jsx("div",{className:"mt-1 text-sm text-white/54",children:i.why})]}),e.jsxs("div",{className:"shrink-0 text-right",children:[e.jsx("div",{className:"text-base font-semibold text-[var(--primary)]",children:re(i.instantAp)}),e.jsx("div",{className:"mt-1 text-xs uppercase tracking-[0.14em] text-white/38",children:O(i.apPerHour)})]})]})},i.id))})]})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs(w,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Warnings"}),e.jsx("div",{className:"mt-4 grid gap-3",children:r.map(i=>e.jsxs("div",{className:K("rounded-[18px] px-4 py-4",Qe(i.tone)),children:[e.jsx("div",{className:"text-sm font-semibold",children:i.title}),e.jsx("div",{className:"mt-1 text-sm leading-6 text-current/80",children:i.detail})]},i.id))})]}),e.jsxs(w,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Recommendations"}),e.jsx("div",{className:"mt-4 grid gap-2",children:o.map((i,v)=>e.jsx("div",{className:"rounded-[16px] bg-white/[0.04] px-4 py-3 text-sm leading-6 text-white/66",children:i},`${i}-${v}`))})]})]})]})}function fe({lifeForce:t,onTired:a,onOkayAgain:r,tiredPending:o,okayPending:i,feedback:v}){return e.jsxs(w,{className:"overflow-hidden p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Life Force now"}),e.jsxs("div",{className:"mt-2 text-2xl font-semibold text-white",children:[t.instantFreeApPerHour.toFixed(1)," AP/h free"]}),e.jsxs("div",{className:"mt-2 text-sm text-white/58",children:[Math.round(t.spentTodayAp)," / ",Math.round(t.dailyBudgetAp)," AP used today"]}),e.jsx("div",{className:"mt-2 text-xs uppercase tracking-[0.14em] text-white/38",children:he(t)})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(ee,{variant:"secondary",onClick:a,pending:o,children:[e.jsx(ke,{className:"mr-2 size-4"}),"I'm getting tired"]}),e.jsxs(ee,{variant:"secondary",onClick:r,pending:i,children:[e.jsx(Pe,{className:"mr-2 size-4"}),"I'm okay again"]})]})]}),v?e.jsx("div",{className:"mt-4 rounded-[18px] bg-[var(--primary)]/10 px-4 py-3 text-sm text-white/74",children:v}):null,e.jsxs("div",{className:"mt-4 grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-white",children:[e.jsx(me,{className:"size-4 text-[var(--primary)]"}),"Instant capacity"]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:O(t.instantCapacityApPerHour)})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-white",children:[e.jsx(De,{className:"size-4 text-[var(--primary)]"}),"Current load"]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:O(t.currentDrainApPerHour)}),e.jsx("div",{className:"mt-2 text-xs uppercase tracking-[0.14em] text-white/38",children:t.overloadApPerHour>0?`${O(t.overloadApPerHour)} overload`:"Inside instant limit"})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-white",children:[e.jsx(Me,{className:"size-4 text-[var(--primary)]"}),"Next move"]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:t.recommendations[0]??"Favor the next clean, manageable action."}),e.jsx("div",{className:"mt-2 text-xs uppercase tracking-[0.14em] text-white/38",children:Ve(t)})]})]})]})}function ot({selectedUserIds:t,fallbackLifeForce:a,onRefresh:r,showEditor:o=!0}){var b,G;const i=ue(),v=new Date().getDay(),[y,L]=u.useState(v),P=xe({queryKey:["forge-life-force",...t],queryFn:()=>pe(t),initialData:a===void 0?void 0:{lifeForce:a,templates:te.map((j,V)=>({weekday:V,baselineDailyAp:a.baselineDailyAp,points:a.currentCurve.map(B=>({...B,locked:V===v?B.locked:!1}))}))}}),x=((b=P.data)==null?void 0:b.lifeForce)??a,n=(((G=P.data)==null?void 0:G.templates)??Be(x,v)).find(j=>j.weekday===y)??{weekday:y,baselineDailyAp:x.baselineDailyAp,points:x.currentCurve},[H,E]=u.useState(n.points),[ae,p]=u.useState(!1),[Q,S]=u.useState(null);u.useEffect(()=>{E(n.points),p(!1)},[n.points,n.weekday]);const F=$({mutationFn:j=>Le(n.weekday,{points:$e(j,n.baselineDailyAp)},t),onSuccess:async j=>{await i.invalidateQueries({queryKey:["forge-life-force"]}),await q(i),r&&await r(),E(j.points),p(!1)}}),Y=$({mutationFn:()=>J({signalType:"tired"},t),onSuccess:async()=>{await i.invalidateQueries({queryKey:["forge-life-force"]}),await q(i),r&&await r(),S("Tiredness signal applied. Today’s Life Force now reflects the extra strain.")}}),c=$({mutationFn:()=>J({signalType:"okay_again"},t),onSuccess:async()=>{await i.invalidateQueries({queryKey:["forge-life-force"]}),await q(i),r&&await r(),S("Recovery signal applied. Instant strain has been eased for the rest of today.")}});return e.jsxs("div",{className:"grid gap-4",children:[e.jsx(Ze,{lifeForce:x}),e.jsx(Je,{lifeForce:x}),e.jsx(fe,{lifeForce:x,onTired:()=>{Y.mutateAsync()},onOkayAgain:()=>{c.mutateAsync()},tiredPending:Y.isPending,okayPending:c.isPending,feedback:Q}),o?e.jsx(Ue,{lifeForce:x,weekday:y,points:H,baselineDailyAp:n.baselineDailyAp,isDirty:ae,isSaving:F.isPending,onWeekdayChange:L,onChange:j=>{E(j),p(!0)},onReset:()=>{E(n.points),p(!1)},onSave:()=>{F.mutateAsync(H)}}):e.jsx(et,{}),e.jsx(tt,{drains:x.activeDrains,plannedDrains:x.plannedDrains,warnings:x.warnings,recommendations:x.recommendations}),x.topTaskIdsNeedingSplit.length>0?e.jsxs(w,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-white",children:[e.jsx(Ae,{className:"size-4 text-[var(--primary)]"}),"Tasks asking to be split"]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:x.topTaskIdsNeedingSplit.map(j=>e.jsx(U,{className:"bg-white/[0.08] text-white/74",children:j},j))})]}):null]})}function lt({selectedUserIds:t,fallbackLifeForce:a,onRefresh:r}){var n;const o=Array.isArray(t)?t:[],i=ue(),y=((n=xe({queryKey:["forge-life-force",...o],queryFn:()=>pe(o),initialData:a===void 0?void 0:{lifeForce:a,templates:[]}}).data)==null?void 0:n.lifeForce)??a;if(!y)return e.jsxs(w,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Life Force"}),e.jsx("div",{className:"mt-2 text-lg font-semibold text-white",children:"Not calibrated yet"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:"Today can still load without a Life Force snapshot, but the AP and instant headroom model is not available for this state yet."})]});const[L,P]=u.useState(null),x=$({mutationFn:()=>J({signalType:"tired"},o),onSuccess:async()=>{await i.invalidateQueries({queryKey:["forge-life-force"]}),await q(i),r&&await r(),P("Tiredness signal applied. Today’s headroom has been reduced.")}}),f=$({mutationFn:()=>J({signalType:"okay_again"},o),onSuccess:async()=>{await i.invalidateQueries({queryKey:["forge-life-force"]}),await q(i),r&&await r(),P("Recovery signal applied. Today’s headroom has been eased.")}});return e.jsx(fe,{lifeForce:y,onTired:()=>{x.mutateAsync()},onOkayAgain:()=>{f.mutateAsync()},tiredPending:x.isPending,okayPending:f.isPending,feedback:L})}export{ot as L,lt as a};
|