dishui 0.0.65 → 0.0.67

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