wendang-react 0.0.0-stage → 0.5.6

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 (548) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE.md +381 -0
  3. package/README.md +478 -2
  4. package/dist/bindings/yjs.js +5 -0
  5. package/dist/chunks/AnchoredPanel-D3nte06T.js +68 -0
  6. package/dist/chunks/MindMapCanvas-D5XwjVH1.js +2072 -0
  7. package/dist/chunks/MindMapViewer-CQTQAgNq.js +180 -0
  8. package/dist/chunks/SpreadsheetViewer-DN_QQGud.js +157 -0
  9. package/dist/chunks/code-highlight-BmaqTe1m.js +30 -0
  10. package/dist/chunks/code-highlight-engine-BFDzDPzy.js +40 -0
  11. package/dist/chunks/comment-hint-DN7LKJAn.js +296 -0
  12. package/dist/chunks/composition-state-Bl-U1R_2.js +40 -0
  13. package/dist/chunks/extensions-B-CVVQhp.js +4210 -0
  14. package/dist/chunks/fuzzy-match-DYQR-4w2.js +89 -0
  15. package/dist/chunks/hooks-C53Dp0pr.js +35 -0
  16. package/dist/chunks/host-C-V688Rq.js +197 -0
  17. package/dist/chunks/index-Ii536CFG.js +720 -0
  18. package/dist/chunks/katex-WjrodtTU.js +71 -0
  19. package/dist/chunks/mind-map-controller-B6SxK3GZ.js +479 -0
  20. package/dist/chunks/mind-map-delete-CVsxdXfs.js +31 -0
  21. package/dist/chunks/mind-map-input-CEWRz_t6.js +43 -0
  22. package/dist/chunks/mind-topic-text-BBNTbFSe.js +446 -0
  23. package/dist/chunks/nodes-iKqTGr_N.js +291 -0
  24. package/dist/chunks/popover-placement-D3xVYdkt.js +47 -0
  25. package/dist/chunks/worksheet-engine-TJ54m0KC.js +125 -0
  26. package/dist/chunks/worksheet-preview-DsDVWxIM.js +129 -0
  27. package/dist/document/viewer.js +287 -0
  28. package/dist/document.js +3620 -0
  29. package/dist/index.js +8 -0
  30. package/dist/mindmap/viewer.js +6 -0
  31. package/dist/mindmap.js +123 -0
  32. package/dist/shared.js +52 -0
  33. package/dist/spreadsheet/viewer.js +5 -0
  34. package/dist/spreadsheet/xlsx.js +299 -0
  35. package/dist/spreadsheet.js +120 -0
  36. package/dist/styles/callout.css +34 -0
  37. package/dist/styles/code-block.css +58 -0
  38. package/dist/styles/content-style.css +619 -0
  39. package/dist/styles/editor-interaction.css +621 -0
  40. package/dist/styles/file-video.css +12 -0
  41. package/dist/styles/image-preview.css +103 -0
  42. package/dist/styles/mind-map-block.css +14 -0
  43. package/dist/styles/mind-map-canvas.css +80 -0
  44. package/dist/styles/mind-map-comments.css +93 -0
  45. package/dist/styles/mind-map-details.css +7 -0
  46. package/dist/styles/mind-map-preview.css +7 -0
  47. package/dist/styles/mind-map-topic.css +112 -0
  48. package/dist/styles/page-picker.css +47 -0
  49. package/dist/styles/renderer.css +45 -0
  50. package/dist/styles/spreadsheet-editor.css +3 -0
  51. package/dist/styles/tokens.css +154 -0
  52. package/dist/styles/video-dialog.css +41 -0
  53. package/dist/styles/video-embed.css +35 -0
  54. package/dist/styles.css +2615 -0
  55. package/dist/types/bindings/yjs.d.ts +3 -0
  56. package/dist/types/document/viewer.d.ts +3 -0
  57. package/dist/types/document.d.ts +7 -0
  58. package/dist/types/editor/BlockAffordance.d.ts +47 -0
  59. package/dist/types/editor/CalloutView.d.ts +2 -0
  60. package/dist/types/editor/CodeBlockView.d.ts +9 -0
  61. package/dist/types/editor/DocumentColorPanel.d.ts +8 -0
  62. package/dist/types/editor/DocumentEditor.d.ts +71 -0
  63. package/dist/types/editor/ImagePreview.d.ts +10 -0
  64. package/dist/types/editor/LinkPopover.d.ts +21 -0
  65. package/dist/types/editor/PagePicker.d.ts +7 -0
  66. package/dist/types/editor/SelectionToolbar.d.ts +11 -0
  67. package/dist/types/editor/SlashMenu.d.ts +30 -0
  68. package/dist/types/editor/TableControls.d.ts +9 -0
  69. package/dist/types/editor/VideoEmbedDialog.d.ts +6 -0
  70. package/dist/types/editor/document-gestures.d.ts +13 -0
  71. package/dist/types/editor/extensions.d.ts +29 -0
  72. package/dist/types/editor/nodes.d.ts +20 -0
  73. package/dist/types/editor/same-document.d.ts +2 -0
  74. package/dist/types/engine/collab/presence.d.ts +1 -0
  75. package/dist/types/engine/editor/block-commands.d.ts +35 -0
  76. package/dist/types/engine/editor/block-conversion.d.ts +12 -0
  77. package/dist/types/engine/editor/block-drag.d.ts +16 -0
  78. package/dist/types/engine/editor/block-menu-placement.d.ts +16 -0
  79. package/dist/types/engine/editor/callout-commands.d.ts +4 -0
  80. package/dist/types/engine/editor/collab-change-origin.d.ts +2 -0
  81. package/dist/types/engine/editor/delete-block.d.ts +2 -0
  82. package/dist/types/engine/editor/extensions/block-format.d.ts +19 -0
  83. package/dist/types/engine/editor/extensions/block-handle.d.ts +17 -0
  84. package/dist/types/engine/editor/extensions/block-menu-highlight.d.ts +4 -0
  85. package/dist/types/engine/editor/extensions/block-selection.d.ts +117 -0
  86. package/dist/types/engine/editor/extensions/code-highlight.d.ts +2 -0
  87. package/dist/types/engine/editor/extensions/collab-cursor.d.ts +13 -0
  88. package/dist/types/engine/editor/extensions/ime-guard.d.ts +8 -0
  89. package/dist/types/engine/editor/extensions/inline-comments.d.ts +15 -0
  90. package/dist/types/engine/editor/extensions/paste-sanitizer.d.ts +4 -0
  91. package/dist/types/engine/editor/extensions/slash.d.ts +16 -0
  92. package/dist/types/engine/editor/extensions/table-interaction.d.ts +9 -0
  93. package/dist/types/engine/editor/extensions/upload-placeholder.d.ts +48 -0
  94. package/dist/types/engine/editor/image-preview-gesture.d.ts +3 -0
  95. package/dist/types/engine/editor/ime/composition-state.d.ts +9 -0
  96. package/dist/types/engine/editor/insert-block.d.ts +6 -0
  97. package/dist/types/engine/editor/insert-picker-logic.d.ts +13 -0
  98. package/dist/types/engine/editor/link-edit.d.ts +10 -0
  99. package/dist/types/engine/editor/mind-map-controller.d.ts +63 -0
  100. package/dist/types/engine/editor/mind-map-delete.d.ts +7 -0
  101. package/dist/types/engine/editor/mind-map-drag.d.ts +16 -0
  102. package/dist/types/engine/editor/mind-map-input.d.ts +16 -0
  103. package/dist/types/engine/editor/mind-map-selection.d.ts +11 -0
  104. package/dist/types/engine/editor/nodes/columns.d.ts +6 -0
  105. package/dist/types/engine/editor/nodes/file-nodeview.d.ts +4 -0
  106. package/dist/types/engine/editor/nodes/file.d.ts +2 -0
  107. package/dist/types/engine/editor/nodes/image-gallery.d.ts +2 -0
  108. package/dist/types/engine/editor/nodes/image-nodeview.d.ts +4 -0
  109. package/dist/types/engine/editor/nodes/image.d.ts +1 -0
  110. package/dist/types/engine/editor/nodes/inline-style.d.ts +4 -0
  111. package/dist/types/engine/editor/nodes/math-nodeview.d.ts +2 -0
  112. package/dist/types/engine/editor/nodes/math.d.ts +3 -0
  113. package/dist/types/engine/editor/nodes/mention.d.ts +2 -0
  114. package/dist/types/engine/editor/nodes/mind-map-schema.d.ts +6 -0
  115. package/dist/types/engine/editor/nodes/page-link.d.ts +2 -0
  116. package/dist/types/engine/editor/nodes/table-cell.d.ts +4 -0
  117. package/dist/types/engine/editor/nodes/video-embed-schema.d.ts +2 -0
  118. package/dist/types/engine/editor/popover-placement.d.ts +35 -0
  119. package/dist/types/engine/editor/table-clipboard.d.ts +3 -0
  120. package/dist/types/engine/editor/table-commands.d.ts +20 -0
  121. package/dist/types/engine/editor/table-geometry.d.ts +34 -0
  122. package/dist/types/engine/editor/table-menu-placement.d.ts +30 -0
  123. package/dist/types/engine/editor/tracked-target.d.ts +8 -0
  124. package/dist/types/engine/editor/trailing-paragraph.d.ts +2 -0
  125. package/dist/types/engine/host.d.ts +2 -0
  126. package/dist/types/engine/renderer/attachments.d.ts +11 -0
  127. package/dist/types/engine/renderer/katex.d.ts +7 -0
  128. package/dist/types/engine/renderer/lazy-visible.d.ts +11 -0
  129. package/dist/types/engine/shared/callout.d.ts +1 -0
  130. package/dist/types/engine/shared/code-block.d.ts +1 -0
  131. package/dist/types/engine/shared/code-highlight-engine.d.ts +2 -0
  132. package/dist/types/engine/shared/code-highlight.d.ts +8 -0
  133. package/dist/types/engine/shared/comment-hint-position.d.ts +20 -0
  134. package/dist/types/engine/shared/comment-hint.d.ts +2 -0
  135. package/dist/types/engine/shared/document-colors.d.ts +1 -0
  136. package/dist/types/engine/shared/fuzzy-match.d.ts +13 -0
  137. package/dist/types/engine/shared/image-gallery.d.ts +1 -0
  138. package/dist/types/engine/shared/inline-comments.d.ts +1 -0
  139. package/dist/types/engine/shared/mind-map-phase2.d.ts +1 -0
  140. package/dist/types/engine/shared/mind-map.d.ts +1 -0
  141. package/dist/types/engine/shared/mind-topic-text.d.ts +1 -0
  142. package/dist/types/engine/shared/modal-stack.d.ts +6 -0
  143. package/dist/types/engine/shared/page-candidates.d.ts +6 -0
  144. package/dist/types/engine/shared/pinyin.d.ts +6 -0
  145. package/dist/types/engine/shared/preview-items.d.ts +10 -0
  146. package/dist/types/engine/shared/safe-href.d.ts +1 -0
  147. package/dist/types/engine/shared/table-cell-format.d.ts +1 -0
  148. package/dist/types/engine/shared/table-layout.d.ts +1 -0
  149. package/dist/types/engine/shared/video-embed.d.ts +1 -0
  150. package/dist/types/engine/shared/video-feedback.d.ts +1 -0
  151. package/dist/types/engine/shared/workbook.d.ts +1 -0
  152. package/dist/types/engine/worksheets/worksheet-engine.d.ts +16 -0
  153. package/dist/types/engine/worksheets/worksheet-format.d.ts +20 -0
  154. package/dist/types/engine/worksheets/worksheet-preview.d.ts +17 -0
  155. package/dist/types/engine/worksheets/worksheet-xlsx.d.ts +21 -0
  156. package/dist/types/engine/wui/core/dialog.d.ts +5 -0
  157. package/dist/types/engine/wui/core/listbox.d.ts +8 -0
  158. package/dist/types/engine/wui/core/placement.d.ts +40 -0
  159. package/dist/types/hooks.d.ts +7 -0
  160. package/dist/types/host-types.d.ts +58 -0
  161. package/dist/types/host.d.ts +24 -0
  162. package/dist/types/index.d.ts +5 -0
  163. package/dist/types/mindmap/Comments.d.ts +9 -0
  164. package/dist/types/mindmap/Details.d.ts +13 -0
  165. package/dist/types/mindmap/Field.d.ts +10 -0
  166. package/dist/types/mindmap/MindMapCanvas.d.ts +19 -0
  167. package/dist/types/mindmap/MindMapEditor.d.ts +30 -0
  168. package/dist/types/mindmap/MindMapViewer.d.ts +23 -0
  169. package/dist/types/mindmap/TopicLabel.d.ts +4 -0
  170. package/dist/types/mindmap/viewer.d.ts +2 -0
  171. package/dist/types/mindmap.d.ts +4 -0
  172. package/dist/types/renderer/CodeToolbar.d.ts +10 -0
  173. package/dist/types/renderer/DocumentViewer.d.ts +23 -0
  174. package/dist/types/renderer/media.d.ts +33 -0
  175. package/dist/types/shared.d.ts +12 -0
  176. package/dist/types/spreadsheet/SpreadsheetEditor.d.ts +23 -0
  177. package/dist/types/spreadsheet/SpreadsheetViewer.d.ts +13 -0
  178. package/dist/types/spreadsheet/viewer.d.ts +2 -0
  179. package/dist/types/spreadsheet/xlsx.d.ts +2 -0
  180. package/dist/types/spreadsheet.d.ts +3 -0
  181. package/dist/types/wui/AnchoredPanel.d.ts +14 -0
  182. package/dist/types/wui/Dropdown.d.ts +18 -0
  183. package/dist/types/wui/Icon.d.ts +7 -0
  184. package/dist/types/wui/Tooltip.d.ts +5 -0
  185. package/dist/types/wui/index.d.ts +69 -0
  186. package/package.json +122 -3
  187. package/third-party-notices/@fast-csv__format@4.3.5-LICENSE.txt +21 -0
  188. package/third-party-notices/@fast-csv__parse@4.3.6-LICENSE.txt +21 -0
  189. package/third-party-notices/@flatten-js__interval-tree@1.1.3-LICENSE.txt +21 -0
  190. package/third-party-notices/@floating-ui__core@1.8.0-LICENSE.txt +20 -0
  191. package/third-party-notices/@floating-ui__dom@1.8.0-LICENSE.txt +20 -0
  192. package/third-party-notices/@floating-ui__react-dom@2.1.9-LICENSE.txt +20 -0
  193. package/third-party-notices/@floating-ui__utils@0.2.12-LICENSE.txt +20 -0
  194. package/third-party-notices/@grpc__grpc-js@1.14.6-LICENSE.txt +201 -0
  195. package/third-party-notices/@grpc__proto-loader@0.8.1-LICENSE.txt +201 -0
  196. package/third-party-notices/@js-sdsl__ordered-map@4.4.2-LICENSE.txt +21 -0
  197. package/third-party-notices/@protobufjs__aspromise@1.1.2-LICENSE.txt +26 -0
  198. package/third-party-notices/@protobufjs__base64@1.1.2-LICENSE.txt +26 -0
  199. package/third-party-notices/@protobufjs__codegen@2.0.5-LICENSE.txt +26 -0
  200. package/third-party-notices/@protobufjs__eventemitter@1.1.1-LICENSE.txt +26 -0
  201. package/third-party-notices/@protobufjs__fetch@1.1.1-LICENSE.txt +26 -0
  202. package/third-party-notices/@protobufjs__float@1.0.2-LICENSE.txt +26 -0
  203. package/third-party-notices/@protobufjs__path@1.1.2-LICENSE.txt +26 -0
  204. package/third-party-notices/@protobufjs__pool@1.1.0-LICENSE.txt +26 -0
  205. package/third-party-notices/@protobufjs__utf8@1.1.2-LICENSE.txt +26 -0
  206. package/third-party-notices/@radix-ui__primitive@1.2.0-LICENSE.txt +21 -0
  207. package/third-party-notices/@radix-ui__react-arrow@1.1.17-LICENSE.txt +21 -0
  208. package/third-party-notices/@radix-ui__react-collection@1.2.0-LICENSE.txt +21 -0
  209. package/third-party-notices/@radix-ui__react-compose-refs@1.1.5-LICENSE.txt +21 -0
  210. package/third-party-notices/@radix-ui__react-context@1.3.0-LICENSE.txt +21 -0
  211. package/third-party-notices/@radix-ui__react-dialog@1.3.1-LICENSE.txt +21 -0
  212. package/third-party-notices/@radix-ui__react-direction@1.2.0-LICENSE.txt +21 -0
  213. package/third-party-notices/@radix-ui__react-dismissable-layer@1.2.1-LICENSE.txt +21 -0
  214. package/third-party-notices/@radix-ui__react-dropdown-menu@2.2.1-LICENSE.txt +21 -0
  215. package/third-party-notices/@radix-ui__react-focus-guards@1.2.0-LICENSE.txt +21 -0
  216. package/third-party-notices/@radix-ui__react-focus-scope@1.3.1-LICENSE.txt +21 -0
  217. package/third-party-notices/@radix-ui__react-hover-card@1.2.1-LICENSE.txt +21 -0
  218. package/third-party-notices/@radix-ui__react-id@1.1.4-LICENSE.txt +21 -0
  219. package/third-party-notices/@radix-ui__react-menu@2.2.1-LICENSE.txt +21 -0
  220. package/third-party-notices/@radix-ui__react-popover@1.3.1-LICENSE.txt +21 -0
  221. package/third-party-notices/@radix-ui__react-popper@1.4.0-LICENSE.txt +21 -0
  222. package/third-party-notices/@radix-ui__react-portal@1.2.0-LICENSE.txt +21 -0
  223. package/third-party-notices/@radix-ui__react-presence@1.1.11-LICENSE.txt +21 -0
  224. package/third-party-notices/@radix-ui__react-primitive@2.2.0-LICENSE.txt +21 -0
  225. package/third-party-notices/@radix-ui__react-roving-focus@1.2.1-LICENSE.txt +21 -0
  226. package/third-party-notices/@radix-ui__react-separator@1.2.0-LICENSE.txt +21 -0
  227. package/third-party-notices/@radix-ui__react-slot@1.5.0-LICENSE.txt +21 -0
  228. package/third-party-notices/@radix-ui__react-use-callback-ref@1.1.5-LICENSE.txt +21 -0
  229. package/third-party-notices/@radix-ui__react-use-controllable-state@1.3.0-LICENSE.txt +21 -0
  230. package/third-party-notices/@radix-ui__react-use-effect-event@0.0.5-LICENSE.txt +21 -0
  231. package/third-party-notices/@radix-ui__react-use-is-hydrated@0.1.3-LICENSE.txt +21 -0
  232. package/third-party-notices/@radix-ui__react-use-layout-effect@1.1.4-LICENSE.txt +21 -0
  233. package/third-party-notices/@radix-ui__react-use-rect@1.1.4-LICENSE.txt +21 -0
  234. package/third-party-notices/@radix-ui__react-use-size@1.1.5-LICENSE.txt +21 -0
  235. package/third-party-notices/@radix-ui__rect@1.1.3-LICENSE.txt +21 -0
  236. package/third-party-notices/@tiptap__core@3.31.4-LICENSE.md.txt +21 -0
  237. package/third-party-notices/@tiptap__extension-blockquote@3.31.4-LICENSE.md.txt +21 -0
  238. package/third-party-notices/@tiptap__extension-bold@3.31.4-LICENSE.md.txt +21 -0
  239. package/third-party-notices/@tiptap__extension-bullet-list@3.31.4-LICENSE.md.txt +21 -0
  240. package/third-party-notices/@tiptap__extension-code-block@3.31.4-LICENSE.md.txt +21 -0
  241. package/third-party-notices/@tiptap__extension-code@3.31.4-LICENSE.md.txt +21 -0
  242. package/third-party-notices/@tiptap__extension-collaboration@3.31.4-LICENSE.md.txt +21 -0
  243. package/third-party-notices/@tiptap__extension-document@3.31.4-LICENSE.md.txt +21 -0
  244. package/third-party-notices/@tiptap__extension-dropcursor@3.31.4-LICENSE.md.txt +21 -0
  245. package/third-party-notices/@tiptap__extension-gapcursor@3.31.4-LICENSE.md.txt +21 -0
  246. package/third-party-notices/@tiptap__extension-hard-break@3.31.4-LICENSE.md.txt +21 -0
  247. package/third-party-notices/@tiptap__extension-heading@3.31.4-LICENSE.md.txt +21 -0
  248. package/third-party-notices/@tiptap__extension-horizontal-rule@3.31.4-LICENSE.md.txt +21 -0
  249. package/third-party-notices/@tiptap__extension-image@3.31.4-LICENSE.md.txt +21 -0
  250. package/third-party-notices/@tiptap__extension-italic@3.31.4-LICENSE.md.txt +21 -0
  251. package/third-party-notices/@tiptap__extension-link@3.31.4-LICENSE.md.txt +21 -0
  252. package/third-party-notices/@tiptap__extension-list-item@3.31.4-LICENSE.md.txt +21 -0
  253. package/third-party-notices/@tiptap__extension-list-keymap@3.31.4-LICENSE.md.txt +21 -0
  254. package/third-party-notices/@tiptap__extension-list@3.31.4-LICENSE.md.txt +21 -0
  255. package/third-party-notices/@tiptap__extension-ordered-list@3.31.4-LICENSE.md.txt +21 -0
  256. package/third-party-notices/@tiptap__extension-paragraph@3.31.4-LICENSE.md.txt +21 -0
  257. package/third-party-notices/@tiptap__extension-placeholder@3.31.4-LICENSE.md.txt +21 -0
  258. package/third-party-notices/@tiptap__extension-strike@3.31.4-LICENSE.md.txt +21 -0
  259. package/third-party-notices/@tiptap__extension-table-cell@3.31.4-LICENSE.md.txt +21 -0
  260. package/third-party-notices/@tiptap__extension-table-header@3.31.4-LICENSE.md.txt +21 -0
  261. package/third-party-notices/@tiptap__extension-table-row@3.31.4-LICENSE.md.txt +21 -0
  262. package/third-party-notices/@tiptap__extension-table@3.31.4-LICENSE.md.txt +21 -0
  263. package/third-party-notices/@tiptap__extension-task-item@3.31.4-LICENSE.md.txt +21 -0
  264. package/third-party-notices/@tiptap__extension-task-list@3.31.4-LICENSE.md.txt +21 -0
  265. package/third-party-notices/@tiptap__extension-text@3.31.4-LICENSE.md.txt +21 -0
  266. package/third-party-notices/@tiptap__extension-underline@3.31.4-LICENSE.md.txt +21 -0
  267. package/third-party-notices/@tiptap__extensions@3.31.4-LICENSE.md.txt +21 -0
  268. package/third-party-notices/@tiptap__pm@3.31.4-LICENSE.txt +21 -0
  269. package/third-party-notices/@tiptap__starter-kit@3.31.4-LICENSE.md.txt +21 -0
  270. package/third-party-notices/@tiptap__y-tiptap@3.0.7-LICENSE.txt +22 -0
  271. package/third-party-notices/@types__hast@3.0.5-LICENSE.txt +21 -0
  272. package/third-party-notices/@types__node@14.18.63-LICENSE.txt +21 -0
  273. package/third-party-notices/@types__node@26.6.2-LICENSE.txt +21 -0
  274. package/third-party-notices/@types__react-dom@19.3.0-LICENSE.txt +21 -0
  275. package/third-party-notices/@types__react@19.3.0-LICENSE.txt +21 -0
  276. package/third-party-notices/@types__unist@3.0.3-LICENSE.txt +21 -0
  277. package/third-party-notices/@univerjs__core@1.1.0-LICENSE.txt +176 -0
  278. package/third-party-notices/@univerjs__design@1.1.0-LICENSE.txt +176 -0
  279. package/third-party-notices/@univerjs__docs-ui@1.1.0-LICENSE.txt +176 -0
  280. package/third-party-notices/@univerjs__docs@1.1.0-LICENSE.txt +176 -0
  281. package/third-party-notices/@univerjs__drawing@1.1.0-LICENSE.txt +176 -0
  282. package/third-party-notices/@univerjs__engine-formula@1.1.0-LICENSE.txt +176 -0
  283. package/third-party-notices/@univerjs__engine-render@1.1.0-LICENSE.txt +176 -0
  284. package/third-party-notices/@univerjs__icons@1.46.0-LICENSE.txt +21 -0
  285. package/third-party-notices/@univerjs__network@1.1.0-LICENSE.txt +176 -0
  286. package/third-party-notices/@univerjs__preset-sheets-core@1.1.0-LICENSE.txt +176 -0
  287. package/third-party-notices/@univerjs__preset-sheets-filter@1.1.0-LICENSE.txt +176 -0
  288. package/third-party-notices/@univerjs__preset-sheets-sort@1.1.0-LICENSE.txt +176 -0
  289. package/third-party-notices/@univerjs__presets@1.1.0-LICENSE.txt +176 -0
  290. package/third-party-notices/@univerjs__rpc@1.1.0-LICENSE.txt +176 -0
  291. package/third-party-notices/@univerjs__sheets-filter-ui@1.1.0-LICENSE.txt +176 -0
  292. package/third-party-notices/@univerjs__sheets-filter@1.1.0-LICENSE.txt +176 -0
  293. package/third-party-notices/@univerjs__sheets-formula-ui@1.1.0-LICENSE.txt +176 -0
  294. package/third-party-notices/@univerjs__sheets-formula@1.1.0-LICENSE.txt +176 -0
  295. package/third-party-notices/@univerjs__sheets-numfmt-ui@1.1.0-LICENSE.txt +176 -0
  296. package/third-party-notices/@univerjs__sheets-numfmt@1.1.0-LICENSE.txt +176 -0
  297. package/third-party-notices/@univerjs__sheets-sort-ui@1.1.0-LICENSE.txt +176 -0
  298. package/third-party-notices/@univerjs__sheets-sort@1.1.0-LICENSE.txt +176 -0
  299. package/third-party-notices/@univerjs__sheets-ui@1.1.0-LICENSE.txt +176 -0
  300. package/third-party-notices/@univerjs__sheets@1.1.0-LICENSE.txt +176 -0
  301. package/third-party-notices/@univerjs__telemetry@1.1.0-LICENSE.txt +176 -0
  302. package/third-party-notices/@univerjs__themes@1.1.0-LICENSE.txt +176 -0
  303. package/third-party-notices/@univerjs__ui@1.1.0-LICENSE.txt +176 -0
  304. package/third-party-notices/@wendellhu__redi@1.1.3-LICENSE.txt +7 -0
  305. package/third-party-notices/ansi-regex@5.0.1-license.txt +9 -0
  306. package/third-party-notices/ansi-styles@4.3.0-license.txt +9 -0
  307. package/third-party-notices/archiver-utils@2.1.0-LICENSE.txt +22 -0
  308. package/third-party-notices/archiver-utils@3.0.4-LICENSE.txt +22 -0
  309. package/third-party-notices/archiver@5.3.2-LICENSE.txt +22 -0
  310. package/third-party-notices/aria-hidden@1.2.6-LICENSE.txt +21 -0
  311. package/third-party-notices/array-buffer-byte-length@1.0.2-LICENSE.txt +21 -0
  312. package/third-party-notices/arraybuffer.prototype.slice@1.0.4-LICENSE.txt +21 -0
  313. package/third-party-notices/async-function@1.0.0-LICENSE.txt +21 -0
  314. package/third-party-notices/async-lock@1.4.1-LICENSE.txt +22 -0
  315. package/third-party-notices/async@3.2.6-LICENSE.txt +19 -0
  316. package/third-party-notices/available-typed-arrays@1.0.7-LICENSE.txt +21 -0
  317. package/third-party-notices/balanced-match@1.0.2-LICENSE.md.txt +21 -0
  318. package/third-party-notices/base64-js@1.5.1-LICENSE.txt +21 -0
  319. package/third-party-notices/big-integer@1.6.52-LICENSE.txt +24 -0
  320. package/third-party-notices/bl@4.1.0-LICENSE.md.txt +13 -0
  321. package/third-party-notices/bluebird@3.4.7-LICENSE.txt +21 -0
  322. package/third-party-notices/brace-expansion@1.1.21-LICENSE.txt +21 -0
  323. package/third-party-notices/brace-expansion@2.1.7-LICENSE.txt +21 -0
  324. package/third-party-notices/buffer-crc32@0.2.13-LICENSE.txt +19 -0
  325. package/third-party-notices/buffer-indexof-polyfill@1.0.2-LICENSE.txt +22 -0
  326. package/third-party-notices/buffer@5.7.1-LICENSE.txt +21 -0
  327. package/third-party-notices/call-bind-apply-helpers@1.0.2-LICENSE.txt +21 -0
  328. package/third-party-notices/call-bind@1.0.9-LICENSE.txt +21 -0
  329. package/third-party-notices/call-bound@1.0.4-LICENSE.txt +21 -0
  330. package/third-party-notices/class-variance-authority@0.7.1-LICENSE.txt +190 -0
  331. package/third-party-notices/cliui@8.0.1-LICENSE.txt.txt +14 -0
  332. package/third-party-notices/clsx@2.1.1-license.txt +9 -0
  333. package/third-party-notices/cmdk@1.1.1-LICENSE.md.txt +21 -0
  334. package/third-party-notices/collapse-white-space@2.1.0-license.txt +22 -0
  335. package/third-party-notices/color-convert@2.0.1-LICENSE.txt +21 -0
  336. package/third-party-notices/color-name@1.1.4-LICENSE.txt +8 -0
  337. package/third-party-notices/commander@15.0.0-LICENSE.txt +22 -0
  338. package/third-party-notices/compress-commons@4.1.2-LICENSE.txt +22 -0
  339. package/third-party-notices/concat-map@0.0.1-LICENSE.txt +18 -0
  340. package/third-party-notices/core-util-is@1.0.3-LICENSE.txt +19 -0
  341. package/third-party-notices/crc-32@1.2.2-LICENSE.txt +201 -0
  342. package/third-party-notices/crc32-stream@4.0.3-LICENSE.txt +22 -0
  343. package/third-party-notices/csstype@3.2.3-LICENSE.txt +19 -0
  344. package/third-party-notices/data-view-buffer@1.0.2-LICENSE.txt +21 -0
  345. package/third-party-notices/data-view-byte-length@1.0.2-LICENSE.txt +21 -0
  346. package/third-party-notices/data-view-byte-offset@1.0.1-LICENSE.txt +21 -0
  347. package/third-party-notices/dayjs@1.11.23-LICENSE.txt +21 -0
  348. package/third-party-notices/decimal.js@10.6.0-LICENCE.md.txt +23 -0
  349. package/third-party-notices/define-data-property@1.1.4-LICENSE.txt +21 -0
  350. package/third-party-notices/define-properties@1.2.1-LICENSE.txt +21 -0
  351. package/third-party-notices/dequal@2.0.3-license.txt +21 -0
  352. package/third-party-notices/detect-node-es@1.1.0-LICENSE.txt +21 -0
  353. package/third-party-notices/devlop@1.1.0-license.txt +22 -0
  354. package/third-party-notices/dunder-proto@1.0.1-LICENSE.txt +21 -0
  355. package/third-party-notices/duplexer2@0.1.4-LICENSE.md.txt +26 -0
  356. package/third-party-notices/end-of-stream@1.4.5-LICENSE.txt +21 -0
  357. package/third-party-notices/es-abstract-get@1.0.0-LICENSE.txt +21 -0
  358. package/third-party-notices/es-abstract@1.24.2-LICENSE.txt +21 -0
  359. package/third-party-notices/es-define-property@1.0.1-LICENSE.txt +21 -0
  360. package/third-party-notices/es-errors@1.3.0-LICENSE.txt +21 -0
  361. package/third-party-notices/es-object-atoms@1.1.2-LICENSE.txt +21 -0
  362. package/third-party-notices/es-set-tostringtag@2.1.0-LICENSE.txt +21 -0
  363. package/third-party-notices/es-to-primitive@1.3.4-LICENSE.txt +22 -0
  364. package/third-party-notices/escalade@3.2.0-license.txt +9 -0
  365. package/third-party-notices/exceljs@4.4.0-LICENSE.txt +22 -0
  366. package/third-party-notices/fast-csv@4.3.6-LICENSE.txt +21 -0
  367. package/third-party-notices/fast-diff@1.3.0-LICENSE.txt +201 -0
  368. package/third-party-notices/for-each@0.3.5-LICENSE.txt +22 -0
  369. package/third-party-notices/fs-constants@1.0.0-LICENSE.txt +21 -0
  370. package/third-party-notices/fs.realpath@1.0.0-LICENSE.txt +43 -0
  371. package/third-party-notices/fstream@1.0.12-LICENSE.txt +15 -0
  372. package/third-party-notices/function-bind@1.1.2-LICENSE.txt +20 -0
  373. package/third-party-notices/function.prototype.name@1.2.0-LICENSE.txt +21 -0
  374. package/third-party-notices/functions-have-names@1.2.3-LICENSE.txt +21 -0
  375. package/third-party-notices/generator-function@2.0.1-LICENSE.md.txt +7 -0
  376. package/third-party-notices/get-caller-file@2.0.5-LICENSE.md.txt +6 -0
  377. package/third-party-notices/get-intrinsic@1.3.0-LICENSE.txt +21 -0
  378. package/third-party-notices/get-nonce@1.0.1-LICENSE.txt +21 -0
  379. package/third-party-notices/get-proto@1.0.1-LICENSE.txt +21 -0
  380. package/third-party-notices/get-symbol-description@1.1.0-LICENSE.txt +21 -0
  381. package/third-party-notices/glob@7.2.3-LICENSE.txt +21 -0
  382. package/third-party-notices/globalthis@1.0.4-LICENSE.txt +21 -0
  383. package/third-party-notices/gopd@1.2.0-LICENSE.txt +21 -0
  384. package/third-party-notices/graceful-fs@4.2.11-LICENSE.txt +15 -0
  385. package/third-party-notices/has-bigints@1.1.0-LICENSE.txt +21 -0
  386. package/third-party-notices/has-property-descriptors@1.0.2-LICENSE.txt +21 -0
  387. package/third-party-notices/has-proto@1.2.0-LICENSE.txt +21 -0
  388. package/third-party-notices/has-symbols@1.1.0-LICENSE.txt +21 -0
  389. package/third-party-notices/has-tostringtag@1.0.2-LICENSE.txt +21 -0
  390. package/third-party-notices/hasown@2.0.4-LICENSE.txt +21 -0
  391. package/third-party-notices/highlight.js@11.11.2-LICENSE.txt +29 -0
  392. package/third-party-notices/ieee754@1.2.1-LICENSE.txt +11 -0
  393. package/third-party-notices/immediate@3.0.6-LICENSE.txt.txt +20 -0
  394. package/third-party-notices/inflight@1.0.6-LICENSE.txt +15 -0
  395. package/third-party-notices/inherits@2.0.4-LICENSE.txt +16 -0
  396. package/third-party-notices/internal-slot@1.1.0-LICENSE.txt +21 -0
  397. package/third-party-notices/is-array-buffer@3.0.5-LICENSE.txt +21 -0
  398. package/third-party-notices/is-async-function@2.1.1-LICENSE.txt +20 -0
  399. package/third-party-notices/is-bigint@1.1.0-LICENSE.txt +21 -0
  400. package/third-party-notices/is-boolean-object@1.2.2-LICENSE.txt +22 -0
  401. package/third-party-notices/is-callable@1.2.7-LICENSE.txt +22 -0
  402. package/third-party-notices/is-data-view@1.0.2-LICENSE.txt +21 -0
  403. package/third-party-notices/is-date-object@1.1.0-LICENSE.txt +22 -0
  404. package/third-party-notices/is-document.all@1.0.0-LICENSE.txt +21 -0
  405. package/third-party-notices/is-finalizationregistry@1.1.1-LICENSE.txt +21 -0
  406. package/third-party-notices/is-fullwidth-code-point@3.0.0-license.txt +9 -0
  407. package/third-party-notices/is-generator-function@1.1.2-LICENSE.txt +20 -0
  408. package/third-party-notices/is-map@2.0.3-LICENSE.txt +21 -0
  409. package/third-party-notices/is-negative-zero@2.0.3-LICENSE.txt +20 -0
  410. package/third-party-notices/is-number-object@1.1.1-LICENSE.txt +22 -0
  411. package/third-party-notices/is-regex@1.2.1-LICENSE.txt +20 -0
  412. package/third-party-notices/is-set@2.0.3-LICENSE.txt +21 -0
  413. package/third-party-notices/is-shared-array-buffer@1.0.4-LICENSE.txt +21 -0
  414. package/third-party-notices/is-string@1.1.1-LICENSE.txt +22 -0
  415. package/third-party-notices/is-symbol@1.1.1-LICENSE.txt +22 -0
  416. package/third-party-notices/is-typed-array@1.1.15-LICENSE.txt +22 -0
  417. package/third-party-notices/is-weakmap@2.0.2-LICENSE.txt +21 -0
  418. package/third-party-notices/is-weakref@1.1.1-LICENSE.txt +21 -0
  419. package/third-party-notices/is-weakset@2.0.4-LICENSE.txt +21 -0
  420. package/third-party-notices/isarray@2.0.5-LICENSE.txt +21 -0
  421. package/third-party-notices/isomorphic.js@0.2.5-LICENSE.txt +21 -0
  422. package/third-party-notices/jszip@3.10.2-LICENSE.markdown.txt +651 -0
  423. package/third-party-notices/katex@0.18.9-LICENSE.txt +21 -0
  424. package/third-party-notices/kdbush@4.1.0-LICENSE.txt +15 -0
  425. package/third-party-notices/lazystream@1.0.1-LICENSE.txt +23 -0
  426. package/third-party-notices/lib0@0.2.119-LICENSE.txt +21 -0
  427. package/third-party-notices/lie@3.3.0-license.md.txt +7 -0
  428. package/third-party-notices/linkifyjs@4.3.3-LICENSE.txt +19 -0
  429. package/third-party-notices/listenercount@1.0.1-LICENSE.md.txt +5 -0
  430. package/third-party-notices/lodash-es@4.18.1-LICENSE.txt +47 -0
  431. package/third-party-notices/lodash.camelcase@4.3.0-LICENSE.txt +47 -0
  432. package/third-party-notices/lodash.defaults@4.2.0-LICENSE.txt +47 -0
  433. package/third-party-notices/lodash.difference@4.5.0-LICENSE.txt +47 -0
  434. package/third-party-notices/lodash.escaperegexp@4.1.2-LICENSE.txt +47 -0
  435. package/third-party-notices/lodash.flatten@4.4.0-LICENSE.txt +47 -0
  436. package/third-party-notices/lodash.groupby@4.6.0-LICENSE.txt +47 -0
  437. package/third-party-notices/lodash.isboolean@3.0.3-LICENSE.txt +22 -0
  438. package/third-party-notices/lodash.isequal@4.5.0-LICENSE.txt +47 -0
  439. package/third-party-notices/lodash.isfunction@3.0.9-LICENSE.txt +47 -0
  440. package/third-party-notices/lodash.isnil@4.0.0-LICENSE.txt +22 -0
  441. package/third-party-notices/lodash.isplainobject@4.0.6-LICENSE.txt +47 -0
  442. package/third-party-notices/lodash.isundefined@3.0.1-LICENSE.txt.txt +22 -0
  443. package/third-party-notices/lodash.union@4.6.0-LICENSE.txt +47 -0
  444. package/third-party-notices/lodash.uniq@4.5.0-LICENSE.txt +47 -0
  445. package/third-party-notices/long@5.3.2-LICENSE.txt +202 -0
  446. package/third-party-notices/lowlight@3.3.0-license.txt +22 -0
  447. package/third-party-notices/math-intrinsics@1.1.0-LICENSE.txt +21 -0
  448. package/third-party-notices/minimatch@3.1.5-LICENSE.txt +15 -0
  449. package/third-party-notices/minimatch@5.1.9-LICENSE.txt +15 -0
  450. package/third-party-notices/minimist@1.2.8-LICENSE.txt +18 -0
  451. package/third-party-notices/mkdirp@0.5.6-LICENSE.txt +21 -0
  452. package/third-party-notices/n-gram@2.0.2-license.txt +22 -0
  453. package/third-party-notices/normalize-path@3.0.0-LICENSE.txt +21 -0
  454. package/third-party-notices/numfmt@4.0.1-LICENSE.txt +19 -0
  455. package/third-party-notices/object-inspect@1.13.4-LICENSE.txt +21 -0
  456. package/third-party-notices/object-keys@1.1.1-LICENSE.txt +21 -0
  457. package/third-party-notices/object.assign@4.1.7-LICENSE.txt +21 -0
  458. package/third-party-notices/once@1.4.0-LICENSE.txt +15 -0
  459. package/third-party-notices/orderedmap@2.1.1-LICENSE.txt +19 -0
  460. package/third-party-notices/own-keys@1.0.2-LICENSE.txt +21 -0
  461. package/third-party-notices/pako@1.0.11-LICENSE.txt +21 -0
  462. package/third-party-notices/path-is-absolute@1.0.1-license.txt +21 -0
  463. package/third-party-notices/possible-typed-array-names@1.1.0-LICENSE.txt +21 -0
  464. package/third-party-notices/process-nextick-args@2.0.1-license.md.txt +19 -0
  465. package/third-party-notices/prosemirror-changeset@2.4.4-LICENSE.txt +19 -0
  466. package/third-party-notices/prosemirror-commands@1.7.2-LICENSE.txt +19 -0
  467. package/third-party-notices/prosemirror-dropcursor@1.8.4-LICENSE.txt +19 -0
  468. package/third-party-notices/prosemirror-gapcursor@1.4.1-LICENSE.txt +19 -0
  469. package/third-party-notices/prosemirror-history@1.5.1-LICENSE.txt +19 -0
  470. package/third-party-notices/prosemirror-inputrules@1.5.1-LICENSE.txt +19 -0
  471. package/third-party-notices/prosemirror-keymap@1.2.3-LICENSE.txt +19 -0
  472. package/third-party-notices/prosemirror-model@1.25.12-LICENSE.txt +19 -0
  473. package/third-party-notices/prosemirror-schema-list@1.5.1-LICENSE.txt +19 -0
  474. package/third-party-notices/prosemirror-state@1.4.4-LICENSE.txt +19 -0
  475. package/third-party-notices/prosemirror-tables@1.8.5-LICENSE.txt +19 -0
  476. package/third-party-notices/prosemirror-transform@1.12.2-LICENSE.txt +19 -0
  477. package/third-party-notices/prosemirror-view@1.42.6-LICENSE.txt +19 -0
  478. package/third-party-notices/protobufjs@7.6.6-LICENSE.txt +39 -0
  479. package/third-party-notices/quickselect@3.0.0-LICENSE.txt +15 -0
  480. package/third-party-notices/rbush@4.0.1-LICENSE.txt +21 -0
  481. package/third-party-notices/react-dom@19.3.1-LICENSE.txt +21 -0
  482. package/third-party-notices/react-remove-scroll@2.7.2-LICENSE.txt +21 -0
  483. package/third-party-notices/react-style-singleton@2.2.3-LICENSE.txt +21 -0
  484. package/third-party-notices/react@19.3.1-LICENSE.txt +21 -0
  485. package/third-party-notices/readable-stream@2.3.8-LICENSE.txt +47 -0
  486. package/third-party-notices/readable-stream@3.6.2-LICENSE.txt +47 -0
  487. package/third-party-notices/readdir-glob@1.1.3-LICENSE.txt +201 -0
  488. package/third-party-notices/reflect.getprototypeof@1.0.10-LICENSE.txt +21 -0
  489. package/third-party-notices/regexp.prototype.flags@1.5.4-LICENSE.txt +22 -0
  490. package/third-party-notices/require-directory@2.1.1-LICENSE.txt +22 -0
  491. package/third-party-notices/rimraf@2.7.1-LICENSE.txt +15 -0
  492. package/third-party-notices/rope-sequence@1.3.4-LICENSE.txt +19 -0
  493. package/third-party-notices/rxjs@7.8.2-LICENSE.txt.txt +202 -0
  494. package/third-party-notices/safe-array-concat@1.1.4-LICENSE.txt +21 -0
  495. package/third-party-notices/safe-buffer@5.1.2-LICENSE.txt +21 -0
  496. package/third-party-notices/safe-buffer@5.2.1-LICENSE.txt +21 -0
  497. package/third-party-notices/safe-push-apply@1.0.0-LICENSE.txt +21 -0
  498. package/third-party-notices/safe-regex-test@1.1.0-LICENSE.txt +21 -0
  499. package/third-party-notices/scheduler@0.28.0-LICENSE.txt +21 -0
  500. package/third-party-notices/set-function-length@1.2.2-LICENSE.txt +21 -0
  501. package/third-party-notices/set-function-name@2.0.2-LICENSE.txt +21 -0
  502. package/third-party-notices/set-proto@1.0.0-LICENSE.txt +21 -0
  503. package/third-party-notices/setimmediate@1.0.5-LICENSE.txt.txt +20 -0
  504. package/third-party-notices/side-channel-list@1.0.1-LICENSE.txt +21 -0
  505. package/third-party-notices/side-channel-map@1.0.1-LICENSE.txt +21 -0
  506. package/third-party-notices/side-channel-weakmap@1.0.2-LICENSE.txt +21 -0
  507. package/third-party-notices/side-channel@1.1.1-LICENSE.txt +21 -0
  508. package/third-party-notices/sonner@2.0.8-LICENSE.md.txt +21 -0
  509. package/third-party-notices/stop-iteration-iterator@1.1.0-LICENSE.txt +21 -0
  510. package/third-party-notices/string-width@4.2.3-license.txt +9 -0
  511. package/third-party-notices/string.prototype.trim@1.2.11-LICENSE.txt +21 -0
  512. package/third-party-notices/string.prototype.trimend@1.0.10-LICENSE.txt +21 -0
  513. package/third-party-notices/string.prototype.trimstart@1.0.8-LICENSE.txt +21 -0
  514. package/third-party-notices/string_decoder@1.1.1-LICENSE.txt +48 -0
  515. package/third-party-notices/string_decoder@1.3.0-LICENSE.txt +48 -0
  516. package/third-party-notices/strip-ansi@6.0.1-license.txt +9 -0
  517. package/third-party-notices/tar-stream@2.2.0-LICENSE.txt +21 -0
  518. package/third-party-notices/tiny-pinyin@1.3.2-LICENSE.txt +21 -0
  519. package/third-party-notices/tmp@0.2.7-LICENSE.txt +21 -0
  520. package/third-party-notices/traverse@0.3.10-LICENSE.txt +21 -0
  521. package/third-party-notices/trigram-utils@2.0.1-license.txt +22 -0
  522. package/third-party-notices/tslib@2.8.1-LICENSE.txt.txt +12 -0
  523. package/third-party-notices/typed-array-buffer@1.0.3-LICENSE.txt +21 -0
  524. package/third-party-notices/typed-array-byte-length@1.0.3-LICENSE.txt +21 -0
  525. package/third-party-notices/typed-array-byte-offset@1.0.5-LICENSE.txt +21 -0
  526. package/third-party-notices/typed-array-length@1.0.8-LICENSE.txt +21 -0
  527. package/third-party-notices/typedarray.prototype.slice@1.0.6-LICENSE.txt +21 -0
  528. package/third-party-notices/unbox-primitive@1.1.0-LICENSE.txt +21 -0
  529. package/third-party-notices/undici-types@8.9.0-LICENSE.txt +21 -0
  530. package/third-party-notices/unzipper@0.10.14-LICENSE.txt +25 -0
  531. package/third-party-notices/use-callback-ref@1.3.3-LICENSE.txt +21 -0
  532. package/third-party-notices/use-sidecar@1.1.3-LICENSE.txt +21 -0
  533. package/third-party-notices/util-deprecate@1.0.2-LICENSE.txt +24 -0
  534. package/third-party-notices/uuid@8.3.2-LICENSE.md.txt +9 -0
  535. package/third-party-notices/w3c-keyname@2.2.8-LICENSE.txt +19 -0
  536. package/third-party-notices/which-boxed-primitive@1.1.1-LICENSE.txt +21 -0
  537. package/third-party-notices/which-builtin-type@1.2.1-LICENSE.txt +21 -0
  538. package/third-party-notices/which-collection@1.0.2-LICENSE.txt +21 -0
  539. package/third-party-notices/which-typed-array@1.1.24-LICENSE.txt +22 -0
  540. package/third-party-notices/wrap-ansi@7.0.0-license.txt +9 -0
  541. package/third-party-notices/wrappy@1.0.2-LICENSE.txt +15 -0
  542. package/third-party-notices/xmlchars@2.2.0-LICENSE.txt +18 -0
  543. package/third-party-notices/y-protocols@1.0.7-LICENSE.txt +21 -0
  544. package/third-party-notices/y18n@5.0.8-LICENSE.txt +13 -0
  545. package/third-party-notices/yargs-parser@21.1.1-LICENSE.txt.txt +14 -0
  546. package/third-party-notices/yargs@17.7.3-LICENSE.txt +21 -0
  547. package/third-party-notices/yjs@13.6.33-LICENSE.txt +23 -0
  548. package/third-party-notices/zip-stream@4.1.1-LICENSE.txt +22 -0
