dishui 0.0.64 → 0.0.65

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 (177) hide show
  1. package/dist/components/Badge/index.js +12 -9
  2. package/dist/components/Badge/index.js.map +1 -1
  3. package/dist/components/Button/index.js +43 -40
  4. package/dist/components/Button/index.js.map +1 -1
  5. package/dist/components/Card/index.d.ts +11 -0
  6. package/dist/components/Card/index.js +62 -37
  7. package/dist/components/Card/index.js.map +1 -1
  8. package/dist/components/Chart/Chart.js.map +1 -1
  9. package/dist/components/Checkbox/index.js +32 -30
  10. package/dist/components/Checkbox/index.js.map +1 -1
  11. package/dist/components/Demo/index.js.map +1 -1
  12. package/dist/components/EmptyState/index.d.ts +4 -1
  13. package/dist/components/EmptyState/index.js +3 -3
  14. package/dist/components/EmptyState/index.js.map +1 -1
  15. package/dist/components/FileUploader/DropZone.js.map +1 -1
  16. package/dist/components/FileUploader/FileItem.js.map +1 -1
  17. package/dist/components/FileUploader/FileUploader.js.map +1 -1
  18. package/dist/components/FileUploader/UploadQueue.js.map +1 -1
  19. package/dist/components/Input/index.js +30 -30
  20. package/dist/components/Input/index.js.map +1 -1
  21. package/dist/components/Label/index.js +41 -40
  22. package/dist/components/Label/index.js.map +1 -1
  23. package/dist/components/List/index.js +47 -32
  24. package/dist/components/List/index.js.map +1 -1
  25. package/dist/components/Markdown/Markdown.js +61 -57
  26. package/dist/components/Markdown/Markdown.js.map +1 -1
  27. package/dist/components/Markdown/markdownComponents.js +49 -49
  28. package/dist/components/Markdown/markdownComponents.js.map +1 -1
  29. package/dist/components/Modal/index.d.ts +7 -3
  30. package/dist/components/Modal/index.js +77 -65
  31. package/dist/components/Modal/index.js.map +1 -1
  32. package/dist/components/Page/index.d.ts +58 -0
  33. package/dist/components/Page/index.js +74 -0
  34. package/dist/components/Page/index.js.map +1 -0
  35. package/dist/components/PageHeader/index.js.map +1 -1
  36. package/dist/components/Select/index.js +0 -3
  37. package/dist/components/Select/index.js.map +1 -1
  38. package/dist/components/SidebarToggleButton/index.js.map +1 -1
  39. package/dist/components/StatCard/index.d.ts +3 -1
  40. package/dist/components/StatCard/index.js +39 -11
  41. package/dist/components/StatCard/index.js.map +1 -1
  42. package/dist/components/Table/index.js +103 -85
  43. package/dist/components/Table/index.js.map +1 -1
  44. package/dist/components/Tabs/index.d.ts +19 -5
  45. package/dist/components/Tabs/index.js +32 -13
  46. package/dist/components/Tabs/index.js.map +1 -1
  47. package/dist/components/Tree/Tree.js.map +1 -1
  48. package/dist/components/pro/ArticleContextMenu/index.js.map +1 -1
  49. package/dist/components/pro/ArticleControl/ArticleControl2.js.map +1 -1
  50. package/dist/components/pro/CodeEditor/editors/CodeEditor.js +141 -134
  51. package/dist/components/pro/CodeEditor/editors/CodeEditor.js.map +1 -1
  52. package/dist/components/pro/CodeEditor/editors/MarkdownEditor.js +81 -78
  53. package/dist/components/pro/CodeEditor/editors/MarkdownEditor.js.map +1 -1
  54. package/dist/components/pro/CodeEditor/panels/FootnotePanel.js.map +1 -1
  55. package/dist/components/pro/CodeEditor/panels/HistoryPanel.js.map +1 -1
  56. package/dist/components/pro/CodeEditor/panels/OutlinePanel.js.map +1 -1
  57. package/dist/components/pro/CodeEditor/panels/TableOfContentsPanel.js.map +1 -1
  58. package/dist/components/pro/CodeEditor/panels/VariablePanel.js.map +1 -1
  59. package/dist/components/pro/CodeEditor/themes.js +59 -59
  60. package/dist/components/pro/CodeEditor/themes.js.map +1 -1
  61. package/dist/components/pro/DataTable/DataTable.js +49 -48
  62. package/dist/components/pro/DataTable/DataTable.js.map +1 -1
  63. package/dist/components/pro/DataTable/Filters.js +42 -42
  64. package/dist/components/pro/DataTable/Filters.js.map +1 -1
  65. package/dist/components/pro/DataTable/PivotPanel.js.map +1 -1
  66. package/dist/components/pro/DataTable/PivotView.js +35 -32
  67. package/dist/components/pro/DataTable/PivotView.js.map +1 -1
  68. package/dist/components/pro/DataTable/components/BulkActions.js.map +1 -1
  69. package/dist/components/pro/DataTable/components/ColumnSelector.js.map +1 -1
  70. package/dist/components/pro/DataTable/components/FilterBar.js.map +1 -1
  71. package/dist/components/pro/DataTable/components/TableBody.js.map +1 -1
  72. package/dist/components/pro/DataTable/components/TableHeader.js.map +1 -1
  73. package/dist/components/pro/DataTable/components/TablePagination.js.map +1 -1
  74. package/dist/components/pro/DataTable/components/TableToolbar.js.map +1 -1
  75. package/dist/components/pro/DataTable/pivotExtension.js.map +1 -1
  76. package/dist/components/pro/DataTable/rowDetailExtension.js.map +1 -1
  77. package/dist/components/pro/DataTable/tanstack-table.js +37 -37
  78. package/dist/components/pro/DataTable/tanstack-table.js.map +1 -1
  79. package/dist/components/pro/FileExplorer/Breadcrumb.js +53 -53
  80. package/dist/components/pro/FileExplorer/Breadcrumb.js.map +1 -1
  81. package/dist/components/pro/FileExplorer/CreateDialog.js.map +1 -1
  82. package/dist/components/pro/FileExplorer/FileExplorer.js.map +1 -1
  83. package/dist/components/pro/FileExplorer/FileIcon.js +22 -22
  84. package/dist/components/pro/FileExplorer/FileIcon.js.map +1 -1
  85. package/dist/components/pro/FileExplorer/GridView.js.map +1 -1
  86. package/dist/components/pro/FileExplorer/ListView.js.map +1 -1
  87. package/dist/components/pro/FileExplorer/Toolbar.js.map +1 -1
  88. package/dist/components/pro/Flow/Flow.js +496 -494
  89. package/dist/components/pro/Flow/Flow.js.map +1 -1
  90. package/dist/components/pro/Flow/FlowCanvas.js +916 -917
  91. package/dist/components/pro/Flow/FlowCanvas.js.map +1 -1
  92. package/dist/components/pro/Flow/context/FlowUIContext.js.map +1 -1
  93. package/dist/components/pro/Flow/edges/EdgeRenderer.js +59 -59
  94. package/dist/components/pro/Flow/edges/EdgeRenderer.js.map +1 -1
  95. package/dist/components/pro/Flow/hooks/useClipboard.js.map +1 -1
  96. package/dist/components/pro/Flow/hooks/useDeleteSelection.js.map +1 -1
  97. package/dist/components/pro/Flow/hooks/useEdgeMutations.js.map +1 -1
  98. package/dist/components/pro/Flow/hooks/useLayoutActions.js +9 -11
  99. package/dist/components/pro/Flow/hooks/useLayoutActions.js.map +1 -1
  100. package/dist/components/pro/Flow/hooks/useLineMutations.js.map +1 -1
  101. package/dist/components/pro/Flow/hooks/useMindMap.js.map +1 -1
  102. package/dist/components/pro/Flow/hooks/useNodeMutations.js.map +1 -1
  103. package/dist/components/pro/Flow/lines/FreehandTool.js +9 -9
  104. package/dist/components/pro/Flow/lines/FreehandTool.js.map +1 -1
  105. package/dist/components/pro/Flow/lines/LineRenderer.js +5 -5
  106. package/dist/components/pro/Flow/lines/LineRenderer.js.map +1 -1
  107. package/dist/components/pro/Flow/nodes/DataNodeView.js +113 -93
  108. package/dist/components/pro/Flow/nodes/DataNodeView.js.map +1 -1
  109. package/dist/components/pro/Flow/nodes/MediaContent.js.map +1 -1
  110. package/dist/components/pro/Flow/nodes/MediaOverlay.js.map +1 -1
  111. package/dist/components/pro/Flow/nodes/Model3DView.js +1 -1
  112. package/dist/components/pro/Flow/nodes/Model3DView.js.map +1 -1
  113. package/dist/components/pro/Flow/nodes/NodeRenderer.js +118 -118
  114. package/dist/components/pro/Flow/nodes/NodeRenderer.js.map +1 -1
  115. package/dist/components/pro/Flow/nodes/dataUtils.js.map +1 -1
  116. package/dist/components/pro/Flow/nodes/shapes.js +1 -3
  117. package/dist/components/pro/Flow/nodes/shapes.js.map +1 -1
  118. package/dist/components/pro/Flow/panels/AIPanel.js.map +1 -1
  119. package/dist/components/pro/Flow/panels/Breadcrumb.js.map +1 -1
  120. package/dist/components/pro/Flow/panels/ContextMenu.js.map +1 -1
  121. package/dist/components/pro/Flow/panels/DataInspectorSection.js.map +1 -1
  122. package/dist/components/pro/Flow/panels/ExpandableTextarea.js.map +1 -1
  123. package/dist/components/pro/Flow/panels/FlowPanelGroup.js.map +1 -1
  124. package/dist/components/pro/Flow/panels/FlowToolbar.js +97 -97
  125. package/dist/components/pro/Flow/panels/FlowToolbar.js.map +1 -1
  126. package/dist/components/pro/Flow/panels/InspectorPanel.js +57 -57
  127. package/dist/components/pro/Flow/panels/InspectorPanel.js.map +1 -1
  128. package/dist/components/pro/Flow/panels/OutlinePanel.js +26 -22
  129. package/dist/components/pro/Flow/panels/OutlinePanel.js.map +1 -1
  130. package/dist/components/pro/Flow/panels/PresentationMode.js +18 -16
  131. package/dist/components/pro/Flow/panels/PresentationMode.js.map +1 -1
  132. package/dist/components/pro/Flow/panels/ProjectTitle.js.map +1 -1
  133. package/dist/components/pro/Flow/panels/ShapePalette.js +109 -104
  134. package/dist/components/pro/Flow/panels/ShapePalette.js.map +1 -1
  135. package/dist/components/pro/Flow/panels/toolbarIcons.js.map +1 -1
  136. package/dist/components/pro/RichTextEditor/AIRewrite.js.map +1 -1
  137. package/dist/components/pro/RichTextEditor/BlockHandle.js.map +1 -1
  138. package/dist/components/pro/RichTextEditor/BubbleToolbar.js.map +1 -1
  139. package/dist/components/pro/RichTextEditor/CommentDialog.js.map +1 -1
  140. package/dist/components/pro/RichTextEditor/CommentPanel.js.map +1 -1
  141. package/dist/components/pro/RichTextEditor/CommentPopover.js.map +1 -1
  142. package/dist/components/pro/RichTextEditor/ContextMenu.js.map +1 -1
  143. package/dist/components/pro/RichTextEditor/RichTextEditor.js.map +1 -1
  144. package/dist/components/pro/RichTextEditor/SlashMenu.js.map +1 -1
  145. package/dist/components/pro/RichTextEditor/Toolbar/ColorPicker.js.map +1 -1
  146. package/dist/components/pro/RichTextEditor/Toolbar/FloatingDialogMenu.js.map +1 -1
  147. package/dist/components/pro/RichTextEditor/Toolbar/MarkdownTemplates.js.map +1 -1
  148. package/dist/components/pro/RichTextEditor/Toolbar/SelectDropdown.js.map +1 -1
  149. package/dist/components/pro/RichTextEditor/Toolbar/TableOpsMenu.js.map +1 -1
  150. package/dist/components/pro/RichTextEditor/Toolbar/Toolbar.js.map +1 -1
  151. package/dist/components/pro/RichTextEditor/extensions/CodeBlockView.js.map +1 -1
  152. package/dist/components/pro/RichTextEditor/extensions/FloatingDialog.js.map +1 -1
  153. package/dist/components/pro/RichTextEditor/extensions/MarkdownBlock.js.map +1 -1
  154. package/dist/contexts/AppContext.js.map +1 -1
  155. package/dist/dishui.css +1 -1
  156. package/dist/hooks/useTableColumns.js +7 -8
  157. package/dist/hooks/useTableColumns.js.map +1 -1
  158. package/dist/index.d.ts +2 -0
  159. package/dist/index.js +227 -221
  160. package/dist/layouts/MainLayout.js +22 -22
  161. package/dist/layouts/MainLayout.js.map +1 -1
  162. package/dist/layouts/Navbar.js.map +1 -1
  163. package/dist/layouts/Sidebar.js +94 -73
  164. package/dist/layouts/Sidebar.js.map +1 -1
  165. package/dist/layouts/headbar/Headbar.js.map +1 -1
  166. package/dist/layouts/headbar/HeadbarLangSwitcher.js.map +1 -1
  167. package/dist/layouts/headbar/HeadbarSearch.js.map +1 -1
  168. package/dist/layouts/headbar/HeadbarThemeSwitcher.js +11 -11
  169. package/dist/layouts/headbar/HeadbarThemeSwitcher.js.map +1 -1
  170. package/dist/layouts/headbar/HeadbarTitle.js.map +1 -1
  171. package/dist/utils/i18n.js +10 -10
  172. package/dist/utils/i18n.js.map +1 -1
  173. package/dist/utils/menu.js.map +1 -1
  174. package/dist/utils/routerBuilder.js +17 -15
  175. package/dist/utils/routerBuilder.js.map +1 -1
  176. package/dist/utils/themes.js.map +1 -1
  177. package/package.json +7 -7
