dishui 0.0.45 → 0.0.46

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 (60) hide show
  1. package/dist/chart.js +46 -0
  2. package/dist/components/Chart/Chart.d.ts +17 -0
  3. package/dist/components/Chart/Chart.js +29 -0
  4. package/dist/components/Chart/Chart.js.map +1 -0
  5. package/dist/components/Chart/index.d.ts +15 -0
  6. package/dist/components/Input/index.js +2 -2
  7. package/dist/components/Input/index.js.map +1 -1
  8. package/dist/components/Select/index.js +1 -1
  9. package/dist/components/Select/index.js.map +1 -1
  10. package/dist/components/pro/Flow/Flow.js +492 -392
  11. package/dist/components/pro/Flow/Flow.js.map +1 -1
  12. package/dist/components/pro/Flow/FlowCanvas.js +895 -864
  13. package/dist/components/pro/Flow/FlowCanvas.js.map +1 -1
  14. package/dist/components/pro/Flow/context/FlowUIContext.d.ts +2 -0
  15. package/dist/components/pro/Flow/context/FlowUIContext.js +68 -65
  16. package/dist/components/pro/Flow/context/FlowUIContext.js.map +1 -1
  17. package/dist/components/pro/Flow/edges/edgePaths.js +234 -216
  18. package/dist/components/pro/Flow/edges/edgePaths.js.map +1 -1
  19. package/dist/components/pro/Flow/hooks/useKeyboardShortcuts.js +21 -10
  20. package/dist/components/pro/Flow/hooks/useKeyboardShortcuts.js.map +1 -1
  21. package/dist/components/pro/Flow/hooks/useMindMap.js +138 -134
  22. package/dist/components/pro/Flow/hooks/useMindMap.js.map +1 -1
  23. package/dist/components/pro/Flow/index.d.ts +1 -1
  24. package/dist/components/pro/Flow/nodes/MediaContent.js +47 -25
  25. package/dist/components/pro/Flow/nodes/MediaContent.js.map +1 -1
  26. package/dist/components/pro/Flow/nodes/Model3DView.d.ts +7 -0
  27. package/dist/components/pro/Flow/nodes/Model3DView.js +118 -0
  28. package/dist/components/pro/Flow/nodes/Model3DView.js.map +1 -0
  29. package/dist/components/pro/Flow/nodes/NodeHandles.d.ts +2 -1
  30. package/dist/components/pro/Flow/nodes/NodeHandles.js +4 -2
  31. package/dist/components/pro/Flow/nodes/NodeHandles.js.map +1 -1
  32. package/dist/components/pro/Flow/nodes/NodeRenderer.d.ts +2 -0
  33. package/dist/components/pro/Flow/nodes/NodeRenderer.js +115 -113
  34. package/dist/components/pro/Flow/nodes/NodeRenderer.js.map +1 -1
  35. package/dist/components/pro/Flow/nodes/NodeText.d.ts +3 -0
  36. package/dist/components/pro/Flow/nodes/NodeText.js +26 -17
  37. package/dist/components/pro/Flow/nodes/NodeText.js.map +1 -1
  38. package/dist/components/pro/Flow/panels/FlowToolbar.js +85 -79
  39. package/dist/components/pro/Flow/panels/FlowToolbar.js.map +1 -1
  40. package/dist/components/pro/Flow/panels/InspectorPanel.js +618 -488
  41. package/dist/components/pro/Flow/panels/InspectorPanel.js.map +1 -1
  42. package/dist/components/pro/Flow/panels/OutlinePanel.js +15 -15
  43. package/dist/components/pro/Flow/panels/OutlinePanel.js.map +1 -1
  44. package/dist/components/pro/Flow/panels/ShapePalette.js +71 -55
  45. package/dist/components/pro/Flow/panels/ShapePalette.js.map +1 -1
  46. package/dist/components/pro/Flow/panels/toolbarIcons.d.ts +1 -0
  47. package/dist/components/pro/Flow/panels/toolbarIcons.js +59 -41
  48. package/dist/components/pro/Flow/panels/toolbarIcons.js.map +1 -1
  49. package/dist/components/pro/Flow/types.d.ts +13 -4
  50. package/dist/components/pro/Flow/types.js.map +1 -1
  51. package/dist/dishui.css +1 -1
  52. package/dist/index-nostyled.d.ts +3 -1
  53. package/dist/index.d.ts +3 -1
  54. package/dist/index.js +145 -143
  55. package/dist/utils/i18n.d.ts +1 -0
  56. package/dist/utils/i18n.js +200 -6
  57. package/dist/utils/i18n.js.map +1 -1
  58. package/dist/utils/menu.js +26 -10
  59. package/dist/utils/menu.js.map +1 -1
  60. package/package.json +14 -3
@@ -1,6 +1,6 @@
1
- import se from "../CodeEditor/editors/CodeEditor.js";
2
- import { DEFAULT_NODE_DATA as oe, ROOT_CANVAS_ID as re, createEmptyDocument as ie } from "./constants.js";
3
- import { FlowProvider as ae, useFlowContext as B } from "./context/FlowContext.js";
1
+ import oe from "../CodeEditor/editors/CodeEditor.js";
2
+ import { DEFAULT_NODE_DATA as $, ROOT_CANVAS_ID as re, createEmptyDocument as ie } from "./constants.js";
3
+ import { FlowProvider as ae, useFlowContext as Y } from "./context/FlowContext.js";
4
4
  import { FlowUIProvider as ce, useFlowUI as J } from "./context/FlowUIContext.js";
5
5
  import { generateId as X } from "./nodes/nodeUtils.js";
6
6
  import { normalizeEdgeHandles as de } from "./edges/edgePaths.js";
@@ -11,7 +11,7 @@ import { InspectorPanelContent as me } from "./panels/InspectorPanel.js";
11
11
  import { OutlinePanelContent as ge } from "./panels/OutlinePanel.js";
12
12
  import { PresentationMode as Ie } from "./panels/PresentationMode.js";
13
13
  import { MediaOverlay as we } from "./nodes/MediaOverlay.js";
14
- import V from "./panels/FlowPanelGroup.js";
14
+ import _ from "./panels/FlowPanelGroup.js";
15
15
  import ve from "./panels/Breadcrumb.js";
16
16
  import ye from "./panels/ContextMenu.js";
17
17
  import { MiniMapRenderer as xe } from "./canvas/MiniMapRenderer.js";
@@ -20,184 +20,195 @@ import { useClipboard as Se } from "./hooks/useClipboard.js";
20
20
  import { useKeyboardShortcuts as Me } from "./hooks/useKeyboardShortcuts.js";
21
21
  import { useMindMap as Ce } from "./hooks/useMindMap.js";
22
22
  /* empty css */
23
- import { forwardRef as ze, useCallback as T, useEffect as Z, useImperativeHandle as De, useMemo as q, useRef as L, useState as H } from "react";
24
- import { jsx as p, jsxs as U } from "react/jsx-runtime";
23
+ import { forwardRef as ze, useCallback as A, useEffect as V, useImperativeHandle as Pe, useMemo as Q, useRef as W, useState as B } from "react";
24
+ import { jsx as w, jsxs as Z } from "react/jsx-runtime";
25
25
  import { EditorView as Ee } from "@codemirror/view";
