@flexkit/studio 0.2.20 → 0.2.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/dist/activity-nav-button-7RLCHOFV.js +2 -0
  2. package/dist/{activity-nav-button-V5DFHADL.js.map → activity-nav-button-7RLCHOFV.js.map} +1 -1
  3. package/dist/astro.js +1 -1
  4. package/dist/chat-page-WLKJ3QNZ.js +4 -0
  5. package/dist/chat-page-WLKJ3QNZ.js.map +1 -0
  6. package/dist/{chunk-D5WYD5M4.js → chunk-4LVMCUHR.js} +2 -2
  7. package/dist/{chunk-D5WYD5M4.js.map → chunk-4LVMCUHR.js.map} +1 -1
  8. package/dist/{chunk-ME55YNBF.js → chunk-4PUMSUJL.js} +2 -2
  9. package/dist/{chunk-ME55YNBF.js.map → chunk-4PUMSUJL.js.map} +1 -1
  10. package/dist/{chunk-B7QMGBK5.js → chunk-6AI7322C.js} +3 -3
  11. package/dist/{chunk-B7QMGBK5.js.map → chunk-6AI7322C.js.map} +1 -1
  12. package/dist/{chunk-BMX4URYN.js → chunk-7ERLYAPR.js} +2 -2
  13. package/dist/{chunk-BMX4URYN.js.map → chunk-7ERLYAPR.js.map} +1 -1
  14. package/dist/chunk-7KLXWCDS.js +3 -0
  15. package/dist/chunk-7KLXWCDS.js.map +1 -0
  16. package/dist/chunk-BM7INZL3.js +3 -0
  17. package/dist/chunk-BM7INZL3.js.map +1 -0
  18. package/dist/chunk-ELOJGLAR.js +2 -0
  19. package/dist/chunk-ELOJGLAR.js.map +1 -0
  20. package/dist/{chunk-GFAOY74A.js → chunk-GGC75EMC.js} +2 -0
  21. package/dist/{chunk-HLHLBMLJ.js → chunk-HBTMGDOM.js} +2 -2
  22. package/dist/{chunk-HLHLBMLJ.js.map → chunk-HBTMGDOM.js.map} +1 -1
  23. package/dist/{chunk-MKK65RQB.js → chunk-HGXYSP47.js} +5 -5
  24. package/dist/{chunk-MKK65RQB.js.map → chunk-HGXYSP47.js.map} +1 -1
  25. package/dist/chunk-HKN6BX5U.js +2 -0
  26. package/dist/chunk-HKN6BX5U.js.map +1 -0
  27. package/dist/chunk-JIB4PRLH.js +3 -0
  28. package/dist/chunk-JIB4PRLH.js.map +1 -0
  29. package/dist/{chunk-2P2QV3K6.js → chunk-K2KW6UYG.js} +2 -2
  30. package/dist/{chunk-2P2QV3K6.js.map → chunk-K2KW6UYG.js.map} +1 -1
  31. package/dist/{chunk-ZZRA4567.js → chunk-LIMXKPEK.js} +2 -2
  32. package/dist/{chunk-ZZRA4567.js.map → chunk-LIMXKPEK.js.map} +1 -1
  33. package/dist/chunk-MHVZXDVL.js +2 -0
  34. package/dist/{chunk-BXN72PW2.js.map → chunk-MHVZXDVL.js.map} +1 -1
  35. package/dist/chunk-MLHXPTBT.js +2 -0
  36. package/dist/chunk-MLHXPTBT.js.map +1 -0
  37. package/dist/{chunk-UOR437J2.js → chunk-QCVQJN5O.js} +2 -2
  38. package/dist/{chunk-UOR437J2.js.map → chunk-QCVQJN5O.js.map} +1 -1
  39. package/dist/{chunk-F2DT6NRK.js → chunk-QTFFVG7C.js} +2 -2
  40. package/dist/{chunk-F2DT6NRK.js.map → chunk-QTFFVG7C.js.map} +1 -1
  41. package/dist/chunk-RPLKJVDQ.js +7 -0
  42. package/dist/{chunk-NYSQU73M.js.map → chunk-RPLKJVDQ.js.map} +1 -1
  43. package/dist/{chunk-RY6PECIT.js → chunk-SE4HJCGA.js} +2 -2
  44. package/dist/{chunk-RY6PECIT.js.map → chunk-SE4HJCGA.js.map} +1 -1
  45. package/dist/{chunk-DHVKE36X.js → chunk-SY67F62K.js} +3 -3
  46. package/dist/{chunk-DHVKE36X.js.map → chunk-SY67F62K.js.map} +1 -1
  47. package/dist/chunk-UCHWUGRT.js +378 -0
  48. package/dist/chunk-UCHWUGRT.js.map +1 -0
  49. package/dist/{chunk-JWBER5NX.js → chunk-UJEDL3IZ.js} +2 -2
  50. package/dist/{chunk-JWBER5NX.js.map → chunk-UJEDL3IZ.js.map} +1 -1
  51. package/dist/chunk-YXUEPR7K.js +4 -0
  52. package/dist/{chunk-LK67JOQA.js.map → chunk-YXUEPR7K.js.map} +1 -1
  53. package/dist/electron.js +1 -1
  54. package/dist/{entry-XVLXKEQV.js → entry-GWZ7DELK.js} +2 -2
  55. package/dist/{entry-XVLXKEQV.js.map → entry-GWZ7DELK.js.map} +1 -1
  56. package/dist/index.css +21 -0
  57. package/dist/index.js +10 -8
  58. package/dist/index.js.map +1 -1
  59. package/dist/list-FQZII7QD.js +3 -0
  60. package/dist/{list-4OJMI4CB.js.map → list-FQZII7QD.js.map} +1 -1
  61. package/dist/list-LMIKCT2W.js +2 -0
  62. package/dist/{list-RABV2F3H.js.map → list-LMIKCT2W.js.map} +1 -1
  63. package/dist/nextjs.js +1 -1
  64. package/dist/{pages-7LWBCW2X.js → pages-NKE7FV34.js} +3 -3
  65. package/dist/{pages-7LWBCW2X.js.map → pages-NKE7FV34.js.map} +1 -1
  66. package/dist/plugin-pages-4HTADSK3.js +2 -0
  67. package/dist/{plugin-pages-PQWTH7P5.js.map → plugin-pages-4HTADSK3.js.map} +1 -1
  68. package/dist/record-links-FDWV4X5W.js +2 -0
  69. package/dist/{record-links-BFHPBOAL.js.map → record-links-FDWV4X5W.js.map} +1 -1
  70. package/dist/{root-COI626G2.js → root-GYJGAS22.js} +2 -2
  71. package/dist/{root-COI626G2.js.map → root-GYJGAS22.js.map} +1 -1
  72. package/dist/root-OSXC52GL.js +2 -0
  73. package/dist/{root-PDSTTPHO.js.map → root-OSXC52GL.js.map} +1 -1
  74. package/dist/root-VL4EM2IS.js +23 -0
  75. package/dist/{root-FTT4XDCE.js.map → root-VL4EM2IS.js.map} +1 -1
  76. package/dist/{root-RXMRNU4M.js → root-X3V4NC2D.js} +2 -2
  77. package/dist/{root-RXMRNU4M.js.map → root-X3V4NC2D.js.map} +1 -1
  78. package/dist/root-YDHREGTF.js +14 -0
  79. package/dist/root-YDHREGTF.js.map +1 -0
  80. package/dist/{root-BS6QCYLO.js → root-ZYUSZZWR.js} +3 -3
  81. package/dist/{root-BS6QCYLO.js.map → root-ZYUSZZWR.js.map} +1 -1
  82. package/dist/{search-VPS2UHPQ.js → search-UW7WE2CS.js} +2 -2
  83. package/dist/{search-VPS2UHPQ.js.map → search-UW7WE2CS.js.map} +1 -1
  84. package/dist/skills-pages-Q4YSUQVZ.js +2 -0
  85. package/dist/skills-pages-Q4YSUQVZ.js.map +1 -0
  86. package/dist/source-PGSWL4DQ.js +2 -0
  87. package/dist/{source-MNHZQD4T.js.map → source-PGSWL4DQ.js.map} +1 -1
  88. package/dist/tanstack-start.js +1 -1
  89. package/dist/{user-nav-36ACWXOW.js → user-nav-B37OEVQN.js} +2 -2
  90. package/dist/{user-nav-36ACWXOW.js.map → user-nav-B37OEVQN.js.map} +1 -1
  91. package/package.json +9 -6
  92. package/dist/activity-nav-button-V5DFHADL.js +0 -2
  93. package/dist/chat-page-4G4XQ26P.js +0 -4
  94. package/dist/chat-page-4G4XQ26P.js.map +0 -1
  95. package/dist/chunk-2HYQVMP3.js +0 -3
  96. package/dist/chunk-2HYQVMP3.js.map +0 -1
  97. package/dist/chunk-445XKMAG.js +0 -379
  98. package/dist/chunk-445XKMAG.js.map +0 -1
  99. package/dist/chunk-A7XHA2P6.js +0 -3
  100. package/dist/chunk-A7XHA2P6.js.map +0 -1
  101. package/dist/chunk-BMO7JFAX.js +0 -2
  102. package/dist/chunk-BMO7JFAX.js.map +0 -1
  103. package/dist/chunk-BXN72PW2.js +0 -2
  104. package/dist/chunk-LK67JOQA.js +0 -4
  105. package/dist/chunk-NYSQU73M.js +0 -7
  106. package/dist/list-4OJMI4CB.js +0 -3
  107. package/dist/list-RABV2F3H.js +0 -2
  108. package/dist/plugin-pages-PQWTH7P5.js +0 -2
  109. package/dist/record-links-BFHPBOAL.js +0 -2
  110. package/dist/root-FTT4XDCE.js +0 -23
  111. package/dist/root-PDSTTPHO.js +0 -2
  112. package/dist/root-TZYOIXVG.js +0 -2
  113. package/dist/root-TZYOIXVG.js.map +0 -1
  114. package/dist/skills-pages-G6JK7KKQ.js +0 -2
  115. package/dist/skills-pages-G6JK7KKQ.js.map +0 -1
  116. package/dist/source-MNHZQD4T.js +0 -2
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/apps/graph/layout.ts","../src/apps/graph/canvas.tsx","../src/apps/graph/context-menu.tsx","../src/apps/graph/scene.ts","../src/apps/graph/inspector.tsx","../src/apps/graph/sidebar.tsx","../src/apps/graph/toolbar.tsx","../src/apps/graph/use-scene.ts","../src/apps/graph/root.tsx"],"names":["layoutBudget","order","isSettled","mean","max","diagonal","threshold","PLACEMENT_RADIUS","SETTLE_INTERVAL_MS","SETTLE_MIN_MS","SETTLE_QUIET_SAMPLES","nodeSize","degree","ringRadius","count","ringPositions","center","radius","phase","_","index","angle","distance","isPositioned","graph","key","placedExtent","placed","sum","reach","placeNewNodes","added","groups","anchor","neighbour","keys","positions","extent","position","PositionTracker","cursor","_key","attributes","total","free","minX","minY","maxX","maxY","x","y","moved","syncGraph","scene","colors","changed","hadNodes","node","edge","GraphCanvas","theme","apiRef","onSelect","onContextMenu","onExpand","onPin","onLayoutChange","containerRef","useRef","graphRef","rendererRef","layoutRef","layoutTimerRef","dragRef","dragLayoutRef","settleTimerRef","layoutDeadlineRef","heldRef","pinnedRef","hoverRef","callbacksRef","mountAttempt","setMountAttempt","useState","Graph","stopLayout","useCallback","startLayout","budgetMs","hold","inferred","forceAtlas2","layout","FA2LayoutSupervisor","drag","startedAt","tracker","hasMoved","quietSamples","onBudget","movement","applyHover","renderer","previous","nodes","useEffect","container","observer","attempt","isDark","Sigma","DEFAULT_STYLES","_attributes","state","graphState","event","original","holdAllBut","wasRunning","camera","handleCameraUpdate","ratio","isZoomedIn","preventContextMenu","sizeObserver","hidden","pinsChanged","fixed","source","target","jsx","GraphContextMenu","menu","relationships","isPinned","onClose","onExpandAll","onExpandAttribute","onHide","onHideOthers","onTogglePin","onOpenRecord","jsxs","DropdownMenu","open","DropdownMenuTrigger","DropdownMenuContent","DropdownMenuItem","DropdownMenuSub","DropdownMenuSubTrigger","DropdownMenuSubContent","attribute","DropdownMenuSeparator","EMPTY_SCENE","mergeCounts","current","incoming","next","perAttribute","mergeFetched","merged","offset","withoutNodes","dropped","edges","pinned","sceneReducer","action","MAX_NODES","kept","entity","countNodesByEntity","result","countEdgesByAttribute","neighbourKeys","getTextColorOn","hex","r","g","b","channel","GraphInspector","schema","scope","isLoading","getEntity","detailsDocument","useMemo","gql","buildDetailsQuery","countsDocument","buildCountsQuery","details","useQuery","counts","record","countRecord","onCanvas","getRelationshipAttributes","getDetailAttributes","updatedAt","color","getEntityLabel","Button","XIcon","SquareArrowOutUpRightIcon","Tooltip","TooltipTrigger","LoaderCircleIcon","ExpandIcon","TooltipContent","EyeOffIcon","formatDetailValue","formatDistance","relatedEntity","shown","fetched","exhausted","SEARCH_DEBOUNCE_MS","SEARCH_HITS_PER_ENTITY","buildSearchRequest","entities","q","trimmed","useTotals","countable","getTotalEntities","document","buildTotalsQuery","data","pair","GraphSidebar","projectId","hiddenEntities","onStart","onHit","onToggleEntity","query","setQuery","debouncedQuery","useDebounce","searchable","request","results","useSearch","totals","entityByName","onCanvasEntities","Sidebar","SidebarContent","SidebarGroup","SearchIcon","Input","hit","label","getDisplayAttribute","SidebarGroupLabel","SidebarMenu","SidebarMenuItem","SidebarMenuButton","name","checked","id","Checkbox","SidebarRail","ToolbarButton","icon","disabled","onClick","GraphToolbar","hasSelection","hasNodes","onFit","onClear","ScanIcon","Separator","EraserIcon","errorMessage","error","useScene","client","useApolloClient","dispatch","useReducer","pending","setPending","loadRecords","selection","ids","expand","limit","records","buildRecordsQuery","graphFromRecords","fetchedFromRecords","nodeKey","toast","expandAll","expandAttribute","buildExpandQuery","EXPAND_PAGE","received","related","Root","currentProjectId","currentProject","currentProjectSchema","useConfig","auth","useAuth","useAppContext","resolvedTheme","useTheme","location","useLocation","dispatchAction","useDispatch","defaultScope","item","scopeField","userSpaces","filterEntitiesForSpaces","getGraphEntities","getEntityColors","canvasApi","setMenu","isLayoutRunning","setIsLayoutRunning","loadedSearchRef","selectedNode","menuNode","menuEntity","nodeCount","edgeCount","defaultOpen","readSidebarCookieState","select","openRecord","hide","hideOthers","togglePin","pin","addRecord","entityName","expandAttributeAndClose","params","parseGraphParams","EXPAND_HOP_MAX_RECORDS","SAMPLE_LIMIT","SidebarProvider","SidebarInset","SidebarTrigger"],"mappings":"o+CAYO,SAASA,EAAAA,CAAaC,CAAAA,CAAuB,CAClD,OAAO,KAAK,GAAA,CAAI,GAAA,CAAO,IAAOA,CAAAA,CAAQ,CAAC,CACzC,CAiBO,SAASC,EAAAA,CAAU,CAAE,KAAAC,CAAAA,CAAM,GAAA,CAAAC,EAAK,QAAA,CAAAC,CAAS,EAA4B,CAC1E,IAAMC,CAAAA,CAAY,IAAA,CAAK,IAAI,GAAA,CAAMD,CAAAA,CAAW,KAAM,CAAA,CAElD,OAAOF,EAAOG,CAAAA,EAAaF,CAAAA,CAAME,EAAY,EAC/C,CCYA,IAAMC,EAAAA,CAAmB,EAAA,CAEnBC,GAAqB,GAAA,CAErBC,EAAAA,CAAgB,IAAA,CAEhBC,EAAAA,CAAuB,EAE7B,SAASC,EAAAA,CAASC,EAAwB,CACxC,SAAW,IAAA,CAAK,GAAA,CAAI,EAAA,CAAI,IAAA,CAAK,KAAKA,CAAM,CAAA,CAAI,CAAC,CAC/C,CAKA,SAASC,EAAAA,CAAWC,CAAAA,CAAuB,CACzC,OAAOP,IAAoB,EAAA,CAAM,IAAA,CAAK,KAAKO,CAAK,CAAA,CAAI,GACtD,CAMA,SAASC,EAAAA,CAAcC,CAAAA,CAAeF,EAAeG,CAAAA,CAAyB,CAC5E,IAAMC,CAAAA,CAAQ,IAAA,CAAK,QAAO,CAAI,IAAA,CAAK,EAAA,CAAK,CAAA,CAExC,OAAO,KAAA,CAAM,IAAA,CAAK,CAAE,MAAA,CAAQJ,CAAM,EAAG,CAACK,C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,MAAA,CAAQ2L,EACR,YAAA,CAAcD,CAAAA,CACd,MAAOhO,GAAAA,CACP,MAAA,CAAQqE,EACR,KAAA,CAAOyI,GAAAA,CACT,EACE,IAAA,CAAA,CACN,CAAA,CACF,GACF,CAAA,CAvGE7L,GAAAA,CAAC,QAAK,SAAA,CAAU,0GAAA,CAA2G,kDAE3H,CAuGN","file":"root-TZYOIXVG.js","sourcesContent":["/**\n * Pure layout rules of the canvas: how long the force layout may run, when\n * it counts as settled, and when a graph is too dense for labels everywhere.\n */\n\n/** Above this many nodes, labels show only around the pointer and the selection unless zoomed in. */\nexport const DENSE_NODES = 300;\n\n/** Camera ratio below which a dense graph shows labels again (1 = the whole graph in view). */\nexport const ZOOMED_IN_RATIO = 0.45;\n\n/** The longest the force layout runs after a change: 2 s for a few nodes, 20 s at the cap. */\nexport function layoutBudget(order: number): number {\n return Math.min(20000, 2000 + order * 9);\n}\n\n/** How much the free nodes moved since the last sample, and the graph's extent. */\nexport interface LayoutMovement {\n /** Mean move of the nodes the layout may move. */\n mean: number;\n /** Largest move of any of them: a few new nodes still flying in keep the layout going. */\n max: number;\n /** Bounding-box diagonal of the whole graph. */\n diagonal: number;\n}\n\n/**\n * Whether the layout has settled: the mean move per free node is a sliver\n * of the graph's extent and no node is still travelling, with a floor so a\n * tiny graph settles too.\n */\nexport function isSettled({ mean, max, diagonal }: LayoutMovement): boolean {\n const threshold = Math.max(0.05, diagonal * 0.0015);\n\n return mean < threshold && max < threshold * 20;\n}\n","'use client';\n\nimport { useCallback, useEffect, useRef, useState } from 'react';\nimport type { JSX, MutableRefObject } from 'react';\nimport Graph from 'graphology';\nimport type { Attributes } from 'graphology-types';\nimport forceAtlas2 from 'graphology-layout-forceatlas2';\nimport FA2LayoutSupervisor from 'graphology-layout-forceatlas2/worker';\nimport Sigma, { DEFAULT_STYLES } from 'sigma';\nimport { DENSE_NODES, isSettled, layoutBudget, ZOOMED_IN_RATIO, type LayoutMovement } from './layout';\nimport type { SceneState } from './scene';\n\ntype NodeAttributes = {\n entity: string;\n label: string;\n color: string;\n size: number;\n x: number;\n y: number;\n fixed?: boolean;\n};\ntype EdgeAttributes = { size: number };\n/** A neighbour of the hovered node, for its label. */\ntype NodeState = { isNeighbour: boolean };\ntype EdgeState = Record<string, never>;\n/** Too many nodes for labels everywhere; zoomed in far enough to show them anyway. */\ntype GraphState = { isDense: boolean; isZoomedIn: boolean };\ntype Renderer = Sigma<NodeAttributes, EdgeAttributes, Attributes, NodeState, EdgeState, GraphState>;\n\nexport interface GraphCanvasApi {\n /** Brings the whole graph into view. */\n fit: () => void;\n}\n\nexport interface GraphCanvasProps {\n scene: SceneState;\n colors: { [entity: string]: string };\n theme: 'light' | 'dark';\n apiRef: MutableRefObject<GraphCanvasApi | null>;\n onSelect: (key: string | null) => void;\n onContextMenu: (key: string, position: { x: number; y: number }) => void;\n onExpand: (key: string) => void;\n onPin: (key: string) => void;\n onLayoutChange: (running: boolean) => void;\n}\n\n/** Spread of new nodes around the node they came from, in graph units. */\nconst PLACEMENT_RADIUS = 40;\n/** How often the layout is checked for movement. */\nconst SETTLE_INTERVAL_MS = 400;\n/** The layout runs at least this long before it may be called settled. */\nconst SETTLE_MIN_MS = 1200;\n/** Two quiet samples in a row, after the worker first moved something, end the layout. */\nconst SETTLE_QUIET_SAMPLES = 2;\n\nfunction nodeSize(degree: number): number {\n return 5 + Math.min(10, Math.sqrt(degree) * 2);\n}\n\ntype Point = { x: number; y: number };\n\n/** The ring new nodes start on: wider the more of them share an anchor, so they do not explode apart. */\nfunction ringRadius(count: number): number {\n return PLACEMENT_RADIUS * (0.8 + Math.sqrt(count) * 0.6);\n}\n\n/**\n * Evenly spaced positions on a ring, with a little jitter so no two coincide\n * and a random phase so a lone newcomer can land on any side of its anchor.\n */\nfunction ringPositions(center: Point, count: number, radius: number): Point[] {\n const phase = Math.random() * Math.PI * 2;\n\n return Array.from({ length: count }, (_, index) => {\n const angle = phase + (index / count) * Math.PI * 2 + Math.random() * 0.3;\n const distance = radius * (0.9 + Math.random() * 0.2);\n\n return { x: center.x + Math.cos(angle) * distance, y: center.y + Math.sin(angle) * distance };\n });\n}\n\nfunction isPositioned(graph: Graph<NodeAttributes, EdgeAttributes>, key: string): boolean {\n return !Number.isNaN(graph.getNodeAttribute(key, 'x'));\n}\n\n/** Centre and reach of the nodes already placed, to put unanchored newcomers beyond them. */\nfunction placedExtent(\n graph: Graph<NodeAttributes, EdgeAttributes>,\n placed: string[]\n): { center: Point; reach: number } {\n if (placed.length === 0) {\n return { center: { x: 0, y: 0 }, reach: 0 };\n }\n\n const center = placed.reduce(\n (sum, key) => ({ x: sum.x + graph.getNodeAttribute(key, 'x'), y: sum.y + graph.getNodeAttribute(key, 'y') }),\n { x: 0, y: 0 }\n );\n center.x /= placed.length;\n center.y /= placed.length;\n const reach = placed.reduce(\n (max, key) =>\n Math.max(\n max,\n Math.hypot(graph.getNodeAttribute(key, 'x') - center.x, graph.getNodeAttribute(key, 'y') - center.y)\n ),\n 0\n );\n\n return { center, reach };\n}\n\n/**\n * Places new nodes: those sharing an anchor already on the canvas go on a\n * ring around it, the rest on a ring beyond everything placed so far.\n */\nfunction placeNewNodes(graph: Graph<NodeAttributes, EdgeAttributes>, added: Set<string>): void {\n const groups = new Map<string | null, string[]>();\n added.forEach((key) => {\n const anchor =\n graph.neighbors(key).find((neighbour) => !added.has(neighbour) && isPositioned(graph, neighbour)) ?? null;\n groups.set(anchor, [...(groups.get(anchor) ?? []), key]);\n });\n groups.forEach((keys, anchor) => {\n let positions: Point[];\n\n if (anchor) {\n const center = { x: graph.getNodeAttribute(anchor, 'x'), y: graph.getNodeAttribute(anchor, 'y') };\n positions = ringPositions(center, keys.length, ringRadius(keys.length));\n } else {\n const placed = graph.nodes().filter((key) => !added.has(key) && isPositioned(graph, key));\n const extent = placedExtent(graph, placed);\n positions = ringPositions(extent.center, keys.length, extent.reach + ringRadius(keys.length));\n }\n\n positions.forEach((position, index) => graph.mergeNodeAttributes(keys[index]!, position));\n });\n}\n\n/**\n * Positions of every node, kept in one typed array the layout's movement is\n * measured against: one pass per sample, no allocation.\n */\nclass PositionTracker {\n private positions: Float64Array;\n\n constructor(private readonly graph: Graph<NodeAttributes, EdgeAttributes>) {\n this.positions = new Float64Array(graph.order * 2);\n let cursor = 0;\n this.graph.forEachNode((_key, attributes) => {\n this.positions[cursor] = attributes.x;\n this.positions[cursor + 1] = attributes.y;\n cursor += 2;\n });\n }\n\n /** Movement since the last call, then remembers the current positions. */\n measure(): LayoutMovement {\n const { graph, positions } = this;\n let total = 0;\n let max = 0;\n let free = 0;\n let minX = Number.POSITIVE_INFINITY;\n let minY = Number.POSITIVE_INFINITY;\n let maxX = Number.NEGATIVE_INFINITY;\n let maxY = Number.NEGATIVE_INFINITY;\n let index = 0;\n graph.forEachNode((_key, attributes) => {\n const { x, y } = attributes;\n\n if (index + 1 < positions.length && !attributes.fixed) {\n const moved = Math.hypot(x - positions[index]!, y - positions[index + 1]!);\n total += moved;\n max = Math.max(max, moved);\n free += 1;\n }\n\n positions[index] = x;\n positions[index + 1] = y;\n index += 2;\n minX = Math.min(minX, x);\n minY = Math.min(minY, y);\n maxX = Math.max(maxX, x);\n maxY = Math.max(maxY, y);\n });\n\n return {\n mean: free > 0 ? total / free : 0,\n max,\n diagonal: graph.order > 0 ? Math.hypot(maxX - minX, maxY - minY) : 0,\n };\n }\n}\n\n/**\n * Adds the scene's new nodes and edges to the graph, drops the removed ones\n * and places new nodes around what is already on the canvas. Reports what\n * was added and whether anything was placed before.\n */\nfunction syncGraph(\n graph: Graph<NodeAttributes, EdgeAttributes>,\n scene: SceneState,\n colors: { [entity: string]: string }\n): { changed: boolean; added: Set<string>; hadNodes: boolean } {\n let changed = false;\n const added = new Set<string>();\n const hadNodes = graph.order > 0;\n\n graph.forEachNode((key) => {\n if (!scene.nodes[key]) {\n graph.dropNode(key);\n changed = true;\n }\n });\n Object.values(scene.nodes).forEach((node) => {\n if (graph.hasNode(node.key)) {\n return;\n }\n\n graph.addNode(node.key, {\n entity: node.entity,\n label: node.label,\n color: colors[node.entity] ?? '#71717a',\n size: 5,\n x: Number.NaN,\n y: Number.NaN,\n });\n added.add(node.key);\n changed = true;\n });\n graph.forEachEdge((key) => {\n if (!scene.edges[key]) {\n graph.dropEdge(key);\n changed = true;\n }\n });\n // A multigraph: two relationships between the same records are two edges.\n Object.values(scene.edges).forEach((edge) => {\n if (!graph.hasEdge(edge.key)) {\n graph.addEdgeWithKey(edge.key, edge.source, edge.target, { size: 1 });\n changed = true;\n }\n });\n\n placeNewNodes(graph, added);\n\n if (changed) {\n graph.forEachNode((key) => {\n graph.setNodeAttribute(key, 'size', nodeSize(graph.degree(key)));\n });\n }\n\n return { changed, added, hadNodes };\n}\n\n/**\n * The WebGL canvas: a graphology graph that lives as long as the component,\n * rendered by sigma and laid out by ForceAtlas2 in a web worker until it\n * settles after every change. Selection, hover, entity visibility and pins\n * are sigma states and node attributes; the scene stays the source of truth.\n */\nexport function GraphCanvas({\n scene,\n colors,\n theme,\n apiRef,\n onSelect,\n onContextMenu,\n onExpand,\n onPin,\n onLayoutChange,\n}: GraphCanvasProps): JSX.Element {\n const containerRef = useRef<HTMLDivElement>(null);\n const graphRef = useRef<Graph<NodeAttributes, EdgeAttributes> | null>(null);\n const rendererRef = useRef<Renderer | null>(null);\n const layoutRef = useRef<FA2LayoutSupervisor | null>(null);\n const layoutTimerRef = useRef<number | null>(null);\n /** The node under the pointer while one is dragged, with the pointer's graph position. */\n const dragRef = useRef<{ node: string; x: number; y: number } | null>(null);\n /** The layout a drag started, so a drop restarts only that one. */\n const dragLayoutRef = useRef<FA2LayoutSupervisor | null>(null);\n const settleTimerRef = useRef<number | null>(null);\n const layoutDeadlineRef = useRef<number | null>(null);\n /** Nodes held still for the running layout so only newcomers move. */\n const heldRef = useRef<Set<string>>(new Set());\n const pinnedRef = useRef<SceneState['pinned']>(scene.pinned);\n pinnedRef.current = scene.pinned;\n /** The hovered node and the neighbours marked around it. */\n const hoverRef = useRef<{ key: string | null; nodes: string[] }>({ key: null, nodes: [] });\n const callbacksRef = useRef({ onSelect, onContextMenu, onExpand, onPin, onLayoutChange });\n const [mountAttempt, setMountAttempt] = useState(0);\n callbacksRef.current = { onSelect, onContextMenu, onExpand, onPin, onLayoutChange };\n\n if (!graphRef.current) {\n graphRef.current = new Graph<NodeAttributes, EdgeAttributes>({ type: 'undirected', multi: true });\n }\n\n const stopLayout = useCallback((): void => {\n if (layoutTimerRef.current !== null) {\n window.clearTimeout(layoutTimerRef.current);\n layoutTimerRef.current = null;\n }\n\n if (settleTimerRef.current !== null) {\n window.clearInterval(settleTimerRef.current);\n settleTimerRef.current = null;\n }\n\n if (layoutRef.current) {\n layoutRef.current.kill();\n layoutRef.current = null;\n layoutDeadlineRef.current = null;\n callbacksRef.current.onLayoutChange(false);\n }\n\n const graph = graphRef.current;\n heldRef.current.forEach((key) => {\n if (graph?.hasNode(key)) {\n graph.setNodeAttribute(key, 'fixed', pinnedRef.current[key] === true);\n }\n });\n heldRef.current = new Set();\n }, []);\n\n // The worker reads `fixed` only when it (re)builds its matrices, so a new\n // supervisor is needed whenever pins change while a layout runs. The\n // layout stops once the nodes stop moving, or at the budget. Nodes in\n // `hold` stay where they are, so adding to a settled canvas moves only\n // the newcomers instead of shaking everything.\n const startLayout = useCallback(\n (budgetMs: number, hold: string[] = []): void => {\n const graph = graphRef.current;\n stopLayout();\n\n if (!graph || graph.order === 0) {\n return;\n }\n\n heldRef.current = new Set(hold.filter((key) => graph.hasNode(key)));\n heldRef.current.forEach((key) => graph.setNodeAttribute(key, 'fixed', true));\n\n // Nothing free to move (say, a dragged node without neighbours): a run would never settle.\n if (!graph.someNode((_key, attributes) => !attributes.fixed)) {\n stopLayout();\n\n return;\n }\n\n const inferred = forceAtlas2.inferSettings(graph);\n const layout = new FA2LayoutSupervisor(graph, {\n // Gentle gravity keeps loose parts near the rest; the extra slowdown keeps the motion calm.\n settings: { ...inferred, adjustSizes: true, gravity: 0.2, slowDown: (inferred.slowDown ?? 1) * 2 },\n // A dragged node stays under the pointer: the worker's positions are\n // overridden for it, and with a reducer set the supervisor reads the\n // graph's positions back into the worker, so the neighbours follow.\n outputReducer: (key: string, attributes: NodeAttributes): NodeAttributes => {\n const drag = dragRef.current;\n\n if (drag && drag.node === key) {\n attributes.x = drag.x;\n attributes.y = drag.y;\n }\n\n return attributes;\n },\n });\n const startedAt = performance.now();\n const tracker = new PositionTracker(graph);\n let hasMoved = false;\n let quietSamples = 0;\n layoutRef.current = layout;\n layoutDeadlineRef.current = startedAt + budgetMs;\n layout.start();\n callbacksRef.current.onLayoutChange(true);\n // While a node is dragged the layout runs on: the budget is extended and settling does not stop it.\n const onBudget = (): void => {\n if (dragRef.current) {\n layoutDeadlineRef.current = performance.now() + budgetMs;\n layoutTimerRef.current = window.setTimeout(onBudget, budgetMs);\n } else {\n stopLayout();\n }\n };\n layoutTimerRef.current = window.setTimeout(onBudget, budgetMs);\n settleTimerRef.current = window.setInterval(() => {\n const movement = tracker.measure();\n\n if (dragRef.current) {\n quietSamples = 0;\n\n return;\n }\n\n // The worker needs a moment to spawn; quiet samples before its first\n // positions arrive say nothing about the layout.\n hasMoved = hasMoved || movement.max > 0;\n quietSamples = hasMoved && isSettled(movement) ? quietSamples + 1 : 0;\n\n if (quietSamples >= SETTLE_QUIET_SAMPLES && performance.now() - startedAt >= SETTLE_MIN_MS) {\n stopLayout();\n }\n }, SETTLE_INTERVAL_MS);\n },\n [stopLayout]\n );\n\n /**\n * Marks the hovered node's neighbours so their labels show, clearing the\n * previous marks first. Re-run after the graph changes so nodes added\n * under the pointer are marked too, and marks of dropped nodes go away.\n */\n const applyHover = useCallback((key: string | null): void => {\n const graph = graphRef.current;\n const renderer = rendererRef.current;\n\n if (!graph || !renderer) {\n return;\n }\n\n const previous = hoverRef.current;\n renderer.setNodesState(\n previous.nodes.filter((node) => graph.hasNode(node)),\n { isNeighbour: false }\n );\n\n if (key && graph.hasNode(key)) {\n const nodes = graph.neighbors(key);\n renderer.setNodesState(nodes, { isNeighbour: true });\n hoverRef.current = { key, nodes };\n } else {\n hoverRef.current = { key: null, nodes: [] };\n }\n }, []);\n\n // The renderer: created per theme (styles are fixed at construction) over\n // the persistent graph.\n useEffect(() => {\n const container = containerRef.current;\n const graph = graphRef.current;\n\n if (!container || !graph) {\n return undefined;\n }\n\n // Sigma throws when the container has no size yet (first paint of a lazy\n // route, hidden app); wait for the box to get one before mounting.\n if (container.clientWidth === 0 || container.clientHeight === 0) {\n const observer = new ResizeObserver(() => {\n if (container.clientWidth > 0 && container.clientHeight > 0) {\n observer.disconnect();\n setMountAttempt((attempt) => attempt + 1);\n }\n });\n observer.observe(container);\n\n return () => observer.disconnect();\n }\n\n const isDark = theme === 'dark';\n const renderer: Renderer = new Sigma<NodeAttributes, EdgeAttributes, Attributes, NodeState, EdgeState, GraphState>(\n graph,\n container,\n {\n customNodeState: { isNeighbour: false },\n customEdgeState: {},\n customGraphState: { isDense: graph.order > DENSE_NODES, isZoomedIn: false },\n settings: {\n // Every render starts with a resize, which would throw while the\n // app is hidden but kept mounted; a hidden canvas renders at 1 px\n // instead and the size observer restores it when it shows again.\n allowInvalidContainer: true,\n itemSizesReference: 'screen',\n enableNodeDrag: true,\n renderEdgeLabels: false,\n labelRenderedSizeThreshold: 7,\n labelDensity: 0.1,\n labelGridCellSize: 80,\n },\n styles: {\n nodes: [\n {\n ...DEFAULT_STYLES.nodes,\n size: {\n whenState: 'isHighlighted',\n then: (attributes: NodeAttributes) => attributes.size + 5,\n else: {\n whenState: 'isHovered',\n then: (attributes: NodeAttributes) => attributes.size + 2,\n else: { attribute: 'size' },\n },\n },\n cursor: 'pointer',\n labelColor: isDark ? '#e4e4e7' : '#18181b',\n labelSize: 12,\n labelFont: 'ui-sans-serif, system-ui, sans-serif',\n // Dense graphs label only the pointer's surroundings and the\n // selection until zoomed in. Neighbours always go through the\n // label grid: a hub's many neighbours would otherwise pile up.\n labelVisibility: (_attributes, state, graphState) => {\n if (state.isHovered || state.isHighlighted) {\n return 'visible';\n }\n\n return graphState.isDense && !graphState.isZoomedIn && !state.isNeighbour ? 'hidden' : 'auto';\n },\n backdropColor: isDark ? '#27272a' : '#ffffff',\n backdropShadowColor: isDark ? 'rgba(0, 0, 0, 0.6)' : 'rgba(0, 0, 0, 0.25)',\n },\n ],\n edges: [\n {\n ...DEFAULT_STYLES.edges,\n color: isDark ? '#3f3f46' : '#d4d4d8',\n size: 1,\n },\n ],\n },\n }\n );\n rendererRef.current = renderer;\n\n renderer.on('clickNode', ({ node }) => {\n callbacksRef.current.onSelect(node);\n });\n renderer.on('clickStage', () => {\n callbacksRef.current.onSelect(null);\n });\n renderer.on('doubleClickNode', ({ node, event }) => {\n event.preventSigmaDefault();\n callbacksRef.current.onExpand(node);\n });\n renderer.on('rightClickNode', ({ node, event }) => {\n event.preventSigmaDefault();\n const original = event.original as MouseEvent;\n original.preventDefault();\n callbacksRef.current.onSelect(node);\n callbacksRef.current.onContextMenu(node, { x: original.clientX, y: original.clientY });\n });\n renderer.on('enterNode', ({ node }) => applyHover(node));\n renderer.on('leaveNode', () => applyHover(null));\n // Dragging a node pulls its neighbours along: the layout runs while the\n // drag lasts with the node held under the pointer, so a cluster can be\n // pulled apart. Everything else is held, so the rest of the canvas\n // stays still, and a canvas without relationships has nothing to pull on.\n const holdAllBut = (node: string): string[] => {\n const free = new Set([node, ...graph.neighbors(node)]);\n\n return graph.nodes().filter((key) => key === node || !free.has(key));\n };\n renderer.on('nodeDragStart', ({ node }) => {\n dragRef.current = { node, x: graph.getNodeAttribute(node, 'x'), y: graph.getNodeAttribute(node, 'y') };\n\n if (graph.size > 0) {\n startLayout(layoutBudget(graph.order), holdAllBut(node));\n dragLayoutRef.current = layoutRef.current;\n } else {\n stopLayout();\n graph.setNodeAttribute(node, 'fixed', true);\n }\n });\n renderer.on('nodeDrag', ({ node }) => {\n if (dragRef.current?.node === node) {\n dragRef.current.x = graph.getNodeAttribute(node, 'x');\n dragRef.current.y = graph.getNodeAttribute(node, 'y');\n }\n });\n renderer.on('nodeDragEnd', ({ node }) => {\n // A scene change during the drag replaced its layout with one settling\n // newcomers; that one keeps running, with the drop pinned by the scene.\n const wasRunning =\n dragRef.current !== null && layoutRef.current !== null && layoutRef.current === dragLayoutRef.current;\n dragRef.current = null;\n dragLayoutRef.current = null;\n callbacksRef.current.onPin(node);\n\n // The node stays where it was dropped while its neighbours settle around it.\n if (wasRunning) {\n startLayout(layoutBudget(graph.order), holdAllBut(node));\n }\n });\n\n const camera = renderer.getCamera();\n const handleCameraUpdate = ({ ratio }: { ratio: number }): void => {\n const isZoomedIn = ratio < ZOOMED_IN_RATIO;\n\n if (renderer.getGraphState().isZoomedIn !== isZoomedIn) {\n renderer.setGraphState({ isZoomedIn });\n }\n };\n camera.on('updated', handleCameraUpdate);\n\n const preventContextMenu = (event: MouseEvent): void => event.preventDefault();\n container.addEventListener('contextmenu', preventContextMenu);\n\n // Sigma only watches the window: the canvases must follow the container\n // when a pane opens beside it, or they keep their size and overflow it.\n const sizeObserver = new ResizeObserver(() => {\n if (container.clientWidth > 0 && container.clientHeight > 0) {\n renderer.resize();\n renderer.scheduleRefresh();\n }\n });\n sizeObserver.observe(container);\n\n apiRef.current = {\n fit: () => {\n void camera.reset({ duration: 300 });\n },\n };\n\n return () => {\n sizeObserver.disconnect();\n camera.off('updated', handleCameraUpdate);\n container.removeEventListener('contextmenu', preventContextMenu);\n apiRef.current = null;\n rendererRef.current = null;\n hoverRef.current = { key: null, nodes: [] };\n renderer.kill();\n };\n }, [theme, mountAttempt, apiRef, startLayout, stopLayout, applyHover]);\n\n // Scene changes: sync the graph, then let the layout settle the new nodes.\n useEffect(() => {\n const graph = graphRef.current;\n\n if (!graph) {\n return;\n }\n\n // The layout's supervisor respawns its worker on every graph change, on\n // a timer that outlives `kill()`: stop it before the graph is touched.\n stopLayout();\n const { changed, added, hadNodes } = syncGraph(graph, scene, colors);\n\n if (!changed) {\n return;\n }\n\n rendererRef.current?.setGraphState({ isDense: graph.order > DENSE_NODES });\n // Nodes added under the pointer get their hover marks; marks of dropped nodes go.\n applyHover(graph.hasNode(hoverRef.current.key ?? '') ? hoverRef.current.key : null);\n\n // Nothing to pull on: a bare sample stays on its ring.\n if (graph.size === 0) {\n stopLayout();\n\n return;\n }\n\n // Adding to a placed canvas: hold what is there, settle the newcomers.\n const hold = hadNodes && added.size > 0 ? graph.nodes().filter((key) => !added.has(key)) : [];\n startLayout(layoutBudget(hold.length > 0 ? added.size : graph.order), hold);\n // Nodes and edges only change with the scene version; colours are applied by their own effect.\n // eslint-disable-next-line react-hooks/exhaustive-deps -- see above\n }, [scene.version]);\n\n // Theme change: recolour the nodes.\n useEffect(() => {\n const graph = graphRef.current;\n\n if (!graph) {\n return;\n }\n\n graph.forEachNode((key, attributes) => {\n graph.setNodeAttribute(key, 'color', colors[attributes.entity] ?? '#71717a');\n });\n }, [colors]);\n\n // Selection, switched-off entities and pins.\n useEffect(() => {\n const graph = graphRef.current;\n const renderer = rendererRef.current;\n\n if (!graph || !renderer) {\n return;\n }\n\n const hidden = new Set(scene.hiddenEntities);\n let pinsChanged = false;\n graph.forEachNode((key, attributes) => {\n renderer.setNodeState(key, { isHidden: hidden.has(attributes.entity), isHighlighted: key === scene.selected });\n const fixed = scene.pinned[key] === true || heldRef.current.has(key);\n\n if ((attributes.fixed ?? false) !== fixed) {\n graph.setNodeAttribute(key, 'fixed', fixed);\n pinsChanged = true;\n }\n });\n\n // A pin change during a run restarts it with the same hold, so the\n // nodes kept still for it stay still.\n if (pinsChanged && layoutDeadlineRef.current !== null) {\n startLayout(Math.max(500, layoutDeadlineRef.current - performance.now()), [...heldRef.current]);\n }\n graph.forEachEdge((key, _attributes, source, target) => {\n renderer.setEdgeState(key, {\n isHidden:\n hidden.has(graph.getNodeAttribute(source, 'entity')) || hidden.has(graph.getNodeAttribute(target, 'entity')),\n });\n });\n }, [scene.hiddenEntities, scene.selected, scene.pinned, scene.version, mountAttempt, theme, startLayout]);\n\n // Unmount: stop the worker.\n useEffect(() => stopLayout, [stopLayout]);\n\n return <div className=\"fk:h-full fk:w-full fk:min-h-0\" ref={containerRef} />;\n}\n","'use client';\n\nimport type { JSX } from 'react';\nimport type { Attribute } from '../../core/types';\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuSeparator,\n DropdownMenuSub,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n DropdownMenuTrigger,\n} from '../../ui';\n\nexport interface GraphContextMenuState {\n key: string;\n x: number;\n y: number;\n}\n\nexport interface GraphContextMenuProps {\n menu: GraphContextMenuState | null;\n relationships: Attribute[];\n isPinned: boolean;\n onClose: () => void;\n onExpandAll: (key: string) => void;\n onExpandAttribute: (key: string, attribute: Attribute) => void;\n onHide: (key: string) => void;\n onHideOthers: (key: string) => void;\n onTogglePin: (key: string) => void;\n onOpenRecord: (key: string) => void;\n}\n\n/** The right-click menu of a node, anchored at the pointer. */\nexport function GraphContextMenu({\n menu,\n relationships,\n isPinned,\n onClose,\n onExpandAll,\n onExpandAttribute,\n onHide,\n onHideOthers,\n onTogglePin,\n onOpenRecord,\n}: GraphContextMenuProps): JSX.Element {\n const key = menu?.key ?? '';\n\n return (\n <DropdownMenu\n onOpenChange={(open) => {\n if (!open) {\n onClose();\n }\n }}\n open={menu !== null}\n >\n <DropdownMenuTrigger asChild>\n <span\n aria-hidden=\"true\"\n className=\"fk:fixed fk:size-0\"\n style={{ left: menu?.x ?? 0, top: menu?.y ?? 0 }}\n />\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"start\" className=\"fk:w-52\" data-testid=\"graph-context-menu\" side=\"bottom\">\n <DropdownMenuItem onSelect={() => onExpandAll(key)}>Expand all</DropdownMenuItem>\n {relationships.length > 0 ? (\n <DropdownMenuSub>\n <DropdownMenuSubTrigger>Expand</DropdownMenuSubTrigger>\n <DropdownMenuSubContent className=\"fk:max-h-80 fk:overflow-y-auto\">\n {relationships.map((attribute) => (\n <DropdownMenuItem key={attribute.name} onSelect={() => onExpandAttribute(key, attribute)}>\n {attribute.label}\n </DropdownMenuItem>\n ))}\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n ) : null}\n <DropdownMenuSeparator />\n <DropdownMenuItem onSelect={() => onHide(key)}>Hide</DropdownMenuItem>\n <DropdownMenuItem onSelect={() => onHideOthers(key)}>Hide others</DropdownMenuItem>\n <DropdownMenuItem onSelect={() => onTogglePin(key)}>{isPinned ? 'Unpin position' : 'Pin position'}</DropdownMenuItem>\n <DropdownMenuSeparator />\n <DropdownMenuItem onSelect={() => onOpenRecord(key)}>Open record</DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n","import { MAX_NODES, type GraphCounts, type GraphData, type GraphEdge, type GraphNode } from './graph';\n\n/**\n * The scene is what the canvas draws: the nodes and edges loaded so far,\n * which entities are switched off, which nodes are pinned, the selection.\n * A pure reducer so every rule is unit-tested; the canvas syncs to it.\n */\n\nexport interface SceneState {\n nodes: { [key: string]: GraphNode };\n edges: { [key: string]: GraphEdge };\n /** Total related records per relationship of a node, when the API told us. */\n counts: GraphCounts;\n /** Related records fetched so far per relationship of a node: the next page's offset. */\n fetched: GraphCounts;\n hiddenEntities: string[];\n pinned: { [key: string]: true };\n selected: string | null;\n /** A message for the status line, such as the node cap being reached. */\n notice: string | null;\n /** Bumped whenever nodes or edges change, so the canvas knows to sync. */\n version: number;\n}\n\nexport type SceneAction =\n | { type: 'merge'; data: GraphData; fetched?: GraphCounts }\n | { type: 'remove'; keys: string[] }\n | { type: 'keepOnly'; keys: string[] }\n | { type: 'clear' }\n | { type: 'toggleEntity'; entity: string }\n | { type: 'select'; key: string | null }\n | { type: 'togglePin'; key: string }\n | { type: 'notice'; message: string | null };\n\nexport const EMPTY_SCENE: SceneState = {\n nodes: {},\n edges: {},\n counts: {},\n fetched: {},\n hiddenEntities: [],\n pinned: {},\n selected: null,\n notice: null,\n version: 0,\n};\n\nfunction mergeCounts(current: GraphCounts, incoming: GraphCounts | undefined): GraphCounts {\n if (!incoming) {\n return current;\n }\n\n const next = { ...current };\n Object.entries(incoming).forEach(([key, perAttribute]) => {\n next[key] = { ...next[key], ...perAttribute };\n });\n\n return next;\n}\n\n/** Fetched offsets only move forward: a fresh first page never rewinds paging. */\nfunction mergeFetched(current: GraphCounts, incoming: GraphCounts | undefined): GraphCounts {\n if (!incoming) {\n return current;\n }\n\n const next = { ...current };\n Object.entries(incoming).forEach(([key, perAttribute]) => {\n const merged = { ...next[key] };\n Object.entries(perAttribute).forEach(([attribute, offset]) => {\n merged[attribute] = Math.max(merged[attribute] ?? 0, offset);\n });\n next[key] = merged;\n });\n\n return next;\n}\n\nfunction withoutNodes(state: SceneState, dropped: Set<string>): SceneState {\n const nodes = Object.fromEntries(Object.entries(state.nodes).filter(([key]) => !dropped.has(key)));\n const edges = Object.fromEntries(\n Object.entries(state.edges).filter(([, edge]) => !dropped.has(edge.source) && !dropped.has(edge.target))\n );\n const pinned = Object.fromEntries(Object.entries(state.pinned).filter(([key]) => !dropped.has(key)));\n\n return {\n ...state,\n nodes,\n edges,\n pinned,\n selected: state.selected && dropped.has(state.selected) ? null : state.selected,\n version: state.version + 1,\n };\n}\n\nexport function sceneReducer(state: SceneState, action: SceneAction): SceneState {\n switch (action.type) {\n case 'merge': {\n const nodes = { ...state.nodes };\n let count = Object.keys(nodes).length;\n let dropped = 0;\n\n action.data.nodes.forEach((node) => {\n if (nodes[node.key]) {\n return;\n }\n\n if (count >= MAX_NODES) {\n dropped += 1;\n\n return;\n }\n\n nodes[node.key] = node;\n count += 1;\n });\n\n const edges = { ...state.edges };\n action.data.edges.forEach((edge) => {\n if (nodes[edge.source] && nodes[edge.target]) {\n edges[edge.key] = edge;\n }\n });\n\n return {\n ...state,\n nodes,\n edges,\n counts: mergeCounts(state.counts, action.data.counts),\n fetched: mergeFetched(state.fetched, action.fetched),\n notice:\n dropped > 0\n ? `The canvas holds ${MAX_NODES.toLocaleString()} nodes at most; ${dropped.toLocaleString()} were left out. Hide some nodes to make room.`\n : state.notice,\n version: state.version + 1,\n };\n }\n case 'remove':\n return withoutNodes(state, new Set(action.keys));\n case 'keepOnly': {\n const kept = new Set(action.keys);\n\n return withoutNodes(state, new Set(Object.keys(state.nodes).filter((key) => !kept.has(key))));\n }\n case 'clear':\n return { ...EMPTY_SCENE, hiddenEntities: state.hiddenEntities, version: state.version + 1 };\n case 'toggleEntity':\n return {\n ...state,\n hiddenEntities: state.hiddenEntities.includes(action.entity)\n ? state.hiddenEntities.filter((entity) => entity !== action.entity)\n : [...state.hiddenEntities, action.entity],\n };\n case 'select':\n return state.selected === action.key ? state : { ...state, selected: action.key };\n case 'togglePin': {\n const pinned = { ...state.pinned };\n\n if (pinned[action.key]) {\n delete pinned[action.key];\n } else {\n pinned[action.key] = true;\n }\n\n return { ...state, pinned };\n }\n case 'notice':\n return { ...state, notice: action.message };\n default:\n return state;\n }\n}\n\n/** Nodes on the canvas per entity, for the legend. */\nexport function countNodesByEntity(state: SceneState): { [entity: string]: number } {\n return Object.values(state.nodes).reduce<{ [entity: string]: number }>((result, node) => {\n result[node.entity] = (result[node.entity] ?? 0) + 1;\n\n return result;\n }, {});\n}\n\n/** Related nodes of one node per relationship attribute that are on the canvas. */\nexport function countEdgesByAttribute(state: SceneState, key: string): { [attribute: string]: number } {\n return Object.values(state.edges).reduce<{ [attribute: string]: number }>((result, edge) => {\n if (edge.source === key) {\n result[edge.sourceAttribute] = (result[edge.sourceAttribute] ?? 0) + 1;\n } else if (edge.target === key) {\n result[edge.targetAttribute] = (result[edge.targetAttribute] ?? 0) + 1;\n }\n\n return result;\n }, {});\n}\n\n/** Keys of the nodes joined to one node by an edge. */\nexport function neighbourKeys(state: SceneState, key: string): string[] {\n return Object.values(state.edges).flatMap((edge) => {\n if (edge.source === key) {\n return [edge.target];\n }\n\n if (edge.target === key) {\n return [edge.source];\n }\n\n return [];\n });\n}\n","'use client';\n\nimport { useMemo } from 'react';\nimport type { JSX } from 'react';\nimport { gql } from '@apollo/client';\nimport { useQuery } from '@apollo/client/react';\nimport { formatDistance } from 'date-fns';\nimport { EyeOffIcon, ExpandIcon, LoaderCircleIcon, SquareArrowOutUpRightIcon, XIcon } from 'lucide-react';\nimport type { Attribute, Entity } from '../../core/types';\nimport { Button, Tooltip, TooltipContent, TooltipTrigger } from '../../ui';\nimport {\n buildCountsQuery,\n buildDetailsQuery,\n formatDetailValue,\n getDetailAttributes,\n getEntity,\n getEntityLabel,\n getRelationshipAttributes,\n type GraphNode,\n type GraphRecord,\n} from './graph';\nimport { countEdgesByAttribute, type SceneState } from './scene';\n\nexport interface GraphInspectorProps {\n node: GraphNode;\n schema: Entity[];\n scope: string;\n scene: SceneState;\n colors: { [entity: string]: string };\n isLoading: boolean;\n onClose: () => void;\n onOpenRecord: (key: string) => void;\n onExpandAll: (key: string) => void;\n onExpandAttribute: (key: string, attribute: Attribute) => void;\n onHide: (key: string) => void;\n}\n\ntype ConnectionCount = { aggregate?: { count?: { nodes?: number } } };\n\n/**\n * Black or white, whichever reads better on a palette color (`#rrggbb`): the\n * yellows and greens are too light for white text.\n */\nfunction getTextColorOn(hex: string): string {\n const [r, g, b] = [1, 3, 5].map((offset) => {\n const channel = parseInt(hex.slice(offset, offset + 2), 16) / 255;\n\n return channel <= 0.03928 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4;\n });\n const luminance = 0.2126 * r + 0.7152 * g + 0.0722 * b;\n\n return luminance > 0.3 ? '#0a0a0a' : '#ffffff';\n}\ntype DetailsResult = { [plural: string]: (GraphRecord & { _updatedAt?: string })[] };\n\n/**\n * The selected node: its scalar attributes in the current scope and each\n * relationship with how many related records are on the canvas out of the\n * total, with a button to fetch the next page.\n */\nexport function GraphInspector({\n node,\n schema,\n scope,\n scene,\n colors,\n isLoading,\n onClose,\n onOpenRecord,\n onExpandAll,\n onExpandAttribute,\n onHide,\n}: GraphInspectorProps): JSX.Element {\n const entity = getEntity(schema, node.entity);\n const detailsDocument = useMemo(\n () => gql(entity ? buildDetailsQuery({ entity, scope }) : 'query GraphDetails { __typename }'),\n [entity, scope]\n );\n const countsDocument = useMemo(\n () => gql(entity ? buildCountsQuery({ entity }) : 'query GraphCounts { __typename }'),\n [entity]\n );\n const details = useQuery<DetailsResult>(detailsDocument, { variables: { id: node.id }, skip: !entity });\n const counts = useQuery<{ [plural: string]: { [field: string]: ConnectionCount }[] }>(countsDocument, {\n variables: { id: node.id },\n skip: !entity,\n });\n const record = entity ? details.data?.[entity.plural]?.[0] : undefined;\n const countRecord = entity ? counts.data?.[entity.plural]?.[0] : undefined;\n const onCanvas = useMemo(() => countEdgesByAttribute(scene, node.key), [scene, node.key]);\n const relationships = entity ? getRelationshipAttributes(entity) : [];\n const attributes = entity ? getDetailAttributes(entity) : [];\n const updatedAt = record?._updatedAt ? new Date(record._updatedAt) : null;\n const color = colors[node.entity] ?? '#71717a';\n\n return (\n <aside\n aria-label=\"Selected record\"\n className=\"fk:flex fk:w-72 fk:shrink-0 fk:flex-col fk:gap-5 fk:overflow-y-auto fk:border-l fk:bg-background fk:p-4 fk:text-sm\"\n data-testid=\"graph-inspector\"\n >\n <div className=\"fk:flex fk:flex-col fk:gap-2\">\n <div className=\"fk:flex fk:items-center fk:justify-between fk:gap-2\">\n <span\n className=\"fk:inline-flex fk:items-center fk:rounded-full fk:px-2 fk:py-0.5 fk:text-xs fk:font-medium\"\n style={{ backgroundColor: color, color: getTextColorOn(color) }}\n >\n {entity ? getEntityLabel(entity) : node.entity}\n </span>\n <Button aria-label=\"Close\" className=\"fk:size-7\" onClick={onClose} size=\"icon\" variant=\"ghost\">\n <XIcon className=\"fk:size-4\" />\n </Button>\n </div>\n <h2 className=\"fk:text-base fk:font-semibold fk:leading-snug fk:break-words\">{node.label}</h2>\n <div className=\"fk:flex fk:gap-1.5\">\n <Button onClick={() => onOpenRecord(node.key)} size=\"xs\">\n <SquareArrowOutUpRightIcon />\n Open record\n </Button>\n <Tooltip>\n <TooltipTrigger asChild>\n <Button\n aria-label=\"Expand every relationship\"\n disabled={isLoading}\n onClick={() => onExpandAll(node.key)}\n size=\"xs\"\n variant=\"outline\"\n >\n {isLoading ? <LoaderCircleIcon className=\"fk:animate-spin\" /> : <ExpandIcon />}\n Expand\n </Button>\n </TooltipTrigger>\n <TooltipContent>Load the first related records of every relationship</TooltipContent>\n </Tooltip>\n <Button aria-label=\"Hide this node\" onClick={() => onHide(node.key)} size=\"xs\" variant=\"outline\">\n <EyeOffIcon />\n Hide\n </Button>\n </div>\n </div>\n\n <section className=\"fk:flex fk:flex-col fk:gap-2\">\n <h3 className=\"fk:text-xs fk:font-medium fk:text-muted-foreground\">Attributes</h3>\n {details.loading && !record ? (\n <span className=\"fk:text-muted-foreground\">Loading…</span>\n ) : (\n <dl className=\"fk:grid fk:grid-cols-[minmax(0,2fr)_minmax(0,3fr)] fk:gap-x-3 fk:gap-y-1.5\">\n {attributes.map((attribute) => (\n <div className=\"fk:contents\" key={attribute.name}>\n <dt className=\"fk:truncate fk:text-muted-foreground\" title={attribute.label}>\n {attribute.label}\n </dt>\n <dd className=\"fk:min-w-0 fk:break-words\">{record ? formatDetailValue(record[attribute.name], scope) || '—' : '—'}</dd>\n </div>\n ))}\n {updatedAt ? (\n <div className=\"fk:contents\">\n <dt className=\"fk:text-muted-foreground\">Updated</dt>\n <dd>{formatDistance(updatedAt, new Date(), { addSuffix: true })}</dd>\n </div>\n ) : null}\n </dl>\n )}\n </section>\n\n {relationships.length > 0 ? (\n <section className=\"fk:flex fk:flex-col fk:gap-1\">\n <h3 className=\"fk:mb-1 fk:text-xs fk:font-medium fk:text-muted-foreground\">Relationships</h3>\n {relationships.map((attribute) => {\n const relatedEntity = getEntity(schema, attribute.relationship?.entity ?? '');\n const total = countRecord?.[`${attribute.name}Connection`]?.aggregate?.count?.nodes;\n const shown = onCanvas[attribute.name] ?? 0;\n const fetched = scene.fetched[node.key]?.[attribute.name] ?? 0;\n const exhausted = typeof total === 'number' && fetched >= total;\n\n return (\n <div className=\"fk:flex fk:h-8 fk:items-center fk:gap-2\" key={attribute.name}>\n <span\n aria-hidden=\"true\"\n className=\"fk:size-2 fk:shrink-0 fk:rounded-full\"\n style={{ backgroundColor: colors[attribute.relationship?.entity ?? ''] ?? '#71717a' }}\n />\n <span className=\"fk:min-w-0 fk:flex-1 fk:truncate\" title={relatedEntity ? getEntityLabel(relatedEntity) : undefined}>\n {attribute.label}\n </span>\n <span className=\"fk:text-xs fk:text-muted-foreground\">\n {typeof total === 'number' ? `${shown} of ${total.toLocaleString()}` : shown}\n </span>\n {total === 0 || exhausted ? null : (\n <Button\n className=\"fk:h-6 fk:px-2 fk:text-xs\"\n disabled={isLoading}\n onClick={() => onExpandAttribute(node.key, attribute)}\n size=\"xs\"\n variant=\"outline\"\n >\n {fetched > 0 ? 'More' : 'Expand'}\n </Button>\n )}\n </div>\n );\n })}\n </section>\n ) : null}\n </aside>\n );\n}\n","'use client';\n\nimport { useMemo, useState } from 'react';\nimport type { JSX } from 'react';\nimport { gql } from '@apollo/client';\nimport { useQuery } from '@apollo/client/react';\nimport { SearchIcon } from 'lucide-react';\nimport { useDebounce } from 'use-debounce';\nimport { getDisplayAttribute } from '../../core/get-display-attribute';\nimport { useSearch } from '../../core/use-search';\nimport type { Entity, SearchRequestProps } from '../../core/types';\nimport {\n Checkbox,\n Input,\n SidebarContent,\n SidebarGroup,\n SidebarGroupLabel,\n SidebarMenu,\n SidebarMenuButton,\n SidebarMenuItem,\n SidebarPanel,\n SidebarRail,\n} from '../../ui';\nimport { buildTotalsQuery, getEntityLabel, getTotalEntities } from './graph';\n\nconst SEARCH_DEBOUNCE_MS = 250;\nconst SEARCH_HITS_PER_ENTITY = 5;\n\nexport interface GraphSidebarProps {\n projectId: string;\n entities: Entity[];\n colors: { [entity: string]: string };\n /** Nodes on the canvas per entity. */\n onCanvas: { [entity: string]: number };\n hiddenEntities: string[];\n onStart: (entity: Entity) => void;\n onHit: (entityName: string, id: string) => void;\n onToggleEntity: (entityName: string) => void;\n}\n\nfunction buildSearchRequest(entities: Entity[], q: string): SearchRequestProps | null {\n const trimmed = q.trim();\n\n if (!trimmed || entities.length === 0) {\n return null;\n }\n\n return {\n searchRequests: { searches: entities.map((entity) => ({ collection: entity.plural })) },\n commonParams: { q: trimmed, limit: SEARCH_HITS_PER_ENTITY },\n };\n}\n\n/** Count-store totals per entity for the \"Nodes\" list; absent for space-bound entities. */\nfunction useTotals(entities: Entity[]): { [plural: string]: number } {\n const countable = useMemo(() => getTotalEntities(entities), [entities]);\n const document = useMemo(() => gql(countable.length > 0 ? buildTotalsQuery(countable) : 'query GraphTotals { __typename }'), [countable]);\n const { data } = useQuery<{ [field: string]: number }>(document, { skip: countable.length === 0 });\n\n return useMemo(\n () =>\n Object.fromEntries(\n countable\n .map((entity) => [entity.plural, data?.[`${entity.plural}Total`]] as const)\n .filter((pair): pair is readonly [string, number] => typeof pair[1] === 'number')\n ),\n [countable, data]\n );\n}\n\n/**\n * Search a record to add it to the canvas, start from a whole entity, and the\n * legend of what is on the canvas with a switch per entity.\n */\nexport function GraphSidebar({\n projectId,\n entities,\n colors,\n onCanvas,\n hiddenEntities,\n onStart,\n onHit,\n onToggleEntity,\n}: GraphSidebarProps): JSX.Element {\n const [query, setQuery] = useState('');\n const [debouncedQuery] = useDebounce(query, SEARCH_DEBOUNCE_MS);\n const searchable = useMemo(\n () => entities.filter((entity) => entity.attributes.some((attribute) => attribute.searchable)),\n [entities]\n );\n const request = useMemo(() => buildSearchRequest(searchable, debouncedQuery), [searchable, debouncedQuery]);\n const { results, isLoading } = useSearch(projectId, request);\n const totals = useTotals(entities);\n const entityByName = useMemo(() => new Map(entities.map((entity) => [entity.name, entity])), [entities]);\n const onCanvasEntities = Object.keys(onCanvas).sort();\n\n return (\n <SidebarPanel collapsible=\"icon\" variant=\"inset\">\n <SidebarContent>\n <SidebarGroup className=\"fk:group-data-[collapsible=icon]:hidden\">\n <div className=\"fk:relative\">\n <SearchIcon className=\"fk:pointer-events-none fk:absolute fk:left-2 fk:top-1/2 fk:size-4 fk:-translate-y-1/2 fk:text-muted-foreground\" />\n <Input\n aria-label=\"Search records to add to the canvas\"\n className=\"fk:h-8 fk:bg-background fk:pl-8 fk:shadow-none\"\n onChange={(event) => setQuery(event.target.value)}\n placeholder={searchable.length > 0 ? 'Search records…' : 'No searchable entity'}\n disabled={searchable.length === 0}\n value={query}\n />\n </div>\n {request ? (\n <ul className=\"fk:mt-2 fk:flex fk:flex-col fk:gap-0.5\" data-testid=\"graph-search-results\">\n {results.map((hit) => {\n const entity = entityByName.get(hit._entityName);\n const label = hit[getDisplayAttribute(entity)?.name ?? ''];\n\n return (\n <li key={`${hit._entityName}:${hit._id}`}>\n <button\n className=\"fk:flex fk:w-full fk:items-center fk:gap-2 fk:rounded-md fk:px-2 fk:py-1.5 fk:text-left fk:text-sm fk:hover:bg-sidebar-accent\"\n onClick={() => onHit(hit._entityName, hit._id)}\n type=\"button\"\n >\n <span\n aria-hidden=\"true\"\n className=\"fk:size-2.5 fk:shrink-0 fk:rounded-full\"\n style={{ backgroundColor: colors[hit._entityName] ?? '#71717a' }}\n />\n <span className=\"fk:min-w-0 fk:flex-1 fk:truncate\">{String(label ?? hit._id)}</span>\n </button>\n </li>\n );\n })}\n {!isLoading && results.length === 0 ? (\n <li className=\"fk:px-2 fk:py-1.5 fk:text-sm fk:text-muted-foreground\">Nothing found</li>\n ) : null}\n </ul>\n ) : null}\n </SidebarGroup>\n\n <SidebarGroup>\n <SidebarGroupLabel>Nodes</SidebarGroupLabel>\n <SidebarMenu>\n {entities.map((entity) => (\n <SidebarMenuItem key={entity.name}>\n <SidebarMenuButton onClick={() => onStart(entity)} tooltip={getEntityLabel(entity)}>\n <span\n aria-hidden=\"true\"\n className=\"fk:size-2.5 fk:shrink-0 fk:rounded-full\"\n style={{ backgroundColor: colors[entity.name] ?? '#71717a' }}\n />\n <span className=\"fk:truncate\">{getEntityLabel(entity)}</span>\n {totals[entity.plural] !== undefined ? (\n <span className=\"fk:ml-auto fk:text-xs fk:text-muted-foreground\">\n {totals[entity.plural]?.toLocaleString()}\n </span>\n ) : null}\n </SidebarMenuButton>\n </SidebarMenuItem>\n ))}\n </SidebarMenu>\n </SidebarGroup>\n\n {onCanvasEntities.length > 0 ? (\n <SidebarGroup className=\"fk:group-data-[collapsible=icon]:hidden\">\n <SidebarGroupLabel>On canvas</SidebarGroupLabel>\n <ul className=\"fk:flex fk:flex-col\" data-testid=\"graph-legend\">\n {onCanvasEntities.map((name) => {\n const entity = entityByName.get(name);\n const checked = !hiddenEntities.includes(name);\n const id = `graph-legend-${name}`;\n\n return (\n <li className=\"fk:flex fk:h-8 fk:items-center fk:gap-2 fk:px-2 fk:text-sm\" key={name}>\n <span\n aria-hidden=\"true\"\n className=\"fk:size-2.5 fk:shrink-0 fk:rounded-full\"\n style={{ backgroundColor: colors[name] ?? '#71717a', opacity: checked ? 1 : 0.35 }}\n />\n <label className=\"fk:min-w-0 fk:flex-1 fk:cursor-pointer fk:truncate\" htmlFor={id}>\n {entity ? getEntityLabel(entity) : name}\n </label>\n <span className=\"fk:text-xs fk:text-muted-foreground\">{onCanvas[name]?.toLocaleString()}</span>\n <Checkbox\n aria-label={`Show ${entity ? getEntityLabel(entity) : name}`}\n checked={checked}\n id={id}\n onCheckedChange={() => onToggleEntity(name)}\n />\n </li>\n );\n })}\n </ul>\n </SidebarGroup>\n ) : null}\n </SidebarContent>\n <SidebarRail />\n </SidebarPanel>\n );\n}\n","'use client';\n\nimport type { JSX } from 'react';\nimport { EraserIcon, ExpandIcon, EyeOffIcon, LoaderCircleIcon, ScanIcon } from 'lucide-react';\nimport { Button, Separator, Tooltip, TooltipContent, TooltipTrigger } from '../../ui';\n\nexport interface GraphToolbarProps {\n hasSelection: boolean;\n hasNodes: boolean;\n isLoading: boolean;\n onFit: () => void;\n onExpand: () => void;\n onHide: () => void;\n onClear: () => void;\n}\n\nfunction ToolbarButton({\n label,\n icon,\n disabled,\n onClick,\n}: {\n label: string;\n icon: JSX.Element;\n disabled?: boolean;\n onClick: () => void;\n}): JSX.Element {\n return (\n <Tooltip>\n <TooltipTrigger asChild>\n <Button className=\"fk:h-8 fk:gap-1.5 fk:px-2.5\" disabled={disabled} onClick={onClick} size=\"sm\" variant=\"ghost\">\n {icon}\n <span className=\"fk:text-xs\">{label}</span>\n </Button>\n </TooltipTrigger>\n <TooltipContent>{label}</TooltipContent>\n </Tooltip>\n );\n}\n\n/** The floating actions over the canvas. */\nexport function GraphToolbar({\n hasSelection,\n hasNodes,\n isLoading,\n onFit,\n onExpand,\n onHide,\n onClear,\n}: GraphToolbarProps): JSX.Element {\n return (\n <div\n className=\"fk:flex fk:items-center fk:gap-0.5 fk:rounded-lg fk:border fk:bg-background fk:p-1 fk:shadow-xs\"\n data-testid=\"graph-toolbar\"\n >\n <ToolbarButton disabled={!hasNodes} icon={<ScanIcon className=\"fk:size-3.5\" />} label=\"Fit\" onClick={onFit} />\n <Separator className=\"fk:mx-0.5 fk:h-4\" orientation=\"vertical\" />\n <ToolbarButton\n disabled={!hasSelection || isLoading}\n icon={isLoading ? <LoaderCircleIcon className=\"fk:size-3.5 fk:animate-spin\" /> : <ExpandIcon className=\"fk:size-3.5\" />}\n label=\"Expand\"\n onClick={onExpand}\n />\n <ToolbarButton disabled={!hasSelection} icon={<EyeOffIcon className=\"fk:size-3.5\" />} label=\"Hide\" onClick={onHide} />\n <Separator className=\"fk:mx-0.5 fk:h-4\" orientation=\"vertical\" />\n <ToolbarButton disabled={!hasNodes} icon={<EraserIcon className=\"fk:size-3.5\" />} label=\"Clear\" onClick={onClear} />\n </div>\n );\n}\n","'use client';\n\nimport { useCallback, useReducer, useState } from 'react';\nimport type { Dispatch } from 'react';\nimport { gql } from '@apollo/client';\nimport { useApolloClient } from '@apollo/client/react';\nimport { toast } from '../../ui';\nimport type { Attribute, Entity } from '../../core/types';\nimport {\n buildExpandQuery,\n buildRecordsQuery,\n EXPAND_PAGE,\n fetchedFromRecords,\n getEntity,\n graphFromRecords,\n nodeKey,\n type GraphRecord,\n} from './graph';\nimport { EMPTY_SCENE, sceneReducer, type SceneAction, type SceneState } from './scene';\n\n/** Which records to load: given ids (with their first hop when `expand`), or a sample. */\nexport type RecordSelection = { ids: string[]; expand: boolean } | { limit: number };\n\nexport interface SceneApi {\n state: SceneState;\n dispatch: Dispatch<SceneAction>;\n isLoading: boolean;\n /** Loads records, with the first page of each relationship when asked; resolves to their node keys. */\n loadRecords: (entity: Entity, selection: RecordSelection) => Promise<string[]>;\n /** Loads the first page of every relationship of a node. */\n expandAll: (key: string) => Promise<void>;\n /** Loads the next page of one relationship of a node. */\n expandAttribute: (key: string, attribute: Attribute) => Promise<void>;\n}\n\ntype RecordsResult = { [plural: string]: GraphRecord[] };\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : 'The records could not be loaded.';\n}\n\n/**\n * The scene plus the loaders that grow it through the project GraphQL API,\n * so the roles and spaces of the signed-in member apply to every node.\n */\nexport function useScene({ schema, scope }: { schema: Entity[]; scope: string }): SceneApi {\n const client = useApolloClient();\n const [state, dispatch] = useReducer(sceneReducer, EMPTY_SCENE);\n const [pending, setPending] = useState(0);\n\n const loadRecords = useCallback(\n async (entity: Entity, selection: RecordSelection): Promise<string[]> => {\n const ids = 'ids' in selection ? selection.ids : undefined;\n const expand = 'ids' in selection ? selection.expand : false;\n const limit = 'limit' in selection ? selection.limit : ids?.length;\n setPending((count) => count + 1);\n\n try {\n const result = await client.query<RecordsResult>({\n query: gql(buildRecordsQuery({ entity, schema, scope, expand })),\n variables: {\n where: ids ? { _id: { in: ids } } : undefined,\n limit,\n },\n fetchPolicy: 'network-only',\n });\n const records = result.data?.[entity.plural] ?? [];\n dispatch({\n type: 'merge',\n data: graphFromRecords({ records, entity, schema, scope }),\n fetched: fetchedFromRecords(records, entity),\n });\n\n return records.map((record) => nodeKey(entity.name, record._id));\n } catch (error) {\n toast.error(errorMessage(error));\n\n return [];\n } finally {\n setPending((count) => count - 1);\n }\n },\n [client, schema, scope]\n );\n\n const expandAll = useCallback(\n async (key: string): Promise<void> => {\n const node = state.nodes[key];\n const entity = node ? getEntity(schema, node.entity) : undefined;\n\n if (!node || !entity) {\n return;\n }\n\n await loadRecords(entity, { ids: [node.id], expand: true });\n },\n [loadRecords, schema, state.nodes]\n );\n\n const expandAttribute = useCallback(\n async (key: string, attribute: Attribute): Promise<void> => {\n const node = state.nodes[key];\n const entity = node ? getEntity(schema, node.entity) : undefined;\n\n if (!node || !entity) {\n return;\n }\n\n const offset = state.fetched[key]?.[attribute.name] ?? 0;\n setPending((count) => count + 1);\n\n try {\n const result = await client.query<RecordsResult>({\n query: gql(buildExpandQuery({ entity, schema, scope, attribute })),\n variables: { id: node.id, offset, limit: EXPAND_PAGE },\n fetchPolicy: 'network-only',\n });\n const records = result.data?.[entity.plural] ?? [];\n const received = records.reduce((sum, record) => {\n const related = record[attribute.name];\n\n return sum + (Array.isArray(related) ? related.length : 0);\n }, 0);\n dispatch({\n type: 'merge',\n data: graphFromRecords({ records, entity, schema, scope }),\n fetched: { [key]: { [attribute.name]: offset + received } },\n });\n } catch (error) {\n toast.error(errorMessage(error));\n } finally {\n setPending((count) => count - 1);\n }\n },\n [client, schema, scope, state.fetched, state.nodes]\n );\n\n return { state, dispatch, isLoading: pending > 0, loadRecords, expandAll, expandAttribute };\n}\n","'use client';\n\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport type { JSX } from 'react';\nimport { useLocation } from 'react-router-dom';\nimport { useAuth } from '../../auth/auth-context';\nimport { useAppContext } from '../../core/app-context';\nimport { useConfig } from '../../core/config/config-context';\nimport { filterEntitiesForSpaces } from '../../core/spaces';\nimport type { Attribute } from '../../core/types';\nimport { useDispatch } from '../../entities/actions-context';\nimport {\n readSidebarCookieState,\n SidebarInset,\n SidebarProvider,\n SidebarTrigger,\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from '../../ui';\nimport { useTheme } from '../../ui/theme-context';\nimport { GraphCanvas, type GraphCanvasApi } from './canvas';\nimport { GraphContextMenu, type GraphContextMenuState } from './context-menu';\nimport {\n EXPAND_HOP_MAX_RECORDS,\n getEntity,\n getEntityColors,\n getGraphEntities,\n getRelationshipAttributes,\n parseGraphParams,\n SAMPLE_LIMIT,\n} from './graph';\nimport { GraphInspector } from './inspector';\nimport { countNodesByEntity, neighbourKeys } from './scene';\nimport { GraphSidebar } from './sidebar';\nimport { GraphToolbar } from './toolbar';\nimport { useScene } from './use-scene';\n\n/**\n * The Graph app: explore records as nodes and relationships. The sidebar\n * adds records, the canvas draws them, the inspector details the selection.\n * Other apps open it with `?entity=<name>&ids=<id,id>` to show those records\n * expanded one hop.\n */\nexport function Root(): JSX.Element {\n const { currentProjectId, currentProject, currentProjectSchema } = useConfig();\n const [, auth] = useAuth();\n const { scope } = useAppContext();\n const { resolvedTheme } = useTheme();\n const location = useLocation();\n const dispatchAction = useDispatch();\n const theme = resolvedTheme === 'dark' ? 'dark' : 'light';\n const defaultScope = currentProject?.scopes?.find((item) => item.isDefault)?.name ?? 'default';\n const scopeField = scope || defaultScope;\n // Space-bound entities are hidden from non-members, as in Desk; the API\n // rejects their data either way.\n const userSpaces = auth.user?.spaces;\n const schema = useMemo(() => filterEntitiesForSpaces(currentProjectSchema, userSpaces), [currentProjectSchema, userSpaces]);\n const entities = useMemo(() => getGraphEntities(schema), [schema]);\n const colors = useMemo(() => getEntityColors(schema, theme), [schema, theme]);\n const scene = useScene({ schema, scope: scopeField });\n const { state, dispatch, isLoading, loadRecords, expandAll, expandAttribute } = scene;\n const canvasApi = useRef<GraphCanvasApi | null>(null);\n const [menu, setMenu] = useState<GraphContextMenuState | null>(null);\n const [isLayoutRunning, setIsLayoutRunning] = useState(false);\n const loadedSearchRef = useRef<string | null>(null);\n const onCanvas = useMemo(() => countNodesByEntity(state), [state]);\n const selectedNode = state.selected ? state.nodes[state.selected] : undefined;\n const menuNode = menu ? state.nodes[menu.key] : undefined;\n const menuEntity = menuNode ? getEntity(schema, menuNode.entity) : undefined;\n const nodeCount = Object.keys(state.nodes).length;\n const edgeCount = Object.keys(state.edges).length;\n const defaultOpen = readSidebarCookieState();\n\n const select = useCallback((key: string | null) => dispatch({ type: 'select', key }), [dispatch]);\n\n const openRecord = useCallback(\n (key: string) => {\n const node = state.nodes[key];\n const entity = node ? getEntity(schema, node.entity) : undefined;\n\n if (node && entity) {\n dispatchAction({ type: 'EditEntity', payload: { entityId: node.id, entityNamePlural: entity.plural } });\n }\n },\n [dispatchAction, schema, state.nodes]\n );\n\n const hide = useCallback((key: string) => dispatch({ type: 'remove', keys: [key] }), [dispatch]);\n\n const hideOthers = useCallback(\n (key: string) => dispatch({ type: 'keepOnly', keys: [key, ...neighbourKeys(state, key)] }),\n [dispatch, state]\n );\n\n const togglePin = useCallback((key: string) => dispatch({ type: 'togglePin', key }), [dispatch]);\n\n const pin = useCallback(\n (key: string) => {\n if (!state.pinned[key]) {\n dispatch({ type: 'togglePin', key });\n }\n },\n [dispatch, state.pinned]\n );\n\n const addRecord = useCallback(\n async (entityName: string, id: string) => {\n const entity = getEntity(schema, entityName);\n\n if (!entity) {\n return;\n }\n\n const [key] = await loadRecords(entity, { ids: [id], expand: true });\n\n if (key) {\n select(key);\n }\n },\n [loadRecords, schema, select]\n );\n\n const expandAttributeAndClose = useCallback(\n (key: string, attribute: Attribute) => {\n setMenu(null);\n void expandAttribute(key, attribute);\n },\n [expandAttribute]\n );\n\n // Records another app asked for: `?entity=product&ids=a,b` loads those\n // records, expanded one hop when they are few, `?entity=product` a sample.\n useEffect(() => {\n const params = parseGraphParams(location.search);\n\n // Keyed on the navigation, not the query string: opening the same\n // records again after a Clear must load them again.\n if (!params || loadedSearchRef.current === location.key) {\n return;\n }\n\n const entity = getEntity(schema, params.entity);\n\n if (!entity || schema.length === 0) {\n return;\n }\n\n loadedSearchRef.current = location.key;\n const selection =\n params.ids.length > 0\n ? { ids: params.ids, expand: params.ids.length <= EXPAND_HOP_MAX_RECORDS }\n : { limit: SAMPLE_LIMIT };\n void loadRecords(entity, selection).then((keys) => {\n if (params.ids.length === 1 && keys[0]) {\n select(keys[0]);\n }\n });\n }, [location.key, location.search, schema, loadRecords, select]);\n\n if (!currentProjectId) {\n return (\n <main className=\"fk:flex fk:h-full fk:flex-1 fk:items-center fk:justify-center fk:p-8 fk:text-sm fk:text-muted-foreground\">\n Select a project to explore its graph.\n </main>\n );\n }\n\n return (\n <SidebarProvider className=\"fk:h-full\" defaultOpen={defaultOpen}>\n <GraphSidebar\n colors={colors}\n entities={entities}\n hiddenEntities={state.hiddenEntities}\n onCanvas={onCanvas}\n onHit={(entityName, id) => void addRecord(entityName, id)}\n onStart={(entity) => void loadRecords(entity, { limit: SAMPLE_LIMIT })}\n onToggleEntity={(entityName) => dispatch({ type: 'toggleEntity', entity: entityName })}\n projectId={currentProjectId}\n />\n <SidebarInset className=\"fk:min-w-0\">\n <div className=\"fk:flex fk:h-full fk:min-h-0 fk:min-w-0\" data-testid=\"graph-app\">\n <div className=\"fk:relative fk:min-w-0 fk:flex-1 fk:overflow-hidden fk:bg-background\">\n <div className=\"fk:absolute fk:left-3 fk:top-3 fk:z-10 fk:flex fk:items-center fk:gap-2\">\n <Tooltip>\n <TooltipTrigger asChild>\n <SidebarTrigger className=\"fk:h-8 fk:w-8 fk:rounded-lg fk:hover:bg-transparent fk:dark:hover:bg-transparent\" />\n </TooltipTrigger>\n <TooltipContent>Toggle Sidebar</TooltipContent>\n </Tooltip>\n <GraphToolbar\n hasNodes={nodeCount > 0}\n hasSelection={selectedNode !== undefined}\n isLoading={isLoading}\n onClear={() => dispatch({ type: 'clear' })}\n onExpand={() => {\n if (state.selected) {\n void expandAll(state.selected);\n }\n }}\n onFit={() => canvasApi.current?.fit()}\n onHide={() => {\n if (state.selected) {\n hide(state.selected);\n }\n }}\n />\n </div>\n {nodeCount > 0 ? null : (\n <div className=\"fk:pointer-events-none fk:absolute fk:inset-0 fk:flex fk:items-center fk:justify-center fk:p-8 fk:text-center fk:text-sm fk:text-muted-foreground\">\n {isLoading ? 'Loading records…' : 'Search a record or start from an entity to draw its graph.'}\n </div>\n )}\n <GraphCanvas\n apiRef={canvasApi}\n colors={colors}\n onContextMenu={(key, position) => setMenu({ key, ...position })}\n onExpand={(key) => void expandAll(key)}\n onLayoutChange={setIsLayoutRunning}\n onPin={pin}\n onSelect={select}\n scene={state}\n theme={theme}\n />\n <div\n className=\"fk:absolute fk:bottom-3 fk:left-3 fk:flex fk:max-w-[calc(100%-1.5rem)] fk:items-center fk:gap-2 fk:rounded-lg fk:border fk:bg-background fk:px-2.5 fk:py-1.5 fk:text-xs fk:text-muted-foreground fk:shadow-xs\"\n data-testid=\"graph-status\"\n >\n <span>\n {nodeCount.toLocaleString()} {nodeCount === 1 ? 'node' : 'nodes'} · {edgeCount.toLocaleString()}{' '}\n {edgeCount === 1 ? 'relationship' : 'relationships'}\n </span>\n {isLayoutRunning ? <span>· laying out…</span> : null}\n {state.notice ? <span className=\"fk:truncate fk:text-foreground\">· {state.notice}</span> : null}\n </div>\n <GraphContextMenu\n isPinned={menu ? state.pinned[menu.key] === true : false}\n menu={menu}\n onClose={() => setMenu(null)}\n onExpandAll={(key) => void expandAll(key)}\n onExpandAttribute={expandAttributeAndClose}\n onHide={hide}\n onHideOthers={hideOthers}\n onOpenRecord={openRecord}\n onTogglePin={togglePin}\n relationships={menuEntity ? getRelationshipAttributes(menuEntity) : []}\n />\n </div>\n {selectedNode ? (\n <GraphInspector\n colors={colors}\n isLoading={isLoading}\n node={selectedNode}\n onClose={() => select(null)}\n onExpandAll={(key) => void expandAll(key)}\n onExpandAttribute={(key, attribute) => void expandAttribute(key, attribute)}\n onHide={hide}\n onOpenRecord={openRecord}\n scene={state}\n schema={schema}\n scope={scopeField}\n />\n ) : null}\n </div>\n </SidebarInset>\n </SidebarProvider>\n );\n}\n"]}
@@ -1,2 +0,0 @@
1
- import'./index.css';import {b as b$1}from'./chunk-F2DT6NRK.js';import'./chunk-UOR437J2.js';import {f,g,d as d$1}from'./chunk-DHVKE36X.js';import {b}from'./chunk-ZZRA4567.js';import'./chunk-A7XHA2P6.js';import {f as f$1}from'./chunk-B7QMGBK5.js';import {g as g$1}from'./chunk-2HYQVMP3.js';import'./chunk-5CVDMZUI.js';import {Tc,Vc,s,na,qa,O,e as e$2,ha,ia,ja}from'./chunk-DGIY4SKN.js';import {t}from'./chunk-SZEGGBOC.js';import {v,w,b as b$4}from'./chunk-32ZU4MLE.js';import'./chunk-U45E5X3H.js';import {a,d,c,e,g as g$2}from'./chunk-HDOIOXMP.js';import {b as b$3,c as c$1,e as e$1}from'./chunk-USNXQOMJ.js';import {b as b$2}from'./chunk-6NRQMG26.js';import'./chunk-O2QMYUPS.js';import {useState,useRef,useMemo,useEffect}from'react';import {Plus,LoaderCircle,Trash2,GraduationCapIcon,ArrowLeft,Info,PenLine,Eye}from'lucide-react';import Pt from'react-markdown';import {useNavigate,Link,useParams}from'react-router-dom';import ve from'swr';import At from'swr/infinite';import {history,defaultKeymap,historyKeymap,indentWithTab}from'@codemirror/commands';import {markdown}from'@codemirror/lang-markdown';import {languages}from'@codemirror/language-data';import {foldGutter,indentOnInput,bracketMatching,foldKeymap}from'@codemirror/language';import {highlightSelectionMatches,searchKeymap}from'@codemirror/search';import {Compartment,EditorState,Prec}from'@codemirror/state';import {EditorView,lineNumbers,highlightActiveLineGutter,highlightSpecialChars,drawSelection,dropCursor,highlightActiveLine,keymap,placeholder}from'@codemirror/view';import {tags}from'@lezer/highlight';import {createTheme}from'@uiw/codemirror-themes';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var je="var(--font-geist-mono), ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",Q="#212121",Y="#fafafa";function ze(t,i,o){return [t,EditorView.theme({"&":{backgroundColor:i},".cm-scroller":{backgroundColor:i},".cm-gutters":{backgroundColor:o}})]}var ce=ze(createTheme({settings:{background:Q,caret:"#f8f8f0",fontFamily:je,foreground:"#f8f8f2",gutterBackground:Q,gutterBorder:"transparent",gutterForeground:"#6d8a88",lineHighlight:"rgba(255, 255, 255, 0.1)",selection:"rgba(255, 255, 255, 0.1)",selectionMatch:"rgba(255, 255, 255, 0.2)"},styles:[{color:"#6272a4",tag:[tags.comment,tags.quote,tags.strikethrough]},{color:"#6272a4",tag:[tags.meta,tags.processingInstruction]},{color:"#f1fa8c",tag:tags.string},{color:"#f91f6f",tag:[tags.atom,tags.bool,tags.number,tags.heading]},{color:"#ff79c6",tag:[tags.keyword,tags.operator,tags.tagName]},{color:"#8be9fd",tag:[tags.typeName,tags.link,tags.url]},{color:"#009fb8",tag:[tags.className,tags.attributeName,tags.monospace]},{color:"#66d9ef",tag:[tags.propertyName,tags.function(tags.propertyName)]},{color:"#009fb8",tag:[tags.definition(tags.variableName),tags.function(tags.variableName)]},{color:"#0072f5",tag:[tags.strong,tags.emphasis]},{color:"#ff5555",tag:tags.invalid}],theme:"dark"}),Q,Q),de=ze(createTheme({settings:{background:Y,caret:"#526fff",fontFamily:je,foreground:"#383a42",gutterBackground:Y,gutterBorder:"transparent",gutterForeground:"#9d9d9f",lineHighlight:"#383a420c",selection:"#e5e5e6",selectionMatch:"#e5e5e6"},styles:[{color:"#a0a1a7",tag:[tags.comment,tags.quote,tags.strikethrough]},{color:"#a0a1a7",tag:[tags.meta,tags.processingInstruction]},{color:"#50a14f",tag:tags.string},{color:"#986801",tag:[tags.attributeName]},{color:"#a626a4",tag:tags.keyword},{color:"#0072f5",tag:[tags.operator,tags.strong,tags.emphasis]},{color:"#f91f6f",tag:[tags.atom,tags.bool,tags.number,tags.heading]},{color:"#c18401",tag:[tags.typeName,tags.className]},{color:"#009fb8",tag:[tags.tagName,tags.propertyName,tags.monospace]},{color:"#4078f2",tag:[tags.link,tags.url,tags.function(tags.variableName),tags.definition(tags.variableName)]},{color:"#f91f6f",tag:tags.invalid}],theme:"light"}),Y,Y);function me(){let t=document.documentElement;return t.getAttribute("data-theme")==="dark"||t.classList.contains("dark")||t.style.colorScheme==="dark"}var xt=EditorView.theme({"&":{fontSize:"13px",height:"100%",maxHeight:"100%",maxWidth:"100%",minHeight:"0",minWidth:"0",width:"100%"},"&.cm-focused":{outline:"none"},".cm-scroller":{height:"100%",lineHeight:"1.6",minHeight:"0",minWidth:"0",overflow:"auto",width:"100%"},".cm-content":{fontSize:"13px",fontStyle:"normal",fontWeight:"400",minWidth:"0 !important",padding:"12px 0"},".cm-line, .cm-line span":{fontSize:"inherit",fontStyle:"inherit",fontWeight:"inherit",lineHeight:"inherit"},".cm-gutters":{borderRight:"1px solid transparent"},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none"}});function ue(t){return [t?ce:de,xt]}function He(t){return [EditorState.readOnly.of(t),EditorView.editable.of(!t)]}function Oe(t){let i={"aria-multiline":"true",role:"textbox"};return t.ariaLabel&&(i["aria-label"]=t.ariaLabel),t.ariaLabelledBy&&(i["aria-labelledby"]=t.ariaLabelledBy),t.ariaDescribedBy&&(i["aria-describedby"]=t.ariaDescribedBy),t.ariaInvalid&&(i["aria-invalid"]="true"),t.readOnly&&(i["aria-readonly"]="true"),i}function Xe({ariaDescribedBy:t,ariaInvalid:i,ariaLabel:o,ariaLabelledBy:l,className:f,onBlur:d,onChange:k,onSave:u,placeholder:m,readOnly:c=false,value:p}){let h=useRef(null),y=useRef(null),L=useRef(new Compartment),P=useRef(new Compartment),N=useRef(new Compartment),C=useRef(d),w=useRef(k),I=useRef(u),v=useRef(p);return C.current=d,w.current=k,I.current=u,v.current=p,useEffect(()=>{let s=h.current;if(!s)return;let g=new EditorView({parent:s,state:EditorState.create({doc:v.current,extensions:[lineNumbers(),highlightActiveLineGutter(),highlightSpecialChars(),history(),foldGutter(),drawSelection(),dropCursor(),EditorState.allowMultipleSelections.of(true),indentOnInput(),bracketMatching(),highlightActiveLine(),highlightSelectionMatches(),EditorView.lineWrapping,markdown({codeLanguages:languages}),keymap.of([...defaultKeymap,...historyKeymap,...searchKeymap,...foldKeymap,indentWithTab]),Prec.highest(keymap.of([{key:"Mod-s",run:()=>(I.current?.(),true)}])),EditorView.updateListener.of(B=>{B.docChanged&&w.current?.(B.state.doc.toString()),B.focusChanged&&!B.view.hasFocus&&C.current?.();}),L.current.of(ue(me())),P.current.of(He(c)),N.current.of(EditorView.contentAttributes.of(Oe({ariaDescribedBy:t,ariaInvalid:i,ariaLabel:o,ariaLabelledBy:l,readOnly:c}))),...m?[placeholder(m)]:[]]})});y.current=g;let K=new ResizeObserver(()=>{g.requestMeasure();});K.observe(s);let G=new MutationObserver(()=>{g.dispatch({effects:L.current.reconfigure(ue(me()))});});return G.observe(document.documentElement,{attributeFilter:["class","data-theme","style"],attributes:true}),()=>{K.disconnect(),G.disconnect(),g.destroy(),y.current=null;}},[]),useEffect(()=>{let s=y.current;s&&s.dispatch({effects:L.current.reconfigure(ue(me()))});},[de,ce]),useEffect(()=>{let s=y.current;if(!s)return;let g=s.state.doc.toString();g!==p&&s.dispatch({changes:{from:0,to:g.length,insert:p}});},[p]),useEffect(()=>{let s=y.current;s&&s.dispatch({effects:[P.current.reconfigure(He(c)),N.current.reconfigure(EditorView.contentAttributes.of(Oe({ariaDescribedBy:t,ariaInvalid:i,ariaLabel:o,ariaLabelledBy:l,readOnly:c})))]});},[t,i,o,l,c]),jsx("div",{className:f??"fk:h-full fk:min-h-0 fk:min-w-0 fk:w-full fk:overflow-hidden",ref:h})}var Je=25,Bt=[{descriptionWidth:"fk:w-44",id:"skill-a",nameWidth:"fk:w-28"},{descriptionWidth:"fk:w-52",id:"skill-b",nameWidth:"fk:w-20"},{descriptionWidth:"fk:w-40",id:"skill-c",nameWidth:"fk:w-36"},{descriptionWidth:"fk:w-48",id:"skill-d",nameWidth:"fk:w-24"},{descriptionWidth:"fk:w-36",id:"skill-e",nameWidth:"fk:w-32"},{descriptionWidth:"fk:w-56",id:"skill-f",nameWidth:"fk:w-16"}];function Wt(){return jsxs("div",{"aria-busy":"true",className:"fk:grid fk:grid-cols-1 fk:gap-x-16 fk:gap-y-1 fk:lg:grid-cols-2",children:[jsx("span",{className:"fk:sr-only",children:"Loading skills"}),Bt.map(t$1=>jsxs("div",{className:"fk:-mx-3 fk:flex fk:min-w-0 fk:items-center fk:gap-3 fk:px-3 fk:py-2",children:[jsx(t,{className:"fk:size-10 fk:shrink-0 fk:rounded-lg"}),jsxs("span",{className:"fk:flex fk:min-w-0 fk:flex-1 fk:flex-col fk:gap-1.5",children:[jsx(t,{className:`fk:h-4 ${t$1.nameWidth}`}),jsx(t,{className:`fk:h-4 ${t$1.descriptionWidth}`})]})]},t$1.id))]})}var Rt={code({children:t,className:i,node:o,...l}){return typeof i=="string"&&i.split(" ").some(d=>d.startsWith("language-"))?jsx("code",{className:i,...l,children:t}):jsx("code",{className:"fk:rounded fk:bg-muted fk:px-1.5 fk:py-0.5 fk:font-mono fk:text-[0.875em] fk:font-medium fk:before:content-none fk:after:content-none fk:corner-squircle",...l,children:t})}};function be(){let{currentProjectId:t}=f$1();return {api:useMemo(()=>t?d$1(t):null,[t]),projectId:t}}function ie({children:t}){return jsx("div",{className:"fk:rounded-md fk:border fk:border-dashed fk:p-8 fk:text-center fk:text-sm fk:text-muted-foreground fk:corner-squircle",children:t})}function jt({onVisible:t}){let i=useRef(null),o=useRef(t);return o.current=t,useEffect(()=>{let l=i.current;if(!l)return;let f=new IntersectionObserver(d=>{d.some(k=>k.isIntersecting)&&o.current();});return f.observe(l),()=>{f.disconnect();}},[]),jsx("div",{"aria-hidden":true,className:"fk:h-px",ref:i})}function zt(t,i){return t.visibility==="space"?(t.spaceId?i.get(t.spaceId):void 0)??"Space":t.visibility==="personal"?"Personal":"Project"}function Dt({skill:t}){return t.logoUrl?jsx("img",{alt:"",className:"fk:size-10 fk:shrink-0 fk:rounded-lg fk:corner-squircle",src:t.logoUrl}):jsx("span",{className:"fk:flex fk:size-10 fk:shrink-0 fk:items-center fk:justify-center fk:rounded-lg fk:bg-muted fk:text-muted-foreground fk:corner-squircle",children:jsx(GraduationCapIcon,{className:"fk:size-5"})})}function hi(){let{api:t,projectId:i}=be(),o=useNavigate(),[l,f$1]=useState(""),d=b(),k=l.trim().length>0,u=(s,g$1)=>!i||g$1&&!g$1.hasMore?null:g(i).skills({limit:Je,offset:s*Je,search:l.trim()||void 0}),{data:m,isLoading:c,setSize:p,size:h}=At(u,f),y=m?.flatMap(s=>s.skills)??[],P=m?.[m.length-1]?.hasMore??false,N=m!==void 0&&h>m.length,C=c&&y.length===0;if(!i||!t)return jsx(ie,{children:"Select a project to view skills."});function w(){p(s=>s+1);}let I="No skills yet.";k&&(I="No skills match your search.");let v=jsx("div",{className:"fk:grid fk:grid-cols-1 fk:gap-x-16 fk:gap-y-1 fk:lg:grid-cols-2",children:y.map(s=>jsxs("button",{type:"button",onClick:()=>o(s.id),className:"fk:-mx-3 fk:flex fk:min-w-0 fk:items-center fk:gap-3 fk:rounded-lg fk:px-3 fk:py-2 fk:text-left fk:transition-colors fk:hover:bg-accent fk:focus-visible:bg-accent fk:focus-visible:outline-none fk:corner-squircle",children:[jsx(Dt,{skill:s}),jsxs("span",{className:"fk:min-w-0 fk:flex-1",children:[jsx("span",{className:"fk:block fk:truncate fk:text-sm fk:font-medium",children:s.name}),jsx("span",{className:"fk:block fk:truncate fk:text-sm fk:text-muted-foreground",children:s.description})]})]},s.id))});return C?v=jsx(Wt,{}):y.length===0&&(v=jsx(Tc,{children:jsx(Vc,{children:I})})),jsxs("main",{className:"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col",children:[jsx(b$1,{}),jsx("div",{className:"fk:min-h-0 fk:flex-1 fk:overflow-auto",children:jsxs("div",{className:"fk:mx-auto fk:flex fk:w-full fk:max-w-4xl fk:flex-col fk:gap-8 fk:py-6 fk:pl-4 fk:pr-6",children:[jsxs("div",{children:[jsx("h2",{className:"fk:text-2xl fk:font-semibold",children:"Skills for your agents"}),jsx("p",{className:"fk:mt-2 fk:text-muted-foreground",children:"Reusable Markdown instructions that agents load when relevant, or always when attached to an automation."})]}),jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-3",children:[jsx(s,{"aria-label":"Search skills",className:"fk:w-full fk:max-w-xs",placeholder:"Search skills\u2026",value:l,onChange:s=>{p(1),f$1(s.target.value);}}),d?jsx(b$2,{asChild:true,className:"fk:ml-auto",size:"sm",children:jsxs(Link,{to:"new",children:[jsx(Plus,{}),"New Skill"]})}):jsx(na,{disabled:true,children:jsxs(b$2,{className:"fk:ml-auto",disabled:true,size:"sm",children:[jsx(Plus,{}),"New Skill"]})})]}),v,P&&!N?jsx(jt,{onVisible:w}):null,N?jsxs("div",{className:"fk:flex fk:items-center fk:justify-center fk:gap-2 fk:py-4 fk:text-sm fk:text-muted-foreground",children:[jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}),jsx("span",{children:"Loading more skills..."})]}):null]})})]})}function te({className:t,id:i,message:o}){return jsx("p",{className:`fk:text-sm fk:text-destructive ${t??""}`,id:i,children:o})}function D({children:t,hint:i,htmlFor:o,id:l}){return jsxs("div",{className:"fk:mb-1.5 fk:pl-2.5 fk:flex fk:items-center fk:gap-1",children:[jsx(e$2,{htmlFor:o,id:l,children:t}),jsxs(b$3,{children:[jsx(c$1,{asChild:true,children:jsx("button",{"aria-label":`About ${t.toLowerCase()}`,className:"fk:rounded-sm fk:text-muted-foreground hover:fk:text-foreground fk:corner-squircle",type:"button",children:jsx(Info,{className:"fk:size-3.5"})})}),jsx(e$1,{className:"fk:max-w-xs",children:i})]})]})}function Se({actions:t,title:i}){return jsxs(Fragment,{children:[jsxs("div",{className:"fk:flex fk:shrink-0 fk:items-center fk:gap-2 fk:pr-4",children:[jsxs(b$3,{children:[jsx(c$1,{asChild:true,children:jsx(O,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(v,{orientation:"vertical",className:"fk:h-4"}),jsx("h1",{className:"fk:min-w-0 fk:flex-1 fk:truncate fk:text-lg fk:font-semibold fk:leading-none fk:tracking-tight",children:i}),t]}),jsx(b$2,{asChild:true,className:"fk:shrink-0 fk:w-fit",size:"sm",variant:"ghost",children:jsxs(Link,{relative:"path",to:"..",children:[jsx(ArrowLeft,{className:"fk:mr-2 fk:size-4"}),"Skills"]})})]})}function Ht(){return jsxs("div",{"aria-busy":"true",className:"fk:flex fk:h-full fk:min-h-0 fk:min-w-0 fk:flex-col fk:gap-3 fk:overflow-hidden fk:pb-3",children:[jsx("span",{className:"fk:sr-only",children:"Loading skill"}),jsx(Se,{actions:jsx(t,{className:"fk:h-8 fk:w-24"}),title:jsx(t,{className:"fk:h-5 fk:w-40"})}),jsxs("div",{className:"fk:m-auto fk:flex fk:min-h-0 fk:w-full fk:max-w-6xl fk:flex-1 fk:flex-col fk:gap-8 fk:px-6",children:[jsxs("div",{className:"fk:grid fk:shrink-0 fk:gap-3 fk:lg:grid-cols-[minmax(0,1fr)_minmax(0,1.6fr)_auto]",children:[["name","description"].map(t$1=>jsxs("div",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsx(t,{className:"fk:h-4 fk:w-20"}),jsx(t,{className:"fk:h-9 fk:w-full"})]},t$1)),jsxs("div",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsx(t,{className:"fk:h-4 fk:w-20"}),jsx(t,{className:"fk:h-9 fk:w-32"})]})]}),jsxs("div",{className:"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col fk:gap-1.5",children:[jsx(t,{className:"fk:h-4 fk:w-16"}),jsx(t,{className:"fk:min-h-48 fk:flex-1 fk:rounded-md"})]})]})]})}function Ke({content:t,onBlur:i,onChange:o,onSave:l,readOnly:f=false,showContentError:d,validationMessage:k}){let[u,m]=useState("write"),c=t.length>5e4,p;return t.trim()?p=jsx(Pt,{components:Rt,children:t}):p=jsx("p",{className:"fk:text-muted-foreground",children:"Nothing to preview."}),jsxs("div",{className:"fk:flex fk:min-h-0 fk:min-w-0 fk:flex-1 fk:flex-col fk:gap-1.5",children:[jsxs("div",{className:"fk:pl-3.25 fk:flex fk:shrink-0 fk:items-center fk:gap-1",children:[jsx(e$2,{htmlFor:"skill-content",id:"skill-content-label",children:"Content"}),jsxs(b$3,{children:[jsx(c$1,{asChild:true,children:jsx("button",{"aria-label":"About skill content",className:"fk:rounded-sm fk:text-muted-foreground hover:fk:text-foreground fk:corner-squircle",type:"button",children:jsx(Info,{className:"fk:size-3.5"})})}),jsx(e$1,{className:"fk:max-w-sm",children:"The skill itself, in Markdown. Write it like instructions for a capable colleague: procedures, rules, examples, and edge cases. Attached skills are always loaded; other visible skills are loaded on demand."})]})]}),jsxs("div",{className:`fk:flex fk:min-h-0 fk:min-w-0 fk:flex-1 fk:flex-col fk:ml-0.75 fk:overflow-hidden fk:rounded-md fk:border ${d?"fk:border-destructive":""} fk:corner-squircle`,children:[jsxs("div",{className:"fk:flex fk:shrink-0 fk:items-center fk:justify-between fk:gap-2 fk:border-b fk:px-2.5 fk:py-1",children:[jsx(ha,{value:u,onValueChange:h=>{m(h==="preview"?"preview":"write");},children:jsxs(ia,{children:[jsxs(b$3,{children:[jsx(c$1,{asChild:true,children:jsx("span",{className:"fk:inline-flex",children:jsx(ja,{"aria-label":"Write",className:"fk:px-2.5",value:"write",children:jsx(PenLine,{className:"fk:size-3.5"})})})}),jsx(e$1,{children:"Write"})]}),jsxs(b$3,{children:[jsx(c$1,{asChild:true,children:jsx("span",{className:"fk:inline-flex",children:jsx(ja,{"aria-label":"Preview",className:"fk:px-2.5",value:"preview",children:jsx(Eye,{className:"fk:size-3.5"})})})}),jsx(e$1,{children:"Preview"})]})]})}),jsxs("span",{className:c?"fk:text-xs fk:text-destructive":"fk:text-xs fk:text-muted-foreground",children:[t.length.toLocaleString()," / ",5e4.toLocaleString()]})]}),jsx("div",{className:"fk:min-h-0 fk:min-w-0 fk:flex-1 fk:overflow-hidden",hidden:u!=="write",children:jsx(Xe,{ariaDescribedBy:d?"skill-content-error":void 0,ariaInvalid:d,ariaLabelledBy:"skill-content-label",className:"fk:h-full fk:min-h-0 fk:min-w-0 fk:w-full fk:overflow-hidden",readOnly:f,value:t,onBlur:i,onChange:o,onSave:l})}),u==="preview"?jsx(w,{className:"fk:min-h-0 fk:flex-1",children:jsx("div",{className:"fk:prose fk:prose-sm fk:dark:prose-invert fk:max-w-none fk:px-4 fk:py-3",children:p})}):null,d&&k?jsx(te,{className:"fk:border-t fk:px-3 fk:py-2",id:"skill-content-error",message:k}):null]})]})}function Ge({api:t,mode:i,onSaved:o,projectId:l,skill:f$1}){let[d$1,k]=useState(f$1?.name??""),[u,m]=useState(f$1?.description??""),[c$1,p]=useState(f$1?.content??""),[h,y]=useState(f$1?.visibility??"project"),[L,P]=useState(f$1?.spaceId??null),[N,C]=useState(false),w=useRef(false),[I,v]=useState(""),[s$1,g$3]=useState({content:false,description:false,name:false}),K=useNavigate(),{data:G}=ve(g(l).spaces,f),[,B]=g$1(),H=b(),$e=B.user?.spaces??[],xe=(G?.spaces??[]).filter(a=>$e.includes(a.code)),ne="";c$1.trim()?c$1.length>5e4&&(ne=`Content must be at most ${String(5e4)} characters`):ne="Content is required";let b$1={content:ne,description:u.trim()?"":"Description is required",name:d$1.trim()?"":"Name is required",space:h==="space"&&!L?"Select a space":""},ae=!b$1.content&&!b$1.description&&!b$1.name&&!b$1.space,$=s$1.name&&!!b$1.name,U=s$1.description&&!!b$1.description,Ue=s$1.content&&!!b$1.content,Ze=i==="create"?"New Skill":f$1?.name??"Skill",se="Update skill";N?se="Saving...":i==="create"&&(se="Create skill");async function ye(){if(!H||w.current)return;if(!ae){g$3({content:true,description:true,name:true});return}w.current=true,C(true),v("");let a={content:c$1,description:u,name:d$1,spaceId:h==="space"?L:null,visibility:h};try{let M=i==="create"||!f$1?await t.createSkill(a):await t.updateSkill(f$1.id,a);if(!M.success){v(Array.isArray(M.errorMessage)?M.errorMessage.join(", "):M.errorMessage);return}qa.success(i==="create"||!f$1?"Skill created.":"Skill saved."),o(M.skill);}catch(M){v(M instanceof Error?M.message:"Failed to save skill.");}finally{w.current=false,C(false);}}async function Qe(a){a.preventDefault(),await ye();}async function Ye(){if(!(!f$1||!H||w.current)){w.current=true,C(true),v("");try{let a=await t.deleteSkill(f$1.id);if(!a.success){v(Array.isArray(a.errorMessage)?a.errorMessage.join(", "):a.errorMessage);return}K("..",{relative:"path"});}catch(a){v(a instanceof Error?a.message:"Failed to delete skill.");}finally{w.current=false,C(false);}}}return jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:min-w-0 fk:flex-col fk:gap-3 fk:pb-3",children:[jsx(Se,{actions:jsxs("div",{className:"fk:flex fk:items-center fk:gap-3",children:[ae?null:jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:"Complete the required fields to save"}),i==="edit"&&f$1?jsxs(b$2,{disabled:N||!H,size:"sm",type:"button",variant:"outline",onClick:()=>{Ye();},children:[jsx(Trash2,{}),"Delete"]}):null,jsx(na,{disabled:!H,children:jsx(b$2,{disabled:N||!ae||!H,form:"skill-editor-form",size:"sm",type:"submit",children:se})})]}),title:Ze}),I?jsx("div",{className:"fk:shrink-0 fk:rounded-md fk:border fk:border-destructive/30 fk:bg-destructive/5 fk:p-3 fk:text-sm fk:text-destructive fk:corner-squircle",children:I}):null,jsxs("form",{className:"fk:flex fk:min-h-0 fk:min-w-0 fk:flex-1 fk:flex-col fk:gap-6 fk:w-full fk:max-w-6xl fk:m-auto fk:gap-8 fk:px-4",id:"skill-editor-form",onSubmit:a=>{Qe(a);},children:[jsxs("div",{className:"fk:grid fk:min-w-0 fk:shrink-0 fk:gap-3 fk:px-0.75 fk:lg:grid-cols-[minmax(0,1fr)_minmax(0,1.6fr)_auto]",children:[jsxs("div",{children:[jsx(D,{hint:"Identifying label for this skill",htmlFor:"skill-name",children:"Name"}),jsx(s,{"aria-describedby":$?"skill-name-error":void 0,"aria-invalid":$,className:$?"fk:border-destructive focus-visible:fk:ring-destructive":"",id:"skill-name",value:d$1,onBlur:()=>g$3(a=>({...a,name:true})),onChange:a=>k(a.target.value)}),$?jsx(te,{id:"skill-name-error",message:b$1.name}):null]}),jsxs("div",{children:[jsx(D,{hint:"One or two sentences describing when to use this skill. Agents rely on it to decide whether the skill applies to their current task.",htmlFor:"skill-description",children:"Description"}),jsx(s,{"aria-describedby":U?"skill-description-error":void 0,"aria-invalid":U,className:U?"fk:border-destructive focus-visible:fk:ring-destructive":"",id:"skill-description",placeholder:"e.g. Rules for writing product descriptions in our brand voice",value:u,onBlur:()=>g$3(a=>({...a,description:true})),onChange:a=>m(a.target.value)}),U?jsx(te,{id:"skill-description-error",message:b$1.description}):null]}),jsxs("div",{children:[jsx(D,{hint:"Who can see and use this skill. Space skills are only visible to members of the selected space and only usable by automations in that space; personal skills are private to you.",htmlFor:"skill-visibility",children:"Visibility"}),jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsxs(a,{value:h,onValueChange:a=>{y(a==="space"||a==="personal"?a:"project"),a!=="space"&&P(null);},children:[jsx(d,{"aria-label":"Visibility",className:"fk:w-fit fk:min-w-26",id:"skill-visibility",children:jsx(c,{})}),jsxs(e,{align:"start",children:[jsx(g$2,{value:"project",children:"Project"}),jsx(g$2,{disabled:xe.length===0,value:"space",children:"Space"}),jsx(g$2,{value:"personal",children:"Personal"})]})]}),h==="space"?jsxs(a,{value:L??"",onValueChange:a=>{P(a||null);},children:[jsx(d,{"aria-label":"Space",className:"fk:w-fit fk:min-w-34",children:jsx(c,{placeholder:"Select a space"})}),jsx(e,{align:"start",children:xe.map(a=>jsx(g$2,{value:a.id,children:a.label},a.id))})]}):null]}),h==="space"&&b$1.space?jsx(te,{message:b$1.space}):null]})]}),jsx(Ke,{content:c$1,showContentError:Ue,validationMessage:b$1.content,onBlur:()=>g$3(a=>({...a,content:true})),onChange:p,onSave:()=>{ye();}})]})]})}function Ot({projectId:t,skill:i,spaceLabelById:o}){let l=b(),f=useNavigate(),[d$1,k]=useState(false),[u,m]=useState("");async function c$1(){k(true),m("");let p;try{p=await fetch(`/api/flexkit/${t}/skills/${i.id}/fork`,{method:"POST",credentials:"include"});}catch{m("Unable to create a copy. Try again."),k(false);return}if(k(false),!p.ok){m("Unable to create a copy. Check your permissions.");return}f("..",{relative:"path"});}return jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:min-w-0 fk:flex-col fk:gap-3 fk:pb-3",children:[jsx(Se,{actions:jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsx(b$4,{variant:"secondary",children:i.source==="plugin"?"Plugin":"Code"}),i.source==="plugin"&&jsx(b$2,{type:"button",disabled:d$1||!l,onClick:()=>{c$1();},size:"sm",children:"Edit a copy"})]}),title:i.name}),jsxs("div",{className:"fk:flex fk:flex-col fk:h-full fk:px-4 fk:gap-3 fk:max-w-6xl fk:m-auto",children:[jsxs("div",{className:"fk:shrink-0 fk:rounded-md fk:border fk:bg-muted/30 fk:px-3 fk:py-2 fk:corner-squircle",children:[jsx("p",{className:"fk:text-sm fk:font-medium",children:"Version-controlled skill"}),jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:i.source==="plugin"?"This skill is managed by its plugin. Edit a copy to create a personal Studio skill.":"Edit this skill in your repository and re-sync it from the Custom Tools settings."})]}),jsxs("div",{className:"fk:grid fk:min-w-0 fk:shrink-0 fk:gap-3 fk:lg:grid-cols-[minmax(0,1fr)_minmax(0,1.6fr)_auto]",children:[jsxs("div",{children:[jsx(D,{hint:"Identifying label for this skill",htmlFor:"skill-name",children:"Name"}),jsx(s,{className:"fk:opacity-100!",disabled:true,id:"skill-name",value:i.name})]}),jsxs("div",{children:[jsx(D,{hint:"One or two sentences describing when to use this skill. Agents rely on it to decide whether the skill applies to their current task.",htmlFor:"skill-description",children:"Description"}),jsx(s,{className:"fk:opacity-100!",disabled:true,id:"skill-description",placeholder:"e.g. Rules for writing product descriptions in our brand voice",value:i.description})]}),jsxs("div",{children:[jsx(D,{hint:"Who can see and use this skill. Space skills are only visible to members of the selected space and only usable by automations in that space; personal skills are private to you.",htmlFor:"skill-visibility",children:"Visibility"}),jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsxs(a,{disabled:true,value:i.visibility,children:[jsx(d,{"aria-label":"Visibility",className:"fk:w-fit fk:min-w-26 fk:opacity-100!",id:"skill-visibility",children:jsx(c,{})}),jsxs(e,{align:"start",children:[jsx(g$2,{value:"project",children:"Project"}),jsx(g$2,{disabled:!i.spaceId,value:"space",children:"Space"}),jsx(g$2,{value:"personal",children:"Personal"})]})]}),i.visibility==="space"?jsxs(a,{disabled:true,value:i.spaceId??"",children:[jsx(d,{"aria-label":"Space",className:"fk:w-fit fk:min-w-34 fk:opacity-100!",children:jsx(c,{placeholder:"Select a space"})}),jsx(e,{align:"start",children:jsx(g$2,{value:i.spaceId??"",children:zt(i,o)})})]}):null]})]})]}),u&&jsx("p",{role:"alert",children:u}),jsx(Ke,{content:i.content,readOnly:true})]})]})}function vi(){let{api:t,projectId:i}=be(),o=useNavigate();return !i||!t?jsx(ie,{children:"Select a project to create skills."}):jsx(Ge,{api:t,mode:"create",projectId:i,onSaved:()=>o("..",{relative:"path"})})}function bi(){let{api:t,projectId:i}=be(),{skillId:o}=useParams(),{data:l,error:f$1,isLoading:d,mutate:k}=ve(i&&o?g(i).skill(o):null,f),{data:u}=ve(i?g(i).spaces:null,f);if(!i||!t||!o)return jsx(ie,{children:"Select a skill."});if(f$1)return jsx(ie,{children:"Failed to load skill."});if(d||!l?.skill)return jsx(Ht,{});let m=new Map((u?.spaces??[]).map(c=>[c.id,c.label]));return l.skill.source!=="studio"?jsx(Ot,{projectId:i,skill:l.skill,spaceLabelById:m}):jsx(Ge,{api:t,mode:"edit",projectId:i,skill:l.skill,onSaved:c=>{c?k({skill:c},{revalidate:false}):k();}})}export{vi as CreateSkillPage,bi as SkillDetailPage,Ge as SkillForm,hi as SkillsPage};//# sourceMappingURL=skills-pages-G6JK7KKQ.js.map
2
- //# sourceMappingURL=skills-pages-G6JK7KKQ.js.map