@@ -1,10 +1,10 @@
1
1
  import he from "../../Select/index.js";
2
2
  import ge from "../CodeEditor/editors/CodeEditor.js";
3
- import { DEFAULT_NODE_DATA as se, ROOT_CANVAS_ID as we, createEmptyDocument as Ie } from "./constants.js";
4
- import { FlowProvider as ve, useFlowContext as ee } from "./context/FlowContext.js";
5
- import { FlowUIProvider as ye, useFlowUI as Y } from "./context/FlowUIContext.js";
3
+ import { DEFAULT_NODE_DATA as ie, ROOT_CANVAS_ID as we, createEmptyDocument as Ie } from "./constants.js";
4
+ import { FlowProvider as ve, useFlowContext as te } from "./context/FlowContext.js";
5
+ import { FlowUIProvider as ye, useFlowUI as q } from "./context/FlowUIContext.js";
6
6
  import { FlowAIProvider as be } from "./context/FlowAIContext.js";
7
- import { generateId as Q } from "./nodes/nodeUtils.js";
7
+ import { generateId as ee } from "./nodes/nodeUtils.js";
8
8
  import { normalizeEdgeHandles as xe } from "./edges/edgePaths.js";
9
9
  import { useDeleteSelection as Se } from "./hooks/useDeleteSelection.js";
10
10
  import Ce from "./FlowCanvas.js";
@@ -16,54 +16,54 @@ import { OutlinePanelContent as Te } from "./panels/OutlinePanel.js";
16
16
  import { AIPanelContent as Re } from "./panels/AIPanel.js";
17
17
  import { PresentationMode as Le } from "./panels/PresentationMode.js";
18
18
  import { MediaOverlay as Fe } from "./nodes/MediaOverlay.js";
19
- import q from "./panels/FlowPanelGroup.js";
19
+ import Q from "./panels/FlowPanelGroup.js";
20
20
  import Ge from "./panels/Breadcrumb.js";
21
21
  import Ke from "./panels/ContextMenu.js";
22
22
  import { MiniMapRenderer as We } from "./canvas/MiniMapRenderer.js";
23
23
  import { useUndoRedo as He } from "./hooks/useUndoRedo.js";
24
- import { useClipboard as ae } from "./hooks/useClipboard.js";
24
+ import { useClipboard as le } from "./hooks/useClipboard.js";
25
25
  import { useCompactMode as Ue } from "./hooks/useCompactMode.js";
26
26
  import { usePdfExport as Ze } from "./hooks/usePdfExport.js";
27
27
  import { useKeyboardShortcuts as Je } from "./hooks/useKeyboardShortcuts.js";
28
28
  import { useMindMap as Oe } from "./hooks/useMindMap.js";
29
29
  /* empty css */
30
- import { forwardRef as _e, useCallback as E, useEffect as X, useImperativeHandle as $e, useMemo as le, useRef as F, useState as j } from "react";
31
- import { jsx as r, jsxs as _ } from "react/jsx-runtime";
30
+ import { forwardRef as _e, useCallback as k, useEffect as Y, useImperativeHandle as $e, useMemo as ce, useRef as F, useState as X } from "react";
31
+ import { jsx as i, jsxs as $ } from "react/jsx-runtime";
32
32
  import { EditorView as Be } from "@codemirror/view";
