@omnitron-dev/prism 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/README.md +148 -0
  2. package/dist/blocks/index.js +3 -1
  3. package/dist/blocks/index.js.map +1 -1
  4. package/dist/{chunk-S6SEGBX6.js → chunk-472SOF76.js} +4 -4
  5. package/dist/{chunk-S6SEGBX6.js.map → chunk-472SOF76.js.map} +1 -1
  6. package/dist/{chunk-Z5OSPAOC.js → chunk-4Z5DE5GK.js} +78 -75
  7. package/dist/chunk-4Z5DE5GK.js.map +1 -0
  8. package/dist/chunk-52PQL67Q.js +559 -0
  9. package/dist/chunk-52PQL67Q.js.map +1 -0
  10. package/dist/chunk-75FQ5IW3.js +590 -0
  11. package/dist/chunk-75FQ5IW3.js.map +1 -0
  12. package/dist/{chunk-6AHI4GSV.js → chunk-7G5D5PTC.js} +4 -3
  13. package/dist/chunk-7G5D5PTC.js.map +1 -0
  14. package/dist/chunk-BJE2AKD4.js +105 -0
  15. package/dist/chunk-BJE2AKD4.js.map +1 -0
  16. package/dist/chunk-FF5RF32O.js +248 -0
  17. package/dist/chunk-FF5RF32O.js.map +1 -0
  18. package/dist/{chunk-OBJ244BO.js → chunk-GMIE6III.js} +9 -42
  19. package/dist/chunk-GMIE6III.js.map +1 -0
  20. package/dist/chunk-GUGTDURV.js +826 -0
  21. package/dist/chunk-GUGTDURV.js.map +1 -0
  22. package/dist/chunk-HOXFSQUV.js +573 -0
  23. package/dist/chunk-HOXFSQUV.js.map +1 -0
  24. package/dist/chunk-JSQTYDPG.js +3 -0
  25. package/dist/chunk-JSQTYDPG.js.map +1 -0
  26. package/dist/{chunk-ZTATTUH7.js → chunk-KQ67XB6T.js} +213 -651
  27. package/dist/chunk-KQ67XB6T.js.map +1 -0
  28. package/dist/{chunk-WFD54GQQ.js → chunk-LOY2NPCO.js} +14 -573
  29. package/dist/chunk-LOY2NPCO.js.map +1 -0
  30. package/dist/{chunk-YQW43BDH.js → chunk-LSPFFEJT.js} +240 -1824
  31. package/dist/chunk-LSPFFEJT.js.map +1 -0
  32. package/dist/{chunk-BZOL7GMU.js → chunk-OKTLA23Q.js} +4 -4
  33. package/dist/chunk-OKTLA23Q.js.map +1 -0
  34. package/dist/chunk-PFT2BNYO.js +191 -0
  35. package/dist/chunk-PFT2BNYO.js.map +1 -0
  36. package/dist/chunk-PGHEP4JD.js +106 -0
  37. package/dist/chunk-PGHEP4JD.js.map +1 -0
  38. package/dist/chunk-PXXPLHIY.js +74 -0
  39. package/dist/chunk-PXXPLHIY.js.map +1 -0
  40. package/dist/chunk-SU3LVQ7N.js +518 -0
  41. package/dist/chunk-SU3LVQ7N.js.map +1 -0
  42. package/dist/chunk-YHE7HXSG.js +206 -0
  43. package/dist/chunk-YHE7HXSG.js.map +1 -0
  44. package/dist/cli/index.js +7 -2
  45. package/dist/cli/index.js.map +1 -1
  46. package/dist/components/accordion/accordion.d.ts.map +1 -1
  47. package/dist/components/admin-filters/admin-data-table.d.ts.map +1 -1
  48. package/dist/components/admin-filters/filter-toolbar.d.ts.map +1 -1
  49. package/dist/components/date-input/date-input.d.ts +27 -0
  50. package/dist/components/date-input/date-input.d.ts.map +1 -0
  51. package/dist/components/date-input/index.d.ts +4 -0
  52. package/dist/components/date-input/index.d.ts.map +1 -0
  53. package/dist/components/date-input/value.d.ts +9 -0
  54. package/dist/components/date-input/value.d.ts.map +1 -0
  55. package/dist/components/doc-layout/doc-sidebar.d.ts +4 -1
  56. package/dist/components/doc-layout/doc-sidebar.d.ts.map +1 -1
  57. package/dist/components/doc-layout/index.js +6 -0
  58. package/dist/components/doc-layout/index.js.map +1 -0
  59. package/dist/components/editor/editor.d.ts.map +1 -1
  60. package/dist/components/editor/icons/index.d.ts +32 -40
  61. package/dist/components/editor/icons/index.d.ts.map +1 -1
  62. package/dist/components/editor/index.js +3 -1
  63. package/dist/components/error-boundary/error-boundary.d.ts.map +1 -1
  64. package/dist/components/index.css +4 -0
  65. package/dist/components/index.css.map +1 -1
  66. package/dist/components/index.d.ts +4 -4
  67. package/dist/components/index.d.ts.map +1 -1
  68. package/dist/components/index.js +18 -8
  69. package/dist/components/knowledge-graph/edge-labels.d.ts +14 -0
  70. package/dist/components/knowledge-graph/edge-labels.d.ts.map +1 -0
  71. package/dist/components/knowledge-graph/graph.d.ts +56 -0
  72. package/dist/components/knowledge-graph/graph.d.ts.map +1 -0
  73. package/dist/components/knowledge-graph/index.css +176 -0
  74. package/dist/components/knowledge-graph/index.css.map +1 -0
  75. package/dist/components/knowledge-graph/index.d.ts +3 -0
  76. package/dist/components/knowledge-graph/index.d.ts.map +1 -0
  77. package/dist/components/knowledge-graph/index.js +795 -0
  78. package/dist/components/knowledge-graph/index.js.map +1 -0
  79. package/dist/components/knowledge-graph/label-layout.d.ts +28 -0
  80. package/dist/components/knowledge-graph/label-layout.d.ts.map +1 -0
  81. package/dist/components/knowledge-graph/label-store.d.ts +15 -0
  82. package/dist/components/knowledge-graph/label-store.d.ts.map +1 -0
  83. package/dist/components/knowledge-graph/model.d.ts +92 -0
  84. package/dist/components/knowledge-graph/model.d.ts.map +1 -0
  85. package/dist/components/lightbox/lightbox.d.ts.map +1 -1
  86. package/dist/components/map/Map.d.ts +19 -43
  87. package/dist/components/map/Map.d.ts.map +1 -1
  88. package/dist/components/map/MapCoverageLayer.d.ts +1 -1
  89. package/dist/components/map/MapCoverageLayer.d.ts.map +1 -1
  90. package/dist/components/map/MapMarker.d.ts +1 -1
  91. package/dist/components/map/MapMarker.d.ts.map +1 -1
  92. package/dist/components/map/MapPlaceSearch.d.ts +33 -0
  93. package/dist/components/map/MapPlaceSearch.d.ts.map +1 -0
  94. package/dist/components/map/MapPointPicker.d.ts +21 -12
  95. package/dist/components/map/MapPointPicker.d.ts.map +1 -1
  96. package/dist/components/map/coordinates.d.ts +10 -0
  97. package/dist/components/map/coordinates.d.ts.map +1 -0
  98. package/dist/components/map/index.css +4 -0
  99. package/dist/components/map/index.css.map +1 -0
  100. package/dist/components/map/index.d.ts +7 -2
  101. package/dist/components/map/index.d.ts.map +1 -1
  102. package/dist/components/map/index.js +3 -0
  103. package/dist/components/map/index.js.map +1 -0
  104. package/dist/components/nav-card/nav-card.d.ts.map +1 -1
  105. package/dist/components/rail/rail.d.ts.map +1 -1
  106. package/dist/components/research/diagram-image.d.ts +11 -0
  107. package/dist/components/research/diagram-image.d.ts.map +1 -0
  108. package/dist/components/research/diagram.d.ts +8 -0
  109. package/dist/components/research/diagram.d.ts.map +1 -0
  110. package/dist/components/research/document.d.ts +33 -0
  111. package/dist/components/research/document.d.ts.map +1 -0
  112. package/dist/components/research/frontmatter.d.ts +15 -0
  113. package/dist/components/research/frontmatter.d.ts.map +1 -0
  114. package/dist/components/research/index.css +51 -0
  115. package/dist/components/research/index.css.map +1 -0
  116. package/dist/components/research/index.d.ts +3 -0
  117. package/dist/components/research/index.d.ts.map +1 -0
  118. package/dist/components/research/index.js +6 -0
  119. package/dist/components/research/index.js.map +1 -0
  120. package/dist/components/research/parse.d.ts +29 -0
  121. package/dist/components/research/parse.d.ts.map +1 -0
  122. package/dist/components/research-editor/block-commands.d.ts +20 -0
  123. package/dist/components/research-editor/block-commands.d.ts.map +1 -0
  124. package/dist/components/research-editor/block-controls.d.ts +13 -0
  125. package/dist/components/research-editor/block-controls.d.ts.map +1 -0
  126. package/dist/components/research-editor/editor.d.ts +75 -0
  127. package/dist/components/research-editor/editor.d.ts.map +1 -0
  128. package/dist/components/research-editor/extensions.d.ts +14 -0
  129. package/dist/components/research-editor/extensions.d.ts.map +1 -0
  130. package/dist/components/research-editor/index.css +332 -0
  131. package/dist/components/research-editor/index.css.map +1 -0
  132. package/dist/components/research-editor/index.d.ts +5 -0
  133. package/dist/components/research-editor/index.d.ts.map +1 -0
  134. package/dist/components/research-editor/index.js +1592 -0
  135. package/dist/components/research-editor/index.js.map +1 -0
  136. package/dist/components/research-editor/math-input.d.ts +32 -0
  137. package/dist/components/research-editor/math-input.d.ts.map +1 -0
  138. package/dist/components/research-editor/math-markup.d.ts +4 -0
  139. package/dist/components/research-editor/math-markup.d.ts.map +1 -0
  140. package/dist/components/research-editor/math-navigation.d.ts +6 -0
  141. package/dist/components/research-editor/math-navigation.d.ts.map +1 -0
  142. package/dist/components/research-editor/math-node.d.ts +11 -0
  143. package/dist/components/research-editor/math-node.d.ts.map +1 -0
  144. package/dist/components/research-editor/source.d.ts +19 -0
  145. package/dist/components/research-editor/source.d.ts.map +1 -0
  146. package/dist/components/scrollbar/scrollbar.d.ts +4 -2
  147. package/dist/components/scrollbar/scrollbar.d.ts.map +1 -1
  148. package/dist/components/search-input/search-input.d.ts +0 -10
  149. package/dist/components/search-input/search-input.d.ts.map +1 -1
  150. package/dist/components/tiptap-renderer/tiptap-renderer.d.ts +4 -3
  151. package/dist/components/tiptap-renderer/tiptap-renderer.d.ts.map +1 -1
  152. package/dist/core/index.d.ts +1 -1
  153. package/dist/core/index.d.ts.map +1 -1
  154. package/dist/core/index.js +8 -4
  155. package/dist/core/provider.d.ts +7 -2
  156. package/dist/core/provider.d.ts.map +1 -1
  157. package/dist/forms/schema-provider.d.ts +3 -3
  158. package/dist/forms/schema-utils.d.ts +3 -3
  159. package/dist/hooks/index.js +9 -5
  160. package/dist/icons/context.d.ts +17 -0
  161. package/dist/icons/context.d.ts.map +1 -0
  162. package/dist/icons/controls.d.ts +51 -0
  163. package/dist/icons/controls.d.ts.map +1 -0
  164. package/dist/icons/index.d.ts +3 -0
  165. package/dist/icons/index.d.ts.map +1 -0
  166. package/dist/icons/index.js +4 -0
  167. package/dist/icons/index.js.map +1 -0
  168. package/dist/icons/theme.d.ts +4 -0
  169. package/dist/icons/theme.d.ts.map +1 -0
  170. package/dist/index.css +4 -0
  171. package/dist/index.css.map +1 -1
  172. package/dist/index.js +24 -13
  173. package/dist/index.js.map +1 -1
  174. package/dist/layouts/core/header-section.d.ts.map +1 -1
  175. package/dist/layouts/dashboard/labels.d.ts +12 -0
  176. package/dist/layouts/dashboard/labels.d.ts.map +1 -0
  177. package/dist/layouts/dashboard/layout.d.ts +7 -1
  178. package/dist/layouts/dashboard/layout.d.ts.map +1 -1
  179. package/dist/layouts/dashboard/sidenav.d.ts +7 -3
  180. package/dist/layouts/dashboard/sidenav.d.ts.map +1 -1
  181. package/dist/layouts/index.d.ts +5 -0
  182. package/dist/layouts/index.d.ts.map +1 -1
  183. package/dist/layouts/index.js +6 -1
  184. package/dist/layouts/panel-layout.d.ts +35 -0
  185. package/dist/layouts/panel-layout.d.ts.map +1 -0
  186. package/dist/layouts/sidebar-toggle.d.ts +11 -0
  187. package/dist/layouts/sidebar-toggle.d.ts.map +1 -0
  188. package/dist/state/stores/auth.d.ts +4 -16
  189. package/dist/state/stores/auth.d.ts.map +1 -1
  190. package/dist/state/stores/ui.d.ts +7 -105
  191. package/dist/state/stores/ui.d.ts.map +1 -1
  192. package/dist/theme/components/Button.d.ts.map +1 -1
  193. package/dist/theme/components/FormControls.d.ts +3 -12
  194. package/dist/theme/components/FormControls.d.ts.map +1 -1
  195. package/dist/theme/components/index.d.ts.map +1 -1
  196. package/dist/theme/create-theme.d.ts +5 -17
  197. package/dist/theme/create-theme.d.ts.map +1 -1
  198. package/dist/theme/index.js +6 -2
  199. package/dist/theme/mixins.d.ts +3 -1
  200. package/dist/theme/mixins.d.ts.map +1 -1
  201. package/dist/theme/palette/overrides.d.ts +23 -0
  202. package/dist/theme/palette/overrides.d.ts.map +1 -0
  203. package/dist/ui/index.d.ts +18 -0
  204. package/dist/ui/index.d.ts.map +1 -0
  205. package/dist/ui/index.js +148 -0
  206. package/dist/ui/index.js.map +1 -0
  207. package/package.json +92 -45
  208. package/dist/chunk-6AHI4GSV.js.map +0 -1
  209. package/dist/chunk-BZOL7GMU.js.map +0 -1
  210. package/dist/chunk-OBJ244BO.js.map +0 -1
  211. package/dist/chunk-WFD54GQQ.js.map +0 -1
  212. package/dist/chunk-YQW43BDH.js.map +0 -1
  213. package/dist/chunk-Z5OSPAOC.js.map +0 -1
  214. package/dist/chunk-ZTATTUH7.js.map +0 -1