@@ -0,0 +1,2072 @@
1
+ "use client";
2
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
3
+ import { useState, useRef, useEffect, useMemo } from "react";
4
+ import { textDifference, mindMapTree, layoutMindMap, MIND_MAP_PALETTE, mindMapDescendants as mindMapDescendants$1, projectMindSideMove, mindMapBranchSides, mindMapOutline, mindRelationPaths, mindMapMarkdown, mindMapSvg, mindMapToJson, MIND_MAP_MAX_TOPICS } from "wendang/mindmap";
5
+ import { TEXT_COLORS, HIGHLIGHT_COLORS, mindTopicLineHeight, MIND_TOPIC_FONT, readableTextColor } from "wendang/shared";
6
+ import { MIND_ICONS, MIND_COLORS, MIND_BACKGROUNDS, branchModel, searchMindMap, parseMindMapImport, importBranch, mindMapTemplate, parseMindBranch, ancestorIds } from "wendang/internal/mind-map-phase2";
7
+ import { normalizeMindFolds, firstLevelMindFolds } from "wendang/internal/mind-map-folding";
8
+ import { p as planMindTopicDeletion } from "./mind-map-delete-CVsxdXfs.js";
9
+ import { mindMapDescendants } from "wendang/internal/mind-map";
10
+ import { m as mindCanvasShortcut, s as selectMindTopic } from "./mind-map-input-CEWRz_t6.js";
11
+ import { b as useContentHost, a as useContentContext } from "./host-C-V688Rq.js";
12
+ import { createPortal } from "react-dom";
13
+ import { u as useLatest } from "./hooks-C53Dp0pr.js";
14
+ import { W as WButton, c as WDialog, a as WSelect, d as WAlert } from "./index-Ii536CFG.js";
15
+ import { T as TopicLabel, A as AttachmentImage } from "./mind-topic-text-BBNTbFSe.js";
16
+ import { A as AnchoredPanel } from "./AnchoredPanel-D3nte06T.js";
17
+ function mindMapDrop(model, drawing, id, point, allowSide = true) {
18
+ const source = drawing.nodes.find((t) => t.id === id), root = drawing.nodes.find((t) => t.id === model.rootId);
19
+ if (!source || !root || id === model.rootId) return null;
20
+ const excluded = mindMapDescendants(model, id), { x, y } = point;
21
+ const candidates = drawing.nodes.filter((t) => !excluded.has(t.id)).map((t) => ({
22
+ t,
23
+ distance: Math.hypot(x - t.x - t.width / 2, y - t.y - t.height / 2)
24
+ })).sort((a, b) => a.distance - b.distance);
25
+ const best = candidates[0];
26
+ const side = x < root.x + root.width / 2 - 24 ? -1 : x > root.x + root.width / 2 + 24 ? 1 : null;
27
+ const crossing = allowSide && model.layout !== "down" && side !== null && side !== source.side;
28
+ const nearNode = best && best.t.id !== root.id && x >= best.t.x - 18 && x <= best.t.x + best.t.width + 18 && y >= best.t.y - 18 && y <= best.t.y + best.t.height + 18;
29
+ if (nearNode || !crossing && best && best.distance < Math.max(best.t.width, 130)) {
30
+ return { kind: "node", id: best.t.id, mode: best.t.id === root.id ? "child" : y < best.t.y + 10 ? "before" : y > best.t.y + best.t.height - 10 ? "after" : "child" };
31
+ }
32
+ if (allowSide && model.layout !== "down" && side !== null && (crossing || source.parentId === root.id && model.layout === "both")) {
33
+ const before = drawing.nodes.filter((t) => t.parentId === root.id && t.id !== id && t.side === side).find((t) => y < t.y + t.height / 2);
34
+ return { kind: "side", id: root.id, mode: "side", side, ...before ? { beforeId: before.id } : {} };
35
+ }
36
+ return null;
37
+ }
38
+ function topicsInMarquee(topics, rect, previous = []) {
39
+ const visible = new Set(topics.map((topic) => topic.id));
40
+ const selected = new Set([...previous].filter((id) => visible.has(id)));
41
+ if (rect.width <= 0 || rect.height <= 0) return selected;
42
+ for (const topic of topics) {
43
+ if (topic.x < rect.x + rect.width && topic.x + topic.width > rect.x && topic.y < rect.y + rect.height && topic.y + topic.height > rect.y) selected.add(topic.id);
44
+ }
45
+ return selected;
46
+ }
47
+ function MindMapComments({ pageId, blockId, topicId, topicLabel, canComment, onClose, onChanged }) {
48
+ const host = useContentHost(), [items, setItems] = useState([]), [draft, setDraft] = useState(""), [error, setError] = useState(""), [busy, setBusy] = useState(false), [loading, setLoading] = useState(true);
49
+ const [composer, setComposer] = useState(null), [confirmId, setConfirmId] = useState(null), [epoch, setEpoch] = useState(0);
50
+ const alive = useRef(true), running = useRef(false);
51
+ useEffect(() => {
52
+ alive.current = true;
53
+ return () => {
54
+ alive.current = false;
55
+ };
56
+ }, []);
57
+ useEffect(() => {
58
+ let active = true;
59
+ setDraft("");
60
+ setComposer(null);
61
+ setConfirmId(null);
62
+ setError("");
63
+ setLoading(true);
64
+ if (!host.comments) {
65
+ setLoading(false);
66
+ return;
67
+ }
68
+ void host.comments.list(pageId).then((result) => {
69
+ if (active) setItems(result.items.filter((item) => {
70
+ var _a, _b;
71
+ return ((_a = item.anchor) == null ? void 0 : _a.prefix) === `mind:${blockId}` && ((_b = item.anchor) == null ? void 0 : _b.suffix) === topicId;
72
+ }));
73
+ }).catch((error2) => {
74
+ if (active) setError(String(error2));
75
+ }).finally(() => {
76
+ if (active) setLoading(false);
77
+ });
78
+ return () => {
79
+ active = false;
80
+ };
81
+ }, [host.comments, pageId, blockId, topicId, epoch]);
82
+ async function perform(action) {
83
+ if (running.current) return;
84
+ running.current = true;
85
+ setBusy(true);
86
+ setError("");
87
+ try {
88
+ await action();
89
+ onChanged == null ? void 0 : onChanged();
90
+ if (alive.current) {
91
+ setDraft("");
92
+ setComposer(null);
93
+ setEpoch((value) => value + 1);
94
+ }
95
+ } catch (error2) {
96
+ if (alive.current) setError(String(error2));
97
+ } finally {
98
+ running.current = false;
99
+ if (alive.current) setBusy(false);
100
+ }
101
+ }
102
+ const title = topicLabel.trim() ? `「${topicLabel.trim()}」` : "当前主题";
103
+ const time = (value) => {
104
+ const date = new Date(value);
105
+ return Number.isNaN(date.getTime()) ? "" : date.toLocaleString();
106
+ };
107
+ function compose(item) {
108
+ if (!composer || composer.id !== item.id) return null;
109
+ const editing = composer.kind === "edit";
110
+ return /* @__PURE__ */ jsxs("form", { className: "mind-comment__compose", onSubmit: (event) => {
111
+ event.preventDefault();
112
+ if (!composer.text.trim() || !editing && !canComment) return;
113
+ void perform(() => editing ? host.comments.update(composer.id, composer.text.trim()) : host.comments.create(pageId, composer.text.trim(), composer.id));
114
+ }, children: [
115
+ /* @__PURE__ */ jsx("label", { className: "mind-comment__label", children: editing ? "正在编辑评论" : `回复 ${item.authorName}` }),
116
+ /* @__PURE__ */ jsx("textarea", { "aria-label": editing ? "编辑主题讨论" : "回复主题讨论", rows: editing ? 3 : 2, maxLength: 5e3, value: composer.text, onChange: (event) => setComposer({ ...composer, text: event.target.value }) }),
117
+ /* @__PURE__ */ jsxs("div", { className: "mind-comment__actions", children: [
118
+ /* @__PURE__ */ jsx(WButton, { variant: "primary", loading: busy, disabled: !composer.text.trim(), htmlType: "submit", children: editing ? "保存" : "发表回复" }),
119
+ /* @__PURE__ */ jsx(WButton, { onClick: () => setComposer(null), children: "取消" })
120
+ ] })
121
+ ] });
122
+ }
123
+ function comment(item, reply = false) {
124
+ var _a, _b;
125
+ const editing = (composer == null ? void 0 : composer.kind) === "edit" && composer.id === item.id;
126
+ return /* @__PURE__ */ jsxs("article", { className: reply ? "mind-comment__reply" : "mind-comment", children: [
127
+ /* @__PURE__ */ jsxs("header", { className: "mind-comment__head", children: [
128
+ /* @__PURE__ */ jsx("strong", { children: item.authorName || "用户" }),
129
+ /* @__PURE__ */ jsxs("span", { children: [
130
+ time(item.createdAt),
131
+ item.resolved ? " · 已解决" : ""
132
+ ] })
133
+ ] }),
134
+ editing ? compose(item) : /* @__PURE__ */ jsx("p", { className: "mind-comment__body", children: item.deleted ? reply ? "回复已删除" : "评论已删除" : item.body }),
135
+ !editing && /* @__PURE__ */ jsxs("div", { className: "mind-comment__actions", children: [
136
+ item.canResolve && !reply && /* @__PURE__ */ jsx(WButton, { variant: "text", disabled: busy, onClick: () => void perform(() => host.comments.resolve(item.id, !item.resolved)), children: item.resolved ? "重新打开" : "标记解决" }),
137
+ canComment && !item.deleted && !reply && /* @__PURE__ */ jsx(WButton, { variant: "text", onClick: () => setComposer({ kind: "reply", id: item.id, text: "" }), children: "回复" }),
138
+ ((_a = host.comments) == null ? void 0 : _a.update) && item.canEdit && /* @__PURE__ */ jsx(WButton, { variant: "text", onClick: () => setComposer({ kind: "edit", id: item.id, text: item.body }), children: "编辑" }),
139
+ item.canDelete && /* @__PURE__ */ jsx(WButton, { variant: "text", disabled: busy, onClick: () => setConfirmId(item.id), children: "删除" })
140
+ ] }),
141
+ !reply && ((_b = item.replies) == null ? void 0 : _b.map((child) => comment(child, true))),
142
+ !editing && compose(item)
143
+ ] }, item.id);
144
+ }
145
+ return /* @__PURE__ */ jsxs("aside", { className: "mind-comments", "aria-label": "主题讨论", children: [
146
+ /* @__PURE__ */ jsxs("header", { className: "mind-comments__head", children: [
147
+ /* @__PURE__ */ jsxs("div", { className: "mind-comments__intro", children: [
148
+ /* @__PURE__ */ jsxs("strong", { children: [
149
+ title,
150
+ "的讨论"
151
+ ] }),
152
+ /* @__PURE__ */ jsx("p", { children: "讨论跟随这个主题移动;复制分支时不会复制。" })
153
+ ] }),
154
+ /* @__PURE__ */ jsxs("div", { className: "mind-comments__head-actions", children: [
155
+ /* @__PURE__ */ jsx(WButton, { variant: "text", disabled: busy, onClick: () => setEpoch((value) => value + 1), children: "刷新" }),
156
+ /* @__PURE__ */ jsx(WButton, { variant: "text", onClick: onClose, children: "关闭" })
157
+ ] })
158
+ ] }),
159
+ error && /* @__PURE__ */ jsx("p", { className: "mind-comments__error", role: "alert", children: error }),
160
+ /* @__PURE__ */ jsxs("div", { className: "mind-comments__list", children: [
161
+ loading && /* @__PURE__ */ jsx("p", { role: "status", children: "正在加载讨论…" }),
162
+ !loading && !error && !items.length && /* @__PURE__ */ jsxs("p", { className: "mind-comments__empty", children: [
163
+ "这个主题还没有讨论。",
164
+ canComment ? "在下方写下第一条即可。" : ""
165
+ ] }),
166
+ items.map((item) => comment(item))
167
+ ] }),
168
+ canComment ? /* @__PURE__ */ jsxs("form", { className: "mind-comments__compose", onSubmit: (event) => {
169
+ event.preventDefault();
170
+ if (!draft.trim()) return;
171
+ void perform(() => host.comments.create(pageId, draft.trim(), void 0, { blockId, topicId }));
172
+ }, children: [
173
+ /* @__PURE__ */ jsxs("label", { className: "mind-comment__label", children: [
174
+ "对",
175
+ title,
176
+ "发表讨论"
177
+ ] }),
178
+ /* @__PURE__ */ jsx("textarea", { "aria-label": "主题评论内容", rows: 3, maxLength: 5e3, placeholder: "写下你的想法…", value: draft, onChange: (event) => setDraft(event.target.value) }),
179
+ /* @__PURE__ */ jsx("div", { className: "mind-comment__actions", children: /* @__PURE__ */ jsx(WButton, { variant: "primary", loading: busy, disabled: !draft.trim(), htmlType: "submit", children: "发表讨论" }) })
180
+ ] }) : /* @__PURE__ */ jsx("p", { className: "mind-comments__empty", children: "你没有在这个空间发表讨论的权限。" }),
181
+ confirmId && /* @__PURE__ */ jsxs(WDialog, { title: "删除评论", onClose: () => setConfirmId(null), children: [
182
+ /* @__PURE__ */ jsx("p", { children: "确定删除这条评论?" }),
183
+ /* @__PURE__ */ jsxs("div", { className: "wr-toolbar", children: [
184
+ /* @__PURE__ */ jsx(WButton, { onClick: () => setConfirmId(null), children: "取消" }),
185
+ /* @__PURE__ */ jsx(WButton, { variant: "primary", onClick: () => {
186
+ const id = confirmId;
187
+ setConfirmId(null);
188
+ void perform(() => host.comments.remove(id));
189
+ }, children: "删除" })
190
+ ] })
191
+ ] })
192
+ ] });
193
+ }
194
+ function MindMapField({ id, field, value, controller, label, onFocus, onCommand }) {
195
+ const input = useRef(null), composing = useRef(false), focused = useRef(false);
196
+ const [draft, setDraft] = useState(value), draftRef = useRef(value);
197
+ draftRef.current = draft;
198
+ useEffect(() => {
199
+ if (composing.current || draftRef.current === value) return;
200
+ const el = input.current, start = (el == null ? void 0 : el.selectionStart) ?? 0, end = (el == null ? void 0 : el.selectionEnd) ?? start;
201
+ const diff = textDifference(draftRef.current, value), shift = diff.text.length - diff.to + diff.from;
202
+ const map = (pos) => pos <= diff.from ? pos : pos >= diff.to ? pos + shift : diff.from + diff.text.length;
203
+ setDraft(value);
204
+ if (focused.current) queueMicrotask(() => el == null ? void 0 : el.setSelectionRange(map(start), map(end)));
205
+ }, [value]);
206
+ useEffect(() => () => {
207
+ controller == null ? void 0 : controller.composition(false);
208
+ controller == null ? void 0 : controller.endText(id, field);
209
+ }, [controller, id, field]);
210
+ function apply(next) {
211
+ if (controller == null ? void 0 : controller.text(id, next, field)) setDraft(next);
212
+ }
213
+ return /* @__PURE__ */ jsx(
214
+ "textarea",
215
+ {
216
+ ref: input,
217
+ "aria-label": label,
218
+ value: draft,
219
+ readOnly: !(controller == null ? void 0 : controller.editable()),
220
+ maxLength: field === "title" ? 2e3 : 4e3,
221
+ rows: field === "title" ? 1 : field === "note" ? 4 : 3,
222
+ onFocus: () => {
223
+ focused.current = true;
224
+ controller == null ? void 0 : controller.beginText(id, field);
225
+ onFocus == null ? void 0 : onFocus();
226
+ },
227
+ onBlur: () => {
228
+ focused.current = false;
229
+ controller == null ? void 0 : controller.composition(false);
230
+ controller == null ? void 0 : controller.endText(id, field);
231
+ },
232
+ onChange: (event) => apply(event.target.value),
233
+ onCompositionStart: () => {
234
+ composing.current = true;
235
+ controller == null ? void 0 : controller.composition(true);
236
+ },
237
+ onCompositionEnd: (event) => {
238
+ apply(event.currentTarget.value);
239
+ composing.current = false;
240
+ controller == null ? void 0 : controller.composition(false);
241
+ controller == null ? void 0 : controller.beginText(id, field);
242
+ },
243
+ onKeyDown: (event) => {
244
+ event.stopPropagation();
245
+ if (event.nativeEvent.isComposing || composing.current || event.keyCode === 229) return;
246
+ if ((event.metaKey || event.ctrlKey) && ["z", "y"].includes(event.key.toLowerCase())) {
247
+ event.preventDefault();
248
+ event.shiftKey || event.key.toLowerCase() === "y" ? controller == null ? void 0 : controller.redo() : controller == null ? void 0 : controller.undo();
249
+ } else onCommand == null ? void 0 : onCommand(event);
250
+ }
251
+ }
252
+ );
253
+ }
254
+ const COLORS = MIND_COLORS.map((value, index) => ({ value, label: ["默认", "深灰", "白色", "蓝色", "青绿", "紫色", "棕色", "红色"][index] }));
255
+ const BACKGROUNDS = MIND_BACKGROUNDS.map((value, index) => ({ value, label: ["默认", "浅灰", "浅蓝", "浅绿", "浅紫", "浅黄", "浅红", "深蓝"][index] }));
256
+ function MindMapDetails({ model, id, controller, range, onClose, onNotice }) {
257
+ var _a;
258
+ const topic = model.topics.find((item) => item.id === id);
259
+ const writable = (controller == null ? void 0 : controller.editable()) ?? false;
260
+ const [href, setHref] = useState(""), [busy, setBusy] = useState(false);
261
+ const [relationTarget, setRelationTarget] = useState(""), [relationLabel, setRelationLabel] = useState("");
262
+ const [relationKind, setRelationKind] = useState("related");
263
+ const [relationId, setRelationId] = useState(void 0);
264
+ const imageInput = useRef(null);
265
+ if (!topic) return null;
266
+ const patch = (key, value) => {
267
+ if (writable) controller == null ? void 0 : controller.patch(id, { [key]: value || null });
268
+ };
269
+ function format(mark, attrs) {
270
+ const from = range.from, to = range.to;
271
+ if (to <= from) {
272
+ onNotice == null ? void 0 : onNotice("请先在主题文字中选中要设置格式的文字。");
273
+ return;
274
+ }
275
+ if (mark === "link" && attrs && !attrs.href) {
276
+ controller == null ? void 0 : controller.clearFormat(id, from, to, ["link"]);
277
+ return;
278
+ }
279
+ controller == null ? void 0 : controller.format(id, from, to, mark, attrs);
280
+ }
281
+ async function upload(file) {
282
+ var _a2;
283
+ if (!file || !(controller == null ? void 0 : controller.context.uploadImage) || !writable) return;
284
+ if (!["image/png", "image/jpeg", "image/webp", "image/gif"].includes(file.type)) {
285
+ onNotice == null ? void 0 : onNotice("请选择 PNG、JPEG、WebP 或 GIF 图片");
286
+ return;
287
+ }
288
+ setBusy(true);
289
+ try {
290
+ const uploaded = await controller.context.uploadImage(file);
291
+ if (controller.editable() && ((_a2 = controller.snapshot()) == null ? void 0 : _a2.topics.some((item) => item.id === id))) controller.patch(id, { attachmentId: uploaded.id });
292
+ } catch (error) {
293
+ onNotice == null ? void 0 : onNotice(error instanceof Error ? error.message : "图片上传失败");
294
+ } finally {
295
+ setBusy(false);
296
+ if (imageInput.current) imageInput.current.value = "";
297
+ }
298
+ }
299
+ function addRelation() {
300
+ if (controller == null ? void 0 : controller.relation({ id: relationId, source: id, target: relationTarget, kind: relationKind, label: relationLabel })) {
301
+ setRelationLabel("");
302
+ setRelationId(void 0);
303
+ onNotice == null ? void 0 : onNotice("已保存主题关系");
304
+ } else onNotice == null ? void 0 : onNotice("请选择不同的目标主题");
305
+ }
306
+ const relations = ((_a = model.relations) == null ? void 0 : _a.filter((relation) => relation.source === id || relation.target === id)) ?? [];
307
+ return /* @__PURE__ */ jsxs("aside", { className: "mind-details", "aria-label": "主题属性", children: [
308
+ /* @__PURE__ */ jsxs("header", { children: [
309
+ /* @__PURE__ */ jsx("strong", { children: "主题属性" }),
310
+ /* @__PURE__ */ jsx(WButton, { size: "small", variant: "text", onClick: onClose, children: "关闭" })
311
+ ] }),
312
+ /* @__PURE__ */ jsx("p", { className: "mind-details-title", children: topic.text || "未命名主题" }),
313
+ writable && /* @__PURE__ */ jsxs(Fragment, { children: [
314
+ /* @__PURE__ */ jsxs("fieldset", { children: [
315
+ /* @__PURE__ */ jsx("legend", { children: "选中文字格式" }),
316
+ /* @__PURE__ */ jsxs("div", { className: "mind-format-buttons", onMouseDown: (event) => event.preventDefault(), children: [
317
+ /* @__PURE__ */ jsx(WButton, { size: "small", "aria-label": "主题文字加粗", onClick: () => format("bold"), children: /* @__PURE__ */ jsx("b", { children: "B" }) }),
318
+ /* @__PURE__ */ jsx(WButton, { size: "small", "aria-label": "主题文字斜体", onClick: () => format("italic"), children: /* @__PURE__ */ jsx("i", { children: "I" }) }),
319
+ /* @__PURE__ */ jsx(WButton, { size: "small", "aria-label": "主题文字删除线", onClick: () => format("strike"), children: /* @__PURE__ */ jsx("s", { children: "S" }) })
320
+ ] }),
321
+ /* @__PURE__ */ jsx("span", { children: "选区文字色" }),
322
+ /* @__PURE__ */ jsx("div", { className: "mind-color-grid", onMouseDown: (event) => event.preventDefault(), children: TEXT_COLORS.filter((color) => color.value).map((color) => /* @__PURE__ */ jsx(
323
+ WButton,
324
+ {
325
+ size: "small",
326
+ variant: "outline",
327
+ narrow: true,
328
+ "aria-label": `选区字体:${color.name}`,
329
+ title: color.name,
330
+ onClick: () => format("textStyle", { color: color.value }),
331
+ children: /* @__PURE__ */ jsx("span", { style: { color: color.value }, children: "A" })
332
+ },
333
+ color.value
334
+ )) }),
335
+ /* @__PURE__ */ jsx("span", { children: "选区高亮" }),
336
+ /* @__PURE__ */ jsx("div", { className: "mind-color-grid", onMouseDown: (event) => event.preventDefault(), children: HIGHLIGHT_COLORS.filter((color) => color.value).map((color) => /* @__PURE__ */ jsx(
337
+ WButton,
338
+ {
339
+ size: "small",
340
+ variant: "outline",
341
+ narrow: true,
342
+ "aria-label": `选区高亮:${color.name}`,
343
+ title: color.name,
344
+ style: { background: color.value },
345
+ onClick: () => format("highlight", { color: color.value })
346
+ },
347
+ color.value
348
+ )) }),
349
+ /* @__PURE__ */ jsxs("label", { children: [
350
+ "选区链接",
351
+ /* @__PURE__ */ jsx("input", { value: href, type: "url", placeholder: "https://… 或站内路径", "aria-label": "主题选区链接", onChange: (event) => setHref(event.target.value) })
352
+ ] }),
353
+ /* @__PURE__ */ jsx(WButton, { size: "small", onClick: () => format("link", { href }), children: "应用链接" }),
354
+ /* @__PURE__ */ jsx(WButton, { size: "small", onClick: () => controller == null ? void 0 : controller.clearFormat(id, range.from, range.to), children: "清除选区格式" })
355
+ ] }),
356
+ /* @__PURE__ */ jsxs("fieldset", { children: [
357
+ /* @__PURE__ */ jsx("legend", { children: "外观" }),
358
+ /* @__PURE__ */ jsxs("label", { children: [
359
+ "形状",
360
+ /* @__PURE__ */ jsx(
361
+ WSelect,
362
+ {
363
+ label: "主题形状",
364
+ ariaLabel: "主题形状",
365
+ value: topic.shape ?? "round",
366
+ onChange: (value) => patch("shape", value),
367
+ options: [{ value: "round", label: "圆角矩形" }, { value: "pill", label: "胶囊" }, { value: "text", label: "文本" }]
368
+ }
369
+ )
370
+ ] }),
371
+ /* @__PURE__ */ jsxs("label", { children: [
372
+ "字号",
373
+ /* @__PURE__ */ jsx(
374
+ WSelect,
375
+ {
376
+ label: "主题字号",
377
+ ariaLabel: "主题字号",
378
+ value: topic.fontSize ?? 14,
379
+ onChange: (value) => patch("fontSize", Number(value)),
380
+ options: [12, 14, 16, 18, 20].map((value) => ({ value, label: String(value) }))
381
+ }
382
+ )
383
+ ] }),
384
+ /* @__PURE__ */ jsxs("label", { children: [
385
+ "对齐",
386
+ /* @__PURE__ */ jsx(
387
+ WSelect,
388
+ {
389
+ label: "主题对齐",
390
+ ariaLabel: "主题对齐",
391
+ value: topic.align ?? "center",
392
+ onChange: (value) => patch("align", value),
393
+ options: [{ value: "left", label: "左对齐" }, { value: "center", label: "居中" }, { value: "right", label: "右对齐" }]
394
+ }
395
+ )
396
+ ] }),
397
+ /* @__PURE__ */ jsx("span", { children: "节点文字色" }),
398
+ /* @__PURE__ */ jsx("div", { className: "mind-color-grid", onMouseDown: (event) => event.preventDefault(), children: COLORS.map((color) => /* @__PURE__ */ jsx(
399
+ WButton,
400
+ {
401
+ size: "small",
402
+ variant: "outline",
403
+ narrow: true,
404
+ "aria-label": `节点字体:${color.label}`,
405
+ title: color.label,
406
+ onClick: () => patch("color", color.value),
407
+ children: /* @__PURE__ */ jsx("span", { style: color.value ? { color: color.value } : void 0, children: "A" })
408
+ },
409
+ color.label
410
+ )) }),
411
+ /* @__PURE__ */ jsx("span", { children: "节点背景" }),
412
+ /* @__PURE__ */ jsx("div", { className: "mind-color-grid", onMouseDown: (event) => event.preventDefault(), children: BACKGROUNDS.map((color) => /* @__PURE__ */ jsx(
413
+ WButton,
414
+ {
415
+ size: "small",
416
+ variant: "outline",
417
+ narrow: true,
418
+ "aria-label": `节点背景:${color.label}`,
419
+ title: color.label,
420
+ style: color.value ? { background: color.value } : void 0,
421
+ onClick: () => patch("background", color.value),
422
+ children: color.value ? "" : "/"
423
+ },
424
+ color.label
425
+ )) }),
426
+ /* @__PURE__ */ jsxs("label", { children: [
427
+ "图标",
428
+ /* @__PURE__ */ jsx(
429
+ WSelect,
430
+ {
431
+ label: "主题图标",
432
+ ariaLabel: "主题图标",
433
+ value: topic.icon ?? "",
434
+ onChange: (value) => patch("icon", value),
435
+ options: MIND_ICONS.map((value) => ({ value, label: value || "无图标" }))
436
+ }
437
+ )
438
+ ] }),
439
+ /* @__PURE__ */ jsx(WButton, { size: "small", onClick: () => controller == null ? void 0 : controller.patch(id, { done: !topic.done }), children: topic.done ? "取消完成" : "标记完成" })
440
+ ] })
441
+ ] }),
442
+ /* @__PURE__ */ jsxs("fieldset", { children: [
443
+ /* @__PURE__ */ jsx("legend", { children: "描述" }),
444
+ /* @__PURE__ */ jsx(MindMapField, { id, field: "description", value: topic.description ?? "", controller, label: "主题描述" })
445
+ ] }),
446
+ /* @__PURE__ */ jsxs("fieldset", { children: [
447
+ /* @__PURE__ */ jsx("legend", { children: "备注" }),
448
+ /* @__PURE__ */ jsx(MindMapField, { id, field: "note", value: topic.note ?? "", controller, label: "主题备注" })
449
+ ] }),
450
+ writable && (controller == null ? void 0 : controller.context.uploadImage) && /* @__PURE__ */ jsxs("fieldset", { children: [
451
+ /* @__PURE__ */ jsx("legend", { children: "节点图片" }),
452
+ /* @__PURE__ */ jsx("input", { ref: imageInput, hidden: true, type: "file", accept: "image/png,image/jpeg,image/webp,image/gif", onChange: (event) => {
453
+ var _a2;
454
+ return void upload((_a2 = event.target.files) == null ? void 0 : _a2[0]);
455
+ } }),
456
+ /* @__PURE__ */ jsx(WButton, { size: "small", loading: busy, onClick: () => {
457
+ var _a2;
458
+ return (_a2 = imageInput.current) == null ? void 0 : _a2.click();
459
+ }, children: topic.attachmentId ? "替换图片" : "添加图片" }),
460
+ topic.attachmentId && /* @__PURE__ */ jsx(WButton, { size: "small", onClick: () => patch("attachmentId", null), children: "移除图片" })
461
+ ] }),
462
+ /* @__PURE__ */ jsxs("fieldset", { children: [
463
+ /* @__PURE__ */ jsx("legend", { children: "主题关系" }),
464
+ relations.map((relation) => {
465
+ var _a2;
466
+ return /* @__PURE__ */ jsxs("div", { className: "mind-relation-item", children: [
467
+ /* @__PURE__ */ jsxs("span", { children: [
468
+ relation.label || { related: "相关", depends: "依赖", reference: "参考" }[relation.kind],
469
+ " → ",
470
+ ((_a2 = model.topics.find((item) => item.id === (relation.source === id ? relation.target : relation.source))) == null ? void 0 : _a2.text) || "已移除主题"
471
+ ] }),
472
+ writable && relation.source === id && /* @__PURE__ */ jsx(WButton, { variant: "text", size: "small", onClick: () => {
473
+ setRelationId(relation.id);
474
+ setRelationTarget(relation.target);
475
+ setRelationKind(relation.kind);
476
+ setRelationLabel(relation.label);
477
+ }, children: "编辑" }),
478
+ writable && /* @__PURE__ */ jsx(WButton, { variant: "text", size: "small", onClick: () => controller == null ? void 0 : controller.deleteRelation(relation.id), children: "删除" })
479
+ ] }, relation.id);
480
+ }),
481
+ writable && /* @__PURE__ */ jsxs(Fragment, { children: [
482
+ /* @__PURE__ */ jsx(
483
+ WSelect,
484
+ {
485
+ label: "关系目标主题",
486
+ ariaLabel: "关系目标主题",
487
+ value: relationTarget,
488
+ onChange: setRelationTarget,
489
+ options: model.topics.filter((item) => item.id !== id).map((item) => ({ value: item.id, label: item.text || "未命名主题" })),
490
+ searchable: true
491
+ }
492
+ ),
493
+ /* @__PURE__ */ jsx(
494
+ WSelect,
495
+ {
496
+ label: "主题关系类型",
497
+ ariaLabel: "主题关系类型",
498
+ value: relationKind,
499
+ onChange: (value) => setRelationKind(value),
500
+ options: [{ value: "related", label: "相关" }, { value: "depends", label: "依赖" }, { value: "reference", label: "参考" }]
501
+ }
502
+ ),
503
+ /* @__PURE__ */ jsx("input", { "aria-label": "关系说明", placeholder: "关系说明(可选)", maxLength: 200, value: relationLabel, onChange: (event) => setRelationLabel(event.target.value) }),
504
+ /* @__PURE__ */ jsx(WButton, { size: "small", disabled: !relationTarget, onClick: addRelation, children: relationId ? "保存关系" : "添加关系" })
505
+ ] })
506
+ ] })
507
+ ] });
508
+ }
509
+ function WDropdown({ label, groups, onSelect, buttonProps }) {
510
+ const [open, setOpen] = useState(false), trigger = useRef(null), menu = useRef(null);
511
+ function keydown(event) {
512
+ var _a, _b;
513
+ if (!open || event.nativeEvent.isComposing) return;
514
+ const items = Array.from(((_a = menu.current) == null ? void 0 : _a.querySelectorAll('[role="menuitem"]:not([aria-disabled="true"])')) ?? []);
515
+ const index = items.indexOf(document.activeElement);
516
+ if (["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key) && items.length) {
517
+ event.preventDefault();
518
+ event.stopPropagation();
519
+ (_b = items[event.key === "Home" ? 0 : event.key === "End" ? items.length - 1 : index < 0 ? event.key === "ArrowUp" ? items.length - 1 : 0 : (index + (event.key === "ArrowUp" ? -1 : 1) + items.length) % items.length]) == null ? void 0 : _b.focus();
520
+ }
521
+ }
522
+ function select(item) {
523
+ if (!item.disabled) {
524
+ setOpen(false);
525
+ onSelect(item.value);
526
+ }
527
+ }
528
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
529
+ /* @__PURE__ */ jsx(WButton, { ...buttonProps, ref: trigger, "aria-haspopup": "menu", "aria-expanded": open, onClick: () => setOpen(!open), onKeyDown: keydown, children: label }),
530
+ open && /* @__PURE__ */ jsx(
531
+ AnchoredPanel,
532
+ {
533
+ anchor: trigger.current,
534
+ align: "center",
535
+ gap: 6,
536
+ role: "menu",
537
+ className: "mind-dropdown-popup",
538
+ label: typeof label === "string" ? label : void 0,
539
+ onClose: () => setOpen(false),
540
+ onKeyDown: keydown,
541
+ children: /* @__PURE__ */ jsx("div", { ref: menu, className: "w-dropdown", children: groups.map((group, index) => /* @__PURE__ */ jsxs("div", { className: "w-dropdown-group", role: "group", "aria-label": group.title, children: [
542
+ group.title && /* @__PURE__ */ jsx("div", { className: "w-dropdown-group__title", children: group.title }),
543
+ group.items.map((item) => /* @__PURE__ */ jsxs(
544
+ "div",
545
+ {
546
+ className: `w-dropdown-option${item.disabled ? " is-disabled" : ""}`,
547
+ role: "menuitem",
548
+ tabIndex: item.disabled ? void 0 : -1,
549
+ "aria-disabled": item.disabled || void 0,
550
+ onClick: () => select(item),
551
+ onKeyDown: (event) => {
552
+ if (event.key === "Enter" || event.key === " ") {
553
+ event.preventDefault();
554
+ select(item);
555
+ }
556
+ },
557
+ children: [
558
+ item.label,
559
+ item.shortcut && /* @__PURE__ */ jsx("span", { className: "mind-menu-key", children: item.shortcut })
560
+ ]
561
+ },
562
+ item.value
563
+ ))
564
+ ] }, index)) })
565
+ }
566
+ )
567
+ ] });
568
+ }
569
+ function WTooltip({ children, content }) {
570
+ var _a;
571
+ const [open, setOpen] = useState(false), anchor = useRef(null), timer = useRef(void 0);
572
+ function close() {
573
+ clearTimeout(timer.current);
574
+ setOpen(false);
575
+ }
576
+ function show() {
577
+ clearTimeout(timer.current);
578
+ timer.current = setTimeout(() => setOpen(true), 200);
579
+ }
580
+ useEffect(() => () => clearTimeout(timer.current), []);
581
+ useEffect(() => {
582
+ if (!open) return;
583
+ window.addEventListener("scroll", close, true);
584
+ return () => window.removeEventListener("scroll", close, true);
585
+ }, [open]);
586
+ return /* @__PURE__ */ jsxs("span", { ref: anchor, style: { display: "contents" }, onMouseEnter: show, onMouseLeave: close, onFocus: show, onBlur: close, children: [
587
+ children,
588
+ open && /* @__PURE__ */ jsx(AnchoredPanel, { anchor: ((_a = anchor.current) == null ? void 0 : _a.firstElementChild) ?? null, align: "center", prefer: "above", gap: 8, role: "tooltip", onClose: close, className: "code-tooltip-popup", children: /* @__PURE__ */ jsx("div", { className: "w-tooltip", children: content }) })
589
+ ] });
590
+ }
591
+ function MindMapCanvas(props) {
592
+ var _a, _b, _c, _d, _e, _f, _g;
593
+ const { host, portal } = useContentContext(), c = props.controller, [, update] = useState(0);
594
+ useEffect(() => {
595
+ const unsubscribe = c == null ? void 0 : c.subscribe(() => update((value) => value + 1));
596
+ return () => {
597
+ unsubscribe == null ? void 0 : unsubscribe();
598
+ };
599
+ }, [c]);
600
+ const model = (c == null ? void 0 : c.snapshot()) ?? props.model, editable = (c == null ? void 0 : c.editable()) ?? false;
601
+ const saved = useRef((_a = c == null ? void 0 : c.context.viewState) == null ? void 0 : _a.maps[model.id]).current;
602
+ const [selected, setSelected] = useState(() => new Set((saved == null ? void 0 : saved.selectedIds) ?? [(saved == null ? void 0 : saved.selectedId) ?? model.rootId]));
603
+ const [active, setActive] = useState((saved == null ? void 0 : saved.selectedId) ?? model.rootId);
604
+ const [editing, setEditing] = useState(null), [text, setText] = useState("");
605
+ const composing = useRef(false);
606
+ const [folds, setFolds] = useState(() => normalizeMindFolds(model, (saved == null ? void 0 : saved.collapsed) ?? []));
607
+ const [zoom, setZoom] = useState(((_b = saved == null ? void 0 : saved.viewport) == null ? void 0 : _b.zoom) ?? 1);
608
+ const [origin, setPan] = useState({ x: ((_c = saved == null ? void 0 : saved.viewport) == null ? void 0 : _c.x) ?? 0, y: ((_d = saved == null ? void 0 : saved.viewport) == null ? void 0 : _d.y) ?? 0 });
609
+ const [moving, setMoving] = useState((saved == null ? void 0 : saved.panMode) ?? false), space = useRef(false), [outline, setOutline] = useState(false), [grid, setGrid] = useState((saved == null ? void 0 : saved.showGrid) ?? true);
610
+ const [spaceHeld, setSpaceHeld] = useState(false);
611
+ const [quickControls, setQuickControls] = useState((saved == null ? void 0 : saved.showQuickControls) ?? true);
612
+ const [settingsOpen, setSettingsOpen] = useState(false), settingsTrigger = useRef(null);
613
+ const [busy, setBusy] = useState(false), exportRunning = useRef(false);
614
+ const [showSearch, setShowSearch] = useState(false), [query, setQuery] = useState(""), [replacement, setReplacement] = useState("");
615
+ const [hitIndex, setHitIndex] = useState(0), [following, setFollowing] = useState(null);
616
+ const [details, setDetails] = useState(false), [comments, setComments] = useState(!!props.openComments);
617
+ const [selectedRange, setSelectedRange] = useState({ from: 0, to: 0 });
618
+ const [notice, setNotice] = useState(""), [focusId, setFocusId] = useState(null);
619
+ const [confirmDelete, setConfirmDelete] = useState(null);
620
+ const deletionSelection = useRef([]), deletionActive = useRef(active);
621
+ const [importOpen, setImportOpen] = useState(false), [importText, setImportText] = useState(""), [importError, setImportError] = useState("");
622
+ const [exportBranch, setExportBranch] = useState(false), [transparent, setTransparent] = useState(false), [imageScale, setImageScale] = useState(2);
623
+ const [box, setBox] = useState(null), [drop, setDrop] = useState(null);
624
+ const [contextMenu, setContextMenu] = useState(null);
625
+ const menuRef = useRef(null);
626
+ const [dragPreview, setDragPreview] = useState(null);
627
+ const [pasting, setPasting] = useState(false), pastingRef = useRef(false), alive = useRef(true);
628
+ const root = useRef(null), stage = useRef(null), input = useRef(null);
629
+ const gesture = useRef(null), copied = useRef([]), [size, setSize] = useState({ width: 0, height: 0 });
630
+ const tree = mindMapTree(model), current = tree.find((topic) => topic.id === active) ?? tree[0];
631
+ const viewModel = focusId && tree.some((topic) => topic.id === focusId) ? branchModel(model, focusId) : model;
632
+ const drawing = layoutMindMap(viewModel, normalizeMindFolds(viewModel, folds)), color = MIND_MAP_PALETTE[model.theme];
633
+ const currentRef = useLatest({ model, editable, c, active });
634
+ const draggedIds = dragPreview ? mindMapDescendants$1(model, dragPreview.id) : /* @__PURE__ */ new Set();
635
+ const projected = (drop == null ? void 0 : drop.kind) === "side" && dragPreview ? projectMindSideMove(model, dragPreview.id, drop.side, drop.beforeId) : null;
636
+ const projection = projected ? layoutMindMap(projected, folds) : null;
637
+ const hits = query ? searchMindMap(model, query) : [];
638
+ const importPreview = useMemo(() => {
639
+ try {
640
+ return importText.trim() ? parseMindMapImport(importText) : null;
641
+ } catch {
642
+ return null;
643
+ }
644
+ }, [importText]);
645
+ const status = props.saveStatus ?? (c == null ? void 0 : c.status()) ?? "", pageId = props.pageId ?? (c == null ? void 0 : c.context.pageId);
646
+ const canExport = c ? c.canExport() : props.allowExport === true;
647
+ const title = ((_e = model.topics.find((topic) => topic.id === model.rootId)) == null ? void 0 : _e.text) || "思维导图";
648
+ useEffect(() => {
649
+ const node = stage.current;
650
+ if (!node) return;
651
+ const observer = new ResizeObserver(() => setSize({ width: node.clientWidth, height: node.clientHeight }));
652
+ const wheel = (event) => event.preventDefault();
653
+ node.addEventListener("wheel", wheel, { passive: false });
654
+ observer.observe(node);
655
+ return () => {
656
+ observer.disconnect();
657
+ node.removeEventListener("wheel", wheel);
658
+ };
659
+ }, []);
660
+ useEffect(() => {
661
+ const keyup = (event) => {
662
+ if (event.code === "Space") {
663
+ space.current = false;
664
+ setSpaceHeld(false);
665
+ }
666
+ };
667
+ const blur = () => {
668
+ cancelGesture();
669
+ space.current = false;
670
+ setSpaceHeld(false);
671
+ setContextMenu(null);
672
+ };
673
+ window.addEventListener("keyup", keyup);
674
+ window.addEventListener("blur", blur);
675
+ return () => {
676
+ window.removeEventListener("keyup", keyup);
677
+ window.removeEventListener("blur", blur);
678
+ };
679
+ }, []);
680
+ useEffect(() => {
681
+ alive.current = true;
682
+ return () => {
683
+ alive.current = false;
684
+ c == null ? void 0 : c.composition(false);
685
+ };
686
+ }, [c]);
687
+ useEffect(() => {
688
+ const close = (event) => {
689
+ var _a2;
690
+ if (!((_a2 = menuRef.current) == null ? void 0 : _a2.contains(event.target))) setContextMenu(null);
691
+ };
692
+ const key = (event) => {
693
+ var _a2;
694
+ if (event.isComposing || event.key !== "Escape") return;
695
+ if (gesture.current || contextMenu) {
696
+ event.preventDefault();
697
+ event.stopImmediatePropagation();
698
+ cancelGesture();
699
+ setContextMenu(null);
700
+ (_a2 = stage.current) == null ? void 0 : _a2.focus();
701
+ }
702
+ };
703
+ document.addEventListener("pointerdown", close, true);
704
+ window.addEventListener("keydown", key, true);
705
+ return () => {
706
+ document.removeEventListener("pointerdown", close, true);
707
+ window.removeEventListener("keydown", key, true);
708
+ };
709
+ }, [contextMenu]);
710
+ useEffect(() => {
711
+ const menu = menuRef.current;
712
+ if (!menu || !contextMenu) return;
713
+ const rect = menu.getBoundingClientRect();
714
+ menu.style.left = `${Math.max(8, Math.min(contextMenu.x, innerWidth - rect.width - 8))}px`;
715
+ menu.style.top = `${Math.max(8, Math.min(contextMenu.y, innerHeight - rect.height - 8))}px`;
716
+ menu.focus();
717
+ }, [contextMenu, portal]);
718
+ useEffect(() => {
719
+ const g = gesture.current;
720
+ if (g && (g.doc !== JSON.stringify(model) || !editable && g.kind === "node")) cancelGesture();
721
+ }, [model, editable]);
722
+ useEffect(() => {
723
+ var _a2, _b2;
724
+ if (editing) {
725
+ (_a2 = input.current) == null ? void 0 : _a2.focus();
726
+ (_b2 = input.current) == null ? void 0 : _b2.select();
727
+ }
728
+ }, [editing]);
729
+ useEffect(() => {
730
+ if (!editing) return;
731
+ const topic = model.topics.find((topic2) => topic2.id === editing), element = input.current;
732
+ if (!topic || !editable) {
733
+ c == null ? void 0 : c.endText(editing);
734
+ setEditing(null);
735
+ return;
736
+ }
737
+ if (composing.current || topic.text === text) return;
738
+ const start = (element == null ? void 0 : element.selectionStart) ?? 0, end = (element == null ? void 0 : element.selectionEnd) ?? start, diff = textDifference(text, topic.text);
739
+ const shift = diff.text.length - diff.to + diff.from;
740
+ const map = (pos) => pos <= diff.from ? pos : pos >= diff.to ? pos + shift : diff.from + diff.text.length;
741
+ setText(topic.text);
742
+ queueMicrotask(() => {
743
+ if (element === document.activeElement) element == null ? void 0 : element.setSelectionRange(map(start), map(end));
744
+ });
745
+ }, [model, editable, editing]);
746
+ useEffect(() => {
747
+ const element = input.current;
748
+ if (!editing || !element) return;
749
+ element.style.height = "0px";
750
+ element.style.height = `${Math.max(mindTopicLineHeight(current.fontSize || 14), element.scrollHeight)}px`;
751
+ }, [editing, text, current.fontSize]);
752
+ useEffect(() => {
753
+ const ids = new Set(drawing.nodes.map((topic) => topic.id));
754
+ setSelected((previous) => {
755
+ const next = new Set([...previous].filter((id) => ids.has(id)));
756
+ return next.size === previous.size ? previous : next;
757
+ });
758
+ if (!ids.has(active)) setActive(model.rootId);
759
+ }, [model, active, focusId, folds]);
760
+ const viewStateRef = useRef({ zoom, pan: origin, grid, quickControls, moving, folds, active, selected });
761
+ viewStateRef.current = { zoom, pan: origin, grid, quickControls, moving, folds, active, selected };
762
+ useEffect(() => () => {
763
+ const state = c == null ? void 0 : c.context.viewState;
764
+ if (!state) return;
765
+ const current2 = viewStateRef.current;
766
+ state.maps[model.id] = {
767
+ selectedId: current2.active,
768
+ selectedIds: [...current2.selected],
769
+ showGrid: current2.grid,
770
+ showQuickControls: current2.quickControls,
771
+ panMode: current2.moving,
772
+ collapsed: [...current2.folds],
773
+ viewport: { x: current2.pan.x, y: current2.pan.y, zoom: current2.zoom }
774
+ };
775
+ }, [c, model.id]);
776
+ const awareness = c == null ? void 0 : c.context.awareness;
777
+ const [peerEpoch, bumpPeers] = useState(0);
778
+ useEffect(() => {
779
+ if (!awareness) return;
780
+ const change = () => bumpPeers((value) => value + 1);
781
+ awareness.on("change", change);
782
+ return () => {
783
+ awareness.off("change", change);
784
+ };
785
+ }, [awareness]);
786
+ useEffect(() => {
787
+ var _a2;
788
+ const local = (_a2 = awareness == null ? void 0 : awareness.getLocalState()) == null ? void 0 : _a2.mindMap;
789
+ if (awareness && ((local == null ? void 0 : local.blockId) === model.id || !local)) {
790
+ awareness.setLocalStateField("mindMap", { blockId: model.id, topicId: active, editing: !!editing, viewport: { ...origin, zoom } });
791
+ }
792
+ }, [awareness, model.id, active, editing, origin.x, origin.y, zoom]);
793
+ useEffect(() => () => {
794
+ var _a2, _b2;
795
+ if (((_b2 = (_a2 = awareness == null ? void 0 : awareness.getLocalState()) == null ? void 0 : _a2.mindMap) == null ? void 0 : _b2.blockId) === model.id) awareness.setLocalStateField("mindMap", null);
796
+ }, [awareness, model.id]);
797
+ useEffect(() => {
798
+ var _a2;
799
+ if (!awareness || following === null) return;
800
+ const peer = (_a2 = awareness.getStates().get(following)) == null ? void 0 : _a2.mindMap;
801
+ if ((peer == null ? void 0 : peer.blockId) !== model.id || !peer.viewport || ![peer.viewport.x, peer.viewport.y, peer.viewport.zoom].every(Number.isFinite)) return;
802
+ const nextZoom = Math.min(2.5, Math.max(5e-3, peer.viewport.zoom));
803
+ setPan({ x: peer.viewport.x, y: peer.viewport.y });
804
+ setZoom(nextZoom);
805
+ }, [awareness, following, model.id, peerEpoch]);
806
+ const peers = useMemo(() => {
807
+ return Array.from((awareness == null ? void 0 : awareness.getStates().entries()) ?? []).flatMap(([client, state]) => {
808
+ var _a2, _b2;
809
+ const data = state.mindMap;
810
+ if (client === (awareness == null ? void 0 : awareness.clientID) || (data == null ? void 0 : data.blockId) !== model.id) return [];
811
+ return [{ client, name: String(((_a2 = state.user) == null ? void 0 : _a2.name) || ((_b2 = state.user) == null ? void 0 : _b2.displayName) || "协作者"), topicId: String(data.topicId || ""), editing: !!data.editing }];
812
+ });
813
+ }, [awareness, model.id, peerEpoch]);
814
+ function fit(target = viewModel) {
815
+ var _a2, _b2;
816
+ const bounds = layoutMindMap(target, normalizeMindFolds(target, folds)).bounds;
817
+ const width = ((_a2 = stage.current) == null ? void 0 : _a2.clientWidth) ?? size.width, height = ((_b2 = stage.current) == null ? void 0 : _b2.clientHeight) ?? size.height;
818
+ const nextZoom = Math.min(1.15, Math.max(5e-3, Math.min((width - 110) / bounds.width, (height - 150) / bounds.height)));
819
+ setZoom(nextZoom);
820
+ setPan({ x: width / 2 - (bounds.x + bounds.width / 2) * nextZoom, y: height / 2 - (bounds.y + bounds.height / 2) * nextZoom });
821
+ }
822
+ const autoFitted = useRef(false);
823
+ const lastLayout = useRef(model.layout), lastPanels = useRef({ details, comments, outline });
824
+ useEffect(() => {
825
+ const panels = lastPanels.current;
826
+ if (autoFitted.current && (lastLayout.current !== model.layout || panels.details !== details || panels.comments !== comments || panels.outline !== outline) && following === null) fit();
827
+ lastLayout.current = model.layout;
828
+ lastPanels.current = { details, comments, outline };
829
+ }, [model.layout, details, comments, outline, size.width, size.height]);
830
+ useEffect(() => {
831
+ if (autoFitted.current) return;
832
+ if (!size.width || !size.height || !stage.current) return;
833
+ autoFitted.current = true;
834
+ if (saved == null ? void 0 : saved.viewport) {
835
+ setPan({ x: saved.viewport.x, y: saved.viewport.y });
836
+ } else fit();
837
+ }, [size.width, size.height]);
838
+ const point = (x, y) => {
839
+ const rect = stage.current.getBoundingClientRect();
840
+ return { x: (x - rect.left - origin.x) / zoom, y: (y - rect.top - origin.y) / zoom };
841
+ };
842
+ function select(id, additive = false) {
843
+ var _a2;
844
+ const next = selectMindTopic(selected, id, additive);
845
+ setFollowing(null);
846
+ setSelected(next);
847
+ setActive(next.has(id) ? id : [...next].at(-1) ?? model.rootId);
848
+ (_a2 = stage.current) == null ? void 0 : _a2.focus();
849
+ }
850
+ function locateHit(hit) {
851
+ locate(hit.id);
852
+ if (hit.field !== "title") {
853
+ setDetails(true);
854
+ setComments(false);
855
+ }
856
+ }
857
+ function locate(id) {
858
+ const live = (c == null ? void 0 : c.snapshot()) ?? model;
859
+ if (!live.topics.some((topic2) => topic2.id === id)) return;
860
+ const next = new Set(folds);
861
+ for (const ancestor of ancestorIds(live, id)) next.delete(ancestor);
862
+ const drawing2 = layoutMindMap(live, next), topic = drawing2.nodes.find((topic2) => topic2.id === id);
863
+ setFolds(next);
864
+ setFocusId(null);
865
+ select(id);
866
+ if (topic) setPan({ x: size.width / 2 - (topic.x + topic.width / 2) * zoom, y: size.height / 2 - (topic.y + topic.height / 2) * zoom });
867
+ }
868
+ useEffect(() => {
869
+ setSelectedRange({ from: 0, to: 0 });
870
+ }, [active]);
871
+ useEffect(() => {
872
+ if (!host.location) return;
873
+ const linked = () => {
874
+ const params = new URLSearchParams(host.location.current().replace(/^#/, ""));
875
+ const id = params.get("topic");
876
+ if (params.get("mind") === model.id && id) locate(id);
877
+ };
878
+ linked();
879
+ return host.location.subscribe(linked);
880
+ }, [host.location, model.id]);
881
+ function jumpHit(delta) {
882
+ if (!hits.length) return;
883
+ const next = (hitIndex + delta + hits.length) % hits.length;
884
+ setHitIndex(next);
885
+ locateHit(hits[next]);
886
+ }
887
+ function edit(id) {
888
+ if (id && editable) {
889
+ const topic = model.topics.find((topic2) => topic2.id === id);
890
+ if (!topic) return;
891
+ setActive(id);
892
+ setSelected(/* @__PURE__ */ new Set([id]));
893
+ c == null ? void 0 : c.beginText(id);
894
+ setText(topic.text);
895
+ setEditing(id);
896
+ } else {
897
+ if (editing) c == null ? void 0 : c.endText(editing);
898
+ setEditing(null);
899
+ queueMicrotask(() => {
900
+ var _a2;
901
+ return (_a2 = stage.current) == null ? void 0 : _a2.focus();
902
+ });
903
+ }
904
+ }
905
+ function add(kind, side, targetId = active) {
906
+ if (!c || !editable) return;
907
+ if (model.topics.length >= MIND_MAP_MAX_TOPICS) {
908
+ setNotice("单张导图最多支持 500 个主题。");
909
+ return;
910
+ }
911
+ const id = kind === "parent" ? c.addParent(targetId) : side !== void 0 && targetId === model.rootId ? c.addRootChild(side) : kind === "sibling" ? c.addSibling(targetId, "after") : c.add(targetId);
912
+ if (id) {
913
+ setFolds((previous) => {
914
+ const next = new Set(previous);
915
+ next.delete(targetId);
916
+ return next;
917
+ });
918
+ setSelected(/* @__PURE__ */ new Set([id]));
919
+ setActive(id);
920
+ c.beginText(id);
921
+ setText("新主题");
922
+ setEditing(id);
923
+ }
924
+ }
925
+ function addSiblingAt(id, placement) {
926
+ if (!c || !editable) return;
927
+ if (model.topics.length >= MIND_MAP_MAX_TOPICS) {
928
+ setNotice("单张导图最多支持 500 个主题。");
929
+ return;
930
+ }
931
+ const next = c.addSibling(id, placement);
932
+ if (next) {
933
+ setFolds((previous) => {
934
+ const nextFolds = new Set(previous);
935
+ nextFolds.delete(id);
936
+ return nextFolds;
937
+ });
938
+ setSelected(/* @__PURE__ */ new Set([next]));
939
+ setActive(next);
940
+ c.beginText(next);
941
+ setText("新主题");
942
+ setEditing(next);
943
+ }
944
+ }
945
+ function remove(targetId = active, targetSelection = selected) {
946
+ if (!c || !editable) return;
947
+ const plan = planMindTopicDeletion(model, targetSelection, targetId);
948
+ if (!plan) return;
949
+ deletionSelection.current = [...targetSelection];
950
+ deletionActive.current = targetId;
951
+ if (plan.ids.size > plan.roots.length) setConfirmDelete(plan);
952
+ else performDelete(plan, targetId);
953
+ }
954
+ function performDelete(plan, targetId = deletionActive.current) {
955
+ const next = planMindTopicDeletion((c == null ? void 0 : c.snapshot()) ?? model, deletionSelection.current, targetId);
956
+ if (!next || next.ids.size !== plan.ids.size || [...next.ids].some((id) => !plan.ids.has(id)) || !(c == null ? void 0 : c.removeMany(deletionSelection.current))) {
957
+ setNotice("主题或权限已变化,请重新选择");
958
+ return;
959
+ }
960
+ setSelected(/* @__PURE__ */ new Set([next.nextId]));
961
+ setActive(next.nextId);
962
+ setEditing(null);
963
+ setConfirmDelete(null);
964
+ setNotice(`已删除 ${plan.ids.size} 个主题,可撤销。`);
965
+ queueMicrotask(() => {
966
+ var _a2;
967
+ return (_a2 = stage.current) == null ? void 0 : _a2.focus();
968
+ });
969
+ }
970
+ function fold(id) {
971
+ if (!mindMapDescendants$1(model, id).size || id === model.rootId) return;
972
+ setFolds((previous) => {
973
+ const next = new Set(previous);
974
+ if (next.has(id)) next.delete(id);
975
+ else next.add(id);
976
+ return next;
977
+ });
978
+ }
979
+ function copy(targetId = active) {
980
+ var _a2;
981
+ if (!c) return;
982
+ copied.current = c.copyBranch(targetId);
983
+ setNotice("分支已复制,选择目标主题后粘贴。");
984
+ if (canExport) void ((_a2 = navigator.clipboard) == null ? void 0 : _a2.writeText(`YWIKI_MINDMAP_BRANCH_V1
985
+ ${JSON.stringify(copied.current)}`).catch(() => {
986
+ }));
987
+ }
988
+ async function materializeImages(source) {
989
+ var _a2, _b2;
990
+ const prepared = structuredClone(source);
991
+ const known = new Set(model.topics.flatMap((topic) => topic.attachmentId ? [topic.attachmentId] : []));
992
+ const clones = /* @__PURE__ */ new Map();
993
+ for (const node of prepared) {
994
+ const id = (_a2 = node.attrs) == null ? void 0 : _a2.attachmentId;
995
+ if (typeof id !== "string" || !id || known.has(id)) continue;
996
+ if (!(c == null ? void 0 : c.context.uploadImage)) throw new Error("当前文档不支持图片复制,请移除图片后导入");
997
+ if (!clones.has(id)) {
998
+ const fetcher = c.context.fetchAttachment ?? props.fetchAttachment ?? ((_b2 = host.attachments) == null ? void 0 : _b2.fetch);
999
+ if (!fetcher) throw new Error("当前文档未配置图片读取服务");
1000
+ const blob = await fetcher(id);
1001
+ const uploaded = await c.context.uploadImage(new File([blob], "导图主题图片.png", { type: blob.type || "image/png" }));
1002
+ clones.set(id, uploaded.id);
1003
+ }
1004
+ node.attrs.attachmentId = clones.get(id);
1005
+ }
1006
+ return prepared;
1007
+ }
1008
+ async function paste(targetId = active) {
1009
+ if (!editable || !c || pastingRef.current) return;
1010
+ pastingRef.current = true;
1011
+ setPasting(true);
1012
+ try {
1013
+ let value = copied.current;
1014
+ if (canExport) try {
1015
+ const raw = await Promise.race([navigator.clipboard.readText(), new Promise((_, reject) => setTimeout(() => reject(new Error("剪贴板读取超时")), 1500))]);
1016
+ if (raw.length < 2e6 && raw.startsWith("YWIKI_MINDMAP_BRANCH_V1\n")) value = parseMindBranch(raw);
1017
+ } catch {
1018
+ }
1019
+ await insertBranch(value, targetId);
1020
+ } catch (error) {
1021
+ if (alive.current) setNotice(error instanceof Error ? error.message : "图片复制失败");
1022
+ } finally {
1023
+ pastingRef.current = false;
1024
+ if (alive.current) setPasting(false);
1025
+ }
1026
+ }
1027
+ async function insertBranch(value, targetId) {
1028
+ var _a2;
1029
+ if (value.filter((node) => node.type === "mindMapTopic").length + model.topics.length > MIND_MAP_MAX_TOPICS) throw new Error("粘贴后主题超过 500 个,本次未修改");
1030
+ const prepared = await materializeImages(value), live = currentRef.current;
1031
+ if (!alive.current || live.c !== c || !live.editable || live.model.id !== model.id) return;
1032
+ if (!((_a2 = c == null ? void 0 : c.snapshot()) == null ? void 0 : _a2.topics.some((topic) => topic.id === targetId))) throw new Error("目标主题已移除,请重新选择");
1033
+ const id = c.pasteBranch(targetId, prepared);
1034
+ if (!id) throw new Error("没有可粘贴的分支,或主题容量超过上限");
1035
+ setNotice("已粘贴分支。");
1036
+ setFolds((previous) => {
1037
+ const next = new Set(previous);
1038
+ next.delete(targetId);
1039
+ return next;
1040
+ });
1041
+ locate(id);
1042
+ }
1043
+ async function nativePaste(event) {
1044
+ var _a2;
1045
+ if (!editable || event.target.closest('input,textarea,[contenteditable="true"]')) return;
1046
+ const raw = ((_a2 = event.clipboardData) == null ? void 0 : _a2.getData("text/plain")) ?? "";
1047
+ if (!raw.startsWith("YWIKI_MINDMAP_BRANCH_V1\n")) return;
1048
+ event.preventDefault();
1049
+ event.stopPropagation();
1050
+ try {
1051
+ if (pastingRef.current) return;
1052
+ pastingRef.current = true;
1053
+ setPasting(true);
1054
+ await insertBranch(parseMindBranch(raw), active);
1055
+ } catch (error) {
1056
+ setNotice(error instanceof Error ? error.message : "分支格式无效");
1057
+ } finally {
1058
+ pastingRef.current = false;
1059
+ if (alive.current) setPasting(false);
1060
+ }
1061
+ }
1062
+ function moveSide(side, targetId = active) {
1063
+ var _a2;
1064
+ if (c == null ? void 0 : c.moveToSide(targetId, side)) {
1065
+ setNotice(`已移到${side === -1 ? "左" : "右"}侧`);
1066
+ (_a2 = stage.current) == null ? void 0 : _a2.focus();
1067
+ }
1068
+ }
1069
+ function openContextMenu(id, event) {
1070
+ event.preventDefault();
1071
+ event.stopPropagation();
1072
+ if (id) select(id);
1073
+ setContextMenu({ id, x: event.clientX, y: event.clientY });
1074
+ }
1075
+ function menuKeydown(event) {
1076
+ var _a2, _b2;
1077
+ const items = Array.from(((_a2 = menuRef.current) == null ? void 0 : _a2.querySelectorAll('[role="menuitem"]:not([aria-disabled="true"])')) ?? []);
1078
+ if (!items.length || !["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) return;
1079
+ event.preventDefault();
1080
+ event.stopPropagation();
1081
+ const index = items.indexOf(document.activeElement);
1082
+ (_b2 = items[event.key === "Home" ? 0 : event.key === "End" ? items.length - 1 : index < 0 ? event.key === "ArrowUp" ? items.length - 1 : 0 : (index + (event.key === "ArrowUp" ? -1 : 1) + items.length) % items.length]) == null ? void 0 : _b2.focus();
1083
+ }
1084
+ function contextAction(action) {
1085
+ const id = (contextMenu == null ? void 0 : contextMenu.id) ?? active;
1086
+ setContextMenu(null);
1087
+ if (!id) return;
1088
+ setActive(id);
1089
+ if (action === "child" || action === "sibling" || action === "parent") add(action, void 0, id);
1090
+ else if (action === "rename") edit(id);
1091
+ else if (action === "properties") {
1092
+ setDetails(true);
1093
+ setComments(false);
1094
+ } else if (action === "fold") fold(id);
1095
+ else if (action === "focus") {
1096
+ setFocusId(id);
1097
+ fit(branchModel(model, id));
1098
+ } else if (action === "left") moveSide(-1, id);
1099
+ else if (action === "right") moveSide(1, id);
1100
+ else if (action === "copy") copy(id);
1101
+ else if (action === "paste") void paste((contextMenu == null ? void 0 : contextMenu.id) ? id : selected.size === 1 ? active : viewModel.rootId);
1102
+ else if (action === "delete") remove(id, /* @__PURE__ */ new Set([id]));
1103
+ else paneCommand(action);
1104
+ }
1105
+ function paneCommand(action) {
1106
+ var _a2;
1107
+ setFollowing(null);
1108
+ if (action === "quick") setQuickControls((value) => !value);
1109
+ else if (action === "grid") setGrid((value) => !value);
1110
+ else if (action === "comments") {
1111
+ setComments((value) => !value);
1112
+ setDetails(false);
1113
+ } else if (action === "zoom-in") zoomTo(zoom * 1.2);
1114
+ else if (action === "zoom-out") zoomTo(zoom / 1.2);
1115
+ else if (action === "reset-zoom") zoomTo(1);
1116
+ else if (action === "fit") fit();
1117
+ (_a2 = stage.current) == null ? void 0 : _a2.focus();
1118
+ }
1119
+ function followPeer(client) {
1120
+ cancelGesture();
1121
+ edit(null);
1122
+ setFollowing(client);
1123
+ }
1124
+ function zoomTo(value, at = { x: size.width / 2, y: size.height / 2 }) {
1125
+ const next = Math.max(5e-3, Math.min(2.5, value)), ratio = next / zoom;
1126
+ const x = at.x - (at.x - origin.x) * ratio, y = at.y - (at.y - origin.y) * ratio;
1127
+ setZoom(next);
1128
+ setPan({ x, y });
1129
+ }
1130
+ async function copyTopicLink() {
1131
+ var _a2, _b2;
1132
+ const link = (_b2 = (_a2 = host.location) == null ? void 0 : _a2.createLink) == null ? void 0 : _b2.call(_a2, { blockId: model.id, topicId: active });
1133
+ if (!link) {
1134
+ setNotice("宿主未提供主题定位链接");
1135
+ return;
1136
+ }
1137
+ try {
1138
+ await navigator.clipboard.writeText(link);
1139
+ setNotice("已复制主题定位链接");
1140
+ } catch {
1141
+ setNotice(link);
1142
+ }
1143
+ }
1144
+ function keydown(event) {
1145
+ var _a2, _b2, _c2, _d2;
1146
+ if (!((_a2 = root.current) == null ? void 0 : _a2.contains(event.target)) || event.defaultPrevented || event.nativeEvent.isComposing || event.keyCode === 229 || event.target.closest("input,textarea,[contenteditable=true]")) return;
1147
+ const command = event.ctrlKey || event.metaKey;
1148
+ const view = mindCanvasShortcut(event);
1149
+ if (event.target.closest("button,select,[role=combobox]") && !view && !command) return;
1150
+ if (event.code === "Space") {
1151
+ event.preventDefault();
1152
+ space.current = true;
1153
+ setSpaceHeld(true);
1154
+ return;
1155
+ }
1156
+ if (event.key === "Escape") {
1157
+ if (!props.inline && !details && !comments && !showSearch) return;
1158
+ event.preventDefault();
1159
+ event.stopPropagation();
1160
+ cancelGesture();
1161
+ setContextMenu(null);
1162
+ setSelected(/* @__PURE__ */ new Set());
1163
+ setDetails(false);
1164
+ setComments(false);
1165
+ setShowSearch(false);
1166
+ return;
1167
+ }
1168
+ if (command && event.key.toLowerCase() === "z" && editable) {
1169
+ event.preventDefault();
1170
+ event.shiftKey ? c == null ? void 0 : c.redo() : c == null ? void 0 : c.undo();
1171
+ return;
1172
+ }
1173
+ if (command && event.key.toLowerCase() === "y" && editable) {
1174
+ event.preventDefault();
1175
+ c == null ? void 0 : c.redo();
1176
+ return;
1177
+ }
1178
+ if (command && event.key.toLowerCase() === "f") {
1179
+ event.preventDefault();
1180
+ setShowSearch(true);
1181
+ return;
1182
+ }
1183
+ if (command && event.key.toLowerCase() === "c" && editable && selected.size === 1) {
1184
+ event.preventDefault();
1185
+ copy();
1186
+ return;
1187
+ }
1188
+ if (command && event.key.toLowerCase() === "v" && editable) {
1189
+ event.preventDefault();
1190
+ void paste();
1191
+ return;
1192
+ }
1193
+ if ((command || event.altKey) && event.key === ".") {
1194
+ event.preventDefault();
1195
+ fold(active);
1196
+ return;
1197
+ }
1198
+ if (view) {
1199
+ event.preventDefault();
1200
+ paneCommand(view);
1201
+ return;
1202
+ }
1203
+ if ((event.key === "Delete" || event.key === "Backspace") && editable && !command && !event.altKey && selected.size) {
1204
+ event.preventDefault();
1205
+ if (!event.repeat) remove();
1206
+ return;
1207
+ }
1208
+ if (!editable || selected.size !== 1) return;
1209
+ if (event.key === "Tab") {
1210
+ event.preventDefault();
1211
+ add(event.shiftKey ? "parent" : "child");
1212
+ } else if (event.key === "Enter") {
1213
+ event.preventDefault();
1214
+ add("sibling");
1215
+ } else if (event.key === "F2") {
1216
+ event.preventDefault();
1217
+ edit(active);
1218
+ } else if (event.altKey && ["ArrowUp", "ArrowDown"].includes(event.key)) {
1219
+ const siblings = tree.filter((topic) => topic.parentId === current.parentId), index = siblings.findIndex((topic) => topic.id === active), target = siblings[index + (event.key === "ArrowUp" ? -1 : 1)];
1220
+ if (target) c == null ? void 0 : c.move(active, target.id, event.key === "ArrowUp" ? "before" : "after");
1221
+ event.preventDefault();
1222
+ } else if (event.key.startsWith("Arrow")) {
1223
+ event.preventDefault();
1224
+ const branchSide = ((_b2 = drawing.nodes.find((topic) => topic.id === active)) == null ? void 0 : _b2.side) ?? 1;
1225
+ const inward = model.layout === "down" ? "ArrowUp" : branchSide === 1 ? "ArrowLeft" : "ArrowRight";
1226
+ const outward = model.layout === "down" ? "ArrowDown" : branchSide === 1 ? "ArrowRight" : "ArrowLeft";
1227
+ const siblings = drawing.nodes.filter((topic) => topic.parentId === current.parentId), index = siblings.findIndex((topic) => topic.id === active);
1228
+ const target = event.key === inward ? current.parentId : event.key === outward ? (_c2 = drawing.nodes.find((topic) => topic.parentId === active)) == null ? void 0 : _c2.id : (_d2 = siblings[index + (event.key === "ArrowUp" || event.key === "ArrowLeft" ? -1 : 1)]) == null ? void 0 : _d2.id;
1229
+ if (target) select(target);
1230
+ }
1231
+ }
1232
+ function cancelGesture(restore = true) {
1233
+ const current2 = gesture.current;
1234
+ if (restore && (current2 == null ? void 0 : current2.kind) === "box") {
1235
+ setSelected(current2.selected);
1236
+ setActive(current2.active);
1237
+ }
1238
+ gesture.current = null;
1239
+ setBox(null);
1240
+ setDrop(null);
1241
+ setDragPreview(null);
1242
+ }
1243
+ function pointerDown(event, id) {
1244
+ var _a2, _b2;
1245
+ if (!((_a2 = stage.current) == null ? void 0 : _a2.contains(event.target))) return;
1246
+ if (event.target.closest("button,input,textarea,a")) return;
1247
+ setFollowing(null);
1248
+ setContextMenu(null);
1249
+ const base = { x: event.clientX, y: event.clientY, lastX: event.clientX, lastY: event.clientY, doc: JSON.stringify(model), count: selected.size, selected: new Set(selected), active };
1250
+ if (id && event.button === 0 && !moving && !space.current) {
1251
+ const additive = event.shiftKey || event.metaKey || event.ctrlKey;
1252
+ const next = selected.has(id) && selected.size > 1 && !additive ? selected : selectMindTopic(selected, id, additive);
1253
+ setSelected(next);
1254
+ setActive(next.has(id) ? id : [...next].at(-1) ?? model.rootId);
1255
+ gesture.current = { ...base, kind: "node", id, count: next.size, additive };
1256
+ } else if (event.button === 1 || event.button === 0 && (moving || space.current)) gesture.current = { ...base, kind: "pan" };
1257
+ else if (!id && event.button === 0) {
1258
+ gesture.current = { ...base, kind: "box", additive: event.shiftKey || event.metaKey || event.ctrlKey };
1259
+ if (!gesture.current.additive) setSelected(/* @__PURE__ */ new Set());
1260
+ } else return;
1261
+ event.currentTarget.setPointerCapture(event.pointerId);
1262
+ (_b2 = stage.current) == null ? void 0 : _b2.focus();
1263
+ event.preventDefault();
1264
+ }
1265
+ function pointerMove(event) {
1266
+ const g = gesture.current;
1267
+ if (!g) return;
1268
+ if (g.doc !== JSON.stringify(currentRef.current.model)) {
1269
+ cancelGesture();
1270
+ return;
1271
+ }
1272
+ if (g.kind === "pan") {
1273
+ const dx = event.clientX - g.lastX, dy = event.clientY - g.lastY;
1274
+ setPan((previous) => ({ x: previous.x + dx, y: previous.y + dy }));
1275
+ } else if (g.kind === "box") {
1276
+ const from = point(g.x, g.y), to = point(event.clientX, event.clientY);
1277
+ g.box = { x: Math.min(from.x, to.x), y: Math.min(from.y, to.y), w: Math.abs(to.x - from.x), h: Math.abs(to.y - from.y) };
1278
+ setBox(g.box);
1279
+ setSelected(topicsInMarquee(drawing.nodes, { x: g.box.x, y: g.box.y, width: g.box.w, height: g.box.h }, g.additive ? g.selected : []));
1280
+ } else if (editable && g.id && g.id !== model.rootId && g.count === 1 && Math.hypot(event.clientX - g.x, event.clientY - g.y) > 8) {
1281
+ g.drop = mindMapDrop(viewModel, drawing, g.id, point(event.clientX, event.clientY), !focusId);
1282
+ setDrop(g.drop);
1283
+ setDragPreview({ id: g.id, dx: (event.clientX - g.x) / zoom, dy: (event.clientY - g.y) / zoom });
1284
+ }
1285
+ g.lastX = event.clientX;
1286
+ g.lastY = event.clientY;
1287
+ }
1288
+ function pointerUp() {
1289
+ const g = gesture.current;
1290
+ if (!g) return;
1291
+ cancelGesture(false);
1292
+ if (g.doc !== JSON.stringify(currentRef.current.model)) return;
1293
+ const bounds = g.box;
1294
+ if (g.kind === "box" && bounds) {
1295
+ const ids = topicsInMarquee(drawing.nodes, { x: bounds.x, y: bounds.y, width: bounds.w, height: bounds.h }, g.additive ? g.selected : []);
1296
+ setSelected(ids);
1297
+ if (ids.size) setActive([...ids].at(-1));
1298
+ } else if (g.kind === "node" && g.id && g.drop && editable) {
1299
+ if (g.drop.kind === "side") c == null ? void 0 : c.moveToSide(g.id, g.drop.side, g.drop.beforeId);
1300
+ else c == null ? void 0 : c.move(g.id, g.drop.id, g.drop.mode);
1301
+ } else if (g.kind === "node" && g.id && g.count > 1 && !g.additive && Math.hypot(g.lastX - g.x, g.lastY - g.y) < 8) {
1302
+ setSelected(/* @__PURE__ */ new Set([g.id]));
1303
+ setActive(g.id);
1304
+ }
1305
+ }
1306
+ async function exportAs(kind) {
1307
+ var _a2, _b2;
1308
+ if (!canExport || exportRunning.current) return;
1309
+ exportRunning.current = true;
1310
+ setBusy(true);
1311
+ const target = exportBranch ? branchModel(model, active) : model;
1312
+ const printWindow = kind === "print" ? window.open("", "_blank") : null;
1313
+ try {
1314
+ if (kind === "copy") {
1315
+ await navigator.clipboard.writeText(mindMapMarkdown(target));
1316
+ return;
1317
+ }
1318
+ const images = {};
1319
+ for (const topic of target.topics) if (topic.attachmentId) {
1320
+ const fetcher = props.fetchAttachment ?? (c == null ? void 0 : c.context.fetchAttachment) ?? ((_a2 = host.attachments) == null ? void 0 : _a2.fetch);
1321
+ if (!fetcher) throw new Error("未配置主题图片读取服务");
1322
+ const blob = await fetcher(topic.attachmentId);
1323
+ images[topic.attachmentId] = await new Promise((resolve, reject) => {
1324
+ const reader = new FileReader();
1325
+ reader.onload = () => resolve(String(reader.result));
1326
+ reader.onerror = reject;
1327
+ reader.readAsDataURL(blob);
1328
+ });
1329
+ }
1330
+ const svg = mindMapSvg(target, { transparent, images }), download = (blob, ext) => {
1331
+ const url = URL.createObjectURL(blob), a = document.createElement("a");
1332
+ a.href = url;
1333
+ a.download = `思维导图.${ext}`;
1334
+ a.click();
1335
+ setTimeout(() => URL.revokeObjectURL(url), 1e3);
1336
+ };
1337
+ if (kind === "svg") download(new Blob([svg], { type: "image/svg+xml" }), "svg");
1338
+ else if (kind === "md") download(new Blob([mindMapMarkdown(target)], { type: "text/markdown" }), "md");
1339
+ else if (kind === "json") download(new Blob([JSON.stringify(mindMapToJson(target), null, 2)], { type: "application/json" }), "json");
1340
+ else if (kind === "png" || kind === "copy-image" || kind === "print") {
1341
+ const image = new Image(), url = URL.createObjectURL(new Blob([svg], { type: "image/svg+xml" }));
1342
+ try {
1343
+ await new Promise((resolve, reject) => {
1344
+ image.onload = () => resolve();
1345
+ image.onerror = reject;
1346
+ image.src = url;
1347
+ });
1348
+ const canvas = document.createElement("canvas");
1349
+ canvas.width = image.width * imageScale;
1350
+ canvas.height = image.height * imageScale;
1351
+ (_b2 = canvas.getContext("2d")) == null ? void 0 : _b2.drawImage(image, 0, 0, canvas.width, canvas.height);
1352
+ const blob = await new Promise((resolve, reject) => canvas.toBlob((value) => value ? resolve(value) : reject(new Error("图片生成失败"))));
1353
+ if (kind === "copy-image") await navigator.clipboard.write([new ClipboardItem({ "image/png": blob })]);
1354
+ else if (kind === "print") {
1355
+ if (!printWindow) throw new Error("打印窗口被浏览器拦截");
1356
+ const img = printWindow.document.createElement("img");
1357
+ img.src = canvas.toDataURL();
1358
+ img.style.maxWidth = "100%";
1359
+ printWindow.document.body.append(img);
1360
+ img.onload = () => printWindow.print();
1361
+ } else download(blob, "png");
1362
+ } finally {
1363
+ URL.revokeObjectURL(url);
1364
+ }
1365
+ }
1366
+ } catch (error) {
1367
+ printWindow == null ? void 0 : printWindow.close();
1368
+ setNotice(String(error));
1369
+ } finally {
1370
+ exportRunning.current = false;
1371
+ if (alive.current) setBusy(false);
1372
+ }
1373
+ }
1374
+ const directions = mindMapBranchSides(model), firstLevel = current.parentId === model.rootId;
1375
+ const menuTopic = tree.find((topic) => topic.id === (contextMenu == null ? void 0 : contextMenu.id));
1376
+ const modifier = typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform) ? "⌘" : "Ctrl";
1377
+ const contextGroups = (contextMenu == null ? void 0 : contextMenu.id) ? [{ items: [
1378
+ ...editable ? [
1379
+ { value: "child", label: "添加子主题" },
1380
+ { value: "sibling", label: "添加同级主题" },
1381
+ ...contextMenu.id !== model.rootId ? [{ value: "parent", label: "插入父主题" }] : [],
1382
+ { value: "rename", label: "修改文字" }
1383
+ ] : [],
1384
+ { value: "properties", label: "主题属性" },
1385
+ ...contextMenu.id !== model.rootId && mindMapDescendants$1(model, contextMenu.id).size > 1 ? [{ value: "fold", label: folds.has(contextMenu.id) ? "展开分支" : "收起分支" }] : [],
1386
+ ...editable && (menuTopic == null ? void 0 : menuTopic.parentId) === model.rootId && model.layout !== "down" ? [
1387
+ { value: "left", label: "移到左侧", disabled: directions.get(contextMenu.id) === -1 },
1388
+ { value: "right", label: "移到右侧", disabled: directions.get(contextMenu.id) === 1 }
1389
+ ] : [],
1390
+ { value: "focus", label: "聚焦分支" },
1391
+ ...editable ? [
1392
+ { value: "copy", label: "复制分支" },
1393
+ { value: "paste", label: "粘贴分支", disabled: pasting },
1394
+ ...contextMenu.id !== model.rootId ? [{ value: "delete", label: "删除分支" }] : []
1395
+ ] : []
1396
+ ] }] : [
1397
+ ...editable ? [{ items: [{ value: "paste", label: "粘贴", disabled: pasting, shortcut: "⌘ / Ctrl+V" }] }] : [],
1398
+ { items: [
1399
+ ...pageId ? [{ value: "comments", label: comments ? "隐藏评论" : "显示评论", shortcut: "Shift+C" }] : [],
1400
+ ...editable ? [{ value: "quick", label: quickControls ? "隐藏快捷创建" : "显示快捷创建", shortcut: "Shift+Q" }] : [],
1401
+ { value: "grid", label: grid ? "隐藏网格" : "显示网格", shortcut: "Shift+G" }
1402
+ ] },
1403
+ { items: [
1404
+ { value: "zoom-in", label: "放大", shortcut: `${modifier} + +` },
1405
+ { value: "zoom-out", label: "缩小", shortcut: `${modifier} + −` },
1406
+ { value: "reset-zoom", label: "缩放至 100%", shortcut: `${modifier} + 0` },
1407
+ { value: "fit", label: "画布全览", shortcut: "Shift+1" }
1408
+ ] }
1409
+ ];
1410
+ const workspace = /* @__PURE__ */ jsxs("div", { className: "mind-map-workspace", ref: root, onKeyDown: keydown, onPaste: nativePaste, style: { "--mind-color": color }, children: [
1411
+ editable && !status && props.showSaveHint !== false && /* @__PURE__ */ jsx(WAlert, { closable: true, closeLabel: "关闭保存提示", className: "mind-save-hint", children: "编辑完成后,请确认已保存再离开。" }),
1412
+ /* @__PURE__ */ jsxs("header", { className: "mind-canvas-toolbar", children: [
1413
+ /* @__PURE__ */ jsxs("div", { className: "mind-canvas-tools", children: [
1414
+ !props.inline && props.onClose && /* @__PURE__ */ jsx(WButton, { onClick: props.onClose, children: "返回文档" }),
1415
+ /* @__PURE__ */ jsx(
1416
+ WDropdown,
1417
+ {
1418
+ label: "展开与收起",
1419
+ groups: [{ items: [{ value: "expand", label: "全部展开" }, { value: "first-level", label: "收起至一级" }] }],
1420
+ onSelect: (value) => setFolds(value === "expand" ? /* @__PURE__ */ new Set() : firstLevelMindFolds(viewModel))
1421
+ }
1422
+ ),
1423
+ /* @__PURE__ */ jsx(WButton, { ref: settingsTrigger, "aria-expanded": settingsOpen, onClick: () => setSettingsOpen(!settingsOpen), children: "视图与导出设置" }),
1424
+ settingsOpen && /* @__PURE__ */ jsx(AnchoredPanel, { anchor: settingsTrigger.current, onClose: () => setSettingsOpen(false), align: "center", gap: 6, label: "视图与导出设置", className: "mind-dropdown-popup", children: /* @__PURE__ */ jsxs("div", { className: "mind-settings-menu", children: [
1425
+ peers.map((peer) => {
1426
+ var _a2, _b2;
1427
+ return /* @__PURE__ */ jsxs("span", { className: "mind-peer", children: [
1428
+ /* @__PURE__ */ jsxs("span", { children: [
1429
+ peer.name,
1430
+ peer.editing ? " 正在编辑" : " 正在查看",
1431
+ " ",
1432
+ (_b2 = (_a2 = model.topics.find((topic) => topic.id === peer.topicId)) == null ? void 0 : _a2.text) == null ? void 0 : _b2.slice(0, 12)
1433
+ ] }),
1434
+ /* @__PURE__ */ jsx(WButton, { variant: "text", onClick: () => followPeer(peer.client), children: "跟随" })
1435
+ ] }, peer.client);
1436
+ }),
1437
+ following !== null && /* @__PURE__ */ jsx(WButton, { onClick: () => followPeer(null), children: "停止跟随" }),
1438
+ /* @__PURE__ */ jsx(WButton, { variant: "text", onClick: () => {
1439
+ const id = focusId ? null : active;
1440
+ setFocusId(id);
1441
+ fit(id ? branchModel(model, id) : model);
1442
+ }, children: focusId ? "返回全图" : "聚焦分支" }),
1443
+ /* @__PURE__ */ jsx(WButton, { variant: "text", onClick: () => void copyTopicLink(), children: "复制主题链接" }),
1444
+ editable && /* @__PURE__ */ jsx(WSelect, { label: "分支线型", ariaLabel: "分支线型", width: 95, value: model.branchStyle ?? "curve", onChange: (value) => c == null ? void 0 : c.settings({ branchStyle: value }), options: ["curve", "straight", "step"].map((value, i) => ({ value, label: ["曲线", "直线", "折线"][i] })) }),
1445
+ canExport && /* @__PURE__ */ jsxs(Fragment, { children: [
1446
+ /* @__PURE__ */ jsxs("label", { children: [
1447
+ /* @__PURE__ */ jsx("input", { type: "checkbox", checked: exportBranch, onChange: (event) => setExportBranch(event.target.checked) }),
1448
+ "仅导出选中分支"
1449
+ ] }),
1450
+ /* @__PURE__ */ jsxs("label", { children: [
1451
+ /* @__PURE__ */ jsx("input", { type: "checkbox", checked: transparent, onChange: (event) => setTransparent(event.target.checked) }),
1452
+ "透明背景"
1453
+ ] }),
1454
+ /* @__PURE__ */ jsx(WSelect, { label: "图片分辨率", ariaLabel: "图片分辨率", width: 90, value: imageScale, onChange: (value) => setImageScale(Number(value)), options: [1, 2, 3].map((value) => ({ value, label: `${value} 倍图片` })) })
1455
+ ] }),
1456
+ canExport && /* @__PURE__ */ jsxs(Fragment, { children: [
1457
+ /* @__PURE__ */ jsx(WButton, { variant: "text", onClick: () => void exportAs("copy-image"), children: "复制图片" }),
1458
+ /* @__PURE__ */ jsx(WButton, { variant: "text", onClick: () => void exportAs("print"), children: "打印 / PDF" })
1459
+ ] })
1460
+ ] }) }),
1461
+ peers.length > 0 && /* @__PURE__ */ jsx(
1462
+ WDropdown,
1463
+ {
1464
+ label: `协作(${peers.length})`,
1465
+ buttonProps: { variant: "text" },
1466
+ groups: [{ items: peers.map((peer) => ({ value: String(peer.client), label: `${peer.name}${peer.editing ? " 正在编辑" : " 正在查看"} · 跟随` })) }],
1467
+ onSelect: (value) => followPeer(Number(value))
1468
+ }
1469
+ )
1470
+ ] }),
1471
+ /* @__PURE__ */ jsxs("div", { className: "mind-canvas-tools mind-canvas-options", children: [
1472
+ status || !editable ? /* @__PURE__ */ jsx("span", { className: "mind-canvas-status", role: "status", "aria-label": "保存状态", children: status || "只读" }) : null,
1473
+ editable && /* @__PURE__ */ jsxs(Fragment, { children: [
1474
+ /* @__PURE__ */ jsx(WSelect, { label: "导图布局", ariaLabel: "导图布局", width: 94, value: model.layout, onChange: (value) => c == null ? void 0 : c.settings({ layout: value }), options: ["right", "left", "both", "down"].map((value, i) => ({ value, label: ["向右", "向左", "双侧", "向下"][i] })) }),
1475
+ /* @__PURE__ */ jsx(WSelect, { label: "导图主题", ariaLabel: "导图主题", width: 94, value: model.theme, onChange: (value) => c == null ? void 0 : c.settings({ theme: value }), options: ["blue", "teal", "violet", "amber"].map((value, i) => ({ value, label: ["靛蓝", "青绿", "紫藤", "琥珀"][i] })) }),
1476
+ /* @__PURE__ */ jsx(WSelect, { label: "正文预览高度", ariaLabel: "正文预览高度", width: 114, value: model.height, onChange: (value) => c == null ? void 0 : c.settings({ height: Number(value) }), options: [280, 380, 520].map((value, index) => ({ value, label: ["预览 · 紧凑", "预览 · 标准", "预览 · 宽松"][index] })) })
1477
+ ] }),
1478
+ /* @__PURE__ */ jsx(WButton, { onClick: () => setShowSearch(!showSearch), children: "查找替换" }),
1479
+ !editable && host.comments && pageId && /* @__PURE__ */ jsx(WButton, { variant: comments ? "primary" : "default", "aria-pressed": comments, onClick: () => {
1480
+ setComments(!comments);
1481
+ setDetails(false);
1482
+ }, children: comments ? "收起讨论" : "查看讨论" }),
1483
+ /* @__PURE__ */ jsx(WDropdown, { label: "更多", groups: [{ items: [
1484
+ { value: "outline", label: outline ? "隐藏文字大纲" : "显示文字大纲" },
1485
+ { value: "details", label: "主题属性" },
1486
+ ...host.comments && pageId ? [{ value: "comments", label: comments ? "隐藏主题讨论" : "主题讨论" }] : [],
1487
+ ...editable ? [{ value: "import", label: "导入" }] : []
1488
+ ] }], onSelect: (value) => {
1489
+ if (value === "outline") setOutline(!outline);
1490
+ else if (value === "details") {
1491
+ setDetails(!details);
1492
+ setComments(false);
1493
+ } else if (value === "comments") {
1494
+ setComments(!comments);
1495
+ setDetails(false);
1496
+ } else if (value === "import") setImportOpen(true);
1497
+ } }),
1498
+ canExport && /* @__PURE__ */ jsx(
1499
+ WSelect,
1500
+ {
1501
+ label: "导出",
1502
+ ariaLabel: "导出思维导图",
1503
+ width: 105,
1504
+ value: "",
1505
+ disabled: busy,
1506
+ onChange: (value) => void exportAs(value),
1507
+ options: [{ value: "png", label: "PNG 图片" }, { value: "svg", label: "SVG 图片" }, { value: "md", label: "文字大纲" }, { value: "json", label: "结构 JSON" }]
1508
+ }
1509
+ )
1510
+ ] })
1511
+ ] }),
1512
+ showSearch && /* @__PURE__ */ jsxs("div", { className: "mind-search", "aria-label": "图内查找替换", children: [
1513
+ /* @__PURE__ */ jsx("input", { "aria-label": "查找导图文字", placeholder: "查找主题、描述和备注", value: query, onChange: (event) => {
1514
+ setQuery(event.target.value);
1515
+ setHitIndex(0);
1516
+ }, onKeyDown: (event) => {
1517
+ if (event.key === "Enter") {
1518
+ event.preventDefault();
1519
+ jumpHit(1);
1520
+ }
1521
+ } }),
1522
+ /* @__PURE__ */ jsxs("span", { children: [
1523
+ hits.length > 5e3 ? "5000+" : hits.length,
1524
+ " 处"
1525
+ ] }),
1526
+ /* @__PURE__ */ jsx(WButton, { disabled: !hits.length, onClick: () => jumpHit(-1), children: "上一处" }),
1527
+ /* @__PURE__ */ jsx(WButton, { disabled: !hits.length, onClick: () => jumpHit(1), children: "下一处" }),
1528
+ hits.length > 0 && /* @__PURE__ */ jsx(
1529
+ WSelect,
1530
+ {
1531
+ label: "导图搜索结果",
1532
+ ariaLabel: "导图搜索结果",
1533
+ width: 180,
1534
+ value: hitIndex,
1535
+ options: hits.slice(0, 500).map((hit, index) => {
1536
+ var _a2, _b2;
1537
+ return { value: index, label: `${index + 1}. ${((_b2 = (_a2 = tree.find((topic) => topic.id === hit.id)) == null ? void 0 : _a2.text) == null ? void 0 : _b2.slice(0, 24)) ?? ""} · ${hit.field === "title" ? "标题" : hit.field === "note" ? "备注" : "描述"}` };
1538
+ }),
1539
+ onChange: (value) => {
1540
+ const index = Number(value);
1541
+ const hit = hits[index];
1542
+ if (hit) {
1543
+ setHitIndex(index);
1544
+ locateHit(hit);
1545
+ }
1546
+ }
1547
+ }
1548
+ ),
1549
+ editable && /* @__PURE__ */ jsxs(Fragment, { children: [
1550
+ /* @__PURE__ */ jsx("input", { "aria-label": "替换为", placeholder: "替换为", value: replacement, onChange: (event) => setReplacement(event.target.value) }),
1551
+ /* @__PURE__ */ jsx(WButton, { disabled: !hits.length, onClick: () => {
1552
+ const count = c == null ? void 0 : c.replace(query, replacement, hits[hitIndex]);
1553
+ setNotice(count === -1 ? "匹配超过 5000 处,请缩小查找范围" : count === -2 ? "替换后文字超过上限,本次未修改" : `已替换 ${count ?? 0} 处`);
1554
+ }, children: "替换当前" }),
1555
+ /* @__PURE__ */ jsx(WButton, { disabled: !hits.length, onClick: () => {
1556
+ const count = c == null ? void 0 : c.replace(query, replacement);
1557
+ setNotice(count === -1 ? "匹配超过 5000 处,请缩小查找范围" : count === -2 ? "替换后文字超过上限,本次未修改" : `已替换 ${count ?? 0} 处`);
1558
+ }, children: "全部替换" })
1559
+ ] }),
1560
+ /* @__PURE__ */ jsx(WButton, { variant: "text", onClick: () => setShowSearch(false), children: "关闭" })
1561
+ ] }),
1562
+ /* @__PURE__ */ jsxs("div", { className: "mind-canvas-body", children: [
1563
+ outline && /* @__PURE__ */ jsx("aside", { className: "mind-canvas-outline", "aria-label": "导图文字大纲", children: mindMapOutline(model).map((topic) => /* @__PURE__ */ jsxs("div", { className: `mind-outline-row${topic.id === active ? " current" : ""}`, style: { paddingLeft: 8 + Math.min(12, topic.depth) * 14 }, children: [
1564
+ editable ? /* @__PURE__ */ jsx(
1565
+ MindMapField,
1566
+ {
1567
+ id: topic.id,
1568
+ field: "title",
1569
+ value: topic.text,
1570
+ controller: c,
1571
+ label: `大纲主题 ${topic.text || "未命名"}`,
1572
+ onFocus: () => {
1573
+ setActive(topic.id);
1574
+ setSelected(/* @__PURE__ */ new Set([topic.id]));
1575
+ },
1576
+ onCommand: (event) => {
1577
+ if (event.key === "Tab") {
1578
+ event.preventDefault();
1579
+ c == null ? void 0 : c.indent(topic.id, event.shiftKey);
1580
+ } else if (event.key === "Enter" && !event.shiftKey) {
1581
+ event.preventDefault();
1582
+ add("sibling", void 0, topic.id);
1583
+ }
1584
+ }
1585
+ }
1586
+ ) : /* @__PURE__ */ jsx("button", { type: "button", onClick: () => locate(topic.id), children: topic.text }),
1587
+ /* @__PURE__ */ jsx("button", { type: "button", title: "定位主题", "aria-label": `定位大纲主题:${topic.text}`, onClick: () => locate(topic.id), children: "⌖" })
1588
+ ] }, topic.id)) }),
1589
+ /* @__PURE__ */ jsxs(
1590
+ "div",
1591
+ {
1592
+ ref: stage,
1593
+ tabIndex: 0,
1594
+ "aria-label": "思维导图画布",
1595
+ className: `mind-canvas-stage${grid ? "" : " mind-grid-hidden"}${moving || spaceHeld ? " mind-space-pan" : ""}`,
1596
+ onPointerDown: (event) => pointerDown(event),
1597
+ onPointerMove: pointerMove,
1598
+ onPointerUp: pointerUp,
1599
+ onPointerCancel: () => cancelGesture(),
1600
+ onLostPointerCapture: () => cancelGesture(),
1601
+ onContextMenu: (event) => {
1602
+ var _a2;
1603
+ const id = ((_a2 = event.target.closest("[data-topic-id]")) == null ? void 0 : _a2.dataset.topicId) ?? null;
1604
+ openContextMenu(id, event);
1605
+ },
1606
+ onWheel: (event) => {
1607
+ setFollowing(null);
1608
+ if (event.ctrlKey || event.metaKey) {
1609
+ const rect = stage.current.getBoundingClientRect();
1610
+ zoomTo(zoom * Math.exp(-event.deltaY * 2e-3), { x: event.clientX - rect.left, y: event.clientY - rect.top });
1611
+ } else setPan((value) => ({ x: value.x - event.deltaX, y: value.y - event.deltaY }));
1612
+ },
1613
+ children: [
1614
+ /* @__PURE__ */ jsx("div", { className: "mind-canvas-surface", children: /* @__PURE__ */ jsxs("div", { className: "mind-canvas-layers", style: { transform: `translate(${origin.x}px,${origin.y}px) scale(${zoom})` }, children: [
1615
+ /* @__PURE__ */ jsxs("svg", { className: "mind-canvas-edges", children: [
1616
+ drawing.edges.map((edge) => /* @__PURE__ */ jsx("path", { d: edge.path, className: draggedIds.has(edge.target) ? "mind-drag-branch-edge" : void 0, stroke: color, strokeWidth: 2, fill: "none" }, edge.id)),
1617
+ mindRelationPaths(model, drawing).map((relation) => /* @__PURE__ */ jsxs("g", { children: [
1618
+ /* @__PURE__ */ jsx("path", { d: relation.path, stroke: "#9a68d4", strokeWidth: 2, strokeDasharray: "6 4", fill: "none" }),
1619
+ /* @__PURE__ */ jsx("text", { x: relation.x, y: relation.y, fill: "var(--color-text)", fontSize: 12, children: relation.label || { related: "相关", depends: "依赖", reference: "参考" }[relation.kind] })
1620
+ ] }, relation.id)),
1621
+ projection && /* @__PURE__ */ jsxs("g", { className: "mind-side-projection", children: [
1622
+ projection.edges.filter((edge) => draggedIds.has(edge.source) || draggedIds.has(edge.target)).map((edge) => /* @__PURE__ */ jsx("path", { d: edge.path, stroke: color, fill: "none", strokeWidth: 2, strokeDasharray: "5 4" }, edge.id)),
1623
+ projection.nodes.filter((topic) => draggedIds.has(topic.id)).map((topic) => /* @__PURE__ */ jsxs("g", { children: [
1624
+ /* @__PURE__ */ jsx("rect", { x: topic.x, y: topic.y, width: topic.width, height: topic.height, rx: 8, fill: "var(--color-accent-soft)", stroke: color, strokeDasharray: "5 4" }),
1625
+ /* @__PURE__ */ jsx("text", { x: topic.x + topic.width / 2, y: topic.y + topic.height / 2 + 5, textAnchor: "middle", fontSize: 14, fill: "var(--color-text)", children: topic.text.slice(0, 24) })
1626
+ ] }, topic.id))
1627
+ ] })
1628
+ ] }),
1629
+ drawing.nodes.map((topic) => {
1630
+ const hasChildren = tree.some((child) => child.parentId === topic.id);
1631
+ const quick = quickControls && !moving && !spaceHeld && !dragPreview && !box && editable && selected.has(topic.id) && selected.size === 1 && editing !== topic.id;
1632
+ const side = topic.side ?? 1;
1633
+ const grows = model.layout === "down" ? "grows-down" : side === -1 ? "grows-left" : "";
1634
+ return /* @__PURE__ */ jsxs(
1635
+ "div",
1636
+ {
1637
+ "data-topic-id": topic.id,
1638
+ className: `mind-topic-shell${topic.id === model.rootId ? " root" : ""}${selected.has(topic.id) ? " is-selected" : ""}${hasChildren ? " has-children" : ""}${grows ? ` ${grows}` : ""}${folds.has(topic.id) ? " is-collapsed" : ""}`,
1639
+ style: { position: "absolute", left: topic.x, top: topic.y, width: topic.width, height: topic.height, transform: dragPreview && draggedIds.has(topic.id) ? `translate(${dragPreview.dx}px,${dragPreview.dy}px)` : void 0, opacity: dragPreview && draggedIds.has(topic.id) ? 0.35 : void 0 },
1640
+ children: [
1641
+ /* @__PURE__ */ jsxs(
1642
+ "div",
1643
+ {
1644
+ className: `mind-topic${topic.id === model.rootId ? " root" : ""}${selected.has(topic.id) ? " active" : ""}${editing === topic.id ? " editing" : ""}${grows ? ` ${grows}` : ""}${(drop == null ? void 0 : drop.id) === topic.id ? ` drop mind-drop-${drop.mode}` : ""}`,
1645
+ style: {
1646
+ width: "100%",
1647
+ minHeight: topic.height,
1648
+ fontFamily: MIND_TOPIC_FONT,
1649
+ "--mind-topic-line-height": `${mindTopicLineHeight(topic.fontSize || 14)}px`,
1650
+ color: topic.color || (topic.shape === "text" ? "var(--color-text)" : topic.background ? readableTextColor(topic.background) : void 0),
1651
+ background: topic.shape === "text" ? "transparent" : topic.background || void 0,
1652
+ borderRadius: topic.shape === "pill" ? 28 : void 0,
1653
+ border: topic.shape === "text" ? 0 : void 0,
1654
+ fontSize: topic.fontSize || 14,
1655
+ textAlign: topic.align || "center"
1656
+ },
1657
+ onPointerDown: (event) => {
1658
+ event.stopPropagation();
1659
+ pointerDown(event, topic.id);
1660
+ },
1661
+ onDoubleClick: () => edit(topic.id),
1662
+ onContextMenu: (event) => openContextMenu(topic.id, event),
1663
+ children: [
1664
+ (topic.icon || topic.done) && /* @__PURE__ */ jsxs("span", { className: "mind-topic-icon", children: [
1665
+ topic.done ? "☑ " : "",
1666
+ topic.icon
1667
+ ] }),
1668
+ editing === topic.id ? /* @__PURE__ */ jsx(
1669
+ "textarea",
1670
+ {
1671
+ ref: input,
1672
+ className: "mind-topic-input",
1673
+ "aria-label": "主题文字",
1674
+ rows: Math.max(1, topic.lines.length),
1675
+ maxLength: 2e3,
1676
+ value: text,
1677
+ onChange: (event) => {
1678
+ if (c == null ? void 0 : c.text(topic.id, event.target.value)) setText(event.target.value);
1679
+ },
1680
+ onSelect: (event) => {
1681
+ const target = event.currentTarget;
1682
+ setSelectedRange({ from: target.selectionStart ?? 0, to: target.selectionEnd ?? 0 });
1683
+ },
1684
+ onKeyUp: (event) => {
1685
+ const target = event.currentTarget;
1686
+ setSelectedRange({ from: target.selectionStart ?? 0, to: target.selectionEnd ?? 0 });
1687
+ },
1688
+ onCompositionStart: () => {
1689
+ composing.current = true;
1690
+ c == null ? void 0 : c.composition(true);
1691
+ },
1692
+ onCompositionEnd: (event) => {
1693
+ c == null ? void 0 : c.text(topic.id, event.currentTarget.value);
1694
+ composing.current = false;
1695
+ c == null ? void 0 : c.composition(false);
1696
+ c == null ? void 0 : c.beginText(topic.id);
1697
+ },
1698
+ onKeyDown: (event) => {
1699
+ event.stopPropagation();
1700
+ if (event.nativeEvent.isComposing || composing.current || event.keyCode === 229) return;
1701
+ if ((event.metaKey || event.ctrlKey) && ["z", "y"].includes(event.key.toLowerCase())) {
1702
+ event.preventDefault();
1703
+ event.shiftKey || event.key.toLowerCase() === "y" ? c == null ? void 0 : c.redo() : c == null ? void 0 : c.undo();
1704
+ return;
1705
+ }
1706
+ if (event.key === "Escape" || event.key === "Enter" && !event.shiftKey) {
1707
+ event.preventDefault();
1708
+ edit(null);
1709
+ } else if (event.key === "Tab") {
1710
+ event.preventDefault();
1711
+ c == null ? void 0 : c.endText(topic.id);
1712
+ add("child", void 0, topic.id);
1713
+ }
1714
+ },
1715
+ onBlur: () => {
1716
+ c == null ? void 0 : c.composition(false);
1717
+ c == null ? void 0 : c.endText(topic.id);
1718
+ setEditing(null);
1719
+ }
1720
+ }
1721
+ ) : /* @__PURE__ */ jsx("div", { className: "mind-topic-label", style: { textAlign: topic.align || "center", minHeight: topic.lines.length * mindTopicLineHeight(topic.fontSize || 14) }, children: /* @__PURE__ */ jsx(TopicLabel, { topic }) }),
1722
+ topic.description && /* @__PURE__ */ jsx("div", { className: "mind-topic-description", style: topic.shape === "text" ? { color: "var(--color-text-muted)" } : topic.background ? { color: readableTextColor(topic.background) } : void 0, children: topic.description }),
1723
+ topic.note && /* @__PURE__ */ jsx("div", { className: "mind-topic-note", title: "此主题有备注", onClick: (event) => {
1724
+ event.stopPropagation();
1725
+ select(topic.id);
1726
+ setDetails(true);
1727
+ }, children: "▤ 备注" }),
1728
+ topic.attachmentId && /* @__PURE__ */ jsx("div", { className: "mind-topic-image", children: /* @__PURE__ */ jsx(AttachmentImage, { id: topic.attachmentId, alt: "主题图片", fetcher: props.fetchAttachment }) }),
1729
+ peers.filter((peer) => peer.topicId === topic.id).map((peer) => /* @__PURE__ */ jsx("span", { className: "mind-peer-badge", title: `${peer.name}${peer.editing ? " 正在编辑" : ""}`, "aria-label": `${peer.name}${peer.editing ? " 正在编辑此主题" : " 正在查看此主题"}`, children: peer.name.slice(0, 2) }, peer.client))
1730
+ ]
1731
+ }
1732
+ ),
1733
+ quick && topic.id !== model.rootId && /* @__PURE__ */ jsx(
1734
+ "button",
1735
+ {
1736
+ type: "button",
1737
+ className: "mind-topic-sibling before",
1738
+ "aria-label": model.layout === "down" ? "在左侧添加同级主题" : "在上方添加同级主题",
1739
+ title: model.layout === "down" ? "在左侧添加同级主题" : "在上方添加同级主题",
1740
+ onPointerDown: (event) => event.stopPropagation(),
1741
+ onClick: (event) => {
1742
+ event.stopPropagation();
1743
+ addSiblingAt(topic.id, "before");
1744
+ },
1745
+ children: /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "+" })
1746
+ }
1747
+ ),
1748
+ quick && topic.id === model.rootId && model.layout !== "down" && /* @__PURE__ */ jsxs(Fragment, { children: [
1749
+ /* @__PURE__ */ jsx(
1750
+ "button",
1751
+ {
1752
+ type: "button",
1753
+ className: "mind-topic-add root-left",
1754
+ "aria-label": "在中心主题左侧添加子主题",
1755
+ title: "在左侧添加子主题",
1756
+ onPointerDown: (event) => event.stopPropagation(),
1757
+ onClick: (event) => {
1758
+ event.stopPropagation();
1759
+ add("child", -1);
1760
+ },
1761
+ children: "+"
1762
+ }
1763
+ ),
1764
+ /* @__PURE__ */ jsx(
1765
+ "button",
1766
+ {
1767
+ type: "button",
1768
+ className: "mind-topic-add root-right",
1769
+ "aria-label": "在中心主题右侧添加子主题",
1770
+ title: "在右侧添加子主题",
1771
+ onPointerDown: (event) => event.stopPropagation(),
1772
+ onClick: (event) => {
1773
+ event.stopPropagation();
1774
+ add("child", 1);
1775
+ },
1776
+ children: "+"
1777
+ }
1778
+ )
1779
+ ] }),
1780
+ quick && (topic.id !== model.rootId || model.layout === "down") && /* @__PURE__ */ jsx(
1781
+ "button",
1782
+ {
1783
+ type: "button",
1784
+ className: "mind-topic-add",
1785
+ "aria-label": "为当前主题添加子主题",
1786
+ title: "添加子主题",
1787
+ onPointerDown: (event) => event.stopPropagation(),
1788
+ onClick: (event) => {
1789
+ event.stopPropagation();
1790
+ add("child");
1791
+ },
1792
+ children: "+"
1793
+ }
1794
+ ),
1795
+ quick && topic.id !== model.rootId && /* @__PURE__ */ jsx(
1796
+ "button",
1797
+ {
1798
+ type: "button",
1799
+ className: "mind-topic-sibling after",
1800
+ "aria-label": model.layout === "down" ? "在右侧添加同级主题" : "在下方添加同级主题",
1801
+ title: model.layout === "down" ? "在右侧添加同级主题" : "在下方添加同级主题",
1802
+ onPointerDown: (event) => event.stopPropagation(),
1803
+ onClick: (event) => {
1804
+ event.stopPropagation();
1805
+ addSiblingAt(topic.id, "after");
1806
+ },
1807
+ children: /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "+" })
1808
+ }
1809
+ ),
1810
+ hasChildren && topic.id !== model.rootId && editing !== topic.id && /* @__PURE__ */ jsx(
1811
+ "button",
1812
+ {
1813
+ type: "button",
1814
+ className: "mind-topic-fold",
1815
+ "aria-label": folds.has(topic.id) ? `展开分支:${topic.text}(隐藏 ${mindMapDescendants$1(model, topic.id).size - 1} 个主题)` : `收起分支:${topic.text}`,
1816
+ title: folds.has(topic.id) ? `展开分支,共 ${mindMapDescendants$1(model, topic.id).size - 1} 个后代主题` : "收起子分支",
1817
+ "aria-expanded": !folds.has(topic.id),
1818
+ onClick: (event) => {
1819
+ event.stopPropagation();
1820
+ fold(topic.id);
1821
+ },
1822
+ children: folds.has(topic.id) ? /* @__PURE__ */ jsx("span", { className: "mind-fold-count", children: mindMapDescendants$1(model, topic.id).size - 1 }) : /* @__PURE__ */ jsx("svg", { className: "mind-fold-chevron", width: "14", height: "14", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "m10 4-4 4 4 4", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) })
1823
+ }
1824
+ )
1825
+ ]
1826
+ },
1827
+ topic.id
1828
+ );
1829
+ })
1830
+ ] }) }),
1831
+ box && /* @__PURE__ */ jsx("div", { className: "mind-marquee", "aria-hidden": "true", style: {
1832
+ left: origin.x + box.x * zoom,
1833
+ top: origin.y + box.y * zoom,
1834
+ width: box.w * zoom,
1835
+ height: box.h * zoom
1836
+ } }),
1837
+ editable && selected.size === 1 && !editing && !dragPreview && !box && /* @__PURE__ */ jsxs("div", { className: "mind-node-actions", "aria-label": "主题操作", children: [
1838
+ /* @__PURE__ */ jsx(WButton, { variant: "primary", onClick: () => add("child"), children: "+ 子主题" }),
1839
+ /* @__PURE__ */ jsx(WButton, { onClick: () => add("sibling"), children: "同级主题" }),
1840
+ /* @__PURE__ */ jsx(WButton, { disabled: active === model.rootId, onClick: () => add("parent"), children: "父主题" }),
1841
+ /* @__PURE__ */ jsx(WDropdown, { label: "调整层级", groups: [
1842
+ { items: [{ value: "out", label: "提升一级" }, { value: "in", label: "缩进一级" }] },
1843
+ ...firstLevel && model.layout !== "down" ? [{ title: "分支方向", items: [
1844
+ { value: "left", label: "移到左侧", disabled: directions.get(active) === -1 },
1845
+ { value: "right", label: "移到右侧", disabled: directions.get(active) === 1 }
1846
+ ] }] : []
1847
+ ], onSelect: (value) => value === "left" ? moveSide(-1) : value === "right" ? moveSide(1) : c == null ? void 0 : c.indent(active, value === "out") }),
1848
+ /* @__PURE__ */ jsx(WButton, { onClick: () => edit(active), children: "改名" }),
1849
+ /* @__PURE__ */ jsx(WButton, { onClick: () => copy(), children: "复制" }),
1850
+ /* @__PURE__ */ jsx(WButton, { loading: pasting, onClick: () => void paste(), children: "粘贴" }),
1851
+ host.comments && pageId && /* @__PURE__ */ jsx(WButton, { variant: comments ? "primary" : "default", "aria-pressed": comments, "aria-label": "主题讨论", onClick: () => {
1852
+ setComments(!comments);
1853
+ setDetails(false);
1854
+ }, children: "讨论" }),
1855
+ /* @__PURE__ */ jsx(WButton, { disabled: active === model.rootId, title: "删除主题(Delete / Backspace)", onClick: () => remove(), children: "删除" })
1856
+ ] }),
1857
+ selected.size > 1 && /* @__PURE__ */ jsxs("div", { className: "mind-selection-summary", role: "status", children: [
1858
+ "已选择 ",
1859
+ selected.size,
1860
+ " 个主题",
1861
+ editable && /* @__PURE__ */ jsx(WButton, { title: "删除所选主题(Delete / Backspace)", onClick: () => remove(), children: "删除所选" }),
1862
+ /* @__PURE__ */ jsx(WButton, { variant: "text", onClick: () => setSelected(/* @__PURE__ */ new Set()), children: "取消选择" })
1863
+ ] }),
1864
+ /* @__PURE__ */ jsxs("div", { className: "mind-canvas-bottom", children: [
1865
+ /* @__PURE__ */ jsxs("span", { className: "mind-canvas-hint", children: [
1866
+ moving ? "移动模式:左键拖动画布" : "选择模式:左键选择 / 空白处框选",
1867
+ " · 中键或空格+拖动平移 · 双指平移 / 捏合缩放 · 右键菜单"
1868
+ ] }),
1869
+ /* @__PURE__ */ jsxs("div", { className: "mind-canvas-viewport", children: [
1870
+ editable && /* @__PURE__ */ jsxs(Fragment, { children: [
1871
+ /* @__PURE__ */ jsx(WButton, { disabled: !(c == null ? void 0 : c.canUndo()), onClick: () => c == null ? void 0 : c.undo(), children: "撤销" }),
1872
+ /* @__PURE__ */ jsx(WButton, { disabled: !(c == null ? void 0 : c.canRedo()), onClick: () => c == null ? void 0 : c.redo(), children: "重做" })
1873
+ ] }),
1874
+ /* @__PURE__ */ jsx("span", { className: "mind-viewport-divider", "aria-hidden": "true" }),
1875
+ /* @__PURE__ */ jsx(WTooltip, { content: /* @__PURE__ */ jsxs("span", { className: "mind-viewport-tip", children: [
1876
+ moving ? "切换为选择模式,左键点选或拖动框选" : "切换为移动模式,左键拖动画布",
1877
+ /* @__PURE__ */ jsx("kbd", { children: "中键拖动" }),
1878
+ /* @__PURE__ */ jsx("kbd", { children: "空格+拖动" }),
1879
+ /* @__PURE__ */ jsx("kbd", { children: "双指平移" })
1880
+ ] }), children: /* @__PURE__ */ jsx(WButton, { variant: moving ? "primary" : "text", "aria-pressed": moving, "aria-label": moving ? "切换为选择模式" : "切换为移动模式", onClick: () => {
1881
+ var _a2;
1882
+ setMoving(!moving);
1883
+ edit(null);
1884
+ cancelGesture();
1885
+ setFollowing(null);
1886
+ (_a2 = stage.current) == null ? void 0 : _a2.focus();
1887
+ }, children: moving ? /* @__PURE__ */ jsx("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.7", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M8 12V5a1.5 1.5 0 0 1 3 0v6-8a1.5 1.5 0 0 1 3 0v8-6a1.5 1.5 0 0 1 3 0v7-4a1.5 1.5 0 0 1 3 0v7c0 5-3 7-7 7-3 0-5-2-7-5l-3-5a1.5 1.5 0 0 1 2.5-1.6L8 14" }) }) : /* @__PURE__ */ jsx("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.7", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "m5 3 14 10-7 1-3 7z" }) }) }) }),
1888
+ /* @__PURE__ */ jsx(WTooltip, { content: /* @__PURE__ */ jsxs("span", { className: "mind-viewport-tip", children: [
1889
+ "缩小 ",
1890
+ /* @__PURE__ */ jsxs("kbd", { children: [
1891
+ modifier,
1892
+ " −"
1893
+ ] }),
1894
+ /* @__PURE__ */ jsxs("kbd", { children: [
1895
+ modifier,
1896
+ "+鼠标滚轮"
1897
+ ] }),
1898
+ /* @__PURE__ */ jsx("kbd", { children: "捏合手势" })
1899
+ ] }), children: /* @__PURE__ */ jsx(WButton, { "aria-label": "缩小导图", onClick: () => paneCommand("zoom-out"), children: "−" }) }),
1900
+ /* @__PURE__ */ jsx(WTooltip, { content: /* @__PURE__ */ jsxs("span", { className: "mind-viewport-tip", children: [
1901
+ "缩放至 100% ",
1902
+ /* @__PURE__ */ jsxs("kbd", { children: [
1903
+ modifier,
1904
+ " 0"
1905
+ ] })
1906
+ ] }), children: /* @__PURE__ */ jsxs(WButton, { variant: "text", "aria-label": "缩放至 100%", className: "mind-zoom-percent", onClick: () => paneCommand("reset-zoom"), children: [
1907
+ Math.round(zoom * 100),
1908
+ "%"
1909
+ ] }) }),
1910
+ /* @__PURE__ */ jsx(WTooltip, { content: /* @__PURE__ */ jsxs("span", { className: "mind-viewport-tip", children: [
1911
+ "放大 ",
1912
+ /* @__PURE__ */ jsxs("kbd", { children: [
1913
+ modifier,
1914
+ " +"
1915
+ ] }),
1916
+ /* @__PURE__ */ jsxs("kbd", { children: [
1917
+ modifier,
1918
+ "+鼠标滚轮"
1919
+ ] }),
1920
+ /* @__PURE__ */ jsx("kbd", { children: "捏合手势" })
1921
+ ] }), children: /* @__PURE__ */ jsx(WButton, { "aria-label": "放大导图", onClick: () => paneCommand("zoom-in"), children: "+" }) }),
1922
+ /* @__PURE__ */ jsx(WTooltip, { content: /* @__PURE__ */ jsxs("span", { className: "mind-viewport-tip", children: [
1923
+ "画布全览 ",
1924
+ /* @__PURE__ */ jsx("kbd", { children: "Shift+1" })
1925
+ ] }), children: /* @__PURE__ */ jsx(WButton, { onClick: () => paneCommand("fit"), children: "适应画布" }) })
1926
+ ] })
1927
+ ] }),
1928
+ (notice || drop) && /* @__PURE__ */ jsx("p", { className: "mind-canvas-notice", role: "status", children: drop ? drop.kind === "side" ? `松开后移到中心主题${drop.side === -1 ? "左" : "右"}侧,保留整条子分支` : `松开后${drop.mode === "child" ? "移入目标主题" : drop.mode === "before" ? "放到目标上方" : "放到目标下方"}` : notice })
1929
+ ]
1930
+ }
1931
+ ),
1932
+ comments && pageId && host.comments && /* @__PURE__ */ jsx(
1933
+ MindMapComments,
1934
+ {
1935
+ pageId,
1936
+ blockId: model.id,
1937
+ topicId: active,
1938
+ topicLabel: current.text,
1939
+ canComment: props.canComment ?? ((_g = c == null ? void 0 : (_f = c.context).canComment) == null ? void 0 : _g.call(_f)),
1940
+ onClose: () => setComments(false),
1941
+ onChanged: props.onCommentsChanged
1942
+ },
1943
+ `${pageId}:${model.id}:${active}`
1944
+ ),
1945
+ details && /* @__PURE__ */ jsx(MindMapDetails, { model, id: active, controller: c, range: selectedRange, onClose: () => setDetails(false), onNotice: setNotice }, active)
1946
+ ] }),
1947
+ contextMenu && portal && createPortal(/* @__PURE__ */ jsx("div", { ref: menuRef, className: "mind-context-menu", role: "menu", tabIndex: -1, "aria-label": contextMenu.id ? "主题操作菜单" : "画布操作菜单", onKeyDown: menuKeydown, style: { left: contextMenu.x, top: contextMenu.y }, children: /* @__PURE__ */ jsx("div", { className: "w-dropdown", children: contextGroups.map((group, index) => /* @__PURE__ */ jsxs("div", { className: "w-dropdown-group", role: "group", "aria-label": group.title, children: [
1948
+ group.title && /* @__PURE__ */ jsx("div", { className: "w-dropdown-group__title", children: group.title }),
1949
+ group.items.map((item) => /* @__PURE__ */ jsxs(
1950
+ "div",
1951
+ {
1952
+ role: "menuitem",
1953
+ tabIndex: item.disabled ? void 0 : -1,
1954
+ "aria-disabled": item.disabled || void 0,
1955
+ className: `w-dropdown-option${item.disabled ? " is-disabled" : ""}`,
1956
+ onClick: () => {
1957
+ if (!item.disabled) contextAction(item.value);
1958
+ },
1959
+ onKeyDown: (event) => {
1960
+ if (!item.disabled && (event.key === "Enter" || event.key === " ")) {
1961
+ event.preventDefault();
1962
+ contextAction(item.value);
1963
+ }
1964
+ },
1965
+ children: [
1966
+ item.label,
1967
+ item.shortcut && /* @__PURE__ */ jsx("span", { className: "mind-menu-key", children: item.shortcut })
1968
+ ]
1969
+ },
1970
+ item.value
1971
+ ))
1972
+ ] }, index)) }) }), portal),
1973
+ confirmDelete && /* @__PURE__ */ jsxs(WDialog, { title: "删除分支", onClose: () => {
1974
+ var _a2;
1975
+ setConfirmDelete(null);
1976
+ (_a2 = stage.current) == null ? void 0 : _a2.focus();
1977
+ }, children: [
1978
+ /* @__PURE__ */ jsxs("p", { children: [
1979
+ "将删除 ",
1980
+ confirmDelete.ids.size,
1981
+ " 个主题(包含子主题),可以撤销。中心主题保留。"
1982
+ ] }),
1983
+ /* @__PURE__ */ jsxs("div", { className: "wr-toolbar", children: [
1984
+ /* @__PURE__ */ jsx(WButton, { onClick: () => {
1985
+ var _a2;
1986
+ setConfirmDelete(null);
1987
+ (_a2 = stage.current) == null ? void 0 : _a2.focus();
1988
+ }, children: "取消" }),
1989
+ /* @__PURE__ */ jsx(WButton, { variant: "primary", onClick: () => performDelete(confirmDelete), children: "删除分支" })
1990
+ ] })
1991
+ ] }),
1992
+ importOpen && /* @__PURE__ */ jsxs(WDialog, { title: "导入导图或列表", onClose: () => setImportOpen(false), footer: /* @__PURE__ */ jsxs(Fragment, { children: [
1993
+ /* @__PURE__ */ jsx(WButton, { onClick: () => setImportOpen(false), children: "取消" }),
1994
+ /* @__PURE__ */ jsx(WButton, { variant: "primary", loading: pasting, disabled: !importPreview, onClick: () => {
1995
+ if (pastingRef.current || !importPreview) return;
1996
+ pastingRef.current = true;
1997
+ setPasting(true);
1998
+ setImportError("");
1999
+ void (async () => {
2000
+ try {
2001
+ await insertBranch(importBranch(importPreview), active);
2002
+ if (alive.current) setImportOpen(false);
2003
+ } catch (error) {
2004
+ if (alive.current) setImportError(error instanceof Error ? error.message : "导入失败");
2005
+ } finally {
2006
+ pastingRef.current = false;
2007
+ if (alive.current) setPasting(false);
2008
+ }
2009
+ })();
2010
+ }, children: "导入分支" })
2011
+ ] }), children: [
2012
+ /* @__PURE__ */ jsx("p", { className: "mind-import-hint", children: "导入为当前主题的子分支;支持 JSON 和缩进列表。不会替换现有导图。" }),
2013
+ /* @__PURE__ */ jsx("input", { "aria-label": "选择导图文件", type: "file", accept: ".json,.md,.txt", onChange: (event) => {
2014
+ var _a2;
2015
+ const file = (_a2 = event.target.files) == null ? void 0 : _a2[0];
2016
+ if (!file) return;
2017
+ if (file.size > 2e6) {
2018
+ setImportError("文件超过 2 MB");
2019
+ return;
2020
+ }
2021
+ void file.text().then((value) => {
2022
+ if (alive.current) {
2023
+ setImportText(value);
2024
+ setImportError("");
2025
+ }
2026
+ }).catch(() => {
2027
+ if (alive.current) setImportError("文件读取失败");
2028
+ });
2029
+ } }),
2030
+ /* @__PURE__ */ jsx("textarea", { "aria-label": "导入内容", rows: 10, placeholder: "粘贴缩进列表或导图 JSON", style: { marginTop: 12 }, value: importText, onChange: (event) => {
2031
+ setImportText(event.target.value);
2032
+ setImportError("");
2033
+ } }),
2034
+ importPreview && /* @__PURE__ */ jsxs("p", { children: [
2035
+ "识别到 ",
2036
+ importPreview.topics.length,
2037
+ " 个主题"
2038
+ ] }),
2039
+ importError && /* @__PURE__ */ jsx("p", { role: "alert", children: importError }),
2040
+ /* @__PURE__ */ jsx("div", { className: "wr-toolbar", children: ["project", "meeting", "knowledge"].map((kind, index) => /* @__PURE__ */ jsx(WButton, { onClick: () => {
2041
+ const id = c == null ? void 0 : c.pasteBranch(active, importBranch(mindMapTemplate(kind)));
2042
+ if (id) {
2043
+ select(id);
2044
+ setImportOpen(false);
2045
+ }
2046
+ }, children: ["项目模板", "会议模板", "知识模板"][index] }, kind)) })
2047
+ ] })
2048
+ ] });
2049
+ return props.inline ? /* @__PURE__ */ jsx("section", { className: "mind-canvas-shell mind-inline", children: workspace }) : /* @__PURE__ */ jsx(
2050
+ WDialog,
2051
+ {
2052
+ workspace: true,
2053
+ fullscreen: true,
2054
+ hideFooter: true,
2055
+ className: "mind-canvas-shell mind-canvas-fullscreen",
2056
+ ariaLabel: "思维导图",
2057
+ title: /* @__PURE__ */ jsxs("span", { className: "mind-canvas-title", children: [
2058
+ "思维导图 ",
2059
+ /* @__PURE__ */ jsx("span", { children: title })
2060
+ ] }),
2061
+ escToClose: !editing && !contextMenu && !settingsOpen && !importOpen && !confirmDelete,
2062
+ onClose: () => {
2063
+ var _a2;
2064
+ return (_a2 = props.onClose) == null ? void 0 : _a2.call(props);
2065
+ },
2066
+ children: workspace
2067
+ }
2068
+ );
2069
+ }
2070
+ export {
2071
+ MindMapCanvas
2072
+ };