33
33
  function Ve(o) {
34
- let p = !1;
35
- const a = { ...o.canvases };
36
- for (const [v, u] of Object.entries(a)) {
37
- const s = u.nodes.map((e) => {
34
+ let u = !1;
35
+ const r = { ...o.canvases };
36
+ for (const [w, d] of Object.entries(r)) {
37
+ const s = d.nodes.map((e) => {
38
38
  if (e.type !== "shapeSvg") return e;
39
- const I = e.data.labelPlacement, m = I === "above" ? "top" : I === "center" ? "middle" : I === "below" ? "bottom" : e.data.labelPlacement;
40
- return m === e.data.labelPlacement ? e : (p = !0, {
39
+ const g = e.data.labelPlacement, f = g === "above" ? "top" : g === "center" ? "middle" : g === "below" ? "bottom" : e.data.labelPlacement;
40
+ return f === e.data.labelPlacement ? e : (u = !0, {
41
41
  ...e,
42
42
  data: {
43
43
  ...e.data,
44
- labelPlacement: m
44
+ labelPlacement: f
45
45
  }
46
46
  });
47
47
  });
48
- let l = !1;
48
+ let a = !1;
49
49
  const n = s.map((e) => {
50
50
  if (!e.data.isMindMapNode) return e;
51
- const I = e.data.fill === "#ffffff" || e.data.fill === "#eef2ff" ? "theme:base-100" : e.data.fill, m = e.data.stroke === "#6366f1" ? "theme:base-content" : e.data.stroke === "#4f46e5" ? "theme:primary" : e.data.stroke;
52
- return I === e.data.fill && m === e.data.stroke ? e : (l = !0, {
51
+ const g = e.data.fill === "#ffffff" || e.data.fill === "#eef2ff" ? "theme:base-100" : e.data.fill, f = e.data.stroke === "#6366f1" ? "theme:base-content" : e.data.stroke === "#4f46e5" ? "theme:primary" : e.data.stroke;
52
+ return g === e.data.fill && f === e.data.stroke ? e : (a = !0, {
53
53
  ...e,
54
54
  data: {
55
55
  ...e.data,
56
- fill: I,
57
- stroke: m
56
+ fill: g,
57
+ stroke: f
58
58
  }
59
59
  });
60
- }), b = /* @__PURE__ */ new Map();
61
- for (const e of n) b.set(e.id, e);
60
+ }), v = /* @__PURE__ */ new Map();
61
+ for (const e of n) v.set(e.id, e);
62
62
  let c = !1;
63
- const y = xe(u.edges, b).map((e) => {
63
+ const I = xe(d.edges, v).map((e) => {
64
64
  if (e.data.strokeColor !== "#94a3b8") return e;
65
- const I = b.get(e.source), m = b.get(e.target);
66
- return !I?.data.isMindMapNode || !m?.data.isMindMapNode ? e : (c = !0, {
65
+ const g = v.get(e.source), f = v.get(e.target);
66
+ return !g?.data.isMindMapNode || !f?.data.isMindMapNode ? e : (c = !0, {
67
67
  ...e,
68
68
  data: {
69
69
  ...e.data,
@@ -71,15 +71,15 @@ function Ve(o) {
71
71
  }
72
72
  });
73
73
  });
74
- (l || c) && (p = !0), (n !== s || y !== u.edges) && (a[v] = {
75
- ...u,
74
+ (a || c) && (u = !0), (n !== s || I !== d.edges) && (r[w] = {
75
+ ...d,
76
76
  nodes: n,
77
- edges: y
77
+ edges: I
78
78
  });
79
79
  }
80
- return p ? {
80
+ return u ? {
81
81
  ...o,
82
- canvases: a
82
+ canvases: r
83
83
  } : o;
84
84
  }
85
85
  var je = {
@@ -87,192 +87,192 @@ var je = {
87
87
  edgeIds: /* @__PURE__ */ new Set(),
88
88
  lineIds: /* @__PURE__ */ new Set()
89
89
  };
90
- function Xe({ onUndo: o, onRedo: p, groupRef: a, geoGroupRef: v, ungroupRef: u }) {
91
- const { selection: s, setSelection: l, currentCanvas: n, setDoc: b, currentCanvasId: c } = ee(), { viewport: y } = Y(), { copy: e, cut: I, paste: m, duplicate: h } = ae(), x = Se(), g = E(() => {
92
- l({
93
- nodeIds: new Set(n.nodes.map((f) => f.id)),
94
- edgeIds: new Set(n.edges.map((f) => f.id)),
95
- lineIds: new Set(n.lines.map((f) => f.id))
90
+ function Xe({ onUndo: o, onRedo: u, groupRef: r, geoGroupRef: w, ungroupRef: d }) {
91
+ const { selection: s, setSelection: a, currentCanvas: n, setDoc: v, currentCanvasId: c } = te(), { viewport: I } = q(), { copy: e, cut: g, paste: f, duplicate: m } = le(), b = Se(), h = k(() => {
92
+ a({
93
+ nodeIds: new Set(n.nodes.map((p) => p.id)),
94
+ edgeIds: new Set(n.edges.map((p) => p.id)),
95
+ lineIds: new Set(n.lines.map((p) => p.id))
96
96
  });
97
- }, [n, l]), S = E((f) => {
98
- const w = s.nodeIds, N = s.lineIds;
99
- if (w.size + N.size < 2) return;
100
- const k = n.nodes.filter((M) => w.has(M.id)), d = n.lines.filter((M) => N.has(M.id)), t = 20;
101
- let i = 1 / 0, R = 1 / 0, L = -1 / 0, W = -1 / 0;
102
- for (const M of k)
103
- i = Math.min(i, M.position.x), R = Math.min(R, M.position.y), L = Math.max(L, M.position.x + M.width), W = Math.max(W, M.position.y + M.height);
104
- for (const M of d) for (const D of M.points)
105
- i = Math.min(i, D.x), R = Math.min(R, D.y), L = Math.max(L, D.x), W = Math.max(W, D.y);
106
- const H = f === "geometryGroup", U = Q("group"), P = {
107
- id: U,
108
- type: f,
97
+ }, [n, a]), C = k((p) => {
98
+ const x = s.nodeIds, N = s.lineIds;
99
+ if (x.size + N.size < 2) return;
100
+ const D = n.nodes.filter((S) => x.has(S.id)), t = n.lines.filter((S) => N.has(S.id)), l = 20;
101
+ let y = 1 / 0, W = 1 / 0, R = -1 / 0, H = -1 / 0;
102
+ for (const S of D)
103
+ y = Math.min(y, S.position.x), W = Math.min(W, S.position.y), R = Math.max(R, S.position.x + S.width), H = Math.max(H, S.position.y + S.height);
104
+ for (const S of t) for (const z of S.points)
105
+ y = Math.min(y, z.x), W = Math.min(W, z.y), R = Math.max(R, z.x), H = Math.max(H, z.y);
106
+ const U = p === "geometryGroup", Z = ee("group"), M = {
107
+ id: Z,
108
+ type: p,
109
109
  position: {
110
- x: i - t,
111
- y: R - t
110
+ x: y - l,
111
+ y: W - l
112
112
  },
113
- width: L - i + t * 2,
114
- height: W - R + t * 2,
113
+ width: R - y + 40,
114
+ height: H - W + 40,
115
115
  data: {
116
- ...se,
117
- label: H ? "Geo Group" : "Group",
118
- fill: H ? "#fefce8" : "#f0f9ff",
116
+ ...ie,
117
+ label: U ? "Geo Group" : "Group",
118
+ fill: U ? "#fefce8" : "#f0f9ff",
119
119
  stroke: "#9ca3af",
120
120
  strokeWidth: 1.5,
121
- borderStyle: H ? "dashed" : "dotted",
121
+ borderStyle: U ? "dashed" : "dotted",
122
122
  isGroup: !0
123
123
  }
124
124
  };
125
- b((M) => {
126
- const D = M.canvases[c];
127
- return D ? {
128
- ...M,
125
+ v((S) => {
126
+ const z = S.canvases[c];
127
+ return z ? {
128
+ ...S,
129
129
  canvases: {
130
- ...M.canvases,
130
+ ...S.canvases,
131
131
  [c]: {
132
- ...D,
133
- nodes: H ? [P, ...D.nodes] : [P, ...D.nodes.map((O) => w.has(O.id) ? {
134
- ...O,
135
- parentId: U
136
- } : O)],
137
- lines: H ? D.lines : D.lines.map((O) => N.has(O.id) ? {
138
- ...O,
139
- parentId: U
140
- } : O)
132
+ ...z,
133
+ nodes: U ? [M, ...z.nodes] : [M, ...z.nodes.map((J) => x.has(J.id) ? {
134
+ ...J,
135
+ parentId: Z
136
+ } : J)],
137
+ lines: U ? z.lines : z.lines.map((J) => N.has(J.id) ? {
138
+ ...J,
139
+ parentId: Z
140
+ } : J)
141
141
  }
142
142
  }
143
- } : M;
144
- }), l({
145
- nodeIds: /* @__PURE__ */ new Set([U]),
143
+ } : S;
144
+ }), a({
145
+ nodeIds: /* @__PURE__ */ new Set([Z]),
146
146
  edgeIds: /* @__PURE__ */ new Set(),
147
147
  lineIds: /* @__PURE__ */ new Set()
148
148
  });
149
149
  }, [
150
150
  s,
151
151
  n,
152
- b,
152
+ v,
153
153
  c,
154
- l
155
- ]), K = E(() => S("flowGroup"), [S]), z = E(() => S("geometryGroup"), [S]), J = E(() => {
156
- const f = s.nodeIds;
157
- if (f.size === 0) return;
158
- const w = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Set(), k = /* @__PURE__ */ new Set();
159
- for (const d of n.nodes) f.has(d.id) && (d.type === "flowGroup" || d.type === "geometryGroup" || d.data.isGroup) && w.add(d.id);
160
- if (w.size !== 0) {
161
- for (const d of n.nodes) d.parentId && w.has(d.parentId) && N.add(d.id);
162
- for (const d of n.lines) d.parentId && w.has(d.parentId) && k.add(d.id);
163
- b((d) => {
164
- const t = d.canvases[c];
165
- return t ? {
166
- ...d,
154
+ a
155
+ ]), K = k(() => C("flowGroup"), [C]), T = k(() => C("geometryGroup"), [C]), _ = k(() => {
156
+ const p = s.nodeIds;
157
+ if (p.size === 0) return;
158
+ const x = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Set(), D = /* @__PURE__ */ new Set();
159
+ for (const t of n.nodes) p.has(t.id) && (t.type === "flowGroup" || t.type === "geometryGroup" || t.data.isGroup) && x.add(t.id);
160
+ if (x.size !== 0) {
161
+ for (const t of n.nodes) t.parentId && x.has(t.parentId) && N.add(t.id);
162
+ for (const t of n.lines) t.parentId && x.has(t.parentId) && D.add(t.id);
163
+ v((t) => {
164
+ const l = t.canvases[c];
165
+ return l ? {
166
+ ...t,
167
167
  canvases: {
168
- ...d.canvases,
168
+ ...t.canvases,
169
169
  [c]: {
170
- ...t,
171
- nodes: t.nodes.filter((i) => !w.has(i.id)).map((i) => N.has(i.id) ? {
172
- ...i,
170
+ ...l,
171
+ nodes: l.nodes.filter((y) => !x.has(y.id)).map((y) => N.has(y.id) ? {
172
+ ...y,
173
173
  parentId: void 0
174
- } : i),
175
- lines: t.lines.map((i) => k.has(i.id) ? {
176
- ...i,
174
+ } : y),
175
+ lines: l.lines.map((y) => D.has(y.id) ? {
176
+ ...y,
177
177
  parentId: void 0
178
- } : i)
178
+ } : y)
179
179
  }
180
180
  }
181
- } : d;
182
- }), l({
181
+ } : t;
182
+ }), a({
183
183
  nodeIds: N,
184
184
  edgeIds: /* @__PURE__ */ new Set(),
185
- lineIds: k
185
+ lineIds: D
186
186
  });
187
187
  }
188
188
  }, [
189
189
  s,
190
190
  n,
191
- b,
191
+ v,
192
192
  c,
193
- l
193
+ a
194
194
  ]);
195
- a.current = K, v.current = z, u.current = J;
196
- const C = E((f) => {
197
- const w = s.nodeIds, N = s.lineIds;
198
- w.size === 0 && N.size === 0 || b((k) => {
199
- const d = k.canvases[c];
200
- if (!d) return k;
201
- const t = d.nodes.map((P) => P.zIndex ?? 0), i = t.length > 0 ? Math.max(...t) : 0, R = t.length > 0 ? Math.min(...t) : 0, L = d.lines.map((P) => P.zIndex ?? 0), W = L.length > 0 ? Math.max(...L) : 0, H = L.length > 0 ? Math.min(...L) : 0, U = (P, M, D) => f === "front" ? M + 1 : f === "back" ? D - 1 : f === "up" ? P + 1 : P - 1;
195
+ r.current = K, w.current = T, d.current = _;
196
+ const P = k((p) => {
197
+ const x = s.nodeIds, N = s.lineIds;
198
+ x.size === 0 && N.size === 0 || v((D) => {
199
+ const t = D.canvases[c];
200
+ if (!t) return D;
201
+ const l = t.nodes.map((M) => M.zIndex ?? 0), y = l.length > 0 ? Math.max(...l) : 0, W = l.length > 0 ? Math.min(...l) : 0, R = t.lines.map((M) => M.zIndex ?? 0), H = R.length > 0 ? Math.max(...R) : 0, U = R.length > 0 ? Math.min(...R) : 0, Z = (M, S, z) => p === "front" ? S + 1 : p === "back" ? z - 1 : p === "up" ? M + 1 : M - 1;
202
202
  return {
203
- ...k,
203
+ ...D,
204
204
  canvases: {
205
- ...k.canvases,
205
+ ...D.canvases,
206
206
  [c]: {
207
- ...d,
208
- nodes: d.nodes.map((P) => w.has(P.id) ? {
209
- ...P,
210
- zIndex: U(P.zIndex ?? 0, i, R)
211
- } : P),
212
- lines: d.lines.map((P) => N.has(P.id) ? {
213
- ...P,
214
- zIndex: U(P.zIndex ?? 0, W, H)
215
- } : P)
207
+ ...t,
208
+ nodes: t.nodes.map((M) => x.has(M.id) ? {
209
+ ...M,
210
+ zIndex: Z(M.zIndex ?? 0, y, W)
211
+ } : M),
212
+ lines: t.lines.map((M) => N.has(M.id) ? {
213
+ ...M,
214
+ zIndex: Z(M.zIndex ?? 0, H, U)
215
+ } : M)
216
216
  }
217
217
  }
218
218
  };
219
219
  });
220
220
  }, [
221
221
  s,
222
- b,
222
+ v,
223
223
  c
224
224
  ]);
225
- return X(() => {
226
- const f = (w) => {
227
- const N = w.target;
225
+ Y(() => {
226
+ const p = (x) => {
227
+ const N = x.target;
228
228
  if (N?.tagName === "INPUT" || N?.tagName === "TEXTAREA" || N?.isContentEditable) return;
229
- const k = Array.from(w.clipboardData?.items ?? []).find((i) => i.type.startsWith("image/"));
230
- if (!k) {
231
- w.preventDefault(), m();
229
+ const D = Array.from(x.clipboardData?.items ?? []).find((y) => y.type.startsWith("image/"));
230
+ if (!D) {
231
+ x.preventDefault(), f();
232
232
  return;
233
233
  }
234
- const d = k.getAsFile();
235
- if (!d) return;
236
- w.preventDefault();
237
- const t = new FileReader();
238
- t.onload = () => {
239
- if (typeof t.result != "string") return;
240
- const i = s.nodeIds.size === 1 ? n.nodes.find((A) => s.nodeIds.has(A.id) && A.type === "mediaNode" && A.data.mediaKind === "image") : void 0;
241
- if (i) {
242
- b((A) => {
243
- const $ = A.canvases[c];
244
- return $ ? {
245
- ...A,
234
+ const t = D.getAsFile();
235
+ if (!t) return;
236
+ x.preventDefault();
237
+ const l = new FileReader();
238
+ l.onload = () => {
239
+ if (typeof l.result != "string") return;
240
+ const y = s.nodeIds.size === 1 ? n.nodes.find((E) => s.nodeIds.has(E.id) && E.type === "mediaNode" && E.data.mediaKind === "image") : void 0;
241
+ if (y) {
242
+ v((E) => {
243
+ const B = E.canvases[c];
244
+ return B ? {
245
+ ...E,
246
246
  canvases: {
247
- ...A.canvases,
247
+ ...E.canvases,
248
248
  [c]: {
249
- ...$,
250
- nodes: $.nodes.map((V) => V.id === i.id ? {
251
- ...V,
249
+ ...B,
250
+ nodes: B.nodes.map((j) => j.id === y.id ? {
251
+ ...j,
252
252
  data: {
253
- ...V.data,
254
- mediaContent: t.result
253
+ ...j.data,
254
+ mediaContent: l.result
255
255
  }
256
- } : V)
256
+ } : j)
257
257
  }
258
258
  }
259
- } : A;
259
+ } : E;
260
260
  });
261
261
  return;
262
262
  }
263
- const R = Q("node"), L = 320, W = 220, H = window.innerWidth, U = window.innerHeight, P = (H / 2 - y.x) / y.zoom, M = (U / 2 - y.y) / y.zoom, D = Math.max(0, ...n.nodes.map((A) => A.zIndex ?? 0)), O = {
264
- id: R,
263
+ const W = ee("node"), R = 320, H = 220, U = window.innerWidth, Z = window.innerHeight, M = (U / 2 - I.x) / I.zoom, S = (Z / 2 - I.y) / I.zoom, z = Math.max(0, ...n.nodes.map((E) => E.zIndex ?? 0)), J = {
264
+ id: W,
265
265
  type: "mediaNode",
266
266
  position: {
267
- x: P - L / 2,
268
- y: M - W / 2
267
+ x: M - R / 2,
268
+ y: S - H / 2
269
269
  },
270
- width: L,
271
- height: W,
272
- zIndex: D + 1,
270
+ width: R,
271
+ height: H,
272
+ zIndex: z + 1,
273
273
  data: {
274
- ...se,
275
- label: d.name || "Image",
274
+ ...ie,
275
+ label: t.name || "Image",
276
276
  fill: "theme:base-100",
277
277
  stroke: "theme:base-content",
278
278
  strokeWidth: 1.5,
@@ -280,183 +280,185 @@ function Xe({ onUndo: o, onRedo: p, groupRef: a, geoGroupRef: v, ungroupRef: u }
280
280
  fontSize: 13,
281
281
  borderStyle: "solid",
282
282
  mediaKind: "image",
283
- mediaContent: t.result
283
+ mediaContent: l.result
284
284
  }
285
285
  };
286
- b((A) => {
287
- const $ = A.canvases[c];
288
- return $ ? {
289
- ...A,
286
+ v((E) => {
287
+ const B = E.canvases[c];
288
+ return B ? {
289
+ ...E,
290
290
  canvases: {
291
- ...A.canvases,
291
+ ...E.canvases,
292
292
  [c]: {
293
- ...$,
294
- nodes: [...$.nodes, O]
293
+ ...B,
294
+ nodes: [...B.nodes, J]
295
295
  }
296
296
  }
297
- } : A;
298
- }), l({
299
- nodeIds: /* @__PURE__ */ new Set([R]),
297
+ } : E;
298
+ }), a({
299
+ nodeIds: /* @__PURE__ */ new Set([W]),
300
300
  edgeIds: /* @__PURE__ */ new Set(),
301
301
  lineIds: /* @__PURE__ */ new Set()
302
302
  });
303
- }, t.readAsDataURL(d);
303
+ }, l.readAsDataURL(t);
304
304
  };
305
- return window.addEventListener("paste", f), () => window.removeEventListener("paste", f);
305
+ return window.addEventListener("paste", p), () => window.removeEventListener("paste", p);
306
306
  }, [
307
307
  n,
308
308
  c,
309
- m,
309
+ f,
310
310
  s,
311
- b,
312
- l,
313
- y
314
- ]), Je(le(() => ({
311
+ v,
312
+ a,
313
+ I
314
+ ]);
315
+ const A = ce(() => ({
315
316
  undo: o,
316
- redo: p,
317
+ redo: u,
317
318
  copy: e,
318
- cut: I,
319
- paste: m,
320
- duplicate: h,
321
- deleteSelected: x,
322
- selectAll: g,
319
+ cut: g,
320
+ paste: f,
321
+ duplicate: m,
322
+ deleteSelected: b,
323
+ selectAll: h,
323
324
  group: K,
324
- geoGroup: z,
325
- ungroup: J,
326
- bringToFront: () => C("front"),
327
- bringForward: () => C("up"),
328
- sendBackward: () => C("down"),
329
- sendToBack: () => C("back")
325
+ geoGroup: T,
326
+ ungroup: _,
327
+ bringToFront: () => P("front"),
328
+ bringForward: () => P("up"),
329
+ sendBackward: () => P("down"),
330
+ sendToBack: () => P("back")
330
331
  }), [
331
332
  o,
332
- p,
333
+ u,
333
334
  e,
334
- I,
335
+ g,
336
+ f,
335
337
  m,
338
+ b,
336
339
  h,
337
- x,
338
- g,
339
340
  K,
340
- z,
341
- J,
342
- C
343
- ])), Oe(), null;
341
+ T,
342
+ _,
343
+ P
344
+ ]);
345
+ return Je(A), Oe(), null;
344
346
  }
345
- function Ye({ pixiRef: o, exportPdfRef: p }) {
346
- return p.current = Ze(o), null;
347
+ function Ye({ pixiRef: o, exportPdfRef: u }) {
348
+ return u.current = Ze(o), null;
347
349
  }
348
- var Ht = _e(function({ initialDocument: p, onChange: a, width: v, height: u, readOnly: s = !1, onBack: l, onExportPNG: n, onPublish: b, showMiniMap: c = !0, showGrid: y = !0, gridSize: e = 20, className: I, showAI: m = !0, showAIConfig: h = !0, aiConfig: x }, g) {
349
- const [S, K] = j(() => Ve(p ?? Ie())), [z, J] = j(je), C = F(null), f = F(null), w = F(null), N = F(null), k = Ue(N), { wrappedSetDoc: d, undo: t, redo: i, canUndo: R, canRedo: L } = He(S, K), W = F(null), H = F(null), U = F(null), P = F(null), M = F(a);
350
- M.current = a;
351
- const D = F(S);
352
- D.current = S, $e(g, () => ({
350
+ var Ht = _e(function({ initialDocument: u, onChange: r, width: w, height: d, readOnly: s = !1, onBack: a, onExportPNG: n, onPublish: v, showMiniMap: c = !0, showGrid: I = !0, gridSize: e = 20, className: g, showAI: f = !0, showAIConfig: m = !0, aiConfig: b }, h) {
351
+ const [C, K] = X(() => Ve(u ?? Ie())), [T, _] = X(je), P = F(null), A = F(null), p = F(null), x = F(null), N = Ue(x), { wrappedSetDoc: D, undo: t, redo: l, canUndo: y, canRedo: W } = He(C, K), R = F(null), H = F(null), U = F(null), Z = F(null), M = F(r);
352
+ M.current = r;
353
+ const S = F(C);
354
+ S.current = C, $e(h, () => ({
353
355
  exportPNG: async (G) => {
354
- const T = C.current;
355
- return !T || T.destroyed ? null : T.exportPNG(G);
356
+ const L = P.current;
357
+ return !L || L.destroyed ? null : L.exportPNG(G);
356
358
  },
357
- getDocument: () => D.current
359
+ getDocument: () => S.current
358
360
  }), []);
359
- const O = E((G) => {
360
- d((T) => {
361
- const B = typeof G == "function" ? G(T) : G;
362
- return s ? B.canvases === T.canvases && B.title === T.title ? B : T : (queueMicrotask(() => M.current?.(B)), B);
361
+ const z = k((G) => {
362
+ D((L) => {
363
+ const V = typeof G == "function" ? G(L) : G;
364
+ return s ? V.canvases === L.canvases && V.title === L.title ? V : L : (queueMicrotask(() => M.current?.(V)), V);
363
365
  });
364
- }, [d, s]), A = E(() => {
366
+ }, [D, s]), J = k(() => {
365
367
  s || t();
366
- }, [s, t]), $ = E(() => {
367
- s || i();
368
- }, [s, i]), V = E((G) => {
369
- C.current = G, f.current && !w.current && (w.current = new We(f.current));
370
- }, []), de = E(async () => {
368
+ }, [s, t]), E = k(() => {
369
+ s || l();
370
+ }, [s, l]), B = k((G) => {
371
+ P.current = G, A.current && !p.current && (p.current = new We(A.current));
372
+ }, []), j = k(async () => {
371
373
  if (n) return void n();
372
- const G = C.current;
374
+ const G = P.current;
373
375
  if (!G || G.destroyed) return;
374
- const T = await G.exportPNG(16777215);
375
- T && Pe(T, `${Me(D.current.title)}.png`);
376
- }, [n]), ue = E(async () => {
377
- await P.current?.();
376
+ const L = await G.exportPNG(16777215);
377
+ L && Pe(L, `${Me(S.current.title)}.png`);
378
+ }, [n]), ue = k(async () => {
379
+ await Z.current?.();
378
380
  }, []);
379
- X(() => {
380
- let G = !1, T = null;
381
- const B = () => {
382
- const Z = C.current, ne = w.current;
383
- if (!Z || Z.destroyed || !ne) return;
381
+ Y(() => {
382
+ let G = !1, L = null;
383
+ const V = () => {
384
+ const O = P.current, oe = p.current;
385
+ if (!O || O.destroyed || !oe) return;
384
386
  const pe = {
385
- x: Z.world.position.x,
386
- y: Z.world.position.y,
387
- zoom: Z.world.scale.x
388
- }, me = S.stack[S.stack.length - 1] ?? "root", oe = S.canvases[me];
389
- oe && ne.update(oe.nodes, pe, Z.app.screen.width, Z.app.screen.height);
390
- }, te = () => {
387
+ x: O.world.position.x,
388
+ y: O.world.position.y,
389
+ zoom: O.world.scale.x
390
+ }, me = C.stack[C.stack.length - 1] ?? "root", se = C.canvases[me];
391
+ se && oe.update(se.nodes, pe, O.app.screen.width, O.app.screen.height);
392
+ }, ne = () => {
391
393
  if (G) return;
392
- const Z = C.current;
393
- Z && !Z.destroyed && w.current ? (Z.app.ticker.add(B), T = Z) : requestAnimationFrame(te);
394
+ const O = P.current;
395
+ O && !O.destroyed && p.current ? (O.app.ticker.add(V), L = O) : requestAnimationFrame(ne);
394
396
  };
395
- return te(), () => {
396
- G = !0, T && !T.destroyed && T.app.ticker.remove(B);
397
+ return ne(), () => {
398
+ G = !0, L && !L.destroyed && L.app.ticker.remove(V);
397
399
  };
398
- }, [S]);
400
+ }, [C]);
399
401
  const fe = {
400
- width: v ?? "100%",
401
- height: u ?? "100%"
402
+ width: w ?? "100%",
403
+ height: d ?? "100%"
402
404
  };
403
- return /* @__PURE__ */ r("div", {
404
- ref: N,
405
- className: `flow-container ${I ?? ""}`,
405
+ return /* @__PURE__ */ i("div", {
406
+ ref: x,
407
+ className: `flow-container ${g ?? ""}`,
406
408
  style: fe,
407
- children: /* @__PURE__ */ r(ve, {
408
- doc: S,
409
- setDoc: O,
410
- selection: z,
411
- setSelection: J,
412
- children: /* @__PURE__ */ r(ye, {
409
+ children: /* @__PURE__ */ i(ve, {
410
+ doc: C,
411
+ setDoc: z,
412
+ selection: T,
413
+ setSelection: _,
414
+ children: /* @__PURE__ */ i(ye, {
413
415
  showMiniMap: c,
414
- showGrid: y,
416
+ showGrid: I,
415
417
  gridSize: e,
416
- showAI: m,
418
+ showAI: f,
417
419
  readOnly: s,
418
- children: /* @__PURE__ */ _(be, {
419
- initialConfig: x,
420
- showAIConfig: h,
420
+ children: /* @__PURE__ */ $(be, {
421
+ initialConfig: b,
422
+ showAIConfig: m,
421
423
  children: [
422
- /* @__PURE__ */ r(Xe, {
423
- onUndo: A,
424
- onRedo: $,
425
- groupRef: W,
424
+ /* @__PURE__ */ i(Xe, {
425
+ onUndo: J,
426
+ onRedo: E,
427
+ groupRef: R,
426
428
  geoGroupRef: H,
427
429
  ungroupRef: U
428
430
  }),
429
- /* @__PURE__ */ r(Ye, {
430
- pixiRef: C,
431
- exportPdfRef: P
431
+ /* @__PURE__ */ i(Ye, {
432
+ pixiRef: P,
433
+ exportPdfRef: Z
432
434
  }),
433
- /* @__PURE__ */ _(tt, {
434
- compact: k,
435
- toolbar: s ? null : /* @__PURE__ */ r(Ne, {
436
- compact: k,
437
- onBack: l,
438
- onUndo: A,
439
- onRedo: $,
440
- canUndo: R,
441
- canRedo: L,
442
- onGroup: () => W.current?.(),
435
+ /* @__PURE__ */ $(tt, {
436
+ compact: N,
437
+ toolbar: s ? null : /* @__PURE__ */ i(Ne, {
438
+ compact: N,
439
+ onBack: a,
440
+ onUndo: J,
441
+ onRedo: E,
442
+ canUndo: y,
443
+ canRedo: W,
444
+ onGroup: () => R.current?.(),
443
445
  onGeoGroup: () => H.current?.(),
444
446
  onUngroup: () => U.current?.(),
445
- onExportPNG: de,
447
+ onExportPNG: j,
446
448
  onExportPDF: ue,
447
- onPublish: b
449
+ onPublish: v
448
450
  }),
449
451
  children: [
450
- /* @__PURE__ */ r(Ce, { onPixiReady: V }),
451
- /* @__PURE__ */ r(Fe, {}),
452
- /* @__PURE__ */ _(qe, { children: [!s && /* @__PURE__ */ r(ke, {}), /* @__PURE__ */ r(Ge, {})] }),
453
- !s && /* @__PURE__ */ r(rt, {}),
454
- /* @__PURE__ */ r(nt, {
455
- canvasRef: f,
456
- pixiRef: C,
457
- miniMapRef: w
452
+ /* @__PURE__ */ i(Ce, { onPixiReady: B }),
453
+ /* @__PURE__ */ i(Fe, {}),
454
+ /* @__PURE__ */ $(qe, { children: [!s && /* @__PURE__ */ i(ke, {}), /* @__PURE__ */ i(Ge, {})] }),
455
+ !s && /* @__PURE__ */ i(rt, {}),
456
+ /* @__PURE__ */ i(nt, {
457
+ canvasRef: A,
458
+ pixiRef: P,
459
+ miniMapRef: p
458
460
  }),
459
- /* @__PURE__ */ r(Le, {})
461
+ /* @__PURE__ */ i(Le, {})
460
462
  ]
461
463
  })
462
464
  ]
@@ -466,10 +468,10 @@ var Ht = _e(function({ initialDocument: p, onChange: a, width: v, height: u, rea
466
468
  });
467
469
  });
468
470
  function qe({ children: o }) {
469
- const { presentation: p } = Y();
470
- return /* @__PURE__ */ r("div", {
471
+ const { presentation: u } = q();
472
+ return /* @__PURE__ */ i("div", {
471
473
  className: "flow-overlay",
472
- style: { display: p ? "none" : void 0 },
474
+ style: { display: u ? "none" : void 0 },
473
475
  children: o
474
476
  });
475
477
  }
@@ -517,22 +519,22 @@ var Qe = [
517
519
  showKey: "showAI"
518
520
  }
519
521
  ];
520
- function ie(o) {
522
+ function re(o) {
521
523
  switch (o) {
522
524
  case "shapes":
523
- return /* @__PURE__ */ r(Ee, {});
525
+ return /* @__PURE__ */ i(Ee, {});
524
526
  case "icons":
525
- return /* @__PURE__ */ r(Ae, {});
527
+ return /* @__PURE__ */ i(Ae, {});
526
528
  case "media":
527
- return /* @__PURE__ */ r(De, {});
529
+ return /* @__PURE__ */ i(De, {});
528
530
  case "inspector":
529
- return /* @__PURE__ */ r(ze, {});
531
+ return /* @__PURE__ */ i(ze, {});
530
532
  case "outline":
531
- return /* @__PURE__ */ r(Te, {});
533
+ return /* @__PURE__ */ i(Te, {});
532
534
  case "json":
533
- return /* @__PURE__ */ r(it, {});
535
+ return /* @__PURE__ */ i(it, {});
534
536
  case "ai":
535
- return /* @__PURE__ */ r(Re, {});
537
+ return /* @__PURE__ */ i(Re, {});
536
538
  default:
537
539
  return null;
538
540
  }
@@ -542,175 +544,175 @@ var et = /* @__PURE__ */ new Set([
542
544
  "icons",
543
545
  "media"
544
546
  ]);
545
- function tt({ children: o, toolbar: p, compact: a }) {
546
- const v = Y(), { panelDocks: u, setPanelDock: s, presentation: l, readOnly: n, setPendingPlacement: b } = v, { setShowPalette: c, setShowInspector: y, setShowOutline: e, setShowJson: I, setShowAI: m } = v, h = n ? [] : Qe.filter((t) => !t.showKey || v[t.showKey]), x = (t) => ({
547
+ function tt({ children: o, toolbar: u, compact: r }) {
548
+ const w = q(), { panelDocks: d, setPanelDock: s, presentation: a, readOnly: n, setPendingPlacement: v } = w, { setShowPalette: c, setShowInspector: I, setShowOutline: e, setShowJson: g, setShowAI: f } = w, m = n ? [] : Qe.filter((t) => !t.showKey || w[t.showKey]), b = (t) => ({
547
549
  id: t.id,
548
550
  label: t.label,
549
551
  icon: t.icon,
550
- content: ie(t.id)
551
- }), [g, S] = j(null), K = F(null);
552
- X(() => {
553
- if (!a) {
552
+ content: re(t.id)
553
+ }), [h, C] = X(null), K = F(null);
554
+ Y(() => {
555
+ if (!r) {
554
556
  K.current = null;
555
557
  return;
556
558
  }
557
- const t = v.pendingPlacement, i = t ? `${t.type}:${t.data?.svgId ?? ""}:${t.data?.mediaKind ?? ""}` : null, R = K.current;
558
- K.current = i, i && i !== R && g && et.has(g) && S(null);
559
+ const t = w.pendingPlacement, l = t ? `${t.type}:${t.data?.svgId ?? ""}:${t.data?.mediaKind ?? ""}` : null, y = K.current;
560
+ K.current = l, l && l !== y && h && et.has(h) && C(null);
559
561
  }, [
560
- v.pendingPlacement,
561
- a,
562
- g
562
+ w.pendingPlacement,
563
+ r,
564
+ h
563
565
  ]);
564
- const [z, J] = j(null), C = E((t, i) => s(t, i), [s]), f = E((t) => {
565
- t === "inspector" ? y(!1) : t === "outline" ? e(!1) : t === "json" ? I(!1) : t === "ai" ? m(!1) : c(!1);
566
+ const [T, _] = X(null), P = k((t, l) => s(t, l), [s]), A = k((t) => {
567
+ t === "inspector" ? I(!1) : t === "outline" ? e(!1) : t === "json" ? g(!1) : t === "ai" ? f(!1) : c(!1);
566
568
  }, [
567
- y,
568
- e,
569
569
  I,
570
- m,
570
+ e,
571
+ g,
572
+ f,
571
573
  c
572
574
  ]);
573
- if (a && !l) {
574
- const t = h.find((i) => i.id === g) ?? null;
575
- return /* @__PURE__ */ _("div", {
575
+ if (r && !a) {
576
+ const t = m.find((l) => l.id === h) ?? null;
577
+ return /* @__PURE__ */ $("div", {
576
578
  className: "flow-workspace",
577
579
  children: [
578
- p,
579
- h.length > 0 && /* @__PURE__ */ r("div", {
580
+ u,
581
+ m.length > 0 && /* @__PURE__ */ i("div", {
580
582
  className: "flow-mobile-panel-bar",
581
- children: /* @__PURE__ */ r(he, {
583
+ children: /* @__PURE__ */ i(he, {
582
584
  placeholder: "选择面板…",
583
- options: h.map((i) => ({
584
- value: i.id,
585
- label: i.label
585
+ options: m.map((l) => ({
586
+ value: l.id,
587
+ label: l.label
586
588
  })),
587
- value: g ?? void 0,
588
- onChange: (i) => {
589
- b(null), S(String(i));
589
+ value: h ?? void 0,
590
+ onChange: (l) => {
591
+ v(null), C(String(l));
590
592
  }
591
593
  })
592
594
  }),
593
- /* @__PURE__ */ _("div", {
595
+ /* @__PURE__ */ $("div", {
594
596
  className: "flow-workspace-main",
595
- children: [/* @__PURE__ */ r("div", {
597
+ children: [/* @__PURE__ */ i("div", {
596
598
  className: "flow-stage",
597
599
  children: o
598
- }), t && /* @__PURE__ */ _("div", {
600
+ }), t && /* @__PURE__ */ $("div", {
599
601
  className: "flow-mobile-panel",
600
- children: [/* @__PURE__ */ _("div", {
602
+ children: [/* @__PURE__ */ $("div", {
601
603
  className: "flow-mobile-panel-header",
602
- children: [/* @__PURE__ */ _("span", {
604
+ children: [/* @__PURE__ */ $("span", {
603
605
  className: "flow-mobile-panel-title",
604
- children: [t.icon && /* @__PURE__ */ r("span", {
606
+ children: [t.icon && /* @__PURE__ */ i("span", {
605
607
  className: "flow-panel-tab-icon",
606
608
  children: t.icon
607
609
  }), t.label]
608
- }), /* @__PURE__ */ r("button", {
610
+ }), /* @__PURE__ */ i("button", {
609
611
  type: "button",
610
612
  className: "flow-mobile-panel-close",
611
613
  "aria-label": "关闭面板",
612
- onClick: () => S(null),
614
+ onClick: () => C(null),
613
615
  children: "✕"
614
616
  })]
615
- }), /* @__PURE__ */ r("div", {
617
+ }), /* @__PURE__ */ i("div", {
616
618
  className: "flow-mobile-panel-body",
617
- children: ie(t.id)
619
+ children: re(t.id)
618
620
  })]
619
621
  })]
620
622
  })
621
623
  ]
622
624
  });
623
625
  }
624
- const w = (t) => u[t] ?? "left", N = h.filter((t) => w(t.id) === "left").map(x), k = h.filter((t) => w(t.id) === "right").map(x), d = h.filter((t) => w(t.id) === "float");
625
- return /* @__PURE__ */ _("div", {
626
+ const p = (t) => d[t] ?? "left", x = m.filter((t) => p(t.id) === "left").map(b), N = m.filter((t) => p(t.id) === "right").map(b), D = m.filter((t) => p(t.id) === "float");
627
+ return /* @__PURE__ */ $("div", {
626
628
  className: "flow-workspace",
627
- children: [!l && p, /* @__PURE__ */ _("div", {
629
+ children: [!a && u, /* @__PURE__ */ $("div", {
628
630
  className: "flow-workspace-main",
629
631
  children: [
630
- !l && N.length > 0 && /* @__PURE__ */ r(q, {
631
- tabs: N,
632
- defaultTab: N[0]?.id,
632
+ !a && x.length > 0 && /* @__PURE__ */ i(Q, {
633
+ tabs: x,
634
+ defaultTab: x[0]?.id,
633
635
  resizeEdge: "right",
634
636
  defaultWidth: 220,
635
637
  dock: "left",
636
- onDock: C,
637
- onClose: f
638
+ onDock: P,
639
+ onClose: A
638
640
  }),
639
- /* @__PURE__ */ r("div", {
641
+ /* @__PURE__ */ i("div", {
640
642
  className: "flow-stage",
641
643
  children: o
642
644
  }),
643
- !l && k.length > 0 && /* @__PURE__ */ r(q, {
644
- tabs: k,
645
- defaultTab: k[0]?.id,
645
+ !a && N.length > 0 && /* @__PURE__ */ i(Q, {
646
+ tabs: N,
647
+ defaultTab: N[0]?.id,
646
648
  resizeEdge: "left",
647
649
  defaultWidth: 220,
648
650
  dock: "right",
649
- onDock: C,
650
- onClose: f
651
+ onDock: P,
652
+ onClose: A
651
653
  }),
652
- !l && d.map((t, i) => /* @__PURE__ */ r(q, {
653
- tabs: [x(t)],
654
+ !a && D.map((t, l) => /* @__PURE__ */ i(Q, {
655
+ tabs: [b(t)],
654
656
  resizeEdge: "right",
655
657
  defaultWidth: 220,
656
658
  dock: "float",
657
659
  style: {
658
- top: 48 + i * 40,
659
- left: 24 + i * 30
660
+ top: 48 + l * 40,
661
+ left: 24 + l * 30
660
662
  },
661
- onDock: C,
662
- onClose: f,
663
- onDragHintChange: J
663
+ onDock: P,
664
+ onClose: A,
665
+ onDragHintChange: _
664
666
  }, t.id)),
665
- !l && z && /* @__PURE__ */ r("div", {
666
- className: `flow-dock-dropzone flow-dock-dropzone--${z}`,
667
- children: /* @__PURE__ */ r("span", { children: z === "left" ? "⇤ 停靠左侧" : "停靠右侧 ⇥" })
667
+ !a && T && /* @__PURE__ */ i("div", {
668
+ className: `flow-dock-dropzone flow-dock-dropzone--${T}`,
669
+ children: /* @__PURE__ */ i("span", { children: T === "left" ? "⇤ 停靠左侧" : "停靠右侧 ⇥" })
668
670
  })
669
671
  ]
670
672
  })]
671
673
  });
672
674
  }
673
- function nt({ canvasRef: o, pixiRef: p, miniMapRef: a }) {
674
- const { showMiniMap: v, setViewport: u, presentation: s } = Y(), l = F(!1), n = E((e, I) => {
675
- const m = o.current, h = p.current, x = a.current;
676
- if (!m || !h || h.destroyed || !x) return;
677
- const g = m.getBoundingClientRect();
678
- if (g.width === 0 || g.height === 0) return;
679
- const { width: S, height: K } = x.size, z = (e - g.left) / g.width * S, J = (I - g.top) / g.height * K, C = x.minimapToWorld(z, J);
680
- if (!C) return;
681
- const f = h.world.scale.x || 1, w = h.app.screen.width, N = h.app.screen.height;
682
- u({
683
- x: w / 2 - C.x * f,
684
- y: N / 2 - C.y * f,
685
- zoom: f
675
+ function nt({ canvasRef: o, pixiRef: u, miniMapRef: r }) {
676
+ const { showMiniMap: w, setViewport: d, presentation: s } = q(), a = F(!1), n = k((e, g) => {
677
+ const f = o.current, m = u.current, b = r.current;
678
+ if (!f || !m || m.destroyed || !b) return;
679
+ const h = f.getBoundingClientRect();
680
+ if (h.width === 0 || h.height === 0) return;
681
+ const { width: C, height: K } = b.size, T = (e - h.left) / h.width * C, _ = (g - h.top) / h.height * K, P = b.minimapToWorld(T, _);
682
+ if (!P) return;
683
+ const A = m.world.scale.x || 1, p = m.app.screen.width, x = m.app.screen.height;
684
+ d({
685
+ x: p / 2 - P.x * A,
686
+ y: x / 2 - P.y * A,
687
+ zoom: A
686
688
  });
687
689
  }, [
688
690
  o,
689
- p,
690
- a,
691
- u
692
- ]), b = E((e) => {
693
- e.preventDefault(), e.currentTarget.setPointerCapture(e.pointerId), l.current = !0, n(e.clientX, e.clientY);
694
- }, [n]), c = E((e) => {
695
- l.current && n(e.clientX, e.clientY);
696
- }, [n]), y = E((e) => {
697
- l.current = !1;
691
+ u,
692
+ r,
693
+ d
694
+ ]), v = k((e) => {
695
+ e.preventDefault(), e.currentTarget.setPointerCapture(e.pointerId), a.current = !0, n(e.clientX, e.clientY);
696
+ }, [n]), c = k((e) => {
697
+ a.current && n(e.clientX, e.clientY);
698
+ }, [n]), I = k((e) => {
699
+ a.current = !1;
698
700
  try {
699
701
  e.currentTarget.releasePointerCapture(e.pointerId);
700
702
  } catch {
701
703
  }
702
704
  }, []);
703
- return /* @__PURE__ */ r("div", {
705
+ return /* @__PURE__ */ i("div", {
704
706
  className: "flow-minimap",
705
707
  style: {
706
- display: v && !s ? void 0 : "none",
708
+ display: w && !s ? void 0 : "none",
707
709
  cursor: "pointer"
708
710
  },
709
- onPointerDown: b,
711
+ onPointerDown: v,
710
712
  onPointerMove: c,
711
- onPointerUp: y,
713
+ onPointerUp: I,
712
714
  title: "点击或拖动以移动画布",
713
- children: /* @__PURE__ */ r("canvas", {
715
+ children: /* @__PURE__ */ i("canvas", {
714
716
  ref: o,
715
717
  width: 180,
716
718
  height: 120,
@@ -722,97 +724,97 @@ function nt({ canvasRef: o, pixiRef: p, miniMapRef: a }) {
722
724
  })
723
725
  });
724
726
  }
725
- function ot(o, p) {
726
- const a = `"id": "${p}"`, v = o.indexOf(a);
727
- if (v === -1) return null;
728
- let u = 0, s = -1;
729
- for (let n = v; n >= 0; n--)
730
- if (o[n] === "}" && u++, o[n] === "{") {
731
- if (u === 0) {
727
+ function ot(o, u) {
728
+ const r = `"id": "${u}"`, w = o.indexOf(r);
729
+ if (w === -1) return null;
730
+ let d = 0, s = -1;
731
+ for (let n = w; n >= 0; n--)
732
+ if (o[n] === "}" && d++, o[n] === "{") {
733
+ if (d === 0) {
732
734
  s = n;
733
735
  break;
734
736
  }
735
- u--;
737
+ d--;
736
738
  }
737
739
  if (s === -1) return null;
738
- u = 0;
739
- let l = -1;
740
+ d = 0;
741
+ let a = -1;
740
742
  for (let n = s; n < o.length; n++)
741
- if (o[n] === "{" && u++, o[n] === "}" && (u--, u === 0)) {
742
- l = n;
743
+ if (o[n] === "{" && d++, o[n] === "}" && (d--, d === 0)) {
744
+ a = n;
743
745
  break;
744
746
  }
745
- return l === -1 ? null : {
747
+ return a === -1 ? null : {
746
748
  startLine: o.slice(0, s).split(`
747
749
  `).length,
748
- endLine: o.slice(0, l + 1).split(`
750
+ endLine: o.slice(0, a + 1).split(`
749
751
  `).length
750
752
  };
751
753
  }
752
- function re(o) {
753
- o.querySelectorAll(".cm-line.flow-json-hl").forEach((p) => p.classList.remove("flow-json-hl"));
754
+ function ae(o) {
755
+ o.querySelectorAll(".cm-line.flow-json-hl").forEach((u) => u.classList.remove("flow-json-hl"));
754
756
  }
755
- function st(o, p, a) {
756
- const v = o.getView();
757
- if (v)
758
- for (let u = p; u <= a; u++) try {
759
- const s = v.state.doc.line(u), l = v.domAtPos(s.from), n = l.node instanceof HTMLElement ? l.node.closest(".cm-line") : l.node.parentElement?.closest(".cm-line");
757
+ function st(o, u, r) {
758
+ const w = o.getView();
759
+ if (w)
760
+ for (let d = u; d <= r; d++) try {
761
+ const s = w.state.doc.line(d), a = w.domAtPos(s.from), n = a.node instanceof HTMLElement ? a.node.closest(".cm-line") : a.node.parentElement?.closest(".cm-line");
760
762
  n && n.classList.add("flow-json-hl");
761
763
  } catch {
762
764
  }
763
765
  }
764
766
  function it() {
765
- const { setDoc: o, currentCanvasId: p, selection: a, currentCanvas: v } = ee(), [u, s] = j(""), [l, n] = j(null), b = F(!1), c = F(null), y = F(null), e = le(() => a.nodeIds.size + a.edgeIds.size + a.lineIds.size !== 1 ? null : a.nodeIds.size === 1 ? [...a.nodeIds][0] : a.edgeIds.size === 1 ? [...a.edgeIds][0] : a.lineIds.size === 1 ? [...a.lineIds][0] : null, [a]);
766
- X(() => {
767
- if (b.current) {
768
- b.current = !1;
767
+ const { setDoc: o, currentCanvasId: u, selection: r, currentCanvas: w } = te(), [d, s] = X(""), [a, n] = X(null), v = F(!1), c = F(null), I = F(null), e = ce(() => r.nodeIds.size + r.edgeIds.size + r.lineIds.size !== 1 ? null : r.nodeIds.size === 1 ? [...r.nodeIds][0] : r.edgeIds.size === 1 ? [...r.edgeIds][0] : r.lineIds.size === 1 ? [...r.lineIds][0] : null, [r]);
768
+ Y(() => {
769
+ if (v.current) {
770
+ v.current = !1;
769
771
  return;
770
772
  }
771
- s(JSON.stringify(v, null, 2)), n(null);
772
- }, [v]), X(() => {
773
- const h = y.current;
774
- if (h && re(h), !e) return;
775
- const x = setTimeout(() => {
776
- const g = ot(u, e);
777
- if (!g || !y.current) return;
778
- const S = c.current?.getView();
779
- if (!S) return;
780
- const K = y.current, z = S.scrollDOM;
781
- z.style.scrollBehavior = "smooth";
782
- const J = S.state.doc.line(g.startLine);
783
- S.dispatch({ effects: Be.scrollIntoView(J.from, {
773
+ s(JSON.stringify(w, null, 2)), n(null);
774
+ }, [w]), Y(() => {
775
+ const m = I.current;
776
+ if (m && ae(m), !e) return;
777
+ const b = setTimeout(() => {
778
+ const h = ot(d, e);
779
+ if (!h || !I.current) return;
780
+ const C = c.current?.getView();
781
+ if (!C) return;
782
+ const K = I.current, T = C.scrollDOM;
783
+ T.style.scrollBehavior = "smooth";
784
+ const _ = C.state.doc.line(h.startLine);
785
+ C.dispatch({ effects: Be.scrollIntoView(_.from, {
784
786
  y: "start",
785
787
  yMargin: 0
786
788
  }) });
787
- const C = () => {
788
- z.style.scrollBehavior = "", re(K), st(c.current, g.startLine, g.endLine);
789
+ const P = () => {
790
+ T.style.scrollBehavior = "", ae(K), st(c.current, h.startLine, h.endLine);
789
791
  };
790
- let f;
791
- const w = () => {
792
- clearTimeout(f), f = setTimeout(C, 100);
792
+ let A;
793
+ const p = () => {
794
+ clearTimeout(A), A = setTimeout(P, 100);
793
795
  };
794
- z.addEventListener("scroll", w), f = setTimeout(() => {
795
- z.removeEventListener("scroll", w), C();
796
+ T.addEventListener("scroll", p), A = setTimeout(() => {
797
+ T.removeEventListener("scroll", p), P();
796
798
  }, 800);
797
799
  }, 120);
798
- return () => clearTimeout(x);
799
- }, [e, u]);
800
- const I = E((h) => {
801
- s(h);
800
+ return () => clearTimeout(b);
801
+ }, [e, d]);
802
+ const g = k((m) => {
803
+ s(m);
802
804
  try {
803
- const x = JSON.parse(h);
804
- x && Array.isArray(x.nodes) && Array.isArray(x.edges) && Array.isArray(x.lines) ? (n(null), b.current = !0, o((g) => ({
805
- ...g,
805
+ const b = JSON.parse(m);
806
+ b && Array.isArray(b.nodes) && Array.isArray(b.edges) && Array.isArray(b.lines) ? (n(null), v.current = !0, o((h) => ({
807
+ ...h,
806
808
  canvases: {
807
- ...g.canvases,
808
- [p]: x
809
+ ...h.canvases,
810
+ [u]: b
809
811
  }
810
812
  }))) : n("JSON must have nodes, edges, lines arrays");
811
- } catch (x) {
812
- n(x.message?.slice(0, 60) ?? "Invalid JSON");
813
+ } catch (b) {
814
+ n(b.message?.slice(0, 60) ?? "Invalid JSON");
813
815
  }
814
- }, [o, p]), m = e ? a.nodeIds.has(e) ? "Node" : a.edgeIds.has(e) ? "Edge" : "Line" : null;
815
- return /* @__PURE__ */ _("div", {
816
+ }, [o, u]), f = e ? r.nodeIds.has(e) ? "Node" : r.edgeIds.has(e) ? "Edge" : "Line" : null;
817
+ return /* @__PURE__ */ $("div", {
816
818
  style: {
817
819
  display: "flex",
818
820
  flexDirection: "column",
@@ -820,32 +822,32 @@ function it() {
820
822
  minHeight: 0
821
823
  },
822
824
  children: [
823
- /* @__PURE__ */ r("div", {
825
+ /* @__PURE__ */ i("div", {
824
826
  className: "flow-json-header",
825
- children: /* @__PURE__ */ r("span", {
827
+ children: /* @__PURE__ */ i("span", {
826
828
  className: "flow-json-scope",
827
- children: m ? `${m}: ${e.slice(0, 8)}` : "Canvas"
829
+ children: f ? `${f}: ${e.slice(0, 8)}` : "Canvas"
828
830
  })
829
831
  }),
830
- l && /* @__PURE__ */ r("div", {
832
+ a && /* @__PURE__ */ i("div", {
831
833
  style: {
832
834
  fontSize: 11,
833
835
  color: "oklch(var(--er))",
834
836
  padding: "4px 0",
835
837
  flexShrink: 0
836
838
  },
837
- children: l
839
+ children: a
838
840
  }),
839
- /* @__PURE__ */ r("div", {
840
- ref: y,
841
+ /* @__PURE__ */ i("div", {
842
+ ref: I,
841
843
  style: {
842
844
  flex: 1,
843
845
  minHeight: 0
844
846
  },
845
- children: /* @__PURE__ */ r(ge, {
847
+ children: /* @__PURE__ */ i(ge, {
846
848
  ref: c,
847
- value: u,
848
- onChange: I,
849
+ value: d,
850
+ onChange: g,
849
851
  language: "json",
850
852
  lineNumbers: !1,
851
853
  height: "100%",
@@ -856,85 +858,85 @@ function it() {
856
858
  });
857
859
  }
858
860
  function rt() {
859
- const { contextMenu: o, setContextMenu: p } = Y(), { doc: a, setDoc: v, currentCanvasId: u, pushCanvas: s, setSelection: l } = ee(), { duplicate: n } = ae();
861
+ const { contextMenu: o, setContextMenu: u } = q(), { doc: r, setDoc: w, currentCanvasId: d, pushCanvas: s, setSelection: a } = te(), { duplicate: n } = le();
860
862
  if (!o) return null;
861
- const b = a.canvases[u];
862
- if (!b)
863
- return p(null), null;
864
- const c = o.nodeId ? b.nodes.find((e) => e.id === o.nodeId) : null, y = [];
865
- return c && (y.push({
863
+ const v = r.canvases[d];
864
+ if (!v)
865
+ return u(null), null;
866
+ const c = o.nodeId ? v.nodes.find((e) => e.id === o.nodeId) : null, I = [];
867
+ return c && (I.push({
866
868
  label: "Duplicate",
867
869
  icon: "⧉",
868
870
  action: () => {
869
871
  n(24, 24, { nodeIds: /* @__PURE__ */ new Set([c.id]) });
870
872
  }
871
- }), y.push({
873
+ }), I.push({
872
874
  label: "---",
873
875
  action: () => {
874
876
  }
875
- }), c.data.childCanvasId ? (y.push({
877
+ }), c.data.childCanvasId ? (I.push({
876
878
  label: "Enter Sub-canvas",
877
879
  icon: "↓",
878
880
  action: () => {
879
- s(c.data.childCanvasId), l({
881
+ s(c.data.childCanvasId), a({
880
882
  nodeIds: /* @__PURE__ */ new Set(),
881
883
  edgeIds: /* @__PURE__ */ new Set(),
882
884
  lineIds: /* @__PURE__ */ new Set()
883
885
  });
884
886
  }
885
- }), y.push({
887
+ }), I.push({
886
888
  label: "---",
887
889
  action: () => {
888
890
  }
889
- }), y.push({
891
+ }), I.push({
890
892
  label: "Delete Sub-canvas",
891
893
  icon: "🗑",
892
894
  danger: !0,
893
895
  action: () => {
894
896
  const e = c.data.childCanvasId;
895
- v((I) => {
896
- const m = { ...I.canvases };
897
- ce(m, e);
898
- const h = m[u];
899
- if (!h) return I;
900
- m[u] = {
901
- ...h,
902
- nodes: h.nodes.map((g) => g.id === c.id ? {
903
- ...g,
897
+ w((g) => {
898
+ const f = { ...g.canvases };
899
+ de(f, e);
900
+ const m = f[d];
901
+ if (!m) return g;
902
+ f[d] = {
903
+ ...m,
904
+ nodes: m.nodes.map((h) => h.id === c.id ? {
905
+ ...h,
904
906
  data: {
905
- ...g.data,
907
+ ...h.data,
906
908
  childCanvasId: void 0
907
909
  }
908
- } : g)
910
+ } : h)
909
911
  };
910
- const x = I.stack.filter((g) => m[g]);
911
- return x.length === 0 && x.push(we), {
912
- ...I,
913
- canvases: m,
914
- stack: x
912
+ const b = g.stack.filter((h) => f[h]);
913
+ return b.length === 0 && b.push(we), {
914
+ ...g,
915
+ canvases: f,
916
+ stack: b
915
917
  };
916
918
  });
917
919
  }
918
- })) : y.push({
920
+ })) : I.push({
919
921
  label: "Create Sub-canvas",
920
922
  icon: "⊞",
921
923
  action: () => {
922
- const e = Q("canvas");
923
- v((I) => {
924
- const m = I.canvases[u];
925
- return m ? {
926
- ...I,
924
+ const e = ee("canvas");
925
+ w((g) => {
926
+ const f = g.canvases[d];
927
+ return f ? {
928
+ ...g,
927
929
  canvases: {
928
- ...I.canvases,
929
- [u]: {
930
- ...m,
931
- nodes: m.nodes.map((h) => h.id === c.id ? {
932
- ...h,
930
+ ...g.canvases,
931
+ [d]: {
932
+ ...f,
933
+ nodes: f.nodes.map((m) => m.id === c.id ? {
934
+ ...m,
933
935
  data: {
934
- ...h.data,
936
+ ...m.data,
935
937
  childCanvasId: e
936
938
  }
937
- } : h)
939
+ } : m)
938
940
  },
939
941
  [e]: {
940
942
  nodes: [],
@@ -942,21 +944,21 @@ function rt() {
942
944
  lines: []
943
945
  }
944
946
  }
945
- } : I;
947
+ } : g;
946
948
  }), s(e);
947
949
  }
948
- })), y.length === 0 ? null : /* @__PURE__ */ r(Ke, {
950
+ })), I.length === 0 ? null : /* @__PURE__ */ i(Ke, {
949
951
  x: o.x,
950
952
  y: o.y,
951
- items: y,
952
- onClose: () => p(null)
953
+ items: I,
954
+ onClose: () => u(null)
953
955
  });
954
956
  }
955
- function ce(o, p) {
956
- const a = o[p];
957
- if (a) {
958
- for (const v of a.nodes) v.data.childCanvasId && ce(o, v.data.childCanvasId);
959
- delete o[p];
957
+ function de(o, u) {
958
+ const r = o[u];
959
+ if (r) {
960
+ for (const w of r.nodes) w.data.childCanvasId && de(o, w.data.childCanvasId);
961
+ delete o[u];
960
962
  }
961
963
  }
962
964
  export {