@@ -0,0 +1,795 @@
1
+ import { DocSidebar } from '../../chunk-YHE7HXSG.js';
2
+ import { PanelLayout } from '../../chunk-PFT2BNYO.js';
3
+ import '../../chunk-XIXSSI3B.js';
4
+ import '../../chunk-PXXPLHIY.js';
5
+ import '../../chunk-HOXFSQUV.js';
6
+ import { ZoomInIcon, ZoomOutIcon, FitViewIcon } from '../../chunk-PGHEP4JD.js';
7
+ import '../../chunk-BJE2AKD4.js';
8
+ import { createContext, memo, useState, useMemo, useRef, useEffect, useCallback, useSyncExternalStore, useLayoutEffect, useContext } from 'react';
9
+ import { Handle, Position, MarkerType, applyNodeChanges, ReactFlow, Background, getSmoothStepPath, BaseEdge, useNodes, useNodesInitialized, useReactFlow, useStore, EdgeLabelRenderer, Controls, ControlButton } from '@xyflow/react';
10
+ import Box2 from '@mui/material/Box';
11
+ import Chip from '@mui/material/Chip';
12
+ import Dialog from '@mui/material/Dialog';
13
+ import Button from '@mui/material/Button';
14
+ import TextField from '@mui/material/TextField';
15
+ import { useTheme } from '@mui/material/styles';
16
+ import '@xyflow/react/dist/style.css';
17
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
18
+
19
+ // src/components/knowledge-graph/model.ts
20
+ function validateKnowledgeGraph(data) {
21
+ const ids = /* @__PURE__ */ new Set();
22
+ for (const entity of data.entities) {
23
+ if (!entity.id || !entity.kind || !entity.label || ids.has(entity.id)) throw Error("invalid_entity");
24
+ ids.add(entity.id);
25
+ }
26
+ const relations = /* @__PURE__ */ new Set();
27
+ for (const relation of data.relations) {
28
+ if (!relation.id || !relation.kind || !relation.label || relations.has(relation.id) || !relation.inputs.length || !relation.outputs.length)
29
+ throw Error("invalid_relation");
30
+ relations.add(relation.id);
31
+ for (const port of [...relation.inputs, ...relation.outputs])
32
+ if (!ids.has(port.entity) || !port.role) throw Error("dangling_port");
33
+ }
34
+ }
35
+ function projectKnowledgeGraph(data, selection, budget = 300) {
36
+ if (!Number.isSafeInteger(budget) || budget < 1) throw Error("invalid_graph_budget");
37
+ const total = data.entities.length + data.relations.length;
38
+ if (!selection && total <= budget)
39
+ return { entities: [...data.entities], relations: [...data.relations], total, omittedRelations: 0, limited: false };
40
+ if (!selection) return { entities: [], relations: [], total, omittedRelations: data.relations.length, limited: true };
41
+ const selectedEntities = /* @__PURE__ */ new Set(), selectedRelations = [];
42
+ if (selection.type === "entity" && data.entities.some((e) => e.id === selection.id))
43
+ selectedEntities.add(selection.id);
44
+ const candidates = selection.type === "relation" ? data.relations.filter((r) => r.id === selection.id) : data.relations.filter((r) => [...r.inputs, ...r.outputs].some((p) => p.entity === selection.id));
45
+ let omittedRelations = 0;
46
+ for (const relation of candidates) {
47
+ const endpoints = new Set([...relation.inputs, ...relation.outputs].map((p) => p.entity));
48
+ const additional = [...endpoints].filter((id) => !selectedEntities.has(id)).length + 1;
49
+ if (selectedEntities.size + selectedRelations.length + additional > budget) {
50
+ omittedRelations++;
51
+ continue;
52
+ }
53
+ for (const id of endpoints) selectedEntities.add(id);
54
+ selectedRelations.push(relation);
55
+ }
56
+ return {
57
+ entities: data.entities.filter((e) => selectedEntities.has(e.id)),
58
+ relations: selectedRelations,
59
+ total,
60
+ omittedRelations,
61
+ limited: total !== selectedEntities.size + selectedRelations.length
62
+ };
63
+ }
64
+ var entityNodeId = (id) => JSON.stringify(["entity", id]);
65
+ var relationNodeId = (id) => JSON.stringify(["relation", id]);
66
+ function incidenceGraph(projection) {
67
+ const nodes = [
68
+ ...projection.entities.map((e) => ({
69
+ id: entityNodeId(e.id),
70
+ selection: { type: "entity", id: e.id },
71
+ label: e.label,
72
+ kind: e.kind,
73
+ description: e.description,
74
+ badges: e.badges
75
+ })),
76
+ ...projection.relations.map((r) => ({
77
+ id: relationNodeId(r.id),
78
+ selection: { type: "relation", id: r.id },
79
+ label: r.label,
80
+ kind: r.kind,
81
+ description: r.description,
82
+ badges: r.badges,
83
+ inputs: r.inputs.length,
84
+ outputs: r.outputs.length
85
+ }))
86
+ ];
87
+ const edges = projection.relations.flatMap(
88
+ (r) => ["inputs", "outputs"].flatMap(
89
+ (side) => r[side].map((port, index) => ({
90
+ id: JSON.stringify([r.id, side, index]),
91
+ source: side === "inputs" ? entityNodeId(port.entity) : relationNodeId(r.id),
92
+ target: side === "inputs" ? relationNodeId(r.id) : entityNodeId(port.entity),
93
+ label: port.role,
94
+ ...side === "inputs" ? { targetHandle: `inputs:${index}` } : { sourceHandle: `outputs:${index}` },
95
+ relationId: r.id,
96
+ side,
97
+ index
98
+ }))
99
+ )
100
+ );
101
+ return { nodes, edges };
102
+ }
103
+
104
+ // src/components/knowledge-graph/label-layout.ts
105
+ function nearestFree(origin, intervals) {
106
+ intervals.sort((a, b) => a[0] - b[0] || a[1] - b[1]);
107
+ const union = [];
108
+ for (const interval of intervals) {
109
+ const last = union[union.length - 1];
110
+ if (last && interval[0] < last[1]) last[1] = Math.max(last[1], interval[1]);
111
+ else union.push([...interval]);
112
+ }
113
+ const hit = union.find(([lo, hi]) => lo < origin && origin < hi);
114
+ return hit ? origin - hit[0] <= hit[1] - origin ? hit[0] : hit[1] : origin;
115
+ }
116
+ function placeEdgeLabels(labels, nodes, gap = 8) {
117
+ if (!Number.isFinite(gap) || gap < 0) throw Error("invalid_label_gap");
118
+ const occupied = [...nodes];
119
+ for (const rect of [...nodes, ...labels]) {
120
+ if (![rect.x, rect.y, rect.width, rect.height].every(Number.isFinite) || rect.width <= 0 || rect.height <= 0)
121
+ throw Error("invalid_label_geometry");
122
+ }
123
+ if (new Set(labels.map((l) => l.id)).size !== labels.length) throw Error("duplicate_label");
124
+ const ordered = [...labels].sort((a, b) => a.y - b.y || a.x - b.x || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
125
+ return ordered.map((label) => {
126
+ const x = label.x - label.width / 2, y = label.y - label.height / 2;
127
+ const vertical = [], horizontal = [];
128
+ for (const r of occupied) {
129
+ if (x < r.x + r.width + gap && x + label.width > r.x - gap)
130
+ vertical.push([r.y - gap - label.height, r.y + r.height + gap]);
131
+ if (y < r.y + r.height + gap && y + label.height > r.y - gap)
132
+ horizontal.push([r.x - gap - label.width, r.x + r.width + gap]);
133
+ }
134
+ const vx = nearestFree(x, horizontal), vy = nearestFree(y, vertical);
135
+ const box = Math.abs(vy - y) <= Math.abs(vx - x) ? { x, y: vy, width: label.width, height: label.height } : { x: vx, y, width: label.width, height: label.height };
136
+ occupied.push(box);
137
+ return { ...label, box };
138
+ });
139
+ }
140
+ function enclosingRect(rects) {
141
+ if (!rects.length) return;
142
+ let x = Infinity, y = Infinity, right = -Infinity, bottom = -Infinity;
143
+ for (const r of rects) {
144
+ x = Math.min(x, r.x);
145
+ y = Math.min(y, r.y);
146
+ right = Math.max(right, r.x + r.width);
147
+ bottom = Math.max(bottom, r.y + r.height);
148
+ }
149
+ return { x, y, width: right - x, height: bottom - y };
150
+ }
151
+ var EdgeLabelsContext = createContext(null);
152
+ function useEdgeLabel(anchor) {
153
+ const store = useContext(EdgeLabelsContext);
154
+ useLayoutEffect(() => {
155
+ if (!store || !anchor) return;
156
+ store.set(anchor);
157
+ return () => store.remove(anchor.id);
158
+ }, [store, anchor?.id, anchor?.text, anchor?.x, anchor?.y]);
159
+ }
160
+ function MeasuredLabel({
161
+ anchor,
162
+ box,
163
+ maxWidth,
164
+ onSize
165
+ }) {
166
+ const ref = useRef(null);
167
+ useLayoutEffect(() => {
168
+ const element = ref.current;
169
+ if (!element) return;
170
+ const measure = (width, height) => {
171
+ if (width > 0 && height > 0) onSize(anchor.id, { width: Math.ceil(width), height: Math.ceil(height) });
172
+ };
173
+ measure(element.offsetWidth, element.offsetHeight);
174
+ const observer = new ResizeObserver((entries) => {
175
+ const border = entries[0]?.borderBoxSize?.[0];
176
+ measure(border?.inlineSize ?? element.offsetWidth, border?.blockSize ?? element.offsetHeight);
177
+ });
178
+ observer.observe(element);
179
+ return () => {
180
+ observer.disconnect();
181
+ onSize(anchor.id, void 0);
182
+ };
183
+ }, [anchor.id, onSize]);
184
+ return /* @__PURE__ */ jsx(
185
+ Box2,
186
+ {
187
+ component: "span",
188
+ ref,
189
+ "aria-hidden": "true",
190
+ "data-edge-label": anchor.id,
191
+ className: "nodrag nopan prism-knowledge__edge-label",
192
+ sx: {
193
+ position: "absolute",
194
+ left: box?.x ?? anchor.x,
195
+ top: box?.y ?? anchor.y,
196
+ visibility: box ? "visible" : "hidden",
197
+ width: "max-content",
198
+ maxWidth,
199
+ bgcolor: "var(--prism-graph-bg)",
200
+ color: "var(--prism-graph-text)",
201
+ borderRadius: 0.5,
202
+ px: 0.75,
203
+ py: 0.25,
204
+ fontSize: 12,
205
+ lineHeight: 1.4,
206
+ boxSizing: "border-box",
207
+ whiteSpace: "pre-wrap",
208
+ overflowWrap: "anywhere",
209
+ pointerEvents: "none",
210
+ zIndex: 1
211
+ },
212
+ children: anchor.text
213
+ }
214
+ );
215
+ }
216
+ function EdgeLabels({
217
+ store,
218
+ gap,
219
+ maxWidth,
220
+ fitLabel,
221
+ zoomInLabel,
222
+ zoomOutLabel
223
+ }) {
224
+ const anchors = useSyncExternalStore(store.subscribe, store.getSnapshot, store.getSnapshot);
225
+ const [sizes, setSizes] = useState(/* @__PURE__ */ new Map());
226
+ const nodes = useNodes();
227
+ const initialized = useNodesInitialized();
228
+ const { fitBounds, zoomIn, zoomOut } = useReactFlow();
229
+ const atMinZoom = useStore((state) => state.transform[2] <= state.minZoom);
230
+ const atMaxZoom = useStore((state) => state.transform[2] >= state.maxZoom);
231
+ const initialFit = useRef(false);
232
+ const onSize = useCallback(
233
+ (id, size) => setSizes((prior) => {
234
+ const old = prior.get(id);
235
+ if (old?.width === size?.width && old?.height === size?.height) return prior;
236
+ const next = new Map(prior);
237
+ if (size) next.set(id, size);
238
+ else next.delete(id);
239
+ return next;
240
+ }),
241
+ []
242
+ );
243
+ const obstacles = useMemo(
244
+ () => nodes.flatMap((node) => {
245
+ const width = node.measured?.width, height = node.measured?.height;
246
+ return width && height && !node.hidden ? [{ ...node.position, width, height }] : [];
247
+ }),
248
+ [nodes]
249
+ );
250
+ const placements = useMemo(
251
+ () => placeEdgeLabels(
252
+ anchors.flatMap((anchor) => {
253
+ const size = sizes.get(anchor.id);
254
+ return size ? [{ ...anchor, ...size }] : [];
255
+ }),
256
+ obstacles,
257
+ gap
258
+ ),
259
+ [anchors, sizes, obstacles, gap]
260
+ );
261
+ const boxes = useMemo(() => new Map(placements.map((l) => [l.id, l.box])), [placements]);
262
+ const bounds = useMemo(() => enclosingRect([...obstacles, ...placements.map((l) => l.box)]), [obstacles, placements]);
263
+ const fit = useCallback(() => {
264
+ if (bounds) void fitBounds(bounds, { padding: 0.12, duration: 0 });
265
+ }, [bounds, fitBounds]);
266
+ useLayoutEffect(() => {
267
+ if (!initialFit.current && initialized && anchors.length && placements.length === anchors.length) {
268
+ initialFit.current = true;
269
+ fit();
270
+ }
271
+ }, [initialized, anchors.length, placements.length, fit]);
272
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
273
+ /* @__PURE__ */ jsxs(EdgeLabelRenderer, { children: [
274
+ /* @__PURE__ */ jsx(
275
+ "svg",
276
+ {
277
+ "aria-hidden": "true",
278
+ width: "1",
279
+ height: "1",
280
+ style: { position: "absolute", overflow: "visible", pointerEvents: "none" },
281
+ children: placements.map(({ id, x, y, box }) => {
282
+ const endX = Math.max(box.x, Math.min(x, box.x + box.width));
283
+ const endY = Math.max(box.y, Math.min(y, box.y + box.height));
284
+ if (endX === x && endY === y) return null;
285
+ return /* @__PURE__ */ jsxs("g", { "data-edge-label-leader": id, stroke: "var(--prism-graph-muted)", strokeWidth: "1", children: [
286
+ /* @__PURE__ */ jsx("path", { d: `M ${x} ${y} L ${endX} ${endY}`, fill: "none", strokeDasharray: "3 3" }),
287
+ /* @__PURE__ */ jsx("circle", { cx: x, cy: y, r: "2", fill: "var(--prism-graph-bg)" })
288
+ ] }, id);
289
+ })
290
+ }
291
+ ),
292
+ anchors.map((anchor) => /* @__PURE__ */ jsx(
293
+ MeasuredLabel,
294
+ {
295
+ anchor,
296
+ box: boxes.get(anchor.id),
297
+ maxWidth,
298
+ onSize
299
+ },
300
+ anchor.id
301
+ ))
302
+ ] }),
303
+ /* @__PURE__ */ jsxs(Controls, { showInteractive: false, showFitView: false, showZoom: false, children: [
304
+ /* @__PURE__ */ jsx(
305
+ ControlButton,
306
+ {
307
+ disabled: atMaxZoom,
308
+ onClick: () => void zoomIn({ duration: 200 }),
309
+ title: zoomInLabel,
310
+ "aria-label": zoomInLabel,
311
+ children: /* @__PURE__ */ jsx(ZoomInIcon, {})
312
+ }
313
+ ),
314
+ /* @__PURE__ */ jsx(
315
+ ControlButton,
316
+ {
317
+ disabled: atMinZoom,
318
+ onClick: () => void zoomOut({ duration: 200 }),
319
+ title: zoomOutLabel,
320
+ "aria-label": zoomOutLabel,
321
+ children: /* @__PURE__ */ jsx(ZoomOutIcon, {})
322
+ }
323
+ ),
324
+ /* @__PURE__ */ jsx(ControlButton, { onClick: fit, title: fitLabel, "aria-label": fitLabel, children: /* @__PURE__ */ jsx(FitViewIcon, {}) })
325
+ ] })
326
+ ] });
327
+ }
328
+
329
+ // src/components/knowledge-graph/label-store.ts
330
+ var EdgeLabelStore = class {
331
+ anchors = /* @__PURE__ */ new Map();
332
+ snapshot = [];
333
+ listeners = /* @__PURE__ */ new Set();
334
+ pending = false;
335
+ getSnapshot = () => this.snapshot;
336
+ subscribe = (listener) => {
337
+ this.listeners.add(listener);
338
+ return () => {
339
+ this.listeners.delete(listener);
340
+ };
341
+ };
342
+ set(anchor) {
343
+ const prior = this.anchors.get(anchor.id);
344
+ if (prior?.x === anchor.x && prior.y === anchor.y && prior.text === anchor.text) return;
345
+ this.anchors.set(anchor.id, anchor);
346
+ this.publish();
347
+ }
348
+ remove(id) {
349
+ if (this.anchors.delete(id)) this.publish();
350
+ }
351
+ publish() {
352
+ if (this.pending) return;
353
+ this.pending = true;
354
+ queueMicrotask(() => {
355
+ this.pending = false;
356
+ this.snapshot = [...this.anchors.values()];
357
+ this.listeners.forEach((listener) => listener());
358
+ });
359
+ }
360
+ };
361
+ var defaultKnowledgeGraphLabels = {
362
+ title: "Knowledge map",
363
+ search: "Find an entity or relation",
364
+ all: "Whole map",
365
+ list: "Index",
366
+ indexTitle: "Objects and relations",
367
+ openIndex: "Expand graph index",
368
+ closeIndex: "Close graph index",
369
+ collapseIndex: "Collapse graph index",
370
+ map: "Map",
371
+ empty: "No objects to display.",
372
+ invalid: "The graph contains invalid identities or references.",
373
+ budget: "Choose an object to inspect its neighbourhood.",
374
+ partial: "Showing a neighbourhood",
375
+ omitted: "Relations outside the display budget",
376
+ details: "Selected object",
377
+ inputs: "Inputs",
378
+ outputs: "Outputs",
379
+ fit: "Fit to view",
380
+ zoomIn: "Zoom in",
381
+ zoomOut: "Zoom out",
382
+ lock: "Toggle interaction",
383
+ hint: "Select an object in the index or map. Dragging changes its position only.",
384
+ clear: "Clear selection",
385
+ expand: "Expand workspace",
386
+ collapse: "Close expanded workspace"
387
+ };
388
+ function Badges({ badges }) {
389
+ if (!badges?.length) return null;
390
+ return /* @__PURE__ */ jsx(Box2, { component: "span", sx: { display: "flex", gap: 0.5, flexWrap: "wrap", mt: 1 }, children: badges.map((badge, index) => /* @__PURE__ */ jsx(
391
+ Chip,
392
+ {
393
+ component: "span",
394
+ label: badge.label,
395
+ size: "small",
396
+ variant: "outlined",
397
+ color: badge.tone ?? "default",
398
+ sx: { height: "auto", minHeight: 24, "& .MuiChip-label": { whiteSpace: "normal", py: 0.25 } }
399
+ },
400
+ index
401
+ )) });
402
+ }
403
+ var EntityNode = memo(function EntityNode2({ data, selected }) {
404
+ return /* @__PURE__ */ jsxs(
405
+ "div",
406
+ {
407
+ style: { minHeight: Math.max(76, Math.max(data.inputs ?? 0, data.outputs ?? 0) * 24 + 24) },
408
+ className: `prism-knowledge__node ${data.selection.type === "relation" ? "prism-knowledge__relation" : ""} ${selected ? "is-selected" : ""}`,
409
+ children: [
410
+ data.selection.type === "relation" ? Array.from({ length: data.inputs ?? 0 }, (_, i) => /* @__PURE__ */ jsx(
411
+ Handle,
412
+ {
413
+ id: `inputs:${i}`,
414
+ type: "target",
415
+ position: Position.Left,
416
+ style: { top: `${(i + 1) / ((data.inputs ?? 0) + 1) * 100}%` },
417
+ isConnectable: false
418
+ },
419
+ i
420
+ )) : /* @__PURE__ */ jsx(Handle, { type: "target", position: Position.Left, isConnectable: false }),
421
+ /* @__PURE__ */ jsx("span", { className: "prism-knowledge__kind", children: data.kind }),
422
+ /* @__PURE__ */ jsx("strong", { children: data.label }),
423
+ /* @__PURE__ */ jsx(Badges, { badges: data.badges }),
424
+ data.selection.type === "relation" ? Array.from({ length: data.outputs ?? 0 }, (_, i) => /* @__PURE__ */ jsx(
425
+ Handle,
426
+ {
427
+ id: `outputs:${i}`,
428
+ type: "source",
429
+ position: Position.Right,
430
+ style: { top: `${(i + 1) / ((data.outputs ?? 0) + 1) * 100}%` },
431
+ isConnectable: false
432
+ },
433
+ i
434
+ )) : /* @__PURE__ */ jsx(Handle, { type: "source", position: Position.Right, isConnectable: false })
435
+ ]
436
+ }
437
+ );
438
+ });
439
+ function KnowledgeEdge(props) {
440
+ const [path, x, y] = getSmoothStepPath(props);
441
+ useEdgeLabel(typeof props.label === "string" ? { id: props.id, text: props.label, x, y } : void 0);
442
+ return /* @__PURE__ */ jsx(
443
+ BaseEdge,
444
+ {
445
+ id: props.id,
446
+ path,
447
+ markerEnd: props.markerEnd,
448
+ markerStart: props.markerStart,
449
+ style: props.style,
450
+ interactionWidth: props.interactionWidth
451
+ }
452
+ );
453
+ }
454
+ var edgeTypes = { knowledge: KnowledgeEdge };
455
+ var nodeTypes = { knowledge: EntityNode };
456
+ function defaultLayout(p) {
457
+ const positions = {};
458
+ p.entities.forEach((e, i) => {
459
+ positions[entityNodeId(e.id)] = { x: i % 3 * 340, y: Math.floor(i / 3) * 170 };
460
+ });
461
+ p.relations.forEach((r, i) => {
462
+ positions[relationNodeId(r.id)] = {
463
+ x: i % 3 * 340 + 170,
464
+ y: Math.floor(p.entities.length / 3) * 170 + 180 + Math.floor(i / 3) * 150
465
+ };
466
+ });
467
+ return positions;
468
+ }
469
+ function KnowledgeGraph({
470
+ data,
471
+ labels: overrides,
472
+ visibleBudget = 300,
473
+ panelPersistKey,
474
+ onSelect,
475
+ onLayoutChange,
476
+ layout = defaultLayout,
477
+ renderDetails,
478
+ height = 560,
479
+ edgeLabelGap = 8,
480
+ edgeLabelMaxWidth = 240,
481
+ className,
482
+ sx
483
+ }) {
484
+ if (!Number.isFinite(edgeLabelGap) || edgeLabelGap < 0 || !Number.isFinite(edgeLabelMaxWidth) || edgeLabelMaxWidth <= 0)
485
+ throw Error("invalid_edge_label_options");
486
+ const [labelStore] = useState(() => new EdgeLabelStore());
487
+ const theme = useTheme(), labels = useMemo(() => ({ ...defaultKnowledgeGraphLabels, ...overrides }), [overrides]);
488
+ const [expanded, setExpanded] = useState(false);
489
+ const [query, setQuery] = useState(""), [selected, setSelected] = useState(), [focus, setFocus] = useState(), [view, setView] = useState("map");
490
+ const selectionRef = useRef(void 0);
491
+ const valid = useMemo(() => {
492
+ try {
493
+ validateKnowledgeGraph(data);
494
+ return true;
495
+ } catch {
496
+ return false;
497
+ }
498
+ }, [data]);
499
+ const projection = useMemo(
500
+ () => valid ? projectKnowledgeGraph(data, focus, visibleBudget) : { entities: [], relations: [], total: 0, omittedRelations: 0, limited: false },
501
+ [data, valid, focus, visibleBudget]
502
+ );
503
+ const graph = useMemo(() => incidenceGraph(projection), [projection]);
504
+ const positions = useMemo(() => layout(projection), [layout, projection]);
505
+ const [nodes, setNodes] = useState([]);
506
+ useEffect(() => {
507
+ setNodes((old) => {
508
+ const prior = new Map(old.map((n) => [n.id, n]));
509
+ return graph.nodes.map((n) => ({
510
+ ...prior.get(n.id),
511
+ id: n.id,
512
+ type: "knowledge",
513
+ position: prior.get(n.id)?.position ?? positions[n.id] ?? { x: 0, y: 0 },
514
+ data: n,
515
+ ariaLabel: `${n.kind}: ${n.label}`,
516
+ deletable: false
517
+ }));
518
+ });
519
+ }, [graph, positions]);
520
+ const displayedNodes = useMemo(
521
+ () => nodes.map((node) => ({
522
+ ...node,
523
+ selected: selected?.id === node.data.selection.id && selected.type === node.data.selection.type
524
+ })),
525
+ [nodes, selected]
526
+ );
527
+ const edges = useMemo(
528
+ () => graph.edges.map((e) => ({
529
+ ...e,
530
+ type: "knowledge",
531
+ markerEnd: { type: MarkerType.ArrowClosed },
532
+ focusable: true,
533
+ ariaLabel: e.label,
534
+ deletable: false
535
+ })),
536
+ [graph]
537
+ );
538
+ const choose = useCallback(
539
+ (s) => {
540
+ const previous = selectionRef.current;
541
+ if (previous?.id === s?.id && previous?.type === s?.type) return;
542
+ selectionRef.current = s;
543
+ setSelected(s);
544
+ onSelect?.(s);
545
+ if (projection.total > visibleBudget) setFocus(s);
546
+ },
547
+ [onSelect, projection.total, visibleBudget]
548
+ );
549
+ const onNodesChange = useCallback(
550
+ (changes) => {
551
+ const selectedChange = [...changes].reverse().find((change) => change.type === "select" && change.selected);
552
+ if (selectedChange?.type === "select") {
553
+ const node = graph.nodes.find((node2) => node2.id === selectedChange.id);
554
+ if (node) choose(node.selection);
555
+ } else {
556
+ const current = selectionRef.current;
557
+ const id = current && (current.type === "entity" ? entityNodeId(current.id) : relationNodeId(current.id));
558
+ if (changes.some((change) => change.type === "select" && !change.selected && change.id === id))
559
+ choose(void 0);
560
+ }
561
+ const geometry = changes.filter((change) => change.type !== "remove" && change.type !== "select");
562
+ if (geometry.length) setNodes((nodes2) => applyNodeChanges(geometry, nodes2));
563
+ },
564
+ [graph, choose]
565
+ );
566
+ const index = useMemo(
567
+ () => [
568
+ ...data.entities.map((e) => ({ ...e, selection: { type: "entity", id: e.id } })),
569
+ ...data.relations.map((r) => ({ ...r, selection: { type: "relation", id: r.id } }))
570
+ ].filter(
571
+ (e) => `${e.label}
572
+ ${e.kind}
573
+ ${e.id}
574
+ ${e.badges?.map((b) => b.label).join(" ") ?? ""}`.toLocaleLowerCase().includes(query.toLocaleLowerCase())
575
+ ),
576
+ [data, query]
577
+ );
578
+ const object = selected?.type === "entity" ? data.entities.find((e) => e.id === selected.id) : data.relations.find((r) => r.id === selected?.id);
579
+ useEffect(() => {
580
+ if (selected && !object) {
581
+ choose(void 0);
582
+ setFocus(void 0);
583
+ }
584
+ }, [selected, object, choose]);
585
+ const graphIndex = /* @__PURE__ */ jsxs(Box2, { className: "prism-knowledge__index", children: [
586
+ /* @__PURE__ */ jsx(
587
+ TextField,
588
+ {
589
+ fullWidth: true,
590
+ size: "small",
591
+ type: "search",
592
+ label: labels.search,
593
+ value: query,
594
+ onChange: (e) => setQuery(e.target.value),
595
+ sx: { mb: 2 }
596
+ }
597
+ ),
598
+ /* @__PURE__ */ jsx("ul", { className: "prism-knowledge__results", children: index.slice(0, visibleBudget).map((item) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
599
+ Button,
600
+ {
601
+ type: "button",
602
+ variant: "text",
603
+ "aria-current": selected?.id === item.id && selected.type === item.selection.type,
604
+ onClick: () => choose(item.selection),
605
+ children: [
606
+ /* @__PURE__ */ jsx("span", { children: item.kind }),
607
+ item.label,
608
+ /* @__PURE__ */ jsx(Badges, { badges: item.badges })
609
+ ]
610
+ }
611
+ ) }, JSON.stringify(item.selection))) }),
612
+ /* @__PURE__ */ jsxs("small", { children: [
613
+ Math.min(index.length, visibleBudget),
614
+ " / ",
615
+ index.length
616
+ ] }),
617
+ /* @__PURE__ */ jsx(
618
+ Button,
619
+ {
620
+ type: "button",
621
+ onClick: () => {
622
+ setFocus(void 0);
623
+ choose(void 0);
624
+ },
625
+ children: labels.clear
626
+ }
627
+ )
628
+ ] });
629
+ const content = /* @__PURE__ */ jsxs(
630
+ Box2,
631
+ {
632
+ className: ["prism-knowledge", view === "list" && "is-list", className].filter(Boolean).join(" "),
633
+ sx: [
634
+ {
635
+ "--prism-graph-border": theme.palette.divider,
636
+ "--prism-graph-bg": theme.palette.background.paper,
637
+ "--prism-graph-text": theme.palette.text.primary,
638
+ "--prism-graph-muted": theme.palette.text.secondary,
639
+ "--prism-graph-accent": theme.palette.primary.main,
640
+ "--prism-graph-radius": `${theme.shape.borderRadius}px`,
641
+ "--prism-graph-hover": theme.palette.action.hover
642
+ },
643
+ ...Array.isArray(sx) ? sx : [sx]
644
+ ],
645
+ children: [
646
+ /* @__PURE__ */ jsxs("header", { className: "prism-knowledge__header", children: [
647
+ /* @__PURE__ */ jsx("strong", { children: labels.title }),
648
+ /* @__PURE__ */ jsxs("span", { children: [
649
+ projection.entities.length + projection.relations.length,
650
+ " / ",
651
+ projection.total
652
+ ] }),
653
+ /* @__PURE__ */ jsx(
654
+ Button,
655
+ {
656
+ variant: view === "map" ? "contained" : "outlined",
657
+ type: "button",
658
+ "aria-pressed": view === "map",
659
+ onClick: () => setView("map"),
660
+ children: labels.map
661
+ }
662
+ ),
663
+ /* @__PURE__ */ jsx(
664
+ Button,
665
+ {
666
+ variant: view === "list" ? "contained" : "outlined",
667
+ type: "button",
668
+ "aria-pressed": view === "list",
669
+ onClick: () => setView("list"),
670
+ children: labels.list
671
+ }
672
+ ),
673
+ /* @__PURE__ */ jsx(Button, { type: "button", onClick: () => setExpanded((v) => !v), children: expanded ? labels.collapse : labels.expand })
674
+ ] }),
675
+ !valid ? /* @__PURE__ */ jsx("p", { role: "alert", children: labels.invalid }) : /* @__PURE__ */ jsxs(Fragment, { children: [
676
+ /* @__PURE__ */ jsx("p", { className: "prism-knowledge__hint", children: labels.hint }),
677
+ view === "list" ? graphIndex : /* @__PURE__ */ jsx(
678
+ PanelLayout,
679
+ {
680
+ title: labels.indexTitle,
681
+ labels: { expand: labels.openIndex, collapse: labels.collapseIndex, close: labels.closeIndex },
682
+ panel: ({ collapsed }) => /* @__PURE__ */ jsxs(Fragment, { children: [
683
+ /* @__PURE__ */ jsx(Box2, { hidden: collapsed, children: graphIndex }),
684
+ collapsed && /* @__PURE__ */ jsx(
685
+ DocSidebar,
686
+ {
687
+ compact: true,
688
+ items: index.slice(0, visibleBudget).map((item) => ({
689
+ id: JSON.stringify(item.selection),
690
+ label: item.label
691
+ })),
692
+ activeId: selected && JSON.stringify(selected),
693
+ onItemClick: (item) => {
694
+ const target = index.find((entry) => JSON.stringify(entry.selection) === item.id);
695
+ if (target) choose(target.selection);
696
+ }
697
+ }
698
+ )
699
+ ] }),
700
+ height: expanded ? "75dvh" : height,
701
+ width: 240,
702
+ offset: 88,
703
+ persistKey: panelPersistKey,
704
+ navigationKey: selected ? selected.type + ":" + selected.id : "",
705
+ sx: { px: 1, pb: 1 },
706
+ children: /* @__PURE__ */ jsx(
707
+ "div",
708
+ {
709
+ className: "prism-knowledge__canvas",
710
+ style: { height: view === "map" ? expanded ? "75dvh" : height : void 0 },
711
+ children: view === "map" && nodes.length > 0 ? /* @__PURE__ */ jsx(EdgeLabelsContext.Provider, { value: labelStore, children: /* @__PURE__ */ jsxs(
712
+ ReactFlow,
713
+ {
714
+ nodes: displayedNodes,
715
+ edges,
716
+ nodeTypes,
717
+ edgeTypes,
718
+ onNodesChange,
719
+ onNodeClick: (_e, n) => choose(n.data.selection),
720
+ onEdgeClick: (_event, edge) => {
721
+ const occurrence = graph.edges.find((item) => item.id === edge.id);
722
+ if (occurrence) choose({ type: "relation", id: occurrence.relationId });
723
+ },
724
+ onNodeDragStop: (_e, node) => onLayoutChange?.(
725
+ Object.fromEntries(nodes.map((n) => [n.id, n.id === node.id ? node.position : n.position]))
726
+ ),
727
+ nodesConnectable: false,
728
+ deleteKeyCode: null,
729
+ edgesReconnectable: false,
730
+ fitView: true,
731
+ minZoom: 0.1,
732
+ maxZoom: 2,
733
+ colorMode: theme.palette.mode,
734
+ ariaLabelConfig: {
735
+ "controls.zoomIn.ariaLabel": labels.zoomIn,
736
+ "controls.zoomOut.ariaLabel": labels.zoomOut,
737
+ "controls.fitView.ariaLabel": labels.fit,
738
+ "controls.interactive.ariaLabel": labels.lock
739
+ },
740
+ children: [
741
+ /* @__PURE__ */ jsx(Background, { gap: 24 }),
742
+ /* @__PURE__ */ jsx(
743
+ EdgeLabels,
744
+ {
745
+ store: labelStore,
746
+ gap: edgeLabelGap,
747
+ maxWidth: edgeLabelMaxWidth,
748
+ fitLabel: labels.fit,
749
+ zoomInLabel: labels.zoomIn,
750
+ zoomOutLabel: labels.zoomOut
751
+ }
752
+ )
753
+ ]
754
+ }
755
+ ) }) : /* @__PURE__ */ jsx("div", { className: "prism-knowledge__empty", children: projection.total === 0 ? labels.empty : projection.limited ? labels.budget : labels.list })
756
+ }
757
+ )
758
+ }
759
+ ),
760
+ projection.limited && /* @__PURE__ */ jsxs("p", { className: "prism-knowledge__hint", role: "status", children: [
761
+ labels.partial,
762
+ ": ",
763
+ projection.entities.length + projection.relations.length,
764
+ " / ",
765
+ projection.total,
766
+ ".",
767
+ " ",
768
+ labels.omitted,
769
+ ": ",
770
+ projection.omittedRelations,
771
+ "."
772
+ ] }),
773
+ selected && object && /* @__PURE__ */ jsxs("section", { className: "prism-knowledge__details", "aria-label": labels.details, children: [
774
+ /* @__PURE__ */ jsx("h3", { children: object.label }),
775
+ /* @__PURE__ */ jsx("p", { children: object.description }),
776
+ selected.type === "relation" && /* @__PURE__ */ jsx("div", { className: "prism-knowledge__ports", children: ["inputs", "outputs"].map((side) => /* @__PURE__ */ jsxs("div", { children: [
777
+ /* @__PURE__ */ jsx("strong", { children: labels[side] }),
778
+ /* @__PURE__ */ jsx("ol", { children: object[side].map((port, i) => /* @__PURE__ */ jsxs("li", { children: [
779
+ port.role,
780
+ ": ",
781
+ data.entities.find((e) => e.id === port.entity)?.label
782
+ ] }, i)) })
783
+ ] }, side)) }),
784
+ renderDetails?.(selected)
785
+ ] })
786
+ ] })
787
+ ]
788
+ }
789
+ );
790
+ return expanded ? /* @__PURE__ */ jsx(Dialog, { open: true, fullScreen: true, onClose: () => setExpanded(false), "aria-label": labels.title, children: content }) : content;
791
+ }
792
+
793
+ export { KnowledgeGraph, defaultKnowledgeGraphLabels, entityNodeId, incidenceGraph, projectKnowledgeGraph, relationNodeId, validateKnowledgeGraph };
794
+ //# sourceMappingURL=index.js.map
795
+ //# sourceMappingURL=index.js.map