26
- function Pe(n) {
27
- let u = !1;
28
- const o = { ...n.canvases };
29
- for (const [h, r] of Object.entries(o)) {
30
- const a = /* @__PURE__ */ new Map();
31
- for (const e of r.nodes) a.set(e.id, e);
32
- const c = de(r.edges, a);
33
- c !== r.edges && (o[h] = {
26
+ function De(n) {
27
+ let p = !1;
28
+ const l = { ...n.canvases };
29
+ for (const [g, r] of Object.entries(l)) {
30
+ const a = r.nodes.map((t) => {
31
+ if (t.type !== "shapeSvg") return t;
32
+ const c = t.data.labelPlacement, I = c === "above" ? "top" : c === "center" ? "middle" : c === "below" ? "bottom" : t.data.labelPlacement;
33
+ return I === t.data.labelPlacement ? t : (p = !0, {
34
+ ...t,
35
+ data: {
36
+ ...t.data,
37
+ labelPlacement: I
38
+ }
39
+ });
40
+ }), f = /* @__PURE__ */ new Map();
41
+ for (const t of a) f.set(t.id, t);
42
+ const e = de(r.edges, f);
43
+ (a !== r.nodes || e !== r.edges) && (l[g] = {
34
44
  ...r,
35
- edges: c
36
- }, u = !0);
45
+ nodes: a,
46
+ edges: e
47
+ }, e !== r.edges && (p = !0));
37
48
  }
38
- return u ? {
49
+ return p ? {
39
50
  ...n,
40
- canvases: o
51
+ canvases: l
41
52
  } : n;
42
53
  }
43
- var Q = {
54
+ var ee = {
44
55
  nodeIds: /* @__PURE__ */ new Set(),
45
56
  edgeIds: /* @__PURE__ */ new Set(),
46
57
  lineIds: /* @__PURE__ */ new Set()
47
58
  };
48
- function Te({ onUndo: n, onRedo: u, groupRef: o, geoGroupRef: h, ungroupRef: r }) {
49
- const { selection: a, setSelection: c, currentCanvas: e, setDoc: m, currentCanvasId: f } = B(), { copy: b, cut: s, paste: t } = Se(), S = T(() => {
50
- const { nodeIds: d, edgeIds: w, lineIds: v } = a;
51
- d.size === 0 && w.size === 0 && v.size === 0 || d.size > 1 && !window.confirm(`确定要删除选中的 ${d.size} 个节点吗?`) || (m((x) => {
52
- const i = x.canvases[f];
59
+ function Te({ onUndo: n, onRedo: p, groupRef: l, geoGroupRef: g, ungroupRef: r }) {
60
+ const { selection: a, setSelection: f, currentCanvas: e, setDoc: t, currentCanvasId: c } = Y(), { viewport: I } = J(), { copy: d, cut: s, paste: M } = Se(), v = A(() => {
61
+ const { nodeIds: u, edgeIds: m, lineIds: S } = a;
62
+ u.size === 0 && m.size === 0 && S.size === 0 || u.size > 1 && !window.confirm(`确定要删除选中的 ${u.size} 个节点吗?`) || (t((z) => {
63
+ const i = z.canvases[c];
53
64
  return i ? {
54
- ...x,
65
+ ...z,
55
66
  canvases: {
56
- ...x.canvases,
57
- [f]: {
67
+ ...z.canvases,
68
+ [c]: {
58
69
  ...i,
59
- nodes: i.nodes.filter((l) => !d.has(l.id)).map((l) => l.parentId && d.has(l.parentId) ? {
60
- ...l,
70
+ nodes: i.nodes.filter((o) => !u.has(o.id)).map((o) => o.parentId && u.has(o.parentId) ? {
71
+ ...o,
61
72
  parentId: void 0
62
- } : l),
63
- edges: i.edges.filter((l) => !w.has(l.id) && !d.has(l.source) && !d.has(l.target)),
64
- lines: i.lines.filter((l) => !v.has(l.id)).map((l) => l.parentId && d.has(l.parentId) ? {
65
- ...l,
73
+ } : o),
74
+ edges: i.edges.filter((o) => !m.has(o.id) && !u.has(o.source) && !u.has(o.target)),
75
+ lines: i.lines.filter((o) => !S.has(o.id)).map((o) => o.parentId && u.has(o.parentId) ? {
76
+ ...o,
66
77
  parentId: void 0
67
- } : l)
78
+ } : o)
68
79
  }
69
80
  }
70
- } : x;
71
- }), c(Q));
81
+ } : z;
82
+ }), f(ee));
72
83
  }, [
73
84
  a,
74
- m,
75
- f,
76
- c
77
- ]), g = T(() => {
78
- c({
79
- nodeIds: new Set(e.nodes.map((d) => d.id)),
80
- edgeIds: new Set(e.edges.map((d) => d.id)),
81
- lineIds: new Set(e.lines.map((d) => d.id))
85
+ t,
86
+ c,
87
+ f
88
+ ]), b = A(() => {
89
+ f({
90
+ nodeIds: new Set(e.nodes.map((u) => u.id)),
91
+ edgeIds: new Set(e.edges.map((u) => u.id)),
92
+ lineIds: new Set(e.lines.map((u) => u.id))
82
93
  });
83
- }, [e, c]), I = T((d) => {
84
- const w = a.nodeIds, v = a.lineIds;
85
- if (w.size + v.size < 2) return;
86
- const x = e.nodes.filter((z) => w.has(z.id)), i = e.lines.filter((z) => v.has(z.id)), l = 20;
87
- let M = 1 / 0, R = 1 / 0, G = -1 / 0, F = -1 / 0;
88
- for (const z of x)
89
- M = Math.min(M, z.position.x), R = Math.min(R, z.position.y), G = Math.max(G, z.position.x + z.width), F = Math.max(F, z.position.y + z.height);
90
- for (const z of i) for (const y of z.points)
91
- M = Math.min(M, y.x), R = Math.min(R, y.y), G = Math.max(G, y.x), F = Math.max(F, y.y);
92
- const O = d === "geometryGroup", K = X("group"), C = {
93
- id: K,
94
- type: d,
94
+ }, [e, f]), P = A((u) => {
95
+ const m = a.nodeIds, S = a.lineIds;
96
+ if (m.size + S.size < 2) return;
97
+ const z = e.nodes.filter((h) => m.has(h.id)), i = e.lines.filter((h) => S.has(h.id)), o = 20;
98
+ let y = 1 / 0, k = 1 / 0, T = -1 / 0, F = -1 / 0;
99
+ for (const h of z)
100
+ y = Math.min(y, h.position.x), k = Math.min(k, h.position.y), T = Math.max(T, h.position.x + h.width), F = Math.max(F, h.position.y + h.height);
101
+ for (const h of i) for (const x of h.points)
102
+ y = Math.min(y, x.x), k = Math.min(k, x.y), T = Math.max(T, x.x), F = Math.max(F, x.y);
103
+ const K = u === "geometryGroup", U = X("group"), C = {
104
+ id: U,
105
+ type: u,
95
106
  position: {
96
- x: M - l,
97
- y: R - l
107
+ x: y - o,
108
+ y: k - o
98
109
  },
99
- width: G - M + l * 2,
100
- height: F - R + l * 2,
110
+ width: T - y + o * 2,
111
+ height: F - k + o * 2,
101
112
  data: {
102
- ...oe,
103
- label: O ? "Geo Group" : "Group",
104
- fill: O ? "#fefce8" : "#f0f9ff",
113
+ ...$,
114
+ label: K ? "Geo Group" : "Group",
115
+ fill: K ? "#fefce8" : "#f0f9ff",
105
116
  stroke: "#9ca3af",
106
117
  strokeWidth: 1.5,
107
- borderStyle: O ? "dashed" : "dotted",
118
+ borderStyle: K ? "dashed" : "dotted",
108
119
  isGroup: !0
109
120
  }
110
121
  };
111
- m((z) => {
112
- const y = z.canvases[f];
113
- return y ? {
114
- ...z,
122
+ t((h) => {
123
+ const x = h.canvases[c];
124
+ return x ? {
125
+ ...h,
115
126
  canvases: {
116
- ...z.canvases,
117
- [f]: {
118
- ...y,
119
- nodes: O ? [C, ...y.nodes] : [C, ...y.nodes.map((E) => w.has(E.id) ? {
120
- ...E,
121
- parentId: K
122
- } : E)],
123
- lines: O ? y.lines : y.lines.map((E) => v.has(E.id) ? {
124
- ...E,
125
- parentId: K
126
- } : E)
127
+ ...h.canvases,
128
+ [c]: {
129
+ ...x,
130
+ nodes: K ? [C, ...x.nodes] : [C, ...x.nodes.map((L) => m.has(L.id) ? {
131
+ ...L,
132
+ parentId: U
133
+ } : L)],
134
+ lines: K ? x.lines : x.lines.map((L) => S.has(L.id) ? {
135
+ ...L,
136
+ parentId: U
137
+ } : L)
127
138
  }
128
139
  }
129
- } : z;
130
- }), c({
131
- nodeIds: /* @__PURE__ */ new Set([K]),
140
+ } : h;
141
+ }), f({
142
+ nodeIds: /* @__PURE__ */ new Set([U]),
132
143
  edgeIds: /* @__PURE__ */ new Set(),
133
144
  lineIds: /* @__PURE__ */ new Set()
134
145
  });
135
146
  }, [
136
147
  a,
137
148
  e,
138
- m,
139
- f,
140
- c
141
- ]), D = T(() => I("flowGroup"), [I]), N = T(() => I("geometryGroup"), [I]), A = T(() => {
142
- const d = a.nodeIds;
143
- if (d.size === 0) return;
144
- const w = /* @__PURE__ */ new Set(), v = /* @__PURE__ */ new Set(), x = /* @__PURE__ */ new Set();
145
- for (const i of e.nodes) d.has(i.id) && (i.type === "flowGroup" || i.type === "geometryGroup" || i.data.isGroup) && w.add(i.id);
146
- if (w.size !== 0) {
147
- for (const i of e.nodes) i.parentId && w.has(i.parentId) && v.add(i.id);
148
- for (const i of e.lines) i.parentId && w.has(i.parentId) && x.add(i.id);
149
- m((i) => {
150
- const l = i.canvases[f];
151
- return l ? {
149
+ t,
150
+ c,
151
+ f
152
+ ]), O = A(() => P("flowGroup"), [P]), G = A(() => P("geometryGroup"), [P]), R = A(() => {
153
+ const u = a.nodeIds;
154
+ if (u.size === 0) return;
155
+ const m = /* @__PURE__ */ new Set(), S = /* @__PURE__ */ new Set(), z = /* @__PURE__ */ new Set();
156
+ for (const i of e.nodes) u.has(i.id) && (i.type === "flowGroup" || i.type === "geometryGroup" || i.data.isGroup) && m.add(i.id);
157
+ if (m.size !== 0) {
158
+ for (const i of e.nodes) i.parentId && m.has(i.parentId) && S.add(i.id);
159
+ for (const i of e.lines) i.parentId && m.has(i.parentId) && z.add(i.id);
160
+ t((i) => {
161
+ const o = i.canvases[c];
162
+ return o ? {
152
163
  ...i,
153
164
  canvases: {
154
165
  ...i.canvases,
155
- [f]: {
156
- ...l,
157
- nodes: l.nodes.filter((M) => !w.has(M.id)).map((M) => v.has(M.id) ? {
158
- ...M,
166
+ [c]: {
167
+ ...o,
168
+ nodes: o.nodes.filter((y) => !m.has(y.id)).map((y) => S.has(y.id) ? {
169
+ ...y,
159
170
  parentId: void 0
160
- } : M),
161
- lines: l.lines.map((M) => x.has(M.id) ? {
162
- ...M,
171
+ } : y),
172
+ lines: o.lines.map((y) => z.has(y.id) ? {
173
+ ...y,
163
174
  parentId: void 0
164
- } : M)
175
+ } : y)
165
176
  }
166
177
  }
167
178
  } : i;
168
- }), c({
169
- nodeIds: v,
179
+ }), f({
180
+ nodeIds: S,
170
181
  edgeIds: /* @__PURE__ */ new Set(),
171
- lineIds: x
182
+ lineIds: z
172
183
  });
173
184
  }
174
185
  }, [
175
186
  a,
176
187
  e,
177
- m,
178
- f,
179
- c
188
+ t,
189
+ c,
190
+ f
180
191
  ]);
181
- o.current = D, h.current = N, r.current = A;
182
- const P = T((d) => {
183
- const w = a.nodeIds, v = a.lineIds;
184
- w.size === 0 && v.size === 0 || m((x) => {
185
- const i = x.canvases[f];
186
- if (!i) return x;
187
- const l = i.nodes.map((C) => C.zIndex ?? 0), M = l.length > 0 ? Math.max(...l) : 0, R = l.length > 0 ? Math.min(...l) : 0, G = i.lines.map((C) => C.zIndex ?? 0), F = G.length > 0 ? Math.max(...G) : 0, O = G.length > 0 ? Math.min(...G) : 0, K = (C, z, y) => d === "front" ? z + 1 : d === "back" ? y - 1 : d === "up" ? C + 1 : C - 1;
192
+ l.current = O, g.current = G, r.current = R;
193
+ const N = A((u) => {
194
+ const m = a.nodeIds, S = a.lineIds;
195
+ m.size === 0 && S.size === 0 || t((z) => {
196
+ const i = z.canvases[c];
197
+ if (!i) return z;
198
+ const o = i.nodes.map((C) => C.zIndex ?? 0), y = o.length > 0 ? Math.max(...o) : 0, k = o.length > 0 ? Math.min(...o) : 0, T = i.lines.map((C) => C.zIndex ?? 0), F = T.length > 0 ? Math.max(...T) : 0, K = T.length > 0 ? Math.min(...T) : 0, U = (C, h, x) => u === "front" ? h + 1 : u === "back" ? x - 1 : u === "up" ? C + 1 : C - 1;
188
199
  return {
189
- ...x,
200
+ ...z,
190
201
  canvases: {
191
- ...x.canvases,
192
- [f]: {
202
+ ...z.canvases,
203
+ [c]: {
193
204
  ...i,
194
- nodes: i.nodes.map((C) => w.has(C.id) ? {
205
+ nodes: i.nodes.map((C) => m.has(C.id) ? {
195
206
  ...C,
196
- zIndex: K(C.zIndex ?? 0, M, R)
207
+ zIndex: U(C.zIndex ?? 0, y, k)
197
208
  } : C),
198
- lines: i.lines.map((C) => v.has(C.id) ? {
209
+ lines: i.lines.map((C) => S.has(C.id) ? {
199
210
  ...C,
200
- zIndex: K(C.zIndex ?? 0, F, O)
211
+ zIndex: U(C.zIndex ?? 0, F, K)
201
212
  } : C)
202
213
  }
203
214
  }
@@ -205,138 +216,227 @@ function Te({ onUndo: n, onRedo: u, groupRef: o, geoGroupRef: h, ungroupRef: r }
205
216
  });
206
217
  }, [
207
218
  a,
208
- m,
209
- f
219
+ t,
220
+ c
210
221
  ]);
211
- return Me(q(() => ({
222
+ return V(() => {
223
+ const u = (m) => {
224
+ const S = m.target;
225
+ if (S?.tagName === "INPUT" || S?.tagName === "TEXTAREA" || S?.isContentEditable) return;
226
+ const z = Array.from(m.clipboardData?.items ?? []).find((y) => y.type.startsWith("image/"));
227
+ if (!z) {
228
+ m.preventDefault(), M();
229
+ return;
230
+ }
231
+ const i = z.getAsFile();
232
+ if (!i) return;
233
+ m.preventDefault();
234
+ const o = new FileReader();
235
+ o.onload = () => {
236
+ if (typeof o.result != "string") return;
237
+ const y = a.nodeIds.size === 1 ? e.nodes.find((D) => a.nodeIds.has(D.id) && D.type === "mediaNode" && D.data.mediaKind === "image") : void 0;
238
+ if (y) {
239
+ t((D) => {
240
+ const E = D.canvases[c];
241
+ return E ? {
242
+ ...D,
243
+ canvases: {
244
+ ...D.canvases,
245
+ [c]: {
246
+ ...E,
247
+ nodes: E.nodes.map((H) => H.id === y.id ? {
248
+ ...H,
249
+ data: {
250
+ ...H.data,
251
+ mediaContent: o.result
252
+ }
253
+ } : H)
254
+ }
255
+ }
256
+ } : D;
257
+ });
258
+ return;
259
+ }
260
+ const k = X("node"), T = 320, F = 220, K = window.innerWidth, U = window.innerHeight, C = (K / 2 - I.x) / I.zoom, h = (U / 2 - I.y) / I.zoom, x = Math.max(0, ...e.nodes.map((D) => D.zIndex ?? 0)), L = {
261
+ id: k,
262
+ type: "mediaNode",
263
+ position: {
264
+ x: C - T / 2,
265
+ y: h - F / 2
266
+ },
267
+ width: T,
268
+ height: F,
269
+ zIndex: x + 1,
270
+ data: {
271
+ ...$,
272
+ label: i.name || "Image",
273
+ fill: "#ffffff",
274
+ stroke: "#cbd5e1",
275
+ strokeWidth: 1.5,
276
+ color: "#1f2937",
277
+ fontSize: 13,
278
+ borderStyle: "solid",
279
+ mediaKind: "image",
280
+ mediaContent: o.result
281
+ }
282
+ };
283
+ t((D) => {
284
+ const E = D.canvases[c];
285
+ return E ? {
286
+ ...D,
287
+ canvases: {
288
+ ...D.canvases,
289
+ [c]: {
290
+ ...E,
291
+ nodes: [...E.nodes, L]
292
+ }
293
+ }
294
+ } : D;
295
+ }), f({
296
+ nodeIds: /* @__PURE__ */ new Set([k]),
297
+ edgeIds: /* @__PURE__ */ new Set(),
298
+ lineIds: /* @__PURE__ */ new Set()
299
+ });
300
+ }, o.readAsDataURL(i);
301
+ };
302
+ return window.addEventListener("paste", u), () => window.removeEventListener("paste", u);
303
+ }, [
304
+ e,
305
+ c,
306
+ M,
307
+ a,
308
+ t,
309
+ f,
310
+ I
311
+ ]), Me(Q(() => ({
212
312
  undo: n,
213
- redo: u,
214
- copy: b,
313
+ redo: p,
314
+ copy: d,
215
315
  cut: s,
216
- paste: t,
217
- deleteSelected: S,
218
- selectAll: g,
219
- group: D,
220
- geoGroup: N,
221
- ungroup: A,
222
- bringToFront: () => P("front"),
223
- bringForward: () => P("up"),
224
- sendBackward: () => P("down"),
225
- sendToBack: () => P("back")
316
+ paste: M,
317
+ deleteSelected: v,
318
+ selectAll: b,
319
+ group: O,
320
+ geoGroup: G,
321
+ ungroup: R,
322
+ bringToFront: () => N("front"),
323
+ bringForward: () => N("up"),
324
+ sendBackward: () => N("down"),
325
+ sendToBack: () => N("back")
226
326
  }), [
227
327
  n,
228
- u,
229
- b,
328
+ p,
329
+ d,
230
330
  s,
231
- t,
232
- S,
233
- g,
234
- D,
235
- N,
236
- A,
237
- P
331
+ M,
332
+ v,
333
+ b,
334
+ O,
335
+ G,
336
+ R,
337
+ N
238
338
  ])), Ce(), null;
239
339
  }
240
- var hn = ze(function({ initialDocument: u, onChange: o, width: h, height: r, readOnly: a = !1, onBack: c, onExportPNG: e, onPublish: m, showMiniMap: f = !0, showGrid: b = !0, gridSize: s = 20, className: t }, S) {
241
- const [g, I] = H(() => Pe(u ?? ie())), [D, N] = H(Q), A = L(null), P = L(null), d = L(null), { wrappedSetDoc: w, undo: v, redo: x, canUndo: i, canRedo: l } = be(g, I), M = L(null), R = L(null), G = L(null), F = L(o);
242
- F.current = o;
243
- const O = L(g);
244
- O.current = g, De(S, () => ({
245
- exportPNG: async (y) => {
246
- const E = A.current;
247
- return !E || E.destroyed ? null : E.exportPNG(y);
340
+ var hn = ze(function({ initialDocument: p, onChange: l, width: g, height: r, readOnly: a = !1, onBack: f, onExportPNG: e, onPublish: t, showMiniMap: c = !0, showGrid: I = !0, gridSize: d = 20, className: s }, M) {
341
+ const [v, b] = B(() => De(p ?? ie())), [P, O] = B(ee), G = W(null), R = W(null), N = W(null), { wrappedSetDoc: u, undo: m, redo: S, canUndo: z, canRedo: i } = be(v, b), o = W(null), y = W(null), k = W(null), T = W(l);
342
+ T.current = l;
343
+ const F = W(v);
344
+ F.current = v, Pe(M, () => ({
345
+ exportPNG: async (h) => {
346
+ const x = G.current;
347
+ return !x || x.destroyed ? null : x.exportPNG(h);
248
348
  },
249
- getDocument: () => O.current
349
+ getDocument: () => F.current
250
350
  }), []);
251
- const K = T((y) => {
252
- w((E) => {
253
- const W = typeof y == "function" ? y(E) : y;
254
- return queueMicrotask(() => F.current?.(W)), W;
351
+ const K = A((h) => {
352
+ u((x) => {
353
+ const L = typeof h == "function" ? h(x) : h;
354
+ return queueMicrotask(() => T.current?.(L)), L;
255
355
  });
256
- }, [w]), C = T((y) => {
257
- A.current = y, P.current && !d.current && (d.current = new xe(P.current));
356
+ }, [u]), U = A((h) => {
357
+ G.current = h, R.current && !N.current && (N.current = new xe(R.current));
258
358
  }, []);
259
- Z(() => {
260
- let y = !1, E = null;
261
- const W = () => {
262
- const k = A.current, j = d.current;
263
- if (!k || k.destroyed || !j) return;
264
- const ne = {
265
- x: k.world.position.x,
266
- y: k.world.position.y,
267
- zoom: k.world.scale.x
268
- }, te = g.stack[g.stack.length - 1] ?? "root", Y = g.canvases[te];
269
- Y && j.update(Y.nodes, ne, k.app.screen.width, k.app.screen.height);
270
- }, _ = () => {
271
- if (y) return;
272
- const k = A.current;
273
- k && !k.destroyed && d.current ? (k.app.ticker.add(W), E = k) : requestAnimationFrame(_);
359
+ V(() => {
360
+ let h = !1, x = null;
361
+ const L = () => {
362
+ const E = G.current, H = N.current;
363
+ if (!E || E.destroyed || !H) return;
364
+ const te = {
365
+ x: E.world.position.x,
366
+ y: E.world.position.y,
367
+ zoom: E.world.scale.x
368
+ }, se = v.stack[v.stack.length - 1] ?? "root", j = v.canvases[se];
369
+ j && H.update(j.nodes, te, E.app.screen.width, E.app.screen.height);
370
+ }, D = () => {
371
+ if (h) return;
372
+ const E = G.current;
373
+ E && !E.destroyed && N.current ? (E.app.ticker.add(L), x = E) : requestAnimationFrame(D);
274
374
  };
275
- return _(), () => {
276
- y = !0, E && !E.destroyed && E.app.ticker.remove(W);
375
+ return D(), () => {
376
+ h = !0, x && !x.destroyed && x.app.ticker.remove(L);
277
377
  };
278
- }, [g]);
279
- const z = {
280
- width: h ?? "100%",
378
+ }, [v]);
379
+ const C = {
380
+ width: g ?? "100%",
281
381
  height: r ?? "100%"
282
382
  };
283
- return /* @__PURE__ */ p("div", {
284
- className: `flow-container ${t ?? ""}`,
285
- style: z,
286
- children: /* @__PURE__ */ p(ae, {
287
- doc: g,
383
+ return /* @__PURE__ */ w("div", {
384
+ className: `flow-container ${s ?? ""}`,
385
+ style: C,
386
+ children: /* @__PURE__ */ w(ae, {
387
+ doc: v,
288
388
  setDoc: K,
289
- selection: D,
290
- setSelection: N,
291
- children: /* @__PURE__ */ U(ce, {
292
- showMiniMap: f,
293
- showGrid: b,
294
- gridSize: s,
295
- children: [/* @__PURE__ */ p(Te, {
296
- onUndo: v,
297
- onRedo: x,
298
- groupRef: M,
299
- geoGroupRef: R,
300
- ungroupRef: G
301
- }), /* @__PURE__ */ U(ke, { children: [
302
- /* @__PURE__ */ p(le, { onPixiReady: C }),
303
- /* @__PURE__ */ U(Ae, { children: [
304
- /* @__PURE__ */ p(we, {}),
305
- !a && /* @__PURE__ */ p(ue, {
306
- onBack: c,
307
- onUndo: v,
308
- onRedo: x,
309
- canUndo: i,
310
- canRedo: l,
311
- onGroup: () => M.current?.(),
312
- onGeoGroup: () => R.current?.(),
313
- onUngroup: () => G.current?.(),
389
+ selection: P,
390
+ setSelection: O,
391
+ children: /* @__PURE__ */ Z(ce, {
392
+ showMiniMap: c,
393
+ showGrid: I,
394
+ gridSize: d,
395
+ children: [/* @__PURE__ */ w(Te, {
396
+ onUndo: m,
397
+ onRedo: S,
398
+ groupRef: o,
399
+ geoGroupRef: y,
400
+ ungroupRef: k
401
+ }), /* @__PURE__ */ Z(Re, { children: [
402
+ /* @__PURE__ */ w(le, { onPixiReady: U }),
403
+ /* @__PURE__ */ Z(Ae, { children: [
404
+ /* @__PURE__ */ w(we, {}),
405
+ !a && /* @__PURE__ */ w(ue, {
406
+ onBack: f,
407
+ onUndo: m,
408
+ onRedo: S,
409
+ canUndo: z,
410
+ canRedo: i,
411
+ onGroup: () => o.current?.(),
412
+ onGeoGroup: () => y.current?.(),
413
+ onUngroup: () => k.current?.(),
314
414
  onExportPNG: e,
315
- onPublish: m
415
+ onPublish: t
316
416
  }),
317
- /* @__PURE__ */ p(ve, {})
417
+ /* @__PURE__ */ w(ve, {})
318
418
  ] }),
319
- /* @__PURE__ */ p(Ke, {}),
320
- /* @__PURE__ */ p(Le, {
321
- canvasRef: P,
322
- pixiRef: A,
323
- miniMapRef: d
419
+ /* @__PURE__ */ w(We, {}),
420
+ /* @__PURE__ */ w(ke, {
421
+ canvasRef: R,
422
+ pixiRef: G,
423
+ miniMapRef: N
324
424
  }),
325
- /* @__PURE__ */ p(Ie, {})
425
+ /* @__PURE__ */ w(Ie, {})
326
426
  ] })]
327
427
  })
328
428
  })
329
429
  });
330
430
  });
331
431
  function Ae({ children: n }) {
332
- const { presentation: u } = J();
333
- return /* @__PURE__ */ p("div", {
432
+ const { presentation: p } = J();
433
+ return /* @__PURE__ */ w("div", {
334
434
  className: "flow-overlay",
335
- style: { display: u ? "none" : void 0 },
435
+ style: { display: p ? "none" : void 0 },
336
436
  children: n
337
437
  });
338
438
  }
339
- var Ge = [
439
+ var Ne = [
340
440
  {
341
441
  id: "shapes",
342
442
  label: "Shapes",
@@ -380,106 +480,106 @@ var Ge = [
380
480
  showKey: "showJson"
381
481
  }
382
482
  ];
383
- function Ne(n) {
483
+ function Le(n) {
384
484
  switch (n) {
385
485
  case "shapes":
386
- return /* @__PURE__ */ p(he, {});
486
+ return /* @__PURE__ */ w(he, {});
387
487
  case "icons":
388
- return /* @__PURE__ */ p(pe, {});
488
+ return /* @__PURE__ */ w(pe, {});
389
489
  case "media":
390
- return /* @__PURE__ */ p(fe, {});
490
+ return /* @__PURE__ */ w(fe, {});
391
491
  case "inspector":
392
- return /* @__PURE__ */ p(me, {});
492
+ return /* @__PURE__ */ w(me, {});
393
493
  case "outline":
394
- return /* @__PURE__ */ p(ge, {});
494
+ return /* @__PURE__ */ w(ge, {});
395
495
  case "json":
396
- return /* @__PURE__ */ p(Oe, {});
496
+ return /* @__PURE__ */ w(Oe, {});
397
497
  default:
398
498
  return null;
399
499
  }
400
500
  }
401
- function ke({ children: n }) {
402
- const u = J(), { detachedTabs: o, toggleDetach: h, presentation: r } = u, a = Ge.filter((t) => !t.showKey || u[t.showKey]), c = (t) => ({
403
- id: t.id,
404
- label: t.label,
405
- icon: t.icon,
406
- content: Ne(t.id)
407
- }), e = a.filter((t) => t.side === "left" && !o.has(t.id)).map(c), m = a.filter((t) => t.side === "right" && !o.has(t.id)).map(c), f = a.filter((t) => o.has(t.id)), b = T((t) => h(t), [h]), s = T((t) => h(t), [h]);
408
- return /* @__PURE__ */ U("div", {
501
+ function Re({ children: n }) {
502
+ const p = J(), { detachedTabs: l, toggleDetach: g, presentation: r } = p, a = Ne.filter((s) => !s.showKey || p[s.showKey]), f = (s) => ({
503
+ id: s.id,
504
+ label: s.label,
505
+ icon: s.icon,
506
+ content: Le(s.id)
507
+ }), e = a.filter((s) => s.side === "left" && !l.has(s.id)).map(f), t = a.filter((s) => s.side === "right" && !l.has(s.id)).map(f), c = a.filter((s) => l.has(s.id)), I = A((s) => g(s), [g]), d = A((s) => g(s), [g]);
508
+ return /* @__PURE__ */ Z("div", {
409
509
  className: "flow-workspace",
410
510
  children: [
411
- !r && e.length > 0 && /* @__PURE__ */ p(V, {
511
+ !r && e.length > 0 && /* @__PURE__ */ w(_, {
412
512
  tabs: e,
413
513
  defaultTab: e[0]?.id,
414
514
  resizeEdge: "right",
415
515
  defaultWidth: 220,
416
- onDetach: b
516
+ onDetach: I
417
517
  }),
418
- /* @__PURE__ */ U("div", {
518
+ /* @__PURE__ */ Z("div", {
419
519
  className: "flow-stage",
420
- children: [n, !r && f.map((t, S) => /* @__PURE__ */ p(V, {
421
- tabs: [c(t)],
520
+ children: [n, !r && c.map((s, M) => /* @__PURE__ */ w(_, {
521
+ tabs: [f(s)],
422
522
  resizeEdge: "right",
423
523
  defaultWidth: 240,
424
524
  style: {
425
- top: 64 + S * 40,
426
- left: 24 + S * 30
525
+ top: 64 + M * 40,
526
+ left: 24 + M * 30
427
527
  },
428
528
  isDetached: !0,
429
- onAttach: s
430
- }, t.id))]
529
+ onAttach: d
530
+ }, s.id))]
431
531
  }),
432
- !r && m.length > 0 && /* @__PURE__ */ p(V, {
433
- tabs: m,
434
- defaultTab: m[0]?.id,
532
+ !r && t.length > 0 && /* @__PURE__ */ w(_, {
533
+ tabs: t,
534
+ defaultTab: t[0]?.id,
435
535
  resizeEdge: "left",
436
536
  defaultWidth: 240,
437
- onDetach: b
537
+ onDetach: I
438
538
  })
439
539
  ]
440
540
  });
441
541
  }
442
- function Le({ canvasRef: n, pixiRef: u, miniMapRef: o }) {
443
- const { showMiniMap: h, setViewport: r, presentation: a } = J(), c = L(!1), e = T((s, t) => {
444
- const S = n.current, g = u.current, I = o.current;
445
- if (!S || !g || g.destroyed || !I) return;
446
- const D = S.getBoundingClientRect();
447
- if (D.width === 0 || D.height === 0) return;
448
- const { width: N, height: A } = I.size, P = (s - D.left) / D.width * N, d = (t - D.top) / D.height * A, w = I.minimapToWorld(P, d);
449
- if (!w) return;
450
- const v = g.world.scale.x || 1, x = g.app.screen.width, i = g.app.screen.height;
542
+ function ke({ canvasRef: n, pixiRef: p, miniMapRef: l }) {
543
+ const { showMiniMap: g, setViewport: r, presentation: a } = J(), f = W(!1), e = A((d, s) => {
544
+ const M = n.current, v = p.current, b = l.current;
545
+ if (!M || !v || v.destroyed || !b) return;
546
+ const P = M.getBoundingClientRect();
547
+ if (P.width === 0 || P.height === 0) return;
548
+ const { width: O, height: G } = b.size, R = (d - P.left) / P.width * O, N = (s - P.top) / P.height * G, u = b.minimapToWorld(R, N);
549
+ if (!u) return;
550
+ const m = v.world.scale.x || 1, S = v.app.screen.width, z = v.app.screen.height;
451
551
  r({
452
- x: x / 2 - w.x * v,
453
- y: i / 2 - w.y * v,
454
- zoom: v
552
+ x: S / 2 - u.x * m,
553
+ y: z / 2 - u.y * m,
554
+ zoom: m
455
555
  });
456
556
  }, [
457
557
  n,
458
- u,
459
- o,
558
+ p,
559
+ l,
460
560
  r
461
- ]), m = T((s) => {
462
- s.preventDefault(), s.currentTarget.setPointerCapture(s.pointerId), c.current = !0, e(s.clientX, s.clientY);
463
- }, [e]), f = T((s) => {
464
- c.current && e(s.clientX, s.clientY);
465
- }, [e]), b = T((s) => {
466
- c.current = !1;
561
+ ]), t = A((d) => {
562
+ d.preventDefault(), d.currentTarget.setPointerCapture(d.pointerId), f.current = !0, e(d.clientX, d.clientY);
563
+ }, [e]), c = A((d) => {
564
+ f.current && e(d.clientX, d.clientY);
565
+ }, [e]), I = A((d) => {
566
+ f.current = !1;
467
567
  try {
468
- s.currentTarget.releasePointerCapture(s.pointerId);
568
+ d.currentTarget.releasePointerCapture(d.pointerId);
469
569
  } catch {
470
570
  }
471
571
  }, []);
472
- return /* @__PURE__ */ p("div", {
572
+ return /* @__PURE__ */ w("div", {
473
573
  className: "flow-minimap",
474
574
  style: {
475
- display: h && !a ? void 0 : "none",
575
+ display: g && !a ? void 0 : "none",
476
576
  cursor: "pointer"
477
577
  },
478
- onPointerDown: m,
479
- onPointerMove: f,
480
- onPointerUp: b,
578
+ onPointerDown: t,
579
+ onPointerMove: c,
580
+ onPointerUp: I,
481
581
  title: "点击或拖动以移动画布",
482
- children: /* @__PURE__ */ p("canvas", {
582
+ children: /* @__PURE__ */ w("canvas", {
483
583
  ref: n,
484
584
  width: 180,
485
585
  height: 120,
@@ -491,11 +591,11 @@ function Le({ canvasRef: n, pixiRef: u, miniMapRef: o }) {
491
591
  })
492
592
  });
493
593
  }
494
- function Re(n, u) {
495
- const o = `"id": "${u}"`, h = n.indexOf(o);
496
- if (h === -1) return null;
594
+ function Ge(n, p) {
595
+ const l = `"id": "${p}"`, g = n.indexOf(l);
596
+ if (g === -1) return null;
497
597
  let r = 0, a = -1;
498
- for (let e = h; e >= 0; e--)
598
+ for (let e = g; e >= 0; e--)
499
599
  if (n[e] === "}" && r++, n[e] === "{") {
500
600
  if (r === 0) {
501
601
  a = e;
@@ -505,83 +605,83 @@ function Re(n, u) {
505
605
  }
506
606
  if (a === -1) return null;
507
607
  r = 0;
508
- let c = -1;
608
+ let f = -1;
509
609
  for (let e = a; e < n.length; e++)
510
610
  if (n[e] === "{" && r++, n[e] === "}" && (r--, r === 0)) {
511
- c = e;
611
+ f = e;
512
612
  break;
513
613
  }
514
- return c === -1 ? null : {
614
+ return f === -1 ? null : {
515
615
  startLine: n.slice(0, a).split(`
516
616
  `).length,
517
- endLine: n.slice(0, c + 1).split(`
617
+ endLine: n.slice(0, f + 1).split(`
518
618
  `).length
519
619
  };
520
620
  }
521
- function $(n) {
522
- n.querySelectorAll(".cm-line.flow-json-hl").forEach((u) => u.classList.remove("flow-json-hl"));
621
+ function q(n) {
622
+ n.querySelectorAll(".cm-line.flow-json-hl").forEach((p) => p.classList.remove("flow-json-hl"));
523
623
  }
524
- function Fe(n, u, o) {
525
- const h = n.getView();
526
- if (h)
527
- for (let r = u; r <= o; r++) try {
528
- const a = h.state.doc.line(r), c = h.domAtPos(a.from), e = c.node instanceof HTMLElement ? c.node.closest(".cm-line") : c.node.parentElement?.closest(".cm-line");
624
+ function Fe(n, p, l) {
625
+ const g = n.getView();
626
+ if (g)
627
+ for (let r = p; r <= l; r++) try {
628
+ const a = g.state.doc.line(r), f = g.domAtPos(a.from), e = f.node instanceof HTMLElement ? f.node.closest(".cm-line") : f.node.parentElement?.closest(".cm-line");
529
629
  e && e.classList.add("flow-json-hl");
530
630
  } catch {
531
631
  }
532
632
  }
533
633
  function Oe() {
534
- const { setDoc: n, currentCanvasId: u, selection: o, currentCanvas: h } = B(), [r, a] = H(""), [c, e] = H(null), m = L(!1), f = L(null), b = L(null), s = q(() => o.nodeIds.size + o.edgeIds.size + o.lineIds.size !== 1 ? null : o.nodeIds.size === 1 ? [...o.nodeIds][0] : o.edgeIds.size === 1 ? [...o.edgeIds][0] : o.lineIds.size === 1 ? [...o.lineIds][0] : null, [o]);
535
- Z(() => {
536
- if (m.current) {
537
- m.current = !1;
634
+ const { setDoc: n, currentCanvasId: p, selection: l, currentCanvas: g } = Y(), [r, a] = B(""), [f, e] = B(null), t = W(!1), c = W(null), I = W(null), d = Q(() => l.nodeIds.size + l.edgeIds.size + l.lineIds.size !== 1 ? null : l.nodeIds.size === 1 ? [...l.nodeIds][0] : l.edgeIds.size === 1 ? [...l.edgeIds][0] : l.lineIds.size === 1 ? [...l.lineIds][0] : null, [l]);
635
+ V(() => {
636
+ if (t.current) {
637
+ t.current = !1;
538
638
  return;
539
639
  }
540
- a(JSON.stringify(h, null, 2)), e(null);
541
- }, [h]), Z(() => {
542
- const g = b.current;
543
- if (g && $(g), !s) return;
544
- const I = setTimeout(() => {
545
- const D = Re(r, s);
546
- if (!D || !b.current) return;
547
- const N = f.current?.getView();
548
- if (!N) return;
549
- const A = b.current, P = N.scrollDOM;
550
- P.style.scrollBehavior = "smooth";
551
- const d = N.state.doc.line(D.startLine);
552
- N.dispatch({ effects: Ee.scrollIntoView(d.from, {
640
+ a(JSON.stringify(g, null, 2)), e(null);
641
+ }, [g]), V(() => {
642
+ const v = I.current;
643
+ if (v && q(v), !d) return;
644
+ const b = setTimeout(() => {
645
+ const P = Ge(r, d);
646
+ if (!P || !I.current) return;
647
+ const O = c.current?.getView();
648
+ if (!O) return;
649
+ const G = I.current, R = O.scrollDOM;
650
+ R.style.scrollBehavior = "smooth";
651
+ const N = O.state.doc.line(P.startLine);
652
+ O.dispatch({ effects: Ee.scrollIntoView(N.from, {
553
653
  y: "start",
554
654
  yMargin: 0
555
655
  }) });
556
- const w = () => {
557
- P.style.scrollBehavior = "", $(A), Fe(f.current, D.startLine, D.endLine);
656
+ const u = () => {
657
+ R.style.scrollBehavior = "", q(G), Fe(c.current, P.startLine, P.endLine);
558
658
  };
559
- let v;
560
- const x = () => {
561
- clearTimeout(v), v = setTimeout(w, 100);
659
+ let m;
660
+ const S = () => {
661
+ clearTimeout(m), m = setTimeout(u, 100);
562
662
  };
563
- P.addEventListener("scroll", x), v = setTimeout(() => {
564
- P.removeEventListener("scroll", x), w();
663
+ R.addEventListener("scroll", S), m = setTimeout(() => {
664
+ R.removeEventListener("scroll", S), u();
565
665
  }, 800);
566
666
  }, 120);
567
- return () => clearTimeout(I);
568
- }, [s, r]);
569
- const t = T((g) => {
570
- a(g);
667
+ return () => clearTimeout(b);
668
+ }, [d, r]);
669
+ const s = A((v) => {
670
+ a(v);
571
671
  try {
572
- const I = JSON.parse(g);
573
- I && Array.isArray(I.nodes) && Array.isArray(I.edges) && Array.isArray(I.lines) ? (e(null), m.current = !0, n((D) => ({
574
- ...D,
672
+ const b = JSON.parse(v);
673
+ b && Array.isArray(b.nodes) && Array.isArray(b.edges) && Array.isArray(b.lines) ? (e(null), t.current = !0, n((P) => ({
674
+ ...P,
575
675
  canvases: {
576
- ...D.canvases,
577
- [u]: I
676
+ ...P.canvases,
677
+ [p]: b
578
678
  }
579
679
  }))) : e("JSON must have nodes, edges, lines arrays");
580
- } catch (I) {
581
- e(I.message?.slice(0, 60) ?? "Invalid JSON");
680
+ } catch (b) {
681
+ e(b.message?.slice(0, 60) ?? "Invalid JSON");
582
682
  }
583
- }, [n, u]), S = s ? o.nodeIds.has(s) ? "Node" : o.edgeIds.has(s) ? "Edge" : "Line" : null;
584
- return /* @__PURE__ */ U("div", {
683
+ }, [n, p]), M = d ? l.nodeIds.has(d) ? "Node" : l.edgeIds.has(d) ? "Edge" : "Line" : null;
684
+ return /* @__PURE__ */ Z("div", {
585
685
  style: {
586
686
  display: "flex",
587
687
  flexDirection: "column",
@@ -589,32 +689,32 @@ function Oe() {
589
689
  minHeight: 0
590
690
  },
591
691
  children: [
592
- /* @__PURE__ */ p("div", {
692
+ /* @__PURE__ */ w("div", {
593
693
  className: "flow-json-header",
594
- children: /* @__PURE__ */ p("span", {
694
+ children: /* @__PURE__ */ w("span", {
595
695
  className: "flow-json-scope",
596
- children: S ? `${S}: ${s.slice(0, 8)}` : "Canvas"
696
+ children: M ? `${M}: ${d.slice(0, 8)}` : "Canvas"
597
697
  })
598
698
  }),
599
- c && /* @__PURE__ */ p("div", {
699
+ f && /* @__PURE__ */ w("div", {
600
700
  style: {
601
701
  fontSize: 11,
602
702
  color: "oklch(var(--er))",
603
703
  padding: "4px 0",
604
704
  flexShrink: 0
605
705
  },
606
- children: c
706
+ children: f
607
707
  }),
608
- /* @__PURE__ */ p("div", {
609
- ref: b,
708
+ /* @__PURE__ */ w("div", {
709
+ ref: I,
610
710
  style: {
611
711
  flex: 1,
612
712
  minHeight: 0
613
713
  },
614
- children: /* @__PURE__ */ p(se, {
615
- ref: f,
714
+ children: /* @__PURE__ */ w(oe, {
715
+ ref: c,
616
716
  value: r,
617
- onChange: t,
717
+ onChange: s,
618
718
  language: "json",
619
719
  lineNumbers: !1,
620
720
  height: "100%",
@@ -624,98 +724,98 @@ function Oe() {
624
724
  ]
625
725
  });
626
726
  }
627
- function Ke() {
628
- const { contextMenu: n, setContextMenu: u } = J(), { doc: o, setDoc: h, currentCanvasId: r, pushCanvas: a, setSelection: c } = B();
727
+ function We() {
728
+ const { contextMenu: n, setContextMenu: p } = J(), { doc: l, setDoc: g, currentCanvasId: r, pushCanvas: a, setSelection: f } = Y();
629
729
  if (!n) return null;
630
- const e = o.canvases[r];
730
+ const e = l.canvases[r];
631
731
  if (!e)
632
- return u(null), null;
633
- const m = n.nodeId ? e.nodes.find((b) => b.id === n.nodeId) : null, f = [];
634
- return m && (m.data.childCanvasId ? (f.push({
732
+ return p(null), null;
733
+ const t = n.nodeId ? e.nodes.find((I) => I.id === n.nodeId) : null, c = [];
734
+ return t && (t.data.childCanvasId ? (c.push({
635
735
  label: "Enter Sub-canvas",
636
736
  icon: "↓",
637
737
  action: () => {
638
- a(m.data.childCanvasId), c({
738
+ a(t.data.childCanvasId), f({
639
739
  nodeIds: /* @__PURE__ */ new Set(),
640
740
  edgeIds: /* @__PURE__ */ new Set(),
641
741
  lineIds: /* @__PURE__ */ new Set()
642
742
  });
643
743
  }
644
- }), f.push({
744
+ }), c.push({
645
745
  label: "---",
646
746
  action: () => {
647
747
  }
648
- }), f.push({
748
+ }), c.push({
649
749
  label: "Delete Sub-canvas",
650
750
  icon: "🗑",
651
751
  danger: !0,
652
752
  action: () => {
653
- const b = m.data.childCanvasId;
654
- h((s) => {
655
- const t = { ...s.canvases };
656
- ee(t, b);
657
- const S = t[r];
658
- if (!S) return s;
659
- t[r] = {
660
- ...S,
661
- nodes: S.nodes.map((I) => I.id === m.id ? {
662
- ...I,
753
+ const I = t.data.childCanvasId;
754
+ g((d) => {
755
+ const s = { ...d.canvases };
756
+ ne(s, I);
757
+ const M = s[r];
758
+ if (!M) return d;
759
+ s[r] = {
760
+ ...M,
761
+ nodes: M.nodes.map((b) => b.id === t.id ? {
762
+ ...b,
663
763
  data: {
664
- ...I.data,
764
+ ...b.data,
665
765
  childCanvasId: void 0
666
766
  }
667
- } : I)
767
+ } : b)
668
768
  };
669
- const g = s.stack.filter((I) => t[I]);
670
- return g.length === 0 && g.push(re), {
671
- ...s,
672
- canvases: t,
673
- stack: g
769
+ const v = d.stack.filter((b) => s[b]);
770
+ return v.length === 0 && v.push(re), {
771
+ ...d,
772
+ canvases: s,
773
+ stack: v
674
774
  };
675
775
  });
676
776
  }
677
- })) : f.push({
777
+ })) : c.push({
678
778
  label: "Create Sub-canvas",
679
779
  icon: "⊞",
680
780
  action: () => {
681
- const b = X("canvas");
682
- h((s) => {
683
- const t = s.canvases[r];
684
- return t ? {
685
- ...s,
781
+ const I = X("canvas");
782
+ g((d) => {
783
+ const s = d.canvases[r];
784
+ return s ? {
785
+ ...d,
686
786
  canvases: {
687
- ...s.canvases,
787
+ ...d.canvases,
688
788
  [r]: {
689
- ...t,
690
- nodes: t.nodes.map((S) => S.id === m.id ? {
691
- ...S,
789
+ ...s,
790
+ nodes: s.nodes.map((M) => M.id === t.id ? {
791
+ ...M,
692
792
  data: {
693
- ...S.data,
694
- childCanvasId: b
793
+ ...M.data,
794
+ childCanvasId: I
695
795
  }
696
- } : S)
796
+ } : M)
697
797
  },
698
- [b]: {
798
+ [I]: {
699
799
  nodes: [],
700
800
  edges: [],
701
801
  lines: []
702
802
  }
703
803
  }
704
- } : s;
705
- }), a(b);
804
+ } : d;
805
+ }), a(I);
706
806
  }
707
- })), f.length === 0 ? null : /* @__PURE__ */ p(ye, {
807
+ })), c.length === 0 ? null : /* @__PURE__ */ w(ye, {
708
808
  x: n.x,
709
809
  y: n.y,
710
- items: f,
711
- onClose: () => u(null)
810
+ items: c,
811
+ onClose: () => p(null)
712
812
  });
713
813
  }
714
- function ee(n, u) {
715
- const o = n[u];
716
- if (o) {
717
- for (const h of o.nodes) h.data.childCanvasId && ee(n, h.data.childCanvasId);
718
- delete n[u];
814
+ function ne(n, p) {
815
+ const l = n[p];
816
+ if (l) {
817
+ for (const g of l.nodes) g.data.childCanvasId && ne(n, g.data.childCanvasId);
818
+ delete n[p];
719
819
  }
720
820
  }
721
821
  export {