forge-openclaw-plugin 0.2.101 → 0.2.102
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-CpjuNSHw.js → activity-page-CgF7K2ww.js} +1 -1
- package/dist/assets/ai-surface-workspace-xtB5RFQu.js +1 -0
- package/dist/assets/atlas-panel-B3dPHCmZ.js +1 -0
- package/dist/assets/{board-BkDRaMp6.js → board-DqHzdCPQ.js} +1 -1
- package/dist/assets/{calendar-page-DNNt6lfz.js → calendar-page-C1Wfd2Fy.js} +1 -1
- package/dist/assets/{calendar-rules-DNJFNsxi.js → calendar-rules-CaZXtlxt.js} +1 -1
- package/dist/assets/calendar-week-toolbar-BZ_-X3Wb.js +1 -0
- package/dist/assets/{charts-P7EVhIog.js → charts-FcU0F3XV.js} +8 -8
- package/dist/assets/{companion-sync-lab-page-KxEDigM6.js → companion-sync-lab-page-NgeK-O-P.js} +1 -1
- package/dist/assets/daily-metrics-dashboard-BMyL0Qr4.js +1 -0
- package/dist/assets/{entity-note-count-link-DrhjJZ4i.js → entity-note-count-link-BrS1-O0o.js} +1 -1
- package/dist/assets/entity-notes-surface-CBylYDwy.js +1 -0
- package/dist/assets/{execution-board-D07gOocB.js → execution-board-CpO2ch6v.js} +1 -1
- package/dist/assets/faceted-token-search-D7xPWfOl.js +1 -0
- package/dist/assets/flagship-signal-deck-BEFKOhvx.js +1 -0
- package/dist/assets/{floating-action-menu-Fs_ZiUMo.js → floating-action-menu-zzC2r0Ob.js} +1 -1
- package/dist/assets/{forms-BFlTgZ3W.js → forms-CmLAyGqz.js} +1 -1
- package/dist/assets/{goal-detail-page-CqLiNz4f.js → goal-detail-page-JK_Nva8e.js} +1 -1
- package/dist/assets/goals-page-yeoJ06Vw.js +1 -0
- package/dist/assets/{graph-D6JLqDbD.js → graph-BTa79qum.js} +14 -14
- package/dist/assets/{habits-page-BJxagdzx.js → habits-page-Dx5EhkJi.js} +1 -1
- package/dist/assets/index-BHIKoiZ6.js +19 -0
- package/dist/assets/index-H8R-ABM3.css +1 -0
- package/dist/assets/insight-flow-dialog-BtIQXXsS.js +1 -0
- package/dist/assets/{insights-page-D6rOa7uk.js → insights-page-CujrosD_.js} +1 -1
- package/dist/assets/{kanban-page-XQ7Se6dH.js → kanban-page-Q9NuIz5w.js} +1 -1
- package/dist/assets/knowledge-graph-page-DaJmlvvM.js +1 -0
- package/dist/assets/{life-force-page-Dy0JTS2G.js → life-force-page-BGDkKfbJ.js} +1 -1
- package/dist/assets/{life-force-workspace-OfyB9HJM.js → life-force-workspace-CLVexVnb.js} +1 -1
- package/dist/assets/{maps-ClgJoCjz.js → maps-CF1RagUX.js} +1 -1
- package/dist/assets/metric-tile-4iMd_WnJ.js +1 -0
- package/dist/assets/{motion-BeD44FeG.js → motion-CfdU2F35.js} +1 -1
- package/dist/assets/movement-page-ClaoTNuX.js +1 -0
- package/dist/assets/note-markdown-CsGQhQXF.js +3 -0
- package/dist/assets/note-tags-input-DdZi93tj.js +1 -0
- package/dist/assets/notes-page-DYI8s3NN.js +1 -0
- package/dist/assets/{open-in-graph-button-IXe9SGth.js → open-in-graph-button-C0TGev7c.js} +1 -1
- package/dist/assets/orbit-map-DVXkfQdd.js +1 -0
- package/dist/assets/overview-page-BwMlFQKX.js +1 -0
- package/dist/assets/page-hero-oFHaAjtL.js +1 -0
- package/dist/assets/pill-cluster-7UZd_lHp.js +1 -0
- package/dist/assets/{preference-entity-handoff-button-5PzUn42S.js → preference-entity-handoff-button-DOKV9bZc.js} +1 -1
- package/dist/assets/preferences-page-BrKEkmfD.js +1 -0
- package/dist/assets/{project-collections-xPz2mlRr.js → project-collections-CZagCmeH.js} +1 -1
- package/dist/assets/{project-detail-page-BXK5-4xW.js → project-detail-page-DogvVNEn.js} +1 -1
- package/dist/assets/{project-management-hierarchy-page-DtRpMABw.js → project-management-hierarchy-page-Dr7hW9PW.js} +1 -1
- package/dist/assets/{project-management-section-nav-P3ixzPa-.js → project-management-section-nav-BLdAgTge.js} +1 -1
- package/dist/assets/{projects-page-C5ViRuf4.js → projects-page-UKrby_5-.js} +1 -1
- package/dist/assets/psyche-behaviors-page-BeVlXvbj.js +5 -0
- package/dist/assets/psyche-flashcards-page-CqAWCO4E.js +1 -0
- package/dist/assets/psyche-goal-map-page-IyNnbk_W.js +1 -0
- package/dist/assets/psyche-graph-IkUQRaDK.js +1 -0
- package/dist/assets/{psyche-metrics-page-CuR9oqEy.js → psyche-metrics-page-uai0a7Lx.js} +1 -1
- package/dist/assets/psyche-mode-guide-page-C7p-ABiF.js +1 -0
- package/dist/assets/psyche-modes-page-CLQ5V3w0.js +1 -0
- package/dist/assets/psyche-page-NQBHkkpU.js +1 -0
- package/dist/assets/psyche-patterns-page-BkRiNpI_.js +5 -0
- package/dist/assets/psyche-questionnaire-builder-page-Du-7HwPC.js +1 -0
- package/dist/assets/psyche-questionnaire-detail-page-C5-yf8MF.js +1 -0
- package/dist/assets/psyche-questionnaire-run-detail-page-CoSH5O6R.js +1 -0
- package/dist/assets/psyche-questionnaire-run-page-ChI7c1wy.js +1 -0
- package/dist/assets/psyche-questionnaires-page-xUcJJzbI.js +1 -0
- package/dist/assets/psyche-report-detail-page-BPrZCFZS.js +3 -0
- package/dist/assets/psyche-reports-page-D2EXJmm6.js +1 -0
- package/dist/assets/{psyche-schemas-HFmg37Wj.js → psyche-schemas-RcZYaokx.js} +1 -1
- package/dist/assets/psyche-schemas-beliefs-page-h0ooZ1lp.js +9 -0
- package/dist/assets/psyche-screen-time-page-_3-4LikV.js +1 -0
- package/dist/assets/psyche-self-observation-page-BdbCsgR5.js +1 -0
- package/dist/assets/psyche-values-page-DuUVki5e.js +5 -0
- package/dist/assets/report-chain-fields-BBMz0sGI.js +1 -0
- package/dist/assets/{rewards-page-DmC4R_Ps.js → rewards-page-PZFPa6rR.js} +1 -1
- package/dist/assets/{scheduling-rules-editor-D02s70hr.js → scheduling-rules-editor-B9KNKsQz.js} +1 -1
- package/dist/assets/schema-badge-D93RcG36.js +1 -0
- package/dist/assets/schema-visuals-CvC9a3i6.js +1 -0
- package/dist/assets/select-menu-Cdq7foRu.js +1 -0
- package/dist/assets/{settings-agents-page-C_v_hMJF.js → settings-agents-page-DPx2F6wf.js} +3 -3
- package/dist/assets/{settings-bin-page-DY5bg81n.js → settings-bin-page-COwP3gjo.js} +1 -1
- package/dist/assets/settings-calendar-page-C-ghE0YT.js +5 -0
- package/dist/assets/{settings-data-page-CHRQFU9H.js → settings-data-page-CBubzKBw.js} +1 -1
- package/dist/assets/{settings-logs-page-B04pUwEv.js → settings-logs-page-uOuXMeBm.js} +1 -1
- package/dist/assets/{settings-mobile-page-D9kTlYDS.js → settings-mobile-page-C5rfj8_r.js} +1 -1
- package/dist/assets/settings-models-page-DijmUWdU.js +1 -0
- package/dist/assets/{settings-page-DYDTFlnv.js → settings-page-B4u5TR5g.js} +1 -1
- package/dist/assets/{settings-rewards-page-cl4vqqO_.js → settings-rewards-page-COiTwkMH.js} +1 -1
- package/dist/assets/{settings-section-nav-DSOuht_F.js → settings-section-nav-Dc4IeVBt.js} +1 -1
- package/dist/assets/{settings-users-page-BU79JB_T.js → settings-users-page-DEGa5DNn.js} +1 -1
- package/dist/assets/settings-wiki-page-Cvsiz5_e.js +1 -0
- package/dist/assets/{sleep-page-D8NbdhyS.js → sleep-page-BnSOwkEU.js} +1 -1
- package/dist/assets/{sports-page-CV4Cnzwn.js → sports-page-l1RqXzA_.js} +1 -1
- package/dist/assets/{state-B-4sS1xO.js → state-VYvD1QVP.js} +1 -1
- package/dist/assets/{strategies-page-C4qvXnql.js → strategies-page-DEnPlpAs.js} +1 -1
- package/dist/assets/{strategy-detail-page-DJLo5rfy.js → strategy-detail-page-Ls8bxKeH.js} +1 -1
- package/dist/assets/strategy-dialog-DMyRKrWf.js +1 -0
- package/dist/assets/surface-Bfz_sLX6.js +1 -0
- package/dist/assets/{table-WfAPUppN.js → table-C0VTeqw0.js} +1 -1
- package/dist/assets/task-detail-page-CgrYgQLD.js +1 -0
- package/dist/assets/{timebox-planning-dialog-DB6FLqmI.js → timebox-planning-dialog-Ww0NGLLo.js} +1 -1
- package/dist/assets/today-page-CIuFHMi1.js +1 -0
- package/dist/assets/training-load-page-BIwc648i.js +1 -0
- package/dist/assets/{ui-C13Nbgas.js → ui-CsEkP2V8.js} +4 -4
- package/dist/assets/use-psyche-focus-target-qxT5Oy_z.js +1 -0
- package/dist/assets/{vendor-DHkYh85p.js → vendor-kIz9EZnX.js} +237 -222
- package/dist/assets/{vitals-page-qre17Nw8.js → vitals-page-Dz1Jt5H8.js} +1 -1
- package/dist/assets/{weekly-review-page-Cz4vkRcx.js → weekly-review-page-BFpBe1kI.js} +1 -1
- package/dist/assets/weight-loss-page-BgMoBpBt.js +5 -0
- package/dist/assets/{wiki-article-markdown-DdiR2TJE.js → wiki-article-markdown-gsPTXTg1.js} +1 -1
- package/dist/assets/{wiki-editor-page-DqwoqVFb.js → wiki-editor-page-BpAZHooY.js} +7 -7
- package/dist/assets/{wiki-ingest-history-page--evBLbOw.js → wiki-ingest-history-page-C-ig8O22.js} +1 -1
- package/dist/assets/{wiki-ingest-modal--ohzFnj2.js → wiki-ingest-modal-BK4eQgqs.js} +1 -1
- package/dist/assets/{wiki-page-B_VJFBPA.js → wiki-page-CMTZ60Zt.js} +1 -1
- package/dist/assets/workbench-flow-page-BIpWUcLJ.js +5 -0
- package/dist/assets/workbench-page-CtCjYSRe.js +1 -0
- package/dist/assets/workout-detail-page-DD9IGN6l.js +2 -0
- package/dist/index.html +9 -9
- package/dist/openclaw/local-runtime.js +41 -14
- package/dist/server/server/migrations/067_weight_loss_daily_active_overrides.sql +13 -0
- package/dist/server/server/src/app.js +103 -30
- package/dist/server/server/src/health-weight-loss.js +457 -55
- package/dist/server/server/src/health.js +12 -4
- package/dist/server/server/src/movement.js +84 -1
- package/dist/server/server/src/openapi.js +123 -18
- package/dist/server/server/src/repositories/model-settings.js +12 -9
- package/dist/server/server/src/repositories/settings.js +19 -5
- package/dist/server/src/components/ui/info-tooltip.js +6 -6
- package/dist/server/src/lib/api.js +14 -4
- package/dist/server/src/lib/theme-system.js +8 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +3 -3
- package/server/migrations/067_weight_loss_daily_active_overrides.sql +13 -0
- package/skills/forge-openclaw/SKILL.md +13 -0
- package/skills/forge-openclaw/entity_conversation_playbooks.md +7 -1
- package/dist/assets/ai-surface-workspace-DEAFZruS.js +0 -1
- package/dist/assets/atlas-panel-CdVNPotj.js +0 -1
- package/dist/assets/calendar-week-toolbar-BbPwYeN0.js +0 -1
- package/dist/assets/daily-metrics-dashboard-B3cqJgDt.js +0 -1
- package/dist/assets/entity-notes-surface-CkcRsKJQ.js +0 -1
- package/dist/assets/faceted-token-search-BxRRcM3q.js +0 -1
- package/dist/assets/flagship-signal-deck-cmy82b8_.js +0 -1
- package/dist/assets/goals-page-BTk7mg_T.js +0 -1
- package/dist/assets/index-CF4J4R9L.js +0 -19
- package/dist/assets/index-CZbuZQjw.css +0 -1
- package/dist/assets/insight-flow-dialog-8f3D0GuC.js +0 -1
- package/dist/assets/knowledge-graph-page-BtAg8iv3.js +0 -1
- package/dist/assets/metric-tile-DKpo-8xw.js +0 -1
- package/dist/assets/movement-page-Bg_T_Stx.js +0 -1
- package/dist/assets/note-markdown-N-uxD3Xt.js +0 -3
- package/dist/assets/note-tags-input-Cdu7wiw6.js +0 -1
- package/dist/assets/notes-page-CKXnF_KU.js +0 -1
- package/dist/assets/orbit-map-Dzi6KliQ.js +0 -1
- package/dist/assets/overview-page-1miYqaVS.js +0 -1
- package/dist/assets/page-hero-DRy5b2MU.js +0 -1
- package/dist/assets/pill-cluster-C9QczVJ2.js +0 -1
- package/dist/assets/preferences-page-DtNaF5Q3.js +0 -1
- package/dist/assets/psyche-behaviors-page-Dco46sC4.js +0 -5
- package/dist/assets/psyche-flashcards-page-ZcoEB8gV.js +0 -1
- package/dist/assets/psyche-goal-map-page-CLBAQOI0.js +0 -1
- package/dist/assets/psyche-graph-k4tX2tdp.js +0 -1
- package/dist/assets/psyche-mode-guide-page-hIVXcCnE.js +0 -1
- package/dist/assets/psyche-modes-page-0lYtBlhO.js +0 -1
- package/dist/assets/psyche-page-VZ9k9ISp.js +0 -1
- package/dist/assets/psyche-patterns-page-gx5nmdGq.js +0 -5
- package/dist/assets/psyche-questionnaire-builder-page-Bn0TOISd.js +0 -1
- package/dist/assets/psyche-questionnaire-detail-page-CmVzSd_s.js +0 -1
- package/dist/assets/psyche-questionnaire-run-detail-page-BsMbmXCG.js +0 -1
- package/dist/assets/psyche-questionnaire-run-page-CgkRL2vi.js +0 -1
- package/dist/assets/psyche-questionnaires-page-D7V8uLXM.js +0 -1
- package/dist/assets/psyche-report-detail-page-OlFq57eL.js +0 -3
- package/dist/assets/psyche-reports-page-dVUZjna1.js +0 -1
- package/dist/assets/psyche-schemas-beliefs-page-BCgc8FUd.js +0 -9
- package/dist/assets/psyche-screen-time-page-B_6BT_WN.js +0 -1
- package/dist/assets/psyche-self-observation-page-CEG5mluK.js +0 -1
- package/dist/assets/psyche-values-page-DRbRfEd6.js +0 -5
- package/dist/assets/report-chain-fields-CALCV3V5.js +0 -1
- package/dist/assets/schema-badge-BZO-qNhO.js +0 -1
- package/dist/assets/schema-visuals-D6nxjbYC.js +0 -1
- package/dist/assets/select-menu-fYyreSdQ.js +0 -1
- package/dist/assets/settings-calendar-page-D1CzE6cg.js +0 -5
- package/dist/assets/settings-models-page-D26270R2.js +0 -1
- package/dist/assets/settings-wiki-page-DwAUlyA3.js +0 -1
- package/dist/assets/strategy-dialog-D3AuUlVz.js +0 -1
- package/dist/assets/task-detail-page-z-9u9rF0.js +0 -1
- package/dist/assets/today-page-BKlu6gx5.js +0 -1
- package/dist/assets/training-load-page-CyJQqo_3.js +0 -1
- package/dist/assets/use-psyche-focus-target-C1C_XjYG.js +0 -1
- package/dist/assets/weight-loss-page-BQrnOI0y.js +0 -1
- package/dist/assets/workbench-flow-page-Du62mtJU.js +0 -5
- package/dist/assets/workbench-page-4MKr3iRm.js +0 -1
- package/dist/assets/workout-detail-page-DfUbYYw1.js +0 -2
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as i,j as r}from"./vendor-DHkYh85p.js";import{Q as N,cR as W,F as m,I as w,b as x,ah as f,j as v,T as p}from"./index-CF4J4R9L.js";function u(e,a){return{originType:(e==null?void 0:e.originType)??"user",originAgentId:(e==null?void 0:e.originAgentId)??"",originLabel:(e==null?void 0:e.originLabel)??"",entityType:(a==null?void 0:a.entityType)??(e==null?void 0:e.entityType)??"",entityId:(a==null?void 0:a.entityId)??(e==null?void 0:e.entityId)??"",timeframeLabel:(e==null?void 0:e.timeframeLabel)??"This week",title:(e==null?void 0:e.title)??"",summary:(e==null?void 0:e.summary)??"",recommendation:(e==null?void 0:e.recommendation)??"",rationale:(e==null?void 0:e.rationale)??"",confidence:(e==null?void 0:e.confidence)??.72,ctaLabel:(e==null?void 0:e.ctaLabel)??"Review insight",targetKind:(a==null?void 0:a.entityType)??(e==null?void 0:e.entityType)??"general"}}function $({open:e,onOpenChange:a,title:j="Store insight",description:T="Capture a clear observation, its recommendation, and where it belongs without dropping into a raw admin form.",eyebrow:I="Insight",pending:L=!1,submitLabel:C="Store insight",initialValue:c,lockedEntity:h,entityCandidates:d=[],onSubmit:F}){const[s,l]=i.useState(()=>u(c,h)),[S,g]=i.useState(null);i.useEffect(()=>{e&&(l(u(c,h)),g(null))},[c,h,e]);const b=i.useMemo(()=>{const o=new Set(["general"]);return d.forEach(n=>o.add(n.entityType)),h&&o.add(h.entityType),Array.from(o)},[d,h]),y=d.filter(o=>o.entityType===s.targetKind),K=[{id:"focus",eyebrow:"Focus",title:"Name the insight and place it in the right context",description:"Start with the main observation, then decide whether this belongs to a specific entity or should stay general.",render:(o,n)=>r.jsxs(r.Fragment,{children:[r.jsx(m,{label:"Insight title",description:"Write the main idea as a clear headline.",labelHelp:"The title should sound like the recommendation or realization you want to remember, not like an internal database field.",children:r.jsx(w,{value:o.title,onChange:t=>n({title:t.target.value}),placeholder:"Weekly review needs a tighter end ritual"})}),r.jsx(m,{label:"Timeframe",description:"Keep the horizon short and readable.",children:r.jsx(w,{value:o.timeframeLabel,onChange:t=>n({timeframeLabel:t.target.value}),placeholder:"This week"})}),r.jsx(m,{label:"Where should this insight live?",description:"Use a specific entity when the insight is about one goal, project, task, or report. Keep it general when it applies to the wider system.",children:h?r.jsxs("div",{className:"rounded-[24px] border border-white/8 bg-white/[0.04] p-4",children:[r.jsx(x,{kind:h.kind,label:h.label}),h.description?r.jsx(f,{className:"mt-2",children:h.description}):null]}):r.jsxs(r.Fragment,{children:[r.jsx(v,{value:o.targetKind,onChange:t=>n({targetKind:t,entityType:t==="general"?"":t,entityId:""}),options:b.map(t=>({value:t,label:t==="general"?"General insight":t==="trigger_report"?"Report":t.charAt(0).toUpperCase()+t.slice(1),description:t==="general"?"Store it in the broader insight feed.":`Attach it to a specific ${t==="trigger_report"?"report":t}.`})),columns:b.length>=3?3:2}),o.targetKind!=="general"?y.length>0?r.jsx("div",{className:"mt-4 grid gap-3 md:grid-cols-2",children:y.map(t=>{const A=o.entityType===t.entityType&&o.entityId===t.entityId;return r.jsxs("button",{type:"button",className:`rounded-[22px] border px-4 py-4 text-left transition ${A?"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:()=>n({entityType:t.entityType,entityId:t.entityId}),children:[r.jsx(x,{kind:t.kind,label:t.label,compact:!0}),t.description?r.jsx("div",{className:"mt-2 text-sm leading-6 text-white/54",children:t.description}):null]},`${t.entityType}:${t.entityId}`)})}):r.jsxs(f,{className:"mt-4",children:["No"," ",o.targetKind==="trigger_report"?"reports":`${o.targetKind}s`," ","are ready to attach here yet."]}):null]})})]})},{id:"observation",eyebrow:"Observation",title:"Capture what you are seeing clearly",description:"Keep the summary plain and useful. Add the why only if it helps the next action make sense.",render:(o,n)=>r.jsxs(r.Fragment,{children:[r.jsx(m,{label:"Summary",description:"Describe the pattern, problem, or opportunity in plain language.",labelHelp:"Write what is actually happening, not a slogan and not a long essay.",children:r.jsx(p,{value:o.summary,onChange:t=>n({summary:t.target.value}),placeholder:"The weekly review loses energy because the close-out is vague, so finished work never turns into clear next moves."})}),r.jsx(m,{label:"Why this matters",description:"Optional context that helps explain the recommendation.",children:r.jsx(p,{value:o.rationale,onChange:t=>n({rationale:t.target.value}),placeholder:"When the close-out is loose, important wins disappear from memory and the next week starts without momentum."})})]})},{id:"move",eyebrow:"Next move",title:"Turn the insight into a recommendation",description:"Finish with the recommendation you want the user or agent to actually act on.",render:(o,n)=>r.jsxs(r.Fragment,{children:[r.jsx(m,{label:"Recommendation",description:"Write the concrete move this insight points toward.",labelHelp:"A recommendation should be actionable. If the user read only this line, they should know what to do next.",children:r.jsx(p,{value:o.recommendation,onChange:t=>n({recommendation:t.target.value}),placeholder:"Add a fixed five-minute close-out block that turns finished tasks into one sentence of evidence and one next move."})}),r.jsx(m,{label:"Confidence",description:"Choose how strongly this recommendation holds up right now.",children:r.jsx(v,{value:String(o.confidence),onChange:t=>n({confidence:Number(t)}),options:[{value:"0.55",label:"Low",description:"Useful hunch, still early."},{value:"0.72",label:"Medium",description:"Solid pattern, worth acting on."},{value:"0.88",label:"High",description:"Clear enough to trust strongly."}],columns:3})})]})}];return r.jsx(N,{open:e,onOpenChange:a,eyebrow:I,title:j,description:T,value:s,onChange:l,draftPersistenceKey:"insights.flow",steps:K,submitLabel:C,pending:L,error:S,onSubmit:async()=>{g(null);const o=W.safeParse({originType:s.originType,originAgentId:s.originAgentId,originLabel:s.originLabel,entityType:s.targetKind==="general"?"":s.entityType,entityId:s.targetKind==="general"?"":s.entityId,timeframeLabel:s.timeframeLabel,title:s.title,summary:s.summary,recommendation:s.recommendation,rationale:s.rationale,confidence:s.confidence,ctaLabel:s.ctaLabel});if(!o.success){g("This insight still needs a title, a summary, and a recommendation before it can be stored.");return}try{await F(o.data),a(!1)}catch(n){g(n instanceof Error?n.message:"Unable to store this insight right now.")}}})}export{$ as I};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as p,j as r,b5 as Wt,c2 as Ut,cg as qt,cl as Qt,cm as ct,bf as lt,b4 as Jt,cn as Zt,co as er,cp as tr}from"./vendor-DHkYh85p.js";import{R as rr,P as nr,O as ar,C as sr,T as ir,D as or,a as ut}from"./ui-C13Nbgas.js";import{i as cr}from"./state-B-4sS1xO.js";import{aA as lr,aB as ur,aC as dr,aD as at,aE as $e,aF as jt,aG as st,aH as Mt,aI as Gt,aJ as hr,aK as it,aL as ot,aM as pr,aN as gr,b as et,V as fr,u as mr,aO as xr,aP as dt,aQ as br,L as wr,E as yr,aR as vr,U as ht,a8 as Nr,B as q,m as Se,I as qe,aS as pt,aT as Sr,aU as _r,aV as gt,ap as Cr,aW as Er}from"./index-CF4J4R9L.js";import{S as Rr,G as jr,i as Mr,C as Gr,B as Fr,M as kr}from"./graph-D6JLqDbD.js";import{F as ft}from"./faceted-token-search-BxRRcM3q.js";import{A as Ir,m as Kr}from"./motion-BeD44FeG.js";import"./board-BkDRaMp6.js";import"./forms-BFlTgZ3W.js";const Or=Math.PI*(3-Math.sqrt(5)),Ar=.48;function Ye(t,n,a){return Math.min(a,Math.max(n,t))}function Pr({positions:t,point:n}){const a=[...t.values()];if(a.length===0)return{x:.5,y:.5};let s=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY;for(const v of a)s=Math.min(s,v.x),c=Math.max(c,v.x),o=Math.min(o,v.y),l=Math.max(l,v.y);const u=Math.max(c-s,0),i=Math.max(l-o,0),m=Math.max(u,i,1),f=(1-u/m)/2,w=(1-i/m)/2,F=u||1,g=i||1;return{x:Ye((n.x-s)/F*(u/m)+f,0,1),y:Ye((n.y-o)/g*(i/m)+w,0,1)}}function Dr(t){let n=2166136261;for(let a=0;a<t.length;a+=1)n^=t.charCodeAt(a),n=Math.imul(n,16777619);return n>>>0}function Tr({nodes:t,cache:n}){const a=new Map,s=[...t].sort((u,i)=>i.importance-u.importance||u.title.localeCompare(i.title)||u.id.localeCompare(i.id));let c=0,o=0,l=0;if(s.forEach((u,i)=>{const m=n.get(u.id);if(m){a.set(u.id,m),c+=m.x,o+=m.y,l+=1;return}const f=(Dr(u.id)%1e3/1e3-.5)*.22,w=i*Or+f,F=Ar*Math.sqrt(i+1),g={x:Math.cos(w)*F,y:Math.sin(w)*F};a.set(u.id,g),c+=g.x,o+=g.y,l+=1}),l>0){const u=c/l,i=o/l;a.forEach((m,f)=>{a.set(f,{x:m.x-u,y:m.y-i})})}return a}function zr(t,n){if(t.startsWith("rgb(")&&t.endsWith(")"))return t.replace("rgb(","rgba(").replace(")",`, ${n})`);if(t.startsWith("#")){const a=t.slice(1),s=a.length===3?a.split("").map(u=>`${u}${u}`).join(""):a,c=parseInt(s.slice(0,2),16),o=parseInt(s.slice(2,4),16),l=parseInt(s.slice(4,6),16);return`rgba(${c}, ${o}, ${l}, ${n})`}return t}function Ge(t,n){return`rgba(${t==="structural"?"125, 211, 252":t==="contextual"?"45, 212, 191":t==="taxonomy"?"192, 132, 252":t==="workspace"?"251, 191, 36":"148, 163, 184"}, ${n})`}function mt(t,n){return!n.focusNodeId||t===n.focusNodeId?0:n.detailNodeIds.has(t)?1:n.relatedNodeIds.has(t)?2:3}function Lr({nodeId:t,attributes:n,node:a,focusNodeId:s,relatedNodeIds:c,detailNodeIds:o,hoveredNodeId:l,draggedNodeId:u}){const i=s===t,m=c.has(t),f=o.has(t),w=l===t,F=u===t,g=!s||m,v=n.color;return{...n,label:i||w||F||f?a.title:"",forceLabel:i||w||F||f,highlighted:i||w||F||f,color:g?v:zr(v,.34),size:F?n.size*2:i?n.size*1.8:w?n.size*1.35:f?n.size*1.16:m?n.size*1.06:n.size,zIndex:F?4:i?3:f||w?2:1}}function $r({attributes:t,edge:n,focusNodeId:a,detailNodeIds:s,relatedNodeIds:c,hoveredNodeId:o}){const l=!!a&&(n.source===a||n.target===a),u=!!o&&(n.source===o||n.target===o),i={focusNodeId:a,detailNodeIds:s,relatedNodeIds:c},m=a?Math.max(mt(n.source,i),mt(n.target,i)):0,f=l?Ge(n.family,.24):u?Ge(n.family,.14):a?m<=1?Ge(n.family,.09):m===2?Ge(n.family,.05):Ge(n.family,.016):Ge(n.family,.055);return{...t,color:f,size:l?t.size*1.18:u?t.size*1.08:t.size,zIndex:l?2:u?1:0}}function xt(t,n){const a=new Set,s=new Set;for(const c of t)c.source===n?a.add(c.target):c.target===n&&a.add(c.source);for(const c of t)c.source!==n&&a.has(c.source)&&s.add(c.target),c.target!==n&&a.has(c.target)&&s.add(c.source);return s.delete(n),a.forEach(c=>s.delete(c)),{firstRing:[...a].sort(),secondRing:[...s].sort()}}function bt(t,n,a){if(!a)return t.map(()=>-1);const s=new Set(t);if(!s.has(a))return t.map(()=>-1);const c=new Map;for(const u of n){if(!s.has(u.source)||!s.has(u.target))continue;const i=c.get(u.source)??new Set;i.add(u.target),c.set(u.source,i);const m=c.get(u.target)??new Set;m.add(u.source),c.set(u.target,m)}const o=new Map([[a,0]]);let l=[a];for(;l.length>0;){const u=[];for(const i of l){const m=o.get(i);for(const f of c.get(i)??[])o.has(f)||(o.set(f,m+1),u.push(f))}l=u}return t.map(u=>o.get(u)??-1)}function Yr({positions:t,focusNodeId:n,firstRingNodeIds:a,secondRingNodeIds:s,currentRatio:c}){const o=t.get(n);if(!o)return null;const l=[n,...a,...s].filter((A,Z,j)=>j.indexOf(A)===Z),u=l.map(A=>t.get(A)).filter(Boolean);if(u.length===0)return null;let i=Number.POSITIVE_INFINITY,m=Number.NEGATIVE_INFINITY,f=Number.POSITIVE_INFINITY,w=Number.NEGATIVE_INFINITY,F=Number.POSITIVE_INFINITY,g=Number.NEGATIVE_INFINITY,v=Number.POSITIVE_INFINITY,M=Number.NEGATIVE_INFINITY;for(const A of t.values())F=Math.min(F,A.x),g=Math.max(g,A.x),v=Math.min(v,A.y),M=Math.max(M,A.y);for(const A of u)i=Math.min(i,A.x),m=Math.max(m,A.x),f=Math.min(f,A.y),w=Math.max(w,A.y);const S=Math.max(m-i,w-f,.75),P=Math.max(g-F,M-v,S),G=u.length<=1?Ye(Math.max(c,.48),.38,.6):Ye(S/P*3.2,.42,Math.max(c,1.12));return{x:o.x,y:o.y,ratio:G,nodeIds:l}}function Ft({positions:t,currentRatio:n=1}){const a=[...t.values()];if(a.length===0)return{x:0,y:0,ratio:n};let s=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY;for(const m of a)s=Math.min(s,m.x),c=Math.max(c,m.x),o=Math.min(o,m.y),l=Math.max(l,m.y);const u=Math.max(c-s,l-o,1),i=Ye(u/6.4,.72,2.8);return{x:0,y:0,ratio:Math.max(n,i)}}function wt(t){const n=at.indexOf(t);return n>=0?n:at.length-1}function Hr(t){const n=$e.find(a=>a.kinds.some(s=>s===t))??$e[$e.length-1];return{laneId:n.id,laneLabel:n.label,laneIndex:$e.findIndex(a=>a.id===n.id)}}function Qe(){return{structural:0,contextual:0,taxonomy:0,workspace:0}}function Vr(t){const n=new Map;for(const a of t){const s=n.get(a.source)??new Set;s.add(a.target),n.set(a.source,s);const c=n.get(a.target)??new Set;c.add(a.source),n.set(a.target,c)}return n}function Br(t,n){return n.strength-t.strength||t.relationKind.localeCompare(n.relationKind)||t.label.localeCompare(n.label)||t.id.localeCompare(n.id)}function kt(t){const n=new Map;for(const a of t){const s=`${a.source}→${a.target}`,c=n.get(s)??[];c.push(a),n.set(s,c)}return Array.from(n.entries()).map(([a,s])=>{const c=[...s].sort(Br),o=c[0],l=c.length,u=Math.max(...c.map(i=>i.strength))*Math.min(1.45,1+(l-1)*.12);return{id:`${a}#${o.id}`,source:o.source,target:o.target,relationKind:o.relationKind,family:o.family,label:l>1?`${o.label} +${l-1}`:o.label,strength:u,directional:o.directional,structural:o.structural,parallelCount:l,data:c}}).sort((a,s)=>a.source.localeCompare(s.source)||a.target.localeCompare(s.target)||a.id.localeCompare(s.id))}function Xr(t,n){const a=kt(n),s=[...t].sort((o,l)=>{var u;return o.id.localeCompare(l.id)||((u=o.updatedAt)==null?void 0:u.localeCompare(l.updatedAt??""))||0}).map(o=>`${o.id}:${o.title}:${o.size}:${o.importance}:${o.updatedAt??""}`).join("|"),c=a.map(o=>`${o.source}:${o.target}:${o.parallelCount}:${o.label}:${o.strength.toFixed(3)}`).join("|");return`${t.length}/${a.length}/${s}::${c}`}function It(t,n){const a=[...t].sort((u,i)=>{const m=wt(u.entityKind)-wt(i.entityKind);return m!==0?m:i.importance-u.importance||u.title.localeCompare(i.title)}),s=new Map,c=a.map(u=>{const{laneId:i,laneIndex:m,laneLabel:f}=Hr(u.entityKind),w=s.get(m)??0;return s.set(m,w+1),{...u,layer:m,laneId:i,laneLabel:f,row:w}}),o=new Map(c.map(u=>[u.id,u])),l=n.map(u=>{const i=o.get(u.source),m=o.get(u.target),f=(i==null?void 0:i.layer)??0,w=(m==null?void 0:m.layer)??0;return{...u,secondary:w<=f||u.family!=="structural"&&u.family!=="taxonomy"}});return{nodes:c,edges:l}}function yt(t,n,a){const s=new Map(t.map(g=>[g.id,g])),c=a?s.get(a)??null:null;if(!c)return{generatedAt:new Date().toISOString(),focusNode:null,firstRingNodes:[],neighborhoodEdges:[],familyGroups:[],relationCounts:Qe(),secondRingCounts:Qe()};const o=n.filter(g=>g.source===c.id||g.target===c.id),l=Array.from(new Set(o.flatMap(g=>g.source===c.id?[g.target]:[g.source]))),u=l.map(g=>s.get(g)??null).filter(g=>!!g),i=new Map,m=Qe(),f=Qe(),w=Vr(n);for(const g of l){const v=w.get(g)??new Set;for(const M of v){if(M===c.id||l.includes(M))continue;const S=n.filter(P=>P.source===g&&P.target===M||P.target===g&&P.source===M);for(const P of S)f[P.family]+=1}}for(const g of o){const v=g.source===c.id?g.target:g.source,M=s.get(v);if(!M)continue;m[g.family]+=1;const S=i.get(g.relationKind);if(S){S.items.some(P=>P.id===M.id)||S.items.push(M);continue}i.set(g.relationKind,{relationKind:g.relationKind,family:g.family,label:ur[g.relationKind],items:[M]})}const F=new Map;for(const g of i.values()){const v=F.get(g.family);if(v){v.relations.push({...g,items:[...g.items].sort((M,S)=>M.title.localeCompare(S.title))}),v.itemCount+=g.items.length,v.relationCount+=1;continue}F.set(g.family,{family:g.family,label:dr[g.family],relationCount:1,itemCount:g.items.length,relations:[{...g,items:[...g.items].sort((M,S)=>M.title.localeCompare(S.title))}]})}return{generatedAt:new Date().toISOString(),focusNode:c,firstRingNodes:u.sort((g,v)=>g.title.localeCompare(v.title)),neighborhoodEdges:o,familyGroups:[...F.values()].map(g=>({...g,relations:g.relations.sort((v,M)=>v.label.localeCompare(M.label))})).sort((g,v)=>g.label.localeCompare(v.label)),relationCounts:m,secondRingCounts:f}}function Wr(t,n){return lr(t,n)}function Ur(t,n){if(!t)return new Set;const a=new Set([t]);for(const s of n)s.source===t?a.add(s.target):s.target===t&&a.add(s.source);return a}let ze=null;function qr(){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 vt(){typeof window>"u"||(delete window.__FORGE_KNOWLEDGE_GRAPH_DIAGNOSTICS__,delete window.__FORGE_KNOWLEDGE_GRAPH_TEST_API__)}function Qr(){if(ze!==null)return ze;if(typeof document>"u")return ze=!1,!1;const t=document.createElement("canvas");return ze=!!(t.getContext("webgl2")||t.getContext("webgl")||t.getContext("experimental-webgl")),ze}function Jr(t){if(!t||typeof window>"u")return"#c0c1ff";const n=getComputedStyle(document.documentElement).getPropertyValue(t).trim();return n?`rgb(${n})`:"#c0c1ff"}function Zr(t,n){if(t.startsWith("rgb(")&&t.endsWith(")"))return t.replace("rgb(","rgba(").replace(")",`, ${n})`);if(t.startsWith("#")){const a=t.slice(1),s=a.length===3?a.split("").map(u=>`${u}${u}`).join(""):a,c=parseInt(s.slice(0,2),16),o=parseInt(s.slice(2,4),16),l=parseInt(s.slice(4,6),16);return`rgba(${c}, ${o}, ${l}, ${n})`}return t}function Le(t,n){t.forEachNode(a=>{const s=t.getNodeAttributes(a);Number.isFinite(s.x)&&Number.isFinite(s.y)&&n.set(a,{x:s.x,y:s.y})})}function en(t,n,a){const s=new jr,c=[...t].sort((l,u)=>u.importance-l.importance||l.title.localeCompare(u.title)||l.id.localeCompare(u.id)),o=Tr({nodes:c,cache:a});return c.forEach(l=>{const u=o.get(l.id);s.addNode(l.id,{x:(u==null?void 0:u.x)??0,y:(u==null?void 0:u.y)??0,size:Math.max(2.5,l.size/14),color:Jr(l.accentToken),label:l.title,hidden:!1,forceLabel:!1,highlighted:!1,zIndex:0,data:l})}),n.forEach(l=>{!s.hasNode(l.source)||!s.hasNode(l.target)||s.addEdgeWithKey(l.id,l.source,l.target,{size:Math.max(.8,l.strength*1.6),color:l.family==="structural"?"rgba(125, 211, 252, 0.055)":l.family==="contextual"?"rgba(45, 212, 191, 0.055)":l.family==="taxonomy"?"rgba(192, 132, 252, 0.055)":l.family==="workspace"?"rgba(251, 191, 36, 0.055)":"rgba(148, 163, 184, 0.055)",label:l.label,hidden:!1,forceLabel:!1,zIndex:0,data:l})}),s}function Nt(t){if(t.order===0)return;let n=0,a=0,s=0;if(t.forEachNode(l=>{const u=t.getNodeAttributes(l);n+=u.x,a+=u.y,s+=1}),s===0)return;const c=n/s,o=a/s;Math.abs(c)<1e-4&&Math.abs(o)<1e-4||t.updateEachNodeAttributes((l,u)=>({...u,x:u.x-c,y:u.y-o}),{attributes:["x","y"]})}function St(t){const n=new Map;return t.forEachNode(a=>{const s=t.getNodeAttributes(a);n.set(a,{x:s.x,y:s.y})}),n}function Fe(t,n){return{nodes:t.nodes().map(a=>({id:a,...t.getNodeAttributes(a)})),edges:n}}function tn(t){if(t.nodes.length===0)return{minX:-1,maxX:1,minY:-1,maxY:1};let n=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,s=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY;for(const o of t.nodes)n=Math.min(n,o.x),a=Math.max(a,o.x),s=Math.min(s,o.y),c=Math.max(c,o.y);return{minX:n,maxX:a,minY:s,maxY:c}}function rn(t){const n=Ft({positions:new Map(t.nodes.map(a=>[a.id,{x:a.x,y:a.y}])),currentRatio:1});return{x:n.x,y:n.y,angle:0,ratio:n.ratio}}function nn({x:t,y:n}){const a=Array.from({length:t.length},(c,o)=>({x:t[o]??0,y:n[o]??0})),s=hr(a);return s.changed?{changed:!0,offsetX:s.offset.x,offsetY:s.offset.y,x:new Float32Array(s.positions.map(c=>c.x)),y:new Float32Array(s.positions.map(c=>c.y))}:{changed:!1,offsetX:0,offsetY:0,x:new Float32Array(t),y:new Float32Array(n)}}function Kt({node:t,snapshot:n,camera:a,width:s,height:c}){const o=tn(n),l=Math.max(1,o.maxX-o.minX),u=Math.max(1,o.maxY-o.minY),i=28,f=Math.min(Math.max(1,s-i*2)/l,Math.max(1,c-i*2)/u)/Math.max(a.ratio,.08);return{x:s/2+(t.x-a.x)*f,y:c/2-(t.y-a.y)*f,size:Math.max(4,t.size*f*.12)}}function an({datasetSignature:t,focusNodeId:n,primaryFocusedNodeId:a,draggedNodeId:s,graph:c,layoutGeneration:o,sigma:l,startupPhase:u,startupInvariantSatisfied:i,simulationPhase:m,focusSources:f,focusPressure:w,centroid:F,cameraTarget:g,latestSnapshotAt:v,latestSnapshotNodeCount:M}){const S=[],P={},G={};let A=null;c.forEachNode(k=>{S.push(k);const K=l.getNodeDisplayData(k),ee=c.getNodeAttributes(k),xe=l.graphToViewport({x:ee.x,y:ee.y});P[k]={x:xe.x,y:xe.y,size:(K==null?void 0:K.size)??ee.size},G[k]=Number((w[S.length-1]??0).toFixed(4)),k===a&&(A={x:ee.x,y:ee.y})});const Z=it(S.map(k=>{const K=c.getNodeAttributes(k);return{x:K.x,y:K.y}})),j=l.getCamera().getState(),H=ot({centroid:F,boundsCenter:Z,camera:j});window.__FORGE_KNOWLEDGE_GRAPH_DIAGNOSTICS__={datasetSignature:t,visibleNodeIds:S,visibleNodeCount:S.length,focusedNodeId:n,primaryFocusedNodeId:a,draggedNodeId:s,layoutGeneration:o,rendererMode:"sigma",startupPhase:u,startupInvariantSatisfied:i,simulationPhase:m,focusSources:f,focusPressureByNodeId:G,graphCentroid:F,boundsCenter:Z,focusedNodePosition:A,cameraTarget:g,cameraFollowError:g?{x:Number((j.x-g.x).toFixed(4)),y:Number((j.y-g.y).toFixed(4)),ratio:Number((j.ratio-g.ratio).toFixed(4))}:null,camera:j,nodeScreenPositions:P,centroidDistanceFromOrigin:H.centroidDistanceFromOrigin,boundsCenterDistanceFromOrigin:H.boundsCenterDistanceFromOrigin,cameraDistanceFromOrigin:H.cameraDistanceFromOrigin,cameraToCentroidDistance:H.cameraToCentroidDistance,latestSnapshotAt:v,latestSnapshotNodeCount:M}}function _t({datasetSignature:t,focusNodeId:n,primaryFocusedNodeId:a,draggedNodeId:s,layoutGeneration:c,camera:o,snapshot:l,width:u,height:i,startupPhase:m,startupInvariantSatisfied:f,simulationPhase:w,focusSources:F,focusPressure:g,centroid:v,cameraTarget:M,latestSnapshotAt:S,latestSnapshotNodeCount:P}){const G=l.nodes.map(K=>K.id),A={},Z={};let j=null;l.nodes.forEach((K,ee)=>{A[K.id]=Kt({node:K,snapshot:l,camera:o,width:u,height:i}),Z[K.id]=Number((g[ee]??0).toFixed(4)),K.id===a&&(j={x:K.x,y:K.y})});const H=it(l.nodes.map(K=>({x:K.x,y:K.y}))),k=ot({centroid:v,boundsCenter:H,camera:o});window.__FORGE_KNOWLEDGE_GRAPH_DIAGNOSTICS__={datasetSignature:t,visibleNodeIds:G,visibleNodeCount:G.length,focusedNodeId:n,primaryFocusedNodeId:a,draggedNodeId:s,layoutGeneration:c,rendererMode:"fallback",startupPhase:m,startupInvariantSatisfied:f,simulationPhase:w,focusSources:F,focusPressureByNodeId:Z,graphCentroid:v,boundsCenter:H,focusedNodePosition:j,cameraTarget:M,cameraFollowError:M?{x:Number((o.x-M.x).toFixed(4)),y:Number((o.y-M.y).toFixed(4)),ratio:Number((o.ratio-M.ratio).toFixed(4))}:null,camera:o,nodeScreenPositions:A,centroidDistanceFromOrigin:k.centroidDistanceFromOrigin,boundsCenterDistanceFromOrigin:k.boundsCenterDistanceFromOrigin,cameraDistanceFromOrigin:k.cameraDistanceFromOrigin,cameraToCentroidDistance:k.cameraToCentroidDistance,latestSnapshotAt:S,latestSnapshotNodeCount:P}}function Ct(t,n){if(!t)return!1;const a=t.clientWidth,s=t.clientHeight,c=t.getBoundingClientRect();return t.isConnected&&n.width>0&&n.height>0&&a>0&&s>0&&c.width>0&&c.height>0&&t.getClientRects().length>0}function sn({sigma:t,graph:n,viewportX:a,viewportY:s}){let c=null,o=Number.POSITIVE_INFINITY;return n.forEachNode(l=>{const u=n.getNodeAttributes(l),i=t.getNodeDisplayData(l);if(!i||u.hidden)return;const m=t.graphToViewport({x:u.x,y:u.y}),f=m.x-a,w=m.y-s,F=Math.hypot(f,w),g=Math.max(i.size*1.8,18);F<=g&&F<o&&(c=l,o=F)}),c}function ke(t,n){return`rgba(${t.family==="structural"?"125, 211, 252":t.family==="contextual"?"45, 212, 191":t.family==="taxonomy"?"192, 132, 252":t.family==="workspace"?"251, 191, 36":"148, 163, 184"}, ${n})`}const on=p.forwardRef(function({nodes:n,edges:a,focusNodeId:s,physicsSettings:c,onSelectNode:o},l){jt(),st(d=>d.knowledgeGraphDiagnostics.panelOpen);const u=p.useRef(null),i=p.useRef(null),m=p.useRef(null),f=p.useRef(null),w=p.useRef(new Map),F=p.useRef(new Map),g=p.useRef(new Map),v=p.useRef(o),M=p.useRef(s),S=p.useRef(null),P=p.useRef(0),G=p.useRef(null),A=p.useRef(0),Z=p.useRef(!0),j=p.useRef(null),H=p.useRef(0),k=p.useRef("global"),K=p.useRef(null),ee=p.useRef([]),xe=p.useRef(new Float32Array(0)),_e=p.useRef({x:0,y:0}),Y=p.useRef("boot"),Ie=p.useRef(!1),V=p.useRef(!1),z=p.useRef(!1),te=p.useRef(null),se=p.useRef(null),ve=p.useRef(0),be=p.useRef(0);p.useRef(0),p.useRef(Mt("/knowledge-graph"));const[re,ie]=p.useState(null),[ue,oe]=p.useState(null),[ce,B]=p.useState(null),[we,X]=p.useState({x:0,y:0,angle:0,ratio:1}),[b,W]=p.useState(null),[N,He]=p.useState({width:0,height:0}),je=Gt(),de=(d=f.current)=>Ft({positions:d?St(d):new Map,currentRatio:1}).ratio,Ke=(d=f.current)=>({x:.5,y:.5,angle:0,ratio:de(d)}),Oe=(d=f.current)=>({x:0,y:0,angle:0,ratio:de(d)}),Ae=()=>i.current?"sigma":"fallback",L=p.useMemo(()=>kt(a),[a]),ye=p.useMemo(()=>Xr(n,a),[a,n]),J=p.useMemo(()=>s?xt(L,s):null,[s,L]),he=p.useMemo(()=>s?new Set([s,...(J==null?void 0:J.firstRing)??[]]):new Set,[s,J]),pe=p.useMemo(()=>s?new Set([s,...(J==null?void 0:J.firstRing)??[],...(J==null?void 0:J.secondRing)??[]]):new Set,[s,J]),Ve=()=>Ct(u.current,N),ge=({resize:d=!1}={})=>{if(!i.current||!Ve())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}},Pe=()=>Date.now()<A.current,$=({level:d,eventKey:x,message:y,details:R,publishBackend:_=!1})=>{},tt=()=>i.current?{...i.current.getCamera().getState()}:{...we},Ne=({rendererMode:d})=>{if(!f.current||!S.current)return null;const x=f.current,y=x.nodes().map(C=>{const D=x.getNodeAttributes(C);return{id:C,x:D.x,y:D.y}}),R=pr(y),_=it(y),O=tt(),T=d==="sigma"?{...O,x:Number((O.x-.5).toFixed(4)),y:Number((O.y-.5).toFixed(4))}:O,I=ot({centroid:R,boundsCenter:_,camera:T});return{datasetSignature:S.current,route:"/knowledge-graph",rendererMode:d,startupPhase:Y.current,startupInvariantSatisfied:gr(I),visibleNodeCount:y.length,focusedNodeId:M.current,primaryFocusedNodeId:K.current,graphCentroid:R,boundsCenter:_,camera:O,cameraTarget:j.current?{x:j.current.x,y:j.current.y,ratio:j.current.ratio}:null,driftMetrics:I,latestSnapshotAt:te.current,lastVerifiedAt:new Date().toISOString()}},Be=(d,{mirrorToConsole:x=!1}={})=>{},Xe=({rendererMode:d,publishAnomaly:x})=>{},De=()=>{const d=i.current?Ke():Oe();if(i.current){i.current.getCamera().setState(d);return}X(d)},e=d=>{var _;if(!f.current)return!1;const x=Ne({rendererMode:Ae()});if(!x)return!1;const y=x.graphCentroid.x,R=x.graphCentroid.y;return Math.abs(y)<1e-4&&Math.abs(R)<1e-4?!1:(Nt(f.current),Le(f.current,w.current),(_=m.current)==null||_.postMessage({type:"recenter-graph",offsetX:y,offsetY:R}),W(Fe(f.current,L)),De(),Y.current="startup_corrected",$({level:"warning",eventKey:"startup_corrected",message:"Corrected the knowledge graph startup bias back to graph-space origin.",publishBackend:!0,details:{datasetSignature:S.current}}),!0)},h=({phase:d,allowCorrection:x,publishBackendOnFailure:y=!1})=>{if(!f.current||!S.current)return;Y.current=d;const R=i.current?"sigma":"fallback",_=Ne({rendererMode:R});if(!_)return;if(_.startupInvariantSatisfied){Y.current="startup_verified",Be({..._},{mirrorToConsole:!0}),$({level:"info",eventKey:"startup_verified",message:"Knowledge graph startup invariant passed.",details:{datasetSignature:_.datasetSignature,driftMetrics:_.driftMetrics}});return}if($({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}}),Ie.current||(Ie.current=!0,!e()))return;ge();const T=Ne({rendererMode:R});if(T){if(T.startupInvariantSatisfied){Y.current="startup_verified",Be({...T},{mirrorToConsole:!0}),$({level:"info",eventKey:"startup_verified_after_correction",message:"Knowledge graph startup invariant passed after correction.",details:{datasetSignature:T.datasetSignature,driftMetrics:T.driftMetrics}});return}$({level:"error",eventKey:"startup_correction_failed",message:"Knowledge graph startup correction did not restore the origin invariant.",publishBackend:!0,details:{datasetSignature:T.datasetSignature,driftMetrics:T.driftMetrics,centroid:T.graphCentroid,boundsCenter:T.boundsCenter,camera:T.camera}})}},E=()=>{var x,y,R,_;if(!S.current||!f.current)return;const d=Date.now();if(!(d-be.current<1500)){if(be.current=d,i.current){an({datasetSignature:S.current,focusNodeId:M.current,primaryFocusedNodeId:K.current,draggedNodeId:((x=G.current)==null?void 0:x.nodeId)??null,graph:f.current,layoutGeneration:P.current,sigma:i.current,startupPhase:Y.current,startupInvariantSatisfied:((y=Ne({rendererMode:"sigma"}))==null?void 0:y.startupInvariantSatisfied)??!1,simulationPhase:k.current,focusSources:ee.current,focusPressure:xe.current,centroid:_e.current,cameraTarget:j.current?{x:j.current.x,y:j.current.y,ratio:j.current.ratio}:null,latestSnapshotAt:te.current,latestSnapshotNodeCount:se.current});return}b&&_t({datasetSignature:S.current,focusNodeId:M.current,primaryFocusedNodeId:K.current,draggedNodeId:((R=G.current)==null?void 0:R.nodeId)??null,layoutGeneration:P.current,camera:we,snapshot:b,width:N.width,height:N.height,startupPhase:Y.current,startupInvariantSatisfied:((_=Ne({rendererMode:"fallback"}))==null?void 0:_.startupInvariantSatisfied)??!1,simulationPhase:k.current,focusSources:ee.current,focusPressure:xe.current,centroid:_e.current,cameraTarget:j.current?{x:j.current.x,y:j.current.y,ratio:j.current.ratio}:null,latestSnapshotAt:te.current,latestSnapshotNodeCount:se.current})}},Ee=()=>{if(!f.current||!M.current){j.current=null;return}const d=f.current;if(!d.hasNode(M.current)){j.current=null;return}const x=St(d),y=xt(L,M.current),R=i.current?i.current.getCamera().getState().ratio:we.ratio,_=Yr({positions:x,focusNodeId:M.current,firstRingNodeIds:y.firstRing,secondRingNodeIds:y.secondRing,currentRatio:R}),O=i.current&&_?Pr({positions:x,point:{x:_.x,y:_.y}}):null;j.current=_?{x:(O==null?void 0:O.x)??_.x,y:(O==null?void 0:O.y)??_.y,angle:0,ratio:_.ratio,nodeIds:_.nodeIds}:null},We=(d=220)=>{if(!j.current)return;const x=j.current;if(i.current){const y=i.current.getCamera(),R=y.getState(),_=Date.now()<H.current;y.animate({x:x.x,y:x.y,ratio:_?R.ratio:x.ratio,angle:0},{duration:d});return}X(y=>({...y,x:x.x,y:x.y,ratio:Date.now()<H.current?y.ratio:x.ratio}))};p.useEffect(()=>{v.current=o},[o]),p.useEffect(()=>{M.current=s,j.current=null},[s]),p.useEffect(()=>{vt()},[je]),p.useEffect(()=>{if(!(!qr()||typeof window>"u"))return window.__FORGE_KNOWLEDGE_GRAPH_TEST_API__={selectNode:d=>{var y;const x=d?g.current.get(d)??((y=f.current)!=null&&y.hasNode(d)?f.current.getNodeAttribute(d,"data")??null:null):null;v.current(x)},moveNodeBy:(d,x,y)=>{var T,I;if(!((T=f.current)!=null&&T.hasNode(d)))return;const R=f.current.getNodeAttributes(d),_=R.x+x,O=R.y+y;f.current.mergeNodeAttributes(d,{x:_,y:O}),w.current.set(d,{x:_,y:O}),(I=m.current)==null||I.postMessage({type:"nudge-node",nodeId:d,x:_,y:O}),ge(),!i.current&&f.current&&W(Fe(f.current,L))},nudgeCameraBy:(d,x)=>{if(i.current){const y=i.current.getCamera(),R=y.getState();y.animate({x:R.x+d,y:R.y+x,ratio:R.ratio,angle:R.angle},{duration:140});return}X(y=>({...y,x:y.x+d,y:y.y+x}))}},()=>{delete window.__FORGE_KNOWLEDGE_GRAPH_TEST_API__}},[L]),p.useEffect(()=>{if(!u.current||typeof ResizeObserver>"u")return;const d=()=>{u.current&&He({width:u.current.clientWidth,height:u.current.clientHeight})};d();const x=new ResizeObserver(()=>{d()});return x.observe(u.current),()=>x.disconnect()},[]),p.useImperativeHandle(l,()=>({zoomIn:()=>{if(H.current=Date.now()+1200,i.current){i.current.getCamera().animatedZoom({factor:1.25,duration:160});return}X(d=>({...d,ratio:Math.max(.08,d.ratio*.82)}))},zoomOut:()=>{if(H.current=Date.now()+1200,i.current){i.current.getCamera().animatedUnzoom({factor:1.25,duration:160});return}X(d=>({...d,ratio:Math.min(4,d.ratio*1.22)}))},fit:()=>{if(j.current=null,i.current){i.current.getCamera().animate(Ke(),{duration:220});return}b&&X(rn(b))},recenterOnFocus:()=>{Ee(),j.current&&We(220)}}),[b,L]),p.useEffect(()=>()=>{var d,x,y;f.current&&Le(f.current,w.current),i.current&&S.current&&F.current.set(S.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,vt()},[je]),p.useEffect(()=>{var O,T;if(!u.current||!Ct(u.current,N))return;if(S.current===ye&&f.current!==null){ge({resize:!0}),E();return}Y.current="boot",Ie.current=!1,V.current=!1,z.current=!1,te.current=null,se.current=null,ve.current=0,j.current=null,$({level:"info",eventKey:"graph_boot",message:"Bootstrapping a fresh knowledge graph dataset.",details:{nodeCount:n.length,edgeCount:L.length}}),f.current&&Le(f.current,w.current),i.current&&S.current&&F.current.set(S.current,i.current.getCamera().getState());const x=en(n,L,w.current);if(Nt(x),Le(x,w.current),f.current=x,g.current=new Map(n.map(I=>[I.id,I])),S.current=ye,P.current+=1,W(Fe(x,L)),Y.current="graph_built",$({level:"info",eventKey:"graph_built",message:"Built and centered the knowledge graph structure.",details:{layoutGeneration:P.current}}),!Qr())(O=i.current)==null||O.kill(),i.current=null,B("WebGL is unavailable in this browser context."),X(Oe(x)),h({phase:"graph_built",allowCorrection:!0,publishBackendOnFailure:!0});else try{if(i.current)i.current.setGraph(x),ge();else{i.current=new Rr(x,u.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}),$({level:"info",eventKey:"sigma_initialized",message:"Initialized Sigma for the knowledge graph.",details:{datasetSignature:ye}}),i.current.on("clickNode",({node:C})=>{if(Pe())return;const D=g.current.get(C)??null;v.current(D)}),i.current.on("clickStage",({event:C})=>{if(Pe())return;if(!i.current||!f.current){v.current(null);return}const D=sn({sigma:i.current,graph:f.current,viewportX:C.x,viewportY:C.y});if(D){v.current(g.current.get(D)??null);return}v.current(null)}),i.current.on("downNode",({node:C,event:D,preventSigmaDefault:fe})=>{var me,U;if(!i.current||!((me=f.current)!=null&&me.hasNode(C)))return;fe();const Me=i.current.viewportToGraph({x:D.x,y:D.y}),ne=f.current.getNodeAttributes(C);G.current={nodeId:C,offsetX:ne.x-Me.x,offsetY:ne.y-Me.y,startViewportX:D.x,startViewportY:D.y,currentX:ne.x,currentY:ne.y,moved:!1},Z.current=i.current.getSetting("enableCameraPanning")??!0,i.current.setSetting("enableCameraPanning",!1),oe(C),ie(C),$({level:"debug",eventKey:"drag_start",message:"Started dragging a knowledge graph node.",details:{nodeId:C}}),(U=m.current)==null||U.postMessage({type:"drag-start",nodeId:C})}),i.current.on("moveBody",({event:C,preventSigmaDefault:D})=>{var U;if(!i.current||!f.current||!G.current)return;D();const fe=i.current.viewportToGraph({x:C.x,y:C.y});Math.hypot(C.x-G.current.startViewportX,C.y-G.current.startViewportY)>3&&(G.current={...G.current,moved:!0});const ne=fe.x+G.current.offsetX,me=fe.y+G.current.offsetY;G.current={...G.current,currentX:ne,currentY:me},f.current.mergeNodeAttributes(G.current.nodeId,{x:ne,y:me}),w.current.set(G.current.nodeId,{x:ne,y:me}),(U=m.current)==null||U.postMessage({type:"drag-move",nodeId:G.current.nodeId,x:ne,y:me}),ge()});const I=()=>{var fe;if(!i.current||!G.current){G.current=null,oe(null);return}const C=G.current.nodeId,D=G.current.moved;i.current.setSetting("enableCameraPanning",Z.current),(fe=m.current)==null||fe.postMessage({type:"drag-end",nodeId:C}),$({level:"debug",eventKey:"drag_end",message:"Released a dragged knowledge graph node.",details:{nodeId:C,moved:D}}),G.current=null,oe(null),D&&(A.current=Date.now()+220,v.current(g.current.get(C)??null))};i.current.on("upNode",I),i.current.on("upStage",I),i.current.on("leaveStage",I),i.current.on("enterNode",({node:C})=>{ie(C)}),i.current.on("leaveNode",()=>{ie(null)}),i.current.on("afterRender",()=>{V.current||(V.current=!0,Y.current="first_frame",$({level:"info",eventKey:"first_frame",message:"Knowledge graph rendered its first frame.",details:{datasetSignature:S.current}}),h({phase:"first_frame",allowCorrection:!0,publishBackendOnFailure:!0}),Xe({rendererMode:"sigma",publishAnomaly:!0})),E()})}B(null),W(Fe(x,L)),i.current.getCamera().setState(Ke(x))}catch(I){(T=i.current)==null||T.kill(),i.current=null,B(I instanceof Error?I.message:"Graph renderer unavailable."),W(Fe(x,L)),X(Oe(x)),$({level:"error",eventKey:"sigma_fallback",message:"Fell back from Sigma to the SVG renderer.",publishBackend:!0,details:{reason:I instanceof Error?I.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=I=>{var me;if(!f.current)return;const C=I.data;if(C.type==="stats"){k.current=C.phase,K.current=C.primaryFocusedNodeId,ee.current=C.focusSources,xe.current=C.focusPressure,_e.current=C.centroid,z.current||(z.current=!0,Y.current="worker_started",$({level:"info",eventKey:"worker_started",message:"Knowledge graph worker reported its first simulation stats.",details:{datasetSignature:S.current,phase:C.phase}}),h({phase:"worker_started",allowCorrection:!0,publishBackendOnFailure:!0}));return}const D=f.current;let fe=C.x,Me=C.y;if(Y.current!=="startup_verified"){const U=nn({x:C.x,y:C.y});U.changed&&(fe=U.x,Me=U.y,(me=m.current)==null||me.postMessage({type:"recenter-graph",offsetX:U.offsetX,offsetY:U.offsetY}),De(),$({level:"warning",eventKey:"worker_startup_recenter",message:"Recentering worker positions during startup because the graph drifted away from origin.",details:{datasetSignature:S.current,startupPhase:Y.current,offsetX:U.offsetX,offsetY:U.offsetY}}))}let ne=0;if(D.updateEachNodeAttributes((U,Xt)=>({...Xt,x:fe[ne],y:Me[ne++]}),{attributes:["x","y"]}),G.current&&D.hasNode(G.current.nodeId)){const U=G.current.nodeId;D.mergeNodeAttributes(U,{x:G.current.currentX,y:G.current.currentY})}Le(D,w.current),i.current?ge():W(Fe(D,L))});const y=x.nodes(),R=new Map(y.map((I,C)=>[I,C])),_=bt(y,L,s);m.current.postMessage({type:"init-graph",nodes:y.map(I=>{const C=x.getNodeAttributes(I);return{id:I,x:C.x,y:C.y,size:C.size,mass:Math.max(1,C.data.importance/42),importance:C.data.importance}}),edges:L.filter(I=>R.has(I.source)&&R.has(I.target)).map(I=>({source:R.get(I.source),target:R.get(I.target),weight:Math.max(.6,I.strength)})),focusNodeId:s,hopLevels:_,physics:c}),$({level:"debug",eventKey:"worker_init",message:"Posted the graph payload to the layout worker.",details:{nodeCount:y.length,edgeCount:L.length}})},[N.height,N.width,ye,s,n,c,L]),p.useEffect(()=>{if(!m.current||!f.current)return;const d=bt(f.current.nodes(),L,s);m.current.postMessage({type:"set-focus",focusNodeId:s,hopLevels:d}),s||(j.current=null)},[s,L]),p.useEffect(()=>{m.current&&m.current.postMessage({type:"update-physics",physics:c})},[c]),p.useEffect(()=>{},[ye,je]),p.useEffect(()=>{!i.current||!f.current||(i.current.setSetting("nodeReducer",(d,x)=>{var R;const y=(R=f.current)==null?void 0:R.getNodeAttribute(d,"data");return Lr({nodeId:d,attributes:x,node:y,focusNodeId:s,relatedNodeIds:pe,detailNodeIds:he,hoveredNodeId:re,draggedNodeId:ue})}),i.current.setSetting("edgeReducer",(d,x)=>{var R;const y=(R=f.current)==null?void 0:R.getEdgeAttribute(d,"data");return $r({attributes:x,edge:y,focusNodeId:s,detailNodeIds:he,relatedNodeIds:pe,hoveredNodeId:re})}),ge())},[he,ue,s,re,pe]),p.useEffect(()=>{var d,x;!b||!S.current||N.width<=0||N.height<=0||!ce&&i.current||(V.current||(V.current=!0,Y.current="first_frame",$({level:"info",eventKey:"fallback_first_frame",message:"Knowledge graph rendered its first fallback frame.",details:{datasetSignature:S.current}}),h({phase:"first_frame",allowCorrection:!0,publishBackendOnFailure:!0})),_t({datasetSignature:S.current,focusNodeId:s,primaryFocusedNodeId:K.current,draggedNodeId:((d=G.current)==null?void 0:d.nodeId)??null,layoutGeneration:P.current,camera:we,snapshot:b,width:N.width,height:N.height,startupPhase:Y.current,startupInvariantSatisfied:((x=Ne({rendererMode:"fallback"}))==null?void 0:x.startupInvariantSatisfied)??!1,simulationPhase:k.current,focusSources:ee.current,focusPressure:xe.current,centroid:_e.current,cameraTarget:j.current?{x:j.current.x,y:j.current.y,ratio:j.current.ratio}:null,latestSnapshotAt:te.current,latestSnapshotNodeCount:se.current}))},[N.height,N.width,we,ce,b,s]);const Te=p.useMemo(()=>!b||N.width<=0||N.height<=0?[]:b.nodes.map(d=>{const x=Kt({node:d,snapshot:b,camera:we,width:N.width,height:N.height});return{...d,viewportX:x.x,viewportY:x.y,viewportSize:x.size}}),[N.height,N.width,we,b]),Ue=p.useMemo(()=>new Map(Te.map(d=>[d.id,d])),[Te]);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:u,className:"h-full w-full touch-none","aria-label":"Knowledge graph canvas",children:ce&&b?r.jsxs("svg",{className:"h-full w-full",viewBox:`0 0 ${Math.max(N.width,1)} ${Math.max(N.height,1)}`,"aria-hidden":"true",children:[r.jsx("title",{children:"Knowledge graph fallback canvas"}),r.jsx("rect",{x:"0",y:"0",width:Math.max(N.width,1),height:Math.max(N.height,1),fill:"transparent",onClick:()=>v.current(null)}),b.edges.map(d=>{const x=Ue.get(d.source),y=Ue.get(d.target);if(!x||!y)return null;const R=!!s&&(d.source===s||d.target===s),_=!!re&&(d.source===re||d.target===re),O=s?d.source===s?0:he.has(d.source)?1:pe.has(d.source)?2:3:0,T=s?d.target===s?0:he.has(d.target)?1:pe.has(d.target)?2:3:0,I=s?Math.max(O,T):0;return r.jsx("line",{x1:x.viewportX,y1:x.viewportY,x2:y.viewportX,y2:y.viewportY,stroke:R?ke(d,.24):_?ke(d,.14):s?I<=1?ke(d,.09):I===2?ke(d,.05):ke(d,.016):ke(d,.055),strokeWidth:R?1.7:_?1.3:.95},d.id)}),Te.map(d=>{const x=s===d.id,y=pe.has(d.id),R=he.has(d.id),_=re===d.id,O=!s||y;return r.jsxs("g",{transform:`translate(${d.viewportX}, ${d.viewportY})`,onMouseEnter:()=>ie(d.id),onMouseLeave:()=>ie(null),onClick:T=>{T.stopPropagation();const I=g.current.get(d.id)??null;v.current(I)},style:{cursor:"pointer"},children:[r.jsx("circle",{r:x?d.viewportSize*1.9:_?d.viewportSize*1.3:R?d.viewportSize*1.15:y?d.viewportSize*1.05:d.viewportSize,fill:O?d.color:Zr(d.color,.3),stroke:x?"rgba(255,255,255,0.78)":"rgba(255,255,255,0.12)",strokeWidth:x?2:1}),(x||_||R)&&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})})}),cn=300,ln=152;function Ot(t,n){return t?Ur(t,n):new Set}function un(t,n,a){const s=It(t,n),c=Ot(a,n);return s.nodes.map(o=>{const l=o.id===a,u=!a||c.has(o.id);return{id:o.id,draggable:!1,selectable:!1,position:{x:72+o.layer*cn,y:88+o.row*ln},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:l?"rgba(255,255,255,0.32)":"rgba(255,255,255,0.1)",background:l?"rgba(11,17,30,0.98)":"rgba(8,14,26,0.92)",opacity:u?1:.28},children:[r.jsx("div",{className:"flex flex-wrap items-center gap-2",children:r.jsx(et,{kind:o.entityKind,label:o.entityKind.replaceAll("_"," "),compact:!0,gradient:l})}),r.jsx("div",{className:"mt-3",children:r.jsx(fr,{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 dn(t,n,a,s){const c=It(t,n),o=Ot(a,n);return c.edges.filter(l=>s||!l.secondary).map(l=>{const u=!a||o.has(l.source)||o.has(l.target);return{id:l.id,source:l.source,target:l.target,animated:!l.secondary&&l.family==="structural"&&u,markerEnd:{type:kr.ArrowClosed,color:l.secondary?"rgba(255,255,255,0.16)":"rgba(232,242,255,0.42)"},style:{opacity:u?1:.18,stroke:l.secondary?"rgba(255,255,255,0.16)":l.family==="taxonomy"?"rgba(162,245,189,0.34)":l.family==="structural"?"rgba(232,242,255,0.4)":"rgba(192,193,255,0.24)",strokeDasharray:l.secondary?"8 6":void 0,strokeWidth:l.secondary?1:l.family==="structural"?1.7:1.2}}})}function hn({nodes:t,edges:n,focusNodeId:a,showSecondaryEdges:s,onSelectNode:c,onOpenNode:o,onNavigateNode:l,isMobile:u}){const i=p.useMemo(()=>un(t,n,a),[n,a,t]),m=p.useMemo(()=>dn(t,n,a,s),[n,a,t,s]),f=p.useMemo(()=>new Map(t.map(w=>[w.id,w])),[t]);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:$e.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(Mr,{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,F)=>{const g=f.get(F.id);g&&c(g)},onNodeDoubleClick:(w,F)=>{const g=f.get(F.id);if(g){if(u){o(g);return}l(g)}},children:[r.jsx(Gr,{showInteractive:!1}),r.jsx(Fr,{gap:28,size:1,color:"rgba(255,255,255,0.05)"})]},`${a??"all"}-${s?"all":"primary"}`)]})}const At=6,Pt=5,Dt=.92,Tt=5,zt=.15,Lt=2.4,$t=2,Yt=.8,Ht=3,le={focusRepulsion:2.25,focusDiffusion:1.95,focusSpringReductionMax:.34,focusSpringReductionDiffusion:1.85,edgeSpringStrength:1,gravityStrength:1,focusShellSpacing:1};function Re(t,n,a){return Math.min(Math.max(t,n),a)}function Vt(t){return{focusRepulsion:Re((t==null?void 0:t.focusRepulsion)??le.focusRepulsion,.6,At),focusDiffusion:Re((t==null?void 0:t.focusDiffusion)??le.focusDiffusion,.6,Pt),focusSpringReductionMax:Re((t==null?void 0:t.focusSpringReductionMax)??le.focusSpringReductionMax,0,Dt),focusSpringReductionDiffusion:Re((t==null?void 0:t.focusSpringReductionDiffusion)??le.focusSpringReductionDiffusion,.6,Tt),edgeSpringStrength:Re((t==null?void 0:t.edgeSpringStrength)??le.edgeSpringStrength,zt,Lt),gravityStrength:Re((t==null?void 0:t.gravityStrength)??le.gravityStrength,0,$t),focusShellSpacing:Re((t==null?void 0:t.focusShellSpacing)??le.focusShellSpacing,Yt,Ht)}}function pn({isMobile:t,currentFocusNodeId:n,nextNodeId:a}){return a?t?n===a?{nextFocusNodeId:a,nextMobileSheetOpen:!0,shouldUpdateFocus:!1}:{nextFocusNodeId:a,nextMobileSheetOpen:!1,shouldUpdateFocus:!0}:{nextFocusNodeId:a,nextMobileSheetOpen:!1,shouldUpdateFocus:n!==a}:{nextFocusNodeId:null,nextMobileSheetOpen:!1,shouldUpdateFocus:n!==null}}const Et="__clear__";function gn({isMobile:t,focusNodeId:n,shellOverlayFocusNodeId:a,lastRequestedKey:s}){const c=t?null:n,o=c??Et;return o===(a??Et)?{action:"none",nextRequestedKey:o}:s===o?{action:"none",nextRequestedKey:o}:{action:c?"set":"clear",nextRequestedKey:o}}const Je=2e3,rt=40,nt=2e3,Bt="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 Ze(t,n){return Array.from(new Set(t.getAll(n).flatMap(a=>a.split(",")).map(a=>a.trim()).filter(Boolean)))}function Q(t,n,a){t.delete(n),a.forEach(s=>t.append(n,s))}function mn(t){switch(t.entityType){case"workbench_flow":case"workbench_surface":case"wiki_space":return null;default:return Cr(t.entityType,t.entityId)}}function ae(t){return t?t.slice(0,10):""}function xn(){if(typeof window>"u")return le;try{const t=window.localStorage.getItem(Bt);return t?Vt(JSON.parse(t)):le}catch{return le}}function bn(t,n,a,s,c){const o=t.find(l=>l.id===n);return o||(!n||!a?null:{id:n,displayName:a,kind:s??"human",accentColor:c??"",handle:a.toLowerCase().replace(/\s+/g,"-"),description:"",createdAt:"",updatedAt:""})}function wn({entityKinds:t,relationKinds:n,tags:a,owners:s}){return[...t.map(c=>`entity:${c}`),...n.map(c=>`relation:${c}`),...a.map(c=>`tag:${c}`),...s.map(c=>`owner:${c}`)]}function Rt(t){const n=[],a=[],s=[],c=[];for(const o of t){const[l,...u]=o.split(":"),i=u.join(":").trim();i&&(l==="entity"?n.push(i):l==="relation"?a.push(i):l==="tag"?s.push(i):l==="owner"&&c.push(i))}return{entityKinds:n,relationKinds:a,tags:s,owners:c}}class yn extends p.Component{constructor(n){super(n),this.state={error:null}}static getDerivedStateFromError(n){return{error:n}}componentDidUpdate(n){n.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 Gn(){var Xe,De;const t=mr(),n=jt();st(e=>e.knowledgeGraphDiagnostics);const a=st(e=>{var h,E;return((E=(h=e.shell.knowledgeGraphOverlayFocus)==null?void 0:h.focusNode)==null?void 0:E.id)??null}),s=Wt(),[c,o]=Ut(),l=p.useRef(null),u=p.useRef(null),i=p.useRef(null),m=p.useRef(null),f=p.useRef(null);p.useRef(Mt("/knowledge-graph"));const[w,F]=p.useState(()=>typeof window<"u"?window.matchMedia("(max-width: 1023px)").matches:!1),[g,v]=p.useState(!1),[M,S]=p.useState(!1),[P,G]=p.useState(!1),[A,Z]=p.useState(!1),[j,H]=p.useState(""),[k,K]=p.useState(()=>xn()),xe=Gt(),_e=({level:e,eventKey:h,message:E,details:Ee,publishBackend:We=!1})=>{};p.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const e=window.matchMedia("(max-width: 1023px)"),h=E=>F(E?E.matches:e.matches);return h(),typeof e.addEventListener=="function"?(e.addEventListener("change",h),()=>e.removeEventListener("change",h)):(e.addListener(h),()=>e.removeListener(h))},[]),p.useEffect(()=>{w||(v(!1),S(!1),u.current=null)},[w]),p.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(Bt,JSON.stringify(k))},[k]);const Y=c.toString(),Ie=p.useMemo(()=>{const e=new URLSearchParams(Y),h=e.get("view")==="hierarchy"?"hierarchy":"graph",E=xr(e.get("focus")),Ee=E?Wr(E.entityType,E.entityId):null,We=Ze(e,"entityKind"),Te=Ze(e,"relationKind"),Ue=Ze(e,"tag"),d=Ze(e,"owner"),x=e.get("q")??"",y=e.get("updatedFrom"),R=e.get("updatedTo"),_=Number(e.get("limit")??Je),O=Number.isFinite(_)?Math.max(rt,Math.min(nt,_)):Je;return{selectedView:h,focusNodeId:Ee,selectedKinds:We,selectedRelations:Te,selectedTags:Ue,selectedOwners:d,showHierarchyCrossLinks:e.get("cross")==="1",queryText:x,updatedFrom:y,updatedTo:R,maxNodes:O}},[Y]),{selectedView:V,focusNodeId:z,selectedKinds:te,selectedRelations:se,selectedTags:ve,selectedOwners:be,showHierarchyCrossLinks:re,queryText:ie,updatedFrom:ue,updatedTo:oe,maxNodes:ce}=Ie;p.useEffect(()=>{H(ie)},[ie]);const B=p.useMemo(()=>({q:ie.trim()||null,entityKinds:[...te].sort(),relationKinds:[...se].sort(),tags:[...ve].sort(),owners:[...be].sort(),updatedFrom:ue,updatedTo:oe,limit:ce,focusNodeId:null}),[ce,ie,te,be,se,ve,ue,oe]),we=p.useMemo(()=>["forge-knowledge-graph",...t.selectedUserIds,JSON.stringify(B)],[B,t.selectedUserIds]),X=cr({queryKey:we,queryFn:()=>Er(t.selectedUserIds,B),placeholderData:e=>e,staleTime:6e4,refetchOnWindowFocus:!1}),b=X.data;p.useEffect(()=>{_e({level:"info",eventKey:"route_arrival",message:"Arrived on the Knowledge Graph page.",details:{search:c.toString()}})},[]),p.useEffect(()=>{if(!X.isSuccess||!b)return;const e=JSON.stringify({q:B.q,entityKinds:B.entityKinds,relationKinds:B.relationKinds,tags:B.tags,owners:B.owners,updatedFrom:B.updatedFrom,updatedTo:B.updatedTo,limit:B.limit,nodeCount:b.counts.nodeCount,edgeCount:b.counts.edgeCount,filteredNodeCount:b.counts.filteredNodeCount,limited:b.counts.limited});f.current!==e&&(f.current=e,_e({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,X.isSuccess,B]),p.useEffect(()=>{!b||!z||b.nodes.some(e=>e.id===z)||(o(e=>{const h=new URLSearchParams(e);return h.delete("focus"),h},{replace:!0}),v(!1),u.current=null)},[z,b,o]),p.useEffect(()=>{if(w){if(!z){u.current=null,v(!1);return}u.current===z&&!g&&(v(!0),u.current=null)}},[z,w,g]);const W=p.useMemo(()=>!b||!z?yt([],[],null):yt(b.nodes,b.edges,z),[z,b]);p.useEffect(()=>{var h;const e=gn({isMobile:w,focusNodeId:((h=W.focusNode)==null?void 0:h.id)??null,shellOverlayFocusNodeId:a,lastRequestedKey:m.current});if(m.current=e.nextRequestedKey,e.action!=="none"){if(e.action==="clear"){n(dt());return}n(br(W))}},[n,W,w,a]),p.useEffect(()=>{{i.current=null;return}},[xe,z,W,w]),p.useEffect(()=>()=>{n(dt())},[n]),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:g,focusNodeId:z,selectedView:V,selectNodeById:e=>{if(!b)return;const h=e?b.nodes.find(E=>E.id===e)??null:null;Ce(h)},activateFocusedNode:()=>{if(!z||!b)return;const e=b.nodes.find(h=>h.id===z)??null;e&&Ce(e)}},()=>{delete window.__FORGE_KNOWLEDGE_GRAPH_PAGE_TEST__}}},[z,w,g,V]);const N=e=>{o(h=>{const E=new URLSearchParams(h);return e(E),E},{replace:!0})},He=e=>{const h=e.trim();H(e),N(E=>{h.length>0?E.set("q",h):E.delete("q")})},Ce=e=>{const h=pn({isMobile:w,currentFocusNodeId:z,nextNodeId:(e==null?void 0:e.id)??null});u.current=w&&h.nextMobileSheetOpen?(e==null?void 0:e.id)??null:null,v(h.nextMobileSheetOpen),h.shouldUpdateFocus&&(N(E=>{if(!e){E.delete("focus");return}E.set("focus",gt(e.entityType,e.entityId))}),w&&S(!1))},je=e=>{e.href&&s(e.href)},de=(e,h)=>{K(E=>Vt({...E,[e]:h}))},Ke=e=>{const h=mn(e);h&&s(h)},Oe=e=>{N(h=>{h.set("view","hierarchy"),h.set("focus",gt(e.entityType,e.entityId))})},Ae=()=>{N(e=>{["q","entityKind","relationKind","tag","owner","updatedFrom","updatedTo","focus"].forEach(h=>e.delete(h)),e.set("limit",String(Je))}),G(!1)};if(X.isLoading&&!b)return r.jsx(wr,{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(X.isError)return r.jsx(yr,{eyebrow:"Knowledge Graph",error:X.error,onRetry:()=>void X.refetch()});if(!b)return null;const L=new Map(b.facets.entityKinds.map(e=>[e.value,e])),ye=at.map(e=>{const h=vr(e),E=L.get(e),Ee=(E==null?void 0:E.count)??0;return{value:e,label:(E==null?void 0:E.label)??h.label,description:Ee===1?"1 node":`${Ee} nodes`,kind:e}}),J=b.facets.relationKinds.map(e=>({value:e.value,label:e.label,description:`${e.count} links`})),he=b.facets.tags.map(e=>({value:e.id,label:e.label,description:`${e.count} linked nodes`,badge:r.jsx(et,{kind:"tag",label:e.label,compact:!0,gradient:!1}),menuBadge:r.jsx(et,{kind:"tag",label:e.label,compact:!0,gradient:!1})})),pe=b.facets.owners.map(e=>{const h=bn(t.snapshot.users,e.userId,e.displayName,e.kind,e.accentColor);return{value:e.userId,label:e.displayName,description:`${e.count} nodes`,badge:r.jsx(ht,{user:h,compact:!0}),menuBadge:r.jsx(ht,{user:h,compact:!0})}}),Ve=[...ye.map(e=>({id:`entity:${e.value}`,label:e.label,description:e.description,searchText:`entity kind ${e.label}`,badge:r.jsx(et,{kind:e.kind??"note",label:e.label,compact:!0,gradient:!1})})),...J.map(e=>({id:`relation:${e.value}`,label:e.label,description:e.description,searchText:`relation kind ${e.label}`})),...he.map(e=>({id:`tag:${e.value}`,label:e.label,description:e.description,searchText:`tag ${e.label}`,badge:e.menuBadge??e.badge})),...pe.map(e=>({id:`owner:${e.value}`,label:e.label,description:e.description,searchText:`owner ${e.label}`,badge:e.menuBadge??e.badge}))],ge=wn({entityKinds:te,relationKinds:se,tags:ve,owners:be}),Pe=b.counts.limited?`${b.counts.nodeCount}/${b.counts.filteredNodeCount} nodes`:`${b.counts.nodeCount}n · ${b.counts.edgeCount}e`,$=b.counts.limited?`${b.counts.nodeCount} visible nodes from ${b.counts.filteredNodeCount} filtered matches`:`${b.counts.nodeCount} nodes and ${b.counts.edgeCount} edges`,tt=ie.trim().length>0||te.length>0||se.length>0||ve.length>0||be.length>0||!!ue||!!oe||ce!==Je,Ne=!w,Be=`${V}:${b.nodes.map(e=>e.id).join("|")}::${b.edges.map(e=>e.id).join("|")}`;return r.jsxs("div",{className:"-mx-4 -mb-2.5 h-[calc(100dvh-var(--forge-mobile-nav-clearance)-5.25rem)] overflow-hidden lg:-mx-6 lg:-mb-3 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(Nr,{metrics:t.snapshot.metrics})}),r.jsx(yn,{resetKey:Be,fallback:e=>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:e.message})]}),r.jsxs("div",{className:"flex flex-wrap justify-center gap-2",children:[r.jsxs(q,{variant:"primary",size:"sm",onClick:()=>N(h=>{h.set("view","hierarchy")}),children:[r.jsx(Qt,{className:"size-4"}),"Open hierarchy"]}),r.jsx(q,{variant:"secondary",size:"sm",onClick:Ae,children:"Reset graph filters"})]})]})}),children:V==="graph"?r.jsx(on,{ref:l,nodes:b.nodes,edges:b.edges,focusNodeId:z,physicsSettings:k,onSelectNode:Ce}):r.jsx("div",{className:"h-full overflow-y-auto px-4 py-4 lg:px-6",children:r.jsx(hn,{nodes:b.nodes,edges:b.edges,focusNodeId:z,showSecondaryEdges:re,isMobile:w,onSelectNode:Ce,onOpenNode:Ce,onNavigateNode:je})})}),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:$,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:Pe}),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 ${V==="graph"?"bg-white/[0.14] text-white":"text-white/52 hover:text-white"}`,onClick:()=>N(e=>{e.set("view","graph")}),children:"Graph"}),r.jsx("button",{type:"button",className:`rounded-full px-2 py-1 text-[10px] transition ${V==="hierarchy"?"bg-white/[0.14] text-white":"text-white/52 hover:text-white"}`,onClick:()=>N(e=>{e.set("view","hierarchy")}),children:"Hierarchy"})]}),r.jsx(q,{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:()=>Z(!0),"aria-label":"Open graph appearance settings",title:"Graph appearance settings",children:r.jsx(ct,{className:"size-3"})}),r.jsxs(q,{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:()=>{v(!1),S(!0)},"aria-label":"Open graph filters",children:[r.jsx(lt,{className:"size-3"}),"Search"]})]})]})}):null,Ne?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:$,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:Pe}),r.jsx("div",{className:"min-w-0 flex-1",children:r.jsx(ft,{title:"",description:"",compact:!0,minimal:!0,hideSummary:!0,query:j,onQueryChange:H,onQuerySubmit:He,submitLabel:"Search graph",options:Ve,selectedOptionIds:ge,onSelectedOptionIdsChange:e=>{const h=Rt(e);N(E=>{Q(E,"entityKind",h.entityKinds),Q(E,"relationKind",h.relationKinds),Q(E,"tag",h.tags),Q(E,"owner",h.owners)})},resultSummary:"",placeholder:"Type a graph search, then press Enter or the search button"})}),r.jsxs(q,{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:()=>G(e=>!e),children:[r.jsx(lt,{className:"size-3"}),"Advanced"]}),tt?r.jsx(q,{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(Ir,{initial:!1,children:P?r.jsx(Kr.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(Se,{options:ye,selectedValues:te,onChange:e=>N(h=>{Q(h,"entityKind",e)}),placeholder:"Filter by entity type",emptyMessage:"No entity kinds match the current graph."}),r.jsx(Se,{options:J,selectedValues:se,onChange:e=>N(h=>{Q(h,"relationKind",e)}),placeholder:"Filter by relation type",emptyMessage:"No relation kinds match the current graph."}),r.jsx(Se,{options:he,selectedValues:ve,onChange:e=>N(h=>{Q(h,"tag",e)}),placeholder:"Filter by tag",emptyMessage:"No tags are available in the current filtered graph."}),r.jsx(Se,{options:pe,selectedValues:be,onChange:e=>N(h=>{Q(h,"owner",e)}),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:ce})]}),r.jsx("input",{type:"range",min:rt,max:nt,step:20,value:ce,onChange:e=>N(h=>{h.set("limit",e.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(qe,{type:"date",value:ae(ue),min:ae(b.facets.updatedAt.min),max:ae(oe??b.facets.updatedAt.max),onChange:e=>N(h=>{e.target.value?h.set("updatedFrom",e.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(qe,{type:"date",value:ae(oe),min:ae(ue??b.facets.updatedAt.min),max:ae(b.facets.updatedAt.max),onChange:e=>N(h=>{e.target.value?h.set("updatedTo",e.target.value):h.delete("updatedTo")})})]})]}),V==="hierarchy"?r.jsx(q,{variant:re?"primary":"secondary",size:"sm",className:"h-8 rounded-full px-3 text-xs",onClick:()=>N(e=>{re?e.delete("cross"):e.set("cross","1")}),children:re?"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 ${V==="graph"?"bg-white/[0.14] text-white":"text-white/52 hover:text-white"}`,onClick:()=>N(e=>{e.set("view","graph")}),children:"Graph"}),r.jsx("button",{type:"button",className:`rounded-full px-2.5 py-1.5 text-[10px] transition ${V==="hierarchy"?"bg-white/[0.14] text-white":"text-white/52 hover:text-white"}`,onClick:()=>N(e=>{e.set("view","hierarchy")}),children:"Hierarchy"})]}),V==="graph"?r.jsxs(r.Fragment,{children:[r.jsx(q,{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:()=>Z(!0),title:"Graph appearance settings","aria-label":"Open graph appearance settings",children:r.jsx(ct,{className:"size-3.5"})}),r.jsx(q,{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 e;return(e=l.current)==null?void 0:e.zoomIn()},title:"Zoom in","aria-label":"Zoom in",children:r.jsx(Jt,{className:"size-3.5"})}),r.jsx(q,{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 e;return(e=l.current)==null?void 0:e.zoomOut()},title:"Zoom out","aria-label":"Zoom out",children:r.jsx(Zt,{className:"size-3.5"})}),r.jsx(q,{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 e;return(e=l.current)==null?void 0:e.recenterOnFocus()},disabled:!W.focusNode,title:"Recenter","aria-label":"Recenter",children:r.jsx(er,{className:"size-3.5"})}),r.jsx(q,{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 e;return(e=l.current)==null?void 0:e.fit()},title:"Reset camera","aria-label":"Reset camera",children:r.jsx(tr,{className:"size-3.5"})}),null]}):null]})})]}),r.jsx(pt,{open:g&&!!W.focusNode,onOpenChange:v,eyebrow:"Knowledge Graph",title:((Xe=W.focusNode)==null?void 0:Xe.title)??"Focus node",description:((De=W.focusNode)==null?void 0:De.subtitle)??"Inspect the selected node and move deeper into the graph.",children:r.jsx(Sr,{focus:W,onOpenPage:e=>{v(!1),je(e)},onOpenNotes:e=>{v(!1),Ke(e)},onOpenHierarchy:e=>{v(!1),Oe(e)},onSelectNode:Ce,className:"border-0 bg-transparent p-0 shadow-none"})}),r.jsx(pt,{open:M,onOpenChange:S,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(ft,{title:"",description:"",compact:!0,query:j,onQueryChange:H,onQuerySubmit:He,submitLabel:"Search graph",options:Ve,selectedOptionIds:ge,onSelectedOptionIdsChange:e=>{const h=Rt(e);N(E=>{Q(E,"entityKind",h.entityKinds),Q(E,"relationKind",h.relationKinds),Q(E,"tag",h.tags),Q(E,"owner",h.owners)})},resultSummary:$,placeholder:"Type a graph search, then press Enter or the search button"})}),r.jsxs("div",{className:"grid gap-3",children:[r.jsx(Se,{options:ye,selectedValues:te,onChange:e=>N(h=>{Q(h,"entityKind",e)}),placeholder:"Filter by entity type",emptyMessage:"No entity kinds match the current graph."}),r.jsx(Se,{options:J,selectedValues:se,onChange:e=>N(h=>{Q(h,"relationKind",e)}),placeholder:"Filter by relation type",emptyMessage:"No relation kinds match the current graph."}),r.jsx(Se,{options:he,selectedValues:ve,onChange:e=>N(h=>{Q(h,"tag",e)}),placeholder:"Filter by tag",emptyMessage:"No tags are available in the current filtered graph."}),r.jsx(Se,{options:pe,selectedValues:be,onChange:e=>N(h=>{Q(h,"owner",e)}),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:ce})]}),r.jsx("input",{type:"range",min:rt,max:nt,step:20,value:ce,onChange:e=>N(h=>{h.set("limit",e.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(qe,{type:"date",value:ae(ue),min:ae(b.facets.updatedAt.min),max:ae(oe??b.facets.updatedAt.max),onChange:e=>N(h=>{e.target.value?h.set("updatedFrom",e.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(qe,{type:"date",value:ae(oe),min:ae(ue??b.facets.updatedAt.min),max:ae(b.facets.updatedAt.max),onChange:e=>N(h=>{e.target.value?h.set("updatedTo",e.target.value):h.delete("updatedTo")})})]})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(q,{variant:"secondary",size:"sm",onClick:Ae,children:"Reset"}),r.jsx(q,{variant:"primary",size:"sm",onClick:()=>S(!1),children:"Done"})]})]})]})}),r.jsx(rr,{open:A,onOpenChange:Z,children:r.jsxs(nr,{children:[r.jsx(ar,{className:"fixed inset-0 z-40 bg-[rgba(4,8,18,0.72)] backdrop-blur-xl"}),r.jsxs(sr,{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(ir,{className:"sr-only",children:"Knowledge Graph appearance settings"}),r.jsx(or,{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(ut,{asChild:!0,children:r.jsx(_r,{"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:k.focusRepulsion.toFixed(2)})]}),r.jsx("input",{"aria-label":"Focused repulsion",type:"range",min:"0.6",max:String(At),step:"0.05",value:k.focusRepulsion,onChange:e=>de("focusRepulsion",Number(e.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:k.focusDiffusion.toFixed(2)})]}),r.jsx("input",{"aria-label":"Focus diffusion",type:"range",min:"0.6",max:String(Pt),step:"0.05",value:k.focusDiffusion,onChange:e=>de("focusDiffusion",Number(e.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:k.focusSpringReductionMax.toFixed(2)})]}),r.jsx("input",{"aria-label":"Spring reduction max",type:"range",min:"0",max:String(Dt),step:"0.02",value:k.focusSpringReductionMax,onChange:e=>de("focusSpringReductionMax",Number(e.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:k.focusSpringReductionDiffusion.toFixed(2)})]}),r.jsx("input",{"aria-label":"Spring reduction diffusion",type:"range",min:"0.6",max:String(Tt),step:"0.05",value:k.focusSpringReductionDiffusion,onChange:e=>de("focusSpringReductionDiffusion",Number(e.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:k.edgeSpringStrength.toFixed(2)})]}),r.jsx("input",{"aria-label":"Edge spring strength",type:"range",min:String(zt),max:String(Lt),step:"0.05",value:k.edgeSpringStrength,onChange:e=>de("edgeSpringStrength",Number(e.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:k.gravityStrength.toFixed(2)})]}),r.jsx("input",{"aria-label":"Gravity strength",type:"range",min:"0",max:String($t),step:"0.05",value:k.gravityStrength,onChange:e=>de("gravityStrength",Number(e.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:k.focusShellSpacing.toFixed(2)})]}),r.jsx("input",{"aria-label":"Focus shell spacing",type:"range",min:String(Yt),max:String(Ht),step:"0.05",value:k.focusShellSpacing,onChange:e=>de("focusShellSpacing",Number(e.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(q,{variant:"secondary",onClick:()=>K(le),children:"Reset defaults"}),r.jsx(ut,{asChild:!0,children:r.jsx(q,{variant:"primary",children:"Done"})})]})]})]})]})}),null]})}export{Gn as KnowledgeGraphPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./vendor-DHkYh85p.js";import{C as l,aq as c,Z as x}from"./index-CF4J4R9L.js";function o({label:t,value:n,tone:a="default",detail:s,help:r,className:i}){return e.jsxs(l,{className:x("rounded-[22px] p-4",a==="core"&&"bg-[linear-gradient(180deg,rgba(29,24,48,0.95),rgba(17,17,31,0.92))]",a==="psyche"&&"bg-[linear-gradient(180deg,rgba(18,31,34,0.96),rgba(13,24,27,0.94))]",i),children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:[e.jsx("span",{children:t}),r?e.jsx(c,{label:`Explain ${t}`,title:t,content:r,panelClassName:"normal-case tracking-normal"}):null]}),e.jsx("div",{className:"mt-3 font-display text-3xl text-white",children:n}),s?e.jsx("div",{className:"mt-2 text-sm text-white/56",children:s}):null]})}export{o as M};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as x,j as e,aK as Nt,b4 as Ca,cq as aa,cr as pt,cs as sa,ct as Pa,c3 as ia,aZ as tt,c7 as La,o as Da,bg as St,bX as Ia,c4 as Mt,bc as $a}from"./vendor-DHkYh85p.js";import{j as ra,x as Rt,i as te,k as ke}from"./state-B-4sS1xO.js";import{I as P,B as k,aY as Ot,aZ as Ht,a_ as na,a$ as Fa,b0 as Ea,S as la,E as da,C as v,c as u,Z as O,aS as oa,b1 as _a,b2 as Kt,b3 as za,b4 as ca,b5 as Ra,u as Oa,b6 as Ha,b7 as Ka,b8 as Xe,h as Bt,d as Ze,b9 as Ba,aq as ce,ba as qa,bb as Qa,bc as Ua,bd as Wa,be as Ga,bf as Va,bg as Ya,O as Xa,bh as Za,bi as Ja,bj as es}from"./index-CF4J4R9L.js";import{F as ma}from"./faceted-token-search-BxRRcM3q.js";import{P as ts}from"./page-hero-DRy5b2MU.js";import{R as Re,P as Oe,O as He,C as Ke,T as Be,D as qe,a as _e}from"./ui-C13Nbgas.js";import{m as qt}from"./motion-BeD44FeG.js";import{R as as,A as ss,C as is,X as rs,Y as ns,T as ls,a as ds}from"./charts-P7EVhIog.js";import"./board-BkDRaMp6.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";function xa({open:t,onOpenChange:a,place:s,seed:i,onSave:c}){const[r,h]=x.useState({label:(s==null?void 0:s.label)??(i==null?void 0:i.label)??"",latitude:String((s==null?void 0:s.latitude)??(i==null?void 0:i.latitude)??""),longitude:String((s==null?void 0:s.longitude)??(i==null?void 0:i.longitude)??""),radiusMeters:String((s==null?void 0:s.radiusMeters)??(i==null?void 0:i.radiusMeters)??100),categoryTags:((s==null?void 0:s.categoryTags)??(i==null?void 0:i.categoryTags)??[]).join(", ")});return x.useEffect(()=>{h({label:(s==null?void 0:s.label)??(i==null?void 0:i.label)??"",latitude:String((s==null?void 0:s.latitude)??(i==null?void 0:i.latitude)??""),longitude:String((s==null?void 0:s.longitude)??(i==null?void 0:i.longitude)??""),radiusMeters:String((s==null?void 0:s.radiusMeters)??(i==null?void 0:i.radiusMeters)??100),categoryTags:((s==null?void 0:s.categoryTags)??(i==null?void 0:i.categoryTags)??[]).join(", ")})},[s,i]),e.jsx(Re,{open:t,onOpenChange:a,children:e.jsxs(Oe,{children:[e.jsx(He,{className:"fixed inset-0 z-50 bg-[rgba(3,7,18,0.74)] backdrop-blur-sm"}),e.jsxs(Ke,{className:"fixed left-1/2 top-[8vh] z-50 w-[min(32rem,calc(100vw-1.25rem))] -translate-x-1/2 rounded-[30px] border border-white/10 bg-[linear-gradient(180deg,rgba(8,14,28,0.98),rgba(10,16,30,0.95))] p-5 shadow-[0_32px_90px_rgba(0,0,0,0.45)]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(Be,{className:"font-display text-[1.3rem] tracking-[-0.05em] text-white",children:s?`Edit ${s.label}`:"New known place"}),e.jsx(qe,{className:"mt-1 text-sm text-white/58",children:"Define life landmarks once so the companion and web views can reason about stays and trips consistently."})]}),e.jsx(_e,{asChild:!0,children:e.jsx("button",{type:"button",className:"rounded-full border border-white/10 bg-white/[0.04] p-2 text-white/64 transition hover:bg-white/[0.08] hover:text-white",children:e.jsx(Nt,{className:"size-4"})})})]}),e.jsxs("div",{className:"mt-5 grid gap-3",children:[e.jsx(P,{value:r.label,onChange:o=>h(m=>({...m,label:o.target.value})),placeholder:"Home, Main Office, Riverside path..."}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(P,{value:r.latitude,onChange:o=>h(m=>({...m,latitude:o.target.value})),placeholder:"Latitude"}),e.jsx(P,{value:r.longitude,onChange:o=>h(m=>({...m,longitude:o.target.value})),placeholder:"Longitude"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-[10rem_minmax(0,1fr)]",children:[e.jsx(P,{value:r.radiusMeters,onChange:o=>h(m=>({...m,radiusMeters:o.target.value})),placeholder:"Radius meters"}),e.jsx(P,{value:r.categoryTags,onChange:o=>h(m=>({...m,categoryTags:o.target.value})),placeholder:"home, gym, holiday, parents-house"})]})]}),e.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[e.jsx(k,{variant:"ghost",onClick:()=>a(!1),className:"border border-white/10 bg-white/[0.04]",children:"Cancel"}),e.jsx(k,{onClick:()=>void c({id:s==null?void 0:s.id,label:r.label,latitude:Number(r.latitude),longitude:Number(r.longitude),radiusMeters:Number(r.radiusMeters),categoryTags:r.categoryTags.split(",").map(o=>o.trim()).filter(Boolean)}).then(()=>a(!1)),children:"Save place"})]})]})]})})}const gt=1e3;function D(t){return new Date(t).getTime()}function bt(t){return new Date(t).toISOString()}function Qt(t,a){const s=D(t.startedAt)-D(a.startedAt);if(s!==0)return s;const i=D(t.endedAt)-D(a.endedAt);return i!==0?i:t.id.localeCompare(a.id)}function kt(t){return t.syncSource==="sleep overlay"}function os(t){const a=[...t].filter(i=>D(i.endedAt)>D(i.startedAt)).sort((i,c)=>{const r=D(i.startedAt)-D(c.startedAt);if(r!==0)return r;const h=D(i.endedAt)-D(c.endedAt);return h!==0?h:i.id.localeCompare(c.id)});if(a.length===0)return[];const s=[];for(const i of a){const c=s.at(-1);if(!c){s.push(i);continue}const r=D(c.endedAt);if(D(i.startedAt)<=r+gt){const o=Math.max(r,D(i.endedAt));s[s.length-1]={...c,id:`${c.id}__${i.id}`,endedAt:bt(o),asleepSeconds:(c.asleepSeconds??0)+(i.asleepSeconds??0)||null,timeInBedSeconds:(c.timeInBedSeconds??0)+(i.timeInBedSeconds??0)||null,sleepScore:i.sleepScore??c.sleepScore,regularityScore:i.regularityScore??c.regularityScore,efficiency:i.efficiency??c.efficiency,recoveryState:i.recoveryState??c.recoveryState};continue}s.push(i)}return s}function cs(t){const a=[];if(typeof t.asleepSeconds=="number"&&t.asleepSeconds>0){const s=t.asleepSeconds/3600;a.push(`${s.toFixed(s>=1?1:2)}h asleep`)}else if(typeof t.timeInBedSeconds=="number"&&t.timeInBedSeconds>0){const s=t.timeInBedSeconds/3600;a.push(`${s.toFixed(s>=1?1:2)}h in bed`)}return typeof t.sleepScore=="number"&&a.push(`score ${t.sleepScore}`),typeof t.regularityScore=="number"&&a.push(`regularity ${t.regularityScore}`),t.recoveryState&&a.push(t.recoveryState),a.join(" · ")||"Sleep session"}function ms(t){const a=Math.max(60,Math.round((D(t.endedAt)-D(t.startedAt))/1e3));return{id:`sleep-overlay-${t.id}`,boxId:`sleep-overlay-${t.id}`,kind:"stay",sourceKind:"automatic",origin:"recorded",editable:!1,isInvalid:!1,startedAt:t.startedAt,endedAt:t.endedAt,trueStartedAt:t.startedAt,trueEndedAt:t.endedAt,visibleStartedAt:t.startedAt,visibleEndedAt:t.endedAt,durationSeconds:a,laneSide:"left",connectorFromLane:"left",connectorToLane:"left",title:"Sleep",subtitle:cs(t),placeLabel:null,tags:["sleep"],syncSource:"sleep overlay",cursor:`${t.endedAt}::sleep-overlay-${t.id}`,overrideCount:0,overriddenAutomaticBoxIds:[],overriddenUserBoxIds:[],isFullyHidden:!1,rawStayIds:[],rawTripIds:[],rawPointCount:0,hasLegacyCorrections:!1,stay:null,trip:null}}function Ut(t,a,s){if(s<=a)return null;const i=bt(a),c=bt(s),r=Math.max(60,Math.round((s-a)/1e3));return{...t,id:`${t.id}::virtual-${a}-${s}`,startedAt:i,endedAt:c,trueStartedAt:i,trueEndedAt:c,visibleStartedAt:i,visibleEndedAt:c,durationSeconds:r,cursor:`${c}::${t.id}::virtual`}}function xs(t,a){let s=[...t].sort(Qt);for(const i of os(a)){const c=D(i.startedAt),r=D(i.endedAt),h=ms(i),o=[];let m=!1;for(const p of s){const N=D(p.startedAt),b=D(p.endedAt);if(b<=c||N>=r){!m&&N>=r&&(o.push(h),m=!0),o.push(p);continue}if(N<c){const A=Ut(p,N,Math.min(b,c-gt));A&&o.push(A)}if(m||(o.push(h),m=!0),b>r){const A=Ut(p,Math.max(N,r+gt),b);A&&o.push(A)}}m||o.push(h),s=o.sort(Qt)}return s}const Wt=24,G=64,ft=360*60,ha=5,ht=1,hs=104,Gt=G*8;function ue(t){return t.trim().toLowerCase()}function ze(t){return t>=86400?`${Math.round(t/3600)}h`:t>=3600?`${(t/3600).toFixed(1)}h`:`${Math.max(1,Math.round(t/60))}m`}function pe(t){return new Intl.DateTimeFormat(void 0,{day:"2-digit",month:"2-digit",year:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(t))}function ua(t){return new Intl.DateTimeFormat(void 0,{day:"2-digit",month:"2-digit",year:"2-digit"}).format(new Date(t))}function us(t){return new Intl.DateTimeFormat(void 0,{hour:"2-digit",hour12:!1}).format(t)}function Ae(t){const a=new Date(t);if(Number.isNaN(a.getTime()))return"";const s=a.getFullYear(),i=String(a.getMonth()+1).padStart(2,"0"),c=String(a.getDate()).padStart(2,"0"),r=String(a.getHours()).padStart(2,"0"),h=String(a.getMinutes()).padStart(2,"0");return`${s}-${i}-${c}T${r}:${h}`}function at(t){if(!t.trim())return null;const a=new Date(t);return Number.isNaN(a.getTime())?null:a.toISOString()}function Te(t){return t>=1e3?`${(t/1e3).toFixed(1)} km`:`${Math.round(t)} m`}function W(t){return new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t))}function Vt(t,a){return`${t.toFixed(3)}, ${a.toFixed(3)}`}function Je(t,a){return`${t.toFixed(6)}, ${a.toFixed(6)}`}function Yt(t){return`${Math.max(1,Math.round(t/60))} min`}function ps(t){if(t.length===0)return[];const a=Math.min(...t.map(o=>o.latitude)),s=Math.max(...t.map(o=>o.latitude)),i=Math.min(...t.map(o=>o.longitude)),c=Math.max(...t.map(o=>o.longitude)),r=Math.max(s-a,1e-4),h=Math.max(c-i,1e-4);return t.map((o,m)=>({...o,x:12+(o.longitude-i)/h*76,y:12+(1-(o.latitude-a)/r)*76,id:`${o.recordedAt??"point"}-${m}`}))}function vt(t){return!le(t)||t.stay.place?null:{label:t.stay.label||t.title,latitude:t.stay.centerLatitude,longitude:t.stay.centerLongitude,radiusMeters:t.stay.radiusMeters,categoryTags:t.tags}}function ye(t){var a;return t?t.kind==="stay"&&le(t)?((a=t.stay.place)==null?void 0:a.label)??t.placeLabel??t.stay.label??null:t.placeLabel??null:null}function et(t,a,s,i){const r=(s-t)*Math.PI/180,h=(i-a)*Math.PI/180,o=t*Math.PI/180,m=s*Math.PI/180,p=Math.sin(r/2)**2+Math.cos(o)*Math.cos(m)*Math.sin(h/2)**2;return 2*6371e3*Math.asin(Math.sqrt(p))}function gs(t){return ue([t.label,...t.aliases].join(" "))}function st(t){return t.kind==="trip"&&t.trip!==null}function le(t){return t.kind==="stay"&&t.stay!==null}function je(t,a,s){if(!t.trip)return{label:t.placeLabel??(a==="start"?"Known origin":"Known destination"),detail:W(a==="start"?t.startedAt:t.endedAt)};const i=a==="start"?t.trip.points[0]??null:t.trip.points[t.trip.points.length-1]??null,c=a==="start"?t.trip.startPlace:t.trip.endPlace,r=(s==null?void 0:s.includeCoordinates)??!0,h=s!=null&&s.useHistoryAnchorFallback&&a==="start"?"Beginning of history":null;return{label:(c==null?void 0:c.label)??h??(r&&i?Vt(i.latitude,i.longitude):a==="start"?"Unknown origin":"Unknown destination"),detail:r&&i&&!c?Vt(i.latitude,i.longitude):W(a==="start"?t.startedAt:t.endedAt)}}function bs(t){const a=t.trim().toLowerCase();return a==="travel"||a==="trip"||a==="move"}function fs(t){const a=t.title.trim().toLowerCase();return a.length===0||a==="stay"||a==="continued stay"||a==="repaired stay"?t.sourceKind==="user_defined"?t.origin==="user_invalidated"?"User invalidated movement":"User-defined missing data":"Missing data":t.title}function vs(t){const a=ye(t),s=t.title.trim().toLowerCase(),i=s.length===0||s==="stay"||s==="continued stay"||s==="repaired stay"||s==="manual stay";return a&&i?a:t.title.trim()||a||"Stay"}function me(t){if(kt(t))return"Sleep";if(t.kind==="missing")return fs(t);if(t.kind==="stay")return vs(t);if(t.kind==="trip"&&bs(t.title)){const a=je(t,"start").label,s=je(t,"end").label;return`${a} → ${s}`}return t.title}function Xt(t){return t==="left"?24:t==="right"?76:50}function ws(t,a,s){const i=Math.min(t,ft)/3600,c=s==="sleep overlay",r=c?112:a==="stay"?104:92,h=c?272:a==="stay"?288:232,o=r+i*30;return Math.max(r,Math.min(h,o))}function wt(t){var a;return{kind:t.kind,label:le(t)?t.stay.label||t.title:st(t)&&t.trip.label||t.title,placeLabel:le(t)?((a=t.stay.place)==null?void 0:a.label)??t.placeLabel??"":"",tagsInput:t.tags.join(", "),startedAtInput:Ae(t.startedAt),endedAtInput:Ae(t.endedAt)}}function ut(t,a){const s=(a==null?void 0:a.startedAt)??new Date(Date.now()-36e5).toISOString(),i=(a==null?void 0:a.endedAt)??new Date().toISOString();return{kind:t,label:t==="missing"?"User-defined missing data":t==="stay"?(a==null?void 0:a.placeLabel)||"Manual stay":"Manual move",placeLabel:(a==null?void 0:a.placeLabel)??"",tagsInput:t==="missing"?"user-defined, missing-data":t==="stay"?"user-defined, stay":"user-defined, move",startedAtInput:Ae(s),endedAtInput:Ae(i)}}function yt(t,a){var r,h;const s=t.tagsInput.split(",").map(o=>o.trim()).filter(Boolean),i=at(t.startedAtInput)??(a==null?void 0:a.startedAt)??new Date(Date.now()-3600*1e3).toISOString(),c=at(t.endedAtInput)??(a==null?void 0:a.endedAt)??new Date().toISOString();return{kind:t.kind,startedAt:i,endedAt:c,title:t.label.trim(),subtitle:t.kind==="missing"?"User-defined missing-data override.":"User-defined movement box.",placeLabel:t.placeLabel.trim()||null,tags:s,distanceMeters:t.kind==="trip"?Math.max(((r=a==null?void 0:a.trip)==null?void 0:r.distanceMeters)??150,150):null,averageSpeedMps:t.kind==="trip"?((h=a==null?void 0:a.trip)==null?void 0:h.averageSpeedMps)??null:null,metadata:{createdFrom:"movement-life-timeline"}}}function ys(t,a){var c,r;const s=t.kind==="stay"?((r=(c=t.stay)==null?void 0:c.label)==null?void 0:r.trim())??"":"";if(s)return s;const i=t.title.trim();return i&&i.toLowerCase()!=="stay"?i:a.trim()||"Stay"}function js(t,a){const s=wt(t),i=a.trim();return yt({...s,label:ys(t,i),placeLabel:i},t)}function pa(t){const a=new Date(t).getHours();return a<6?"night":a<12?"morning":a<18?"afternoon":"evening"}function it(t){return new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}).format(new Date(t))}function Ns(t){var a,s,i;return ue([t.kind,me(t),t.subtitle,t.placeLabel??"",...t.tags,it(t.startedAt),it(t.endedAt),pa(t.startedAt),le(t)?((a=t.stay.place)==null?void 0:a.label)??t.stay.label:st(t)?[t.trip.label,t.trip.activityType,t.trip.travelMode,(s=t.trip.startPlace)==null?void 0:s.label,(i=t.trip.endPlace)==null?void 0:i.label].filter(Boolean).join(" "):t.kind==="trip"?[t.title,t.subtitle,t.placeLabel??""].filter(Boolean).join(" "):"missing data gap"].join(" "))}function Ss(t){const a=new Map;a.set("kind:stay",{id:"kind:stay",label:"Stay",description:"Stationary spans and place anchors."}),a.set("kind:trip",{id:"kind:trip",label:"Move",description:"Trips and movement connectors."});for(const s of["night","morning","afternoon","evening"])a.set(`time:${s}`,{id:`time:${s}`,label:s[0].toUpperCase()+s.slice(1),description:"Filter by the segment start time."});for(const s of t){for(const i of s.tags)a.set(`tag:${i}`,{id:`tag:${i}`,label:i,description:"Movement tag"});s.placeLabel&&a.set(`place:${s.placeLabel}`,{id:`place:${s.placeLabel}`,label:s.placeLabel,description:"Matched place"})}return[...a.values()].sort((s,i)=>s.label.localeCompare(i.label))}function Ms(t,a){return a.every(s=>s==="kind:stay"||s==="kind:trip"?t.kind===s.slice(5):s.startsWith("time:")?pa(t.startedAt)===s.slice(5):s.startsWith("tag:")?t.tags.includes(s.slice(4)):s.startsWith("place:")?(t.placeLabel??"")===s.slice(6):!0)}function Zt(t,a){return t&&{...t,pages:t.pages.map(s=>({...s,segments:s.segments.filter(i=>i.id!==a)}))}}function ks(t,a){const s=t+(Math.sin((t-.5)*Math.PI)+1)*.5-t,i=t-.5,r=.5+(i*(1-a*.64)+i*i*i*a*2.56);return Math.max(0,Math.min(1,r-(s-t)*a*.08))}function As(t){return t.getHours()===0?ua(t.toISOString()):us(t)}function Ts(t,a){const s=new Date(t.endedAt).getTime(),i=new Date(t.startedAt).getTime(),c=Math.max(1,s-i),r=Math.max(0,Math.min(1,(a-i)/c));if(t.durationSeconds<=ft)return r;const h=Math.max(0,1-Math.min(1,ft/Math.max(1,t.durationSeconds)));return ks(r,h)}function Cs(t,a,s){if(t.items.length===0)return null;const i=t.items[0];if(a<new Date(i.segment.startedAt).getTime())return t.historyHeaderHeight+t.leadHeight-(new Date(i.segment.startedAt).getTime()-a)/36e5*G;for(let h=0;h<t.items.length;h+=1){const o=t.items[h],m=new Date(o.segment.startedAt).getTime(),p=new Date(o.segment.endedAt).getTime();if(a>=m&&a<=p)return o.boxTop+Ts(o.segment,a)*o.displayHeight;const N=t.items[h+1]??null,b=N?new Date(N.segment.startedAt).getTime():s;if(a>p&&a<b)return o.boxBottom+(a-p)/36e5*G}const c=t.items[t.items.length-1],r=new Date(c.segment.endedAt).getTime();return a>=r?c.boxBottom+(a-r)/36e5*G:null}function Ps(t){const a=new Date(t);a.setMinutes(0,0,0);const s=a.getTime();return s<=t?s+36e5:s}function Ls(t,a){const s=[];if(t.items.length===0)return s;const i=t.items[0],c=new Date(i.segment.startedAt).getTime();for(let r=Ps(c-ha*36e5);r<=a;r+=36e5){const h=Cs(t,r,a);if(h===null)continue;const o=new Date(r);s.push({y:h,label:As(o),strong:o.getHours()===0})}return s}function Ds({segments:t,viewportHeight:a,nowMs:s=Date.now()}){var B;const i=t.length>0?hs:0,c=t.length>0?G*ha:0;let r=i+c,h=null;const o=t.map(w=>{const T=ws(w.durationSeconds,w.kind,w.syncSource),F=new Date(w.startedAt).getTime(),H=h===null?0:Math.max(0,(F-h)/36e5)*G;r+=H;const V=r,_=V+T;return r=_,h=new Date(w.endedAt).getTime(),{id:w.id,segment:w,gapBefore:H,displayHeight:T,boxTop:V,boxBottom:_}}),m=s+ht*36e5,p=(()=>{var F;const w=(F=t[t.length-1])==null?void 0:F.endedAt;if(!w)return G*ht;const T=new Date(w).getTime();return Math.max(G*ht,(m-T)/36e5*G)})(),N=(((B=o[o.length-1])==null?void 0:B.boxBottom)??i+c)+p,b=Math.max(N,a>0?a+260:960,i+c+p),A={historyHeaderHeight:i,leadHeight:c,items:o,markers:[],rangeEndMs:m,futureTailHeight:p+Math.max(0,b-N),totalHeight:b};return{...A,markers:Ls(A,m)}}function Is({layout:t,scrollTop:a,viewportHeight:s}){const i=G*6,c=Math.max(0,a-i),r=Math.min(t.totalHeight,a+Math.max(s,G*8)+i),h=t.markers.filter(o=>o.y>=c&&o.y<=r);return e.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 overflow-hidden rounded-[30px]",style:{height:`${t.totalHeight}px`},children:[e.jsx("div",{className:"absolute inset-y-0 left-0 w-18 bg-[linear-gradient(90deg,rgba(7,12,22,0.96),rgba(7,12,22,0.42),transparent)]"}),h.map((o,m)=>e.jsxs("div",{className:"absolute inset-x-0",style:{top:`${o.y}px`},children:[e.jsx("div",{className:O("border-t",o.strong?"border-white/14":"border-white/7")}),e.jsx("div",{className:O("absolute left-3 top-0 -translate-y-1/2 font-label text-[9px] tracking-[0.24em]",o.strong?"text-white/38":"text-white/22"),children:o.label})]},`timeline-grid-${m}`))]})}function $s({fromSide:t,toSide:a,height:s,emphasized:i}){const c=Xt(t),r=Xt(a),h=`M ${c} 16 C ${c} ${Math.max(40,s*.26)}, ${r} ${Math.max(70,s*.72)}, ${r} ${s-18}`;return e.jsxs("svg",{viewBox:`0 0 100 ${s}`,className:"absolute inset-x-0 top-0 h-full w-full overflow-visible",preserveAspectRatio:"none",children:[e.jsx("path",{d:h,fill:"none",stroke:i?"rgba(241,246,255,0.18)":"rgba(241,246,255,0.11)",strokeWidth:i?"1.05":"0.85",strokeDasharray:i?"3 10":"2.5 12",strokeLinecap:"round"}),e.jsx("circle",{cx:c,cy:"16",r:"1.5",fill:"rgba(255,255,255,0.26)"}),e.jsx("circle",{cx:r,cy:s-18,r:"1.5",fill:"rgba(255,255,255,0.26)"})]})}function jt({position:t}){return e.jsx("div",{className:O("absolute left-1/2 z-20 flex -translate-x-1/2 items-center justify-center",t==="top"?"-top-3":"-bottom-3"),children:e.jsx("div",{className:"h-6 w-[3px] rounded-full bg-[rgba(160,224,255,0.92)] shadow-[0_0_14px_rgba(126,229,255,0.36)]"})})}function Fs({segment:t}){const a=(t==null?void 0:t.kind)==="stay"?t.placeLabel||t.title||null:(t==null?void 0:t.kind)==="trip"?je(t,"start",{includeCoordinates:!1,useHistoryAnchorFallback:!0}).label:null,s=a||"Beginning of time";return e.jsx("div",{className:"pointer-events-none flex justify-center px-6 py-4",children:e.jsxs("div",{className:"relative w-[min(18rem,calc(100vw-6rem))] overflow-hidden rounded-[26px] border border-[rgba(152,208,255,0.2)] bg-[linear-gradient(180deg,rgba(98,130,238,0.14),rgba(18,34,79,0.14))] shadow-[0_20px_48px_rgba(3,8,20,0.3)]",children:[e.jsx(jt,{position:"bottom"}),e.jsxs("div",{className:"relative z-10 px-5 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(u,{tone:"signal",className:"bg-white/10 text-white/78",children:"Start"}),e.jsx("div",{className:"font-label text-[10px] uppercase tracking-[0.2em] text-white/28",children:"Beginning of history"})]}),e.jsx("div",{className:"mt-5 font-display text-[1.25rem] tracking-[-0.05em] text-white",children:s}),e.jsx("div",{className:"mt-2 font-label text-[10px] uppercase tracking-[0.22em] text-white/30",children:a?"Oldest loaded known stay":"Earliest known anchor"})]})]})})}function Es(t,a,s){const i=a+Math.max(96,Math.min(s*.28,220)),c=t.items.find(r=>r.boxBottom>=i)??t.items[t.items.length-1]??null;return c?ua(c.segment.startedAt):null}function _s({open:t,anchor:a,items:s,onClose:i}){if(x.useEffect(()=>{if(!t)return;const m=N=>{N.key==="Escape"&&i()},p=()=>i();return window.addEventListener("keydown",m),window.addEventListener("pointerdown",p),()=>{window.removeEventListener("keydown",m),window.removeEventListener("pointerdown",p)}},[i,t]),!t||!a||typeof document>"u")return null;const c=Math.max(12,Math.min(a.top,window.innerHeight-360)),r=Math.max(220,window.innerHeight-c-96),h=Math.min(368,window.innerWidth-24),o=Math.max(12,Math.min(a.right,window.innerWidth-h-12));return Da.createPortal(e.jsx("div",{className:"fixed inset-0 z-[70] pointer-events-none",children:e.jsxs("div",{className:"pointer-events-auto fixed z-[71] overflow-y-auto overscroll-contain rounded-[28px] border border-white/10 bg-[linear-gradient(180deg,rgba(18,24,40,0.985),rgba(8,13,24,0.985))] p-2 shadow-[0_28px_90px_rgba(3,8,18,0.48)] backdrop-blur-xl",style:{top:`${c}px`,right:`${o}px`,width:`${h}px`,maxHeight:`${r}px`},onPointerDown:m=>m.stopPropagation(),children:[e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.035] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[10px] uppercase tracking-[0.2em] text-white/40",children:"Movement actions"}),e.jsx("div",{className:"mt-1 text-sm text-white/70",children:"Add boxes, inspect raw data, and adjust timeline overlays."})]}),e.jsx("div",{className:"mt-2 grid gap-1",children:s.map(m=>{const p=m.icon;return e.jsxs("button",{type:"button",className:"flex w-full items-start gap-3 rounded-[20px] bg-white/[0.035] px-4 py-3 text-left text-white/76 transition hover:bg-white/[0.08] hover:text-white",onClick:()=>{m.onSelect(),i()},children:[e.jsx("span",{className:"rounded-[14px] bg-[var(--primary)]/12 p-2 text-[var(--primary)]",children:e.jsx(p,{className:"size-4"})}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm font-medium",children:m.label}),e.jsx("span",{className:"mt-1 block text-xs leading-5 text-white/48",children:m.description})]})]},m.id)})})]})}),document.body)}function zs({segment:t,onEdit:a,onOpenDetail:s,onDefinePlace:i,onClose:c}){var h;const r=kt(t);return e.jsxs(v,{className:"rounded-[28px] border border-white/10 bg-[linear-gradient(180deg,rgba(9,14,26,0.98),rgba(5,9,19,0.95))] p-5 shadow-[0_24px_74px_rgba(0,0,0,0.34)]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/40",children:r?"Sleep overlay":t.kind==="stay"?"Stay detail":t.kind==="trip"?"Move detail":"Missing data"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:me(t)}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(u,{className:r?"bg-cyan-400/14 text-cyan-100":t.sourceKind==="user_defined"?"bg-fuchsia-400/12 text-fuchsia-100":"bg-white/[0.06] text-white/70",children:r?"Virtual":t.sourceKind==="user_defined"?t.origin==="user_invalidated"?"User invalidated":"User-defined":"Automatic"}),t.overrideCount>0?e.jsxs(u,{className:"bg-amber-400/10 text-amber-100",children:["Overrides ",t.overrideCount," automatic box",t.overrideCount===1?"":"es"]}):null]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{onClick:s,variant:"ghost",className:"rounded-full border border-white/10 bg-white/[0.04] px-3 text-white/78 hover:bg-white/[0.08]",disabled:r,children:"Details"}),e.jsx(k,{onClick:a,variant:"ghost",className:"size-9 rounded-full border border-white/10 bg-white/[0.04] text-white/78 hover:bg-white/[0.08]","aria-label":"Edit movement segment",disabled:r||t.kind==="missing"||!t.editable,children:e.jsx(Mt,{className:"size-4"})}),c?e.jsx("button",{type:"button",onClick:c,className:"rounded-full border border-white/10 bg-white/[0.04] p-2 text-white/64 transition hover:bg-white/[0.08] hover:text-white","aria-label":"Close movement segment actions",children:e.jsx(Nt,{className:"size-4"})}):null,e.jsx(St,{className:"size-4 text-white/42"})]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.03] p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/34",children:"Started"}),e.jsx("div",{className:"mt-2 text-sm text-white/82",children:pe(t.startedAt)})]}),e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.03] p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/34",children:"Ended"}),e.jsx("div",{className:"mt-2 text-sm text-white/82",children:pe(t.endedAt)})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(u,{tone:"signal",children:ze(t.durationSeconds)}),st(t)?e.jsxs(e.Fragment,{children:[e.jsx(u,{className:"bg-white/[0.08] text-white/74",children:Te(t.trip.distanceMeters)}),t.trip.stops.length>0?e.jsxs(u,{className:"bg-white/[0.08] text-white/74",children:[t.trip.stops.length," stop",t.trip.stops.length===1?"":"s"]}):null]}):null,r?e.jsx(u,{className:"bg-cyan-400/12 text-cyan-50",children:t.subtitle}):ye(t)?e.jsx(u,{className:"bg-white/[0.08] text-white/74",children:ye(t)}):null]}),le(t)&&!r?e.jsxs("div",{className:"mt-4 rounded-[18px] border border-sky-300/14 bg-sky-300/8 p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-sky-100/66",children:"Location label"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-sky-50/86",children:t.stay.place?`This stay is currently linked to ${t.stay.place.label}. Search saved places or relabel it from this stay center.`:"Search saved places for this stay, or create a new one from the stay center so later matching stays inherit it automatically."}),e.jsx("div",{className:"mt-3",children:e.jsx(k,{onClick:i,variant:"ghost",className:"rounded-full border border-sky-300/24 bg-sky-300/12 px-4 text-sky-50 hover:bg-sky-300/18",children:"Label location"})})]}):null,e.jsxs("div",{className:"mt-5 grid gap-3",children:[e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.03] p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/34",children:"Timeline summary"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/76",children:t.kind==="stay"?r?`Sleep overlay from ${W(t.startedAt)} to ${W(t.endedAt)}. Underlying movement boxes are sliced virtually while this overlay is visible.`:`Stay block from ${W(t.startedAt)} to ${W(t.endedAt)}.`:t.kind==="trip"?`Connector from ${je(t,"start").label} to ${je(t,"end").label}.`:`No reliable movement signal reached Forge from ${W(t.startedAt)} to ${W(t.endedAt)}.`})]}),e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.03] p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/34",children:"Projection model"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/76",children:r?"This sleep layer is visual only. Forge does not persist these split boxes; it temporarily slices the visible movement boxes around each sleep interval.":"Raw phone measurements stay immutable. Forge derives automatic boxes from that raw movement evidence, then overlays user-defined boxes on top without mutating the imported raw data."}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(u,{className:"bg-white/[0.08] text-white/74",children:["Raw stays ",t.rawStayIds.length]}),e.jsxs(u,{className:"bg-white/[0.08] text-white/74",children:["Raw trips ",t.rawTripIds.length]}),e.jsxs(u,{className:"bg-white/[0.08] text-white/74",children:["Raw points ",t.rawPointCount]}),t.hasLegacyCorrections?e.jsx(u,{className:"bg-amber-400/10 text-amber-100",children:"Legacy corrections present"}):null]})]})]}),e.jsx("div",{className:"mt-5 flex flex-wrap items-center gap-2 text-sm text-white/56",children:r?e.jsxs(e.Fragment,{children:[e.jsx(aa,{className:"size-4 text-cyan-300"}),"Sleep overlay"]}):le(t)?e.jsxs(e.Fragment,{children:[e.jsx(ia,{className:"size-4 text-[var(--primary)]"}),((h=t.stay.place)==null?void 0:h.label)??"No canonical place linked yet"]}):st(t)?e.jsxs(e.Fragment,{children:[e.jsx(tt,{className:"size-4 text-[var(--primary)]"}),t.trip.activityType||t.trip.travelMode]}):t.kind==="trip"?e.jsxs(e.Fragment,{children:[e.jsx(tt,{className:"size-4 text-[var(--primary)]"}),"Repaired movement connector"]}):e.jsxs(e.Fragment,{children:[e.jsx(pt,{className:"size-4 text-white/56"}),"Missing intervals are synthesized from long signal gaps instead of inventing fake travel."]})})]})}function Jt({title:t,points:a,averagePoint:s}){const i=ps(s?[...a,s]:a),c=s?i.length-1:i.length,r=i.slice(0,c),h=s?i[i.length-1]??null:null,o=r.map((m,p)=>`${p===0?"M":"L"} ${m.x} ${m.y}`).join(" ");return e.jsxs(v,{className:"rounded-[30px] border border-white/10 bg-[linear-gradient(180deg,rgba(8,13,25,0.95),rgba(10,17,30,0.88))] p-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/42",children:t}),e.jsx("div",{className:"mt-2 text-sm text-white/62",children:"Relative coordinates normalized into one view so we can inspect the actual captured stay or trip geometry in one glance."}),e.jsx("div",{className:"mt-5 rounded-[24px] border border-white/8 bg-[rgba(255,255,255,0.03)] p-3",children:e.jsxs("svg",{viewBox:"0 0 100 100",className:"h-52 w-full",children:[e.jsx("rect",{x:"0",y:"0",width:"100",height:"100",rx:"18",fill:"rgba(255,255,255,0.02)"}),r.length>1?e.jsx("path",{d:o,fill:"none",stroke:"rgba(92,225,230,0.95)",strokeWidth:"1.6"}):null,r.map((m,p)=>e.jsx("circle",{cx:m.x,cy:m.y,r:p===0||p===r.length-1?2.2:1.4,fill:p===0||p===r.length-1?"#ffffff":"rgba(92,225,230,0.9)"},m.id)),h?e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:h.x,cy:h.y,r:3,fill:"rgba(255,208,88,0.95)"}),e.jsx("circle",{cx:h.x,cy:h.y,r:6,fill:"none",stroke:"rgba(255,208,88,0.48)",strokeWidth:"1",strokeDasharray:"2 2"})]}):null]})})]})}function Rs({open:t,onOpenChange:a,segment:s,detail:i,loading:c,onEdit:r,onDefinePlace:h}){var N;const o=(i==null?void 0:i.segment)??s,m=(i==null?void 0:i.stayDetail)??null,p=(i==null?void 0:i.tripDetail)??null;return e.jsx(Re,{open:t,onOpenChange:a,children:e.jsxs(Oe,{children:[e.jsx(He,{className:"fixed inset-0 z-50 bg-[rgba(3,7,18,0.74)] backdrop-blur-sm"}),e.jsxs(Ke,{className:"fixed left-1/2 top-[6vh] z-50 max-h-[88vh] w-[min(60rem,calc(100vw-1.25rem))] -translate-x-1/2 overflow-y-auto rounded-[30px] border border-white/10 bg-[linear-gradient(180deg,rgba(8,14,28,0.98),rgba(10,16,30,0.95))] p-5 shadow-[0_32px_90px_rgba(0,0,0,0.45)]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(Be,{className:"font-display text-[1.3rem] tracking-[-0.05em] text-white",children:o?`${me(o)} details`:"Movement details"}),e.jsx(qe,{className:"mt-2 text-sm leading-6 text-white/62",children:"Inspect the canonical box, the raw movement evidence behind it, and the exact coordinates Forge used to assemble this stay or trip."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[o?e.jsxs(k,{onClick:r,variant:"ghost",className:"rounded-full border border-white/10 bg-white/[0.04] px-3 text-white/78 hover:bg-white/[0.08]",disabled:!o.editable||o.kind==="missing",children:[e.jsx(Mt,{className:"size-4"}),"Edit"]}):null,e.jsx(_e,{asChild:!0,children:e.jsx("button",{type:"button",className:"rounded-full border border-white/10 bg-white/[0.04] p-2 text-white/64 transition hover:bg-white/[0.08] hover:text-white",children:e.jsx(St,{className:"size-4 rotate-45"})})})]})]}),c?e.jsx("div",{className:"mt-6 rounded-[22px] border border-white/8 bg-white/[0.03] p-5 text-sm text-white/62",children:"Loading the canonical box detail and raw movement evidence…"}):o?e.jsxs("div",{className:"mt-6 grid gap-4",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsxs(v,{className:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/38",children:"Started"}),e.jsx("div",{className:"mt-2 text-sm text-white",children:pe(o.startedAt)})]}),e.jsxs(v,{className:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/38",children:"Ended"}),e.jsx("div",{className:"mt-2 text-sm text-white",children:pe(o.endedAt)})]}),e.jsxs(v,{className:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/38",children:"Duration"}),e.jsx("div",{className:"mt-2 text-sm text-white",children:ze(o.durationSeconds)})]}),e.jsxs(v,{className:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/38",children:"Raw coverage"}),e.jsxs("div",{className:"mt-2 text-sm text-white",children:[o.rawStayIds.length," stays · ",o.rawTripIds.length," trips · ",o.rawPointCount," points"]})]})]}),m?e.jsxs(e.Fragment,{children:[e.jsxs(v,{className:"rounded-[22px] border border-sky-300/14 bg-sky-300/8 p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-sky-100/66",children:"Location label"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-sky-50/86",children:m.canonicalPlace?`This stay is linked to ${m.canonicalPlace.label}. Search a different saved place or relabel it from the stay center.`:"This stay has no saved place yet. Search known locations first, or create a new place directly from the stay center."}),e.jsx("div",{className:"mt-3",children:e.jsx(k,{onClick:h,variant:"ghost",className:"rounded-full border border-sky-300/24 bg-sky-300/12 px-4 text-sky-50 hover:bg-sky-300/18",children:"Label location"})})]}),e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)]",children:[e.jsx(Jt,{title:"Stay positions",points:m.positions,averagePoint:m.averagePosition}),e.jsxs(v,{className:"rounded-[28px] border border-white/10 bg-white/[0.03] p-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/42",children:"Stay metrics"}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsxs("div",{className:"text-sm text-white/78",children:["Canonical place: ",((N=m.canonicalPlace)==null?void 0:N.label)??"Not linked yet"]}),e.jsxs("div",{className:"text-sm text-white/78",children:["Average position: ",m.averagePosition?Je(m.averagePosition.latitude,m.averagePosition.longitude):"Unavailable"]}),e.jsxs("div",{className:"text-sm text-white/78",children:["Radius: ",m.radiusMeters!=null?Te(m.radiusMeters):"Unavailable"]}),e.jsxs("div",{className:"text-sm text-white/78",children:["Samples: ",m.sampleCount]}),e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-black/10 p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/34",children:"Exact positions"}),e.jsx("div",{className:"mt-3 grid gap-2",children:m.positions.map((b,A)=>e.jsxs("div",{className:"text-sm text-white/74",children:[b.label??`Position ${A+1}`,": ",Je(b.latitude,b.longitude)]},`${b.recordedAt??"stay"}-${A}`))})]})]})]})]})]}):null,p?e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)]",children:[e.jsx(Jt,{title:"Travel map",points:p.positions}),e.jsxs(v,{className:"rounded-[28px] border border-white/10 bg-white/[0.03] p-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/42",children:"Trip metrics"}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsxs("div",{className:"text-sm text-white/78",children:["Start position: ",p.startPosition?Je(p.startPosition.latitude,p.startPosition.longitude):"Unavailable"]}),e.jsxs("div",{className:"text-sm text-white/78",children:["End position: ",p.endPosition?Je(p.endPosition.latitude,p.endPosition.longitude):"Unavailable"]}),e.jsxs("div",{className:"text-sm text-white/78",children:["Distance: ",Te(p.totalDistanceMeters)]}),e.jsxs("div",{className:"text-sm text-white/78",children:["Moving time: ",Yt(p.movingSeconds)]}),e.jsxs("div",{className:"text-sm text-white/78",children:["Idle time: ",Yt(p.idleSeconds)]}),e.jsxs("div",{className:"text-sm text-white/78",children:["Average speed: ",p.averageSpeedMps!=null?`${p.averageSpeedMps.toFixed(2)} m/s`:"Unavailable"]}),e.jsxs("div",{className:"text-sm text-white/78",children:["Max speed: ",p.maxSpeedMps!=null?`${p.maxSpeedMps.toFixed(2)} m/s`:"Unavailable"]}),e.jsxs("div",{className:"text-sm text-white/78",children:["Stops: ",p.stopCount]})]})]})]}):null]}):null]})]})})}function Os({open:t,segment:a,onOpenChange:s,onEdit:i,onOpenDetail:c,onDefinePlace:r}){return e.jsx(Re,{open:t,onOpenChange:s,children:e.jsxs(Oe,{children:[e.jsx(He,{className:"fixed inset-0 z-50 bg-[rgba(3,7,18,0.74)] backdrop-blur-sm"}),e.jsxs(Ke,{className:"fixed left-1/2 top-[6vh] z-50 max-h-[88vh] w-[min(36rem,calc(100vw-1.25rem))] -translate-x-1/2 overflow-y-auto rounded-[30px] outline-none",children:[e.jsx(Be,{className:"sr-only",children:a?`${me(a)} actions`:"Movement actions"}),e.jsx(qe,{className:"sr-only",children:"Inspect, edit, or label the selected movement box."}),a?e.jsx(zs,{segment:a,onEdit:i,onOpenDetail:c,onDefinePlace:r,onClose:()=>s(!1)}):null]})]})})}function Hs({open:t,onOpenChange:a,segment:s,places:i,loading:c,onSelectPlace:r,onCreatePlace:h}){const o=s?vt(s):null,[m,p]=x.useState("");x.useEffect(()=>{if(!t){p("");return}p(ye(s)??"")},[t,s]);const N=x.useMemo(()=>{if(!o)return[];const w=ue(m);return[...i].filter(T=>w.length===0?!0:gs(T).includes(w)).sort((T,F)=>{const H=ue(T.label),V=ue(F.label),_=w.length>0&&H.startsWith(w),Y=w.length>0&&V.startsWith(w);if(_!==Y)return _?-1:1;const Q=et(o.latitude,o.longitude,T.latitude,T.longitude),X=et(o.latitude,o.longitude,F.latitude,F.longitude);return Math.abs(Q-X)>1?Q-X:T.label.localeCompare(F.label)}).slice(0,6)},[i,m,o]),b=ue(m),A=N.some(w=>ue(w.label)===b),B=ye(s);return e.jsx(Re,{open:t,onOpenChange:a,children:e.jsxs(Oe,{children:[e.jsx(He,{className:"fixed inset-0 z-50 bg-[rgba(3,7,18,0.74)] backdrop-blur-sm"}),e.jsxs(Ke,{className:"fixed left-1/2 top-[8vh] z-50 max-h-[84vh] w-[min(38rem,calc(100vw-1.25rem))] -translate-x-1/2 overflow-y-auto rounded-[30px] border border-white/10 bg-[linear-gradient(180deg,rgba(8,14,28,0.98),rgba(10,16,30,0.95))] p-5 shadow-[0_32px_90px_rgba(0,0,0,0.45)]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(Be,{className:"font-display text-[1.3rem] tracking-[-0.05em] text-white",children:"Label stay location"}),e.jsx(qe,{className:"mt-2 text-sm leading-6 text-white/62",children:"Search saved locations by name first. If this stay is new, create a location from the stay center with latitude and longitude already filled in."})]}),e.jsx(_e,{asChild:!0,children:e.jsx("button",{type:"button",className:"rounded-full border border-white/10 bg-white/[0.04] p-2 text-white/64 transition hover:bg-white/[0.08] hover:text-white","aria-label":"Close location label dialog",children:e.jsx(Nt,{className:"size-4"})})})]}),o?e.jsxs("div",{className:"mt-5 rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(u,{tone:"signal",children:"Stay center"}),B?e.jsx(u,{className:"bg-white/[0.08] text-white/74",children:B}):null]}),e.jsxs("div",{className:"mt-3 grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-black/10 px-3 py-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/34",children:"Latitude"}),e.jsx("div",{className:"mt-1 text-sm text-white/82",children:o.latitude.toFixed(6)})]}),e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-black/10 px-3 py-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/34",children:"Longitude"}),e.jsx("div",{className:"mt-1 text-sm text-white/82",children:o.longitude.toFixed(6)})]})]})]}):e.jsx("div",{className:"mt-5 rounded-[22px] border border-amber-300/14 bg-amber-300/8 p-4 text-sm text-amber-50/86",children:"Forge can only label stays that already have a recorded stay center."}),e.jsxs("div",{className:"mt-5 grid gap-3",children:[e.jsx(P,{value:m,onChange:w=>p(w.target.value),placeholder:"Type a location name or create a new one"}),e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/42",children:"Known places"}),c?e.jsx("div",{className:"mt-3 text-sm text-white/58",children:"Loading saved places…"}):N.length>0?e.jsx("div",{className:"mt-3 grid gap-2",children:N.map(w=>{const T=o==null?null:et(o.latitude,o.longitude,w.latitude,w.longitude);return e.jsxs("button",{type:"button",onClick:()=>void r(w).then(F=>{F&&a(!1)}),className:"rounded-[18px] border border-white/8 bg-black/10 px-4 py-3 text-left transition hover:border-[var(--primary)]/40 hover:bg-white/[0.05]",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"text-sm text-white",children:w.label}),T!=null?e.jsxs(u,{className:"bg-white/[0.08] text-white/70",children:[Te(T)," away"]}):null]}),w.aliases.length>0||w.categoryTags.length>0?e.jsx("div",{className:"mt-1 text-xs text-white/52",children:[...w.aliases,...w.categoryTags].join(" · ")}):null]},w.id)})}):e.jsx("div",{className:"mt-3 text-sm text-white/58",children:"No saved place matches this stay yet."})]})]}),e.jsxs("div",{className:"mt-5 flex flex-wrap justify-end gap-2",children:[e.jsx(k,{variant:"ghost",onClick:()=>a(!1),className:"border border-white/10 bg-white/[0.04]",children:"Cancel"}),e.jsx(k,{onClick:()=>{!s||!o||h(s,A?"":m.trim())},disabled:!s||!o,children:b.length>0&&!A?`Create "${m.trim()}"`:"Create new location"})]})]})]})})}function Ks({open:t,segment:a,draft:s,creating:i,saving:c,preflight:r,preflightLoading:h,onDraftChange:o,onFitMissing:m,onSave:p,onOpenChange:N}){return e.jsx(Re,{open:t,onOpenChange:N,children:e.jsxs(Oe,{children:[e.jsx(He,{className:"fixed inset-0 z-50 bg-[rgba(3,7,18,0.74)] backdrop-blur-sm"}),e.jsxs(Ke,{className:"fixed left-1/2 top-[8vh] z-50 w-[min(34rem,calc(100vw-1.25rem))] -translate-x-1/2 rounded-[30px] border border-white/10 bg-[linear-gradient(180deg,rgba(8,14,28,0.98),rgba(10,16,30,0.95))] p-5 shadow-[0_32px_90px_rgba(0,0,0,0.45)]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(Be,{className:"font-display text-[1.3rem] tracking-[-0.05em] text-white",children:i?"Create movement box":"Edit movement box"}),e.jsx(qe,{className:"mt-2 text-sm leading-6 text-white/62",children:s?i?"Create a canonical user-defined stay, move, or missing-data box without mutating raw phone measurements.":`Adjust this user-defined ${s.kind} box. Automatic boxes stay immutable and can only be invalidated.`:"No segment selected."})]}),e.jsx(_e,{asChild:!0,children:e.jsx("button",{type:"button",className:"rounded-full border border-white/10 bg-white/[0.04] p-2 text-white/72 transition hover:bg-white/[0.08]",children:e.jsx(St,{className:"size-4 rotate-45"})})})]}),s?e.jsxs("div",{className:"mt-5 grid gap-4",children:[e.jsxs("label",{className:"grid gap-2 text-sm text-white/78",children:["Kind",e.jsx("div",{className:"grid grid-cols-3 gap-2",children:[["stay","Stay"],["trip","Move"],["missing","Missing"]].map(([b,A])=>e.jsx(k,{type:"button",variant:"ghost",className:O("border border-white/10 bg-white/[0.04] text-white hover:bg-white/[0.08]",s.kind===b?"ring-1 ring-[rgba(126,229,255,0.42)]":""),onClick:()=>o({...s,kind:b}),children:A},b))})]}),e.jsxs("label",{className:"grid gap-2 text-sm text-white/78",children:["Label",e.jsx(P,{value:s.label,onChange:b=>o({...s,label:b.target.value})})]}),s.kind!=="trip"?e.jsxs("label",{className:"grid gap-2 text-sm text-white/78",children:["Place",e.jsx(P,{value:s.placeLabel,onChange:b=>o({...s,placeLabel:b.target.value}),placeholder:"Home, Office, Riverside path..."})]}):null,e.jsxs("label",{className:"grid gap-2 text-sm text-white/78",children:["Tags",e.jsx(P,{value:s.tagsInput,onChange:b=>o({...s,tagsInput:b.target.value}),placeholder:"movement, social, errand"})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("label",{className:"grid gap-2 text-sm text-white/78",children:["Started",e.jsx(P,{type:"datetime-local",value:s.startedAtInput,onChange:b=>o({...s,startedAtInput:b.target.value})})]}),e.jsxs("label",{className:"grid gap-2 text-sm text-white/78",children:["Ended",e.jsx(P,{type:"datetime-local",value:s.endedAtInput,onChange:b=>o({...s,endedAtInput:b.target.value})})]})]}),e.jsxs(v,{className:"grid gap-3 border-white/10 bg-white/[0.03] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:"Overlap guidance"}),e.jsx(k,{type:"button",variant:"ghost",className:"border border-white/10 bg-white/[0.04] text-white hover:bg-white/[0.08]",onClick:m,disabled:!(r!=null&&r.nearestMissingStartedAt)||!(r!=null&&r.nearestMissingEndedAt),children:"Fit Missing Time"})]}),e.jsx("div",{className:"text-sm leading-6 text-white/62",children:h?"Checking visible overlaps and missing windows…":r!=null&&r.overlapsAnything?`This box overlaps ${r.affectedAutomaticBoxIds.length} automatic and ${r.affectedUserBoxIds.length} manual boxes. Saving will fully override ${r.fullyOverriddenUserBoxIds.length} manual boxes and trim ${r.trimmedUserBoxIds.length}.`:"No overlap in the currently visible timeline window."}),e.jsxs("div",{className:"grid gap-1 text-xs text-white/50",children:[e.jsxs("div",{children:["Visible range:"," ",r!=null&&r.visibleRangeStart&&(r!=null&&r.visibleRangeEnd)?`${pe(r.visibleRangeStart)} -> ${pe(r.visibleRangeEnd)}`:"Unavailable"]}),e.jsxs("div",{children:["Suggested missing slot:"," ",r!=null&&r.nearestMissingStartedAt&&(r!=null&&r.nearestMissingEndedAt)?`${pe(r.nearestMissingStartedAt)} -> ${pe(r.nearestMissingEndedAt)}`:"No missing interval in view"]})]})]})]}):null,e.jsxs("div",{className:"mt-6 flex items-center justify-end gap-3",children:[e.jsx(_e,{asChild:!0,children:e.jsx(k,{type:"button",variant:"ghost",className:"border border-white/10 bg-white/[0.04] text-white hover:bg-white/[0.08]",children:"Cancel"})}),e.jsxs(k,{onClick:p,disabled:!s||c,children:[e.jsx(Ia,{className:"size-4"}),c?"Saving…":i?"Create box":"Save changes"]})]})]})]})})}function ea({side:t,vertical:a,emphasized:s=!1}){return e.jsx("div",{className:O("absolute z-10 h-7 w-8 rounded-[12px] border bg-[linear-gradient(180deg,rgba(10,16,28,0.94),rgba(7,12,24,0.88))] shadow-[0_12px_30px_rgba(0,0,0,0.22)] backdrop-blur-sm",s?"border-[rgba(152,208,255,0.34)]":"border-white/10",t==="left"?"left-[8%]":t==="right"?"right-[8%]":"left-1/2 -translate-x-1/2",a==="top"?"top-0":"bottom-0")})}function Bs({layout:t,selected:a,onToggle:s}){var m,p,N,b;const{segment:i}=t,c=kt(i),r=t.displayHeight,h=i.kind==="stay"?c?"bg-[linear-gradient(180deg,rgba(39,127,173,0.28),rgba(16,51,79,0.22))] border-[rgba(138,227,255,0.28)]":"bg-[linear-gradient(180deg,rgba(98,130,238,0.22),rgba(18,34,79,0.22))] border-[rgba(152,208,255,0.24)]":"",o=i.kind==="trip"?{start:je(i,"start",{includeCoordinates:!1,useHistoryAnchorFallback:!0}),end:je(i,"end",{includeCoordinates:!1})}:null;return e.jsxs("div",{className:O("absolute left-0 w-full px-3 sm:px-6",a?"z-40":"z-10"),"data-testid":"movement-timeline-row","data-selected":a?"true":"false",style:{top:`${t.boxTop}px`,height:`${r}px`},children:[e.jsx("div",{className:"absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-[linear-gradient(180deg,rgba(255,255,255,0.02),rgba(255,255,255,0.08),rgba(255,255,255,0.02))]"}),e.jsx("div",{className:"relative h-full",children:i.kind==="trip"?e.jsxs(qt.div,{layout:!0,animate:{x:0},transition:{type:"spring",stiffness:240,damping:30},className:"absolute inset-x-0 top-0 h-full z-10",children:[o&&a?e.jsxs(e.Fragment,{children:[e.jsx(ea,{side:"center",vertical:"top",emphasized:!0}),e.jsx(ea,{side:"center",vertical:"bottom",emphasized:!0})]}):null,e.jsx($s,{fromSide:"center",toSide:"center",height:r,emphasized:a}),e.jsxs("button",{type:"button",onClick:s,className:O("group absolute top-1/2 max-w-[min(8rem,calc(100vw-8rem))] -translate-y-1/2 rounded-[16px] border border-white/8 bg-[linear-gradient(180deg,rgba(9,14,24,0.58),rgba(8,12,22,0.42))] px-2.5 py-2 text-left shadow-[0_12px_24px_rgba(0,0,0,0.14)] backdrop-blur-sm transition hover:border-white/14 sm:max-w-[9rem] sm:px-3","left-1/2 -translate-x-1/2",a?"ring-1 ring-[rgba(126,229,255,0.38)]":""),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-label text-[10px] uppercase tracking-[0.18em] text-white/34",children:"Move"}),e.jsx("div",{className:"text-[11px] tracking-[0.18em] text-white/44",children:ze(i.durationSeconds)})]}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-2",children:[e.jsx(u,{className:"bg-white/[0.08] text-white/74",children:Te(((m=i.trip)==null?void 0:m.distanceMeters)??0)}),(((p=i.trip)==null?void 0:p.stops.length)??0)>0?e.jsxs(u,{className:"bg-white/[0.08] text-white/74",children:[(N=i.trip)==null?void 0:N.stops.length," stop",((b=i.trip)==null?void 0:b.stops.length)===1?"":"s"]}):null]}),e.jsxs("div",{className:"mt-2 font-label text-[9px] uppercase tracking-[0.22em] text-white/28",children:[W(i.startedAt)," → ",W(i.endedAt)]})]})]}):e.jsx(qt.div,{layout:!0,animate:{x:0},transition:{type:"spring",stiffness:260,damping:28},className:"absolute top-0 left-1/2 z-10 w-[min(18.5rem,calc(100vw-3.25rem))] -translate-x-1/2 sm:w-[min(21rem,calc(100vw-5rem))]",children:e.jsxs("button",{type:"button",onClick:s,className:O("group relative w-full overflow-hidden rounded-[24px] border text-left shadow-[0_20px_52px_rgba(3,8,20,0.36)] transition sm:rounded-[30px]",h,a?"ring-1 ring-[rgba(126,229,255,0.42)]":"hover:border-white/22"),style:{minHeight:`${r}px`},children:[e.jsx(jt,{position:"top"}),e.jsx(jt,{position:"bottom"}),e.jsxs("div",{className:"relative z-10 flex h-full flex-col justify-between p-3.5 sm:p-5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(u,{tone:"signal",className:"bg-white/10 text-white/82",children:c?"Sleep":"Stay"}),e.jsx("div",{className:"text-[11px] tracking-[0.16em] text-white/46 sm:text-xs sm:tracking-[0.18em]",children:ze(i.durationSeconds)})]}),e.jsxs("div",{className:"mt-3 min-w-0 sm:mt-5",children:[e.jsx("div",{className:"truncate font-display text-[1rem] tracking-[-0.03em] text-white sm:text-[1.12rem]",children:me(i)}),i.kind==="stay"&&ye(i)&&!c?e.jsx("div",{className:"mt-2 flex flex-wrap gap-2 sm:mt-3",children:e.jsx(u,{className:"max-w-full truncate bg-white/[0.08] text-white/76",children:ye(i)})}):c?e.jsx("div",{className:"mt-2 flex flex-wrap gap-2 sm:mt-3",children:e.jsx(u,{className:"max-w-full truncate bg-cyan-400/12 text-cyan-50",children:i.subtitle})}):null]}),e.jsx("div",{className:"mt-auto pt-4 sm:pt-8",children:e.jsxs("div",{className:"font-label text-[9px] uppercase tracking-[0.2em] text-white/34 sm:text-[10px] sm:tracking-[0.22em]",children:[W(i.startedAt)," → ",W(i.endedAt)]})})]})]})})})]})}function qs({userIds:t=[]}){var Et,_t,zt;const a=ra(),s=x.useRef(null),i=x.useRef(null),c=x.useRef(null),r=x.useRef(!1),h=x.useRef(!1),o=x.useRef(null),[m,p]=x.useState(null),[N,b]=x.useState(!1),[A,B]=x.useState(!1),[w,T]=x.useState(null),[F,H]=x.useState({}),[V,_]=x.useState(null),[Y,Q]=x.useState(null),[X,Z]=x.useState(null),[Qe,Ce]=x.useState(null),[Pe,Le]=x.useState(!1),[Ue,Ne]=x.useState(!1),[nt,Se]=x.useState(null),[lt,De]=x.useState(null),[ae,q]=x.useState(!1),[se,ie]=x.useState(!1),[K,xe]=x.useState(!1),[y,We]=x.useState(""),[ge,Ge]=x.useState([]),[he,Ve]=x.useState(0),[z,Ie]=x.useState(0),Me=()=>{const l=s.current;l&&(Ve(l.scrollTop),Ie(l.clientHeight))},C=Rt({queryKey:["forge-movement-life-timeline",...t],initialPageParam:null,queryFn:({pageParam:l})=>Kt({before:l??void 0,limit:Wt,userIds:t}).then(d=>d.movement),getNextPageParam:l=>l.nextCursor??void 0,retry:!1,refetchOnWindowFocus:!1}),j=Rt({queryKey:["forge-movement-life-timeline-data",...t],initialPageParam:null,queryFn:({pageParam:l})=>Kt({before:l??void 0,includeInvalid:!0,limit:Wt,userIds:t}).then(d=>d.movement),getNextPageParam:l=>l.nextCursor??void 0,retry:!1,refetchOnWindowFocus:!1}),be=x.useMemo(()=>{var l;return((l=C.data)==null?void 0:l.pages.flatMap(d=>d.segments))??[]},[C.data]),de=x.useMemo(()=>{var l;return((l=j.data)==null?void 0:l.pages.flatMap(d=>d.segments))??[]},[j.data]),oe=x.useMemo(()=>{var l;return((l=C.data)==null?void 0:l.pages.reduce((d,g)=>Math.max(d,g.invalidSegmentCount??0),0))??0},[C.data]),S=x.useMemo(()=>[...be].reverse(),[be]),J=x.useMemo(()=>[...de].reverse(),[de]),$e=x.useMemo(()=>{var d;const l=new Map;for(const g of((d=C.data)==null?void 0:d.pages)??[])for(const E of g.sleepOverlays??[])l.set(E.id,E);return[...l.values()].sort((g,E)=>new Date(g.startedAt).getTime()-new Date(E.startedAt).getTime())},[C.data]),fe=x.useMemo(()=>xs(S,$e),[S,$e]),M=x.useMemo(()=>K?fe:S,[S,fe,K]),Fe=x.useMemo(()=>fe.filter(l=>l.syncSource==="sleep overlay"),[fe]),re=((Et=Fe.at(-1))==null?void 0:Et.id)??null,n=x.useMemo(()=>M.find(l=>l.id===X)??null,[X,M]),f=x.useMemo(()=>M.find(l=>l.id===m)??null,[M,m]),ee=te({queryKey:["forge-movement-box-detail",(n==null?void 0:n.boxId)??null,...t],queryFn:async()=>n!=null&&n.boxId?(await za(n.boxId,t)).movement:null,enabled:!!(n!=null&&n.boxId)}),U=x.useMemo(()=>S.find(l=>l.id===Qe)??null,[Qe,S]),ne=te({queryKey:["forge-movement-places",...t],queryFn:async()=>(await ca(t)).places,retry:!1,refetchOnWindowFocus:!1}),I=x.useMemo(()=>Ds({segments:M,viewportHeight:z}),[M,z]),dt=x.useMemo(()=>new Map(I.items.map(l=>[l.segment.id,l])),[I.items]),ba=x.useMemo(()=>{const l=Math.max(0,he-Gt),d=he+Math.max(z,G*8)+Gt;return I.items.filter(g=>g.segment.id===m?!0:g.boxBottom>=l&&g.boxTop<=d)},[he,m,I.items,z]),Tt=x.useMemo(()=>Es(I,he,z),[he,I,z]),fa=()=>{var d;const l=(d=c.current)==null?void 0:d.getBoundingClientRect();if(!l){B(g=>!g);return}T({top:l.bottom+10,right:Math.max(12,window.innerWidth-l.right)}),B(g=>!g)},va=x.useMemo(()=>[{id:"add-box",label:"Add box",description:"Create a user-defined stay, move, or missing-data interval.",icon:Ca,onSelect:()=>Q(ut("stay",S.at(-1)??null))},{id:"sleep",label:K?"Hide sleep":"Show sleep",description:"Toggle sleep overlays without rewriting the movement boxes.",icon:aa,onSelect:()=>xe(l=>{const d=!l;return d&&re&&(p(re),b(!0)),d})},{id:"view-data",label:"View data",description:"Open the canonical loaded records and raw-data filters.",icon:pt,onSelect:()=>q(!0)}],[re,S,K]),Ct=(l,d="smooth")=>{const g=s.current,E=dt.get(l);if(!g||!E)return;const Ee=Math.max(0,E.boxTop-g.clientHeight/2+E.displayHeight/2);if(typeof g.scrollTo=="function"){g.scrollTo({top:Ee,behavior:d});return}g.scrollTop=Ee};x.useEffect(()=>{ae&&(!j.hasNextPage||j.isFetchingNextPage||j.fetchNextPage())},[ae,j.fetchNextPage,j.hasNextPage,j.isFetchingNextPage]),x.useEffect(()=>{const l=M.at(-1);!h.current&&l&&(h.current=!0,p(l.id))},[M]),x.useEffect(()=>{if(!r.current&&M.length>0){r.current=!0,requestAnimationFrame(()=>{var d;const l=(d=M[M.length-1])==null?void 0:d.id;l&&Ct(l,"auto"),requestAnimationFrame(()=>{Me()})});return}if(o.current&&M.length>o.current.count&&s.current){const l=o.current;o.current=null,requestAnimationFrame(()=>{const d=s.current;if(!d)return;const g=I.totalHeight-l.size;d.scrollTop+=g,Me()})}},[M.length,I.totalHeight,dt]),x.useEffect(()=>{if(!s.current)return;const d=()=>{Me()};return d(),window.addEventListener("resize",d),()=>window.removeEventListener("resize",d)},[]),x.useEffect(()=>{if(!m)return;const l=S.find(d=>d.id===m);l&&H(d=>d[m]?d:{...d,[m]:wt(l)})},[S,m]),x.useEffect(()=>{var l;m&&(M.some(d=>d.id===m)||(p(((l=M.at(-1))==null?void 0:l.id)??null),b(!1)))},[M,m]),x.useEffect(()=>{if(!K||!re)return;const l=M.findIndex(d=>d.id===re);l<0||(p(re),requestAnimationFrame(()=>{var g;const d=(g=M[l])==null?void 0:g.id;d&&Ct(d)}))},[M,re,K,dt]);const ot=async()=>{await Promise.all([a.invalidateQueries({queryKey:["forge-movement-life-timeline"]}),a.invalidateQueries({queryKey:["forge-movement-life-timeline-data"]}),a.invalidateQueries({queryKey:["forge-movement-box-detail"]}),a.invalidateQueries({queryKey:["forge-movement-day"]}),a.invalidateQueries({queryKey:["forge-movement-month"]}),a.invalidateQueries({queryKey:["forge-movement-all-time"]}),a.invalidateQueries({queryKey:["forge-movement-places"]}),a.invalidateQueries({queryKey:["forge-psyche-self-observation-calendar"]})])},Pt=ke({mutationFn:async l=>{const{segment:d,draft:g,creating:E}=l,Ee=yt(g,d);if(E){await Ot(Ee,t);return}if(!d)throw new Error("No movement box selected.");if(d.sourceKind!=="user_defined")throw new Error("Automatic movement boxes are immutable. Invalidate them into missing data or create a user-defined override instead.");await Ht(d.boxId,{...Ee,metadata:{updatedFrom:"movement-life-timeline"}},t)},onSuccess:ot}),wa=async(l,d)=>{if(l.kind!=="stay")throw new Error("Only stays can be linked to a saved place.");const g=js(l,d.label);if(l.sourceKind==="user_defined"){await Ht(l.boxId,{...g,metadata:{updatedFrom:"movement-life-timeline-place-label"}},t);return}await Ot({...g,metadata:{createdFrom:"movement-life-timeline-place-label"}},t)},Lt=async(l,d)=>{if(l.rawStayIds.length===0)throw new Error("This stay has no raw stay ids to relabel.");await Promise.all(l.rawStayIds.map(g=>_a(g,{placeExternalUid:d.externalUid,placeLabel:d.label})))},ya=(l,d)=>{const g=vt(l);if(!g)return!0;const E=et(g.latitude,g.longitude,d.latitude,d.longitude);return E<=100||typeof window>"u"||typeof window.confirm!="function"?!0:window.confirm(`"${d.label}" is ${Te(E)} away from this stay's recorded center. Link it anyway?`)},ja=ke({mutationFn:async l=>{const{segment:d,...g}=l,E=await na(g,t);return d&&le(d)&&await Lt(d,E.place),E},onSuccess:ot}),Na=ke({mutationFn:async l=>{const{segment:d,place:g}=l;if(!ya(d,g))return{assigned:!1};if(le(d))return await Lt(d,g),{assigned:!0};if(d.kind!=="stay")throw new Error("Only stays can be linked to a saved place.");return await wa(d,g),{assigned:!0}},onSuccess:async l=>{l.assigned&&await ot()}}),ct=ke({mutationFn:async l=>{if(l.sourceKind==="user_defined"){await Fa(l.boxId,t);return}await Ea(l.boxId,{title:"User invalidated automatic movement",subtitle:`Overrides ${me(l)} with missing data.`},t)},onSuccess:async(l,d)=>{p(g=>g===d.id?null:g),b(!1),_(g=>g===d.id?null:g),a.setQueryData(["forge-movement-life-timeline",...t],g=>Zt(g,d.id)),a.setQueryData(["forge-movement-life-timeline-data",...t],g=>Zt(g,d.id)),await Promise.all([a.invalidateQueries({queryKey:["forge-movement-life-timeline"]}),a.invalidateQueries({queryKey:["forge-movement-life-timeline-data"]}),a.invalidateQueries({queryKey:["forge-movement-day"]}),a.invalidateQueries({queryKey:["forge-movement-month"]}),a.invalidateQueries({queryKey:["forge-movement-all-time"]}),a.invalidateQueries({queryKey:["forge-movement-selection"]}),a.invalidateQueries({queryKey:["forge-psyche-self-observation-calendar"]})])}}),Sa=x.useMemo(()=>Ss(J),[J]),ve=x.useMemo(()=>{const l=ue(y);return[...J].sort((d,g)=>new Date(g.endedAt).getTime()-new Date(d.endedAt).getTime()).filter(d=>(l.length===0||Ns(d).includes(l))&&Ms(d,ge))},[J,y,ge]),Dt=x.useMemo(()=>J.length===0?"No movement records loaded yet.":ve.length===J.length&&y.trim().length===0&&ge.length===0?`${J.length} loaded movement records visible`:`${ve.length} of ${J.length} loaded records visible`,[J.length,ve.length,y,ge.length]),mt=sa({count:ve.length,getScrollElement:()=>i.current,estimateSize:()=>136,overscan:8}),L=V?S.find(l=>l.id===V)??null:null,Ma=L?F[L.id]??wt(L):null,Ye=Y!==null,$=Y??Ma,It=((_t=S[0])==null?void 0:_t.startedAt)??null,$t=((zt=S[S.length-1])==null?void 0:zt.endedAt)??null,xt=te({queryKey:["forge-movement-user-box-preflight",(L==null?void 0:L.boxId)??"create",($==null?void 0:$.kind)??null,($==null?void 0:$.startedAtInput)??null,($==null?void 0:$.endedAtInput)??null,It,$t,...t],enabled:$!==null&&at($.startedAtInput)!==null&&at($.endedAtInput)!==null,queryFn:async()=>{if(!$)return null;const l=yt($,L);return(await Ra({...l,excludeBoxId:(L==null?void 0:L.sourceKind)==="user_defined"?L.boxId:null,rangeStart:It,rangeEnd:$t},t)).preflight}}),Ft=l=>{le(l)&&(Ce(l.id),Le(!0))},ka=(l,d)=>{const g=vt(l);g&&(Le(!1),Ce(l.id),Se({...g,label:d.trim()||g.label}),De(l.id),Ne(!0))},Aa=()=>{const l=s.current;l&&(Ve(l.scrollTop),Ie(l.clientHeight),!(!C.hasNextPage||C.isFetchingNextPage)&&l.scrollTop<=960&&(o.current={count:M.length,size:I.totalHeight},C.fetchNextPage()))};if(C.isPending)return e.jsx(la,{eyebrow:"Movement",title:"Loading life timeline",description:"Reconstructing the longer road of stays, moves, and places.",columns:1,blocks:6});if(C.isError)return e.jsx(da,{eyebrow:"Movement",error:C.error,onRetry:()=>void C.refetch()});const Ta=I.totalHeight;return e.jsxs("section",{className:"grid gap-4",children:[e.jsxs(v,{className:"overflow-hidden rounded-[28px] border border-white/8 bg-[radial-gradient(circle_at_top,rgba(88,182,255,0.08),transparent_28%),linear-gradient(180deg,rgba(4,8,17,0.99),rgba(5,9,18,0.97))] p-3 sm:rounded-[34px] sm:p-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3 px-1",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.22em] text-white/34",children:"Movement"}),e.jsxs("div",{className:"flex min-w-0 items-center justify-end gap-2",children:[oe>0?e.jsxs(u,{className:"hidden bg-amber-500/10 text-amber-100 sm:inline-flex",children:[oe," invalid hidden"]}):null,e.jsxs(u,{className:"hidden bg-white/[0.06] text-white/68 sm:inline-flex",children:[M.length," visible"]}),e.jsx("div",{ref:c,children:e.jsxs(k,{type:"button",variant:"ghost",size:"sm","aria-expanded":A,"aria-haspopup":"dialog",className:O("h-9 rounded-full border border-white/10 bg-white/[0.05] px-3 text-white/78 hover:bg-white/[0.1] hover:text-white",A?"ring-1 ring-[rgba(126,229,255,0.34)]":""),onClick:fa,children:[e.jsx(Pa,{className:"size-4"}),"Actions"]})})]})]}),e.jsx(_s,{open:A,anchor:w,items:va,onClose:()=>B(!1)}),K&&Fe.length===0?e.jsx("p",{className:"mb-3 px-1 text-sm text-amber-100/80",children:"No sleep session overlaps the currently loaded timeline range yet. Scroll further back to load older history."}):null,e.jsxs("div",{ref:s,onScroll:Aa,className:"relative h-[82vh] overflow-auto rounded-[30px] border border-white/8 bg-[linear-gradient(180deg,rgba(4,7,15,0.98),rgba(6,10,18,0.96))]",children:[e.jsx(Is,{layout:I,scrollTop:he,viewportHeight:z}),Tt?e.jsx("div",{className:"pointer-events-none sticky top-3 z-50 flex h-0 justify-center",children:e.jsx("div",{className:"rounded-full border border-white/10 bg-[rgba(8,13,24,0.86)] px-3 py-1.5 font-label text-[10px] uppercase tracking-[0.18em] text-white/70 shadow-[0_16px_36px_rgba(0,0,0,0.28)] backdrop-blur-xl",children:Tt})}):null,e.jsxs("div",{className:"relative",style:{height:`${Ta}px`},children:[I.historyHeaderHeight>0?e.jsx("div",{className:"absolute inset-x-0 top-0",style:{height:`${I.historyHeaderHeight}px`},children:e.jsx(Fs,{segment:M[0]??null})}):null,ba.map(l=>{const d=l.segment;return e.jsx(Bs,{layout:l,selected:m===d.id,onToggle:()=>{p(d.id),b(!0)}},d.id)})]})]})]}),e.jsx(Ks,{open:L!==null||Y!==null,segment:L,draft:$,creating:Ye,saving:Pt.isPending,preflight:xt.data??null,preflightLoading:xt.isFetching,onDraftChange:l=>{if(Ye){Q(l);return}L&&H(d=>({...d,[L.id]:l}))},onFitMissing:()=>{const l=xt.data;if(!(l!=null&&l.nearestMissingStartedAt)||!l.nearestMissingEndedAt)return;const d={...$??ut("stay",L),startedAtInput:Ae(l.nearestMissingStartedAt),endedAtInput:Ae(l.nearestMissingEndedAt)};if(Ye){Q(d);return}L&&H(g=>({...g,[L.id]:d}))},onSave:()=>{$&&Pt.mutateAsync({segment:L,draft:$,creating:Ye},{onSuccess:()=>{_(null),Q(null),se&&(ie(!1),q(!0))}})},onOpenChange:l=>{l||(_(null),Q(null),se&&(ie(!1),q(!0)))}}),e.jsx(Os,{open:N&&f!==null,onOpenChange:l=>{b(l)},segment:f,onEdit:()=>{f!=null&&f.editable&&(_(f.id),b(!1))},onOpenDetail:()=>{f&&(Z(f.id),b(!1))},onDefinePlace:()=>{f&&(Ft(f),b(!1))}}),e.jsx(Rs,{open:n!==null,onOpenChange:l=>{l||Z(null)},segment:n,detail:ee.data??null,loading:ee.isFetching,onEdit:()=>{!n||!n.editable||(_(n.id),Z(null))},onDefinePlace:()=>{n&&Ft(n)}}),e.jsx(Hs,{open:Pe,onOpenChange:l=>{Le(l),l||Ce(null)},segment:U,places:ne.data??[],loading:ne.isFetching,onSelectPlace:async l=>U?(await Na.mutateAsync({segment:U,place:l})).assigned:!1,onCreatePlace:(l,d)=>{ka(l,d)}}),e.jsx(xa,{open:Ue,onOpenChange:l=>{Ne(l),l||(Se(null),De(null))},place:null,seed:nt,onSave:async l=>{await ja.mutateAsync({...l,segment:S.find(d=>d.id===lt)??null})}}),e.jsx(oa,{open:ae,onOpenChange:l=>{q(l),l||se||(We(""),Ge([]))},eyebrow:"Movement data",title:"View data",description:"",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsx(ma,{title:"",description:"",query:y,onQueryChange:We,options:Sa,selectedOptionIds:ge,onSelectedOptionIdsChange:Ge,resultSummary:Dt,placeholder:"Search movement labels, places, times, tags, or add time and kind filters",emptyStateMessage:"Keep typing or pick filters to narrow the movement history."}),e.jsxs(v,{className:"grid gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Canonical boxes"}),e.jsx("div",{className:"max-w-3xl text-sm leading-6 text-white/56",children:"This list shows the canonical movement boxes projected by Forge. Automatic boxes are derived from immutable raw phone measurements. User-defined boxes override the projection without mutating raw movement data."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{type:"button",variant:"ghost",size:"sm",className:"h-8 rounded-full border border-white/10 bg-white/[0.04] px-3 text-white/70",onClick:()=>{ie(!0),q(!1),Q(ut("stay",ve.at(-1)??null))},children:"Add box"}),e.jsx(u,{tone:"meta",children:Dt}),oe>0?e.jsxs(u,{className:"bg-amber-500/10 text-amber-100",children:[oe," invalid hidden included"]}):null,j.hasNextPage?e.jsx(k,{type:"button",variant:"ghost",size:"sm",className:"h-8 rounded-full border border-white/10 bg-white/[0.04] px-3 text-white/70",pending:j.isFetchingNextPage,pendingLabel:"Loading…",onClick:()=>void j.fetchNextPage(),children:"Load older"}):null]})]}),e.jsx("div",{ref:i,className:"h-[36rem] overflow-y-auto rounded-[24px] border border-white/8 bg-white/[0.03]",children:ve.length===0?e.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center text-sm leading-6 text-white/50",children:"No movement record matches the current search. Clear filters or load older timeline history."}):e.jsx("div",{className:"relative w-full",style:{height:`${mt.getTotalSize()}px`},children:mt.getVirtualItems().map(l=>{var g;const d=ve[l.index];return e.jsx("div",{ref:mt.measureElement,"data-index":l.index,className:"absolute left-0 top-0 w-full px-3 py-2",style:{transform:`translateY(${l.start}px)`},children:e.jsxs("div",{className:"flex items-start gap-2 rounded-[18px] border border-white/8 bg-white/[0.04] px-3 py-2.5",children:[e.jsx("button",{type:"button",className:"min-w-0 flex-1 text-left transition hover:opacity-100",onClick:()=>{d.editable&&(ie(!0),q(!1),_(d.id))},children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white",children:[d.kind==="stay"?e.jsx(ia,{className:"size-3.5 shrink-0 text-[var(--primary)]"}):d.kind==="missing"?e.jsx(pt,{className:"size-3.5 shrink-0 text-slate-300/80"}):e.jsx(tt,{className:"size-3.5 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate text-sm font-medium",children:me(d)})]}),e.jsxs("div",{className:"mt-1 text-xs text-white/56",children:[it(d.startedAt)," →"," ",it(d.endedAt)]})]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap justify-end gap-1.5",children:[e.jsx(u,{tone:d.kind==="trip"?"signal":"meta",children:d.kind==="trip"?"Move":d.kind==="missing"?"Missing":"Stay"}),e.jsx(u,{className:d.sourceKind==="user_defined"?"bg-fuchsia-400/12 text-fuchsia-100":"bg-white/[0.06] text-white/70",children:d.sourceKind==="user_defined"?d.origin==="user_invalidated"?"User invalidated":"User-defined":"Automatic"}),e.jsx(u,{tone:"meta",children:ze(d.durationSeconds)}),d.origin==="continued_stay"?e.jsx(u,{className:"bg-sky-400/10 text-sky-100",children:"Continued stay"}):null,d.origin==="repaired_gap"?e.jsx(u,{className:"bg-amber-400/10 text-amber-100",children:"Repaired"}):null,d.kind==="missing"?e.jsx(u,{className:"bg-slate-300/10 text-slate-100",children:"Missing"}):null,d.isInvalid?e.jsx(u,{className:"bg-amber-500/10 text-amber-100",children:"Invalid"}):null,d.placeLabel?e.jsx(u,{tone:"default",children:d.placeLabel}):null,d.overrideCount>0?e.jsxs(u,{className:"bg-amber-400/10 text-amber-100",children:["Overrides ",d.overrideCount]}):null,e.jsxs(u,{className:"bg-white/[0.06] text-white/66",children:["Raw stays ",d.rawStayIds.length]}),e.jsxs(u,{className:"bg-white/[0.06] text-white/66",children:["Raw trips ",d.rawTripIds.length]}),e.jsxs(u,{className:"bg-white/[0.06] text-white/66",children:["Raw points ",d.rawPointCount]}),d.hasLegacyCorrections?e.jsx(u,{className:"bg-amber-400/10 text-amber-100",children:"Legacy corrections"}):null]})]})}),e.jsx(k,{type:"button",variant:"ghost",size:"sm",className:O("h-8 shrink-0 rounded-full border px-2.5",d.sourceKind==="user_defined"?"border-rose-400/22 bg-rose-500/10 text-rose-100 hover:bg-rose-500/18":"border-amber-400/22 bg-amber-500/10 text-amber-100 hover:bg-amber-500/18"),pending:ct.isPending&&((g=ct.variables)==null?void 0:g.id)===d.id,pendingLabel:"",onClick:()=>{window.confirm(d.sourceKind==="user_defined"?`Delete ${me(d)} and remove this user-defined box from every synced surface?`:`Invalidate ${me(d)} into missing data and hide the automatic box everywhere?`)&&ct.mutateAsync(d)},children:e.jsx(La,{className:"size-3.5"})})]})},d.id)})})})]})]})})]})}function Qs(t){return new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"short"}).format(new Date(t))}function Us(t,a){const s=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"});return`${s.format(new Date(t))} - ${s.format(new Date(a))}`}function R(t){return t>=3600?`${(t/3600).toFixed(1)}h`:`${Math.round(t/60)}m`}function we(t){return t>=1e3?`${(t/1e3).toFixed(1)} km`:`${Math.round(t)} m`}function Ws(t,a){return t==="distanceMeters"?we(a):t==="caloriesKcal"?`${Math.round(a)} kcal`:R(a)}function ga(t){return t.trim().toLowerCase()}function rt(t){const a=new Date(t).getHours();return a<6?"night":a<12?"morning":a<18?"afternoon":"evening"}function At(t){return new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}).format(new Date(t))}function Gs(t){const a=new Date(t);return Number.isNaN(a.getTime())?"":new Date(a.getTime()-a.getTimezoneOffset()*6e4).toISOString().slice(0,16)}function ta(t){return{recordedAt:Gs(t.recordedAt),latitude:String(t.latitude),longitude:String(t.longitude),accuracyMeters:t.accuracyMeters!=null?String(t.accuracyMeters):"",altitudeMeters:t.altitudeMeters!=null?String(t.altitudeMeters):"",speedMps:t.speedMps!=null?String(t.speedMps):"",isStopAnchor:t.isStopAnchor}}function Vs(t){return ga([At(t.recordedAt),t.externalUid,t.isStopAnchor?"stop anchor stop":"path trace point",t.accuracyMeters!=null?`${Math.round(t.accuracyMeters)} meters accuracy`:"",rt(t.recordedAt)].join(" "))}function Ys(t){const a=new Map;return a.set("anchor:stop",{id:"anchor:stop",label:"Stop anchors",description:"Only the canonical pause anchors",badge:e.jsx(u,{tone:"meta",children:"Stop anchors"})}),a.set("anchor:path",{id:"anchor:path",label:"Path points",description:"Non-anchor trace points",badge:e.jsx(u,{tone:"meta",children:"Path points"})}),a.set("accuracy:precise",{id:"accuracy:precise",label:"Precise",description:"GPS accuracy below 20m",badge:e.jsx(u,{tone:"meta",children:"Precise"})}),a.set("accuracy:loose",{id:"accuracy:loose",label:"Loose accuracy",description:"GPS accuracy at or above 20m",badge:e.jsx(u,{tone:"meta",children:"Loose accuracy"})}),t.forEach(s=>{const i=rt(s.recordedAt);a.has(`time:${i}`)||a.set(`time:${i}`,{id:`time:${i}`,label:i,description:"Recorded during this time band",badge:e.jsx(u,{tone:"meta",className:"capitalize",children:i})})}),[...a.values()]}function Xs(t,a){return a.every(s=>s==="anchor:stop"?t.isStopAnchor:s==="anchor:path"?!t.isStopAnchor:s==="accuracy:precise"?t.accuracyMeters!=null&&t.accuracyMeters<20:s==="accuracy:loose"?t.accuracyMeters==null||t.accuracyMeters>=20:s.startsWith("time:")?rt(t.recordedAt)===s.slice(5):!0)}function Zs(t){if(t.length===0)return[];const a=Math.min(...t.map(o=>o.latitude)),s=Math.max(...t.map(o=>o.latitude)),i=Math.min(...t.map(o=>o.longitude)),c=Math.max(...t.map(o=>o.longitude)),r=Math.max(s-a,1e-4),h=Math.max(c-i,1e-4);return t.map(o=>({x:12+(o.longitude-i)/h*76,y:12+(1-(o.latitude-a)/r)*76}))}function Js({curve:t,startLabel:a,endLabel:s,stopLabels:i}){const c=t.map((r,h)=>`${h===0?"M":"Q"} ${r.x} ${r.y}`).join(" ");return e.jsxs(v,{className:"overflow-hidden rounded-[30px] border border-white/10 bg-[radial-gradient(circle_at_top,rgba(114,204,255,0.18),transparent_44%),linear-gradient(180deg,rgba(6,11,26,0.98),rgba(8,14,28,0.92))] p-5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/42",children:"Stylized trajectory"}),e.jsx(ce,{content:"This graph is a softened trip trace. It emphasizes rhythm, stops, and endpoints instead of raw GPS jitter."})]}),e.jsx("div",{className:"mt-2 text-sm text-white/64",children:"A softened path that prioritizes rhythm, stops, and landmarks over raw map noise."})]}),e.jsxs(u,{tone:"signal",children:[a," → ",s]})]}),e.jsxs("div",{className:"mt-5 rounded-[26px] border border-white/8 bg-[rgba(255,255,255,0.03)] p-4",children:[e.jsxs("svg",{viewBox:"0 0 100 60",className:"h-48 w-full",children:[e.jsx("defs",{children:e.jsxs("filter",{id:"movementGlow",children:[e.jsx("feGaussianBlur",{stdDeviation:"1.8",result:"blur"}),e.jsxs("feMerge",{children:[e.jsx("feMergeNode",{in:"blur"}),e.jsx("feMergeNode",{in:"SourceGraphic"})]})]})}),e.jsx("path",{d:c,fill:"none",stroke:"rgba(255,255,255,0.86)",strokeWidth:"1.5",strokeDasharray:"2.8 2.8",filter:"url(#movementGlow)"}),t.map((r,h)=>e.jsx("g",{children:e.jsx("circle",{cx:r.x,cy:r.y,r:h===0||h===t.length-1?2.6:1.6,fill:h===0||h===t.length-1?"#ffffff":"rgba(170,229,255,0.96)"})},`${r.x}-${r.y}-${h}`))]}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:i.map(r=>e.jsx(u,{tone:"default",className:"bg-white/[0.06] text-white/74",children:r},r))})]})]})}function ei({points:t}){const a=Zs(t),s=a.map((i,c)=>`${c===0?"M":"L"} ${i.x} ${i.y}`).join(" ");return e.jsxs(v,{className:"rounded-[30px] border border-white/10 bg-[linear-gradient(180deg,rgba(8,13,25,0.95),rgba(10,17,30,0.88))] p-5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/42",children:"Exact path"}),e.jsx(ce,{content:"This keeps the recent raw location points. Use it when you want the literal recorded trace instead of the cleaned movement graph."})]}),e.jsx("div",{className:"mt-2 text-sm text-white/62",children:"Recent raw points preserved by the companion before long-term simplification."}),e.jsx("div",{className:"mt-5 rounded-[24px] border border-white/8 bg-[rgba(255,255,255,0.03)] p-3",children:e.jsxs("svg",{viewBox:"0 0 100 100",className:"h-52 w-full",children:[e.jsx("rect",{x:"0",y:"0",width:"100",height:"100",rx:"18",fill:"rgba(255,255,255,0.02)"}),e.jsx("path",{d:s,fill:"none",stroke:"rgba(92,225,230,0.95)",strokeWidth:"1.6"}),a.map((i,c)=>e.jsx("circle",{cx:i.x,cy:i.y,r:c===0||c===a.length-1?2:1.1,fill:c===0||c===a.length-1?"#ffffff":"rgba(92,225,230,0.9)"},`${i.x}-${i.y}-${c}`))]})})]})}function ti({point:t,draft:a}){return e.jsxs(v,{className:"grid gap-4 rounded-[28px] border border-white/8 bg-[linear-gradient(180deg,rgba(12,18,32,0.98),rgba(8,13,24,0.98))] p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/42",children:"Raw datapoint"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:At(t.recordedAt)}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:"Raw phone measurements are immutable in product UI. To change the visible movement story, create or edit user-defined boxes in the Life Timeline instead."})]}),e.jsx(u,{tone:t.isStopAnchor?"signal":"meta",children:t.isStopAnchor?"Stop anchor":"Path point"})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-white/40",children:"Recorded at"}),e.jsx(P,{type:"datetime-local",value:a.recordedAt,disabled:!0})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-white/40",children:"Speed (m/s)"}),e.jsx(P,{value:a.speedMps,disabled:!0,placeholder:"Optional"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-white/40",children:"Latitude"}),e.jsx(P,{value:a.latitude,disabled:!0})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-white/40",children:"Longitude"}),e.jsx(P,{value:a.longitude,disabled:!0})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-white/40",children:"Accuracy (m)"}),e.jsx(P,{value:a.accuracyMeters,disabled:!0,placeholder:"Optional"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-white/40",children:"Altitude (m)"}),e.jsx(P,{value:a.altitudeMeters,disabled:!0,placeholder:"Optional"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(k,{variant:"ghost",className:O("h-10 rounded-full border px-4",a.isStopAnchor?"border-[var(--primary)] bg-[var(--primary)]/16 text-white":"border-white/10 bg-white/[0.04] text-white/64"),disabled:!0,children:[e.jsx(tt,{className:"mr-2 size-4"}),a.isStopAnchor?"Stop anchor":"Path point"]}),e.jsxs("div",{className:"text-sm text-white/50",children:["External id: ",e.jsx("span",{className:"text-white/72",children:t.externalUid})]})]}),e.jsx("div",{className:"rounded-[20px] border border-white/8 bg-white/[0.03] px-4 py-3 text-sm leading-6 text-white/56",children:"This browser is read-only now. Raw points stay immutable so the web app and iPhone can both project the same repaired canonical boxes from the backend."})]})}function hi(){var $e,fe,M,Fe,re;const t=Oa(),a=ra(),s=Array.isArray(t.selectedUserIds)?t.selectedUserIds:[],[i,c]=x.useState("life"),[r,h]=x.useState(new Date().toISOString().slice(0,10)),[o,m]=x.useState(new Date().toISOString().slice(0,7)),[p,N]=x.useState(null),[b,A]=x.useState(!1),[B,w]=x.useState(!1),[T,F]=x.useState(""),[H,V]=x.useState([]),[_,Y]=x.useState(null),[Q,X]=x.useState(null),[Z,Qe]=x.useState({stayIds:[],tripIds:[]}),[Ce,Pe]=x.useState(!1),[Le,Ue]=x.useState(null),[Ne,nt]=x.useState(""),[Se,lt]=x.useState("distanceMeters"),De=x.useRef(null),ae=te({queryKey:["forge-movement-day",r,...s],queryFn:async()=>(await Ga({date:r,userIds:s})).movement}),q=te({queryKey:["forge-movement-month",o,...s],queryFn:async()=>(await Va({month:o,userIds:s})).movement}),se=te({queryKey:["forge-movement-all-time",...s],queryFn:async()=>(await Ya(s)).movement}),ie=te({queryKey:["forge-life-force",...s],queryFn:async()=>(await Xa(s)).lifeForce}),K=te({queryKey:["forge-movement-settings",...s],queryFn:async()=>(await Za(s)).settings}),xe=te({queryKey:["forge-movement-places",...s],queryFn:async()=>(await ca(s)).places}),y=te({queryKey:["forge-movement-trip",p],queryFn:async()=>p?(await Ja(p)).movement:null,enabled:!!p}),We=te({queryKey:["forge-movement-selection",r,Z.stayIds.join(","),Z.tripIds.join(","),...s],queryFn:async()=>(await es({...Z,userIds:s})).movement,enabled:Z.stayIds.length>0||Z.tripIds.length>0}),ge=ke({mutationFn:async n=>Ha({trackingEnabled:n},s),onSuccess:async()=>{await a.invalidateQueries({queryKey:["forge-movement-settings"]}),await a.invalidateQueries({queryKey:["forge-movement-day"]})}}),Ge=ke({mutationFn:async n=>n.id?Ka(n.id,n):na(n,s),onSuccess:async()=>{await a.invalidateQueries({queryKey:["forge-movement-places"]}),await a.invalidateQueries({queryKey:["forge-movement-day"]}),await a.invalidateQueries({queryKey:["forge-movement-all-time"]})}}),he=x.useMemo(()=>{const n=xe.data??[],f=Ne.trim().toLowerCase();return f?n.filter(ee=>[ee.label,...ee.aliases,...ee.categoryTags].join(" ").toLowerCase().includes(f)):n},[Ne,xe.data]),Ve=x.useMemo(()=>{var n;return Ys(((n=y.data)==null?void 0:n.trip.points)??[])},[($e=y.data)==null?void 0:$e.trip.points]),z=x.useMemo(()=>{var ee;const n=((ee=y.data)==null?void 0:ee.trip.points)??[],f=ga(T);return[...n].sort((U,ne)=>new Date(ne.recordedAt).getTime()-new Date(U.recordedAt).getTime()).filter(U=>(f.length===0||Vs(U).includes(f))&&Xs(U,H))},[T,H,(fe=y.data)==null?void 0:fe.trip.points]),Ie=x.useMemo(()=>{var f;const n=((f=y.data)==null?void 0:f.trip.points.length)??0;return n===0?"No raw datapoints on this trip yet.":z.length===n&&T.trim().length===0&&H.length===0?`${n} datapoints visible`:`${z.length} of ${n} datapoints visible`},[z.length,T,H.length,(M=y.data)==null?void 0:M.trip.points.length]),Me=sa({count:z.length,getScrollElement:()=>De.current,estimateSize:()=>96,overscan:8}),C=z.find(n=>n.id===_)??((Fe=y.data)==null?void 0:Fe.trip.points.find(n=>n.id===_))??z[0]??((re=y.data)==null?void 0:re.trip.points[0])??null;if(x.useEffect(()=>{if(B){if(!C){Y(null),X(null);return}Y(C.id),X(ta(C))}},[C,B]),x.useEffect(()=>{F(""),V([]),Y(null),X(null),w(!1)},[p]),ae.isLoading||q.isLoading||se.isLoading||K.isLoading||xe.isLoading)return e.jsx(la,{eyebrow:"Movement",title:"Loading movement workspace",description:"Reconstructing stays, trips, and place intelligence across Forge.",columns:2,blocks:8});if(ae.isError||q.isError||se.isError||K.isError||xe.isError||!ae.data||!q.data||!se.data||!K.data)return e.jsx(da,{eyebrow:"Movement",error:ae.error??q.error??se.error??K.error??xe.error??new Error("Movement data unavailable"),onRetry:()=>{ae.refetch(),q.refetch(),se.refetch(),K.refetch(),xe.refetch()}});const j=ae.data,be=q.data,de=se.data,oe=K.data,S=We.data??j.selectionAggregate,J=j.trips.reduce((n,f)=>n+Xe(f).totalAp,0);return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(ts,{entityKind:"project",title:"Movement",description:"Turn passive place and travel signals into a real Forge domain: day rhythm, travel arcs, known landmarks, linked work, and reflective evidence.",badge:`${j.summary.tripCount} trips today`,actions:e.jsx("div",{className:"flex flex-wrap gap-2",children:["life","day","month","all_time"].map(n=>e.jsx(k,{variant:"ghost",className:O("h-9 rounded-full border px-4 text-sm",i===n?"border-[var(--primary)] bg-[var(--primary)]/16 text-white":"border-white/10 bg-white/[0.04] text-white/64"),onClick:()=>c(n),children:n==="all_time"?"All time":n==="life"?"Life":n.charAt(0).toUpperCase()+n.slice(1)},n))})}),e.jsxs(v,{className:"grid gap-3 rounded-[28px] border border-white/8 bg-[linear-gradient(180deg,rgba(12,20,34,0.98),rgba(8,14,25,0.96))] p-4 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Movement AP today"}),e.jsx("div",{className:"mt-2 text-3xl font-semibold text-white",children:Bt(J)}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:"Trips and transitions now contribute to the same Action Point ledger as work, habits, and notes."})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Typical trip drain"}),e.jsx("div",{className:"mt-2 text-2xl font-semibold text-[var(--primary)]",children:j.trips[0]?Ze(Xe(j.trips[0]).rateApPerHour):"0 AP/h"}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:"Movement uses a MET-like drain under the hood, translated into Forge Action Points."})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Life Force sync"}),e.jsx("div",{className:"mt-2 text-2xl font-semibold text-white",children:ie.data?`${Math.round(ie.data.spentTodayAp??0)}/${Math.round(ie.data.dailyBudgetAp??0)} AP`:"Loading..."}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:ie.data?`${Ze(ie.data.instantFreeApPerHour)} free right now`:"Movement can now be read against today’s live capacity."})]})]}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.65fr)_minmax(20rem,0.95fr)]",children:[e.jsx(Ba,{children:e.jsxs(v,{className:"overflow-hidden rounded-[30px] border border-white/8 bg-[radial-gradient(circle_at_top_left,rgba(107,214,255,0.16),transparent_42%),linear-gradient(180deg,rgba(10,18,35,0.98),rgba(9,15,28,0.92))]",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/42",children:"Movement operating mode"}),e.jsx(ce,{content:"This is the passive capture state of the movement system: whether tracking is running, how much is published into Forge, and how aggressive retention is."})]}),e.jsx("div",{className:"mt-2 text-[clamp(1.05rem,1.8vw,1.35rem)] text-white",children:"Background stays and trips as structured life evidence"}),e.jsx("div",{className:"mt-2 max-w-2xl text-sm leading-6 text-white/58",children:"The companion samples quietly while stationary, switches to denser trip capture when you move, and keeps only simplified long-term traces."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{tone:"signal",children:oe.trackingEnabled?"Tracking on":"Tracking off"}),e.jsx(u,{tone:"default",className:"bg-white/[0.06] text-white/72",children:oe.publishMode.replaceAll("_"," ")}),e.jsx(k,{variant:"ghost",className:"h-9 rounded-full border border-white/10 bg-white/[0.04] px-4",onClick:()=>ge.mutate(!oe.trackingEnabled),children:oe.trackingEnabled?"Pause passive capture":"Enable passive capture"})]})]}),e.jsxs("div",{className:"mt-5 grid gap-3 sm:grid-cols-3",children:[e.jsxs(v,{className:"rounded-[24px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/40",children:"Distance today"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:we(j.summary.totalDistanceMeters)}),e.jsx("div",{className:"mt-2 text-sm text-white/56",children:"Across trips, stops, and linked place changes."})]}),e.jsxs(v,{className:"rounded-[24px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/40",children:"Idle time"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:R(j.summary.totalIdleSeconds)}),e.jsx("div",{className:"mt-2 text-sm text-white/56",children:"Time spent settled enough to count as a real stay."})]}),e.jsxs(v,{className:"rounded-[24px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/40",children:"Estimated phone time"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:R(j.summary.estimatedScreenTimeSeconds)}),e.jsx("div",{className:"mt-2 text-sm text-white/56",children:"Estimated from hourly Screen Time bins, not exact foreground traces."})]}),e.jsxs(v,{className:"rounded-[24px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/40",children:"Known places"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:j.summary.knownPlaceCount}),e.jsx("div",{className:"mt-2 text-sm text-white/56",children:"Shared between Forge and the iPhone companion."})]}),e.jsxs(v,{className:"rounded-[24px] border border-white/8 bg-[linear-gradient(180deg,rgba(148,163,184,0.12),rgba(71,85,105,0.12))] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/40",children:"Missing data"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:R(j.summary.missingDurationSeconds)}),e.jsxs("div",{className:"mt-2 text-sm text-white/56",children:[j.summary.missingCount," grey gap",j.summary.missingCount===1?"":"s"," where Forge had over one hour without enough movement signal."]})]}),e.jsxs(v,{className:"rounded-[24px] border border-white/8 bg-[linear-gradient(180deg,rgba(251,191,36,0.12),rgba(16,185,129,0.08))] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/40",children:"Repaired gaps"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:R(j.summary.repairedGapDurationSeconds)}),e.jsxs("div",{className:"mt-2 text-sm text-white/56",children:[j.summary.repairedGapCount," inferred span",j.summary.repairedGapCount===1?"":"s"," classified as stay or move instead of leaving blank holes in the day."]})]}),e.jsxs(v,{className:"rounded-[24px] border border-white/8 bg-[linear-gradient(180deg,rgba(56,189,248,0.12),rgba(99,102,241,0.08))] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/40",children:"Continued stays"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:R(j.summary.continuedStayDurationSeconds)}),e.jsxs("div",{className:"mt-2 text-sm text-white/56",children:[j.summary.continuedStayCount," short stationary span",j.summary.continuedStayCount===1?"":"s"," carried forward so quiet home time stays continuous instead of disappearing."]})]})]})]})}),e.jsx(qa,{children:e.jsxs(v,{className:"rounded-[30px] border border-white/8 bg-[linear-gradient(180deg,rgba(10,17,31,0.96),rgba(8,13,24,0.92))] p-5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/42",children:"Selection aggregate"}),e.jsx(ce,{content:"When you select stays or trips, Forge totals their span, distance, work overlap, notes, and places here."})]}),e.jsx("div",{className:"mt-2 text-sm text-white/56",children:"Select any combination of stays and trips to sum movement, time, and work evidence."}),e.jsxs("div",{className:"mt-5 grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/36",children:"Span"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:R(S.durationSeconds)})]}),e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/36",children:"Distance"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:we(S.distanceMeters)})]}),e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/36",children:"Work overlap"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:R(S.trackedWorkSeconds)})]}),e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/36",children:"Notes"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:S.noteCount})]}),e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/36",children:"Estimated phone time"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:R(S.estimatedScreenTimeSeconds)})]}),e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/36",children:"Pickups"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:S.pickupCount})]}),e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/36",children:"Notifications"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:S.notificationCount})]})]}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:S.placeLabels.map(n=>e.jsx(u,{tone:"default",className:"bg-white/[0.06] text-white/74",children:n},n))}),S.topApps.length>0?e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:S.topApps.map(n=>e.jsx(u,{tone:"default",className:"bg-[rgba(114,204,255,0.12)] text-white/80",children:(n.displayName||n.bundleIdentifier)+" · "+R(n.totalActivitySeconds)},n.id))}):null,S.topCategories.length>0?e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:S.topCategories.map(n=>e.jsx(u,{tone:"default",className:"bg-white/[0.05] text-white/64",children:n.categoryLabel},n.id))}):null]})})]}),i==="life"?e.jsx(Qa,{children:e.jsxs("section",{className:"grid gap-3",children:[e.jsx("div",{className:"flex items-center justify-between gap-3 px-1",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/38",children:"Life graph"}),e.jsx(ce,{content:"This graph shows the movement road of your life: stays are blocks, moves connect them, and the hour/day lines live in the background. Click a segment for details, then use edit when you want to correct it."})]})}),e.jsx(qs,{userIds:s})]})}):null,i==="day"?e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.55fr)_minmax(22rem,1fr)]",children:[e.jsxs(v,{className:"rounded-[30px] border border-white/8 bg-[linear-gradient(180deg,rgba(10,17,31,0.96),rgba(7,12,22,0.92))] p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/42",children:"Day strip"}),e.jsx(ce,{content:"A compressed 24-hour strip. Each segment keeps its true order and duration, but the whole day stays navigable on one line."})]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:"A single-row timeline from 00:00 to 24:00, always compressed into one navigable strip."})]}),e.jsx(P,{type:"date",value:r,onChange:n=>h(n.target.value),className:"w-[11rem]"})]}),e.jsx("div",{className:"mt-6 overflow-x-auto pb-2",children:e.jsxs("div",{className:"min-w-[52rem]",children:[e.jsx("div",{className:"mb-3 flex justify-between text-[11px] uppercase tracking-[0.18em] text-white/36",children:["00:00","06:00","12:00","18:00","24:00"].map(n=>e.jsx("span",{children:n},n))}),e.jsx("div",{className:"flex h-28 items-stretch overflow-hidden rounded-[28px] border border-white/10 bg-[rgba(255,255,255,0.03)] p-2",children:j.segments.map(n=>{const f=Math.max(9,n.durationSeconds/86400*100),ee=n.kind==="stay"?Z.stayIds.includes(n.id):n.kind==="trip"?Z.tripIds.includes(n.id):!1;return e.jsxs("button",{type:"button",className:O("relative flex min-w-[5.5rem] flex-col justify-between rounded-[22px] border px-3 py-2 text-left transition",n.kind==="missing"?"border-slate-400/20 bg-[linear-gradient(180deg,rgba(148,163,184,0.18),rgba(51,65,85,0.14))] hover:border-slate-300/30 hover:bg-[rgba(148,163,184,0.14)]":ee?"border-[rgba(171,232,255,0.5)] bg-[rgba(171,232,255,0.16)]":"border-white/6 bg-[linear-gradient(180deg,rgba(255,255,255,0.08),rgba(255,255,255,0.02))] hover:border-white/14 hover:bg-white/[0.08]"),style:{width:`${f}%`},onClick:()=>{n.kind!=="missing"&&Qe(U=>{const ne=new Set(U.stayIds),I=new Set(U.tripIds);return n.kind==="stay"?ne.has(n.id)?ne.delete(n.id):ne.add(n.id):I.has(n.id)?I.delete(n.id):(I.add(n.id),N(n.id)),{stayIds:[...ne],tripIds:[...I]}})},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(u,{tone:n.kind==="trip"?"signal":n.kind==="missing"?"meta":"default",className:"bg-white/[0.08] text-white/82",children:n.kind==="missing"?"gap":n.kind}),e.jsx("span",{className:"text-[11px] text-white/46",children:R(n.durationSeconds)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"line-clamp-2 text-sm font-semibold text-white",children:n.label}),e.jsx("div",{className:"mt-1 text-[12px] leading-5 text-white/52",children:n.subtitle})]})]},n.id)})})]})}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(u,{tone:"signal",children:Qs(r)}),e.jsxs(u,{tone:"default",className:"bg-white/[0.06] text-white/72",children:[j.summary.tripCount," trips"]}),e.jsxs(u,{tone:"default",className:"bg-white/[0.06] text-white/72",children:[j.summary.stayCount," stays"]}),e.jsxs(u,{tone:"meta",children:[j.summary.missingCount," gaps"]})]})]}),e.jsx("div",{className:"grid gap-4",children:y.data?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/42",children:"Selected trip"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsx(k,{variant:"ghost",className:"h-9 rounded-full border border-white/10 bg-white/[0.04] px-4",onClick:()=>A(n=>!n),children:b?"Stylized graph":"Exact path"})})]}),b?e.jsx(ei,{points:y.data.trip.points}):e.jsx(Js,{curve:y.data.stylizedPath.curve,startLabel:y.data.stylizedPath.startLabel,endLabel:y.data.stylizedPath.endLabel,stopLabels:y.data.stylizedPath.stops.map(n=>n.label)}),e.jsxs(v,{className:"rounded-[28px] border border-white/8 bg-white/[0.04] p-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/42",children:"Trip context"}),(()=>{const n=Xe(y.data.trip);return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(u,{tone:"signal",children:we(y.data.trip.distanceMeters)}),e.jsx(u,{tone:"default",className:"bg-white/[0.06] text-white/74",children:y.data.trip.activityType||y.data.trip.travelMode}),e.jsx(u,{tone:"default",className:"bg-white/[0.06] text-white/74",children:R(y.data.trip.durationSeconds)}),e.jsx(u,{tone:"default",className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:Ze(n.rateApPerHour)}),e.jsx(u,{tone:"default",className:"bg-white/[0.06] text-white/74",children:Bt(n.totalAp)})]})})})(),e.jsx("div",{className:"mt-4 text-sm leading-6 text-white/58",children:Us(y.data.trip.startedAt,y.data.trip.endedAt)}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[20px] border border-white/8 bg-white/[0.04] p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/38",children:"Hourly estimate"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:R(y.data.trip.estimatedScreenTimeSeconds)})]}),e.jsxs("div",{className:"rounded-[20px] border border-white/8 bg-white/[0.04] p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/38",children:"Pickups"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:y.data.trip.pickupCount})]}),e.jsxs("div",{className:"rounded-[20px] border border-white/8 bg-white/[0.04] p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/38",children:"Notifications"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:y.data.trip.notificationCount})]})]}),e.jsx("div",{className:"mt-3 text-xs leading-5 text-white/48",children:"Derived from Screen Time hourly bins, not exact foreground traces."}),y.data.trip.topApps.length>0?e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:y.data.trip.topApps.map(n=>e.jsx(u,{tone:"default",className:"bg-[rgba(114,204,255,0.12)] text-white/80",children:(n.displayName||n.bundleIdentifier)+" · "+R(n.totalActivitySeconds)},n.id))}):null,y.data.trip.topCategories.length>0?e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:y.data.trip.topCategories.map(n=>e.jsx(u,{tone:"default",className:"bg-white/[0.05] text-white/64",children:n.categoryLabel},n.id))}):null]})]}):e.jsx(v,{className:"rounded-[30px] border border-dashed border-white/12 bg-white/[0.03] p-6 text-white/58",children:"Select a trip segment to open the stylized trajectory card and exact path toggle."})})]}):null,i==="month"?e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.4fr)_minmax(18rem,0.85fr)]",children:[e.jsxs(v,{className:"rounded-[30px] border border-white/8 bg-[linear-gradient(180deg,rgba(9,15,28,0.97),rgba(8,13,24,0.92))] p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/42",children:"Month view"}),e.jsx(ce,{content:"This chart stays quantitative. Switch the metric to compare daily distance, moving time, idle time, or calories across the month."})]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:"Switch the Y-axis between motion, idle time, and energy without losing the same monthly frame."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(P,{type:"month",value:o,onChange:n=>m(n.target.value),className:"w-[10.5rem]"}),["distanceMeters","movingSeconds","idleSeconds","caloriesKcal"].map(n=>e.jsx(k,{variant:"ghost",className:O("h-9 rounded-full border px-4 text-sm",Se===n?"border-[var(--primary)] bg-[var(--primary)]/14 text-white":"border-white/10 bg-white/[0.04] text-white/62"),onClick:()=>lt(n),children:n==="distanceMeters"?"Distance":n==="movingSeconds"?"Moving":n==="idleSeconds"?"Idle":"Calories"},n))]})]}),e.jsx("div",{className:"mt-6 h-[24rem]",children:e.jsx(as,{width:"100%",height:"100%",children:e.jsxs(ss,{data:be.days,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"movementMonthFill",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"rgba(110,220,255,0.7)"}),e.jsx("stop",{offset:"100%",stopColor:"rgba(110,220,255,0.05)"})]})}),e.jsx(is,{stroke:"rgba(255,255,255,0.08)",vertical:!1}),e.jsx(rs,{dataKey:"dateKey",tick:{fill:"rgba(255,255,255,0.46)",fontSize:11},axisLine:!1,tickLine:!1}),e.jsx(ns,{tick:{fill:"rgba(255,255,255,0.46)",fontSize:11},axisLine:!1,tickLine:!1}),e.jsx(ls,{contentStyle:{background:"rgba(7,12,24,0.94)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:16},formatter:n=>Ws(Se,Number(n))}),e.jsx(ds,{type:"monotone",dataKey:Se,stroke:"rgba(126,233,255,0.95)",fill:"url(#movementMonthFill)",strokeWidth:2.4})]})})})]}),e.jsxs(v,{className:"rounded-[30px] border border-white/8 bg-white/[0.04] p-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/42",children:"Month totals"}),e.jsxs("div",{className:"mt-5 grid gap-3",children:[e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/36",children:"Distance"}),e.jsx("div",{className:"mt-2 text-2xl text-white",children:we(be.totals.distanceMeters)})]}),e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/36",children:"Moving time"}),e.jsx("div",{className:"mt-2 text-2xl text-white",children:R(be.totals.movingSeconds)})]}),e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/36",children:"Settled time"}),e.jsx("div",{className:"mt-2 text-2xl text-white",children:R(be.totals.idleSeconds)})]})]})]})]}):null,i==="all_time"?e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.35fr)_minmax(20rem,0.95fr)]",children:[e.jsxs(v,{className:"rounded-[30px] border border-white/8 bg-[linear-gradient(180deg,rgba(8,13,25,0.97),rgba(8,13,24,0.92))] p-5",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsxs(v,{className:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/36",children:"Trips"}),e.jsx("div",{className:"mt-2 text-3xl text-white",children:de.summary.tripCount})]}),e.jsxs(v,{className:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/36",children:"Known places"}),e.jsx("div",{className:"mt-2 text-3xl text-white",children:de.summary.knownPlaceCount})]}),e.jsxs(v,{className:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/36",children:"Distance"}),e.jsx("div",{className:"mt-2 text-3xl text-white",children:we(de.summary.totalDistanceMeters)})]}),e.jsxs(v,{className:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/36",children:"Countries"}),e.jsx("div",{className:"mt-2 text-3xl text-white",children:de.summary.visitedCountries})]})]}),e.jsx("div",{className:"mt-6 grid gap-3 sm:grid-cols-2",children:de.recentTrips.map(n=>e.jsx("button",{type:"button",className:"rounded-[24px] border border-white/8 bg-white/[0.03] p-4 text-left transition hover:bg-white/[0.06]",onClick:()=>{c("day"),N(n.id)},children:(()=>{const f=Xe({startedAt:n.startedAt,endedAt:new Date(new Date(n.startedAt).getTime()+36e5).toISOString(),expectedMet:2});return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/36",children:"Recent travel"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:n.label||"Untitled trip"}),e.jsxs("div",{className:"mt-1 text-sm text-white/56",children:[we(n.distanceMeters)," · ",n.activityType||"travel"]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:e.jsx(u,{tone:"default",className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:Ze(f.rateApPerHour)})})]})})()},n.id))})]}),e.jsxs(v,{className:"rounded-[30px] border border-white/8 bg-white/[0.04] p-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/42",children:"Place categories"}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:de.categoryBreakdown.map(n=>e.jsxs(u,{tone:"default",className:"bg-white/[0.06] text-white/74",children:[n.tag," · ",n.count]},n.tag))})]})]}):null,e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.25fr)_minmax(22rem,0.95fr)]",children:[e.jsx(Ua,{children:e.jsxs(v,{className:"rounded-[30px] border border-white/8 bg-[linear-gradient(180deg,rgba(8,14,28,0.96),rgba(9,15,28,0.92))] p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/42",children:"Known places"}),e.jsx(ce,{content:"Known places turn raw stationary spans into named contexts like home, work, gym, nature, or any custom place tag you want Forge to remember."})]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:"These landmarks anchor stays, travel XP, and contextual reasoning in both Forge and the companion. Seeded tags like home, workplace, gym, holiday, grocery, or nature matter for downstream calculations, but place tags stay open-ended."})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(P,{value:Ne,onChange:n=>nt(n.target.value),placeholder:"Search places",className:"w-[11rem]"}),e.jsx(k,{onClick:()=>{Ue(null),Pe(!0)},children:"Add place"})]})]}),e.jsx("div",{className:"mt-5 grid gap-3",children:he.map(n=>e.jsxs("button",{type:"button",className:"flex items-start justify-between gap-3 rounded-[24px] border border-white/8 bg-white/[0.03] p-4 text-left transition hover:bg-white/[0.06]",onClick:()=>{Ue(n),Pe(!0)},children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-lg text-white",children:n.label}),e.jsxs("div",{className:"mt-1 text-sm text-white/56",children:[n.latitude.toFixed(4),", ",n.longitude.toFixed(4)," · radius ",Math.round(n.radiusMeters)," m"]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:n.categoryTags.map(f=>e.jsx(u,{tone:"default",className:"bg-white/[0.06] text-white/74",children:f},f))})]}),e.jsx(Mt,{className:"mt-1 size-4 text-white/42"})]},n.id))})]})}),e.jsxs(v,{className:"rounded-[30px] border border-white/8 bg-[linear-gradient(180deg,rgba(10,17,31,0.96),rgba(8,13,24,0.92))] p-5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/42",children:"Movement help"}),e.jsx(ce,{content:"Most movement surfaces on this page have help buttons. Use them to understand the graph, the day strip, the month chart, and the place system without keeping a large prose block on screen."})]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/58",children:"Use the small help icons across this page for graph explanations, timeline semantics, and metric meanings."}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(u,{className:"bg-white/[0.06] text-white/74",children:"Life graph"}),e.jsx(u,{className:"bg-white/[0.06] text-white/74",children:"Day strip"}),e.jsx(u,{className:"bg-white/[0.06] text-white/74",children:"Month chart"}),e.jsx(u,{className:"bg-white/[0.06] text-white/74",children:"Known places"}),e.jsx(u,{className:"bg-white/[0.06] text-white/74",children:"Selection aggregate"})]})]})]}),y.data?e.jsx(oa,{open:B,onOpenChange:n=>{w(n),n||(F(""),V([]),Y(null),X(null))},eyebrow:"Movement data",title:y.data.trip.label||"Trip datapoints",description:"Inspect the raw datapoints behind this trip. Raw measurements are read-only here; visible movement corrections now happen through canonical user-defined boxes.",children:e.jsx(Wa,{children:e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,24rem)_minmax(0,1fr)]",children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsx(ma,{title:"Datapoint browser",description:"Search raw points by time band, anchor status, or accuracy before opening the point editor.",query:T,onQueryChange:F,options:Ve,selectedOptionIds:H,onSelectedOptionIdsChange:V,resultSummary:Ie,placeholder:"Search timestamps, accuracy, point ids, or filter chips",emptyStateMessage:"Keep typing or pick a time/quality chip to narrow the trip datapoints."}),e.jsxs(v,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Raw datapoints"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:"Open a point to correct or delete it."})]}),e.jsx(u,{tone:"meta",children:Ie})]}),e.jsx("div",{ref:De,className:"h-[34rem] overflow-y-auto rounded-[24px] border border-white/8 bg-white/[0.03]",children:z.length===0?e.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center text-sm leading-6 text-white/50",children:"No datapoint matches the current search. Clear some filters or search by time, anchor type, or accuracy."}):e.jsx("div",{className:"relative w-full",style:{height:`${Me.getTotalSize()}px`},children:Me.getVirtualItems().map(n=>{const f=z[n.index];return e.jsx("div",{className:"absolute left-0 top-0 w-full px-3 py-2",style:{transform:`translateY(${n.start}px)`},children:e.jsxs("button",{type:"button",className:O("grid w-full gap-3 rounded-[20px] border px-4 py-3 text-left transition",_===f.id?"border-[rgba(171,232,255,0.34)] bg-[rgba(171,232,255,0.12)]":"border-white/8 bg-white/[0.04] hover:bg-white/[0.07]"),onClick:()=>{Y(f.id),X(ta(f))},children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white",children:[e.jsx($a,{className:"size-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate text-base font-medium",children:At(f.recordedAt)})]}),e.jsxs("div",{className:"mt-2 text-sm text-white/56",children:[f.latitude.toFixed(5),", ",f.longitude.toFixed(5)]})]}),e.jsx(u,{tone:f.isStopAnchor?"signal":"meta",children:f.isStopAnchor?"Stop anchor":"Path point"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{tone:"meta",className:"capitalize",children:rt(f.recordedAt)}),f.accuracyMeters!=null?e.jsxs(u,{tone:"meta",children:[Math.round(f.accuracyMeters)," m accuracy"]}):null,f.speedMps!=null?e.jsxs(u,{tone:"meta",children:[f.speedMps.toFixed(1)," m/s"]}):null]})]})},f.id)})})})]})]}),C&&Q?e.jsx(ti,{point:C,draft:Q}):e.jsx(v,{className:"rounded-[28px] border border-dashed border-white/12 bg-white/[0.03] p-6 text-white/56",children:"Pick a datapoint to inspect its raw measurement details. To correct what the user sees, use canonical user-defined movement boxes in the Life Timeline."})]})})}):null,e.jsx(xa,{open:Ce,onOpenChange:Pe,place:Le,onSave:async n=>{await Ge.mutateAsync(n)}})]})}export{hi as MovementPage};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{j as n,r as b}from"./vendor-DHkYh85p.js";import{Z as u,cO as w,bq as j}from"./index-CF4J4R9L.js";function m(h,t){const l=[],e=/(!?\[\[([^\]]+)\]\]|\[([^\]]+)\]\(([^)]+)\)|`([^`]+)`|\*\*([^*]+)\*\*|\*([^*]+)\*)/g;let r=0,i=null,a=0;for(;(i=e.exec(h))!==null;){if(i.index>r&&(l.push(n.jsx(b.Fragment,{children:h.slice(r,i.index)},`${t}-text-${a}`)),a+=1),i[1]&&i[2]){const c=i[2].trim(),s=i[1].startsWith("!"),o=c.indexOf("|"),p=o>=0?c.slice(0,o).trim():c,x=o>=0?c.slice(o+1).trim():p;if(p.toLowerCase().startsWith("forge:")){const[,d,g]=p.split(":"),$=d&&g?j(d,g):null,f=$?w($):null;l.push(f?n.jsxs("a",{href:f,className:"inline-flex items-center gap-1 rounded-full bg-amber-400/10 px-2 py-0.5 text-[0.9em] text-amber-100 transition hover:bg-amber-400/18",children:[n.jsx("span",{className:"text-[0.72em] uppercase tracking-[0.14em] text-amber-200/72",children:"Forge"}),n.jsx("span",{children:x})]},`${t}-forge-${a}`):n.jsx("span",{className:"inline-flex items-center gap-1 rounded-full bg-white/[0.06] px-2 py-0.5 text-[0.9em] text-white/66",children:x},`${t}-forge-${a}`))}else{const d=w(`/wiki/page/${encodeURIComponent(p)}`);l.push(n.jsxs("a",{href:d,className:u("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[0.9em] transition",s?"bg-cyan-400/14 text-cyan-50 hover:bg-cyan-400/22":"bg-white/[0.06] text-[var(--secondary)] hover:bg-white/[0.1]"),children:[s?n.jsx("span",{className:"text-[0.72em] uppercase tracking-[0.14em] text-cyan-100/68",children:"Embed"}):null,n.jsx("span",{children:x})]},`${t}-wiki-${a}`))}}else if(i[3]&&i[4]){const c=i[4].trim(),s=/^https?:\/\//i.test(c);l.push(n.jsx("a",{href:c,className:"text-[var(--secondary)] underline decoration-[rgba(125,211,252,0.4)] underline-offset-4 transition hover:text-white",target:s?"_blank":void 0,rel:s?"noreferrer":void 0,children:i[3]},`${t}-link-${a}`))}else i[5]?l.push(n.jsx("code",{className:"rounded bg-white/[0.08] px-1.5 py-0.5 text-[0.92em] text-white/90",children:i[5]},`${t}-code-${a}`)):i[6]?l.push(n.jsx("strong",{className:"font-semibold text-white",children:i[6]},`${t}-strong-${a}`)):i[7]&&l.push(n.jsx("em",{className:"italic text-white/88",children:i[7]},`${t}-em-${a}`));r=e.lastIndex,a+=1}return r<h.length&&l.push(n.jsx(b.Fragment,{children:h.slice(r)},`${t}-tail-${a}`)),l}function N(h){const t=h.replace(/\r/g,"").split(`
|
|
2
|
-
`),l=[];let e=0;for(;e<t.length;){const r=t[e]??"",i=r.trim();if(!i){e+=1;continue}if(i.startsWith("```")){const s=[];for(e+=1;e<t.length&&!(t[e]??"").trim().startsWith("```");)s.push(t[e]??""),e+=1;e+=1,l.push(n.jsx("pre",{className:"overflow-x-auto rounded-[18px] bg-[rgba(6,10,18,0.88)] px-4 py-3 text-xs leading-6 text-white/86",children:n.jsx("code",{children:s.join(`
|
|
3
|
-
`)})},`code-${e}`));continue}const a=r.match(/^(#{1,6})\s+(.*)$/);if(a){const s=a[1].length,o=s===1?"text-xl":s===2?"text-lg":s===3?"text-base":"text-sm";l.push(n.jsx("div",{className:u("font-semibold text-white",o),children:m(a[2],`heading-${e}`)},`heading-${e}`)),e+=1;continue}if(/^>\s?/.test(r)){const s=[];for(;e<t.length&&/^>\s?/.test(t[e]??"");)s.push((t[e]??"").replace(/^>\s?/,"")),e+=1;l.push(n.jsx("blockquote",{className:"border-l-2 border-[var(--secondary)]/50 pl-4 text-sm leading-7 text-white/72",children:m(s.join(" "),`quote-${e}`)},`quote-${e}`));continue}if(/^[-*+]\s+/.test(r)||/^\d+\.\s+/.test(r)){const s=/^\d+\.\s+/.test(r),o=[];for(;e<t.length&&(/^[-*+]\s+/.test(t[e]??"")||/^\d+\.\s+/.test(t[e]??""));)o.push((t[e]??"").replace(/^[-*+]\s+/,"").replace(/^\d+\.\s+/,"")),e+=1;const p=s?"ol":"ul";l.push(n.jsx(p,{className:u("space-y-1 pl-5 text-sm leading-7 text-white/74",s?"list-decimal":"list-disc"),children:o.map((x,d)=>n.jsx("li",{children:m(x,`list-${e}-${d}`)},`item-${e}-${d}`))},`list-${e}`));continue}const c=[];for(;e<t.length;){const s=t[e]??"";if(!s.trim()||s.trim().startsWith("```")||/^#{1,6}\s+/.test(s)||/^>\s?/.test(s)||/^[-*+]\s+/.test(s)||/^\d+\.\s+/.test(s))break;c.push(s.trim()),e+=1}l.push(n.jsx("p",{className:"text-sm leading-7 text-white/72",children:m(c.join(" "),`paragraph-${e}`)},`paragraph-${e}`))}return l}function q({markdown:h,className:t}){return n.jsx("div",{className:u("grid gap-3",t),children:N(h)})}export{q as N};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as s}from"./vendor-DHkYh85p.js";import{m as u,c as i}from"./index-CF4J4R9L.js";const c=[{value:"Working memory",label:"Working memory",description:"What you are actively working on right now."},{value:"Short-term memory",label:"Short-term memory",description:"What just happened and still needs near-term recall."},{value:"Episodic memory",label:"Episodic memory",description:"Long-term recall for what happened or what you did."},{value:"Semantic memory",label:"Semantic memory",description:"Long-term knowledge about what something is."},{value:"Procedural memory",label:"Procedural memory",description:"Long-term know-how and repeatable how-to knowledge."}];function m(n){const t=new Set;return n.map(a=>a.trim()).filter(Boolean).filter(a=>{const r=a.toLowerCase();return t.has(r)?!1:(t.add(r),!0)})}function p(n){const t=n.trim();if(!t)return null;const a=new Date(t);return Number.isNaN(a.getTime())?null:a.toISOString()}function b(n){if(!n)return"";const t=new Date(n);if(Number.isNaN(t.getTime()))return"";const a=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),e=String(t.getDate()).padStart(2,"0"),l=String(t.getHours()).padStart(2,"0"),o=String(t.getMinutes()).padStart(2,"0");return`${a}-${r}-${e}T${l}:${o}`}function w(n,t){const a=Number(n);if(!Number.isFinite(a)||a<=0)return null;const r=t==="hours"?3600*1e3:1440*60*1e3;return new Date(Date.now()+a*r).toISOString()}function d(n){const t=new Set(c.map(e=>e.value.toLowerCase())),a=c.map(e=>({value:e.value,label:e.label,description:e.description,searchText:`${e.label} ${e.description}`,badge:s.jsx(i,{className:"bg-cyan-400/10 text-cyan-50",children:e.label}),menuBadge:s.jsx(i,{className:"bg-cyan-400/10 text-cyan-50",children:e.label})})),r=m(n).filter(e=>!t.has(e.toLowerCase())).map(e=>({value:e,label:e,description:"Custom note tag",searchText:e,badge:s.jsx(i,{className:"bg-white/[0.08] text-white/78",children:e}),menuBadge:s.jsx(i,{className:"bg-white/[0.08] text-white/78",children:e})}));return[...a,...r]}function y({value:n,onChange:t,availableTags:a=[],placeholder:r="Add a memory tag or create a custom tag"}){const e=d([...a,...n]);return s.jsx(u,{options:e,selectedValues:m(n),onChange:l=>t(m(l)),placeholder:r,emptyMessage:"No note tags yet.",createLabel:"Add custom tag",onCreate:async l=>{const o=l.trim();return{value:o,label:o,description:"Custom note tag",searchText:o,badge:s.jsx(i,{className:"bg-white/[0.08] text-white/78",children:o}),menuBadge:s.jsx(i,{className:"bg-white/[0.08] text-white/78",children:o})}}})}export{y as N,w as b,b as f,m as n,p};
|